From 9b4fadfa28e5ce735f8cf59e4c5bf3c363bac7db Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Sun, 9 Jan 2022 22:46:33 +0000 Subject: [PATCH] refactor(nvim): use shorthand variables I'm not sure if I like this, but it's less characters and seems to be the convention with LuaSnip which will make it easier if introducing snippets from any examples or anyone else's dotfiles. --- .../lua/opdavies/snippets/javascript.lua | 8 +++---- .../files/lua/opdavies/snippets/php.lua | 24 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/roles/neovim/files/lua/opdavies/snippets/javascript.lua b/roles/neovim/files/lua/opdavies/snippets/javascript.lua index 46dc178..89e1fc6 100644 --- a/roles/neovim/files/lua/opdavies/snippets/javascript.lua +++ b/roles/neovim/files/lua/opdavies/snippets/javascript.lua @@ -1,9 +1,9 @@ -local luasnip = require "luasnip" local fmta = require("luasnip.extras.fmt").fmta +local luasnip = require "luasnip" -local insert = luasnip.insert_node -local snippet = luasnip.snippet +local i = luasnip.insert_node +local s = luasnip.snippet return { - snippet({ trig = "log", dscr = "console.log" }, fmta("console.log(<>);", { insert(1, "value") })), + s({ trig = "log", dscr = "console.log" }, fmta("console.log(<>);", { i(1, "value") })), } diff --git a/roles/neovim/files/lua/opdavies/snippets/php.lua b/roles/neovim/files/lua/opdavies/snippets/php.lua index 5759cf5..a49e622 100644 --- a/roles/neovim/files/lua/opdavies/snippets/php.lua +++ b/roles/neovim/files/lua/opdavies/snippets/php.lua @@ -1,13 +1,13 @@ -local luasnip = require "luasnip" local fmta = require("luasnip.extras.fmt").fmta +local luasnip = require "luasnip" -local choice = luasnip.choice_node -local insert = luasnip.insert_node -local snippet = luasnip.snippet -local text = luasnip.text_node +local c = luasnip.choice_node +local i = luasnip.insert_node +local s = luasnip.snippet +local t = luasnip.text_node return { - snippet( + s( "test", fmta( [[ @@ -17,13 +17,13 @@ return { } ]], { - choice(1, { - text "test", - text "it", - text "should", + c(1, { + t "test", + t "it", + t "should", }), - insert(2), - insert(0), + i(2), + i(0), } ) ),