mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
test: typing for helpers.meths
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -42,9 +42,9 @@ describe('api/buf', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it("doesn't crash just after set undolevels=1 #24894", function()
|
it("doesn't crash just after set undolevels=1 #24894", function()
|
||||||
local buf = meths.create_buf(false, true)
|
local buf = meths.nvim_create_buf(false, true)
|
||||||
meths.buf_set_option(buf, 'undolevels', -1)
|
meths.nvim_buf_set_option(buf, 'undolevels', -1)
|
||||||
meths.buf_set_lines(buf, 0, 1, false, {})
|
meths.nvim_buf_set_lines(buf, 0, 1, false, {})
|
||||||
|
|
||||||
assert_alive()
|
assert_alive()
|
||||||
end)
|
end)
|
||||||
@@ -85,35 +85,41 @@ describe('api/buf', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('cursor position is maintained in non-current window', function()
|
it('cursor position is maintained in non-current window', function()
|
||||||
meths.buf_set_lines(0, 0, -1, 1, { 'line1', 'line2', 'line3', 'line4' })
|
meths.nvim_buf_set_lines(0, 0, -1, 1, { 'line1', 'line2', 'line3', 'line4' })
|
||||||
meths.win_set_cursor(0, { 3, 2 })
|
meths.nvim_win_set_cursor(0, { 3, 2 })
|
||||||
local win = meths.get_current_win()
|
local win = meths.nvim_get_current_win()
|
||||||
local buf = meths.get_current_buf()
|
local buf = meths.nvim_get_current_buf()
|
||||||
|
|
||||||
command('new')
|
command('new')
|
||||||
|
|
||||||
meths.buf_set_lines(buf, 1, 2, 1, { 'line5', 'line6' })
|
meths.nvim_buf_set_lines(buf, 1, 2, 1, { 'line5', 'line6' })
|
||||||
eq({ 'line1', 'line5', 'line6', 'line3', 'line4' }, meths.buf_get_lines(buf, 0, -1, true))
|
eq(
|
||||||
eq({ 4, 2 }, meths.win_get_cursor(win))
|
{ 'line1', 'line5', 'line6', 'line3', 'line4' },
|
||||||
|
meths.nvim_buf_get_lines(buf, 0, -1, true)
|
||||||
|
)
|
||||||
|
eq({ 4, 2 }, meths.nvim_win_get_cursor(win))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('cursor position is maintained in TWO non-current windows', function()
|
it('cursor position is maintained in TWO non-current windows', function()
|
||||||
meths.buf_set_lines(0, 0, -1, 1, { 'line1', 'line2', 'line3', 'line4' })
|
meths.nvim_buf_set_lines(0, 0, -1, 1, { 'line1', 'line2', 'line3', 'line4' })
|
||||||
meths.win_set_cursor(0, { 3, 2 })
|
meths.nvim_win_set_cursor(0, { 3, 2 })
|
||||||
local win = meths.get_current_win()
|
local win = meths.nvim_get_current_win()
|
||||||
local buf = meths.get_current_buf()
|
local buf = meths.nvim_get_current_buf()
|
||||||
|
|
||||||
command('split')
|
command('split')
|
||||||
meths.win_set_cursor(0, { 4, 2 })
|
meths.nvim_win_set_cursor(0, { 4, 2 })
|
||||||
local win2 = meths.get_current_win()
|
local win2 = meths.nvim_get_current_win()
|
||||||
|
|
||||||
-- set current window to third one with another buffer
|
-- set current window to third one with another buffer
|
||||||
command('new')
|
command('new')
|
||||||
|
|
||||||
meths.buf_set_lines(buf, 1, 2, 1, { 'line5', 'line6' })
|
meths.nvim_buf_set_lines(buf, 1, 2, 1, { 'line5', 'line6' })
|
||||||
eq({ 'line1', 'line5', 'line6', 'line3', 'line4' }, meths.buf_get_lines(buf, 0, -1, true))
|
eq(
|
||||||
eq({ 4, 2 }, meths.win_get_cursor(win))
|
{ 'line1', 'line5', 'line6', 'line3', 'line4' },
|
||||||
eq({ 5, 2 }, meths.win_get_cursor(win2))
|
meths.nvim_buf_get_lines(buf, 0, -1, true)
|
||||||
|
)
|
||||||
|
eq({ 4, 2 }, meths.nvim_win_get_cursor(win))
|
||||||
|
eq({ 5, 2 }, meths.nvim_win_get_cursor(win2))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('line_count has defined behaviour for unloaded buffers', function()
|
it('line_count has defined behaviour for unloaded buffers', function()
|
||||||
@@ -156,16 +162,22 @@ describe('api/buf', function()
|
|||||||
[3] = { reverse = true },
|
[3] = { reverse = true },
|
||||||
}
|
}
|
||||||
screen:attach()
|
screen:attach()
|
||||||
meths.buf_set_lines(0, 0, -1, 1, { 'aaa', 'bbb', 'ccc', 'ddd', 'www', 'xxx', 'yyy', 'zzz' })
|
meths.nvim_buf_set_lines(
|
||||||
meths.set_option_value('modified', false, {})
|
0,
|
||||||
|
0,
|
||||||
|
-1,
|
||||||
|
1,
|
||||||
|
{ 'aaa', 'bbb', 'ccc', 'ddd', 'www', 'xxx', 'yyy', 'zzz' }
|
||||||
|
)
|
||||||
|
meths.nvim_set_option_value('modified', false, {})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('of current window', function()
|
it('of current window', function()
|
||||||
local win = meths.get_current_win()
|
local win = meths.nvim_get_current_win()
|
||||||
local buf = meths.get_current_buf()
|
local buf = meths.nvim_get_current_buf()
|
||||||
|
|
||||||
command('new | wincmd w')
|
command('new | wincmd w')
|
||||||
meths.win_set_cursor(win, { 8, 0 })
|
meths.nvim_win_set_cursor(win, { 8, 0 })
|
||||||
|
|
||||||
screen:expect {
|
screen:expect {
|
||||||
grid = [[
|
grid = [[
|
||||||
@@ -181,7 +193,7 @@ describe('api/buf', function()
|
|||||||
]],
|
]],
|
||||||
}
|
}
|
||||||
|
|
||||||
meths.buf_set_lines(buf, 0, 2, true, { 'aaabbb' })
|
meths.nvim_buf_set_lines(buf, 0, 2, true, { 'aaabbb' })
|
||||||
screen:expect {
|
screen:expect {
|
||||||
grid = [[
|
grid = [[
|
||||||
|
|
|
|
||||||
@@ -197,7 +209,7 @@ describe('api/buf', function()
|
|||||||
}
|
}
|
||||||
|
|
||||||
-- replacing topline keeps it the topline
|
-- replacing topline keeps it the topline
|
||||||
meths.buf_set_lines(buf, 3, 4, true, { 'wwweeee' })
|
meths.nvim_buf_set_lines(buf, 3, 4, true, { 'wwweeee' })
|
||||||
screen:expect {
|
screen:expect {
|
||||||
grid = [[
|
grid = [[
|
||||||
|
|
|
|
||||||
@@ -213,7 +225,7 @@ describe('api/buf', function()
|
|||||||
}
|
}
|
||||||
|
|
||||||
-- inserting just before topline does not scroll up if cursor would be moved
|
-- inserting just before topline does not scroll up if cursor would be moved
|
||||||
meths.buf_set_lines(buf, 3, 3, true, { 'mmm' })
|
meths.nvim_buf_set_lines(buf, 3, 3, true, { 'mmm' })
|
||||||
screen:expect {
|
screen:expect {
|
||||||
grid = [[
|
grid = [[
|
||||||
|
|
|
|
||||||
@@ -229,7 +241,7 @@ describe('api/buf', function()
|
|||||||
unchanged = true,
|
unchanged = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
meths.win_set_cursor(0, { 7, 0 })
|
meths.nvim_win_set_cursor(0, { 7, 0 })
|
||||||
screen:expect {
|
screen:expect {
|
||||||
grid = [[
|
grid = [[
|
||||||
|
|
|
|
||||||
@@ -244,7 +256,7 @@ describe('api/buf', function()
|
|||||||
]],
|
]],
|
||||||
}
|
}
|
||||||
|
|
||||||
meths.buf_set_lines(buf, 4, 4, true, { 'mmmeeeee' })
|
meths.nvim_buf_set_lines(buf, 4, 4, true, { 'mmmeeeee' })
|
||||||
screen:expect {
|
screen:expect {
|
||||||
grid = [[
|
grid = [[
|
||||||
|
|
|
|
||||||
@@ -261,11 +273,11 @@ describe('api/buf', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('of non-current window', function()
|
it('of non-current window', function()
|
||||||
local win = meths.get_current_win()
|
local win = meths.nvim_get_current_win()
|
||||||
local buf = meths.get_current_buf()
|
local buf = meths.nvim_get_current_buf()
|
||||||
|
|
||||||
command('new')
|
command('new')
|
||||||
meths.win_set_cursor(win, { 8, 0 })
|
meths.nvim_win_set_cursor(win, { 8, 0 })
|
||||||
|
|
||||||
screen:expect {
|
screen:expect {
|
||||||
grid = [[
|
grid = [[
|
||||||
@@ -281,7 +293,7 @@ describe('api/buf', function()
|
|||||||
]],
|
]],
|
||||||
}
|
}
|
||||||
|
|
||||||
meths.buf_set_lines(buf, 0, 2, true, { 'aaabbb' })
|
meths.nvim_buf_set_lines(buf, 0, 2, true, { 'aaabbb' })
|
||||||
screen:expect {
|
screen:expect {
|
||||||
grid = [[
|
grid = [[
|
||||||
^ |
|
^ |
|
||||||
@@ -297,7 +309,7 @@ describe('api/buf', function()
|
|||||||
}
|
}
|
||||||
|
|
||||||
-- replacing topline keeps it the topline
|
-- replacing topline keeps it the topline
|
||||||
meths.buf_set_lines(buf, 3, 4, true, { 'wwweeee' })
|
meths.nvim_buf_set_lines(buf, 3, 4, true, { 'wwweeee' })
|
||||||
screen:expect {
|
screen:expect {
|
||||||
grid = [[
|
grid = [[
|
||||||
^ |
|
^ |
|
||||||
@@ -313,7 +325,7 @@ describe('api/buf', function()
|
|||||||
}
|
}
|
||||||
|
|
||||||
-- inserting just before topline scrolls up
|
-- inserting just before topline scrolls up
|
||||||
meths.buf_set_lines(buf, 3, 3, true, { 'mmm' })
|
meths.nvim_buf_set_lines(buf, 3, 3, true, { 'mmm' })
|
||||||
screen:expect {
|
screen:expect {
|
||||||
grid = [[
|
grid = [[
|
||||||
^ |
|
^ |
|
||||||
@@ -330,12 +342,12 @@ describe('api/buf', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('of split windows with same buffer', function()
|
it('of split windows with same buffer', function()
|
||||||
local win = meths.get_current_win()
|
local win = meths.nvim_get_current_win()
|
||||||
local buf = meths.get_current_buf()
|
local buf = meths.nvim_get_current_buf()
|
||||||
|
|
||||||
command('split')
|
command('split')
|
||||||
meths.win_set_cursor(win, { 8, 0 })
|
meths.nvim_win_set_cursor(win, { 8, 0 })
|
||||||
meths.win_set_cursor(0, { 1, 0 })
|
meths.nvim_win_set_cursor(0, { 1, 0 })
|
||||||
|
|
||||||
screen:expect {
|
screen:expect {
|
||||||
grid = [[
|
grid = [[
|
||||||
@@ -353,7 +365,7 @@ describe('api/buf', function()
|
|||||||
|
|
|
|
||||||
]],
|
]],
|
||||||
}
|
}
|
||||||
meths.buf_set_lines(buf, 0, 2, true, { 'aaabbb' })
|
meths.nvim_buf_set_lines(buf, 0, 2, true, { 'aaabbb' })
|
||||||
|
|
||||||
screen:expect {
|
screen:expect {
|
||||||
grid = [[
|
grid = [[
|
||||||
@@ -373,7 +385,7 @@ describe('api/buf', function()
|
|||||||
}
|
}
|
||||||
|
|
||||||
-- replacing topline keeps it the topline
|
-- replacing topline keeps it the topline
|
||||||
meths.buf_set_lines(buf, 3, 4, true, { 'wwweeee' })
|
meths.nvim_buf_set_lines(buf, 3, 4, true, { 'wwweeee' })
|
||||||
screen:expect {
|
screen:expect {
|
||||||
grid = [[
|
grid = [[
|
||||||
^aaabbb |
|
^aaabbb |
|
||||||
@@ -392,7 +404,7 @@ describe('api/buf', function()
|
|||||||
}
|
}
|
||||||
|
|
||||||
-- inserting just before topline scrolls up
|
-- inserting just before topline scrolls up
|
||||||
meths.buf_set_lines(buf, 3, 3, true, { 'mmm' })
|
meths.nvim_buf_set_lines(buf, 3, 3, true, { 'mmm' })
|
||||||
screen:expect {
|
screen:expect {
|
||||||
grid = [[
|
grid = [[
|
||||||
^aaabbb |
|
^aaabbb |
|
||||||
@@ -413,15 +425,15 @@ describe('api/buf', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('handles clearing out non-current buffer #24911', function()
|
it('handles clearing out non-current buffer #24911', function()
|
||||||
local buf = meths.get_current_buf()
|
local buf = meths.nvim_get_current_buf()
|
||||||
meths.buf_set_lines(buf, 0, -1, true, { 'aaa', 'bbb', 'ccc' })
|
meths.nvim_buf_set_lines(buf, 0, -1, true, { 'aaa', 'bbb', 'ccc' })
|
||||||
command('new')
|
command('new')
|
||||||
|
|
||||||
meths.buf_set_lines(0, 0, -1, true, { 'xxx', 'yyy', 'zzz' })
|
meths.nvim_buf_set_lines(0, 0, -1, true, { 'xxx', 'yyy', 'zzz' })
|
||||||
|
|
||||||
meths.buf_set_lines(buf, 0, -1, true, {})
|
meths.nvim_buf_set_lines(buf, 0, -1, true, {})
|
||||||
eq({ 'xxx', 'yyy', 'zzz' }, meths.buf_get_lines(0, 0, -1, true))
|
eq({ 'xxx', 'yyy', 'zzz' }, meths.nvim_buf_get_lines(0, 0, -1, true))
|
||||||
eq({ '' }, meths.buf_get_lines(buf, 0, -1, true))
|
eq({ '' }, meths.nvim_buf_get_lines(buf, 0, -1, true))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -676,7 +688,7 @@ describe('api/buf', function()
|
|||||||
Who would win?
|
Who would win?
|
||||||
A real window
|
A real window
|
||||||
with proper text]])
|
with proper text]])
|
||||||
local buf = api.meths.create_buf(false, true)
|
local buf = api.meths.nvim_create_buf(false, true)
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
Who would win? |
|
Who would win? |
|
||||||
A real window |
|
A real window |
|
||||||
@@ -685,7 +697,7 @@ describe('api/buf', function()
|
|||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
api.meths.buf_set_lines(buf, 0, -1, true, { 'or some', 'scratchy text' })
|
api.meths.nvim_buf_set_lines(buf, 0, -1, true, { 'or some', 'scratchy text' })
|
||||||
feed('i') -- provoke redraw
|
feed('i') -- provoke redraw
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
Who would win? |
|
Who would win? |
|
||||||
@@ -701,22 +713,22 @@ describe('api/buf', function()
|
|||||||
visible buffer line 1
|
visible buffer line 1
|
||||||
line 2
|
line 2
|
||||||
]])
|
]])
|
||||||
local hiddenbuf = api.meths.create_buf(false, true)
|
local hiddenbuf = api.meths.nvim_create_buf(false, true)
|
||||||
command('vsplit')
|
command('vsplit')
|
||||||
command('vsplit')
|
command('vsplit')
|
||||||
feed('<c-w>l<c-w>l<c-w>l')
|
feed('<c-w>l<c-w>l<c-w>l')
|
||||||
eq(3, funcs.winnr())
|
eq(3, funcs.winnr())
|
||||||
feed('<c-w>h')
|
feed('<c-w>h')
|
||||||
eq(2, funcs.winnr())
|
eq(2, funcs.winnr())
|
||||||
api.meths.buf_set_lines(hiddenbuf, 0, -1, true, { 'hidden buffer line 1', 'line 2' })
|
api.meths.nvim_buf_set_lines(hiddenbuf, 0, -1, true, { 'hidden buffer line 1', 'line 2' })
|
||||||
feed('<c-w>p')
|
feed('<c-w>p')
|
||||||
eq(3, funcs.winnr())
|
eq(3, funcs.winnr())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('set_lines on unloaded buffer #8659 #22670', function()
|
it('set_lines on unloaded buffer #8659 #22670', function()
|
||||||
local bufnr = curbuf('get_number')
|
local bufnr = curbuf('get_number')
|
||||||
meths.buf_set_lines(bufnr, 0, -1, false, { 'a', 'b', 'c' })
|
meths.nvim_buf_set_lines(bufnr, 0, -1, false, { 'a', 'b', 'c' })
|
||||||
meths.buf_set_name(bufnr, 'set_lines')
|
meths.nvim_buf_set_name(bufnr, 'set_lines')
|
||||||
finally(function()
|
finally(function()
|
||||||
os.remove('set_lines')
|
os.remove('set_lines')
|
||||||
end)
|
end)
|
||||||
@@ -724,8 +736,8 @@ describe('api/buf', function()
|
|||||||
command('new')
|
command('new')
|
||||||
command('bunload! ' .. bufnr)
|
command('bunload! ' .. bufnr)
|
||||||
local new_bufnr = funcs.bufnr('set_lines', true)
|
local new_bufnr = funcs.bufnr('set_lines', true)
|
||||||
meths.buf_set_lines(new_bufnr, 0, -1, false, {})
|
meths.nvim_buf_set_lines(new_bufnr, 0, -1, false, {})
|
||||||
eq({ '' }, meths.buf_get_lines(new_bufnr, 0, -1, false))
|
eq({ '' }, meths.nvim_buf_get_lines(new_bufnr, 0, -1, false))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -822,18 +834,18 @@ describe('api/buf', function()
|
|||||||
hello world!]])
|
hello world!]])
|
||||||
|
|
||||||
-- position the cursor on `!`
|
-- position the cursor on `!`
|
||||||
meths.win_set_cursor(0, { 1, 11 })
|
meths.nvim_win_set_cursor(0, { 1, 11 })
|
||||||
|
|
||||||
local win = meths.get_current_win()
|
local win = meths.nvim_get_current_win()
|
||||||
local buf = meths.get_current_buf()
|
local buf = meths.nvim_get_current_buf()
|
||||||
|
|
||||||
command('new')
|
command('new')
|
||||||
|
|
||||||
-- replace 'world' with 'foo'
|
-- replace 'world' with 'foo'
|
||||||
meths.buf_set_text(buf, 0, 6, 0, 11, { 'foo' })
|
meths.nvim_buf_set_text(buf, 0, 6, 0, 11, { 'foo' })
|
||||||
eq({ 'hello foo!' }, meths.buf_get_lines(buf, 0, -1, true))
|
eq({ 'hello foo!' }, meths.nvim_buf_get_lines(buf, 0, -1, true))
|
||||||
-- cursor should be moved left by two columns (replacement is shorter by 2 chars)
|
-- cursor should be moved left by two columns (replacement is shorter by 2 chars)
|
||||||
eq({ 1, 9 }, meths.win_get_cursor(win))
|
eq({ 1, 9 }, meths.nvim_win_get_cursor(win))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('updates the cursor position in TWO non-current windows', function()
|
it('updates the cursor position in TWO non-current windows', function()
|
||||||
@@ -841,24 +853,24 @@ describe('api/buf', function()
|
|||||||
hello world!]])
|
hello world!]])
|
||||||
|
|
||||||
-- position the cursor on `!`
|
-- position the cursor on `!`
|
||||||
meths.win_set_cursor(0, { 1, 11 })
|
meths.nvim_win_set_cursor(0, { 1, 11 })
|
||||||
local win = meths.get_current_win()
|
local win = meths.nvim_get_current_win()
|
||||||
local buf = meths.get_current_buf()
|
local buf = meths.nvim_get_current_buf()
|
||||||
|
|
||||||
command('split')
|
command('split')
|
||||||
local win2 = meths.get_current_win()
|
local win2 = meths.nvim_get_current_win()
|
||||||
-- position the cursor on `w`
|
-- position the cursor on `w`
|
||||||
meths.win_set_cursor(0, { 1, 6 })
|
meths.nvim_win_set_cursor(0, { 1, 6 })
|
||||||
|
|
||||||
command('new')
|
command('new')
|
||||||
|
|
||||||
-- replace 'hello' with 'foo'
|
-- replace 'hello' with 'foo'
|
||||||
meths.buf_set_text(buf, 0, 0, 0, 5, { 'foo' })
|
meths.nvim_buf_set_text(buf, 0, 0, 0, 5, { 'foo' })
|
||||||
eq({ 'foo world!' }, meths.buf_get_lines(buf, 0, -1, true))
|
eq({ 'foo world!' }, meths.nvim_buf_get_lines(buf, 0, -1, true))
|
||||||
|
|
||||||
-- both cursors should be moved left by two columns (replacement is shorter by 2 chars)
|
-- both cursors should be moved left by two columns (replacement is shorter by 2 chars)
|
||||||
eq({ 1, 9 }, meths.win_get_cursor(win))
|
eq({ 1, 9 }, meths.nvim_win_get_cursor(win))
|
||||||
eq({ 1, 4 }, meths.win_get_cursor(win2))
|
eq({ 1, 4 }, meths.nvim_win_get_cursor(win2))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('when text is being added right at cursor position #22526', function()
|
describe('when text is being added right at cursor position #22526', function()
|
||||||
@@ -1693,7 +1705,7 @@ describe('api/buf', function()
|
|||||||
it('no heap-use-after-free when called consecutively #19643', function()
|
it('no heap-use-after-free when called consecutively #19643', function()
|
||||||
set_text(0, 0, 0, 0, { 'one', '', '', 'two' })
|
set_text(0, 0, 0, 0, { 'one', '', '', 'two' })
|
||||||
eq({ 'one', '', '', 'two' }, get_lines(0, 4, true))
|
eq({ 'one', '', '', 'two' }, get_lines(0, 4, true))
|
||||||
meths.win_set_cursor(0, { 1, 0 })
|
meths.nvim_win_set_cursor(0, { 1, 0 })
|
||||||
exec_lua([[
|
exec_lua([[
|
||||||
vim.api.nvim_buf_set_text(0, 0, 3, 1, 0, {''})
|
vim.api.nvim_buf_set_text(0, 0, 3, 1, 0, {''})
|
||||||
vim.api.nvim_buf_set_text(0, 0, 3, 1, 0, {''})
|
vim.api.nvim_buf_set_text(0, 0, 3, 1, 0, {''})
|
||||||
@@ -1711,16 +1723,22 @@ describe('api/buf', function()
|
|||||||
[3] = { reverse = true },
|
[3] = { reverse = true },
|
||||||
}
|
}
|
||||||
screen:attach()
|
screen:attach()
|
||||||
meths.buf_set_lines(0, 0, -1, 1, { 'aaa', 'bbb', 'ccc', 'ddd', 'www', 'xxx', 'yyy', 'zzz' })
|
meths.nvim_buf_set_lines(
|
||||||
meths.set_option_value('modified', false, {})
|
0,
|
||||||
|
0,
|
||||||
|
-1,
|
||||||
|
1,
|
||||||
|
{ 'aaa', 'bbb', 'ccc', 'ddd', 'www', 'xxx', 'yyy', 'zzz' }
|
||||||
|
)
|
||||||
|
meths.nvim_set_option_value('modified', false, {})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('of current window', function()
|
it('of current window', function()
|
||||||
local win = meths.get_current_win()
|
local win = meths.nvim_get_current_win()
|
||||||
local buf = meths.get_current_buf()
|
local buf = meths.nvim_get_current_buf()
|
||||||
|
|
||||||
command('new | wincmd w')
|
command('new | wincmd w')
|
||||||
meths.win_set_cursor(win, { 8, 0 })
|
meths.nvim_win_set_cursor(win, { 8, 0 })
|
||||||
|
|
||||||
screen:expect {
|
screen:expect {
|
||||||
grid = [[
|
grid = [[
|
||||||
@@ -1735,7 +1753,7 @@ describe('api/buf', function()
|
|||||||
|
|
|
|
||||||
]],
|
]],
|
||||||
}
|
}
|
||||||
meths.buf_set_text(buf, 0, 3, 1, 0, { 'X' })
|
meths.nvim_buf_set_text(buf, 0, 3, 1, 0, { 'X' })
|
||||||
|
|
||||||
screen:expect {
|
screen:expect {
|
||||||
grid = [[
|
grid = [[
|
||||||
@@ -1753,11 +1771,11 @@ describe('api/buf', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('of non-current window', function()
|
it('of non-current window', function()
|
||||||
local win = meths.get_current_win()
|
local win = meths.nvim_get_current_win()
|
||||||
local buf = meths.get_current_buf()
|
local buf = meths.nvim_get_current_buf()
|
||||||
|
|
||||||
command('new')
|
command('new')
|
||||||
meths.win_set_cursor(win, { 8, 0 })
|
meths.nvim_win_set_cursor(win, { 8, 0 })
|
||||||
|
|
||||||
screen:expect {
|
screen:expect {
|
||||||
grid = [[
|
grid = [[
|
||||||
@@ -1773,7 +1791,7 @@ describe('api/buf', function()
|
|||||||
]],
|
]],
|
||||||
}
|
}
|
||||||
|
|
||||||
meths.buf_set_text(buf, 0, 3, 1, 0, { 'X' })
|
meths.nvim_buf_set_text(buf, 0, 3, 1, 0, { 'X' })
|
||||||
screen:expect {
|
screen:expect {
|
||||||
grid = [[
|
grid = [[
|
||||||
^ |
|
^ |
|
||||||
@@ -1790,12 +1808,12 @@ describe('api/buf', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('of split windows with same buffer', function()
|
it('of split windows with same buffer', function()
|
||||||
local win = meths.get_current_win()
|
local win = meths.nvim_get_current_win()
|
||||||
local buf = meths.get_current_buf()
|
local buf = meths.nvim_get_current_buf()
|
||||||
|
|
||||||
command('split')
|
command('split')
|
||||||
meths.win_set_cursor(win, { 8, 0 })
|
meths.nvim_win_set_cursor(win, { 8, 0 })
|
||||||
meths.win_set_cursor(0, { 1, 1 })
|
meths.nvim_win_set_cursor(0, { 1, 1 })
|
||||||
|
|
||||||
screen:expect {
|
screen:expect {
|
||||||
grid = [[
|
grid = [[
|
||||||
@@ -1813,7 +1831,7 @@ describe('api/buf', function()
|
|||||||
|
|
|
|
||||||
]],
|
]],
|
||||||
}
|
}
|
||||||
meths.buf_set_text(buf, 0, 3, 1, 0, { 'X' })
|
meths.nvim_buf_set_text(buf, 0, 3, 1, 0, { 'X' })
|
||||||
|
|
||||||
screen:expect {
|
screen:expect {
|
||||||
grid = [[
|
grid = [[
|
||||||
@@ -1861,7 +1879,7 @@ describe('api/buf', function()
|
|||||||
eq('Index out of bounds', pcall_err(get_text, 0, 0, 3, 0, {}))
|
eq('Index out of bounds', pcall_err(get_text, 0, 0, 3, 0, {}))
|
||||||
eq('Index out of bounds', pcall_err(get_text, 0, 0, -4, 0, {}))
|
eq('Index out of bounds', pcall_err(get_text, 0, 0, -4, 0, {}))
|
||||||
-- no ml_get errors should happen #19017
|
-- no ml_get errors should happen #19017
|
||||||
eq('', meths.get_vvar('errmsg'))
|
eq('', meths.nvim_get_vvar('errmsg'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('errors when start is greater than end', function()
|
it('errors when start is greater than end', function()
|
||||||
@@ -1884,19 +1902,19 @@ describe('api/buf', function()
|
|||||||
eq('Index out of bounds', pcall_err(get_offset, 6))
|
eq('Index out of bounds', pcall_err(get_offset, 6))
|
||||||
eq('Index out of bounds', pcall_err(get_offset, -1))
|
eq('Index out of bounds', pcall_err(get_offset, -1))
|
||||||
|
|
||||||
meths.set_option_value('eol', false, {})
|
meths.nvim_set_option_value('eol', false, {})
|
||||||
meths.set_option_value('fixeol', false, {})
|
meths.nvim_set_option_value('fixeol', false, {})
|
||||||
eq(28, get_offset(5))
|
eq(28, get_offset(5))
|
||||||
|
|
||||||
-- fileformat is ignored
|
-- fileformat is ignored
|
||||||
meths.set_option_value('fileformat', 'dos', {})
|
meths.nvim_set_option_value('fileformat', 'dos', {})
|
||||||
eq(0, get_offset(0))
|
eq(0, get_offset(0))
|
||||||
eq(6, get_offset(1))
|
eq(6, get_offset(1))
|
||||||
eq(15, get_offset(2))
|
eq(15, get_offset(2))
|
||||||
eq(16, get_offset(3))
|
eq(16, get_offset(3))
|
||||||
eq(24, get_offset(4))
|
eq(24, get_offset(4))
|
||||||
eq(28, get_offset(5))
|
eq(28, get_offset(5))
|
||||||
meths.set_option_value('eol', true, {})
|
meths.nvim_set_option_value('eol', true, {})
|
||||||
eq(29, get_offset(5))
|
eq(29, get_offset(5))
|
||||||
|
|
||||||
command('set hidden')
|
command('set hidden')
|
||||||
@@ -2077,7 +2095,7 @@ describe('api/buf', function()
|
|||||||
eq(false, pcall(curbufmeths.set_mark, 'fail', 1, 0, {}))
|
eq(false, pcall(curbufmeths.set_mark, 'fail', 1, 0, {}))
|
||||||
end)
|
end)
|
||||||
it('fails when invalid buffer number is used', function()
|
it('fails when invalid buffer number is used', function()
|
||||||
eq(false, pcall(meths.buf_set_mark, 99, 'a', 1, 1, {}))
|
eq(false, pcall(meths.nvim_buf_set_mark, 99, 'a', 1, 1, {}))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -2095,7 +2113,7 @@ describe('api/buf', function()
|
|||||||
eq({ 0, 0 }, curbufmeths.get_mark('Z'))
|
eq({ 0, 0 }, curbufmeths.get_mark('Z'))
|
||||||
end)
|
end)
|
||||||
it('returns false in marks not set in this buffer', function()
|
it('returns false in marks not set in this buffer', function()
|
||||||
local abuf = meths.create_buf(false, true)
|
local abuf = meths.nvim_create_buf(false, true)
|
||||||
bufmeths.set_lines(abuf, -1, -1, true, { 'a', 'bit of', 'text' })
|
bufmeths.set_lines(abuf, -1, -1, true, { 'a', 'bit of', 'text' })
|
||||||
bufmeths.set_mark(abuf, 'A', 2, 2, {})
|
bufmeths.set_mark(abuf, 'A', 2, 2, {})
|
||||||
eq(false, curbufmeths.del_mark('A'))
|
eq(false, curbufmeths.del_mark('A'))
|
||||||
@@ -2112,7 +2130,7 @@ describe('api/buf', function()
|
|||||||
eq(false, pcall(curbufmeths.del_mark, 'fail'))
|
eq(false, pcall(curbufmeths.del_mark, 'fail'))
|
||||||
end)
|
end)
|
||||||
it('fails when invalid buffer number is used', function()
|
it('fails when invalid buffer number is used', function()
|
||||||
eq(false, pcall(meths.buf_del_mark, 99, 'a'))
|
eq(false, pcall(meths.nvim_buf_del_mark, 99, 'a'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
@@ -51,24 +51,24 @@ describe('nvim_get_commands', function()
|
|||||||
before_each(clear)
|
before_each(clear)
|
||||||
|
|
||||||
it('gets empty list if no commands were defined', function()
|
it('gets empty list if no commands were defined', function()
|
||||||
eq({}, meths.get_commands({ builtin = false }))
|
eq({}, meths.nvim_get_commands({ builtin = false }))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('validation', function()
|
it('validation', function()
|
||||||
eq('builtin=true not implemented', pcall_err(meths.get_commands, { builtin = true }))
|
eq('builtin=true not implemented', pcall_err(meths.nvim_get_commands, { builtin = true }))
|
||||||
eq("Invalid key: 'foo'", pcall_err(meths.get_commands, { foo = 'blah' }))
|
eq("Invalid key: 'foo'", pcall_err(meths.nvim_get_commands, { foo = 'blah' }))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('gets global user-defined commands', function()
|
it('gets global user-defined commands', function()
|
||||||
-- Define a command.
|
-- Define a command.
|
||||||
command('command -nargs=1 Hello echo "Hello World"')
|
command('command -nargs=1 Hello echo "Hello World"')
|
||||||
eq({ Hello = cmd_dict }, meths.get_commands({ builtin = false }))
|
eq({ Hello = cmd_dict }, meths.nvim_get_commands({ builtin = false }))
|
||||||
-- Define another command.
|
-- Define another command.
|
||||||
command('command -nargs=? Pwd pwd')
|
command('command -nargs=? Pwd pwd')
|
||||||
eq({ Hello = cmd_dict, Pwd = cmd_dict2 }, meths.get_commands({ builtin = false }))
|
eq({ Hello = cmd_dict, Pwd = cmd_dict2 }, meths.nvim_get_commands({ builtin = false }))
|
||||||
-- Delete a command.
|
-- Delete a command.
|
||||||
command('delcommand Pwd')
|
command('delcommand Pwd')
|
||||||
eq({ Hello = cmd_dict }, meths.get_commands({ builtin = false }))
|
eq({ Hello = cmd_dict }, meths.nvim_get_commands({ builtin = false }))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('gets buffer-local user-defined commands', function()
|
it('gets buffer-local user-defined commands', function()
|
||||||
@@ -171,9 +171,9 @@ describe('nvim_get_commands', function()
|
|||||||
let s:foo = 1
|
let s:foo = 1
|
||||||
command -complete=custom,ListUsers -nargs=+ Finger !finger <args>
|
command -complete=custom,ListUsers -nargs=+ Finger !finger <args>
|
||||||
]])
|
]])
|
||||||
eq({ Finger = cmd1 }, meths.get_commands({ builtin = false }))
|
eq({ Finger = cmd1 }, meths.nvim_get_commands({ builtin = false }))
|
||||||
command('command -nargs=1 -complete=dir -addr=arguments -count=10 TestCmd pwd <args>')
|
command('command -nargs=1 -complete=dir -addr=arguments -count=10 TestCmd pwd <args>')
|
||||||
eq({ Finger = cmd1, TestCmd = cmd0 }, meths.get_commands({ builtin = false }))
|
eq({ Finger = cmd1, TestCmd = cmd0 }, meths.nvim_get_commands({ builtin = false }))
|
||||||
|
|
||||||
source([[
|
source([[
|
||||||
function! s:foo() abort
|
function! s:foo() abort
|
||||||
@@ -193,7 +193,7 @@ describe('nvim_get_commands', function()
|
|||||||
-- TODO(justinmk): Order is stable but undefined. Sort before return?
|
-- TODO(justinmk): Order is stable but undefined. Sort before return?
|
||||||
eq(
|
eq(
|
||||||
{ Cmd2 = cmd2, Cmd3 = cmd3, Cmd4 = cmd4, Finger = cmd1, TestCmd = cmd0 },
|
{ Cmd2 = cmd2, Cmd3 = cmd3, Cmd4 = cmd4, Finger = cmd1, TestCmd = cmd0 },
|
||||||
meths.get_commands({ builtin = false })
|
meths.nvim_get_commands({ builtin = false })
|
||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
@@ -202,9 +202,9 @@ describe('nvim_create_user_command', function()
|
|||||||
before_each(clear)
|
before_each(clear)
|
||||||
|
|
||||||
it('works with strings', function()
|
it('works with strings', function()
|
||||||
meths.create_user_command('SomeCommand', 'let g:command_fired = <args>', { nargs = 1 })
|
meths.nvim_create_user_command('SomeCommand', 'let g:command_fired = <args>', { nargs = 1 })
|
||||||
meths.command('SomeCommand 42')
|
meths.nvim_command('SomeCommand 42')
|
||||||
eq(42, meths.eval('g:command_fired'))
|
eq(42, meths.nvim_eval('g:command_fired'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('works with Lua functions', function()
|
it('works with Lua functions', function()
|
||||||
@@ -646,11 +646,11 @@ describe('nvim_create_user_command', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('can define buffer-local commands', function()
|
it('can define buffer-local commands', function()
|
||||||
local bufnr = meths.create_buf(false, false)
|
local bufnr = meths.nvim_create_buf(false, false)
|
||||||
bufmeths.create_user_command(bufnr, 'Hello', '', {})
|
bufmeths.create_user_command(bufnr, 'Hello', '', {})
|
||||||
matches('Not an editor command: Hello', pcall_err(meths.command, 'Hello'))
|
matches('Not an editor command: Hello', pcall_err(meths.nvim_command, 'Hello'))
|
||||||
meths.set_current_buf(bufnr)
|
meths.nvim_set_current_buf(bufnr)
|
||||||
meths.command('Hello')
|
meths.nvim_command('Hello')
|
||||||
assert_alive()
|
assert_alive()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -731,28 +731,28 @@ describe('nvim_create_user_command', function()
|
|||||||
vim.api.nvim_cmd({ cmd = 'echo', args = { '&verbose' }, mods = opts.smods }, {})
|
vim.api.nvim_cmd({ cmd = 'echo', args = { '&verbose' }, mods = opts.smods }, {})
|
||||||
end, {})
|
end, {})
|
||||||
]]
|
]]
|
||||||
eq('3', meths.cmd({ cmd = 'MyEcho', mods = { verbose = 3 } }, { output = true }))
|
eq('3', meths.nvim_cmd({ cmd = 'MyEcho', mods = { verbose = 3 } }, { output = true }))
|
||||||
|
|
||||||
eq(1, #meths.list_tabpages())
|
eq(1, #meths.nvim_list_tabpages())
|
||||||
exec_lua [[
|
exec_lua [[
|
||||||
vim.api.nvim_create_user_command('MySplit', function(opts)
|
vim.api.nvim_create_user_command('MySplit', function(opts)
|
||||||
vim.api.nvim_cmd({ cmd = 'split', mods = opts.smods }, {})
|
vim.api.nvim_cmd({ cmd = 'split', mods = opts.smods }, {})
|
||||||
end, {})
|
end, {})
|
||||||
]]
|
]]
|
||||||
meths.cmd({ cmd = 'MySplit' }, {})
|
meths.nvim_cmd({ cmd = 'MySplit' }, {})
|
||||||
eq(1, #meths.list_tabpages())
|
eq(1, #meths.nvim_list_tabpages())
|
||||||
eq(2, #meths.list_wins())
|
eq(2, #meths.nvim_list_wins())
|
||||||
meths.cmd({ cmd = 'MySplit', mods = { tab = 1 } }, {})
|
meths.nvim_cmd({ cmd = 'MySplit', mods = { tab = 1 } }, {})
|
||||||
eq(2, #meths.list_tabpages())
|
eq(2, #meths.nvim_list_tabpages())
|
||||||
eq(2, funcs.tabpagenr())
|
eq(2, funcs.tabpagenr())
|
||||||
meths.cmd({ cmd = 'MySplit', mods = { tab = 1 } }, {})
|
meths.nvim_cmd({ cmd = 'MySplit', mods = { tab = 1 } }, {})
|
||||||
eq(3, #meths.list_tabpages())
|
eq(3, #meths.nvim_list_tabpages())
|
||||||
eq(2, funcs.tabpagenr())
|
eq(2, funcs.tabpagenr())
|
||||||
meths.cmd({ cmd = 'MySplit', mods = { tab = 3 } }, {})
|
meths.nvim_cmd({ cmd = 'MySplit', mods = { tab = 3 } }, {})
|
||||||
eq(4, #meths.list_tabpages())
|
eq(4, #meths.nvim_list_tabpages())
|
||||||
eq(4, funcs.tabpagenr())
|
eq(4, funcs.tabpagenr())
|
||||||
meths.cmd({ cmd = 'MySplit', mods = { tab = 0 } }, {})
|
meths.nvim_cmd({ cmd = 'MySplit', mods = { tab = 0 } }, {})
|
||||||
eq(5, #meths.list_tabpages())
|
eq(5, #meths.nvim_list_tabpages())
|
||||||
eq(1, funcs.tabpagenr())
|
eq(1, funcs.tabpagenr())
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
@@ -761,16 +761,16 @@ describe('nvim_del_user_command', function()
|
|||||||
before_each(clear)
|
before_each(clear)
|
||||||
|
|
||||||
it('can delete global commands', function()
|
it('can delete global commands', function()
|
||||||
meths.create_user_command('Hello', 'echo "Hi"', {})
|
meths.nvim_create_user_command('Hello', 'echo "Hi"', {})
|
||||||
meths.command('Hello')
|
meths.nvim_command('Hello')
|
||||||
meths.del_user_command('Hello')
|
meths.nvim_del_user_command('Hello')
|
||||||
matches('Not an editor command: Hello', pcall_err(meths.command, 'Hello'))
|
matches('Not an editor command: Hello', pcall_err(meths.nvim_command, 'Hello'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('can delete buffer-local commands', function()
|
it('can delete buffer-local commands', function()
|
||||||
bufmeths.create_user_command(0, 'Hello', 'echo "Hi"', {})
|
bufmeths.create_user_command(0, 'Hello', 'echo "Hi"', {})
|
||||||
meths.command('Hello')
|
meths.nvim_command('Hello')
|
||||||
bufmeths.del_user_command(0, 'Hello')
|
bufmeths.del_user_command(0, 'Hello')
|
||||||
matches('Not an editor command: Hello', pcall_err(meths.command, 'Hello'))
|
matches('Not an editor command: Hello', pcall_err(meths.nvim_command, 'Hello'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
@@ -1472,7 +1472,7 @@ describe('API/extmarks', function()
|
|||||||
|
|
||||||
it('in read-only buffer', function()
|
it('in read-only buffer', function()
|
||||||
command('view! runtime/doc/help.txt')
|
command('view! runtime/doc/help.txt')
|
||||||
eq(true, meths.get_option_value('ro', {}))
|
eq(true, meths.nvim_get_option_value('ro', {}))
|
||||||
local id = set_extmark(ns, 0, 0, 2)
|
local id = set_extmark(ns, 0, 0, 2)
|
||||||
eq({ { id, 0, 2 } }, get_extmarks(ns, 0, -1))
|
eq({ { id, 0, 2 } }, get_extmarks(ns, 0, -1))
|
||||||
end)
|
end)
|
||||||
@@ -1512,7 +1512,7 @@ describe('API/extmarks', function()
|
|||||||
curbufmeths.set_text(0, 0, 0, 17, {})
|
curbufmeths.set_text(0, 0, 0, 17, {})
|
||||||
|
|
||||||
-- handles set_text correctly as well
|
-- handles set_text correctly as well
|
||||||
eq({ { 1, 0, 0 }, { 2, 0, 0 } }, meths.buf_get_extmarks(0, ns, 0, -1, {}))
|
eq({ { 1, 0, 0 }, { 2, 0, 0 } }, meths.nvim_buf_get_extmarks(0, ns, 0, -1, {}))
|
||||||
curbufmeths.set_text(0, 0, 0, 0, { 'asdfasdf' })
|
curbufmeths.set_text(0, 0, 0, 0, { 'asdfasdf' })
|
||||||
eq({ { 1, 0, 0 }, { 2, 0, 8 } }, curbufmeths.get_extmarks(ns, 0, -1, {}))
|
eq({ { 1, 0, 0 }, { 2, 0, 8 } }, curbufmeths.get_extmarks(ns, 0, -1, {}))
|
||||||
|
|
||||||
@@ -1520,7 +1520,7 @@ describe('API/extmarks', function()
|
|||||||
-- handles pasting
|
-- handles pasting
|
||||||
exec([[let @a='asdfasdf']])
|
exec([[let @a='asdfasdf']])
|
||||||
feed([["ap]])
|
feed([["ap]])
|
||||||
eq({ { 1, 0, 0 }, { 2, 0, 8 } }, meths.buf_get_extmarks(0, ns, 0, -1, {}))
|
eq({ { 1, 0, 0 }, { 2, 0, 8 } }, meths.nvim_buf_get_extmarks(0, ns, 0, -1, {}))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('can accept "end_row" or "end_line" #16548', function()
|
it('can accept "end_row" or "end_line" #16548', function()
|
||||||
@@ -1547,7 +1547,7 @@ describe('API/extmarks', function()
|
|||||||
it('in prompt buffer', function()
|
it('in prompt buffer', function()
|
||||||
feed('dd')
|
feed('dd')
|
||||||
local id = set_extmark(ns, marks[1], 0, 0, {})
|
local id = set_extmark(ns, marks[1], 0, 0, {})
|
||||||
meths.set_option_value('buftype', 'prompt', {})
|
meths.nvim_set_option_value('buftype', 'prompt', {})
|
||||||
feed('i<esc>')
|
feed('i<esc>')
|
||||||
eq({ { id, 0, 2 } }, get_extmarks(ns, 0, -1))
|
eq({ { id, 0, 2 } }, get_extmarks(ns, 0, -1))
|
||||||
end)
|
end)
|
||||||
@@ -1695,7 +1695,7 @@ describe('API/extmarks', function()
|
|||||||
screen = Screen.new(40, 6)
|
screen = Screen.new(40, 6)
|
||||||
screen:attach()
|
screen:attach()
|
||||||
feed('dd6iaaa bbb ccc<CR><ESC>gg')
|
feed('dd6iaaa bbb ccc<CR><ESC>gg')
|
||||||
meths.set_option_value('signcolumn', 'auto:2', {})
|
meths.nvim_set_option_value('signcolumn', 'auto:2', {})
|
||||||
set_extmark(ns, 1, 0, 0, { invalidate = true, sign_text = 'S1', end_row = 1 })
|
set_extmark(ns, 1, 0, 0, { invalidate = true, sign_text = 'S1', end_row = 1 })
|
||||||
set_extmark(ns, 2, 1, 0, { invalidate = true, sign_text = 'S2', end_row = 2 })
|
set_extmark(ns, 2, 1, 0, { invalidate = true, sign_text = 'S2', end_row = 2 })
|
||||||
-- mark with invalidate is removed
|
-- mark with invalidate is removed
|
||||||
|
@@ -59,7 +59,7 @@ describe('API: highlight', function()
|
|||||||
eq(expected_rgb, nvim('get_hl_by_id', hl_id, true))
|
eq(expected_rgb, nvim('get_hl_by_id', hl_id, true))
|
||||||
|
|
||||||
-- Test invalid id.
|
-- Test invalid id.
|
||||||
eq('Invalid highlight id: 30000', pcall_err(meths.get_hl_by_id, 30000, false))
|
eq('Invalid highlight id: 30000', pcall_err(meths.nvim_get_hl_by_id, 30000, false))
|
||||||
|
|
||||||
-- Test all highlight properties.
|
-- Test all highlight properties.
|
||||||
command('hi NewHighlight gui=underline,bold,italic,reverse,strikethrough,altfont,nocombine')
|
command('hi NewHighlight gui=underline,bold,italic,reverse,strikethrough,altfont,nocombine')
|
||||||
@@ -72,30 +72,30 @@ describe('API: highlight', function()
|
|||||||
-- Test nil argument.
|
-- Test nil argument.
|
||||||
eq(
|
eq(
|
||||||
'Wrong type for argument 1 when calling nvim_get_hl_by_id, expecting Integer',
|
'Wrong type for argument 1 when calling nvim_get_hl_by_id, expecting Integer',
|
||||||
pcall_err(meths.get_hl_by_id, { nil }, false)
|
pcall_err(meths.nvim_get_hl_by_id, { nil }, false)
|
||||||
)
|
)
|
||||||
|
|
||||||
-- Test 0 argument.
|
-- Test 0 argument.
|
||||||
eq('Invalid highlight id: 0', pcall_err(meths.get_hl_by_id, 0, false))
|
eq('Invalid highlight id: 0', pcall_err(meths.nvim_get_hl_by_id, 0, false))
|
||||||
|
|
||||||
-- Test -1 argument.
|
-- Test -1 argument.
|
||||||
eq('Invalid highlight id: -1', pcall_err(meths.get_hl_by_id, -1, false))
|
eq('Invalid highlight id: -1', pcall_err(meths.nvim_get_hl_by_id, -1, false))
|
||||||
|
|
||||||
-- Test highlight group without ctermbg value.
|
-- Test highlight group without ctermbg value.
|
||||||
command('hi Normal ctermfg=red ctermbg=yellow')
|
command('hi Normal ctermfg=red ctermbg=yellow')
|
||||||
command('hi NewConstant ctermfg=green guifg=white guibg=blue')
|
command('hi NewConstant ctermfg=green guifg=white guibg=blue')
|
||||||
hl_id = eval("hlID('NewConstant')")
|
hl_id = eval("hlID('NewConstant')")
|
||||||
eq({ foreground = 10 }, meths.get_hl_by_id(hl_id, false))
|
eq({ foreground = 10 }, meths.nvim_get_hl_by_id(hl_id, false))
|
||||||
|
|
||||||
-- Test highlight group without ctermfg value.
|
-- Test highlight group without ctermfg value.
|
||||||
command('hi clear NewConstant')
|
command('hi clear NewConstant')
|
||||||
command('hi NewConstant ctermbg=Magenta guifg=white guibg=blue')
|
command('hi NewConstant ctermbg=Magenta guifg=white guibg=blue')
|
||||||
eq({ background = 13 }, meths.get_hl_by_id(hl_id, false))
|
eq({ background = 13 }, meths.nvim_get_hl_by_id(hl_id, false))
|
||||||
|
|
||||||
-- Test highlight group with ctermfg and ctermbg values.
|
-- Test highlight group with ctermfg and ctermbg values.
|
||||||
command('hi clear NewConstant')
|
command('hi clear NewConstant')
|
||||||
command('hi NewConstant ctermfg=green ctermbg=Magenta guifg=white guibg=blue')
|
command('hi NewConstant ctermfg=green ctermbg=Magenta guifg=white guibg=blue')
|
||||||
eq({ foreground = 10, background = 13 }, meths.get_hl_by_id(hl_id, false))
|
eq({ foreground = 10, background = 13 }, meths.nvim_get_hl_by_id(hl_id, false))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('nvim_get_hl_by_name', function()
|
it('nvim_get_hl_by_name', function()
|
||||||
@@ -114,28 +114,28 @@ describe('API: highlight', function()
|
|||||||
-- Test invalid name.
|
-- Test invalid name.
|
||||||
eq(
|
eq(
|
||||||
"Invalid highlight name: 'unknown_highlight'",
|
"Invalid highlight name: 'unknown_highlight'",
|
||||||
pcall_err(meths.get_hl_by_name, 'unknown_highlight', false)
|
pcall_err(meths.nvim_get_hl_by_name, 'unknown_highlight', false)
|
||||||
)
|
)
|
||||||
|
|
||||||
-- Test nil argument.
|
-- Test nil argument.
|
||||||
eq(
|
eq(
|
||||||
'Wrong type for argument 1 when calling nvim_get_hl_by_name, expecting String',
|
'Wrong type for argument 1 when calling nvim_get_hl_by_name, expecting String',
|
||||||
pcall_err(meths.get_hl_by_name, { nil }, false)
|
pcall_err(meths.nvim_get_hl_by_name, { nil }, false)
|
||||||
)
|
)
|
||||||
|
|
||||||
-- Test empty string argument.
|
-- Test empty string argument.
|
||||||
eq('Invalid highlight name', pcall_err(meths.get_hl_by_name, '', false))
|
eq('Invalid highlight name', pcall_err(meths.nvim_get_hl_by_name, '', false))
|
||||||
|
|
||||||
-- Test "standout" attribute. #8054
|
-- Test "standout" attribute. #8054
|
||||||
eq({ underline = true }, meths.get_hl_by_name('cursorline', 0))
|
eq({ underline = true }, meths.nvim_get_hl_by_name('cursorline', 0))
|
||||||
command('hi CursorLine cterm=standout,underline term=standout,underline gui=standout,underline')
|
command('hi CursorLine cterm=standout,underline term=standout,underline gui=standout,underline')
|
||||||
command('set cursorline')
|
command('set cursorline')
|
||||||
eq({ underline = true, standout = true }, meths.get_hl_by_name('cursorline', 0))
|
eq({ underline = true, standout = true }, meths.nvim_get_hl_by_name('cursorline', 0))
|
||||||
|
|
||||||
-- Test cterm & Normal values. #18024 (tail) & #18980
|
-- Test cterm & Normal values. #18024 (tail) & #18980
|
||||||
-- Ensure Normal, and groups that match Normal return their fg & bg cterm values
|
-- Ensure Normal, and groups that match Normal return their fg & bg cterm values
|
||||||
meths.set_hl(0, 'Normal', { ctermfg = 17, ctermbg = 213 })
|
meths.nvim_set_hl(0, 'Normal', { ctermfg = 17, ctermbg = 213 })
|
||||||
meths.set_hl(0, 'NotNormal', { ctermfg = 17, ctermbg = 213, nocombine = true })
|
meths.nvim_set_hl(0, 'NotNormal', { ctermfg = 17, ctermbg = 213, nocombine = true })
|
||||||
-- Note colors are "cterm" values, not rgb-as-ints
|
-- Note colors are "cterm" values, not rgb-as-ints
|
||||||
eq({ foreground = 17, background = 213 }, nvim('get_hl_by_name', 'Normal', false))
|
eq({ foreground = 17, background = 213 }, nvim('get_hl_by_name', 'Normal', false))
|
||||||
eq(
|
eq(
|
||||||
@@ -146,31 +146,34 @@ describe('API: highlight', function()
|
|||||||
|
|
||||||
it('nvim_get_hl_id_by_name', function()
|
it('nvim_get_hl_id_by_name', function()
|
||||||
-- precondition: use a hl group that does not yet exist
|
-- precondition: use a hl group that does not yet exist
|
||||||
eq("Invalid highlight name: 'Shrubbery'", pcall_err(meths.get_hl_by_name, 'Shrubbery', true))
|
eq(
|
||||||
|
"Invalid highlight name: 'Shrubbery'",
|
||||||
|
pcall_err(meths.nvim_get_hl_by_name, 'Shrubbery', true)
|
||||||
|
)
|
||||||
eq(0, funcs.hlID('Shrubbery'))
|
eq(0, funcs.hlID('Shrubbery'))
|
||||||
|
|
||||||
local hl_id = meths.get_hl_id_by_name('Shrubbery')
|
local hl_id = meths.nvim_get_hl_id_by_name('Shrubbery')
|
||||||
ok(hl_id > 0)
|
ok(hl_id > 0)
|
||||||
eq(hl_id, funcs.hlID('Shrubbery'))
|
eq(hl_id, funcs.hlID('Shrubbery'))
|
||||||
|
|
||||||
command('hi Shrubbery guifg=#888888 guibg=#888888')
|
command('hi Shrubbery guifg=#888888 guibg=#888888')
|
||||||
eq(
|
eq(
|
||||||
{ foreground = tonumber('0x888888'), background = tonumber('0x888888') },
|
{ foreground = tonumber('0x888888'), background = tonumber('0x888888') },
|
||||||
meths.get_hl_by_id(hl_id, true)
|
meths.nvim_get_hl_by_id(hl_id, true)
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
{ foreground = tonumber('0x888888'), background = tonumber('0x888888') },
|
{ foreground = tonumber('0x888888'), background = tonumber('0x888888') },
|
||||||
meths.get_hl_by_name('Shrubbery', true)
|
meths.nvim_get_hl_by_name('Shrubbery', true)
|
||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("nvim_buf_add_highlight to other buffer doesn't crash if undo is disabled #12873", function()
|
it("nvim_buf_add_highlight to other buffer doesn't crash if undo is disabled #12873", function()
|
||||||
command('vsplit file')
|
command('vsplit file')
|
||||||
local err, _ = pcall(meths.set_option_value, 'undofile', false, { buf = 1 })
|
local err, _ = pcall(meths.nvim_set_option_value, 'undofile', false, { buf = 1 })
|
||||||
eq(true, err)
|
eq(true, err)
|
||||||
err, _ = pcall(meths.set_option_value, 'undolevels', -1, { buf = 1 })
|
err, _ = pcall(meths.nvim_set_option_value, 'undolevels', -1, { buf = 1 })
|
||||||
eq(true, err)
|
eq(true, err)
|
||||||
err, _ = pcall(meths.buf_add_highlight, 1, -1, 'Question', 0, 0, -1)
|
err, _ = pcall(meths.nvim_buf_add_highlight, 1, -1, 'Question', 0, 0, -1)
|
||||||
eq(true, err)
|
eq(true, err)
|
||||||
assert_alive()
|
assert_alive()
|
||||||
end)
|
end)
|
||||||
@@ -241,8 +244,8 @@ describe('API: set highlight', function()
|
|||||||
}
|
}
|
||||||
|
|
||||||
local function get_ns()
|
local function get_ns()
|
||||||
local ns = meths.create_namespace('Test_set_hl')
|
local ns = meths.nvim_create_namespace('Test_set_hl')
|
||||||
meths.set_hl_ns(ns)
|
meths.nvim_set_hl_ns(ns)
|
||||||
return ns
|
return ns
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -251,51 +254,51 @@ describe('API: set highlight', function()
|
|||||||
it('validation', function()
|
it('validation', function()
|
||||||
eq(
|
eq(
|
||||||
"Invalid 'blend': out of range",
|
"Invalid 'blend': out of range",
|
||||||
pcall_err(meths.set_hl, 0, 'Test_hl3', { fg = '#FF00FF', blend = 999 })
|
pcall_err(meths.nvim_set_hl, 0, 'Test_hl3', { fg = '#FF00FF', blend = 999 })
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
"Invalid 'blend': expected Integer, got Array",
|
"Invalid 'blend': expected Integer, got Array",
|
||||||
pcall_err(meths.set_hl, 0, 'Test_hl3', { fg = '#FF00FF', blend = {} })
|
pcall_err(meths.nvim_set_hl, 0, 'Test_hl3', { fg = '#FF00FF', blend = {} })
|
||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('can set gui highlight', function()
|
it('can set gui highlight', function()
|
||||||
local ns = get_ns()
|
local ns = get_ns()
|
||||||
meths.set_hl(ns, 'Test_hl', highlight1)
|
meths.nvim_set_hl(ns, 'Test_hl', highlight1)
|
||||||
eq(highlight1, meths.get_hl_by_name('Test_hl', true))
|
eq(highlight1, meths.nvim_get_hl_by_name('Test_hl', true))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('can set cterm highlight', function()
|
it('can set cterm highlight', function()
|
||||||
local ns = get_ns()
|
local ns = get_ns()
|
||||||
meths.set_hl(ns, 'Test_hl', highlight2_config)
|
meths.nvim_set_hl(ns, 'Test_hl', highlight2_config)
|
||||||
eq(highlight2_result, meths.get_hl_by_name('Test_hl', false))
|
eq(highlight2_result, meths.nvim_get_hl_by_name('Test_hl', false))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('can set empty cterm attr', function()
|
it('can set empty cterm attr', function()
|
||||||
local ns = get_ns()
|
local ns = get_ns()
|
||||||
meths.set_hl(ns, 'Test_hl', { cterm = {} })
|
meths.nvim_set_hl(ns, 'Test_hl', { cterm = {} })
|
||||||
eq({}, meths.get_hl_by_name('Test_hl', false))
|
eq({}, meths.nvim_get_hl_by_name('Test_hl', false))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('cterm attr defaults to gui attr', function()
|
it('cterm attr defaults to gui attr', function()
|
||||||
local ns = get_ns()
|
local ns = get_ns()
|
||||||
meths.set_hl(ns, 'Test_hl', highlight1)
|
meths.nvim_set_hl(ns, 'Test_hl', highlight1)
|
||||||
eq({
|
eq({
|
||||||
bold = true,
|
bold = true,
|
||||||
italic = true,
|
italic = true,
|
||||||
}, meths.get_hl_by_name('Test_hl', false))
|
}, meths.nvim_get_hl_by_name('Test_hl', false))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('can overwrite attr for cterm', function()
|
it('can overwrite attr for cterm', function()
|
||||||
local ns = get_ns()
|
local ns = get_ns()
|
||||||
meths.set_hl(ns, 'Test_hl', highlight3_config)
|
meths.nvim_set_hl(ns, 'Test_hl', highlight3_config)
|
||||||
eq(highlight3_result_gui, meths.get_hl_by_name('Test_hl', true))
|
eq(highlight3_result_gui, meths.nvim_get_hl_by_name('Test_hl', true))
|
||||||
eq(highlight3_result_cterm, meths.get_hl_by_name('Test_hl', false))
|
eq(highlight3_result_cterm, meths.nvim_get_hl_by_name('Test_hl', false))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('only allows one underline attribute #22371', function()
|
it('only allows one underline attribute #22371', function()
|
||||||
local ns = get_ns()
|
local ns = get_ns()
|
||||||
meths.set_hl(ns, 'Test_hl', {
|
meths.nvim_set_hl(ns, 'Test_hl', {
|
||||||
underdouble = true,
|
underdouble = true,
|
||||||
underdotted = true,
|
underdotted = true,
|
||||||
cterm = {
|
cterm = {
|
||||||
@@ -303,21 +306,21 @@ describe('API: set highlight', function()
|
|||||||
undercurl = true,
|
undercurl = true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
eq({ undercurl = true }, meths.get_hl_by_name('Test_hl', false))
|
eq({ undercurl = true }, meths.nvim_get_hl_by_name('Test_hl', false))
|
||||||
eq({ underdotted = true }, meths.get_hl_by_name('Test_hl', true))
|
eq({ underdotted = true }, meths.nvim_get_hl_by_name('Test_hl', true))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('can set a highlight in the global namespace', function()
|
it('can set a highlight in the global namespace', function()
|
||||||
meths.set_hl(0, 'Test_hl', highlight2_config)
|
meths.nvim_set_hl(0, 'Test_hl', highlight2_config)
|
||||||
eq(
|
eq(
|
||||||
'Test_hl xxx cterm=underline,reverse ctermfg=8 ctermbg=15 gui=underline,reverse',
|
'Test_hl xxx cterm=underline,reverse ctermfg=8 ctermbg=15 gui=underline,reverse',
|
||||||
exec_capture('highlight Test_hl')
|
exec_capture('highlight Test_hl')
|
||||||
)
|
)
|
||||||
|
|
||||||
meths.set_hl(0, 'Test_hl', { background = highlight_color.bg })
|
meths.nvim_set_hl(0, 'Test_hl', { background = highlight_color.bg })
|
||||||
eq('Test_hl xxx guibg=#0032aa', exec_capture('highlight Test_hl'))
|
eq('Test_hl xxx guibg=#0032aa', exec_capture('highlight Test_hl'))
|
||||||
|
|
||||||
meths.set_hl(0, 'Test_hl2', highlight3_config)
|
meths.nvim_set_hl(0, 'Test_hl2', highlight3_config)
|
||||||
eq(
|
eq(
|
||||||
'Test_hl2 xxx cterm=italic,reverse,strikethrough,altfont,nocombine ctermfg=8 ctermbg=15 gui=bold,underdashed,italic,reverse,strikethrough,altfont guifg=#ff0000 guibg=#0032aa',
|
'Test_hl2 xxx cterm=italic,reverse,strikethrough,altfont,nocombine ctermfg=8 ctermbg=15 gui=bold,underdashed,italic,reverse,strikethrough,altfont guifg=#ff0000 guibg=#0032aa',
|
||||||
exec_capture('highlight Test_hl2')
|
exec_capture('highlight Test_hl2')
|
||||||
@@ -325,58 +328,64 @@ describe('API: set highlight', function()
|
|||||||
|
|
||||||
-- Colors are stored with the name they are defined, but
|
-- Colors are stored with the name they are defined, but
|
||||||
-- with canonical casing
|
-- with canonical casing
|
||||||
meths.set_hl(0, 'Test_hl3', { bg = 'reD', fg = 'bLue' })
|
meths.nvim_set_hl(0, 'Test_hl3', { bg = 'reD', fg = 'bLue' })
|
||||||
eq('Test_hl3 xxx guifg=Blue guibg=Red', exec_capture('highlight Test_hl3'))
|
eq('Test_hl3 xxx guifg=Blue guibg=Red', exec_capture('highlight Test_hl3'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('can modify a highlight in the global namespace', function()
|
it('can modify a highlight in the global namespace', function()
|
||||||
meths.set_hl(0, 'Test_hl3', { bg = 'red', fg = 'blue' })
|
meths.nvim_set_hl(0, 'Test_hl3', { bg = 'red', fg = 'blue' })
|
||||||
eq('Test_hl3 xxx guifg=Blue guibg=Red', exec_capture('highlight Test_hl3'))
|
eq('Test_hl3 xxx guifg=Blue guibg=Red', exec_capture('highlight Test_hl3'))
|
||||||
|
|
||||||
meths.set_hl(0, 'Test_hl3', { bg = 'red' })
|
meths.nvim_set_hl(0, 'Test_hl3', { bg = 'red' })
|
||||||
eq('Test_hl3 xxx guibg=Red', exec_capture('highlight Test_hl3'))
|
eq('Test_hl3 xxx guibg=Red', exec_capture('highlight Test_hl3'))
|
||||||
|
|
||||||
meths.set_hl(0, 'Test_hl3', { ctermbg = 9, ctermfg = 12 })
|
meths.nvim_set_hl(0, 'Test_hl3', { ctermbg = 9, ctermfg = 12 })
|
||||||
eq('Test_hl3 xxx ctermfg=12 ctermbg=9', exec_capture('highlight Test_hl3'))
|
eq('Test_hl3 xxx ctermfg=12 ctermbg=9', exec_capture('highlight Test_hl3'))
|
||||||
|
|
||||||
meths.set_hl(0, 'Test_hl3', { ctermbg = 'red', ctermfg = 'blue' })
|
meths.nvim_set_hl(0, 'Test_hl3', { ctermbg = 'red', ctermfg = 'blue' })
|
||||||
eq('Test_hl3 xxx ctermfg=12 ctermbg=9', exec_capture('highlight Test_hl3'))
|
eq('Test_hl3 xxx ctermfg=12 ctermbg=9', exec_capture('highlight Test_hl3'))
|
||||||
|
|
||||||
meths.set_hl(0, 'Test_hl3', { ctermbg = 9 })
|
meths.nvim_set_hl(0, 'Test_hl3', { ctermbg = 9 })
|
||||||
eq('Test_hl3 xxx ctermbg=9', exec_capture('highlight Test_hl3'))
|
eq('Test_hl3 xxx ctermbg=9', exec_capture('highlight Test_hl3'))
|
||||||
|
|
||||||
eq("Invalid highlight color: 'redd'", pcall_err(meths.set_hl, 0, 'Test_hl3', { fg = 'redd' }))
|
eq(
|
||||||
|
"Invalid highlight color: 'redd'",
|
||||||
|
pcall_err(meths.nvim_set_hl, 0, 'Test_hl3', { fg = 'redd' })
|
||||||
|
)
|
||||||
|
|
||||||
eq(
|
eq(
|
||||||
"Invalid highlight color: 'bleu'",
|
"Invalid highlight color: 'bleu'",
|
||||||
pcall_err(meths.set_hl, 0, 'Test_hl3', { ctermfg = 'bleu' })
|
pcall_err(meths.nvim_set_hl, 0, 'Test_hl3', { ctermfg = 'bleu' })
|
||||||
)
|
)
|
||||||
|
|
||||||
meths.set_hl(0, 'Test_hl3', { fg = '#FF00FF' })
|
meths.nvim_set_hl(0, 'Test_hl3', { fg = '#FF00FF' })
|
||||||
eq('Test_hl3 xxx guifg=#ff00ff', exec_capture('highlight Test_hl3'))
|
eq('Test_hl3 xxx guifg=#ff00ff', exec_capture('highlight Test_hl3'))
|
||||||
|
|
||||||
eq(
|
eq(
|
||||||
"Invalid highlight color: '#FF00FF'",
|
"Invalid highlight color: '#FF00FF'",
|
||||||
pcall_err(meths.set_hl, 0, 'Test_hl3', { ctermfg = '#FF00FF' })
|
pcall_err(meths.nvim_set_hl, 0, 'Test_hl3', { ctermfg = '#FF00FF' })
|
||||||
)
|
)
|
||||||
|
|
||||||
for _, fg_val in ipairs { nil, 'NONE', 'nOnE', '', -1 } do
|
for _, fg_val in ipairs { nil, 'NONE', 'nOnE', '', -1 } do
|
||||||
meths.set_hl(0, 'Test_hl3', { fg = fg_val })
|
meths.nvim_set_hl(0, 'Test_hl3', { fg = fg_val })
|
||||||
eq('Test_hl3 xxx cleared', exec_capture('highlight Test_hl3'))
|
eq('Test_hl3 xxx cleared', exec_capture('highlight Test_hl3'))
|
||||||
end
|
end
|
||||||
|
|
||||||
meths.set_hl(0, 'Test_hl3', { fg = '#FF00FF', blend = 50 })
|
meths.nvim_set_hl(0, 'Test_hl3', { fg = '#FF00FF', blend = 50 })
|
||||||
eq('Test_hl3 xxx guifg=#ff00ff blend=50', exec_capture('highlight Test_hl3'))
|
eq('Test_hl3 xxx guifg=#ff00ff blend=50', exec_capture('highlight Test_hl3'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("correctly sets 'Normal' internal properties", function()
|
it("correctly sets 'Normal' internal properties", function()
|
||||||
-- Normal has some special handling internally. #18024
|
-- Normal has some special handling internally. #18024
|
||||||
meths.set_hl(0, 'Normal', { fg = '#000083', bg = '#0000F3' })
|
meths.nvim_set_hl(0, 'Normal', { fg = '#000083', bg = '#0000F3' })
|
||||||
eq({ foreground = 131, background = 243 }, nvim('get_hl_by_name', 'Normal', true))
|
eq({ foreground = 131, background = 243 }, nvim('get_hl_by_name', 'Normal', true))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('does not segfault on invalid group name #20009', function()
|
it('does not segfault on invalid group name #20009', function()
|
||||||
eq("Invalid highlight name: 'foo bar'", pcall_err(meths.set_hl, 0, 'foo bar', { bold = true }))
|
eq(
|
||||||
|
"Invalid highlight name: 'foo bar'",
|
||||||
|
pcall_err(meths.nvim_set_hl, 0, 'foo bar', { bold = true })
|
||||||
|
)
|
||||||
assert_alive()
|
assert_alive()
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
@@ -443,14 +452,14 @@ describe('API: get highlight', function()
|
|||||||
|
|
||||||
local function get_ns()
|
local function get_ns()
|
||||||
-- Test namespace filtering behavior
|
-- Test namespace filtering behavior
|
||||||
local ns2 = meths.create_namespace('Another_namespace')
|
local ns2 = meths.nvim_create_namespace('Another_namespace')
|
||||||
meths.set_hl(ns2, 'Test_hl', { ctermfg = 23 })
|
meths.nvim_set_hl(ns2, 'Test_hl', { ctermfg = 23 })
|
||||||
meths.set_hl(ns2, 'Test_another_hl', { link = 'Test_hl' })
|
meths.nvim_set_hl(ns2, 'Test_another_hl', { link = 'Test_hl' })
|
||||||
meths.set_hl(ns2, 'Test_hl_link', { link = 'Test_another_hl' })
|
meths.nvim_set_hl(ns2, 'Test_hl_link', { link = 'Test_another_hl' })
|
||||||
meths.set_hl(ns2, 'Test_another_hl_link', { link = 'Test_hl_link' })
|
meths.nvim_set_hl(ns2, 'Test_another_hl_link', { link = 'Test_hl_link' })
|
||||||
|
|
||||||
local ns = meths.create_namespace('Test_set_hl')
|
local ns = meths.nvim_create_namespace('Test_set_hl')
|
||||||
meths.set_hl_ns(ns)
|
meths.nvim_set_hl_ns(ns)
|
||||||
|
|
||||||
return ns
|
return ns
|
||||||
end
|
end
|
||||||
@@ -458,23 +467,26 @@ describe('API: get highlight', function()
|
|||||||
before_each(clear)
|
before_each(clear)
|
||||||
|
|
||||||
it('validation', function()
|
it('validation', function()
|
||||||
eq("Invalid 'name': expected String, got Integer", pcall_err(meths.get_hl, 0, { name = 177 }))
|
eq(
|
||||||
eq('Highlight id out of bounds', pcall_err(meths.get_hl, 0, { name = 'Test set hl' }))
|
"Invalid 'name': expected String, got Integer",
|
||||||
|
pcall_err(meths.nvim_get_hl, 0, { name = 177 })
|
||||||
|
)
|
||||||
|
eq('Highlight id out of bounds', pcall_err(meths.nvim_get_hl, 0, { name = 'Test set hl' }))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('nvim_get_hl with create flag', function()
|
it('nvim_get_hl with create flag', function()
|
||||||
eq({}, nvim('get_hl', 0, { name = 'Foo', create = false }))
|
eq({}, nvim('get_hl', 0, { name = 'Foo', create = false }))
|
||||||
eq(0, funcs.hlexists('Foo'))
|
eq(0, funcs.hlexists('Foo'))
|
||||||
meths.get_hl(0, { name = 'Bar', create = true })
|
meths.nvim_get_hl(0, { name = 'Bar', create = true })
|
||||||
eq(1, funcs.hlexists('Bar'))
|
eq(1, funcs.hlexists('Bar'))
|
||||||
meths.get_hl(0, { name = 'FooBar' })
|
meths.nvim_get_hl(0, { name = 'FooBar' })
|
||||||
eq(1, funcs.hlexists('FooBar'))
|
eq(1, funcs.hlexists('FooBar'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('can get all highlights in current namespace', function()
|
it('can get all highlights in current namespace', function()
|
||||||
local ns = get_ns()
|
local ns = get_ns()
|
||||||
meths.set_hl(ns, 'Test_hl', { bg = '#B4BEFE' })
|
meths.nvim_set_hl(ns, 'Test_hl', { bg = '#B4BEFE' })
|
||||||
meths.set_hl(ns, 'Test_hl_link', { link = 'Test_hl' })
|
meths.nvim_set_hl(ns, 'Test_hl_link', { link = 'Test_hl' })
|
||||||
eq({
|
eq({
|
||||||
Test_hl = {
|
Test_hl = {
|
||||||
bg = 11845374,
|
bg = 11845374,
|
||||||
@@ -482,42 +494,42 @@ describe('API: get highlight', function()
|
|||||||
Test_hl_link = {
|
Test_hl_link = {
|
||||||
link = 'Test_hl',
|
link = 'Test_hl',
|
||||||
},
|
},
|
||||||
}, meths.get_hl(ns, {}))
|
}, meths.nvim_get_hl(ns, {}))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('can get gui highlight', function()
|
it('can get gui highlight', function()
|
||||||
local ns = get_ns()
|
local ns = get_ns()
|
||||||
meths.set_hl(ns, 'Test_hl', highlight1)
|
meths.nvim_set_hl(ns, 'Test_hl', highlight1)
|
||||||
eq(highlight1, meths.get_hl(ns, { name = 'Test_hl' }))
|
eq(highlight1, meths.nvim_get_hl(ns, { name = 'Test_hl' }))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('can get cterm highlight', function()
|
it('can get cterm highlight', function()
|
||||||
local ns = get_ns()
|
local ns = get_ns()
|
||||||
meths.set_hl(ns, 'Test_hl', highlight2)
|
meths.nvim_set_hl(ns, 'Test_hl', highlight2)
|
||||||
eq(highlight2, meths.get_hl(ns, { name = 'Test_hl' }))
|
eq(highlight2, meths.nvim_get_hl(ns, { name = 'Test_hl' }))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('can get empty cterm attr', function()
|
it('can get empty cterm attr', function()
|
||||||
local ns = get_ns()
|
local ns = get_ns()
|
||||||
meths.set_hl(ns, 'Test_hl', { cterm = {} })
|
meths.nvim_set_hl(ns, 'Test_hl', { cterm = {} })
|
||||||
eq({}, meths.get_hl(ns, { name = 'Test_hl' }))
|
eq({}, meths.nvim_get_hl(ns, { name = 'Test_hl' }))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('cterm attr defaults to gui attr', function()
|
it('cterm attr defaults to gui attr', function()
|
||||||
local ns = get_ns()
|
local ns = get_ns()
|
||||||
meths.set_hl(ns, 'Test_hl', highlight1)
|
meths.nvim_set_hl(ns, 'Test_hl', highlight1)
|
||||||
eq(highlight1, meths.get_hl(ns, { name = 'Test_hl' }))
|
eq(highlight1, meths.nvim_get_hl(ns, { name = 'Test_hl' }))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('can overwrite attr for cterm', function()
|
it('can overwrite attr for cterm', function()
|
||||||
local ns = get_ns()
|
local ns = get_ns()
|
||||||
meths.set_hl(ns, 'Test_hl', highlight3_config)
|
meths.nvim_set_hl(ns, 'Test_hl', highlight3_config)
|
||||||
eq(highlight3_result, meths.get_hl(ns, { name = 'Test_hl' }))
|
eq(highlight3_result, meths.nvim_get_hl(ns, { name = 'Test_hl' }))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('only allows one underline attribute #22371', function()
|
it('only allows one underline attribute #22371', function()
|
||||||
local ns = get_ns()
|
local ns = get_ns()
|
||||||
meths.set_hl(ns, 'Test_hl', {
|
meths.nvim_set_hl(ns, 'Test_hl', {
|
||||||
underdouble = true,
|
underdouble = true,
|
||||||
underdotted = true,
|
underdotted = true,
|
||||||
cterm = {
|
cterm = {
|
||||||
@@ -525,32 +537,35 @@ describe('API: get highlight', function()
|
|||||||
undercurl = true,
|
undercurl = true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
eq({ underdotted = true, cterm = { undercurl = true } }, meths.get_hl(ns, { name = 'Test_hl' }))
|
eq(
|
||||||
|
{ underdotted = true, cterm = { undercurl = true } },
|
||||||
|
meths.nvim_get_hl(ns, { name = 'Test_hl' })
|
||||||
|
)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('can get a highlight in the global namespace', function()
|
it('can get a highlight in the global namespace', function()
|
||||||
meths.set_hl(0, 'Test_hl', highlight2)
|
meths.nvim_set_hl(0, 'Test_hl', highlight2)
|
||||||
eq(highlight2, meths.get_hl(0, { name = 'Test_hl' }))
|
eq(highlight2, meths.nvim_get_hl(0, { name = 'Test_hl' }))
|
||||||
|
|
||||||
meths.set_hl(0, 'Test_hl', { background = highlight_color.bg })
|
meths.nvim_set_hl(0, 'Test_hl', { background = highlight_color.bg })
|
||||||
eq({
|
eq({
|
||||||
bg = 12970,
|
bg = 12970,
|
||||||
}, meths.get_hl(0, { name = 'Test_hl' }))
|
}, meths.nvim_get_hl(0, { name = 'Test_hl' }))
|
||||||
|
|
||||||
meths.set_hl(0, 'Test_hl2', highlight3_config)
|
meths.nvim_set_hl(0, 'Test_hl2', highlight3_config)
|
||||||
eq(highlight3_result, meths.get_hl(0, { name = 'Test_hl2' }))
|
eq(highlight3_result, meths.nvim_get_hl(0, { name = 'Test_hl2' }))
|
||||||
|
|
||||||
-- Colors are stored with the name they are defined, but
|
-- Colors are stored with the name they are defined, but
|
||||||
-- with canonical casing
|
-- with canonical casing
|
||||||
meths.set_hl(0, 'Test_hl3', { bg = 'reD', fg = 'bLue' })
|
meths.nvim_set_hl(0, 'Test_hl3', { bg = 'reD', fg = 'bLue' })
|
||||||
eq({
|
eq({
|
||||||
bg = 16711680,
|
bg = 16711680,
|
||||||
fg = 255,
|
fg = 255,
|
||||||
}, meths.get_hl(0, { name = 'Test_hl3' }))
|
}, meths.nvim_get_hl(0, { name = 'Test_hl3' }))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('nvim_get_hl by id', function()
|
it('nvim_get_hl by id', function()
|
||||||
local hl_id = meths.get_hl_id_by_name('NewHighlight')
|
local hl_id = meths.nvim_get_hl_id_by_name('NewHighlight')
|
||||||
|
|
||||||
command(
|
command(
|
||||||
'hi NewHighlight cterm=underline ctermbg=green guifg=red guibg=yellow guisp=blue gui=bold'
|
'hi NewHighlight cterm=underline ctermbg=green guifg=red guibg=yellow guisp=blue gui=bold'
|
||||||
@@ -562,14 +577,14 @@ describe('API: get highlight', function()
|
|||||||
bold = true,
|
bold = true,
|
||||||
ctermbg = 10,
|
ctermbg = 10,
|
||||||
cterm = { underline = true },
|
cterm = { underline = true },
|
||||||
}, meths.get_hl(0, { id = hl_id }))
|
}, meths.nvim_get_hl(0, { id = hl_id }))
|
||||||
|
|
||||||
-- Test 0 argument
|
-- Test 0 argument
|
||||||
eq('Highlight id out of bounds', pcall_err(meths.get_hl, 0, { id = 0 }))
|
eq('Highlight id out of bounds', pcall_err(meths.nvim_get_hl, 0, { id = 0 }))
|
||||||
|
|
||||||
eq(
|
eq(
|
||||||
"Invalid 'id': expected Integer, got String",
|
"Invalid 'id': expected Integer, got String",
|
||||||
pcall_err(meths.get_hl, 0, { id = 'Test_set_hl' })
|
pcall_err(meths.nvim_get_hl, 0, { id = 'Test_set_hl' })
|
||||||
)
|
)
|
||||||
|
|
||||||
-- Test all highlight properties.
|
-- Test all highlight properties.
|
||||||
@@ -587,7 +602,7 @@ describe('API: get highlight', function()
|
|||||||
underline = true,
|
underline = true,
|
||||||
ctermbg = 10,
|
ctermbg = 10,
|
||||||
cterm = { underline = true },
|
cterm = { underline = true },
|
||||||
}, meths.get_hl(0, { id = hl_id }))
|
}, meths.nvim_get_hl(0, { id = hl_id }))
|
||||||
|
|
||||||
-- Test undercurl
|
-- Test undercurl
|
||||||
command('hi NewHighlight gui=undercurl')
|
command('hi NewHighlight gui=undercurl')
|
||||||
@@ -598,16 +613,16 @@ describe('API: get highlight', function()
|
|||||||
undercurl = true,
|
undercurl = true,
|
||||||
ctermbg = 10,
|
ctermbg = 10,
|
||||||
cterm = { underline = true },
|
cterm = { underline = true },
|
||||||
}, meths.get_hl(0, { id = hl_id }))
|
}, meths.nvim_get_hl(0, { id = hl_id }))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('can correctly detect links', function()
|
it('can correctly detect links', function()
|
||||||
command('hi String guifg=#a6e3a1 ctermfg=NONE')
|
command('hi String guifg=#a6e3a1 ctermfg=NONE')
|
||||||
command('hi link @string string')
|
command('hi link @string string')
|
||||||
command('hi link @string.cpp @string')
|
command('hi link @string.cpp @string')
|
||||||
eq({ fg = 10937249 }, meths.get_hl(0, { name = 'String' }))
|
eq({ fg = 10937249 }, meths.nvim_get_hl(0, { name = 'String' }))
|
||||||
eq({ link = 'String' }, meths.get_hl(0, { name = '@string' }))
|
eq({ link = 'String' }, meths.nvim_get_hl(0, { name = '@string' }))
|
||||||
eq({ fg = 10937249 }, meths.get_hl(0, { name = '@string.cpp', link = false }))
|
eq({ fg = 10937249 }, meths.nvim_get_hl(0, { name = '@string.cpp', link = false }))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('can get all attributes for a linked group', function()
|
it('can get all attributes for a linked group', function()
|
||||||
@@ -616,55 +631,55 @@ describe('API: get highlight', function()
|
|||||||
command('hi! link Foo Bar')
|
command('hi! link Foo Bar')
|
||||||
eq(
|
eq(
|
||||||
{ link = 'Bar', fg = tonumber('00ff00', 16), bold = true, underline = true },
|
{ link = 'Bar', fg = tonumber('00ff00', 16), bold = true, underline = true },
|
||||||
meths.get_hl(0, { name = 'Foo', link = true })
|
meths.nvim_get_hl(0, { name = 'Foo', link = true })
|
||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('can set link as well as other attributes', function()
|
it('can set link as well as other attributes', function()
|
||||||
command('hi Bar guifg=red')
|
command('hi Bar guifg=red')
|
||||||
local hl = { link = 'Bar', fg = tonumber('00ff00', 16), bold = true, cterm = { bold = true } }
|
local hl = { link = 'Bar', fg = tonumber('00ff00', 16), bold = true, cterm = { bold = true } }
|
||||||
meths.set_hl(0, 'Foo', hl)
|
meths.nvim_set_hl(0, 'Foo', hl)
|
||||||
eq(hl, meths.get_hl(0, { name = 'Foo', link = true }))
|
eq(hl, meths.nvim_get_hl(0, { name = 'Foo', link = true }))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("doesn't contain unset groups", function()
|
it("doesn't contain unset groups", function()
|
||||||
local id = meths.get_hl_id_by_name '@foobar.hubbabubba'
|
local id = meths.nvim_get_hl_id_by_name '@foobar.hubbabubba'
|
||||||
ok(id > 0)
|
ok(id > 0)
|
||||||
|
|
||||||
local data = meths.get_hl(0, {})
|
local data = meths.nvim_get_hl(0, {})
|
||||||
eq(nil, data['@foobar.hubbabubba'])
|
eq(nil, data['@foobar.hubbabubba'])
|
||||||
eq(nil, data['@foobar'])
|
eq(nil, data['@foobar'])
|
||||||
|
|
||||||
command 'hi @foobar.hubbabubba gui=bold'
|
command 'hi @foobar.hubbabubba gui=bold'
|
||||||
data = meths.get_hl(0, {})
|
data = meths.nvim_get_hl(0, {})
|
||||||
eq({ bold = true }, data['@foobar.hubbabubba'])
|
eq({ bold = true }, data['@foobar.hubbabubba'])
|
||||||
eq(nil, data['@foobar'])
|
eq(nil, data['@foobar'])
|
||||||
|
|
||||||
-- @foobar.hubbabubba was explicitly cleared and thus shows up
|
-- @foobar.hubbabubba was explicitly cleared and thus shows up
|
||||||
-- but @foobar was never touched, and thus doesn't
|
-- but @foobar was never touched, and thus doesn't
|
||||||
command 'hi clear @foobar.hubbabubba'
|
command 'hi clear @foobar.hubbabubba'
|
||||||
data = meths.get_hl(0, {})
|
data = meths.nvim_get_hl(0, {})
|
||||||
eq({}, data['@foobar.hubbabubba'])
|
eq({}, data['@foobar.hubbabubba'])
|
||||||
eq(nil, data['@foobar'])
|
eq(nil, data['@foobar'])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('should return default flag', function()
|
it('should return default flag', function()
|
||||||
meths.set_hl(0, 'Tried', { fg = '#00ff00', default = true })
|
meths.nvim_set_hl(0, 'Tried', { fg = '#00ff00', default = true })
|
||||||
eq({ fg = tonumber('00ff00', 16), default = true }, meths.get_hl(0, { name = 'Tried' }))
|
eq({ fg = tonumber('00ff00', 16), default = true }, meths.nvim_get_hl(0, { name = 'Tried' }))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('should not output empty gui and cterm #23474', function()
|
it('should not output empty gui and cterm #23474', function()
|
||||||
meths.set_hl(0, 'Foo', { default = true })
|
meths.nvim_set_hl(0, 'Foo', { default = true })
|
||||||
meths.set_hl(0, 'Bar', { default = true, fg = '#ffffff' })
|
meths.nvim_set_hl(0, 'Bar', { default = true, fg = '#ffffff' })
|
||||||
meths.set_hl(0, 'FooBar', { default = true, fg = '#ffffff', cterm = { bold = true } })
|
meths.nvim_set_hl(0, 'FooBar', { default = true, fg = '#ffffff', cterm = { bold = true } })
|
||||||
meths.set_hl(
|
meths.nvim_set_hl(
|
||||||
0,
|
0,
|
||||||
'FooBarA',
|
'FooBarA',
|
||||||
{ default = true, fg = '#ffffff', cterm = { bold = true, italic = true } }
|
{ default = true, fg = '#ffffff', cterm = { bold = true, italic = true } }
|
||||||
)
|
)
|
||||||
|
|
||||||
eq('Foo xxx cleared', exec_capture('highlight Foo'))
|
eq('Foo xxx cleared', exec_capture('highlight Foo'))
|
||||||
eq({ default = true }, meths.get_hl(0, { name = 'Foo' }))
|
eq({ default = true }, meths.nvim_get_hl(0, { name = 'Foo' }))
|
||||||
eq('Bar xxx guifg=#ffffff', exec_capture('highlight Bar'))
|
eq('Bar xxx guifg=#ffffff', exec_capture('highlight Bar'))
|
||||||
eq('FooBar xxx cterm=bold guifg=#ffffff', exec_capture('highlight FooBar'))
|
eq('FooBar xxx cterm=bold guifg=#ffffff', exec_capture('highlight FooBar'))
|
||||||
eq('FooBarA xxx cterm=bold,italic guifg=#ffffff', exec_capture('highlight FooBarA'))
|
eq('FooBarA xxx cterm=bold,italic guifg=#ffffff', exec_capture('highlight FooBarA'))
|
||||||
@@ -673,27 +688,27 @@ describe('API: get highlight', function()
|
|||||||
it('can override exist highlight group by force #20323', function()
|
it('can override exist highlight group by force #20323', function()
|
||||||
local white = tonumber('ffffff', 16)
|
local white = tonumber('ffffff', 16)
|
||||||
local green = tonumber('00ff00', 16)
|
local green = tonumber('00ff00', 16)
|
||||||
meths.set_hl(0, 'Foo', { fg = white })
|
meths.nvim_set_hl(0, 'Foo', { fg = white })
|
||||||
meths.set_hl(0, 'Foo', { fg = green, force = true })
|
meths.nvim_set_hl(0, 'Foo', { fg = green, force = true })
|
||||||
eq({ fg = green }, meths.get_hl(0, { name = 'Foo' }))
|
eq({ fg = green }, meths.nvim_get_hl(0, { name = 'Foo' }))
|
||||||
meths.set_hl(0, 'Bar', { link = 'Comment', default = true })
|
meths.nvim_set_hl(0, 'Bar', { link = 'Comment', default = true })
|
||||||
meths.set_hl(0, 'Bar', { link = 'Foo', default = true, force = true })
|
meths.nvim_set_hl(0, 'Bar', { link = 'Foo', default = true, force = true })
|
||||||
eq({ link = 'Foo', default = true }, meths.get_hl(0, { name = 'Bar' }))
|
eq({ link = 'Foo', default = true }, meths.nvim_get_hl(0, { name = 'Bar' }))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('API: set/get highlight namespace', function()
|
describe('API: set/get highlight namespace', function()
|
||||||
it('set/get highlight namespace', function()
|
it('set/get highlight namespace', function()
|
||||||
eq(0, meths.get_hl_ns({}))
|
eq(0, meths.nvim_get_hl_ns({}))
|
||||||
local ns = meths.create_namespace('')
|
local ns = meths.nvim_create_namespace('')
|
||||||
meths.set_hl_ns(ns)
|
meths.nvim_set_hl_ns(ns)
|
||||||
eq(ns, meths.get_hl_ns({}))
|
eq(ns, meths.nvim_get_hl_ns({}))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('set/get window highlight namespace', function()
|
it('set/get window highlight namespace', function()
|
||||||
eq(-1, meths.get_hl_ns({ winid = 0 }))
|
eq(-1, meths.nvim_get_hl_ns({ winid = 0 }))
|
||||||
local ns = meths.create_namespace('')
|
local ns = meths.nvim_create_namespace('')
|
||||||
meths.win_set_hl_ns(0, ns)
|
meths.nvim_win_set_hl_ns(0, ns)
|
||||||
eq(ns, meths.get_hl_ns({ winid = 0 }))
|
eq(ns, meths.nvim_get_hl_ns({ winid = 0 }))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
@@ -57,7 +57,7 @@ describe('nvim_get_keymap', function()
|
|||||||
}
|
}
|
||||||
|
|
||||||
it('returns empty list when no map', function()
|
it('returns empty list when no map', function()
|
||||||
eq({}, meths.get_keymap('n'))
|
eq({}, meths.nvim_get_keymap('n'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('returns list of all applicable mappings', function()
|
it('returns list of all applicable mappings', function()
|
||||||
@@ -66,8 +66,8 @@ describe('nvim_get_keymap', function()
|
|||||||
-- Should be the same as the dictionary we supplied earlier
|
-- Should be the same as the dictionary we supplied earlier
|
||||||
-- and the dictionary you would get from maparg
|
-- and the dictionary you would get from maparg
|
||||||
-- since this is a global map, and not script local
|
-- since this is a global map, and not script local
|
||||||
eq({ foo_bar_map_table }, meths.get_keymap('n'))
|
eq({ foo_bar_map_table }, meths.nvim_get_keymap('n'))
|
||||||
eq({ funcs.maparg('foo', 'n', false, true) }, meths.get_keymap('n'))
|
eq({ funcs.maparg('foo', 'n', false, true) }, meths.nvim_get_keymap('n'))
|
||||||
|
|
||||||
-- Add another mapping
|
-- Add another mapping
|
||||||
command('nnoremap foo_longer bar_longer')
|
command('nnoremap foo_longer bar_longer')
|
||||||
@@ -76,11 +76,11 @@ describe('nvim_get_keymap', function()
|
|||||||
foolong_bar_map_table['lhsraw'] = 'foo_longer'
|
foolong_bar_map_table['lhsraw'] = 'foo_longer'
|
||||||
foolong_bar_map_table['rhs'] = 'bar_longer'
|
foolong_bar_map_table['rhs'] = 'bar_longer'
|
||||||
|
|
||||||
eq({ foolong_bar_map_table, foo_bar_map_table }, meths.get_keymap('n'))
|
eq({ foolong_bar_map_table, foo_bar_map_table }, meths.nvim_get_keymap('n'))
|
||||||
|
|
||||||
-- Remove a mapping
|
-- Remove a mapping
|
||||||
command('unmap foo_longer')
|
command('unmap foo_longer')
|
||||||
eq({ foo_bar_map_table }, meths.get_keymap('n'))
|
eq({ foo_bar_map_table }, meths.nvim_get_keymap('n'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('works for other modes', function()
|
it('works for other modes', function()
|
||||||
@@ -94,7 +94,7 @@ describe('nvim_get_keymap', function()
|
|||||||
insert_table['mode'] = 'i'
|
insert_table['mode'] = 'i'
|
||||||
insert_table['mode_bits'] = 0x10
|
insert_table['mode_bits'] = 0x10
|
||||||
|
|
||||||
eq({ insert_table }, meths.get_keymap('i'))
|
eq({ insert_table }, meths.nvim_get_keymap('i'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('considers scope', function()
|
it('considers scope', function()
|
||||||
@@ -111,7 +111,7 @@ describe('nvim_get_keymap', function()
|
|||||||
command('nnoremap <buffer> foo bar')
|
command('nnoremap <buffer> foo bar')
|
||||||
|
|
||||||
-- The buffer mapping should not show up
|
-- The buffer mapping should not show up
|
||||||
eq({ foolong_bar_map_table }, meths.get_keymap('n'))
|
eq({ foolong_bar_map_table }, meths.nvim_get_keymap('n'))
|
||||||
eq({ buffer_table }, curbufmeths.get_keymap('n'))
|
eq({ buffer_table }, curbufmeths.get_keymap('n'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -123,7 +123,7 @@ describe('nvim_get_keymap', function()
|
|||||||
|
|
||||||
command('nnoremap <buffer> foo bar')
|
command('nnoremap <buffer> foo bar')
|
||||||
|
|
||||||
eq({ foo_bar_map_table }, meths.get_keymap('n'))
|
eq({ foo_bar_map_table }, meths.nvim_get_keymap('n'))
|
||||||
eq({ buffer_table }, curbufmeths.get_keymap('n'))
|
eq({ buffer_table }, curbufmeths.get_keymap('n'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -143,15 +143,15 @@ describe('nvim_get_keymap', function()
|
|||||||
-- Final buffer will have buffer mappings
|
-- Final buffer will have buffer mappings
|
||||||
local buffer_table = shallowcopy(foo_bar_map_table)
|
local buffer_table = shallowcopy(foo_bar_map_table)
|
||||||
buffer_table['buffer'] = final_buffer
|
buffer_table['buffer'] = final_buffer
|
||||||
eq({ buffer_table }, meths.buf_get_keymap(final_buffer, 'n'))
|
eq({ buffer_table }, meths.nvim_buf_get_keymap(final_buffer, 'n'))
|
||||||
eq({ buffer_table }, meths.buf_get_keymap(0, 'n'))
|
eq({ buffer_table }, meths.nvim_buf_get_keymap(0, 'n'))
|
||||||
|
|
||||||
command('buffer ' .. original_buffer)
|
command('buffer ' .. original_buffer)
|
||||||
eq(original_buffer, curbufmeths.get_number())
|
eq(original_buffer, curbufmeths.get_number())
|
||||||
-- Original buffer won't have any mappings
|
-- Original buffer won't have any mappings
|
||||||
eq({}, meths.get_keymap('n'))
|
eq({}, meths.nvim_get_keymap('n'))
|
||||||
eq({}, curbufmeths.get_keymap('n'))
|
eq({}, curbufmeths.get_keymap('n'))
|
||||||
eq({ buffer_table }, meths.buf_get_keymap(final_buffer, 'n'))
|
eq({ buffer_table }, meths.nvim_buf_get_keymap(final_buffer, 'n'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Test toggle switches for basic options
|
-- Test toggle switches for basic options
|
||||||
@@ -191,7 +191,7 @@ describe('nvim_get_keymap', function()
|
|||||||
function()
|
function()
|
||||||
make_new_windows(new_windows)
|
make_new_windows(new_windows)
|
||||||
command(map .. ' ' .. option_token .. ' foo bar')
|
command(map .. ' ' .. option_token .. ' foo bar')
|
||||||
local result = meths.get_keymap(mode)[1][option]
|
local result = meths.nvim_get_keymap(mode)[1][option]
|
||||||
eq(global_on_result, result)
|
eq(global_on_result, result)
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
@@ -228,7 +228,7 @@ describe('nvim_get_keymap', function()
|
|||||||
function()
|
function()
|
||||||
make_new_windows(new_windows)
|
make_new_windows(new_windows)
|
||||||
command(map .. ' baz bat')
|
command(map .. ' baz bat')
|
||||||
local result = meths.get_keymap(mode)[1][option]
|
local result = meths.nvim_get_keymap(mode)[1][option]
|
||||||
eq(global_off_result, result)
|
eq(global_off_result, result)
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
@@ -277,9 +277,9 @@ describe('nvim_get_keymap', function()
|
|||||||
|
|
||||||
nnoremap fizz :call <SID>maparg_test_function()<CR>
|
nnoremap fizz :call <SID>maparg_test_function()<CR>
|
||||||
]])
|
]])
|
||||||
local sid_result = meths.get_keymap('n')[1]['sid']
|
local sid_result = meths.nvim_get_keymap('n')[1]['sid']
|
||||||
eq(1, sid_result)
|
eq(1, sid_result)
|
||||||
eq('testing', meths.call_function('<SNR>' .. sid_result .. '_maparg_test_function', {}))
|
eq('testing', meths.nvim_call_function('<SNR>' .. sid_result .. '_maparg_test_function', {}))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('returns script numbers for buffer maps', function()
|
it('returns script numbers for buffer maps', function()
|
||||||
@@ -292,13 +292,13 @@ describe('nvim_get_keymap', function()
|
|||||||
]])
|
]])
|
||||||
local sid_result = curbufmeths.get_keymap('n')[1]['sid']
|
local sid_result = curbufmeths.get_keymap('n')[1]['sid']
|
||||||
eq(1, sid_result)
|
eq(1, sid_result)
|
||||||
eq('testing', meths.call_function('<SNR>' .. sid_result .. '_maparg_test_function', {}))
|
eq('testing', meths.nvim_call_function('<SNR>' .. sid_result .. '_maparg_test_function', {}))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('works with <F12> and others', function()
|
it('works with <F12> and others', function()
|
||||||
command('nnoremap <F12> :let g:maparg_test_var = 1<CR>')
|
command('nnoremap <F12> :let g:maparg_test_var = 1<CR>')
|
||||||
eq('<F12>', meths.get_keymap('n')[1]['lhs'])
|
eq('<F12>', meths.nvim_get_keymap('n')[1]['lhs'])
|
||||||
eq(':let g:maparg_test_var = 1<CR>', meths.get_keymap('n')[1]['rhs'])
|
eq(':let g:maparg_test_var = 1<CR>', meths.nvim_get_keymap('n')[1]['rhs'])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('works correctly despite various &cpo settings', function()
|
it('works correctly despite various &cpo settings', function()
|
||||||
@@ -341,7 +341,7 @@ describe('nvim_get_keymap', function()
|
|||||||
|
|
||||||
-- wrapper around get_keymap() that drops "lhsraw" and "lhsrawalt" which are hard to check
|
-- wrapper around get_keymap() that drops "lhsraw" and "lhsrawalt" which are hard to check
|
||||||
local function get_keymap_noraw(...)
|
local function get_keymap_noraw(...)
|
||||||
local ret = meths.get_keymap(...)
|
local ret = meths.nvim_get_keymap(...)
|
||||||
for _, item in ipairs(ret) do
|
for _, item in ipairs(ret) do
|
||||||
item.lhsraw = nil
|
item.lhsraw = nil
|
||||||
item.lhsrawalt = nil
|
item.lhsrawalt = nil
|
||||||
@@ -392,7 +392,7 @@ describe('nvim_get_keymap', function()
|
|||||||
lnum = 0,
|
lnum = 0,
|
||||||
}
|
}
|
||||||
command('nnoremap \\|<Char-0x20><Char-32><Space><Bar> \\|<Char-0x20><Char-32><Space> <Bar>')
|
command('nnoremap \\|<Char-0x20><Char-32><Space><Bar> \\|<Char-0x20><Char-32><Space> <Bar>')
|
||||||
eq({ space_table }, meths.get_keymap('n'))
|
eq({ space_table }, meths.nvim_get_keymap('n'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('can handle lua mappings', function()
|
it('can handle lua mappings', function()
|
||||||
@@ -421,7 +421,7 @@ describe('nvim_get_keymap', function()
|
|||||||
]])
|
]])
|
||||||
eq(3, exec_lua([[return GlobalCount]]))
|
eq(3, exec_lua([[return GlobalCount]]))
|
||||||
|
|
||||||
local mapargs = meths.get_keymap('n')
|
local mapargs = meths.nvim_get_keymap('n')
|
||||||
mapargs[1].callback = nil
|
mapargs[1].callback = nil
|
||||||
eq({
|
eq({
|
||||||
lhs = 'asdf',
|
lhs = 'asdf',
|
||||||
@@ -442,7 +442,7 @@ describe('nvim_get_keymap', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('can handle map descriptions', function()
|
it('can handle map descriptions', function()
|
||||||
meths.set_keymap('n', 'lhs', 'rhs', { desc = 'map description' })
|
meths.nvim_set_keymap('n', 'lhs', 'rhs', { desc = 'map description' })
|
||||||
eq({
|
eq({
|
||||||
lhs = 'lhs',
|
lhs = 'lhs',
|
||||||
lhsraw = 'lhs',
|
lhsraw = 'lhs',
|
||||||
@@ -460,7 +460,7 @@ describe('nvim_get_keymap', function()
|
|||||||
noremap = 0,
|
noremap = 0,
|
||||||
lnum = 0,
|
lnum = 0,
|
||||||
desc = 'map description',
|
desc = 'map description',
|
||||||
}, meths.get_keymap('n')[1])
|
}, meths.nvim_get_keymap('n')[1])
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -522,9 +522,9 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
|||||||
|
|
||||||
it('error on empty LHS', function()
|
it('error on empty LHS', function()
|
||||||
-- escape parentheses in lua string, else comparison fails erroneously
|
-- escape parentheses in lua string, else comparison fails erroneously
|
||||||
eq('Invalid (empty) LHS', pcall_err(meths.set_keymap, '', '', 'rhs', {}))
|
eq('Invalid (empty) LHS', pcall_err(meths.nvim_set_keymap, '', '', 'rhs', {}))
|
||||||
eq('Invalid (empty) LHS', pcall_err(meths.set_keymap, '', '', '', {}))
|
eq('Invalid (empty) LHS', pcall_err(meths.nvim_set_keymap, '', '', '', {}))
|
||||||
eq('Invalid (empty) LHS', pcall_err(meths.del_keymap, '', ''))
|
eq('Invalid (empty) LHS', pcall_err(meths.nvim_del_keymap, '', ''))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('error if LHS longer than MAXMAPLEN', function()
|
it('error if LHS longer than MAXMAPLEN', function()
|
||||||
@@ -536,16 +536,19 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- exactly 50 chars should be fine
|
-- exactly 50 chars should be fine
|
||||||
meths.set_keymap('', lhs, 'rhs', {})
|
meths.nvim_set_keymap('', lhs, 'rhs', {})
|
||||||
|
|
||||||
-- del_keymap should unmap successfully
|
-- del_keymap should unmap successfully
|
||||||
meths.del_keymap('', lhs)
|
meths.nvim_del_keymap('', lhs)
|
||||||
eq({}, get_mapargs('', lhs))
|
eq({}, get_mapargs('', lhs))
|
||||||
|
|
||||||
-- 51 chars should produce an error
|
-- 51 chars should produce an error
|
||||||
lhs = lhs .. '1'
|
lhs = lhs .. '1'
|
||||||
eq('LHS exceeds maximum map length: ' .. lhs, pcall_err(meths.set_keymap, '', lhs, 'rhs', {}))
|
eq(
|
||||||
eq('LHS exceeds maximum map length: ' .. lhs, pcall_err(meths.del_keymap, '', lhs))
|
'LHS exceeds maximum map length: ' .. lhs,
|
||||||
|
pcall_err(meths.nvim_set_keymap, '', lhs, 'rhs', {})
|
||||||
|
)
|
||||||
|
eq('LHS exceeds maximum map length: ' .. lhs, pcall_err(meths.nvim_del_keymap, '', lhs))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('does not throw errors when rhs is longer than MAXMAPLEN', function()
|
it('does not throw errors when rhs is longer than MAXMAPLEN', function()
|
||||||
@@ -555,56 +558,65 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
|||||||
rhs = rhs .. (i % 10)
|
rhs = rhs .. (i % 10)
|
||||||
end
|
end
|
||||||
rhs = rhs .. '1'
|
rhs = rhs .. '1'
|
||||||
meths.set_keymap('', 'lhs', rhs, {})
|
meths.nvim_set_keymap('', 'lhs', rhs, {})
|
||||||
eq(generate_mapargs('', 'lhs', rhs), get_mapargs('', 'lhs'))
|
eq(generate_mapargs('', 'lhs', rhs), get_mapargs('', 'lhs'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('error on invalid mode shortname', function()
|
it('error on invalid mode shortname', function()
|
||||||
eq('Invalid mode shortname: " "', pcall_err(meths.set_keymap, ' ', 'lhs', 'rhs', {}))
|
eq('Invalid mode shortname: " "', pcall_err(meths.nvim_set_keymap, ' ', 'lhs', 'rhs', {}))
|
||||||
eq('Invalid mode shortname: "m"', pcall_err(meths.set_keymap, 'm', 'lhs', 'rhs', {}))
|
eq('Invalid mode shortname: "m"', pcall_err(meths.nvim_set_keymap, 'm', 'lhs', 'rhs', {}))
|
||||||
eq('Invalid mode shortname: "?"', pcall_err(meths.set_keymap, '?', 'lhs', 'rhs', {}))
|
eq('Invalid mode shortname: "?"', pcall_err(meths.nvim_set_keymap, '?', 'lhs', 'rhs', {}))
|
||||||
eq('Invalid mode shortname: "y"', pcall_err(meths.set_keymap, 'y', 'lhs', 'rhs', {}))
|
eq('Invalid mode shortname: "y"', pcall_err(meths.nvim_set_keymap, 'y', 'lhs', 'rhs', {}))
|
||||||
eq('Invalid mode shortname: "p"', pcall_err(meths.set_keymap, 'p', 'lhs', 'rhs', {}))
|
eq('Invalid mode shortname: "p"', pcall_err(meths.nvim_set_keymap, 'p', 'lhs', 'rhs', {}))
|
||||||
eq('Invalid mode shortname: "a"', pcall_err(meths.set_keymap, 'a', 'lhs', 'rhs', {}))
|
eq('Invalid mode shortname: "a"', pcall_err(meths.nvim_set_keymap, 'a', 'lhs', 'rhs', {}))
|
||||||
eq('Invalid mode shortname: "oa"', pcall_err(meths.set_keymap, 'oa', 'lhs', 'rhs', {}))
|
eq('Invalid mode shortname: "oa"', pcall_err(meths.nvim_set_keymap, 'oa', 'lhs', 'rhs', {}))
|
||||||
eq('Invalid mode shortname: "!o"', pcall_err(meths.set_keymap, '!o', 'lhs', 'rhs', {}))
|
eq('Invalid mode shortname: "!o"', pcall_err(meths.nvim_set_keymap, '!o', 'lhs', 'rhs', {}))
|
||||||
eq('Invalid mode shortname: "!i"', pcall_err(meths.set_keymap, '!i', 'lhs', 'rhs', {}))
|
eq('Invalid mode shortname: "!i"', pcall_err(meths.nvim_set_keymap, '!i', 'lhs', 'rhs', {}))
|
||||||
eq('Invalid mode shortname: "!!"', pcall_err(meths.set_keymap, '!!', 'lhs', 'rhs', {}))
|
eq('Invalid mode shortname: "!!"', pcall_err(meths.nvim_set_keymap, '!!', 'lhs', 'rhs', {}))
|
||||||
eq('Invalid mode shortname: "map"', pcall_err(meths.set_keymap, 'map', 'lhs', 'rhs', {}))
|
eq('Invalid mode shortname: "map"', pcall_err(meths.nvim_set_keymap, 'map', 'lhs', 'rhs', {}))
|
||||||
eq('Invalid mode shortname: "vmap"', pcall_err(meths.set_keymap, 'vmap', 'lhs', 'rhs', {}))
|
eq('Invalid mode shortname: "vmap"', pcall_err(meths.nvim_set_keymap, 'vmap', 'lhs', 'rhs', {}))
|
||||||
eq(
|
eq(
|
||||||
'Invalid mode shortname: "xnoremap"',
|
'Invalid mode shortname: "xnoremap"',
|
||||||
pcall_err(meths.set_keymap, 'xnoremap', 'lhs', 'rhs', {})
|
pcall_err(meths.nvim_set_keymap, 'xnoremap', 'lhs', 'rhs', {})
|
||||||
)
|
)
|
||||||
eq('Invalid mode shortname: " "', pcall_err(meths.del_keymap, ' ', 'lhs'))
|
eq('Invalid mode shortname: " "', pcall_err(meths.nvim_del_keymap, ' ', 'lhs'))
|
||||||
eq('Invalid mode shortname: "m"', pcall_err(meths.del_keymap, 'm', 'lhs'))
|
eq('Invalid mode shortname: "m"', pcall_err(meths.nvim_del_keymap, 'm', 'lhs'))
|
||||||
eq('Invalid mode shortname: "?"', pcall_err(meths.del_keymap, '?', 'lhs'))
|
eq('Invalid mode shortname: "?"', pcall_err(meths.nvim_del_keymap, '?', 'lhs'))
|
||||||
eq('Invalid mode shortname: "y"', pcall_err(meths.del_keymap, 'y', 'lhs'))
|
eq('Invalid mode shortname: "y"', pcall_err(meths.nvim_del_keymap, 'y', 'lhs'))
|
||||||
eq('Invalid mode shortname: "p"', pcall_err(meths.del_keymap, 'p', 'lhs'))
|
eq('Invalid mode shortname: "p"', pcall_err(meths.nvim_del_keymap, 'p', 'lhs'))
|
||||||
eq('Invalid mode shortname: "a"', pcall_err(meths.del_keymap, 'a', 'lhs'))
|
eq('Invalid mode shortname: "a"', pcall_err(meths.nvim_del_keymap, 'a', 'lhs'))
|
||||||
eq('Invalid mode shortname: "oa"', pcall_err(meths.del_keymap, 'oa', 'lhs'))
|
eq('Invalid mode shortname: "oa"', pcall_err(meths.nvim_del_keymap, 'oa', 'lhs'))
|
||||||
eq('Invalid mode shortname: "!o"', pcall_err(meths.del_keymap, '!o', 'lhs'))
|
eq('Invalid mode shortname: "!o"', pcall_err(meths.nvim_del_keymap, '!o', 'lhs'))
|
||||||
eq('Invalid mode shortname: "!i"', pcall_err(meths.del_keymap, '!i', 'lhs'))
|
eq('Invalid mode shortname: "!i"', pcall_err(meths.nvim_del_keymap, '!i', 'lhs'))
|
||||||
eq('Invalid mode shortname: "!!"', pcall_err(meths.del_keymap, '!!', 'lhs'))
|
eq('Invalid mode shortname: "!!"', pcall_err(meths.nvim_del_keymap, '!!', 'lhs'))
|
||||||
eq('Invalid mode shortname: "map"', pcall_err(meths.del_keymap, 'map', 'lhs'))
|
eq('Invalid mode shortname: "map"', pcall_err(meths.nvim_del_keymap, 'map', 'lhs'))
|
||||||
eq('Invalid mode shortname: "vmap"', pcall_err(meths.del_keymap, 'vmap', 'lhs'))
|
eq('Invalid mode shortname: "vmap"', pcall_err(meths.nvim_del_keymap, 'vmap', 'lhs'))
|
||||||
eq('Invalid mode shortname: "xnoremap"', pcall_err(meths.del_keymap, 'xnoremap', 'lhs'))
|
eq('Invalid mode shortname: "xnoremap"', pcall_err(meths.nvim_del_keymap, 'xnoremap', 'lhs'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('error on invalid optnames', function()
|
it('error on invalid optnames', function()
|
||||||
eq("Invalid key: 'silentt'", pcall_err(meths.set_keymap, 'n', 'lhs', 'rhs', { silentt = true }))
|
eq(
|
||||||
eq("Invalid key: 'sidd'", pcall_err(meths.set_keymap, 'n', 'lhs', 'rhs', { sidd = false }))
|
"Invalid key: 'silentt'",
|
||||||
eq("Invalid key: 'nowaiT'", pcall_err(meths.set_keymap, 'n', 'lhs', 'rhs', { nowaiT = false }))
|
pcall_err(meths.nvim_set_keymap, 'n', 'lhs', 'rhs', { silentt = true })
|
||||||
|
)
|
||||||
|
eq("Invalid key: 'sidd'", pcall_err(meths.nvim_set_keymap, 'n', 'lhs', 'rhs', { sidd = false }))
|
||||||
|
eq(
|
||||||
|
"Invalid key: 'nowaiT'",
|
||||||
|
pcall_err(meths.nvim_set_keymap, 'n', 'lhs', 'rhs', { nowaiT = false })
|
||||||
|
)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('error on <buffer> option key', function()
|
it('error on <buffer> option key', function()
|
||||||
eq("Invalid key: 'buffer'", pcall_err(meths.set_keymap, 'n', 'lhs', 'rhs', { buffer = true }))
|
eq(
|
||||||
|
"Invalid key: 'buffer'",
|
||||||
|
pcall_err(meths.nvim_set_keymap, 'n', 'lhs', 'rhs', { buffer = true })
|
||||||
|
)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('error when "replace_keycodes" is used without "expr"', function()
|
it('error when "replace_keycodes" is used without "expr"', function()
|
||||||
eq(
|
eq(
|
||||||
'"replace_keycodes" requires "expr"',
|
'"replace_keycodes" requires "expr"',
|
||||||
pcall_err(meths.set_keymap, 'n', 'lhs', 'rhs', { replace_keycodes = true })
|
pcall_err(meths.nvim_set_keymap, 'n', 'lhs', 'rhs', { replace_keycodes = true })
|
||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -614,45 +626,45 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
|||||||
it('throws an error when given non-boolean value for ' .. opt, function()
|
it('throws an error when given non-boolean value for ' .. opt, function()
|
||||||
local opts = {}
|
local opts = {}
|
||||||
opts[opt] = 'fooo'
|
opts[opt] = 'fooo'
|
||||||
eq(opt .. ' is not a boolean', pcall_err(meths.set_keymap, 'n', 'lhs', 'rhs', opts))
|
eq(opt .. ' is not a boolean', pcall_err(meths.nvim_set_keymap, 'n', 'lhs', 'rhs', opts))
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Perform tests of basic functionality
|
-- Perform tests of basic functionality
|
||||||
it('sets ordinary mappings', function()
|
it('sets ordinary mappings', function()
|
||||||
meths.set_keymap('n', 'lhs', 'rhs', {})
|
meths.nvim_set_keymap('n', 'lhs', 'rhs', {})
|
||||||
eq(generate_mapargs('n', 'lhs', 'rhs'), get_mapargs('n', 'lhs'))
|
eq(generate_mapargs('n', 'lhs', 'rhs'), get_mapargs('n', 'lhs'))
|
||||||
|
|
||||||
meths.set_keymap('v', 'lhs', 'rhs', {})
|
meths.nvim_set_keymap('v', 'lhs', 'rhs', {})
|
||||||
eq(generate_mapargs('v', 'lhs', 'rhs'), get_mapargs('v', 'lhs'))
|
eq(generate_mapargs('v', 'lhs', 'rhs'), get_mapargs('v', 'lhs'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('does not throw when LHS or RHS have leading/trailing whitespace', function()
|
it('does not throw when LHS or RHS have leading/trailing whitespace', function()
|
||||||
meths.set_keymap('n', ' lhs', 'rhs', {})
|
meths.nvim_set_keymap('n', ' lhs', 'rhs', {})
|
||||||
eq(generate_mapargs('n', '<Space><Space><Space>lhs', 'rhs'), get_mapargs('n', ' lhs'))
|
eq(generate_mapargs('n', '<Space><Space><Space>lhs', 'rhs'), get_mapargs('n', ' lhs'))
|
||||||
|
|
||||||
meths.set_keymap('n', 'lhs ', 'rhs', {})
|
meths.nvim_set_keymap('n', 'lhs ', 'rhs', {})
|
||||||
eq(generate_mapargs('n', 'lhs<Space><Space><Space><Space>', 'rhs'), get_mapargs('n', 'lhs '))
|
eq(generate_mapargs('n', 'lhs<Space><Space><Space><Space>', 'rhs'), get_mapargs('n', 'lhs '))
|
||||||
|
|
||||||
meths.set_keymap('v', ' lhs ', '\trhs\t\f', {})
|
meths.nvim_set_keymap('v', ' lhs ', '\trhs\t\f', {})
|
||||||
eq(generate_mapargs('v', '<Space>lhs<Space><Space>', '\trhs\t\f'), get_mapargs('v', ' lhs '))
|
eq(generate_mapargs('v', '<Space>lhs<Space><Space>', '\trhs\t\f'), get_mapargs('v', ' lhs '))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('can set noremap mappings', function()
|
it('can set noremap mappings', function()
|
||||||
meths.set_keymap('x', 'lhs', 'rhs', { noremap = true })
|
meths.nvim_set_keymap('x', 'lhs', 'rhs', { noremap = true })
|
||||||
eq(generate_mapargs('x', 'lhs', 'rhs', { noremap = true }), get_mapargs('x', 'lhs'))
|
eq(generate_mapargs('x', 'lhs', 'rhs', { noremap = true }), get_mapargs('x', 'lhs'))
|
||||||
|
|
||||||
meths.set_keymap('t', 'lhs', 'rhs', { noremap = true })
|
meths.nvim_set_keymap('t', 'lhs', 'rhs', { noremap = true })
|
||||||
eq(generate_mapargs('t', 'lhs', 'rhs', { noremap = true }), get_mapargs('t', 'lhs'))
|
eq(generate_mapargs('t', 'lhs', 'rhs', { noremap = true }), get_mapargs('t', 'lhs'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('can unmap mappings', function()
|
it('can unmap mappings', function()
|
||||||
meths.set_keymap('v', 'lhs', 'rhs', {})
|
meths.nvim_set_keymap('v', 'lhs', 'rhs', {})
|
||||||
meths.del_keymap('v', 'lhs')
|
meths.nvim_del_keymap('v', 'lhs')
|
||||||
eq({}, get_mapargs('v', 'lhs'))
|
eq({}, get_mapargs('v', 'lhs'))
|
||||||
|
|
||||||
meths.set_keymap('t', 'lhs', 'rhs', { noremap = true })
|
meths.nvim_set_keymap('t', 'lhs', 'rhs', { noremap = true })
|
||||||
meths.del_keymap('t', 'lhs')
|
meths.nvim_del_keymap('t', 'lhs')
|
||||||
eq({}, get_mapargs('t', 'lhs'))
|
eq({}, get_mapargs('t', 'lhs'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -660,8 +672,8 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
|||||||
it('"!" and empty string are synonyms for mapmode-nvo', function()
|
it('"!" and empty string are synonyms for mapmode-nvo', function()
|
||||||
local nvo_shortnames = { '', '!' }
|
local nvo_shortnames = { '', '!' }
|
||||||
for _, name in ipairs(nvo_shortnames) do
|
for _, name in ipairs(nvo_shortnames) do
|
||||||
meths.set_keymap(name, 'lhs', 'rhs', {})
|
meths.nvim_set_keymap(name, 'lhs', 'rhs', {})
|
||||||
meths.del_keymap(name, 'lhs')
|
meths.nvim_del_keymap(name, 'lhs')
|
||||||
eq({}, get_mapargs(name, 'lhs'))
|
eq({}, get_mapargs(name, 'lhs'))
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
@@ -671,46 +683,46 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
|||||||
for _, rhs in ipairs(special_chars) do
|
for _, rhs in ipairs(special_chars) do
|
||||||
local mapmode = '!'
|
local mapmode = '!'
|
||||||
it('can set mappings with special characters, lhs: ' .. lhs .. ', rhs: ' .. rhs, function()
|
it('can set mappings with special characters, lhs: ' .. lhs .. ', rhs: ' .. rhs, function()
|
||||||
meths.set_keymap(mapmode, lhs, rhs, {})
|
meths.nvim_set_keymap(mapmode, lhs, rhs, {})
|
||||||
eq(generate_mapargs(mapmode, lhs, rhs), get_mapargs(mapmode, lhs))
|
eq(generate_mapargs(mapmode, lhs, rhs), get_mapargs(mapmode, lhs))
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it('can set mappings containing literal keycodes', function()
|
it('can set mappings containing literal keycodes', function()
|
||||||
meths.set_keymap('n', '\n\r\n', 'rhs', {})
|
meths.nvim_set_keymap('n', '\n\r\n', 'rhs', {})
|
||||||
local expected = generate_mapargs('n', '<NL><CR><NL>', 'rhs')
|
local expected = generate_mapargs('n', '<NL><CR><NL>', 'rhs')
|
||||||
eq(expected, get_mapargs('n', '<NL><CR><NL>'))
|
eq(expected, get_mapargs('n', '<NL><CR><NL>'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('can set mappings whose RHS is a <Nop>', function()
|
it('can set mappings whose RHS is a <Nop>', function()
|
||||||
meths.set_keymap('i', 'lhs', '<Nop>', {})
|
meths.nvim_set_keymap('i', 'lhs', '<Nop>', {})
|
||||||
command('normal ilhs')
|
command('normal ilhs')
|
||||||
eq({ '' }, curbufmeths.get_lines(0, -1, 0)) -- imap to <Nop> does nothing
|
eq({ '' }, curbufmeths.get_lines(0, -1, 0)) -- imap to <Nop> does nothing
|
||||||
eq(generate_mapargs('i', 'lhs', '<Nop>', {}), get_mapargs('i', 'lhs'))
|
eq(generate_mapargs('i', 'lhs', '<Nop>', {}), get_mapargs('i', 'lhs'))
|
||||||
|
|
||||||
-- also test for case insensitivity
|
-- also test for case insensitivity
|
||||||
meths.set_keymap('i', 'lhs', '<nOp>', {})
|
meths.nvim_set_keymap('i', 'lhs', '<nOp>', {})
|
||||||
command('normal ilhs')
|
command('normal ilhs')
|
||||||
eq({ '' }, curbufmeths.get_lines(0, -1, 0))
|
eq({ '' }, curbufmeths.get_lines(0, -1, 0))
|
||||||
-- note: RHS in returned mapargs() dict reflects the original RHS
|
-- note: RHS in returned mapargs() dict reflects the original RHS
|
||||||
-- provided by the user
|
-- provided by the user
|
||||||
eq(generate_mapargs('i', 'lhs', '<nOp>', {}), get_mapargs('i', 'lhs'))
|
eq(generate_mapargs('i', 'lhs', '<nOp>', {}), get_mapargs('i', 'lhs'))
|
||||||
|
|
||||||
meths.set_keymap('i', 'lhs', '<NOP>', {})
|
meths.nvim_set_keymap('i', 'lhs', '<NOP>', {})
|
||||||
command('normal ilhs')
|
command('normal ilhs')
|
||||||
eq({ '' }, curbufmeths.get_lines(0, -1, 0))
|
eq({ '' }, curbufmeths.get_lines(0, -1, 0))
|
||||||
eq(generate_mapargs('i', 'lhs', '<NOP>', {}), get_mapargs('i', 'lhs'))
|
eq(generate_mapargs('i', 'lhs', '<NOP>', {}), get_mapargs('i', 'lhs'))
|
||||||
|
|
||||||
-- a single ^V in RHS is also <Nop> (see :h map-empty-rhs)
|
-- a single ^V in RHS is also <Nop> (see :h map-empty-rhs)
|
||||||
meths.set_keymap('i', 'lhs', '\022', {})
|
meths.nvim_set_keymap('i', 'lhs', '\022', {})
|
||||||
command('normal ilhs')
|
command('normal ilhs')
|
||||||
eq({ '' }, curbufmeths.get_lines(0, -1, 0))
|
eq({ '' }, curbufmeths.get_lines(0, -1, 0))
|
||||||
eq(generate_mapargs('i', 'lhs', '\022', {}), get_mapargs('i', 'lhs'))
|
eq(generate_mapargs('i', 'lhs', '\022', {}), get_mapargs('i', 'lhs'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('treats an empty RHS in a mapping like a <Nop>', function()
|
it('treats an empty RHS in a mapping like a <Nop>', function()
|
||||||
meths.set_keymap('i', 'lhs', '', {})
|
meths.nvim_set_keymap('i', 'lhs', '', {})
|
||||||
command('normal ilhs')
|
command('normal ilhs')
|
||||||
eq({ '' }, curbufmeths.get_lines(0, -1, 0))
|
eq({ '' }, curbufmeths.get_lines(0, -1, 0))
|
||||||
eq(generate_mapargs('i', 'lhs', '', {}), get_mapargs('i', 'lhs'))
|
eq(generate_mapargs('i', 'lhs', '', {}), get_mapargs('i', 'lhs'))
|
||||||
@@ -720,8 +732,8 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
|||||||
-- Taken from the legacy test: test_mapping.vim. Exposes a bug in which
|
-- Taken from the legacy test: test_mapping.vim. Exposes a bug in which
|
||||||
-- replace_termcodes changes the length of the mapping's LHS, but
|
-- replace_termcodes changes the length of the mapping's LHS, but
|
||||||
-- do_map continues to use the *old* length of LHS.
|
-- do_map continues to use the *old* length of LHS.
|
||||||
meths.set_keymap('i', '<M-">', 'foo', {})
|
meths.nvim_set_keymap('i', '<M-">', 'foo', {})
|
||||||
meths.del_keymap('i', '<M-">')
|
meths.nvim_del_keymap('i', '<M-">')
|
||||||
eq({}, get_mapargs('i', '<M-">'))
|
eq({}, get_mapargs('i', '<M-">'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -736,13 +748,13 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
|||||||
)
|
)
|
||||||
|
|
||||||
it('throws appropriate error messages when setting <unique> maps', function()
|
it('throws appropriate error messages when setting <unique> maps', function()
|
||||||
meths.set_keymap('l', 'lhs', 'rhs', {})
|
meths.nvim_set_keymap('l', 'lhs', 'rhs', {})
|
||||||
eq(
|
eq(
|
||||||
'E227: mapping already exists for lhs',
|
'E227: mapping already exists for lhs',
|
||||||
pcall_err(meths.set_keymap, 'l', 'lhs', 'rhs', { unique = true })
|
pcall_err(meths.nvim_set_keymap, 'l', 'lhs', 'rhs', { unique = true })
|
||||||
)
|
)
|
||||||
-- different mapmode, no error should be thrown
|
-- different mapmode, no error should be thrown
|
||||||
meths.set_keymap('t', 'lhs', 'rhs', { unique = true })
|
meths.nvim_set_keymap('t', 'lhs', 'rhs', { unique = true })
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('can set <expr> mappings whose RHS change dynamically', function()
|
it('can set <expr> mappings whose RHS change dynamically', function()
|
||||||
@@ -753,12 +765,12 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
|||||||
return g:flip
|
return g:flip
|
||||||
endfunction
|
endfunction
|
||||||
]])
|
]])
|
||||||
eq(1, meths.call_function('FlipFlop', {}))
|
eq(1, meths.nvim_call_function('FlipFlop', {}))
|
||||||
eq(0, meths.call_function('FlipFlop', {}))
|
eq(0, meths.nvim_call_function('FlipFlop', {}))
|
||||||
eq(1, meths.call_function('FlipFlop', {}))
|
eq(1, meths.nvim_call_function('FlipFlop', {}))
|
||||||
eq(0, meths.call_function('FlipFlop', {}))
|
eq(0, meths.nvim_call_function('FlipFlop', {}))
|
||||||
|
|
||||||
meths.set_keymap('i', 'lhs', 'FlipFlop()', { expr = true })
|
meths.nvim_set_keymap('i', 'lhs', 'FlipFlop()', { expr = true })
|
||||||
command('normal ilhs')
|
command('normal ilhs')
|
||||||
eq({ '1' }, curbufmeths.get_lines(0, -1, 0))
|
eq({ '1' }, curbufmeths.get_lines(0, -1, 0))
|
||||||
|
|
||||||
@@ -769,8 +781,8 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('can set mappings that do trigger other mappings', function()
|
it('can set mappings that do trigger other mappings', function()
|
||||||
meths.set_keymap('i', 'mhs', 'rhs', {})
|
meths.nvim_set_keymap('i', 'mhs', 'rhs', {})
|
||||||
meths.set_keymap('i', 'lhs', 'mhs', {})
|
meths.nvim_set_keymap('i', 'lhs', 'mhs', {})
|
||||||
|
|
||||||
command('normal imhs')
|
command('normal imhs')
|
||||||
eq({ 'rhs' }, curbufmeths.get_lines(0, -1, 0))
|
eq({ 'rhs' }, curbufmeths.get_lines(0, -1, 0))
|
||||||
@@ -782,8 +794,8 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it("can set noremap mappings that don't trigger other mappings", function()
|
it("can set noremap mappings that don't trigger other mappings", function()
|
||||||
meths.set_keymap('i', 'mhs', 'rhs', {})
|
meths.nvim_set_keymap('i', 'mhs', 'rhs', {})
|
||||||
meths.set_keymap('i', 'lhs', 'mhs', { noremap = true })
|
meths.nvim_set_keymap('i', 'lhs', 'mhs', { noremap = true })
|
||||||
|
|
||||||
command('normal imhs')
|
command('normal imhs')
|
||||||
eq({ 'rhs' }, curbufmeths.get_lines(0, -1, 0))
|
eq({ 'rhs' }, curbufmeths.get_lines(0, -1, 0))
|
||||||
@@ -795,8 +807,8 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('can set nowait mappings that fire without waiting', function()
|
it('can set nowait mappings that fire without waiting', function()
|
||||||
meths.set_keymap('i', '123456', 'longer', {})
|
meths.nvim_set_keymap('i', '123456', 'longer', {})
|
||||||
meths.set_keymap('i', '123', 'shorter', { nowait = true })
|
meths.nvim_set_keymap('i', '123', 'shorter', { nowait = true })
|
||||||
|
|
||||||
-- feed keys one at a time; if all keys arrive atomically, the longer
|
-- feed keys one at a time; if all keys arrive atomically, the longer
|
||||||
-- mapping will trigger
|
-- mapping will trigger
|
||||||
@@ -812,22 +824,22 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
|||||||
local mapmodes = { 'n', 'v', 'x', 's', 'o', '!', 'i', 'l', 'c', 't', '', 'ia', 'ca', '!a' }
|
local mapmodes = { 'n', 'v', 'x', 's', 'o', '!', 'i', 'l', 'c', 't', '', 'ia', 'ca', '!a' }
|
||||||
for _, mapmode in ipairs(mapmodes) do
|
for _, mapmode in ipairs(mapmodes) do
|
||||||
it('can set/unset normal mappings in mapmode ' .. mapmode, function()
|
it('can set/unset normal mappings in mapmode ' .. mapmode, function()
|
||||||
meths.set_keymap(mapmode, 'lhs', 'rhs', {})
|
meths.nvim_set_keymap(mapmode, 'lhs', 'rhs', {})
|
||||||
eq(generate_mapargs(mapmode, 'lhs', 'rhs'), get_mapargs(mapmode, 'lhs'))
|
eq(generate_mapargs(mapmode, 'lhs', 'rhs'), get_mapargs(mapmode, 'lhs'))
|
||||||
|
|
||||||
-- some mapmodes (like 'o') will prevent other mapmodes (like '!') from
|
-- some mapmodes (like 'o') will prevent other mapmodes (like '!') from
|
||||||
-- taking effect, so unmap after each mapping
|
-- taking effect, so unmap after each mapping
|
||||||
meths.del_keymap(mapmode, 'lhs')
|
meths.nvim_del_keymap(mapmode, 'lhs')
|
||||||
eq({}, get_mapargs(mapmode, 'lhs'))
|
eq({}, get_mapargs(mapmode, 'lhs'))
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, mapmode in ipairs(mapmodes) do
|
for _, mapmode in ipairs(mapmodes) do
|
||||||
it('can set/unset noremap mappings using mapmode ' .. mapmode, function()
|
it('can set/unset noremap mappings using mapmode ' .. mapmode, function()
|
||||||
meths.set_keymap(mapmode, 'lhs', 'rhs', { noremap = true })
|
meths.nvim_set_keymap(mapmode, 'lhs', 'rhs', { noremap = true })
|
||||||
eq(generate_mapargs(mapmode, 'lhs', 'rhs', { noremap = true }), get_mapargs(mapmode, 'lhs'))
|
eq(generate_mapargs(mapmode, 'lhs', 'rhs', { noremap = true }), get_mapargs(mapmode, 'lhs'))
|
||||||
|
|
||||||
meths.del_keymap(mapmode, 'lhs')
|
meths.nvim_del_keymap(mapmode, 'lhs')
|
||||||
eq({}, get_mapargs(mapmode, 'lhs'))
|
eq({}, get_mapargs(mapmode, 'lhs'))
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
@@ -839,12 +851,12 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
|||||||
-- Test with single mappings
|
-- Test with single mappings
|
||||||
for _, maparg in ipairs(optnames) do
|
for _, maparg in ipairs(optnames) do
|
||||||
it('can set/unset ' .. mapmode .. '-mappings with maparg: ' .. maparg, function()
|
it('can set/unset ' .. mapmode .. '-mappings with maparg: ' .. maparg, function()
|
||||||
meths.set_keymap(mapmode, 'lhs', 'rhs', { [maparg] = true })
|
meths.nvim_set_keymap(mapmode, 'lhs', 'rhs', { [maparg] = true })
|
||||||
eq(
|
eq(
|
||||||
generate_mapargs(mapmode, 'lhs', 'rhs', { [maparg] = true }),
|
generate_mapargs(mapmode, 'lhs', 'rhs', { [maparg] = true }),
|
||||||
get_mapargs(mapmode, 'lhs')
|
get_mapargs(mapmode, 'lhs')
|
||||||
)
|
)
|
||||||
meths.del_keymap(mapmode, 'lhs')
|
meths.nvim_del_keymap(mapmode, 'lhs')
|
||||||
eq({}, get_mapargs(mapmode, 'lhs'))
|
eq({}, get_mapargs(mapmode, 'lhs'))
|
||||||
end)
|
end)
|
||||||
it(
|
it(
|
||||||
@@ -854,9 +866,9 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
|||||||
.. maparg
|
.. maparg
|
||||||
.. ', whose value is false',
|
.. ', whose value is false',
|
||||||
function()
|
function()
|
||||||
meths.set_keymap(mapmode, 'lhs', 'rhs', { [maparg] = false })
|
meths.nvim_set_keymap(mapmode, 'lhs', 'rhs', { [maparg] = false })
|
||||||
eq(generate_mapargs(mapmode, 'lhs', 'rhs'), get_mapargs(mapmode, 'lhs'))
|
eq(generate_mapargs(mapmode, 'lhs', 'rhs'), get_mapargs(mapmode, 'lhs'))
|
||||||
meths.del_keymap(mapmode, 'lhs')
|
meths.nvim_del_keymap(mapmode, 'lhs')
|
||||||
eq({}, get_mapargs(mapmode, 'lhs'))
|
eq({}, get_mapargs(mapmode, 'lhs'))
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
@@ -876,9 +888,9 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
|||||||
.. opt3,
|
.. opt3,
|
||||||
function()
|
function()
|
||||||
local opts = { [opt1] = true, [opt2] = false, [opt3] = true }
|
local opts = { [opt1] = true, [opt2] = false, [opt3] = true }
|
||||||
meths.set_keymap(mapmode, 'lhs', 'rhs', opts)
|
meths.nvim_set_keymap(mapmode, 'lhs', 'rhs', opts)
|
||||||
eq(generate_mapargs(mapmode, 'lhs', 'rhs', opts), get_mapargs(mapmode, 'lhs'))
|
eq(generate_mapargs(mapmode, 'lhs', 'rhs', opts), get_mapargs(mapmode, 'lhs'))
|
||||||
meths.del_keymap(mapmode, 'lhs')
|
meths.nvim_del_keymap(mapmode, 'lhs')
|
||||||
eq({}, get_mapargs(mapmode, 'lhs'))
|
eq({}, get_mapargs(mapmode, 'lhs'))
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
@@ -958,7 +970,7 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
|||||||
|
|
||||||
feed('aa')
|
feed('aa')
|
||||||
|
|
||||||
eq({ 'π<M-π>foo<' }, meths.buf_get_lines(0, 0, -1, false))
|
eq({ 'π<M-π>foo<' }, meths.nvim_buf_get_lines(0, 0, -1, false))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('can make lua expr mappings without replacing keycodes', function()
|
it('can make lua expr mappings without replacing keycodes', function()
|
||||||
@@ -968,7 +980,7 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
|||||||
|
|
||||||
feed('iaa<esc>')
|
feed('iaa<esc>')
|
||||||
|
|
||||||
eq({ '<space>' }, meths.buf_get_lines(0, 0, -1, false))
|
eq({ '<space>' }, meths.nvim_buf_get_lines(0, 0, -1, false))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('lua expr mapping returning nil is equivalent to returning an empty string', function()
|
it('lua expr mapping returning nil is equivalent to returning an empty string', function()
|
||||||
@@ -978,7 +990,7 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
|||||||
|
|
||||||
feed('iaa<esc>')
|
feed('iaa<esc>')
|
||||||
|
|
||||||
eq({ '' }, meths.buf_get_lines(0, 0, -1, false))
|
eq({ '' }, meths.nvim_buf_get_lines(0, 0, -1, false))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('does not reset pum in lua mapping', function()
|
it('does not reset pum in lua mapping', function()
|
||||||
@@ -1081,7 +1093,7 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('can set descriptions on mappings', function()
|
it('can set descriptions on mappings', function()
|
||||||
meths.set_keymap('n', 'lhs', 'rhs', { desc = 'map description' })
|
meths.nvim_set_keymap('n', 'lhs', 'rhs', { desc = 'map description' })
|
||||||
eq(generate_mapargs('n', 'lhs', 'rhs', { desc = 'map description' }), get_mapargs('n', 'lhs'))
|
eq(generate_mapargs('n', 'lhs', 'rhs', { desc = 'map description' }), get_mapargs('n', 'lhs'))
|
||||||
eq('\nn lhs rhs\n map description', helpers.exec_capture('nmap lhs'))
|
eq('\nn lhs rhs\n map description', helpers.exec_capture('nmap lhs'))
|
||||||
end)
|
end)
|
||||||
@@ -1096,10 +1108,10 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
|||||||
]]
|
]]
|
||||||
|
|
||||||
feed 'iThe foo and the bar and the foo again<esc>'
|
feed 'iThe foo and the bar and the foo again<esc>'
|
||||||
eq('The 1 and the bar and the 2 again', meths.get_current_line())
|
eq('The 1 and the bar and the 2 again', meths.nvim_get_current_line())
|
||||||
|
|
||||||
feed ':let x = "The foo is the one"<cr>'
|
feed ':let x = "The foo is the one"<cr>'
|
||||||
eq('The 3 is the one', meths.eval 'x')
|
eq('The 3 is the one', meths.nvim_eval 'x')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('can define insert mode abbreviations with lua callbacks', function()
|
it('can define insert mode abbreviations with lua callbacks', function()
|
||||||
@@ -1112,10 +1124,10 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
|||||||
]]
|
]]
|
||||||
|
|
||||||
feed 'iThe foo and the bar and the foo again<esc>'
|
feed 'iThe foo and the bar and the foo again<esc>'
|
||||||
eq('The 1 and the bar and the 2 again', meths.get_current_line())
|
eq('The 1 and the bar and the 2 again', meths.nvim_get_current_line())
|
||||||
|
|
||||||
feed ':let x = "The foo is the one"<cr>'
|
feed ':let x = "The foo is the one"<cr>'
|
||||||
eq('The foo is the one', meths.eval 'x')
|
eq('The foo is the one', meths.nvim_eval 'x')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('can define cmdline mode abbreviations with lua callbacks', function()
|
it('can define cmdline mode abbreviations with lua callbacks', function()
|
||||||
@@ -1128,10 +1140,10 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
|
|||||||
]]
|
]]
|
||||||
|
|
||||||
feed 'iThe foo and the bar and the foo again<esc>'
|
feed 'iThe foo and the bar and the foo again<esc>'
|
||||||
eq('The foo and the bar and the foo again', meths.get_current_line())
|
eq('The foo and the bar and the foo again', meths.nvim_get_current_line())
|
||||||
|
|
||||||
feed ':let x = "The foo is the one"<cr>'
|
feed ':let x = "The foo is the one"<cr>'
|
||||||
eq('The 1 is the one', meths.eval 'x')
|
eq('The 1 is the one', meths.nvim_eval 'x')
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -1154,9 +1166,9 @@ describe('nvim_buf_set_keymap, nvim_buf_del_keymap', function()
|
|||||||
local function make_two_buffers(start_from_first)
|
local function make_two_buffers(start_from_first)
|
||||||
command('set hidden')
|
command('set hidden')
|
||||||
|
|
||||||
local first_buf = meths.call_function('bufnr', { '%' })
|
local first_buf = meths.nvim_call_function('bufnr', { '%' })
|
||||||
command('new')
|
command('new')
|
||||||
local second_buf = meths.call_function('bufnr', { '%' })
|
local second_buf = meths.nvim_call_function('bufnr', { '%' })
|
||||||
neq(second_buf, first_buf) -- sanity check
|
neq(second_buf, first_buf) -- sanity check
|
||||||
|
|
||||||
if start_from_first then
|
if start_from_first then
|
||||||
@@ -1254,7 +1266,7 @@ describe('nvim_buf_set_keymap, nvim_buf_del_keymap', function()
|
|||||||
|
|
||||||
feed('aa')
|
feed('aa')
|
||||||
|
|
||||||
eq({ 'π<M-π>foo<' }, meths.buf_get_lines(0, 0, -1, false))
|
eq({ 'π<M-π>foo<' }, meths.nvim_buf_get_lines(0, 0, -1, false))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('can make lua expr mappings without replacing keycodes', function()
|
it('can make lua expr mappings without replacing keycodes', function()
|
||||||
@@ -1264,7 +1276,7 @@ describe('nvim_buf_set_keymap, nvim_buf_del_keymap', function()
|
|||||||
|
|
||||||
feed('iaa<esc>')
|
feed('iaa<esc>')
|
||||||
|
|
||||||
eq({ '<space>' }, meths.buf_get_lines(0, 0, -1, false))
|
eq({ '<space>' }, meths.nvim_buf_get_lines(0, 0, -1, false))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('can overwrite lua mappings', function()
|
it('can overwrite lua mappings', function()
|
||||||
|
@@ -47,9 +47,11 @@ describe('notify', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('does not crash for deeply nested variable', function()
|
it('does not crash for deeply nested variable', function()
|
||||||
meths.set_var('l', {})
|
meths.nvim_set_var('l', {})
|
||||||
local nest_level = 1000
|
local nest_level = 1000
|
||||||
meths.command(('call map(range(%u), "extend(g:, {\'l\': [g:l]})")'):format(nest_level - 1))
|
meths.nvim_command(
|
||||||
|
('call map(range(%u), "extend(g:, {\'l\': [g:l]})")'):format(nest_level - 1)
|
||||||
|
)
|
||||||
eval('rpcnotify(' .. channel .. ', "event", g:l)')
|
eval('rpcnotify(' .. channel .. ', "event", g:l)')
|
||||||
local msg = next_msg()
|
local msg = next_msg()
|
||||||
eq('notification', msg[1])
|
eq('notification', msg[1])
|
||||||
@@ -106,7 +108,7 @@ describe('notify', function()
|
|||||||
exec_lua([[ return {pcall(vim.rpcrequest, ..., 'nvim_eval', '1+1')}]], catchan)
|
exec_lua([[ return {pcall(vim.rpcrequest, ..., 'nvim_eval', '1+1')}]], catchan)
|
||||||
)
|
)
|
||||||
retry(nil, 3000, function()
|
retry(nil, 3000, function()
|
||||||
eq({}, meths.get_chan_info(catchan))
|
eq({}, meths.nvim_get_chan_info(catchan))
|
||||||
end) -- cat be dead :(
|
end) -- cat be dead :(
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
@@ -244,7 +244,7 @@ describe('server -> client', function()
|
|||||||
\ 'rpc': v:true
|
\ 'rpc': v:true
|
||||||
\ }
|
\ }
|
||||||
]])
|
]])
|
||||||
meths.set_var('args', {
|
meths.nvim_set_var('args', {
|
||||||
nvim_prog,
|
nvim_prog,
|
||||||
'-ll',
|
'-ll',
|
||||||
'test/functional/api/rpc_fixture.lua',
|
'test/functional/api/rpc_fixture.lua',
|
||||||
@@ -296,7 +296,7 @@ describe('server -> client', function()
|
|||||||
|
|
||||||
set_session(server)
|
set_session(server)
|
||||||
eq(serverpid, funcs.getpid())
|
eq(serverpid, funcs.getpid())
|
||||||
eq('hello', meths.get_current_line())
|
eq('hello', meths.nvim_get_current_line())
|
||||||
|
|
||||||
-- method calls work both ways
|
-- method calls work both ways
|
||||||
funcs.rpcrequest(client_id, 'nvim_set_current_line', 'howdy!')
|
funcs.rpcrequest(client_id, 'nvim_set_current_line', 'howdy!')
|
||||||
@@ -304,7 +304,7 @@ describe('server -> client', function()
|
|||||||
|
|
||||||
set_session(client)
|
set_session(client)
|
||||||
eq(clientpid, funcs.getpid())
|
eq(clientpid, funcs.getpid())
|
||||||
eq('howdy!', meths.get_current_line())
|
eq('howdy!', meths.nvim_get_current_line())
|
||||||
|
|
||||||
server:close()
|
server:close()
|
||||||
client:close()
|
client:close()
|
||||||
@@ -375,7 +375,7 @@ describe('server -> client', function()
|
|||||||
local id = funcs.sockconnect('pipe', address, { rpc = true })
|
local id = funcs.sockconnect('pipe', address, { rpc = true })
|
||||||
|
|
||||||
funcs.rpcrequest(id, 'nvim_set_current_line', 'hello')
|
funcs.rpcrequest(id, 'nvim_set_current_line', 'hello')
|
||||||
eq('hello', meths.get_current_line())
|
eq('hello', meths.nvim_get_current_line())
|
||||||
eq(serverpid, funcs.rpcrequest(id, 'nvim_eval', 'getpid()'))
|
eq(serverpid, funcs.rpcrequest(id, 'nvim_eval', 'getpid()'))
|
||||||
|
|
||||||
eq(id, funcs.rpcrequest(id, 'nvim_get_api_info')[1])
|
eq(id, funcs.rpcrequest(id, 'nvim_get_api_info')[1])
|
||||||
|
@@ -23,39 +23,39 @@ describe('nvim_ui_attach()', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('validation', function()
|
it('validation', function()
|
||||||
eq('No such UI option: foo', pcall_err(meths.ui_attach, 80, 24, { foo = { 'foo' } }))
|
eq('No such UI option: foo', pcall_err(meths.nvim_ui_attach, 80, 24, { foo = { 'foo' } }))
|
||||||
|
|
||||||
eq(
|
eq(
|
||||||
"Invalid 'ext_linegrid': expected Boolean, got Array",
|
"Invalid 'ext_linegrid': expected Boolean, got Array",
|
||||||
pcall_err(meths.ui_attach, 80, 24, { ext_linegrid = {} })
|
pcall_err(meths.nvim_ui_attach, 80, 24, { ext_linegrid = {} })
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
"Invalid 'override': expected Boolean, got Array",
|
"Invalid 'override': expected Boolean, got Array",
|
||||||
pcall_err(meths.ui_attach, 80, 24, { override = {} })
|
pcall_err(meths.nvim_ui_attach, 80, 24, { override = {} })
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
"Invalid 'rgb': expected Boolean, got Array",
|
"Invalid 'rgb': expected Boolean, got Array",
|
||||||
pcall_err(meths.ui_attach, 80, 24, { rgb = {} })
|
pcall_err(meths.nvim_ui_attach, 80, 24, { rgb = {} })
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
"Invalid 'term_name': expected String, got Boolean",
|
"Invalid 'term_name': expected String, got Boolean",
|
||||||
pcall_err(meths.ui_attach, 80, 24, { term_name = true })
|
pcall_err(meths.nvim_ui_attach, 80, 24, { term_name = true })
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
"Invalid 'term_colors': expected Integer, got Boolean",
|
"Invalid 'term_colors': expected Integer, got Boolean",
|
||||||
pcall_err(meths.ui_attach, 80, 24, { term_colors = true })
|
pcall_err(meths.nvim_ui_attach, 80, 24, { term_colors = true })
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
"Invalid 'stdin_fd': expected Integer, got String",
|
"Invalid 'stdin_fd': expected Integer, got String",
|
||||||
pcall_err(meths.ui_attach, 80, 24, { stdin_fd = 'foo' })
|
pcall_err(meths.nvim_ui_attach, 80, 24, { stdin_fd = 'foo' })
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
"Invalid 'stdin_tty': expected Boolean, got String",
|
"Invalid 'stdin_tty': expected Boolean, got String",
|
||||||
pcall_err(meths.ui_attach, 80, 24, { stdin_tty = 'foo' })
|
pcall_err(meths.nvim_ui_attach, 80, 24, { stdin_tty = 'foo' })
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
"Invalid 'stdout_tty': expected Boolean, got String",
|
"Invalid 'stdout_tty': expected Boolean, got String",
|
||||||
pcall_err(meths.ui_attach, 80, 24, { stdout_tty = 'foo' })
|
pcall_err(meths.nvim_ui_attach, 80, 24, { stdout_tty = 'foo' })
|
||||||
)
|
)
|
||||||
|
|
||||||
eq('UI not attached to channel: 1', pcall_err(request, 'nvim_ui_try_resize', 40, 10))
|
eq('UI not attached to channel: 1', pcall_err(request, 'nvim_ui_try_resize', 40, 10))
|
||||||
@@ -117,17 +117,17 @@ it('autocmds VimSuspend/VimResume #22041', function()
|
|||||||
end)
|
end)
|
||||||
eq({ 's', 'r', 's' }, eval('g:ev'))
|
eq({ 's', 'r', 's' }, eval('g:ev'))
|
||||||
screen.suspended = false
|
screen.suspended = false
|
||||||
meths.input_mouse('move', '', '', 0, 0, 0)
|
meths.nvim_input_mouse('move', '', '', 0, 0, 0)
|
||||||
eq({ 's', 'r', 's', 'r' }, eval('g:ev'))
|
eq({ 's', 'r', 's', 'r' }, eval('g:ev'))
|
||||||
|
|
||||||
feed('<C-Z><C-Z><C-Z>')
|
feed('<C-Z><C-Z><C-Z>')
|
||||||
screen:expect(function()
|
screen:expect(function()
|
||||||
eq(true, screen.suspended)
|
eq(true, screen.suspended)
|
||||||
end)
|
end)
|
||||||
meths.ui_set_focus(false)
|
meths.nvim_ui_set_focus(false)
|
||||||
eq({ 's', 'r', 's', 'r', 's' }, eval('g:ev'))
|
eq({ 's', 'r', 's', 'r', 's' }, eval('g:ev'))
|
||||||
screen.suspended = false
|
screen.suspended = false
|
||||||
meths.ui_set_focus(true)
|
meths.nvim_ui_set_focus(true)
|
||||||
eq({ 's', 'r', 's', 'r', 's', 'r' }, eval('g:ev'))
|
eq({ 's', 'r', 's', 'r', 's', 'r' }, eval('g:ev'))
|
||||||
|
|
||||||
command('suspend | suspend | suspend')
|
command('suspend | suspend | suspend')
|
||||||
|
@@ -94,7 +94,7 @@ describe('api metadata', function()
|
|||||||
local old_api = {}
|
local old_api = {}
|
||||||
setup(function()
|
setup(function()
|
||||||
clear() -- Ensure a session before requesting api_info.
|
clear() -- Ensure a session before requesting api_info.
|
||||||
api = meths.get_api_info()[2]
|
api = meths.nvim_get_api_info()[2]
|
||||||
compat = api.version.api_compatible
|
compat = api.version.api_compatible
|
||||||
api_level = api.version.api_level
|
api_level = api.version.api_level
|
||||||
if api.version.api_prerelease then
|
if api.version.api_prerelease then
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -53,9 +53,9 @@ describe('API/win', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('disallowed in cmdwin if win={old_}curwin or buf=curbuf', function()
|
it('disallowed in cmdwin if win={old_}curwin or buf=curbuf', function()
|
||||||
local new_buf = meths.create_buf(true, true)
|
local new_buf = meths.nvim_create_buf(true, true)
|
||||||
local old_win = meths.get_current_win()
|
local old_win = meths.nvim_get_current_win()
|
||||||
local new_win = meths.open_win(new_buf, false, {
|
local new_win = meths.nvim_open_win(new_buf, false, {
|
||||||
relative = 'editor',
|
relative = 'editor',
|
||||||
row = 10,
|
row = 10,
|
||||||
col = 10,
|
col = 10,
|
||||||
@@ -65,20 +65,20 @@ describe('API/win', function()
|
|||||||
feed('q:')
|
feed('q:')
|
||||||
eq(
|
eq(
|
||||||
'E11: Invalid in command-line window; <CR> executes, CTRL-C quits',
|
'E11: Invalid in command-line window; <CR> executes, CTRL-C quits',
|
||||||
pcall_err(meths.win_set_buf, 0, new_buf)
|
pcall_err(meths.nvim_win_set_buf, 0, new_buf)
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
'E11: Invalid in command-line window; <CR> executes, CTRL-C quits',
|
'E11: Invalid in command-line window; <CR> executes, CTRL-C quits',
|
||||||
pcall_err(meths.win_set_buf, old_win, new_buf)
|
pcall_err(meths.nvim_win_set_buf, old_win, new_buf)
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
'E11: Invalid in command-line window; <CR> executes, CTRL-C quits',
|
'E11: Invalid in command-line window; <CR> executes, CTRL-C quits',
|
||||||
pcall_err(meths.win_set_buf, new_win, 0)
|
pcall_err(meths.nvim_win_set_buf, new_win, 0)
|
||||||
)
|
)
|
||||||
|
|
||||||
local next_buf = meths.create_buf(true, true)
|
local next_buf = meths.nvim_create_buf(true, true)
|
||||||
meths.win_set_buf(new_win, next_buf)
|
meths.nvim_win_set_buf(new_win, next_buf)
|
||||||
eq(next_buf, meths.win_get_buf(new_win))
|
eq(next_buf, meths.nvim_win_get_buf(new_win))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ describe('API/win', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('does not leak memory when using invalid window ID with invalid pos', function()
|
it('does not leak memory when using invalid window ID with invalid pos', function()
|
||||||
eq('Invalid window id: 1', pcall_err(meths.win_set_cursor, 1, { 'b\na' }))
|
eq('Invalid window id: 1', pcall_err(meths.nvim_win_set_cursor, 1, { 'b\na' }))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('updates the screen, and also when the window is unfocused', function()
|
it('updates the screen, and also when the window is unfocused', function()
|
||||||
@@ -334,7 +334,7 @@ describe('API/win', function()
|
|||||||
call nvim_win_set_height(w, 5)
|
call nvim_win_set_height(w, 5)
|
||||||
]])
|
]])
|
||||||
feed('l')
|
feed('l')
|
||||||
eq('', meths.get_vvar('errmsg'))
|
eq('', meths.nvim_get_vvar('errmsg'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -365,7 +365,7 @@ describe('API/win', function()
|
|||||||
call nvim_win_set_width(w, 5)
|
call nvim_win_set_width(w, 5)
|
||||||
]])
|
]])
|
||||||
feed('l')
|
feed('l')
|
||||||
eq('', meths.get_vvar('errmsg'))
|
eq('', meths.nvim_get_vvar('errmsg'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -501,48 +501,48 @@ describe('API/win', function()
|
|||||||
|
|
||||||
describe('close', function()
|
describe('close', function()
|
||||||
it('can close current window', function()
|
it('can close current window', function()
|
||||||
local oldwin = meths.get_current_win()
|
local oldwin = meths.nvim_get_current_win()
|
||||||
command('split')
|
command('split')
|
||||||
local newwin = meths.get_current_win()
|
local newwin = meths.nvim_get_current_win()
|
||||||
meths.win_close(newwin, false)
|
meths.nvim_win_close(newwin, false)
|
||||||
eq({ oldwin }, meths.list_wins())
|
eq({ oldwin }, meths.nvim_list_wins())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('can close noncurrent window', function()
|
it('can close noncurrent window', function()
|
||||||
local oldwin = meths.get_current_win()
|
local oldwin = meths.nvim_get_current_win()
|
||||||
command('split')
|
command('split')
|
||||||
local newwin = meths.get_current_win()
|
local newwin = meths.nvim_get_current_win()
|
||||||
meths.win_close(oldwin, false)
|
meths.nvim_win_close(oldwin, false)
|
||||||
eq({ newwin }, meths.list_wins())
|
eq({ newwin }, meths.nvim_list_wins())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("handles changed buffer when 'hidden' is unset", function()
|
it("handles changed buffer when 'hidden' is unset", function()
|
||||||
command('set nohidden')
|
command('set nohidden')
|
||||||
local oldwin = meths.get_current_win()
|
local oldwin = meths.nvim_get_current_win()
|
||||||
insert('text')
|
insert('text')
|
||||||
command('new')
|
command('new')
|
||||||
local newwin = meths.get_current_win()
|
local newwin = meths.nvim_get_current_win()
|
||||||
eq(
|
eq(
|
||||||
'Vim:E37: No write since last change (add ! to override)',
|
'Vim:E37: No write since last change (add ! to override)',
|
||||||
pcall_err(meths.win_close, oldwin, false)
|
pcall_err(meths.nvim_win_close, oldwin, false)
|
||||||
)
|
)
|
||||||
eq({ newwin, oldwin }, meths.list_wins())
|
eq({ newwin, oldwin }, meths.nvim_list_wins())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('handles changed buffer with force', function()
|
it('handles changed buffer with force', function()
|
||||||
local oldwin = meths.get_current_win()
|
local oldwin = meths.nvim_get_current_win()
|
||||||
insert('text')
|
insert('text')
|
||||||
command('new')
|
command('new')
|
||||||
local newwin = meths.get_current_win()
|
local newwin = meths.nvim_get_current_win()
|
||||||
meths.win_close(oldwin, true)
|
meths.nvim_win_close(oldwin, true)
|
||||||
eq({ newwin }, meths.list_wins())
|
eq({ newwin }, meths.nvim_list_wins())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('in cmdline-window #9767', function()
|
it('in cmdline-window #9767', function()
|
||||||
command('split')
|
command('split')
|
||||||
eq(2, #meths.list_wins())
|
eq(2, #meths.nvim_list_wins())
|
||||||
local oldwin = meths.get_current_win()
|
local oldwin = meths.nvim_get_current_win()
|
||||||
local otherwin = meths.open_win(0, false, {
|
local otherwin = meths.nvim_open_win(0, false, {
|
||||||
relative = 'editor',
|
relative = 'editor',
|
||||||
row = 10,
|
row = 10,
|
||||||
col = 10,
|
col = 10,
|
||||||
@@ -551,19 +551,19 @@ describe('API/win', function()
|
|||||||
})
|
})
|
||||||
-- Open cmdline-window.
|
-- Open cmdline-window.
|
||||||
feed('q:')
|
feed('q:')
|
||||||
eq(4, #meths.list_wins())
|
eq(4, #meths.nvim_list_wins())
|
||||||
eq(':', funcs.getcmdwintype())
|
eq(':', funcs.getcmdwintype())
|
||||||
-- Not allowed to close previous window from cmdline-window.
|
-- Not allowed to close previous window from cmdline-window.
|
||||||
eq(
|
eq(
|
||||||
'E11: Invalid in command-line window; <CR> executes, CTRL-C quits',
|
'E11: Invalid in command-line window; <CR> executes, CTRL-C quits',
|
||||||
pcall_err(meths.win_close, oldwin, true)
|
pcall_err(meths.nvim_win_close, oldwin, true)
|
||||||
)
|
)
|
||||||
-- Closing other windows is fine.
|
-- Closing other windows is fine.
|
||||||
meths.win_close(otherwin, true)
|
meths.nvim_win_close(otherwin, true)
|
||||||
eq(false, meths.win_is_valid(otherwin))
|
eq(false, meths.nvim_win_is_valid(otherwin))
|
||||||
-- Close cmdline-window.
|
-- Close cmdline-window.
|
||||||
meths.win_close(0, true)
|
meths.nvim_win_close(0, true)
|
||||||
eq(2, #meths.list_wins())
|
eq(2, #meths.nvim_list_wins())
|
||||||
eq('', funcs.getcmdwintype())
|
eq('', funcs.getcmdwintype())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -572,7 +572,7 @@ describe('API/win', function()
|
|||||||
command('botright split')
|
command('botright split')
|
||||||
local prevwin = curwin().id
|
local prevwin = curwin().id
|
||||||
eq(2, eval('tabpagenr()'))
|
eq(2, eval('tabpagenr()'))
|
||||||
local win = meths.open_win(0, true, {
|
local win = meths.nvim_open_win(0, true, {
|
||||||
relative = 'editor',
|
relative = 'editor',
|
||||||
row = 10,
|
row = 10,
|
||||||
col = 10,
|
col = 10,
|
||||||
@@ -582,67 +582,67 @@ describe('API/win', function()
|
|||||||
local tab = eval('tabpagenr()')
|
local tab = eval('tabpagenr()')
|
||||||
command('tabprevious')
|
command('tabprevious')
|
||||||
eq(1, eval('tabpagenr()'))
|
eq(1, eval('tabpagenr()'))
|
||||||
meths.win_close(win, false)
|
meths.nvim_win_close(win, false)
|
||||||
|
|
||||||
eq(prevwin, meths.tabpage_get_win(tab).id)
|
eq(prevwin, meths.nvim_tabpage_get_win(tab).id)
|
||||||
assert_alive()
|
assert_alive()
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('hide', function()
|
describe('hide', function()
|
||||||
it('can hide current window', function()
|
it('can hide current window', function()
|
||||||
local oldwin = meths.get_current_win()
|
local oldwin = meths.nvim_get_current_win()
|
||||||
command('split')
|
command('split')
|
||||||
local newwin = meths.get_current_win()
|
local newwin = meths.nvim_get_current_win()
|
||||||
meths.win_hide(newwin)
|
meths.nvim_win_hide(newwin)
|
||||||
eq({ oldwin }, meths.list_wins())
|
eq({ oldwin }, meths.nvim_list_wins())
|
||||||
end)
|
end)
|
||||||
it('can hide noncurrent window', function()
|
it('can hide noncurrent window', function()
|
||||||
local oldwin = meths.get_current_win()
|
local oldwin = meths.nvim_get_current_win()
|
||||||
command('split')
|
command('split')
|
||||||
local newwin = meths.get_current_win()
|
local newwin = meths.nvim_get_current_win()
|
||||||
meths.win_hide(oldwin)
|
meths.nvim_win_hide(oldwin)
|
||||||
eq({ newwin }, meths.list_wins())
|
eq({ newwin }, meths.nvim_list_wins())
|
||||||
end)
|
end)
|
||||||
it('does not close the buffer', function()
|
it('does not close the buffer', function()
|
||||||
local oldwin = meths.get_current_win()
|
local oldwin = meths.nvim_get_current_win()
|
||||||
local oldbuf = meths.get_current_buf()
|
local oldbuf = meths.nvim_get_current_buf()
|
||||||
local buf = meths.create_buf(true, false)
|
local buf = meths.nvim_create_buf(true, false)
|
||||||
local newwin = meths.open_win(buf, true, {
|
local newwin = meths.nvim_open_win(buf, true, {
|
||||||
relative = 'win',
|
relative = 'win',
|
||||||
row = 3,
|
row = 3,
|
||||||
col = 3,
|
col = 3,
|
||||||
width = 12,
|
width = 12,
|
||||||
height = 3,
|
height = 3,
|
||||||
})
|
})
|
||||||
meths.win_hide(newwin)
|
meths.nvim_win_hide(newwin)
|
||||||
eq({ oldwin }, meths.list_wins())
|
eq({ oldwin }, meths.nvim_list_wins())
|
||||||
eq({ oldbuf, buf }, meths.list_bufs())
|
eq({ oldbuf, buf }, meths.nvim_list_bufs())
|
||||||
end)
|
end)
|
||||||
it('deletes the buffer when bufhidden=wipe', function()
|
it('deletes the buffer when bufhidden=wipe', function()
|
||||||
local oldwin = meths.get_current_win()
|
local oldwin = meths.nvim_get_current_win()
|
||||||
local oldbuf = meths.get_current_buf()
|
local oldbuf = meths.nvim_get_current_buf()
|
||||||
local buf = meths.create_buf(true, false).id
|
local buf = meths.nvim_create_buf(true, false).id
|
||||||
local newwin = meths.open_win(buf, true, {
|
local newwin = meths.nvim_open_win(buf, true, {
|
||||||
relative = 'win',
|
relative = 'win',
|
||||||
row = 3,
|
row = 3,
|
||||||
col = 3,
|
col = 3,
|
||||||
width = 12,
|
width = 12,
|
||||||
height = 3,
|
height = 3,
|
||||||
})
|
})
|
||||||
meths.set_option_value('bufhidden', 'wipe', { buf = buf })
|
meths.nvim_set_option_value('bufhidden', 'wipe', { buf = buf })
|
||||||
meths.win_hide(newwin)
|
meths.nvim_win_hide(newwin)
|
||||||
eq({ oldwin }, meths.list_wins())
|
eq({ oldwin }, meths.nvim_list_wins())
|
||||||
eq({ oldbuf }, meths.list_bufs())
|
eq({ oldbuf }, meths.nvim_list_bufs())
|
||||||
end)
|
end)
|
||||||
it('in the cmdwin', function()
|
it('in the cmdwin', function()
|
||||||
feed('q:')
|
feed('q:')
|
||||||
-- Can close the cmdwin.
|
-- Can close the cmdwin.
|
||||||
meths.win_hide(0)
|
meths.nvim_win_hide(0)
|
||||||
eq('', funcs.getcmdwintype())
|
eq('', funcs.getcmdwintype())
|
||||||
|
|
||||||
local old_win = meths.get_current_win()
|
local old_win = meths.nvim_get_current_win()
|
||||||
local other_win = meths.open_win(0, false, {
|
local other_win = meths.nvim_open_win(0, false, {
|
||||||
relative = 'win',
|
relative = 'win',
|
||||||
row = 3,
|
row = 3,
|
||||||
col = 3,
|
col = 3,
|
||||||
@@ -653,24 +653,24 @@ describe('API/win', function()
|
|||||||
-- Cannot close the previous window.
|
-- Cannot close the previous window.
|
||||||
eq(
|
eq(
|
||||||
'E11: Invalid in command-line window; <CR> executes, CTRL-C quits',
|
'E11: Invalid in command-line window; <CR> executes, CTRL-C quits',
|
||||||
pcall_err(meths.win_hide, old_win)
|
pcall_err(meths.nvim_win_hide, old_win)
|
||||||
)
|
)
|
||||||
-- Can close other windows.
|
-- Can close other windows.
|
||||||
meths.win_hide(other_win)
|
meths.nvim_win_hide(other_win)
|
||||||
eq(false, meths.win_is_valid(other_win))
|
eq(false, meths.nvim_win_is_valid(other_win))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('text_height', function()
|
describe('text_height', function()
|
||||||
it('validation', function()
|
it('validation', function()
|
||||||
local X = meths.get_vvar('maxcol')
|
local X = meths.nvim_get_vvar('maxcol')
|
||||||
insert([[
|
insert([[
|
||||||
aaa
|
aaa
|
||||||
bbb
|
bbb
|
||||||
ccc
|
ccc
|
||||||
ddd
|
ddd
|
||||||
eee]])
|
eee]])
|
||||||
eq('Invalid window id: 23', pcall_err(meths.win_text_height, 23, {}))
|
eq('Invalid window id: 23', pcall_err(meths.nvim_win_text_height, 23, {}))
|
||||||
eq('Line index out of bounds', pcall_err(curwinmeths.text_height, { start_row = 5 }))
|
eq('Line index out of bounds', pcall_err(curwinmeths.text_height, { start_row = 5 }))
|
||||||
eq('Line index out of bounds', pcall_err(curwinmeths.text_height, { start_row = -6 }))
|
eq('Line index out of bounds', pcall_err(curwinmeths.text_height, { start_row = -6 }))
|
||||||
eq('Line index out of bounds', pcall_err(curwinmeths.text_height, { end_row = 5 }))
|
eq('Line index out of bounds', pcall_err(curwinmeths.text_height, { end_row = 5 }))
|
||||||
@@ -713,7 +713,7 @@ describe('API/win', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('with two diff windows', function()
|
it('with two diff windows', function()
|
||||||
local X = meths.get_vvar('maxcol')
|
local X = meths.nvim_get_vvar('maxcol')
|
||||||
local screen = Screen.new(45, 22)
|
local screen = Screen.new(45, 22)
|
||||||
screen:set_default_attr_ids({
|
screen:set_default_attr_ids({
|
||||||
[0] = { foreground = Screen.colors.Blue1, bold = true },
|
[0] = { foreground = Screen.colors.Blue1, bold = true },
|
||||||
@@ -775,70 +775,88 @@ describe('API/win', function()
|
|||||||
|
|
|
|
||||||
]],
|
]],
|
||||||
}
|
}
|
||||||
eq({ all = 20, fill = 5 }, meths.win_text_height(1000, {}))
|
eq({ all = 20, fill = 5 }, meths.nvim_win_text_height(1000, {}))
|
||||||
eq({ all = 20, fill = 5 }, meths.win_text_height(1001, {}))
|
eq({ all = 20, fill = 5 }, meths.nvim_win_text_height(1001, {}))
|
||||||
eq({ all = 20, fill = 5 }, meths.win_text_height(1000, { start_row = 0 }))
|
eq({ all = 20, fill = 5 }, meths.nvim_win_text_height(1000, { start_row = 0 }))
|
||||||
eq({ all = 20, fill = 5 }, meths.win_text_height(1001, { start_row = 0 }))
|
eq({ all = 20, fill = 5 }, meths.nvim_win_text_height(1001, { start_row = 0 }))
|
||||||
eq({ all = 15, fill = 0 }, meths.win_text_height(1000, { end_row = -1 }))
|
eq({ all = 15, fill = 0 }, meths.nvim_win_text_height(1000, { end_row = -1 }))
|
||||||
eq({ all = 15, fill = 0 }, meths.win_text_height(1000, { end_row = 40 }))
|
eq({ all = 15, fill = 0 }, meths.nvim_win_text_height(1000, { end_row = 40 }))
|
||||||
eq({ all = 20, fill = 5 }, meths.win_text_height(1001, { end_row = -1 }))
|
eq({ all = 20, fill = 5 }, meths.nvim_win_text_height(1001, { end_row = -1 }))
|
||||||
eq({ all = 20, fill = 5 }, meths.win_text_height(1001, { end_row = 40 }))
|
eq({ all = 20, fill = 5 }, meths.nvim_win_text_height(1001, { end_row = 40 }))
|
||||||
eq({ all = 10, fill = 5 }, meths.win_text_height(1000, { start_row = 23 }))
|
eq({ all = 10, fill = 5 }, meths.nvim_win_text_height(1000, { start_row = 23 }))
|
||||||
eq({ all = 13, fill = 3 }, meths.win_text_height(1001, { start_row = 18 }))
|
eq({ all = 13, fill = 3 }, meths.nvim_win_text_height(1001, { start_row = 18 }))
|
||||||
eq({ all = 11, fill = 0 }, meths.win_text_height(1000, { end_row = 23 }))
|
eq({ all = 11, fill = 0 }, meths.nvim_win_text_height(1000, { end_row = 23 }))
|
||||||
eq({ all = 11, fill = 5 }, meths.win_text_height(1001, { end_row = 18 }))
|
eq({ all = 11, fill = 5 }, meths.nvim_win_text_height(1001, { end_row = 18 }))
|
||||||
eq({ all = 11, fill = 0 }, meths.win_text_height(1000, { start_row = 3, end_row = 39 }))
|
eq({ all = 11, fill = 0 }, meths.nvim_win_text_height(1000, { start_row = 3, end_row = 39 }))
|
||||||
eq({ all = 11, fill = 3 }, meths.win_text_height(1001, { start_row = 1, end_row = 34 }))
|
eq({ all = 11, fill = 3 }, meths.nvim_win_text_height(1001, { start_row = 1, end_row = 34 }))
|
||||||
eq({ all = 9, fill = 0 }, meths.win_text_height(1000, { start_row = 4, end_row = 38 }))
|
eq({ all = 9, fill = 0 }, meths.nvim_win_text_height(1000, { start_row = 4, end_row = 38 }))
|
||||||
eq({ all = 9, fill = 3 }, meths.win_text_height(1001, { start_row = 2, end_row = 33 }))
|
eq({ all = 9, fill = 3 }, meths.nvim_win_text_height(1001, { start_row = 2, end_row = 33 }))
|
||||||
eq({ all = 9, fill = 0 }, meths.win_text_height(1000, { start_row = 5, end_row = 37 }))
|
eq({ all = 9, fill = 0 }, meths.nvim_win_text_height(1000, { start_row = 5, end_row = 37 }))
|
||||||
eq({ all = 9, fill = 3 }, meths.win_text_height(1001, { start_row = 3, end_row = 32 }))
|
eq({ all = 9, fill = 3 }, meths.nvim_win_text_height(1001, { start_row = 3, end_row = 32 }))
|
||||||
eq({ all = 9, fill = 0 }, meths.win_text_height(1000, { start_row = 17, end_row = 25 }))
|
eq({ all = 9, fill = 0 }, meths.nvim_win_text_height(1000, { start_row = 17, end_row = 25 }))
|
||||||
eq({ all = 9, fill = 3 }, meths.win_text_height(1001, { start_row = 15, end_row = 20 }))
|
eq({ all = 9, fill = 3 }, meths.nvim_win_text_height(1001, { start_row = 15, end_row = 20 }))
|
||||||
eq({ all = 7, fill = 0 }, meths.win_text_height(1000, { start_row = 18, end_row = 24 }))
|
eq({ all = 7, fill = 0 }, meths.nvim_win_text_height(1000, { start_row = 18, end_row = 24 }))
|
||||||
eq({ all = 7, fill = 3 }, meths.win_text_height(1001, { start_row = 16, end_row = 19 }))
|
eq({ all = 7, fill = 3 }, meths.nvim_win_text_height(1001, { start_row = 16, end_row = 19 }))
|
||||||
eq({ all = 6, fill = 5 }, meths.win_text_height(1000, { start_row = -1 }))
|
eq({ all = 6, fill = 5 }, meths.nvim_win_text_height(1000, { start_row = -1 }))
|
||||||
eq({ all = 5, fill = 5 }, meths.win_text_height(1000, { start_row = -1, start_vcol = X }))
|
|
||||||
eq(
|
eq(
|
||||||
{ all = 0, fill = 0 },
|
{ all = 5, fill = 5 },
|
||||||
meths.win_text_height(1000, { start_row = -1, start_vcol = X, end_row = -1 })
|
meths.nvim_win_text_height(1000, { start_row = -1, start_vcol = X })
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
{ all = 0, fill = 0 },
|
{ all = 0, fill = 0 },
|
||||||
meths.win_text_height(1000, { start_row = -1, start_vcol = X, end_row = -1, end_vcol = X })
|
meths.nvim_win_text_height(1000, { start_row = -1, start_vcol = X, end_row = -1 })
|
||||||
|
)
|
||||||
|
eq(
|
||||||
|
{ all = 0, fill = 0 },
|
||||||
|
meths.nvim_win_text_height(
|
||||||
|
1000,
|
||||||
|
{ start_row = -1, start_vcol = X, end_row = -1, end_vcol = X }
|
||||||
|
)
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
{ all = 1, fill = 0 },
|
{ all = 1, fill = 0 },
|
||||||
meths.win_text_height(1000, { start_row = -1, start_vcol = 0, end_row = -1, end_vcol = X })
|
meths.nvim_win_text_height(
|
||||||
|
1000,
|
||||||
|
{ start_row = -1, start_vcol = 0, end_row = -1, end_vcol = X }
|
||||||
)
|
)
|
||||||
eq({ all = 3, fill = 2 }, meths.win_text_height(1001, { end_row = 0 }))
|
)
|
||||||
eq({ all = 2, fill = 2 }, meths.win_text_height(1001, { end_row = 0, end_vcol = 0 }))
|
eq({ all = 3, fill = 2 }, meths.nvim_win_text_height(1001, { end_row = 0 }))
|
||||||
|
eq({ all = 2, fill = 2 }, meths.nvim_win_text_height(1001, { end_row = 0, end_vcol = 0 }))
|
||||||
eq(
|
eq(
|
||||||
{ all = 2, fill = 2 },
|
{ all = 2, fill = 2 },
|
||||||
meths.win_text_height(1001, { start_row = 0, end_row = 0, end_vcol = 0 })
|
meths.nvim_win_text_height(1001, { start_row = 0, end_row = 0, end_vcol = 0 })
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
{ all = 0, fill = 0 },
|
{ all = 0, fill = 0 },
|
||||||
meths.win_text_height(1001, { start_row = 0, start_vcol = 0, end_row = 0, end_vcol = 0 })
|
meths.nvim_win_text_height(
|
||||||
|
1001,
|
||||||
|
{ start_row = 0, start_vcol = 0, end_row = 0, end_vcol = 0 }
|
||||||
|
)
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
{ all = 1, fill = 0 },
|
{ all = 1, fill = 0 },
|
||||||
meths.win_text_height(1001, { start_row = 0, start_vcol = 0, end_row = 0, end_vcol = X })
|
meths.nvim_win_text_height(
|
||||||
|
1001,
|
||||||
|
{ start_row = 0, start_vcol = 0, end_row = 0, end_vcol = X }
|
||||||
)
|
)
|
||||||
eq({ all = 11, fill = 5 }, meths.win_text_height(1001, { end_row = 18 }))
|
)
|
||||||
|
eq({ all = 11, fill = 5 }, meths.nvim_win_text_height(1001, { end_row = 18 }))
|
||||||
eq(
|
eq(
|
||||||
{ all = 9, fill = 3 },
|
{ all = 9, fill = 3 },
|
||||||
meths.win_text_height(1001, { start_row = 0, start_vcol = 0, end_row = 18 })
|
meths.nvim_win_text_height(1001, { start_row = 0, start_vcol = 0, end_row = 18 })
|
||||||
)
|
)
|
||||||
eq({ all = 10, fill = 5 }, meths.win_text_height(1001, { end_row = 18, end_vcol = 0 }))
|
eq({ all = 10, fill = 5 }, meths.nvim_win_text_height(1001, { end_row = 18, end_vcol = 0 }))
|
||||||
eq(
|
eq(
|
||||||
{ all = 8, fill = 3 },
|
{ all = 8, fill = 3 },
|
||||||
meths.win_text_height(1001, { start_row = 0, start_vcol = 0, end_row = 18, end_vcol = 0 })
|
meths.nvim_win_text_height(
|
||||||
|
1001,
|
||||||
|
{ start_row = 0, start_vcol = 0, end_row = 18, end_vcol = 0 }
|
||||||
|
)
|
||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('with wrapped lines', function()
|
it('with wrapped lines', function()
|
||||||
local X = meths.get_vvar('maxcol')
|
local X = meths.nvim_get_vvar('maxcol')
|
||||||
local screen = Screen.new(45, 22)
|
local screen = Screen.new(45, 22)
|
||||||
screen:set_default_attr_ids({
|
screen:set_default_attr_ids({
|
||||||
[0] = { foreground = Screen.colors.Blue1, bold = true },
|
[0] = { foreground = Screen.colors.Blue1, bold = true },
|
||||||
@@ -850,15 +868,15 @@ describe('API/win', function()
|
|||||||
set number cpoptions+=n
|
set number cpoptions+=n
|
||||||
call setline(1, repeat([repeat('foobar-', 36)], 3))
|
call setline(1, repeat([repeat('foobar-', 36)], 3))
|
||||||
]])
|
]])
|
||||||
local ns = meths.create_namespace('')
|
local ns = meths.nvim_create_namespace('')
|
||||||
meths.buf_set_extmark(
|
meths.nvim_buf_set_extmark(
|
||||||
0,
|
0,
|
||||||
ns,
|
ns,
|
||||||
1,
|
1,
|
||||||
100,
|
100,
|
||||||
{ virt_text = { { ('?'):rep(15), 'Search' } }, virt_text_pos = 'inline' }
|
{ virt_text = { { ('?'):rep(15), 'Search' } }, virt_text_pos = 'inline' }
|
||||||
)
|
)
|
||||||
meths.buf_set_extmark(
|
meths.nvim_buf_set_extmark(
|
||||||
0,
|
0,
|
||||||
ns,
|
ns,
|
||||||
2,
|
2,
|
||||||
@@ -898,113 +916,155 @@ describe('API/win', function()
|
|||||||
|
|
|
|
||||||
]],
|
]],
|
||||||
}
|
}
|
||||||
eq({ all = 21, fill = 0 }, meths.win_text_height(0, {}))
|
eq({ all = 21, fill = 0 }, meths.nvim_win_text_height(0, {}))
|
||||||
eq({ all = 6, fill = 0 }, meths.win_text_height(0, { start_row = 0, end_row = 0 }))
|
eq({ all = 6, fill = 0 }, meths.nvim_win_text_height(0, { start_row = 0, end_row = 0 }))
|
||||||
eq({ all = 7, fill = 0 }, meths.win_text_height(0, { start_row = 1, end_row = 1 }))
|
eq({ all = 7, fill = 0 }, meths.nvim_win_text_height(0, { start_row = 1, end_row = 1 }))
|
||||||
eq({ all = 8, fill = 0 }, meths.win_text_height(0, { start_row = 2, end_row = 2 }))
|
eq({ all = 8, fill = 0 }, meths.nvim_win_text_height(0, { start_row = 2, end_row = 2 }))
|
||||||
eq(
|
eq(
|
||||||
{ all = 0, fill = 0 },
|
{ all = 0, fill = 0 },
|
||||||
meths.win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 0 })
|
meths.nvim_win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 0 })
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
{ all = 1, fill = 0 },
|
{ all = 1, fill = 0 },
|
||||||
meths.win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 41 })
|
meths.nvim_win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 41 })
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
{ all = 2, fill = 0 },
|
{ all = 2, fill = 0 },
|
||||||
meths.win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 42 })
|
meths.nvim_win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 42 })
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
{ all = 2, fill = 0 },
|
{ all = 2, fill = 0 },
|
||||||
meths.win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 86 })
|
meths.nvim_win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 86 })
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
{ all = 3, fill = 0 },
|
{ all = 3, fill = 0 },
|
||||||
meths.win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 87 })
|
meths.nvim_win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 87 })
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
{ all = 6, fill = 0 },
|
{ all = 6, fill = 0 },
|
||||||
meths.win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 266 })
|
meths.nvim_win_text_height(
|
||||||
|
0,
|
||||||
|
{ start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 266 }
|
||||||
|
)
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
{ all = 7, fill = 0 },
|
{ all = 7, fill = 0 },
|
||||||
meths.win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 267 })
|
meths.nvim_win_text_height(
|
||||||
|
0,
|
||||||
|
{ start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 267 }
|
||||||
|
)
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
{ all = 7, fill = 0 },
|
{ all = 7, fill = 0 },
|
||||||
meths.win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 311 })
|
meths.nvim_win_text_height(
|
||||||
|
0,
|
||||||
|
{ start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 311 }
|
||||||
|
)
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
{ all = 7, fill = 0 },
|
{ all = 7, fill = 0 },
|
||||||
meths.win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 312 })
|
meths.nvim_win_text_height(
|
||||||
|
0,
|
||||||
|
{ start_row = 1, start_vcol = 0, end_row = 1, end_vcol = 312 }
|
||||||
|
)
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
{ all = 7, fill = 0 },
|
{ all = 7, fill = 0 },
|
||||||
meths.win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = X })
|
meths.nvim_win_text_height(0, { start_row = 1, start_vcol = 0, end_row = 1, end_vcol = X })
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
{ all = 7, fill = 0 },
|
{ all = 7, fill = 0 },
|
||||||
meths.win_text_height(0, { start_row = 1, start_vcol = 40, end_row = 1, end_vcol = X })
|
meths.nvim_win_text_height(0, { start_row = 1, start_vcol = 40, end_row = 1, end_vcol = X })
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
{ all = 6, fill = 0 },
|
{ all = 6, fill = 0 },
|
||||||
meths.win_text_height(0, { start_row = 1, start_vcol = 41, end_row = 1, end_vcol = X })
|
meths.nvim_win_text_height(0, { start_row = 1, start_vcol = 41, end_row = 1, end_vcol = X })
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
{ all = 6, fill = 0 },
|
{ all = 6, fill = 0 },
|
||||||
meths.win_text_height(0, { start_row = 1, start_vcol = 85, end_row = 1, end_vcol = X })
|
meths.nvim_win_text_height(0, { start_row = 1, start_vcol = 85, end_row = 1, end_vcol = X })
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
{ all = 5, fill = 0 },
|
{ all = 5, fill = 0 },
|
||||||
meths.win_text_height(0, { start_row = 1, start_vcol = 86, end_row = 1, end_vcol = X })
|
meths.nvim_win_text_height(0, { start_row = 1, start_vcol = 86, end_row = 1, end_vcol = X })
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
{ all = 2, fill = 0 },
|
{ all = 2, fill = 0 },
|
||||||
meths.win_text_height(0, { start_row = 1, start_vcol = 265, end_row = 1, end_vcol = X })
|
meths.nvim_win_text_height(
|
||||||
|
0,
|
||||||
|
{ start_row = 1, start_vcol = 265, end_row = 1, end_vcol = X }
|
||||||
|
)
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
{ all = 1, fill = 0 },
|
{ all = 1, fill = 0 },
|
||||||
meths.win_text_height(0, { start_row = 1, start_vcol = 266, end_row = 1, end_vcol = X })
|
meths.nvim_win_text_height(
|
||||||
|
0,
|
||||||
|
{ start_row = 1, start_vcol = 266, end_row = 1, end_vcol = X }
|
||||||
|
)
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
{ all = 1, fill = 0 },
|
{ all = 1, fill = 0 },
|
||||||
meths.win_text_height(0, { start_row = 1, start_vcol = 310, end_row = 1, end_vcol = X })
|
meths.nvim_win_text_height(
|
||||||
|
0,
|
||||||
|
{ start_row = 1, start_vcol = 310, end_row = 1, end_vcol = X }
|
||||||
|
)
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
{ all = 0, fill = 0 },
|
{ all = 0, fill = 0 },
|
||||||
meths.win_text_height(0, { start_row = 1, start_vcol = 311, end_row = 1, end_vcol = X })
|
meths.nvim_win_text_height(
|
||||||
|
0,
|
||||||
|
{ start_row = 1, start_vcol = 311, end_row = 1, end_vcol = X }
|
||||||
|
)
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
{ all = 1, fill = 0 },
|
{ all = 1, fill = 0 },
|
||||||
meths.win_text_height(0, { start_row = 1, start_vcol = 86, end_row = 1, end_vcol = 131 })
|
meths.nvim_win_text_height(
|
||||||
|
0,
|
||||||
|
{ start_row = 1, start_vcol = 86, end_row = 1, end_vcol = 131 }
|
||||||
|
)
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
{ all = 1, fill = 0 },
|
{ all = 1, fill = 0 },
|
||||||
meths.win_text_height(0, { start_row = 1, start_vcol = 221, end_row = 1, end_vcol = 266 })
|
meths.nvim_win_text_height(
|
||||||
|
0,
|
||||||
|
{ start_row = 1, start_vcol = 221, end_row = 1, end_vcol = 266 }
|
||||||
)
|
)
|
||||||
eq({ all = 18, fill = 0 }, meths.win_text_height(0, { start_row = 0, start_vcol = 131 }))
|
)
|
||||||
eq({ all = 19, fill = 0 }, meths.win_text_height(0, { start_row = 0, start_vcol = 130 }))
|
eq({ all = 18, fill = 0 }, meths.nvim_win_text_height(0, { start_row = 0, start_vcol = 131 }))
|
||||||
eq({ all = 20, fill = 0 }, meths.win_text_height(0, { end_row = 2, end_vcol = 311 }))
|
eq({ all = 19, fill = 0 }, meths.nvim_win_text_height(0, { start_row = 0, start_vcol = 130 }))
|
||||||
eq({ all = 21, fill = 0 }, meths.win_text_height(0, { end_row = 2, end_vcol = 312 }))
|
eq({ all = 20, fill = 0 }, meths.nvim_win_text_height(0, { end_row = 2, end_vcol = 311 }))
|
||||||
|
eq({ all = 21, fill = 0 }, meths.nvim_win_text_height(0, { end_row = 2, end_vcol = 312 }))
|
||||||
eq(
|
eq(
|
||||||
{ all = 17, fill = 0 },
|
{ all = 17, fill = 0 },
|
||||||
meths.win_text_height(0, { start_row = 0, start_vcol = 131, end_row = 2, end_vcol = 311 })
|
meths.nvim_win_text_height(
|
||||||
|
0,
|
||||||
|
{ start_row = 0, start_vcol = 131, end_row = 2, end_vcol = 311 }
|
||||||
|
)
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
{ all = 19, fill = 0 },
|
{ all = 19, fill = 0 },
|
||||||
meths.win_text_height(0, { start_row = 0, start_vcol = 130, end_row = 2, end_vcol = 312 })
|
meths.nvim_win_text_height(
|
||||||
|
0,
|
||||||
|
{ start_row = 0, start_vcol = 130, end_row = 2, end_vcol = 312 }
|
||||||
)
|
)
|
||||||
eq({ all = 16, fill = 0 }, meths.win_text_height(0, { start_row = 0, start_vcol = 221 }))
|
)
|
||||||
eq({ all = 17, fill = 0 }, meths.win_text_height(0, { start_row = 0, start_vcol = 220 }))
|
eq({ all = 16, fill = 0 }, meths.nvim_win_text_height(0, { start_row = 0, start_vcol = 221 }))
|
||||||
eq({ all = 14, fill = 0 }, meths.win_text_height(0, { end_row = 2, end_vcol = 41 }))
|
eq({ all = 17, fill = 0 }, meths.nvim_win_text_height(0, { start_row = 0, start_vcol = 220 }))
|
||||||
eq({ all = 15, fill = 0 }, meths.win_text_height(0, { end_row = 2, end_vcol = 42 }))
|
eq({ all = 14, fill = 0 }, meths.nvim_win_text_height(0, { end_row = 2, end_vcol = 41 }))
|
||||||
|
eq({ all = 15, fill = 0 }, meths.nvim_win_text_height(0, { end_row = 2, end_vcol = 42 }))
|
||||||
eq(
|
eq(
|
||||||
{ all = 9, fill = 0 },
|
{ all = 9, fill = 0 },
|
||||||
meths.win_text_height(0, { start_row = 0, start_vcol = 221, end_row = 2, end_vcol = 41 })
|
meths.nvim_win_text_height(
|
||||||
|
0,
|
||||||
|
{ start_row = 0, start_vcol = 221, end_row = 2, end_vcol = 41 }
|
||||||
|
)
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
{ all = 11, fill = 0 },
|
{ all = 11, fill = 0 },
|
||||||
meths.win_text_height(0, { start_row = 0, start_vcol = 220, end_row = 2, end_vcol = 42 })
|
meths.nvim_win_text_height(
|
||||||
|
0,
|
||||||
|
{ start_row = 0, start_vcol = 220, end_row = 2, end_vcol = 42 }
|
||||||
|
)
|
||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
@@ -1012,7 +1072,7 @@ describe('API/win', function()
|
|||||||
describe('open_win', function()
|
describe('open_win', function()
|
||||||
it('noautocmd option works', function()
|
it('noautocmd option works', function()
|
||||||
command('autocmd BufEnter,BufLeave,BufWinEnter * let g:fired = 1')
|
command('autocmd BufEnter,BufLeave,BufWinEnter * let g:fired = 1')
|
||||||
meths.open_win(meths.create_buf(true, true), true, {
|
meths.nvim_open_win(meths.nvim_create_buf(true, true), true, {
|
||||||
relative = 'win',
|
relative = 'win',
|
||||||
row = 3,
|
row = 3,
|
||||||
col = 3,
|
col = 3,
|
||||||
@@ -1021,7 +1081,7 @@ describe('API/win', function()
|
|||||||
noautocmd = true,
|
noautocmd = true,
|
||||||
})
|
})
|
||||||
eq(0, funcs.exists('g:fired'))
|
eq(0, funcs.exists('g:fired'))
|
||||||
meths.open_win(meths.create_buf(true, true), true, {
|
meths.nvim_open_win(meths.nvim_create_buf(true, true), true, {
|
||||||
relative = 'win',
|
relative = 'win',
|
||||||
row = 3,
|
row = 3,
|
||||||
col = 3,
|
col = 3,
|
||||||
@@ -1032,11 +1092,11 @@ describe('API/win', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('disallowed in cmdwin if enter=true or buf=curbuf', function()
|
it('disallowed in cmdwin if enter=true or buf=curbuf', function()
|
||||||
local new_buf = meths.create_buf(true, true)
|
local new_buf = meths.nvim_create_buf(true, true)
|
||||||
feed('q:')
|
feed('q:')
|
||||||
eq(
|
eq(
|
||||||
'E11: Invalid in command-line window; <CR> executes, CTRL-C quits',
|
'E11: Invalid in command-line window; <CR> executes, CTRL-C quits',
|
||||||
pcall_err(meths.open_win, new_buf, true, {
|
pcall_err(meths.nvim_open_win, new_buf, true, {
|
||||||
relative = 'editor',
|
relative = 'editor',
|
||||||
row = 5,
|
row = 5,
|
||||||
col = 5,
|
col = 5,
|
||||||
@@ -1046,7 +1106,7 @@ describe('API/win', function()
|
|||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
'E11: Invalid in command-line window; <CR> executes, CTRL-C quits',
|
'E11: Invalid in command-line window; <CR> executes, CTRL-C quits',
|
||||||
pcall_err(meths.open_win, 0, false, {
|
pcall_err(meths.nvim_open_win, 0, false, {
|
||||||
relative = 'editor',
|
relative = 'editor',
|
||||||
row = 5,
|
row = 5,
|
||||||
col = 5,
|
col = 5,
|
||||||
@@ -1057,7 +1117,7 @@ describe('API/win', function()
|
|||||||
|
|
||||||
eq(
|
eq(
|
||||||
new_buf,
|
new_buf,
|
||||||
meths.win_get_buf(meths.open_win(new_buf, false, {
|
meths.nvim_win_get_buf(meths.nvim_open_win(new_buf, false, {
|
||||||
relative = 'editor',
|
relative = 'editor',
|
||||||
row = 5,
|
row = 5,
|
||||||
col = 5,
|
col = 5,
|
||||||
@@ -1068,10 +1128,10 @@ describe('API/win', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('aborts if buffer is invalid', function()
|
it('aborts if buffer is invalid', function()
|
||||||
local wins_before = meths.list_wins()
|
local wins_before = meths.nvim_list_wins()
|
||||||
eq(
|
eq(
|
||||||
'Invalid buffer id: 1337',
|
'Invalid buffer id: 1337',
|
||||||
pcall_err(meths.open_win, 1337, false, {
|
pcall_err(meths.nvim_open_win, 1337, false, {
|
||||||
relative = 'editor',
|
relative = 'editor',
|
||||||
row = 5,
|
row = 5,
|
||||||
col = 5,
|
col = 5,
|
||||||
@@ -1079,14 +1139,14 @@ describe('API/win', function()
|
|||||||
height = 5,
|
height = 5,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
eq(wins_before, meths.list_wins())
|
eq(wins_before, meths.nvim_list_wins())
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('get_config', function()
|
describe('get_config', function()
|
||||||
it('includes border', function()
|
it('includes border', function()
|
||||||
local b = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' }
|
local b = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' }
|
||||||
local win = meths.open_win(0, true, {
|
local win = meths.nvim_open_win(0, true, {
|
||||||
relative = 'win',
|
relative = 'win',
|
||||||
row = 3,
|
row = 3,
|
||||||
col = 3,
|
col = 3,
|
||||||
@@ -1095,7 +1155,7 @@ describe('API/win', function()
|
|||||||
border = b,
|
border = b,
|
||||||
})
|
})
|
||||||
|
|
||||||
local cfg = meths.win_get_config(win)
|
local cfg = meths.nvim_win_get_config(win)
|
||||||
eq(b, cfg.border)
|
eq(b, cfg.border)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -1110,7 +1170,7 @@ describe('API/win', function()
|
|||||||
{ 'g', 'Constant' },
|
{ 'g', 'Constant' },
|
||||||
{ 'h', 'PreProc' },
|
{ 'h', 'PreProc' },
|
||||||
}
|
}
|
||||||
local win = meths.open_win(0, true, {
|
local win = meths.nvim_open_win(0, true, {
|
||||||
relative = 'win',
|
relative = 'win',
|
||||||
row = 3,
|
row = 3,
|
||||||
col = 3,
|
col = 3,
|
||||||
@@ -1119,14 +1179,14 @@ describe('API/win', function()
|
|||||||
border = b,
|
border = b,
|
||||||
})
|
})
|
||||||
|
|
||||||
local cfg = meths.win_get_config(win)
|
local cfg = meths.nvim_win_get_config(win)
|
||||||
eq(b, cfg.border)
|
eq(b, cfg.border)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('includes title and footer', function()
|
it('includes title and footer', function()
|
||||||
local title = { { 'A', { 'StatusLine', 'TabLine' } }, { 'B' }, { 'C', 'WinBar' } }
|
local title = { { 'A', { 'StatusLine', 'TabLine' } }, { 'B' }, { 'C', 'WinBar' } }
|
||||||
local footer = { { 'A', 'WinBar' }, { 'B' }, { 'C', { 'StatusLine', 'TabLine' } } }
|
local footer = { { 'A', 'WinBar' }, { 'B' }, { 'C', { 'StatusLine', 'TabLine' } } }
|
||||||
local win = meths.open_win(0, true, {
|
local win = meths.nvim_open_win(0, true, {
|
||||||
relative = 'win',
|
relative = 'win',
|
||||||
row = 3,
|
row = 3,
|
||||||
col = 3,
|
col = 3,
|
||||||
@@ -1137,7 +1197,7 @@ describe('API/win', function()
|
|||||||
footer = footer,
|
footer = footer,
|
||||||
})
|
})
|
||||||
|
|
||||||
local cfg = meths.win_get_config(win)
|
local cfg = meths.nvim_win_get_config(win)
|
||||||
eq(title, cfg.title)
|
eq(title, cfg.title)
|
||||||
eq(footer, cfg.footer)
|
eq(footer, cfg.footer)
|
||||||
end)
|
end)
|
||||||
@@ -1145,7 +1205,7 @@ describe('API/win', function()
|
|||||||
|
|
||||||
describe('set_config', function()
|
describe('set_config', function()
|
||||||
it('no crash with invalid title', function()
|
it('no crash with invalid title', function()
|
||||||
local win = meths.open_win(0, true, {
|
local win = meths.nvim_open_win(0, true, {
|
||||||
width = 10,
|
width = 10,
|
||||||
height = 10,
|
height = 10,
|
||||||
relative = 'editor',
|
relative = 'editor',
|
||||||
@@ -1156,14 +1216,14 @@ describe('API/win', function()
|
|||||||
})
|
})
|
||||||
eq(
|
eq(
|
||||||
'title/footer cannot be an empty array',
|
'title/footer cannot be an empty array',
|
||||||
pcall_err(meths.win_set_config, win, { title = {} })
|
pcall_err(meths.nvim_win_set_config, win, { title = {} })
|
||||||
)
|
)
|
||||||
command('redraw!')
|
command('redraw!')
|
||||||
assert_alive()
|
assert_alive()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('no crash with invalid footer', function()
|
it('no crash with invalid footer', function()
|
||||||
local win = meths.open_win(0, true, {
|
local win = meths.nvim_open_win(0, true, {
|
||||||
width = 10,
|
width = 10,
|
||||||
height = 10,
|
height = 10,
|
||||||
relative = 'editor',
|
relative = 'editor',
|
||||||
@@ -1174,7 +1234,7 @@ describe('API/win', function()
|
|||||||
})
|
})
|
||||||
eq(
|
eq(
|
||||||
'title/footer cannot be an empty array',
|
'title/footer cannot be an empty array',
|
||||||
pcall_err(meths.win_set_config, win, { footer = {} })
|
pcall_err(meths.nvim_win_set_config, win, { footer = {} })
|
||||||
)
|
)
|
||||||
command('redraw!')
|
command('redraw!')
|
||||||
assert_alive()
|
assert_alive()
|
||||||
|
@@ -23,7 +23,7 @@ describe('oldtests', function()
|
|||||||
]]
|
]]
|
||||||
|
|
||||||
eq(3, #exec_lines('au vimBarTest'))
|
eq(3, #exec_lines('au vimBarTest'))
|
||||||
eq(1, #meths.get_autocmds({ group = 'vimBarTest' }))
|
eq(1, #meths.nvim_get_autocmds({ group = 'vimBarTest' }))
|
||||||
end
|
end
|
||||||
|
|
||||||
it('should recognize a bar before the {event}', function()
|
it('should recognize a bar before the {event}', function()
|
||||||
@@ -31,7 +31,7 @@ describe('oldtests', function()
|
|||||||
add_an_autocmd()
|
add_an_autocmd()
|
||||||
exec [[ augroup vimBarTest | au! | augroup END ]]
|
exec [[ augroup vimBarTest | au! | augroup END ]]
|
||||||
eq(1, #exec_lines('au vimBarTest'))
|
eq(1, #exec_lines('au vimBarTest'))
|
||||||
eq({}, meths.get_autocmds({ group = 'vimBarTest' }))
|
eq({}, meths.nvim_get_autocmds({ group = 'vimBarTest' }))
|
||||||
|
|
||||||
-- Sad spacing
|
-- Sad spacing
|
||||||
add_an_autocmd()
|
add_an_autocmd()
|
||||||
@@ -74,7 +74,7 @@ describe('oldtests', function()
|
|||||||
funcs.writefile(funcs.split(content, '\n'), fname)
|
funcs.writefile(funcs.split(content, '\n'), fname)
|
||||||
|
|
||||||
funcs.delete('Xout')
|
funcs.delete('Xout')
|
||||||
funcs.system(string.format('%s --clean -N -S %s', meths.get_vvar('progpath'), fname))
|
funcs.system(string.format('%s --clean -N -S %s', meths.nvim_get_vvar('progpath'), fname))
|
||||||
eq(1, funcs.filereadable('Xout'))
|
eq(1, funcs.filereadable('Xout'))
|
||||||
|
|
||||||
funcs.delete('Xxx1')
|
funcs.delete('Xxx1')
|
||||||
|
@@ -143,7 +143,7 @@ describe('autocmd', function()
|
|||||||
|
|
||||||
describe('BufLeave autocommand', function()
|
describe('BufLeave autocommand', function()
|
||||||
it('can wipe out the buffer created by :edit which triggered autocmd', function()
|
it('can wipe out the buffer created by :edit which triggered autocmd', function()
|
||||||
meths.set_option_value('hidden', true, {})
|
meths.nvim_set_option_value('hidden', true, {})
|
||||||
curbufmeths.set_lines(0, 1, false, {
|
curbufmeths.set_lines(0, 1, false, {
|
||||||
'start of test file xx',
|
'start of test file xx',
|
||||||
'end of test file xx',
|
'end of test file xx',
|
||||||
@@ -416,7 +416,11 @@ describe('autocmd', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('gives E814 when there are other floating windows', function()
|
it('gives E814 when there are other floating windows', function()
|
||||||
meths.open_win(0, true, { width = 10, height = 10, relative = 'editor', row = 10, col = 10 })
|
meths.nvim_open_win(
|
||||||
|
0,
|
||||||
|
true,
|
||||||
|
{ width = 10, height = 10, relative = 'editor', row = 10, col = 10 }
|
||||||
|
)
|
||||||
eq(
|
eq(
|
||||||
'BufAdd Autocommands for "Xa.txt": Vim(close):E814: Cannot close window, only autocmd window would remain',
|
'BufAdd Autocommands for "Xa.txt": Vim(close):E814: Cannot close window, only autocmd window would remain',
|
||||||
pcall_err(command, 'doautoall BufAdd')
|
pcall_err(command, 'doautoall BufAdd')
|
||||||
@@ -512,15 +516,15 @@ describe('autocmd', function()
|
|||||||
command('autocmd ChanOpen * let v:event.info.id = 0')
|
command('autocmd ChanOpen * let v:event.info.id = 0')
|
||||||
funcs.jobstart({ 'cat' })
|
funcs.jobstart({ 'cat' })
|
||||||
retry(nil, nil, function()
|
retry(nil, nil, function()
|
||||||
eq('E46: Cannot change read-only variable "v:event.info"', meths.get_vvar('errmsg'))
|
eq('E46: Cannot change read-only variable "v:event.info"', meths.nvim_get_vvar('errmsg'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('during ChanOpen event', function()
|
it('during ChanOpen event', function()
|
||||||
command('autocmd ChanInfo * let v:event.info.id = 0')
|
command('autocmd ChanInfo * let v:event.info.id = 0')
|
||||||
meths.set_client_info('foo', {}, 'remote', {}, {})
|
meths.nvim_set_client_info('foo', {}, 'remote', {}, {})
|
||||||
retry(nil, nil, function()
|
retry(nil, nil, function()
|
||||||
eq('E46: Cannot change read-only variable "v:event.info"', meths.get_vvar('errmsg'))
|
eq('E46: Cannot change read-only variable "v:event.info"', meths.nvim_get_vvar('errmsg'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -574,7 +578,7 @@ describe('autocmd', function()
|
|||||||
call assert_fails('au WinNew * ++once ++once echo bad', 'E983:')
|
call assert_fails('au WinNew * ++once ++once echo bad', 'E983:')
|
||||||
]]
|
]]
|
||||||
|
|
||||||
meths.set_var('did_split', 0)
|
meths.nvim_set_var('did_split', 0)
|
||||||
|
|
||||||
source [[
|
source [[
|
||||||
augroup Testing
|
augroup Testing
|
||||||
@@ -586,11 +590,11 @@ describe('autocmd', function()
|
|||||||
split
|
split
|
||||||
]]
|
]]
|
||||||
|
|
||||||
eq(2, meths.get_var('did_split'))
|
eq(2, meths.nvim_get_var('did_split'))
|
||||||
eq(1, funcs.exists('#WinNew'))
|
eq(1, funcs.exists('#WinNew'))
|
||||||
|
|
||||||
-- Now with once
|
-- Now with once
|
||||||
meths.set_var('did_split', 0)
|
meths.nvim_set_var('did_split', 0)
|
||||||
|
|
||||||
source [[
|
source [[
|
||||||
augroup Testing
|
augroup Testing
|
||||||
@@ -602,7 +606,7 @@ describe('autocmd', function()
|
|||||||
split
|
split
|
||||||
]]
|
]]
|
||||||
|
|
||||||
eq(1, meths.get_var('did_split'))
|
eq(1, meths.nvim_get_var('did_split'))
|
||||||
eq(0, funcs.exists('#WinNew'))
|
eq(0, funcs.exists('#WinNew'))
|
||||||
|
|
||||||
-- call assert_fails('au WinNew * ++once ++once echo bad', 'E983:')
|
-- call assert_fails('au WinNew * ++once ++once echo bad', 'E983:')
|
||||||
@@ -619,7 +623,7 @@ describe('autocmd', function()
|
|||||||
|
|
||||||
it('should have autocmds in filetypedetect group', function()
|
it('should have autocmds in filetypedetect group', function()
|
||||||
source [[filetype on]]
|
source [[filetype on]]
|
||||||
neq({}, meths.get_autocmds { group = 'filetypedetect' })
|
neq({}, meths.nvim_get_autocmds { group = 'filetypedetect' })
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('should allow comma-separated patterns', function()
|
it('should allow comma-separated patterns', function()
|
||||||
@@ -631,7 +635,7 @@ describe('autocmd', function()
|
|||||||
augroup END
|
augroup END
|
||||||
]]
|
]]
|
||||||
|
|
||||||
eq(4, #meths.get_autocmds { event = 'BufReadCmd', group = 'TestingPatterns' })
|
eq(4, #meths.nvim_get_autocmds { event = 'BufReadCmd', group = 'TestingPatterns' })
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@@ -14,8 +14,8 @@ describe('cmdline autocommands', function()
|
|||||||
local channel
|
local channel
|
||||||
before_each(function()
|
before_each(function()
|
||||||
clear()
|
clear()
|
||||||
channel = meths.get_api_info()[1]
|
channel = meths.nvim_get_api_info()[1]
|
||||||
meths.set_var('channel', channel)
|
meths.nvim_set_var('channel', channel)
|
||||||
command("autocmd CmdlineEnter * call rpcnotify(g:channel, 'CmdlineEnter', v:event)")
|
command("autocmd CmdlineEnter * call rpcnotify(g:channel, 'CmdlineEnter', v:event)")
|
||||||
command("autocmd CmdlineLeave * call rpcnotify(g:channel, 'CmdlineLeave', v:event)")
|
command("autocmd CmdlineLeave * call rpcnotify(g:channel, 'CmdlineLeave', v:event)")
|
||||||
command("autocmd CmdWinEnter * call rpcnotify(g:channel, 'CmdWinEnter', v:event)")
|
command("autocmd CmdWinEnter * call rpcnotify(g:channel, 'CmdWinEnter', v:event)")
|
||||||
|
@@ -26,47 +26,47 @@ describe('CursorHold', function()
|
|||||||
-- if testing with small 'updatetime' fails, double its value and test again
|
-- if testing with small 'updatetime' fails, double its value and test again
|
||||||
retry(10, nil, function()
|
retry(10, nil, function()
|
||||||
ut = ut * 2
|
ut = ut * 2
|
||||||
meths.set_option_value('updatetime', ut, {})
|
meths.nvim_set_option_value('updatetime', ut, {})
|
||||||
feed('0') -- reset did_cursorhold
|
feed('0') -- reset did_cursorhold
|
||||||
meths.set_var('cursorhold', 0)
|
meths.nvim_set_var('cursorhold', 0)
|
||||||
sleep(ut / 4)
|
sleep(ut / 4)
|
||||||
fn()
|
fn()
|
||||||
eq(0, meths.get_var('cursorhold'))
|
eq(0, meths.nvim_get_var('cursorhold'))
|
||||||
sleep(ut / 2)
|
sleep(ut / 2)
|
||||||
fn()
|
fn()
|
||||||
eq(0, meths.get_var('cursorhold'))
|
eq(0, meths.nvim_get_var('cursorhold'))
|
||||||
sleep(ut / 2)
|
sleep(ut / 2)
|
||||||
eq(early, meths.get_var('cursorhold'))
|
eq(early, meths.nvim_get_var('cursorhold'))
|
||||||
sleep(ut / 4 * 3)
|
sleep(ut / 4 * 3)
|
||||||
eq(1, meths.get_var('cursorhold'))
|
eq(1, meths.nvim_get_var('cursorhold'))
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
local ignore_key = meths.replace_termcodes('<Ignore>', true, true, true)
|
local ignore_key = meths.nvim_replace_termcodes('<Ignore>', true, true, true)
|
||||||
test_cursorhold(function() end, 1)
|
test_cursorhold(function() end, 1)
|
||||||
test_cursorhold(function()
|
test_cursorhold(function()
|
||||||
feed('')
|
feed('')
|
||||||
end, 1)
|
end, 1)
|
||||||
test_cursorhold(function()
|
test_cursorhold(function()
|
||||||
meths.feedkeys('', 'n', true)
|
meths.nvim_feedkeys('', 'n', true)
|
||||||
end, 1)
|
end, 1)
|
||||||
test_cursorhold(function()
|
test_cursorhold(function()
|
||||||
feed('<Ignore>')
|
feed('<Ignore>')
|
||||||
end, 0)
|
end, 0)
|
||||||
test_cursorhold(function()
|
test_cursorhold(function()
|
||||||
meths.feedkeys(ignore_key, 'n', true)
|
meths.nvim_feedkeys(ignore_key, 'n', true)
|
||||||
end, 0)
|
end, 0)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("reducing 'updatetime' while waiting for CursorHold #20241", function()
|
it("reducing 'updatetime' while waiting for CursorHold #20241", function()
|
||||||
meths.set_option_value('updatetime', 10000, {})
|
meths.nvim_set_option_value('updatetime', 10000, {})
|
||||||
feed('0') -- reset did_cursorhold
|
feed('0') -- reset did_cursorhold
|
||||||
meths.set_var('cursorhold', 0)
|
meths.nvim_set_var('cursorhold', 0)
|
||||||
sleep(50)
|
sleep(50)
|
||||||
eq(0, meths.get_var('cursorhold'))
|
eq(0, meths.nvim_get_var('cursorhold'))
|
||||||
meths.set_option_value('updatetime', 20, {})
|
meths.nvim_set_option_value('updatetime', 20, {})
|
||||||
sleep(10)
|
sleep(10)
|
||||||
eq(1, meths.get_var('cursorhold'))
|
eq(1, meths.nvim_get_var('cursorhold'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -85,7 +85,7 @@ describe('CursorHoldI', function()
|
|||||||
feed('ifoo')
|
feed('ifoo')
|
||||||
retry(5, nil, function()
|
retry(5, nil, function()
|
||||||
sleep(1)
|
sleep(1)
|
||||||
eq(1, meths.get_var('cursorhold'))
|
eq(1, meths.nvim_get_var('cursorhold'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
@@ -41,9 +41,9 @@ describe('CursorMoved', function()
|
|||||||
vsplit foo
|
vsplit foo
|
||||||
autocmd CursorMoved * let g:cursormoved += 1
|
autocmd CursorMoved * let g:cursormoved += 1
|
||||||
]])
|
]])
|
||||||
meths.buf_set_lines(eval('g:buf'), 0, -1, true, { 'aaa' })
|
meths.nvim_buf_set_lines(eval('g:buf'), 0, -1, true, { 'aaa' })
|
||||||
eq(0, eval('g:cursormoved'))
|
eq(0, eval('g:cursormoved'))
|
||||||
eq({ 'aaa' }, meths.buf_get_lines(eval('g:buf'), 0, -1, true))
|
eq({ 'aaa' }, meths.nvim_buf_get_lines(eval('g:buf'), 0, -1, true))
|
||||||
eq(0, eval('g:cursormoved'))
|
eq(0, eval('g:cursormoved'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@@ -18,40 +18,40 @@ describe('SafeState autocommand', function()
|
|||||||
it('with pending operator', function()
|
it('with pending operator', function()
|
||||||
feed('d')
|
feed('d')
|
||||||
create_autocmd()
|
create_autocmd()
|
||||||
eq(0, meths.get_var('safe'))
|
eq(0, meths.nvim_get_var('safe'))
|
||||||
feed('d')
|
feed('d')
|
||||||
eq(1, meths.get_var('safe'))
|
eq(1, meths.nvim_get_var('safe'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('with specified register', function()
|
it('with specified register', function()
|
||||||
feed('"r')
|
feed('"r')
|
||||||
create_autocmd()
|
create_autocmd()
|
||||||
eq(0, meths.get_var('safe'))
|
eq(0, meths.nvim_get_var('safe'))
|
||||||
feed('x')
|
feed('x')
|
||||||
eq(1, meths.get_var('safe'))
|
eq(1, meths.nvim_get_var('safe'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('with i_CTRL-O', function()
|
it('with i_CTRL-O', function()
|
||||||
feed('i<C-O>')
|
feed('i<C-O>')
|
||||||
create_autocmd()
|
create_autocmd()
|
||||||
eq(0, meths.get_var('safe'))
|
eq(0, meths.nvim_get_var('safe'))
|
||||||
feed('x')
|
feed('x')
|
||||||
eq(1, meths.get_var('safe'))
|
eq(1, meths.nvim_get_var('safe'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('with Insert mode completion', function()
|
it('with Insert mode completion', function()
|
||||||
feed('i<C-X><C-V>')
|
feed('i<C-X><C-V>')
|
||||||
create_autocmd()
|
create_autocmd()
|
||||||
eq(0, meths.get_var('safe'))
|
eq(0, meths.nvim_get_var('safe'))
|
||||||
feed('<C-X><C-Z>')
|
feed('<C-X><C-Z>')
|
||||||
eq(1, meths.get_var('safe'))
|
eq(1, meths.nvim_get_var('safe'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('with Cmdline completion', function()
|
it('with Cmdline completion', function()
|
||||||
feed(':<Tab>')
|
feed(':<Tab>')
|
||||||
create_autocmd()
|
create_autocmd()
|
||||||
eq(0, meths.get_var('safe'))
|
eq(0, meths.nvim_get_var('safe'))
|
||||||
feed('<C-E>')
|
feed('<C-E>')
|
||||||
eq(1, meths.get_var('safe'))
|
eq(1, meths.nvim_get_var('safe'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
@@ -204,7 +204,7 @@ describe('autocmd TextChangedT', function()
|
|||||||
command('autocmd TextChangedT * ++once let g:called = 1')
|
command('autocmd TextChangedT * ++once let g:called = 1')
|
||||||
thelpers.feed_data('a')
|
thelpers.feed_data('a')
|
||||||
retry(nil, nil, function()
|
retry(nil, nil, function()
|
||||||
eq(1, meths.get_var('called'))
|
eq(1, meths.nvim_get_var('called'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -212,6 +212,9 @@ describe('autocmd TextChangedT', function()
|
|||||||
command([[autocmd TextChangedT * call nvim_input('<CR>') | bwipe!]])
|
command([[autocmd TextChangedT * call nvim_input('<CR>') | bwipe!]])
|
||||||
thelpers.feed_data('a')
|
thelpers.feed_data('a')
|
||||||
screen:expect({ any = 'E937: ' })
|
screen:expect({ any = 'E937: ' })
|
||||||
matches('^E937: Attempt to delete a buffer that is in use: term://', meths.get_vvar('errmsg'))
|
matches(
|
||||||
|
'^E937: Attempt to delete a buffer that is in use: term://',
|
||||||
|
meths.nvim_get_vvar('errmsg')
|
||||||
|
)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
@@ -45,7 +45,7 @@ describe('WinScrolled', function()
|
|||||||
local win_id
|
local win_id
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
win_id = meths.get_current_win().id
|
win_id = meths.nvim_get_current_win().id
|
||||||
command(string.format('autocmd WinScrolled %d let g:matched = v:true', win_id))
|
command(string.format('autocmd WinScrolled %d let g:matched = v:true', win_id))
|
||||||
exec([[
|
exec([[
|
||||||
let g:scrolled = 0
|
let g:scrolled = 0
|
||||||
@@ -64,7 +64,7 @@ describe('WinScrolled', function()
|
|||||||
|
|
||||||
it('is triggered by scrolling vertically', function()
|
it('is triggered by scrolling vertically', function()
|
||||||
local lines = { '123', '123' }
|
local lines = { '123', '123' }
|
||||||
meths.buf_set_lines(0, 0, -1, true, lines)
|
meths.nvim_buf_set_lines(0, 0, -1, true, lines)
|
||||||
eq(0, eval('g:scrolled'))
|
eq(0, eval('g:scrolled'))
|
||||||
|
|
||||||
feed('<C-E>')
|
feed('<C-E>')
|
||||||
@@ -84,10 +84,10 @@ describe('WinScrolled', function()
|
|||||||
|
|
||||||
it('is triggered by scrolling horizontally', function()
|
it('is triggered by scrolling horizontally', function()
|
||||||
command('set nowrap')
|
command('set nowrap')
|
||||||
local width = meths.win_get_width(0)
|
local width = meths.nvim_win_get_width(0)
|
||||||
local line = '123' .. ('*'):rep(width * 2)
|
local line = '123' .. ('*'):rep(width * 2)
|
||||||
local lines = { line, line }
|
local lines = { line, line }
|
||||||
meths.buf_set_lines(0, 0, -1, true, lines)
|
meths.nvim_buf_set_lines(0, 0, -1, true, lines)
|
||||||
eq(0, eval('g:scrolled'))
|
eq(0, eval('g:scrolled'))
|
||||||
|
|
||||||
feed('zl')
|
feed('zl')
|
||||||
@@ -108,8 +108,8 @@ describe('WinScrolled', function()
|
|||||||
it('is triggered by horizontal scrolling from cursor move', function()
|
it('is triggered by horizontal scrolling from cursor move', function()
|
||||||
command('set nowrap')
|
command('set nowrap')
|
||||||
local lines = { '', '', 'Foo' }
|
local lines = { '', '', 'Foo' }
|
||||||
meths.buf_set_lines(0, 0, -1, true, lines)
|
meths.nvim_buf_set_lines(0, 0, -1, true, lines)
|
||||||
meths.win_set_cursor(0, { 3, 0 })
|
meths.nvim_win_set_cursor(0, { 3, 0 })
|
||||||
eq(0, eval('g:scrolled'))
|
eq(0, eval('g:scrolled'))
|
||||||
|
|
||||||
feed('zl')
|
feed('zl')
|
||||||
@@ -143,10 +143,10 @@ describe('WinScrolled', function()
|
|||||||
|
|
||||||
-- oldtest: Test_WinScrolled_long_wrapped()
|
-- oldtest: Test_WinScrolled_long_wrapped()
|
||||||
it('is triggered by scrolling on a long wrapped line #19968', function()
|
it('is triggered by scrolling on a long wrapped line #19968', function()
|
||||||
local height = meths.win_get_height(0)
|
local height = meths.nvim_win_get_height(0)
|
||||||
local width = meths.win_get_width(0)
|
local width = meths.nvim_win_get_width(0)
|
||||||
meths.buf_set_lines(0, 0, -1, true, { ('foo'):rep(height * width) })
|
meths.nvim_buf_set_lines(0, 0, -1, true, { ('foo'):rep(height * width) })
|
||||||
meths.win_set_cursor(0, { 1, height * width - 1 })
|
meths.nvim_win_set_cursor(0, { 1, height * width - 1 })
|
||||||
eq(0, eval('g:scrolled'))
|
eq(0, eval('g:scrolled'))
|
||||||
|
|
||||||
feed('gj')
|
feed('gj')
|
||||||
@@ -168,12 +168,12 @@ describe('WinScrolled', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('is triggered when the window scrolls in Insert mode', function()
|
it('is triggered when the window scrolls in Insert mode', function()
|
||||||
local height = meths.win_get_height(0)
|
local height = meths.nvim_win_get_height(0)
|
||||||
local lines = {}
|
local lines = {}
|
||||||
for i = 1, height * 2 do
|
for i = 1, height * 2 do
|
||||||
lines[i] = tostring(i)
|
lines[i] = tostring(i)
|
||||||
end
|
end
|
||||||
meths.buf_set_lines(0, 0, -1, true, lines)
|
meths.nvim_buf_set_lines(0, 0, -1, true, lines)
|
||||||
|
|
||||||
feed('M')
|
feed('M')
|
||||||
eq(0, eval('g:scrolled'))
|
eq(0, eval('g:scrolled'))
|
||||||
@@ -220,12 +220,12 @@ describe('WinScrolled', function()
|
|||||||
eq(0, eval('g:scrolled'))
|
eq(0, eval('g:scrolled'))
|
||||||
|
|
||||||
-- With the upper split focused, send a scroll-down event to the unfocused one.
|
-- With the upper split focused, send a scroll-down event to the unfocused one.
|
||||||
meths.input_mouse('wheel', 'down', '', 0, 6, 0)
|
meths.nvim_input_mouse('wheel', 'down', '', 0, 6, 0)
|
||||||
eq(1, eval('g:scrolled'))
|
eq(1, eval('g:scrolled'))
|
||||||
|
|
||||||
-- Again, but this time while we're in insert mode.
|
-- Again, but this time while we're in insert mode.
|
||||||
feed('i')
|
feed('i')
|
||||||
meths.input_mouse('wheel', 'down', '', 0, 6, 0)
|
meths.nvim_input_mouse('wheel', 'down', '', 0, 6, 0)
|
||||||
feed('<Esc>')
|
feed('<Esc>')
|
||||||
eq(2, eval('g:scrolled'))
|
eq(2, eval('g:scrolled'))
|
||||||
end)
|
end)
|
||||||
@@ -296,15 +296,15 @@ describe('WinScrolled', function()
|
|||||||
]])
|
]])
|
||||||
eq(0, eval('g:scrolled'))
|
eq(0, eval('g:scrolled'))
|
||||||
|
|
||||||
local buf = meths.create_buf(true, true)
|
local buf = meths.nvim_create_buf(true, true)
|
||||||
meths.buf_set_lines(
|
meths.nvim_buf_set_lines(
|
||||||
buf,
|
buf,
|
||||||
0,
|
0,
|
||||||
-1,
|
-1,
|
||||||
false,
|
false,
|
||||||
{ '@', 'b', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n' }
|
{ '@', 'b', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n' }
|
||||||
)
|
)
|
||||||
local win = meths.open_win(buf, false, {
|
local win = meths.nvim_open_win(buf, false, {
|
||||||
height = 5,
|
height = 5,
|
||||||
width = 10,
|
width = 10,
|
||||||
col = 0,
|
col = 0,
|
||||||
@@ -317,7 +317,7 @@ describe('WinScrolled', function()
|
|||||||
-- WinScrolled should not be triggered when creating a new floating window
|
-- WinScrolled should not be triggered when creating a new floating window
|
||||||
eq(0, eval('g:scrolled'))
|
eq(0, eval('g:scrolled'))
|
||||||
|
|
||||||
meths.input_mouse('wheel', 'down', '', 0, 3, 3)
|
meths.nvim_input_mouse('wheel', 'down', '', 0, 3, 3)
|
||||||
eq(1, eval('g:scrolled'))
|
eq(1, eval('g:scrolled'))
|
||||||
eq(winid_str, eval('g:amatch'))
|
eq(winid_str, eval('g:amatch'))
|
||||||
eq({
|
eq({
|
||||||
@@ -325,7 +325,7 @@ describe('WinScrolled', function()
|
|||||||
[winid_str] = { leftcol = 0, topline = 3, topfill = 0, width = 0, height = 0, skipcol = 0 },
|
[winid_str] = { leftcol = 0, topline = 3, topfill = 0, width = 0, height = 0, skipcol = 0 },
|
||||||
}, eval('g:v_event'))
|
}, eval('g:v_event'))
|
||||||
|
|
||||||
meths.input_mouse('wheel', 'up', '', 0, 3, 3)
|
meths.nvim_input_mouse('wheel', 'up', '', 0, 3, 3)
|
||||||
eq(2, eval('g:scrolled'))
|
eq(2, eval('g:scrolled'))
|
||||||
eq(tostring(win.id), eval('g:amatch'))
|
eq(tostring(win.id), eval('g:amatch'))
|
||||||
eq({
|
eq({
|
||||||
|
@@ -38,7 +38,7 @@ describe('channels', function()
|
|||||||
set_session(client)
|
set_session(client)
|
||||||
source(init)
|
source(init)
|
||||||
|
|
||||||
meths.set_var('address', address)
|
meths.nvim_set_var('address', address)
|
||||||
command("let g:id = sockconnect('pipe', address, {'on_data':'OnEvent'})")
|
command("let g:id = sockconnect('pipe', address, {'on_data':'OnEvent'})")
|
||||||
local id = eval('g:id')
|
local id = eval('g:id')
|
||||||
ok(id > 0)
|
ok(id > 0)
|
||||||
@@ -46,7 +46,7 @@ describe('channels', function()
|
|||||||
command("call chansend(g:id, msgpackdump([[2,'nvim_set_var',['code',23]]]))")
|
command("call chansend(g:id, msgpackdump([[2,'nvim_set_var',['code',23]]]))")
|
||||||
set_session(server)
|
set_session(server)
|
||||||
retry(nil, 1000, function()
|
retry(nil, 1000, function()
|
||||||
eq(23, meths.get_var('code'))
|
eq(23, meths.nvim_get_var('code'))
|
||||||
end)
|
end)
|
||||||
set_session(client)
|
set_session(client)
|
||||||
|
|
||||||
@@ -67,8 +67,8 @@ describe('channels', function()
|
|||||||
\ 'on_exit': function('OnEvent'),
|
\ 'on_exit': function('OnEvent'),
|
||||||
\ }
|
\ }
|
||||||
]])
|
]])
|
||||||
meths.set_var('nvim_prog', nvim_prog)
|
meths.nvim_set_var('nvim_prog', nvim_prog)
|
||||||
meths.set_var(
|
meths.nvim_set_var(
|
||||||
'code',
|
'code',
|
||||||
[[
|
[[
|
||||||
function! OnEvent(id, data, event) dict
|
function! OnEvent(id, data, event) dict
|
||||||
@@ -117,8 +117,8 @@ describe('channels', function()
|
|||||||
\ 'on_exit': function('OnEvent'),
|
\ 'on_exit': function('OnEvent'),
|
||||||
\ }
|
\ }
|
||||||
]])
|
]])
|
||||||
meths.set_var('nvim_prog', nvim_prog)
|
meths.nvim_set_var('nvim_prog', nvim_prog)
|
||||||
meths.set_var(
|
meths.nvim_set_var(
|
||||||
'code',
|
'code',
|
||||||
[[
|
[[
|
||||||
function! OnStdin(id, data, event) dict
|
function! OnStdin(id, data, event) dict
|
||||||
@@ -165,8 +165,8 @@ describe('channels', function()
|
|||||||
\ 'pty': v:true,
|
\ 'pty': v:true,
|
||||||
\ }
|
\ }
|
||||||
]])
|
]])
|
||||||
meths.set_var('nvim_prog', nvim_prog)
|
meths.nvim_set_var('nvim_prog', nvim_prog)
|
||||||
meths.set_var(
|
meths.nvim_set_var(
|
||||||
'code',
|
'code',
|
||||||
[[
|
[[
|
||||||
function! OnEvent(id, data, event) dict
|
function! OnEvent(id, data, event) dict
|
||||||
@@ -220,8 +220,8 @@ describe('channels', function()
|
|||||||
\ 'rpc': v:true,
|
\ 'rpc': v:true,
|
||||||
\ }
|
\ }
|
||||||
]])
|
]])
|
||||||
meths.set_var('nvim_prog', nvim_prog)
|
meths.nvim_set_var('nvim_prog', nvim_prog)
|
||||||
meths.set_var(
|
meths.nvim_set_var(
|
||||||
'code',
|
'code',
|
||||||
[[
|
[[
|
||||||
let id = stdioopen({'rpc':v:true})
|
let id = stdioopen({'rpc':v:true})
|
||||||
|
@@ -409,14 +409,14 @@ describe('tmpdir', function()
|
|||||||
funcs.tempname()
|
funcs.tempname()
|
||||||
funcs.tempname()
|
funcs.tempname()
|
||||||
funcs.tempname()
|
funcs.tempname()
|
||||||
eq('', meths.get_vvar('errmsg'))
|
eq('', meths.nvim_get_vvar('errmsg'))
|
||||||
rm_tmpdir()
|
rm_tmpdir()
|
||||||
funcs.tempname()
|
funcs.tempname()
|
||||||
funcs.tempname()
|
funcs.tempname()
|
||||||
funcs.tempname()
|
funcs.tempname()
|
||||||
eq('E5431: tempdir disappeared (2 times)', meths.get_vvar('errmsg'))
|
eq('E5431: tempdir disappeared (2 times)', meths.nvim_get_vvar('errmsg'))
|
||||||
rm_tmpdir()
|
rm_tmpdir()
|
||||||
eq('E5431: tempdir disappeared (3 times)', meths.get_vvar('errmsg'))
|
eq('E5431: tempdir disappeared (3 times)', meths.nvim_get_vvar('errmsg'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('$NVIM_APPNAME relative path', function()
|
it('$NVIM_APPNAME relative path', function()
|
||||||
|
@@ -403,11 +403,11 @@ describe('jobs', function()
|
|||||||
it('can get the pid value using getpid', function()
|
it('can get the pid value using getpid', function()
|
||||||
nvim('command', "let j = jobstart(['cat', '-'], g:job_opts)")
|
nvim('command', "let j = jobstart(['cat', '-'], g:job_opts)")
|
||||||
local pid = eval('jobpid(j)')
|
local pid = eval('jobpid(j)')
|
||||||
neq(NIL, meths.get_proc(pid))
|
neq(NIL, meths.nvim_get_proc(pid))
|
||||||
nvim('command', 'call jobstop(j)')
|
nvim('command', 'call jobstop(j)')
|
||||||
eq({ 'notification', 'stdout', { 0, { '' } } }, next_msg())
|
eq({ 'notification', 'stdout', { 0, { '' } } }, next_msg())
|
||||||
eq({ 'notification', 'exit', { 0, 143 } }, next_msg())
|
eq({ 'notification', 'exit', { 0, 143 } }, next_msg())
|
||||||
eq(NIL, meths.get_proc(pid))
|
eq(NIL, meths.nvim_get_proc(pid))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('disposed on Nvim exit', function()
|
it('disposed on Nvim exit', function()
|
||||||
@@ -417,9 +417,9 @@ describe('jobs', function()
|
|||||||
"let g:j = jobstart(has('win32') ? ['ping', '-n', '1001', '127.0.0.1'] : ['sleep', '1000'], g:job_opts)"
|
"let g:j = jobstart(has('win32') ? ['ping', '-n', '1001', '127.0.0.1'] : ['sleep', '1000'], g:job_opts)"
|
||||||
)
|
)
|
||||||
local pid = eval('jobpid(g:j)')
|
local pid = eval('jobpid(g:j)')
|
||||||
neq(NIL, meths.get_proc(pid))
|
neq(NIL, meths.nvim_get_proc(pid))
|
||||||
clear()
|
clear()
|
||||||
eq(NIL, meths.get_proc(pid))
|
eq(NIL, meths.nvim_get_proc(pid))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('can survive the exit of nvim with "detach"', function()
|
it('can survive the exit of nvim with "detach"', function()
|
||||||
@@ -429,9 +429,9 @@ describe('jobs', function()
|
|||||||
"let g:j = jobstart(has('win32') ? ['ping', '-n', '1001', '127.0.0.1'] : ['sleep', '1000'], g:job_opts)"
|
"let g:j = jobstart(has('win32') ? ['ping', '-n', '1001', '127.0.0.1'] : ['sleep', '1000'], g:job_opts)"
|
||||||
)
|
)
|
||||||
local pid = eval('jobpid(g:j)')
|
local pid = eval('jobpid(g:j)')
|
||||||
neq(NIL, meths.get_proc(pid))
|
neq(NIL, meths.nvim_get_proc(pid))
|
||||||
clear()
|
clear()
|
||||||
neq(NIL, meths.get_proc(pid))
|
neq(NIL, meths.nvim_get_proc(pid))
|
||||||
-- clean up after ourselves
|
-- clean up after ourselves
|
||||||
eq(0, os_kill(pid))
|
eq(0, os_kill(pid))
|
||||||
end)
|
end)
|
||||||
@@ -948,7 +948,7 @@ describe('jobs', function()
|
|||||||
]],
|
]],
|
||||||
}
|
}
|
||||||
feed('<CR>')
|
feed('<CR>')
|
||||||
funcs.jobstop(meths.get_var('id'))
|
funcs.jobstop(meths.nvim_get_var('id'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -1066,7 +1066,7 @@ describe('jobs', function()
|
|||||||
local children
|
local children
|
||||||
if is_os('win') then
|
if is_os('win') then
|
||||||
local status, result = pcall(retry, nil, nil, function()
|
local status, result = pcall(retry, nil, nil, function()
|
||||||
children = meths.get_proc_children(ppid)
|
children = meths.nvim_get_proc_children(ppid)
|
||||||
-- On Windows conhost.exe may exist, and
|
-- On Windows conhost.exe may exist, and
|
||||||
-- e.g. vctip.exe might appear. #10783
|
-- e.g. vctip.exe might appear. #10783
|
||||||
ok(#children >= 3 and #children <= 5)
|
ok(#children >= 3 and #children <= 5)
|
||||||
@@ -1078,13 +1078,13 @@ describe('jobs', function()
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
retry(nil, nil, function()
|
retry(nil, nil, function()
|
||||||
children = meths.get_proc_children(ppid)
|
children = meths.nvim_get_proc_children(ppid)
|
||||||
eq(3, #children)
|
eq(3, #children)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
-- Assert that nvim_get_proc() sees the children.
|
-- Assert that nvim_get_proc() sees the children.
|
||||||
for _, child_pid in ipairs(children) do
|
for _, child_pid in ipairs(children) do
|
||||||
local info = meths.get_proc(child_pid)
|
local info = meths.nvim_get_proc(child_pid)
|
||||||
-- eq((is_os('win') and 'nvim.exe' or 'nvim'), info.name)
|
-- eq((is_os('win') and 'nvim.exe' or 'nvim'), info.name)
|
||||||
eq(ppid, info.ppid)
|
eq(ppid, info.ppid)
|
||||||
end
|
end
|
||||||
@@ -1093,7 +1093,7 @@ describe('jobs', function()
|
|||||||
-- Assert that the children were killed.
|
-- Assert that the children were killed.
|
||||||
retry(nil, nil, function()
|
retry(nil, nil, function()
|
||||||
for _, child_pid in ipairs(children) do
|
for _, child_pid in ipairs(children) do
|
||||||
eq(NIL, meths.get_proc(child_pid))
|
eq(NIL, meths.nvim_get_proc(child_pid))
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
@@ -1129,7 +1129,7 @@ describe('jobs', function()
|
|||||||
local j
|
local j
|
||||||
local function send(str)
|
local function send(str)
|
||||||
-- check no nvim_chan_free double free with pty job (#14198)
|
-- check no nvim_chan_free double free with pty job (#14198)
|
||||||
meths.chan_send(j, str)
|
meths.nvim_chan_send(j, str)
|
||||||
end
|
end
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
|
@@ -24,7 +24,7 @@ describe('spellfile', function()
|
|||||||
-- │ ┌ Spell file version (#VIMSPELLVERSION)
|
-- │ ┌ Spell file version (#VIMSPELLVERSION)
|
||||||
local spellheader = 'VIMspell\050'
|
local spellheader = 'VIMspell\050'
|
||||||
it('errors out when prefcond section is truncated', function()
|
it('errors out when prefcond section is truncated', function()
|
||||||
meths.set_option_value('runtimepath', testdir, {})
|
meths.nvim_set_option_value('runtimepath', testdir, {})
|
||||||
-- stylua: ignore
|
-- stylua: ignore
|
||||||
write_file(testdir .. '/spell/en.ascii.spl',
|
write_file(testdir .. '/spell/en.ascii.spl',
|
||||||
-- ┌ Section identifier (#SN_PREFCOND)
|
-- ┌ Section identifier (#SN_PREFCOND)
|
||||||
@@ -35,11 +35,11 @@ describe('spellfile', function()
|
|||||||
-- │ ┌ Condition length (1 byte)
|
-- │ ┌ Condition length (1 byte)
|
||||||
-- │ │ ┌ Condition regex (missing!)
|
-- │ │ ┌ Condition regex (missing!)
|
||||||
.. '\000\001\001')
|
.. '\000\001\001')
|
||||||
meths.set_option_value('spelllang', 'en', {})
|
meths.nvim_set_option_value('spelllang', 'en', {})
|
||||||
eq('Vim(set):E758: Truncated spell file', exc_exec('set spell'))
|
eq('Vim(set):E758: Truncated spell file', exc_exec('set spell'))
|
||||||
end)
|
end)
|
||||||
it('errors out when prefcond regexp contains NUL byte', function()
|
it('errors out when prefcond regexp contains NUL byte', function()
|
||||||
meths.set_option_value('runtimepath', testdir, {})
|
meths.nvim_set_option_value('runtimepath', testdir, {})
|
||||||
-- stylua: ignore
|
-- stylua: ignore
|
||||||
write_file(testdir .. '/spell/en.ascii.spl',
|
write_file(testdir .. '/spell/en.ascii.spl',
|
||||||
-- ┌ Section identifier (#SN_PREFCOND)
|
-- ┌ Section identifier (#SN_PREFCOND)
|
||||||
@@ -55,11 +55,11 @@ describe('spellfile', function()
|
|||||||
-- │ ┌ KWORDTREE tree length (4 bytes)
|
-- │ ┌ KWORDTREE tree length (4 bytes)
|
||||||
-- │ │ ┌ PREFIXTREE tree length
|
-- │ │ ┌ PREFIXTREE tree length
|
||||||
.. '\000\000\000\000\000\000\000\000\000\000\000\000')
|
.. '\000\000\000\000\000\000\000\000\000\000\000\000')
|
||||||
meths.set_option_value('spelllang', 'en', {})
|
meths.nvim_set_option_value('spelllang', 'en', {})
|
||||||
eq('Vim(set):E759: Format error in spell file', exc_exec('set spell'))
|
eq('Vim(set):E759: Format error in spell file', exc_exec('set spell'))
|
||||||
end)
|
end)
|
||||||
it('errors out when region contains NUL byte', function()
|
it('errors out when region contains NUL byte', function()
|
||||||
meths.set_option_value('runtimepath', testdir, {})
|
meths.nvim_set_option_value('runtimepath', testdir, {})
|
||||||
-- stylua: ignore
|
-- stylua: ignore
|
||||||
write_file(testdir .. '/spell/en.ascii.spl',
|
write_file(testdir .. '/spell/en.ascii.spl',
|
||||||
-- ┌ Section identifier (#SN_REGION)
|
-- ┌ Section identifier (#SN_REGION)
|
||||||
@@ -72,11 +72,11 @@ describe('spellfile', function()
|
|||||||
-- │ ┌ KWORDTREE tree length (4 bytes)
|
-- │ ┌ KWORDTREE tree length (4 bytes)
|
||||||
-- │ │ ┌ PREFIXTREE tree length
|
-- │ │ ┌ PREFIXTREE tree length
|
||||||
.. '\000\000\000\000\000\000\000\000\000\000\000\000')
|
.. '\000\000\000\000\000\000\000\000\000\000\000\000')
|
||||||
meths.set_option_value('spelllang', 'en', {})
|
meths.nvim_set_option_value('spelllang', 'en', {})
|
||||||
eq('Vim(set):E759: Format error in spell file', exc_exec('set spell'))
|
eq('Vim(set):E759: Format error in spell file', exc_exec('set spell'))
|
||||||
end)
|
end)
|
||||||
it('errors out when SAL section contains NUL byte', function()
|
it('errors out when SAL section contains NUL byte', function()
|
||||||
meths.set_option_value('runtimepath', testdir, {})
|
meths.nvim_set_option_value('runtimepath', testdir, {})
|
||||||
-- stylua: ignore
|
-- stylua: ignore
|
||||||
write_file(testdir .. '/spell/en.ascii.spl',
|
write_file(testdir .. '/spell/en.ascii.spl',
|
||||||
-- ┌ Section identifier (#SN_SAL)
|
-- ┌ Section identifier (#SN_SAL)
|
||||||
@@ -96,13 +96,13 @@ describe('spellfile', function()
|
|||||||
-- │ ┌ KWORDTREE tree length (4 bytes)
|
-- │ ┌ KWORDTREE tree length (4 bytes)
|
||||||
-- │ │ ┌ PREFIXTREE tree length
|
-- │ │ ┌ PREFIXTREE tree length
|
||||||
.. '\000\000\000\000\000\000\000\000\000\000\000\000')
|
.. '\000\000\000\000\000\000\000\000\000\000\000\000')
|
||||||
meths.set_option_value('spelllang', 'en', {})
|
meths.nvim_set_option_value('spelllang', 'en', {})
|
||||||
eq('Vim(set):E759: Format error in spell file', exc_exec('set spell'))
|
eq('Vim(set):E759: Format error in spell file', exc_exec('set spell'))
|
||||||
end)
|
end)
|
||||||
it('errors out when spell header contains NUL bytes', function()
|
it('errors out when spell header contains NUL bytes', function()
|
||||||
meths.set_option_value('runtimepath', testdir, {})
|
meths.nvim_set_option_value('runtimepath', testdir, {})
|
||||||
write_file(testdir .. '/spell/en.ascii.spl', spellheader:sub(1, -3) .. '\000\000')
|
write_file(testdir .. '/spell/en.ascii.spl', spellheader:sub(1, -3) .. '\000\000')
|
||||||
meths.set_option_value('spelllang', 'en', {})
|
meths.nvim_set_option_value('spelllang', 'en', {})
|
||||||
eq('Vim(set):E757: This does not look like a spell file', exc_exec('set spell'))
|
eq('Vim(set):E757: This does not look like a spell file', exc_exec('set spell'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
@@ -38,7 +38,7 @@ describe('startup', function()
|
|||||||
clear()
|
clear()
|
||||||
ok(
|
ok(
|
||||||
string.find(
|
string.find(
|
||||||
alter_slashes(meths.get_option_value('runtimepath', {})),
|
alter_slashes(meths.nvim_get_option_value('runtimepath', {})),
|
||||||
funcs.stdpath('config'),
|
funcs.stdpath('config'),
|
||||||
1,
|
1,
|
||||||
true
|
true
|
||||||
@@ -47,7 +47,7 @@ describe('startup', function()
|
|||||||
clear('--clean')
|
clear('--clean')
|
||||||
ok(
|
ok(
|
||||||
string.find(
|
string.find(
|
||||||
alter_slashes(meths.get_option_value('runtimepath', {})),
|
alter_slashes(meths.nvim_get_option_value('runtimepath', {})),
|
||||||
funcs.stdpath('config'),
|
funcs.stdpath('config'),
|
||||||
1,
|
1,
|
||||||
true
|
true
|
||||||
@@ -737,11 +737,11 @@ describe('startup', function()
|
|||||||
os.remove('Xdiff.vim')
|
os.remove('Xdiff.vim')
|
||||||
end)
|
end)
|
||||||
clear { args = { '-u', 'Xdiff.vim', '-d', 'Xdiff.vim', 'Xdiff.vim' } }
|
clear { args = { '-u', 'Xdiff.vim', '-d', 'Xdiff.vim', 'Xdiff.vim' } }
|
||||||
eq(true, meths.get_option_value('diff', { win = funcs.win_getid(1) }))
|
eq(true, meths.nvim_get_option_value('diff', { win = funcs.win_getid(1) }))
|
||||||
eq(true, meths.get_option_value('diff', { win = funcs.win_getid(2) }))
|
eq(true, meths.nvim_get_option_value('diff', { win = funcs.win_getid(2) }))
|
||||||
local float_win = funcs.win_getid(3)
|
local float_win = funcs.win_getid(3)
|
||||||
eq('editor', meths.win_get_config(float_win).relative)
|
eq('editor', meths.nvim_win_get_config(float_win).relative)
|
||||||
eq(false, meths.get_option_value('diff', { win = float_win }))
|
eq(false, meths.nvim_get_option_value('diff', { win = float_win }))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('does not crash if --embed is given twice', function()
|
it('does not crash if --embed is given twice', function()
|
||||||
@@ -870,7 +870,7 @@ describe('startup', function()
|
|||||||
exec_lua [[ return _G.test_loadorder ]]
|
exec_lua [[ return _G.test_loadorder ]]
|
||||||
)
|
)
|
||||||
|
|
||||||
local rtp = meths.get_option_value('rtp', {})
|
local rtp = meths.nvim_get_option_value('rtp', {})
|
||||||
ok(
|
ok(
|
||||||
startswith(
|
startswith(
|
||||||
rtp,
|
rtp,
|
||||||
@@ -963,9 +963,9 @@ describe('startup', function()
|
|||||||
os.remove('Xtab2.noft')
|
os.remove('Xtab2.noft')
|
||||||
end)
|
end)
|
||||||
clear({ args = { '-p', 'Xtab1.noft', 'Xtab2.noft' } })
|
clear({ args = { '-p', 'Xtab1.noft', 'Xtab2.noft' } })
|
||||||
eq(81, meths.win_get_width(0))
|
eq(81, meths.nvim_win_get_width(0))
|
||||||
command('tabnext')
|
command('tabnext')
|
||||||
eq(81, meths.win_get_width(0))
|
eq(81, meths.nvim_win_get_width(0))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@@ -61,9 +61,9 @@ describe('K', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('empty string falls back to :help #19298', function()
|
it('empty string falls back to :help #19298', function()
|
||||||
meths.set_option_value('keywordprg', '', {})
|
meths.nvim_set_option_value('keywordprg', '', {})
|
||||||
meths.buf_set_lines(0, 0, -1, true, { 'doesnotexist' })
|
meths.nvim_buf_set_lines(0, 0, -1, true, { 'doesnotexist' })
|
||||||
feed('K')
|
feed('K')
|
||||||
eq('E149: Sorry, no help for doesnotexist', meths.get_vvar('errmsg'))
|
eq('E149: Sorry, no help for doesnotexist', meths.nvim_get_vvar('errmsg'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
@@ -883,8 +883,8 @@ describe('completion', function()
|
|||||||
return ''
|
return ''
|
||||||
endfunction
|
endfunction
|
||||||
]])
|
]])
|
||||||
meths.set_option_value('completeopt', 'menuone,noselect', {})
|
meths.nvim_set_option_value('completeopt', 'menuone,noselect', {})
|
||||||
meths.set_var('_complist', {
|
meths.nvim_set_var('_complist', {
|
||||||
{
|
{
|
||||||
word = 0,
|
word = 0,
|
||||||
abbr = 1,
|
abbr = 1,
|
||||||
|
@@ -139,7 +139,7 @@ describe('immediately after a macro has finished executing,', function()
|
|||||||
|
|
||||||
it('if the macro does not end with a <Nop> mapping', function()
|
it('if the macro does not end with a <Nop> mapping', function()
|
||||||
feed('@asq') -- "q" from "s" mapping should start recording a macro instead of being no-op
|
feed('@asq') -- "q" from "s" mapping should start recording a macro instead of being no-op
|
||||||
eq({ mode = 'n', blocking = false }, meths.get_mode())
|
eq({ mode = 'n', blocking = false }, meths.nvim_get_mode())
|
||||||
expect('')
|
expect('')
|
||||||
eq('', eval('@a'))
|
eq('', eval('@a'))
|
||||||
end)
|
end)
|
||||||
@@ -147,7 +147,7 @@ describe('immediately after a macro has finished executing,', function()
|
|||||||
it('if the macro ends with a <Nop> mapping', function()
|
it('if the macro ends with a <Nop> mapping', function()
|
||||||
command('nnoremap 0 <Nop>')
|
command('nnoremap 0 <Nop>')
|
||||||
feed('@asq') -- "q" from "s" mapping should start recording a macro instead of being no-op
|
feed('@asq') -- "q" from "s" mapping should start recording a macro instead of being no-op
|
||||||
eq({ mode = 'n', blocking = false }, meths.get_mode())
|
eq({ mode = 'n', blocking = false }, meths.nvim_get_mode())
|
||||||
expect('')
|
expect('')
|
||||||
eq('', eval('@a'))
|
eq('', eval('@a'))
|
||||||
end)
|
end)
|
||||||
|
@@ -10,7 +10,7 @@ local feed = helpers.feed
|
|||||||
local write_file = helpers.write_file
|
local write_file = helpers.write_file
|
||||||
local pcall_err = helpers.pcall_err
|
local pcall_err = helpers.pcall_err
|
||||||
local cursor = function()
|
local cursor = function()
|
||||||
return helpers.meths.win_get_cursor(0)
|
return helpers.meths.nvim_win_get_cursor(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe('named marks', function()
|
describe('named marks', function()
|
||||||
@@ -105,7 +105,7 @@ describe('named marks', function()
|
|||||||
feed('mA')
|
feed('mA')
|
||||||
command('next')
|
command('next')
|
||||||
feed("'A")
|
feed("'A")
|
||||||
eq(1, meths.get_current_buf().id)
|
eq(1, meths.nvim_get_current_buf().id)
|
||||||
eq({ 2, 0 }, cursor())
|
eq({ 2, 0 }, cursor())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ describe('named marks', function()
|
|||||||
feed('mA')
|
feed('mA')
|
||||||
command('next')
|
command('next')
|
||||||
feed('`A')
|
feed('`A')
|
||||||
eq(1, meths.get_current_buf().id)
|
eq(1, meths.nvim_get_current_buf().id)
|
||||||
eq({ 2, 2 }, cursor())
|
eq({ 2, 2 }, cursor())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -131,7 +131,7 @@ describe('named marks', function()
|
|||||||
feed('mA')
|
feed('mA')
|
||||||
command('next')
|
command('next')
|
||||||
feed("g'A")
|
feed("g'A")
|
||||||
eq(1, meths.get_current_buf().id)
|
eq(1, meths.nvim_get_current_buf().id)
|
||||||
eq({ 2, 0 }, cursor())
|
eq({ 2, 0 }, cursor())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -144,7 +144,7 @@ describe('named marks', function()
|
|||||||
feed('mA')
|
feed('mA')
|
||||||
command('next')
|
command('next')
|
||||||
feed('g`A')
|
feed('g`A')
|
||||||
eq(1, meths.get_current_buf().id)
|
eq(1, meths.nvim_get_current_buf().id)
|
||||||
eq({ 2, 2 }, cursor())
|
eq({ 2, 2 }, cursor())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -158,7 +158,7 @@ describe('named marks', function()
|
|||||||
feed('mA')
|
feed('mA')
|
||||||
command('next')
|
command('next')
|
||||||
command("'A")
|
command("'A")
|
||||||
eq(1, meths.get_current_buf().id)
|
eq(1, meths.nvim_get_current_buf().id)
|
||||||
eq({ 2, 0 }, cursor())
|
eq({ 2, 0 }, cursor())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -303,24 +303,24 @@ describe('named marks', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it("getting '{ '} '( ') does not move cursor", function()
|
it("getting '{ '} '( ') does not move cursor", function()
|
||||||
meths.buf_set_lines(0, 0, 0, true, { 'aaaaa', 'bbbbb', 'ccccc', 'ddddd', 'eeeee' })
|
meths.nvim_buf_set_lines(0, 0, 0, true, { 'aaaaa', 'bbbbb', 'ccccc', 'ddddd', 'eeeee' })
|
||||||
meths.win_set_cursor(0, { 2, 0 })
|
meths.nvim_win_set_cursor(0, { 2, 0 })
|
||||||
funcs.getpos("'{")
|
funcs.getpos("'{")
|
||||||
eq({ 2, 0 }, meths.win_get_cursor(0))
|
eq({ 2, 0 }, meths.nvim_win_get_cursor(0))
|
||||||
funcs.getpos("'}")
|
funcs.getpos("'}")
|
||||||
eq({ 2, 0 }, meths.win_get_cursor(0))
|
eq({ 2, 0 }, meths.nvim_win_get_cursor(0))
|
||||||
funcs.getpos("'(")
|
funcs.getpos("'(")
|
||||||
eq({ 2, 0 }, meths.win_get_cursor(0))
|
eq({ 2, 0 }, meths.nvim_win_get_cursor(0))
|
||||||
funcs.getpos("')")
|
funcs.getpos("')")
|
||||||
eq({ 2, 0 }, meths.win_get_cursor(0))
|
eq({ 2, 0 }, meths.nvim_win_get_cursor(0))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('in command range does not move cursor #19248', function()
|
it('in command range does not move cursor #19248', function()
|
||||||
meths.create_user_command('Test', ':', { range = true })
|
meths.nvim_create_user_command('Test', ':', { range = true })
|
||||||
meths.buf_set_lines(0, 0, 0, true, { 'aaaaa', 'bbbbb', 'ccccc', 'ddddd', 'eeeee' })
|
meths.nvim_buf_set_lines(0, 0, 0, true, { 'aaaaa', 'bbbbb', 'ccccc', 'ddddd', 'eeeee' })
|
||||||
meths.win_set_cursor(0, { 2, 0 })
|
meths.nvim_win_set_cursor(0, { 2, 0 })
|
||||||
command([['{,'}Test]])
|
command([['{,'}Test]])
|
||||||
eq({ 2, 0 }, meths.win_get_cursor(0))
|
eq({ 2, 0 }, meths.nvim_win_get_cursor(0))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@@ -85,7 +85,7 @@ describe('cmdline', function()
|
|||||||
it('correctly clears end of the history', function()
|
it('correctly clears end of the history', function()
|
||||||
-- Regression test: check absence of the memory leak when clearing end of
|
-- Regression test: check absence of the memory leak when clearing end of
|
||||||
-- the history using cmdhist.c/clr_history().
|
-- the history using cmdhist.c/clr_history().
|
||||||
meths.set_option_value('history', 1, {})
|
meths.nvim_set_option_value('history', 1, {})
|
||||||
eq(1, funcs.histadd(':', 'foo'))
|
eq(1, funcs.histadd(':', 'foo'))
|
||||||
eq(1, funcs.histdel(':'))
|
eq(1, funcs.histdel(':'))
|
||||||
eq('', funcs.histget(':', -1))
|
eq('', funcs.histget(':', -1))
|
||||||
|
@@ -74,28 +74,28 @@ describe('tabpage', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('nvim_win_close and nvim_win_hide update tabline #20285', function()
|
it('nvim_win_close and nvim_win_hide update tabline #20285', function()
|
||||||
eq(1, #meths.list_tabpages())
|
eq(1, #meths.nvim_list_tabpages())
|
||||||
eq({ 1, 1 }, funcs.win_screenpos(0))
|
eq({ 1, 1 }, funcs.win_screenpos(0))
|
||||||
local win1 = curwin().id
|
local win1 = curwin().id
|
||||||
|
|
||||||
command('tabnew')
|
command('tabnew')
|
||||||
eq(2, #meths.list_tabpages())
|
eq(2, #meths.nvim_list_tabpages())
|
||||||
eq({ 2, 1 }, funcs.win_screenpos(0))
|
eq({ 2, 1 }, funcs.win_screenpos(0))
|
||||||
local win2 = curwin().id
|
local win2 = curwin().id
|
||||||
|
|
||||||
meths.win_close(win1, true)
|
meths.nvim_win_close(win1, true)
|
||||||
eq(win2, curwin().id)
|
eq(win2, curwin().id)
|
||||||
eq(1, #meths.list_tabpages())
|
eq(1, #meths.nvim_list_tabpages())
|
||||||
eq({ 1, 1 }, funcs.win_screenpos(0))
|
eq({ 1, 1 }, funcs.win_screenpos(0))
|
||||||
|
|
||||||
command('tabnew')
|
command('tabnew')
|
||||||
eq(2, #meths.list_tabpages())
|
eq(2, #meths.nvim_list_tabpages())
|
||||||
eq({ 2, 1 }, funcs.win_screenpos(0))
|
eq({ 2, 1 }, funcs.win_screenpos(0))
|
||||||
local win3 = curwin().id
|
local win3 = curwin().id
|
||||||
|
|
||||||
meths.win_hide(win2)
|
meths.nvim_win_hide(win2)
|
||||||
eq(win3, curwin().id)
|
eq(win3, curwin().id)
|
||||||
eq(1, #meths.list_tabpages())
|
eq(1, #meths.nvim_list_tabpages())
|
||||||
eq({ 1, 1 }, funcs.win_screenpos(0))
|
eq({ 1, 1 }, funcs.win_screenpos(0))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ describe('tabpage', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it(':tabs does not overflow IObuff with long path with comma #20850', function()
|
it(':tabs does not overflow IObuff with long path with comma #20850', function()
|
||||||
meths.buf_set_name(0, ('x'):rep(1024) .. ',' .. ('x'):rep(1024))
|
meths.nvim_buf_set_name(0, ('x'):rep(1024) .. ',' .. ('x'):rep(1024))
|
||||||
command('tabs')
|
command('tabs')
|
||||||
assert_alive()
|
assert_alive()
|
||||||
end)
|
end)
|
||||||
|
@@ -42,7 +42,7 @@ local cmdtest = function(cmd, prep, ret1)
|
|||||||
eq(hisline, funcs.histget(':', -2))
|
eq(hisline, funcs.histget(':', -2))
|
||||||
eq(cmd, funcs.histget(':'))
|
eq(cmd, funcs.histget(':'))
|
||||||
-- Test that command-line window was launched
|
-- Test that command-line window was launched
|
||||||
eq('nofile', meths.get_option_value('buftype', {}))
|
eq('nofile', meths.nvim_get_option_value('buftype', {}))
|
||||||
eq('n', funcs.mode(1))
|
eq('n', funcs.mode(1))
|
||||||
feed('<CR>')
|
feed('<CR>')
|
||||||
eq('c', funcs.mode(1))
|
eq('c', funcs.mode(1))
|
||||||
|
@@ -223,7 +223,7 @@ describe(':echo :echon :echomsg :echoerr', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('does not crash or halt when dumping partials with reference cycles in self', function()
|
it('does not crash or halt when dumping partials with reference cycles in self', function()
|
||||||
meths.set_var('d', { v = true })
|
meths.nvim_set_var('d', { v = true })
|
||||||
eq(
|
eq(
|
||||||
dedent(
|
dedent(
|
||||||
[[
|
[[
|
||||||
@@ -251,7 +251,7 @@ describe(':echo :echon :echomsg :echoerr', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('does not crash or halt when dumping partials with reference cycles in arguments', function()
|
it('does not crash or halt when dumping partials with reference cycles in arguments', function()
|
||||||
meths.set_var('l', {})
|
meths.nvim_set_var('l', {})
|
||||||
eval('add(l, l)')
|
eval('add(l, l)')
|
||||||
-- Regression: the below line used to crash (add returns original list and
|
-- Regression: the below line used to crash (add returns original list and
|
||||||
-- there was error in dumping partials). Tested explicitly in
|
-- there was error in dumping partials). Tested explicitly in
|
||||||
@@ -269,8 +269,8 @@ describe(':echo :echon :echomsg :echoerr', function()
|
|||||||
it(
|
it(
|
||||||
'does not crash or halt when dumping partials with reference cycles in self and arguments',
|
'does not crash or halt when dumping partials with reference cycles in self and arguments',
|
||||||
function()
|
function()
|
||||||
meths.set_var('d', { v = true })
|
meths.nvim_set_var('d', { v = true })
|
||||||
meths.set_var('l', {})
|
meths.nvim_set_var('l', {})
|
||||||
eval('add(l, l)')
|
eval('add(l, l)')
|
||||||
eval('add(l, function("Test1", l))')
|
eval('add(l, function("Test1", l))')
|
||||||
eval('add(l, function("Test1", d))')
|
eval('add(l, function("Test1", d))')
|
||||||
@@ -305,13 +305,13 @@ describe(':echo :echon :echomsg :echoerr', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('does not error when dumping recursive lists', function()
|
it('does not error when dumping recursive lists', function()
|
||||||
meths.set_var('l', {})
|
meths.nvim_set_var('l', {})
|
||||||
eval('add(l, l)')
|
eval('add(l, l)')
|
||||||
eq(0, exc_exec('echo String(l)'))
|
eq(0, exc_exec('echo String(l)'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('dumps recursive lists without error', function()
|
it('dumps recursive lists without error', function()
|
||||||
meths.set_var('l', {})
|
meths.nvim_set_var('l', {})
|
||||||
eval('add(l, l)')
|
eval('add(l, l)')
|
||||||
eq('[[...@0]]', exec_capture('echo String(l)'))
|
eq('[[...@0]]', exec_capture('echo String(l)'))
|
||||||
eq('[[[...@1]]]', exec_capture('echo String([l])'))
|
eq('[[[...@1]]]', exec_capture('echo String([l])'))
|
||||||
@@ -335,13 +335,13 @@ describe(':echo :echon :echomsg :echoerr', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('does not error when dumping recursive dictionaries', function()
|
it('does not error when dumping recursive dictionaries', function()
|
||||||
meths.set_var('d', { d = 1 })
|
meths.nvim_set_var('d', { d = 1 })
|
||||||
eval('extend(d, {"d": d})')
|
eval('extend(d, {"d": d})')
|
||||||
eq(0, exc_exec('echo String(d)'))
|
eq(0, exc_exec('echo String(d)'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('dumps recursive dictionaries without the error', function()
|
it('dumps recursive dictionaries without the error', function()
|
||||||
meths.set_var('d', { d = 1 })
|
meths.nvim_set_var('d', { d = 1 })
|
||||||
eval('extend(d, {"d": d})')
|
eval('extend(d, {"d": d})')
|
||||||
eq("{'d': {...@0}}", exec_capture('echo String(d)'))
|
eq("{'d': {...@0}}", exec_capture('echo String(d)'))
|
||||||
eq("{'out': {'d': {...@1}}}", exec_capture('echo String({"out": d})'))
|
eq("{'out': {'d': {...@1}}}", exec_capture('echo String({"out": d})'))
|
||||||
|
@@ -40,6 +40,6 @@ describe(':help', function()
|
|||||||
command('helptags Xhelptags/doc')
|
command('helptags Xhelptags/doc')
|
||||||
command('set rtp+=Xhelptags')
|
command('set rtp+=Xhelptags')
|
||||||
command('help …')
|
command('help …')
|
||||||
eq('*…*', meths.get_current_line())
|
eq('*…*', meths.nvim_get_current_line())
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
@@ -53,11 +53,11 @@ describe(':highlight', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('clear', function()
|
it('clear', function()
|
||||||
meths.set_var('colors_name', 'foo')
|
meths.nvim_set_var('colors_name', 'foo')
|
||||||
eq(1, funcs.exists('g:colors_name'))
|
eq(1, funcs.exists('g:colors_name'))
|
||||||
command('hi clear')
|
command('hi clear')
|
||||||
eq(0, funcs.exists('g:colors_name'))
|
eq(0, funcs.exists('g:colors_name'))
|
||||||
meths.set_var('colors_name', 'foo')
|
meths.nvim_set_var('colors_name', 'foo')
|
||||||
eq(1, funcs.exists('g:colors_name'))
|
eq(1, funcs.exists('g:colors_name'))
|
||||||
exec([[
|
exec([[
|
||||||
func HiClear()
|
func HiClear()
|
||||||
|
@@ -16,13 +16,13 @@ describe(':*map', function()
|
|||||||
before_each(clear)
|
before_each(clear)
|
||||||
|
|
||||||
it('are not affected by &isident', function()
|
it('are not affected by &isident', function()
|
||||||
meths.set_var('counter', 0)
|
meths.nvim_set_var('counter', 0)
|
||||||
command('nnoremap <C-x> :let counter+=1<CR>')
|
command('nnoremap <C-x> :let counter+=1<CR>')
|
||||||
meths.set_option_value('isident', ('%u'):format(('>'):byte()), {})
|
meths.nvim_set_option_value('isident', ('%u'):format(('>'):byte()), {})
|
||||||
command('nnoremap <C-y> :let counter+=1<CR>')
|
command('nnoremap <C-y> :let counter+=1<CR>')
|
||||||
-- &isident used to disable keycode parsing here as well
|
-- &isident used to disable keycode parsing here as well
|
||||||
feed('\24\25<C-x><C-y>')
|
feed('\24\25<C-x><C-y>')
|
||||||
eq(4, meths.get_var('counter'))
|
eq(4, meths.nvim_get_var('counter'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it(':imap <M-">', function()
|
it(':imap <M-">', function()
|
||||||
@@ -42,9 +42,9 @@ n asdf <Nop>]],
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('mappings with description can be filtered', function()
|
it('mappings with description can be filtered', function()
|
||||||
meths.set_keymap('n', 'asdf1', 'qwert', { desc = 'do the one thing' })
|
meths.nvim_set_keymap('n', 'asdf1', 'qwert', { desc = 'do the one thing' })
|
||||||
meths.set_keymap('n', 'asdf2', 'qwert', { desc = 'doesnot really do anything' })
|
meths.nvim_set_keymap('n', 'asdf2', 'qwert', { desc = 'doesnot really do anything' })
|
||||||
meths.set_keymap('n', 'asdf3', 'qwert', { desc = 'do the other thing' })
|
meths.nvim_set_keymap('n', 'asdf3', 'qwert', { desc = 'do the other thing' })
|
||||||
eq(
|
eq(
|
||||||
[[
|
[[
|
||||||
|
|
||||||
@@ -58,21 +58,21 @@ n asdf1 qwert
|
|||||||
|
|
||||||
it('<Plug> mappings ignore nore', function()
|
it('<Plug> mappings ignore nore', function()
|
||||||
command('let x = 0')
|
command('let x = 0')
|
||||||
eq(0, meths.eval('x'))
|
eq(0, meths.nvim_eval('x'))
|
||||||
command [[
|
command [[
|
||||||
nnoremap <Plug>(Increase_x) <cmd>let x+=1<cr>
|
nnoremap <Plug>(Increase_x) <cmd>let x+=1<cr>
|
||||||
nmap increase_x_remap <Plug>(Increase_x)
|
nmap increase_x_remap <Plug>(Increase_x)
|
||||||
nnoremap increase_x_noremap <Plug>(Increase_x)
|
nnoremap increase_x_noremap <Plug>(Increase_x)
|
||||||
]]
|
]]
|
||||||
feed('increase_x_remap')
|
feed('increase_x_remap')
|
||||||
eq(1, meths.eval('x'))
|
eq(1, meths.nvim_eval('x'))
|
||||||
feed('increase_x_noremap')
|
feed('increase_x_noremap')
|
||||||
eq(2, meths.eval('x'))
|
eq(2, meths.nvim_eval('x'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("Doesn't auto ignore nore for keys before or after <Plug> mapping", function()
|
it("Doesn't auto ignore nore for keys before or after <Plug> mapping", function()
|
||||||
command('let x = 0')
|
command('let x = 0')
|
||||||
eq(0, meths.eval('x'))
|
eq(0, meths.nvim_eval('x'))
|
||||||
command [[
|
command [[
|
||||||
nnoremap x <nop>
|
nnoremap x <nop>
|
||||||
nnoremap <Plug>(Increase_x) <cmd>let x+=1<cr>
|
nnoremap <Plug>(Increase_x) <cmd>let x+=1<cr>
|
||||||
@@ -83,10 +83,10 @@ n asdf1 qwert
|
|||||||
eq('Some text', eval("getline('.')"))
|
eq('Some text', eval("getline('.')"))
|
||||||
|
|
||||||
feed('increase_x_remap')
|
feed('increase_x_remap')
|
||||||
eq(1, meths.eval('x'))
|
eq(1, meths.nvim_eval('x'))
|
||||||
eq('Some text', eval("getline('.')"))
|
eq('Some text', eval("getline('.')"))
|
||||||
feed('increase_x_noremap')
|
feed('increase_x_noremap')
|
||||||
eq(2, meths.eval('x'))
|
eq(2, meths.nvim_eval('x'))
|
||||||
eq('Some te', eval("getline('.')"))
|
eq('Some te', eval("getline('.')"))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@@ -70,7 +70,7 @@ describe(':mksession', function()
|
|||||||
-- Restore session.
|
-- Restore session.
|
||||||
command('source ' .. session_file)
|
command('source ' .. session_file)
|
||||||
|
|
||||||
eq(expected_buf_count, #meths.list_bufs())
|
eq(expected_buf_count, #meths.nvim_list_bufs())
|
||||||
end
|
end
|
||||||
|
|
||||||
it(
|
it(
|
||||||
@@ -80,28 +80,28 @@ describe(':mksession', function()
|
|||||||
command('edit ' .. tmpfile_base)
|
command('edit ' .. tmpfile_base)
|
||||||
command('terminal')
|
command('terminal')
|
||||||
|
|
||||||
local buf_count = #meths.list_bufs()
|
local buf_count = #meths.nvim_list_bufs()
|
||||||
eq(2, buf_count)
|
eq(2, buf_count)
|
||||||
|
|
||||||
eq('terminal', meths.get_option_value('buftype', {}))
|
eq('terminal', meths.nvim_get_option_value('buftype', {}))
|
||||||
|
|
||||||
test_terminal_session_disabled(2)
|
test_terminal_session_disabled(2)
|
||||||
|
|
||||||
-- no terminal should be set. As a side effect we end up with a blank buffer
|
-- no terminal should be set. As a side effect we end up with a blank buffer
|
||||||
eq('', meths.get_option_value('buftype', { buf = meths.list_bufs()[1] }))
|
eq('', meths.nvim_get_option_value('buftype', { buf = meths.nvim_list_bufs()[1] }))
|
||||||
eq('', meths.get_option_value('buftype', { buf = meths.list_bufs()[2] }))
|
eq('', meths.nvim_get_option_value('buftype', { buf = meths.nvim_list_bufs()[2] }))
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
||||||
it('do not restore :terminal if not set in sessionoptions, terminal hidden #13078', function()
|
it('do not restore :terminal if not set in sessionoptions, terminal hidden #13078', function()
|
||||||
command('terminal')
|
command('terminal')
|
||||||
local terminal_bufnr = meths.get_current_buf()
|
local terminal_bufnr = meths.nvim_get_current_buf()
|
||||||
|
|
||||||
local tmpfile_base = file_prefix .. '-tmpfile'
|
local tmpfile_base = file_prefix .. '-tmpfile'
|
||||||
-- make terminal hidden by opening a new file
|
-- make terminal hidden by opening a new file
|
||||||
command('edit ' .. tmpfile_base .. '1')
|
command('edit ' .. tmpfile_base .. '1')
|
||||||
|
|
||||||
local buf_count = #meths.list_bufs()
|
local buf_count = #meths.nvim_list_bufs()
|
||||||
eq(2, buf_count)
|
eq(2, buf_count)
|
||||||
|
|
||||||
eq(1, funcs.getbufinfo(terminal_bufnr)[1].hidden)
|
eq(1, funcs.getbufinfo(terminal_bufnr)[1].hidden)
|
||||||
@@ -109,20 +109,20 @@ describe(':mksession', function()
|
|||||||
test_terminal_session_disabled(1)
|
test_terminal_session_disabled(1)
|
||||||
|
|
||||||
-- no terminal should exist here
|
-- no terminal should exist here
|
||||||
neq('', meths.buf_get_name(meths.list_bufs()[1]))
|
neq('', meths.nvim_buf_get_name(meths.nvim_list_bufs()[1]))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('do not restore :terminal if not set in sessionoptions, only buffer #13078', function()
|
it('do not restore :terminal if not set in sessionoptions, only buffer #13078', function()
|
||||||
command('terminal')
|
command('terminal')
|
||||||
eq('terminal', meths.get_option_value('buftype', {}))
|
eq('terminal', meths.nvim_get_option_value('buftype', {}))
|
||||||
|
|
||||||
local buf_count = #meths.list_bufs()
|
local buf_count = #meths.nvim_list_bufs()
|
||||||
eq(1, buf_count)
|
eq(1, buf_count)
|
||||||
|
|
||||||
test_terminal_session_disabled(1)
|
test_terminal_session_disabled(1)
|
||||||
|
|
||||||
-- no terminal should be set
|
-- no terminal should be set
|
||||||
eq('', meths.get_option_value('buftype', {}))
|
eq('', meths.nvim_get_option_value('buftype', {}))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('restores tab-local working directories', function()
|
it('restores tab-local working directories', function()
|
||||||
@@ -238,7 +238,7 @@ describe(':mksession', function()
|
|||||||
local tmpfile = file_prefix .. '-tmpfile-float'
|
local tmpfile = file_prefix .. '-tmpfile-float'
|
||||||
|
|
||||||
command('edit ' .. tmpfile)
|
command('edit ' .. tmpfile)
|
||||||
local buf = meths.create_buf(false, true)
|
local buf = meths.nvim_create_buf(false, true)
|
||||||
local config = {
|
local config = {
|
||||||
relative = 'editor',
|
relative = 'editor',
|
||||||
focusable = false,
|
focusable = false,
|
||||||
@@ -248,8 +248,8 @@ describe(':mksession', function()
|
|||||||
col = 1,
|
col = 1,
|
||||||
style = 'minimal',
|
style = 'minimal',
|
||||||
}
|
}
|
||||||
meths.open_win(buf, false, config)
|
meths.nvim_open_win(buf, false, config)
|
||||||
local cmdheight = meths.get_option_value('cmdheight', {})
|
local cmdheight = meths.nvim_get_option_value('cmdheight', {})
|
||||||
command('mksession ' .. session_file)
|
command('mksession ' .. session_file)
|
||||||
|
|
||||||
-- Create a new test instance of Nvim.
|
-- Create a new test instance of Nvim.
|
||||||
@@ -262,7 +262,7 @@ describe(':mksession', function()
|
|||||||
-- window was not restored.
|
-- window was not restored.
|
||||||
eq(1, funcs.winnr('$'))
|
eq(1, funcs.winnr('$'))
|
||||||
-- The command-line height should remain the same as it was.
|
-- The command-line height should remain the same as it was.
|
||||||
eq(cmdheight, meths.get_option_value('cmdheight', {}))
|
eq(cmdheight, meths.nvim_get_option_value('cmdheight', {}))
|
||||||
|
|
||||||
os.remove(tmpfile)
|
os.remove(tmpfile)
|
||||||
end)
|
end)
|
||||||
|
@@ -42,7 +42,7 @@ describe(':oldfiles', function()
|
|||||||
feed_command('edit testfile2')
|
feed_command('edit testfile2')
|
||||||
feed_command('wshada')
|
feed_command('wshada')
|
||||||
feed_command('rshada!')
|
feed_command('rshada!')
|
||||||
local oldfiles = helpers.meths.get_vvar('oldfiles')
|
local oldfiles = helpers.meths.nvim_get_vvar('oldfiles')
|
||||||
feed_command('oldfiles')
|
feed_command('oldfiles')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
|
|
|
|
||||||
@@ -108,7 +108,7 @@ describe(':browse oldfiles', function()
|
|||||||
-- Ensure v:oldfiles isn't busted. Since things happen so fast,
|
-- Ensure v:oldfiles isn't busted. Since things happen so fast,
|
||||||
-- the ordering of v:oldfiles is unstable (it uses qsort() under-the-hood).
|
-- the ordering of v:oldfiles is unstable (it uses qsort() under-the-hood).
|
||||||
-- Let's verify the contents and the length of v:oldfiles before moving on.
|
-- Let's verify the contents and the length of v:oldfiles before moving on.
|
||||||
oldfiles = helpers.meths.get_vvar('oldfiles')
|
oldfiles = helpers.meths.nvim_get_vvar('oldfiles')
|
||||||
eq(2, #oldfiles)
|
eq(2, #oldfiles)
|
||||||
ok(filename == oldfiles[1] or filename == oldfiles[2])
|
ok(filename == oldfiles[1] or filename == oldfiles[2])
|
||||||
ok(filename2 == oldfiles[1] or filename2 == oldfiles[2])
|
ok(filename2 == oldfiles[1] or filename2 == oldfiles[2])
|
||||||
|
@@ -83,7 +83,7 @@ describe('script_get-based command', function()
|
|||||||
]])):format(cmd, garbage)
|
]])):format(cmd, garbage)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
neq(0, meths.get_var('exc'))
|
neq(0, meths.nvim_get_var('exc'))
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
@@ -49,7 +49,7 @@ describe(':source', function()
|
|||||||
pending("'shellslash' only works on Windows")
|
pending("'shellslash' only works on Windows")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
meths.set_option_value('shellslash', false, {})
|
meths.nvim_set_option_value('shellslash', false, {})
|
||||||
mkdir('Xshellslash')
|
mkdir('Xshellslash')
|
||||||
|
|
||||||
write_file(
|
write_file(
|
||||||
@@ -65,9 +65,9 @@ describe(':source', function()
|
|||||||
|
|
||||||
for _ = 1, 2 do
|
for _ = 1, 2 do
|
||||||
command([[source Xshellslash/Xstack.vim]])
|
command([[source Xshellslash/Xstack.vim]])
|
||||||
matches([[Xshellslash\Xstack%.vim]], meths.get_var('stack1'))
|
matches([[Xshellslash\Xstack%.vim]], meths.nvim_get_var('stack1'))
|
||||||
matches([[Xshellslash/Xstack%.vim]], meths.get_var('stack2'))
|
matches([[Xshellslash/Xstack%.vim]], meths.nvim_get_var('stack2'))
|
||||||
matches([[Xshellslash\Xstack%.vim]], meths.get_var('stack3'))
|
matches([[Xshellslash\Xstack%.vim]], meths.nvim_get_var('stack3'))
|
||||||
end
|
end
|
||||||
|
|
||||||
write_file(
|
write_file(
|
||||||
@@ -83,9 +83,9 @@ describe(':source', function()
|
|||||||
|
|
||||||
for _ = 1, 2 do
|
for _ = 1, 2 do
|
||||||
command([[source Xshellslash/Xstack.lua]])
|
command([[source Xshellslash/Xstack.lua]])
|
||||||
matches([[Xshellslash\Xstack%.lua]], meths.get_var('stack1'))
|
matches([[Xshellslash\Xstack%.lua]], meths.nvim_get_var('stack1'))
|
||||||
matches([[Xshellslash/Xstack%.lua]], meths.get_var('stack2'))
|
matches([[Xshellslash/Xstack%.lua]], meths.nvim_get_var('stack2'))
|
||||||
matches([[Xshellslash\Xstack%.lua]], meths.get_var('stack3'))
|
matches([[Xshellslash\Xstack%.lua]], meths.nvim_get_var('stack3'))
|
||||||
end
|
end
|
||||||
|
|
||||||
rmdir('Xshellslash')
|
rmdir('Xshellslash')
|
||||||
@@ -182,9 +182,9 @@ describe(':source', function()
|
|||||||
command('set shellslash')
|
command('set shellslash')
|
||||||
command('source ' .. test_file)
|
command('source ' .. test_file)
|
||||||
eq(1, eval('g:sourced_lua'))
|
eq(1, eval('g:sourced_lua'))
|
||||||
matches([[/test%.lua$]], meths.get_var('sfile_value'))
|
matches([[/test%.lua$]], meths.nvim_get_var('sfile_value'))
|
||||||
matches([[/test%.lua$]], meths.get_var('stack_value'))
|
matches([[/test%.lua$]], meths.nvim_get_var('stack_value'))
|
||||||
matches([[/test%.lua$]], meths.get_var('script_value'))
|
matches([[/test%.lua$]], meths.nvim_get_var('script_value'))
|
||||||
|
|
||||||
os.remove(test_file)
|
os.remove(test_file)
|
||||||
end)
|
end)
|
||||||
@@ -229,9 +229,9 @@ describe(':source', function()
|
|||||||
|
|
||||||
eq(12, eval('g:c'))
|
eq(12, eval('g:c'))
|
||||||
eq(' \\ 1\n "\\ 2', exec_lua('return _G.a'))
|
eq(' \\ 1\n "\\ 2', exec_lua('return _G.a'))
|
||||||
eq(':source (no file)', meths.get_var('sfile_value'))
|
eq(':source (no file)', meths.nvim_get_var('sfile_value'))
|
||||||
eq(':source (no file)', meths.get_var('stack_value'))
|
eq(':source (no file)', meths.nvim_get_var('stack_value'))
|
||||||
eq(':source (no file)', meths.get_var('script_value'))
|
eq(':source (no file)', meths.nvim_get_var('script_value'))
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@@ -438,7 +438,7 @@ describe('quitting swapfile dialog on startup stops TUI properly', function()
|
|||||||
feed('Gisometext<esc>')
|
feed('Gisometext<esc>')
|
||||||
poke_eventloop()
|
poke_eventloop()
|
||||||
clear() -- Leaves a swap file behind
|
clear() -- Leaves a swap file behind
|
||||||
meths.ui_attach(80, 30, {})
|
meths.nvim_ui_attach(80, 30, {})
|
||||||
end)
|
end)
|
||||||
after_each(function()
|
after_each(function()
|
||||||
rmdir(swapdir)
|
rmdir(swapdir)
|
||||||
@@ -459,7 +459,7 @@ describe('quitting swapfile dialog on startup stops TUI properly', function()
|
|||||||
eval("getline('$')->trim(' ', 2)")
|
eval("getline('$')->trim(' ', 2)")
|
||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
meths.chan_send(chan, 'q')
|
meths.nvim_chan_send(chan, 'q')
|
||||||
retry(nil, nil, function()
|
retry(nil, nil, function()
|
||||||
eq(
|
eq(
|
||||||
{ '', '[Process exited 1]', '' },
|
{ '', '[Process exited 1]', '' },
|
||||||
@@ -491,7 +491,7 @@ describe('quitting swapfile dialog on startup stops TUI properly', function()
|
|||||||
eval("getline('$')->trim(' ', 2)")
|
eval("getline('$')->trim(' ', 2)")
|
||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
meths.chan_send(chan, 'a')
|
meths.nvim_chan_send(chan, 'a')
|
||||||
retry(nil, nil, function()
|
retry(nil, nil, function()
|
||||||
eq(
|
eq(
|
||||||
{ '', '[Process exited 1]', '' },
|
{ '', '[Process exited 1]', '' },
|
||||||
@@ -531,11 +531,11 @@ describe('quitting swapfile dialog on startup stops TUI properly', function()
|
|||||||
eval("getline('$')->trim(' ', 2)")
|
eval("getline('$')->trim(' ', 2)")
|
||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
meths.chan_send(chan, 'q')
|
meths.nvim_chan_send(chan, 'q')
|
||||||
retry(nil, nil, function()
|
retry(nil, nil, function()
|
||||||
eq('Press ENTER or type command to continue', eval("getline('$')->trim(' ', 2)"))
|
eq('Press ENTER or type command to continue', eval("getline('$')->trim(' ', 2)"))
|
||||||
end)
|
end)
|
||||||
meths.chan_send(chan, '\r')
|
meths.nvim_chan_send(chan, '\r')
|
||||||
retry(nil, nil, function()
|
retry(nil, nil, function()
|
||||||
eq(
|
eq(
|
||||||
{ '', '[Process exited 1]', '' },
|
{ '', '[Process exited 1]', '' },
|
||||||
|
@@ -5,7 +5,7 @@ local eq = helpers.eq
|
|||||||
local exec = helpers.exec
|
local exec = helpers.exec
|
||||||
local exec_capture = helpers.exec_capture
|
local exec_capture = helpers.exec_capture
|
||||||
local write_file = helpers.write_file
|
local write_file = helpers.write_file
|
||||||
local call_viml_function = helpers.meths.call_function
|
local call_viml_function = helpers.meths.nvim_call_function
|
||||||
|
|
||||||
local function last_set_tests(cmd)
|
local function last_set_tests(cmd)
|
||||||
local script_location, script_file
|
local script_location, script_file
|
||||||
|
@@ -133,17 +133,17 @@ describe(':write', function()
|
|||||||
pcall_err(command, 'write .')
|
pcall_err(command, 'write .')
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
meths.set_option_value('writeany', true, {})
|
meths.nvim_set_option_value('writeany', true, {})
|
||||||
-- Message from buf_write
|
-- Message from buf_write
|
||||||
eq('Vim(write):E502: "." is a directory', pcall_err(command, 'write .'))
|
eq('Vim(write):E502: "." is a directory', pcall_err(command, 'write .'))
|
||||||
funcs.mkdir(fname_bak)
|
funcs.mkdir(fname_bak)
|
||||||
meths.set_option_value('backupdir', '.', {})
|
meths.nvim_set_option_value('backupdir', '.', {})
|
||||||
meths.set_option_value('backup', true, {})
|
meths.nvim_set_option_value('backup', true, {})
|
||||||
write_file(fname, 'content0')
|
write_file(fname, 'content0')
|
||||||
command('edit ' .. fname)
|
command('edit ' .. fname)
|
||||||
funcs.setline(1, 'TTY')
|
funcs.setline(1, 'TTY')
|
||||||
eq("Vim(write):E510: Can't make backup file (add ! to override)", pcall_err(command, 'write'))
|
eq("Vim(write):E510: Can't make backup file (add ! to override)", pcall_err(command, 'write'))
|
||||||
meths.set_option_value('backup', false, {})
|
meths.nvim_set_option_value('backup', false, {})
|
||||||
funcs.setfperm(fname, 'r--------')
|
funcs.setfperm(fname, 'r--------')
|
||||||
eq(
|
eq(
|
||||||
'Vim(write):E505: "Xtest-functional-ex_cmds-write" is read-only (add ! to override)',
|
'Vim(write):E505: "Xtest-functional-ex_cmds-write" is read-only (add ! to override)',
|
||||||
|
@@ -631,6 +631,9 @@ module.uimeths = module.create_callindex(ui)
|
|||||||
local function create_api(request, call)
|
local function create_api(request, call)
|
||||||
local m = {}
|
local m = {}
|
||||||
function m.nvim(method, ...)
|
function m.nvim(method, ...)
|
||||||
|
if vim.startswith(method, 'nvim_') then
|
||||||
|
return request(method, ...)
|
||||||
|
end
|
||||||
return request('nvim_' .. method, ...)
|
return request('nvim_' .. method, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -700,6 +703,9 @@ module.describe_lua_and_rpc = function(describe)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- add for typing. The for loop after will overwrite this
|
||||||
|
module.meths = vim.api
|
||||||
|
|
||||||
for name, fn in pairs(module.rpc.api) do
|
for name, fn in pairs(module.rpc.api) do
|
||||||
module[name] = fn
|
module[name] = fn
|
||||||
end
|
end
|
||||||
@@ -862,11 +868,11 @@ function module.skip_fragile(pending_fn, cond)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function module.exec(code)
|
function module.exec(code)
|
||||||
module.meths.exec2(code, {})
|
module.meths.nvim_exec2(code, {})
|
||||||
end
|
end
|
||||||
|
|
||||||
function module.exec_capture(code)
|
function module.exec_capture(code)
|
||||||
return module.meths.exec2(code, { output = true }).output
|
return module.meths.nvim_exec2(code, { output = true }).output
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param code string
|
--- @param code string
|
||||||
|
@@ -56,9 +56,9 @@ describe("'directory' option", function()
|
|||||||
line 3 Abcdefghij
|
line 3 Abcdefghij
|
||||||
end of testfile]])
|
end of testfile]])
|
||||||
|
|
||||||
meths.set_option_value('swapfile', true, {})
|
meths.nvim_set_option_value('swapfile', true, {})
|
||||||
meths.set_option_value('swapfile', true, {})
|
meths.nvim_set_option_value('swapfile', true, {})
|
||||||
meths.set_option_value('directory', '.', {})
|
meths.nvim_set_option_value('directory', '.', {})
|
||||||
|
|
||||||
-- sanity check: files should not exist yet.
|
-- sanity check: files should not exist yet.
|
||||||
eq(nil, vim.uv.fs_stat('.Xtest1.swp'))
|
eq(nil, vim.uv.fs_stat('.Xtest1.swp'))
|
||||||
@@ -70,7 +70,7 @@ describe("'directory' option", function()
|
|||||||
-- reading the output from :!ls.
|
-- reading the output from :!ls.
|
||||||
neq(nil, vim.uv.fs_stat('.Xtest1.swp'))
|
neq(nil, vim.uv.fs_stat('.Xtest1.swp'))
|
||||||
|
|
||||||
meths.set_option_value('directory', './Xtest2,.', {})
|
meths.nvim_set_option_value('directory', './Xtest2,.', {})
|
||||||
command('edit Xtest1')
|
command('edit Xtest1')
|
||||||
poke_eventloop()
|
poke_eventloop()
|
||||||
|
|
||||||
@@ -79,10 +79,10 @@ describe("'directory' option", function()
|
|||||||
|
|
||||||
eq({ 'Xtest1.swp', 'Xtest3' }, ls_dir_sorted('Xtest2'))
|
eq({ 'Xtest1.swp', 'Xtest3' }, ls_dir_sorted('Xtest2'))
|
||||||
|
|
||||||
meths.set_option_value('directory', 'Xtest.je', {})
|
meths.nvim_set_option_value('directory', 'Xtest.je', {})
|
||||||
command('bdelete')
|
command('bdelete')
|
||||||
command('edit Xtest2/Xtest3')
|
command('edit Xtest2/Xtest3')
|
||||||
eq(true, meths.get_option_value('swapfile', {}))
|
eq(true, meths.nvim_get_option_value('swapfile', {}))
|
||||||
poke_eventloop()
|
poke_eventloop()
|
||||||
|
|
||||||
eq({ 'Xtest3' }, ls_dir_sorted('Xtest2'))
|
eq({ 'Xtest3' }, ls_dir_sorted('Xtest2'))
|
||||||
|
@@ -204,7 +204,7 @@ describe('Visual block mode', function()
|
|||||||
feed('G2l')
|
feed('G2l')
|
||||||
feed('2k<C-v>$gj<ESC>')
|
feed('2k<C-v>$gj<ESC>')
|
||||||
feed_command([[let cpos=getpos("'>")]])
|
feed_command([[let cpos=getpos("'>")]])
|
||||||
local cpos = nvim.get_var('cpos')
|
local cpos = nvim.nvim_get_var('cpos')
|
||||||
local expected = {
|
local expected = {
|
||||||
col = 4,
|
col = 4,
|
||||||
off = 0,
|
off = 0,
|
||||||
|
@@ -6,11 +6,11 @@ local exc_exec = helpers.exc_exec
|
|||||||
local eval = helpers.eval
|
local eval = helpers.eval
|
||||||
|
|
||||||
local function expected_errors(errors)
|
local function expected_errors(errors)
|
||||||
eq(errors, nvim.get_vvar('errors'))
|
eq(errors, nvim.nvim_get_vvar('errors'))
|
||||||
end
|
end
|
||||||
|
|
||||||
local function expected_empty()
|
local function expected_empty()
|
||||||
eq({}, nvim.get_vvar('errors'))
|
eq({}, nvim.nvim_get_vvar('errors'))
|
||||||
end
|
end
|
||||||
|
|
||||||
describe('assert function:', function()
|
describe('assert function:', function()
|
||||||
|
@@ -5,7 +5,7 @@ local source, exec_capture = helpers.source, helpers.exec_capture
|
|||||||
local mkdir = helpers.mkdir
|
local mkdir = helpers.mkdir
|
||||||
|
|
||||||
local function expected_empty()
|
local function expected_empty()
|
||||||
eq({}, meths.get_vvar('errors'))
|
eq({}, meths.nvim_get_vvar('errors'))
|
||||||
end
|
end
|
||||||
|
|
||||||
describe('autochdir behavior', function()
|
describe('autochdir behavior', function()
|
||||||
|
@@ -38,7 +38,7 @@ local function init_var()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function get_result()
|
local function get_result()
|
||||||
local ret = nvim.get_var('ret')
|
local ret = nvim.nvim_get_var('ret')
|
||||||
init_var()
|
init_var()
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
@@ -696,24 +696,24 @@ describe('au OptionSet', function()
|
|||||||
it('should trigger if a boolean option be set globally', function()
|
it('should trigger if a boolean option be set globally', function()
|
||||||
set_hook('autochdir')
|
set_hook('autochdir')
|
||||||
|
|
||||||
nvim.set_option_value('autochdir', true, { scope = 'global' })
|
nvim.nvim_set_option_value('autochdir', true, { scope = 'global' })
|
||||||
eq(true, nvim.get_option_value('autochdir', { scope = 'global' }))
|
eq(true, nvim.nvim_get_option_value('autochdir', { scope = 'global' }))
|
||||||
expected_combination({ 'autochdir', false, '', false, true, 'global', 'setglobal' })
|
expected_combination({ 'autochdir', false, '', false, true, 'global', 'setglobal' })
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('should trigger if a number option be set globally', function()
|
it('should trigger if a number option be set globally', function()
|
||||||
set_hook('cmdheight')
|
set_hook('cmdheight')
|
||||||
|
|
||||||
nvim.set_option_value('cmdheight', 5, { scope = 'global' })
|
nvim.nvim_set_option_value('cmdheight', 5, { scope = 'global' })
|
||||||
eq(5, nvim.get_option_value('cmdheight', { scope = 'global' }))
|
eq(5, nvim.nvim_get_option_value('cmdheight', { scope = 'global' }))
|
||||||
expected_combination({ 'cmdheight', 1, '', 1, 5, 'global', 'setglobal' })
|
expected_combination({ 'cmdheight', 1, '', 1, 5, 'global', 'setglobal' })
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('should trigger if a string option be set globally', function()
|
it('should trigger if a string option be set globally', function()
|
||||||
set_hook('ambiwidth')
|
set_hook('ambiwidth')
|
||||||
|
|
||||||
nvim.set_option_value('ambiwidth', 'double', { scope = 'global' })
|
nvim.nvim_set_option_value('ambiwidth', 'double', { scope = 'global' })
|
||||||
eq('double', nvim.get_option_value('ambiwidth', { scope = 'global' }))
|
eq('double', nvim.nvim_get_option_value('ambiwidth', { scope = 'global' }))
|
||||||
expected_combination({
|
expected_combination({
|
||||||
'ambiwidth',
|
'ambiwidth',
|
||||||
'single',
|
'single',
|
||||||
|
@@ -3,14 +3,14 @@ local clear, source = helpers.clear, helpers.source
|
|||||||
local call, eq, meths = helpers.call, helpers.eq, helpers.meths
|
local call, eq, meths = helpers.call, helpers.eq, helpers.meths
|
||||||
|
|
||||||
local function expected_empty()
|
local function expected_empty()
|
||||||
eq({}, meths.get_vvar('errors'))
|
eq({}, meths.nvim_get_vvar('errors'))
|
||||||
end
|
end
|
||||||
|
|
||||||
describe('buffer', function()
|
describe('buffer', function()
|
||||||
before_each(function()
|
before_each(function()
|
||||||
clear()
|
clear()
|
||||||
meths.ui_attach(80, 24, {})
|
meths.nvim_ui_attach(80, 24, {})
|
||||||
meths.set_option_value('hidden', false, {})
|
meths.nvim_set_option_value('hidden', false, {})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('deleting a modified buffer with :confirm', function()
|
it('deleting a modified buffer with :confirm', function()
|
||||||
|
@@ -198,9 +198,9 @@ describe('cmdline', function()
|
|||||||
[3] = { reverse = true }, -- TabLineFill
|
[3] = { reverse = true }, -- TabLineFill
|
||||||
})
|
})
|
||||||
screen:attach()
|
screen:attach()
|
||||||
meths.set_option_value('laststatus', 2, {})
|
meths.nvim_set_option_value('laststatus', 2, {})
|
||||||
meths.set_option_value('showtabline', 2, {})
|
meths.nvim_set_option_value('showtabline', 2, {})
|
||||||
meths.set_option_value('cmdheight', 1, {})
|
meths.nvim_set_option_value('cmdheight', 1, {})
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{2: [No Name] }{3: }|
|
{2: [No Name] }{3: }|
|
||||||
^ |
|
^ |
|
||||||
@@ -217,10 +217,10 @@ describe('cmdline', function()
|
|||||||
[0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText
|
[0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText
|
||||||
}
|
}
|
||||||
screen:attach()
|
screen:attach()
|
||||||
meths.set_option_value('ruler', true, {})
|
meths.nvim_set_option_value('ruler', true, {})
|
||||||
meths.set_option_value('rulerformat', 'longish', {})
|
meths.nvim_set_option_value('rulerformat', 'longish', {})
|
||||||
meths.set_option_value('laststatus', 0, {})
|
meths.nvim_set_option_value('laststatus', 0, {})
|
||||||
meths.set_option_value('winwidth', 1, {})
|
meths.nvim_set_option_value('winwidth', 1, {})
|
||||||
feed [[<C-W>v<C-W>|<C-W>p]]
|
feed [[<C-W>v<C-W>|<C-W>p]]
|
||||||
screen:expect [[
|
screen:expect [[
|
||||||
│^ |
|
│^ |
|
||||||
|
@@ -16,7 +16,7 @@ describe('Ex mode', function()
|
|||||||
feed('gQ' .. cmd .. '<C-b>"<CR>')
|
feed('gQ' .. cmd .. '<C-b>"<CR>')
|
||||||
local ret = eval('@:[1:]') -- Remove leading quote.
|
local ret = eval('@:[1:]') -- Remove leading quote.
|
||||||
feed('visual<CR>')
|
feed('visual<CR>')
|
||||||
eq(meths.replace_termcodes(expected, true, true, true), ret)
|
eq(meths.nvim_replace_termcodes(expected, true, true, true), ret)
|
||||||
end
|
end
|
||||||
command('set sw=2')
|
command('set sw=2')
|
||||||
test_ex_edit('bar', 'foo bar<C-u>bar')
|
test_ex_edit('bar', 'foo bar<C-u>bar')
|
||||||
|
@@ -24,7 +24,7 @@ end
|
|||||||
describe('Ex command', function()
|
describe('Ex command', function()
|
||||||
before_each(clear)
|
before_each(clear)
|
||||||
after_each(function()
|
after_each(function()
|
||||||
eq({}, meths.get_vvar('errors'))
|
eq({}, meths.nvim_get_vvar('errors'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('checks for address line overflow', function()
|
it('checks for address line overflow', function()
|
||||||
|
@@ -5,15 +5,15 @@ local is_os = helpers.is_os
|
|||||||
local skip = helpers.skip
|
local skip = helpers.skip
|
||||||
|
|
||||||
local function expected_empty()
|
local function expected_empty()
|
||||||
eq({}, meths.get_vvar('errors'))
|
eq({}, meths.nvim_get_vvar('errors'))
|
||||||
end
|
end
|
||||||
|
|
||||||
describe('file changed dialog', function()
|
describe('file changed dialog', function()
|
||||||
before_each(function()
|
before_each(function()
|
||||||
clear()
|
clear()
|
||||||
meths.ui_attach(80, 24, {})
|
meths.nvim_ui_attach(80, 24, {})
|
||||||
meths.set_option_value('autoread', false, {})
|
meths.nvim_set_option_value('autoread', false, {})
|
||||||
meths.set_option_value('fsync', true, {})
|
meths.nvim_set_option_value('fsync', true, {})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('works', function()
|
it('works', function()
|
||||||
|
@@ -5,7 +5,7 @@ local clear, source = helpers.clear, helpers.source
|
|||||||
local call, eq, nvim = helpers.call, helpers.eq, helpers.meths
|
local call, eq, nvim = helpers.call, helpers.eq, helpers.meths
|
||||||
|
|
||||||
local function expected_empty()
|
local function expected_empty()
|
||||||
eq({}, nvim.get_vvar('errors'))
|
eq({}, nvim.nvim_get_vvar('errors'))
|
||||||
end
|
end
|
||||||
|
|
||||||
describe('filename modifiers', function()
|
describe('filename modifiers', function()
|
||||||
|
@@ -743,18 +743,18 @@ describe('Ctrl-A/Ctrl-X on visual selections', function()
|
|||||||
it('works on Test ' .. id, function()
|
it('works on Test ' .. id, function()
|
||||||
command('set nrformats&vi') -- &vi makes Vim compatible
|
command('set nrformats&vi') -- &vi makes Vim compatible
|
||||||
call('Test_visual_increment_' .. id)
|
call('Test_visual_increment_' .. id)
|
||||||
eq({}, nvim.get_vvar('errors'))
|
eq({}, nvim.nvim_get_vvar('errors'))
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
it('does not drop leading zeroes', function()
|
it('does not drop leading zeroes', function()
|
||||||
command('set nrformats&vi') -- &vi makes Vim compatible
|
command('set nrformats&vi') -- &vi makes Vim compatible
|
||||||
call('Test_normal_increment_01')
|
call('Test_normal_increment_01')
|
||||||
eq({}, nvim.get_vvar('errors'))
|
eq({}, nvim.nvim_get_vvar('errors'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('maintains correct column after CTRL-A', function()
|
it('maintains correct column after CTRL-A', function()
|
||||||
call('Test_normal_increment_02')
|
call('Test_normal_increment_02')
|
||||||
eq({}, nvim.get_vvar('errors'))
|
eq({}, nvim.nvim_get_vvar('errors'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
@@ -134,9 +134,9 @@ describe('mapping', function()
|
|||||||
|
|
||||||
command('nnoremap <LeftDrag> <LeftDrag><Cmd><CR>')
|
command('nnoremap <LeftDrag> <LeftDrag><Cmd><CR>')
|
||||||
poke_eventloop()
|
poke_eventloop()
|
||||||
meths.input_mouse('left', 'press', '', 0, 0, 0)
|
meths.nvim_input_mouse('left', 'press', '', 0, 0, 0)
|
||||||
poke_eventloop()
|
poke_eventloop()
|
||||||
meths.input_mouse('left', 'drag', '', 0, 0, 1)
|
meths.nvim_input_mouse('left', 'drag', '', 0, 0, 1)
|
||||||
poke_eventloop()
|
poke_eventloop()
|
||||||
eq('s', eval('mode()'))
|
eq('s', eval('mode()'))
|
||||||
end)
|
end)
|
||||||
@@ -147,9 +147,9 @@ describe('mapping', function()
|
|||||||
command('inoremap <LeftDrag> <LeftDrag><Cmd>let g:dragged = 1<CR>')
|
command('inoremap <LeftDrag> <LeftDrag><Cmd>let g:dragged = 1<CR>')
|
||||||
feed('i')
|
feed('i')
|
||||||
poke_eventloop()
|
poke_eventloop()
|
||||||
meths.input_mouse('left', 'press', '', 0, 0, 0)
|
meths.nvim_input_mouse('left', 'press', '', 0, 0, 0)
|
||||||
poke_eventloop()
|
poke_eventloop()
|
||||||
meths.input_mouse('left', 'drag', '', 0, 0, 1)
|
meths.nvim_input_mouse('left', 'drag', '', 0, 0, 1)
|
||||||
poke_eventloop()
|
poke_eventloop()
|
||||||
eq(1, eval('g:dragged'))
|
eq(1, eval('g:dragged'))
|
||||||
eq('v', eval('mode()'))
|
eq('v', eval('mode()'))
|
||||||
@@ -158,9 +158,9 @@ describe('mapping', function()
|
|||||||
command([[inoremap <LeftDrag> <LeftDrag><C-\><C-N>]])
|
command([[inoremap <LeftDrag> <LeftDrag><C-\><C-N>]])
|
||||||
feed('i')
|
feed('i')
|
||||||
poke_eventloop()
|
poke_eventloop()
|
||||||
meths.input_mouse('left', 'press', '', 0, 0, 0)
|
meths.nvim_input_mouse('left', 'press', '', 0, 0, 0)
|
||||||
poke_eventloop()
|
poke_eventloop()
|
||||||
meths.input_mouse('left', 'drag', '', 0, 0, 1)
|
meths.nvim_input_mouse('left', 'drag', '', 0, 0, 1)
|
||||||
poke_eventloop()
|
poke_eventloop()
|
||||||
eq('n', eval('mode()'))
|
eq('n', eval('mode()'))
|
||||||
end)
|
end)
|
||||||
|
@@ -410,9 +410,9 @@ describe('messages', function()
|
|||||||
screen:attach()
|
screen:attach()
|
||||||
|
|
||||||
command('cd ' .. nvim_dir)
|
command('cd ' .. nvim_dir)
|
||||||
meths.set_option_value('shell', './shell-test', {})
|
meths.nvim_set_option_value('shell', './shell-test', {})
|
||||||
meths.set_option_value('shellcmdflag', 'REP 20', {})
|
meths.nvim_set_option_value('shellcmdflag', 'REP 20', {})
|
||||||
meths.set_option_value('shellxquote', '', {}) -- win: avoid extra quotes
|
meths.nvim_set_option_value('shellxquote', '', {}) -- win: avoid extra quotes
|
||||||
|
|
||||||
-- display a page and go back, results in exactly the same view
|
-- display a page and go back, results in exactly the same view
|
||||||
feed([[:4 verbose echo system('foo')<CR>]])
|
feed([[:4 verbose echo system('foo')<CR>]])
|
||||||
|
@@ -180,12 +180,12 @@ describe('prompt buffer', function()
|
|||||||
call timer_start(0, {-> nvim_buf_set_lines(s:buf, -1, -1, 0, ['walrus'])})
|
call timer_start(0, {-> nvim_buf_set_lines(s:buf, -1, -1, 0, ['walrus'])})
|
||||||
]]
|
]]
|
||||||
poke_eventloop()
|
poke_eventloop()
|
||||||
eq({ mode = 'i', blocking = false }, meths.get_mode())
|
eq({ mode = 'i', blocking = false }, meths.nvim_get_mode())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- oldtest: Test_prompt_appending_while_hidden()
|
-- oldtest: Test_prompt_appending_while_hidden()
|
||||||
it('accessing hidden prompt buffer does not start insert mode', function()
|
it('accessing hidden prompt buffer does not start insert mode', function()
|
||||||
local prev_win = meths.get_current_win()
|
local prev_win = meths.nvim_get_current_win()
|
||||||
source([[
|
source([[
|
||||||
new prompt
|
new prompt
|
||||||
set buftype=prompt
|
set buftype=prompt
|
||||||
@@ -205,16 +205,16 @@ describe('prompt buffer', function()
|
|||||||
endfunc
|
endfunc
|
||||||
]])
|
]])
|
||||||
feed('asomething<CR>')
|
feed('asomething<CR>')
|
||||||
eq('something', meths.get_var('entered'))
|
eq('something', meths.nvim_get_var('entered'))
|
||||||
neq(prev_win, meths.get_current_win())
|
neq(prev_win, meths.nvim_get_current_win())
|
||||||
feed('exit<CR>')
|
feed('exit<CR>')
|
||||||
eq(prev_win, meths.get_current_win())
|
eq(prev_win, meths.nvim_get_current_win())
|
||||||
eq({ mode = 'n', blocking = false }, meths.get_mode())
|
eq({ mode = 'n', blocking = false }, meths.nvim_get_mode())
|
||||||
command('call DoAppend()')
|
command('call DoAppend()')
|
||||||
eq({ mode = 'n', blocking = false }, meths.get_mode())
|
eq({ mode = 'n', blocking = false }, meths.nvim_get_mode())
|
||||||
feed('i')
|
feed('i')
|
||||||
eq({ mode = 'i', blocking = false }, meths.get_mode())
|
eq({ mode = 'i', blocking = false }, meths.nvim_get_mode())
|
||||||
command('call DoAppend()')
|
command('call DoAppend()')
|
||||||
eq({ mode = 'i', blocking = false }, meths.get_mode())
|
eq({ mode = 'i', blocking = false }, meths.nvim_get_mode())
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
@@ -16,7 +16,7 @@ end
|
|||||||
describe('put', function()
|
describe('put', function()
|
||||||
before_each(clear)
|
before_each(clear)
|
||||||
after_each(function()
|
after_each(function()
|
||||||
eq({}, meths.get_vvar('errors'))
|
eq({}, meths.nvim_get_vvar('errors'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('very large count 64-bit', function()
|
it('very large count 64-bit', function()
|
||||||
|
@@ -57,6 +57,6 @@ describe('undolevel', function()
|
|||||||
call Test_global_local_undolevels()
|
call Test_global_local_undolevels()
|
||||||
]])
|
]])
|
||||||
|
|
||||||
eq({}, nvim.get_vvar('errors'))
|
eq({}, nvim.nvim_get_vvar('errors'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
@@ -12,7 +12,7 @@ describe('Vim script', function()
|
|||||||
it('Error when if/for/while/try/function is nested too deep', function()
|
it('Error when if/for/while/try/function is nested too deep', function()
|
||||||
local screen = Screen.new(80, 24)
|
local screen = Screen.new(80, 24)
|
||||||
screen:attach()
|
screen:attach()
|
||||||
meths.set_option_value('laststatus', 2, {})
|
meths.nvim_set_option_value('laststatus', 2, {})
|
||||||
exec([[
|
exec([[
|
||||||
" Deep nesting of if ... endif
|
" Deep nesting of if ... endif
|
||||||
func Test1()
|
func Test1()
|
||||||
|
@@ -54,9 +54,9 @@ end)
|
|||||||
describe('lua buffer event callbacks: on_lines', function()
|
describe('lua buffer event callbacks: on_lines', function()
|
||||||
local function setup_eventcheck(verify, utf_sizes, lines)
|
local function setup_eventcheck(verify, utf_sizes, lines)
|
||||||
local lastsize
|
local lastsize
|
||||||
meths.buf_set_lines(0, 0, -1, true, lines)
|
meths.nvim_buf_set_lines(0, 0, -1, true, lines)
|
||||||
if verify then
|
if verify then
|
||||||
lastsize = meths.buf_get_offset(0, meths.buf_line_count(0))
|
lastsize = meths.nvim_buf_get_offset(0, meths.nvim_buf_line_count(0))
|
||||||
end
|
end
|
||||||
exec_lua('return test_register(...)', 0, 'on_lines', 'test1', false, utf_sizes)
|
exec_lua('return test_register(...)', 0, 'on_lines', 'test1', false, utf_sizes)
|
||||||
local verify_name = 'test1'
|
local verify_name = 'test1'
|
||||||
@@ -76,8 +76,9 @@ describe('lua buffer event callbacks: on_lines', function()
|
|||||||
for _, event in ipairs(events) do
|
for _, event in ipairs(events) do
|
||||||
if event[1] == verify_name and event[2] == 'lines' then
|
if event[1] == verify_name and event[2] == 'lines' then
|
||||||
local startline, endline = event[5], event[7]
|
local startline, endline = event[5], event[7]
|
||||||
local newrange = meths.buf_get_offset(0, endline) - meths.buf_get_offset(0, startline)
|
local newrange = meths.nvim_buf_get_offset(0, endline)
|
||||||
local newsize = meths.buf_get_offset(0, meths.buf_line_count(0))
|
- meths.nvim_buf_get_offset(0, startline)
|
||||||
|
local newsize = meths.nvim_buf_get_offset(0, meths.nvim_buf_line_count(0))
|
||||||
local oldrange = newrange + lastsize - newsize
|
local oldrange = newrange + lastsize - newsize
|
||||||
eq(oldrange, event[8])
|
eq(oldrange, event[8])
|
||||||
lastsize = newsize
|
lastsize = newsize
|
||||||
@@ -97,13 +98,13 @@ describe('lua buffer event callbacks: on_lines', function()
|
|||||||
local function check(verify, utf_sizes)
|
local function check(verify, utf_sizes)
|
||||||
local check_events, verify_name = setup_eventcheck(verify, utf_sizes, origlines)
|
local check_events, verify_name = setup_eventcheck(verify, utf_sizes, origlines)
|
||||||
|
|
||||||
local tick = meths.buf_get_changedtick(0)
|
local tick = meths.nvim_buf_get_changedtick(0)
|
||||||
command('set autoindent')
|
command('set autoindent')
|
||||||
command('normal! GyyggP')
|
command('normal! GyyggP')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
check_events { { 'test1', 'lines', 1, tick, 0, 0, 1, 0 } }
|
check_events { { 'test1', 'lines', 1, tick, 0, 0, 1, 0 } }
|
||||||
|
|
||||||
meths.buf_set_lines(0, 3, 5, true, { 'changed line' })
|
meths.nvim_buf_set_lines(0, 3, 5, true, { 'changed line' })
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
check_events { { 'test1', 'lines', 1, tick, 3, 5, 4, 32 } }
|
check_events { { 'test1', 'lines', 1, tick, 3, 5, 4, 32 } }
|
||||||
|
|
||||||
@@ -141,7 +142,7 @@ describe('lua buffer event callbacks: on_lines', function()
|
|||||||
-- simulate next callback returning true
|
-- simulate next callback returning true
|
||||||
exec_lua("test_unreg = 'test1'")
|
exec_lua("test_unreg = 'test1'")
|
||||||
|
|
||||||
meths.buf_set_lines(0, 6, 7, true, { 'x1', 'x2', 'x3' })
|
meths.nvim_buf_set_lines(0, 6, 7, true, { 'x1', 'x2', 'x3' })
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
|
|
||||||
-- plugins can opt in to receive changedtick events, or choose
|
-- plugins can opt in to receive changedtick events, or choose
|
||||||
@@ -153,7 +154,7 @@ describe('lua buffer event callbacks: on_lines', function()
|
|||||||
|
|
||||||
verify_name 'test2'
|
verify_name 'test2'
|
||||||
|
|
||||||
meths.buf_set_lines(0, 1, 1, true, { 'added' })
|
meths.nvim_buf_set_lines(0, 1, 1, true, { 'added' })
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
check_events { { 'test2', 'lines', 1, tick, 1, 1, 2, 0 } }
|
check_events { { 'test2', 'lines', 1, tick, 1, 1, 2, 0 } }
|
||||||
|
|
||||||
@@ -205,7 +206,7 @@ describe('lua buffer event callbacks: on_lines', function()
|
|||||||
}
|
}
|
||||||
local check_events, verify_name = setup_eventcheck(verify, true, unicode_text)
|
local check_events, verify_name = setup_eventcheck(verify, true, unicode_text)
|
||||||
|
|
||||||
local tick = meths.buf_get_changedtick(0)
|
local tick = meths.nvim_buf_get_changedtick(0)
|
||||||
|
|
||||||
feed('ggdd')
|
feed('ggdd')
|
||||||
tick = tick + 1
|
tick = tick + 1
|
||||||
@@ -253,7 +254,7 @@ describe('lua buffer event callbacks: on_lines', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('has valid cursor position while shifting', function()
|
it('has valid cursor position while shifting', function()
|
||||||
meths.buf_set_lines(0, 0, -1, true, { 'line1' })
|
meths.nvim_buf_set_lines(0, 0, -1, true, { 'line1' })
|
||||||
exec_lua([[
|
exec_lua([[
|
||||||
vim.api.nvim_buf_attach(0, false, {
|
vim.api.nvim_buf_attach(0, false, {
|
||||||
on_lines = function()
|
on_lines = function()
|
||||||
@@ -262,15 +263,15 @@ describe('lua buffer event callbacks: on_lines', function()
|
|||||||
})
|
})
|
||||||
]])
|
]])
|
||||||
feed('>>')
|
feed('>>')
|
||||||
eq(1, meths.get_var('listener_cursor_line'))
|
eq(1, meths.nvim_get_var('listener_cursor_line'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('has valid cursor position while deleting lines', function()
|
it('has valid cursor position while deleting lines', function()
|
||||||
meths.buf_set_lines(0, 0, -1, true, { 'line_1', 'line_2', 'line_3', 'line_4' })
|
meths.nvim_buf_set_lines(0, 0, -1, true, { 'line_1', 'line_2', 'line_3', 'line_4' })
|
||||||
meths.win_set_cursor(0, { 2, 0 })
|
meths.nvim_win_set_cursor(0, { 2, 0 })
|
||||||
eq(2, meths.win_get_cursor(0)[1])
|
eq(2, meths.nvim_win_get_cursor(0)[1])
|
||||||
meths.buf_set_lines(0, 0, -1, true, { 'line_1', 'line_2', 'line_3' })
|
meths.nvim_buf_set_lines(0, 0, -1, true, { 'line_1', 'line_2', 'line_3' })
|
||||||
eq(2, meths.win_get_cursor(0)[1])
|
eq(2, meths.nvim_win_get_cursor(0)[1])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('does not SEGFAULT when accessing window buffer info in on_detach #14998', function()
|
it('does not SEGFAULT when accessing window buffer info in on_detach #14998', function()
|
||||||
@@ -298,7 +299,7 @@ describe('lua buffer event callbacks: on_lines', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('#12718 lnume', function()
|
it('#12718 lnume', function()
|
||||||
meths.buf_set_lines(0, 0, -1, true, { '1', '2', '3' })
|
meths.nvim_buf_set_lines(0, 0, -1, true, { '1', '2', '3' })
|
||||||
exec_lua([[
|
exec_lua([[
|
||||||
vim.api.nvim_buf_attach(0, false, {
|
vim.api.nvim_buf_attach(0, false, {
|
||||||
on_lines = function(...)
|
on_lines = function(...)
|
||||||
@@ -311,15 +312,15 @@ describe('lua buffer event callbacks: on_lines', function()
|
|||||||
feed('G0')
|
feed('G0')
|
||||||
feed('p')
|
feed('p')
|
||||||
-- Is the last arg old_byte_size correct? Doesn't matter for this PR
|
-- Is the last arg old_byte_size correct? Doesn't matter for this PR
|
||||||
eq(meths.get_var('linesev'), { 'lines', 1, 4, 2, 3, 5, 4 })
|
eq(meths.nvim_get_var('linesev'), { 'lines', 1, 4, 2, 3, 5, 4 })
|
||||||
|
|
||||||
feed('2G0')
|
feed('2G0')
|
||||||
feed('p')
|
feed('p')
|
||||||
eq(meths.get_var('linesev'), { 'lines', 1, 5, 1, 4, 4, 8 })
|
eq(meths.nvim_get_var('linesev'), { 'lines', 1, 5, 1, 4, 4, 8 })
|
||||||
|
|
||||||
feed('1G0')
|
feed('1G0')
|
||||||
feed('P')
|
feed('P')
|
||||||
eq(meths.get_var('linesev'), { 'lines', 1, 6, 0, 3, 3, 9 })
|
eq(meths.nvim_get_var('linesev'), { 'lines', 1, 6, 0, 3, 3, 9 })
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it(
|
it(
|
||||||
@@ -333,7 +334,7 @@ describe('lua buffer event callbacks: on_lines', function()
|
|||||||
})
|
})
|
||||||
]])
|
]])
|
||||||
feed('itest123<Esc><C-A>')
|
feed('itest123<Esc><C-A>')
|
||||||
eq('test124', meths.get_current_line())
|
eq('test124', meths.nvim_get_current_line())
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
@@ -345,19 +346,19 @@ describe('lua: nvim_buf_attach on_bytes', function()
|
|||||||
-- test both ways.
|
-- test both ways.
|
||||||
local function setup_eventcheck(verify, start_txt)
|
local function setup_eventcheck(verify, start_txt)
|
||||||
if start_txt then
|
if start_txt then
|
||||||
meths.buf_set_lines(0, 0, -1, true, start_txt)
|
meths.nvim_buf_set_lines(0, 0, -1, true, start_txt)
|
||||||
else
|
else
|
||||||
start_txt = meths.buf_get_lines(0, 0, -1, true)
|
start_txt = meths.nvim_buf_get_lines(0, 0, -1, true)
|
||||||
end
|
end
|
||||||
local shadowbytes = table.concat(start_txt, '\n') .. '\n'
|
local shadowbytes = table.concat(start_txt, '\n') .. '\n'
|
||||||
-- TODO: while we are brewing the real strong coffee,
|
-- TODO: while we are brewing the real strong coffee,
|
||||||
-- verify should check buf_get_offset after every check_events
|
-- verify should check buf_get_offset after every check_events
|
||||||
if verify then
|
if verify then
|
||||||
local len = meths.buf_get_offset(0, meths.buf_line_count(0))
|
local len = meths.nvim_buf_get_offset(0, meths.nvim_buf_line_count(0))
|
||||||
eq(len == -1 and 1 or len, string.len(shadowbytes))
|
eq(len == -1 and 1 or len, string.len(shadowbytes))
|
||||||
end
|
end
|
||||||
exec_lua('return test_register(...)', 0, 'on_bytes', 'test1', false, false, true)
|
exec_lua('return test_register(...)', 0, 'on_bytes', 'test1', false, false, true)
|
||||||
meths.buf_get_changedtick(0)
|
meths.nvim_buf_get_changedtick(0)
|
||||||
|
|
||||||
local verify_name = 'test1'
|
local verify_name = 'test1'
|
||||||
local function check_events(expected)
|
local function check_events(expected)
|
||||||
@@ -384,11 +385,11 @@ describe('lua: nvim_buf_attach on_bytes', function()
|
|||||||
local after = string.sub(shadowbytes, start_byte + old_byte + 1)
|
local after = string.sub(shadowbytes, start_byte + old_byte + 1)
|
||||||
shadowbytes = before .. unknown .. after
|
shadowbytes = before .. unknown .. after
|
||||||
elseif event[1] == verify_name and event[2] == 'reload' then
|
elseif event[1] == verify_name and event[2] == 'reload' then
|
||||||
shadowbytes = table.concat(meths.buf_get_lines(0, 0, -1, true), '\n') .. '\n'
|
shadowbytes = table.concat(meths.nvim_buf_get_lines(0, 0, -1, true), '\n') .. '\n'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local text = meths.buf_get_lines(0, 0, -1, true)
|
local text = meths.nvim_buf_get_lines(0, 0, -1, true)
|
||||||
local bytes = table.concat(text, '\n') .. '\n'
|
local bytes = table.concat(text, '\n') .. '\n'
|
||||||
|
|
||||||
eq(
|
eq(
|
||||||
@@ -425,7 +426,7 @@ describe('lua: nvim_buf_attach on_bytes', function()
|
|||||||
|
|
||||||
it('opening lines', function()
|
it('opening lines', function()
|
||||||
local check_events = setup_eventcheck(verify, origlines)
|
local check_events = setup_eventcheck(verify, origlines)
|
||||||
-- meths.set_option_value('autoindent', true, {})
|
-- meths.nvim_set_option_value('autoindent', true, {})
|
||||||
feed 'Go'
|
feed 'Go'
|
||||||
check_events {
|
check_events {
|
||||||
{ 'test1', 'bytes', 1, 3, 7, 0, 114, 0, 0, 0, 1, 0, 1 },
|
{ 'test1', 'bytes', 1, 3, 7, 0, 114, 0, 0, 0, 1, 0, 1 },
|
||||||
@@ -438,7 +439,7 @@ describe('lua: nvim_buf_attach on_bytes', function()
|
|||||||
|
|
||||||
it('opening lines with autoindent', function()
|
it('opening lines with autoindent', function()
|
||||||
local check_events = setup_eventcheck(verify, origlines)
|
local check_events = setup_eventcheck(verify, origlines)
|
||||||
meths.set_option_value('autoindent', true, {})
|
meths.nvim_set_option_value('autoindent', true, {})
|
||||||
feed 'Go'
|
feed 'Go'
|
||||||
check_events {
|
check_events {
|
||||||
{ 'test1', 'bytes', 1, 3, 7, 0, 114, 0, 0, 0, 1, 0, 5 },
|
{ 'test1', 'bytes', 1, 3, 7, 0, 114, 0, 0, 0, 1, 0, 5 },
|
||||||
@@ -463,7 +464,7 @@ describe('lua: nvim_buf_attach on_bytes', function()
|
|||||||
{ 'test1', 'bytes', 1, 5, 2, 0, 20, 0, 15, 15, 0, 3, 3 },
|
{ 'test1', 'bytes', 1, 5, 2, 0, 20, 0, 15, 15, 0, 3, 3 },
|
||||||
}
|
}
|
||||||
|
|
||||||
local buf_len = meths.buf_line_count(0)
|
local buf_len = meths.nvim_buf_line_count(0)
|
||||||
funcs.setline(buf_len + 1, 'baz')
|
funcs.setline(buf_len + 1, 'baz')
|
||||||
check_events {
|
check_events {
|
||||||
{ 'test1', 'bytes', 1, 6, 7, 0, 90, 0, 0, 0, 1, 0, 4 },
|
{ 'test1', 'bytes', 1, 6, 7, 0, 90, 0, 0, 0, 1, 0, 4 },
|
||||||
@@ -472,8 +473,8 @@ describe('lua: nvim_buf_attach on_bytes', function()
|
|||||||
|
|
||||||
it('continuing comments with fo=or', function()
|
it('continuing comments with fo=or', function()
|
||||||
local check_events = setup_eventcheck(verify, { '// Comment' })
|
local check_events = setup_eventcheck(verify, { '// Comment' })
|
||||||
meths.set_option_value('formatoptions', 'ro', {})
|
meths.nvim_set_option_value('formatoptions', 'ro', {})
|
||||||
meths.set_option_value('filetype', 'c', {})
|
meths.nvim_set_option_value('filetype', 'c', {})
|
||||||
feed 'A<CR>'
|
feed 'A<CR>'
|
||||||
check_events {
|
check_events {
|
||||||
{ 'test1', 'bytes', 1, 4, 0, 10, 10, 0, 0, 0, 1, 3, 4 },
|
{ 'test1', 'bytes', 1, 4, 0, 10, 10, 0, 0, 0, 1, 3, 4 },
|
||||||
@@ -611,7 +612,7 @@ describe('lua: nvim_buf_attach on_bytes', function()
|
|||||||
|
|
||||||
it('inccomand=nosplit and substitute', function()
|
it('inccomand=nosplit and substitute', function()
|
||||||
local check_events = setup_eventcheck(verify, { 'abcde', '12345' })
|
local check_events = setup_eventcheck(verify, { 'abcde', '12345' })
|
||||||
meths.set_option_value('inccommand', 'nosplit', {})
|
meths.nvim_set_option_value('inccommand', 'nosplit', {})
|
||||||
|
|
||||||
-- linewise substitute
|
-- linewise substitute
|
||||||
feed(':%s/bcd/')
|
feed(':%s/bcd/')
|
||||||
@@ -696,41 +697,41 @@ describe('lua: nvim_buf_attach on_bytes', function()
|
|||||||
|
|
||||||
it('nvim_buf_set_text insert', function()
|
it('nvim_buf_set_text insert', function()
|
||||||
local check_events = setup_eventcheck(verify, { 'bastext' })
|
local check_events = setup_eventcheck(verify, { 'bastext' })
|
||||||
meths.buf_set_text(0, 0, 3, 0, 3, { 'fiol', 'kontra' })
|
meths.nvim_buf_set_text(0, 0, 3, 0, 3, { 'fiol', 'kontra' })
|
||||||
check_events {
|
check_events {
|
||||||
{ 'test1', 'bytes', 1, 3, 0, 3, 3, 0, 0, 0, 1, 6, 11 },
|
{ 'test1', 'bytes', 1, 3, 0, 3, 3, 0, 0, 0, 1, 6, 11 },
|
||||||
}
|
}
|
||||||
|
|
||||||
meths.buf_set_text(0, 1, 6, 1, 6, { 'punkt', 'syntgitarr', 'övnings' })
|
meths.nvim_buf_set_text(0, 1, 6, 1, 6, { 'punkt', 'syntgitarr', 'övnings' })
|
||||||
check_events {
|
check_events {
|
||||||
{ 'test1', 'bytes', 1, 4, 1, 6, 14, 0, 0, 0, 2, 8, 25 },
|
{ 'test1', 'bytes', 1, 4, 1, 6, 14, 0, 0, 0, 2, 8, 25 },
|
||||||
}
|
}
|
||||||
|
|
||||||
eq(
|
eq(
|
||||||
{ 'basfiol', 'kontrapunkt', 'syntgitarr', 'övningstext' },
|
{ 'basfiol', 'kontrapunkt', 'syntgitarr', 'övningstext' },
|
||||||
meths.buf_get_lines(0, 0, -1, true)
|
meths.nvim_buf_get_lines(0, 0, -1, true)
|
||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('nvim_buf_set_text replace', function()
|
it('nvim_buf_set_text replace', function()
|
||||||
local check_events = setup_eventcheck(verify, origlines)
|
local check_events = setup_eventcheck(verify, origlines)
|
||||||
|
|
||||||
meths.buf_set_text(0, 2, 3, 2, 8, { 'very text' })
|
meths.nvim_buf_set_text(0, 2, 3, 2, 8, { 'very text' })
|
||||||
check_events {
|
check_events {
|
||||||
{ 'test1', 'bytes', 1, 3, 2, 3, 35, 0, 5, 5, 0, 9, 9 },
|
{ 'test1', 'bytes', 1, 3, 2, 3, 35, 0, 5, 5, 0, 9, 9 },
|
||||||
}
|
}
|
||||||
|
|
||||||
meths.buf_set_text(0, 3, 5, 3, 7, { ' splitty', 'line ' })
|
meths.nvim_buf_set_text(0, 3, 5, 3, 7, { ' splitty', 'line ' })
|
||||||
check_events {
|
check_events {
|
||||||
{ 'test1', 'bytes', 1, 4, 3, 5, 57, 0, 2, 2, 1, 5, 14 },
|
{ 'test1', 'bytes', 1, 4, 3, 5, 57, 0, 2, 2, 1, 5, 14 },
|
||||||
}
|
}
|
||||||
|
|
||||||
meths.buf_set_text(0, 0, 8, 1, 2, { 'JOINY' })
|
meths.nvim_buf_set_text(0, 0, 8, 1, 2, { 'JOINY' })
|
||||||
check_events {
|
check_events {
|
||||||
{ 'test1', 'bytes', 1, 5, 0, 8, 8, 1, 2, 10, 0, 5, 5 },
|
{ 'test1', 'bytes', 1, 5, 0, 8, 8, 1, 2, 10, 0, 5, 5 },
|
||||||
}
|
}
|
||||||
|
|
||||||
meths.buf_set_text(0, 4, 0, 6, 0, { 'was 5,6', '' })
|
meths.nvim_buf_set_text(0, 4, 0, 6, 0, { 'was 5,6', '' })
|
||||||
check_events {
|
check_events {
|
||||||
{ 'test1', 'bytes', 1, 6, 4, 0, 75, 2, 0, 32, 1, 0, 8 },
|
{ 'test1', 'bytes', 1, 6, 4, 0, 75, 2, 0, 32, 1, 0, 8 },
|
||||||
}
|
}
|
||||||
@@ -742,20 +743,20 @@ describe('lua: nvim_buf_attach on_bytes', function()
|
|||||||
'line l line 4',
|
'line l line 4',
|
||||||
'was 5,6',
|
'was 5,6',
|
||||||
' indented line',
|
' indented line',
|
||||||
}, meths.buf_get_lines(0, 0, -1, true))
|
}, meths.nvim_buf_get_lines(0, 0, -1, true))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('nvim_buf_set_text delete', function()
|
it('nvim_buf_set_text delete', function()
|
||||||
local check_events = setup_eventcheck(verify, origlines)
|
local check_events = setup_eventcheck(verify, origlines)
|
||||||
|
|
||||||
-- really {""} but accepts {} as a shorthand
|
-- really {""} but accepts {} as a shorthand
|
||||||
meths.buf_set_text(0, 0, 0, 1, 0, {})
|
meths.nvim_buf_set_text(0, 0, 0, 1, 0, {})
|
||||||
check_events {
|
check_events {
|
||||||
{ 'test1', 'bytes', 1, 3, 0, 0, 0, 1, 0, 16, 0, 0, 0 },
|
{ 'test1', 'bytes', 1, 3, 0, 0, 0, 1, 0, 16, 0, 0, 0 },
|
||||||
}
|
}
|
||||||
|
|
||||||
-- TODO(bfredl): this works but is not as convenient as set_lines
|
-- TODO(bfredl): this works but is not as convenient as set_lines
|
||||||
meths.buf_set_text(0, 4, 15, 5, 17, { '' })
|
meths.nvim_buf_set_text(0, 4, 15, 5, 17, { '' })
|
||||||
check_events {
|
check_events {
|
||||||
{ 'test1', 'bytes', 1, 4, 4, 15, 79, 1, 17, 18, 0, 0, 0 },
|
{ 'test1', 'bytes', 1, 4, 4, 15, 79, 1, 17, 18, 0, 0, 0 },
|
||||||
}
|
}
|
||||||
@@ -765,7 +766,7 @@ describe('lua: nvim_buf_attach on_bytes', function()
|
|||||||
'original line 4',
|
'original line 4',
|
||||||
'original line 5',
|
'original line 5',
|
||||||
'original line 6',
|
'original line 6',
|
||||||
}, meths.buf_get_lines(0, 0, -1, true))
|
}, meths.nvim_buf_get_lines(0, 0, -1, true))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('checktime autoread', function()
|
it('checktime autoread', function()
|
||||||
@@ -800,7 +801,7 @@ describe('lua: nvim_buf_attach on_bytes', function()
|
|||||||
{ 'test1', 'bytes', 1, 5, 0, 10, 10, 1, 0, 1, 0, 1, 1 },
|
{ 'test1', 'bytes', 1, 5, 0, 10, 10, 1, 0, 1, 0, 1, 1 },
|
||||||
}
|
}
|
||||||
|
|
||||||
eq({ 'new line 1 new line 2', 'new line 3' }, meths.buf_get_lines(0, 0, -1, true))
|
eq({ 'new line 1 new line 2', 'new line 3' }, meths.nvim_buf_get_lines(0, 0, -1, true))
|
||||||
|
|
||||||
-- check we can undo and redo a reload event.
|
-- check we can undo and redo a reload event.
|
||||||
feed 'u'
|
feed 'u'
|
||||||
@@ -924,19 +925,19 @@ describe('lua: nvim_buf_attach on_bytes', function()
|
|||||||
command('set undodir=. | set undofile')
|
command('set undodir=. | set undofile')
|
||||||
|
|
||||||
local ns = helpers.request('nvim_create_namespace', 'ns1')
|
local ns = helpers.request('nvim_create_namespace', 'ns1')
|
||||||
meths.buf_set_extmark(0, ns, 0, 0, {})
|
meths.nvim_buf_set_extmark(0, ns, 0, 0, {})
|
||||||
|
|
||||||
eq({ '12345', 'hello world' }, meths.buf_get_lines(0, 0, -1, true))
|
eq({ '12345', 'hello world' }, meths.nvim_buf_get_lines(0, 0, -1, true))
|
||||||
|
|
||||||
-- splice
|
-- splice
|
||||||
feed('gg0d2l')
|
feed('gg0d2l')
|
||||||
|
|
||||||
eq({ '345', 'hello world' }, meths.buf_get_lines(0, 0, -1, true))
|
eq({ '345', 'hello world' }, meths.nvim_buf_get_lines(0, 0, -1, true))
|
||||||
|
|
||||||
-- move
|
-- move
|
||||||
command('.m+1')
|
command('.m+1')
|
||||||
|
|
||||||
eq({ 'hello world', '345' }, meths.buf_get_lines(0, 0, -1, true))
|
eq({ 'hello world', '345' }, meths.nvim_buf_get_lines(0, 0, -1, true))
|
||||||
|
|
||||||
-- reload undofile and undo changes
|
-- reload undofile and undo changes
|
||||||
command('w')
|
command('w')
|
||||||
@@ -949,7 +950,7 @@ describe('lua: nvim_buf_attach on_bytes', function()
|
|||||||
local check_events = setup_eventcheck(verify, nil)
|
local check_events = setup_eventcheck(verify, nil)
|
||||||
|
|
||||||
feed('u')
|
feed('u')
|
||||||
eq({ '345', 'hello world' }, meths.buf_get_lines(0, 0, -1, true))
|
eq({ '345', 'hello world' }, meths.nvim_buf_get_lines(0, 0, -1, true))
|
||||||
|
|
||||||
check_events {
|
check_events {
|
||||||
{ 'test1', 'bytes', 2, 6, 1, 0, 12, 1, 0, 4, 0, 0, 0 },
|
{ 'test1', 'bytes', 2, 6, 1, 0, 12, 1, 0, 4, 0, 0, 0 },
|
||||||
@@ -957,7 +958,7 @@ describe('lua: nvim_buf_attach on_bytes', function()
|
|||||||
}
|
}
|
||||||
|
|
||||||
feed('u')
|
feed('u')
|
||||||
eq({ '12345', 'hello world' }, meths.buf_get_lines(0, 0, -1, true))
|
eq({ '12345', 'hello world' }, meths.nvim_buf_get_lines(0, 0, -1, true))
|
||||||
|
|
||||||
check_events {
|
check_events {
|
||||||
{ 'test1', 'bytes', 2, 8, 0, 0, 0, 0, 0, 0, 0, 2, 2 },
|
{ 'test1', 'bytes', 2, 8, 0, 0, 0, 0, 0, 0, 0, 2, 2 },
|
||||||
@@ -968,7 +969,7 @@ describe('lua: nvim_buf_attach on_bytes', function()
|
|||||||
it('blockwise paste with uneven line lengths', function()
|
it('blockwise paste with uneven line lengths', function()
|
||||||
local check_events = setup_eventcheck(verify, { 'aaaa', 'aaa', 'aaa' })
|
local check_events = setup_eventcheck(verify, { 'aaaa', 'aaa', 'aaa' })
|
||||||
|
|
||||||
-- eq({}, meths.buf_get_lines(0, 0, -1, true))
|
-- eq({}, meths.nvim_buf_get_lines(0, 0, -1, true))
|
||||||
feed('gg0<c-v>jj$d')
|
feed('gg0<c-v>jj$d')
|
||||||
|
|
||||||
check_events {
|
check_events {
|
||||||
@@ -1022,7 +1023,7 @@ describe('lua: nvim_buf_attach on_bytes', function()
|
|||||||
it('virtual edit', function()
|
it('virtual edit', function()
|
||||||
local check_events = setup_eventcheck(verify, { '', ' ' })
|
local check_events = setup_eventcheck(verify, { '', ' ' })
|
||||||
|
|
||||||
meths.set_option_value('virtualedit', 'all', {})
|
meths.nvim_set_option_value('virtualedit', 'all', {})
|
||||||
|
|
||||||
feed [[<Right><Right>iab<ESC>]]
|
feed [[<Right><Right>iab<ESC>]]
|
||||||
|
|
||||||
@@ -1076,20 +1077,20 @@ describe('lua: nvim_buf_attach on_bytes', function()
|
|||||||
local check_events = setup_eventcheck(verify, { 'AAA', 'BBB' })
|
local check_events = setup_eventcheck(verify, { 'AAA', 'BBB' })
|
||||||
|
|
||||||
-- delete
|
-- delete
|
||||||
meths.buf_set_lines(0, 0, 1, true, {})
|
meths.nvim_buf_set_lines(0, 0, 1, true, {})
|
||||||
|
|
||||||
check_events {
|
check_events {
|
||||||
{ 'test1', 'bytes', 1, 3, 0, 0, 0, 1, 0, 4, 0, 0, 0 },
|
{ 'test1', 'bytes', 1, 3, 0, 0, 0, 1, 0, 4, 0, 0, 0 },
|
||||||
}
|
}
|
||||||
|
|
||||||
-- add
|
-- add
|
||||||
meths.buf_set_lines(0, 0, 0, true, { 'asdf' })
|
meths.nvim_buf_set_lines(0, 0, 0, true, { 'asdf' })
|
||||||
check_events {
|
check_events {
|
||||||
{ 'test1', 'bytes', 1, 4, 0, 0, 0, 0, 0, 0, 1, 0, 5 },
|
{ 'test1', 'bytes', 1, 4, 0, 0, 0, 0, 0, 0, 1, 0, 5 },
|
||||||
}
|
}
|
||||||
|
|
||||||
-- replace
|
-- replace
|
||||||
meths.buf_set_lines(0, 0, 1, true, { 'asdf', 'fdsa' })
|
meths.nvim_buf_set_lines(0, 0, 1, true, { 'asdf', 'fdsa' })
|
||||||
check_events {
|
check_events {
|
||||||
{ 'test1', 'bytes', 1, 5, 0, 0, 0, 1, 0, 5, 2, 0, 10 },
|
{ 'test1', 'bytes', 1, 5, 0, 0, 0, 1, 0, 5, 2, 0, 10 },
|
||||||
}
|
}
|
||||||
@@ -1201,13 +1202,13 @@ describe('lua: nvim_buf_attach on_bytes', function()
|
|||||||
command('diffthis')
|
command('diffthis')
|
||||||
command('new')
|
command('new')
|
||||||
command('diffthis')
|
command('diffthis')
|
||||||
meths.buf_set_lines(0, 0, -1, true, { 'AAA', 'BBB' })
|
meths.nvim_buf_set_lines(0, 0, -1, true, { 'AAA', 'BBB' })
|
||||||
feed('G')
|
feed('G')
|
||||||
command('diffput')
|
command('diffput')
|
||||||
check_events {
|
check_events {
|
||||||
{ 'test1', 'bytes', 1, 3, 1, 0, 4, 0, 0, 0, 1, 0, 4 },
|
{ 'test1', 'bytes', 1, 3, 1, 0, 4, 0, 0, 0, 1, 0, 4 },
|
||||||
}
|
}
|
||||||
meths.buf_set_lines(0, 0, -1, true, { 'AAA', 'CCC' })
|
meths.nvim_buf_set_lines(0, 0, -1, true, { 'AAA', 'CCC' })
|
||||||
feed('<C-w>pG')
|
feed('<C-w>pG')
|
||||||
command('diffget')
|
command('diffget')
|
||||||
check_events {
|
check_events {
|
||||||
@@ -1249,7 +1250,7 @@ describe('lua: nvim_buf_attach on_bytes', function()
|
|||||||
{ 'test1', 'bytes', 1, 5, 3, 0, 10, 1, 0, 1, 0, 0, 0 },
|
{ 'test1', 'bytes', 1, 5, 3, 0, 10, 1, 0, 1, 0, 0, 0 },
|
||||||
}
|
}
|
||||||
|
|
||||||
eq('CCC|BBBB|', table.concat(meths.buf_get_lines(0, 0, -1, true), '|'))
|
eq('CCC|BBBB|', table.concat(meths.nvim_buf_get_lines(0, 0, -1, true), '|'))
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@@ -76,7 +76,7 @@ describe(':lua command', function()
|
|||||||
it('accepts embedded NLs without heredoc', function()
|
it('accepts embedded NLs without heredoc', function()
|
||||||
-- Such code is usually used for `:execute 'lua' {generated_string}`:
|
-- Such code is usually used for `:execute 'lua' {generated_string}`:
|
||||||
-- heredocs do not work in this case.
|
-- heredocs do not work in this case.
|
||||||
meths.command([[
|
meths.nvim_command([[
|
||||||
lua
|
lua
|
||||||
vim.api.nvim_buf_set_lines(1, 1, 2, false, {"ETTS"})
|
vim.api.nvim_buf_set_lines(1, 1, 2, false, {"ETTS"})
|
||||||
vim.api.nvim_buf_set_lines(1, 2, 3, false, {"TTSE"})
|
vim.api.nvim_buf_set_lines(1, 2, 3, false, {"TTSE"})
|
||||||
|
@@ -165,6 +165,6 @@ describe('filetype.lua', function()
|
|||||||
clear({
|
clear({
|
||||||
args = { '--clean', '--cmd', 'autocmd BufRead *.md set filetype=notmarkdown', 'README.md' },
|
args = { '--clean', '--cmd', 'autocmd BufRead *.md set filetype=notmarkdown', 'README.md' },
|
||||||
})
|
})
|
||||||
eq('notmarkdown', meths.get_option_value('filetype', {}))
|
eq('notmarkdown', meths.nvim_get_option_value('filetype', {}))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
@@ -48,13 +48,13 @@ describe('vim.uv', function()
|
|||||||
end)()
|
end)()
|
||||||
]]
|
]]
|
||||||
|
|
||||||
eq(0, meths.get_var('coroutine_cnt'))
|
eq(0, meths.nvim_get_var('coroutine_cnt'))
|
||||||
exec_lua(code)
|
exec_lua(code)
|
||||||
retry(2, nil, function()
|
retry(2, nil, function()
|
||||||
sleep(50)
|
sleep(50)
|
||||||
eq(2, meths.get_var('coroutine_cnt'))
|
eq(2, meths.nvim_get_var('coroutine_cnt'))
|
||||||
end)
|
end)
|
||||||
eq(3, meths.get_var('coroutine_cnt_1'))
|
eq(3, meths.nvim_get_var('coroutine_cnt_1'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('is API safe', function()
|
it('is API safe', function()
|
||||||
|
@@ -67,17 +67,17 @@ describe('luaeval()', function()
|
|||||||
describe('strings with NULs', function()
|
describe('strings with NULs', function()
|
||||||
it('are successfully converted to blobs', function()
|
it('are successfully converted to blobs', function()
|
||||||
command([[let s = luaeval('"\0"')]])
|
command([[let s = luaeval('"\0"')]])
|
||||||
eq('\000', meths.get_var('s'))
|
eq('\000', meths.nvim_get_var('s'))
|
||||||
end)
|
end)
|
||||||
it('are successfully converted to special dictionaries in table keys', function()
|
it('are successfully converted to special dictionaries in table keys', function()
|
||||||
command([[let d = luaeval('{["\0"]=1}')]])
|
command([[let d = luaeval('{["\0"]=1}')]])
|
||||||
eq({_TYPE={}, _VAL={{{_TYPE={}, _VAL={'\n'}}, 1}}}, meths.get_var('d'))
|
eq({_TYPE={}, _VAL={{{_TYPE={}, _VAL={'\n'}}, 1}}}, meths.nvim_get_var('d'))
|
||||||
eq(1, funcs.eval('d._TYPE is v:msgpack_types.map'))
|
eq(1, funcs.eval('d._TYPE is v:msgpack_types.map'))
|
||||||
eq(1, funcs.eval('d._VAL[0][0]._TYPE is v:msgpack_types.string'))
|
eq(1, funcs.eval('d._VAL[0][0]._TYPE is v:msgpack_types.string'))
|
||||||
end)
|
end)
|
||||||
it('are successfully converted to blobs from a list', function()
|
it('are successfully converted to blobs from a list', function()
|
||||||
command([[let l = luaeval('{"abc", "a\0b", "c\0d", "def"}')]])
|
command([[let l = luaeval('{"abc", "a\0b", "c\0d", "def"}')]])
|
||||||
eq({'abc', 'a\000b', 'c\000d', 'def'}, meths.get_var('l'))
|
eq({'abc', 'a\000b', 'c\000d', 'def'}, meths.nvim_get_var('l'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -411,14 +411,14 @@ describe('luaeval()', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('correctly converts self-containing containers', function()
|
it('correctly converts self-containing containers', function()
|
||||||
meths.set_var('l', {})
|
meths.nvim_set_var('l', {})
|
||||||
eval('add(l, l)')
|
eval('add(l, l)')
|
||||||
eq(true, eval('luaeval("_A == _A[1]", l)'))
|
eq(true, eval('luaeval("_A == _A[1]", l)'))
|
||||||
eq(true, eval('luaeval("_A[1] == _A[1][1]", [l])'))
|
eq(true, eval('luaeval("_A[1] == _A[1][1]", [l])'))
|
||||||
eq(true, eval('luaeval("_A.d == _A.d[1]", {"d": l})'))
|
eq(true, eval('luaeval("_A.d == _A.d[1]", {"d": l})'))
|
||||||
eq(true, eval('luaeval("_A ~= _A[1]", [l])'))
|
eq(true, eval('luaeval("_A ~= _A[1]", [l])'))
|
||||||
|
|
||||||
meths.set_var('d', {foo=42})
|
meths.nvim_set_var('d', {foo=42})
|
||||||
eval('extend(d, {"d": d})')
|
eval('extend(d, {"d": d})')
|
||||||
eq(true, eval('luaeval("_A == _A.d", d)'))
|
eq(true, eval('luaeval("_A == _A.d", d)'))
|
||||||
eq(true, eval('luaeval("_A[1] == _A[1].d", [d])'))
|
eq(true, eval('luaeval("_A[1] == _A[1].d", [d])'))
|
||||||
@@ -478,7 +478,7 @@ describe('v:lua', function()
|
|||||||
eq(7, eval('v:lua.foo(3,4,v:null)'))
|
eq(7, eval('v:lua.foo(3,4,v:null)'))
|
||||||
eq(true, exec_lua([[return _G.val == vim.NIL]]))
|
eq(true, exec_lua([[return _G.val == vim.NIL]]))
|
||||||
eq(NIL, eval('v:lua.mymod.noisy("eval")'))
|
eq(NIL, eval('v:lua.mymod.noisy("eval")'))
|
||||||
eq("hey eval", meths.get_current_line())
|
eq("hey eval", meths.nvim_get_current_line())
|
||||||
eq("string: abc", eval('v:lua.mymod.whatis(0z616263)'))
|
eq("string: abc", eval('v:lua.mymod.whatis(0z616263)'))
|
||||||
eq("string: ", eval('v:lua.mymod.whatis(v:_null_blob)'))
|
eq("string: ", eval('v:lua.mymod.whatis(v:_null_blob)'))
|
||||||
|
|
||||||
@@ -494,7 +494,7 @@ describe('v:lua', function()
|
|||||||
eq("boop", exec_lua([[return _G.val]]))
|
eq("boop", exec_lua([[return _G.val]]))
|
||||||
|
|
||||||
eq(NIL, eval('"there"->v:lua.mymod.noisy()'))
|
eq(NIL, eval('"there"->v:lua.mymod.noisy()'))
|
||||||
eq("hey there", meths.get_current_line())
|
eq("hey there", meths.nvim_get_current_line())
|
||||||
eq({5, 10, 15, 20}, eval('[[1], [2, 3], [4]]->v:lua.vim.tbl_flatten()->map({_, v -> v * 5})'))
|
eq({5, 10, 15, 20}, eval('[[1], [2, 3], [4]]->v:lua.vim.tbl_flatten()->map({_, v -> v * 5})'))
|
||||||
|
|
||||||
eq("Vim:E5108: Error executing lua [string \"<nvim>\"]:0: attempt to call global 'nonexistent' (a nil value)",
|
eq("Vim:E5108: Error executing lua [string \"<nvim>\"]:0: attempt to call global 'nonexistent' (a nil value)",
|
||||||
@@ -503,7 +503,7 @@ describe('v:lua', function()
|
|||||||
|
|
||||||
it('works in :call', function()
|
it('works in :call', function()
|
||||||
command(":call v:lua.mymod.noisy('command')")
|
command(":call v:lua.mymod.noisy('command')")
|
||||||
eq("hey command", meths.get_current_line())
|
eq("hey command", meths.nvim_get_current_line())
|
||||||
eq("Vim(call):E5108: Error executing lua [string \"<nvim>\"]:0: attempt to call global 'nonexistent' (a nil value)",
|
eq("Vim(call):E5108: Error executing lua [string \"<nvim>\"]:0: attempt to call global 'nonexistent' (a nil value)",
|
||||||
pcall_err(command, 'call v:lua.mymod.crashy()'))
|
pcall_err(command, 'call v:lua.mymod.crashy()'))
|
||||||
end)
|
end)
|
||||||
@@ -518,7 +518,7 @@ describe('v:lua', function()
|
|||||||
[5] = {bold = true, foreground = Screen.colors.SeaGreen4},
|
[5] = {bold = true, foreground = Screen.colors.SeaGreen4},
|
||||||
})
|
})
|
||||||
screen:attach()
|
screen:attach()
|
||||||
meths.set_option_value('omnifunc', 'v:lua.mymod.omni', {})
|
meths.nvim_set_option_value('omnifunc', 'v:lua.mymod.omni', {})
|
||||||
feed('isome st<c-x><c-o>')
|
feed('isome st<c-x><c-o>')
|
||||||
screen:expect{grid=[[
|
screen:expect{grid=[[
|
||||||
some stuff^ |
|
some stuff^ |
|
||||||
@@ -528,9 +528,9 @@ describe('v:lua', function()
|
|||||||
{1:~ }|*3
|
{1:~ }|*3
|
||||||
{4:-- Omni completion (^O^N^P) }{5:match 1 of 3} |
|
{4:-- Omni completion (^O^N^P) }{5:match 1 of 3} |
|
||||||
]]}
|
]]}
|
||||||
meths.set_option_value('operatorfunc', 'v:lua.mymod.noisy', {})
|
meths.nvim_set_option_value('operatorfunc', 'v:lua.mymod.noisy', {})
|
||||||
feed('<Esc>g@g@')
|
feed('<Esc>g@g@')
|
||||||
eq("hey line", meths.get_current_line())
|
eq("hey line", meths.nvim_get_current_line())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('supports packages', function()
|
it('supports packages', function()
|
||||||
|
@@ -113,7 +113,7 @@ describe('print', function()
|
|||||||
eq('Vim(lua):E5108: Error executing lua [NULL]', pcall_err(command, 'lua bad_custom_error()'))
|
eq('Vim(lua):E5108: Error executing lua [NULL]', pcall_err(command, 'lua bad_custom_error()'))
|
||||||
end)
|
end)
|
||||||
it('prints strings with NULs and NLs correctly', function()
|
it('prints strings with NULs and NLs correctly', function()
|
||||||
meths.set_option_value('more', true, {})
|
meths.nvim_set_option_value('more', true, {})
|
||||||
eq(
|
eq(
|
||||||
'abc ^@ def\nghi^@^@^@jkl\nTEST\n\n\nT\n',
|
'abc ^@ def\nghi^@^@^@jkl\nTEST\n\n\nT\n',
|
||||||
exec_capture([[lua print("abc \0 def\nghi\0\0\0jkl\nTEST\n\n\nT\n")]])
|
exec_capture([[lua print("abc \0 def\nghi\0\0\0jkl\nTEST\n\n\nT\n")]])
|
||||||
@@ -341,7 +341,7 @@ describe('os.getenv', function()
|
|||||||
end)
|
end)
|
||||||
it('returns env var set by let', function()
|
it('returns env var set by let', function()
|
||||||
local value = 'foo'
|
local value = 'foo'
|
||||||
meths.command('let $XTEST_1 = "' .. value .. '"')
|
meths.nvim_command('let $XTEST_1 = "' .. value .. '"')
|
||||||
eq(value, funcs.luaeval('os.getenv("XTEST_1")'))
|
eq(value, funcs.luaeval('os.getenv("XTEST_1")'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
@@ -170,7 +170,7 @@ describe('vim.secure', function()
|
|||||||
|
|
||||||
-- Cannot write file
|
-- Cannot write file
|
||||||
pcall_err(command, 'write')
|
pcall_err(command, 'write')
|
||||||
eq(true, meths.get_option_value('readonly', {}))
|
eq(true, meths.nvim_get_option_value('readonly', {}))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@@ -1205,7 +1205,7 @@ describe('lua stdlib', function()
|
|||||||
chan = vim.fn.jobstart({'cat'}, {rpc=true})
|
chan = vim.fn.jobstart({'cat'}, {rpc=true})
|
||||||
vim.rpcrequest(chan, 'nvim_set_current_line', 'meow')
|
vim.rpcrequest(chan, 'nvim_set_current_line', 'meow')
|
||||||
]])
|
]])
|
||||||
eq('meow', meths.get_current_line())
|
eq('meow', meths.nvim_get_current_line())
|
||||||
command("let x = [3, 'aa', v:true, v:null]")
|
command("let x = [3, 'aa', v:true, v:null]")
|
||||||
eq(
|
eq(
|
||||||
true,
|
true,
|
||||||
@@ -1250,7 +1250,7 @@ describe('lua stdlib', function()
|
|||||||
]])
|
]])
|
||||||
)
|
)
|
||||||
retry(10, nil, function()
|
retry(10, nil, function()
|
||||||
eq('foo', meths.get_current_line())
|
eq('foo', meths.nvim_get_current_line())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local screen = Screen.new(50, 7)
|
local screen = Screen.new(50, 7)
|
||||||
@@ -1282,7 +1282,7 @@ describe('lua stdlib', function()
|
|||||||
]],
|
]],
|
||||||
}
|
}
|
||||||
feed('<cr>')
|
feed('<cr>')
|
||||||
eq({ 3, NIL }, meths.get_var('yy'))
|
eq({ 3, NIL }, meths.nvim_get_var('yy'))
|
||||||
|
|
||||||
exec_lua([[timer:close()]])
|
exec_lua([[timer:close()]])
|
||||||
end)
|
end)
|
||||||
@@ -1845,18 +1845,18 @@ describe('lua stdlib', function()
|
|||||||
eq({}, eval('v:oldfiles'))
|
eq({}, eval('v:oldfiles'))
|
||||||
|
|
||||||
feed('i foo foo foo<Esc>0/foo<CR>')
|
feed('i foo foo foo<Esc>0/foo<CR>')
|
||||||
eq({ 1, 1 }, meths.win_get_cursor(0))
|
eq({ 1, 1 }, meths.nvim_win_get_cursor(0))
|
||||||
eq(1, eval('v:searchforward'))
|
eq(1, eval('v:searchforward'))
|
||||||
feed('n')
|
feed('n')
|
||||||
eq({ 1, 5 }, meths.win_get_cursor(0))
|
eq({ 1, 5 }, meths.nvim_win_get_cursor(0))
|
||||||
exec_lua([[vim.v.searchforward = 0]])
|
exec_lua([[vim.v.searchforward = 0]])
|
||||||
eq(0, eval('v:searchforward'))
|
eq(0, eval('v:searchforward'))
|
||||||
feed('n')
|
feed('n')
|
||||||
eq({ 1, 1 }, meths.win_get_cursor(0))
|
eq({ 1, 1 }, meths.nvim_win_get_cursor(0))
|
||||||
exec_lua([[vim.v.searchforward = 1]])
|
exec_lua([[vim.v.searchforward = 1]])
|
||||||
eq(1, eval('v:searchforward'))
|
eq(1, eval('v:searchforward'))
|
||||||
feed('n')
|
feed('n')
|
||||||
eq({ 1, 5 }, meths.win_get_cursor(0))
|
eq({ 1, 5 }, meths.nvim_win_get_cursor(0))
|
||||||
|
|
||||||
local screen = Screen.new(60, 3)
|
local screen = Screen.new(60, 3)
|
||||||
screen:set_default_attr_ids({
|
screen:set_default_attr_ids({
|
||||||
@@ -2886,7 +2886,7 @@ describe('lua stdlib', function()
|
|||||||
eq({}, exec_lua [[return {re1:match_str("x ac")}]])
|
eq({}, exec_lua [[return {re1:match_str("x ac")}]])
|
||||||
eq({ 3, 7 }, exec_lua [[return {re1:match_str("ac abbc")}]])
|
eq({ 3, 7 }, exec_lua [[return {re1:match_str("ac abbc")}]])
|
||||||
|
|
||||||
meths.buf_set_lines(0, 0, -1, true, { 'yy', 'abc abbc' })
|
meths.nvim_buf_set_lines(0, 0, -1, true, { 'yy', 'abc abbc' })
|
||||||
eq({}, exec_lua [[return {re1:match_line(0, 0)}]])
|
eq({}, exec_lua [[return {re1:match_line(0, 0)}]])
|
||||||
eq({ 0, 3 }, exec_lua [[return {re1:match_line(0, 1)}]])
|
eq({ 0, 3 }, exec_lua [[return {re1:match_line(0, 1)}]])
|
||||||
eq({ 3, 7 }, exec_lua [[return {re1:match_line(0, 1, 1)}]])
|
eq({ 3, 7 }, exec_lua [[return {re1:match_line(0, 1, 1)}]])
|
||||||
@@ -2970,10 +2970,10 @@ describe('lua stdlib', function()
|
|||||||
|
|
||||||
it('allows removing on_key listeners', function()
|
it('allows removing on_key listeners', function()
|
||||||
-- Create some unused namespaces
|
-- Create some unused namespaces
|
||||||
meths.create_namespace('unused1')
|
meths.nvim_create_namespace('unused1')
|
||||||
meths.create_namespace('unused2')
|
meths.nvim_create_namespace('unused2')
|
||||||
meths.create_namespace('unused3')
|
meths.nvim_create_namespace('unused3')
|
||||||
meths.create_namespace('unused4')
|
meths.nvim_create_namespace('unused4')
|
||||||
|
|
||||||
insert([[hello world]])
|
insert([[hello world]])
|
||||||
|
|
||||||
@@ -3303,8 +3303,8 @@ describe('lua stdlib', function()
|
|||||||
|
|
||||||
describe('returns -2 when interrupted', function()
|
describe('returns -2 when interrupted', function()
|
||||||
before_each(function()
|
before_each(function()
|
||||||
local channel = meths.get_api_info()[1]
|
local channel = meths.nvim_get_api_info()[1]
|
||||||
meths.set_var('channel', channel)
|
meths.nvim_set_var('channel', channel)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('without callback', function()
|
it('without callback', function()
|
||||||
@@ -3408,14 +3408,14 @@ describe('lua stdlib', function()
|
|||||||
|
|
||||||
describe('vim.api.nvim_buf_call', function()
|
describe('vim.api.nvim_buf_call', function()
|
||||||
it('can access buf options', function()
|
it('can access buf options', function()
|
||||||
local buf1 = meths.get_current_buf().id
|
local buf1 = meths.nvim_get_current_buf().id
|
||||||
local buf2 = exec_lua [[
|
local buf2 = exec_lua [[
|
||||||
buf2 = vim.api.nvim_create_buf(false, true)
|
buf2 = vim.api.nvim_create_buf(false, true)
|
||||||
return buf2
|
return buf2
|
||||||
]]
|
]]
|
||||||
|
|
||||||
eq(false, meths.get_option_value('autoindent', { buf = buf1 }))
|
eq(false, meths.nvim_get_option_value('autoindent', { buf = buf1 }))
|
||||||
eq(false, meths.get_option_value('autoindent', { buf = buf2 }))
|
eq(false, meths.nvim_get_option_value('autoindent', { buf = buf2 }))
|
||||||
|
|
||||||
local val = exec_lua [[
|
local val = exec_lua [[
|
||||||
return vim.api.nvim_buf_call(buf2, function()
|
return vim.api.nvim_buf_call(buf2, function()
|
||||||
@@ -3424,9 +3424,9 @@ describe('lua stdlib', function()
|
|||||||
end)
|
end)
|
||||||
]]
|
]]
|
||||||
|
|
||||||
eq(false, meths.get_option_value('autoindent', { buf = buf1 }))
|
eq(false, meths.nvim_get_option_value('autoindent', { buf = buf1 }))
|
||||||
eq(true, meths.get_option_value('autoindent', { buf = buf2 }))
|
eq(true, meths.nvim_get_option_value('autoindent', { buf = buf2 }))
|
||||||
eq(buf1, meths.get_current_buf().id)
|
eq(buf1, meths.nvim_get_current_buf().id)
|
||||||
eq(buf2, val)
|
eq(buf2, val)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -3488,7 +3488,7 @@ describe('lua stdlib', function()
|
|||||||
describe('vim.api.nvim_win_call', function()
|
describe('vim.api.nvim_win_call', function()
|
||||||
it('can access window options', function()
|
it('can access window options', function()
|
||||||
command('vsplit')
|
command('vsplit')
|
||||||
local win1 = meths.get_current_win().id
|
local win1 = meths.nvim_get_current_win().id
|
||||||
command('wincmd w')
|
command('wincmd w')
|
||||||
local win2 = exec_lua [[
|
local win2 = exec_lua [[
|
||||||
win2 = vim.api.nvim_get_current_win()
|
win2 = vim.api.nvim_get_current_win()
|
||||||
@@ -3496,8 +3496,8 @@ describe('lua stdlib', function()
|
|||||||
]]
|
]]
|
||||||
command('wincmd p')
|
command('wincmd p')
|
||||||
|
|
||||||
eq('', meths.get_option_value('winhighlight', { win = win1 }))
|
eq('', meths.nvim_get_option_value('winhighlight', { win = win1 }))
|
||||||
eq('', meths.get_option_value('winhighlight', { win = win2 }))
|
eq('', meths.nvim_get_option_value('winhighlight', { win = win2 }))
|
||||||
|
|
||||||
local val = exec_lua [[
|
local val = exec_lua [[
|
||||||
return vim.api.nvim_win_call(win2, function()
|
return vim.api.nvim_win_call(win2, function()
|
||||||
@@ -3506,9 +3506,9 @@ describe('lua stdlib', function()
|
|||||||
end)
|
end)
|
||||||
]]
|
]]
|
||||||
|
|
||||||
eq('', meths.get_option_value('winhighlight', { win = win1 }))
|
eq('', meths.nvim_get_option_value('winhighlight', { win = win1 }))
|
||||||
eq('Normal:Normal', meths.get_option_value('winhighlight', { win = win2 }))
|
eq('Normal:Normal', meths.nvim_get_option_value('winhighlight', { win = win2 }))
|
||||||
eq(win1, meths.get_current_win().id)
|
eq(win1, meths.nvim_get_current_win().id)
|
||||||
eq(win2, val)
|
eq(win2, val)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -3882,7 +3882,7 @@ describe('vim.keymap', function()
|
|||||||
|
|
||||||
feed('aa')
|
feed('aa')
|
||||||
|
|
||||||
eq({ 'π<M-π>foo<' }, meths.buf_get_lines(0, 0, -1, false))
|
eq({ 'π<M-π>foo<' }, meths.nvim_buf_get_lines(0, 0, -1, false))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('can overwrite a mapping', function()
|
it('can overwrite a mapping', function()
|
||||||
|
@@ -203,7 +203,7 @@ describe("'listchars'", function()
|
|||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
meths._invalidate_glyph_cache()
|
meths.nvim__invalidate_glyph_cache()
|
||||||
screen:_reset()
|
screen:_reset()
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{1:d̞̄̃̒̉̎ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐l̞̀̄̆̌̚d̞̄̃̒̉̎ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐l̞̀̄̆̌̚d̞̄̃̒̉̎ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐l̞̀̄̆̌̚}^x{1:å̲} |
|
{1:d̞̄̃̒̉̎ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐l̞̀̄̆̌̚d̞̄̃̒̉̎ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐l̞̀̄̆̌̚d̞̄̃̒̉̎ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐ò́̌̌̂̐l̞̀̄̆̌̚}^x{1:å̲} |
|
||||||
|
@@ -195,8 +195,8 @@ describe('startup defaults', function()
|
|||||||
clear { args = {}, args_rm = { '-i' }, env = env }
|
clear { args = {}, args_rm = { '-i' }, env = env }
|
||||||
-- Default 'shadafile' is empty.
|
-- Default 'shadafile' is empty.
|
||||||
-- This means use the default location. :help shada-file-name
|
-- This means use the default location. :help shada-file-name
|
||||||
eq('', meths.get_option_value('shadafile', {}))
|
eq('', meths.nvim_get_option_value('shadafile', {}))
|
||||||
eq('', meths.get_option_value('viminfofile', {}))
|
eq('', meths.nvim_get_option_value('viminfofile', {}))
|
||||||
-- Handles viminfo/viminfofile as alias for shada/shadafile.
|
-- Handles viminfo/viminfofile as alias for shada/shadafile.
|
||||||
eq('\n shadafile=', eval('execute("set shadafile?")'))
|
eq('\n shadafile=', eval('execute("set shadafile?")'))
|
||||||
eq('\n shadafile=', eval('execute("set viminfofile?")'))
|
eq('\n shadafile=', eval('execute("set viminfofile?")'))
|
||||||
@@ -218,13 +218,13 @@ describe('startup defaults', function()
|
|||||||
args_rm = { 'runtimepath' },
|
args_rm = { 'runtimepath' },
|
||||||
}
|
}
|
||||||
-- Defaults to &runtimepath.
|
-- Defaults to &runtimepath.
|
||||||
eq(meths.get_option_value('runtimepath', {}), meths.get_option_value('packpath', {}))
|
eq(meths.nvim_get_option_value('runtimepath', {}), meths.nvim_get_option_value('packpath', {}))
|
||||||
|
|
||||||
-- Does not follow modifications to runtimepath.
|
-- Does not follow modifications to runtimepath.
|
||||||
meths.command('set runtimepath+=foo')
|
meths.nvim_command('set runtimepath+=foo')
|
||||||
neq(meths.get_option_value('runtimepath', {}), meths.get_option_value('packpath', {}))
|
neq(meths.nvim_get_option_value('runtimepath', {}), meths.nvim_get_option_value('packpath', {}))
|
||||||
meths.command('set packpath+=foo')
|
meths.nvim_command('set packpath+=foo')
|
||||||
eq(meths.get_option_value('runtimepath', {}), meths.get_option_value('packpath', {}))
|
eq(meths.nvim_get_option_value('runtimepath', {}), meths.nvim_get_option_value('packpath', {}))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('v:progpath is set to the absolute path', function()
|
it('v:progpath is set to the absolute path', function()
|
||||||
@@ -316,10 +316,10 @@ describe('XDG defaults', function()
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
eq('.', meths.get_option_value('backupdir', {}))
|
eq('.', meths.nvim_get_option_value('backupdir', {}))
|
||||||
eq('.', meths.get_option_value('viewdir', {}))
|
eq('.', meths.nvim_get_option_value('viewdir', {}))
|
||||||
eq('.', meths.get_option_value('directory', {}))
|
eq('.', meths.nvim_get_option_value('directory', {}))
|
||||||
eq('.', meths.get_option_value('undodir', {}))
|
eq('.', meths.nvim_get_option_value('undodir', {}))
|
||||||
ok((funcs.tempname()):len() > 4)
|
ok((funcs.tempname()):len() > 4)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
@@ -328,7 +328,7 @@ describe('XDG defaults', function()
|
|||||||
local vimruntime = eval('$VIMRUNTIME')
|
local vimruntime = eval('$VIMRUNTIME')
|
||||||
-- libdir is hard to calculate reliably across various ci platforms
|
-- libdir is hard to calculate reliably across various ci platforms
|
||||||
-- local libdir = string.gsub(vimruntime, "share/nvim/runtime$", "lib/nvim")
|
-- local libdir = string.gsub(vimruntime, "share/nvim/runtime$", "lib/nvim")
|
||||||
local libdir = meths._get_lib_dir()
|
local libdir = meths.nvim__get_lib_dir()
|
||||||
return vimruntime, libdir
|
return vimruntime, libdir
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -428,13 +428,13 @@ describe('XDG defaults', function()
|
|||||||
.. '/nvim/after'
|
.. '/nvim/after'
|
||||||
):gsub('\\', '/')
|
):gsub('\\', '/')
|
||||||
),
|
),
|
||||||
(meths.get_option_value('runtimepath', {})):gsub('\\', '/')
|
(meths.nvim_get_option_value('runtimepath', {})):gsub('\\', '/')
|
||||||
)
|
)
|
||||||
meths.command('set runtimepath&')
|
meths.nvim_command('set runtimepath&')
|
||||||
meths.command('set backupdir&')
|
meths.nvim_command('set backupdir&')
|
||||||
meths.command('set directory&')
|
meths.nvim_command('set directory&')
|
||||||
meths.command('set undodir&')
|
meths.nvim_command('set undodir&')
|
||||||
meths.command('set viewdir&')
|
meths.nvim_command('set viewdir&')
|
||||||
eq(
|
eq(
|
||||||
(
|
(
|
||||||
(
|
(
|
||||||
@@ -499,23 +499,23 @@ describe('XDG defaults', function()
|
|||||||
.. '/nvim/after'
|
.. '/nvim/after'
|
||||||
):gsub('\\', '/')
|
):gsub('\\', '/')
|
||||||
),
|
),
|
||||||
(meths.get_option_value('runtimepath', {})):gsub('\\', '/')
|
(meths.nvim_get_option_value('runtimepath', {})):gsub('\\', '/')
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
'.,' .. root_path .. ('/X'):rep(4096) .. '/' .. state_dir .. '/backup//',
|
'.,' .. root_path .. ('/X'):rep(4096) .. '/' .. state_dir .. '/backup//',
|
||||||
(meths.get_option_value('backupdir', {}):gsub('\\', '/'))
|
(meths.nvim_get_option_value('backupdir', {}):gsub('\\', '/'))
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
root_path .. ('/X'):rep(4096) .. '/' .. state_dir .. '/swap//',
|
root_path .. ('/X'):rep(4096) .. '/' .. state_dir .. '/swap//',
|
||||||
(meths.get_option_value('directory', {})):gsub('\\', '/')
|
(meths.nvim_get_option_value('directory', {})):gsub('\\', '/')
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
root_path .. ('/X'):rep(4096) .. '/' .. state_dir .. '/undo//',
|
root_path .. ('/X'):rep(4096) .. '/' .. state_dir .. '/undo//',
|
||||||
(meths.get_option_value('undodir', {})):gsub('\\', '/')
|
(meths.nvim_get_option_value('undodir', {})):gsub('\\', '/')
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
root_path .. ('/X'):rep(4096) .. '/' .. state_dir .. '/view//',
|
root_path .. ('/X'):rep(4096) .. '/' .. state_dir .. '/view//',
|
||||||
(meths.get_option_value('viewdir', {})):gsub('\\', '/')
|
(meths.nvim_get_option_value('viewdir', {})):gsub('\\', '/')
|
||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
@@ -571,13 +571,13 @@ describe('XDG defaults', function()
|
|||||||
.. ',$XDG_DATA_HOME/nvim/after'
|
.. ',$XDG_DATA_HOME/nvim/after'
|
||||||
):gsub('\\', '/')
|
):gsub('\\', '/')
|
||||||
),
|
),
|
||||||
(meths.get_option_value('runtimepath', {})):gsub('\\', '/')
|
(meths.nvim_get_option_value('runtimepath', {})):gsub('\\', '/')
|
||||||
)
|
)
|
||||||
meths.command('set runtimepath&')
|
meths.nvim_command('set runtimepath&')
|
||||||
meths.command('set backupdir&')
|
meths.nvim_command('set backupdir&')
|
||||||
meths.command('set directory&')
|
meths.nvim_command('set directory&')
|
||||||
meths.command('set undodir&')
|
meths.nvim_command('set undodir&')
|
||||||
meths.command('set viewdir&')
|
meths.nvim_command('set viewdir&')
|
||||||
eq(
|
eq(
|
||||||
(
|
(
|
||||||
(
|
(
|
||||||
@@ -599,25 +599,25 @@ describe('XDG defaults', function()
|
|||||||
.. ',$XDG_DATA_HOME/nvim/after'
|
.. ',$XDG_DATA_HOME/nvim/after'
|
||||||
):gsub('\\', '/')
|
):gsub('\\', '/')
|
||||||
),
|
),
|
||||||
(meths.get_option_value('runtimepath', {})):gsub('\\', '/')
|
(meths.nvim_get_option_value('runtimepath', {})):gsub('\\', '/')
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
('.,$XDG_CONFIG_HOME/' .. state_dir .. '/backup//'),
|
('.,$XDG_CONFIG_HOME/' .. state_dir .. '/backup//'),
|
||||||
meths.get_option_value('backupdir', {}):gsub('\\', '/')
|
meths.nvim_get_option_value('backupdir', {}):gsub('\\', '/')
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
('$XDG_CONFIG_HOME/' .. state_dir .. '/swap//'),
|
('$XDG_CONFIG_HOME/' .. state_dir .. '/swap//'),
|
||||||
meths.get_option_value('directory', {}):gsub('\\', '/')
|
meths.nvim_get_option_value('directory', {}):gsub('\\', '/')
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
('$XDG_CONFIG_HOME/' .. state_dir .. '/undo//'),
|
('$XDG_CONFIG_HOME/' .. state_dir .. '/undo//'),
|
||||||
meths.get_option_value('undodir', {}):gsub('\\', '/')
|
meths.nvim_get_option_value('undodir', {}):gsub('\\', '/')
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
('$XDG_CONFIG_HOME/' .. state_dir .. '/view//'),
|
('$XDG_CONFIG_HOME/' .. state_dir .. '/view//'),
|
||||||
meths.get_option_value('viewdir', {}):gsub('\\', '/')
|
meths.nvim_get_option_value('viewdir', {}):gsub('\\', '/')
|
||||||
)
|
)
|
||||||
meths.command('set all&')
|
meths.nvim_command('set all&')
|
||||||
eq(
|
eq(
|
||||||
(
|
(
|
||||||
'$XDG_DATA_HOME/nvim'
|
'$XDG_DATA_HOME/nvim'
|
||||||
@@ -637,23 +637,23 @@ describe('XDG defaults', function()
|
|||||||
.. ',$XDG_DATA_DIRS/nvim/after'
|
.. ',$XDG_DATA_DIRS/nvim/after'
|
||||||
.. ',$XDG_DATA_HOME/nvim/after'
|
.. ',$XDG_DATA_HOME/nvim/after'
|
||||||
):gsub('\\', '/'),
|
):gsub('\\', '/'),
|
||||||
(meths.get_option_value('runtimepath', {})):gsub('\\', '/')
|
(meths.nvim_get_option_value('runtimepath', {})):gsub('\\', '/')
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
('.,$XDG_CONFIG_HOME/' .. state_dir .. '/backup//'),
|
('.,$XDG_CONFIG_HOME/' .. state_dir .. '/backup//'),
|
||||||
meths.get_option_value('backupdir', {}):gsub('\\', '/')
|
meths.nvim_get_option_value('backupdir', {}):gsub('\\', '/')
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
('$XDG_CONFIG_HOME/' .. state_dir .. '/swap//'),
|
('$XDG_CONFIG_HOME/' .. state_dir .. '/swap//'),
|
||||||
meths.get_option_value('directory', {}):gsub('\\', '/')
|
meths.nvim_get_option_value('directory', {}):gsub('\\', '/')
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
('$XDG_CONFIG_HOME/' .. state_dir .. '/undo//'),
|
('$XDG_CONFIG_HOME/' .. state_dir .. '/undo//'),
|
||||||
meths.get_option_value('undodir', {}):gsub('\\', '/')
|
meths.nvim_get_option_value('undodir', {}):gsub('\\', '/')
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
('$XDG_CONFIG_HOME/' .. state_dir .. '/view//'),
|
('$XDG_CONFIG_HOME/' .. state_dir .. '/view//'),
|
||||||
meths.get_option_value('viewdir', {}):gsub('\\', '/')
|
meths.nvim_get_option_value('viewdir', {}):gsub('\\', '/')
|
||||||
)
|
)
|
||||||
eq(nil, (funcs.tempname()):match('XDG_RUNTIME_DIR'))
|
eq(nil, (funcs.tempname()):match('XDG_RUNTIME_DIR'))
|
||||||
end)
|
end)
|
||||||
@@ -743,13 +743,13 @@ describe('XDG defaults', function()
|
|||||||
.. path_sep
|
.. path_sep
|
||||||
.. 'after'
|
.. 'after'
|
||||||
),
|
),
|
||||||
meths.get_option_value('runtimepath', {})
|
meths.nvim_get_option_value('runtimepath', {})
|
||||||
)
|
)
|
||||||
meths.command('set runtimepath&')
|
meths.nvim_command('set runtimepath&')
|
||||||
meths.command('set backupdir&')
|
meths.nvim_command('set backupdir&')
|
||||||
meths.command('set directory&')
|
meths.nvim_command('set directory&')
|
||||||
meths.command('set undodir&')
|
meths.nvim_command('set undodir&')
|
||||||
meths.command('set viewdir&')
|
meths.nvim_command('set viewdir&')
|
||||||
eq(
|
eq(
|
||||||
(
|
(
|
||||||
'\\, \\, \\,'
|
'\\, \\, \\,'
|
||||||
@@ -821,11 +821,11 @@ describe('XDG defaults', function()
|
|||||||
.. path_sep
|
.. path_sep
|
||||||
.. 'after'
|
.. 'after'
|
||||||
),
|
),
|
||||||
meths.get_option_value('runtimepath', {})
|
meths.nvim_get_option_value('runtimepath', {})
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
'.,\\,=\\,=\\,' .. path_sep .. state_dir .. '' .. path_sep .. 'backup' .. (path_sep):rep(2),
|
'.,\\,=\\,=\\,' .. path_sep .. state_dir .. '' .. path_sep .. 'backup' .. (path_sep):rep(2),
|
||||||
meths.get_option_value('backupdir', {})
|
meths.nvim_get_option_value('backupdir', {})
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
'\\,=\\,=\\,'
|
'\\,=\\,=\\,'
|
||||||
@@ -836,7 +836,7 @@ describe('XDG defaults', function()
|
|||||||
.. path_sep
|
.. path_sep
|
||||||
.. 'swap'
|
.. 'swap'
|
||||||
.. (path_sep):rep(2),
|
.. (path_sep):rep(2),
|
||||||
meths.get_option_value('directory', {})
|
meths.nvim_get_option_value('directory', {})
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
'\\,=\\,=\\,'
|
'\\,=\\,=\\,'
|
||||||
@@ -847,7 +847,7 @@ describe('XDG defaults', function()
|
|||||||
.. path_sep
|
.. path_sep
|
||||||
.. 'undo'
|
.. 'undo'
|
||||||
.. (path_sep):rep(2),
|
.. (path_sep):rep(2),
|
||||||
meths.get_option_value('undodir', {})
|
meths.nvim_get_option_value('undodir', {})
|
||||||
)
|
)
|
||||||
eq(
|
eq(
|
||||||
'\\,=\\,=\\,'
|
'\\,=\\,=\\,'
|
||||||
@@ -858,7 +858,7 @@ describe('XDG defaults', function()
|
|||||||
.. path_sep
|
.. path_sep
|
||||||
.. 'view'
|
.. 'view'
|
||||||
.. (path_sep):rep(2),
|
.. (path_sep):rep(2),
|
||||||
meths.get_option_value('viewdir', {})
|
meths.nvim_get_option_value('viewdir', {})
|
||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
@@ -1112,7 +1112,7 @@ describe('stdpath()', function()
|
|||||||
|
|
||||||
local function set_paths_at_runtime(var_name, paths)
|
local function set_paths_at_runtime(var_name, paths)
|
||||||
clear({ env = base_env() })
|
clear({ env = base_env() })
|
||||||
meths.set_var('env_val', table.concat(paths, env_sep))
|
meths.nvim_set_var('env_val', table.concat(paths, env_sep))
|
||||||
command(('let $%s=g:env_val'):format(var_name))
|
command(('let $%s=g:env_val'):format(var_name))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@@ -11,7 +11,7 @@ local function should_fail(opt, value, errmsg)
|
|||||||
feed_command('setlocal ' .. opt .. '=' .. value)
|
feed_command('setlocal ' .. opt .. '=' .. value)
|
||||||
eq(errmsg, eval('v:errmsg'):match('E%d*'))
|
eq(errmsg, eval('v:errmsg'):match('E%d*'))
|
||||||
feed_command('let v:errmsg = ""')
|
feed_command('let v:errmsg = ""')
|
||||||
local status, err = pcall(meths.set_option_value, opt, value, {})
|
local status, err = pcall(meths.nvim_set_option_value, opt, value, {})
|
||||||
eq(status, false)
|
eq(status, false)
|
||||||
eq(errmsg, err:match('E%d*'))
|
eq(errmsg, err:match('E%d*'))
|
||||||
eq('', eval('v:errmsg'))
|
eq('', eval('v:errmsg'))
|
||||||
@@ -20,8 +20,8 @@ end
|
|||||||
local function should_succeed(opt, value)
|
local function should_succeed(opt, value)
|
||||||
feed_command('setglobal ' .. opt .. '=' .. value)
|
feed_command('setglobal ' .. opt .. '=' .. value)
|
||||||
feed_command('setlocal ' .. opt .. '=' .. value)
|
feed_command('setlocal ' .. opt .. '=' .. value)
|
||||||
meths.set_option_value(opt, value, {})
|
meths.nvim_set_option_value(opt, value, {})
|
||||||
eq(value, meths.get_option_value(opt, {}))
|
eq(value, meths.nvim_get_option_value(opt, {}))
|
||||||
eq('', eval('v:errmsg'))
|
eq('', eval('v:errmsg'))
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -29,12 +29,12 @@ describe(':setlocal', function()
|
|||||||
before_each(clear)
|
before_each(clear)
|
||||||
|
|
||||||
it('setlocal sets only local value', function()
|
it('setlocal sets only local value', function()
|
||||||
eq(0, meths.get_option_value('iminsert', { scope = 'global' }))
|
eq(0, meths.nvim_get_option_value('iminsert', { scope = 'global' }))
|
||||||
feed_command('setlocal iminsert=1')
|
feed_command('setlocal iminsert=1')
|
||||||
eq(0, meths.get_option_value('iminsert', { scope = 'global' }))
|
eq(0, meths.nvim_get_option_value('iminsert', { scope = 'global' }))
|
||||||
eq(-1, meths.get_option_value('imsearch', { scope = 'global' }))
|
eq(-1, meths.nvim_get_option_value('imsearch', { scope = 'global' }))
|
||||||
feed_command('setlocal imsearch=1')
|
feed_command('setlocal imsearch=1')
|
||||||
eq(-1, meths.get_option_value('imsearch', { scope = 'global' }))
|
eq(-1, meths.nvim_get_option_value('imsearch', { scope = 'global' }))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -77,8 +77,8 @@ describe(':set validation', function()
|
|||||||
|
|
||||||
-- If smaller than 1 this one is set to 'lines'-1
|
-- If smaller than 1 this one is set to 'lines'-1
|
||||||
feed_command('setglobal window=-10')
|
feed_command('setglobal window=-10')
|
||||||
meths.set_option_value('window', -10, {})
|
meths.nvim_set_option_value('window', -10, {})
|
||||||
eq(23, meths.get_option_value('window', {}))
|
eq(23, meths.nvim_get_option_value('window', {}))
|
||||||
eq('', eval('v:errmsg'))
|
eq('', eval('v:errmsg'))
|
||||||
|
|
||||||
-- 'scrolloff' and 'sidescrolloff' can have a -1 value when
|
-- 'scrolloff' and 'sidescrolloff' can have a -1 value when
|
||||||
@@ -112,8 +112,8 @@ describe(':set validation', function()
|
|||||||
local function setto(value)
|
local function setto(value)
|
||||||
feed_command('setglobal maxcombine=' .. value)
|
feed_command('setglobal maxcombine=' .. value)
|
||||||
feed_command('setlocal maxcombine=' .. value)
|
feed_command('setlocal maxcombine=' .. value)
|
||||||
meths.set_option_value('maxcombine', value, {})
|
meths.nvim_set_option_value('maxcombine', value, {})
|
||||||
eq(6, meths.get_option_value('maxcombine', {}))
|
eq(6, meths.nvim_get_option_value('maxcombine', {}))
|
||||||
eq('', eval('v:errmsg'))
|
eq('', eval('v:errmsg'))
|
||||||
end
|
end
|
||||||
setto(0)
|
setto(0)
|
||||||
|
@@ -13,7 +13,7 @@ local function test_case(name, expected)
|
|||||||
local filename = testdir .. pathsep .. name
|
local filename = testdir .. pathsep .. name
|
||||||
command('edit ' .. filename)
|
command('edit ' .. filename)
|
||||||
for opt, val in pairs(expected) do
|
for opt, val in pairs(expected) do
|
||||||
eq(val, meths.get_option_value(opt, { buf = 0 }), name)
|
eq(val, meths.nvim_get_option_value(opt, { buf = 0 }), name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -195,15 +195,15 @@ But not this one
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('can be disabled globally', function()
|
it('can be disabled globally', function()
|
||||||
meths.set_var('editorconfig', false)
|
meths.nvim_set_var('editorconfig', false)
|
||||||
meths.set_option_value('shiftwidth', 42, {})
|
meths.nvim_set_option_value('shiftwidth', 42, {})
|
||||||
test_case('3_space.txt', { shiftwidth = 42 })
|
test_case('3_space.txt', { shiftwidth = 42 })
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('can be disabled per-buffer', function()
|
it('can be disabled per-buffer', function()
|
||||||
meths.set_option_value('shiftwidth', 42, {})
|
meths.nvim_set_option_value('shiftwidth', 42, {})
|
||||||
local bufnr = funcs.bufadd(testdir .. pathsep .. '3_space.txt')
|
local bufnr = funcs.bufadd(testdir .. pathsep .. '3_space.txt')
|
||||||
meths.buf_set_var(bufnr, 'editorconfig', false)
|
meths.nvim_buf_set_var(bufnr, 'editorconfig', false)
|
||||||
test_case('3_space.txt', { shiftwidth = 42 })
|
test_case('3_space.txt', { shiftwidth = 42 })
|
||||||
test_case('4_space.py', { shiftwidth = 4 })
|
test_case('4_space.py', { shiftwidth = 4 })
|
||||||
end)
|
end)
|
||||||
|
@@ -62,7 +62,7 @@ local function test_edit(
|
|||||||
offset_encoding = offset_encoding or 'utf-16'
|
offset_encoding = offset_encoding or 'utf-16'
|
||||||
line_ending = line_ending or '\n'
|
line_ending = line_ending or '\n'
|
||||||
|
|
||||||
meths.buf_set_lines(0, 0, -1, true, prev_buffer)
|
meths.nvim_buf_set_lines(0, 0, -1, true, prev_buffer)
|
||||||
exec_lua('return test_register(...)', 0, 'test1', offset_encoding, line_ending)
|
exec_lua('return test_register(...)', 0, 'test1', offset_encoding, line_ending)
|
||||||
|
|
||||||
for _, edit in ipairs(edit_operations) do
|
for _, edit in ipairs(edit_operations) do
|
||||||
|
@@ -363,9 +363,9 @@ describe('LSP', function()
|
|||||||
end,
|
end,
|
||||||
on_handler = function(_, _, ctx)
|
on_handler = function(_, _, ctx)
|
||||||
if ctx.method == 'finish' then
|
if ctx.method == 'finish' then
|
||||||
eq('basic_init', meths.get_var('lsp_attached'))
|
eq('basic_init', meths.nvim_get_var('lsp_attached'))
|
||||||
exec_lua('return lsp.buf_detach_client(BUFFER, TEST_RPC_CLIENT_ID)')
|
exec_lua('return lsp.buf_detach_client(BUFFER, TEST_RPC_CLIENT_ID)')
|
||||||
eq('basic_init', meths.get_var('lsp_detached'))
|
eq('basic_init', meths.nvim_get_var('lsp_detached'))
|
||||||
client.stop()
|
client.stop()
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
@@ -22,7 +22,7 @@ describe('matchparen', function()
|
|||||||
|
|
||||||
it('uses correct column after i_<Up>. Vim patch 7.4.1296', function()
|
it('uses correct column after i_<Up>. Vim patch 7.4.1296', function()
|
||||||
command('set noautoindent nosmartindent nocindent laststatus=0')
|
command('set noautoindent nosmartindent nocindent laststatus=0')
|
||||||
eq(1, meths.get_var('loaded_matchparen'))
|
eq(1, meths.nvim_get_var('loaded_matchparen'))
|
||||||
feed('ivoid f_test()<cr>')
|
feed('ivoid f_test()<cr>')
|
||||||
feed('{<cr>')
|
feed('{<cr>')
|
||||||
feed('}')
|
feed('}')
|
||||||
|
@@ -526,17 +526,17 @@ describe('autoload/msgpack.vim', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('works for special v: values like v:true', function()
|
it('works for special v: values like v:true', function()
|
||||||
meths.set_var('true', true)
|
meths.nvim_set_var('true', true)
|
||||||
meths.set_var('false', false)
|
meths.nvim_set_var('false', false)
|
||||||
meths.set_var('nil', NIL)
|
meths.nvim_set_var('nil', NIL)
|
||||||
|
|
||||||
nvim_command('let true2 = msgpack#deepcopy(true)')
|
nvim_command('let true2 = msgpack#deepcopy(true)')
|
||||||
nvim_command('let false2 = msgpack#deepcopy(false)')
|
nvim_command('let false2 = msgpack#deepcopy(false)')
|
||||||
nvim_command('let nil2 = msgpack#deepcopy(nil)')
|
nvim_command('let nil2 = msgpack#deepcopy(nil)')
|
||||||
|
|
||||||
eq(true, meths.get_var('true'))
|
eq(true, meths.nvim_get_var('true'))
|
||||||
eq(false, meths.get_var('false'))
|
eq(false, meths.nvim_get_var('false'))
|
||||||
eq(NIL, meths.get_var('nil'))
|
eq(NIL, meths.nvim_get_var('nil'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@@ -2644,7 +2644,8 @@ describe('plugin/shada.vim', function()
|
|||||||
wshada('\004\000\009\147\000\196\002ab\196\001a')
|
wshada('\004\000\009\147\000\196\002ab\196\001a')
|
||||||
wshada_tmp('\004\000\009\147\000\196\002ab\196\001b')
|
wshada_tmp('\004\000\009\147\000\196\002ab\196\001b')
|
||||||
|
|
||||||
local bufread_commands = meths.get_autocmds({ group = 'ShaDaCommands', event = 'BufReadCmd' })
|
local bufread_commands =
|
||||||
|
meths.nvim_get_autocmds({ group = 'ShaDaCommands', event = 'BufReadCmd' })
|
||||||
eq(2, #bufread_commands--[[, vim.inspect(bufread_commands) ]])
|
eq(2, #bufread_commands--[[, vim.inspect(bufread_commands) ]])
|
||||||
|
|
||||||
-- Need to set nohidden so that the buffer containing 'fname' is not unloaded
|
-- Need to set nohidden so that the buffer containing 'fname' is not unloaded
|
||||||
|
@@ -188,7 +188,7 @@ describe('clipboard', function()
|
|||||||
|
|
||||||
it('valid g:clipboard', function()
|
it('valid g:clipboard', function()
|
||||||
-- provider#clipboard#Executable() only checks the structure.
|
-- provider#clipboard#Executable() only checks the structure.
|
||||||
meths.set_var('clipboard', {
|
meths.nvim_set_var('clipboard', {
|
||||||
['name'] = 'clippy!',
|
['name'] = 'clippy!',
|
||||||
['copy'] = { ['+'] = 'any command', ['*'] = 'some other' },
|
['copy'] = { ['+'] = 'any command', ['*'] = 'some other' },
|
||||||
['paste'] = { ['+'] = 'any command', ['*'] = 'some other' },
|
['paste'] = { ['+'] = 'any command', ['*'] = 'some other' },
|
||||||
@@ -545,7 +545,7 @@ describe('clipboard (with fake clipboard.vim)', function()
|
|||||||
eq({ { 'text', '' }, 'V' }, eval("g:test_clip['*']"))
|
eq({ { 'text', '' }, 'V' }, eval("g:test_clip['*']"))
|
||||||
command("let g:test_clip['*'] = [['star'], 'c']")
|
command("let g:test_clip['*'] = [['star'], 'c']")
|
||||||
feed('p')
|
feed('p')
|
||||||
eq('textstar', meths.get_current_line())
|
eq('textstar', meths.nvim_get_current_line())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('Block paste works correctly', function()
|
it('Block paste works correctly', function()
|
||||||
|
@@ -48,7 +48,7 @@ describe('legacy perl provider', function()
|
|||||||
-- :perldo 1; doesn't change $_,
|
-- :perldo 1; doesn't change $_,
|
||||||
-- the buffer should not be changed
|
-- the buffer should not be changed
|
||||||
command('normal :perldo 1;')
|
command('normal :perldo 1;')
|
||||||
eq(false, meths.get_option_value('modified', {}))
|
eq(false, meths.nvim_get_option_value('modified', {}))
|
||||||
-- insert some text
|
-- insert some text
|
||||||
insert('abc\ndef\nghi')
|
insert('abc\ndef\nghi')
|
||||||
expect([[
|
expect([[
|
||||||
|
@@ -43,12 +43,12 @@ end)
|
|||||||
describe(':ruby command', function()
|
describe(':ruby command', function()
|
||||||
it('evaluates ruby', function()
|
it('evaluates ruby', function()
|
||||||
command('ruby VIM.command("let g:set_by_ruby = [100, 0]")')
|
command('ruby VIM.command("let g:set_by_ruby = [100, 0]")')
|
||||||
eq({ 100, 0 }, meths.get_var('set_by_ruby'))
|
eq({ 100, 0 }, meths.nvim_get_var('set_by_ruby'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('supports nesting', function()
|
it('supports nesting', function()
|
||||||
command([[ruby VIM.command('ruby VIM.command("let set_by_nested_ruby = 555")')]])
|
command([[ruby VIM.command('ruby VIM.command("let set_by_nested_ruby = 555")')]])
|
||||||
eq(555, meths.get_var('set_by_nested_ruby'))
|
eq(555, meths.nvim_get_var('set_by_nested_ruby'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ describe(':rubyfile command', function()
|
|||||||
local fname = 'rubyfile.rb'
|
local fname = 'rubyfile.rb'
|
||||||
write_file(fname, 'VIM.command("let set_by_rubyfile = 123")')
|
write_file(fname, 'VIM.command("let set_by_rubyfile = 123")')
|
||||||
command('rubyfile rubyfile.rb')
|
command('rubyfile rubyfile.rb')
|
||||||
eq(123, meths.get_var('set_by_rubyfile'))
|
eq(123, meths.nvim_get_var('set_by_rubyfile'))
|
||||||
os.remove(fname)
|
os.remove(fname)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
@@ -97,7 +97,7 @@ describe(':rubydo command', function()
|
|||||||
|
|
||||||
it('does not modify the buffer if no changes are made', function()
|
it('does not modify the buffer if no changes are made', function()
|
||||||
command('normal :rubydo 42')
|
command('normal :rubydo 42')
|
||||||
eq(false, meths.get_option_value('modified', {}))
|
eq(false, meths.nvim_get_option_value('modified', {}))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@@ -48,7 +48,7 @@ describe('shada support code', function()
|
|||||||
reset('set shada+=%')
|
reset('set shada+=%')
|
||||||
nvim_command('edit ' .. testfilename)
|
nvim_command('edit ' .. testfilename)
|
||||||
nvim_command('edit ' .. testfilename_2)
|
nvim_command('edit ' .. testfilename_2)
|
||||||
meths.set_option_value('buflisted', false, {})
|
meths.nvim_set_option_value('buflisted', false, {})
|
||||||
expect_exit(nvim_command, 'qall')
|
expect_exit(nvim_command, 'qall')
|
||||||
reset('set shada+=%')
|
reset('set shada+=%')
|
||||||
eq(2, funcs.bufnr('$'))
|
eq(2, funcs.bufnr('$'))
|
||||||
@@ -60,7 +60,7 @@ describe('shada support code', function()
|
|||||||
reset('set shada+=%')
|
reset('set shada+=%')
|
||||||
nvim_command('edit ' .. testfilename)
|
nvim_command('edit ' .. testfilename)
|
||||||
nvim_command('edit ' .. testfilename_2)
|
nvim_command('edit ' .. testfilename_2)
|
||||||
meths.set_option_value('buftype', 'quickfix', {})
|
meths.nvim_set_option_value('buftype', 'quickfix', {})
|
||||||
expect_exit(nvim_command, 'qall')
|
expect_exit(nvim_command, 'qall')
|
||||||
reset('set shada+=%')
|
reset('set shada+=%')
|
||||||
eq(2, funcs.bufnr('$'))
|
eq(2, funcs.bufnr('$'))
|
||||||
|
@@ -28,7 +28,7 @@ local function reset(o)
|
|||||||
args_rm = args_rm,
|
args_rm = args_rm,
|
||||||
args = args,
|
args = args,
|
||||||
}
|
}
|
||||||
meths.set_var('tmpname', tmpname)
|
meths.nvim_set_var('tmpname', tmpname)
|
||||||
end
|
end
|
||||||
|
|
||||||
local clear = function()
|
local clear = function()
|
||||||
|
@@ -104,40 +104,40 @@ describe('ShaDa support code', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('dumps and loads last search pattern with offset', function()
|
it('dumps and loads last search pattern with offset', function()
|
||||||
meths.set_option_value('wrapscan', false, {})
|
meths.nvim_set_option_value('wrapscan', false, {})
|
||||||
funcs.setline('.', { 'foo', 'bar--' })
|
funcs.setline('.', { 'foo', 'bar--' })
|
||||||
nvim_feed('gg0/a/e+1\n')
|
nvim_feed('gg0/a/e+1\n')
|
||||||
eq({ 0, 2, 3, 0 }, funcs.getpos('.'))
|
eq({ 0, 2, 3, 0 }, funcs.getpos('.'))
|
||||||
nvim_command('wshada')
|
nvim_command('wshada')
|
||||||
reset()
|
reset()
|
||||||
meths.set_option_value('wrapscan', false, {})
|
meths.nvim_set_option_value('wrapscan', false, {})
|
||||||
funcs.setline('.', { 'foo', 'bar--' })
|
funcs.setline('.', { 'foo', 'bar--' })
|
||||||
nvim_feed('gg0n')
|
nvim_feed('gg0n')
|
||||||
eq({ 0, 2, 3, 0 }, funcs.getpos('.'))
|
eq({ 0, 2, 3, 0 }, funcs.getpos('.'))
|
||||||
eq(1, meths.get_vvar('searchforward'))
|
eq(1, meths.nvim_get_vvar('searchforward'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('dumps and loads last search pattern with offset and backward direction', function()
|
it('dumps and loads last search pattern with offset and backward direction', function()
|
||||||
meths.set_option_value('wrapscan', false, {})
|
meths.nvim_set_option_value('wrapscan', false, {})
|
||||||
funcs.setline('.', { 'foo', 'bar--' })
|
funcs.setline('.', { 'foo', 'bar--' })
|
||||||
nvim_feed('G$?a?e+1\n')
|
nvim_feed('G$?a?e+1\n')
|
||||||
eq({ 0, 2, 3, 0 }, funcs.getpos('.'))
|
eq({ 0, 2, 3, 0 }, funcs.getpos('.'))
|
||||||
nvim_command('wshada')
|
nvim_command('wshada')
|
||||||
reset()
|
reset()
|
||||||
meths.set_option_value('wrapscan', false, {})
|
meths.nvim_set_option_value('wrapscan', false, {})
|
||||||
funcs.setline('.', { 'foo', 'bar--' })
|
funcs.setline('.', { 'foo', 'bar--' })
|
||||||
nvim_feed('G$n')
|
nvim_feed('G$n')
|
||||||
eq({ 0, 2, 3, 0 }, funcs.getpos('.'))
|
eq({ 0, 2, 3, 0 }, funcs.getpos('.'))
|
||||||
eq(0, meths.get_vvar('searchforward'))
|
eq(0, meths.nvim_get_vvar('searchforward'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('saves v:hlsearch=1', function()
|
it('saves v:hlsearch=1', function()
|
||||||
nvim_command('set hlsearch shada-=h')
|
nvim_command('set hlsearch shada-=h')
|
||||||
nvim_feed('/test\n')
|
nvim_feed('/test\n')
|
||||||
eq(1, meths.get_vvar('hlsearch'))
|
eq(1, meths.nvim_get_vvar('hlsearch'))
|
||||||
expect_exit(nvim_command, 'qall')
|
expect_exit(nvim_command, 'qall')
|
||||||
reset()
|
reset()
|
||||||
eq(1, meths.get_vvar('hlsearch'))
|
eq(1, meths.nvim_get_vvar('hlsearch'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('saves v:hlsearch=0 with :nohl', function()
|
it('saves v:hlsearch=0 with :nohl', function()
|
||||||
@@ -146,16 +146,16 @@ describe('ShaDa support code', function()
|
|||||||
nvim_command('nohlsearch')
|
nvim_command('nohlsearch')
|
||||||
expect_exit(nvim_command, 'qall')
|
expect_exit(nvim_command, 'qall')
|
||||||
reset()
|
reset()
|
||||||
eq(0, meths.get_vvar('hlsearch'))
|
eq(0, meths.nvim_get_vvar('hlsearch'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('saves v:hlsearch=0 with default &shada', function()
|
it('saves v:hlsearch=0 with default &shada', function()
|
||||||
nvim_command('set hlsearch')
|
nvim_command('set hlsearch')
|
||||||
nvim_feed('/test\n')
|
nvim_feed('/test\n')
|
||||||
eq(1, meths.get_vvar('hlsearch'))
|
eq(1, meths.nvim_get_vvar('hlsearch'))
|
||||||
expect_exit(nvim_command, 'qall')
|
expect_exit(nvim_command, 'qall')
|
||||||
reset()
|
reset()
|
||||||
eq(0, meths.get_vvar('hlsearch'))
|
eq(0, meths.nvim_get_vvar('hlsearch'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('dumps and loads last substitute pattern and replacement string', function()
|
it('dumps and loads last substitute pattern and replacement string', function()
|
||||||
|
@@ -124,7 +124,7 @@ describe('ShaDa support code', function()
|
|||||||
local tf_full_2 = curbufmeths.get_name()
|
local tf_full_2 = curbufmeths.get_name()
|
||||||
expect_exit(nvim_command, 'qall')
|
expect_exit(nvim_command, 'qall')
|
||||||
reset()
|
reset()
|
||||||
local oldfiles = meths.get_vvar('oldfiles')
|
local oldfiles = meths.nvim_get_vvar('oldfiles')
|
||||||
table.sort(oldfiles)
|
table.sort(oldfiles)
|
||||||
eq(2, #oldfiles)
|
eq(2, #oldfiles)
|
||||||
eq(testfilename, oldfiles[1]:sub(-#testfilename))
|
eq(testfilename, oldfiles[1]:sub(-#testfilename))
|
||||||
@@ -132,7 +132,7 @@ describe('ShaDa support code', function()
|
|||||||
eq(tf_full, oldfiles[1])
|
eq(tf_full, oldfiles[1])
|
||||||
eq(tf_full_2, oldfiles[2])
|
eq(tf_full_2, oldfiles[2])
|
||||||
nvim_command('rshada!')
|
nvim_command('rshada!')
|
||||||
oldfiles = meths.get_vvar('oldfiles')
|
oldfiles = meths.nvim_get_vvar('oldfiles')
|
||||||
table.sort(oldfiles)
|
table.sort(oldfiles)
|
||||||
eq(2, #oldfiles)
|
eq(2, #oldfiles)
|
||||||
eq(testfilename, oldfiles[1]:sub(-#testfilename))
|
eq(testfilename, oldfiles[1]:sub(-#testfilename))
|
||||||
@@ -229,7 +229,7 @@ describe('ShaDa support code', function()
|
|||||||
},
|
},
|
||||||
args = {
|
args = {
|
||||||
'-i',
|
'-i',
|
||||||
meths.get_var('tmpname'), -- Use same shada file as parent.
|
meths.nvim_get_var('tmpname'), -- Use same shada file as parent.
|
||||||
'--cmd',
|
'--cmd',
|
||||||
'silent edit ' .. non_existent_testfilename,
|
'silent edit ' .. non_existent_testfilename,
|
||||||
'-c',
|
'-c',
|
||||||
@@ -248,7 +248,7 @@ describe('ShaDa support code', function()
|
|||||||
},
|
},
|
||||||
args = {
|
args = {
|
||||||
'-i',
|
'-i',
|
||||||
meths.get_var('tmpname'), -- Use same shada file as parent.
|
meths.nvim_get_var('tmpname'), -- Use same shada file as parent.
|
||||||
'-c',
|
'-c',
|
||||||
'silent edit ' .. non_existent_testfilename,
|
'silent edit ' .. non_existent_testfilename,
|
||||||
'-c',
|
'-c',
|
||||||
|
@@ -175,7 +175,7 @@ describe('ShaDa support code', function()
|
|||||||
|
|
||||||
it('correctly uses shada-r option', function()
|
it('correctly uses shada-r option', function()
|
||||||
nvim_command('set shellslash')
|
nvim_command('set shellslash')
|
||||||
meths.set_var('__home', paths.test_source_path)
|
meths.nvim_set_var('__home', paths.test_source_path)
|
||||||
nvim_command('let $HOME = __home')
|
nvim_command('let $HOME = __home')
|
||||||
nvim_command('unlet __home')
|
nvim_command('unlet __home')
|
||||||
nvim_command('edit ~/README.md')
|
nvim_command('edit ~/README.md')
|
||||||
@@ -203,7 +203,7 @@ describe('ShaDa support code', function()
|
|||||||
local pwd = funcs.getcwd()
|
local pwd = funcs.getcwd()
|
||||||
local relfname = 'абв/test'
|
local relfname = 'абв/test'
|
||||||
local fname = pwd .. '/' .. relfname
|
local fname = pwd .. '/' .. relfname
|
||||||
meths.set_var('__fname', fname)
|
meths.nvim_set_var('__fname', fname)
|
||||||
nvim_command('silent! edit `=__fname`')
|
nvim_command('silent! edit `=__fname`')
|
||||||
funcs.setline(1, { 'a', 'b', 'c', 'd' })
|
funcs.setline(1, { 'a', 'b', 'c', 'd' })
|
||||||
nvim_command('normal! GmAggmaAabc')
|
nvim_command('normal! GmAggmaAabc')
|
||||||
@@ -217,30 +217,30 @@ describe('ShaDa support code', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('is able to set &shada after &viminfo', function()
|
it('is able to set &shada after &viminfo', function()
|
||||||
meths.set_option_value('viminfo', "'10", {})
|
meths.nvim_set_option_value('viminfo', "'10", {})
|
||||||
eq("'10", meths.get_option_value('viminfo', {}))
|
eq("'10", meths.nvim_get_option_value('viminfo', {}))
|
||||||
eq("'10", meths.get_option_value('shada', {}))
|
eq("'10", meths.nvim_get_option_value('shada', {}))
|
||||||
meths.set_option_value('shada', '', {})
|
meths.nvim_set_option_value('shada', '', {})
|
||||||
eq('', meths.get_option_value('viminfo', {}))
|
eq('', meths.nvim_get_option_value('viminfo', {}))
|
||||||
eq('', meths.get_option_value('shada', {}))
|
eq('', meths.nvim_get_option_value('shada', {}))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('is able to set all& after setting &shada', function()
|
it('is able to set all& after setting &shada', function()
|
||||||
meths.set_option_value('shada', "'10", {})
|
meths.nvim_set_option_value('shada', "'10", {})
|
||||||
eq("'10", meths.get_option_value('viminfo', {}))
|
eq("'10", meths.nvim_get_option_value('viminfo', {}))
|
||||||
eq("'10", meths.get_option_value('shada', {}))
|
eq("'10", meths.nvim_get_option_value('shada', {}))
|
||||||
nvim_command('set all&')
|
nvim_command('set all&')
|
||||||
eq("!,'100,<50,s10,h", meths.get_option_value('viminfo', {}))
|
eq("!,'100,<50,s10,h", meths.nvim_get_option_value('viminfo', {}))
|
||||||
eq("!,'100,<50,s10,h", meths.get_option_value('shada', {}))
|
eq("!,'100,<50,s10,h", meths.nvim_get_option_value('shada', {}))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('is able to set &shada after &viminfo using :set', function()
|
it('is able to set &shada after &viminfo using :set', function()
|
||||||
nvim_command("set viminfo='10")
|
nvim_command("set viminfo='10")
|
||||||
eq("'10", meths.get_option_value('viminfo', {}))
|
eq("'10", meths.nvim_get_option_value('viminfo', {}))
|
||||||
eq("'10", meths.get_option_value('shada', {}))
|
eq("'10", meths.nvim_get_option_value('shada', {}))
|
||||||
nvim_command('set shada=')
|
nvim_command('set shada=')
|
||||||
eq('', meths.get_option_value('viminfo', {}))
|
eq('', meths.nvim_get_option_value('viminfo', {}))
|
||||||
eq('', meths.get_option_value('shada', {}))
|
eq('', meths.nvim_get_option_value('shada', {}))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('setting &shada gives proper error message on missing number', function()
|
it('setting &shada gives proper error message on missing number', function()
|
||||||
@@ -259,14 +259,14 @@ describe('ShaDa support code', function()
|
|||||||
funcs.mkdir(dirname, '', 0)
|
funcs.mkdir(dirname, '', 0)
|
||||||
eq(0, funcs.filewritable(dirname))
|
eq(0, funcs.filewritable(dirname))
|
||||||
reset { shadafile = dirshada, args = { '--cmd', 'set shada=' } }
|
reset { shadafile = dirshada, args = { '--cmd', 'set shada=' } }
|
||||||
meths.set_option_value('shada', "'10", {})
|
meths.nvim_set_option_value('shada', "'10", {})
|
||||||
eq(
|
eq(
|
||||||
'Vim(wshada):E886: System error while opening ShaDa file '
|
'Vim(wshada):E886: System error while opening ShaDa file '
|
||||||
.. 'Xtest-functional-shada-shada.d/main.shada for reading to merge '
|
.. 'Xtest-functional-shada-shada.d/main.shada for reading to merge '
|
||||||
.. 'before writing it: permission denied',
|
.. 'before writing it: permission denied',
|
||||||
exc_exec('wshada')
|
exc_exec('wshada')
|
||||||
)
|
)
|
||||||
meths.set_option_value('shada', '', {})
|
meths.nvim_set_option_value('shada', '', {})
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@@ -12,13 +12,13 @@ describe('ShaDa support code', function()
|
|||||||
after_each(clear)
|
after_each(clear)
|
||||||
|
|
||||||
it('is able to dump and read back string variable', function()
|
it('is able to dump and read back string variable', function()
|
||||||
meths.set_var('STRVAR', 'foo')
|
meths.nvim_set_var('STRVAR', 'foo')
|
||||||
nvim_command('set shada+=!')
|
nvim_command('set shada+=!')
|
||||||
nvim_command('wshada')
|
nvim_command('wshada')
|
||||||
reset()
|
reset()
|
||||||
nvim_command('set shada+=!')
|
nvim_command('set shada+=!')
|
||||||
nvim_command('rshada')
|
nvim_command('rshada')
|
||||||
eq('foo', meths.get_var('STRVAR'))
|
eq('foo', meths.nvim_get_var('STRVAR'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local autotest = function(tname, varname, varval, val_is_expr)
|
local autotest = function(tname, varname, varval, val_is_expr)
|
||||||
@@ -26,9 +26,9 @@ describe('ShaDa support code', function()
|
|||||||
reset('set shada+=!')
|
reset('set shada+=!')
|
||||||
if val_is_expr then
|
if val_is_expr then
|
||||||
nvim_command('let g:' .. varname .. ' = ' .. varval)
|
nvim_command('let g:' .. varname .. ' = ' .. varval)
|
||||||
varval = meths.get_var(varname)
|
varval = meths.nvim_get_var(varname)
|
||||||
else
|
else
|
||||||
meths.set_var(varname, varval)
|
meths.nvim_set_var(varname, varval)
|
||||||
end
|
end
|
||||||
local vartype = eval('type(g:' .. varname .. ')')
|
local vartype = eval('type(g:' .. varname .. ')')
|
||||||
-- Exit during `reset` is not a regular exit: it does not write shada
|
-- Exit during `reset` is not a regular exit: it does not write shada
|
||||||
@@ -36,7 +36,7 @@ describe('ShaDa support code', function()
|
|||||||
expect_exit(nvim_command, 'qall')
|
expect_exit(nvim_command, 'qall')
|
||||||
reset('set shada+=!')
|
reset('set shada+=!')
|
||||||
eq(vartype, eval('type(g:' .. varname .. ')'))
|
eq(vartype, eval('type(g:' .. varname .. ')'))
|
||||||
eq(varval, meths.get_var(varname))
|
eq(varval, meths.nvim_get_var(varname))
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ describe('ShaDa support code', function()
|
|||||||
autotest('blob (with NULs)', 'BLOBVARNULS', '0z004e554c7300', true)
|
autotest('blob (with NULs)', 'BLOBVARNULS', '0z004e554c7300', true)
|
||||||
|
|
||||||
it('does not read back variables without `!` in &shada', function()
|
it('does not read back variables without `!` in &shada', function()
|
||||||
meths.set_var('STRVAR', 'foo')
|
meths.nvim_set_var('STRVAR', 'foo')
|
||||||
nvim_command('set shada+=!')
|
nvim_command('set shada+=!')
|
||||||
nvim_command('wshada')
|
nvim_command('wshada')
|
||||||
reset('set shada-=!')
|
reset('set shada-=!')
|
||||||
@@ -63,7 +63,7 @@ describe('ShaDa support code', function()
|
|||||||
|
|
||||||
it('does not dump variables without `!` in &shada', function()
|
it('does not dump variables without `!` in &shada', function()
|
||||||
nvim_command('set shada-=!')
|
nvim_command('set shada-=!')
|
||||||
meths.set_var('STRVAR', 'foo')
|
meths.nvim_set_var('STRVAR', 'foo')
|
||||||
nvim_command('wshada')
|
nvim_command('wshada')
|
||||||
reset()
|
reset()
|
||||||
nvim_command('set shada+=!')
|
nvim_command('set shada+=!')
|
||||||
@@ -73,7 +73,7 @@ describe('ShaDa support code', function()
|
|||||||
|
|
||||||
it('does not dump session variables', function()
|
it('does not dump session variables', function()
|
||||||
nvim_command('set shada+=!')
|
nvim_command('set shada+=!')
|
||||||
meths.set_var('StrVar', 'foo')
|
meths.nvim_set_var('StrVar', 'foo')
|
||||||
nvim_command('wshada')
|
nvim_command('wshada')
|
||||||
reset()
|
reset()
|
||||||
nvim_command('set shada+=!')
|
nvim_command('set shada+=!')
|
||||||
@@ -83,7 +83,7 @@ describe('ShaDa support code', function()
|
|||||||
|
|
||||||
it('does not dump regular variables', function()
|
it('does not dump regular variables', function()
|
||||||
nvim_command('set shada+=!')
|
nvim_command('set shada+=!')
|
||||||
meths.set_var('str_var', 'foo')
|
meths.nvim_set_var('str_var', 'foo')
|
||||||
nvim_command('wshada')
|
nvim_command('wshada')
|
||||||
reset()
|
reset()
|
||||||
nvim_command('set shada+=!')
|
nvim_command('set shada+=!')
|
||||||
@@ -93,70 +93,73 @@ describe('ShaDa support code', function()
|
|||||||
|
|
||||||
it('dumps and loads variables correctly with utf-8 strings', function()
|
it('dumps and loads variables correctly with utf-8 strings', function()
|
||||||
reset()
|
reset()
|
||||||
meths.set_var('STRVAR', '«')
|
meths.nvim_set_var('STRVAR', '«')
|
||||||
meths.set_var('LSTVAR', { '«' })
|
meths.nvim_set_var('LSTVAR', { '«' })
|
||||||
meths.set_var('DCTVAR', { ['«'] = '«' })
|
meths.nvim_set_var('DCTVAR', { ['«'] = '«' })
|
||||||
meths.set_var('NESTEDVAR', { ['«'] = { { '«' }, { ['«'] = '«' }, { a = 'Test' } } })
|
meths.nvim_set_var('NESTEDVAR', { ['«'] = { { '«' }, { ['«'] = '«' }, { a = 'Test' } } })
|
||||||
expect_exit(nvim_command, 'qall')
|
expect_exit(nvim_command, 'qall')
|
||||||
reset()
|
reset()
|
||||||
eq('«', meths.get_var('STRVAR'))
|
eq('«', meths.nvim_get_var('STRVAR'))
|
||||||
eq({ '«' }, meths.get_var('LSTVAR'))
|
eq({ '«' }, meths.nvim_get_var('LSTVAR'))
|
||||||
eq({ ['«'] = '«' }, meths.get_var('DCTVAR'))
|
eq({ ['«'] = '«' }, meths.nvim_get_var('DCTVAR'))
|
||||||
eq({ ['«'] = { { '«' }, { ['«'] = '«' }, { a = 'Test' } } }, meths.get_var('NESTEDVAR'))
|
eq(
|
||||||
|
{ ['«'] = { { '«' }, { ['«'] = '«' }, { a = 'Test' } } },
|
||||||
|
meths.nvim_get_var('NESTEDVAR')
|
||||||
|
)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('dumps and loads variables correctly with 8-bit strings', function()
|
it('dumps and loads variables correctly with 8-bit strings', function()
|
||||||
reset()
|
reset()
|
||||||
-- \171 is U+00AB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK in latin1
|
-- \171 is U+00AB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK in latin1
|
||||||
-- This is invalid unicode, but we should still dump and restore it.
|
-- This is invalid unicode, but we should still dump and restore it.
|
||||||
meths.set_var('STRVAR', '\171')
|
meths.nvim_set_var('STRVAR', '\171')
|
||||||
meths.set_var('LSTVAR', { '\171' })
|
meths.nvim_set_var('LSTVAR', { '\171' })
|
||||||
meths.set_var('DCTVAR', { ['«\171'] = '«\171' })
|
meths.nvim_set_var('DCTVAR', { ['«\171'] = '«\171' })
|
||||||
meths.set_var(
|
meths.nvim_set_var(
|
||||||
'NESTEDVAR',
|
'NESTEDVAR',
|
||||||
{ ['\171'] = { { '\171«' }, { ['\171'] = '\171' }, { a = 'Test' } } }
|
{ ['\171'] = { { '\171«' }, { ['\171'] = '\171' }, { a = 'Test' } } }
|
||||||
)
|
)
|
||||||
expect_exit(nvim_command, 'qall')
|
expect_exit(nvim_command, 'qall')
|
||||||
reset()
|
reset()
|
||||||
eq('\171', meths.get_var('STRVAR'))
|
eq('\171', meths.nvim_get_var('STRVAR'))
|
||||||
eq({ '\171' }, meths.get_var('LSTVAR'))
|
eq({ '\171' }, meths.nvim_get_var('LSTVAR'))
|
||||||
eq({ ['«\171'] = '«\171' }, meths.get_var('DCTVAR'))
|
eq({ ['«\171'] = '«\171' }, meths.nvim_get_var('DCTVAR'))
|
||||||
eq(
|
eq(
|
||||||
{ ['\171'] = { { '\171«' }, { ['\171'] = '\171' }, { a = 'Test' } } },
|
{ ['\171'] = { { '\171«' }, { ['\171'] = '\171' }, { a = 'Test' } } },
|
||||||
meths.get_var('NESTEDVAR')
|
meths.nvim_get_var('NESTEDVAR')
|
||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('ignore when a funcref is stored in a variable', function()
|
it('ignore when a funcref is stored in a variable', function()
|
||||||
nvim_command('let F = function("tr")')
|
nvim_command('let F = function("tr")')
|
||||||
meths.set_var('U', '10')
|
meths.nvim_set_var('U', '10')
|
||||||
nvim_command('set shada+=!')
|
nvim_command('set shada+=!')
|
||||||
nvim_command('wshada')
|
nvim_command('wshada')
|
||||||
reset()
|
reset()
|
||||||
nvim_command('set shada+=!')
|
nvim_command('set shada+=!')
|
||||||
nvim_command('rshada')
|
nvim_command('rshada')
|
||||||
eq('10', meths.get_var('U'))
|
eq('10', meths.nvim_get_var('U'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('ignore when a partial is stored in a variable', function()
|
it('ignore when a partial is stored in a variable', function()
|
||||||
nvim_command('let P = { -> 1 }')
|
nvim_command('let P = { -> 1 }')
|
||||||
meths.set_var('U', '10')
|
meths.nvim_set_var('U', '10')
|
||||||
nvim_command('set shada+=!')
|
nvim_command('set shada+=!')
|
||||||
nvim_command('wshada')
|
nvim_command('wshada')
|
||||||
reset()
|
reset()
|
||||||
nvim_command('set shada+=!')
|
nvim_command('set shada+=!')
|
||||||
nvim_command('rshada')
|
nvim_command('rshada')
|
||||||
eq('10', meths.get_var('U'))
|
eq('10', meths.nvim_get_var('U'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('ignore when a self-referencing list is stored in a variable', function()
|
it('ignore when a self-referencing list is stored in a variable', function()
|
||||||
meths.set_var('L', {})
|
meths.nvim_set_var('L', {})
|
||||||
nvim_command('call add(L, L)')
|
nvim_command('call add(L, L)')
|
||||||
meths.set_var('U', '10')
|
meths.nvim_set_var('U', '10')
|
||||||
nvim_command('set shada+=!')
|
nvim_command('set shada+=!')
|
||||||
nvim_command('wshada')
|
nvim_command('wshada')
|
||||||
reset()
|
reset()
|
||||||
nvim_command('rshada')
|
nvim_command('rshada')
|
||||||
eq('10', meths.get_var('U'))
|
eq('10', meths.nvim_get_var('U'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
@@ -321,8 +321,8 @@ describe(':terminal buffer', function()
|
|||||||
it('emits TermRequest events #26972', function()
|
it('emits TermRequest events #26972', function()
|
||||||
command('split')
|
command('split')
|
||||||
command('enew')
|
command('enew')
|
||||||
local term = meths.open_term(0, {})
|
local term = meths.nvim_open_term(0, {})
|
||||||
local termbuf = meths.get_current_buf().id
|
local termbuf = meths.nvim_get_current_buf().id
|
||||||
|
|
||||||
-- Test that autocommand buffer is associated with the terminal buffer, not the current buffer
|
-- Test that autocommand buffer is associated with the terminal buffer, not the current buffer
|
||||||
command('au TermRequest * let g:termbuf = +expand("<abuf>")')
|
command('au TermRequest * let g:termbuf = +expand("<abuf>")')
|
||||||
@@ -332,7 +332,7 @@ describe(':terminal buffer', function()
|
|||||||
local cwd = funcs.getcwd():gsub('\\', '/')
|
local cwd = funcs.getcwd():gsub('\\', '/')
|
||||||
local parent = cwd:match('^(.+/)')
|
local parent = cwd:match('^(.+/)')
|
||||||
local expected = '\027]7;file://host' .. parent
|
local expected = '\027]7;file://host' .. parent
|
||||||
meths.chan_send(term, string.format('%s\027\\', expected))
|
meths.nvim_chan_send(term, string.format('%s\027\\', expected))
|
||||||
eq(expected, eval('v:termrequest'))
|
eq(expected, eval('v:termrequest'))
|
||||||
eq(termbuf, eval('g:termbuf'))
|
eq(termbuf, eval('g:termbuf'))
|
||||||
end)
|
end)
|
||||||
@@ -405,11 +405,11 @@ end)
|
|||||||
|
|
||||||
it('terminal truncates number of composing characters to 5', function()
|
it('terminal truncates number of composing characters to 5', function()
|
||||||
clear()
|
clear()
|
||||||
local chan = meths.open_term(0, {})
|
local chan = meths.nvim_open_term(0, {})
|
||||||
local composing = ('a̳'):sub(2)
|
local composing = ('a̳'):sub(2)
|
||||||
meths.chan_send(chan, 'a' .. composing:rep(8))
|
meths.nvim_chan_send(chan, 'a' .. composing:rep(8))
|
||||||
retry(nil, nil, function()
|
retry(nil, nil, function()
|
||||||
eq('a' .. composing:rep(5), meths.get_current_line())
|
eq('a' .. composing:rep(5), meths.nvim_get_current_line())
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -512,7 +512,7 @@ describe('terminal input', function()
|
|||||||
}) do
|
}) do
|
||||||
feed('<CR><C-V>' .. key)
|
feed('<CR><C-V>' .. key)
|
||||||
retry(nil, nil, function()
|
retry(nil, nil, function()
|
||||||
eq(key, meths.get_current_line())
|
eq(key, meths.nvim_get_current_line())
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
@@ -140,7 +140,7 @@ describe('no crash when TermOpen autocommand', function()
|
|||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
clear()
|
clear()
|
||||||
meths.set_option_value('shell', testprg('shell-test'), {})
|
meths.nvim_set_option_value('shell', testprg('shell-test'), {})
|
||||||
command('set shellcmdflag=EXE shellredir= shellpipe= shellquote= shellxquote=')
|
command('set shellcmdflag=EXE shellredir= shellpipe= shellquote= shellxquote=')
|
||||||
screen = Screen.new(60, 4)
|
screen = Screen.new(60, 4)
|
||||||
screen:set_default_attr_ids({
|
screen:set_default_attr_ids({
|
||||||
@@ -232,11 +232,11 @@ describe('nvim_open_term', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('with force_crlf=true converts newlines', function()
|
it('with force_crlf=true converts newlines', function()
|
||||||
local win = meths.get_current_win()
|
local win = meths.nvim_get_current_win()
|
||||||
local buf = meths.create_buf(false, true)
|
local buf = meths.nvim_create_buf(false, true)
|
||||||
local term = meths.open_term(buf, { force_crlf = true })
|
local term = meths.nvim_open_term(buf, { force_crlf = true })
|
||||||
meths.win_set_buf(win, buf)
|
meths.nvim_win_set_buf(win, buf)
|
||||||
meths.chan_send(term, 'here\nthere\nfoo\r\nbar\n\ntest')
|
meths.nvim_chan_send(term, 'here\nthere\nfoo\r\nbar\n\ntest')
|
||||||
screen:expect {
|
screen:expect {
|
||||||
grid = [[
|
grid = [[
|
||||||
^here |
|
^here |
|
||||||
@@ -248,7 +248,7 @@ describe('nvim_open_term', function()
|
|||||||
|*4
|
|*4
|
||||||
]],
|
]],
|
||||||
}
|
}
|
||||||
meths.chan_send(term, '\nfirst')
|
meths.nvim_chan_send(term, '\nfirst')
|
||||||
screen:expect {
|
screen:expect {
|
||||||
grid = [[
|
grid = [[
|
||||||
^here |
|
^here |
|
||||||
@@ -264,11 +264,11 @@ describe('nvim_open_term', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('with force_crlf=false does not convert newlines', function()
|
it('with force_crlf=false does not convert newlines', function()
|
||||||
local win = meths.get_current_win()
|
local win = meths.nvim_get_current_win()
|
||||||
local buf = meths.create_buf(false, true)
|
local buf = meths.nvim_create_buf(false, true)
|
||||||
local term = meths.open_term(buf, { force_crlf = false })
|
local term = meths.nvim_open_term(buf, { force_crlf = false })
|
||||||
meths.win_set_buf(win, buf)
|
meths.nvim_win_set_buf(win, buf)
|
||||||
meths.chan_send(term, 'here\nthere')
|
meths.nvim_chan_send(term, 'here\nthere')
|
||||||
screen:expect { grid = [[
|
screen:expect { grid = [[
|
||||||
^here |
|
^here |
|
||||||
there |
|
there |
|
||||||
|
@@ -21,15 +21,15 @@ describe(':edit term://*', function()
|
|||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
clear()
|
clear()
|
||||||
meths.set_option_value('shell', testprg('shell-test'), {})
|
meths.nvim_set_option_value('shell', testprg('shell-test'), {})
|
||||||
meths.set_option_value('shellcmdflag', 'EXE', {})
|
meths.nvim_set_option_value('shellcmdflag', 'EXE', {})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('runs TermOpen event', function()
|
it('runs TermOpen event', function()
|
||||||
meths.set_var('termopen_runs', {})
|
meths.nvim_set_var('termopen_runs', {})
|
||||||
command('autocmd TermOpen * :call add(g:termopen_runs, expand("<amatch>"))')
|
command('autocmd TermOpen * :call add(g:termopen_runs, expand("<amatch>"))')
|
||||||
command('edit term://')
|
command('edit term://')
|
||||||
local termopen_runs = meths.get_var('termopen_runs')
|
local termopen_runs = meths.nvim_get_var('termopen_runs')
|
||||||
eq(1, #termopen_runs)
|
eq(1, #termopen_runs)
|
||||||
local cwd = funcs.fnamemodify('.', ':p:~'):gsub([[[\/]*$]], '')
|
local cwd = funcs.fnamemodify('.', ':p:~'):gsub([[[\/]*$]], '')
|
||||||
matches('^term://' .. pesc(cwd) .. '//%d+:$', termopen_runs[1])
|
matches('^term://' .. pesc(cwd) .. '//%d+:$', termopen_runs[1])
|
||||||
@@ -39,7 +39,7 @@ describe(':edit term://*', function()
|
|||||||
local columns, lines = 20, 4
|
local columns, lines = 20, 4
|
||||||
local scr = get_screen(columns, lines)
|
local scr = get_screen(columns, lines)
|
||||||
local rep = 97
|
local rep = 97
|
||||||
meths.set_option_value('shellcmdflag', 'REP ' .. rep, {})
|
meths.nvim_set_option_value('shellcmdflag', 'REP ' .. rep, {})
|
||||||
command('set shellxquote=') -- win: avoid extra quotes
|
command('set shellxquote=') -- win: avoid extra quotes
|
||||||
local sb = 10
|
local sb = 10
|
||||||
command(
|
command(
|
||||||
|
@@ -400,7 +400,7 @@ describe("'scrollback' option", function()
|
|||||||
screen = thelpers.screen_setup(nil, { 'sh' }, 30)
|
screen = thelpers.screen_setup(nil, { 'sh' }, 30)
|
||||||
end
|
end
|
||||||
|
|
||||||
meths.set_option_value('scrollback', 0, {})
|
meths.nvim_set_option_value('scrollback', 0, {})
|
||||||
feed_data(('%s REP 31 line%s'):format(testprg('shell-test'), is_os('win') and '\r' or '\n'))
|
feed_data(('%s REP 31 line%s'):format(testprg('shell-test'), is_os('win') and '\r' or '\n'))
|
||||||
screen:expect { any = '30: line ' }
|
screen:expect { any = '30: line ' }
|
||||||
retry(nil, nil, function()
|
retry(nil, nil, function()
|
||||||
@@ -418,7 +418,7 @@ describe("'scrollback' option", function()
|
|||||||
screen = thelpers.screen_setup(nil, { 'sh' }, 30)
|
screen = thelpers.screen_setup(nil, { 'sh' }, 30)
|
||||||
end
|
end
|
||||||
|
|
||||||
meths.set_option_value('scrollback', 200, {})
|
meths.nvim_set_option_value('scrollback', 200, {})
|
||||||
|
|
||||||
-- Wait for prompt.
|
-- Wait for prompt.
|
||||||
screen:expect { any = '%$' }
|
screen:expect { any = '%$' }
|
||||||
@@ -429,12 +429,12 @@ describe("'scrollback' option", function()
|
|||||||
retry(nil, nil, function()
|
retry(nil, nil, function()
|
||||||
expect_lines(33, 2)
|
expect_lines(33, 2)
|
||||||
end)
|
end)
|
||||||
meths.set_option_value('scrollback', 10, {})
|
meths.nvim_set_option_value('scrollback', 10, {})
|
||||||
poke_eventloop()
|
poke_eventloop()
|
||||||
retry(nil, nil, function()
|
retry(nil, nil, function()
|
||||||
expect_lines(16)
|
expect_lines(16)
|
||||||
end)
|
end)
|
||||||
meths.set_option_value('scrollback', 10000, {})
|
meths.nvim_set_option_value('scrollback', 10000, {})
|
||||||
retry(nil, nil, function()
|
retry(nil, nil, function()
|
||||||
expect_lines(16)
|
expect_lines(16)
|
||||||
end)
|
end)
|
||||||
@@ -495,18 +495,18 @@ describe("'scrollback' option", function()
|
|||||||
]])
|
]])
|
||||||
local term_height = 6 -- Actual terminal screen height, not the scrollback
|
local term_height = 6 -- Actual terminal screen height, not the scrollback
|
||||||
-- Initial
|
-- Initial
|
||||||
local scrollback = meths.get_option_value('scrollback', {})
|
local scrollback = meths.nvim_get_option_value('scrollback', {})
|
||||||
eq(scrollback + term_height, eval('line("$")'))
|
eq(scrollback + term_height, eval('line("$")'))
|
||||||
-- Reduction
|
-- Reduction
|
||||||
scrollback = scrollback - 2
|
scrollback = scrollback - 2
|
||||||
meths.set_option_value('scrollback', scrollback, {})
|
meths.nvim_set_option_value('scrollback', scrollback, {})
|
||||||
eq(scrollback + term_height, eval('line("$")'))
|
eq(scrollback + term_height, eval('line("$")'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('defaults to 10000 in :terminal buffers', function()
|
it('defaults to 10000 in :terminal buffers', function()
|
||||||
set_fake_shell()
|
set_fake_shell()
|
||||||
command('terminal')
|
command('terminal')
|
||||||
eq(10000, meths.get_option_value('scrollback', {}))
|
eq(10000, meths.nvim_get_option_value('scrollback', {}))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('error if set to invalid value', function()
|
it('error if set to invalid value', function()
|
||||||
@@ -519,7 +519,7 @@ describe("'scrollback' option", function()
|
|||||||
|
|
||||||
it('defaults to -1 on normal buffers', function()
|
it('defaults to -1 on normal buffers', function()
|
||||||
command('new')
|
command('new')
|
||||||
eq(-1, meths.get_option_value('scrollback', {}))
|
eq(-1, meths.nvim_get_option_value('scrollback', {}))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it(':setlocal in a :terminal buffer', function()
|
it(':setlocal in a :terminal buffer', function()
|
||||||
@@ -528,45 +528,45 @@ describe("'scrollback' option", function()
|
|||||||
-- _Global_ scrollback=-1 defaults :terminal to 10_000.
|
-- _Global_ scrollback=-1 defaults :terminal to 10_000.
|
||||||
command('setglobal scrollback=-1')
|
command('setglobal scrollback=-1')
|
||||||
command('terminal')
|
command('terminal')
|
||||||
eq(10000, meths.get_option_value('scrollback', {}))
|
eq(10000, meths.nvim_get_option_value('scrollback', {}))
|
||||||
|
|
||||||
-- _Local_ scrollback=-1 in :terminal forces the _maximum_.
|
-- _Local_ scrollback=-1 in :terminal forces the _maximum_.
|
||||||
command('setlocal scrollback=-1')
|
command('setlocal scrollback=-1')
|
||||||
retry(nil, nil, function() -- Fixup happens on refresh, not immediately.
|
retry(nil, nil, function() -- Fixup happens on refresh, not immediately.
|
||||||
eq(100000, meths.get_option_value('scrollback', {}))
|
eq(100000, meths.nvim_get_option_value('scrollback', {}))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- _Local_ scrollback=-1 during TermOpen forces the maximum. #9605
|
-- _Local_ scrollback=-1 during TermOpen forces the maximum. #9605
|
||||||
command('setglobal scrollback=-1')
|
command('setglobal scrollback=-1')
|
||||||
command('autocmd TermOpen * setlocal scrollback=-1')
|
command('autocmd TermOpen * setlocal scrollback=-1')
|
||||||
command('terminal')
|
command('terminal')
|
||||||
eq(100000, meths.get_option_value('scrollback', {}))
|
eq(100000, meths.nvim_get_option_value('scrollback', {}))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it(':setlocal in a normal buffer', function()
|
it(':setlocal in a normal buffer', function()
|
||||||
command('new')
|
command('new')
|
||||||
-- :setlocal to -1.
|
-- :setlocal to -1.
|
||||||
command('setlocal scrollback=-1')
|
command('setlocal scrollback=-1')
|
||||||
eq(-1, meths.get_option_value('scrollback', {}))
|
eq(-1, meths.nvim_get_option_value('scrollback', {}))
|
||||||
-- :setlocal to anything except -1. Currently, this just has no effect.
|
-- :setlocal to anything except -1. Currently, this just has no effect.
|
||||||
command('setlocal scrollback=42')
|
command('setlocal scrollback=42')
|
||||||
eq(42, meths.get_option_value('scrollback', {}))
|
eq(42, meths.nvim_get_option_value('scrollback', {}))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it(':set updates local value and global default', function()
|
it(':set updates local value and global default', function()
|
||||||
set_fake_shell()
|
set_fake_shell()
|
||||||
command('set scrollback=42') -- set global value
|
command('set scrollback=42') -- set global value
|
||||||
eq(42, meths.get_option_value('scrollback', {}))
|
eq(42, meths.nvim_get_option_value('scrollback', {}))
|
||||||
command('terminal')
|
command('terminal')
|
||||||
eq(42, meths.get_option_value('scrollback', {})) -- inherits global default
|
eq(42, meths.nvim_get_option_value('scrollback', {})) -- inherits global default
|
||||||
command('setlocal scrollback=99')
|
command('setlocal scrollback=99')
|
||||||
eq(99, meths.get_option_value('scrollback', {}))
|
eq(99, meths.nvim_get_option_value('scrollback', {}))
|
||||||
command('set scrollback<') -- reset to global default
|
command('set scrollback<') -- reset to global default
|
||||||
eq(42, meths.get_option_value('scrollback', {}))
|
eq(42, meths.nvim_get_option_value('scrollback', {}))
|
||||||
command('setglobal scrollback=734') -- new global default
|
command('setglobal scrollback=734') -- new global default
|
||||||
eq(42, meths.get_option_value('scrollback', {})) -- local value did not change
|
eq(42, meths.nvim_get_option_value('scrollback', {})) -- local value did not change
|
||||||
command('terminal')
|
command('terminal')
|
||||||
eq(734, meths.get_option_value('scrollback', {}))
|
eq(734, meths.nvim_get_option_value('scrollback', {}))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@@ -375,7 +375,7 @@ describe('TUI', function()
|
|||||||
if esc then
|
if esc then
|
||||||
feed_data('\027[<65;8;1M')
|
feed_data('\027[<65;8;1M')
|
||||||
else
|
else
|
||||||
meths.input_mouse('wheel', 'down', '', 0, 0, 7)
|
meths.nvim_input_mouse('wheel', 'down', '', 0, 0, 7)
|
||||||
end
|
end
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{11: 2 }{1:0}----1----2----3----4│{11: 1 }0----1----2----3----|
|
{11: 2 }{1:0}----1----2----3----4│{11: 1 }0----1----2----3----|
|
||||||
@@ -390,7 +390,7 @@ describe('TUI', function()
|
|||||||
if esc then
|
if esc then
|
||||||
feed_data('\027[<65;48;1M')
|
feed_data('\027[<65;48;1M')
|
||||||
else
|
else
|
||||||
meths.input_mouse('wheel', 'down', '', 0, 0, 47)
|
meths.nvim_input_mouse('wheel', 'down', '', 0, 0, 47)
|
||||||
end
|
end
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{11: 2 }{1:0}----1----2----3----4│{11: 2 }0----1----2----3----|
|
{11: 2 }{1:0}----1----2----3----4│{11: 2 }0----1----2----3----|
|
||||||
@@ -405,7 +405,7 @@ describe('TUI', function()
|
|||||||
if esc then
|
if esc then
|
||||||
feed_data('\027[<67;8;1M')
|
feed_data('\027[<67;8;1M')
|
||||||
else
|
else
|
||||||
meths.input_mouse('wheel', 'right', '', 0, 0, 7)
|
meths.nvim_input_mouse('wheel', 'right', '', 0, 0, 7)
|
||||||
end
|
end
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{11: 2 }{1:-}---1----2----3----4-│{11: 2 }0----1----2----3----|
|
{11: 2 }{1:-}---1----2----3----4-│{11: 2 }0----1----2----3----|
|
||||||
@@ -420,7 +420,7 @@ describe('TUI', function()
|
|||||||
if esc then
|
if esc then
|
||||||
feed_data('\027[<67;48;1M')
|
feed_data('\027[<67;48;1M')
|
||||||
else
|
else
|
||||||
meths.input_mouse('wheel', 'right', '', 0, 0, 47)
|
meths.nvim_input_mouse('wheel', 'right', '', 0, 0, 47)
|
||||||
end
|
end
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{11: 2 }{1:-}---1----2----3----4-│{11: 2 }----1----2----3----4|
|
{11: 2 }{1:-}---1----2----3----4-│{11: 2 }----1----2----3----4|
|
||||||
@@ -435,7 +435,7 @@ describe('TUI', function()
|
|||||||
if esc then
|
if esc then
|
||||||
feed_data('\027[<69;8;1M')
|
feed_data('\027[<69;8;1M')
|
||||||
else
|
else
|
||||||
meths.input_mouse('wheel', 'down', 'S', 0, 0, 7)
|
meths.nvim_input_mouse('wheel', 'down', 'S', 0, 0, 7)
|
||||||
end
|
end
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{11: 5 }{1:-}---1----2----3----4-│{11: 2 }----1----2----3----4|
|
{11: 5 }{1:-}---1----2----3----4-│{11: 2 }----1----2----3----4|
|
||||||
@@ -450,7 +450,7 @@ describe('TUI', function()
|
|||||||
if esc then
|
if esc then
|
||||||
feed_data('\027[<69;48;1M')
|
feed_data('\027[<69;48;1M')
|
||||||
else
|
else
|
||||||
meths.input_mouse('wheel', 'down', 'S', 0, 0, 47)
|
meths.nvim_input_mouse('wheel', 'down', 'S', 0, 0, 47)
|
||||||
end
|
end
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{11: 5 }{1:-}---1----2----3----4-│{11: 5 }----1----2----3----4|
|
{11: 5 }{1:-}---1----2----3----4-│{11: 5 }----1----2----3----4|
|
||||||
@@ -465,7 +465,7 @@ describe('TUI', function()
|
|||||||
if esc then
|
if esc then
|
||||||
feed_data('\027[<71;8;1M')
|
feed_data('\027[<71;8;1M')
|
||||||
else
|
else
|
||||||
meths.input_mouse('wheel', 'right', 'S', 0, 0, 7)
|
meths.nvim_input_mouse('wheel', 'right', 'S', 0, 0, 7)
|
||||||
end
|
end
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{11: 5 }{1:-}---6----7----8----9 │{11: 5 }----1----2----3----4|
|
{11: 5 }{1:-}---6----7----8----9 │{11: 5 }----1----2----3----4|
|
||||||
@@ -480,7 +480,7 @@ describe('TUI', function()
|
|||||||
if esc then
|
if esc then
|
||||||
feed_data('\027[<71;48;1M')
|
feed_data('\027[<71;48;1M')
|
||||||
else
|
else
|
||||||
meths.input_mouse('wheel', 'right', 'S', 0, 0, 47)
|
meths.nvim_input_mouse('wheel', 'right', 'S', 0, 0, 47)
|
||||||
end
|
end
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{11: 5 }{1:-}---6----7----8----9 │{11: 5 }5----6----7----8----|
|
{11: 5 }{1:-}---6----7----8----9 │{11: 5 }5----6----7----8----|
|
||||||
@@ -495,7 +495,7 @@ describe('TUI', function()
|
|||||||
if esc then
|
if esc then
|
||||||
feed_data('\027[<64;8;1M')
|
feed_data('\027[<64;8;1M')
|
||||||
else
|
else
|
||||||
meths.input_mouse('wheel', 'up', '', 0, 0, 7)
|
meths.nvim_input_mouse('wheel', 'up', '', 0, 0, 7)
|
||||||
end
|
end
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{11: 4 }----6----7----8----9 │{11: 5 }5----6----7----8----|
|
{11: 4 }----6----7----8----9 │{11: 5 }5----6----7----8----|
|
||||||
@@ -510,7 +510,7 @@ describe('TUI', function()
|
|||||||
if esc then
|
if esc then
|
||||||
feed_data('\027[<64;48;1M')
|
feed_data('\027[<64;48;1M')
|
||||||
else
|
else
|
||||||
meths.input_mouse('wheel', 'up', '', 0, 0, 47)
|
meths.nvim_input_mouse('wheel', 'up', '', 0, 0, 47)
|
||||||
end
|
end
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{11: 4 }----6----7----8----9 │{11: 4 }5----6----7----8----|
|
{11: 4 }----6----7----8----9 │{11: 4 }5----6----7----8----|
|
||||||
@@ -525,7 +525,7 @@ describe('TUI', function()
|
|||||||
if esc then
|
if esc then
|
||||||
feed_data('\027[<66;8;1M')
|
feed_data('\027[<66;8;1M')
|
||||||
else
|
else
|
||||||
meths.input_mouse('wheel', 'left', '', 0, 0, 7)
|
meths.nvim_input_mouse('wheel', 'left', '', 0, 0, 7)
|
||||||
end
|
end
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{11: 4 }5----6----7----8----9│{11: 4 }5----6----7----8----|
|
{11: 4 }5----6----7----8----9│{11: 4 }5----6----7----8----|
|
||||||
@@ -540,7 +540,7 @@ describe('TUI', function()
|
|||||||
if esc then
|
if esc then
|
||||||
feed_data('\027[<66;48;1M')
|
feed_data('\027[<66;48;1M')
|
||||||
else
|
else
|
||||||
meths.input_mouse('wheel', 'left', '', 0, 0, 47)
|
meths.nvim_input_mouse('wheel', 'left', '', 0, 0, 47)
|
||||||
end
|
end
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{11: 4 }5----6----7----8----9│{11: 4 }-5----6----7----8---|
|
{11: 4 }5----6----7----8----9│{11: 4 }-5----6----7----8---|
|
||||||
@@ -555,7 +555,7 @@ describe('TUI', function()
|
|||||||
if esc then
|
if esc then
|
||||||
feed_data('\027[<68;8;1M')
|
feed_data('\027[<68;8;1M')
|
||||||
else
|
else
|
||||||
meths.input_mouse('wheel', 'up', 'S', 0, 0, 7)
|
meths.nvim_input_mouse('wheel', 'up', 'S', 0, 0, 7)
|
||||||
end
|
end
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{11: 1 }5----6----7----8----9│{11: 4 }-5----6----7----8---|
|
{11: 1 }5----6----7----8----9│{11: 4 }-5----6----7----8---|
|
||||||
@@ -570,7 +570,7 @@ describe('TUI', function()
|
|||||||
if esc then
|
if esc then
|
||||||
feed_data('\027[<68;48;1M')
|
feed_data('\027[<68;48;1M')
|
||||||
else
|
else
|
||||||
meths.input_mouse('wheel', 'up', 'S', 0, 0, 47)
|
meths.nvim_input_mouse('wheel', 'up', 'S', 0, 0, 47)
|
||||||
end
|
end
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{11: 1 }5----6----7----8----9│{11: 1 }-5----6----7----8---|
|
{11: 1 }5----6----7----8----9│{11: 1 }-5----6----7----8---|
|
||||||
@@ -585,7 +585,7 @@ describe('TUI', function()
|
|||||||
if esc then
|
if esc then
|
||||||
feed_data('\027[<70;8;1M')
|
feed_data('\027[<70;8;1M')
|
||||||
else
|
else
|
||||||
meths.input_mouse('wheel', 'left', 'S', 0, 0, 7)
|
meths.nvim_input_mouse('wheel', 'left', 'S', 0, 0, 7)
|
||||||
end
|
end
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{11: 1 }0----1----2----3----4│{11: 1 }-5----6----7----8---|
|
{11: 1 }0----1----2----3----4│{11: 1 }-5----6----7----8---|
|
||||||
@@ -600,7 +600,7 @@ describe('TUI', function()
|
|||||||
if esc then
|
if esc then
|
||||||
feed_data('\027[<70;48;1M')
|
feed_data('\027[<70;48;1M')
|
||||||
else
|
else
|
||||||
meths.input_mouse('wheel', 'left', 'S', 0, 0, 47)
|
meths.nvim_input_mouse('wheel', 'left', 'S', 0, 0, 47)
|
||||||
end
|
end
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{11: 1 }0----1----2----3----4│{11: 1 }0----1----2----3----|
|
{11: 1 }0----1----2----3----4│{11: 1 }0----1----2----3----|
|
||||||
@@ -642,7 +642,7 @@ describe('TUI', function()
|
|||||||
if esc then
|
if esc then
|
||||||
feed_data('\027[<2;5;1M')
|
feed_data('\027[<2;5;1M')
|
||||||
else
|
else
|
||||||
meths.input_mouse('right', 'press', '', 0, 0, 4)
|
meths.nvim_input_mouse('right', 'press', '', 0, 0, 4)
|
||||||
end
|
end
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{1:p}opup menu test |
|
{1:p}opup menu test |
|
||||||
@@ -656,13 +656,13 @@ describe('TUI', function()
|
|||||||
if esc then
|
if esc then
|
||||||
feed_data('\027[<2;5;1m')
|
feed_data('\027[<2;5;1m')
|
||||||
else
|
else
|
||||||
meths.input_mouse('right', 'release', '', 0, 0, 4)
|
meths.nvim_input_mouse('right', 'release', '', 0, 0, 4)
|
||||||
end
|
end
|
||||||
screen:expect_unchanged()
|
screen:expect_unchanged()
|
||||||
if esc then
|
if esc then
|
||||||
feed_data('\027[<35;7;4M')
|
feed_data('\027[<35;7;4M')
|
||||||
else
|
else
|
||||||
meths.input_mouse('move', '', '', 0, 3, 6)
|
meths.nvim_input_mouse('move', '', '', 0, 3, 6)
|
||||||
end
|
end
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{1:p}opup menu test |
|
{1:p}opup menu test |
|
||||||
@@ -676,7 +676,7 @@ describe('TUI', function()
|
|||||||
if esc then
|
if esc then
|
||||||
feed_data('\027[<0;7;3M')
|
feed_data('\027[<0;7;3M')
|
||||||
else
|
else
|
||||||
meths.input_mouse('left', 'press', '', 0, 2, 6)
|
meths.nvim_input_mouse('left', 'press', '', 0, 2, 6)
|
||||||
end
|
end
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{1:p}opup menu test |
|
{1:p}opup menu test |
|
||||||
@@ -688,13 +688,13 @@ describe('TUI', function()
|
|||||||
if esc then
|
if esc then
|
||||||
feed_data('\027[<0;7;3m')
|
feed_data('\027[<0;7;3m')
|
||||||
else
|
else
|
||||||
meths.input_mouse('left', 'release', '', 0, 2, 6)
|
meths.nvim_input_mouse('left', 'release', '', 0, 2, 6)
|
||||||
end
|
end
|
||||||
screen:expect_unchanged()
|
screen:expect_unchanged()
|
||||||
if esc then
|
if esc then
|
||||||
feed_data('\027[<2;45;3M')
|
feed_data('\027[<2;45;3M')
|
||||||
else
|
else
|
||||||
meths.input_mouse('right', 'press', '', 0, 2, 44)
|
meths.nvim_input_mouse('right', 'press', '', 0, 2, 44)
|
||||||
end
|
end
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{1:p}opup menu test |
|
{1:p}opup menu test |
|
||||||
@@ -707,7 +707,7 @@ describe('TUI', function()
|
|||||||
if esc then
|
if esc then
|
||||||
feed_data('\027[<34;48;6M')
|
feed_data('\027[<34;48;6M')
|
||||||
else
|
else
|
||||||
meths.input_mouse('right', 'drag', '', 0, 5, 47)
|
meths.nvim_input_mouse('right', 'drag', '', 0, 5, 47)
|
||||||
end
|
end
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{1:p}opup menu test |
|
{1:p}opup menu test |
|
||||||
@@ -720,7 +720,7 @@ describe('TUI', function()
|
|||||||
if esc then
|
if esc then
|
||||||
feed_data('\027[<2;48;6m')
|
feed_data('\027[<2;48;6m')
|
||||||
else
|
else
|
||||||
meths.input_mouse('right', 'release', '', 0, 5, 47)
|
meths.nvim_input_mouse('right', 'release', '', 0, 5, 47)
|
||||||
end
|
end
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{1:p}opup menu test |
|
{1:p}opup menu test |
|
||||||
@@ -2989,7 +2989,7 @@ describe('TUI as a client', function()
|
|||||||
local client_super = spawn_argv(true)
|
local client_super = spawn_argv(true)
|
||||||
|
|
||||||
set_session(server)
|
set_session(server)
|
||||||
local server_pipe = meths.get_vvar('servername')
|
local server_pipe = meths.nvim_get_vvar('servername')
|
||||||
server:request('nvim_input', 'iHalloj!<Esc>')
|
server:request('nvim_input', 'iHalloj!<Esc>')
|
||||||
server:request('nvim_command', 'set notermguicolors')
|
server:request('nvim_command', 'set notermguicolors')
|
||||||
|
|
||||||
@@ -3022,10 +3022,10 @@ describe('TUI as a client', function()
|
|||||||
]],
|
]],
|
||||||
}
|
}
|
||||||
|
|
||||||
eq(0, meths.get_vvar('shell_error'))
|
eq(0, meths.nvim_get_vvar('shell_error'))
|
||||||
-- exits on input eof #22244
|
-- exits on input eof #22244
|
||||||
funcs.system({ nvim_prog, '--server', server_pipe, '--remote-ui' })
|
funcs.system({ nvim_prog, '--server', server_pipe, '--remote-ui' })
|
||||||
eq(1, meths.get_vvar('shell_error'))
|
eq(1, meths.nvim_get_vvar('shell_error'))
|
||||||
|
|
||||||
client_super:close()
|
client_super:close()
|
||||||
server:close()
|
server:close()
|
||||||
|
@@ -19,7 +19,7 @@ describe(':terminal', function()
|
|||||||
clear()
|
clear()
|
||||||
-- set the statusline to a constant value because of variables like pid
|
-- set the statusline to a constant value because of variables like pid
|
||||||
-- and current directory and to improve visibility of splits
|
-- and current directory and to improve visibility of splits
|
||||||
meths.set_option_value('statusline', '==========', {})
|
meths.nvim_set_option_value('statusline', '==========', {})
|
||||||
command('highlight StatusLine cterm=NONE')
|
command('highlight StatusLine cterm=NONE')
|
||||||
command('highlight StatusLineNC cterm=NONE')
|
command('highlight StatusLineNC cterm=NONE')
|
||||||
command('highlight VertSplit cterm=NONE')
|
command('highlight VertSplit cterm=NONE')
|
||||||
@@ -69,10 +69,10 @@ describe(':terminal', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('does not change size if updated when not visible in any window #19665', function()
|
it('does not change size if updated when not visible in any window #19665', function()
|
||||||
local channel = meths.get_option_value('channel', {})
|
local channel = meths.nvim_get_option_value('channel', {})
|
||||||
command('enew')
|
command('enew')
|
||||||
sleep(100)
|
sleep(100)
|
||||||
meths.chan_send(channel, 'foo')
|
meths.nvim_chan_send(channel, 'foo')
|
||||||
sleep(100)
|
sleep(100)
|
||||||
command('bprevious')
|
command('bprevious')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
|
@@ -709,11 +709,11 @@ describe('treesitter highlighting (C)', function()
|
|||||||
|
|
||||||
it('@foo.bar groups has the correct fallback behavior', function()
|
it('@foo.bar groups has the correct fallback behavior', function()
|
||||||
local get_hl = function(name)
|
local get_hl = function(name)
|
||||||
return meths.get_hl_by_name(name, 1).foreground
|
return meths.nvim_get_hl_by_name(name, 1).foreground
|
||||||
end
|
end
|
||||||
meths.set_hl(0, '@foo', { fg = 1 })
|
meths.nvim_set_hl(0, '@foo', { fg = 1 })
|
||||||
meths.set_hl(0, '@foo.bar', { fg = 2 })
|
meths.nvim_set_hl(0, '@foo.bar', { fg = 2 })
|
||||||
meths.set_hl(0, '@foo.bar.baz', { fg = 3 })
|
meths.nvim_set_hl(0, '@foo.bar.baz', { fg = 3 })
|
||||||
|
|
||||||
eq(1, get_hl '@foo')
|
eq(1, get_hl '@foo')
|
||||||
eq(1, get_hl '@foo.a.b.c.d')
|
eq(1, get_hl '@foo.a.b.c.d')
|
||||||
@@ -725,7 +725,7 @@ describe('treesitter highlighting (C)', function()
|
|||||||
-- lookup is case insensitive
|
-- lookup is case insensitive
|
||||||
eq(2, get_hl '@FOO.BAR.SPAM')
|
eq(2, get_hl '@FOO.BAR.SPAM')
|
||||||
|
|
||||||
meths.set_hl(0, '@foo.missing.exists', { fg = 3 })
|
meths.nvim_set_hl(0, '@foo.missing.exists', { fg = 3 })
|
||||||
eq(1, get_hl '@foo.missing')
|
eq(1, get_hl '@foo.missing')
|
||||||
eq(3, get_hl '@foo.missing.exists')
|
eq(3, get_hl '@foo.missing.exists')
|
||||||
eq(3, get_hl '@foo.missing.exists.bar')
|
eq(3, get_hl '@foo.missing.exists.bar')
|
||||||
|
@@ -494,7 +494,7 @@ describe('Buffer highlighting', function()
|
|||||||
|
|
||||||
it('respects priority', function()
|
it('respects priority', function()
|
||||||
local set_extmark = curbufmeths.set_extmark
|
local set_extmark = curbufmeths.set_extmark
|
||||||
local id = meths.create_namespace('')
|
local id = meths.nvim_create_namespace('')
|
||||||
insert [[foobar]]
|
insert [[foobar]]
|
||||||
|
|
||||||
set_extmark(id, 0, 0, {
|
set_extmark(id, 0, 0, {
|
||||||
@@ -901,9 +901,9 @@ describe('Buffer highlighting', function()
|
|||||||
local set_virtual_text = curbufmeths.set_virtual_text
|
local set_virtual_text = curbufmeths.set_virtual_text
|
||||||
eq(1, add_highlight(0, 'String', 0, 0, -1))
|
eq(1, add_highlight(0, 'String', 0, 0, -1))
|
||||||
eq(2, set_virtual_text(0, 0, { { '= text', 'Comment' } }, {}))
|
eq(2, set_virtual_text(0, 0, { { '= text', 'Comment' } }, {}))
|
||||||
eq(3, meths.create_namespace('my-ns'))
|
eq(3, meths.nvim_create_namespace('my-ns'))
|
||||||
eq(4, add_highlight(0, 'String', 0, 0, -1))
|
eq(4, add_highlight(0, 'String', 0, 0, -1))
|
||||||
eq(5, set_virtual_text(0, 0, { { '= text', 'Comment' } }, {}))
|
eq(5, set_virtual_text(0, 0, { { '= text', 'Comment' } }, {}))
|
||||||
eq(6, meths.create_namespace('other-ns'))
|
eq(6, meths.nvim_create_namespace('other-ns'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
@@ -157,16 +157,16 @@ before_each(function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
local function set_color_cb(funcname, callback_return, id)
|
local function set_color_cb(funcname, callback_return, id)
|
||||||
meths.set_var('id', id or '')
|
meths.nvim_set_var('id', id or '')
|
||||||
if id and id ~= '' and funcs.exists('*' .. funcname .. 'N') then
|
if id and id ~= '' and funcs.exists('*' .. funcname .. 'N') then
|
||||||
command(('let g:Nvim_color_input%s = {cmdline -> %sN(%s, cmdline)}'):format(id, funcname, id))
|
command(('let g:Nvim_color_input%s = {cmdline -> %sN(%s, cmdline)}'):format(id, funcname, id))
|
||||||
if callback_return then
|
if callback_return then
|
||||||
meths.set_var('callback_return' .. id, callback_return)
|
meths.nvim_set_var('callback_return' .. id, callback_return)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
meths.set_var('Nvim_color_input', funcname)
|
meths.nvim_set_var('Nvim_color_input', funcname)
|
||||||
if callback_return then
|
if callback_return then
|
||||||
meths.set_var('callback_return', callback_return)
|
meths.nvim_set_var('callback_return', callback_return)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -177,7 +177,7 @@ end
|
|||||||
describe('Command-line coloring', function()
|
describe('Command-line coloring', function()
|
||||||
it('works', function()
|
it('works', function()
|
||||||
set_color_cb('RainBowParens')
|
set_color_cb('RainBowParens')
|
||||||
meths.set_option_value('more', false, {})
|
meths.nvim_set_option_value('more', false, {})
|
||||||
start_prompt()
|
start_prompt()
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
|
|
|
|
||||||
@@ -362,7 +362,7 @@ describe('Command-line coloring', function()
|
|||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
feed('\n')
|
feed('\n')
|
||||||
eq('let x = "«»«»«»«»«»"', meths.get_var('out'))
|
eq('let x = "«»«»«»«»«»"', meths.nvim_get_var('out'))
|
||||||
local msg = '\nE5405: Chunk 0 start 10 splits multibyte character'
|
local msg = '\nE5405: Chunk 0 start 10 splits multibyte character'
|
||||||
eq(msg:rep(1), funcs.execute('messages'))
|
eq(msg:rep(1), funcs.execute('messages'))
|
||||||
end)
|
end)
|
||||||
@@ -398,7 +398,7 @@ describe('Command-line coloring', function()
|
|||||||
:echo 42 |
|
:echo 42 |
|
||||||
]])
|
]])
|
||||||
feed('\n')
|
feed('\n')
|
||||||
eq('echo 42', meths.get_var('out'))
|
eq('echo 42', meths.nvim_get_var('out'))
|
||||||
feed('<C-c>')
|
feed('<C-c>')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
^ |
|
^ |
|
||||||
@@ -564,16 +564,16 @@ describe('Command-line coloring', function()
|
|||||||
{EOB:~ }|*6
|
{EOB:~ }|*6
|
||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
eq('1234', meths.get_var('out'))
|
eq('1234', meths.nvim_get_var('out'))
|
||||||
eq('234', meths.get_var('out1'))
|
eq('234', meths.nvim_get_var('out1'))
|
||||||
eq('34', meths.get_var('out2'))
|
eq('34', meths.nvim_get_var('out2'))
|
||||||
eq('4', meths.get_var('out3'))
|
eq('4', meths.nvim_get_var('out3'))
|
||||||
eq(0, funcs.exists('g:out4'))
|
eq(0, funcs.exists('g:out4'))
|
||||||
end)
|
end)
|
||||||
it('runs callback with the same data only once', function()
|
it('runs callback with the same data only once', function()
|
||||||
local function new_recording_calls(...)
|
local function new_recording_calls(...)
|
||||||
eq({ ... }, meths.get_var('recording_calls'))
|
eq({ ... }, meths.nvim_get_var('recording_calls'))
|
||||||
meths.set_var('recording_calls', {})
|
meths.nvim_set_var('recording_calls', {})
|
||||||
end
|
end
|
||||||
set_color_cb('Recording')
|
set_color_cb('Recording')
|
||||||
start_prompt('')
|
start_prompt('')
|
||||||
@@ -594,7 +594,7 @@ describe('Command-line coloring', function()
|
|||||||
feed('<BS>')
|
feed('<BS>')
|
||||||
new_recording_calls() -- ('a')
|
new_recording_calls() -- ('a')
|
||||||
feed('<CR><CR>')
|
feed('<CR><CR>')
|
||||||
eq('', meths.get_var('out'))
|
eq('', meths.nvim_get_var('out'))
|
||||||
end)
|
end)
|
||||||
it('does not crash when callback has caught not-a-editor-command exception', function()
|
it('does not crash when callback has caught not-a-editor-command exception', function()
|
||||||
source([[
|
source([[
|
||||||
@@ -609,12 +609,12 @@ describe('Command-line coloring', function()
|
|||||||
]])
|
]])
|
||||||
set_color_cb('CaughtExc')
|
set_color_cb('CaughtExc')
|
||||||
start_prompt('1')
|
start_prompt('1')
|
||||||
eq(1, meths.eval('1'))
|
eq(1, meths.nvim_eval('1'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
describe('Ex commands coloring', function()
|
describe('Ex commands coloring', function()
|
||||||
it('works', function()
|
it('works', function()
|
||||||
meths.set_var('Nvim_color_cmdline', 'RainBowParens')
|
meths.nvim_set_var('Nvim_color_cmdline', 'RainBowParens')
|
||||||
feed(':echo (((1)))')
|
feed(':echo (((1)))')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
|
|
|
|
||||||
@@ -623,9 +623,9 @@ describe('Ex commands coloring', function()
|
|||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
it('still executes command-line even if errored out', function()
|
it('still executes command-line even if errored out', function()
|
||||||
meths.set_var('Nvim_color_cmdline', 'SplitMultibyteStart')
|
meths.nvim_set_var('Nvim_color_cmdline', 'SplitMultibyteStart')
|
||||||
feed(':let x = "«"\n')
|
feed(':let x = "«"\n')
|
||||||
eq('«', meths.get_var('x'))
|
eq('«', meths.nvim_get_var('x'))
|
||||||
local msg = 'E5405: Chunk 0 start 10 splits multibyte character'
|
local msg = 'E5405: Chunk 0 start 10 splits multibyte character'
|
||||||
eq('\n' .. msg, funcs.execute('messages'))
|
eq('\n' .. msg, funcs.execute('messages'))
|
||||||
end)
|
end)
|
||||||
@@ -709,7 +709,7 @@ describe('Ex commands coloring', function()
|
|||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
it('errors out when failing to get callback', function()
|
it('errors out when failing to get callback', function()
|
||||||
meths.set_var('Nvim_color_cmdline', 42)
|
meths.nvim_set_var('Nvim_color_cmdline', 42)
|
||||||
feed(':#')
|
feed(':#')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
|
|
|
|
||||||
@@ -725,10 +725,10 @@ describe('Ex commands coloring', function()
|
|||||||
end)
|
end)
|
||||||
describe('Expressions coloring support', function()
|
describe('Expressions coloring support', function()
|
||||||
it('works', function()
|
it('works', function()
|
||||||
meths.command('hi clear NvimNumber')
|
meths.nvim_command('hi clear NvimNumber')
|
||||||
meths.command('hi clear NvimNestingParenthesis')
|
meths.nvim_command('hi clear NvimNestingParenthesis')
|
||||||
meths.command('hi NvimNumber guifg=Blue2')
|
meths.nvim_command('hi NvimNumber guifg=Blue2')
|
||||||
meths.command('hi NvimNestingParenthesis guifg=Yellow')
|
meths.nvim_command('hi NvimNestingParenthesis guifg=Yellow')
|
||||||
feed(':echo <C-r>=(((1)))')
|
feed(':echo <C-r>=(((1)))')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
|
|
|
|
||||||
@@ -737,10 +737,10 @@ describe('Expressions coloring support', function()
|
|||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
it('does not use Nvim_color_expr', function()
|
it('does not use Nvim_color_expr', function()
|
||||||
meths.set_var('Nvim_color_expr', 42)
|
meths.nvim_set_var('Nvim_color_expr', 42)
|
||||||
-- Used to error out due to failing to get callback.
|
-- Used to error out due to failing to get callback.
|
||||||
meths.command('hi clear NvimNumber')
|
meths.nvim_command('hi clear NvimNumber')
|
||||||
meths.command('hi NvimNumber guifg=Blue2')
|
meths.nvim_command('hi NvimNumber guifg=Blue2')
|
||||||
feed(':<C-r>=1')
|
feed(':<C-r>=1')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
|
|
|
|
||||||
@@ -749,12 +749,12 @@ describe('Expressions coloring support', function()
|
|||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
it('works correctly with non-ASCII and control characters', function()
|
it('works correctly with non-ASCII and control characters', function()
|
||||||
meths.command('hi clear NvimStringBody')
|
meths.nvim_command('hi clear NvimStringBody')
|
||||||
meths.command('hi clear NvimStringQuote')
|
meths.nvim_command('hi clear NvimStringQuote')
|
||||||
meths.command('hi clear NvimInvalid')
|
meths.nvim_command('hi clear NvimInvalid')
|
||||||
meths.command('hi NvimStringQuote guifg=Blue3')
|
meths.nvim_command('hi NvimStringQuote guifg=Blue3')
|
||||||
meths.command('hi NvimStringBody guifg=Blue4')
|
meths.nvim_command('hi NvimStringBody guifg=Blue4')
|
||||||
meths.command('hi NvimInvalid guifg=Red guibg=Blue')
|
meths.nvim_command('hi NvimInvalid guifg=Red guibg=Blue')
|
||||||
feed('i<C-r>="«»"«»')
|
feed('i<C-r>="«»"«»')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
|
|
|
|
||||||
|
@@ -922,7 +922,7 @@ describe('cmdline redraw', function()
|
|||||||
|
|
||||||
it('with rightleftcmd', function()
|
it('with rightleftcmd', function()
|
||||||
command('set rightleft rightleftcmd=search shortmess+=s')
|
command('set rightleft rightleftcmd=search shortmess+=s')
|
||||||
meths.buf_set_lines(0, 0, -1, true, { "let's rock!" })
|
meths.nvim_buf_set_lines(0, 0, -1, true, { "let's rock!" })
|
||||||
screen:expect {
|
screen:expect {
|
||||||
grid = [[
|
grid = [[
|
||||||
!kcor s'te^l|
|
!kcor s'te^l|
|
||||||
@@ -1531,7 +1531,7 @@ describe('cmdheight=0', function()
|
|||||||
it('with multigrid', function()
|
it('with multigrid', function()
|
||||||
clear { args = { '--cmd', 'set cmdheight=0' } }
|
clear { args = { '--cmd', 'set cmdheight=0' } }
|
||||||
screen:attach { ext_multigrid = true }
|
screen:attach { ext_multigrid = true }
|
||||||
meths.buf_set_lines(0, 0, -1, true, { 'p' })
|
meths.nvim_buf_set_lines(0, 0, -1, true, { 'p' })
|
||||||
screen:expect {
|
screen:expect {
|
||||||
grid = [[
|
grid = [[
|
||||||
## grid 1
|
## grid 1
|
||||||
@@ -1701,9 +1701,9 @@ describe('cmdheight=0', function()
|
|||||||
{1:~ }|*3
|
{1:~ }|*3
|
||||||
{3:[No Name] }|
|
{3:[No Name] }|
|
||||||
]])
|
]])
|
||||||
meths.input_mouse('left', 'press', '', 0, 6, 10)
|
meths.nvim_input_mouse('left', 'press', '', 0, 6, 10)
|
||||||
poke_eventloop()
|
poke_eventloop()
|
||||||
meths.input_mouse('left', 'drag', '', 0, 5, 10)
|
meths.nvim_input_mouse('left', 'drag', '', 0, 5, 10)
|
||||||
screen:expect_unchanged()
|
screen:expect_unchanged()
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
@@ -299,7 +299,7 @@ describe('ui/cursor', function()
|
|||||||
}
|
}
|
||||||
|
|
||||||
-- Another cursor style.
|
-- Another cursor style.
|
||||||
meths.set_option_value(
|
meths.nvim_set_option_value(
|
||||||
'guicursor',
|
'guicursor',
|
||||||
'n-v-c:ver35-blinkwait171-blinkoff172-blinkon173'
|
'n-v-c:ver35-blinkwait171-blinkoff172-blinkon173'
|
||||||
.. ',ve:hor35,o:ver50,i-ci:block,r-cr:hor90,sm:ver42',
|
.. ',ve:hor35,o:ver50,i-ci:block,r-cr:hor90,sm:ver42',
|
||||||
@@ -326,7 +326,7 @@ describe('ui/cursor', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
-- If there is no setting for guicursor, it becomes the default setting.
|
-- If there is no setting for guicursor, it becomes the default setting.
|
||||||
meths.set_option_value(
|
meths.nvim_set_option_value(
|
||||||
'guicursor',
|
'guicursor',
|
||||||
'n:ver35-blinkwait171-blinkoff172-blinkon173-Cursor/lCursor',
|
'n:ver35-blinkwait171-blinkoff172-blinkon173-Cursor/lCursor',
|
||||||
{}
|
{}
|
||||||
@@ -346,7 +346,7 @@ describe('ui/cursor', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it("empty 'guicursor' sets cursor_shape=block in all modes", function()
|
it("empty 'guicursor' sets cursor_shape=block in all modes", function()
|
||||||
meths.set_option_value('guicursor', '', {})
|
meths.nvim_set_option_value('guicursor', '', {})
|
||||||
screen:expect(function()
|
screen:expect(function()
|
||||||
-- Empty 'guicursor' sets enabled=false.
|
-- Empty 'guicursor' sets enabled=false.
|
||||||
eq(false, screen._cursor_style_enabled)
|
eq(false, screen._cursor_style_enabled)
|
||||||
|
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user