From 4c5fa067e26bb3a86c401997e949334c8924bb90 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Sun, 28 Sep 2025 21:28:19 +0545 Subject: [PATCH] refactor(keys): improve keymap configurations and remove unused floaterm plugin --- lazy-lock.json | 28 +++++------ lua/core/keys.lua | 30 +++++------ lua/core/options.lua | 106 +++++++++++++++++++-------------------- lua/plugins/files.lua | 97 ++++++++++++++++------------------- lua/plugins/utility.lua | 38 +++++--------- lua/plugins/whichkey.lua | 16 +----- 6 files changed, 137 insertions(+), 178 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index 45d568e..99766ef 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -4,43 +4,43 @@ "Navigator.nvim": { "branch": "master", "commit": "91d86506ac2a039504d5205d32a1d4bc7aa57072" }, "better-escape.nvim": { "branch": "master", "commit": "19a38aab94961016430905ebec30d272a01e9742" }, "blink.cmp": { "branch": "main", "commit": "327fff91fe6af358e990be7be1ec8b78037d2138" }, - "conform.nvim": { "branch": "master", "commit": "b4aab989db276993ea5dcb78872be494ce546521" }, - "floaterm": { "branch": "main", "commit": "ae3de018d20dccd9372bbff7137e8a6d6030f69e" }, + "conform.nvim": { "branch": "master", "commit": "3bad87250ed85246fe8c5bc10005ab5a6289ae4c" }, + "floaterm": { "branch": "main", "commit": "34e14f0b5e2687fd31a93fe75982ec84e5145856" }, "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, - "gitsigns.nvim": { "branch": "main", "commit": "f780609807eca1f783a36a8a31c30a48fbe150c5" }, + "gitsigns.nvim": { "branch": "main", "commit": "23ae90a2a52fdc9b8c50dc61d6c30ebb18521343" }, "gruvbox.nvim": { "branch": "main", "commit": "5e0a460d8e0f7f669c158dedd5f9ae2bcac31437" }, "harpoon": { "branch": "harpoon2", "commit": "ed1f853847ffd04b2b61c314865665e1dadf22c7" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, "lspsaga.nvim": { "branch": "main", "commit": "8efe00d6aed9db6449969f889170f1a7e43101a1" }, "lualine.nvim": { "branch": "master", "commit": "b8c23159c0161f4b89196f74ee3a6d02cdc3a955" }, "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, - "markview.nvim": { "branch": "main", "commit": "e6b0f5aee8105adab6077509c46459812db4cffa" }, + "markview.nvim": { "branch": "main", "commit": "82c21e3b3f982ae76107a787fb28383d76fffeab" }, "mason-conform.nvim": { "branch": "main", "commit": "48da2ebd5efbaf8a99566eadc3ece82d523f03c5" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "7f9a39fcd2ac6e979001f857727d606888f5909c" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "f760507df8c49a4bf46a4d12e1fc616797508979" }, "mason-nvim-lint": { "branch": "main", "commit": "767b8ccdddaa977bec8987fd7507b9865a279235" }, - "mason.nvim": { "branch": "main", "commit": "7dc4facca9702f95353d5a1f87daf23d78e31c2a" }, + "mason.nvim": { "branch": "main", "commit": "b3689a41dd77e5294498dba9757fb22cc80cbebd" }, "mdx.nvim": { "branch": "main", "commit": "464a74be368dce212cff02f6305845dc7f209ab3" }, "mini.ai": { "branch": "main", "commit": "e139eb1101beb0250fea322f8c07a42f0f175688" }, - "mini.bracketed": { "branch": "main", "commit": "672b4e2fe9222fd4d5a104ff23217801bae37046" }, + "mini.bracketed": { "branch": "main", "commit": "87cf031b49e3753227f73f433851a6a75cf31445" }, "mini.files": { "branch": "main", "commit": "49c855977e9f4821d1ed8179ed44fe098b93ea2a" }, - "mini.indentscope": { "branch": "main", "commit": "9d9490c172a4718d7d1f20eaae668a28f160c2d7" }, + "mini.indentscope": { "branch": "main", "commit": "fc1bb1e4573f7174cb6e2bbabc3453340a9eec16" }, "mini.surround": { "branch": "main", "commit": "5aab42fcdcf31fa010f012771eda5631c077840a" }, "neogen": { "branch": "main", "commit": "d7f9461727751fb07f82011051338a9aba07581d" }, "neoscroll.nvim": { "branch": "master", "commit": "f957373912e88579e26fdaea4735450ff2ef5c9c" }, "netrw.nvim": { "branch": "master", "commit": "90501c62b9b816ed3ed1e912ae9db9af5671a1b2" }, "nvim-autopairs": { "branch": "master", "commit": "23320e75953ac82e559c610bec5a90d9c6dfa743" }, "nvim-genghis": { "branch": "main", "commit": "cdf584d05ffc9d5c1f247079991552249e4f7487" }, - "nvim-lint": { "branch": "master", "commit": "0864f81c681e15d9bdc1156fe3a17bd07db5a3ed" }, - "nvim-lspconfig": { "branch": "master", "commit": "107c2458cdc780c4ed2c2b5e1b7800cd019010bd" }, + "nvim-lint": { "branch": "master", "commit": "335a6044be16d7701001059cba9baa36fbeef422" }, + "nvim-lspconfig": { "branch": "master", "commit": "336b388c272555d2ae94627a50df4c2f89a5e257" }, "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, "nvim-ts-autotag": { "branch": "main", "commit": "c4ca798ab95b316a768d51eaaaee48f64a4a46bc" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "1b212c2eee76d787bbea6aa5e92a2b534e7b4f8f" }, "nvim-ufo": { "branch": "main", "commit": "d31e2a9fd572a25a4d5011776677223a8ccb7e35" }, "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, "promise-async": { "branch": "main", "commit": "119e8961014c9bfaf1487bf3c2a393d254f337e2" }, - "snacks.nvim": { "branch": "main", "commit": "d67a47739dfc652cfcf66c59e929c704a854b37a" }, - "tiny-code-action.nvim": { "branch": "main", "commit": "2b3fa2fbd25496259eaf50987097982f8ad08d1b" }, - "tiny-inline-diagnostic.nvim": { "branch": "main", "commit": "f64efd33a51ea89bdb847fb3aaf716e96b83ba1a" }, + "snacks.nvim": { "branch": "main", "commit": "5e0e8698526f350f1280ad1ef7a8670f857c9445" }, + "tiny-code-action.nvim": { "branch": "main", "commit": "5b7716f36f346e07ef035d9bdeea870854533413" }, + "tiny-inline-diagnostic.nvim": { "branch": "main", "commit": "29315861711f11daf75e1cf0953ab92ec1a3e69f" }, "todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" }, "toggleterm.nvim": { "branch": "main", "commit": "50ea089fc548917cc3cc16b46a8211833b9e3c7c" }, "treesj": { "branch": "main", "commit": "4770492244ccecdc9b01e0e81fa8f2f6b4a23841" }, @@ -48,6 +48,6 @@ "vim-visual-multi": { "branch": "master", "commit": "a6975e7c1ee157615bbc80fc25e4392f71c344d4" }, "vim-wakatime": { "branch": "master", "commit": "d7973b157a632d1edeff01818f18d67e584eeaff" }, "volt": { "branch": "main", "commit": "620de1321f275ec9d80028c68d1b88b409c0c8b1" }, - "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" }, + "which-key.nvim": { "branch": "main", "commit": "904308e6885bbb7b60714c80ab3daf0c071c1492" }, "windsurf.vim": { "branch": "main", "commit": "a8d47ec54fe82df920b2545559f767003e8a7f8d" } } diff --git a/lua/core/keys.lua b/lua/core/keys.lua index d76c458..0e2b516 100644 --- a/lua/core/keys.lua +++ b/lua/core/keys.lua @@ -80,10 +80,12 @@ map('v', "'", "s''Pll", { desc = 'wrap selection with single quotes map('v', '"', 's""Pll', { desc = 'wrap selection with double quotes' }) -- Insert mode cursor movement with Ctrl+hjkl -map('i', '', '', { desc = 'Move to end of previous line' }) -map('i', '', '', { desc = 'Move cursor down' }) -map('i', '', '', { desc = 'Move cursor up' }) -map('i', '', '', { desc = 'Move cursor right' }) +map('i', '', '', { noremap = true, silent = true }) +map('i', '', '', { noremap = true, silent = true }) +map('i', '', '', { noremap = true, silent = true }) +map('i', '', '', { noremap = true, silent = true }) + +map('n', 're', ':%s//', { desc = 'Shortcut to replace current word under cursor' }) -- toggle inlay hints vim.keymap.set('n', 'th', function() @@ -91,17 +93,11 @@ vim.keymap.set('n', 'th', function() end) -- No arrow navigation -vim.api.nvim_set_keymap('n', '', '', opts) -vim.api.nvim_set_keymap('n', '', '', opts) -vim.api.nvim_set_keymap('n', '', '', opts) -vim.api.nvim_set_keymap('n', '', '', opts) +local modes = { 'n', 'v', 'i' } +local arrows = { '', '', '', '' } -vim.api.nvim_set_keymap('v', '', '', opts) -vim.api.nvim_set_keymap('v', '', '', opts) -vim.api.nvim_set_keymap('v', '', '', opts) -vim.api.nvim_set_keymap('v', '', '', opts) - -vim.api.nvim_set_keymap('i', '', '', opts) -vim.api.nvim_set_keymap('i', '', '', opts) -vim.api.nvim_set_keymap('i', '', '', opts) -vim.api.nvim_set_keymap('i', '', '', opts) +for _, mode in ipairs(modes) do + for _, key in ipairs(arrows) do + vim.api.nvim_set_keymap(mode, key, '', opts) + end +end diff --git a/lua/core/options.lua b/lua/core/options.lua index 4c23248..edd8863 100644 --- a/lua/core/options.lua +++ b/lua/core/options.lua @@ -1,66 +1,66 @@ local options = { - ai = true, - clipboard = "unnamedplus", -- use system clipboard - number = true, - relativenumber = true, - undofile = true, -- save state of file on write - undodir = vim.fn.stdpath("cache") .. "/undo", - undolevels = 10000, - autoread = true, -- autoread changes from other sources - signcolumn = "yes", - cursorline = true, - cursorlineopt = "number", - wrap = false, - scrolloff = 3, - ruler = false, -- removes cursor position from lastline - pumheight = 10, -- size of completion window - showmode = false, -- do not show mode under statusline - swapfile = false, -- creates a swapfile - backup = false, -- creates a backup file - writebackup = false, -- do not edit backups - winminwidth = 5, -- Minimum window width - termguicolors = true, -- set term gui colors (most terminals support this) - showtabline = 0, -- always show tabs - showcmd = false, - mouse = "a", -- allow the mouse to be used in neovim - confirm = true, -- Confirm to save changes before exiting modified buffer + ai = true, + clipboard = 'unnamedplus', -- use system clipboard + number = true, + relativenumber = true, + undofile = true, -- save state of file on write + undodir = vim.fn.stdpath('cache') .. '/undo', + undolevels = 10000, + autoread = true, -- autoread changes from other sources + signcolumn = 'yes', + cursorline = true, + cursorlineopt = 'number', + wrap = false, + scrolloff = 3, + ruler = false, -- removes cursor position from lastline + pumheight = 10, -- size of completion window + showmode = false, -- do not show mode under statusline + swapfile = false, -- creates a swapfile + backup = false, -- creates a backup file + writebackup = false, -- do not edit backups + winminwidth = 5, -- Minimum window width + termguicolors = true, -- set term gui colors (most terminals support this) + showtabline = 0, -- always show tabs + showcmd = false, + mouse = 'a', -- allow the mouse to be used in neovim + confirm = true, -- Confirm to save changes before exiting modified buffer - -- tabs - smarttab = true, - tabstop = 4, -- 1 tab represented as 4 spaces - expandtab = true, -- key will create " " instead of "\t" - shiftwidth = 4, -- indent change after backspace and >> << - softtabstop = 4, -- number of spaces instead of tab - autoindent = true, -- auto indent - smartindent = true, -- make indenting smarter again - list = true, - -- listchars = { trail = "", tab = "", nbsp = "_", extends = ">", precedes = "<" }, -- highlight - showbreak = string.rep(" ", 3), + -- tabs + smarttab = true, + tabstop = 4, -- 1 tab represented as 4 spaces + expandtab = true, -- key will create " " instead of "\t" + shiftwidth = 4, -- indent change after backspace and >> << + softtabstop = 4, -- number of spaces instead of tab + autoindent = true, -- auto indent + smartindent = true, -- make indenting smarter again + list = true, + -- listchars = { trail = "", tab = "", nbsp = "_", extends = ">", precedes = "<" }, -- highlight + showbreak = string.rep(' ', 3), - -- Search - ignorecase = true, - smartcase = true, - hlsearch = true, - wildmenu = true, - wildmode = "longest:full,full", - wildoptions = "pum", + -- Search + ignorecase = true, + smartcase = true, + hlsearch = true, + wildmenu = true, + wildmode = 'longest:full,full', + wildoptions = 'pum', - -- Folds (keep open by default, works well with nvim-ufo) - foldlevel = 99, - foldlevelstart = 99, - foldenable = true, + -- Folds (keep open by default, works well with nvim-ufo) + foldlevel = 99, + foldlevelstart = 99, + foldenable = true, - -- Window - splitright = true, - splitbelow = true, - title = true, + -- Window + splitright = true, + splitbelow = true, + title = true, } for k, v in pairs(options) do - vim.opt[k] = v + vim.opt[k] = v end -vim.opt.path:append({ "**" }) +vim.opt.path:append({ '**' }) vim.opt.shortmess:append({ W = true, I = true, c = true }) -- disable greeting -- Fix markdown indentation settings diff --git a/lua/plugins/files.lua b/lua/plugins/files.lua index 8e1c6e4..880e571 100644 --- a/lua/plugins/files.lua +++ b/lua/plugins/files.lua @@ -1,55 +1,46 @@ return { - { - "echasnovski/mini.files", - version = "*", - event = { "BufReadPost", "BufNewFile" }, - config = function() - require("mini.files").setup({ - content = { - filter = nil, - prefix = nil, - sort = nil, - }, - mappings = { - close = "q", - go_in = "L", - go_in_plus = "l", - go_out = "h", - go_out_plus = "H", - mark_goto = "'", - mark_set = "m", - reset = "", - reveal_cwd = "@", - show_help = "g?", - synchronize = "", - trim_left = "<", - trim_right = ">", - }, - options = { - permanent_delete = true, - use_as_default_explorer = true, - }, - windows = { - max_number = math.huge, - preview = false, - width_focus = 30, - width_nofocus = 20, - width_preview = 80, - }, - }) - end, - }, - { - "prichrd/netrw.nvim", - config = function() - require("netrw").setup({ - icons = { - symlink = "", - directory = "", - file = "", - }, - use_devicons = true, - }) - end, - }, + { + 'echasnovski/mini.files', + version = '*', + event = { 'BufReadPost', 'BufNewFile' }, + config = function() + require('mini.files').setup({ + content = { + filter = nil, + prefix = nil, + sort = nil, + }, + mappings = { + close = 'q', + go_in = 'L', + go_in_plus = 'l', + go_out = 'h', + go_out_plus = 'H', + mark_goto = "'", + mark_set = 'm', + reset = '', + reveal_cwd = '@', + show_help = 'g?', + synchronize = '', + trim_left = '<', + trim_right = '>', + }, + options = { + permanent_delete = true, + use_as_default_explorer = true, + }, + windows = { + max_number = math.huge, + preview = false, + width_focus = 30, + width_nofocus = 20, + width_preview = 80, + }, + }) + end, + }, + { + 'prichrd/netrw.nvim', + opts = {}, + }, } diff --git a/lua/plugins/utility.lua b/lua/plugins/utility.lua index e022597..8b619c2 100644 --- a/lua/plugins/utility.lua +++ b/lua/plugins/utility.lua @@ -81,12 +81,12 @@ return { insert_mappings = true, terminal_mappings = true, persist_size = true, - direction = 'float', -- Use 'float' for floating terminal windows + direction = 'float', -- 'vertical' | 'horizontal' | 'tab' | 'float' close_on_exit = true, shell = vim.o.shell, float_opts = { - border = 'curved', -- or 'single', 'double', 'shadow', etc. - winblend = 0, -- Set to 0 for full transparency + border = 'curved', -- 'single', 'double', 'shadow', etc. + winblend = 0, -- Set to 0 for full transparency highlights = { border = 'Normal', background = 'Normal', @@ -95,20 +95,6 @@ return { }) end, }, - { - 'nvzone/floaterm', - dependencies = 'nvzone/volt', - opts = { - mappings = { - term = function(buf) - vim.keymap.set({ 'n', 't' }, '', function() - require('floaterm.api').cycle_term_bufs('prev') - end, { buffer = buf }) - end, - }, - }, - cmd = 'FloatermToggle', - }, -- smooth scrolling { @@ -131,16 +117,16 @@ return { picker_integration = true, keymaps = { prefix = 'u', -- Main prefix for uv commands - commands = true, -- Show uv commands menu (x) - run_file = true, -- Run current file (xr) + commands = true, -- Show uv commands menu (x) + run_file = true, -- Run current file (xr) run_selection = true, -- Run selected code (xs) - run_function = true, -- Run function (xf) - venv = true, -- Environment management (xe) - init = true, -- Initialize uv project (xi) - add = true, -- Add a package (xa) - remove = true, -- Remove a package (xd) - sync = true, -- Sync packages (xc) - sync_all = true, -- Sync all packages, extras and groups (xC) + run_function = true, -- Run function (xf) + venv = true, -- Environment management (xe) + init = true, -- Initialize uv project (xi) + add = true, -- Add a package (xa) + remove = true, -- Remove a package (xd) + sync = true, -- Sync packages (xc) + sync_all = true, -- Sync all packages, extras and groups (xC) }, }, }, diff --git a/lua/plugins/whichkey.lua b/lua/plugins/whichkey.lua index b0f1354..5a398bd 100644 --- a/lua/plugins/whichkey.lua +++ b/lua/plugins/whichkey.lua @@ -101,23 +101,9 @@ return { { 'gu', ':Gitsigns undo_stage_hunk', desc = 'Undo Stage Hunk' }, { 'gv', ':Gitsigns select_hunk', desc = 'Select Hunk' }, { 'gw', ':lua require("snacks").gitbrowse()', desc = 'Git Browse' }, - { 'gbr', ':lua Snacks.picker.git_branches()', desc = 'Pick and Switch Git Branches' }, + { 'gp', ':lua Snacks.picker.git_branches()', desc = 'Pick and Switch Git Branches' }, { 'h', group = 'Harpoon' }, - -- { - -- 'ha', - -- function() - -- require('harpoon'):list():add() - -- end, - -- desc = 'Harpoon add file', - -- }, - -- { - -- 'hl', - -- function() - -- require('harpoon').ui:toggle_quick_menu(require('harpoon'):list()) - -- end, - -- desc = 'Harpoon quick menu', - -- }, { 'gt', group = 'Toggle' }, { 'gtb', ':Gitsigns toggle_current_line_blame', desc = 'Blame' },