aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorAriel D'Alessandro <dalessandro.ariel@gmail.com>2023-02-28 09:29:21 +0100
committerAriel D'Alessandro <dalessandro.ariel@gmail.com>2023-02-28 09:29:43 +0100
commit61499082db8f34ca38fc9eb916f9cc87d82e7655 (patch)
treeec4a15d83ada78023b35d54e7c7ce584381f3f02 /lua
parent9b7f8bb3fac4af6685a26d7bcfbf019ee2e21ebf (diff)
downloadnvim-conf-61499082db8f34ca38fc9eb916f9cc87d82e7655.tar.gz
nvim-conf-61499082db8f34ca38fc9eb916f9cc87d82e7655.zip
fix: update snippets, add todo for namespace
Diffstat (limited to 'lua')
-rw-r--r--lua/alpha/snips/ft/php.lua51
1 files changed, 29 insertions, 22 deletions
diff --git a/lua/alpha/snips/ft/php.lua b/lua/alpha/snips/ft/php.lua
index abfc6f7..630673b 100644
--- a/lua/alpha/snips/ft/php.lua
+++ b/lua/alpha/snips/ft/php.lua
@@ -32,13 +32,21 @@ local visibility = function(position, default)
return c(position, options)
end
+-- FIX: This logic does not work properly
local namespace = function()
local dir = vim.fn.expand "%:h"
local autoloads = composer.query { "autoload", "psr-4" }
+ local dev_autoloads = composer.query { "autoload-dev", "psr-4" }
+
if autoloads == nil then
return (dir:gsub("^%l", string.upper))
end
+ for index, value in pairs(dev_autoloads) do
+ autoloads[index] = value
+ end
+
+ P(dir)
local globalNamespace
for key, value in pairs(autoloads) do
if string.starts(dir, value:sub(1, -2)) then
@@ -97,8 +105,8 @@ class {}
M.pro = fmt([[{} {}{} ${},]], {
visibility(1, "private"),
c(2, {
- t "",
t "readonly ",
+ t "",
}),
i(3, "Type"),
d(4, function(args)
@@ -108,6 +116,15 @@ M.pro = fmt([[{} {}{} ${},]], {
end, { 3 }),
})
+M.op = fmt("private {}|ObjectProphecy ${};", {
+ 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.arg = fmt([[{} ${}]], {
i(1, "Type"),
d(2, function(args)
@@ -141,30 +158,20 @@ M._p = fmt(
M.strict = t "declare(strict_types=1);"
-M.fn = {
- visibility(1, "public"),
- t " function ",
- i(2, "name"),
- t "(",
- i(3),
- t ")",
- c(4, {
- t "",
- snippet_from_nodes(nil, {
- t ": ",
- i(1, "void"),
- }),
- }),
- newline "{",
- newline "\t",
- i(0, ""),
- newline "}",
-}
+M["fn"] = fmt(
+ [[{} function {}({}): {}
+{{
+ {}
+}}]],
+ { visibility(1, "public"), i(2), i(3), i(4, "void"), i(0) }
+)
M["then"] = fmt(
- [[->then(function ({}) {{
+ [[->then(
+ function ({}) {{
{}
-}})]],
+ }}
+)]],
{ i(1, ""), i(2, "") }
)