aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-03-31 20:21:47 +0800
committerGitHub <noreply@github.com>2024-03-31 20:21:47 +0800
commitb25753381c6049132c5c8d02eb62df99f8a958fd (patch)
tree7acd3961648f9d7a9b76a4297f8384de5ba2ca51 /test
parente1ff2c51cad755d0ddc04a23df23e317d77023ed (diff)
downloadrneovim-b25753381c6049132c5c8d02eb62df99f8a958fd.tar.gz
rneovim-b25753381c6049132c5c8d02eb62df99f8a958fd.tar.bz2
rneovim-b25753381c6049132c5c8d02eb62df99f8a958fd.zip
fix(api): set script context when using nvim_set_hl (#28123)
Diffstat (limited to 'test')
-rw-r--r--test/functional/ex_cmds/verbose_spec.lua70
1 files changed, 60 insertions, 10 deletions
diff --git a/test/functional/ex_cmds/verbose_spec.lua b/test/functional/ex_cmds/verbose_spec.lua
index 026c70be8a..ba90793a37 100644
--- a/test/functional/ex_cmds/verbose_spec.lua
+++ b/test/functional/ex_cmds/verbose_spec.lua
@@ -32,21 +32,30 @@ vim.api.nvim_exec2("augroup test_group\
augroup END\
", {})
+vim.api.nvim_create_autocmd('FileType', {
+ group = 'test_group',
+ pattern = 'cpp',
+ command = 'setl cindent',
+})
+
+vim.api.nvim_exec2(':highlight TestHL1 guibg=Blue', {})
+vim.api.nvim_set_hl(0, 'TestHL2', { bg = 'Green' })
+
vim.api.nvim_command("command Bdelete :bd")
vim.api.nvim_create_user_command("TestCommand", ":echo 'Hello'", {})
-vim.api.nvim_exec ("\
+vim.api.nvim_exec2 ("\
function Close_Window() abort\
wincmd -\
endfunction\
-", false)
+", {})
-local ret = vim.api.nvim_exec ("\
+local ret = vim.api.nvim_exec2 ("\
function! s:return80()\
return 80\
endfunction\
let &tw = s:return80()\
-", true)
+", {})
]]
)
exec(cmd .. ' ' .. script_file)
@@ -109,7 +118,7 @@ n \key1 * :echo "test"<CR>
)
end)
- it('"Last set" for mapping set by vim.keymap', function()
+ it('"Last set" for mapping set by vim.keymap.set', function()
local result = exec_capture(':verbose map <leader>key2')
eq(
string.format(
@@ -123,7 +132,7 @@ n \key2 * :echo "test"<CR>
)
end)
- it('"Last set" for autocmd by vim.api.nvim_exec', function()
+ it('"Last set" for autocmd set by nvim_exec2', function()
local result = exec_capture(':verbose autocmd test_group Filetype c')
eq(
string.format(
@@ -138,6 +147,47 @@ test_group FileType
)
end)
+ it('"Last set" for autocmd set by nvim_create_autocmd', function()
+ local result = exec_capture(':verbose autocmd test_group Filetype cpp')
+ eq(
+ string.format(
+ [[
+--- Autocommands ---
+test_group FileType
+ cpp setl cindent
+ Last set from %s line 13]],
+ script_location
+ ),
+ result
+ )
+ end)
+
+ it('"Last set" for highlight group set by nvim_exec2', function()
+ local result = exec_capture(':verbose highlight TestHL1')
+ eq(
+ string.format(
+ [[
+TestHL1 xxx guibg=Blue
+ Last set from %s line 19]],
+ script_location
+ ),
+ result
+ )
+ end)
+
+ it('"Last set" for highlight group set by nvim_set_hl', function()
+ local result = exec_capture(':verbose highlight TestHL2')
+ eq(
+ string.format(
+ [[
+TestHL2 xxx guibg=Green
+ Last set from %s line 20]],
+ script_location
+ ),
+ result
+ )
+ end)
+
it('"Last set" for command defined by nvim_command', function()
if cmd == 'luafile' then
pending('nvim_command does not set the script context')
@@ -148,7 +198,7 @@ test_group FileType
[[
Name Args Address Complete Definition
Bdelete 0 :bd
- Last set from %s line 13]],
+ Last set from %s line 22]],
script_location
),
result
@@ -162,7 +212,7 @@ test_group FileType
[[
Name Args Address Complete Definition
TestCommand 0 :echo 'Hello'
- Last set from %s line 14]],
+ Last set from %s line 23]],
script_location
),
result
@@ -175,7 +225,7 @@ test_group FileType
string.format(
[[
function Close_Window() abort
- Last set from %s line 16
+ Last set from %s line 25
1 wincmd -
endfunction]],
script_location
@@ -190,7 +240,7 @@ test_group FileType
string.format(
[[
textwidth=80
- Last set from %s line 22]],
+ Last set from %s line 31]],
script_location
),
result