From a3ec4500488bb5a9c73c7d43b615283f667943cf Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 1 Jun 2019 01:12:58 +1200 Subject: Use :helpgrep not :lhelpgrep in mapping --- vim/vimrc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 4fbed756..c0ee1bb8 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -434,8 +434,8 @@ sunmap } " \/ types :vimgrep for me ready to enter a search pattern nnoremap / :vimgrep /\c/j ** -" \? types :lhelpgrep for me ready to enter a search pattern -nnoremap ? :lhelpgrep \c +" \? types :helpgrep for me ready to enter a search pattern +nnoremap ? :helpgrep \c " \\ escapes regex metacharacters nmap \ (RegexEscape) -- cgit v1.2.3 From 5a0ff4a7b339a27128f179faff8d8ec8586bfe57 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 1 Jun 2019 11:36:02 +1200 Subject: Clarify an idea --- IDEAS.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/IDEAS.md b/IDEAS.md index dbeccea8..7f2c1eb4 100644 --- a/IDEAS.md +++ b/IDEAS.md @@ -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. -- cgit v1.2.3 From 1a971547bae553b71d752189860425014488ff29 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 1 Jun 2019 11:52:21 +1200 Subject: Update vim-write-mkpath to v1.1.2 --- vim/bundle/write_mkpath | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/write_mkpath b/vim/bundle/write_mkpath index 6255e5fa..1c436090 160000 --- a/vim/bundle/write_mkpath +++ b/vim/bundle/write_mkpath @@ -1 +1 @@ -Subproject commit 6255e5fae6a29cda2bf1abf7bcfad1818ec2529a +Subproject commit 1c436090fe82120ce58c5075fe04bdc30f8bcc7e -- cgit v1.2.3 From f4b38e9f8a6055e4470e68ee7140cb3d97194e64 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 1 Jun 2019 11:55:02 +1200 Subject: Add an idea --- IDEAS.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/IDEAS.md b/IDEAS.md index 7f2c1eb4..8802e85d 100644 --- a/IDEAS.md +++ b/IDEAS.md @@ -33,3 +33,6 @@ Ideas some point * I'd like a Git hook that pre-fills out "Version X.Y.Z" if making an annotated tag named vX.Y.Z. +* Alternate files for buffers handled by vim-write-mkpath on creation still + have their alternate files broken; not a big deal but it would be nice to fix + it -- cgit v1.2.3 From bc6b8c2b49521ca0683dd14d1ba64eda0a928387 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 1 Jun 2019 18:12:55 +1200 Subject: Move an issue from IDEAS.md to ISSUES.md --- IDEAS.md | 3 --- ISSUES.md | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/IDEAS.md b/IDEAS.md index 8802e85d..7f2c1eb4 100644 --- a/IDEAS.md +++ b/IDEAS.md @@ -33,6 +33,3 @@ Ideas some point * I'd like a Git hook that pre-fills out "Version X.Y.Z" if making an annotated tag named vX.Y.Z. -* Alternate files for buffers handled by vim-write-mkpath on creation still - have their alternate files broken; not a big deal but it would be nice to fix - it diff --git a/ISSUES.md b/ISSUES.md index a4bb0ccb..42b0a563 100644 --- a/ISSUES.md +++ b/ISSUES.md @@ -30,3 +30,6 @@ Known issues pushed upstream. * The `_text_filenames` completion handler for Bash won't work on files with newlines in their names. Can it be made to? +* Alternate files for buffers handled by vim-write-mkpath on creation still + have their alternate files broken; not a big deal but it would be nice to fix + it -- cgit v1.2.3 From 286ddea973808909055784eff9415984e7696193 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 1 Jun 2019 18:13:18 +1200 Subject: Update vim-write-mkpath to v2.0.0 --- ISSUES.md | 3 --- vim/bundle/write_mkpath | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/ISSUES.md b/ISSUES.md index 42b0a563..a4bb0ccb 100644 --- a/ISSUES.md +++ b/ISSUES.md @@ -30,6 +30,3 @@ Known issues pushed upstream. * The `_text_filenames` completion handler for Bash won't work on files with newlines in their names. Can it be made to? -* Alternate files for buffers handled by vim-write-mkpath on creation still - have their alternate files broken; not a big deal but it would be nice to fix - it diff --git a/vim/bundle/write_mkpath b/vim/bundle/write_mkpath index 1c436090..336d46e8 160000 --- a/vim/bundle/write_mkpath +++ b/vim/bundle/write_mkpath @@ -1 +1 @@ -Subproject commit 1c436090fe82120ce58c5075fe04bdc30f8bcc7e +Subproject commit 336d46e800cfa51b5923ca7263c2eedd5b4c7cfb -- cgit v1.2.3 From 322d1eae405ba9f38f2828aeb52b5586360f0228 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 1 Jun 2019 18:56:38 +1200 Subject: Update vim-write-mkpath to v2.0.1 --- vim/bundle/write_mkpath | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/write_mkpath b/vim/bundle/write_mkpath index 336d46e8..965dad00 160000 --- a/vim/bundle/write_mkpath +++ b/vim/bundle/write_mkpath @@ -1 +1 @@ -Subproject commit 336d46e800cfa51b5923ca7263c2eedd5b4c7cfb +Subproject commit 965dad00d5e667cbf410c77b01862e5767475cae -- cgit v1.2.3 From b39c5d017bc829699449824c67cd0c934aab2645 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 1 Jun 2019 20:21:04 +1200 Subject: Update vim-write-mkpath to v2.0.2 --- vim/bundle/write_mkpath | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/write_mkpath b/vim/bundle/write_mkpath index 965dad00..16635b94 160000 --- a/vim/bundle/write_mkpath +++ b/vim/bundle/write_mkpath @@ -1 +1 @@ -Subproject commit 965dad00d5e667cbf410c77b01862e5767475cae +Subproject commit 16635b944666af202838e9e528787bbba23e670e -- cgit v1.2.3 From 3d3acdfc3395b34a2fa1398bc13dc3bd19a275f6 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 1 Jun 2019 21:19:31 +1200 Subject: Remap \g and \G for printing and moving to file --- vim/vimrc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index c0ee1bb8..1612e3dd 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -312,8 +312,10 @@ nnoremap f :setlocal formatoptions? " \F reloads filetype plugins nnoremap F :doautocmd filetypedetect BufRead -" \g changes directory to the current file's location -nnoremap g :cd %:hpwd +" \g shows the current file's fully expanded path +nnoremap g :echo expand('%:p') +" \G changes directory to the current file's location +nnoremap G :cd %:hpwd " \h toggles highlighting search results nnoremap h :set hlsearch! hlsearch? -- cgit v1.2.3 From 8e4a2ed3a6ddb4a2627ffec908a5c5686921ae34 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 1 Jun 2019 21:34:51 +1200 Subject: Update vim-regex-escape to v1.1.0 --- vim/bundle/regex_escape | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/regex_escape b/vim/bundle/regex_escape index 745dc406..9473dfab 160000 --- a/vim/bundle/regex_escape +++ b/vim/bundle/regex_escape @@ -1 +1 @@ -Subproject commit 745dc4060a75bd0b1ec4f0667a309de61cf1d668 +Subproject commit 9473dfab9dc8a4b049c940a9575d1cb1f3ee6ea1 -- cgit v1.2.3 From fb6ad5bd6f4ac15b49a115401425b53b0c493657 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 1 Jun 2019 21:42:34 +1200 Subject: Update vim-replace-operator to v1.1.0 --- vim/bundle/replace_operator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/replace_operator b/vim/bundle/replace_operator index e7657df1..61433b46 160000 --- a/vim/bundle/replace_operator +++ b/vim/bundle/replace_operator @@ -1 +1 @@ -Subproject commit e7657df12f0514989ae14b32c23b5cd1f70e4aec +Subproject commit 61433b46cdbc7efcba5bc429a50752030ca54479 -- cgit v1.2.3 From e30a8a5f1f457b804d480328e8d9b693108fcb69 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 1 Jun 2019 21:55:11 +1200 Subject: Update vim-strip-trailing-whitespace v3.1.0 --- vim/bundle/strip_trailing_whitespace | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/strip_trailing_whitespace b/vim/bundle/strip_trailing_whitespace index c8d73a50..4ae00d5a 160000 --- a/vim/bundle/strip_trailing_whitespace +++ b/vim/bundle/strip_trailing_whitespace @@ -1 +1 @@ -Subproject commit c8d73a50108d3d7e21f50a2aa3234dbb3c00b99b +Subproject commit 4ae00d5a5cf92aed3cab774f72df8fcd6d141b94 -- cgit v1.2.3 From ff891bbdc835da12894373bd918251a06a1de8f7 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 3 Jun 2019 00:13:59 +1200 Subject: Use autoloaded and correct function for &rtp split --- vim/autoload/vimrc.vim | 47 +++++++++++++++++++++++++++++++++++++++++++++++ vim/vimrc | 6 ++---- 2 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 vim/autoload/vimrc.vim diff --git a/vim/autoload/vimrc.vim b/vim/autoload/vimrc.vim new file mode 100644 index 00000000..71b29d61 --- /dev/null +++ b/vim/autoload/vimrc.vim @@ -0,0 +1,47 @@ +" 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 diff --git a/vim/vimrc b/vim/vimrc index 1612e3dd..ad582717 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -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 -- cgit v1.2.3 From 8ca01a93dc1e9139f7dc74036b3b40586b06ae15 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 3 Jun 2019 22:24:37 +1200 Subject: Factor out Vim version checks into autoload func --- vim/autoload/vimrc.vim | 27 +++++++++++++++++++++++++++ vim/vimrc | 11 ++++------- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/vim/autoload/vimrc.vim b/vim/autoload/vimrc.vim index 71b29d61..bfbae263 100644 --- a/vim/autoload/vimrc.vim +++ b/vim/autoload/vimrc.vim @@ -45,3 +45,30 @@ function! vimrc#SplitEscaped(str, ...) abort 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/vimrc b/vim/vimrc index ad582717..302f1388 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -14,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 @@ -26,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') @@ -74,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 -- cgit v1.2.3 From f81cbabed06817ce0286b20242664d68d29a646d Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 3 Jun 2019 22:51:52 +1200 Subject: Add vim-keep-position v0.1.0 --- .gitmodules | 3 +++ vim/bundle/keep_position | 1 + vim/vimrc | 4 ++-- 3 files changed, 6 insertions(+), 2 deletions(-) create mode 160000 vim/bundle/keep_position 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 diff --git a/vim/bundle/keep_position b/vim/bundle/keep_position new file mode 160000 index 00000000..d350864e --- /dev/null +++ b/vim/bundle/keep_position @@ -0,0 +1 @@ +Subproject commit d350864ef0b3218bb712d9c17fdb8d4f454f8e98 diff --git a/vim/vimrc b/vim/vimrc index 302f1388..74b60b74 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -406,9 +406,9 @@ nnoremap y :registers nnoremap z :setlocal spelllang=en_nz " \= runs the whole buffer through =, preserving position -nnoremap = m`1G=G`` +nnoremap = :KeepPosition normal! 1G=G " \+ runs the whole buffer through gq, preserving position -nnoremap + m`1GgqG`` +nnoremap + :KeepPosition normal! 1GgqG " \. runs the configured make program into the location list nnoremap . :lmake! -- cgit v1.2.3 From 1e89a8c3a43dbbe5437ca62198a4058e10242495 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 4 Jun 2019 01:12:06 +1200 Subject: Update vim-keep-position to v0.2.0 --- vim/bundle/keep_position | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/keep_position b/vim/bundle/keep_position index d350864e..2bb4902d 160000 --- a/vim/bundle/keep_position +++ b/vim/bundle/keep_position @@ -1 +1 @@ -Subproject commit d350864ef0b3218bb712d9c17fdb8d4f454f8e98 +Subproject commit 2bb4902d546efc814150134f3900b7860bac9b84 -- cgit v1.2.3 From adaddd739a48eb4e41058b7574cbe39cec9290d7 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 4 Jun 2019 01:28:37 +1200 Subject: Remove recursion from mappings that don't need it --- vim/vimrc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 74b60b74..5d989d96 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -392,12 +392,12 @@ nnoremap w :setlocal wrap! wrap? xnoremap w :setlocal wrap! wrap?gv " \x strips trailing whitespace via a custom plugin -nmap x :StripTrailingWhitespace -xmap x :StripTrailingWhitespace +nnoremap x :StripTrailingWhitespace +xnoremap x :StripTrailingWhitespace " \X squeezes repeated blank lines via a custom plugin -nmap X :SqueezeRepeatBlanks -xmap X :SqueezeRepeatBlanks +nnoremap X :SqueezeRepeatBlanks +xnoremap X :SqueezeRepeatBlanks " \y shows all registers nnoremap y :registers -- cgit v1.2.3 From 60266721b09cc115cdb273bd52944d724cddcefe Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 4 Jun 2019 01:45:59 +1200 Subject: Remove from some mappings --- vim/vimrc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/vim/vimrc b/vim/vimrc index 5d989d96..05b3c7e5 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -248,14 +248,14 @@ endif imap (DigraphSearch) " Stack Ctrl-L to clear search highlight, make it work in insert mode too -nnoremap :nohlsearch -vnoremap :nohlsearchgv -inoremap :nohlsearch +nnoremap :nohlsearch +vnoremap :nohlsearchgv +inoremap :nohlsearch " Remap normal/visual & and g& to preserve substitution flags -nnoremap & :&& -xnoremap & :&& -nnoremap g& :%&& +nnoremap & :&& +xnoremap & :&& +nnoremap g& :%&& " Map g: as a 'colon operator' nmap g: (ColonOperator) -- cgit v1.2.3 From 226f9a9423ad30149513a079a80978798a4a2059 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 4 Jun 2019 08:19:49 +1200 Subject: Update vim-write-mkpath to v2.1.0 --- vim/bundle/write_mkpath | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/bundle/write_mkpath b/vim/bundle/write_mkpath index 16635b94..5c00abcf 160000 --- a/vim/bundle/write_mkpath +++ b/vim/bundle/write_mkpath @@ -1 +1 @@ -Subproject commit 16635b944666af202838e9e528787bbba23e670e +Subproject commit 5c00abcf43f905dd0aefe5d8468a2f46a2fbf6a0 -- cgit v1.2.3 From d5e7e53beec58917955b3450b422cd6c4bd52885 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 4 Jun 2019 08:21:33 +1200 Subject: Bump VERSION --- VERSION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index ba689ce1..7d0295e8 100644 --- a/VERSION +++ b/VERSION @@ -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 -- cgit v1.2.3