zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
47.81k stars 2.8k forks source link

Swift extension: support path for sourcekit-lsp #13302

Closed TeamPuzel closed 2 months ago

TeamPuzel commented 3 months ago

Check for existing issues

Describe the bug / provide steps to reproduce it

The Swift extension appears to be getting the lsp binary from Xcode, so when I'm using the latest Swift toolchain rather than the one from Xcode there's a mismatch as Zed uses an outdated language server.

2024-06-20T11:26:39+02:00 [INFO] starting language server. binary path: "/usr/bin/xcrun", working directory:

This results in missing types, attributes and keywords:

image

It would be an improvement if Zed respected which binary is actually in the path and only used Apple tools to get their binary as a fallback.

It also seems to ignore adding the path manually in my Zed configuration file

Environment

Zed: v0.141.0 (Zed Preview) OS: macOS 15.0.0 Memory: 32 GiB Architecture: aarch64

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

N/A

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

N/A

notpeter commented 3 months ago

Hi @TeamPuzel!

We have added support for explicit path specification for other extensions/language servers (rust, zig, golang, clang) and you're looking for this to be implemented for swift as well. Gotcha.

For reference the swift extension lives here: zed-extensions/swift.

See also:

Thanks for reporting!

TeamPuzel commented 3 months ago

For reference the swift extension lives here: zed-extensions/swift.

Thanks, I was able to get it to check the path first 👍

notpeter commented 3 months ago

Wonderful, so this is ok to close?

For future reference / searchability can you paste any settings that got it working as expected?

TeamPuzel commented 3 months ago

For future reference / searchability can you paste any settings that got it working as expected?

Ah, I didn't find any settings that worked, I instead added this to the source code

if let Some(path) = worktree.which("sourcekit-lsp") {
    return Ok(zed::Command {
        command: path,
        args: Default::default(),
        env: worktree.shell_env(),
    });
}
maxdeviant commented 2 months ago

This was done in https://github.com/zed-extensions/swift/pull/11 and is available in v0.3.0 of the Swift extension.