helix-editor / helix

A post-modern modal text editor.
https://helix-editor.com
Mozilla Public License 2.0
32.58k stars 2.4k forks source link

Incorrect syntax highlighting of functions in Haskell typeclasses #11227

Open A-Walrus opened 1 month ago

A-Walrus commented 1 month ago

Summary

The syntax highlighting is wrong with multiple default function implementations for a type-class in Haskell (like rust traits). image

Tree sitter scopes are identical for both the correctly highlighted and incorrectly highlighted ones: ["haskell", "class", "class_body", "function", "variable"]

But the highlight name for the first one (correct) is function and for the rest are variable.

Reproduction Steps

I tried this: 1. `hx` 2. paste in the exmple code: ```hs class Foo a where as_int :: a -> Int as_str :: a -> String as_txt :: a -> Text as_int = read as_str as_str = show as_int as_txt = pack as_str ``` I expected this to happen: All functions highlighted identically Instead, this happened: Only the first function is highlighted correctly ### Helix log _No response_ ### Platform Linux ### Terminal Emulator kgx (Gnome Console) ### Installation Method Arch (24.3), AUR (24.7) ### Helix Version helix 24.3, helix 24.7
TornaxO7 commented 1 month ago

I think the haskell treesitter expects to have the following format when writing functions:

<type>
<function implementation>

I'm getting the following syntax highlighting:

class Foo a where
  as_int :: a -> Int
  as_int = read as_str

  as_str :: a -> String
  as_str = show as_int

  as_txt :: a -> Text
  as_txt = pack as_str

image