From d423105cf6490331039ddfe53514f7a61d2eea88 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Sun, 20 Feb 2022 14:10:31 +0100 Subject: add utility functions detecting certain return types --- init.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/init.lua b/init.lua index 840fb38..2b58ccf 100644 --- a/init.lua +++ b/init.lua @@ -574,6 +574,19 @@ local function vis_apply_workspaceEdit(_, _, workspaceEdit) end end +-- Detect a MarkedString +-- https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/#markedString +local function lsp_is_marked_string(s) + return type(s) == 'string' or (type(s) == 'table' and s.language and s.value) +end + +-- Detect MarkupContent +-- https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/#markupContent +local function lsp_is_markup_content(s) + return type(s) == 'table' and s.kind and + (s.kind == 'markdown' or s.kind == 'plaintext') and s.value +end + local function lspc_highlight_diagnostics(win, diagnostics) for _, diagnostic in ipairs(diagnostics) do local range = diagnostic.vis_range -- cgit v1.2.3