From: Indelog Date: Fri, 19 Nov 2021 09:37:53 +0000 (+0100) Subject: Fix : Better ft detection for preview widow on hover reply X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=bed903cb61dba4be5405d09be3cabd86083045f9;p=vim-lsp.git Fix : Better ft detection for preview widow on hover reply Avoid ` E715: Dictionary required` if lsp server does not provide the kind of reply. --- diff --git a/autoload/handlers.vim b/autoload/handlers.vim index 7a9126a..6c2adaf 100644 --- a/autoload/handlers.vim +++ b/autoload/handlers.vim @@ -335,8 +335,15 @@ def s:processHoverReply(lspserver: dict, req: dict, reply: dict): wincmd P setlocal buftype=nofile setlocal bufhidden=delete - if !reply.result.contents.kind->empty() - exe 'setlocal ft=' .. reply.result.contents.kind + # If lsp server provide kind of hover reply and this kind is in syntaxs + # syported by vim, use it for file type of preview window. Else use + # type text by default. + if reply.result.contents->has_key('kind') +\ && !reply.result.contents.kind->empty() +\ && getcompletion('', 'filetype')->index(reply.result.content.kind) > -1 + exe 'setlocal ft=' .. reply.result.contents.kind + else + set setlocal ft=text endif deletebufline(bufnr(), 1, getbufinfo(bufnr())[0].linecount) append(0, hoverText)