mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-12-23 21:09:48 +01:00
feat: add nvimtree keybindings
This commit is contained in:
parent
25eda46629
commit
e372fb1ccc
3 changed files with 36 additions and 14 deletions
|
@ -1,30 +1,29 @@
|
||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
|
pkgs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; let
|
with builtins; let
|
||||||
cfg = config.vim.filetree.nvimTreeLua;
|
cfg = config.vim.filetree.nvimTreeLua;
|
||||||
|
self = import ./nvimtree-lua.nix {
|
||||||
|
inherit pkgs;
|
||||||
|
lib = lib;
|
||||||
|
};
|
||||||
|
mappings = self.options.vim.filetree.nvimTreeLua.mappings;
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim.startPlugins = ["nvim-tree-lua"];
|
vim.startPlugins = ["nvim-tree-lua"];
|
||||||
|
|
||||||
# vim.nnoremap = {
|
vim.maps.normal = mkMerge [
|
||||||
# "<C-n>" = ":NvimTreeToggle<CR>";
|
(mkBinding cfg.mappings.toggle ":NvimTreeToggle<cr>" mappings.toggle.description)
|
||||||
# "<leader>tr" = ":NvimTreeRefresh<CR>";
|
(mkBinding cfg.mappings.refresh ":NvimTreeRefresh<cr>" mappings.refresh.description)
|
||||||
# "<leader>tg" = ":NvimTreeFindFile<CR>";
|
(mkBinding cfg.mappings.findFile ":NvimTreeFindFile<cr>" mappings.findFile.description)
|
||||||
# "<leader>tf" = ":NvimTreeFocus<CR>";
|
(mkBinding cfg.mappings.focus ":NvimTreeFocus<cr>" mappings.focus.description)
|
||||||
# };
|
];
|
||||||
|
|
||||||
vim.luaConfigRC.nvimtreelua = nvim.dag.entryAnywhere ''
|
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 function open_nvim_tree(data)
|
||||||
local IGNORED_FT = {
|
local IGNORED_FT = {
|
||||||
"markdown",
|
"markdown",
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
{
|
{
|
||||||
pkgs,
|
pkgs,
|
||||||
config,
|
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
@ -13,6 +12,29 @@ with builtins; {
|
||||||
description = "Enable nvim-tree-lua";
|
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 {
|
sortBy = mkOption {
|
||||||
default = "name";
|
default = "name";
|
||||||
description = "Sort by name or extension";
|
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
|
if config.vim.filetree.nvimTreeLua.enable
|
||||||
then ''
|
then ''
|
||||||
-- NvimTree
|
-- NvimTree
|
||||||
|
|
Loading…
Reference in a new issue