[Bugfix] Wrap the gl floating window diagnostics (#1588)

This commit is contained in:
Abouzar Parvan 2021-09-21 13:29:32 +04:30 committed by GitHub
parent f5c03643a2
commit 55d9a15a08
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: 4AEE18F83AFDEB23

View file

@ -126,18 +126,20 @@ function M.show_line_diagnostics()
if diagnostic.code then if diagnostic.code then
diags[i].message = string.format("%s [%s]", diags[i].message, diagnostic.code) diags[i].message = string.format("%s [%s]", diags[i].message, diagnostic.code)
end end
if diags[i].message:len() > width then width = math.max(width, diags[i].message:len())
width = string.len(diags[i].message)
end
end 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 = vim.lsp.util.make_floating_popup_options(width, height, opts)
opts["style"] = "minimal" opts["style"] = "minimal"
opts["border"] = "rounded" opts["border"] = "rounded"
opts["focusable"] = true
vim.api.nvim_buf_set_option(bufnr, "bufhidden", "wipe") vim.api.nvim_buf_set_option(bufnr, "bufhidden", "wipe")
local winnr = vim.api.nvim_open_win(bufnr, false, opts) 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, "winblend", 0)
vim.api.nvim_win_set_option(winnr, "wrap", true)
vim.api.nvim_buf_set_var(bufnr, "lsp_floating_window", winnr) vim.api.nvim_buf_set_var(bufnr, "lsp_floating_window", winnr)
for i, diag in ipairs(diags) do for i, diag in ipairs(diags) do
local message = diag.message:gsub("[\n\r]", " ") local message = diag.message:gsub("[\n\r]", " ")