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] 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 30cc680b..d865e4c8 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