From 48aca176ee07af4bb6c9c0292a34635b03a12016 Mon Sep 17 00:00:00 2001 From: Davidyz Date: Wed, 26 Mar 2025 15:42:00 +0000 Subject: [PATCH 1/6] feat(nvim)!: use new LSP APIs introduced in nvim 0.11.0 --- doc/VectorCode.txt | 4 +-- docs/neovim.md | 4 +-- lua/lsp/vectorcode_server.lua | 1 + lua/vectorcode/cacher/lsp.lua | 60 -------------------------------- lua/vectorcode/config.lua | 7 ++-- lua/vectorcode/jobrunner/lsp.lua | 35 +++---------------- 6 files changed, 13 insertions(+), 98 deletions(-) create mode 100644 lua/lsp/vectorcode_server.lua diff --git a/doc/VectorCode.txt b/doc/VectorCode.txt index 54dc416e..580265d1 100644 --- a/doc/VectorCode.txt +++ b/doc/VectorCode.txt @@ -194,7 +194,7 @@ registered to run when `setup` is called. Supported keys: - `update`: if `true`, the plugin will run `vectorcode update` on startup to update the embeddings; - `lsp`: if `true`, the plugin will try to start the LSP server on startup so that you won’t need to wait for the server loading when making -your first request. +your first request. _Requires neovim 0.11.0+._ You may notice that a lot of options in `async_opts` are the same as the other options in the top-level of the main option table. This is because the @@ -324,7 +324,7 @@ interface: 1. The `default` backend which works exactly like the original implementation used in previous versions; 2. The `lsp` based backend, which make use of the experimental `vectorcode-server` -implemented in version 0.4.0. +implemented in version 0.4.0. _Requires neovim 0.11.0+._ ------------------------------------------------------------------------------- Features default lsp diff --git a/docs/neovim.md b/docs/neovim.md index 679fc8e6..1bc98771 100644 --- a/docs/neovim.md +++ b/docs/neovim.md @@ -177,7 +177,7 @@ The following are the available options for the parameter of this function: update the embeddings; - `lsp`: if `true`, the plugin will try to start the LSP server on startup so that you won't need to wait for the server loading when making your first - request. + request. _Requires neovim 0.11.0+._ You may notice that a lot of options in `async_opts` are the same as the other options in the top-level of the main option table. This is because the top-level @@ -293,7 +293,7 @@ interface: 1. The `default` backend which works exactly like the original implementation used in previous versions; 2. The `lsp` based backend, which make use of the experimental `vectorcode-server` - implemented in version 0.4.0. + implemented in version 0.4.0. _Requires neovim 0.11.0+._ | Features | `default` | `lsp` | diff --git a/lua/lsp/vectorcode_server.lua b/lua/lsp/vectorcode_server.lua new file mode 100644 index 00000000..c9359e74 --- /dev/null +++ b/lua/lsp/vectorcode_server.lua @@ -0,0 +1 @@ +return { cmd = { "vectorcode-server" }, root_markers = { ".vectorcode", ".git" } } diff --git a/lua/vectorcode/cacher/lsp.lua b/lua/vectorcode/cacher/lsp.lua index 9c0e4106..ca8c2039 100644 --- a/lua/vectorcode/cacher/lsp.lua +++ b/lua/vectorcode/cacher/lsp.lua @@ -43,60 +43,6 @@ local function is_lsp_running() return true end ----@param project_root string? ----@param ok_to_fail boolean? ----@return boolean -local function start_server(project_root, ok_to_fail) - if is_lsp_running() then - return true - end - - if ok_to_fail == nil then - ok_to_fail = true - end - local cmd = { "vectorcode-server" } - if - type(project_root) == "string" - and vim.list_contains({ "directory" }, vim.uv.fs_stat(project_root).type) - then - vim.list_extend(cmd, { "--project_root", project_root }) - else - local try_root = vim.fs.root(".", ".vectorcode") or vim.fs.root(".", ".git") - if try_root ~= nil then - vim.list_extend(cmd, { "--project_root", try_root }) - else - vim.schedule(function() - vim.notify( - "Failed to start vectorcode-server due to failing to resolve the project root.", - vim.log.levels.ERROR, - notify_opts - ) - end) - return false - end - end - local id, err = vim.lsp.start_client({ - name = "vectorcode_server", - cmd = cmd, - }) - - if err ~= nil and (vc_config.get_user_config().notify or not ok_to_fail) then - vim.schedule(function() - vim.notify( - ("Failed to start vectorcode-server due to the following error:\n%s"):format( - err - ), - vim.log.levels.ERROR, - notify_opts - ) - end) - return false - else - client_id = id - return true - end -end - ---@type table local CACHE = {} @@ -223,12 +169,6 @@ M.register_buffer = vc_config.check_cli_wrap( opts = vim.tbl_deep_extend("force", vc_config.get_user_config().async_opts, opts or {}) - if - not start_server(opts.project_root or vim.api.nvim_buf_get_name(bufnr), false) - then - -- failed to start the server - return false - end assert(client_id ~= nil) if CACHE[bufnr] ~= nil then diff --git a/lua/vectorcode/config.lua b/lua/vectorcode/config.lua index 7f21cdf1..cce0a5c9 100644 --- a/lua/vectorcode/config.lua +++ b/lua/vectorcode/config.lua @@ -55,10 +55,9 @@ local startup_handler = check_cli_wrap(function(configs) end) end if configs.on_setup.lsp then - local lsp_module = require("vectorcode.jobrunner.lsp") - if type(lsp_module) == "table" then - -- this will trigger the private `get_client` function in the runner and hence start the LSP - lsp_module.is_job_running(0) + local ok, _ = pcall(vim.lsp.enable, "vectorcode_server", true) + if not ok then + vim.notify("Failed to start vectorcode-server.", vim.log.levels.WARN, notify_opts) end end end) diff --git a/lua/vectorcode/jobrunner/lsp.lua b/lua/vectorcode/jobrunner/lsp.lua index 3b073663..6a1cb905 100644 --- a/lua/vectorcode/jobrunner/lsp.lua +++ b/lua/vectorcode/jobrunner/lsp.lua @@ -17,46 +17,21 @@ local notify_opts = vc_config.notify_opts ---@param ok_to_fail boolean local function get_client(ok_to_fail) ok_to_fail = ok_to_fail or true + vim.lsp.enable({ "vectorcode_server" }, true) if #vim.lsp.get_clients({ name = "vectorcode_server" }) > 0 then + -- server started CLIENT = vim.lsp.get_clients({ name = "vectorcode_server" })[1] else - local cmd = { "vectorcode-server" } - - local try_root = vim.fs.root(".", ".vectorcode") or vim.fs.root(".", ".git") - if try_root ~= nil then - vim.list_extend(cmd, { "--project_root", try_root }) - else - vim.schedule(function() - vim.notify( - "Failed to start vectorcode-server due to failing to resolve the project root.", - vim.log.levels.ERROR, - notify_opts - ) - end) - return false - end - local id, err = vim.lsp.start_client({ - name = "vectorcode_server", - cmd = cmd, - }) - - if err ~= nil and (vc_config.get_user_config().notify or not ok_to_fail) then + -- failed to start server + if vc_config.get_user_config().notify or not ok_to_fail then vim.schedule(function() vim.notify( - ("Failed to start vectorcode-server due to the following error:\n%s"):format( - err - ), + "Failed to start vectorcode-server due to the following error.", vim.log.levels.ERROR, notify_opts ) end) return false - elseif id ~= nil then - local cli = vim.lsp.get_client_by_id(id) - if cli ~= nil then - CLIENT = cli - return true - end end end end From 175fa39b78daba240085892aaecc05c2fbf5734d Mon Sep 17 00:00:00 2001 From: Davidyz Date: Thu, 27 Mar 2025 17:05:14 +0000 Subject: [PATCH 2/6] refactor(nvim)!: use the nvim 0.11.0 API to configure and start LSP --- lua/lsp/vectorcode_server.lua | 1 - lua/vectorcode/cacher/lsp.lua | 10 +++------- lua/vectorcode/config.lua | 2 +- lua/vectorcode/jobrunner/init.lua | 1 + lua/vectorcode/jobrunner/lsp.lua | 32 +++++++++++++++++++------------ 5 files changed, 25 insertions(+), 21 deletions(-) delete mode 100644 lua/lsp/vectorcode_server.lua diff --git a/lua/lsp/vectorcode_server.lua b/lua/lsp/vectorcode_server.lua deleted file mode 100644 index c9359e74..00000000 --- a/lua/lsp/vectorcode_server.lua +++ /dev/null @@ -1 +0,0 @@ -return { cmd = { "vectorcode-server" }, root_markers = { ".vectorcode", ".git" } } diff --git a/lua/vectorcode/cacher/lsp.lua b/lua/vectorcode/cacher/lsp.lua index ca8c2039..059bcd61 100644 --- a/lua/vectorcode/cacher/lsp.lua +++ b/lua/vectorcode/cacher/lsp.lua @@ -35,12 +35,8 @@ end ---@return boolean local function is_lsp_running() - local clients = vim.lsp.get_clients({ name = "vectorcode_server" }) - if #clients == 0 then - return false - end - client_id = clients[1].id - return true + client_id = job_runner.init() + return client_id ~= nil end ---@type table @@ -169,7 +165,7 @@ M.register_buffer = vc_config.check_cli_wrap( opts = vim.tbl_deep_extend("force", vc_config.get_user_config().async_opts, opts or {}) - assert(client_id ~= nil) + assert(is_lsp_running()) if CACHE[bufnr] ~= nil then -- update the options and/or query_cb diff --git a/lua/vectorcode/config.lua b/lua/vectorcode/config.lua index cce0a5c9..c07d40b3 100644 --- a/lua/vectorcode/config.lua +++ b/lua/vectorcode/config.lua @@ -55,7 +55,7 @@ local startup_handler = check_cli_wrap(function(configs) end) end if configs.on_setup.lsp then - local ok, _ = pcall(vim.lsp.enable, "vectorcode_server", true) + local ok, _ = pcall(vim.lsp.start, vim.lsp.config.vectorcode_server) if not ok then vim.notify("Failed to start vectorcode-server.", vim.log.levels.WARN, notify_opts) end diff --git a/lua/vectorcode/jobrunner/init.lua b/lua/vectorcode/jobrunner/init.lua index f2a9245c..f13a436e 100644 --- a/lua/vectorcode/jobrunner/init.lua +++ b/lua/vectorcode/jobrunner/init.lua @@ -7,6 +7,7 @@ local utils = require("vectorcode.utils") ---@field run fun(args: string[], timeout_ms: integer?, bufnr: integer):(result:table, error:table) ---@field is_job_running fun(job_handle: integer):boolean ---@field stop_job fun(job_handle: integer) +---@field init function? return { --- Automatically find project_root from buffer path if it's not already specified. diff --git a/lua/vectorcode/jobrunner/lsp.lua b/lua/vectorcode/jobrunner/lsp.lua index 6a1cb905..d8e8d4ff 100644 --- a/lua/vectorcode/jobrunner/lsp.lua +++ b/lua/vectorcode/jobrunner/lsp.lua @@ -5,6 +5,11 @@ then return nil end +vim.lsp.config( + "vectorcode_server", + { cmd = { "vectorcode-server" }, root_markers = { ".vectorcode", ".git" } } +) + ---@type VectorCode.JobRunner local jobrunner = {} @@ -14,30 +19,33 @@ local CLIENT = nil local vc_config = require("vectorcode.config") local notify_opts = vc_config.notify_opts +--- Returns the Client ID if applicable, or `nil` if the language server fails to start ---@param ok_to_fail boolean -local function get_client(ok_to_fail) +---@return integer? +function jobrunner.init(ok_to_fail) ok_to_fail = ok_to_fail or true - vim.lsp.enable({ "vectorcode_server" }, true) - if #vim.lsp.get_clients({ name = "vectorcode_server" }) > 0 then + local client_id = vim.lsp.start(vim.lsp.config.vectorcode_server, {}) + if client_id ~= nil then -- server started - CLIENT = vim.lsp.get_clients({ name = "vectorcode_server" })[1] + CLIENT = vim.lsp.get_client_by_id(client_id) --[[@as vim.lsp.Client]] else -- failed to start server if vc_config.get_user_config().notify or not ok_to_fail then vim.schedule(function() vim.notify( - "Failed to start vectorcode-server due to the following error.", + "Failed to start vectorcode-server due some error.", vim.log.levels.ERROR, notify_opts ) end) - return false end + return nil end + return client_id end function jobrunner.run(args, timeout_ms, bufnr) - get_client(false) + jobrunner.init(false) assert(CLIENT ~= nil) assert(bufnr ~= nil) if timeout_ms == nil or timeout_ms < 0 then @@ -60,7 +68,7 @@ function jobrunner.run(args, timeout_ms, bufnr) end function jobrunner.run_async(args, callback, bufnr) - get_client(false) + jobrunner.init(false) assert(CLIENT ~= nil) assert(bufnr ~= nil) @@ -81,7 +89,7 @@ function jobrunner.run_async(args, callback, bufnr) end end args = require("vectorcode.jobrunner").find_root(args, bufnr) - local _, id = CLIENT.request( + local _, id = CLIENT:request( vim.lsp.protocol.Methods.workspace_executeCommand, { command = "vectorcode", arguments = args }, function(err, result, _, _) @@ -99,7 +107,7 @@ function jobrunner.run_async(args, callback, bufnr) end function jobrunner.is_job_running(job_handler) - get_client(true) + jobrunner.init(true) if CLIENT ~= nil then local request_data = CLIENT.requests[job_handler] return request_data ~= nil and request_data.type == "pending" @@ -108,9 +116,9 @@ function jobrunner.is_job_running(job_handler) end function jobrunner.stop_job(job_handler) - get_client(true) + jobrunner.init(true) if CLIENT ~= nil then - CLIENT.cancel_request(job_handler) + CLIENT:cancel_request(job_handler) end end From c4b8bba9bc6f1e59431ccc0fbb13af2c2e93bc03 Mon Sep 17 00:00:00 2001 From: Davidyz Date: Thu, 27 Mar 2025 17:38:35 +0000 Subject: [PATCH 3/6] refactor(nvim): move `vim.lsp.config` to `config.lua` --- lua/vectorcode/config.lua | 6 ++++++ lua/vectorcode/jobrunner/lsp.lua | 5 ----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lua/vectorcode/config.lua b/lua/vectorcode/config.lua index c07d40b3..66790355 100644 --- a/lua/vectorcode/config.lua +++ b/lua/vectorcode/config.lua @@ -18,6 +18,12 @@ local config = { on_setup = { update = false, lsp = false }, } +vim.lsp.config.vectorcode_server = vim.tbl_deep_extend( + "force", + { cmd = { "vectorcode-server" }, root_markers = { ".vectorcode", ".git" } }, + vim.lsp.config.vectorcode_server or {} +) + local setup_config = vim.deepcopy(config, true) local notify_opts = { title = "VectorCode" } diff --git a/lua/vectorcode/jobrunner/lsp.lua b/lua/vectorcode/jobrunner/lsp.lua index d8e8d4ff..164dcc05 100644 --- a/lua/vectorcode/jobrunner/lsp.lua +++ b/lua/vectorcode/jobrunner/lsp.lua @@ -5,11 +5,6 @@ then return nil end -vim.lsp.config( - "vectorcode_server", - { cmd = { "vectorcode-server" }, root_markers = { ".vectorcode", ".git" } } -) - ---@type VectorCode.JobRunner local jobrunner = {} From d68800a5566d546ad9be6b3ff240f2887f5c4fc8 Mon Sep 17 00:00:00 2001 From: Davidyz Date: Thu, 27 Mar 2025 20:39:33 +0000 Subject: [PATCH 4/6] feat(nvim): fallback to `nvim-lspconfig` when `vim.lsp.config` is not available. --- lua/vectorcode/config.lua | 23 +++++++++++++++++------ lua/vectorcode/jobrunner/lsp.lua | 2 +- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/lua/vectorcode/config.lua b/lua/vectorcode/config.lua index 66790355..4db32f08 100644 --- a/lua/vectorcode/config.lua +++ b/lua/vectorcode/config.lua @@ -18,11 +18,20 @@ local config = { on_setup = { update = false, lsp = false }, } -vim.lsp.config.vectorcode_server = vim.tbl_deep_extend( - "force", - { cmd = { "vectorcode-server" }, root_markers = { ".vectorcode", ".git" } }, - vim.lsp.config.vectorcode_server or {} -) +---@type vim.lsp.ClientConfig +local lsp_configs = + { cmd = { "vectorcode-server" }, root_markers = { ".vectorcode", ".git" } } +if vim.lsp.config ~= nil then + -- nvim >= 0.11.0 + lsp_configs = + vim.tbl_deep_extend("force", lsp_configs, vim.lsp.config.vectorcode_server or {}) +else + -- nvim < 0.11.0 + local ok, lspconfig = pcall(require, "lspconfig.configs") + if ok and lspconfig.vectorcode_server ~= nil then + lsp_configs = lspconfig.vectorcode_server.config_def.default_config + end +end local setup_config = vim.deepcopy(config, true) local notify_opts = { title = "VectorCode" } @@ -61,7 +70,7 @@ local startup_handler = check_cli_wrap(function(configs) end) end if configs.on_setup.lsp then - local ok, _ = pcall(vim.lsp.start, vim.lsp.config.vectorcode_server) + local ok, _ = pcall(vim.lsp.start, lsp_configs) if not ok then vim.notify("Failed to start vectorcode-server.", vim.log.levels.WARN, notify_opts) end @@ -140,4 +149,6 @@ return { has_cli = has_cli, check_cli_wrap = check_cli_wrap, + ---@type vim.lsp.ClientConfig + lsp_configs = lsp_configs, } diff --git a/lua/vectorcode/jobrunner/lsp.lua b/lua/vectorcode/jobrunner/lsp.lua index 164dcc05..1c37b98a 100644 --- a/lua/vectorcode/jobrunner/lsp.lua +++ b/lua/vectorcode/jobrunner/lsp.lua @@ -19,7 +19,7 @@ local notify_opts = vc_config.notify_opts ---@return integer? function jobrunner.init(ok_to_fail) ok_to_fail = ok_to_fail or true - local client_id = vim.lsp.start(vim.lsp.config.vectorcode_server, {}) + local client_id = vim.lsp.start(vc_config.lsp_configs, {}) if client_id ~= nil then -- server started CLIENT = vim.lsp.get_client_by_id(client_id) --[[@as vim.lsp.Client]] From 1f91889945c326e605cfe324e4ca6f630a970e7b Mon Sep 17 00:00:00 2001 From: Davidyz Date: Fri, 28 Mar 2025 09:50:29 +0000 Subject: [PATCH 5/6] fix(nvim): wrap lsp config loading in a function and call it from only one place. --- lua/vectorcode/config.lua | 34 ++++++++++++++++++-------------- lua/vectorcode/jobrunner/lsp.lua | 2 +- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/lua/vectorcode/config.lua b/lua/vectorcode/config.lua index 4db32f08..8493f513 100644 --- a/lua/vectorcode/config.lua +++ b/lua/vectorcode/config.lua @@ -18,19 +18,21 @@ local config = { on_setup = { update = false, lsp = false }, } ----@type vim.lsp.ClientConfig -local lsp_configs = - { cmd = { "vectorcode-server" }, root_markers = { ".vectorcode", ".git" } } -if vim.lsp.config ~= nil then - -- nvim >= 0.11.0 - lsp_configs = - vim.tbl_deep_extend("force", lsp_configs, vim.lsp.config.vectorcode_server or {}) -else - -- nvim < 0.11.0 - local ok, lspconfig = pcall(require, "lspconfig.configs") - if ok and lspconfig.vectorcode_server ~= nil then - lsp_configs = lspconfig.vectorcode_server.config_def.default_config +---@return vim.lsp.ClientConfig +local lsp_configs = function() + local cfg = + { cmd = { "vectorcode-server" }, root_markers = { ".vectorcode", ".git" } } + if vim.lsp.config ~= nil then + -- nvim >= 0.11.0 + cfg = vim.tbl_deep_extend("force", cfg, vim.lsp.config.vectorcode_server or {}) + else + -- nvim < 0.11.0 + local ok, lspconfig = pcall(require, "lspconfig.configs") + if ok and lspconfig.vectorcode_server ~= nil then + cfg = lspconfig.vectorcode_server.config_def.default_config + end end + return cfg end local setup_config = vim.deepcopy(config, true) @@ -70,10 +72,12 @@ local startup_handler = check_cli_wrap(function(configs) end) end if configs.on_setup.lsp then - local ok, _ = pcall(vim.lsp.start, lsp_configs) - if not ok then + local ok, runner = pcall(require, "vectorcode.jobrunner.lsp") + if not ok or not type(runner) == "table" or runner == nil then vim.notify("Failed to start vectorcode-server.", vim.log.levels.WARN, notify_opts) + return end + runner.init() end end) @@ -149,6 +153,6 @@ return { has_cli = has_cli, check_cli_wrap = check_cli_wrap, - ---@type vim.lsp.ClientConfig + lsp_configs = lsp_configs, } diff --git a/lua/vectorcode/jobrunner/lsp.lua b/lua/vectorcode/jobrunner/lsp.lua index 1c37b98a..0c526039 100644 --- a/lua/vectorcode/jobrunner/lsp.lua +++ b/lua/vectorcode/jobrunner/lsp.lua @@ -19,7 +19,7 @@ local notify_opts = vc_config.notify_opts ---@return integer? function jobrunner.init(ok_to_fail) ok_to_fail = ok_to_fail or true - local client_id = vim.lsp.start(vc_config.lsp_configs, {}) + local client_id = vim.lsp.start(vc_config.lsp_configs(), {}) if client_id ~= nil then -- server started CLIENT = vim.lsp.get_client_by_id(client_id) --[[@as vim.lsp.Client]] From fb89399fd1259bb48d171f7e6d29113cc1f4943b Mon Sep 17 00:00:00 2001 From: Davidyz Date: Fri, 28 Mar 2025 15:34:31 +0000 Subject: [PATCH 6/6] feat(nvim): allow using nvim-lspconfig on nvim 0.11+ --- doc/VectorCode.txt | 12 +++++++++--- docs/neovim.md | 10 ++++++++-- lua/vectorcode/config.lua | 4 ++-- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/doc/VectorCode.txt b/doc/VectorCode.txt index 580265d1..a152bddc 100644 --- a/doc/VectorCode.txt +++ b/doc/VectorCode.txt @@ -1,4 +1,4 @@ -*VectorCode.txt* For Last change: 2025 March 27 +*VectorCode.txt* For Last change: 2025 March 28 ============================================================================== Table of Contents *VectorCode-table-of-contents* @@ -194,7 +194,7 @@ registered to run when `setup` is called. Supported keys: - `update`: if `true`, the plugin will run `vectorcode update` on startup to update the embeddings; - `lsp`: if `true`, the plugin will try to start the LSP server on startup so that you won’t need to wait for the server loading when making -your first request. _Requires neovim 0.11.0+._ +your first request. You may notice that a lot of options in `async_opts` are the same as the other options in the top-level of the main option table. This is because the @@ -324,7 +324,13 @@ interface: 1. The `default` backend which works exactly like the original implementation used in previous versions; 2. The `lsp` based backend, which make use of the experimental `vectorcode-server` -implemented in version 0.4.0. _Requires neovim 0.11.0+._ +implemented in version 0.4.0. If you want to customise the LSP executable or +any options supported by `vim.lsp.ClientConfig`, you can do so by using +`vim.lsp.config()` or +nvim-lspconfig . The LSP will +attempt to read configurations from these 2 sources before it starts. (If +`vim.lsp.config.vectorcode_server` is not `nil`, this will be used and +nvim-lspconfig will be ignored.) ------------------------------------------------------------------------------- Features default lsp diff --git a/docs/neovim.md b/docs/neovim.md index 1bc98771..40922d50 100644 --- a/docs/neovim.md +++ b/docs/neovim.md @@ -177,7 +177,7 @@ The following are the available options for the parameter of this function: update the embeddings; - `lsp`: if `true`, the plugin will try to start the LSP server on startup so that you won't need to wait for the server loading when making your first - request. _Requires neovim 0.11.0+._ + request. You may notice that a lot of options in `async_opts` are the same as the other options in the top-level of the main option table. This is because the top-level @@ -293,7 +293,13 @@ interface: 1. The `default` backend which works exactly like the original implementation used in previous versions; 2. The `lsp` based backend, which make use of the experimental `vectorcode-server` - implemented in version 0.4.0. _Requires neovim 0.11.0+._ + implemented in version 0.4.0. If you want to customise the LSP executable or + any options supported by `vim.lsp.ClientConfig`, you can do so by using + `vim.lsp.config()` or + [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig). The LSP will + attempt to read configurations from these 2 sources before it starts. (If + `vim.lsp.config.vectorcode_server` is not `nil`, this will be used and + nvim-lspconfig will be ignored.) | Features | `default` | `lsp` | diff --git a/lua/vectorcode/config.lua b/lua/vectorcode/config.lua index 8493f513..8cb60916 100644 --- a/lua/vectorcode/config.lua +++ b/lua/vectorcode/config.lua @@ -22,9 +22,9 @@ local config = { local lsp_configs = function() local cfg = { cmd = { "vectorcode-server" }, root_markers = { ".vectorcode", ".git" } } - if vim.lsp.config ~= nil then + if vim.lsp.config ~= nil and vim.lsp.config.vectorcode_server ~= nil then -- nvim >= 0.11.0 - cfg = vim.tbl_deep_extend("force", cfg, vim.lsp.config.vectorcode_server or {}) + cfg = vim.tbl_deep_extend("force", cfg, vim.lsp.config.vectorcode_server) else -- nvim < 0.11.0 local ok, lspconfig = pcall(require, "lspconfig.configs")