neovim/CMakeLists.txt

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

782 lines
26 KiB
CMake
Raw Normal View History

# CMAKE REFERENCE
# intro: https://codingnest.com/basic-cmake/
# best practices (3.0+): https://gist.github.com/mbinna/c61dbb39bca0e4fb7d1f73b0d66a4fd1
# Version should match the tested CMAKE_URL in .github/workflows/ci.yml.
cmake_minimum_required(VERSION 3.10)
project(nvim C)
if(POLICY CMP0065)
cmake_policy(SET CMP0065 NEW)
endif()
if(POLICY CMP0060)
cmake_policy(SET CMP0060 NEW)
endif()
2022-03-03 04:20:21 -07:00
if(POLICY CMP0075)
cmake_policy(SET CMP0075 NEW)
endif()
2014-02-24 13:54:45 -07:00
# Point CMake at any custom modules we may ship
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
2014-02-24 13:54:45 -07:00
# We don't support building in-tree.
include(PreventInTreeBuilds)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Prefer our bundled versions of dependencies.
if(DEFINED ENV{DEPS_BUILD_DIR})
if(CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
# pkg-config 29.2 has a bug on OpenBSD which causes it to drop any paths that
# *contain* system include paths. To avoid this, we prefix what would be
# "/usr/include" as "/_usr/include".
# This check is also performed in the third-party/CMakeLists.txt and in the
# else clause following here.
# https://github.com/neovim/neovim/pull/14745#issuecomment-860201794
set(DEPS_PREFIX "$ENV{DEPS_BUILD_DIR}/_usr" CACHE PATH "Path prefix for finding dependencies")
else()
set(DEPS_PREFIX "$ENV{DEPS_BUILD_DIR}/usr" CACHE PATH "Path prefix for finding dependencies")
endif()
else()
if(CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
set(DEPS_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/.deps/_usr" CACHE PATH "Path prefix for finding dependencies")
else()
set(DEPS_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/.deps/usr" CACHE PATH "Path prefix for finding dependencies")
endif()
# When running from within CLion or Visual Studio,
# build bundled dependencies automatically.
if(NOT EXISTS ${DEPS_PREFIX}
AND (DEFINED ENV{CLION_IDE}
OR DEFINED ENV{VisualStudioEdition}))
message(STATUS "Building dependencies...")
set(DEPS_BUILD_DIR ${PROJECT_BINARY_DIR}/.deps)
file(MAKE_DIRECTORY ${DEPS_BUILD_DIR})
execute_process(
COMMAND ${CMAKE_COMMAND} -G ${CMAKE_GENERATOR}
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_C_FLAGS_DEBUG=${CMAKE_C_FLAGS_DEBUG}
-DCMAKE_C_FLAGS_MINSIZEREL=${CMAKE_C_FLAGS_MINSIZEREL}
-DCMAKE_C_FLAGS_RELWITHDEBINFO=${CMAKE_C_FLAGS_RELWITHDEBINFO}
-DCMAKE_C_FLAGS_RELEASE=${CMAKE_C_FLAGS_RELEASE}
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
${PROJECT_SOURCE_DIR}/third-party
WORKING_DIRECTORY ${DEPS_BUILD_DIR})
execute_process(
COMMAND ${CMAKE_COMMAND} --build ${DEPS_BUILD_DIR}
--config ${CMAKE_BUILD_TYPE})
set(DEPS_PREFIX ${DEPS_BUILD_DIR}/usr)
endif()
endif()
if(CMAKE_CROSSCOMPILING AND NOT UNIX)
list(INSERT CMAKE_FIND_ROOT_PATH 0 ${DEPS_PREFIX})
list(INSERT CMAKE_PREFIX_PATH 0 ${DEPS_PREFIX}/../host/bin)
else()
list(INSERT CMAKE_PREFIX_PATH 0 ${DEPS_PREFIX})
set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:${DEPS_PREFIX}/lib/pkgconfig")
endif()
# used for check_c_compiler_flag
include(CheckCCompilerFlag)
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
# CMake tries to treat /sw and /opt/local as extension of the system path, but
# that doesn't really work out very well. Once you have a dependency that
# resides there and have to add it as an include directory, then any other
# dependency that could be satisfied from there must be--otherwise you can end
# up with conflicting versions. So, let's make them more of a priority having
# them be included as one of the first places to look for dependencies.
list(APPEND CMAKE_PREFIX_PATH /sw /opt/local)
# Work around some old, broken detection by CMake for knowing when to use the
# isystem flag. Apple's compilers have supported this for quite some time
# now.
if(CMAKE_COMPILER_IS_GNUCC)
set(CMAKE_INCLUDE_SYSTEM_FLAG_C "-isystem ")
endif()
2017-01-17 08:32:41 -07:00
endif()
2017-01-17 08:32:41 -07:00
if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL "Darwin")
# Ignore case when comparing filenames on Windows and Mac.
set(CASE_INSENSITIVE_FILENAME TRUE)
2017-01-17 08:32:41 -07:00
# Enable fixing case-insensitive filenames for Windows and Mac.
set(USE_FNAME_CASE TRUE)
endif()
option(ENABLE_LIBINTL "enable libintl" ON)
option(ENABLE_LIBICONV "enable libiconv" ON)
if (MINGW)
# Disable LTO by default as it may not compile
# See https://github.com/Alexpux/MINGW-packages/issues/3516
# and https://github.com/neovim/neovim/pull/8654#issuecomment-402316672
option(ENABLE_LTO "enable link time optimization" OFF)
else()
option(ENABLE_LTO "enable link time optimization" ON)
endif()
message(STATUS "CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}")
# Build type.
2014-11-09 05:52:15 -07:00
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "CMAKE_BUILD_TYPE not specified, default is 'Debug'")
2018-10-06 09:45:34 -07:00
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build" FORCE)
else()
message(STATUS "CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}")
endif()
if(CMAKE_BUILD_TYPE MATCHES Debug)
set(DEBUG 1)
else()
set(DEBUG 0)
2014-11-09 05:52:15 -07:00
endif()
# Set available build types for CMake GUIs.
# Other build types can still be set by -DCMAKE_BUILD_TYPE=...
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY
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`.
set(NVIM_VERSION_MAJOR 0)
2021-11-30 10:38:40 -07:00
set(NVIM_VERSION_MINOR 7)
2018-12-30 16:44:49 -07:00
set(NVIM_VERSION_PATCH 0)
NVIM 0.7 BREAKING CHANGES * Support for Python 2 is dropped. For Python 3, the minimum supported version is 3.6. Legacy `:pythonx` commands are still available, and always uses the python 3 provider. * api: Existing usages of `nvim_buf_set_text` that use negative line numbers will be off-by-one. * highlight: signature of `vim.highlight.range` was changed. * input: distinguish between some input keys which previously were synonyms. This will break some exiting mappings. - `<cr>`, `<tab>` and `<esc>` are no longer considered equivalent to `<c-m>`, `<c-i>` and `<c-[`> respectively. In case the terminal or GUI supports distinguishing these keys, these can now be mapped separately. But even if the terminal only can send one code you might still need to change what variant is used in the config. FEATURES Core APIs: * api: add support for lua function & description in keymap * api: add api and lua autocmds * api: nvim_clear_autocmd * api: pass args table to autocommand callbacks * api: remove Lua autocommand callbacks when they return true * api: implement nvim_{add,del}_user_command * api: implement nvim_buf_get_text * api: add nvim_get_option_value * highlight: ns=0 to set :highlight namespace * highlight: support for blend in nvim_set_hl * api: add strikethrough, nocombine to set_hl * api: relax statusline fillchar width check Lua: * lua: add vim.keymap * lua: add vim.spell * lua: add proper support of luv threads * lua: make :lua =expr print result of expr * lua: handle lazy submodules in `:lua vim.` wildmenu completion * lua: add notify_once() * lua: add support for multiple optional types in vim.validate * lua: show proper verbose output for lua configuration * lua: more conversions between LuaRef and Vim Funcref * lua: support converting nested Funcref back to LuaRef * call __tostring on lua errors if possible before reporting to user * filetype.lua * filetype.lua: add support for files under .git * filetype.lua: add support for patch files * filetype.lua: add support for tmux.conf files * filetype.lua: add support for txt files * filetype.lua: Add typescript extension to filetype detection * filetype.lua: fix .cc file not detected * filetype.lua: fix .env file not detected * filetype: convert patterns for mail buffers * filetype: support scripts.vim with filetype.lua UI and decorations: * decorations: support signs * extmarks: add strict option * api: expose extmark more details * api: expose extmark right_gravity and end_right_gravity * use nvim_buf_set_extmark for vim.highlight * statusline: support multibyte fillchar * add support for global statusline Treesitter: * ui: allow conceal to be defined in decorations and tree-sitter queries * tree-sitter: allow Atom-style capture fallbacks * treesitter: add more default groups to highlight map * treesitter: multiline match predicates * treesitter: set allocator when possible * ts: add support for multiline nodes in get_node_text * ts: expose minimum language version to lua * runtime: add query filetype LSP and diagnostic: * diagnostic: add "code" to the diagnostic structure * diagnostic: allow retrieving current diagnostic config * lsp,diagnostic: open folds in jump-related functions * lsp: add buf_detach_client * lsp: add handler for workspace/workspaceFolders * lsp: dynamically generate list title in response_to_list * lsp: enable default debounce of 150 ms * lsp: skip or reduce debounce after idle * lsp: use `vim.ui.select` for selecting lsp client Initial work to support remote TUI (and ui client library): * ui_client: connect to remote ui * ui_client: implement event handlers * ui_client: handle resize events * ui_client: implement async paste handling * ui_client: pass user input to remote server * --headless: add on_print callback to stdioopen * add autocommand event when search wraps around * add vim.tbl_get * autocmd: add Recording autocmds * autocmd: populate v:event in RecordingLeave * completion: support selecting item via API from Lua mapping * eval/method: partially port v8.1.1993 * eval/method: partially port v8.1.1996 * eval/method: partially port v8.1.2004 * eval: partially port v8.2.0878 * eval: port emsg from v8.2.3284 * events: add DirChangedPre * events: support SIGWINCH for Signal event * hardcopy: check gui colours for highlights first * highlight: support color names for cterm * ignore nore on <Plug> maps * input: delay some conversions to vgetc() * input: enable <tab>/<c-i>, <cr>/<c-m>, <esc>/<c-[> pairs unconditionally * keymap: add F38-F63 keys * keymap: return nil from an expr keymap * mappings: considering map description when filtering * provider: remove support for python2 and python3.[3-5] * remote: add basic --remote support * runtime: import cleanadd.vim from Vim * runtime: include Lua in C++ ftplugin * runtime: new checkhealth filetype * term: use vterm_output_set_callback() * test: use nvim_exec in helpers.source() * trigger ModeChanged for terminal modes * tui: add error logging * tui: add support for `CSI 4 : [2,4,5] m` * tui: enable CSI u keys * vim-patch.sh: support additional args for -s Performance Improvements * lsp: request only changed portions of the buffer in changetracking * only redraw concealed line if cursor has moved horizontally * pre-compile embedded Lua source into bytecode * screen: reduce cursorline redrawing when jumping around * treesitter: cache query parsing * api: elide luaref copy when setting 'callback' in nvim_set_keymap BUG FIXES * --headless: do not block on press-enter prompts when no UI * <Nop> not shown in :map commands * add forkpty for SunOS variants * add STRNLEN compatability macro * anonymous sid not working * api, lua: return NIL on failure to find converted function * api/nvim_win_call: share common win_execute logic * api: allow empty list for cterm in nvim_set_hl * api: allow nvim_buf_set_extmark to accept end_row key * api: convert blob to NUL-terminated API string * api: correctly handle negative line numbers for nvim_buf_set_text * api: correctly pass f-args for nvim_create_user_command * api: delete all autocmds with the same ID * api: force redefinition of user commands by default * api: highlight attribute for underline * api: improve autocmd error handling * api: include event in get_autocmds * api: make nil value in nvim_set_option_value clear local value * api: nvim__set_hl_ns causes extra redraws * api: nvim_win_set_cursor() redraw for cursorline and statusline * api: re-route nvim_get_runtime_file errors * api: use changedir_func() in nvim_set_current_dir() * api: validate command names in nvim_add_user_command * api: validate user_command name * append test for checking zero width node range * aucmd_win: always make aucmd_win the last window * aucmd_win: ensure aucmd_win stays floating * autocmd: clean up autocmds only when needed * autocmd: restore autocmd showing behavior * autoload variables not loaded with vim.g & nvim_get_var * bounds check for underdot * build: check for empty value of LUAC_PRG * build: check that LuaJIT has required modules for compilation * build: install luajit modules on windows * channel: fix channel consistency * check for interrupt in nvim_echo, write_msg and nlua_print * checkhealth: make provider checkhealth output more consistent * ci/backport: check for event_name == "pull_request_target" * ci: provide necessary permissions for calling workflow * clang/'Dead store': do not assign endcol * close floating windows when calling win_close() * completion: prevent K_LUA from closing pum * completion: update submode message when selecting from API * correct vertical dragging room calculation with global statusline * coverity/175977: big parameter passed by value * coverity/188749: nullify pointer to fix use-after-free * coverity/340720: error if nvim_eval_statusline given invalid winid * coverity: dead code and operands don't affect result * decorations: do not put empty virt_text * define NAME_MAX from _XOPEN_NAME_MAX * diagnostic: allow setting arbitrary config values * diagnostic: assert that diagnostics have line number and column * diagnostic: clamp diagnostics on negative line numbers * diagnostic: escape special chars in file names * diagnostic: improve validation for list arguments * diagnostic: make `open_float` respect global diagnostic options * diagnostic: only set default handler config if unset * diagnostic: resolve nil opts tables * diagnostic: respect "if_many" source option for virtual text * diagnostic: set effective buffer number for DiagnosticChanged autocmd * diagnostic: set effective buffer number in autocmd (again) * diagnostic: use botright copen for qflist * diff: make algorithm work for vim.diff * do not cast offset to char_u * do not pass aucmd to the callback * do not save K_EVENT as lastc in Insert mode * docs: add bufnr and user_data to diagnostic-structure * docs: spelling in new underlines docs * don't include pty.h on SunOS * don't use cfsetspeed, use i and o variants * enable filetype detection and syntax highlighting with --clean * eval/method: add missing method support for existing built-ins * eval: v:lua support for `-` in module names * event-loop: call vpeekc() directly first to check for character * event-loop: check if executed register has ended * event-loop: duplicate display updating logic in vgetorpeek() * events: make v:event readonly in more events * ex_normal: spam \n in Ex mode only if in Cmdline mode * extmarks: fix signs * extmarks: splice extmarks on accepting spell * filetype.lua: always return a string in getline helper function * filetype: expand tildes in filetype patterns * filetype: fix foam pattern detection * filetype: match negative priority patterns after extensions * filetype: match on <afile> rather than <abuf> * filetype: normalize slashes in file paths * filetype: set default ft_ignore_pat in filetype.lua * float: do not switch window before deleting last listed buffer * float: don't always switch window when deleting last listed buffer * float: handle buffer deletion with floating windows * float: make laststatus=1 behave consistently with floating windows * healthcheck: handle empty reports * health: do not run external processes in a shell * highlight: accept NONE as a color name * highlight: allow globals to be cleared * highlight: always update window highlight if highlight changed * inccommand: do not change reg_prev_sub when previewing * input: do not translate scroll keys into multiclicks * input: fix clearing of reg_executing * input: never escape CSI bytes * input: put modifiers back into typeahead buffer when needed * input: remove reinterpreted ALT/META chords from recorded macro * keymap: don't coerce false to '' * keywordprg: retain terminal buffer after K * line continuation: set growsize to correct value * lsp and diagnostic highlight priority * lsp: always split text edits on \r, \r\n, and \n * lsp: always use target bufnr in location handler * lsp: avoid attaching to unloaded buffers * lsp: avoid nil workspace/symbol query * lsp: call config on_exit handler before context is cleared * lsp: correct prefix when filterText is present * lsp: correctly align start and end range to codepoints during incremental sync * lsp: create lsp requests with position offsets considering client encoding * lsp: ensure pending changes are flushed on skipped debounce * lsp: explicitly pass bufnr in didSave handler * lsp: fetch offset_encoding from client in references * lsp: fix `nil`-index behavior for UTF-8 in `_str_*index_enc` methods * lsp: fix applying multiple out-of-range TextEdits * lsp: fix lookup of boolean values in workspace/configuration * lsp: forward offset_encoding in rename handler * lsp: forward offset_encoding to apply_text_edits * lsp: handle insertion of previous line * lsp: handle negative activeSignature in signatureHelp * lsp: only send valid params in executeCommand * lsp: pass offset_encoding in formatexpr() * lsp: progress handlers should return vim.NIL on error * lsp: resolve bufnr for get_lines * lsp: resolve nil bufnr * lsp: respect all of 'fixeol', 'eol', and 'binary' applying edits * lsp: set tabSize from 'shiftwidth', not 'softtabstop' * lsp: start incremental sync range at previous newline character * lsp: strictly enforce passing offset encoding * lsp: suppress ContentModified errors from UI * lsp: use "text" filetype for plaintext * lsp: use botright copen for all handlers * lua: don't use nlua_error when exiting early * lua: print multiple return values with =expr * lua: restore priority of the preloader * lua: stricter type check when calling API function * make mode() return correct value in ex mode * man.vim: fix search function on some systems * man.vim: support calling :Man without a section again * msgpack#strptime: use calendar.timegm to get seconds since epoch * ops: str_to_reg passing NULL to memcpy * options: disallow empty 'fdc' and 'scl' * paste: avoid edges cases caused by empty chunk * paste: deal with eol and eof in Visual mode * paste: deal with trailing new line in chunk * paste: don't move cursor past the end of pasted text in Normal mode * paste: escape control characters in Cmdline mode * paste: use getcmdtype() to determine whether in cmdline mode * prompt: add missing changes from v8.1.0036 * pty_process_win/wait_eof_timer_cb: also check for proc->out.did_eof * pum_redraw: use grid_puts_len() to truncate the text * PVS/V1019: compound assignment expression is used inside condition * PVS/V560: ignore false "conditional expression is always false" * PVS/V583: the '?:' operator always returns one and the same value * query.lua: check empty table for lines * quickfix: avoid O(N^2) when filling from string typval * remote: make compile again * remote: report connection error, missing return values * remote: report on missing wait commands, typecheck lua results * remote: respect silent in error reporting * remote: use STATIC_CSTR_AS_STRING * resolve nil arguments to API functions * respect os_proc_children rv of pid not found * runtime: add missing release metadata * runtime: add syntax file for query * runtime: check markdownError before syn-clear * screen: do not do syntax highlighting at filler or folded lines * screen: do not draw filler lines post eof if already at last row * screen: do not update syntax_last_parsed when drawing folded line * screen: don't put empty sign text in line number column * screenpos, float: add top and left border adjustment * screen: truncate double-width character correctly * screen: truncate when overwriting right half of a double-width char * set nested before executing callback * set RedrawingDisabled before entering aucmd_win * signcol: always trigger a redraw * signcol: handle edge case with maximum value * signcol: update cursor when signcol changes * skip libutil on SunOS * substitute: properly check for empty command line * syntax.c: correct hunk from Vim patch 8.0.0647 * syntax: remove trailing spaces in vim.vim * tabpage: correct check for failure to close window * termdebug: handle exiting during startup properly * terminal: correctly forward mouse events * terminal: fix resize crash with pending scrollback * terminal: ignore left-release mouse action * terminal: return early if there are no invalid rows * terminal: use coladvance() to calculate buffer cursor position * test: only use buffer completion in popupmenu timer test * tests: update legacy tab switch test to be sane * translation: po file for Russian * translation: po file for Ukrainian * ts: escape lang when loading parsers * tui: avoid using uninitialized memory in kitty * tui: correct CSI sequence * tui: end streamed paste correctly when key buffer is empty * tui: remove `ESC NUL` forced escape * ui: close floating window on BufLeave event * ui: inccomand performance degradation * ui: make window resize commands manage cmdheight * update last cursor on first CursorMoved * uri: change scheme pattern to not include the comma character * use normal! <C-L> in default <C-L> mapping * vim-patch.sh: fix N/A files patterns * win_close: count the window the be closed instead of curwin * win_split_ins: do not fail when oldwin is not valid
2022-04-15 04:38:44 -07:00
set(NVIM_VERSION_PRERELEASE "") # for package maintainers
# API level
2021-12-04 14:03:28 -07:00
set(NVIM_API_LEVEL 9) # Bump this after any API change.
set(NVIM_API_LEVEL_COMPAT 0) # Adjust this after a _breaking_ API change.
NVIM 0.7 BREAKING CHANGES * Support for Python 2 is dropped. For Python 3, the minimum supported version is 3.6. Legacy `:pythonx` commands are still available, and always uses the python 3 provider. * api: Existing usages of `nvim_buf_set_text` that use negative line numbers will be off-by-one. * highlight: signature of `vim.highlight.range` was changed. * input: distinguish between some input keys which previously were synonyms. This will break some exiting mappings. - `<cr>`, `<tab>` and `<esc>` are no longer considered equivalent to `<c-m>`, `<c-i>` and `<c-[`> respectively. In case the terminal or GUI supports distinguishing these keys, these can now be mapped separately. But even if the terminal only can send one code you might still need to change what variant is used in the config. FEATURES Core APIs: * api: add support for lua function & description in keymap * api: add api and lua autocmds * api: nvim_clear_autocmd * api: pass args table to autocommand callbacks * api: remove Lua autocommand callbacks when they return true * api: implement nvim_{add,del}_user_command * api: implement nvim_buf_get_text * api: add nvim_get_option_value * highlight: ns=0 to set :highlight namespace * highlight: support for blend in nvim_set_hl * api: add strikethrough, nocombine to set_hl * api: relax statusline fillchar width check Lua: * lua: add vim.keymap * lua: add vim.spell * lua: add proper support of luv threads * lua: make :lua =expr print result of expr * lua: handle lazy submodules in `:lua vim.` wildmenu completion * lua: add notify_once() * lua: add support for multiple optional types in vim.validate * lua: show proper verbose output for lua configuration * lua: more conversions between LuaRef and Vim Funcref * lua: support converting nested Funcref back to LuaRef * call __tostring on lua errors if possible before reporting to user * filetype.lua * filetype.lua: add support for files under .git * filetype.lua: add support for patch files * filetype.lua: add support for tmux.conf files * filetype.lua: add support for txt files * filetype.lua: Add typescript extension to filetype detection * filetype.lua: fix .cc file not detected * filetype.lua: fix .env file not detected * filetype: convert patterns for mail buffers * filetype: support scripts.vim with filetype.lua UI and decorations: * decorations: support signs * extmarks: add strict option * api: expose extmark more details * api: expose extmark right_gravity and end_right_gravity * use nvim_buf_set_extmark for vim.highlight * statusline: support multibyte fillchar * add support for global statusline Treesitter: * ui: allow conceal to be defined in decorations and tree-sitter queries * tree-sitter: allow Atom-style capture fallbacks * treesitter: add more default groups to highlight map * treesitter: multiline match predicates * treesitter: set allocator when possible * ts: add support for multiline nodes in get_node_text * ts: expose minimum language version to lua * runtime: add query filetype LSP and diagnostic: * diagnostic: add "code" to the diagnostic structure * diagnostic: allow retrieving current diagnostic config * lsp,diagnostic: open folds in jump-related functions * lsp: add buf_detach_client * lsp: add handler for workspace/workspaceFolders * lsp: dynamically generate list title in response_to_list * lsp: enable default debounce of 150 ms * lsp: skip or reduce debounce after idle * lsp: use `vim.ui.select` for selecting lsp client Initial work to support remote TUI (and ui client library): * ui_client: connect to remote ui * ui_client: implement event handlers * ui_client: handle resize events * ui_client: implement async paste handling * ui_client: pass user input to remote server * --headless: add on_print callback to stdioopen * add autocommand event when search wraps around * add vim.tbl_get * autocmd: add Recording autocmds * autocmd: populate v:event in RecordingLeave * completion: support selecting item via API from Lua mapping * eval/method: partially port v8.1.1993 * eval/method: partially port v8.1.1996 * eval/method: partially port v8.1.2004 * eval: partially port v8.2.0878 * eval: port emsg from v8.2.3284 * events: add DirChangedPre * events: support SIGWINCH for Signal event * hardcopy: check gui colours for highlights first * highlight: support color names for cterm * ignore nore on <Plug> maps * input: delay some conversions to vgetc() * input: enable <tab>/<c-i>, <cr>/<c-m>, <esc>/<c-[> pairs unconditionally * keymap: add F38-F63 keys * keymap: return nil from an expr keymap * mappings: considering map description when filtering * provider: remove support for python2 and python3.[3-5] * remote: add basic --remote support * runtime: import cleanadd.vim from Vim * runtime: include Lua in C++ ftplugin * runtime: new checkhealth filetype * term: use vterm_output_set_callback() * test: use nvim_exec in helpers.source() * trigger ModeChanged for terminal modes * tui: add error logging * tui: add support for `CSI 4 : [2,4,5] m` * tui: enable CSI u keys * vim-patch.sh: support additional args for -s Performance Improvements * lsp: request only changed portions of the buffer in changetracking * only redraw concealed line if cursor has moved horizontally * pre-compile embedded Lua source into bytecode * screen: reduce cursorline redrawing when jumping around * treesitter: cache query parsing * api: elide luaref copy when setting 'callback' in nvim_set_keymap BUG FIXES * --headless: do not block on press-enter prompts when no UI * <Nop> not shown in :map commands * add forkpty for SunOS variants * add STRNLEN compatability macro * anonymous sid not working * api, lua: return NIL on failure to find converted function * api/nvim_win_call: share common win_execute logic * api: allow empty list for cterm in nvim_set_hl * api: allow nvim_buf_set_extmark to accept end_row key * api: convert blob to NUL-terminated API string * api: correctly handle negative line numbers for nvim_buf_set_text * api: correctly pass f-args for nvim_create_user_command * api: delete all autocmds with the same ID * api: force redefinition of user commands by default * api: highlight attribute for underline * api: improve autocmd error handling * api: include event in get_autocmds * api: make nil value in nvim_set_option_value clear local value * api: nvim__set_hl_ns causes extra redraws * api: nvim_win_set_cursor() redraw for cursorline and statusline * api: re-route nvim_get_runtime_file errors * api: use changedir_func() in nvim_set_current_dir() * api: validate command names in nvim_add_user_command * api: validate user_command name * append test for checking zero width node range * aucmd_win: always make aucmd_win the last window * aucmd_win: ensure aucmd_win stays floating * autocmd: clean up autocmds only when needed * autocmd: restore autocmd showing behavior * autoload variables not loaded with vim.g & nvim_get_var * bounds check for underdot * build: check for empty value of LUAC_PRG * build: check that LuaJIT has required modules for compilation * build: install luajit modules on windows * channel: fix channel consistency * check for interrupt in nvim_echo, write_msg and nlua_print * checkhealth: make provider checkhealth output more consistent * ci/backport: check for event_name == "pull_request_target" * ci: provide necessary permissions for calling workflow * clang/'Dead store': do not assign endcol * close floating windows when calling win_close() * completion: prevent K_LUA from closing pum * completion: update submode message when selecting from API * correct vertical dragging room calculation with global statusline * coverity/175977: big parameter passed by value * coverity/188749: nullify pointer to fix use-after-free * coverity/340720: error if nvim_eval_statusline given invalid winid * coverity: dead code and operands don't affect result * decorations: do not put empty virt_text * define NAME_MAX from _XOPEN_NAME_MAX * diagnostic: allow setting arbitrary config values * diagnostic: assert that diagnostics have line number and column * diagnostic: clamp diagnostics on negative line numbers * diagnostic: escape special chars in file names * diagnostic: improve validation for list arguments * diagnostic: make `open_float` respect global diagnostic options * diagnostic: only set default handler config if unset * diagnostic: resolve nil opts tables * diagnostic: respect "if_many" source option for virtual text * diagnostic: set effective buffer number for DiagnosticChanged autocmd * diagnostic: set effective buffer number in autocmd (again) * diagnostic: use botright copen for qflist * diff: make algorithm work for vim.diff * do not cast offset to char_u * do not pass aucmd to the callback * do not save K_EVENT as lastc in Insert mode * docs: add bufnr and user_data to diagnostic-structure * docs: spelling in new underlines docs * don't include pty.h on SunOS * don't use cfsetspeed, use i and o variants * enable filetype detection and syntax highlighting with --clean * eval/method: add missing method support for existing built-ins * eval: v:lua support for `-` in module names * event-loop: call vpeekc() directly first to check for character * event-loop: check if executed register has ended * event-loop: duplicate display updating logic in vgetorpeek() * events: make v:event readonly in more events * ex_normal: spam \n in Ex mode only if in Cmdline mode * extmarks: fix signs * extmarks: splice extmarks on accepting spell * filetype.lua: always return a string in getline helper function * filetype: expand tildes in filetype patterns * filetype: fix foam pattern detection * filetype: match negative priority patterns after extensions * filetype: match on <afile> rather than <abuf> * filetype: normalize slashes in file paths * filetype: set default ft_ignore_pat in filetype.lua * float: do not switch window before deleting last listed buffer * float: don't always switch window when deleting last listed buffer * float: handle buffer deletion with floating windows * float: make laststatus=1 behave consistently with floating windows * healthcheck: handle empty reports * health: do not run external processes in a shell * highlight: accept NONE as a color name * highlight: allow globals to be cleared * highlight: always update window highlight if highlight changed * inccommand: do not change reg_prev_sub when previewing * input: do not translate scroll keys into multiclicks * input: fix clearing of reg_executing * input: never escape CSI bytes * input: put modifiers back into typeahead buffer when needed * input: remove reinterpreted ALT/META chords from recorded macro * keymap: don't coerce false to '' * keywordprg: retain terminal buffer after K * line continuation: set growsize to correct value * lsp and diagnostic highlight priority * lsp: always split text edits on \r, \r\n, and \n * lsp: always use target bufnr in location handler * lsp: avoid attaching to unloaded buffers * lsp: avoid nil workspace/symbol query * lsp: call config on_exit handler before context is cleared * lsp: correct prefix when filterText is present * lsp: correctly align start and end range to codepoints during incremental sync * lsp: create lsp requests with position offsets considering client encoding * lsp: ensure pending changes are flushed on skipped debounce * lsp: explicitly pass bufnr in didSave handler * lsp: fetch offset_encoding from client in references * lsp: fix `nil`-index behavior for UTF-8 in `_str_*index_enc` methods * lsp: fix applying multiple out-of-range TextEdits * lsp: fix lookup of boolean values in workspace/configuration * lsp: forward offset_encoding in rename handler * lsp: forward offset_encoding to apply_text_edits * lsp: handle insertion of previous line * lsp: handle negative activeSignature in signatureHelp * lsp: only send valid params in executeCommand * lsp: pass offset_encoding in formatexpr() * lsp: progress handlers should return vim.NIL on error * lsp: resolve bufnr for get_lines * lsp: resolve nil bufnr * lsp: respect all of 'fixeol', 'eol', and 'binary' applying edits * lsp: set tabSize from 'shiftwidth', not 'softtabstop' * lsp: start incremental sync range at previous newline character * lsp: strictly enforce passing offset encoding * lsp: suppress ContentModified errors from UI * lsp: use "text" filetype for plaintext * lsp: use botright copen for all handlers * lua: don't use nlua_error when exiting early * lua: print multiple return values with =expr * lua: restore priority of the preloader * lua: stricter type check when calling API function * make mode() return correct value in ex mode * man.vim: fix search function on some systems * man.vim: support calling :Man without a section again * msgpack#strptime: use calendar.timegm to get seconds since epoch * ops: str_to_reg passing NULL to memcpy * options: disallow empty 'fdc' and 'scl' * paste: avoid edges cases caused by empty chunk * paste: deal with eol and eof in Visual mode * paste: deal with trailing new line in chunk * paste: don't move cursor past the end of pasted text in Normal mode * paste: escape control characters in Cmdline mode * paste: use getcmdtype() to determine whether in cmdline mode * prompt: add missing changes from v8.1.0036 * pty_process_win/wait_eof_timer_cb: also check for proc->out.did_eof * pum_redraw: use grid_puts_len() to truncate the text * PVS/V1019: compound assignment expression is used inside condition * PVS/V560: ignore false "conditional expression is always false" * PVS/V583: the '?:' operator always returns one and the same value * query.lua: check empty table for lines * quickfix: avoid O(N^2) when filling from string typval * remote: make compile again * remote: report connection error, missing return values * remote: report on missing wait commands, typecheck lua results * remote: respect silent in error reporting * remote: use STATIC_CSTR_AS_STRING * resolve nil arguments to API functions * respect os_proc_children rv of pid not found * runtime: add missing release metadata * runtime: add syntax file for query * runtime: check markdownError before syn-clear * screen: do not do syntax highlighting at filler or folded lines * screen: do not draw filler lines post eof if already at last row * screen: do not update syntax_last_parsed when drawing folded line * screen: don't put empty sign text in line number column * screenpos, float: add top and left border adjustment * screen: truncate double-width character correctly * screen: truncate when overwriting right half of a double-width char * set nested before executing callback * set RedrawingDisabled before entering aucmd_win * signcol: always trigger a redraw * signcol: handle edge case with maximum value * signcol: update cursor when signcol changes * skip libutil on SunOS * substitute: properly check for empty command line * syntax.c: correct hunk from Vim patch 8.0.0647 * syntax: remove trailing spaces in vim.vim * tabpage: correct check for failure to close window * termdebug: handle exiting during startup properly * terminal: correctly forward mouse events * terminal: fix resize crash with pending scrollback * terminal: ignore left-release mouse action * terminal: return early if there are no invalid rows * terminal: use coladvance() to calculate buffer cursor position * test: only use buffer completion in popupmenu timer test * tests: update legacy tab switch test to be sane * translation: po file for Russian * translation: po file for Ukrainian * ts: escape lang when loading parsers * tui: avoid using uninitialized memory in kitty * tui: correct CSI sequence * tui: end streamed paste correctly when key buffer is empty * tui: remove `ESC NUL` forced escape * ui: close floating window on BufLeave event * ui: inccomand performance degradation * ui: make window resize commands manage cmdheight * update last cursor on first CursorMoved * uri: change scheme pattern to not include the comma character * use normal! <C-L> in default <C-L> mapping * vim-patch.sh: fix N/A files patterns * win_close: count the window the be closed instead of curwin * win_split_ins: do not fail when oldwin is not valid
2022-04-15 04:38:44 -07:00
set(NVIM_API_PRERELEASE false)
2014-11-09 05:52:15 -07:00
set(NVIM_VERSION_BUILD_TYPE "${CMAKE_BUILD_TYPE}")
# NVIM_VERSION_CFLAGS set further below.
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Log level (MIN_LOG_LEVEL in log.h)
if("${MIN_LOG_LEVEL}" MATCHES "^$")
# Minimize logging for release-type builds.
if(CMAKE_BUILD_TYPE STREQUAL "Release"
OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo"
OR CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
message(STATUS "MIN_LOG_LEVEL not specified, default is 3 (ERROR) for release builds")
set(MIN_LOG_LEVEL 3)
else()
message(STATUS "MIN_LOG_LEVEL not specified, default is 1 (INFO)")
set(MIN_LOG_LEVEL 1)
endif()
else()
if(NOT MIN_LOG_LEVEL MATCHES "^[0-3]$")
message(FATAL_ERROR "invalid MIN_LOG_LEVEL: " ${MIN_LOG_LEVEL})
endif()
message(STATUS "MIN_LOG_LEVEL=${MIN_LOG_LEVEL}")
endif()
# Default to -O2 on release builds.
if(CMAKE_C_FLAGS_RELEASE MATCHES "-O3")
message(STATUS "Replacing -O3 in CMAKE_C_FLAGS_RELEASE with -O2")
string(REPLACE "-O3" "-O2" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
endif()
if(CMAKE_COMPILER_IS_GNUCC)
check_c_compiler_flag(-Og HAS_OG_FLAG)
else()
set(HAS_OG_FLAG 0)
endif()
#
# Build-type: RelWithDebInfo
#
if(HAS_OG_FLAG)
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -Og -g")
endif()
# We _want_ assertions in RelWithDebInfo build-type.
if(CMAKE_C_FLAGS_RELWITHDEBINFO MATCHES DNDEBUG)
string(REPLACE "-DNDEBUG" "" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
endif()
# gcc 4.0+ sets _FORTIFY_SOURCE=2 automatically. This currently
# does not work with Neovim due to some uses of dynamically-sized structures.
# https://github.com/neovim/neovim/issues/223
include(CheckCSourceCompiles)
# Include the build type's default flags in the check for _FORTIFY_SOURCE,
# otherwise we may incorrectly identify the level as acceptable and find out
# later that it was not when optimizations were enabled. CFLAGS is applied
# even though you don't see it in CMAKE_REQUIRED_FLAGS.
set(INIT_FLAGS_NAME CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE})
string(TOUPPER ${INIT_FLAGS_NAME} INIT_FLAGS_NAME)
if(${INIT_FLAGS_NAME})
set(CMAKE_REQUIRED_FLAGS "${${INIT_FLAGS_NAME}}")
endif()
# Include <string.h> because some toolchains define _FORTIFY_SOURCE=2 in
# internal header files, which should in turn be #included by <string.h>.
check_c_source_compiles("
#include <string.h>
#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 1
#error \"_FORTIFY_SOURCE > 1\"
#endif
int
main(void)
{
return 0;
}
" HAS_ACCEPTABLE_FORTIFY)
if(NOT HAS_ACCEPTABLE_FORTIFY)
2018-10-06 09:45:34 -07:00
message(STATUS "Unsupported _FORTIFY_SOURCE found, forcing _FORTIFY_SOURCE=1")
# Extract possible prefix to _FORTIFY_SOURCE (e.g. -Wp,-D_FORTIFY_SOURCE).
STRING(REGEX MATCH "[^\ ]+-D_FORTIFY_SOURCE" _FORTIFY_SOURCE_PREFIX "${CMAKE_C_FLAGS}")
STRING(REPLACE "-D_FORTIFY_SOURCE" "" _FORTIFY_SOURCE_PREFIX "${_FORTIFY_SOURCE_PREFIX}" )
if(NOT _FORTIFY_SOURCE_PREFIX STREQUAL "")
2018-10-06 09:45:34 -07:00
message(STATUS "Detected _FORTIFY_SOURCE Prefix=${_FORTIFY_SOURCE_PREFIX}")
endif()
# -U in add_definitions doesn't end up in the correct spot, so we add it to
# the flags variable instead.
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_FORTIFY_SOURCE_PREFIX}-U_FORTIFY_SOURCE ${_FORTIFY_SOURCE_PREFIX}-D_FORTIFY_SOURCE=1")
endif()
# Remove --sort-common from linker flags, as this seems to cause bugs (see #2641, #3374).
# TODO: Figure out the root cause.
if(CMAKE_EXE_LINKER_FLAGS MATCHES "--sort-common" OR
CMAKE_SHARED_LINKER_FLAGS MATCHES "--sort-common" OR
CMAKE_MODULE_LINKER_FLAGS MATCHES "--sort-common")
2018-10-06 09:45:34 -07:00
message(STATUS "Removing --sort-common from linker flags")
string(REGEX REPLACE ",--sort-common(=[^,]+)?" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
string(REGEX REPLACE ",--sort-common(=[^,]+)?" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
string(REGEX REPLACE ",--sort-common(=[^,]+)?" "" CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS}")
# If no linker flags remain for a -Wl argument, remove it.
# '-Wl$' will match LDFLAGS="-Wl,--sort-common",
# '-Wl ' will match LDFLAGS="-Wl,--sort-common -Wl,..."
string(REGEX REPLACE "-Wl($| )" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
string(REGEX REPLACE "-Wl($| )" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
string(REGEX REPLACE "-Wl($| )" "" CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS}")
endif()
check_c_source_compiles("
#include <execinfo.h>
int main(void)
{
void *trace[1];
backtrace(trace, 1);
return 0;
}
" HAVE_EXECINFO_BACKTRACE)
check_c_source_compiles("
int main(void)
{
int a = 42;
__builtin_add_overflow(a, a, &a);
__builtin_sub_overflow(a, a, &a);
return 0;
}
" HAVE_BUILTIN_ADD_OVERFLOW)
if(MSVC)
# XXX: /W4 gives too many warnings. #3241
add_compile_options(/W3)
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE)
add_definitions(-DWIN32)
else()
add_compile_options(-Wall -Wextra -pedantic -Wno-unused-parameter
-Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion
-Wdouble-promotion
-Wmissing-noreturn
-Wmissing-format-attribute
-Wmissing-prototypes)
check_c_compiler_flag(-Wimplicit-fallthrough HAVE_WIMPLICIT_FALLTHROUGH_FLAG)
if(HAVE_WIMPLICIT_FALLTHROUGH_FLAG)
add_compile_options(-Wimplicit-fallthrough)
endif()
# Clang doesn't have -Wsuggest-attribute so check for each one.
check_c_compiler_flag(-Wsuggest-attribute=pure HAVE_WSUGGEST_ATTRIBUTE_PURE)
if(HAVE_WSUGGEST_ATTRIBUTE_PURE)
add_compile_options(-Wsuggest-attribute=pure)
endif()
check_c_compiler_flag(-Wsuggest-attribute=const HAVE_WSUGGEST_ATTRIBUTE_CONST)
if(HAVE_WSUGGEST_ATTRIBUTE_CONST)
add_compile_options(-Wsuggest-attribute=const)
endif()
check_c_compiler_flag(-Wsuggest-attribute=malloc HAVE_WSUGGEST_ATTRIBUTE_MALLOC)
if(HAVE_WSUGGEST_ATTRIBUTE_MALLOC)
add_compile_options(-Wsuggest-attribute=malloc)
endif()
check_c_compiler_flag(-Wsuggest-attribute=cold HAVE_WSUGGEST_ATTRIBUTE_COLD)
if(HAVE_WSUGGEST_ATTRIBUTE_COLD)
add_compile_options(-Wsuggest-attribute=cold)
endif()
# On FreeBSD 64 math.h uses unguarded C11 extension, which taints clang
# 3.4.1 used there.
if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" AND CMAKE_C_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wno-c11-extensions)
endif()
endif()
if(MINGW)
# Use POSIX compatible stdio in Mingw
add_definitions(-D__USE_MINGW_ANSI_STDIO)
endif()
if(WIN32)
# Windows Vista is the minimum supported version
add_definitions(-D_WIN32_WINNT=0x0600)
endif()
# OpenBSD's GCC (4.2.1) doesn't have -Wvla
check_c_compiler_flag(-Wvla HAS_WVLA_FLAG)
if(HAS_WVLA_FLAG)
add_compile_options(-Wvla)
endif()
if(UNIX)
# -fstack-protector breaks non Unix builds even in Mingw-w64
check_c_compiler_flag(-fstack-protector-strong HAS_FSTACK_PROTECTOR_STRONG_FLAG)
check_c_compiler_flag(-fstack-protector HAS_FSTACK_PROTECTOR_FLAG)
if(HAS_FSTACK_PROTECTOR_STRONG_FLAG)
add_compile_options(-fstack-protector-strong)
link_libraries(-fstack-protector-strong)
elseif(HAS_FSTACK_PROTECTOR_FLAG)
add_compile_options(-fstack-protector --param ssp-buffer-size=4)
link_libraries(-fstack-protector --param ssp-buffer-size=4)
endif()
endif()
check_c_compiler_flag(-fno-common HAVE_FNO_COMMON)
if (HAVE_FNO_COMMON)
add_compile_options(-fno-common)
endif()
check_c_compiler_flag(-fdiagnostics-color=auto HAS_DIAG_COLOR_FLAG)
if(HAS_DIAG_COLOR_FLAG)
if(CMAKE_GENERATOR MATCHES "Ninja")
add_compile_options(-fdiagnostics-color=always)
else()
add_compile_options(-fdiagnostics-color=auto)
endif()
endif()
option(CI_BUILD "CI, extra flags will be set" OFF)
if(CI_BUILD)
message(STATUS "CI build enabled")
add_compile_options(-Werror)
if(DEFINED ENV{BUILD_32BIT})
# Get some test coverage for unsigned char
add_compile_options(-funsigned-char)
endif()
endif()
option(LOG_LIST_ACTIONS "Add list actions logging" OFF)
add_definitions(-DINCLUDE_GENERATED_DECLARATIONS)
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
set(NO_UNDEFINED "-Wl,--no-undefined -lsocket")
elseif(NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(NO_UNDEFINED "-Wl,--no-undefined")
endif()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${NO_UNDEFINED}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${NO_UNDEFINED}")
# For O_CLOEXEC, O_DIRECTORY, and O_NOFOLLOW flags on older systems
# (pre POSIX.1-2008: glibc 2.11 and earlier). #4042
# For ptsname(). #6743
add_definitions(-D_GNU_SOURCE)
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT PREFER_LUA AND LUAJIT_VERSION LESS "2.1.0-beta3")
# Required for luajit < 2.1.0-beta3.
set(CMAKE_EXE_LINKER_FLAGS
"${CMAKE_EXE_LINKER_FLAGS} -pagezero_size 10000 -image_base 100000000")
set(CMAKE_SHARED_LINKER_FLAGS
"${CMAKE_SHARED_LINKER_FLAGS} -image_base 100000000")
set(CMAKE_MODULE_LINKER_FLAGS
"${CMAKE_MODULE_LINKER_FLAGS} -image_base 100000000")
endif()
include_directories("${PROJECT_BINARY_DIR}/config")
include_directories("${PROJECT_SOURCE_DIR}/src")
find_package(LibUV 1.28.0 REQUIRED)
include_directories(SYSTEM ${LIBUV_INCLUDE_DIRS})
find_package(Msgpack 1.0.0 REQUIRED)
include_directories(SYSTEM ${MSGPACK_INCLUDE_DIRS})
2014-04-10 11:39:34 -07:00
find_package(LibLUV 1.43.0 REQUIRED)
include_directories(SYSTEM ${LIBLUV_INCLUDE_DIRS})
find_package(TreeSitter REQUIRED)
include_directories(SYSTEM ${TreeSitter_INCLUDE_DIRS})
list(APPEND CMAKE_REQUIRED_INCLUDES "${TreeSitter_INCLUDE_DIRS}")
list(APPEND CMAKE_REQUIRED_LIBRARIES "${TreeSitter_LIBRARIES}")
check_c_source_compiles("
#include <tree_sitter/api.h>
int
main(void)
{
TSQueryCursor *cursor = ts_query_cursor_new();
ts_query_cursor_set_match_limit(cursor, 32);
return 0;
}
" TS_HAS_SET_MATCH_LIMIT)
if(TS_HAS_SET_MATCH_LIMIT)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNVIM_TS_HAS_SET_MATCH_LIMIT")
endif()
check_c_source_compiles("
#include <stdlib.h>
#include <tree_sitter/api.h>
int
main(void)
{
ts_set_allocator(malloc, calloc, realloc, free);
return 0;
}
" TS_HAS_SET_ALLOCATOR)
if(TS_HAS_SET_ALLOCATOR)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNVIM_TS_HAS_SET_ALLOCATOR")
endif()
# Note: The test lib requires LuaJIT; it will be skipped if LuaJIT is missing.
option(PREFER_LUA "Prefer Lua over LuaJIT in the nvim executable." OFF)
if(PREFER_LUA)
find_package(Lua 5.1 REQUIRED)
set(LUA_PREFERRED_INCLUDE_DIRS ${LUA_INCLUDE_DIR})
set(LUA_PREFERRED_LIBRARIES ${LUA_LIBRARIES})
# Passive (not REQUIRED): if LUAJIT_FOUND is not set, nvim-test is skipped.
find_package(LuaJit)
else()
find_package(LuaJit REQUIRED)
set(LUA_PREFERRED_INCLUDE_DIRS ${LUAJIT_INCLUDE_DIRS})
set(LUA_PREFERRED_LIBRARIES ${LUAJIT_LIBRARIES})
endif()
list(APPEND CMAKE_REQUIRED_INCLUDES "${MSGPACK_INCLUDE_DIRS}")
check_c_source_compiles("
#include <msgpack.h>
int
main(void)
{
return MSGPACK_OBJECT_FLOAT32;
}
" MSGPACK_HAS_FLOAT32)
list(REMOVE_ITEM CMAKE_REQUIRED_INCLUDES "${MSGPACK_INCLUDE_DIRS}")
if(MSGPACK_HAS_FLOAT32)
add_definitions(-DNVIM_MSGPACK_HAS_FLOAT32)
endif()
option(FEAT_TUI "Enable the Terminal UI" ON)
if(FEAT_TUI)
find_package(UNIBILIUM 2.0 REQUIRED)
include_directories(SYSTEM ${UNIBILIUM_INCLUDE_DIRS})
list(APPEND CMAKE_REQUIRED_INCLUDES "${UNIBILIUM_INCLUDE_DIRS}")
list(APPEND CMAKE_REQUIRED_LIBRARIES "${UNIBILIUM_LIBRARIES}")
check_c_source_compiles("
#include <unibilium.h>
int
main(void)
{
return unibi_num_from_var(unibi_var_from_num(0));
}
" UNIBI_HAS_VAR_FROM)
list(REMOVE_ITEM CMAKE_REQUIRED_INCLUDES "${UNIBILIUM_INCLUDE_DIRS}")
list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES "${UNIBILIUM_LIBRARIES}")
if(UNIBI_HAS_VAR_FROM)
add_definitions(-DNVIM_UNIBI_HAS_VAR_FROM)
endif()
find_package(LibTermkey 0.18 REQUIRED)
include_directories(SYSTEM ${LIBTERMKEY_INCLUDE_DIRS})
endif()
find_package(LIBVTERM 0.1 REQUIRED)
include_directories(SYSTEM ${LIBVTERM_INCLUDE_DIRS})
if(WIN32)
find_package(Winpty 0.4.3 REQUIRED)
include_directories(SYSTEM ${WINPTY_INCLUDE_DIRS})
endif()
option(CLANG_ASAN_UBSAN "Enable Clang address & undefined behavior sanitizer for nvim binary." OFF)
2015-06-08 09:49:23 -07:00
option(CLANG_MSAN "Enable Clang memory sanitizer for nvim binary." OFF)
option(CLANG_TSAN "Enable Clang thread sanitizer for nvim binary." OFF)
if((CLANG_ASAN_UBSAN AND CLANG_MSAN)
OR (CLANG_ASAN_UBSAN AND CLANG_TSAN)
OR (CLANG_MSAN AND CLANG_TSAN))
2018-10-06 09:45:34 -07:00
message(FATAL_ERROR "Sanitizers cannot be enabled simultaneously")
2015-06-08 09:49:23 -07:00
endif()
if((CLANG_ASAN_UBSAN OR CLANG_MSAN OR CLANG_TSAN) AND NOT CMAKE_C_COMPILER_ID MATCHES "Clang")
2018-10-06 09:45:34 -07:00
message(FATAL_ERROR "Sanitizers are only supported for Clang")
endif()
if(ENABLE_LIBICONV)
find_package(Iconv REQUIRED)
include_directories(SYSTEM ${Iconv_INCLUDE_DIRS})
endif()
if(ENABLE_LIBINTL)
# LibIntl (not Intl) selects our FindLibIntl.cmake script. #8464
find_package(LibIntl REQUIRED)
include_directories(SYSTEM ${LibIntl_INCLUDE_DIRS})
endif()
# Determine platform's threading library. Set CMAKE_THREAD_PREFER_PTHREAD
# explicitly to indicate a strong preference for pthread.
set(CMAKE_THREAD_PREFER_PTHREAD ON)
find_package(Threads REQUIRED)
# Place targets in bin/ or lib/ for all build configurations
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
foreach(CFGNAME ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER ${CFGNAME} CFGNAME)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFGNAME} ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFGNAME} ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFGNAME} ${CMAKE_BINARY_DIR}/lib)
endforeach()
# Find Lua interpreter
include(LuaHelpers)
set(LUA_DEPENDENCIES lpeg mpack bit)
if(NOT LUA_PRG)
foreach(CURRENT_LUA_PRG luajit lua5.1 lua5.2 lua)
unset(_CHECK_LUA_PRG CACHE)
unset(LUA_PRG_WORKS)
find_program(_CHECK_LUA_PRG ${CURRENT_LUA_PRG})
if(_CHECK_LUA_PRG)
check_lua_deps(${_CHECK_LUA_PRG} "${LUA_DEPENDENCIES}" LUA_PRG_WORKS)
if(LUA_PRG_WORKS)
set(LUA_PRG "${_CHECK_LUA_PRG}" CACHE FILEPATH "Path to a program.")
break()
endif()
endif()
endforeach()
unset(_CHECK_LUA_PRG CACHE)
else()
check_lua_deps(${LUA_PRG} "${LUA_DEPENDENCIES}" LUA_PRG_WORKS)
endif()
if(NOT LUA_PRG_WORKS)
2018-10-06 09:45:34 -07:00
message(FATAL_ERROR "Failed to find a Lua 5.1-compatible interpreter")
endif()
2018-10-06 09:45:34 -07:00
message(STATUS "Using Lua interpreter: ${LUA_PRG}")
if(DEBUG)
option(COMPILE_LUA "Pre-compile Lua sources into bytecode (for sources that are included in the binary)" OFF)
else()
option(COMPILE_LUA "Pre-compile Lua sources into bytecode (for sources that are included in the binary)" ON)
endif()
if(COMPILE_LUA AND NOT WIN32)
if(PREFER_LUA)
foreach(CURRENT_LUAC_PRG luac5.1 luac)
find_program(_CHECK_LUAC_PRG ${CURRENT_LUAC_PRG})
if(_CHECK_LUAC_PRG)
set(LUAC_PRG "${_CHECK_LUAC_PRG} -s -o - %s" CACHE STRING "Format for compiling to Lua bytecode")
break()
endif()
endforeach()
elseif(LUA_PRG MATCHES "luajit")
check_lua_module(${LUA_PRG} "jit.bcsave" LUAJIT_HAS_JIT_BCSAVE)
if(LUAJIT_HAS_JIT_BCSAVE)
set(LUAC_PRG "${LUA_PRG} -b -s %s -" CACHE STRING "Format for compiling to Lua bytecode")
endif()
endif()
endif()
if(LUAC_PRG)
message(STATUS "Using Lua compiler: ${LUAC_PRG}")
endif()
# Setup busted.
find_program(BUSTED_PRG NAMES busted busted.bat)
find_program(BUSTED_LUA_PRG busted-lua)
if(NOT BUSTED_OUTPUT_TYPE)
set(BUSTED_OUTPUT_TYPE "nvim")
endif()
find_program(LUACHECK_PRG luacheck)
find_program(FLAKE8_PRG flake8)
find_program(GPERF_PRG gperf)
include(InstallHelpers)
file(GLOB MANPAGES
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
Remove outdated and unused manuals #2891 `nvim-[lang].1`: The non-english manuals are completely outdated and still written in roff, as opposed to mdoc, which is used for `nvim.1`. Given that, they're nearly useless at the moment, and when/if they are updated, they should probably be rewritten from scratch using `nvim.1` as a reference. `xxd*.1`: xxd hasn't been in the source tree for a long time, so the manual is of little use. `nvimtutor*.1`: The vimtutor script hasn't ever shipped with nvim, and the consensus seems to be that it won't, at least in the form of an executable installed alongside `$(PREFIX)/bin/nvim` (see #2700). In `nvim.1`, the argument to the `.Os` macro was removed. This was done because its only purpose was to signify that nvim and nvimtutor were part of the "Neovim" distribution, i.e., one and the same, which isn't applicable anymore because `nvimtutor.1` is being removed. From the `.Os` documentation in `man mdoc`: Os Operating system version for display in the page footer. This is the mandatory third macro of any mdoc file. Its syntax is as follows: .Os [system [version]] The optional system parameter specifies the relevant operating system or environment. It is suggested to leave it unspecified, in which case mandoc(1) uses its -Ios argument or, if that isn't specified either, sysname and release as returned by uname(3). Examples: .Os .Os KTH/CSC/TCS .Os BSD 4.3 See also Dd and Dt. Reviewed-by: Felipe Morales <hel.sheep@gmail.com> Reviewed-by: Florian Walch <florian@fwalch.com> Reviewed-by: Justin M. Keyes <justinkz@gmail.com> [ci skip]
2015-06-24 11:12:51 -07:00
man/nvim.1)
install_helper(
FILES ${MANPAGES}
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
#
# Go down the tree.
#
add_subdirectory(src/nvim)
get_directory_property(NVIM_VERSION_CFLAGS DIRECTORY src/nvim DEFINITION NVIM_VERSION_CFLAGS)
add_subdirectory(test/includes)
2014-11-09 05:52:15 -07:00
add_subdirectory(config)
add_subdirectory(test/functional/fixtures) # compile test programs
add_subdirectory(runtime)
get_directory_property(GENERATED_HELP_TAGS DIRECTORY runtime DEFINITION GENERATED_HELP_TAGS)
if(WIN32)
install_helper(
FILES ${DEPS_PREFIX}/share/nvim-qt/runtime/plugin/nvim_gui_shim.vim
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nvim-qt/runtime/plugin)
endif()
# Setup some test-related bits. We do this after going down the tree because we
# need some of the targets.
if(BUSTED_PRG)
get_property(TEST_INCLUDE_DIRS DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
PROPERTY INCLUDE_DIRECTORIES)
2016-05-16 03:49:32 -07:00
# When running tests from 'ninja' we need to use the
# console pool: to do so we need to use the USES_TERMINAL
# option, but this is only available in CMake 3.2
set(TEST_TARGET_ARGS)
list(APPEND TEST_TARGET_ARGS "USES_TERMINAL")
2016-05-16 03:49:32 -07:00
set(UNITTEST_PREREQS nvim-test unittest-headers)
set(FUNCTIONALTEST_PREREQS nvim printenv-test printargs-test shell-test streams-test tty-test ${GENERATED_HELP_TAGS})
set(BENCHMARK_PREREQS nvim tty-test)
# Useful for automated build systems, if they want to manually run the tests.
add_custom_target(unittest-prereqs
DEPENDS ${UNITTEST_PREREQS})
set_target_properties(unittest-prereqs PROPERTIES FOLDER test)
add_custom_target(functionaltest-prereqs
DEPENDS ${FUNCTIONALTEST_PREREQS})
add_custom_target(benchmark-prereqs
DEPENDS ${BENCHMARK_PREREQS})
check_lua_module(${LUA_PRG} "ffi" LUA_HAS_FFI)
if(LUA_HAS_FFI)
add_custom_target(unittest
COMMAND ${CMAKE_COMMAND}
-DBUSTED_PRG=${BUSTED_PRG}
-DLUA_PRG=${LUA_PRG}
-DWORKING_DIR=${CMAKE_CURRENT_SOURCE_DIR}
-DBUSTED_OUTPUT_TYPE=${BUSTED_OUTPUT_TYPE}
-DTEST_DIR=${CMAKE_CURRENT_SOURCE_DIR}/test
-DBUILD_DIR=${CMAKE_BINARY_DIR}
-DTEST_TYPE=unit
-P ${PROJECT_SOURCE_DIR}/cmake/RunTests.cmake
DEPENDS ${UNITTEST_PREREQS}
${TEST_TARGET_ARGS})
set_target_properties(unittest PROPERTIES FOLDER test)
else()
message(WARNING "disabling unit tests: no Luajit FFI in ${LUA_PRG}")
endif()
if(LUA_HAS_FFI)
set(TEST_LIBNVIM_PATH $<TARGET_FILE:nvim-test>)
else()
set(TEST_LIBNVIM_PATH "")
endif()
configure_file(
${CMAKE_SOURCE_DIR}/test/config/paths.lua.in
${CMAKE_BINARY_DIR}/test/config/paths.lua.gen)
file(GENERATE
OUTPUT ${CMAKE_BINARY_DIR}/test/config/paths.lua
INPUT ${CMAKE_BINARY_DIR}/test/config/paths.lua.gen)
add_custom_target(functionaltest
COMMAND ${CMAKE_COMMAND}
-DBUSTED_PRG=${BUSTED_PRG}
-DLUA_PRG=${LUA_PRG}
-DNVIM_PRG=$<TARGET_FILE:nvim>
-DWORKING_DIR=${CMAKE_CURRENT_SOURCE_DIR}
-DBUSTED_OUTPUT_TYPE=${BUSTED_OUTPUT_TYPE}
-DTEST_DIR=${CMAKE_CURRENT_SOURCE_DIR}/test
-DBUILD_DIR=${CMAKE_BINARY_DIR}
-DTEST_TYPE=functional
-P ${PROJECT_SOURCE_DIR}/cmake/RunTests.cmake
2016-05-16 03:49:32 -07:00
DEPENDS ${FUNCTIONALTEST_PREREQS}
${TEST_TARGET_ARGS})
set_target_properties(functionaltest functionaltest-prereqs
PROPERTIES FOLDER test)
add_custom_target(benchmark
COMMAND ${CMAKE_COMMAND}
-DBUSTED_PRG=${BUSTED_PRG}
-DLUA_PRG=${LUA_PRG}
-DNVIM_PRG=$<TARGET_FILE:nvim>
-DWORKING_DIR=${CMAKE_CURRENT_SOURCE_DIR}
-DBUSTED_OUTPUT_TYPE=${BUSTED_OUTPUT_TYPE}
-DTEST_DIR=${CMAKE_CURRENT_SOURCE_DIR}/test
-DBUILD_DIR=${CMAKE_BINARY_DIR}
-DTEST_TYPE=benchmark
-P ${PROJECT_SOURCE_DIR}/cmake/RunTests.cmake
2016-05-16 03:49:32 -07:00
DEPENDS ${BENCHMARK_PREREQS}
${TEST_TARGET_ARGS})
set_target_properties(benchmark benchmark-prereqs PROPERTIES FOLDER test)
endif()
if(BUSTED_LUA_PRG)
add_custom_target(functionaltest-lua
COMMAND ${CMAKE_COMMAND}
-DBUSTED_PRG=${BUSTED_LUA_PRG}
-DLUA_PRG=${LUA_PRG}
-DNVIM_PRG=$<TARGET_FILE:nvim>
-DWORKING_DIR=${CMAKE_CURRENT_SOURCE_DIR}
-DBUSTED_OUTPUT_TYPE=${BUSTED_OUTPUT_TYPE}
-DTEST_DIR=${CMAKE_CURRENT_SOURCE_DIR}/test
-DBUILD_DIR=${CMAKE_BINARY_DIR}
-DTEST_TYPE=functional
-P ${PROJECT_SOURCE_DIR}/cmake/RunTests.cmake
2016-05-16 03:49:32 -07:00
DEPENDS ${FUNCTIONALTEST_PREREQS}
${TEST_TARGET_ARGS})
set_target_properties(functionaltest-lua PROPERTIES FOLDER test)
endif()
if(LUACHECK_PRG)
add_custom_target(lualint
2021-09-19 16:35:38 -07:00
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()
#add uninstall target
if(NOT TARGET uninstall)
configure_file(
"cmake/UninstallHelper.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/UninstallHelper.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/UninstallHelper.cmake)
endif()
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
add_subdirectory(packaging)
endif()