From a7c79cb5a04562be10347856642a80f0c4be89fc Mon Sep 17 00:00:00 2001 From: delta Date: Fri, 17 Apr 2026 08:10:30 +0200 Subject: sync --- .config/nvim/lua/plugins/trouble.lua | 109 +++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 .config/nvim/lua/plugins/trouble.lua (limited to '.config/nvim/lua/plugins/trouble.lua') diff --git a/.config/nvim/lua/plugins/trouble.lua b/.config/nvim/lua/plugins/trouble.lua new file mode 100644 index 0000000..cc40587 --- /dev/null +++ b/.config/nvim/lua/plugins/trouble.lua @@ -0,0 +1,109 @@ +local icons = require "icons" + +return { + "folke/trouble.nvim", + opts = function() + local Util = require "trouble.util" + return { + modes = { + symbols = { + win = { + position = "right", + size = 0.4, + }, + format = "{symbol_kind} {symbol_pos:Comment} {symbol.name} {text:Comment}", + preview = { + type = "float", + relative = "editor", + border = "rounded", + title = "Preview", + title_pos = "center", + position = { 1, 0 }, + size = { width = 0.3, height = 0.3 }, + zindex = 200, + }, + }, + qflist = { + win = { + position = "right", + size = 0.4, + }, + format = "{severity_icon|item.type:DiagnosticSignWarn} {text:ts} {pos:Comment}", + preview = { + type = "float", + relative = "editor", + border = "rounded", + title = "Preview", + title_pos = "center", + position = { 1, 0 }, + size = { width = 0.3, height = 0.3 }, + zindex = 200, + }, + }, + diagnostics = { + win = { + position = "down", + size = 0.4, + }, + preview = { + type = "split", + relative = "win", + position = "right", + size = 0.5, + }, + }, + }, + icons = { + kinds = icons.kinds, + }, + formatters = { + symbol_kind = function(ctx) + return { text = "[" .. ctx.item.kind .. "]", hl = "Type" } + end, + symbol_pos = function(ctx) + return "@ " .. ctx.item.pos[1] .. ":" .. (ctx.item.pos[2] + 1) + end, + severity_icon = function(ctx) + local severity = ctx.item.severity or vim.diagnostic.severity.ERROR + if not vim.diagnostic.severity[severity] then + return + end + if type(severity) == "string" then + severity = vim.diagnostic.severity[severity:upper()] or vim.diagnostic.severity.ERROR + end + local name = Util.camel(vim.diagnostic.severity[severity]:lower()) + local sign = vim.fn.sign_getdefined("DiagnosticSign" .. name)[1] + local config = vim.diagnostic.config() or {} + if config.signs == nil or type(config.signs) == "boolean" then + return { + text = sign and "[" .. sign.text .. "]" or name:sub(1, 1), + hl = "DiagnosticSign" .. name, + } + end + local signs = config.signs or {} + if type(signs) == "function" then + signs = signs(0, 0) --[[@as vim.diagnostic.Opts.Signs]] + end + return { + text = type(signs) == "table" and signs.text and "[" .. signs.text[severity] .. "]" + or sign and sign.text + or name:sub(1, 1), + hl = "DiagnosticSign" .. name, + } + end, + }, + signs = true, + } + end, + dependencies = { "nvim-tree/nvim-web-devicons" }, + keys = { + { + "pe", + "Trouble diagnostics toggle win.position=bottom", + desc = "Toggle diagnstostics panel", + }, + { "ps", "Trouble symbols toggle", desc = "Toggle symbols panel" }, + { "pq", "Trouble qflist toggle", desc = "Toggle quickfix panel" }, + }, + cmd = { "Trouble" }, +} -- cgit v1.2.3