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

Implement auto indentation when pressing the : or Enter keys #671

Closed

Description

  • Today indentation of code is implemented within the extension (and buggy, as we do not have the token/AST information, etc)
  • The C# extension supports similar features (indentation changes) when you type the character }.
    • The C# extension is TS code, that sends requests to a .NET process over a protocol.
    • I.e. .NET is performing the necessary formatting, and sending back the formatted code (asynchronously) back to the TS code.
  • We need the same thing, when users type the character :.
    • I.e. TS can send a custom request to language server, get the response back and send formatted code to VSC.

I.e. if C# extension (using the .NET code, async communication via a protocol) can do this, then how about we do the same thing (using LSP over custom request).

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

Activity

  1. MikhailArkhipov commented on Feb 27, 2019

    @MikhailArkhipov

    Omni 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.

    Therefore what you are asking is a way to get to LS while actually VS Code did not launch it. This can be done at the extension side - start the process and perform similar connection hookup as VS Code performs internally in regular LS scenarios. Then send and receive requests either via LSP or via custom messages.

    This is basically a hybrid solution. There may be other cases such as get syntax errors from the parser without actually switching to LS.

  2. DonJayamanne commented on Feb 27, 2019

    @DonJayamanne
    Author

    Omni 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.

    Agreed. I just see it as a separate process that ts extension communicates over some protocol.

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

    Yes, but we can still send custom requests via the language client, and that's the plan. No changes.

    Therefore what you are asking is a way to get to LS while actually VS Code did not launch it.

    No, we'll let VSC launch the language server as done today. No changes there.
    All, we'll do is use the language client and send a request (we already do this today), so architecturally, no changes.
    The only exception would be we'd probably send a custom request to the LSP.
    FYI - we already send requests manually to LS from extension code manually.

    This is basically a hybrid solution. There may be other cases such as get syntax errors from the parser without actually switching to LS.

    Not really, we'll only do this for language server, and not when using Jedi.
    We will not change how LS is loaded.

  3. MikhailArkhipov commented on Feb 27, 2019

    @MikhailArkhipov

    No, we'll let VSC launch the language server as done today. No changes there.

    Do you still get requests for the editor functionality when LS is running?

  4. DonJayamanne commented on Feb 27, 2019

    @DonJayamanne
    Author

    Do you still get requests for the editor functionality when LS is running?

    Not sure what you mean. But we have the ability to manually send requests to the LS, and we do this today.

  5. MikhailArkhipov commented on Feb 27, 2019

    @MikhailArkhipov

    I mean that when LS is up you don't get requests for completion, tooltips, etc in the TS part, they bypass the extension and go straight to LS. I.e. TS 'completion provider' is mute. Do you still get requests for the indentation?

  6. DonJayamanne commented on Feb 27, 2019

    @DonJayamanne
    Author

    Do you still get requests for the indentation?

    Got it. No that doesn't work.
    Also double check with C#, the auto indentation of } is done by VSC and not C#.
    I.e. disabling formatOnType doesn't provide what we need.
    Back to square one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions