vscode-zig icon indicating copy to clipboard operation
vscode-zig copied to clipboard

command 'zig.zls.startRestart' not found

Open davidmdm opened this issue 2 years ago • 21 comments

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.

image

davidmdm avatar Sep 16 '23 21:09 davidmdm

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.

davidmdm avatar Sep 16 '23 22:09 davidmdm

Same

awarebayes avatar Sep 17 '23 13:09 awarebayes

Do you have zig.zigPath, zig.zls.path and zig.zls.enabled set? Are you seeing any output from "Zig Language Server"?

Vexu avatar Sep 18 '23 10:09 Vexu

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?

  1. Should zig or zls be installed automatically?
  2. Should the extension find zig or zls in PATH and use those?
  3. Should zig and zls be treated differently? (How does zls interoperate with various zig versions?)

dnut avatar Oct 09 '23 18:10 dnut

Setup only requires answering two questions: (after #138 at least)

  • what zig to use
    • install zig
    • select path to zig
    • use zig in PATH
  • what zls to use
    • do not use zls
    • install zls
    • select path to zls
    • use zls in PATH

Everything else is automatic.

Vexu avatar Oct 09 '23 18:10 Vexu

A new version of the extension has been published, please try running through the setup with it.

Vexu avatar Oct 20 '23 13:10 Vexu

Got into the same problem today with v0.5.2. Is this a regression?

dephiros avatar Feb 10 '24 14:02 dephiros

Nobody actually confirmed if this was fixed so I don't know. Could you give details on your installation process and setup?

Vexu avatar Feb 10 '24 17:02 Vexu

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

dephiros avatar Feb 11 '24 12:02 dephiros

The only reasonable way it wouldn't get registered is the initial setup failing; do you have zig.initialSetupDone set in your global config?

Vexu avatar Feb 11 '24 15:02 Vexu

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

dephiros avatar Feb 12 '24 12:02 dephiros

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?

Vexu avatar Feb 12 '24 14:02 Vexu

Can you try if 0.5.3 fixed this for you?

Vexu avatar Feb 14 '24 14:02 Vexu

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

davidmdm avatar Feb 14 '24 14:02 davidmdm

Sorry for the delay in reponse. A couple of busy days at work. Will check it later today and report back

dephiros avatar Feb 14 '24 14:02 dephiros

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 avatar Feb 14 '24 15:02 Vexu

@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 Screenshot 2024-02-14 at 14 45 13

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:

Screenshot 2024-02-14 at 14 40 19

dephiros avatar Feb 14 '24 20:02 dephiros

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.

Vexu avatar Feb 14 '24 20:02 Vexu

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

dephiros avatar Feb 15 '24 12:02 dephiros

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.

dnut avatar Feb 16 '24 15:02 dnut

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.

Vexu avatar Feb 16 '24 17:02 Vexu