mirror of
https://github.com/chenasraf/nvim-treesitter.git
synced 2026-05-18 01:39:00 +00:00
fix(lua): fix some emmyluals warnings
This commit is contained in:
committed by
Christian Clason
parent
75797cdd8a
commit
e0eec76dad
25
.emmyrc.json
Normal file
25
.emmyrc.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/EmmyLuaLs/emmylua-analyzer-rust/refs/heads/main/crates/emmylua_code_analysis/resources/schema.json",
|
||||
"format": {
|
||||
"externalTool": {
|
||||
"program": "stylua",
|
||||
"args": [
|
||||
"-",
|
||||
"--stdin-filepath",
|
||||
"${file}"
|
||||
]
|
||||
}
|
||||
},
|
||||
"diagnostics": {
|
||||
"disable": [
|
||||
"unnecessary-if"
|
||||
]
|
||||
},
|
||||
"codeAction": {
|
||||
"insertSpace": true
|
||||
},
|
||||
"strict": {
|
||||
"typeCall": true,
|
||||
"arrayIndex": true
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ M.tiers = { 'stable', 'unstable', 'unmaintained', 'unsupported' }
|
||||
|
||||
---@type TSConfig
|
||||
local config = {
|
||||
install_dir = vim.fs.joinpath(vim.fn.stdpath('data'), 'site'),
|
||||
install_dir = vim.fs.joinpath(vim.fn.stdpath('data') --[[@as string]], 'site'),
|
||||
}
|
||||
|
||||
---Setup call for users to override configuration configurations.
|
||||
|
||||
@@ -487,7 +487,7 @@ end
|
||||
local function install(languages, options)
|
||||
options = options or {}
|
||||
|
||||
local cache_dir = fs.normalize(fn.stdpath('cache'))
|
||||
local cache_dir = fs.normalize(fn.stdpath('cache') --[[@as string]])
|
||||
if not uv.fs_stat(cache_dir) then
|
||||
fn.mkdir(cache_dir, 'p')
|
||||
end
|
||||
|
||||
@@ -14,7 +14,6 @@ do
|
||||
|
||||
for _, lang in pairs(parsers) do
|
||||
if configs[lang] and configs[lang].install_info then
|
||||
timings[lang] = {}
|
||||
for _, query_type in pairs(query_types) do
|
||||
local before = vim.uv.hrtime()
|
||||
local ok, query = pcall(vim.treesitter.query.get, lang, query_type)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
local generate = false
|
||||
local update = false
|
||||
local max_jobs = nil ---@type integer?
|
||||
local max_jobs = nil ---@type number?
|
||||
local parsers = {}
|
||||
for i = 1, #_G.arg do
|
||||
if _G.arg[i] == '--generate' then
|
||||
@@ -10,7 +10,7 @@ for i = 1, #_G.arg do
|
||||
elseif _G.arg[i] == '--update' then
|
||||
update = true
|
||||
elseif _G.arg[i]:find('^%-%-max%-jobs') then
|
||||
max_jobs = _G.arg[i]:match('=(%d+)')
|
||||
max_jobs = tonumber(_G.arg[i]:match('=(%d+)'))
|
||||
else
|
||||
parsers[#parsers + 1] = _G.arg[i] ---@type string
|
||||
end
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
-- nvim -l update-parsers.lua --tier=1 # update stable parsers to latest version
|
||||
-- nvim -l update-parsers.lua --tier=2 # update unstable parsers to latest commit
|
||||
|
||||
local tier = nil ---@type integer?
|
||||
local tier = nil ---@type number?
|
||||
for i = 1, #_G.arg do
|
||||
if _G.arg[i]:find('^%-%-tier=') then
|
||||
tier = tonumber(_G.arg[i]:match('=(%d+)'))
|
||||
@@ -41,15 +41,15 @@ for k, p in pairs(parsers) do
|
||||
|
||||
if #vim.tbl_keys(jobs) % 100 == 0 or next(parsers, k) == nil then
|
||||
for name, job in pairs(jobs) do
|
||||
local stdout = vim.split(job:wait().stdout, '\n')
|
||||
local stdout = vim.split(job:wait().stdout or '', '\n')
|
||||
jobs[name] = nil
|
||||
|
||||
local info = parsers[name].install_info
|
||||
assert(info)
|
||||
assert(parsers[name])
|
||||
local info = assert(parsers[name].install_info)
|
||||
|
||||
local sha ---@type string
|
||||
local sha ---@type string?
|
||||
if parsers[name].tier == 1 then
|
||||
sha = stdout[#stdout - 1]:match('v[%d%.]+$')
|
||||
sha = stdout[#stdout - 1] and stdout[#stdout - 1]:match('v[%d%.]+$')
|
||||
else
|
||||
local branch = info.branch
|
||||
local line = 1
|
||||
@@ -61,10 +61,10 @@ for k, p in pairs(parsers) do
|
||||
end
|
||||
end
|
||||
end
|
||||
sha = vim.split(stdout[line], '\t')[1]
|
||||
sha = stdout[line] and vim.split(stdout[line], '\t')[1]
|
||||
end
|
||||
|
||||
if info.revision ~= sha then
|
||||
if sha and info.revision ~= sha then
|
||||
info.revision = sha
|
||||
updates[#updates + 1] = name
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user