Just started this journey.
In a VSCode setup, besides having "ZLS for VSCode" extension installed, is there any option to have also formatting and syntax hightlighting, please?
Thanks.
Apparently it doesn't in my case.
And the only setting that I have it the (full) path to zls, as required.
Thanks for the quick feedback, Alex!
I'll see if I can find the root cause of it.
@dxps ah gotcha. Maybe try going through the zls config setup. Also it may be necessary match your zls with your zig version. For example I am running zig 0.9.1 and zls 0.9.0.
@dxps
I should add, don't forget to do zls config and go through the setup options.
$ zls config
Welcome to the ZLS configuration wizard!
*
|\
/* \
| *\
_/_*___|_ x
| @ @ /
@ \ /
\__-/ /
? Should this configuration be system-wide? (y/n) > n
Found zig executable '/usr/local/bin/zig' in PATH.
? Which code editor do you use? (select one)
- VSCode
- Sublime
- Kate
- Neovim
- Vim8
- Emacs
- Doom
- Other
> VSCode
? Do you want to enable snippets? (y/n) > y
? Do you want to enable style warnings? (y/n) > y
? Do you want to enable semantic highlighting? (y/n) > y
? Do you want to enable .* and .? completions? (y/n) > y
Writing config to /Users/alex/Library/Application Support/zls.json ... successful.
To use ZLS in Visual Studio Code, install the 'ZLS for VSCode' extension from
'https://github.com/zigtools/zls-vscode/releases' or via the extensions menu.
Then, open VSCode's 'settings.json' file, and add:
"zigLanguageClient.path": "[command_or_path_to_zls]"
Thank you for choosing ZLS!
Yeah, found it and just did that.
Reloaded and restarted VSCode. Now, there seems to be some syntax highlighting (just on brackets), but no formatting on save.
@dxps If you run the Format Document command in VSCode it should run zig fmt behind the scenes. Then you can toggle on the general VSCode preference: Editor: Format On Save.
Just found out that in the ZLS output ("output" vscode pane), whenever I do save it throws a "need to run as root or suid".
Gotta go to sleep, it's late here, i'll solve it tomorrow.
Just noticed: the amazing
zls
now supports both formatting and syntax hi-lighting!Just started this journey.
In a VSCode setup, besides having "ZLS for VSCode" extension installed, is there any option to have also formatting and syntax hightlighting, please?
Thanks.
@dxps
zls
actually does all that already for VSCode! github.com/zigtools/zls#featuresApparently it doesn't in my case.
And the only setting that I have it the (full) path to
zls
, as required.Thanks for the quick feedback, Alex!
I'll see if I can find the root cause of it.
@dxps ah gotcha. Maybe try going through the
zls config
setup. Also it may be necessary match your zls with your zig version. For example I am running zig 0.9.1 and zls 0.9.0.@dxps
I should add, don't forget to do
zls config
and go through the setup options.Yeah, found it and just did that.
Reloaded and restarted VSCode. Now, there seems to be some syntax highlighting (just on brackets), but no formatting on save.
@dxps If you run the Format Document command in VSCode it should run
zig fmt
behind the scenes. Then you can toggle on the general VSCode preference: Editor: Format On Save.Just found out that in the ZLS output ("output" vscode pane), whenever I do save it throws a "need to run as root or suid".
Gotta go to sleep, it's late here, i'll solve it tomorrow.
Thanks again for the help! Really appreciate it!
Oh wow: i have never seen that error. Cheers I'm sure you'll get it sorted.
Issue solved.
I had to do
chmod a+x {path/to}/zls
(instead of just
chmod +x ...
).