Diagnostic error per buffer

pull/44/head
ray-x 3 years ago
parent 96e9772d5b
commit 54906cebaf

@ -407,6 +407,8 @@ Jump between symbols with treesitter (with `]r` and `[r`)
### Diagnostic ### Diagnostic
Visual studio code style show errors minimap in scroll bar area Visual studio code style show errors minimap in scroll bar area
(Check setup for `diag_scroll_bar_sign`)
![diagnostic_scroll_bar](https://user-images.githubusercontent.com/1681295/128736430-e365523d-810c-4c16-a3b4-c74969f45f0b.jpg) ![diagnostic_scroll_bar](https://user-images.githubusercontent.com/1681295/128736430-e365523d-810c-4c16-a3b4-c74969f45f0b.jpg)

@ -27,10 +27,10 @@ local function error_marker(result, client_id)
log(result, bufnr) log(result, bufnr)
if result == nil or result.diagnostics == nil or #result.diagnostics == 0 then if result == nil or result.diagnostics == nil or #result.diagnostics == 0 then
local diag_cnt = vim.lsp.diagnostic.get_count(0, [[Error]]) local diag_cnt = vim.lsp.diagnostic.get_count(bufnr, [[Error]])
+ vim.lsp.diagnostic.get_count(0, [[Warning]]) + vim.lsp.diagnostic.get_count(bufnr, [[Warning]])
if diag_cnt == 0 then if diag_cnt == 0 and _NG_VT_NS ~= nil then
vim.api.nvim_buf_clear_namespace(0, _NG_VT_NS, 0, -1) vim.api.nvim_buf_clear_namespace(bufnr, _NG_VT_NS, 0, -1)
end end
return return
end end
@ -208,8 +208,34 @@ M.set_diag_loclist = function()
end end
end end
function M.clear_blame_VT() -- important for clearing out the text when our cursor moves function M.clear_blame_VT() -- important for clearing out when no more errors
vim.api.nvim_buf_clear_namespace(0, _NG_VT_NS, 0, -1) vim.api.nvim_buf_clear_namespace(0, _NG_VT_NS, 0, -1)
_NG_VT_NS = nil
end end
-- TODO: callback when scroll
function M.update_err_marker()
if _NG_VT_NS == nil then
-- nothing to update
return
end
local bufnr = vim.fn.bufnr()
local diag_cnt = vim.lsp.diagnostic.get_count(bufnr, [[Error]])
+ vim.lsp.diagnostic.get_count(bufnr, [[Warning]])
if diag_cnt == 0 and _NG_VT_NS ~= nil then
vim.api.nvim_buf_clear_namespace(bufnr, _NG_VT_NS, 0, -1)
return
end
-- redraw
vim.api.nvim_buf_clear_namespace(0, _NG_VT_NS, 0, -1)
local errors = vim.lsp.diagnostic.get(bufnr)
local result = {diagnostics = errors}
error_marker(result)
end
-- TODO: update the marker
-- vim.cmd [[autocmd WinScrolled * lua require'navigator.diagnostics'.update_err_marker()]]
return M return M

@ -214,7 +214,7 @@ return M
call_by = { <table 1> }, call_by = { <table 1> },
col = 40, col = 40,
display_filename = "./curry.js", display_filename = "./curry.js",
filename = "/Users/ray.xu/lsp_test/js/curry.js", filename = "/Users/username/lsp_test/js/curry.js",
lnum = 4, lnum = 4,
range = { range = {
end = { end = {
@ -228,7 +228,7 @@ return M
}, },
rpath = "js/curry.js", rpath = "js/curry.js",
text = " (sum, element, index) => (sum += element * vector2[index]),", text = " (sum, element, index) => (sum += element * vector2[index]),",
uri = "file:///Users/ray.xu/lsp_test/js/curry.js" uri = "file:///Users/username/lsp_test/js/curry.js"
} }
--]] --]]
@ -252,7 +252,7 @@ return M
} }, } },
col = 22, col = 22,
display_filename = "./curry.js", display_filename = "./curry.js",
filename = "/Users/ray.xu/lsp_test/js/curry.js", filename = "/Users/username/lsp_test/js/curry.js",
lnum = 4, lnum = 4,
range = { range = {
end = { end = {
@ -266,6 +266,6 @@ return M
}, },
rpath = "js/curry.js", rpath = "js/curry.js",
text = " 4: (sum, element, index) => (sum += element * vector   curriedDot()", text = " 4: (sum, element, index) => (sum += element * vector   curriedDot()",
uri = "file:///Users/ray.xu/lsp_test/js/curry.js" uri = "file:///Users/username/lsp_test/js/curry.js"
-- --
]] ]]

@ -5,7 +5,7 @@ parameter
line = 13 line = 13
}, },
textDocument = { textDocument = {
uri = "file:///Users/ray.xu/lsp_test/go/interface.go" uri = "file:///Users/username/lsp_test/go/interface.go"
} }
} }
@ -38,7 +38,7 @@ dir from result { {
line = 39 line = 39
} }
}, },
uri = "file:///Users/ray.xu/lsp-test/go/interface.go" uri = "file:///Users/username/lsp-test/go/interface.go"
}, },
fromRanges = { { fromRanges = { {
end = { end = {
@ -75,7 +75,7 @@ dir from result { {
line = 43 line = 43
} }
}, },
uri = "file:///Users/ray.xu/lsp-test/go/interface.go" uri = "file:///Users/username/lsp-test/go/interface.go"
}, },
fromRanges = { { fromRanges = { {
end = { end = {
@ -116,7 +116,7 @@ dir from result { {
line = 26 line = 26
} }
}, },
uri = "file:///Users/ray.xu/lsp-test/go/interface.go" uri = "file:///Users/username/lsp-test/go/interface.go"
}, { }, {
range = { range = {
["end"] = { ["end"] = {
@ -128,7 +128,7 @@ dir from result { {
line = 35 line = 35
} }
}, },
uri = "file:///Users/ray.xu/lsp-test/go/interface.go" uri = "file:///Users/username/lsp-test/go/interface.go"
} } } }
--]] --]]
@ -146,7 +146,7 @@ definition.lua:9: { {
line = 33 line = 33
} }
}, },
uri = "file:///Users/ray.xu/lsp-test/go/interface.go" uri = "file:///Users/username/lsp-test/go/interface.go"
} } } }
@ -165,7 +165,7 @@ definition.lua:9: { {
line = 33 line = 33
} }
}, },
uri = "file:///Users/ray.xu/lsp-test/go/interface.go" uri = "file:///Users/username/lsp-test/go/interface.go"
} } } }
} }
} }
@ -186,7 +186,7 @@ definition.lua:9: { {
line = 7 line = 7
} }
}, },
uri = "file:///Users/ray.xu/lsp-test/go/interface.go" uri = "file:///Users/username/lsp-test/go/interface.go"
}, },
name = "command-line-arguments.geometry" name = "command-line-arguments.geometry"
}, { }, {
@ -203,7 +203,7 @@ definition.lua:9: { {
line = 12 line = 12
} }
}, },
uri = "file:///Users/ray.xu/lsp-test/go/interface.go" uri = "file:///Users/username/lsp-test/go/interface.go"
}, },
name = "command-line-arguments.rect" name = "command-line-arguments.rect"
}, { }, {
@ -220,7 +220,7 @@ definition.lua:9: { {
line = 43 line = 43
} }
}, },
uri = "file:///Users/ray.xu/lsp-test/go/interface.go" uri = "file:///Users/username/lsp-test/go/interface.go"
}, },
name = "command-line-arguments.main" name = "command-line-arguments.main"
}, { }, {
@ -237,7 +237,7 @@ definition.lua:9: { {
line = 8 line = 8
} }
}, },
uri = "file:///Users/ray.xu/lsp-test/go/interface.go" uri = "file:///Users/username/lsp-test/go/interface.go"
}, },
name = "command-line-arguments.geometry.area" name = "command-line-arguments.geometry.area"
}, { }, {
@ -254,7 +254,7 @@ definition.lua:9: { {
line = 13 line = 13
} }
}, },
uri = "file:///Users/ray.xu/lsp-test/go/interface.go" uri = "file:///Users/username/lsp-test/go/interface.go"
}, },
name = "command-line-arguments.rect.width" name = "command-line-arguments.rect.width"
}} }}
@ -298,7 +298,7 @@ definition.lua:9: { {
severity = 1, severity = 1,
source = "compiler" source = "compiler"
} }, } },
uri = "file:///Users/ray.xu/lsp-test/go/interface.go" uri = "file:///Users/username/lsp-test/go/interface.go"
} }
@ -320,7 +320,7 @@ definition.lua:9: { {
} }
} }, } },
textDocument = { textDocument = {
uri = "file:///Users/ray.xu/lsp_test/go/ref.go", uri = "file:///Users/username/lsp_test/go/ref.go",
version = 0 version = 0
} }
} } } }
@ -341,7 +341,7 @@ definition.lua:9: { {
line = 4 line = 4
} }
}, },
URI = "file:///Users/ray.xu/lsp_test/go/ref.go" URI = "file:///Users/username/lsp_test/go/ref.go"
} }, } },
command = "gopls.apply_fix", command = "gopls.apply_fix",
title = "undeclared name: rect" title = "undeclared name: rect"
@ -383,7 +383,7 @@ definition.lua:9: { {
line = 4 line = 4
} }
}, },
URI = "file:///Users/ray.xu/lsp_test/go/ref.go" URI = "file:///Users/username/lsp_test/go/ref.go"
} }, } },
command = "gopls.apply_fix", command = "gopls.apply_fix",
title = "Extract to function" title = "Extract to function"
@ -433,7 +433,7 @@ definition.lua:9: { {
} }
} }, } },
textDocument = { textDocument = {
uri = "file:///Users/ray.xu/lsp_test/go/ref.go", uri = "file:///Users/username/lsp_test/go/ref.go",
version = 0 version = 0
} }
} } } }
@ -457,7 +457,7 @@ definition.lua:9: { {
} }
} }, } },
textDocument = { textDocument = {
uri = "file:///Users/ray.xu/lsp_test/go/ref.go", uri = "file:///Users/username/lsp_test/go/ref.go",
version = 0 version = 0
} }
} } } }
@ -969,3 +969,59 @@ definition.lua:9: { {
range = { 25, 32 } range = { 25, 32 }
}, },
}} }}
-- get diagnostics response
{ {
code = "UndeclaredName",
codeDescription = {
href = "https://pkg.go.dev/golang.org/x/tools/internal/typesinternal?utm_source=gopls#UndeclaredName"
},
col = 16,
display_filename = "./interface.go",
filename = "/Users/username/lsp_test/go/interface.go",
lnum = 38,
message = "undeclared name: geometry",
range = {
end = {
character = 23,
line = 37
},
start = {
character = 15,
line = 37
}
},
severity = 1,
source = "compiler",
tags = { 1 },
text = "🈲func measure(g geometry) int {📛undeclared name: geometry",
uri = "file:///Users/username/lsp_test/go/interface.go"
},{
code = "UndeclaredName",
codeDescription = {
href = "https://pkg.go.dev/golang.org/x/tools/internal/typesinternal?utm_source=gopls#UndeclaredName"
},
col = 9,
display_filename = "./interface.go",
filename = "/Users/username/lsp_test/go/interface.go",
lnum = 30,
message = "undeclared name: circle",
range = {
end = {
character = 14,
line = 29
},
start = {
character = 8,
line = 29
}
},
severity = 1,
source = "compiler",
tags = { 1 },
text = "🈲func (c circle) area() float64 {📛undeclared name: circle",
uri = "file:///Users/username/lsp_test/go/interface.go"
} }

Loading…
Cancel
Save