Vi and Vim Asked by ostrov040 on August 31, 2021
Currently, I am trying to create a ~/.vimrc
file that I will be able to integrate into any environment and get all my configs with minimum user interference.
In order to simplify my vim configuration. I decided to install my plugins into the ~/.vim/plugged
directory and the colorschemes into another directory ~/.vim/colors
.
Supposedly, I would run 2 commands in vim to install the plugins :source %
:PlugInstall
and then extract the colorscheme *(.vim)*
from the ~/.vim/color/gruvbox/color
and ~/.vim/color/vim-monokai/color
directories in order to make the config more versatile.
Briefly talking, the problem is that the plugins stop working – eg: :NERDTreeToggle
would result in
:NERDTreeToggle is not an edditor command
if there are two call plug#begin/end
statements in the file but the colorschemes get installed as expected.
call plug#begin('~/.vim/plugged')
Plug 'mbbill/undotree'
Plug 'ycm-core/YouCompleteMe'
Plug 'preservim/nerdtree'
Plug 'lyuts/vim-rtags'
Plug 'vim-utils/vim-man'
" Git Integration:
Plug 'mhinz/vim-signify'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rhubarb'
Plug 'junegunn/gv.vim'
call plug#end()
call plug#begin('~/.vim/colors')
" Colorscheme:
Plug 'morhetz/gruvbox'
Plug 'sickill/vim-monokai'
call plug#end()
Although I was able to fix the problem simply by putting all repos into one call plug#begin/end
block as indicated below, I am still curious if there exists a different solution to the problem.
call plug#begin('~/.vim/plugged')
Plug 'mbbill/undotree'
Plug 'ycm-core/YouCompleteMe'
Plug 'preservim/nerdtree'
Plug 'lyuts/vim-rtags'
Plug 'vim-utils/vim-man'
" Git Integration:
Plug 'mhinz/vim-signify'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rhubarb'
Plug 'junegunn/gv.vim'
" Colorscheme:
Plug 'morhetz/gruvbox'
Plug 'sickill/vim-monokai'
call plug#end()
PS: I am using vim-plug as my plugin manager
So your question has already been asked in vim-plug's issue tracker, see #905.
@raindev said this (I changed the link to the code to not use master in case the code changes in the future):
I don't think that will work currently as each call to plug#begin resets Plug configuration (and not appends to it): https://github.com/junegunn/vim-plug/blob/c31903639623c5be2431a/plug.vim#L166-L169
I've run into this issue trying to have multiple plug sections: only plugins from the last one will be included.
Also @janlazo (who is one of the current maintainers) said that changing that would require a big refactor and thus I think there are few chances that the feature will be one day added to vim-plug.
Now what would be interesting is to understand why you think having your colorscheme in a different repository would simplify your configuration:
color
directory which integrates well with Vim built-in mechanisms.So my advise would be to avoid doing what you are trying to do. However you could still want to have some logic in your vimrc to source plugins depending on the machine you are using.
In this question I asked, @VanLaser suggests a simple way to source a file containing some Plug '.../...'
directives only if the file exists. And on another vim-plug issue @janlazo suggests to add a function in the plugin section which would source some plugins.
Maybe you can get some inspiration from these ideas to add the logic you want in your plugins.
Correct answer by statox on August 31, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP