|
122 | 122 | function M.tab_change()
|
123 | 123 | if view.is_visible { any_tabpage = true } then
|
124 | 124 | local bufname = api.nvim_buf_get_name(0)
|
125 |
| - if bufname:match "Neogit" ~= nil or bufname:match "--graph" ~= nil then |
126 |
| - return |
| 125 | + local ft = api.nvim_buf_get_option(0, "ft") |
| 126 | + for _, filter in ipairs(M.config.ignore_buf_on_tab_change) do |
| 127 | + if bufname:match(filter) ~= nil or ft:match(filter) ~= nil then |
| 128 | + return |
| 129 | + end |
127 | 130 | end
|
128 | 131 | view.open { focus_tree = false }
|
129 | 132 | require("nvim-tree.renderer").draw()
|
@@ -350,7 +353,7 @@ local function setup_autocommands(opts)
|
350 | 353 | end
|
351 | 354 |
|
352 | 355 | if opts.open_on_tab then
|
353 |
| - create_nvim_tree_autocmd("TabEnter", { callback = M.tab_change }) |
| 356 | + create_nvim_tree_autocmd("TabEnter", { callback = vim.schedule_wrap(M.tab_change) }) |
354 | 357 | end
|
355 | 358 | if opts.hijack_cursor then
|
356 | 359 | create_nvim_tree_autocmd("CursorMoved", { pattern = "NvimTree_*", callback = M.place_cursor_on_node })
|
@@ -424,6 +427,7 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
|
424 | 427 | open_on_setup = false,
|
425 | 428 | open_on_setup_file = false,
|
426 | 429 | open_on_tab = false,
|
| 430 | + ignore_buf_on_tab_change = {}, |
427 | 431 | sort_by = "name",
|
428 | 432 | root_dirs = {},
|
429 | 433 | prefer_startup_root = false,
|
@@ -665,6 +669,7 @@ function M.setup(conf)
|
665 | 669 | _config.open_on_setup_file = opts.open_on_setup_file
|
666 | 670 | _config.ignore_buffer_on_setup = opts.ignore_buffer_on_setup
|
667 | 671 | _config.ignore_ft_on_setup = opts.ignore_ft_on_setup
|
| 672 | + _config.ignore_buf_on_tab_change = opts.ignore_buf_on_tab_change |
668 | 673 | _config.hijack_directories = opts.hijack_directories
|
669 | 674 | _config.hijack_directories.enable = _config.hijack_directories.enable and netrw_disabled
|
670 | 675 |
|
|
0 commit comments