Skip to content
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: highlight query file #33

Merged
merged 1 commit into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 114 additions & 0 deletions queries/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
(identifier) @variable

(import_stmt
(dotted_name
(identifier) @namespace))

(import_stmt
(dotted_name
(identifier) @namespace)
(identifier) @namespace)

(basic_type) @type

(schema_type
(dotted_name
(identifier) @type))

(schema_type
(dotted_name
(identifier) @namespace
(identifier) @type))

(schema_expr
(identifier) @type)

(protocol_stmt
(identifier) @type)

(rule_stmt
(identifier) @type)

(schema_stmt
(identifier) @type)

(lambda_expr
(typed_parameter (identifier) @parameter))

(lambda_expr
(identifier) @parameter)

(selector_expr
(select_suffix
(identifier) @property))

(comment) @comment
(string) @string
(escape_sequence) @escape

(call_expr
(identifier) @function)

[
(integer)
(float)
] @number

[
(true)
(false)
(none)
(undefined)
] @constant.builtin

[
"all"
"any"
"assert"
"as"
"check"
"elif"
"else"
"filter"
"for"
"if"
"import"
"lambda"
"map"
"mixin"
"protocol"
"rule"
"schema"
"type"
] @keyword

[
"+"
"-"
"*"
"**"
"/"
"//"
"%"
"<<"
">>"
"&"
"|"
"^"
"<"
">"
"~"
"<="
">="
"=="
"!="
"@"
; "\\"
"and"
"or"
"not"
"in"
"is"
"="
":"
] @operator
24 changes: 24 additions & 0 deletions test/highlight/import.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import regex
# ^ keyword
# ^ namespace

import regex.v1
# ^ keyword
# ^ namespace
# ^ namespace

import regex as rxp
# ^ keyword
# ^ namespace
# ^ keyword
# ^ namespace

import regex.v1 as rxp
# ^ keyword
# ^ namespace
# ^ keyword
# ^ namespace

import ...regex
# ^ keyword
# ^ namespace
12 changes: 12 additions & 0 deletions test/highlight/lambda.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
lambda fullname: Person, lastname {
# ^ keyword
# ^ parameter
# ^ type
# ^ parameter
x.name + " " + str(lastname)
# <- variable
# ^ property
# ^ string
# ^ function
# ^ variable
}
15 changes: 15 additions & 0 deletions test/highlight/literal.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
33
# <- number

3.14
# <- number

"all"
# <- string

{
key = value
# <- variable
# ^ operator
# ^ variable
}
23 changes: 23 additions & 0 deletions test/highlight/schema.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
schema Person:
#^ @keyword
# ^ type
age: str = 33
# ^ variable
# ^ type
# ^ number

protocol DataProtocol:
#^ @keyword
# ^ type
data: str
# ^ variable
# ^ type

rule SomeRule:
#^ @keyword
# ^ type
age > 0, "rule check failure message"
# ^ variable
# ^ operator
# ^ number
# ^ string
18 changes: 18 additions & 0 deletions test/highlight/type.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
a: int
# <- variable
# ^ type

b: float
# ^ type

c: bool
# ^ type

d: str
# ^ type

e: None
# ^ type

f: Undefined
# ^ type
Loading