0

I saw that the harpoon2 plugin uses vim.loop.cwd() in here, and then it got me thinking what is the difference between using vim.fn.getcwd() and vim.loop.cwd().

The following code returns the same path

:lua print(vim.fn.getcwd(), vim.loop.cwd())
/Users/rubelagu/git/urllib3 /Users/rubelagu/git/urllib3

So it's there any reason to choose one over the other? To me vim.loop.cwd() looks like the "default" choice, so I wonder why anybody will use vim.loop.cwd() instead.

Are they completely equivalent? is there any difference in behaviour, performance, etc in any case?

3
  • I would imagine only the person who wrote the code will be able to answer this question.
    – Friedrich
    Mar 5 at 7:48
  • well, I'm using harpoon2 as an example but the question was meant to be general, is there any reason to choose one over the other or they are actually completely equivalent when used without arguments. Mar 5 at 13:30
  • It would be the difference between needing libUV behavior vs. needing vimscript-style getcwd() behavior, no (I don't imagine there's a difference, but still)?
    – D. Ben Knoble
    Mar 5 at 16:51

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.