From b685e528aff30d35244995b19cdb586c67f410e0 Mon Sep 17 00:00:00 2001 From: Ruslan Date: Thu, 25 Jul 2024 12:56:11 +0300 Subject: [PATCH] add neovim config to lua-lsp --- lua/crentist/lazy/lsp.lua | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/lua/crentist/lazy/lsp.lua b/lua/crentist/lazy/lsp.lua index 9658311..e4fe4fa 100644 --- a/lua/crentist/lazy/lsp.lua +++ b/lua/crentist/lazy/lsp.lua @@ -105,5 +105,38 @@ return { } } lspconfig.ansiblels.setup {} + + lspconfig.lua_ls.setup { + on_init = function(client) + local path = client.workspace_folders[1].name + if vim.loop.fs_stat(path .. '/.luarc.json') or vim.loop.fs_stat(path .. '/.luarc.jsonc') then + return + end + + client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, { + runtime = { + -- Tell the language server which version of Lua you're using + -- (most likely LuaJIT in the case of Neovim) + version = 'LuaJIT' + }, + -- Make the server aware of Neovim runtime files + workspace = { + checkThirdParty = false, + library = { + vim.env.VIMRUNTIME + -- Depending on the usage, you might want to add additional paths here. + -- "${3rd}/luv/library" + -- "${3rd}/busted/library", + } + -- or pull in all of 'runtimepath'. NOTE: this is a lot slower + -- library = vim.api.nvim_get_runtime_file("", true) + } + }) + end, + settings = { + Lua = {} + } + } end } +