Skip to content

Commit

Permalink
filetree/nvim-tree: Open on directory (#462)
Browse files Browse the repository at this point in the history
* nvim-tree: Add directory opening

* formatting

* Fix formatting

* format

Co-authored-by: raf <[email protected]>

---------

Co-authored-by: Ching Pei Yang <[email protected]>
Co-authored-by: raf <[email protected]>
  • Loading branch information
3 people authored Dec 23, 2024
1 parent 46aa168 commit 3a2edd1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion modules/plugins/filetree/nvimtree/config.nix
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,17 @@ 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 == ""
-- &ft
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
Expand All @@ -93,6 +96,10 @@ in {
return
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
Expand Down

0 comments on commit 3a2edd1

Please sign in to comment.