do not follow global hide options for buffer
This commit is contained in:
@@ -317,7 +317,7 @@ end
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
function M.draw(tree, reload)
|
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
|
local cursor
|
||||||
if view.win_open() then
|
if view.win_open() then
|
||||||
cursor = api.nvim_win_get_cursor(view.View.winnr)
|
cursor = api.nvim_win_get_cursor(view.View.winnr)
|
||||||
@@ -329,12 +329,14 @@ function M.draw(tree, reload)
|
|||||||
update_draw_data(tree, 0, {})
|
update_draw_data(tree, 0, {})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
api.nvim_buf_set_option(view.View.bufnr, 'modifiable', true)
|
||||||
api.nvim_buf_set_lines(view.View.bufnr, 0, -1, false, lines)
|
api.nvim_buf_set_lines(view.View.bufnr, 0, -1, false, lines)
|
||||||
M.render_hl(view.View.bufnr)
|
M.render_hl(view.View.bufnr)
|
||||||
|
api.nvim_buf_set_option(view.View.bufnr, 'modifiable', false)
|
||||||
|
|
||||||
if cursor and #lines >= cursor[1] then
|
if cursor and #lines >= cursor[1] then
|
||||||
api.nvim_win_set_cursor(view.View.winnr, cursor)
|
api.nvim_win_set_cursor(view.View.winnr, cursor)
|
||||||
end
|
end
|
||||||
api.nvim_buf_set_option(view.View.bufnr, 'modifiable', false)
|
|
||||||
if cursor then
|
if cursor then
|
||||||
api.nvim_win_set_option(view.View.winnr, 'wrap', false)
|
api.nvim_win_set_option(view.View.winnr, 'wrap', false)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ M.View = {
|
|||||||
buftype = 'nofile';
|
buftype = 'nofile';
|
||||||
modifiable = false;
|
modifiable = false;
|
||||||
filetype = 'NvimTree';
|
filetype = 'NvimTree';
|
||||||
|
bufhidden = 'hide';
|
||||||
},
|
},
|
||||||
bindings = {
|
bindings = {
|
||||||
["<CR>"] = M.nvim_tree_callback("edit"),
|
["<CR>"] = M.nvim_tree_callback("edit"),
|
||||||
@@ -67,11 +68,6 @@ M.View = {
|
|||||||
|
|
||||||
-- set user options and create tree buffer (should never be wiped)
|
-- set user options and create tree buffer (should never be wiped)
|
||||||
function M.setup()
|
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.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.side = vim.g.nvim_tree_side or M.View.side
|
||||||
M.View.width = vim.g.nvim_tree_width or M.View.width
|
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')
|
a.nvim_buf_set_name(M.View.bufnr, 'NvimTree')
|
||||||
|
|
||||||
if not vim.g.nvim_tree_disable_keybindings then
|
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
|
for key, cb in pairs(M.View.bindings) do
|
||||||
a.nvim_buf_set_keymap(M.View.bufnr, 'n', key, cb, { noremap = true, silent = true })
|
a.nvim_buf_set_keymap(M.View.bufnr, 'n', key, cb, { noremap = true, silent = true })
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user