Remove drupal_class snippet

Removed now I have Phpactor working again.
This commit is contained in:
Oliver Davies 2025-01-03 18:00:00 +00:00
parent aa666a2391
commit 44f413cd53

View file

@ -3,7 +3,6 @@ require("luasnip.session.snippet_collection").clear_snippets "php"
local ls = require "luasnip" local ls = require "luasnip"
local c = ls.choice_node local c = ls.choice_node
local f = ls.function_node
local i = ls.insert_node local i = ls.insert_node
local s = ls.snippet local s = ls.snippet
local t = ls.text_node local t = ls.text_node
@ -11,63 +10,6 @@ local t = ls.text_node
local fmta = require("luasnip.extras.fmt").fmta local fmta = require("luasnip.extras.fmt").fmta
ls.add_snippets("php", { ls.add_snippets("php", {
s(
"drupalclass",
fmta(
[[
<<?php
declare(strict_types=1);
namespace <>;
final class <> {
<>
}]],
{
f(function()
local filepath = vim.fn.expand "%:h"
local filepath_parts = vim.fn.split(filepath, "/")
if not vim.tbl_contains(filepath_parts, "src") then
return ""
end
local namespace_parts = { "Drupal" }
local is_test_file = vim.tbl_contains(filepath_parts, "tests")
if is_test_file then
table.insert(namespace_parts, "Tests")
end
-- Find and add the module name.
for k, v in ipairs(filepath_parts) do
if v == "src" then
if is_test_file then
table.insert(namespace_parts, filepath_parts[k - 2])
else
table.insert(namespace_parts, filepath_parts[k - 1])
end
end
end
-- Add the rest of the namespace.
local namespace = vim.split(filepath, "src/")
local final_part = (namespace[2] or ""):gsub("/", "\\")
table.insert(namespace_parts, final_part)
return table.concat(namespace_parts, "\\")
end),
f(function()
return vim.fn.expand "%:t:r"
end),
i(0),
}
)
),
s("func", fmta("function <>(<>)<> {\n <>\n}<>", { i(1), i(2), i(3), i(4), i(0) })), s("func", fmta("function <>(<>)<> {\n <>\n}<>", { i(1), i(2), i(3), i(4), i(0) })),
s( s(