fix: stop using vim.wo to set window options

vim.wo also affects the global status of the option. We only want to set
the window-local option.
This commit is contained in:
Steven Arcangeli 2023-06-15 21:48:00 -07:00
parent 63cfd55eb2
commit 154f22393b
4 changed files with 9 additions and 5 deletions

View File

@ -129,6 +129,8 @@ local default_config = {
win_options = {
-- Window transparency (0-100)
winblend = 10,
cursorline = true,
cursorlineopt = "both",
},
-- These can be integers or a float between 0 and 1 (e.g. 0.4 for 40%)

View File

@ -316,7 +316,7 @@ setmetatable(M, {
start_in_insert = start_in_insert,
}
for option, value in pairs(config.win_options) do
vim.wo[winid][option] = value
vim.api.nvim_set_option_value(option, value, { scope = "local", win = winid })
end
local bufnr = vim.api.nvim_win_get_buf(winid)

View File

@ -75,10 +75,8 @@ M.select = function(config, items, opts, on_choice)
end
winopt = config.override(winopt) or winopt
local winid = vim.api.nvim_open_win(bufnr, true, winopt)
vim.wo[winid].cursorline = true
vim.wo[winid].cursorlineopt = "both"
for option, value in pairs(config.win_options) do
vim.wo[winid][option] = value
vim.api.nvim_set_option_value(option, value, { scope = "local", win = winid })
end
vim.bo[bufnr].filetype = "DressingSelect"
if vim.fn.has("nvim-0.9") == 0 then

View File

@ -136,7 +136,11 @@ M.add_title_to_win = function(winid, title, opts)
noautocmd = true,
})
winid_map[winid] = title_winid
vim.wo[title_winid].winblend = vim.wo[winid].winblend
vim.api.nvim_set_option_value(
"winblend",
vim.wo[winid].winblend,
{ scope = "local", win = title_winid }
)
vim.bo[bufnr].bufhidden = "wipe"
vim.cmd(string.format(
[[