mirror of
https://github.com/jdhao/nvim-config.git
synced 2025-06-08 14:14:33 +02:00
Update meta markdown snippets
The original snippet use vim interpolation and the date keeps changing while we are inside the snippet region, which is not desired. According to https://www.youtube.com/watch?v=JJQYwt6Diro, we can use Python interpolation and check if snip.c is empty to see if the interpolation has been finished. If the interpolation has finished (snip.c is empty in this condition), the date will be fixed and does not change when we are inside the snippet region.
This commit is contained in:
parent
37498210ba
commit
3fdf189471
@ -18,7 +18,9 @@ endsnippet
|
||||
snippet "meta(data)?" "Markdown metadata front matter" br
|
||||
---
|
||||
title: "$1"
|
||||
date: `!v strftime("%Y-%m-%d %H:%M:%S%z")`
|
||||
date: `!p from datetime import datetime
|
||||
if not snip.c:
|
||||
snip.rv=datetime.now().strftime("%Y-%m-%d %H:%M:%S%z")`
|
||||
tags: [$2]
|
||||
categories: [$3]
|
||||
---
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user