Commits

Meikel Brandmeyer committed 646b27c

Cleanup CheckForString in indent

Comments (0)

Files changed (1)

vim/indent/clojure.vim

 				\ a:stopat)
 endfunction
 
-function! VimClojureCheckForStringWorker()
-	" Check whether there is the last character of the previous line is
-	" highlighted as a string. If so, we check whether it's a ". In this
-	" case we have to check also the previous character. The " might be the
-	" closing one. In case the we are still in the string, we search for the
-	" opening ". If this is not found we take the indent of the line.
-	let nb = prevnonblank(v:lnum - 1)
+function! s:CheckForString()
+	let closure = {}
 
-	if nb == 0
-		return -1
-	endif
+	function closure.f() dict
+		" Check whether there is the last character of the previous line is
+		" highlighted as a string. If so, we check whether it's a ". In this
+		" case we have to check also the previous character. The " might be the
+		" closing one. In case the we are still in the string, we search for the
+		" opening ". If this is not found we take the indent of the line.
+		let nb = prevnonblank(v:lnum - 1)
 
-	call cursor(nb, 0)
-	call cursor(0, col("$") - 1)
-	if vimclojure#util#SynIdName() != "clojureString"
-		return -1
-	endif
+		if nb == 0
+			return -1
+		endif
 
-	" This will not work for a " in the first column...
-	if vimclojure#util#Yank('l', 'normal! "lyl') == '"'
-		call cursor(0, col("$") - 2)
+		call cursor(nb, 0)
+		call cursor(0, col("$") - 1)
 		if vimclojure#util#SynIdName() != "clojureString"
 			return -1
 		endif
-		if vimclojure#util#Yank('l', 'normal! "lyl') != '\\'
-			return -1
+
+		" This will not work for a " in the first column...
+		if vimclojure#util#Yank('l', 'normal! "lyl') == '"'
+			call cursor(0, col("$") - 2)
+			if vimclojure#util#SynIdName() != "clojureString"
+				return -1
+			endif
+			if vimclojure#util#Yank('l', 'normal! "lyl') != '\\'
+				return -1
+			endif
+			call cursor(0, col("$") - 1)
 		endif
-		call cursor(0, col("$") - 1)
-	endif
 
-	let p = searchpos('\(^\|[^\\]\)\zs"', 'bW')
+		let p = searchpos('\(^\|[^\\]\)\zs"', 'bW')
 
-	if p != [0, 0]
-		return p[1] - 1
-	endif
+		if p != [0, 0]
+			return p[1] - 1
+		endif
 
-	return indent(".")
-endfunction
+		return indent(".")
+	endfunction
 
-function! VimClojureCheckForString()
-	return vimclojure#util#WithSavedPosition({'f': function("VimClojureCheckForStringWorker")})
+	return vimclojure#util#WithSavedPosition(closure)
 endfunction
 
 function! s:IsMethodSpecialCase(position)
 
 	" We have to apply some heuristics here to figure out, whether to use
 	" normal lisp indenting or not.
-	let i = VimClojureCheckForString()
+	let i = s:CheckForString()
 	if i > -1
 		return i
 	endif
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.