[Help] Not working with Kate
Hello, I am having troubles making zls work with Kate currently,
For some reason, with the configuration provided in the README.md, Kate does not seem to work with zls whenever I open a Zig file. This is weird because Kate works with rust-analyzer perfectly, but not zls
It also appears as if Zig was added into the "Default server settings" tab in this (which may mean that we don't need to specify it in the User server settings tab anymore).
Hello, I use the following on Windows 10 (20H2) with Kate 21.04.2. I run my kate straight from a zip bundle (kate-21.04.2-1337-windows-msvc2019_64-cl).
in zls.json:
{
"enable_snippets": true,
"warn_style": true,
"enable_semantic_tokens": true,
"operator_completions": true,
"zig_lib_path": "absolute_path_to_zig_lib\\lib",
"zig_exe_path": "absolute_path_to_zig_exe\\zig.exe"
}
and for the LSP client:
{
"servers": {
"zig": {
"command": ["absolute_path_to_zls\\zls.exe"],
"url": "https://github.com/zigtools/zls",
"highlightingModeRegex": "^Zig$"
}
}
}
with the above I get tooltips on function signatures. I can see for a custom lib.

The std lib can be queried as well.

If you can give more details about your system and what is not working maybe someone can help better. Thank you. Good day.
Well, I ended up giving up on Kate because I'm sure I did everything right and it didn't work. Was still kind of a weird issue because it worked with other LSP servers.
Hello, Please consider closing this ticket if you are not going to pursue helping to investigate or resolve it. There is just not enough information that you provided to make this viable to pursue at this point. Thank you. Good day.
are you experiencing a crash in zls or is not starting up at all?
I'm going to close this due to inactivity.
Hi, I don't think this is a bug in zig or zls but wanted to know if anyone has figured out why Kate doesn't work with Zig (it does work with Rust, Dart and D's LSP servers which I tried).
When I open a Zig file, it complains about clangd:
Please check your PATH for the binary
See also https://clang.llvm.org/extra/clangd/ for installation or details 13:36:54 LSP Client Warning Failed to find server binary: clangd
I already installed both zls and clangd and they're on the PATH (Even from the Kate terminal, I can call them and see they're in the PATH).
The default LSP client config for zig seems correct:
"zig": {
"command": ["zls"],
"url": "https://github.com/zigtools/zls",
"highlightingModeRegex": "^Zig$"
}
I had to fix the Dart config as it's plain wrong in the Kate defaults (if any Kate devs are reading, the Dart LSP command is documented here)... and the D config was correct but it couldn't find serve-d so I also had to edit it, but there's nothing I can think of in the Zig config that could be modified.
As I like Kate and Zig, it would be wonderful if this could be fixed... I can try whatever hints you guys may have both on Linux and Mac OS (the same thing happens on both). Let me know if I can try something.
@renatoathaydes, Have you done the first step in this list https://github.com/zigtools/zls/wiki/Installation#kate ?
@nullptrdevs I am not sure that's required (that's a 5-year old repository without updates and by reading the comments on the PR that was not accepted)...
Kate already supports Zig syntax out-of-the-box: https://kate-editor.org/syntax/
The zls server also comes configured by default.
When I start kate from the terminal, it can find "clangd":
20:24:55 LSP Client Log Started server c@/home/renato: /home/renato/.nix-profile/bin/clangd -log=error --background-index --limit-results=500 --completion-style=bundled
I thought it was doing that to support Zig's C interop or something like that, but more likely, Kate comes misconfigured (it's not just my KDE machine, the behaviour is exactly the same on a freshly downloaded Kate on Mac OS) to use clangd when Zig files are opened... I will reach out to Kate devs on IRC.
@renatoathaydes Fair enough, but it's what I had to use a ~year ago
❯ ll ~/.local/share/org.kde.syntax-highlighting/syntax/Zig.xml
-rw-r--r-- 1 npd npd 6.9K Oct 3 2022 /home/npd/.local/share/org.kde.syntax-highlighting/syntax/Zig.xml
My LSP Client -> User Server Settings
{
"servers":
{
"zig":
{
"command": ["/home/npd/lab/zls/npdm/zig-out/bin/zls"],
"url": "https://github.com/zigtools/zls",
"highlightingModeRegex": "^Zig$"
}
}
}
[3:26:50  LSP Client Log] Started server zig@/home/npd: /home/npd/lab/zls/npdm/zig-out/bin/zls
[3:26:50  LSP Server Log] zig@/home/npd
info : ( main ): Starting ZLS 0.12.0-dev.337+e5ede4b @ '/home/npd/lab/zls/npdm/zig-out/bin/zls'
info : (server): set config option 'enable_autofix' to 'true'
info : (server): set config option 'semantic_tokens' to 'Config.Config__enum_4994.none'
info : (server): set config option 'inlay_hints_show_parameter_name' to 'false'
info : (server): set config option 'warn_style' to 'true'
info : (server): set config option 'highlight_global_var_declarations' to 'true'
info : (server): set config option 'skip_std_references' to 'true'
info : (server): set config option 'prefer_ast_check_as_child_process' to 'false'
info : (server): set config option 'builtin_path' to '/home/npd/.cache/zls/builtin.zig'
info : (server): set config option 'zig_lib_path' to '/home/npd/lab/zig/build/stage4/lib/zig'
info : (server): set config option 'zig_exe_path' to '/home/npd/lab/zig/build/stage4/bin/zig'
info : (server): set config option 'build_runner_path' to '/home/npd/.cache/zls/build_runner_master.zig'
info : (server): set config option 'global_cache_path' to '/home/npd/.cache/zls'
info : (server): set config option 'build_runner_global_cache_path' to '/home/npd/.cache/zig'
[3:26:51  LSP Server Log] zig@/home/npd
info : (server): Server.ClientCapabilities{ .supports_snippets = true, .supports_apply_edits = false, .supports_will_save = false, .supports_will_save_wait_until = false, .supports_publish_diagnostics = true, .supports_code_action_fixall = false, .hover_supports_md = true, .completion_doc_supports_md = false, .label_details_support = false, .supports_configuration = false, .supports_workspace_did_change_configuration_dynamic_registration = false, .supports_textDocument_definition_linkSupport = false, .include_at_in_builtins = false, .max_detail_length = 1048576, .workspace_folders = { } }
info : (server): offset encoding: utf-16
[3:26:51  LSP Server Log] zig@/home/npd
debug: (server): Took 6ms to process request-1-initialize on Thread 5330
...
Kate 23.08.4
I've talked with the Kate devs.. the conclusions were:
- I was using an older version of Kate on Linux. Distros can be very slow to update :(
- On Mac OS, Kate doesn't seem to read
/etc/pathsnor the.profileor.zshrcfiles, so I have to either start Kate from the terminal (instead of the Mac launcher) or set the server path to the absolute path.
Up to version 22, Kate looked for clangd when opening Zig files. That was fixed sometime after version 23.
Syntax highlighting for Zig was already available even in Kate 21, at least.