From f893caefac30ed8e64b8b2c22c151bb42f7098a3 Mon Sep 17 00:00:00 2001
From: Oliver Davies <oliver@oliverdavies.dev>
Date: Mon, 3 Mar 2025 18:37:20 +0000
Subject: [PATCH] Add Twig snippets

---
 nvim/lua/opdavies/snippets/twig.lua | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 nvim/lua/opdavies/snippets/twig.lua

diff --git a/nvim/lua/opdavies/snippets/twig.lua b/nvim/lua/opdavies/snippets/twig.lua
new file mode 100644
index 0000000..628e1e2
--- /dev/null
+++ b/nvim/lua/opdavies/snippets/twig.lua
@@ -0,0 +1,28 @@
+require("luasnip.session.snippet_collection").clear_snippets "twig"
+
+local ls = require "luasnip"
+
+local s = ls.snippet
+local i = ls.insert_node
+
+local fmta = require("luasnip.extras.fmt").fmta
+
+ls.add_snippets("twig", {
+  s("do", fmta("{% <> %}<>", { i(1), i(0) })),
+  s("dump", fmta("{{ dump(<>) }}<>", { i(1), i(0) })),
+  s("echo", fmta("{{ <> }}<>", { i(1), i(0) })),
+
+  s(
+    "for",
+    fmta(
+      [[
+      {% for <> in <> %}
+        <>
+      {% endfor %}<>
+      ]],
+      { i(1), i(2), i(3), i(0) }
+    )
+  ),
+
+  s("if", fmta("{% if <> %}<>{% endif %}<>", { i(1), i(2), i(0) })),
+})