aboutsummaryrefslogtreecommitdiff
path: root/.config/nvim/lua/plugins/trouble.lua
diff options
context:
space:
mode:
authordelta <darkussdelta@gmail.com>2026-04-17 08:10:30 +0200
committerdelta <darkussdelta@gmail.com>2026-04-17 08:10:30 +0200
commita7c79cb5a04562be10347856642a80f0c4be89fc (patch)
tree98fac95855d84f5037a1c6f44061cbe94b550600 /.config/nvim/lua/plugins/trouble.lua
parent225eeafcea67d63a608f9c666faf2a2ef014be4a (diff)
Diffstat (limited to '.config/nvim/lua/plugins/trouble.lua')
-rw-r--r--.config/nvim/lua/plugins/trouble.lua109
1 files changed, 109 insertions, 0 deletions
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 = {
+ {
+ "<Leader>pe",
+ "<cmd>Trouble diagnostics toggle win.position=bottom<CR>",
+ desc = "Toggle diagnstostics panel",
+ },
+ { "<Leader>ps", "<cmd>Trouble symbols toggle<CR>", desc = "Toggle symbols panel" },
+ { "<Leader>pq", "<cmd>Trouble qflist toggle<CR>", desc = "Toggle quickfix panel" },
+ },
+ cmd = { "Trouble" },
+}