From 5c511dd1244fc8eeccf8920a5a4754ae01da296e Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Fri, 24 Feb 2023 07:42:04 -0500 Subject: [PATCH 0001/2704] feat(solidity): use maintained parser and update highlights accordingly --- README.md | 2 +- lockfile.json | 2 +- lua/nvim-treesitter/parsers.lua | 6 +- queries/solidity/highlights.scm | 218 ++++++++++++++--------- tests/query/highlights/solidity/test.sol | 8 +- 5 files changed, 138 insertions(+), 98 deletions(-) diff --git a/README.md b/README.md index 2a6ebf5e5..091a47e90 100644 --- a/README.md +++ b/README.md @@ -303,7 +303,7 @@ We are looking for maintainers to add more parsers and to write query files for - [x] [slint](https://github.com/jrmoulton/tree-sitter-slint) (experimental, maintained by @jrmoulton) - [x] [smali](https://git.sr.ht/~yotam/tree-sitter-smali) (maintained by @amaanq) - [x] [smithy](https://github.com/indoorvivants/tree-sitter-smithy) (maintained by @amaanq, @keynmol) -- [x] [solidity](https://github.com/YongJieYongJie/tree-sitter-solidity) (maintained by @YongJieYongJie) +- [x] [solidity](https://github.com/JoranHonig/tree-sitter-solidity) (maintained by @amaanq) - [x] [sparql](https://github.com/BonaBeavis/tree-sitter-sparql) (maintained by @BonaBeavis) - [x] [sql](https://github.com/derekstride/tree-sitter-sql) (maintained by @derekstride) - [x] [starlark](https://github.com/amaanq/tree-sitter-starlark) (maintained by @amaanq) diff --git a/lockfile.json b/lockfile.json index 0fe13282c..ca9770ad7 100644 --- a/lockfile.json +++ b/lockfile.json @@ -390,7 +390,7 @@ "revision": "cf8c7eb9faf7c7049839585eac19c94af231e6a0" }, "solidity": { - "revision": "52ed0880c0126df2f2c7693f215fe6f38e4a2e0a" + "revision": "168020304759ad5d8b4a88a541a699134e3730c5" }, "sparql": { "revision": "05f949d3c1c15e3261473a244d3ce87777374dec" diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index 4769c95f0..de31f4196 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -1235,11 +1235,11 @@ list.smithy = { list.solidity = { install_info = { - url = "https://github.com/YongJieYongJie/tree-sitter-solidity", - branch = "with-generated-c-code", + url = "https://github.com/JoranHonig/tree-sitter-solidity", + branch = "master", files = { "src/parser.c" }, }, - maintainers = { "@YongJieYongJie" }, + maintainers = { "@amaanq" }, } list.sparql = { diff --git a/queries/solidity/highlights.scm b/queries/solidity/highlights.scm index 33c837d5c..5afebb990 100644 --- a/queries/solidity/highlights.scm +++ b/queries/solidity/highlights.scm @@ -1,73 +1,75 @@ -(comment) @comment -;; Handles natspec comments -((comment) @preproc - (#match? @preproc "^/// .*")) - ; Pragma -(pragma_directive) @attribute +[ + "pragma" + "solidity" +] @preproc + +(solidity_pragma_token + "||" @symbol) +(solidity_pragma_token + "-" @symbol) + +(solidity_version_comparison_operator) @operator ; Literals + [ (string) - (hex_string_literal) - (unicode_string_literal) (yul_string_literal) ] @string + +(hex_string_literal + "hex" @symbol + (_) @string) + +(unicode_string_literal + "unicode" @symbol + (_) @string) + [ (number_literal) (yul_decimal_number) (yul_hex_number) ] @number -[ - (true) - (false) -] @constant.builtin +(yul_boolean) @boolean ; Type (type_name (identifier) @type) -(type_name "mapping" @type) -(primitive_type) @type +(type_name "mapping" @function.builtin) + +[ + (primitive_type) + (number_unit) +] @type.builtin + (contract_declaration name: (identifier) @type) -(struct_declaration struct_name: (identifier) @type) +(struct_declaration name: (identifier) @type) (struct_member name: (identifier) @field) -(enum_declaration enum_type_name: (identifier) @type) +(enum_declaration name: (identifier) @type) (emit_statement . (identifier) @type) ; Handles ContractA, ContractB in function foo() override(ContractA, contractB) {} -(override_specifier (identifier) @type) -; Ensures that delimiters in mapping( ... => .. ) are not colored like types -(type_name - "(" @punctuation.bracket - "=>" @punctuation.delimiter - ")" @punctuation.bracket) - +(override_specifier (user_defined_type) @type) ; Functions and parameters (function_definition - function_name: (identifier) @function) + name: (identifier) @function) (modifier_definition name: (identifier) @function) (yul_evm_builtin) @function.builtin ; Use constructor coloring for special functions (constructor_definition "constructor" @constructor) -(fallback_receive_definition "receive" @constructor) -(fallback_receive_definition "fallback" @constructor) (modifier_invocation (identifier) @function) ; Handles expressions like structVariable.g(); -(call_expression . (member_expression (property_identifier) @method.call)) +(call_expression . (member_expression (identifier) @method.call)) ; Handles expressions like g(); (call_expression . (identifier) @function.call) -(function_definition - function_name: (identifier) @function) - -; Handles the field in struct literals like MyStruct({MyField: MyVar * 2}) -(call_expression (identifier) @field . ":") ; Function parameters (event_paramater name: (identifier) @parameter) @@ -81,100 +83,123 @@ (meta_type_expression "type" @keyword) -(member_expression (property_identifier) @field) -(property_identifier) @field -(struct_expression ((identifier) @field . ":")) +(member_expression property: (identifier) @field) +(call_struct_argument name: (identifier) @field) +(struct_field_assignment name: (identifier) @field) (enum_value) @constant ; Keywords [ - "contract" - "interface" - "library" - "is" - "struct" - "enum" - "event" - "assembly" - "emit" - "modifier" - "var" - (virtual) - (override_specifier) + "contract" + "interface" + "library" + "is" + "struct" + "enum" + "event" + "assembly" + "emit" + "override" + "modifier" + "var" + "let" + "emit" + "fallback" + "receive" + (virtual) ] @keyword +; FIXME: update grammar +; (block_statement "unchecked" @keyword) + +(event_paramater "indexed" @keyword) + [ - "public" - "internal" - "private" - "external" - "pure" - "view" - "payable" + "public" + "internal" + "private" + "external" + "pure" + "view" + "payable" + (immutable) ] @type.qualifier [ - "memory" - "storage" - "calldata" - (constant) + "memory" + "storage" + "calldata" + "constant" ] @storageclass [ - "for" - "while" - "do" + "for" + "while" + "do" + "break" + "continue" ] @repeat [ - "break" - "continue" - "if" - "else" - "switch" - "case" - "default" + "if" + "else" + "switch" + "case" + "default" ] @conditional +(ternary_expression + "?" @conditional.ternary + ":" @conditional.ternary) + [ - "try" - "catch" + "try" + "catch" + "revert" ] @exception [ - "return" - "returns" - (yul_leave) + "return" + "returns" + (yul_leave) ] @keyword.return "function" @keyword.function -"pragma" @preproc - -["import" "using"] @include +[ + "import" + "using" +] @include (import_directive "as" @include) (import_directive "from" @include) - -(event_paramater "indexed" @keyword) +(import_directive "*" @character.special) ; Punctuation -[ - "(" - ")" - "[" - "]" - "{" - "}" -] @punctuation.bracket +[ "{" "}" ] @punctuation.bracket +[ "[" "]" ] @punctuation.bracket + +[ "(" ")" ] @punctuation.bracket [ "." "," + ; FIXME: update grammar + ; (semicolon) + "->" + "=>" ] @punctuation.delimiter +(call_struct_argument + ":" @punctuation.delimiter) +(slice_access + ":" @punctuation.delimiter) +(struct_field_assignment + ":" @punctuation.delimiter) +(yul_label + ":" @punctuation.delimiter) ; Operators @@ -206,12 +231,27 @@ "+" "++" "--" + ":=" ] @operator +(yul_assignment + ":" @operator + "=" @operator) + [ "delete" "new" ] @keyword.operator -(identifier) @variable -(yul_identifier) @variable +[ + (identifier) + (yul_identifier) +] @variable + +; Comments + +(comment) @comment @spell + +; Errors + +(ERROR) @error diff --git a/tests/query/highlights/solidity/test.sol b/tests/query/highlights/solidity/test.sol index a4b642ee6..062970fdd 100644 --- a/tests/query/highlights/solidity/test.sol +++ b/tests/query/highlights/solidity/test.sol @@ -4,13 +4,13 @@ // ^ comment pragma solidity >=0.7.0 <0.9.0; // ^ preproc -// ^ attribute +// ^ preproc import * as something from "anotherFile"; // ^ ^ ^ include /// @title Voting with delegation. -// ^ preproc +// <- comment contract Ballot { // ^keyword // ^ type @@ -20,7 +20,7 @@ contract Ballot { struct Voter { // ^ type uint weight; // weight is accumulated by delegation -// ^ type +// ^ type.builtin // ^ field bool voted; // if true, that person already voted address delegate; // person delegated to @@ -34,7 +34,7 @@ contract Ballot { } address public chairperson; -// ^ type +// ^ type.builtin // This declares a state variable that // stores a `Voter` struct for each possible address. From 68ab44277cd3eca7c5f1d227f153bd4e56d6303f Mon Sep 17 00:00:00 2001 From: SzeLamC Date: Sat, 25 Feb 2023 05:06:31 +0800 Subject: [PATCH 0002/2704] fix(dart): add `@indent_end` to } (#4167) * fix dart indentation after } * add some simple test case --- queries/dart/indents.scm | 4 ++++ tests/indent/dart/class.dart | 4 ++++ tests/indent/dart_spec.lua | 20 ++++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 tests/indent/dart/class.dart create mode 100644 tests/indent/dart_spec.lua diff --git a/queries/dart/indents.scm b/queries/dart/indents.scm index e01cc238d..ad0ba389e 100644 --- a/queries/dart/indents.scm +++ b/queries/dart/indents.scm @@ -21,6 +21,10 @@ "]" ] @branch +[ + "}" +] @indent_end + ; this one is for dedenting the else block (if_statement (block) @branch) diff --git a/tests/indent/dart/class.dart b/tests/indent/dart/class.dart new file mode 100644 index 000000000..0402cc677 --- /dev/null +++ b/tests/indent/dart/class.dart @@ -0,0 +1,4 @@ +void main() { +} +class Test { +} diff --git a/tests/indent/dart_spec.lua b/tests/indent/dart_spec.lua new file mode 100644 index 000000000..8b05cc753 --- /dev/null +++ b/tests/indent/dart_spec.lua @@ -0,0 +1,20 @@ +local Runner = require("tests.indent.common").Runner + +local run = Runner:new(it, "tests/indent/dart", { + tabstop = 4, + shiftwidth = 2, + softtabstop = 0, + expandtab = true, +}) + +describe("indent Lua:", function() + describe("whole file:", function() + run:whole_file(".", { + expected_failures = {}, + }) + end) +end) + +describe("new line:", function() + run:new_line("class.dart", { on_line = 2, text = "var x;", indent = 0 }) +end) From 2ad12932a26a429750b3343199afd60b93c97b72 Mon Sep 17 00:00:00 2001 From: ExpandingMan Date: Fri, 24 Feb 2023 16:19:46 -0500 Subject: [PATCH 0003/2704] docs: add small note in README clarifying custom parser installation (#3625) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 091a47e90..fdc603100 100644 --- a/README.md +++ b/README.md @@ -471,7 +471,7 @@ local parser_config = require "nvim-treesitter.parsers".get_parser_configs() parser_config.zimbu = { install_info = { url = "~/projects/tree-sitter-zimbu", -- local path or git repo - files = {"src/parser.c"}, + files = {"src/parser.c"}, -- note that some parsers also require src/scanner.c or src/scanner.cc -- optional entries: branch = "main", -- default branch in case of git repo if different from master generate_requires_npm = false, -- if stand-alone parser without npm dependencies From e138c066f7e33464655bd064341483867c43d1fe Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Thu, 23 Feb 2023 23:50:55 -0500 Subject: [PATCH 0004/2704] feat(health): sort parser list for clarity --- lua/nvim-treesitter/parsers.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index de31f4196..0eec2f116 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -1570,12 +1570,14 @@ end -- Get a list of all available parsers ---@return string[] function M.available_parsers() + local parsers = vim.tbl_keys(M.list) + table.sort(parsers) if vim.fn.executable "tree-sitter" == 1 and vim.fn.executable "node" == 1 then - return vim.tbl_keys(M.list) + return parsers else return vim.tbl_filter(function(p) ---@param p string return not M.list[p].install_info.requires_generate_from_grammar - end, vim.tbl_keys(M.list)) + end, parsers) end end From 06e8a91ce2aac663023d40cf57965ffade72c792 Mon Sep 17 00:00:00 2001 From: Tomas Sandven Date: Thu, 7 Apr 2022 10:39:46 +0200 Subject: [PATCH 0005/2704] Add YANG indentation tests --- tests/indent/yang/module.yang | 58 +++++++++++++++++++++++++++++++++++ tests/indent/yang_spec.lua | 23 ++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 tests/indent/yang/module.yang create mode 100644 tests/indent/yang_spec.lua diff --git a/tests/indent/yang/module.yang b/tests/indent/yang/module.yang new file mode 100644 index 000000000..29c911fa0 --- /dev/null +++ b/tests/indent/yang/module.yang @@ -0,0 +1,58 @@ +module test-module { + yang-version 1.1; + namespace "http://example.com"; + prefix test; + + import ietf-inet-types { prefix inet; } + import tailf-ncs { + prefix ncs; + } + + description "Multi-line strings has indentation + aligned with the first line."; + + typedef foo { + type enumeration { + enum "foo"; + enum "bar"; + } + } + + ncs:plan-outline test-nano-service { + description "Testing indentation of extension statements."; + + ncs:component-type "ncs:self" { + ncs:state "ncs:init" { + ncs:create { + ncs:nano-callback; + } + } + ncs:state "ncs:ready"; + } + + ncs:component-type "alloc:resource-allocator" { + ncs:state "ncs:init"; + ncs:state "alloc:resources-allocated"; + ncs:state "ncs:ready"; + } + } + + container test { + } + + augment /alloc:resource-allocator { + description "Augmentation for the resource allocator mock services."; + + list test-nano-service { + key "id"; + + leaf id { + type string; + description + "I'm a multi-line string + + Starting on the next line from the statement."; + } + } + } +} diff --git a/tests/indent/yang_spec.lua b/tests/indent/yang_spec.lua new file mode 100644 index 000000000..c5ff2c886 --- /dev/null +++ b/tests/indent/yang_spec.lua @@ -0,0 +1,23 @@ +local Runner = require("tests.indent.common").Runner + +local run = Runner:new(it, "tests/indent/yang", { + tabstop = 2, + shiftwidth = 2, + softtabstop = 0, + expandtab = true, +}) + +describe("indent YANG:", function() + describe("whole file:", function() + run:whole_file(".", { + expected_failures = {}, + }) + end) + + describe("new line:", function() + run:new_line("module.yang", { on_line = 12, text = "# Aligned indentation ended", indent = 2 }) + run:new_line("module.yang", { on_line = 37, text = "# Test", indent = 2 }) + run:new_line("module.yang", { on_line = 40, text = "# Test", indent = 4 }) + run:new_line("module.yang", { on_line = 52, text = "Aligned string!", indent = 4 }) + end) +end) From 061ee1b98f928a928771f35bba5deb6ad74a15b1 Mon Sep 17 00:00:00 2001 From: Tomas Sandven Date: Sat, 17 Dec 2022 22:58:02 +0100 Subject: [PATCH 0006/2704] Fix broken YANG indent tests --- tests/indent/yang_spec.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/indent/yang_spec.lua b/tests/indent/yang_spec.lua index c5ff2c886..618d260c6 100644 --- a/tests/indent/yang_spec.lua +++ b/tests/indent/yang_spec.lua @@ -15,9 +15,9 @@ describe("indent YANG:", function() end) describe("new line:", function() - run:new_line("module.yang", { on_line = 12, text = "# Aligned indentation ended", indent = 2 }) - run:new_line("module.yang", { on_line = 37, text = "# Test", indent = 2 }) - run:new_line("module.yang", { on_line = 40, text = "# Test", indent = 4 }) - run:new_line("module.yang", { on_line = 52, text = "Aligned string!", indent = 4 }) + run:new_line("module.yang", { on_line = 12, text = "// Aligned indentation ended", indent = 2 }) + run:new_line("module.yang", { on_line = 37, text = "// Test", indent = 4 }) + run:new_line("module.yang", { on_line = 40, text = "// Test", indent = 4 }) + run:new_line("module.yang", { on_line = 52, text = "Aligned string!", indent = 11 }) end) end) From 028b7dfbddffdd4738a25a76b280d9b26f38ce42 Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Thu, 23 Feb 2023 04:42:37 -0500 Subject: [PATCH 0007/2704] feat: add bicep --- README.md | 1 + lockfile.json | 3 + lua/nvim-treesitter/parsers.lua | 8 ++ queries/bicep/folds.scm | 25 ++++ queries/bicep/highlights.scm | 230 ++++++++++++++++++++++++++++++++ queries/bicep/indents.scm | 18 +++ queries/bicep/injections.scm | 4 + queries/bicep/locals.scm | 74 ++++++++++ 8 files changed, 363 insertions(+) create mode 100644 queries/bicep/folds.scm create mode 100644 queries/bicep/highlights.scm create mode 100644 queries/bicep/indents.scm create mode 100644 queries/bicep/injections.scm create mode 100644 queries/bicep/locals.scm diff --git a/README.md b/README.md index fdc603100..7510dfc07 100644 --- a/README.md +++ b/README.md @@ -181,6 +181,7 @@ We are looking for maintainers to add more parsers and to write query files for - [x] [bash](https://github.com/tree-sitter/tree-sitter-bash) (maintained by @TravonteD) - [x] [beancount](https://github.com/polarmutex/tree-sitter-beancount) (maintained by @polarmutex) - [x] [bibtex](https://github.com/latex-lsp/tree-sitter-bibtex) (maintained by @theHamsta, @clason) +- [x] [bicep](https://github.com/amaanq/tree-sitter-bicep) (maintained by @amaanq) - [x] [blueprint](https://gitlab.com/gabmus/tree-sitter-blueprint.git) (experimental, maintained by @gabmus) - [x] [c](https://github.com/tree-sitter/tree-sitter-c) (maintained by @vigoux) - [x] [c_sharp](https://github.com/tree-sitter/tree-sitter-c-sharp) (maintained by @Luxed) diff --git a/lockfile.json b/lockfile.json index ca9770ad7..4e685055d 100644 --- a/lockfile.json +++ b/lockfile.json @@ -23,6 +23,9 @@ "bibtex": { "revision": "ccfd77db0ed799b6c22c214fe9d2937f47bc8b34" }, + "bicep": { + "revision": "b94a0983b69ebb75e9129329a188199ad6ebcec0" + }, "blueprint": { "revision": "6ef91ca8270f0112b9c6d27ecb9966c741a5d103" }, diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index 0eec2f116..4d7f9baf4 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -144,6 +144,14 @@ list.bibtex = { maintainers = { "@theHamsta", "@clason" }, } +list.bicep = { + install_info = { + url = "https://github.com/amaanq/tree-sitter-bicep", + files = { "src/parser.c" }, + }, + maintainers = { "@amaanq" }, +} + list.blueprint = { install_info = { url = "https://gitlab.com/gabmus/tree-sitter-blueprint.git", diff --git a/queries/bicep/folds.scm b/queries/bicep/folds.scm new file mode 100644 index 000000000..8ec5ba200 --- /dev/null +++ b/queries/bicep/folds.scm @@ -0,0 +1,25 @@ +[ + (module_declaration) + (metadata_declaration) + (output_declaration) + (parameter_declaration) + (resource_declaration) + (type_declaration) + (variable_declaration) + + (parenthesized_expression) + + (decorators) + (array) + (object) + + (if_statement) + (for_statement) + + (subscript_expression) + (ternary_expression) + + (string) + + (comment) +] @fold diff --git a/queries/bicep/highlights.scm b/queries/bicep/highlights.scm new file mode 100644 index 000000000..07c2c4efa --- /dev/null +++ b/queries/bicep/highlights.scm @@ -0,0 +1,230 @@ +; Includes + +(import_statement + "import" @include) + +(import_with_statement + "import" @include + "with" @include) + +; Namespaces + +(module_declaration + (identifier) @namespace) + +; Builtins + +(primitive_type) @type.builtin + +((member_expression + object: (identifier) @type.builtin) + (#match? @type.builtin "^sys$")) + +; Functions + +(call_expression + function: (identifier) @function.call) + +; Properties + +(object_property + (identifier) @property + ":" @punctuation.delimiter + (_)) + +(object_property + (compatible_identifier) @property + ":" @punctuation.delimiter + (_)) + +(property_identifier) @property + +; Attributes + +(decorator + "@" @attribute) + +(decorator + (call_expression (identifier) @attribute)) + +(decorator + (call_expression + (member_expression + object: (identifier) @attribute + property: (property_identifier) @attribute))) + +; Types + +(type_declaration + (identifier) @type) + +(type_declaration + (identifier) + "=" + (identifier) @type) + +(type_declaration + (identifier) + "=" + (array_type (identifier) @type)) + +(type + (identifier) @type) + +(resource_declaration + (identifier) @type) + +(resource_expression + (identifier) @type) + +; Parameters + +(parameter_declaration + (identifier) @parameter + (_)) + +(call_expression + function: (_) + (arguments (identifier) @parameter)) + +(call_expression + function: (_) + (arguments (member_expression object: (identifier) @parameter))) + +; Variables + +(variable_declaration + (identifier) @variable + (_)) + +(metadata_declaration + (identifier) @variable + (_)) + +(output_declaration + (identifier) @variable + (_)) + +(object_property + (_) + ":" + (identifier) @variable) + +(for_statement + "for" + (for_loop_parameters + (loop_variable) @variable + (loop_enumerator) @variable)) + +; Conditionals + +"if" @conditional + +(ternary_expression + "?" @conditional.ternary + ":" @conditional.ternary) + +; Loops + +(for_statement + "for" @repeat + "in" + ":" @punctuation.delimiter) + +; Keywords + +[ + "module" + "metadata" + "output" + "param" + "resource" + "existing" + "targetScope" + "type" + "var" +] @keyword + +; Operators + +[ + "+" + "-" + "*" + "/" + "%" + "||" + "&&" + "|" + "==" + "!=" + "=~" + "!~" + ">" + ">=" + "<=" + "<" + "??" + "=" + "!" +] @operator + +[ + "in" +] @keyword.operator + + +; Literals + +(string) @string +(import_string + "'" @string + (import_name) @namespace + "@" @symbol + (import_version) @string.special) + +(escape_sequence) @string.escape + +(number) @number + +(boolean) @boolean + +(null) @constant.builtin + +; Misc + +(compatible_identifier + "?" @punctuation.special) + +(nullable_return_type) @punctuation.special + +["{" "}"] @punctuation.bracket + +["[" "]"] @punctuation.bracket + +["(" ")"] @punctuation.bracket + +[ + "." + "::" + "=>" +] @punctuation.delimiter + + +; Interpolation + +(interpolation) @none + +(interpolation + "${" @punctuation.special + "}" @punctuation.special) + +(interpolation + (identifier) @variable) + +; Comments + +[ + (comment) + (diagnostic_comment) +] @comment @spell diff --git a/queries/bicep/indents.scm b/queries/bicep/indents.scm new file mode 100644 index 000000000..7fcf7ffb9 --- /dev/null +++ b/queries/bicep/indents.scm @@ -0,0 +1,18 @@ +[ + (array) + (object) +] @indent + +"}" @indent_end + +[ "{" "}" ] @branch + +[ "[" "]" ] @branch + +[ "(" ")" ] @branch + +[ + (ERROR) + (comment) + (diagnostic_comment) +] @auto diff --git a/queries/bicep/injections.scm b/queries/bicep/injections.scm new file mode 100644 index 000000000..c85cfe3b6 --- /dev/null +++ b/queries/bicep/injections.scm @@ -0,0 +1,4 @@ +[ + (comment) + (diagnostic_comment) +] @comment diff --git a/queries/bicep/locals.scm b/queries/bicep/locals.scm new file mode 100644 index 000000000..361be94fb --- /dev/null +++ b/queries/bicep/locals.scm @@ -0,0 +1,74 @@ +; Scopes + +[ + (infrastructure) + (call_expression) + + (lambda_expression) + (subscript_expression) + + (if_statement) + (for_statement) + + (array) + (object) + (interpolation) +] @scope + +; References + +(property_identifier) @reference + +(call_expression + (identifier) @reference) + +(object_property + (_) + ":" + (identifier) @reference) + +(resource_expression + (identifier) @reference) + +; Definitions + +(type) @definition.associated + +(object_property + (identifier) @definition.field + (_)) + +(object_property + (compatible_identifier) @definition.field + (_)) + +(import_name) @definition.import + +(module_declaration + (identifier) @definition.namespace) + +(parameter_declaration + (identifier) @definition.parameter + (_)) + +(type_declaration + (identifier) @definition.type + (_)) + +(variable_declaration + (identifier) @definition.var + (_)) + +(metadata_declaration + (identifier) @definition.var + (_)) + +(output_declaration + (identifier) @definition.var + (_)) + +(for_statement + "for" + (for_loop_parameters + (loop_variable) @definition.var + (loop_enumerator) @definition.var)) From a744ed1b274b586a00dcb39dc0da7ba264758efb Mon Sep 17 00:00:00 2001 From: Stephen Bolton Date: Sun, 5 Feb 2023 15:56:46 -0500 Subject: [PATCH 0008/2704] Fix elixir `@function` captures When viewing the previous rule in the `TSPlayground` the `@function` captures were not actually matching. This led all functions to get the `@function.call` group applied to them. This change makes it so that the capture now works and where functions are defined will get the `@function` group. --- queries/elixir/highlights.scm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/queries/elixir/highlights.scm b/queries/elixir/highlights.scm index c3aee40c7..d87afcf1b 100644 --- a/queries/elixir/highlights.scm +++ b/queries/elixir/highlights.scm @@ -111,9 +111,10 @@ "defp" "defprotocol" "defstruct" -)) (arguments [ - (identifier) @function - (binary_operator left: (identifier) @function operator: "when")])?) + )) + (arguments [ + (call (identifier) @function) + (binary_operator left: (call target: (identifier) @function) operator: "when")])?) ; Kernel Keywords & Special Forms (call target: ((identifier) @keyword (#any-of? @keyword From 22de3532cc0a8d8f3bf70962723f5c9a4058852c Mon Sep 17 00:00:00 2001 From: Nat Williams Date: Thu, 2 Feb 2023 09:31:22 -0600 Subject: [PATCH 0009/2704] also pass the node to the statusline transform fn --- lua/nvim-treesitter/ts_utils.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/nvim-treesitter/ts_utils.lua b/lua/nvim-treesitter/ts_utils.lua index 6b330fda4..f0cccc2cc 100644 --- a/lua/nvim-treesitter/ts_utils.lua +++ b/lua/nvim-treesitter/ts_utils.lua @@ -51,7 +51,7 @@ function M._get_line_for_node(node, type_patterns, transform_fn, bufnr) if not is_valid then return "" end - local line = transform_fn(vim.trim(get_node_text(node, bufnr)[1] or "")) + local line = transform_fn(vim.trim(get_node_text(node, bufnr)[1] or ""), node) -- Escape % to avoid statusline to evaluate content as expression return line:gsub("%%", "%%%%") end From 34adfe8e95d31ba21c274ad11c6e16472ba5ef65 Mon Sep 17 00:00:00 2001 From: Nat Williams Date: Thu, 2 Feb 2023 09:42:18 -0600 Subject: [PATCH 0010/2704] update docs for transform_fn to reflect additional node argument --- doc/nvim-treesitter.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/nvim-treesitter.txt b/doc/nvim-treesitter.txt index 61507cb58..f2da04203 100644 --- a/doc/nvim-treesitter.txt +++ b/doc/nvim-treesitter.txt @@ -445,7 +445,7 @@ Default options (lua syntax): { indicator_size = 100, type_patterns = {'class', 'function', 'method'}, - transform_fn = function(line) return line:gsub('%s*[%[%(%{]*%s*$', '') end, + transform_fn = function(line, _node) return line:gsub('%s*[%[%(%{]*%s*$', '') end, separator = ' -> ' } < @@ -453,7 +453,8 @@ Default options (lua syntax): the beginning. - `type_patterns` - Which node type patterns to match. - `transform_fn` - Function used to transform the single item in line. By - default removes opening brackets and spaces from end. + default removes opening brackets and spaces from end. Takes two arguments: + the text of the line in question, and the corresponding treesitter node. - `separator` - Separator between nodes. *nvim_treesitter#foldexpr()* From 3fab7abf6f653eb92eee74c19ce5e655536ced87 Mon Sep 17 00:00:00 2001 From: Nat Williams Date: Thu, 2 Feb 2023 13:16:44 -0600 Subject: [PATCH 0011/2704] add statusline option to dedupe or not --- doc/nvim-treesitter.txt | 4 +++- lua/nvim-treesitter/statusline.lua | 10 ++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/doc/nvim-treesitter.txt b/doc/nvim-treesitter.txt index f2da04203..f8ac369bd 100644 --- a/doc/nvim-treesitter.txt +++ b/doc/nvim-treesitter.txt @@ -446,7 +446,8 @@ Default options (lua syntax): indicator_size = 100, type_patterns = {'class', 'function', 'method'}, transform_fn = function(line, _node) return line:gsub('%s*[%[%(%{]*%s*$', '') end, - separator = ' -> ' + separator = ' -> ', + dedupe = true } < - `indicator_size` - How long should the string be. If longer, it is cut from @@ -456,6 +457,7 @@ Default options (lua syntax): default removes opening brackets and spaces from end. Takes two arguments: the text of the line in question, and the corresponding treesitter node. - `separator` - Separator between nodes. +- `dedupe` - Whether or not to remove duplicate components. *nvim_treesitter#foldexpr()* nvim_treesitter#foldexpr()~ diff --git a/lua/nvim-treesitter/statusline.lua b/lua/nvim-treesitter/statusline.lua index cd75fcb00..fde7def2b 100644 --- a/lua/nvim-treesitter/statusline.lua +++ b/lua/nvim-treesitter/statusline.lua @@ -21,6 +21,10 @@ function M.statusline(opts) local type_patterns = options.type_patterns or { "class", "function", "method" } local transform_fn = options.transform_fn or transform_line local separator = options.separator or " -> " + local dedupe = options.dedupe + if dedupe == nil then + dedupe = true + end local current_node = ts_utils.get_node_at_cursor() if not current_node then @@ -32,8 +36,10 @@ function M.statusline(opts) while expr do local line = ts_utils._get_line_for_node(expr, type_patterns, transform_fn, bufnr) - if line ~= "" and not vim.tbl_contains(lines, line) then - table.insert(lines, 1, line) + if line ~= "" then + if not dedupe or not vim.tbl_contains(lines, line) then + table.insert(lines, 1, line) + end end expr = expr:parent() end From 20a8f30ace9fa9209b1c345311a36e91ab2f6d1d Mon Sep 17 00:00:00 2001 From: Nat Williams Date: Thu, 2 Feb 2023 13:26:20 -0600 Subject: [PATCH 0012/2704] use positive option "allow_duplicates" instead of negative "dedupe" --- doc/nvim-treesitter.txt | 4 ++-- lua/nvim-treesitter/statusline.lua | 7 ++----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/doc/nvim-treesitter.txt b/doc/nvim-treesitter.txt index f8ac369bd..884f334eb 100644 --- a/doc/nvim-treesitter.txt +++ b/doc/nvim-treesitter.txt @@ -447,7 +447,7 @@ Default options (lua syntax): type_patterns = {'class', 'function', 'method'}, transform_fn = function(line, _node) return line:gsub('%s*[%[%(%{]*%s*$', '') end, separator = ' -> ', - dedupe = true + allow_duplicates = false } < - `indicator_size` - How long should the string be. If longer, it is cut from @@ -457,7 +457,7 @@ Default options (lua syntax): default removes opening brackets and spaces from end. Takes two arguments: the text of the line in question, and the corresponding treesitter node. - `separator` - Separator between nodes. -- `dedupe` - Whether or not to remove duplicate components. +- `allow_duplicates` - Whether or not to remove duplicate components. *nvim_treesitter#foldexpr()* nvim_treesitter#foldexpr()~ diff --git a/lua/nvim-treesitter/statusline.lua b/lua/nvim-treesitter/statusline.lua index fde7def2b..68ba41aca 100644 --- a/lua/nvim-treesitter/statusline.lua +++ b/lua/nvim-treesitter/statusline.lua @@ -21,10 +21,7 @@ function M.statusline(opts) local type_patterns = options.type_patterns or { "class", "function", "method" } local transform_fn = options.transform_fn or transform_line local separator = options.separator or " -> " - local dedupe = options.dedupe - if dedupe == nil then - dedupe = true - end + local allow_duplicates = options.allow_duplicates or false local current_node = ts_utils.get_node_at_cursor() if not current_node then @@ -37,7 +34,7 @@ function M.statusline(opts) while expr do local line = ts_utils._get_line_for_node(expr, type_patterns, transform_fn, bufnr) if line ~= "" then - if not dedupe or not vim.tbl_contains(lines, line) then + if allow_duplicates or not vim.tbl_contains(lines, line) then table.insert(lines, 1, line) end end From fe80f7c2bbd216f5a26fe28c91bb335ef9ad8ec2 Mon Sep 17 00:00:00 2001 From: Philipp Mildenberger Date: Mon, 20 Feb 2023 18:05:10 +0100 Subject: [PATCH 0013/2704] feat: add ungrammar --- README.md | 1 + lockfile.json | 3 +++ lua/nvim-treesitter/parsers.lua | 8 ++++++++ queries/ungrammar/folds.scm | 1 + queries/ungrammar/highlights.scm | 30 ++++++++++++++++++++++++++++++ queries/ungrammar/indents.scm | 6 ++++++ queries/ungrammar/injections.scm | 2 ++ queries/ungrammar/locals.scm | 7 +++++++ 8 files changed, 58 insertions(+) create mode 100644 queries/ungrammar/folds.scm create mode 100644 queries/ungrammar/highlights.scm create mode 100644 queries/ungrammar/indents.scm create mode 100644 queries/ungrammar/injections.scm create mode 100644 queries/ungrammar/locals.scm diff --git a/README.md b/README.md index 7510dfc07..74de9992b 100644 --- a/README.md +++ b/README.md @@ -325,6 +325,7 @@ We are looking for maintainers to add more parsers and to write query files for - [x] [turtle](https://github.com/BonaBeavis/tree-sitter-turtle) (maintained by @BonaBeavis) - [x] [twig](https://github.com/gbprod/tree-sitter-twig) (maintained by @gbprod) - [x] [typescript](https://github.com/tree-sitter/tree-sitter-typescript) (maintained by @steelsojka) +- [x] [ungrammar](https://github.com/Philipp-M/tree-sitter-ungrammar) (maintained by @Philipp-M, @amaanq) - [x] [v](https://github.com/vlang/vls) (maintained by @kkharji) - [x] [vala](https://github.com/vala-lang/tree-sitter-vala) (maintained by @Prince781) - [x] [verilog](https://github.com/tree-sitter/tree-sitter-verilog) (maintained by @zegervdv) diff --git a/lockfile.json b/lockfile.json index 4e685055d..6c6516d4f 100644 --- a/lockfile.json +++ b/lockfile.json @@ -455,6 +455,9 @@ "typescript": { "revision": "5d20856f34315b068c41edaee2ac8a100081d259" }, + "ungrammar": { + "revision": "5275e45d1edb16aab4f0d63a3aa15b61ef033a9c" + }, "v": { "revision": "136f3a0ad91ab8a781c2d4eb419df0a981839f69" }, diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index 4d7f9baf4..c570343bd 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -1451,6 +1451,14 @@ list.typescript = { maintainers = { "@steelsojka" }, } +list.ungrammar = { + install_info = { + url = "https://github.com/Philipp-M/tree-sitter-ungrammar", + files = { "src/parser.c" }, + }, + maintainers = { "@Philipp-M", "@amaanq" }, +} + list.v = { install_info = { url = "https://github.com/vlang/vls", diff --git a/queries/ungrammar/folds.scm b/queries/ungrammar/folds.scm new file mode 100644 index 000000000..206c4bed8 --- /dev/null +++ b/queries/ungrammar/folds.scm @@ -0,0 +1 @@ +(node) @fold diff --git a/queries/ungrammar/highlights.scm b/queries/ungrammar/highlights.scm new file mode 100644 index 000000000..027c6e008 --- /dev/null +++ b/queries/ungrammar/highlights.scm @@ -0,0 +1,30 @@ +(comment) @comment + +(definition) @keyword + +(identifier) @variable + +(label_name) @label + +(token) @string + +[ + "=" + "|" +] @operator + +[ + "*" + "?" +] @repeat + +[ + ":" +] @punctuation.delimiter + +[ + "(" + ")" +] @punctuation.bracket + +(ERROR) @error diff --git a/queries/ungrammar/indents.scm b/queries/ungrammar/indents.scm new file mode 100644 index 000000000..d4b7c085d --- /dev/null +++ b/queries/ungrammar/indents.scm @@ -0,0 +1,6 @@ +(node) @indent + +[ + (ERROR) + (comment) +] @auto diff --git a/queries/ungrammar/injections.scm b/queries/ungrammar/injections.scm new file mode 100644 index 000000000..35c0af746 --- /dev/null +++ b/queries/ungrammar/injections.scm @@ -0,0 +1,2 @@ +(comment) @comment + diff --git a/queries/ungrammar/locals.scm b/queries/ungrammar/locals.scm new file mode 100644 index 000000000..9fd87e637 --- /dev/null +++ b/queries/ungrammar/locals.scm @@ -0,0 +1,7 @@ +(grammar) @scope + +(definition) @definition + +(label_name) @definition.label + +(identifier) @reference From 53695580e38d9ab5f858e8966275f1992bd2e2ec Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Thu, 23 Feb 2023 23:19:59 -0500 Subject: [PATCH 0014/2704] feat(dart): add folds --- queries/dart/folds.scm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 queries/dart/folds.scm diff --git a/queries/dart/folds.scm b/queries/dart/folds.scm new file mode 100644 index 000000000..ea398a4b3 --- /dev/null +++ b/queries/dart/folds.scm @@ -0,0 +1,15 @@ +[ + (class_definition) + (enum_declaration) + (extension_declaration) + + (arguments) + (function_body) + + (block) + (switch_block) + + (list_literal) + (set_or_map_literal) + (string_literal) +] @fold From df968afd9dd444990c0e7844c92aa20603e9ced1 Mon Sep 17 00:00:00 2001 From: Kiyoon Kim Date: Tue, 7 Feb 2023 06:25:27 +0000 Subject: [PATCH 0015/2704] goto_node select last character when in operator-pending mode --- lua/nvim-treesitter/ts_utils.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lua/nvim-treesitter/ts_utils.lua b/lua/nvim-treesitter/ts_utils.lua index f0cccc2cc..373bae340 100644 --- a/lua/nvim-treesitter/ts_utils.lua +++ b/lua/nvim-treesitter/ts_utils.lua @@ -452,6 +452,14 @@ function M.goto_node(node, goto_end, avoid_set_jump) else position = { range[3], range[4] } end + + -- Enter visual mode if we are in operator pending mode + -- If we don't do this, it will miss the last character. + local mode = vim.api.nvim_get_mode() + if mode.mode == "no" then + vim.cmd "normal! v" + end + -- Position is 1, 0 indexed. api.nvim_win_set_cursor(0, { position[1], position[2] - 1 }) end From ad8798795c71a00e796e1919c905a6bf815e9359 Mon Sep 17 00:00:00 2001 From: GitHub Date: Sat, 25 Feb 2023 06:39:20 +0000 Subject: [PATCH 0016/2704] Update parsers: cpon, javascript, perl, tsx, typescript --- lockfile.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lockfile.json b/lockfile.json index 6c6516d4f..2d4359501 100644 --- a/lockfile.json +++ b/lockfile.json @@ -57,7 +57,7 @@ "revision": "5e113412aadb78955c27010daa4dbe1d202013cf" }, "cpon": { - "revision": "b894a70f883d2cb7505b87a9d84a189fe8cd1982" + "revision": "eedb93bf9e22e82ed6a67e6c57fd78731b44f591" }, "cpp": { "revision": "66262d3e76eb2046c76e6d661a6b72664bfb5819" @@ -216,7 +216,7 @@ "revision": "3c24aa9365985830421a3a7b6791b415961ea770" }, "javascript": { - "revision": "266455e22fc54f0add4dd2404ebe307d4d65deae" + "revision": "5720b249490b3c17245ba772f6be4a43edb4e3b7" }, "jq": { "revision": "13990f530e8e6709b7978503da9bc8701d366791" @@ -309,7 +309,7 @@ "revision": "9e995404ddff8319631d72d4b46552e737206912" }, "perl": { - "revision": "749d26fe13fb131b92e6515416096e572575b981" + "revision": "3e4b9cad82a3e7e45390b751528dce581eb092b7" }, "php": { "revision": "f860e598194f4a71747f91789bf536b393ad4a56" @@ -444,7 +444,7 @@ "revision": "8bd2056818b21860e3d756b5a58c4f6e05fb744e" }, "tsx": { - "revision": "5d20856f34315b068c41edaee2ac8a100081d259" + "revision": "c6e56d44c686a67c89e29e773e662567285d610f" }, "turtle": { "revision": "085437f5cb117703b7f520dd92161140a684f092" @@ -453,7 +453,7 @@ "revision": "2457993b13a06dec2706e6a6c3d5b65bb23024b8" }, "typescript": { - "revision": "5d20856f34315b068c41edaee2ac8a100081d259" + "revision": "c6e56d44c686a67c89e29e773e662567285d610f" }, "ungrammar": { "revision": "5275e45d1edb16aab4f0d63a3aa15b61ef033a9c" From 248a87ef6587b7ccfaaf4b6b405cec50849b0f8c Mon Sep 17 00:00:00 2001 From: Benny Powers Date: Thu, 13 Oct 2022 18:04:04 +0300 Subject: [PATCH 0017/2704] feat(ecma): add innerHTML injection --- queries/ecma/injections.scm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/queries/ecma/injections.scm b/queries/ecma/injections.scm index 6bd5da862..a901f34b3 100644 --- a/queries/ecma/injections.scm +++ b/queries/ecma/injections.scm @@ -67,3 +67,18 @@ (((template_string) @_template_string (#match? @_template_string "^`#graphql")) @graphql) + +; el.innerHTML = `` +(assignment_expression + left: (member_expression + property: (property_identifier) @_prop + (#eq? @_prop "innerHTML")) + right: (template_string) @html + (#offset! @html 0 1 0 -1)) +; el.innerHTML = '' +(assignment_expression + left: (member_expression + property: (property_identifier) @_prop + (#eq? @_prop "innerHTML")) + right: (string) @html + (#offset! @html 0 1 0 -1)) From 8d2f9903f11542c3363353a65a8e08adfcca9d29 Mon Sep 17 00:00:00 2001 From: Benny Powers Date: Thu, 13 Oct 2022 18:08:56 +0300 Subject: [PATCH 0018/2704] feat(ecma): include outerHTML and innerHTML --- queries/ecma/injections.scm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/queries/ecma/injections.scm b/queries/ecma/injections.scm index a901f34b3..43596ecb2 100644 --- a/queries/ecma/injections.scm +++ b/queries/ecma/injections.scm @@ -72,13 +72,14 @@ (assignment_expression left: (member_expression property: (property_identifier) @_prop - (#eq? @_prop "innerHTML")) + (#match? @_prop "(out|inn)erHTML")) right: (template_string) @html (#offset! @html 0 1 0 -1)) + ; el.innerHTML = '' (assignment_expression left: (member_expression property: (property_identifier) @_prop - (#eq? @_prop "innerHTML")) + (#match? @_prop "(out|inn)erHTML")) right: (string) @html (#offset! @html 0 1 0 -1)) From 4f8f4fe4c13939093e070da077698796a034fd7f Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sun, 26 Feb 2023 00:21:41 +0100 Subject: [PATCH 0019/2704] fix: do not recommend removing bundled parsers --- lua/nvim-treesitter/install.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lua/nvim-treesitter/install.lua b/lua/nvim-treesitter/install.lua index a82da7885..ba8cada87 100644 --- a/lua/nvim-treesitter/install.lua +++ b/lua/nvim-treesitter/install.lua @@ -643,8 +643,7 @@ function M.uninstall(...) vim.notify( "Tried to uninstall parser for " .. lang - .. "! But the parser is still installed (not by nvim-treesitter)." - .. " Please delete the following files manually: " + .. "! But the parser is still installed (not by nvim-treesitter):" .. table.concat(all_parsers_after_deletion, ", "), vim.log.levels.ERROR ) From b4d8b7e5a374b800838a13aa6829ac4d542c6f1c Mon Sep 17 00:00:00 2001 From: GitHub Date: Sun, 26 Feb 2023 06:39:18 +0000 Subject: [PATCH 0020/2704] Update parsers: clojure, latex, perl --- lockfile.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lockfile.json b/lockfile.json index 2d4359501..b038fc74e 100644 --- a/lockfile.json +++ b/lockfile.json @@ -42,7 +42,7 @@ "revision": "3baf22e7e507cedf15d1dbc03df8afa50a625586" }, "clojure": { - "revision": "262d6d60f39f0f77b3dd08da8ec895bd5a044416" + "revision": "421546c2547c74d1d9a0d8c296c412071d37e7ca" }, "cmake": { "revision": "399605a02bcd5daa309ce63a6459c600dce3473f" @@ -249,7 +249,7 @@ "revision": "7744b56f03ac1e5643fad23c9dd90837fe97291e" }, "latex": { - "revision": "6b7ea839307670e6bda011f888717d3a882ecc09" + "revision": "376f64097b7a26691a2ca60dc94e4dfa417be932" }, "ledger": { "revision": "f787ae635ca79589faa25477b94291a87e2d3e23" @@ -309,7 +309,7 @@ "revision": "9e995404ddff8319631d72d4b46552e737206912" }, "perl": { - "revision": "3e4b9cad82a3e7e45390b751528dce581eb092b7" + "revision": "c43bae0090cfcfc62d9904312599ded1b645a66d" }, "php": { "revision": "f860e598194f4a71747f91789bf536b393ad4a56" From 50709361378fa37d455b21fb716169416888314f Mon Sep 17 00:00:00 2001 From: Benny Powers Date: Mon, 17 Oct 2022 21:13:17 +0300 Subject: [PATCH 0021/2704] feat(html): lit attr binding interpolation --- queries/html_tags/injections.scm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/queries/html_tags/injections.scm b/queries/html_tags/injections.scm index 1c8cdf6ab..c29619281 100644 --- a/queries/html_tags/injections.scm +++ b/queries/html_tags/injections.scm @@ -63,4 +63,14 @@ (quoted_attribute_value (attribute_value) @css)) (#eq? @_attr "style")) +; lit-html style template interpolation +((attribute + (quoted_attribute_value (attribute_value) @javascript)) + (#match? @javascript "\\$\\{") + (#offset! @javascript 0 2 0 -1)) +((attribute + (attribute_value) @javascript) + (#match? @javascript "\\$\\{") + (#offset! @javascript 0 2 0 -2)) + (comment) @comment From a9f0b1c2ba1d70de9189e1ade0e65346ad08849b Mon Sep 17 00:00:00 2001 From: GitHub Date: Mon, 27 Feb 2023 06:41:13 +0000 Subject: [PATCH 0022/2704] Update parsers: c_sharp, fortran, swift --- lockfile.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lockfile.json b/lockfile.json index b038fc74e..a3e3f471e 100644 --- a/lockfile.json +++ b/lockfile.json @@ -33,7 +33,7 @@ "revision": "f35789006ccbe5be8db21d1a2dd4cc0b5a1286f2" }, "c_sharp": { - "revision": "3a5de1b38136add719c2e4dfba64359619745ae6" + "revision": "fc6be5ae61c8788e0c028e757f132d67bfc538f5" }, "capnp": { "revision": "fc6e2addf103861b9b3dffb82c543eb6b71061aa" @@ -123,7 +123,7 @@ "revision": "c238f4af9a5723a212cf1a4c9b31dd5c1d5270a2" }, "fortran": { - "revision": "67cf1c96fd0dd92edd7812a95626c86c9be0781a" + "revision": "31552ac43ecaffa443a12ebea68cc526d334892f" }, "fsh": { "revision": "fa3347712f7a59ed02ccf508284554689c6cde28" @@ -414,7 +414,7 @@ "revision": "52e122ae68b316d3aa960a0a422d3645ba717f42" }, "swift": { - "revision": "0c32d2948b79939b6464d9ced40fca43912cd486" + "revision": "c249318113629435c75c7eedfd5d5bfcb4b6d12a" }, "sxhkdrc": { "revision": "440d5f913d9465c9c776a1bd92334d32febcf065" From cf718048ca2a43701931ccba445cf17502641d53 Mon Sep 17 00:00:00 2001 From: Uy Ha Date: Mon, 27 Feb 2023 15:26:11 +0000 Subject: [PATCH 0023/2704] simplify cmake highlight queries --- queries/cmake/highlights.scm | 138 +---------------------------------- 1 file changed, 2 insertions(+), 136 deletions(-) diff --git a/queries/cmake/highlights.scm b/queries/cmake/highlights.scm index 0e846507d..b96323420 100644 --- a/queries/cmake/highlights.scm +++ b/queries/cmake/highlights.scm @@ -97,143 +97,9 @@ ) (normal_command - (identifier) @_function - (#match? @_function "\\c^set$") - ( - (argument) @constant - (#any-of? @constant "PARENT_SCOPE") - ) . -) - -(normal_command - (identifier) @_function - (#match? @_function "\\c^set$") - . (argument) - ( - (argument) @_cache @storageclass - . - (argument) @_type @type - (#any-of? @_cache "CACHE") - (#any-of? @_type "BOOL" "FILEPATH" "PATH" "STRING" "INTERNAL") - ) -) -(normal_command - (identifier) @_function - (#match? @_function "\\c^set$") - . (argument) - (argument) @_cache - (#any-of? @_cache "CACHE") - ( - (argument) @_force @constant - (#any-of? @_force "FORCE") - ) . -) - -(normal_command - (identifier) @_function - (#match? @_function "\\c^unset$") - . (argument) @variable -) -(normal_command - (identifier) @_function - (#match? @_function "\\c^unset$") - . (argument) - (argument) @storageclass - (#any-of? @storageclass "CACHE" "PARENT_SCOPE") -) - -(normal_command - (identifier) @_function - (#match? @_function "\\c^list$") - . (argument) @constant - (#any-of? @constant "LENGTH" "GET" "JOIN" "SUBLIST" "FIND") - . (argument) @variable - (argument) @variable . -) -(normal_command - (identifier) @_function - (#match? @_function "\\c^list$") - . (argument) @constant - . (argument) @variable - (#any-of? @constant "APPEND" "FILTER" "INSERT" - "POP_BACK" "POP_FRONT" "PREPEND" - "REMOVE_ITEM" "REMOVE_AT" "REMOVE_DUPLICATES" - "REVERSE" "SORT") -) -(normal_command - (identifier) @_function - (#match? @_function "\\c^list$") - . (argument) @_transform @constant - . (argument) @variable - . (argument) @_action @constant - (#match? @_transform "TRANSFORM") - (#any-of? @_action "APPEND" "PREPEND" "TOUPPER" "TOLOWER" "STRIP" "GENEX_STRIP" "REPLACE") -) -(normal_command - (identifier) @_function - (#match? @_function "\\c^list$") - . (argument) @_transform @constant - . (argument) @variable - . (argument) @_action @constant - . (argument)? @_selector @constant - (#match? @_transform "TRANSFORM") - (#any-of? @_action "APPEND" "PREPEND" "TOUPPER" "TOLOWER" "STRIP" "GENEX_STRIP" "REPLACE") - (#any-of? @_selector "AT" "FOR" "REGEX") -) -(normal_command - (identifier) @_function - (#match? @_function "\\c^list$") - . (argument) @_transform @constant - (argument) @constant . - (argument) @variable - (#match? @_transform "TRANSFORM") - (#match? @constant "OUTPUT_VARIABLE") -) - -(normal_command - (identifier) @_function - (#match? @_function "\\c^add_custom_target$") - . (argument) + (identifier) (argument) @constant - (#any-of? @constant "ALL" "COMMAND" "DEPENDS" "BYPRODUCTS" "WORKING_DIRECTORY" "COMMENT" - "JOB_POOL" "VERBATIM" "USES_TERMINAL" "COMMAND_EXPAND_LISTS" "SOURCES") -) - -(normal_command - (identifier) @_function - (#match? @_function "\\c^add_custom_command$") - (argument) @constant - (#any-of? @constant "OUTPUT" "COMMAND" "MAIN_DEPENDENCY" "DEPENDS" "BYPRODUCTS" "IMPLICIT_DEPENDS" "WORKING_DIRECTORY" - "COMMENT" "DEPFILE" "JOB_POOL" "VERBATIM" "APPEND" "USES_TERMINAL" "COMMAND_EXPAND_LISTS") -) - -(normal_command - (identifier) @_function - (#match? @_function "\\c^include$") - (argument) @constant - (#any-of? @constant "OPTIONAL" "NO_POLICY_SCOPE") -) -(normal_command - (identifier) @_function - (#match? @_function "\\c^include$") - (argument) @constant - . - (argument) @variable - (#match? @constant "RESULT_VARIABLE") -) - -(normal_command - (identifier) @_function - (#match? @_function "\\c^project$") - (argument) @constant - (#any-of? @constant "VERSION" "DESCRIPTION" "HOMEPAGE_URL" "LANGUAGES") -) - -(normal_command - (identifier) @_function - (#match? @_function "\\c^cmake_minimum_required$") - (argument) @constant - (#any-of? @constant "VERSION" "FATAL_ERROR") + (#match? @constant "^[A-Z][A-Z_]+$") ) (escape_sequence) @string.escape From a5a6590f157608f2c90c3bb674c2fe019931a020 Mon Sep 17 00:00:00 2001 From: Uy Ha Date: Mon, 27 Feb 2023 15:31:47 +0000 Subject: [PATCH 0024/2704] only match unquoted arguments --- queries/cmake/highlights.scm | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/queries/cmake/highlights.scm b/queries/cmake/highlights.scm index b96323420..576e19cd8 100644 --- a/queries/cmake/highlights.scm +++ b/queries/cmake/highlights.scm @@ -91,15 +91,15 @@ ) (normal_command - (identifier) @_function - . (argument) @variable - (#match? @_function "\\c^set$") + (identifier) + (argument (unquoted_argument)) @constant + (#match? @constant "^[A-Z][A-Z_]+$") ) (normal_command - (identifier) - (argument) @constant - (#match? @constant "^[A-Z][A-Z_]+$") + (identifier) @_function + . (argument) @variable + (#match? @_function "\\c^set$") ) (escape_sequence) @string.escape From 28475d5676c478c55ecc293c75b10bcb782467df Mon Sep 17 00:00:00 2001 From: Uy Ha Date: Mon, 27 Feb 2023 16:55:01 +0000 Subject: [PATCH 0025/2704] add highlighting for elseif --- queries/cmake/highlights.scm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/queries/cmake/highlights.scm b/queries/cmake/highlights.scm index 576e19cd8..f528a04dc 100644 --- a/queries/cmake/highlights.scm +++ b/queries/cmake/highlights.scm @@ -84,6 +84,18 @@ "VERSION_LESS" "VERSION_GREATER" "VERSION_EQUAL" "VERSION_LESS_EQUAL" "VERSION_GREATER_EQUAL" ) ) +(elseif_command + (elseif) + (argument) @keyword.operator + (#any-of? @keyword.operator "NOT" "AND" "OR" + "COMMAND" "POLICY" "TARGET" "TEST" "DEFINED" "IN_LIST" + "EXISTS" "IS_NEWER_THAN" "IS_DIRECTORY" "IS_SYMLINK" "IS_ABSOLUTE" + "MATCHES" + "LESS" "GREATER" "EQUAL" "LESS_EQUAL" "GREATER_EQUAL" + "STRLESS" "STRGREATER" "STREQUAL" "STRLESS_EQUAL" "STRGREATER_EQUAL" + "VERSION_LESS" "VERSION_GREATER" "VERSION_EQUAL" "VERSION_LESS_EQUAL" "VERSION_GREATER_EQUAL" + ) +) (normal_command (identifier) @function.builtin From 04b87c7b6e9a4cb81e5f21aba689811c8bed85dc Mon Sep 17 00:00:00 2001 From: Uy Ha Date: Mon, 27 Feb 2023 20:21:40 +0100 Subject: [PATCH 0026/2704] move the catch uppercase query to the top to make it overridable, add back the more useful queries --- queries/cmake/highlights.scm | 77 ++++++++++++++++++++++++++++++++++-- 1 file changed, 73 insertions(+), 4 deletions(-) diff --git a/queries/cmake/highlights.scm b/queries/cmake/highlights.scm index f528a04dc..8a471fd1c 100644 --- a/queries/cmake/highlights.scm +++ b/queries/cmake/highlights.scm @@ -1,3 +1,9 @@ +(normal_command + (identifier) + (argument (unquoted_argument)) @constant + (#match? @constant "^[A-Z][A-Z_]+$") +) + [ (quoted_argument) (bracket_argument) @@ -103,15 +109,78 @@ ) (normal_command - (identifier) - (argument (unquoted_argument)) @constant - (#match? @constant "^[A-Z][A-Z_]+$") + (identifier) @_function + . (argument) @variable + (#match? @_function "\\c^set$") ) (normal_command (identifier) @_function - . (argument) @variable (#match? @_function "\\c^set$") + . (argument) + ( + (argument) @_cache @storageclass + . + (argument) @_type @type + (#any-of? @_cache "CACHE") + (#any-of? @_type "BOOL" "FILEPATH" "PATH" "STRING" "INTERNAL") + ) +) + +(normal_command + (identifier) @_function + (#match? @_function "\\c^unset$") + . (argument) + (argument) @storageclass + (#any-of? @storageclass "CACHE" "PARENT_SCOPE") +) + +(normal_command + (identifier) @_function + (#match? @_function "\\c^list$") + . (argument) @constant + (#any-of? @constant "LENGTH" "GET" "JOIN" "SUBLIST" "FIND") + . (argument) @variable + (argument) @variable . +) +(normal_command + (identifier) @_function + (#match? @_function "\\c^list$") + . (argument) @constant + . (argument) @variable + (#any-of? @constant "APPEND" "FILTER" "INSERT" + "POP_BACK" "POP_FRONT" "PREPEND" + "REMOVE_ITEM" "REMOVE_AT" "REMOVE_DUPLICATES" + "REVERSE" "SORT") +) +(normal_command + (identifier) @_function + (#match? @_function "\\c^list$") + . (argument) @_transform @constant + . (argument) @variable + . (argument) @_action @constant + (#match? @_transform "TRANSFORM") + (#any-of? @_action "APPEND" "PREPEND" "TOUPPER" "TOLOWER" "STRIP" "GENEX_STRIP" "REPLACE") +) +(normal_command + (identifier) @_function + (#match? @_function "\\c^list$") + . (argument) @_transform @constant + . (argument) @variable + . (argument) @_action @constant + . (argument)? @_selector @constant + (#match? @_transform "TRANSFORM") + (#any-of? @_action "APPEND" "PREPEND" "TOUPPER" "TOLOWER" "STRIP" "GENEX_STRIP" "REPLACE") + (#any-of? @_selector "AT" "FOR" "REGEX") +) +(normal_command + (identifier) @_function + (#match? @_function "\\c^list$") + . (argument) @_transform @constant + (argument) @constant . + (argument) @variable + (#match? @_transform "TRANSFORM") + (#match? @constant "OUTPUT_VARIABLE") ) (escape_sequence) @string.escape From b9a7591b6c23c983256d034bedd5f509edc6351d Mon Sep 17 00:00:00 2001 From: Philipp Mildenberger Date: Mon, 20 Feb 2023 17:55:06 +0100 Subject: [PATCH 0027/2704] feat: add yuck --- README.md | 1 + lockfile.json | 3 + lua/nvim-treesitter/parsers.lua | 9 ++ queries/yuck/folds.scm | 9 ++ queries/yuck/highlights.scm | 209 ++++++++++++++++++++++++++++++++ queries/yuck/indents.scm | 25 ++++ queries/yuck/injections.scm | 1 + queries/yuck/locals.scm | 21 ++++ 8 files changed, 278 insertions(+) create mode 100644 queries/yuck/folds.scm create mode 100644 queries/yuck/highlights.scm create mode 100644 queries/yuck/indents.scm create mode 100644 queries/yuck/injections.scm create mode 100644 queries/yuck/locals.scm diff --git a/README.md b/README.md index 74de9992b..9ba980f97 100644 --- a/README.md +++ b/README.md @@ -336,6 +336,7 @@ We are looking for maintainers to add more parsers and to write query files for - [x] [wgsl_bevy](https://github.com/theHamsta/tree-sitter-wgsl-bevy) (maintained by @theHamsta) - [x] [yaml](https://github.com/ikatyang/tree-sitter-yaml) (maintained by @stsewd) - [x] [yang](https://github.com/Hubro/tree-sitter-yang) (maintained by @Hubro) +- [x] [yuck](https://github.com/Philipp-M/tree-sitter-yuck) (maintained by @Philipp-M, @amaanq) - [x] [zig](https://github.com/maxxnino/tree-sitter-zig) (maintained by @maxxnino) diff --git a/lockfile.json b/lockfile.json index a3e3f471e..410e06557 100644 --- a/lockfile.json +++ b/lockfile.json @@ -488,6 +488,9 @@ "yang": { "revision": "2c0e6be8dd4dcb961c345fa35c309ad4f5bd3502" }, + "yuck": { + "revision": "607bf03cc78912cbaa85a3d373af21ddeaef5b41" + }, "zig": { "revision": "6b3f5788f38be900b45f5af5a753bf6a37d614b8" } diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index c570343bd..75efd7fca 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -1551,6 +1551,15 @@ list.yang = { filetype = "yang", } +list.yuck = { + install_info = { + url = "https://github.com/Philipp-M/tree-sitter-yuck", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@Philipp-M", "@amaanq" }, + filetype = "yuck", +} + list.zig = { install_info = { url = "https://github.com/maxxnino/tree-sitter-zig", diff --git a/queries/yuck/folds.scm b/queries/yuck/folds.scm new file mode 100644 index 000000000..bad5a07c9 --- /dev/null +++ b/queries/yuck/folds.scm @@ -0,0 +1,9 @@ +[ + (ast_block) + (list) + (array) + (expr) + (json_array) + (json_object) + (parenthesized_expression) +] @fold diff --git a/queries/yuck/highlights.scm b/queries/yuck/highlights.scm new file mode 100644 index 000000000..8b2ca5814 --- /dev/null +++ b/queries/yuck/highlights.scm @@ -0,0 +1,209 @@ +; Tags + +(list + (symbol) @tag) + +; Includes + +((symbol) @include + (#match? @include "include")) + +; Keywords + +((symbol) @keyword + (#any-of? @keyword "defwindow" "defwidget" "defvar" "defpoll" "deflisten" "for" "geometry" "children" "struts")) + +; Functions + +(function_call + name: (ident) @function.call) + +; Variables + +(array + (symbol) @variable) + +(binary_expression + (simplexpr + (ident) @variable)) + +(unary_expression + (simplexpr + (ident) @variable)) + +(ternary_expression + (simplexpr + (ident) @variable)) + +(array + (symbol) @variable) + +(json_access + (simplexpr + (ident) @variable)) + +(json_safe_access + (simplexpr + (ident) @variable)) + +(json_array + (simplexpr + (ident) @variable)) + +(json_dot_access + (simplexpr + (ident) @variable)) + +(json_safe_dot_access + (simplexpr + (ident) @variable)) + +(json_object + (_) + ":" + (simplexpr + (ident) @variable)) + +; Properties & Fields + +(keyword) @property + +(json_access + (_) + "[" + (simplexpr + (ident) @property)) + +(json_safe_access + (_) + "?." + "[" + (simplexpr + (ident) @property)) + +(json_dot_access + (index) @property) + +(json_safe_dot_access + (index) @property) + +(json_object + (simplexpr + (ident) @field)) + +; Operators + +[ + "+" + "-" + "*" + "/" + "%" + "&&" + "||" + "==" + "!=" + "=~" + ">=" + "<=" + ">" + "<" + "?:" + "?." + "!" +] @operator + +(ternary_expression + ["?" ":"] @conditional.ternary) + +; Properties & Fields + +(keyword) @property + +(json_access + (_) + "[" + (simplexpr + (ident) @property)) + +(json_safe_access + (_) + "?." + "[" + (simplexpr + (ident) @property)) + +(json_dot_access + (index) @property) + +(json_safe_dot_access + (index) @property) + +(json_object + (simplexpr + (ident) @field)) + +; Operators + +[ + "+" + "-" + "*" + "/" + "%" + "||" + "&&" + "==" + "!=" + "=~" + ">" + "<" + ">=" + "<=" + "!" + "?." +] @operator + +(ternary_expression + ["?" ":"] @conditional.ternary) + +; Punctuation + +[ + ":" + "." + "," +] @punctuation.delimiter + +["{" "}" "[" "]" "(" ")"] @punctuation.bracket + +; Literals + +(number) @number + +(float) @float + +(boolean) @boolean + +; Strings + +[ (string_fragment) "\"" "'" "`" ] @string + +(string_interpolation + "${" @punctuation.special + "}" @punctuation.special) + +(escape_sequence) @string.escape + +; Comments + +(comment) @comment @spell + +; Other stuff that has not been catched by the previous queries yet + +(ident) @variable +(index) @property + +; Errors + +(ERROR) @error diff --git a/queries/yuck/indents.scm b/queries/yuck/indents.scm new file mode 100644 index 000000000..b53ba75dd --- /dev/null +++ b/queries/yuck/indents.scm @@ -0,0 +1,25 @@ +[ + (ast_block) + (array) + (expr) + (json_array) + (json_object) + (parenthesized_expression) +] @indent + +; TODO: can't get this to work, goal is to indent at the property ":" prefix +; ((list (identifier) (property)) @aligned_indent +; (#set! "delimiter" ":")) + +[")" "}" "]"] @indent_end + +[ "{" "}" ] @branch + +[ "(" ")" ] @branch + +[ "[" "]" ] @branch + +[ + (ERROR) + (comment) +] @auto diff --git a/queries/yuck/injections.scm b/queries/yuck/injections.scm new file mode 100644 index 000000000..4bb7d675d --- /dev/null +++ b/queries/yuck/injections.scm @@ -0,0 +1 @@ +(comment) @comment diff --git a/queries/yuck/locals.scm b/queries/yuck/locals.scm new file mode 100644 index 000000000..677281b0b --- /dev/null +++ b/queries/yuck/locals.scm @@ -0,0 +1,21 @@ +[ + (ast_block) + (list) + (array) + (expr) + (json_array) + (json_object) + (parenthesized_expression) +] @scope + +(symbol) @reference + +(keyword) @definition.field + +(json_object + (simplexpr + (ident) @definition.field)) + +(ast_block + (symbol) + (ident) @definition.type) From e2a9fc8e5c15e1be1b9ce1210d2b2667707d1ae5 Mon Sep 17 00:00:00 2001 From: Uy Ha Date: Tue, 28 Feb 2023 02:11:09 +0100 Subject: [PATCH 0028/2704] use lua-match where possible --- queries/cmake/highlights.scm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/queries/cmake/highlights.scm b/queries/cmake/highlights.scm index 8a471fd1c..055319978 100644 --- a/queries/cmake/highlights.scm +++ b/queries/cmake/highlights.scm @@ -1,7 +1,7 @@ (normal_command (identifier) (argument (unquoted_argument)) @constant - (#match? @constant "^[A-Z][A-Z_]+$") + (#lua-match? @constant "^%u[%u_]+$") ) [ @@ -186,4 +186,4 @@ (escape_sequence) @string.escape ((source_file . (line_comment) @preproc) - (#match? @preproc "^#!/")) + (#lua-match? @preproc "^#!/")) From 5cfb5d776812296a7b77d0d74d63a5f77df22327 Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Sat, 25 Feb 2023 19:40:08 -0500 Subject: [PATCH 0029/2704] feat(fortran): update highlight queries --- README.md | 2 +- lua/nvim-treesitter/parsers.lua | 1 + queries/fortran/highlights.scm | 382 ++++++++++++++++++++++---------- 3 files changed, 265 insertions(+), 120 deletions(-) diff --git a/README.md b/README.md index 9ba980f97..ce129942b 100644 --- a/README.md +++ b/README.md @@ -214,7 +214,7 @@ We are looking for maintainers to add more parsers and to write query files for - [x] [fennel](https://github.com/travonted/tree-sitter-fennel) (maintained by @TravonteD) - [x] [fish](https://github.com/ram02z/tree-sitter-fish) (maintained by @ram02z) - [x] [foam](https://github.com/FoamScience/tree-sitter-foam) (experimental, maintained by @FoamScience) -- [ ] [fortran](https://github.com/stadelmanma/tree-sitter-fortran) +- [x] [fortran](https://github.com/stadelmanma/tree-sitter-fortran) (maintained by @amaanq) - [x] [fsh](https://github.com/mgramigna/tree-sitter-fsh) (maintained by @mgramigna) - [x] [func](https://github.com/amaanq/tree-sitter-func) (maintained by @amaanq) - [x] [fusion](https://gitlab.com/jirgn/tree-sitter-fusion.git) (maintained by @jirgn) diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index 75efd7fca..fa5795335 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -443,6 +443,7 @@ list.fortran = { url = "https://github.com/stadelmanma/tree-sitter-fortran", files = { "src/parser.c", "src/scanner.cc" }, }, + maintainers = { "@amaanq" }, } list.fsh = { diff --git a/queries/fortran/highlights.scm b/queries/fortran/highlights.scm index 95839184a..4604e9a92 100644 --- a/queries/fortran/highlights.scm +++ b/queries/fortran/highlights.scm @@ -1,96 +1,224 @@ -(identifier) @variable -(string_literal) @string -(number_literal) @number -(boolean_literal) @boolean -(comment) @comment +; Preprocs + +(preproc_file_line) @preproc + +; Namespaces + +(program_statement + (name) @namespace) + +(end_program_statement + (name) @namespace) + +(module_statement + (name) @namespace) + +(end_module_statement + (name) @namespace) + +(submodule_statement + (name) @namespace) + +(end_submodule_statement + (name) @namespace) + +; Includes [ - (intrinsic_type) - "pointer" -] @type - -[ - "allocatable" - "attributes" - "device" - "dimension" - "global" - "grid_global" - "host" - "optional" - "private" - "public" - "value" -] @type.qualifier - -[ - "endtype" - "type" -] @type.definition - -[ - "in" - "inout" - "out" -] @storageclass - -[ - "contains" "import" + "include" + "use" ] @include +(import_statement + "," + ["all" "none"] @keyword) + +; Attributes + [ (none) "implicit" "intent" ] @attribute +(implicit_statement + "type" @attribute) + +; Keywords + [ + "attributes" + "associate" + "block" + "class" + "classis" + "contains" + "default" + "dimension" + "endassociate" + "endenum" + "endinterface" + "endmodule" + "endselect" + "endsubmodule" + "endtype" + "enum" + "enumerator" + "equivalence" + "extends" + "goto" + "interface" + "intrinsic" + "non_intrinsic" + "module" + "submodule" + "namelist" + "parameter" + "quiet" + "rank" + "save" + "selectcase" + "selectrank" + "selecttype" + "sequence" + "stop" + "target" + "type" + "typeis" +] @keyword + +[ + (default) +] @keyword + +; Types + +[ + (type_name) +] @type + +[ + (intrinsic_type) +] @type.builtin + +; Qualifiers + +[ + "abstract" + "allocatable" + "automatic" + "constant" + "contiguous" + "data" + "deferred" + "device" + "external" + "family" + "final" + "generic" + "global" + "grid_global" + "host" + "initial" + "local" + "local_init" + "managed" + "nopass" + "non_overridable" + "optional" + "pass" + "pinned" + "pointer" + "private" + "property" + "protected" + "public" + "shared" + "static" + "texture" + "value" + "volatile" + (procedure_qualifier) +] @type.qualifier + +[ + "common" + "in" + "inout" + "out" +] @storageclass + +; Labels + +[ + (statement_label) + (statement_label_reference) +] @label + +[ + "call" "endfunction" "endprogram" + "endprocedure" "endsubroutine" "function" "procedure" + "program" "subroutine" ] @keyword.function [ - "bind" - "call" - "class" - "continue" - "cycle" - "endenum" - "endinterface" - "endmodule" - "endprogram" - "enum" - "enumerator" - "equivalence" - "exit" - "format" - "goto" - "include" - "interface" - "module" - "namelist" - "only" - "parameter" - "print" - "program" - "read" - "stop" - "use" - "write" - (default) - (procedure_qualifier) -] @keyword + "result" + "return" +] @keyword.return -"return" @keyword.return +; Functions + +(function_statement + (name) @function) + +(end_function_statement + (name) @function) + +(subroutine_statement + (name) @function) + +(end_subroutine_statement + (name) @function) + +(module_procedure_statement + (name) @function) + +(end_module_procedure_statement + (name) @function) + +(subroutine_call + (identifier) @function.call) + +[ + "character" + "close" + "bind" + "format" + "open" + "print" + "read" + "write" +] @function.builtin + +; Exceptions + +[ + "error" +] @exception + +; Conditionals [ "else" "elseif" + "elsewhere" "endif" "endwhere" "if" @@ -98,17 +226,44 @@ "where" ] @conditional -[ - "do" - "enddo" - "forall" - "while" -] @repeat +; Repeats + +[ + "do" + "concurrent" + "enddo" + "endforall" + "forall" + "while" + "continue" + "cycle" + "exit" +] @repeat + +; Variables + +(identifier) @variable + +; Parameters + +(keyword_argument + name: (identifier) @parameter) + +(parameters + (identifier) @parameter) + +; Properties + +(derived_type_member_expression + (type_member) @property) + +; Operators [ - "*" "+" "-" + "*" + "**" "/" "=" "<" @@ -117,69 +272,58 @@ ">=" "==" "/=" + "//" + (assumed_rank) ] @operator [ "\\.and\\." "\\.or\\." - "\\.lt\\." - "\\.gt\\." - "\\.ge\\." - "\\.le\\." - "\\.eq\\." "\\.eqv\\." "\\.neqv\\." + "\\.lt\\." + "\\.gt\\." + "\\.le\\." + "\\.ge\\." + "\\.eq\\." + "\\.ne\\." + "\\.not\\." ] @keyword.operator - ;; Brackets - [ - "(" - ")" - "[" - "]" - "<<<" - ">>>" - ] @punctuation.bracket +; Punctuation - ;; Delimiter - [ - "::" +[ "[" "]" ] @punctuation.bracket + +[ "(" ")" ] @punctuation.bracket + +[ "<<<" ">>>" ] @punctuation.bracket + +(array_literal + ["(/" "/)"] @punctuation.bracket) + +[ + ":" "," + "/" "%" - ] @punctuation.delimiter + "::" + "=>" +] @punctuation.delimiter -(parameters - (identifier) @parameter) +; Literals -(program_statement - (name) @namespace) +(string_literal) @string -(module_statement - (name) @namespace) +(number_literal) @number -(function_statement - (name) @function) +(boolean_literal) @boolean -(subroutine_statement - (name) @function) +(null_literal) @constant.builtin -(end_program_statement - (name) @namespace) +; Comments -(end_module_statement - (name) @namespace) +(comment) @comment @spell -(end_function_statement - (name) @function) +; Errors -(end_subroutine_statement - (name) @function) - -(subroutine_call - (identifier) @function.call) - -(keyword_argument - name: (identifier) @keyword) - -(derived_type_member_expression - (type_member) @property) +(ERROR) @error From f0617c31f4bb52050f03707ec29c1d2830250dad Mon Sep 17 00:00:00 2001 From: Mitchell Hanberg Date: Mon, 27 Feb 2023 23:19:27 -0500 Subject: [PATCH 0030/2704] fix(eex): map eelixir filetype to the eex parser --- lua/nvim-treesitter/parsers.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index fa5795335..b5bdeb820 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -354,7 +354,7 @@ list.eex = { files = { "src/parser.c" }, branch = "main", }, - filetype = "eex", + filetype = "eelixir", maintainers = { "@connorlay" }, } From 316200f77d4261ebd4957b29fc6958f988e0964d Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Tue, 28 Feb 2023 00:16:21 -0500 Subject: [PATCH 0031/2704] feat: add matlab --- README.md | 1 + lockfile.json | 3 + lua/nvim-treesitter/parsers.lua | 8 +++ queries/matlab/folds.scm | 16 +++++ queries/matlab/highlights.scm | 107 ++++++++++++++++++++++++++++++++ queries/matlab/injections.scm | 1 + 6 files changed, 136 insertions(+) create mode 100644 queries/matlab/folds.scm create mode 100644 queries/matlab/highlights.scm create mode 100644 queries/matlab/injections.scm diff --git a/README.md b/README.md index ce129942b..c677cc261 100644 --- a/README.md +++ b/README.md @@ -264,6 +264,7 @@ We are looking for maintainers to add more parsers and to write query files for - [x] [make](https://github.com/alemuller/tree-sitter-make) (maintained by @lewis6991) - [x] [markdown](https://github.com/MDeiml/tree-sitter-markdown) (experimental, maintained by @MDeiml) - [x] [markdown_inline](https://github.com/MDeiml/tree-sitter-markdown) (experimental, maintained by @MDeiml) +- [x] [matlab](https://github.com/mstanciu552/tree-sitter-matlab) (maintained by @amaanq) - [x] [menhir](https://github.com/Kerl13/tree-sitter-menhir) (maintained by @Kerl13) - [ ] [mermaid](https://github.com/monaqa/tree-sitter-mermaid) (experimental) - [x] [meson](https://github.com/Decodetalkers/tree-sitter-meson) (maintained by @Decodetalkers) diff --git a/lockfile.json b/lockfile.json index 410e06557..52002c5e8 100644 --- a/lockfile.json +++ b/lockfile.json @@ -272,6 +272,9 @@ "markdown_inline": { "revision": "7e7aa9a25ca9729db9fe22912f8f47bdb403a979" }, + "matlab": { + "revision": "2d5d3d5193718a86477d4335aba5b34e79147326" + }, "menhir": { "revision": "db7953acb0d5551f207373c81fa07a57d7b085cb" }, diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index b5bdeb820..2719194bc 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -888,6 +888,14 @@ list.markdown_inline = { experimental = true, } +list.matlab = { + install_info = { + url = "https://github.com/mstanciu552/tree-sitter-matlab", + files = { "src/parser.c" }, + }, + maintainers = { "@amaanq" }, +} + list.menhir = { install_info = { url = "https://github.com/Kerl13/tree-sitter-menhir", diff --git a/queries/matlab/folds.scm b/queries/matlab/folds.scm new file mode 100644 index 000000000..063a99b5a --- /dev/null +++ b/queries/matlab/folds.scm @@ -0,0 +1,16 @@ +[ + (function_definition) + + (if_statement) + + (for_statement) + (while_statement) + + (switch_statement) + (case_statement) + + (otherwise_statement) + + (try_statement) + (catch_statement) +] @fold diff --git a/queries/matlab/highlights.scm b/queries/matlab/highlights.scm new file mode 100644 index 000000000..bad9dbdf4 --- /dev/null +++ b/queries/matlab/highlights.scm @@ -0,0 +1,107 @@ +; Functions + +(function_definition + function_name: (identifier) @function + (end) @keyword.function) + +(parameter_list (identifier) @parameter) + +; Keywords + +((identifier) @keyword + (#eq? @keyword "end")) + +(function_keyword) @keyword.function + +[ + "return" +] @keyword.return + +; Conditionals + +[ + "if" + "elseif" + "else" + "switch" + "case" + "otherwise" +] @conditional + +(if_statement (end) @conditional) +(switch_statement (end) @conditional) + +; Repeats + +[ + "for" + "while" + "break" + "continue" +] @repeat + +(for_statement (end) @repeat) +(while_statement (end) @repeat) + +; Exceptions + +[ + "try" + "catch" +] @exception + +(try_statement (end) @exception) + +; Punctuation + +[ + "," + ";" + ":" +] @punctuation.delimiter + +[ "{" "}" ] @punctuation.bracket + +[ "[" "]" ] @punctuation.bracket + +[ "(" ")" ] @punctuation.bracket + +; Operators + +[ + ">" + "<" + "==" + "<=" + ">=" + "=<" + "=>" + "~=" + "*" + ".*" + "/" + "\\" + "./" + "^" + ".^" + "+" + "=" + "&&" + "||" +] @operator + +; Literals + +(number) @number + +(string) @string + +[ "true" "false" ] @boolean + +; Comments + +(comment) @comment @spell + +; Errors + +(ERROR) @error diff --git a/queries/matlab/injections.scm b/queries/matlab/injections.scm new file mode 100644 index 000000000..4bb7d675d --- /dev/null +++ b/queries/matlab/injections.scm @@ -0,0 +1 @@ +(comment) @comment From 418caac89dab5a37ccaf403b3829e4eeb4124d67 Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Tue, 28 Feb 2023 00:53:13 -0500 Subject: [PATCH 0032/2704] feat(starlark): improve assertion parsing --- lockfile.json | 2 +- queries/starlark/highlights.scm | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lockfile.json b/lockfile.json index 52002c5e8..a87b65752 100644 --- a/lockfile.json +++ b/lockfile.json @@ -405,7 +405,7 @@ "revision": "672fe6b5180d20e9e84fd61749cc3e083e88d9d9" }, "starlark": { - "revision": "2608deac514242c9e7e5609cbfab59095997b1da" + "revision": "8ad93a74c2a880bc16325affba3cc66c14bb2bde" }, "supercollider": { "revision": "90c6d9f777d2b8c4ce497c48b5f270a44bcf3ea0" diff --git a/queries/starlark/highlights.scm b/queries/starlark/highlights.scm index 8ce3d0f77..401b985d7 100644 --- a/queries/starlark/highlights.scm +++ b/queries/starlark/highlights.scm @@ -218,7 +218,6 @@ ] @keyword.function [ - "assert" "async" "await" "exec" @@ -256,6 +255,11 @@ ;; Starlark-specific +;; Assertion calls +(assert_keyword) @keyword + +(assert_builtin) @function.builtin + ;; Struct definitions ((call function: (identifier) @_func From 934113c913c773d8b60225c0f570f5f8ce88eb68 Mon Sep 17 00:00:00 2001 From: GitHub Date: Tue, 28 Feb 2023 08:35:10 +0000 Subject: [PATCH 0033/2704] Update parsers: ungrammar --- lockfile.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lockfile.json b/lockfile.json index a87b65752..e5ba870b7 100644 --- a/lockfile.json +++ b/lockfile.json @@ -459,7 +459,7 @@ "revision": "c6e56d44c686a67c89e29e773e662567285d610f" }, "ungrammar": { - "revision": "5275e45d1edb16aab4f0d63a3aa15b61ef033a9c" + "revision": "debd26fed283d80456ebafa33a06957b0c52e451" }, "v": { "revision": "136f3a0ad91ab8a781c2d4eb419df0a981839f69" From bae59318b3f80e25d8b9c548315a842dc9f5bf88 Mon Sep 17 00:00:00 2001 From: GitHub Date: Tue, 28 Feb 2023 14:11:22 +0000 Subject: [PATCH 0034/2704] Update parsers: markdown, markdown_inline --- lockfile.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lockfile.json b/lockfile.json index e5ba870b7..f3d9d69a8 100644 --- a/lockfile.json +++ b/lockfile.json @@ -267,10 +267,10 @@ "revision": "a4b9187417d6be349ee5fd4b6e77b4172c6827dd" }, "markdown": { - "revision": "7e7aa9a25ca9729db9fe22912f8f47bdb403a979" + "revision": "ca85c6db7088ce98f59e2fbc31b966f5834ea6d7" }, "markdown_inline": { - "revision": "7e7aa9a25ca9729db9fe22912f8f47bdb403a979" + "revision": "ca85c6db7088ce98f59e2fbc31b966f5834ea6d7" }, "matlab": { "revision": "2d5d3d5193718a86477d4335aba5b34e79147326" From b1b2e9b6d3cb1b18732246a3429686aa2df23ff6 Mon Sep 17 00:00:00 2001 From: GitHub Date: Tue, 28 Feb 2023 18:48:45 +0000 Subject: [PATCH 0035/2704] Update parsers: markdown, markdown_inline, python, zig --- lockfile.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lockfile.json b/lockfile.json index f3d9d69a8..f2e36d625 100644 --- a/lockfile.json +++ b/lockfile.json @@ -267,10 +267,10 @@ "revision": "a4b9187417d6be349ee5fd4b6e77b4172c6827dd" }, "markdown": { - "revision": "ca85c6db7088ce98f59e2fbc31b966f5834ea6d7" + "revision": "6138ee0c0d0ddafc4bf0e25728b73f902bbf2c98" }, "markdown_inline": { - "revision": "ca85c6db7088ce98f59e2fbc31b966f5834ea6d7" + "revision": "6138ee0c0d0ddafc4bf0e25728b73f902bbf2c98" }, "matlab": { "revision": "2d5d3d5193718a86477d4335aba5b34e79147326" @@ -336,7 +336,7 @@ "revision": "884e225b5ecca5d885ae627275f16ef648acd42e" }, "python": { - "revision": "528855eee2665210e1bf5556de48b8d8dacb8932" + "revision": "62827156d01c74dc1538266344e788da74536b8a" }, "ql": { "revision": "bd087020f0d8c183080ca615d38de0ec827aeeaf" @@ -495,6 +495,6 @@ "revision": "607bf03cc78912cbaa85a3d373af21ddeaef5b41" }, "zig": { - "revision": "6b3f5788f38be900b45f5af5a753bf6a37d614b8" + "revision": "1cd5f339b146b764f39b36bb7be98ca631a2e02a" } } From f95ffd09ed35880c3a46ad2b968df361fa592a76 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Tue, 28 Feb 2023 20:14:55 +0100 Subject: [PATCH 0036/2704] python(highlights): adapt query to parser change --- queries/python/highlights.scm | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/queries/python/highlights.scm b/queries/python/highlights.scm index 976528c48..b8b8b7b94 100644 --- a/queries/python/highlights.scm +++ b/queries/python/highlights.scm @@ -173,11 +173,7 @@ (#match? @preproc "^#!/")) (string) @string -[ - (escape_sequence) - "{{" - "}}" -] @string.escape +(escape_sequence) @string.escape ; doc-strings (expression_statement (string) @spell) From 3fe80dbecdf1fa88cf81a4d7b30ab0714f8c443a Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Mon, 27 Feb 2023 21:18:00 -0500 Subject: [PATCH 0037/2704] feat: add passwd --- README.md | 1 + lockfile.json | 3 +++ lua/nvim-treesitter/parsers.lua | 8 ++++++++ queries/passwd/highlights.scm | 16 ++++++++++++++++ 4 files changed, 28 insertions(+) create mode 100644 queries/passwd/highlights.scm diff --git a/README.md b/README.md index c677cc261..bb93e4d9f 100644 --- a/README.md +++ b/README.md @@ -277,6 +277,7 @@ We are looking for maintainers to add more parsers and to write query files for - [x] [ocamllex](https://github.com/atom-ocaml/tree-sitter-ocamllex) (maintained by @undu) - [ ] [org](https://github.com/milisims/tree-sitter-org) - [x] [pascal](https://github.com/Isopod/tree-sitter-pascal.git) (maintained by @Isopod) +- [x] [passwd](https://github.com/ath3/tree-sitter-passwd) (maintained by @amaanq) - [x] [perl](https://github.com/ganezdragon/tree-sitter-perl) (maintained by @lcrownover) - [x] [php](https://github.com/tree-sitter/tree-sitter-php) (maintained by @tk-shirasaka) - [x] [phpdoc](https://github.com/claytonrcarter/tree-sitter-phpdoc) (experimental, maintained by @mikehaertl) diff --git a/lockfile.json b/lockfile.json index f2e36d625..d8736f659 100644 --- a/lockfile.json +++ b/lockfile.json @@ -311,6 +311,9 @@ "pascal": { "revision": "9e995404ddff8319631d72d4b46552e737206912" }, + "passwd": { + "revision": "20239395eacdc2e0923a7e5683ad3605aee7b716" + }, "perl": { "revision": "c43bae0090cfcfc62d9904312599ded1b645a66d" }, diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index 2719194bc..2c8956f67 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -1003,6 +1003,14 @@ list.pascal = { maintainers = { "@Isopod" }, } +list.passwd = { + install_info = { + url = "https://github.com/ath3/tree-sitter-passwd", + files = { "src/parser.c" }, + }, + maintainers = { "@amaanq" }, +} + list.perl = { install_info = { url = "https://github.com/ganezdragon/tree-sitter-perl", diff --git a/queries/passwd/highlights.scm b/queries/passwd/highlights.scm new file mode 100644 index 000000000..3e078a123 --- /dev/null +++ b/queries/passwd/highlights.scm @@ -0,0 +1,16 @@ +(user) @namespace + +(auth) @symbol + +(gecos) @string + +(home) @text.uri @constant + +(shell) @text.uri @string.special + +[ + (gid) + (uid) +] @number + +(separator) @punctuation.delimiter From ba4ecfe471e0ee1e8a7b0710ce6f74acf0946609 Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Wed, 1 Mar 2023 01:23:52 -0500 Subject: [PATCH 0038/2704] feat: add qmldir --- README.md | 1 + lockfile.json | 3 +++ queries/qmldir/highlights.scm | 24 ++++++++++++++++++++++++ queries/qmldir/injections.scm | 1 + 4 files changed, 29 insertions(+) create mode 100644 queries/qmldir/highlights.scm create mode 100644 queries/qmldir/injections.scm diff --git a/README.md b/README.md index bb93e4d9f..558927a50 100644 --- a/README.md +++ b/README.md @@ -288,6 +288,7 @@ We are looking for maintainers to add more parsers and to write query files for - [x] [pug](https://github.com/zealot128/tree-sitter-pug) (experimental, maintained by @zealot128) - [x] [python](https://github.com/tree-sitter/tree-sitter-python) (maintained by @stsewd, @theHamsta) - [x] [ql](https://github.com/tree-sitter/tree-sitter-ql) (maintained by @pwntester) +- [x] [qmldir](https://github.com/Decodetalkers/tree-sitter-qmldir) (maintained by @amaanq) - [x] [qmljs](https://github.com/yuja/tree-sitter-qmljs) (maintained by @Decodetalkers) - [x] [Tree-sitter query language](https://github.com/nvim-treesitter/tree-sitter-query) (maintained by @steelsojka) - [x] [r](https://github.com/r-lib/tree-sitter-r) (maintained by @echasnovski) diff --git a/lockfile.json b/lockfile.json index d8736f659..41616f172 100644 --- a/lockfile.json +++ b/lockfile.json @@ -344,6 +344,9 @@ "ql": { "revision": "bd087020f0d8c183080ca615d38de0ec827aeeaf" }, + "qmldir": { + "revision": "ce42c9abb9b86a563f117d733b3bc0dd7e2e6e76" + }, "qmljs": { "revision": "ab75be9750e6f2f804638824d1790034286a830c" }, diff --git a/queries/qmldir/highlights.scm b/queries/qmldir/highlights.scm new file mode 100644 index 000000000..1fd174708 --- /dev/null +++ b/queries/qmldir/highlights.scm @@ -0,0 +1,24 @@ +; Preproc + +(command (identifier) @preproc) + +; Keywords + +(keyword) @keyword + +; Literals + +(number) @number + +(float) @float + +; Variables + +[ + (identifier) + (unit) +] @variable + +; Comments + +(comment) @comment @spell diff --git a/queries/qmldir/injections.scm b/queries/qmldir/injections.scm new file mode 100644 index 000000000..4bb7d675d --- /dev/null +++ b/queries/qmldir/injections.scm @@ -0,0 +1 @@ +(comment) @comment From d80c99cab0a05ad4263783a59ad2286892c14fa0 Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Wed, 1 Mar 2023 02:42:30 -0500 Subject: [PATCH 0039/2704] fix(qmldir): add to parsers.lua --- lua/nvim-treesitter/parsers.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index 2c8956f67..a06c1baea 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -1104,6 +1104,14 @@ list.ql = { maintainers = { "@pwntester" }, } +list.qmldir = { + install_info = { + url = "https://github.com/Decodetalkers/tree-sitter-qmldir", + files = { "src/parser.c" }, + }, + maintainers = { "@amaanq" }, +} + list.qmljs = { install_info = { url = "https://github.com/yuja/tree-sitter-qmljs", From 5b9339f6f48acd7482a24884807c608fef401249 Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Tue, 28 Feb 2023 00:14:08 -0500 Subject: [PATCH 0040/2704] feat: add PO --- README.md | 1 + lockfile.json | 3 +++ lua/nvim-treesitter/parsers.lua | 8 ++++++++ queries/po/folds.scm | 9 +++++++++ queries/po/highlights.scm | 33 +++++++++++++++++++++++++++++++++ queries/po/injections.scm | 1 + 6 files changed, 55 insertions(+) create mode 100644 queries/po/folds.scm create mode 100644 queries/po/highlights.scm create mode 100644 queries/po/injections.scm diff --git a/README.md b/README.md index 558927a50..45edb3612 100644 --- a/README.md +++ b/README.md @@ -282,6 +282,7 @@ We are looking for maintainers to add more parsers and to write query files for - [x] [php](https://github.com/tree-sitter/tree-sitter-php) (maintained by @tk-shirasaka) - [x] [phpdoc](https://github.com/claytonrcarter/tree-sitter-phpdoc) (experimental, maintained by @mikehaertl) - [x] [pioasm](https://github.com/leo60228/tree-sitter-pioasm) (maintained by @leo60228) +- [x] [po](https://github.com/erasin/tree-sitter-po) (maintained by @amaanq) - [x] [Path of Exile item filter](https://github.com/ObserverOfTime/tree-sitter-poe-filter) (experimental, maintained by @ObserverOfTime) - [x] [prisma](https://github.com/victorhqc/tree-sitter-prisma) (maintained by @elianiva) - [x] [proto](https://github.com/mitchellh/tree-sitter-proto) (maintained by @fsouza) diff --git a/lockfile.json b/lockfile.json index 41616f172..375ea2ab2 100644 --- a/lockfile.json +++ b/lockfile.json @@ -326,6 +326,9 @@ "pioasm": { "revision": "924aadaf5dea2a6074d72027b064f939acf32e20" }, + "po": { + "revision": "d6aed225290bc71a15ab6f06305cb11419360c56" + }, "poe_filter": { "revision": "80dc10195e26c72598ed1ab02cdf2d8e4c792e7b" }, diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index a06c1baea..743f0f3e5 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -1048,6 +1048,14 @@ list.pioasm = { maintainers = { "@leo60228" }, } +list.po = { + install_info = { + url = "https://github.com/erasin/tree-sitter-po", + files = { "src/parser.c" }, + }, + maintainers = { "@amaanq" }, +} + list.poe_filter = { install_info = { url = "https://github.com/ObserverOfTime/tree-sitter-poe-filter", diff --git a/queries/po/folds.scm b/queries/po/folds.scm new file mode 100644 index 000000000..589696477 --- /dev/null +++ b/queries/po/folds.scm @@ -0,0 +1,9 @@ +[ + (msgctxt) + (msgid) + (msgid_plural) + (msgstr) + (msgstr_plural) + + (message) +] @fold diff --git a/queries/po/highlights.scm b/queries/po/highlights.scm new file mode 100644 index 000000000..bddeb5ba9 --- /dev/null +++ b/queries/po/highlights.scm @@ -0,0 +1,33 @@ +; Keywords + +[ + "msgctxt" + "msgid" + "msgid_plural" + "msgstr" + "msgstr_plural" +] @keyword + +; Punctuation + +[ "[" "]" ] @punctuation.bracket + +; Literals + +(string) @string + +(escape_sequence) @string.escape + +(number) @number + +; Comments + +(comment) @comment @spell + +(comment (reference (text) @string.special.path)) + +(comment (flag (text) @preproc)) + +; Errors + +(ERROR) @error diff --git a/queries/po/injections.scm b/queries/po/injections.scm new file mode 100644 index 000000000..4bb7d675d --- /dev/null +++ b/queries/po/injections.scm @@ -0,0 +1 @@ +(comment) @comment From 75d98eaac424661812cc18de11f3d8037be8e8f4 Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Tue, 28 Feb 2023 20:26:51 -0500 Subject: [PATCH 0041/2704] feat(kdl): update parser & queries fixing the comment bug --- lockfile.json | 2 +- queries/kdl/highlights.scm | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lockfile.json b/lockfile.json index 375ea2ab2..3c6888222 100644 --- a/lockfile.json +++ b/lockfile.json @@ -240,7 +240,7 @@ "revision": "e2f449e2bcc95f1d07ceb62d67f986005f73a6be" }, "kdl": { - "revision": "c3c4856464842e05366b1f3ebc4434c9194cad43" + "revision": "e36f054a60c4d9e5ae29567d439fdb8790b53b30" }, "kotlin": { "revision": "e4637037a5fe6f25fe66c305669faa0855f35692" diff --git a/queries/kdl/highlights.scm b/queries/kdl/highlights.scm index 35da6ec63..d903128a8 100644 --- a/queries/kdl/highlights.scm +++ b/queries/kdl/highlights.scm @@ -31,18 +31,21 @@ (number (decimal) @float) (number (exponent) @float) -(number (decimal) (exponent) @float) (boolean) @boolean -; Misc - "null" @constant.builtin +; Punctuation + ["{" "}"] @punctuation.bracket ["(" ")"] @punctuation.bracket +[ + ";" +] @punctuation.delimiter + ; Comments [ From 9dd1b9c09707bf1cdd565b999c79ac6461602591 Mon Sep 17 00:00:00 2001 From: GitHub Date: Wed, 1 Mar 2023 06:42:40 +0000 Subject: [PATCH 0042/2704] Update parsers: gdscript, kdl, meson, yuck --- lockfile.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lockfile.json b/lockfile.json index 3c6888222..ee0f5de10 100644 --- a/lockfile.json +++ b/lockfile.json @@ -135,7 +135,7 @@ "revision": "19db2f47ba4c3a0f6238d4ae0e2abfca16e61dd6" }, "gdscript": { - "revision": "31ebb7cd0b880ea53a152eaf9d4df73f737181cc" + "revision": "a4b57cc3bcbfc24550e858159647e9238e7ad1ac" }, "git_rebase": { "revision": "d8a4207ebbc47bd78bacdf48f883db58283f9fd8" @@ -282,7 +282,7 @@ "revision": "d787c66276e7e95899230539f556e8b83ee16f6d" }, "meson": { - "revision": "5f3138d555aceef976ec9a1d4a3f78e13b31e45f" + "revision": "3d6dfbdb2432603bc84ca7dc009bb39ed9a8a7b1" }, "nickel": { "revision": "d6c7eeb751038f934b5b1aa7ff236376d0235c56" @@ -501,7 +501,7 @@ "revision": "2c0e6be8dd4dcb961c345fa35c309ad4f5bd3502" }, "yuck": { - "revision": "607bf03cc78912cbaa85a3d373af21ddeaef5b41" + "revision": "1e1a7e10053b910f3864fe8d97ca1741d2df66b2" }, "zig": { "revision": "1cd5f339b146b764f39b36bb7be98ca631a2e02a" From 0572657d4dba9b5c1108adfd4ecacc52a04917b5 Mon Sep 17 00:00:00 2001 From: Matthias Q <35303817+matthias-Q@users.noreply.github.com> Date: Wed, 1 Mar 2023 21:21:11 +0100 Subject: [PATCH 0043/2704] feat: add prql (#4393) * feat: add prql * highlights(prql): null as constant.builtin * highlights(prql): add missing kwd, update queries * highlights(prql): remove redundant queries * highlights(prql): make `->` a delimiter * highlights(prql): instructions to `@method.call` --- README.md | 1 + lockfile.json | 3 + lua/nvim-treesitter/parsers.lua | 10 +++ queries/prql/highlights.scm | 141 ++++++++++++++++++++++++++++++++ queries/prql/injections.scm | 13 +++ 5 files changed, 168 insertions(+) create mode 100644 queries/prql/highlights.scm create mode 100644 queries/prql/injections.scm diff --git a/README.md b/README.md index 45edb3612..666d264b6 100644 --- a/README.md +++ b/README.md @@ -286,6 +286,7 @@ We are looking for maintainers to add more parsers and to write query files for - [x] [Path of Exile item filter](https://github.com/ObserverOfTime/tree-sitter-poe-filter) (experimental, maintained by @ObserverOfTime) - [x] [prisma](https://github.com/victorhqc/tree-sitter-prisma) (maintained by @elianiva) - [x] [proto](https://github.com/mitchellh/tree-sitter-proto) (maintained by @fsouza) +- [x] [prql](https://github.com/PRQL/tree-sitter-prql) (maintained by @matthias-Q) - [x] [pug](https://github.com/zealot128/tree-sitter-pug) (experimental, maintained by @zealot128) - [x] [python](https://github.com/tree-sitter/tree-sitter-python) (maintained by @stsewd, @theHamsta) - [x] [ql](https://github.com/tree-sitter/tree-sitter-ql) (maintained by @pwntester) diff --git a/lockfile.json b/lockfile.json index ee0f5de10..437e104a3 100644 --- a/lockfile.json +++ b/lockfile.json @@ -338,6 +338,9 @@ "proto": { "revision": "42d82fa18f8afe59b5fc0b16c207ee4f84cb185f" }, + "prql": { + "revision": "3f27cac466f030ee7d985d91eba5470e01dd21ea" + }, "pug": { "revision": "884e225b5ecca5d885ae627275f16ef648acd42e" }, diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index 743f0f3e5..d0b933779 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -1086,6 +1086,16 @@ list.proto = { filetype = "proto", } +list.prql = { + install_info = { + url = "https://github.com/PRQL/tree-sitter-prql", + branch = "main", + files = { "src/parser.c" }, + }, + maintainers = { "@matthias-Q" }, + filetype = "prql", +} + list.pug = { install_info = { url = "https://github.com/zealot128/tree-sitter-pug", diff --git a/queries/prql/highlights.scm b/queries/prql/highlights.scm new file mode 100644 index 000000000..3810bdda4 --- /dev/null +++ b/queries/prql/highlights.scm @@ -0,0 +1,141 @@ +[ + (keyword_from) + (keyword_filter) + (keyword_derive) + (keyword_group) + (keyword_aggregate) + (keyword_sort) + (keyword_take) + (keyword_window) + (keyword_join) + (keyword_select) + (keyword_switch) + (keyword_append) + (keyword_remove) + (keyword_intersect) + (keyword_rolling) + (keyword_rows) + (keyword_expanding) + (keyword_let) + (keyword_prql) + (keyword_from_text) +] @keyword + +[ + (literal) + (f_string) + (s_string) +] @string + +(assignment + alias: (field) @field) + +alias: (identifier) @field + + + +(comment) @comment @spell + +(keyword_func) @keyword.function + +(function_call + (identifier) @function.call) + +[ + "+" + "-" + "*" + "/" + "=" + "==" + "<" + "<=" + "!=" + ">=" + ">" + (bang) +] @operator + +[ + "(" + ")" + "[" + "]" +] @punctuation.bracket + +[ + "," + "." + (pipe) + "->" +] @punctuation.delimiter + +(integer) @number + +(decimal_number) @float + +[ + (keyword_min) + (keyword_max) + (keyword_count) + (keyword_count_distinct) + (keyword_average) + (keyword_avg) + (keyword_sum) + (keyword_stddev) + (keyword_count) +] @function + +[ + (keyword_side) + (keyword_format) +] @attribute + +[ + (keyword_version) + (keyword_target) +] @type.qualifier + +(target) @function.builtin + + [ + (date) + (time) + (timestamp) +] @string.special + +[ + (keyword_left) + (keyword_inner) + (keyword_right) + (keyword_full) + (keyword_csv) + (keyword_json) +] @method.call + +[ + (keyword_true) + (keyword_false) +] @boolean + +[ + (keyword_and) + (keyword_or) + (keyword_in) +] @keyword.operator + +(function_definition + (keyword_func) + name: (identifier) @function) + +(parameter + (identifier) @parameter) + +(variable + (keyword_let) + name: (identifier) @constant) + + + (keyword_null) @constant.builtin + + diff --git a/queries/prql/injections.scm b/queries/prql/injections.scm new file mode 100644 index 000000000..a6d4ccb12 --- /dev/null +++ b/queries/prql/injections.scm @@ -0,0 +1,13 @@ +( + (s_string) @sql + (#offset! @sql 0 2 0 -1) +) + +(from_text + (keyword_from_text) + (keyword_json) + (literal) @json + (#offset! @json 0 3 0 -3) +) + +(comment) @comment From 252c1011c4bae91d25a8c54be4ed1a7b341c088c Mon Sep 17 00:00:00 2001 From: Yochem van Rosmalen Date: Wed, 1 Mar 2023 14:26:52 +0100 Subject: [PATCH 0044/2704] comment(highlights): add `@nospell` to tags and user mentions --- queries/comment/highlights.scm | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/queries/comment/highlights.scm b/queries/comment/highlights.scm index 6466a4783..15adf45ab 100644 --- a/queries/comment/highlights.scm +++ b/queries/comment/highlights.scm @@ -1,39 +1,39 @@ (_) @spell ((tag - (name) @text.todo + (name) @text.todo @nospell ("(" @punctuation.bracket (user) @constant ")" @punctuation.bracket)? ":" @punctuation.delimiter) (#eq? @text.todo "TODO")) -("text" @text.todo +("text" @text.todo @nospell (#eq? @text.todo "TODO")) ((tag - (name) @text.note + (name) @text.note @nospell ("(" @punctuation.bracket (user) @constant ")" @punctuation.bracket)? ":" @punctuation.delimiter) (#any-of? @text.note "NOTE" "XXX")) -("text" @text.note +("text" @text.note @nospell (#any-of? @text.note "NOTE" "XXX")) ((tag - (name) @text.warning + (name) @text.warning @nospell ("(" @punctuation.bracket (user) @constant ")" @punctuation.bracket)? ":" @punctuation.delimiter) (#any-of? @text.warning "HACK" "WARNING")) -("text" @text.warning +("text" @text.warning @nospell (#any-of? @text.warning "HACK" "WARNING")) ((tag - (name) @text.danger + (name) @text.danger @nospell ("(" @punctuation.bracket (user) @constant ")" @punctuation.bracket)? ":" @punctuation.delimiter) (#any-of? @text.danger "FIXME" "BUG")) -("text" @text.danger +("text" @text.danger @nospell (#any-of? @text.danger "FIXME" "BUG")) ; Issue number (#123) @@ -41,5 +41,5 @@ (#lua-match? @number "^#[0-9]+$")) ; User mention (@user) -("text" @constant +("text" @constant @nospell (#lua-match? @constant "^[@][a-zA-Z0-9_-]+$")) From b1450214993582d54b2fd7e0fe6b556710cae606 Mon Sep 17 00:00:00 2001 From: Jaehwang Jung Date: Thu, 2 Mar 2023 13:47:00 +0900 Subject: [PATCH 0045/2704] fix: remove wrong/pointless tostring --- lua/nvim-treesitter/caching.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lua/nvim-treesitter/caching.lua b/lua/nvim-treesitter/caching.lua index 810d3a408..7733202ed 100644 --- a/lua/nvim-treesitter/caching.lua +++ b/lua/nvim-treesitter/caching.lua @@ -8,7 +8,7 @@ local M = {} function M.create_buffer_cache() local cache = {} - ---@type table> + ---@type table> local items = setmetatable({}, { __index = function(tbl, key) rawset(tbl, key, {}) @@ -16,7 +16,7 @@ function M.create_buffer_cache() end, }) - ---@type table + ---@type table local loaded_buffers = {} ---@param type_name string @@ -30,21 +30,21 @@ function M.create_buffer_cache() api.nvim_buf_attach(bufnr, false, { on_detach = function() cache.clear_buffer(bufnr) - loaded_buffers[tostring(bufnr)] = nil + loaded_buffers[bufnr] = nil return true end, on_reload = function() end, -- this is needed to prevent on_detach being called on buffer reload }) end - items[tostring(bufnr)][type_name] = value + items[bufnr][type_name] = value end ---@param type_name string ---@param bufnr integer ---@return any function cache.get(type_name, bufnr) - return items[tostring(bufnr)][type_name] + return items[bufnr][type_name] end ---@param type_name string @@ -57,12 +57,12 @@ function M.create_buffer_cache() ---@param type_name string ---@param bufnr integer function cache.remove(type_name, bufnr) - items[tostring(bufnr)][type_name] = nil + items[bufnr][type_name] = nil end ---@param bufnr integer function cache.clear_buffer(bufnr) - items[tostring(bufnr)] = nil + items[bufnr] = nil end return cache From 36b1038a65f250e93c88496350ab9f03ad00fa8a Mon Sep 17 00:00:00 2001 From: Preston Knopp Date: Wed, 1 Mar 2023 23:28:13 -0800 Subject: [PATCH 0046/2704] Update gdscript queries (#4405) * locals(gdscript): update locals * folds(gdscript): add folds * indents(gdscript): update indents with notes * highlights(gdscript): update highlights * docs(gdscript): add gdscript maintainer * indents(gdscript): add ERROR auto indent Co-authored-by: Amaan Qureshi * highlights(gdscript): use text.uri for get_node and node_path * highlights(gdscript): add "@" of annotation as attribute * highlights(gdscript): use keyword.operator for "new", match all attribute_call * highlights(gdscript): update (underscore) and (pattern_open_ending) --------- Co-authored-by: Amaan Qureshi --- lua/nvim-treesitter/parsers.lua | 1 + queries/gdscript/folds.scm | 25 ++++ queries/gdscript/highlights.scm | 249 +++++++++++++++++++++++++++++--- queries/gdscript/indents.scm | 80 ++++++++-- queries/gdscript/locals.scm | 92 +++++++++++- 5 files changed, 412 insertions(+), 35 deletions(-) create mode 100644 queries/gdscript/folds.scm diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index d0b933779..a600e2de0 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -478,6 +478,7 @@ list.gdscript = { files = { "src/parser.c", "src/scanner.cc" }, }, readme_name = "Godot (gdscript)", + maintainers = { "@PrestonKnopp" }, } list.git_rebase = { diff --git a/queries/gdscript/folds.scm b/queries/gdscript/folds.scm new file mode 100644 index 000000000..946b0fea3 --- /dev/null +++ b/queries/gdscript/folds.scm @@ -0,0 +1,25 @@ +[ + ; Body fold will "join" the next adjacent fold into a SUPER fold. + ; This is an issue with the grammar. + ; (body) + + (if_statement) + (elif_clause) + (else_clause) + (for_statement) + (while_statement) + (class_definition) + (enum_definition) + (match_statement) + (pattern_section) + (function_definition) + (lambda) + (constructor_definition) +] @fold + +; It's nice to be able to fold the if/elif/else clauses and the entire +; if_statement. +(if_statement (body) @fold) + +; Fold strings that are probably doc strings. +(expression_statement (string) @fold) diff --git a/queries/gdscript/highlights.scm b/queries/gdscript/highlights.scm index 7b5469f62..073096556 100644 --- a/queries/gdscript/highlights.scm +++ b/queries/gdscript/highlights.scm @@ -1,21 +1,30 @@ ;; Basic +(ERROR) @error + (identifier) @variable (name) @variable (type) @type -(comment) @comment -(get_node) @string +(comment) @comment @spell +(string_name) @string (string) @string (float) @float (integer) @number (null) @constant (setter) @function (getter) @function +(set_body "set" @keyword.function) +(get_body "get" @keyword.function) (static_keyword) @type.qualifier (tool_statement) @keyword -(breakpoint_statement) @keyword +(breakpoint_statement) @debug (inferred_type) @operator [(true) (false)] @boolean +[ + (get_node) + (node_path) +] @text.uri + (class_name_statement (name) @type) @keyword @@ -23,16 +32,13 @@ "const" @type.qualifier (name) @constant) -((identifier) @variable.builtin - (#eq? @variable.builtin "self")) +(expression_statement (string) @comment @spell) ;; Identifier naming conventions ((identifier) @type (#lua-match? @type "^[A-Z]")) ((identifier) @constant (#lua-match? @constant "^[A-Z][A-Z_0-9]*$")) -((identifier) @type - (#lua-match? @type "^[A-Z][A-Z_0-9]*$") . (_)) ;; Functions (constructor_definition) @constructor @@ -41,16 +47,44 @@ (name) @function (parameters (identifier) @parameter)*) -(typed_parameter - (identifier) @parameter) +(typed_parameter (identifier) @parameter) +(default_parameter (identifier) @parameter) -(default_parameter - (identifier) @parameter) +(call (identifier) @function.call) +(call (identifier) @include + (#any-of? @include "preload" "load")) -(call - (identifier) @function) -(attribute_call - (identifier) @function) +;; Properties and Methods + +; We'll use @property since that's the term Godot uses. +; But, should (source (variable_statement (name))) be @property, too? Since a +; script file is a class in gdscript. +(class_definition + (body (variable_statement (name) @property))) + +; Same question but for methods? +(class_definition + (body (function_definition (name) @method))) + +(attribute_call (identifier) @method.call) +(attribute (_) (identifier) @property) + +;; Enums + +(enumerator left: (identifier) @constant) + +;; Special Builtins + +((identifier) @variable.builtin + (#any-of? @variable.builtin "self" "super")) + +(attribute_call (identifier) @keyword.operator + (#eq? @keyword.operator "new")) + +;; Match Pattern + +(underscore) @constant ; The "_" pattern. +(pattern_open_ending) @operator ; The ".." pattern. ;; Alternations ["(" ")" "[" "]" "{" "}"] @punctuation.bracket @@ -109,7 +143,6 @@ "class_name" "extends" "signal" - "func" "enum" "var" "onready" @@ -123,4 +156,186 @@ "puppetsync" ] @keyword -"return" @keyword.return +"func" @keyword.function + +[ + "await" + "return" +] @keyword.return + +(call (identifier) @keyword.return + (#eq? @keyword.return "yield")) + + +;; Builtins +; generated from +; - https://github.com/godotengine/godot/blob/491ded18983a4ae963ce9c29e8df5d5680873ccb/doc/classes/@GlobalScope.xml +; - https://github.com/godotengine/godot/blob/491ded18983a4ae963ce9c29e8df5d5680873ccb/modules/gdscript/doc_classes/@GDScript.xml +; some from: +; - https://github.com/godotengine/godot-vscode-plugin/blob/0636797c22bf1e23a41fd24d55cdb9be62e0c992/syntaxes/GDScript.tmLanguage.json + +;; Bulitin Annotations + +((annotation "@" @attribute (identifier) @attribute) + (#any-of? @attribute + ; @GDScript + "export" "export_category" "export_color_no_alpha" "export_dir" + "export_enum" "export_exp_easing" "export_file" "export_flags" + "export_flags_2d_navigation" "export_flags_2d_physics" + "export_flags_2d_render" "export_flags_3d_navigation" + "export_flags_3d_physics" "export_flags_3d_render" "export_global_dir" + "export_global_file" "export_group" "export_multiline" "export_node_path" + "export_placeholder" "export_range" "export_subgroup" "icon" "onready" + "rpc" "tool" "warning_ignore" + )) + +;; Builtin Types + +([(identifier) (type)] @type.builtin + (#any-of? @type.builtin + ; from godot-vscode-plugin + "Vector2" "Vector2i" "Vector3" "Vector3i" + "Color" "Rect2" "Rect2i" "Array" "Basis" "Dictionary" + "Plane" "Quat" "RID" "Rect3" "Transform" "Transform2D" + "Transform3D" "AABB" "String" "NodePath" "Object" + "PoolByteArray" "PoolIntArray" "PoolRealArray" + "PoolStringArray" "PoolVector2Array" "PoolVector3Array" + "PoolColorArray" "bool" "int" "float" "StringName" "Quaternion" + "PackedByteArray" "PackedInt32Array" "PackedInt64Array" + "PackedFloat32Array" "PackedFloat64Array" "PackedStringArray" + "PackedVector2Array" "PackedVector2iArray" "PackedVector3Array" + "PackedVector3iArray" "PackedColorArray" + + ; @GlobalScope + "AudioServer" "CameraServer" "ClassDB" "DisplayServer" "Engine" + "EngineDebugger" "GDExtensionManager" "Geometry2D" "Geometry3D" "GodotSharp" + "IP" "Input" "InputMap" "JavaClassWrapper" "JavaScriptBridge" "Marshalls" + "NavigationMeshGenerator" "NavigationServer2D" "NavigationServer3D" "OS" + "Performance" "PhysicsServer2D" "PhysicsServer2DManager" "PhysicsServer3D" + "PhysicsServer3DManager" "ProjectSettings" "RenderingServer" "ResourceLoader" + "ResourceSaver" "ResourceUID" "TextServerManager" "ThemeDB" "Time" + "TranslationServer" "WorkerThreadPool" "XRServer" + )) + +;; Builtin Funcs + +(call (identifier) @function.builtin + (#any-of? @function.builtin + ; @GlobalScope + "abs" "absf" "absi" "acos" "asin" "atan" "atan2" "bezier_derivative" + "bezier_interpolate" "bytes_to_var" "bytes_to_var_with_objects" "ceil" "ceilf" + "ceili" "clamp" "clampf" "clampi" "cos" "cosh" "cubic_interpolate" + "cubic_interpolate_angle" "cubic_interpolate_angle_in_time" + "cubic_interpolate_in_time" "db_to_linear" "deg_to_rad" "ease" "error_string" + "exp" "floor" "floorf" "floori" "fmod" "fposmod" "hash" "instance_from_id" + "inverse_lerp" "is_equal_approx" "is_finite" "is_inf" "is_instance_id_valid" + "is_instance_valid" "is_nan" "is_same" "is_zero_approx" "lerp" "lerp_angle" + "lerpf" "linear_to_db" "log" "max" "maxf" "maxi" "min" "minf" "mini" + "move_toward" "nearest_po2" "pingpong" "posmod" "pow" "print" "print_rich" + "print_verbose" "printerr" "printraw" "prints" "printt" "push_error" + "push_warning" "rad_to_deg" "rand_from_seed" "randf" "randf_range" "randfn" + "randi" "randi_range" "randomize" "remap" "rid_allocate_id" "rid_from_int64" + "round" "roundf" "roundi" "seed" "sign" "signf" "signi" "sin" "sinh" + "smoothstep" "snapped" "snappedf" "snappedi" "sqrt" "step_decimals" "str" + "str_to_var" "tan" "tanh" "typeof" "var_to_bytes" "var_to_bytes_with_objects" + "var_to_str" "weakref" "wrap" "wrapf" "wrapi" + + ; @GDScript + "Color8" "assert" "char" "convert" "dict_to_inst" "get_stack" "inst_to_dict" + "is_instance_of" "len" "print_debug" "print_stack" "range" + "type_exists" + )) + +;; Builtin Constants + +((identifier) @constant.builtin + (#any-of? @constant.builtin + ; @GDScript + "PI" "TAU" "INF" "NAN" + + ; @GlobalScope + "SIDE_LEFT" "SIDE_TOP" "SIDE_RIGHT" "SIDE_BOTTOM" "CORNER_TOP_LEFT" "CORNER_TOP_RIGHT" "CORNER_BOTTOM_RIGHT" + "CORNER_BOTTOM_LEFT" "VERTICAL" "HORIZONTAL" "CLOCKWISE" "COUNTERCLOCKWISE" "HORIZONTAL_ALIGNMENT_LEFT" + "HORIZONTAL_ALIGNMENT_CENTER" "HORIZONTAL_ALIGNMENT_RIGHT" "HORIZONTAL_ALIGNMENT_FILL" "VERTICAL_ALIGNMENT_TOP" + "VERTICAL_ALIGNMENT_CENTER" "VERTICAL_ALIGNMENT_BOTTOM" "VERTICAL_ALIGNMENT_FILL" "INLINE_ALIGNMENT_TOP_TO" + "INLINE_ALIGNMENT_CENTER_TO" "INLINE_ALIGNMENT_BASELINE_TO" "INLINE_ALIGNMENT_BOTTOM_TO" "INLINE_ALIGNMENT_TO_TOP" + "INLINE_ALIGNMENT_TO_CENTER" "INLINE_ALIGNMENT_TO_BASELINE" "INLINE_ALIGNMENT_TO_BOTTOM" "INLINE_ALIGNMENT_TOP" + "INLINE_ALIGNMENT_CENTER" "INLINE_ALIGNMENT_BOTTOM" "INLINE_ALIGNMENT_IMAGE_MASK" "INLINE_ALIGNMENT_TEXT_MASK" + "EULER_ORDER_XYZ" "EULER_ORDER_XZY" "EULER_ORDER_YXZ" "EULER_ORDER_YZX" "EULER_ORDER_ZXY" "EULER_ORDER_ZYX" "KEY_NONE" + "KEY_SPECIAL" "KEY_ESCAPE" "KEY_TAB" "KEY_BACKTAB" "KEY_BACKSPACE" "KEY_ENTER" "KEY_KP_ENTER" "KEY_INSERT" "KEY_DELETE" + "KEY_PAUSE" "KEY_PRINT" "KEY_SYSREQ" "KEY_CLEAR" "KEY_HOME" "KEY_END" "KEY_LEFT" "KEY_UP" "KEY_RIGHT" "KEY_DOWN" + "KEY_PAGEUP" "KEY_PAGEDOWN" "KEY_SHIFT" "KEY_CTRL" "KEY_META" "KEY_ALT" "KEY_CAPSLOCK" "KEY_NUMLOCK" "KEY_SCROLLLOCK" + "KEY_F1" "KEY_F2" "KEY_F3" "KEY_F4" "KEY_F5" "KEY_F6" "KEY_F7" "KEY_F8" "KEY_F9" "KEY_F10" "KEY_F11" "KEY_F12" + "KEY_F13" "KEY_F14" "KEY_F15" "KEY_F16" "KEY_F17" "KEY_F18" "KEY_F19" "KEY_F20" "KEY_F21" "KEY_F22" "KEY_F23" "KEY_F24" + "KEY_F25" "KEY_F26" "KEY_F27" "KEY_F28" "KEY_F29" "KEY_F30" "KEY_F31" "KEY_F32" "KEY_F33" "KEY_F34" "KEY_F35" + "KEY_KP_MULTIPLY" "KEY_KP_DIVIDE" "KEY_KP_SUBTRACT" "KEY_KP_PERIOD" "KEY_KP_ADD" "KEY_KP_0" "KEY_KP_1" "KEY_KP_2" + "KEY_KP_3" "KEY_KP_4" "KEY_KP_5" "KEY_KP_6" "KEY_KP_7" "KEY_KP_8" "KEY_KP_9" "KEY_MENU" "KEY_HYPER" "KEY_HELP" + "KEY_BACK" "KEY_FORWARD" "KEY_STOP" "KEY_REFRESH" "KEY_VOLUMEDOWN" "KEY_VOLUMEMUTE" "KEY_VOLUMEUP" "KEY_MEDIAPLAY" + "KEY_MEDIASTOP" "KEY_MEDIAPREVIOUS" "KEY_MEDIANEXT" "KEY_MEDIARECORD" "KEY_HOMEPAGE" "KEY_FAVORITES" "KEY_SEARCH" + "KEY_STANDBY" "KEY_OPENURL" "KEY_LAUNCHMAIL" "KEY_LAUNCHMEDIA" "KEY_LAUNCH0" "KEY_LAUNCH1" "KEY_LAUNCH2" "KEY_LAUNCH3" + "KEY_LAUNCH4" "KEY_LAUNCH5" "KEY_LAUNCH6" "KEY_LAUNCH7" "KEY_LAUNCH8" "KEY_LAUNCH9" "KEY_LAUNCHA" "KEY_LAUNCHB" + "KEY_LAUNCHC" "KEY_LAUNCHD" "KEY_LAUNCHE" "KEY_LAUNCHF" "KEY_UNKNOWN" "KEY_SPACE" "KEY_EXCLAM" "KEY_QUOTEDBL" + "KEY_NUMBERSIGN" "KEY_DOLLAR" "KEY_PERCENT" "KEY_AMPERSAND" "KEY_APOSTROPHE" "KEY_PARENLEFT" "KEY_PARENRIGHT" + "KEY_ASTERISK" "KEY_PLUS" "KEY_COMMA" "KEY_MINUS" "KEY_PERIOD" "KEY_SLASH" "KEY_0" "KEY_1" "KEY_2" "KEY_3" "KEY_4" + "KEY_5" "KEY_6" "KEY_7" "KEY_8" "KEY_9" "KEY_COLON" "KEY_SEMICOLON" "KEY_LESS" "KEY_EQUAL" "KEY_GREATER" "KEY_QUESTION" + "KEY_AT" "KEY_A" "KEY_B" "KEY_C" "KEY_D" "KEY_E" "KEY_F" "KEY_G" "KEY_H" "KEY_I" "KEY_J" "KEY_K" "KEY_L" "KEY_M" + "KEY_N" "KEY_O" "KEY_P" "KEY_Q" "KEY_R" "KEY_S" "KEY_T" "KEY_U" "KEY_V" "KEY_W" "KEY_X" "KEY_Y" "KEY_Z" + "KEY_BRACKETLEFT" "KEY_BACKSLASH" "KEY_BRACKETRIGHT" "KEY_ASCIICIRCUM" "KEY_UNDERSCORE" "KEY_QUOTELEFT" "KEY_BRACELEFT" + "KEY_BAR" "KEY_BRACERIGHT" "KEY_ASCIITILDE" "KEY_YEN" "KEY_SECTION" "KEY_GLOBE" "KEY_KEYBOARD" "KEY_JIS_EISU" + "KEY_JIS_KANA" "KEY_CODE_MASK" "KEY_MODIFIER_MASK" "KEY_MASK_CMD_OR_CTRL" "KEY_MASK_SHIFT" "KEY_MASK_ALT" + "KEY_MASK_META" "KEY_MASK_CTRL" "KEY_MASK_KPAD" "KEY_MASK_GROUP_SWITCH" "MOUSE_BUTTON_NONE" "MOUSE_BUTTON_LEFT" + "MOUSE_BUTTON_RIGHT" "MOUSE_BUTTON_MIDDLE" "MOUSE_BUTTON_WHEEL_UP" "MOUSE_BUTTON_WHEEL_DOWN" "MOUSE_BUTTON_WHEEL_LEFT" + "MOUSE_BUTTON_WHEEL_RIGHT" "MOUSE_BUTTON_XBUTTON1" "MOUSE_BUTTON_XBUTTON2" "MOUSE_BUTTON_MASK_LEFT" + "MOUSE_BUTTON_MASK_RIGHT" "MOUSE_BUTTON_MASK_MIDDLE" "MOUSE_BUTTON_MASK_MB_XBUTTON1" "MOUSE_BUTTON_MASK_MB_XBUTTON2" + "JOY_BUTTON_INVALID" "JOY_BUTTON_A" "JOY_BUTTON_B" "JOY_BUTTON_X" "JOY_BUTTON_Y" "JOY_BUTTON_BACK" "JOY_BUTTON_GUIDE" + "JOY_BUTTON_START" "JOY_BUTTON_LEFT_STICK" "JOY_BUTTON_RIGHT_STICK" "JOY_BUTTON_LEFT_SHOULDER" + "JOY_BUTTON_RIGHT_SHOULDER" "JOY_BUTTON_DPAD_UP" "JOY_BUTTON_DPAD_DOWN" "JOY_BUTTON_DPAD_LEFT" "JOY_BUTTON_DPAD_RIGHT" + "JOY_BUTTON_MISC1" "JOY_BUTTON_PADDLE1" "JOY_BUTTON_PADDLE2" "JOY_BUTTON_PADDLE3" "JOY_BUTTON_PADDLE4" + "JOY_BUTTON_TOUCHPAD" "JOY_BUTTON_SDL_MAX" "JOY_BUTTON_MAX" "JOY_AXIS_INVALID" "JOY_AXIS_LEFT_X" "JOY_AXIS_LEFT_Y" + "JOY_AXIS_RIGHT_X" "JOY_AXIS_RIGHT_Y" "JOY_AXIS_TRIGGER_LEFT" "JOY_AXIS_TRIGGER_RIGHT" "JOY_AXIS_SDL_MAX" + "JOY_AXIS_MAX" "MIDI_MESSAGE_NONE" "MIDI_MESSAGE_NOTE_OFF" "MIDI_MESSAGE_NOTE_ON" "MIDI_MESSAGE_AFTERTOUCH" + "MIDI_MESSAGE_CONTROL_CHANGE" "MIDI_MESSAGE_PROGRAM_CHANGE" "MIDI_MESSAGE_CHANNEL_PRESSURE" "MIDI_MESSAGE_PITCH_BEND" + "MIDI_MESSAGE_SYSTEM_EXCLUSIVE" "MIDI_MESSAGE_QUARTER_FRAME" "MIDI_MESSAGE_SONG_POSITION_POINTER" + "MIDI_MESSAGE_SONG_SELECT" "MIDI_MESSAGE_TUNE_REQUEST" "MIDI_MESSAGE_TIMING_CLOCK" "MIDI_MESSAGE_START" + "MIDI_MESSAGE_CONTINUE" "MIDI_MESSAGE_STOP" "MIDI_MESSAGE_ACTIVE_SENSING" "MIDI_MESSAGE_SYSTEM_RESET" "OK" "FAILED" + "ERR_UNAVAILABLE" "ERR_UNCONFIGURED" "ERR_UNAUTHORIZED" "ERR_PARAMETER_RANGE_ERROR" "ERR_OUT_OF_MEMORY" + "ERR_FILE_NOT_FOUND" "ERR_FILE_BAD_DRIVE" "ERR_FILE_BAD_PATH" "ERR_FILE_NO_PERMISSION" "ERR_FILE_ALREADY_IN_USE" + "ERR_FILE_CANT_OPEN" "ERR_FILE_CANT_WRITE" "ERR_FILE_CANT_READ" "ERR_FILE_UNRECOGNIZED" "ERR_FILE_CORRUPT" + "ERR_FILE_MISSING_DEPENDENCIES" "ERR_FILE_EOF" "ERR_CANT_OPEN" "ERR_CANT_CREATE" "ERR_QUERY_FAILED" + "ERR_ALREADY_IN_USE" "ERR_LOCKED" "ERR_TIMEOUT" "ERR_CANT_CONNECT" "ERR_CANT_RESOLVE" "ERR_CONNECTION_ERROR" + "ERR_CANT_ACQUIRE_RESOURCE" "ERR_CANT_FORK" "ERR_INVALID_DATA" "ERR_INVALID_PARAMETER" "ERR_ALREADY_EXISTS" + "ERR_DOES_NOT_EXIST" "ERR_DATABASE_CANT_READ" "ERR_DATABASE_CANT_WRITE" "ERR_COMPILATION_FAILED" "ERR_METHOD_NOT_FOUND" + "ERR_LINK_FAILED" "ERR_SCRIPT_FAILED" "ERR_CYCLIC_LINK" "ERR_INVALID_DECLARATION" "ERR_DUPLICATE_SYMBOL" + "ERR_PARSE_ERROR" "ERR_BUSY" "ERR_SKIP" "ERR_HELP" "ERR_BUG" "ERR_PRINTER_ON_FIRE" "PROPERTY_HINT_NONE" + "PROPERTY_HINT_RANGE" "PROPERTY_HINT_ENUM" "PROPERTY_HINT_ENUM_SUGGESTION" "PROPERTY_HINT_EXP_EASING" + "PROPERTY_HINT_LINK" "PROPERTY_HINT_FLAGS" "PROPERTY_HINT_LAYERS_2D_RENDER" "PROPERTY_HINT_LAYERS_2D_PHYSICS" + "PROPERTY_HINT_LAYERS_2D_NAVIGATION" "PROPERTY_HINT_LAYERS_3D_RENDER" "PROPERTY_HINT_LAYERS_3D_PHYSICS" + "PROPERTY_HINT_LAYERS_3D_NAVIGATION" "PROPERTY_HINT_FILE" "PROPERTY_HINT_DIR" "PROPERTY_HINT_GLOBAL_FILE" + "PROPERTY_HINT_GLOBAL_DIR" "PROPERTY_HINT_RESOURCE_TYPE" "PROPERTY_HINT_MULTILINE_TEXT" "PROPERTY_HINT_EXPRESSION" + "PROPERTY_HINT_PLACEHOLDER_TEXT" "PROPERTY_HINT_COLOR_NO_ALPHA" "PROPERTY_HINT_OBJECT_ID" "PROPERTY_HINT_TYPE_STRING" + "PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE" "PROPERTY_HINT_OBJECT_TOO_BIG" "PROPERTY_HINT_NODE_PATH_VALID_TYPES" + "PROPERTY_HINT_SAVE_FILE" "PROPERTY_HINT_GLOBAL_SAVE_FILE" "PROPERTY_HINT_INT_IS_OBJECTID" + "PROPERTY_HINT_INT_IS_POINTER" "PROPERTY_HINT_ARRAY_TYPE" "PROPERTY_HINT_LOCALE_ID" "PROPERTY_HINT_LOCALIZABLE_STRING" + "PROPERTY_HINT_NODE_TYPE" "PROPERTY_HINT_HIDE_QUATERNION_EDIT" "PROPERTY_HINT_PASSWORD" "PROPERTY_HINT_MAX" + "PROPERTY_USAGE_NONE" "PROPERTY_USAGE_STORAGE" "PROPERTY_USAGE_EDITOR" "PROPERTY_USAGE_INTERNAL" + "PROPERTY_USAGE_CHECKABLE" "PROPERTY_USAGE_CHECKED" "PROPERTY_USAGE_GROUP" "PROPERTY_USAGE_CATEGORY" + "PROPERTY_USAGE_SUBGROUP" "PROPERTY_USAGE_CLASS_IS_BITFIELD" "PROPERTY_USAGE_NO_INSTANCE_STATE" + "PROPERTY_USAGE_RESTART_IF_CHANGED" "PROPERTY_USAGE_SCRIPT_VARIABLE" "PROPERTY_USAGE_STORE_IF_NULL" + "PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED" "PROPERTY_USAGE_SCRIPT_DEFAULT_VALUE" "PROPERTY_USAGE_CLASS_IS_ENUM" + "PROPERTY_USAGE_NIL_IS_VARIANT" "PROPERTY_USAGE_ARRAY" "PROPERTY_USAGE_ALWAYS_DUPLICATE" + "PROPERTY_USAGE_NEVER_DUPLICATE" "PROPERTY_USAGE_HIGH_END_GFX" "PROPERTY_USAGE_NODE_PATH_FROM_SCENE_ROOT" + "PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT" "PROPERTY_USAGE_KEYING_INCREMENTS" "PROPERTY_USAGE_DEFERRED_SET_RESOURCE" + "PROPERTY_USAGE_EDITOR_INSTANTIATE_OBJECT" "PROPERTY_USAGE_EDITOR_BASIC_SETTING" "PROPERTY_USAGE_READ_ONLY" + "PROPERTY_USAGE_DEFAULT" "PROPERTY_USAGE_NO_EDITOR" "METHOD_FLAG_NORMAL" "METHOD_FLAG_EDITOR" "METHOD_FLAG_CONST" + "METHOD_FLAG_VIRTUAL" "METHOD_FLAG_VARARG" "METHOD_FLAG_STATIC" "METHOD_FLAG_OBJECT_CORE" "METHOD_FLAGS_DEFAULT" + "TYPE_NIL" "TYPE_BOOL" "TYPE_INT" "TYPE_FLOAT" "TYPE_STRING" "TYPE_VECTOR2" "TYPE_VECTOR2I" "TYPE_RECT2" "TYPE_RECT2I" + "TYPE_VECTOR3" "TYPE_VECTOR3I" "TYPE_TRANSFORM2D" "TYPE_VECTOR4" "TYPE_VECTOR4I" "TYPE_PLANE" "TYPE_QUATERNION" + "TYPE_AABB" "TYPE_BASIS" "TYPE_TRANSFORM3D" "TYPE_PROJECTION" "TYPE_COLOR" "TYPE_STRING_NAME" "TYPE_NODE_PATH" + "TYPE_RID" "TYPE_OBJECT" "TYPE_CALLABLE" "TYPE_SIGNAL" "TYPE_DICTIONARY" "TYPE_ARRAY" "TYPE_PACKED_BYTE_ARRAY" + "TYPE_PACKED_INT32_ARRAY" "TYPE_PACKED_INT64_ARRAY" "TYPE_PACKED_FLOAT32_ARRAY" "TYPE_PACKED_FLOAT64_ARRAY" + "TYPE_PACKED_STRING_ARRAY" "TYPE_PACKED_VECTOR2_ARRAY" "TYPE_PACKED_VECTOR3_ARRAY" "TYPE_PACKED_COLOR_ARRAY" "TYPE_MAX" + "OP_EQUAL" "OP_NOT_EQUAL" "OP_LESS" "OP_LESS_EQUAL" "OP_GREATER" "OP_GREATER_EQUAL" "OP_ADD" "OP_SUBTRACT" + "OP_MULTIPLY" "OP_DIVIDE" "OP_NEGATE" "OP_POSITIVE" "OP_MODULE" "OP_POWER" "OP_SHIFT_LEFT" "OP_SHIFT_RIGHT" + "OP_BIT_AND" "OP_BIT_OR" "OP_BIT_XOR" "OP_BIT_NEGATE" "OP_AND" "OP_OR" "OP_XOR" "OP_NOT" "OP_IN" "OP_MAX" + )) + diff --git a/queries/gdscript/indents.scm b/queries/gdscript/indents.scm index 38069c38f..74d14d3b8 100644 --- a/queries/gdscript/indents.scm +++ b/queries/gdscript/indents.scm @@ -1,24 +1,78 @@ [ - (if_statement) + (lambda) + (function_definition) (for_statement) (while_statement) - - (parenthesized_expression) - - (function_definition) + (if_statement) (class_definition) + (match_statement) + (pattern_section) + (setget) + (match_body) + (set_body) + (get_body) ] @indent -((arguments) @aligned_indent - (#set! "delimiter" "()")) -((parameters) @aligned_indent - (#set! "delimiter" "()")) - [ - ")" - "]" - "}" (elif_clause) (else_clause) ] @branch + +[ + (string) + (comment) + (array) + (dictionary) + (parenthesized_expression) + (ERROR) +] @auto + +[ + (pass_statement) + (continue_statement) + (break_statement) + (return_statement) +] @dedent + +[ + (ERROR "[") + (ERROR "(") + (ERROR "{") +] @indent + +;; This only works with expanded tabs. +; ((parameters) @aligned_indent (#set! "delimiter" "()")) +; ((arguments) @aligned_indent (#set! "delimiter" "()")) + +;; The following queries either do not agree with the current body parsing or are +;; attempted workarounds. Specifically as the last statement of a body. Opening +;; a new line in between statements works well. +;; +;; The overall experience is poor, so I've opted for @auto. +;; +;; The gdscript parser will need to be patched to accommodate more interactive +;; edits. As far as I can tell the parser greedily consumes whitespace +;; as a zero-width token which causes trouble when inserting indents. + +;; This indents correctly with tabs. +; (arguments) @indent +; (parameters) @indent +; (array) @indent +; (dictionary) @indent +; (parenthesized_expression) @indent + +;; Partial workaround for when the cursor is on the bracket character and a newline +;; is created with . Without this the newline is opened with extra +;; indentation. +; (body (_ (array "]" @indent_end) ) _) +;; Problematic behaviors occur at the last statement of a body. +;; with @dedent: +;; - [ | ] i will dedent ] to 0. +;; - [ +;; ]| o will open new line at correct indentation. +;; with @auto: +;; - [ | ] i same +;; - [ +;; ]| o will open new line with extra indent. +;(body (_ (array "]" @auto) ) .) diff --git a/queries/gdscript/locals.scm b/queries/gdscript/locals.scm index 313af2aef..2c352b4a3 100644 --- a/queries/gdscript/locals.scm +++ b/queries/gdscript/locals.scm @@ -1,10 +1,92 @@ -(function_definition) @definition.function +;; Scopes [ - (extends_statement) - (variable_statement) - (expression_statement) (if_statement) + (elif_clause) + (else_clause) + (for_statement) + (while_statement) (function_definition) - (body) + (constructor_definition) + (class_definition) + (match_statement) + (pattern_section) + (lambda) + (get_body) + (set_body) ] @scope + +;; Parameters + +(parameters (identifier) @definition.parameter) +(default_parameter (identifier) @definition.parameter) +(typed_parameter (identifier) @definition.parameter) +(typed_default_parameter (identifier) @definition.parameter) + +;; Signals + +; Can gdscript 2 signals be considered fields? +(signal_statement (name) @definition.field) + +;; Variable Definitions + +(const_statement (name) @definition.constant) +; onready and export variations are only properties. +(variable_statement (name) @definition.var) + +(setter) @reference +(getter) @reference + +;; Function Definition + +((function_definition (name) @definition.function) + (#set! "definition.function.scope" "parent")) + +;; Lambda + +; lambda names are not accessible and are only for debugging. +(lambda (name) @definition.function) + +;; Source + +(class_name_statement (name) @definition.type) + +(source (variable_statement (name) @definition.field)) +(source (onready_variable_statement (name) @definition.field)) +(source (export_variable_statement (name) @definition.field)) + +;; Class + +((class_definition (name) @definition.type) + (#set! "definition.type.scope" "parent")) + +(class_definition + (body (variable_statement (name) @definition.field))) +(class_definition + (body (onready_variable_statement (name) @definition.field))) +(class_definition + (body (export_variable_statement (name) @definition.field))) +(class_definition + (body (signal_statement (name) @definition.field))) + +; Although a script is also a class, let's only define functions in an inner class as +; methods. +((class_definition + (body (function_definition (name) @definition.method))) + (#set! "definition.method.scope" "parent")) + +;; Enum + +((enum_definition (name) @definition.enum)) + +;; Repeat + +(for_statement . (identifier) @definition.var) + +;; Match Statement + +(pattern_binding (identifier) @definition.var) + +;; References + +(identifier) @reference From 6d96e2b6ace02db0bedc60ff268f2da7877895e0 Mon Sep 17 00:00:00 2001 From: GitHub Date: Thu, 2 Mar 2023 06:41:32 +0000 Subject: [PATCH 0047/2704] Update parsers: erlang, haskell, qmldir, sql, v --- lockfile.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lockfile.json b/lockfile.json index 437e104a3..91366890b 100644 --- a/lockfile.json +++ b/lockfile.json @@ -111,7 +111,7 @@ "revision": "203f7bd3c1bbfbd98fc19add4b8fcb213c059205" }, "erlang": { - "revision": "2422bc9373094bfa97653ac540e08759f812523c" + "revision": "9fe5cdfab0f0d753112e9949a3501f64b75a3d92" }, "fennel": { "revision": "517195970428aacca60891b050aa53eabf4ba78d" @@ -180,7 +180,7 @@ "revision": "b7bd6928532ada34dddb1dece4a158ab62c6e783" }, "haskell": { - "revision": "3bdba07c7a8eec23f87fa59ce9eb2ea4823348b3" + "revision": "0da7f826e85b3e589e217adf69a6fd89ee4301b9" }, "hcl": { "revision": "0ff887f2a60a147452d52db060de6b42f42f1441" @@ -351,7 +351,7 @@ "revision": "bd087020f0d8c183080ca615d38de0ec827aeeaf" }, "qmldir": { - "revision": "ce42c9abb9b86a563f117d733b3bc0dd7e2e6e76" + "revision": "6b2b5e41734bd6f07ea4c36ac20fb6f14061c841" }, "qmljs": { "revision": "ab75be9750e6f2f804638824d1790034286a830c" @@ -414,7 +414,7 @@ "revision": "05f949d3c1c15e3261473a244d3ce87777374dec" }, "sql": { - "revision": "672fe6b5180d20e9e84fd61749cc3e083e88d9d9" + "revision": "d4b8be1e52b07b66e5ec62d2f1c0d701dfa85ed9" }, "starlark": { "revision": "8ad93a74c2a880bc16325affba3cc66c14bb2bde" @@ -474,7 +474,7 @@ "revision": "debd26fed283d80456ebafa33a06957b0c52e451" }, "v": { - "revision": "136f3a0ad91ab8a781c2d4eb419df0a981839f69" + "revision": "66cf9d3086fb5ecc827cb32c64c5d812ab17d2c6" }, "vala": { "revision": "8f690bfa639f2b83d1fb938ed3dd98a7ba453e8b" From b31312729e1b779e2773d99bf83355b09b5ba3d3 Mon Sep 17 00:00:00 2001 From: Github Actions Date: Thu, 2 Mar 2023 07:28:32 +0000 Subject: [PATCH 0048/2704] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 666d264b6..90bebb570 100644 --- a/README.md +++ b/README.md @@ -218,7 +218,7 @@ We are looking for maintainers to add more parsers and to write query files for - [x] [fsh](https://github.com/mgramigna/tree-sitter-fsh) (maintained by @mgramigna) - [x] [func](https://github.com/amaanq/tree-sitter-func) (maintained by @amaanq) - [x] [fusion](https://gitlab.com/jirgn/tree-sitter-fusion.git) (maintained by @jirgn) -- [ ] [Godot (gdscript)](https://github.com/PrestonKnopp/tree-sitter-gdscript) +- [x] [Godot (gdscript)](https://github.com/PrestonKnopp/tree-sitter-gdscript) (maintained by @PrestonKnopp) - [x] [git_rebase](https://github.com/the-mikedavis/tree-sitter-git-rebase) (maintained by @gbprod) - [x] [gitattributes](https://github.com/ObserverOfTime/tree-sitter-gitattributes) (maintained by @ObserverOfTime) - [x] [gitcommit](https://github.com/gbprod/tree-sitter-gitcommit) (maintained by @gbprod) From 07fb134752b4af49d1a87cc735573edeadcbb271 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Thu, 2 Mar 2023 17:53:56 +0100 Subject: [PATCH 0049/2704] markdown!: switch to scanner.c --- lockfile.json | 4 ++-- lua/nvim-treesitter/parsers.lua | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lockfile.json b/lockfile.json index 91366890b..44d7d437a 100644 --- a/lockfile.json +++ b/lockfile.json @@ -267,10 +267,10 @@ "revision": "a4b9187417d6be349ee5fd4b6e77b4172c6827dd" }, "markdown": { - "revision": "6138ee0c0d0ddafc4bf0e25728b73f902bbf2c98" + "revision": "afbb3195c9c1683e358eb36805c0088ffbb2306c" }, "markdown_inline": { - "revision": "6138ee0c0d0ddafc4bf0e25728b73f902bbf2c98" + "revision": "afbb3195c9c1683e358eb36805c0088ffbb2306c" }, "matlab": { "revision": "2d5d3d5193718a86477d4335aba5b34e79147326" diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index a600e2de0..249a1b00a 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -869,7 +869,7 @@ list.markdown = { install_info = { url = "https://github.com/MDeiml/tree-sitter-markdown", location = "tree-sitter-markdown", - files = { "src/parser.c", "src/scanner.cc" }, + files = { "src/parser.c", "src/scanner.c" }, branch = "split_parser", readme_name = "markdown (basic highlighting)", }, @@ -881,7 +881,7 @@ list.markdown_inline = { install_info = { url = "https://github.com/MDeiml/tree-sitter-markdown", location = "tree-sitter-markdown-inline", - files = { "src/parser.c", "src/scanner.cc" }, + files = { "src/parser.c", "src/scanner.c" }, branch = "split_parser", readme_name = "markdown_inline (needs to be installed for full markdown highlighting)", }, From e9fb90da020d08bda2a616324a64921fde3236f6 Mon Sep 17 00:00:00 2001 From: Matthias Queitsch Date: Thu, 2 Mar 2023 18:41:33 +0100 Subject: [PATCH 0050/2704] feat(prql): update queries --- lockfile.json | 2 +- queries/prql/highlights.scm | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lockfile.json b/lockfile.json index 44d7d437a..6b1281d85 100644 --- a/lockfile.json +++ b/lockfile.json @@ -339,7 +339,7 @@ "revision": "42d82fa18f8afe59b5fc0b16c207ee4f84cb185f" }, "prql": { - "revision": "3f27cac466f030ee7d985d91eba5470e01dd21ea" + "revision": "5f6c4e4a90633b19e2077c1d37248989789d64be" }, "pug": { "revision": "884e225b5ecca5d885ae627275f16ef648acd42e" diff --git a/queries/prql/highlights.scm b/queries/prql/highlights.scm index 3810bdda4..a69259a0a 100644 --- a/queries/prql/highlights.scm +++ b/queries/prql/highlights.scm @@ -22,7 +22,7 @@ ] @keyword [ - (literal) + (literal_string) (f_string) (s_string) ] @string @@ -84,6 +84,15 @@ alias: (identifier) @field (keyword_sum) (keyword_stddev) (keyword_count) + (keyword_lag) + (keyword_lead) + (keyword_first) + (keyword_last) + (keyword_rank) + (keyword_row_number) + (keyword_round) + (keyword_all) + (keyword_map) ] @function [ From 8894d78f63a589b7fca609e42d682e32067b2448 Mon Sep 17 00:00:00 2001 From: Anthony Shi <69449791+anthony-S93@users.noreply.github.com> Date: Fri, 3 Mar 2023 11:37:21 +0800 Subject: [PATCH 0051/2704] Update highlights.scm for Python Added new keywords "is not" and "not in" --- queries/python/highlights.scm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/queries/python/highlights.scm b/queries/python/highlights.scm index b8b8b7b94..54ad82b09 100644 --- a/queries/python/highlights.scm +++ b/queries/python/highlights.scm @@ -227,6 +227,8 @@ "is" "not" "or" + "is not" + "not in" "del" ] @keyword.operator From a0d6c28f893cbbc761cfa7fc7204ba6f3e2710cf Mon Sep 17 00:00:00 2001 From: GitHub Date: Fri, 3 Mar 2023 06:40:53 +0000 Subject: [PATCH 0052/2704] Update parsers: cpp, cuda, markdown, markdown_inline, racket, sql --- lockfile.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lockfile.json b/lockfile.json index 6b1281d85..4720e882c 100644 --- a/lockfile.json +++ b/lockfile.json @@ -60,13 +60,13 @@ "revision": "eedb93bf9e22e82ed6a67e6c57fd78731b44f591" }, "cpp": { - "revision": "66262d3e76eb2046c76e6d661a6b72664bfb5819" + "revision": "03fa93db133d6048a77d4de154a7b17ea8b9d076" }, "css": { "revision": "769203d0f9abe1a9a691ac2b9fe4bb4397a73c51" }, "cuda": { - "revision": "9b1f7481a151686fce8af66da147f40388f8ee4d" + "revision": "91c3ca3e42326e0f7b83c82765940bbf7f91c847" }, "d": { "revision": "c2fbf21bd3aa45495fe13247e040ad5815250032" @@ -267,10 +267,10 @@ "revision": "a4b9187417d6be349ee5fd4b6e77b4172c6827dd" }, "markdown": { - "revision": "afbb3195c9c1683e358eb36805c0088ffbb2306c" + "revision": "10b9b5ad8742456b383908868b14709d73ff81f4" }, "markdown_inline": { - "revision": "afbb3195c9c1683e358eb36805c0088ffbb2306c" + "revision": "10b9b5ad8742456b383908868b14709d73ff81f4" }, "matlab": { "revision": "2d5d3d5193718a86477d4335aba5b34e79147326" @@ -363,7 +363,7 @@ "revision": "80efda55672d1293aa738f956c7ae384ecdc31b4" }, "racket": { - "revision": "1a5df0206b25a05cb1b35a68d2105fc7493df39b" + "revision": "c2f7baa22053a66b4dba852cdba3f14f34bb6985" }, "rasi": { "revision": "5f04634dd4e12de4574c4a3dc9d6d5d4da4a2a1b" @@ -414,7 +414,7 @@ "revision": "05f949d3c1c15e3261473a244d3ce87777374dec" }, "sql": { - "revision": "d4b8be1e52b07b66e5ec62d2f1c0d701dfa85ed9" + "revision": "ee50e2e8c3df92bd66093aefa1834b2735355b9b" }, "starlark": { "revision": "8ad93a74c2a880bc16325affba3cc66c14bb2bde" From 8212548e3346aa56166a0831016026f265562e4a Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Fri, 3 Mar 2023 15:49:25 +0100 Subject: [PATCH 0053/2704] docs(readme): recommend installing query parser now bundled in Neovim --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 90bebb570..f97bcd5bb 100644 --- a/README.md +++ b/README.md @@ -105,8 +105,8 @@ All modules are disabled by default and need to be activated explicitly in your ```lua require'nvim-treesitter.configs'.setup { - -- A list of parser names, or "all" (the four listed parsers should always be installed) - ensure_installed = { "c", "lua", "vim", "help" }, + -- A list of parser names, or "all" (the five listed parsers should always be installed) + ensure_installed = { "c", "lua", "vim", "help", "query" }, -- Install parsers synchronously (only applied to `ensure_installed`) sync_install = false, From 1bf4be044138cc9b3f802d77a9d5c2b5dd9be61d Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Fri, 24 Feb 2023 05:37:39 -0500 Subject: [PATCH 0054/2704] docs: add `@keyword.coroutine` --- CONTRIBUTING.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 219555a8a..f954bff1d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -140,6 +140,7 @@ effect on highlighting. We will work on improving highlighting in the near futur ```scheme @keyword ; various keywords +@keyword.coroutine ; keywords related to coroutines (e.g. `go` in Go, `async/await` in Python) @keyword.function ; keywords that define a function (e.g. `func` in Go, `def` in Python) @keyword.operator ; operators that are English words (e.g. `and` / `or`) @keyword.return ; keywords like `return` and `yield` From 33ba346e60c3151fcdafc55d0e547556dc803c03 Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Fri, 24 Feb 2023 06:37:45 -0500 Subject: [PATCH 0055/2704] feat!: add `@keyword.coroutine` capture --- queries/c_sharp/highlights.scm | 7 ++- queries/clojure/highlights.scm | 14 +++--- queries/cpp/highlights.scm | 15 ++++--- queries/dart/highlights.scm | 13 +++--- queries/ecma/highlights.scm | 79 +++++++++++++++++---------------- queries/gdscript/highlights.scm | 9 ++-- queries/hack/highlights.scm | 7 ++- queries/kotlin/highlights.scm | 8 +++- queries/python/highlights.scm | 7 ++- queries/rust/highlights.scm | 7 ++- queries/starlark/highlights.scm | 5 +++ queries/svelte/highlights.scm | 3 ++ queries/swift/highlights.scm | 6 ++- queries/thrift/highlights.scm | 11 ++++- queries/tlaplus/highlights.scm | 4 +- queries/vala/highlights.scm | 7 ++- queries/zig/highlights.scm | 13 +++--- 17 files changed, 137 insertions(+), 78 deletions(-) diff --git a/queries/c_sharp/highlights.scm b/queries/c_sharp/highlights.scm index ddb08eca4..c2bac3c1d 100644 --- a/queries/c_sharp/highlights.scm +++ b/queries/c_sharp/highlights.scm @@ -337,8 +337,6 @@ "implicit" "explicit" "override" - "async" - "await" "class" "delegate" "enum" @@ -358,6 +356,11 @@ "fixed" ] @keyword +[ + "async" + "await" +] @keyword.coroutine + [ "const" "extern" diff --git a/queries/clojure/highlights.scm b/queries/clojure/highlights.scm index 00a692521..e5609b25b 100644 --- a/queries/clojure/highlights.scm +++ b/queries/clojure/highlights.scm @@ -112,6 +112,9 @@ "deftype")) ((sym_lit) @keyword (#eq? @keyword "declare")) +((sym_name) @keyword.coroutine + (#any-of? @keyword.coroutine + "alts!" "alts!!" "await" "await-for" "await1" "chan" "close!" "future" "go" "sync" "thread" "timeout" "!" ">!!")) ((sym_lit) @keyword.function (#match? @keyword.function "^(defn|defn-|fn|fn[*])$")) @@ -148,13 +151,13 @@ (#any-of? @function.macro "." ".." "->" "->>" "amap" "areduce" "as->" "assert" "binding" "bound-fn" "delay" "do" "dosync" - "doto" "extend-protocol" "extend-type" "future" + "doto" "extend-protocol" "extend-type" "gen-class" "gen-interface" "io!" "lazy-cat" "lazy-seq" "let" "letfn" "locking" "memfn" "monitor-enter" "monitor-exit" "proxy" "proxy-super" "pvalues" - "refer-clojure" "reify" "set!" "some->" "some->>" "sync" + "refer-clojure" "reify" "set!" "some->" "some->>" "time" "unquote" "unquote-splicing" "var" "vswap!" - "ex-cause" "ex-data" "ex-message")) + "ex-cause" "ex-data" "ex-message")) ((sym_lit) @function.macro (#match? @function.macro "^with\\-.*$")) @@ -175,9 +178,8 @@ "any?" "apply" "array-map" "aset" "aset-boolean" "aset-byte" "aset-char" "aset-double" "aset-float" "aset-int" "aset-long" "aset-short" "assoc" "assoc!" "assoc-in" - "associative?" "atom" "await" "await-for" "await1" - "bases" "bean" "bigdec" "bigint" "biginteger" "bit-and" - "bit-and-not" "bit-clear" "bit-flip" "bit-not" "bit-or" + "associative?" "atom" "bases" "bean" "bigdec" "bigint" "biginteger" + "bit-and" "bit-and-not" "bit-clear" "bit-flip" "bit-not" "bit-or" "bit-set" "bit-shift-left" "bit-shift-right" "bit-test" "bit-xor" "boolean" "boolean-array" "boolean?" "booleans" "bound-fn*" "bound?" "bounded-count" diff --git a/queries/cpp/highlights.scm b/queries/cpp/highlights.scm index 1f770e9f8..0f12dd8df 100644 --- a/queries/cpp/highlights.scm +++ b/queries/cpp/highlights.scm @@ -143,11 +143,19 @@ "template" "typename" "using" - "co_await" "concept" "requires" ] @keyword +[ + "co_await" +] @keyword.coroutine + +[ + "co_yield" + "co_return" +] @keyword.coroutine.return + [ "public" "private" @@ -156,11 +164,6 @@ "final" ] @type.qualifier -[ - "co_yield" - "co_return" -] @keyword.return - [ "new" "delete" diff --git a/queries/dart/highlights.scm b/queries/dart/highlights.scm index f5e391092..154a92b3a 100644 --- a/queries/dart/highlights.scm +++ b/queries/dart/highlights.scm @@ -195,14 +195,12 @@ [ "return" - "yield" ] @keyword.return ; Built in identifiers: ; alone these are marked as keywords [ - "await" "deferred" "factory" "get" @@ -216,17 +214,22 @@ "typedef" ] @keyword +[ + "async" + "async*" + "sync*" + "await" + "yield" +] @keyword.coroutine + [ (const_builtin) (final_builtin) "abstract" - "async" - "async*" "covariant" "dynamic" "external" "static" - "sync*" ] @type.qualifier ; when used as an identifier: diff --git a/queries/ecma/highlights.scm b/queries/ecma/highlights.scm index e347098a3..cdae02ab2 100644 --- a/queries/ecma/highlights.scm +++ b/queries/ecma/highlights.scm @@ -210,15 +210,15 @@ ;---------- [ -"if" -"else" -"switch" -"case" + "if" + "else" + "switch" + "case" ] @conditional [ -"import" -"from" + "import" + "from" ] @include (export_specifier "as" @include) @@ -227,53 +227,56 @@ (namespace_import "as" @include) [ -"for" -"of" -"do" -"while" -"continue" + "for" + "of" + "do" + "while" + "continue" ] @repeat [ -"async" -"await" -"break" -"class" -"const" -"debugger" -"export" -"extends" -"get" -"in" -"instanceof" -"let" -"set" -"static" -"target" -"typeof" -"var" -"with" + "break" + "class" + "const" + "debugger" + "export" + "extends" + "get" + "in" + "instanceof" + "let" + "set" + "static" + "target" + "typeof" + "var" + "with" ] @keyword [ -"return" -"yield" + "async" + "await" +] @keyword.coroutine + +[ + "return" + "yield" ] @keyword.return [ - "function" + "function" ] @keyword.function [ - "new" - "delete" + "new" + "delete" ] @keyword.operator [ - "throw" - "try" - "catch" - "finally" + "throw" + "try" + "catch" + "finally" ] @exception (export_statement diff --git a/queries/gdscript/highlights.scm b/queries/gdscript/highlights.scm index 073096556..c6c6dae13 100644 --- a/queries/gdscript/highlights.scm +++ b/queries/gdscript/highlights.scm @@ -159,12 +159,15 @@ "func" @keyword.function [ - "await" "return" ] @keyword.return -(call (identifier) @keyword.return - (#eq? @keyword.return "yield")) +[ + "await" +] @keyword.coroutine + +(call (identifier) @keyword.coroutine + (#eq? @keyword.coroutine "yield")) ;; Builtins diff --git a/queries/hack/highlights.scm b/queries/hack/highlights.scm index e79d62c75..ffb365c87 100644 --- a/queries/hack/highlights.scm +++ b/queries/hack/highlights.scm @@ -17,8 +17,6 @@ "function" @keyword.function [ - "async" - "await" "type" "interface" "implements" @@ -31,6 +29,11 @@ "insteadof" ] @keyword +[ + "async" + "await" +] @keyword.coroutine + [ "use" "include" diff --git a/queries/kotlin/highlights.scm b/queries/kotlin/highlights.scm index 2fd2c089b..caf62f1f0 100644 --- a/queries/kotlin/highlights.scm +++ b/queries/kotlin/highlights.scm @@ -307,7 +307,13 @@ ; "typeof" ; NOTE: It is reserved for future use ] @keyword -("fun") @keyword.function +[ + "suspend" +] @keyword.coroutine + +[ + "fun" +] @keyword.function (jump_expression) @keyword.return diff --git a/queries/python/highlights.scm b/queries/python/highlights.scm index 54ad82b09..fe66d7ca3 100644 --- a/queries/python/highlights.scm +++ b/queries/python/highlights.scm @@ -240,8 +240,6 @@ [ "assert" - "async" - "await" "class" "exec" "global" @@ -252,6 +250,11 @@ "as" ] @keyword +[ + "async" + "await" +] @keyword.coroutine + [ "return" "yield" diff --git a/queries/rust/highlights.scm b/queries/rust/highlights.scm index db80fbb32..c24a278f6 100644 --- a/queries/rust/highlights.scm +++ b/queries/rust/highlights.scm @@ -169,8 +169,6 @@ (use_as_clause "as" @include) [ - "async" - "await" "default" "dyn" "enum" @@ -188,6 +186,11 @@ "where" ] @keyword +[ + "async" + "await" +] @keyword.coroutine + [ "ref" (mutable_specifier) diff --git a/queries/starlark/highlights.scm b/queries/starlark/highlights.scm index 401b985d7..a92832d68 100644 --- a/queries/starlark/highlights.scm +++ b/queries/starlark/highlights.scm @@ -228,6 +228,11 @@ "as" ] @keyword +[ + "async" + "await" +] @keyword.coroutine + [ "return" ] @keyword.return diff --git a/queries/svelte/highlights.scm b/queries/svelte/highlights.scm index 058682a7c..e1a67296e 100644 --- a/queries/svelte/highlights.scm +++ b/queries/svelte/highlights.scm @@ -8,6 +8,9 @@ (as) ] @keyword +((special_block_keyword) @keyword.coroutine + (#eq? @keyword.coroutine "await")) + [ "{" "}" diff --git a/queries/swift/highlights.scm b/queries/swift/highlights.scm index c6220984e..5773c2377 100644 --- a/queries/swift/highlights.scm +++ b/queries/swift/highlights.scm @@ -22,7 +22,6 @@ (function_declaration (simple_identifier) @method) (function_declaration ["init" @constructor]) (throws) @keyword -"async" @keyword (where_keyword) @keyword (parameter external_name: (simple_identifier) @parameter) (parameter name: (simple_identifier) @parameter) @@ -47,6 +46,11 @@ "some" ] @keyword +[ + "async" + "await" +] @keyword.coroutine + [ (getter_specifier) (setter_specifier) diff --git a/queries/thrift/highlights.scm b/queries/thrift/highlights.scm index c6ff6464f..5df609c3d 100644 --- a/queries/thrift/highlights.scm +++ b/queries/thrift/highlights.scm @@ -86,7 +86,6 @@ "include" "interaction" "namespace" - "oneway" "optional" "required" "senum" @@ -96,10 +95,13 @@ "union" ] @keyword +[ + "oneway" +] @keyword.coroutine + ; Deprecated Keywords [ - "async" "cocoa_prefix" "cpp_namespace" "csharp_namespace" @@ -118,7 +120,12 @@ "xsd_optional" ] @keyword +[ + "async" +] @keyword.coroutine + ; Extended Keywords + [ "client" "idempotent" diff --git a/queries/tlaplus/highlights.scm b/queries/tlaplus/highlights.scm index a94a91f4e..2199359f8 100644 --- a/queries/tlaplus/highlights.scm +++ b/queries/tlaplus/highlights.scm @@ -81,7 +81,6 @@ (pcal_algorithm_start) "algorithm" "assert" - "await" "begin" "call" "define" @@ -98,6 +97,9 @@ "when" "with" ] @keyword +[ + "await" +] @keyword.coroutine (pcal_with ("=") @keyword) (pcal_process ("=") @keyword) [ diff --git a/queries/vala/highlights.scm b/queries/vala/highlights.scm index 1c9732dff..5ad7e0345 100644 --- a/queries/vala/highlights.scm +++ b/queries/vala/highlights.scm @@ -90,7 +90,6 @@ [ "abstract" - "async" "class" "construct" "continue" @@ -114,6 +113,11 @@ "with" ] @keyword +[ + "async" + "yield" +] @keyword.coroutine + [ "const" "dynamic" @@ -183,7 +187,6 @@ [ "return" - "yield" ] @keyword.return [ diff --git a/queries/zig/highlights.scm b/queries/zig/highlights.scm index e3e91dc65..60e5b373a 100644 --- a/queries/zig/highlights.scm +++ b/queries/zig/highlights.scm @@ -95,10 +95,17 @@ field_constant: (IDENTIFIER) @constant "asm" "defer" "errdefer" - "nosuspend" "test" ] @keyword +[ + "async" + "await" + "suspend" + "nosuspend" + "resume" +] @keyword.coroutine + [ "fn" ] @keyword.function @@ -111,10 +118,6 @@ field_constant: (IDENTIFIER) @constant [ "return" - "async" - "await" - "suspend" - "resume" ] @keyword.return [ From 3c8842c79a2b499453c7f40d4babf5067a07e452 Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Fri, 24 Feb 2023 06:38:02 -0500 Subject: [PATCH 0056/2704] refactor(ruby): move keywords appropriately --- queries/ruby/highlights.scm | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/queries/ruby/highlights.scm b/queries/ruby/highlights.scm index cf253a474..c350e5ad1 100644 --- a/queries/ruby/highlights.scm +++ b/queries/ruby/highlights.scm @@ -8,19 +8,13 @@ [ "alias" "begin" - "break" "class" - "def" "do" "end" "ensure" "module" - "next" - "redo" "rescue" - "retry" "then" - "undef" ] @keyword [ @@ -35,6 +29,14 @@ "not" ] @keyword.operator +[ + "def" + "undef" +] @keyword.function + +(method + "end" @keyword.function) + [ "case" "else" @@ -44,10 +46,23 @@ "when" ] @conditional +(if + "end" @conditional) +(if + (then) @conditional) +(unless + (then) @conditional) +(elsif + (then) @conditional) + [ "for" "until" "while" + "break" + "redo" + "retry" + "next" ] @repeat (constant) @type From d2a45aa5318b7b1a6d66dbdd7d2d592dd5bb21d7 Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Fri, 24 Feb 2023 06:38:47 -0500 Subject: [PATCH 0057/2704] refactor(zig): `@type.definition` items belong in `@keyword`, differentiate `@boolean` from `@constant.builtin` --- queries/zig/highlights.scm | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/queries/zig/highlights.scm b/queries/zig/highlights.scm index 60e5b373a..0989704ce 100644 --- a/queries/zig/highlights.scm +++ b/queries/zig/highlights.scm @@ -79,6 +79,11 @@ field_constant: (IDENTIFIER) @constant (FLOAT) @float +[ + "true" + "false" +] @boolean + [ (LINESTRING) (STRINGLITERALSINGLE) @@ -96,6 +101,11 @@ field_constant: (IDENTIFIER) @constant "defer" "errdefer" "test" + "struct" + "union" + "enum" + "opaque" + "error" ] @keyword [ @@ -147,14 +157,6 @@ field_constant: (IDENTIFIER) @constant (BuildinTypeExpr) ] @type.builtin -[ - "struct" - "union" - "enum" - "opaque" - "error" -] @type.definition - [ "const" "var" @@ -185,8 +187,6 @@ field_constant: (IDENTIFIER) @constant "null" "unreachable" "undefined" - "true" - "false" ] @constant.builtin [ From 3c42fb9d702e1246313d2b5531b815595cb4d889 Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Fri, 24 Feb 2023 06:54:21 -0500 Subject: [PATCH 0058/2704] refactor(svelte): match certain keywords for conditional and exception --- queries/svelte/highlights.scm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/queries/svelte/highlights.scm b/queries/svelte/highlights.scm index e1a67296e..9877fc7a5 100644 --- a/queries/svelte/highlights.scm +++ b/queries/svelte/highlights.scm @@ -11,6 +11,12 @@ ((special_block_keyword) @keyword.coroutine (#eq? @keyword.coroutine "await")) +((special_block_keyword) @exception + (#eq? @exception "catch")) + +((special_block_keyword) @conditional + (#match? @conditional "^(if|else)$")) + [ "{" "}" From f225f53510986997ae843b2a825df8083d85a191 Mon Sep 17 00:00:00 2001 From: GitHub Date: Fri, 3 Mar 2023 15:23:53 +0000 Subject: [PATCH 0059/2704] Update parsers: sql, yuck --- lockfile.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lockfile.json b/lockfile.json index 4720e882c..bf3d59baf 100644 --- a/lockfile.json +++ b/lockfile.json @@ -414,7 +414,7 @@ "revision": "05f949d3c1c15e3261473a244d3ce87777374dec" }, "sql": { - "revision": "ee50e2e8c3df92bd66093aefa1834b2735355b9b" + "revision": "1cb7c7a11015983f6d173847d5a3574f8e20107b" }, "starlark": { "revision": "8ad93a74c2a880bc16325affba3cc66c14bb2bde" @@ -504,7 +504,7 @@ "revision": "2c0e6be8dd4dcb961c345fa35c309ad4f5bd3502" }, "yuck": { - "revision": "1e1a7e10053b910f3864fe8d97ca1741d2df66b2" + "revision": "0f96c1d3bbdd32ca92b4e706c3f1fc2cb0d26b3f" }, "zig": { "revision": "1cd5f339b146b764f39b36bb7be98ca631a2e02a" From 190561df8995ff9526c06d33cf17416b9e0791e3 Mon Sep 17 00:00:00 2001 From: Yochem van Rosmalen Date: Fri, 3 Mar 2023 18:55:49 +0100 Subject: [PATCH 0060/2704] v(injections): inject regex for some methods in `re` module --- queries/v/highlights.scm | 2 ++ queries/v/injections.scm | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/queries/v/highlights.scm b/queries/v/highlights.scm index af2905239..16904d18b 100644 --- a/queries/v/highlights.scm +++ b/queries/v/highlights.scm @@ -396,6 +396,8 @@ (rune_literal) @string +(raw_string_literal) @string + (escape_sequence) @string.escape (float_literal) @float diff --git a/queries/v/injections.scm b/queries/v/injections.scm index b77e7c630..11f02639e 100644 --- a/queries/v/injections.scm +++ b/queries/v/injections.scm @@ -4,3 +4,10 @@ ;; #include <...> (hash_statement) @c +;; regex for the methods defined in `re` module +((call_expression + function: (selector_expression + field: (identifier) @_re) + arguments: (argument_list + (raw_string_literal) @regex (#offset! @regex 0 2 0 -1))) + (#any-of? @_re "regex_base" "regex_opt" "compile_opt")) From 28f84d69e3b6c26f1f7a2ef3f248a7242f36d620 Mon Sep 17 00:00:00 2001 From: Evan Phoenix Date: Fri, 3 Mar 2023 20:26:51 -0800 Subject: [PATCH 0061/2704] fix(go): Indent on type switch case properly --- queries/go/indents.scm | 1 + tests/indent/go/switch.go | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/queries/go/indents.scm b/queries/go/indents.scm index e21fc8771..fe6e447eb 100644 --- a/queries/go/indents.scm +++ b/queries/go/indents.scm @@ -7,6 +7,7 @@ (literal_value) (expression_case) (communication_case) + (type_case) (default_case) (block) (call_expression) diff --git a/tests/indent/go/switch.go b/tests/indent/go/switch.go index 8ccacd564..9b6e74db2 100644 --- a/tests/indent/go/switch.go +++ b/tests/indent/go/switch.go @@ -11,4 +11,10 @@ func test(ch byte) { case 'l': return } + + var i interface{} + switch i.(type) { + case int: + return + } } From 88c490f00f837fbac95b2948bb7f0454a9cc4cf0 Mon Sep 17 00:00:00 2001 From: GitHub Date: Sat, 4 Mar 2023 06:39:17 +0000 Subject: [PATCH 0062/2704] Update parsers: hlsl, yuck --- lockfile.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lockfile.json b/lockfile.json index bf3d59baf..9e795a15f 100644 --- a/lockfile.json +++ b/lockfile.json @@ -195,7 +195,7 @@ "revision": "02fa3b79b3ff9a296066da6277adfc3f26cbc9e0" }, "hlsl": { - "revision": "18f2dcb5f65075457638658c4763672e826dcddf" + "revision": "306d48516a6b3dbb18a184692e8edffa8403018f" }, "hocon": { "revision": "c390f10519ae69fdb03b3e5764f5592fb6924bcc" @@ -504,7 +504,7 @@ "revision": "2c0e6be8dd4dcb961c345fa35c309ad4f5bd3502" }, "yuck": { - "revision": "0f96c1d3bbdd32ca92b4e706c3f1fc2cb0d26b3f" + "revision": "48af129ab5411cd6f7ae2b36f53c1192572fa030" }, "zig": { "revision": "1cd5f339b146b764f39b36bb7be98ca631a2e02a" From c553e6c5608ba54e210e9131bf9ba5e36ef18e57 Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Fri, 3 Mar 2023 06:32:24 -0500 Subject: [PATCH 0063/2704] fix(ecma): properly capture constants in const declarations --- queries/ecma/highlights.scm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/queries/ecma/highlights.scm b/queries/ecma/highlights.scm index cdae02ab2..97feae8f3 100644 --- a/queries/ecma/highlights.scm +++ b/queries/ecma/highlights.scm @@ -24,10 +24,15 @@ (#lua-match? @type "^[A-Z]")) ((identifier) @constant - (#lua-match? @constant "^[A-Z_][A-Z%d_]+$")) + (#lua-match? @constant "^_*[A-Z][A-Z%d_]*$")) ((shorthand_property_identifier) @constant - (#lua-match? @constant "^[A-Z_][A-Z%d_]+$")) + (#lua-match? @constant "^_*[A-Z][A-Z%d_]*$")) + +(lexical_declaration + "const" + . (variable_declarator + . name: (identifier) @constant)) ((identifier) @variable.builtin (#vim-match? @variable.builtin "^(arguments|module|console|window|document)$")) From d7cef15b01e04f8322900f4b0294be582d31ab9d Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Fri, 3 Mar 2023 20:04:08 -0500 Subject: [PATCH 0064/2704] feat(ecma): add tests for constants --- tests/query/highlights/ecma/const.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 tests/query/highlights/ecma/const.js diff --git a/tests/query/highlights/ecma/const.js b/tests/query/highlights/ecma/const.js new file mode 100644 index 000000000..2b778fd15 --- /dev/null +++ b/tests/query/highlights/ecma/const.js @@ -0,0 +1,13 @@ +_FOO = 4 +// <- @constant +__A__ = 2 +// <- @constant +_ = 2 +// <- @variable +A_B_C = 4 +// <- @constant +_1 = 1 +// <- @variable + +const A = 2 +// ^ @constant From 376d74006fd8fff91431639136416ffca4458bfd Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Sat, 4 Mar 2023 04:31:11 -0500 Subject: [PATCH 0065/2704] feat: add cue --- README.md | 1 + lockfile.json | 3 + lua/nvim-treesitter/parsers.lua | 8 ++ queries/cue/folds.scm | 5 + queries/cue/highlights.scm | 164 ++++++++++++++++++++++++++++++++ queries/cue/indents.scm | 21 ++++ queries/cue/injections.scm | 1 + queries/cue/locals.scm | 34 +++++++ 8 files changed, 237 insertions(+) create mode 100644 queries/cue/folds.scm create mode 100644 queries/cue/highlights.scm create mode 100644 queries/cue/indents.scm create mode 100644 queries/cue/injections.scm create mode 100644 queries/cue/locals.scm diff --git a/README.md b/README.md index f97bcd5bb..cb16f3c77 100644 --- a/README.md +++ b/README.md @@ -196,6 +196,7 @@ We are looking for maintainers to add more parsers and to write query files for - [x] [cpp](https://github.com/tree-sitter/tree-sitter-cpp) (maintained by @theHamsta) - [x] [css](https://github.com/tree-sitter/tree-sitter-css) (maintained by @TravonteD) - [x] [cuda](https://github.com/theHamsta/tree-sitter-cuda) (maintained by @theHamsta) +- [x] [cue](https://github.com/eonpatapon/tree-sitter-cue) (maintained by @amaanq) - [x] [d](https://github.com/CyberShadow/tree-sitter-d) (experimental, maintained by @nawordar) - [x] [dart](https://github.com/UserNobody14/tree-sitter-dart) (maintained by @akinsho) - [x] [devicetree](https://github.com/joelspadin/tree-sitter-devicetree) (maintained by @jedrzejboczar) diff --git a/lockfile.json b/lockfile.json index 9e795a15f..f1f630267 100644 --- a/lockfile.json +++ b/lockfile.json @@ -68,6 +68,9 @@ "cuda": { "revision": "91c3ca3e42326e0f7b83c82765940bbf7f91c847" }, + "cue": { + "revision": "4ffcda8c2bdfee1c2ba786cd503d0508ea92cca2" + }, "d": { "revision": "c2fbf21bd3aa45495fe13247e040ad5815250032" }, diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index 249a1b00a..179513d9b 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -271,6 +271,14 @@ list.cuda = { maintainers = { "@theHamsta" }, } +list.cue = { + install_info = { + url = "https://github.com/eonpatapon/tree-sitter-cue", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@amaanq" }, +} + list.d = { install_info = { url = "https://github.com/CyberShadow/tree-sitter-d", diff --git a/queries/cue/folds.scm b/queries/cue/folds.scm new file mode 100644 index 000000000..934b59e6f --- /dev/null +++ b/queries/cue/folds.scm @@ -0,0 +1,5 @@ +[ + (import_spec_list) + (field) + (string) +] @fold diff --git a/queries/cue/highlights.scm b/queries/cue/highlights.scm new file mode 100644 index 000000000..c1f27fb8f --- /dev/null +++ b/queries/cue/highlights.scm @@ -0,0 +1,164 @@ +; Includes + +[ + "package" + "import" +] @include + +; Namespaces + +(package_identifier) @namespace + +(import_spec ["." "_"] @punctuation.special) + +[ + (attr_path) + (package_path) +] @text.uri ;; In attributes + +; Attributes + +(attribute) @attribute + +; Conditionals + +"if" @conditional + +; Repeats + +[ + "for" +] @repeat + +(for_clause "_" @punctuation.special) + +; Keywords + +[ + "let" +] @keyword + +[ + "in" +] @keyword.operator + +; Operators + +[ + "+" + "-" + "*" + "/" + "|" + "&" + "||" + "&&" + "==" + "!=" + "<" + "<=" + ">" + ">=" + "=~" + "!~" + "!" + "=" +] @operator + +; Fields & Properties + +(field + (label + (identifier) @field)) + +(selector_expression + (_) + (identifier) @property) + +; Functions + +(call_expression + function: (identifier) @function.call) +(call_expression + function: (selector_expression + (_) + (identifier) @function.call)) +(call_expression + function: (builtin_function) @function.call) + +(builtin_function) @function.builtin + +; Variables + +(identifier) @variable + +; Types + +(primitive_type) @type.builtin + +((identifier) @type + (#match? @type "^(#|_#)")) + +[ + (slice_type) + (pointer_type) +] @type ;; In attributes + +; Punctuation + +[ + "," + ":" +] @punctuation.delimiter + +[ "{" "}" ] @punctuation.bracket + +[ "[" "]" ] @punctuation.bracket + +[ "(" ")" ] @punctuation.bracket + +[ "<" ">" ] @punctuation.bracket + +[ + (ellipsis) + "?" +] @punctuation.special + +; Literals + +(string) @string + +[ + (escape_char) + (escape_unicode) +] @string.escape + +(number) @number + +(float) @float + +(si_unit + (float) + (_) @symbol) + +(boolean) @boolean + +[ + (null) + (top) + (bottom) +] @constant.builtin + +; Interpolations + +(interpolation "\\(" @punctuation.special (_) ")" @punctuation.special) @none + +(interpolation "\\(" (identifier) @variable ")") + +; Commments + +(comment) @comment @spell + +; Errors + +(ERROR) @error diff --git a/queries/cue/indents.scm b/queries/cue/indents.scm new file mode 100644 index 000000000..731e69b79 --- /dev/null +++ b/queries/cue/indents.scm @@ -0,0 +1,21 @@ +[ + (import_spec_list) + (field) +] @indent + +[ + "}" + "]" + ")" +] @indent_end + +[ "{" "}" ] @branch + +[ "[" "]" ] @branch + +[ "(" ")" ] @branch + +[ + (ERROR) + (comment) +] @auto diff --git a/queries/cue/injections.scm b/queries/cue/injections.scm new file mode 100644 index 000000000..4bb7d675d --- /dev/null +++ b/queries/cue/injections.scm @@ -0,0 +1 @@ +(comment) @comment diff --git a/queries/cue/locals.scm b/queries/cue/locals.scm new file mode 100644 index 000000000..b99a4fca8 --- /dev/null +++ b/queries/cue/locals.scm @@ -0,0 +1,34 @@ +; Scopes + +[ + (source_file) + (field) + (for_clause) +] @scope + +; References + +(identifier) @reference + +; Definitions + +(import_spec + path: (string) @definition.import) + +(field + (label + (identifier) @definition.field)) + +(package_identifier) @definition.namespace + +(for_clause + (identifier) @definition.variable + (expression)) + +(for_clause + (identifier) + (identifier) @definition.variable + (expression)) + +(let_clause + (identifier) @definition.variable) From e3a1ae4c4eccf309eaa1880176de7307cd70748a Mon Sep 17 00:00:00 2001 From: Matthias Queitsch Date: Thu, 2 Mar 2023 23:18:10 +0100 Subject: [PATCH 0066/2704] highlights(sql): add missing keywords --- queries/sql/highlights.scm | 81 +++++++++++++++++++++++++++++--------- 1 file changed, 62 insertions(+), 19 deletions(-) diff --git a/queries/sql/highlights.scm b/queries/sql/highlights.scm index 274469989..4178f9727 100644 --- a/queries/sql/highlights.scm +++ b/queries/sql/highlights.scm @@ -2,13 +2,16 @@ name: (identifier) @function.call parameter: [(field)]? @parameter) -(keyword_gist) @function.call -(keyword_btree) @function.call -(keyword_hash) @function.call -(keyword_spgist) @function.call -(keyword_gin) @function.call -(keyword_brin) @function.call -(keyword_float) @function.call +[ + (keyword_gist) + (keyword_btree) + (keyword_hash) + (keyword_spgist) + (keyword_gin) + (keyword_brin) + (keyword_float) + (keyword_array) +] @function.call (count name: (keyword_count) @function.call @@ -33,7 +36,7 @@ parameter: [(literal)]?))) (literal) @string -(comment) @comment +(comment) @comment @spell (marginalia) @comment ((literal) @number @@ -53,7 +56,6 @@ (keyword_asc) (keyword_desc) (keyword_external) - (keyword_stored) (keyword_parquet) (keyword_csv) (keyword_rcfile) @@ -61,21 +63,27 @@ (keyword_orc) (keyword_avro) (keyword_jsonfile) + (keyword_sequencefile) (keyword_temp) - (keyword_cached) (keyword_uncached) (keyword_unlogged) (keyword_terminated) (keyword_escaped) - (keyword_partitioned) - (keyword_location) - (keyword_lines) (keyword_unsigned) (keyword_nulls) (keyword_last) (keyword_materialized) (keyword_temp) (keyword_temporary) + (keyword_delimited) + (keyword_replication) + (keyword_auto_increment) + (keyword_default) + (keyword_collate) + (keyword_concurrently) + (keyword_engine) + (keyword_character) + (keyword_concurrently) ] @attribute [ @@ -91,7 +99,6 @@ (keyword_where) (keyword_index) (keyword_join) - (keyword_on) (keyword_primary) (keyword_delete) (keyword_create) @@ -107,10 +114,9 @@ (keyword_outer) (keyword_inner) (keyword_order) + (keyword_partition) (keyword_group) - (keyword_by) (keyword_having) - (keyword_as) (keyword_limit) (keyword_offset) (keyword_table) @@ -121,8 +127,6 @@ (keyword_for) (keyword_if) (keyword_exists) - (keyword_auto_increment) - (keyword_default) (keyword_max) (keyword_min) (keyword_avg) @@ -139,7 +143,6 @@ (keyword_cascade) (keyword_between) (keyword_window) - (keyword_with) (keyword_no) (keyword_data) (keyword_type) @@ -160,18 +163,54 @@ (keyword_like) (keyword_similar) (keyword_over) + (keyword_change) + (keyword_modify) + (keyword_restrict) + (keyword_first) + (keyword_after) + (keyword_range) + (keyword_rows) + (keyword_groups) + (keyword_unbounded) + (keyword_preceding) + (keyword_following) + (keyword_exclude) + (keyword_current) + (keyword_ties) + (keyword_others) + (keyword_unique) + (keyword_preserve) + (keyword_zerofill) + (keyword_format) + (keyword_fields) + (keyword_row) + (keyword_sort) + (keyword_compute) + (keyword_stats) + (keyword_comment) + (keyword_partitioned) + (keyword_location) + (keyword_cached) + (keyword_lines) + (keyword_stored) ] @keyword +(keyword_with) @repeat + +(keyword_as) @label + [ (keyword_int) (keyword_null) (keyword_boolean) + (keyword_bit) (keyword_smallserial) (keyword_serial) (keyword_bigserial) (keyword_smallint) (keyword_bigint) (keyword_decimal) + (keyword_float) (keyword_numeric) (keyword_real) (double) @@ -199,6 +238,8 @@ (keyword_and) (keyword_or) (keyword_not) + (keyword_by) + (keyword_on) ] @keyword.operator [ @@ -214,6 +255,7 @@ "!=" ">=" ">" + "<>" ] @operator [ @@ -227,3 +269,4 @@ "." ] @punctuation.delimiter + From d382b4156326195725d0d8cd84fe8b60a39bb73b Mon Sep 17 00:00:00 2001 From: Matthias Queitsch Date: Fri, 3 Mar 2023 20:52:59 +0100 Subject: [PATCH 0067/2704] highlights(sql): added missing kwds, added `@attribute` and @`type.qualifier` kwds --- queries/sql/highlights.scm | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/queries/sql/highlights.scm b/queries/sql/highlights.scm index 4178f9727..a0e049082 100644 --- a/queries/sql/highlights.scm +++ b/queries/sql/highlights.scm @@ -11,6 +11,7 @@ (keyword_brin) (keyword_float) (keyword_array) + (keyword_group_concat) ] @function.call (count @@ -83,7 +84,10 @@ (keyword_concurrently) (keyword_engine) (keyword_character) - (keyword_concurrently) + (keyword_concurrently) + (keyword_preceding) + (keyword_following) + (keyword_first) ] @attribute [ @@ -116,6 +120,8 @@ (keyword_order) (keyword_partition) (keyword_group) + (keyword_with) + (keyword_as) (keyword_having) (keyword_limit) (keyword_offset) @@ -140,7 +146,6 @@ (keyword_end) (keyword_is) (keyword_using) - (keyword_cascade) (keyword_between) (keyword_window) (keyword_no) @@ -165,20 +170,14 @@ (keyword_over) (keyword_change) (keyword_modify) - (keyword_restrict) - (keyword_first) (keyword_after) (keyword_range) (keyword_rows) (keyword_groups) - (keyword_unbounded) - (keyword_preceding) - (keyword_following) (keyword_exclude) (keyword_current) (keyword_ties) (keyword_others) - (keyword_unique) (keyword_preserve) (keyword_zerofill) (keyword_format) @@ -195,9 +194,12 @@ (keyword_stored) ] @keyword -(keyword_with) @repeat - -(keyword_as) @label +[ + (keyword_restrict) + (keyword_unbounded) + (keyword_unique) + (keyword_cascade) +] @type.qualifier [ (keyword_int) @@ -231,6 +233,7 @@ (keyword_geography) (keyword_box2d) (keyword_box3d) + (keyword_interval) ] @type.builtin [ From d4e48be88d9822d98c9194f5cc2778c9953afb66 Mon Sep 17 00:00:00 2001 From: Matthias Queitsch Date: Sat, 4 Mar 2023 00:36:52 +0100 Subject: [PATCH 0068/2704] highlights(sql): keywords as `@storageclass` --- queries/sql/highlights.scm | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/queries/sql/highlights.scm b/queries/sql/highlights.scm index a0e049082..db413cc0e 100644 --- a/queries/sql/highlights.scm +++ b/queries/sql/highlights.scm @@ -56,26 +56,11 @@ [ (keyword_asc) (keyword_desc) - (keyword_external) - (keyword_parquet) - (keyword_csv) - (keyword_rcfile) - (keyword_textfile) - (keyword_orc) - (keyword_avro) - (keyword_jsonfile) - (keyword_sequencefile) - (keyword_temp) - (keyword_uncached) - (keyword_unlogged) (keyword_terminated) (keyword_escaped) (keyword_unsigned) (keyword_nulls) (keyword_last) - (keyword_materialized) - (keyword_temp) - (keyword_temporary) (keyword_delimited) (keyword_replication) (keyword_auto_increment) @@ -90,6 +75,22 @@ (keyword_first) ] @attribute +[ + (keyword_materialized) + (keyword_temp) + (keyword_temporary) + (keyword_unlogged) + (keyword_external) + (keyword_parquet) + (keyword_csv) + (keyword_rcfile) + (keyword_textfile) + (keyword_orc) + (keyword_avro) + (keyword_jsonfile) + (keyword_sequencefile) +] @storageclass + [ (keyword_case) (keyword_when) @@ -190,8 +191,12 @@ (keyword_partitioned) (keyword_location) (keyword_cached) + (keyword_uncached) (keyword_lines) (keyword_stored) + (keyword_location) + (keyword_partitioned) + (keyword_cached) ] @keyword [ From c9d7918901693041179ef569eb9b7f3f88a89e52 Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Fri, 3 Mar 2023 05:33:20 -0500 Subject: [PATCH 0069/2704] feat: add luap --- README.md | 1 + lockfile.json | 3 +++ lua/nvim-treesitter/parsers.lua | 9 +++++++++ queries/luap/highlights.scm | 35 +++++++++++++++++++++++++++++++++ 4 files changed, 48 insertions(+) create mode 100644 queries/luap/highlights.scm diff --git a/README.md b/README.md index cb16f3c77..d11ffd833 100644 --- a/README.md +++ b/README.md @@ -261,6 +261,7 @@ We are looking for maintainers to add more parsers and to write query files for - [x] [ledger](https://github.com/cbarrete/tree-sitter-ledger) (maintained by @cbarrete) - [x] [llvm](https://github.com/benwilliamgraham/tree-sitter-llvm) (maintained by @benwilliamgraham) - [x] [lua](https://github.com/MunifTanjim/tree-sitter-lua) (maintained by @muniftanjim) +- [x] [lua patterns](https://github.com/vhyrro/tree-sitter-luap) (maintained by @amaanq) - [x] [m68k](https://github.com/grahambates/tree-sitter-m68k) (maintained by @grahambates) - [x] [make](https://github.com/alemuller/tree-sitter-make) (maintained by @lewis6991) - [x] [markdown](https://github.com/MDeiml/tree-sitter-markdown) (experimental, maintained by @MDeiml) diff --git a/lockfile.json b/lockfile.json index f1f630267..ddef7a391 100644 --- a/lockfile.json +++ b/lockfile.json @@ -263,6 +263,9 @@ "lua": { "revision": "0fc89962b7ff5c7d676b8592c1cbce1ceaa806fd" }, + "luap": { + "revision": "ebc6739bf8900a0191a386ef53371fc556c662a8" + }, "m68k": { "revision": "d097b123f19c6eaba2bf181c05420d88b9fc489d" }, diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index 179513d9b..4c873df81 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -855,6 +855,15 @@ list.lua = { maintainers = { "@muniftanjim" }, } +list.luap = { + install_info = { + url = "https://github.com/amaanq/tree-sitter-luap", + files = { "src/parser.c" }, + readme_name = "lua patterns", + }, + maintainers = { "@amaanq" }, +} + list.m68k = { install_info = { url = "https://github.com/grahambates/tree-sitter-m68k", diff --git a/queries/luap/highlights.scm b/queries/luap/highlights.scm new file mode 100644 index 000000000..62d2b3182 --- /dev/null +++ b/queries/luap/highlights.scm @@ -0,0 +1,35 @@ +"." @character + +[ + (anchor_begin) + (anchor_end) +] @string.escape + +[ + "[" "]" + "(" ")" +] @punctuation.bracket + +[ + (zero_or_more) + (shortest_zero_or_more) + (one_or_more) + (zero_or_one) +] @operator + +(range + from: (character) @constant + "-" @punctuation.delimiter + to: (character) @constant) + +(set + (character) @constant) + +(class) @keyword + +(negated_set + "^" @operator + (character) @constant) + +(balanced_match + (character) @parameter) From 25f99a270ac94afd7a4adc8c2055d33ec60125ab Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Fri, 3 Mar 2023 05:35:20 -0500 Subject: [PATCH 0070/2704] feat(lua): add luap injections --- queries/lua/injections.scm | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/queries/lua/injections.scm b/queries/lua/injections.scm index c11e3fb29..14714573a 100644 --- a/queries/lua/injections.scm +++ b/queries/lua/injections.scm @@ -19,4 +19,30 @@ ;; highlight string as query if starts with `;; query` ((string ("string_content") @query) (#lua-match? @query "^%s*;+%s?query")) +; string.match("123", "%d+") +(function_call + (dot_index_expression + field: (identifier) @_method + (#any-of? @_method "find" "match")) + arguments: (arguments (_) . (string content: _ @luap))) + +(function_call + (dot_index_expression + field: (identifier) @_method + (#eq? @_method "gmatch" "gsub")) + arguments: (arguments (_) (string content: _ @luap))) + +; ("123"):match("%d+") +(function_call + (method_index_expression + method: (identifier) @_method + (#any-of? @_method "find" "match")) + arguments: (arguments . (string content: _ @luap))) + +(function_call + (method_index_expression + method: (identifier) @_method + (#any-of? @_method "gmatch" "gsub")) + arguments: (arguments (string content: _ @luap))) + (comment) @comment From 4beba61ddec3e2d470796b1822af21f0cc6008d3 Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Fri, 3 Mar 2023 05:36:23 -0500 Subject: [PATCH 0071/2704] feat(query): differentiate lua-match strings by using luap injections and fix offset matches --- queries/query/injections.scm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/queries/query/injections.scm b/queries/query/injections.scm index 95ce2978f..c4b877d0b 100644 --- a/queries/query/injections.scm +++ b/queries/query/injections.scm @@ -1,6 +1,13 @@ ((predicate name: (identifier) @_name parameters: (parameters (string) @regex)) - (#match? @_name "^#?(not-)?(match|vim-match|lua-match)$")) + (#match? @_name "^#?(not-)?(match|vim-match)$") + (#offset! @regex 0 1 0 -1)) + +((predicate + name: (identifier) @_name + parameters: (parameters (string) @luap)) + (#match? @_name "^#?(not-)?lua-match$") + (#offset! @luap 0 1 0 -1)) (comment) @comment From 00b403f190949275c809d83771a1927d2376c694 Mon Sep 17 00:00:00 2001 From: Github Actions Date: Sat, 4 Mar 2023 16:32:48 +0000 Subject: [PATCH 0072/2704] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d11ffd833..e6d00fbb9 100644 --- a/README.md +++ b/README.md @@ -261,7 +261,7 @@ We are looking for maintainers to add more parsers and to write query files for - [x] [ledger](https://github.com/cbarrete/tree-sitter-ledger) (maintained by @cbarrete) - [x] [llvm](https://github.com/benwilliamgraham/tree-sitter-llvm) (maintained by @benwilliamgraham) - [x] [lua](https://github.com/MunifTanjim/tree-sitter-lua) (maintained by @muniftanjim) -- [x] [lua patterns](https://github.com/vhyrro/tree-sitter-luap) (maintained by @amaanq) +- [x] [luap](https://github.com/amaanq/tree-sitter-luap) (maintained by @amaanq) - [x] [m68k](https://github.com/grahambates/tree-sitter-m68k) (maintained by @grahambates) - [x] [make](https://github.com/alemuller/tree-sitter-make) (maintained by @lewis6991) - [x] [markdown](https://github.com/MDeiml/tree-sitter-markdown) (experimental, maintained by @MDeiml) From 1ceaceb9dea9b0bac2162345ee11e47a44e07a70 Mon Sep 17 00:00:00 2001 From: ObserverOfTime Date: Sat, 4 Mar 2023 20:25:03 +0200 Subject: [PATCH 0073/2704] docs: fix readme names --- README.md | 6 +++--- lua/nvim-treesitter/parsers.lua | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e6d00fbb9..6371f7c10 100644 --- a/README.md +++ b/README.md @@ -261,11 +261,11 @@ We are looking for maintainers to add more parsers and to write query files for - [x] [ledger](https://github.com/cbarrete/tree-sitter-ledger) (maintained by @cbarrete) - [x] [llvm](https://github.com/benwilliamgraham/tree-sitter-llvm) (maintained by @benwilliamgraham) - [x] [lua](https://github.com/MunifTanjim/tree-sitter-lua) (maintained by @muniftanjim) -- [x] [luap](https://github.com/amaanq/tree-sitter-luap) (maintained by @amaanq) +- [x] [lua patterns](https://github.com/amaanq/tree-sitter-luap) (maintained by @amaanq) - [x] [m68k](https://github.com/grahambates/tree-sitter-m68k) (maintained by @grahambates) - [x] [make](https://github.com/alemuller/tree-sitter-make) (maintained by @lewis6991) -- [x] [markdown](https://github.com/MDeiml/tree-sitter-markdown) (experimental, maintained by @MDeiml) -- [x] [markdown_inline](https://github.com/MDeiml/tree-sitter-markdown) (experimental, maintained by @MDeiml) +- [x] [markdown (basic highlighting)](https://github.com/MDeiml/tree-sitter-markdown) (experimental, maintained by @MDeiml) +- [x] [markdown_inline (needed for full highlighting)](https://github.com/MDeiml/tree-sitter-markdown) (experimental, maintained by @MDeiml) - [x] [matlab](https://github.com/mstanciu552/tree-sitter-matlab) (maintained by @amaanq) - [x] [menhir](https://github.com/Kerl13/tree-sitter-menhir) (maintained by @Kerl13) - [ ] [mermaid](https://github.com/monaqa/tree-sitter-mermaid) (experimental) diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index 4c873df81..1185d02d3 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -859,9 +859,9 @@ list.luap = { install_info = { url = "https://github.com/amaanq/tree-sitter-luap", files = { "src/parser.c" }, - readme_name = "lua patterns", }, maintainers = { "@amaanq" }, + readme_name = "lua patterns", } list.m68k = { @@ -888,9 +888,9 @@ list.markdown = { location = "tree-sitter-markdown", files = { "src/parser.c", "src/scanner.c" }, branch = "split_parser", - readme_name = "markdown (basic highlighting)", }, maintainers = { "@MDeiml" }, + readme_name = "markdown (basic highlighting)", experimental = true, } @@ -900,9 +900,9 @@ list.markdown_inline = { location = "tree-sitter-markdown-inline", files = { "src/parser.c", "src/scanner.c" }, branch = "split_parser", - readme_name = "markdown_inline (needs to be installed for full markdown highlighting)", }, maintainers = { "@MDeiml" }, + readme_name = "markdown_inline (needed for full highlighting)", experimental = true, } From 14fb59e125d7db4378e2345f36c9d2735528b899 Mon Sep 17 00:00:00 2001 From: GitHub Date: Sun, 5 Mar 2023 06:38:51 +0000 Subject: [PATCH 0074/2704] Update parsers: c_sharp, luap, perl --- lockfile.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lockfile.json b/lockfile.json index ddef7a391..a231b4d53 100644 --- a/lockfile.json +++ b/lockfile.json @@ -33,7 +33,7 @@ "revision": "f35789006ccbe5be8db21d1a2dd4cc0b5a1286f2" }, "c_sharp": { - "revision": "fc6be5ae61c8788e0c028e757f132d67bfc538f5" + "revision": "fcacbeb4af6bcdcfb4527978a997bb03f4fe086d" }, "capnp": { "revision": "fc6e2addf103861b9b3dffb82c543eb6b71061aa" @@ -264,7 +264,7 @@ "revision": "0fc89962b7ff5c7d676b8592c1cbce1ceaa806fd" }, "luap": { - "revision": "ebc6739bf8900a0191a386ef53371fc556c662a8" + "revision": "bfb38d254f380362e26b5c559a4086ba6e92ba77" }, "m68k": { "revision": "d097b123f19c6eaba2bf181c05420d88b9fc489d" @@ -321,7 +321,7 @@ "revision": "20239395eacdc2e0923a7e5683ad3605aee7b716" }, "perl": { - "revision": "c43bae0090cfcfc62d9904312599ded1b645a66d" + "revision": "ff1f0ac0f1c678a23f68d0140e75a0da8e11b7b5" }, "php": { "revision": "f860e598194f4a71747f91789bf536b393ad4a56" From 3731cf1c0c70287568d26f190849c68a46c21297 Mon Sep 17 00:00:00 2001 From: GitHub Date: Sun, 5 Mar 2023 11:24:18 +0000 Subject: [PATCH 0075/2704] Update parsers: zig --- lockfile.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lockfile.json b/lockfile.json index a231b4d53..5b60f8f54 100644 --- a/lockfile.json +++ b/lockfile.json @@ -513,6 +513,6 @@ "revision": "48af129ab5411cd6f7ae2b36f53c1192572fa030" }, "zig": { - "revision": "1cd5f339b146b764f39b36bb7be98ca631a2e02a" + "revision": "f3bc9ffe9ca10f52dee01999b5b6ce9a4074b0ac" } } From d11dd552dbde181cd49652188521f4b5f6cad2f8 Mon Sep 17 00:00:00 2001 From: Pham Huy Hoang Date: Fri, 3 Mar 2023 09:09:52 +0700 Subject: [PATCH 0076/2704] injections(html): fix faulty css/js injections Group queries to reduce duplicate injection tree use only regex --- queries/html_tags/injections.scm | 34 ++++--------------- .../injections/html/test-html-injections.html | 4 +++ .../injections/vue/test-vue-injections.vue | 6 ++++ 3 files changed, 17 insertions(+), 27 deletions(-) diff --git a/queries/html_tags/injections.scm b/queries/html_tags/injections.scm index c29619281..5f0719c64 100644 --- a/queries/html_tags/injections.scm +++ b/queries/html_tags/injections.scm @@ -1,22 +1,12 @@ ; -( - (style_element - (start_tag - (tag_name) .) - (raw_text) @css) -) - ; ; Add "lang" to predicate check so that vue/svelte can inherit this ; without having this element being captured twice ( (style_element - (start_tag - (attribute - (attribute_name) @_no_set_type)) - (raw_text) @css) - (#not-any-of? @_no_set_type "type" "lang") -) + (start_tag) @_no_type_lang + (#not-match? @_no_type_lang "\\s(lang|type)\\s*\\=") + (raw_text) @css)) ( (style_element @@ -30,22 +20,12 @@ ) ; -( - (script_element - (start_tag - (tag_name) .) - (raw_text) @javascript) -) - ; ( (script_element - (start_tag - (attribute - (attribute_name) @_no_set_type)) - (raw_text) @javascript) - (#not-any-of? @_no_set_type "type" "lang") -) + (start_tag) @_no_type_lang + (#not-match? @_no_type_lang "\\s(lang|type)\\s*\\=") + (raw_text) @javascript)) ( (script_element @@ -55,7 +35,7 @@ (quoted_attribute_value (attribute_value) @_javascript))) (raw_text) @javascript) (#eq? @_type "type") - (#eq? @_javascript "text/javascript") + (#any-of? @_javascript "text/javascript" "module") ) ((attribute diff --git a/tests/query/injections/html/test-html-injections.html b/tests/query/injections/html/test-html-injections.html index 4449923c6..348d901ca 100644 --- a/tests/query/injections/html/test-html-injections.html +++ b/tests/query/injections/html/test-html-injections.html @@ -19,6 +19,10 @@ + + + +
Test div to test css injections for style attributes diff --git a/tests/query/injections/vue/test-vue-injections.vue b/tests/query/injections/vue/test-vue-injections.vue index 4cb4ae215..b0df16071 100644 --- a/tests/query/injections/vue/test-vue-injections.vue +++ b/tests/query/injections/vue/test-vue-injections.vue @@ -17,6 +17,9 @@ + + + @@ -26,3 +29,6 @@ + + + From 51030378eb12160cbf802b68aaf56b3116aa22de Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Wed, 1 Mar 2023 12:25:39 -0500 Subject: [PATCH 0077/2704] docs: add `@string.documentation` --- CONTRIBUTING.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f954bff1d..c972da7e0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -108,17 +108,18 @@ effect on highlighting. We will work on improving highlighting in the near futur #### Literals ```scheme -@string ; string literals -@string.regex ; regular expressions -@string.escape ; escape sequences -@string.special ; other special strings (e.g. dates) +@string ; string literals +@string.documentation ; string documenting code (e.g. Python docstrings) +@string.regex ; regular expressions +@string.escape ; escape sequences +@string.special ; other special strings (e.g. dates) -@character ; character literals -@character.special ; special characters (e.g. wildcards) +@character ; character literals +@character.special ; special characters (e.g. wildcards) -@boolean ; boolean literals -@number ; numeric literals -@float ; floating-point number literals +@boolean ; boolean literals +@number ; numeric literals +@float ; floating-point number literals ``` #### Functions From 95bcd6a8fa1baa0824d44b697ba05bcc0b97bd34 Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Wed, 1 Mar 2023 12:26:26 -0500 Subject: [PATCH 0078/2704] feat: add `@string.documentation` where applicable --- queries/graphql/highlights.scm | 4 ++-- queries/julia/highlights.scm | 12 +++++++++++- queries/python/highlights.scm | 13 ++++++++++++- queries/starlark/highlights.scm | 8 +++++++- 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/queries/graphql/highlights.scm b/queries/graphql/highlights.scm index 3a9d47dad..48f27f983 100644 --- a/queries/graphql/highlights.scm +++ b/queries/graphql/highlights.scm @@ -111,9 +111,9 @@ ;--------- (description - (string_value) @comment) + (string_value) @string.documentation @spell) -(comment) @comment +(comment) @comment @spell (directive_location (executable_directive_location) @type.builtin) diff --git a/queries/julia/highlights.scm b/queries/julia/highlights.scm index bf51076c7..6044e66de 100644 --- a/queries/julia/highlights.scm +++ b/queries/julia/highlights.scm @@ -226,8 +226,18 @@ (prefixed_command_literal prefix: (identifier) @function.macro) @string.special +((string_literal) @string.documentation + . [ + (module_definition) + (abstract_definition) + (struct_definition) + (function_definition) + (assignment) + (const_declaration) + ]) + [ (line_comment) (block_comment) -] @comment +] @comment @spell diff --git a/queries/python/highlights.scm b/queries/python/highlights.scm index fe66d7ca3..d25448000 100644 --- a/queries/python/highlights.scm +++ b/queries/python/highlights.scm @@ -176,7 +176,18 @@ (escape_sequence) @string.escape ; doc-strings -(expression_statement (string) @spell) + +(module . (expression_statement (string) @string.documentation @spell)) + +(class_definition + body: + (block + . (expression_statement (string) @string.documentation @spell))) + +(function_definition + body: + (block + . (expression_statement (string) @string.documentation @spell))) ; Tokens diff --git a/queries/starlark/highlights.scm b/queries/starlark/highlights.scm index a92832d68..ab9bfd68d 100644 --- a/queries/starlark/highlights.scm +++ b/queries/starlark/highlights.scm @@ -158,7 +158,13 @@ ] @string.escape ; doc-strings -(expression_statement (string) @spell) + +(module . (expression_statement (string) @string.documentation @spell)) + +(function_definition + body: + (block + . (expression_statement (string) @string.documentation @spell))) ; Tokens From 3a82b58745c668eb9a456eb061455b1ef497710e Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Thu, 2 Mar 2023 08:06:23 -0500 Subject: [PATCH 0079/2704] docs: add `@comment.documentation` --- CONTRIBUTING.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c972da7e0..cea14ac53 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -89,12 +89,13 @@ effect on highlighting. We will work on improving highlighting in the near futur #### Misc ```scheme -@comment ; line and block comments -@error ; syntax/parser errors -@none ; completely disable the highlight -@preproc ; various preprocessor directives & shebangs -@define ; preprocessor definition directives -@operator ; symbolic operators (e.g. `+` / `*`) +@comment ; line and block comments +@comment.documentation ; comments documenting code +@error ; syntax/parser errors +@none ; completely disable the highlight +@preproc ; various preprocessor directives & shebangs +@define ; preprocessor definition directives +@operator ; symbolic operators (e.g. `+` / `*`) ``` #### Punctuation From 5a87bc98dabd0d38152a6fa774005f7ecbd40f1b Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Thu, 2 Mar 2023 08:06:35 -0500 Subject: [PATCH 0080/2704] feat: add `@comment.documentation` where applicable --- queries/ada/highlights.scm | 26 +++++++++++++++++----- queries/c/highlights.scm | 3 +++ queries/c_sharp/highlights.scm | 8 +++++++ queries/d/highlights.scm | 13 ++++++++++- queries/dart/highlights.scm | 4 ++-- queries/ecma/highlights.scm | 7 +++--- queries/elixir/highlights.scm | 20 ++++++++--------- queries/elm/highlights.scm | 5 ++++- queries/erlang/highlights.scm | 6 ++++-- queries/fortran/highlights.scm | 3 +++ queries/gleam/highlights.scm | 7 ++++-- queries/go/highlights.scm | 38 +++++++++++++++++++++++++++------ queries/hack/highlights.scm | 5 ++++- queries/java/highlights.scm | 9 ++++++++ queries/kotlin/highlights.scm | 7 +++--- queries/lua/highlights.scm | 6 ++++++ queries/pascal/highlights.scm | 31 ++++++++++++++++++++++++++- queries/prisma/highlights.scm | 7 +++--- queries/proto/highlights.scm | 7 ++++-- queries/ql/highlights.scm | 5 +++-- queries/ruby/highlights.scm | 23 +++++++++++++++++--- queries/rust/highlights.scm | 12 +++++++++++ queries/scala/highlights.scm | 3 +++ queries/smali/highlights.scm | 7 ++++++ queries/smithy/highlights.scm | 7 +++--- queries/solidity/highlights.scm | 8 +++++++ queries/swift/highlights.scm | 9 ++++++++ queries/teal/highlights.scm | 6 +++++- queries/thrift/highlights.scm | 8 +++++++ queries/v/highlights.scm | 5 ++++- queries/vala/highlights.scm | 4 +++- queries/zig/highlights.scm | 5 +++-- 32 files changed, 256 insertions(+), 58 deletions(-) diff --git a/queries/ada/highlights.scm b/queries/ada/highlights.scm index 884203791..bcd041d5a 100644 --- a/queries/ada/highlights.scm +++ b/queries/ada/highlights.scm @@ -94,11 +94,9 @@ [ "exception" "raise" -] @exception -(comment) @comment -(comment) @spell ;; spell-check comments -(string_literal) @string -(string_literal) @spell ;; spell-check strings +] @exception +(comment) @comment @spell +(string_literal) @string @spell (character_literal) @string (numeric_literal) @number @@ -173,6 +171,24 @@ ; ] @function.spec ;) +((comment) @comment.documentation + . [ + (entry_declaration) + (subprogram_declaration) + (parameter_specification) + ]) + +(compilation_unit + . (comment) @comment.documentation) + +(component_list + (component_declaration) + . (comment) @comment.documentation) + +(enumeration_type_definition + (identifier) + . (comment) @comment.documentation) + ;; Highlight errors in red. This is not very useful in practice, as text will ;; be highlighted as user types, and the error could be elsewhere in the code. ;; This also requires defining :hi @error guifg=Red for instance. diff --git a/queries/c/highlights.scm b/queries/c/highlights.scm index 661f71b53..f607d3b8c 100644 --- a/queries/c/highlights.scm +++ b/queries/c/highlights.scm @@ -176,6 +176,9 @@ (comment) @comment @spell +((comment) @comment.documentation + (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$")) + ;; Parameters (parameter_declaration declarator: (identifier) @parameter) diff --git a/queries/c_sharp/highlights.scm b/queries/c_sharp/highlights.scm index c2bac3c1d..993609485 100644 --- a/queries/c_sharp/highlights.scm +++ b/queries/c_sharp/highlights.scm @@ -75,6 +75,14 @@ (comment) @comment @spell +((comment) @comment.documentation + (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$")) + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^///[^/]")) +((comment) @comment.documentation + (#lua-match? @comment.documentation "^///$")) + (using_directive (identifier) @type) diff --git a/queries/d/highlights.scm b/queries/d/highlights.scm index 8bec1ca10..229a9bf55 100644 --- a/queries/d/highlights.scm +++ b/queries/d/highlights.scm @@ -4,7 +4,18 @@ (line_comment) (block_comment) (nesting_block_comment) -] @comment +] @comment @spell + +((line_comment) @comment.documentation + (#lua-match? @comment.documentation "^///[^/]")) +((line_comment) @comment.documentation + (#lua-match? @comment.documentation "^///$")) + +((block_comment) @comment.documentation + (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$")) + +((nesting_block_comment) @comment.documentation + (#lua-match? @comment.documentation "^/[+][+][^+].*[+]/$")) [ "(" ")" diff --git a/queries/dart/highlights.scm b/queries/dart/highlights.scm index 154a92b3a..e34467f65 100644 --- a/queries/dart/highlights.scm +++ b/queries/dart/highlights.scm @@ -155,8 +155,8 @@ (false) @boolean (null_literal) @constant.builtin -(documentation_comment) @comment -(comment) @comment +(comment) @comment @spell +(documentation_comment) @comment.documentation @spell ; Keywords ; -------------------- diff --git a/queries/ecma/highlights.scm b/queries/ecma/highlights.scm index 97feae8f3..82a0b99ab 100644 --- a/queries/ecma/highlights.scm +++ b/queries/ecma/highlights.scm @@ -123,12 +123,13 @@ (undefined) ] @constant.builtin -(comment) @comment +(comment) @comment @spell + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$")) (hash_bang_line) @preproc -(comment) @spell - (string) @string @spell (template_string) @string (escape_sequence) @string.escape diff --git a/queries/elixir/highlights.scm b/queries/elixir/highlights.scm index d87afcf1b..3223fa683 100644 --- a/queries/elixir/highlights.scm +++ b/queries/elixir/highlights.scm @@ -29,12 +29,10 @@ ((identifier) @comment (#match? @comment "^_")) ; Comments -(comment) @comment -(comment) @spell +(comment) @comment @spell ; Strings -(string) @string -(string) @spell +(string) @string @spell ; Modules (alias) @type @@ -214,15 +212,15 @@ (unary_operator operator: "@" operand: (call - target: ((identifier) @_identifier (#any-of? @_identifier "moduledoc" "typedoc" "shortdoc" "doc")) @comment + target: ((identifier) @_identifier (#any-of? @_identifier "moduledoc" "typedoc" "shortdoc" "doc")) @comment.documentation (arguments [ (string) (boolean) (charlist) (sigil - "~" @comment - ((sigil_name) @comment) - quoted_start: _ @comment - (quoted_content) @comment - quoted_end: _ @comment) - ] @comment))) @comment + "~" @comment.documentation + ((sigil_name) @comment.documentation) + quoted_start: _ @comment.documentation + (quoted_content) @comment.documentation + quoted_end: _ @comment.documentation) + ] @comment.documentation))) @comment.documentation diff --git a/queries/elm/highlights.scm b/queries/elm/highlights.scm index 4d0f6f447..fbd3a4c3f 100644 --- a/queries/elm/highlights.scm +++ b/queries/elm/highlights.scm @@ -1,7 +1,10 @@ [ (line_comment) (block_comment) -] @comment +] @comment @spell + +((block_comment) @comment.documentation + (#lua-match? @comment.documentation "^{[-]|[^|]")) ; Keywords diff --git a/queries/erlang/highlights.scm b/queries/erlang/highlights.scm index fba44359f..63e6ea214 100644 --- a/queries/erlang/highlights.scm +++ b/queries/erlang/highlights.scm @@ -5,7 +5,10 @@ (integer) @number (float) @float -(comment) @comment +(comment) @comment @spell + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^[%%][%%]")) ;; keyword [ @@ -104,7 +107,6 @@ (type_alias name: _ @type) @type.definition (spec) @type.definition -(comment) @comment [(string) (binary)] @string ;;; expr_function_call diff --git a/queries/fortran/highlights.scm b/queries/fortran/highlights.scm index 4604e9a92..a6b55413b 100644 --- a/queries/fortran/highlights.scm +++ b/queries/fortran/highlights.scm @@ -324,6 +324,9 @@ (comment) @comment @spell +((comment) @comment.documentation + (#lua-match? @comment.documentation "^!>")) + ; Errors (ERROR) @error diff --git a/queries/gleam/highlights.scm b/queries/gleam/highlights.scm index 0e2712879..00cabd171 100644 --- a/queries/gleam/highlights.scm +++ b/queries/gleam/highlights.scm @@ -82,11 +82,14 @@ (identifier) @variable ; Comments +[ + (comment) +] @comment @spell + [ (module_comment) (statement_comment) - (comment) -] @comment +] @comment.documentation @spell ; Unused Identifiers [ diff --git a/queries/go/highlights.scm b/queries/go/highlights.scm index be72804b6..ce4ae89b6 100644 --- a/queries/go/highlights.scm +++ b/queries/go/highlights.scm @@ -196,20 +196,46 @@ (float_literal) @float (imaginary_literal) @number -(true) @boolean -(false) @boolean +[ + (true) + (false) +] @boolean + (nil) @constant.builtin (keyed_element . (literal_element (identifier) @field)) (field_declaration name: (field_identifier) @field) +; Comments + (comment) @comment @spell +;; Doc Comments + +(source_file . (comment)+ @comment.documentation) + +(source_file + (comment)+ @comment.documentation + . (const_declaration)) + +(source_file + (comment)+ @comment.documentation + . (function_declaration)) + +(source_file + (comment)+ @comment.documentation + . (type_declaration)) + +(source_file + (comment)+ @comment.documentation + . (var_declaration)) + +; Errors + (ERROR) @error +; Spell + ((interpreted_string_literal) @spell - (#not-has-parent? @spell - import_spec - ) -) + (#not-has-parent? @spell import_spec)) diff --git a/queries/hack/highlights.scm b/queries/hack/highlights.scm index ffb365c87..a75b166ca 100644 --- a/queries/hack/highlights.scm +++ b/queries/hack/highlights.scm @@ -12,7 +12,10 @@ [ (comment) (heredoc) -] @comment +] @comment @spell + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$")) "function" @keyword.function diff --git a/queries/java/highlights.scm b/queries/java/highlights.scm index 717a13bad..c97242295 100644 --- a/queries/java/highlights.scm +++ b/queries/java/highlights.scm @@ -279,3 +279,12 @@ (line_comment) (block_comment) ] @comment @spell + +((block_comment) @comment.documentation + (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$")) + +((line_comment) @comment.documentation + (#lua-match? @comment.documentation "^///[^/]")) + +((line_comment) @comment.documentation + (#lua-match? @comment.documentation "^///$")) diff --git a/queries/kotlin/highlights.scm b/queries/kotlin/highlights.scm index caf62f1f0..679cc0ad6 100644 --- a/queries/kotlin/highlights.scm +++ b/queries/kotlin/highlights.scm @@ -217,12 +217,13 @@ ;;; Literals -(comment) @comment +(comment) @comment @spell + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$")) (shebang_line) @preproc -(comment) @spell - (real_literal) @float [ (integer_literal) diff --git a/queries/lua/highlights.scm b/queries/lua/highlights.scm index 1c17d823b..fa2eff68d 100644 --- a/queries/lua/highlights.scm +++ b/queries/lua/highlights.scm @@ -187,6 +187,12 @@ (comment) @comment @spell +((comment) @comment.documentation + (#lua-match? @comment.documentation "^[-][-][-]")) + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^[-][-](%s?)@")) + (hash_bang_line) @preproc (number) @number diff --git a/queries/pascal/highlights.scm b/queries/pascal/highlights.scm index 3a1c484e0..e11e0eaa2 100644 --- a/queries/pascal/highlights.scm +++ b/queries/pascal/highlights.scm @@ -248,7 +248,36 @@ ; -- Comments -(comment) @comment +(comment) @comment @spell + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^///[^/]")) +((comment) @comment.documentation + (#lua-match? @comment.documentation "^///$")) + +((comment) @comment.documentation + . [(unit) (declProc)]) + +(declTypes + (comment) @comment.documentation + . (declType)) + +(declSection + (comment) @comment.documentation + . [(declField) (declProc)]) + +(declEnum + (comment) @comment.documentation + . (declEnumValue)) + +(declConsts + (comment) @comment.documentation + . (declConst)) + +(declVars + (comment) @comment.documentation + . (declVar)) + (pp) @preproc ; -- Type declaration diff --git a/queries/prisma/highlights.scm b/queries/prisma/highlights.scm index e3a025d98..59ee2881c 100644 --- a/queries/prisma/highlights.scm +++ b/queries/prisma/highlights.scm @@ -8,10 +8,9 @@ "type" ] @keyword -[ - (comment) - (developer_comment) -] @comment +(comment) @comment @spell + +(developer_comment) @comment.documentation @spell [ (attribute) diff --git a/queries/proto/highlights.scm b/queries/proto/highlights.scm index 48c18906c..a6f47da93 100644 --- a/queries/proto/highlights.scm +++ b/queries/proto/highlights.scm @@ -42,7 +42,10 @@ (false) ] @boolean -(comment) @comment +(comment) @comment @spell + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$")) [ "(" @@ -53,7 +56,7 @@ "}" "<" ">" -] @punctuation.bracket +] @punctuation.bracket [ ";" diff --git a/queries/ql/highlights.scm b/queries/ql/highlights.scm index 009920a82..dcc702263 100644 --- a/queries/ql/highlights.scm +++ b/queries/ql/highlights.scm @@ -130,5 +130,6 @@ [ (line_comment) (block_comment) - (qldoc) -] @comment +] @comment @spell + +(qldoc) @comment.documentation diff --git a/queries/ruby/highlights.scm b/queries/ruby/highlights.scm index c350e5ad1..9488297b4 100644 --- a/queries/ruby/highlights.scm +++ b/queries/ruby/highlights.scm @@ -173,13 +173,30 @@ (float) @float [ - (nil) (true) (false) ] @boolean -(comment) @comment -(comment) @spell +(nil) @constant.builtin + +(comment) @comment @spell + +(program + (comment)+ @comment.documentation + (class)) + +(module + (comment)+ @comment.documentation + (body_statement (class))) + +(class + (comment)+ @comment.documentation + (body_statement (method))) + +(body_statement + (comment)+ @comment.documentation + (method)) + (string_content) @spell ; Operators diff --git a/queries/rust/highlights.scm b/queries/rust/highlights.scm index c24a278f6..1a9330a70 100644 --- a/queries/rust/highlights.scm +++ b/queries/rust/highlights.scm @@ -148,6 +148,18 @@ (block_comment) ] @comment @spell +((line_comment) @comment.documentation + (#lua-match? @comment.documentation "^///[^/]")) +((line_comment) @comment.documentation + (#lua-match? @comment.documentation "^///$")) +((line_comment) @comment.documentation + (#lua-match? @comment.documentation "^//!")) + +((block_comment) @comment.documentation + (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$")) +((block_comment) @comment.documentation + (#lua-match? @comment.documentation "^/[*][!]")) + (boolean_literal) @boolean (integer_literal) @number (float_literal) @float diff --git a/queries/scala/highlights.scm b/queries/scala/highlights.scm index f600dc185..6220cbfe1 100644 --- a/queries/scala/highlights.scm +++ b/queries/scala/highlights.scm @@ -234,6 +234,9 @@ (comment) @comment @spell +((comment) @comment.documentation + (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$")) + ;; `case` is a conditional keyword in case_block (case_block diff --git a/queries/smali/highlights.scm b/queries/smali/highlights.scm index 5f89cfa74..bdcb464ae 100644 --- a/queries/smali/highlights.scm +++ b/queries/smali/highlights.scm @@ -182,3 +182,10 @@ ; Comments (comment) @comment @spell + +(class_definition + (comment) @comment.documentation) + +; Errors + +(ERROR) @error diff --git a/queries/smithy/highlights.scm b/queries/smithy/highlights.scm index 07ee328f1..2b709c2a2 100644 --- a/queries/smithy/highlights.scm +++ b/queries/smithy/highlights.scm @@ -108,7 +108,6 @@ ; Comments -[ - (comment) - (documentation_comment) -] @comment @spell +(comment) @comment @spell + +(documentation_comment) @comment.documentation @spell diff --git a/queries/solidity/highlights.scm b/queries/solidity/highlights.scm index 5afebb990..76a623267 100644 --- a/queries/solidity/highlights.scm +++ b/queries/solidity/highlights.scm @@ -252,6 +252,14 @@ (comment) @comment @spell +((comment) @comment.documentation + (#lua-match? @comment.documentation "^///[^/]")) +((comment) @comment.documentation + (#lua-match? @comment.documentation "^///$")) + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$")) + ; Errors (ERROR) @error diff --git a/queries/swift/highlights.scm b/queries/swift/highlights.scm index 5773c2377..4cdd882a8 100644 --- a/queries/swift/highlights.scm +++ b/queries/swift/highlights.scm @@ -107,6 +107,15 @@ (multiline_comment) ] @comment @spell +((comment) @comment.documentation + (#lua-match? @comment.documentation "^///[^/]")) + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^///$")) + +((multiline_comment) @comment.documentation + (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$")) + ; String literals (line_str_text) @string (str_escaped_char) @string diff --git a/queries/teal/highlights.scm b/queries/teal/highlights.scm index 2af9be589..4af3e212b 100644 --- a/queries/teal/highlights.scm +++ b/queries/teal/highlights.scm @@ -2,7 +2,11 @@ ;; Primitives (boolean) @boolean (comment) @comment @spell -(shebang_comment) @comment +((comment) @comment.documentation + (#lua-match? @comment.documentation "^[-][-][-]")) +((comment) @comment.documentation + (#lua-match? @comment.documentation "^[-][-](%s?)@")) +(shebang_comment) @preproc (identifier) @variable ((identifier) @variable.builtin (#eq? @variable.builtin "self")) diff --git a/queries/thrift/highlights.scm b/queries/thrift/highlights.scm index 5df609c3d..adf147d9d 100644 --- a/queries/thrift/highlights.scm +++ b/queries/thrift/highlights.scm @@ -198,3 +198,11 @@ ; Comments (comment) @comment @spell + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$")) + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^///[^/]")) +((comment) @comment.documentation + (#lua-match? @comment.documentation "^///$")) diff --git a/queries/v/highlights.scm b/queries/v/highlights.scm index 16904d18b..c4e69e802 100644 --- a/queries/v/highlights.scm +++ b/queries/v/highlights.scm @@ -406,5 +406,8 @@ (ERROR) @error -(comment) @comment +(comment) @comment @spell +(_ + (comment)+ @comment.documentation + [(function_declaration) (type_declaration) (const_spec) (enum_declaration)]) diff --git a/queries/vala/highlights.scm b/queries/vala/highlights.scm index 5ad7e0345..e1a20b8a0 100644 --- a/queries/vala/highlights.scm +++ b/queries/vala/highlights.scm @@ -1,7 +1,9 @@ ; highlights.scm ; highlight comments and symbols -(comment) @comment +(comment) @comment @spell +((comment) @comment.documentation + (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$")) (symbol) @symbol (member_access_expression (_) (identifier) @symbol) diff --git a/queries/zig/highlights.scm b/queries/zig/highlights.scm index 0989704ce..37afe1c2f 100644 --- a/queries/zig/highlights.scm +++ b/queries/zig/highlights.scm @@ -1,8 +1,9 @@ +(line_comment) @comment @spell + [ (container_doc_comment) (doc_comment) - (line_comment) -] @comment @spell +] @comment.documentation @spell [ variable: (IDENTIFIER) From 5ac39d10cc8a28f7bdb3725f3ee84a132ba783a8 Mon Sep 17 00:00:00 2001 From: Pham Huy Hoang Date: Mon, 6 Mar 2023 09:56:25 +0700 Subject: [PATCH 0081/2704] indents(vue): fix indents on new line after