harpoon,gitsigns: update keybindings, space as leader key

This commit is contained in:
xinyangli 2024-12-26 21:31:42 +08:00
parent fdf7775c73
commit 4439691030
Signed by: xin
SSH key fingerprint: SHA256:UU5pRTl7NiLFJbWJZa+snLylZSXIz5rgHmwjzv8v4oE
3 changed files with 32 additions and 54 deletions

View file

@ -9,7 +9,7 @@
# Navigate through hunks
{
mode = [ "n" ];
key = "]c";
key = "]h";
action = helpers.mkRaw ''
function()
if vim.wo.diff then
@ -23,7 +23,7 @@
}
{
mode = [ "n" ];
key = "[c";
key = "[h";
action = helpers.mkRaw ''
function()
if vim.wo.diff then
@ -35,8 +35,18 @@
'';
}
{
mode = [ "v" ];
key = "<leader>hs";
mode = [ "n" ];
key = "<leader>gs";
action = helpers.mkRaw ''
require("gitsigns").stage_buffer
'';
options = {
desc = "Stage Buffer";
};
}
{
mode = [ "n" ];
key = "<leader>gsh";
action = helpers.mkRaw ''
function()
require("gitsigns").stage_hunk({ vim.fn.line("."), vim.fn.line("v") })
@ -48,7 +58,7 @@
}
{
mode = [ "n" ];
key = "<leader>hu";
key = "<leader>gshd";
action = helpers.mkRaw ''
require("gitsigns").undo_stage_hunk
'';
@ -58,7 +68,7 @@
}
{
mode = [ "n" ];
key = "<leader>hp";
key = "<leader>gp";
action = helpers.mkRaw ''
require("gitsigns").preview_hunk
'';

View file

@ -1,53 +1,20 @@
{ pkgs, ... }:
{ pkgs, helpers, ... }:
{
# keymaps for this plugin are difined in config/keymaps/window-movements module
plugins.harpoon = {
enable = true;
enableTelescope = true;
keymaps = {
navFile = {
"1" = "<leader>h1";
"2" = "<leader>h2";
"3" = "<leader>h3";
"4" = "<leader>h4";
};
addFile = "<leader>ha";
cmdToggleQuickMenu = "<leader>he";
};
};
extraPlugins = with pkgs.vimPlugins; [
harpoon2
];
extraConfigLua = ''
local harpoon = require("harpoon")
harpoon:setup(
{
settings = {
save_on_toggle = true,
sync_on_ui_close = true,
key = function()
return vim.loop.cwd()
end,
},
}
)
-- basic telescope configuration
-- local conf = require("telescope.config").values
-- local function toggle_telescope(harpoon_files)
-- local file_paths = {}
-- for _, item in ipairs(harpoon_files.items) do
-- table.insert(file_paths, item.value)
-- end
--
-- require("telescope.pickers").new({}, {
-- prompt_title = "Harpoon",
-- finder = require("telescope.finders").new_table({
-- results = file_paths,
-- }),
-- previewer = conf.file_previewer({}),
-- sorter = conf.generic_sorter({}),
-- layout_strategy = getLayoutStrategy()
-- }):find()
-- end
--
-- vim.keymap.set("n", "<C-e>", function() toggle_telescope(harpoon:list()) end,
-- { desc = "Open harpoon window" })
vim.keymap.set("n", "<C-e>", function() harpoon.ui:toggle_quick_menu(harpoon:list()) end)
vim.keymap.set("n", "<leader>a", function() harpoon:list():add() end)
vim.keymap.set("n", "<C-a>", function() harpoon:list():select(1) end)
vim.keymap.set("n", "<C-s>", function() harpoon:list():select(2) end)
vim.keymap.set("n", "<C-f>", function() harpoon:list():select(3) end)
vim.keymap.set("n", "<C-g>", function() harpoon:list():select(4) end)
-- Toggle previous & next buffers stored within Harpoon list
vim.keymap.set("n", "<C-S-k>", function() harpoon:list():prev() end)
vim.keymap.set("n", "<C-S-j>", function() harpoon:list():next() end)
'';
}

View file

@ -1,5 +1,6 @@
{ helpers, ... }:
{
globals.mapleader = " ";
keymaps = [
# Window movement.
{