Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add preview options for hover function #189

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion autoload/lsp/ui/vim/output.vim
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ function! lsp#ui#vim#output#preview(data) abort

let l:current_window_id = win_getid()

execute &previewheight.'new'
execute g:lsp_preview_position.' '.&previewheight.'new'

let l:ft = s:append(a:data)
" Delete first empty line
0delete

if g:lsp_preview_auto_resize
execute 'resize ' . line('$')
endif
soywod marked this conversation as resolved.
Show resolved Hide resolved

setlocal readonly nomodifiable

let &l:filetype = l:ft . '.lsp-hover'
Expand Down
21 changes: 20 additions & 1 deletion doc/vim-lsp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ CONTENTS *vim-lsp-contents*
g:lsp_diagnostics_enabled |g:lsp_diagnostics_enabled|
g:lsp_auto_enable |g:lsp_auto_enable|
g:lsp_preview_keep_focus |g:lsp_preview_keep_focus|
g:lsp_preview_position |g:lsp_preview_position|
g:lsp_preview_auto_resize |g:lsp_preview_auto_resize|
g:lsp_insert_text_enabled |g:lsp_insert_text_enabled|
Functions |vim-lsp-functions|
enable |vim-lsp-enable|
Expand Down Expand Up @@ -136,6 +138,20 @@ g:lsp_preview_keep_focus *g:lsp_preview_keep_focus*

* |preview-window| can be closed using the default vim mapping - `<c-w><c-z>`.

g:lsp_preview_position *g:lsp_preview_position*
Type: |String|
Default: `above`

Indicates the position of the |preview-window| when a |preview-window| is
opened by vim-lsp. It can be `above` or `below`.

g:lsp_preview_auto_resize *g:lsp_preview_auto_resize*
Type: |Number|
Default: `0`

Indicates if the |preview-window| should be automatically resized to fit
its content when it is opened by vim-lsp.

g:lsp_insert_text_enabled *g:lsp_insert_text_enabled*
Type: |Number|
Default: `1`
Expand All @@ -147,7 +163,6 @@ g:lsp_insert_text_enabled *g:lsp_insert_text_enabled*
let g:lsp_insert_text_enabled = 1
let g:lsp_insert_text_enabled = 0


===============================================================================
FUNCTIONS *vim-lsp-functions*

Expand Down Expand Up @@ -371,6 +386,10 @@ Gets the hover information and displays it in the |preview-window|.
* |preview-window| can be closed using the default vim mapping - `<c-w><c-z>`.
* To control the default focus of |preview-window| for |LspHover|
configure |g:lsp_preview_keep_focus|.
* To control the default position of |preview-window| for |LspHover|
configure |g:lsp_preview_position|.
* To control the auto-resizing of the |preview-window| for |LspHover|
configure |g:lsp_preview_auto_resize|.


LspNextError *LspNextError*
Expand Down
2 changes: 2 additions & 0 deletions plugin/lsp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ let g:lsp_diagnostics_echo_cursor = get(g:, 'lsp_diagnostics_echo_cursor', 0)
let g:lsp_diagnostics_echo_delay = get(g:, 'lsp_diagnostics_echo_delay', 500)
let g:lsp_next_sign_id = get(g:, 'lsp_next_sign_id', 6999)
let g:lsp_preview_keep_focus = get(g:, 'lsp_preview_keep_focus', 1)
let g:lsp_preview_position = get(g:, 'lsp_preview_position', 'above')
let g:lsp_preview_auto_resize = get(g:, 'lsp_preview_auto_resize', 0)
let g:lsp_use_event_queue = get(g:, 'lsp_use_event_queue', 0)
let g:lsp_insert_text_enabled= get(g:, 'lsp_insert_text_enabled', 1)

Expand Down