nixos-private-dots/nvim/lua/custom/plugins/symbol_usage.lua
Buliway 356c37f179 Update system to latest unstable and Linux 6.18.5
Changes
- Update pkgs to latest unstable (2026.01.19) and spkgs to 25.05
- Fix qt5 "end of life" and use `sddm qt5`
- Fix mpv config symlink
- Fix starship config
- Refactor `packages.nix`
- Rename `hardware.pulseaudio` to `services.pulseaudio`
- Use `qview` as a default image viewer
- Disable `qt` theme settings in `./shit/`. Stylix now works with Qt
- Enable `flatpak`, `grub OS prober`
- Install `kubernetes`, `godot`, `ldtk`, `adb`, `throne`, `amnezia`
- Update `neovim` to 0.11
- Delete `vscode.nix`, `imv.nix`, `git.nix`, `lynx.nix`
- Delete `mtr`, `ollama`, `pg-admin4`, `postgres-lsp`, `lynx`, `imv`, `feh`, `osu`, `gimp`
- Delete `rustup` and `driwio` cuz no binary cache
- Commented many packages
2026-01-19 06:11:22 +03:00

87 lines
3.2 KiB
Lua

-- Symbol usage plugin
local SymbolKind = vim.lsp.protocol.SymbolKind
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' }
-- Indicator that shows if there are any other symbols in the same line
local stacked_functions_content = 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(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
if stacked_functions_content ~= '' then
if #res > 0 then
table.insert(res, { ' ', 'NonText' })
end
table.insert(res, round_start)
table.insert(res, { '', 'SymbolUsageImpl' })
table.insert(res, { stacked_functions_content, 'SymbolUsageContent' })
table.insert(res, round_end)
end
return res
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,
},
}