nixvim: Add initial configuration for keymaps
Signed-off-by: George Kaklamanos <gkaklas@gkaklas.gr>
This commit is contained in:
parent
e9ca2034bc
commit
f4b43e3a18
2 changed files with 53 additions and 0 deletions
50
home-manager/nixvim/keymaps.nix
Normal file
50
home-manager/nixvim/keymaps.nix
Normal file
|
@ -0,0 +1,50 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
# Telescope
|
||||
# { key = "<leader>ff";
|
||||
# action = config.nixvim.helpers.mkRaw "require('telescope.builtin').find_files";
|
||||
# } becomes:
|
||||
# { key = ldr "ff";
|
||||
# action = mfn "telescope.builtin" "find_files";
|
||||
# } becomes:
|
||||
# (tscope "ff" "find_files")
|
||||
lua = config.nixvim.helpers.mkRaw;
|
||||
ldr = k: "<leader>${k}";
|
||||
key = k: fn: {
|
||||
key = "${k}";
|
||||
action = lua "${fn}";
|
||||
};
|
||||
lkey = k: fn: {
|
||||
key = ldr "${k}";
|
||||
action = lua "${fn}";
|
||||
};
|
||||
luaf = fn: "function() ${fn} end";
|
||||
luafr = m: fn: "function() require('${m}').${fn} end";
|
||||
|
||||
mkey = module: k: fn: (lkey "${k}" "require('${module}').${fn}");
|
||||
tscope = k: fn: mkey "telescope.builtin" "${k}" "${fn}";
|
||||
gs = k: fn: mkey "gitsigns" "${k}" "${fn}";
|
||||
in {
|
||||
programs.nixvim.keymaps = [
|
||||
(tscope "ff" "find_files")
|
||||
(tscope "fg" "live_grep")
|
||||
(tscope "fb" "buffers")
|
||||
(tscope "fh" "help_tags")
|
||||
|
||||
(gs "hs" "stage_hunk")
|
||||
(gs "rs" "reset_hunk")
|
||||
(gs "hS" "stage_buffer")
|
||||
(gs "hu" "undo_stage_hunk")
|
||||
(gs "hR" "reset_buffer")
|
||||
(gs "hp" "preview_hunk")
|
||||
(gs "tb" "toggle_current_line_blame")
|
||||
(gs "hd" "diffthis")
|
||||
(gs "td" "toggle_deleted")
|
||||
|
||||
(key "<F5>" (luafr "nvim-tree.api" "tree.toggle()"))
|
||||
(lkey "d" "vim.cmd.bdelete")
|
||||
];
|
||||
}
|
|
@ -3,6 +3,9 @@
|
|||
config,
|
||||
...
|
||||
}: {
|
||||
imports = [
|
||||
./keymaps.nix
|
||||
];
|
||||
programs.nixvim = {
|
||||
enable = true;
|
||||
plugins = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue