diff options
author | dundargoc <gocdundar@gmail.com> | 2025-02-06 13:45:41 +0100 |
---|---|---|
committer | dundargoc <33953936+dundargoc@users.noreply.github.com> | 2025-02-09 18:10:54 +0100 |
commit | 198a952c13a1f44c216d3e83b65295cf78802f30 (patch) | |
tree | 1c286184abe99148dc6a6a08adc06c488675dadf | |
parent | cd3855fb2be78e2dc2d2ca4b8e950d9d9d9081bb (diff) | |
download | rneovim-198a952c13a1f44c216d3e83b65295cf78802f30.tar.gz rneovim-198a952c13a1f44c216d3e83b65295cf78802f30.tar.bz2 rneovim-198a952c13a1f44c216d3e83b65295cf78802f30.zip |
build: add luals check
This automatically downloads and uses the correct luals binary for the
currently used system. `make luals` will run luals on all lua files in
`runtime`.
We download lua-language-server manually instead of relying on
contributors downloading it on their own (like with stylua) as
lua-language-server is updated frequently which may cause unnecessary
friction. Therefore, we download a pinned version of luals which we then
can manually bump when needed. This can be re-evaluated if luals becomes
more stable in the future.
Currently this is not run when using `make lint` since cmake style "file
caching" doesn't seem possible at the moment. This is because checking a
single file doesn't seem to work.
Work on https://github.com/neovim/neovim/issues/24563.
-rw-r--r-- | .github/workflows/test.yml | 4 | ||||
-rw-r--r-- | CMakeLists.txt | 30 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | runtime/autoload/ccomplete.lua | 3 | ||||
-rw-r--r-- | runtime/lua/coxpcall.lua | 1 | ||||
-rw-r--r-- | runtime/lua/vim/shared.lua | 2 | ||||
-rw-r--r-- | runtime/pack/dist/opt/cfilter/plugin/cfilter.lua | 3 |
7 files changed, 41 insertions, 4 deletions
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 797f102879..4b0af4d94b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -58,6 +58,10 @@ jobs: run: cmake --build build --target lintlua-stylua - if: success() || failure() && steps.abort_job.outputs.status == 'success' + name: luals + run: cmake --build build --target luals + + - if: success() || failure() && steps.abort_job.outputs.status == 'success' name: luacheck run: cmake --build build --target lintlua-luacheck diff --git a/CMakeLists.txt b/CMakeLists.txt index b9ceb05aba..6964ce79a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -321,3 +321,33 @@ if(USE_BUNDLED_BUSTED) else() add_custom_target(lua_dev_deps) endif() + +if (CMAKE_SYSTEM_PROCESSOR MATCHES arm64) + set(LUALS_ARCH arm64) +else() + set(LUALS_ARCH x64) +endif() + +set(LUALS_VERSION 3.13.6) +set(LUALS "lua-language-server-${LUALS_VERSION}-${CMAKE_SYSTEM_NAME}-${LUALS_ARCH}") +set(LUALS_TARBALL ${LUALS}.tar.gz) +set(LUALS_URL https://github.com/LuaLS/lua-language-server/releases/download/${LUALS_VERSION}/${LUALS_TARBALL}) + +ExternalProject_Add(download_luals + URL ${LUALS_URL} + DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR}/luals + SOURCE_DIR ${DEPS_BIN_DIR}/luals + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + EXCLUDE_FROM_ALL TRUE + DOWNLOAD_NO_PROGRESS TRUE + CMAKE_CACHE_ARGS ${DEPS_CMAKE_CACHE_ARGS}) + +file(GLOB_RECURSE LUAFILES runtime/*.lua) +add_target(luals + COMMAND ${DEPS_BIN_DIR}/luals/bin/lua-language-server --configpath=${PROJECT_SOURCE_DIR}/.luarc.json --check=${PROJECT_SOURCE_DIR}/runtime + DEPENDS ${LUAFILES} + CUSTOM_COMMAND_ARGS USES_TERMINAL) + +add_dependencies(luals download_luals) @@ -126,7 +126,7 @@ functionaltest-lua: | nvim $(CMAKE) --build build --target functionaltest FORMAT=formatc formatlua format -LINT=lintlua lintsh lintc clang-analyzer lintcommit lintdoc lint +LINT=lintlua lintsh lintc clang-analyzer lintcommit lintdoc lint luals TEST=functionaltest unittest generated-sources benchmark $(FORMAT) $(LINT) $(TEST) doc: | build/.ran-cmake $(CMAKE) --build build --target $@ diff --git a/runtime/autoload/ccomplete.lua b/runtime/autoload/ccomplete.lua index ce85e84f7a..dbb70ec2f7 100644 --- a/runtime/autoload/ccomplete.lua +++ b/runtime/autoload/ccomplete.lua @@ -5,7 +5,8 @@ -- Ignore "value assigned to a local variable is unused" because -- we can't guarantee that local variables will be used by plugins --- luacheck: ignore 311 +-- luacheck: ignore +--- @diagnostic disable local vim9 = require('_vim9script') local M = {} diff --git a/runtime/lua/coxpcall.lua b/runtime/lua/coxpcall.lua index 43e321eac3..23ea023f0c 100644 --- a/runtime/lua/coxpcall.lua +++ b/runtime/lua/coxpcall.lua @@ -39,6 +39,7 @@ end ------------------------------------------------------------------------------- -- Implements xpcall with coroutines ------------------------------------------------------------------------------- +---@diagnostic disable-next-line local performResume local oldpcall, oldxpcall = pcall, xpcall local pack = table.pack or function(...) return {n = select("#", ...), ...} end diff --git a/runtime/lua/vim/shared.lua b/runtime/lua/vim/shared.lua index 04a40830f7..f370cbfb4e 100644 --- a/runtime/lua/vim/shared.lua +++ b/runtime/lua/vim/shared.lua @@ -7,7 +7,7 @@ -- so this wouldn't be a separate case to consider) ---@nodoc -_G.vim = _G.vim or {} +_G.vim = _G.vim or {} --[[@as table]] -- TODO(lewis6991): better fix for flaky luals ---@generic T ---@param orig T diff --git a/runtime/pack/dist/opt/cfilter/plugin/cfilter.lua b/runtime/pack/dist/opt/cfilter/plugin/cfilter.lua index 20c158da65..bfb0712484 100644 --- a/runtime/pack/dist/opt/cfilter/plugin/cfilter.lua +++ b/runtime/pack/dist/opt/cfilter/plugin/cfilter.lua @@ -5,7 +5,8 @@ -- Ignore "value assigned to a local variable is unused" because -- we can't guarantee that local variables will be used by plugins --- luacheck: ignore 311 +-- luacheck: ignore +--- @diagnostic disable local vim9 = require('_vim9script') local M = {} |