Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions autoload/lsp/ui/vim/output.vim
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,6 @@ function! s:setcontent(lines, ft) abort
" nvim floating
call setline(1, a:lines)

" Set maximum width of floating window, if specified
if g:lsp_preview_max_width > 0
let &l:textwidth = g:lsp_preview_max_width
normal! gggqGgg
endif

setlocal readonly nomodifiable
let &l:filetype = a:ft . '.lsp-hover'
endif
Expand Down Expand Up @@ -301,8 +295,20 @@ function! lsp#ui#vim#output#preview(data, options) abort
call s:setcontent(l:lines, l:ft)

" Get size information while still having the buffer active
let l:bufferlines = line('$')
let l:maxwidth = max(map(getline(1, '$'), 'strdisplaywidth(v:val)'))
if g:lsp_preview_max_width > 0
let l:bufferlines = 0
let l:maxwidth = min([g:lsp_preview_max_width, l:maxwidth])

" Determine, for each line, how many "virtual" lines it spans, and add
" these together for all lines in the buffer
for l:line in getline(1, '$')
let l:num_lines = str2nr(string(ceil(strdisplaywidth(l:line) * 1.0 / g:lsp_preview_max_width)))
let l:bufferlines += max([l:num_lines, 1])
endfor
else
let l:bufferlines = line('$')
endif

if !s:supports_floating || !g:lsp_preview_float
" Set statusline
Expand Down