How to toggle (Vimplug) plugins on and off on the fly?
source link: https://stackoverflow.com/questions/64507845/how-to-toggle-vimplug-plugins-on-and-off-on-the-fly
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
How to toggle (Vimplug) plugins on and off on the fly?
Using COC on multiple instances can really take a toll on my intel i3+4GB machine.
So I was wondering if I could toggle it on demand.
I have managed to turn it off by default and toggle it on using Vimplug's built in feature like the following.
Plug 'neoclide/coc.nvim', {'branch': 'release', 'on': 'CocToggle' }
However, I'm not sure how to toggle it off.
Any help would be highly appreciated!
P.S.: I have tried CocDisable
and didn't notice any practical benefits that would minimize the resource usage like killing the gazillion node processes started by COC for each instances!
Solution
I ended up writing the following function for my use case.
Plug 'neoclide/coc.nvim', {'branch': 'release' }
let g:coc_start_at_startup = 0
let s:coc_enabled = 0
function! ToggleCoc()
if s:coc_enabled == 0
let s:coc_enabled = 1
CocStart
echo 'COC on'
else
let s:coc_enabled = 0
echo 'COC off'
call coc#rpc#stop()
endif
endfunction
nnoremap <silent> <leader>h :call ToggleCoc()<cr>
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK