mirror of
https://github.com/prabirshrestha/vim-lsp.git
synced 2025-12-14 20:35:59 +01:00
* 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
39 lines
911 B
VimL
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
|