languages/php: add debugging

This commit is contained in:
Snoweuph 2026-02-04 02:00:05 +01:00
commit 58b35564d1
No known key found for this signature in database
GPG key ID: BEFC41DA223CEC55
2 changed files with 46 additions and 2 deletions

View file

@ -174,6 +174,8 @@
- Added Makefile support via `languages.make`.
- Added Debugging support to `languages.php`.
[vagahbond](https://github.com/vagahbond): [codewindow.nvim]:
https://github.com/gorbit99/codewindow.nvim

View file

@ -4,11 +4,12 @@
lib,
...
}: let
inherit (builtins) attrNames;
inherit (builtins) attrNames toString toFile;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.meta) getExe;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.types) enum;
inherit (lib.types) enum int attrs;
inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.types) mkGrammarOption deprecatedSingleOrListOf;
inherit (lib.nvim.attrsets) mapListToAttrs;
inherit (lib.generators) mkLuaInline;
@ -82,6 +83,28 @@ in {
description = "PHP LSP server to use";
};
};
dap = {
enable = mkEnableOption "Enable PHP Debug Adapter" // {default = config.vim.languages.enableDAP;};
xdebug = {
adapter = mkOption {
type = attrs;
default = {
type = "executable";
command = "${pkgs.nodePackages_latest.nodejs}/bin/node";
args = [
"${pkgs.vscode-extensions.xdebug.php-debug}/share/vscode/extensions/xdebug.php-debug/out/phpDebug.js"
];
};
description = "XDebug adapter to use for nvim-dap";
};
port = mkOption {
type = int;
default = 9003;
description = "Port to use for XDebug";
};
};
};
};
config = mkIf cfg.enable (mkMerge [
@ -98,5 +121,24 @@ in {
})
cfg.lsp.servers;
})
(mkIf cfg.dap.enable {
vim = {
debugger.nvim-dap = {
enable = true;
sources.php-debugger = ''
dap.adapters.xdebug = ${toLuaObject cfg.dap.xdebug.adapter}
dap.configurations.php = {
{
type = 'xdebug',
request = 'launch',
name = 'Listen for XDebug',
port = ${toString cfg.dap.xdebug.port},
},
}
'';
};
};
})
]);
}