bugfix clangd #102 buffer not loaded empty diagnostic info

pull/106/head
ray-x 3 years ago
parent 388711d97d
commit 49fb9032d8

@ -216,6 +216,7 @@ local diag_hdlr = mk_handler(function(err, result, ctx, config)
item.lnum = v.range.start.line + 1
item.col = v.range.start.character + 1
item.uri = uri
trace(item)
local head = _NgConfigValues.icons.diagnostic_head
if v.severity == 1 then
head = _NgConfigValues.icons.diagnostic_head_severity_1
@ -227,27 +228,29 @@ local diag_hdlr = mk_handler(function(err, result, ctx, config)
head = _NgConfigValues.icons.diagnostic_head_severity_3
end
local bufnr1 = vim.uri_to_bufnr(uri)
if not vim.api.nvim_buf_is_loaded(bufnr1) then
if _NgConfigValues.diagnostic_load_files then
-- print('load buffers')
local loaded = vim.api.nvim_buf_is_loaded(bufnr1)
if _NgConfigValues.diagnostic_load_files then
-- print('load buffers')
if not loaded then
vim.fn.bufload(bufnr1) -- this may slow down the neovim
local pos = v.range.start
local row = pos.line
local line = (vim.api.nvim_buf_get_lines(bufnr1, row, row + 1, false) or {""})[1]
if line ~= nil then
item.text = head .. line .. _NgConfigValues.icons.diagnostic_head_description .. v.message
table.insert(item_list, item)
else
error("diagnostic result empty line", v, row, bufnr1)
end
else
item.text = head .. _NgConfigValues.icons.diagnostic_head_description .. v.message
end
local pos = v.range.start
local row = pos.line
local line = (vim.api.nvim_buf_get_lines(bufnr1, row, row + 1, false) or {""})[1]
if line ~= nil then
item.text = head .. line .. _NgConfigValues.icons.diagnostic_head_description .. v.message
table.insert(item_list, item)
else
error("diagnostic result empty line", v, row, bufnr1)
end
else
item.text = head .. _NgConfigValues.icons.diagnostic_head_description .. v.message
table.insert(item_list, item)
end
end
-- local old_items = vim.fn.getqflist()
diagnostic_list[ft][uri] = item_list
trace(uri, ft, item_list)
if not result.uri then
result.uri = uri
end

@ -148,7 +148,8 @@ local setups = {
flags = {allow_incremental_sync = true, debounce_text_changes = 500},
cmd = {
"clangd", "--background-index", "--suggest-missing-includes", "--clang-tidy",
"--header-insertion=iwyu"
"--header-insertion=iwyu", "--clang-tidy-checks=-*,llvm-*,clang-analyzer-*",
"--cross-file-rename"
},
filetypes = {"c", "cpp", "objc", "objcpp"},
on_attach = function(client)

Loading…
Cancel
Save