update diangostic event handler

neovim_0_5
ray-x 3 years ago
parent 1fa56d20a5
commit 3d170771e9

@ -9,9 +9,9 @@ local path_sep = require"navigator.util".path_sep()
local path_cur = require"navigator.util".path_cur()
diagnostic_list[vim.bo.filetype] = {}
local diag_hdlr = function(err, method, result, client_id, br, config)
local diag_hdlr = function(err, method, result, client_id, bufnr, config)
-- log(result)
vim.lsp.diagnostic.on_publish_diagnostics(err, method, result, client_id, br, config)
vim.lsp.diagnostic.on_publish_diagnostics(err, method, result, client_id, bufnr, config)
if err ~= nil then
log(err, config)
end
@ -43,9 +43,9 @@ local diag_hdlr = function(err, method, result, client_id, br, config)
if v.severity > 2 then
head = _NgConfigValues.icons.diagnostic_head_severity_3
end
local bufnr = vim.uri_to_bufnr(uri)
if not vim.api.nvim_buf_is_loaded(bufnr) then
vim.fn.bufload(bufnr)
local bufnr1 = vim.uri_to_bufnr(uri)
if not vim.api.nvim_buf_is_loaded(bufnr1) then
vim.fn.bufload(bufnr1)
end
local pos = v.range.start
local row = pos.line
@ -110,4 +110,13 @@ M.show_diagnostic = function()
end
end
M.set_diag_loclist = function()
if not vim.tbl_isempty(vim.lsp.buf_get_clients(0)) then
local err_cnt = vim.lsp.diagnostic.get_count(0, [[Error]])
if err_cnt > 0 then
vim.lsp.diagnostic.set_loclist()
end
end
end
return M

@ -4,7 +4,7 @@ local function set_keymap(...)
end
local event_hdlrs = {
{ev = "BufWritePre", func = "diagnostic.set_loclist({open = false})"},
{ev = "BufWritePre", func = [[require "navigator.diagnostics".set_diag_loclist()]]},
{ev = "CursorHold", func = "document_highlight()"},
{ev = "CursorHoldI", func = "document_highlight()"},
{ev = "CursorMoved", func = "clear_references()"}
@ -164,8 +164,8 @@ local function set_event_handler(user_opts)
for _, value in pairs(event_hdlrs) do
local f = ""
if string.find(value.func, "diagnostic") then
f = "lua vim.lsp." .. value.func
if string.find(value.func, "require") ~= nil then
f = "lua " .. value.func
else
f = "lua vim.lsp.buf." .. value.func
end
@ -244,6 +244,7 @@ function M.setup(user_opts)
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {border = single})
vim.lsp.handlers["textDocument/formatting"] = require"navigator.formatting".format_hdl
end
return M

@ -47,7 +47,6 @@ local match_parameter = function(result)
end
local function signature_handler(err, method, result, _, bufnr, config)
-- log(result)
if config == nil then
log("config nil")
end

@ -273,6 +273,7 @@ end
M.open_file_at = function(filename, line, col)
vim.api.nvim_command(string.format("e! +%s %s", line, filename))
-- vim.api.nvim_command(string.format("e! %s", filename))
col = col or 1
vim.fn.cursor(line, col)
end

Loading…
Cancel
Save