mirror of
https://github.com/neovim/neovim
synced 2025-07-27 08:52:10 +00:00
fix(lua): not using global value in vim.opt_global (#25196)
This commit is contained in:
@ -727,7 +727,10 @@ local function create_option_accessor(scope)
|
|||||||
|
|
||||||
return setmetatable({}, {
|
return setmetatable({}, {
|
||||||
__index = function(_, k)
|
__index = function(_, k)
|
||||||
return make_option(k, api.nvim_get_option_value(k, {}))
|
-- vim.opt_global must get global value only
|
||||||
|
-- vim.opt_local may fall back to global value like vim.opt
|
||||||
|
local opts = { scope = scope == 'global' and 'global' or nil }
|
||||||
|
return make_option(k, api.nvim_get_option_value(k, opts))
|
||||||
end,
|
end,
|
||||||
|
|
||||||
__newindex = function(_, k, v)
|
__newindex = function(_, k, v)
|
||||||
|
@ -2257,8 +2257,8 @@ describe('lua stdlib', function()
|
|||||||
end)
|
end)
|
||||||
end) -- vim.opt
|
end) -- vim.opt
|
||||||
|
|
||||||
describe('opt_local', function()
|
describe('vim.opt_local', function()
|
||||||
it('should be able to append to an array list type option', function()
|
it('appends into global value when changing local option value', function()
|
||||||
eq({ "foo,bar,baz,qux" }, exec_lua [[
|
eq({ "foo,bar,baz,qux" }, exec_lua [[
|
||||||
local result = {}
|
local result = {}
|
||||||
|
|
||||||
@ -2273,6 +2273,19 @@ describe('lua stdlib', function()
|
|||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
describe('vim.opt_global', function()
|
||||||
|
it('gets current global option value', function()
|
||||||
|
eq({ "yes" }, exec_lua [[
|
||||||
|
local result = {}
|
||||||
|
|
||||||
|
vim.cmd "setglobal signcolumn=yes"
|
||||||
|
table.insert(result, vim.opt_global.signcolumn:get())
|
||||||
|
|
||||||
|
return result
|
||||||
|
]])
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
|
||||||
it('vim.cmd', function()
|
it('vim.cmd', function()
|
||||||
exec_lua [[
|
exec_lua [[
|
||||||
vim.cmd "autocmd BufNew * ++once lua BUF = vim.fn.expand('<abuf>')"
|
vim.cmd "autocmd BufNew * ++once lua BUF = vim.fn.expand('<abuf>')"
|
||||||
|
Reference in New Issue
Block a user