-
-
Notifications
You must be signed in to change notification settings - Fork 136
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
[WIP][RFC] Hyperlink Refactor #790
Conversation
I really appreciate this refactoring. As the author of the original Url class I also spent a lot of time with the hyperlink feature (the situation before was even more constraining), and I am very happy, that you're driving this more forward. Currently a couple of tests are still failing - I didn't hat the time to take a deeper look. Is this mainly because of changed API/changed assumptions? If so and you consider this feature as usable, I would be very happy to merge it on my personal development branch and test it during my daily work. I also took a brief look into the code. It looks promising, but I hadn't had the time for a focused review. The last saying has @kristijanhusak. I think, he is also a bit busy right now - but I hope he can just have a brief look soon to look, if your PR is aligned with his vision of orgmode, so you can continue and polish your PR. |
Thank you for having a look @seflue! I have done some brief testing of the major features I believe to have touched, and they all seem to work properly. It'd be very useful if you could do some more extensive testing, and I'd greatly appreciate it! |
Are you planning to make a PR to org-roam too? Actually I am using org-roam quite extensively. Can I help you to craft an PR? I am also contributing to this project. It would be good, to have the PR in for org-roam ready to merge when your PR in Orgmode gets merged, to keep the implications for org-roam users at a minimum. |
I am planning on making a PR to Org-Roam too, as in a user of it too. I just happen to be on vacation until Saturday so i dont currently have time to work on it. Feel free to make a PR/local version of Org-roam that works with this refactor. That'd be greatly appreciated, and would probably help in getting this merged sooner rather than later. |
Hey, thanks for the PR! If you would like to attempt to do the changes, I'd prefer if we do this in several steps (PRs), so it's easier to review and catch any potential bugs:
|
Refactors all hyperlink handling. This improves maintainablity, and adds flexibilty. It also introduces link aliases, and custom link types.
cf650e5
to
0773a4d
Compare
Make org-insert-link autocompletion more flexible and reliable. Resolves links to IDs on insertion. Pulls names for functions in line with org-link-parameters.
Thank you for having a look @kristijanhusak! What do you mean exactly with "a similar structure to autocompletion"? I would also like to know how you imagine the usage of the current link handling (Primarily Do you have any suggestions on how to handle this gracefully? I would be more than willing to take on the work, especially since I'm now very familiar with how all the hyperlink stuff works. |
Greatly improved the autocompletion of the file protocol. Also adds autocompletion for targets.
As this is a breaking change, @kristijanhusak do you plan to bump the released version of this plugin when this rolls out? So far, org-roam.nvim has been compatible with the latest version of this plugin without needing to support new and old logic. If this is going to be a break, having a tag so I can publish a new version of org-roam.nvim matching that tag would be great 😄 |
In the autocompletion that I linked https://github.com/nvim-orgmode/orgmode/blob/master/lua/orgmode/org/autocompletion/init.lua, there is a "master" OrgCompletion class that has a list of sources, and orchestrates everything. In completions example, it knows how to figure out the context, collect all sources for the completion and return it. I'd like to have a similar thing for hyperlinks, basically:
To give you an example of usage. Once we have this, and we want to autocomplete all of the links that match a partial string, we would do this: local autocompletion_string = 'file:/home`
local results = OrgHyperlink:complete(autocompletion_string)
--- results = OrgHyperlinkSource[]
--- where OrgHyperlinkSource is something like this:
---@class OrgHyperlinkSource
---@field protocol string - id,file,headline
---@field path
--- and other similar fields that `OrgUrl` currently have
As mentioned, current code is not touched, we just write the new one. I don't expect any bigger changes to the OrgUrl or Hyperlink at this moment.
Yeah, basically these steps (high level):
@chipsenkbeil No worries, I don't plan to release any breaking changes without a notice. |
Are we sure we want every (Hyper)link source to have all the fields the current One of the reasons I wanted to restructure this |
That's correct, we don't want to have all of them. We just need to figure out what they all share. Ideally we should have the interface with methods that are generic, like |
Thanks for all the responses @kristijanhusak! I'm currently working on restructuring my current code to the way you had in mind (similar to Previously you suggested
I originally used a structure similar to this, but ended up falling back to returning |
Start with what you can work with, and we can expand on it later if necessary. |
I've made a branch on my fork to work on switching what I have to a structure similar to If you could look and confirm whether this is more like you had in mind, I would greatly appreciate it @kristijanhusak. The branch is links/registry, and all the new code can be found under lua/orgmode/org/links (Except for a |
@SlayerOfTheBad please open up a separate PR with those changes so I can leave comments on it. |
@kristijanhusak new PR has been created, #793. As that one superseeds this one, I will close this one. |
I noticed that link abbreviations weren't supported, and wanted to make a PR to do that.
After looking at the code, I quickly started understanding why they weren't supported.
So I set to work refactoring the entire Hyperlink section.
This is a draft because
However, I'm going on vacation soon, so I thought I'd present it so this can be reviewed whilst I'm away.
Also, if this is not something that's desired, I don't have to bother writing all the Unit tests.
I've tried to keep the Api stable, but I do know that at least
org-roam.nvim
does some calls tolink.url
which doesn't exist anymore.I am willing to make a PR for
org-roam.nvim
to resolve those issues.As for what this pull request changes feature-wise:
org-insert-link
In addition to being much more maintainable and easier to extend in future.