mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-01 11:01:15 +00:00
Compare commits
5 commits
b59689dbd9
...
bf54ca3cb2
Author | SHA1 | Date | |
---|---|---|---|
|
bf54ca3cb2 | ||
|
de6e701386 | ||
|
11e0b9a031 | ||
|
7543cc2725 | ||
|
9360becd30 |
5 changed files with 80 additions and 38 deletions
|
@ -3,11 +3,12 @@
|
|||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) toJSON;
|
||||
inherit (lib.strings) optionalString;
|
||||
inherit (lib.lists) optional;
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.meta) getExe;
|
||||
inherit (lib.nvim.binds) mkLznBinding;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
|
||||
cfg = config.vim.terminal.toggleterm;
|
||||
lazygitMapDesc = "Open lazygit [toggleterm]";
|
||||
|
@ -17,13 +18,12 @@ in {
|
|||
lazy.plugins.toggleterm-nvim = {
|
||||
package = "toggleterm-nvim";
|
||||
cmd = ["ToggleTerm" "ToggleTermSendCurrentLine" "ToggleTermSendVisualLines" "ToggleTermSendVisualSelection" "ToggleTermSetName" "ToggleTermToggleAll"];
|
||||
keys = [
|
||||
(mkLznBinding ["n"] cfg.mappings.open "<Cmd>execute v:count . \"ToggleTerm\"<CR>" "Toggle terminal")
|
||||
{
|
||||
keys =
|
||||
[(mkLznBinding ["n"] cfg.mappings.open "<Cmd>execute v:count . \"ToggleTerm\"<CR>" "Toggle terminal")]
|
||||
++ optional cfg.lazygit.enable {
|
||||
key = cfg.lazygit.mappings.open;
|
||||
desc = lazygitMapDesc;
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
setupModule = "toggleterm";
|
||||
inherit (cfg) setupOpts;
|
||||
|
@ -42,7 +42,7 @@ in {
|
|||
end
|
||||
})
|
||||
|
||||
vim.keymap.set('n', ${toJSON cfg.lazygit.mappings.open}, function() lazygit:toggle() end, {silent = true, noremap = true, desc = '${lazygitMapDesc}'})
|
||||
vim.keymap.set('n', ${toLuaObject cfg.lazygit.mappings.open}, function() lazygit:toggle() end, {silent = true, noremap = true, desc = '${lazygitMapDesc}'})
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
|
|
@ -8,19 +8,6 @@
|
|||
inherit (lib.nvim.lua) toLuaObject;
|
||||
|
||||
cfg = config.vim.utility.surround;
|
||||
vendoredKeybinds = {
|
||||
insert = "<C-g>z";
|
||||
insert_line = "<C-g>Z";
|
||||
normal = "gz";
|
||||
normal_cur = "gZ";
|
||||
normal_line = "gzz";
|
||||
normal_cur_line = "gZZ";
|
||||
visual = "gz";
|
||||
visual_line = "gZ";
|
||||
delete = "gzd";
|
||||
change = "gzr";
|
||||
change_line = "gZR";
|
||||
};
|
||||
mkLznKey = mode: key: {
|
||||
inherit key mode;
|
||||
};
|
||||
|
@ -36,20 +23,33 @@ in {
|
|||
inherit (cfg) setupOpts;
|
||||
|
||||
keys =
|
||||
map (mkLznKey ["i"]) (with vendoredKeybinds; [insert insert_line])
|
||||
++ map (mkLznKey ["x"]) (with vendoredKeybinds; [visual visual_line])
|
||||
++ map (mkLznKey ["n"]) (with vendoredKeybinds; [
|
||||
normal
|
||||
normal_cur
|
||||
normal_line
|
||||
normal_cur_line
|
||||
delete
|
||||
change
|
||||
change_line
|
||||
]);
|
||||
[
|
||||
(mkLznKey ["i"] cfg.setupOpts.keymaps.insert)
|
||||
(mkLznKey ["i"] cfg.setupOpts.keymaps.insert_line)
|
||||
(mkLznKey ["x"] cfg.setupOpts.keymaps.visual)
|
||||
(mkLznKey ["x"] cfg.setupOpts.keymaps.visual_line)
|
||||
(mkLznKey ["n"] cfg.setupOpts.keymaps.normal)
|
||||
(mkLznKey ["n"] cfg.setupOpts.keymaps.normal_cur)
|
||||
(mkLznKey ["n"] cfg.setupOpts.keymaps.normal_line)
|
||||
(mkLznKey ["n"] cfg.setupOpts.keymaps.normal_cur_line)
|
||||
(mkLznKey ["n"] cfg.setupOpts.keymaps.delete)
|
||||
(mkLznKey ["n"] cfg.setupOpts.keymaps.change)
|
||||
(mkLznKey ["n"] cfg.setupOpts.keymaps.change_line)
|
||||
]
|
||||
++ map (mkLznKey ["n" "i" "v"]) [
|
||||
"<Plug>(nvim-surround-insert)"
|
||||
"<Plug>(nvim-surround-insert-line)"
|
||||
"<Plug>(nvim-surround-normal)"
|
||||
"<Plug>(nvim-surround-normal-cur)"
|
||||
"<Plug>(nvim-surround-normal-line)"
|
||||
"<Plug>(nvim-surround-normal-cur-line)"
|
||||
"<Plug>(nvim-surround-visual)"
|
||||
"<Plug>(nvim-surround-visual-line)"
|
||||
"<Plug>(nvim-surround-delete)"
|
||||
"<Plug>(nvim-surround-change)"
|
||||
"<Plug>(nvim-surround-change-line)"
|
||||
];
|
||||
};
|
||||
|
||||
utility.surround.setupOpts.keymaps = mkIf cfg.useVendoredKeybindings vendoredKeybinds;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,7 +1,36 @@
|
|||
{lib, ...}: let
|
||||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.options) mkOption;
|
||||
inherit (lib.types) bool;
|
||||
inherit (lib.types) bool str;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption;
|
||||
|
||||
cfg = config.vim.utility.surround;
|
||||
vendoredKeybinds = {
|
||||
insert = "<C-g>z";
|
||||
insert_line = "<C-g>Z";
|
||||
normal = "gz";
|
||||
normal_cur = "gZ";
|
||||
normal_line = "gzz";
|
||||
normal_cur_line = "gZZ";
|
||||
visual = "gz";
|
||||
visual_line = "gZ";
|
||||
delete = "gzd";
|
||||
change = "gzr";
|
||||
change_line = "gZR";
|
||||
};
|
||||
|
||||
mkKeymapOption = name: default:
|
||||
mkOption {
|
||||
description = "keymap for ${name}";
|
||||
type = str;
|
||||
default =
|
||||
if cfg.useVendoredKeybindings
|
||||
then vendoredKeybinds.${name}
|
||||
else default;
|
||||
};
|
||||
in {
|
||||
options.vim.utility.surround = {
|
||||
enable = mkOption {
|
||||
|
@ -13,7 +42,21 @@ in {
|
|||
with nvim-leap.
|
||||
'';
|
||||
};
|
||||
setupOpts = mkPluginSetupOption "nvim-surround" {};
|
||||
setupOpts = mkPluginSetupOption "nvim-surround" {
|
||||
keymaps = {
|
||||
insert = mkKeymapOption "insert" "<C-g>s";
|
||||
insert_line = mkKeymapOption "insert_line" "<C-g>S";
|
||||
normal = mkKeymapOption "normal" "ys";
|
||||
normal_cur = mkKeymapOption "normal_cur" "yss";
|
||||
normal_line = mkKeymapOption "normal_line" "yS";
|
||||
normal_cur_line = mkKeymapOption "normal_cur_line" "ySS";
|
||||
visual = mkKeymapOption "visual" "S";
|
||||
visual_line = mkKeymapOption "visual_line" "gS";
|
||||
delete = mkKeymapOption "delete" "ds";
|
||||
change = mkKeymapOption "change" "cs";
|
||||
change_line = mkKeymapOption "change_line" "cS";
|
||||
};
|
||||
};
|
||||
|
||||
useVendoredKeybindings = mkOption {
|
||||
type = bool;
|
||||
|
|
|
@ -23,7 +23,6 @@ in {
|
|||
package = "telescope";
|
||||
setupModule = "telescope";
|
||||
inherit (cfg) setupOpts;
|
||||
# FIXME: how do I deal with extensions? set all as deps?
|
||||
after = ''
|
||||
local telescope = require("telescope")
|
||||
${optionalString config.vim.ui.noice.enable "telescope.load_extension('noice')"}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
_: {
|
||||
{
|
||||
imports = [
|
||||
./lazy.nix
|
||||
./config.nix
|
||||
|
|
Loading…
Reference in a new issue