-
Notifications
You must be signed in to change notification settings - Fork 0
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
Is it possible to add to Format Document? #3
Comments
Hello. Yes, vscode allows extensions to register document formatters: https://code.visualstudio.com/api/references/vscode-api#DocumentFormattingEditProvider But there's still a caveat that you can use only one formatter for document (they're sorted by score). Will add this feature to TODOs. |
That won't really help then... I was thinking about adding it as a second step after my current formatter (which is Intelephense; actually, I saw you mention the question of use imports about a year ago or so in the issue queue there, I guess you made this plugin just because Intelephense doesn't offer it by itself). |
I can suggest you to use a command or assign a hotkey to command to format imports then. Also, I found that there is special code action for organizing imports in vscode API ( |
That's what I do but I have two shortcuts then, one for formatting the document, another one for yours. Come to think of it, what if you provided one more entry point in your plugin that calls whatever source formatter is currently defined in VSCode, and then call your own formatter? Then we could kill two birds with one stone... |
A little Googling revealed that we can create tasks in VSC to perform consecutive tasks. So I created this to perform both actions: {
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "cmd-mine-format-1",
"command": "${command:vscode-php-imports.format}"
},
{
"label": "cmd-mine-format-2",
"command": "${command:editor.action.formatDocument}"
},
{
"label": "cmd-mine-format",
"dependsOrder": "sequence",
"dependsOn": [
"cmd-mine-format-1",
"cmd-mine-format-2"
],
"problemMatcher": []
}
]
} This is just fine for me now but still, you might possibly consider the idea above. :-) |
Does VS Code allow the plugin to be linked to whatever code formatter you use with Format Document? It would be nice to do it in one step. I'm not sure it's possible but it would be very comfortable.
Yes, I'm aware of the possibility to do it on save but that doesn't work with auto save functionality added (it removes items before you get a chance to edit them).
The text was updated successfully, but these errors were encountered: