Compare commits
2 Commits
1f58b9f136
...
78b8bf177c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
78b8bf177c | ||
|
|
4f8e722f13 |
@@ -1,45 +1,128 @@
|
||||
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('du', { t 'console.log(', i(0), t ');' }),
|
||||
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) }
|
||||
)
|
||||
),
|
||||
|
||||
s('vue', {
|
||||
t { '<template>', '' },
|
||||
t { '', '</template>', '', '', '<script setup>', '' },
|
||||
i(0),
|
||||
t { '', '</script>', '', '', '<style scoped>', '', '.o-share-page {', '}', '', '</style>' },
|
||||
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('fun', {
|
||||
t 'function ',
|
||||
i(1),
|
||||
t '(',
|
||||
i(2),
|
||||
t ') {',
|
||||
t { '', ' ' },
|
||||
i(0),
|
||||
t { '', '}' },
|
||||
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) }
|
||||
)
|
||||
),
|
||||
}),
|
||||
}),
|
||||
|
||||
s('afun', {
|
||||
t 'async function ',
|
||||
i(1),
|
||||
t '(',
|
||||
i(2),
|
||||
t ') {',
|
||||
t { '', ' ' },
|
||||
i(0),
|
||||
t { '', '}' },
|
||||
}),
|
||||
|
||||
s('()', {
|
||||
t '() => {',
|
||||
t { '', ' ' },
|
||||
i(0),
|
||||
t { '', '}' },
|
||||
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) }
|
||||
)
|
||||
),
|
||||
}),
|
||||
}),
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ return {
|
||||
s(etr('return ', 'Add semicolon after return'), fmta('return #~;', { i(0) })),
|
||||
s(atr(' use ', 'Add use to function'), fmta(' use (#~)', { i(0) })),
|
||||
s(etr('rt ', 'return alias'), fmta('return #~;', { i(0) })),
|
||||
bs(etr('fn ', 'Shorthand function block'), {
|
||||
bs(atr('fn ', 'Shorthand function block'), {
|
||||
c(1, {
|
||||
sn(nil, fmta('fn (#~) => #~', { i(1), i(2) })),
|
||||
sn(
|
||||
@@ -188,7 +188,7 @@ return {
|
||||
),
|
||||
}),
|
||||
}),
|
||||
bs(etr('fun ', 'Shorthand function block'), {
|
||||
bs(atr('fun ', 'Shorthand function block'), {
|
||||
c(1, {
|
||||
sn(
|
||||
nil,
|
||||
@@ -384,7 +384,7 @@ return {
|
||||
-------------
|
||||
s(
|
||||
etr('bt', 'belongsTo Laravel relationship method'),
|
||||
c(0, {
|
||||
c(1, {
|
||||
sn(
|
||||
nil,
|
||||
fmta(
|
||||
@@ -397,7 +397,7 @@ return {
|
||||
return $this->belongsTo(#~::class);
|
||||
}
|
||||
]],
|
||||
{ rep(1), i(0), i(1) }
|
||||
{ rep(1), i(2), i(1) }
|
||||
)
|
||||
),
|
||||
sn(
|
||||
@@ -412,14 +412,14 @@ return {
|
||||
return $this->belongsTo(#~::class, #~);
|
||||
}
|
||||
]],
|
||||
{ rep(1), i(2), i(1), i(0) }
|
||||
{ rep(1), i(2), i(1), i(3) }
|
||||
)
|
||||
),
|
||||
})
|
||||
),
|
||||
s(
|
||||
etr('hm', 'hasMany Laravel relationship method'),
|
||||
c(0, {
|
||||
c(1, {
|
||||
sn(
|
||||
nil,
|
||||
fmta(
|
||||
@@ -432,7 +432,7 @@ return {
|
||||
return $this->hasOne(#~::class);
|
||||
}
|
||||
]],
|
||||
{ rep(1), i(0), i(1) }
|
||||
{ rep(1), i(2), i(1) }
|
||||
)
|
||||
),
|
||||
sn(
|
||||
@@ -447,14 +447,14 @@ return {
|
||||
return $this->hasOne(#~::class, #~);
|
||||
}
|
||||
]],
|
||||
{ rep(1), i(2), i(1), i(0) }
|
||||
{ rep(1), i(2), i(1), i(3) }
|
||||
)
|
||||
),
|
||||
})
|
||||
),
|
||||
s(
|
||||
etr('ho', 'hasOne Laravel relationship method'),
|
||||
c(0, {
|
||||
c(1, {
|
||||
sn(
|
||||
nil,
|
||||
fmta(
|
||||
@@ -467,7 +467,7 @@ return {
|
||||
return $this->hasOne(#~::class);
|
||||
}
|
||||
]],
|
||||
{ rep(1), i(0), i(1) }
|
||||
{ rep(1), i(2), i(1) }
|
||||
)
|
||||
),
|
||||
sn(
|
||||
@@ -482,14 +482,14 @@ return {
|
||||
return $this->hasOne(#~::class, #~);
|
||||
}
|
||||
]],
|
||||
{ rep(1), i(2), i(1), i(0) }
|
||||
{ rep(1), i(2), i(1), i(3) }
|
||||
)
|
||||
),
|
||||
})
|
||||
),
|
||||
s(
|
||||
etr('bm', 'belongsToMany Laravel relationship method'),
|
||||
c(0, {
|
||||
c(1, {
|
||||
sn(
|
||||
nil,
|
||||
fmta(
|
||||
@@ -502,7 +502,7 @@ return {
|
||||
return $this->belongsToMany(#~::class, #~);
|
||||
}
|
||||
]],
|
||||
{ rep(1), i(2), i(1), i(0) }
|
||||
{ rep(1), i(2), i(1), i(3) }
|
||||
)
|
||||
),
|
||||
sn(
|
||||
@@ -517,7 +517,7 @@ return {
|
||||
return $this->belongsToMany(#~::class, #~, #~);
|
||||
}
|
||||
]],
|
||||
{ rep(1), i(2), i(1), i(3), i(0) }
|
||||
{ rep(1), i(2), i(1), i(3), i(4) }
|
||||
)
|
||||
),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user