aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorLaurynas Lazauskas <8823448+lawrence-laz@users.noreply.github.com>2024-10-02 13:29:13 +0300
committerGitHub <noreply@github.com>2024-10-02 03:29:13 -0700
commit2b5e962cb175def20842b16de3fa1124ee7c614a (patch)
treea14ad0a9cda263d4859b26290990d12890ab9f3d /lua
parentrefactor(docgen): cleanup #3336 (diff)
downloadnvim-lspconfig-2b5e962cb175def20842b16de3fa1124ee7c614a.tar
nvim-lspconfig-2b5e962cb175def20842b16de3fa1124ee7c614a.tar.gz
nvim-lspconfig-2b5e962cb175def20842b16de3fa1124ee7c614a.tar.bz2
nvim-lspconfig-2b5e962cb175def20842b16de3fa1124ee7c614a.tar.lz
nvim-lspconfig-2b5e962cb175def20842b16de3fa1124ee7c614a.tar.xz
nvim-lspconfig-2b5e962cb175def20842b16de3fa1124ee7c614a.tar.zst
nvim-lspconfig-2b5e962cb175def20842b16de3fa1124ee7c614a.zip
fix(zls): use workspace zls.json if available #2944
Language server config is read from `zls.json`. By default common global and user config directories are searched. However, this omits per-project configuration, which can be available in the workspace dir. We already look for `zls.json` to determine root dir, but we don't use it when starting the language server. This change appends `cmd` with `--config-path "zls.json"`, which uses the file when it's available and fall-backs to default logic when file is not available.
Diffstat (limited to 'lua')
-rw-r--r--lua/lspconfig/configs/zls.lua6
1 files changed, 6 insertions, 0 deletions
diff --git a/lua/lspconfig/configs/zls.lua b/lua/lspconfig/configs/zls.lua
index d92a797d..8deeda97 100644
--- a/lua/lspconfig/configs/zls.lua
+++ b/lua/lspconfig/configs/zls.lua
@@ -3,6 +3,11 @@ local util = require 'lspconfig.util'
return {
default_config = {
cmd = { 'zls' },
+ on_new_config = function(new_config, new_root_dir)
+ if vim.fn.filereadable(vim.fs.joinpath(new_root_dir, 'zls.json')) ~= 0 then
+ new_config.cmd = { 'zls', '--config-path', 'zls.json' }
+ end
+ end,
filetypes = { 'zig', 'zir' },
root_dir = util.root_pattern('zls.json', 'build.zig', '.git'),
single_file_support = true,
@@ -14,6 +19,7 @@ https://github.com/zigtools/zls
Zig LSP implementation + Zig Language Server
]],
default_config = {
+ cmd = { 'zls' },
root_dir = [[util.root_pattern("zls.json", "build.zig", ".git")]],
},
},