mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 11:06:54 -04:00
ci: migrate to emmyluals
This commit is contained in:
parent
c82bf96f0a
commit
6878ae017d
5 changed files with 45 additions and 28 deletions
|
|
@ -12,7 +12,14 @@
|
||||||
},
|
},
|
||||||
"diagnostics": {
|
"diagnostics": {
|
||||||
"disable": [
|
"disable": [
|
||||||
"unnecessary-if"
|
"unnecessary-if",
|
||||||
|
"incomplete-signature-doc"
|
||||||
|
],
|
||||||
|
"enables": [
|
||||||
|
"iter-variable-reassign",
|
||||||
|
"non-literal-expressions-in-assert",
|
||||||
|
"incomplete-signature-doc",
|
||||||
|
"missing-global-doc"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"codeAction": {
|
"codeAction": {
|
||||||
|
|
|
||||||
25
Makefile
25
Makefile
|
|
@ -1,5 +1,4 @@
|
||||||
NVIM_VERSION ?= nightly
|
NVIM_VERSION ?= nightly
|
||||||
LUALS_VERSION := 3.17.1
|
|
||||||
|
|
||||||
DEPDIR ?= .test-deps
|
DEPDIR ?= .test-deps
|
||||||
CURL ?= curl -sL --create-dirs
|
CURL ?= curl -sL --create-dirs
|
||||||
|
|
@ -35,18 +34,18 @@ $(NVIM):
|
||||||
tar -xf $(NVIM_TARBALL) -C $@
|
tar -xf $(NVIM_TARBALL) -C $@
|
||||||
rm -rf $(NVIM_TARBALL)
|
rm -rf $(NVIM_TARBALL)
|
||||||
|
|
||||||
LUALS := $(DEPDIR)/lua-language-server-$(LUALS_VERSION)-$(LUALS_ARCH)
|
EMMYLUALS := $(DEPDIR)/emmylua_check-$(LUALS_ARCH)
|
||||||
LUALS_TARBALL := $(LUALS).tar.gz
|
EMMYLUALS_TARBALL := $(EMMYLUALS).tar.gz
|
||||||
LUALS_URL := https://github.com/LuaLS/lua-language-server/releases/download/$(LUALS_VERSION)/$(notdir $(LUALS_TARBALL))
|
EMMYLUALS_URL := https://github.com/emmyluals/emmylua-analyzer-rust/releases/latest/download/$(notdir $(EMMYLUALS_TARBALL))
|
||||||
|
|
||||||
.PHONY: luals
|
.PHONY: emmyluals
|
||||||
luals: $(LUALS)
|
emmyluals: $(EMMYLUALS)
|
||||||
|
|
||||||
$(LUALS):
|
$(EMMYLUALS):
|
||||||
$(CURL) $(LUALS_URL) -o $(LUALS_TARBALL)
|
$(CURL) $(EMMYLUALS_URL) -o $(EMMYLUALS_TARBALL)
|
||||||
mkdir $@
|
mkdir $@
|
||||||
tar -xf $(LUALS_TARBALL) -C $@
|
tar -xf $(EMMYLUALS_TARBALL) -C $@
|
||||||
rm -rf $(LUALS_TARBALL)
|
rm -rf $(EMMYLUALS_TARBALL)
|
||||||
|
|
||||||
STYLUA := $(DEPDIR)/stylua-$(STYLUA_ARCH)
|
STYLUA := $(DEPDIR)/stylua-$(STYLUA_ARCH)
|
||||||
STYLUA_TARBALL := $(STYLUA).zip
|
STYLUA_TARBALL := $(STYLUA).zip
|
||||||
|
|
@ -104,10 +103,8 @@ formatlua: $(STYLUA)
|
||||||
$(STYLUA)/stylua .
|
$(STYLUA)/stylua .
|
||||||
|
|
||||||
.PHONY: checklua
|
.PHONY: checklua
|
||||||
checklua: $(LUALS) $(NVIM)
|
checklua: $(EMMYLUALS) $(NVIM)
|
||||||
VIMRUNTIME=$(NVIM_RUNTIME) $(LUALS)/bin/lua-language-server \
|
VIMRUNTIME=$(NVIM_RUNTIME) $(EMMYLUALS)/emmylua_check --warnings-as-errors .
|
||||||
--configpath=../.luarc.json \
|
|
||||||
--check=./
|
|
||||||
|
|
||||||
.PHONY: query
|
.PHONY: query
|
||||||
query: formatquery lintquery checkquery
|
query: formatquery lintquery checkquery
|
||||||
|
|
|
||||||
31
lua/nvim-treesitter/async.lua
vendored
31
lua/nvim-treesitter/async.lua
vendored
|
|
@ -1,3 +1,4 @@
|
||||||
|
---@meta nvim-treesitter.async vendored file, don't diagnose
|
||||||
local pcall = copcall or pcall
|
local pcall = copcall or pcall
|
||||||
|
|
||||||
--- @param ... any
|
--- @param ... any
|
||||||
|
|
@ -345,8 +346,9 @@ end
|
||||||
--- -- Since uv functions have sync versions. You can just do:
|
--- -- Since uv functions have sync versions. You can just do:
|
||||||
--- local stat = vim.fs_stat('foo.txt')
|
--- local stat = vim.fs_stat('foo.txt')
|
||||||
--- ```
|
--- ```
|
||||||
--- @param func function
|
--- @generic T, R
|
||||||
--- @param ... any
|
--- @param func async fun(...: T...): R...
|
||||||
|
--- @param ... T...
|
||||||
--- @return async.Task
|
--- @return async.Task
|
||||||
function M.arun(func, ...)
|
function M.arun(func, ...)
|
||||||
local task = Task._new(func)
|
local task = Task._new(func)
|
||||||
|
|
@ -354,19 +356,27 @@ function M.arun(func, ...)
|
||||||
return task
|
return task
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @class async.TaskFun
|
--- @alias async.TaskFun<T, R> fun(...: T...): async.Task
|
||||||
--- @field package _fun fun(...: any): any
|
|
||||||
--- @operator call(...): any
|
--- @generic T, R
|
||||||
|
--- @class async._TaskFun<T, R>
|
||||||
|
--- @field package _fun async fun(...: T...): R...
|
||||||
|
--- @operator call(...: T...): async.Task
|
||||||
local TaskFun = {}
|
local TaskFun = {}
|
||||||
TaskFun.__index = TaskFun
|
TaskFun.__index = TaskFun
|
||||||
|
|
||||||
|
--- @generic T, R
|
||||||
|
--- @param self async._TaskFun<T, R>
|
||||||
|
--- @param ... T...
|
||||||
|
--- @return async.Task
|
||||||
function TaskFun:__call(...)
|
function TaskFun:__call(...)
|
||||||
return M.arun(self._fun, ...)
|
return M.arun(self._fun, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Create an async function
|
--- Create an async function
|
||||||
--- @param fun function
|
--- @generic T, R
|
||||||
--- @return async.TaskFun
|
--- @param fun async fun(...: T...): R...
|
||||||
|
--- @return async.TaskFun<T, R>
|
||||||
function M.async(fun)
|
function M.async(fun)
|
||||||
return setmetatable({ _fun = fun }, TaskFun)
|
return setmetatable({ _fun = fun }, TaskFun)
|
||||||
end
|
end
|
||||||
|
|
@ -430,9 +440,10 @@ local function await_cbfun(argc, fun, ...)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param taskfun async.TaskFun
|
--- @generic T, R
|
||||||
--- @param ... any
|
--- @param taskfun async.TaskFun<T, R>
|
||||||
--- @return any ...
|
--- @param ... T...
|
||||||
|
--- @return R...
|
||||||
local function await_taskfun(taskfun, ...)
|
local function await_taskfun(taskfun, ...)
|
||||||
return taskfun._fun(...)
|
return taskfun._fun(...)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ local get_indents = memoize(function(bufnr, root, lang)
|
||||||
return map
|
return map
|
||||||
end
|
end
|
||||||
for id, node, metadata in query:iter_captures(root, bufnr) do
|
for id, node, metadata in query:iter_captures(root, bufnr) do
|
||||||
if query.captures[id]:sub(1, 1) ~= '_' then
|
if assert(query.captures[id]):sub(1, 1) ~= '_' then
|
||||||
map[query.captures[id]][node:id()] = metadata or {}
|
map[query.captures[id]][node:id()] = metadata or {}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,7 @@ local function join(max_jobs, tasks)
|
||||||
end
|
end
|
||||||
|
|
||||||
for i = 1, max_jobs do
|
for i = 1, max_jobs do
|
||||||
|
assert(tasks[i])
|
||||||
tasks[i]():await(cb)
|
tasks[i]():await(cb)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
@ -155,7 +156,8 @@ end
|
||||||
---@param ... string
|
---@param ... string
|
||||||
---@return string
|
---@return string
|
||||||
function M.get_package_path(...)
|
function M.get_package_path(...)
|
||||||
return fs.joinpath(fn.fnamemodify(debug.getinfo(1, 'S').source:sub(2), ':p:h:h:h'), ...)
|
local info = assert(debug.getinfo(1, 'S'))
|
||||||
|
return fs.joinpath(fn.fnamemodify(info.source:sub(2), ':p:h:h:h'), ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param lang string
|
---@param lang string
|
||||||
|
|
@ -487,8 +489,8 @@ end
|
||||||
|
|
||||||
--- Reload the parser table and user modifications in case of update
|
--- Reload the parser table and user modifications in case of update
|
||||||
local function reload_parsers()
|
local function reload_parsers()
|
||||||
---@diagnostic disable-next-line:no-unknown
|
|
||||||
package.loaded['nvim-treesitter.parsers'] = nil
|
package.loaded['nvim-treesitter.parsers'] = nil
|
||||||
|
---@diagnostic disable-next-line:duplicate-require
|
||||||
parsers = require('nvim-treesitter.parsers')
|
parsers = require('nvim-treesitter.parsers')
|
||||||
vim.api.nvim_exec_autocmds('User', { pattern = 'TSUpdate' })
|
vim.api.nvim_exec_autocmds('User', { pattern = 'TSUpdate' })
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue