nix

configuration files that power my machines
Log | Files | Refs | README | LICENSE

commit 18fa8e3b4602e2c0f0ad9aba4bb23181c179d919
parent a33d29f88bada9e40ad78edea092a6f77d2e2b85
Author: mtmn <miro@haravara.org>
Date:   Wed,  8 Apr 2026 12:44:02 +0200

ad: fix tree-sitter, add parsers

Diffstat:
Mmodules/mixins/dotfiles/home/ad/config.toml | 18+-----------------
Amodules/mixins/dotfiles/home/ad/tree-sitter/parsers/rust.so | 0
Amodules/mixins/dotfiles/home/ad/tree-sitter/queries/awk/highlights.scm | 199+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amodules/mixins/dotfiles/home/ad/tree-sitter/queries/bash/highlights.scm | 253+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amodules/mixins/dotfiles/home/ad/tree-sitter/queries/c/highlights.scm | 329+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amodules/mixins/dotfiles/home/ad/tree-sitter/queries/dart/highlights.scm | 212+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amodules/mixins/dotfiles/home/ad/tree-sitter/queries/graphql/highlights.scm | 92+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amodules/mixins/dotfiles/home/ad/tree-sitter/queries/ini/highlights.scm | 16++++++++++++++++
Amodules/mixins/dotfiles/home/ad/tree-sitter/queries/json/highlights.scm | 24++++++++++++++++++++++++
Amodules/mixins/dotfiles/home/ad/tree-sitter/queries/just/highlights.scm | 133+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amodules/mixins/dotfiles/home/ad/tree-sitter/queries/make/highlights.scm | 170+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amodules/mixins/dotfiles/home/ad/tree-sitter/queries/markdown/highlights.scm | 99+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amodules/mixins/dotfiles/home/ad/tree-sitter/queries/plumbing_rules/highlights.scm | 16++++++++++++++++
Amodules/mixins/dotfiles/home/ad/tree-sitter/queries/proto/highlights.scm | 79+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amodules/mixins/dotfiles/home/ad/tree-sitter/queries/python/highlights.scm | 418+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amodules/mixins/dotfiles/home/ad/tree-sitter/queries/r/highlights.scm | 143+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amodules/mixins/dotfiles/home/ad/tree-sitter/queries/rust/highlights.scm | 161+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amodules/mixins/dotfiles/home/ad/tree-sitter/queries/rust/injections.scm | 9+++++++++
Amodules/mixins/dotfiles/home/ad/tree-sitter/queries/rust/tags.scm | 60++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amodules/mixins/dotfiles/home/ad/tree-sitter/queries/scheme/highlights.scm | 22++++++++++++++++++++++
Amodules/mixins/dotfiles/home/ad/tree-sitter/queries/sql/highlights.scm | 338+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amodules/mixins/dotfiles/home/ad/tree-sitter/queries/swift/highlights.scm | 347+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amodules/mixins/dotfiles/home/ad/tree-sitter/queries/toml/highlights.scm | 31+++++++++++++++++++++++++++++++
Amodules/mixins/dotfiles/home/ad/tree-sitter/queries/yaml/highlights.scm | 75+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
24 files changed, 3227 insertions(+), 17 deletions(-)

diff --git a/modules/mixins/dotfiles/home/ad/config.toml b/modules/mixins/dotfiles/home/ad/config.toml @@ -1,35 +1,19 @@ -# Config file for the ad text editor -# For details of the TOML file format see https://toml.io/en/v1.0.0 - -# Top level config options [editor] -# Display a welcome message when opening the editor without any files -show_splash = true -# Whether or not tab characters should be automatically replaced with `tabstop` spaces +show_splash = false expand_tab = true -# The number of spaces to render tab characters with tabstop = 4 -# Whether or not leading whitespace should be copied to new lines on pressing Return match_indent = true -# Number of seconds to persist status messages for status_timeout = 3 -# Number of milliseconds allowed between left mouse clicks for registering a double click double_click_ms = 200 -# Maximum number of lines used when rendering the minibuffer state minibuffer_lines = 8 -# Shell command to be used for listing files when running the `find file` and `find repo file` commands find_command = "fd --hidden" [filesystem] -# Whether or not the 9p filesystem interface should be enabled or not enabled = true -# Whether or not the 9p filesystem interface should attempt to automount via fuse on startup auto_mount = false -# Configuration for tree-sitter based syntax highlighting. See :help for details on the required -# directory structure. [tree_sitter] # The directory to search for compiled *.so files for parsing each language. parser_dir = "~/.ad/tree-sitter/parsers" diff --git a/modules/mixins/dotfiles/home/ad/tree-sitter/parsers/rust.so b/modules/mixins/dotfiles/home/ad/tree-sitter/parsers/rust.so Binary files differ. diff --git a/modules/mixins/dotfiles/home/ad/tree-sitter/queries/awk/highlights.scm b/modules/mixins/dotfiles/home/ad/tree-sitter/queries/awk/highlights.scm @@ -0,0 +1,199 @@ +; adapted from https://github.com/Beaglefoot/tree-sitter-awk +[ + (identifier) + (field_ref) +] @variable + +(field_ref + (_) @variable) + +; https://www.gnu.org/software/gawk/manual/html_node/Auto_002dset.html +((identifier) @constant.builtin + (#any-of? @constant.builtin + "ARGC" "ARGV" "ARGIND" "ENVIRON" "ERRNO" "FILENAME" "FNR" "NF" "FUNCTAB" "NR" "PROCINFO" + "RLENGTH" "RSTART" "RT" "SYMTAB")) + +; https://www.gnu.org/software/gawk/manual/html_node/User_002dmodified.html +((identifier) @variable.builtin + (#any-of? @variable.builtin + "BINMODE" "CONVFMT" "FIELDWIDTHS" "FPAT" "FS" "IGNORECASE" "LINT" "OFMT" "OFS" "ORS" "PREC" + "ROUNDMODE" "RS" "SUBSEP" "TEXTDOMAIN")) + +(number) @number + +(string) @string + +(regex) @string.regexp + +(escape_sequence) @string.escape + +(comment) @comment + +((program + . + (comment) @keyword.directive) + (#match? @keyword.directive "^#!/")) + +(ns_qualified_name + (namespace) @module) + +(ns_qualified_name + "::" @punctuation.delimiter) + +(func_def + name: (_ + (identifier) @function) @function) + +(func_call + name: (_ + (identifier) @function) @function) + +(func_def + (param_list + (identifier) @variable.parameter)) + +[ + "print" + "printf" + "getline" +] @function.builtin + +[ + (delete_statement) + (break_statement) + (continue_statement) + (next_statement) + (nextfile_statement) +] @keyword + +[ + "func" + "function" +] @keyword.function + +[ + "return" + "exit" +] @keyword.return + +[ + "do" + "while" + "for" + "in" +] @keyword.repeat + +[ + "if" + "else" + "switch" + "case" + "default" +] @keyword.conditional + +[ + "@include" + "@load" +] @keyword.import + +"@namespace" @keyword.directive + +[ + "BEGIN" + "END" + "BEGINFILE" + "ENDFILE" +] @label + +(binary_exp + [ + "^" + "**" + "*" + "/" + "%" + "+" + "-" + "<" + ">" + "<=" + ">=" + "==" + "!=" + "~" + "!~" + "in" + "&&" + "||" + ] @operator) + +(unary_exp + [ + "!" + "+" + "-" + ] @operator) + +(assignment_exp + [ + "=" + "+=" + "-=" + "*=" + "/=" + "%=" + "^=" + ] @operator) + +(ternary_exp + [ + "?" + ":" + ] @keyword.conditional.ternary) + +(update_exp + [ + "++" + "--" + ] @operator) + +(redirected_io_statement + [ + ">" + ">>" + ] @operator) + +(piped_io_statement + [ + "|" + "|&" + ] @operator) + +(piped_io_exp + [ + "|" + "|&" + ] @operator) + +(field_ref + "$" @punctuation.delimiter) + +(regex + "/" @punctuation.delimiter) + +(regex_constant + "@" @punctuation.delimiter) + +[ + ";" + "," +] @punctuation.delimiter + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket diff --git a/modules/mixins/dotfiles/home/ad/tree-sitter/queries/bash/highlights.scm b/modules/mixins/dotfiles/home/ad/tree-sitter/queries/bash/highlights.scm @@ -0,0 +1,253 @@ +[ + "(" + ")" + "{" + "}" + "[" + "]" + "[[" + "]]" + "((" + "))" +] @punctuation.bracket + +[ + ";" + ";;" + ";&" + ";;&" + "&" +] @punctuation.delimiter + +[ + ">" + ">>" + "<" + "<<" + "&&" + "|" + "|&" + "||" + "=" + "+=" + "=~" + "==" + "!=" + "&>" + "&>>" + "<&" + ">&" + ">|" + "<&-" + ">&-" + "<<-" + "<<<" + ".." + "!" +] @operator + +[ + (string) + (raw_string) + (ansi_c_string) + (heredoc_body) +] @string + +[ + (heredoc_start) + (heredoc_end) +] @string + +(variable_assignment + (word) @string) + +(command argument: "$" @string) ; bare dollar + +(concatenation (word) @string) + +[ + "if" + "then" + "else" + "elif" + "fi" + "case" + "in" + "esac" +] @keyword.conditional + +[ + "for" + "do" + "done" + "select" + "until" + "while" +] @keyword.repeat + +[ + "declare" + "typeset" + "readonly" + "local" + "unset" + "unsetenv" +] @keyword + +"export" @keyword.import + +"function" @keyword.function + +(special_variable_name) @constant + +; trap -l +((word) @constant.builtin + (#any-of? @constant.builtin + "SIGHUP" "SIGINT" "SIGQUIT" "SIGILL" "SIGTRAP" "SIGABRT" "SIGBUS" "SIGFPE" "SIGKILL" "SIGUSR1" + "SIGSEGV" "SIGUSR2" "SIGPIPE" "SIGALRM" "SIGTERM" "SIGSTKFLT" "SIGCHLD" "SIGCONT" "SIGSTOP" + "SIGTSTP" "SIGTTIN" "SIGTTOU" "SIGURG" "SIGXCPU" "SIGXFSZ" "SIGVTALRM" "SIGPROF" "SIGWINCH" + "SIGIO" "SIGPWR" "SIGSYS" "SIGRTMIN" "SIGRTMIN+1" "SIGRTMIN+2" "SIGRTMIN+3" "SIGRTMIN+4" + "SIGRTMIN+5" "SIGRTMIN+6" "SIGRTMIN+7" "SIGRTMIN+8" "SIGRTMIN+9" "SIGRTMIN+10" "SIGRTMIN+11" + "SIGRTMIN+12" "SIGRTMIN+13" "SIGRTMIN+14" "SIGRTMIN+15" "SIGRTMAX-14" "SIGRTMAX-13" + "SIGRTMAX-12" "SIGRTMAX-11" "SIGRTMAX-10" "SIGRTMAX-9" "SIGRTMAX-8" "SIGRTMAX-7" "SIGRTMAX-6" + "SIGRTMAX-5" "SIGRTMAX-4" "SIGRTMAX-3" "SIGRTMAX-2" "SIGRTMAX-1" "SIGRTMAX")) + +((word) @boolean + (#any-of? @boolean "true" "false")) + +(comment) @comment + +(test_operator) @operator + +(command_substitution + "$(" @punctuation.special + ")" @punctuation.special) + +(process_substitution + [ + "<(" + ">(" + ] @punctuation.special + ")" @punctuation.special) + +(arithmetic_expansion + [ + "$((" + "((" + ] @punctuation.special + "))" @punctuation.special) + +(arithmetic_expansion + "," @punctuation.delimiter) + +(ternary_expression + [ + "?" + ":" + ] @keyword.conditional.ternary) + +(binary_expression + operator: _ @operator) + +(unary_expression + operator: _ @operator) + +(postfix_expression + operator: _ @operator) + +(function_definition + name: (word) @function) + +(command_name + (word) @function.call) + +(command_name + (word) @function.builtin + (#any-of? @function.builtin + "." ":" "alias" "bg" "bind" "break" "builtin" "caller" "cd" "command" "compgen" "complete" + "compopt" "continue" "coproc" "dirs" "disown" "echo" "enable" "eval" "exec" "exit" "false" "fc" + "fg" "getopts" "hash" "help" "history" "jobs" "kill" "let" "logout" "mapfile" "popd" "printf" + "pushd" "pwd" "read" "readarray" "return" "set" "shift" "shopt" "source" "suspend" "test" "time" + "times" "trap" "true" "type" "typeset" "ulimit" "umask" "unalias" "wait")) + +(command + argument: [ + (word) @variable.parameter + (concatenation + (word) @variable.parameter) + ]) + +(declaration_command + (word) @variable.parameter) + +(unset_command + (word) @variable.parameter) + +(number) @number + +((word) @number + (#match? @number "^[0-9]+$")) + +(file_redirect + destination: (word) @variable.parameter) + +(file_descriptor) @operator + +(simple_expansion + "$" @punctuation.special) @none + +(expansion + "${" @punctuation.special + "}" @punctuation.special) @none + +(expansion + operator: _ @punctuation.special) + +(expansion + "@" + . + operator: _ @character.special) + +((expansion + (subscript + index: (word) @character.special)) + (#any-of? @character.special "@" "*")) + +"``" @punctuation.special + +(variable_name) @variable + +((variable_name) @constant + (#match? @constant "^[A-Z][A-Z_0-9]*$")) + +((variable_name) @variable.builtin + (#any-of? @variable.builtin + ; https://www.gnu.org/software/bash/manual/html_node/Bourne-Shell-Variables.html + "CDPATH" "HOME" "IFS" "MAIL" "MAILPATH" "OPTARG" "OPTIND" "PATH" "PS1" "PS2" + ; https://www.gnu.org/software/bash/manual/html_node/Bash-Variables.html + "_" "BASH" "BASHOPTS" "BASHPID" "BASH_ALIASES" "BASH_ARGC" "BASH_ARGV" "BASH_ARGV0" "BASH_CMDS" + "BASH_COMMAND" "BASH_COMPAT" "BASH_ENV" "BASH_EXECUTION_STRING" "BASH_LINENO" + "BASH_LOADABLES_PATH" "BASH_REMATCH" "BASH_SOURCE" "BASH_SUBSHELL" "BASH_VERSINFO" + "BASH_VERSION" "BASH_XTRACEFD" "CHILD_MAX" "COLUMNS" "COMP_CWORD" "COMP_LINE" "COMP_POINT" + "COMP_TYPE" "COMP_KEY" "COMP_WORDBREAKS" "COMP_WORDS" "COMPREPLY" "COPROC" "DIRSTACK" "EMACS" + "ENV" "EPOCHREALTIME" "EPOCHSECONDS" "EUID" "EXECIGNORE" "FCEDIT" "FIGNORE" "FUNCNAME" + "FUNCNEST" "GLOBIGNORE" "GROUPS" "histchars" "HISTCMD" "HISTCONTROL" "HISTFILE" "HISTFILESIZE" + "HISTIGNORE" "HISTSIZE" "HISTTIMEFORMAT" "HOSTFILE" "HOSTNAME" "HOSTTYPE" "IGNOREEOF" "INPUTRC" + "INSIDE_EMACS" "LANG" "LC_ALL" "LC_COLLATE" "LC_CTYPE" "LC_MESSAGES" "LC_NUMERIC" "LC_TIME" + "LINENO" "LINES" "MACHTYPE" "MAILCHECK" "MAPFILE" "OLDPWD" "OPTERR" "OSTYPE" "PIPESTATUS" + "POSIXLY_CORRECT" "PPID" "PROMPT_COMMAND" "PROMPT_DIRTRIM" "PS0" "PS3" "PS4" "PWD" "RANDOM" + "READLINE_ARGUMENT" "READLINE_LINE" "READLINE_MARK" "READLINE_POINT" "REPLY" "SECONDS" "SHELL" + "SHELLOPTS" "SHLVL" "SRANDOM" "TIMEFORMAT" "TMOUT" "TMPDIR" "UID")) + +(case_item + value: (word) @variable.parameter) + +[ + (regex) + (extglob_pattern) +] @string.regexp + +((program + . + (comment) @keyword.directive) + (#match? @keyword.directive "^#!/")) diff --git a/modules/mixins/dotfiles/home/ad/tree-sitter/queries/c/highlights.scm b/modules/mixins/dotfiles/home/ad/tree-sitter/queries/c/highlights.scm @@ -0,0 +1,329 @@ +; Lower priority to prefer @variable.parameter when identifier appears in parameter_declaration. +((identifier) @variable + (#set! priority 95)) + +(preproc_def + (preproc_arg) @variable) + +[ + "default" + "goto" + "asm" + "__asm__" +] @keyword + +[ + "enum" + "struct" + "union" + "typedef" +] @keyword.type + +[ + "sizeof" + "offsetof" +] @keyword.operator + +(alignof_expression + . + _ @keyword.operator) + +"return" @keyword.return + +[ + "while" + "for" + "do" + "continue" + "break" +] @keyword.repeat + +[ + "if" + "else" + "case" + "switch" +] @keyword.conditional + +[ + "#if" + "#ifdef" + "#ifndef" + "#else" + "#elif" + "#endif" + "#elifdef" + "#elifndef" + (preproc_directive) +] @keyword.directive + +"#define" @keyword.directive.define + +"#include" @keyword.import + +[ + ";" + ":" + "," + "::" +] @punctuation.delimiter + +"..." @punctuation.special + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +[ + "=" + "-" + "*" + "/" + "+" + "%" + "~" + "|" + "&" + "^" + "<<" + ">>" + "->" + "." + "<" + "<=" + ">=" + ">" + "==" + "!=" + "!" + "&&" + "||" + "-=" + "+=" + "*=" + "/=" + "%=" + "|=" + "&=" + "^=" + ">>=" + "<<=" + "--" + "++" +] @operator + +; Make sure the comma operator is given a highlight group after the comma +; punctuator so the operator is highlighted properly. +(comma_expression + "," @operator) + +[ + (true) + (false) +] @boolean + +(conditional_expression + [ + "?" + ":" + ] @keyword.conditional.ternary) + +(string_literal) @string + +(system_lib_string) @string + +(escape_sequence) @string.escape + +(null) @constant.builtin + +(number_literal) @number + +(char_literal) @character + +(preproc_defined) @function.macro + +(field_designator) @property + +(statement_identifier) @label + +(declaration + type: (type_identifier) @_type + declarator: (identifier) @label + (#eq? @_type "__label__")) + +[ + (type_identifier) + (type_descriptor) +] @type + +(storage_class_specifier) @keyword.modifier + +[ + (type_qualifier) + (gnu_asm_qualifier) + "__extension__" +] @keyword.modifier + +(linkage_specification + "extern" @keyword.modifier) + +(type_definition + declarator: (type_identifier) @type.definition) + +(primitive_type) @type.builtin + +(sized_type_specifier + _ @type.builtin + type: _?) + +((identifier) @constant + (#match? @constant "^[A-Z][A-Z0-9_]+$")) + +(preproc_def + (preproc_arg) @constant + (#match? @constant "^[A-Z][A-Z0-9_]+$")) + +(enumerator + name: (identifier) @constant) + +(case_statement + value: (identifier) @constant) + +((identifier) @constant.builtin + ; format-ignore + (#any-of? @constant.builtin + "stderr" "stdin" "stdout" + "__FILE__" "__LINE__" "__DATE__" "__TIME__" + "__STDC__" "__STDC_VERSION__" "__STDC_HOSTED__" + "__cplusplus" "__OBJC__" "__ASSEMBLER__" + "__BASE_FILE__" "__FILE_NAME__" "__INCLUDE_LEVEL__" + "__TIMESTAMP__" "__clang__" "__clang_major__" + "__clang_minor__" "__clang_patchlevel__" + "__clang_version__" "__clang_literal_encoding__" + "__clang_wide_literal_encoding__" + "__FUNCTION__" "__func__" "__PRETTY_FUNCTION__" + "__VA_ARGS__" "__VA_OPT__")) + +(preproc_def + (preproc_arg) @constant.builtin + ; format-ignore + (#any-of? @constant.builtin + "stderr" "stdin" "stdout" + "__FILE__" "__LINE__" "__DATE__" "__TIME__" + "__STDC__" "__STDC_VERSION__" "__STDC_HOSTED__" + "__cplusplus" "__OBJC__" "__ASSEMBLER__" + "__BASE_FILE__" "__FILE_NAME__" "__INCLUDE_LEVEL__" + "__TIMESTAMP__" "__clang__" "__clang_major__" + "__clang_minor__" "__clang_patchlevel__" + "__clang_version__" "__clang_literal_encoding__" + "__clang_wide_literal_encoding__" + "__FUNCTION__" "__func__" "__PRETTY_FUNCTION__" + "__VA_ARGS__" "__VA_OPT__")) + +(attribute_specifier + (argument_list + (identifier) @variable.builtin)) + +(attribute_specifier + (argument_list + (call_expression + function: (identifier) @variable.builtin))) + +((call_expression + function: (identifier) @function.builtin) + (#match? @function.builtin "^__builtin_")) + +; Preproc def / undef +(preproc_def + name: (_) @constant.macro) + +(preproc_call + directive: (preproc_directive) @_u + argument: (_) @constant.macro + (#eq? @_u "#undef")) + +(preproc_ifdef + name: (identifier) @constant.macro) + +(preproc_elifdef + name: (identifier) @constant.macro) + +(preproc_defined + (identifier) @constant.macro) + +(call_expression + function: (identifier) @function.call) + +(call_expression + function: (field_expression + field: (field_identifier) @function.call)) + +(function_declarator + declarator: (identifier) @function) + +(function_declarator + declarator: (parenthesized_declarator + (pointer_declarator + declarator: (field_identifier) @function))) + +(preproc_function_def + name: (identifier) @function.macro) + +(comment) @comment + +((comment) @comment.documentation + (#match? @comment.documentation "^/[*][*][^*].*[*]/$")) + +; Parameters +(parameter_declaration + declarator: (identifier) @variable.parameter) + +(parameter_declaration + declarator: (array_declarator) @variable.parameter) + +(parameter_declaration + declarator: (pointer_declarator) @variable.parameter) + +; K&R functions +; To enable support for K&R functions, +; add the following lines to your own query config and uncomment them. +; They are commented out as they'll conflict with C++ +; Note that you'll need to have `; extends` at the top of your query file. +; +; (parameter_list (identifier) @variable.parameter) +; +; (function_definition +; declarator: _ +; (declaration +; declarator: (identifier) @variable.parameter)) +; +; (function_definition +; declarator: _ +; (declaration +; declarator: (array_declarator) @variable.parameter)) +; +; (function_definition +; declarator: _ +; (declaration +; declarator: (pointer_declarator) @variable.parameter)) +(preproc_params + (identifier) @variable.parameter) + +[ + "__attribute__" + "__declspec" + "__based" + "__cdecl" + "__clrcall" + "__stdcall" + "__fastcall" + "__thiscall" + "__vectorcall" + (ms_pointer_modifier) + (attribute_declaration) +] @attribute diff --git a/modules/mixins/dotfiles/home/ad/tree-sitter/queries/dart/highlights.scm b/modules/mixins/dotfiles/home/ad/tree-sitter/queries/dart/highlights.scm @@ -0,0 +1,212 @@ +[ + "import" + "library" + "export" + "as" + "show" + "hide" +] @keyword.import + +[ + (case_builtin) + "late" + "required" + "on" + "extends" + "in" + "is" + "new" + "super" + "with" +] @keyword + +[ + "class" + "enum" + "extension" +] @keyword.type + +"return" @keyword.return + +[ + "deferred" + "factory" + "get" + "implements" + "interface" + "library" + "operator" + "mixin" + "part" + "set" + "typedef" +] @keyword + +[ + "async" + "async*" + "sync*" + "await" + "yield" +] @keyword.coroutine + +[ + (const_builtin) + (final_builtin) + "abstract" + "covariant" + "external" + "static" + "final" + "base" + "sealed" +] @keyword.modifier + +[ + "if" + "else" + "switch" + "default" +] @keyword.conditional + +(conditional_expression + [ + "?" + ":" + ] @keyword.conditional.ternary) + +[ + "try" + "throw" + "catch" + "finally" + (break_statement) +] @keyword.exception + +[ + "do" + "while" + "continue" + "for" +] @keyword.repeat + +(class_definition + name: (identifier) @type) + +(constructor_signature + name: (identifier) @type) + +(scoped_identifier + scope: (identifier) @type) + +(function_signature + name: (identifier) @function.method) + +(getter_signature + (identifier) @function.method) + +(setter_signature + name: (identifier) @function.method) + +(enum_declaration + name: (identifier) @type) + +(enum_constant + name: (identifier) @type) + +(void_type) @type + +(type_identifier) @type + +(type_alias + (type_identifier) @type.definition) + +(type_arguments + [ + "<" + ">" + ] @punctuation.bracket) + +(inferred_type) @keyword + + +(identifier) @variable +(this) @variable.builtin + +(dotted_identifier_list) @string +(string_literal) @string + +[ + (hex_integer_literal) + (decimal_integer_literal) + (decimal_floating_point_literal) +] @number + +(symbol_literal) @string.special.symbol +(string_literal) @string + +(true) @boolean +(false) @boolean + +(null_literal) @constant.builtin + +(comment) @comment +(documentation_comment) @comment.documentation + +(function_expression_body + (identifier) @function.call) + +[ + "=>" + ".." + "??" + "==" + "!" + "?" + "&&" + "%" + "<" + ">" + "=" + ">=" + "<=" + "||" + ">>>=" + ">>=" + "<<=" + "&=" + "|=" + "??=" + "%=" + "+=" + "-=" + "*=" + "/=" + "^=" + "~/=" + (shift_operator) + (multiplicative_operator) + (increment_operator) + (is_operator) + (prefix_operator) + (equality_operator) + (additive_operator) +] @operator + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +[ + ";" + "." + "," + ":" + "?." + "?" +] @punctuation.delimiter diff --git a/modules/mixins/dotfiles/home/ad/tree-sitter/queries/graphql/highlights.scm b/modules/mixins/dotfiles/home/ad/tree-sitter/queries/graphql/highlights.scm @@ -0,0 +1,92 @@ +; Types +(scalar_type_definition (name) @type) +(object_type_definition (name) @type) +(interface_type_definition (name) @type) +(union_type_definition (name) @type) +(enum_type_definition (name) @type) +(input_object_type_definition (name) @type) +(scalar_type_extension (name) @type) +(object_type_extension (name) @type) +(interface_type_extension (name) @type) +(union_type_extension (name) @type) +(enum_type_extension (name) @type) +(input_object_type_extension (name) @type) +(named_type (name) @type) + +; Directives +(directive_definition "@" @attribute (name) @attribute) +(directive) @attribute + +; Properties +(field (name) @property) +(field (alias (name) @property)) +(field_definition (name) @property) +(object_value (object_field (name) @property)) +(enum_value (name) @property) + +; Variable Definitions and Arguments +(operation_definition (name) @variable) +(fragment_name (name) @variable) +(input_fields_definition (input_value_definition (name) @variable.parameter)) +(argument (name) @variable.parameter) +(arguments_definition (input_value_definition (name) @variable.parameter)) +(variable_definition (variable) @variable.parameter) +(argument (value (variable) @variable)) + +; Constants +(string_value) @string +(int_value) @number +(float_value) @number.float +(boolean_value) @boolean + +; Literals +(description (string_value) @string.documentation) +(comment) @comment +(directive_location (executable_directive_location) @type.builtin) +(directive_location (type_system_directive_location) @type.builtin) + +; Keywords +[ + "query" + "mutation" + "subscription" + "fragment" + "scalar" + "input" + "extend" + "directive" + "schema" + "on" + "repeatable" + "implements" +] @keyword + +[ + "enum" + "union" + "type" + "interface" +] @keyword.type + +; Punctuation +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +"=" @operator + +[ + "|" + "&" + ":" +] @punctuation.delimiter + +[ + "..." + "!" +] @punctuation.special diff --git a/modules/mixins/dotfiles/home/ad/tree-sitter/queries/ini/highlights.scm b/modules/mixins/dotfiles/home/ad/tree-sitter/queries/ini/highlights.scm @@ -0,0 +1,16 @@ +(section_name + (text) @markup.heading) + +(comment) @comment + +[ + "[" + "]" +] @punctuation.bracket + +"=" @operator + +(setting + (setting_name) @property) + +(setting_value) @string diff --git a/modules/mixins/dotfiles/home/ad/tree-sitter/queries/json/highlights.scm b/modules/mixins/dotfiles/home/ad/tree-sitter/queries/json/highlights.scm @@ -0,0 +1,24 @@ +[ + (true) + (false) +] @boolean + +(null) @constant.builtin +(number) @number +(pair key: (string) @property) +(pair value: (string) @string) +(array (string) @string) + +[ + "," + ":" +] @punctuation.delimiter + +[ + "[" + "]" + "{" + "}" +] @punctuation.bracket + +(escape_sequence) @string.escape diff --git a/modules/mixins/dotfiles/home/ad/tree-sitter/queries/just/highlights.scm b/modules/mixins/dotfiles/home/ad/tree-sitter/queries/just/highlights.scm @@ -0,0 +1,133 @@ +[ + "true" + "false" +] @boolean + +[ + "if" + "else" +] @keyword.conditional + +[ + "alias" + "set" + "shell" + "mod" +] @keyword + +[ + "import" + "export" +] @keyword.import + +[ + ":=" + "?" + "==" + "!=" + "=~" + "@" + "=" + "$" + "*" + "+" + "&&" + "@-" + "-@" + "-" + "/" + ":" +] @operator + +[ + "(" + ")" + "[" + "]" + "{{" + "}}" + "{" + "}" +] @punctuation.bracket + +[ + "`" + "```" +] @punctuation.special + +"," @punctuation.delimiter + +(shebang) @keyword.directive + +(comment) @comment + +[ + (string) + (external_command) +] @string + +(escape_sequence) @string.escape + +(module + (identifier) @module) + +(assignment + (identifier) @variable) + +(alias + (identifier) @variable) + +(value + (identifier) @variable) + +; Recipe definitions +(recipe_header + (identifier) @function) + +(dependency + (identifier) @function.call) + +(dependency_expression + (identifier) @function.call) + +(parameter + (identifier) @variable.parameter) + +(dependency_expression + (expression + (value + (identifier) @variable.parameter))) + +; Fallback highlighting for recipe bodies +(recipe + (recipe_body) @string + (#set! priority 90)) + +; Ref: https://just.systems/man/en/chapter_26.html +;(setting (identifier) @error) +(setting + (identifier) @constant.builtin + (#any-of? @constant.builtin + "allow-duplicate-recipes" "dotenv-filename" "dotenv-load" "dotenv-path" "export" "fallback" + "ignore-comments" "positional-arguments" "tempdir" "windows-powershell" "windows-shell")) + +; Ref: https://just.systems/man/en/chapter_32.html +;(recipe (attribute (identifier) @error)) +(recipe + (attribute + (identifier) @attribute) + (#any-of? @attribute + "confirm" "linux" "macos" "no-cd" "no-exit-message" "no-quiet" "private" "unix" "windows")) + +; Ref: https://just.systems/man/en/chapter_31.html +;(function_call (identifier) @error) +(function_call + (identifier) @function.call + (#any-of? @function.call + "arch" "num_cpus" "os" "os_family" "env_var" "env_var_or_default" "env" "invocation_directory" + "invocation_directory_native" "justfile" "justfile_directory" "just_executable" "quote" + "replace" "replace_regex" "trim" "trim_end" "trim_end_match" "trim_end_matches" "trim_start" + "trim_start_match" "trim_start_matches" "capitalize" "kebabcase" "lowercamelcase" "lowercase" + "shoutykebabcase" "shoutysnakecase" "snakecase" "titlecase" "uppercamelcase" "uppercase" + "absolute_path" "extension" "file_name" "file_stem" "parent_directory" "without_extension" + "clean" "join" "path_exists" "error" "sha256" "sha256_file" "uuid" "semver_matches")) diff --git a/modules/mixins/dotfiles/home/ad/tree-sitter/queries/make/highlights.scm b/modules/mixins/dotfiles/home/ad/tree-sitter/queries/make/highlights.scm @@ -0,0 +1,170 @@ +(comment) @comment + +(conditional + (_ + [ + "ifeq" + "else" + "ifneq" + "ifdef" + "ifndef" + ] @keyword.conditional) + "endif" @keyword.conditional) + +(rule + (targets + (word) @function)) + +(rule + (targets) @_target + (prerequisites + (word) @function + (#eq? @_target ".PHONY"))) + +(rule + (targets + (word) @function.builtin + (#any-of? @function.builtin + ".DEFAULT" ".SUFFIXES" ".DELETE_ON_ERROR" ".EXPORT_ALL_VARIABLES" ".IGNORE" ".INTERMEDIATE" + ".LOW_RESOLUTION_TIME" ".NOTPARALLEL" ".ONESHELL" ".PHONY" ".POSIX" ".PRECIOUS" ".SECONDARY" + ".SECONDEXPANSION" ".SILENT" ".SUFFIXES"))) + +(rule + [ + "&:" + ":" + "::" + "|" + ] @operator) + +[ + "export" + "unexport" +] @keyword.import + +(override_directive + "override" @keyword) + +(include_directive + [ + "include" + "-include" + ] @keyword.import + filenames: (list + (word) @string.special.path)) + +(variable_assignment + name: (word) @string.special.symbol + [ + "?=" + ":=" + "::=" + ; ":::=" + "+=" + "=" + ] @operator) + +(shell_assignment + name: (word) @string.special.symbol + "!=" @operator) + +(define_directive + "define" @keyword + name: (word) @string.special.symbol + [ + "=" + ":=" + "::=" + ; ":::=" + "?=" + "!=" + ]? @operator + "endef" @keyword) + +(variable_assignment + (word) @variable.builtin + (#any-of? @variable.builtin + ".DEFAULT_GOAL" ".EXTRA_PREREQS" ".FEATURES" ".INCLUDE_DIRS" ".RECIPEPREFIX" ".SHELLFLAGS" + ".VARIABLES" "MAKEARGS" "MAKEFILE_LIST" "MAKEFLAGS" "MAKE_RESTARTS" "MAKE_TERMERR" + "MAKE_TERMOUT" "SHELL")) + +; Use string to match bash +(variable_reference + (word) @string) @operator + +(shell_function + [ + "$" + "(" + ")" + ] @operator + "shell" @function.builtin) + +(function_call + [ + "$" + "(" + ")" + ] @operator) + +(substitution_reference + [ + "$" + "(" + ")" + ] @operator) + +(automatic_variable + "$" + _ @character.special + (#set! priority 105)) + +(automatic_variable + [ + "$" + "(" + ")" + ] @operator + (#set! priority 105)) + +(recipe_line + "@" @character.special) + +(function_call + [ + "subst" + "patsubst" + "strip" + "findstring" + "filter" + "filter-out" + "sort" + "word" + "words" + "wordlist" + "firstword" + "lastword" + "dir" + "notdir" + "suffix" + "basename" + "addsuffix" + "addprefix" + "join" + "wildcard" + "realpath" + "abspath" + "error" + "warning" + "info" + "origin" + "flavor" + "foreach" + "if" + "or" + "and" + "call" + "eval" + "file" + "value" + ] @function.builtin) diff --git a/modules/mixins/dotfiles/home/ad/tree-sitter/queries/markdown/highlights.scm b/modules/mixins/dotfiles/home/ad/tree-sitter/queries/markdown/highlights.scm @@ -0,0 +1,99 @@ +(setext_heading + (paragraph) @markup.heading.1 + (setext_h1_underline) @markup.heading.1) + +(setext_heading + (paragraph) @markup.heading.2 + (setext_h2_underline) @markup.heading.2) + +(atx_heading (atx_h1_marker)) @markup.heading.1 +(atx_heading (atx_h2_marker)) @markup.heading.2 +(atx_heading (atx_h3_marker)) @markup.heading.3 +(atx_heading (atx_h4_marker)) @markup.heading.4 +(atx_heading (atx_h5_marker)) @markup.heading.5 +(atx_heading (atx_h6_marker)) @markup.heading.6 + +(info_string) @label + +(pipe_table_header (pipe_table_cell) @markup.heading) +(pipe_table_header "|" @punctuation.special) +(pipe_table_row "|" @punctuation.special) +(pipe_table_delimiter_row "|" @punctuation.special) +(pipe_table_delimiter_cell) @punctuation.special + +(indented_code_block) @markup.raw.block +(fenced_code_block) @markup.raw.block + +(fenced_code_block + (fenced_code_block_delimiter) @markup.raw.block) + +(fenced_code_block + (info_string + (language) @label)) + +[ + (link_destination) +] @markup.link.url + +[ + (link_title) + (link_label) +] @markup.link.label + +((link_label) + . + ":" @punctuation.delimiter) + +[ + (list_marker_plus) + (list_marker_minus) + (list_marker_star) + (list_marker_dot) + (list_marker_parenthesis) +] @markup.list + +(thematic_break) @punctuation.special + +(task_list_marker_unchecked) @markup.list.unchecked +(task_list_marker_checked) @markup.list.checked + +(block_quote) @markup.quote + +[ + (plus_metadata) + (minus_metadata) +] @keyword.directive + +[ + (block_continuation) + (block_quote_marker) +] @punctuation.special + +(backslash_escape) @string.escape + +; From MDeiml/tree-sitter-markdown +; (code_span) @markup.raw + +; (emphasis) @markup.italic + +; (strong_emphasis) @markup.bold + +; (strikethrough) @markup.strikethrough + +; [ +; (backslash_escape) +; (hard_line_break) +; ] @string.escape + +; [ +; (link_label) +; (link_text) +; (link_title) +; (image_description) +; ] @markup.link.label + +; [ +; (link_destination) +; (uri_autolink) +; (email_autolink) +; ] @markup.link.url diff --git a/modules/mixins/dotfiles/home/ad/tree-sitter/queries/plumbing_rules/highlights.scm b/modules/mixins/dotfiles/home/ad/tree-sitter/queries/plumbing_rules/highlights.scm @@ -0,0 +1,16 @@ +(comment) @comment + +(variable_declaration + name: (identifier) @constant + value: (variable_value) @string) + +["data" "src" "dst" "wdir" "arg" "attr" "plumb"] @keyword +["matches" "narrows" "set" "from" "is" "isfile" "isdir" "add" "delete" "to" "start"] @function +["="] @punctuation + +(regex) @string.regex +(value_content) @character +(variable_reference) @string.template + +(plumb_to port: (identifier) @number) +(attr_pair attr: (identifier) @boolean) diff --git a/modules/mixins/dotfiles/home/ad/tree-sitter/queries/proto/highlights.scm b/modules/mixins/dotfiles/home/ad/tree-sitter/queries/proto/highlights.scm @@ -0,0 +1,79 @@ +[ + "extend" + "extensions" + "oneof" + "option" + "reserved" + "syntax" + "to" +] @keyword + +[ + "enum" + "service" + "message" +] @keyword.type + +"rpc" @keyword.function +"returns" @keyword.return + +[ + "optional" + "repeated" + "required" +] @keyword.modifier + +[ + "package" + "import" +] @keyword.import + +[ + (key_type) + (type) + (message_name) + (enum_name) + (service_name) + (rpc_name) + (message_or_enum_type) +] @type + +(enum_field (identifier) @constant) + +(string) @string + +[ + "\"proto3\"" + "\"proto2\"" +] @string.special + +(int_lit) @number +(float_lit) @number.float + +[ + (true) + (false) +] @boolean + +(comment) @comment + +((comment) @comment.documentation + (#match? @comment.documentation "^/[*][*][^*].*[*]/$")) + +[ + "(" + ")" + "[" + "]" + "{" + "}" + "<" + ">" +] @punctuation.bracket + +[ + ";" + "," +] @punctuation.delimiter + +"=" @operator diff --git a/modules/mixins/dotfiles/home/ad/tree-sitter/queries/python/highlights.scm b/modules/mixins/dotfiles/home/ad/tree-sitter/queries/python/highlights.scm @@ -0,0 +1,418 @@ +; From tree-sitter-python licensed under MIT License +; Copyright (c) 2016 Max Brunsfeld +; Variables +(identifier) @variable + +; Reset highlighting in f-string interpolations +(interpolation) @none + +((identifier) @constant.builtin + (#any-of? @constant.builtin + ; https://docs.python.org/3/library/constants.html + "NotImplemented" "Ellipsis" "quit" "exit" "copyright" "credits" "license")) + +"_" @character.special ; match wildcard + + +((assignment + left: (identifier) @type.definition + (type + (identifier) @_annotation)) + (#eq? @_annotation "TypeAlias")) + +((assignment + left: (identifier) @type.definition + right: (call + function: (identifier) @_func)) + (#any-of? @_func "TypeVar" "NewType")) + +; Function calls +(call + function: (identifier) @function.call) + +(call + function: (attribute + attribute: (identifier) @function.method.call)) + +; Decorators +((decorator + "@" @attribute) + (#set! priority 101)) + +(decorator + (identifier) @attribute) + +(decorator + (attribute + attribute: (identifier) @attribute)) + +(decorator + (call + (identifier) @attribute)) + +(decorator + (call + (attribute + attribute: (identifier) @attribute))) + +((decorator + (identifier) @attribute.builtin) + (#any-of? @attribute.builtin "classmethod" "property" "staticmethod")) + +; Builtin functions +((call + function: (identifier) @function.builtin) + (#any-of? @function.builtin + "abs" "all" "any" "ascii" "bin" "bool" "breakpoint" "bytearray" "bytes" "callable" "chr" + "classmethod" "compile" "complex" "delattr" "dict" "dir" "divmod" "enumerate" "eval" "exec" + "filter" "float" "format" "frozenset" "getattr" "globals" "hasattr" "hash" "help" "hex" "id" + "input" "int" "isinstance" "issubclass" "iter" "len" "list" "locals" "map" "max" "memoryview" + "min" "next" "object" "oct" "open" "ord" "pow" "print" "property" "range" "repr" "reversed" + "round" "set" "setattr" "slice" "sorted" "staticmethod" "str" "sum" "super" "tuple" "type" + "vars" "zip" "__import__")) + +; Function definitions +(function_definition + name: (identifier) @function) + +(type + (identifier) @type) + +(type + (subscript + (identifier) @type)) ; type subscript: Tuple[int] + +((call + function: (identifier) @_isinstance + arguments: (argument_list + (_) + (identifier) @type)) + (#eq? @_isinstance "isinstance")) + +; Normal parameters +(parameters + (identifier) @variable.parameter) + +; Lambda parameters +(lambda_parameters + (identifier) @variable.parameter) + +(lambda_parameters + (tuple_pattern + (identifier) @variable.parameter)) + +; Default parameters +(keyword_argument + name: (identifier) @variable.parameter) + +; Naming parameters on call-site +(default_parameter + name: (identifier) @variable.parameter) + +(typed_parameter + (identifier) @variable.parameter) + +(typed_default_parameter + name: (identifier) @variable.parameter) + +; Variadic parameters *args, **kwargs +(parameters + (list_splat_pattern ; *args + (identifier) @variable.parameter)) + +(parameters + (dictionary_splat_pattern ; **kwargs + (identifier) @variable.parameter)) + +; Typed variadic parameters +(parameters + (typed_parameter + (list_splat_pattern ; *args: type + (identifier) @variable.parameter))) + +(parameters + (typed_parameter + (dictionary_splat_pattern ; *kwargs: type + (identifier) @variable.parameter))) + +; Lambda parameters +(lambda_parameters + (list_splat_pattern + (identifier) @variable.parameter)) + +(lambda_parameters + (dictionary_splat_pattern + (identifier) @variable.parameter)) + +; Literals +(none) @constant.builtin + +[ + (true) + (false) +] @boolean + +((identifier) @variable.builtin + (#eq? @variable.builtin "self")) + +((identifier) @variable.builtin + (#eq? @variable.builtin "cls")) + +(integer) @number + +(float) @number.float + +(comment) @comment + +(string) @string + +[ + (escape_sequence) + (escape_interpolation) +] @string.escape + +; doc-strings +(module + . + (comment)* + . + (expression_statement + (string + (string_content)) @string.documentation)) + +(class_definition + body: (block + . + (expression_statement + (string + (string_content)) @string.documentation))) + +(function_definition + body: (block + . + (expression_statement + (string + (string_content)) @string.documentation))) + +; Tokens +[ + "-" + "-=" + ":=" + "!=" + "*" + "**" + "**=" + "*=" + "/" + "//" + "//=" + "/=" + "&" + "&=" + "%" + "%=" + "^" + "^=" + "+" + "+=" + "<" + "<<" + "<<=" + "<=" + "<>" + "=" + "==" + ">" + ">=" + ">>" + ">>=" + "@" + "@=" + "|" + "|=" + "~" + "->" +] @operator + +; Keywords +[ + "and" + "in" + "is" + "not" + "or" + "is not" + "not in" + "del" +] @keyword.operator + +[ + "def" + "lambda" +] @keyword.function + +[ + "assert" + "exec" + "global" + "nonlocal" + "pass" + "print" + "with" + "as" +] @keyword + +[ + "type" + "class" +] @keyword.type + +[ + "async" + "await" +] @keyword.coroutine + +[ + "return" + "yield" +] @keyword.return + +(yield + "from" @keyword.return) + +(future_import_statement + "from" @keyword.import + "__future__" @module.builtin) + +(import_from_statement + "from" @keyword.import) + +"import" @keyword.import + +(aliased_import + "as" @keyword.import) + +(wildcard_import + "*" @character.special) + +(import_statement + name: (dotted_name + (identifier) @module)) + +(import_statement + name: (aliased_import + name: (dotted_name + (identifier) @module) + alias: (identifier) @module)) + +(import_from_statement + module_name: (dotted_name + (identifier) @module)) + +(import_from_statement + module_name: (relative_import + (dotted_name + (identifier) @module))) + +[ + "if" + "elif" + "else" + "match" + "case" +] @keyword.conditional + +[ + "for" + "while" + "break" + "continue" +] @keyword.repeat + +[ + "try" + "except" + "except*" + "raise" + "finally" +] @keyword.exception + +(raise_statement + "from" @keyword.exception) + +(try_statement + (else_clause + "else" @keyword.exception)) + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +(interpolation + "{" @punctuation.special + "}" @punctuation.special) + +(type_conversion) @function.macro + +[ + "," + "." + ":" + ";" + (ellipsis) +] @punctuation.delimiter + +; Class definitions +(class_definition + name: (identifier) @type) + +(class_definition + body: (block + (function_definition + name: (identifier) @function.method))) + +(class_definition + superclasses: (argument_list + (identifier) @type)) + +((class_definition + (block + (function_definition + name: (identifier) @constructor))) + (#any-of? @constructor "__new__" "__init__")) + +((identifier) @type.builtin + (#any-of? @type.builtin + ; https://docs.python.org/3/library/exceptions.html + "BaseException" "Exception" "ArithmeticError" "BufferError" "LookupError" "AssertionError" + "AttributeError" "EOFError" "FloatingPointError" "GeneratorExit" "ImportError" + "ModuleNotFoundError" "IndexError" "KeyError" "KeyboardInterrupt" "MemoryError" "NameError" + "NotImplementedError" "OSError" "OverflowError" "RecursionError" "ReferenceError" "RuntimeError" + "StopIteration" "StopAsyncIteration" "SyntaxError" "IndentationError" "TabError" "SystemError" + "SystemExit" "TypeError" "UnboundLocalError" "UnicodeError" "UnicodeEncodeError" + "UnicodeDecodeError" "UnicodeTranslateError" "ValueError" "ZeroDivisionError" "EnvironmentError" + "IOError" "WindowsError" "BlockingIOError" "ChildProcessError" "ConnectionError" + "BrokenPipeError" "ConnectionAbortedError" "ConnectionRefusedError" "ConnectionResetError" + "FileExistsError" "FileNotFoundError" "InterruptedError" "IsADirectoryError" + "NotADirectoryError" "PermissionError" "ProcessLookupError" "TimeoutError" "Warning" + "UserWarning" "DeprecationWarning" "PendingDeprecationWarning" "SyntaxWarning" "RuntimeWarning" + "FutureWarning" "ImportWarning" "UnicodeWarning" "BytesWarning" "ResourceWarning" + ; https://docs.python.org/3/library/stdtypes.html + "bool" "int" "float" "complex" "list" "tuple" "range" "str" "bytes" "bytearray" "memoryview" + "set" "frozenset" "dict" "type" "object")) + +; Regex from the `re` module +(call + function: (attribute + object: (identifier) @_re) + arguments: (argument_list + . + (string + (string_content) @string.regexp)) + (#eq? @_re "re")) diff --git a/modules/mixins/dotfiles/home/ad/tree-sitter/queries/r/highlights.scm b/modules/mixins/dotfiles/home/ad/tree-sitter/queries/r/highlights.scm @@ -0,0 +1,143 @@ +; Literals +(integer) @number + +(float) @number.float + +(complex) @number + +(string) @string + +(string + (string_content + (escape_sequence) @string.escape)) + +; Comments +(comment) @comment + +; Operators +[ + "?" + ":=" + "=" + "<-" + "<<-" + "->" + "->>" + "~" + "|>" + "||" + "|" + "&&" + "&" + "<" + "<=" + ">" + ">=" + "==" + "!=" + "+" + "-" + "*" + "/" + "::" + ":::" + "**" + "^" + "$" + "@" + ":" + "!" + "special" +] @operator + +; Punctuation +[ + "(" + ")" + "{" + "}" + "[" + "]" + "[[" + "]]" +] @punctuation.bracket + +(comma) @punctuation.delimiter + +; Variables +(identifier) @variable + +; Functions +(binary_operator + lhs: (identifier) @function + operator: "<-" + rhs: (function_definition)) + +(binary_operator + lhs: (identifier) @function + operator: "=" + rhs: (function_definition)) + +; Calls +(call + function: (identifier) @function.call) + +(extract_operator + rhs: (identifier) @variable.member) + +function: (extract_operator + rhs: (identifier) @function.method.call) + +; Parameters +(parameters + (parameter + name: (identifier) @variable.parameter)) + +(arguments + (argument + name: (identifier) @variable.parameter)) + +; Namespace +(namespace_operator + lhs: (identifier) @module) + +(call + function: (namespace_operator + rhs: (identifier) @function)) + +; Keywords +(function_definition + name: "function" @keyword.function) + +(function_definition + name: "\\" @operator) + +(return) @keyword.return + +[ + "if" + "else" +] @keyword.conditional + +[ + "while" + "repeat" + "for" + "in" + (break) + (next) +] @keyword.repeat + +[ + (true) + (false) +] @boolean + +[ + (null) + (inf) + (nan) + (na) + (dots) + (dot_dot_i) +] @constant.builtin diff --git a/modules/mixins/dotfiles/home/ad/tree-sitter/queries/rust/highlights.scm b/modules/mixins/dotfiles/home/ad/tree-sitter/queries/rust/highlights.scm @@ -0,0 +1,161 @@ +; Identifiers + +(type_identifier) @type +(primitive_type) @type.builtin +(field_identifier) @property + +; Identifier conventions + +; Assume all-caps names are constants +((identifier) @constant + (#match? @constant "^[A-Z][A-Z\\d_]+$'")) + +; Assume uppercase names are enum constructors +((identifier) @constructor + (#match? @constructor "^[A-Z]")) + +; Assume that uppercase names in paths are types +((scoped_identifier + path: (identifier) @type) + (#match? @type "^[A-Z]")) +((scoped_identifier + path: (scoped_identifier + name: (identifier) @type)) + (#match? @type "^[A-Z]")) +((scoped_type_identifier + path: (identifier) @type) + (#match? @type "^[A-Z]")) +((scoped_type_identifier + path: (scoped_identifier + name: (identifier) @type)) + (#match? @type "^[A-Z]")) + +; Assume all qualified names in struct patterns are enum constructors. (They're +; either that, or struct names; highlighting both as constructors seems to be +; the less glaring choice of error, visually.) +(struct_pattern + type: (scoped_type_identifier + name: (type_identifier) @constructor)) + +; Function calls + +(call_expression + function: (identifier) @function) +(call_expression + function: (field_expression + field: (field_identifier) @function.method)) +(call_expression + function: (scoped_identifier + "::" + name: (identifier) @function)) + +(generic_function + function: (identifier) @function) +(generic_function + function: (scoped_identifier + name: (identifier) @function)) +(generic_function + function: (field_expression + field: (field_identifier) @function.method)) + +(macro_invocation + macro: (identifier) @function.macro + "!" @function.macro) + +; Function definitions + +(function_item (identifier) @function) +(function_signature_item (identifier) @function) + +(line_comment) @comment +(block_comment) @comment + +(line_comment (doc_comment)) @comment.documentation +(block_comment (doc_comment)) @comment.documentation + +"(" @punctuation.bracket +")" @punctuation.bracket +"[" @punctuation.bracket +"]" @punctuation.bracket +"{" @punctuation.bracket +"}" @punctuation.bracket + +(type_arguments + "<" @punctuation.bracket + ">" @punctuation.bracket) +(type_parameters + "<" @punctuation.bracket + ">" @punctuation.bracket) + +"::" @punctuation.delimiter +":" @punctuation.delimiter +"." @punctuation.delimiter +"," @punctuation.delimiter +";" @punctuation.delimiter + +(parameter (identifier) @variable.parameter) + +(lifetime (identifier) @label) + +"as" @keyword +"async" @keyword +"await" @keyword +"break" @keyword +"const" @keyword +"continue" @keyword +"default" @keyword +"dyn" @keyword +"else" @keyword +"enum" @keyword +"extern" @keyword +"fn" @keyword +"for" @keyword +"gen" @keyword +"if" @keyword +"impl" @keyword +"in" @keyword +"let" @keyword +"loop" @keyword +"macro_rules!" @keyword +"match" @keyword +"mod" @keyword +"move" @keyword +"pub" @keyword +"raw" @keyword +"ref" @keyword +"return" @keyword +"static" @keyword +"struct" @keyword +"trait" @keyword +"type" @keyword +"union" @keyword +"unsafe" @keyword +"use" @keyword +"where" @keyword +"while" @keyword +"yield" @keyword +(crate) @keyword +(mutable_specifier) @keyword +(use_list (self) @keyword) +(scoped_use_list (self) @keyword) +(scoped_identifier (self) @keyword) +(super) @keyword + +(self) @variable.builtin + +(char_literal) @string +(string_literal) @string +(raw_string_literal) @string + +(boolean_literal) @constant.builtin +(integer_literal) @constant.builtin +(float_literal) @constant.builtin + +(escape_sequence) @escape + +(attribute_item) @attribute +(inner_attribute_item) @attribute + +"*" @operator +"&" @operator +"'" @operator diff --git a/modules/mixins/dotfiles/home/ad/tree-sitter/queries/rust/injections.scm b/modules/mixins/dotfiles/home/ad/tree-sitter/queries/rust/injections.scm @@ -0,0 +1,9 @@ +((macro_invocation + (token_tree) @injection.content) + (#set! injection.language "rust") + (#set! injection.include-children)) + +((macro_rule + (token_tree) @injection.content) + (#set! injection.language "rust") + (#set! injection.include-children)) diff --git a/modules/mixins/dotfiles/home/ad/tree-sitter/queries/rust/tags.scm b/modules/mixins/dotfiles/home/ad/tree-sitter/queries/rust/tags.scm @@ -0,0 +1,60 @@ +; ADT definitions + +(struct_item + name: (type_identifier) @name) @definition.class + +(enum_item + name: (type_identifier) @name) @definition.class + +(union_item + name: (type_identifier) @name) @definition.class + +; type aliases + +(type_item + name: (type_identifier) @name) @definition.class + +; method definitions + +(declaration_list + (function_item + name: (identifier) @name) @definition.method) + +; function definitions + +(function_item + name: (identifier) @name) @definition.function + +; trait definitions +(trait_item + name: (type_identifier) @name) @definition.interface + +; module definitions +(mod_item + name: (identifier) @name) @definition.module + +; macro definitions + +(macro_definition + name: (identifier) @name) @definition.macro + +; references + +(call_expression + function: (identifier) @name) @reference.call + +(call_expression + function: (field_expression + field: (field_identifier) @name)) @reference.call + +(macro_invocation + macro: (identifier) @name) @reference.call + +; implementations + +(impl_item + trait: (type_identifier) @name) @reference.implementation + +(impl_item + type: (type_identifier) @name + !trait) @reference.implementation diff --git a/modules/mixins/dotfiles/home/ad/tree-sitter/queries/scheme/highlights.scm b/modules/mixins/dotfiles/home/ad/tree-sitter/queries/scheme/highlights.scm @@ -0,0 +1,22 @@ +; A highlight query can override the highlights queries before it. +; So the order is important. +; We should highlight general rules, then highlight special forms. +(number) @number +(character) @character +(boolean) @boolean +(string) @string +(symbol) @variable + +[ + (comment) + (block_comment) +] @comment + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation diff --git a/modules/mixins/dotfiles/home/ad/tree-sitter/queries/sql/highlights.scm b/modules/mixins/dotfiles/home/ad/tree-sitter/queries/sql/highlights.scm @@ -0,0 +1,338 @@ +(literal) @string +(comment) @comment + +[ + (keyword_true) + (keyword_false) +] @boolean + +[ + (keyword_asc) + (keyword_desc) + (keyword_terminated) + (keyword_escaped) + (keyword_unsigned) + (keyword_nulls) + (keyword_last) + (keyword_delimited) + (keyword_replication) + (keyword_auto_increment) + (keyword_default) + (keyword_collate) + (keyword_concurrently) + (keyword_engine) + (keyword_always) + (keyword_generated) + (keyword_preceding) + (keyword_following) + (keyword_first) + (keyword_current_timestamp) + (keyword_immutable) + (keyword_atomic) + (keyword_parallel) + (keyword_leakproof) + (keyword_safe) + (keyword_cost) + (keyword_strict) +] @keyword + +[ + (keyword_case) + (keyword_when) + (keyword_then) + (keyword_else) +] @keyword.conditional + +[ + (keyword_select) + (keyword_from) + (keyword_where) + (keyword_index) + (keyword_join) + (keyword_primary) + (keyword_delete) + (keyword_create) + (keyword_insert) + (keyword_merge) + (keyword_distinct) + (keyword_replace) + (keyword_update) + (keyword_into) + (keyword_overwrite) + (keyword_matched) + (keyword_values) + (keyword_value) + (keyword_attribute) + (keyword_set) + (keyword_left) + (keyword_right) + (keyword_outer) + (keyword_inner) + (keyword_full) + (keyword_order) + (keyword_partition) + (keyword_group) + (keyword_with) + (keyword_without) + (keyword_as) + (keyword_having) + (keyword_limit) + (keyword_offset) + (keyword_table) + (keyword_tables) + (keyword_key) + (keyword_references) + (keyword_foreign) + (keyword_constraint) + (keyword_force) + (keyword_use) + (keyword_for) + (keyword_if) + (keyword_exists) + (keyword_column) + (keyword_columns) + (keyword_cross) + (keyword_lateral) + (keyword_natural) + (keyword_alter) + (keyword_drop) + (keyword_add) + (keyword_view) + (keyword_end) + (keyword_is) + (keyword_using) + (keyword_between) + (keyword_window) + (keyword_no) + (keyword_data) + (keyword_type) + (keyword_rename) + (keyword_to) + (keyword_schema) + (keyword_owner) + (keyword_authorization) + (keyword_all) + (keyword_any) + (keyword_some) + (keyword_returning) + (keyword_begin) + (keyword_commit) + (keyword_rollback) + (keyword_transaction) + (keyword_only) + (keyword_like) + (keyword_similar) + (keyword_over) + (keyword_change) + (keyword_modify) + (keyword_after) + (keyword_before) + (keyword_range) + (keyword_rows) + (keyword_groups) + (keyword_exclude) + (keyword_current) + (keyword_ties) + (keyword_others) + (keyword_zerofill) + (keyword_format) + (keyword_fields) + (keyword_row) + (keyword_sort) + (keyword_compute) + (keyword_comment) + (keyword_location) + (keyword_cached) + (keyword_uncached) + (keyword_lines) + (keyword_stored) + (keyword_virtual) + (keyword_partitioned) + (keyword_analyze) + (keyword_explain) + (keyword_verbose) + (keyword_truncate) + (keyword_rewrite) + (keyword_optimize) + (keyword_vacuum) + (keyword_cache) + (keyword_language) + (keyword_called) + (keyword_conflict) + (keyword_declare) + (keyword_filter) + (keyword_function) + (keyword_input) + (keyword_name) + (keyword_oid) + (keyword_oids) + (keyword_precision) + (keyword_regclass) + (keyword_regnamespace) + (keyword_regproc) + (keyword_regtype) + (keyword_restricted) + (keyword_return) + (keyword_returns) + (keyword_separator) + (keyword_setof) + (keyword_stable) + (keyword_support) + (keyword_tblproperties) + (keyword_trigger) + (keyword_unsafe) + (keyword_admin) + (keyword_connection) + (keyword_cycle) + (keyword_database) + (keyword_encrypted) + (keyword_increment) + (keyword_logged) + (keyword_none) + (keyword_owned) + (keyword_password) + (keyword_reset) + (keyword_role) + (keyword_sequence) + (keyword_start) + (keyword_restart) + (keyword_tablespace) + (keyword_until) + (keyword_user) + (keyword_valid) + (keyword_action) + (keyword_definer) + (keyword_invoker) + (keyword_security) + (keyword_extension) + (keyword_version) + (keyword_out) + (keyword_inout) + (keyword_variadic) + (keyword_session) + (keyword_isolation) + (keyword_level) + (keyword_serializable) + (keyword_repeatable) + (keyword_read) + (keyword_write) + (keyword_committed) + (keyword_uncommitted) + (keyword_deferrable) + (keyword_names) + (keyword_zone) + (keyword_immediate) + (keyword_deferred) + (keyword_constraints) + (keyword_snapshot) + (keyword_characteristics) + (keyword_off) + (keyword_follows) + (keyword_precedes) + (keyword_each) + (keyword_instead) + (keyword_of) + (keyword_initially) + (keyword_old) + (keyword_new) + (keyword_referencing) + (keyword_statement) + (keyword_execute) + (keyword_procedure) +] @keyword + +[ + (keyword_int) + (keyword_null) + (keyword_boolean) + (keyword_binary) + (keyword_varbinary) + (keyword_image) + (keyword_bit) + (keyword_inet) + (keyword_character) + (keyword_smallserial) + (keyword_serial) + (keyword_bigserial) + (keyword_smallint) + (keyword_mediumint) + (keyword_bigint) + (keyword_tinyint) + (keyword_decimal) + (keyword_float) + (keyword_double) + (keyword_numeric) + (keyword_real) + (double) + (keyword_money) + (keyword_smallmoney) + (keyword_char) + (keyword_nchar) + (keyword_varchar) + (keyword_nvarchar) + (keyword_varying) + (keyword_text) + (keyword_string) + (keyword_uuid) + (keyword_json) + (keyword_jsonb) + (keyword_xml) + (keyword_bytea) + (keyword_enum) + (keyword_date) + (keyword_datetime) + (keyword_time) + (keyword_datetime2) + (keyword_datetimeoffset) + (keyword_smalldatetime) + (keyword_timestamp) + (keyword_timestamptz) + (keyword_geometry) + (keyword_geography) + (keyword_box2d) + (keyword_box3d) + (keyword_interval) +] @type.builtin + +[ + (keyword_in) + (keyword_and) + (keyword_or) + (keyword_not) + (keyword_by) + (keyword_on) + (keyword_do) + (keyword_union) + (keyword_except) + (keyword_intersect) +] @operator + +[ + "+" + "-" + "*" + "/" + "%" + "^" + ":=" + "=" + "<" + "<=" + "!=" + ">=" + ">" + "<>" + (op_other) + (op_unary_other) +] @operator + +[ + "(" + ")" +] @punctuation.bracket + +[ + ";" + "," + "." +] @punctuation.delimiter diff --git a/modules/mixins/dotfiles/home/ad/tree-sitter/queries/swift/highlights.scm b/modules/mixins/dotfiles/home/ad/tree-sitter/queries/swift/highlights.scm @@ -0,0 +1,347 @@ +[ + "." + ";" + ":" + "," +] @punctuation.delimiter + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +; Identifiers +(type_identifier) @type + +[ + (self_expression) + (super_expression) +] @variable.builtin + +; Declarations +[ + "func" + "deinit" +] @keyword.function + +[ + (visibility_modifier) + (member_modifier) + (function_modifier) + (property_modifier) + (parameter_modifier) + (inheritance_modifier) + (mutation_modifier) +] @keyword.modifier + +(simple_identifier) @variable + +(function_declaration + (simple_identifier) @function.method) + +(protocol_function_declaration + name: (simple_identifier) @function.method) + +(init_declaration + "init" @constructor) + +(parameter + external_name: (simple_identifier) @variable.parameter) + +(parameter + name: (simple_identifier) @variable.parameter) + +(type_parameter + (type_identifier) @variable.parameter) + +(inheritance_constraint + (identifier + (simple_identifier) @variable.parameter)) + +(equality_constraint + (identifier + (simple_identifier) @variable.parameter)) + +[ + "protocol" + "extension" + "indirect" + "nonisolated" + "override" + "convenience" + "required" + "some" + "any" + "weak" + "unowned" + "didSet" + "willSet" + "subscript" + "let" + "var" + (throws) + (where_keyword) + (getter_specifier) + (setter_specifier) + (modify_specifier) + (else) + (as_operator) +] @keyword + +[ + "enum" + "struct" + "class" + "typealias" +] @keyword.type + +[ + "async" + "await" +] @keyword.coroutine + +(shebang_line) @keyword.directive + +(class_body + (property_declaration + (pattern + (simple_identifier) @variable.member))) + +(protocol_property_declaration + (pattern + (simple_identifier) @variable.member)) + +(navigation_expression + (navigation_suffix + (simple_identifier) @variable.member)) + +(value_argument + name: (value_argument_label + (simple_identifier) @variable.member)) + +(import_declaration + "import" @keyword.import) + +(enum_entry + "case" @keyword) + +(modifiers + (attribute + "@" @attribute + (user_type + (type_identifier) @attribute))) + +; Function calls +(call_expression + (simple_identifier) @function.call) ; foo() + +(call_expression + ; foo.bar.baz(): highlight the baz() + (navigation_expression + (navigation_suffix + (simple_identifier) @function.call))) + +(call_expression + (prefix_expression + (simple_identifier) @function.call)) ; .foo() + +((navigation_expression + (simple_identifier) @type) ; SomeType.method(): highlight SomeType as a type + (#match? @type "^[A-Z]")) + +(directive) @keyword.directive + +; See https://docs.swift.org/swift-book/documentation/the-swift-programming-language/lexicalstructure/#Keywords-and-Punctuation +[ + (diagnostic) + "#available" + "#unavailable" + "#fileLiteral" + "#colorLiteral" + "#imageLiteral" + "#keyPath" + "#selector" + "#externalMacro" +] @function.macro + +[ + "#column" + "#dsohandle" + "#fileID" + "#filePath" + "#file" + "#function" + "#line" +] @constant.macro + +; Statements +(for_statement + "for" @keyword.repeat) + +(for_statement + "in" @keyword.repeat) + +[ + "while" + "repeat" + "continue" + "break" +] @keyword.repeat + +(guard_statement + "guard" @keyword.conditional) + +(if_statement + "if" @keyword.conditional) + +(switch_statement + "switch" @keyword.conditional) + +(switch_entry + "case" @keyword) + +(switch_entry + "fallthrough" @keyword) + +(switch_entry + (default_keyword) @keyword) + +"return" @keyword.return + +(ternary_expression + [ + "?" + ":" + ] @keyword.conditional.ternary) + +[ + (try_operator) + "do" + (throw_keyword) + (catch_keyword) +] @keyword.exception + +(statement_label) @label + +; Comments +[ + (comment) + (multiline_comment) +] @comment + +((comment) @comment.documentation + (#match? @comment.documentation "^///[^/]")) + +((comment) @comment.documentation + (#match? @comment.documentation "^///$")) + +((multiline_comment) @comment.documentation + (#match? @comment.documentation "^/[*][*][^*].*[*]/$")) + +; String literals +(line_str_text) @string + +(str_escaped_char) @string.escape + +(multi_line_str_text) @string + +(raw_str_part) @string + +(raw_str_end_part) @string + +(line_string_literal + [ + "\\(" + ")" + ] @punctuation.special) + +(multi_line_string_literal + [ + "\\(" + ")" + ] @punctuation.special) + +(raw_str_interpolation + [ + (raw_str_interpolation_start) + ")" + ] @punctuation.special) + +[ + "\"" + "\"\"\"" +] @string + +; Lambda literals +(lambda_literal + "in" @keyword.operator) + +; Basic literals +[ + (integer_literal) + (hex_literal) + (oct_literal) + (bin_literal) +] @number + +(real_literal) @number.float + +(boolean_literal) @boolean + +"nil" @constant.builtin + +(wildcard_pattern) @character.special + +; Regex literals +(regex_literal) @string.regexp + +; Operators +(custom_operator) @operator + +[ + "+" + "-" + "*" + "/" + "%" + "=" + "+=" + "-=" + "*=" + "/=" + "<" + ">" + "<<" + ">>" + "<=" + ">=" + "++" + "--" + "^" + "&" + "&&" + "|" + "||" + "~" + "%=" + "!=" + "!==" + "==" + "===" + "?" + "??" + "->" + "..<" + "..." + (bang) +] @operator + +(type_arguments + [ + "<" + ">" + ] @punctuation.bracket) diff --git a/modules/mixins/dotfiles/home/ad/tree-sitter/queries/toml/highlights.scm b/modules/mixins/dotfiles/home/ad/tree-sitter/queries/toml/highlights.scm @@ -0,0 +1,31 @@ +(bare_key) @variable +(boolean) @boolean +(comment) @comment +(integer) @number +(float) @number + +[ + (string) + (quoted_key) + (escape_sequence) +] @string + +[ + (local_date) + (local_date_time) + (local_time) + (offset_date_time) +] @character + +"=" @operator + +[ + "." + "," + "[" + "]" + "[[" + "]]" + "{" + "}" +] @punctuation diff --git a/modules/mixins/dotfiles/home/ad/tree-sitter/queries/yaml/highlights.scm b/modules/mixins/dotfiles/home/ad/tree-sitter/queries/yaml/highlights.scm @@ -0,0 +1,75 @@ +(boolean_scalar) @boolean +(null_scalar) @constant.builtin +(double_quote_scalar) @string +(single_quote_scalar) @string + +((block_scalar) @string + (#set! priority 99)) + +(string_scalar) @string +(escape_sequence) @string.escape +(integer_scalar) @number +(float_scalar) @number +(comment) @comment + +[ + (anchor_name) + (alias_name) +] @label + +(tag) @type + +[ + (yaml_directive) + (tag_directive) + (reserved_directive) +] @keyword.directive + +(block_mapping_pair + key: (flow_node + [ + (double_quote_scalar) + (single_quote_scalar) + ] @property)) + +(block_mapping_pair + key: (flow_node + (plain_scalar + (string_scalar) @property))) + +(flow_mapping + (_ + key: (flow_node + [ + (double_quote_scalar) + (single_quote_scalar) + ] @property))) + +(flow_mapping + (_ + key: (flow_node + (plain_scalar + (string_scalar) @property)))) + +[ + "," + "-" + ":" + ">" + "?" + "|" +] @punctuation.delimiter + +[ + "[" + "]" + "{" + "}" +] @punctuation.bracket + +[ + "*" + "&" + "---" + "..." +] @punctuation.special