zed icon indicating copy to clipboard operation
zed copied to clipboard

Haskell support

Open Daeraxa opened this issue 2 years ago • 6 comments

Would be great to have Haskell syntax support and LSP integration via haskell-language-server.

hls has auto formatting support via a couple of different plugins.

https://github.com/haskell/haskell-language-server https://haskell-language-server.readthedocs.io/

Update with tree-sitter link: https://github.com/tree-sitter/tree-sitter-haskell

Daeraxa avatar Jul 18 '22 14:07 Daeraxa

Looking forward to this 👍

alt-romes avatar Jan 24 '24 22:01 alt-romes

I was able to get basic syntax highlighting for Haskell, in case anyone is interested in running a dev build you can use this commit https://github.com/pseudomata/zed/commit/02ab16037c91a6d4883f91316ae7ed02b1bb3d69.

I'm not quite ready to open a PR because there's a few things that I'm not clear on but I plan on reading code for the other language integrations and add Haskell specific stuff in the indents.scm, outline.scm, and brackets.scm files.

See screenshot showing syntax highlighting
The highlighting for imports and modules seems broken, so that's another thing I need to fix. See below.

If I have more time I'll look into adding the LSP adapter in Zed for Haskell as well :-)

ghost avatar Jan 24 '24 23:01 ghost

If I have more time I'll look into adding the LSP adapter in Zed for Haskell as well :-)

@pseudomata I have a working (but fragile) implementation at https://github.com/leifu1128/zed/commit/1be3e7b99b5f0aa7ba7786a752c7dcd196dead5c, I copied your config.toml to get it working temporarily, let me know if that's a problem.

leizaf avatar Jan 26 '24 14:01 leizaf

That looks great @leifu1128! Maybe we can open a combined PR to add both the syntax highlighting and LSP once we have fixed any of the issues.

ghost avatar Jan 26 '24 14:01 ghost

That looks great @leifu1128! Maybe we can open a combined PR to add both the syntax highlighting and LSP once we have fixed any of the issues.

Sounds good! Only thing I can't figure out is how to configure which directory the LSP runs in, since hls needs to run where hie.yml is.

leizaf avatar Jan 26 '24 15:01 leizaf

Okay I think I've got the syntax highlighting in a good spot. I created a haskell-support branch, and merged a PR for syntax support into that branch (see https://github.com/pseudomata/zed/pull/1). If you'd like to open a PR against that adding your LSP changes, we can have both our changes in one PR (if you prefer separate PRs that's fine too, I'm happy to do the work to make whatever work).

I opened a draft PR to merge the haskell-support branch upstream: https://github.com/zed-industries/zed/pull/6786, once things are ready I'll mark it ready for review.

Regarding the directory: I'm not sure either! I can look into that a bit or see if we can get someone from Zed to take a look in the PR when we mark it ready for review (in the meanwhile, it should work with the implicit configuration?)

ghost avatar Jan 26 '24 16:01 ghost

Hi there, I have a basic question. Once I have the LSP configured, how do I create and run the program? I am used to having a REPL within Doom Emacs and dont see the equivalent for Zed...

murthynukala avatar Apr 17 '24 01:04 murthynukala

One possibility would be to use tasks and do something similar to https://github.com/zed-industries/zed/pull/10548/files#diff-555038673fd8f3dcee873862e12320197c756e5661ada52d90b94339c56f0266 does for bash: there's a way to spawn a bash task that runs the selection.

Presumably, Haskell and other repl-rich languages could define similar tasks in their plugins as a start.

SomeoneToIgnore avatar Apr 17 '24 09:04 SomeoneToIgnore