Open cpkio opened 2 years ago
It can create notes only in the root directory of the current wiki, but multiple wikis should work.
If I configured it right (my config above), it should create new notes in root of ~/zettel
, but it always creates notes in current directory anyway. I'm on Windows if this matters.
Ah, that's weird. And normal Vimwiki commands create notes correctly? Try to visually select some words and press enter. This should create a normal Vimwiki note named after the selected text in the current wiki dir. If even this doesn't work, then it may be a possible issue with your configuration. I don't know much about configuring Neovim using Lua, so I cannot tell what can be the problem.
And normal Vimwiki commands create notes correctly?
Yes, Vimwiki in Neovim works fine, been using it for a year already. It creates notes on enter, saves them in correct places etc.
I am having a similar (same?) problem with Vim 9.0 (Debian testing), Vimwiki (dev branch) and vim-zettel.
When I use :ZettelNew or I capture a string, the new note is always created on the current directory, no matter if it is outside my wiki.
I have a single wiki configuration:
let g:vimwiki_ext2syntax = {}
let g:vimwiki_list = [{
\'path': '~/syncthing/vimwiki/',
\'syntax': 'markdown',
\'ext': '.md',
\'links_space_char': '_',
\'auto_tags': 1,
\'auto_toc': 1,
\'auto_diary_index': 1
\}]
let g:vimwiki_global_ext = 0
let g:vimwiki_dir_link = 'index'
let g:vimwiki_auto_chdir = 1
let g:zettel_format = "%Y-%m-%dT%H%M%S-%title"
let g:zettel_options = [ { "front_matter": [["tags", ""]] }, {} ]
After playing around with the code, notes are created in the vimwiki/zettel path when I comment/uncomment these lines in the function zettel#vimwiki#create(...)
in the file autoload/zettel/vimwiki.vim
:
" the following command doesn't work correctly with the vimwiki navigation
call vimwiki#base#open_link(':e ', format, s:vimwiki_dir.path) " add third argument
" call vimwiki#base#open_link(':e ', "./". format, )
" add basic template to the new file
I do not use most of the Vimwiki features, so I do not totally understand the consequences of this change (beyond it kind of fix this issue)
@juanlufont thanks for the pointer. You are right, it is necessary to pass the full path to vimwiki#base#open_link
, otherwise capturing from outside of the wiki directory will not work. It has a downside in that it will break Vimwiki navigational commands, so when you create a new note using the z
key from visual selection, you cannot get back to the previous page using backspace.
My solution is to detect if the current file is in wiki, and select the opening method accordingly. This should support the navigation when you create notes from the wiki.
init.lua
zettel.vim