mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-01 19:11:15 +00:00
feat: add nvimtree keybindings
This commit is contained in:
parent
15185f9ad6
commit
f1f0144c62
3 changed files with 36 additions and 14 deletions
|
@ -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",
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -88,6 +88,7 @@ in {
|
|||
}
|
||||
|
||||
${
|
||||
# TODO: This probably will need to be reworked for custom-keybinds
|
||||
if config.vim.filetree.nvimTreeLua.enable
|
||||
then ''
|
||||
-- NvimTree
|
||||
|
|
Loading…
Reference in a new issue