coc-php-cs-fixer
yaegassyPHP CS Fixer (PHP Coding Standards Fixer) and Laravel Pint extension for coc.nvim
Published Package Summary
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
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
- PHP CS Fixer (PHP Coding Standards Fixer) and Laravel Pint extension for coc.nvim
- onLanguage:php
Want to build, test, or contribute to coc.nvim extensions? Explore our official SDK and testing toolkits.
Open Developer GuideVersion History
This published npm package does not include a history.md or changelog.md file. Browse its npm versions or repository releases for available release information.
Contributed Commands
All contributes.commands entries from the published package manifest for coc-php-cs-fixer@0.7.10.
| Command (:CocCommand) | Description |
|---|---|
| php-cs-fixer.fix | Run php-cs-fixer fix |
| php-cs-fixer.dryRunDiff | Run php-cs-fixer fix with --dry-run and --diff in a terminal window |
| php-cs-fixer.pintFix | Run pint |
| php-cs-fixer.pintTest | Run pint with --test in a terminal window |
| php-cs-fixer.download | Download php-cs-fixer |
| php-cs-fixer.pintDownload | Download pint |
| php-cs-fixer.showOutput | Show php-cs-fixer output channel |
Configuration Schema
All contributes.configuration entries from the published package manifest, including each raw property schema for coc-settings.json.
Raw JSON Schema
{
"type": "string",
"default": "@PSR12",
"description": "Rules to use when fixing files (--rules)"
}Raw JSON Schema
{
"type": "string",
"default": "",
"description": "Path to php-cs-fixer config file (--config)"
}Raw JSON Schema
{
"type": "boolean",
"default": true,
"description": "Enable coc-php-cs-fixer extension"
}Raw JSON Schema
{
"type": "string",
"default": "",
"description": "The path to the php-cs-fixer tool"
}Raw JSON Schema
{
"type": "boolean",
"default": false,
"description": "Use a cache file when fixing files (--using-cache)"
}Raw JSON Schema
{
"type": "boolean",
"default": false,
"description": "Are risky fixers allowed (--allow-risky)"
}Raw JSON Schema
{
"type": "string",
"default": "",
"description": "Path to pint.json config file (--config)"
}Raw JSON Schema
{
"enum": [
"laravel",
"psr12",
"symfony"
],
"type": "string",
"default": "laravel",
"description": "Presets define a set of rules that can be used to fix code style issues in your code (--preset)"
}Raw JSON Schema
{
"enum": [
"php-cs-fixer",
"pint"
],
"type": "string",
"default": "php-cs-fixer",
"description": ""
}Raw JSON Schema
{
"type": "string",
"default": "",
"description": "The path to the pint tool"
}Raw JSON Schema
{
"type": "boolean",
"default": false,
"description": "Add the environment variable PHP_CS_FIXER_IGNORE_ENV=1 and run php-cs-fixer"
}Raw JSON Schema
{
"enum": [
2,
3
],
"type": "number",
"scope": "window",
"default": 3,
"description": "Specify the major version of php-cs-fixer to download for the extension"
}Raw JSON Schema
{
"type": "boolean",
"default": true,
"description": "Enable codeAction provider"
}Raw JSON Schema
{
"type": "boolean",
"default": true,
"description": "Enable format provider"
}Raw JSON Schema
{
"type": "boolean",
"default": true,
"description": "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"
}Raw JSON Schema
{
"type": "boolean",
"default": false,
"description": "Use vertical belowright for dryRunDiff and pintTest terminal window"
}