From a4addb63da5ccee6b86a86164dfeaf3252142fba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Levente=20Krizs=C3=A1n?= Date: Sun, 1 Sep 2024 11:16:38 +0200 Subject: [PATCH] Set up better pane/buffer navigation --- init.lua | 9 +++++---- lazy-lock.json | 4 +++- lua/custom/plugins/bufferline.lua | 19 +++++++++++++++++- lua/custom/plugins/smart-splits.lua | 31 +++++++++++++++++++++++++++++ lua/custom/plugins/tmux.lua | 18 ----------------- 5 files changed, 57 insertions(+), 24 deletions(-) create mode 100644 lua/custom/plugins/smart-splits.lua delete mode 100644 lua/custom/plugins/tmux.lua diff --git a/init.lua b/init.lua index a4d7da79..4fa34a25 100644 --- a/init.lua +++ b/init.lua @@ -185,10 +185,10 @@ vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' } -- Use CTRL+ to switch between windows -- -- See `:help wincmd` for a list of all window commands -vim.keymap.set('n', '', '', { desc = 'Move focus to the left window' }) -vim.keymap.set('n', '', '', { desc = 'Move focus to the right window' }) -vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) -vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) +-- vim.keymap.set('n', '', '', { desc = 'Move focus to the left window' }) +-- vim.keymap.set('n', '', '', { desc = 'Move focus to the right window' }) +-- vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) +-- vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) vim.keymap.set('n', 'v', ':vsplit', { noremap = true, silent = true, desc = 'Create vertical split' }) vim.keymap.set('n', 'h', ':split', { noremap = true, silent = true, desc = 'Create horizontal split' }) @@ -871,6 +871,7 @@ require('lazy').setup({ -- -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`. 'rebelot/kanagawa.nvim', + lazy = false, priority = 10000, -- Make sure to load this before all the other start plugins. init = function() -- Load the colorscheme here. diff --git a/lazy-lock.json b/lazy-lock.json index c8ebffb8..1978476b 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -2,6 +2,7 @@ "LuaSnip": { "branch": "master", "commit": "45db5addf8d0a201e1cf247cae4cdce605ad3768" }, "barbar.nvim": { "branch": "master", "commit": "c20691d686addb0d6ea87896d186c082324b01f8" }, "bufferline.nvim": { "branch": "main", "commit": "0b2fd861eee7595015b6561dade52fb060be10c4" }, + "bufresize.nvim": { "branch": "master", "commit": "3b19527ab936d6910484dcc20fb59bdb12322d8b" }, "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, @@ -33,13 +34,14 @@ "nvim-ts-context-commentstring": { "branch": "main", "commit": "375c2d86cee6674afd75b4f727ce3a80065552f7" }, "nvim-web-devicons": { "branch": "master", "commit": "3722e3d1fb5fe1896a104eb489e8f8651260b520" }, "plenary.nvim": { "branch": "master", "commit": "ec289423a1693aeae6cd0d503bac2856af74edaa" }, + "smart-splits.nvim": { "branch": "master", "commit": "aee30930689ae427729aad41568ccaae57c167fe" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" }, "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, "telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, "todo-comments.nvim": { "branch": "main", "commit": "319c01b99b7a8c9ac2066bf0efd4d6ec68fef444" }, "tokyonight.nvim": { "branch": "main", "commit": "b0e7c7382a7e8f6456f2a95655983993ffda745e" }, + "trouble.nvim": { "branch": "main", "commit": "6efc446226679fda0547c0fd6a7892fd5f5b15d8" }, "ts-comments.nvim": { "branch": "main", "commit": "98d7d4dec0af1312d38e288f800bbf6ff562b6ab" }, "vim-sleuth": { "branch": "master", "commit": "1cc4557420f215d02c4d2645a748a816c220e99b" }, - "vim-tmux-navigator": { "branch": "master", "commit": "5b3c701686fb4e6629c100ed32e827edf8dad01e" }, "which-key.nvim": { "branch": "main", "commit": "bfec3d6bc0a9b0b2cb11644642f78c2c3915eef0" } } diff --git a/lua/custom/plugins/bufferline.lua b/lua/custom/plugins/bufferline.lua index 5b6ae3fd..2bae24d9 100644 --- a/lua/custom/plugins/bufferline.lua +++ b/lua/custom/plugins/bufferline.lua @@ -2,5 +2,22 @@ return { 'akinsho/bufferline.nvim', enabled = true, - opts = {}, + opts = { + options = { + mode = 'buffers', + themable = true, + diagnostics = 'nvim_lsp', + offsets = { + { + filetype = 'neo-tree', + }, + }, + }, + }, + config = function(_, opts) + require('bufferline').setup(opts) + + vim.keymap.set('n', '', ':BufferLineCycleNext', { noremap = true, silent = true, desc = 'Move to next buffer' }) + vim.keymap.set('n', '', ':BufferLineCyclePrev', { noremap = true, silent = true, desc = 'Move to previous buffer' }) + end, } diff --git a/lua/custom/plugins/smart-splits.lua b/lua/custom/plugins/smart-splits.lua new file mode 100644 index 00000000..0c4e22a0 --- /dev/null +++ b/lua/custom/plugins/smart-splits.lua @@ -0,0 +1,31 @@ +return { + 'mrjones2014/smart-splits.nvim', + dependencies = { + { 'kwkarlwang/bufresize.nvim', config = true }, + }, + config = function() + require('smart-splits').setup { + resize_mode = { + hooks = { + on_leave = require('bufresize').register, + }, + }, + } + local smart_splits = require 'smart-splits' + vim.keymap.set('n', '', smart_splits.resize_left) + vim.keymap.set('n', '', smart_splits.resize_down) + vim.keymap.set('n', '', smart_splits.resize_up) + vim.keymap.set('n', '', smart_splits.resize_right) + -- moving between splits + vim.keymap.set('n', '', smart_splits.move_cursor_left) + vim.keymap.set('n', '', smart_splits.move_cursor_down) + vim.keymap.set('n', '', smart_splits.move_cursor_up) + vim.keymap.set('n', '', smart_splits.move_cursor_right) + vim.keymap.set('n', '', smart_splits.move_cursor_previous) + -- swapping buffers between windows + vim.keymap.set('n', 'h', smart_splits.swap_buf_left) + vim.keymap.set('n', 'j', smart_splits.swap_buf_down) + vim.keymap.set('n', 'k', smart_splits.swap_buf_up) + vim.keymap.set('n', 'l', smart_splits.swap_buf_right) + end, +} diff --git a/lua/custom/plugins/tmux.lua b/lua/custom/plugins/tmux.lua deleted file mode 100644 index a9349b4b..00000000 --- a/lua/custom/plugins/tmux.lua +++ /dev/null @@ -1,18 +0,0 @@ -return { - 'christoomey/vim-tmux-navigator', - cmd = { - 'TmuxNavigateLeft', - 'TmuxNavigateDown', - 'TmuxNavigateUp', - 'TmuxNavigateRight', - 'TmuxNavigatePrevious', - }, - keys = { - { '', 'TmuxNavigateLeft' }, - { '', 'TmuxNavigateDown' }, - { '', 'TmuxNavigateUp' }, - { '', 'TmuxNavigateRight' }, - { '', 'TmuxNavigatePrevious' }, - }, -} --- vim: ts=2 sts=2 sw=2 et