From 40fa00f90f8a96dde92a182bd7abf6a90e07e331 Mon Sep 17 00:00:00 2001 From: rootiest Date: Sat, 24 Aug 2024 16:24:09 -0400 Subject: [PATCH] refactor: extract common keymap properties to use data module functions --- lua/config/keymaps.lua | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/lua/config/keymaps.lua b/lua/config/keymaps.lua index 03f9503..5f4a587 100644 --- a/lua/config/keymaps.lua +++ b/lua/config/keymaps.lua @@ -5,20 +5,11 @@ local wk = require("which-key") local rootiest = require("config.rootiest") local smartsplits = require("smart-splits") +local data = require("data") local all_modes = { "n", "i", "v", "x", "s", "o", "c", "t" } --- Helper function to add keymaps with common properties -local function add_keymap(lhs, rhs, desc, modes) - wk.add({ - { - lhs, - rhs = rhs, - desc = desc, - mode = modes or "n", -- default to normal mode if not specified - }, - }) -end +local add_keymap = require("data").func.add_keymap -- General Keybinds add_keymap("gt", function() @@ -33,6 +24,21 @@ end, "Toggle Hardmode") add_keymap("Y", "%y", "Yank buffer contents") add_keymap("", "norm ggVG", "Select all") add_keymap("|", "Neotree reveal toggle", "Neotree reveal") +add_keymap( + "Ca", + ":lua require('utils.rootiest').code_action_on_selection()", + "Code Action on Selection", + "x" +) + +wk.add({ + lhs = "Cq", + rhs = function() + data.func.exit() + end, + desc = "Exit Neovim", + mode = all_modes, +}) -- Group Keybinds wk.add({