From 48364fb8f01600ced41a39b745b0ffe8c6a4ff09 Mon Sep 17 00:00:00 2001 From: abeldekat Date: Tue, 5 Mar 2024 14:37:02 +0100 Subject: docs(lua_ls): change suggested setup --- lua/lspconfig/server_configurations/lua_ls.lua | 51 +++++++++++++------------- 1 file changed, 26 insertions(+), 25 deletions(-) (limited to 'lua/lspconfig/server_configurations/lua_ls.lua') diff --git a/lua/lspconfig/server_configurations/lua_ls.lua b/lua/lspconfig/server_configurations/lua_ls.lua index f730d713..3bb9fd6a 100644 --- a/lua/lspconfig/server_configurations/lua_ls.lua +++ b/lua/lspconfig/server_configurations/lua_ls.lua @@ -46,32 +46,33 @@ settings. require'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 = { - -- 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. - -- E.g.: For using `vim.*` functions, add vim.env.VIMRUNTIME/lua. - -- "${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) - } - } - }) + if vim.loop.fs_stat(path..'/.luarc.json') or vim.loop.fs_stat(path..'/.luarc.jsonc') then + return end - return true - 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 = {} + } } ``` -- cgit v1.2.3-70-g09d2