-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
feat: add tree-sitter-make #1433
feat: add tree-sitter-make #1433
Conversation
Hey guys! Helix is an awesome project, I've only found it in the last few days but I love what I've seen so far. Thanks so much for your hard work! What a great idea to build an editor from the ground up with LSP and tree-sitter in mind. I've used GNU Emacs for 10 years with some thousands of lines of configuration. Lately I've been using neovim, where I have ~100 lines of config. I'm happy with helix with all of 5 lines of config, and LSP works better and faster with helix than any of my other editors. This team is on to something! I tried editing a GNU Makefile today and found there is no syntax highlighting. This PR imports the preexisting I'm not sure if you have any conventions for tracking existing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thank you!
languages.toml
Outdated
[[language]] | ||
name = "make" | ||
scope = "source.make" | ||
file-types = ["Makefile"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we also add the other variants, makefile
and GNUmakefile
? And also could we throw in justfile
and .justfile
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good thinking!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, I thought there is tree-sitter-just? https://github.com/IndianBoy42/tree-sitter-just
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh interesting. Is it good to use? It mentions it's a work in progress and doesn't have tests yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the kind words!
The PR looks good but highlights.scm
needs some changes to follow the list of scopes we use: https://docs.helix-editor.com/themes.html#syntax-highlighting
runtime/queries/make/highlights.scm
Outdated
"if" | ||
"or" ; boolean functions are conditional in make grammar | ||
"and" | ||
] @conditional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@keyword.control.conditional
runtime/queries/make/highlights.scm
Outdated
"and" | ||
] @conditional | ||
|
||
"foreach" @repeat |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@keyword.control.repeat
runtime/queries/make/highlights.scm
Outdated
"include" | ||
"sinclude" | ||
"-include" | ||
] @include |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@keyword.control.import
runtime/queries/make/highlights.scm
Outdated
"error" | ||
"warning" | ||
"info" | ||
] @exception |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@keyword.control.exception
Hmm, that one looks like it's missing from the list, can you add it here?
Line 146 in 5b1a628
- `conditional` - `if`, `else` |
runtime/queries/make/highlights.scm
Outdated
(variable_assignment | ||
name: (word) @constant) | ||
|
||
(variable_reference | ||
(word) @constant) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to me that these should be @variable
?
runtime/queries/make/highlights.scm
Outdated
|
||
(comment) @comment | ||
|
||
((word) @clean @string.regex |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@string.regexp
runtime/queries/make/highlights.scm
Outdated
|
||
(function_call | ||
function: "error" | ||
(arguments (text) @text.danger)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see @error
on this list -- is this a scope that should also be added to themes.md
?
Oh I see it, under the Interface
heading 👍
runtime/queries/make/highlights.scm
Outdated
|
||
(function_call | ||
function: "warning" | ||
(arguments (text) @text.warning)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@warning
runtime/queries/make/highlights.scm
Outdated
|
||
(function_call | ||
function: "info" | ||
(arguments (text) @text.note)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@info
As identified in [this GitHub comment](helix-editor#1433 (comment))
a4f8782
to
4cc7fb1
Compare
Thanks for the pointer, and the complete review! I've updated the scopes and added |
[[language]] | ||
name = "make" | ||
scope = "source.make" | ||
file-types = ["Makefile", "makefile", "justfile", ".justfile"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"justfile"
will cover files with justfile
as their name or as their extension.
file-types = ["Makefile", "makefile", "justfile", ".justfile"] | |
file-types = ["Makefile", "makefile", "justfile"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does that include .justfile
by itself?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that is what this is meant to cover, my mistake.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should remove just, there is https://github.com/IndianBoy42/tree-sitter-just
As identified in [this GitHub comment](helix-editor#1433 (comment))
4cc7fb1
to
9fe8e0b
Compare
As identified in [this GitHub comment](helix-editor#1433 (comment))
9fe8e0b
to
1f3120a
Compare
This commit adds syntax highlighting for GNU Make[^1] makefiles via tree-sitter-make[^2]. [^1]: https://www.gnu.org/software/make/ [^2]: https://github.com/alemuller/tree-sitter-make
As identified in [this GitHub comment](helix-editor#1433 (comment))
1f3120a
to
a462716
Compare
Thanks! 🎉 |
This commit adds syntax highlighting for GNU Make1 makefiles
via tree-sitter-make2.
Footnotes
https://www.gnu.org/software/make/ ↩
https://github.com/alemuller/tree-sitter-make ↩