summaryrefslogtreecommitdiff
path: root/lua/lsp
diff options
context:
space:
mode:
authorAbouzar Parvan <[email protected]>2021-09-21 13:29:32 +0430
committerGitHub <[email protected]>2021-09-21 13:29:32 +0430
commit55d9a15a088d688627426b034f4b71aa86a8ce9e (patch)
tree29a2d88de39fe35e60d0e9f3bfc80b47ad8bb221 /lua/lsp
parentf5c03643a24a383f4cabe961b120fff45ad4e09b (diff)
[Bugfix] Wrap the `gl` floating window diagnostics (#1588)
Diffstat (limited to 'lua/lsp')
-rw-r--r--lua/lsp/handlers.lua8
1 files changed, 5 insertions, 3 deletions
diff --git a/lua/lsp/handlers.lua b/lua/lsp/handlers.lua
index d55bd0b2..2f06cb8a 100644
--- a/lua/lsp/handlers.lua
+++ b/lua/lsp/handlers.lua
@@ -126,18 +126,20 @@ function M.show_line_diagnostics()
if diagnostic.code then
diags[i].message = string.format("%s [%s]", diags[i].message, diagnostic.code)
end
- if diags[i].message:len() > width then
- width = string.len(diags[i].message)
- end
+ width = math.max(width, diags[i].message:len())
end
+ local max_width = vim.fn.winwidth(0) - 10
+ width = math.min(width, max_width)
opts = vim.lsp.util.make_floating_popup_options(width, height, opts)
opts["style"] = "minimal"
opts["border"] = "rounded"
+ opts["focusable"] = true
vim.api.nvim_buf_set_option(bufnr, "bufhidden", "wipe")
local winnr = vim.api.nvim_open_win(bufnr, false, opts)
vim.api.nvim_win_set_option(winnr, "winblend", 0)
+ vim.api.nvim_win_set_option(winnr, "wrap", true)
vim.api.nvim_buf_set_var(bufnr, "lsp_floating_window", winnr)
for i, diag in ipairs(diags) do
local message = diag.message:gsub("[\n\r]", " ")