As title. I'm using NeoVim. If I use vim.fn.getcwd()
in the config I will not get the correct path considering the argument, e.g. nvim ./go/deeper/into/some/folder
, passed to nvim
. Solutions in VimScript is welcome since I can translate it into lua one.
1 Answer
The getcwd()
returns the current working directory of vim. By default it is the current working directory of the process that started vim.
In particular it is not the path of the folder of the file edited that you pass as argument to vim.
-
-
I believe not while reading the .vimrc file. If you give us more information about what you would like to achieve I suppose we could guide you better on the way to achieve it. Why do you want to use the folder path of the file you pass as argument to vim? Apr 19, 2022 at 12:04
-
-
@VivianDeSmedt: github.com/nyngwang/NeoRoot.lua, I'm the author. I want to skip the first step. "what you would like to achieve"... Hmmm, the best of me?– KindredApr 20, 2022 at 3:35
fnamemodify()
withargc()
/argv()
, orv:argv
if you need the full command-line.