Snippets
This commit is contained in:
@@ -2,6 +2,7 @@ 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
|
||||
@@ -19,7 +20,7 @@ local atr = utils.atr
|
||||
local ctr = utils.ctr
|
||||
local bs = utils.bs
|
||||
|
||||
local function psr_namespace(_, snip)
|
||||
local function psr_namespace()
|
||||
local path = vim.fn.expand '%'
|
||||
-- Get the directory of the path
|
||||
local dir = vim.fs.dirname(path)
|
||||
@@ -169,26 +170,24 @@ 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(
|
||||
atr('fn ', 'Shorthand function block'),
|
||||
c(0, {
|
||||
bs(etr('fn ', 'Shorthand function block'), {
|
||||
c(1, {
|
||||
sn(nil, fmta('fn (#~) => #~', { i(1), i(2) })),
|
||||
sn(
|
||||
nil,
|
||||
fmta(
|
||||
[[
|
||||
function (#~) {
|
||||
#~
|
||||
}
|
||||
]],
|
||||
function (#~) {
|
||||
#~
|
||||
}
|
||||
]],
|
||||
{ i(1), i(2) }
|
||||
)
|
||||
),
|
||||
})
|
||||
),
|
||||
bs(
|
||||
atr('fun ', 'Shorthand function block'),
|
||||
c(0, {
|
||||
}),
|
||||
}),
|
||||
bs(etr('fun ', 'Shorthand function block'), {
|
||||
c(1, {
|
||||
sn(
|
||||
nil,
|
||||
fmta(
|
||||
@@ -211,11 +210,11 @@ return {
|
||||
{ i(1), i(2), i(3) }
|
||||
)
|
||||
),
|
||||
})
|
||||
),
|
||||
}),
|
||||
}),
|
||||
s(
|
||||
etr('con', 'Constructor function block'),
|
||||
c(0, {
|
||||
c(1, {
|
||||
sn(
|
||||
nil,
|
||||
fmta(
|
||||
@@ -250,41 +249,45 @@ return {
|
||||
bs(atr('a%$', 'array type parameter'), fmta('array $#~', { i(0, 'var') })),
|
||||
s(atr('$ ', 'Expand $this->'), fmta('$this->#~', { i(0) })),
|
||||
bs(
|
||||
atr('am ', 'array_map function'),
|
||||
c(0, {
|
||||
sn(nil, fmta('array_map(fn (#~) => #~, #~)', { i(2), i(3), i(1) })),
|
||||
sn(
|
||||
nil,
|
||||
fmta(
|
||||
[[
|
||||
etr('am ', 'array_map function'),
|
||||
{
|
||||
c(1, {
|
||||
sn(nil, fmta('array_map(fn (#~) => #~, #~)', { i(2), i(3), i(1) })),
|
||||
sn(
|
||||
nil,
|
||||
fmta(
|
||||
[[
|
||||
array_map(function (#~) {
|
||||
#~
|
||||
}, #~)
|
||||
]],
|
||||
{ i(2), i(0), i(1) }
|
||||
)
|
||||
),
|
||||
})
|
||||
{ i(2), i(0), i(1) }
|
||||
)
|
||||
),
|
||||
}),
|
||||
}
|
||||
),
|
||||
bs(atr('array_map', 'array_map function'), fmta('am', {})),
|
||||
bs(etr('array_map', 'array_map function'), fmta('am', {})),
|
||||
bs(
|
||||
atr('af ', 'array_filter function'),
|
||||
c(0, {
|
||||
sn(nil, fmta('array_filter(#~, fn (#~) => #~)', { i(1), i(2), i(3) })),
|
||||
sn(
|
||||
nil,
|
||||
fmta(
|
||||
[[
|
||||
etr('af ', 'array_filter function'),
|
||||
{
|
||||
c(1, {
|
||||
sn(nil, fmta('array_filter(#~, fn (#~) => #~)', { i(1), i(2), i(3) })),
|
||||
sn(
|
||||
nil,
|
||||
fmta(
|
||||
[[
|
||||
array_filter(#~, function (#~) {
|
||||
#~
|
||||
})
|
||||
]],
|
||||
{ i(1), i(2), i(0) }
|
||||
)
|
||||
),
|
||||
})
|
||||
{ i(1), i(2), i(0) }
|
||||
)
|
||||
),
|
||||
}),
|
||||
}
|
||||
),
|
||||
bs(atr('([^%w])array_filter', 'array_filter function'), fmta('af', {})),
|
||||
bs(etr('array_filter', 'array_filter function'), fmta('af', {})),
|
||||
s(
|
||||
etr('php', 'php class'),
|
||||
fmta(
|
||||
|
||||
Reference in New Issue
Block a user