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
---@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[]
function M.norm_languages(languages, skip)
if not languages then
@ -150,7 +150,7 @@ function M.norm_languages(languages, skip)
languages = vim.tbl_filter(
--- @param v string
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,
languages
)
@ -158,7 +158,7 @@ function M.norm_languages(languages, skip)
if not (skip and skip.dependencies) then
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)
end
end

View file

@ -28,27 +28,25 @@ local function install_health()
health.error('Nvim-treesitter requires Neovim 0.11.0 or later.')
end
if vim.treesitter.language_version then
if vim.treesitter.language_version >= NVIM_TREESITTER_MINIMUM_ABI then
health.ok(
'Neovim was compiled with tree-sitter runtime ABI version '
.. vim.treesitter.language_version
.. ' (required >='
.. NVIM_TREESITTER_MINIMUM_ABI
.. ').'
)
else
health.error(
'Neovim was compiled with tree-sitter runtime ABI version '
.. vim.treesitter.language_version
.. '.\n'
.. 'nvim-treesitter expects at least ABI version '
.. NVIM_TREESITTER_MINIMUM_ABI
.. '\n'
.. '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.'
)
end
if vim.treesitter.language_version >= NVIM_TREESITTER_MINIMUM_ABI then
health.ok(
'Neovim was compiled with tree-sitter runtime ABI version '
.. vim.treesitter.language_version
.. ' (required >='
.. NVIM_TREESITTER_MINIMUM_ABI
.. ').'
)
else
health.error(
'Neovim was compiled with tree-sitter runtime ABI version '
.. vim.treesitter.language_version
.. '.\n'
.. 'nvim-treesitter expects at least ABI version '
.. NVIM_TREESITTER_MINIMUM_ABI
.. '\n'
.. '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.'
)
end
end
@ -140,7 +138,7 @@ function M.check()
for _, lang in pairs(languages) do
local parser = parsers[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
local status, err = query_status(lang, query_group)
out = out .. status .. ' '
@ -149,7 +147,7 @@ function M.check()
end
end
end
if parser.requires then
if parser and parser.requires then
for _, p in pairs(parser.requires) do
if not vim.list_contains(languages, p) then
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
end)
---@param lnum number (1-indexed)
---@param lnum integer (1-indexed)
---@return integer
function M.get_indent(lnum)
local bufnr = vim.api.nvim_get_current_buf()

View file

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