Improve debugging
This commit is contained in:
@@ -121,7 +121,9 @@ return {
|
|||||||
dap.adapters.php = {
|
dap.adapters.php = {
|
||||||
type = 'executable',
|
type = 'executable',
|
||||||
command = 'node',
|
command = 'node',
|
||||||
args = { '/Users/chris/.local/src/vscode-php-debug/out/phpDebug.js' },
|
args = {
|
||||||
|
vim.fn.expand '$MASON/packages/php-debug-adapter/extension/out/phpDebug.js',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
dap.configurations.php = {
|
dap.configurations.php = {
|
||||||
@@ -160,10 +162,10 @@ return {
|
|||||||
},
|
},
|
||||||
element_mappings = {
|
element_mappings = {
|
||||||
stacks = {
|
stacks = {
|
||||||
open = "<CR>",
|
open = '<CR>',
|
||||||
expand = "o",
|
expand = 'o',
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Change breakpoint icons
|
-- Change breakpoint icons
|
||||||
|
|||||||
6
lua/plugins/suda.lua
Normal file
6
lua/plugins/suda.lua
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
return {
|
||||||
|
'lambdalisue/vim-suda',
|
||||||
|
config = function()
|
||||||
|
vim.g.suda_smart_edit = 1
|
||||||
|
end,
|
||||||
|
}
|
||||||
@@ -1,84 +1,110 @@
|
|||||||
local ls = require("luasnip")
|
local ls = require 'luasnip'
|
||||||
local s = ls.snippet
|
local s = ls.snippet
|
||||||
local t = ls.text_node
|
local t = ls.text_node
|
||||||
local i = ls.insert_node
|
local i = ls.insert_node
|
||||||
local f = ls.function_node
|
local f = ls.function_node
|
||||||
|
|
||||||
|
local function get_psr4_root()
|
||||||
|
local handle = io.popen [[php -r "echo array_keys(json_decode(file_get_contents('composer.json'), true)['autoload']['psr-4'])[0];"]]
|
||||||
|
local ns_root = handle and handle:read '*a' or ''
|
||||||
|
if handle then
|
||||||
|
handle:close()
|
||||||
|
end
|
||||||
|
ns_root = ns_root:gsub('\\$', '') -- Remove trailing backslash
|
||||||
|
return ns_root
|
||||||
|
end
|
||||||
|
|
||||||
local function psr_namespace(args, snip)
|
local function psr_namespace(args, snip)
|
||||||
local path = snip.env.TM_FILENAME_FULL or ""
|
local path = snip.env.TM_FILENAME_FULL or ''
|
||||||
local root = "/src/"
|
local composer_root = get_psr4_root()
|
||||||
local ns = path:match(root .. "(.*)/[^/]+%.php$")
|
-- Find the directory mapped by composer.json
|
||||||
|
local root_dir = composer_root:gsub('\\', '/')
|
||||||
|
local ns = path:match(root_dir .. '/(.*)/[^/]+%.php$')
|
||||||
if ns then
|
if ns then
|
||||||
return ns:gsub("/", "\\")
|
return composer_root .. '\\' .. ns:gsub('/', '\\')
|
||||||
else
|
else
|
||||||
return "App"
|
return composer_root ~= '' and composer_root or 'App'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function class_name(args, snip)
|
local function class_name(args, snip)
|
||||||
local filename = snip.env.TM_FILENAME or ""
|
local filename = snip.env.TM_FILENAME or ''
|
||||||
return filename:match("([^%.]+)") or "ClassName"
|
return filename:match '([^%.]+)' or 'ClassName'
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
s("du", { t("dump("), i(1), t(");") }),
|
s('du', { t 'dump(', i(1), t ');' }),
|
||||||
s("dt", { t("\\PhpStan\\dumpType("), i(1), t(");") }),
|
s('dt', { t '\\PhpStan\\dumpType(', i(1), t ');' }),
|
||||||
s("ql", {
|
s('ql', {
|
||||||
t("\\Illuminate\\Support\\Facades\\DB::listen(function (\\Illuminate\\Database\\Events\\QueryExecuted $e) {"),
|
t '\\Illuminate\\Support\\Facades\\DB::listen(function (\\Illuminate\\Database\\Events\\QueryExecuted $e) {',
|
||||||
t({"", " dump($e->sql, $e->bindings);"}),
|
t { '', ' dump($e->sql, $e->bindings);' },
|
||||||
t({"", "});"})
|
t { '', '});' },
|
||||||
}),
|
}),
|
||||||
s("test", {
|
s('test', {
|
||||||
t("test("), i(1), t(", function () {"),
|
t 'test(',
|
||||||
t({"", " "}), i(2),
|
|
||||||
t({"", ");"})
|
|
||||||
}),
|
|
||||||
s("/**", {
|
|
||||||
t("/**"),
|
|
||||||
t({"", " * "}), i(1),
|
|
||||||
t({"", " */"})
|
|
||||||
}),
|
|
||||||
s("@p", { t("@property "), i(1), t(" $"), i(2) }),
|
|
||||||
s("@pb", { t("@property bool $"), i(1) }),
|
|
||||||
s("@ps", { t("@property string $"), i(1) }),
|
|
||||||
s("@pi", { t("@property int $"), i(1) }),
|
|
||||||
s("@pc", { t("@property \\Illuminate\\Support\\Collection<int, "), i(1), t("> $"), i(2) }),
|
|
||||||
s("@pd", { t("@property \\Illuminate\\Support\\Carbon $"), i(1) }),
|
|
||||||
s("@pp", {
|
|
||||||
t("/**"),
|
|
||||||
t({"", " * @property int $id"}),
|
|
||||||
t({"", " * "}), i(1),
|
|
||||||
t({"", " * @property \\Illuminate\\Support\\Carbon $created_at"}),
|
|
||||||
t({"", " * @property \\Illuminate\\Support\\Carbon $updated_at"}),
|
|
||||||
t({"", " *", " * Relationships"}),
|
|
||||||
t({"", " * "}), i(2),
|
|
||||||
t({"", " */"})
|
|
||||||
}),
|
|
||||||
s("php", {
|
|
||||||
t("<?php"),
|
|
||||||
t({"", ""}),
|
|
||||||
t("namespace "),
|
|
||||||
f(psr_namespace, {}),
|
|
||||||
t(";"),
|
|
||||||
t({"", "", "/**", " * Class "}),
|
|
||||||
f(class_name, {}),
|
|
||||||
t({"", " */", "class "}),
|
|
||||||
f(class_name, {}),
|
|
||||||
i(1),
|
i(1),
|
||||||
t({"", "{", " public function __construct()", " {", " "}),
|
t ', function () {',
|
||||||
i(2, "// TODO: Implement constructor"),
|
t { '', ' ' },
|
||||||
t({"", " }", "}"})
|
i(2),
|
||||||
|
t { '', ');' },
|
||||||
}),
|
}),
|
||||||
s("pub", {
|
s('/**', {
|
||||||
t("public function "), i(1), t("("), i(2), t(")"),
|
t '/**',
|
||||||
t({"", "{"}),
|
t { '', ' * ' },
|
||||||
t({"", " "}), i(3),
|
i(1),
|
||||||
t({"", "}"})
|
t { '', ' */' },
|
||||||
}),
|
}),
|
||||||
s("pro", {
|
s('@p', { t '@property ', i(1), t ' $', i(2) }),
|
||||||
t("protected function "), i(1), t("("), i(2), t(")"),
|
s('@pb', { t '@property bool $', i(1) }),
|
||||||
t({"", "{"}),
|
s('@ps', { t '@property string $', i(1) }),
|
||||||
t({"", " "}), i(3),
|
s('@pi', { t '@property int $', i(1) }),
|
||||||
t({"", "}"})
|
s('@pc', { t '@property \\Illuminate\\Support\\Collection<int, ', i(1), t '> $', i(2) }),
|
||||||
|
s('@pd', { t '@property \\Illuminate\\Support\\Carbon $', i(1) }),
|
||||||
|
s('@pp', {
|
||||||
|
t '/**',
|
||||||
|
t { '', ' * @property int $id' },
|
||||||
|
t { '', ' * ' },
|
||||||
|
i(1),
|
||||||
|
t { '', ' * @property \\Illuminate\\Support\\Carbon $created_at' },
|
||||||
|
t { '', ' * @property \\Illuminate\\Support\\Carbon $updated_at' },
|
||||||
|
t { '', ' *', ' * Relationships' },
|
||||||
|
t { '', ' * ' },
|
||||||
|
i(2),
|
||||||
|
t { '', ' */' },
|
||||||
|
}),
|
||||||
|
s('php', {
|
||||||
|
t '<?php',
|
||||||
|
t { '', '', '' },
|
||||||
|
t 'namespace ',
|
||||||
|
f(psr_namespace, {}),
|
||||||
|
t ';',
|
||||||
|
t { '', '', 'class ' },
|
||||||
|
f(class_name, {}),
|
||||||
|
t { '', '{' },
|
||||||
|
t { '', '' },
|
||||||
|
i(0),
|
||||||
|
t { '', '', '}' },
|
||||||
|
}),
|
||||||
|
s('pub', {
|
||||||
|
t 'public function ',
|
||||||
|
i(1),
|
||||||
|
t '(',
|
||||||
|
i(2),
|
||||||
|
t ')',
|
||||||
|
t { '', '{' },
|
||||||
|
t { '', ' ' },
|
||||||
|
i(3),
|
||||||
|
t { '', '}' },
|
||||||
|
}),
|
||||||
|
s('pro', {
|
||||||
|
t 'protected function ',
|
||||||
|
i(1),
|
||||||
|
t '(',
|
||||||
|
i(2),
|
||||||
|
t ')',
|
||||||
|
t { '', '{' },
|
||||||
|
t { '', ' ' },
|
||||||
|
i(3),
|
||||||
|
t { '', '}' },
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user