-
Notifications
You must be signed in to change notification settings - Fork 89
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
[FEATURE] Respect identation settings when doing Format Document #93
Comments
How i can format file with tabs? |
Formatting is done by PHP CodeSniffer, please refer to its documentation for configuring it. |
@felixfbecker I failed to see how configuring PHP CodeSniffer to use vscode configuration can/should be done outside this vscode plugin. I'm reading the PHP CodeSniffer tab documentation but can't see how I can influence Please advise. |
See the LS itself for an example: https://github.com/felixfbecker/php-language-server/blob/master/phpcs.xml.dist |
As I see it, vscode-php-intellisense needs a patch to forward vscode settings to php-language-server. Unfortunately, I don't have time to implement this. But 🥇 to who-ever who do it! :) |
um, no. As said, you can use an XML file already, which can be read by more than just VS Code. If any patch is required, it would be needed in the language server. |
I don't get it. Why would I want to maintain a separate xml file, with the same settings as in vscode for php-language-server? If I want to change my vscode settings in one project, I would expect the php intellisense to honor my settings. In vscode: // Place your settings in this file to overwrite the default settings
{
// The number of spaces a tab is equal to.
"editor.tabSize": 2,
// Insert spaces when pressing Tab.
"editor.insertSpaces": true
} Don't know the file location of user/workspace settings Somewhere in my project (don't know the location for php-language-server xml config in my project): <?xml version="1.0"?>
<ruleset name="PHP Language Server">
<file>src</file>
<file>tests</file>
<rule ref="PSR2">
<exclude name="PSR2.Namespaces.UseDeclaration.MultipleDeclarations"/>
<exclude name="PSR2.ControlStructures.ElseIfDeclaration.NotAllowed"/>
<exclude name="PSR2.ControlStructures.ControlStructureSpacing.SpacingAfterOpenBrace"/>
</rule>
</ruleset> How do I set |
There is a need for vscode-php-intellisense to forward vscode settings to php-language-server. |
Why? Because the vscode settings are only read by vscode. On a serious project you will likely have CI where you want to run linting. CodeSniffer can read your XML file then too, when running as a command in CI. "Forwarding" the vscode settings to the language server is not the complicated part, that is already done through |
I understand your hesitation to cater for vscode in php-language-server, but couldn't vscode-php-intellisense transform the JSON settings to the XML format php-language-server understand? I'm afraid I can't find how |
Are you proposing the vscode extension should write an XML file into your workspace? |
I would have to understand how vscode-php-intellisense can communicate to php-language-server and if the All I'm saying is that, settings in vscode should be honored by php-language-server, so that I as a vscode user, only need to make my project (user/workspace) configurations in one place - which seems to naturally be in vscode. Regardless of where vscode and php-language-server stores its configuration files. I'm sorry but I lack deep understanding of both vscode-php-intellisense and php-language-server to propose an implementation. I'm only making a feature request and I'm still bewildered about how I would even set this up manually. |
What is the problem with creating a CodeSniffer XML config file in your workspace? Your vscode config will not be read by anything but vscode, so it clearly is not the suitable location for "only needing to make my project (user/workspace) configurations in one place" |
Maybe I'm misunderstanding the use-case for vscode-php-intellisense. I thought it was only to facilitate PHP development in vscode. Why should I have to understand CodeSniffer XML configuration in order to use vscode-php-intellisense? Anyway, it was only a request. Feel free to ignore it. I'll just stay away from the code formatting feature. |
How exactly has a I tried adding Like this: <?xml version="1.0"?>
<ruleset name="PHP Language Server Custom">
<arg name="tab-width" value="2"/>
<file>src</file>
<file>tests</file>
<exclude-pattern>tests/Validation/cases</exclude-pattern>
<rule ref="PSR2">
<exclude name="PSR2.Namespaces.UseDeclaration.MultipleDeclarations"/>
<exclude name="PSR2.ControlStructures.ElseIfDeclaration.NotAllowed"/>
<exclude name="PSR2.ControlStructures.ControlStructureSpacing.SpacingAfterOpenBrace"/>
<exclude name="Squiz.WhiteSpace.ControlStructureSpacing.SpacingBeforeClose"/>
<exclude name="Squiz.WhiteSpace.ControlStructureSpacing.SpacingAfterOpen"/>
</rule>
</ruleset> It seems to be loaded. But it still uses 4 spaces for indentation. |
When I do Format Document the tab size is always 4 even though I've set
"editor.tabSize": 2
.Also it appears that I can not format only the selected text but have to format the entire document.
See the screen shot:
The text was updated successfully, but these errors were encountered: