From 7dc55f4179621001e28c0840675b14767deaec59 Mon Sep 17 00:00:00 2001 From: Daniel Sissom Date: Wed, 23 Oct 2019 15:19:14 -0500 Subject: [PATCH] Updated vimrc to also work before plugins are installed. --- vim/vim/autoload/.gitignore | 1 + vim/vimrc | 59 ++++++++++++++++++++++++------------- 2 files changed, 40 insertions(+), 20 deletions(-) create mode 100644 vim/vim/autoload/.gitignore diff --git a/vim/vim/autoload/.gitignore b/vim/vim/autoload/.gitignore new file mode 100644 index 0000000..43c9cab --- /dev/null +++ b/vim/vim/autoload/.gitignore @@ -0,0 +1 @@ +plug.vim diff --git a/vim/vimrc b/vim/vimrc index 858c7ea..9bf68e4 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -29,6 +29,13 @@ if has("autocmd") filetype plugin indent on endif +" Use plugin manager if available +if (filereadable($HOME."/.vim/autoload/plug.vim")) || (filereadable("/usr/share/vim/vimfiles/autoload/plug.vim")) + let g:use_pluggin_manager = 1 +else + let g:use_pluggin_manager = 0 +endif + "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -165,15 +172,24 @@ function! LazyLoadingYMC() call plug#load('YouCompleteMe') | call youcompleteme#Enable() endif endfunction -autocmd BufRead * call timer_start(1, {id->execute('call LazyLoadingYMC()')} ) -" (also try BufWinEnter, InsertEnter, or CursorHold and CursorHoldI events) +if g:use_pluggin_manager == 1 + autocmd BufRead * call timer_start(1, {id->execute('call LazyLoadingYMC()')} ) + " (also try BufWinEnter, InsertEnter, or CursorHold and CursorHoldI events) +endif " Enable vimtex completions for YCM -if !exists('g:ycm_semantic_triggers') - let g:ycm_semantic_triggers = {} +function! VimtexYCMSetup() + if !exists('g:ycm_semantic_triggers') + let g:ycm_semantic_triggers = {} + endif + if exists('g:vimtex#re#youcompleteme') + let g:ycm_semantic_triggers.tex=g:vimtex#re#youcompleteme + endif +endfunction +if has("autocmd") + autocmd VimEnter * call VimtexYCMSetup() endif -autocmd VimEnter * let g:ycm_semantic_triggers.tex=g:vimtex#re#youcompleteme @@ -184,21 +200,24 @@ autocmd VimEnter * let g:ycm_semantic_triggers.tex=g:vimtex#re#youcompleteme " Use with :PlugInstall and :PlugUpdate -" Set custom plugin directory -call plug#begin('~/.vim/vim-plug') - -Plug 'ycm-core/YouCompleteMe', { 'do': function('BuildYCM'), 'on': [] } -Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } -Plug 'dense-analysis/ale' -Plug 'airblade/vim-gitgutter' -Plug 'godlygeek/tabular' -Plug 'tpope/vim-surround' -Plug 'tpope/vim-unimpaired' -Plug 'tpope/vim-speeddating' -Plug 'tpope/vim-repeat' -Plug 'lervag/vimtex' - -call plug#end() +"if exists('g:use_pluggin_manager') && g:use_pluggin_manager +if g:use_pluggin_manager == 1 + " Set custom plugin directory + call plug#begin('~/.vim/vim-plug') + + Plug 'ycm-core/YouCompleteMe', { 'do': function('BuildYCM'), 'on': [] } + Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } + Plug 'dense-analysis/ale' + Plug 'airblade/vim-gitgutter' + Plug 'godlygeek/tabular' + Plug 'tpope/vim-surround' + Plug 'tpope/vim-unimpaired' + Plug 'tpope/vim-speeddating' + Plug 'tpope/vim-repeat' + Plug 'lervag/vimtex' + + call plug#end() +endif