From 10c601851625784c7058f52c8d88bdb2e99b5620 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 8 Jul 2018 23:13:02 +1200 Subject: Overhaul base after-ftplugins Mostly to simplify them--remove a lot of the load-guard cruft. --- vim/after/ftplugin/sh.vim | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'vim/after/ftplugin/sh.vim') diff --git a/vim/after/ftplugin/sh.vim b/vim/after/ftplugin/sh.vim index 05c3e293..086e23d5 100644 --- a/vim/after/ftplugin/sh.vim +++ b/vim/after/ftplugin/sh.vim @@ -1,22 +1,14 @@ -" Extra configuration for 'sh' filetypes -if exists('b:did_ftplugin_after') || &compatible +" Extra configuration for shell script +if &filetype != 'sh' || &compatible || v:version < 700 finish endif -if v:version < 700 - finish -endif -if &filetype !=# 'sh' - finish -endif -let b:did_ftplugin_after = 1 -let b:undo_ftplugin = b:undo_ftplugin - \ . '|unlet b:did_ftplugin_after' " Set comment formats setlocal comments=:# setlocal formatoptions+=or let b:undo_ftplugin = b:undo_ftplugin - \ . '|setlocal comments< formatoptions<' + \ . '|setlocal comments<' + \ . '|setlocal formatoptions<' " If subtype is Bash, set 'keywordprg' to han(1df) if exists('b:is_bash') @@ -38,6 +30,8 @@ elseif exists('b:is_kornshell') else let b:sh_check_compiler = 'sh' endif +let b:undo_ftplugin = b:undo_ftplugin + \ . '|unlet b:sh_check_compiler' " Set mappings nnoremap c -- cgit v1.2.3 From 950f883d89ca0fa7e80cca8f9a0d8cfbade8ebc3 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 9 Jul 2018 01:15:22 +1200 Subject: 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 --- vim/after/ftplugin/sh.vim | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'vim/after/ftplugin/sh.vim') 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 c - \ :call compiler#Make(b:sh_check_compiler) +" Mappings to choose compiler +nnoremap c + \ ':compiler '.b:sh_check_compiler.'' nnoremap l - \ :call compiler#Make('shellcheck') + \ :compiler shellcheck let b:undo_ftplugin = b:undo_ftplugin \ . '|nunmap c' \ . '|nunmap l' -- cgit v1.2.3 From 9ede911cc92a224419e034b81e8c3abf4cdf9119 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 9 Jul 2018 03:08:24 +1200 Subject: Clear b:current_compiler on unload --- vim/after/ftplugin/sh.vim | 1 + 1 file changed, 1 insertion(+) (limited to 'vim/after/ftplugin/sh.vim') diff --git a/vim/after/ftplugin/sh.vim b/vim/after/ftplugin/sh.vim index 01505a88..5cafdd70 100644 --- a/vim/after/ftplugin/sh.vim +++ b/vim/after/ftplugin/sh.vim @@ -27,6 +27,7 @@ else endif execute 'compiler '.b:sh_check_compiler let b:undo_ftplugin = b:undo_ftplugin + \ . '|unlet b:current_compiler' \ . '|unlet b:sh_check_compiler' \ . '|setlocal errorformat<' \ . '|setlocal makeprg<' -- cgit v1.2.3