From a0f084a4652695cf947b2c755cfb102a7d7dce82 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 4 Jun 2024 12:37:26 +0100 Subject: [PATCH] nixvim buffer_manager --- home/common/core/nixvim/plugins/default.nix | 72 ++++++++++++++++++--- home/common/core/nixvim/plugins/harpoon.nix | 2 +- 2 files changed, 63 insertions(+), 11 deletions(-) diff --git a/home/common/core/nixvim/plugins/default.nix b/home/common/core/nixvim/plugins/default.nix index b2196e6..73d8f02 100644 --- a/home/common/core/nixvim/plugins/default.nix +++ b/home/common/core/nixvim/plugins/default.nix @@ -16,17 +16,69 @@ ]; # Load Plugins that aren't provided as modules by nixvim - programs.nixvim.extraPlugins = builtins.attrValues { - inherit (pkgs.vimPlugins) - ale - vim-numbertoggle - vimwiki - vim-dadbod - vim-dadbod-ui + programs.nixvim.extraPlugins = [ + pkgs.vimPlugins.vim-numbertoggle + pkgs.vimPlugins.vimwiki + pkgs.vimPlugins.vim-dadbod + pkgs.vimPlugins.vim-dadbod-ui - # Keep vim-devicons as last entry - vim-devicons; - }; + # Keep vim-devicons as last entry + pkgs.vimPlugins.vim-devicons + (pkgs.vimUtils.buildVimPlugin + { + name = "buffer_manager.nvim"; + src = pkgs.fetchFromGitHub { + owner = "j-morano"; + repo = "buffer_manager.nvim"; + rev = "fd36131"; + sha256 = "sha256-abe9ZGmL7U9rC+LxC3LO5/bOn8lHke1FCKO0V3TZGs0="; + }; + }) + ]; + programs.nixvim.extraConfigLua = '' + -- buffer_manager.nvim + local opts = {noremap = true} + + require("buffer_manager").setup( + { + line_keys = "1234567890", + select_menu_item_commands = { + edit = { + key = "", + command = "edit" + } + }, + focus_alternate_buffer = true, + short_file_names = false, + short_term_names = true, + height = 15, + width = 0.8, + loop_nav = true, + highlight = "", + win_extra_options = {}, + borderchars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" }, + order_buffers = "lastused", + show_indicators = "before", + } + ) + + -- Custom color for modified buffers + vim.api.nvim_set_hl(0, "BufferManagerModified", { fg = "#988100" }) + + local bmui = require("buffer_manager.ui") + vim.keymap.set('n', 'b', bmui.toggle_quick_menu, opts) + vim.keymap.set('n', 'n', bmui.nav_next, opts) + vim.keymap.set('n', 'p', bmui.nav_prev, opts) + + local keys="1234567890" + for i = 1, #keys do + local key = keys:sub(i,i) + vim.keymap.set('n', string.format('%s', key), + function () bmui.nav_file(i) end, + opts + ) + end + ''; } diff --git a/home/common/core/nixvim/plugins/harpoon.nix b/home/common/core/nixvim/plugins/harpoon.nix index 1462b1e..0080b57 100644 --- a/home/common/core/nixvim/plugins/harpoon.nix +++ b/home/common/core/nixvim/plugins/harpoon.nix @@ -2,7 +2,7 @@ programs.nixvim.plugins.harpoon = { enable = true; keymaps = { - toggleQuickMenu = "b"; + toggleQuickMenu = "h"; }; }; }