From a22acac57d9ef8fe150e902ce9c9dcad76fc5f9a Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 12 Jul 2022 12:36:10 +0000 Subject: [PATCH] neovim improve bufferline and tree --- modules/editor/neovim/lua/keybinds.lua | 15 +++--- modules/editor/neovim/lua/packer/misc.lua | 1 - modules/editor/neovim/lua/packer/visuals.lua | 51 ++++++++++++++++++-- modules/editor/neovim/lua/packer_init.lua | 4 +- 4 files changed, 55 insertions(+), 16 deletions(-) diff --git a/modules/editor/neovim/lua/keybinds.lua b/modules/editor/neovim/lua/keybinds.lua index 9135e0a..bdfa235 100644 --- a/modules/editor/neovim/lua/keybinds.lua +++ b/modules/editor/neovim/lua/keybinds.lua @@ -26,15 +26,11 @@ key("n", "", ":m .-2==") key("v", "", ":m '>+1gv=gv") key("v", "", ":m '<-2gv=gv") --- Buffer tabs -key("n", "", "gt") -key("i", "", "gt") -key("n", "", "gT") -key("i", "", "gT") - --- Move buffers -key("n", "L", ":bnext") -key("n", "H", ":bprevious") +-- Better window navigation +key("n", "", "h") +key("n", "", "j") +key("n", "", "k") +key("n", "", "l") -- File commands key("n", "q", ":quit") @@ -80,3 +76,4 @@ key("n", "", ":noh", { silent = true }) --- Clear search in VimWiki key("n", "Y", "y$") --- Copy to end of line key("v", "", "y:%s/+//gc") --- Substitute selected key("v", "D", "y'>gp") --- Duplicate selected +key("v", "p", '"_dP') -- Don't overwrite register when pasting diff --git a/modules/editor/neovim/lua/packer/misc.lua b/modules/editor/neovim/lua/packer/misc.lua index e8c6980..5b015a4 100644 --- a/modules/editor/neovim/lua/packer/misc.lua +++ b/modules/editor/neovim/lua/packer/misc.lua @@ -9,7 +9,6 @@ M.packer = function(use) use("tpope/vim-vinegar") --- Fixes netrw file explorer use("tpope/vim-fugitive") --- Git commands and syntax use("tpope/vim-repeat") --- Actually repeat using . - use("christoomey/vim-tmux-navigator") --- Hotkeys for tmux panes -- Use gc or gcc to add comments use({ diff --git a/modules/editor/neovim/lua/packer/visuals.lua b/modules/editor/neovim/lua/packer/visuals.lua index 25ac39f..299d196 100644 --- a/modules/editor/neovim/lua/packer/visuals.lua +++ b/modules/editor/neovim/lua/packer/visuals.lua @@ -13,6 +13,7 @@ M.packer = function(use) vim.keymap.set("n", "gp", gitsigns.preview_hunk) vim.keymap.set("v", "gp", gitsigns.preview_hunk) vim.keymap.set("n", "gd", gitsigns.diffthis) + vim.keymap.set("v", "gd", gitsigns.diffthis) vim.keymap.set("n", "rgf", gitsigns.reset_buffer) vim.keymap.set("v", "hs", gitsigns.stage_hunk) vim.keymap.set("v", "hs", gitsigns.reset_hunk) @@ -37,7 +38,7 @@ M.packer = function(use) use({ "akinsho/bufferline.nvim", tag = "v2.*", - requires = "kyazdani42/nvim-web-devicons", + requires = { "kyazdani42/nvim-web-devicons", "moll/vim-bbye" }, config = function() require("bufferline").setup({ options = { @@ -47,7 +48,18 @@ M.packer = function(use) offsets = { { filetype = "NvimTree" } }, }, }) - vim.keymap.set("n", "x", " :bdelete") + -- Move buffers + vim.keymap.set("n", "L", ":BufferLineCycleNext") + vim.keymap.set("n", "H", ":BufferLineCyclePrev") + + -- Kill buffer + vim.keymap.set("n", "x", " :Bdelete") + + -- Shift buffers + -- vim.keymap.set("n", "", ":BufferLineMoveNext") + -- vim.keymap.set("i", "", ":BufferLineMoveNexti") + -- vim.keymap.set("n", "", ":BufferLineMovePrev") + -- vim.keymap.set("i", "", ":BufferLineMovePrevi") end, }) @@ -56,8 +68,39 @@ M.packer = function(use) "kyazdani42/nvim-tree.lua", requires = { "kyazdani42/nvim-web-devicons" }, config = function() - require("nvim-tree").setup() - vim.keymap.set("n", "e", ":NvimTreeToggle") + require("nvim-tree").setup({ + disable_netrw = true, + hijack_netrw = true, + diagnostics = { + enable = true, + icons = { + hint = "", + info = "", + warning = "", + error = "", + }, + }, + view = { + width = 30, + height = 30, + hide_root_folder = false, + side = "left", + mappings = { + custom_only = false, + list = { + { + key = { "l", "", "o" }, + cb = require("nvim-tree.config").nvim_tree_callback("edit"), + }, + { key = "h", cb = require("nvim-tree.config").nvim_tree_callback("close_node") }, + { key = "v", cb = require("nvim-tree.config").nvim_tree_callback("vsplit") }, + }, + }, + number = false, + relativenumber = false, + }, + }) + vim.keymap.set("n", "e", ":NvimTreeFindFileToggle") end, }) diff --git a/modules/editor/neovim/lua/packer_init.lua b/modules/editor/neovim/lua/packer_init.lua index 7989559..9491a9a 100644 --- a/modules/editor/neovim/lua/packer_init.lua +++ b/modules/editor/neovim/lua/packer_init.lua @@ -2,7 +2,7 @@ local fn = vim.fn local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim" if fn.empty(fn.glob(install_path)) > 0 then - packer_bootstrap = fn.system({ + PACKER_BOOTSTRAP = fn.system({ "git", "clone", "--depth", @@ -27,7 +27,7 @@ require("packer").startup(function(use) require("packer.telescope").packer(use) -- Auto-install after bootstrapping - if packer_bootstrap then + if PACKER_BOOTSTRAP then require("packer").sync() end end)