Permalink
Browse files

Merge pull request #7414 from bfredl/bufhl_new

bufhl: support creating new groups
  • Loading branch information...
bfredl committed Oct 20, 2017
2 parents 91586d1 + dfe806e commit 6338199b76e661e85e4061122be99c57bf198cf8
Showing with 35 additions and 2 deletions.
  1. +5 −1 src/nvim/api/buffer.c
  2. +30 −1 test/functional/ui/bufhl_spec.lua
View
@@ -793,7 +793,11 @@ Integer nvim_buf_add_highlight(Buffer buffer,
col_end = MAXCOL;
}
int hlg_id = syn_name2id((char_u *)(hl_group.data ? hl_group.data : ""));
int hlg_id = 0;
if (hl_group.size > 0) {
hlg_id = syn_check_group((char_u *)hl_group.data, (int)hl_group.size);
}
src_id = bufhl_add_hl(buf, (int)src_id, hlg_id, (linenr_T)line+1,
(colnr_T)col_start+1, (colnr_T)col_end);
return src_id;
@@ -24,7 +24,8 @@ describe('Buffer highlighting', function()
[6] = {foreground = Screen.colors.DarkCyan}, -- Identifier
[7] = {bold = true},
[8] = {underline = true, bold = true, foreground = Screen.colors.SlateBlue},
[9] = {foreground = Screen.colors.SlateBlue, underline = true}
[9] = {foreground = Screen.colors.SlateBlue, underline = true},
[10] = {foreground = Screen.colors.Red}
})
curbuf = request('nvim_get_current_buf')
end)
@@ -255,4 +256,32 @@ describe('Buffer highlighting', function()
|
]])
end)
it('works with new syntax groups', function()
insert([[
fancy code in a new fancy language]])
add_hl(-1, "FancyLangItem", 0, 0, 5)
screen:expect([[
fancy code in a new fancy languag^e |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
|
]])
command('hi FancyLangItem guifg=red')
screen:expect([[
{10:fancy} code in a new fancy languag^e |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
|
]])
end)
end)

0 comments on commit 6338199

Please sign in to comment.