aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmake.deps/CMakeLists.txt34
-rw-r--r--cmake.deps/cmake/BuildTreesitterParsers.cmake6
-rw-r--r--cmake.deps/cmake/GetBinaryDeps.cmake32
-rw-r--r--runtime/doc/api.txt25
-rw-r--r--runtime/doc/deprecated.txt1
-rw-r--r--runtime/doc/lsp.txt3
-rw-r--r--runtime/doc/lua.txt11
-rw-r--r--runtime/doc/luvref.txt7
-rw-r--r--runtime/doc/news.txt7
-rw-r--r--runtime/doc/treesitter.txt68
-rw-r--r--runtime/lua/vim/diagnostic.lua12
-rw-r--r--runtime/lua/vim/filetype.lua1
-rw-r--r--runtime/lua/vim/fs.lua45
-rw-r--r--runtime/lua/vim/loader.lua197
-rw-r--r--runtime/lua/vim/lsp/diagnostic.lua54
-rw-r--r--runtime/lua/vim/lsp/protocol.lua2
-rw-r--r--runtime/lua/vim/lsp/types.lua17
-rw-r--r--runtime/lua/vim/shared.lua8
-rw-r--r--runtime/lua/vim/treesitter.lua33
-rw-r--r--runtime/lua/vim/treesitter/health.lua2
-rw-r--r--runtime/lua/vim/treesitter/language.lua61
-rw-r--r--runtime/lua/vim/treesitter/languagetree.lua7
-rw-r--r--runtime/queries/c/highlights.scm115
-rw-r--r--runtime/queries/c/injections.scm4
-rw-r--r--runtime/queries/lua/highlights.scm43
-rw-r--r--runtime/queries/lua/injections.scm12
-rw-r--r--runtime/queries/vim/highlights.scm2
-rw-r--r--runtime/queries/vimdoc/highlights.scm (renamed from runtime/queries/help/highlights.scm)0
-rw-r--r--runtime/queries/vimdoc/injections.scm (renamed from runtime/queries/help/injections.scm)0
-rw-r--r--scripts/gen_help_html.lua6
-rwxr-xr-xsrc/nvim/CMakeLists.txt7
-rw-r--r--src/nvim/api/deprecated.c14
-rw-r--r--src/nvim/api/options.c47
-rw-r--r--src/nvim/api/vim.c7
-rw-r--r--src/nvim/autocmd.c29
-rw-r--r--src/nvim/channel.c2
-rw-r--r--src/nvim/charset.c34
-rw-r--r--src/nvim/charset.h2
-rw-r--r--src/nvim/drawline.c2
-rw-r--r--src/nvim/drawscreen.c6
-rw-r--r--src/nvim/edit.c8
-rw-r--r--src/nvim/eval.c6
-rw-r--r--src/nvim/eval/funcs.c8
-rw-r--r--src/nvim/eval/typval_defs.h2
-rw-r--r--src/nvim/eval/userfunc.c6
-rw-r--r--src/nvim/ex_cmds.c4
-rw-r--r--src/nvim/ex_cmds2.c2
-rw-r--r--src/nvim/ex_getln.c2
-rw-r--r--src/nvim/ex_session.c2
-rw-r--r--src/nvim/file_search.c2
-rw-r--r--src/nvim/generators/gen_ex_cmds.lua2
-rw-r--r--src/nvim/generators/gen_options.lua2
-rw-r--r--src/nvim/globals.h60
-rw-r--r--src/nvim/grid.c4
-rw-r--r--src/nvim/highlight_group.c28
-rw-r--r--src/nvim/keycodes.c40
-rw-r--r--src/nvim/lua/executor.c2
-rw-r--r--src/nvim/lua/stdlib.c2
-rw-r--r--src/nvim/main.c2
-rw-r--r--src/nvim/mapping.c10
-rw-r--r--src/nvim/match.c7
-rw-r--r--src/nvim/mbyte.c20
-rw-r--r--src/nvim/memline.c4
-rw-r--r--src/nvim/message.c65
-rw-r--r--src/nvim/move.c2
-rw-r--r--src/nvim/ops.c2
-rw-r--r--src/nvim/option.c389
-rw-r--r--src/nvim/option_defs.h4
-rw-r--r--src/nvim/optionstr.c35
-rw-r--r--src/nvim/os/env.c2
-rw-r--r--src/nvim/regexp.c14
-rw-r--r--src/nvim/runtime.c27
-rw-r--r--src/nvim/search.c4
-rw-r--r--src/nvim/spell.c6
-rw-r--r--src/nvim/spell_defs.h2
-rw-r--r--src/nvim/spellfile.c120
-rw-r--r--src/nvim/spellsuggest.c10
-rw-r--r--src/nvim/state.c2
-rw-r--r--src/nvim/tag.c2
-rw-r--r--src/nvim/types.h4
-rw-r--r--test/functional/api/highlight_spec.lua14
-rw-r--r--test/functional/api/vim_spec.lua93
-rw-r--r--test/functional/lua/diagnostic_spec.lua2
-rw-r--r--test/functional/lua/ffi_spec.lua1
-rw-r--r--test/functional/lua/vim_spec.lua9
-rw-r--r--test/functional/plugin/lsp/diagnostic_spec.lua4
-rw-r--r--test/functional/treesitter/highlight_spec.lua28
-rw-r--r--test/functional/treesitter/parser_spec.lua32
-rw-r--r--test/old/testdir/test_filetype.vim1
-rw-r--r--test/old/testdir/test_packadd.vim7
-rw-r--r--test/symbolic/klee/nvim/charset.c172
-rw-r--r--test/symbolic/klee/nvim/garray.c195
-rw-r--r--test/symbolic/klee/nvim/gettext.c4
-rw-r--r--test/symbolic/klee/nvim/keymap.c559
-rw-r--r--test/symbolic/klee/nvim/mbyte.c266
-rw-r--r--test/symbolic/klee/nvim/memory.c101
-rwxr-xr-xtest/symbolic/klee/run.sh101
-rw-r--r--test/symbolic/klee/viml_expressions_lexer.c105
-rw-r--r--test/symbolic/klee/viml_expressions_parser.c117
-rw-r--r--test/unit/eval/helpers.lua2
-rw-r--r--test/unit/message_spec.lua4
-rw-r--r--test/unit/undo_spec.lua2
102 files changed, 1230 insertions, 2469 deletions
diff --git a/cmake.deps/CMakeLists.txt b/cmake.deps/CMakeLists.txt
index 665503aded..4659183d19 100644
--- a/cmake.deps/CMakeLists.txt
+++ b/cmake.deps/CMakeLists.txt
@@ -151,21 +151,27 @@ set(LUAROCKS_SHA256 a0b36cd68586cd79966d0106bb2e5a4f5523327867995fd66bee4237062b
set(UNIBILIUM_URL https://github.com/neovim/unibilium/archive/d72c3598e7ac5d1ebf86ee268b8b4ed95c0fa628.tar.gz)
set(UNIBILIUM_SHA256 9c4747c862ab5e3076dcf8fa8f0ea7a6b50f20ec5905618b9536655596797487)
-set(LIBTERMKEY_URL https://www.leonerd.org.uk/code/libtermkey/libtermkey-0.22.tar.gz)
+set(LIBTERMKEY_URL https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/libtermkey/0.22-1/libtermkey_0.22.orig.tar.gz)
set(LIBTERMKEY_SHA256 6945bd3c4aaa83da83d80a045c5563da4edd7d0374c62c0d35aec09eb3014600)
-set(LIBVTERM_URL https://www.leonerd.org.uk/code/libvterm/libvterm-0.3.1.tar.gz)
+set(LIBVTERM_URL https://launchpad.net/libvterm/trunk/v0.3/+download/libvterm-0.3.1.tar.gz)
set(LIBVTERM_SHA256 25a8ad9c15485368dfd0a8a9dca1aec8fea5c27da3fa74ec518d5d3787f0c397)
-set(LUV_URL https://github.com/luvit/luv/archive/e5da6417db06a09d75bb5315662a2cf3e48a4a89.tar.gz)
-set(LUV_SHA256 16720d17b9e6d42a7008b902207ea2d61e3eeaef3cf358398dbbf3777867ec09)
+set(LUV_URL https://github.com/luvit/luv/archive/093a977b82077591baefe1e880d37dfa2730bd54.tar.gz)
+set(LUV_SHA256 222b38b6425f0926218e14e7da81481fdde6f9660c1feac25a53e6fb52e886e6)
set(LUA_COMPAT53_URL https://github.com/keplerproject/lua-compat-5.3/archive/v0.9.tar.gz)
set(LUA_COMPAT53_SHA256 ad05540d2d96a48725bb79a1def35cf6652a4e2ec26376e2617c8ce2baa6f416)
-# cat.exe curl.exe curl-ca-bundle.crt diff.exe tee.exe xxd.exe
-set(WINTOOLS_URL https://github.com/neovim/deps/raw/c1e7dd8de9e1b18d11dcfa0a192cd029262e5303/opt/win32tools.zip)
-set(WINTOOLS_SHA256 3c4c490a3d392ceeb1347cb77cc821a31900b688a2189276d3a1131a3f21daf1)
+# Windows only: cat.exe diff.exe tee.exe xxd.exe
+set(CAT_URL https://github.com/neovim/deps/raw/21c5e8bdda33521a6ed497b315e03265a2785cbc/opt/cat.exe)
+set(CAT_SHA256 93b8d307bb15af3968920bdea3beb869a49d166f9164853c58a4e6ffdcae61c6)
+set(DIFF_URL https://github.com/neovim/deps/raw/21c5e8bdda33521a6ed497b315e03265a2785cbc/opt/diff.exe)
+set(DIFF_SHA256 4ceceebc8150422c6d8d9a06c2e9686d5a5d90f1033f60ad92ab81fe810e2a28)
+set(TEE_URL https://github.com/neovim/deps/raw/21c5e8bdda33521a6ed497b315e03265a2785cbc/opt/tee.exe)
+set(TEE_SHA256 950eea4e17fa3a7e89fa2c55374037b5797b3f1a54fea1304634884ab42ec14d)
+set(XXD_URL https://github.com/neovim/deps/raw/21c5e8bdda33521a6ed497b315e03265a2785cbc/opt/xxd.exe)
+set(XXD_SHA256 7a581e3882d28161cc52850f9a11d634b3eaf2c029276f093c1ed4c90e45a10c)
set(WINGUI_URL https://github.com/equalsraf/neovim-qt/releases/download/v0.2.17/neovim-qt.zip)
set(WINGUI_SHA256 502e386eef677c2c2e0c11d8cbb27f3e12b4d96818369417e8da4129c4580c25)
@@ -185,11 +191,11 @@ set(TREESITTER_C_SHA256 af66fde03feb0df4faf03750102a0d265b007e5d957057b6b293c131
set(TREESITTER_LUA_URL https://github.com/MunifTanjim/tree-sitter-lua/archive/v0.0.14.tar.gz)
set(TREESITTER_LUA_SHA256 930d0370dc15b66389869355c8e14305b9ba7aafd36edbfdb468c8023395016d)
-set(TREESITTER_VIM_URL https://github.com/vigoux/tree-sitter-viml/archive/55ff1b080c09edeced9b748cf4c16d0b49d17fb9.tar.gz)
-set(TREESITTER_VIM_SHA256 1b1cd39e33c8fb02fa7fe3977e844883c2a8508a7edd621f2d21e39a9aeefa92)
+set(TREESITTER_VIM_URL https://github.com/vigoux/tree-sitter-viml/archive/e39a7bbcfdcfc7900629962b785c7e14503ae590.tar.gz)
+set(TREESITTER_VIM_SHA256 7ca85fa1a5a9e4d057ff3b7ae53d13d31371973e734ada87a83f3f6cbe9c0e32)
-set(TREESITTER_HELP_URL https://github.com/neovim/tree-sitter-vimdoc/archive/v1.3.0.tar.gz)
-set(TREESITTER_HELP_SHA256 f33f6d49c7d71feb2fd68ef2b2684da150f9f8e486ad9726213631d673942331)
+set(TREESITTER_VIMDOC_URL https://github.com/neovim/tree-sitter-vimdoc/archive/b2ec4ec5f7be24cb6f7ccffafd7204477fe5784a.tar.gz)
+set(TREESITTER_VIMDOC_SHA256 0689a57d455243de6c6a6c8737a8ce137e225eb8f32676a7037f7dd13dfaec5d)
set(TREESITTER_QUERY_URL https://github.com/nvim-treesitter/tree-sitter-query/archive/v0.1.0.tar.gz)
set(TREESITTER_QUERY_SHA256 e2b806f80e8bf1c4f4e5a96248393fe6622fc1fc6189d6896d269658f67f914c)
@@ -264,8 +270,10 @@ endif()
if(WIN32)
include(GetBinaryDeps)
- GetBinaryDep(TARGET wintools
- INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory . ${DEPS_BIN_DIR})
+ GetExecutable(TARGET cat)
+ GetExecutable(TARGET diff)
+ GetExecutable(TARGET tee)
+ GetExecutable(TARGET xxd)
if(USE_BUNDLED_NVIMQT)
GetBinaryDep(TARGET wingui
diff --git a/cmake.deps/cmake/BuildTreesitterParsers.cmake b/cmake.deps/cmake/BuildTreesitterParsers.cmake
index 1202e4f7a4..ef7d521249 100644
--- a/cmake.deps/cmake/BuildTreesitterParsers.cmake
+++ b/cmake.deps/cmake/BuildTreesitterParsers.cmake
@@ -38,9 +38,9 @@ BuildTSParser(
CMAKE_FILE TreesitterParserCMakeLists.txt)
BuildTSParser(
- LANG help
- URL ${TREESITTER_HELP_URL}
- SHA256 ${TREESITTER_HELP_SHA256}
+ LANG vimdoc
+ URL ${TREESITTER_VIMDOC_URL}
+ SHA256 ${TREESITTER_VIMDOC_SHA256}
CMAKE_FILE TreesitterParserCMakeLists.txt)
BuildTSParser(
diff --git a/cmake.deps/cmake/GetBinaryDeps.cmake b/cmake.deps/cmake/GetBinaryDeps.cmake
index bac7dff919..48e66363d3 100644
--- a/cmake.deps/cmake/GetBinaryDeps.cmake
+++ b/cmake.deps/cmake/GetBinaryDeps.cmake
@@ -10,17 +10,10 @@ function(GetBinaryDep)
"INSTALL_COMMAND"
${ARGN})
- if(NOT _gettool_TARGET OR NOT _gettool_INSTALL_COMMAND)
- message(FATAL_ERROR "Must pass INSTALL_COMMAND and TARGET")
- endif()
-
string(TOUPPER "${_gettool_TARGET}_URL" URL_VARNAME)
string(TOUPPER "${_gettool_TARGET}_SHA256" HASH_VARNAME)
set(URL ${${URL_VARNAME}})
set(HASH ${${HASH_VARNAME}})
- if(NOT URL OR NOT HASH )
- message(FATAL_ERROR "${URL_VARNAME} and ${HASH_VARNAME} must be set")
- endif()
ExternalProject_Add(${_gettool_TARGET}
URL ${URL}
@@ -33,3 +26,28 @@ function(GetBinaryDep)
INSTALL_COMMAND ${CMAKE_COMMAND} -E make_directory ${DEPS_BIN_DIR}
COMMAND "${_gettool_INSTALL_COMMAND}")
endfunction()
+
+# Download executable and move it to DEPS_BIN_DIR
+function(GetExecutable)
+ cmake_parse_arguments(ARG
+ ""
+ "TARGET"
+ ""
+ ${ARGN})
+
+ string(TOUPPER "${ARG_TARGET}_URL" URL_VARNAME)
+ string(TOUPPER "${ARG_TARGET}_SHA256" HASH_VARNAME)
+ set(URL ${${URL_VARNAME}})
+ set(HASH ${${HASH_VARNAME}})
+
+ ExternalProject_Add(${ARG_TARGET}
+ URL ${URL}
+ URL_HASH SHA256=${HASH}
+ DOWNLOAD_NO_PROGRESS TRUE
+ DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR}
+ DOWNLOAD_NO_EXTRACT TRUE
+ CONFIGURE_COMMAND ""
+ BUILD_COMMAND ""
+ INSTALL_COMMAND ${CMAKE_COMMAND} -E make_directory ${DEPS_BIN_DIR}
+ COMMAND ${CMAKE_COMMAND} -E copy <DOWNLOADED_FILE> ${DEPS_BIN_DIR})
+endfunction()
diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt
index cc887ad024..3c3e66dd57 100644
--- a/runtime/doc/api.txt
+++ b/runtime/doc/api.txt
@@ -941,6 +941,10 @@ nvim_get_hl({ns_id}, {*opts}) *nvim_get_hl()*
map as in |nvim_set_hl()|, or only a single highlight definition map
if requested by name or id.
+ Note:
+ When the `link` attribute is defined in the highlight definition map,
+ other attributes will not be taking effect (see |:hi-link|).
+
nvim_get_hl_id_by_name({name}) *nvim_get_hl_id_by_name()*
Gets a highlight group by name
@@ -1388,6 +1392,10 @@ nvim_set_hl({ns_id}, {name}, {*val}) *nvim_set_hl()*
values of the Normal group. If the Normal group has not been defined,
using these values results in an error.
+ Note:
+ If `link` is used in combination with other attributes; only the
+ `link` will take effect (see |:hi-link|).
+
Parameters: ~
• {ns_id} Namespace id for this highlight |nvim_create_namespace()|.
Use 0 to set a highlight group globally |:highlight|.
@@ -1912,7 +1920,7 @@ nvim_get_all_options_info() *nvim_get_all_options_info()*
Gets the option information for all options.
The dictionary has the full option names as keys and option metadata
- dictionaries as detailed at |nvim_get_option_info()|.
+ dictionaries as detailed at |nvim_get_option_info2()|.
Return: ~
dictionary of all options
@@ -1926,8 +1934,8 @@ nvim_get_option({name}) *nvim_get_option()*
Return: ~
Option value (global)
-nvim_get_option_info({name}) *nvim_get_option_info()*
- Gets the option information for one option
+nvim_get_option_info2({name}, {*opts}) *nvim_get_option_info2()*
+ Gets the option information for one option from arbitrary buffer or window
Resulting dictionary has keys:
• name: Name of the option (like 'filetype')
@@ -1943,8 +1951,19 @@ nvim_get_option_info({name}) *nvim_get_option_info()*
• commalist: List of comma separated values
• flaglist: List of single char flags
+ When {scope} is not provided, the last set information applies to the
+ local value in the current buffer or window if it is available, otherwise
+ the global value information is returned. This behavior can be disabled by
+ explicitly specifying {scope} in the {opts} table.
+
Parameters: ~
• {name} Option name
+ • {opts} Optional parameters
+ • scope: One of "global" or "local". Analogous to |:setglobal|
+ and |:setlocal|, respectively.
+ • win: |window-ID|. Used for getting window local options.
+ • buf: Buffer number. Used for getting buffer local options.
+ Implies {scope} is "local".
Return: ~
Option Information
diff --git a/runtime/doc/deprecated.txt b/runtime/doc/deprecated.txt
index 69cec8da53..3eb2017bed 100644
--- a/runtime/doc/deprecated.txt
+++ b/runtime/doc/deprecated.txt
@@ -20,6 +20,7 @@ API
- *nvim_get_hl_by_name()* Use |nvim_get_hl()| instead.
- *nvim_get_hl_by_id()* Use |nvim_get_hl()| instead.
- *nvim_exec()* Use |nvim_exec2()| instead.
+- *nvim_get_option_info()* Use |nvim_get_option_info2()| instead.
COMMANDS
- *:rv* *:rviminfo* Deprecated alias to |:rshada| command.
diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt
index 0164b34efb..f5695669ae 100644
--- a/runtime/doc/lsp.txt
+++ b/runtime/doc/lsp.txt
@@ -1113,7 +1113,8 @@ code_action({options}) *vim.lsp.buf.code_action()*
• {options} (table|nil) Optional table which holds the following
optional fields:
• context: (table|nil) Corresponds to `CodeActionContext` of the LSP specification:
- • diagnostics (table|nil): LSP`Diagnostic[]` . Inferred from the current position if not provided.
+ • diagnostics (table|nil): LSP `Diagnostic[]`. Inferred
+ from the current position if not provided.
• only (table|nil): List of LSP `CodeActionKind`s used to
filter the code actions. Most language servers support
values like `refactor` or `quickfix`.
diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt
index 58522ac1f3..ebbf8bb463 100644
--- a/runtime/doc/lua.txt
+++ b/runtime/doc/lua.txt
@@ -1635,8 +1635,8 @@ defaulttable({create}) *vim.defaulttable()*
<
Parameters: ~
- • {create} (function|nil) The function called to create a missing
- value.
+ • {create} function?(key:any):any The function called to create a
+ missing value.
Return: ~
(table) Empty table with metamethod
@@ -2065,7 +2065,7 @@ find({modname}, {opts}) *vim.loader.find()*
for `modname="*"`
reset({path}) *vim.loader.reset()*
- Resets the topmods cache for the path, or all the paths if path is nil.
+ Resets the cache for the path, or all the paths if path is nil.
Parameters: ~
• {path} string? path to reset
@@ -2502,7 +2502,7 @@ find({names}, {opts}) *vim.fs.find()*
(table) Normalized paths |vim.fs.normalize()| of all matching files or
directories
-normalize({path}) *vim.fs.normalize()*
+normalize({path}, {opts}) *vim.fs.normalize()*
Normalize a path to a standard format. A tilde (~) character at the
beginning of the path is expanded to the user's home directory and any
backslash (\) characters are converted to forward slashes (/). Environment
@@ -2522,6 +2522,9 @@ normalize({path}) *vim.fs.normalize()*
Parameters: ~
• {path} (string) Path to normalize
+ • {opts} (table|nil) Options:
+ • expand_env: boolean Expand environment variables (default:
+ true)
Return: ~
(string) Normalized path
diff --git a/runtime/doc/luvref.txt b/runtime/doc/luvref.txt
index 0fdd010880..799d0f6f74 100644
--- a/runtime/doc/luvref.txt
+++ b/runtime/doc/luvref.txt
@@ -91,7 +91,7 @@ used here to facilitate documenting consistent behavior:
metamethod
- `buffer`: a `string` or a sequential `table` of `string`s
- `threadargs`: variable arguments (`...`) of type `nil`, `boolean`, `number`,
- `string`, or `userdata`
+ `string`, or `userdata`; number of arguments limited to 9.
==============================================================================
CONTENTS *luv-contents*
@@ -2576,7 +2576,7 @@ uv.fs_poll_start({fs_poll}, {path}, {interval}, {callback}) *uv.fs_poll_start()*
> method form `fs_poll:start(path, interval, callback)`
Parameters:
- - `fs_event`: `uv_fs_event_t userdata`
+ - `fs_poll`: `uv_fs_poll_t userdata`
- `path`: `string`
- `interval`: `integer`
- `callback`: `callable`
@@ -3484,6 +3484,9 @@ uv.new_thread([{options}, ] {entry}, {...}) *uv.new_thread()*
Returns: `luv_thread_t userdata` or `fail`
+ Note: unsafe, please make sure that the thread's end of life
+ is before Lua state is closed.
+
uv.thread_equal({thread}, {other_thread}) *uv.thread_equal()*
> method form `thread:equal(other_thread)`
diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt
index 7efb0ab36f..7b71b53b29 100644
--- a/runtime/doc/news.txt
+++ b/runtime/doc/news.txt
@@ -62,6 +62,10 @@ The following changes may require adaptations in user config or plugins.
• |nvim_exec()| is now deprecated in favor of |nvim_exec2()|.
+• `help` treesitter parser was renamed to `vimdoc`. The only user-visible
+ change is that language-specific highlight groups need to be renamed from
+ `@foo.help` to `@foo.vimdoc`.
+
==============================================================================
NEW FEATURES *news-features*
@@ -231,6 +235,9 @@ The following new APIs or features were added.
• Added |nvim_get_hl()| for getting highlight group definitions in a format compatible with |nvim_set_hl()|.
+• |vim.diagnostic| now supports LSP DiagnosticsTag.
+ See: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#diagnosticTag
+
==============================================================================
CHANGED FEATURES *news-changes*
diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt
index d7e005ae51..0298f5a9b1 100644
--- a/runtime/doc/treesitter.txt
+++ b/runtime/doc/treesitter.txt
@@ -195,7 +195,7 @@ treesitter queries from Lua.
TREESITTER QUERY PREDICATES *treesitter-predicates*
Predicates are special scheme nodes that are evaluated to conditionally capture
-nodes. For example, the `eq?` predicate can be used as follows: >
+nodes. For example, the `eq?` predicate can be used as follows: >query
((identifier) @foo (#eq? @foo "foo"))
<
@@ -204,13 +204,13 @@ to only match identifier corresponding to the `"foo"` text.
The following predicates are built in:
`eq?` *treesitter-predicate-eq?*
- Match a string against the text corresponding to a node: >
+ Match a string against the text corresponding to a node: >query
((identifier) @foo (#eq? @foo "foo"))
((node1) @left (node2) @right (#eq? @left @right))
<
`match?` *treesitter-predicate-match?*
`vim-match?` *treesitter-predicate-vim-match?*
- Match a |regexp| against the text corresponding to a node: >
+ Match a |regexp| against the text corresponding to a node: >query
((identifier) @constant (#match? @constant "^[A-Z_]+$"))
< Note: The `^` and `$` anchors will match the start and end of the
node's text.
@@ -220,13 +220,14 @@ The following predicates are built in:
similar to `match?`
`contains?` *treesitter-predicate-contains?*
- Match a string against parts of the text corresponding to a node: >
+ Match a string against parts of the text corresponding to a node:
+ >query
((identifier) @foo (#contains? @foo "foo"))
((identifier) @foo-bar (#contains? @foo-bar "foo" "bar"))
<
`any-of?` *treesitter-predicate-any-of?*
Match any of the given strings against the text corresponding to
- a node: >
+ a node: >query
((identifier) @foo (#any-of? @foo "foo" "bar"))
<
This is the recommended way to check if the node matches one of many
@@ -243,7 +244,7 @@ Use |vim.treesitter.query.list_predicates()| to list all available predicates.
TREESITTER QUERY DIRECTIVES *treesitter-directives*
Treesitter directives store metadata for a node or match and perform side
-effects. For example, the `set!` directive sets metadata on the match or node: >
+effects. For example, the `set!` directive sets metadata on the match or node: >query
((identifier) @foo (#set! "type" "parameter"))
<
@@ -259,7 +260,7 @@ The following directives are built in:
{key}
{value}
- Examples: >
+ Examples: >query
((identifier) @foo (#set! @foo "kind" "parameter"))
((node1) @left (node2) @right (#set! "type" "pair"))
<
@@ -275,7 +276,7 @@ The following directives are built in:
{end_row}
{end_col}
- Example: >
+ Example: >query
((identifier) @constant (#offset! @constant 0 1 0 -1))
<
@@ -304,7 +305,8 @@ currently supported modeline alternatives:
a base depends on your 'runtimepath' value.
Note: These modeline comments must be at the top of the query, but can be
-repeated, for example, the following two modeline blocks are both valid: >
+repeated, for example, the following two modeline blocks are both valid:
+>query
;; inherits: foo,bar
;; extends
@@ -318,13 +320,13 @@ TREESITTER SYNTAX HIGHLIGHTING *treesitter-highlight*
Syntax highlighting is specified through queries named `highlights.scm`,
which match a |TSNode| in the parsed |TSTree| to a `capture` that can be
-assigned a highlight group. For example, the query >
+assigned a highlight group. For example, the query >query
(parameters (identifier) @parameter)
<
matches any `identifier` node inside a function `parameter` node (e.g., the
`bar` in `foo(bar)`) to the capture named `@parameter`. It is also possible to
-match literal expressions (provided the parser returns them): >
+match literal expressions (provided the parser returns them): >query
"return" @keyword.return
<
@@ -409,7 +411,7 @@ The following captures are linked by default to standard |group-name|s:
*treesitter-highlight-spell*
The special `@spell` capture can be used to indicate that a node should be
spell checked by Nvim's builtin |spell| checker. For example, the following
-capture marks comments as to be checked: >
+capture marks comments as to be checked: >query
(comment) @spell
<
@@ -420,14 +422,14 @@ There is also `@nospell` which disables spellchecking regions with `@spell`.
Treesitter highlighting supports |conceal| via the `conceal` metadata. By
convention, nodes to be concealed are captured as `@conceal`, but any capture
can be used. For example, the following query can be used to hide code block
-delimiters in Markdown: >
+delimiters in Markdown: >query
- (fenced_code_block_delimiter) @conceal (#set! conceal "")
+ (fenced_code_block_delimiter @conceal (#set! conceal ""))
<
It is also possible to replace a node with a single character, which (unlike
legacy syntax) can be given a custom highlight. For example, the following
(ill-advised) query replaces the `!=` operator by a Unicode glyph, which is
-still highlighted the same as other operators: >
+still highlighted the same as other operators: >query
"!=" @operator (#set! conceal "≠")
<
@@ -438,9 +440,10 @@ Treesitter uses |nvim_buf_set_extmark()| to set highlights with a default
priority of 100. This enables plugins to set a highlighting priority lower or
higher than tree-sitter. It is also possible to change the priority of an
individual query pattern manually by setting its `"priority"` metadata
-attribute: >
+attribute: >query
- (super_important_node) @ImportantHighlight (#set! "priority" 105)
+ ((super_important_node) @superimportant (#set! "priority" 105))
+<
==============================================================================
TREESITTER LANGUAGE INJECTIONS *treesitter-language-injections*
@@ -592,8 +595,7 @@ get_node_text({node}, {source}, {opts})
(string)
get_parser({bufnr}, {lang}, {opts}) *vim.treesitter.get_parser()*
- Returns the parser for a specific buffer and filetype and attaches it to
- the buffer
+ Returns the parser for a specific buffer and attaches it to the buffer
If needed, this will create the parser.
@@ -728,29 +730,35 @@ stop({bufnr}) *vim.treesitter.stop()*
Lua module: vim.treesitter.language *lua-treesitter-language*
add({lang}, {opts}) *vim.treesitter.language.add()*
- Asserts that a parser for the language {lang} is installed.
+ Load parser with name {lang}
Parsers are searched in the `parser` runtime directory, or the provided
{path}
Parameters: ~
- • {lang} (string) Language the parser should parse (alphanumerical and
- `_` only)
+ • {lang} (string) Name of the parser (alphanumerical and `_` only)
• {opts} (table|nil) Options:
- • filetype (string|string[]) Filetype(s) that lang can be
- parsed with. Note this is not strictly the same as lang
- since a single lang can parse multiple filetypes. Defaults
- to lang.
+ • filetype (string|string[]) Default filetype the parser
+ should be associated with. Defaults to {lang}.
• path (string|nil) Optional path the parser is located at
• symbol_name (string|nil) Internal symbol name for the
language to load
+get_filetypes({lang}) *vim.treesitter.language.get_filetypes()*
+ Get the filetypes associated with the parser named {lang}.
+
+ Parameters: ~
+ • {lang} string Name of parser
+
+ Return: ~
+ string[] filetypes
+
get_lang({filetype}) *vim.treesitter.language.get_lang()*
Parameters: ~
- • {filetype} (string)
+ • {filetype} string
Return: ~
- (string|nil)
+ string|nil
inspect({lang}) *vim.treesitter.language.inspect()*
Inspects the provided language.
@@ -765,10 +773,10 @@ inspect({lang}) *vim.treesitter.language.inspect()*
(table)
register({lang}, {filetype}) *vim.treesitter.language.register()*
- Register a lang to be used for a filetype (or list of filetypes).
+ Register a parser named {lang} to be used for {filetype}(s).
Parameters: ~
- • {lang} (string) Language to register
+ • {lang} string Name of parser
• {filetype} string|string[] Filetype(s) to associate with lang
diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua
index 56532d0184..714038f8e4 100644
--- a/runtime/lua/vim/diagnostic.lua
+++ b/runtime/lua/vim/diagnostic.lua
@@ -483,6 +483,7 @@ local function next_diagnostic(position, search_forward, bufnr, opts, namespace)
local diagnostics =
get_diagnostics(bufnr, vim.tbl_extend('keep', opts, { namespace = namespace }), true)
local line_diagnostics = diagnostic_lines(diagnostics)
+
for i = 0, line_count do
local offset = i * (search_forward and 1 or -1)
local lnum = position[1] + offset
@@ -752,6 +753,7 @@ end
---@field message string
---@field source nil|string
---@field code nil|string
+---@field _tags { deprecated: boolean, unnecessary: boolean}
---@field user_data nil|any arbitrary data plugins can add
--- Get current diagnostics.
@@ -948,6 +950,16 @@ M.handlers.underline = {
higroup = underline_highlight_map.Error
end
+ if diagnostic._tags then
+ -- TODO(lewis6991): we should be able to stack these.
+ if diagnostic._tags.unnecessary then
+ higroup = 'DiagnosticUnnecessary'
+ end
+ if diagnostic._tags.deprecated then
+ higroup = 'DiagnosticDeprecated'
+ end
+ end
+
vim.highlight.range(
bufnr,
underline_ns,
diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua
index 740304df15..87439f9f0c 100644
--- a/runtime/lua/vim/filetype.lua
+++ b/runtime/lua/vim/filetype.lua
@@ -615,6 +615,7 @@ local extension = {
asd = 'lisp',
lt = 'lite',
lite = 'lite',
+ livemd = 'livebook',
lgt = 'logtalk',
lotos = 'lotos',
lot = 'lotos',
diff --git a/runtime/lua/vim/fs.lua b/runtime/lua/vim/fs.lua
index 2c3fc64d57..407b334f20 100644
--- a/runtime/lua/vim/fs.lua
+++ b/runtime/lua/vim/fs.lua
@@ -77,6 +77,8 @@ local function join_paths(...)
return (table.concat({ ... }, '/'):gsub('//+', '/'))
end
+---@alias Iterator fun(): string?, string?
+
--- Return an iterator over the files and directories located in {path}
---
---@param path (string) An absolute or relative path to the directory to iterate
@@ -100,10 +102,13 @@ function M.dir(path, opts)
})
if not opts.depth or opts.depth == 1 then
- return function(fs)
+ local fs = vim.loop.fs_scandir(M.normalize(path))
+ return function()
+ if not fs then
+ return
+ end
return vim.loop.fs_scandir_next(fs)
- end,
- vim.loop.fs_scandir(M.normalize(path))
+ end
end
--- @async
@@ -316,16 +321,32 @@ end
--- </pre>
---
---@param path (string) Path to normalize
+---@param opts table|nil Options:
+--- - expand_env: boolean Expand environment variables (default: true)
---@return (string) Normalized path
-function M.normalize(path)
- vim.validate({ path = { path, 's' } })
- return (
- path
- :gsub('^~$', vim.loop.os_homedir())
- :gsub('^~/', vim.loop.os_homedir() .. '/')
- :gsub('%$([%w_]+)', vim.loop.os_getenv)
- :gsub('\\', '/')
- )
+function M.normalize(path, opts)
+ opts = opts or {}
+
+ vim.validate({
+ path = { path, { 'string' } },
+ expand_env = { opts.expand_env, { 'boolean' }, true },
+ })
+
+ if path:sub(1, 1) == '~' then
+ local home = vim.loop.os_homedir() or '~'
+ if home:sub(-1) == '\\' or home:sub(-1) == '/' then
+ home = home:sub(1, -2)
+ end
+ path = home .. path:sub(2)
+ end
+
+ if opts.expand_env == nil or opts.expand_env then
+ path = path:gsub('%$([%w_]+)', vim.loop.os_getenv)
+ end
+
+ path = path:gsub('\\', '/'):gsub('/+', '/')
+
+ return path:sub(-1) == '/' and path:sub(1, -2) or path
end
return M
diff --git a/runtime/lua/vim/loader.lua b/runtime/lua/vim/loader.lua
index 41d5579664..201de18497 100644
--- a/runtime/lua/vim/loader.lua
+++ b/runtime/lua/vim/loader.lua
@@ -1,8 +1,11 @@
local uv = vim.loop
+--- @type (fun(modename: string): fun()|string)[]
+local loaders = package.loaders
+
local M = {}
----@alias CacheHash {mtime: {sec:number, nsec:number}, size:number}
+---@alias CacheHash {mtime: {sec:number, nsec:number}, size:number, type: string}
---@alias CacheEntry {hash:CacheHash, chunk:string}
---@class ModuleFindOpts
@@ -29,6 +32,8 @@ local Loader = {
VERSION = 3,
---@type table<string, table<string,ModuleInfo>>
_indexed = {},
+ ---@type table<string, CacheHash>
+ _hashes = {},
---@type table<string, string[]>
_topmods = {},
_loadfile = loadfile,
@@ -38,27 +43,21 @@ local Loader = {
},
}
---- Tracks the time spent in a function
----@private
-function Loader.track(stat, start)
- Loader._stats[stat] = Loader._stats[stat] or { total = 0, time = 0 }
- Loader._stats[stat].total = Loader._stats[stat].total + 1
- Loader._stats[stat].time = Loader._stats[stat].time + uv.hrtime() - start
+--- @param path string
+--- @return uv.fs_stat.result
+--- @private
+function Loader.get_hash(path)
+ if not Loader._hashes[path] then
+ -- Note we must never save a stat for a non-existent path.
+ -- For non-existent paths fs_stat() will return nil.
+ Loader._hashes[path] = uv.fs_stat(path)
+ end
+ return Loader._hashes[path]
end
---- slightly faster/different version than vim.fs.normalize
---- we also need to have it here, since the loader will load vim.fs
---@private
-function Loader.normalize(path)
- if path:sub(1, 1) == '~' then
- local home = vim.loop.os_homedir() or '~'
- if home:sub(-1) == '\\' or home:sub(-1) == '/' then
- home = home:sub(1, -2)
- end
- path = home .. path:sub(2)
- end
- path = path:gsub('\\', '/'):gsub('/+', '/')
- return path:sub(-1) == '/' and path:sub(1, -2) or path
+local function normalize(path)
+ return vim.fs.normalize(path, { expand_env = false })
end
--- Gets the rtp excluding after directories.
@@ -67,9 +66,7 @@ end
--- @return string[] rtp, boolean updated
---@private
function Loader.get_rtp()
- local start = uv.hrtime()
if vim.in_fast_event() then
- Loader.track('get_rtp', start)
return (Loader._rtp or {}), false
end
local updated = false
@@ -77,7 +74,7 @@ function Loader.get_rtp()
if key ~= Loader._rtp_key then
Loader._rtp = {}
for _, path in ipairs(vim.api.nvim_get_runtime_file('', true)) do
- path = Loader.normalize(path)
+ path = normalize(path)
-- skip after directories
if
path:sub(-6, -1) ~= '/after'
@@ -89,7 +86,6 @@ function Loader.get_rtp()
updated = true
Loader._rtp_key = key
end
- Loader.track('get_rtp', start)
return Loader._rtp, updated
end
@@ -120,19 +116,28 @@ function Loader.write(name, entry)
uv.fs_close(f)
end
+--- @param path string
+--- @param mode integer
+--- @return string? data
+--- @private
+local function readfile(path, mode)
+ local f = uv.fs_open(path, 'r', mode)
+ if f then
+ local hash = assert(uv.fs_fstat(f))
+ local data = uv.fs_read(f, hash.size, 0) --[[@as string?]]
+ uv.fs_close(f)
+ return data
+ end
+end
+
--- Loads the cache entry for a given module or file
---@param name string module name or filename
---@return CacheEntry?
---@private
function Loader.read(name)
- local start = uv.hrtime()
local cname = Loader.cache_file(name)
- local f = uv.fs_open(cname, 'r', 438)
- if f then
- local hash = uv.fs_fstat(f) --[[@as CacheHash]]
- local data = uv.fs_read(f, hash.size, 0) --[[@as string]]
- uv.fs_close(f)
-
+ local data = readfile(cname, 438)
+ if data then
local zero = data:find('\0', 1, true)
if not zero then
return
@@ -143,7 +148,6 @@ function Loader.read(name)
if tonumber(header[1]) ~= Loader.VERSION then
return
end
- Loader.track('read', start)
return {
hash = {
size = tonumber(header[2]),
@@ -152,7 +156,6 @@ function Loader.read(name)
chunk = data:sub(zero + 1),
}
end
- Loader.track('read', start)
end
--- The `package.loaders` loader for lua files using the cache.
@@ -160,14 +163,13 @@ end
---@return string|function
---@private
function Loader.loader(modname)
- local start = uv.hrtime()
local ret = M.find(modname)[1]
if ret then
- local chunk, err = Loader.load(ret.modpath, { hash = ret.stat })
- Loader.track('loader', start)
+ -- Make sure to call the global loadfile so we respect any augmentations done elsewhere.
+ -- E.g. profiling
+ local chunk, err = loadfile(ret.modpath)
return chunk or error(err)
end
- Loader.track('loader', start)
return '\ncache_loader: module ' .. modname .. ' not found'
end
@@ -176,7 +178,6 @@ end
---@return string|function
---@private
function Loader.loader_lib(modname)
- local start = uv.hrtime()
local sysname = uv.os_uname().sysname:lower() or ''
local is_win = sysname:find('win', 1, true) and not sysname:find('darwin', 1, true)
local ret = M.find(modname, { patterns = is_win and { '.dll' } or { '.so' } })[1]
@@ -190,28 +191,23 @@ function Loader.loader_lib(modname)
local dash = modname:find('-', 1, true)
local funcname = dash and modname:sub(dash + 1) or modname
local chunk, err = package.loadlib(ret.modpath, 'luaopen_' .. funcname:gsub('%.', '_'))
- Loader.track('loader_lib', start)
return chunk or error(err)
end
- Loader.track('loader_lib', start)
return '\ncache_loader_lib: module ' .. modname .. ' not found'
end
--- `loadfile` using the cache
+--- Note this has the mode and env arguments which is supported by LuaJIT and is 5.1 compatible.
---@param filename? string
---@param mode? "b"|"t"|"bt"
---@param env? table
----@param hash? CacheHash
---@return function?, string? error_message
---@private
-- luacheck: ignore 312
-function Loader.loadfile(filename, mode, env, hash)
- local start = uv.hrtime()
- filename = Loader.normalize(filename)
- mode = nil -- ignore mode, since we byte-compile the lua source files
- local chunk, err = Loader.load(filename, { mode = mode, env = env, hash = hash })
- Loader.track('loadfile', start)
- return chunk, err
+function Loader.loadfile(filename, mode, env)
+ -- ignore mode, since we byte-compile the lua source files
+ mode = nil
+ return Loader.load(normalize(filename), { mode = mode, env = env })
end
--- Checks whether two cache hashes are the same based on:
@@ -231,26 +227,21 @@ end
--- Loads the given module path using the cache
---@param modpath string
----@param opts? {hash?: CacheHash, mode?: "b"|"t"|"bt", env?:table} (table|nil) Options for loading the module:
---- - hash: (table) the hash of the file to load if it is already known. (defaults to `vim.loop.fs_stat({modpath})`)
+---@param opts? {mode?: "b"|"t"|"bt", env?:table} (table|nil) Options for loading the module:
--- - mode: (string) the mode to load the module with. "b"|"t"|"bt" (defaults to `nil`)
--- - env: (table) the environment to load the module in. (defaults to `nil`)
---@see |luaL_loadfile()|
---@return function?, string? error_message
---@private
function Loader.load(modpath, opts)
- local start = uv.hrtime()
-
opts = opts or {}
- local hash = opts.hash or uv.fs_stat(modpath)
+ local hash = Loader.get_hash(modpath)
---@type function?, string?
local chunk, err
if not hash then
-- trigger correct error
- chunk, err = Loader._loadfile(modpath, opts.mode, opts.env)
- Loader.track('load', start)
- return chunk, err
+ return Loader._loadfile(modpath, opts.mode, opts.env)
end
local entry = Loader.read(modpath)
@@ -258,7 +249,6 @@ function Loader.load(modpath, opts)
-- found in cache and up to date
chunk, err = load(entry.chunk --[[@as string]], '@' .. modpath, opts.mode, opts.env)
if not (err and err:find('cannot load incompatible bytecode', 1, true)) then
- Loader.track('load', start)
return chunk, err
end
end
@@ -269,7 +259,6 @@ function Loader.load(modpath, opts)
entry.chunk = string.dump(chunk)
Loader.write(modpath, entry)
end
- Loader.track('load', start)
return chunk, err
end
@@ -287,7 +276,6 @@ end
--- - modname: (string) the name of the module
--- - stat: (table|nil) the fs_stat of the module path. Won't be returned for `modname="*"`
function M.find(modname, opts)
- local start = uv.hrtime()
opts = opts or {}
modname = modname:gsub('/', '.')
@@ -338,7 +326,7 @@ function M.find(modname, opts)
for _, pattern in ipairs(patterns) do
local modpath = path .. pattern
Loader._stats.find.stat = (Loader._stats.find.stat or 0) + 1
- local hash = uv.fs_stat(modpath)
+ local hash = Loader.get_hash(modpath)
if hash then
results[#results + 1] = { modpath = modpath, stat = hash, modname = modname }
if not continue() then
@@ -366,7 +354,6 @@ function M.find(modname, opts)
_find(opts.paths)
end
- Loader.track('find', start)
if #results == 0 then
-- module not found
Loader._stats.find.not_found = Loader._stats.find.not_found + 1
@@ -375,15 +362,18 @@ function M.find(modname, opts)
return results
end
---- Resets the topmods cache for the path, or all the paths
+--- Resets the cache for the path, or all the paths
--- if path is nil.
---@param path string? path to reset
function M.reset(path)
if path then
- Loader._indexed[Loader.normalize(path)] = nil
+ Loader._indexed[normalize(path)] = nil
else
Loader._indexed = {}
end
+
+ -- Path could be a directory so just clear all the hashes.
+ Loader._hashes = {}
end
--- Enables the experimental Lua module loader:
@@ -399,29 +389,16 @@ function M.enable()
vim.fn.mkdir(vim.fn.fnamemodify(M.path, ':p'), 'p')
_G.loadfile = Loader.loadfile
-- add lua loader
- table.insert(package.loaders, 2, Loader.loader)
+ table.insert(loaders, 2, Loader.loader)
-- add libs loader
- table.insert(package.loaders, 3, Loader.loader_lib)
+ table.insert(loaders, 3, Loader.loader_lib)
-- remove Neovim loader
- for l, loader in ipairs(package.loaders) do
+ for l, loader in ipairs(loaders) do
if loader == vim._load_package then
- table.remove(package.loaders, l)
+ table.remove(loaders, l)
break
end
end
-
- -- this will reset the top-mods in case someone adds a new
- -- top-level lua module to a path already on the rtp
- vim.api.nvim_create_autocmd('BufWritePost', {
- group = vim.api.nvim_create_augroup('cache_topmods_reset', { clear = true }),
- callback = function(event)
- local bufname = event.match ---@type string
- local idx = bufname:find('/lua/', 1, true)
- if idx then
- M.reset(bufname:sub(1, idx - 1))
- end
- end,
- })
end
--- Disables the experimental Lua module loader:
@@ -433,14 +410,12 @@ function M.disable()
end
M.enabled = false
_G.loadfile = Loader._loadfile
- ---@diagnostic disable-next-line: no-unknown
- for l, loader in ipairs(package.loaders) do
+ for l, loader in ipairs(loaders) do
if loader == Loader.loader or loader == Loader.loader_lib then
- table.remove(package.loaders, l)
+ table.remove(loaders, l)
end
end
- table.insert(package.loaders, 2, vim._load_package)
- vim.api.nvim_del_augroup_by_name('cache_topmods_reset')
+ table.insert(loaders, 2, vim._load_package)
end
--- Return the top-level `/lua/*` modules for this path
@@ -448,17 +423,11 @@ end
---@private
function Loader.lsmod(path)
if not Loader._indexed[path] then
- local start = uv.hrtime()
Loader._indexed[path] = {}
- local handle = vim.loop.fs_scandir(path .. '/lua')
- while handle do
- local name, t = vim.loop.fs_scandir_next(handle)
- if not name then
- break
- end
+ for name, t in vim.fs.dir(path .. '/lua') do
local modpath = path .. '/lua/' .. name
-- HACK: type is not always returned due to a bug in luv
- t = t or uv.fs_stat(modpath).type
+ t = t or Loader.get_hash(modpath).type
---@type string
local topname
local ext = name:sub(-4)
@@ -477,22 +446,46 @@ function Loader.lsmod(path)
end
end
end
- Loader.track('lsmod', start)
end
return Loader._indexed[path]
end
+--- Tracks the time spent in a function
+--- @generic F: function
+--- @param f F
+--- @return F
+--- @private
+function Loader.track(stat, f)
+ return function(...)
+ local start = vim.loop.hrtime()
+ local r = { f(...) }
+ Loader._stats[stat] = Loader._stats[stat] or { total = 0, time = 0 }
+ Loader._stats[stat].total = Loader._stats[stat].total + 1
+ Loader._stats[stat].time = Loader._stats[stat].time + uv.hrtime() - start
+ return unpack(r, 1, table.maxn(r))
+ end
+end
+
+---@class ProfileOpts
+---@field loaders? boolean Add profiling to the loaders
+
--- Debug function that wrapps all loaders and tracks stats
---@private
-function M._profile_loaders()
- for l, loader in pairs(package.loaders) do
- local loc = debug.getinfo(loader, 'Sn').source:sub(2)
- package.loaders[l] = function(modname)
- local start = vim.loop.hrtime()
- local ret = loader(modname)
- Loader.track('loader ' .. l .. ': ' .. loc, start)
- Loader.track('loader_all', start)
- return ret
+---@param opts ProfileOpts?
+function M._profile(opts)
+ Loader.get_rtp = Loader.track('get_rtp', Loader.get_rtp)
+ Loader.read = Loader.track('read', Loader.read)
+ Loader.loader = Loader.track('loader', Loader.loader)
+ Loader.loader_lib = Loader.track('loader_lib', Loader.loader_lib)
+ Loader.loadfile = Loader.track('loadfile', Loader.loadfile)
+ Loader.load = Loader.track('load', Loader.load)
+ M.find = Loader.track('find', M.find)
+ Loader.lsmod = Loader.track('lsmod', Loader.lsmod)
+
+ if opts and opts.loaders then
+ for l, loader in pairs(loaders) do
+ local loc = debug.getinfo(loader, 'Sn').source:sub(2)
+ loaders[l] = Loader.track('loader ' .. l .. ': ' .. loc, loader)
end
end
end
diff --git a/runtime/lua/vim/lsp/diagnostic.lua b/runtime/lua/vim/lsp/diagnostic.lua
index b27bf6e425..3efa5c51ff 100644
--- a/runtime/lua/vim/lsp/diagnostic.lua
+++ b/runtime/lua/vim/lsp/diagnostic.lua
@@ -1,13 +1,6 @@
---@brief lsp-diagnostic
----
----@class Diagnostic
----@field range Range
----@field message string
----@field severity DiagnosticSeverity|nil
----@field code integer | string
----@field source string
----@field tags DiagnosticTag[]
----@field relatedInformation DiagnosticRelatedInformation[]
+
+local protocol = require('vim.lsp.protocol')
local M = {}
@@ -22,14 +15,16 @@ local function get_client_id(client_id)
end
---@private
+---@param severity lsp.DiagnosticSeverity
local function severity_lsp_to_vim(severity)
if type(severity) == 'string' then
- severity = vim.lsp.protocol.DiagnosticSeverity[severity]
+ severity = protocol.DiagnosticSeverity[severity]
end
return severity
end
---@private
+---@return lsp.DiagnosticSeverity
local function severity_vim_to_lsp(severity)
if type(severity) == 'string' then
severity = vim.diagnostic.severity[severity]
@@ -38,6 +33,7 @@ local function severity_vim_to_lsp(severity)
end
---@private
+---@return integer
local function line_byte_from_position(lines, lnum, col, offset_encoding)
if not lines or offset_encoding == 'utf-8' then
return col
@@ -77,12 +73,41 @@ local function get_buf_lines(bufnr)
return lines
end
+--- @private
+--- @param diagnostic lsp.Diagnostic
+--- @param client_id integer
+--- @return table?
+local function tags_lsp_to_vim(diagnostic, client_id)
+ local tags ---@type table?
+ for _, tag in ipairs(diagnostic.tags or {}) do
+ if tag == protocol.DiagnosticTag.Unnecessary then
+ tags = tags or {}
+ tags.unnecessary = true
+ elseif tag == protocol.DiagnosticTag.Deprecated then
+ tags = tags or {}
+ tags.deprecated = true
+ else
+ vim.notify_once(
+ string.format('Unknown DiagnosticTag %d from LSP client %d', tag, client_id),
+ vim.log.levels.WARN
+ )
+ end
+ end
+ return tags
+end
+
---@private
+---@param diagnostics lsp.Diagnostic[]
+---@param bufnr integer
+---@param client_id integer
+---@return Diagnostic[]
local function diagnostic_lsp_to_vim(diagnostics, bufnr, client_id)
local buf_lines = get_buf_lines(bufnr)
local client = vim.lsp.get_client_by_id(client_id)
local offset_encoding = client and client.offset_encoding or 'utf-16'
+ ---@diagnostic disable-next-line:no-unknown
return vim.tbl_map(function(diagnostic)
+ ---@cast diagnostic lsp.Diagnostic
local start = diagnostic.range.start
local _end = diagnostic.range['end']
return {
@@ -94,12 +119,12 @@ local function diagnostic_lsp_to_vim(diagnostics, bufnr, client_id)
message = diagnostic.message,
source = diagnostic.source,
code = diagnostic.code,
+ _tags = tags_lsp_to_vim(diagnostic, client_id),
user_data = {
lsp = {
-- usage of user_data.lsp.code is deprecated in favor of the top-level code field
code = diagnostic.code,
codeDescription = diagnostic.codeDescription,
- tags = diagnostic.tags,
relatedInformation = diagnostic.relatedInformation,
data = diagnostic.data,
},
@@ -108,9 +133,13 @@ local function diagnostic_lsp_to_vim(diagnostics, bufnr, client_id)
end, diagnostics)
end
----@private
+--- @private
+--- @param diagnostics Diagnostic[]
+--- @return lsp.Diagnostic[]
local function diagnostic_vim_to_lsp(diagnostics)
+ ---@diagnostic disable-next-line:no-unknown
return vim.tbl_map(function(diagnostic)
+ ---@cast diagnostic Diagnostic
return vim.tbl_extend('keep', {
-- "keep" the below fields over any duplicate fields in diagnostic.user_data.lsp
range = {
@@ -131,6 +160,7 @@ local function diagnostic_vim_to_lsp(diagnostics)
end, diagnostics)
end
+---@type table<integer,integer>
local _client_namespaces = {}
--- Get the diagnostic namespace associated with an LSP client |vim.diagnostic|.
diff --git a/runtime/lua/vim/lsp/protocol.lua b/runtime/lua/vim/lsp/protocol.lua
index 1686e22c48..f4489ad17d 100644
--- a/runtime/lua/vim/lsp/protocol.lua
+++ b/runtime/lua/vim/lsp/protocol.lua
@@ -21,6 +21,7 @@ end
--]=]
local constants = {
+ --- @enum lsp.DiagnosticSeverity
DiagnosticSeverity = {
-- Reports an error.
Error = 1,
@@ -32,6 +33,7 @@ local constants = {
Hint = 4,
},
+ --- @enum lsp.DiagnosticTag
DiagnosticTag = {
-- Unused or unnecessary code
Unnecessary = 1,
diff --git a/runtime/lua/vim/lsp/types.lua b/runtime/lua/vim/lsp/types.lua
index 1aea6841ee..779f313aa7 100644
--- a/runtime/lua/vim/lsp/types.lua
+++ b/runtime/lua/vim/lsp/types.lua
@@ -18,3 +18,20 @@
---@class lsp.FileEvent
---@field uri string
---@field type lsp.FileChangeType
+
+---@class lsp.Position
+---@field line integer
+---@field character integer
+
+---@class lsp.Range
+---@field start lsp.Position
+---@field end lsp.Position
+
+---@class lsp.Diagnostic
+---@field range lsp.Range
+---@field message string
+---@field severity? lsp.DiagnosticSeverity
+---@field code integer | string
+---@field source string
+---@field tags? lsp.DiagnosticTag[]
+---@field relatedInformation DiagnosticRelatedInformation[]
diff --git a/runtime/lua/vim/shared.lua b/runtime/lua/vim/shared.lua
index 884929e33a..9e337e93e8 100644
--- a/runtime/lua/vim/shared.lua
+++ b/runtime/lua/vim/shared.lua
@@ -796,13 +796,15 @@ end
--- a.b.c = 1
--- </pre>
---
----@param create function|nil The function called to create a missing value.
+---@param create function?(key:any):any The function called to create a missing value.
---@return table Empty table with metamethod
function vim.defaulttable(create)
- create = create or vim.defaulttable
+ create = create or function(_)
+ return vim.defaulttable()
+ end
return setmetatable({}, {
__index = function(tbl, key)
- rawset(tbl, key, create())
+ rawset(tbl, key, create(key))
return rawget(tbl, key)
end,
})
diff --git a/runtime/lua/vim/treesitter.lua b/runtime/lua/vim/treesitter.lua
index 4c3b17daa4..2594c1672d 100644
--- a/runtime/lua/vim/treesitter.lua
+++ b/runtime/lua/vim/treesitter.lua
@@ -58,9 +58,6 @@ function M._create_parser(bufnr, lang, opts)
vim.fn.bufload(bufnr)
- local ft = vim.bo[bufnr].filetype
- M.language.add(lang, { filetype = ft ~= '' and ft or nil })
-
local self = LanguageTree.new(bufnr, lang, opts)
---@private
@@ -94,7 +91,12 @@ function M._create_parser(bufnr, lang, opts)
return self
end
---- Returns the parser for a specific buffer and filetype and attaches it to the buffer
+--- @private
+local function valid_lang(lang)
+ return lang and lang ~= ''
+end
+
+--- Returns the parser for a specific buffer and attaches it to the buffer
---
--- If needed, this will create the parser.
---
@@ -110,18 +112,12 @@ function M.get_parser(bufnr, lang, opts)
bufnr = a.nvim_get_current_buf()
end
- if lang == nil then
- local ft = vim.bo[bufnr].filetype
- if ft ~= '' then
- lang = M.language.get_lang(ft) or ft
- -- TODO(lewis6991): we should error here and not default to ft
- -- if not lang then
- -- error(string.format('filetype %s of buffer %d is not associated with any lang', ft, bufnr))
- -- end
- else
- if parsers[bufnr] then
- return parsers[bufnr]
- end
+ if not valid_lang(lang) then
+ lang = M.language.get_lang(vim.bo[bufnr].filetype) or vim.bo[bufnr].filetype
+ end
+
+ if not valid_lang(lang) then
+ if not parsers[bufnr] then
error(
string.format(
'There is no parser available for buffer %d and one could not be'
@@ -131,9 +127,7 @@ function M.get_parser(bufnr, lang, opts)
)
)
end
- end
-
- if parsers[bufnr] == nil or parsers[bufnr]:lang() ~= lang then
+ elseif parsers[bufnr] == nil or parsers[bufnr]:lang() ~= lang then
parsers[bufnr] = M._create_parser(bufnr, lang, opts)
end
@@ -164,7 +158,6 @@ function M.get_string_parser(str, lang, opts)
str = { str, 'string' },
lang = { lang, 'string' },
})
- M.language.add(lang)
return LanguageTree.new(str, lang, opts)
end
diff --git a/runtime/lua/vim/treesitter/health.lua b/runtime/lua/vim/treesitter/health.lua
index fd1188fde4..dabf2cdf6c 100644
--- a/runtime/lua/vim/treesitter/health.lua
+++ b/runtime/lua/vim/treesitter/health.lua
@@ -22,7 +22,7 @@ function M.check()
)
)
else
- local lang = ts.language.inspect_language(parsername)
+ local lang = ts.language.inspect(parsername)
health.report_ok(
string.format('Parser: %-10s ABI: %d, path: %s', parsername, lang._abi_version, parser)
)
diff --git a/runtime/lua/vim/treesitter/language.lua b/runtime/lua/vim/treesitter/language.lua
index 974d66ec05..5b74bb6200 100644
--- a/runtime/lua/vim/treesitter/language.lua
+++ b/runtime/lua/vim/treesitter/language.lua
@@ -4,11 +4,29 @@ local a = vim.api
local M = {}
---@type table<string,string>
-local ft_to_lang = {}
+local ft_to_lang = {
+ help = 'vimdoc',
+}
+
+--- Get the filetypes associated with the parser named {lang}.
+--- @param lang string Name of parser
+--- @return string[] filetypes
+function M.get_filetypes(lang)
+ local r = {} ---@type string[]
+ for ft, p in pairs(ft_to_lang) do
+ if p == lang then
+ r[#r + 1] = ft
+ end
+ end
+ return r
+end
----@param filetype string
----@return string|nil
+--- @param filetype string
+--- @return string|nil
function M.get_lang(filetype)
+ if filetype == '' then
+ return
+ end
return ft_to_lang[filetype]
end
@@ -35,16 +53,14 @@ end
---@field filetype? string|string[]
---@field symbol_name? string
---- Asserts that a parser for the language {lang} is installed.
+--- Load parser with name {lang}
---
--- Parsers are searched in the `parser` runtime directory, or the provided {path}
---
----@param lang string Language the parser should parse (alphanumerical and `_` only)
+---@param lang string Name of the parser (alphanumerical and `_` only)
---@param opts (table|nil) Options:
---- - filetype (string|string[]) Filetype(s) that lang can be parsed with.
---- Note this is not strictly the same as lang since a single lang can
---- parse multiple filetypes.
---- Defaults to lang.
+--- - filetype (string|string[]) Default filetype the parser should be associated with.
+--- Defaults to {lang}.
--- - path (string|nil) Optional path the parser is located at
--- - symbol_name (string|nil) Internal symbol name for the language to load
function M.add(lang, opts)
@@ -61,7 +77,7 @@ function M.add(lang, opts)
filetype = { filetype, { 'string', 'table' }, true },
})
- M.register(lang, filetype or lang)
+ M.register(lang, filetype)
if vim._ts_has_language(lang) then
return
@@ -83,23 +99,26 @@ function M.add(lang, opts)
vim._ts_add_language(path, lang, symbol_name)
end
---- Register a lang to be used for a filetype (or list of filetypes).
----@param lang string Language to register
----@param filetype string|string[] Filetype(s) to associate with lang
+--- @private
+--- @param x string|string[]
+--- @return string[]
+local function ensure_list(x)
+ if type(x) == 'table' then
+ return x
+ end
+ return { x }
+end
+
+--- Register a parser named {lang} to be used for {filetype}(s).
+--- @param lang string Name of parser
+--- @param filetype string|string[] Filetype(s) to associate with lang
function M.register(lang, filetype)
vim.validate({
lang = { lang, 'string' },
filetype = { filetype, { 'string', 'table' } },
})
- local filetypes ---@type string[]
- if type(filetype) == 'string' then
- filetypes = { filetype }
- else
- filetypes = filetype
- end
-
- for _, f in ipairs(filetypes) do
+ for _, f in ipairs(ensure_list(filetype)) do
if f ~= '' then
ft_to_lang[f] = lang
end
diff --git a/runtime/lua/vim/treesitter/languagetree.lua b/runtime/lua/vim/treesitter/languagetree.lua
index 82e507551d..922e4881ca 100644
--- a/runtime/lua/vim/treesitter/languagetree.lua
+++ b/runtime/lua/vim/treesitter/languagetree.lua
@@ -76,7 +76,7 @@ LanguageTree.__index = LanguageTree
--- "injected" language parsers, which themselves may inject other languages, recursively.
---
---@param source (integer|string) Buffer or text string to parse
----@param lang string Root language of this tree
+---@param lang string|nil Root language of this tree
---@param opts (table|nil) Optional arguments:
--- - injections table Map of language to injection query strings. Overrides the
--- built-in runtime file searching for language injections.
@@ -86,11 +86,6 @@ function LanguageTree.new(source, lang, opts)
---@type LanguageTreeOpts
opts = opts or {}
- if opts.queries then
- a.nvim_err_writeln("'queries' is no longer supported. Use 'injections' now")
- opts.injections = opts.queries
- end
-
local injections = opts.injections or {}
local self = setmetatable({
_source = source,
diff --git a/runtime/queries/c/highlights.scm b/runtime/queries/c/highlights.scm
index 33e6df74ab..dee70f9cc7 100644
--- a/runtime/queries/c/highlights.scm
+++ b/runtime/queries/c/highlights.scm
@@ -1,22 +1,19 @@
-(identifier) @variable
+; Lower priority to prefer @parameter when identifier appears in parameter_declaration.
+((identifier) @variable (#set! "priority" 95))
[
- "const"
"default"
"enum"
- "extern"
- "inline"
- "return"
- "sizeof"
- "static"
"struct"
"typedef"
"union"
- "volatile"
"goto"
- "register"
] @keyword
+"sizeof" @keyword.operator
+
+"return" @keyword.return
+
[
"while"
"for"
@@ -32,7 +29,6 @@
"switch"
] @conditional
-"#define" @constant.macro
[
"#if"
"#ifdef"
@@ -41,10 +37,18 @@
"#elif"
"#endif"
(preproc_directive)
-] @keyword
+] @preproc
+
+"#define" @define
"#include" @include
+[ ";" ":" "," ] @punctuation.delimiter
+
+"..." @punctuation.special
+
+[ "(" ")" "[" "]" "{" "}"] @punctuation.bracket
+
[
"="
@@ -62,6 +66,7 @@
">>"
"->"
+ "."
"<"
"<="
@@ -88,35 +93,25 @@
"++"
] @operator
+;; Make sure the comma operator is given a highlight group after the comma
+;; punctuator so the operator is highlighted properly.
+(comma_expression [ "," ] @operator)
+
[
(true)
(false)
] @boolean
-[ "." ";" ":" "," ] @punctuation.delimiter
-
-(conditional_expression [ "?" ":" ] @conditional)
-
-
-[ "(" ")" "[" "]" "{" "}"] @punctuation.bracket
+(conditional_expression [ "?" ":" ] @conditional.ternary)
(string_literal) @string
-(string_literal) @spell
(system_lib_string) @string
+(escape_sequence) @string.escape
(null) @constant.builtin
(number_literal) @number
-(char_literal) @number
+(char_literal) @character
-(call_expression
- function: (identifier) @function)
-(call_expression
- function: (field_expression
- field: (field_identifier) @function))
-(function_declarator
- declarator: (identifier) @function)
-(preproc_function_def
- name: (identifier) @function.macro)
[
(preproc_arg)
(preproc_defined)
@@ -126,18 +121,32 @@
(statement_identifier) @label
[
-(type_identifier)
-(primitive_type)
-(sized_type_specifier)
-(type_descriptor)
- ] @type
+ (type_identifier)
+ (sized_type_specifier)
+ (type_descriptor)
+] @type
+
+(storage_class_specifier) @storageclass
+
+(type_qualifier) @type.qualifier
+
+(linkage_specification
+ "extern" @storageclass)
-(declaration (type_qualifier) @type)
-(cast_expression type: (type_descriptor) @type)
-(sizeof_expression value: (parenthesized_expression (identifier) @type))
+(type_definition
+ declarator: (type_identifier) @type.definition)
+
+(primitive_type) @type.builtin
((identifier) @constant
- (#match? @constant "^[A-Z][A-Z0-9_]+$"))
+ (#lua-match? @constant "^[A-Z][A-Z0-9_]+$"))
+(enumerator
+ name: (identifier) @constant)
+(case_statement
+ value: (identifier) @constant)
+
+((identifier) @constant.builtin
+ (#any-of? @constant.builtin "stderr" "stdin" "stdout"))
;; Preproc def / undef
(preproc_def
@@ -147,9 +156,20 @@
argument: (_) @constant
(#eq? @_u "#undef"))
+(call_expression
+ function: (identifier) @function.call)
+(call_expression
+ function: (field_expression
+ field: (field_identifier) @function.call))
+(function_declarator
+ declarator: (identifier) @function)
+(preproc_function_def
+ name: (identifier) @function.macro)
+
+(comment) @comment @spell
-(comment) @comment
-(comment) @spell
+((comment) @comment.documentation
+ (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
;; Parameters
(parameter_declaration
@@ -158,7 +178,20 @@
(parameter_declaration
declarator: (pointer_declarator) @parameter)
-(preproc_params
- (identifier)) @parameter
+(preproc_params (identifier) @parameter)
+
+[
+ "__attribute__"
+ "__cdecl"
+ "__clrcall"
+ "__stdcall"
+ "__fastcall"
+ "__thiscall"
+ "__vectorcall"
+ "_unaligned"
+ "__unaligned"
+ "__declspec"
+ (attribute_declaration)
+] @attribute
(ERROR) @error
diff --git a/runtime/queries/c/injections.scm b/runtime/queries/c/injections.scm
index 84ae33683e..3b99c7a444 100644
--- a/runtime/queries/c/injections.scm
+++ b/runtime/queries/c/injections.scm
@@ -1,5 +1,5 @@
-((preproc_arg) @injection.content
- (#set! injection.language "c"))
+; ((preproc_arg) @injection.content
+; (#set! injection.language "c"))
; ((comment) @injection.content
; (#set! injection.language "comment"))
diff --git a/runtime/queries/lua/highlights.scm b/runtime/queries/lua/highlights.scm
index 2c0dc5447a..5fbf8a1833 100644
--- a/runtime/queries/lua/highlights.scm
+++ b/runtime/queries/lua/highlights.scm
@@ -8,8 +8,6 @@
"local"
] @keyword
-(label_statement) @label
-
(break_statement) @keyword
(do_statement
@@ -109,6 +107,7 @@
[
";"
":"
+ "::"
","
"."
] @punctuation.delimiter
@@ -129,12 +128,21 @@
(identifier) @variable
((identifier) @variable.builtin
- (#eq? @variable.builtin "self"))
+ (#any-of? @variable.builtin "_G" "_VERSION" "debug" "io" "jit" "math" "os" "package" "self" "string" "table" "utf8"))
+
+((identifier) @keyword.coroutine
+ (#eq? @keyword.coroutine "coroutine"))
(variable_list
- attribute: (attribute
- (["<" ">"] @punctuation.bracket
- (identifier) @attribute)))
+ attribute: (attribute
+ (["<" ">"] @punctuation.bracket
+ (identifier) @attribute)))
+
+;; Labels
+
+(label_statement (identifier) @label)
+
+(goto_statement (identifier) @label)
;; Constants
@@ -172,7 +180,7 @@
(function_call name: (dot_index_expression field: (identifier) @function.call))
(function_declaration name: (dot_index_expression field: (identifier) @function))
-(method_index_expression method: (identifier) @method)
+(method_index_expression method: (identifier) @method.call)
(function_call
(identifier) @function.builtin
@@ -180,20 +188,27 @@
;; built-in functions in Lua 5.1
"assert" "collectgarbage" "dofile" "error" "getfenv" "getmetatable" "ipairs"
"load" "loadfile" "loadstring" "module" "next" "pairs" "pcall" "print"
- "rawequal" "rawget" "rawset" "require" "select" "setfenv" "setmetatable"
- "tonumber" "tostring" "type" "unpack" "xpcall"))
+ "rawequal" "rawget" "rawlen" "rawset" "require" "select" "setfenv" "setmetatable"
+ "tonumber" "tostring" "type" "unpack" "xpcall"
+ "__add" "__band" "__bnot" "__bor" "__bxor" "__call" "__concat" "__div" "__eq" "__gc"
+ "__idiv" "__index" "__le" "__len" "__lt" "__metatable" "__mod" "__mul" "__name" "__newindex"
+ "__pairs" "__pow" "__shl" "__shr" "__sub" "__tostring" "__unm"))
;; Others
-(comment) @comment
-(comment) @spell
+(comment) @comment @spell
+
+((comment) @comment.documentation
+ (#lua-match? @comment.documentation "^[-][-][-]"))
+
+((comment) @comment.documentation
+ (#lua-match? @comment.documentation "^[-][-](%s?)@"))
-(hash_bang_line) @comment
+(hash_bang_line) @preproc
(number) @number
-(string) @string
-(string) @spell
+(string) @string @spell
;; Error
(ERROR) @error
diff --git a/runtime/queries/lua/injections.scm b/runtime/queries/lua/injections.scm
index 10eb4c4054..1c7bdaf951 100644
--- a/runtime/queries/lua/injections.scm
+++ b/runtime/queries/lua/injections.scm
@@ -11,18 +11,18 @@
name: (_) @_vimcmd_identifier
arguments: (arguments (string content: _ @injection.content)))
(#set! injection.language "vim")
- (#any-of? @_vimcmd_identifier "vim.cmd" "vim.api.nvim_command" "vim.api.nvim_exec" "vim.api.nvim_cmd"))
+ (#any-of? @_vimcmd_identifier "vim.cmd" "vim.api.nvim_command" "vim.api.nvim_exec2" "vim.api.nvim_cmd"))
((function_call
name: (_) @_vimcmd_identifier
arguments: (arguments (string content: _ @injection.content) .))
(#set! injection.language "query")
- (#eq? @_vimcmd_identifier "vim.treesitter.query.set_query"))
+ (#any-of? @_vimcmd_identifier "vim.treesitter.query.set" "vim.treesitter.query.parse"))
-; ;; highlight string as query if starts with `;; query`
-; ((string ("string_content") @injection.content)
-; (#set! injection.language "query")
-; (#lua-match? @injection.content "^%s*;+%s?query"))
+;; highlight string as query if starts with `;; query`
+((string ("string_content") @injection.content)
+ (#set! injection.language "query")
+ (#lua-match? @injection.content "^%s*;+%s?query"))
; ((comment) @injection.content
; (#set! injection.language "comment"))
diff --git a/runtime/queries/vim/highlights.scm b/runtime/queries/vim/highlights.scm
index 239b0a0b37..ce25b13b9f 100644
--- a/runtime/queries/vim/highlights.scm
+++ b/runtime/queries/vim/highlights.scm
@@ -271,7 +271,7 @@
":"
] @punctuation.delimiter
-(ternary_expression ["?" ":"] @conditional)
+(ternary_expression ["?" ":"] @conditional.ternary)
; Options
((set_value) @number
diff --git a/runtime/queries/help/highlights.scm b/runtime/queries/vimdoc/highlights.scm
index c0d88301bc..c0d88301bc 100644
--- a/runtime/queries/help/highlights.scm
+++ b/runtime/queries/vimdoc/highlights.scm
diff --git a/runtime/queries/help/injections.scm b/runtime/queries/vimdoc/injections.scm
index 260a05d863..260a05d863 100644
--- a/runtime/queries/help/injections.scm
+++ b/runtime/queries/vimdoc/injections.scm
diff --git a/scripts/gen_help_html.lua b/scripts/gen_help_html.lua
index 2563f2f410..367ce60765 100644
--- a/scripts/gen_help_html.lua
+++ b/scripts/gen_help_html.lua
@@ -624,7 +624,7 @@ local function get_helptags(help_dir)
return m
end
--- Use the help.so parser defined in the build, not whatever happens to be installed on the system.
+-- Use the vimdoc parser defined in the build, not whatever happens to be installed on the system.
local function ensure_runtimepath()
if not vim.o.runtimepath:find('build/lib/nvim/') then
vim.cmd[[set runtimepath^=./build/lib/nvim/]]
@@ -643,8 +643,8 @@ local function parse_buf(fname)
buf = fname
vim.cmd('sbuffer '..tostring(fname)) -- Buffer number.
end
- -- vim.treesitter.require_language('help', './build/lib/nvim/parser/help.so')
- local lang_tree = vim.treesitter.get_parser(buf, 'help')
+ -- vim.treesitter.require_language('help', './build/lib/nvim/parser/vimdoc.so')
+ local lang_tree = vim.treesitter.get_parser(buf)
return lang_tree, buf
end
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt
index ea7dc8acaa..cb688785df 100755
--- a/src/nvim/CMakeLists.txt
+++ b/src/nvim/CMakeLists.txt
@@ -273,6 +273,7 @@ set(LUA_EDITOR_MODULE_SOURCE ${PROJECT_SOURCE_DIR}/runtime/lua/vim/_editor.lua)
set(LUA_SHARED_MODULE_SOURCE ${PROJECT_SOURCE_DIR}/runtime/lua/vim/shared.lua)
set(LUA_LOADER_MODULE_SOURCE ${PROJECT_SOURCE_DIR}/runtime/lua/vim/loader.lua)
set(LUA_INSPECT_MODULE_SOURCE ${PROJECT_SOURCE_DIR}/runtime/lua/vim/inspect.lua)
+set(LUA_FS_MODULE_SOURCE ${PROJECT_SOURCE_DIR}/runtime/lua/vim/fs.lua)
set(LUA_F_MODULE_SOURCE ${PROJECT_SOURCE_DIR}/runtime/lua/vim/F.lua)
set(LUA_META_MODULE_SOURCE ${PROJECT_SOURCE_DIR}/runtime/lua/vim/_meta.lua)
set(LUA_FILETYPE_MODULE_SOURCE ${PROJECT_SOURCE_DIR}/runtime/lua/vim/filetype.lua)
@@ -505,6 +506,7 @@ add_custom_command(
${LUA_PRG} ${CHAR_BLOB_GENERATOR} -c ${VIM_MODULE_FILE}
${LUA_INIT_PACKAGES_MODULE_SOURCE} "vim._init_packages"
${LUA_INSPECT_MODULE_SOURCE} "vim.inspect"
+ ${LUA_FS_MODULE_SOURCE} "vim.fs"
${LUA_EDITOR_MODULE_SOURCE} "vim._editor"
${LUA_SHARED_MODULE_SOURCE} "vim.shared"
${LUA_LOADER_MODULE_SOURCE} "vim.loader"
@@ -744,15 +746,12 @@ if(WIN32)
"file(MAKE_DIRECTORY \"${PROJECT_BINARY_DIR}/windows_runtime_deps/platforms\")")
foreach(DEP_FILE IN ITEMS
cat.exe
- curl-ca-bundle.crt
- curl.exe
diff.exe
tee.exe
win32yank.exe
xxd.exe
- ${NVIMQT_DEPS}
- )
+ ${NVIMQT_DEPS})
get_filename_component(DEP_FILE_DIR ${DEP_FILE} DIRECTORY)
set(EXTERNAL_BLOBS_SCRIPT "${EXTERNAL_BLOBS_SCRIPT}\n"
"file(COPY \"${DEPS_PREFIX}/bin/${DEP_FILE}\"
diff --git a/src/nvim/api/deprecated.c b/src/nvim/api/deprecated.c
index 6a12cfe2da..5937b2f635 100644
--- a/src/nvim/api/deprecated.c
+++ b/src/nvim/api/deprecated.c
@@ -20,6 +20,7 @@
#include "nvim/highlight_group.h"
#include "nvim/lua/executor.h"
#include "nvim/memory.h"
+#include "nvim/option.h"
#include "nvim/pos.h"
#include "nvim/types.h"
@@ -508,3 +509,16 @@ static int64_t convert_index(int64_t index)
{
return index < 0 ? index - 1 : index;
}
+
+/// Gets the option information for one option
+///
+/// @deprecated Use @ref nvim_get_option_info2 instead.
+///
+/// @param name Option name
+/// @param[out] err Error details, if any
+/// @return Option Information
+Dictionary nvim_get_option_info(String name, Error *err)
+ FUNC_API_SINCE(7)
+{
+ return get_vimoption(name, OPT_GLOBAL, curbuf, curwin, err);
+}
diff --git a/src/nvim/api/options.c b/src/nvim/api/options.c
index 7a453c01b4..baeb3e88fb 100644
--- a/src/nvim/api/options.c
+++ b/src/nvim/api/options.c
@@ -111,15 +111,15 @@ static buf_T *do_ft_buf(char *filetype, aco_save_T *aco, Error *err)
// Set curwin/curbuf to buf and save a few things.
aucmd_prepbuf(aco, ftbuf);
- set_option_value("bufhidden", 0L, "hide", OPT_LOCAL);
- set_option_value("buftype", 0L, "nofile", OPT_LOCAL);
- set_option_value("swapfile", 0L, NULL, OPT_LOCAL);
- set_option_value("modeline", 0L, NULL, OPT_LOCAL); // 'nomodeline'
-
- ftbuf->b_p_ft = xstrdup(filetype);
TRY_WRAP(err, {
- apply_autocmds(EVENT_FILETYPE, ftbuf->b_p_ft, ftbuf->b_fname, true, ftbuf);
+ set_option_value("bufhidden", 0L, "hide", OPT_LOCAL);
+ set_option_value("buftype", 0L, "nofile", OPT_LOCAL);
+ set_option_value("swapfile", 0L, NULL, OPT_LOCAL);
+ set_option_value("modeline", 0L, NULL, OPT_LOCAL); // 'nomodeline'
+
+ ftbuf->b_p_ft = xstrdup(filetype);
+ do_filetype_autocmd(ftbuf, false);
});
return ftbuf;
@@ -283,7 +283,7 @@ void nvim_set_option_value(uint64_t channel_id, String name, Object value, Dict(
/// Gets the option information for all options.
///
/// The dictionary has the full option names as keys and option metadata
-/// dictionaries as detailed at |nvim_get_option_info()|.
+/// dictionaries as detailed at |nvim_get_option_info2()|.
///
/// @return dictionary of all options
Dictionary nvim_get_all_options_info(Error *err)
@@ -292,7 +292,7 @@ Dictionary nvim_get_all_options_info(Error *err)
return get_all_vimoptions();
}
-/// Gets the option information for one option
+/// Gets the option information for one option from arbitrary buffer or window
///
/// Resulting dictionary has keys:
/// - name: Name of the option (like 'filetype')
@@ -311,15 +311,36 @@ Dictionary nvim_get_all_options_info(Error *err)
/// - commalist: List of comma separated values
/// - flaglist: List of single char flags
///
+/// When {scope} is not provided, the last set information applies to the local
+/// value in the current buffer or window if it is available, otherwise the
+/// global value information is returned. This behavior can be disabled by
+/// explicitly specifying {scope} in the {opts} table.
///
-/// @param name Option name
+/// @param name Option name
+/// @param opts Optional parameters
+/// - scope: One of "global" or "local". Analogous to
+/// |:setglobal| and |:setlocal|, respectively.
+/// - win: |window-ID|. Used for getting window local options.
+/// - buf: Buffer number. Used for getting buffer local options.
+/// Implies {scope} is "local".
/// @param[out] err Error details, if any
/// @return Option Information
-Dictionary nvim_get_option_info(String name, Error *err)
- FUNC_API_SINCE(7)
+Dictionary nvim_get_option_info2(String name, Dict(option) *opts, Error *err)
+ FUNC_API_SINCE(11)
{
- return get_vimoption(name, err);
+ int scope = 0;
+ int opt_type = SREQ_GLOBAL;
+ void *from = NULL;
+ if (!validate_option_value_args(opts, &scope, &opt_type, &from, NULL, err)) {
+ return (Dictionary)ARRAY_DICT_INIT;
+ }
+
+ buf_T *buf = (opt_type == SREQ_BUF) ? (buf_T *)from : curbuf;
+ win_T *win = (opt_type == SREQ_WIN) ? (win_T *)from : curwin;
+
+ return get_vimoption(name, scope, buf, win, err);
}
+
/// Sets the global value of an option.
///
/// @param channel_id
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index ca5dd97020..9812313b7b 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -95,6 +95,9 @@ Integer nvim_get_hl_id_by_name(String name)
/// @param[out] err Error details, if any.
/// @return Highlight groups as a map from group name to a highlight definition map as in |nvim_set_hl()|,
/// or only a single highlight definition map if requested by name or id.
+///
+/// @note When the `link` attribute is defined in the highlight definition
+/// map, other attributes will not be taking effect (see |:hi-link|).
Dictionary nvim_get_hl(Integer ns_id, Dict(get_highlight) *opts, Arena *arena, Error *err)
FUNC_API_SINCE(11)
{
@@ -113,6 +116,10 @@ Dictionary nvim_get_hl(Integer ns_id, Dict(get_highlight) *opts, Arena *arena, E
/// values of the Normal group. If the Normal group has not been defined,
/// using these values results in an error.
///
+///
+/// @note If `link` is used in combination with other attributes; only the
+/// `link` will take effect (see |:hi-link|).
+///
/// @param ns_id Namespace id for this highlight |nvim_create_namespace()|.
/// Use 0 to set a highlight group globally |:highlight|.
/// Highlights from non-global namespaces are not active by default, use
diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c
index c66ee4286e..578542adfe 100644
--- a/src/nvim/autocmd.c
+++ b/src/nvim/autocmd.c
@@ -2758,3 +2758,32 @@ void do_autocmd_focusgained(bool gained)
recursive = false;
}
+
+void do_filetype_autocmd(buf_T *buf, bool force)
+{
+ static int ft_recursive = 0;
+
+ if (ft_recursive > 0 && !force) {
+ return; // disallow recursion
+ }
+
+ char **varp = &buf->b_p_ft;
+ int secure_save = secure;
+
+ // Reset the secure flag, since the value of 'filetype' has
+ // been checked to be safe.
+ secure = 0;
+
+ ft_recursive++;
+ did_filetype = true;
+ // Only pass true for "force" when it is true or
+ // used recursively, to avoid endless recurrence.
+ apply_autocmds(EVENT_FILETYPE, buf->b_p_ft, buf->b_fname, force || ft_recursive == 1, buf);
+ ft_recursive--;
+
+ // Just in case the old "buf" is now invalid
+ if (varp != &(buf->b_p_ft)) {
+ varp = NULL;
+ }
+ secure = secure_save;
+}
diff --git a/src/nvim/channel.c b/src/nvim/channel.c
index f68ee2b39e..a0fe3cc734 100644
--- a/src/nvim/channel.c
+++ b/src/nvim/channel.c
@@ -218,7 +218,7 @@ void channel_create_event(Channel *chan, const char *ext_source)
source = ext_source;
} else {
eval_fmt_source_name_line(IObuff, sizeof(IObuff));
- source = (const char *)IObuff;
+ source = IObuff;
}
assert(chan->id <= VARNUMBER_MAX);
diff --git a/src/nvim/charset.c b/src/nvim/charset.c
index a3aa6783ee..2be8ccc456 100644
--- a/src/nvim/charset.c
+++ b/src/nvim/charset.c
@@ -55,7 +55,7 @@ static bool chartab_initialized = false;
((chartab)[(unsigned)(c) >> 6] & (1ull << ((c) & 0x3f)))
// Table used below, see init_chartab() for an explanation
-static char_u g_chartab[256];
+static uint8_t g_chartab[256];
// Flags for g_chartab[].
#define CT_CELL_MASK 0x07 ///< mask: nr of display cells (1, 2 or 4)
@@ -286,7 +286,7 @@ void trans_characters(char *buf, int bufsize)
if ((trs_len = utfc_ptr2len(buf)) > 1) {
len -= trs_len;
} else {
- trs = (char *)transchar_byte((uint8_t)(*buf));
+ trs = transchar_byte((uint8_t)(*buf));
trs_len = (int)strlen(trs);
if (trs_len > 1) {
@@ -532,7 +532,7 @@ char *str_foldcase(char *str, int orglen, char *buf, int buflen)
// Does NOT work for multi-byte characters, c must be <= 255.
// Also doesn't work for the first byte of a multi-byte, "c" must be a
// character!
-static char_u transchar_charbuf[11];
+static uint8_t transchar_charbuf[11];
/// Translate a character into a printable one, leaving printable ASCII intact
///
@@ -543,10 +543,10 @@ static char_u transchar_charbuf[11];
/// @return translated character into a static buffer.
char *transchar(int c)
{
- return (char *)transchar_buf(curbuf, c);
+ return transchar_buf(curbuf, c);
}
-char_u *transchar_buf(const buf_T *buf, int c)
+char *transchar_buf(const buf_T *buf, int c)
{
int i = 0;
if (IS_SPECIAL(c)) {
@@ -560,14 +560,14 @@ char_u *transchar_buf(const buf_T *buf, int c)
if ((!chartab_initialized && (c >= ' ' && c <= '~'))
|| ((c <= 0xFF) && vim_isprintc_strict(c))) {
// printable character
- transchar_charbuf[i] = (char_u)c;
+ transchar_charbuf[i] = (uint8_t)c;
transchar_charbuf[i + 1] = NUL;
} else if (c <= 0xFF) {
- transchar_nonprint(buf, transchar_charbuf + i, c);
+ transchar_nonprint(buf, (char *)transchar_charbuf + i, c);
} else {
transchar_hex((char *)transchar_charbuf + i, c);
}
- return transchar_charbuf;
+ return (char *)transchar_charbuf;
}
/// Like transchar(), but called with a byte instead of a character.
@@ -577,7 +577,7 @@ char_u *transchar_buf(const buf_T *buf, int c)
/// @param[in] c Byte to translate.
///
/// @return pointer to translated character in transchar_charbuf.
-char_u *transchar_byte(const int c)
+char *transchar_byte(const int c)
FUNC_ATTR_WARN_UNUSED_RESULT
{
return transchar_byte_buf(curbuf, c);
@@ -590,12 +590,12 @@ char_u *transchar_byte(const int c)
/// @param[in] c Byte to translate.
///
/// @return pointer to translated character in transchar_charbuf.
-char_u *transchar_byte_buf(const buf_T *buf, const int c)
+char *transchar_byte_buf(const buf_T *buf, const int c)
FUNC_ATTR_WARN_UNUSED_RESULT
{
if (c >= 0x80) {
- transchar_nonprint(buf, transchar_charbuf, c);
- return transchar_charbuf;
+ transchar_nonprint(buf, (char *)transchar_charbuf, c);
+ return (char *)transchar_charbuf;
}
return transchar_buf(buf, c);
}
@@ -609,7 +609,7 @@ char_u *transchar_byte_buf(const buf_T *buf, const int c)
/// at least 5 bytes (conversion result + NUL).
/// @param[in] c Character to convert. NUL is assumed to be NL according to
/// `:h NL-used-for-NUL`.
-void transchar_nonprint(const buf_T *buf, char_u *charbuf, int c)
+void transchar_nonprint(const buf_T *buf, char *charbuf, int c)
{
if (c == NL) {
// we use newline in place of a NUL
@@ -622,12 +622,12 @@ void transchar_nonprint(const buf_T *buf, char_u *charbuf, int c)
if (dy_flags & DY_UHEX || c > 0x7f) {
// 'display' has "uhex"
- transchar_hex((char *)charbuf, c);
+ transchar_hex(charbuf, c);
} else {
// 0x00 - 0x1f and 0x7f
charbuf[0] = '^';
// DEL displayed as ^?
- charbuf[1] = (char_u)(c ^ 0x40);
+ charbuf[1] = (char)(uint8_t)(c ^ 0x40);
charbuf[2] = NUL;
}
@@ -755,7 +755,7 @@ int ptr2cells(const char *p_in)
/// @param s
///
/// @return number of character cells.
-int vim_strsize(char *s)
+int vim_strsize(const char *s)
{
return vim_strnsize(s, MAXCOL);
}
@@ -769,7 +769,7 @@ int vim_strsize(char *s)
/// @param len
///
/// @return Number of character cells.
-int vim_strnsize(char *s, int len)
+int vim_strnsize(const char *s, int len)
{
assert(s != NULL);
int size = 0;
diff --git a/src/nvim/charset.h b/src/nvim/charset.h
index e1ef06ef1d..f98ed94b87 100644
--- a/src/nvim/charset.h
+++ b/src/nvim/charset.h
@@ -54,6 +54,6 @@ static inline bool vim_isbreak(int c)
/// Used very often if 'linebreak' is set
static inline bool vim_isbreak(int c)
{
- return breakat_flags[(char_u)c];
+ return breakat_flags[(uint8_t)c];
}
#endif // NVIM_CHARSET_H
diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c
index 6d8cf1c7e1..caad88c212 100644
--- a/src/nvim/drawline.c
+++ b/src/nvim/drawline.c
@@ -2371,7 +2371,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
mb_c = c;
mb_utf8 = check_mb_utf8(&c, u8cc);
} else if (c != NUL) {
- wlv.p_extra = (char *)transchar_buf(wp->w_buffer, c);
+ wlv.p_extra = transchar_buf(wp->w_buffer, c);
if (wlv.n_extra == 0) {
wlv.n_extra = byte2cells(c) - 1;
}
diff --git a/src/nvim/drawscreen.c b/src/nvim/drawscreen.c
index 1c8bf56e8e..13e9d1ea49 100644
--- a/src/nvim/drawscreen.c
+++ b/src/nvim/drawscreen.c
@@ -939,9 +939,9 @@ int showmode(void)
}
if (length - vim_strsize(edit_submode) > 0) {
if (edit_submode_pre != NULL) {
- msg_puts_attr((const char *)edit_submode_pre, attr);
+ msg_puts_attr(edit_submode_pre, attr);
}
- msg_puts_attr((const char *)edit_submode, attr);
+ msg_puts_attr(edit_submode, attr);
}
if (edit_submode_extra != NULL) {
msg_puts_attr(" ", attr); // Add a space in between.
@@ -950,7 +950,7 @@ int showmode(void)
} else {
sub_attr = attr;
}
- msg_puts_attr((const char *)edit_submode_extra, sub_attr);
+ msg_puts_attr(edit_submode_extra, sub_attr);
}
}
} else {
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index 0983d025e5..c551ec2726 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -1955,7 +1955,7 @@ static void insert_special(int c, int allow_modmask, int ctrlv)
allow_modmask = true;
}
if (IS_SPECIAL(c) || (mod_mask && allow_modmask)) {
- char *p = (char *)get_special_key_name(c, mod_mask);
+ char *p = get_special_key_name(c, mod_mask);
int len = (int)strlen(p);
c = (uint8_t)p[len - 1];
if (len > 2) {
@@ -2294,11 +2294,11 @@ static void stop_insert(pos_T *end_insert_pos, int esc, int nomove)
// Don't do it when "restart_edit" was set and nothing was inserted,
// otherwise CTRL-O w and then <Left> will clear "last_insert".
ptr = get_inserted();
- if (did_restart_edit == 0 || (ptr != NULL
- && (int)strlen(ptr) > new_insert_skip)) {
+ int added = ptr == NULL ? 0 : (int)strlen(ptr) - new_insert_skip;
+ if (did_restart_edit == 0 || added > 0) {
xfree(last_insert);
last_insert = ptr;
- last_insert_skip = new_insert_skip;
+ last_insert_skip = added < 0 ? 0 : new_insert_skip;
} else {
xfree(ptr);
}
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index fc9ddb75ef..edaa2bb809 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -596,7 +596,7 @@ int var_redir_start(char *name, int append)
/// :redir => foo
/// :let foo
/// :redir END
-void var_redir_str(char *value, int value_len)
+void var_redir_str(const char *value, int value_len)
{
if (redir_lval == NULL) {
return;
@@ -2147,10 +2147,10 @@ int pattern_match(const char *pat, const char *text, bool ic)
// avoid 'l' flag in 'cpoptions'
char *save_cpo = p_cpo;
p_cpo = empty_option;
- regmatch.regprog = vim_regcomp((char *)pat, RE_MAGIC + RE_STRING);
+ regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
if (regmatch.regprog != NULL) {
regmatch.rm_ic = ic;
- matches = vim_regexec_nl(&regmatch, (char *)text, (colnr_T)0);
+ matches = vim_regexec_nl(&regmatch, text, (colnr_T)0);
vim_regfree(regmatch.regprog);
}
p_cpo = save_cpo;
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index df8004dc73..4286e16eb1 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -4670,7 +4670,7 @@ static void find_some_match(typval_T *const argvars, typval_T *const rettv,
}
}
- regmatch.regprog = vim_regcomp((char *)pat, RE_MAGIC + RE_STRING);
+ regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
if (regmatch.regprog != NULL) {
regmatch.rm_ic = p_ic;
@@ -6197,7 +6197,7 @@ static void f_resolve(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
}
# else
char *v = os_realpath(fname, NULL);
- rettv->vval.v_string = (char_u *)(v == NULL ? xstrdup(fname) : v);
+ rettv->vval.v_string = v == NULL ? xstrdup(fname) : v;
# endif
#endif
@@ -7895,7 +7895,7 @@ static void f_split(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
}
regmatch_T regmatch = {
- .regprog = vim_regcomp((char *)pat, RE_MAGIC + RE_STRING),
+ .regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING),
.startp = { NULL },
.endp = { NULL },
.rm_ic = false,
@@ -7906,7 +7906,7 @@ static void f_split(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
if (*str == NUL) {
match = false; // Empty item at the end.
} else {
- match = vim_regexec_nl(&regmatch, (char *)str, col);
+ match = vim_regexec_nl(&regmatch, str, col);
}
const char *end;
if (match) {
diff --git a/src/nvim/eval/typval_defs.h b/src/nvim/eval/typval_defs.h
index 4615198441..80432271b0 100644
--- a/src/nvim/eval/typval_defs.h
+++ b/src/nvim/eval/typval_defs.h
@@ -206,7 +206,7 @@ typedef struct {
struct { \
typval_T di_tv; /* Structure that holds scope dictionary itself. */ \
uint8_t di_flags; /* Flags. */ \
- char_u di_key[__VA_ARGS__]; /* Key value. */ /* NOLINT(runtime/arrays)*/ \
+ char di_key[__VA_ARGS__]; /* Key value. */ /* NOLINT(runtime/arrays)*/ \
}
/// Structure to hold a scope dictionary
diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c
index 13779f4173..40bca9acc1 100644
--- a/src/nvim/eval/userfunc.c
+++ b/src/nvim/eval/userfunc.c
@@ -90,7 +90,7 @@ static int get_function_args(char **argp, char endchar, garray_T *newargs, int *
bool mustend = false;
char *arg = *argp;
char *p = arg;
- char_u c;
+ uint8_t c;
int i;
if (newargs != NULL) {
@@ -128,7 +128,7 @@ static int get_function_args(char **argp, char endchar, garray_T *newargs, int *
}
if (newargs != NULL) {
ga_grow(newargs, 1);
- c = (char_u)(*p);
+ c = (uint8_t)(*p);
*p = NUL;
arg = xstrdup(arg);
@@ -159,7 +159,7 @@ static int get_function_args(char **argp, char endchar, garray_T *newargs, int *
while (p > expr && ascii_iswhite(p[-1])) {
p--;
}
- c = (char_u)(*p);
+ c = (uint8_t)(*p);
*p = NUL;
expr = xstrdup(expr);
((char **)(default_args->ga_data))[default_args->ga_len] = expr;
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index ac3c8c4f8e..705f0fe83d 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -149,7 +149,7 @@ void do_ascii(const exarg_T *const eap)
char buf1[20];
if (vim_isprintc_strict(c) && (c < ' ' || c > '~')) {
char buf3[7];
- transchar_nonprint(curbuf, (char_u *)buf3, c);
+ transchar_nonprint(curbuf, buf3, c);
vim_snprintf(buf1, sizeof(buf1), " <%s>", (char *)buf3);
} else {
buf1[0] = NUL;
@@ -4742,7 +4742,7 @@ void ex_oldfiles(exarg_T *eap)
}
nr++;
const char *fname = tv_get_string(TV_LIST_ITEM_TV(li));
- if (!message_filtered((char *)fname)) {
+ if (!message_filtered(fname)) {
msg_outnum(nr);
msg_puts(": ");
msg_outtrans((char *)tv_get_string(TV_LIST_ITEM_TV(li)));
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c
index c777efb445..a86676733f 100644
--- a/src/nvim/ex_cmds2.c
+++ b/src/nvim/ex_cmds2.c
@@ -201,7 +201,7 @@ void dialog_changed(buf_T *buf, bool checkall)
.forceit = false,
};
- dialog_msg((char *)buff, _("Save changes to \"%s\"?"), buf->b_fname);
+ dialog_msg(buff, _("Save changes to \"%s\"?"), buf->b_fname);
if (checkall) {
ret = vim_dialog_yesnoallcancel(VIM_QUESTION, NULL, buff, 1);
} else {
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 5112505eda..bd7ddbf567 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -2117,7 +2117,7 @@ static int command_line_handle_key(CommandLineState *s)
// put the character in the command line
if (IS_SPECIAL(s->c) || mod_mask != 0) {
- put_on_cmdline((char *)get_special_key_name(s->c, mod_mask), -1, true);
+ put_on_cmdline(get_special_key_name(s->c, mod_mask), -1, true);
} else {
int j = utf_char2bytes(s->c, IObuff);
IObuff[j] = NUL; // exclude composing chars
diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c
index 855a5f7538..d47d40cbee 100644
--- a/src/nvim/ex_session.c
+++ b/src/nvim/ex_session.c
@@ -959,7 +959,7 @@ void ex_mkrc(exarg_T *eap)
// When using 'viewdir' may have to create the directory.
if (using_vdir && !os_isdir(p_vdir)) {
- vim_mkdir_emsg((const char *)p_vdir, 0755);
+ vim_mkdir_emsg(p_vdir, 0755);
}
fd = open_exfile(fname, eap->forceit, WRITEBIN);
diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c
index e27c7c4349..d91e2dfeeb 100644
--- a/src/nvim/file_search.c
+++ b/src/nvim/file_search.c
@@ -794,7 +794,7 @@ char *vim_findfile(void *search_ctx_arg)
) {
#ifdef FF_VERBOSE
if (ff_check_visited(&search_ctx->ffsc_visited_list->ffvl_visited_list,
- file_path, (char_u *)"") == FAIL) {
+ file_path, "") == FAIL) {
if (p_verbose >= 5) {
verbose_enter_scroll();
smsg("Already: %s", file_path);
diff --git a/src/nvim/generators/gen_ex_cmds.lua b/src/nvim/generators/gen_ex_cmds.lua
index 935d7b333e..26edd33604 100644
--- a/src/nvim/generators/gen_ex_cmds.lua
+++ b/src/nvim/generators/gen_ex_cmds.lua
@@ -41,7 +41,7 @@ static const uint16_t cmdidxs1[%u] = {
-- Values in cmdidxs2[c1][c2] are relative to cmdidxs1[c1] so that they
-- fit in a byte.
local cmdidxs2_out = string.format([[
-static const char_u cmdidxs2[%u][%u] = {
+static const uint8_t cmdidxs2[%u][%u] = {
/* a b c d e f g h i j k l m n o p q r s t u v w x y z */
]], a_to_z, a_to_z)
diff --git a/src/nvim/generators/gen_options.lua b/src/nvim/generators/gen_options.lua
index edb7dae159..54b97c5286 100644
--- a/src/nvim/generators/gen_options.lua
+++ b/src/nvim/generators/gen_options.lua
@@ -139,7 +139,7 @@ local dump_option = function(i, o)
w(get_cond(o.enable_if))
end
if o.varname then
- w(' .var=(char_u *)&' .. o.varname)
+ w(' .var=(char *)&' .. o.varname)
elseif #o.scope == 1 and o.scope[1] == 'window' then
w(' .var=VAR_WIN')
end
diff --git a/src/nvim/globals.h b/src/nvim/globals.h
index 816471d7c1..571df45e89 100644
--- a/src/nvim/globals.h
+++ b/src/nvim/globals.h
@@ -169,7 +169,7 @@ EXTERN char *edit_submode_extra INIT(= NULL); // appended to edit_submode
EXTERN hlf_T edit_submode_highl; // highl. method for extra info
// state for putting characters in the message area
-EXTERN int cmdmsg_rl INIT(= false); // cmdline is drawn right to left
+EXTERN bool cmdmsg_rl INIT(= false); // cmdline is drawn right to left
EXTERN int msg_col;
EXTERN int msg_row;
EXTERN int msg_scrolled; // Number of screen lines that windows have
@@ -224,7 +224,7 @@ EXTERN bool did_wait_return INIT(= false); // wait_return() was used and
// nothing written since then
EXTERN bool need_maketitle INIT(= true); // call maketitle() soon
-EXTERN int quit_more INIT(= false); // 'q' hit at "--more--" msg
+EXTERN bool quit_more INIT(= false); // 'q' hit at "--more--" msg
EXTERN int vgetc_busy INIT(= 0); // when inside vgetc() then > 0
EXTERN bool didset_vim INIT(= false); // did set $VIM ourselves
@@ -233,7 +233,7 @@ EXTERN bool didset_vimruntime INIT(= false); // idem for $VIMRUNTIME
/// Lines left before a "more" message. Ex mode needs to be able to reset this
/// after you type something.
EXTERN int lines_left INIT(= -1); // lines left for listing
-EXTERN int msg_no_more INIT(= false); // don't use more prompt, truncate
+EXTERN bool msg_no_more INIT(= false); // don't use more prompt, truncate
// messages
EXTERN int ex_nesting_level INIT(= 0); // nesting level
@@ -275,7 +275,7 @@ EXTERN int trylevel INIT(= 0);
/// non-zero (and ":silent!" was not used) or an exception is being thrown at
/// the time an error is detected. It is set to false when "trylevel" gets
/// zero again and there was no error or interrupt or throw.
-EXTERN int force_abort INIT(= false);
+EXTERN bool force_abort INIT(= false);
/// "msg_list" points to a variable in the stack of do_cmdline() which keeps
/// the list of arguments of several emsg() calls, one of which is to be
@@ -308,8 +308,8 @@ EXTERN except_T *caught_stack INIT(= NULL);
/// "garbage_collect_at_exit" indicates garbagecollect(1) was called.
///
EXTERN bool may_garbage_collect INIT(= false);
-EXTERN int want_garbage_collect INIT(= false);
-EXTERN int garbage_collect_at_exit INIT(= false);
+EXTERN bool want_garbage_collect INIT(= false);
+EXTERN bool garbage_collect_at_exit INIT(= false);
// Special values for current_SID.
#define SID_MODELINE (-1) // when using a modeline
@@ -360,19 +360,19 @@ EXTERN linenr_T search_last_line INIT(= MAXLNUM); // for :{first},{LAST}s/pat
EXTERN bool no_smartcase INIT(= false); // don't use 'smartcase' once
-EXTERN int need_check_timestamps INIT(= false); // need to check file
- // timestamps asap
-EXTERN int did_check_timestamps INIT(= false); // did check timestamps
- // recently
-EXTERN int no_check_timestamps INIT(= 0); // Don't check timestamps
+EXTERN bool need_check_timestamps INIT(= false); // need to check file
+ // timestamps asap
+EXTERN bool did_check_timestamps INIT(= false); // did check timestamps
+ // recently
+EXTERN int no_check_timestamps INIT(= 0); // Don't check timestamps
-EXTERN int autocmd_busy INIT(= false); // Is apply_autocmds() busy?
+EXTERN bool autocmd_busy INIT(= false); // Is apply_autocmds() busy?
EXTERN int autocmd_no_enter INIT(= false); // *Enter autocmds disabled
EXTERN int autocmd_no_leave INIT(= false); // *Leave autocmds disabled
EXTERN int modified_was_set; // did ":set modified"
-EXTERN int did_filetype INIT(= false); // FileType event found
+EXTERN bool did_filetype INIT(= false); // FileType event found
// value for did_filetype when starting to execute autocommands
-EXTERN int keep_filetype INIT(= false);
+EXTERN bool keep_filetype INIT(= false);
// When deleting the current buffer, another one must be loaded.
// If we know which one is preferred, au_new_curbuf is set to it.
@@ -398,7 +398,7 @@ EXTERN int mouse_dragging INIT(= 0); // extending Visual area with
EXTERN vimmenu_T *root_menu INIT(= NULL);
// While defining the system menu, sys_menu is true. This avoids
// overruling of menus that the user already defined.
-EXTERN int sys_menu INIT(= false);
+EXTERN bool sys_menu INIT(= false);
// All windows are linked in a list. firstwin points to the first entry,
// lastwin to the last entry (can be the same as firstwin) and curwin to the
@@ -501,7 +501,7 @@ EXTERN bool stderr_isatty INIT(= true);
EXTERN int stdin_fd INIT(= -1);
// true when doing full-screen output, otherwise only writing some messages.
-EXTERN int full_screen INIT(= false);
+EXTERN bool full_screen INIT(= false);
/// Non-zero when only "safe" commands are allowed
EXTERN int secure INIT(= 0);
@@ -519,14 +519,14 @@ EXTERN int allbuf_lock INIT(= 0);
EXTERN int sandbox INIT(= 0);
/// Batch-mode: "-es", "-Es", "-l" commandline argument was given.
-EXTERN int silent_mode INIT(= false);
+EXTERN bool silent_mode INIT(= false);
/// Start position of active Visual selection.
EXTERN pos_T VIsual;
/// Whether Visual mode is active.
-EXTERN int VIsual_active INIT(= false);
+EXTERN bool VIsual_active INIT(= false);
/// Whether Select mode is active.
-EXTERN int VIsual_select INIT(= false);
+EXTERN bool VIsual_select INIT(= false);
/// Register name for Select mode
EXTERN int VIsual_select_reg INIT(= 0);
/// Restart Select mode when next cmd finished
@@ -536,7 +536,7 @@ EXTERN int VIsual_reselect;
/// Type of Visual mode.
EXTERN int VIsual_mode INIT(= 'v');
/// true when redoing Visual.
-EXTERN int redo_VIsual_busy INIT(= false);
+EXTERN bool redo_VIsual_busy INIT(= false);
// The Visual area is remembered for reselection.
EXTERN int resel_VIsual_mode INIT(= NUL); // 'v', 'V', or Ctrl-V
@@ -704,8 +704,8 @@ EXTERN char os_buf[ ///< Buffer for the os/ layer
// When non-zero, postpone redrawing.
EXTERN int RedrawingDisabled INIT(= 0);
-EXTERN int readonlymode INIT(= false); // Set to true for "view"
-EXTERN int recoverymode INIT(= false); // Set to true for "-r" option
+EXTERN bool readonlymode INIT(= false); // Set to true for "view"
+EXTERN bool recoverymode INIT(= false); // Set to true for "-r" option
// typeahead buffer
EXTERN typebuf_T typebuf INIT(= { NULL, NULL, 0, 0, 0, 0, 0, 0, 0 });
@@ -714,13 +714,13 @@ EXTERN typebuf_T typebuf INIT(= { NULL, NULL, 0, 0, 0, 0, 0, 0, 0 });
/// :normal argument was exhausted.
EXTERN bool typebuf_was_empty INIT(= false);
-EXTERN int ex_normal_busy INIT(= 0); // recursiveness of ex_normal()
-EXTERN int expr_map_lock INIT(= 0); // running expr mapping, prevent use of ex_normal() and text changes
-EXTERN int ignore_script INIT(= false); // ignore script input
-EXTERN int stop_insert_mode; // for ":stopinsert"
-EXTERN bool KeyTyped; // true if user typed current char
-EXTERN int KeyStuffed; // true if current char from stuffbuf
-EXTERN int maptick INIT(= 0); // tick for each non-mapped char
+EXTERN int ex_normal_busy INIT(= 0); // recursiveness of ex_normal()
+EXTERN int expr_map_lock INIT(= 0); // running expr mapping, prevent use of ex_normal() and text changes
+EXTERN bool ignore_script INIT(= false); // ignore script input
+EXTERN int stop_insert_mode; // for ":stopinsert"
+EXTERN bool KeyTyped; // true if user typed current char
+EXTERN int KeyStuffed; // true if current char from stuffbuf
+EXTERN int maptick INIT(= 0); // tick for each non-mapped char
EXTERN int must_redraw INIT(= 0); // type of redraw necessary
EXTERN bool skip_redraw INIT(= false); // skip redraw once
@@ -776,7 +776,7 @@ EXTERN int replace_offset INIT(= 0); // offset for replace_push()
EXTERN char *escape_chars INIT(= " \t\\\"|"); // need backslash in cmd line
-EXTERN int keep_help_flag INIT(= false); // doing :ta from help file
+EXTERN bool keep_help_flag INIT(= false); // doing :ta from help file
// When a string option is NULL (which only happens in out-of-memory
// situations), it is set to empty_option, to avoid having to check for NULL
diff --git a/src/nvim/grid.c b/src/nvim/grid.c
index cd70e98047..3c4b1e9d70 100644
--- a/src/nvim/grid.c
+++ b/src/nvim/grid.c
@@ -197,10 +197,10 @@ void grid_put_schar(ScreenGrid *grid, int row, int col, char *schar, int attr)
/// like grid_puts(), but output "text[len]". When "len" is -1 output up to
/// a NUL.
-int grid_puts_len(ScreenGrid *grid, char *text, int textlen, int row, int col, int attr)
+int grid_puts_len(ScreenGrid *grid, const char *text, int textlen, int row, int col, int attr)
{
size_t off;
- char *ptr = text;
+ const char *ptr = text;
int len = textlen;
int c;
size_t max_off;
diff --git a/src/nvim/highlight_group.c b/src/nvim/highlight_group.c
index 38af2a708a..cce124de77 100644
--- a/src/nvim/highlight_group.c
+++ b/src/nvim/highlight_group.c
@@ -218,6 +218,8 @@ static const char *highlight_init_both[] = {
"default link DiagnosticSignInfo DiagnosticInfo",
"default link DiagnosticSignHint DiagnosticHint",
"default link DiagnosticSignOk DiagnosticOk",
+ "default DiagnosticDeprecated cterm=strikethrough gui=strikethrough guisp=Red",
+ "default link DiagnosticUnnecessary Comment",
// Text
"default link @text.literal Comment",
@@ -795,9 +797,9 @@ void set_hl_group(int id, HlAttrs attrs, Dict(highlight) *dict, int link_id)
}
HlGroup *g = &hl_table[idx];
+ g->sg_cleared = false;
if (link_id > 0) {
- g->sg_cleared = false;
g->sg_link = link_id;
g->sg_script_ctx = current_sctx;
g->sg_script_ctx.sc_lnum += SOURCING_LNUM;
@@ -807,11 +809,10 @@ void set_hl_group(int id, HlAttrs attrs, Dict(highlight) *dict, int link_id)
g->sg_deflink_sctx = current_sctx;
g->sg_deflink_sctx.sc_lnum += SOURCING_LNUM;
}
- goto update;
+ } else {
+ g->sg_link = 0;
}
- g->sg_cleared = false;
- g->sg_link = 0;
g->sg_gui = attrs.rgb_ae_attr;
g->sg_rgb_fg = attrs.rgb_fg_color;
@@ -863,7 +864,6 @@ void set_hl_group(int id, HlAttrs attrs, Dict(highlight) *dict, int link_id)
}
}
-update:
if (!updating_screen) {
redraw_all_later(UPD_NOT_VALID);
}
@@ -1531,17 +1531,15 @@ static bool hlgroup2dict(Dictionary *hl, NS ns_id, int hl_id, Arena *arena)
}
HlAttrs attr =
syn_attr2entry(ns_id == 0 ? sgp->sg_attr : ns_get_hl(&ns_id, hl_id, false, sgp->sg_set));
+ *hl = arena_dict(arena, HLATTRS_DICT_SIZE + 1);
if (link > 0) {
- *hl = arena_dict(arena, 1);
PUT_C(*hl, "link", STRING_OBJ(cstr_as_string(hl_table[link - 1].sg_name)));
- } else {
- *hl = arena_dict(arena, HLATTRS_DICT_SIZE);
- Dictionary hl_cterm = arena_dict(arena, HLATTRS_DICT_SIZE);
- hlattrs2dict(hl, NULL, attr, true, true);
- hlattrs2dict(hl, &hl_cterm, attr, false, true);
- if (kv_size(hl_cterm)) {
- PUT_C(*hl, "cterm", DICTIONARY_OBJ(hl_cterm));
- }
+ }
+ Dictionary hl_cterm = arena_dict(arena, HLATTRS_DICT_SIZE);
+ hlattrs2dict(hl, NULL, attr, true, true);
+ hlattrs2dict(hl, &hl_cterm, attr, false, true);
+ if (kv_size(hl_cterm)) {
+ PUT_C(*hl, "cterm", DICTIONARY_OBJ(hl_cterm));
}
return true;
}
@@ -1633,7 +1631,7 @@ static bool highlight_list_arg(const int id, bool didh, const int type, int iarg
}
}
- (void)syn_list_header(didh, vim_strsize((char *)ts) + (int)strlen(name) + 1, id, false);
+ (void)syn_list_header(didh, vim_strsize(ts) + (int)strlen(name) + 1, id, false);
didh = true;
if (!got_int) {
if (*name != NUL) {
diff --git a/src/nvim/keycodes.c b/src/nvim/keycodes.c
index f3d379c2e9..8eec9014f7 100644
--- a/src/nvim/keycodes.c
+++ b/src/nvim/keycodes.c
@@ -34,18 +34,18 @@
static const struct modmasktable {
uint16_t mod_mask; ///< Bit-mask for particular key modifier.
uint16_t mod_flag; ///< Bit(s) for particular key modifier.
- char_u name; ///< Single letter name of modifier.
+ char name; ///< Single letter name of modifier.
} mod_mask_table[] = {
- { MOD_MASK_ALT, MOD_MASK_ALT, (char_u)'M' },
- { MOD_MASK_META, MOD_MASK_META, (char_u)'T' },
- { MOD_MASK_CTRL, MOD_MASK_CTRL, (char_u)'C' },
- { MOD_MASK_SHIFT, MOD_MASK_SHIFT, (char_u)'S' },
- { MOD_MASK_MULTI_CLICK, MOD_MASK_2CLICK, (char_u)'2' },
- { MOD_MASK_MULTI_CLICK, MOD_MASK_3CLICK, (char_u)'3' },
- { MOD_MASK_MULTI_CLICK, MOD_MASK_4CLICK, (char_u)'4' },
- { MOD_MASK_CMD, MOD_MASK_CMD, (char_u)'D' },
+ { MOD_MASK_ALT, MOD_MASK_ALT, 'M' },
+ { MOD_MASK_META, MOD_MASK_META, 'T' },
+ { MOD_MASK_CTRL, MOD_MASK_CTRL, 'C' },
+ { MOD_MASK_SHIFT, MOD_MASK_SHIFT, 'S' },
+ { MOD_MASK_MULTI_CLICK, MOD_MASK_2CLICK, '2' },
+ { MOD_MASK_MULTI_CLICK, MOD_MASK_3CLICK, '3' },
+ { MOD_MASK_MULTI_CLICK, MOD_MASK_4CLICK, '4' },
+ { MOD_MASK_CMD, MOD_MASK_CMD, 'D' },
// 'A' must be the last one
- { MOD_MASK_ALT, MOD_MASK_ALT, (char_u)'A' },
+ { MOD_MASK_ALT, MOD_MASK_ALT, 'A' },
{ 0, 0, NUL }
// NOTE: when adding an entry, update MAX_KEY_NAME_LEN!
};
@@ -386,7 +386,7 @@ int name_to_mod_mask(int c)
{
c = TOUPPER_ASC(c);
for (size_t i = 0; mod_mask_table[i].mod_mask != 0; i++) {
- if (c == mod_mask_table[i].name) {
+ if (c == (uint8_t)mod_mask_table[i].name) {
return mod_mask_table[i].mod_flag;
}
}
@@ -468,9 +468,9 @@ int handle_x_keys(const int key)
}
/// @return a string which contains the name of the given key when the given modifiers are down.
-char_u *get_special_key_name(int c, int modifiers)
+char *get_special_key_name(int c, int modifiers)
{
- static char_u string[MAX_KEY_NAME_LEN + 1];
+ static char string[MAX_KEY_NAME_LEN + 1];
int i, idx;
int table_idx;
@@ -524,7 +524,7 @@ char_u *get_special_key_name(int c, int modifiers)
if ((modifiers & mod_mask_table[i].mod_mask)
== mod_mask_table[i].mod_flag) {
string[idx++] = mod_mask_table[i].name;
- string[idx++] = (char_u)'-';
+ string[idx++] = '-';
}
}
@@ -532,18 +532,18 @@ char_u *get_special_key_name(int c, int modifiers)
if (IS_SPECIAL(c)) {
string[idx++] = 't';
string[idx++] = '_';
- string[idx++] = (char_u)KEY2TERMCAP0(c);
- string[idx++] = KEY2TERMCAP1(c);
+ string[idx++] = (char)(uint8_t)KEY2TERMCAP0(c);
+ string[idx++] = (char)(uint8_t)KEY2TERMCAP1(c);
} else {
// Not a special key, only modifiers, output directly.
if (utf_char2len(c) > 1) {
- idx += utf_char2bytes(c, (char *)string + idx);
+ idx += utf_char2bytes(c, string + idx);
} else if (vim_isprintc(c)) {
- string[idx++] = (char_u)c;
+ string[idx++] = (char)(uint8_t)c;
} else {
s = transchar(c);
while (*s) {
- string[idx++] = (uint8_t)(*s++);
+ string[idx++] = *s++;
}
}
}
@@ -1083,7 +1083,7 @@ char *vim_strsave_escape_ks(char *p)
/// vim_strsave_escape_ks(). Works in-place.
void vim_unescape_ks(char *p)
{
- char_u *s = (char_u *)p, *d = (char_u *)p;
+ uint8_t *s = (uint8_t *)p, *d = (uint8_t *)p;
while (*s != NUL) {
if (s[0] == K_SPECIAL && s[1] == KS_SPECIAL && s[2] == KE_FILLER) {
diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c
index dfbbfe9ab5..b5dd7a3e78 100644
--- a/src/nvim/lua/executor.c
+++ b/src/nvim/lua/executor.c
@@ -623,7 +623,7 @@ static bool nlua_init_packages(lua_State *lstate, bool is_standalone)
lua_getglobal(lstate, "require");
lua_pushstring(lstate, "vim._init_packages");
if (nlua_pcall(lstate, 1, 0)) {
- os_errmsg((char *)lua_tostring(lstate, -1));
+ os_errmsg(lua_tostring(lstate, -1));
os_errmsg("\n");
return false;
}
diff --git a/src/nvim/lua/stdlib.c b/src/nvim/lua/stdlib.c
index ee5676e927..20a99b2836 100644
--- a/src/nvim/lua/stdlib.c
+++ b/src/nvim/lua/stdlib.c
@@ -288,7 +288,7 @@ int nlua_regex(lua_State *lstate)
regprog_T *prog = NULL;
TRY_WRAP(&err, {
- prog = vim_regcomp((char *)text, RE_AUTO | RE_MAGIC | RE_STRICT);
+ prog = vim_regcomp(text, RE_AUTO | RE_MAGIC | RE_STRICT);
});
if (ERROR_SET(&err)) {
diff --git a/src/nvim/main.c b/src/nvim/main.c
index a16badc1a0..1f16ecff76 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -2153,7 +2153,7 @@ static void print_mainerr(const char *errstr, const char *str)
os_errmsg(_(errstr));
if (str != NULL) {
os_errmsg(": \"");
- os_errmsg((char *)str);
+ os_errmsg(str);
os_errmsg("\"");
}
os_errmsg(_("\nMore info with \""));
diff --git a/src/nvim/mapping.c b/src/nvim/mapping.c
index 5cedc5e97d..2941d5965b 100644
--- a/src/nvim/mapping.c
+++ b/src/nvim/mapping.c
@@ -1189,7 +1189,7 @@ static char *translate_mapping(char *str_in, int cpo_flags)
str += 2;
}
if (IS_SPECIAL(c) || modifiers) { // special key
- ga_concat(&ga, (char *)get_special_key_name(c, modifiers));
+ ga_concat(&ga, get_special_key_name(c, modifiers));
continue; // for (str)
}
}
@@ -1436,7 +1436,7 @@ int ExpandMappings(char *pat, regmatch_T *regmatch, int *numMatches, char ***mat
bool check_abbr(int c, char *ptr, int col, int mincol)
{
int scol; // starting column of the abbr.
- char_u tb[MB_MAXBYTES + 4];
+ uint8_t tb[MB_MAXBYTES + 4];
mapblock_T *mp;
mapblock_T *mp2;
int clen = 0; // length in characters
@@ -1535,8 +1535,8 @@ bool check_abbr(int c, char *ptr, int col, int mincol)
// special key code, split up
if (IS_SPECIAL(c) || c == K_SPECIAL) {
tb[j++] = K_SPECIAL;
- tb[j++] = (char_u)K_SECOND(c);
- tb[j++] = (char_u)K_THIRD(c);
+ tb[j++] = (uint8_t)K_SECOND(c);
+ tb[j++] = (uint8_t)K_THIRD(c);
} else {
if (c < ABBR_OFF && (c < ' ' || c > '~')) {
tb[j++] = Ctrl_V; // special char needs CTRL-V
@@ -1918,7 +1918,7 @@ int put_escstr(FILE *fd, char *strstart, int what)
str += 2;
}
if (IS_SPECIAL(c) || modifiers) { // special key
- if (fputs((char *)get_special_key_name(c, modifiers), fd) < 0) {
+ if (fputs(get_special_key_name(c, modifiers), fd) < 0) {
return FAIL;
}
continue;
diff --git a/src/nvim/match.c b/src/nvim/match.c
index 93c8a58051..29d4b7c225 100644
--- a/src/nvim/match.c
+++ b/src/nvim/match.c
@@ -98,7 +98,7 @@ static int match_add(win_T *wp, const char *const grp, const char *const pat, in
if ((hlg_id = syn_check_group(grp, strlen(grp))) == 0) {
return -1;
}
- if (pat != NULL && (regprog = vim_regcomp((char *)pat, RE_MAGIC)) == NULL) {
+ if (pat != NULL && (regprog = vim_regcomp(pat, RE_MAGIC)) == NULL) {
semsg(_(e_invarg2), pat);
return -1;
}
@@ -1232,7 +1232,7 @@ void ex_match(exarg_T *eap)
if (!eap->skip) {
if (*end != NUL && !ends_excmd(*skipwhite(end + 1))) {
xfree(g);
- eap->errmsg = ex_errmsg(e_trailing_arg, (const char *)end);
+ eap->errmsg = ex_errmsg(e_trailing_arg, end);
return;
}
if (*end != *p) {
@@ -1243,8 +1243,7 @@ void ex_match(exarg_T *eap)
c = (uint8_t)(*end);
*end = NUL;
- match_add(curwin, (const char *)g, (const char *)p + 1, 10, id,
- NULL, NULL);
+ match_add(curwin, g, p + 1, 10, id, NULL, NULL);
xfree(g);
*end = (char)c;
}
diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c
index fb52a11025..c580dc29e6 100644
--- a/src/nvim/mbyte.c
+++ b/src/nvim/mbyte.c
@@ -653,32 +653,32 @@ int utf_ptr2char(const char *const p_in)
//
// If byte sequence is illegal or incomplete, returns -1 and does not advance
// "s".
-static int utf_safe_read_char_adv(const char_u **s, size_t *n)
+static int utf_safe_read_char_adv(const char **s, size_t *n)
{
if (*n == 0) { // end of buffer
return 0;
}
- uint8_t k = utf8len_tab_zero[**s];
+ uint8_t k = utf8len_tab_zero[(uint8_t)(**s)];
if (k == 1) {
// ASCII character or NUL
(*n)--;
- return *(*s)++;
+ return (uint8_t)(*(*s)++);
}
if (k <= *n) {
// We have a multibyte sequence and it isn't truncated by buffer
// limits so utf_ptr2char() is safe to use. Or the first byte is
// illegal (k=0), and it's also safe to use utf_ptr2char().
- int c = utf_ptr2char((char *)(*s));
+ int c = utf_ptr2char(*s);
// On failure, utf_ptr2char() returns the first byte, so here we
// check equality with the first byte. The only non-ASCII character
// which equals the first byte of its own UTF-8 representation is
// U+00C3 (UTF-8: 0xC3 0x83), so need to check that special case too.
// It's safe even if n=1, else we would have k=2 > n.
- if (c != (int)(**s) || (c == 0xC3 && (*s)[1] == 0x83)) {
+ if (c != (int)((uint8_t)(**s)) || (c == 0xC3 && (uint8_t)(*s)[1] == 0x83)) {
// byte sequence was successfully decoded
*s += k;
*n -= k;
@@ -1271,7 +1271,7 @@ bool mb_isalpha(int a)
return mb_islower(a) || mb_isupper(a);
}
-static int utf_strnicmp(const char_u *s1, const char_u *s2, size_t n1, size_t n2)
+static int utf_strnicmp(const char *s1, const char *s2, size_t n1, size_t n2)
{
int c1, c2, cdiff;
char buffer[6];
@@ -1313,14 +1313,14 @@ static int utf_strnicmp(const char_u *s1, const char_u *s2, size_t n1, size_t n2
if (c1 != -1 && c2 == -1) {
n1 = (size_t)utf_char2bytes(utf_fold(c1), (char *)buffer);
- s1 = (char_u *)buffer;
+ s1 = buffer;
} else if (c2 != -1 && c1 == -1) {
n2 = (size_t)utf_char2bytes(utf_fold(c2), (char *)buffer);
- s2 = (char_u *)buffer;
+ s2 = buffer;
}
while (n1 > 0 && n2 > 0 && *s1 != NUL && *s2 != NUL) {
- cdiff = (int)(*s1) - (int)(*s2);
+ cdiff = (int)((uint8_t)(*s1)) - (int)((uint8_t)(*s2));
if (cdiff != 0) {
return cdiff;
}
@@ -1498,7 +1498,7 @@ ssize_t mb_utf_index_to_bytes(const char *s, size_t len, size_t index, bool use_
/// two characters otherwise.
int mb_strnicmp(const char *s1, const char *s2, const size_t nn)
{
- return utf_strnicmp((char_u *)s1, (char_u *)s2, nn, nn);
+ return utf_strnicmp(s1, s2, nn, nn);
}
/// Compare strings case-insensitively
diff --git a/src/nvim/memline.c b/src/nvim/memline.c
index 0f2790b06c..51a4186775 100644
--- a/src/nvim/memline.c
+++ b/src/nvim/memline.c
@@ -351,7 +351,7 @@ int ml_open(buf_T *buf)
dp->db_index[0] = --dp->db_txt_start; // at end of block
dp->db_free -= 1 + (unsigned)INDEX_SIZE;
dp->db_line_count = 1;
- *((char_u *)dp + dp->db_txt_start) = NUL; // empty line
+ *((char *)dp + dp->db_txt_start) = NUL; // empty line
return OK;
@@ -1065,7 +1065,7 @@ void ml_recover(bool checkext)
}
// make sure there is a NUL at the end of the block
- *((char_u *)dp + dp->db_txt_end - 1) = NUL;
+ *((char *)dp + dp->db_txt_end - 1) = NUL;
// check number of lines in block
// if wrong, use count in data block
diff --git a/src/nvim/message.c b/src/nvim/message.c
index aecb46c6bd..b43bc6ce9b 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -216,13 +216,13 @@ void msg_grid_validate(void)
/// When terminal not initialized (yet) os_errmsg(..) is used.
///
/// @return true if wait_return() not called
-int msg(char *s)
+int msg(const char *s)
{
return msg_attr_keep(s, 0, false, false);
}
/// Like msg() but keep it silent when 'verbosefile' is set.
-int verb_msg(char *s)
+int verb_msg(const char *s)
{
verbose_enter();
int n = msg_attr_keep(s, 0, false, false);
@@ -278,8 +278,7 @@ void msg_multiattr(HlMessage hl_msg, const char *kind, bool history)
msg_ext_set_kind(kind);
for (uint32_t i = 0; i < kv_size(hl_msg); i++) {
HlMessageChunk chunk = kv_A(hl_msg, i);
- msg_multiline_attr((const char *)chunk.text.data, chunk.attr,
- true, &need_clear);
+ msg_multiline_attr(chunk.text.data, chunk.attr, true, &need_clear);
}
if (history && kv_size(hl_msg)) {
add_msg_hist_multiattr(NULL, 0, 0, true, hl_msg);
@@ -305,7 +304,7 @@ bool msg_attr_keep(const char *s, int attr, bool keep, bool multiline)
// Skip messages not match ":filter pattern".
// Don't filter when there is an error.
- if (!emsg_on_display && message_filtered((char *)s)) {
+ if (!emsg_on_display && message_filtered(s)) {
return true;
}
@@ -333,7 +332,7 @@ bool msg_attr_keep(const char *s, int attr, bool keep, bool multiline)
// Truncate the message if needed.
msg_start();
- buf = msg_strtrunc((char *)s, false);
+ buf = msg_strtrunc(s, false);
if (buf != NULL) {
s = buf;
}
@@ -349,8 +348,8 @@ bool msg_attr_keep(const char *s, int attr, bool keep, bool multiline)
}
retval = msg_end();
- if (keep && retval && vim_strsize((char *)s) < (Rows - cmdline_row - 1) * Columns + sc_col) {
- set_keep_msg((char *)s, 0);
+ if (keep && retval && vim_strsize(s) < (Rows - cmdline_row - 1) * Columns + sc_col) {
+ set_keep_msg(s, 0);
}
need_fileinfo = false;
@@ -365,7 +364,7 @@ bool msg_attr_keep(const char *s, int attr, bool keep, bool multiline)
/// @return an allocated string or NULL when no truncating is done.
///
/// @param force always truncate
-char *msg_strtrunc(char *s, int force)
+char *msg_strtrunc(const char *s, int force)
{
char *buf = NULL;
@@ -395,7 +394,7 @@ char *msg_strtrunc(char *s, int force)
/// Truncate a string "s" to "buf" with cell width "room".
/// "s" and "buf" may be equal.
-void trunc_string(char *s, char *buf, int room_in, int buflen)
+void trunc_string(const char *s, char *buf, int room_in, int buflen)
{
int room = room_in - 3; // "..." takes 3 chars
int half;
@@ -503,7 +502,7 @@ int smsg_attr(int attr, const char *s, ...)
va_start(arglist, s);
vim_vsnprintf(IObuff, IOSIZE, s, arglist);
va_end(arglist);
- return msg_attr((const char *)IObuff, attr);
+ return msg_attr(IObuff, attr);
}
int smsg_attr_keep(int attr, const char *s, ...)
@@ -514,7 +513,7 @@ int smsg_attr_keep(int attr, const char *s, ...)
va_start(arglist, s);
vim_vsnprintf(IObuff, IOSIZE, s, arglist);
va_end(arglist);
- return msg_attr_keep((const char *)IObuff, attr, true, false);
+ return msg_attr_keep(IObuff, attr, true, false);
}
// Remember the last sourcing name/lnum used in an error message, so that it
@@ -862,7 +861,7 @@ void siemsg(const char *s, ...)
}
/// Give an "Internal error" message.
-void internal_error(char *where)
+void internal_error(const char *where)
{
siemsg(_(e_intern2), where);
}
@@ -1327,7 +1326,7 @@ static void hit_return_msg(void)
}
/// Set "keep_msg" to "s". Free the old value and check for NULL pointer.
-void set_keep_msg(char *s, int attr)
+void set_keep_msg(const char *s, int attr)
{
xfree(keep_msg);
if (s != NULL && msg_silent == 0) {
@@ -1562,7 +1561,7 @@ int msg_outtrans_len_attr(const char *msgstr, int len, int attr)
// If the string starts with a composing character first draw a space on
// which the composing char can be drawn.
- if (utf_iscomposing(utf_ptr2char((char *)msgstr))) {
+ if (utf_iscomposing(utf_ptr2char(msgstr))) {
msg_puts_attr(" ", attr);
}
@@ -1590,7 +1589,7 @@ int msg_outtrans_len_attr(const char *msgstr, int len, int attr)
len -= mb_l - 1;
str += mb_l;
} else {
- s = (char *)transchar_byte_buf(NULL, (uint8_t)(*str));
+ s = transchar_byte_buf(NULL, (uint8_t)(*str));
if (s[1] != NUL) {
// Unprintable char: print the printable chars so far and the
// translation of the unprintable char.
@@ -1598,7 +1597,7 @@ int msg_outtrans_len_attr(const char *msgstr, int len, int attr)
msg_puts_attr_len(plain_start, str - plain_start, attr);
}
plain_start = str + 1;
- msg_puts_attr((const char *)s, attr == 0 ? HL_ATTR(HLF_8) : attr);
+ msg_puts_attr(s, attr == 0 ? HL_ATTR(HLF_8) : attr);
retval += (int)strlen(s);
} else {
retval++;
@@ -1672,9 +1671,9 @@ int msg_outtrans_special(const char *strstart, bool from, int maxlen)
}
if (text[0] != NUL && text[1] == NUL) {
// single-byte character or illegal byte
- text = (char *)transchar_byte_buf(NULL, (uint8_t)text[0]);
+ text = transchar_byte_buf(NULL, (uint8_t)text[0]);
}
- const int len = vim_strsize((char *)text);
+ const int len = vim_strsize(text);
if (maxlen > 0 && retval + len >= maxlen) {
break;
}
@@ -1918,7 +1917,7 @@ void msg_prt_line(char *s, int list)
s--;
} else if (c != NUL && (n = byte2cells(c)) > 1) {
n_extra = n - 1;
- p_extra = (char *)transchar_byte_buf(NULL, c);
+ p_extra = transchar_byte_buf(NULL, c);
c_extra = NUL;
c_final = NUL;
c = (unsigned char)(*p_extra++);
@@ -1966,7 +1965,7 @@ void msg_prt_line(char *s, int list)
/// Use grid_puts() to output one multi-byte character.
///
/// @return the pointer "s" advanced to the next character.
-static char *screen_puts_mbyte(char *s, int l, int attr)
+static const char *screen_puts_mbyte(const char *s, int l, int attr)
{
int cw;
attr = hl_combine_attr(HL_ATTR(HLF_MSG), attr);
@@ -2212,7 +2211,7 @@ static void msg_puts_display(const char *str, int maxlen, int attr, int recurse)
} else {
l = utfc_ptr2len(s);
}
- s = screen_puts_mbyte((char *)s, l, attr);
+ s = screen_puts_mbyte(s, l, attr);
did_last_char = true;
} else {
did_last_char = false;
@@ -2229,7 +2228,7 @@ static void msg_puts_display(const char *str, int maxlen, int attr, int recurse)
if (p_more) {
// Store text for scrolling back.
- store_sb_text((char **)&sb_str, (char *)s, attr, &sb_col, true);
+ store_sb_text(&sb_str, s, attr, &sb_col, true);
}
inc_msg_scrolled();
@@ -2274,7 +2273,7 @@ static void msg_puts_display(const char *str, int maxlen, int attr, int recurse)
if (wrap && p_more && !recurse) {
// Store text for scrolling back.
- store_sb_text((char **)&sb_str, (char *)s, attr, &sb_col, true);
+ store_sb_text(&sb_str, s, attr, &sb_col, true);
}
if (*s == '\n') { // go to next line
@@ -2312,7 +2311,7 @@ static void msg_puts_display(const char *str, int maxlen, int attr, int recurse)
// characters and draw them all at once later.
if (cmdmsg_rl || (cw > 1 && msg_col + t_col >= Columns - 1)) {
if (l > 1) {
- s = screen_puts_mbyte((char *)s, l, attr) - 1;
+ s = screen_puts_mbyte(s, l, attr) - 1;
} else {
msg_screen_putchar(*s, attr);
}
@@ -2333,7 +2332,7 @@ static void msg_puts_display(const char *str, int maxlen, int attr, int recurse)
t_puts(&t_col, t_s, s, attr);
}
if (p_more && !recurse && !(s == sb_str + 1 && *sb_str == '\n')) {
- store_sb_text((char **)&sb_str, (char *)s, attr, &sb_col, false);
+ store_sb_text(&sb_str, s, attr, &sb_col, false);
}
msg_check();
@@ -2341,7 +2340,7 @@ static void msg_puts_display(const char *str, int maxlen, int attr, int recurse)
/// @return true when ":filter pattern" was used and "msg" does not match
/// "pattern".
-bool message_filtered(char *msg)
+bool message_filtered(const char *msg)
{
if (cmdmod.cmod_filter_regmatch.regprog == NULL) {
return false;
@@ -2507,7 +2506,7 @@ static sb_clear_T do_clear_sb_text = SB_CLEAR_NONE;
/// @param sb_str start of string
/// @param s just after string
/// @param finish line ends
-static void store_sb_text(char **sb_str, char *s, int attr, int *sb_col, int finish)
+static void store_sb_text(const char **sb_str, const char *s, int attr, int *sb_col, int finish)
{
msgchunk_T *mp;
@@ -2681,7 +2680,7 @@ static void t_puts(int *t_col, const char *t_s, const char *s, int attr)
attr = hl_combine_attr(HL_ATTR(HLF_MSG), attr);
// Output postponed text.
msg_didout = true; // Remember that line is not empty.
- grid_puts_len(&msg_grid_adj, (char *)t_s, (int)(s - t_s), msg_row, msg_col, attr);
+ grid_puts_len(&msg_grid_adj, t_s, (int)(s - t_s), msg_row, msg_col, attr);
msg_col += *t_col;
*t_col = 0;
// If the string starts with a composing character don't increment the
@@ -3308,7 +3307,7 @@ static void redir_write(const char *const str, const ptrdiff_t maxlen)
write_reg_contents(redir_reg, s, (ssize_t)len, true);
}
if (redir_vname) {
- var_redir_str((char *)s, (int)maxlen);
+ var_redir_str(s, (int)maxlen);
}
// Write and adjust the current column.
@@ -3417,7 +3416,7 @@ int verbose_open(void)
/// Give a warning message (for searching).
/// Use 'w' highlighting and may repeat the message after redrawing
-void give_warning(char *message, bool hl)
+void give_warning(const char *message, bool hl)
FUNC_ATTR_NONNULL_ARG(1)
{
// Don't do this for ":silent".
@@ -3440,7 +3439,7 @@ void give_warning(char *message, bool hl)
msg_ext_set_kind("wmsg");
}
- if (msg_attr((const char *)message, keep_msg_attr) && msg_scrolled == 0) {
+ if (msg_attr(message, keep_msg_attr) && msg_scrolled == 0) {
set_keep_msg(message, keep_msg_attr);
}
msg_didout = false; // Overwrite this message.
@@ -3450,7 +3449,7 @@ void give_warning(char *message, bool hl)
no_wait_return--;
}
-void give_warning2(char *const message, char *const a1, bool hl)
+void give_warning2(const char *const message, const char *const a1, bool hl)
{
vim_snprintf(IObuff, IOSIZE, message, a1);
give_warning(IObuff, hl);
diff --git a/src/nvim/move.c b/src/nvim/move.c
index a9f7ffaa76..e74dc32fd4 100644
--- a/src/nvim/move.c
+++ b/src/nvim/move.c
@@ -2241,7 +2241,7 @@ void do_check_cursorbind(void)
int old_VIsual_active = VIsual_active;
// loop through the cursorbound windows
- VIsual_select = VIsual_active = 0;
+ VIsual_select = VIsual_active = false;
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
curwin = wp;
curbuf = curwin->w_buffer;
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index 2edd1772ca..d66ed9abff 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -5162,7 +5162,7 @@ void write_reg_contents_ex(int name, const char *str, ssize_t len, bool must_app
/// @param str string or list of strings to put in register
/// @param len length of the string (Ignored when str_list=true.)
/// @param blocklen width of visual block, or -1 for "I don't know."
-/// @param str_list True if str is `char_u **`.
+/// @param str_list True if str is `char **`.
static void str_to_reg(yankreg_T *y_ptr, MotionType yank_type, const char *str, size_t len,
colnr_T blocklen, bool str_list)
FUNC_ATTR_NONNULL_ALL
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 0aa2f8ab04..8fa719c3a9 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -421,7 +421,7 @@ static void set_option_default(const int opt_idx, int opt_flags)
// pointer to variable for current option
vimoption_T *opt = &options[opt_idx];
- char_u *varp = (char_u *)get_varp_scope(opt, both ? OPT_LOCAL : opt_flags);
+ char *varp = get_varp_scope(opt, both ? OPT_LOCAL : opt_flags);
uint32_t flags = opt->flags;
if (varp != NULL) { // skip hidden option, nothing to do for it
if (flags & P_STRING) {
@@ -833,7 +833,7 @@ static void do_set_num(int opt_idx, int opt_flags, char **argp, int nextchar, co
if (op == OP_REMOVING) {
value = *(long *)varp - value;
}
- *errmsg = set_num_option(opt_idx, (char_u *)varp, (long)value,
+ *errmsg = set_num_option(opt_idx, (char *)varp, (long)value,
errbuf, errbuflen, opt_flags);
}
@@ -847,7 +847,7 @@ static void munge_string_opt_val(char **varp, char **oldval, char **const origva
if (varp == &p_kp && (**argp == NUL || **argp == ' ')) {
*save_argp = *argp;
*argp = ":help";
- } else if (varp == &p_bs && ascii_isdigit(**(char_u **)varp)) {
+ } else if (varp == &p_bs && ascii_isdigit((uint8_t)(**varp))) {
// Convert 'backspace' number to string, for
// adding, prepending and removing string.
const int i = getdigits_int(varp, true, 0);
@@ -927,7 +927,7 @@ static void do_set_string(int opt_idx, int opt_flags, char **argp, int nextchar,
// reset, use the global value here.
if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
&& ((int)options[opt_idx].indir & PV_BOTH)) {
- varp = (char *)options[opt_idx].var;
+ varp = options[opt_idx].var;
}
// The old value is kept until we are sure that the new value is valid.
@@ -1439,7 +1439,7 @@ static void do_set_option(int opt_flags, char **argp, bool *did_show, char *errb
showoneopt(&options[opt_idx], opt_flags);
if (p_verbose > 0) {
// Mention where the option was last set.
- if (varp == (char *)options[opt_idx].var) {
+ if (varp == options[opt_idx].var) {
option_last_set_msg(options[opt_idx].last_set);
} else if ((int)options[opt_idx].indir & PV_WIN) {
option_last_set_msg(curwin->w_p_script_ctx[(int)options[opt_idx].indir & PV_MASK]);
@@ -1735,7 +1735,7 @@ static char *option_expand(int opt_idx, char *val)
// For 'spellsuggest' expand after "file:".
expand_env_esc(val, NameBuff, MAXPATHL,
(char **)options[opt_idx].var == &p_tags, false,
- (char_u **)options[opt_idx].var == (char_u **)&p_sps ? "file:" :
+ (char **)options[opt_idx].var == &p_sps ? "file:" :
NULL);
if (strcmp(NameBuff, val) == 0) { // they are the same
return NULL;
@@ -2274,7 +2274,7 @@ static char *set_bool_option(const int opt_idx, char *const varp, const int valu
/// @param[in] opt_flags OPT_LOCAL, OPT_GLOBAL or OPT_MODELINE.
///
/// @return NULL on success, error message on error.
-static char *set_num_option(int opt_idx, char_u *varp, long value, char *errbuf, size_t errbuflen,
+static char *set_num_option(int opt_idx, char *varp, long value, char *errbuf, size_t errbuflen,
int opt_flags)
{
char *errmsg = NULL;
@@ -2905,7 +2905,7 @@ getoption_T get_option_value(const char *name, long *numval, char **stringval, u
return gov_unknown;
}
- char_u *varp = (char_u *)get_varp_scope(&(options[opt_idx]), scope);
+ char *varp = get_varp_scope(&(options[opt_idx]), scope);
if (flagsp != NULL) {
// Return the P_xxxx option flags.
@@ -3010,7 +3010,7 @@ int get_option_value_strict(char *name, int64_t *numval, char **stringval, int o
return rv;
}
- char_u *varp = NULL;
+ char *varp = NULL;
if (opt_type == SREQ_GLOBAL) {
if (p->var == VAR_WIN) {
@@ -3030,7 +3030,7 @@ int get_option_value_strict(char *name, int64_t *numval, char **stringval, int o
// only getting a pointer, no need to use aucmd_prepbuf()
curbuf = (buf_T *)from;
curwin->w_buffer = curbuf;
- varp = (char_u *)get_varp_scope(p, OPT_LOCAL);
+ varp = get_varp_scope(p, OPT_LOCAL);
curbuf = save_curbuf;
curwin->w_buffer = curbuf;
}
@@ -3038,7 +3038,7 @@ int get_option_value_strict(char *name, int64_t *numval, char **stringval, int o
win_T *save_curwin = curwin;
curwin = (win_T *)from;
curbuf = curwin->w_buffer;
- varp = (char_u *)get_varp_scope(p, OPT_LOCAL);
+ varp = get_varp_scope(p, OPT_LOCAL);
curwin = save_curwin;
curbuf = curwin->w_buffer;
}
@@ -3109,7 +3109,7 @@ char *set_option_value(const char *const name, const long number, const char *co
return set_string_option(opt_idx, s, opt_flags, errbuf, sizeof(errbuf));
}
- char_u *varp = (char_u *)get_varp_scope(&(options[opt_idx]), opt_flags);
+ char *varp = get_varp_scope(&(options[opt_idx]), opt_flags);
if (varp == NULL) {
// hidden option is not changed
return NULL;
@@ -3146,7 +3146,7 @@ char *set_option_value(const char *const name, const long number, const char *co
if (flags & P_NUM) {
return set_num_option(opt_idx, varp, numval, errbuf, sizeof(errbuf), opt_flags);
}
- return set_bool_option(opt_idx, (char *)varp, (int)numval, opt_flags);
+ return set_bool_option(opt_idx, varp, (int)numval, opt_flags);
}
/// Call set_option_value() and when an error is returned report it.
@@ -3243,7 +3243,7 @@ static void showoptions(bool all, int opt_flags)
varp = get_varp_scope(p, opt_flags);
}
} else {
- varp = (char *)get_varp(p);
+ varp = get_varp(p);
}
if (varp != NULL
&& (all == 1 || (all == 0 && !optval_default(p, varp)))) {
@@ -3349,7 +3349,7 @@ static void showoneopt(vimoption_T *p, int opt_flags)
silent_mode = false;
info_message = true; // use os_msg(), not os_errmsg()
- char_u *varp = (char_u *)get_varp_scope(p, opt_flags);
+ char *varp = get_varp_scope(p, opt_flags);
// for 'modified' we also need to check if 'ff' or 'fenc' changed.
if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed
@@ -3427,12 +3427,12 @@ int makeset(FILE *fd, int opt_flags, int local_only)
}
if ((opt_flags & OPT_SKIPRTP)
- && (p->var == (char_u *)&p_rtp || p->var == (char_u *)&p_pp)) {
+ && (p->var == (char *)&p_rtp || p->var == (char *)&p_pp)) {
continue;
}
int round = 2;
- char_u *varp_local = NULL; // fresh value
+ char *varp_local = NULL; // fresh value
if (p->indir != PV_NONE) {
if (p->var == VAR_WIN) {
// skip window-local option when only doing globals
@@ -3442,11 +3442,11 @@ int makeset(FILE *fd, int opt_flags, int local_only)
// When fresh value of window-local option is not at the
// default, need to write it too.
if (!(opt_flags & OPT_GLOBAL) && !local_only) {
- char_u *varp_fresh = (char_u *)get_varp_scope(p, OPT_GLOBAL); // local value
- if (!optval_default(p, (char *)varp_fresh)) {
+ char *varp_fresh = get_varp_scope(p, OPT_GLOBAL); // local value
+ if (!optval_default(p, varp_fresh)) {
round = 1;
- varp_local = (char_u *)varp;
- varp = (char *)varp_fresh;
+ varp_local = varp;
+ varp = varp_fresh;
}
}
}
@@ -3454,7 +3454,7 @@ int makeset(FILE *fd, int opt_flags, int local_only)
// Round 1: fresh value for window-local options.
// Round 2: other values
- for (; round <= 2; varp = (char *)varp_local, round++) {
+ for (; round <= 2; varp = varp_local, round++) {
char *cmd;
if (round == 1 || (opt_flags & OPT_GLOBAL)) {
cmd = "set";
@@ -3477,7 +3477,7 @@ int makeset(FILE *fd, int opt_flags, int local_only)
// already right, avoids reloading the syntax file.
if (p->indir == PV_SYN || p->indir == PV_FT) {
if (fprintf(fd, "if &%s != '%s'", p->fullname,
- *(char_u **)(varp)) < 0
+ *(char **)(varp)) < 0
|| put_eol(fd) < 0) {
return FAIL;
}
@@ -3524,7 +3524,7 @@ static int put_setstring(FILE *fd, char *cmd, char *name, char **valuep, uint64_
}
char *buf = NULL;
- char_u *part = NULL;
+ char *part = NULL;
if (*valuep != NULL) {
if ((flags & P_EXPAND) != 0) {
@@ -3552,8 +3552,8 @@ static int put_setstring(FILE *fd, char *cmd, char *name, char **valuep, uint64_
if (fprintf(fd, "%s %s+=", cmd, name) < 0) {
goto fail;
}
- (void)copy_option_part(&p, (char *)part, size, ",");
- if (put_escstr(fd, (char *)part, 2) == FAIL || put_eol(fd) == FAIL) {
+ (void)copy_option_part(&p, part, size, ",");
+ if (put_escstr(fd, part, 2) == FAIL || put_eol(fd) == FAIL) {
goto fail;
}
}
@@ -3586,9 +3586,9 @@ static int put_setnum(FILE *fd, char *cmd, char *name, long *valuep)
return FAIL;
}
long wc;
- if (wc_use_keyname((char_u *)valuep, &wc)) {
+ if (wc_use_keyname((char *)valuep, &wc)) {
// print 'wildchar' and 'wildcharm' as a key name
- if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0) {
+ if (fputs(get_special_key_name((int)wc, 0), fd) < 0) {
return FAIL;
}
} else if (fprintf(fd, "%" PRId64, (int64_t)(*valuep)) < 0) {
@@ -3727,7 +3727,7 @@ char *get_varp_scope_from(vimoption_T *p, int scope, buf_T *buf, win_T *win)
if (p->var == VAR_WIN) {
return GLOBAL_WO(get_varp_from(p, buf, win));
}
- return (char *)p->var;
+ return p->var;
}
if ((scope & OPT_LOCAL) && ((int)p->indir & PV_BOTH)) {
switch ((int)p->indir) {
@@ -3790,7 +3790,7 @@ char *get_varp_scope_from(vimoption_T *p, int scope, buf_T *buf, win_T *win)
}
return NULL; // "cannot happen"
}
- return (char *)get_varp_from(p, buf, win);
+ return get_varp_from(p, buf, win);
}
/// Get pointer to option variable, depending on local or global scope.
@@ -3801,7 +3801,7 @@ char *get_varp_scope(vimoption_T *p, int scope)
return get_varp_scope_from(p, scope, curbuf, curwin);
}
-static char_u *get_varp_from(vimoption_T *p, buf_T *buf, win_T *win)
+static char *get_varp_from(vimoption_T *p, buf_T *buf, win_T *win)
{
// hidden option, always return NULL
if (p->var == NULL) {
@@ -3815,308 +3815,308 @@ static char_u *get_varp_from(vimoption_T *p, buf_T *buf, win_T *win)
// global option with local value: use local value if it's been set
case PV_EP:
return *buf->b_p_ep != NUL
- ? (char_u *)&buf->b_p_ep : p->var;
+ ? (char *)&buf->b_p_ep : p->var;
case PV_KP:
return *buf->b_p_kp != NUL
- ? (char_u *)&buf->b_p_kp : p->var;
+ ? (char *)&buf->b_p_kp : p->var;
case PV_PATH:
return *buf->b_p_path != NUL
- ? (char_u *)&(buf->b_p_path) : p->var;
+ ? (char *)&(buf->b_p_path) : p->var;
case PV_AR:
return buf->b_p_ar >= 0
- ? (char_u *)&(buf->b_p_ar) : p->var;
+ ? (char *)&(buf->b_p_ar) : p->var;
case PV_TAGS:
return *buf->b_p_tags != NUL
- ? (char_u *)&(buf->b_p_tags) : p->var;
+ ? (char *)&(buf->b_p_tags) : p->var;
case PV_TC:
return *buf->b_p_tc != NUL
- ? (char_u *)&(buf->b_p_tc) : p->var;
+ ? (char *)&(buf->b_p_tc) : p->var;
case PV_SISO:
return win->w_p_siso >= 0
- ? (char_u *)&(win->w_p_siso) : p->var;
+ ? (char *)&(win->w_p_siso) : p->var;
case PV_SO:
return win->w_p_so >= 0
- ? (char_u *)&(win->w_p_so) : p->var;
+ ? (char *)&(win->w_p_so) : p->var;
case PV_BKC:
return *buf->b_p_bkc != NUL
- ? (char_u *)&(buf->b_p_bkc) : p->var;
+ ? (char *)&(buf->b_p_bkc) : p->var;
case PV_DEF:
return *buf->b_p_def != NUL
- ? (char_u *)&(buf->b_p_def) : p->var;
+ ? (char *)&(buf->b_p_def) : p->var;
case PV_INC:
return *buf->b_p_inc != NUL
- ? (char_u *)&(buf->b_p_inc) : p->var;
+ ? (char *)&(buf->b_p_inc) : p->var;
case PV_DICT:
return *buf->b_p_dict != NUL
- ? (char_u *)&(buf->b_p_dict) : p->var;
+ ? (char *)&(buf->b_p_dict) : p->var;
case PV_TSR:
return *buf->b_p_tsr != NUL
- ? (char_u *)&(buf->b_p_tsr) : p->var;
+ ? (char *)&(buf->b_p_tsr) : p->var;
case PV_TSRFU:
return *buf->b_p_tsrfu != NUL
- ? (char_u *)&(buf->b_p_tsrfu) : p->var;
+ ? (char *)&(buf->b_p_tsrfu) : p->var;
case PV_FP:
return *buf->b_p_fp != NUL
- ? (char_u *)&(buf->b_p_fp) : p->var;
+ ? (char *)&(buf->b_p_fp) : p->var;
case PV_EFM:
return *buf->b_p_efm != NUL
- ? (char_u *)&(buf->b_p_efm) : p->var;
+ ? (char *)&(buf->b_p_efm) : p->var;
case PV_GP:
return *buf->b_p_gp != NUL
- ? (char_u *)&(buf->b_p_gp) : p->var;
+ ? (char *)&(buf->b_p_gp) : p->var;
case PV_MP:
return *buf->b_p_mp != NUL
- ? (char_u *)&(buf->b_p_mp) : p->var;
+ ? (char *)&(buf->b_p_mp) : p->var;
case PV_SBR:
return *win->w_p_sbr != NUL
- ? (char_u *)&(win->w_p_sbr) : p->var;
+ ? (char *)&(win->w_p_sbr) : p->var;
case PV_STL:
return *win->w_p_stl != NUL
- ? (char_u *)&(win->w_p_stl) : p->var;
+ ? (char *)&(win->w_p_stl) : p->var;
case PV_WBR:
return *win->w_p_wbr != NUL
- ? (char_u *)&(win->w_p_wbr) : p->var;
+ ? (char *)&(win->w_p_wbr) : p->var;
case PV_UL:
return buf->b_p_ul != NO_LOCAL_UNDOLEVEL
- ? (char_u *)&(buf->b_p_ul) : p->var;
+ ? (char *)&(buf->b_p_ul) : p->var;
case PV_LW:
return *buf->b_p_lw != NUL
- ? (char_u *)&(buf->b_p_lw) : p->var;
+ ? (char *)&(buf->b_p_lw) : p->var;
case PV_MENC:
return *buf->b_p_menc != NUL
- ? (char_u *)&(buf->b_p_menc) : p->var;
+ ? (char *)&(buf->b_p_menc) : p->var;
case PV_FCS:
return *win->w_p_fcs != NUL
- ? (char_u *)&(win->w_p_fcs) : p->var;
+ ? (char *)&(win->w_p_fcs) : p->var;
case PV_LCS:
return *win->w_p_lcs != NUL
- ? (char_u *)&(win->w_p_lcs) : p->var;
+ ? (char *)&(win->w_p_lcs) : p->var;
case PV_VE:
return *win->w_p_ve != NUL
- ? (char_u *)&win->w_p_ve : p->var;
+ ? (char *)&win->w_p_ve : p->var;
case PV_ARAB:
- return (char_u *)&(win->w_p_arab);
+ return (char *)&(win->w_p_arab);
case PV_LIST:
- return (char_u *)&(win->w_p_list);
+ return (char *)&(win->w_p_list);
case PV_SPELL:
- return (char_u *)&(win->w_p_spell);
+ return (char *)&(win->w_p_spell);
case PV_CUC:
- return (char_u *)&(win->w_p_cuc);
+ return (char *)&(win->w_p_cuc);
case PV_CUL:
- return (char_u *)&(win->w_p_cul);
+ return (char *)&(win->w_p_cul);
case PV_CULOPT:
- return (char_u *)&(win->w_p_culopt);
+ return (char *)&(win->w_p_culopt);
case PV_CC:
- return (char_u *)&(win->w_p_cc);
+ return (char *)&(win->w_p_cc);
case PV_DIFF:
- return (char_u *)&(win->w_p_diff);
+ return (char *)&(win->w_p_diff);
case PV_FDC:
- return (char_u *)&(win->w_p_fdc);
+ return (char *)&(win->w_p_fdc);
case PV_FEN:
- return (char_u *)&(win->w_p_fen);
+ return (char *)&(win->w_p_fen);
case PV_FDI:
- return (char_u *)&(win->w_p_fdi);
+ return (char *)&(win->w_p_fdi);
case PV_FDL:
- return (char_u *)&(win->w_p_fdl);
+ return (char *)&(win->w_p_fdl);
case PV_FDM:
- return (char_u *)&(win->w_p_fdm);
+ return (char *)&(win->w_p_fdm);
case PV_FML:
- return (char_u *)&(win->w_p_fml);
+ return (char *)&(win->w_p_fml);
case PV_FDN:
- return (char_u *)&(win->w_p_fdn);
+ return (char *)&(win->w_p_fdn);
case PV_FDE:
- return (char_u *)&(win->w_p_fde);
+ return (char *)&(win->w_p_fde);
case PV_FDT:
- return (char_u *)&(win->w_p_fdt);
+ return (char *)&(win->w_p_fdt);
case PV_FMR:
- return (char_u *)&(win->w_p_fmr);
+ return (char *)&(win->w_p_fmr);
case PV_NU:
- return (char_u *)&(win->w_p_nu);
+ return (char *)&(win->w_p_nu);
case PV_RNU:
- return (char_u *)&(win->w_p_rnu);
+ return (char *)&(win->w_p_rnu);
case PV_NUW:
- return (char_u *)&(win->w_p_nuw);
+ return (char *)&(win->w_p_nuw);
case PV_WFH:
- return (char_u *)&(win->w_p_wfh);
+ return (char *)&(win->w_p_wfh);
case PV_WFW:
- return (char_u *)&(win->w_p_wfw);
+ return (char *)&(win->w_p_wfw);
case PV_PVW:
- return (char_u *)&(win->w_p_pvw);
+ return (char *)&(win->w_p_pvw);
case PV_RL:
- return (char_u *)&(win->w_p_rl);
+ return (char *)&(win->w_p_rl);
case PV_RLC:
- return (char_u *)&(win->w_p_rlc);
+ return (char *)&(win->w_p_rlc);
case PV_SCROLL:
- return (char_u *)&(win->w_p_scr);
+ return (char *)&(win->w_p_scr);
case PV_WRAP:
- return (char_u *)&(win->w_p_wrap);
+ return (char *)&(win->w_p_wrap);
case PV_LBR:
- return (char_u *)&(win->w_p_lbr);
+ return (char *)&(win->w_p_lbr);
case PV_BRI:
- return (char_u *)&(win->w_p_bri);
+ return (char *)&(win->w_p_bri);
case PV_BRIOPT:
- return (char_u *)&(win->w_p_briopt);
+ return (char *)&(win->w_p_briopt);
case PV_SCBIND:
- return (char_u *)&(win->w_p_scb);
+ return (char *)&(win->w_p_scb);
case PV_CRBIND:
- return (char_u *)&(win->w_p_crb);
+ return (char *)&(win->w_p_crb);
case PV_COCU:
- return (char_u *)&(win->w_p_cocu);
+ return (char *)&(win->w_p_cocu);
case PV_COLE:
- return (char_u *)&(win->w_p_cole);
+ return (char *)&(win->w_p_cole);
case PV_AI:
- return (char_u *)&(buf->b_p_ai);
+ return (char *)&(buf->b_p_ai);
case PV_BIN:
- return (char_u *)&(buf->b_p_bin);
+ return (char *)&(buf->b_p_bin);
case PV_BOMB:
- return (char_u *)&(buf->b_p_bomb);
+ return (char *)&(buf->b_p_bomb);
case PV_BH:
- return (char_u *)&(buf->b_p_bh);
+ return (char *)&(buf->b_p_bh);
case PV_BT:
- return (char_u *)&(buf->b_p_bt);
+ return (char *)&(buf->b_p_bt);
case PV_BL:
- return (char_u *)&(buf->b_p_bl);
+ return (char *)&(buf->b_p_bl);
case PV_CHANNEL:
- return (char_u *)&(buf->b_p_channel);
+ return (char *)&(buf->b_p_channel);
case PV_CI:
- return (char_u *)&(buf->b_p_ci);
+ return (char *)&(buf->b_p_ci);
case PV_CIN:
- return (char_u *)&(buf->b_p_cin);
+ return (char *)&(buf->b_p_cin);
case PV_CINK:
- return (char_u *)&(buf->b_p_cink);
+ return (char *)&(buf->b_p_cink);
case PV_CINO:
- return (char_u *)&(buf->b_p_cino);
+ return (char *)&(buf->b_p_cino);
case PV_CINSD:
- return (char_u *)&(buf->b_p_cinsd);
+ return (char *)&(buf->b_p_cinsd);
case PV_CINW:
- return (char_u *)&(buf->b_p_cinw);
+ return (char *)&(buf->b_p_cinw);
case PV_COM:
- return (char_u *)&(buf->b_p_com);
+ return (char *)&(buf->b_p_com);
case PV_CMS:
- return (char_u *)&(buf->b_p_cms);
+ return (char *)&(buf->b_p_cms);
case PV_CPT:
- return (char_u *)&(buf->b_p_cpt);
+ return (char *)&(buf->b_p_cpt);
#ifdef BACKSLASH_IN_FILENAME
case PV_CSL:
- return (char_u *)&(buf->b_p_csl);
+ return (char *)&(buf->b_p_csl);
#endif
case PV_CFU:
- return (char_u *)&(buf->b_p_cfu);
+ return (char *)&(buf->b_p_cfu);
case PV_OFU:
- return (char_u *)&(buf->b_p_ofu);
+ return (char *)&(buf->b_p_ofu);
case PV_EOF:
- return (char_u *)&(buf->b_p_eof);
+ return (char *)&(buf->b_p_eof);
case PV_EOL:
- return (char_u *)&(buf->b_p_eol);
+ return (char *)&(buf->b_p_eol);
case PV_FIXEOL:
- return (char_u *)&(buf->b_p_fixeol);
+ return (char *)&(buf->b_p_fixeol);
case PV_ET:
- return (char_u *)&(buf->b_p_et);
+ return (char *)&(buf->b_p_et);
case PV_FENC:
- return (char_u *)&(buf->b_p_fenc);
+ return (char *)&(buf->b_p_fenc);
case PV_FF:
- return (char_u *)&(buf->b_p_ff);
+ return (char *)&(buf->b_p_ff);
case PV_FT:
- return (char_u *)&(buf->b_p_ft);
+ return (char *)&(buf->b_p_ft);
case PV_FO:
- return (char_u *)&(buf->b_p_fo);
+ return (char *)&(buf->b_p_fo);
case PV_FLP:
- return (char_u *)&(buf->b_p_flp);
+ return (char *)&(buf->b_p_flp);
case PV_IMI:
- return (char_u *)&(buf->b_p_iminsert);
+ return (char *)&(buf->b_p_iminsert);
case PV_IMS:
- return (char_u *)&(buf->b_p_imsearch);
+ return (char *)&(buf->b_p_imsearch);
case PV_INF:
- return (char_u *)&(buf->b_p_inf);
+ return (char *)&(buf->b_p_inf);
case PV_ISK:
- return (char_u *)&(buf->b_p_isk);
+ return (char *)&(buf->b_p_isk);
case PV_INEX:
- return (char_u *)&(buf->b_p_inex);
+ return (char *)&(buf->b_p_inex);
case PV_INDE:
- return (char_u *)&(buf->b_p_inde);
+ return (char *)&(buf->b_p_inde);
case PV_INDK:
- return (char_u *)&(buf->b_p_indk);
+ return (char *)&(buf->b_p_indk);
case PV_FEX:
- return (char_u *)&(buf->b_p_fex);
+ return (char *)&(buf->b_p_fex);
case PV_LISP:
- return (char_u *)&(buf->b_p_lisp);
+ return (char *)&(buf->b_p_lisp);
case PV_LOP:
- return (char_u *)&(buf->b_p_lop);
+ return (char *)&(buf->b_p_lop);
case PV_ML:
- return (char_u *)&(buf->b_p_ml);
+ return (char *)&(buf->b_p_ml);
case PV_MPS:
- return (char_u *)&(buf->b_p_mps);
+ return (char *)&(buf->b_p_mps);
case PV_MA:
- return (char_u *)&(buf->b_p_ma);
+ return (char *)&(buf->b_p_ma);
case PV_MOD:
- return (char_u *)&(buf->b_changed);
+ return (char *)&(buf->b_changed);
case PV_NF:
- return (char_u *)&(buf->b_p_nf);
+ return (char *)&(buf->b_p_nf);
case PV_PI:
- return (char_u *)&(buf->b_p_pi);
+ return (char *)&(buf->b_p_pi);
case PV_QE:
- return (char_u *)&(buf->b_p_qe);
+ return (char *)&(buf->b_p_qe);
case PV_RO:
- return (char_u *)&(buf->b_p_ro);
+ return (char *)&(buf->b_p_ro);
case PV_SCBK:
- return (char_u *)&(buf->b_p_scbk);
+ return (char *)&(buf->b_p_scbk);
case PV_SI:
- return (char_u *)&(buf->b_p_si);
+ return (char *)&(buf->b_p_si);
case PV_STS:
- return (char_u *)&(buf->b_p_sts);
+ return (char *)&(buf->b_p_sts);
case PV_SUA:
- return (char_u *)&(buf->b_p_sua);
+ return (char *)&(buf->b_p_sua);
case PV_SWF:
- return (char_u *)&(buf->b_p_swf);
+ return (char *)&(buf->b_p_swf);
case PV_SMC:
- return (char_u *)&(buf->b_p_smc);
+ return (char *)&(buf->b_p_smc);
case PV_SYN:
- return (char_u *)&(buf->b_p_syn);
+ return (char *)&(buf->b_p_syn);
case PV_SPC:
- return (char_u *)&(win->w_s->b_p_spc);
+ return (char *)&(win->w_s->b_p_spc);
case PV_SPF:
- return (char_u *)&(win->w_s->b_p_spf);
+ return (char *)&(win->w_s->b_p_spf);
case PV_SPL:
- return (char_u *)&(win->w_s->b_p_spl);
+ return (char *)&(win->w_s->b_p_spl);
case PV_SPO:
- return (char_u *)&(win->w_s->b_p_spo);
+ return (char *)&(win->w_s->b_p_spo);
case PV_SW:
- return (char_u *)&(buf->b_p_sw);
+ return (char *)&(buf->b_p_sw);
case PV_TFU:
- return (char_u *)&(buf->b_p_tfu);
+ return (char *)&(buf->b_p_tfu);
case PV_TS:
- return (char_u *)&(buf->b_p_ts);
+ return (char *)&(buf->b_p_ts);
case PV_TW:
- return (char_u *)&(buf->b_p_tw);
+ return (char *)&(buf->b_p_tw);
case PV_UDF:
- return (char_u *)&(buf->b_p_udf);
+ return (char *)&(buf->b_p_udf);
case PV_WM:
- return (char_u *)&(buf->b_p_wm);
+ return (char *)&(buf->b_p_wm);
case PV_VSTS:
- return (char_u *)&(buf->b_p_vsts);
+ return (char *)&(buf->b_p_vsts);
case PV_VTS:
- return (char_u *)&(buf->b_p_vts);
+ return (char *)&(buf->b_p_vts);
case PV_KMAP:
- return (char_u *)&(buf->b_p_keymap);
+ return (char *)&(buf->b_p_keymap);
case PV_SCL:
- return (char_u *)&(win->w_p_scl);
+ return (char *)&(win->w_p_scl);
case PV_WINHL:
- return (char_u *)&(win->w_p_winhl);
+ return (char *)&(win->w_p_winhl);
case PV_WINBL:
- return (char_u *)&(win->w_p_winbl);
+ return (char *)&(win->w_p_winbl);
case PV_STC:
- return (char_u *)&(win->w_p_stc);
+ return (char *)&(win->w_p_stc);
default:
iemsg(_("E356: get_varp ERROR"));
}
// always return a valid pointer to avoid a crash!
- return (char_u *)&(buf->b_p_wm);
+ return (char *)&(buf->b_p_wm);
}
/// Get pointer to option variable.
-static inline char_u *get_varp(vimoption_T *p)
+static inline char *get_varp(vimoption_T *p)
{
return get_varp_from(p, curbuf, curwin);
}
@@ -4608,7 +4608,7 @@ void set_imsearch_global(buf_T *buf)
}
static int expand_option_idx = -1;
-static char_u expand_option_name[5] = { 't', '_', NUL, NUL, NUL };
+static char expand_option_name[5] = { 't', '_', NUL, NUL, NUL };
static int expand_option_flags = 0;
/// @param opt_flags OPT_GLOBAL and/or OPT_LOCAL
@@ -4670,8 +4670,8 @@ void set_context_in_set_cmd(expand_T *xp, char *arg, int opt_flags)
}
nextchar = *++p;
is_term_option = true;
- expand_option_name[2] = (char_u)KEY2TERMCAP0(key);
- expand_option_name[3] = KEY2TERMCAP1(key);
+ expand_option_name[2] = (char)(uint8_t)KEY2TERMCAP0(key);
+ expand_option_name[3] = (char)(uint8_t)KEY2TERMCAP1(key);
} else {
if (p[0] == 't' && p[1] == '_') {
p += 2;
@@ -4683,8 +4683,8 @@ void set_context_in_set_cmd(expand_T *xp, char *arg, int opt_flags)
}
nextchar = *++p;
is_term_option = true;
- expand_option_name[2] = (char_u)p[-2];
- expand_option_name[3] = (char_u)p[-1];
+ expand_option_name[2] = p[-2];
+ expand_option_name[3] = p[-1];
} else {
// Allow * wildcard.
while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*') {
@@ -4734,7 +4734,7 @@ void set_context_in_set_cmd(expand_T *xp, char *arg, int opt_flags)
xp->xp_pattern = p + 1;
if (flags & P_EXPAND) {
- p = (char *)options[opt_idx].var;
+ p = options[opt_idx].var;
if (p == (char *)&p_bdir
|| p == (char *)&p_dir
|| p == (char *)&p_path
@@ -4778,7 +4778,7 @@ void set_context_in_set_cmd(expand_T *xp, char *arg, int opt_flags)
}
// for 'spellsuggest' start at "file:"
- if (options[opt_idx].var == (char_u *)&p_sps
+ if (options[opt_idx].var == (char *)&p_sps
&& strncmp(p, "file:", 5) == 0) {
xp->xp_pattern = p + 5;
break;
@@ -4915,7 +4915,7 @@ void ExpandOldSetting(int *numMatches, char ***matches)
// For a terminal key code expand_option_idx is < 0.
if (expand_option_idx < 0) {
- expand_option_idx = findoption((const char *)expand_option_name);
+ expand_option_idx = findoption(expand_option_name);
}
if (expand_option_idx >= 0) {
@@ -4959,8 +4959,8 @@ static void option_value2string(vimoption_T *opp, int scope)
if (opp->flags & P_NUM) {
long wc = 0;
- if (wc_use_keyname((char_u *)varp, &wc)) {
- xstrlcpy(NameBuff, (char *)get_special_key_name((int)wc, 0), sizeof(NameBuff));
+ if (wc_use_keyname(varp, &wc)) {
+ xstrlcpy(NameBuff, get_special_key_name((int)wc, 0), sizeof(NameBuff));
} else if (wc != 0) {
xstrlcpy(NameBuff, transchar((int)wc), sizeof(NameBuff));
} else {
@@ -4984,7 +4984,7 @@ static void option_value2string(vimoption_T *opp, int scope)
/// Return true if "varp" points to 'wildchar' or 'wildcharm' and it can be
/// printed as a keyname.
/// "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'.
-static int wc_use_keyname(const char_u *varp, long *wcp)
+static int wc_use_keyname(const char *varp, long *wcp)
{
if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm)) {
*wcp = *(long *)varp;
@@ -5198,7 +5198,7 @@ void fill_breakat_flags(void)
int fill_culopt_flags(char *val, win_T *wp)
{
char *p;
- char_u culopt_flags_new = 0;
+ uint8_t culopt_flags_new = 0;
if (val == NULL) {
p = wp->w_p_culopt;
@@ -5568,7 +5568,7 @@ dict_T *get_winbuf_options(const int bufopt)
if ((bufopt && (opt->indir & PV_BUF))
|| (!bufopt && (opt->indir & PV_WIN))) {
- char_u *varp = get_varp(opt);
+ char *varp = get_varp(opt);
if (varp != NULL) {
if (opt->flags & P_STRING) {
@@ -5605,26 +5605,27 @@ long get_sidescrolloff_value(win_T *wp)
return wp->w_p_siso < 0 ? p_siso : wp->w_p_siso;
}
-Dictionary get_vimoption(String name, Error *err)
+Dictionary get_vimoption(String name, int scope, buf_T *buf, win_T *win, Error *err)
{
int opt_idx = findoption_len((const char *)name.data, name.size);
VALIDATE_S(opt_idx >= 0, "option (not found)", name.data, {
return (Dictionary)ARRAY_DICT_INIT;
});
- return vimoption2dict(&options[opt_idx]);
+
+ return vimoption2dict(&options[opt_idx], scope, buf, win);
}
Dictionary get_all_vimoptions(void)
{
Dictionary retval = ARRAY_DICT_INIT;
for (size_t i = 0; options[i].fullname != NULL; i++) {
- Dictionary opt_dict = vimoption2dict(&options[i]);
+ Dictionary opt_dict = vimoption2dict(&options[i], OPT_GLOBAL, curbuf, curwin);
PUT(retval, options[i].fullname, DICTIONARY_OBJ(opt_dict));
}
return retval;
}
-static Dictionary vimoption2dict(vimoption_T *opt)
+static Dictionary vimoption2dict(vimoption_T *opt, int req_scope, buf_T *buf, win_T *win)
{
Dictionary dict = ARRAY_DICT_INIT;
@@ -5649,14 +5650,30 @@ static Dictionary vimoption2dict(vimoption_T *opt)
PUT(dict, "was_set", BOOL(opt->flags & P_WAS_SET));
- PUT(dict, "last_set_sid", INTEGER_OBJ(opt->last_set.script_ctx.sc_sid));
- PUT(dict, "last_set_linenr", INTEGER_OBJ(opt->last_set.script_ctx.sc_lnum));
- PUT(dict, "last_set_chan", INTEGER_OBJ((int64_t)opt->last_set.channel_id));
+ LastSet last_set = { .channel_id = 0 };
+ if (req_scope == OPT_GLOBAL) {
+ last_set = opt->last_set;
+ } else {
+ // Scope is either OPT_LOCAL or a fallback mode was requested.
+ if (opt->indir & PV_BUF) {
+ last_set = buf->b_p_script_ctx[opt->indir & PV_MASK];
+ }
+ if (opt->indir & PV_WIN) {
+ last_set = win->w_p_script_ctx[opt->indir & PV_MASK];
+ }
+ if (req_scope != OPT_LOCAL && last_set.script_ctx.sc_sid == 0) {
+ last_set = opt->last_set;
+ }
+ }
+
+ PUT(dict, "last_set_sid", INTEGER_OBJ(last_set.script_ctx.sc_sid));
+ PUT(dict, "last_set_linenr", INTEGER_OBJ(last_set.script_ctx.sc_lnum));
+ PUT(dict, "last_set_chan", INTEGER_OBJ((int64_t)last_set.channel_id));
const char *type;
Object def;
// TODO(bfredl): do you even nocp?
- char_u *def_val = (char_u *)opt->def_val;
+ char *def_val = opt->def_val;
if (opt->flags & P_STRING) {
type = "string";
def = CSTR_TO_OBJ(def_val ? (char *)def_val : "");
diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h
index de289fe54e..b7ea8cd2c2 100644
--- a/src/nvim/option_defs.h
+++ b/src/nvim/option_defs.h
@@ -993,7 +993,7 @@ typedef struct vimoption {
char *fullname; // full option name
char *shortname; // permissible abbreviation
uint32_t flags; // see below
- char_u *var; // global option: pointer to variable;
+ char *var; // global option: pointer to variable;
// window-local option: VAR_WIN;
// buffer-local option: global value
idopt_T indir; // global option: PV_NONE;
@@ -1018,6 +1018,6 @@ typedef struct vimoption {
// Options local to a window have a value local to a buffer and global to all
// buffers. Indicate this by setting "var" to VAR_WIN.
-#define VAR_WIN ((char_u *)-1)
+#define VAR_WIN ((char *)-1)
#endif // NVIM_OPTION_DEFS_H
diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c
index 170800b4e6..bf4ebbb3e2 100644
--- a/src/nvim/optionstr.c
+++ b/src/nvim/optionstr.c
@@ -1529,34 +1529,6 @@ static void do_syntax_autocmd(buf_T *buf, bool value_changed)
syn_recursive--;
}
-static void do_filetype_autocmd(buf_T *buf, char **varp, int opt_flags, bool value_changed)
-{
- // 'filetype' is set, trigger the FileType autocommand
- // Skip this when called from a modeline and the filetype was
- // already set to this value.
- if (!(opt_flags & OPT_MODELINE) || value_changed) {
- static int ft_recursive = 0;
- int secure_save = secure;
-
- // Reset the secure flag, since the value of 'filetype' has
- // been checked to be safe.
- secure = 0;
-
- ft_recursive++;
- did_filetype = true;
- // Only pass true for "force" when the value changed or not
- // used recursively, to avoid endless recurrence.
- apply_autocmds(EVENT_FILETYPE, buf->b_p_ft, buf->b_fname,
- value_changed || ft_recursive == 1, buf);
- ft_recursive--;
- // Just in case the old "buf" is now invalid
- if (varp != &(buf->b_p_ft)) {
- varp = NULL;
- }
- secure = secure_save;
- }
-}
-
static void do_spelllang_source(win_T *win)
{
char fname[200];
@@ -1884,7 +1856,12 @@ static char *did_set_string_option_for(buf_T *buf, win_T *win, int opt_idx, char
if (varp == &buf->b_p_syn) {
do_syntax_autocmd(buf, value_changed);
} else if (varp == &buf->b_p_ft) {
- do_filetype_autocmd(buf, varp, opt_flags, value_changed);
+ // 'filetype' is set, trigger the FileType autocommand
+ // Skip this when called from a modeline
+ // Force autocmd when the filetype was changed
+ if (!(opt_flags & OPT_MODELINE) || value_changed) {
+ do_filetype_autocmd(buf, value_changed);
+ }
} else if (varp == &win->w_s->b_p_spl) {
do_spelllang_source(win);
}
diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c
index 30092b9142..5b8c060e7a 100644
--- a/src/nvim/os/env.c
+++ b/src/nvim/os/env.c
@@ -494,7 +494,7 @@ void init_homedir(void)
// links. Don't do it when we can't return.
if (os_dirname(os_buf, MAXPATHL) == OK && os_chdir(os_buf) == 0) {
if (!os_chdir(var) && os_dirname(IObuff, IOSIZE) == OK) {
- var = (char *)IObuff;
+ var = IObuff;
}
if (os_chdir(os_buf) != 0) {
emsg(_(e_prev_dir));
diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c
index 122f3e2020..0b9a9bbdec 100644
--- a/src/nvim/regexp.c
+++ b/src/nvim/regexp.c
@@ -2304,10 +2304,10 @@ static uint8_t regname[][30] = {
// Returns the program in allocated memory.
// Use vim_regfree() to free the memory.
// Returns NULL for an error.
-regprog_T *vim_regcomp(char *expr_arg, int re_flags)
+regprog_T *vim_regcomp(const char *expr_arg, int re_flags)
{
regprog_T *prog = NULL;
- char *expr = expr_arg;
+ const char *expr = expr_arg;
regexp_engine = (int)p_re;
@@ -2403,7 +2403,7 @@ void free_regexp_stuff(void)
#endif
-static void report_re_switch(char *pat)
+static void report_re_switch(const char *pat)
{
if (p_verbose > 0) {
verbose_enter();
@@ -2425,7 +2425,7 @@ static void report_re_switch(char *pat)
/// @param nl
///
/// @return true if there is a match, false if not.
-static bool vim_regexec_string(regmatch_T *rmp, char *line, colnr_T col, bool nl)
+static bool vim_regexec_string(regmatch_T *rmp, const char *line, colnr_T col, bool nl)
{
regexec_T rex_save;
bool rex_in_use_save = rex_in_use;
@@ -2482,7 +2482,7 @@ static bool vim_regexec_string(regmatch_T *rmp, char *line, colnr_T col, bool nl
// Note: "*prog" may be freed and changed.
// Return true if there is a match, false if not.
-bool vim_regexec_prog(regprog_T **prog, bool ignore_case, char *line, colnr_T col)
+bool vim_regexec_prog(regprog_T **prog, bool ignore_case, const char *line, colnr_T col)
{
regmatch_T regmatch = { .regprog = *prog, .rm_ic = ignore_case };
bool r = vim_regexec_string(&regmatch, line, col, false);
@@ -2492,7 +2492,7 @@ bool vim_regexec_prog(regprog_T **prog, bool ignore_case, char *line, colnr_T co
// Note: "rmp->regprog" may be freed and changed.
// Return true if there is a match, false if not.
-bool vim_regexec(regmatch_T *rmp, char *line, colnr_T col)
+bool vim_regexec(regmatch_T *rmp, const char *line, colnr_T col)
{
return vim_regexec_string(rmp, line, col, false);
}
@@ -2500,7 +2500,7 @@ bool vim_regexec(regmatch_T *rmp, char *line, colnr_T col)
// Like vim_regexec(), but consider a "\n" in "line" to be a line break.
// Note: "rmp->regprog" may be freed and changed.
// Return true if there is a match, false if not.
-bool vim_regexec_nl(regmatch_T *rmp, char *line, colnr_T col)
+bool vim_regexec_nl(regmatch_T *rmp, const char *line, colnr_T col)
{
return vim_regexec_string(rmp, line, col, true);
}
diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c
index c9667d58ed..5d1c104dc5 100644
--- a/src/nvim/runtime.c
+++ b/src/nvim/runtime.c
@@ -914,19 +914,6 @@ static int add_pack_dir_to_rtp(char *fname, bool is_pack)
const char *cur_entry = entry;
copy_option_part((char **)&entry, buf, MAXPATHL, ",");
- if (insp == NULL) {
- add_pathsep(buf);
- char *const rtp_ffname = fix_fname(buf);
- if (rtp_ffname == NULL) {
- goto theend;
- }
- bool match = path_fnamencmp(rtp_ffname, ffname, fname_len) == 0;
- xfree(rtp_ffname);
- if (match) {
- // Insert "ffname" after this entry (and comma).
- insp = entry;
- }
- }
if ((p = strstr(buf, "after")) != NULL
&& p > buf
@@ -940,6 +927,20 @@ static int add_pack_dir_to_rtp(char *fname, bool is_pack)
after_insp = cur_entry;
break;
}
+
+ if (insp == NULL) {
+ add_pathsep(buf);
+ char *const rtp_ffname = fix_fname(buf);
+ if (rtp_ffname == NULL) {
+ goto theend;
+ }
+ bool match = path_fnamencmp(rtp_ffname, ffname, fname_len) == 0;
+ xfree(rtp_ffname);
+ if (match) {
+ // Insert "ffname" after this entry (and comma).
+ insp = entry;
+ }
+ }
}
if (insp == NULL) {
diff --git a/src/nvim/search.c b/src/nvim/search.c
index 67b6f5e6a6..525cec8b02 100644
--- a/src/nvim/search.c
+++ b/src/nvim/search.c
@@ -4159,10 +4159,10 @@ static void show_pat_in_path(char *line, int type, bool did_show, int action, FI
}
if (action == ACTION_SHOW_ALL) {
snprintf(IObuff, IOSIZE, "%3ld: ", count); // Show match nr.
- msg_puts((const char *)IObuff);
+ msg_puts(IObuff);
snprintf(IObuff, IOSIZE, "%4" PRIdLINENR, *lnum); // Show line nr.
// Highlight line numbers.
- msg_puts_attr((const char *)IObuff, HL_ATTR(HLF_N));
+ msg_puts_attr(IObuff, HL_ATTR(HLF_N));
msg_puts(" ");
}
msg_prt_line(line, false);
diff --git a/src/nvim/spell.c b/src/nvim/spell.c
index c65f822080..9108059b4d 100644
--- a/src/nvim/spell.c
+++ b/src/nvim/spell.c
@@ -150,7 +150,7 @@ typedef struct matchinf_S {
// for when checking a compound word
int mi_compoff; // start of following word offset
- char_u mi_compflags[MAXWLEN]; // flags for compound words used
+ uint8_t mi_compflags[MAXWLEN]; // flags for compound words used
int mi_complen; // nr of compound words used
int mi_compextra; // nr of COMPOUNDROOT words
@@ -961,7 +961,7 @@ bool can_compound(slang_T *slang, const char *word, const uint8_t *flags)
// compound rule. This is used to stop trying a compound if the flags
// collected so far can't possibly match any compound rule.
// Caller must check that slang->sl_comprules is not NULL.
-bool match_compoundrule(slang_T *slang, const char_u *compflags)
+bool match_compoundrule(slang_T *slang, const uint8_t *compflags)
{
// loop over all the COMPOUNDRULE entries
for (char *p = (char *)slang->sl_comprules; *p != NUL; p++) {
@@ -1748,7 +1748,7 @@ void count_common_word(slang_T *lp, char *word, int len, uint8_t count)
wc = xmalloc(offsetof(wordcount_T, wc_word) + p_len + 1);
memcpy(wc->wc_word, p, p_len + 1);
wc->wc_count = count;
- hash_add_item(&lp->sl_wordcount, hi, (char *)wc->wc_word, hash);
+ hash_add_item(&lp->sl_wordcount, hi, wc->wc_word, hash);
} else {
wc = HI2WC(hi);
wc->wc_count = (uint16_t)(wc->wc_count + count);
diff --git a/src/nvim/spell_defs.h b/src/nvim/spell_defs.h
index 1c163071c5..0b95cfed8e 100644
--- a/src/nvim/spell_defs.h
+++ b/src/nvim/spell_defs.h
@@ -243,7 +243,7 @@ typedef enum {
typedef struct wordcount_S {
uint16_t wc_count; ///< nr of times word was seen
- char_u wc_word[]; ///< word
+ char wc_word[]; ///< word
} wordcount_T;
#define WC_KEY_OFF offsetof(wordcount_T, wc_word)
diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c
index 8927b599d0..aa76dcbd32 100644
--- a/src/nvim/spellfile.c
+++ b/src/nvim/spellfile.c
@@ -404,14 +404,14 @@ typedef struct sblock_S sblock_T;
struct sblock_S {
int sb_used; // nr of bytes already in use
sblock_T *sb_next; // next block in list
- char_u sb_data[]; // data
+ char sb_data[]; // data
};
// A node in the tree.
typedef struct wordnode_S wordnode_T;
struct wordnode_S {
union { // shared to save space
- char_u hashkey[6]; // the hash key, only used while compressing
+ uint8_t hashkey[6]; // the hash key, only used while compressing
int index; // index in written nodes (valid after first
// round)
} wn_u1;
@@ -422,17 +422,17 @@ struct wordnode_S {
wordnode_T *wn_child; // child (next byte in word)
wordnode_T *wn_sibling; // next sibling (alternate byte in word,
// always sorted)
- int wn_refs; // Nr. of references to this node. Only
- // relevant for first node in a list of
- // siblings, in following siblings it is
- // always one.
- char_u wn_byte; // Byte for this node. NUL for word end
+ int wn_refs; // Nr. of references to this node. Only
+ // relevant for first node in a list of
+ // siblings, in following siblings it is
+ // always one.
+ uint8_t wn_byte; // Byte for this node. NUL for word end
// Info for when "wn_byte" is NUL.
// In PREFIXTREE "wn_region" is used for the prefcondnr.
// In the soundfolded word tree "wn_flags" has the MSW of the wordnr and
// "wn_region" the LSW of the wordnr.
- char_u wn_affixID; // supported/required prefix ID or 0
+ uint8_t wn_affixID; // supported/required prefix ID or 0
uint16_t wn_flags; // WF_ flags
int16_t wn_region; // region mask
@@ -482,7 +482,7 @@ typedef struct spellinfo_S {
char *si_info; // info text chars or NULL
int si_region_count; // number of regions supported (1 when there
// are no regions)
- char_u si_region_name[MAXREGIONS * 2 + 1];
+ char si_region_name[MAXREGIONS * 2 + 1];
// region names; used only if
// si_region_count > 1)
@@ -508,7 +508,7 @@ typedef struct spellinfo_S {
garray_T si_comppat; // CHECKCOMPOUNDPATTERN items, each stored as
// a string
char *si_compflags; // flags used for compounding
- char_u si_nobreak; // NOBREAK
+ char si_nobreak; // NOBREAK
char *si_syllable; // syllable string
garray_T si_prefcond; // table with conditions for postponed
// prefixes, each stored as a string
@@ -608,7 +608,7 @@ slang_T *spell_load_file(char *fname, char *lang, slang_T *old_lp, bool silent)
semsg(_(e_notopen), fname);
} else if (p_verbose > 2) {
verbose_enter();
- smsg((char *)e_notopen, fname);
+ smsg(e_notopen, fname);
verbose_leave();
}
goto endFAIL;
@@ -985,7 +985,7 @@ someerror:
if (c < 0) {
goto someerror;
}
- GA_APPEND(char_u, &ga, (char_u)c);
+ GA_APPEND(uint8_t, &ga, (uint8_t)c);
if (c == NUL) {
break;
}
@@ -1060,7 +1060,7 @@ static int read_region_section(FILE *fd, slang_T *lp, int len)
static int read_charflags_section(FILE *fd)
{
char *flags;
- char_u *fol;
+ char *fol;
int flagslen, follen;
// <charflagslen> <charflags>
@@ -1070,7 +1070,7 @@ static int read_charflags_section(FILE *fd)
}
// <folcharslen> <folchars>
- fol = (char_u *)read_cnt_string(fd, 2, &follen);
+ fol = read_cnt_string(fd, 2, &follen);
if (follen < 0) {
xfree(flags);
return follen;
@@ -1078,7 +1078,7 @@ static int read_charflags_section(FILE *fd)
// Set the word-char flags and fill SPELL_ISUPPER() table.
if (flags != NULL && fol != NULL) {
- set_spell_charflags(flags, flagslen, (char *)fol);
+ set_spell_charflags(flags, flagslen, fol);
}
xfree(flags);
@@ -2538,9 +2538,9 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char *fname)
if (idx < 0) {
// Not found, add a new condition.
idx = spin->si_prefcond.ga_len;
- char_u **pp = GA_APPEND_VIA_PTR(char_u *, &spin->si_prefcond);
+ char **pp = GA_APPEND_VIA_PTR(char *, &spin->si_prefcond);
*pp = (aff_entry->ae_cond == NULL) ?
- NULL : (char_u *)getroom_save(spin, aff_entry->ae_cond);
+ NULL : getroom_save(spin, aff_entry->ae_cond);
}
// Add the prefix to the prefix tree.
@@ -2565,7 +2565,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char *fname)
if (aff_entry->ae_compforbid) {
n |= WFP_COMPFORBID;
}
- tree_add_word(spin, (char_u *)p, spin->si_prefroot, n,
+ tree_add_word(spin, p, spin->si_prefroot, n,
idx, cur_aff->ah_newID);
did_postpone_prefix = true;
}
@@ -3232,7 +3232,7 @@ static int spell_read_dic(spellinfo_T *spin, char *fname, afffile_T *affile)
if (spin->si_compflags != NULL) {
// Need to store the list of compound flags with the word.
// Concatenate them to the list of prefix IDs.
- get_compflags(affile, afflist, (char_u *)store_afflist + pfxlen);
+ get_compflags(affile, afflist, store_afflist + pfxlen);
}
}
@@ -3349,7 +3349,7 @@ static int get_pfxlist(afffile_T *affile, char *afflist, char *store_afflist)
// Get the list of compound IDs from the affix list "afflist" that are used
// for compound words.
// Puts the flags in "store_afflist[]".
-static void get_compflags(afffile_T *affile, char *afflist, char_u *store_afflist)
+static void get_compflags(afffile_T *affile, char *afflist, char *store_afflist)
{
int cnt = 0;
char key[AH_KEY_LEN];
@@ -3362,7 +3362,7 @@ static void get_compflags(afffile_T *affile, char *afflist, char_u *store_afflis
xstrlcpy(key, prevp, (size_t)(p - prevp) + 1);
hi = hash_find(&affile->af_comp, (char *)key);
if (!HASHITEM_EMPTY(hi)) {
- store_afflist[cnt++] = (char_u)HI2CI(hi)->ci_newID;
+ store_afflist[cnt++] = (char)(uint8_t)HI2CI(hi)->ci_newID;
}
}
if (affile->af_flagtype == AFT_NUM && *p == ',') {
@@ -3530,7 +3530,7 @@ static int store_aff_word(spellinfo_T *spin, char *word, char *afflist, afffile_
if (spin->si_compflags != NULL) {
// Get compound IDS from the affix list.
get_compflags(affile, ae->ae_flags,
- (char_u *)use_pfxlist + use_pfxlen);
+ use_pfxlist + use_pfxlen);
} else {
use_pfxlist[use_pfxlen] = NUL;
}
@@ -3835,7 +3835,7 @@ static void *getroom(spellinfo_T *spin, size_t len, bool align)
spin->si_blocks_cnt++;
}
- p = (char *)bl->sb_data + bl->sb_used;
+ p = bl->sb_data + bl->sb_used;
bl->sb_used += (int)len;
return p;
@@ -3913,7 +3913,7 @@ static int store_word(spellinfo_T *spin, char *word, int flags, int region, cons
(void)spell_casefold(curwin, word, len, foldword, MAXWLEN);
for (const char *p = pfxlist; res == OK; p++) {
if (!need_affix || (p != NULL && *p != NUL)) {
- res = tree_add_word(spin, (char_u *)foldword, spin->si_foldroot, ct | flags,
+ res = tree_add_word(spin, foldword, spin->si_foldroot, ct | flags,
region, p == NULL ? 0 : *p);
}
if (p == NULL || *p == NUL) {
@@ -3925,7 +3925,7 @@ static int store_word(spellinfo_T *spin, char *word, int flags, int region, cons
if (res == OK && (ct == WF_KEEPCAP || (flags & WF_KEEPCAP))) {
for (const char *p = pfxlist; res == OK; p++) {
if (!need_affix || (p != NULL && *p != NUL)) {
- res = tree_add_word(spin, (char_u *)word, spin->si_keeproot, flags,
+ res = tree_add_word(spin, word, spin->si_keeproot, flags,
region, p == NULL ? 0 : *p);
}
if (p == NULL || *p == NUL) {
@@ -3941,7 +3941,7 @@ static int store_word(spellinfo_T *spin, char *word, int flags, int region, cons
// When "flags" < 0 we are adding to the prefix tree where "flags" is used for
// "rare" and "region" is the condition nr.
// Returns FAIL when out of memory.
-static int tree_add_word(spellinfo_T *spin, const char_u *word, wordnode_T *root, int flags,
+static int tree_add_word(spellinfo_T *spin, const char *word, wordnode_T *root, int flags,
int region, int affixID)
{
wordnode_T *node = root;
@@ -3993,7 +3993,7 @@ static int tree_add_word(spellinfo_T *spin, const char_u *word, wordnode_T *root
// higher byte value. For zero bytes (end of word) the sorting is
// done on flags and then on affixID.
while (node != NULL
- && (node->wn_byte < word[i]
+ && (node->wn_byte < (uint8_t)word[i]
|| (node->wn_byte == NUL
&& (flags < 0
? node->wn_affixID < (unsigned)affixID
@@ -4007,7 +4007,7 @@ static int tree_add_word(spellinfo_T *spin, const char_u *word, wordnode_T *root
node = *prev;
}
if (node == NULL
- || node->wn_byte != word[i]
+ || node->wn_byte != (uint8_t)word[i]
|| (word[i] == NUL
&& (flags < 0
|| spin->si_sugtree
@@ -4018,7 +4018,7 @@ static int tree_add_word(spellinfo_T *spin, const char_u *word, wordnode_T *root
if (np == NULL) {
return FAIL;
}
- np->wn_byte = word[i];
+ np->wn_byte = (uint8_t)word[i];
// If "node" is NULL this is a new child or the end of the sibling
// list: ref count is one. Otherwise use ref count of sibling and
@@ -4040,14 +4040,14 @@ static int tree_add_word(spellinfo_T *spin, const char_u *word, wordnode_T *root
if (word[i] == NUL) {
node->wn_flags = (uint16_t)flags;
node->wn_region |= (int16_t)region;
- node->wn_affixID = (char_u)affixID;
+ node->wn_affixID = (uint8_t)affixID;
break;
}
prev = &node->wn_child;
node = *prev;
}
#ifdef SPELL_PRINTTREE
- smsg((char_u *)"Added \"%s\"", word);
+ smsg("Added \"%s\"", word);
spell_print_tree(root->wn_sibling);
#endif
@@ -4266,7 +4266,7 @@ static long node_compress(spellinfo_T *spin, wordnode_T *node, hashtab_T *ht, lo
// Make a hash key for the node and its siblings, so that we can quickly
// find a lookalike node. This must be done after compressing the sibling
// list, otherwise the hash key would become invalid by the compression.
- node->wn_u1.hashkey[0] = (char_u)len;
+ node->wn_u1.hashkey[0] = (uint8_t)len;
nr = 0;
for (np = node; np != NULL; np = np->wn_sibling) {
if (np->wn_byte == NUL) {
@@ -4281,13 +4281,13 @@ static long node_compress(spellinfo_T *spin, wordnode_T *node, hashtab_T *ht, lo
// Avoid NUL bytes, it terminates the hash key.
n = nr & 0xff;
- node->wn_u1.hashkey[1] = n == 0 ? 1 : (char_u)n;
+ node->wn_u1.hashkey[1] = n == 0 ? 1 : (uint8_t)n;
n = (nr >> 8) & 0xff;
- node->wn_u1.hashkey[2] = n == 0 ? 1 : (char_u)n;
+ node->wn_u1.hashkey[2] = n == 0 ? 1 : (uint8_t)n;
n = (nr >> 16) & 0xff;
- node->wn_u1.hashkey[3] = n == 0 ? 1 : (char_u)n;
+ node->wn_u1.hashkey[3] = n == 0 ? 1 : (uint8_t)n;
n = (nr >> 24) & 0xff;
- node->wn_u1.hashkey[4] = n == 0 ? 1 : (char_u)n;
+ node->wn_u1.hashkey[4] = n == 0 ? 1 : (uint8_t)n;
node->wn_u1.hashkey[5] = NUL;
// Check for CTRL-C pressed now and then.
@@ -4957,8 +4957,8 @@ static int sug_filltree(spellinfo_T *spin, slang_T *slang)
int depth;
idx_T arridx[MAXWLEN];
int curi[MAXWLEN];
- char_u tword[MAXWLEN];
- char_u tsalword[MAXWLEN];
+ char tword[MAXWLEN];
+ char tsalword[MAXWLEN];
int c;
idx_T n;
unsigned words_done = 0;
@@ -4999,7 +4999,7 @@ static int sug_filltree(spellinfo_T *spin, slang_T *slang)
if (c == 0) {
// Sound-fold the word.
tword[depth] = NUL;
- spell_soundfold(slang, (char *)tword, true, (char *)tsalword);
+ spell_soundfold(slang, tword, true, tsalword);
// We use the "flags" field for the MSB of the wordnr,
// "region" for the LSB of the wordnr.
@@ -5024,7 +5024,7 @@ static int sug_filltree(spellinfo_T *spin, slang_T *slang)
}
} else {
// Normal char, go one level deeper.
- tword[depth++] = (char_u)c;
+ tword[depth++] = (char)(uint8_t)c;
arridx[depth] = idxs[n];
curi[depth] = 1;
wordcount[depth] = 0;
@@ -5090,12 +5090,11 @@ static int sug_filltable(spellinfo_T *spin, wordnode_T *node, int startwordnr, g
// following bytes.
nr -= prev_nr;
prev_nr += nr;
- gap->ga_len += offset2bytes(nr,
- (char_u *)gap->ga_data + gap->ga_len);
+ gap->ga_len += offset2bytes(nr, (char *)gap->ga_data + gap->ga_len);
}
// add the NUL byte
- ((char_u *)gap->ga_data)[gap->ga_len++] = NUL;
+ ((char *)gap->ga_data)[gap->ga_len++] = NUL;
if (ml_append_buf(spin->si_spellbuf, (linenr_T)wordnr,
gap->ga_data, gap->ga_len, true) == FAIL) {
@@ -5126,8 +5125,9 @@ static int sug_filltable(spellinfo_T *spin, wordnode_T *node, int startwordnr, g
// Convert an offset into a minimal number of bytes.
// Similar to utf_char2byters, but use 8 bits in followup bytes and avoid NUL
// bytes.
-static int offset2bytes(int nr, char_u *buf)
+static int offset2bytes(int nr, char *buf_in)
{
+ uint8_t *buf = (uint8_t *)buf_in;
int rem;
int b1, b2, b3, b4;
@@ -5140,25 +5140,25 @@ static int offset2bytes(int nr, char_u *buf)
b4 = rem / 255 + 1;
if (b4 > 1 || b3 > 0x1f) { // 4 bytes
- buf[0] = (char_u)(0xe0 + b4);
- buf[1] = (char_u)b3;
- buf[2] = (char_u)b2;
- buf[3] = (char_u)b1;
+ buf[0] = (uint8_t)(0xe0 + b4);
+ buf[1] = (uint8_t)b3;
+ buf[2] = (uint8_t)b2;
+ buf[3] = (uint8_t)b1;
return 4;
}
if (b3 > 1 || b2 > 0x3f) { // 3 bytes
- buf[0] = (char_u)(0xc0 + b3);
- buf[1] = (char_u)b2;
- buf[2] = (char_u)b1;
+ buf[0] = (uint8_t)(0xc0 + b3);
+ buf[1] = (uint8_t)b2;
+ buf[2] = (uint8_t)b1;
return 3;
}
if (b2 > 1 || b1 > 0x7f) { // 2 bytes
- buf[0] = (char_u)(0x80 + b2);
- buf[1] = (char_u)b1;
+ buf[0] = (uint8_t)(0x80 + b2);
+ buf[1] = (uint8_t)b1;
return 2;
}
// 1 byte
- buf[0] = (char_u)b1;
+ buf[0] = (uint8_t)b1;
return 1;
}
@@ -5342,8 +5342,8 @@ static void mkspell(int fcount, char **fnames, bool ascii, bool over_write, bool
semsg(_("E755: Invalid region in %s"), innames[i]);
goto theend;
}
- spin.si_region_name[i * 2] = (char_u)TOLOWER_ASC(innames[i][len - 2]);
- spin.si_region_name[i * 2 + 1] = (char_u)TOLOWER_ASC(innames[i][len - 1]);
+ spin.si_region_name[i * 2] = (char)(uint8_t)TOLOWER_ASC(innames[i][len - 2]);
+ spin.si_region_name[i * 2 + 1] = (char)(uint8_t)TOLOWER_ASC(innames[i][len - 1]);
}
}
spin.si_region_count = incount;
@@ -5599,21 +5599,21 @@ void spell_add_word(char *word, int len, SpellAddType what, int idx, bool undo)
if (!undo) {
fd = os_fopen(fname, "a");
if (fd == NULL && new_spf) {
- char_u *p;
+ char *p;
// We just initialized the 'spellfile' option and can't open the
// file. We may need to create the "spell" directory first. We
// already checked the runtime directory is writable in
// init_spellfile().
if (!dir_of_file_exists(fname)
- && (p = (char_u *)path_tail_with_sep(fname)) != (char_u *)fname) {
- int c = *p;
+ && (p = path_tail_with_sep(fname)) != fname) {
+ char c = *p;
// The directory doesn't exist. Try creating it and opening
// the file again.
*p = NUL;
os_mkdir(fname, 0755);
- *p = (char_u)c;
+ *p = c;
fd = os_fopen(fname, "a");
}
}
diff --git a/src/nvim/spellsuggest.c b/src/nvim/spellsuggest.c
index 705e215dfa..d28460a63d 100644
--- a/src/nvim/spellsuggest.c
+++ b/src/nvim/spellsuggest.c
@@ -551,7 +551,7 @@ void spell_suggest(int count)
vim_snprintf(IObuff, IOSIZE, ":ot \"%.*s\" egnahC",
sug.su_badlen, sug.su_badptr);
}
- msg_puts((const char *)IObuff);
+ msg_puts(IObuff);
msg_clr_eos();
msg_putchar('\n');
@@ -570,16 +570,16 @@ void spell_suggest(int count)
if (cmdmsg_rl) {
rl_mirror_ascii(IObuff);
}
- msg_puts((const char *)IObuff);
+ msg_puts(IObuff);
vim_snprintf(IObuff, IOSIZE, " \"%s\"", wcopy);
- msg_puts((const char *)IObuff);
+ msg_puts(IObuff);
// The word may replace more than "su_badlen".
if (sug.su_badlen < stp->st_orglen) {
vim_snprintf(IObuff, IOSIZE, _(" < \"%.*s\""),
stp->st_orglen, sug.su_badptr);
- msg_puts((const char *)IObuff);
+ msg_puts(IObuff);
}
if (p_verbose > 0) {
@@ -597,7 +597,7 @@ void spell_suggest(int count)
rl_mirror_ascii(IObuff + 1);
}
msg_advance(30);
- msg_puts((const char *)IObuff);
+ msg_puts(IObuff);
}
msg_putchar('\n');
}
diff --git a/src/nvim/state.c b/src/nvim/state.c
index d02ea46d31..160bc3cd69 100644
--- a/src/nvim/state.c
+++ b/src/nvim/state.c
@@ -92,7 +92,7 @@ getkey:
}
#ifdef NVIM_LOG_DEBUG
- char *keyname = key == K_EVENT ? "K_EVENT" : (char *)get_special_key_name(key, mod_mask);
+ char *keyname = key == K_EVENT ? "K_EVENT" : get_special_key_name(key, mod_mask);
DLOG("input: %s", keyname);
#endif
diff --git a/src/nvim/tag.c b/src/nvim/tag.c
index 852e7e6e7c..2d9d0de951 100644
--- a/src/nvim/tag.c
+++ b/src/nvim/tag.c
@@ -726,7 +726,7 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose)
if ((num_matches > prev_num_matches || new_tag)
&& num_matches > 1) {
if (ic) {
- msg_attr((const char *)IObuff, HL_ATTR(HLF_W));
+ msg_attr(IObuff, HL_ATTR(HLF_W));
} else {
msg(IObuff);
}
diff --git a/src/nvim/types.h b/src/nvim/types.h
index d90c623955..0bc2f76078 100644
--- a/src/nvim/types.h
+++ b/src/nvim/types.h
@@ -7,10 +7,6 @@
// dummy to pass an ACL to a function
typedef void *vim_acl_T;
-// Shorthand for unsigned variables. Many systems, but not all, have u_char
-// already defined, so we use char_u to avoid trouble.
-typedef unsigned char char_u;
-
// Can hold one decoded UTF-8 character.
typedef uint32_t u8char_T;
diff --git a/test/functional/api/highlight_spec.lua b/test/functional/api/highlight_spec.lua
index 65b13bebf7..a4bd574a56 100644
--- a/test/functional/api/highlight_spec.lua
+++ b/test/functional/api/highlight_spec.lua
@@ -561,4 +561,18 @@ describe('API: get highlight', function()
eq({ link = 'String' }, meths.get_hl(0, { name = '@string' }))
eq({ fg = 10937249 }, meths.get_hl(0, { name = '@string.cpp', link = false }))
end)
+
+ it('can get all attributes for a linked group', function()
+ command('hi Bar guifg=red')
+ command('hi Foo guifg=#00ff00 gui=bold,underline')
+ command('hi! link Foo Bar')
+ eq({ link = 'Bar', fg = tonumber('00ff00', 16), bold = true, underline = true }, meths.get_hl(0, { name = 'Foo', link = true }))
+ end)
+
+ it('can set link as well as other attributes', function()
+ command('hi Bar guifg=red')
+ local hl = { link = 'Bar', fg = tonumber('00ff00', 16), bold = true, cterm = { bold = true } }
+ meths.set_hl(0, 'Foo', hl)
+ eq(hl, meths.get_hl(0, { name = 'Foo', link = true }))
+ end)
end)
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index d8fb1bc623..9d5a0c4b4e 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -2892,6 +2892,99 @@ describe('API', function()
end)
end)
+ describe('nvim_get_option_info2', function()
+ local fname
+ local bufs
+ local wins
+
+ before_each(function()
+ fname = tmpname()
+ write_file(fname, [[
+ setglobal dictionary=mydict " 1, global-local (buffer)
+ setlocal formatprg=myprg " 2, global-local (buffer)
+ setglobal equalprg=prg1 " 3, global-local (buffer)
+ setlocal equalprg=prg2 " 4, global-local (buffer)
+ setglobal fillchars=stl:x " 5, global-local (window)
+ setlocal listchars=eol:c " 6, global-local (window)
+ setglobal showbreak=aaa " 7, global-local (window)
+ setlocal showbreak=bbb " 8, global-local (window)
+ setglobal completeopt=menu " 9, global
+ ]])
+
+ exec_lua 'vim.cmd.vsplit()'
+ meths.create_buf(false, false)
+
+ bufs = meths.list_bufs()
+ wins = meths.list_wins()
+
+ meths.win_set_buf(wins[1].id, bufs[1].id)
+ meths.win_set_buf(wins[2].id, bufs[2].id)
+
+ meths.set_current_win(wins[2].id)
+ meths.exec('source ' .. fname, false)
+
+ meths.set_current_win(wins[1].id)
+ end)
+
+ after_each(function()
+ os.remove(fname)
+ end)
+
+ it('should return option information', function()
+ eq(meths.get_option_info('dictionary'), meths.get_option_info2('dictionary', {})) -- buffer
+ eq(meths.get_option_info('fillchars'), meths.get_option_info2('fillchars', {})) -- window
+ eq(meths.get_option_info('completeopt'), meths.get_option_info2('completeopt', {})) -- global
+ end)
+
+ describe('last set', function()
+ local tests = {
+ {desc="(buf option, global requested, global set) points to global", linenr=1, sid=1, args={'dictionary', {scope='global'}}},
+ {desc="(buf option, global requested, local set) is not set", linenr=0, sid=0, args={'formatprg', {scope='global'}}},
+ {desc="(buf option, global requested, both set) points to global", linenr=3, sid=1, args={'equalprg', {scope='global'}}},
+ {desc="(buf option, local requested, global set) is not set", linenr=0, sid=0, args={'dictionary', {scope='local'}}},
+ {desc="(buf option, local requested, local set) points to local", linenr=2, sid=1, args={'formatprg', {scope='local'}}},
+ {desc="(buf option, local requested, both set) points to local", linenr=4, sid=1, args={'equalprg', {scope='local'}}},
+ {desc="(buf option, fallback requested, global set) points to global", linenr=1, sid=1, args={'dictionary', {}}},
+ {desc="(buf option, fallback requested, local set) points to local", linenr=2, sid=1, args={'formatprg', {}}},
+ {desc="(buf option, fallback requested, both set) points to local", linenr=4, sid=1, args={'equalprg', {}}},
+ {desc="(win option, global requested, global set) points to global", linenr=5, sid=1, args={'fillchars', {scope='global'}}},
+ {desc="(win option, global requested, local set) is not set", linenr=0, sid=0, args={'listchars', {scope='global'}}},
+ {desc="(win option, global requested, both set) points to global", linenr=7, sid=1, args={'showbreak', {scope='global'}}},
+ {desc="(win option, local requested, global set) is not set", linenr=0, sid=0, args={'fillchars', {scope='local'}}},
+ {desc="(win option, local requested, local set) points to local", linenr=6, sid=1, args={'listchars', {scope='local'}}},
+ {desc="(win option, local requested, both set) points to local", linenr=8, sid=1, args={'showbreak', {scope='local'}}},
+ {desc="(win option, fallback requested, global set) points to global", linenr=5, sid=1, args={'fillchars', {}}},
+ {desc="(win option, fallback requested, local set) points to local", linenr=6, sid=1, args={'listchars', {}}},
+ {desc="(win option, fallback requested, both set) points to local", linenr=8, sid=1, args={'showbreak', {}}},
+ {desc="(global option, global requested) points to global", linenr=9, sid=1, args={'completeopt', {scope='global'}}},
+ {desc="(global option, local requested) is not set", linenr=0, sid=0, args={'completeopt', {scope='local'}}},
+ {desc="(global option, fallback requested) points to global", linenr=9, sid=1, args={'completeopt', {}}},
+ }
+
+ for _, t in pairs(tests) do
+ it(t.desc, function()
+ -- Switch to the target buffer/window so that curbuf/curwin are used.
+ meths.set_current_win(wins[2].id)
+ local info = meths.get_option_info2(unpack(t.args))
+ eq(t.linenr, info.last_set_linenr)
+ eq(t.sid, info.last_set_sid)
+ end)
+ end
+
+ it('is provided for cross-buffer requests', function()
+ local info = meths.get_option_info2('formatprg', {buf=bufs[2].id})
+ eq(2, info.last_set_linenr)
+ eq(1, info.last_set_sid)
+ end)
+
+ it('is provided for cross-window requests', function()
+ local info = meths.get_option_info2('listchars', {win=wins[2].id})
+ eq(6, info.last_set_linenr)
+ eq(1, info.last_set_sid)
+ end)
+ end)
+ end)
+
describe('nvim_echo', function()
local screen
diff --git a/test/functional/lua/diagnostic_spec.lua b/test/functional/lua/diagnostic_spec.lua
index d364986ad7..7b4d68c9cd 100644
--- a/test/functional/lua/diagnostic_spec.lua
+++ b/test/functional/lua/diagnostic_spec.lua
@@ -86,6 +86,7 @@ describe('vim.diagnostic', function()
it('creates highlight groups', function()
command('runtime plugin/diagnostic.vim')
eq({
+ 'DiagnosticDeprecated',
'DiagnosticError',
'DiagnosticFloatingError',
'DiagnosticFloatingHint',
@@ -105,6 +106,7 @@ describe('vim.diagnostic', function()
'DiagnosticUnderlineInfo',
'DiagnosticUnderlineOk',
'DiagnosticUnderlineWarn',
+ 'DiagnosticUnnecessary',
'DiagnosticVirtualTextError',
'DiagnosticVirtualTextHint',
'DiagnosticVirtualTextInfo',
diff --git a/test/functional/lua/ffi_spec.lua b/test/functional/lua/ffi_spec.lua
index c492c1e765..3a37b18cd1 100644
--- a/test/functional/lua/ffi_spec.lua
+++ b/test/functional/lua/ffi_spec.lua
@@ -25,7 +25,6 @@ describe('ffi.cdef', function()
local ffi = require('ffi')
ffi.cdef[[
- typedef unsigned char char_u;
typedef struct window_S win_T;
typedef struct {} stl_hlrec_t;
typedef struct {} StlClickRecord;
diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua
index a0428ed933..4f401eed8f 100644
--- a/test/functional/lua/vim_spec.lua
+++ b/test/functional/lua/vim_spec.lua
@@ -2915,6 +2915,15 @@ describe('lua stdlib', function()
return a
]])
end)
+
+ it('accepts the key name', function()
+ eq({ b = 'b', c = 'c' }, exec_lua [[
+ local a = vim.defaulttable(function(k) return k end)
+ local _ = a.b
+ local _ = a.c
+ return a
+ ]])
+ end)
end)
it('vim.lua_omnifunc', function()
diff --git a/test/functional/plugin/lsp/diagnostic_spec.lua b/test/functional/plugin/lsp/diagnostic_spec.lua
index f73ffc29b0..f58016bf01 100644
--- a/test/functional/plugin/lsp/diagnostic_spec.lua
+++ b/test/functional/plugin/lsp/diagnostic_spec.lua
@@ -97,7 +97,6 @@ describe('vim.lsp.diagnostic', function()
}
diagnostics[1].code = 42
- diagnostics[1].tags = {"foo", "bar"}
diagnostics[1].data = "Hello world"
vim.lsp.diagnostic.on_publish_diagnostics(nil, {
@@ -110,10 +109,9 @@ describe('vim.lsp.diagnostic', function()
vim.lsp.diagnostic.get_line_diagnostics(diagnostic_bufnr, 1)[1],
}
]]
- eq({code = 42, tags = {"foo", "bar"}, data = "Hello world"}, result[1].user_data.lsp)
+ eq({code = 42, data = "Hello world"}, result[1].user_data.lsp)
eq(42, result[1].code)
eq(42, result[2].code)
- eq({"foo", "bar"}, result[2].tags)
eq("Hello world", result[2].data)
end)
end)
diff --git a/test/functional/treesitter/highlight_spec.lua b/test/functional/treesitter/highlight_spec.lua
index 44e6500008..4e1efec404 100644
--- a/test/functional/treesitter/highlight_spec.lua
+++ b/test/functional/treesitter/highlight_spec.lua
@@ -413,7 +413,7 @@ describe('treesitter highlighting', function()
it("supports injected languages", function()
insert([[
int x = INT_MAX;
- #define READ_STRING(x, y) (char_u *)read_string((x), (size_t)(y))
+ #define READ_STRING(x, y) (char *)read_string((x), (size_t)(y))
#define foo void main() { \
return 42; \
}
@@ -421,7 +421,7 @@ describe('treesitter highlighting', function()
screen:expect{grid=[[
int x = INT_MAX; |
- #define READ_STRING(x, y) (char_u *)read_string((x), (size_t)(y))|
+ #define READ_STRING(x, y) (char *)read_string((x), (size_t)(y)) |
#define foo void main() { \ |
return 42; \ |
} |
@@ -450,7 +450,7 @@ describe('treesitter highlighting', function()
screen:expect{grid=[[
{3:int} x = {5:INT_MAX}; |
- #define {5:READ_STRING}(x, y) ({3:char_u} *)read_string((x), ({3:size_t})(y))|
+ #define {5:READ_STRING}(x, y) ({3:char} *)read_string((x), ({3:size_t})(y)) |
#define foo {3:void} main() { \ |
{4:return} {5:42}; \ |
} |
@@ -473,7 +473,7 @@ describe('treesitter highlighting', function()
it("supports overriding queries, like ", function()
insert([[
int x = INT_MAX;
- #define READ_STRING(x, y) (char_u *)read_string((x), (size_t)(y))
+ #define READ_STRING(x, y) (char *)read_string((x), (size_t)(y))
#define foo void main() { \
return 42; \
}
@@ -489,7 +489,7 @@ describe('treesitter highlighting', function()
screen:expect{grid=[[
{3:int} x = {5:INT_MAX}; |
- #define {5:READ_STRING}(x, y) ({3:char_u} *)read_string((x), ({3:size_t})(y))|
+ #define {5:READ_STRING}(x, y) ({3:char} *)read_string((x), ({3:size_t})(y)) |
#define foo {3:void} main() { \ |
{4:return} {5:42}; \ |
} |
@@ -567,7 +567,7 @@ describe('treesitter highlighting', function()
it("supports highlighting with priority", function()
insert([[
int x = INT_MAX;
- #define READ_STRING(x, y) (char_u *)read_string((x), (size_t)(y))
+ #define READ_STRING(x, y) (char *)read_string((x), (size_t)(y))
#define foo void main() { \
return 42; \
}
@@ -575,14 +575,14 @@ describe('treesitter highlighting', function()
exec_lua [[
local parser = vim.treesitter.get_parser(0, "c")
- test_hl = vim.treesitter.highlighter.new(parser, {queries = {c = hl_query..'\n((translation_unit) @Error (set! "priority" 101))\n'}})
+ test_hl = vim.treesitter.highlighter.new(parser, {queries = {c = hl_query..'\n((translation_unit) @constant (#set! "priority" 101))\n'}})
]]
- -- expect everything to have Error highlight
+ -- expect everything to have Constant highlight
screen:expect{grid=[[
{12:int}{8: x = INT_MAX;} |
- {8:#define READ_STRING(x, y) (}{12:char_u}{8: *)read_string((x), (}{12:size_t}{8:)(y))}|
- {8:#define foo }{12:void}{8: main() { \} |
- {8: }{12:return}{8: 42; \} |
+ {8:#define READ_STRING(x, y) (char *)read_string((x), (size_t)(y))} |
+ {8:#define foo void main() { \} |
+ {8: return 42; \} |
{8: }} |
^ |
{1:~ }|
@@ -599,13 +599,13 @@ describe('treesitter highlighting', function()
|
]], attr_ids={
[1] = {bold = true, foreground = Screen.colors.Blue1};
- [8] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red};
+ [8] = {foreground = Screen.colors.Magenta1};
-- bold will not be overwritten at the moment
- [12] = {background = Screen.colors.Red, bold = true, foreground = Screen.colors.Grey100};
+ [12] = {bold = true, foreground = Screen.colors.Magenta1};
}}
eq({
- {capture='Error', metadata = { priority='101' }, lang='c' };
+ {capture='constant', metadata = { priority='101' }, lang='c' };
{capture='type', metadata = { }, lang='c' };
}, exec_lua [[ return vim.treesitter.get_captures_at_pos(0, 0, 2) ]])
end)
diff --git a/test/functional/treesitter/parser_spec.lua b/test/functional/treesitter/parser_spec.lua
index 72a8cd9e9b..ea9958b12a 100644
--- a/test/functional/treesitter/parser_spec.lua
+++ b/test/functional/treesitter/parser_spec.lua
@@ -627,8 +627,8 @@ end]]
before_each(function()
insert([[
int x = INT_MAX;
-#define READ_STRING(x, y) (char_u *)read_string((x), (size_t)(y))
-#define READ_STRING_OK(x, y) (char_u *)read_string((x), (size_t)(y))
+#define READ_STRING(x, y) (char *)read_string((x), (size_t)(y))
+#define READ_STRING_OK(x, y) (char *)read_string((x), (size_t)(y))
#define VALUE 123
#define VALUE1 123
#define VALUE2 123
@@ -650,8 +650,8 @@ int x = INT_MAX;
{3, 14, 3, 17}, -- VALUE 123
{4, 15, 4, 18}, -- VALUE1 123
{5, 15, 5, 18}, -- VALUE2 123
- {1, 26, 1, 65}, -- READ_STRING(x, y) (char_u *)read_string((x), (size_t)(y))
- {2, 29, 2, 68} -- READ_STRING_OK(x, y) (char_u *)read_string((x), (size_t)(y))
+ {1, 26, 1, 63}, -- READ_STRING(x, y) (char *)read_string((x), (size_t)(y))
+ {2, 29, 2, 66} -- READ_STRING_OK(x, y) (char *)read_string((x), (size_t)(y))
}, get_ranges())
helpers.feed('ggo<esc>')
@@ -661,8 +661,8 @@ int x = INT_MAX;
{4, 14, 4, 17}, -- VALUE 123
{5, 15, 5, 18}, -- VALUE1 123
{6, 15, 6, 18}, -- VALUE2 123
- {2, 26, 2, 65}, -- READ_STRING(x, y) (char_u *)read_string((x), (size_t)(y))
- {3, 29, 3, 68} -- READ_STRING_OK(x, y) (char_u *)read_string((x), (size_t)(y))
+ {2, 26, 2, 63}, -- READ_STRING(x, y) (char *)read_string((x), (size_t)(y))
+ {3, 29, 3, 66} -- READ_STRING_OK(x, y) (char *)read_string((x), (size_t)(y))
}, get_ranges())
end)
end)
@@ -682,8 +682,8 @@ int x = INT_MAX;
{3, 14, 5, 18}, -- VALUE 123
-- VALUE1 123
-- VALUE2 123
- {1, 26, 2, 68} -- READ_STRING(x, y) (char_u *)read_string((x), (size_t)(y))
- -- READ_STRING_OK(x, y) (char_u *)read_string((x), (size_t)(y))
+ {1, 26, 2, 66} -- READ_STRING(x, y) (char *)read_string((x), (size_t)(y))
+ -- READ_STRING_OK(x, y) (char *)read_string((x), (size_t)(y))
}, get_ranges())
helpers.feed('ggo<esc>')
@@ -694,8 +694,8 @@ int x = INT_MAX;
{4, 14, 6, 18}, -- VALUE 123
-- VALUE1 123
-- VALUE2 123
- {2, 26, 3, 68} -- READ_STRING(x, y) (char_u *)read_string((x), (size_t)(y))
- -- READ_STRING_OK(x, y) (char_u *)read_string((x), (size_t)(y))
+ {2, 26, 3, 66} -- READ_STRING(x, y) (char *)read_string((x), (size_t)(y))
+ -- READ_STRING_OK(x, y) (char *)read_string((x), (size_t)(y))
}, get_ranges())
end)
end)
@@ -722,8 +722,8 @@ int x = INT_MAX;
{3, 14, 5, 18}, -- VALUE 123
-- VALUE1 123
-- VALUE2 123
- {1, 26, 2, 68} -- READ_STRING(x, y) (char_u *)read_string((x), (size_t)(y))
- -- READ_STRING_OK(x, y) (char_u *)read_string((x), (size_t)(y))
+ {1, 26, 2, 66} -- READ_STRING(x, y) (char *)read_string((x), (size_t)(y))
+ -- READ_STRING_OK(x, y) (char *)read_string((x), (size_t)(y))
}, get_ranges())
helpers.feed('ggo<esc>')
@@ -734,8 +734,8 @@ int x = INT_MAX;
{4, 14, 6, 18}, -- VALUE 123
-- VALUE1 123
-- VALUE2 123
- {2, 26, 3, 68} -- READ_STRING(x, y) (char_u *)read_string((x), (size_t)(y))
- -- READ_STRING_OK(x, y) (char_u *)read_string((x), (size_t)(y))
+ {2, 26, 3, 66} -- READ_STRING(x, y) (char *)read_string((x), (size_t)(y))
+ -- READ_STRING_OK(x, y) (char *)read_string((x), (size_t)(y))
}, get_ranges())
end)
@@ -768,8 +768,8 @@ int x = INT_MAX;
{3, 15, 3, 16}, -- VALUE 123
{4, 16, 4, 17}, -- VALUE1 123
{5, 16, 5, 17}, -- VALUE2 123
- {1, 26, 1, 65}, -- READ_STRING(x, y) (char_u *)read_string((x), (size_t)(y))
- {2, 29, 2, 68} -- READ_STRING_OK(x, y) (char_u *)read_string((x), (size_t)(y))
+ {1, 26, 1, 63}, -- READ_STRING(x, y) (char *)read_string((x), (size_t)(y))
+ {2, 29, 2, 66} -- READ_STRING_OK(x, y) (char *)read_string((x), (size_t)(y))
}, get_ranges())
end)
it("should list all directives", function()
diff --git a/test/old/testdir/test_filetype.vim b/test/old/testdir/test_filetype.vim
index 29eb0c599d..23adff3d3d 100644
--- a/test/old/testdir/test_filetype.vim
+++ b/test/old/testdir/test_filetype.vim
@@ -338,6 +338,7 @@ let s:filename_checks = {
\ 'lite': ['file.lite', 'file.lt'],
\ 'litestep': ['/LiteStep/any/file.rc', 'any/LiteStep/any/file.rc'],
\ 'logcheck': ['/etc/logcheck/file.d-some/file', '/etc/logcheck/file.d/file', 'any/etc/logcheck/file.d-some/file', 'any/etc/logcheck/file.d/file'],
+ \ 'livebook': ['file.livemd'],
\ 'loginaccess': ['/etc/login.access', 'any/etc/login.access'],
\ 'logindefs': ['/etc/login.defs', 'any/etc/login.defs'],
\ 'logtalk': ['file.lgt'],
diff --git a/test/old/testdir/test_packadd.vim b/test/old/testdir/test_packadd.vim
index 3121b3b4d1..64c8fd8659 100644
--- a/test/old/testdir/test_packadd.vim
+++ b/test/old/testdir/test_packadd.vim
@@ -20,6 +20,13 @@ func Test_packadd()
call mkdir(s:plugdir . '/plugin/also', 'p')
call mkdir(s:plugdir . '/ftdetect', 'p')
call mkdir(s:plugdir . '/after', 'p')
+
+ " This used to crash Vim
+ let &rtp = 'nosuchdir,' . s:plugdir . '/after'
+ packadd mytest
+ " plugdir should be inserted before plugdir/after
+ call assert_match('^nosuchdir,' . s:plugdir . ',', &rtp)
+
set rtp&
let rtp = &rtp
filetype on
diff --git a/test/symbolic/klee/nvim/charset.c b/test/symbolic/klee/nvim/charset.c
deleted file mode 100644
index fd1c5ee4b9..0000000000
--- a/test/symbolic/klee/nvim/charset.c
+++ /dev/null
@@ -1,172 +0,0 @@
-#include <stdbool.h>
-
-#include "nvim/ascii.h"
-#include "nvim/macros.h"
-#include "nvim/charset.h"
-#include "nvim/eval/typval.h"
-#include "nvim/vim.h"
-
-int hex2nr(int c)
-{
- if ((c >= 'a') && (c <= 'f')) {
- return c - 'a' + 10;
- }
-
- if ((c >= 'A') && (c <= 'F')) {
- return c - 'A' + 10;
- }
- return c - '0';
-}
-
-void vim_str2nr(const char_u *const start, int *const prep, int *const len,
- const int what, varnumber_T *const nptr,
- uvarnumber_T *const unptr, const int maxlen)
-{
- const char *ptr = (const char *)start;
-#define STRING_ENDED(ptr) \
- (!(maxlen == 0 || (int)((ptr) - (const char *)start) < maxlen))
- int pre = 0; // default is decimal
- const bool negative = (ptr[0] == '-');
- uvarnumber_T un = 0;
-
- if (negative) {
- ptr++;
- }
-
- if (what & STR2NR_FORCE) {
- // When forcing main consideration is skipping the prefix. Octal and decimal
- // numbers have no prefixes to skip. pre is not set.
- switch ((unsigned)what & (~(unsigned)STR2NR_FORCE)) {
- case STR2NR_HEX: {
- if (!STRING_ENDED(ptr + 2)
- && ptr[0] == '0'
- && (ptr[1] == 'x' || ptr[1] == 'X')
- && ascii_isxdigit(ptr[2])) {
- ptr += 2;
- }
- goto vim_str2nr_hex;
- }
- case STR2NR_BIN: {
- if (!STRING_ENDED(ptr + 2)
- && ptr[0] == '0'
- && (ptr[1] == 'b' || ptr[1] == 'B')
- && ascii_isbdigit(ptr[2])) {
- ptr += 2;
- }
- goto vim_str2nr_bin;
- }
- case STR2NR_OCT: {
- goto vim_str2nr_oct;
- }
- case 0: {
- goto vim_str2nr_dec;
- }
- default: {
- abort();
- }
- }
- } else if ((what & (STR2NR_HEX|STR2NR_OCT|STR2NR_BIN))
- && !STRING_ENDED(ptr + 1)
- && ptr[0] == '0' && ptr[1] != '8' && ptr[1] != '9') {
- pre = ptr[1];
- // Detect hexadecimal: 0x or 0X followed by hex digit
- if ((what & STR2NR_HEX)
- && !STRING_ENDED(ptr + 2)
- && (pre == 'X' || pre == 'x')
- && ascii_isxdigit(ptr[2])) {
- ptr += 2;
- goto vim_str2nr_hex;
- }
- // Detect binary: 0b or 0B followed by 0 or 1
- if ((what & STR2NR_BIN)
- && !STRING_ENDED(ptr + 2)
- && (pre == 'B' || pre == 'b')
- && ascii_isbdigit(ptr[2])) {
- ptr += 2;
- goto vim_str2nr_bin;
- }
- // Detect octal number: zero followed by octal digits without '8' or '9'
- pre = 0;
- if (!(what & STR2NR_OCT)) {
- goto vim_str2nr_dec;
- }
- for (int i = 2; !STRING_ENDED(ptr + i) && ascii_isdigit(ptr[i]); i++) {
- if (ptr[i] > '7') {
- goto vim_str2nr_dec;
- }
- }
- pre = '0';
- goto vim_str2nr_oct;
- } else {
- goto vim_str2nr_dec;
- }
-
- // Do the string-to-numeric conversion "manually" to avoid sscanf quirks.
- abort(); // Should’ve used goto earlier.
-#define PARSE_NUMBER(base, cond, conv) \
- do { \
- while (!STRING_ENDED(ptr) && (cond)) { \
- /* avoid ubsan error for overflow */ \
- if (un < UVARNUMBER_MAX / base) { \
- un = base * un + (uvarnumber_T)(conv); \
- } else { \
- un = UVARNUMBER_MAX; \
- } \
- ptr++; \
- } \
- } while (0)
- switch (pre) {
- case 'b':
- case 'B': {
-vim_str2nr_bin:
- PARSE_NUMBER(2, (*ptr == '0' || *ptr == '1'), (*ptr - '0'));
- break;
- }
- case '0': {
-vim_str2nr_oct:
- PARSE_NUMBER(8, ('0' <= *ptr && *ptr <= '7'), (*ptr - '0'));
- break;
- }
- case 0: {
-vim_str2nr_dec:
- PARSE_NUMBER(10, (ascii_isdigit(*ptr)), (*ptr - '0'));
- break;
- }
- case 'x':
- case 'X': {
-vim_str2nr_hex:
- PARSE_NUMBER(16, (ascii_isxdigit(*ptr)), (hex2nr(*ptr)));
- break;
- }
- }
-#undef PARSE_NUMBER
-
- if (prep != NULL) {
- *prep = pre;
- }
-
- if (len != NULL) {
- *len = (int)(ptr - (const char *)start);
- }
-
- if (nptr != NULL) {
- if (negative) { // account for leading '-' for decimal numbers
- // avoid ubsan error for overflow
- if (un > VARNUMBER_MAX) {
- *nptr = VARNUMBER_MIN;
- } else {
- *nptr = -(varnumber_T)un;
- }
- } else {
- if (un > VARNUMBER_MAX) {
- un = VARNUMBER_MAX;
- }
- *nptr = (varnumber_T)un;
- }
- }
-
- if (unptr != NULL) {
- *unptr = un;
- }
-#undef STRING_ENDED
-}
diff --git a/test/symbolic/klee/nvim/garray.c b/test/symbolic/klee/nvim/garray.c
deleted file mode 100644
index 260870c3c2..0000000000
--- a/test/symbolic/klee/nvim/garray.c
+++ /dev/null
@@ -1,195 +0,0 @@
-// This is an open source non-commercial project. Dear PVS-Studio, please check
-// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
-
-/// @file garray.c
-///
-/// Functions for handling growing arrays.
-
-#include <string.h>
-#include <inttypes.h>
-
-#include "nvim/vim.h"
-#include "nvim/ascii.h"
-#include "nvim/log.h"
-#include "nvim/memory.h"
-#include "nvim/path.h"
-#include "nvim/garray.h"
-#include "nvim/strings.h"
-
-// #include "nvim/globals.h"
-#include "nvim/memline.h"
-
-#ifdef INCLUDE_GENERATED_DECLARATIONS
-# include "garray.c.generated.h"
-#endif
-
-/// Clear an allocated growing array.
-void ga_clear(garray_T *gap)
-{
- xfree(gap->ga_data);
-
- // Initialize growing array without resetting itemsize or growsize
- gap->ga_data = NULL;
- gap->ga_maxlen = 0;
- gap->ga_len = 0;
-}
-
-/// Clear a growing array that contains a list of strings.
-///
-/// @param gap
-void ga_clear_strings(garray_T *gap)
-{
- GA_DEEP_CLEAR_PTR(gap);
-}
-
-/// Initialize a growing array.
-///
-/// @param gap
-/// @param itemsize
-/// @param growsize
-void ga_init(garray_T *gap, int itemsize, int growsize)
-{
- gap->ga_data = NULL;
- gap->ga_maxlen = 0;
- gap->ga_len = 0;
- gap->ga_itemsize = itemsize;
- ga_set_growsize(gap, growsize);
-}
-
-/// A setter for the growsize that guarantees it will be at least 1.
-///
-/// @param gap
-/// @param growsize
-void ga_set_growsize(garray_T *gap, int growsize)
-{
- if (growsize < 1) {
- WLOG("trying to set an invalid ga_growsize: %d", growsize);
- gap->ga_growsize = 1;
- } else {
- gap->ga_growsize = growsize;
- }
-}
-
-/// Make room in growing array "gap" for at least "n" items.
-///
-/// @param gap
-/// @param n
-void ga_grow(garray_T *gap, int n)
-{
- if (gap->ga_maxlen - gap->ga_len >= n) {
- // the garray still has enough space, do nothing
- return;
- }
-
- if (gap->ga_growsize < 1) {
- WLOG("ga_growsize(%d) is less than 1", gap->ga_growsize);
- }
-
- // the garray grows by at least growsize
- if (n < gap->ga_growsize) {
- n = gap->ga_growsize;
- }
- int new_maxlen = gap->ga_len + n;
-
- size_t new_size = (size_t)(gap->ga_itemsize * new_maxlen);
- size_t old_size = (size_t)(gap->ga_itemsize * gap->ga_maxlen);
-
- // reallocate and clear the new memory
- char *pp = xrealloc(gap->ga_data, new_size);
- memset(pp + old_size, 0, new_size - old_size);
-
- gap->ga_maxlen = new_maxlen;
- gap->ga_data = pp;
-}
-
-/// For a growing array that contains a list of strings: concatenate all the
-/// strings with sep as separator.
-///
-/// @param gap
-/// @param sep
-///
-/// @returns the concatenated strings
-char_u *ga_concat_strings_sep(const garray_T *gap, const char *sep)
- FUNC_ATTR_NONNULL_RET
-{
- const size_t nelem = (size_t) gap->ga_len;
- const char **strings = gap->ga_data;
-
- if (nelem == 0) {
- return (char_u *) xstrdup("");
- }
-
- size_t len = 0;
- for (size_t i = 0; i < nelem; i++) {
- len += strlen(strings[i]);
- }
-
- // add some space for the (num - 1) separators
- len += (nelem - 1) * strlen(sep);
- char *const ret = xmallocz(len);
-
- char *s = ret;
- for (size_t i = 0; i < nelem - 1; i++) {
- s = xstpcpy(s, strings[i]);
- s = xstpcpy(s, sep);
- }
- strcpy(s, strings[nelem - 1]);
-
- return (char_u *) ret;
-}
-
-/// For a growing array that contains a list of strings: concatenate all the
-/// strings with a separating comma.
-///
-/// @param gap
-///
-/// @returns the concatenated strings
-char_u* ga_concat_strings(const garray_T *gap) FUNC_ATTR_NONNULL_RET
-{
- return ga_concat_strings_sep(gap, ",");
-}
-
-/// Concatenate a string to a growarray which contains characters.
-/// When "s" is NULL does not do anything.
-///
-/// WARNING:
-/// - Does NOT copy the NUL at the end!
-/// - The parameter may not overlap with the growing array
-///
-/// @param gap
-/// @param s
-void ga_concat(garray_T *gap, const char_u *restrict s)
-{
- if (s == NULL) {
- return;
- }
-
- ga_concat_len(gap, (const char *restrict) s, strlen((char *) s));
-}
-
-/// Concatenate a string to a growarray which contains characters
-///
-/// @param[out] gap Growarray to modify.
-/// @param[in] s String to concatenate.
-/// @param[in] len String length.
-void ga_concat_len(garray_T *const gap, const char *restrict s,
- const size_t len)
- FUNC_ATTR_NONNULL_ALL
-{
- if (len) {
- ga_grow(gap, (int) len);
- char *data = gap->ga_data;
- memcpy(data + gap->ga_len, s, len);
- gap->ga_len += (int) len;
- }
-}
-
-/// Append one byte to a growarray which contains bytes.
-///
-/// @param gap
-/// @param c
-void ga_append(garray_T *gap, char c)
-{
- GA_APPEND(char, gap, c);
-}
-
diff --git a/test/symbolic/klee/nvim/gettext.c b/test/symbolic/klee/nvim/gettext.c
deleted file mode 100644
index b9cc98d770..0000000000
--- a/test/symbolic/klee/nvim/gettext.c
+++ /dev/null
@@ -1,4 +0,0 @@
-char *gettext(const char *s)
-{
- return (char *)s;
-}
diff --git a/test/symbolic/klee/nvim/keymap.c b/test/symbolic/klee/nvim/keymap.c
deleted file mode 100644
index 1f7f0e0911..0000000000
--- a/test/symbolic/klee/nvim/keymap.c
+++ /dev/null
@@ -1,559 +0,0 @@
-#include <stdbool.h>
-
-#include "nvim/types.h"
-#include "nvim/keycodes.h"
-#include "nvim/ascii.h"
-#include "nvim/eval/typval.h"
-
-#define MOD_KEYS_ENTRY_SIZE 5
-
-static char_u modifier_keys_table[] =
-{
- MOD_MASK_SHIFT, '&', '9', '@', '1',
- MOD_MASK_SHIFT, '&', '0', '@', '2',
- MOD_MASK_SHIFT, '*', '1', '@', '4',
- MOD_MASK_SHIFT, '*', '2', '@', '5',
- MOD_MASK_SHIFT, '*', '3', '@', '6',
- MOD_MASK_SHIFT, '*', '4', 'k', 'D',
- MOD_MASK_SHIFT, '*', '5', 'k', 'L',
- MOD_MASK_SHIFT, '*', '7', '@', '7',
- MOD_MASK_CTRL, KS_EXTRA, (int)KE_C_END, '@', '7',
- MOD_MASK_SHIFT, '*', '9', '@', '9',
- MOD_MASK_SHIFT, '*', '0', '@', '0',
- MOD_MASK_SHIFT, '#', '1', '%', '1',
- MOD_MASK_SHIFT, '#', '2', 'k', 'h',
- MOD_MASK_CTRL, KS_EXTRA, (int)KE_C_HOME, 'k', 'h',
- MOD_MASK_SHIFT, '#', '3', 'k', 'I',
- MOD_MASK_SHIFT, '#', '4', 'k', 'l',
- MOD_MASK_CTRL, KS_EXTRA, (int)KE_C_LEFT, 'k', 'l',
- MOD_MASK_SHIFT, '%', 'a', '%', '3',
- MOD_MASK_SHIFT, '%', 'b', '%', '4',
- MOD_MASK_SHIFT, '%', 'c', '%', '5',
- MOD_MASK_SHIFT, '%', 'd', '%', '7',
- MOD_MASK_SHIFT, '%', 'e', '%', '8',
- MOD_MASK_SHIFT, '%', 'f', '%', '9',
- MOD_MASK_SHIFT, '%', 'g', '%', '0',
- MOD_MASK_SHIFT, '%', 'h', '&', '3',
- MOD_MASK_SHIFT, '%', 'i', 'k', 'r',
- MOD_MASK_CTRL, KS_EXTRA, (int)KE_C_RIGHT, 'k', 'r',
- MOD_MASK_SHIFT, '%', 'j', '&', '5',
- MOD_MASK_SHIFT, '!', '1', '&', '6',
- MOD_MASK_SHIFT, '!', '2', '&', '7',
- MOD_MASK_SHIFT, '!', '3', '&', '8',
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_UP, 'k', 'u',
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_DOWN, 'k', 'd',
-
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_XF1, KS_EXTRA, (int)KE_XF1,
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_XF2, KS_EXTRA, (int)KE_XF2,
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_XF3, KS_EXTRA, (int)KE_XF3,
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_XF4, KS_EXTRA, (int)KE_XF4,
-
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F1, 'k', '1',
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F2, 'k', '2',
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F3, 'k', '3',
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F4, 'k', '4',
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F5, 'k', '5',
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F6, 'k', '6',
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F7, 'k', '7',
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F8, 'k', '8',
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F9, 'k', '9',
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F10, 'k', ';',
-
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F11, 'F', '1',
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F12, 'F', '2',
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F13, 'F', '3',
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F14, 'F', '4',
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F15, 'F', '5',
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F16, 'F', '6',
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F17, 'F', '7',
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F18, 'F', '8',
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F19, 'F', '9',
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F20, 'F', 'A',
-
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F21, 'F', 'B',
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F22, 'F', 'C',
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F23, 'F', 'D',
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F24, 'F', 'E',
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F25, 'F', 'F',
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F26, 'F', 'G',
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F27, 'F', 'H',
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F28, 'F', 'I',
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F29, 'F', 'J',
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F30, 'F', 'K',
-
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F31, 'F', 'L',
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F32, 'F', 'M',
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F33, 'F', 'N',
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F34, 'F', 'O',
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F35, 'F', 'P',
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F36, 'F', 'Q',
- MOD_MASK_SHIFT, KS_EXTRA, (int)KE_S_F37, 'F', 'R',
-
- MOD_MASK_SHIFT, 'k', 'B', KS_EXTRA, (int)KE_TAB,
-
- NUL
-};
-
-int simplify_key(const int key, int *modifiers)
-{
- if (*modifiers & (MOD_MASK_SHIFT | MOD_MASK_CTRL | MOD_MASK_ALT)) {
- // TAB is a special case.
- if (key == TAB && (*modifiers & MOD_MASK_SHIFT)) {
- *modifiers &= ~MOD_MASK_SHIFT;
- return K_S_TAB;
- }
- const int key0 = KEY2TERMCAP0(key);
- const int key1 = KEY2TERMCAP1(key);
- for (int i = 0; modifier_keys_table[i] != NUL; i += MOD_KEYS_ENTRY_SIZE) {
- if (key0 == modifier_keys_table[i + 3]
- && key1 == modifier_keys_table[i + 4]
- && (*modifiers & modifier_keys_table[i])) {
- *modifiers &= ~modifier_keys_table[i];
- return TERMCAP2KEY(modifier_keys_table[i + 1],
- modifier_keys_table[i + 2]);
- }
- }
- }
- return key;
-}
-
-int handle_x_keys(const int key)
- FUNC_ATTR_CONST FUNC_ATTR_WARN_UNUSED_RESULT
-{
- switch (key) {
- case K_XUP: return K_UP;
- case K_XDOWN: return K_DOWN;
- case K_XLEFT: return K_LEFT;
- case K_XRIGHT: return K_RIGHT;
- case K_XHOME: return K_HOME;
- case K_ZHOME: return K_HOME;
- case K_XEND: return K_END;
- case K_ZEND: return K_END;
- case K_XF1: return K_F1;
- case K_XF2: return K_F2;
- case K_XF3: return K_F3;
- case K_XF4: return K_F4;
- case K_S_XF1: return K_S_F1;
- case K_S_XF2: return K_S_F2;
- case K_S_XF3: return K_S_F3;
- case K_S_XF4: return K_S_F4;
- }
- return key;
-}
-
-static const struct key_name_entry {
- int key; // Special key code or ascii value
- const char *name; // Name of key
-} key_names_table[] = {
- { ' ', "Space" },
- { TAB, "Tab" },
- { K_TAB, "Tab" },
- { NL, "NL" },
- { NL, "NewLine" }, // Alternative name
- { NL, "LineFeed" }, // Alternative name
- { NL, "LF" }, // Alternative name
- { CAR, "CR" },
- { CAR, "Return" }, // Alternative name
- { CAR, "Enter" }, // Alternative name
- { K_BS, "BS" },
- { K_BS, "BackSpace" }, // Alternative name
- { ESC, "Esc" },
- { CSI, "CSI" },
- { K_CSI, "xCSI" },
- { '|', "Bar" },
- { '\\', "Bslash" },
- { K_DEL, "Del" },
- { K_DEL, "Delete" }, // Alternative name
- { K_KDEL, "kDel" },
- { K_KDEL, "KPPeriod" }, // termkey KPPeriod value
- { K_UP, "Up" },
- { K_DOWN, "Down" },
- { K_LEFT, "Left" },
- { K_RIGHT, "Right" },
- { K_XUP, "xUp" },
- { K_XDOWN, "xDown" },
- { K_XLEFT, "xLeft" },
- { K_XRIGHT, "xRight" },
- { K_KUP, "kUp" },
- { K_KUP, "KP8" },
- { K_KDOWN, "kDown" },
- { K_KDOWN, "KP2" },
- { K_KLEFT, "kLeft" },
- { K_KLEFT, "KP4" },
- { K_KRIGHT, "kRight" },
- { K_KRIGHT, "KP6" },
-
- { K_F1, "F1" },
- { K_F2, "F2" },
- { K_F3, "F3" },
- { K_F4, "F4" },
- { K_F5, "F5" },
- { K_F6, "F6" },
- { K_F7, "F7" },
- { K_F8, "F8" },
- { K_F9, "F9" },
- { K_F10, "F10" },
-
- { K_F11, "F11" },
- { K_F12, "F12" },
- { K_F13, "F13" },
- { K_F14, "F14" },
- { K_F15, "F15" },
- { K_F16, "F16" },
- { K_F17, "F17" },
- { K_F18, "F18" },
- { K_F19, "F19" },
- { K_F20, "F20" },
-
- { K_F21, "F21" },
- { K_F22, "F22" },
- { K_F23, "F23" },
- { K_F24, "F24" },
- { K_F25, "F25" },
- { K_F26, "F26" },
- { K_F27, "F27" },
- { K_F28, "F28" },
- { K_F29, "F29" },
- { K_F30, "F30" },
-
- { K_F31, "F31" },
- { K_F32, "F32" },
- { K_F33, "F33" },
- { K_F34, "F34" },
- { K_F35, "F35" },
- { K_F36, "F36" },
- { K_F37, "F37" },
-
- { K_XF1, "xF1" },
- { K_XF2, "xF2" },
- { K_XF3, "xF3" },
- { K_XF4, "xF4" },
-
- { K_HELP, "Help" },
- { K_UNDO, "Undo" },
- { K_INS, "Insert" },
- { K_INS, "Ins" }, // Alternative name
- { K_KINS, "kInsert" },
- { K_KINS, "KP0" },
- { K_HOME, "Home" },
- { K_KHOME, "kHome" },
- { K_KHOME, "KP7" },
- { K_XHOME, "xHome" },
- { K_ZHOME, "zHome" },
- { K_END, "End" },
- { K_KEND, "kEnd" },
- { K_XEND, "xEnd" },
- { K_ZEND, "zEnd" },
- { K_PAGEUP, "PageUp" },
- { K_PAGEDOWN, "PageDown" },
- { K_KPAGEUP, "kPageUp" },
- { K_KPAGEUP, "KP9" },
- { K_KPAGEDOWN, "kPageDown" },
- { K_KPAGEDOWN, "KP3" },
- { K_KORIGIN, "kOrigin" },
- { K_KORIGIN, "KP5" },
-
- { K_KPLUS, "kPlus" },
- { K_KPLUS, "KPPlus" },
- { K_KMINUS, "kMinus" },
- { K_KMINUS, "KPMinus" },
- { K_KDIVIDE, "kDivide" },
- { K_KDIVIDE, "KPDiv" },
- { K_KMULTIPLY, "kMultiply" },
- { K_KMULTIPLY, "KPMult" },
- { K_KENTER, "kEnter" },
- { K_KENTER, "KPEnter" },
- { K_KPOINT, "kPoint" },
-
- { K_K0, "k0" },
- { K_K1, "k1" },
- { K_K2, "k2" },
- { K_K3, "k3" },
- { K_K4, "k4" },
- { K_K5, "k5" },
- { K_K6, "k6" },
- { K_K7, "k7" },
- { K_K8, "k8" },
- { K_K9, "k9" },
-
- { '<', "lt" },
-
- { K_MOUSE, "Mouse" },
- { K_LEFTMOUSE, "LeftMouse" },
- { K_LEFTMOUSE_NM, "LeftMouseNM" },
- { K_LEFTDRAG, "LeftDrag" },
- { K_LEFTRELEASE, "LeftRelease" },
- { K_LEFTRELEASE_NM, "LeftReleaseNM" },
- { K_MIDDLEMOUSE, "MiddleMouse" },
- { K_MIDDLEDRAG, "MiddleDrag" },
- { K_MIDDLERELEASE, "MiddleRelease" },
- { K_RIGHTMOUSE, "RightMouse" },
- { K_RIGHTDRAG, "RightDrag" },
- { K_RIGHTRELEASE, "RightRelease" },
- { K_MOUSEDOWN, "ScrollWheelUp" },
- { K_MOUSEUP, "ScrollWheelDown" },
- { K_MOUSELEFT, "ScrollWheelRight" },
- { K_MOUSERIGHT, "ScrollWheelLeft" },
- { K_MOUSEDOWN, "MouseDown" }, // OBSOLETE: Use
- { K_MOUSEUP, "MouseUp" }, // ScrollWheelXXX instead
- { K_X1MOUSE, "X1Mouse" },
- { K_X1DRAG, "X1Drag" },
- { K_X1RELEASE, "X1Release" },
- { K_X2MOUSE, "X2Mouse" },
- { K_X2DRAG, "X2Drag" },
- { K_X2RELEASE, "X2Release" },
- { K_DROP, "Drop" },
- { K_ZERO, "Nul" },
- { K_SNR, "SNR" },
- { K_PLUG, "Plug" },
- { K_PASTE, "Paste" },
- { 0, NULL }
-};
-
-int get_special_key_code(const char_u *name)
-{
- for (int i = 0; key_names_table[i].name != NULL; i++) {
- const char *const table_name = key_names_table[i].name;
- int j;
- for (j = 0; ascii_isident(name[j]) && table_name[j] != NUL; j++) {
- if (TOLOWER_ASC(table_name[j]) != TOLOWER_ASC(name[j])) {
- break;
- }
- }
- if (!ascii_isident(name[j]) && table_name[j] == NUL) {
- return key_names_table[i].key;
- }
- }
-
- return 0;
-}
-
-
-static const struct modmasktable {
- short mod_mask; ///< Bit-mask for particular key modifier.
- short mod_flag; ///< Bit(s) for particular key modifier.
- char_u name; ///< Single letter name of modifier.
-} mod_mask_table[] = {
- {MOD_MASK_ALT, MOD_MASK_ALT, (char_u)'M'},
- {MOD_MASK_META, MOD_MASK_META, (char_u)'T'},
- {MOD_MASK_CTRL, MOD_MASK_CTRL, (char_u)'C'},
- {MOD_MASK_SHIFT, MOD_MASK_SHIFT, (char_u)'S'},
- {MOD_MASK_MULTI_CLICK, MOD_MASK_2CLICK, (char_u)'2'},
- {MOD_MASK_MULTI_CLICK, MOD_MASK_3CLICK, (char_u)'3'},
- {MOD_MASK_MULTI_CLICK, MOD_MASK_4CLICK, (char_u)'4'},
- {MOD_MASK_CMD, MOD_MASK_CMD, (char_u)'D'},
- // 'A' must be the last one
- {MOD_MASK_ALT, MOD_MASK_ALT, (char_u)'A'},
- {0, 0, NUL}
-};
-
-int name_to_mod_mask(int c)
-{
- c = TOUPPER_ASC(c);
- for (size_t i = 0; mod_mask_table[i].mod_mask != 0; i++) {
- if (c == mod_mask_table[i].name) {
- return mod_mask_table[i].mod_flag;
- }
- }
- return 0;
-}
-
-static int extract_modifiers(int key, int *modp)
-{
- int modifiers = *modp;
-
- if (!(modifiers & MOD_MASK_CMD)) { // Command-key is special
- if ((modifiers & MOD_MASK_SHIFT) && ASCII_ISALPHA(key)) {
- key = TOUPPER_ASC(key);
- modifiers &= ~MOD_MASK_SHIFT;
- }
- }
- if ((modifiers & MOD_MASK_CTRL)
- && ((key >= '?' && key <= '_') || ASCII_ISALPHA(key))) {
- key = Ctrl_chr(key);
- modifiers &= ~MOD_MASK_CTRL;
- if (key == 0) { // <C-@> is <Nul>
- key = K_ZERO;
- }
- }
-
- *modp = modifiers;
- return key;
-}
-
-int find_special_key(const char_u **srcp, const size_t src_len, int *const modp,
- const bool keycode, const bool keep_x_key,
- const bool in_string)
-{
- const char_u *last_dash;
- const char_u *end_of_name;
- const char_u *src;
- const char_u *bp;
- const char_u *const end = *srcp + src_len - 1;
- int modifiers;
- int bit;
- int key;
- uvarnumber_T n;
- int l;
-
- if (src_len == 0) {
- return 0;
- }
-
- src = *srcp;
- if (src[0] != '<') {
- return 0;
- }
-
- // Find end of modifier list
- last_dash = src;
- for (bp = src + 1; bp <= end && (*bp == '-' || ascii_isident(*bp)); bp++) {
- if (*bp == '-') {
- last_dash = bp;
- if (bp + 1 <= end) {
- l = utfc_ptr2len_len(bp + 1, (int)(end - bp) + 1);
- // Anything accepted, like <C-?>.
- // <C-"> or <M-"> are not special in strings as " is
- // the string delimiter. With a backslash it works: <M-\">
- if (end - bp > l && !(in_string && bp[1] == '"') && bp[2] == '>') {
- bp += l;
- } else if (end - bp > 2 && in_string && bp[1] == '\\'
- && bp[2] == '"' && bp[3] == '>') {
- bp += 2;
- }
- }
- }
- if (end - bp > 3 && bp[0] == 't' && bp[1] == '_') {
- bp += 3; // skip t_xx, xx may be '-' or '>'
- } else if (end - bp > 4 && STRNICMP(bp, "char-", 5) == 0) {
- vim_str2nr(bp + 5, NULL, &l, STR2NR_ALL, NULL, NULL, 0);
- bp += l + 5;
- break;
- }
- }
-
- if (bp <= end && *bp == '>') { // found matching '>'
- end_of_name = bp + 1;
-
- /* Which modifiers are given? */
- modifiers = 0x0;
- for (bp = src + 1; bp < last_dash; bp++) {
- if (*bp != '-') {
- bit = name_to_mod_mask(*bp);
- if (bit == 0x0) {
- break; // Illegal modifier name
- }
- modifiers |= bit;
- }
- }
-
- // Legal modifier name.
- if (bp >= last_dash) {
- if (STRNICMP(last_dash + 1, "char-", 5) == 0
- && ascii_isdigit(last_dash[6])) {
- // <Char-123> or <Char-033> or <Char-0x33>
- vim_str2nr(last_dash + 6, NULL, NULL, STR2NR_ALL, NULL, &n, 0);
- key = (int)n;
- } else {
- int off = 1;
-
- // Modifier with single letter, or special key name.
- if (in_string && last_dash[1] == '\\' && last_dash[2] == '"') {
- off = 2;
- }
- l = mb_ptr2len(last_dash + 1);
- if (modifiers != 0 && last_dash[l + 1] == '>') {
- key = PTR2CHAR(last_dash + off);
- } else {
- key = get_special_key_code(last_dash + off);
- if (!keep_x_key) {
- key = handle_x_keys(key);
- }
- }
- }
-
- // get_special_key_code() may return NUL for invalid
- // special key name.
- if (key != NUL) {
- // Only use a modifier when there is no special key code that
- // includes the modifier.
- key = simplify_key(key, &modifiers);
-
- if (!keycode) {
- // don't want keycode, use single byte code
- if (key == K_BS) {
- key = BS;
- } else if (key == K_DEL || key == K_KDEL) {
- key = DEL;
- }
- }
-
- // Normal Key with modifier:
- // Try to make a single byte code (except for Alt/Meta modifiers).
- if (!IS_SPECIAL(key)) {
- key = extract_modifiers(key, &modifiers);
- }
-
- *modp = modifiers;
- *srcp = end_of_name;
- return key;
- }
- }
- }
- return 0;
-}
-
-char_u *add_char2buf(int c, char_u *s)
-{
- char_u temp[MB_MAXBYTES + 1];
- const int len = utf_char2bytes(c, temp);
- for (int i = 0; i < len; ++i) {
- c = temp[i];
- // Need to escape K_SPECIAL and CSI like in the typeahead buffer.
- if (c == K_SPECIAL) {
- *s++ = K_SPECIAL;
- *s++ = KS_SPECIAL;
- *s++ = KE_FILLER;
- } else {
- *s++ = c;
- }
- }
- return s;
-}
-
-unsigned int trans_special(const char_u **srcp, const size_t src_len,
- char_u *const dst, const bool keycode,
- const bool in_string)
-{
- int modifiers = 0;
- int key;
- unsigned int dlen = 0;
-
- key = find_special_key(srcp, src_len, &modifiers, keycode, false, in_string);
- if (key == 0) {
- return 0;
- }
-
- // Put the appropriate modifier in a string.
- if (modifiers != 0) {
- dst[dlen++] = K_SPECIAL;
- dst[dlen++] = KS_MODIFIER;
- dst[dlen++] = (char_u)modifiers;
- }
-
- if (IS_SPECIAL(key)) {
- dst[dlen++] = K_SPECIAL;
- dst[dlen++] = (char_u)KEY2TERMCAP0(key);
- dst[dlen++] = KEY2TERMCAP1(key);
- } else if (!keycode) {
- dlen += (unsigned int)(*mb_char2bytes)(key, dst + dlen);
- } else if (keycode) {
- char_u *after = add_char2buf(key, dst + dlen);
- assert(after >= dst && (uintmax_t)(after - dst) <= UINT_MAX);
- dlen = (unsigned int)(after - dst);
- } else {
- dst[dlen++] = (char_u)key;
- }
-
- return dlen;
-}
diff --git a/test/symbolic/klee/nvim/mbyte.c b/test/symbolic/klee/nvim/mbyte.c
deleted file mode 100644
index f98a531206..0000000000
--- a/test/symbolic/klee/nvim/mbyte.c
+++ /dev/null
@@ -1,266 +0,0 @@
-#include <stddef.h>
-#include <inttypes.h>
-#include <assert.h>
-#include <stdbool.h>
-
-#include "nvim/types.h"
-#include "nvim/mbyte.h"
-#include "nvim/ascii.h"
-
-const uint8_t utf8len_tab_zero[] = {
- //1 2 3 4 5 6 7 8 9 A B C D E F 0 1 2 3 4 5 6 7 8 9 A B C D E F
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 2
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 4
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 6
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 8
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // A
- 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, // C
- 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,6,6,0,0, // E
-};
-
-const uint8_t utf8len_tab[] = {
- // ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9 ?A ?B ?C ?D ?E ?F
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0?
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 1?
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 2?
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 3?
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 4?
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 5?
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 6?
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 7?
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 8?
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 9?
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // A?
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // B?
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // C?
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // D?
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // E?
- 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 1, 1, // F?
-};
-
-int utf_ptr2char(const char_u *const p)
-{
- if (p[0] < 0x80) { // Be quick for ASCII.
- return p[0];
- }
-
- const uint8_t len = utf8len_tab_zero[p[0]];
- if (len > 1 && (p[1] & 0xc0) == 0x80) {
- if (len == 2) {
- return ((p[0] & 0x1f) << 6) + (p[1] & 0x3f);
- }
- if ((p[2] & 0xc0) == 0x80) {
- if (len == 3) {
- return (((p[0] & 0x0f) << 12) + ((p[1] & 0x3f) << 6)
- + (p[2] & 0x3f));
- }
- if ((p[3] & 0xc0) == 0x80) {
- if (len == 4) {
- return (((p[0] & 0x07) << 18) + ((p[1] & 0x3f) << 12)
- + ((p[2] & 0x3f) << 6) + (p[3] & 0x3f));
- }
- if ((p[4] & 0xc0) == 0x80) {
- if (len == 5) {
- return (((p[0] & 0x03) << 24) + ((p[1] & 0x3f) << 18)
- + ((p[2] & 0x3f) << 12) + ((p[3] & 0x3f) << 6)
- + (p[4] & 0x3f));
- }
- if ((p[5] & 0xc0) == 0x80 && len == 6) {
- return (((p[0] & 0x01) << 30) + ((p[1] & 0x3f) << 24)
- + ((p[2] & 0x3f) << 18) + ((p[3] & 0x3f) << 12)
- + ((p[4] & 0x3f) << 6) + (p[5] & 0x3f));
- }
- }
- }
- }
- }
- // Illegal value: just return the first byte.
- return p[0];
-}
-
-bool utf_composinglike(const char_u *p1, const char_u *p2)
-{
- return false;
-}
-
-char_u *string_convert(const vimconv_T *conv, char_u *data, size_t *size)
-{
- return NULL;
-}
-
-int utf_ptr2len_len(const char_u *p, int size)
-{
- int len;
- int i;
- int m;
-
- len = utf8len_tab[*p];
- if (len == 1)
- return 1; /* NUL, ascii or illegal lead byte */
- if (len > size)
- m = size; /* incomplete byte sequence. */
- else
- m = len;
- for (i = 1; i < m; ++i)
- if ((p[i] & 0xc0) != 0x80)
- return 1;
- return len;
-}
-
-int utfc_ptr2len_len(const char_u *p, int size)
-{
- int len;
- int prevlen;
-
- if (size < 1 || *p == NUL)
- return 0;
- if (p[0] < 0x80 && (size == 1 || p[1] < 0x80)) /* be quick for ASCII */
- return 1;
-
- /* Skip over first UTF-8 char, stopping at a NUL byte. */
- len = utf_ptr2len_len(p, size);
-
- /* Check for illegal byte and incomplete byte sequence. */
- if ((len == 1 && p[0] >= 0x80) || len > size)
- return 1;
-
- /*
- * Check for composing characters. We can handle only the first six, but
- * skip all of them (otherwise the cursor would get stuck).
- */
- prevlen = 0;
- while (len < size) {
- int len_next_char;
-
- if (p[len] < 0x80)
- break;
-
- /*
- * Next character length should not go beyond size to ensure that
- * UTF_COMPOSINGLIKE(...) does not read beyond size.
- */
- len_next_char = utf_ptr2len_len(p + len, size - len);
- if (len_next_char > size - len)
- break;
-
- if (!UTF_COMPOSINGLIKE(p + prevlen, p + len))
- break;
-
- /* Skip over composing char */
- prevlen = len;
- len += len_next_char;
- }
- return len;
-}
-
-int utf_char2len(const int c)
-{
- if (c < 0x80) {
- return 1;
- } else if (c < 0x800) {
- return 2;
- } else if (c < 0x10000) {
- return 3;
- } else if (c < 0x200000) {
- return 4;
- } else if (c < 0x4000000) {
- return 5;
- } else {
- return 6;
- }
-}
-
-int utf_char2bytes(const int c, char_u *const buf)
-{
- if (c < 0x80) { // 7 bits
- buf[0] = c;
- return 1;
- } else if (c < 0x800) { // 11 bits
- buf[0] = 0xc0 + ((unsigned)c >> 6);
- buf[1] = 0x80 + (c & 0x3f);
- return 2;
- } else if (c < 0x10000) { // 16 bits
- buf[0] = 0xe0 + ((unsigned)c >> 12);
- buf[1] = 0x80 + (((unsigned)c >> 6) & 0x3f);
- buf[2] = 0x80 + (c & 0x3f);
- return 3;
- } else if (c < 0x200000) { // 21 bits
- buf[0] = 0xf0 + ((unsigned)c >> 18);
- buf[1] = 0x80 + (((unsigned)c >> 12) & 0x3f);
- buf[2] = 0x80 + (((unsigned)c >> 6) & 0x3f);
- buf[3] = 0x80 + (c & 0x3f);
- return 4;
- } else if (c < 0x4000000) { // 26 bits
- buf[0] = 0xf8 + ((unsigned)c >> 24);
- buf[1] = 0x80 + (((unsigned)c >> 18) & 0x3f);
- buf[2] = 0x80 + (((unsigned)c >> 12) & 0x3f);
- buf[3] = 0x80 + (((unsigned)c >> 6) & 0x3f);
- buf[4] = 0x80 + (c & 0x3f);
- return 5;
- } else { // 31 bits
- buf[0] = 0xfc + ((unsigned)c >> 30);
- buf[1] = 0x80 + (((unsigned)c >> 24) & 0x3f);
- buf[2] = 0x80 + (((unsigned)c >> 18) & 0x3f);
- buf[3] = 0x80 + (((unsigned)c >> 12) & 0x3f);
- buf[4] = 0x80 + (((unsigned)c >> 6) & 0x3f);
- buf[5] = 0x80 + (c & 0x3f);
- return 6;
- }
-}
-
-int utf_ptr2len(const char_u *const p)
-{
- if (*p == NUL) {
- return 0;
- }
- const int len = utf8len_tab[*p];
- for (int i = 1; i < len; i++) {
- if ((p[i] & 0xc0) != 0x80) {
- return 1;
- }
- }
- return len;
-}
-
-int utfc_ptr2len(const char_u *const p)
-{
- uint8_t b0 = (uint8_t)(*p);
-
- if (b0 == NUL) {
- return 0;
- }
- if (b0 < 0x80 && p[1] < 0x80) { // be quick for ASCII
- return 1;
- }
-
- // Skip over first UTF-8 char, stopping at a NUL byte.
- int len = utf_ptr2len(p);
-
- // Check for illegal byte.
- if (len == 1 && b0 >= 0x80) {
- return 1;
- }
-
- // Check for composing characters. We can handle only the first six, but
- // skip all of them (otherwise the cursor would get stuck).
- int prevlen = 0;
- for (;;) {
- if (p[len] < 0x80 || !UTF_COMPOSINGLIKE(p + prevlen, p + len)) {
- return len;
- }
-
- // Skip over composing char.
- prevlen = len;
- len += utf_ptr2len(p + len);
- }
-}
-
-void mb_copy_char(const char_u **fp, char_u **tp)
-{
- const size_t l = utfc_ptr2len(*fp);
-
- memmove(*tp, *fp, (size_t)l);
- *tp += l;
- *fp += l;
-}
diff --git a/test/symbolic/klee/nvim/memory.c b/test/symbolic/klee/nvim/memory.c
deleted file mode 100644
index 1614f813d7..0000000000
--- a/test/symbolic/klee/nvim/memory.c
+++ /dev/null
@@ -1,101 +0,0 @@
-#include <stdlib.h>
-#include <assert.h>
-
-#include "nvim/lib/ringbuf.h"
-
-enum { RB_SIZE = 1024 };
-
-typedef struct {
- void *ptr;
- size_t size;
-} AllocRecord;
-
-RINGBUF_TYPEDEF(AllocRecords, AllocRecord)
-RINGBUF_INIT(AllocRecords, arecs, AllocRecord, RINGBUF_DUMMY_FREE)
-RINGBUF_STATIC(static, AllocRecords, AllocRecord, arecs, RB_SIZE)
-
-size_t allocated_memory = 0;
-size_t ever_allocated_memory = 0;
-
-size_t allocated_memory_limit = SIZE_MAX;
-
-void *xmalloc(const size_t size)
-{
- void *ret = malloc(size);
- allocated_memory += size;
- ever_allocated_memory += size;
- assert(allocated_memory <= allocated_memory_limit);
- assert(arecs_rb_length(&arecs) < RB_SIZE);
- arecs_rb_push(&arecs, (AllocRecord) {
- .ptr = ret,
- .size = size,
- });
- return ret;
-}
-
-void xfree(void *const p)
-{
- if (p == NULL) {
- return;
- }
- RINGBUF_FORALL(&arecs, AllocRecord, arec) {
- if (arec->ptr == p) {
- allocated_memory -= arec->size;
- arecs_rb_remove(&arecs, arecs_rb_find_idx(&arecs, arec));
- return;
- }
- }
- abort();
-}
-
-void *xrealloc(void *const p, size_t new_size)
-{
- void *ret = realloc(p, new_size);
- RINGBUF_FORALL(&arecs, AllocRecord, arec) {
- if (arec->ptr == p) {
- allocated_memory -= arec->size;
- allocated_memory += new_size;
- if (new_size > arec->size) {
- ever_allocated_memory += (new_size - arec->size);
- }
- arec->ptr = ret;
- arec->size = new_size;
- return ret;
- }
- }
- abort();
- return (void *)(intptr_t)1;
-}
-
-char *xstrdup(const char *str)
- FUNC_ATTR_MALLOC FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_RET
- FUNC_ATTR_NONNULL_ALL
-{
- return xmemdupz(str, strlen(str));
-}
-
-void *xmallocz(size_t size)
- FUNC_ATTR_MALLOC FUNC_ATTR_NONNULL_RET FUNC_ATTR_WARN_UNUSED_RESULT
-{
- size_t total_size = size + 1;
- assert(total_size > size);
-
- void *ret = xmalloc(total_size);
- ((char *)ret)[size] = 0;
-
- return ret;
-}
-
-char *xstpcpy(char *restrict dst, const char *restrict src)
- FUNC_ATTR_NONNULL_RET FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
-{
- const size_t len = strlen(src);
- return (char *)memcpy(dst, src, len + 1) + len;
-}
-
-void *xmemdupz(const void *data, size_t len)
- FUNC_ATTR_MALLOC FUNC_ATTR_NONNULL_RET FUNC_ATTR_WARN_UNUSED_RESULT
- FUNC_ATTR_NONNULL_ALL
-{
- return memcpy(xmallocz(len), data, len);
-}
diff --git a/test/symbolic/klee/run.sh b/test/symbolic/klee/run.sh
deleted file mode 100755
index d022fccb02..0000000000
--- a/test/symbolic/klee/run.sh
+++ /dev/null
@@ -1,101 +0,0 @@
-#!/bin/sh
-
-set -e
-set -x
-test -z "$POSH_VERSION" && set -u
-
-PROJECT_SOURCE_DIR=.
-PROJECT_BINARY_DIR="$PROJECT_SOURCE_DIR/build"
-KLEE_TEST_DIR="$PROJECT_SOURCE_DIR/test/symbolic/klee"
-KLEE_BIN_DIR="$PROJECT_BINARY_DIR/klee"
-KLEE_OUT_DIR="$KLEE_BIN_DIR/out"
-
-help() {
- echo "Usage:"
- echo
- echo " $0 -c fname"
- echo " $0 fname"
- echo " $0 -s"
- echo
- echo "First form compiles executable out of test/symbolic/klee/{fname}.c."
- echo "Compiled executable is placed into build/klee/{fname}. Must first"
- echo "successfully compile Neovim in order to generate declarations."
- echo
- echo "Second form runs KLEE in a docker container using file "
- echo "test/symbolic/klee/{fname.c}. Bitcode is placed into build/klee/a.bc,"
- echo "results are placed into build/klee/out/. The latter is first deleted if"
- echo "it exists."
- echo
- echo "Third form runs ktest-tool which prints errors found by KLEE via "
- echo "the same container used to run KLEE."
-}
-
-main() {
- local compile=
- local print_errs=
- if test "$1" = "--help" ; then
- help
- return
- fi
- if test "$1" = "-s" ; then
- print_errs=1
- shift
- elif test "$1" = "-c" ; then
- compile=1
- shift
- fi
- if test -z "$print_errs" ; then
- local test="$1" ; shift
- fi
-
- local includes=
- includes="$includes -I$KLEE_TEST_DIR"
- includes="$includes -I/home/klee/klee_src/include"
- includes="$includes -I$PROJECT_SOURCE_DIR/src"
- includes="$includes -I$PROJECT_BINARY_DIR/src/nvim/auto"
- includes="$includes -I$PROJECT_BINARY_DIR/include"
- includes="$includes -I$PROJECT_BINARY_DIR/cmake.config"
- includes="$includes -I/host-includes"
-
- local defines=
- defines="$defines -DINCLUDE_GENERATED_DECLARATIONS"
-
- test -z "$compile" && defines="$defines -DUSE_KLEE"
-
- test -d "$KLEE_BIN_DIR" || mkdir -p "$KLEE_BIN_DIR"
-
- if test -z "$compile" ; then
- local line1='cd /image'
- if test -z "$print_errs" ; then
- test -d "$KLEE_OUT_DIR" && rm -r "$KLEE_OUT_DIR"
-
- line1="$line1 && $(echo clang \
- $includes $defines \
- -o "$KLEE_BIN_DIR/a.bc" -emit-llvm -g -c \
- "$KLEE_TEST_DIR/$test.c")"
- line1="$line1 && klee --libc=uclibc --posix-runtime "
- line1="$line1 '--output-dir=$KLEE_OUT_DIR' '$KLEE_BIN_DIR/a.bc'"
- fi
- local line2="for t in '$KLEE_OUT_DIR'/*.err"
- line2="$line2 ; do ktest-tool --write-ints"
- line2="$line2 \"\$(printf '%s' \"\$t\" | sed -e 's@\\.[^/]*\$@.ktest@')\""
- line2="$line2 ; done"
- printf '%s\n%s\n' "$line1" "$line2" | \
- docker run \
- --volume "$(cd "$PROJECT_SOURCE_DIR" && pwd)":/image \
- --volume "/usr/include":/host-includes \
- --interactive \
- --rm \
- --ulimit='stack=-1:-1' \
- klee/klee \
- /bin/sh -x
- else
- clang \
- $includes $defines \
- -o "$KLEE_BIN_DIR/$test" \
- -O0 -g \
- "$KLEE_TEST_DIR/$test.c"
- fi
-}
-
-main "$@"
diff --git a/test/symbolic/klee/viml_expressions_lexer.c b/test/symbolic/klee/viml_expressions_lexer.c
deleted file mode 100644
index 03c9d66ca4..0000000000
--- a/test/symbolic/klee/viml_expressions_lexer.c
+++ /dev/null
@@ -1,105 +0,0 @@
-#ifdef USE_KLEE
-# include <klee/klee.h>
-#else
-# include <string.h>
-# include <stdio.h>
-#endif
-#include <stddef.h>
-#include <stdint.h>
-#include <assert.h>
-
-#include "nvim/viml/parser/expressions.h"
-#include "nvim/viml/parser/parser.h"
-#include "nvim/mbyte.h"
-
-#include "nvim/memory.c"
-#include "nvim/mbyte.c"
-#include "nvim/charset.c"
-#include "nvim/garray.c"
-#include "nvim/gettext.c"
-#include "nvim/keycodes.c"
-#include "nvim/viml/parser/expressions.c"
-
-#define INPUT_SIZE 7
-
-uint8_t avoid_optimizing_out;
-
-void simple_get_line(void *cookie, ParserLine *ret_pline)
-{
- ParserLine **plines_p = (ParserLine **)cookie;
- *ret_pline = **plines_p;
- (*plines_p)++;
-}
-
-int main(const int argc, const char *const *const argv,
- const char *const *const environ)
-{
- char input[INPUT_SIZE];
- uint8_t shift;
- int flags;
- avoid_optimizing_out = argc;
-
-#ifndef USE_KLEE
- sscanf(argv[2], "%d", &flags);
-#endif
-
-#ifdef USE_KLEE
- klee_make_symbolic(input, sizeof(input), "input");
- klee_make_symbolic(&shift, sizeof(shift), "shift");
- klee_make_symbolic(&flags, sizeof(flags), "flags");
- klee_assume(shift < INPUT_SIZE);
- klee_assume(flags <= (kELFlagPeek|kELFlagAllowFloat|kELFlagForbidEOC
- |kELFlagForbidScope|kELFlagIsNotCmp));
-#endif
-
- ParserLine plines[] = {
- {
-#ifdef USE_KLEE
- .data = &input[shift],
- .size = sizeof(input) - shift,
-#else
- .data = (const char *)argv[1],
- .size = strlen(argv[1]),
-#endif
- .allocated = false,
- },
- {
- .data = NULL,
- .size = 0,
- .allocated = false,
- },
- };
-#ifdef USE_KLEE
- assert(plines[0].size <= INPUT_SIZE);
- assert((plines[0].data[0] != 5) | (plines[0].data[0] != argc));
-#endif
- ParserLine *cur_pline = &plines[0];
-
- ParserState pstate = {
- .reader = {
- .get_line = simple_get_line,
- .cookie = &cur_pline,
- .lines = KV_INITIAL_VALUE,
- .conv.vc_type = CONV_NONE,
- },
- .pos = { 0, 0 },
- .colors = NULL,
- .can_continuate = false,
- };
- kvi_init(pstate.reader.lines);
-
- allocated_memory_limit = 0;
- LexExprToken token = viml_pexpr_next_token(&pstate, flags);
- if (flags & kELFlagPeek) {
- assert(pstate.pos.line == 0 && pstate.pos.col == 0);
- } else {
- assert((pstate.pos.line == 0)
- ? (pstate.pos.col > 0)
- : (pstate.pos.line == 1 && pstate.pos.col == 0));
- }
- assert(allocated_memory == 0);
- assert(ever_allocated_memory == 0);
-#ifndef USE_KLEE
- fprintf(stderr, "tkn: %s\n", viml_pexpr_repr_token(&pstate, token, NULL));
-#endif
-}
diff --git a/test/symbolic/klee/viml_expressions_parser.c b/test/symbolic/klee/viml_expressions_parser.c
deleted file mode 100644
index b0e1d71127..0000000000
--- a/test/symbolic/klee/viml_expressions_parser.c
+++ /dev/null
@@ -1,117 +0,0 @@
-#ifdef USE_KLEE
-# include <klee/klee.h>
-#else
-# include <string.h>
-#endif
-#include <stddef.h>
-#include <stdint.h>
-#include <assert.h>
-
-#include "nvim/viml/parser/expressions.h"
-#include "nvim/viml/parser/parser.h"
-#include "nvim/mbyte.h"
-
-#include "nvim/memory.c"
-#include "nvim/mbyte.c"
-#include "nvim/charset.c"
-#include "nvim/garray.c"
-#include "nvim/gettext.c"
-#include "nvim/viml/parser/expressions.c"
-#include "nvim/keycodes.c"
-
-#define INPUT_SIZE 50
-
-uint8_t avoid_optimizing_out;
-
-void simple_get_line(void *cookie, ParserLine *ret_pline)
-{
- ParserLine **plines_p = (ParserLine **)cookie;
- *ret_pline = **plines_p;
- (*plines_p)++;
-}
-
-int main(const int argc, const char *const *const argv,
- const char *const *const environ)
-{
- char input[INPUT_SIZE];
- uint8_t shift;
- unsigned flags;
- const bool peek = false;
- avoid_optimizing_out = argc;
-
-#ifndef USE_KLEE
- sscanf(argv[2], "%d", &flags);
-#endif
-
-#ifdef USE_KLEE
- klee_make_symbolic(input, sizeof(input), "input");
- klee_make_symbolic(&shift, sizeof(shift), "shift");
- klee_make_symbolic(&flags, sizeof(flags), "flags");
- klee_assume(shift < INPUT_SIZE);
- klee_assume(
- flags <= (kExprFlagsMulti|kExprFlagsDisallowEOC|kExprFlagsParseLet));
-#endif
-
- ParserLine plines[] = {
- {
-#ifdef USE_KLEE
- .data = &input[shift],
- .size = sizeof(input) - shift,
-#else
- .data = argv[1],
- .size = strlen(argv[1]),
-#endif
- .allocated = false,
- },
- {
- .data = NULL,
- .size = 0,
- .allocated = false,
- },
- };
-#ifdef USE_KLEE
- assert(plines[0].size <= INPUT_SIZE);
- assert((plines[0].data[0] != 5) | (plines[0].data[0] != argc));
-#endif
- ParserLine *cur_pline = &plines[0];
-
- ParserHighlight colors;
- kvi_init(colors);
-
- ParserState pstate = {
- .reader = {
- .get_line = simple_get_line,
- .cookie = &cur_pline,
- .lines = KV_INITIAL_VALUE,
- .conv.vc_type = CONV_NONE,
- },
- .pos = { 0, 0 },
- .colors = &colors,
- .can_continuate = false,
- };
- kvi_init(pstate.reader.lines);
-
- const ExprAST ast = viml_pexpr_parse(&pstate, (int)flags);
- assert(ast.root != NULL || ast.err.msg);
- if (flags & kExprFlagsParseLet) {
- assert(ast.err.msg != NULL
- || ast.root->type == kExprNodeAssignment
- || (ast.root->type == kExprNodeListLiteral
- && ast.root->children != NULL)
- || ast.root->type == kExprNodeComplexIdentifier
- || ast.root->type == kExprNodeCurlyBracesIdentifier
- || ast.root->type == kExprNodePlainIdentifier
- || ast.root->type == kExprNodeRegister
- || ast.root->type == kExprNodeEnvironment
- || ast.root->type == kExprNodeOption
- || ast.root->type == kExprNodeSubscript
- || ast.root->type == kExprNodeConcatOrSubscript);
- }
- // Can’t possibly have more highlight tokens then there are bytes in string.
- assert(kv_size(colors) <= INPUT_SIZE - shift);
- kvi_destroy(colors);
- // Not destroying pstate.reader.lines because there is no way it could exceed
- // its limits in the current circumstances.
- viml_pexpr_free_ast(ast);
- assert(allocated_memory == 0);
-}
diff --git a/test/unit/eval/helpers.lua b/test/unit/eval/helpers.lua
index b600f01ab2..9dd6b76de2 100644
--- a/test/unit/eval/helpers.lua
+++ b/test/unit/eval/helpers.lua
@@ -349,7 +349,7 @@ local special_vals = nil
lua2typvalt = function(l, processed)
if not special_vals then
special_vals = {
- [null_string] = {'VAR_STRING', {v_string=ffi.cast('char_u*', nil)}},
+ [null_string] = {'VAR_STRING', {v_string=ffi.cast('char*', nil)}},
[null_list] = {'VAR_LIST', {v_list=ffi.cast('list_T*', nil)}},
[null_dict] = {'VAR_DICT', {v_dict=ffi.cast('dict_T*', nil)}},
[nil_value] = {'VAR_SPECIAL', {v_special=eval.kSpecialVarNull}},
diff --git a/test/unit/message_spec.lua b/test/unit/message_spec.lua
index 549eff6e03..0d5268d199 100644
--- a/test/unit/message_spec.lua
+++ b/test/unit/message_spec.lua
@@ -12,7 +12,7 @@ describe('trunc_string', function()
local buflen = 40
local function test_inplace(s, expected, room)
room = room and room or 20
- local buf = cimp.xmalloc(ffi.sizeof('char_u') * buflen)
+ local buf = cimp.xmalloc(ffi.sizeof('char') * buflen)
ffi.C.strcpy(buf, s)
cimp.trunc_string(buf, buf, room, buflen)
eq(expected, ffi.string(buf))
@@ -21,7 +21,7 @@ describe('trunc_string', function()
local function test_copy(s, expected, room)
room = room and room or 20
- local buf = cimp.xmalloc(ffi.sizeof('char_u') * buflen)
+ local buf = cimp.xmalloc(ffi.sizeof('char') * buflen)
local str = cimp.xstrdup(to_cstr(s))
cimp.trunc_string(str, buf, room, buflen)
eq(expected, ffi.string(buf))
diff --git a/test/unit/undo_spec.lua b/test/unit/undo_spec.lua
index f7f8d26d58..cdc5d3a99e 100644
--- a/test/unit/undo_spec.lua
+++ b/test/unit/undo_spec.lua
@@ -37,7 +37,7 @@ child_call_once(function()
-- requires refactor of UNDO_HASH_SIZE into constant/enum for ffi
--
-- compute a hash for this undofile
- buffer_hash = ffi.new('char_u[32]')
+ buffer_hash = ffi.new('char[32]')
undo.u_compute_hash(file_buffer, buffer_hash)
end)