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(-) (limited to 'vim/config') 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