mirror of
https://github.com/neovim/neovim.git
synced 2025-10-26 12:27:24 +00:00
feat(lsp): pass resolved config to cmd() #34550
Problem: In LSP configs, the function form of `cmd()` cannot easily get the resolved root dir (workspace). One of the main use-cases of a dynamic `cmd()` is to be able to start a new server whose binary may be located *in the workspace* ([example](https://github.com/neovim/nvim-lspconfig/pull/3912)). Compare `reuse_client()`, which also receives the resolved config. Solution: Pass the resolved config to `cmd()`. Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
This commit is contained in:
@@ -45,11 +45,11 @@ local validate = vim.validate
|
||||
---
|
||||
--- Command `string[]` that launches the language server (treated as in |jobstart()|, must be
|
||||
--- absolute or on `$PATH`, shell constructs like "~" are not expanded), or function that creates an
|
||||
--- RPC client. Function receives a `dispatchers` table and returns a table with member functions
|
||||
--- `request`, `notify`, `is_closing` and `terminate`.
|
||||
--- RPC client. Function receives a `dispatchers` table and the resolved `config`, and must return
|
||||
--- a table with member functions `request`, `notify`, `is_closing` and `terminate`.
|
||||
--- See |vim.lsp.rpc.request()|, |vim.lsp.rpc.notify()|.
|
||||
--- For TCP there is a builtin RPC client factory: |vim.lsp.rpc.connect()|
|
||||
--- @field cmd string[]|fun(dispatchers: vim.lsp.rpc.Dispatchers): vim.lsp.rpc.PublicClient
|
||||
--- @field cmd string[]|fun(dispatchers: vim.lsp.rpc.Dispatchers, config: vim.lsp.ClientConfig): vim.lsp.rpc.PublicClient
|
||||
---
|
||||
--- Directory to launch the `cmd` process. Not related to `root_dir`.
|
||||
--- (default: cwd)
|
||||
@@ -455,7 +455,7 @@ function Client.create(config)
|
||||
-- Start the RPC client.
|
||||
local config_cmd = config.cmd
|
||||
if type(config_cmd) == 'function' then
|
||||
self.rpc = config_cmd(dispatchers)
|
||||
self.rpc = config_cmd(dispatchers, config)
|
||||
else
|
||||
self.rpc = lsp.rpc.start(config_cmd, dispatchers, {
|
||||
cwd = config.cmd_cwd,
|
||||
|
||||
Reference in New Issue
Block a user