local helpers = require('test.functional.helpers')(after_each)
local NIL = helpers.NIL
local command = helpers.command
local clear = helpers.clear
local exec_lua = helpers.exec_lua
local eq = helpers.eq
local nvim = helpers.nvim
local matches = helpers.matches
local pcall_err = helpers.pcall_err
describe('vim.diagnostic', function()
before_each(function()
clear()
exec_lua [[
require('vim.diagnostic')
function make_diagnostic(msg, x1, y1, x2, y2, severity, source)
return {
lnum = x1,
col = y1,
end_lnum = x2,
end_col = y2,
message = msg,
severity = severity,
source = source,
}
end
function make_error(msg, x1, y1, x2, y2, source)
return make_diagnostic(msg, x1, y1, x2, y2, vim.diagnostic.severity.ERROR, source)
end
function make_warning(msg, x1, y1, x2, y2, source)
return make_diagnostic(msg, x1, y1, x2, y2, vim.diagnostic.severity.WARN, source)
end
function make_info(msg, x1, y1, x2, y2, source)
return make_diagnostic(msg, x1, y1, x2, y2, vim.diagnostic.severity.INFO, source)
end
function make_hint(msg, x1, y1, x2, y2, source)
return make_diagnostic(msg, x1, y1, x2, y2, vim.diagnostic.severity.HINT, source)
end
function count_diagnostics(bufnr, severity, namespace)
return #vim.diagnostic.get(bufnr, {severity = severity, namespace = namespace})
end
function count_extmarks(bufnr, namespace)
local ns = vim.diagnostic.get_namespace(namespace)
local extmarks = 0
if ns.user_data.virt_text_ns then
extmarks = extmarks + #vim.api.nvim_buf_get_extmarks(bufnr, ns.user_data.virt_text_ns, 0, -1, {})
end
if ns.user_data.underline_ns then
extmarks = extmarks + #vim.api.nvim_buf_get_extmarks(bufnr, ns.user_data.underline_ns, 0, -1, {})
end
return extmarks
end
function get_virt_text_extmarks(ns)
local ns = vim.diagnostic.get_namespace(ns)
local virt_text_ns = ns.user_data.virt_text_ns
return vim.api.nvim_buf_get_extmarks(diagnostic_bufnr, virt_text_ns, 0, -1, {details = true})
end
]]
exec_lua([[
diagnostic_ns = vim.api.nvim_create_namespace("diagnostic_spec")
other_ns = vim.api.nvim_create_namespace("other_namespace")
|