From 09e396ede222b8accc0798073734047e823c13a5 Mon Sep 17 00:00:00 2001 From: Adithya Nair Date: Sun, 11 Feb 2024 14:02:09 +0530 Subject: [PATCH] setup lsp for lua --- after/plugin/lsp.lua | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 after/plugin/lsp.lua diff --git a/after/plugin/lsp.lua b/after/plugin/lsp.lua new file mode 100644 index 0000000..7a95e35 --- /dev/null +++ b/after/plugin/lsp.lua @@ -0,0 +1,25 @@ +local lspconfig = require("lspconfig") + +lspconfig.lua_ls.setup({ + on_init = function(client) + 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 + client.config.settings = vim.tbl_deep_extend("force", client.config.settings, { + Lua = { + runtime = { + version = "LuaJIT", + }, + workspace = { + checkThirdParty = false, + library = { + vim.env.VIMRUNTIME, + }, + }, + }, + }) + client.notify("workspace/didChangeConfiguration", { settings = client.config.settings }) + end + return true + end, +}) +