diff options
| author | fdschmidt93 <39233597+fdschmidt93@users.noreply.github.com> | 2021-03-04 21:53:41 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-04 21:53:41 +0100 |
| commit | 8369acea3e6b0258f125ea251111e3217655b11c (patch) | |
| tree | 3905f8d90ed2d3ce9c3e6eb3ecbfce3c0533b183 | |
| parent | e7f724b437aa0cdfecb144e39aea67d62b745f83 (diff) | |
fix: error from unset LspDiagnosticSign & introduce opts.no_sign to lsp_*_diagnostics (#607)
| -rw-r--r-- | lua/telescope/make_entry.lua | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/lua/telescope/make_entry.lua b/lua/telescope/make_entry.lua index 45601af..dd31193 100644 --- a/lua/telescope/make_entry.lua +++ b/lua/telescope/make_entry.lua @@ -858,16 +858,25 @@ function make_entry.gen_from_lsp_diagnostics(opts) opts = opts or {} opts.tail_path = utils.get_default(opts.tail_path, true) - local signs = {} - for _, v in pairs(lsp_type_diagnostic) do - signs[v] = vim.trim(vim.fn.sign_getdefined("LspDiagnosticsSign" .. v)[1].text) + local signs + if not opts.no_sign then + signs = {} + for _, v in pairs(lsp_type_diagnostic) do + -- pcall to catch entirely unbound or cleared out sign hl group + local status, sign = pcall( + function() return vim.trim(vim.fn.sign_getdefined("LspDiagnosticsSign" .. v)[1].text) end) + if not status then + sign = v:sub(1,1) + end + signs[v] = sign + end end local layout = { - { width = 9 }, + { width = utils.if_nil(signs, 8, 10) }, { remaining = true } } - local line_width = utils.get_default(opts.line_width, 47) + local line_width = utils.get_default(opts.line_width, 45) if not opts.hide_filename then table.insert(layout, 2, {width = line_width}) end local displayer = entry_display.create { separator = "▏", @@ -886,10 +895,10 @@ function make_entry.gen_from_lsp_diagnostics(opts) end -- add styling of entries - local pos = string.format("%3d:%2d", entry.lnum, entry.col) + local pos = string.format("%4d:%2d", entry.lnum, entry.col) local line_info = { - string.format("%s %s", signs[entry.type], pos), - string.format("LspDiagnosticsDefault%s", entry.type) + (signs and signs[entry.type] .. " " or "") .. pos, + "LspDiagnosticsDefault" .. entry.type } return displayer { |
