diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2019-06-06 22:51:06 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2019-06-06 22:51:06 +1200 |
commit | 41a77e7b5f44955b55c87fbf6f16582251477543 (patch) | |
tree | 742e42aa5a083879b940ffb951c95d60f1f96487 | |
parent | Merge branch 'release/v5.18.0' (diff) | |
parent | Bump VERSION (diff) | |
download | dotfiles-41a77e7b5f44955b55c87fbf6f16582251477543.tar.gz dotfiles-41a77e7b5f44955b55c87fbf6f16582251477543.zip |
Merge branch 'release/v5.19.0'v5.19.0
* release/v5.19.0: (22 commits)
Reset colorscheme rather than calling default
Remove recursion from some maps that don't need it
Stop wasting version pattern match, use submatches
Simplify version comparison
Change a variable name
Correct pattern in version match string
Switch to regex-based &runtimepath split
Actually correct 'runtimepath' dissection code
Improve handling of awkward filenames in options
Add a couple of 'formatoptions'
Use vimrc#EscapeSet() consistently
Remove overzealous checks from gitcommit ftplugin
Factor out plugin availability checks to function
Adjust a few version check comments
Use more natural test for &runtimepath value
Add missing 'abort' attribute to new function
Remove overkill environment variable
Adjust layout of 'formatoptions'
Use autoload function for escaping :set values
...
-rw-r--r-- | VERSION | 4 | ||||
-rw-r--r-- | vim/after/ftplugin/gitcommit.vim | 16 | ||||
-rw-r--r-- | vim/autoload/.vimrc.vim.un~ | bin | 0 -> 96333 bytes | |||
-rw-r--r-- | vim/autoload/vimrc.vim | 95 | ||||
-rw-r--r-- | vim/autoload/vimrc.vim~ | 54 | ||||
m--------- | vim/bundle/squeeze_repeat_blanks | 0 | ||||
-rw-r--r-- | vim/vimrc | 55 |
7 files changed, 128 insertions, 96 deletions
@@ -1,2 +1,2 @@ -tejr dotfiles v5.18.0 -Wed Jun 5 11:57:17 UTC 2019 +tejr dotfiles v5.19.0 +Thu Jun 6 10:51:06 UTC 2019 diff --git a/vim/after/ftplugin/gitcommit.vim b/vim/after/ftplugin/gitcommit.vim index bac342f0..4a1c3814 100644 --- a/vim/after/ftplugin/gitcommit.vim +++ b/vim/after/ftplugin/gitcommit.vim @@ -4,15 +4,13 @@ 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_cursorcolumn - autocmd CursorMoved,CursorMovedI <buffer> - \ let &l:colorcolumn = gitcommit#CursorColumn() - augroup END - let b:undo_ftplugin .= '|execute ''autocmd! gitcommit_cursorcolumn''' - \ . '|augroup! gitcommit_cursorcolumn' - \ . '|setlocal colorcolumn<' -endif +augroup gitcommit_cursorcolumn + autocmd CursorMoved,CursorMovedI <buffer> + \ let &l:colorcolumn = gitcommit#CursorColumn() +augroup END +let b:undo_ftplugin .= '|execute ''autocmd! gitcommit_cursorcolumn''' + \ . '|augroup! gitcommit_cursorcolumn' + \ . '|setlocal colorcolumn<' " Stop here if the user doesn't want ftplugin mappings if exists('no_plugin_maps') || exists('no_gitcommit_maps') diff --git a/vim/autoload/.vimrc.vim.un~ b/vim/autoload/.vimrc.vim.un~ Binary files differnew file mode 100644 index 00000000..9ad13933 --- /dev/null +++ b/vim/autoload/.vimrc.vim.un~ diff --git a/vim/autoload/vimrc.vim b/vim/autoload/vimrc.vim index bfbae263..94922e93 100644 --- a/vim/autoload/vimrc.vim +++ b/vim/autoload/vimrc.vim @@ -1,74 +1,53 @@ -" Split a string with a split character that can be escaped with another, -" e.g. &runtimepath with commas and backslashes respectively -function! vimrc#SplitEscaped(str, ...) abort - - " Arguments to function - let str = a:str " String to split - let sep = a:0 >= 1 ? a:1 : ',' " Optional split char, default comma - let esc = a:0 >= 2 ? a:2 : '\' " Optional escape char, default backslash - - " Get length of string, return empty list if it's zero - let len = strlen(str) - if !len - return [] - endif - - " Collect items into list by iterating characterwise - let list = [''] " List items - let idx = 0 " Offset in string - while idx < len - - if str[idx] ==# sep - - " This character is the item separator, and it wasn't escaped; start a - " new list item - call add(list, '') - - else - - " This character is the escape character, so we'll skip to the next - " character, if any, and add that; testing suggests that a terminal - " escape character on its own shouldn't be added - if str[idx] ==# esc - let idx += 1 - endif - let list[-1] .= str[idx] - - endif - - " Bump index for next character - let idx += 1 +" Escape a text value for :execute-based :set inclusion in an option +function! vimrc#EscapeSet(string) abort + return escape(a:string, '\ |"') +endfunction - endwhile +" Escape a text value for inclusion as an element in a comma-separated list +" option. Yes, the comma being the sole inner escaped character here is +" correct. No, we shouldn't escape backslash itself. Yes, that means it's +" impossible to have the literal string '\,' in a part. +function! vimrc#EscapeSetPart(string) abort + return vimrc#EscapeSet(escape(a:string, ',')) +endfunction - " Return the completed list - return list +" Check that we have a plugin available, and will be loading it +function! vimrc#PluginReady(filename) abort + return globpath(&runtimepath, 'plugin/'.a:filename.'.vim') !=# '' + \ && &loadplugins +endfunction +" Split a comma-separated option string into its constituent parts, imitating +" copy_option_part() in the Vim sources. This isn't perfect, but it should be +" more than good enough. A separator can be defined as: a comma that is not +" preceded by a backslash, and which is followed by any number of spaces +" and/or further commas. +function! vimrc#SplitOption(string) abort + return split(a:string, '\\\@<!,[, ]*') endfunction " Convenience version function check that should work with 7.0 or newer; " takes strings like 7.3.251 -function! vimrc#Version(verstr) abort +function! vimrc#Version(string) abort + + " Test the version string and get submatches for each part + let match = matchlist(a:string, '^\(\d\+\)\.\(\d\+\)\.\(\d\+\)$') - " Throw toys if the string doesn't match the expected format - if a:verstr !~# '^\d\+\.\d\+.\d\+$' - echoerr 'Invalid version string: '.a:verstr + " Throw toys if the string didn't match the expected format + if !len(match) + echoerr 'Invalid version string: '.a:string + return endif - " Split version string into major, minor, and patch level integers - let [major, minor, patch] = split(a:verstr, '\.') + " Get the major, minor, and patch numbers from the submatches + let [major, minor, patch] = match[1:3] - " Create a string like 801 from a version number 8.1 to compare it to - " the v:version integer + " Create a string like 801 from a version number 8.1 to compare it to the + " v:version integer let ver = major * 100 + minor " Compare versions - if v:version > ver - return 1 " Current Vim is newer than the wanted one - elseif ver < v:version - return 0 " Current Vim is older than the wanted one - else - return has('patch'.patch) " Versions equal, return patch presence - endif + return v:version > ver + \ || v:version == ver && has('patch'.patch) endfunction diff --git a/vim/autoload/vimrc.vim~ b/vim/autoload/vimrc.vim~ new file mode 100644 index 00000000..90ff13f1 --- /dev/null +++ b/vim/autoload/vimrc.vim~ @@ -0,0 +1,54 @@ +" Escape a text value for :execute-based :set inclusion in an option +function! vimrc#EscapeSet(string) abort + return escape(a:string, '\ |"') +endfunction + +" Escape a text value for inclusion as an element in a comma-separated list +" option. Yes, the comma being the sole inner escaped character here is +" correct. No, we shouldn't escape backslash itself. Yes, that means it's +" impossible to have the literal string '\,' in a part. +function! vimrc#EscapeSetPart(string) abort + return vimrc#EscapeSet(escape(a:string, ',')) +endfunction + +" Check that we have a plugin available, and will be loading it +function! vimrc#PluginReady(filename) abort + return globpath(&runtimepath, 'plugin/'.a:filename.'.vim') !=# '' + \ && &loadplugins +endfunction + +" Split a comma-separated option string into its constituent parts, imitating +" copy_option_part() in the Vim sources. This isn't perfect, but it should be +" more than good enough. A separator can be defined as: a comma that is not +" preceded by a backslash, and which is followed by any number of spaces +" and/or further commas. +function! vimrc#SplitOption(str) abort + return split(a:str, '\\\@<!,[, ]*') +endfunction + +" Convenience version function check that should work with 7.0 or newer; +" takes strings like 7.3.251 +function! vimrc#Version(verstr) abort + + " Throw toys if the string doesn't match the expected format + if a:verstr !~# '^\d\+\.\d\+.\d\+$' + echoerr 'Invalid version string: '.a:verstr + endif + + " Split version string into major, minor, and patch level integers + let [major, minor, patch] = split(a:verstr, '\.') + + " Create a string like 801 from a version number 8.1 to compare it to + " the v:version integer + let ver = major * 100 + minor + + " Compare versions + if v:version > ver + return 1 " Current Vim is newer than the wanted one + elseif ver < v:version + return 0 " Current Vim is older than the wanted one + else + return has('patch'.patch) " Versions equal, return patch presence + endif + +endfunction diff --git a/vim/bundle/squeeze_repeat_blanks b/vim/bundle/squeeze_repeat_blanks -Subproject fe84095e699642359ba59ce53684edaf6ac00b2 +Subproject 448470c75df7d3f2a5513cb68fe43e703faaf23 @@ -3,8 +3,8 @@ " Set an environment variable for the user runtime directory, if not already " set; use the first element of &runtimepath, rather like 'spellfile' -if !exists('$MYVIM') && strlen(&runtimepath) > 0 - let $MYVIM = vimrc#SplitEscaped(&runtimepath)[0] +if !exists('$MYVIM') && &runtimepath !=# '' + let $MYVIM = vimrc#SplitOption(&runtimepath)[0] endif " The all-important default indent settings; filetypes to tweak @@ -13,7 +13,7 @@ set expandtab " Use spaces instead of tabs set shiftwidth=4 " Indent with four spaces " Make insert mode tab key add the same number of spaces as 'shiftwidth', use -" negative value to do this if Vim new enough to support it +" negative value to do this dynamically, if Vim is new enough to support it let &softtabstop = vimrc#Version('7.3.693') ? -1 : &shiftwidth " Let me backspace over pretty much anything @@ -24,7 +24,7 @@ set backspace+=start " Before the start of current insertion " Keep backup files in dedicated directory; add trailing double-slash to keep " full path in name, if Vim is new enough to support that set backup -execute 'set backupdir^='.escape($MYVIM, '\ ').'/cache/backup' +execute 'set backupdir^='.vimrc#EscapeSetPart($MYVIM.'/cache/backup') \ . (vimrc#Version('8.1.251') ? '//' : '') " Add some *nix paths not to back up @@ -35,8 +35,8 @@ if has('unix') set backupskip+=/var/tmp/* " Hard-coded path for `sudo -e` 2/2 endif -" Indent wrapped lines if supported (v7.4.338) -if exists('+breakindent') +" Indent wrapped lines +if exists('+breakindent') " v7.4.338 set breakindent endif @@ -55,7 +55,7 @@ set confirm set cpoptions+=J " Keep swap files in dedicated directory, named with full path -set directory^=$MYVIM/cache/swap// +execute 'set directory^='.vimrc#EscapeSetPart($MYVIM.'/cache/swap') " If the environment didn't set an encoding, use UTF-8, not ASCII if !exists('$LANG') @@ -63,8 +63,7 @@ if !exists('$LANG') endif " Don't wait for a key after Escape in insert mode -" Not in Neovim -if exists('+esckeys') +if exists('+esckeys') " No such option in Neovim set noesckeys endif @@ -72,14 +71,14 @@ endif set foldlevelstart=99 set foldmethod=indent -" Delete comment leaders when joining lines, if supported +" Automatic formatting options +set formatoptions+=l " Don't break a long line in insert mode +set formatoptions+=1 " Avoid breaking lines after one-letter words if vimrc#Version('7.3.541') - set formatoptions+=j + set formatoptions+=j " Delete comment leaders when joining lines endif - -" Don't break a single space after a period, if supported if vimrc#Version('8.1.728') - set formatoptions+=p + set formatoptions+=p " Don't break a single space after a period endif " Don't load GUI menus; set here before GUI starts or any filetype or syntax @@ -170,16 +169,15 @@ endif " Keep persistent undo files in dedicated directory, named with full path if has('persistent_undo') " v7.2.438 set undofile - set undodir^=$MYVIM/cache/undo// + execute 'set undodir^='.vimrc#EscapeSetPart($MYVIM.'/cache/undo//') endif " Keep the viminfo file in the home Vim directory, mostly to stop history " getting clobbered when something runs Vim without using this vimrc -let $VIMINFO = $MYVIM.'/cache/viminfo' if exists('+viminfofile') " Use new option method if we can (v8.1.716) - set viminfofile=$VIMINFO + set viminfofile=$MYVIM/cache/viminfo else " Resort to clunkier method with 'viminfo' option flag - execute 'set viminfo+=n'.escape($VIMINFO, '\ ') + execute 'set viminfo+='.vimrc#EscapeSet('n'.$MYVIM.'/cache/viminfo') endif " Let me move beyond buffer text in visual block mode @@ -196,8 +194,8 @@ set wildignore=*~,#*#,*.7z,.DS_Store,.git,.hg,.svn,*.a,*.adf,*.asc,*.au,*.aup \,*.ogg,*.ogv,*.opus,*.pbm,*.pdf,*.png,*.ppt,*.psd,*.pyc,*.rar,*.rm \,*.s3m,*.sdbm,*.sqlite,*.swf,*.swp,*.tar,*.tga,*.ttf,*.wav,*.webm,*.xbm \,*.xcf,*.xls,*.xlsx,*.xpm,*.xz,*.zip -if exists('+wildignorecase') - set wildignorecase " Case insensitive, if supported (v7.3.072) +if exists('+wildignorecase') " v7.3.072 + set wildignorecase " Case insensitive tab completion endif set wildmode=list:longest " Tab press completes and lists @@ -215,20 +213,21 @@ try colorscheme sahara set cursorline catch - colorscheme default + syntax reset set background=dark set nocursorline endtry -" Space bar scrolls down a page, :next if plugin available -if &loadplugins +" Space bar scrolls down a page, :next at buffer's end if plugin available +if vimrc#PluginReady('scroll_next') nmap <Space> <Plug>(ScrollNext) else nnoremap <Space> <PageDown> endif -" Remap insert Ctrl-C to undo the escaped insert operation -if &loadplugins " Don't break the key if we won't be loading the plugin +" Remap insert Ctrl-C to undo the escaped insert operation, but don't break +" the key if the plugin isn't there +if vimrc#PluginReady('insert_cancel') imap <C-C> <Plug>(InsertCancel) endif @@ -428,8 +427,8 @@ xmap <Leader>* <Plug>(RegexEscape) " \\ jumps to the last edit position mark, like g;, but works as a motion " "Now, where was I?" (tap-tap) -nmap <Leader>\ `" -xmap <Leader>\ `" +nnoremap <Leader>\ `" +xnoremap <Leader>\ `" " \DEL deletes the current buffer nnoremap <Leader><Delete> :bdelete<CR> @@ -443,6 +442,8 @@ nnoremap <Leader><Tab> :<C-U>setlocal autoindent! autoindent?<CR> inoreabbrev almsot almost inoreabbrev wrnog wrong inoreabbrev Fielding Feilding +inoreabbrev THe the +inoreabbrev THere there " Reload this file when I save it, modified or nay augroup vimrc |