diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2017-11-19 23:43:53 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2017-11-19 23:43:53 +1300 |
commit | 062274de75e25ad96f52d39e17844048003b90dc (patch) | |
tree | 093c2479feb70548882938177d0edb95d47056e9 | |
parent | Merge branch 'hotfix/v0.17.2' (diff) | |
parent | Rebuild dotfiles(7) manual from README.md (diff) | |
download | dotfiles-0.18.0.tar.gz (sig) dotfiles-0.18.0.zip |
Merge branch 'release/v0.18.0'v0.18.0
* release/v0.18.0:
Rebuild dotfiles(7) manual from README.md
Bump version number to 0.18.0
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
Use single-quotes for strings in sh.vim
Use full word "syntax" in sh.vim
Coax sh.vim into accepting #/% param expansion
Mention the Vim plugin dist target in README.md
Add Makefile targets for Vim plugin dists
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 97 | ||||
-rw-r--r-- | README.md | 9 | ||||
-rw-r--r-- | VERSION | 4 | ||||
-rw-r--r-- | dist/vim-plugin.sh | 18 | ||||
-rw-r--r-- | lint/vim.sh | 1 | ||||
-rw-r--r-- | man/man7/dotfiles.7df | 11 | ||||
-rw-r--r-- | vim/after/ftplugin/html/lint.vim | 16 | ||||
-rw-r--r-- | vim/after/ftplugin/perl/check.vim | 16 | ||||
-rw-r--r-- | vim/after/ftplugin/perl/lint.vim | 16 | ||||
-rw-r--r-- | vim/after/ftplugin/sh/check.vim | 26 | ||||
-rw-r--r-- | vim/after/ftplugin/sh/lint.vim | 26 | ||||
-rw-r--r-- | vim/after/ftplugin/vim/lint.vim | 16 | ||||
-rw-r--r-- | vim/after/syntax/sh.vim | 17 | ||||
-rw-r--r-- | vim/compiler/perlcritic.vim | 17 | ||||
-rw-r--r-- | vim/compiler/vint.vim | 17 | ||||
-rw-r--r-- | vim/config/command.vim | 3 |
17 files changed, 280 insertions, 31 deletions
@@ -166,3 +166,4 @@ gnupg/gpg.conf gnupg/gpg.conf.m4 include/mktd.m4 urxvt/ext/select +vim/dist @@ -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 \ @@ -71,7 +72,19 @@ lint-sh \ lint-urxvt \ lint-vim \ - lint-xinit + lint-xinit \ + dist-vim-plugin \ + dist-vim-plugin-auto-backupdir \ + dist-vim-plugin-auto-swapdir \ + dist-vim-plugin-auto-undodir \ + dist-vim-plugin-big-file-options \ + dist-vim-plugin-command-typos \ + dist-vim-plugin-copy-linebreak \ + dist-vim-plugin-fixed-join \ + dist-vim-plugin-insert-suspend-hlsearch \ + dist-vim-plugin-mail-mutt \ + dist-vim-plugin-strip-trailing-whitespace \ + dist-vim-plugin-toggle-option-flag .SUFFIXES: .SUFFIXES: .awk .bash .m4 .mi5 .pl .sed .sh @@ -261,7 +274,8 @@ clean distclean: gnupg/gpg.conf.m4 \ include/mktd.m4 \ man/man8/dotfiles.7df \ - urxvt/ext/select + urxvt/ext/select \ + vim/dist/* .awk: sh bin/shb.sh awk -f < $< > $@ @@ -482,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 \ @@ -516,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 @@ -633,3 +652,77 @@ lint-vim: lint-xinit: check-xinit sh lint/xinit.sh + +dist-vim-plugin: dist-vim-plugin-auto-backupdir \ + dist-vim-plugin-auto-swapdir \ + dist-vim-plugin-auto-undodir \ + dist-vim-plugin-big-file-options \ + dist-vim-plugin-command-typos \ + dist-vim-plugin-copy-linebreak \ + dist-vim-plugin-detect-background \ + dist-vim-plugin-fixed-join \ + dist-vim-plugin-insert-suspend-hlsearch \ + dist-vim-plugin-mail-mutt \ + dist-vim-plugin-strip-trailing-whitespace \ + dist-vim-plugin-toggle-option-flag + +dist-vim-plugin-auto-backupdir: \ + vim/plugin/auto_backupdir.vim \ + vim/doc/auto_backupdir.txt \ + VERSION + sh dist/vim-plugin.sh auto_backupdir +dist-vim-plugin-auto-swapdir: \ + vim/plugin/auto_swapdir.vim \ + vim/doc/auto_swapdir.txt \ + VERSION + sh dist/vim-plugin.sh auto_swapdir +dist-vim-plugin-auto-undodir: \ + vim/plugin/auto_undodir.vim \ + vim/doc/auto_undodir.txt \ + VERSION + sh dist/vim-plugin.sh auto_undodir +dist-vim-plugin-big-file-options: \ + vim/plugin/big_file_options.vim \ + vim/doc/big_file_options.txt \ + VERSION + sh dist/vim-plugin.sh big_file_options +dist-vim-plugin-command-typos: \ + vim/plugin/command_typos.vim \ + vim/doc/command_typos.txt \ + VERSION + sh dist/vim-plugin.sh command_typos +dist-vim-plugin-copy-linebreak: \ + vim/plugin/copy_linebreak.vim \ + vim/doc/copy_linebreak.txt \ + VERSION + sh dist/vim-plugin.sh copy_linebreak +dist-vim-plugin-detect-background: \ + vim/autoload/detect_background.vim \ + vim/doc/detect_background.txt \ + VERSION + sh dist/vim-plugin.sh detect_background +dist-vim-plugin-fixed-join: \ + vim/plugin/fixed_join.vim \ + vim/doc/fixed_join.txt \ + VERSION + sh dist/vim-plugin.sh fixed_join +dist-vim-plugin-insert-suspend-hlsearch: \ + vim/plugin/insert_suspend_hlsearch.vim \ + vim/doc/insert_suspend_hlsearch.txt \ + VERSION + sh dist/vim-plugin.sh insert_suspend_hlsearch +dist-vim-plugin-mail-mutt: \ + vim/plugin/mail_mutt.vim \ + vim/doc/mail_mutt.txt \ + VERSION + sh dist/vim-plugin.sh mail_mutt +dist-vim-plugin-strip-trailing-whitespace: \ + vim/plugin/strip_trailing_whitespace.vim \ + vim/doc/strip_trailing_whitespace.txt \ + VERSION + sh dist/vim-plugin.sh strip_trailing_whitespace +dist-vim-plugin-toggle-option-flag: \ + vim/plugin/toggle_option_flag.vim \ + vim/doc/toggle_option_flag.txt \ + VERSION + sh dist/vim-plugin.sh toggle_option_flag @@ -352,16 +352,17 @@ structures like functions, I like to implement it as a plugin in `~/.vim/plugin` and/or `~/.vim/autoload`. There's documentation for each of those in `~/.vim/doc`. +Any/all of those plugins may eventually be spun off into their own repositories +in the future, but for the moment they live here. You can create distribution +packages for them with `make dist-vim-plugin`; they will be created in +`vim/dist`. + I also define a few rules specific to file types I often edit in `~/.vim/after/ftplugin`, including some local mappings for checking, linting, and tidying, and a few more in `~/.vim/after/indent`. There are also a few tweaks to core syntax files in `~/.vim/after/syntax`, especially for shell script (`sh.vim`). -Any/all of the plugins may eventually be spun off into their own repositories -in the future, but for the moment they live here. Contact me if you find one of -them useful and you'd like to see it in its own distribution. - Third-party plugins are in submodules in `~/.vim/bundle`, loaded using Tim Pope's [pathogen.vim](https://github.com/tpope/vim-pathogen). @@ -1,2 +1,2 @@ -tejr dotfiles v0.17.2 -Tue Nov 14 22:20:41 UTC 2017 +tejr dotfiles v0.18.0 +Sun Nov 19 10:42:36 UTC 2017 diff --git a/dist/vim-plugin.sh b/dist/vim-plugin.sh new file mode 100644 index 00000000..0f549be4 --- /dev/null +++ b/dist/vim-plugin.sh @@ -0,0 +1,18 @@ +#!/bin/sh +ver=$(awk -Fv 'NR<2&&$0=$NF' VERSION) || exit +mkdir -p -- vim/dist || exit +cd -- vim/dist || exit +for pn ; do + dn=vim-$(printf '%s' "$pn"|sed 's/_/-/g')-$ver + mkdir -p -- "$pn" + for fn in ../*/"$pn".txt ../*/"$pn".vim ; do + [ -e "$fn" ] || continue + sdn=$fn + sdn=${sdn#../} + sdn=${sdn%/*} + mkdir -p -- "$pn"/"$sdn" + cp -- "$fn" "$pn"/"$sdn" + done + tar c "$pn" | gzip > "$dn".tar.gz || exit + rm -r -- "$pn" +done 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/man/man7/dotfiles.7df b/man/man7/dotfiles.7df index bdecae9a..df5d9dfa 100644 --- a/man/man7/dotfiles.7df +++ b/man/man7/dotfiles.7df @@ -489,6 +489,12 @@ structures like functions, I like to implement it as a plugin in \f[C]~/.vim/plugin\f[] and/or \f[C]~/.vim/autoload\f[]. There's documentation for each of those in \f[C]~/.vim/doc\f[]. .PP +Any/all of those plugins may eventually be spun off into their own +repositories in the future, but for the moment they live here. +You can create distribution packages for them with +\f[C]make\ dist\-vim\-plugin\f[]; they will be created in +\f[C]vim/dist\f[]. +.PP I also define a few rules specific to file types I often edit in \f[C]~/.vim/after/ftplugin\f[], including some local mappings for checking, linting, and tidying, and a few more in @@ -497,11 +503,6 @@ There are also a few tweaks to core syntax files in \f[C]~/.vim/after/syntax\f[], especially for shell script (\f[C]sh.vim\f[]). .PP -Any/all of the plugins may eventually be spun off into their own -repositories in the future, but for the moment they live here. -Contact me if you find one of them useful and you'd like to see it in -its own distribution. -.PP Third\-party plugins are in submodules in \f[C]~/.vim/bundle\f[], loaded using Tim Pope's pathogen.vim (https://github.com/tpope/vim-pathogen). .SS Scripts 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/after/syntax/sh.vim b/vim/after/syntax/sh.vim index 8025c567..08dbd857 100644 --- a/vim/after/syntax/sh.vim +++ b/vim/after/syntax/sh.vim @@ -111,7 +111,7 @@ if exists('b:is_posix') syntax clear shRepeat syntax region shRepeat \ matchgroup=shLoop - \ start="\<while\_s" end="\<do\>"me=e-2 + \ start='\<while\_s' end='\<do\>'me=e-2 \ contains=@shLoopList " Run some clustering that core syntax/sh.vim thinks doesn't apply to POSIX; @@ -119,6 +119,21 @@ if exists('b:is_posix') syntax cluster shCaseList add=shRepeat syntax cluster shFunctionList add=shRepeat + " ${foo%bar}, ${foo%%bar}, ${foo#bar}, and ${foo##bar} are all valid forms + " of parameter expansion in POSIX, but sh.vim makes them conditional on + " Bash or Korn shell. We reinstate them (slightly adapted) here. + syntax match shDerefOp contained + \ '##\|#\|%%\|%' + \ nextgroup=@shDerefPatternList + syntax match shDerefPattern contained + \ '[^{}]\+' + \ contains=shDeref,shDerefSimple,shDerefPattern,shDerefString,shCommandSub,shDerefEscape + \ nextgroup=shDerefPattern + syntax region shDerefPattern contained + \ start='{' end='}' + \ contains=shDeref,shDerefSimple,shDerefString,shCommandSub + \ nextgroup=shDerefPattern + endif " Some corrections for highlighting specific to the Bash mode 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') |