mirror of
https://github.com/neovim/neovim
synced 2025-07-15 16:51:49 +00:00
build: enable lintlua for test/ dir
Problem: Not all Lua code is checked by stylua. Automating code-style is an important mechanism for reducing time spent on accidental (non-essential) complexity. Solution: - Enable stylua for entire `test/` directory. - Exclude these high-churn files until this issue is resolved: https://github.com/JohnnyMorganz/StyLua/issues/829 ``` test/functional/ui/decorations_spec.lua | 3560 ++++++++++++++++++++++++++++++++++++---------------- test/functional/ui/float_spec.lua | 5826 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------- test/functional/ui/multigrid_spec.lua | 1349 ++++++++++++++------ ``` - Make surgical changes to these files (or add `stylua: ignore` in some small scopes) to improve the result: ``` test/functional/vimscript/msgpack_functions_spec.lua | 1414 +++++++++++++++------ test/functional/api/buffer_spec.lua | 1389 +++++++++++---------- test/functional/api/vim_spec.lua | 2740 +++++++++++++++++++++++----------------- ``` - These "high churn" files are NOT excluded because the changes are largely an improvement: ``` test/functional/plugin/lsp_spec.lua | 2198 ++++++++++++++++++--------------- test/functional/plugin/shada_spec.lua | 4078 +++++++++++++++++++++++++++++++++++------------------------- test/functional/ui/cmdline_spec.lua | 1199 +++++++++++------- test/functional/ui/popupmenu_spec.lua | 1267 +++++++++++-------- test/functional/ui/messages_spec.lua | 1643 +++++++++++++++--------- ``` - TODO: how to check "all directories"? With `GLOB_DIRS *` and `/.deps/` (or `.deps/`) in `.styluaignore`, Lua code in `.deps/` is still checked...
This commit is contained in:
@ -227,7 +227,7 @@ endif()
|
||||
find_program(SHELLCHECK_PRG shellcheck ${LINT_REQUIRED})
|
||||
find_program(STYLUA_PRG stylua ${LINT_REQUIRED})
|
||||
|
||||
set(STYLUA_DIRS runtime scripts src test/unit)
|
||||
set(STYLUA_DIRS runtime scripts src test)
|
||||
|
||||
add_glob_target(
|
||||
TARGET lintlua-luacheck
|
||||
@ -235,7 +235,7 @@ add_glob_target(
|
||||
FLAGS -ll ${PROJECT_SOURCE_DIR}/test/lua_runner.lua ${CMAKE_BINARY_DIR}/usr luacheck -q
|
||||
GLOB_DIRS runtime scripts src test
|
||||
GLOB_PAT *.lua
|
||||
TOUCH_STRATEGY SINGLE)
|
||||
TOUCH_STRATEGY PER_DIR)
|
||||
add_dependencies(lintlua-luacheck lua-dev-deps)
|
||||
|
||||
add_glob_target(
|
||||
@ -244,7 +244,7 @@ add_glob_target(
|
||||
FLAGS --color=always --check --respect-ignores
|
||||
GLOB_DIRS ${STYLUA_DIRS}
|
||||
GLOB_PAT *.lua
|
||||
TOUCH_STRATEGY SINGLE)
|
||||
TOUCH_STRATEGY PER_DIR)
|
||||
|
||||
add_custom_target(lintlua)
|
||||
add_dependencies(lintlua lintlua-luacheck lintlua-stylua)
|
||||
@ -255,7 +255,7 @@ add_glob_target(
|
||||
FLAGS -x -a
|
||||
GLOB_DIRS scripts
|
||||
GLOB_PAT *.sh
|
||||
TOUCH_STRATEGY SINGLE)
|
||||
TOUCH_STRATEGY PER_DIR)
|
||||
|
||||
add_custom_target(lintcommit
|
||||
COMMAND $<TARGET_FILE:nvim> -u NONE -l ${PROJECT_SOURCE_DIR}/scripts/lintcommit.lua main)
|
||||
@ -270,7 +270,8 @@ add_glob_target(
|
||||
COMMAND ${STYLUA_PRG}
|
||||
FLAGS --respect-ignores
|
||||
GLOB_DIRS ${STYLUA_DIRS}
|
||||
GLOB_PAT *.lua)
|
||||
GLOB_PAT *.lua
|
||||
TOUCH_STRATEGY PER_DIR)
|
||||
|
||||
add_custom_target(format)
|
||||
add_dependencies(format formatc formatlua)
|
||||
|
Reference in New Issue
Block a user