mirror of
https://github.com/prabirshrestha/vim-lsp.git
synced 2025-12-14 20:35:59 +01:00
Fix float sizing in Neovim (#468)
* Fix float sizing in Neovim * Add g:lsp_preview_max_height
This commit is contained in:
committed by
GitHub
parent
1090950a59
commit
1ab8e838ef
@@ -74,9 +74,9 @@ function! s:get_float_positioning(height, width) abort
|
||||
let l:y = winline()
|
||||
if l:y + l:height >= winheight(0)
|
||||
" Float does not fit
|
||||
if l:y - 2 > l:height
|
||||
if l:y > l:height
|
||||
" Fits above
|
||||
let l:y = winline() - l:height -1
|
||||
let l:y = winline() - l:height - 1
|
||||
elseif l:y - 2 > winheight(0) - l:y
|
||||
" Take space above cursor
|
||||
let l:y = 1
|
||||
@@ -103,9 +103,13 @@ function! lsp#ui#vim#output#floatingpreview(data) abort
|
||||
let l:buf = nvim_create_buf(v:false, v:true)
|
||||
call setbufvar(l:buf, '&signcolumn', 'no')
|
||||
|
||||
" Try to get as much pace right-bolow the cursor, but at least 10x10
|
||||
" Try to get as much space around the cursor, but at least 10x10
|
||||
let l:width = max([s:bufwidth(), 10])
|
||||
let l:height = max([&lines - winline() + 1, 10])
|
||||
let l:height = max([&lines - winline() + 1, winline() - 1, 10])
|
||||
|
||||
if g:lsp_preview_max_height > 0
|
||||
let l:height = min([g:lsp_preview_max_height, l:height])
|
||||
endif
|
||||
|
||||
let l:opts = s:get_float_positioning(l:height, l:width)
|
||||
|
||||
@@ -130,6 +134,10 @@ function! lsp#ui#vim#output#floatingpreview(data) abort
|
||||
let l:options['maxwidth'] = g:lsp_preview_max_width
|
||||
endif
|
||||
|
||||
if g:lsp_preview_max_height > 0
|
||||
let l:options['maxheight'] = g:lsp_preview_max_height
|
||||
endif
|
||||
|
||||
let s:winid = popup_atcursor('...', l:options)
|
||||
endif
|
||||
return s:winid
|
||||
|
||||
@@ -29,6 +29,7 @@ CONTENTS *vim-lsp-contents*
|
||||
g:lsp_get_supported_capabilities |g:lsp_get_supported_capabilities|
|
||||
g:lsp_peek_alignment |g:lsp_peek_alignment|
|
||||
g:lsp_preview_max_width |g:lsp_preview_max_width|
|
||||
g:lsp_preview_max_height |g:lsp_preview_max_height|
|
||||
Functions |vim-lsp-functions|
|
||||
enable |vim-lsp-enable|
|
||||
disable |vim-lsp-disable|
|
||||
@@ -432,6 +433,13 @@ g:lsp_preview_max_width *g:lsp_preview_max_width*
|
||||
fit in the preview window. Use a value of `-1` to disable setting a
|
||||
maximum width.
|
||||
|
||||
g:lsp_preview_max_height *g:lsp_preview_max_height*
|
||||
Type: |Number|
|
||||
Default: `-1`
|
||||
|
||||
If positive, determines the maximum height of the preview window in
|
||||
characters. Use a value of `-1` to disable setting a maximum height.
|
||||
|
||||
===============================================================================
|
||||
FUNCTIONS *vim-lsp-functions*
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ let g:lsp_preview_autoclose = get(g:, 'lsp_preview_autoclose', 1)
|
||||
let g:lsp_preview_doubletap = get(g:, 'lsp_preview_doubletap', [function('lsp#ui#vim#output#focuspreview')])
|
||||
let g:lsp_peek_alignment = get(g:, 'lsp_peek_alignment', 'center')
|
||||
let g:lsp_preview_max_width = get(g:, 'lsp_preview_max_width', -1)
|
||||
let g:lsp_preview_max_height = get(g:, 'lsp_preview_max_height', -1)
|
||||
|
||||
let g:lsp_get_vim_completion_item = get(g:, 'lsp_get_vim_completion_item', [function('lsp#omni#default_get_vim_completion_item')])
|
||||
let g:lsp_get_supported_capabilities = get(g:, 'lsp_get_supported_capabilities', [function('lsp#default_get_supported_capabilities')])
|
||||
|
||||
Reference in New Issue
Block a user