diff options
| author | Christian Clason <c.clason@uni-graz.at> | 2025-05-31 11:26:24 +0200 |
|---|---|---|
| committer | Christian Clason <ch.clason+github@icloud.com> | 2025-05-31 11:30:56 +0200 |
| commit | 3cad4eb434ba886a1a7035ae8955b7391a42aa05 (patch) | |
| tree | f1733f9fef69f585e9794eaf541a3af5adc62d75 | |
| parent | fix(git_config): match lowercase Git config vars (diff) | |
| download | nvim-treesitter-3cad4eb434ba886a1a7035ae8955b7391a42aa05.tar nvim-treesitter-3cad4eb434ba886a1a7035ae8955b7391a42aa05.tar.gz nvim-treesitter-3cad4eb434ba886a1a7035ae8955b7391a42aa05.tar.bz2 nvim-treesitter-3cad4eb434ba886a1a7035ae8955b7391a42aa05.tar.lz nvim-treesitter-3cad4eb434ba886a1a7035ae8955b7391a42aa05.tar.xz nvim-treesitter-3cad4eb434ba886a1a7035ae8955b7391a42aa05.tar.zst nvim-treesitter-3cad4eb434ba886a1a7035ae8955b7391a42aa05.zip | |
fix(lua): fix some emmyluals warnings
| -rw-r--r-- | lua/nvim-treesitter/config.lua | 6 | ||||
| -rw-r--r-- | lua/nvim-treesitter/health.lua | 44 | ||||
| -rw-r--r-- | lua/nvim-treesitter/indent.lua | 2 | ||||
| -rw-r--r-- | lua/nvim-treesitter/install.lua | 7 |
4 files changed, 28 insertions, 31 deletions
diff --git a/lua/nvim-treesitter/config.lua b/lua/nvim-treesitter/config.lua index 1a5b56cdb..9a586b7b5 100644 --- a/lua/nvim-treesitter/config.lua +++ b/lua/nvim-treesitter/config.lua @@ -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 diff --git a/lua/nvim-treesitter/health.lua b/lua/nvim-treesitter/health.lua index 3f5058996..e284381dd 100644 --- a/lua/nvim-treesitter/health.lua +++ b/lua/nvim-treesitter/health.lua @@ -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' }) diff --git a/lua/nvim-treesitter/indent.lua b/lua/nvim-treesitter/indent.lua index b0982c6c6..13f7b2740 100644 --- a/lua/nvim-treesitter/indent.lua +++ b/lua/nvim-treesitter/indent.lua @@ -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() diff --git a/lua/nvim-treesitter/install.lua b/lua/nvim-treesitter/install.lua index a5a2eb2a5..c56069621 100644 --- a/lua/nvim-treesitter/install.lua +++ b/lua/nvim-treesitter/install.lua @@ -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 = {} |
