From 3a007886fe248bedc5e189f5fb933379fdc72d12 Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Thu, 25 Jul 2024 01:31:34 +0200 Subject: Refactor workflow snippets --- fnl/plugins/snippets/init.fnl | 6 ++++-- fnl/plugins/snippets/org.fnl | 34 +------------------------------ fnl/plugins/snippets/workflow.fnl | 42 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 35 deletions(-) create mode 100644 fnl/plugins/snippets/workflow.fnl (limited to 'fnl/plugins') diff --git a/fnl/plugins/snippets/init.fnl b/fnl/plugins/snippets/init.fnl index b586d76..016b3b6 100644 --- a/fnl/plugins/snippets/init.fnl +++ b/fnl/plugins/snippets/init.fnl @@ -3,8 +3,10 @@ (local dependencies [:rafamadriz/friendly-snippets]) (fn add-snippets [] - (let [org (require :plugins.snippets.org)] - (org.add-snippets))) + (let [org (require :plugins.snippets.org) + workflow (require :plugins.snippets.workflow)] + (org.add-snippets) + (workflow.add-snippets))) (fn config [] (let [ls (require :luasnip) diff --git a/fnl/plugins/snippets/org.fnl b/fnl/plugins/snippets/org.fnl index 0887821..a2b2e46 100644 --- a/fnl/plugins/snippets/org.fnl +++ b/fnl/plugins/snippets/org.fnl @@ -8,38 +8,6 @@ fmt fmt.fmt] (ls.add_snippets :org [(s :be - (fmt "#+begin_src {}\n{}\n#+end_src" [(i 1) (i 2)])) - (s :wf - (fmt "workflow \"{}\" = - input: {} - output (on success): - {} - output (on error): - {} - - // step {} - do {} - {} - " - [(i 1) (i 2) (i 3) (i 4) (i 5) (i 6) (i 7)])) - (s :st - (fmt " - // step {} - do {} - If {}: - {} - - " - [(i 1) (i 2) (i 3) (i 4)])) - (s :ss - (fmt " -substep \"{}\" = - input: {} - output: {} - dependencies: {} - - {} - " - [(i 1) (i 2) (i 3) (i 4) (i 5)]))])))) + (fmt "#+begin_src {}\n{}\n#+end_src" [(i 1) (i 2)]))])))) {: add-snippets} diff --git a/fnl/plugins/snippets/workflow.fnl b/fnl/plugins/snippets/workflow.fnl new file mode 100644 index 0000000..b7f0807 --- /dev/null +++ b/fnl/plugins/snippets/workflow.fnl @@ -0,0 +1,42 @@ +(fn workflow-snippets [] + (let [ls (require :luasnip) + fmt (require :luasnip.extras.fmt)] + (let [s ls.s + i ls.insert_node + fmt fmt.fmt] + [(s :wf (fmt "workflow \"{}\" = + input: {} + output (on success): + {} + output (on error): + {} + + // step {} + do {} + {} + " [(i 1) (i 2) (i 3) (i 4) (i 5) (i 6) (i 7)])) + (s :st (fmt " + // step {} + do {} + If {}: + {} + + " + [(i 1) (i 2) (i 3) (i 4)])) + (s :ss (fmt " +substep \"{}\" = + input: {} + output: {} + dependencies: {} + + {} + " + [(i 1) (i 2) (i 3) (i 4) (i 5)]))]))) + +(fn add-snippets [] + (let [ls (require :luasnip) + snippets (workflow-snippets)] + (ls.add_snippets :org snippets) + (ls.add_snippets :markdown snippets))) + +{: add-snippets} -- cgit v1.2.3-70-g09d2