-
Notifications
You must be signed in to change notification settings - Fork 208
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 option to generate Obsidian-compatible wiki links #729
base: main
Are you sure you want to change the base?
Conversation
Nice! For my use-case I also remove the path, and so I just keep the file name. I guess that'd be the real The reasoning is that if I move a note from outside of Obsidian Desktop (via a script for example), it would not update the file path inside of links, so it would break the links. But yeah, I was surprised that most of the available in the plugin options for generating links are unsupported by the Obsidian app. This PR is needed IMHO. |
Could you give some examples so I can better understand your use case? From my understanding, Obsidian uses the name of the notes (without the extension) in order to be able to locate the files. It can also use the relative path from the root of the vault to achieve the same result. For this reason, moving new files to the Obsidian directory should allow to link them from other notes without problems. Please let me know if I understand this correctly. The other option is that you want to link to files outside the Obsidian directory, which could bring problems if you want to access the linked note from another device. I’m also looking at adding an option to facilitate the inclusion of subsections within the note, titles or tags, but the current system uses a strange character that is not fully compatible with the standard Obsidian form (which can lead to inconsistencies if some notes are created from Obsidian and others from Neovim). |
Sure. You're right that Obsidian uses either a filename or a relative filepath to create links. In my case I avoid including the filepath for the following reason: My workflow:
The crux is that I don't typically use the Obsidian app to move files around. I either do it with some bash scripts, or just from inside nvim. So, if I had created a link in a note that is something like Hence, I simply added a small regex to the function I took from this PR local name = opts.path:match("[^/]+$"):gsub("%.md", "") , although I don't know if the forward-slash is platform-independent in this path. I haven't looked at how paths are parsed in the plugin. |
This PR adds a new option
use_name_only
for thewiki_link_func
setting that generates links in the[[Foo]]
format without the.md
extension. This ensures compatibility with the Obsidian desktop app, which does not recognize links in the[[alias]]
format.Changes made:
use_name_only
option towiki_link_func
, which generates links using the filename and the relative path without the extension.use_name_only
option differs from the existinguse_alias_only
, asuse_alias_only
might not work correctly with the desktop version if the alias is not identical to the filename.wiki_link_name_only
function and produce the expected results.use_name_only
option differs from the existinguse_alias_only
, asuse_alias_only
might not function correctly with the desktop version if the alias does not match the filename exactly.Reason for the contribution:
The default autocompletion function generated links that were not recognized by the Obsidian desktop app, making note navigation more difficult. With this function, links are compatible and easy to use in both
obsidian.nvim
and the Obsidian app.