diff options
Diffstat (limited to 'runtime/queries')
-rw-r--r-- | runtime/queries/c/highlights.scm | 2 | ||||
-rw-r--r-- | runtime/queries/c/injections.scm | 3 | ||||
-rw-r--r-- | runtime/queries/help/highlights.scm | 25 | ||||
-rw-r--r-- | runtime/queries/help/injections.scm | 3 | ||||
-rw-r--r-- | runtime/queries/lua/highlights.scm | 199 | ||||
-rw-r--r-- | runtime/queries/lua/injections.scm | 22 | ||||
-rw-r--r-- | runtime/queries/vim/highlights.scm | 290 | ||||
-rw-r--r-- | runtime/queries/vim/injections.scm | 28 |
8 files changed, 572 insertions, 0 deletions
diff --git a/runtime/queries/c/highlights.scm b/runtime/queries/c/highlights.scm index 260750a85b..33e6df74ab 100644 --- a/runtime/queries/c/highlights.scm +++ b/runtime/queries/c/highlights.scm @@ -101,6 +101,7 @@ [ "(" ")" "[" "]" "{" "}"] @punctuation.bracket (string_literal) @string +(string_literal) @spell (system_lib_string) @string (null) @constant.builtin @@ -148,6 +149,7 @@ (comment) @comment +(comment) @spell ;; Parameters (parameter_declaration diff --git a/runtime/queries/c/injections.scm b/runtime/queries/c/injections.scm new file mode 100644 index 0000000000..7e9e73449d --- /dev/null +++ b/runtime/queries/c/injections.scm @@ -0,0 +1,3 @@ +(preproc_arg) @c + +; (comment) @comment diff --git a/runtime/queries/help/highlights.scm b/runtime/queries/help/highlights.scm new file mode 100644 index 0000000000..c0d88301bc --- /dev/null +++ b/runtime/queries/help/highlights.scm @@ -0,0 +1,25 @@ +(h1) @text.title +(h2) @text.title +(h3) @text.title +(column_heading) @text.title +(column_heading + "~" @conceal (#set! conceal "")) +(tag + "*" @conceal (#set! conceal "") + text: (_) @label) +(taglink + "|" @conceal (#set! conceal "") + text: (_) @text.reference) +(optionlink + text: (_) @text.reference) +(codespan + "`" @conceal (#set! conceal "") + text: (_) @text.literal) +(codeblock) @text.literal +(codeblock + [">" (language)] @conceal (#set! conceal "")) +(block + "<" @conceal (#set! conceal "")) +(argument) @parameter +(keycode) @string.special +(url) @text.uri diff --git a/runtime/queries/help/injections.scm b/runtime/queries/help/injections.scm new file mode 100644 index 0000000000..09bbe44e84 --- /dev/null +++ b/runtime/queries/help/injections.scm @@ -0,0 +1,3 @@ +(codeblock + (language) @language + (code) @content) diff --git a/runtime/queries/lua/highlights.scm b/runtime/queries/lua/highlights.scm new file mode 100644 index 0000000000..2c0dc5447a --- /dev/null +++ b/runtime/queries/lua/highlights.scm @@ -0,0 +1,199 @@ +;; Keywords + +"return" @keyword.return + +[ + "goto" + "in" + "local" +] @keyword + +(label_statement) @label + +(break_statement) @keyword + +(do_statement +[ + "do" + "end" +] @keyword) + +(while_statement +[ + "while" + "do" + "end" +] @repeat) + +(repeat_statement +[ + "repeat" + "until" +] @repeat) + +(if_statement +[ + "if" + "elseif" + "else" + "then" + "end" +] @conditional) + +(elseif_statement +[ + "elseif" + "then" + "end" +] @conditional) + +(else_statement +[ + "else" + "end" +] @conditional) + +(for_statement +[ + "for" + "do" + "end" +] @repeat) + +(function_declaration +[ + "function" + "end" +] @keyword.function) + +(function_definition +[ + "function" + "end" +] @keyword.function) + +;; Operators + +[ + "and" + "not" + "or" +] @keyword.operator + +[ + "+" + "-" + "*" + "/" + "%" + "^" + "#" + "==" + "~=" + "<=" + ">=" + "<" + ">" + "=" + "&" + "~" + "|" + "<<" + ">>" + "//" + ".." +] @operator + +;; Punctuations + +[ + ";" + ":" + "," + "." +] @punctuation.delimiter + +;; Brackets + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +;; Variables + +(identifier) @variable + +((identifier) @variable.builtin + (#eq? @variable.builtin "self")) + +(variable_list + attribute: (attribute + (["<" ">"] @punctuation.bracket + (identifier) @attribute))) + +;; Constants + +((identifier) @constant + (#lua-match? @constant "^[A-Z][A-Z_0-9]*$")) + +(vararg_expression) @constant + +(nil) @constant.builtin + +[ + (false) + (true) +] @boolean + +;; Tables + +(field name: (identifier) @field) + +(dot_index_expression field: (identifier) @field) + +(table_constructor +[ + "{" + "}" +] @constructor) + +;; Functions + +(parameters (identifier) @parameter) + +(function_call name: (identifier) @function.call) +(function_declaration name: (identifier) @function) + +(function_call name: (dot_index_expression field: (identifier) @function.call)) +(function_declaration name: (dot_index_expression field: (identifier) @function)) + +(method_index_expression method: (identifier) @method) + +(function_call + (identifier) @function.builtin + (#any-of? @function.builtin + ;; built-in functions in Lua 5.1 + "assert" "collectgarbage" "dofile" "error" "getfenv" "getmetatable" "ipairs" + "load" "loadfile" "loadstring" "module" "next" "pairs" "pcall" "print" + "rawequal" "rawget" "rawset" "require" "select" "setfenv" "setmetatable" + "tonumber" "tostring" "type" "unpack" "xpcall")) + +;; Others + +(comment) @comment +(comment) @spell + +(hash_bang_line) @comment + +(number) @number + +(string) @string +(string) @spell + +;; Error +(ERROR) @error diff --git a/runtime/queries/lua/injections.scm b/runtime/queries/lua/injections.scm new file mode 100644 index 0000000000..0e67329139 --- /dev/null +++ b/runtime/queries/lua/injections.scm @@ -0,0 +1,22 @@ +((function_call + name: [ + (identifier) @_cdef_identifier + (_ _ (identifier) @_cdef_identifier) + ] + arguments: (arguments (string content: _ @c))) + (#eq? @_cdef_identifier "cdef")) + +((function_call + name: (_) @_vimcmd_identifier + arguments: (arguments (string content: _ @vim))) + (#any-of? @_vimcmd_identifier "vim.cmd" "vim.api.nvim_command" "vim.api.nvim_exec" "vim.api.nvim_cmd")) + +; ((function_call +; name: (_) @_vimcmd_identifier +; arguments: (arguments (string content: _ @query) .)) +; (#eq? @_vimcmd_identifier "vim.treesitter.query.set_query")) + +; ;; highlight string as query if starts with `;; query` +; ((string ("string_content") @query) (#lua-match? @query "^%s*;+%s?query")) + +; (comment) @comment diff --git a/runtime/queries/vim/highlights.scm b/runtime/queries/vim/highlights.scm new file mode 100644 index 0000000000..239b0a0b37 --- /dev/null +++ b/runtime/queries/vim/highlights.scm @@ -0,0 +1,290 @@ +(identifier) @variable +((identifier) @constant + (#lua-match? @constant "^[A-Z][A-Z_0-9]*$")) + +;; Keywords + +[ + "if" + "else" + "elseif" + "endif" +] @conditional + +[ + "try" + "catch" + "finally" + "endtry" + "throw" +] @exception + +[ + "for" + "endfor" + "in" + "while" + "endwhile" + "break" + "continue" +] @repeat + +[ + "function" + "endfunction" +] @keyword.function + +;; Function related +(function_declaration name: (_) @function) +(call_expression function: (identifier) @function.call) +(call_expression function: (scoped_identifier (identifier) @function.call)) +(parameters (identifier) @parameter) +(default_parameter (identifier) @parameter) + +[ (bang) (spread) ] @punctuation.special + +[ (no_option) (inv_option) (default_option) (option_name) ] @variable.builtin +[ + (scope) + "a:" + "$" +] @namespace + +;; Commands and user defined commands + +[ + "let" + "unlet" + "const" + "call" + "execute" + "normal" + "set" + "setfiletype" + "setlocal" + "silent" + "echo" + "echon" + "echohl" + "echomsg" + "echoerr" + "autocmd" + "augroup" + "return" + "syntax" + "filetype" + "source" + "lua" + "ruby" + "perl" + "python" + "highlight" + "command" + "delcommand" + "comclear" + "colorscheme" + "startinsert" + "stopinsert" + "global" + "runtime" + "wincmd" + "cnext" + "cprevious" + "cNext" + "vertical" + "leftabove" + "aboveleft" + "rightbelow" + "belowright" + "topleft" + "botright" + (unknown_command_name) + "edit" + "enew" + "find" + "ex" + "visual" + "view" + "eval" +] @keyword +(map_statement cmd: _ @keyword) +(command_name) @function.macro + +;; Filetype command + +(filetype_statement [ + "detect" + "plugin" + "indent" + "on" + "off" +] @keyword) + +;; Syntax command + +(syntax_statement (keyword) @string) +(syntax_statement [ + "enable" + "on" + "off" + "reset" + "case" + "spell" + "foldlevel" + "iskeyword" + "keyword" + "match" + "cluster" + "region" + "clear" + "include" +] @keyword) + +(syntax_argument name: _ @keyword) + +[ + "<buffer>" + "<nowait>" + "<silent>" + "<script>" + "<expr>" + "<unique>" +] @constant.builtin + +(augroup_name) @namespace + +(au_event) @constant +(normal_statement (commands) @constant) + +;; Highlight command + +(hl_attribute + key: _ @property + val: _ @constant) + +(hl_group) @type + +(highlight_statement [ + "default" + "link" + "clear" +] @keyword) + +;; Command command + +(command) @string + +(command_attribute + name: _ @property + val: (behavior + name: _ @constant + val: (identifier)? @function)?) + +;; Edit command +(plus_plus_opt + val: _? @constant) @property +(plus_cmd "+" @property) @property + +;; Runtime command + +(runtime_statement (where) @keyword.operator) + +;; Colorscheme command + +(colorscheme_statement (name) @string) + +;; Literals + +(string_literal) @string +(integer_literal) @number +(float_literal) @float +(comment) @comment @spell +(line_continuation_comment) @comment @spell +(pattern) @string.special +(pattern_multi) @string.regex +(filename) @string +(heredoc (body) @string) +(heredoc (parameter) @keyword) +[ (marker_definition) (endmarker) ] @label +(literal_dictionary (literal_key) @label) +((scoped_identifier + (scope) @_scope . (identifier) @boolean) + (#eq? @_scope "v:") + (#any-of? @boolean "true" "false")) + +;; Operators + +[ + "||" + "&&" + "&" + "+" + "-" + "*" + "/" + "%" + ".." + "is" + "isnot" + "==" + "!=" + ">" + ">=" + "<" + "<=" + "=~" + "!~" + "=" + "+=" + "-=" + "*=" + "/=" + "%=" + ".=" + "..=" + "<<" + "=<<" + (match_case) +] @operator + +; Some characters have different meanings based on the context +(unary_operation "!" @operator) +(binary_operation "." @operator) + + +;; Punctuation + +[ + "(" + ")" + "{" + "}" + "[" + "]" + "#{" +] @punctuation.bracket + +(field_expression "." @punctuation.delimiter) + +[ + "," + ":" +] @punctuation.delimiter + +(ternary_expression ["?" ":"] @conditional) + +; Options +((set_value) @number + (#match? @number "^[0-9]+(\.[0-9]+)?$")) + +(inv_option "!" @operator) +(set_item "?" @operator) + +((set_item + option: (option_name) @_option + value: (set_value) @function) + (#any-of? @_option + "tagfunc" "tfu" + "completefunc" "cfu" + "omnifunc" "ofu" + "operatorfunc" "opfunc")) diff --git a/runtime/queries/vim/injections.scm b/runtime/queries/vim/injections.scm new file mode 100644 index 0000000000..fdd025bfd9 --- /dev/null +++ b/runtime/queries/vim/injections.scm @@ -0,0 +1,28 @@ +(lua_statement (script (body) @lua)) +(lua_statement (chunk) @lua) +(ruby_statement (script (body) @ruby)) +(ruby_statement (chunk) @ruby) +(python_statement (script (body) @python)) +(python_statement (chunk) @python) +;; If we support perl at some point... +;; (perl_statement (script (body) @perl)) +;; (perl_statement (chunk) @perl) + +(autocmd_statement (pattern) @regex) + +((set_item + option: (option_name) @_option + value: (set_value) @vim) + (#any-of? @_option + "includeexpr" "inex" + "printexpr" "pexpr" + "formatexpr" "fex" + "indentexpr" "inde" + "foldtext" "fdt" + "foldexpr" "fde" + "diffexpr" "dex" + "patchexpr" "pex" + "charconvert" "ccv")) + +(comment) @comment +(line_continuation_comment) @comment |