Skip to content

Commit

Permalink
Get basic syntax highlighting working
Browse files Browse the repository at this point in the history
This pulls the queries and injections straight from the work done for
Helix in [this PR][1], from @zetashift. These should definitely be
upstreamed when possible! They also show up a few bugs in the grammar
as it stands, e.g. keywords get highlighted in the middle of
documentation blocks, where they should be ignored. Still: a start!

[1]: helix-editor/helix#7724
  • Loading branch information
chriskrycho committed Aug 28, 2023
1 parent 5f11305 commit 54aa5e2
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 1 deletion.
72 changes: 71 additions & 1 deletion Queries/highlights.scm
Original file line number Diff line number Diff line change
@@ -1 +1,71 @@
(kw_forall) @keyword
;; Primitives
(comment) @comment
(nat) @constant.numeric
(unit) @constant.builtin
(literal_char) @constant.character
(literal_text) @string
(literal_boolean) @constant.builtin.boolean

;; Keywords
[
(kw_forall)
(unique_kw)
(type_kw)
(kw_equals)
(do)
] @keyword

(kw_let) @keyword.function
(type_kw) @keyword.storage.type
(unique) @keyword.storage.modifier
("use") @keyword.control.import


[
(type_constructor)
] @constructor

[
(operator)
(pipe)
(arrow_symbol)
(">")
(or)
(bang)
] @operator

[
"if"
"else"
"then"
(match)
(with)
(cases)
] @keyword.control.conditional

(blank_pattern) @variable.builtin

;; Types
(record_field name: (wordy_id) @variable.other.member type: (wordy_id) @type)
[
(type_name)
(type_signature)
(effect)
] @type

(term_definition) @variable

;; Punctuation
[
(type_signature_colon)
":"
] @punctuation.delimiter

[
"("
")"
"{"
"}"
"["
"]"
] @punctuation.bracket
1 change: 1 addition & 0 deletions Queries/injections.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
((doc_block) @injection.content (#set! injection.language "markdown"))
1 change: 1 addition & 0 deletions Syntaxes/unison.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@
<highlights path="highlights.scm" />
<folds path="folds.scm" />
<symbols path="symbols.scm" />
<injections />
</tree-sitter>
</syntax>

0 comments on commit 54aa5e2

Please sign in to comment.