Skip to content
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

open relative links to root #17

Closed
olesendan opened this issue Mar 7, 2022 · 5 comments
Closed

open relative links to root #17

olesendan opened this issue Mar 7, 2022 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@olesendan
Copy link

olesendan commented Mar 7, 2022

Hi Jake.

I've been thinking if it makes sence to enhance the function 'open-relative_to'. In my workflow, I create links to documents in my 'wiki' in two ways. Either a sub link from my document, or a link from another domain(which is in other sub filer/directories from the wiki root folder. These two a used random in my wiki pages.

I suggest that instead of setting the option in config 'open_relative_to', then use some logic to define if the link is relative to the document or relative to root of the wiki.
From my thinking there should be a function which defines root, based on content i a paraent folder( should search up in the directory tree untill it finds a folder with the defined content.) the content could be defined in config ex. 'root_dir_content = {'.git', '.root', '.wiki_root'}

then the open file function could choose who to open relative files from this logic.

[relative sub file]('relative/sub-file.Rmd')
[relative root file]('~/relative/root-file.Rmd')

From my thinking this should not interfer with how we implemented files from outside the wiki, because we prefix with 'file:'

What do you think?

Greetings from denmark.
Dan Olesen

@jakewvincent jakewvincent added the enhancement New feature or request label Apr 1, 2022
@jakewvincent
Copy link
Owner

Hi Dan--I know it's been a while since you proposed this but I think this would improve the plugin, and I hope to implement it very soon.

@jakewvincent jakewvincent self-assigned this Apr 22, 2022
@jakewvincent
Copy link
Owner

@olesendan I've pushed an implementation of this to the dev branch, if you want to give it a try. The dev readme is updated (see https://github.com/jakewvincent/mkdnflow.nvim/tree/dev), so you can see the sample config there. The links_relative_to key in the config table now requires a table itself, where you can specify which perspective you want the plugin-to take (e.g. relative to root, relative to current file, etc.). Setup will look for a key in the links_relative_to table called root_tell which should be a string that represents the "tell" of the root directory, or in other words, a file that the plugin can use to identify which directory is the root. If you happen to try it out, let me know if there are any issues or things that you think should be changed.

@jakewvincent
Copy link
Owner

(Just pushed this to main. Please let me know if you experience any issues with the new functionality!)

@olesendan
Copy link
Author

Hi JAke.

Sorry for my late reply. I will do some testing in the next cuple of days. If I encounter any problems, I will raise a new issue.

Greetings from denmark
Dan Olesen

@jakewvincent
Copy link
Owner

Sounds good, thanks Dan! :)

By the way, after implementing this, I realized that your suggestion was to be able to specify multiple files that together could identify the root directory. That wouldn't be too crazy to implement, but currently only one file can be provided as the "tell", just FYI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants