coc-rust-analyzer 不再显示内嵌类型提示问题求助
coc-rust-analyzer 内嵌类型提示消失的解决办法
你的问题:此前coc-rust-analyzer会在变量旁显示类型提示(比如let a = 12;旁显示:i32),现在提示消失,当前配置如下:
{ "suggest.noselect": true, "rust-analyzer.inlayHints.typeHints.enable": true, "rust-analyzer.inlayHints.chainingHints.enable": true }
可按以下步骤排查解决:
开启全局内嵌提示总开关
仅开启类型提示的细分开关可能无效,需确保全局内嵌提示开关处于启用状态,在coc-settings.json中添加:"rust-analyzer.inlayHints.enable": true检查类型提示的细分配置
部分细分配置会隐藏特定场景的类型提示,确保以下配置未被设为true:"rust-analyzer.inlayHints.typeHints.hideClosureInitialization": false, "rust-analyzer.inlayHints.typeHints.hideNamedConstructor": false重启coc服务与Neovim
配置修改后需重启生效,在Neovim中执行:CocRestart重启coc服务,或直接重启Neovim。更新coc-rust-analyzer插件
旧版本可能存在bug,执行:CocUpdate coc-rust-analyzer更新插件,更新后再次重启验证。确认Neovim的内嵌提示支持
若使用较新版本的Neovim,需确保LSP内嵌提示功能未被禁用:- Lua配置:检查
init.lua中是否有vim.lsp.inlay_hint.enable(true) - Vimscript配置:确保无相关禁用设置
- Lua配置:检查
修改后的完整配置示例:
{ "suggest.noselect": true, "rust-analyzer.inlayHints.enable": true, "rust-analyzer.inlayHints.typeHints.enable": true, "rust-analyzer.inlayHints.chainingHints.enable": true, "rust-analyzer.inlayHints.typeHints.hideClosureInitialization": false, "rust-analyzer.inlayHints.typeHints.hideNamedConstructor": false }
完成以上操作后,打开Rust文件测试变量类型提示是否恢复。
内容的提问来源于stack exchange,提问作者realzhujunhao
相关产品推荐
相关产品推荐

