mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-02-23 20:12:00 +00:00
languages/php: add formatting (#1401)
Some checks failed
Set up binary cache / cachix (default) (push) Has been cancelled
Set up binary cache / cachix (maximal) (push) Has been cancelled
Set up binary cache / cachix (nix) (push) Has been cancelled
Treewide Checks / Validate flake (push) Has been cancelled
Treewide Checks / Check formatting (push) Has been cancelled
Treewide Checks / Check source tree for typos (push) Has been cancelled
Treewide Checks / Validate documentation builds (push) Has been cancelled
Treewide Checks / Validate documentation builds-1 (push) Has been cancelled
Treewide Checks / Validate documentation builds-2 (push) Has been cancelled
Treewide Checks / Validate documentation builds-3 (push) Has been cancelled
Treewide Checks / Validate hyperlinks in documentation sources (push) Has been cancelled
Treewide Checks / Validate Editorconfig conformance (push) Has been cancelled
Build and deploy documentation / Check latest commit (push) Has been cancelled
Build and deploy documentation / publish (push) Has been cancelled
Some checks failed
Set up binary cache / cachix (default) (push) Has been cancelled
Set up binary cache / cachix (maximal) (push) Has been cancelled
Set up binary cache / cachix (nix) (push) Has been cancelled
Treewide Checks / Validate flake (push) Has been cancelled
Treewide Checks / Check formatting (push) Has been cancelled
Treewide Checks / Check source tree for typos (push) Has been cancelled
Treewide Checks / Validate documentation builds (push) Has been cancelled
Treewide Checks / Validate documentation builds-1 (push) Has been cancelled
Treewide Checks / Validate documentation builds-2 (push) Has been cancelled
Treewide Checks / Validate documentation builds-3 (push) Has been cancelled
Treewide Checks / Validate hyperlinks in documentation sources (push) Has been cancelled
Treewide Checks / Validate Editorconfig conformance (push) Has been cancelled
Build and deploy documentation / Check latest commit (push) Has been cancelled
Build and deploy documentation / publish (push) Has been cancelled
This commit is contained in:
parent
4d0d1884a0
commit
bd265fee7e
2 changed files with 45 additions and 2 deletions
|
|
@ -176,6 +176,9 @@
|
||||||
|
|
||||||
- Added Debugging support to `languages.php`.
|
- Added Debugging support to `languages.php`.
|
||||||
|
|
||||||
|
- Added Formatting support to `languages.php` via
|
||||||
|
[PHP-CS-Fixer](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer).
|
||||||
|
|
||||||
- Didn't Add
|
- Didn't Add
|
||||||
[`syntax-gaslighting`](https://github.com/NotAShelf/syntax-gaslighting.nvim),
|
[`syntax-gaslighting`](https://github.com/NotAShelf/syntax-gaslighting.nvim),
|
||||||
you're crazy.
|
you're crazy.
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,11 @@
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (builtins) attrNames toString toFile;
|
inherit (builtins) attrNames toString;
|
||||||
inherit (lib.options) mkEnableOption mkOption;
|
inherit (lib.options) mkEnableOption mkOption;
|
||||||
inherit (lib.meta) getExe;
|
inherit (lib.meta) getExe;
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.types) enum int attrs;
|
inherit (lib.types) enum int attrs listOf;
|
||||||
inherit (lib.nvim.lua) toLuaObject;
|
inherit (lib.nvim.lua) toLuaObject;
|
||||||
inherit (lib.nvim.types) mkGrammarOption deprecatedSingleOrListOf;
|
inherit (lib.nvim.types) mkGrammarOption deprecatedSingleOrListOf;
|
||||||
inherit (lib.nvim.attrsets) mapListToAttrs;
|
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||||
|
|
@ -65,6 +65,21 @@
|
||||||
root_markers = ["composer.json" ".git"];
|
root_markers = ["composer.json" ".git"];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
defaultFormat = ["php_cs_fixer"];
|
||||||
|
formats = {
|
||||||
|
php_cs_fixer = {
|
||||||
|
/*
|
||||||
|
Using 8.4 instead of 8.5 because of compatibility:
|
||||||
|
```logs
|
||||||
|
2026-02-08 00:42:23[ERROR] Formatter 'php_cs_fixer' error: PHP CS Fixer 3.87.2
|
||||||
|
PHP runtime: 8.5.2
|
||||||
|
PHP CS Fixer currently supports PHP syntax only up to PHP 8.4, current PHP version: 8.5.2.
|
||||||
|
```
|
||||||
|
*/
|
||||||
|
command = "${pkgs.php84Packages.php-cs-fixer}/bin/php-cs-fixer";
|
||||||
|
};
|
||||||
|
};
|
||||||
in {
|
in {
|
||||||
options.vim.languages.php = {
|
options.vim.languages.php = {
|
||||||
enable = mkEnableOption "PHP language support";
|
enable = mkEnableOption "PHP language support";
|
||||||
|
|
@ -84,6 +99,16 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
format = {
|
||||||
|
enable = mkEnableOption "PHP formatting" // {default = config.vim.languages.enableFormat;};
|
||||||
|
|
||||||
|
type = mkOption {
|
||||||
|
description = "PHP formatter to use";
|
||||||
|
type = listOf (enum (attrNames formats));
|
||||||
|
default = defaultFormat;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
dap = {
|
dap = {
|
||||||
enable = mkEnableOption "Enable PHP Debug Adapter" // {default = config.vim.languages.enableDAP;};
|
enable = mkEnableOption "Enable PHP Debug Adapter" // {default = config.vim.languages.enableDAP;};
|
||||||
xdebug = {
|
xdebug = {
|
||||||
|
|
@ -122,6 +147,21 @@ in {
|
||||||
cfg.lsp.servers;
|
cfg.lsp.servers;
|
||||||
})
|
})
|
||||||
|
|
||||||
|
(mkIf cfg.format.enable {
|
||||||
|
vim.formatter.conform-nvim = {
|
||||||
|
enable = true;
|
||||||
|
setupOpts = {
|
||||||
|
formatters_by_ft.php = cfg.format.type;
|
||||||
|
formatters =
|
||||||
|
mapListToAttrs (name: {
|
||||||
|
inherit name;
|
||||||
|
value = formats.${name};
|
||||||
|
})
|
||||||
|
cfg.format.type;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
})
|
||||||
|
|
||||||
(mkIf cfg.dap.enable {
|
(mkIf cfg.dap.enable {
|
||||||
vim = {
|
vim = {
|
||||||
debugger.nvim-dap = {
|
debugger.nvim-dap = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue