fix config.root() so it returns a string or nil #192
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
config.root()
should returnstring?
, butvim.loop.fs_realpath
returns a 3-tuple (see :help vim.uv.fs_realpath and :help luv-error-handling). By adding parentheses around the function call, we force the function to return the first value of the tuple, which also fixesconfig.types()
so it returnsstring?
as well.This fixes an error when trying to use rocks.nvim to install
neodev.nvim
. Since thetypes/
folder is nowhere to be found when installing neodev.nvim with luarocks, the call to fs_realpath returns an error, and stops the execution after any call toconfig.types()
(which happens when trying to setup library folders for the LSP. This creates a bunch ofUndefined global 'vim'
appear on myinit.lua
config.Although this looks like a fix specifically for my use case with rocks.nvim, it makes the function comply with it's signature, which I see as a good thing in the long run.