diff options
Diffstat (limited to 'queries/jai')
| -rw-r--r-- | queries/jai/context.scm | 8 | ||||
| -rw-r--r-- | queries/jai/highlights.scm | 261 | ||||
| -rw-r--r-- | queries/jai/indents.scm | 67 |
3 files changed, 336 insertions, 0 deletions
diff --git a/queries/jai/context.scm b/queries/jai/context.scm new file mode 100644 index 0000000..aebefb7 --- /dev/null +++ b/queries/jai/context.scm @@ -0,0 +1,8 @@ +(procedure_declaration) @context +(static_if_statement) @context +(if_statement) @context +(else_clause) @context +(for_statement) @context +(enum_declaration) @context +(struct_declaration) @context +(while_statement) @context
\ No newline at end of file diff --git a/queries/jai/highlights.scm b/queries/jai/highlights.scm new file mode 100644 index 0000000..91b2f19 --- /dev/null +++ b/queries/jai/highlights.scm @@ -0,0 +1,261 @@ +; Includes + +[ + (import) + (load) +] @include + + +; Keywords +[ + ; from modules/Jai_Lexer + "if" + "xx" + + "ifx" + "for" + + "then" + "else" + "null" + "case" + "enum" + "true" + "cast" + + "while" + "break" + "using" + "defer" + "false" + "union" + + "return" + "struct" + "inline" + "remove" + + ; "size_of" + "type_of" + ; "code_of" + ; "context" + + "continue" + "operator" + + ; "type_info" + "no_inline" + "interface" + + "enum_flags" + + ; "is_constant" + + "push_context" + + ; "initializer_of" +] @keyword + +[ + "return" +] @keyword.return + +[ + "if" + "else" + "case" + "break" +] @conditional + +((if_expression + [ + "then" + "ifx" + "else" + ] @conditional.ternary) + (#set! "priority" 105)) + +; Repeats + +[ + "for" + "while" + "continue" +] @repeat + +; Variables + +; (identifier) @variable +name: (identifier) @variable +argument: (identifier) @variable +named_argument: (identifier) @variable +(member_expression (identifier) @variable) +(parenthesized_expression (identifier) @variable) + +((identifier) @variable.builtin + (#any-of? @variable.builtin "context")) + +; Namespaces + +(import (identifier) @namespace) + +; Parameters + +(parameter (identifier) @parameter ":" "="? (identifier)? @constant) + +; (call_expression argument: (identifier) @parameter "=") + +; Functions + +; (procedure_declaration (identifier) @function (procedure (block))) +(procedure_declaration (identifier) @function (block)) + +(call_expression function: (identifier) @function.call) + +; Types + +type: (types) @type +type: (identifier) @type +((types) @type) + +modifier: (identifier) @keyword +keyword: (identifier) @keyword + +((types (identifier) @type.builtin) + (#any-of? @type.builtin + "bool" "int" "string" + "s8" "s16" "s32" "s64" + "u8" "u16" "u32" "u64" + "Type" "Any")) + +(struct_declaration (identifier) @type ":" ":") + +(enum_declaration (identifier) @type ":" ":") + +; (const_declaration (identifier) @type ":" ":" [(array_type) (pointer_type)]) + +; ; I don't like this +; ((identifier) @type +; (#lua-match? @type "^[A-Z][a-zA-Z0-9]*$") +; (#not-has-parent? @type parameter procedure_declaration call_expression)) + +; Fields + +(member_expression "." (identifier) @field) + +(assignment_statement (identifier) @field "="?) +(update_statement (identifier) @field) + +; Constants + +((identifier) @constant + (#lua-match? @constant "^_*[A-Z][A-Z0-9_]*$") + (#not-has-parent? @constant type parameter)) + +(member_expression . "." (identifier) @constant) + +(enum_field (identifier) @constant) + +; Literals + +(integer) @number +(float) @number + +(string) @string + +;(character) @character + +(string_contents (escape_sequence) @string.escape) + +(boolean) @boolean + +[ + (uninitialized) + (null) +] @constant.builtin + +; Operators + +[ + ":" + "=" + "+" + "-" + "*" + "/" + "%" + ">" + ">=" + "<" + "<=" + "==" + "!=" + "|" + "~" + "&" + "&~" + "<<" + ">>" + "<<<" + ">>>" + "||" + "&&" + "!" + ".." + "+=" + "-=" + "*=" + "/=" + "%=" + "&=" + "|=" + "^=" + "<<=" + ">>=" + "<<<=" + ">>>=" + "||=" + "&&=" +] @operator + +; Punctuation + +[ "{" "}" ] @punctuation.bracket + +[ "(" ")" ] @punctuation.bracket + +[ "[" "]" ] @punctuation.bracket + +[ + "`" + "->" + "." + "," + ":" + ";" +] @punctuation.delimiter + +; Comments + +[ + (block_comment) + (comment) +] @spell + +[ + (block_comment) + (comment) +] @comment + +; Errors + +(ERROR) @error + +directive: ("#") @keyword ; #if +type: ("type_of") @type + +(compiler_directive) @keyword +(heredoc_start) @none +(heredoc_end) @none +(heredoc_body) @string +(note) @string diff --git a/queries/jai/indents.scm b/queries/jai/indents.scm new file mode 100644 index 0000000..82b0331 --- /dev/null +++ b/queries/jai/indents.scm @@ -0,0 +1,67 @@ +; Some documentation I found in a random github issue +; @indent.begin ; indent children when matching this node +; @indent.end ; marks the end of indented block +; @indent.align ; behaves like python aligned/hanging indent +; @indent.dedent ; dedent children when matching this node +; @indent.branch ; dedent itself when matching this node +; @indent.ignore ; do not indent in this node +; @indent.auto ; behaves like 'autoindent' buffer option +; @indent.zero ; sets this node at position 0 (no indent) + +; NOTE: these don't work well with Allman style. +; Also; I am really bad at this. There is almost no documentation available and I don't speak lisp or whichever of it's flavors this is. + +; Incomplete + +[ + (block) + (enum_declaration "{") + (struct_or_union_block "{") + (struct_literal "{") + (anonymous_enum_type "{") + (asm_statement "{") + (array_literal "[") + (index_expression "[") + (literal) + (assignment_parameters "(") +] @indent.begin + +((modify_block) @indent.end) +((place_directive) @indent.branch) + +; only indent the first statement after an if +(if_statement_condition_and_consequence + consequence: (_ + ";" @indent.end) @_consequence + (#not-match? @_consequence "\\{") +) @indent.begin + +(else_clause) @indent.branch + +; This is a workaround. I can't get 'else if' indentation to work properly. +(else_clause + consequence: (_) @_consequence + (#match? @_consequence "if") +) @indent.auto + +(if_case_statement) @indent.begin +(switch_case ";") @indent.branch + +((identifier) . (ERROR "(" @indent.begin)) + +(block + "}" @indent.end) + +[ + ")" + "]" + "}" +] @indent.branch @indent.end + +[ + (comment) + (block_comment) + (string) + (ERROR) +] @indent.auto + |
