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