From dc7f25c81025981ea20fa9ffa2697ef8459123a1 Mon Sep 17 00:00:00 2001 From: blue pitaya Date: Sun, 3 Sep 2023 21:15:21 +0200 Subject: [PATCH] add 'full' for line_width in diagnostics options (#2452) * add 'full' for line_width in diagnostics options * lowercase documentation entry and change error notify method * moved line_width options checking --- lua/telescope/builtin/__diagnostics.lua | 8 ++++++++ lua/telescope/builtin/init.lua | 2 +- lua/telescope/make_entry.lua | 6 +++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lua/telescope/builtin/__diagnostics.lua b/lua/telescope/builtin/__diagnostics.lua index e29be31..fcaa10f 100644 --- a/lua/telescope/builtin/__diagnostics.lua +++ b/lua/telescope/builtin/__diagnostics.lua @@ -146,6 +146,14 @@ diagnostics.get = function(opts) return end + if type(opts.line_width) == "string" and opts.line_width ~= "full" then + utils.notify("builtin.diagnostics", { + msg = string.format("'%s' is not a valid value for line_width", opts.line_width), + level = "ERROR", + }) + return + end + opts.path_display = vim.F.if_nil(opts.path_display, "hidden") pickers .new(opts, { diff --git a/lua/telescope/builtin/init.lua b/lua/telescope/builtin/init.lua index a02b58a..4e5d72e 100644 --- a/lua/telescope/builtin/init.lua +++ b/lua/telescope/builtin/init.lua @@ -532,7 +532,7 @@ builtin.lsp_dynamic_workspace_symbols = require_on_exported_call("telescope.buil ---@field root_dir string|boolean: if set to string, get diagnostics only for buffers under this dir otherwise cwd ---@field no_unlisted boolean: if true, get diagnostics only for listed buffers ---@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 string|number: set length of diagnostic entry text in Results. Use 'full' for full untruncated text ---@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") diff --git a/lua/telescope/make_entry.lua b/lua/telescope/make_entry.lua index 68af228..57d06a5 100644 --- a/lua/telescope/make_entry.lua +++ b/lua/telescope/make_entry.lua @@ -1164,9 +1164,13 @@ function make_entry.gen_from_diagnostics(opts) { remaining = true }, } local line_width = vim.F.if_nil(opts.line_width, 0.5) + local line_width_opts = { width = line_width } + if type(line_width) == "string" and line_width == "full" then + line_width_opts = {} + end local hidden = utils.is_path_hidden(opts) if not hidden then - table.insert(display_items, 2, { width = line_width }) + table.insert(display_items, 2, line_width_opts) end local displayer = entry_display.create { separator = "▏",