Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to query neovim API for the current working directory?

Tags:

neovim

The neovim API provides nvim_set_current_dir(), but apparently does not expose a way to query cwd. How can I go about doing this?

like image 918
thisisrandy Avatar asked Dec 21 '25 12:12

thisisrandy


1 Answers

old question, but I couldn't find the answer, so...
here it is; :lua print(vim.fn.getcwd())

ps; if you're using lsp, you may want to put it on on_attach; vim.api.nvim_set_current_dir(client.config.root_dir)

like image 50
Rafael Quintela Avatar answered Dec 24 '25 11:12

Rafael Quintela



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!