-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] Show dashboard with directory as first argument #61
Comments
would this also change the working directory? i do this accidentally all the time, actually. it's tricky to get the behavior right so it should definitely be opt in |
in my personal config i currently have this relatively complicated autocmd setup to open a file tree when i try to open a directory with nvim vim.cmd[[
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in') |
\ execute 'cd '.argv()[0] | execute 'NvimTreeOpen' | wincmd p | q | endif
]] |
No, that's not required.
NvimTree has an option to do that for you. After rereading, I understand your comment better. |
@genebean -- Set workdir if argument is provided
if vim.api.nvim_buf_get_name(0) ~= '' then
-- get current opened buffer (first argument with `nvim /path/to/dir/or/file`)
local path = vim.api.nvim_buf_get_name(0)
-- workdir is either the directory itself or the directory where the file is
local workdir = vim.fn.isdirectory(path) == 1 and path or vim.fs.dirname(path)
if vim.fn.isdirectory(path) == 1 then
-- remove directory buffer to get an empty buffer
-- to show neovim info you need a single empty buffer
vim.cmd([[bdelete %]])
end
-- set workdir which allows creating/navigating in the directory (used by telescope/etc...)
vim.loop.chdir(workdir)
end If this is not enough, you can use |
@JSteitz Your suggestion lead me to this fix (I added it to my alpha config) vim.cmd('autocmd User AlphaReady Neotree show') |
In the code, you are already handling files as first argument.
It would be nice, if we could have an option to show the dashboard when the first argument a directory is.
The text was updated successfully, but these errors were encountered: