@@ -3,9 +3,9 @@ local util = require 'diagnostic.util'
33local M = {}
44
55-- TODO change this to use vim.lsp.util.diagnostics_by_buf
6- M .bufferDiagnostic = {}
76local diagnosticTable = {}
87
8+
99local remove_diagnostics = function (diagnostics )
1010 -- Remove Index
1111 local remove = {}
@@ -38,7 +38,7 @@ function M.modifyCallback()
3838 if not result then
3939 return
4040 end
41- local uri = result .uri
41+ uri = result .uri
4242 local bufnr = vim .uri_to_bufnr (uri )
4343 if not bufnr then
4444 vim .lsp .err_message (" LSP.publishDiagnostics: Couldn't find buffer for " , uri )
@@ -48,7 +48,7 @@ function M.modifyCallback()
4848 if vim .api .nvim_get_var (' diagnostic_level' ) ~= nil then
4949 result .diagnostics = remove_diagnostics (result .diagnostics )
5050 end
51- M . bufferDiagnostic [ bufnr ] = result
51+ vim . lsp . util . buf_diagnostics_save_positions ( bufnr , result . diagnostics )
5252 if vim .api .nvim_get_var (' diagnostic_insert_delay' ) == 1 then
5353 if vim .api .nvim_get_mode ()[' mode' ] == " i" or vim .api .nvim_get_mode ()[' mode' ] == " ic" then
5454 return
@@ -60,33 +60,31 @@ function M.modifyCallback()
6060end
6161
6262function M .diagnostics_loclist (local_result )
63- if local_result and local_result . diagnostics then
64- for _ , v in ipairs (local_result . diagnostics ) do
65- v .uri = v .uri or local_result . uri
63+ if local_result then
64+ for _ , v in ipairs (local_result ) do
65+ v .uri = v .uri or uri
6666 end
6767 end
68- vim .lsp .util .set_loclist (vim . lsp . util .locations_to_items (local_result . diagnostics ))
68+ vim .lsp .util .set_loclist (util .locations_to_items (local_result ))
6969end
7070
7171function M .publish_diagnostics (bufnr )
7272 if vim .fn .getcmdwintype () == ' :' then return end
73+ vim .lsp .util .buf_clear_diagnostics (bufnr )
7374 if # vim .lsp .buf_get_clients () == 0 then return end
74- local result = M . bufferDiagnostic [bufnr ]
75- if result == nil then return end
75+ local diagnostics = vim . lsp . util . diagnostics_by_buf [bufnr ]
76+ if diagnostics == nil then return end
7677 vim .fn .setloclist (0 , {}, ' r' )
77- vim .lsp .util .buf_clear_diagnostics (bufnr )
78- vim .lsp .util .buf_diagnostics_save_positions (bufnr , result .diagnostics )
79- util .buf_diagnostics_save_positions (bufnr , result .diagnostics )
8078 if vim .api .nvim_get_var (' diagnostic_enable_underline' ) == 1 then
81- vim .lsp .util .buf_diagnostics_underline (bufnr , result . diagnostics )
79+ vim .lsp .util .buf_diagnostics_underline (bufnr , diagnostics )
8280 end
8381 if vim .api .nvim_get_var (' diagnostic_show_sign' ) == 1 then
84- util .buf_diagnostics_signs (bufnr , result . diagnostics )
82+ util .buf_diagnostics_signs (bufnr , diagnostics )
8583 end
8684 if vim .api .nvim_get_var (' diagnostic_enable_virtual_text' ) == 1 then
87- util .buf_diagnostics_virtual_text (bufnr , result . diagnostics )
85+ util .buf_diagnostics_virtual_text (bufnr , diagnostics )
8886 end
89- M .diagnostics_loclist (result )
87+ M .diagnostics_loclist (diagnostics )
9088 M .trigger_diagnostics_changed ()
9189end
9290
0 commit comments