zls icon indicating copy to clipboard operation
zls copied to clipboard

Emacs, nothing works

Open jgarvin opened this issue 3 years ago • 3 comments

Zig Version

0.11.0-dev.1095+8bd734d60

Zig Language Server Version

0.11.0-dev.107+20baa59

Steps to Reproduce

  • In a fresh emacs M-x install-packages and install lsp-mode and zig-mode
  • In the scratch buffer be sure to evaluate (setq lsp-zig-zls-executable "~/zls/zig-out/bin/zls") with your zig path substituted.
  • make a new directory foo and run zig init-exe inside
  • Open build.zig or main.zig in emacs. It should ask if you want to import the project, press 'i' for yes. Messages will indicate successful connection to ZLS.
  • M-x lsp-find-references on any symbol will not work, even symbols in the same file.
  • M-x lsp-find-definition will only work on the symbols defined in build.zig or main.zig. Looking up anything imported from std will not work.

Note that rust-analyzer with lsp-mode works, so I don't think it's my emacs setup, but emacs is huge so :shrug:

Expected Behavior

For finding definitions and references to work.

Actual Behavior

  • M-x lsp-find-references on any symbol will not work, even symbols in the same file.
  • M-x lsp-find-definition will only work on the symbols defined in build.zig or main.zig. Looking up anything imported from std will not work.

jgarvin avatar Jan 11 '23 03:01 jgarvin

I later tried in vs-code, which put up an error that ZLS couldn't find zig and I needed to set zig_exe. For anyone who finds this in the future, running zls --show-config-path will tell you where the zls config file is. It expects a top level JSON object, then you can put the key zig_exe with the path, e.g.:

{
    "zig_exe_path" : "/home/xxxx/zig/zig"
}

This was needed because I didn't change my $PATH to include zig.

I'm assuming that if vs-code got the error but emacs didn't that emacs not showing the error is an lsp-mode problem rather than a zls issue, but I'm not sure. Maybe there should be an installation note in README about zls needing zig in the path or for this option to be set though? If so I would have done it as part of the install. At the least there's nothing in the emacs specific directions for this.

jgarvin avatar Jan 11 '23 04:01 jgarvin

Both Neovim and Emacs will write this error to the lsp-log file/buffer, but not show a notification. The notification in VSCode probably comes from the plugin, and not from zls itself.

acristoffers avatar Jan 11 '23 07:01 acristoffers

With lsp-mode, ZLS stderr goes to a buffer zls::stderr rather than something directly managed by the LSP client. Perhaps you could try looking in this buffer?

Luexa avatar Jan 11 '23 07:01 Luexa