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

File creation based on parent folder #54

Closed
hongyuanjia opened this issue Feb 5, 2020 · 5 comments
Closed

File creation based on parent folder #54

hongyuanjia opened this issue Feb 5, 2020 · 5 comments

Comments

@hongyuanjia
Copy link

hongyuanjia commented Feb 5, 2020

I am trying to learn how to use wiki.vim. Basically I want to create one folder per project and put all project-notes in its corresponding folder. But it seems like wiki.vim does not expect the folder of current wiki but create all wikis inside g:wiki_root folder.

Here is my wiki.vim settings:

let g:wiki_filetypes = ['md']
let g:wiki_link_extenstion = '.md'
let g:wiki_link_target_type = 'md'

Here is my example index.md:

1. [work](work)
2. [personal](personal)

Here is an example of work.md:

1. [project1](project1)
2. [project2](work/project2)

Right now, in work.md:

  1. If I follow the project1 link, project1.md will be created in the g:wiki_root folder
  2. If I follow the project2 link, project2.md will be created in the g:wiki_root/work folder

How can I specify relative path to current note when creating new files?

Here is another example: in both project1.md and project2.md:

# Meetings

1. [2020-02-05](2020-02-05)

This link will link to the same file under g:wiki_root/2020-02-05.md

Is there any way to make wiki.vim respect the folder of current wiki when creating new files? Otherwise I have to make sure to include the parent folder each time when I create a new link.

By the way, could you share some insights what is the better way to arrange notes for different projects? Do you put all of them inside the wiki root folder or create a folder to store notes for each projects?

Thanks!

@lervag
Copy link
Owner

lervag commented Feb 9, 2020

Here is my wiki.vim settings:

Did you forget the g:wiki_root setting? I assume it is also defined?

Here is my example index.md ... work.md.

Do I understand correctly that the files you are referring to are placed like this?

.
├── index.md
└── work.md
├── work
│   ├── project1.md
│   └── project2.md

That is, you are not describing issues with using two separate wiki's, but rather with how links work within a single wiki with multiple folder levels. I that right?

How can I specify relative path to current note when creating new files?

Links are generally relative to the path of the current file. So, from project1.md, a link like [project2](project2) should work as expected. But from work.md, links to files inside the work folder needs the work/ prefix.

Is there any way to make wiki.vim respect the folder of current wiki when creating new files? Otherwise I have to make sure to include the parent folder each time when I create a new link.

I think this is how it is supposed to work already, and it seems to work like that for me.

By the way, could you share some insights what is the better way to arrange notes for different projects? Do you put all of them inside the wiki root folder or create a folder to store notes for each projects?

Good question. I keep a rather flat structure, but I do agree that it makes sense to keep project specific notes within a project folder. The main drawback is that information may be related to more than a single project or topic. That is, you might end up writing redundant/duplicate notes. But if you are good at organizing this well, I think you could avoid issues like this.

@hongyuanjia
Copy link
Author

Thanks for your explanation!

Did you forget the g:wiki_root setting? I assume it is also defined?

Sorry I forgot to put the g:wiki_root setting here. Yes, it is defined correctly.

Do I understand correctly that the files you are referring to are placed like this?

.
├── index.md
└── work.md
├── work
│   ├── project1.md
│   └── project2.md

That is, you are not describing issues with using two separate wiki's, but rather with how links work within a single wiki with multiple folder levels. I that right?

Exactly. This structure is what I want to achieve.

I think this is how it is supposed to work already, and it seems to work like that for me.
Links are generally relative to the path of the current file. So, from project1.md, a link like project2 should work as expected. But from work.md, links to files inside the work folder needs the work/ prefix.

That's right. So if I understand it right, all new notes will be created inside the same folder of current note. Previously I was also trying to find a way to create new notes inside the folder with the same name as its parent folder, e.g.:

.
├───index.md
│
└───work
    ├───work.md
    │
    ├───project1
    │   ├───project1.md
    │   │
    │   ├───materials
    │   └───meetings
    └───project2
        ├───project2.md
        │
        ├───materials
        └───meetings

Probably this has to be achieved by adding folder prefix. This may also be out of scope of a wiki plugin.

Good question. I keep a rather flat structure, but I do agree that it makes sense to keep project specific notes within a project folder. The main drawback is that information may be related to more than a single project or topic. That is, you might end up writing redundant/duplicate notes. But if you are good at organizing this well, I think you could avoid issues like this.

I agree that a project-centric structure does need taking more care on organizing things, but that may pay off in the long run.

Thanks for this awesome plugin!

@lervag
Copy link
Owner

lervag commented Feb 10, 2020

Exactly. This structure is what I want to achieve.

Good, then I understand correctly.

Ok, so: Links are by default relative to the current file. However, you can root them to the wiki root by prepending /. I think this works as expected, at least it does for me. If you should find that it does not work like this, then I think we have a bug.

In this updated example:

.
├───index.md
│
└───work
    ├───work.md
    │
    ├───project1
    │   ├───project1.md
    │   │
    │   ├───materials
    │   └───meetings
    │
    └───project2
        ├───project2.md
        │
        ├───materials
        └───meetings

Here you would use a link like [](work/work) inside your index.md. Inside work.md, you would use a link like [](project1/project1) or [](project2/project2). From project1.md, you could link back to work.md with [](../work.md) or [](/work/work.md).

However, note that the link syntax [](work/) will expand to [](work/index).

Probably this has to be achieved by adding folder prefix. This may also be out of scope of a wiki plugin.

I am not quite sure what you mean here. Are you saying that the links are somehow not working as I am explaining? If so, then I think it may be a bug and I'll be happy to try and fix it.

Thanks for this awesome plugin!

You're welcome, I'm happy you like it! I find it very useful for my own workflow, and it makes me happy to hear that it is useful to others as well.

@hongyuanjia
Copy link
Author

Here you would use a link like [](work/work) inside your index.md. Inside work.md, you would use a link like [](project1/project1) or [](project2/project2). From project1.md, you could link back to work.md with [](../work.md) or [](/work/work.md).

Thank you for this hint! Right now it works 100% as I want.

Since this issue seems more like questions on usage instead of actual bugs, I will close it now.

Thanks for you help.

@lervag
Copy link
Owner

lervag commented Feb 11, 2020

Thank you for this hint! Right now it works 100% as I want.

Great, happy to hear it! :)

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

No branches or pull requests

2 participants