use new floating window api for hover (#1078)

* use new floating window api for hover

* rename type to ui

* fix lint issues

* add support for --ui=float|preview for LspHover

* add g:lsp_hover_ui

* always show below the cursor

* close on move

* fix when using empty g:lsp_hover_ui

* add hover preview support

* apply markdown for preview

* show top if available

* fix col position when far right

* silent deletebufline

* fix indent

* remove language

* set language

* fix normalize

* don't close if curpos hasn't changed

* if hover window is foused close

* add border

* add double tap support for floating LspHover window and lsp-hover-close plug

* fix indent

* fix lint issue

* fix grammar

* *ed

* remove echom register

* fix indent

* add lsp-hover-float and lsp-hover-preview plug
This commit is contained in:
Prabir Shrestha
2021-12-17 15:04:04 -08:00
committed by GitHub
parent a91419ea0a
commit 10bbcb1142
4 changed files with 252 additions and 5 deletions

View File

@@ -60,6 +60,7 @@ let g:lsp_signature_help_delay = get(g:, 'lsp_signature_help_delay', 200)
let g:lsp_show_workspace_edits = get(g:, 'lsp_show_workspace_edits', 0)
let g:lsp_fold_enabled = get(g:, 'lsp_fold_enabled', 1)
let g:lsp_hover_conceal = get(g:, 'lsp_hover_conceal', 1)
let g:lsp_hover_ui = get(g:, 'lsp_hover_ui', '')
let g:lsp_ignorecase = get(g:, 'lsp_ignorecase', &ignorecase)
let g:lsp_semantic_enabled = get(g:, 'lsp_semantic_enabled', 0)
let g:lsp_text_document_did_save_delay = get(g:, 'lsp_text_document_did_save_delay', -1)
@@ -103,7 +104,10 @@ command! -nargs=? LspDocumentDiagnostics call lsp#internal#diagnostics#document_
\ extend({}, lsp#utils#args#_parse(<q-args>, {
\ 'buffers': {'type': type('')},
\ })))
command! -nargs=? -complete=customlist,lsp#utils#empty_complete LspHover call lsp#internal#document_hover#under_cursor#do({})
command! -nargs=? -complete=customlist,lsp#utils#empty_complete LspHover call lsp#internal#document_hover#under_cursor#do(
\ extend({}, lsp#utils#args#_parse(<q-args>, {
\ 'ui': { 'type': type('') },
\ })))
command! -nargs=* LspNextError call lsp#internal#diagnostics#movement#_next_error(<f-args>)
command! -nargs=* LspPreviousError call lsp#internal#diagnostics#movement#_previous_error(<f-args>)
command! -nargs=* LspNextWarning call lsp#internal#diagnostics#movement#_next_warning(<f-args>)
@@ -152,6 +156,8 @@ nnoremap <silent> <plug>(lsp-document-symbol) :<c-u>call lsp#ui#vim#document_sym
nnoremap <silent> <plug>(lsp-document-symbol-search) :<c-u>call lsp#internal#document_symbol#search#do({})<cr>
nnoremap <silent> <plug>(lsp-document-diagnostics) :<c-u>call lsp#internal#diagnostics#document_diagnostics_command#do({})<cr>
nnoremap <silent> <plug>(lsp-hover) :<c-u>call lsp#internal#document_hover#under_cursor#do({})<cr>
nnoremap <silent> <plug>(lsp-hover-float) :<c-u>call lsp#internal#document_hover#under_cursor#do({ 'ui': 'float' })<cr>
nnoremap <silent> <plug>(lsp-hover-preview) :<c-u>call lsp#internal#document_hover#under_cursor#do({ 'ui': 'preview' })<cr>
nnoremap <silent> <plug>(lsp-preview-close) :<c-u>call lsp#ui#vim#output#closepreview()<cr>
nnoremap <silent> <plug>(lsp-preview-focus) :<c-u>call lsp#ui#vim#output#focuspreview()<cr>
nnoremap <silent> <plug>(lsp-next-error) :<c-u>call lsp#internal#diagnostics#movement#_next_error()<cr>