From a7bfabb96fa5b186447839de048629d0aa53b154 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 10 Mar 2020 14:14:11 +1300 Subject: Check for existence of 'colorcolumn' option --- vim/after/ftplugin/gitcommit.vim | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'vim') diff --git a/vim/after/ftplugin/gitcommit.vim b/vim/after/ftplugin/gitcommit.vim index 4a1c3814..093dc5f5 100644 --- a/vim/after/ftplugin/gitcommit.vim +++ b/vim/after/ftplugin/gitcommit.vim @@ -4,13 +4,15 @@ setlocal formatoptions+=coqr let b:undo_ftplugin .= '|setlocal comments< formatoptions<' " Choose the color column depending on non-comment line count -augroup gitcommit_cursorcolumn - autocmd CursorMoved,CursorMovedI - \ let &l:colorcolumn = gitcommit#CursorColumn() -augroup END -let b:undo_ftplugin .= '|execute ''autocmd! gitcommit_cursorcolumn''' - \ . '|augroup! gitcommit_cursorcolumn' - \ . '|setlocal colorcolumn<' +if exists('&colorcolumn') + augroup gitcommit_cursorcolumn + autocmd CursorMoved,CursorMovedI + \ let &l:colorcolumn = gitcommit#CursorColumn() + augroup END + let b:undo_ftplugin .= '|execute ''autocmd! gitcommit_cursorcolumn''' + \ . '|augroup! gitcommit_cursorcolumn' + \ . '|setlocal colorcolumn<' +endif " Stop here if the user doesn't want ftplugin mappings if exists('no_plugin_maps') || exists('no_gitcommit_maps') -- cgit v1.2.3 From 0350f6c03d8b9d31e25999a31e230722b3815080 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 5 Apr 2020 21:59:14 +1200 Subject: Vim: Use more correct method of escaping :set RHS --- vim/autoload/argument.vim | 8 -------- vim/autoload/option.vim | 6 ++++++ vim/vimrc | 14 +++++++------- 3 files changed, 13 insertions(+), 15 deletions(-) delete mode 100644 vim/autoload/argument.vim (limited to 'vim') diff --git a/vim/autoload/argument.vim b/vim/autoload/argument.vim deleted file mode 100644 index 85d75eb1..00000000 --- a/vim/autoload/argument.vim +++ /dev/null @@ -1,8 +0,0 @@ -" Escape a single argument for use on an Ex command line; essentially -" a backport of fnameescape() for versions before v7.1.299 -" -function! argument#Escape(argument) abort - return exists('*fnameescape') - \ ? fnameescape(a:argument) - \ : escape(a:argument, "\n\r\t".' *?[{`$\%#''"|!<') -endfunction diff --git a/vim/autoload/option.vim b/vim/autoload/option.vim index 5ff44ced..c44cf94b 100644 --- a/vim/autoload/option.vim +++ b/vim/autoload/option.vim @@ -9,3 +9,9 @@ function! option#Split(expr, ...) abort let parts = split(a:expr, '\\\@ " -execute 'set viminfo+='.argument#Escape('n'.$MYVIM.'/viminfo') +execute 'set viminfo+='.option#Escape('n'.$MYVIM.'/viminfo') CreatePath $MYVIM " Speaking of recorded data in viminfo files, the default Vim limit of a mere @@ -179,7 +179,7 @@ set history=10000 " 'backupfullname', 'swapfilefullname' would have been clearer. " set backup -execute 'set backupdir^='.argument#Escape(option#item#Escape( +execute 'set backupdir^='.option#Escape(option#item#Escape( \ $MYVIM.'/backup'.(has#('patch-8.1.251') ? '//' : ''), \)) CreatePath! $MYVIM/backup @@ -219,7 +219,7 @@ endif " apply path#Create() to attempt to create the path, if needed. " execute 'set directory^=' - \.argument#Escape(option#item#Escape($MYVIM.'/swap//')) + \.option#Escape(option#item#Escape($MYVIM.'/swap//')) CreatePath! $MYVIM/swap " Keep tracked undo history for files permanently, in a dedicated cache @@ -238,7 +238,7 @@ CreatePath! $MYVIM/swap if has#('persistent_undo') set undofile execute 'set undodir^=' - \.argument#Escape(option#item#Escape($MYVIM.'/undo//')) + \.option#Escape(option#item#Escape($MYVIM.'/undo//')) CreatePath! $MYVIM/undo endif @@ -357,9 +357,9 @@ set dictionary^=/usr/share/dict/words let s:ref = $MYVIM.'/ref' try execute 'set dictionary^=' - \.argument#Escape(option#item#Escape(s:ref.'/dictionary.txt')) + \.option#Escape(option#item#Escape(s:ref.'/dictionary.txt')) execute 'set thesaurus^=' - \.argument#Escape(option#item#Escape(s:ref.'/thesaurus.txt')) + \.option#Escape(option#item#Escape(s:ref.'/thesaurus.txt')) catch /^Vim\%((\a\+)\)\=:E474:/ endtry -- cgit v1.2.3