Comments (8)
diagnostic.separateRelatedInformationAsDiagnostics
has added into coc.nvim.
from coc-rust-analyzer.
Agreed, showing related informations will do grep help for user. We should not be limited to how VSCode does.
from coc-rust-analyzer.
coc.nvim + coc-rust-analyzer already support relatedInformation
diagnostic, but not displayed in floating window. Put your cursor on line 6 x
, current diagnostic position, run :CocCommand workspace.diagnosticRelated
, you will get related informations in coc lists.
I'll try to improve this.
from coc-rust-analyzer.
Try :CocUpdate
. I've displayed relatedInformation
messages with diagnostic message. You still need :CocCommand workspace.diagnosticRelated
to do jumping.
from coc-rust-analyzer.
Thank for the quick answer/fix! Much more usable now :)
However, I usually use the virtual text feature much more than the floating messages, so seeing them there would be the absolute best, but I think I'll try experimenting with the plugin code myself and report my findings when I did :)
from coc-rust-analyzer.
With a bit of experimentation I managed to create separate diagnostics from the related information.
IMO this should probably be solved directly in neoclide/coc.nvim though, since many language servers publish related information, which might be useful to see in-editor.
diff --git a/src/client.ts b/src/client.ts
index 4f749af..fdc6862 100644
--- a/src/client.ts
+++ b/src/client.ts
@@ -40,18 +40,26 @@ export function createClient(config: Config, bin: string): LanguageClient {
return help;
},
handleDiagnostics: async (uri, diagnostics, next) => {
+ const mkInfoDiag = (related, diag) => {
+ return {
+ "code": diag.code,
+ "source": diag.source,
+ "message": related.message,
+ "range": related.location.range,
+ "uri": related.location.uri,
+ "severity": 4
+ };
+ };
+ const infos = [];
+
diagnostics.map((diagnostic) => {
if (diagnostic.relatedInformation) {
- let message = `${diagnostic.message}\n\nRelated diagnostics: (Run \`:CocCommand workspace.diagnosticRelated\` to jump)\n`;
for (const info of diagnostic.relatedInformation) {
- const basename = path.basename(Uri.parse(info.location.uri).fsPath);
- const ln = info.location.range.start.line;
- message = `${message}\n${basename}(line ${ln + 1}): ${info.message}`;
+ infos.push(mkInfoDiag(info, diagnostic));
}
- diagnostic.message = message;
}
});
- next(uri, diagnostics);
+ next(uri, diagnostics.concat(infos));
},
},
outputChannel,
from coc-rust-analyzer.
I was going to concat related information as diagnostics to all diagnostics list, same as what your patch does, but this is how VSCode + rust-analyzer does:
I don't know whether it's correct to separate the related informations to diagnostics list.
from coc-rust-analyzer.
At least for me, fixing bugs in a larger function is much easier when the related diagnostics are also shown directly in the editor.
It would be cool to have it as an option, so users can choose whether or not they should be shown as separate diagnostics.
Also, integrating the related information into the popup should IMO also be solved in coc.nvim, since it might be useful to have the message structured (this would allow switching between both styles for any language via a config option).
TL;DR:
- yes, if your whole goal is to just replicate the VS-code plugin, then your patch is better than mine
- fixing this for all of CoC would make this much more configurable and more flexible, on top of giving the user more choice in how to view his errors / warnings
I'm going to try to look at the CoC codebase, and see if I can integrate something like what you did, and as a configurable option my proposal.
from coc-rust-analyzer.
Related Issues (20)
- rust-analyzer failed to start in coc.nvim HOT 2
- unresolved import regex: maybe a missing crate regex? HOT 2
- Ubuntu22.04云主机UEFI版,源码安装vim9和coc.nvim后,用coc命令安装该插件后,发现rust插件不能正常运行 HOT 1
- couldn't create connection to server. HOT 2
- question: how to check which rust analyzer binary is being used HOT 1
- How to disable the documentation in pmenu HOT 1
- How to stop notes from showing-up in the editor? HOT 3
- Installation error on macOS M2 airbook
- The last two lines of doc comments are always missing in popup window. HOT 8
- rust-analyzer.completion.snippets.custom was not covered as expected, but was added instead HOT 1
- is rust-analyzer.checkOnSave.command deprecated? HOT 1
- Warning diagnostics underline formatting is using hint underline formatting.
- Extraneous backslashes in code-action auto completes HOT 7
- overly long loop turn warning on every few keytypes HOT 3
- codelens run, how to make the split configurable? HOT 4
- Performance issues, for a large number of header comments HOT 12
- Failed to activate after setting a http_proxy HOT 1
- backslash generated if we use extract into a function OR fill struct fields etc OR implement missing members HOT 2
- implement missing members sometimes generated anti slashes before } HOT 4
- Fails to load when `rust-analyzer` component is not installed via rustup HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from coc-rust-analyzer.