From fcf1318c8b0c8c82f20dcd62bc58d8698039ef44 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Wed, 1 Mar 2023 16:19:50 +0300 Subject: [PATCH] feat: update nvimtree view --- modules/filetree/nvimtree-lua/config.nix | 21 ++++++++---- .../filetree/nvimtree-lua/nvimtree-lua.nix | 33 +++++++------------ 2 files changed, 25 insertions(+), 29 deletions(-) diff --git a/modules/filetree/nvimtree-lua/config.nix b/modules/filetree/nvimtree-lua/config.nix index fd72530..d9c43a6 100644 --- a/modules/filetree/nvimtree-lua/config.nix +++ b/modules/filetree/nvimtree-lua/config.nix @@ -11,14 +11,19 @@ in { config = mkIf cfg.enable { vim.startPlugins = ["nvim-tree-lua"]; - vim.nnoremap = { - "" = ":NvimTreeToggle"; - "tr" = ":NvimTreeRefresh"; - "tg" = ":NvimTreeFindFile"; - "tf" = ":NvimTreeFocus"; - }; + # vim.nnoremap = { + # "" = ":NvimTreeToggle"; + # "tr" = ":NvimTreeRefresh"; + # "tg" = ":NvimTreeFindFile"; + # "tf" = ":NvimTreeFocus"; + # }; vim.luaConfigRC.nvimtreelua = nvim.dag.entryAnywhere '' + vim.api.nvim_set_keymap("n", "", ":NvimTreeToggle" ,{silent = true, noremap = true, nowait = true}) + vim.api.nvim_set_keymap("n", "tr", ":NvimTreeRefresh" ,{silent = true, noremap = true}) + vim.api.nvim_set_keymap("n", "tg", ":NvimTreeFindFile" ,{silent = true, noremap = true}) + vim.api.nvim_set_keymap("n", "tf", ":NvimTreeFocus" ,{silent = true, noremap = true}) + local function open_nvim_tree(data) local IGNORED_FT = { "markdown", @@ -46,7 +51,6 @@ in { -- open the tree but don't focus it require("nvim-tree.api").tree.toggle({ focus = false }) end - -- Open on startup has been deprecated -- 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 @@ -87,6 +91,9 @@ in { }, actions = { + change_dir = { + global = ${boolToString cfg.actions.changeDir.global}, + }, open_file = { quit_on_open = ${boolToString cfg.actions.openFile.quitOnOpen}, resize_window = ${boolToString cfg.actions.openFile.resizeWindow}, diff --git a/modules/filetree/nvimtree-lua/nvimtree-lua.nix b/modules/filetree/nvimtree-lua/nvimtree-lua.nix index cf3ee4f..871018d 100644 --- a/modules/filetree/nvimtree-lua/nvimtree-lua.nix +++ b/modules/filetree/nvimtree-lua/nvimtree-lua.nix @@ -21,30 +21,12 @@ in { 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 { - default = [".git" "node_modules" ".cache"]; + default = ["node_modules" ".cache"]; description = "Files to hide in the file view by default."; type = with types; listOf str; }; - hideIgnoredGitFiles = mkOption { - default = false; - description = "Hide files ignored by git"; - type = types.bool; - }; - openOnSetup = mkOption { default = true; description = "Open when vim is started on a directory"; @@ -82,7 +64,7 @@ in { }; openTreeOnNewTab = mkOption { - default = false; + default = true; description = "Opens the tree view when opening a new tab"; type = types.bool; }; @@ -182,7 +164,7 @@ in { }; hideRootFolder = mkOption { - default = false; + default = true; description = "Hide the root folder"; type = types.bool; }; @@ -191,7 +173,7 @@ in { git = { enable = mkEnableOption "Git integration"; ignore = mkOption { - default = true; + default = false; description = "Ignore files in git"; type = types.bool; }; @@ -206,6 +188,13 @@ in { }; actions = { + changeDir = { + global = mkOption { + default = true; + description = "Change directory when changing nvim's directory (DirChanged event)."; + type = types.bool; + }; + }; openFile = { resizeWindow = mkOption { default = true;