Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(diagnosticts): add option to show the source of the entry #3376

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/telescope.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)



Expand Down
3 changes: 2 additions & 1 deletion lua/telescope/builtin/__diagnostics.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions lua/telescope/builtin/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down