mirror of
https://github.com/LunarVim/LunarVim.git
synced 2025-08-31 23:20:08 +02:00
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:
parent
918a26ebc0
commit
dc6196ee29
2 changed files with 37 additions and 1 deletions
|
@ -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_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_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_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
|
local tree_cb = require'nvim-tree.config'.nvim_tree_callback
|
||||||
vim.g.nvim_tree_bindings = {
|
vim.g.nvim_tree_bindings = {
|
||||||
-- ["<CR>"] = ":YourVimFunction()<cr>",
|
-- ["<CR>"] = ":YourVimFunction()<cr>",
|
||||||
|
@ -63,3 +64,19 @@ vim.g.nvim_tree_icons = {
|
||||||
git = {unstaged = "", staged = "✓", unmerged = "", renamed = "➜", untracked = ""},
|
git = {unstaged = "", staged = "✓", unmerged = "", renamed = "➜", untracked = ""},
|
||||||
folder = {default = "", open = "", empty = "", empty_open = "", symlink = ""}
|
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
|
||||||
|
|
|
@ -52,7 +52,7 @@ vim.g.mapleader = ' '
|
||||||
vim.api.nvim_set_keymap('n', '<Leader>h', ':let @/=""<CR>', {noremap = true, silent = true})
|
vim.api.nvim_set_keymap('n', '<Leader>h', ':let @/=""<CR>', {noremap = true, silent = true})
|
||||||
|
|
||||||
-- explorer
|
-- explorer
|
||||||
vim.api.nvim_set_keymap('n', '<Leader>e', ':NvimTreeToggle<CR>', {noremap = true, silent = true})
|
vim.api.nvim_set_keymap('n', '<Leader>e', ":lua require'lv-nvimtree'.toggle_tree()<CR>", {noremap = true, silent = true})
|
||||||
|
|
||||||
-- telescope
|
-- telescope
|
||||||
vim.api.nvim_set_keymap('n', '<Leader>f', ':Telescope find_files<CR>', {noremap = true, silent = true})
|
vim.api.nvim_set_keymap('n', '<Leader>f', ':Telescope find_files<CR>', {noremap = true, silent = true})
|
||||||
|
@ -74,6 +74,24 @@ vim.api.nvim_set_keymap('n', '<leader>p', ":lua require'telescope'.extensions.pr
|
||||||
-- TODO create entire treesitter section
|
-- TODO create entire treesitter section
|
||||||
|
|
||||||
local mappings = {
|
local mappings = {
|
||||||
|
|
||||||
|
["/"] = "Comment",
|
||||||
|
["c"] = "Close Buffer",
|
||||||
|
["e"] = "Explorer",
|
||||||
|
["f"] = "Find File",
|
||||||
|
["h"] = "No Highlight",
|
||||||
|
["p"] = "Projects",
|
||||||
|
b = {
|
||||||
|
name = "+Buffers",
|
||||||
|
j = {"<cmd>BufferPick<cr>", "jump to buffer"},
|
||||||
|
w = {"<cmd>BufferWipeout<cr>", "wipeout buffer"},
|
||||||
|
e = {"<cmd>BufferCloseAllButCurrent<cr>", "close all but current buffer"},
|
||||||
|
h = {"<cmd>BufferCloseBuffersLeft<cr>", "close all buffers to the left"},
|
||||||
|
l = {"<cmd>BufferCloseBuffersRight<cr>", "close all BufferLines to the right"},
|
||||||
|
D = {"<cmd>BufferOrderByDirectory<cr>", "sort BufferLines automatically by directory"},
|
||||||
|
L = {"<cmd>BufferOrderByLanguage<cr>", "sort BufferLines automatically by language"},
|
||||||
|
},
|
||||||
|
|
||||||
["/"] = {"<cmd>CommentToggle<cr>", "Comment"},
|
["/"] = {"<cmd>CommentToggle<cr>", "Comment"},
|
||||||
[";"] = {"<cmd>Dashboard<cr>", "Dashboard"},
|
[";"] = {"<cmd>Dashboard<cr>", "Dashboard"},
|
||||||
["c"] = {"<cmd>BufferClose<cr>", "Close Buffer"},
|
["c"] = {"<cmd>BufferClose<cr>", "Close Buffer"},
|
||||||
|
@ -81,6 +99,7 @@ local mappings = {
|
||||||
["f"] = {"<cmd>Telescope find_files<cr>", "Find File"},
|
["f"] = {"<cmd>Telescope find_files<cr>", "Find File"},
|
||||||
["h"] = {"<cmd>set hlsearch!<cr>", "No Highlight"},
|
["h"] = {"<cmd>set hlsearch!<cr>", "No Highlight"},
|
||||||
["p"] = {"<cmd>lua require'telescope'.extensions.project.project{}<cr>", "Projects"},
|
["p"] = {"<cmd>lua require'telescope'.extensions.project.project{}<cr>", "Projects"},
|
||||||
|
|
||||||
d = {
|
d = {
|
||||||
name = "Diagnostics",
|
name = "Diagnostics",
|
||||||
t = {"<cmd>TroubleToggle<cr>", "trouble"},
|
t = {"<cmd>TroubleToggle<cr>", "trouble"},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue