diff options
Diffstat (limited to 'vim/ftplugin')
-rw-r--r-- | vim/ftplugin/html.vim | 6 | ||||
-rw-r--r-- | vim/ftplugin/mail.vim | 2 | ||||
-rw-r--r-- | vim/ftplugin/markdown.vim | 6 | ||||
-rw-r--r-- | vim/ftplugin/perl.vim | 6 | ||||
-rw-r--r-- | vim/ftplugin/sh.vim | 65 | ||||
-rw-r--r-- | vim/ftplugin/text.vim | 6 | ||||
-rw-r--r-- | vim/ftplugin/vim.vim | 4 |
7 files changed, 59 insertions, 36 deletions
diff --git a/vim/ftplugin/html.vim b/vim/ftplugin/html.vim index 3db5dcca..d2c6a3e3 100644 --- a/vim/ftplugin/html.vim +++ b/vim/ftplugin/html.vim @@ -28,3 +28,9 @@ endfunction nnoremap <buffer> <silent> \ <LocalLeader>r \ :<C-U>call <SID>UrlLink()<CR> + +" Unload this filetype plugin +let b:undo_user_ftplugin + \ = 'silent! nunmap <LocalLeader>c' + \ . '|silent! nunmap <LocalLeader>t' + \ . '|silent! nunmap <LocalLeader>r' diff --git a/vim/ftplugin/mail.vim b/vim/ftplugin/mail.vim index d4840bfd..697ce499 100644 --- a/vim/ftplugin/mail.vim +++ b/vim/ftplugin/mail.vim @@ -1,4 +1,6 @@ " Use trailing whitespace to denote continued paragraph setlocal formatoptions+=w + +" Unload this filetype plugin let b:undo_user_ftplugin \ = 'setlocal formatoptions<' diff --git a/vim/ftplugin/markdown.vim b/vim/ftplugin/markdown.vim index ab27c2f7..f26fb156 100644 --- a/vim/ftplugin/markdown.vim +++ b/vim/ftplugin/markdown.vim @@ -1,6 +1,8 @@ " Spellcheck documents by default if has('syntax') setlocal spell - let b:undo_user_ftplugin - \ = 'setlocal spell<' endif + +" Unload this filetype plugin +let b:undo_user_ftplugin + \ = 'silent! setlocal spell<' diff --git a/vim/ftplugin/perl.vim b/vim/ftplugin/perl.vim index 07cf9a1f..c18653d2 100644 --- a/vim/ftplugin/perl.vim +++ b/vim/ftplugin/perl.vim @@ -12,3 +12,9 @@ nnoremap <buffer> <silent> nnoremap <buffer> <silent> \ <LocalLeader>t \ :<C-U>%!perltidy<CR> + +" Unload this filetype plugin +let l:undo_user_ftplugin + \ = 'silent! nunmap <LocalLeader>c' + \ . '|silent! nunmap <LocalLeader>l' + \ . '|silent! nunmap <LocalLeader>t' diff --git a/vim/ftplugin/sh.vim b/vim/ftplugin/sh.vim index 21d494e3..60e8b6c4 100644 --- a/vim/ftplugin/sh.vim +++ b/vim/ftplugin/sh.vim @@ -1,52 +1,53 @@ -" Default to POSIX shell, as I never write Bourne, and if I write Bash or Ksh -" it'll be denoted with either a shebang or an appropriate extension. -let g:is_posix = 1 - -" -" Setting g:is_posix above also prompts Vim's core syntax/sh.vim script to -" set g:is_kornshell and thereby b:is_kornshell to the same value as g:is_posix. " -" That's very confusing, so before it happens we'll copy b:is_kornshell's -" value as determined by filetype.vim and ~/.vim/ftdetect/sh.vim into a custom -" variable b:is_ksh, before its meaning gets confused. +" If we have a #!/bin/sh shebang and filetype.vim determined we were neither +" POSIX nor Bash nor Korn shell, we'll guess POSIX, just because it's far more +" likely that's what I want to write than plain Bourne shell. " -" b:is_ksh as a name is more inline with b:is_bash and b:is_sh, anyway, so -" we'll just treat b:is_kornshell like it's both misnamed and broken. +" You're supposed to be able to do this by setting g:is_posix, but if that's +" set, the syntax file ends up setting g:is_kornshell for you too, for reasons +" I don't really understand. This method works though, and is cleaner than +" the other workaround I had been trying. " -" We can then switch on our custom variable in ~/.vim/after/syntax/sh.vim to -" apply settings that actually *are* unique to Korn shell and its derivatives. -" -if exists('b:is_kornshell') - let b:is_ksh = b:is_kornshell +if exists('b:is_sh') + unlet b:is_sh + if !exists('b:is_bash') && !exists('b:is_kornshell') + let b:is_posix = 1 + endif endif " Use han(1df) as a man(1) wrapper for Bash files if available -if exists('b:is_bash') && executable('han') +if exists('b:is_bash') + \ && executable('han') setlocal keywordprg=han - let b:undo_user_indent - \ = 'setlocal keywordprg<' endif " Map checker based on shell family -if exists('b:is_bash') && b:is_bash - let b:check = 'write !bash -n' -elseif exists('b:is_ksh') && b:is_ksh - let b:check = 'write !ksh -n' +if exists('b:is_bash') + let b:sh_check = 'write !bash -n' +elseif exists('b:is_kornshell') + let b:sh_check = 'write !ksh -n' else - let b:check = 'write !sh -n' + let b:sh_check = 'write !sh -n' endif nnoremap <buffer> <silent> \ <LocalLeader>c - \ :<C-U>execute b:check<CR> + \ :<C-U>execute b:sh_check<CR> " Map linter based on shell family -if exists('b:is_bash') && b:is_bash - let b:lint = 'write !shellcheck -s bash -' -elseif exists('b:is_ksh') && b:is_ksh - let b:lint = 'write !shellcheck -s ksh -' +if exists('b:is_bash') + let b:sh_lint = 'write !shellcheck -s bash -' +elseif exists('b:is_kornshell') + let b:sh_lint = 'write !shellcheck -s ksh -' else - let b:lint = 'write !shellcheck -s sh -' + let b:sh_lint = 'write !shellcheck -s sh -' endif nnoremap <buffer> <silent> \ <LocalLeader>l - \ :<C-U>execute b:lint<CR> + \ :<C-U>execute b:sh_lint<CR> + +" Unload this filetype plugin +let b:undo_user_ftplugin + \ = 'setlocal keywordprg<' + \ . '|unlet! b:sh_check b:sh_lint' + \ . '|silent! nunmap <LocalLeader>c' + \ . '|silent! nunmap <LocalLeader>l' diff --git a/vim/ftplugin/text.vim b/vim/ftplugin/text.vim index ab27c2f7..f26fb156 100644 --- a/vim/ftplugin/text.vim +++ b/vim/ftplugin/text.vim @@ -1,6 +1,8 @@ " Spellcheck documents by default if has('syntax') setlocal spell - let b:undo_user_ftplugin - \ = 'setlocal spell<' endif + +" Unload this filetype plugin +let b:undo_user_ftplugin + \ = 'silent! setlocal spell<' diff --git a/vim/ftplugin/vim.vim b/vim/ftplugin/vim.vim index d4e55ace..e8113134 100644 --- a/vim/ftplugin/vim.vim +++ b/vim/ftplugin/vim.vim @@ -4,3 +4,7 @@ nnoremap <buffer> <silent> \ <LocalLeader>l \ :<C-U>write !vint -s /dev/stdin<CR> + +" Unload this filetype plugin +let b:undo_user_ftplugin + \ = 'silent! nunmap <LocalLeader>l' |