Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Haskell highlight queries #40

Merged
merged 1 commit into from
Jun 18, 2021

Conversation

farbodsz
Copy link
Contributor

This PR makes improvements to the highlights.scm file in
tree-sitter-haskell.

It's partly based off the one by @elianiva from nvim-treesitter/nvim-treesitter#1210.
(I'm aware that PR is still in the works, so wasn't sure whether to open the PR
here or on the nvim-treesitter repo).

Here are the changes I've made compared to the one from the nvim-treesitter
PR:

  • Highlight minus sign in negated numbers, e.g. (-10)
  • Resolve error when comma captured as punctuation delimiter (previously
    commented out)
  • Add semicolon as punctuation delimiter
  • Add case and of to @conditional capture group
  • Move qualified out of @keyword and into @include capture group
  • Add missing operators:
    • type_operator
    • Dots from export and record wildcards, i.e. Record{..}, exp (..)
    • Equals and pipe = and |
    • Function arrows => and ->
    • Bind arrow <-
    • Lambda operator \
    • Treat infix functions as operators (and also highlight the backtick)
    • @ symbol (except for in the as-pattern, where it is highlighted as
      @namespace)
  • Highlight namespaces with @namespace instead of @constructor, e.g.
    in T.Text
  • Simplify queries for types

There's also a comparison of each of the aforementioned highlights, so you can see the results visually.

Example 1

tree-sitter-haskell nvim-treesitter PR This PR
screenshot_20210618_213617 screenshot_20210618_214054 screenshot_20210618_215022

Example 2

tree-sitter-haskell nvim-treesitter PR This PR
screenshot_20210618_213740 screenshot_20210618_214235 screenshot_20210618_215113

The highlighting is based on the highlight file from nvim-treesitter PR
1210, with the following changes:

* Highlight minus sign in negated numbers, e.g. (-10)
* Resolve error when comma captured as punctuation delimiter (previously
  commented out)
* Add semicolon as punctuation delimiter
* Add `case` and `of` to `@conditional` capture group
* Move `qualified` out of `@keyword` and into `@include` capture group
* Add missing operators:
  * `type_operator`
  * Dots from export and record wildcards, i.e. `Record{..}`, `exp (..)`
  * Equals and pipe = |
  * Function arrows => and ->
  * Bind arrow <-
  * Lambda operator \
  * Treat infix functions as operators (and also highlight the backtick)
  * @ symbol (except for in the as-pattern, where it is highlighted as
    `@namespace`)
* Highlight namespaces with `@namespace` instead of `@constructor`, e.g.
  in `T.Text`
* Simplify queries for types
@tek
Copy link
Contributor

tek commented Jun 18, 2021

wait, this is rendered by nvim? any clue if there was some recent change that made this possible? I've been having issues like this one #35

anyways, looks good!

@tek tek merged commit a0c1adb into tree-sitter:master Jun 18, 2021
@farbodsz
Copy link
Contributor Author

Thanks for merging! Yes, it is rendered by nvim.

While I haven't been able to reproduce the exact issue you mentioned, I have noticed Playground not updating at all (for all languages). Not sure if those issues are related but I might look into it further in the near future.

@theHamsta
Copy link

@elianiva shouldn't qualified be also @include for us?

@elianiva
Copy link

elianiva commented Jul 5, 2021

@elianiva shouldn't qualified be also @include for us?

I think it should, but isn't it already the case though?

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.

4 participants