diff options
| author | Cezary Drożak <czarek@drozak.net> | 2021-10-01 11:33:33 +0200 |
|---|---|---|
| committer | Stephan Seitz <stephan.seitz@fau.de> | 2021-10-07 22:43:09 +0200 |
| commit | c2c454c29a92e2d0db955fc1d6841566c28e3ecd (patch) | |
| tree | 86e49ee3b3d4f4bb82450a947dc62120e261fed7 | |
| parent | feat: add "experimental" key to parsers (diff) | |
| download | nvim-treesitter-c2c454c29a92e2d0db955fc1d6841566c28e3ecd.tar nvim-treesitter-c2c454c29a92e2d0db955fc1d6841566c28e3ecd.tar.gz nvim-treesitter-c2c454c29a92e2d0db955fc1d6841566c28e3ecd.tar.bz2 nvim-treesitter-c2c454c29a92e2d0db955fc1d6841566c28e3ecd.tar.lz nvim-treesitter-c2c454c29a92e2d0db955fc1d6841566c28e3ecd.tar.xz nvim-treesitter-c2c454c29a92e2d0db955fc1d6841566c28e3ecd.tar.zst nvim-treesitter-c2c454c29a92e2d0db955fc1d6841566c28e3ecd.zip | |
parsers: add D parser
| -rw-r--r-- | lua/nvim-treesitter/parsers.lua | 11 | ||||
| -rw-r--r-- | queries/d/folds.scm | 1 | ||||
| -rw-r--r-- | queries/d/highlights.scm | 264 | ||||
| -rw-r--r-- | queries/d/indents.scm | 17 | ||||
| -rw-r--r-- | queries/d/injections.scm | 7 |
5 files changed, 300 insertions, 0 deletions
diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index c54ebfa50..89b12d39b 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -85,6 +85,17 @@ list.cuda = { maintainers = { "@theHamsta" }, } +list.d = { + install_info = { + url = "https://github.com/CyberShadow/tree-sitter-d", + files = { "src/parser.c", "src/scanner.cc" }, + requires_generate_from_grammar = true, + }, + maintainers = { "@nawordar" }, + -- Generating grammar takes ~60s + experimental = true, +} + list.glsl = { install_info = { url = "https://github.com/theHamsta/tree-sitter-glsl", diff --git a/queries/d/folds.scm b/queries/d/folds.scm new file mode 100644 index 000000000..be4dee45e --- /dev/null +++ b/queries/d/folds.scm @@ -0,0 +1 @@ +(block_statement) @fold diff --git a/queries/d/highlights.scm b/queries/d/highlights.scm new file mode 100644 index 000000000..3dffa1828 --- /dev/null +++ b/queries/d/highlights.scm @@ -0,0 +1,264 @@ +;; Misc + +[ + (line_comment) + (block_comment) + (nesting_block_comment) +] @comment + +[ + "(" ")" + "[" "]" + "{" "}" +] @punctuation.bracket + +[ + "," + ";" + "." +] @punctuation.delimiter + +[ + ".." + "$" +] @punctuation.special + +;; Constants + +[ + "__FILE_FULL_PATH__" + "__FILE__" + "__FUNCTION__" + "__LINE__" + "__MODULE__" + "__PRETTY_FUNCTION__" +] @constant.macro + +(string_literals) @string + +; Don't highlight token strings as strings +(token_string_tokens) @none + +(character_literal) @character + +(integer_literal) @number + +(float_literal) @float + +[ + "true" + "false" +] @boolean + +;; Functions + +(func_declarator + (identifier) @function +) + +[ + "__traits" + "__vector" + "assert" + "is" + "mixin" + "pragma" + "typeid" +] @function.builtin + +(import_expression + "import" @function.builtin +) + +(parameter + (var_declarator + (identifier) @parameter + ) +) + +(function_literal + (identifier) @parameter +) + +(constructor + "this" @constructor +) + +(destructor + "this" @constructor +) + +;; Keywords + +[ + "case" + "default" + "else" + "if" + "switch" +] @conditional + +[ + "break" + "continue" + "do" + "for" + "foreach" + "foreach_reverse" + "while" +] @repeat + +[ + "__gshared" + "__parameters" + "abstract" + "alias" + "align" + "asm" + "auto" + "body" + "class" + "const" + "debug" + "deprecated" + "enum" + "export" + "extern" + "final" + "goto" + "immutable" + "inout" + "interface" + "invariant" + "lazy" + "macro" + "nothrow" + "null" + "out" + "override" + "package" + "private" + "protected" + "public" + "pure" + "ref" + "scope" + "shared" + "static" + "struct" + "synchronized" + "template" + "union" + "unittest" + "version" + "with" +] @keyword + +[ + "delegate" + "function" +] @keyword.function + +"return" @keyword.return + +[ + "cast" + "new" +] @keyword.operator + +[ + "+" + "++" + "+=" + "-" + "--" + "-=" + "*" + "*=" + "%" + "%=" + "^" + "^=" + "^^" + "^^=" + "/" + "/=" + "|" + "|=" + "||" + "~" + "~=" + "=" + "==" + "=>" + "<" + "<=" + "<<" + "<<=" + ">" + ">=" + ">>" + ">>=" + ">>>" + ">>>=" + "!" + "!=" + "&" + "&&" +] @operator + +[ + "catch" + "finally" + "throw" + "try" +] @exception + +(module_declaration + "module" @include +) + +(import_declaration + "import" @include +) + +(type) @type + +(catch_parameter + (qualified_identifier) @type +) + +(var_declarations + (qualified_identifier) @type +) + +(func_declaration + (qualified_identifier) @type +) + +(parameter + (qualified_identifier) @type +) + +(class_declaration + (identifier) @type +) + +(fundamental_type) @type.builtin + +[ + (module_name) + (module_fully_qualified_name) +] @namespace + +(at_attribute) @attribute + +(user_defined_attribute + "@" @attribute +) + +;; Variables + +(primary_expression + "this" @variable.builtin +) diff --git a/queries/d/indents.scm b/queries/d/indents.scm new file mode 100644 index 000000000..7a6df759c --- /dev/null +++ b/queries/d/indents.scm @@ -0,0 +1,17 @@ +[ + (block_statement) + (case_statement) + (token_string) +] @indent + +[ + "(" ")" + "{" "}" + "[" "]" +] @branch + +[ + (line_comment) + (block_comment) + (nesting_block_comment) +] @ignore diff --git a/queries/d/injections.scm b/queries/d/injections.scm new file mode 100644 index 000000000..d95514370 --- /dev/null +++ b/queries/d/injections.scm @@ -0,0 +1,7 @@ +[ + (line_comment) + (block_comment) + (nesting_block_comment) +] @comment + +(token_string_tokens) @d |
