tree-sitter / tree-sitter-haskell

Haskell grammar for tree-sitter.
MIT License
151 stars 36 forks source link

Correctly parse `\cases` expressions #106

Closed crumbtoo closed 8 months ago

crumbtoo commented 8 months ago

Added support in the grammar for LambdaCase expressions with multiple scrutinees, as described here.

This addition is incomplete, as the cases keyword is not correctly highlighted. I was hoping to get assistance with this part; neither of the following changes to queries/highlights.scm seemed to have any effect:

 [
   "if"
   "then"
   "else"
; unconditionally treat `cases` as a keyword
+  "cases"
   "case"
   "of"
 ] @conditional
; only treat `cases` as a keyword in a cases lambda (`cases` is a valid id)
 + (exp_lambda_cases "\\" ("cases" @conditional))
tek commented 8 months ago

both work for me 🤷🏻 did you edit the queries in this repo? because those are not necessarily read by your editor. e.g. Neovim ships its own in https://github.com/nvim-treesitter/nvim-treesitter

btw. you need to use _apat, otherwise the patterns will be parsed a single applied pattern.

crumbtoo commented 8 months ago

I assumed nvim-treesitter installed the queries along with the parser, my bad! Both do in fact work. Corrections made.

tek commented 8 months ago

alright, thanks a lot!