Skip to content

Commit

Permalink
Closing of floating preview & lightlinefix (vim8.1)
Browse files Browse the repository at this point in the history
  • Loading branch information
jerdna-regeiz committed Jun 24, 2019
1 parent 27500f2 commit 91128e9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
13 changes: 12 additions & 1 deletion autoload/lsp/ui/vim/output.vim
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ function! lsp#ui#vim#output#closepreview() abort
"closing floats in vim8.1 must use popup_close() (nvim could use nvim_win_close but pclose
"works)
if s:supports_floating && s:winid && g:lsp_preview_float && !has('nvim')
" TODO:
call popup_close(s:winid)
else
pclose
endif
let s:winid = v:false
augroup lsp_float_preview_close
augroup end
autocmd! lsp_float_preview_close CursorMoved,CursorMovedI,VimResized *
doautocmd User lsp_float_closed
endfunction
Expand Down Expand Up @@ -122,7 +123,17 @@ function! s:setcontent(lines, ft) abort
if s:supports_floating && g:lsp_preview_float && !has('nvim')
" vim popup
call setbufline(winbufnr(s:winid), 1, a:lines)
let l:lightline_toggle = v:false
if exists('#lightline') && !has("nvim")
" Lightline does not work in popups but does not recognize it yet.
" It is ugly to have an check for an other plugin here, better fix lightline...
let l:lightline_toggle = v:true
call lightline#disable()
endif
call win_execute(s:winid, 'setlocal filetype=' . a:ft . '.lsp-hover')
if l:lightline_toggle
call lightline#enable()
endif
else
" nvim floating
call setline(1, a:lines)
Expand Down
7 changes: 6 additions & 1 deletion ftplugin/lsp-hover.vim
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
" No usual did_ftplugin header here as we NEED to run this always

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

if has('syntax')
Expand Down

0 comments on commit 91128e9

Please sign in to comment.