According to the OP, the plugin directory is located inside the 'packpath'
, which means the plugin is not available until after the vimrc is processed:
When Vim starts up, after processing your .vimrc, it scans all directories in
'packpath' for plugins under the "pack/*/start" directory. First all those
directories are added to 'runtimepath'. Then all the plugins are loaded.
See |packload-two-steps| for how these two steps can be useful.
[...]
Note that the files under "pack/foo/opt" are not loaded automatically, only the
ones under "pack/foo/start". See |pack-add| below for how the "opt" directory
is used.
Loading packages automatically will not happen if loading plugins is disabled,
see |load-plugins|.
To load packages earlier, so that 'runtimepath' gets updated: >
:packloadall
This also works when loading plugins is disabled. The automatic loading will
only happen once.
(:help packages
)
While the help system mentions using :packloadall
to load packages earlier, I offer an alternative suggestion: the after
directory. By the time after files load, packages have been loaded. In my own Dotfiles, I keep a directory ~/.vim/after/plugin/config/
1 with short files to customize my plugins.
As an example, my config for ale is in ~/.vim/after/plugin/config/ale.vim
:
if ! exists(':ALEInfo')
finish
endif
let g:ale_set_signs = 0
let g:ale_linters = {
\ 'python': 'all',
\ 'java': [],
\ }
The trick is generally to find a reliable way of testing for the presence of the plugin: when they define commands or "skip" variables (e.g. g:loaded_{name}
), we can test those. Autoload'ed functions (file#name
) are harder because they don't exist until they are used.
In your case, I'd use g:loaded_deoplete
in a file like ~/.vim/after/plugin/config/deoplete.vim
(use the equivalent for neovim):
if ! exists('g:loaded_deoplete')
finish
endif
" your custom code here
call deoplete#custom#source('ultisnips', 'rank', 1000)
- The name
plugin
does not mean plugin as a set of code from GitHub or elsewhere, but rather a plugin script (cf. :help plugin
). The name config
is not significant except that it helps me organize my after/plugin
directory: all the configuration lies there. Note that all subdirectories of a plugin directory are searched for scripts.
site/pack/me/start/**
- is there somewhere else they should be ?