From b33d4bea7f3f23a845d961a1652640e37371a2e1 Mon Sep 17 00:00:00 2001 From: dogeystamp Date: Thu, 6 Jul 2023 20:03:31 -0400 Subject: [PATCH] nvim: extra typst stuff for lectures --- src/.config/nvim/typst.vim | 8 ++++++++ src/.config/nvim/ultisnips/typst.snippets | 18 +++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/.config/nvim/typst.vim b/src/.config/nvim/typst.vim index b412955..4232848 100644 --- a/src/.config/nvim/typst.vim +++ b/src/.config/nvim/typst.vim @@ -3,6 +3,7 @@ Plug 'kaarmu/typst.vim' " edit figure in Inkscape function EditFig() + " expands filename under cursor let figure_fname = expand('') exec "silent !typst-figure " .. figure_fname vsp @@ -12,6 +13,13 @@ endfunc nnoremap ff :call EditFig() +" imports latest screenshot into a figure +function ScreenshotFig() + call system("mkdir -p " . expand(":h")) + call system("ffmpeg -y -i ~/med/screen/latest.png " . expand("")) +endf +nnoremap fs :call ScreenshotFig() + " compile typst doc on write function TypstWatch() vsp diff --git a/src/.config/nvim/ultisnips/typst.snippets b/src/.config/nvim/ultisnips/typst.snippets index 56855ff..72c7e1a 100644 --- a/src/.config/nvim/ultisnips/typst.snippets +++ b/src/.config/nvim/ultisnips/typst.snippets @@ -1,5 +1,5 @@ snippet problem "template for problem notes" bi -#import "../templates/problems.typ": template, source_code, status +#import "../templates/sfd.typ": template #show: template.with( problem_url: "$1", title: "$2", @@ -8,6 +8,15 @@ snippet problem "template for problem notes" bi endsnippet +snippet sfd "template for lecture notes" bi +#import "../../templates/problems.typ": template, source_code, status +#show: template.with( + lecture_url: "$1", + title: "$2", +) + +endsnippet + snippet contest "template for contest problems" bi #import "../../templates/contest.typ": template, source_code, status #show: template.with( @@ -61,3 +70,10 @@ snippet fig "create new figure" bi caption: [$2], ) <$1> endsnippet + +snippet figp "create new image figure" bi +#figure( + image("fig/`!v expand("%:r")`/$1.jpg"), + caption: [$2], +) <$1> +endsnippet