-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Zig formatting does not work #1364
Comments
With #1269 resolved, I was successfully able to reproduce this issue on master. (Specifically 22b728d) ~/.cache/helix/helix.log
|
I'm seeing this same issue with My custom language config for reference
|
Turns out it's an off-by-one error in the Zig language server. Solved in zigtools/zls#505. Build |
@kevinsjoberg: thanks for the info, this indeed fixes the problem. However I have one minor nit: when I use |
@sudormrfbin: thanks for the tip, I have tried with latest master, but sadly the behavior did not change. Shall I open a separate bug report as this is a different problem now? |
From what I can tell, whole document gets selected after formatting due to the response from ZLS. I compared Rust's LSP formatting output to ZLS's. For both of these, I added some newlines to an empty project generated from Rust LSP format response: Array([
Object({
"newText": String(
"",
),
"range": Object({
"end": Object({
"character": Number(
0,
),
"line": Number(
5,
),
}),
"start": Object({
"character": Number(
0,
),
"line": Number(
1,
),
}),
}),
}),
]) Zig LSP format response: Array([
Object({
"newText": String(
"const std = @import(\"std\");\n\npub fn main() anyerror!void {\n std.log.info(\"Test\", .{});\n}\n",
),
"range": Object({
"end": Object({
"character": Number(
0,
),
"line": Number(
8,
),
}),
"start": Object({
"character": Number(
0,
),
"line": Number(
0,
),
}),
}),
}),
]) I haven't looked into how Helix decides to place the cursor after formatting, but as you can see, ZLS returns the entire file in the I don't really know what Helix should do in this situation. Maybe it should remember the last cursor position and keep it unchanged after formatting, but the cursor could end up in a different spot than it was initially after being formatted |
I've been following this issue for awhile and I'd like to chime in. On helix 22.05 (e4c9d40), with Windows cmd prompt, I can confirm that I don't get the whole file selection after save any more, it's treated like a file reload. |
My pull request to ZLS was just accepted to fix this issue. Helix should no longer be selecting the entire document after a format |
@jefftime: Thank You very much! |
Reproduction steps
PATH
zig fmt
should format it:format
and see nothing happeningEnvironment
zls seems to respond with proper output, but does not picket up by helix
In this example notice the
,
after'!';\n }
which is added by zls, but textDocument/didChange overwrites it right after.The text was updated successfully, but these errors were encountered: