ms-jpq / chadtree

File manager for Neovim. Better than NERDTree.
1.62k stars 60 forks source link

Breaks ability to run "nvim ." #357

Closed BaktashGorgani closed 6 months ago

BaktashGorgani commented 6 months ago

nvim . used to bring me right to netrw in the directory I am currently in.

Since installing chadtree, nvim . now opens up a blank file

BaktashGorgani commented 6 months ago

Well I found the following

          Try adding the following to your .vimrc as it worked for me 
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in') |
    \ execute 'CHADopen' | execute 'cd '.argv()[0] | endif

Originally posted by @declancm in https://github.com/ms-jpq/chadtree/issues/262#issuecomment-996155449

Just converted it over to lua

vim.api.nvim_create_autocmd("StdinReadPre", {
    pattern = "*",
    command = "let s:std_in=1"
})
vim.api.nvim_create_autocmd("VimEnter", {
    pattern = "*",
    command = "if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in') | execute 'CHADopen' | execute 'cd '.argv()[0] | endif"
}) 

Works pretty good