Skip to content
This repository has been archived by the owner on Apr 14, 2022. It is now read-only.

Implement format on type #5

Closed
MikhailArkhipov opened this issue Aug 31, 2018 · 4 comments
Closed

Implement format on type #5

MikhailArkhipov opened this issue Aug 31, 2018 · 4 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@MikhailArkhipov
Copy link

MikhailArkhipov commented Aug 31, 2018

microsoft/PTVS#4694

Implementation can be borrowed from
https://github.com/Microsoft/vscode-python/blob/master/src/client/formatters/lineFormatter.ts

translate to C#
change it to use LS tokenizer
augment with knowledge of the AST where appropriate (such as checking if = is inside function arguments)
See also microsoft/vscode-python#1799

@MikhailArkhipov
Copy link
Author

Reducing cost to actual for this milestone - basically to the PR review.

@jakebailey
Copy link
Member

Finished in #126.

@DonJayamanne
Copy link

DonJayamanne commented Feb 27, 2019

Would like to discuss this once again:

  • Today indentation of code is implemented within the extension (and buggy, as we do not have the AST information, etc)
  • The C# extension supports similar features (indentation changes) when you type the character }.
  • We need the same thing, when users type the character :.

The decision was get the extension to do the formatting.
However, if C# extension (using the language server) can do this, they why can't we do the same.

https://github.com/OmniSharp/omnisharp-vscode/blob/f0a0336ced8cb44f78bdee88120bfe9d62a596c0/src/features/formattingEditProvider.ts#L44

export async function formatAfterKeystroke(server: OmniSharpServer, request: protocol.FormatAfterKeystrokeRequest, token: vscode.CancellationToken) {
https://github.com/OmniSharp/omnisharp-vscode/blob/f0a0336ced8cb44f78bdee88120bfe9d62a596c0/src/omnisharp/utils.ts#L42

Related to microsoft/vscode-python#481

@MikhailArkhipov
Copy link
Author

MikhailArkhipov commented Feb 27, 2019

Could you please open separate issue. This one was explicitly about moving code from TS to C# and adding additional functionality. This item was completed.

Short answer: TS side does not have AST. I guess you are talking about smart indent as in using AST vs relying on regex?

Speaking of Omni, it is not using LSP. They have regular TS extension which then runs their process manually and communicates with it via custom protocol. This is not technically a language server at all. Omni was implemented way before LSP was born.

When actual LS/LSP runs the extension TS/editor part is bypassed and requests go directly to the LS process.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants