-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add support for Mojo #10743
Merged
Merged
Add support for Mojo #10743
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
(attribute attribute: (identifier) @property) | ||
(type (identifier) @type) | ||
|
||
; Function calls | ||
|
||
(decorator) @function | ||
|
||
(call | ||
function: (attribute attribute: (identifier) @function.method)) | ||
(call | ||
function: (identifier) @function) | ||
|
||
; Function definitions | ||
|
||
(function_definition | ||
name: (identifier) @function) | ||
|
||
; Identifier naming conventions | ||
|
||
((identifier) @type | ||
(#match? @type "^[A-Z]")) | ||
|
||
((identifier) @constant | ||
(#match? @constant "^_*[A-Z][A-Z\\d_]*$")) | ||
|
||
; Builtin functions | ||
|
||
((call | ||
function: (identifier) @function.builtin) | ||
(#match? | ||
@function.builtin | ||
"^(abs|all|always_inline|any|ascii|bin|bool|breakpoint|bytearray|bytes|callable|chr|classmethod|compile|complex|constrained|delattr|dict|dir|divmod|enumerate|eval|exec|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|isinstance|issubclass|iter|len|list|locals|map|max|memoryview|min|next|object|oct|open|ord|pow|print|property|range|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unroll|vars|zip|__mlir_attr|__mlir_op|__mlir_type|__import__)$")) | ||
|
||
; Literals | ||
|
||
[ | ||
(none) | ||
(true) | ||
(false) | ||
] @constant.builtin | ||
|
||
[ | ||
(integer) | ||
(float) | ||
] @number | ||
|
||
(comment) @comment | ||
(string) @string | ||
(escape_sequence) @escape | ||
|
||
[ | ||
"(" | ||
")" | ||
"[" | ||
"]" | ||
"{" | ||
"}" | ||
] @punctuation.bracket | ||
|
||
(interpolation | ||
"{" @punctuation.special | ||
"}" @punctuation.special) @embedded | ||
|
||
; Docstrings. | ||
(function_definition | ||
"async"? | ||
"def" | ||
name: (_) | ||
(parameters)? | ||
body: (block (expression_statement (string) @string.doc))) | ||
|
||
[ | ||
"-" | ||
"-=" | ||
"!=" | ||
"*" | ||
"**" | ||
"**=" | ||
"*=" | ||
"/" | ||
"//" | ||
"//=" | ||
"/=" | ||
"&" | ||
"%" | ||
"%=" | ||
"^" | ||
"+" | ||
"->" | ||
"+=" | ||
"<" | ||
"<<" | ||
"<=" | ||
"<>" | ||
"=" | ||
":=" | ||
"==" | ||
">" | ||
">=" | ||
">>" | ||
"|" | ||
"~" | ||
"and" | ||
"in" | ||
"is" | ||
"not" | ||
"or" | ||
"is not" | ||
"not in" | ||
] @operator | ||
|
||
[ | ||
"as" | ||
"alias" | ||
"assert" | ||
"async" | ||
"await" | ||
"borrowed" | ||
"break" | ||
"class" | ||
"continue" | ||
"def" | ||
"del" | ||
"elif" | ||
"else" | ||
"except" | ||
"exec" | ||
"finally" | ||
"fn" | ||
"for" | ||
"from" | ||
"global" | ||
"if" | ||
"import" | ||
"inout" | ||
"lambda" | ||
"nonlocal" | ||
"owned" | ||
"pass" | ||
"print" | ||
"raise" | ||
"raises" | ||
"return" | ||
"struct" | ||
"try" | ||
"var" | ||
"while" | ||
"with" | ||
"yield" | ||
"match" | ||
"case" | ||
] @keyword |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The highlights need to be updated to use Helix-specific capture names: https://docs.helix-editor.com/master/themes.html#syntax-highlighting
For example
@property
should become@variable.other.member
,(true)
and(false)
should be captured as@constant.builtin.boolean
, escape sequences as@constant.character.escape
, etc.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've updated the queries to be a superset of the current Python queries.
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.
If it's a superset you can use a comment in the query files
; inherits: python
which will do the same thing as copy/pasting in the python query for that fileThere 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 that for now it's OK to use inheritance. If I understand correctly, later if there are any additions, I will need to delete the comment and make a full modified version?
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.
If the python queries start using a new node that isn't in the mojo grammar then we will need to replace the
; inherits: python
. But if you just want to add onto the python queries you can place patterns before or after the inherits comment. The ones before are higher precedence and the ones after lowerThere 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.
At the moment, the differences are mainly related to modifying queries rather than adding new ones. So, I think I'm done with the changes, further improvements depend on the tree-sitter repository.