Skip to content

Commit 6c8790f

Browse files
committed
use setlocal to avoid losing window options (neovim regression using lua api for setting options)
1 parent 048828b commit 6c8790f

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

lua/nvim-tree/view.lua

+16-3
Original file line numberDiff line numberDiff line change
@@ -249,23 +249,36 @@ local move_tbl = {
249249
top = 'K',
250250
}
251251

252+
-- TODO: remove this once they fix https://github.com/neovim/neovim/issues/14670
253+
local function set_local(opt, value)
254+
local cmd
255+
if value == true then
256+
cmd = string.format('setlocal %s', opt)
257+
elseif value == false then
258+
cmd = string.format('setlocal no%s', opt)
259+
else
260+
cmd = string.format('setlocal %s=%s', opt, value)
261+
end
262+
vim.cmd(cmd)
263+
end
264+
252265
function M.open()
253266
if not is_buf_valid() then
254267
M.setup()
255268
end
256269

257270
a.nvim_command("vsp")
271+
258272
local move_to = move_tbl[M.View.side]
259273
a.nvim_command("wincmd "..move_to)
260274
a.nvim_command("vertical resize "..get_width())
261275
local winnr = a.nvim_get_current_win()
262276
local tabpage = a.nvim_get_current_tabpage()
263277
M.View.tabpages[tabpage] = vim.tbl_extend("force", M.View.tabpages[tabpage] or {help = false}, {winnr = winnr})
278+
vim.cmd("buffer "..M.View.bufnr)
264279
for k, v in pairs(M.View.winopts) do
265-
vim.wo[winnr][k] = v
280+
set_local(k, v)
266281
end
267-
268-
vim.cmd("buffer "..M.View.bufnr)
269282
vim.cmd ":wincmd ="
270283
end
271284

0 commit comments

Comments
 (0)