coc-php-cs-fixer v0.7.10
coc-php-cs-fixer
PHP CS Fixer (PHP Coding Standards Fixer) and Laravel Pint extension for coc.nvim
Install
:CocInstall coc-php-cs-fixer
Features
php-cs-fixer and laravel/pint are supported.
- Formatter
- Command
- Code Action
- Status Bar
pint.jsonAuto Completion and JSON validation- Downloader
Note
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.
{
"php-cs-fixer.activateTool": "pint"
}Detects the php-cs-fixer or pint tool. They are prioritized in order from the top.
php-cs-fixer.toolPathorphp-cs-fixer.pint.toolPathvendor/bin/php-cs-fixerorvendor/bin/pintphp-cs-fixerorpintretrieved by the download feature (:CocCommand php-cs-fixer.downloadorphp-cs-fixer.pintDownload)- php-cs-fixer:
- Mac/Linux:
~/.config/coc/extensions/coc-php-cs-fixer-data/php-cs-fixer - Windows:
~/AppData/Local/coc/extensions/coc-php-cs-fixer-data/php-cs-fixer
- Mac/Linux:
- pint:
- Mac/Linux:
~/.config/coc/extensions/coc-php-cs-fixer-data/pint - Windows:
~/AppData/Local/coc/extensions/coc-php-cs-fixer-data/pint
- Mac/Linux:
- php-cs-fixer:
If "1" and "2" above are not detected, the download feature will be executed (The prompt will be displayed)
Usage
coc-php-cs-fixer can be executed in multiple ways.
Auto run when saving a file
Add the settings to coc-settings.json.
{
"[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.
Run from CocCommand
- If the
php-cs-fixer.activateToolsetting isphp-cs-fixer:CocCommand php-cs-fixer.fix
- If the
php-cs-fixer.activateToolsetting ispint:CocCommand php-cs-fixer.pintFix
Run formatting from call function
:call CocAction('format')
Run codeAction from call function
:call CocAction('codeAction')- If the
php-cs-fixer.activateToolsetting isphp-cs-fixer- Choose action:
"Run: php-cs-fixer.fix"
- Choose action:
- If the
php-cs-fixer.activateToolsetting ispint- Choose action:
"Run: php-cs-fixer.pintFix"
- Choose action:
- If the
Precedence of "php-cs-fixer" and "laravel/pint" configuration files and options
php-cs-fixer
php-cs-fixer.configsetting for this extension..php-cs-fixer.phpor.php-cs-fixer.dist.phpconfig file in the workspace (project) root.- options-reated settings for this extension. e.g.
php-cs-fixer.rulesand more.
pint
php-cs-fixer.pint.configsetting for this extension.pint.jsonconfig file in the workspace (project) root.- options-reated settings for this extension.
php-cs-fixer.pint.preset.
Configuration options
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 variablePHP_CS_FIXER_IGNORE_ENV=1and run php-cs-fixer, default:falsephp-cs-fixer.pint.toolPath: The path to the pint tool, default:""php-cs-fixer.pint.config: Path topint.jsonconfig 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: Ifphp-cs-fixerorpintis not present at startup, run the built-in download. The tool to be downloaded will follow thephp-cs-fixer.activateToolconfiguration, 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
Commands
php-cs-fixer.fix: Run php-cs-fixer fixphp-cs-fixer.dryRunDiff: Run php-cs-fixer fix with--dry-runand--diffin a terminal window | DEMOphp-cs-fixer.pintFix: Run pintphp-cs-fixer.pintTest: Run pint with--testin a terminal window | DEMOphp-cs-fixer.download: Download php-cs-fixer- By default, the "v3" series will be downloaded. If you want to download "v2" series, please change the
php-cs-fixer.downloadMajorVersionsetting.
- By default, the "v3" series will be downloaded. If you want to download "v2" series, please change the
php-cs-fixer.pintDownload: Download pintphp-cs-fixer.showOutput: Show php-cs-fixer output channel
Code Actions
Run: php-cs-fixer.fixRun: php-cs-fixer.pintFix
Thanks
- https://github.com/FriendsOfPHP/PHP-CS-Fixer
- https://github.com/laravel/pint
- https://github.com/mlocati/php-cs-fixer-configurator
- https://github.com/open-southeners/vscode-laravel-pint
License
MIT
This extension is built with create-coc-extension
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago