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" }, }