allow to enable or disable diagnostics per buffer (#1005)

This commit is contained in:
Prabir Shrestha
2021-01-02 14:20:05 -08:00
committed by GitHub
parent 268341fe60
commit d78d219abd
2 changed files with 40 additions and 0 deletions

View File

@@ -1115,6 +1115,16 @@ function! s:send_didchange_queue(...) abort
let s:didchange_queue = []
endfunction
function! lsp#enable_diagnostics_for_buffer(...) abort
let l:bufnr = a:0 > 0 ? a:1 : bufnr('%')
call lsp#internal#diagnostics#state#_enable_for_buffer(l:bufnr)
endfunction
function! lsp#disable_diagnostics_for_buffer(...) abort
let l:bufnr = a:0 > 0 ? a:1 : bufnr('%')
call lsp#internal#diagnostics#state#_disable_for_buffer(l:bufnr)
endfunction
" Return dict with diagnostic counts for current buffer
" { 'error': 1, 'warning': 0, 'information': 0, 'hint': 0 }
function! lsp#get_buffer_diagnostics_counts() abort

View File

@@ -79,6 +79,8 @@ CONTENTS *vim-lsp-contents*
lsp#stop_server |lsp#stop_server()|
lsp#utils#find_nearest_parent_file_directory()
|lsp#utils#find_nearest_parent_file_directory()|
lsp#enable_diagnostics_for_buffer() |lsp#enable_diagnostics_for_buffer()|
lsp#disable_diagnostics_for_buffer()|lsp#disable_diagnostics_for_buffer()|
lsp#get_buffer_diagnostics_counts() |lsp#get_buffer_diagnostics_counts()|
lsp#get_buffer_first_error_line() |lsp#get_buffer_first_error_line()|
lsp#get_progress() |lsp#get_progress()|
@@ -1268,6 +1270,34 @@ This method is mainly used to generate 'root_uri' when registering server.
* If there is not directory with the specific files or diretories
found, the method will return an empty string.
lsp#enable_diagnostics_for_buffer() *lsp#enable_diagnotics_for_buffer()*
Re-enable diagnsostics for the specified buffer. By default diagnostics are
enabled for all buffers.
Example: >
:call lsp#enable_diagnostics_for_buffer()
:call lsp#enable_diagnostics_for_buffer(bufnr('%'))
lsp#disable_diagnostics_for_buffer() *lsp#disable_diagnostics_for_buffer()*
Diable diagnostics for the specified buffer. By default diagnostics are
enabled for all buffers.
Example: >
:call lsp#enable_diagnostics_for_buffer()
:call lsp#enable_diagnostics_for_buffer(bufnr('%'))
Diagnostics can be disabled for buffer to temporarily avoid conflicts with
other plugins.
Example: >
augroup LspEasyMotion
autocmd!
autocmd User EasyMotionPromptBegin call lsp#disable_diagnostics_for_buffer()<CR>
autocmd User EasyMotionPromptEnd call lsp#enable_diagnostics_for_buffer()<CR>
augroup END
lsp#get_buffer_diagnostics_counts() *lsp#get_buffer_diagnostics_counts()*
Get dict with diagnostic counts for current buffer. Useful e.g. for display