Closed lambtho12 closed 2 years ago
Hi, great work you've done over there! I especially like that you implemented action mappings! This is something I haven't gotten into yet, but it is probably very useful!!! :+1: :+1: :+1:
I am thinking about supporting your style of links. Image links in telekasten are treated in a way that preserves subdirectories, which is simply done by removing the main path.
Personally, I am not sure whether I find [[daily/2021-11-30]] rather verbose. So, for daily and weekly subdirectories: notes in there will always be found.
I just tried the following:
$ cd zettelkasten
$ mkdir testdir
$ echo found > testdir/testnote.md
Then I manually created the link [[testdir/testnote]]
- and telekasten found it.
So, for the moment, you can use it like that. If you try to follow [[testnote]]
without the path, telekasten will create it in the root directory, though.
So, what do you think of this: for all non-daily/weekly sub-directories, telekasten will always insert relative links containing sub-directories.
That should do the trick. Customizable link formats could be done, too. At the moment, it is just searched for what is between the []
brackets. So if you [link that way](this will be ignored)
, and the title matches the filename, it should work. Because of the involved complexity, proper markdown links are towards the end of my todo list :smile: .
Done!
Inserted links will keep the sub-directory component(s) if they are not pointing to daily or weekly notes :smile:
Hope that helps!
I just checked with your code: there is a major difference between our implemented concepts of 'relative path': your code always creates links relative to the current note.
Telekasten has no concept of the current note. So if you link from one note within testdir/
to another note other.md
within testdir/
, you would just place a [[other]]
, whereas telekasten would place it like this: [[testdir/other]]
.
I, personally, prefer the current telekasten way: therefore you can copy a link as text and paste it into any other note and it will always work.
Can you live with that?
I only use my ZK from neovim, so as long as the note opens without issue when using follow_link()
, I do not have a major issue with that.
However, maybe that could be a problem for people using something to render their markdown notes as a webpage (using neuron for instance). Not sure about that.
Thank you very much for the (very) quick reply and solution to this issue!
Thx for the quick reply!
I also thought about other tools. My go-to reference for compatibility is Obsidian. It works with links the way telekasten produces now. In Obsidian, sub-dirs are optional, so it still works.
Regarding static-site generators and such: I would think that they should be happy with being provided non-ambiguous (context-free) path information. I would hope that they support subdir-including links for links pointing to the same subdir. If not, I, personally, would consider link substitution as a part of the generation step and pre-process the notes to strip off un-necessary subdirs.
Maybe I can implement a feature that goes through all notes and does the stripping... At one's own risk.
Thx for the pointer, I'll definitely check out neuron! If it supports some config option that helps it deal with un-stripped subdir-containing links, I'll better document it somewhere in the readme.
Update: just checked out neuron. What a beast! :smile: . The way I understand it, is that neuron at least does not require to specify subdirs in links. No idea what it does when it encounters them.
Given that your subdir style of working and linking is a very sane option, I suggest waiting until an issue with subdir-containing links comes up.
I would think that they should be happy with being provided non-ambiguous (context-free) path information.
True, it may be much simpler for them to do so.
I'll definitely check out neuron
I think neuron is being deprecated in favor of emanote. I never tested it but apparently it works with polymorphic (in filetype, and path signifier) wiki-links: [[Foo]], [[Bar/Qux]], [[Examples/Program.py]]
I suggest waiting until an issue with subdir-containing links comes up.
Agree with you on that. I tested 35f4e6342f6d73d179c5af0b741b643b312e7458 and it seems to be everything that I wished for :smile:
Thanks again!
Welcome! :blush:
I think the latest commit (1bd06e5d3642970f7cde3c2edb01631603c0b67e) has just broken this feature.. :D
UPDATE: I get this error with any link. Simple filename as well as subdir/filename. Opened a separate issue for that (https://github.com/renerocksai/telekasten.nvim/issues/15)
When I try to follow_link(), I get
E5108: Error executing lua ...ite/pack/packer/start/telekasten.nvim/lua/telekasten.lua:490: attempt to get length of local 'filename' (a nil value)
stack traceback:
...ite/pack/packer/start/telekasten.nvim/lua/telekasten.lua:490: in function 'follow_link'
[string ":lua"]:1: in main chunk
Press ENTER or type command to continue
Hi, thank you for this great plugin!
I have a rather large zettelkasten with one level of subirectories (I know, it is not the standard approach to ZK). I have an issue when I paste a link, as only the filename is pasted. Therefore I can not follow-through the link. Would it be possible to have some modifiers when pasting a link that allow to paste a relative path instead?
Before stumbling on your really feature-rich extension, I made my own very simplistic telescope plugin. I made it so the link could be formatted in different ways upon paste to circumvent this issue (maybe there could even be an option to always paste links a certain way).