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")
|
local lsp_tools = require("plugins.lsp_tools")
|
||||||
|
|
||||||
function M.setup()
|
function M.setup()
|
||||||
pack.add({ "mason", "nvim-lspconfig", "conform" })
|
pack.add({ "mason", "nvim-lspconfig", "conform", "symbol-usage" })
|
||||||
|
|
||||||
require("mason").setup()
|
require("mason").setup()
|
||||||
|
|
||||||
@@ -62,6 +62,32 @@ function M.setup()
|
|||||||
|
|
||||||
vim.diagnostic.config({ virtual_text = false })
|
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 })
|
local lsp_group = vim.api.nvim_create_augroup("UserLspAttach", { clear = true })
|
||||||
vim.api.nvim_create_autocmd("LspAttach", {
|
vim.api.nvim_create_autocmd("LspAttach", {
|
||||||
group = lsp_group,
|
group = lsp_group,
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ M.map = {
|
|||||||
["grug-far.nvim"] = { name = "grug-far.nvim", src = "https://github.com/MagicDuck/grug-far.nvim" },
|
["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" },
|
["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" },
|
["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)
|
function M.by_names(names)
|
||||||
|
|||||||
@@ -88,9 +88,17 @@
|
|||||||
"rev": "07d20fce48a5629686aefb0a7cd4b25e33947d50",
|
"rev": "07d20fce48a5629686aefb0a7cd4b25e33947d50",
|
||||||
"src": "https://github.com/supermaven-inc/supermaven-nvim"
|
"src": "https://github.com/supermaven-inc/supermaven-nvim"
|
||||||
},
|
},
|
||||||
|
"symbol-usage": {
|
||||||
|
"rev": "6a449e6b37be61a110606e9a67a7a308774f120f",
|
||||||
|
"src": "https://github.com/Wansmer/symbol-usage.nvim"
|
||||||
|
},
|
||||||
"telescope.nvim": {
|
"telescope.nvim": {
|
||||||
"rev": "f7c673b8e46e8f233ff581d3624a517d33a7e264",
|
"rev": "f7c673b8e46e8f233ff581d3624a517d33a7e264",
|
||||||
"src": "https://github.com/nvim-telescope/telescope.nvim"
|
"src": "https://github.com/nvim-telescope/telescope.nvim"
|
||||||
|
},
|
||||||
|
"trouble.nvim": {
|
||||||
|
"rev": "bd67efe408d4816e25e8491cc5ad4088e708a69a",
|
||||||
|
"src": "https://github.com/folke/trouble.nvim"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user