Skip to content

Commit 3244bed

Browse files
authored
Add option to disable float of diagnostic error when insert mode (#1417)
1 parent 5009876 commit 3244bed

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

autoload/lsp/internal/diagnostics/float.vim

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,14 @@ function! lsp#internal#diagnostics#float#_enable() abort
1616
let s:enabled = 1
1717

1818
let s:Dispose = lsp#callbag#pipe(
19-
\ lsp#callbag#fromEvent('CursorMoved'),
19+
\ lsp#callbag#merge(
20+
\ lsp#callbag#fromEvent(['CursorMoved', 'CursorHold']),
21+
\ lsp#callbag#pipe(
22+
\ lsp#callbag#fromEvent(['InsertEnter']),
23+
\ lsp#callbag#filter({_->!g:lsp_diagnostics_float_insert_mode_enabled}),
24+
\ lsp#callbag#tap({_->s:hide_float()}),
25+
\ )
26+
\ ),
2027
\ lsp#callbag#filter({_->g:lsp_diagnostics_float_cursor}),
2128
\ lsp#callbag#tap({_->s:hide_float()}),
2229
\ lsp#callbag#debounceTime(g:lsp_diagnostics_float_delay),

doc/vim-lsp.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ CONTENTS *vim-lsp-contents*
3030
g:lsp_diagnostics_echo_delay |g:lsp_diagnostics_echo_delay|
3131
g:lsp_diagnostics_float_cursor |g:lsp_diagnostics_float_cursor|
3232
g:lsp_diagnostics_float_delay |g:lsp_diagnostics_float_delay|
33+
g:lsp_diagnostics_float_insert_mode_enabled
34+
|g:lsp_diagnostics_float_insert_mode_enabled|
3335
g:lsp_diagnostics_highlights_enabled
3436
|g:lsp_diagnostics_highlights_enabled|
3537
g:lsp_diagnostics_highlights_insert_mode_enabled
@@ -531,6 +533,18 @@ g:lsp_diagnostics_float_delay *g:lsp_diagnostics_float_delay*
531533
let g:lsp_diagnostics_float_delay = 200
532534
let g:lsp_diagnostics_float_delay = 1000
533535
536+
g:lsp_diagnostics_float_insert_mode_enabled
537+
*g:lsp_diagnostics_float_insert_mode_enabled*
538+
Type: |Boolean|
539+
Default: `1`
540+
541+
Indicates whether to enable float of diagnostic error for the current line
542+
to status when in |insertmode|. Requires |g:lsp_diagnostics_enabled| and
543+
|g:lsp_diagnostics_float_cursor| set to 1.
544+
545+
Example: >
546+
let g:lsp_diagnostics_float_insert_mode_enabled = 0
547+
534548
g:lsp_format_sync_timeout *g:lsp_format_sync_timeout*
535549
Type: |Number|
536550
Default: `-1`

plugin/lsp.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ let g:lsp_diagnostics_echo_cursor = get(g:, 'lsp_diagnostics_echo_cursor', 0)
2121
let g:lsp_diagnostics_echo_delay = get(g:, 'lsp_diagnostics_echo_delay', 500)
2222
let g:lsp_diagnostics_float_cursor = get(g:, 'lsp_diagnostics_float_cursor', 0)
2323
let g:lsp_diagnostics_float_delay = get(g:, 'lsp_diagnostics_float_delay', 500)
24+
let g:lsp_diagnostics_float_insert_mode_enabled = get(g:, 'lsp_diagnostics_float_insert_mode_enabled', 1)
2425
let g:lsp_diagnostics_highlights_enabled = get(g:, 'lsp_diagnostics_highlights_enabled', lsp#utils#_has_highlights())
2526
let g:lsp_diagnostics_highlights_insert_mode_enabled = get(g:, 'lsp_diagnostics_highlights_insert_mode_enabled', 1)
2627
let g:lsp_diagnostics_highlights_delay = get(g:, 'lsp_diagnostics_highlights_delay', 500)

0 commit comments

Comments
 (0)