eclipse/aCute

Code formatting not implemented?

Opened this issue · 6 comments

norru commented

Right-click + Format on a .cs source code file is grayed out. Is it a missing feature? Does aCute require external software to have the Format option active?

aCute includes OmniSharp as language server that may ship support for Format.
Looking into the LSP logs (accessible from preferences) you can see the format serverCapability is set.
If not, you can use one of the possible hacks in https://github.com/eclipse/aCute/blob/master/org.eclipse.acute/src/org/eclipse/acute/OmnisharpStreamConnectionProvider.java#L65 to try another version of OmniSharp and report whether it works and submit a pull request for it.

norru commented
[t=1571909712357] LSP4E to org.eclipse.acute.omnisharp:
{"jsonrpc":"2.0","id":"1","method":"initialize","params":{"processId":22534,"rootPath":"/home/norru/Projects/ivt/dotnet_test/","rootUri":"file:///home/norru/Projects/ivt/dotnet_test/","capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true,"resourceOperations":["create","delete","rename"],"failureHandling":"undo"},"symbol":{"dynamicRegistration":true},"executeCommand":{"dynamicRegistration":true},"workspaceFolders":true},"textDocument":{"synchronization":{"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"completionItem":{"snippetSupport":true}},"hover":{},"signatureHelp":{},"references":{},"documentHighlight":{},"documentSymbol":{"symbolKind":{"valueSet":[18,17,5,14,9,10,22,24,8,1,12,11,20,6,2,3,21,16,19,25,4,7,15,23,26,13]},"hierarchicalDocumentSymbolSupport":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{},"definition":{"linkSupport":true},"typeDefinition":{"linkSupport":true},"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},"dynamicRegistration":true},"codeLens":{},"documentLink":{},"colorProvider":{},"rename":{}}},"clientName":"Eclipse IDE","trace":"off"}}
[t=1571909712619] org.eclipse.acute.omnisharp to LSP4E:
{"protocolVersion":"2.0","method":"window/logMessage","params":{"type":4,"message":"Starting server..."}}
[t=1571909713397] org.eclipse.acute.omnisharp to LSP4E:
{"protocolVersion":"2.0","method":"window/logMessage","params":{"type":4,"message":"Added handlers... waiting for initialize..."}}
[t=1571909713441] org.eclipse.acute.omnisharp to LSP4E:
{"protocolVersion":"2.0","id":"1","result":{"capabilities":{"textDocumentSync":{"openClose":true,"change":2,"willSave":false,"willSaveWaitUntil":false,"save":{"includeText":true}},"hoverProvider":true,"completionProvider":{"resolveProvider":false},"signatureHelpProvider":{},"definitionProvider":true,"referencesProvider":false,"documentHighlightProvider":false,"documentSymbolProvider":true,"workspaceSymbolProvider":false,"codeActionProvider":false,"documentFormattingProvider":false,"documentRangeFormattingProvider":false,"renameProvider":true,"experimental":{}}}}
[t=1571909713449] LSP4E to org.eclipse.acute.omnisharp:
Content-Length: 52


[t=1571909713449] LSP4E to org.eclipse.acute.omnisharp:
{"jsonrpc":"2.0","method":"initialized","params":{}}

org.eclipse.acute.omnisharp to LSP4E: [...] "documentFormattingProvider":false,"documentRangeFormattingProvider":false [...]

and not dynamic registration is sent later => LS limitation; try newer OmniSharp

norru commented

No luck with newest Omnisharp, I can't even run it from the CLI.

Bear in mind I am not familiar with .NET Core (yet).

dotnet ./OmniSharp.exe
A fatal error was encountered. The library 'libhostpolicy.so' required to execute the application was not found in '/opt/omnisharp-dist/omnisharp/'.
Failed to run as a self-contained app. If this should be a framework-dependent app, add the /opt/omnisharp-dist/omnisharp/OmniSharp.runtimeconfig.json file specifying the appropriate framework.

I have created this issue OmniSharp/omnisharp-roslyn#1639

Any chance that an aCute maintainer can look into upgrading the embedded version into something more modern? This project has had no activity since April.

norru commented

Oh it does look like I need Mono - never mind then.

norru commented

Actually I did manage to install mono and the latest version of OmniSharp.

Now the "Format" command appears but has no effect. Here's the affected log:

[t=1571933271588] LSP4E to org.eclipse.acute.omnisharp:
Content-Length: 198


[t=1571933271588] LSP4E to org.eclipse.acute.omnisharp:
{"jsonrpc":"2.0","id":"19","method":"textDocument/formatting","params":{"textDocument":{"uri":"file:///home/norru/Projects/ivt/dotnet_test/Program.cs"},"options":{"tabSize":4,"insertSpaces":false}}}
[t=1571933271589] org.eclipse.acute.omnisharp to LSP4E:
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Finding descriptor for textDocument/formatting"}}
[t=1571933271589] org.eclipse.acute.omnisharp to LSP4E:
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Found attributes 1, ::file:///home/norru/Projects/ivt/dotnet_test/Program.cs"}}
[t=1571933271589] org.eclipse.acute.omnisharp to LSP4E:
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Looking for handler for descriptors textDocument/formatting"}}
[t=1571933271589] org.eclipse.acute.omnisharp to LSP4E:
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Checking handler textDocument/formatting:OmniSharp.LanguageServerProtocol.Handlers.OmniSharpDocumentFormattingHandler"}}
[t=1571933271589] org.eclipse.acute.omnisharp to LSP4E:
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Registration options OmniSharp.Extensions.LanguageServer.Protocol.Models.TextDocumentRegistrationOptions"}}
[t=1571933271589] org.eclipse.acute.omnisharp to LSP4E:
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Document Selector [**/*.cs], [**/*.csx]"}}
[t=1571933271589] org.eclipse.acute.omnisharp to LSP4E:
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Handler Selected: OmniSharp.LanguageServerProtocol.Handlers.OmniSharpDocumentFormattingHandler via [**/*.cs], [**/*.csx] (targeting OmniSharp.Extensions.JsonRpc.IJsonRpcRequestHandler`2[[OmniSharp.Extensions.LanguageServer.Protocol.Models.DocumentFormattingParams, OmniSharp.Extensions.LanguageProtocol, Version=0.13.0.0, Culture=neutral, PublicKeyToken=6d868dff454e6022],[OmniSharp.Extensions.LanguageServer.Protocol.Models.TextEditContainer, OmniSharp.Extensions.LanguageProtocol, Version=0.13.0.0, Culture=neutral, PublicKeyToken=6d868dff454e6022]])"}}
[t=1571933271589] org.eclipse.acute.omnisharp to LSP4E:
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Starting: Routing Request (19) textDocument/formatting"}}
[t=1571933271590] org.eclipse.acute.omnisharp to LSP4E:
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Converting params for Request (19) textDocument/formatting to OmniSharp.Extensions.LanguageServer.Protocol.Models.DocumentFormattingParams"}}
[t=1571933271591] org.eclipse.acute.omnisharp to LSP4E:
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Result was System.Threading.Tasks.Task`1[[OmniSharp.Extensions.LanguageServer.Protocol.Models.TextEditContainer, OmniSharp.Extensions.LanguageProtocol, Version=0.13.0.0, Culture=neutral, PublicKeyToken=6d868dff454e6022]]"}}
[t=1571933271591] org.eclipse.acute.omnisharp to LSP4E:
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Response value was OmniSharp.Extensions.LanguageServer.Protocol.Models.TextEditContainer"}}
[t=1571933271592] org.eclipse.acute.omnisharp to LSP4E:
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Finished: Routing Request (19) textDocument/formatting in 1ms"}}
[t=1571933271592] org.eclipse.acute.omnisharp to LSP4E:
{"jsonrpc":"2.0","id":"19","result":[]}