aboutsummaryrefslogtreecommitdiff
path: root/vim
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-06-06 15:00:41 +1200
committerTom Ryder <tom@sanctum.geek.nz>2019-06-06 15:00:41 +1200
commit7fb6107237376c63de62943619b749d35d8fc853 (patch)
tree91c5d591286e0f7838de8227369251ad6d505bc1 /vim
parentAdjust a few version check comments (diff)
downloaddotfiles-7fb6107237376c63de62943619b749d35d8fc853.tar.gz
dotfiles-7fb6107237376c63de62943619b749d35d8fc853.zip
Factor out plugin availability checks to function
Diffstat (limited to 'vim')
-rw-r--r--vim/autoload/vimrc.vim6
-rw-r--r--vim/vimrc9
2 files changed, 11 insertions, 4 deletions
diff --git a/vim/autoload/vimrc.vim b/vim/autoload/vimrc.vim
index 356861c6..de73720b 100644
--- a/vim/autoload/vimrc.vim
+++ b/vim/autoload/vimrc.vim
@@ -3,6 +3,12 @@ function! vimrc#EscapeSet(string) abort
return escape(a:string, '\ ,')
endfunction
+" Check that we have a plugin available, and will be loading it
+function! vimrc#PluginReady(filename) abort
+ return globpath(&runtimepath, 'plugin/'.a:filename.'.vim') !=# ''
+ \ && &loadplugins
+endfunction
+
" Split a string with a split character that can be escaped with another,
" e.g. &runtimepath with commas and backslashes respectively
function! vimrc#SplitEscaped(str, ...) abort
diff --git a/vim/vimrc b/vim/vimrc
index b32b7ca6..6c5552d4 100644
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -216,15 +216,16 @@ catch
set nocursorline
endtry
-" Space bar scrolls down a page, :next if plugin available
-if &loadplugins
+" Space bar scrolls down a page, :next at buffer's end if plugin available
+if vimrc#PluginReady('scroll_next')
nmap <Space> <Plug>(ScrollNext)
else
nnoremap <Space> <PageDown>
endif
-" Remap insert Ctrl-C to undo the escaped insert operation
-if &loadplugins " Don't break the key if we won't be loading the plugin
+" Remap insert Ctrl-C to undo the escaped insert operation, but don't break
+" the key if the plugin isn't there
+if vimrc#PluginReady('insert_cancel')
imap <C-C> <Plug>(InsertCancel)
endif