Skip to content

Commit

Permalink
add 'full' for line_width in diagnostics options (nvim-telescope#2452)
Browse files Browse the repository at this point in the history
* add 'full' for line_width in diagnostics options

* lowercase documentation entry and change error notify method

* moved line_width options checking
  • Loading branch information
blue-pitaya authored and rameshsanth committed Nov 17, 2023
1 parent 611f417 commit d5a0a79
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
8 changes: 8 additions & 0 deletions lua/telescope/builtin/__diagnostics.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
2 changes: 1 addition & 1 deletion lua/telescope/builtin/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 5 additions & 1 deletion lua/telescope/make_entry.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1167,9 +1167,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 = "",
Expand Down

0 comments on commit d5a0a79

Please sign in to comment.