This commit is contained in:
DamitusThyYeetus123 2024-11-13 18:49:14 +01:00 committed by GitHub
commit 79bfa52d16
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -58,6 +58,9 @@ in {
-- buffer is a real file on the disk -- buffer is a real file on the disk
local real_file = vim.fn.filereadable(data.file) == 1 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] -- buffer is a [No Name]
local no_name = data.file == "" and vim.bo[data.buf].buftype == "" local no_name = data.file == "" and vim.bo[data.buf].buftype == ""
@ -65,15 +68,19 @@ in {
local filetype = vim.bo[data.buf].ft local filetype = vim.bo[data.buf].ft
-- only files please -- 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 return
end end
-- skip ignored filetypes -- skip ignored filetypes
if vim.tbl_contains(IGNORED_FT, filetype) then if vim.tbl_contains(IGNORED_FT, filetype) then
return 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 -- open the tree but don't focus it
require("nvim-tree.api").tree.toggle({ focus = false }) require("nvim-tree.api").tree.toggle({ focus = false })
end end