Closed shasherazi closed 1 year ago
Thanks for the suggestion!
MiniFiles.open()
by default uses current working directory as anchor (target) directory. When you open nvim dotfiles/config/nvim
, MiniFiles.open()
is called with 'dotfiles/config/nvim'
path, but when you later call it (probably without arguments), it is called without arguments and uses current working directory (which by default is the one Neovim was opened in; ~
in your case).
You have several options:
MiniMisc.setup_auto_root()
from 'mini.misc'.Closing as not planned.
Hi, I tried the first two methods, and kinda both of them failed. For the first method, I need to open a file in that directory, and for the second method, it just selects the sensible root (the directory with .git
in my case, where I am trying to open nvim
in a subfolder).
Basically, what I wanted was to get the path argument when running nvim
and change cwd
to that. I have searched fairly long time but couldn't find a way. Guess I'll just stick to the 2nd method till a solution is found.
For the first method, I need to open a file in that directory,
Judging by your example, you've already inside target directory, so first method (with example buffer mapping from 'mini.files') should work (assuming directory is not empty, though).
Basically, what I wanted was to get the path argument when running
nvim
and changecwd
to that. I have searched fairly long time but couldn't find a way. Guess I'll just stick to the 2nd method till a solution is found.
I am not sure if I understand correctly, but this basically sounds like a combination argv()
and chdir()
built-in functions. Try putting something like this inside your config startup files:
if vim.fn.argc(-1) > 0 then
local path = vim.fn.argv(0)
if vim.fn.isdirectory(path) == 0 then path = vim.fs.dirname(path) end
vim.fn.chdir(path)
end
Contributing guidelines 贡献指南
- [x] I have read CONTRIBUTING.md 我已阅读 CONTRIBUTING.md
- [x] I have read CODE_OF_CONDUCT.md 我已阅读 CODE_OF_CONDUCT.md
Module(s) 模块
mini.files 迷你文件
Description 描述
When I open neovim like
nvim dotfiles/config/nvim
from the home directorymini.files
opens like this当我从主目录nvim dotfiles/config/nvim
打开neovim时mini.files
像这样打开But the next time
mini.nvim
is opened, it shows this但是下次打开mini.nvim
时,它会显示这个I used
nvim-tree
before and it changed the working directory to whichever folder was first opened and persisted. Can I have this feature inmini.files
as well?我之前使用过nvim-tree
,它将工作目录更改为首先打开并保留的文件夹。我也可以在mini.files
中使用此功能吗?vim.keymap.set("n", "<leader>e", ":lua MiniFiles.open(vim.api.nvim_buf_get_name(0))<CR>", {noremap = true, silent = true,})
mayme you can try keymap like this(?
try this
{
"
Contributing guidelines
Module(s)
mini.files
Description
When I open neovim like
nvim dotfiles/config/nvim
from the home directorymini.files
opens like thisBut the next time
mini.nvim
is opened, it shows thisI used
nvim-tree
before and it changed the working directory to whichever folder was first opened and persisted. Can I have this feature inmini.files
as well?