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 "invalid" status notification when rust-analyzer fails to discover a workspace #5829

Closed
bstaletic opened this issue Aug 20, 2020 · 0 comments · Fixed by #13603
Closed
Labels
S-actionable Someone could pick this issue up and work on it right now

Comments

@bstaletic
Copy link
Contributor

YCM relies on receiving rust-analyzer/status with either ready or invalid as a signal that rust-analyzer has finished all the background work at startup.

https://github.com/ycm-core/ycmd/blob/master/ycmd/completers/rust/rust_completer.py#L117-L119

However, the version available through rustup, as well as the current master (844e1aa7), never send the notification if there's no actual workspace. Instead, I only see a window/showMessage notification. An example trace of exchanged messages:

2020-08-20 16:26:28,826 - DEBUG - TX: Sending message: b'Content-Length: 987\r\n\r\n{"id":1,"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"experimental":{"statusNotification":true},"textDocument":{"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"completion":{"completionItem":{"documentationFormat":["plaintext","markdown"]},"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]}},"hover":{"contentFormat":["plaintext","markdown"]},"signatureHelp":{"signatureInformation":{"documentationFormat":["plaintext","markdown"],"parameterInformation":{"labelOffsetSupport":true}}},"synchronization":{"didSave":true}},"workspace":{"configuration":true}},"initializationOptions":{},"processId":12967,"rootPath":"/home/bstaletic/.vim/pack/bundle/start/YouCompleteMe/third_party/ycmd","rootUri":"file:///home/bstaletic/.vim/pack/bundle/start/YouCompleteMe/third_party/ycmd"}}'
2020-08-20 16:26:28,830 - DEBUG - RX: Received message: b'{"jsonrpc":"2.0","id":1,"result":{"capabilities":{"callHierarchyProvider":true,"codeActionProvider":{"codeActionKinds":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite"]},"codeLensProvider":{"resolveProvider":true},"completionProvider":{"triggerCharacters":[":","."]},"definitionProvider":true,"documentFormattingProvider":true,"documentHighlightProvider":true,"documentOnTypeFormattingProvider":{"firstTriggerCharacter":"=","moreTriggerCharacter":[".",">"]},"documentSymbolProvider":true,"experimental":{"joinLines":true,"onEnter":true,"parentModule":true,"runnables":{"kinds":["cargo"]},"ssr":true},"foldingRangeProvider":true,"hoverProvider":true,"implementationProvider":true,"referencesProvider":true,"renameProvider":{"prepareProvider":true},"selectionRangeProvider":true,"semanticTokensProvider":{"documentProvider":{"edits":true},"legend":{"tokenModifiers":["documentation","declaration","definition","static","abstract","deprecated","readonly","constant","controlFlow","injected","mutable","consuming","unsafe","attribute"],"tokenTypes":["comment","keyword","string","number","regexp","operator","namespace","type","struct","class","interface","enum","typeParameter","function","member","property","macro","variable","parameter","label","attribute","boolean","builtinType","enumMember","escapeSequence","formatSpecifier","generic","lifetime","punctuation","selfKeyword","typeAlias","union","unresolvedReference"]},"rangeProvider":true},"signatureHelpProvider":{"triggerCharacters":["(",","]},"textDocumentSync":{"change":2,"openClose":true,"save":{}},"typeDefinitionProvider":true,"workspaceSymbolProvider":true},"serverInfo":{"name":"rust-analyzer","version":"844e1aa"}}}'
2020-08-20 16:26:28,831 - DEBUG - TX: Sending notification: b'Content-Length: 52\r\n\r\n{"jsonrpc":"2.0","method":"initialized","params":{}}'
2020-08-20 16:26:28,831 - DEBUG - TX: Sending notification: b'Content-Length: 86\r\n\r\n{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{}}}'
2020-08-20 16:26:28,831 - DEBUG - TX: Sending notification: b'Content-Length: 144\r\n\r\n{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"rust","text":"\\n","uri":"file:///foo.rs","version":1}}}'
2020-08-20 16:26:28,849 - DEBUG - RX: Received message: b'{"jsonrpc":"2.0","method":"window/showMessage","params":{"message":"rust-analyzer failed to discover workspace","type":1}}'
2020-08-20 16:26:28,849 - DEBUG - RX: Received message: b'{"jsonrpc":"2.0","id":0,"method":"client/registerCapability","params":{"registrations":[{"id":"textDocument/didSave","method":"textDocument/didSave","registerOptions":{"documentSelector":[{"pattern":"**/*.rs"},{"pattern":"**/Cargo.toml"},{"pattern":"**/Cargo.lock"}],"includeText":false}}]}}'
2020-08-20 16:26:28,849 - DEBUG - TX: Sending response: b'Content-Length: 38\r\n\r\n{"id":0,"jsonrpc":"2.0","result":null}'
2020-08-20 16:26:28,855 - DEBUG - RX: Received message: b'{"jsonrpc":"2.0","id":1,"method":"workspace/configuration","params":{"items":[{"section":"rust-analyzer"}]}}'
2020-08-20 16:26:28,855 - DEBUG - TX: Sending response: b'Content-Length: 40\r\n\r\n{"id":1,"jsonrpc":"2.0","result":[null]}'

This is the rust-analyzer log with RA_LOG set to rust-analyzer=trace:

[INFO  rust_analyzer] lifecycle: server started
[INFO  rust_analyzer::config] Config::update({})
[INFO  rust_analyzer::main_loop] initial config: Config {
        client_caps: ClientCapsConfig {
            location_link: false,
            line_folding_only: false,
            hierarchical_symbols: false,
            code_action_literals: true,
            work_done_progress: false,
            code_action_group: false,
            resolve_code_action: false,
            hover_actions: false,
            status_notification: true,
            signature_help_label_offsets: true,
        },
        publish_diagnostics: true,
        diagnostics: DiagnosticsConfig {
            disable_experimental: false,
            disabled: {},
        },
        diagnostics_map: DiagnosticsMapConfig {
            warnings_as_info: [],
            warnings_as_hint: [],
        },
        lru_capacity: None,
        proc_macro_srv: None,
        files: FilesConfig {
            watcher: Notify,
            exclude: [],
        },
        notifications: NotificationsConfig {
            cargo_toml_not_found: true,
        },
        cargo_autoreload: true,
        cargo: CargoConfig {
            no_default_features: false,
            all_features: false,
            features: [],
            load_out_dirs_from_check: false,
            target: None,
        },
        rustfmt: Rustfmt {
            extra_args: [],
        },
        flycheck: Some(
            CargoCommand {
                command: "check",
                target_triple: None,
                all_targets: true,
                no_default_features: false,
                all_features: false,
                features: [],
                extra_args: [],
            },
        ),
        inlay_hints: InlayHintsConfig {
            type_hints: true,
            parameter_hints: true,
            chaining_hints: true,
            max_length: None,
        },
        completion: CompletionConfig {
            enable_postfix_completions: true,
            add_call_parenthesis: true,
            add_call_argument_snippets: true,
            snippet_cap: None,
        },
        assist: AssistConfig {
            snippet_cap: None,
            allowed: None,
        },
        call_info_full: true,
        lens: LensConfig {
            run: true,
            debug: true,
            implementations: true,
        },
        hover: HoverConfig {
            implementations: true,
            run: true,
            debug: true,
            goto_type_def: true,
        },
        with_sysroot: true,
        linked_projects: [],
        root_path: AbsPathBuf(
            "/home/bstaletic/.vim/pack/bundle/start/YouCompleteMe/third_party/ycmd",
        ),
    }
[INFO  rust_analyzer::main_loop] handle_event(Notification(Notification { method: "workspace/didChangeConfiguration", params: Object({"settings": Object({})}) }))
[INFO  rust_analyzer::main_loop] handle_event(Workspaces([]))
[INFO  rust_analyzer::reload] reloading projects: []
[INFO  rust_analyzer::main_loop] handle_event(Notification { method: "textDocument/didOpen" })
[INFO  rust_analyzer::main_loop] handle_event(Response(Response { id: RequestId(U64(0)), result: None, error: None }))
[INFO  rust_analyzer::main_loop] handle_event(Response(Response { id: RequestId(U64(1)), result: Some(Array([Null])), error: None }))
[DEBUG rust_analyzer::main_loop] config update response: 'Response { id: RequestId(U64(1)), result: Some(Array([Null])), error: None }
[INFO  rust_analyzer::config] Config::update(null)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants