]> git.madduck.net Git - etc/vim.git/blob - autoload/lsp/internal/diagnostics/document_diagnostics_command.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Squashed '.vim/bundle/vim-lsp/' content from commit 04428c92
[etc/vim.git] / autoload / lsp / internal / diagnostics / document_diagnostics_command.vim
1 " options = {
2 "   buffers: '1'    " optional string, defaults to current buffer, '*' for all buffers
3 " }
4 function! lsp#internal#diagnostics#document_diagnostics_command#do(options) abort
5     if !g:lsp_diagnostics_enabled
6         call lsp#utils#error(':LspDocumentDiagnostics g:lsp_diagnostics_enabled must be enabled')
7         return
8     endif
9
10     let l:buffers = get(a:options, 'buffers', '')
11
12     let l:filtered_diagnostics = {}
13
14     if l:buffers ==# '*'
15         let l:filtered_diagnostics = lsp#internal#diagnostics#state#_get_all_diagnostics_grouped_by_uri_and_server()
16     else
17         let l:uri = lsp#utils#get_buffer_uri()
18         if !empty(l:uri)
19             let l:filtered_diagnostics[l:uri] = lsp#internal#diagnostics#state#_get_all_diagnostics_grouped_by_server_for_uri(l:uri)
20         endif
21     endif
22
23     let l:result = []
24     for [l:uri, l:value] in items(l:filtered_diagnostics)
25         if lsp#internal#diagnostics#state#_is_enabled_for_buffer(bufnr(lsp#utils#uri_to_path(l:uri)))
26             for l:diagnostics in values(l:value)
27                 let l:result += lsp#ui#vim#utils#diagnostics_to_loc_list({ 'response': l:diagnostics })
28             endfor
29         endif
30     endfor
31
32     if empty(l:result)
33         call lsp#utils#error('No diagnostics results')
34         return
35     else
36         call setloclist(0, l:result)
37         echo 'Retrieved diagnostics results'
38         botright lopen
39     endif
40 endfunction