diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2018-07-09 01:15:22 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2018-07-09 01:15:22 +1200 |
commit | 950f883d89ca0fa7e80cca8f9a0d8cfbade8ebc3 (patch) | |
tree | 4c1cada051a4d3ebe017d9241e471a95e127725e /vim/after | |
parent | Change local leader back to comma (diff) | |
download | dotfiles-950f883d89ca0fa7e80cca8f9a0d8cfbade8ebc3.tar.gz dotfiles-950f883d89ca0fa7e80cca8f9a0d8cfbade8ebc3.zip |
Overhaul ftplugin check, lint, tidy
- Set 'equalprg' for HTML and Perl
- Discard filter#Stable()
- Set default :compiler for all applicable filetypes
- Change local leader mappings for Perl and shell script merely to set
:compiler, rather than running it
- Bind global leader mapping for running :lmake!
- Bind global leader mappings for applying 'equalprg' and 'formatprg' to
the whole buffer, using a new autoloaded helper function
vimrc#Anchor() to avoid the cursor jumping around
Diffstat (limited to 'vim/after')
-rw-r--r-- | vim/after/ftplugin/gitcommit.vim | 10 | ||||
-rw-r--r-- | vim/after/ftplugin/html.vim | 24 | ||||
-rw-r--r-- | vim/after/ftplugin/perl.vim | 17 | ||||
-rw-r--r-- | vim/after/ftplugin/php.vim | 12 | ||||
-rw-r--r-- | vim/after/ftplugin/sh.vim | 21 | ||||
-rw-r--r-- | vim/after/ftplugin/vim.vim | 12 | ||||
-rw-r--r-- | vim/after/ftplugin/zsh.vim | 13 |
7 files changed, 56 insertions, 53 deletions
diff --git a/vim/after/ftplugin/gitcommit.vim b/vim/after/ftplugin/gitcommit.vim index 035b835c..e55ebff7 100644 --- a/vim/after/ftplugin/gitcommit.vim +++ b/vim/after/ftplugin/gitcommit.vim @@ -6,10 +6,6 @@ endif " Make angle brackets behave like mail quotes setlocal comments+=n:> setlocal formatoptions+=coqr - -" Add to undo script -if exists('b:undo_ftplugin') - let b:undo_ftplugin = b:undo_ftplugin - \ . '|setlocal comments<' - \ . '|setlocal formatoptions<' -endif +let b:undo_ftplugin = b:undo_ftplugin + \ . '|setlocal comments<' + \ . '|setlocal formatoptions<' diff --git a/vim/after/ftplugin/html.vim b/vim/after/ftplugin/html.vim index 545076b1..3a08d110 100644 --- a/vim/after/ftplugin/html.vim +++ b/vim/after/ftplugin/html.vim @@ -3,11 +3,21 @@ if &filetype != 'html' || &compatible || v:version < 700 finish endif +" Use tidy(1) for checking and program formatting +compiler tidy +setlocal equalprg=tidy\ -quiet +let b:undo_ftplugin = b:undo_ftplugin + \ . '|setlocal equalprg<' + \ . '|setlocal errorformat<' + \ . '|setlocal makeprg<' + " Set up hooks for timestamp updating -autocmd html_timestamp BufWritePre <buffer> - \ if exists('b:html_timestamp_check') - \| call html#TimestampUpdate() - \|endif +augroup html_timestamp + autocmd BufWritePre <buffer> + \ if exists('b:html_timestamp_check') + \| call html#TimestampUpdate() + \|endif +augroup END let b:undo_ftplugin = b:undo_ftplugin \ . '|autocmd! html_timestamp BufWritePre <buffer>' @@ -17,13 +27,7 @@ if exists('g:no_plugin_maps') || exists('g:no_html_maps') endif " Set mappings -nnoremap <buffer> <LocalLeader>l - \ :<C-U>call compiler#Make('tidy')<CR> nnoremap <buffer> <LocalLeader>r \ :<C-U>call html#UrlLink()<CR> -nnoremap <buffer> <LocalLeader>t - \ :<C-U>call filter#Stable('tidy -quiet')<CR> let b:undo_ftplugin = b:undo_ftplugin - \ . '|nunmap <buffer> <LocalLeader>l' \ . '|nunmap <buffer> <LocalLeader>r' - \ . '|nunmap <buffer> <LocalLeader>t' diff --git a/vim/after/ftplugin/perl.vim b/vim/after/ftplugin/perl.vim index 8887b56a..564653d2 100644 --- a/vim/after/ftplugin/perl.vim +++ b/vim/after/ftplugin/perl.vim @@ -3,22 +3,27 @@ if &filetype != 'perl' || &compatible || v:version < 700 finish endif +" Use Perl itself for checking and Perl::Tidy for tidying +compiler perl +setlocal equalprg=perltidy +let b:undo_ftplugin = b:undo_ftplugin + \ . '|setlocal equalprg<' + \ . '|setlocal errorformat<' + \ . '|setlocal makeprg<' + " Stop here if the user doesn't want ftplugin mappings if exists('g:no_plugin_maps') || exists('g:no_perl_maps') finish endif -" Set mappings +" Mappings to choose compiler nnoremap <buffer> <LocalLeader>c - \ :<C-U>call compiler#Make('perl')<CR> + \ :<C-U>compiler perl<CR> nnoremap <buffer> <LocalLeader>l - \ :<C-U>call compiler#Make('perlcritic')<CR> -nnoremap <buffer> <LocalLeader>t - \ :<C-U>call filter#Stable('perltidy')<CR> + \ :<C-U>compiler perlcritic<CR> let b:undo_ftplugin = b:undo_ftplugin \ . '|nunmap <buffer> <LocalLeader>c' \ . '|nunmap <buffer> <LocalLeader>l' - \ . '|nunmap <buffer> <LocalLeader>t' " Bump version numbers nmap <buffer> <LocalLeader>v diff --git a/vim/after/ftplugin/php.vim b/vim/after/ftplugin/php.vim index 35849ac5..1f40aba7 100644 --- a/vim/after/ftplugin/php.vim +++ b/vim/after/ftplugin/php.vim @@ -3,6 +3,12 @@ if &filetype != 'php' || &compatible || v:version < 700 finish endif +" Use PHP itself for syntax checking +compiler php +let b:undo_ftplugin = b:undo_ftplugin + \ . '|setlocal errorformat<' + \ . '|setlocal makeprg<' + " Set comment formats setlocal comments=s1:/*,m:*,ex:*/,://,:# setlocal formatoptions+=or @@ -15,12 +21,6 @@ if exists('g:no_plugin_maps') || exists('g:no_php_maps') finish endif -" Set mappings -nnoremap <buffer> <LocalLeader>c - \ :<C-U>call compiler#Make('php')<CR> -let b:undo_ftplugin = b:undo_ftplugin - \ . '|nunmap <buffer> <LocalLeader>c' - " Get rid of the core ftplugin's square-bracket maps on unload let b:undo_ftplugin = b:undo_ftplugin \ . '|nunmap <buffer> [[' diff --git a/vim/after/ftplugin/sh.vim b/vim/after/ftplugin/sh.vim index 086e23d5..01505a88 100644 --- a/vim/after/ftplugin/sh.vim +++ b/vim/after/ftplugin/sh.vim @@ -17,11 +17,6 @@ if exists('b:is_bash') \ . '|setlocal keywordprg<' endif -" Stop here if the user doesn't want ftplugin mappings -if exists('g:no_plugin_maps') || exists('g:no_sh_maps') - finish -endif - " Choose check compiler based on file subtype if exists('b:is_bash') let b:sh_check_compiler = 'bash' @@ -30,14 +25,22 @@ elseif exists('b:is_kornshell') else let b:sh_check_compiler = 'sh' endif +execute 'compiler '.b:sh_check_compiler let b:undo_ftplugin = b:undo_ftplugin \ . '|unlet b:sh_check_compiler' + \ . '|setlocal errorformat<' + \ . '|setlocal makeprg<' + +" Stop here if the user doesn't want ftplugin mappings +if exists('g:no_plugin_maps') || exists('g:no_sh_maps') + finish +endif -" Set mappings -nnoremap <buffer> <LocalLeader>c - \ :<C-U>call compiler#Make(b:sh_check_compiler)<CR> +" Mappings to choose compiler +nnoremap <buffer> <expr> <LocalLeader>c + \ ':<C-U>compiler '.b:sh_check_compiler.'<CR>' nnoremap <buffer> <LocalLeader>l - \ :<C-U>call compiler#Make('shellcheck')<CR> + \ :<C-U>compiler shellcheck<CR> let b:undo_ftplugin = b:undo_ftplugin \ . '|nunmap <buffer> <LocalLeader>c' \ . '|nunmap <buffer> <LocalLeader>l' diff --git a/vim/after/ftplugin/vim.vim b/vim/after/ftplugin/vim.vim index e01e2050..bd0a83ce 100644 --- a/vim/after/ftplugin/vim.vim +++ b/vim/after/ftplugin/vim.vim @@ -3,17 +3,17 @@ if &filetype != 'vim' || &compatible || v:version < 700 finish endif +" Use Vint as a syntax checker +compiler vint +let b:undo_ftplugin = b:undo_ftplugin + \ . '|setlocal errorformat<' + \ . '|setlocal makeprg<' + " Stop here if the user doesn't want ftplugin mappings if exists('g:no_plugin_maps') || exists('g:no_vim_maps') finish endif -" Set mappings -nnoremap <buffer> <LocalLeader>l - \ :<C-U>call compiler#Make('vint')<CR> -let b:undo_ftplugin = b:undo_ftplugin - \ . '|nunmap <buffer> <LocalLeader>l' - " Get rid of the core ftplugin's square-bracket maps on unload let b:undo_ftplugin = b:undo_ftplugin \ . '|nunmap <buffer> [[' diff --git a/vim/after/ftplugin/zsh.vim b/vim/after/ftplugin/zsh.vim index 79f3c638..d5852e53 100644 --- a/vim/after/ftplugin/zsh.vim +++ b/vim/after/ftplugin/zsh.vim @@ -3,13 +3,8 @@ if &filetype != 'zsh' || &compatible || v:version < 700 finish endif -" Stop here if the user doesn't want ftplugin mappings -if exists('g:no_plugin_maps') || exists('g:no_zsh_maps') - finish -endif - -" Set mappings -nnoremap <buffer> <LocalLeader>c - \ :<C-U>call compiler#Make('zsh')<CR> +" Use Z shell itself as a syntax checker +compiler zsh let b:undo_ftplugin = b:undo_ftplugin - \ . '|nunmap <buffer> <LocalLeader>c' + \ . '|setlocal errorformat<' + \ . '|setlocal makeprg<' |