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) 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)