Compare commits
10 commits
752f941589
...
2d89ec8b20
Author | SHA1 | Date | |
---|---|---|---|
Bruno BELANYI | 2d89ec8b20 | ||
Bruno BELANYI | 073ff80adb | ||
Bruno BELANYI | 64ff9dd944 | ||
Bruno BELANYI | bd42c2c9c1 | ||
Bruno BELANYI | aff11eefce | ||
Bruno BELANYI | b22ca8cd67 | ||
Bruno BELANYI | 5f38f649bd | ||
Bruno BELANYI | b998075f2d | ||
Bruno BELANYI | 62a601469e | ||
Bruno BELANYI | 67b555c381 |
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,3 +1,6 @@
|
|||
# Nix files
|
||||
/result
|
||||
/.pre-commit-config.yaml
|
||||
|
||||
# Tree-sitter artifact
|
||||
/tree-sitter-tiger.wasm
|
||||
|
|
|
@ -115,7 +115,7 @@
|
|||
default = pkgs.mkShell {
|
||||
nativeBuildInputs = with pkgs; [
|
||||
nodejs
|
||||
tree-sitter
|
||||
(tree-sitter.override { webUISupport = true; })
|
||||
];
|
||||
|
||||
inherit (checks.pre-commit) shellHook;
|
||||
|
|
|
@ -1,12 +1,23 @@
|
|||
; Misc {{{
|
||||
(comment) @comment
|
||||
|
||||
(type_identifier) @type
|
||||
(field_identifier) @property
|
||||
(identifier) @variable
|
||||
; Built-ins {{{
|
||||
((function_call
|
||||
function: (identifier) @function.builtin)
|
||||
(#match? @function.builtin "^(chr|concat|exit|flush|getchar|not|ord|print|print_err|print_int|size|strcmp|streq|substring)$")
|
||||
(#is-not? local))
|
||||
; }}}
|
||||
|
||||
; Keywords {{{
|
||||
[
|
||||
"function"
|
||||
"primitive"
|
||||
] @keyword.function
|
||||
|
||||
[
|
||||
"do"
|
||||
"for"
|
||||
"to"
|
||||
"while"
|
||||
] @keyword.repeat
|
||||
|
||||
[
|
||||
"array"
|
||||
(break_expression)
|
||||
|
@ -29,13 +40,6 @@
|
|||
] @keyword
|
||||
; }}}
|
||||
|
||||
; Literals {{{
|
||||
(nil_literal) @constant.builtin
|
||||
(integer_literal) @number
|
||||
(string_literal) @string
|
||||
(escape_sequence) @string.escape
|
||||
; }}}
|
||||
|
||||
; Operators {{{
|
||||
(operator) @operator
|
||||
|
||||
|
@ -56,4 +60,36 @@
|
|||
] @punctuation.bracket
|
||||
; }}}
|
||||
|
||||
; Functions {{{
|
||||
(function_call
|
||||
function: (identifier) @function)
|
||||
(function_declaration
|
||||
name: (identifier) @function)
|
||||
(primitive_declaration
|
||||
name: (identifier) @function)
|
||||
|
||||
(parameters
|
||||
name: (identifier) @variable.parameter)
|
||||
; }}}
|
||||
|
||||
; Declarations {{{
|
||||
(import_declaration
|
||||
file: (string_literal) @string.special.path)
|
||||
; }}}
|
||||
|
||||
; Literals {{{
|
||||
(nil_literal) @constant.builtin
|
||||
(integer_literal) @number
|
||||
(string_literal) @string
|
||||
(escape_sequence) @string.escape
|
||||
; }}}
|
||||
|
||||
; Misc {{{
|
||||
(comment) @comment
|
||||
|
||||
(type_identifier) @type
|
||||
(field_identifier) @property
|
||||
(identifier) @variable
|
||||
; }}}
|
||||
|
||||
; vim: sw=2 foldmethod=marker
|
||||
|
|
29
queries/locals.scm
Normal file
29
queries/locals.scm
Normal file
|
@ -0,0 +1,29 @@
|
|||
; Scopes {{{
|
||||
[
|
||||
(for_expression)
|
||||
(let_expression)
|
||||
(function_declaration)
|
||||
] @local.scope
|
||||
; }}}
|
||||
|
||||
; Definitions {{{
|
||||
(type_declaration
|
||||
name: (identifier) @local.definition)
|
||||
|
||||
(parameters
|
||||
name: (identifier) @local.definition)
|
||||
|
||||
(function_declaration
|
||||
name: (identifier) @local.definition)
|
||||
(primitive_declaration
|
||||
name: (identifier) @local.definition)
|
||||
|
||||
(variable_declaration
|
||||
name: (identifier) @local.definition)
|
||||
; }}}
|
||||
|
||||
; References {{{
|
||||
(identifier) @local.reference
|
||||
; }}}
|
||||
|
||||
; vim: sw=2 foldmethod=marker
|
19
test/highlight/built-ins.tig
Normal file
19
test/highlight/built-ins.tig
Normal file
|
@ -0,0 +1,19 @@
|
|||
let
|
||||
var a := exit(0)
|
||||
/* ^ function.builtin */
|
||||
|
||||
primitive exit(ret: int) /* Shadowing the prelude-included built-in */
|
||||
|
||||
var b := exit(0)
|
||||
/* ^ function */
|
||||
|
||||
in
|
||||
exit(1);
|
||||
/* <- function */
|
||||
|
||||
print("shadowing is fun");
|
||||
/* <- function.builtin */
|
||||
|
||||
b := print
|
||||
/* ^ variable */
|
||||
end
|
8
test/highlight/functions.tig
Normal file
8
test/highlight/functions.tig
Normal file
|
@ -0,0 +1,8 @@
|
|||
primitive print(s: string)
|
||||
/* ^ function */
|
||||
/* ^ variable.parameter */
|
||||
|
||||
function func(a: int) : int = (print("Hello World!"); a)
|
||||
/* ^ function */
|
||||
/* ^ variable.parameter */
|
||||
/* ^ function */
|
|
@ -22,8 +22,8 @@ var array := int_array[12] of 27;
|
|||
/* ^ type */
|
||||
|
||||
primitive func(a: int, b: string) : array
|
||||
/* ^ variable */
|
||||
/* ^ variable.parameter */
|
||||
/* ^ type */
|
||||
/* ^ variable */
|
||||
/* ^ variable.parameter */
|
||||
/* ^ type */
|
||||
/* ^ type */
|
||||
|
|
3
test/highlight/imports.tig
Normal file
3
test/highlight/imports.tig
Normal file
|
@ -0,0 +1,3 @@
|
|||
import "lib.tih"
|
||||
/* <- keyword */
|
||||
/* ^ string.special.path */
|
|
@ -5,9 +5,9 @@ let
|
|||
/* <- keyword */
|
||||
|
||||
function f() : int = a
|
||||
/* <- keyword */
|
||||
/* <- keyword.function */
|
||||
primitive g()
|
||||
/* <- keyword */
|
||||
/* <- keyword.function */
|
||||
|
||||
import "lib.tih"
|
||||
/* <- keyword */
|
||||
|
@ -28,13 +28,13 @@ in
|
|||
/* ^ keyword */
|
||||
|
||||
for i := 12 to 27 do 42;
|
||||
/* <- keyword */
|
||||
/* ^ keyword */
|
||||
/* ^ keyword */
|
||||
/* <- keyword.repeat */
|
||||
/* ^ keyword.repeat */
|
||||
/* ^ keyword.repeat */
|
||||
|
||||
while 12 do break
|
||||
/* <- keyword */
|
||||
/* ^ keyword */
|
||||
/* <- keyword.repeat */
|
||||
/* ^ keyword.repeat */
|
||||
/* ^ keyword */
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue