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

formatDocument #8

Closed
felixfbecker opened this issue Sep 2, 2016 · 4 comments
Closed

formatDocument #8

felixfbecker opened this issue Sep 2, 2016 · 4 comments
Labels

Comments

@felixfbecker
Copy link
Owner

It can use the PHPParser's pretty printer

@mniewrzal
Copy link
Contributor

Method 'textDocument/formatting' needs as response TextEdit array. PHPParser's pretty printer returns always formatted string and simplest solution is to create one TextEdit to replace whole document. If you don't plan to implement it in near future I can try to do this :) or maybe you have different idea how utilize PHPParser.

@felixfbecker
Copy link
Owner Author

Yes, I think that is the easiest solution. We currently also sync all textdocuments with full content, it doesn't seem to have significant perf impact, but it reduces complexity. We can adjust the implementation later.

Using PHPParser is of course not required for this, we could look at other formatting tools for PHP. But we already have the AST, so it is easier to just use the formatter, and the pretty printer comes included.

I'm super short on free time atm so yeah I would be more than happy if you implement it :)

@mniewrzal
Copy link
Contributor

I was looking for alternative but I didn't found anything actively developed/maintained. For now PHPParser's pretty printer is easy to use but is not customizable. I think it will be easy to replace it with different formatting library if something will came up in the future.

@felixfbecker
Copy link
Owner Author

We could customize it by subclassing it. Or doing a PR to support some options :)
But I would like to get basic features out as quick as possible, customization can be added later.

mniewrzal pushed a commit to mniewrzal/php-language-server that referenced this issue Sep 5, 2016
mniewrzal pushed a commit to mniewrzal/php-language-server that referenced this issue Sep 5, 2016
mniewrzal pushed a commit to mniewrzal/php-language-server that referenced this issue Sep 5, 2016
mniewrzal pushed a commit to mniewrzal/php-language-server that referenced this issue Sep 5, 2016
mniewrzal pushed a commit to mniewrzal/php-language-server that referenced this issue Sep 6, 2016
mniewrzal pushed a commit to mniewrzal/php-language-server that referenced this issue Sep 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants