From d43151ea0bb194f7463cc8762919cd38546973c2 Mon Sep 17 00:00:00 2001 From: Gregory Anders Date: Sat, 18 Sep 2021 15:00:32 -0600 Subject: feat(diagnostic): add option to include diagnostic source Add an option to virtual text display and floating window previews to include diagnostic source in the diagnostic message. --- runtime/lua/vim/lsp/diagnostic.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'runtime/lua/vim/lsp') diff --git a/runtime/lua/vim/lsp/diagnostic.lua b/runtime/lua/vim/lsp/diagnostic.lua index a9d93ae65f..b4557b0e26 100644 --- a/runtime/lua/vim/lsp/diagnostic.lua +++ b/runtime/lua/vim/lsp/diagnostic.lua @@ -103,6 +103,7 @@ local function diagnostic_lsp_to_vim(diagnostics, bufnr, client_id) end_col = line_byte_from_position(buf_lines, _end.line, _end.character, offset_encoding), severity = severity_lsp_to_vim(diagnostic.severity), message = diagnostic.message, + source = diagnostic.source, user_data = { lsp = { code = diagnostic.code, @@ -132,6 +133,7 @@ local function diagnostic_vim_to_lsp(diagnostics) }, severity = severity_vim_to_lsp(diagnostic.severity), message = diagnostic.message, + source = diagnostic.source, }, diagnostic.user_data and (diagnostic.user_data.lsp or {}) or {}) end, diagnostics) end -- cgit From bc652f148f6bb03511e36a0d9c3e383bb22abcfa Mon Sep 17 00:00:00 2001 From: Gregory Anders Date: Mon, 20 Sep 2021 15:32:14 -0600 Subject: refactor(diagnostic): remove get_virt_text_chunks() This function isn't compatible with including diagnostic sources when "source" is "if_many" since it only has access to diagnostics for a single line. Rather than having an inconsistent or incomplete interface, make this function private. It is still exported as part of the module for backward compatibility with vim.lsp.diagnostics, but it can eventually be made into a local function. --- runtime/lua/vim/lsp/diagnostic.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/lua/vim/lsp') diff --git a/runtime/lua/vim/lsp/diagnostic.lua b/runtime/lua/vim/lsp/diagnostic.lua index b4557b0e26..c6c08a15d3 100644 --- a/runtime/lua/vim/lsp/diagnostic.lua +++ b/runtime/lua/vim/lsp/diagnostic.lua @@ -529,7 +529,7 @@ end ---@return an array of [text, hl_group] arrays. This can be passed directly to --- the {virt_text} option of |nvim_buf_set_extmark()|. function M.get_virtual_text_chunks_for_line(bufnr, _, line_diags, opts) - return vim.diagnostic.get_virt_text_chunks(diagnostic_lsp_to_vim(line_diags, bufnr), opts) + return vim.diagnostic._get_virt_text_chunks(diagnostic_lsp_to_vim(line_diags, bufnr), opts) end --- Open a floating window with the diagnostics from {position} -- cgit