fix(lua): fix some emmyluals warnings

This commit is contained in:
Christian Clason 2025-05-31 11:26:24 +02:00 committed by Christian Clason
parent 9a51f860c1
commit 3cad4eb434
4 changed files with 28 additions and 31 deletions

View file

@ -96,7 +96,7 @@ end
---Normalize languages ---Normalize languages
---@param languages? string[]|string ---@param languages? string[]|string
---@param skip? { missing: boolean, unsupported: boolean, installed: boolean, dependencies: boolean } ---@param skip? { missing: boolean?, unsupported: boolean?, installed: boolean?, dependencies: boolean? }
---@return string[] ---@return string[]
function M.norm_languages(languages, skip) function M.norm_languages(languages, skip)
if not languages then if not languages then
@ -150,7 +150,7 @@ function M.norm_languages(languages, skip)
languages = vim.tbl_filter( languages = vim.tbl_filter(
--- @param v string --- @param v string
function(v) function(v)
return not (parsers[v].tier and parsers[v].tier == 4) return not (parsers[v] and parsers[v].tier and parsers[v].tier == 4)
end, end,
languages languages
) )
@ -158,7 +158,7 @@ function M.norm_languages(languages, skip)
if not (skip and skip.dependencies) then if not (skip and skip.dependencies) then
for _, lang in pairs(languages) do for _, lang in pairs(languages) do
if parsers[lang].requires then if parsers[lang] and parsers[lang].requires then
vim.list_extend(languages, parsers[lang].requires) vim.list_extend(languages, parsers[lang].requires)
end end
end end

View file

@ -28,27 +28,25 @@ local function install_health()
health.error('Nvim-treesitter requires Neovim 0.11.0 or later.') health.error('Nvim-treesitter requires Neovim 0.11.0 or later.')
end end
if vim.treesitter.language_version then if vim.treesitter.language_version >= NVIM_TREESITTER_MINIMUM_ABI then
if vim.treesitter.language_version >= NVIM_TREESITTER_MINIMUM_ABI then health.ok(
health.ok( 'Neovim was compiled with tree-sitter runtime ABI version '
'Neovim was compiled with tree-sitter runtime ABI version ' .. vim.treesitter.language_version
.. vim.treesitter.language_version .. ' (required >='
.. ' (required >=' .. NVIM_TREESITTER_MINIMUM_ABI
.. NVIM_TREESITTER_MINIMUM_ABI .. ').'
.. ').' )
) else
else health.error(
health.error( 'Neovim was compiled with tree-sitter runtime ABI version '
'Neovim was compiled with tree-sitter runtime ABI version ' .. vim.treesitter.language_version
.. vim.treesitter.language_version .. '.\n'
.. '.\n' .. 'nvim-treesitter expects at least ABI version '
.. 'nvim-treesitter expects at least ABI version ' .. NVIM_TREESITTER_MINIMUM_ABI
.. NVIM_TREESITTER_MINIMUM_ABI .. '\n'
.. '\n' .. 'Please make sure that Neovim is linked against a recent tree-sitter library when building'
.. 'Please make sure that Neovim is linked against a recent tree-sitter library when building' .. ' or raise an issue at your Neovim packager. Parsers must be compatible with runtime ABI.'
.. ' or raise an issue at your Neovim packager. Parsers must be compatible with runtime ABI.' )
)
end
end end
end end
@ -140,7 +138,7 @@ function M.check()
for _, lang in pairs(languages) do for _, lang in pairs(languages) do
local parser = parsers[lang] local parser = parsers[lang]
local out = lang .. string.rep(' ', 22 - #lang) local out = lang .. string.rep(' ', 22 - #lang)
if parser.install_info then if parser and parser.install_info then
for _, query_group in pairs(M.bundled_queries) do for _, query_group in pairs(M.bundled_queries) do
local status, err = query_status(lang, query_group) local status, err = query_status(lang, query_group)
out = out .. status .. ' ' out = out .. status .. ' '
@ -149,7 +147,7 @@ function M.check()
end end
end end
end end
if parser.requires then if parser and parser.requires then
for _, p in pairs(parser.requires) do for _, p in pairs(parser.requires) do
if not vim.list_contains(languages, p) then if not vim.list_contains(languages, p) then
table.insert(error_collection, { lang, 'queries', 'dependency ' .. p .. ' missing' }) table.insert(error_collection, { lang, 'queries', 'dependency ' .. p .. ' missing' })

View file

@ -106,7 +106,7 @@ end, function(bufnr, root, lang)
return tostring(bufnr) .. root:id() .. '_' .. lang return tostring(bufnr) .. root:id() .. '_' .. lang
end) end)
---@param lnum number (1-indexed) ---@param lnum integer (1-indexed)
---@return integer ---@return integer
function M.get_indent(lnum) function M.get_indent(lnum)
local bufnr = vim.api.nvim_get_current_buf() local bufnr = vim.api.nvim_get_current_buf()

View file

@ -97,15 +97,14 @@ end
---@async ---@async
---@param path string ---@param path string
---@param mode? string
---@return string? err ---@return string? err
local function mkpath(path, mode) local function mkpath(path)
local parent = fs.dirname(path) local parent = fs.dirname(path)
if not parent:match('^[./]$') and not uv.fs_stat(parent) then if not parent:match('^[./]$') and not uv.fs_stat(parent) then
mkpath(parent, mode) mkpath(parent)
end end
return uv_mkdir(path, tonumber(mode or '755', 8)) return uv_mkdir(path, 493) -- tonumber('755', 8)
end end
local M = {} local M = {}