-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Improved detection and re-use of language servers #7902
Comments
Note that direnv integration #4977 can be reloaded if changed, so the integration should support that. |
I hear you .I do think we can go a long way without supporting a specific tool and just supporting good old PATH. Once we have that, we can see how/when we need to reload something. |
That's fair enough - I want to express that until https://direnv.net is supported (and thus https://devenv.sh), I'm not able to move to Zed (which besides Linux support are the two last blockers). |
How is your usecase different from |
I installed Even if Zed fails to detect the globally installed Is there a workaround until your proposed solution gets released? Output of
|
Zed tries to always install the @nilskch can you create a separate ticket for that? Version mismatch seems semi-orthogonal to the issue here. |
Thanks for the write-up here @nilskch, I have also run into this problem with Go! (In the most extreme case if you're trying to change the main go repo, you need to build I think the proposed changes will help a bit – if I manually installed the correct That said, I do think it would be nice if we used the right version of the language server automatically, so look forward to making that work too! |
From my understanding, Zed ignores all manually installed Its important to note, that it really depends how @ConradIrwin I think we should move this discussion to #8071. I would love to make this work with you and I am happy to assist/make a PR! |
That's right, @nilskch. First step is to pick up things from PATH. I'll start working on that as soon as I can. Then, once we have that, we'll have to see how much wider we make the language-specific interfaces so that extensions can do their thing and pick the right tools. |
Using Zed to work on oven-sh/bun is mostly blocked on I think the proposal you have is good. Though I have a very simple/stupid question: does zed allow a per project configuration? Also something to keep in mind for local binaries, or paths binaries in general: Windows binaries must end with |
It does, yep. In your project: |
Updated after talking about this with @maxbrunsfeld @nathansobo and @maxdeviant yesterday: first step is to launch a login shell per worktree when a worktree is opened, keep the resulting env around (after thinking about it overnight: we do not want to set it on our own process, since that would clobber our env), then when trying to find language server binaries, we look in the (I updated the ticket to reflect this) |
Synced with @maxbrunsfeld again and we both came to the same conclusion: adding more and more logic to Zed itself is not a good idea. The logic for fetching/starting language servers is already hard to follow (because each language server needs to do a slightly different thing). So instead of adding more to Zed, we're going to push the logic down into the extensions (that Max & Marshall are working on). In short: closing, because we'll try to solve the problems in here with extensions. |
Update after another round of conversations: in #8188 I'm going to do a minimal move towards the goals outlined in this ticket. I add a method that each language server adapter can overwrite to check for locally installed binaries. In that PR I added that for Go, meaning that (1) and (3) is implemented for Go in #8188. |
…rs (#8188) After a lot of back-and-forth, this is a small attempt to implement solutions (1) and (3) in #7902. The goal is to have a minimal change that helps users get started with Zed, until we have extensions ready. Release Notes: - Added detection of user-installed `gopls` to Go language server adapter. If a user has `gopls` in `$PATH` when opening a worktree, it will be used. - Added detection of user-installed `zls` to Zig language server adapter. If a user has `zls` in `$PATH` when opening a worktree, it will be used. Example: I don't have `go` installed globally, but I do have `gopls`: ``` ~ $ which go go not found ~ $ which gopls /Users/thorstenball/code/go/bin/gopls ``` But I do have `go` in a project's directory: ``` ~/tmp/go-testing φ which go /Users/thorstenball/.local/share/mise/installs/go/1.21.5/go/bin/go ~/tmp/go-testing φ which gopls /Users/thorstenball/code/go/bin/gopls ``` With current Zed when I run `zed ~/tmp/go-testing`, I'd get the dreaded error: ![screenshot-2024-02-23-11 14 08@2x](https://github.com/zed-industries/zed/assets/1185253/822ea59b-c63e-4102-a50e-75501cc4e0e3) But with the changes in this PR, it works: ``` [2024-02-23T11:14:42+01:00 INFO language::language_registry] starting language server "gopls", path: "/Users/thorstenball/tmp/go-testing", id: 1 [2024-02-23T11:14:42+01:00 INFO language::language_registry] found user-installed language server for Go. path: "/Users/thorstenball/code/go/bin/gopls", arguments: ["-mode=stdio"] [2024-02-23T11:14:42+01:00 INFO lsp] starting language server. binary path: "/Users/thorstenball/code/go/bin/gopls", working directory: "/Users/thorstenball/tmp/go-testing", args: ["-mode=stdio"] ``` --------- Co-authored-by: Antonio <[email protected]>
…rs (#8188) After a lot of back-and-forth, this is a small attempt to implement solutions (1) and (3) in #7902. The goal is to have a minimal change that helps users get started with Zed, until we have extensions ready. Release Notes: - Added detection of user-installed `gopls` to Go language server adapter. If a user has `gopls` in `$PATH` when opening a worktree, it will be used. - Added detection of user-installed `zls` to Zig language server adapter. If a user has `zls` in `$PATH` when opening a worktree, it will be used. Example: I don't have `go` installed globally, but I do have `gopls`: ``` ~ $ which go go not found ~ $ which gopls /Users/thorstenball/code/go/bin/gopls ``` But I do have `go` in a project's directory: ``` ~/tmp/go-testing φ which go /Users/thorstenball/.local/share/mise/installs/go/1.21.5/go/bin/go ~/tmp/go-testing φ which gopls /Users/thorstenball/code/go/bin/gopls ``` With current Zed when I run `zed ~/tmp/go-testing`, I'd get the dreaded error: ![screenshot-2024-02-23-11 14 08@2x](https://github.com/zed-industries/zed/assets/1185253/822ea59b-c63e-4102-a50e-75501cc4e0e3) But with the changes in this PR, it works: ``` [2024-02-23T11:14:42+01:00 INFO language::language_registry] starting language server "gopls", path: "/Users/thorstenball/tmp/go-testing", id: 1 [2024-02-23T11:14:42+01:00 INFO language::language_registry] found user-installed language server for Go. path: "/Users/thorstenball/code/go/bin/gopls", arguments: ["-mode=stdio"] [2024-02-23T11:14:42+01:00 INFO lsp] starting language server. binary path: "/Users/thorstenball/code/go/bin/gopls", working directory: "/Users/thorstenball/tmp/go-testing", args: ["-mode=stdio"] ``` --------- Co-authored-by: Antonio <[email protected]>
Sorry, beginner Zed user here trying to see it I can make this work for me. I'm in a restricted dev environment so have my LSPs in I have |
Problems
Person A
cd their-project
both end up in$PATH
, with matching versions.$PATH
#4978 (comment)Person B
go
versions. They don't have a global Go version, but useasdf
to set a go version per project.gopls
installed.gopls
is installed and tries to install a global one using thego
command, but that command doesn't exist globally inPATH
, only in a project's directory (when asdf/mise/... kicks in). Installation ofgopls
fails because Zed can't findgo
.go
: Go support not working at all #4471 (comment)Person C
bundle exec solargraph
in a projects directory.Person D
.bin/language-server
Proposed solutions
login
shell environment in~
once per Zed process, we launch a login shell once per worktree and keep the result of that environment around. We don't set it on our own process env.$PATH
, mainly) whenzed
is launched via CLI. That should be a superset of the env from (1) (it would allow users to do something likeexport PATH="my-bin-folder:$PATH" && zed .
)worktree.env.PATH
(stored in (1)) already contains a language server before starting it (I think this can be universal for all languages, because if we don't find one, we just fallback to our old behaviour, sweet), if so: use thatlsp
section of our settings, allow users to setcommand
to define how to launch a language server. Because some language servers aren't in PATH and need to be launched via.bin/foobar
ornode_modules/.bin/foobar
or something.command
is an absolute path, we can just execute itcommand
is a relative path, we execute it relative to the projects root directorycommand
is just a file-name (bundle
), we try to look it up in$PATH
and execute itargs
next tocommand
so that users can runbundle exec solargraph
, for example.1 and 3 fix
Person A
andPerson B
's problem.2 would be an improvement on that and make it work more often.
4 fixes
Person C
andPerson D
's problem.The text was updated successfully, but these errors were encountered: