Skip to content
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

Front Matter not included in YAML #117

Closed
sebastianbock17 opened this issue Dec 12, 2021 · 5 comments
Closed

Front Matter not included in YAML #117

sebastianbock17 opened this issue Dec 12, 2021 · 5 comments

Comments

@sebastianbock17
Copy link

sebastianbock17 commented Dec 12, 2021

when I include front matter options, such as:

let g:zettel_options = [{"front_matter" : [["tags", ""], ["citation", ""]]}]

the result is just:

tags:
citation:
---
title: test2
date: 2021-12-12 14:40

How is it possible, to have tags and citation in the YAML?

My current solution is editing directly the vimwiki.vim

" title and date to a new zettel note
function! zettel#vimwiki#template(title, date)
  if g:zettel_disable_front_matter == 0
    call <sid>add_line(s:header_delimiter)
    call <sid>add_to_header("citation", "")
    call <sid>add_to_header("tags", "")
    call <sid>add_to_header("date", a:date)
    call <sid>add_to_header("title", a:title)
    call <sid>add_line(s:header_delimiter)
  endif
endfunction

I simply added 'call add_to_header("tags", "")' as the first option, resulting in:

---
title: test5
date: 2021-12-12 14:49
tags:
citation:
---

This is my current solution. Is there perhaps a better way of solving it in the plugin?
Hope it might be helpful for others

@heitorPB
Copy link

heitorPB commented Jan 7, 2022

This is what I have in my .vimrc:

let front_matter = {}
let front_matter.front_matter = {}
let front_matter.front_matter.keywords = []
let front_matter.front_matter.draft = "false"
let g:zettel_options = [front_matter]

this results in:

---
title: Example note
date: 2022-01-07 10:30
draft: false
keywords: []
---

@sebastianbock17
Copy link
Author

sebastianbock17 commented Jan 9, 2022

With your above example, I still get the following:

draft: false
keywords: []
---
title: test5
date: 2022-01-09 22:00
---

… while your above lines were the only configuration options included in my vimrc referring to vim-zettel, I have no idea what I'm doing wrong

Now I followed the advice by mihal, simply enabling the template and disabling the front matter, which gives me finally the result I was hoping for:

let g:zettel_options = [{"template" :  "~/scratchbox/vimwiki/mdtemplate.tpl", "disable_front_matter": 1}]

Originally posted by @michal-h21 in #67 (comment)

This way I can finally solely use the template that I can change ad hoc and customizable - which leads me to the next question - how to include the current ID , like %id ..., instead of %date (as %id is not defined) …

@heitorPB
Copy link

heitorPB commented Jan 9, 2022

Do you have any other modification to vimwiki/vimzettel? Did you remove/revert your modification to vimwiki.vim?

@sebastianbock17
Copy link
Author

Yes, I have reverted / removed all my modifications (which were only the ones mentioned above) from vimwiki.vim, and still have the same issue - I had it from beginning on, retried with empty vimrcs several times, but at least now the old suggestion from @michal-h21 is working fine for me, which is the easiest and most flexible way in my opinion - to keep a template file at shorthand, editable if necessary to my likings with direct result. :)

I hope no other users deal with the same troubles - I dont know exactly why, but I have the opinion that my vimrc behaves illogical at times, as I am still a rookie in grasping how to work with it.

Nonetheless, many thanks to your efforts and support @heitorPB it is much appreciated, as I had almost given up with this issue and coincidentally still found the solution :)

@heitorPB
Copy link

It puzzles me that the same configuration gives a different output for us...

But I'm glad you managed to get it working somehow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants