add:symbol usage
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user