From 5221d941d056202c971716907c0c97b82341aba1 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Thu, 8 Aug 2024 21:50:41 +0100 Subject: [PATCH] Add Sculpin talk snippets --- lua/opdavies/snippets/talks/sculpin.lua | 154 ++++++++++++++++++++++++ plugin/completion.lua | 5 + 2 files changed, 159 insertions(+) create mode 100644 lua/opdavies/snippets/talks/sculpin.lua diff --git a/lua/opdavies/snippets/talks/sculpin.lua b/lua/opdavies/snippets/talks/sculpin.lua new file mode 100644 index 0000000..766e5d3 --- /dev/null +++ b/lua/opdavies/snippets/talks/sculpin.lua @@ -0,0 +1,154 @@ +local should_load = false + +if not should_load then + return +end + +local fmt = require("luasnip.extras.fmt").fmt +local ls = require "luasnip" + +local s = ls.snippet +local t = ls.text_node + +ls.add_snippets("twig", { + s( + "sortdate", + fmt( + [[ + {{% set speakersAndDates = [] %}} + + {{% for speaker in speakers %}} + {{% set talksForSpeaker = talks|default([])|filter(talk =>> talk.speaker == speaker.name) %}} + + {{% set mostRecentTalk = talksForSpeaker|first %}} + + {{% set speakersAndDates = speakersAndDates|merge([{{ + date: mostRecentTalk.date, + speaker, + }}]) %}} + {{% endfor %}} + + {{% set sortedSpeakers = speakersAndDates|sort((a, b) => b.date <=> a.date) %}} + + {{% for speaker in sortedSpeakers|column('speaker') %}} + ]], + {} + ) + ), + + s("sortname", { t "{% for speaker in site.speakers|sort((a, b) => a.name <=> b.name) %}" }), + + s( + "speakerpage", + fmt( + [[ + {{% block content_wrapper %}} +

{{{{ page.name }}}}

+ +
+ Photo of {{{{ page.name }}}} +
+ +
+ {{{{ block('content') }}}} +
+ {{% endblock %}} + ]], + {} + ) + ), + + s( + "speaker", + fmt( + [[ +
+ +
+

{{{{ speaker.name }}}}

+
+ +
+ Photo of {{{{ speaker.name }}}}
+
+
+ ]], + {} + ) + ), + + s( + "speakers", + fmt( + [[ +
+

Speakers

+ +
+
+ {{% for speaker in site.speakers %}} + + {{% endfor %}} +
+
+
+ ]], + {} + ) + ), +}) + +ls.add_snippets("yaml", { + s( + "talks", + fmt( + [[ + talks: + - title: Building Static Websites with PHP and Sculpin + speaker: Oliver Davies + date: 2024-02-14 + - title: 'FPGA^2: An open-source FPGA' + speaker: Robin Hodson + date: 2024-02-14 + - title: Introducing Domain Driven Design + speaker: Rob Allen + date: 2024-01-10 + - title: Building Better TUIs (with PHP) + speaker: Dan Leech + date: 2023-11-08 + - title: Thoughts on Ubiquitous Language + speaker: Rob Allen + date: 2023-11-08 + - title: Testing Legacy + speaker: Mike Karthauser + date: 2023-11-08 + - title: Building "Build Configs" + speaker: Oliver Davies + date: 2023-11-08 + - title: Terraform from a dev’s perspective + speaker: Nigel Dunn + date: 2023-10-11 + - title: What is TDD and why should I care? + speaker: Naomi Gotts + date: 2023-07-12 + - title: Go for PHP + speaker: Dan Leech + date: 2023-02-08 + - title: What's new in PHP 8.* + speaker: Derick Rethans + date: 2023-02-11 + - title: Behaviour Driven Development (BDD) in Practice + speaker: Ciaran McNulty + date: 2022-09-14 + ]], + {} + ) + ), +}) diff --git a/plugin/completion.lua b/plugin/completion.lua index 8d3d6c0..3ecff97 100644 --- a/plugin/completion.lua +++ b/plugin/completion.lua @@ -123,6 +123,11 @@ ls.add_snippets("js", snippets.javascript) ls.add_snippets("typescript", snippets.javascript) ls.add_snippets("vue", snippets.javascript) +-- Include any snippets to use in presentations. +for _, ft_path in ipairs(vim.api.nvim_get_runtime_file("lua/opdavies/snippets/talks/*.lua", true)) do + loadfile(ft_path)() +end + require("luasnip.loaders.from_vscode").lazy_load() ls.config.set_config {