PHP CS Fixer (PHP Coding Standards Fixer) and Laravel Pint extension for coc.nvim
npm install coc-php-cs-fixerPHP CS Fixer (PHP Coding Standards Fixer) and Laravel Pint extension for coc.nvim
:CocInstall coc-php-cs-fixer
php-cs-fixer and laravel/pint are supported.
- Formatter
- Command
- Code Action
- Status Bar
- pint.json Auto Completion and JSON validation
- Downloader
The formatter tool used is php-cs-fixer by default. If you want to use laravel/pint, change the php-cs-fixer.activateTool setting in coc-settings.json.
``json`
{
"php-cs-fixer.activateTool": "pint"
}
- DEMO
---
Detects the php-cs-fixer or pint tool. They are prioritized in order from the top.
1. php-cs-fixer.toolPath or php-cs-fixer.pint.toolPathvendor/bin/php-cs-fixer
1. or vendor/bin/pintphp-cs-fixer
1. or pint retrieved by the download feature (:CocCommand php-cs-fixer.download or php-cs-fixer.pintDownload)~/.config/coc/extensions/coc-php-cs-fixer-data/php-cs-fixer
- php-cs-fixer:
- Mac/Linux: ~/AppData/Local/coc/extensions/coc-php-cs-fixer-data/php-cs-fixer
- Windows: ~/.config/coc/extensions/coc-php-cs-fixer-data/pint
- pint:
- Mac/Linux: ~/AppData/Local/coc/extensions/coc-php-cs-fixer-data/pint
- Windows:
If "1" and "2" above are not detected, the download feature will be executed (The prompt will be displayed)
coc-php-cs-fixer can be executed in multiple ways.
Add the settings to coc-settings.json.
`jsonc`
{
"[php]": {
"coc.preferences.formatOnSave": true
},
}
If the file size is large or the tool (php-cs-fixer or pint) is slow in your environment, formatting may not work properly when saving. In coc.nvim, time-consuming formatting on save is canceled.
In that case, please perform the formatting in another way.
- If the php-cs-fixer.activateTool setting is php-cs-fixer:CocCommand php-cs-fixer.fix
- php-cs-fixer.activateTool
- If the setting is pint:CocCommand php-cs-fixer.pintFix
-
- :call CocAction('format')
- :call CocAction('codeAction')php-cs-fixer.activateTool
- If the setting is php-cs-fixer"Run: php-cs-fixer.fix"
- Choose action: php-cs-fixer.activateTool
- If the setting is pint"Run: php-cs-fixer.pintFix"
- Choose action:
1. php-cs-fixer.config setting for this extension..php-cs-fixer.php
2. or .php-cs-fixer.dist.php config file in the workspace (project) root.php-cs-fixer.rules
3. options-reated settings for this extension. e.g. and more.
1. php-cs-fixer.pint.config setting for this extension.pint.json
2. config file in the workspace (project) root.php-cs-fixer.pint.preset
3. options-reated settings for this extension. .
- php-cs-fixer.enable: Enable coc-php-cs-fixer extension, default: truephp-cs-fixer.activateTool
- : Formatter tool to be used, valid option ["php-cs-fixer", "pint"], default: "php-cs-fixer"php-cs-fixer.toolPath
- : The path to the php-cs-fixer tool, default: ""php-cs-fixer.config
- : Path to php-cs-fixer config file (--config), default: ""php-cs-fixer.useCache
- : Use a cache file when fixing files (--using-cache), default: falsephp-cs-fixer.allowRisky
- : Determines whether risky rules are allowed (--allow-risky), default: falsephp-cs-fixer.rules
- : Rules to use when fixing files (--rules), e.g. "@PSR12,@Symfony", default: "@PSR12"php-cs-fixer.enableIgnoreEnv
- : Add the environment variable PHP_CS_FIXER_IGNORE_ENV=1 and run php-cs-fixer, default: falsephp-cs-fixer.pint.toolPath
- : The path to the pint tool, default: ""php-cs-fixer.pint.config
- : Path to pint.json config file (--config), default: ""php-cs-fixer.pint.preset
- : Presets define a set of rules that can be used to fix code style issues in your code (--preset), valid option ["laravel", "psr12", "symfony"], default: "laravel"php-cs-fixer.downloadCheckOnStartup
- : If php-cs-fixer or pint is not present at startup, run the built-in download. The tool to be downloaded will follow the php-cs-fixer.activateTool configuration, default: truephp-cs-fixer.downloadMajorVersion
- : Specify the major version of php-cs-fixer to download for the extension, valid option [2, 3], default: 3php-cs-fixer.enableFormatProvider
- : Enable format provider, default: truephp-cs-fixer.enableActionProvider
- : Enable codeAction provider, default: truephp-cs-fixer.terminal.enableSplitRight
- : Use vertical belowright for dryRunDiff and pintTest terminal window, default: false
- php-cs-fixer.fix: Run php-cs-fixer fixphp-cs-fixer.dryRunDiff
- : Run php-cs-fixer fix with --dry-run and --diff in a terminal window | DEMOphp-cs-fixer.pintFix
- : Run pintphp-cs-fixer.pintTest
- : Run pint with --test in a terminal window | DEMOphp-cs-fixer.download
- : Download php-cs-fixerphp-cs-fixer.downloadMajorVersion
- By default, the "v3" series will be downloaded. If you want to download "v2" series, please change the setting.php-cs-fixer.pintDownload
- : Download pintphp-cs-fixer.showOutput
- : Show php-cs-fixer output channel
- Run: php-cs-fixer.fixRun: php-cs-fixer.pintFix`
-
-
-
-
-
MIT
---
> This extension is built with create-coc-extension