Vim-plug: Option to Disable a Plugin

Created on 13 Apr 2016  路  4Comments  路  Source: junegunn/vim-plug

I'm using Thoughtbot's dotfiles, which installs Syntastic by default. Since I'm using Neovim, I'd like for a way to disable the prevent Syntastic from being installed and install Neomake instead.

For sample, I'd like to do something like this:

" In Thoughtbot's .vimrc
Plug 'scrooloose/syntastic'

...

" In my .vimrc
Unplug 'scrooloose/syntastic'
Plug 'benekastah/neomake'

Is something like that possible? Thanks in advance!

P.S. Thanks for creating such a great plugin manager!


NVIM 0.1.2
Build type: RelWithDebInfo
Compilation: /usr/local/Library/ENV/4.3/clang -Wconversion -O2 -g -DDISABLE_LOG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99
 -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -DHAVE_CONFIG_H -I/tmp/neovim20160307-12635-1qupgzn/neovim-0.1.2/b
uild/config -I/tmp/neovim20160307-12635-1qupgzn/neovim-0.1.2/src -I/tmp/neovim20160307-12635-1qupgzn/neovim-0.1.2/deps-build/usr/include -I/tmp/neovim201603
07-12635-1qupgzn/neovim-0.1.2/deps-build/usr/include -I/tmp/neovim20160307-12635-1qupgzn/neovim-0.1.2/deps-build/usr/include/luajit-2.0 -I/tmp/neovim2016030
7-12635-1qupgzn/neovim-0.1.2/deps-build/usr/include -I/tmp/neovim20160307-12635-1qupgzn/neovim-0.1.2/deps-build/usr/include -I/tmp/neovim20160307-12635-1qup
gzn/neovim-0.1.2/deps-build/usr/include -I/tmp/neovim20160307-12635-1qupgzn/neovim-0.1.2/deps-build/usr/include -I/usr/local/opt/gettext/include -I/usr/incl
ude -I/usr/include -I/tmp/neovim20160307-12635-1qupgzn/neovim-0.1.2/build/src/nvim/auto -I/tmp/neovim20160307-12635-1qupgzn/neovim-0.1.2/build/include
Compiled by [email protected]

Optional features included (+) or not (-): +acl   +iconv    +jemalloc
For differences from Vim, see :help vim-differences

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/0.1.2/share/nvim"

  • Type:

    • [ ] Bug

    • [ ] Enhancement

    • [ ] Feature Request

    • [x] Question

  • OS:

    • [ ] All/Other

    • [ ] Linux

    • [x] OS X

    • [ ] Windows

  • Vim:

    • [ ] Terminal Vim

    • [ ] GVim

    • [x] Neovim

question

Most helpful comment

Just for the record, this solution worked for me.

The plugin must be removed from both g:plugs and g:plugs_order,
so I created the UnPlug command which call a custom function.

vimrc:

function! s:deregister(repo)
  let repo = substitute(a:repo, '[\/]\+$', '', '')
  let name = fnamemodify(repo, ':t:s?\.git$??')
  call remove(g:plugs, name)
  call remove(g:plugs_order, index(g:plugs_order, name))
endfunction

command! -nargs=1 -bar UnPlug call s:deregister(<args>)


call plug#begin('~/.vim/bundle')

" Load bundles
source ~/.vim/bundle.vim

" Load bundles of the fork
if filereadable(expand("~/.vim/bundle.fork"))
  source ~/.vim/bundle.fork
endif

" Load bundles of the local machine
if filereadable(expand("~/.vim/bundle.local"))
  source ~/.vim/bundle.local
endif

call plug#end()

delcom UnPlug

bundle.vim:

" ...
Plug 'kien/ctrlp.vim'
" ...

bundle.local:

" Disable
UnPlug 'kien/ctrlp.vim'
" Replace
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'

All 4 comments

  1. Remove if from g:plugs: call remove(g:plugs, 'syntastic')
  2. Override it so that it's not loaded: Plug 'scrooloose/syntastic', { 'on': [] }

    • It will be still installed though

  3. Fork the repo, which I honestly think is the best approach :)

(1 and 2 should be done before call plug#end())

Thanks!

Just for the record, this solution worked for me.

The plugin must be removed from both g:plugs and g:plugs_order,
so I created the UnPlug command which call a custom function.

vimrc:

function! s:deregister(repo)
  let repo = substitute(a:repo, '[\/]\+$', '', '')
  let name = fnamemodify(repo, ':t:s?\.git$??')
  call remove(g:plugs, name)
  call remove(g:plugs_order, index(g:plugs_order, name))
endfunction

command! -nargs=1 -bar UnPlug call s:deregister(<args>)


call plug#begin('~/.vim/bundle')

" Load bundles
source ~/.vim/bundle.vim

" Load bundles of the fork
if filereadable(expand("~/.vim/bundle.fork"))
  source ~/.vim/bundle.fork
endif

" Load bundles of the local machine
if filereadable(expand("~/.vim/bundle.local"))
  source ~/.vim/bundle.local
endif

call plug#end()

delcom UnPlug

bundle.vim:

" ...
Plug 'kien/ctrlp.vim'
" ...

bundle.local:

" Disable
UnPlug 'kien/ctrlp.vim'
" Replace
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'

The plugin must be removed from both g:plugs and g:plugs_order

Hmm, you're right. I'll make the code ignore any entry in g:plugs_order that is not found in g:plugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bearzyj picture bearzyj  路  3Comments

RubenVerborgh picture RubenVerborgh  路  3Comments

fvictorio picture fvictorio  路  3Comments

bmcilw1 picture bmcilw1  路  3Comments

stobenski picture stobenski  路  5Comments