-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: add an entry about the setup-hook #1873
Conversation
Maybe emphasize "this is principally for plugin developers, and overriding this without wrapping the original function may break external integrations with lspconfig" |
would it make sense to have this setting per-server instead of being global? diff --git a/lua/lspconfig/util.lua b/lua/lspconfig/util.lua
index 3febafc..3e57fde 100644
--- a/lua/lspconfig/util.lua
+++ b/lua/lspconfig/util.lua
@@ -14,11 +14,9 @@ M.default_config = {
init_options = vim.empty_dict(),
handlers = {},
autostart = true,
+ on_setup = nil
}
--- global on_setup hook
-M.on_setup = nil
|
FWIW, I found use for this in my personal configs for making sure to apply a set of default configurations (primarily the ever so present
|
doc/lspconfig.txt
Outdated
lspconfig.util.on_setup = util.add_hook_before(lspconfig.util.on_setup, function(config) | ||
if some_condition then | ||
local custom_server_prefix = "/my/custom/path" | ||
config.cmd_env = custom_server_prefix |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you perhaps mean to set the cmd
? cmd_env
is a table
config.cmd_env = custom_server_prefix | |
config.cmd = { custom_server_prefix } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hopefully this new example makes sense!
FWIW, I found use for this in my personal configs for making sure to apply a set of default configurations (primarily the ever so present
on_attach
andcapabilities
settings).
I'm not sure if this is something that @mjlbach wants to advertise (?)
since he suggested the note about this targeting plugins devs, and one can get a somewhat similar result by overriding the global defaults :h lspconfig-global-defaults
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah TIL about global defaults 😅. I guess one difference is that with the hook approach you can make sure to merge settings, for example chaining function on_attach
and on_new_config
calls.
The
on_setup
hook is currently undocumented, and it should gain some attention after williamboman/nvim-lsp-installer#631