aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-11-05 15:14:46 +1300
committerTom Ryder <tom@sanctum.geek.nz>2017-11-05 15:14:46 +1300
commit6e289012d5a9ec4efbc348a03f1199d4f461983f (patch)
tree25e8aed9e38be9da47273046b714de68faecaf99
parentMerge branch 'hotfix/v0.8.1' (diff)
parentBump version number to 0.9.0 (diff)
downloaddotfiles-6e289012d5a9ec4efbc348a03f1199d4f461983f.tar.gz
dotfiles-6e289012d5a9ec4efbc348a03f1199d4f461983f.zip
Merge branch 'release/v0.9.0'v0.9.0
* release/v0.9.0: Bump version number to 0.9.0 Move 'formatoptions-a' test near applicable block Precisely define 'formatoptions' 'a' flag presence Restructure 'format' flag logic around vim-tiny Map <leader>j to toggle 'fo'-'j' flag in Vim Use :echoerr not :echomsg for 'fo'-'a' absence Use simpler error message for 'fo'-'a' absence Keep script var cache of 'a' 'fo' flag support Keep script var cache of 'j' 'fo' flag support Lower threshold for 'formatoptions' 'a' flag Block 'formatoptions' 'a' flag on old Vim versions Add 'abort' attribute to autoload function Add vim/autoload to the lint-vim target
-rw-r--r--VERSION4
-rw-r--r--lint/vim.sh1
-rw-r--r--vim/autoload/detect_background.vim2
-rw-r--r--vim/config/format.vim79
4 files changed, 61 insertions, 25 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
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 \
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, ';')
diff --git a/vim/config/format.vim b/vim/config/format.vim
index 688b60c9..54d46dc2 100644
--- a/vim/config/format.vim
+++ b/vim/config/format.vim
@@ -1,30 +1,65 @@
-" If we can, add j to the format options to get rid of comment leaders when
-" joining lines
-if v:version > 703
- \ || v:version ==# 703 && has('patch541')
- 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')
-"
-" Use toggle_option_flag.vim plugin to bind quick toggle actions for some
-" 'formatoptions' flags:
-"
-" 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 <silent>
- \ <Leader>a
- \ :<C-U>ToggleOptionFlagLocal formatoptions a<CR>
+ " 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
+
+ " 'c' and 't' have both been around since at least 6.1
nnoremap <silent>
\ <Leader>c
\ :<C-U>ToggleOptionFlagLocal formatoptions c<CR>
nnoremap <silent>
\ <Leader>t
\ :<C-U>ToggleOptionFlagLocal formatoptions t<CR>
+
+ " 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 <silent>
+ \ <Leader>a
+ \ :<C-U>ToggleOptionFlagLocal formatoptions a<CR>
+ else
+ nnoremap <silent>
+ \ <Leader>a
+ \ :<C-U>echoerr 'No formatoptions a-flag'<CR>
+ endif
+
+ " 'j' needs testing
+ if s:formatoptions_has_j
+ nnoremap <silent>
+ \ <Leader>j
+ \ :<C-U>ToggleOptionFlagLocal formatoptions j<CR>
+ else
+ nnoremap <silent>
+ \ <Leader>j
+ \ :<C-U>echoerr 'No formatoptions j-flag'<CR>
+ endif
+
endif