mirror of
https://github.com/neovim/neovim.git
synced 2025-12-16 03:15:39 +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
@@ -105,7 +105,7 @@ describe('float window', function()
|
||||
|
||||
it('opened with correct height', function()
|
||||
local height = exec_lua([[
|
||||
vim.api.nvim_set_option("winheight", 20)
|
||||
vim.go.winheight = 20
|
||||
local bufnr = vim.api.nvim_create_buf(false, true)
|
||||
|
||||
local opts = {
|
||||
@@ -127,7 +127,7 @@ describe('float window', function()
|
||||
|
||||
it('opened with correct width', function()
|
||||
local width = exec_lua([[
|
||||
vim.api.nvim_set_option("winwidth", 20)
|
||||
vim.go.winwidth = 20
|
||||
local bufnr = vim.api.nvim_create_buf(false, true)
|
||||
|
||||
local opts = {
|
||||
@@ -427,36 +427,36 @@ describe('float window', function()
|
||||
it("no segfault when setting minimal style after clearing local 'fillchars' #19510", function()
|
||||
local float_opts = {relative = 'editor', row = 1, col = 1, width = 1, height = 1}
|
||||
local float_win = meths.open_win(0, true, float_opts)
|
||||
meths.win_set_option(float_win, 'fillchars', NIL)
|
||||
meths.set_option_value('fillchars', NIL, {win=float_win.id})
|
||||
float_opts.style = 'minimal'
|
||||
meths.win_set_config(float_win, float_opts)
|
||||
assert_alive()
|
||||
end)
|
||||
end)
|
||||
|
||||
it("should re-apply 'style' when present", function()
|
||||
it("should re-apply 'style' when present", function()
|
||||
local float_opts = {style = 'minimal', relative = 'editor', row = 1, col = 1, width = 1, height = 1}
|
||||
local float_win = meths.open_win(0, true, float_opts)
|
||||
meths.win_set_option(float_win, 'number', true)
|
||||
meths.set_option_value('number', true, { win = float_win })
|
||||
float_opts.row = 2
|
||||
meths.win_set_config(float_win, float_opts)
|
||||
eq(false, meths.win_get_option(float_win, 'number'))
|
||||
eq(false, meths.get_option_value('number', { win = float_win }))
|
||||
end)
|
||||
|
||||
it("should not re-apply 'style' when missing", function()
|
||||
local float_opts = {style = 'minimal', relative = 'editor', row = 1, col = 1, width = 1, height = 1}
|
||||
local float_win = meths.open_win(0, true, float_opts)
|
||||
meths.win_set_option(float_win, 'number', true)
|
||||
meths.set_option_value('number', true, { win = float_win })
|
||||
float_opts.row = 2
|
||||
float_opts.style = nil
|
||||
meths.win_set_config(float_win, float_opts)
|
||||
eq(true, meths.win_get_option(float_win, 'number'))
|
||||
eq(true, meths.get_option_value('number', { win = float_win }))
|
||||
end)
|
||||
|
||||
it("'scroll' is computed correctly when opening float with splitkeep=screen #20684", function()
|
||||
meths.set_option('splitkeep', 'screen')
|
||||
meths.set_option_value('splitkeep', 'screen', {})
|
||||
local float_opts = {relative = 'editor', row = 1, col = 1, width = 10, height = 10}
|
||||
local float_win = meths.open_win(0, true, float_opts)
|
||||
eq(5, meths.win_get_option(float_win, 'scroll'))
|
||||
eq(5, meths.get_option_value('scroll', {win=float_win.id}))
|
||||
end)
|
||||
|
||||
describe('with only one tabpage,', function()
|
||||
@@ -4553,8 +4553,8 @@ describe('float window', function()
|
||||
describe('and completion', function()
|
||||
before_each(function()
|
||||
local buf = meths.create_buf(false,false)
|
||||
local win = meths.open_win(buf, true, {relative='editor', width=12, height=4, row=2, col=5})
|
||||
meths.win_set_option(win , 'winhl', 'Normal:ErrorMsg')
|
||||
local win = meths.open_win(buf, true, {relative='editor', width=12, height=4, row=2, col=5}).id
|
||||
meths.set_option_value('winhl', 'Normal:ErrorMsg', {win=win})
|
||||
if multigrid then
|
||||
screen:expect{grid=[[
|
||||
## grid 1
|
||||
@@ -7823,7 +7823,7 @@ describe('float window', function()
|
||||
local buf = meths.create_buf(false,false)
|
||||
meths.buf_set_lines(buf, 0, -1, true, {'foo', 'bar', 'baz'})
|
||||
local float_win = meths.open_win(buf, false, {relative='editor', width=20, height=4, row=1, col=5})
|
||||
meths.win_set_option(float_win, 'winbar', 'floaty bar')
|
||||
meths.set_option_value('winbar', 'floaty bar', {win=float_win.id})
|
||||
if multigrid then
|
||||
screen:expect{grid=[[
|
||||
## grid 1
|
||||
@@ -8144,7 +8144,7 @@ describe('float window', function()
|
||||
]])
|
||||
end
|
||||
|
||||
meths.win_set_option(win, "winblend", 30)
|
||||
meths.set_option_value("winblend", 30, {win=win.id})
|
||||
if multigrid then
|
||||
screen:expect{grid=[[
|
||||
## grid 1
|
||||
@@ -8452,7 +8452,7 @@ describe('float window', function()
|
||||
-- at least. Also check invisible EndOfBuffer region blends correctly.
|
||||
meths.buf_set_lines(buf, 0, -1, true, {" x x x xx", " x x x x"})
|
||||
win = meths.open_win(buf, false, {relative='editor', width=12, height=3, row=0, col=11, style='minimal'})
|
||||
meths.win_set_option(win, 'winblend', 30)
|
||||
meths.set_option_value('winblend', 30, {win=win.id})
|
||||
screen:set_default_attr_ids({
|
||||
[1] = {foreground = tonumber('0xb282b2'), background = tonumber('0xffcfff')},
|
||||
[2] = {foreground = Screen.colors.Grey0, background = tonumber('0xffcfff')},
|
||||
@@ -8694,7 +8694,7 @@ describe('float window', function()
|
||||
it("correctly orders multiple opened floats (current last)", function()
|
||||
local buf = meths.create_buf(false,false)
|
||||
local win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5})
|
||||
meths.win_set_option(win, "winhl", "Normal:ErrorMsg,EndOfBuffer:ErrorMsg")
|
||||
meths.set_option_value("winhl", "Normal:ErrorMsg,EndOfBuffer:ErrorMsg", {win=win.id})
|
||||
|
||||
if multigrid then
|
||||
screen:expect{grid=[[
|
||||
@@ -8739,10 +8739,10 @@ describe('float window', function()
|
||||
exec_lua [[
|
||||
local buf = vim.api.nvim_create_buf(false,false)
|
||||
local win = vim.api.nvim_open_win(buf, false, {relative='editor', width=16, height=2, row=3, col=8})
|
||||
vim.api.nvim_win_set_option(win, "winhl", "EndOfBuffer:Normal")
|
||||
vim.wo[win].winhl = "EndOfBuffer:Normal"
|
||||
buf = vim.api.nvim_create_buf(false,false)
|
||||
win = vim.api.nvim_open_win(buf, true, {relative='editor', width=12, height=2, row=4, col=10})
|
||||
vim.api.nvim_win_set_option(win, "winhl", "Normal:Search,EndOfBuffer:Search")
|
||||
vim.wo[win].winhl = "Normal:Search,EndOfBuffer:Search"
|
||||
]]
|
||||
|
||||
if multigrid then
|
||||
@@ -8799,7 +8799,7 @@ describe('float window', function()
|
||||
it("correctly orders multiple opened floats (non-current last)", function()
|
||||
local buf = meths.create_buf(false,false)
|
||||
local win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5})
|
||||
meths.win_set_option(win, "winhl", "Normal:ErrorMsg,EndOfBuffer:ErrorMsg")
|
||||
meths.set_option_value("winhl", "Normal:ErrorMsg,EndOfBuffer:ErrorMsg", {win=win.id})
|
||||
|
||||
if multigrid then
|
||||
screen:expect{grid=[[
|
||||
@@ -8844,10 +8844,10 @@ describe('float window', function()
|
||||
exec_lua [[
|
||||
local buf = vim.api.nvim_create_buf(false,false)
|
||||
local win = vim.api.nvim_open_win(buf, true, {relative='editor', width=12, height=2, row=4, col=10})
|
||||
vim.api.nvim_win_set_option(win, "winhl", "Normal:Search,EndOfBuffer:Search")
|
||||
vim.wo[win].winhl = "Normal:Search,EndOfBuffer:Search"
|
||||
buf = vim.api.nvim_create_buf(false,false)
|
||||
win = vim.api.nvim_open_win(buf, false, {relative='editor', width=16, height=2, row=3, col=8})
|
||||
vim.api.nvim_win_set_option(win, "winhl", "EndOfBuffer:Normal")
|
||||
vim.wo[win].winhl = "EndOfBuffer:Normal"
|
||||
]]
|
||||
|
||||
if multigrid then
|
||||
@@ -8904,11 +8904,11 @@ describe('float window', function()
|
||||
it('can use z-index', function()
|
||||
local buf = meths.create_buf(false,false)
|
||||
local win1 = meths.open_win(buf, false, {relative='editor', width=20, height=3, row=1, col=5, zindex=30})
|
||||
meths.win_set_option(win1, "winhl", "Normal:ErrorMsg,EndOfBuffer:ErrorMsg")
|
||||
meths.set_option_value("winhl", "Normal:ErrorMsg,EndOfBuffer:ErrorMsg", {win=win1.id})
|
||||
local win2 = meths.open_win(buf, false, {relative='editor', width=20, height=3, row=2, col=6, zindex=50})
|
||||
meths.win_set_option(win2, "winhl", "Normal:Search,EndOfBuffer:Search")
|
||||
meths.set_option_value("winhl", "Normal:Search,EndOfBuffer:Search", {win=win2.id})
|
||||
local win3 = meths.open_win(buf, false, {relative='editor', width=20, height=3, row=3, col=7, zindex=40})
|
||||
meths.win_set_option(win3, "winhl", "Normal:Question,EndOfBuffer:Question")
|
||||
meths.set_option_value("winhl", "Normal:Question,EndOfBuffer:Question", {win=win3.id})
|
||||
|
||||
if multigrid then
|
||||
screen:expect{grid=[[
|
||||
@@ -8967,7 +8967,7 @@ describe('float window', function()
|
||||
it('can use winbar', function()
|
||||
local buf = meths.create_buf(false,false)
|
||||
local win1 = meths.open_win(buf, false, {relative='editor', width=15, height=3, row=1, col=5})
|
||||
meths.win_set_option(win1, 'winbar', 'floaty bar')
|
||||
meths.set_option_value('winbar', 'floaty bar', {win=win1.id})
|
||||
|
||||
if multigrid then
|
||||
screen:expect{grid=[[
|
||||
|
||||
Reference in New Issue
Block a user