lervag / wiki.vim

A wiki plugin for Vim
MIT License
642 stars 69 forks source link

Activating wiki-style links in files with an ".md" extent #294

Closed EricEWeir closed 1 year ago

EricEWeir commented 1 year ago

Hello, Karl. Since I was last active here I've been getting familiar with Obsidian. The files I brought over from wiki.vim had markdown links. Using them is not as straightforward in Obsidian as in wiki.vim. Eventually I was persuaded to convert to wiki-style links:.

I would like to use Vim to compose and edit Obsidian notes. However, when Obsidian notes are opened in Vim wiki-style links are not active. Checking the wiki.vim documentation I see that wiki-style links are an option. That it is activated by specifying wiki as the link target type.

Since my Obsidian notes have an .md extent I was not sure how to do that. I've included the lines from my .vimrc where I tried, unsuccessfully, to do that. I also tried adding .wiki as a link extension. That didn't work either.

Is it possible to activate wiki-style links in files with an .md extent?

llet g:wiki_filetypes = ['md', 'wiki']
let g:wiki_link_extension = '.md'
let g:wiki_link_target_type = 'wiki'
bybor commented 1 year ago

@EricEWeir , please note that there has been a new release just a couple days ago. It probably makes sense to get it to have a common ground. I'm sorry, I cannot help with your question.

lervag commented 1 year ago

I would like to use Vim to compose and edit Obsidian notes. However, when Obsidian notes are opened in Vim wiki-style links are not active.

What does "not active" mean?

Also, can you be explicit about what you mean by wiki-style? Do you mean links like [[text|url]] or [[url]] where url is the filename of the target page?

Note that this is key to helping you. I need to understand 1) how the links "look like" in Obsidian, and 2) how the link url's relate to the target filenames.

Checking the wiki.vim documentation I see that wiki-style links are an option. That it is activated by specifying wiki as the link target type.

Yes, specifying the target type means to specify which type of link is created when you hit Enter on a word or selection.

Since my Obsidian notes have an .md extent I was not sure how to do that. I've included the lines from my .vimrc where I tried, unsuccessfully, to do that.

I would assume that you want something like this:

" Activate wiki.vim for files with extensions .md and .wiki
let g:wiki_filetypes = ['md', 'wiki']

" Do not append any extension when you create a link
let g:wiki_link_extension = ''

" Use [[...]] style links with Enter key
let g:wiki_link_target_type = 'wiki'

The comment by @bybor is also very relevant. If you have not done so already, please update wiki.vim. There were some updates that relate to e.g. the default values of some of these options.

EricEWeir commented 1 year ago

On Apr 13, 2023, at 3:07 PM, bybor @.***> wrote:

@EricEWeir , please note that there has been a new release just a couple days ago. It probably makes sense to get it to have a common ground. I'm sorry, I cannot help with your question.

Wow! Lotsa changes.


Eric Weir Decatur, GA USA @.***

"Imagining the other is a powerful antidote to fanaticism and hatred."

EricEWeir commented 1 year ago

I would like to use Vim to compose and edit Obsidian notes. However, when Obsidian notes are opened in Vim wiki-style links are not active.

What does "not active" mean?

The link is non functioning text.

Also, can you be explicit about what you mean by wiki-style? Do you mean links like [[text|url]] or [[url]] where url is the filename of the target page?

The latter. Tapping or clicking on the link has no effect.

Checking the wiki.vim documentation I see that wiki-style links are an option. That it is activated by specifying wiki as the link target type.

Yes, specifying the target type means to specify which type of link is created when you hit Enter on a word or selection.

Since my Obsidian notes have an .md extent I was not sure how to do that. I've included the lines from my .vimrc where I tried, unsuccessfully, to do that.

I would assume that you want something like this:

" Activate wiki.vim for files with extensions .md and .wiki
let g:wiki_filetypes = ['md', 'wiki']

" Do not append any extension when you create a link
let g:wiki_link_extension = ''

" Use [[...]] style links with Enter key
let g:wiki_link_target_type = 'wiki'

Thanks for those, Karl.

The comment by @bybor is also very relevant. If you have not done so already, please update wiki.vim. There were some updates that relate to e.g. the default values of some of these options.

I upgraded when I got @bybor’s response. Vim Plug reported a humongous number of changes.

lervag commented 1 year ago

Also, can you be explicit about what you mean by wiki-style? Do you mean links like [[text|url]] or [[url]] where url is the filename of the target page?

The latter. Tapping or clicking on the link has no effect.

With the mouse? I know neovim and Vim does have some support for the mouse, but I never use it myself. I've never implemented any default mouse behaviour for wiki.vim. If I understand correctly, you can map actions to mouse clicks.

What is the difference between "tapping" and "clicking"? I'm sorry for asking these possibly dumb questions, but it is much easier to help when I understand exactly what you are doing and what you want to happen.

I would like to use Vim to compose and edit Obsidian notes. However, when Obsidian notes are opened in Vim wiki-style links are not active.

What does "not active" mean?

The link is non functioning text.

With "non functioning text", you mean that "tapping or clicking on the link has no effect"? Or do you mean something else?

" …

Thanks for those, Karl.

My pleasure.

The comment by @bybor is also very relevant. If you have not done so already, please update wiki.vim. There were some updates that relate to e.g. the default values of some of these options.

I upgraded when I got @bybor’s response. Vim Plug reported a humongous number of changes.

Heh, yes, I'm trying to update and improve things. wiki.vim is probably the one plugin in Vim I use the most, and so it is personally well worth my time improving it!

EricEWeir commented 1 year ago

What is the difference between "tapping" and "clicking"? I'm sorry for asking these possibly dumb questions, but it is much easier to help when I understand exactly what you are doing and what you want to happen.

I misspoke. I have a MacBook with a track pad. I also use Vim on mu mobile apps. So there is only tapping. E.g., on the MacBook in Obsidian with a page with wiki style links open, if I place the cursor on a link and tap on the link, the linked file opens.

I upgraded when I got @bybor’s response. Vim Plug reported a humongous number of changes.

Heh, yes, I'm trying to update and improve things. wiki.vim is probably the one plugin in Vim I use the most, and so it is personally well worth my time improving it!

When I finally started getting the hang of Obsidian I began experimenting with it. Tons and tons of features that I will never use. Maybe even never find out about. Two things make it attractive: They have good mobile versions and sinking between them and my notebook is without a hitch. And they have a Vim mode.

If I could have gotten syncing going between Vim on the notebook and iVim on my iPhone and iPad wiki vim would have been adequate for my needs.

EricEWeir commented 1 year ago
" Activate wiki.vim for files with extensions .md and .wiki
let g:wiki_filetypes = ['md', 'wiki']

" Do not append any extension when you create a link
let g:wiki_link_extension = ''

" Use [[...]] style links with Enter key
let g:wiki_link_target_type = 'wiki'

I copied a file with wiki style links to my vim wiki directory. After making the changes above to get wiki style links working in files with an .md extent they are still not working.

This is what the file looks like when opened in vim:

Screen Shot 2023-04-15 at 12 35 43 PM

This is the wiki vim section of my .vimrc: Screen Shot 2023-04-15 at 12 53 28 PM

EricEWeir commented 1 year ago

Markdown links are working.

lervag commented 1 year ago

Ok. I wrote earlier "Note that this is key to helping you. I need to understand 1) how the links "look like" in Obsidian, and 2) how the link url's relate to the target filenames." I believe I may have been unclear. The point is that I need to understand exactly what you are trying to do, and you are not really providing me enough information.

So, to be more clear: In the file titled "1 is inference material" you have several links. Let's consider the first link: [[s 208 logic and inferring]]. What is the file name of the target of that link?

EricEWeir commented 1 year ago

Ok. I wrote earlier "Note that this is key to helping you. I need to understand 1) how the links "look like" in Obsidian, and 2) how the link url's relate to the target filenames."

So, to be more clear: In the file titled "1 is inference material" you have several links. Let's consider the first link: [[s 208 logic and inferring]]. What is the file name of the target of that link?

Apologies for not providing what you need.

This is what the file 1 is inference material looks like when open in Obsidian:

Screen Shot 2023-04-16 at 4 42 38 PM

The name of the file that is the target of [[s 208 logic and inferring]] is s 208 logic and inferring.md.

The URL of that file is: obsidian://open?vault=ZK&file=cook%20wilson%20two%2Fs%20208%20logic%20and%20inferring

lervag commented 1 year ago

Apologies for not providing what you need.

It's ok, I understand it can be hard to know what I need. :)

This is what the file 1 is inference material looks like when open in Obsidian:

The URL of that file is: obsidian://open?vault=ZK&file=cook%20wilson%20two%2Fs%20208%20logic%20and%20inferring

If I decode that, I notice it has this path: cook wilson two/s 208 logic and inferring. It seems Obsidion may use a different mechanism for determining file locations. To understand this better, it would help if you could lay out the file hierarchy of the files.

I would want something like this: A tree view that shows the files and their locations:

~/vimfiles/wiki (or whatever is the Obsidian wiki root)
└─ some path (??)
   └─ 1 is inference material.md
      └─ cook wilson two (??)
         └─ s 208 logic and inferring.md

You could get something like this with the tree command in a shell, but please filter out everything not relevant.


wiki.vim interprets a link from a file /path/to/file.md with [[word]] to be a link to /path/to/word.md, i.e. the link is relative to file.md, unless you specify that it should be relative to the wiki root. You can customize this behaviour with g:wiki_resolver, but that is what I would call advanced customization.

lervag commented 1 year ago

In short: I want to know where s 208 logic and inferring.md is compared to 1 is inference material.md in your file hierarchy.

EricEWeir commented 1 year ago

In short: I want to know where s 208 logic and inferring.md is compared to 1 is inference material.md in your file hierarchy.

I can't draw a diagram. Perhaps this will help:

1 is inference material.md is at:

~/.../iCloud~md~obsidian/Documents/ZK/cook wilson two/1 is inference material.md

It is linked to s 208 logic and inferring.md which is located at:

~/.../iCloud~md~obsidian/Documents/ZK/pages/s 208 logic and inferring.md

If that doesn't help I'll find a way to draw a diagram.

EricEWeir commented 1 year ago

The URL of that file is: obsidian://open?vault=ZK&file=cook%20wilson%20two%2Fs%20208%20logic%20and%20inferring

If I decode that, I notice it has this path: cook wilson two/s 208 logic and inferring. It seems Obsidion may use a different mechanism for determining file locations....

When I was getting started with Obsidian I imported the files I had created with wiki.vim, which had markdown links. Obsidian reads markdown links, but the links in the files I imported from vim.wiki were dead. I could not open linked files. It turns out that markdown links in Obsidian have %20 in every space. Likewise wiki style links.

They may have a plugin that will convert links to a format that are readable by vim.

lervag commented 1 year ago

This seems to confirm my suspicion that Obsidian is doing something "more advanced" with the links. To simplify, it seems like you have files like this:

Here foo.md correspond to 1 is inference material.md and bar.md to one of the targets.

In wiki.vim, the link [[bar]] would target /path/a/b/bar.md, not /path/a/c/bar.md. However, when you click on the link with wiki.vim, you should actually open an empty page at the wrong location. Does that not happen?

EricEWeir commented 1 year ago

This seems to confirm my suspicion that Obsidian is doing something "more advanced" with the links.

Obsidian bills itself as creating/reading plain text/markdown files. It took me a while, interacting with people on the Obsidian users' forum, to learn why markdown links created with vim.wiki weren't working in Obsidian.

Am I correct in understanding that other apps, certainly those that bill themselves as creating/reading plain text/markdown files, don't put %20 or any other characters in spaces in file names? Do you know why they do it?

There seem to be quite a few people creating and editing notes in Obsidian notes with vim. They make it sound straight forward. I'm gonna try to find it

To simplify, it seems like you have files like this:

  • /path/a/b/foo.md with content like this:

    # Title
    
    [[bar]]
  • /path/a/c/bar.md

Here foo.md correspond to 1 is inference material.md and bar.md to one of the targets.

In wiki.vim, the link [[bar]] would target /path/a/b/bar.md, not /path/a/c/bar.md.

That doesn't sound right: As you say, in Obsidian foo and bar are in different folders.

But maybe I don't understand. If in wiki.vim foo and bar were in different folders wouldn't the path to bar be different from the path to foo?

However, when you click on the link with wiki.vim, you should actually open an empty page at the wrong location. Does that not happen?

Yes, when I clink on a link created in Obsidian in vim.wiki an empty page opens.

lervag commented 1 year ago

Am I correct in understanding that other apps, certainly those that bill themselves as creating/reading plain text/markdown files, don't put %20 or any other characters in spaces in file names? Do you know why they do it?

I can't speak for any other apps; sorry. But I do know what %20 is and I can guess why you find it around. It is called URL encoding and is en encoding used to transfer URLs across networks. You can read about them e.g. here.

%20 is the encoding for a regular space character.

My guess is that Obsidian will apply this type of encoding on its URL's when you try to copy it. For instance, the URL you shared earlier is encoded: obsidian://open?vault=ZK&file=cook%20wilson%20two%2Fs%20208%20logic%20and%20inferring. Decoding it results in this string: obsidian://open?vault=ZK&file=cook wilson two/s 208 logic and inferring.

There seem to be quite a few people creating and editing notes in Obsidian notes with vim. They make it sound straight forward. I'm gonna try to find it

I don't use Obsidian and can't really comment so much about the Obsidian perspective of things. Sorry.

But maybe I don't understand. If in wiki.vim foo and bar were in different folders wouldn't the path to bar be different from the path to foo?

Let's take one step back. First, it is important to distinguish between a link (e.g. [title](url)) and a URL:

wiki.vim uses the wiki scheme for the regular wiki URLs. The wiki scheme can be used both to handle wikis with Markdown files and for wikis with .wiki files. As this is a default scheme, you don't have to include the scheme part in the URL. Thus, [[page]] is equivalent to writing [[wiki:page]].

Now, to support navigating between pages through links, we need to define the behaviour for following a wiki schemed link. I.e., we need to convert [[page]] to a specific path. We need to make some assumptions here. And I believe this may be one cause for your confusion.

I believe an example can be enlightening. Given g:wiki_root pointing to ~/wiki and these files:

~/wiki/
├─ index.md
├─ foo/
│  ├─ index.md
│  ├─ bar.md
│  └─ baz.md
├─ bar.md
└─ baz.md

With the default configuration of wiki.vim, you will see this behaviour:

Notice that this behaviour is clearly opinionated. You may find it more intuitive that all links should always be relative to the wiki root. If that is the case, then you are free to configure a custom resolver with g:wiki_resolver.

EricEWeir commented 1 year ago

Am I correct in understanding that other apps, certainly those that bill themselves as creating/reading plain text/markdown files, don't put %20 or any other characters in spaces in file names? Do you know why they do it?

I can't speak for any other apps; sorry. But I do know what %20 is and I can guess why you find it around. It is called URL encoding and is en encoding used to transfer URLs across networks. You can read about them e.g. here.

Thanks for that. No surprise, my actual understanding of the mechanics of linking is pretty minimal ....

But maybe I don't understand. If in wiki.vim foo and bar were in different folders wouldn't the path to bar be different from the path to foo?

Let's take one step back. First, it is important to distinguish between a link (e.g. [title](url)) and a URL:

  • wiki.vim supports several different types of links, most of which are composed of both a title or text part and a URL.
  • wiki.vim also supports various types of URLs. URLs are schemed, where the scheme is the leading part of an URL. E.g. http in http://... or file in file:....

wiki.vim uses the wiki scheme for the regular wiki URLs. The wiki scheme can be used both to handle wikis with Markdown files and for wikis with .wiki files. As this is a default scheme, you don't have to include the scheme part in the URL. Thus, [[page]] is equivalent to writing [[wiki:page]].

I was clueless about URLs before I started trying to work with Obsidian. I had no idea that wiki.vim and vimwiki, used them. Your explanation above is a lot to take in. I think I understand, but dimly. I'm clueless about what it has to do with why links created in Obsidian are not being read by wiki.vim. I take it there's a mis-match of the URLs? Or of the URL schemes?

Now, to support navigating between pages through links, we need to define the behaviour for following a wiki schemed link. I.e., we need to convert [[page]] to a specific path. We need to make some assumptions here. And I believe this may be one cause for your confusion.

I believe an example can be enlightening. Given g:wiki_root pointing to ~/wiki and these files:

~/wiki/
├─ index.md
├─ foo/
│  ├─ index.md
│  ├─ bar.md
│  └─ baz.md
├─ bar.md
└─ baz.md

With the default configuration of wiki.vim, you will see this behaviour:

  • The link [[baz]] in ~/wiki/foo/bar.md will reach ~/wiki/foo/baz.md because the targets are assumed relative to the source file.
  • The link [[../baz]] in ~/wiki/foo/bar.md will reach ~/wiki/baz.md for similar reason (relative path from source file).
  • The link [[/baz]] in ~/wiki/foo/bar.md will reach ~/wiki/baz.md because the initial / specifies to root the link to the wiki root.
  • The link [[/foo/baz]] in ~/wiki/foo/bar.md will reach ~/wiki/foo/baz.md.
  • The link [[foo]] in ~/wiki/bar.md will reach ~/wiki/foo/index.md because if a directory is a target, the index file is the assumed target.

I think I understand all of those. May or may not be helpful to note that Obsidian provides for setting of link paths, with three values:shortest path when possible, relative path to file, absolute path in vault.

Notice that this behaviour is clearly opinionated. You may find it more intuitive that all links should always be relative to the wiki root. If that is the case, then you are free to configure a custom resolver with g:wiki_resolver.

I don't understand why your example has the foo subdirectory. I'm guess it's not simply a replica of the rest of the folder, that though the files in it are not replicas of the files in the top level folder in spite of the fact that they have the same names.

Still groping. I have few folders in my Obsidian vault, but I am striving toward a vault that has folders only for the journal and one as a holding place for new files, before any linking has been done to them.

You don't need to respond to this right away. I need to think about it some more. And, anyway, none of this is urgent.

lervag commented 1 year ago

But maybe I don't understand. If in wiki.vim foo and bar were in different folders wouldn't the path to bar be different from the path to foo?

Let's take one step back. First, it is important to distinguish between a link (e.g. [title](url)) and a URL:

  • wiki.vim supports several different types of links, most of which are composed of both a title or text part and a URL.
  • wiki.vim also supports various types of URLs. URLs are schemed, where the scheme is the leading part of an URL. E.g. http in http://... or file in file:....

wiki.vim uses the wiki scheme for the regular wiki URLs. The wiki scheme can be used both to handle wikis with Markdown files and for wikis with .wiki files. As this is a default scheme, you don't have to include the scheme part in the URL. Thus, [[page]] is equivalent to writing [[wiki:page]].

I was clueless about URLs before I started trying to work with Obsidian. I had no idea that wiki.vim and vimwiki, used them. Your explanation above is a lot to take in. I think I understand, but dimly.

Well, to be honest, it is a mouthful. I made mistakes in my first versions of wiki.vim and I learned about all of these things by working on this project. And I would not be surprised if my handling of links and URLs is still not quite correct. But it works for me :)

I'm clueless about what it has to do with why links created in Obsidian are not being read by wiki.vim. I take it there's a mis-match of the URLs? Or of the URL schemes?

I opened the docs for Obsidian and I notice that it relies on a couple of concepts.

First, it is based on Markdown and uses the standard Markdown link for external links. Thus, when you write [text](url) the url part should typically be an external link such as http://example.com or file://path/to/file or obsidian://open?vault=MainVault&file=Note.md or similar.

Next, for internal links, Obsidian uses the Wikilink syntax: [[title of page]] or [[title of page|link text]] to make a link to the page "title of page". The second form changes the displayed text. However, you can also use the Markdown link, but it seems Obsidian requires that you URL encode the url part. Thus you need [link text](title%20of%20page); notice that this URL does not have a preceding scheme part such as http:, obsidian:. I believe this means Obsidian will default to its internal link "scheme".

The above indicates that Obsidian should be quite compatible with wiki.vim. But I did not find any documentation about how Obsidian stores its files and how it works with respect to relative or absolute links.

May or may not be helpful to note that Obsidian provides for setting of link paths, with three values:shortest path when possible, relative path to file, absolute path in vault.

Yes; but I don't quite understand this. Which value are you currently using?

I don't understand why your example has the foo subdirectory. I'm guess it's not simply a replica of the rest of the folder, that though the files in it are not replicas of the files in the top level folder in spite of the fact that they have the same names.

Ah, yes; my example is just made up. The point of the foo subdirectory was to show the behaviour when you link to files into and out of directories. The point of the files having the same names was to make an example where the names were ambiguous. I.e., the link [[bar]] could mean both root/bar.md or root/foo/bar.md - we need to specify the behaviuor to make it clear. That was what I tried to do. wiki.vim is probably aligned with the relative path to file setting in Obsidian, I would think.

Still groping. I have few folders in my Obsidian vault, but I am striving toward a vault that has folders only for the journal and one as a holding place for new files, before any linking has been done to them.

I mostly have a "flat" wiki myself. I've found directories don't really help me much with regards to order/structure. In fact, I've found it better to just not care so much about the structure at all. Learn to love the chaos and to build the structure by linking.

You don't need to respond to this right away. I need to think about it some more. And, anyway, none of this is urgent.

Hehe, too late. :)

EricEWeir commented 1 year ago

Well, a quickee before I respond to your last note. I opened the file that still has markdown links. Vim/wiki.vim reads them! So, I guess the problem now is to find out how to convert my wiki links to markdown. I understand there are several Obsidian plugins that convert the different kinks to other links. We'll see.


I found a plugin that converts links in an entire vault. Can also specify a path setting to apply during conversion. A down side is that when creating markdown links Obsidian doesn't suggest possible names. Bummer.

EricEWeir commented 1 year ago

I'm clueless about what it has to do with why links created in Obsidian are not being read by wiki.vim. I take it there's a mis-match of the URLs? Or of the URL schemes?

I opened the docs for Obsidian and I notice that it relies on a couple of concepts.

First, it is based on Markdown and uses the standard Markdown link for external links. Thus, when you write [text](url) the url part should typically be an external link such as http://example.com or file://path/to/file or obsidian://open?vault=MainVault&file=Note.md or similar.

At present I don't have any external links. When I access an Obsidian file with internal links in vim the link would still be an internal link, wouldn't it?

Next, for internal links, Obsidian uses the Wikilink syntax: [[title of page]] or [[title of page|link text]] to make a link to the page "title of page". The second form changes the displayed text. However, you can also use the Markdown link, but it seems Obsidian requires that you URL encode the url part. Thus you need [link text](title%20of%20page); notice that this URL does not have a preceding scheme part such as http:, obsidian:. I believe this means Obsidian will default to its internal link "scheme".

As I reported earlier, vim/wiki.vim reads markdown links. However when creating a markdown in Obsidian Obsidian will not suggest possible file names the way it does when creating a wiki link. And I don't believe it will read markdown links created with vim/wiki.vim. At least it wouldn't when I imported the first batch of notes created with vim/wiki.vim.

The above indicates that Obsidian should be quite compatible with wiki.vim. But I did not find any documentation about how Obsidian stores its files and how it works with respect to relative or absolute links.

I don't know anything about that. Probably can't. Probably way over my head.

May or may not be helpful to note that Obsidian provides for setting of link paths, with three values:shortest path when possible, relative path to file, absolute path in vault.

Yes; but I don't quite understand this. Which value are you currently using?

Currently I have relative path to file. But I have no idea what difference the different settings make. Posters on that Reddit thread I referred to you had strong opinions about which setting was best for them. And they had clear reasons for their preferences, e.g., I think I remember one poster saying that for him absolute path in vault resulted in very noisy link names.

When I guessed on the Obsidian forum that my problem might be a result of a mismatch between the URLs and URL schemes used by Obsidian and vim/wiki.vim one of the guys whose also been trying to help me asked what URL wiki.vim uses.

Of course I have no idea, but I'm guessing that it's the same one obsidian uses. But if so then why don't they read each others' links?

lervag commented 1 year ago

First, it is based on Markdown and uses the standard Markdown link for external links. Thus, when you write [text](url) the url part should typically be an external link such as http://example.com or file://path/to/file or obsidian://open?vault=MainVault&file=Note.md or similar.

At present I don't have any external links. When I access an Obsidian file with internal links in vim the link would still be an internal link, wouldn't it?

Yes, I should probably have written "external url", not "external link". Here internal was intended to mean link between your Obsidian/wiki files, whereas external points to links outside Obsidian/wiki.

And I don't believe it will read markdown links created with vim/wiki.vim. At least it wouldn't when I imported the first batch of notes created with vim/wiki.vim.

The links should be interoperable. Can you show examples of the same link created with wiki.vim and Obsidian? I believe you could adjust some wiki.vim setting to create link urls that should work in Obsidian.

Yes; but I don't quite understand this. Which value are you currently using?

Currently I have relative path to file. But I have no idea what difference the different settings make. Posters on that Reddit thread I referred to you had strong opinions about which setting was best for them. And they had clear reasons for their preferences, e.g., I think I remember one poster saying that for him absolute path in vault resulted in very noisy link names.

Ok; I think this setting should be compatible with wiki.vim.

When I guessed on the Obsidian forum that my problem might be a result of a mismatch between the URLs and URL schemes used by Obsidian and vim/wiki.vim one of the guys whose also been trying to help me asked what URL wiki.vim uses.

Of course I have no idea, but I'm guessing that it's the same one obsidian uses. But if so then why don't they read each others' links?

No, I think this may be the main problem here. If you create the same link in wiki.vim and in Obsidian, as mentioned above, you should see the difference in how the URL is formatted.

lervag commented 1 year ago

You shared it with me in an email, I'll copy it here:

Obsidian:
[Dependence with objectivity](Dependence%20with%20objectivity.md)

vim.wiki:
[Dependence with objectivity](Dependence with objectivity.md)

We see that Obsidian applies URL encoding of the URL, whereas vim.wiki does not. Thus, if you applied url encoding from wiki.vim, I believe you would have links that would work in Obsidian.

As a first step, you could use something like this to encode the space character:

let g:wiki_map_text_to_link = 'MyTextToLink'

function MyTextToLink(text) abort
  return [substitute(a:text, '\s', '%20', 'g'), a:text]
endfunction
EricEWeir commented 1 year ago

Thanks. I’ll check it out. Not today. I don’t need to to use it but I wish I could read stuff like this. Is it vim script? (This is simply a wish, NOT a request for help.)

lervag commented 1 year ago

Yes, that is vimscript. You could add it at the same place as where you add your other wiki.vim configuration.

lervag commented 1 year ago

By the way, I don't know what else to do here, so I hope you don't mind if I close the issue. Feel free to continue the discussion, of course. :)

EricEWeir commented 1 year ago

I've checked out the code you suggested for create links that are active, i.e., that open the files linked to. This is the result I got:

Created with vim/wiki.vim. Opens new file with URL as name. Has no effect in Obsidian. [[meaning%20necessitates|meaning necessitates]]

Here's the wiki.vim configuration from my .vimrc:

let g:wiki_root = '~/Library/Mobile\ Documents/iCloud~md~obsidian/Documents/ZK/'
let g:wiki_filetypes = ['md', 'wiki']
let g:wiki_link_extension = ''
let g:wiki_link_target_type = 'wiki'
let g:wiki_map_text_to_link = 'MyTextToLink'
function MyTextToLink(text) abort
  return [substitute(a:text, '\s', '%20', 'g'), a:text]
endfunction
let g:wiki_write_on_nav = 1

FYI, this is what I got creating a link in Obsidian with Obsidian set to generate markdown links:

Created with Obsidian. Has no effect in Obsidian. With vim/wiki.vim opens new file with URL as name. [Meaning necessitates](Meaning%20necessitates.md)

I'm going to leave all this alone for a while. Perhaps for the duration of my stay in Texas. So no urgency in responding. When you do respond though I will respond.

lervag commented 1 year ago

Created with vim/wiki.vim. Opens new file with URL as name. Has no effect in Obsidian. [[meaning%20necessitates|meaning necessitates]]

Ok; for this particular functionality, you would want to use Markdown as the default link types. I.e., you want this config (I'm only listing the settings I'm changing from those you posted):

let g:wiki_link_extension = '.md'
let g:wiki_link_target_type = 'md'

After making this change, creating links with wiki.vim should create links like [meaning necessitates](meaning%20necessitates.md). However, there will probably be an issue with opening these links, because we also need a converter that decodes the URL encoding. I believe something like this could work:

let g:wiki_resolver = 'MyLinkResolver'
function MyLinkResolver(fname, origin) abort
  let l:fname_decoded = substitute(a:fname, '%20', ' ', 'g')
  return wiki#url#wiki#resolver(l:fname_decoded, a:origin)
endfunction

I'm going to leave all this alone for a while. Perhaps for the duration of my stay in Texas. So no urgency in responding. When you do respond though I will respond.

I have to admit it's a little bit hard to help here, as I don't know Obsidian and I have no interest in learning it. But I hope my answers so far is at least somewhat helpful.