How do you detect if a directory is opened(with
:edit) in Vimscript? I am lazy loading a file explorer and need it to load it before I open a directory.
One approach I tried using an autocommand that fires on
BufRead that calls a function that checks if the current buffer is a directory using
isdirectory(), but unfortunately to no avail:
-- call directory checker vim.cmd[[autocmd BufRead * lua checkDir()]] -- function to check if the file being edited is a directory -- it also sends a call to my plugin manager to load my file explorer(vim-dirvish) function checkDir() if vim.fn.isdirectory('%') == 1 then -- load file manager end end