Skip to content

Commit

Permalink
feat: make signs configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Apr 21, 2021
1 parent 83ac057 commit ff9fd51
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
4 changes: 3 additions & 1 deletion lua/trouble/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ local defaults = {
},
auto_open = false,
auto_close = true,
auto_preview = false
auto_preview = false,
signs = {error = "", warning = "", hint = "", information = ""},
use_lsp_diagnostic_signs = false
}

---@type Options
Expand Down
2 changes: 1 addition & 1 deletion lua/trouble/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function M.get_signs()
.text)
end)
if not status then sign = v:sub(1, 1) end
signs[v] = sign
signs[string.lower(v)] = sign
end
return signs
end
Expand Down
12 changes: 10 additions & 2 deletions lua/trouble/renderer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ local function get_icon(file)
return icons.get_icon(fname, ext, {default = true})
end

local function update_signs()
if config.options.use_lsp_diagnostic_signs then
signs = lsp.get_signs()
else
signs = config.options.signs
end
end

---@param view View
function renderer.render(view, opts)
opts = opts or {}
Expand All @@ -32,7 +40,7 @@ function renderer.render(view, opts)
end

-- Update lsp signs
signs = lsp.get_signs()
update_signs()

local text = Text:new()
view.items = {}
Expand Down Expand Up @@ -85,7 +93,7 @@ function renderer.render_diagnostics(view, text, items)
for _, diag in ipairs(items) do
view.items[text.lineNr] = diag

local sign = signs[diag.type]
local sign = signs[string.lower(diag.type)]
if not sign then sign = diag.type end

text:render(" " .. sign .. " ", "Sign" .. diag.type)
Expand Down

0 comments on commit ff9fd51

Please sign in to comment.