aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2021-07-23 17:56:16 +0200
committerGitHub <noreply@github.com>2021-07-23 17:56:16 +0200
commit754ac5a834cb82f73ca552a9a55b90a40f9367f6 (patch)
treedefa4a691604ca45742399336bc91e32175785d1 /test
parenta8c3d50fad94971ebfe9eeedf933bdd829e66787 (diff)
parent5ea6cc1d752bff196711f58d36b541e660fdcc1a (diff)
downloadrneovim-754ac5a834cb82f73ca552a9a55b90a40f9367f6.tar.gz
rneovim-754ac5a834cb82f73ca552a9a55b90a40f9367f6.tar.bz2
rneovim-754ac5a834cb82f73ca552a9a55b90a40f9367f6.zip
Merge pull request #15114 from theHamsta/treesitter-hl-priority
feat(treesitter): allow to set highlight priority for queries
Diffstat (limited to 'test')
-rw-r--r--test/functional/treesitter/highlight_spec.lua43
1 files changed, 43 insertions, 0 deletions
diff --git a/test/functional/treesitter/highlight_spec.lua b/test/functional/treesitter/highlight_spec.lua
index 05e0c5fe2c..175525b3f2 100644
--- a/test/functional/treesitter/highlight_spec.lua
+++ b/test/functional/treesitter/highlight_spec.lua
@@ -570,4 +570,47 @@ describe('treesitter highlighting', function()
]]}
screen:expect{ unchanged=true }
end)
+
+ it("supports highlighting with priority", function()
+ if pending_c_parser(pending) then return end
+
+ insert([[
+ int x = INT_MAX;
+ #define READ_STRING(x, y) (char_u *)read_string((x), (size_t)(y))
+ #define foo void main() { \
+ return 42; \
+ }
+ ]])
+
+ exec_lua [[
+ local parser = vim.treesitter.get_parser(0, "c")
+ test_hl = vim.treesitter.highlighter.new(parser, {queries = {c = hl_query..'\n((translation_unit) @Error (set! "priority" 101))\n'}})
+ ]]
+ -- expect everything to have Error highlight
+ screen:expect{grid=[[
+ {12:int}{8: x = INT_MAX;} |
+ {8:#define READ_STRING(x, y) (char_u *)read_string((x), (size_t)(y))}|
+ {8:#define foo void main() { \} |
+ {8: return 42; \} |
+ {8: }} |
+ ^ |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ |
+ ]], attr_ids={
+ [1] = {bold = true, foreground = Screen.colors.Blue1};
+ [8] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red};
+ -- bold will not be overwritten at the moment
+ [12] = {background = Screen.colors.Red, bold = true, foreground = Screen.colors.Grey100};
+ }}
+ end)
end)