Skip to content

Commit

Permalink
Implement the necessary queries
Browse files Browse the repository at this point in the history
This implements all highlights, locals, and tags.
  • Loading branch information
yorickpeterse committed May 1, 2024
1 parent 75ba7ad commit ae17524
Show file tree
Hide file tree
Showing 9 changed files with 16,174 additions and 15,562 deletions.
12 changes: 8 additions & 4 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,13 +374,17 @@ module.exports = grammar({

// Method calls
_call_name: $ => choice(
alias($.identifier_with_special, $.identifier),
$.identifier,
$.constant,
// Identifiers are aliased as "name" such that highliths don't conflict
// with locals (e.g. ensuring `name` in `self.name` doesn't get
// highlighted as a variable if a local variable with the same name
// exists).
alias($.identifier_with_special, $.name),
alias($.identifier, $.name),
alias($.constant, $.name),
$.integer,
),
call: $ => choice(
seq(field('name', alias($.identifier_with_special, $.identifier))),
seq(field('name', alias($.identifier_with_special, $.name))),
seq(
field('name', $._call_name),
field('arguments', alias($.call_arguments, $.arguments)),
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@
"scope": "source.inko",
"injection-regex": "^inko$",
"file-types": ["inko"],
"highlights": ["queries/highlights.scm"]
"highlights": ["queries/highlights.scm"],
"locals": ["queries/locals.scm"],
"tags": ["queries/tags.scm"]
}
]
}
29 changes: 18 additions & 11 deletions queries/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,16 @@
"ref"
"trait"
"uni"
;"break"
;"else"
;"loop"
;"match"
;"move"
;"next"
"loop"
"match"
"else"
"move"
"or"
;"recover"
;"return"
;"throw"
;"try"
;"while"
"recover"
"return"
"throw"
"try"
"while"
(modifier)
(visibility)
] @keyword
Expand All @@ -70,6 +68,8 @@
[
(nil)
(self)
(break)
(next)
] @keyword

[
Expand Down Expand Up @@ -114,3 +114,10 @@
; Methods
(method name: _ @function)
(external_function name: _ @function)
(argument name: _ @variable)
(named_argument name: _ @variable)

(call name: _ @function)
(identifier) @variable
((identifier) @function
(#is-not? local))
10 changes: 10 additions & 0 deletions queries/locals.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
(method)
(block)
] @local.scope

(argument name: _ @local.definition)
(define_variable name: _ @local.definition)
(named_argument name: _ @local.definition)

(identifier) @local.reference
4 changes: 4 additions & 0 deletions queries/tags.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(method name: _ @name) @definition.function
(external_function name: _ @name) @definition.function
(class name: _ @name) @definition.class
(trait name: _ @name) @definition.interface
22 changes: 16 additions & 6 deletions src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 8 additions & 12 deletions src/node-types.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ae17524

Please sign in to comment.