aboutsummaryrefslogtreecommitdiff
path: root/test/functional/treesitter/highlight_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/treesitter/highlight_spec.lua')
-rw-r--r--test/functional/treesitter/highlight_spec.lua475
1 files changed, 232 insertions, 243 deletions
diff --git a/test/functional/treesitter/highlight_spec.lua b/test/functional/treesitter/highlight_spec.lua
index e037c9e215..2bf230fe69 100644
--- a/test/functional/treesitter/highlight_spec.lua
+++ b/test/functional/treesitter/highlight_spec.lua
@@ -6,7 +6,7 @@ local insert = helpers.insert
local exec_lua = helpers.exec_lua
local feed = helpers.feed
local command = helpers.command
-local meths = helpers.meths
+local api = helpers.api
local eq = helpers.eq
before_each(clear)
@@ -100,17 +100,7 @@ local injection_grid_c = [[
return 42; \ |
} |
^ |
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
+ {1:~ }|*11
|
]]
@@ -121,17 +111,7 @@ local injection_grid_expected_c = [[
{4:return} {5:42}; \ |
} |
^ |
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
+ {1:~ }|*11
|
]]
@@ -142,17 +122,17 @@ describe('treesitter highlighting (C)', function()
screen = Screen.new(65, 18)
screen:attach()
screen:set_default_attr_ids {
- [1] = {bold = true, foreground = Screen.colors.Blue1};
- [2] = {foreground = Screen.colors.Blue1};
- [3] = {bold = true, foreground = Screen.colors.SeaGreen4};
- [4] = {bold = true, foreground = Screen.colors.Brown};
- [5] = {foreground = Screen.colors.Magenta};
- [6] = {foreground = Screen.colors.Red};
- [7] = {bold = true, foreground = Screen.colors.SlateBlue};
- [8] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red};
- [9] = {foreground = Screen.colors.Magenta, background = Screen.colors.Red};
- [10] = {foreground = Screen.colors.Red, background = Screen.colors.Red};
- [11] = {foreground = Screen.colors.Cyan4};
+ [1] = { bold = true, foreground = Screen.colors.Blue1 },
+ [2] = { foreground = Screen.colors.Blue1 },
+ [3] = { bold = true, foreground = Screen.colors.SeaGreen4 },
+ [4] = { bold = true, foreground = Screen.colors.Brown },
+ [5] = { foreground = Screen.colors.Magenta },
+ [6] = { foreground = Screen.colors.Red },
+ [7] = { bold = true, foreground = Screen.colors.SlateBlue },
+ [8] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red },
+ [9] = { foreground = Screen.colors.Magenta, background = Screen.colors.Red },
+ [10] = { foreground = Screen.colors.Red, background = Screen.colors.Red },
+ [11] = { foreground = Screen.colors.Cyan4 },
}
exec_lua([[ hl_query = ... ]], hl_query_c)
@@ -162,7 +142,8 @@ describe('treesitter highlighting (C)', function()
it('is updated with edits', function()
insert(hl_text_c)
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
/// Schedule Lua callback on main loop's event queue |
static int nlua_schedule(lua_State *const lstate) |
{ |
@@ -178,17 +159,18 @@ describe('treesitter highlighting (C)', function()
1, (void *)(ptrdiff_t)cb); |
return 0; |
^} |
- {1:~ }|
- {1:~ }|
+ {1:~ }|*2
|
- ]]}
+ ]],
+ }
exec_lua [[
local parser = vim.treesitter.get_parser(0, "c")
local highlighter = vim.treesitter.highlighter
test_hl = highlighter.new(parser, {queries = {c = hl_query}})
]]
- screen:expect{grid=[[
+ 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) |
{ |
@@ -204,14 +186,15 @@ describe('treesitter highlighting (C)', function()
{5:1}, ({3:void} *)({3:ptrdiff_t})cb); |
{4:return} {5:0}; |
^} |
- {1:~ }|
- {1:~ }|
+ {1:~ }|*2
|
- ]]}
+ ]],
+ }
- feed("5Goc<esc>dd")
+ feed('5Goc<esc>dd')
- screen:expect{grid=[[
+ 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) |
{ |
@@ -227,13 +210,14 @@ describe('treesitter highlighting (C)', function()
{5:1}, ({3:void} *)({3:ptrdiff_t})cb); |
{4:return} {5:0}; |
} |
- {1:~ }|
- {1:~ }|
+ {1:~ }|*2
|
- ]]}
+ ]],
+ }
feed('7Go*/<esc>')
- screen:expect{grid=[[
+ 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) |
{ |
@@ -252,10 +236,12 @@ describe('treesitter highlighting (C)', function()
} |
{1:~ }|
|
- ]]}
+ ]],
+ }
feed('3Go/*<esc>')
- screen:expect{grid=[[
+ 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) |
{ |
@@ -274,11 +260,13 @@ describe('treesitter highlighting (C)', function()
{4:return} {5:0}; |
{8:}} |
|
- ]]}
+ ]],
+ }
- feed("gg$")
- feed("~")
- screen:expect{grid=[[
+ feed('gg$')
+ feed('~')
+ screen:expect {
+ grid = [[
{2:/// Schedule Lua callback on main loop's event queu^E} |
{3:static} {3:int} {11:nlua_schedule}({3:lua_State} *{3:const} lstate) |
{ |
@@ -297,11 +285,12 @@ describe('treesitter highlighting (C)', function()
{4:return} {5:0}; |
{8:}} |
|
- ]]}
-
+ ]],
+ }
- feed("re")
- screen:expect{grid=[[
+ feed('re')
+ screen:expect {
+ grid = [[
{2:/// Schedule Lua callback on main loop's event queu^e} |
{3:static} {3:int} {11:nlua_schedule}({3:lua_State} *{3:const} lstate) |
{ |
@@ -320,7 +309,8 @@ describe('treesitter highlighting (C)', function()
{4:return} {5:0}; |
{8:}} |
|
- ]]}
+ ]],
+ }
end)
it('is updated with :sort', function()
@@ -329,7 +319,8 @@ describe('treesitter highlighting (C)', function()
local parser = vim.treesitter.get_parser(0, "c")
test_hl = vim.treesitter.highlighter.new(parser, {queries = {c = hl_query}})
]]
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{3:int} width = {5:INT_MAX}, height = {5:INT_MAX}; |
{3:bool} ext_widgets[kUIExtCount]; |
{4:for} ({3:UIExtension} i = {5:0}; ({3:int})i < kUIExtCount; i++) { |
@@ -348,10 +339,12 @@ describe('treesitter highlighting (C)', function()
} |
^} |
|
- ]]}
+ ]],
+ }
- feed ":sort<cr>"
- screen:expect{grid=[[
+ feed ':sort<cr>'
+ screen:expect {
+ grid = [[
^ |
ext_widgets[j] &= (ui->ui_ext[j] || inclusive); |
{3:UI} *ui = uis[i]; |
@@ -366,15 +359,16 @@ describe('treesitter highlighting (C)', function()
{4:for} ({3:UIExtension} i = {5:0}; ({3:int})i < kUIExtCount; i++) { |
{4:for} ({3:size_t} i = {5:0}; i < ui_count; i++) { |
{3:int} width = {5:INT_MAX}, height = {5:INT_MAX}; |
- } |
- } |
+ } |*2
{3:void} ui_refresh({3:void}) |
:sort |
- ]]}
+ ]],
+ }
- feed "u"
+ feed 'u'
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{3:int} width = {5:INT_MAX}, height = {5:INT_MAX}; |
{3:bool} ext_widgets[kUIExtCount]; |
{4:for} ({3:UIExtension} i = {5:0}; ({3:int})i < kUIExtCount; i++) { |
@@ -393,17 +387,19 @@ describe('treesitter highlighting (C)', function()
} |
^} |
19 changes; before #2 {MATCH:.*}|
- ]]}
+ ]],
+ }
end)
- it("supports with custom parser", function()
+ it('supports with custom parser', function()
screen:set_default_attr_ids {
- [1] = {bold = true, foreground = Screen.colors.SeaGreen4};
+ [1] = { bold = true, foreground = Screen.colors.SeaGreen4 },
}
insert(test_text_c)
- screen:expect{ grid= [[
+ screen:expect {
+ grid = [[
int width = INT_MAX, height = INT_MAX; |
bool ext_widgets[kUIExtCount]; |
for (UIExtension i = 0; (int)i < kUIExtCount; i++) { |
@@ -422,7 +418,8 @@ describe('treesitter highlighting (C)', function()
} |
^} |
|
- ]] }
+ ]],
+ }
exec_lua [[
parser = vim.treesitter.get_parser(0, "c")
@@ -438,7 +435,8 @@ describe('treesitter highlighting (C)', function()
local hl = vim.treesitter.highlighter.new(parser, {queries = {c = "(identifier) @type"}})
]]
- screen:expect{ grid = [[
+ screen:expect {
+ grid = [[
int {1:width} = {1:INT_MAX}, {1:height} = {1:INT_MAX}; |
bool {1:ext_widgets}[{1:kUIExtCount}]; |
for (UIExtension {1:i} = 0; (int)i < kUIExtCount; i++) { |
@@ -457,13 +455,14 @@ describe('treesitter highlighting (C)', function()
} |
^} |
|
- ]] }
+ ]],
+ }
end)
- it("supports injected languages", function()
+ it('supports injected languages', function()
insert(injection_text_c)
- screen:expect{grid=injection_grid_c}
+ screen:expect { grid = injection_grid_c }
exec_lua [[
local parser = vim.treesitter.get_parser(0, "c", {
@@ -473,13 +472,13 @@ describe('treesitter highlighting (C)', function()
test_hl = highlighter.new(parser, {queries = {c = hl_query}})
]]
- screen:expect{grid=injection_grid_expected_c}
+ screen:expect { grid = injection_grid_expected_c }
end)
it("supports injecting by ft name in metadata['injection.language']", function()
insert(injection_text_c)
- screen:expect{grid=injection_grid_c}
+ screen:expect { grid = injection_grid_c }
exec_lua [[
vim.treesitter.language.register("c", "foo")
@@ -490,10 +489,10 @@ describe('treesitter highlighting (C)', function()
test_hl = highlighter.new(parser, {queries = {c = hl_query}})
]]
- screen:expect{grid=injection_grid_expected_c}
+ screen:expect { grid = injection_grid_expected_c }
end)
- it("supports overriding queries, like ", function()
+ it('supports overriding queries, like ', function()
insert([[
int x = INT_MAX;
#define READ_STRING(x, y) (char *)read_string((x), (size_t)(y))
@@ -510,29 +509,21 @@ describe('treesitter highlighting (C)', function()
vim.treesitter.highlighter.new(vim.treesitter.get_parser(0, "c"))
]]
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{3:int} x = {5:INT_MAX}; |
#define {5:READ_STRING}(x, y) ({3:char} *)read_string((x), ({3:size_t})(y)) |
#define foo {3:void} main() { \ |
{4:return} {5:42}; \ |
} |
^ |
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
+ {1:~ }|*11
|
- ]]}
+ ]],
+ }
end)
- it("supports highlighting with custom highlight groups", function()
+ it('supports highlighting with custom highlight groups', function()
insert(hl_text_c)
exec_lua [[
@@ -540,7 +531,8 @@ describe('treesitter highlighting (C)', function()
test_hl = vim.treesitter.highlighter.new(parser, {queries = {c = hl_query}})
]]
- screen:expect{grid=[[
+ 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) |
{ |
@@ -556,15 +548,16 @@ describe('treesitter highlighting (C)', function()
{5:1}, ({3:void} *)({3:ptrdiff_t})cb); |
{4:return} {5:0}; |
^} |
- {1:~ }|
- {1:~ }|
+ {1:~ }|*2
|
- ]]}
+ ]],
+ }
-- 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 @string.nonexistent_specializer comment")]]
- screen:expect{grid=[[
+ 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) |
{ |
@@ -580,14 +573,14 @@ describe('treesitter highlighting (C)', function()
{5:1}, ({3:void} *)({3:ptrdiff_t})cb); |
{4:return} {5:0}; |
^} |
- {1:~ }|
- {1:~ }|
+ {1:~ }|*2
|
- ]]}
- screen:expect{ unchanged=true }
+ ]],
+ }
+ screen:expect { unchanged = true }
end)
- it("supports highlighting with priority", function()
+ it('supports highlighting with priority', function()
insert([[
int x = INT_MAX;
#define READ_STRING(x, y) (char *)read_string((x), (size_t)(y))
@@ -601,120 +594,80 @@ describe('treesitter highlighting (C)', function()
test_hl = vim.treesitter.highlighter.new(parser, {queries = {c = hl_query..'\n((translation_unit) @constant (#set! "priority" 101))\n'}})
]]
-- expect everything to have Constant highlight
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{12:int}{8: x = INT_MAX;} |
{8:#define READ_STRING(x, y) (}{12:char}{8: *)read_string((x), (}{12:size_t}{8:)(y))} |
{8:#define foo }{12:void}{8: main() { \} |
{8: }{12:return}{8: 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.Magenta1};
- -- bold will not be overwritten at the moment
- [12] = {bold = true, foreground = Screen.colors.Magenta1};
- }}
+ {1:~ }|*11
+ |
+ ]],
+ attr_ids = {
+ [1] = { bold = true, foreground = Screen.colors.Blue1 },
+ [8] = { foreground = Screen.colors.Magenta1 },
+ -- bold will not be overwritten at the moment
+ [12] = { bold = true, foreground = Screen.colors.Magenta1 },
+ },
+ }
eq({
- {capture='constant', metadata = { priority='101' }, lang='c' };
- {capture='type', metadata = { }, lang='c' };
+ { capture = 'constant', metadata = { priority = '101' }, lang = 'c' },
+ { capture = 'type', metadata = {}, lang = 'c' },
}, exec_lua [[ return vim.treesitter.get_captures_at_pos(0, 0, 2) ]])
- end)
+ end)
- it("allows to use captures with dots (don't use fallback when specialization of foo exists)", function()
- insert([[
+ it(
+ "allows to use captures with dots (don't use fallback when specialization of foo exists)",
+ function()
+ insert([[
char* x = "Will somebody ever read this?";
]])
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
char* x = "Will somebody ever read this?"; |
^ |
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
+ {1:~ }|*15
|
- ]]}
+ ]],
+ }
- command [[
+ command [[
hi link @foo.bar Type
hi link @foo String
]]
- exec_lua [[
+ exec_lua [[
local parser = vim.treesitter.get_parser(0, "c", {})
local highlighter = vim.treesitter.highlighter
test_hl = highlighter.new(parser, {queries = {c = "(primitive_type) @foo.bar (string_literal) @foo"}})
]]
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{3:char}* x = {5:"Will somebody ever read this?"}; |
^ |
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
+ {1:~ }|*15
|
- ]]}
+ ]],
+ }
- -- clearing specialization reactivates fallback
- command [[ hi clear @foo.bar ]]
- screen:expect{grid=[[
+ -- clearing specialization reactivates fallback
+ command [[ hi clear @foo.bar ]]
+ screen:expect {
+ grid = [[
{5:char}* x = {5:"Will somebody ever read this?"}; |
^ |
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
+ {1:~ }|*15
|
- ]]}
- end)
+ ]],
+ }
+ end
+ )
- it("supports conceal attribute", function()
+ it('supports conceal attribute', function()
insert(hl_text_c)
-- conceal can be empty or a single cchar.
@@ -723,15 +676,16 @@ describe('treesitter highlighting (C)', function()
local parser = vim.treesitter.get_parser(0, "c")
test_hl = vim.treesitter.highlighter.new(parser, {queries = {c = [[
("static" @keyword
- (set! conceal "R"))
+ (#set! conceal "R"))
((identifier) @Identifier
- (set! conceal "")
- (eq? @Identifier "lstate"))
+ (#set! conceal "")
+ (#eq? @Identifier "lstate"))
]]}})
]=]
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
/// Schedule Lua callback on main loop's event queue |
{4:R} int nlua_schedule(lua_State *const ) |
{ |
@@ -747,33 +701,60 @@ describe('treesitter highlighting (C)', function()
1, (void *)(ptrdiff_t)cb); |
return 0; |
^} |
- {1:~ }|
- {1:~ }|
+ {1:~ }|*2
|
- ]]}
+ ]],
+ }
end)
- it("@foo.bar groups has the correct fallback behavior", function()
- local get_hl = function(name) return meths.get_hl_by_name(name,1).foreground end
- meths.set_hl(0, "@foo", {fg = 1})
- meths.set_hl(0, "@foo.bar", {fg = 2})
- meths.set_hl(0, "@foo.bar.baz", {fg = 3})
-
- eq(1, get_hl"@foo")
- eq(1, get_hl"@foo.a.b.c.d")
- eq(2, get_hl"@foo.bar")
- eq(2, get_hl"@foo.bar.a.b.c.d")
- eq(3, get_hl"@foo.bar.baz")
- eq(3, get_hl"@foo.bar.baz.d")
+ it('@foo.bar groups has the correct fallback behavior', function()
+ local get_hl = function(name)
+ return api.nvim_get_hl_by_name(name, 1).foreground
+ end
+ api.nvim_set_hl(0, '@foo', { fg = 1 })
+ api.nvim_set_hl(0, '@foo.bar', { fg = 2 })
+ api.nvim_set_hl(0, '@foo.bar.baz', { fg = 3 })
+
+ eq(1, get_hl '@foo')
+ eq(1, get_hl '@foo.a.b.c.d')
+ eq(2, get_hl '@foo.bar')
+ eq(2, get_hl '@foo.bar.a.b.c.d')
+ eq(3, get_hl '@foo.bar.baz')
+ eq(3, get_hl '@foo.bar.baz.d')
-- lookup is case insensitive
- eq(2, get_hl"@FOO.BAR.SPAM")
+ eq(2, get_hl '@FOO.BAR.SPAM')
+
+ api.nvim_set_hl(0, '@foo.missing.exists', { fg = 3 })
+ eq(1, get_hl '@foo.missing')
+ eq(3, get_hl '@foo.missing.exists')
+ eq(3, get_hl '@foo.missing.exists.bar')
+ eq(nil, get_hl '@total.nonsense.but.a.lot.of.dots')
+ end)
- meths.set_hl(0, "@foo.missing.exists", {fg = 3})
- eq(1, get_hl"@foo.missing")
- eq(3, get_hl"@foo.missing.exists")
- eq(3, get_hl"@foo.missing.exists.bar")
- eq(nil, get_hl"@total.nonsense.but.a.lot.of.dots")
+ it('supports multiple nodes assigned to the same capture #17060', function()
+ insert([[
+ int x = 4;
+ int y = 5;
+ int z = 6;
+ ]])
+
+ exec_lua([[
+ local query = '((declaration)+ @string)'
+ vim.treesitter.query.set('c', 'highlights', query)
+ vim.treesitter.highlighter.new(vim.treesitter.get_parser(0, 'c'))
+ ]])
+
+ screen:expect {
+ grid = [[
+ {5:int x = 4;} |
+ {5:int y = 5;} |
+ {5:int z = 6;} |
+ ^ |
+ {1:~ }|*13
+ |
+ ]],
+ }
end)
end)
@@ -784,16 +765,16 @@ describe('treesitter highlighting (help)', function()
screen = Screen.new(40, 6)
screen:attach()
screen:set_default_attr_ids {
- [1] = {foreground = Screen.colors.Blue1};
- [2] = {bold = true, foreground = Screen.colors.Blue1};
- [3] = {bold = true, foreground = Screen.colors.Brown};
- [4] = {foreground = Screen.colors.Cyan4};
- [5] = {foreground = Screen.colors.Magenta1};
+ [1] = { foreground = Screen.colors.Blue1 },
+ [2] = { bold = true, foreground = Screen.colors.Blue1 },
+ [3] = { bold = true, foreground = Screen.colors.Brown },
+ [4] = { foreground = Screen.colors.Cyan4 },
+ [5] = { foreground = Screen.colors.Magenta1 },
}
end)
- it("correctly redraws added/removed injections", function()
- insert[[
+ it('correctly redraws added/removed injections', function()
+ insert [[
>ruby
-- comment
local this_is = 'actually_lua'
@@ -805,38 +786,43 @@ describe('treesitter highlighting (help)', function()
vim.treesitter.start()
]]
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1:>ruby} |
{1: -- comment} |
{1: local this_is = 'actually_lua'} |
- < |
+ {1:<} |
^ |
|
- ]]}
+ ]],
+ }
- helpers.curbufmeths.set_text(0, 1, 0, 5, {'lua'})
+ helpers.api.nvim_buf_set_text(0, 0, 1, 0, 5, { 'lua' })
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1:>lua} |
{1: -- comment} |
{1: }{3:local}{1: }{4:this_is}{1: }{3:=}{1: }{5:'actually_lua'} |
- < |
+ {1:<} |
^ |
|
- ]]}
+ ]],
+ }
- helpers.curbufmeths.set_text(0, 1, 0, 4, {'ruby'})
+ helpers.api.nvim_buf_set_text(0, 0, 1, 0, 4, { 'ruby' })
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1:>ruby} |
{1: -- comment} |
{1: local this_is = 'actually_lua'} |
- < |
+ {1:<} |
^ |
|
- ]]}
+ ]],
+ }
end)
-
end)
describe('treesitter highlighting (nested injections)', function()
@@ -846,15 +832,15 @@ describe('treesitter highlighting (nested injections)', function()
screen = Screen.new(80, 7)
screen:attach()
screen:set_default_attr_ids {
- [1] = {foreground = Screen.colors.SlateBlue};
- [2] = {bold = true, foreground = Screen.colors.Brown};
- [3] = {foreground = Screen.colors.Cyan4};
- [4] = {foreground = Screen.colors.Fuchsia};
+ [1] = { foreground = Screen.colors.SlateBlue },
+ [2] = { bold = true, foreground = Screen.colors.Brown },
+ [3] = { foreground = Screen.colors.Cyan4 },
+ [4] = { foreground = Screen.colors.Fuchsia },
}
end)
- it("correctly redraws nested injections (GitHub #25252)", function()
- insert[=[
+ it('correctly redraws nested injections (GitHub #25252)', function()
+ insert [=[
function foo() print("Lua!") end
local lorem = {
@@ -875,9 +861,10 @@ vim.cmd([[
]]
-- invalidate the language tree
- feed("ggi--[[<ESC>04x")
+ feed('ggi--[[<ESC>04x')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{2:^function} {3:foo}{1:()} {1:print(}{4:"Lua!"}{1:)} {2:end} |
|
{2:local} {3:lorem} {2:=} {1:{} |
@@ -885,12 +872,14 @@ vim.cmd([[
{3:bar} {2:=} {1:{},} |
{1:}} |
|
- ]]}
+ ]],
+ }
-- spam newline insert/delete to invalidate Lua > Vim > Lua region
- feed("3jo<ESC>ddko<ESC>ddko<ESC>ddko<ESC>ddk0")
+ feed('3jo<ESC>ddko<ESC>ddko<ESC>ddko<ESC>ddk0')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{2:function} {3:foo}{1:()} {1:print(}{4:"Lua!"}{1:)} {2:end} |
|
{2:local} {3:lorem} {2:=} {1:{} |
@@ -898,7 +887,7 @@ vim.cmd([[
{3:bar} {2:=} {1:{},} |
{1:}} |
|
- ]]}
+ ]],
+ }
end)
-
end)