nixos_dots/nvim/lua/custom/plugins/symbol_usage.lua

41 lines
1.4 KiB
Lua

-- Symbol usage plugin
local SymbolKind = vim.lsp.protocol.SymbolKind
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
return {
{
'Wansmer/symbol-usage.nvim',
event = 'LspAttach', -- need run before LspAttach if you use nvim 0.9. On 0.10 use 'LspAttach'
config = function()
require('symbol-usage').setup {
filetypes = {},
log = { enabled = false, level = 'INFO', stdout = {}, log_file = {}, notify = {} },
text_format = text_format,
kinds = { SymbolKind.Function, SymbolKind.Method, SymbolKind.Class, SymbolKind.Struct, SymbolKind.Variable, SymbolKind.Constant },
}
end,
},
}