From 837e5418d6e3246b2849e0a3e50bedd87f0bcd14 Mon Sep 17 00:00:00 2001 From: Tobias Manske Date: Tue, 28 Jun 2022 02:42:37 +0200 Subject: [PATCH] VIM: Smart buffer handling --- vim/config/keybindings.vim | 38 ++++++++++++++++++++++++++++++++++++++ vim/config/plugins.vim | 2 ++ 2 files changed, 40 insertions(+) diff --git a/vim/config/keybindings.vim b/vim/config/keybindings.vim index da27029..e036b9b 100644 --- a/vim/config/keybindings.vim +++ b/vim/config/keybindings.vim @@ -61,3 +61,41 @@ autocmd Filetype rmd imap :w\|:!echo"require(rmarkdown); imap + +" nvim smartbuffs +" Jump to the N buffer (by index) according to :ls buffer list +" where N is NOT the buffer number but the INDEX in such list +" NOTE: it does not include terminal buffers +nnoremap 1 :lua require("nvim-smartbufs").goto_buffer(1) +nnoremap 2 :lua require("nvim-smartbufs").goto_buffer(2) +nnoremap 3 :lua require("nvim-smartbufs").goto_buffer(3) +nnoremap 4 :lua require("nvim-smartbufs").goto_buffer(4) +nnoremap 5 :lua require("nvim-smartbufs").goto_buffer(5) +nnoremap 6 :lua require("nvim-smartbufs").goto_buffer(6) +nnoremap 7 :lua require("nvim-smartbufs").goto_buffer(7) +nnoremap 8 :lua require("nvim-smartbufs").goto_buffer(8) +nnoremap 9 :lua require("nvim-smartbufs").goto_buffer(9) + +" Improved :bnext :bprev behavior (without considering terminal buffers) +nnoremap :lua require("nvim-smartbufs").goto_next_buffer() +nnoremap :lua require("nvim-smartbufs").goto_prev_buffer() + +" Open terminal buffer and set it as hidden so it won't get deleted +nnoremap c1 :lua require("nvim-smartbufs").goto_terminal(1) +nnoremap c2 :lua require("nvim-smartbufs").goto_terminal(2) +nnoremap c3 :lua require("nvim-smartbufs").goto_terminal(3) +nnoremap c4 :lua require("nvim-smartbufs").goto_terminal(4) + +" Delete current buffer and goes back to the previous one +nnoremap qq :lua require("nvim-smartbufs").close_current_buffer() + +" Delete the N buffer according to :ls buffer list +nnoremap q1 :lua require("nvim-smartbufs").close_buffer(1) +nnoremap q2 :lua require("nvim-smartbufs").close_buffer(2) +nnoremap q3 :lua require("nvim-smartbufs").close_buffer(3) +nnoremap q4 :lua require("nvim-smartbufs").close_buffer(4) +nnoremap q5 :lua require("nvim-smartbufs").close_buffer(5) +nnoremap q6 :lua require("nvim-smartbufs").close_buffer(6) +nnoremap q7 :lua require("nvim-smartbufs").close_buffer(7) +nnoremap q8 :lua require("nvim-smartbufs").close_buffer(8) +nnoremap q9 :lua require("nvim-smartbufs").close_buffer(9) diff --git a/vim/config/plugins.vim b/vim/config/plugins.vim index a23fe38..7383b4d 100644 --- a/vim/config/plugins.vim +++ b/vim/config/plugins.vim @@ -101,7 +101,9 @@ Plug 'rad4day/vim-ripgrep' Plug 'github/copilot.vim' +" Fancy buffer handling Plug 'akinsho/bufferline.nvim', { 'tag': 'v2.2.1' } +Plug 'johann2357/nvim-smartbufs' Plug 'braxtons12/blame_line.nvim'