Resolving markdown links without extension lead to following error:
E5108: Error executing lua ...e/nvim/lazy/follow-md-links.nvim/lua/follow-md-links.lua:99: attempt to concatenate local 'modified_link' (a nil value)
stack traceback:
...e/nvim/lazy/follow-md-links.nvim/lua/follow-md-links.lua:99: in function 'follow_local_link'
...e/nvim/lazy/follow-md-links.nvim/lua/follow-md-links.lua:128: in function 'follow_link'
[string ":lua"]:1: in main chunk
The error happens in the function follow_local_link():
Lets say we have a file test.md and we want to link to that file, we have at least the following 4 cases:
[test](test) -> fails
[test](test.md) -> works
[test](test:3) -> nothing happens
[test](test.md:2) -> works
For case 1 both if statements in L96 and L98 are true and a string concatenation of modified_link and ".md" is tried. But as modified_link is a nil value (defined as in L94) this fails with the error described above. The fix for this is to concatenate with the link variable:
modified_link = link .. ".md"
But then the code for parsing the line number is never reached and that is why `test can't be resolved. To fix that a further refactor is necessary.
Resolving markdown links without extension lead to following error:
The error happens in the function
follow_local_link()
:https://github.com/jghauser/follow-md-links.nvim/blob/a5e023f70e704197fea1c83b9e4b09333c07e178/lua/follow-md-links.lua#L93-L111
Lets say we have a file
test.md
and we want to link to that file, we have at least the following 4 cases:[test](test)
-> fails[test](test.md)
-> works[test](test:3)
-> nothing happens[test](test.md:2)
-> worksFor case 1 both if statements in L96 and L98 are true and a string concatenation of
modified_link
and".md"
is tried. But asmodified_link
is anil
value (defined as in L94) this fails with the error described above. The fix for this is to concatenate with thelink
variable:But then the code for parsing the line number is never reached and that is why `test can't be resolved. To fix that a further refactor is necessary.
I'll file a pull request with the changes.