129 lines
3.1 KiB
Lua
129 lines
3.1 KiB
Lua
local ls = require 'luasnip'
|
|
local s = ls.snippet
|
|
local sn = ls.snippet_node
|
|
local fn = ls.function_node
|
|
local ms = ls.multi_snippet
|
|
local t = ls.text_node
|
|
local c = ls.choice_node
|
|
local i = ls.insert_node
|
|
local f = ls.function_node
|
|
local d = ls.dynamic_node
|
|
local fmt = require('luasnip.extras.fmt').fmt
|
|
local rep = require('luasnip.extras').rep
|
|
local extend_decorator = require 'luasnip.util.extend_decorator'
|
|
local fmta = extend_decorator.apply(fmt, { delimiters = '#~' })
|
|
|
|
local utils = require 'snippets.snip_utils'
|
|
local tr = utils.tr
|
|
local etr = utils.etr
|
|
local atr = utils.atr
|
|
local ctr = utils.ctr
|
|
local bs = utils.bs
|
|
|
|
return {
|
|
s(etr('du ', 'Dump a variable to the console'), fmta('console.log(#~);', { i(0) })),
|
|
s(
|
|
etr('vue', 'Vue Single File Component skeleton'),
|
|
fmta(
|
|
[[
|
|
<template>
|
|
</template>
|
|
<script setup>
|
|
#~
|
|
</script>
|
|
<style scoped>
|
|
</style>
|
|
]],
|
|
{ i(0) }
|
|
)
|
|
),
|
|
|
|
bs(atr('t ', 'this'), fmta('this.#~', { i(0) })),
|
|
|
|
s(etr('return ', 'Add semicolon after return'), fmta('return #~;', { i(0) })),
|
|
s(etr('rt ', 'return alias'), fmta('return #~;', { i(0) })),
|
|
|
|
s(etr('const', 'const declaration'), {
|
|
c(1, {
|
|
sn(nil, fmta('const #~ = #~;', { i(1, 'variableName'), i(2, 'value') })),
|
|
sn(
|
|
nil,
|
|
fmta(
|
|
[[
|
|
const #~ = (#~) => {
|
|
#~
|
|
}
|
|
]],
|
|
{ i(1), i(2), i(3) }
|
|
)
|
|
),
|
|
}),
|
|
}),
|
|
|
|
s(
|
|
etr('fn ', 'function block'),
|
|
fmta(
|
|
[[
|
|
function #~(#~) {
|
|
#~
|
|
}
|
|
]],
|
|
{ i(1), i(2), i(0) }
|
|
)
|
|
),
|
|
|
|
bs(atr('fn ', 'function block'), {
|
|
c(1, {
|
|
sn(
|
|
nil,
|
|
fmta(
|
|
[[
|
|
(#~) => {
|
|
#~
|
|
}
|
|
]],
|
|
{ i(1), i(2) }
|
|
)
|
|
),
|
|
sn(
|
|
nil,
|
|
fmta(
|
|
[[
|
|
function (#~) {
|
|
#~
|
|
}
|
|
]],
|
|
{ i(1), i(2) }
|
|
)
|
|
),
|
|
}),
|
|
}),
|
|
|
|
bs(atr('afn ', 'async function block'), {
|
|
c(1, {
|
|
sn(
|
|
nil,
|
|
fmta(
|
|
[[
|
|
async (#~) => {
|
|
#~
|
|
}
|
|
]],
|
|
{ i(1), i(2) }
|
|
)
|
|
),
|
|
sn(
|
|
nil,
|
|
fmta(
|
|
[[
|
|
async function (#~) {
|
|
#~
|
|
}
|
|
]],
|
|
{ i(1), i(2) }
|
|
)
|
|
),
|
|
}),
|
|
}),
|
|
}
|