feat(neovim): Show codelens virtual text for implementations

- Rust: `rust-analyzer` enable `lens`
- Rust: Refresh lens on LspAttach and subsequently on rust buffers
- Use `LspSaga` for all other lsp types to show codelens
This commit is contained in:
Pratik Tripathy
2025-08-21 23:32:23 +05:30
parent e7a1250a8a
commit c99861d997
3 changed files with 54 additions and 27 deletions

View File

@@ -7,8 +7,26 @@ if pcall(require, "rustaceanvim") then
vim.keymap.set("n", "<leader>rh", "<cmd>RustLsp openDocs<cr>", { desc = "Open docs.rs Documentation" })
vim.keymap.set("n", "<leader>rM", "<cmd>RustLsp view mir<cr>", { desc = "View Mid-Level IR", buffer = bufnr })
vim.keymap.set("n", "<leader>rH", "<cmd>RustLsp view hir<cr>", { desc = "View High-Level IR", buffer = bufnr })
vim.keymap.set("n", "<leader>rL", vim.lsp.codelens.refresh, { desc = "Run CodeLens" })
end
vim.api.nvim_create_autocmd("LspAttach", {
callback = function(event)
local client = vim.lsp.get_client_by_id(event.data.client_id)
if not client or client.name ~= "rust-analyzer" then
return
end
pcall(vim.lsp.codelens.refresh)
-- Setup ongoing refresh triggers
vim.api.nvim_create_autocmd({ "InsertLeave", "BufWritePost", "BufEnter" }, {
buffer = event.buf,
callback = vim.lsp.codelens.refresh,
})
end,
})
local function run_tests_with_coverage()
-- Run tests through neotest
require("neotest").run.run(vim.fn.expand("%"))

View File

@@ -156,12 +156,16 @@ return {
ui = {
-- kind = require("config.util").icons.kind_lspsaga,
kind = require("catppuccin.groups.integrations.lsp_saga").custom_kind(),
devicon = true,
title = true,
},
implement = { enabled = true },
symbol_in_winbar = {
implement = {
enable = true,
hide_keyword = true,
virtual_text = true,
sign = true,
priority = 100,
},
symbol_in_winbar = { enable = true, hide_keyword = true },
lightbulb = { virtual_text = false },
outline = { auto_preview = false },
})

View File

@@ -94,33 +94,38 @@ return {
postfix = { enable = true },
autoimport = { enable = true },
},
},
inlayHints = {
bindingModeHints = { enable = false },
chainingHints = { enable = true },
closingBraceHints = { enable = true, minLines = 25 },
closureReturnTypeHints = { enable = "never" },
lifetimeElisionHints = { enable = "never", useParameterNames = false },
maxLength = 25,
parameterHints = { enable = true },
reborrowHints = { enable = "never" },
renderColons = true,
typeHints = {
lens = {
enable = true,
hideClosureInitialization = false,
hideNamedConstructor = false,
implementations = { enable = true },
run = { enable = false },
},
},
procMacro = {
enable = true,
ignored = {
["async-trait"] = { "async_trait" },
["napi-derive"] = { "napi" },
["async-recursion"] = { "async_recursion" },
inlayHints = {
bindingModeHints = { enable = false },
chainingHints = { enable = true },
closingBraceHints = { enable = true, minLines = 25 },
closureReturnTypeHints = { enable = "never" },
lifetimeElisionHints = { enable = "never", useParameterNames = false },
maxLength = 25,
parameterHints = { enable = true },
reborrowHints = { enable = "never" },
renderColons = true,
typeHints = {
enable = true,
hideClosureInitialization = false,
hideNamedConstructor = false,
},
},
procMacro = {
enable = true,
ignored = {
["async-trait"] = { "async_trait" },
["napi-derive"] = { "napi" },
["async-recursion"] = { "async_recursion" },
},
},
files = {
excludeDirs = { ".direnv", ".git", ".github", ".gitlab", "bin", "node_modules", "target", "venv", ".venv" },
},
},
files = {
excludeDirs = { ".direnv", ".git", ".github", ".gitlab", "bin", "node_modules", "target", "venv", ".venv" },
},
},
},