-
-
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 Teal language #12081
Open
barsoosayque
wants to merge
2
commits into
helix-editor:master
Choose a base branch
from
barsoosayque:teal-language
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+228
−0
Open
Changes from all commits
Commits
Show all changes
2 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,15 @@ | ||
[ | ||
(do_statement) | ||
(numeric_for_statement) | ||
(generic_for_statement) | ||
(while_statement) | ||
(repeat_statement) | ||
(if_statement) | ||
(function_statement) | ||
(record_declaration) | ||
(interface_declaration) | ||
(enum_declaration) | ||
(anon_function) | ||
(table_constructor) | ||
] @fold | ||
|
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,171 @@ | ||
|
||
;; Primitives | ||
(boolean) @constant.builtin.boolean | ||
(comment) @comment | ||
(shebang_comment) @comment | ||
(identifier) @variable | ||
((identifier) @variable.builtin | ||
(#eq? @variable.builtin "self")) | ||
(nil) @constant.builtin | ||
(number) @constant.numeric | ||
(string) @string | ||
(table_constructor ["{" "}"] @constructor) | ||
(varargs "..." @constant.builtin) | ||
[ "," "." ":" ";" ] @punctuation.delimiter | ||
|
||
(escape_sequence) @constant.character.escape | ||
(format_specifier) @constant.character.escape | ||
|
||
;; Basic statements/Keywords | ||
[ "if" "then" "elseif" "else" ] @keyword.control.conditional | ||
[ "for" "while" "repeat" "until" "do" ] @keyword.control.repeat | ||
[ "end" ] @keyword | ||
[ "in" ] @keyword.operator | ||
[ "local" ] @keyword.storage.type | ||
[ (break) (goto) ] @keyword.control | ||
[ "return" ] @keyword.control.return | ||
(label) @label | ||
|
||
;; Global isn't a real keyword, but it gets special treatment in these places | ||
(var_declaration "global" @keyword.storage.type) | ||
(type_declaration "global" @keyword.storage.type) | ||
(function_statement "global" @keyword.storage.type) | ||
(record_declaration "global" @keyword.storage.type) | ||
(interface_declaration "global" @keyword.storage.type) | ||
(enum_declaration "global" @keyword.storage.type) | ||
|
||
(macroexp_statement "macroexp" @keyword) | ||
|
||
;; Ops | ||
(bin_op (op) @operator) | ||
(unary_op (op) @operator) | ||
[ "=" "as" ] @operator | ||
|
||
;; Functions | ||
(function_statement | ||
"function" @keyword.function | ||
. name: (_) @function) | ||
(anon_function | ||
"function" @keyword.function) | ||
(function_body "end" @keyword.function) | ||
|
||
(arg name: (identifier) @variable.parameter) | ||
|
||
(function_signature | ||
(arguments | ||
. (arg name: (identifier) @variable.builtin)) | ||
(#eq? @variable.builtin "self")) | ||
|
||
(typeargs | ||
"<" @punctuation.bracket | ||
. (_) @type.parameter | ||
. ("," . (_) @type.parameter)* | ||
. ">" @punctuation.bracket) | ||
|
||
(function_call | ||
(identifier) @function . (arguments)) | ||
(function_call | ||
(index (_) key: (identifier) @function) . (arguments)) | ||
(function_call | ||
(method_index (_) key: (identifier) @function) . (arguments)) | ||
|
||
;; Types | ||
|
||
; Contextual keywords in record bodies | ||
(record_declaration | ||
. [ "record" ] @keyword.storage.type | ||
name: (identifier) @type) | ||
(anon_record . "record" @keyword.storage.type) | ||
(record_body | ||
(record_declaration | ||
. [ "record" ] @keyword.storage.type | ||
. name: (identifier) @type)) | ||
(record_body | ||
(enum_declaration | ||
. [ "enum" ] @keyword.storage.type | ||
. name: (identifier) @type.enum)) | ||
(record_body | ||
(interface_declaration | ||
. [ "interface" ] @keyword.storage.type | ||
. name: (identifier) @type)) | ||
(record_body | ||
(typedef | ||
. "type" @keyword.storage.type | ||
. name: (identifier) @type . "=")) | ||
(record_body | ||
(macroexp_declaration | ||
. [ "macroexp" ] @keyword.storage.type)) | ||
(record_body (metamethod "metamethod" @keyword.storage.modifier)) | ||
(record_body (userdata) @keyword.storage.modifier) | ||
|
||
; Contextual keywords in interface bodies | ||
(interface_declaration | ||
. [ "interface" ] @keyword.storage.type | ||
name: (identifier) @type) | ||
(anon_interface . "interface" @keyword.storage.type) | ||
(interface_body | ||
(record_declaration | ||
. [ "record" ] @keyword.storage.type | ||
. name: (identifier) @type)) | ||
(interface_body | ||
(enum_declaration | ||
. [ "enum" ] @keyword.storage.type | ||
. name: (identifier) @type.enum)) | ||
(interface_body | ||
(interface_declaration | ||
. [ "interface" ] @keyword.storage.type | ||
. name: (identifier) @type)) | ||
(interface_body | ||
(typedef | ||
. "type" @keyword.storage.type | ||
. name: (identifier) @type . "=")) | ||
(interface_body | ||
(macroexp_declaration | ||
. [ "macroexp" ] @keyword.storage.type)) | ||
(interface_body (metamethod "metamethod" @keyword.storage.modifier)) | ||
(interface_body (userdata) @keyword.storage.modifier) | ||
|
||
(enum_declaration | ||
"enum" @keyword.storage.type | ||
name: (identifier) @type.enum) | ||
|
||
(type_declaration "type" @keyword.storage.type) | ||
(type_declaration (identifier) @type) | ||
(simple_type) @type | ||
(type_index) @type | ||
(type_union "|" @operator) | ||
(function_type "function" @type) | ||
|
||
;; The rest of it | ||
(var_declaration | ||
declarators: (var_declarators | ||
(var name: (identifier) @variable))) | ||
(var_declaration | ||
declarators: (var_declarators | ||
(var | ||
"<" @punctuation.bracket | ||
. attribute: (attribute) @attribute | ||
. ">" @punctuation.bracket))) | ||
[ "(" ")" "[" "]" "{" "}" ] @punctuation.bracket | ||
|
||
;; Only highlight format specifiers in calls to string.format | ||
;; string.format('...') | ||
;(function_call | ||
; called_object: (index | ||
; (identifier) @base | ||
; key: (identifier) @entry) | ||
; arguments: (arguments . | ||
; (string (format_specifier) @string.escape)) | ||
; | ||
; (#eq? @base "string") | ||
; (#eq? @entry "format")) | ||
|
||
;; ('...'):format() | ||
;(function_call | ||
; called_object: (method_index | ||
; (string (format_specifier) @string.escape) | ||
; key: (identifier) @func-name) | ||
; (#eq? @func-name "format")) | ||
|
||
|
||
(ERROR) @error |
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,26 @@ | ||
|
||
(var_declaration | ||
declarators: (var_declarators | ||
(var (identifier)) @local.definition.var)) | ||
|
||
(var_assignment | ||
variables: (assignment_variables | ||
(var (identifier) @local.definition.var) @local.definition.associated)) | ||
|
||
(arg name: (identifier) @local.definition.parameter) | ||
|
||
(anon_function) @local.scope | ||
((function_statement | ||
(function_name) @local.definition.function) @local.scope | ||
(#set! local.definition.function.local.scope "parent")) | ||
|
||
(program) @local.scope | ||
(if_statement) @local.scope | ||
(generic_for_statement (for_body) @local.scope) | ||
(numeric_for_statement (for_body) @local.scope) | ||
(repeat_statement) @local.scope | ||
(while_statement (while_body) @local.scope) | ||
(do_statement) @local.scope | ||
|
||
(identifier) @local.reference | ||
|
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.
It looks like the tree-sitter-teal repo doesn't have a LICENSE yet. Could you propose adding one and update the commit here once one is merged?
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.
Issue filed: euclidianAce/tree-sitter-teal#36. Though, I'm not sure how active is the maintainer, I hope it will be resolved soon.