aboutsummaryrefslogtreecommitdiffstats
path: root/lua/lspconfig/server_configurations/lua_ls.lua
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2023-08-08 11:35:15 +0100
committerLewis Russell <me@lewisr.dev>2023-08-08 11:58:07 +0100
commit2071b4e63dadc60125a73bcb7a2d6acf74c289fb (patch)
tree05482fbceb6ddda849e2f6c952922828ed271492 /lua/lspconfig/server_configurations/lua_ls.lua
parentdocs: rename deprecated `resolved_capabilities` -> `server_capabilities` (#2746) (diff)
downloadnvim-lspconfig-2071b4e63dadc60125a73bcb7a2d6acf74c289fb.tar
nvim-lspconfig-2071b4e63dadc60125a73bcb7a2d6acf74c289fb.tar.gz
nvim-lspconfig-2071b4e63dadc60125a73bcb7a2d6acf74c289fb.tar.bz2
nvim-lspconfig-2071b4e63dadc60125a73bcb7a2d6acf74c289fb.tar.lz
nvim-lspconfig-2071b4e63dadc60125a73bcb7a2d6acf74c289fb.tar.xz
nvim-lspconfig-2071b4e63dadc60125a73bcb7a2d6acf74c289fb.tar.zst
nvim-lspconfig-2071b4e63dadc60125a73bcb7a2d6acf74c289fb.zip
feat(lua_ls): update recommended settings
- Only override settings if there is no `.luarc.json(c)` file present. - Prefer setting workspace to `VIMRUNTIME` over `'runtimepath'`
Diffstat (limited to 'lua/lspconfig/server_configurations/lua_ls.lua')
-rw-r--r--lua/lspconfig/server_configurations/lua_ls.lua38
1 files changed, 19 insertions, 19 deletions
diff --git a/lua/lspconfig/server_configurations/lua_ls.lua b/lua/lspconfig/server_configurations/lua_ls.lua
index acb57318..e6a1438e 100644
--- a/lua/lspconfig/server_configurations/lua_ls.lua
+++ b/lua/lspconfig/server_configurations/lua_ls.lua
@@ -49,26 +49,26 @@ Completion results will include a workspace indexing progress message until the
```lua
require'lspconfig'.lua_ls.setup {
- 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 = {
+ 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
+ local 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
- library = vim.api.nvim_get_runtime_file("", true),
- },
- -- Do not send telemetry data containing a randomized but unique identifier
- telemetry = {
- enable = false,
- },
- },
- },
+ workspace = {
+ library = { vim.env.VIMRUNTIME }
+ -- or pull in all of 'runtimepath'. NOTE: this is a lot slower
+ -- library = vim.api.nvim_get_runtime_file("", true)
+ }
+ }
+
+ client.notify("workspace/didChangeConfiguration", { settings = settings })
+ end
+ return true
+ end
}
```