Files
vim-lsp-mirror/autoload/lsp/ui/vim/output.vim
Łukasz Jan Niemier 203d682e30 Create preview window instead of using quickfix list (#78)
* Create preview window instead of using quickfix list

This removes from us burden of providing formatting for content as this
is now simple as setting proper filetype.

* Create custom filetype for preview window

This will allow users to provide their own mappings and features in
hover window easily.

* Add proper statusline for LSP Hover

* Guard and undo_ftplugin

* Support all LSP hover syntaxes
2018-01-01 13:29:50 -08:00

39 lines
911 B
VimL

function! lsp#ui#vim#output#preview(data) abort
" Close any previously opened preview window
pclose
execute &previewheight.'new'
let l:ft = s:append(a:data)
" Delete first empty line
0delete
setlocal readonly nomodifiable
let &l:filetype = l:ft . '.lsp-hover'
endfunction
function! s:append(data) abort
if type(a:data) == type([])
for l:entry in a:data
call s:append(entry)
endfor
return 'markdown'
elseif type(a:data) == type('')
put =a:data
return 'markdown'
elseif type(a:data) == type({}) && has_key(a:data, 'language')
put ='```'.a:data.language
put =a:data.value
put ='```'
return 'markdown'
elseif type(a:data) == type({}) && has_key(a:data, 'kind')
put =a:data.value
return a:data.kind == 'plaintext' ? 'text' : a:data.kind
endif
endfunction