-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Wikilink titles support #221
Conversation
Love it, thanks! I'll have a closer look shortly. Meanwhile, could you please
|
With this patch wikilinks of the form [[doc#heading|title]] are correctly recognized as links to doc#heading. Also go-to-definition works as normal. This fixes artempyanykh#136.
af28c0e
to
8fa8b25
Compare
I applied the suggestions from I need to spend some time understanding how the tests are set up, I'll try to do so soon. Unrelated: while testing these changes interactively I found a problem that was not caught by the tests when suggesting completions for an empty |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple nits, otherwise looks great! @eguiraud LMK if you need some help with testing.
- better names for things - make contentAndSpan more readable
Applied suggestions from code review and added some tests, although I still don't understand how the tests works 😅 first time I write F#, sorry |
Great job, thanks @eguiraud! Re: tests -- I use snapshot tests quite often (also known as golden testing) where the test output is compared to a previously recorded output. I use https://github.com/theramis/Snapper library, which works albeit a bit fiddly wrt. updating the snapshots. |
@eguiraud It doesn't seem to be working for me :( the cwd of neovim is the same folder where the |
@tjex it hasn't been released yet, just merged into main. I'll cut a new release in a couple days. Otherwise, you may want to try building from source. |
ahh! apologies! |
With this patch wikilinks of the form [[doc#heading|title]] are correctly recognized as links to doc#heading.
Also go-to-definition works as normal.
Fixes #136.
Admittedly, this could have been done with a smaller patch, but the addition of the title-handling logic was making the function quite hard to follow (already before the patch it had 6+ levels of indentation).
So I took this chance to refactor the parsing to use a simple "functional finite state machine pattern". Basically we have a
parse()
function that kicks off the parsing and then transitions to other functions as needed via pattern matching (parseTitle
,parseHeading
,parseDoc
,parseEnd
).parseDoc
can transition to all other functions but not toparse
(we don't go back to the beginning) or fail earlyparseHeading
can only transition toparseTitle
orparseEnd
(we don't go back to the doc) or fail earlyparseTitle
can only transition toparseEnd
or fail earlyparseEnd
can either return success (this was a well-formed wiki link) or failure (not a well-formed wiki link)I hope the new logic is easy to follow!