feat: add nvimtree keybindings

This commit is contained in:
n3oney 2023-04-12 17:17:23 +02:00
parent 25eda46629
commit e372fb1ccc
No known key found for this signature in database
GPG key ID: C786693DE727850E
3 changed files with 36 additions and 14 deletions

View file

@ -1,30 +1,29 @@
{
config,
lib,
pkgs,
...
}:
with lib;
with builtins; let
cfg = config.vim.filetree.nvimTreeLua;
self = import ./nvimtree-lua.nix {
inherit pkgs;
lib = lib;
};
mappings = self.options.vim.filetree.nvimTreeLua.mappings;
in {
config = mkIf cfg.enable {
vim.startPlugins = ["nvim-tree-lua"];
# vim.nnoremap = {
# "<C-n>" = ":NvimTreeToggle<CR>";
# "<leader>tr" = ":NvimTreeRefresh<CR>";
# "<leader>tg" = ":NvimTreeFindFile<CR>";
# "<leader>tf" = ":NvimTreeFocus<CR>";
# };
vim.maps.normal = mkMerge [
(mkBinding cfg.mappings.toggle ":NvimTreeToggle<cr>" mappings.toggle.description)
(mkBinding cfg.mappings.refresh ":NvimTreeRefresh<cr>" mappings.refresh.description)
(mkBinding cfg.mappings.findFile ":NvimTreeFindFile<cr>" mappings.findFile.description)
(mkBinding cfg.mappings.focus ":NvimTreeFocus<cr>" mappings.focus.description)
];
vim.luaConfigRC.nvimtreelua = nvim.dag.entryAnywhere ''
local opts = { silent = true, noremap = true }
vim.api.nvim_set_keymap("n", "<C-n>", ":NvimTreeToggle<cr>", opts)
vim.api.nvim_set_keymap("n", "<leader>tr", ":NvimTreeRefresh<cr>", opts)
vim.api.nvim_set_keymap("n", "<leader>tg", ":NvimTreeFindFile<cr>", opts)
vim.api.nvim_set_keymap("n", "<leader>tf", ":NvimTreeFocus<cr>", opts)
local function open_nvim_tree(data)
local IGNORED_FT = {
"markdown",

View file

@ -1,6 +1,5 @@
{
pkgs,
config,
lib,
...
}:
@ -13,6 +12,29 @@ with builtins; {
description = "Enable nvim-tree-lua";
};
mappings = {
toggle = mkOption {
type = types.nullOr types.str;
default = "<C-n>";
description = "Toggle NvimTree";
};
refresh = mkOption {
type = types.nullOr types.str;
default = "<leader>tr";
description = "Refresh NvimTree";
};
findFile = mkOption {
type = types.nullOr types.str;
default = "<leader>tg";
description = "Find file in NvimTree";
};
focus = mkOption {
type = types.nullOr types.str;
default = "<leader>tf";
description = "Focus NvimTree";
};
};
sortBy = mkOption {
default = "name";
description = "Sort by name or extension";

View file

@ -88,6 +88,7 @@ in {
}
${
# TODO: This probably will need to be reworked for custom-keybinds
if config.vim.filetree.nvimTreeLua.enable
then ''
-- NvimTree