elixir-lang / tree-sitter-elixir

Elixir grammar for tree-sitter
https://elixir-lang.org/tree-sitter-elixir
Apache License 2.0
249 stars 25 forks source link

highlight calls to erlang modules as types #5

Closed the-mikedavis closed 3 years ago

the-mikedavis commented 3 years ago

:wave: hello!

I'm integrating the new parser and highlight queries into the helix editor (see helix-editor/helix#830) and I noticed that a function call on an atom highlights differently than an alias (module). This PR adds a clause to the highlights to recognize that case and highlight the atom the same as an alias:

highlight-atom-modules-as-types

before | after

What do you think?

jonatanklosko commented 3 years ago

Hey @the-mikedavis! I intentionally didn't do it, because I'm not sure if atom should be colored differently based on context. On one side both tokens refer to a module, but in the end atoms and aliases are different beings. It's certainly subjective, but for some reference makup_elixir does the same.

@josevalim any preference?

josevalim commented 3 years ago

I am thinking they could be the same. It is already syntactically distinct so having them visually the same can help drive the point home they are all modules?

jonatanklosko commented 3 years ago

I'm not really opinionated here, so as you two agree it sounds perfectly fine to me!

the-mikedavis commented 3 years ago

I think the consistency with makeup is pretty desirable. I'd be willing to try out a PR to makeup to align the behavior.

here are some more snippets from a real code-base for comparison...
![crypto-compare](https://user-images.githubusercontent.com/21230295/137026741-cb7df83a-9c15-4cc6-b627-9df2857e68b5.png) ![per-message-deflate-compare](https://user-images.githubusercontent.com/21230295/137028777-015b9ef7-1177-486b-92aa-1753956d16da.png) before | after
jonatanklosko commented 3 years ago

Ah, actually this matches the behaviour in https://github.com/nvim-treesitter/nvim-treesitter/pull/1904 too :)

jonatanklosko commented 3 years ago

Thanks! :cat:

connorlay commented 3 years ago

Ah, actually this matches the behaviour in nvim-treesitter/nvim-treesitter#1904 too :)

Yep, which was me following what I saw in exdocs snippets, bringing things around full circle 😆