Skip to main content
Back to Extensions Directory
coc.nvim fallback icon

coc-php-cs-fixer

yaegassy

PHP CS Fixer (PHP Coding Standards Fixer) and Laravel Pint extension for coc.nvim

Installation CommandVim prompt
:CocInstall coc-php-cs-fixer
GitHub owner
yaegassy
Version
v0.7.10
npm package
coc-php-cs-fixer
Requirements
coc ^0.0.80
License
MIT
Repository
GitHub
npm latest published 2024-03-30Registry checked 2026-08-23Registry summary

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.json Auto 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.

  1. php-cs-fixer.toolPath or php-cs-fixer.pint.toolPath
  2. vendor/bin/php-cs-fixer or vendor/bin/pint
  3. php-cs-fixer or pint retrieved by the download feature (:CocCommand php-cs-fixer.download or php-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
    • pint:
      • Mac/Linux: ~/.config/coc/extensions/coc-php-cs-fixer-data/pint
      • Windows: ~/AppData/Local/coc/extensions/coc-php-cs-fixer-data/pint

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.activateTool setting is php-cs-fixer
    • :CocCommand php-cs-fixer.fix
  • If the php-cs-fixer.activateTool setting is pint
    • :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.activateTool setting is php-cs-fixer
      • Choose action: "Run: php-cs-fixer.fix"
    • If the php-cs-fixer.activateTool setting is pint
      • Choose action: "Run: php-cs-fixer.pintFix"

Code Actions

  • Run: php-cs-fixer.fix
  • Run: php-cs-fixer.pintFix

Thanks

License

MIT


This extension is built with create-coc-extension

Read the complete README
  • PHP CS Fixer (PHP Coding Standards Fixer) and Laravel Pint extension for coc.nvim
Activation Events
  • onLanguage:php
Developer Resources

Want to build, test, or contribute to coc.nvim extensions? Explore our official SDK and testing toolkits.

Open Developer Guide

Version 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.