Skip to content

Commit

Permalink
fix(zls): include build.zig in root dir search
Browse files Browse the repository at this point in the history
File `build.zig` by convention sits at the root dir and thus can be used
to correctly identify the root directory.

This is particularly useful if `zls` has `enable_build_on_save` set to
`true`, since then the language server uses workspace path (root_dir) to
execute `zig build` command, output of which is then used to publish
diagnostic errors.

Without `build.zig` root directory can incorrectly be deduced some
layers too high at the root of the git repo. In such case
`enable_build_on_save` silently fails and does not report build error
diagnostics.
  • Loading branch information
lawrence-laz committed Dec 18, 2023
1 parent e50a8fc commit cc4fdfe
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lua/lspconfig/server_configurations/zls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ return {
default_config = {
cmd = { 'zls' },
filetypes = { 'zig', 'zir' },
root_dir = util.root_pattern('zls.json', '.git'),
root_dir = util.root_pattern('zls.json', 'build.zig', '.git'),
single_file_support = true,
},
docs = {
Expand All @@ -14,7 +14,7 @@ https://github.com/zigtools/zls
Zig LSP implementation + Zig Language Server
]],
default_config = {
root_dir = [[util.root_pattern("zls.json", ".git")]],
root_dir = [[util.root_pattern("zls.json", "build.zig", ".git")]],
},
},
}

0 comments on commit cc4fdfe

Please sign in to comment.