diff --git a/nvim/lua/plugins/lsp.lua b/nvim/lua/plugins/lsp.lua index c0a36fb..fa2133e 100644 --- a/nvim/lua/plugins/lsp.lua +++ b/nvim/lua/plugins/lsp.lua @@ -5,7 +5,7 @@ local mason_utils = require("utils.mason") local lsp_tools = require("plugins.lsp_tools") function M.setup() - pack.add({ "mason", "nvim-lspconfig", "conform" }) + pack.add({ "mason", "nvim-lspconfig", "conform", "symbol-usage" }) require("mason").setup() @@ -62,6 +62,32 @@ function M.setup() vim.diagnostic.config({ virtual_text = false }) + local function text_format(symbol) + local fragments = {} + + -- Indicator that shows if there are any other symbols in the same line + local stacked_functions = symbol.stacked_count > 0 and (" | +%s"):format(symbol.stacked_count) or "" + + if symbol.references then + local usage = symbol.references <= 1 and "usage" or "usages" + local num = symbol.references == 0 and "no" or symbol.references + table.insert(fragments, ("%s %s"):format(num, usage)) + end + + -- if symbol.definition then + -- table.insert(fragments, symbol.definition .. " defs") + -- end + + if symbol.implementation then + table.insert(fragments, symbol.implementation .. " impls") + end + + return table.concat(fragments, ", ") .. stacked_functions + end + require("symbol-usage").setup({ + text_format = text_format, + }) + local lsp_group = vim.api.nvim_create_augroup("UserLspAttach", { clear = true }) vim.api.nvim_create_autocmd("LspAttach", { group = lsp_group, diff --git a/nvim/lua/plugins/registry.lua b/nvim/lua/plugins/registry.lua index 85eae80..638c697 100644 --- a/nvim/lua/plugins/registry.lua +++ b/nvim/lua/plugins/registry.lua @@ -26,6 +26,7 @@ M.map = { ["grug-far.nvim"] = { name = "grug-far.nvim", src = "https://github.com/MagicDuck/grug-far.nvim" }, ["nvim-ts-autotag"] = { name = "nvim-ts-autotag", src = "https://github.com/windwp/nvim-ts-autotag" }, ["supermaven-nvim"] = { name = "supermaven-nvim", src = "https://github.com/supermaven-inc/supermaven-nvim" }, + ["symbol-usage"] = { name = "symbol-usage", src = "https://github.com/Wansmer/symbol-usage.nvim" }, } function M.by_names(names) diff --git a/nvim/nvim-pack-lock.json b/nvim/nvim-pack-lock.json index 3547c3d..6940fe2 100644 --- a/nvim/nvim-pack-lock.json +++ b/nvim/nvim-pack-lock.json @@ -88,9 +88,17 @@ "rev": "07d20fce48a5629686aefb0a7cd4b25e33947d50", "src": "https://github.com/supermaven-inc/supermaven-nvim" }, + "symbol-usage": { + "rev": "6a449e6b37be61a110606e9a67a7a308774f120f", + "src": "https://github.com/Wansmer/symbol-usage.nvim" + }, "telescope.nvim": { "rev": "f7c673b8e46e8f233ff581d3624a517d33a7e264", "src": "https://github.com/nvim-telescope/telescope.nvim" + }, + "trouble.nvim": { + "rev": "bd67efe408d4816e25e8491cc5ad4088e708a69a", + "src": "https://github.com/folke/trouble.nvim" } } }