Closed pseudomata closed 4 months ago
We require contributors to sign our Contributor License Agreement, and we don't have @leifu1128 on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.
@cla-bot check
The cla-bot has been summoned, and re-checked this pull request!
Sweet, thanks @leifu1128! Marking this "Ready for review". There was an open question about which directory the LSP runs in (https://github.com/zed-industries/zed/issues/5281#issuecomment-1912226039) though I do not think that's a blocker and can likely be a follow-up (I don't have a strong preference).
Thank you for the review @mikayla-maki. I've switched back to using the highlights.scm
from tree-sitter-haskell
as the base and modified it to use the captures supported by Zed (thank you for that reference!).
With these changes I've taken screenshots of a random code selection that showcases most of the syntax in common use, comparison is with the Helix editor.
(P.S. I just marked it back as ready for review and re-requested a review, I apologize if you meant to keep it in draft and I don't mean to be impatient here -- appreciate the review!)
@pseudomata Have you had a chance to try out the LSP support in Zed?
@mikayla-maki and I are trying to test it out locally, but we're running into issues where it's not able to resolve the haskell-language-server
for the right GHC version.
Thank you @mikayla-maki and @maxdeviant. I believe this might have been the issue @leifu1128 was running into as well. I would like to take a crack at fixing the issues and see if I can come up with a reasonable solution first! I'm going to dig around a little bit and see if I can get things working by looking at how VS Code handles this (which might have a similar environment).
If not, I'll convert this PR to cover syntax highlighting only.
Sounds good, and good luck @pseudomata!
Aside: I just realized why the LSP integration works fine for me -- it's because I have HLS installed via ghcup
on my system, so haskell-language-server-wrapper
is actually able to find the binary under ~/.ghcup/bin/
. In order to reproduce the issue, removing HLS via ghcup rm hls 2.5.0.0
and re-running Zed will break things again.
@pseudomata we could just request users install it themselves in our documentation. I believe for nu
and uiua
, whose LSPs are integrated into their binary, you just have to have it in your PATH
. If Haskell land is ok with that, it's a good middle ground I think.
I was actually just going to ask about this, I was looking at the Elixir implementation and copied that to expose a Haskell setting to do something similar, e.g. install HLS with ghcup
and then adding this to editor configuration:
"haskell": {
"lsp": {
"local": {
"path": "~/.ghcup/hls/2.5.0.0/bin/haskell-language-server-wrapper",
"arguments": ["lsp"]
}
}
}
To play it safe, I added the default to be none
so a fresh installation of Zed would open a Haskell project with syntax highlighting but no LSP integration. So far things are working for me:
Let me clean up my branch really quick and I can push that change up.
Let me know what you think! I see nu
does this a bit differently (as opposed to exposing a setting), but considering we'd have to provide the path anyway which has the version in the path ( (EDIT: nvm, it's in the path already if using ~/.ghcup/hls/2.5.0.0/bin/haskell-language-server-wrapper
)ghcup
so we don't need to provide any configuration) my thoughts are this avoids an error with the default setting and is more explicit.
"haskell": {
"lsp": "none"
}
With this version if a user opens a Haskell project and doesn't have HLS installed, there's an error but otherwise things work fine:
failed to start language server "hls": No such file or directory (os error 2)
I think that the nu
style with the useful error about hls
would be best. No need for additional settings, smart default, works with the way most non-vscode haskell systems work. We can add more configuration options later if needed.
Sounds good to me, thanks @mikayla-maki. I just pushed those changes up.
Oh and I'm so sorry, I forgot to mention this earlier, do you think you could add an outline.scm
file? It's how a language integrates with Zed's buffer symbol search (cmd-shift-o
).
This PR is really great, thanks for working with us on this :D :D
Oh cool, I hadn't discovered that feature yet! Happy to add that, I think it might take a bit to figure out all the symbols to add for Haskell (I just picked up learning the language so I'm a bit of a noob). I'm signing off for the weekend but might find some time to work on it over the next few days and can ping this PR again when I have something working -- I can also commit to doing that in a follow-up. Whichever you prefer 🙂
Thanks for the all the feedback, and for open sourcing Zed!
Let's fast follow with it, y'all have put in the work for this one :). Thank you so much for the contribution!
Just woke up to see this, thanks for the hard work y'all. I can finally write more whitepapers.
Is this already out in the main version of Zed?
Is this already out in the main version of Zed?
Yes, it is available in Zed Stable starting from Zed 0.121.5.
Amazing! Is it automatically integrated or do I need to install it somehow? I'm not getting type signatures highlighted yet in my code (just installed latest version today).
It is currently bundled with part of Zed, but it will most likely move to an extension once we have language server support in extensions.
If it doesn't seem to be working then it might be a problem running the language server?
It could be that, I'm not really sure of how I should be 'running' the language server if I'm honest. On VSCode it works well though, does that indicate anything?
Hey @BasLaa, you need to have HLS
installed (see installation instructions via ghcup
) and then things should work. Though syntax highlighting should work out of the box without needing to install anything — is this not the case for you? Can you confirm which version of Zed you're running?
If you run into other issues feel free to contact me and I'll see if I can help 🙂
Hi @pseudomata, I have HLS installed via ghcup
, although I do have multiple versions of HLS installed (2.4.0.0, 2.5.0.0, 2.6.0.0), that might interfere? Syntax highlighting for Haskell works for me in Zed, version is 0.123.6. I'm just trying out a Cabal project, and there I'm not getting any type signatures or hints, whereas I do get them in VSCode with the same project.
I don't think multiple versions should be causing an issue, but I think it might be worth trying removing the others and re-installing just one version. AFAIK the 'wrapper' binary will select the correct version.
Have you tried building the project first as well? It might also be helpful to see some of the debug logs and language server logs. Currently away from my computer so can't share exact steps to get logs but they're in the command panel.
Before stepping away I opened a Haskell project and tested things were working for me on the same version of Zed you're running, so at least there isn't a regression.
I tried removing all versions and reinstalling a single one, no change unfortunately. I also tried building the project. I believe I found the debug log for the LSP, but the log seems to be empty for me, so perhaps I'm looking at the wrong log?
There's also the Zed debug log (not related to LSP) which might be helpful to take a look at.
This PR adds the Haskell tree-sitter grammar copied from
nvim-treesitter
. It also adds the Haskell Language Server.This is a joint effort by myself (adding the grammar) and @leifu1128 (who is adding the language server integration).
This PR resolves https://github.com/zed-industries/zed/issues/5281
Release Notes: