mirror of
https://github.com/neovim/neovim.git
synced 2026-05-04 04:55:16 +00:00
fix(vim.diagnostic): improve typing
Problem: `vim.diagnostic.set()` doesn't actually accept a list of `vim.Diagnostic` as internally `vim.diagnostic.set()` normalizes the diagnostics and this normalization is assumed throughout the module. Solution: - Add a new type `vim.Diagnostic.Set` which is the input to `vim.diagnostic.set()` - `col` is now an optional field and defaults to `0` to be consistent with `vim.diagnostic.match()`. - Change `table.insert(t, x)` to `table[#table + 1] = x` for improved type checking.
This commit is contained in:
committed by
Lewis Russell
parent
9641ad9369
commit
533cc0ab35
@@ -17,7 +17,7 @@ local M = {}
|
||||
--- @field is_first_lang boolean Whether this is the first language of a linter run checking queries for multiple `langs`
|
||||
|
||||
--- Adds a diagnostic for node in the query buffer
|
||||
--- @param diagnostics vim.Diagnostic[]
|
||||
--- @param diagnostics vim.Diagnostic.Set[]
|
||||
--- @param range Range4
|
||||
--- @param lint string
|
||||
--- @param lang string?
|
||||
@@ -126,7 +126,7 @@ end)
|
||||
--- @param match table<integer,TSNode[]>
|
||||
--- @param query vim.treesitter.Query
|
||||
--- @param lang_context QueryLinterLanguageContext
|
||||
--- @param diagnostics vim.Diagnostic[]
|
||||
--- @param diagnostics vim.Diagnostic.Set[]
|
||||
local function lint_match(buf, match, query, lang_context, diagnostics)
|
||||
local lang = lang_context.lang
|
||||
local parser_info = lang_context.parser_info
|
||||
@@ -162,7 +162,7 @@ function M.lint(buf, opts)
|
||||
buf = api.nvim_get_current_buf()
|
||||
end
|
||||
|
||||
local diagnostics = {}
|
||||
local diagnostics = {} --- @type vim.Diagnostic.Set[]
|
||||
local query = vim.treesitter.query.parse('query', lint_query)
|
||||
|
||||
opts = normalize_opts(buf, opts)
|
||||
|
||||
Reference in New Issue
Block a user