Closed kwinso closed 2 years ago
You're using coc-rls
and coc-rust-analyzer
, you shouldn't use them at same time, disable one and try again.
I've done :CocUninstall coc-rls
and the problem is still present. Now in :CocInfo
it says this:
2022-04-28T15:03:55.667 INFO (pid:180079) [completion-complete] - 1 results from: rust-analyzer
So as I understood, rust-analyzer
is the only extension that will do completion. But "double import" still happens.
Can you reproduce this with VS Code + rust-analyzer? If so, it's an issue of rust-analyzer.
Set "rust-analyzer.trace.server": "verbose"
in your coc-settings.json, and when reproduce this issue, checkout :CocCommand workspace.showOutput rust-analyzer
.
I tried to import the same module in VSCode, it works as expected.
The output of :CocCommand workspace.showOutput rust-analyzer
(initialization and the autocompletion request/response):
[Trace - 3:22:57 PM] Sending request 'initialize - (0)'.
Params: {
"processId": 185095,
"rootPath": "/home/mouse/code/rust/ash",
"rootUri": "file:///home/mouse/code/rust/ash",
"capabilities": {
"workspace": {
"applyEdit": true,
"workspaceEdit": {
"documentChanges": true,
"resourceOperations": [
"create",
"rename",
"delete"
],
"failureHandling": "textOnlyTransactional",
"normalizesLineEndings": 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
]
},
"tagSupport": {
"valueSet": [
1
]
}
},
"codeLens": {
"refreshSupport": true
},
"executeCommand": {
"dynamicRegistration": true
},
"configuration": true,
"fileOperations": {
"dynamicRegistration": true,
"didCreate": true,
"didRename": true,
"didDelete": true,
"willCreate": true,
"willRename": true,
"willDelete": true
},
"semanticTokens": {
"refreshSupport": true
},
"workspaceFolders": true
},
"textDocument": {
"publishDiagnostics": {
"relatedInformation": true,
"versionSupport": true,
"tagSupport": {
"valueSet": [
1,
2
]
},
"codeDescriptionSupport": true,
"dataSupport": 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,
"insertReplaceSupport": true,
"tagSupport": {
"valueSet": [
1
]
},
"resolveSupport": {
"properties": [
"documentation",
"detail",
"additionalTextEdits"
]
},
"insertTextModeSupport": {
"valueSet": [
1,
2
]
}
},
"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
]
},
"insertTextMode": 2
},
"hover": {
"dynamicRegistration": true,
"contentFormat": [
"markdown",
"plaintext"
]
},
"signatureHelp": {
"dynamicRegistration": true,
"contextSupport": true,
"signatureInformation": {
"documentationFormat": [
"markdown",
"plaintext"
],
"activeParameterSupport": true,
"parameterInformation": {
"labelOffsetSupport": true
}
}
},
"references": {
"dynamicRegistration": true
},
"definition": {
"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
]
},
"hierarchicalDocumentSymbolSupport": true,
"tagSupport": {
"valueSet": [
1
]
},
"labelSupport": true
},
"codeAction": {
"dynamicRegistration": true,
"isPreferredSupport": true,
"disabledSupport": true,
"dataSupport": true,
"honorsChangeAnnotations": false,
"resolveSupport": {
"properties": [
"edit"
]
},
"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,
"prepareSupport": true
},
"documentLink": {
"dynamicRegistration": true,
"tooltipSupport": true
},
"typeDefinition": {
"dynamicRegistration": true
},
"implementation": {
"dynamicRegistration": true
},
"declaration": {
"dynamicRegistration": true
},
"colorProvider": {
"dynamicRegistration": true
},
"foldingRange": {
"dynamicRegistration": true,
"rangeLimit": 5000,
"lineFoldingOnly": true
},
"selectionRange": {
"dynamicRegistration": true
},
"callHierarchy": {
"dynamicRegistration": true
},
"linkedEditingRange": {
"dynamicRegistration": true
},
"semanticTokens": {
"dynamicRegistration": true,
"tokenTypes": [
"namespace",
"type",
"class",
"enum",
"interface",
"struct",
"typeParameter",
"parameter",
"variable",
"property",
"enumMember",
"event",
"function",
"method",
"macro",
"keyword",
"modifier",
"comment",
"string",
"number",
"regexp",
"operator"
],
"tokenModifiers": [
"declaration",
"definition",
"readonly",
"static",
"deprecated",
"abstract",
"async",
"modification",
"documentation",
"defaultLibrary"
],
"formats": [
"relative"
],
"requests": {
"range": true,
"full": {
"delta": true
}
},
"multilineTokenSupport": false,
"overlappingTokenSupport": false
}
},
"window": {
"showMessage": {
"messageActionItem": {
"additionalPropertiesSupport": true
}
},
"showDocument": {
"support": true
},
"workDoneProgress": true
},
"general": {
"regularExpressions": {
"engine": "ECMAScript",
"version": "ES2020"
},
"markdown": {
"parser": "marked",
"version": "4.0.10"
}
},
"experimental": {
"snippetTextEdit": true,
"resolveCodeAction": true,
"serverStatusNotification": true,
"commands": {
"commands": [
"rust-analyzer.runSingle",
"rust-analyzer.debugSingle",
"rust-analyzer.showReferences",
"rust-analyzer.gotoLocation",
"editor.action.triggerParameterHints"
]
}
}
},
"initializationOptions": {
"enable": true,
"terminal": {
"startinsert": false
},
"debug": {
"runtime": "termdebug",
"vimspector": {
"configuration": {
"name": "launch"
}
}
},
"inlayHints": {
"enable": true,
"typeHintsSeparator": "‣",
"chainingHintsSeparator": "‣",
"refreshOnInsertMode": false,
"renderColons": true,
"maxLength": 25,
"typeHints": true,
"chainingHints": true,
"closureReturnTypeHints": false,
"reborrowHints": false,
"lifetimeElisionHints": {
"enable": "never",
"useParameterNames": false
},
"hideNamedConstructorHints": false
},
"trace": {
"server": "verbose"
},
"updates": {
"prompt": true,
"checkOnStartup": true,
"channel": "stable"
},
"assist": {
"exprFillDefault": "todo",
"importGranularity": "crate",
"importEnforceGranularity": false,
"importPrefix": "plain",
"importGroup": true,
"allowMergingIntoGlobImports": true
},
"cache": {
"warmup": true
},
"callInfo": {
"full": true
},
"cargo": {
"autoreload": true,
"allFeatures": false,
"unsetTest": [
"core"
],
"features": [],
"runBuildScripts": true,
"useRustcWrapperForBuildScripts": true,
"noDefaultFeatures": false,
"noSysroot": false
},
"checkOnSave": {
"enable": true,
"allTargets": true,
"command": "check",
"extraArgs": []
},
"completion": {
"addCallArgumentSnippets": true,
"addCallParenthesis": true,
"snippets": {
"Arc::new": {
"postfix": "arc",
"body": "Arc::new(${receiver})",
"requires": "std::sync::Arc",
"description": "Put the expression into an `Arc`",
"scope": "expr"
},
"Rc::new": {
"postfix": "rc",
"body": "Rc::new(${receiver})",
"requires": "std::rc::Rc",
"description": "Put the expression into an `Rc`",
"scope": "expr"
},
"Box::pin": {
"postfix": "pinbox",
"body": "Box::pin(${receiver})",
"requires": "std::boxed::Box",
"description": "Put the expression into a pinned `Box`",
"scope": "expr"
},
"Ok": {
"postfix": "ok",
"body": "Ok(${receiver})",
"description": "Wrap the expression in a `Result::Ok`",
"scope": "expr"
},
"Err": {
"postfix": "err",
"body": "Err(${receiver})",
"description": "Wrap the expression in a `Result::Err`",
"scope": "expr"
},
"Some": {
"postfix": "some",
"body": "Some(${receiver})",
"description": "Wrap the expression in an `Option::Some`",
"scope": "expr"
}
},
"postfix": {
"enable": true
},
"autoimport": {
"enable": true
},
"autoself": {
"enable": true
},
"privateEditable": {
"enable": false
}
},
"diagnostics": {
"enable": true,
"enableExperimental": false,
"disabled": [],
"remapPrefix": {},
"warningsAsHint": [],
"warningsAsInfo": []
},
"experimental": {
"procAttrMacros": true
},
"files": {
"watcher": "client",
"excludeDirs": []
},
"highlightRelated": {
"references": true,
"exitPoints": true,
"breakPoints": true,
"yieldPoints": true
},
"highlighting": {
"strings": true
},
"hover": {
"documentation": true,
"linksInHover": true
},
"hoverActions": {
"enable": true
},
"joinLines": {
"joinElseIf": true,
"removeTrailingComma": true,
"unwrapTrivialBlock": true,
"joinAssignments": true
},
"lens": {
"enable": true,
"implementations": true,
"run": true,
"methodReferences": false,
"references": false,
"enumVariantReferences": false,
"forceCustomCommands": true
},
"linkedProjects": [],
"notifications": {
"cargoTomlNotFound": true
},
"primeCaches": {
"numThreads": 0
},
"procMacro": {
"enable": true,
"ignored": {}
},
"runnables": {
"cargoExtraArgs": []
},
"rustfmt": {
"extraArgs": [],
"enableRangeFormatting": false
},
"workspace": {
"symbol": {
"search": {
"scope": "workspace",
"kind": "only_types",
"limit": 128
}
}
}
},
"trace": "verbose",
"workspaceFolders": [
{
"uri": "file:///home/mouse/code/rust/ash",
"name": "ash"
}
],
"locale": "en_US",
"clientInfo": {
"name": "coc.nvim",
"version": "0.0.80"
}
}
[Trace - 3:22:57 PM] Received response 'initialize - (0)' in 7ms.
Result: {
"capabilities": {
"textDocumentSync": {
"openClose": true,
"change": 2,
"save": {}
},
"selectionRangeProvider": true,
"hoverProvider": true,
"completionProvider": {
"resolveProvider": true,
"triggerCharacters": [
":",
".",
"'"
]
},
"signatureHelpProvider": {
"triggerCharacters": [
"(",
",",
"<"
]
},
"definitionProvider": true,
"typeDefinitionProvider": true,
"implementationProvider": true,
"referencesProvider": true,
"documentHighlightProvider": true,
"documentSymbolProvider": true,
"workspaceSymbolProvider": true,
"codeActionProvider": {
"codeActionKinds": [
"",
"quickfix",
"refactor",
"refactor.extract",
"refactor.inline",
"refactor.rewrite"
],
"resolveProvider": true
},
"codeLensProvider": {
"resolveProvider": true
},
"documentFormattingProvider": true,
"documentRangeFormattingProvider": false,
"documentOnTypeFormattingProvider": {
"firstTriggerCharacter": "=",
"moreTriggerCharacter": [
".",
">",
"{"
]
},
"renameProvider": {
"prepareProvider": true
},
"foldingRangeProvider": true,
"declarationProvider": true,
"workspace": {
"fileOperations": {
"willRename": {
"filters": [
{
"scheme": "file",
"pattern": {
"glob": "**/*.rs",
"matches": "file"
}
},
{
"scheme": "file",
"pattern": {
"glob": "**",
"matches": "folder"
}
}
]
}
}
},
"callHierarchyProvider": true,
"semanticTokensProvider": {
"legend": {
"tokenTypes": [
"comment",
"keyword",
"string",
"number",
"regexp",
"operator",
"namespace",
"type",
"struct",
"class",
"interface",
"enum",
"enumMember",
"typeParameter",
"function",
"method",
"property",
"macro",
"variable",
"parameter",
"angle",
"arithmetic",
"attribute",
"attributeBracket",
"bitwise",
"boolean",
"brace",
"bracket",
"builtinAttribute",
"builtinType",
"character",
"colon",
"comma",
"comparison",
"constParameter",
"derive",
"dot",
"escapeSequence",
"formatSpecifier",
"generic",
"label",
"lifetime",
"logical",
"macroBang",
"operator",
"parenthesis",
"punctuation",
"selfKeyword",
"selfTypeKeyword",
"semicolon",
"typeAlias",
"toolModule",
"union",
"unresolvedReference"
],
"tokenModifiers": [
"documentation",
"declaration",
"definition",
"static",
"abstract",
"deprecated",
"readonly",
"defaultLibrary",
"async",
"attribute",
"callable",
"constant",
"consuming",
"controlFlow",
"crateRoot",
"injected",
"intraDocLink",
"library",
"mutable",
"public",
"reference",
"trait",
"unsafe"
]
},
"range": true,
"full": {
"delta": true
}
},
"inlayHintProvider": true,
"experimental": {
"externalDocs": true,
"hoverRange": true,
"joinLines": true,
"matchingBrace": true,
"moveItem": true,
"onEnter": true,
"openCargoToml": true,
"parentModule": true,
"runnables": {
"kinds": [
"cargo"
]
},
"ssr": true,
"workspaceSymbolScopeKindFiltering": true
}
},
"serverInfo": {
"name": "rust-analyzer",
"version": "b5d7a712e 2022-04-25 stable"
}
}
<SOME OTHER LOGS>
[Trace - 3:23:16 PM] Sending request 'completionItem/resolve - (21)'.
Params: {
"label": "Command (use commands::Command)",
"kind": 8,
"deprecated": false,
"sortText": "fffffff0",
"filterText": "Command",
"textEdit": {
"newText": "Command",
"insert": {
"start": {
"line": 9,
"character": 4
},
"end": {
"line": 9,
"character": 8
}
},
"replace": {
"start": {
"line": 9,
"character": 4
},
"end": {
"line": 9,
"character": 8
}
}
},
"additionalTextEdits": [
{
"range": {
"start": {
"line": 2,
"character": 0
},
"end": {
"line": 2,
"character": 0
}
},
"newText": "use commands::Command;"
},
{
"range": {
"start": {
"line": 2,
"character": 0
},
"end": {
"line": 2,
"character": 0
}
},
"newText": "\n"
}
],
"data": {
"position": {
"textDocument": {
"uri": "file:///home/mouse/code/rust/ash/src/main.rs"
},
"position": {
"line": 9,
"character": 8
}
},
"imports": [
{
"full_import_path": "commands::Command",
"imported_name": "Command"
}
]
}
}
[Trace - 3:23:16 PM] Received response 'completionItem/resolve - (21)' in 10ms.
Result: {
"label": "Command (use commands::Command)",
"kind": 8,
"deprecated": false,
"sortText": "fffffff0",
"filterText": "Command",
"textEdit": {
"newText": "Command",
"insert": {
"start": {
"line": 9,
"character": 4
},
"end": {
"line": 9,
"character": 8
}
},
"replace": {
"start": {
"line": 9,
"character": 4
},
"end": {
"line": 9,
"character": 8
}
}
},
"additionalTextEdits": [
{
"range": {
"start": {
"line": 2,
"character": 0
},
"end": {
"line": 2,
"character": 0
}
},
"newText": "use commands::Command;"
},
{
"range": {
"start": {
"line": 2,
"character": 0
},
"end": {
"line": 2,
"character": 0
}
},
"newText": "\n"
},
{
"range": {
"start": {
"line": 2,
"character": 0
},
"end": {
"line": 2,
"character": 0
}
},
"newText": "use commands::Command;"
},
{
"range": {
"start": {
"line": 2,
"character": 0
},
"end": {
"line": 2,
"character": 0
}
},
"newText": "\n"
}
]
}
Reproduced, but looks like it's rust-analyzer's issue:
"additionalTextEdits": [
{
"range": {
"start": {
"line": 2,
"character": 0
},
"end": {
"line": 2,
"character": 0
}
},
"newText": "use commands::Command;"
},
{
"range": {
"start": {
"line": 2,
"character": 0
},
"end": {
"line": 2,
"character": 0
}
},
"newText": "\n"
},
{
"range": {
"start": {
"line": 2,
"character": 0
},
"end": {
"line": 2,
"character": 0
}
},
"newText": "use commands::Command;"
},
{
"range": {
"start": {
"line": 2,
"character": 0
},
"end": {
"line": 2,
"character": 0
}
},
"newText": "\n"
}
]
RA returns two use commands::Command;
textEdits, coc/coc-rust-analyzer applied them.
Oh, then I should probably go to rust-analyzers repo with my issue. Thanks for help!
I think I found where this problem is coming from, I opened an issue in coc.nvim here.
When I try to import local module, it imports it twice for some reason (some other libs that not belong to my project is auto-imported normally): Then I hit
Enter
:What's the output of
:CocInfo
What's the output of
:CocCommand rust-analyzer.serverVersion
My nvim config