artempyanykh / marksman

Write Markdown with code assist and intelligence in the comfort of your favourite editor.
MIT License
1.98k stars 35 forks source link

Relative Markdown Link Completion #182

Open fingolfin19 opened 1 year ago

fingolfin19 commented 1 year ago

Follow up to https://github.com/artempyanykh/marksman/issues/27#issuecomment-1369911689 since I do not see that a new issue was ever created.

When i start typing [title]( then absolute paths are suggested like /path-to-file.md this works fine. Also autocompletion works, when using # afterwards - like [title](/path-to-file.md# - to get a link to a header.

For relative paths both of this does not work. When typing [title](./ nothing further is being suggested by marksman. After finishing the path to an existing file and starting to type a header - like [title](./path-to-file.md# - no completions are suggested.

artempyanykh commented 1 year ago

Thanks for filing this issue @fingolfin19! I definitely got lost in #27

artempyanykh commented 1 year ago

To leave some relevant context here:

  1. Resolving links works both with absolute and with relative paths.
  2. We can make completion follow the user's style, e.g. if the user starts entering a relative path we can suggest completions that would also be relative paths.
gustavokrieger commented 1 year ago

Hey @artempyanykh. I've been trying to stick to relative paths for compatibility with jetbrains tools' markdown preview. Is there support for relative completion today?

serranomorante commented 1 year ago

~Hi! I think it is not supported yet~

image

I correct, Link to non-existent document warning doesn't appear if I also open those 2 files in a buffer. I don't know if this is the intended behaviour for links to work only on opened buffers.

artempyanykh commented 1 year ago

@serranomorante not really. Although, it depends on how your project folder is organized. Is your root folder under version control? If not could you git init inside the root folder and try this again?

artempyanykh commented 1 year ago

Hi @gustavopcassol ! Unfortunately, too much life in the way of open source -- I didn't have time to implement this. It's still on the todo list, though. Also, PRs are welcome :)

serranomorante commented 1 year ago

@serranomorante not really. Although, it depends on how your project folder is organized. Is your root folder under version control? If not could you git init inside the root folder and try this again?

I will check on this, thank you for your response!

serranomorante commented 1 year ago

I'm so sorry for having branch-off the main point here. My project folder indeed was in version control but I had a very "special" .gitignore file and I just read that marksman behaves like git in that sense. The solution was adding a .ignore file as recommended here and that solved all of those warnings about relative links.

Thank you!

artempyanykh commented 1 year ago

@serranomorante happy to hear the problem is resolved!

jhrv commented 7 months ago

Using mkdocs it's recommended using relative links, so having completion with a list of suggestions relative to the current file when you press "dot" after the start parenthesis would be fantastic.