editor-rs / vscode-rust

Rust for Visual Studio Code
MIT License
474 stars 62 forks source link

Formatting doesn't work #392

Open louisabraham opened 5 years ago

louisabraham commented 5 years ago

Version of VSCode: 1.32.1 Version of the extension: 0.5.4 OS: MacOS

Description: my code is not formatted

Output of the "Rust logging" channel:

[Trace - 9:06:07 PM] Sending request 'initialize - (0)'.
Params: {
    "processId": 11657,
    "rootPath": "/Users/louisabraham/rustlang",
    "rootUri": "file:///Users/louisabraham/rustlang",
    "capabilities": {
        "workspace": {
            "applyEdit": true,
            "workspaceEdit": {
                "documentChanges": true
            },
            "didChangeConfiguration": {
                "dynamicRegistration": true
            },
            "didChangeWatchedFiles": {
                "dynamicRegistration": true
            },
            "symbol": {
                "dynamicRegistration": true,
                "symbolKind": {
                    "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,
                        26
                    ]
                }
            },
            "executeCommand": {
                "dynamicRegistration": true
            },
            "configuration": true,
            "workspaceFolders": true
        },
        "textDocument": {
            "publishDiagnostics": {
                "relatedInformation": true
            },
            "synchronization": {
                "dynamicRegistration": true,
                "willSave": true,
                "willSaveWaitUntil": true,
                "didSave": true
            },
            "completion": {
                "dynamicRegistration": true,
                "contextSupport": true,
                "completionItem": {
                    "snippetSupport": true,
                    "commitCharactersSupport": true,
                    "documentationFormat": [
                        "markdown",
                        "plaintext"
                    ],
                    "deprecatedSupport": true,
                    "preselectSupport": true
                },
                "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": {
                "dynamicRegistration": true,
                "contentFormat": [
                    "markdown",
                    "plaintext"
                ]
            },
            "signatureHelp": {
                "dynamicRegistration": true,
                "signatureInformation": {
                    "documentationFormat": [
                        "markdown",
                        "plaintext"
                    ]
                }
            },
            "definition": {
                "dynamicRegistration": true
            },
            "references": {
                "dynamicRegistration": true
            },
            "documentHighlight": {
                "dynamicRegistration": true
            },
            "documentSymbol": {
                "dynamicRegistration": true,
                "symbolKind": {
                    "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,
                        26
                    ]
                }
            },
            "codeAction": {
                "dynamicRegistration": true,
                "codeActionLiteralSupport": {
                    "codeActionKind": {
                        "valueSet": [
                            "",
                            "quickfix",
                            "refactor",
                            "refactor.extract",
                            "refactor.inline",
                            "refactor.rewrite",
                            "source",
                            "source.organizeImports"
                        ]
                    }
                }
            },
            "codeLens": {
                "dynamicRegistration": true
            },
            "formatting": {
                "dynamicRegistration": true
            },
            "rangeFormatting": {
                "dynamicRegistration": true
            },
            "onTypeFormatting": {
                "dynamicRegistration": true
            },
            "rename": {
                "dynamicRegistration": true
            },
            "documentLink": {
                "dynamicRegistration": true
            },
            "typeDefinition": {
                "dynamicRegistration": true
            },
            "implementation": {
                "dynamicRegistration": true
            },
            "colorProvider": {
                "dynamicRegistration": true
            }
        }
    },
    "initializationOptions": {
        "omitInitBuild": true,
        "cmdRun": true
    },
    "trace": "verbose",
    "workspaceFolders": [
        {
            "uri": "file:///Users/louisabraham/rustlang",
            "name": "rustlang"
        }
    ]
}

[Trace - 9:06:07 PM] Received response 'initialize - (0)' in 89ms.
Result: {
    "capabilities": {
        "textDocumentSync": 2,
        "hoverProvider": true,
        "completionProvider": {
            "resolveProvider": true,
            "triggerCharacters": [
                ".",
                ":"
            ]
        },
        "definitionProvider": true,
        "implementationProvider": true,
        "referencesProvider": true,
        "documentHighlightProvider": true,
        "documentSymbolProvider": true,
        "workspaceSymbolProvider": true,
        "codeActionProvider": true,
        "codeLensProvider": {
            "resolveProvider": false
        },
        "documentFormattingProvider": true,
        "documentRangeFormattingProvider": false,
        "renameProvider": true,
        "executeCommandProvider": {
            "commands": [
                "rls.applySuggestion-11718",
                "rls.deglobImports-11718"
            ]
        }
    }
}

[Trace - 9:06:07 PM] Sending notification 'initialized'.
Params: {}

[Trace - 9:06:07 PM] Sending notification 'workspace/didChangeConfiguration'.
Params: {
    "settings": {
        "rust": {
            "sysroot": null,
            "target": null,
            "rustflags": null,
            "clear_env_rust_log": true,
            "build_lib": null,
            "build_bin": null,
            "cfg_test": false,
            "unstable_features": false,
            "wait_to_build": 1500,
            "show_warnings": true,
            "use_crate_blacklist": true,
            "build_on_save": false,
            "features": [],
            "all_features": false,
            "no_default_features": false,
            "racer_completion": true,
            "clippy_preference": "opt-in",
            "jobs": null,
            "all_targets": true,
            "target_dir": null,
            "rustfmt_path": "/Users/louisabraham/.cargo/bin/rustfmt",
            "build_command": null,
            "full_docs": null,
            "show_hover_context": true,
            "trace": {
                "server": "verbose"
            }
        }
    }
}

[Trace - 9:06:07 PM] Sending notification 'textDocument/didOpen'.
Params: {
    "textDocument": {
        "uri": "file:///Users/louisabraham/rustlang/hello_world/main.rs",
        "languageId": "rust",
        "version": 1,
        "text": "fn main() {\nprintln!(\"Hello, world!\");\n    \n\n    }"
    }
}

[Trace - 9:06:07 PM] Received request 'client/registerCapability - (1)'.
Params: {
    "registrations": [
        {
            "id": "rls-watch",
            "method": "workspace/didChangeWatchedFiles",
            "registerOptions": {
                "watchers": [
                    {
                        "globPattern": "/Users/louisabraham/rustlang/Cargo.lock"
                    },
                    {
                        "globPattern": "/Users/louisabraham/rustlang/target",
                        "kind": 4
                    }
                ]
            }
        }
    ]
}

[Trace - 9:06:07 PM] Sending response 'client/registerCapability - (1)'. Processing request took 1ms
No result returned.

[Trace - 9:06:07 PM] Received notification 'window/progress'.
Params: {
    "id": "progress_1",
    "title": "Building"
}

[Trace - 9:06:07 PM] Received request 'client/unregisterCapability - (2)'.
Params: {
    "unregisterations": [
        {
            "id": "rls-range-formatting",
            "method": "textDocument/rangeFormatting"
        }
    ]
}

[Trace - 9:06:07 PM] Sending response 'client/unregisterCapability - (2)'. Processing request took 0ms
No result returned.

[Trace - 9:06:07 PM] Received notification 'window/progress'.
Params: {
    "done": true,
    "id": "progress_1",
    "title": "Building"
}

[Trace - 9:06:07 PM] Received notification 'window/progress'.
Params: {
    "id": "progress_0",
    "title": "Indexing"
}

[Trace - 9:06:07 PM] Received notification 'window/showMessage'.
Params: {
    "message": "could not find `Cargo.toml` in `/Users/louisabraham/rustlang` or any parent directory",
    "type": 1
}

[Trace - 9:06:07 PM] Received notification 'window/progress'.
Params: {
    "done": true,
    "id": "progress_0",
    "title": "Indexing"
}

[Trace - 9:06:07 PM] Sending request 'textDocument/codeAction - (1)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/louisabraham/rustlang/hello_world/main.rs"
    },
    "range": {
        "start": {
            "line": 1,
            "character": 0
        },
        "end": {
            "line": 1,
            "character": 0
        }
    },
    "context": {
        "diagnostics": []
    }
}

[Trace - 9:06:07 PM] Received response 'textDocument/codeAction - (1)' in 12ms.
Result: []

[Trace - 9:06:07 PM] Sending request 'textDocument/codeLens - (2)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/louisabraham/rustlang/hello_world/main.rs"
    }
}

[Trace - 9:06:07 PM] Received response 'textDocument/codeLens - (2)' in 30ms.
Result: []

[Trace - 9:06:14 PM] Sending notification 'textDocument/didChange'.
Params: {
    "textDocument": {
        "uri": "file:///Users/louisabraham/rustlang/hello_world/main.rs",
        "version": 2
    },
    "contentChanges": [
        {
            "range": {
                "start": {
                    "line": 2,
                    "character": 0
                },
                "end": {
                    "line": 2,
                    "character": 4
                }
            },
            "rangeLength": 4,
            "text": ""
        }
    ]
}

[Trace - 9:06:14 PM] Received notification 'window/progress'.
Params: {
    "id": "progress_3",
    "title": "Building"
}

[Trace - 9:06:14 PM] Received notification 'window/progress'.
Params: {
    "done": true,
    "id": "progress_3",
    "title": "Building"
}

[Trace - 9:06:14 PM] Received notification 'window/progress'.
Params: {
    "id": "progress_2",
    "title": "Indexing"
}

[Trace - 9:06:14 PM] Received notification 'window/progress'.
Params: {
    "done": true,
    "id": "progress_2",
    "title": "Indexing"
}

[Trace - 9:06:14 PM] Sending request 'textDocument/codeLens - (3)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/louisabraham/rustlang/hello_world/main.rs"
    }
}

[Trace - 9:06:14 PM] Received response 'textDocument/codeLens - (3)' in 2ms.
Result: []

[Trace - 9:06:14 PM] Sending request 'textDocument/formatting - (4)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/louisabraham/rustlang/hello_world/main.rs"
    },
    "options": {
        "tabSize": 4,
        "insertSpaces": true
    }
}

[Trace - 9:06:14 PM] Received response 'textDocument/formatting - (4)' in 2ms. Request failed: Reformat failed to complete successfully (-32603).
[Error - 9:06:14 PM] Request textDocument/formatting failed.
  Message: Reformat failed to complete successfully
  Code: -32603 
[Trace - 9:06:14 PM] Sending notification 'textDocument/didSave'.
Params: {
    "textDocument": {
        "uri": "file:///Users/louisabraham/rustlang/hello_world/main.rs",
        "version": 2
    }
}

[Trace - 9:06:20 PM] Sending request 'textDocument/codeLens - (5)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/louisabraham/rustlang/hello_world/main.rs"
    }
}

[Trace - 9:06:20 PM] Received response 'textDocument/codeLens - (5)' in 2ms.
Result: []

[Trace - 9:06:20 PM] Sending request 'textDocument/codeLens - (6)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/louisabraham/rustlang/hello_world/main.rs"
    }
}

[Trace - 9:06:20 PM] Received response 'textDocument/codeLens - (6)' in 2ms.
Result: []
Friz64 commented 5 years ago

I have the exact same issue (VSCodium 1.35.1 Linux - Extension Version: 0.6.1)

[Error - 5:57:39 PM] Request textDocument/formatting failed.
  Message: Reformat failed to complete successfully
  Code: -32603
Friz64 commented 5 years ago

Okay, for some reason just reinstalling the RLS Extension fixed this for me.

deklanw commented 5 years ago

Getting this too on Windows. Reinstalling didn't help.