]> git.madduck.net Git - etc/vim.git/blobdiff - .vim/bundle/vim-lsp/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:

Merge commit 'a39f715c13be3352193ffd9c5b7536b8786eff64' as '.vim/bundle/vim-lsp'
[etc/vim.git] / .vim / bundle / vim-lsp / autoload / lsp / internal / diagnostics / document_diagnostics_command.vim
diff --git a/.vim/bundle/vim-lsp/autoload/lsp/internal/diagnostics/document_diagnostics_command.vim b/.vim/bundle/vim-lsp/autoload/lsp/internal/diagnostics/document_diagnostics_command.vim
new file mode 100644 (file)
index 0000000..cc43b94
--- /dev/null
@@ -0,0 +1,40 @@
+" options = {
+"   buffers: '1'    " optional string, defaults to current buffer, '*' for all buffers
+" }
+function! lsp#internal#diagnostics#document_diagnostics_command#do(options) abort
+    if !g:lsp_diagnostics_enabled
+        call lsp#utils#error(':LspDocumentDiagnostics g:lsp_diagnostics_enabled must be enabled')
+        return
+    endif
+
+    let l:buffers = get(a:options, 'buffers', '')
+
+    let l:filtered_diagnostics = {}
+
+    if l:buffers ==# '*'
+        let l:filtered_diagnostics = lsp#internal#diagnostics#state#_get_all_diagnostics_grouped_by_uri_and_server()
+    else
+        let l:uri = lsp#utils#get_buffer_uri()
+        if !empty(l:uri)
+            let l:filtered_diagnostics[l:uri] = lsp#internal#diagnostics#state#_get_all_diagnostics_grouped_by_server_for_uri(l:uri)
+        endif
+    endif
+
+    let l:result = []
+    for [l:uri, l:value] in items(l:filtered_diagnostics)
+        if lsp#internal#diagnostics#state#_is_enabled_for_buffer(bufnr(lsp#utils#uri_to_path(l:uri)))
+            for l:diagnostics in values(l:value)
+                let l:result += lsp#ui#vim#utils#diagnostics_to_loc_list({ 'response': l:diagnostics })
+            endfor
+        endif
+    endfor
+
+    if empty(l:result)
+        call lsp#utils#error('No diagnostics results')
+        return
+    else
+        call setloclist(0, l:result)
+        echo 'Retrieved diagnostics results'
+        botright lopen
+    endif
+endfunction