aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-11-19 23:41:14 +1300
committerTom Ryder <tom@sanctum.geek.nz>2017-11-19 23:41:14 +1300
commit3ed77af5d2f15d5a934843c9156e90c7d10c252e (patch)
tree46e4b353306593c550f342aa9f916d4eddfa5d79
parentMerge branch 'feature/vim-sh' into develop (diff)
parentUse %:S expansion only when available (diff)
downloaddotfiles-3ed77af5d2f15d5a934843c9156e90c7d10c252e.tar.gz
dotfiles-3ed77af5d2f15d5a934843c9156e90c7d10c252e.zip
Merge branch 'feature/vim-loclist' into develop
* feature/vim-loclist: Use %:S expansion only when available Force g:current_compiler removal before check/lint Use quickfix window for check/lint Add vim/compiler scripts to vint targets Use :compiler quickfix systems for Vim/HTML lint Use :compiler scripts for makeprg setup Add :lwindow support to Perl check/lint Adapt sh check/lint to use :lmake Remove 'shellpipe' setting
-rw-r--r--Makefile6
-rw-r--r--lint/vim.sh1
-rw-r--r--vim/after/ftplugin/html/lint.vim16
-rw-r--r--vim/after/ftplugin/perl/check.vim16
-rw-r--r--vim/after/ftplugin/perl/lint.vim16
-rw-r--r--vim/after/ftplugin/sh/check.vim26
-rw-r--r--vim/after/ftplugin/sh/lint.vim26
-rw-r--r--vim/after/ftplugin/vim/lint.vim16
-rw-r--r--vim/compiler/perlcritic.vim17
-rw-r--r--vim/compiler/vint.vim17
-rw-r--r--vim/config/command.vim3
11 files changed, 143 insertions, 17 deletions
diff --git a/Makefile b/Makefile
index 4d292b46..a899a367 100644
--- a/Makefile
+++ b/Makefile
@@ -44,6 +44,7 @@
install-vim-after-syntax \
install-vim-autoload \
install-vim-bundle \
+ install-vim-compiler \
install-vim-config \
install-vim-ftdetect \
install-vim-gui \
@@ -495,6 +496,7 @@ install-urxvt: urxvt/ext/select
install-vim: install-vim-after \
install-vim-autoload \
install-vim-bundle \
+ install-vim-compiler \
install-vim-config \
install-vim-doc \
install-vim-ftdetect \
@@ -529,6 +531,10 @@ install-vim-bundle: install-vim-config
-type d -exec sh -c 'mkdir -p -- $(HOME)/."$$1"' _ {} \; -o \
-type f -exec sh -c 'cp -p -- "$$1" $(HOME)/."$$1"' _ {} \;
+install-vim-compiler:
+ mkdir -p -- $(HOME)/.vim/compiler
+ cp -p -- vim/compiler/*.vim $(HOME)/.vim/compiler
+
install-vim-config:
mkdir -p -- $(HOME)/.vim/config
cp -p -- vim/vimrc $(HOME)/.vimrc
diff --git a/lint/vim.sh b/lint/vim.sh
index 9af8d203..5c1bbe22 100644
--- a/lint/vim.sh
+++ b/lint/vim.sh
@@ -1,6 +1,7 @@
set -- \
vim/after \
vim/autoload \
+ vim/compiler \
vim/config \
vim/ftdetect \
vim/gvimrc \
diff --git a/vim/after/ftplugin/html/lint.vim b/vim/after/ftplugin/html/lint.vim
index 3ac760ed..c0fdc44f 100644
--- a/vim/after/ftplugin/html/lint.vim
+++ b/vim/after/ftplugin/html/lint.vim
@@ -11,13 +11,27 @@ if exists('b:undo_ftplugin')
\ . '|unlet b:did_ftplugin_html_lint'
endif
+" Build function for linter
+if !exists('*s:HtmlLint')
+ function s:HtmlLint()
+ let l:save_makeprg = &l:makeprg
+ let l:save_errorformat = &l:errorformat
+ unlet! g:current_compiler
+ compiler tidy
+ make!
+ let &l:makeprg = l:save_makeprg
+ let &l:errorformat = l:save_errorformat
+ cwindow
+ endfunction
+endif
+
" Set up a mapping for the linter, if we're allowed
if !exists('g:no_plugin_maps') && !exists('g:no_html_maps')
" Define a mapping target
nnoremap <buffer> <silent> <unique>
\ <Plug>HtmlLint
- \ :<C-U>write !tidy -errors -quiet<CR>
+ \ :<C-U>call <SID>HtmlLint()<CR>
if exists('b:undo_ftplugin')
let b:undo_ftplugin = b:undo_ftplugin
\ . '|nunmap <buffer> <Plug>HtmlLint'
diff --git a/vim/after/ftplugin/perl/check.vim b/vim/after/ftplugin/perl/check.vim
index 6b057c82..df90784f 100644
--- a/vim/after/ftplugin/perl/check.vim
+++ b/vim/after/ftplugin/perl/check.vim
@@ -9,13 +9,27 @@ if exists('b:undo_ftplugin')
\ . '|unlet b:did_ftplugin_perl_check'
endif
+" Build function for checker
+if !exists('*s:PerlCheck')
+ function s:PerlCheck()
+ let l:save_makeprg = &l:makeprg
+ let l:save_errorformat = &l:errorformat
+ unlet! g:current_compiler
+ compiler perl
+ make!
+ let &l:makeprg = l:save_makeprg
+ let &l:errorformat = l:save_errorformat
+ cwindow
+ endfunction
+endif
+
" Set up a mapping for the checker, if we're allowed
if !exists('g:no_plugin_maps') && !exists('g:no_perl_maps')
" Define a mapping target
nnoremap <buffer> <silent> <unique>
\ <Plug>PerlCheck
- \ :<C-U>write !perl -c<CR>
+ \ :<C-U>call <SID>PerlCheck()<CR>
if exists('b:undo_ftplugin')
let b:undo_ftplugin = b:undo_ftplugin
\ . '|nunmap <buffer> <Plug>PerlCheck'
diff --git a/vim/after/ftplugin/perl/lint.vim b/vim/after/ftplugin/perl/lint.vim
index 86740c81..48b23091 100644
--- a/vim/after/ftplugin/perl/lint.vim
+++ b/vim/after/ftplugin/perl/lint.vim
@@ -9,13 +9,27 @@ if exists('b:undo_ftplugin')
\ . '|unlet b:did_ftplugin_perl_lint'
endif
+" Build function for linter
+if !exists('*s:PerlLint')
+ function s:PerlLint()
+ let l:save_makeprg = &l:makeprg
+ let l:save_errorformat = &l:errorformat
+ unlet! g:current_compiler
+ compiler perlcritic
+ make!
+ let &l:makeprg = l:save_makeprg
+ let &l:errorformat = l:save_errorformat
+ cwindow
+ endfunction
+endif
+
" Set up a mapping for the linter, if we're allowed
if !exists('g:no_plugin_maps') && !exists('g:no_perl_maps')
" Define a mapping target
nnoremap <buffer> <silent> <unique>
\ <Plug>PerlLint
- \ :<C-U>write !perlcritic<CR>
+ \ :<C-U>call <SID>PerlLint()<CR>
if exists('b:undo_ftplugin')
let b:undo_ftplugin = b:undo_ftplugin
\ . '|nunmap <buffer> <Plug>PerlLint'
diff --git a/vim/after/ftplugin/sh/check.vim b/vim/after/ftplugin/sh/check.vim
index 334ec1db..3eaf3f57 100644
--- a/vim/after/ftplugin/sh/check.vim
+++ b/vim/after/ftplugin/sh/check.vim
@@ -11,15 +11,31 @@ endif
" Choose checker based on shell family
if exists('b:is_bash')
- let b:sh_check = 'write !bash -n'
+ let b:sh_check_makeprg = 'bash -n %:S'
elseif exists('b:is_kornshell')
- let b:sh_check = 'write !ksh -n'
+ let b:sh_check_makeprg = 'ksh -n %:S'
else
- let b:sh_check = 'write !sh -n'
+ let b:sh_check_makeprg = 'sh -n %:S'
endif
+let b:sh_check_errorformat = '%f: %l: %m'
if exists('b:undo_ftplugin')
let b:undo_ftplugin = b:undo_ftplugin
- \ . '|unlet b:sh_check'
+ \ . '|unlet b:sh_check_makeprg'
+ \ . '|unlet b:sh_check_errorformat'
+endif
+
+" Build function for checker
+if !exists('*s:ShCheck')
+ function s:ShCheck()
+ let l:save_makeprg = &l:makeprg
+ let l:save_errorformat = &l:errorformat
+ let &l:makeprg = b:sh_check_makeprg
+ let &l:errorformat = b:sh_check_errorformat
+ make!
+ let &l:makeprg = l:save_makeprg
+ let &l:errorformat = l:save_errorformat
+ cwindow
+ endfunction
endif
" Set up a mapping for the checker, if we're allowed
@@ -28,7 +44,7 @@ if !exists('g:no_plugin_maps') && !exists('g:no_sh_maps')
" Define a mapping target
nnoremap <buffer> <silent> <unique>
\ <Plug>ShCheck
- \ :<C-U>execute b:sh_check<CR>
+ \ :<C-U>call <SID>ShCheck()<CR>
if exists('b:undo_ftplugin')
let b:undo_ftplugin = b:undo_ftplugin
\ . '|nunmap <buffer> <Plug>ShCheck'
diff --git a/vim/after/ftplugin/sh/lint.vim b/vim/after/ftplugin/sh/lint.vim
index 8745a31e..7d6e4d75 100644
--- a/vim/after/ftplugin/sh/lint.vim
+++ b/vim/after/ftplugin/sh/lint.vim
@@ -11,15 +11,31 @@ endif
" Choose linter based on shell family
if exists('b:is_bash')
- let b:sh_lint = 'write !shellcheck -e SC1090 -s bash -'
+ let b:sh_lint_makeprg = 'shellcheck -e SC1090 -f gcc -s bash %:S'
elseif exists('b:is_kornshell')
- let b:sh_lint = 'write !shellcheck -e SC1090 -s ksh -'
+ let b:sh_lint_makeprg = 'shellcheck -e SC1090 -f gcc -s ksh %:S'
else
- let b:sh_lint = 'write !shellcheck -e SC1090 -s sh -'
+ let b:sh_lint_makeprg = 'shellcheck -e SC1090 -f gcc -s sh %:S'
endif
+let b:sh_lint_errorformat = '%f:%l:%c: %m [SC%n]'
if exists('b:undo_ftplugin')
let b:undo_ftplugin = b:undo_ftplugin
- \ . '|unlet b:sh_lint'
+ \ . '|unlet b:sh_lint_makeprg'
+ \ . '|unlet b:sh_lint_errorformat'
+endif
+
+" Build function for checker
+if !exists('*s:ShLint')
+ function s:ShLint()
+ let l:save_makeprg = &l:makeprg
+ let l:save_errorformat = &l:errorformat
+ let &l:makeprg = b:sh_lint_makeprg
+ let &l:errorformat = b:sh_lint_errorformat
+ make!
+ let &l:makeprg = l:save_makeprg
+ let &l:errorformat = l:save_errorformat
+ cwindow
+ endfunction
endif
" Set up a mapping for the linter, if we're allowed
@@ -28,7 +44,7 @@ if !exists('g:no_plugin_maps') && !exists('g:no_sh_maps')
" Define a mapping target
nnoremap <buffer> <silent> <unique>
\ <Plug>ShLint
- \ :<C-U>execute b:sh_lint<CR>
+ \ :<C-U>call <SID>ShLint()<CR>
if exists('b:undo_ftplugin')
let b:undo_ftplugin = b:undo_ftplugin
\ . '|nunmap <buffer> <Plug>ShLint'
diff --git a/vim/after/ftplugin/vim/lint.vim b/vim/after/ftplugin/vim/lint.vim
index 1b557593..2c402964 100644
--- a/vim/after/ftplugin/vim/lint.vim
+++ b/vim/after/ftplugin/vim/lint.vim
@@ -9,13 +9,27 @@ if exists('b:undo_ftplugin')
\ . '|unlet b:did_ftplugin_vim_lint'
endif
+" Build function for checker
+if !exists('*s:VimLint')
+ function s:VimLint()
+ let l:save_makeprg = &l:makeprg
+ let l:save_errorformat = &l:errorformat
+ unlet! g:current_compiler
+ compiler vint
+ make!
+ let &l:makeprg = l:save_makeprg
+ let &l:errorformat = l:save_errorformat
+ cwindow
+ endfunction
+endif
+
" Set up a mapping for the linter, if we're allowed
if !exists('g:no_plugin_maps') && !exists('g:no_vim_maps')
" Define a mapping target
nnoremap <buffer> <silent> <unique>
\ <Plug>VimLint
- \ :<C-U>write !vint -s /dev/stdin<CR>
+ \ :<C-U>call <SID>VimLint()<CR>
if exists('b:undo_ftplugin')
let b:undo_ftplugin = b:undo_ftplugin
\ . '|nunmap <buffer> <Plug>VimLint'
diff --git a/vim/compiler/perlcritic.vim b/vim/compiler/perlcritic.vim
new file mode 100644
index 00000000..ec151906
--- /dev/null
+++ b/vim/compiler/perlcritic.vim
@@ -0,0 +1,17 @@
+if exists('g:current_compiler')
+ finish
+endif
+let g:current_compiler = 'tidy'
+
+if exists(':CompilerSet') != 2
+ command -nargs=* CompilerSet setlocal <args>
+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\ %
+fi
+CompilerSet errorformat=%f:%l:%c:%m
diff --git a/vim/compiler/vint.vim b/vim/compiler/vint.vim
new file mode 100644
index 00000000..0dcd4720
--- /dev/null
+++ b/vim/compiler/vint.vim
@@ -0,0 +1,17 @@
+if exists('g:current_compiler')
+ finish
+endif
+let g:current_compiler = 'vimlint'
+
+if exists(':CompilerSet') != 2
+ command -nargs=* CompilerSet setlocal <args>
+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\ %
+fi
+CompilerSet errorformat=%f:%l:%c:\ %m
diff --git a/vim/config/command.vim b/vim/config/command.vim
index e6679b84..b96987cd 100644
--- a/vim/config/command.vim
+++ b/vim/config/command.vim
@@ -4,9 +4,6 @@ set history=2000
" Always tell me the number of lines changed by a command
set report=0
-" Don't write the output of :make to the terminal
-set shellpipe=>
-
" Command-line based features
if has('cmdline_info')