diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2019-06-06 15:00:41 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2019-06-06 15:00:41 +1200 |
commit | 7fb6107237376c63de62943619b749d35d8fc853 (patch) | |
tree | 91c5d591286e0f7838de8227369251ad6d505bc1 | |
parent | Adjust a few version check comments (diff) | |
download | dotfiles-7fb6107237376c63de62943619b749d35d8fc853.tar.gz dotfiles-7fb6107237376c63de62943619b749d35d8fc853.zip |
Factor out plugin availability checks to function
-rw-r--r-- | vim/autoload/vimrc.vim | 6 | ||||
-rw-r--r-- | vim/vimrc | 9 |
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 @@ -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 |