Skip to content

Commit ac22efb

Browse files
iamFIREcrackerprabirshrestha
authored andcommitted
Add flag to disable diagnostics (#197)
* Add switch, g:lsp_diagnostics_enabled, to disable support for diagnostics * Reduce PR changeset
1 parent 14225b5 commit ac22efb

File tree

5 files changed

+32
-2
lines changed

5 files changed

+32
-2
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,18 @@ Refer to docs on configuring omnifunc or [asyncomplete.vim](https://github.com/p
6969

7070
### Diagnostics
7171

72+
Document diagnostics (e.g. warnings, errors) are enabled by default, but if you
73+
preferred to turn them off and use other plugins instead (like
74+
[Neomake](https://github.com/neomake/neomake) or
75+
[ALE](https://github.com/neomake/neomake), set `g:lsp_diagnostics_enabled` to
76+
`0`:
77+
78+
```viml
79+
let g:lsp_diagnostics_enabled = 0 " disable diagnostics support
80+
```
81+
82+
#### Signs
83+
7284
```viml
7385
let g:lsp_signs_enabled = 1 " enable signs
7486
let g:lsp_diagnostics_echo_cursor = 1 " enable echo under cursor when in normal mode

autoload/lsp.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function! lsp#enable() abort
3535
let s:already_setup = 1
3636
endif
3737
let s:enabled = 1
38-
if g:lsp_signs_enabled
38+
if g:lsp_diagnostics_enabled && g:lsp_signs_enabled
3939
call lsp#ui#vim#signs#enable()
4040
endif
4141
call s:register_events()
@@ -514,7 +514,7 @@ function! s:on_notification(server_name, id, data, event) abort
514514

515515
if lsp#client#is_server_instantiated_notification(a:data)
516516
if has_key(l:response, 'method')
517-
if l:response['method'] ==# 'textDocument/publishDiagnostics'
517+
if g:lsp_diagnostics_enabled && l:response['method'] ==# 'textDocument/publishDiagnostics'
518518
call lsp#ui#vim#diagnostics#handle_text_document_publish_diagnostics(a:server_name, a:data)
519519
endif
520520
endif

autoload/lsp/ui/vim/diagnostics.vim

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ function! lsp#ui#vim#diagnostics#handle_text_document_publish_diagnostics(server
1515
endfunction
1616

1717
function! lsp#ui#vim#diagnostics#document_diagnostics() abort
18+
if !g:lsp_diagnostics_enabled
19+
call lsp#utils#error('Diagnostics manually disabled -- g:lsp_diagnostics_enabled = 0')
20+
return
21+
endif
22+
1823
let l:uri = lsp#utils#get_buffer_uri()
1924

2025
let [l:has_diagnostics, l:diagnostics] = s:get_diagnostics(l:uri)

doc/vim-lsp.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ CONTENTS *vim-lsp-contents*
1010
Configure |vim-lsp-configure-source|
1111
Wiki |vim-lsp-configure-wiki|
1212
Options |vim-lsp-options|
13+
g:lsp_diagnostics_enabled |g:lsp_diagnostics_enabled|
1314
g:lsp_auto_enable |g:lsp_auto_enable|
1415
g:lsp_preview_keep_focus |g:lsp_preview_keep_focus|
1516
Functions |vim-lsp-functions|
@@ -93,6 +94,17 @@ to https://github.com/prabirshrestha/vim-lsp/wiki/Servers
9394
===============================================================================
9495
Options *vim-lsp-options*
9596

97+
g:lsp_diagnostics_enabled *g:lsp_diagnostics_enabled*
98+
Type: |Number|
99+
Default: `1`
100+
101+
Enable support for document diagnostics like warnings and error messages.
102+
enabling vim-lsp during startup.
103+
104+
Example:
105+
let g:lsp_diagnostics_enabled = 1
106+
let g:lsp_diagnostics_enabled = 0
107+
96108
g:lsp_auto_enable *g:lsp_auto_enable*
97109
Type: |Number|
98110
Default: `1`

plugin/lsp.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ let g:lsp_signs_error = get(g:, 'lsp_signs_error', {})
1313
let g:lsp_signs_warning = get(g:, 'lsp_signs_warning', {})
1414
let g:lsp_signs_information = get(g:, 'lsp_signs_information', {})
1515
let g:lsp_signs_hint = get(g:, 'lsp_signs_hint', {})
16+
let g:lsp_diagnostics_enabled = get(g:, 'lsp_diagnostics_enabled', 1)
1617
let g:lsp_diagnostics_echo_cursor = get(g:, 'lsp_diagnostics_echo_cursor', 0)
1718
let g:lsp_diagnostics_echo_delay = get(g:, 'lsp_diagnostics_echo_delay', 500)
1819
let g:lsp_next_sign_id = get(g:, 'lsp_next_sign_id', 6999)

0 commit comments

Comments
 (0)