feat: update nvimtree view

This commit is contained in:
NotAShelf 2023-03-01 16:19:50 +03:00
parent 0a7d4e49ae
commit fcf1318c8b
No known key found for this signature in database
GPG key ID: 5B5C8895F28445F1
2 changed files with 25 additions and 29 deletions

View file

@ -11,14 +11,19 @@ in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim.startPlugins = ["nvim-tree-lua"]; vim.startPlugins = ["nvim-tree-lua"];
vim.nnoremap = { # vim.nnoremap = {
"<C-n>" = ":NvimTreeToggle<CR>"; # "<C-n>" = ":NvimTreeToggle<CR>";
"<leader>tr" = ":NvimTreeRefresh<CR>"; # "<leader>tr" = ":NvimTreeRefresh<CR>";
"<leader>tg" = ":NvimTreeFindFile<CR>"; # "<leader>tg" = ":NvimTreeFindFile<CR>";
"<leader>tf" = ":NvimTreeFocus<CR>"; # "<leader>tf" = ":NvimTreeFocus<CR>";
}; # };
vim.luaConfigRC.nvimtreelua = nvim.dag.entryAnywhere '' vim.luaConfigRC.nvimtreelua = nvim.dag.entryAnywhere ''
vim.api.nvim_set_keymap("n", "<C-n>", ":NvimTreeToggle<cr>" ,{silent = true, noremap = true, nowait = true})
vim.api.nvim_set_keymap("n", "<leader>tr", ":NvimTreeRefresh<cr>" ,{silent = true, noremap = true})
vim.api.nvim_set_keymap("n", "<leader>tg", ":NvimTreeFindFile<cr>" ,{silent = true, noremap = true})
vim.api.nvim_set_keymap("n", "<leader>tf", ":NvimTreeFocus<cr>" ,{silent = true, noremap = true})
local function open_nvim_tree(data) local function open_nvim_tree(data)
local IGNORED_FT = { local IGNORED_FT = {
"markdown", "markdown",
@ -46,7 +51,6 @@ in {
-- open the tree but don't focus it -- open the tree but don't focus it
require("nvim-tree.api").tree.toggle({ focus = false }) require("nvim-tree.api").tree.toggle({ focus = false })
end end
-- Open on startup has been deprecated -- Open on startup has been deprecated
-- see https://github.com/nvim-tree/nvim-tree.lua/wiki/Open-At-Startup -- see https://github.com/nvim-tree/nvim-tree.lua/wiki/Open-At-Startup
-- use a nix eval to dynamically insert the open on startup function -- use a nix eval to dynamically insert the open on startup function
@ -87,6 +91,9 @@ in {
}, },
actions = { actions = {
change_dir = {
global = ${boolToString cfg.actions.changeDir.global},
},
open_file = { open_file = {
quit_on_open = ${boolToString cfg.actions.openFile.quitOnOpen}, quit_on_open = ${boolToString cfg.actions.openFile.quitOnOpen},
resize_window = ${boolToString cfg.actions.openFile.resizeWindow}, resize_window = ${boolToString cfg.actions.openFile.resizeWindow},

View file

@ -21,30 +21,12 @@ in {
type = types.enum ["name" "extension" "modification_time" "case_sensitive"]; type = types.enum ["name" "extension" "modification_time" "case_sensitive"];
}; };
treeSide = mkOption {
default = "left";
description = "Side the tree will appear on left or right";
type = types.enum ["left" "right"];
};
treeWidth = mkOption {
default = 25;
description = "Width of the tree in charecters";
type = types.int;
};
hideFiles = mkOption { hideFiles = mkOption {
default = [".git" "node_modules" ".cache"]; default = ["node_modules" ".cache"];
description = "Files to hide in the file view by default."; description = "Files to hide in the file view by default.";
type = with types; listOf str; type = with types; listOf str;
}; };
hideIgnoredGitFiles = mkOption {
default = false;
description = "Hide files ignored by git";
type = types.bool;
};
openOnSetup = mkOption { openOnSetup = mkOption {
default = true; default = true;
description = "Open when vim is started on a directory"; description = "Open when vim is started on a directory";
@ -82,7 +64,7 @@ in {
}; };
openTreeOnNewTab = mkOption { openTreeOnNewTab = mkOption {
default = false; default = true;
description = "Opens the tree view when opening a new tab"; description = "Opens the tree view when opening a new tab";
type = types.bool; type = types.bool;
}; };
@ -182,7 +164,7 @@ in {
}; };
hideRootFolder = mkOption { hideRootFolder = mkOption {
default = false; default = true;
description = "Hide the root folder"; description = "Hide the root folder";
type = types.bool; type = types.bool;
}; };
@ -191,7 +173,7 @@ in {
git = { git = {
enable = mkEnableOption "Git integration"; enable = mkEnableOption "Git integration";
ignore = mkOption { ignore = mkOption {
default = true; default = false;
description = "Ignore files in git"; description = "Ignore files in git";
type = types.bool; type = types.bool;
}; };
@ -206,6 +188,13 @@ in {
}; };
actions = { actions = {
changeDir = {
global = mkOption {
default = true;
description = "Change directory when changing nvim's directory (DirChanged event).";
type = types.bool;
};
};
openFile = { openFile = {
resizeWindow = mkOption { resizeWindow = mkOption {
default = true; default = true;