From b19c1aa538db149585dc9fa9336772f33ce6ebc6 Mon Sep 17 00:00:00 2001 From: leafee98 Date: Fri, 2 Jan 2026 15:51:08 +0800 Subject: [PATCH] Update nvim-lspconfig for its newest version --- lua/plugins/50-lsp.lua | 46 +++++++++++++++--------------------------- 1 file changed, 16 insertions(+), 30 deletions(-) diff --git a/lua/plugins/50-lsp.lua b/lua/plugins/50-lsp.lua index d9d6b52..e25c8ef 100644 --- a/lua/plugins/50-lsp.lua +++ b/lua/plugins/50-lsp.lua @@ -1,4 +1,4 @@ -function setup_keymap_lsp() +local function setup_keymap_lsp() -- -- Global mappings. -- -- See `:help vim.diagnostic.*` for documentation on any of the below functions -- vim.keymap.set("n", "e", vim.diagnostic.open_float) @@ -36,29 +36,6 @@ function setup_keymap_lsp() }) end -local lua_ls_opts = { - settings = { - Lua = { - runtime = { - -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) - version = "LuaJIT", - }, - diagnostics = { - -- Get the language server to recognize the `vim` global - globals = { "vim" }, - }, - workspace = { - -- Make the server aware of Neovim runtime files - library = vim.api.nvim_get_runtime_file("", true), - }, - -- Do not send telemetry data containing a randomized but unique identifier - telemetry = { - enable = false, - }, - }, - }, -} - return { { "neovim/nvim-lspconfig", @@ -85,13 +62,22 @@ return { mason.setup() mason_lsp.setup() - mason_lsp.setup_handlers { - function (server_name) -- default handler (optional) - require("lspconfig")[server_name].setup {} - end, - ["lua_ls"] = function () - require("lspconfig")["lua_ls"].setup(lua_ls_opts) + vim.lsp.config('lua_ls', { + on_init = function(client) + client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, { + runtime = { + version = "LuaJIT", + }, + diagnostics = { + -- Get the language server to recognize the `vim` global + globals = { "vim" }, + }, + -- Do not send telemetry data containing a randomized but unique identifier + telemetry = { + enable = false, + } + } end }