From 4a5e7b0855bee95002827d4766e1dd4aab54785f Mon Sep 17 00:00:00 2001 From: Jannik Donker Date: Wed, 5 Nov 2025 19:45:59 +0100 Subject: [PATCH] added linux/mac handling for barbar (cmd or alt key) --- init.lua | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/init.lua b/init.lua index 3948565..574530b 100644 --- a/init.lua +++ b/init.lua @@ -28,19 +28,19 @@ vim.pack.add({ { src = "https://github.com/neovim/nvim-lspconfig" }, { src = "https://github.com/nvim-treesitter/nvim-treesitter" }, { src = "https://github.com/nvim-treesitter/nvim-treesitter-textobjects" }, - { src = "https://github.com/Saghen/blink.cmp", version = "v1.6.0", }, + { src = "https://github.com/Saghen/blink.cmp", version = "v1.6.0", }, { src = "https://github.com/mason-org/mason.nvim" }, { src = "https://github.com/dimitry-ishenko-neovim/lualine-nvim" }, { src = "https://github.com/chomosuke/typst-preview.nvim" }, { src = "https://github.com/kosayoda/nvim-lightbulb" }, - { src = "https://codeberg.org/mfussenegger/nvim-jdtls.git", dependencies = { "https://codeberg.org/mfussenegger/nvim-dap.git" } }, + { src = "https://codeberg.org/mfussenegger/nvim-jdtls.git", dependencies = { "https://codeberg.org/mfussenegger/nvim-dap.git" } }, { src = "https://github.com/m4xshen/autoclose.nvim", }, { src = "https://codeberg.org/mfussenegger/nvim-dap.git" }, { src = "https://github.com/romgrk/barbar.nvim" }, { src = "https://github.com/nvim-tree/nvim-web-devicons" }, { src = "https://github.com/lewis6991/gitsigns.nvim" }, { src = "https://github.com/folke/trouble.nvim" }, - { src = "https://github.com/rcarriga/nvim-dap-ui", dependencies = { "https://github.com/mfussenegger/nvim-dap", "https://github.com/nvim-neotest/nvim-nio" } }, + { src = "https://github.com/rcarriga/nvim-dap-ui", dependencies = { "https://github.com/mfussenegger/nvim-dap", "https://github.com/nvim-neotest/nvim-nio" } }, { src = "https://github.com/nvim-neotest/nvim-nio" }, }) @@ -233,29 +233,32 @@ map.set("n", "duc", dapui.close) map.set("n", "dbp", dap.toggle_breakpoint) map.set("n", "drc", dap.run_to_cursor) +local is_mac = vim.fn.has("macunix") == 1 +local barbarKey = is_mac and "M" or "A" + -- Move to previous/next -map.set('n', '', 'BufferPrevious', opts) -map.set('n', '', 'BufferNext', opts) +map.set('n', '<' .. barbarKey .. '-,>', 'BufferPrevious', opts) +map.set('n', '<' .. barbarKey .. '-.>', 'BufferNext', opts) -- Re-order to previous/next -map.set('n', '', 'BufferMovePrevious', opts) -map.set('n', '>', 'BufferMoveNext', opts) +map.set('n', '<' .. barbarKey .. '-<>', 'BufferMovePrevious', opts) +map.set('n', '<' .. barbarKey .. '->>', 'BufferMoveNext', opts) -- Goto buffer in position... -map.set('n', '', 'BufferGoto 1', opts) -map.set('n', '', 'BufferGoto 2', opts) -map.set('n', '', 'BufferGoto 3', opts) -map.set('n', '', 'BufferGoto 4', opts) -map.set('n', '', 'BufferGoto 5', opts) -map.set('n', '', 'BufferGoto 6', opts) -map.set('n', '', 'BufferGoto 7', opts) -map.set('n', '', 'BufferGoto 8', opts) -map.set('n', '', 'BufferGoto 9', opts) -map.set('n', '', 'BufferLast', opts) +map.set('n', '<' .. barbarKey .. '-1>', 'BufferGoto 1', opts) +map.set('n', '<' .. barbarKey .. '-2>', 'BufferGoto 2', opts) +map.set('n', '<' .. barbarKey .. '-3>', 'BufferGoto 3', opts) +map.set('n', '<' .. barbarKey .. '-4>', 'BufferGoto 4', opts) +map.set('n', '<' .. barbarKey .. '-5>', 'BufferGoto 5', opts) +map.set('n', '<' .. barbarKey .. '-6>', 'BufferGoto 6', opts) +map.set('n', '<' .. barbarKey .. '-7>', 'BufferGoto 7', opts) +map.set('n', '<' .. barbarKey .. '-8>', 'BufferGoto 8', opts) +map.set('n', '<' .. barbarKey .. '-9>', 'BufferGoto 9', opts) +map.set('n', '<' .. barbarKey .. '-0>', 'BufferLast', opts) -- Pin/unpin buffer -map.set('n', '', 'BufferPin', opts) +map.set('n', '<' .. barbarKey .. '-p>', 'BufferPin', opts) -- Close buffer -map.set('n', '', 'BufferClose', opts) +map.set('n', '<' .. barbarKey .. '-w>', 'BufferClose', opts) -- Magic buffer-picking mode map.set('n', '', 'BufferPick', opts)