summaryrefslogtreecommitdiff
path: root/lua/telescope/make_entry.lua
diff options
context:
space:
mode:
authorfdschmidt93 <39233597+fdschmidt93@users.noreply.github.com>2021-06-10 17:13:34 +0200
committerGitHub <noreply@github.com>2021-06-10 17:13:34 +0200
commit1407ac3400971bcdbcf8b8026ff6957edfada1a3 (patch)
tree72148e3ada893f6112da738f392f33e0d7a4a8cb /lua/telescope/make_entry.lua
parentf9ce723f2ee0de17610d703e7a6553e875bafd2a (diff)
feat: improved configuration and sorting of lsp_{document,workspace}_diagnostics (#867)
Diffstat (limited to 'lua/telescope/make_entry.lua')
-rw-r--r--lua/telescope/make_entry.lua22
1 files changed, 9 insertions, 13 deletions
diff --git a/lua/telescope/make_entry.lua b/lua/telescope/make_entry.lua
index 2339fb6..4fee48d 100644
--- a/lua/telescope/make_entry.lua
+++ b/lua/telescope/make_entry.lua
@@ -29,13 +29,6 @@ local lsp_type_highlight = {
["Variable"] = "TelescopeResultsVariable",
}
-local lsp_type_diagnostic = {
- [1] = "Error",
- [2] = "Warning",
- [3] = "Information",
- [4] = "Hint"
-}
-
local make_entry = {}
do
@@ -936,18 +929,21 @@ end
function make_entry.gen_from_lsp_diagnostics(opts)
opts = opts or {}
opts.tail_path = utils.get_default(opts.tail_path, true)
+ local lsp_type_diagnostic = vim.lsp.protocol.DiagnosticSeverity
local signs
if not opts.no_sign then
signs = {}
- for _, v in pairs(lsp_type_diagnostic) do
+ for severity, _ 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)
+ if type(severity) == 'string' then
+ local status, sign = pcall(
+ function() return vim.trim(vim.fn.sign_getdefined("LspDiagnosticsSign" .. severity)[1].text) end)
+ if not status then
+ sign = severity:sub(1,1)
+ end
+ signs[severity] = sign
end
- signs[v] = sign
end
end