diff --git a/doc/lspconfig.txt b/doc/lspconfig.txt index d1d9103c5b..b64750f49c 100644 --- a/doc/lspconfig.txt +++ b/doc/lspconfig.txt @@ -266,6 +266,28 @@ The global defaults for all servers can be overridden by extending the < `setup {}` can additionally override these defaults in subsequent calls. +============================================================================== +SETUP HOOK *lspconfig-setup-hook* + +`lspconfig` will execute the `on_setup` hook for each setup call to a server after +validating its configuration, and before attempting to launch the server +itself. One typical usage is to allow ad-hoc substitution for any +configuration entry, such as `cmd`. + +> + local lspconfig = require 'lspconfig' + lspconfig.util.on_setup = util.add_hook_before(lspconfig.util.on_setup, function(config) + if some_condition and config.name == "clangd" then + local custom_server_prefix = "/my/custom/server/prefix" + config.cmd = { custom_server_prefix .. "/bin/clangd" } + end + end) + + +Note: This is primarily targeted at plugins developers, so make sure to use +`util.add_hook_before()` as a wrapper instead of overriding the original function +completely, to void breaking external integrations with lspconfig. + ============================================================================== SERVER CONFIGURATIONS *lspconfig-configurations*