Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add "laravel/pint" integration feature #7

Merged
merged 2 commits into from
Jul 5, 2022
Merged

Conversation

yaegassy
Copy link
Owner

@yaegassy yaegassy commented Jul 5, 2022

Description

Added ability to use laravel/pint as a formatter.

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"
}

Add Configration

  • php-cs-fixer.activateTool: Formatter tool to be used, valid option ["php-cs-fixer", "pint"], default: "php-cs-fixer"
  • php-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"

Add Command

  • php-cs-fixer.pintFix: Run pint
  • php-cs-fixer.pintDownload: Download pint

Add Code Action

  • Run: php-cs-fixer.pintFix

Add Completion and JSON validation

  • pint.json Auto Completion and JSON validation

DEMO (mp4)

coc-php-cs-fixer-pint.mp4

Note

Tool detection

Detects the pint tool. They are prioritized in order from the top.

  1. php-cs-fixer.pint.toolPath
  2. vendor/bin/pint
  3. pint retrieved by the download feature (:CocCommand php-cs-fixer.pintDownload`)
    • 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)

Precedence of "laravel/pint" configuration files and options

  1. php-cs-fixer.pint.config setting for this extension.
  2. pint.json config file in the workspace (project) root.
  3. options-reated settings for this extension. php-cs-fixer.pint.preset.

@yaegassy yaegassy merged commit 1559ffd into master Jul 5, 2022
@yaegassy yaegassy deleted the feat/laravel-pint branch July 5, 2022 01:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant