From ea07178de031c25a16e007564ad61cc1fd8b98e1 Mon Sep 17 00:00:00 2001 From: jasmine Date: Sun, 14 Dec 2025 20:36:21 +0800 Subject: [PATCH] revert 620bad6011 --- config/default.nix | 1 + config/plugins/editor/sessions.nix | 19 ++++++++++++ config/plugins/ui/nvim-tree.nix | 47 ++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+) create mode 100644 config/plugins/ui/nvim-tree.nix diff --git a/config/default.nix b/config/default.nix index 596de7d..1d41001 100644 --- a/config/default.nix +++ b/config/default.nix @@ -35,6 +35,7 @@ # User Interface Plugins ./plugins/ui/lualine.nix + ./plugins/ui/nvim-tree.nix ./plugins/ui/web-devicons.nix ./plugins/ui/whichkey.nix diff --git a/config/plugins/editor/sessions.nix b/config/plugins/editor/sessions.nix index 12deaf9..a439794 100644 --- a/config/plugins/editor/sessions.nix +++ b/config/plugins/editor/sessions.nix @@ -1,6 +1,25 @@ {...}: { plugins.auto-session = { enable = true; + + # fix: nvim-tree / auto-session + settings = { + log_level = "error"; + pre_save_cmds = [ + "NvimTreeClose" + ]; + post_save_cmds = [ + "NvimTreeOpen" + ]; + post_open_cmds = [ + "NvimTreeOpen" + ]; + post_restore_cmds = [ + "NvimTreeOpen" + ]; + cwd_change_handling = true; + }; + # https://github.com/zwhitchcox/auto-session-nvim-tree }; keymaps = [ diff --git a/config/plugins/ui/nvim-tree.nix b/config/plugins/ui/nvim-tree.nix new file mode 100644 index 0000000..4563183 --- /dev/null +++ b/config/plugins/ui/nvim-tree.nix @@ -0,0 +1,47 @@ +{...}: { + plugins.nvim-tree = { + enable = true; + + # Configure nvim-tree + settings = { + # Set width of nvim-tree + view = { + width = 38; + }; + + # Hide dotfiles + filters = { + dotfiles = true; + }; + + # fix: nvim-tree / auto-session + sync_root_with_cwd = true; + actions = { + change_dir = { + global = true; + }; + }; + # https://github.com/zwhitchcox/auto-session-nvim-tree + }; + }; + + keymaps = [ + { + mode = ["n"]; + key = "n"; + action = "NvimTreeToggle"; + options = { + desc = "Toggle file explorer"; + }; + } + + { + mode = ["n"]; + key = "e"; + action = "NvimTreeFocus"; + options = { + desc = "Focus file explorer"; + }; + } + ]; +}