From a0b7081ce224503d1735874d28bd8d2271b5e2b8 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 5 Nov 2017 01:07:40 +1300 Subject: Add vim/autoload to the lint-vim target This directory was created in commit 4c46c80, but its contents haven't been linted with `vint` until now. --- lint/vim.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/lint/vim.sh b/lint/vim.sh index c370e177..64ac63ba 100644 --- a/lint/vim.sh +++ b/lint/vim.sh @@ -1,5 +1,6 @@ set -- \ vim/after \ + vim/autoload \ vim/config \ vim/ftdetect \ vim/ftplugin \ -- cgit v1.2.3 From 47703aca40d5cd9126dbd3031b87ea8b535b38f4 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 5 Nov 2017 01:08:39 +1300 Subject: Add 'abort' attribute to autoload function `vint -s` says: > vim/autoload/detect_background.vim:16:1: Use the abort attribute for > functions in autoload (see Google VimScript Style Guide (Functions)) All right, then. Doesn't seem to break vim.tiny or Vim 6.1. --- vim/autoload/detect_background.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/autoload/detect_background.vim b/vim/autoload/detect_background.vim index 168640c3..e4fee199 100644 --- a/vim/autoload/detect_background.vim +++ b/vim/autoload/detect_background.vim @@ -13,7 +13,7 @@ endif let g:loaded_detect_background = 1 " Declare autoload function for 'background' set -function! detect_background#DetectBackground() +function! detect_background#DetectBackground() abort " Split up the value of $COLORFGBG (if any) by semicolons let l:colorfgbg = split($COLORFGBG, ';') -- cgit v1.2.3 From 9e20cbd7294ef76d2b7270b56af59fb82fea5785 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 5 Nov 2017 01:16:46 +1300 Subject: Block 'formatoptions' 'a' flag on old Vim versions If I ever care, this needs more careful testing to find the version in which the flag was added. --- vim/config/format.vim | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/vim/config/format.vim b/vim/config/format.vim index 688b60c9..40019d0a 100644 --- a/vim/config/format.vim +++ b/vim/config/format.vim @@ -9,22 +9,36 @@ endif " Use toggle_option_flag.vim plugin to bind quick toggle actions for some " 'formatoptions' flags: " +" c - Automatically wrap comments at 'textwidth' (which I allow the filetypes +" to set for me) +" t - Automatically wrap text at 'textwidth' (as above) +" +" Only in Vim >= 7.1 (I think): +" " a - Automatically format paragraphs, reapplying the wrap on every text " insertion or deletion; sometimes I want this and sometimes I " don't, it particularly varies when typing prose in Markdown that " includes headings and code -" c - Automatically wrap comments at 'textwidth' (which I allow the filetypes -" to set for me) -" t - Automatically wrap text at 'textwidth' (as above) " if has('eval') && has('user_commands') - nnoremap - \ a - \ :ToggleOptionFlagLocal formatoptions a + + " 'c' and 't' have both been around since at least 6.1 nnoremap \ c \ :ToggleOptionFlagLocal formatoptions c nnoremap \ t \ :ToggleOptionFlagLocal formatoptions t + + " 'a' is newer + if v:version >= 701 + nnoremap + \ a + \ :ToggleOptionFlagLocal formatoptions a + else + nnoremap + \ a + \ :echomsg 'No "formatoptions" "a" flag in Vim < 7.1' + endif + endif -- cgit v1.2.3 From 21366b8848fd44c4c83e6f0bc87ed9c6644e74de Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 5 Nov 2017 01:21:48 +1300 Subject: Lower threshold for 'formatoptions' 'a' flag I have found it works correctly on an instance of Vim 7.0. --- vim/config/format.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vim/config/format.vim b/vim/config/format.vim index 40019d0a..fe6da87c 100644 --- a/vim/config/format.vim +++ b/vim/config/format.vim @@ -13,7 +13,7 @@ endif " to set for me) " t - Automatically wrap text at 'textwidth' (as above) " -" Only in Vim >= 7.1 (I think): +" Only in Vim >= 7.0 (I think): " " a - Automatically format paragraphs, reapplying the wrap on every text " insertion or deletion; sometimes I want this and sometimes I @@ -31,14 +31,14 @@ if has('eval') && has('user_commands') \ :ToggleOptionFlagLocal formatoptions t " 'a' is newer - if v:version >= 701 + if v:version >= 700 nnoremap \ a \ :ToggleOptionFlagLocal formatoptions a else nnoremap \ a - \ :echomsg 'No "formatoptions" "a" flag in Vim < 7.1' + \ :echomsg 'No "formatoptions" "a" flag in Vim < 7.0' endif endif -- cgit v1.2.3 From 2105d7080529cf549eca10e716291ddee635498f Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 5 Nov 2017 01:39:13 +1300 Subject: Keep script var cache of 'j' 'fo' flag support We'll use this in a subsequent commit to decide how to map j. --- vim/config/format.vim | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/vim/config/format.vim b/vim/config/format.vim index fe6da87c..7d6fb2b1 100644 --- a/vim/config/format.vim +++ b/vim/config/format.vim @@ -1,7 +1,10 @@ -" If we can, add j to the format options to get rid of comment leaders when -" joining lines -if v:version > 703 +" Figure out if we have the 'j' flag for 'formatoptions', to automatically +" delete comment leaders when joining lines; keep it in a script variable +let s:formatoptions_has_j = v:version > 703 \ || v:version ==# 703 && has('patch541') + +" If we do have 'j', default to setting it +if s:formatoptions_has_j set formatoptions+=j endif -- cgit v1.2.3 From ddc776dd2d08663525436bbe80823b36bc7e2b7e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 5 Nov 2017 01:41:07 +1300 Subject: Keep script var cache of 'a' 'fo' flag support Use the result to decide how to map a. --- vim/config/format.vim | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/vim/config/format.vim b/vim/config/format.vim index 7d6fb2b1..a3a1a453 100644 --- a/vim/config/format.vim +++ b/vim/config/format.vim @@ -1,3 +1,8 @@ +" Figure out if we have the 'a' flag for 'formatoptions', to reapply +" 'textwidth' wrapping to the current paragraph on every insertion or +" deletion; keep in a script variable +let s:formatoptions_has_a = v:version > 700 + " Figure out if we have the 'j' flag for 'formatoptions', to automatically " delete comment leaders when joining lines; keep it in a script variable let s:formatoptions_has_j = v:version > 703 @@ -33,8 +38,8 @@ if has('eval') && has('user_commands') \ t \ :ToggleOptionFlagLocal formatoptions t - " 'a' is newer - if v:version >= 700 + " 'a' needs testing + if s:formatoptions_has_a nnoremap \ a \ :ToggleOptionFlagLocal formatoptions a -- cgit v1.2.3 From 373c46f8a7db8bb07d180ae2b5cf61b6f9add681 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 5 Nov 2017 01:41:42 +1300 Subject: Use simpler error message for 'fo'-'a' absence --- vim/config/format.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/config/format.vim b/vim/config/format.vim index a3a1a453..c41e55ef 100644 --- a/vim/config/format.vim +++ b/vim/config/format.vim @@ -46,7 +46,7 @@ if has('eval') && has('user_commands') else nnoremap \ a - \ :echomsg 'No "formatoptions" "a" flag in Vim < 7.0' + \ :echomsg 'No formatoptions a-flag' endif endif -- cgit v1.2.3 From 7f25dd5c05704d73e57c5dd149c3263062765197 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 5 Nov 2017 01:42:00 +1300 Subject: Use :echoerr not :echomsg for 'fo'-'a' absence A bit clearer as the mapping was clearly called in error, and results in not being able to do what was need. --- vim/config/format.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vim/config/format.vim b/vim/config/format.vim index c41e55ef..64a0a35b 100644 --- a/vim/config/format.vim +++ b/vim/config/format.vim @@ -46,7 +46,7 @@ if has('eval') && has('user_commands') else nnoremap \ a - \ :echomsg 'No formatoptions a-flag' + \ :echoerr 'No formatoptions a-flag' endif endif -- cgit v1.2.3 From 8d7d5421f500d193e565fc9bfad8f1a67d77f762 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 5 Nov 2017 01:42:46 +1300 Subject: Map j to toggle 'fo'-'j' flag in Vim This is implemented in the same way as done for 'fo'-'a'; testing for the presence of the flag based on known version tests first. --- vim/config/format.vim | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/vim/config/format.vim b/vim/config/format.vim index 64a0a35b..759b5110 100644 --- a/vim/config/format.vim +++ b/vim/config/format.vim @@ -15,18 +15,12 @@ endif " " Use toggle_option_flag.vim plugin to bind quick toggle actions for some -" 'formatoptions' flags: +" 'formatoptions' flags; both of the above, plus: " " c - Automatically wrap comments at 'textwidth' (which I allow the filetypes " to set for me) " t - Automatically wrap text at 'textwidth' (as above) " -" Only in Vim >= 7.0 (I think): -" -" a - Automatically format paragraphs, reapplying the wrap on every text -" insertion or deletion; sometimes I want this and sometimes I -" don't, it particularly varies when typing prose in Markdown that -" includes headings and code " if has('eval') && has('user_commands') @@ -49,4 +43,15 @@ if has('eval') && has('user_commands') \ :echoerr 'No formatoptions a-flag' endif + " 'j' needs testing + if s:formatoptions_has_j + nnoremap + \ j + \ :ToggleOptionFlagLocal formatoptions j + else + nnoremap + \ j + \ :echoerr 'No formatoptions j-flag' + endif + endif -- cgit v1.2.3 From 1da79fc20e26a10c268c5bb042d861eeb670ff79 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 5 Nov 2017 01:48:11 +1300 Subject: Restructure 'format' flag logic around vim-tiny Put in appropriate 'eval' checks and adjust the order of evaluation so that vim-tiny doesn't try to run all this and fail due to the absence of 'eval' for :let. --- vim/config/format.vim | 55 +++++++++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/vim/config/format.vim b/vim/config/format.vim index 759b5110..61222164 100644 --- a/vim/config/format.vim +++ b/vim/config/format.vim @@ -1,28 +1,35 @@ -" Figure out if we have the 'a' flag for 'formatoptions', to reapply -" 'textwidth' wrapping to the current paragraph on every insertion or -" deletion; keep in a script variable -let s:formatoptions_has_a = v:version > 700 - -" Figure out if we have the 'j' flag for 'formatoptions', to automatically -" delete comment leaders when joining lines; keep it in a script variable -let s:formatoptions_has_j = v:version > 703 - \ || v:version ==# 703 && has('patch541') - -" If we do have 'j', default to setting it -if s:formatoptions_has_j - set formatoptions+=j -endif +" All of this variable logic requires 'eval', and I can't just short-circuit +" it due to a quirk in the way vim-tiny evaluates these expressions +if has('eval') + + " Figure out if we have the 'j' flag for 'formatoptions', to automatically + " delete comment leaders when joining lines; keep it in a script variable + let s:formatoptions_has_j = v:version > 703 + \ || v:version ==# 703 && has('patch541') + + " If we do have 'j', default to setting it + if s:formatoptions_has_j + set formatoptions+=j + endif + + " + " Use toggle_option_flag.vim plugin to bind quick toggle actions for some + " 'formatoptions' flags; both of the above, plus: + " + " c - Automatically wrap comments at 'textwidth' (which I allow the filetypes + " to set for me) + " t - Automatically wrap text at 'textwidth' (as above) + " + " We need user-defined commands to do this. + " + if !has('user_commands') + finish + endif -" -" Use toggle_option_flag.vim plugin to bind quick toggle actions for some -" 'formatoptions' flags; both of the above, plus: -" -" c - Automatically wrap comments at 'textwidth' (which I allow the filetypes -" to set for me) -" t - Automatically wrap text at 'textwidth' (as above) -" -" -if has('eval') && has('user_commands') + " Figure out if we have the 'a' flag for 'formatoptions', to reapply + " 'textwidth' wrapping to the current paragraph on every insertion or + " deletion; keep in a script variable + let s:formatoptions_has_a = v:version > 700 " 'c' and 't' have both been around since at least 6.1 nnoremap -- cgit v1.2.3 From 157c36ee49f5f8e37ecbe5598ac50166ae814464 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 5 Nov 2017 13:29:24 +1300 Subject: Precisely define 'formatoptions' 'a' flag presence :help version6.txt, /^Patch 6\.1\.142: > Patch 6.1.142 > Problem: Defining paragraphs without a separating blank line isn't > possible. Paragraphs can't be formatted automatically. > Solution: Allow defining paragraphs with lines that end in white > space. Added the 'w' and 'a' flags in 'formatoptions'. > Files: runtime/doc/change.txt, src/edit.c, src/misc1.c, > src/normal.c, src/option.h, src/ops.c, src/proto/edit.pro, > src/proto/ops.pro, src/vim.h --- vim/config/format.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vim/config/format.vim b/vim/config/format.vim index 61222164..477ad6d2 100644 --- a/vim/config/format.vim +++ b/vim/config/format.vim @@ -29,7 +29,8 @@ if has('eval') " Figure out if we have the 'a' flag for 'formatoptions', to reapply " 'textwidth' wrapping to the current paragraph on every insertion or " deletion; keep in a script variable - let s:formatoptions_has_a = v:version > 700 + let s:formatoptions_has_a = v:version > 610 + \ || v:version ==# 610 && has('patch142') " 'c' and 't' have both been around since at least 6.1 nnoremap -- cgit v1.2.3 From 6e78aaf23837f7c35b20467e7422276b8edba79b Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 5 Nov 2017 13:33:03 +1300 Subject: Move 'formatoptions-a' test near applicable block Just to keep related things together. --- vim/config/format.vim | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/vim/config/format.vim b/vim/config/format.vim index 477ad6d2..54d46dc2 100644 --- a/vim/config/format.vim +++ b/vim/config/format.vim @@ -26,12 +26,6 @@ if has('eval') finish endif - " Figure out if we have the 'a' flag for 'formatoptions', to reapply - " 'textwidth' wrapping to the current paragraph on every insertion or - " deletion; keep in a script variable - let s:formatoptions_has_a = v:version > 610 - \ || v:version ==# 610 && has('patch142') - " 'c' and 't' have both been around since at least 6.1 nnoremap \ c @@ -40,6 +34,12 @@ if has('eval') \ t \ :ToggleOptionFlagLocal formatoptions t + " Figure out if we have the 'a' flag for 'formatoptions', to reapply + " 'textwidth' wrapping to the current paragraph on every insertion or + " deletion; keep in a script variable + let s:formatoptions_has_a = v:version > 610 + \ || v:version ==# 610 && has('patch142') + " 'a' needs testing if s:formatoptions_has_a nnoremap -- cgit v1.2.3 From 0ffdb540998d526d74df24f65aa6298b85368b80 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 5 Nov 2017 15:13:18 +1300 Subject: Bump version number to 0.9.0 --- VERSION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 201c1716..ce102cf1 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ -tejr dotfiles v0.8.1 -Sat Nov 4 11:54:36 UTC 2017 +tejr dotfiles v0.9.0 +Sun Nov 5 02:13:08 UTC 2017 -- cgit v1.2.3