michal-h21 / vim-zettel

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

Add zettel ID to YAML header #66

Closed johangustafsson closed 4 years ago

johangustafsson commented 4 years ago

I wish there was a way to automatically add the zettel ID to the YAML header. Using %date need not yield the same result.

michal-h21 commented 4 years ago

Good idea! I have added support for functions in the front_matter option. It can be used in this way:


  function! s:insert_id()
    if exists("g:zettel_current_id")
      return g:zettel_current_id
    else
      return "unnamed"
    endif
  endfunction

  let g:zettel_options = [{"front_matter" : 
    [["tags" , ":hello:"],
    [ "id" , function("s:insert_id")]]
  }]
johangustafsson commented 4 years ago

Thanks! It works.