diff --git a/modules/filetree/nvimtree-lua/config.nix b/modules/filetree/nvimtree-lua/config.nix index 6546232..e0d598a 100644 --- a/modules/filetree/nvimtree-lua/config.nix +++ b/modules/filetree/nvimtree-lua/config.nix @@ -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 = { - # "" = ":NvimTreeToggle"; - # "tr" = ":NvimTreeRefresh"; - # "tg" = ":NvimTreeFindFile"; - # "tf" = ":NvimTreeFocus"; - # }; + vim.maps.normal = mkMerge [ + (mkBinding cfg.mappings.toggle ":NvimTreeToggle" mappings.toggle.description) + (mkBinding cfg.mappings.refresh ":NvimTreeRefresh" mappings.refresh.description) + (mkBinding cfg.mappings.findFile ":NvimTreeFindFile" mappings.findFile.description) + (mkBinding cfg.mappings.focus ":NvimTreeFocus" mappings.focus.description) + ]; vim.luaConfigRC.nvimtreelua = nvim.dag.entryAnywhere '' - local opts = { silent = true, noremap = true } - - vim.api.nvim_set_keymap("n", "", ":NvimTreeToggle", opts) - vim.api.nvim_set_keymap("n", "tr", ":NvimTreeRefresh", opts) - vim.api.nvim_set_keymap("n", "tg", ":NvimTreeFindFile", opts) - vim.api.nvim_set_keymap("n", "tf", ":NvimTreeFocus", opts) - local function open_nvim_tree(data) local IGNORED_FT = { "markdown", diff --git a/modules/filetree/nvimtree-lua/nvimtree-lua.nix b/modules/filetree/nvimtree-lua/nvimtree-lua.nix index fbd0fb6..373ace3 100644 --- a/modules/filetree/nvimtree-lua/nvimtree-lua.nix +++ b/modules/filetree/nvimtree-lua/nvimtree-lua.nix @@ -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 = ""; + description = "Toggle NvimTree"; + }; + refresh = mkOption { + type = types.nullOr types.str; + default = "tr"; + description = "Refresh NvimTree"; + }; + findFile = mkOption { + type = types.nullOr types.str; + default = "tg"; + description = "Find file in NvimTree"; + }; + focus = mkOption { + type = types.nullOr types.str; + default = "tf"; + description = "Focus NvimTree"; + }; + }; + sortBy = mkOption { default = "name"; description = "Sort by name or extension"; diff --git a/modules/utility/binds/which-key/config.nix b/modules/utility/binds/which-key/config.nix index e2f5ae1..5035ce3 100644 --- a/modules/utility/binds/which-key/config.nix +++ b/modules/utility/binds/which-key/config.nix @@ -88,6 +88,7 @@ in { } ${ + # TODO: This probably will need to be reworked for custom-keybinds if config.vim.filetree.nvimTreeLua.enable then '' -- NvimTree