Commits

Meikel Brandmeyer committed 77f0a8b

Allow custom fuzzy indent patterns (idea by Oskar Kvist)

Comments (0)

Files changed (3)

vim/autoload/vimclojure.vim

 	let vimclojure#FuzzyIndent = 0
 endif
 
+if !exists("g:vimclojure#FuzzyIndentPatterns")
+	let vimclojure#FuzzyIndentPatterns = "with.*,def.*,let.*"
+endif
+
 if !exists("g:vimclojure#HighlightBuiltins")
 	if exists("g:clj_highlight_builtins")
 		call vimclojure#WarnDeprecated("g:clj_highlight_builtins",

vim/doc/clojure.txt

 pattern like "defsomething" or "with-something".
 
 By setting the fuzzy indent option, you can tell VimClojure, that you
-want names beginning in "def" or "with" to be indented as if they
+want names matching a fuzzy indent pattern to be indented as if they
 were included in the 'lispwords' option.
 >
         let vimclojure#FuzzyIndent = 1
 <
 This option is disabled by default.
 
+Custom fuzzy indent patterns may be specified as normal regular expressions
+in the corresponding option. The patterns are matched against the leading
+symbol of the form in a way to ignore namespace aliases. The default
+patterns are “def.*”, “with.*” and “let.*”.
+
+For example, consider working a lot with core.logic. Then you may specify
+eg. “fresh” in .vim/after/ftplugin/clojure.vim.
+>
+        let vimclojure#FuzzyIndentPatterns .= ",fresh"
+<
+Note: this is a normal variable. So you have to use “.=” rather than
+“+=” and the comma separator has to be given explicitly.
+
 To be able to properly indent a given line there is some searching
 necessary to determine the surroundings of the cursor. In big files
 this my result in a slow down when entering a new line. So there is

vim/indent/clojure.vim

 	if g:vimclojure#FuzzyIndent
 				\ && w != 'with-meta'
 				\ && w != 'clojure.core/with-meta'
-				\ && w =~ '\(^\|/\)\(def\|with\|let\)'
-				\ && w !~ '\(^\|/\)\(def\|with\).*\*$'
-				\ && w !~ '\(^\|/\)\(def\|with\).*-fn$'
-		return paren[1] + &shiftwidth - 1
+		for pat in split(g:vimclojure#FuzzyIndentPatterns, ",")
+			if w =~ '\(^\|/\)' . pat . '$'
+						\ && w !~ '\(^\|/\)' . pat . '\*$'
+						\ && w !~ '\(^\|/\)' . pat . '-fn$'
+				return paren[1] + &shiftwidth - 1
+			endif
+		endfor
 	endif
 
 	normal! w