Implement on-type block formatting #165
Description
The VS Code extension provides an on-type formatter that triggers on : which allows for block formatting. For example, you can hit colon after the else in the following code:
if x:
pass
elseWhich will then be reformatted into:
if x:
pass
else:This functionality should be implemented in language server for feature parity. The language server may even be able to handle more cases correctly than the extension's use of regex, since we have access to an AST.
Since on-type formatting has only one entrypoint (DocumentOnTypeFormatting), that function would need to map trigger characters to the right handler. A nicety would be to have a Dictionary of handlers, then produce the DocumentOnTypeFormattingOptions's trigger character members from that dictionary rather than needing to remember to change the characters in two different files.
Related to microsoft/vscode-python#2714.
Activity
Turn off on type formatting until #165 is done.
MikhailArkhipov commentedon Oct 8, 2018
Also these
microsoft/vscode-python#481
microsoft/vscode-python#684
Enable on-type formatting from language server (#2737)
Turn off on type formatting until microsoft#165 is done.