mirror of
https://github.com/neovim/neovim.git
synced 2026-04-28 18:24:13 +00:00
refactor(options): deprecate nvim[_buf|_win]_[gs]et_option
Co-authored-by: zeertzjq <zeertzjq@outlook.com> Co-authored-by: famiu <famiuhaque@protonmail.com>
This commit is contained in:
committed by
Famiu Haque
parent
e3e6fadfd8
commit
1fe1bb084d
@@ -415,7 +415,7 @@ describe('lua: nvim_buf_attach on_bytes', function()
|
||||
|
||||
it('opening lines', function()
|
||||
local check_events = setup_eventcheck(verify, origlines)
|
||||
-- meths.buf_set_option(0, 'autoindent', true)
|
||||
-- meths.set_option_value('autoindent', true, { buf = 0 })
|
||||
feed 'Go'
|
||||
check_events {
|
||||
{ "test1", "bytes", 1, 4, 7, 0, 114, 0, 0, 0, 1, 0, 1 };
|
||||
@@ -428,7 +428,7 @@ describe('lua: nvim_buf_attach on_bytes', function()
|
||||
|
||||
it('opening lines with autoindent', function()
|
||||
local check_events = setup_eventcheck(verify, origlines)
|
||||
meths.buf_set_option(0, 'autoindent', true)
|
||||
meths.set_option_value('autoindent', true, { buf = 0 })
|
||||
feed 'Go'
|
||||
check_events {
|
||||
{ "test1", "bytes", 1, 4, 7, 0, 114, 0, 0, 0, 1, 0, 5 };
|
||||
@@ -462,8 +462,8 @@ describe('lua: nvim_buf_attach on_bytes', function()
|
||||
|
||||
it('continuing comments with fo=or', function()
|
||||
local check_events = setup_eventcheck(verify, {'// Comment'})
|
||||
meths.buf_set_option(0, 'formatoptions', 'ro')
|
||||
meths.buf_set_option(0, 'filetype', 'c')
|
||||
meths.set_option_value('formatoptions', 'ro', { buf = 0 })
|
||||
meths.set_option_value('filetype', 'c', { buf = 0 })
|
||||
feed 'A<CR>'
|
||||
check_events {
|
||||
{ "test1", "bytes", 1, 4, 0, 10, 10, 0, 0, 0, 1, 3, 4 };
|
||||
@@ -603,7 +603,7 @@ describe('lua: nvim_buf_attach on_bytes', function()
|
||||
it('inccomand=nosplit and substitute', function()
|
||||
local check_events = setup_eventcheck(verify,
|
||||
{"abcde", "12345"})
|
||||
meths.set_option('inccommand', 'nosplit')
|
||||
meths.set_option_value('inccommand', 'nosplit', {})
|
||||
|
||||
-- linewise substitute
|
||||
feed(':%s/bcd/')
|
||||
@@ -998,7 +998,7 @@ describe('lua: nvim_buf_attach on_bytes', function()
|
||||
it("virtual edit", function ()
|
||||
local check_events = setup_eventcheck(verify, { "", " " })
|
||||
|
||||
meths.set_option("virtualedit", "all")
|
||||
meths.set_option_value('virtualedit', "all", {})
|
||||
|
||||
feed [[<Right><Right>iab<ESC>]]
|
||||
|
||||
|
||||
@@ -31,14 +31,12 @@ describe('nlua_expand_pat', function()
|
||||
eq(
|
||||
{{
|
||||
'nvim_buf_set_lines',
|
||||
'nvim_buf_set_option'
|
||||
}, 8
|
||||
},
|
||||
get_completions('vim.api.nvim_buf_', {
|
||||
vim = {
|
||||
api = {
|
||||
nvim_buf_set_lines = true,
|
||||
nvim_buf_set_option = true,
|
||||
nvim_win_doesnt_match = true,
|
||||
},
|
||||
other_key = true,
|
||||
@@ -68,14 +66,12 @@ describe('nlua_expand_pat', function()
|
||||
eq(
|
||||
{{
|
||||
'nvim_buf_set_lines',
|
||||
'nvim_buf_set_option'
|
||||
}, 11
|
||||
},
|
||||
get_completions('vim["api"].nvim_buf_', {
|
||||
vim = {
|
||||
api = {
|
||||
nvim_buf_set_lines = true,
|
||||
nvim_buf_set_option = true,
|
||||
nvim_win_doesnt_match = true,
|
||||
},
|
||||
other_key = true,
|
||||
@@ -88,7 +84,6 @@ describe('nlua_expand_pat', function()
|
||||
eq(
|
||||
{{
|
||||
'nvim_buf_set_lines',
|
||||
'nvim_buf_set_option'
|
||||
}, 21
|
||||
},
|
||||
get_completions('vim["nested"]["api"].nvim_buf_', {
|
||||
@@ -96,7 +91,6 @@ describe('nlua_expand_pat', function()
|
||||
nested = {
|
||||
api = {
|
||||
nvim_buf_set_lines = true,
|
||||
nvim_buf_set_option = true,
|
||||
nvim_win_doesnt_match = true,
|
||||
},
|
||||
},
|
||||
@@ -121,7 +115,6 @@ describe('nlua_expand_pat', function()
|
||||
eq(
|
||||
{{
|
||||
'nvim_buf_set_lines',
|
||||
'nvim_buf_set_option'
|
||||
}, 12
|
||||
},
|
||||
get_completions('vim[MY_VAR].nvim_buf_', {
|
||||
@@ -129,7 +122,6 @@ describe('nlua_expand_pat', function()
|
||||
vim = {
|
||||
api = {
|
||||
nvim_buf_set_lines = true,
|
||||
nvim_buf_set_option = true,
|
||||
nvim_win_doesnt_match = true,
|
||||
},
|
||||
other_key = true,
|
||||
|
||||
@@ -134,6 +134,6 @@ end)
|
||||
describe('filetype.lua', function()
|
||||
it('does not override user autocommands that set filetype #20333', function()
|
||||
clear({args={'--clean', '--cmd', 'autocmd BufRead *.md set filetype=notmarkdown', 'README.md'}})
|
||||
eq('notmarkdown', meths.buf_get_option(0, 'filetype'))
|
||||
eq('notmarkdown', meths.get_option_value('filetype', { buf = 0 }))
|
||||
end)
|
||||
end)
|
||||
|
||||
@@ -18,8 +18,8 @@ describe('vim.inspect_pos', function()
|
||||
vim.api.nvim_set_current_buf(buf)
|
||||
vim.api.nvim_buf_set_lines(0, 0, -1, false, {"local a = 123"})
|
||||
vim.api.nvim_buf_set_lines(buf1, 0, -1, false, {"--commentline"})
|
||||
vim.api.nvim_buf_set_option(buf, "filetype", "lua")
|
||||
vim.api.nvim_buf_set_option(buf1, "filetype", "lua")
|
||||
vim.bo[buf].filetype = 'lua'
|
||||
vim.bo[buf1].filetype = 'lua'
|
||||
vim.api.nvim_buf_set_extmark(buf, ns1, 0, 10, { hl_group = "Normal" })
|
||||
vim.api.nvim_buf_set_extmark(buf, ns2, 0, 10, { hl_group = "Normal" })
|
||||
vim.cmd("syntax on")
|
||||
@@ -97,7 +97,7 @@ describe('vim.show_pos', function()
|
||||
local buf = vim.api.nvim_create_buf(true, false)
|
||||
vim.api.nvim_set_current_buf(buf)
|
||||
vim.api.nvim_buf_set_lines(0, 0, -1, false, {"local a = 123"})
|
||||
vim.api.nvim_buf_set_option(buf, "filetype", "lua")
|
||||
vim.bo[buf].filetype = 'lua'
|
||||
vim.cmd("syntax on")
|
||||
return {buf, vim.show_pos(0, 0, 10)}
|
||||
]])
|
||||
|
||||
@@ -514,7 +514,7 @@ describe('v:lua', function()
|
||||
[5] = {bold = true, foreground = Screen.colors.SeaGreen4},
|
||||
})
|
||||
screen:attach()
|
||||
meths.buf_set_option(0, 'omnifunc', 'v:lua.mymod.omni')
|
||||
meths.set_option_value('omnifunc', 'v:lua.mymod.omni', { buf = 0 })
|
||||
feed('isome st<c-x><c-o>')
|
||||
screen:expect{grid=[[
|
||||
some stuff^ |
|
||||
@@ -526,7 +526,7 @@ describe('v:lua', function()
|
||||
{1:~ }|
|
||||
{4:-- Omni completion (^O^N^P) }{5:match 1 of 3} |
|
||||
]]}
|
||||
meths.set_option('operatorfunc', 'v:lua.mymod.noisy')
|
||||
meths.set_option_value('operatorfunc', 'v:lua.mymod.noisy', {})
|
||||
feed('<Esc>g@g@')
|
||||
eq("hey line", meths.get_current_line())
|
||||
end)
|
||||
|
||||
@@ -100,7 +100,7 @@ describe('print', function()
|
||||
pcall_err(command, 'lua bad_custom_error()'))
|
||||
end)
|
||||
it('prints strings with NULs and NLs correctly', function()
|
||||
meths.set_option('more', true)
|
||||
meths.set_option_value('more', true, {})
|
||||
eq('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")]]))
|
||||
eq('abc ^@ def\nghi^@^@^@jkl\nTEST\n\n\nT^@',
|
||||
|
||||
@@ -6,7 +6,7 @@ local clear = helpers.clear
|
||||
local command = helpers.command
|
||||
local pathsep = helpers.get_pathsep()
|
||||
local is_os = helpers.is_os
|
||||
local curbufmeths = helpers.curbufmeths
|
||||
local meths = helpers.meths
|
||||
local exec_lua = helpers.exec_lua
|
||||
local feed_command = helpers.feed_command
|
||||
local feed = helpers.feed
|
||||
@@ -160,7 +160,7 @@ describe('vim.secure', function()
|
||||
|
||||
-- Cannot write file
|
||||
pcall_err(command, 'write')
|
||||
eq(true, curbufmeths.get_option('readonly'))
|
||||
eq(true, meths.get_option_value('readonly', {buf=0}))
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
@@ -1496,9 +1496,9 @@ describe('lua stdlib', function()
|
||||
it('vim.bo', function()
|
||||
eq('', funcs.luaeval "vim.bo.filetype")
|
||||
exec_lua [[
|
||||
vim.api.nvim_buf_set_option(0, "filetype", "markdown")
|
||||
vim.api.nvim_set_option_value("filetype", "markdown", {buf = 0})
|
||||
BUF = vim.api.nvim_create_buf(false, true)
|
||||
vim.api.nvim_buf_set_option(BUF, "modifiable", false)
|
||||
vim.api.nvim_set_option_value("modifiable", false, {buf = BUF})
|
||||
]]
|
||||
eq(false, funcs.luaeval "vim.bo.modified")
|
||||
eq('markdown', funcs.luaeval "vim.bo.filetype")
|
||||
@@ -1519,9 +1519,9 @@ describe('lua stdlib', function()
|
||||
|
||||
it('vim.wo', function()
|
||||
exec_lua [[
|
||||
vim.api.nvim_win_set_option(0, "cole", 2)
|
||||
vim.api.nvim_set_option_value("cole", 2, {win=0})
|
||||
vim.cmd "split"
|
||||
vim.api.nvim_win_set_option(0, "cole", 2)
|
||||
vim.api.nvim_set_option_value("cole", 2, {win=0})
|
||||
]]
|
||||
eq(2, funcs.luaeval "vim.wo.cole")
|
||||
exec_lua [[
|
||||
@@ -1566,8 +1566,8 @@ describe('lua stdlib', function()
|
||||
local result = exec_lua [[
|
||||
local result = {}
|
||||
|
||||
table.insert(result, vim.api.nvim_get_option('scrolloff'))
|
||||
table.insert(result, vim.api.nvim_win_get_option(0, 'scrolloff'))
|
||||
table.insert(result, vim.api.nvim_get_option_value('scrolloff', {scope='global'}))
|
||||
table.insert(result, vim.api.nvim_get_option_value('scrolloff', {win=0}))
|
||||
|
||||
return result
|
||||
]]
|
||||
@@ -1631,20 +1631,20 @@ describe('lua stdlib', function()
|
||||
local result = {}
|
||||
|
||||
vim.opt.makeprg = "global-local"
|
||||
table.insert(result, vim.api.nvim_get_option('makeprg'))
|
||||
table.insert(result, vim.api.nvim_buf_get_option(0, 'makeprg'))
|
||||
table.insert(result, vim.go.makeprg)
|
||||
table.insert(result, vim.api.nvim_get_option_value('makeprg', {buf=0}))
|
||||
|
||||
vim.opt_local.mp = "only-local"
|
||||
table.insert(result, vim.api.nvim_get_option('makeprg'))
|
||||
table.insert(result, vim.api.nvim_buf_get_option(0, 'makeprg'))
|
||||
table.insert(result, vim.go.makeprg)
|
||||
table.insert(result, vim.api.nvim_get_option_value('makeprg', {buf=0}))
|
||||
|
||||
vim.opt_global.makeprg = "only-global"
|
||||
table.insert(result, vim.api.nvim_get_option('makeprg'))
|
||||
table.insert(result, vim.api.nvim_buf_get_option(0, 'makeprg'))
|
||||
table.insert(result, vim.go.makeprg)
|
||||
table.insert(result, vim.api.nvim_get_option_value('makeprg', {buf=0}))
|
||||
|
||||
vim.opt.makeprg = "global-local"
|
||||
table.insert(result, vim.api.nvim_get_option('makeprg'))
|
||||
table.insert(result, vim.api.nvim_buf_get_option(0, 'makeprg'))
|
||||
table.insert(result, vim.go.makeprg)
|
||||
table.insert(result, vim.api.nvim_get_option_value('makeprg', {buf=0}))
|
||||
return result
|
||||
]]
|
||||
|
||||
@@ -2173,7 +2173,7 @@ describe('lua stdlib', function()
|
||||
it('can handle isfname ,,,', function()
|
||||
local result = exec_lua [[
|
||||
vim.opt.isfname = "a,b,,,c"
|
||||
return { vim.opt.isfname:get(), vim.api.nvim_get_option('isfname') }
|
||||
return { vim.opt.isfname:get(), vim.go.isfname }
|
||||
]]
|
||||
|
||||
eq({{",", "a", "b", "c"}, "a,b,,,c"}, result)
|
||||
@@ -2183,7 +2183,7 @@ describe('lua stdlib', function()
|
||||
it('can handle isfname ,^,,', function()
|
||||
local result = exec_lua [[
|
||||
vim.opt.isfname = "a,b,^,,c"
|
||||
return { vim.opt.isfname:get(), vim.api.nvim_get_option('isfname') }
|
||||
return { vim.opt.isfname:get(), vim.go.isfname }
|
||||
]]
|
||||
|
||||
eq({{"^,", "a", "b", "c"}, "a,b,^,,c"}, result)
|
||||
@@ -2734,14 +2734,14 @@ describe('lua stdlib', function()
|
||||
|
||||
describe('vim.api.nvim_buf_call', function()
|
||||
it('can access buf options', function()
|
||||
local buf1 = meths.get_current_buf()
|
||||
local buf1 = meths.get_current_buf().id
|
||||
local buf2 = exec_lua [[
|
||||
buf2 = vim.api.nvim_create_buf(false, true)
|
||||
return buf2
|
||||
]]
|
||||
|
||||
eq(false, meths.buf_get_option(buf1, 'autoindent'))
|
||||
eq(false, meths.buf_get_option(buf2, 'autoindent'))
|
||||
eq(false, meths.get_option_value('autoindent', {buf=buf1}))
|
||||
eq(false, meths.get_option_value('autoindent', {buf=buf2}))
|
||||
|
||||
local val = exec_lua [[
|
||||
return vim.api.nvim_buf_call(buf2, function()
|
||||
@@ -2750,9 +2750,9 @@ describe('lua stdlib', function()
|
||||
end)
|
||||
]]
|
||||
|
||||
eq(false, meths.buf_get_option(buf1, 'autoindent'))
|
||||
eq(true, meths.buf_get_option(buf2, 'autoindent'))
|
||||
eq(buf1, meths.get_current_buf())
|
||||
eq(false, meths.get_option_value('autoindent', {buf=buf1}))
|
||||
eq(true, meths.get_option_value('autoindent', {buf=buf2}))
|
||||
eq(buf1, meths.get_current_buf().id)
|
||||
eq(buf2, val)
|
||||
end)
|
||||
|
||||
@@ -2771,10 +2771,10 @@ describe('lua stdlib', function()
|
||||
eq(true, exec_lua([[
|
||||
local function scratch_buf_call(fn)
|
||||
local buf = vim.api.nvim_create_buf(false, true)
|
||||
vim.api.nvim_buf_set_option(buf, 'cindent', true)
|
||||
vim.api.nvim_set_option_value('cindent', true, {buf = buf})
|
||||
return vim.api.nvim_buf_call(buf, function()
|
||||
return vim.api.nvim_get_current_buf() == buf
|
||||
and vim.api.nvim_buf_get_option(buf, 'cindent')
|
||||
and vim.api.nvim_get_option_value('cindent', {buf = buf})
|
||||
and fn()
|
||||
end) and vim.api.nvim_buf_delete(buf, {}) == nil
|
||||
end
|
||||
@@ -2811,7 +2811,7 @@ describe('lua stdlib', function()
|
||||
describe('vim.api.nvim_win_call', function()
|
||||
it('can access window options', function()
|
||||
command('vsplit')
|
||||
local win1 = meths.get_current_win()
|
||||
local win1 = meths.get_current_win().id
|
||||
command('wincmd w')
|
||||
local win2 = exec_lua [[
|
||||
win2 = vim.api.nvim_get_current_win()
|
||||
@@ -2819,8 +2819,8 @@ describe('lua stdlib', function()
|
||||
]]
|
||||
command('wincmd p')
|
||||
|
||||
eq('', meths.win_get_option(win1, 'winhighlight'))
|
||||
eq('', meths.win_get_option(win2, 'winhighlight'))
|
||||
eq('', meths.get_option_value('winhighlight', {win=win1}))
|
||||
eq('', meths.get_option_value('winhighlight', {win=win2}))
|
||||
|
||||
local val = exec_lua [[
|
||||
return vim.api.nvim_win_call(win2, function()
|
||||
@@ -2829,9 +2829,9 @@ describe('lua stdlib', function()
|
||||
end)
|
||||
]]
|
||||
|
||||
eq('', meths.win_get_option(win1, 'winhighlight'))
|
||||
eq('Normal:Normal', meths.win_get_option(win2, 'winhighlight'))
|
||||
eq(win1, meths.get_current_win())
|
||||
eq('', meths.get_option_value('winhighlight', {win=win1}))
|
||||
eq('Normal:Normal', meths.get_option_value('winhighlight', {win=win2}))
|
||||
eq(win1, meths.get_current_win().id)
|
||||
eq(win2, val)
|
||||
end)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user