Skip to content
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 support | build_on_save/check doesn't appear to be working #19617

Closed
1 task done
iamcdonald opened this issue Oct 23, 2024 · 4 comments
Closed
1 task done

Zig support | build_on_save/check doesn't appear to be working #19617

iamcdonald opened this issue Oct 23, 2024 · 4 comments
Labels
bug [core label] language server An umbrella label for all language servers language An umbrella label for all programming languages syntax behaviors setting Feedback for preferences, configuration, etc support User support (non-defect troubleshooting, documentation, etc) zig Zig programming language support

Comments

@iamcdonald
Copy link

iamcdonald commented Oct 23, 2024

Check for existing issues

  • Completed

Describe the bug / provide steps to reproduce it

With the zig language extension I'm unable to get syntax highlighting expected for build_on_save functionality as outlined in this blog post.

I'm unsure if there's more I need to configure on top of the out of the box extension and even defining something like (whilst picking up the --enable-dbug-messages args) doesn't appear to work.

"languages": {
    "zig": {
      "formatter": "language_server",
      "language_servers": ["zls"]
    }
  },
  "lsp": {
    "zls": {
      "binary": {
        "path": "/Users/ooooo/.zvm/bin/zls",
        "arguments": ["--enable-debug-log", "--enable-message-tracing"]
      },
      "initialization_options": {
        "enable_autofix": true,
        "enable_build_on_save": true,
        "inlay_hints_hide_redundant_param_names": true,
        "warn_style": true,
        "highlight_global_var_declarations": true
      }
    }
  }

I'm wondering if anyone can point me to what I'm doing wrong or can attest to it working for them.

Environment

Zed: v0.157.5 (Zed)
OS: macOS 15.0.1
Memory: 16 GiB
Architecture: aarch64

If applicable, add mockups / screenshots to help explain present your vision of the feature

Screenshot 2024-10-23 at 11 03 38

Upon saving the above I expected the check command to be run by the language server (zls) and the resulting error to be surfaced. Just for completeness this is the error produced from running check.

src/test.zig:4:35: error: type 'i16' cannot represent integer value '2147483647'
    const x: i16 = std.math.maxInt(i32);
@iamcdonald iamcdonald added admin read Pending admin review bug [core label] triage Maintainer needs to classify the issue labels Oct 23, 2024
@xdBronch
Copy link
Contributor

this seems to be more than just build on save, same story with ast errors when "prefer_ast_check_as_child_process" is enabled (default). ig something with whatever zls is doing with diagnostics from spawned processes? im not sure what would make that any different though. @Techatrix hate to ping you but youve practically written half of zls at this point

@Techatrix
Copy link
Contributor

@Techatrix hate to ping you but youve practically written half of zls at this point

I don't mind being pinged. Always happy to help wherever I can :)


I was not able to reproduce this issue. I have copied the provided Zed settings, manually specified the path to my ZLS nightly (0.14.0-dev.175+ea2c303) and added Zig nightly (0.14.0-dev.2034+56996a280) to my PATH. I inspected the log file and saw that ZLS correctly ran zig build check and reported the diagnostics. zig ast-check diagnostics also worked for me.

If haven't anything that let me to believe that this issue is related to Zed specifically. @iamcdonald Did you use the latest nightly of Zig and ZLS? If so, could you also share your zls.log file?

@xdBronch
Copy link
Contributor

huh its working for me now, i updated zed last night after a little while i wonder if that fixed it. fwiw my logs showed zls running build on save, i just didnt get any diagnostics from it

@iamcdonald
Copy link
Author

Hi @Techatrix, @xdBronch

thanks for taking a look, really appreciate it.

I put together a demo repo to show the exact setup I have only to find it then start working.

Now it's working I think I'm noticing a couple of issues but they're more related to zls so I've popped a couple of issues (1, 2) there. Happy to be told it's just my misunderstanding though.

Going to close this issue though.

Thanks again everyone.

@JosephTLyons JosephTLyons added language An umbrella label for all programming languages syntax behaviors language server An umbrella label for all language servers zig Zig programming language support support User support (non-defect troubleshooting, documentation, etc) setting Feedback for preferences, configuration, etc and removed triage Maintainer needs to classify the issue admin read Pending admin review labels Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug [core label] language server An umbrella label for all language servers language An umbrella label for all programming languages syntax behaviors setting Feedback for preferences, configuration, etc support User support (non-defect troubleshooting, documentation, etc) zig Zig programming language support
Projects
None yet
Development

No branches or pull requests

4 participants