Skip to content

Commit

Permalink
feat: Make floating window configuration customizable (#310)
Browse files Browse the repository at this point in the history
* feat(ui): make floating window border configurable

* docs: document setting in readme

* feat: make the entire configuration customizable
  • Loading branch information
MariaSolOs committed Jul 28, 2023
1 parent 6386dd8 commit ef0336a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ Trouble comes with the following defaults:
},
multiline = true, -- render multi-line messages
indent_lines = true, -- add an indent guide below the fold icons
win_config = { border = "single" }, -- window configuration for floating windows. See |nvim_open_win()|.
auto_open = false, -- automatically open the list when you have diagnostics
auto_close = false, -- automatically close the list when you have no diagnostics
auto_preview = true, -- automatically preview the location of the diagnostic. <esc> to close preview and go back to last window
Expand Down
3 changes: 2 additions & 1 deletion lua/trouble/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ local defaults = {
},
multiline = true, -- render multi-line messages
indent_lines = true, -- add an indent guide below the fold icons
win_config = { border = "single" }, -- window configuration for floating windows. See |nvim_open_win()|.
auto_open = false, -- automatically open the list when you have diagnostics
auto_close = false, -- automatically close the list when you have no diagnostics
auto_preview = true, -- automatically preview the location of the diagnostic. <esc> to close preview and go back to last window
auto_fold = false, -- automatically fold a file trouble list at creation
auto_jump = { "lsp_definitions" }, -- for the given modes, automatically jump if there is only a single result
include_declaration = { "lsp_references", "lsp_implementations", "lsp_definitions" }, -- for the given modes, include the declaration of the current symbol in the results
include_declaration = { "lsp_references", "lsp_implementations", "lsp_definitions" }, -- for the given modes, include the declaration of the current symbol in the results
signs = {
-- icons / text used for a diagnostic
error = "",
Expand Down
6 changes: 3 additions & 3 deletions lua/trouble/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function Trouble.open(...)
config.options.mode = opts.mode
end

if opts.severity and (opts.severity ~=config.options.severity) then
if opts.severity and (opts.severity ~= config.options.severity) then
config.options.severity = opts.severity
end

Expand Down Expand Up @@ -110,7 +110,7 @@ function Trouble.help()
height = height + 1
end
-- help
vim.lsp.util.open_floating_preview(lines, "markdown", { border = "single" })
vim.lsp.util.open_floating_preview(lines, "markdown", config.options.win_config)
end

local updater = util.debounce(100, function()
Expand Down Expand Up @@ -169,7 +169,7 @@ function Trouble.action(action)
action = "refresh"
end

if action == 'switch_severity' then
if action == "switch_severity" then
if config.options.severity == nil then
config.options.severity = vim.diagnostic.severity.ERROR
elseif config.options.severity < 4 then
Expand Down
2 changes: 1 addition & 1 deletion lua/trouble/view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ function View:hover(opts)
if not (item and item.full_text) then
return
end
vim.lsp.util.open_floating_preview(vim.split(item.full_text, "\n"), "markdown", { border = "single" })
vim.lsp.util.open_floating_preview(vim.split(item.full_text, "\n"), "markdown", config.options.win_config)
end

function View:jump(opts)
Expand Down

0 comments on commit ef0336a

Please sign in to comment.