From 6a31d9086e38bde36415c736ed189747971cf2af Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Sun, 1 Jan 2023 15:16:04 +0100 Subject: [PATCH] highlights(rust): use `@namespace` for `[(crate) (self) (super)]` Fixes https://github.com/nvim-treesitter/nvim-treesitter/issues/3992 --- queries/rust/highlights.scm | 8 +++--- tests/query/highlights_spec.lua | 48 ++++++++++++++++++++++----------- 2 files changed, 37 insertions(+), 19 deletions(-) diff --git a/queries/rust/highlights.scm b/queries/rust/highlights.scm index c7cd1174b..db80fbb32 100644 --- a/queries/rust/highlights.scm +++ b/queries/rust/highlights.scm @@ -209,10 +209,10 @@ (type_cast_expression "as" @keyword.operator) (qualified_type "as" @keyword.operator) -(use_list (self) @keyword) -(scoped_use_list (self) @keyword) -(scoped_identifier [(crate) (super) (self)] @keyword) -(visibility_modifier [(crate) (super) (self)] @keyword) +(use_list (self) @namespace) +(scoped_use_list (self) @namespace) +(scoped_identifier [(crate) (super) (self)] @namespace) +(visibility_modifier [(crate) (super) (self)] @namespace) [ "else" diff --git a/tests/query/highlights_spec.lua b/tests/query/highlights_spec.lua index ff022ba21..8bfd3c2ec 100644 --- a/tests/query/highlights_spec.lua +++ b/tests/query/highlights_spec.lua @@ -76,21 +76,39 @@ local function check_assertions(file) end end end, true) - assert.True( - captures[assertion.expected_capture_name] or highlights[assertion.expected_capture_name], - "Error in at " - .. file - .. ":" - .. (row + 1) - .. ":" - .. (col + 1) - .. ': expected "' - .. assertion.expected_capture_name - .. '", captures: ' - .. vim.inspect(vim.tbl_keys(captures)) - .. '", highlights: ' - .. vim.inspect(vim.tbl_keys(highlights)) - ) + if assertion.expected_capture_name:match "^!" then + assert.Falsy( + captures[assertion.expected_capture_name:sub(2)] or highlights[assertion.expected_capture_name:sub(2)], + "Error in at " + .. file + .. ":" + .. (row + 1) + .. ":" + .. (col + 1) + .. ': expected "' + .. assertion.expected_capture_name + .. '", captures: ' + .. vim.inspect(vim.tbl_keys(captures)) + .. '", highlights: ' + .. vim.inspect(vim.tbl_keys(highlights)) + ) + else + assert.True( + captures[assertion.expected_capture_name] or highlights[assertion.expected_capture_name], + "Error in at " + .. file + .. ":" + .. (row + 1) + .. ":" + .. (col + 1) + .. ': expected "' + .. assertion.expected_capture_name + .. '", captures: ' + .. vim.inspect(vim.tbl_keys(captures)) + .. '", highlights: ' + .. vim.inspect(vim.tbl_keys(highlights)) + ) + end end end