From 7684fdc1883b66649772fa2d25bcb23d4fba8823 Mon Sep 17 00:00:00 2001 From: Matt Green Date: Sat, 11 May 2024 07:54:16 -0700 Subject: [PATCH] split diagnostic lines on \n character in floating window --- lua/lspsaga/diagnostic/show.lua | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/lua/lspsaga/diagnostic/show.lua b/lua/lspsaga/diagnostic/show.lua index bcc1606cb..970a9d740 100644 --- a/lua/lspsaga/diagnostic/show.lua +++ b/lua/lspsaga/diagnostic/show.lua @@ -293,7 +293,7 @@ function sd:show(opt) curnode.expand = true for i, entry in ipairs(curnode.diags) do local virt_start = i == #curnode.diags and ui.lines[1] or ui.lines[2] - local mes = msg_fmt(entry) + if i == 1 then ---@diagnostic disable-next-line: param-type-mismatch local fname = fn.fnamemodify(api.nvim_buf_get_name(tonumber(entry.bufnr)), ':t') @@ -310,8 +310,26 @@ function sd:show(opt) count = count + 1 curnode.lnum = count end - self:write_line(mes, entry.severity, virt_start, count) - count = count + 1 + + local messages = vim.split(entry.message, '\n') + for j, message in ipairs(messages) do + local mes = '' + if j == 1 then + mes = msg_fmt({ + message = message, + lnum = entry.lnum, + col = entry.col, + bufnr = entry.bufnr, + source = entry.source, + code = entry.code, + }) + else + mes = ' ' .. message + end + + self:write_line(mes, entry.severity, virt_start, count) + count = count + 1 + end end curnode = curnode.next end