Fix barbar integration with nvim-tree (#523)

- Add an offset to display NvimTree buffer in barbar.
It won't work correctly if you enable "vim.g.nvim_tree_quit_on_open".
- Add which-key support to barbar to enable missing mappings.

Co-authored-by: Christian Chiarulli <chris.machine@pm.me>
This commit is contained in:
kylo252 2021-06-26 19:37:24 +02:00 committed by GitHub
commit dc6196ee29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 1 deletions

View file

@ -20,6 +20,7 @@ vim.g.nvim_tree_indent_markers = 1 -- "0 by default, this option shows indent ma
vim.g.nvim_tree_follow = 1 -- "0 by default, this option allows the cursor to be updated when entering a buffer
vim.g.nvim_tree_auto_close = O.auto_close_tree -- 0 by default, closes the tree when it's the last window
vim.g.nvim_tree_auto_ignore_ft = 'startify' --empty by default, don't auto open tree on specific filetypes.
vim.g.nvim_tree_quit_on_open = 0 -- this doesn't play well with barbar
local tree_cb = require'nvim-tree.config'.nvim_tree_callback
vim.g.nvim_tree_bindings = {
-- ["<CR>"] = ":YourVimFunction()<cr>",
@ -63,3 +64,19 @@ vim.g.nvim_tree_icons = {
git = {unstaged = "", staged = "", unmerged = "", renamed = "", untracked = ""},
folder = {default = "", open = "", empty = "", empty_open = "", symlink = ""}
}
local view = require'nvim-tree.view'
local _M = {}
_M.toggle_tree = function()
if view.win_open() then
require'nvim-tree'.close()
require'bufferline.state'.set_offset(0)
else
require'bufferline.state'.set_offset(31, 'File Explorer')
require'nvim-tree'.find_file(true)
end
end
return _M