Skip to content

Commit 45cf3a5

Browse files
committed
Set undo_ftplugin for remaining filetypes
Also adds the did_ftplugin guard clauses where missing.
1 parent d02e928 commit 45cf3a5

File tree

5 files changed

+42
-12
lines changed

5 files changed

+42
-12
lines changed

ftplugin/oasis.vim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
if exists("b:did_ftplugin")
2+
finish
3+
endif
4+
let b:did_ftplugin=1
15

26
setlocal comments=:#
37
setlocal commentstring=#\ %s
8+
9+
let b:undo_ftplugin = "com< cms<"

ftplugin/ocaml.vim

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ setlocal comments=sr:(*\ ,mb:\ ,ex:*)
4242
setlocal comments^=sr:(**,mb:\ \ ,ex:*)
4343
setlocal commentstring=(*%s*)
4444

45+
let b:undo_ftplugin = "setlocal com< cms<"
46+
4547
" Add mappings, unless the user didn't want this.
4648
if !exists("no_plugin_maps") && !exists("no_ocaml_maps")
4749
" (un)commenting
@@ -50,6 +52,11 @@ if !exists("no_plugin_maps") && !exists("no_ocaml_maps")
5052
xmap <buffer> <LocalLeader>c <Plug>BUncomOn
5153
nmap <buffer> <LocalLeader>C <Plug>LUncomOff
5254
xmap <buffer> <LocalLeader>C <Plug>BUncomOff
55+
let b:undo_ftplugin .=
56+
\ " | silent! execute 'nunmap <buffer> <LocalLeader>c'" .
57+
\ " | silent! execute 'xunmap <buffer> <LocalLeader>c'" .
58+
\ " | silent! execute 'nunmap <buffer> <LocalLeader>C'" .
59+
\ " | silent! execute 'xunmap <buffer> <LocalLeader>C'"
5360
endif
5461

5562
nnoremap <buffer> <Plug>LUncomOn gI(* <End> *)<ESC>
@@ -62,17 +69,27 @@ if !exists("no_plugin_maps") && !exists("no_ocaml_maps")
6269
6370
nmap <buffer> <LocalLeader>t <Plug>OCamlPrintType
6471
xmap <buffer> <LocalLeader>t <Plug>OCamlPrintType
72+
73+
let b:undo_ftplugin .=
74+
\ " | silent! execute 'nunmap <buffer> <LocalLeader>s'" .
75+
\ " | silent! execute 'nunmap <buffer> <LocalLeader>S'" .
76+
\ " | silent! execute 'nunmap <buffer> <LocalLeader>t'" .
77+
\ " | silent! execute 'xunmap <buffer> <LocalLeader>t'"
6578
endif
6679

67-
" Let % jump between structure elements (due to Issac Trotts)
68-
let b:mw = '\<let\>:\<and\>:\(\<in\>\|;;\)'
69-
let b:mw = b:mw . ',\<if\>:\<then\>:\<else\>'
70-
let b:mw = b:mw . ',\<\(for\|while\)\>:\<do\>:\<done\>'
71-
let b:mw = b:mw . ',\<\(object\|sig\|struct\|begin\)\>:\<end\>'
72-
let b:mw = b:mw . ',\<\(match\|try\)\>:\<with\>'
73-
let b:match_words = b:mw
80+
if exists("loaded_matchit") && !exists("b:match_words")
81+
" Let % jump between structure elements (due to Issac Trotts)
82+
let b:mw = '\<let\>:\<and\>:\(\<in\>\|;;\)'
83+
let b:mw = b:mw . ',\<if\>:\<then\>:\<else\>'
84+
let b:mw = b:mw . ',\<\(for\|while\)\>:\<do\>:\<done\>'
85+
let b:mw = b:mw . ',\<\(object\|sig\|struct\|begin\)\>:\<end\>'
86+
let b:mw = b:mw . ',\<\(match\|try\)\>:\<with\>'
87+
let b:match_words = b:mw
88+
89+
let b:match_ignorecase=0
7490

75-
let b:match_ignorecase=0
91+
let b:undo_ftplugin .= " | unlet! b:match_ignorecase b:match_words"
92+
endif
7693

7794
function! s:OcpGrep(bang,args) abort
7895
let grepprg = &l:grepprg
@@ -150,12 +167,9 @@ endif
150167
if exists("g:ocaml_folding")
151168
setlocal foldmethod=expr
152169
setlocal foldexpr=OMLetFoldLevel(v:lnum)
170+
let b:undo_ftplugin .= " | setlocal fdm< fde<"
153171
endif
154172

155-
let b:undo_ftplugin = "setlocal efm< foldmethod< foldexpr<"
156-
\ . "| unlet! b:mw b:match_words b:match_ignorecase"
157-
158-
159173
" - Only definitions below, executed once -------------------------------------
160174

161175
if exists("*OMLetFoldLevel")

ftplugin/ocamlbuild_tags.vim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
if exists("b:did_ftplugin")
2+
finish
3+
endif
4+
let b:did_ftplugin=1
15

26
setlocal comments=:#
37
setlocal commentstring=#\ %s
8+
9+
let b:undo_ftplugin = "com< cms<"

ftplugin/omake.vim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ setlocal expandtab
2222

2323
" Including files.
2424
let &l:include = '^\s*include'
25+
26+
let b:undo_ftplugin = "fo< com< cms< et< inc<"

ftplugin/sexplib.vim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ let b:did_ftplugin=1
1313
" Comment string
1414
setl commentstring=;\ %s
1515
setl comments=n:;
16+
17+
let b:undo_ftplugin = "setl cms< com<"

0 commit comments

Comments
 (0)