cmp-nvim-lsp
cmp-nvim-lsp copied to clipboard
Move from after/plugin to plugin and follow plugin best pratices
Resolves #60
Don't think adding global variables is the desired solution.
Don't think adding global variables is the desired solution.
I disagree, this is regarded as the best practice to allow users to disable your plugin from loading, and or for it not to redo it's work (which might e.g create duplicate autocmd). Source with respect to regarded: examples of a few popular plugins (by vim-awesome):
It should be achievable without global variables though.
In lua, we can use package.loaded[mod]
- if vim.g.loaded_cmp_nvim_lsp then
+ if package.loaded['cmp_nvim_lsp'] then
return
end
- vim.g.loaded_cmp_nvim_lsp = true
require("cmp_nvim_lsp").setup()
I think global load_... variables for plugin is fine, as it's a very common convention.
Common from vim as there was no other way. @fitrh solution is way cleaner.
I prefer @fitrh's method. Could you please change it like that?
While I understand the point as to why you would prefer the latter method in a Lua package. I might offer one last disadvantage, that is that we're not compatible with the way you can disable builtin plugins in Neovim using:
local disabled_builtin_plugins = {
"netrw",
-- ...
}
for _, plugin in ipairs(disabled_builtin_plugins) do
vim.g["loaded_" .. plugin] = true
end
If regardless of that we still want this change I'll make the adjustment.
I prefer @fitrh's method. Could you please change it like that?
Done