From 73a98f36678342f3e424abb083603ed1addc1f2d Mon Sep 17 00:00:00 2001 From: Koliras Date: Thu, 5 Dec 2024 22:44:49 +0200 Subject: [PATCH 1/2] feat: add show_source option for builtin.diagnostics picker --- lua/telescope/builtin/__diagnostics.lua | 3 ++- lua/telescope/builtin/init.lua | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lua/telescope/builtin/__diagnostics.lua b/lua/telescope/builtin/__diagnostics.lua index ec129d634f..dde9b1c657 100644 --- a/lua/telescope/builtin/__diagnostics.lua +++ b/lua/telescope/builtin/__diagnostics.lua @@ -107,12 +107,13 @@ local diagnostics_to_tbl = function(opts) end local preprocess_diag = function(diagnostic) + local source = opts.show_source and " (" .. diagnostic.source .. ")" or "" return { bufnr = diagnostic.bufnr, filename = bufnr_name_map[diagnostic.bufnr], lnum = diagnostic.lnum + 1, col = diagnostic.col + 1, - text = vim.trim(diagnostic.message:gsub("[\n]", "")), + text = vim.trim(diagnostic.message:gsub("[\n]", "")) .. source, type = severities[diagnostic.severity] or severities[1], } end diff --git a/lua/telescope/builtin/init.lua b/lua/telescope/builtin/init.lua index 6e27c27ab3..cd12622bc7 100644 --- a/lua/telescope/builtin/init.lua +++ b/lua/telescope/builtin/init.lua @@ -539,6 +539,7 @@ builtin.lsp_dynamic_workspace_symbols = require_on_exported_call("telescope.buil ---@field namespace number: limit your diagnostics to a specific namespace ---@field disable_coordinates boolean: don't show the line & row numbers (default: false) ---@field sort_by string: sort order of the diagnostics results; see above notes (default: "buffer") +---@field show_source boolean: show source of diagnostic entries (default: false) builtin.diagnostics = require_on_exported_call("telescope.builtin.__diagnostics").get local apply_config = function(mod) From b95753d4ee1e70311ecdda71705cb59059657970 Mon Sep 17 00:00:00 2001 From: Koliras Date: Fri, 6 Dec 2024 12:29:53 +0200 Subject: [PATCH 2/2] chore: update docs --- doc/telescope.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/telescope.txt b/doc/telescope.txt index bb43329500..ccde4e8582 100644 --- a/doc/telescope.txt +++ b/doc/telescope.txt @@ -1835,6 +1835,8 @@ builtin.diagnostics({opts}) *telescope.builtin.diagnostics()* {sort_by} (string) sort order of the diagnostics results; see above notes (default: "buffer") + {show_source} (boolean) show source of diagnostic + entries (default: false)