aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-07-09 15:47:14 +1200
committerTom Ryder <tom@sanctum.geek.nz>2018-07-09 15:47:14 +1200
commitb4a2c25d7e81c88077c408e7189fbc23e771fb36 (patch)
tree9eba14fcffd5084c8a1d1d08e4f37b80b0f30a46
parent42436d43a453ced475e3c76fb68eb51141571471 (diff)
parent5436627ce24e278915e088f6fc5fcf69836282d2 (diff)
downloaddotfiles-b4a2c25d7e81c88077c408e7189fbc23e771fb36.tar.gz
dotfiles-b4a2c25d7e81c88077c408e7189fbc23e771fb36.zip
Merge branch 'release/v1.25.0'v1.25.0
* release/v1.25.0: Add extra Perl file detection rules Adjust comment on scripts.vim load Don't defer package load for matchit Clear b:current_compiler on unload Adjust comments in filetype.vim Specify which Vim to run in Makefile Tweak HTML indenting to indent after <p> Use !=# for &filetype match Revert :setglobal changes Overhaul ftplugin check, lint, tidy Change local leader back to comma Overhaul base after-ftplugins Remove Perl indent string again Tidy space and backspace mappings Upgrade and adjust config for diff_prune.vim Highlight overly long Git commit subjects as error Test 'modifiable' for spellchecking text/markdown Disable concealing when editing Vim help Add patterns for Vim help file detection Move shebang updating into filetype.vim Use stridx() for shebang check Correct filetype reset; blank, not NONE Correct a comment on shebang_update.vim
-rw-r--r--Makefile10
-rw-r--r--VERSION4
-rw-r--r--vim/after/ftplugin/awk.vim16
-rw-r--r--vim/after/ftplugin/c.vim16
-rw-r--r--vim/after/ftplugin/cpp.vim16
-rw-r--r--vim/after/ftplugin/diff.vim19
-rw-r--r--vim/after/ftplugin/gitcommit.vim16
-rw-r--r--vim/after/ftplugin/help.vim12
-rw-r--r--vim/after/ftplugin/html.vim38
-rw-r--r--vim/after/ftplugin/mail.vim13
-rw-r--r--vim/after/ftplugin/make.vim21
-rw-r--r--vim/after/ftplugin/markdown.vim15
-rw-r--r--vim/after/ftplugin/perl.vim29
-rw-r--r--vim/after/ftplugin/php.vim27
-rw-r--r--vim/after/ftplugin/sed.vim16
-rw-r--r--vim/after/ftplugin/sh.vim40
-rw-r--r--vim/after/ftplugin/text.vim15
-rw-r--r--vim/after/ftplugin/vim.vim24
-rw-r--r--vim/after/ftplugin/zsh.vim27
-rw-r--r--vim/after/syntax/gitcommit.vim2
-rw-r--r--vim/autoload/compiler.vim33
-rw-r--r--vim/autoload/filter.vim7
-rw-r--r--vim/autoload/shebang.vim7
-rw-r--r--vim/autoload/vimrc.vim6
m---------vim/bundle/diff_prune0
-rw-r--r--vim/filetype.vim23
-rw-r--r--vim/ftdetect/perl.vim9
-rw-r--r--vim/indent/html.vim2
-rw-r--r--vim/indent/perl.vim137
-rw-r--r--vim/plugin/matchit.vim2
-rw-r--r--vim/plugin/shebang_update.vim20
-rw-r--r--vim/scripts.vim2
-rw-r--r--vim/vimrc63
33 files changed, 212 insertions, 475 deletions
diff --git a/Makefile b/Makefile
index 4556ceae..e3e0ad38 100644
--- a/Makefile
+++ b/Makefile
@@ -47,6 +47,7 @@
install-vim-compiler \
install-vim-config \
install-vim-filetype \
+ install-vim-ftdetect \
install-vim-ftplugin \
install-vim-gui \
install-vim-gui-config \
@@ -492,6 +493,7 @@ install-urxvt: urxvt/ext/select
find urxvt/ext -type f ! -name '*.pl' \
-exec cp -p -- {} $(HOME)/.urxvt/ext \;
+VIM = vim
VIMDIR = $(HOME)/.vim
VIMRC = $(HOME)/.vimrc
@@ -501,12 +503,14 @@ install-vim: install-vim-after \
install-vim-compiler \
install-vim-config \
install-vim-filetype \
+ install-vim-ftdetect \
install-vim-ftplugin \
install-vim-indent \
install-vim-plugin
install-neovim:
make install-vim \
+ VIM=nvim \
VIMDIR=$${XDG_CONFIG_HOME:-"$$HOME"/.config}/nvim \
VIMRC=$${XDF_CONFIG_HOME:="$$HOME"/.config}/init.vim
@@ -542,7 +546,7 @@ install-vim-bundle: install-vim-config
find vim/bundle/*/*/* \
-type f -exec sh -c \
'cp -p -- "$$1" $(VIMDIR)/"$${1#vim/bundle/*/}"' _ {} \;
- vim -e -u NONE -c 'helptags $(VIMDIR)/doc' -c quit
+ $(VIM) -e -u NONE -c 'helptags $(VIMDIR)/doc' -c quit
install-vim-compiler:
mkdir -p -- $(VIMDIR)/compiler
@@ -559,6 +563,10 @@ install-vim-config:
install-vim-filetype:
cp -p -- vim/filetype.vim vim/scripts.vim $(VIMDIR)
+install-vim-ftdetect:
+ mkdir -p -- $(VIMDIR)/ftdetect
+ cp -p -- vim/ftdetect/*.vim $(VIMDIR)/ftdetect
+
install-vim-ftplugin:
mkdir -p -- $(VIMDIR)/ftplugin
cp -p -- vim/ftplugin/*.vim $(VIMDIR)/ftplugin
diff --git a/VERSION b/VERSION
index 423aa0de..4be13693 100644
--- a/VERSION
+++ b/VERSION
@@ -1,2 +1,2 @@
-tejr dotfiles v1.24.0
-Sun Jul 8 04:20:25 UTC 2018
+tejr dotfiles v1.25.0
+Mon Jul 9 03:46:58 UTC 2018
diff --git a/vim/after/ftplugin/awk.vim b/vim/after/ftplugin/awk.vim
index fae66c3c..42b3e1db 100644
--- a/vim/after/ftplugin/awk.vim
+++ b/vim/after/ftplugin/awk.vim
@@ -1,19 +1,11 @@
-" Extra configuration for 'awk' filetypes
-if exists('b:did_ftplugin_after') || &compatible
+" Extra configuration for AWK scripts
+if &filetype != 'awk' || &compatible || v:version < 700
finish
endif
-if v:version < 700
- finish
-endif
-if &filetype !=# 'awk'
- 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<'
diff --git a/vim/after/ftplugin/c.vim b/vim/after/ftplugin/c.vim
index d98aa130..ff74d386 100644
--- a/vim/after/ftplugin/c.vim
+++ b/vim/after/ftplugin/c.vim
@@ -1,19 +1,11 @@
-" Extra configuration for 'c' filetypes
-if exists('b:did_ftplugin_after') || &compatible
+" Extra configuration for C files
+if &filetype != 'c' || &compatible || v:version < 700
finish
endif
-if v:version < 700
- finish
-endif
-if &filetype !=# 'c'
- finish
-endif
-let b:did_ftplugin_after = 1
-let b:undo_ftplugin = b:undo_ftplugin
- \ . '|unlet b:did_ftplugin_after'
" Set comment formats
setlocal include=^\\s*#\\s*include
setlocal path+=/usr/include
let b:undo_ftplugin = b:undo_ftplugin
- \ . '|setlocal include< path<'
+ \ . '|setlocal include<'
+ \ . '|setlocal path<'
diff --git a/vim/after/ftplugin/cpp.vim b/vim/after/ftplugin/cpp.vim
index acecf3e5..9a58cfa5 100644
--- a/vim/after/ftplugin/cpp.vim
+++ b/vim/after/ftplugin/cpp.vim
@@ -1,19 +1,11 @@
-" Extra configuration for 'cpp' filetypes
-if exists('b:did_ftplugin_after') || &compatible
+" Extra configuration for C++ files
+if &filetype != 'cpp' || &compatible || v:version < 700
finish
endif
-if v:version < 700
- finish
-endif
-if &filetype !=# 'cpp'
- finish
-endif
-let b:did_ftplugin_after = 1
-let b:undo_ftplugin = b:undo_ftplugin
- \ . '|unlet b:did_ftplugin_after'
" Set comment formats
setlocal include=^\\s*#\\s*include
setlocal path+=/usr/include
let b:undo_ftplugin = b:undo_ftplugin
- \ . '|setlocal include< path<'
+ \ . '|setlocal include<'
+ \ . '|setlocal path<'
diff --git a/vim/after/ftplugin/diff.vim b/vim/after/ftplugin/diff.vim
index 6098ce48..5b0e7b31 100644
--- a/vim/after/ftplugin/diff.vim
+++ b/vim/after/ftplugin/diff.vim
@@ -1,16 +1,7 @@
-" Extra configuration for 'diff' filetypes
-if exists('b:did_ftplugin_after') || &compatible
+" Extra configuration for diffs
+if &filetype != 'diff' || &compatible || v:version < 700
finish
endif
-if v:version < 700
- finish
-endif
-if &filetype !=# 'diff'
- finish
-endif
-let b:did_ftplugin_after = 1
-let b:undo_ftplugin = b:undo_ftplugin
- \ . '|unlet b:did_ftplugin_after'
" Stop here if the user doesn't want ftplugin mappings
if exists('g:no_plugin_maps') || exists('g:no_diff_maps')
@@ -18,8 +9,10 @@ if exists('g:no_plugin_maps') || exists('g:no_diff_maps')
endif
" Set mappings
-nmap <buffer> <LocalLeader>p <Plug>DiffPrune
-xmap <buffer> <LocalLeader>p <Plug>DiffPrune
+nmap <buffer> <LocalLeader>p <Plug>(DiffPrune)
+xmap <buffer> <LocalLeader>p <Plug>(DiffPrune)
+nmap <buffer> <LocalLeader>pp <Plug>(DiffPrune)_
let b:undo_ftplugin = b:undo_ftplugin
\ . '|nunmap <buffer> <LocalLeader>p'
\ . '|xunmap <buffer> <LocalLeader>p'
+ \ . '|nunmap <buffer> <LocalLeader>pp'
diff --git a/vim/after/ftplugin/gitcommit.vim b/vim/after/ftplugin/gitcommit.vim
index d903e84e..e55ebff7 100644
--- a/vim/after/ftplugin/gitcommit.vim
+++ b/vim/after/ftplugin/gitcommit.vim
@@ -1,19 +1,11 @@
-" Extra configuration for 'gitcommit' filetypes
-if exists('b:did_ftplugin_after') || &compatible
+" Extra configuration for Git commit messages
+if &filetype != 'gitcommit' || &compatible || v:version < 700
finish
endif
-if v:version < 700
- finish
-endif
-if &filetype !=# 'gitcommit'
- finish
-endif
-let b:did_ftplugin_after = 1
-let b:undo_ftplugin = b:undo_ftplugin
- \ . '|unlet b:did_ftplugin_after'
" Make angle brackets behave like mail quotes
setlocal comments+=n:>
setlocal formatoptions+=coqr
let b:undo_ftplugin = b:undo_ftplugin
- \ . '|setlocal comments< formatoptions<'
+ \ . '|setlocal comments<'
+ \ . '|setlocal formatoptions<'
diff --git a/vim/after/ftplugin/help.vim b/vim/after/ftplugin/help.vim
new file mode 100644
index 00000000..3d9ad072
--- /dev/null
+++ b/vim/after/ftplugin/help.vim
@@ -0,0 +1,12 @@
+" Extra configuration for Vim help files
+if &filetype != 'help' || &compatible || v:version < 700
+ finish
+endif
+
+" If the buffer is modifiable and writable, we're writing documentation, not
+" reading it; don't conceal characters
+if &modifiable && !&readonly
+ setlocal conceallevel=0
+ let b:undo_ftplugin = b:undo_ftplugin
+ \ . '|setlocal conceallevel'
+endif
diff --git a/vim/after/ftplugin/html.vim b/vim/after/ftplugin/html.vim
index 8a1c22d4..d0625fb7 100644
--- a/vim/after/ftplugin/html.vim
+++ b/vim/after/ftplugin/html.vim
@@ -1,28 +1,26 @@
-" Extra configuration for 'html' filetypes
-if exists('b:did_ftplugin_after') || &compatible
+" Extra configuration for HTML files
+if &filetype != 'html' || &compatible || v:version < 700
finish
endif
-if v:version < 700
- finish
-endif
-if &filetype !=# 'html'
- finish
-endif
-let b:did_ftplugin_after = 1
+
+" Use tidy(1) for checking and program formatting
+compiler tidy
+setlocal equalprg=tidy\ -quiet
let b:undo_ftplugin = b:undo_ftplugin
- \ . '|unlet b:did_ftplugin_after'
+ \ . '|unlet b:current_compiler'
+ \ . '|setlocal equalprg<'
+ \ . '|setlocal errorformat<'
+ \ . '|setlocal makeprg<'
" Set up hooks for timestamp updating
augroup html_timestamp
- autocmd!
- autocmd BufWritePre *.html
- \ if exists('b:html_timestamp_check')
- \| call html#TimestampUpdate()
- \|endif
+ autocmd BufWritePre <buffer>
+ \ if exists('b:html_timestamp_check')
+ \| call html#TimestampUpdate()
+ \|endif
augroup END
let b:undo_ftplugin = b:undo_ftplugin
- \ . '|augroup html_timestamp|autocmd!|augroup END'
- \ . '|augroup! html_timestamp'
+ \ . '|autocmd! html_timestamp BufWritePre <buffer>'
" Stop here if the user doesn't want ftplugin mappings
if exists('g:no_plugin_maps') || exists('g:no_html_maps')
@@ -30,13 +28,7 @@ if exists('g:no_plugin_maps') || exists('g:no_html_maps')
endif
" Set mappings
-nnoremap <buffer> <LocalLeader>l
- \ :<C-U>call compiler#Make('tidy')<CR>
nnoremap <buffer> <LocalLeader>r
\ :<C-U>call html#UrlLink()<CR>
-nnoremap <buffer> <LocalLeader>t
- \ :<C-U>call filter#Stable('tidy -quiet')<CR>
let b:undo_ftplugin = b:undo_ftplugin
- \ . '|nunmap <buffer> <LocalLeader>l'
\ . '|nunmap <buffer> <LocalLeader>r'
- \ . '|nunmap <buffer> <LocalLeader>t'
diff --git a/vim/after/ftplugin/mail.vim b/vim/after/ftplugin/mail.vim
index 68e9e17a..200358d8 100644
--- a/vim/after/ftplugin/mail.vim
+++ b/vim/after/ftplugin/mail.vim
@@ -1,16 +1,7 @@
-" Extra configuration for 'mail' filetypes
-if exists('b:did_ftplugin_after') || &compatible
+" Extra configuration for mail messages
+if &filetype != 'mail' || &compatible || v:version < 700
finish
endif
-if v:version < 700
- finish
-endif
-if &filetype !=# 'mail'
- finish
-endif
-let b:did_ftplugin_after = 1
-let b:undo_ftplugin = b:undo_ftplugin
- \ . '|unlet b:did_ftplugin_after'
" Add a space to the end of wrapped lines for format-flowed mail
setlocal formatoptions+=w
diff --git a/vim/after/ftplugin/make.vim b/vim/after/ftplugin/make.vim
index 30db753f..b946d547 100644
--- a/vim/after/ftplugin/make.vim
+++ b/vim/after/ftplugin/make.vim
@@ -1,16 +1,7 @@
-" Extra configuration for 'make' filetypes
-if exists('b:did_ftplugin_after') || &compatible
+" Extra configuration for Makefiles
+if &filetype != 'make' || &compatible || v:version < 700
finish
endif
-if v:version < 700
- finish
-endif
-if &filetype !=# 'make'
- finish
-endif
-let b:did_ftplugin_after = 1
-let b:undo_ftplugin = b:undo_ftplugin
- \ . '|unlet b:did_ftplugin_after'
" Stop here if the user doesn't want ftplugin mappings
if exists('g:no_plugin_maps') || exists('g:no_make_maps')
@@ -18,6 +9,8 @@ if exists('g:no_plugin_maps') || exists('g:no_make_maps')
endif
" Set mappings
-nmap <buffer> <LocalLeader>m <Plug>MakeTarget
-let b:undo_ftplugin = b:undo_ftplugin
- \ . '|nunmap <buffer> <LocalLeader>m'
+if exists('b:undo_ftplugin')
+ nmap <buffer> <LocalLeader>m <Plug>MakeTarget
+ let b:undo_ftplugin = b:undo_ftplugin
+ \ . '|nunmap <buffer> <LocalLeader>m'
+endif
diff --git a/vim/after/ftplugin/markdown.vim b/vim/after/ftplugin/markdown.vim
index 7ec37c64..3c97dd97 100644
--- a/vim/after/ftplugin/markdown.vim
+++ b/vim/after/ftplugin/markdown.vim
@@ -1,19 +1,10 @@
-" Extra configuration for 'markdown' filetypes
-if exists('b:did_ftplugin_after') || &compatible
+" Extra configuration for Markdown documents
+if &filetype != 'markdown' || &compatible || v:version < 700
finish
endif
-if v:version < 700
- finish
-endif
-if &filetype !=# 'markdown'
- finish
-endif
-let b:did_ftplugin_after = 1
-let b:undo_ftplugin = b:undo_ftplugin
- \ . '|unlet b:did_ftplugin_after'
" Spellcheck documents we're actually editing (not just viewing)
-if !&readonly
+if &modifiable && !&readonly
setlocal spell
let b:undo_ftplugin = b:undo_ftplugin
\ . '|setlocal spell<'
diff --git a/vim/after/ftplugin/perl.vim b/vim/after/ftplugin/perl.vim
index 1a7df559..c17ebb56 100644
--- a/vim/after/ftplugin/perl.vim
+++ b/vim/after/ftplugin/perl.vim
@@ -1,33 +1,30 @@
-" Extra configuration for 'perl' filetypes
-if exists('b:did_ftplugin_after') || &compatible
+" Extra configuration for Perl filetypes
+if &filetype != 'perl' || &compatible || v:version < 700
finish
endif
-if v:version < 700
- finish
-endif
-if &filetype !=# 'perl'
- finish
-endif
-let b:did_ftplugin_after = 1
+
+" Use Perl itself for checking and Perl::Tidy for tidying
+compiler perl
+setlocal equalprg=perltidy
let b:undo_ftplugin = b:undo_ftplugin
- \ . '|unlet b:did_ftplugin_after'
+ \ . '|unlet b:current_compiler'
+ \ . '|setlocal equalprg<'
+ \ . '|setlocal errorformat<'
+ \ . '|setlocal makeprg<'
" Stop here if the user doesn't want ftplugin mappings
if exists('g:no_plugin_maps') || exists('g:no_perl_maps')
finish
endif
-" Set mappings
+" Mappings to choose compiler
nnoremap <buffer> <LocalLeader>c
- \ :<C-U>call compiler#Make('perl')<CR>
+ \ :<C-U>compiler perl<CR>
nnoremap <buffer> <LocalLeader>l
- \ :<C-U>call compiler#Make('perlcritic')<CR>
-nnoremap <buffer> <LocalLeader>t
- \ :<C-U>call filter#Stable('perltidy')<CR>
+ \ :<C-U>compiler perlcritic<CR>
let b:undo_ftplugin = b:undo_ftplugin
\ . '|nunmap <buffer> <LocalLeader>c'
\ . '|nunmap <buffer> <LocalLeader>l'
- \ . '|nunmap <buffer> <LocalLeader>t'
" Bump version numbers
nmap <buffer> <LocalLeader>v
diff --git a/vim/after/ftplugin/php.vim b/vim/after/ftplugin/php.vim
index 70e92dfd..765c1fb9 100644
--- a/vim/after/ftplugin/php.vim
+++ b/vim/after/ftplugin/php.vim
@@ -1,34 +1,27 @@
-" Extra configuration for 'php' filetypes
-if exists('b:did_ftplugin_after') || &compatible
+" Extra configuration for PHP scripts
+if &filetype != 'php' || &compatible || v:version < 700
finish
endif
-if v:version < 700
- finish
-endif
-if &filetype !=# 'php'
- finish
-endif
-let b:did_ftplugin_after = 1
+
+" Use PHP itself for syntax checking
+compiler php
let b:undo_ftplugin = b:undo_ftplugin
- \ . '|unlet b:did_ftplugin_after'
+ \ . '|unlet b:current_compiler'
+ \ . '|setlocal errorformat<'
+ \ . '|setlocal makeprg<'
" Set comment formats
setlocal comments=s1:/*,m:*,ex:*/,://,:#
setlocal formatoptions+=or
let b:undo_ftplugin = b:undo_ftplugin
- \ . '|setlocal comments< formatoptions<'
+ \ . '|setlocal comments<'
+ \ . '|setlocal formatoptions<'
" Stop here if the user doesn't want ftplugin mappings
if exists('g:no_plugin_maps') || exists('g:no_php_maps')
finish
endif
-" Set mappings
-nnoremap <buffer> <LocalLeader>c
- \ :<C-U>call compiler#Make('php')<CR>
-let b:undo_ftplugin = b:undo_ftplugin
- \ . '|nunmap <buffer> <LocalLeader>c'
-
" Get rid of the core ftplugin's square-bracket maps on unload
let b:undo_ftplugin = b:undo_ftplugin
\ . '|nunmap <buffer> [['
diff --git a/vim/after/ftplugin/sed.vim b/vim/after/ftplugin/sed.vim
index e16ec53d..f4045d93 100644
--- a/vim/after/ftplugin/sed.vim
+++ b/vim/after/ftplugin/sed.vim
@@ -1,19 +1,11 @@
-" Extra configuration for 'sed' filetypes
-if exists('b:did_ftplugin_after') || &compatible
+" Extra configuration for sed scripts
+if &filetype != 'sed' || &compatible || v:version < 700
finish
endif
-if v:version < 700
- finish
-endif
-if &filetype !=# 'sed'
- 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<'
diff --git a/vim/after/ftplugin/sh.vim b/vim/after/ftplugin/sh.vim
index 05c3e293..5cafdd70 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')
@@ -25,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'
@@ -38,12 +25,23 @@ 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:current_compiler'
+ \ . '|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 <buffer> <LocalLeader>c
- \ :<C-U>call compiler#Make(b:sh_check_compiler)<CR>
+" Mappings to choose compiler
+nnoremap <buffer> <expr> <LocalLeader>c
+ \ ':<C-U>compiler '.b:sh_check_compiler.'<CR>'
nnoremap <buffer> <LocalLeader>l
- \ :<C-U>call compiler#Make('shellcheck')<CR>
+ \ :<C-U>compiler shellcheck<CR>
let b:undo_ftplugin = b:undo_ftplugin
\ . '|nunmap <buffer> <LocalLeader>c'
\ . '|nunmap <buffer> <LocalLeader>l'
diff --git a/vim/after/ftplugin/text.vim b/vim/after/ftplugin/text.vim
index 06ca464a..0ca72122 100644
--- a/vim/after/ftplugin/text.vim
+++ b/vim/after/ftplugin/text.vim
@@ -1,19 +1,10 @@
-" Extra configuration for 'text' filetypes
-if exists('b:did_ftplugin_after') || &compatible
+" Extra configuration for text files
+if &filetype != 'text' || &compatible || v:version < 700
finish
endif
-if v:version < 700
- finish
-endif
-if &filetype !=# 'text'
- finish
-endif
-let b:did_ftplugin_after = 1
-let b:undo_ftplugin = b:undo_ftplugin
- \ . '|unlet b:did_ftplugin_after'
" Spellcheck documents we're actually editing (not just viewing)
-if !&readonly
+if &modifiable && !&readonly
setlocal spell
let b:undo_ftplugin = b:undo_ftplugin
\ . '|setlocal spell<'
diff --git a/vim/after/ftplugin/vim.vim b/vim/after/ftplugin/vim.vim
index 9710b2d8..2d11b2d6 100644
--- a/vim/after/ftplugin/vim.vim
+++ b/vim/after/ftplugin/vim.vim
@@ -1,28 +1,20 @@
-" Extra configuration for 'vim' filetypes
-if exists('b:did_ftplugin_after') || &compatible
+" Extra configuration for Vim scripts
+if &filetype != 'vim' || &compatible || v:version < 700
finish
endif
-if v:version < 700
- finish
-endif
-if &filetype !=# 'vim'
- finish
-endif
-let b:did_ftplugin_after = 1
+
+" Use Vint as a syntax checker
+compiler vint
let b:undo_ftplugin = b:undo_ftplugin
- \ . '|unlet b:did_ftplugin_after'
+ \ . '|unlet b:current_compiler'
+ \ . '|setlocal errorformat<'
+ \ . '|setlocal makeprg<'
" Stop here if the user doesn't want ftplugin mappings
if exists('g:no_plugin_maps') || exists('g:no_vim_maps')
finish
endif
-" Set mappings
-nnoremap <buffer> <LocalLeader>l
- \ :<C-U>call compiler#Make('vint')<CR>
-let b:undo_ftplugin = b:undo_ftplugin
- \ . '|nunmap <buffer> <LocalLeader>l'
-
" Get rid of the core ftplugin's square-bracket maps on unload
let b:undo_ftplugin = b:undo_ftplugin
\ . '|nunmap <buffer> [['
diff --git a/vim/after/ftplugin/zsh.vim b/vim/after/ftplugin/zsh.vim
index eb5fc035..8a27846b 100644
--- a/vim/after/ftplugin/zsh.vim
+++ b/vim/after/ftplugin/zsh.vim
@@ -1,24 +1,11 @@
-" Extra configuration for 'zsh' filetypes
-if exists('b:did_ftplugin_after') || &compatible
- finish
-endif
-if v:version < 700
- finish
-endif
-if &filetype !=# 'zsh'
- finish
-endif
-let b:did_ftplugin_after = 1
-let b:undo_ftplugin = b:undo_ftplugin
- \ . '|unlet b:did_ftplugin_after'
-
-" Stop here if the user doesn't want ftplugin mappings
-if exists('g:no_plugin_maps') || exists('g:no_zsh_maps')
+" Extra configuration for Z shell scripts
+if &filetype != 'zsh' || &compatible || v:version < 700
finish
endif
-" Set mappings
-nnoremap <buffer> <LocalLeader>c
- \ :<C-U>call compiler#Make('zsh')<CR>
+" Use Z shell itself as a syntax checker
+compiler zsh
let b:undo_ftplugin = b:undo_ftplugin
- \ . '|nunmap <buffer> <LocalLeader>c'
+ \ . '|unlet b:current_compiler'
+ \ . '|setlocal errorformat<'
+ \ . '|setlocal makeprg<'
diff --git a/vim/after/syntax/gitcommit.vim b/vim/after/syntax/gitcommit.vim
new file mode 100644
index 00000000..e47091f9
--- /dev/null
+++ b/vim/after/syntax/gitcommit.vim
@@ -0,0 +1,2 @@
+" If my commit subject is too long, highlight it as an error.
+highlight link gitCommitOverflow Error
diff --git a/vim/autoload/compiler.vim b/vim/autoload/compiler.vim
deleted file mode 100644
index b4bf66b6..00000000
--- a/vim/autoload/compiler.vim
+++ /dev/null
@@ -1,33 +0,0 @@
-" Run a compiler check (:lmake, :lwindow) without trampling over previous
-" settings, by temporarily loading the compiler with the given name
-function! compiler#Make(compiler) abort
-
- " Save the given compiler or failing that the current 'makeprg' and
- " 'errorformat' values
- if exists('b:current_compiler')
- let l:save_compiler = b:current_compiler
- else
- let l:save_makeprg = &makeprg
- let l:save_errorformat = &errorformat
- endif
-
- " Choose the compiler
- execute 'compiler ' . a:compiler
-
- " Run the 'makeprg' with results in location list
- lmake!
-
- " If we saved a compiler, switch back to it, otherwise restore the previous
- " values for 'makeprg' and 'errorformat'
- if exists('l:save_compiler')
- execute 'compiler ' . l:save_compiler
- else
- unlet! b:current_compiler
- let &l:makeprg = l:save_makeprg
- let &l:errorformat = l:save_errorformat
- endif
-
- " Show location list
- lwindow
-
-endfunction
diff --git a/vim/autoload/filter.vim b/vim/autoload/filter.vim
deleted file mode 100644
index 0a39f23a..00000000
--- a/vim/autoload/filter.vim
+++ /dev/null
@@ -1,7 +0,0 @@
-" Run a filter over the entire buffer, but save the window position and
-" restore it after doing so
-function! filter#Stable(command) abort
- let l:view = winsaveview()
- execute '%!' . a:command
- call winrestview(l:view)
-endfunction
diff --git a/vim/autoload/shebang.vim b/vim/autoload/shebang.vim
deleted file mode 100644
index f39fcf48..00000000
--- a/vim/autoload/shebang.vim
+++ /dev/null
@@ -1,7 +0,0 @@
-" If the first line was changed in the last insert operation, re-run script
-" detection
-function! shebang#Update() abort
- if line("'[") == 1
- runtime scripts.vim
- endif
-endfunction
diff --git a/vim/autoload/vimrc.vim b/vim/autoload/vimrc.vim
new file mode 100644
index 00000000..0dff8ffd
--- /dev/null
+++ b/vim/autoload/vimrc.vim
@@ -0,0 +1,6 @@
+" Run some normal-mode keystrokes without jumping around
+function! vimrc#Anchor(keys) abort
+ let l:view = winsaveview()
+ execute 'normal! '.a:keys
+ call winrestview(l:view)
+endfunction
diff --git a/vim/bundle/diff_prune b/vim/bundle/diff_prune
-Subproject 3f2fac88e3bd4debd263f01dcab90e7eec5a4a6
+Subproject e015502fa63ff48ffb0493dd21106b0855f2636
diff --git a/vim/filetype.vim b/vim/filetype.vim
index ad2545a0..6bb52b96 100644
--- a/vim/filetype.vim
+++ b/vim/filetype.vim
@@ -42,6 +42,14 @@ function! s:StripRepeat()
endfunction
+" Check whether the first line was changed and looks like a shebang, and if
+" so, re-run filetype detection
+function! s:CheckShebang()
+ if line('''[') == 1 && stridx(getline(1), '#!') == 0
+ doautocmd filetypedetect BufRead
+ endif
+endfunction
+
" Use our own filetype detection rules
augroup filetypedetect
autocmd!
@@ -165,6 +173,8 @@ augroup filetypedetect
" Vim help files
autocmd BufNewFile,BufRead
\ ~/.vim/doc/?*.txt
+ \,*/vim-*/doc/?*.txt
+ \,*/*.vim/doc/?*.txt
\,$VIMRUNTIME/doc/?*.txt
\ setfiletype help
" HTML files
@@ -499,13 +509,20 @@ augroup filetypedetect
\| call s:StripRepeat()
\|endif
- " If we *still* don't have a filetype, run the scripts.vim file that will
- " examine actual file contents--but only the first one; don't load the
- " system one at all
+ " If we still don't have a filetype, run the scripts.vim file that performs
+ " cleverer checks including looking at actual file contents--but only my
+ " custom one; don't load the system one at all.
autocmd BufNewFile,BufRead,StdinReadPost
\ *
\ if !did_filetype()
\| runtime scripts.vim
\|endif
+ " If supported, on leaving insert mode, check whether the first line was
+ " changed and looks like a shebang format, and if so, re-run filetype
+ " detection
+ if v:version > 700
+ autocmd InsertLeave * call s:CheckShebang()
+ endif
+
augroup END
diff --git a/vim/ftdetect/perl.vim b/vim/ftdetect/perl.vim
new file mode 100644
index 00000000..8b2e1b4e
--- /dev/null
+++ b/vim/ftdetect/perl.vim
@@ -0,0 +1,9 @@
+" If it's a new file in a bin, libexec, or scripts subdir that has a
+" Makefile.PL, it's almost definitely Perl.
+autocmd BufNewFile
+ \ */bin/*
+ \,*/libexec/*
+ \,*/scripts/*
+ \ if filereadable(expand('<afile>:p:h:h') . '/Makefile.PL')
+ \| setfiletype perl
+ \|endif
diff --git a/vim/indent/html.vim b/vim/indent/html.vim
new file mode 100644
index 00000000..b0a4a4f6
--- /dev/null
+++ b/vim/indent/html.vim
@@ -0,0 +1,2 @@
+" Indent after <p> paragraph tags too
+let g:html_indent_inctags = 'p'
diff --git a/vim/indent/perl.vim b/vim/indent/perl.vim
deleted file mode 100644
index aac8f818..00000000
--- a/vim/indent/perl.vim
+++ /dev/null
@@ -1,137 +0,0 @@
-" Custom Vim indent file for Perl5; the stock one didn't suit me.
-
-" Only load this indent file when no other was loaded.
-if exists('b:did_indent') || &compatible
- finish
-endif
-let b:did_indent = 1
-
-" Indent settings
-setlocal indentexpr=GetPerlIndent(v:lnum)
-setlocal indentkeys=o,O,0=,0=},0=),0=],0=&&,0=\|\|,0=//,0=?,0=:,<Space>
-
-" Build patterns for heredoc indenting. Note that we detect indented heredocs
-" with tildes like <<~EOF, but we don't treat them any differently. We don't
-" strictly match the quotes either, in an effort to keep this fast.
-let s:heredoc_word = '\I\i*'
-let s:heredoc_open = '<<\~\?'
- \ . '\('
- \ . '\\\?' . s:heredoc_word
- \ . '\|'
- \ . "['`\"]" . s:heredoc_word . "['`\"]"
- \ . '\)'
- \ . '.*;\s*$'
-
-" Define indent function
-function! GetPerlIndent(lnum)
-
- " Get previous line, bail if none
- let l:pn = prevnonblank(a:lnum - 1)
- if !l:pn
- return 0
- endif
-
- " Heredoc and POD flags
- let l:heredoc = 0
- let l:pod = 0
-
- " Start loop back through up to 512 lines of context
- let l:lim = 512
- let l:hpn = a:lnum > l:lim ? a:lnum - l:lim : 0
- while l:hpn < a:lnum
- let l:hpl = getline(l:hpn)
-
- " If we're not in a heredoc and not in a comment ...
- if !l:heredoc && l:hpl !~# '^\s*#'
-
- " POD switching; match any section so that we can handle long PODs
- if stridx(l:hpl, '=') == 0
- let l:pod = stridx(l:hpl, '=cut') != 0
-
- " Heredoc switch on
- else
- let l:hpm = matchstr(l:hpl, s:heredoc_open)
- if strlen(l:hpm)
- let l:heredoc = 1
- let l:hpw = matchstr(l:hpm, s:heredoc_word)
- let l:pn = l:hpn
- endif
- endif
-
- " If we are in a heredoc and we found the token word, finish it
- elseif l:heredoc && l:hpl =~# '^'.l:hpw.'\>'
- let l:heredoc = 0
- unlet l:hpw
- endif
-
- " Bump the loop index
- let l:hpn = l:hpn + 1
-
- endwhile
-
- " If we ended up in a heredoc, never indent.
- if l:heredoc
- return 0
- endif
-
- " If we're in POD, just autoindent; simple and good enough.
- if l:pod
- return indent(a:lnum - 1)
- endif
-
- " Get data of previous non-blank and non-heredoc line
- let l:pl = getline(l:pn)
- let l:pi = indent(l:pn)
-
- " Just follow comment indent
- if l:pl =~# '^\s*#'
- return l:pi
- endif
-
- " Get current line properties
- let l:cl = getline(a:lnum)
-
- " Get value of 'shiftwidth'
- let l:sw = &shiftwidth ? &shiftwidth : &tabstop
-
- " Base indent with any fractional indent removed
- let l:pb = l:pi - l:pi % l:sw
-
- " Handle open and closing brackets
- let l:open = l:pl =~# '[{([]\s*$'
- let l:shut = l:cl =~# '^\s*[])}]'
- if l:open || l:shut
- let l:in = l:pb
- if l:open
- let l:in = l:in + l:sw
- endif
- if l:shut
- let l:in = l:in - l:sw
- endif
- return l:in > 0 ? l:in : 0
- endif
-
- " Never continue after a semicolon or a double-underscore
- if l:pl =~# '\;\s*$'
- \ || l:pl =~# '__DATA__'
- \ || l:pl =~# '__END__'
- return l:pb
-
- " Line continuation hints
- elseif l:cl =~# '^\s*\(and\|or\|xor\)'
- \ || l:cl =~# '^\s*\(&&\|||\|//\)'
- \ || l:cl =~# '^\s*[?:=]'
- return l:pb + l:sw / 2
-
- " Default to indent of previous line
- else
- return l:pb
-
- endif
-
-endfunction
-
-" How to undo all of that
-let b:undo_indent = 'setlocal indentexpr<'
- \ . '|setlocal indentkeys<'
- \ . '|delfunction GetPerlIndent'
diff --git a/vim/plugin/matchit.vim b/vim/plugin/matchit.vim
index 31e6e37d..4507640e 100644
--- a/vim/plugin/matchit.vim
+++ b/vim/plugin/matchit.vim
@@ -1,6 +1,6 @@
" Get matchit.vim, one way or another
if has('packages') && !has('nvim')
- packadd! matchit
+ packadd matchit
else
silent! runtime macros/matchit.vim
endif
diff --git a/vim/plugin/shebang_update.vim b/vim/plugin/shebang_update.vim
deleted file mode 100644
index 1dbcaf67..00000000
--- a/vim/plugin/shebang_update.vim
+++ /dev/null
@@ -1,20 +0,0 @@
-"
-" shabeng_update.vim: If the first line of a file was changed, re-run
-" scripts.vim to do shebang detection to update the filetype.
-"
-" Author: Tom Ryder <tom@sanctum.geek.nz>
-" License: Same as Vim itself
-"
-if exists('g:loaded_shebang_update') || &compatible
- finish
-endif
-if v:version < 700
- finish
-endif
-let g:loaded_shebang_update = 1
-
-" Call the update function whenever leaving insert mode
-augroup shebang_update
- autocmd!
- autocmd InsertLeave * call shebang#Update()
-augroup END
diff --git a/vim/scripts.vim b/vim/scripts.vim
index cbef0b4e..2dc602d7 100644
--- a/vim/scripts.vim
+++ b/vim/scripts.vim
@@ -6,7 +6,7 @@
let s:line = getline(1)
" If it's not a shebang, we're done
-if s:line !~# '\m^#!'
+if stridx(s:line, '#!') != 0
finish
endif
diff --git a/vim/vimrc b/vim/vimrc
index 982bd5ba..3678e375 100644
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -9,7 +9,7 @@ runtime system.vim
" Load filetype settings, plugins, and maps
if has('autocmd')
- let g:maplocalleader = '\\'
+ let g:maplocalleader = ','
filetype plugin indent on
endif
@@ -32,15 +32,15 @@ if has('syntax') && !exists('g:syntax_on')
endif
" The all-important default indent settings; filetypes to tweak
-setglobal autoindent " Use indent of previous line on new lines
-setglobal expandtab " Use spaces instead of tabs
-setglobal shiftwidth=4 " Indent with four spaces
+set autoindent " Use indent of previous line on new lines
+set expandtab " Use spaces instead of tabs
+set shiftwidth=4 " Indent with four spaces
" Spaces to insert on Tab key insert
if v:version > 703 || v:version == 703 && has('patch693')
- setglobal softtabstop=-1 " Refer to 'shiftwidth' if supported
+ set softtabstop=-1 " Refer to 'shiftwidth' if supported
else
- setglobal softtabstop=4 " Otherwise just four spaces
+ set softtabstop=4 " Otherwise just four spaces
endif
" Let me backspace over pretty much anything
@@ -69,14 +69,14 @@ endif
" Delete comment leaders when joining lines, if supported
if v:version > 703 || v:version == 703 && has('patch541')
- setglobal formatoptions+=j
+ set formatoptions+=j
endif
" Keep more command and search history
set history=500
" Don't assume I'm editing C; let the filetype set this
-setglobal include=
+set include=
" Don't join lines with two spaces at the end of sentences
set nojoinspaces
@@ -99,13 +99,13 @@ if v:version >= 700
endif
" Add angle brackets to pairs of matched characters
-setglobal matchpairs+=<:>
+set matchpairs+=<:>
" Don't allow setting options via buffer content
-setglobal nomodeline
+set nomodeline
" Treat numbers with a leading zero as decimal, not octal
-setglobal nrformats-=octal
+set nrformats-=octal
" Abbreviate some more regularly displayed messages
set shortmess+=I " Don't show startup splash screen
@@ -115,7 +115,7 @@ set shortmess+=w " written -> [w], appended -> [a]
" Clear default 'comments' value, let the filetype handle it
if has('comments')
- setglobal comments=
+ set comments=
endif
" Highlight settings for search
@@ -127,7 +127,7 @@ endif
" More sensible language-agnostic setting for gf/:find
if has('file_in_path')
- setglobal path=.,,**
+ set path=.,,**
endif
" Don't load GUI menus; set here before GUI starts
@@ -137,10 +137,10 @@ endif
" Line break behaviour settings for 'wrap'
if has('linebreak')
- setglobal linebreak " Break lines at word boundaries
- set showbreak=... " Prefix wrapped rows with three dots
+ set linebreak " Break lines at word boundaries
+ set showbreak=... " Prefix wrapped rows with three dots
if exists('+breakindent')
- setglobal breakindent " Indent wrapped lines, if supported
+ set breakindent " Indent wrapped lines, if supported
endif
endif
@@ -180,16 +180,12 @@ imap <C-C> <Plug>InsertCancel
nnoremap <Plug>FixedJoin mzJ`z
nmap J <Plug>FixedJoin
-" Remap normal/visual <Space> to scroll down a page
+" Remap normal/visual space to scroll down a page, backspace up
nnoremap <Space> <C-F>
+nnoremap <BS> <C-B>
if v:version >= 700
xnoremap <Space> <C-F>
-endif
-
-" Remap normal/visual <Backspace> to scroll up a page
-nnoremap <Backspace> <C-B>
-if v:version >= 700
- xnoremap <Backspace> <C-B>
+ xnoremap <BS> <C-B>
endif
" Remap normal/visual & to preserve substitution flags
@@ -273,7 +269,7 @@ nnoremap <Bslash>s :<C-U>setlocal spell! spell?<CR>
" \t shows current filetype
nnoremap <Bslash>t :<C-U>setlocal filetype?<CR>
" \T clears filetype (follow with \R)
-nnoremap <Bslash>T :<C-U>setlocal filetype=NONE<CR>
+nnoremap <Bslash>T :<C-U>setlocal filetype=<CR>
" \u sets US English spelling (compare \z)
nnoremap <Bslash>u :<C-U>setlocal spelllang=en_us<CR>
" \v shows all global variables
@@ -289,6 +285,13 @@ nnoremap <Bslash>y :<C-U>registers<CR>
" \z sets NZ English spelling (compare \u)
nnoremap <Bslash>z :<C-U>setlocal spelllang=en_nz<CR>
+" \= runs the whole buffer through =, preserving position
+nnoremap <Bslash>= :<C-U>call vimrc#Anchor('1G=G')<CR>
+" \+ runs the whole buffer through gq, preserving position
+nnoremap <Bslash>+ :<C-U>call vimrc#Anchor('1GgqG')<CR>
+" \. runs the configured make program to location list
+nnoremap <Bslash>. :<C-U>lmake!<CR>
+
" \DEL deletes the current buffer
nnoremap <Bslash><Delete> :<C-U>bdelete<CR>
" \INS edits a new buffer
@@ -297,10 +300,14 @@ nnoremap <Bslash><Insert> :<C-U>enew<CR>
" Source any .vim files from ~/.vim/config
runtime! config/*.vim
-" Flag that we loaded, tell the user if we reload
-if 1
- if exists('g:loaded_vimrc')
- echomsg 'Reloaded vimrc: '.$MYVIMRC
+" If we reloaded, reload filetype detection for the active buffer too, so that
+" any local settings for it are restored
+if exists('g:loaded_vimrc')
+ if &filetype !=# ''
+ doautocmd filetypedetect BufRead
endif
+ echomsg 'Reloaded vimrc: '.$MYVIMRC
+endif
+if 1
let g:loaded_vimrc = 1
endif