diff --git a/CMakeLists.txt b/CMakeLists.txt index 11afefe4cd..141fa81e16 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,14 +51,14 @@ endif() # Set default build type. if(NOT CMAKE_BUILD_TYPE) - message(STATUS "CMAKE_BUILD_TYPE not given, defaulting to 'Dev'.") - set(CMAKE_BUILD_TYPE "Dev" CACHE STRING "Choose the type of build." FORCE) + message(STATUS "CMAKE_BUILD_TYPE not given, defaulting to 'Debug'.") + set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build." FORCE) endif() # Set available build types for CMake GUIs. # A different build type can still be set by -DCMAKE_BUILD_TYPE=... set_property(CACHE CMAKE_BUILD_TYPE PROPERTY - STRINGS "Debug" "Dev" "Release" "MinSizeRel" "RelWithDebInfo") + STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") # If not in a git repo (e.g., a tarball) these tokens define the complete # version string, else they are combined with the result of `git describe`. @@ -107,46 +107,24 @@ if(NOT CMAKE_C_FLAGS_RELWITHDEBINFO MATCHES DMIN_LOG_LEVEL) set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -DMIN_LOG_LEVEL=3") endif() -# Enable assertions for RelWithDebInfo. -if(CMAKE_C_FLAGS_RELWITHDEBINFO MATCHES DNDEBUG) +if(CMAKE_COMPILER_IS_GNUCC) + check_c_compiler_flag(-Og HAS_OG_FLAG) +else() + set(HAS_OG_FLAG 0) +endif() + +# Set custom build flags for RelWithDebInfo. +# -DNDEBUG purposely omitted because we want assertions. +if(HAS_OG_FLAG) + set(CMAKE_C_FLAGS_RELWITHDEBINFO "-Og -g" + CACHE STRING "Flags used by the compiler during release-with-debug builds." FORCE) +elseif(NOT MSVC) + set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g" + CACHE STRING "Flags used by the compiler during release-with-debug builds." FORCE) +elseif(CMAKE_C_FLAGS_RELWITHDEBINFO MATCHES DNDEBUG) string(REPLACE "-DNDEBUG" "" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}") endif() -# Set build flags for custom Dev build type. -# -DNDEBUG purposely omitted because we want assertions. -if(MSVC) - SET(CMAKE_C_FLAGS_DEV "" - CACHE STRING "Flags used by the compiler during development (optimized, but with debug info and logging) builds." - FORCE) -else() - if(CMAKE_COMPILER_IS_GNUCC) - check_c_compiler_flag(-Og HAS_OG_FLAG) - else() - set(HAS_OG_FLAG 0) - endif() - - if(HAS_OG_FLAG) - set(CMAKE_C_FLAGS_DEV "-Og -g" - CACHE STRING "Flags used by the compiler during development (optimized, but with debug info and logging) builds." - FORCE) - else() - set(CMAKE_C_FLAGS_DEV "-O2 -g" - CACHE STRING "Flags used by the compiler during development (optimized, but with debug info and logging) builds." - FORCE) - endif() -endif() -SET(CMAKE_EXE_LINKER_FLAGS_DEV "" - CACHE STRING "Flags used for linking binaries during development (optimized, but with debug info and logging) builds." - FORCE) -SET(CMAKE_SHARED_LINKER_FLAGS_DEV "" - CACHE STRING "Flags used by the shared libraries linker during development (optimized, but with debug info and logging) builds." - FORCE) - -MARK_AS_ADVANCED( - CMAKE_C_FLAGS_DEV - CMAKE_EXE_LINKER_FLAGS_DEV - CMAKE_SHARED_LINKER_FLAGS_DEV) - # Enable -Wconversion. if(NOT MSVC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion") @@ -600,9 +578,26 @@ if(LUACHECK_PRG) add_custom_target(testlint COMMAND ${CMAKE_COMMAND} -DLUACHECK_PRG=${LUACHECK_PRG} - -DTEST_DIR=${CMAKE_CURRENT_SOURCE_DIR}/test + -DLUAFILES_DIR=${CMAKE_CURRENT_SOURCE_DIR}/test + -DIGNORE_PATTERN="*/preload.lua" -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} - -P ${PROJECT_SOURCE_DIR}/cmake/RunTestsLint.cmake) + -P ${PROJECT_SOURCE_DIR}/cmake/RunLuacheck.cmake) + + add_custom_target( + blobcodelint + COMMAND + ${CMAKE_COMMAND} + -DLUACHECK_PRG=${LUACHECK_PRG} + -DLUAFILES_DIR=${CMAKE_CURRENT_SOURCE_DIR}/src/nvim/lua + -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} + -DREAD_GLOBALS=vim + -P ${PROJECT_SOURCE_DIR}/cmake/RunLuacheck.cmake + ) + # TODO(ZyX-I): Run linter for all lua code in src + add_custom_target( + lualint + DEPENDS blobcodelint + ) endif() set(CPACK_PACKAGE_NAME "Neovim") diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md index 011739396d..1a7268a51e 100644 --- a/ISSUE_TEMPLATE.md +++ b/ISSUE_TEMPLATE.md @@ -1,16 +1,19 @@ + + - `nvim --version`: - Vim (version: ) behaves differently? - Operating system/version: - Terminal name/version: - `$TERM`: -### Actual behaviour - -### Expected behaviour - ### Steps to reproduce using `nvim -u NORC` ``` nvim -u NORC ``` + +### Actual behaviour + +### Expected behaviour + diff --git a/Makefile b/Makefile index e69475a514..e349cc4d0f 100644 --- a/Makefile +++ b/Makefile @@ -107,6 +107,9 @@ functionaltest-lua: | nvim testlint: | build/.ran-cmake deps $(BUILD_CMD) -C build testlint +lualint: | build/.ran-cmake deps + $(BUILD_CMD) -C build lualint + unittest: | nvim +$(BUILD_CMD) -C build unittest @@ -138,6 +141,6 @@ check-single-includes: build/.ran-cmake appimage: bash scripts/genappimage.sh -lint: check-single-includes clint testlint +lint: check-single-includes clint testlint lualint -.PHONY: test testlint functionaltest unittest lint clint clean distclean nvim libnvim cmake deps install appimage +.PHONY: test testlint lualint functionaltest unittest lint clint clean distclean nvim libnvim cmake deps install appimage diff --git a/ci/run_lint.sh b/ci/run_lint.sh index 73647dacaa..e7f6727448 100755 --- a/ci/run_lint.sh +++ b/ci/run_lint.sh @@ -20,6 +20,12 @@ run_test 'top_make testlint' testlint exit_suite --continue +enter_suite 'lualint' + +run_test 'top_make lualint' lualint + +exit_suite --continue + enter_suite single-includes CLICOLOR_FORCE=1 run_test_wd \ diff --git a/cmake/FindJeMalloc.cmake b/cmake/FindJeMalloc.cmake index 820ceeed4a..f139196a38 100644 --- a/cmake/FindJeMalloc.cmake +++ b/cmake/FindJeMalloc.cmake @@ -27,6 +27,9 @@ find_path(JEMALLOC_INCLUDE_DIR jemalloc/jemalloc.h if(JEMALLOC_USE_STATIC) list(APPEND JEMALLOC_NAMES "${CMAKE_STATIC_LIBRARY_PREFIX}jemalloc${CMAKE_STATIC_LIBRARY_SUFFIX}") +elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + list(INSERT JEMALLOC_NAMES 0 + "${CMAKE_STATIC_LIBRARY_PREFIX}jemalloc${CMAKE_STATIC_LIBRARY_SUFFIX}") endif() list(APPEND JEMALLOC_NAMES jemalloc) diff --git a/cmake/RunLuacheck.cmake b/cmake/RunLuacheck.cmake new file mode 100644 index 0000000000..5129541cd8 --- /dev/null +++ b/cmake/RunLuacheck.cmake @@ -0,0 +1,22 @@ +set(LUACHECK_ARGS -q "${LUAFILES_DIR}") +if(DEFINED IGNORE_PATTERN) + list(APPEND LUACHECK_ARGS --exclude-files "${LUAFILES_DIR}/${IGNORE_PATTERN}") +endif() +if(DEFINED CHECK_PATTERN) + list(APPEND LUACHECK_ARGS --include-files "${LUAFILES_DIR}/${CHECK_PATTERN}") +endif() +if(DEFINED READ_GLOBALS) + list(APPEND LUACHECK_ARGS --read-globals "${READ_GLOBALS}") +endif() + +execute_process( + COMMAND "${LUACHECK_PRG}" ${LUACHECK_ARGS} + WORKING_DIRECTORY "${LUAFILES_DIR}" + ERROR_VARIABLE err + RESULT_VARIABLE res +) + +if(NOT res EQUAL 0) + message(STATUS "Output to stderr:\n${err}") + message(FATAL_ERROR "Linting tests failed with error: ${res}.") +endif() diff --git a/cmake/RunTestsLint.cmake b/cmake/RunTestsLint.cmake deleted file mode 100644 index addc9ab35e..0000000000 --- a/cmake/RunTestsLint.cmake +++ /dev/null @@ -1,13 +0,0 @@ -set(IGNORE_FILES "${TEST_DIR}/*/preload.lua") - -execute_process( - COMMAND ${LUACHECK_PRG} -q ${TEST_DIR} --exclude-files ${IGNORE_FILES} - WORKING_DIRECTORY ${TEST_DIR} - ERROR_VARIABLE err - RESULT_VARIABLE res - ${EXTRA_ARGS}) - -if(NOT res EQUAL 0) - message(STATUS "Output to stderr:\n${err}") - message(FATAL_ERROR "Linting tests failed with error: ${res}.") -endif() diff --git a/contrib/local.mk.example b/contrib/local.mk.example index cadb9cf4b2..23fe11622b 100644 --- a/contrib/local.mk.example +++ b/contrib/local.mk.example @@ -13,26 +13,21 @@ # Sets the build type; defaults to Debug. Valid values: # -# - Debug: Disables optimizations (-O0), enables debug information and logging. +# - Debug: Disables optimizations (-O0), enables debug information. # -# - Dev: Enables all optimizations that do not interfere with -# debugging (-Og if available, -O2 and -g if not). -# Enables debug information and logging. -# -# - RelWithDebInfo: Enables optimizations (-O2) and debug information. -# Disables logging. +# - RelWithDebInfo: Enables optimizations (-Og or -O2) with debug information. # # - MinSizeRel: Enables all -O2 optimization that do not typically # increase code size, and performs further optimizations # designed to reduce code size (-Os). -# Disables debug information and logging. +# Disables debug information. # # - Release: Same as RelWithDebInfo, but disables debug information. # # CMAKE_BUILD_TYPE := Debug -# The default log level is 1 (INFO) (unless CMAKE_BUILD_TYPE is "Release"). # Log levels: 0 (DEBUG), 1 (INFO), 2 (WARNING), 3 (ERROR) +# Default is 1 (INFO) unless CMAKE_BUILD_TYPE is Release or RelWithDebInfo. # CMAKE_EXTRA_FLAGS += -DMIN_LOG_LEVEL=1 # By default, nvim uses bundled versions of its required third-party diff --git a/runtime/autoload/health.vim b/runtime/autoload/health.vim index 1d8cae7d19..f875c8b797 100644 --- a/runtime/autoload/health.vim +++ b/runtime/autoload/health.vim @@ -33,7 +33,8 @@ function! health#check(plugin_names) abort setlocal wrap breakindent setlocal filetype=markdown setlocal conceallevel=2 concealcursor=nc - setlocal keywordprg=:help iskeyword=@,48-57,_,192-255,-,# + setlocal keywordprg=:help + let &l:iskeyword='!-~,^*,^|,^",192-255' call s:enhance_syntax() if empty(healthchecks) diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index 31a235a397..ec20615f69 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -125,6 +125,10 @@ function! s:check_clipboard() abort call health#report_warn( \ 'No clipboard tool found. Clipboard registers will not work.', \ [':help clipboard']) + elseif exists('g:clipboard') && (type({}) != type(g:clipboard) + \ || !has_key(g:clipboard, 'copy') || !has_key(g:clipboard, 'paste')) + call health#report_error( + \ 'g:clipboard exists but is malformed. It must be a dictionary with the keys documented at :help g:clipboard') else call health#report_ok('Clipboard tool found: '. clipboard_tool) endif diff --git a/runtime/autoload/provider/clipboard.vim b/runtime/autoload/provider/clipboard.vim index e15aa1f2bd..a67681d28e 100644 --- a/runtime/autoload/provider/clipboard.vim +++ b/runtime/autoload/provider/clipboard.vim @@ -8,7 +8,7 @@ let s:paste = {} " ownership of the selection, so we know how long the cache is valid. let s:selection = { 'owner': 0, 'data': [] } -function! s:selection.on_exit(jobid, data, event) +function! s:selection.on_exit(jobid, data, event) abort " At this point this nvim instance might already have launched " a new provider instance. Don't drop ownership in this case. if self.owner == a:jobid @@ -18,7 +18,7 @@ endfunction let s:selections = { '*': s:selection, '+': copy(s:selection)} -function! s:try_cmd(cmd, ...) +function! s:try_cmd(cmd, ...) abort let argv = split(a:cmd, " ") let out = a:0 ? systemlist(argv, a:1, 1) : systemlist(argv, [''], 1) if v:shell_error @@ -34,7 +34,7 @@ function! s:try_cmd(cmd, ...) endfunction " Returns TRUE if `cmd` exits with success, else FALSE. -function! s:cmd_ok(cmd) +function! s:cmd_ok(cmd) abort call system(a:cmd) return v:shell_error == 0 endfunction @@ -47,7 +47,12 @@ function! provider#clipboard#Error() abort endfunction function! provider#clipboard#Executable() abort - if has('mac') && executable('pbcopy') + if exists('g:clipboard') + let s:copy = get(g:clipboard, 'copy', { '+': v:null, '*': v:null }) + let s:paste = get(g:clipboard, 'paste', { '+': v:null, '*': v:null }) + let s:cache_enabled = get(g:clipboard, 'cache_enabled', 1) + return get(g:clipboard, 'name', 'g:clipboard') + elseif has('mac') && executable('pbcopy') let s:copy['+'] = 'pbcopy' let s:paste['+'] = 'pbpaste' let s:copy['*'] = s:copy['+'] @@ -102,14 +107,14 @@ endif let s:clipboard = {} -function! s:clipboard.get(reg) +function! s:clipboard.get(reg) abort if s:selections[a:reg].owner > 0 return s:selections[a:reg].data end return s:try_cmd(s:paste[a:reg]) endfunction -function! s:clipboard.set(lines, regtype, reg) +function! s:clipboard.set(lines, regtype, reg) abort if a:reg == '"' call s:clipboard.set(a:lines,a:regtype,'+') if s:copy['*'] != s:copy['+'] @@ -144,6 +149,6 @@ function! s:clipboard.set(lines, regtype, reg) let selection.owner = jobid endfunction -function! provider#clipboard#Call(method, args) +function! provider#clipboard#Call(method, args) abort return call(s:clipboard[a:method],a:args,s:clipboard) endfunction diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index ebc2a40561..7c6b8a3c1a 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -165,7 +165,16 @@ nvim_input({keys}) *nvim_input()* *nvim_replace_termcodes()* nvim_replace_termcodes({str}, {from_part}, {do_lt}, {special}) - Replaces any terminal codes with the internal representation + Replaces terminal codes and |keycodes| (, , ...) in a + string with the internal representation. + + Parameters:~ + {str} String to be converted. + {from_part} Legacy Vim parameter. Usually true. + {do_lt} Also translate . Does nothing if + `special` is false. + {special} Replace |keycodes|, e.g. becomes a "\n" + char. nvim_command_output({str}) *nvim_command_output()* TODO: Documentation @@ -182,8 +191,10 @@ nvim_eval({expr}) *nvim_eval()* Evaluation result or expanded object nvim_call_function({fname}, {args}) *nvim_call_function()* - Calls a VimL function with the given arguments. On VimL error: - Returns a generic error; v:errmsg is not updated. + Calls a VimL function with the given arguments + + On VimL error: Returns a generic error; v:errmsg is not + updated. Parameters:~ {fname} Function to call @@ -192,6 +203,23 @@ nvim_call_function({fname}, {args}) *nvim_call_function()* Return:~ Result of the function call +nvim_execute_lua({code}, {args}) *nvim_execute_lua()* + Execute lua code. Parameters might be passed, they are + available inside the chunk as `...`. The chunk can return a + value. + + To evaluate an expression, it must be prefixed with "return ". + For instance, to call a lua function with arguments sent in + and get its return value back, use the code "return + my_function(...)". + + Parameters:~ + {code} lua code to execute + {args} Arguments to the code + + Return:~ + Return value of lua code if present or NIL. + nvim_strwidth({str}) *nvim_strwidth()* Calculates the number of display cells occupied by `text`. counts as one cell. @@ -382,6 +410,17 @@ nvim_get_mode() *nvim_get_mode()* Return:~ Dictionary { "mode": String, "blocking": Boolean } +nvim_get_keymap({mode}) *nvim_get_keymap()* + Get a list of dictionaries describing global (i.e. non-buffer) + mappings Note that the "buffer" key will be 0 to represent + false. + + Parameters:~ + {mode} The abbreviation for the mode + + Return:~ + An array of maparg() like dictionaries describing mappings + nvim_get_api_info() *nvim_get_api_info()* TODO: Documentation @@ -414,6 +453,54 @@ nvim_call_atomic({calls}) *nvim_call_atomic()* error ocurred, the values from all preceding calls will still be returned. +nvim__id({obj}) *nvim__id()* + Returns object given as argument + + This API function is used for testing. One should not rely on + its presence in plugins. + + Parameters:~ + {obj} Object to return. + + Return:~ + its argument. + +nvim__id_array({arr}) *nvim__id_array()* + Returns array given as argument + + This API function is used for testing. One should not rely on + its presence in plugins. + + Parameters:~ + {arr} Array to return. + + Return:~ + its argument. + +nvim__id_dictionary({dct}) *nvim__id_dictionary()* + Returns dictionary given as argument + + This API function is used for testing. One should not rely on + its presence in plugins. + + Parameters:~ + {dct} Dictionary to return. + + Return:~ + its argument. + +nvim__id_float({flt}) *nvim__id_float()* + Returns floating-point value given as argument + + This API function is used for testing. One should not rely on + its presence in plugins. + + Parameters:~ + {flt} Value to return. + + Return:~ + its argument. + ============================================================================== Buffer Functions *api-buffer* @@ -492,6 +579,18 @@ nvim_buf_get_changedtick({buffer}) *nvim_buf_get_changedtick()* Return:~ b:changedtickvalue. +nvim_buf_get_keymap({buffer}, {mode}) *nvim_buf_get_keymap()* + Get a list of dictionaries describing buffer-local mappings + Note that the buffer key in the dictionary will represent the + buffer handle where the mapping is present + + Parameters:~ + {mode} The abbreviation for the mode + {buffer_id} Buffer handle + + Return:~ + An array of maparg() like dictionaries describing mappings + nvim_buf_set_var({buffer}, {name}, {value}) *nvim_buf_set_var()* Sets a buffer-scoped (b:) variable diff --git a/runtime/doc/cmdline.txt b/runtime/doc/cmdline.txt index 948c921431..d870a72600 100644 --- a/runtime/doc/cmdline.txt +++ b/runtime/doc/cmdline.txt @@ -389,12 +389,26 @@ CTRL-L A match is done on the pattern in front of the cursor. If If there are multiple matches the longest common part is inserted in place of the pattern. If the result is shorter than the pattern, no completion is done. + */_CTRL-L* When 'incsearch' is set, entering a search pattern for "/" or "?" and the current match is displayed then CTRL-L will add one character from the end of the current match. If 'ignorecase' and 'smartcase' are set and the command line has no uppercase characters, the added character is converted to lowercase. + *c_CTRL-G* */_CTRL-G* +CTRL-G When 'incsearch' is set, entering a search pattern for "/" or + "?" and the current match is displayed then CTRL-G will move + to the next match (does not take |search-offset| into account) + Use CTRL-T to move to the previous match. Hint: on a regular + keyboard T is above G. + *c_CTRL-T* */_CTRL-T* +CTRL-T When 'incsearch' is set, entering a search pattern for "/" or + "?" and the current match is displayed then CTRL-T will move + to the previous match (does not take |search-offset| into + account). + Use CTRL-G to move to the next match. Hint: on a regular + keyboard T is above G. The 'wildchar' option defaults to (CTRL-E when in Vi compatible mode; in a previous version was used). In the pattern standard wildcards '*' and diff --git a/runtime/doc/deprecated.txt b/runtime/doc/deprecated.txt index 26cd5b24cc..b3e2f7a92f 100644 --- a/runtime/doc/deprecated.txt +++ b/runtime/doc/deprecated.txt @@ -39,10 +39,16 @@ Functions ~ *highlightID()* Obsolete name for |hlID()|. *last_buffer_nr()* Obsolete name for bufnr("$"). +Modifiers ~ +*:menu-* +*:menu-special* <> notation is always enabled. |cpo-<| +*:map-* +*:map-special* <> notation is always enabled. |cpo-<| + Options ~ *'fe'* 'fenc'+'enc' before Vim 6.0; no longer used. *'langnoremap'* Deprecated alias to 'nolangremap'. *'vi'* *'viminfo'* Deprecated alias to 'shada' option. - vim:tw=78:ts=8:ft=help:norl: + vim:noet:tw=78:ts=8:ft=help:norl: diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 2262c01374..e51f0f5dfc 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1852,10 +1852,11 @@ v:t_number Value of Number type. Read-only. See: |type()| v:t_string Value of String type. Read-only. See: |type()| *v:termresponse* *termresponse-variable* -v:termresponse The escape sequence returned by the terminal for the |t_RV| - termcap entry. It is set when Vim receives an escape sequence - that starts with ESC [ or CSI and ends in a 'c', with only - digits, ';' and '.' in between. +v:termresponse The escape sequence returned by the terminal for the DA + (request primary device attributes) control sequence. It is + set when Vim receives an escape sequence that starts with ESC + [ or CSI and ends in a 'c', with only digits, ';' and '.' in + between. When this option is set, the TermResponse autocommand event is fired, so that you can react to the response from the terminal. diff --git a/runtime/doc/gui.txt b/runtime/doc/gui.txt index 0bd3a40a7c..b66a60c860 100644 --- a/runtime/doc/gui.txt +++ b/runtime/doc/gui.txt @@ -490,9 +490,6 @@ expression register: > :amenu Insert.foobar "='foobar'P -Note that the '<' and 'k' flags in 'cpoptions' also apply here (when -included they make the <> form and raw key codes not being recognized). - Note that in Cmdline mode executes the command, like in a mapping. This is Vi compatible. Use CTRL-C to quit Cmdline mode. @@ -504,21 +501,13 @@ The ":set ic" will not be echoed when using this menu. Messages from the executed command are still given though. To shut them up too, add a ":silent" in the executed command: > :menu Search.Header :exe ":silent normal /Header\r" -"" may also appear just after "" or "