michal-h21 / vim-zettel

VimWiki addon for managing notes according to Zettelkasten method
MIT License
555 stars 72 forks source link

No File extension when new zettel is created from outside a Wiki #141

Open uwolf opened 7 months ago

uwolf commented 7 months ago

When ZettelNew is called from outside a wiki, the note file is created without a file extension, at least in my very basic setup:

let g:vimwiki_list = [{'path': '~/vimwiki/',  'syntax': 'markdown', 'ext': 'md'}]
let g:vimwiki_global_ext = 0
let g:zettel_options = [ {"rel_path" : "zettel/" } ]

I don't know much about vimscript, so no pull request, but for a quick fix, I added the file extension from the wiki config in autoload/zettel/vimwiki.vim in function zettel#vimwiki#create

567     let zettelpath = zettel#vimwiki#path(a:wiki_nr)
568     " add extension 
569     let ext = vimwiki#vars#get_wikilocal('ext', vimwiki#vars#get_bufferlocal('wiki_nr'))
570     execute(':e ' . zettelpath . format . ext)
michal-h21 commented 7 months ago

Thanks for the report and for the proposed fix. It seems to work. I've modified it a bit, as the wiki_nr should be passed to zettel#vimwiki#create as a parameter.

uwolf commented 7 months ago

Thanks you. There is still an Issue with ZettelGenerateLinks though. It generates Links to the main wiki dir, not the rel_path. So whenever i click those links, it opens empty files, not the notes. But did not have the time to dig deeper into the code yet. I think this plugin is much more usefull, when ZettelNew can be called whereever you are.

michal-h21 commented 7 months ago

Relative paths are painful in general. The support for them is a work in progress.