-
Notifications
You must be signed in to change notification settings - Fork 4
/
php.lua
98 lines (94 loc) · 2.65 KB
/
php.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
local generator = require("plugins.extras.langspec"):new()
---@type LangConfig
local conf = {
ft = "php",
parsers = { -- nvim-treesitter: language parsers
"php",
},
}
if vim.fn.executable("php") == 1 then
conf = vim.tbl_extend("force", conf, {
-- NOTE: When the `composer` mirror is not synchronized, it may not match the version in `Mason` and cannot be installed.
cmdtools = { -- mason.nvim: cmdline tools for LSP servers, DAP servers, formatters and linters
"phpactor",
"phpcs",
"php-cs-fixer",
"php-debug-adapter", -- https://github.com/xdebug/vscode-php-debug
},
lsp = {
servers = { -- nvim-lspconfig: setup lspconfig servers
phpactor = {},
},
},
formatters = { -- conform.nvim
"php_cs_fixer",
},
linters = { -- nvim-lint
"phpcs",
},
dap = {
function()
local dap = require("dap")
dap.adapters.php = {
type = "executable",
command = vim.env.HOME .. "/.local/share/nvim/mason/bin/php-debug-adapter",
}
dap.configurations.php = {
{
type = "php",
request = "launch",
name = "Launch file (Xdebug)",
program = "${file}",
cwd = "${workspaceFolder}",
port = 9003,
stopOnEntry = false,
runtimeArgs = {
"-dxdebug.start_with_request=yes",
},
env = {
XDEBUG_MODE = "develop,coverage,debug",
XDEBUG_CONFIG = "idekey=nvim",
},
},
{
type = "php",
request = "launch",
name = "Launch file with arguments (Xdebug)",
program = "${file}",
cwd = "${workspaceFolder}",
port = 9003,
stopOnEntry = false,
args = U.dap.get_args,
runtimeArgs = {
"-dxdebug.start_with_request=yes",
},
env = {
XDEBUG_MODE = "develop,coverage,debug",
XDEBUG_CONFIG = "idekey=nvim",
},
},
}
end,
},
test = { -- neotest: language specific adapters
"olimorris/neotest-phpunit",
adapters = {
["neotest-phpunit"] = {
env = {
XDEBUG_CONFIG = "idekey=nvim",
},
dap = {
type = "php",
request = "launch",
name = "Launch file (Xdebug)",
program = "${file}",
cwd = "${workspaceFolder}",
port = 9003,
stopOnEntry = false,
},
},
},
},
} --[[@as LangConfig]])
end
return generator:generate(conf)