aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-11-05 01:48:11 +1300
committerTom Ryder <tom@sanctum.geek.nz>2017-11-05 01:48:11 +1300
commit1da79fc20e26a10c268c5bb042d861eeb670ff79 (patch)
tree5368b5e72ad7d01f2ed201d41e9148907f74f1d6
parentMap <leader>j to toggle 'fo'-'j' flag in Vim (diff)
downloaddotfiles-1da79fc20e26a10c268c5bb042d861eeb670ff79.tar.gz
dotfiles-1da79fc20e26a10c268c5bb042d861eeb670ff79.zip
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.
-rw-r--r--vim/config/format.vim55
1 files 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 <silent>