Highlight deprecated symbols
I recently saw #1764 which highlights deprecated symbols in the completion list and I think this is an awesome feature.
Is it possible to extend that feature and highlight the deprecated symbols via diagnostics? For example, like rust_analyzer's deprecation highlights (note how foo() is hightlighted - er, struck-through - on line 6):
Showing an error when using a symbol that is a @compileError would require reliable semantic analysis (#552) to avoid emitting incorrect diagnostics. Using the build on save feature of ZLS or vscode-zig can provide these diagnostics.
#1764 does emit tokens with a "deprecated" modifier but it depends on the editor/client on whether they do anything with this information like highlighting the token as strike-through. I've checked VS Code, Sublime Text 4 and Helix but none of them highlighted a symbol as strike-through.
I was able to get symbols highlighted as strike-through in VS Code with the following setting:
"editor.semanticTokenColorCustomizations": {
"rules": {
"*.deprecated": {
"strikethrough": true
}
}
},
Not really sure which editor you were using but I am curious to see if your editor is special in that regard or rust_analyzer uses a different approach to get ~~foo~~ as strike-through in rust.
Probably making use of tags?: DiagnosticTag[];, https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#diagnostic
Not really sure which editor you were using but I am curious to see if your editor is special in that regard or rust_analyzer uses a different approach to get foo as strike-through in rust.
I'm using neovim (master branch). Neovim's documentation on its diagnostic framework suggests it supports the Deprecated diagnostic tag:
*hl-DiagnosticDeprecated*
DiagnosticDeprecated
Used for deprecated or obsolete code.
Using the build on save feature of ZLS or vscode-zig can provide these diagnostics.
I was able to get symbols highlighted as strike-through in VS Code with the following setting:
Interesting, I'll test with enable_build_on_save turned on and report back.
Probably making use of tags?: DiagnosticTag[];, https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#diagnostic
That does appear to be the case (using the lsp-types crate). However, I'm not familiar with rust_analyzer from a developer's perspective. I'm just a user. That could be a red herring.
Unfortunately, setting enable_build_on_save didn't get deprecation warning diagnostics comparable to rust-analyzer.
If you were able to get it working in VS Code, perhaps this is editor specific?
Swinging back around on this... I was able to reproduce your results on Windows using VS Code. This is an editor specific issue. I'm gonna close this, but if I find a way to get it working in Neovim I'll update this issue.
So I eventually figured this out, and it was a pretty dumb reason: I wasn't passing the client capabilities to the LSP server. After passing the capabilities to the setup call in my neovim lua, it worked:
require('lspconfig').zls.setup({
capabilities = client_capabilities,
})