aboutsummaryrefslogtreecommitdiff
path: root/test/functional/treesitter/highlight_spec.lua
diff options
context:
space:
mode:
authorTJ DeVries <devries.timothyj@gmail.com>2021-03-29 16:07:21 -0400
committerThomas Vigouroux <tomvig38@gmail.com>2021-03-31 18:09:00 +0200
commit06c065469b12a3a8088b812380db612a9984c45f (patch)
tree4a59fd401fe7bbae5b6d97402c23801927fbadca /test/functional/treesitter/highlight_spec.lua
parent94c2ce2ce4599622bbf65215fde876ae7fb16114 (diff)
downloadrneovim-06c065469b12a3a8088b812380db612a9984c45f.tar.gz
rneovim-06c065469b12a3a8088b812380db612a9984c45f.tar.bz2
rneovim-06c065469b12a3a8088b812380db612a9984c45f.zip
ts: Add per-language highlight links
Diffstat (limited to 'test/functional/treesitter/highlight_spec.lua')
-rw-r--r--test/functional/treesitter/highlight_spec.lua58
1 files changed, 58 insertions, 0 deletions
diff --git a/test/functional/treesitter/highlight_spec.lua b/test/functional/treesitter/highlight_spec.lua
index 1992f75413..8f6a0433a1 100644
--- a/test/functional/treesitter/highlight_spec.lua
+++ b/test/functional/treesitter/highlight_spec.lua
@@ -4,6 +4,7 @@ local Screen = require('test.functional.ui.screen')
local clear = helpers.clear
local insert = helpers.insert
local exec_lua = helpers.exec_lua
+local eq = helpers.eq
local feed = helpers.feed
local pending_c_parser = helpers.pending_c_parser
@@ -513,4 +514,61 @@ describe('treesitter highlighting', function()
|
]]}
end)
+
+ it("supports highlighting with custom highlight groups", function()
+ if pending_c_parser(pending) then return end
+
+ insert(hl_text)
+
+ exec_lua [[
+ local parser = vim.treesitter.get_parser(0, "c")
+ test_hl = vim.treesitter.highlighter.new(parser, {queries = {c = hl_query}})
+ ]]
+
+ screen:expect{grid=[[
+ {2:/// Schedule Lua callback on main loop's event queue} |
+ {3:static} {3:int} {11:nlua_schedule}({3:lua_State} *{3:const} lstate) |
+ { |
+ {4:if} ({11:lua_type}(lstate, {5:1}) != {5:LUA_TFUNCTION} |
+ || {6:lstate} != {6:lstate}) { |
+ {11:lua_pushliteral}(lstate, {5:"vim.schedule: expected function"}); |
+ {4:return} {11:lua_error}(lstate); |
+ } |
+ |
+ {7:LuaRef} cb = {11:nlua_ref}(lstate, {5:1}); |
+ |
+ multiqueue_put(main_loop.events, {11:nlua_schedule_event}, |
+ {5:1}, ({3:void} *)({3:ptrdiff_t})cb); |
+ {4:return} {5:0}; |
+ ^} |
+ {1:~ }|
+ {1:~ }|
+ |
+ ]]}
+
+ -- This will change ONLY the literal strings to look like comments
+ -- The only literal string is the "vim.schedule: expected function" in this test.
+ exec_lua [[vim.cmd("highlight link cString comment")]]
+ screen:expect{grid=[[
+ {2:/// Schedule Lua callback on main loop's event queue} |
+ {3:static} {3:int} {11:nlua_schedule}({3:lua_State} *{3:const} lstate) |
+ { |
+ {4:if} ({11:lua_type}(lstate, {5:1}) != {5:LUA_TFUNCTION} |
+ || {6:lstate} != {6:lstate}) { |
+ {11:lua_pushliteral}(lstate, {2:"vim.schedule: expected function"}); |
+ {4:return} {11:lua_error}(lstate); |
+ } |
+ |
+ {7:LuaRef} cb = {11:nlua_ref}(lstate, {5:1}); |
+ |
+ multiqueue_put(main_loop.events, {11:nlua_schedule_event}, |
+ {5:1}, ({3:void} *)({3:ptrdiff_t})cb); |
+ {4:return} {5:0}; |
+ ^} |
+ {1:~ }|
+ {1:~ }|
+ |
+ ]]}
+ screen:expect{ unchanged=true }
+ end)
end)