本地Vim插件加载顺序

3
有时Vim插件会建议一个加载顺序,但现在Vim已经原生支持不使用插件管理器加载插件。你只需要将子模块放在文件夹中,例如~/.vim/pack/vendor/start,它就会自动加载。那么,我的问题是如何确保与以前类似的加载顺序。下面是以前的做法示例:
Plug 'preservim/nerdtree' |
            \ Plug 'Xuyuanp/nerdtree-git-plugin' |
            \ Plug 'ryanoasis/vim-devicons'

这段内容摘自https://github.com/Xuyuanp/nerdtree-git-plugin#faq

1个回答

3

让我们尝试一个小实验...

  1. Create the following dummy files with their corresponding content:

    Filepath Content
    pack/dummy/start/nerdtree/plugin/foo.vim echom "nerdtree"
    pack/dummy/start/nerdtree-git-plugin/plugin/bar.vim echom "nerdtree-git-plugin"
    pack/dummy/start/vim-devicons/plugin/baz.vim echom "vim-devicons"
  2. Start Vim and you should see something like the following:

    $ vim
    nerdtree
    nerdtree-git-plugin
    vim-devicons
    Press ENTER or type command to continue
    

    which is consistant with:

    :filter dummy scriptnames
     40: ~/.vim/pack/dummy/start/nerdtree/plugin/foo.vim
     41: ~/.vim/pack/dummy/start/nerdtree-git-plugin/plugin/bar.vim
     42: ~/.vim/pack/dummy/start/vim-devicons/plugin/baz.vim
    Press ENTER or type command to continue
    
根据这个实验,我们可以得出结论:内置的“package”功能将按照文件系统中发现的插件的顺序“加载”start/目录下的插件,这恰好与规定的顺序相同。当然,你的文件系统对目录的排序可能与我的不同,所以结果可能会有所不同。
理论上,:help :packadd命令应该允许您像使用插件管理器一样从vimrc中“管理”您的插件。让我们进行实验...
  1. Rename start/ to opt/:

    pack/dummy/opt/nerdtree/
    pack/dummy/opt/nerdtree-git-plugin/
    pack/dummy/opt/vim-devicons/
    
  2. Add the following lines to your vimrc after any syntax on or filetype on line:

    packadd! nerdtree
    packadd! nerdtree-git-plugin
    packadd! vim-devicons
    
  3. Start Vim:

    $ vim
    vim-devicons
    nerdtree-git-plugin
    nerdtree
    Press ENTER or type command to continue
    

    What?

嗯...我猜你可以尝试调整顺序,直到你得到所需的顺序,但倒序看起来像是一个bug。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接