cleanup lsp for lua

This commit is contained in:
Adithya 2024-03-10 09:50:49 +05:30
parent d01c5d2812
commit c9832c51f1
Signed by: adtya
GPG key ID: 48FC9915FFD326D0

View file

@ -38,9 +38,11 @@ lspconfig.lua_ls.setup({
capabilities = lsp_capabilities, capabilities = lsp_capabilities,
on_init = function(client) on_init = function(client)
local path = client.workspace_folders[1].name local path = client.workspace_folders[1].name
if not vim.loop.fs_stat(path .. "/.luarc.json") and not vim.loop.fs_stat(path .. "/.luarc.jsonc") then if vim.loop.fs_stat(path .. "/.luarc.json") and not vim.loop.fs_stat(path .. "/.luarc.jsonc") then
client.config.settings = vim.tbl_deep_extend("force", client.config.settings, { return
Lua = { end
client.config.settings.Lua = vim.tbl_deep_extend("force", client.config.settings.Lua, {
runtime = { runtime = {
version = "LuaJIT", version = "LuaJIT",
}, },
@ -50,12 +52,11 @@ lspconfig.lua_ls.setup({
vim.env.VIMRUNTIME, vim.env.VIMRUNTIME,
}, },
}, },
},
}) })
client.notify("workspace/didChangeConfiguration", { settings = client.config.settings })
end
return true
end, end,
settings = {
Lua = {},
},
}) })
lspconfig.nil_ls.setup({ lspconfig.nil_ls.setup({
@ -89,3 +90,6 @@ vim.api.nvim_create_autocmd("LspAttach", {
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts) vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
end, end,
}) })
-- refer https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md