Skip to content

Commit 6541a8a

Browse files
committed
Refactor ftplugin
* The dashed lists feature in comments did not work with nested comment leaders (as are common in Lisp), so it was removed * Add 'regex' to b:match_skip * unlet! buffer variables in b:undo_ftplugin
1 parent ad0a76a commit 6541a8a

1 file changed

Lines changed: 19 additions & 18 deletions

File tree

ftplugin/clojure.vim

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ set cpo&vim
1616

1717
let b:undo_ftplugin = 'setlocal define< formatoptions< comments< commentstring< complete<'
1818

19-
" There will be false positives, but this is arguably better than missing the
20-
" whole set of user-defined def* definitions.
19+
" There will be false positives, but this is better than missing the whole set
20+
" of user-defined def* definitions.
2121
setlocal define=\\v[(/]def(ault)@!\\S*
2222

23-
" Set 'formatoptions' to break comment lines but not other lines,
24-
" and insert the comment leader when hitting <CR> or using "o".
23+
" Remove 't' from 'formatoptions' to avoid auto-wrapping code. The '+=croql'
24+
" is standard ftplugin boilerplate, although it is arguably intrusive.
2525
setlocal formatoptions-=t formatoptions+=croql
2626

27-
" Set 'comments' to format dashed lists in comments.
28-
setlocal comments=sO:;\ -,mO:;\ \ ,n:;
29-
setlocal commentstring=;%s
27+
" Lisp comments are routinely nested (e.g. ;;; SECTION HEADING)
28+
setlocal comments=n:;
29+
setlocal commentstring=;\ %s
3030

3131
function! s:escape_path_for_option(path)
3232
let path = fnameescape(a:path)
@@ -36,8 +36,7 @@ function! s:escape_path_for_option(path)
3636
return path
3737
endfunction
3838

39-
" Provide insert mode completions for special forms and public vars in
40-
" clojure.core
39+
" Provide insert mode completions for special forms and clojure.core
4140
for s:compfile in split(globpath(&rtp, "ftplugin/clojure/*.txt"), '\n')
4241
execute 'setlocal complete+=k' . s:escape_path_for_option(s:compfile)
4342
endfor
@@ -46,25 +45,27 @@ endfor
4645
" and add them to the path option.
4746
"
4847
" This is a legacy option for VimClojure users.
49-
let s:delim = (has("win32") || has("win64")) ? ';' : ':'
50-
for s:dir in split($CLOJURE_SOURCE_DIRS, s:delim)
51-
execute "setlocal path+=" . s:escape_path_for_option(s:dir . "/**")
52-
endfor
5348
if exists('$CLOJURE_SOURCE_DIRS')
54-
let b:undo_ftplugin .= '| setlocal path<'
49+
for s:dir in split($CLOJURE_SOURCE_DIRS, (has("win32") || has("win64")) ? ';' : ':')
50+
execute "setlocal path+=" . s:escape_path_for_option(s:dir . "/**")
51+
endfor
52+
let b:undo_ftplugin .= ' | setlocal path<'
5553
endif
5654

57-
" When the matchit plugin is loaded, this makes the % command skip parens and
58-
" braces in comments.
59-
let b:match_words = &matchpairs
60-
let b:match_skip = 's:comment\|string\|character'
55+
" Skip brackets in ignored syntax regions when using the % command
56+
if exists('loaded_matchit')
57+
let b:match_words = &matchpairs
58+
let b:match_skip = 's:comment\|string\|regex\|character'
59+
let b:undo_ftplugin .= ' | unlet! b:match_words b:match_skip'
60+
endif
6161

6262
" Win32 can filter files in the browse dialog
6363
if has("gui_win32") && !exists("b:browsefilter")
6464
let b:browsefilter = "Clojure Source Files (*.clj)\t*.clj\n" .
6565
\ "ClojureScript Source Files (*.cljs)\t*.cljs\n" .
6666
\ "Java Source Files (*.java)\t*.java\n" .
6767
\ "All Files (*.*)\t*.*\n"
68+
let b:undo_ftplugin .= ' | unlet! b:browsefilter'
6869
endif
6970

7071
delfunction s:escape_path_for_option

0 commit comments

Comments
 (0)