summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorkylo252 <[email protected]>2021-06-26 19:37:24 +0200
committerGitHub <[email protected]>2021-06-26 13:37:24 -0400
commitdc6196ee295fa92b1a20a436be5d539f44475e29 (patch)
tree8022a8a1fa01f79b9f71a68adb4d5d451ebbf530 /lua
parent918a26ebc070ba21e5073b85a0addac867057617 (diff)
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 <[email protected]>
Diffstat (limited to 'lua')
-rw-r--r--lua/lv-nvimtree/init.lua17
-rw-r--r--lua/lv-which-key/init.lua21
2 files changed, 37 insertions, 1 deletions
diff --git a/lua/lv-nvimtree/init.lua b/lua/lv-nvimtree/init.lua
index 934a321b..4b8c3973 100644
--- a/lua/lv-nvimtree/init.lua
+++ b/lua/lv-nvimtree/init.lua
@@ -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
diff --git a/lua/lv-which-key/init.lua b/lua/lv-which-key/init.lua
index 27f1b406..d98ea3ed 100644
--- a/lua/lv-which-key/init.lua
+++ b/lua/lv-which-key/init.lua
@@ -52,7 +52,7 @@ vim.g.mapleader = ' '
vim.api.nvim_set_keymap('n', '<Leader>h', ':let @/=""<CR>', {noremap = true, silent = true})
-- 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
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
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>Dashboard<cr>", "Dashboard"},
["c"] = {"<cmd>BufferClose<cr>", "Close Buffer"},
@@ -81,6 +99,7 @@ local mappings = {
["f"] = {"<cmd>Telescope find_files<cr>", "Find File"},
["h"] = {"<cmd>set hlsearch!<cr>", "No Highlight"},
["p"] = {"<cmd>lua require'telescope'.extensions.project.project{}<cr>", "Projects"},
+
d = {
name = "Diagnostics",
t = {"<cmd>TroubleToggle<cr>", "trouble"},