Forráskód Böngészése

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

Abouzar Parvan 3 éve
szülő
commit
55d9a15a08
1 módosított fájl, 5 hozzáadás és 3 törlés
  1. 5 3
      lua/lsp/handlers.lua

+ 5 - 3
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]", " ")