Doesn't this mean that neovim will load the nvim-lspconfig plugin while executing my init.vim config, even though nvim-lspconfig would have been loaded automatically by neovim anyway?
Basically, a plugin is a collection of scripts. So what does "loading a plugin" really mean? As simple as expanding
&runtimepath and sourcing everything under
However, the Lua engine doesn't require
&runtimepath expansion in order to find Lua modules under
lua/ (and in last versions even Vim isn't strict anymore, so it's now allowed to call plugins' functions from
autoload/ right from
vimrc without delaying to
So the real point if it's okay to call plugin's exported functions before its
plugin/ was sourced as part of startup or not. Also, another question if those functions are okay to call before full application init (i.e. VimEnter).
And so it may depend on particular plugin, but in many cases it's all right.
Would adding this config to after/ make it possible to execute it conditionally based on whether the plugin was loaded or not (in case it isn't installed on a different pc)?
after/ is not a "conditional directory". It's just (the last) node in
&runtimepath. So one knows that
after/plugin/ is sourced after
plugin/ was sourced but nothing more. Thus if you need "a condition" you still have to add it yourself. But indeed
after/ could be a good place for this.
Although remember that some plugins may not expect changing its settings at this point. Or, maybe, they need quite "expensive" default init on startup, and so doing it for the second time is not recommended.
IOW, if in doubt always look into both
plugin/ subdirectory. If during the startup a plugin only creates commands/mappings etc. (and this is the case for many and many of them) then you're totally free to do anything you like (except, you can't invoke those commands from your vimrc, of course).