From 8cf3fed368a014f9b483aaecc427fab2d0b3cb38 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Sun, 9 Jan 2022 22:48:32 +0000 Subject: [PATCH] refactor(nvim): use `fmt` and shorthand variables --- .../files/lua/opdavies/snippets/markdown.lua | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/roles/neovim/files/lua/opdavies/snippets/markdown.lua b/roles/neovim/files/lua/opdavies/snippets/markdown.lua index 5af43917..4ef4eba4 100644 --- a/roles/neovim/files/lua/opdavies/snippets/markdown.lua +++ b/roles/neovim/files/lua/opdavies/snippets/markdown.lua @@ -1,14 +1,20 @@ +local fmt = require("luasnip.extras.fmt").fmt local luasnip = require "luasnip" -local snippet = luasnip.s -local insert = luasnip.insert_node -local text = luasnip.text_node +local i = luasnip.insert_node +local s = luasnip.snippet return { - snippet({ trig = "frontmatter", dscr = "Document frontmatter" }, { - text { "---", "tags: " }, - insert(1, "value"), - text { "", "---", "" }, - insert(0), - }), + s( + { trig = "frontmatter", dscr = "Document frontmatter" }, + fmt( + [[ + --- + title: {} + --- + {} + ]], + { i(1), i(0) } + ) + ), }