epwalsh / obsidian.nvim

Obsidian 🤝 Neovim
Apache License 2.0
4.18k stars 188 forks source link

Markdown Links instead of WikiLinks #75

Closed vicecaycedo closed 11 months ago

vicecaycedo commented 1 year ago

🚀 The feature, motivation and pitch

Markdown links are generally better supported than WikiLinks in other tools. As such, Obsidian has the option to use markdown links instead of wikilinks. Can a similar configuration option be provided here for the autocompletion? Thanks!

Alternatives

No response

Additional context

No response

epwalsh commented 1 year ago

By "wikilink" do you mean like this [[ ... ]]?

I think this is possible. I can think of two options for how this would work:

  1. You would still trigger autocomplete by typing [[ and then the search term, but when the completion is accepted it would insert the MD form of the link instead of the wiki form. You would get this behavior by setting some value in obsidian.nvim's config.
  2. If you want an MD link, you type a single [ and then the search term (instead of double brackets [[). We would need to implement a separate completion source, but I think I like this option better because it allows users to get both forms of link style without any additional configuration changes.
vicecaycedo commented 1 year ago

Yes, that's exactly what I meant 🙂

I like the second option more as well, but if that's too much work, the first option seems good to me too!

Thanks for making this plugin!

bigzhu commented 1 year ago

Need this feature too, 2 is better.

epwalsh commented 1 year ago

Ok I will try to find some time to implement option 2 soon. In the meantime, if anyone else wants to take a stab at this, here's what I'd suggest: Create a new lua file for the completion source: lua/cmp_obsidian_md.lua. Start by just copying the code from lua/cmp_obsidian.lua. Most of the functionality is implemented in lua/obsidian/completion.lua, so you might have to add new variants of those functions.

epwalsh commented 11 months ago

Option 2 is now implemented in #237