michal-h21 / vim-zettel

VimWiki addon for managing notes according to Zettelkasten method
MIT License
557 stars 74 forks source link

ZettelNew not using template file when not created from a word #33

Open Laptop765 opened 4 years ago

Laptop765 commented 4 years ago

ZettelNew does not use the template file when not created from an existing word/page (i.e. there is no backlink.)

Looks like that's a known issue based on a comment in autoload/zettel/vimwiki.vim in function! zettel#vimwiki#zettel_new(...):

variables are available only when this function is called from zettel_new_selected

...
let template = zettel#vimwiki#get_option("template")
if !empty(template)
  let variables = get(a:, 2, 0)
  if !empty(variables) " HERE is the check that fails
    call zettel#vimwiki#expand_template(template, variables)
  endif
endif
...

Originally posted by @Laptop765 in https://github.com/michal-h21/vim-zettel/issues/27#issuecomment-599830471

Laptop765 commented 4 years ago

@michal-h21 I'd be happy to take a look at fixing this if you know what you want the behavior to be!

Locally I have a change to use the template and just leave placeholders that haven't been filled (e.g. backlinks) as-is.

michal-h21 commented 4 years ago

@Laptop765 sorry for the late reply, I was bit overwhelmed by various issues in the past months. Template should be now used also for :ZettelNew command.