-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
a153443
commit 203d682
Showing
6 changed files
with
87 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
" No usual did_ftplugin header here as we NEED to run this always | ||
|
||
setlocal previewwindow buftype=nofile bufhidden=wipe noswapfile nobuflisted | ||
setlocal nocursorline nofoldenable | ||
|
||
if has('syntax') | ||
setlocal nospell | ||
endif | ||
|
||
let &l:statusline = ' LSP Hover' | ||
|
||
let b:undo_ftplugin = 'setlocal pvw< bt< bh< swf< bl< cul< fen<' . | ||
\ (has('syntax') ? ' spell<' : '') . | ||
\ ' | unlet! g:markdown_fenced_languages' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters