aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/alpha/plugins.lua2
-rw-r--r--lua/alpha/snips/ft/php.lua54
2 files changed, 35 insertions, 21 deletions
diff --git a/lua/alpha/plugins.lua b/lua/alpha/plugins.lua
index 0e1584f..bb59623 100644
--- a/lua/alpha/plugins.lua
+++ b/lua/alpha/plugins.lua
@@ -81,7 +81,7 @@ return require("packer").startup(function(use)
"rcarriga/cmp-dap",
"saadparwaiz1/cmp_luasnip",
"onsails/lspkind-nvim",
- "L3MON4D3/LuaSnip",
+ {"L3MON4D3/LuaSnip", tag = "v1.*"},
"windwp/nvim-autopairs",
},
})
diff --git a/lua/alpha/snips/ft/php.lua b/lua/alpha/snips/ft/php.lua
index decee10..d70db2e 100644
--- a/lua/alpha/snips/ft/php.lua
+++ b/lua/alpha/snips/ft/php.lua
@@ -4,7 +4,7 @@ local composer = require("composer")
local snippet_from_nodes = ls.sn
local c = ls.choice_node
local t = ls.text_node
--- local d = ls.dynamic_node
+local d = ls.dynamic_node
local f = ls.function_node
local i = ls.insert_node
local fmt = require("luasnip.extras.fmt").fmt
@@ -18,7 +18,7 @@ local newline = function(text)
end
local visibility = function(position, default)
- local possibles = { "private", "public" }
+ local possibles = { "private", "protected", "public" }
local options = {}
for _, value in pairs(possibles) do
@@ -48,9 +48,9 @@ local namespace = function()
end
end
dir = dir:gsub("/", "\\")
- if dir == "" then
- return globalNamespace
- end
+ if dir == "" then
+ return globalNamespace
+ end
return string.format("%s\\%s", globalNamespace, dir)
end
@@ -94,18 +94,27 @@ class {}
}
)
-M.pro = fmt([[{} {} ${},]], {
+M.pro = fmt([[{} {}{} ${},]], {
visibility(1, "private"),
- i(2, "Type"),
- f(function(args)
- return args[1][1]:gsub("^%u", string.lower)
- end, { 2 }),
+ c(2, {
+ t(""),
+ t("readonly "),
+ }),
+ i(3, "Type"),
+ d(4, function(args)
+ return snippet_from_nodes(nil, {
+ i(1, args[1][1]:gsub("^%u", string.lower) or ""),
+ })
+ end, { 3 }),
})
-M.rpro = fmt([[{} readonly {} ${},]], {
- visibility(1, "public"),
- i(2, "int"),
- i(3, ""),
+M.arg = fmt([[{} ${}]], {
+ i(1, "Type"),
+ d(2, function(args)
+ return snippet_from_nodes(nil, {
+ i(1, args[1][1]:gsub("^%u", string.lower) or ""),
+ })
+ end, { 1 }),
})
M._c = fmt(
@@ -137,7 +146,7 @@ M.fn = {
t(" function "),
i(2, "name"),
t("("),
- i(3, "$arg"),
+ i(3),
t(")"),
c(4, {
t(""),
@@ -152,18 +161,23 @@ M.fn = {
newline("}"),
}
-M["then"] = fmt([[->then(function ({}) {{
+M["then"] = fmt(
+ [[->then(function ({}) {{
{}
-}})]], {i(1, ""), i(2, "")})
+}})]],
+ { i(1, ""), i(2, "") }
+)
-M.test = fmt([[/**
+M.test = fmt(
+ [[/**
* @test
*/
public function it_{}(): void
{{
{}
}}
-]], {i(1, ""), i(0, "")})
-
+]],
+ { i(1, ""), i(0, "") }
+)
return M