diff --git a/.config/helix/languages.toml b/.config/helix/languages.toml index 3c39118e..011b2de7 100644 --- a/.config/helix/languages.toml +++ b/.config/helix/languages.toml @@ -134,6 +134,22 @@ file-types = [ "cfg", "directory", ] + +[[grammar]] +name = "vim" +source = { git = "https://github.com/tree-sitter-grammars/tree-sitter-vim", rev = "f3cd62d8bd043ef20507e84bb6b4b53731ccf3a7" } + +[[language]] +name = "vim" +scope = "source.vim" +injection-regex = "vim" +comment-token = '"' +indent = { tab-width = 4, unit = "\t" } +file-types = [ + "vim", + { glob = ".vimrc" }, +] + # [[grammar]] # name = "mail" # source.path = "/home/fic/dev/tree-sitter-mail" diff --git a/.config/helix/runtime/queries/vim/highlights.scm b/.config/helix/runtime/queries/vim/highlights.scm new file mode 100644 index 00000000..0859eb92 --- /dev/null +++ b/.config/helix/runtime/queries/vim/highlights.scm @@ -0,0 +1,350 @@ +(identifier) @variable + +((identifier) @constant + (#match? @constant "^[A-Z][A-Z_0-9]*$")) + +; Keywords +[ + "if" + "else" + "elseif" + "endif" +] @keyword.control.conditional + +[ + "try" + "catch" + "finally" + "endtry" + "throw" +] @keyword.control.except + +[ + "for" + "endfor" + "in" + "while" + "endwhile" + "break" + "continue" +] @keyword.control.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) @variable.parameter) + +(default_parameter + (identifier) @variable.parameter) + +[ + (bang) + (spread) +] @punctuation.special + +[ + (no_option) + (inv_option) + (default_option) + (option_name) +] @variable.builtin + +[ + (scope) + "a:" + "$" +] @module + +; 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" + "scriptencoding" + "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" + "sign" +] @keyword + +(map_statement + cmd: _ @keyword) + +(keycode) @constant.character.escape + +(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) + +[ + "" + "" + "" + "