⚙️ config(nvim): trying another lens plugin
This commit is contained in:
parent
c15b0082fb
commit
25b761d47c
1 changed files with 73 additions and 14 deletions
|
@ -1,14 +1,72 @@
|
||||||
|
local function h(name)
|
||||||
|
return vim.api.nvim_get_hl(0, { name = name })
|
||||||
|
end
|
||||||
|
|
||||||
|
-- hl-groups can have any name
|
||||||
|
vim.api.nvim_set_hl(0, "SymbolUsageRounding", { fg = h("CursorLine").bg, italic = true })
|
||||||
|
vim.api.nvim_set_hl(0, "SymbolUsageContent", { bg = h("CursorLine").bg, fg = h("Comment").fg, italic = true })
|
||||||
|
vim.api.nvim_set_hl(0, "SymbolUsageRef", { fg = h("Function").fg, bg = h("CursorLine").bg, italic = true })
|
||||||
|
vim.api.nvim_set_hl(0, "SymbolUsageDef", { fg = h("Type").fg, bg = h("CursorLine").bg, italic = true })
|
||||||
|
vim.api.nvim_set_hl(0, "SymbolUsageImpl", { fg = h("@keyword").fg, bg = h("CursorLine").bg, italic = true })
|
||||||
|
|
||||||
|
local function text_format(symbol)
|
||||||
|
local res = {}
|
||||||
|
|
||||||
|
local round_start = { "", "SymbolUsageRounding" }
|
||||||
|
local round_end = { "", "SymbolUsageRounding" }
|
||||||
|
|
||||||
|
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(res, round_start)
|
||||||
|
table.insert(res, { " ", "SymbolUsageRef" })
|
||||||
|
table.insert(res, { ("%s %s"):format(num, usage), "SymbolUsageContent" })
|
||||||
|
table.insert(res, round_end)
|
||||||
|
end
|
||||||
|
|
||||||
|
if symbol.definition then
|
||||||
|
if #res > 0 then
|
||||||
|
table.insert(res, { " ", "NonText" })
|
||||||
|
end
|
||||||
|
table.insert(res, round_start)
|
||||||
|
table.insert(res, { " ", "SymbolUsageDef" })
|
||||||
|
table.insert(res, { symbol.definition .. " defs", "SymbolUsageContent" })
|
||||||
|
table.insert(res, round_end)
|
||||||
|
end
|
||||||
|
|
||||||
|
if symbol.implementation then
|
||||||
|
if #res > 0 then
|
||||||
|
table.insert(res, { " ", "NonText" })
|
||||||
|
end
|
||||||
|
table.insert(res, round_start)
|
||||||
|
table.insert(res, { " ", "SymbolUsageImpl" })
|
||||||
|
table.insert(res, { symbol.implementation .. " impls", "SymbolUsageContent" })
|
||||||
|
table.insert(res, round_end)
|
||||||
|
end
|
||||||
|
|
||||||
|
return res
|
||||||
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
{
|
||||||
|
"Wansmer/symbol-usage.nvim",
|
||||||
|
enabled = false,
|
||||||
|
event = "BufReadPre", -- need run before LspAttach if you use nvim 0.9. On 0.10 use 'LspAttach'
|
||||||
|
opts = {
|
||||||
|
text_format = text_format,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
"VidocqH/lsp-lens.nvim",
|
"VidocqH/lsp-lens.nvim",
|
||||||
event = "BufReadPost",
|
event = "LspAttach",
|
||||||
opts = {
|
opts = {
|
||||||
sections = {
|
sections = {
|
||||||
definition = false,
|
definition = false,
|
||||||
references = function(count)
|
references = function(count)
|
||||||
return " Ref: " .. count
|
return " Ref: " .. count
|
||||||
end,
|
end,
|
||||||
implements = function(count)
|
implements = function(count)
|
||||||
return " Imp: " .. count
|
return " Imp: " .. count
|
||||||
end,
|
end,
|
||||||
git_authors = false,
|
git_authors = false,
|
||||||
},
|
},
|
||||||
|
@ -16,4 +74,5 @@ return {
|
||||||
keys = {
|
keys = {
|
||||||
{ "<leader>ue", "<cmd>LspLensToggle<cr>", desc = "Toggle Lsp Lens" },
|
{ "<leader>ue", "<cmd>LspLensToggle<cr>", desc = "Toggle Lsp Lens" },
|
||||||
},
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue