diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2019-06-04 08:21:33 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2019-06-04 08:21:33 +1200 |
commit | cb5259e60028a796ed44e4ac4173deb69d7b5518 (patch) | |
tree | 2d0b7dd0b69effc5da87a903e5e27ddf903eef73 | |
parent | Merge branch 'release/v5.15.0' (diff) | |
parent | Bump VERSION (diff) | |
download | dotfiles-5.16.0.tar.gz (sig) dotfiles-5.16.0.zip |
Merge branch 'release/v5.16.0'v5.16.0
* release/v5.16.0:
Update vim-write-mkpath to v2.1.0
Remove <silent> from some mappings
Remove recursion from mappings that don't need it
Update vim-keep-position to v0.2.0
Add vim-keep-position v0.1.0
Factor out Vim version checks into autoload func
Use autoloaded and correct function for &rtp split
Update vim-strip-trailing-whitespace v3.1.0
Update vim-replace-operator to v1.1.0
Update vim-regex-escape to v1.1.0
Remap \g and \G for printing and moving to file
Update vim-write-mkpath to v2.0.2
Update vim-write-mkpath to v2.0.1
Update vim-write-mkpath to v2.0.0
Move an issue from IDEAS.md to ISSUES.md
Add an idea
Update vim-write-mkpath to v1.1.2
Clarify an idea
Use :helpgrep not :lhelpgrep in mapping
-rw-r--r-- | .gitmodules | 3 | ||||
-rw-r--r-- | IDEAS.md | 4 | ||||
-rw-r--r-- | VERSION | 4 | ||||
-rw-r--r-- | vim/autoload/vimrc.vim | 74 | ||||
m--------- | vim/bundle/keep_position | 0 | ||||
m--------- | vim/bundle/regex_escape | 0 | ||||
m--------- | vim/bundle/replace_operator | 0 | ||||
m--------- | vim/bundle/strip_trailing_whitespace | 0 | ||||
m--------- | vim/bundle/write_mkpath | 0 | ||||
-rw-r--r-- | vim/vimrc | 51 |
10 files changed, 105 insertions, 31 deletions
diff --git a/.gitmodules b/.gitmodules index 2526e82f..1c789480 100644 --- a/.gitmodules +++ b/.gitmodules @@ -93,3 +93,6 @@ [submodule "vim/bundle/sahara"] path = vim/bundle/sahara url = https://sanctum.geek.nz/code/vim-sahara.git +[submodule "vim/bundle/keep_position"] + path = vim/bundle/keep_position + url = https://sanctum.geek.nz/code/vim-keep-position.git @@ -31,5 +31,5 @@ Ideas vice-versa. * Almost definitely going to want to try a runparts layout for Git hooks at some point -* I'd like a Git hook that pre-fills out "Version X.Y.Z" if making a commit - tagged with vX.Y.Z. +* I'd like a Git hook that pre-fills out "Version X.Y.Z" if making an annotated + tag named vX.Y.Z. @@ -1,2 +1,2 @@ -tejr dotfiles v5.15.0 -Fri May 31 13:04:38 UTC 2019 +tejr dotfiles v5.16.0 +Mon Jun 3 20:21:33 UTC 2019 diff --git a/vim/autoload/vimrc.vim b/vim/autoload/vimrc.vim new file mode 100644 index 00000000..bfbae263 --- /dev/null +++ b/vim/autoload/vimrc.vim @@ -0,0 +1,74 @@ +" 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 + + endwhile + + " Return the completed list + return list + +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/keep_position b/vim/bundle/keep_position new file mode 160000 +Subproject 2bb4902d546efc814150134f3900b7860bac9b8 diff --git a/vim/bundle/regex_escape b/vim/bundle/regex_escape -Subproject 745dc4060a75bd0b1ec4f0667a309de61cf1d66 +Subproject 9473dfab9dc8a4b049c940a9575d1cb1f3ee6ea diff --git a/vim/bundle/replace_operator b/vim/bundle/replace_operator -Subproject e7657df12f0514989ae14b32c23b5cd1f70e4ae +Subproject 61433b46cdbc7efcba5bc429a50752030ca5447 diff --git a/vim/bundle/strip_trailing_whitespace b/vim/bundle/strip_trailing_whitespace -Subproject c8d73a50108d3d7e21f50a2aa3234dbb3c00b99 +Subproject 4ae00d5a5cf92aed3cab774f72df8fcd6d141b9 diff --git a/vim/bundle/write_mkpath b/vim/bundle/write_mkpath -Subproject 6255e5fae6a29cda2bf1abf7bcfad1818ec2529 +Subproject 5c00abcf43f905dd0aefe5d8468a2f46a2fbf6a @@ -3,10 +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') - let $MYVIM = expand( - \ strpart(&runtimepath, 0, stridx(&runtimepath, ',')) - \ ) +if !exists('$MYVIM') && strlen(&runtimepath) > 0 + let $MYVIM = vimrc#SplitEscaped(&runtimepath)[0] endif " The all-important default indent settings; filetypes to tweak @@ -16,9 +14,7 @@ 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 -let &softtabstop = v:version > 703 - \ || v:version == 703 && has('patch693') - \ ? -1 : &shiftwidth +let &softtabstop = vimrc#Version('7.3.693') ? -1 : &shiftwidth " Allow me to backspace 'autoindent' spaces in insert mode, and back over the " end of lines I've inserted in this session @@ -28,7 +24,7 @@ set backspace=indent,eol " full path in name, if Vim is new enough to support that set backup execute 'set backupdir^='.escape($MYVIM, '\ ').'/cache/backup' - \ . (has('patch-8.1.251') ? '//' : '') + \ . (vimrc#Version('8.1.251') ? '//' : '') " Add some *nix paths not to back up if has('unix') @@ -76,13 +72,12 @@ set foldlevelstart=99 set foldmethod=indent " Delete comment leaders when joining lines, if supported -if v:version > 703 - \ || v:version == 703 && has('patch541') +if vimrc#Version('7.3.541') set formatoptions+=j endif " Don't break a single space after a period, if supported -if has('patch-8.1.728') +if vimrc#Version('8.1.728') set formatoptions+=p endif @@ -253,14 +248,14 @@ endif imap <C-K><C-K> <Plug>(DigraphSearch) " Stack Ctrl-L to clear search highlight, make it work in insert mode too -nnoremap <silent> <C-L> :<C-U>nohlsearch<CR><C-L> -vnoremap <silent> <C-L> :<C-U>nohlsearch<CR>gv<C-L> -inoremap <silent> <C-L> <C-O>:<C-U>nohlsearch<CR><C-O><C-L> +nnoremap <C-L> :<C-U>nohlsearch<CR><C-L> +vnoremap <C-L> :<C-U>nohlsearch<CR>gv<C-L> +inoremap <C-L> <C-O>:<C-U>nohlsearch<CR><C-O><C-L> " Remap normal/visual & and g& to preserve substitution flags -nnoremap <silent> & :&&<CR> -xnoremap <silent> & :&&<CR> -nnoremap <silent> g& :<C-U>%&&<CR> +nnoremap & :&&<CR> +xnoremap & :&&<CR> +nnoremap g& :<C-U>%&&<CR> " Map g: as a 'colon operator' nmap g: <Plug>(ColonOperator) @@ -312,8 +307,10 @@ nnoremap <Leader>f :<C-U>setlocal formatoptions?<CR> " \F reloads filetype plugins nnoremap <Leader>F :<C-U>doautocmd filetypedetect BufRead<CR> -" \g changes directory to the current file's location -nnoremap <Leader>g :<C-U>cd %:h<Bar>pwd<CR> +" \g shows the current file's fully expanded path +nnoremap <Leader>g :<C-U>echo expand('%:p')<CR> +" \G changes directory to the current file's location +nnoremap <Leader>G :<C-U>cd %:h<Bar>pwd<CR> " \h toggles highlighting search results nnoremap <Leader>h :<C-U>set hlsearch! hlsearch?<CR> @@ -395,12 +392,12 @@ nnoremap <Leader>w :<C-U>setlocal wrap! wrap?<CR> xnoremap <Leader>w :<C-U>setlocal wrap! wrap?<CR>gv " \x strips trailing whitespace via a custom plugin -nmap <Leader>x :StripTrailingWhitespace<CR> -xmap <Leader>x :StripTrailingWhitespace<CR> +nnoremap <Leader>x :StripTrailingWhitespace<CR> +xnoremap <Leader>x :StripTrailingWhitespace<CR> " \X squeezes repeated blank lines via a custom plugin -nmap <Leader>X :SqueezeRepeatBlanks<CR> -xmap <Leader>X :SqueezeRepeatBlanks<CR> +nnoremap <Leader>X :SqueezeRepeatBlanks<CR> +xnoremap <Leader>X :SqueezeRepeatBlanks<CR> " \y shows all registers nnoremap <Leader>y :<C-U>registers<CR> @@ -409,9 +406,9 @@ nnoremap <Leader>y :<C-U>registers<CR> nnoremap <Leader>z :<C-U>setlocal spelllang=en_nz<CR> " \= runs the whole buffer through =, preserving position -nnoremap <Leader>= m`1G=G`` +nnoremap <Leader>= :<C-U>KeepPosition normal! 1G=G<CR> " \+ runs the whole buffer through gq, preserving position -nnoremap <Leader>+ m`1GgqG`` +nnoremap <Leader>+ :<C-U>KeepPosition normal! 1GgqG<CR> " \. runs the configured make program into the location list nnoremap <Leader>. :<C-U>lmake!<CR> @@ -434,8 +431,8 @@ sunmap <Leader>} " \/ types :vimgrep for me ready to enter a search pattern nnoremap <Leader>/ :<C-U>vimgrep /\c/j **<S-Left><S-Left><Right> -" \? types :lhelpgrep for me ready to enter a search pattern -nnoremap <Leader>? :<C-U>lhelpgrep \c<S-Left> +" \? types :helpgrep for me ready to enter a search pattern +nnoremap <Leader>? :<C-U>helpgrep \c<S-Left> " \\ escapes regex metacharacters nmap <Leader>\ <Plug>(RegexEscape) |