Skip to content

Commit 71ae724

Browse files
committed
Closing of floating preview & lightlinefix (vim8.1)
1 parent 920f2f8 commit 71ae724

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

autoload/lsp/ui/vim/output.vim

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ function! lsp#ui#vim#output#closepreview() abort
1010
"closing floats in vim8.1 must use popup_close() (nvim could use nvim_win_close but pclose
1111
"works)
1212
if s:supports_floating && s:winid && g:lsp_preview_float && !has('nvim')
13-
" TODO:
1413
call popup_close(s:winid)
1514
else
1615
pclose
1716
endif
1817
let s:winid = v:false
18+
augroup lsp_float_preview_close
19+
augroup end
1920
autocmd! lsp_float_preview_close CursorMoved,CursorMovedI,VimResized *
2021
doautocmd User lsp_float_closed
2122
endfunction
@@ -122,7 +123,17 @@ function! s:setcontent(lines, ft) abort
122123
if s:supports_floating && g:lsp_preview_float && !has('nvim')
123124
" vim popup
124125
call setbufline(winbufnr(s:winid), 1, a:lines)
126+
let l:lightline_toggle = v:false
127+
if exists('#lightline') && !has("nvim")
128+
" Lightline does not work in popups but does not recognize it yet.
129+
" It is ugly to have an check for an other plugin here, better fix lightline...
130+
let l:lightline_toggle = v:true
131+
call lightline#disable()
132+
endif
125133
call win_execute(s:winid, 'setlocal filetype=' . a:ft . '.lsp-hover')
134+
if l:lightline_toggle
135+
call lightline#enable()
136+
endif
126137
else
127138
" nvim floating
128139
call setline(1, a:lines)

ftplugin/lsp-hover.vim

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
" No usual did_ftplugin header here as we NEED to run this always
22

3-
setlocal previewwindow buftype=nofile bufhidden=wipe noswapfile nobuflisted
3+
if has('patch-8.1.1517') && g:lsp_preview_float && !has('nvim')
4+
" Can not set buftype or popup_close will fail with 'not a popup window'
5+
setlocal previewwindow bufhidden=wipe noswapfile nobuflisted
6+
else
7+
setlocal previewwindow buftype=nofile bufhidden=wipe noswapfile nobuflisted
8+
endif
49
setlocal nocursorline nofoldenable
510

611
if has('syntax')

0 commit comments

Comments
 (0)