do not follow global hide options for buffer

This commit is contained in:
kiyan
2021-04-14 23:46:44 +02:00
parent ce7b1861ad
commit 91c3d1b5eb
2 changed files with 10 additions and 7 deletions

View File

@@ -317,7 +317,7 @@ end
local M = {}
function M.draw(tree, reload)
api.nvim_buf_set_option(view.View.bufnr, 'modifiable', true)
if not api.nvim_buf_is_loaded(view.View.bufnr) then return end
local cursor
if view.win_open() then
cursor = api.nvim_win_get_cursor(view.View.winnr)
@@ -329,12 +329,14 @@ function M.draw(tree, reload)
update_draw_data(tree, 0, {})
end
api.nvim_buf_set_option(view.View.bufnr, 'modifiable', true)
api.nvim_buf_set_lines(view.View.bufnr, 0, -1, false, lines)
M.render_hl(view.View.bufnr)
api.nvim_buf_set_option(view.View.bufnr, 'modifiable', false)
if cursor and #lines >= cursor[1] then
api.nvim_win_set_cursor(view.View.winnr, cursor)
end
api.nvim_buf_set_option(view.View.bufnr, 'modifiable', false)
if cursor then
api.nvim_win_set_option(view.View.winnr, 'wrap', false)
end

View File

@@ -30,6 +30,7 @@ M.View = {
buftype = 'nofile';
modifiable = false;
filetype = 'NvimTree';
bufhidden = 'hide';
},
bindings = {
["<CR>"] = M.nvim_tree_callback("edit"),
@@ -67,11 +68,6 @@ M.View = {
-- set user options and create tree buffer (should never be wiped)
function M.setup()
M.View.bindings = vim.tbl_extend(
'force',
M.View.bindings,
vim.g.nvim_tree_bindings or {}
)
M.View.auto_resize = vim.g.nvim_tree_auto_resize or M.View.auto_resize
M.View.side = vim.g.nvim_tree_side or M.View.side
M.View.width = vim.g.nvim_tree_width or M.View.width
@@ -83,6 +79,11 @@ function M.setup()
a.nvim_buf_set_name(M.View.bufnr, 'NvimTree')
if not vim.g.nvim_tree_disable_keybindings then
M.View.bindings = vim.tbl_extend(
'force',
M.View.bindings,
vim.g.nvim_tree_bindings or {}
)
for key, cb in pairs(M.View.bindings) do
a.nvim_buf_set_keymap(M.View.bufnr, 'n', key, cb, { noremap = true, silent = true })
end