feat(diagnotics): add disable_coordinates option (#2477)

This commit is contained in:
James Trew
2023-05-24 05:05:10 -04:00
committed by GitHub
parent 8dd1cb2771
commit 106662e056
3 changed files with 36 additions and 24 deletions

View File

@@ -1646,28 +1646,31 @@ builtin.diagnostics({opts}) *telescope.builtin.diagnostics()*
{opts} (table) options to pass to the picker {opts} (table) options to pass to the picker
Options: ~ Options: ~
{bufnr} (number|nil) Buffer number to get diagnostics {bufnr} (number|nil) Buffer number to get
from. Use 0 for current buffer or diagnostics from. Use 0 for
nil for all buffers current buffer or nil for all
{severity} (string|number) filter diagnostics by severity name buffers
(string) or id (number) {severity} (string|number) filter diagnostics by severity
name (string) or id (number)
{severity_limit} (string|number) keep diagnostics equal or more {severity_limit} (string|number) keep diagnostics equal or more
severe wrt severity name (string) severe wrt severity name
or id (number) (string) or id (number)
{severity_bound} (string|number) keep diagnostics equal or less {severity_bound} (string|number) keep diagnostics equal or less
severe wrt severity name (string) severe wrt severity name
or id (number) (string) or id (number)
{root_dir} (string|boolean) if set to string, get diagnostics {root_dir} (string|boolean) if set to string, get
only for buffers under this dir diagnostics only for buffers
otherwise cwd under this dir otherwise cwd
{no_unlisted} (boolean) if true, get diagnostics only for {no_unlisted} (boolean) if true, get diagnostics only
listed buffers for listed buffers
{no_sign} (boolean) hide DiagnosticSigns from Results {no_sign} (boolean) hide DiagnosticSigns from
(default: false) Results (default: false)
{line_width} (number) set length of diagnostic entry text {line_width} (number) set length of diagnostic entry
in Results text in Results
{namespace} (number) limit your diagnostics to a {namespace} (number) limit your diagnostics to a
specific namespace specific namespace
{disable_coordinates} (boolean) don't show the line & row
numbers (default: false)

View File

@@ -485,6 +485,7 @@ builtin.lsp_dynamic_workspace_symbols = require_on_exported_call("telescope.buil
---@field no_sign boolean: hide DiagnosticSigns from Results (default: false) ---@field no_sign boolean: hide DiagnosticSigns from Results (default: false)
---@field line_width number: set length of diagnostic entry text in Results ---@field line_width number: set length of diagnostic entry text in Results
---@field namespace number: limit your diagnostics to a specific namespace ---@field namespace number: limit your diagnostics to a specific namespace
---@field disable_coordinates boolean: don't show the line & row numbers (default: false)
builtin.diagnostics = require_on_exported_call("telescope.builtin.__diagnostics").get builtin.diagnostics = require_on_exported_call("telescope.builtin.__diagnostics").get
local apply_config = function(mod) local apply_config = function(mod)

View File

@@ -1152,8 +1152,15 @@ function make_entry.gen_from_diagnostics(opts)
return signs return signs
end)() end)()
local sign_width
if opts.disable_coordinates then
sign_width = signs ~= nil and 2 or 0
else
sign_width = signs ~= nil and 10 or 8
end
local display_items = { local display_items = {
{ width = signs ~= nil and 10 or 8 }, { width = sign_width },
{ remaining = true }, { remaining = true },
} }
local line_width = vim.F.if_nil(opts.line_width, 0.5) local line_width = vim.F.if_nil(opts.line_width, 0.5)
@@ -1171,8 +1178,9 @@ function make_entry.gen_from_diagnostics(opts)
-- add styling of entries -- add styling of entries
local pos = string.format("%4d:%2d", entry.lnum, entry.col) local pos = string.format("%4d:%2d", entry.lnum, entry.col)
local line_info_text = signs and signs[entry.type] .. " " or ""
local line_info = { local line_info = {
(signs and signs[entry.type] .. " " or "") .. pos, opts.disable_coordinates and line_info_text or line_info_text .. pos,
"DiagnosticSign" .. entry.type, "DiagnosticSign" .. entry.type,
} }