diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2018-07-16 09:22:44 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2018-07-16 09:22:44 +1200 |
commit | d7491b213b2f0df6da97f2f1c951cb070b9513a5 (patch) | |
tree | a3a2df95aae0f674dd21736a9ab1d13c31de96e4 | |
parent | Merge branch 'release/v1.30.0' (diff) | |
parent | Bump VERSION (diff) | |
download | dotfiles-d7491b213b2f0df6da97f2f1c951cb070b9513a5.tar.gz dotfiles-d7491b213b2f0df6da97f2f1c951cb070b9513a5.zip |
Merge branch 'release/v1.31.0'v1.31.0
* release/v1.31.0:
Bump VERSION
Add shebang_create_exec.vim plugin
Add missing <buffer> to mail quote unmaps
Update plugins
Remove pattern \m where not needed for 'magic'
Simplify/correct Korn shell shebang matching
Use non-capturing groups in VimL where appropriate
Use \= in preference to \+ in VimL patterns
Add plugin file for setting 'wildignore'
Update auto_cache_dirs.vim plugin
Check for +autocmd before gitcommit ftplugin hooks
Adaptive 'colorcolumn' for gitcommit filetype
-rw-r--r-- | VERSION | 4 | ||||
-rw-r--r-- | vim/after/ftplugin/gitcommit.vim | 16 | ||||
-rw-r--r-- | vim/after/ftplugin/mail.vim | 6 | ||||
-rw-r--r-- | vim/after/ftplugin/markdown.vim | 6 | ||||
-rw-r--r-- | vim/autoload/gitcommit.vim | 20 | ||||
m--------- | vim/bundle/auto_cache_dirs | 0 | ||||
m--------- | vim/bundle/markdown_autoformat | 0 | ||||
m--------- | vim/bundle/toggle_option_flags | 0 | ||||
-rw-r--r-- | vim/filetype.vim | 6 | ||||
-rw-r--r-- | vim/plugin/shebang_create_exec.vim | 35 | ||||
-rw-r--r-- | vim/plugin/wildignore.vim | 170 | ||||
-rw-r--r-- | vim/scripts.vim | 22 | ||||
-rw-r--r-- | vim/vimrc | 1 |
13 files changed, 261 insertions, 25 deletions
@@ -1,2 +1,2 @@ -tejr dotfiles v1.30.0 -Sat Jul 14 08:52:21 UTC 2018 +tejr dotfiles v1.31.0 +Sun Jul 15 21:22:13 UTC 2018 diff --git a/vim/after/ftplugin/gitcommit.vim b/vim/after/ftplugin/gitcommit.vim index 4f57a407..7fab5a92 100644 --- a/vim/after/ftplugin/gitcommit.vim +++ b/vim/after/ftplugin/gitcommit.vim @@ -8,6 +8,16 @@ setlocal comments+=n:> setlocal formatoptions+=coqr let b:undo_ftplugin .= '|setlocal comments< formatoptions<' +" Choose the color column depending on non-comment line count +if has('autocmd') && exists('+cursorcolumn') + augroup gitcommit + autocmd CursorMoved,CursorMovedI <buffer> + \ let &l:colorcolumn = gitcommit#CursorColumn() + augroup END + let b:undo_ftplugin .= '|autocmd! gitcommit' + \ . '|augroup! gitcommit' +endif + " Stop here if the user doesn't want ftplugin mappings if exists('g:no_plugin_maps') || exists('g:no_gitcommit_maps') finish @@ -17,6 +27,6 @@ endif nnoremap <buffer> <expr> <LocalLeader>q quote#Quote() nnoremap <buffer> <expr> <LocalLeader>qq quote#Quote().'_' xnoremap <buffer> <expr> <LocalLeader>q quote#Quote() -let b:undo_ftplugin .= '|nunmap <LocalLeader>q' - \ . '|nunmap <LocalLeader>qq' - \ . '|xunmap <LocalLeader>q' +let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>q' + \ . '|nunmap <buffer> <LocalLeader>qq' + \ . '|xunmap <buffer> <LocalLeader>q' diff --git a/vim/after/ftplugin/mail.vim b/vim/after/ftplugin/mail.vim index 0867311a..3e3a08c5 100644 --- a/vim/after/ftplugin/mail.vim +++ b/vim/after/ftplugin/mail.vim @@ -24,6 +24,6 @@ endif nnoremap <buffer> <expr> <LocalLeader>q quote#Quote() nnoremap <buffer> <expr> <LocalLeader>qq quote#Quote().'_' xnoremap <buffer> <expr> <LocalLeader>q quote#Quote() -let b:undo_ftplugin .= '|nunmap <LocalLeader>q' - \ . '|nunmap <LocalLeader>qq' - \ . '|xunmap <LocalLeader>q' +let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>q' + \ . '|nunmap <buffer> <LocalLeader>qq' + \ . '|xunmap <buffer> <LocalLeader>q' diff --git a/vim/after/ftplugin/markdown.vim b/vim/after/ftplugin/markdown.vim index 26b42849..38f2a8b9 100644 --- a/vim/after/ftplugin/markdown.vim +++ b/vim/after/ftplugin/markdown.vim @@ -30,6 +30,6 @@ endif nnoremap <buffer> <expr> <LocalLeader>q quote#Quote() nnoremap <buffer> <expr> <LocalLeader>qq quote#Quote().'_' xnoremap <buffer> <expr> <LocalLeader>q quote#Quote() -let b:undo_ftplugin .= '|nunmap <LocalLeader>q' - \ . '|nunmap <LocalLeader>qq' - \ . '|xunmap <LocalLeader>q' +let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>q' + \ . '|nunmap <buffer> <LocalLeader>qq' + \ . '|xunmap <buffer> <LocalLeader>q' diff --git a/vim/autoload/gitcommit.vim b/vim/autoload/gitcommit.vim new file mode 100644 index 00000000..56b35ba6 --- /dev/null +++ b/vim/autoload/gitcommit.vim @@ -0,0 +1,20 @@ +" Choose the color column depending on non-comment line count +function! gitcommit#CursorColumn() abort + + " Last line number + let l:ll = line('$') + + " If we can find a line after the first that isn't a comment, we're + " composing the message + if l:ll > 1 + for l:li in range(2, l:ll) + if getline(l:li) !~# '^\s*#' + return '+1' + endif + endfor + endif + + " Otherwise, we're still composing our subject + return '51' + +endfunction diff --git a/vim/bundle/auto_cache_dirs b/vim/bundle/auto_cache_dirs -Subproject 331bcdef619118fe98c9c32bb844e7af8733cf8 +Subproject 70ce18086dcd84044b307d1481ae8651b9edd4a diff --git a/vim/bundle/markdown_autoformat b/vim/bundle/markdown_autoformat -Subproject aea3e81506a08945dabc2766fe0a7b4d59d67fc +Subproject dc5d96400412f63a170e87bc7e947743df07b76 diff --git a/vim/bundle/toggle_option_flags b/vim/bundle/toggle_option_flags -Subproject 1a8ff0ee47debbd9ee15d7338434f953e9d322f +Subproject 4c6224a138eb5a479a462df3f384266bd9cfeff diff --git a/vim/filetype.vim b/vim/filetype.vim index 33d08f0b..00e47c0c 100644 --- a/vim/filetype.vim +++ b/vim/filetype.vim @@ -23,11 +23,11 @@ function! s:StripRepeat() let l:fn = expand('<afile>') " Strip leading and trailing #hashes# - if l:fn =~# '\m^#\+.*#\+$' - let l:fn = substitute(l:fn, '\m^#\+\(.\+\)#\+$', '\1', '') + if l:fn =~# '^#\+.*#\+$' + let l:fn = substitute(l:fn, '^#\+\(.\+\)#\+$', '\1', '') " Strip trailing tilde~ - elseif l:fn =~# '\m\~$' + elseif l:fn =~# '\~$' let l:fn = substitute(l:fn, '\~$', '', '') " Strip generic .extension diff --git a/vim/plugin/shebang_create_exec.vim b/vim/plugin/shebang_create_exec.vim new file mode 100644 index 00000000..7fabd8f7 --- /dev/null +++ b/vim/plugin/shebang_create_exec.vim @@ -0,0 +1,35 @@ +" +" shebang_create_exec.vim: Make a file executable on first save if it starts with a +" shebang. +" +" Author: Tom Ryder <tom@sanctum.geek.nz> +" License: Same as Vim itself +" +if exists('g:loaded_shebang_create_exec') || &compatible + finish +endif +if !has('autocmd') || !has('unix') || !exists('*shellescape') + finish +endif +let g:loaded_shebang_create_exec = 1 + +" Set up hook for before writes to check the buffer for new shebangs +augroup shebang_create_exec + autocmd! + autocmd BufWritePre * call s:Check(expand('<afile>:p')) +augroup END + +" If the buffer starts with a shebang and the file being saved to doesn't +" exist yet, set up a hook to make it executable after the write is done +function! s:Check(filename) abort + if stridx(getline(1), '#!') == 0 && !filereadable(a:filename) + autocmd shebang_create_exec BufWritePost <buffer> + \ call s:Chmod(expand('<afile>:p')) + endif +endfunction + +" Make the file executable and clear away the hook that called us +function! s:Chmod(filename) abort + autocmd! shebang_create_exec BufWritePost <buffer> + call system('chmod +x '.shellescape(a:filename)) +endfunction diff --git a/vim/plugin/wildignore.vim b/vim/plugin/wildignore.vim new file mode 100644 index 00000000..fb190bce --- /dev/null +++ b/vim/plugin/wildignore.vim @@ -0,0 +1,170 @@ +" Don't complete certain files that I'm not likely to want to manipulate +" from within Vim; this is kind of expensive to reload, so I've made it a +" plugin with a load guard +if v:version < 700 || !has('wildignore') + finish +endif +if exists('g:loaded_wildmenu') + finish +endif +let g:loaded_wildmenu = 1 + +" Helper function for local scope +function! s:Wildignore() abort + + " New empty array + let l:ignores = [] + + " Archives + let l:ignores += [ + \ '*.7z' + \,'*.bz2' + \,'*.gz' + \,'*.jar' + \,'*.rar' + \,'*.tar' + \,'*.xz' + \,'*.zip' + \ ] + + " Bytecode + let l:ignores += [ + \ '*.class' + \,'*.pyc' + \ ] + + " Databases + let l:ignores += [ + \ '*.db' + \,'*.dbm' + \,'*.sdbm' + \,'*.sqlite' + \ ] + + " Disk + let l:ignores += [ + \ '*.adf' + \,'*.bin' + \,'*.hdf' + \,'*.iso' + \ ] + + " Documents + let l:ignores += [ + \ '*.docx' + \,'*.djvu' + \,'*.odp' + \,'*.ods' + \,'*.odt' + \,'*.pdf' + \,'*.ppt' + \,'*.xls' + \,'*.xlsx' + \ ] + + " Encrypted + let l:ignores += [ + \ '*.asc' + \,'*.gpg' + \ ] + + " Executables + let l:ignores += [ + \ '*.exe' + \ ] + + " Fonts + let l:ignores += [ + \ '*.ttf' + \ ] + + " Images + let l:ignores += [ + \ '*.bmp' + \,'*.gd2' + \,'*.gif' + \,'*.ico' + \,'*.jpeg' + \,'*.jpg' + \,'*.pbm' + \,'*.png' + \,'*.psd' + \,'*.tga' + \,'*.xbm' + \,'*.xcf' + \,'*.xpm' + \ ] + + " Incomplete + let l:ignores += [ + \ '*.filepart' + \ ] + + " Objects + let l:ignores += [ + \ '*.a' + \,'*.o' + \ ] + + " Sound + let l:ignores += [ + \ '*.au' + \,'*.aup' + \,'*.flac' + \,'*.mid' + \,'*.m4a' + \,'*.mp3' + \,'*.ogg' + \,'*.opus' + \,'*.s3m' + \,'*.wav' + \ ] + + " System-specific + let l:ignores += [ + \ '.DS_Store' + \ ] + + " Translation + let l:ignores += [ + \ '*.gmo' + \ ] + + " Version control + let l:ignores += [ + \ '.git' + \,'.hg' + \,'.svn' + \ ] + + " Video + let l:ignores += [ + \ '*.avi' + \,'*.gifv' + \,'*.mp4' + \,'*.ogv' + \,'*.rm' + \,'*.swf' + \,'*.webm' + \ ] + + " Vim + let l:ignores += [ + \ '*~' + \,'*.swp' + \ ] + + " For any that had lowercase letters, add their uppercase analogues + for l:ignore in l:ignores + if l:ignore =~# '\l' + call add(l:ignores, toupper(l:ignore)) + endif + endfor + + " Return the completed setting + return join(l:ignores, ',') + +endfunction + +" Run helper function just defined +let &wildignore = s:Wildignore() diff --git a/vim/scripts.vim b/vim/scripts.vim index 2dc602d7..ae792ada 100644 --- a/vim/scripts.vim +++ b/vim/scripts.vim @@ -11,50 +11,50 @@ if stridx(s:line, '#!') != 0 endif " AWK -if s:line =~# '\m\<[gm]\?awk\>' +if s:line =~# '\<[gm]\=awk\>' setfiletype awk " Perl 5 -elseif s:line =~# '\m\<perl5\?\>' +elseif s:line =~# '\<perl5\=\>' setfiletype perl " Perl 6 -elseif s:line =~# '\m\<perl6\>' +elseif s:line =~# '\<perl6\>' setfiletype perl6 " PHP -elseif s:line =~# '\m\<php\>' +elseif s:line =~# '\<php\>' setfiletype php " Python -elseif s:line =~# '\m\<python[23]\?\>' +elseif s:line =~# '\<python[23]\=\>' setfiletype python " Ruby -elseif s:line =~# '\m\<ruby[23]\?\>' +elseif s:line =~# '\<ruby[23]\=\>' setfiletype ruby " sed -elseif s:line =~# '\m\<sed\>' +elseif s:line =~# '\<sed\>' setfiletype sed " Bash -elseif s:line =~# '\m\<bash\>' +elseif s:line =~# '\<bash\>' let b:is_bash = 1 setfiletype sh " Korn shell -elseif s:line =~# '\m\<\(m\|pd\)\?ksh\(93\)\?\>' +elseif s:line =~# '\<\%(\ksh\|ksh93\|mksh\|pdksh\)\>' let b:is_kornshell = 1 setfiletype sh " POSIX/Bourne shell -elseif s:line =~# '\m\<sh\>' +elseif s:line =~# '\<sh\>' let b:is_posix = 1 setfiletype sh " TCL -elseif s:line =~# '\m\<\(tcl\|wish\)\>' +elseif s:line =~# '\<\%(tcl\|wish\)\>' setfiletype tcl endif @@ -154,6 +154,7 @@ if has('wildmenu') if exists('+wildignorecase') set wildignorecase " Case insensitive, if supported endif + " 'wildignore' is built in plugin/wildignore.vim endif " New windows go below or to the right of a split |