Skip to content

Commit

Permalink
make float auto close configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
Boyang Du committed Apr 24, 2024
1 parent f7ccf00 commit d595f41
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
8 changes: 6 additions & 2 deletions autoload/lsp/internal/diagnostics/float.vim
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,19 @@ function! lsp#internal#diagnostics#float#_enable() abort

let s:Dispose = lsp#callbag#pipe(
\ lsp#callbag#merge(
\ lsp#callbag#fromEvent(['CursorMoved', 'CursorHold']),
\ lsp#callbag#fromEvent(['CursorMoved', ]),
\ lsp#callbag#pipe(
\ lsp#callbag#fromEvent(['CursorHold', ]),
\ lsp#callbag#filter({_->g:lsp_diagnostics_float_close_on_hold}),
\ lsp#callbag#tap({_->s:hide_float()}),
\ ),
\ lsp#callbag#pipe(
\ lsp#callbag#fromEvent(['InsertEnter']),
\ lsp#callbag#filter({_->!g:lsp_diagnostics_float_insert_mode_enabled}),
\ lsp#callbag#tap({_->s:hide_float()}),
\ )
\ ),
\ lsp#callbag#filter({_->g:lsp_diagnostics_float_cursor}),
\ lsp#callbag#tap({_->s:hide_float()}),
\ lsp#callbag#debounceTime(g:lsp_diagnostics_float_delay),
\ lsp#callbag#map({_->{'bufnr': bufnr('%'), 'curpos': getcurpos()[0:2], 'changedtick': b:changedtick }}),
\ lsp#callbag#distinctUntilChanged({a,b -> a['bufnr'] == b['bufnr'] && a['curpos'] == b['curpos'] && a['changedtick'] == b['changedtick']}),
Expand Down
14 changes: 14 additions & 0 deletions doc/vim-lsp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ CONTENTS *vim-lsp-contents*
g:lsp_diagnostics_echo_delay |g:lsp_diagnostics_echo_delay|
g:lsp_diagnostics_float_cursor |g:lsp_diagnostics_float_cursor|
g:lsp_diagnostics_float_delay |g:lsp_diagnostics_float_delay|
g:lsp_diagnostics_float_close_on_hold
|g:lsp_diagnostics_float_close_on_hold|
g:lsp_diagnostics_float_insert_mode_enabled
|g:lsp_diagnostics_float_insert_mode_enabled|
g:lsp_diagnostics_highlights_enabled
Expand Down Expand Up @@ -535,6 +537,18 @@ g:lsp_diagnostics_float_delay *g:lsp_diagnostics_float_delay*
let g:lsp_diagnostics_float_delay = 200
let g:lsp_diagnostics_float_delay = 1000
g:lsp_diagnostics_float_close_on_hold
*g:lsp_diagnostics_float_close_on_hold*
Type: |Boolean|
Default: `1`

Indicates whether to close float of diagnostic error when <CursorHold> is
triggered. Setting this to 0 will allow float to stay open until cursor
is moved or mode is changed.

Example: >
let g:lsp_diagnostics_float_close_on_hold = 0
g:lsp_diagnostics_float_insert_mode_enabled
*g:lsp_diagnostics_float_insert_mode_enabled*
Type: |Boolean|
Expand Down
1 change: 1 addition & 0 deletions plugin/lsp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ 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_diagnostics_float_cursor = get(g:, 'lsp_diagnostics_float_cursor', 0)
let g:lsp_diagnostics_float_delay = get(g:, 'lsp_diagnostics_float_delay', 500)
let g:lsp_diagnostics_float_close_on_hold = get(g:, 'lsp_diagnostics_float_close_on_hold', 1)
let g:lsp_diagnostics_float_insert_mode_enabled = get(g:, 'lsp_diagnostics_float_insert_mode_enabled', 1)
let g:lsp_diagnostics_highlights_enabled = get(g:, 'lsp_diagnostics_highlights_enabled', lsp#utils#_has_highlights())
let g:lsp_diagnostics_highlights_insert_mode_enabled = get(g:, 'lsp_diagnostics_highlights_insert_mode_enabled', 1)
Expand Down

0 comments on commit d595f41

Please sign in to comment.