diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2017-10-30 18:36:18 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2017-10-30 18:36:18 +1300 |
commit | 1eef391006a3c70b7361b6480c8922d1a29c7a7d (patch) | |
tree | 37fd358093c2656b3af7f076c16723ed3c618c1a | |
parent | Move non-indent HTML Vim config indent->ftplugin (diff) | |
parent | Add a `lint-vim` target for linting Vim config (diff) | |
download | dotfiles-1eef391006a3c70b7361b6480c8922d1a29c7a7d.tar.gz dotfiles-1eef391006a3c70b7361b6480c8922d1a29c7a7d.zip |
Merge branch 'vim/vint'
The Vim configuration, excluding the submodule plugin bundles, now
passes a strict run of the vim-vint tool. There's also now a `lint-vim`
target in the Makefile.
-rw-r--r-- | Makefile | 5 | ||||
-rw-r--r-- | README.md | 18 | ||||
-rw-r--r-- | lint/vim.sh | 5 | ||||
-rw-r--r-- | man/man7/dotfiles.7df | 34 | ||||
-rw-r--r-- | vim/config/format.vim | 2 | ||||
-rw-r--r-- | vim/config/linebreak.vim | 6 | ||||
-rw-r--r-- | vim/config/syntax.vim | 2 | ||||
-rw-r--r-- | vim/config/whitespace.vim | 9 | ||||
-rw-r--r-- | vim/ftplugin/html.vim | 8 | ||||
-rw-r--r-- | vim/gvimrc | 2 | ||||
-rw-r--r-- | vim/vimrc | 9 |
11 files changed, 71 insertions, 29 deletions
@@ -66,6 +66,7 @@ lint-ksh \ lint-sh \ lint-urxvt \ + lint-vim \ lint-xinit .SUFFIXES: @@ -570,6 +571,7 @@ lint: lint-bash \ lint-ksh \ lint-sh \ lint-urxvt \ + lint-vim \ lint-xinit lint-bash: check-bash @@ -590,5 +592,8 @@ lint-sh: check-sh lint-urxvt: check-urxvt sh lint/urxvt.sh +lint-vim: + sh lint/vim.sh + lint-xinit: check-xinit sh lint/xinit.sh @@ -584,10 +584,20 @@ You can check that both sets of shell scripts are syntactically correct with the scripts in `bin` and `games`. There's no proper test suite for the actual functionality (yet). -If you have [ShellCheck](https://www.shellcheck.net/) and/or -[Perl::Critic](http://perlcritic.com/), there's a `lint` target for the shell -script files and Perl files respectively. The files don't need to pass that -check to be installed. +There are also optional `lint` targets, if you have the appropriate tools +available to run them: + +* [ShellCheck](https://www.shellcheck.net/): + * `lint-bash` + * `lint-bin` + * `lint-games` + * `lint-ksh` + * `lint-sh` + * `lint-xinit` +* [Perl::Critic](https://perlcritic.com/): + * `lint-urxvt` +* [Vint](https://github.com/Kuniwak/vint): + * `lint-vim` Known issues ------------ diff --git a/lint/vim.sh b/lint/vim.sh new file mode 100644 index 00000000..6714ac9a --- /dev/null +++ b/lint/vim.sh @@ -0,0 +1,5 @@ +for v in vim/* ; do + [ "$v" != vim/bundle ] || continue + printf '%s\n' "$v" + vint -s -- "$v" +done diff --git a/man/man7/dotfiles.7df b/man/man7/dotfiles.7df index 6ddacd5d..91b4b841 100644 --- a/man/man7/dotfiles.7df +++ b/man/man7/dotfiles.7df @@ -921,10 +921,36 @@ with \f[C]make\ check\-bash\f[], \f[C]make\ check\-sh\f[], or \f[C]bin\f[] and \f[C]games\f[]. There's no proper test suite for the actual functionality (yet). .PP -If you have ShellCheck (https://www.shellcheck.net/) and/or -Perl::Critic (http://perlcritic.com/), there's a \f[C]lint\f[] target -for the shell script files and Perl files respectively. -The files don't need to pass that check to be installed. +There are also optional \f[C]lint\f[] targets, if you have the +appropriate tools available to run them: +.IP \[bu] 2 +ShellCheck (https://www.shellcheck.net/): +.RS 2 +.IP \[bu] 2 +\f[C]lint\-bash\f[] +.IP \[bu] 2 +\f[C]lint\-bin\f[] +.IP \[bu] 2 +\f[C]lint\-games\f[] +.IP \[bu] 2 +\f[C]lint\-ksh\f[] +.IP \[bu] 2 +\f[C]lint\-sh\f[] +.IP \[bu] 2 +\f[C]lint\-xinit\f[] +.RE +.IP \[bu] 2 +Perl::Critic (https://perlcritic.com/): +.RS 2 +.IP \[bu] 2 +\f[C]lint\-urxvt\f[] +.RE +.IP \[bu] 2 +Vint (https://github.com/Kuniwak/vint): +.RS 2 +.IP \[bu] 2 +\f[C]lint\-vim\f[] +.RE .SS Known issues .PP See ISSUES.markdown. diff --git a/vim/config/format.vim b/vim/config/format.vim index cbc995af..fadbd8f7 100644 --- a/vim/config/format.vim +++ b/vim/config/format.vim @@ -1,6 +1,6 @@ " If we can, add j to the format options to get rid of comment leaders when " joining lines -if v:version > 703 || v:version == 703 && has('patch541') +if v:version > 703 || v:version ==# 703 && has('patch541') set formatoptions+=j endif diff --git a/vim/config/linebreak.vim b/vim/config/linebreak.vim index 887d5f39..5abdabd1 100644 --- a/vim/config/linebreak.vim +++ b/vim/config/linebreak.vim @@ -4,7 +4,7 @@ if has('linebreak') set linebreak set showbreak=... - if v:version > 704 || v:version == 704 && has('patch338') + if v:version > 704 || v:version ==# 704 && has('patch338') set breakindent endif @@ -15,13 +15,13 @@ if has('linebreak') if &linebreak set nolinebreak set showbreak= - if v:version > 704 || v:version == 704 && has('patch338') + if v:version > 704 || v:version ==# 704 && has('patch338') set nobreakindent endif else set linebreak set showbreak=... - if v:version > 704 || v:version == 704 && has('patch338') + if v:version > 704 || v:version ==# 704 && has('patch338') set breakindent endif endif diff --git a/vim/config/syntax.vim b/vim/config/syntax.vim index df75b3f0..08b908c8 100644 --- a/vim/config/syntax.vim +++ b/vim/config/syntax.vim @@ -19,7 +19,7 @@ if has('syntax') let l:bg = len(l:colorfgbg) ? l:colorfgbg[-1] : '' " Choose the background setting based on this value - if l:bg == 'default' || l:bg == '7' || l:bg == '15' + if l:bg ==# 'default' || l:bg ==# '7' || l:bg ==# '15' set background=light else set background=dark diff --git a/vim/config/whitespace.vim b/vim/config/whitespace.vim index 2202f47b..119d2c48 100644 --- a/vim/config/whitespace.vim +++ b/vim/config/whitespace.vim @@ -5,10 +5,11 @@ set nojoinspaces " Strip trailing whitespace with \x if has('eval') function! StripTrailingWhitespace() - let l:search = @/ - %substitute/\s\+$//e - let @/ = l:search - nohlsearch + let l:li = 1 + for l:line in getline(1,'$') + call setline(l:li, substitute(l:line, '\m\C\s\+$', '', 'g')) + let l:li = l:li + 1 + endfor endfunction nnoremap <silent> <leader>x :<C-U>call StripTrailingWhitespace()<CR> endif diff --git a/vim/ftplugin/html.vim b/vim/ftplugin/html.vim index 38b71656..ca762422 100644 --- a/vim/ftplugin/html.vim +++ b/vim/ftplugin/html.vim @@ -3,9 +3,9 @@ nnoremap <leader>v :exe "!tidy -eq -utf8 " . shellescape(expand("%"))<CR> " Make a bare URL into a link to itself function! UrlLink() - normal yiW - execute "normal i<a href=\"\<C-R>0\">\<Esc>" - normal E - execute "normal a</a>\<Esc>" + normal! yiW + execute "normal! i<a href=\"\<C-R>0\">\<Esc>" + normal! E + execute "normal! a</a>\<Esc>" endfunction nnoremap <silent> <leader>r :<C-U>call UrlLink()<CR> @@ -1,7 +1,7 @@ " My choice of font changes depending on which operating system I'm using; " these are both workable monospace fonts, but Ubuntu Mono doesn't render very " nicely on Windows a lot of the time -if has("unix") +if has('unix') silent! set guifont=Ubuntu\ Mono\ 12 else silent! set guifont=Consolas:h11 @@ -1,8 +1,3 @@ -" Don't make any effort to be compatible with vi, use more sensible settings. -" This is only here in case this file gets loaded explicitly with -u; the mere -" existence of a ~/.vimrc file already turns this off. -set nocompatible - " Use UTF-8 by default wherever possible, including in this file if has('multi_byte') set encoding=utf-8 @@ -26,8 +21,8 @@ if v:version >= 701 " The 'sahara' colorscheme only works for dark backgrounds with 256 colors if has('syntax') - \ && &background == 'dark' - \ && (has('gui_running') || &t_Co == 256) + \ && &background ==# 'dark' + \ && (has('gui_running') || &t_Co ==# 256) silent! colorscheme sahara endif endif |