From 73cc5edd31aaf51ff3ff69c12e0f84c739a9a3c6 Mon Sep 17 00:00:00 2001 From: DamitusThyYeetus123 <108782125+DamitusThyYeetus123@users.noreply.github.com> Date: Tue, 12 Nov 2024 13:04:33 +1100 Subject: [PATCH 1/3] nvim-tree: Add directory opening --- modules/plugins/filetree/nvimtree/config.nix | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/plugins/filetree/nvimtree/config.nix b/modules/plugins/filetree/nvimtree/config.nix index 30cc680..d865e4c 100644 --- a/modules/plugins/filetree/nvimtree/config.nix +++ b/modules/plugins/filetree/nvimtree/config.nix @@ -58,6 +58,9 @@ in { -- buffer is a real file on the disk local real_file = vim.fn.filereadable(data.file) == 1 + -- buffer is a directory + local directory = vim.fn.isdirectory(data.file) == 1 + -- buffer is a [No Name] local no_name = data.file == "" and vim.bo[data.buf].buftype == "" @@ -65,15 +68,19 @@ in { local filetype = vim.bo[data.buf].ft -- only files please - if not real_file and not no_name then + if not real_file and not directory and not no_name then return end -- skip ignored filetypes if vim.tbl_contains(IGNORED_FT, filetype) then return - end + end + -- cd if buffer is a directory + if directory then + vim.cmd.cd(data.file) + end -- open the tree but don't focus it require("nvim-tree.api").tree.toggle({ focus = false }) end From 14de965ce9b38a8d3b2b642517886d5940eb586f Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Tue, 3 Dec 2024 01:31:48 +0100 Subject: [PATCH 2/3] formatting --- modules/plugins/filetree/nvimtree/config.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/plugins/filetree/nvimtree/config.nix b/modules/plugins/filetree/nvimtree/config.nix index 1cf8eba..750f4e1 100644 --- a/modules/plugins/filetree/nvimtree/config.nix +++ b/modules/plugins/filetree/nvimtree/config.nix @@ -94,7 +94,7 @@ in { -- skip ignored filetypes if vim.tbl_contains(IGNORED_FT, filetype) then return - end + end -- cd if buffer is a directory if directory then From 6d07646fae39c64850a0df06a81913f45c284b73 Mon Sep 17 00:00:00 2001 From: damii Date: Wed, 4 Dec 2024 09:35:25 +1100 Subject: [PATCH 3/3] Fix formatting --- modules/plugins/filetree/nvimtree/config.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/plugins/filetree/nvimtree/config.nix b/modules/plugins/filetree/nvimtree/config.nix index 750f4e1..8a34a0b 100644 --- a/modules/plugins/filetree/nvimtree/config.nix +++ b/modules/plugins/filetree/nvimtree/config.nix @@ -77,7 +77,7 @@ in { -- buffer is a real file on the disk local real_file = vim.fn.filereadable(data.file) == 1 - -- buffer is a directory + -- buffer is a directory local directory = vim.fn.isdirectory(data.file) == 1 -- buffer is a [No Name]