Merge pull request #1606 from poseidon-rises/php/PHPStan

PHP/PHPStan
This commit is contained in:
Snoweuph 2026-05-21 00:54:26 +02:00 committed by GitHub
commit e6a92b1b5a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 40 additions and 1 deletions

View file

@ -561,4 +561,10 @@ https://github.com/gorbit99/codewindow.nvim
- Fix `golangci-lint` to lint at the package level.
[Poseidon](https://github.com/poseidon-rises)
[PHPStan]: https://github.com/phpstan/phpstan
- Add [PHPStan] as a formatter for `vim.languages.php`.
<!-- vim: set textwidth=80: -->

View file

@ -11,7 +11,7 @@
inherit (lib.modules) mkIf mkMerge;
inherit (lib.types) enum int attrs listOf;
inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.nvim.types) mkGrammarOption diagnostics;
inherit (lib.nvim.attrsets) mapListToAttrs;
cfg = config.vim.languages.php;
@ -33,6 +33,14 @@
command = "${pkgs.php84Packages.php-cs-fixer}/bin/php-cs-fixer";
};
};
defaultDiagnosticsProvider = ["phpstan"];
diagnosticsProviders = {
phpstan = {
config.cmd = getExe pkgs.phpstan;
};
};
in {
options.vim.languages.php = {
enable = mkEnableOption "PHP language support";
@ -103,6 +111,21 @@ in {
};
};
};
extraDiagnostics = {
enable =
mkEnableOption "extra PHP diagnostics"
// {
default = config.vim.languages.enableExtraDiagnostics;
defaultText = literalExpression "config.vim.languages.enableExtraDiagnostic";
};
types = diagnostics {
langDesc = "PHP";
inherit diagnosticsProviders;
inherit defaultDiagnosticsProvider;
};
};
};
config = mkIf cfg.enable (mkMerge [
@ -154,5 +177,15 @@ in {
};
};
})
(mkIf cfg.extraDiagnostics.enable {
vim.diagnostics.nvim-lint = {
enable = true;
linters_by_ft.php = cfg.extraDiagnostics.types;
linters =
mkMerge (map (name: {${name} = diagnosticsProviders.${name}.config;})
cfg.extraDiagnostics.types);
};
})
]);
}