From 52a44874f805cad8d51474d905ced6494af53229 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 29 May 2019 03:00:30 +1200 Subject: Overhaul Vim :compiler scripts * Drop support for everything before Vim 8.0; this is mostly because of the requirement of %:S for safe 'makeprg' handling; it's not likely that I'll do much development on anything older than v8.0 anymore * Remove :CompilerSet definition for ancient Vims * Add brief comments and URLs to top of file --- vim/compiler/bash.vim | 16 +++------------- vim/compiler/ksh.vim | 16 +++------------- vim/compiler/perlcritic.vim | 17 ++++------------- vim/compiler/php.vim | 18 +++--------------- vim/compiler/sh.vim | 16 +++------------- vim/compiler/shellcheck.vim | 19 +++++-------------- vim/compiler/vint.vim | 17 ++++------------- vim/compiler/zsh.vim | 16 +++------------- 8 files changed, 28 insertions(+), 107 deletions(-) (limited to 'vim/compiler') diff --git a/vim/compiler/bash.vim b/vim/compiler/bash.vim index 13271e2b..aca87eb7 100644 --- a/vim/compiler/bash.vim +++ b/vim/compiler/bash.vim @@ -1,18 +1,8 @@ -if exists('current_compiler') +" :compiler support for GNU Bash syntax checking with `bash -n` +if exists('current_compiler') || &compatible || v:version < 800 finish endif let current_compiler = 'bash' -if exists(':CompilerSet') != 2 - command -nargs=* CompilerSet setlocal -endif - -" 7.4.191 is the earliest version with the :S file name modifier, which we -" really should use if we can -if v:version >= 704 - \ || v:version == 704 && has('patch191') - CompilerSet makeprg=bash\ -n\ --\ %:S -else - CompilerSet makeprg=bash\ -n\ --\ % -endif +CompilerSet makeprg=bash\ -n\ --\ %:S CompilerSet errorformat=%f:\ line\ %l:\ %m diff --git a/vim/compiler/ksh.vim b/vim/compiler/ksh.vim index 5dbff5a1..9ee21748 100644 --- a/vim/compiler/ksh.vim +++ b/vim/compiler/ksh.vim @@ -1,18 +1,8 @@ -if exists('current_compiler') +" :compiler support for Korn shell syntax checking with `ksh -n` +if exists('current_compiler') || &compatible || v:version < 800 finish endif let current_compiler = 'ksh' -if exists(':CompilerSet') != 2 - command -nargs=* CompilerSet setlocal -endif - -" 7.4.191 is the earliest version with the :S file name modifier, which we -" really should use if we can -if v:version >= 704 - \ || v:version == 704 && has('patch191') - CompilerSet makeprg=ksh\ -n\ --\ %:S -else - CompilerSet makeprg=ksh\ -n\ --\ % -endif +CompilerSet makeprg=ksh\ -n\ --\ %:S CompilerSet errorformat=%f:\ %l:\ %m diff --git a/vim/compiler/perlcritic.vim b/vim/compiler/perlcritic.vim index b89ee76b..f0d100b6 100644 --- a/vim/compiler/perlcritic.vim +++ b/vim/compiler/perlcritic.vim @@ -1,18 +1,9 @@ -if exists('current_compiler') +" :compiler support for Perl::Critic +" +if exists('current_compiler') || &compatible || v:version < 800 finish endif let current_compiler = 'perlcritic' -if exists(':CompilerSet') != 2 - command -nargs=* CompilerSet setlocal -endif - -" 7.4.191 is the earliest version with the :S file name modifier, which we -" really should use if we can -if v:version >= 704 - \ || v:version == 704 && has('patch191') - CompilerSet makeprg=perlcritic\ --verbose\ 1\ --\ %:S -else - CompilerSet makeprg=perlcritic\ --verbose\ 1\ --\ % -endif +CompilerSet makeprg=perlcritic\ --verbose\ 1\ --\ %:S CompilerSet errorformat=%f:%l:%c:%m diff --git a/vim/compiler/php.vim b/vim/compiler/php.vim index be4283ef..c0c626ec 100644 --- a/vim/compiler/php.vim +++ b/vim/compiler/php.vim @@ -1,22 +1,10 @@ -if exists('current_compiler') || &compatible +" :compiler support for PHP syntax checking with `php -l` +if exists('current_compiler') || &compatible || v:version < 800 finish endif let current_compiler = 'php' -if exists(':CompilerSet') != 2 - command -nargs=* CompilerSet setlocal -endif - -" 7.4.191 is the earliest version with the :S file name modifier, which we -" really should use if we can -if v:version >= 704 - \ || v:version == 704 && has('patch191') - CompilerSet makeprg=php\ -lq\ -f\ %:S -else - CompilerSet makeprg=php\ -lq\ -f\ % -endif - -" Here be copy-pasted dragons +CompilerSet makeprg=php\ -lq\ -f\ %:S CompilerSet errorformat= \%E%.%#Parse\ error: \\ %m\ in\ %f\ on\ line\ %l, diff --git a/vim/compiler/sh.vim b/vim/compiler/sh.vim index 5e7bc3ba..6abb715e 100644 --- a/vim/compiler/sh.vim +++ b/vim/compiler/sh.vim @@ -1,18 +1,8 @@ -if exists('current_compiler') +" :compiler support for POSIX sh syntax checking with `sh -n` +if exists('current_compiler') || &compatible || v:version < 800 finish endif let current_compiler = 'sh' -if exists(':CompilerSet') != 2 - command -nargs=* CompilerSet setlocal -endif - -" 7.4.191 is the earliest version with the :S file name modifier, which we -" really should use if we can -if v:version >= 704 - \ || v:version == 704 && has('patch191') - CompilerSet makeprg=sh\ -n\ --\ %:S -else - CompilerSet makeprg=sh\ -n\ --\ % -endif +CompilerSet makeprg=sh\ -n\ --\ %:S CompilerSet errorformat=%f:\ %l:\ %m diff --git a/vim/compiler/shellcheck.vim b/vim/compiler/shellcheck.vim index fa5db235..f440a23d 100644 --- a/vim/compiler/shellcheck.vim +++ b/vim/compiler/shellcheck.vim @@ -1,13 +1,11 @@ -if exists('current_compiler') +" :compiler support for shell script linting with ShellCheck +" +if exists('current_compiler') || &compatible || v:version < 800 finish endif let current_compiler = 'shellcheck' -if exists(':CompilerSet') != 2 - command -nargs=* CompilerSet setlocal -endif - -" Build :CompilerSet command based on buffer shell type +" Build 'makeprg' command line based on this buffer's shell script type let s:set = 'CompilerSet makeprg=shellcheck\ -e\ SC1090\ -f\ gcc' if exists('b:is_bash') let s:set = s:set . '\ -s\ bash' @@ -16,13 +14,6 @@ elseif exists('b:is_kornshell') else let s:set = s:set . '\ -s\ sh' endif +execute s:set . '\ --\ %:S' -" 7.4.191 is the earliest version with the :S file name modifier, which we -" really should use if we can -if v:version >= 704 - \ || v:version == 704 && has('patch191') - execute s:set . '\ --\ %:S' -else - execute s:set . '\ --\ %' -endif CompilerSet errorformat=%f:%l:%c:\ %m\ [SC%n] diff --git a/vim/compiler/vint.vim b/vim/compiler/vint.vim index 35819ae3..8cd35cf1 100644 --- a/vim/compiler/vint.vim +++ b/vim/compiler/vint.vim @@ -1,18 +1,9 @@ -if exists('current_compiler') +" :compiler support for Vim script linting with Vint +" +if exists('current_compiler') || &compatible || v:version < 800 finish endif let current_compiler = 'vimlint' -if exists(':CompilerSet') != 2 - command -nargs=* CompilerSet setlocal -endif - -" 7.4.191 is the earliest version with the :S file name modifier, which we -" really should use if we can -if v:version >= 704 - \ || v:version == 704 && has('patch191') - CompilerSet makeprg=vint\ --\ %:S -else - CompilerSet makeprg=vint\ --\ % -endif +CompilerSet makeprg=vint\ --\ %:S CompilerSet errorformat=%f:%l:%c:\ %m diff --git a/vim/compiler/zsh.vim b/vim/compiler/zsh.vim index ad82cc3b..bb8802c9 100644 --- a/vim/compiler/zsh.vim +++ b/vim/compiler/zsh.vim @@ -1,18 +1,8 @@ -if exists('current_compiler') +" :compiler support for Z Shell syntax checking with `zsh -n` +if exists('current_compiler') || &compatible || v:version < 800 finish endif let current_compiler = 'zsh' -if exists(':CompilerSet') != 2 - command -nargs=* CompilerSet setlocal -endif - -" 7.4.191 is the earliest version with the :S file name modifier, which we -" really should use if we can -if v:version >= 704 - \ || v:version == 704 && has('patch191') - CompilerSet makeprg=zsh\ -n\ --\ %:S -else - CompilerSet makeprg=zsh\ -n\ --\ % -endif +CompilerSet makeprg=zsh\ -n\ --\ %:S CompilerSet errorformat=%f:%l:\ %m -- cgit v1.2.3