command 'zig.zls.startRestart' not found
Hi, I have a fresh installation of zig on my mac 0.11.0, and installed zls through the vscode market place v0.4.3.
The documentation says that it should work out of the box, but any zls command I try to trigger such as start server results in an error.
I have zig installed I have zls installed I have the zig language extension installed.
Documentation says everything should work out of the box but it does not. Either documentation with the correct steps need to be written, or there is a bug.
Same
Do you have zig.zigPath, zig.zls.path and zig.zls.enabled set? Are you seeing any output from "Zig Language Server"?
There are two concerns here:
- Lack of automation. This extension requires manual steps to get it working. It would be nice if the extension would just work out of the box, if practical
- Lack of documentation. If an extension requires manual configuration before it is useful, the bare minimum steps need to be documented somewhere obvious. I've raised this issue here https://github.com/ziglang/vscode-zig/issues/142.
Automation requires some careful thought. What are the sane defaults?
- Should zig or zls be installed automatically?
- Should the extension find zig or zls in PATH and use those?
- Should zig and zls be treated differently? (How does zls interoperate with various zig versions?)
Setup only requires answering two questions: (after #138 at least)
- what
zigto use- install zig
- select path to zig
- use zig in
PATH
- what
zlsto use- do not use zls
- install zls
- select path to zls
- use zls in
PATH
Everything else is automatic.
A new version of the extension has been published, please try running through the setup with it.
Got into the same problem today with v0.5.2. Is this a regression?
Nobody actually confirmed if this was fixed so I don't know. Could you give details on your installation process and setup?
I am running on a mac but I am using flake to install all the dependencies.
VSCode terminal recognizes the zls and zig
Starting zls manually and VSCode seems to be able to connect to it directly(go to definition...)
I wonder if there is an error somewhere that stops the commands from being registered
The only reasonable way it wouldn't get registered is the initial setup failing; do you have zig.initialSetupDone set in your global config?
I checked mine and it is not set.
Hm, I recently starts to manage the settings with home-manager(nix) which would make the global settings readonly. Does the plugin set the option and use that as an indicator to register command?
I also tried to set the same option in workspace settings to true but that would not work
I wasn't able to reproduce your issues by setting the settings readonly and changing the workspace settings should have the same effect as global settings. Are you getting a modal asking you to select which zig to use? Is there anything logged in the Output view under zig?
Can you try if 0.5.3 fixed this for you?
I think the main problem is documentation.
It's unclear from the docs or setup that these settings need to be set:
- zig.initialSetupDone
- zig.path
- zig.zls.path
Sorry for the delay in reponse. A couple of busy days at work. Will check it later today and report back
I think the main problem is documentation.
It's unclear from the docs or setup that these settings need to be set:
They need to be set but the extension sets them for you.
@Vexu
Can you try if 0.5.3 fixed this for you?
I am on the 0.5.3 branch and unfortunately this does not work.
Are you getting a modal asking you to select which zig to use? There used to be a modal until I set zig path inside my workspace settings:
"zig.path": "/nix/store/0qglrgn4flkqdavxkw4snvr3zn5496y7-zig-0.12.0-dev.2327+b0c8a3f31/bin/zig",
"zig.zls.path": "/nix/store/q9f3k6djhc6nfyj63249nda1qk5v4zkg-zls/bin/zls",
"zig.formattingProvider": "zls",
"zig.initialSetupDone": true,
"zig.zls.checkForUpdate": false
There was a modal that pop-up every time I open VSCode about error writing to readonly file. I double checked if this is caused by the extension by disable the extension and it would stop
Maybe the extension crashes after failing to set the settings? Would it be possible for the extension to set the workspace settings instead or use an alternative method to store init state?
There are also no zig output:
By "0.5.3 branch" you mean the extension reports version 0.5.3? Can you try setting zig.checkForUpdates to false? It's the only other setting I can think of that it could be trying to set.
oh sorry i meant extension version 0.5.3 and not the branch.
I set the workspace extensions to
{
"editor.formatOnSave": true,
"files.autoSave": "onFocusChange",
"zig.path": "/nix/store/0qglrgn4flkqdavxkw4snvr3zn5496y7-zig-0.12.0-dev.2327+b0c8a3f31/bin/zig",
"zig.zls.path": "/nix/store/q9f3k6djhc6nfyj63249nda1qk5v4zkg-zls/bin/zls",
"zig.checkForUpdate": false,
"zig.formattingProvider": "zls",
"zig.initialSetupDone": true,
"zig.zls.checkForUpdate": false
}
The extension still try to write to the global settings but it seems like zls starts correctly and I can run "Start/Restart server" now
I think the main problem is documentation.
It's unclear from the docs or setup that these settings need to be set:
* zig.initialSetupDone * zig.path * zig.zls.path
I agree, which is why I created #142. Unfortunately, this was closed without any documentation being added. I would have been happy to open a pr to address this if I thought the maintainers would be receptive to it.
I think the maintainers have a philosophy about software development that UX alone should be good enough to make documentation unnecessary. I agree that this is a good goal that we should all pursue. But it is not realistic to assume that it can always be reached 100%, especially when the software is just a plugin with UX that is tightly constrained by another application.
I occasionally set up new vscode instances with this extension and in my experience, these settings often do not get configured. I dealt with this as recently as last week. There are supposed to be prompts to ensure these are configured, but I don't think this approach is very reliable.
I already know that they need to be set, so I manually go into the config file and edit the values when necessary. For new users who don't have this knowledge yet, it could be useful to have a simple explanation to help them troubleshoot when these values are not set correctly, so they don't need to go through github issues to figure it out. It would also be useful for anyone who needs to make changes to their zig tooling after the initial setup of this extension.
I don't want users to have to read documentation to use the basic funcionalities of the extension and I think the initial setup is now good enough to accomplish that. If you make a PR that adds some documentation describing the key configuration values and some troubleshooting tips then I'll gladly merge it.