Skip to content

Commit

Permalink
Fix #13: Add UnPlug and g:plugs_disabled
Browse files Browse the repository at this point in the history
It is now possible to either "UnPlug" plugins similarly
to how one would "Plug" them. Alternatively use the
`g:plugs_disabled` as a list of repo names to be disabled.

See comments in `.vimrc` and updated README for further
instructions and information.
  • Loading branch information
timss committed Sep 3, 2017
1 parent 5bfcf01 commit 1b4f629
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 5 deletions.
33 changes: 28 additions & 5 deletions .vimrc
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,28 @@
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif

""" Plugins to be disabled {{{
""" https://github.com/timss/vimconf/issues/13
" Create empty list with names of disabled plugins if not defined
let g:plugs_disabled = get(g:, 'plug_disabled', [])

" Trim and extract repo name
" Same substitute/fnamemodify args as vim-plug itself
" https://github.com/junegunn/vim-plug/issues/469#issuecomment-226965736
function! s:plugs_disable(repo)
let repo = substitute(a:repo, '[\/]\+$', '', '')
let name = fnamemodify(repo, ':t:s?\.git$??')
call add(g:plugs_disabled, name)
endfunction

" Append to list of repo names to be disabled just like they're added
" UnPlug 'junegunn/vim-plug'
command! -nargs=1 -bar UnPlug call s:plugs_disable(<args>)
""" }}}

" Default to same plugin directory as vundle etc
call plug#begin('~/.vim/bundle')

" local plugins
if filereadable($HOME."/.vimrc.plugins")
source $HOME/.vimrc.plugins
endif

" <Tab> everything!
Plug 'ervandew/supertab'

Expand Down Expand Up @@ -86,6 +100,15 @@
Plug 'majutsushi/tagbar'
endif

" Local plugins
if filereadable($HOME."/.vimrc.plugins")
source $HOME/.vimrc.plugins
endif

" Remove disabled plugins from installation/initialization
" https://vi.stackexchange.com/q/13471/5070
call filter(g:plugs, 'index(g:plugs_disabled, v:key) == -1')

" Initalize plugin system
call plug#end()
""" }}}
Expand Down
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,24 @@ Some useful plugins could be:
* [jedi-vim](https://github.com/davidhalter/jedi-vim) - Python autocompletion using the Jedi library.
* [YouCompleteMe](https://github.com/Valloric/YouCompleteMe) - Autocompletion for several languages (C/C++, Python, ...)

### Disabling plugins

If you want to disable any of the plugins included in the main configuration
either `UnPlug` them:

```viml
UnPlug 'ervandew/supertab'
UnPlug 'scrooloose/syntastic'
```

Or define a list of repo names to be disabled:

```viml
let g:plugs_disabled = ['supertab', 'syntastic']
```

Both should be added to `~/.vimrc.plugins`.

Preview
-------

Expand Down

0 comments on commit 1b4f629

Please sign in to comment.