♻️ refactor(nvim): symbol usage now as extra

This commit is contained in:
Sergio Laín 2023-12-07 22:49:53 +01:00
parent 5d13d9677d
commit 03ad7f74cf
No known key found for this signature in database
GPG key ID: 14C9B8080681777B
3 changed files with 27 additions and 81 deletions

View file

@ -24,7 +24,7 @@
"dial.nvim": { "branch": "master", "commit": "27eb570085db2ef44bff4f620d3806039184651c" }, "dial.nvim": { "branch": "master", "commit": "27eb570085db2ef44bff4f620d3806039184651c" },
"diffview.nvim": { "branch": "main", "commit": "3dc498c9777fe79156f3d32dddd483b8b3dbd95f" }, "diffview.nvim": { "branch": "main", "commit": "3dc498c9777fe79156f3d32dddd483b8b3dbd95f" },
"dooku.nvim": { "branch": "main", "commit": "10d7ccca5cdd30d4d03bc7433023590ca620edc7" }, "dooku.nvim": { "branch": "main", "commit": "10d7ccca5cdd30d4d03bc7433023590ca620edc7" },
"dropbar.nvim": { "branch": "master", "commit": "2b7c2d53363cb3d93376904dac3ea6d52dd900c5" }, "dropbar.nvim": { "branch": "master", "commit": "5ca5e7f7a57d5180654a73ae7cc06be74032c099" },
"edgy.nvim": { "branch": "main", "commit": "8355be45610afdf79a0bab32b91ee297997455b4" }, "edgy.nvim": { "branch": "main", "commit": "8355be45610afdf79a0bab32b91ee297997455b4" },
"flash.nvim": { "branch": "main", "commit": "48817af25f51c0590653bbc290866e4890fe1cbe" }, "flash.nvim": { "branch": "main", "commit": "48817af25f51c0590653bbc290866e4890fe1cbe" },
"friendly-snippets": { "branch": "main", "commit": "53d3df271d031c405255e99410628c26a8f0d2b0" }, "friendly-snippets": { "branch": "main", "commit": "53d3df271d031c405255e99410628c26a8f0d2b0" },
@ -40,7 +40,6 @@
"indent-blankline.nvim": { "branch": "master", "commit": "7206c77cb931f79885fc47f88ae18f99148392eb" }, "indent-blankline.nvim": { "branch": "master", "commit": "7206c77cb931f79885fc47f88ae18f99148392eb" },
"lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" }, "lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" },
"live-server.nvim": { "branch": "main", "commit": "f6f00a3f541251f0320910bb0d03c4ae14ee6d10" }, "live-server.nvim": { "branch": "main", "commit": "f6f00a3f541251f0320910bb0d03c4ae14ee6d10" },
"lsp-lens.nvim": { "branch": "main", "commit": "48bb1a7e271424c15f3d588d54adc9b7c319d977" },
"lualine.nvim": { "branch": "master", "commit": "2248ef254d0a1488a72041cfb45ca9caada6d994" }, "lualine.nvim": { "branch": "master", "commit": "2248ef254d0a1488a72041cfb45ca9caada6d994" },
"markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "9453e3d6cd2ca45d96e20f343e8f1b927364b630" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "9453e3d6cd2ca45d96e20f343e8f1b927364b630" },
@ -102,6 +101,7 @@
"smart-splits.nvim": { "branch": "master", "commit": "c970c7a3cc7ba635fd73d43c81b40f04c00f5058" }, "smart-splits.nvim": { "branch": "master", "commit": "c970c7a3cc7ba635fd73d43c81b40f04c00f5058" },
"sqlite.lua": { "branch": "master", "commit": "b7e28c8463254c46a8e61c52d27d6a2040492fc3" }, "sqlite.lua": { "branch": "master", "commit": "b7e28c8463254c46a8e61c52d27d6a2040492fc3" },
"suda.vim": { "branch": "master", "commit": "8b0fc3711760195aba104e2d190cff9af8267052" }, "suda.vim": { "branch": "master", "commit": "8b0fc3711760195aba104e2d190cff9af8267052" },
"symbol-usage.nvim": { "branch": "main", "commit": "6b4c65b65ce25842209348e067c4c015917acfe2" },
"telescope-all-recent.nvim": { "branch": "main", "commit": "766d79bedf8dd59c2d0a944a7cf3c98795ab5f07" }, "telescope-all-recent.nvim": { "branch": "main", "commit": "766d79bedf8dd59c2d0a944a7cf3c98795ab5f07" },
"telescope-floaterm.nvim": { "branch": "main", "commit": "ccd3f40ae30dce5de0e5d0f5069e08e7d9ad6d23" }, "telescope-floaterm.nvim": { "branch": "main", "commit": "ccd3f40ae30dce5de0e5d0f5069e08e7d9ad6d23" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" },

View file

@ -1,68 +1,4 @@
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 = function()
if vim.fn.has("nvim-0.10") == 1 then
return "LspAttach"
else
return "BufRead"
end
end,
opts = {
text_format = text_format,
},
},
{
"VidocqH/lsp-lens.nvim", "VidocqH/lsp-lens.nvim",
event = "LspAttach", event = "LspAttach",
opts = { opts = {
@ -80,5 +16,4 @@ return {
keys = { keys = {
{ "<leader>ue", "<cmd>LspLensToggle<cr>", desc = "Toggle Lsp Lens" }, { "<leader>ue", "<cmd>LspLensToggle<cr>", desc = "Toggle Lsp Lens" },
}, },
},
} }

View file

@ -0,0 +1,11 @@
return {
"Wansmer/symbol-usage.nvim",
event = function()
if vim.fn.has("nvim-0.10") == 1 then
return "LspAttach"
else
return "BufRead"
end
end,
opts = {},
}