HvyIndustries / crane

PHP Intellisense/code-completion for VS Code
https://hvy.io/crane
Other
240 stars 25 forks source link

Code formatter #256

Open ichiriac opened 7 years ago

ichiriac commented 7 years ago

Integrate https://github.com/glayzzle/php-unparser as external library in order to format back PHP code.

This library consume php-parser AST tree and builds back the PHP formatting with proper indentation. Can try here an old online version : https://chris-l.github.io/php-unparser/.

Actually supported options :

As the formatting is based on AST, the simplest is to re-format all the file.

Note : Could be possible to format only a portion of code by scanning all the file, using offsets to identify the root node, and then pass it on the formatter - this way is hard to implement and with edge cases


ToDo :

ichiriac commented 7 years ago

Could also include this topic : (Format Line on Type Provider https://github.com/HvyIndustries/crane/issues/214) - the formating would be based on the same configuration for space indentation.

davidsielert commented 6 years ago

Couldn't it be provided as a VS Code Document Formatter instead of a custom shortcut ?