aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/ci.yml18
-rw-r--r--CMakeLists.txt19
-rw-r--r--Makefile66
-rwxr-xr-xci/run_lint.sh2
-rw-r--r--cmake/lint.cmake34
-rwxr-xr-xsrc/nvim/CMakeLists.txt4
-rw-r--r--src/nvim/diff.c1
7 files changed, 62 insertions, 82 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index b3949578c1..ef70fdfc3c 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -107,11 +107,11 @@ jobs:
run: ./ci/run_tests.sh build_nvim
- if: "!cancelled()"
- name: clint-full
- run: ./ci/run_lint.sh clint-full
+ name: lintcfull
+ run: ./ci/run_lint.sh lintcfull
- if: "!cancelled()"
- name: stylua
+ name: lintstylua
uses: JohnnyMorganz/stylua-action@1.0.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
@@ -124,16 +124,16 @@ jobs:
git diff --color --exit-code
- if: "!cancelled()"
- name: lualint
- run: ./ci/run_lint.sh lualint
+ name: lintlua
+ run: ./ci/run_lint.sh lintlua
- if: "!cancelled()"
- name: pylint
- run: ./ci/run_lint.sh pylint
+ name: lintpy
+ run: ./ci/run_lint.sh lintpy
- if: "!cancelled()"
- name: shlint
- run: ./ci/run_lint.sh shlint
+ name: lintsh
+ run: ./ci/run_lint.sh lintsh
- if: "!cancelled()"
name: check-single-includes
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d75c1a4a6a..ee59d26a89 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -612,9 +612,6 @@ if(NOT BUSTED_OUTPUT_TYPE)
set(BUSTED_OUTPUT_TYPE "nvim")
endif()
-find_program(LUACHECK_PRG luacheck)
-find_program(FLAKE8_PRG flake8)
-
include(InstallHelpers)
file(GLOB MANPAGES
@@ -748,15 +745,13 @@ if(BUSTED_LUA_PRG)
set_target_properties(functionaltest-lua PROPERTIES FOLDER test)
endif()
-if(LUACHECK_PRG)
- add_custom_target(lualint
- COMMAND ${LUACHECK_PRG} -q runtime/ scripts/ src/ test/
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
-else()
- add_custom_target(lualint false
- COMMENT "lualint: LUACHECK_PRG not defined")
-endif()
-
+foreach(TARGET IN ITEMS lintlua lintsh lintpy lintuncrustify)
+ add_custom_target(${TARGET}
+ COMMAND ${CMAKE_COMMAND}
+ -DPROJECT_ROOT=${PROJECT_SOURCE_DIR}
+ -DTARGET=${TARGET}
+ -P ${PROJECT_SOURCE_DIR}/cmake/lint.cmake)
+endforeach()
#add uninstall target
if(NOT TARGET uninstall)
diff --git a/Makefile b/Makefile
index 3039d84a6b..5a5bd80763 100644
--- a/Makefile
+++ b/Makefile
@@ -47,13 +47,7 @@ endif
ifeq (,$(BUILD_TOOL))
ifeq (Ninja,$(CMAKE_GENERATOR))
- ifneq ($(shell $(CMAKE_PRG) --help 2>/dev/null | grep Ninja),)
- BUILD_TOOL = ninja
- else
- # User's version of CMake doesn't support Ninja
- BUILD_TOOL = $(MAKE)
- CMAKE_GENERATOR := Unix Makefiles
- endif
+ BUILD_TOOL = ninja
else
BUILD_TOOL = $(MAKE)
endif
@@ -140,51 +134,19 @@ build/runtime/doc/tags helptags: | nvim
helphtml: | nvim build/runtime/doc/tags
+$(BUILD_TOOL) -C build doc_html
-functionaltest: | nvim
- +$(BUILD_TOOL) -C build functionaltest
+functionaltest functionaltest-lua unittest benchmark: | nvim
+ $(BUILD_TOOL) -C build $@
-functionaltest-lua: | nvim
- +$(BUILD_TOOL) -C build functionaltest-lua
+lintlua lintsh lintpy lintuncrustify lintc lintcfull check-single-includes generated-sources: | build/.ran-cmake
+ $(CMAKE_PRG) --build build --target $@
-stylua:
- stylua --check runtime/
-
-lualint: | build/.ran-cmake deps
- $(BUILD_TOOL) -C build lualint
-
-_opt_stylua:
- @command -v stylua && { $(MAKE) stylua; exit $$?; } \
- || echo "SKIP: stylua (stylua not found)"
-
-shlint:
- @shellcheck --version | head -n 2
- shellcheck scripts/vim-patch.sh
-
-_opt_shlint:
- @command -v shellcheck && { $(MAKE) shlint; exit $$?; } \
- || echo "SKIP: shlint (shellcheck not found)"
-
-pylint:
- flake8 contrib/ scripts/ src/ test/
-
-# Run pylint only if flake8 is installed.
-_opt_pylint:
- @command -v flake8 && { $(MAKE) pylint; exit $$?; } \
- || echo "SKIP: pylint (flake8 not found)"
-
-commitlint:
+commitlint: | nvim
$(NVIM_PRG) -u NONE -es +"lua require('scripts.lintcommit').main({trace=false})"
_opt_commitlint:
@test -x build/bin/nvim && { $(MAKE) commitlint; exit $$?; } \
|| echo "SKIP: commitlint (build/bin/nvim not found)"
-unittest: | nvim
- +$(BUILD_TOOL) -C build unittest
-
-benchmark: | nvim
- +$(BUILD_TOOL) -C build benchmark
-
test: functionaltest unittest
clean:
@@ -200,18 +162,6 @@ distclean:
install: checkprefix nvim
+$(BUILD_TOOL) -C build install
-clint: build/.ran-cmake
- +$(BUILD_TOOL) -C build clint
-
-clint-full: build/.ran-cmake
- +$(BUILD_TOOL) -C build clint-full
-
-check-single-includes: build/.ran-cmake
- +$(BUILD_TOOL) -C build check-single-includes
-
-generated-sources: build/.ran-cmake
- +$(BUILD_TOOL) -C build generated-sources
-
appimage:
bash scripts/genappimage.sh
@@ -221,7 +171,7 @@ appimage:
appimage-%:
bash scripts/genappimage.sh $*
-lint: check-single-includes clint _opt_stylua lualint _opt_pylint _opt_shlint _opt_commitlint
+lint: check-single-includes lintc lintlua lintpy lintsh _opt_commitlint lintuncrustify
# Generic pattern rules, allowing for `make build/bin/nvim` etc.
# Does not work with "Unix Makefiles".
@@ -233,4 +183,4 @@ $(DEPS_BUILD_DIR)/%: phony_force
$(BUILD_TOOL) -C $(DEPS_BUILD_DIR) $(patsubst $(DEPS_BUILD_DIR)/%,%,$@)
endif
-.PHONY: test stylua lualint pylint shlint functionaltest unittest lint clint clean distclean nvim libnvim cmake deps install appimage checkprefix commitlint
+.PHONY: test lintlua lintpy lintsh functionaltest unittest lint lintc clean distclean nvim libnvim cmake deps install appimage checkprefix commitlint
diff --git a/ci/run_lint.sh b/ci/run_lint.sh
index 3a524b4ed6..ba1a61858e 100755
--- a/ci/run_lint.sh
+++ b/ci/run_lint.sh
@@ -12,7 +12,7 @@ rm -f "$END_MARKER"
# Run all tests if no input argument is given
if (($# == 0)); then
- tests=('clint-full' 'lualint' 'pylint' 'shlint' 'check-single-includes')
+ tests=('lintcfull' 'lintlua' 'lintpy' 'lintsh' 'check-single-includes')
else
tests=("$@")
fi
diff --git a/cmake/lint.cmake b/cmake/lint.cmake
new file mode 100644
index 0000000000..1fb8c749a8
--- /dev/null
+++ b/cmake/lint.cmake
@@ -0,0 +1,34 @@
+function(lint)
+ cmake_parse_arguments(LINT "QUIET" "PROGRAM" "FLAGS;FILES" ${ARGN})
+
+ if(LINT_QUIET)
+ set(OUTPUT_QUIET OUTPUT_QUIET)
+ elseif()
+ set(OUTPUT_QUIET "")
+ endif()
+
+ find_program(PROGRAM_EXISTS ${LINT_PROGRAM})
+ if(PROGRAM_EXISTS)
+ execute_process(COMMAND ${LINT_PROGRAM} ${LINT_FLAGS} ${LINT_FILES}
+ WORKING_DIRECTORY ${PROJECT_ROOT}
+ RESULT_VARIABLE ret
+ ${OUTPUT_QUIET})
+ if(ret AND NOT ret EQUAL 0)
+ message(FATAL_ERROR "FAILED: ${TARGET}")
+ endif()
+ else()
+ message(STATUS "${TARGET}: ${LINT_PROGRAM} not found. SKIP.")
+ endif()
+endfunction()
+
+if(${TARGET} STREQUAL "lintuncrustify")
+ file(GLOB_RECURSE FILES ${PROJECT_ROOT}/src/nvim/*.[c,h])
+ lint(PROGRAM uncrustify FLAGS -c src/uncrustify.cfg -q --check FILES ${FILES} QUIET)
+elseif(${TARGET} STREQUAL "lintpy")
+ lint(PROGRAM flake8 FILES contrib/ scripts/ src/ test/)
+elseif(${TARGET} STREQUAL "lintsh")
+ lint(PROGRAM shellcheck FILES scripts/vim-patch.sh)
+elseif(${TARGET} STREQUAL "lintlua")
+ lint(PROGRAM luacheck FLAGS -q FILES runtime/ scripts/ src/ test/)
+ lint(PROGRAM stylua FLAGS --color=always --check FILES runtime/)
+endif()
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt
index da74b4dc9d..c902ff6c50 100755
--- a/src/nvim/CMakeLists.txt
+++ b/src/nvim/CMakeLists.txt
@@ -800,10 +800,10 @@ foreach(sfile ${LINT_NVIM_SOURCES})
list(APPEND LINT_TARGETS ${touch_file})
list(APPEND LINT_NVIM_REL_SOURCES ${rsfile})
endforeach()
-add_custom_target(clint DEPENDS ${LINT_TARGETS})
+add_custom_target(lintc DEPENDS ${LINT_TARGETS})
add_custom_target(
- clint-full
+ lintcfull
COMMAND
${LINT_PRG} --suppress-errors=${LINT_SUPPRESS_FILE} ${LINT_NVIM_REL_SOURCES}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
diff --git a/src/nvim/diff.c b/src/nvim/diff.c
index 8c98c1ef23..1625632842 100644
--- a/src/nvim/diff.c
+++ b/src/nvim/diff.c
@@ -2307,6 +2307,7 @@ bool diff_find_change(win_T *wp, linenr_T lnum, int *startp, int *endp)
if ((dp == NULL) || (diff_check_sanity(curtab, dp) == FAIL)) {
xfree(line_org);
+
return false;
}