ci: format
This commit is contained in:
commit
e49a664d48
30 changed files with 1612 additions and 0 deletions
40
lua/render/diagnostic.lua
Normal file
40
lua/render/diagnostic.lua
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
local M = {}
|
||||
|
||||
local log = require('render.log')
|
||||
|
||||
local ns = vim.api.nvim_create_namespace('render')
|
||||
|
||||
---@param bufnr integer
|
||||
function M.clear(bufnr)
|
||||
vim.diagnostic.set(ns, bufnr, {})
|
||||
log.dbg('cleared diagnostics for buffer %d', bufnr)
|
||||
end
|
||||
|
||||
---@param bufnr integer
|
||||
---@param name string
|
||||
---@param error_parser fun(stderr: string, ctx: render.Context): vim.Diagnostic[]
|
||||
---@param stderr string
|
||||
---@param ctx render.Context
|
||||
function M.set(bufnr, name, error_parser, stderr, ctx)
|
||||
local ok, diagnostics = pcall(error_parser, stderr, ctx)
|
||||
if not ok then
|
||||
log.dbg('error_parser for "%s" failed: %s', name, diagnostics)
|
||||
return
|
||||
end
|
||||
if not diagnostics or #diagnostics == 0 then
|
||||
log.dbg('error_parser for "%s" returned no diagnostics', name)
|
||||
return
|
||||
end
|
||||
for _, d in ipairs(diagnostics) do
|
||||
d.source = d.source or name
|
||||
end
|
||||
vim.diagnostic.set(ns, bufnr, diagnostics)
|
||||
log.dbg('set %d diagnostics for buffer %d from provider "%s"', #diagnostics, bufnr, name)
|
||||
end
|
||||
|
||||
---@return integer
|
||||
function M.get_namespace()
|
||||
return ns
|
||||
end
|
||||
|
||||
return M
|
||||
Loading…
Add table
Add a link
Reference in a new issue