README
coc-php-cs-fixer
PHP CS Fixer (PHP Coding Standards Fixer) extension for coc.nvim
Install
:CocInstall coc-php-cs-fixer
Note
Detects the php-cs-fixer command. They are prioritized in order from the top.
php-cs-fixer.toolPathvendor/bin/php-cs-fixerphp-cs-fixerretrieved by the download feature (:CocCommand php-cs-fixer.download)- 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:
If "1" and "2" above are not detected, the download feature will be executed (The prompt will be displayed)
Usage
Format document
Run from CocCommand:
:CocCommand php-cs-fixer.fix
If "php-cs-fixer.enableActionProvider" is "true" (default: true):
:call CocAction('codeAction')-> Choose action: "Run: php-cs-fixer.fix"
If "php-cs-fixer.enableFormatProvider" is "true" (default: false):
:call CocAction('format')
Configuration options
php-cs-fixer.enable: Enable coc-php-cs-fixer extension, 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.enableActionProvider: Enable codeAction provider, default:truephp-cs-fixer.enableFormatProvider: Enable format provider, default:falsephp-cs-fixer.toolPath: The path to the php-cs-fixer tool (Absolute path), 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.config: Path to a.php_csor.php-cs-fixer.phpfile (--config), default:""php-cs-fixer.rules: Rules to use when fixing files (--rules), e.g."@PSR12,@Symfony", default:"@PSR12"
Commands
php-cs-fixer.fix: Run php-cs-fixer fixphp-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
Code Actions
Run: php-cs-fixer.fix
TIPS
Using with other coc extensions
Run from "Code Action" or ":CocCommand" is recommended because it can be used together without any problem even if another coc extension provides the formatting.
- For example, coc-intelephense + coc-php-cs-fixer
- For example, coc-phpls + coc-php-cs-fixer
Equivalent to "organize imports"
The intelephense does not currently support "organize imports".
You can add a configuration equivalent to "organize imports" in php-cs-fixer to handle this.
coc-settings.json:
{
// ...snip
"php-cs-fixer.rules": "@PSR12,ordered_imports,no_unused_imports",
// ...snip
}
License
MIT
This extension is built with create-coc-extension