From cb560705034928bb0e0817ee3cbcbbd2663eac3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20Mu=C3=B1oz=20Paredes?= Date: Wed, 3 Jul 2024 14:16:52 +0200 Subject: [PATCH] Improve keymaps --- init.lua | 24 +++++++++---------- lua/custom/init.lua | 45 ----------------------------------- lua/custom/plugins/barbar.lua | 19 ++++++++++----- 3 files changed, 25 insertions(+), 63 deletions(-) diff --git a/init.lua b/init.lua index c4f439d9..0d5f6c70 100644 --- a/init.lua +++ b/init.lua @@ -285,8 +285,8 @@ require('lazy').setup({ ['b'] = { name = '[B]uffer', _ = 'which_key_ignore' }, ['c'] = { name = '[C]ode', _ = 'which_key_ignore' }, ['d'] = { name = '[D]ebugger', _ = 'which_key_ignore' }, + ['f'] = { name = '[F]ind', _ = 'which_key_ignore' }, ['r'] = { name = '[R]ename', _ = 'which_key_ignore' }, - ['s'] = { name = '[S]earch', _ = 'which_key_ignore' }, ['w'] = { name = '[W]orkspace', _ = 'which_key_ignore' }, ['t'] = { name = '[T]oggle', _ = 'which_key_ignore' }, ['h'] = { name = 'Git [H]unk', _ = 'which_key_ignore' }, @@ -374,15 +374,15 @@ require('lazy').setup({ -- See `:help telescope.builtin` local builtin = require 'telescope.builtin' - vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) - vim.keymap.set('n', 'sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) - vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) - vim.keymap.set('n', 'ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) - vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) - vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) - vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) - vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) - vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) + vim.keymap.set('n', 'fh', builtin.help_tags, { desc = '[F]ind [H]elp' }) + vim.keymap.set('n', 'fk', builtin.keymaps, { desc = '[F]ind [K]eymaps' }) + vim.keymap.set('n', 'ff', builtin.find_files, { desc = '[F]ind [F]iles' }) + vim.keymap.set('n', 'fs', builtin.builtin, { desc = '[F]ind [S]elect Telescope' }) + vim.keymap.set('n', 'fw', builtin.grep_string, { desc = '[F]ind [W]ord' }) + vim.keymap.set('n', 'fg', builtin.live_grep, { desc = '[F]ind [G]rep' }) + vim.keymap.set('n', 'fd', builtin.diagnostics, { desc = '[F]ind [D]iagnostics' }) + vim.keymap.set('n', 'fr', builtin.resume, { desc = '[F]ind [R]esume' }) + vim.keymap.set('n', 'f.', builtin.oldfiles, { desc = '[F]ind Recent Files ("." for repeat)' }) vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) -- Slightly advanced example of overriding default behavior and theme @@ -633,12 +633,12 @@ require('lazy').setup({ lazy = false, keys = { { - 'f', + 'cf', function() require('conform').format { async = true, lsp_fallback = true } end, mode = '', - desc = '[F]ormat buffer', + desc = '[C]ode [F]ormat buffer', }, }, opts = { diff --git a/lua/custom/init.lua b/lua/custom/init.lua index 3db2efd5..3d117dc7 100644 --- a/lua/custom/init.lua +++ b/lua/custom/init.lua @@ -13,51 +13,6 @@ vim.keymap.set('i', '', function() end, { desc = '[S]ave file' }) --- mappings barbar - -local map = vim.api.nvim_set_keymap -local opts = { noremap = true, silent = true } --- Move to previous/next -map('n', '', 'BufferPrevious', opts) -map('n', '', 'BufferNext', opts) --- Re-order to previous/next -map('n', '', 'BufferMovePrevious', opts) -map('n', '>', 'BufferMoveNext', opts) --- Goto buffer in position... -map('n', '', 'BufferGoto 1', opts) -map('n', '', 'BufferGoto 2', opts) -map('n', '', 'BufferGoto 3', opts) -map('n', '', 'BufferGoto 4', opts) -map('n', '', 'BufferGoto 5', opts) -map('n', '', 'BufferGoto 6', opts) -map('n', '', 'BufferGoto 7', opts) -map('n', '', 'BufferGoto 8', opts) -map('n', '', 'BufferGoto 9', opts) -map('n', '', 'BufferLast', opts) --- Pin/unpin buffer -map('n', '', 'BufferPin', opts) --- Close buffer -map('n', '', 'BufferClose', opts) --- Wipeout buffer --- :BufferWipeout --- Close commands -map('n', 'bcab', 'BufferCloseAllButCurrent', opts) -map('n', 'bcab', 'BufferCloseAllButPinned', opts) -map('n', 'bcar', 'BufferCloseBuffersRight', opts) --- :BufferCloseAllButCurrent --- :BufferCloseAllButPinned --- :BufferCloseAllButCurrentOrPinned --- :BufferCloseBuffersLeft --- :BufferCloseBuffersRight --- Magic buffer-picking mode -map('n', '', 'BufferPick', opts) --- Sort automatically by... -map('n', 'bb', 'BufferOrderByBufferNumber', opts) -map('n', 'bn', 'BufferOrderByName', opts) -map('n', 'bd', 'BufferOrderByDirectory', opts) -map('n', 'bl', 'BufferOrderByLanguage', opts) -map('n', 'bw', 'BufferOrderByWindowNumber', opts) - vim.api.nvim_create_autocmd('VimEnter', { desc = 'Auto select virtualenv Nvim open', pattern = '*', diff --git a/lua/custom/plugins/barbar.lua b/lua/custom/plugins/barbar.lua index 8ed38c8a..591a5a89 100644 --- a/lua/custom/plugins/barbar.lua +++ b/lua/custom/plugins/barbar.lua @@ -7,13 +7,20 @@ return { }, init = function() vim.g.barbar_auto_setup = false + local map = vim.api.nvim_set_keymap + local opts = { noremap = true, silent = true } + -- Move to previous/next + map('n', '', 'BufferPrevious', opts) + map('n', '', 'BufferNext', opts) + -- Pin/unpin buffer + map('n', '', 'BufferPin', opts) + -- Close buffer + map('n', '', 'BufferClose', opts) + -- Magic buffer-picking mode + map('n', '', 'BufferPick', opts) end, - opts = { - -- lazy.nvim will automatically call setup for you. put your options here, anything missing will use the default: - -- animation = true, - -- insert_at_start = true, - -- …etc. - }, + opts = {}, + version = '^1.0.0', -- optional: only update when a new 1.x version is released }, }