Skip to content

Commit

Permalink
Merge pull request #33 from bertbaron/main
Browse files Browse the repository at this point in the history
feat: highlight query file
  • Loading branch information
Peefy authored Feb 4, 2025
2 parents 3dbc657 + 13b5007 commit ca62a22
Show file tree
Hide file tree
Showing 6 changed files with 206 additions and 0 deletions.
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

0 comments on commit ca62a22

Please sign in to comment.