Update nvim-lspconfig for its newest version

This commit is contained in:
leafee98 2026-01-02 15:51:08 +08:00
parent 06ff82f719
commit b19c1aa538

View file

@ -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", "<leader>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
}