Comments (14)
I abandon my previous PR for CS-Fixer. I created PR #35 with PHPCBF integration. PHPCBF formatting looks slightly better and performance is good even with XDebug enabled. Like CS-Fixer it has some gaps to fill (e.g. whitespaces in namespace declaration) but I think it will be easier to add missing rules than writing formatter from scratch (e.g. based on PrettyPrinter).
from php-language-server.
Range formatting is probably less problematic than lack of configuration. PrettyPrinter should be able to format just selected range if user will select complete AST node. To make it configurable we need to extend it and add own logic.
I will take a look at CS Fixer and PHPCBF.
from php-language-server.
Yes, I understand. I just wanted to say that without hope for better performance I didn't see a chance for using cs-fixer with language server. Actual implementation is too messy to make PR from it ;)
from php-language-server.
This early implementation of the formatting feature is using he standard PrettyPrinter
of PHPParser: https://github.com/nikic/PHP-Parser/blob/master/lib/PhpParser/PrettyPrinter/Standard.php.
I am also not satisfied with the output, for example how it handles use
and declare
statements and the empty lines. I'm sure the class can be customized more. We could
- do a PR to PHPParser to allow customizing of the PrettyPrinter
- subclass it to customize it
contributions welcome!
from php-language-server.
I heard from @mniewrzal that the PrettyPrinter can't be used for range formatting, but only for formatting the whole document.
I wonder if we can use either the CS Fixer or PHPCBF. AFAIK they already support a variety of coding standards.
I am not sure if they are better for range formatting, but perhaps it's worth taking a look.
from php-language-server.
I played with CS Fixer today and I was able to use it with language server. If someone want to take a look here is branch with changes. Its just a fast hack ;-)
Pros:
- configurable
- workspace can contain configuration file .php_cs, no need for additional configuration through language server protocol
- quite easy to integrate
Cons:
- can be very slow, with enabled xdebug formatting 1600 LOC can take more than 10s, The same operation without xdebug takes under 1s.
from php-language-server.
@mniewrzal always feel free to open a PR, it is a nice way to start a discussion :)
can be very slow, with enabled xdebug formatting 1600 LOC can take more than 10s, The same operation without xdebug takes under 1s.
I would like to implement some solution in the client that spawns the language server without XDebug, XDebug is performance killer. Some ideas here: http://stackoverflow.com/questions/38506140/how-to-run-composer-without-xdebug-when-installed-with-homebrew
On startup, read the php.ini, remove lines containing "xdebug", write to temp folder, start php with the ini file.
from php-language-server.
@mniewrzal always feel free to open a PR, it is a nice way to start a discussion :)
If there is an option to overcome xdebug performance issue making such PR make sense :) I will prepare something soon.
from php-language-server.
I meant that I prefer to discuss changes on an open PR that is not yet finished, because you can better comment on the changes, even when it won't get merged in the current state of the branch :)
from php-language-server.
@mniewrzal can you check what is the performance impact if having Zend Debugger instead of Xdebug?
from php-language-server.
PHP CS Fixer times for https://github.com/composer/composer/blob/master/src/Composer/Installer.php:
- no debugger: ~0.9s
- zenddebugger: ~1.3s
- xdebug: ~4.4s
from php-language-server.
Solved with PHP_CodeSniffer
from php-language-server.
And how to configure the formatting now?
Can you give an example?
from php-language-server.
Please refer to the PHP CodeSniffer documentation on how to configure it with an XML file - you can also find one in this repository
from php-language-server.
Related Issues (20)
- VS Code error
- PHP intelisense not working with MacOS 11.3
- open source funding available from Gitpod
- Keep getting alert for PHP 7
- Intellisense is "Unable to open" "Unable to read file" "Error: Unable to resolve non-existing file" after a directory is renamed in PHP Project HOT 1
- not found LanguageServer\StderrLogger
- Extension causes high cpu load
- Language Server Crashing and VS Code is hanged when opening Laravel 8 project with PHP 8.0 HOT 1
- File Copy Participants never finishes
- [Feature request] Autocomplete `$variable` without needing to type the `$`
- [FEATURE] Autocomplete classes in PHP DocBlock
- Requirements could not be resolved.
- New Issue HOT 1
- PHP language server crash in VS Code HOT 1
- __callStatic via trait not absorbed HOT 1
- Plugin Not Starting? - Help me please HOT 1
- more open source funding available from Gitpod HOT 1
- PHP (felixfbecker) language server has excited and exceeded the restart limit HOT 4
- "type is missing before a type separator" HOT 2
- is a malware????
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-language-server.