-
Notifications
You must be signed in to change notification settings - Fork 69
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
wiki:index is linking me to the index of the directory (journal) and not index of the wiki #160
Comments
Hi, Anshul 👋🏻
Yes, actually it is. I'll try to explain why. The anatomy of an url is, basically, I believe the confusion is caused by the fact that the wiki links are by default relative to the current file. So, Obviously, it would be possible to instead make the link targets relative to the wiki root. But, in that case, directory structures becomes much more "entangled". That is, say you have a subdirectory in your wiki, sort of a subwiki. By using relative paths, you could essentially move that subdirectory out of your main wiki, and all interwiki links within the subwiki will still just work. But it would not work if the links are relative to the wiki root, since we changed the wiki root when moving the subwiki out. This is also why I've implemented the syntax I hope this makes sense. If you feel strongly about this, then I'm not opposed to discussing what is the best solution. Also, you should note that it is possible to customize the behaviour. In fact, you can change the entire wiki link resolver, see wiki.vim/autoload/wiki/url/wiki.vim Lines 30 to 61 in 4d8e037
|
Thank you Karl for explanation.
It does make sense. I am going to stick to the default behaviour. Because I do plan to have subwikis for different fields. |
Great! Feel free to open new issues/questions/requests :) |
Hi Karl @lervag I was looking for a feature where when I open a new journal entry, it should have the date as the first line of the file. function file_exists(name)
local f=io.open(name,"r")
if f~=nil then io.close(f) return true else return false end
end
local api = vim.api
local M = {}
function M.currentEntry()
-- set the filename based on the current date
local filepath = vim.g['wiki_root']..'journal/'..os.date('%Y-%m-%d')..'.md'
-- if the file doesn't exist
-- then created file and write date to the top of the file
if not file_exists(filepath) then
file = io.open(filepath, 'a')
io.output(file)
io.write(os.date("# %a, %d %B '%y"))
io.close(file)
end
api.nvim_command('edit '..filepath)
end
return M What do you think? Have other people also mention interest in such a thing for your wiki plugin? If yes, I would love to contribute. |
Hi! (Are you the same Anshul as the OP?) Are you aware of #83? I'm currently working on exactly this feature. There's no code yet, but I've made a specification that I think I'm happy with. Feel free to comment on it. Please note, I (still) want to keep wiki.vim "Vim agnostic", i.e. compatible with both neovim and Vim. So I don't want lua code within the repo. Yet - I might change my mind in the future. But I would not mind making the user customization flexible enough for you to use Lua for the template feature. |
Yes, using my work account right now.
I was not, that looks exactly like what I wanted, this is great
Yeah, understandable. I have been scared of VimL so when I saw that I could use Lua in nvim v0.5, I just wrote the script. I'll go through the #83 and see if I can add value. |
Great! :) |
Description
Hi Karl 👋
wiki:index
is linking me to the index of the directory (journal) and not index of the wiki. Is this the expected behavior.wiki:index
from my~/wiki/journal/2021-06-10.md
file would take me to~/wiki/index.md
~/wiki/jounral/index.md
instead3.1 Open Vim,
<leader>ww
to go to wiki index3.2 Open today's journal,
<leader>w<leader>w
3.3 Write in the file
wiki:index
3.4 In normal mode,
<cr>
onwiki:index
my wiki directory currently looks like this
my vimrc settings
Screen.Recording.2021-06-10.at.1.44.59.PM.mov
PS
I was able to link to the root
index.md
file using[[/index.md|index]]
link.The text was updated successfully, but these errors were encountered: