Skip to content

Add syntax highlighting and LSP support for Haskell#164

Open
a12l wants to merge 1 commit intosminez:developfrom
a12l:feature/add-haskell-lsp
Open

Add syntax highlighting and LSP support for Haskell#164
a12l wants to merge 1 commit intosminez:developfrom
a12l:feature/add-haskell-lsp

Conversation

@a12l
Copy link
Copy Markdown

@a12l a12l commented Nov 25, 2025

This is both a pull request and a issue.

Pull Request

highlights.scm is copied direct from the nvim-treesitter repository with the latest commit that touched it being 188b1a6d01fd9bcf04bf2bc932d611809b154acc.

From what I understand you usually vendor the query file from tree sitter, but the user themselves need to install the parser? I guess the parser is platform dependent and you need to build it for each platform?

Issue

The reason I include the issue with the pull request is that I'm having an issue, and I want to make sure that it isn't related to my PR.

  • ad Version: 9f33bcc (branch feature/add-haskell-lsp)
  • OS: FreeBSD
  • Distribution: N/A
  • OS Version: 14.3

Describe the bug

When I press <space> l c (I've the line "<space> l c" = { run = "lsp-completion" } in my ~/.ad/config.toml) while having selected a symbol I get an error message (see attached image). The error message says

unable to send textDocument/didChange LSP notification: Broken pipe (os error 32)

To Reproduce

I created my haskell.so parser by

  1. git clone https://github.com/tree-sitter-grammars/tree-sitter-haskell.git
  2. cd tree-sitter-haskell
  3. Execute tree-sitter build
  4. cp haskell.so ~/.ad/tree-sitter/parsers/

The tree-sitter CLI is installed from FreeBSD's port collection.

I hope I've configured everything correctly. I've created a new Haskell project by running stack new foo and manually adding hie.yaml to the project root with the content

cradle:
  stack:
    - path: "."
      component: "foo:exe:Setup.hs"
    - path: "app/Main.hs"
      component: "foo:exe:foo-exe"
    - path: "src"
      component: "foo:lib"
    - path: "test/Spec.hs"
      component: "foo:test:foo-test"

When I start ad with ad ./app/Main.hs i get the messages LSP server started and a little while later `Setting up foo (for app/Main.hs):.

Expected behavior

Some form of completion suggestions showing up.

Screenshots

Felmeddelande LSP ad

Additional context

@sminez
Copy link
Copy Markdown
Owner

sminez commented Nov 25, 2025

This is two very different things here:

  • adding treesitter config for Haskell
  • trying to debug an issue with your LSP setup

I'm happy with the first as a PR, but the second is likely not something I can help with much I'm afraid. That error looks like the LSP server is crashing or exiting early. If there are any hard errors then they should show up in the ad log (there's a key binding to open it).

Can you remove the LSP parts of this PR and then raise an issue for the LSP problem if the ad log shows that ad is doing something wrong here please. From what I've heard previously about Haskell LSP setup, I suspect this might end up being something out of my control if there isn't an obvious error in the log

@a12l a12l force-pushed the feature/add-haskell-lsp branch 2 times, most recently from 6a308eb to 7391274 Compare November 27, 2025 17:57
@a12l
Copy link
Copy Markdown
Author

a12l commented Nov 27, 2025

@sminez does the syntax highlighting commit look good to you? I'm planning to moving the commit for LSP support to another branch later.

@sminez
Copy link
Copy Markdown
Owner

sminez commented Nov 30, 2025

The syntax highlighting commit looks fine. I'm not sure about the LSP support one though, from what you said in #159 it sounded like the way you need to set up LSP for Haskell differs per project? If that's the case, I don't think ad should provide fixed config for it out of the box.

@a12l
Copy link
Copy Markdown
Author

a12l commented Nov 30, 2025

Sorry, forgot to write a reply in that issue. It turned out that I was mistaken. Apparently you need to manually set an option for the script haskell-language-server-wrapper to become available in $PATH, which is used globally. The problem is still there (each HLS version need to be compiled against each GHC version), but you need to manage this using GHCup (tool for managing Haskell tooling). From what I understand you can't change these settings using your editor, you need to use GHCup.

highlights.scm is copied direct from the nvim-treesitter repository with the latest commit that touched it being 188b1a6d01fd9bcf04bf2bc932d611809b154acc.
@a12l a12l force-pushed the feature/add-haskell-lsp branch from 7391274 to f5beaca Compare December 7, 2025 00:32
@sminez
Copy link
Copy Markdown
Owner

sminez commented Dec 7, 2025

@a12l the queries you've got here aren't validating I'm afraid. I think it's just a case of stripping out some of the tags that neovim queries add for internal vim functionality.

If you can fix up the queries and validate locally with cargo xtask lint-ts-queries that should do the trick. It would also be good to see some screenshots of what this ends up looking like.

I'm aiming to publish the 0.4 build to crates tomorrow and it would be nice to have this in for that release but no worries if you've not got time to sort things before then.

@sminez sminez force-pushed the develop branch 5 times, most recently from 8dff1e7 to 4e81f74 Compare December 12, 2025 15:51
@a12l
Copy link
Copy Markdown
Author

a12l commented Jan 25, 2026

Just want to say that I haven't forgotten about this, just haven't had the time to complete it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants