mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-12-27 19:49:48 +01:00
filetree/nvim-tree: Open on directory (#462)
* nvim-tree: Add directory opening * formatting * Fix formatting * format Co-authored-by: raf <raf@notashelf.dev> --------- Co-authored-by: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Co-authored-by: raf <raf@notashelf.dev>
This commit is contained in:
parent
46aa168b2d
commit
3a2edd1b75
1 changed files with 8 additions and 1 deletions
|
@ -77,6 +77,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 == ""
|
||||
|
||||
|
@ -84,7 +87,7 @@ 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
|
||||
|
||||
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue