Skip to content
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

No autocomplete with C# (OmniSharp Roslyn) #661

Closed
trbjo opened this issue Jul 21, 2019 · 12 comments
Closed

No autocomplete with C# (OmniSharp Roslyn) #661

trbjo opened this issue Jul 21, 2019 · 12 comments
Labels
language server issue Issues related to language servers communicating with this plugin

Comments

@trbjo
Copy link
Contributor

trbjo commented Jul 21, 2019

The LSP only works partially.

It has to major problems:

  • No autocompletion

No autocompletion from the LSP only the built in from Sublime appears, even though I have explicitly disabled it in the LSP settings.

  • No reloading of buffer:

It does not reload when I edit the buffer (so only initial analysis). If I delete a line and then hover over a symbol beneath it, it gives me the old line, indicating again that the LSP does not accommodate to the buffer's contents.

I don't think it is an LSP problem, since it works fine in Neovim.

OS and language server

I use Arch Linux and the latest release of the OmniSharp Roslyn language server (1.34)

How you installed LSP (Package Control or from git?)

I installed the development version via cloning the git repository and then satisfying dependencies from within Sublime.

Minimal reproduction steps

  • Install Sublime.
  • Install the LSP plugin
  • Download the release of the OmniSharp Roslyn LSP (see above) and extract.
  • Add the following settings to the LSP settings:
{
	"auto_show_diagnostics_panel_level": 4,
	"clients":
	{
		"C#":
		{
			"command":
			[
				"/home/tb/prebuilt/omnisharp/OmniSharp.exe",
				"-lsp"
			],
			"enabled": true,
			"languageId": "csharp",
			"syntaxes": ["Packages/C#/C#.sublime-syntax"],
			"scopes":
			[
				"source.cs"
			]
		}
	},
	"log_payloads": true,
	"log_stderr": true,
	"show_code_actions_bulb": true,
	"show_diagnostics_count_in_view_status": true,
	"show_diagnostics_in_view_status": false,
	"show_diagnostics_phantoms": false,
	"show_references_in_quick_panel": true,
	"only_show_lsp_completions": true
}

The following is an excerpt from the log. It does not log anything when I try to trigger autocomplete.

C#: Finding descriptor for textDocument/hover
C#: Found attributes 1, ::file:///home/tb/Project/Services/ILoginService.cs
C#: Looking for handler for descriptors textDocument/hover
C#: Checking handler textDocument/hover:OmniSharp.LanguageServerProtocol.Handlers.HoverHandler
C#: Registration options (null)
C#: Document Selector (null)
C#: Handler Selected: OmniSharp.LanguageServerProtocol.Handlers.HoverHandler via (null) (targeting OmniSharp.Extensions.JsonRpc.IJsonRpcRequestHandler`2[[OmniSharp.Extensions.LanguageServer.Protocol.Models.HoverParams, OmniSharp.Extensions.LanguageProtocol, Version=0.12.0.0, Culture=neutral, PublicKeyToken=6d868dff454e6022],[OmniSharp.Extensions.LanguageServer.Protocol.Models.Hover, OmniSharp.Extensions.LanguageProtocol, Version=0.12.0.0, Culture=neutral, PublicKeyToken=6d868dff454e6022]])
C#: Starting: Routing Request (2) textDocument/hover
C#: Converting params for Request (2) textDocument/hover to OmniSharp.Extensions.LanguageServer.Protocol.Models.HoverParams
C#: Result was System.Threading.Tasks.Task`1[[OmniSharp.Extensions.LanguageServer.Protocol.Models.Hover, OmniSharp.Extensions.LanguageProtocol, Version=0.12.0.0, Culture=neutral, PublicKeyToken=6d868dff454e6022]]
C#: Response value was OmniSharp.Extensions.LanguageServer.Protocol.Models.Hover
C#: Finished: Routing Request (2) textDocument/hover in 97ms
C#: Finding descriptor for textDocument/hover
C#: Found attributes 1, ::file:///home/tb/Project/Services/ILoginService.cs
C#: Looking for handler for descriptors textDocument/hover
C#: Checking handler textDocument/hover:OmniSharp.LanguageServerProtocol.Handlers.HoverHandler
C#: Registration options (null)
C#: Document Selector (null)
C#: Handler Selected: OmniSharp.LanguageServerProtocol.Handlers.HoverHandler via (null) (targeting OmniSharp.Extensions.JsonRpc.IJsonRpcRequestHandler`2[[OmniSharp.Extensions.LanguageServer.Protocol.Models.HoverParams, OmniSharp.Extensions.LanguageProtocol, Version=0.12.0.0, Culture=neutral, PublicKeyToken=6d868dff454e6022],[OmniSharp.Extensions.LanguageServer.Protocol.Models.Hover, OmniSharp.Extensions.LanguageProtocol, Version=0.12.0.0, Culture=neutral, PublicKeyToken=6d868dff454e6022]])
C#: Starting: Routing Request (3) textDocument/hover
C#: Converting params for Request (3) textDocument/hover to OmniSharp.Extensions.LanguageServer.Protocol.Models.HoverParams
C#: Result was System.Threading.Tasks.Task`1[[OmniSharp.Extensions.LanguageServer.Protocol.Models.Hover, OmniSharp.Extensions.LanguageProtocol, Version=0.12.0.0, Culture=neutral, PublicKeyToken=6d868dff454e6022]]
C#: Response value was OmniSharp.Extensions.LanguageServer.Protocol.Models.Hover
C#: Finished: Routing Request (3) textDocument/hover in 23ms
no such prop font.size when matching panel_control against panel_control console_panel
no such prop font.size when matching panel_control against panel_control console_panel
no such prop font.size when matching panel_control against panel_control console_panel
C#: Finding descriptor for textDocument/hover
C#: Found attributes 1, ::file:///home/tb/Project/Services/ILoginService.cs
C#: Looking for handler for descriptors textDocument/hover
C#: Checking handler textDocument/hover:OmniSharp.LanguageServerProtocol.Handlers.HoverHandler
C#: Registration options (null)
C#: Document Selector (null)
C#: Handler Selected: OmniSharp.LanguageServerProtocol.Handlers.HoverHandler via (null) (targeting OmniSharp.Extensions.JsonRpc.IJsonRpcRequestHandler`2[[OmniSharp.Extensions.LanguageServer.Protocol.Models.HoverParams, OmniSharp.Extensions.LanguageProtocol, Version=0.12.0.0, Culture=neutral, PublicKeyToken=6d868dff454e6022],[OmniSharp.Extensions.LanguageServer.Protocol.Models.Hover, OmniSharp.Extensions.LanguageProtocol, Version=0.12.0.0, Culture=neutral, PublicKeyToken=6d868dff454e6022]])
C#: Starting: Routing Request (4) textDocument/hover
C#: Converting params for Request (4) textDocument/hover to OmniSharp.Extensions.LanguageServer.Protocol.Models.HoverParams
C#: Result was System.Threading.Tasks.Task`1[[OmniSharp.Extensions.LanguageServer.Protocol.Models.Hover, OmniSharp.Extensions.LanguageProtocol, Version=0.12.0.0, Culture=neutral, PublicKeyToken=6d868dff454e6022]]
C#: Response value was OmniSharp.Extensions.LanguageServer.Protocol.Models.Hover
C#: Finished: Routing Request (4) textDocument/hover in 39ms
C#: Finding descriptor for textDocument/hover
C#: Found attributes 1, ::file:///home/tb/Project/Services/ILoginService.cs
C#: Looking for handler for descriptors textDocument/hover
C#: Checking handler textDocument/hover:OmniSharp.LanguageServerProtocol.Handlers.HoverHandler
C#: Registration options (null)
C#: Document Selector (null)
C#: Handler Selected: OmniSharp.LanguageServerProtocol.Handlers.HoverHandler via (null) (targeting OmniSharp.Extensions.JsonRpc.IJsonRpcRequestHandler`2[[OmniSharp.Extensions.LanguageServer.Protocol.Models.HoverParams, OmniSharp.Extensions.LanguageProtocol, Version=0.12.0.0, Culture=neutral, PublicKeyToken=6d868dff454e6022],[OmniSharp.Extensions.LanguageServer.Protocol.Models.Hover, OmniSharp.Extensions.LanguageProtocol, Version=0.12.0.0, Culture=neutral, PublicKeyToken=6d868dff454e6022]])
C#: Starting: Routing Request (5) textDocument/hover
C#: Converting params for Request (5) textDocument/hover to OmniSharp.Extensions.LanguageServer.Protocol.Models.HoverParams
C#: Result was System.Threading.Tasks.Task`1[[OmniSharp.Extensions.LanguageServer.Protocol.Models.Hover, OmniSharp.Extensions.LanguageProtocol, Version=0.12.0.0, Culture=neutral, PublicKeyToken=6d868dff454e6022]]
C#: Response value was OmniSharp.Extensions.LanguageServer.Protocol.Models.Hover
C#: Finished: Routing Request (5) textDocument/hover in 1ms
Error handling server payload
Traceback (most recent call last):
  File "/home/tb/.config/sublime-text-3/Packages/LSP/plugin/core/rpc.py", line 149, in receive_payload
    self.response_handler(payload)
  File "/home/tb/.config/sublime-text-3/Packages/LSP/plugin/core/rpc.py", line 168, in response_handler
    handler(response["result"])
  File "/home/tb/.config/sublime-text-3/Packages/LSP/plugin/hover.py", line 76, in <lambda>
    lambda response: self.handle_response(response, point))
  File "/home/tb/.config/sublime-text-3/Packages/LSP/plugin/hover.py", line 85, in handle_response
    all_content += self.hover_content(point, response)
  File "/home/tb/.config/sublime-text-3/Packages/LSP/plugin/hover.py", line 144, in hover_content
    value = item.get("value")
AttributeError: 'NoneType' object has no attribute 'get'

@tomv564
Copy link
Contributor

tomv564 commented Jul 21, 2019

No completion: I see this issue on the language server's repo: OmniSharp/omnisharp-roslyn#1554
If you want to be really sure, we need to see what capabilities the roslyn server is replying to the window/initialize request with. If you set log_payloads to True (in addition to log_debug you should see it as soon as the server starts.

Document not updating: Perhaps you can see if the server is not logging errors in response to any didChange notifications?

Hover error: I can't see the response, but judging by the error it might be invalid - something like: { 'contents': null }. Perhaps the build you are running is still suffering from this issue : OmniSharp/omnisharp-roslyn#1087 ?

@trbjo
Copy link
Contributor Author

trbjo commented Jul 22, 2019

After enabling the debug log I get this. This is the initialization messages:

LSP: starting ['/home/tb/prebuilt/omnisharp/OmniSharp.exe', '-lsp']
LSP:  --> initialize
LSP: window 2 added session C#
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP: Unhandled notification window/logMessage
LSP:      {'capabilities': {'textDocumentSync': 0, 'workspaceSymbolProvider': False, 'documentSymbolProvider': True, 'documentFormattingProvider': False, 'definitionProvider': True, 'documentRangeFormattingProvider': False, 'hoverProvider': True, 'experimental': {}, 'referencesProvider': True, 'documentHighlightProvider': False}}
LSP:  --> initialized
C#: Finding descriptor for initialized
C#: Starting: Routing Notification initialized
C#: Converting params for Notification initialized to OmniSharp.Extensions.LanguageServer.Protocol.Models.InitializedParams
C#: initialized...

The log does not contain the word change. There is no new output to the log if I delete or add a line.
I guess this is also why the hover suddenly is wrong: It still thinks the buffer has the same content on line X, but in the fact that content now resides on line X+1.

There are also no occurrences of the contents being null.

@trbjo
Copy link
Contributor Author

trbjo commented Jul 22, 2019

The full log can be found here: https://git.sr.ht/~troels/Log/tree/master/log.log

@tomv564
Copy link
Contributor

tomv564 commented Jul 22, 2019

Thanks for the log, it confirms the completion issue as well as why buffer changes are not communicated - the server turns it off (textDocumentSync: 0).

The first issue I linked explains the problem with the omnisharp server - if it turns out this package is responsible for the incomplete capabilities then I'll gladly have a look!

@trbjo
Copy link
Contributor Author

trbjo commented Jul 22, 2019

if it turns out this package is responsible for the incomplete capabilities then I'll gladly have a look

How can I check that?

I have just checked with the same LSP in Neovim (via CoC).

Both textDocumentSync and autocompletion works there.

To be honest I don't know much about the LSP protocol. Coc.nvim touts itself as being compatible with vscode. I don't know if that means that there is the protocol and then there is a non-standard vscode implementation.

I saw that the issue you linked to links to another issue, which has been solved. I guess it ought to be solved.

@Sword-Smith
Copy link

I also have this issue.

@tomv564
Copy link
Contributor

tomv564 commented Jul 22, 2019

The fix for the issues was merged in a related project (csharp-language-server-protocol), but I believe the reference to that project hasn't been updated in omnisharp-roslyn itself. Hopefully a maintainer will comment in their issue (#1554) when that's been released.

LSP follows the protocol, but avoids some complexities like dynamic registration of capabilities. It's possible CoC and VSCode use dynamic registration and therefore don't experience this issue.

@rwols
Copy link
Member

rwols commented Aug 4, 2019

Any updates on this? I tried OmniSharp too, but didn't really get anywhere. Some points of interest:

  1. OmniSharp says "don't synchronize documents please". So no textDocument/didChange events are sent from Sublime to OmniSharp. Which makes completion/signatureHelp/hover useless.
  2. OmniSharp always responds to a textDocument/hover request with [None, None], not a valid response.
  3. Completions seem to behave crazy.

@rwols rwols changed the title No autocomplete with C# No autocomplete with C# (OmniSharp Roslyn) Aug 4, 2019
@trbjo
Copy link
Contributor Author

trbjo commented Aug 17, 2019

I just tried with the latest release 1.34.2. Still the same.

@tomv564
Copy link
Contributor

tomv564 commented Aug 26, 2019

A new issue was created for the TextDocumentSync here: OmniSharp/csharp-language-server-protocol#162. Although an incomplete fix was added, new bugs appeared, and the related package also needs to be updated to the omnisharp-roslyn repo itself.

Perhaps someone wants to contribute some tests that cover non-dynamic-registration :)

I'll add some documentation for this server as I found it to be pretty quick to set up otherwise!

@tomv564 tomv564 added language server issue Issues related to language servers communicating with this plugin and removed investigation labels Aug 28, 2019
@trbjo
Copy link
Contributor Author

trbjo commented Sep 12, 2019

It has improved a bit with the release of 1.34.3. There is still no textDocumentSync but autocompletion now works embryonically.

@tomv564
Copy link
Contributor

tomv564 commented Oct 15, 2019

I wondered if this was a recent regression, but even 1.32.9 turns off textDocumentSync for static capabilities. Either way, they merged a fix to the protocol library 3 days ago, so perhaps the next release of omnisharp-roslyn will get this working!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language server issue Issues related to language servers communicating with this plugin
Projects
None yet
Development

No branches or pull requests

4 participants