aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-x.github/scripts/install_deps.sh2
-rw-r--r--cmake.config/CMakeLists.txt3
-rw-r--r--cmake.config/config.h.in1
-rw-r--r--cmake.config/iwyu/mapping.imp7
-rw-r--r--runtime/doc/api.txt1
-rw-r--r--runtime/doc/editing.txt7
-rw-r--r--runtime/doc/news.txt3
-rw-r--r--runtime/lua/vim/_meta/api.lua1
-rw-r--r--runtime/lua/vim/_meta/api_keysets.lua1
-rwxr-xr-xscripts/vim-patch.sh4
-rw-r--r--src/nvim/api/autocmd.c5
-rw-r--r--src/nvim/api/buffer.c2
-rw-r--r--src/nvim/api/command.c1
-rw-r--r--src/nvim/api/deprecated.c4
-rw-r--r--src/nvim/api/extmark.c3
-rw-r--r--src/nvim/api/keysets.h1
-rw-r--r--src/nvim/api/options.c8
-rw-r--r--src/nvim/api/private/converter.c2
-rw-r--r--src/nvim/api/private/helpers.c2
-rw-r--r--src/nvim/api/private/helpers.h2
-rw-r--r--src/nvim/api/private/validate.c10
-rw-r--r--src/nvim/api/private/validate.h5
-rw-r--r--src/nvim/api/ui.c1
-rw-r--r--src/nvim/api/vim.c5
-rw-r--r--src/nvim/api/vimscript.c4
-rw-r--r--src/nvim/api/win_config.c10
-rw-r--r--src/nvim/api/window.c7
-rw-r--r--src/nvim/arabic.c2
-rw-r--r--src/nvim/arglist.c2
-rw-r--r--src/nvim/autocmd.c2
-rw-r--r--src/nvim/buffer.c3
-rw-r--r--src/nvim/buffer_defs.h86
-rw-r--r--src/nvim/bufwrite.c13
-rw-r--r--src/nvim/change.c1
-rw-r--r--src/nvim/channel.c2
-rw-r--r--src/nvim/charset.c1
-rw-r--r--src/nvim/charset.h2
-rw-r--r--src/nvim/cmdexpand.c30
-rw-r--r--src/nvim/cmdhist.c2
-rw-r--r--src/nvim/context.c2
-rw-r--r--src/nvim/cursor.c3
-rw-r--r--src/nvim/cursor_shape.c2
-rw-r--r--src/nvim/debugger.c3
-rw-r--r--src/nvim/decoration.c1
-rw-r--r--src/nvim/decoration_provider.c4
-rw-r--r--src/nvim/decoration_provider.h1
-rw-r--r--src/nvim/diff.c2
-rw-r--r--src/nvim/digraph.c3
-rw-r--r--src/nvim/drawline.c3
-rw-r--r--src/nvim/drawline.h1
-rw-r--r--src/nvim/drawscreen.c8
-rw-r--r--src/nvim/drawscreen.h1
-rw-r--r--src/nvim/edit.c2
-rw-r--r--src/nvim/eval.c4
-rw-r--r--src/nvim/eval.h1
-rw-r--r--src/nvim/eval/decode.c1
-rw-r--r--src/nvim/eval/funcs.c8
-rw-r--r--src/nvim/eval/typval.c9
-rw-r--r--src/nvim/eval/typval_defs.h14
-rw-r--r--src/nvim/eval/userfunc.c6
-rw-r--r--src/nvim/eval/vars.c4
-rw-r--r--src/nvim/eval/window.c2
-rw-r--r--src/nvim/eval/window.h1
-rw-r--r--src/nvim/ex_cmds.c1
-rw-r--r--src/nvim/ex_cmds2.c5
-rw-r--r--src/nvim/ex_cmds_defs.h1
-rw-r--r--src/nvim/ex_docmd.c5
-rw-r--r--src/nvim/ex_docmd.h1
-rw-r--r--src/nvim/ex_eval.c4
-rw-r--r--src/nvim/ex_getln.c4
-rw-r--r--src/nvim/ex_getln.h1
-rw-r--r--src/nvim/ex_session.c4
-rw-r--r--src/nvim/extmark.c1
-rw-r--r--src/nvim/file_search.c5
-rw-r--r--src/nvim/fileio.c1
-rw-r--r--src/nvim/fold.c7
-rw-r--r--src/nvim/fold.h1
-rw-r--r--src/nvim/garray.c2
-rw-r--r--src/nvim/generators/gen_options.lua14
-rw-r--r--src/nvim/getchar.c6
-rw-r--r--src/nvim/grid.c8
-rw-r--r--src/nvim/grid.h1
-rw-r--r--src/nvim/hashtab.c2
-rw-r--r--src/nvim/help.c3
-rw-r--r--src/nvim/highlight.c4
-rw-r--r--src/nvim/highlight.h1
-rw-r--r--src/nvim/highlight_group.c5
-rw-r--r--src/nvim/indent.c2
-rw-r--r--src/nvim/indent_c.c1
-rw-r--r--src/nvim/input.c2
-rw-r--r--src/nvim/insexpand.c3
-rw-r--r--src/nvim/insexpand.h1
-rw-r--r--src/nvim/keycodes.c2
-rw-r--r--src/nvim/keycodes.h1
-rw-r--r--src/nvim/linematch.c1
-rw-r--r--src/nvim/lua/converter.c1
-rw-r--r--src/nvim/lua/executor.c6
-rw-r--r--src/nvim/lua/executor.h1
-rw-r--r--src/nvim/lua/secure.c8
-rw-r--r--src/nvim/lua/spell.c1
-rw-r--r--src/nvim/lua/stdlib.c2
-rw-r--r--src/nvim/lua/treesitter.c2
-rw-r--r--src/nvim/lua/xdiff.c1
-rw-r--r--src/nvim/main.c6
-rw-r--r--src/nvim/map.c2
-rw-r--r--src/nvim/map_glyph_cache.c10
-rw-r--r--src/nvim/mapping.c7
-rw-r--r--src/nvim/mark.c4
-rw-r--r--src/nvim/marktree.c4
-rw-r--r--src/nvim/marktree.h1
-rw-r--r--src/nvim/match.c3
-rw-r--r--src/nvim/mbyte.c3
-rw-r--r--src/nvim/memfile.c3
-rw-r--r--src/nvim/memline.c5
-rw-r--r--src/nvim/memory.c2
-rw-r--r--src/nvim/menu.c5
-rw-r--r--src/nvim/message.c3
-rw-r--r--src/nvim/mouse.c3
-rw-r--r--src/nvim/move.c7
-rw-r--r--src/nvim/msgpack_rpc/channel.c1
-rw-r--r--src/nvim/msgpack_rpc/helpers.c1
-rw-r--r--src/nvim/normal.c3
-rw-r--r--src/nvim/ops.c2
-rw-r--r--src/nvim/ops.h1
-rw-r--r--src/nvim/option.c1004
-rw-r--r--src/nvim/option.h90
-rw-r--r--src/nvim/option_defs.h1086
-rw-r--r--src/nvim/option_vars.h946
-rw-r--r--src/nvim/optionstr.c1655
-rw-r--r--src/nvim/os/env.c2
-rw-r--r--src/nvim/os/fs.c99
-rw-r--r--src/nvim/os/input.c4
-rw-r--r--src/nvim/os/input.h1
-rw-r--r--src/nvim/os/shell.c3
-rw-r--r--src/nvim/os/signal.c1
-rw-r--r--src/nvim/os/stdpaths.c2
-rw-r--r--src/nvim/os/time.c2
-rw-r--r--src/nvim/path.c5
-rw-r--r--src/nvim/plines.c3
-rw-r--r--src/nvim/popupmenu.c4
-rw-r--r--src/nvim/profile.c1
-rw-r--r--src/nvim/quickfix.c5
-rw-r--r--src/nvim/quickfix.h1
-rw-r--r--src/nvim/regexp.c4
-rw-r--r--src/nvim/runtime.c5
-rw-r--r--src/nvim/runtime.h1
-rw-r--r--src/nvim/search.c1
-rw-r--r--src/nvim/shada.c2
-rw-r--r--src/nvim/sign.c3
-rw-r--r--src/nvim/spell.c1
-rw-r--r--src/nvim/spellfile.c4
-rw-r--r--src/nvim/spellsuggest.c3
-rw-r--r--src/nvim/state.c4
-rw-r--r--src/nvim/statusline.c4
-rw-r--r--src/nvim/strings.c1
-rw-r--r--src/nvim/syntax.c3
-rw-r--r--src/nvim/tag.c3
-rw-r--r--src/nvim/tag.h1
-rw-r--r--src/nvim/terminal.c3
-rw-r--r--src/nvim/textformat.c2
-rw-r--r--src/nvim/textobject.c3
-rw-r--r--src/nvim/tui/input.c4
-rw-r--r--src/nvim/tui/input.h1
-rw-r--r--src/nvim/tui/tui.c1
-rw-r--r--src/nvim/ui.c1
-rw-r--r--src/nvim/ui_client.c2
-rw-r--r--src/nvim/ui_compositor.c3
-rw-r--r--src/nvim/undo.c2
-rw-r--r--src/nvim/usercmd.c2
-rw-r--r--src/nvim/version.c5
-rw-r--r--src/nvim/viml/parser/expressions.c2
-rw-r--r--src/nvim/window.c33
-rw-r--r--test/functional/ui/float_spec.lua126
-rw-r--r--test/old/testdir/test.sh4
-rw-r--r--test/old/testdir/test_cmdline.vim16
-rw-r--r--test/old/testdir/test_writefile.vim23
-rw-r--r--test/unit/buffer_spec.lua276
-rw-r--r--test/unit/keycodes_spec.lua22
-rw-r--r--test/unit/optionstr_spec.lua4
-rw-r--r--test/unit/os/fs_spec.lua4
-rw-r--r--test/unit/os/shell_spec.lua2
-rw-r--r--test/unit/path_spec.lua2
-rw-r--r--test/unit/statusline_spec.lua282
-rw-r--r--test/unit/undo_spec.lua5
184 files changed, 3375 insertions, 2941 deletions
diff --git a/.github/scripts/install_deps.sh b/.github/scripts/install_deps.sh
index 6a4e163feb..05e07bda1d 100755
--- a/.github/scripts/install_deps.sh
+++ b/.github/scripts/install_deps.sh
@@ -12,7 +12,7 @@ done
os=$(uname -s)
if [[ $os == Linux ]]; then
sudo apt-get update
- sudo apt-get install -y build-essential cmake curl gettext ninja-build unzip
+ sudo apt-get install -y attr build-essential cmake curl gettext libattr1-dev ninja-build unzip
if [[ -n $TEST ]]; then
sudo apt-get install -y locales-all cpanminus
fi
diff --git a/cmake.config/CMakeLists.txt b/cmake.config/CMakeLists.txt
index 26a7a262c1..1b175475ee 100644
--- a/cmake.config/CMakeLists.txt
+++ b/cmake.config/CMakeLists.txt
@@ -40,6 +40,9 @@ check_include_files(sys/utsname.h HAVE_SYS_UTSNAME_H)
check_include_files(termios.h HAVE_TERMIOS_H)
check_include_files(sys/uio.h HAVE_SYS_UIO_H)
check_include_files(sys/sdt.h HAVE_SYS_SDT_H)
+if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ check_include_files(sys/xattr.h HAVE_XATTR)
+endif()
# Functions
check_function_exists(fseeko HAVE_FSEEKO)
diff --git a/cmake.config/config.h.in b/cmake.config/config.h.in
index 90916d55bd..fb12a7c558 100644
--- a/cmake.config/config.h.in
+++ b/cmake.config/config.h.in
@@ -27,6 +27,7 @@
#cmakedefine HAVE_STRINGS_H
#cmakedefine HAVE_STRNCASECMP
#cmakedefine HAVE_STRPTIME
+#cmakedefine HAVE_XATTR
#cmakedefine HAVE_SYS_SDT_H
#cmakedefine HAVE_SYS_UTSNAME_H
#cmakedefine HAVE_SYS_WAIT_H
diff --git a/cmake.config/iwyu/mapping.imp b/cmake.config/iwyu/mapping.imp
index 7cdd63a723..737b9b0e57 100644
--- a/cmake.config/iwyu/mapping.imp
+++ b/cmake.config/iwyu/mapping.imp
@@ -9,6 +9,7 @@
{ include: [ '"api/private/converter.h.generated.h"', private, '"nvim/api/private/converter.h"', public ] },
{ include: [ '"api/private/dispatch.h.generated.h"', private, '"nvim/api/private/dispatch.h"', public ] },
{ include: [ '"api/private/helpers.h.generated.h"', private, '"nvim/api/private/helpers.h"', public ] },
+ { include: [ '"api/private/validate.h.generated.h"', private, '"nvim/api/private/validate.h"', public ] },
{ include: [ '"api/tabpage.h.generated.h"', private, '"nvim/api/tabpage.h"', public ] },
{ include: [ '"api/ui.h.generated.h"', private, '"nvim/api/ui.h"', public ] },
{ include: [ '"api/vim.h.generated.h"', private, '"nvim/api/vim.h"', public ] },
@@ -85,6 +86,7 @@
{ include: [ '"log.h.generated.h"', private, '"nvim/log.h"', public ] },
{ include: [ '"lua/converter.h.generated.h"', private, '"nvim/lua/converter.h"', public ] },
{ include: [ '"lua/executor.h.generated.h"', private, '"nvim/lua/executor.h"', public ] },
+ { include: [ '"lua/secure.h.generated.h"', private, '"nvim/lua/secure.h"', public ] },
{ include: [ '"lua/spell.h.generated.h"', private, '"nvim/lua/spell.h"', public ] },
{ include: [ '"lua/stdlib.h.generated.h"', private, '"nvim/lua/stdlib.h"', public ] },
{ include: [ '"lua/treesitter.h.generated.h"', private, '"nvim/lua/treesitter.h"', public ] },
@@ -188,12 +190,17 @@
# headers on the left, it will use the headers on the right if possible. This
# isn't explicitly mentioned in the IWYU docs, this is just my interpretation
# of its behavior.
+ { include: [ '"nvim/arglist_defs.h"', public, '"nvim/arglist.h"', public ] },
{ include: [ '"nvim/buffer_defs.h"', public, '"nvim/buffer.h"', public ] },
+ { include: [ '"nvim/eval/typval_defs.h"', public, '"nvim/eval/typval.h"', public ] },
{ include: [ '"nvim/ex_cmds_defs.h"', public, '"nvim/ex_cmds.h"', public ] },
{ include: [ '"nvim/ex_eval_defs.h"', public, '"nvim/ex_eval.h"', public ] },
{ include: [ '"nvim/extmark_defs.h"', public, '"nvim/extmark.h"', public ] },
+ { include: [ '"nvim/fold_defs.h"', public, '"nvim/fold.h"', public ] },
+ { include: [ '"nvim/getchar_defs.h"', public, '"nvim/getchar.h"', public ] },
{ include: [ '"nvim/grid_defs.h"', public, '"nvim/grid.h"', public ] },
{ include: [ '"nvim/highlight_defs.h"', public, '"nvim/highlight.h"', public ] },
+ { include: [ '"nvim/mapping_defs.h"', public, '"nvim/mapping.h"', public ] },
{ include: [ '"nvim/mark_defs.h"', public, '"nvim/mark.h"', public ] },
{ include: [ '"nvim/mbyte_defs.h"', public, '"nvim/mbyte.h"', public ] },
{ include: [ '"nvim/memfile_defs.h"', public, '"nvim/memfile.h"', public ] },
diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt
index e3daf1defa..d64020191d 100644
--- a/runtime/doc/api.txt
+++ b/runtime/doc/api.txt
@@ -3194,6 +3194,7 @@ nvim_open_win({buffer}, {enter}, {*config}) *nvim_open_win()*
fire from calling this function.
• fixed: If true when anchor is NW or SW, the float window
would be kept fixed even if the window would be truncated.
+ • hide: If true the floating window will be hidden.
Return: ~
Window handle, or 0 on error
diff --git a/runtime/doc/editing.txt b/runtime/doc/editing.txt
index abfe466b07..6e7963c066 100644
--- a/runtime/doc/editing.txt
+++ b/runtime/doc/editing.txt
@@ -1078,6 +1078,13 @@ will get the ACL info of the original file.
The ACL info is also used to check if a file is read-only (when opening the
file).
+ *xattr* *E1506* *E1507* *E1508* *E1509*
+xattr stands for Extended Attributes It is an advanced way to save metadata
+alongside the file in the filesystem. It depends on the actual filesystem
+being used and Vim supports it only on a Linux system.
+ Vim attempts to preserve the extended attribute info when writing a file.
+The backup file will get the extended attribute of the original file.
+
*read-only-share*
When MS-Windows shares a drive on the network it can be marked as read-only.
This means that even if the file read-only attribute is absent, and the ACL
diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt
index 3062c4c393..b632cf0932 100644
--- a/runtime/doc/news.txt
+++ b/runtime/doc/news.txt
@@ -65,6 +65,9 @@ The following changes may require adaptations in user config or plugins.
now requires an explicit range argument to be passed. If injections are
required, provide an explicit range via `parser:parse({ start_row, end_row })`.
+• Float window support hide and show by setting `hide` on `nvim_open_win` and
+ `nvim_win_set_config`.
+
==============================================================================
NEW FEATURES *news-features*
diff --git a/runtime/lua/vim/_meta/api.lua b/runtime/lua/vim/_meta/api.lua
index f0101eb6a4..bdcc68d7cd 100644
--- a/runtime/lua/vim/_meta/api.lua
+++ b/runtime/lua/vim/_meta/api.lua
@@ -1627,6 +1627,7 @@ function vim.api.nvim_open_term(buffer, opts) end
--- fire from calling this function.
--- • fixed: If true when anchor is NW or SW, the float window
--- would be kept fixed even if the window would be truncated.
+--- • hide: If true the floating window will be hidden.
--- @return integer
function vim.api.nvim_open_win(buffer, enter, config) end
diff --git a/runtime/lua/vim/_meta/api_keysets.lua b/runtime/lua/vim/_meta/api_keysets.lua
index 88de2f58d0..ebd164712c 100644
--- a/runtime/lua/vim/_meta/api_keysets.lua
+++ b/runtime/lua/vim/_meta/api_keysets.lua
@@ -113,6 +113,7 @@ error('Cannot require a meta file')
--- @field style? string
--- @field noautocmd? boolean
--- @field fixed? boolean
+--- @field hide? boolean
--- @class vim.api.keyset.get_autocmds
--- @field event? any
diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh
index 8b061add0d..478415376a 100755
--- a/scripts/vim-patch.sh
+++ b/scripts/vim-patch.sh
@@ -288,6 +288,10 @@ preprocess_patch() {
LC_ALL=C sed -Ee 's/( [ab]\/src\/nvim)\/keymap\.h/\1\/keycodes.h/g' \
"$file" > "$file".tmp && mv "$file".tmp "$file"
+ # Rename option.h to option_vars.h
+ LC_ALL=C sed -Ee 's/( [ab]\/src\/nvim)\/option\.h/\1\/option_vars.h/g' \
+ "$file" > "$file".tmp && mv "$file".tmp "$file"
+
# Rename terminal.txt to nvim_terminal_emulator.txt
LC_ALL=C sed -Ee 's/( [ab]\/runtime\/doc)\/terminal\.txt/\1\/nvim_terminal_emulator.txt/g' \
"$file" > "$file".tmp && mv "$file".tmp "$file"
diff --git a/src/nvim/api/autocmd.c b/src/nvim/api/autocmd.c
index 2e4d2a622d..768ed869cc 100644
--- a/src/nvim/api/autocmd.c
+++ b/src/nvim/api/autocmd.c
@@ -8,17 +8,16 @@
#include <stdlib.h>
#include <string.h>
+#include "klib/kvec.h"
#include "lauxlib.h"
#include "nvim/api/autocmd.h"
+#include "nvim/api/keysets.h"
#include "nvim/api/private/defs.h"
-#include "nvim/api/private/dispatch.h"
#include "nvim/api/private/helpers.h"
#include "nvim/api/private/validate.h"
-#include "nvim/ascii.h"
#include "nvim/autocmd.h"
#include "nvim/buffer.h"
#include "nvim/eval/typval.h"
-#include "nvim/eval/typval_defs.h"
#include "nvim/ex_cmds_defs.h"
#include "nvim/globals.h"
#include "nvim/lua/executor.h"
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c
index e8f9f809f2..64dddea5b8 100644
--- a/src/nvim/api/buffer.c
+++ b/src/nvim/api/buffer.c
@@ -4,7 +4,6 @@
// Some of this code was adapted from 'if_py_both.h' from the original
// vim source
-#include <assert.h>
#include <lauxlib.h>
#include <stdbool.h>
#include <stddef.h>
@@ -14,6 +13,7 @@
#include "klib/kvec.h"
#include "lua.h"
#include "nvim/api/buffer.h"
+#include "nvim/api/keysets.h"
#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/api/private/validate.h"
diff --git a/src/nvim/api/command.c b/src/nvim/api/command.c
index 808d4e0b8d..eb32f46143 100644
--- a/src/nvim/api/command.c
+++ b/src/nvim/api/command.c
@@ -9,6 +9,7 @@
#include "klib/kvec.h"
#include "lauxlib.h"
#include "nvim/api/command.h"
+#include "nvim/api/keysets.h"
#include "nvim/api/private/defs.h"
#include "nvim/api/private/dispatch.h"
#include "nvim/api/private/helpers.h"
diff --git a/src/nvim/api/deprecated.c b/src/nvim/api/deprecated.c
index a96485be83..e0827012f6 100644
--- a/src/nvim/api/deprecated.c
+++ b/src/nvim/api/deprecated.c
@@ -1,13 +1,15 @@
// 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
+#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
-#include <stdlib.h>
+#include <string.h>
#include "nvim/api/buffer.h"
#include "nvim/api/deprecated.h"
#include "nvim/api/extmark.h"
+#include "nvim/api/keysets.h"
#include "nvim/api/options.h"
#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
diff --git a/src/nvim/api/extmark.c b/src/nvim/api/extmark.c
index 91e197bea7..14454b626e 100644
--- a/src/nvim/api/extmark.c
+++ b/src/nvim/api/extmark.c
@@ -9,8 +9,8 @@
#include "klib/kvec.h"
#include "lauxlib.h"
#include "nvim/api/extmark.h"
+#include "nvim/api/keysets.h"
#include "nvim/api/private/defs.h"
-#include "nvim/api/private/dispatch.h"
#include "nvim/api/private/helpers.h"
#include "nvim/api/private/validate.h"
#include "nvim/buffer_defs.h"
@@ -20,6 +20,7 @@
#include "nvim/drawscreen.h"
#include "nvim/extmark.h"
#include "nvim/highlight_group.h"
+#include "nvim/marktree.h"
#include "nvim/mbyte.h"
#include "nvim/memline.h"
#include "nvim/memory.h"
diff --git a/src/nvim/api/keysets.h b/src/nvim/api/keysets.h
index 5962dec3ec..18f6d5368b 100644
--- a/src/nvim/api/keysets.h
+++ b/src/nvim/api/keysets.h
@@ -113,6 +113,7 @@ typedef struct {
String style;
Boolean noautocmd;
Boolean fixed;
+ Boolean hide;
} Dict(float_config);
typedef struct {
diff --git a/src/nvim/api/options.c b/src/nvim/api/options.c
index 619e23affb..5a75d10043 100644
--- a/src/nvim/api/options.c
+++ b/src/nvim/api/options.c
@@ -1,22 +1,24 @@
// 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
+#include <assert.h>
#include <inttypes.h>
-#include <limits.h>
#include <stdbool.h>
+#include <stdlib.h>
#include <string.h>
+#include "nvim/api/keysets.h"
#include "nvim/api/options.h"
#include "nvim/api/private/defs.h"
-#include "nvim/api/private/dispatch.h"
#include "nvim/api/private/helpers.h"
#include "nvim/api/private/validate.h"
#include "nvim/autocmd.h"
-#include "nvim/buffer_defs.h"
+#include "nvim/buffer.h"
#include "nvim/eval/window.h"
#include "nvim/globals.h"
#include "nvim/memory.h"
#include "nvim/option.h"
+#include "nvim/types.h"
#include "nvim/vim.h"
#include "nvim/window.h"
diff --git a/src/nvim/api/private/converter.c b/src/nvim/api/private/converter.c
index 68939e609c..dc6928f4b9 100644
--- a/src/nvim/api/private/converter.c
+++ b/src/nvim/api/private/converter.c
@@ -15,7 +15,6 @@
#include "nvim/eval/typval.h"
#include "nvim/eval/typval_defs.h"
#include "nvim/eval/userfunc.h"
-#include "nvim/garray.h"
#include "nvim/lua/executor.h"
#include "nvim/memory.h"
#include "nvim/types.h"
@@ -204,6 +203,7 @@ static inline void typval_encode_dict_end(EncodedData *const edata)
#define TYPVAL_ENCODE_FIRST_ARG_TYPE EncodedData *const
#define TYPVAL_ENCODE_FIRST_ARG_NAME edata
#include "nvim/eval/typval_encode.c.h"
+
#undef TYPVAL_ENCODE_SCOPE
#undef TYPVAL_ENCODE_NAME
#undef TYPVAL_ENCODE_FIRST_ARG_TYPE
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c
index 5463578b56..25e752bea8 100644
--- a/src/nvim/api/private/helpers.c
+++ b/src/nvim/api/private/helpers.c
@@ -20,7 +20,6 @@
#include "nvim/ascii.h"
#include "nvim/buffer_defs.h"
#include "nvim/eval/typval.h"
-#include "nvim/eval/typval_defs.h"
#include "nvim/eval/vars.h"
#include "nvim/ex_eval.h"
#include "nvim/garray.h"
@@ -34,6 +33,7 @@
#include "nvim/message.h"
#include "nvim/msgpack_rpc/helpers.h"
#include "nvim/pos.h"
+#include "nvim/types.h"
#include "nvim/ui.h"
#include "nvim/version.h"
diff --git a/src/nvim/api/private/helpers.h b/src/nvim/api/private/helpers.h
index 95e5cf67c8..e5ad30a10f 100644
--- a/src/nvim/api/private/helpers.h
+++ b/src/nvim/api/private/helpers.h
@@ -6,9 +6,11 @@
#include "klib/kvec.h"
#include "nvim/api/private/defs.h"
+#include "nvim/api/private/dispatch.h"
#include "nvim/decoration.h"
#include "nvim/ex_eval_defs.h"
#include "nvim/getchar.h"
+#include "nvim/gettext.h"
#include "nvim/globals.h"
#include "nvim/macros.h"
#include "nvim/map.h"
diff --git a/src/nvim/api/private/validate.c b/src/nvim/api/private/validate.c
index c4dd5bcac8..cede32f72c 100644
--- a/src/nvim/api/private/validate.c
+++ b/src/nvim/api/private/validate.c
@@ -1,13 +1,15 @@
// 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
+#include <inttypes.h>
+#include <stdio.h>
+#include <string.h>
+
#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/api/private/validate.h"
-
-#ifdef INCLUDE_GENERATED_DECLARATIONS
-# include "api/private/validate.c.generated.h"
-#endif
+#include "nvim/ascii.h"
+#include "nvim/globals.h"
/// Creates "Invalid …" message and sets it on `err`.
void api_err_invalid(Error *err, const char *name, const char *val_s, int64_t val_n, bool quote_val)
diff --git a/src/nvim/api/private/validate.h b/src/nvim/api/private/validate.h
index a3e77ea838..089b8d2f9c 100644
--- a/src/nvim/api/private/validate.h
+++ b/src/nvim/api/private/validate.h
@@ -1,8 +1,13 @@
#ifndef NVIM_API_PRIVATE_VALIDATE_H
#define NVIM_API_PRIVATE_VALIDATE_H
+#include <stdbool.h>
+#include <stddef.h>
+
#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
+#include "nvim/assert.h"
+#include "nvim/macros.h"
#define VALIDATE(cond, fmt_, fmt_arg1, code) \
do { \
diff --git a/src/nvim/api/ui.c b/src/nvim/api/ui.c
index 0ea2310042..e0b5e6ea57 100644
--- a/src/nvim/api/ui.c
+++ b/src/nvim/api/ui.c
@@ -21,6 +21,7 @@
#include "nvim/globals.h"
#include "nvim/grid.h"
#include "nvim/highlight.h"
+#include "nvim/macros.h"
#include "nvim/main.h"
#include "nvim/map.h"
#include "nvim/mbyte.h"
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index 6a38374ade..675aaf1006 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -14,6 +14,7 @@
#include "lauxlib.h"
#include "nvim/api/buffer.h"
#include "nvim/api/deprecated.h"
+#include "nvim/api/keysets.h"
#include "nvim/api/private/converter.h"
#include "nvim/api/private/defs.h"
#include "nvim/api/private/dispatch.h"
@@ -26,12 +27,13 @@
#include "nvim/channel.h"
#include "nvim/context.h"
#include "nvim/cursor.h"
+#include "nvim/decoration.h"
#include "nvim/drawscreen.h"
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
-#include "nvim/eval/typval_defs.h"
#include "nvim/ex_docmd.h"
#include "nvim/ex_eval.h"
+#include "nvim/fold.h"
#include "nvim/getchar.h"
#include "nvim/globals.h"
#include "nvim/grid.h"
@@ -53,6 +55,7 @@
#include "nvim/msgpack_rpc/unpacker.h"
#include "nvim/ops.h"
#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/optionstr.h"
#include "nvim/os/input.h"
#include "nvim/os/os_defs.h"
diff --git a/src/nvim/api/vimscript.c b/src/nvim/api/vimscript.c
index 4801562ad2..b09e4d7d87 100644
--- a/src/nvim/api/vimscript.c
+++ b/src/nvim/api/vimscript.c
@@ -8,21 +8,19 @@
#include <string.h>
#include "klib/kvec.h"
+#include "nvim/api/keysets.h"
#include "nvim/api/private/converter.h"
#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/api/vimscript.h"
#include "nvim/ascii.h"
-#include "nvim/buffer_defs.h"
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
-#include "nvim/eval/typval_defs.h"
#include "nvim/eval/userfunc.h"
#include "nvim/ex_docmd.h"
#include "nvim/garray.h"
#include "nvim/globals.h"
#include "nvim/memory.h"
-#include "nvim/pos.h"
#include "nvim/runtime.h"
#include "nvim/vim.h"
#include "nvim/viml/parser/expressions.h"
diff --git a/src/nvim/api/win_config.c b/src/nvim/api/win_config.c
index ea0b7ce512..ca7086ab7f 100644
--- a/src/nvim/api/win_config.c
+++ b/src/nvim/api/win_config.c
@@ -2,15 +2,17 @@
// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
#include <stdbool.h>
+#include <stdlib.h>
#include <string.h>
#include "klib/kvec.h"
#include "nvim/api/extmark.h"
+#include "nvim/api/keysets.h"
#include "nvim/api/private/defs.h"
-#include "nvim/api/private/dispatch.h"
#include "nvim/api/private/helpers.h"
#include "nvim/api/win_config.h"
#include "nvim/ascii.h"
+#include "nvim/autocmd.h"
#include "nvim/buffer_defs.h"
#include "nvim/decoration.h"
#include "nvim/drawscreen.h"
@@ -165,6 +167,7 @@
/// calling this function.
/// - fixed: If true when anchor is NW or SW, the float window
/// would be kept fixed even if the window would be truncated.
+/// - hide: If true the floating window will be hidden.
///
/// @param[out] err Error details, if any
///
@@ -323,6 +326,7 @@ Dictionary nvim_win_get_config(Window window, Error *err)
PUT(rv, "focusable", BOOLEAN_OBJ(config->focusable));
PUT(rv, "external", BOOLEAN_OBJ(config->external));
+ PUT(rv, "hide", BOOLEAN_OBJ(config->hide));
if (wp->w_floating) {
PUT(rv, "width", INTEGER_OBJ(config->width));
@@ -848,6 +852,10 @@ static bool parse_float_config(Dict(float_config) *config, FloatConfig *fconfig,
fconfig->fixed = config->fixed;
}
+ if (HAS_KEY_X(config, hide)) {
+ fconfig->hide = config->hide;
+ }
+
return true;
#undef HAS_KEY_X
}
diff --git a/src/nvim/api/window.c b/src/nvim/api/window.c
index 001797add5..53095ab019 100644
--- a/src/nvim/api/window.c
+++ b/src/nvim/api/window.c
@@ -6,12 +6,12 @@
#include <stdint.h>
#include <stdlib.h>
+#include "nvim/api/keysets.h"
#include "nvim/api/private/defs.h"
-#include "nvim/api/private/dispatch.h"
#include "nvim/api/private/helpers.h"
#include "nvim/api/private/validate.h"
#include "nvim/api/window.h"
-#include "nvim/ascii.h"
+#include "nvim/autocmd.h"
#include "nvim/buffer_defs.h"
#include "nvim/cursor.h"
#include "nvim/drawscreen.h"
@@ -20,7 +20,8 @@
#include "nvim/gettext.h"
#include "nvim/globals.h"
#include "nvim/lua/executor.h"
-#include "nvim/memline_defs.h"
+#include "nvim/memory.h"
+#include "nvim/message.h"
#include "nvim/move.h"
#include "nvim/plines.h"
#include "nvim/pos.h"
diff --git a/src/nvim/arabic.c b/src/nvim/arabic.c
index 41024cafda..bab77a4a84 100644
--- a/src/nvim/arabic.c
+++ b/src/nvim/arabic.c
@@ -28,7 +28,7 @@
#include "nvim/ascii.h"
#include "nvim/macros.h"
#include "nvim/mbyte.h"
-#include "nvim/option_defs.h"
+#include "nvim/option_vars.h"
#include "nvim/vim.h"
// Unicode values for Arabic characters.
diff --git a/src/nvim/arglist.c b/src/nvim/arglist.c
index 9c2b3ba6d8..a4221a1562 100644
--- a/src/nvim/arglist.c
+++ b/src/nvim/arglist.c
@@ -11,6 +11,7 @@
#include "auto/config.h"
#include "nvim/arglist.h"
#include "nvim/ascii.h"
+#include "nvim/autocmd.h"
#include "nvim/buffer.h"
#include "nvim/charset.h"
#include "nvim/eval/typval.h"
@@ -30,6 +31,7 @@
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/os/input.h"
#include "nvim/path.h"
#include "nvim/pos.h"
diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c
index 8c2df6f3b5..657760914f 100644
--- a/src/nvim/autocmd.c
+++ b/src/nvim/autocmd.c
@@ -34,7 +34,7 @@
#include "nvim/memline_defs.h"
#include "nvim/memory.h"
#include "nvim/message.h"
-#include "nvim/option_defs.h"
+#include "nvim/option.h"
#include "nvim/optionstr.h"
#include "nvim/os/input.h"
#include "nvim/os/os.h"
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index d6cab233d2..5025e86771 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -47,6 +47,7 @@
#include "nvim/digraph.h"
#include "nvim/drawscreen.h"
#include "nvim/eval.h"
+#include "nvim/eval/typval_defs.h"
#include "nvim/eval/vars.h"
#include "nvim/ex_cmds.h"
#include "nvim/ex_cmds2.h"
@@ -71,12 +72,14 @@
#include "nvim/mapping.h"
#include "nvim/mark.h"
#include "nvim/mbyte.h"
+#include "nvim/memfile_defs.h"
#include "nvim/memline_defs.h"
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/move.h"
#include "nvim/normal.h"
#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/optionstr.h"
#include "nvim/os/fs_defs.h"
#include "nvim/os/input.h"
diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h
index f0fdf0a230..a9ad0051ed 100644
--- a/src/nvim/buffer_defs.h
+++ b/src/nvim/buffer_defs.h
@@ -28,7 +28,7 @@ typedef struct {
#include "nvim/mapping_defs.h"
#include "nvim/mark_defs.h"
#include "nvim/marktree.h"
-#include "nvim/option_defs.h"
+#include "nvim/option_vars.h"
#include "nvim/pos.h"
#include "nvim/statusline_defs.h"
#include "nvim/undo_defs.h"
@@ -967,6 +967,7 @@ typedef struct {
int footer_width;
bool noautocmd;
bool fixed;
+ bool hide;
} FloatConfig;
#define FLOAT_CONFIG_INIT ((FloatConfig){ .height = 0, .width = 0, \
@@ -977,6 +978,7 @@ typedef struct {
.zindex = kZIndexFloatDefault, \
.style = kWinStyleUnused, \
.noautocmd = false, \
+ .hide = false, \
.fixed = false })
// Structure to store last cursor position and topline. Used by check_lnums()
@@ -988,6 +990,45 @@ typedef struct {
pos_T w_cursor_corr; // corrected cursor position
} pos_save_T;
+/// Characters from the 'listchars' option.
+typedef struct {
+ int eol;
+ int ext;
+ int prec;
+ int nbsp;
+ int space;
+ int tab1; ///< first tab character
+ int tab2; ///< second tab character
+ int tab3; ///< third tab character
+ int lead;
+ int trail;
+ int *multispace;
+ int *leadmultispace;
+ int conceal;
+} lcs_chars_T;
+
+/// Characters from the 'fillchars' option.
+typedef struct {
+ int stl;
+ int stlnc;
+ int wbr;
+ int horiz;
+ int horizup;
+ int horizdown;
+ int vert;
+ int vertleft;
+ int vertright;
+ int verthoriz;
+ int fold;
+ int foldopen; ///< when fold is open
+ int foldclosed; ///< when fold is closed
+ int foldsep; ///< continuous fold marker
+ int diff;
+ int msgsep;
+ int eob;
+ int lastline;
+} fcs_chars_T;
+
/// Structure which contains all information that belongs to a window.
///
/// All row numbers are relative to the start of the window, except w_winrow.
@@ -1043,44 +1084,11 @@ struct window_S {
linenr_T w_last_cursor_lnum_rnu; ///< cursor lnum when 'rnu' was last redrawn
- // 'listchars' characters. Defaults set in set_chars_option().
- struct {
- int eol;
- int ext;
- int prec;
- int nbsp;
- int space;
- int tab1; ///< first tab character
- int tab2; ///< second tab character
- int tab3; ///< third tab character
- int lead;
- int trail;
- int *multispace;
- int *leadmultispace;
- int conceal;
- } w_p_lcs_chars;
-
- // 'fillchars' characters. Defaults set in set_chars_option().
- struct {
- int stl;
- int stlnc;
- int wbr;
- int horiz;
- int horizup;
- int horizdown;
- int vert;
- int vertleft;
- int vertright;
- int verthoriz;
- int fold;
- int foldopen; ///< when fold is open
- int foldclosed; ///< when fold is closed
- int foldsep; ///< continuous fold marker
- int diff;
- int msgsep;
- int eob;
- int lastline;
- } w_p_fcs_chars;
+ /// 'listchars' characters. Defaults set in set_chars_option().
+ lcs_chars_T w_p_lcs_chars;
+
+ /// 'fillchars' characters. Defaults set in set_chars_option().
+ fcs_chars_T w_p_fcs_chars;
// "w_topline", "w_leftcol" and "w_skipcol" specify the offsets for
// displaying the buffer.
diff --git a/src/nvim/bufwrite.c b/src/nvim/bufwrite.c
index 770c269b0e..db813a3ae1 100644
--- a/src/nvim/bufwrite.c
+++ b/src/nvim/bufwrite.c
@@ -37,6 +37,7 @@
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/os/fs_defs.h"
#include "nvim/os/input.h"
#include "nvim/os/os.h"
@@ -912,6 +913,9 @@ static int buf_write_make_backup(char *fname, bool append, FileInfo *file_info_o
&& os_chown(*backupp, (uv_uid_t)-1, (uv_gid_t)file_info_old->stat.st_gid) != 0) {
os_setperm(*backupp, ((int)perm & 0707) | (((int)perm & 07) << 3));
}
+# ifdef HAVE_XATTR
+ os_copy_xattr(fname, *backupp);
+# endif
#endif
// copy the file
@@ -928,6 +932,9 @@ static int buf_write_make_backup(char *fname, bool append, FileInfo *file_info_o
(double)file_info_old->stat.st_mtim.tv_sec);
#endif
os_set_acl(*backupp, acl);
+#ifdef HAVE_XATTR
+ os_copy_xattr(fname, *backupp);
+#endif
*err = set_err(NULL);
break;
}
@@ -1633,6 +1640,12 @@ restore_backup:
end = 0;
}
+ if (!backup_copy) {
+#ifdef HAVE_XATTR
+ os_copy_xattr(backup, wfname);
+#endif
+ }
+
#ifdef UNIX
// When creating a new file, set its owner/group to that of the original
// file. Get the new device and inode number.
diff --git a/src/nvim/change.c b/src/nvim/change.c
index 084a8a1897..48dc02b65b 100644
--- a/src/nvim/change.c
+++ b/src/nvim/change.c
@@ -39,6 +39,7 @@
#include "nvim/message.h"
#include "nvim/move.h"
#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/os/time.h"
#include "nvim/plines.h"
#include "nvim/pos.h"
diff --git a/src/nvim/channel.c b/src/nvim/channel.c
index e22a4a0b51..5c8e922f90 100644
--- a/src/nvim/channel.c
+++ b/src/nvim/channel.c
@@ -7,6 +7,7 @@
#include <stdio.h>
#include <string.h>
+#include "klib/kvec.h"
#include "lauxlib.h"
#include "nvim/api/private/converter.h"
#include "nvim/api/private/defs.h"
@@ -17,7 +18,6 @@
#include "nvim/eval.h"
#include "nvim/eval/encode.h"
#include "nvim/eval/typval.h"
-#include "nvim/event/loop.h"
#include "nvim/event/rstream.h"
#include "nvim/event/socket.h"
#include "nvim/event/wstream.h"
diff --git a/src/nvim/charset.c b/src/nvim/charset.c
index c4ff712f3a..c2722af971 100644
--- a/src/nvim/charset.c
+++ b/src/nvim/charset.c
@@ -11,6 +11,7 @@
#include <limits.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/types.h>
#include "auto/config.h"
#include "klib/kvec.h"
diff --git a/src/nvim/charset.h b/src/nvim/charset.h
index cb5fbb22ed..d615012cd5 100644
--- a/src/nvim/charset.h
+++ b/src/nvim/charset.h
@@ -6,6 +6,8 @@
#include "nvim/buffer_defs.h"
#include "nvim/eval/typval_defs.h"
+#include "nvim/option_defs.h"
+#include "nvim/option_vars.h"
#include "nvim/pos.h"
#include "nvim/strings.h"
diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c
index ed693092a1..d733ffe6ab 100644
--- a/src/nvim/cmdexpand.c
+++ b/src/nvim/cmdexpand.c
@@ -4,7 +4,6 @@
// cmdexpand.c: functions for command-line completion
#include <assert.h>
-#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
@@ -49,6 +48,7 @@
#include "nvim/menu.h"
#include "nvim/message.h"
#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/os/lang.h"
#include "nvim/os/os.h"
#include "nvim/path.h"
@@ -617,7 +617,7 @@ static void redraw_wildmenu(expand_T *xp, int num_matches, char **matches, int m
/// Get the next or prev cmdline completion match. The index of the match is set
/// in "xp->xp_selected"
-static char *get_next_or_prev_match(int mode, expand_T *xp, char *orig_save)
+static char *get_next_or_prev_match(int mode, expand_T *xp)
{
if (xp->xp_numfiles <= 0) {
return NULL;
@@ -677,14 +677,14 @@ static char *get_next_or_prev_match(int mode, expand_T *xp, char *orig_save)
// When wrapping around, return the original string, set findex to -1.
if (findex < 0) {
- if (orig_save == NULL) {
+ if (xp->xp_orig == NULL) {
findex = xp->xp_numfiles - 1;
} else {
findex = -1;
}
}
if (findex >= xp->xp_numfiles) {
- if (orig_save == NULL) {
+ if (xp->xp_orig == NULL) {
findex = 0;
} else {
findex = -1;
@@ -698,7 +698,7 @@ static char *get_next_or_prev_match(int mode, expand_T *xp, char *orig_save)
}
xp->xp_selected = findex;
- return xstrdup(findex == -1 ? orig_save : xp->xp_files[findex]);
+ return xstrdup(findex == -1 ? xp->xp_orig : xp->xp_files[findex]);
}
/// Start the command-line expansion and get the matches.
@@ -805,8 +805,8 @@ static char *find_longest_match(expand_T *xp, int options)
/// Return NULL for failure.
///
/// "orig" is the originally expanded string, copied to allocated memory. It
-/// should either be kept in orig_save or freed. When "mode" is WILD_NEXT or
-/// WILD_PREV "orig" should be NULL.
+/// should either be kept in "xp->xp_orig" or freed. When "mode" is WILD_NEXT
+/// or WILD_PREV "orig" should be NULL.
///
/// Results are cached in xp->xp_files and xp->xp_numfiles, except when "mode"
/// is WILD_EXPAND_FREE or WILD_ALL.
@@ -841,21 +841,20 @@ static char *find_longest_match(expand_T *xp, int options)
char *ExpandOne(expand_T *xp, char *str, char *orig, int options, int mode)
{
char *ss = NULL;
- static char *orig_save = NULL; // kept value of orig
int orig_saved = false;
// first handle the case of using an old match
if (mode == WILD_NEXT || mode == WILD_PREV
|| mode == WILD_PAGEUP || mode == WILD_PAGEDOWN
|| mode == WILD_PUM_WANT) {
- return get_next_or_prev_match(mode, xp, orig_save);
+ return get_next_or_prev_match(mode, xp);
}
if (mode == WILD_CANCEL) {
- ss = xstrdup(orig_save ? orig_save : "");
+ ss = xstrdup(xp->xp_orig ? xp->xp_orig : "");
} else if (mode == WILD_APPLY) {
ss = xstrdup(xp->xp_selected == -1
- ? (orig_save ? orig_save : "")
+ ? (xp->xp_orig ? xp->xp_orig : "")
: xp->xp_files[xp->xp_selected]);
}
@@ -863,7 +862,7 @@ char *ExpandOne(expand_T *xp, char *str, char *orig, int options, int mode)
if (xp->xp_numfiles != -1 && mode != WILD_ALL && mode != WILD_LONGEST) {
FreeWild(xp->xp_numfiles, xp->xp_files);
xp->xp_numfiles = -1;
- XFREE_CLEAR(orig_save);
+ XFREE_CLEAR(xp->xp_orig);
// The entries from xp_files may be used in the PUM, remove it.
if (compl_match_array != NULL) {
@@ -877,8 +876,8 @@ char *ExpandOne(expand_T *xp, char *str, char *orig, int options, int mode)
}
if (xp->xp_numfiles == -1 && mode != WILD_APPLY && mode != WILD_CANCEL) {
- xfree(orig_save);
- orig_save = orig;
+ xfree(xp->xp_orig);
+ xp->xp_orig = orig;
orig_saved = true;
ss = ExpandOne_start(mode, xp, str, options);
@@ -927,7 +926,7 @@ char *ExpandOne(expand_T *xp, char *str, char *orig, int options, int mode)
ExpandCleanup(xp);
}
- // Free "orig" if it wasn't stored in "orig_save".
+ // Free "orig" if it wasn't stored in "xp->xp_orig".
if (!orig_saved) {
xfree(orig);
}
@@ -952,6 +951,7 @@ void ExpandCleanup(expand_T *xp)
FreeWild(xp->xp_numfiles, xp->xp_files);
xp->xp_numfiles = -1;
}
+ XFREE_CLEAR(xp->xp_orig);
}
/// Display one line of completion matches. Multiple matches are displayed in
diff --git a/src/nvim/cmdhist.c b/src/nvim/cmdhist.c
index 72379fd86d..50bdfd892f 100644
--- a/src/nvim/cmdhist.c
+++ b/src/nvim/cmdhist.c
@@ -22,7 +22,7 @@
#include "nvim/macros.h"
#include "nvim/memory.h"
#include "nvim/message.h"
-#include "nvim/option_defs.h"
+#include "nvim/option_vars.h"
#include "nvim/pos.h"
#include "nvim/regexp.h"
#include "nvim/strings.h"
diff --git a/src/nvim/context.c b/src/nvim/context.c
index ca28ed9970..fe5a49faa2 100644
--- a/src/nvim/context.c
+++ b/src/nvim/context.c
@@ -9,6 +9,7 @@
#include <stdio.h>
#include <string.h>
+#include "nvim/api/keysets.h"
#include "nvim/api/private/converter.h"
#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
@@ -16,7 +17,6 @@
#include "nvim/context.h"
#include "nvim/eval/encode.h"
#include "nvim/eval/typval.h"
-#include "nvim/eval/typval_defs.h"
#include "nvim/eval/userfunc.h"
#include "nvim/ex_docmd.h"
#include "nvim/gettext.h"
diff --git a/src/nvim/cursor.c b/src/nvim/cursor.c
index 418d49dfeb..ca309757f9 100644
--- a/src/nvim/cursor.c
+++ b/src/nvim/cursor.c
@@ -10,7 +10,6 @@
#include "nvim/assert.h"
#include "nvim/buffer_defs.h"
#include "nvim/change.h"
-#include "nvim/charset.h"
#include "nvim/cursor.h"
#include "nvim/drawscreen.h"
#include "nvim/fold.h"
@@ -22,10 +21,10 @@
#include "nvim/memory.h"
#include "nvim/move.h"
#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/plines.h"
#include "nvim/pos.h"
#include "nvim/state.h"
-#include "nvim/types.h"
#include "nvim/vim.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
diff --git a/src/nvim/cursor_shape.c b/src/nvim/cursor_shape.c
index 4e5886406a..fb2ca9ff8c 100644
--- a/src/nvim/cursor_shape.c
+++ b/src/nvim/cursor_shape.c
@@ -17,7 +17,7 @@
#include "nvim/log.h"
#include "nvim/macros.h"
#include "nvim/memory.h"
-#include "nvim/option_defs.h"
+#include "nvim/option_vars.h"
#include "nvim/strings.h"
#include "nvim/ui.h"
#include "nvim/vim.h"
diff --git a/src/nvim/debugger.c b/src/nvim/debugger.c
index ea6fd3bcb4..3d5f27e76c 100644
--- a/src/nvim/debugger.c
+++ b/src/nvim/debugger.c
@@ -11,13 +11,11 @@
#include <string.h>
#include "nvim/ascii.h"
-#include "nvim/buffer_defs.h"
#include "nvim/charset.h"
#include "nvim/debugger.h"
#include "nvim/drawscreen.h"
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
-#include "nvim/eval/typval_defs.h"
#include "nvim/ex_cmds_defs.h"
#include "nvim/ex_docmd.h"
#include "nvim/ex_getln.h"
@@ -35,7 +33,6 @@
#include "nvim/pos.h"
#include "nvim/regexp.h"
#include "nvim/runtime.h"
-#include "nvim/types.h"
#include "nvim/vim.h"
/// batch mode debugging: don't save and restore typeahead.
diff --git a/src/nvim/decoration.c b/src/nvim/decoration.c
index 9d391cde8c..59e0711906 100644
--- a/src/nvim/decoration.c
+++ b/src/nvim/decoration.c
@@ -2,6 +2,7 @@
// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
#include <assert.h>
+#include <limits.h>
#include "nvim/buffer.h"
#include "nvim/decoration.h"
diff --git a/src/nvim/decoration_provider.c b/src/nvim/decoration_provider.c
index 63c9772fb8..1b0171a0a5 100644
--- a/src/nvim/decoration_provider.c
+++ b/src/nvim/decoration_provider.c
@@ -2,7 +2,6 @@
// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
#include <assert.h>
-#include <stdio.h>
#include <string.h>
#include "klib/kvec.h"
@@ -11,12 +10,13 @@
#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/buffer_defs.h"
+#include "nvim/decoration.h"
#include "nvim/decoration_provider.h"
#include "nvim/globals.h"
#include "nvim/highlight.h"
#include "nvim/log.h"
#include "nvim/lua/executor.h"
-#include "nvim/memory.h"
+#include "nvim/message.h"
#include "nvim/pos.h"
static kvec_t(DecorProvider) decor_providers = KV_INITIAL_VALUE;
diff --git a/src/nvim/decoration_provider.h b/src/nvim/decoration_provider.h
index fa32eb97fe..ad2cdd564d 100644
--- a/src/nvim/decoration_provider.h
+++ b/src/nvim/decoration_provider.h
@@ -2,6 +2,7 @@
#define NVIM_DECORATION_PROVIDER_H
#include <stdbool.h>
+#include <stdint.h>
#include "klib/kvec.h"
#include "nvim/buffer_defs.h"
diff --git a/src/nvim/diff.c b/src/nvim/diff.c
index 4f2d510d8b..3ab1da76f4 100644
--- a/src/nvim/diff.c
+++ b/src/nvim/diff.c
@@ -33,7 +33,6 @@
#include "nvim/ex_cmds_defs.h"
#include "nvim/ex_docmd.h"
#include "nvim/extmark.h"
-#include "nvim/extmark_defs.h"
#include "nvim/fileio.h"
#include "nvim/fold.h"
#include "nvim/garray.h"
@@ -48,6 +47,7 @@
#include "nvim/move.h"
#include "nvim/normal.h"
#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/optionstr.h"
#include "nvim/os/fs_defs.h"
#include "nvim/os/os.h"
diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c
index 69a4676148..1bcb21508b 100644
--- a/src/nvim/digraph.c
+++ b/src/nvim/digraph.c
@@ -17,7 +17,6 @@
#include "nvim/drawscreen.h"
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
-#include "nvim/eval/typval_defs.h"
#include "nvim/ex_cmds_defs.h"
#include "nvim/ex_docmd.h"
#include "nvim/ex_getln.h"
@@ -32,7 +31,7 @@
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/normal.h"
-#include "nvim/option_defs.h"
+#include "nvim/option_vars.h"
#include "nvim/os/input.h"
#include "nvim/runtime.h"
#include "nvim/strings.h"
diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c
index 5baaa913b3..eef427a7b8 100644
--- a/src/nvim/drawline.c
+++ b/src/nvim/drawline.c
@@ -7,6 +7,7 @@
#include <assert.h>
#include <limits.h>
#include <stdbool.h>
+#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -25,7 +26,6 @@
#include "nvim/eval.h"
#include "nvim/extmark_defs.h"
#include "nvim/fold.h"
-#include "nvim/garray.h"
#include "nvim/globals.h"
#include "nvim/grid.h"
#include "nvim/highlight.h"
@@ -38,6 +38,7 @@
#include "nvim/memory.h"
#include "nvim/move.h"
#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/plines.h"
#include "nvim/pos.h"
#include "nvim/quickfix.h"
diff --git a/src/nvim/drawline.h b/src/nvim/drawline.h
index 9a917df0c5..f35b15c474 100644
--- a/src/nvim/drawline.h
+++ b/src/nvim/drawline.h
@@ -8,6 +8,7 @@
#include "nvim/decoration_provider.h"
#include "nvim/fold.h"
#include "nvim/macros.h"
+#include "nvim/pos.h"
#include "nvim/types.h"
// Maximum columns for terminal highlight attributes
diff --git a/src/nvim/drawscreen.c b/src/nvim/drawscreen.c
index 06e4cd48e7..cc22accf2b 100644
--- a/src/nvim/drawscreen.c
+++ b/src/nvim/drawscreen.c
@@ -56,7 +56,10 @@
#include <assert.h>
#include <inttypes.h>
+#include <limits.h>
#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include "klib/kvec.h"
@@ -77,6 +80,8 @@
#include "nvim/ex_getln.h"
#include "nvim/extmark_defs.h"
#include "nvim/fold.h"
+#include "nvim/getchar.h"
+#include "nvim/gettext.h"
#include "nvim/globals.h"
#include "nvim/grid.h"
#include "nvim/highlight.h"
@@ -89,6 +94,8 @@
#include "nvim/move.h"
#include "nvim/normal.h"
#include "nvim/option.h"
+#include "nvim/option_vars.h"
+#include "nvim/os/os_defs.h"
#include "nvim/plines.h"
#include "nvim/popupmenu.h"
#include "nvim/pos.h"
@@ -98,6 +105,7 @@
#include "nvim/spell.h"
#include "nvim/state.h"
#include "nvim/statusline.h"
+#include "nvim/strings.h"
#include "nvim/syntax.h"
#include "nvim/terminal.h"
#include "nvim/types.h"
diff --git a/src/nvim/drawscreen.h b/src/nvim/drawscreen.h
index 398825f1bc..7fab7ebacf 100644
--- a/src/nvim/drawscreen.h
+++ b/src/nvim/drawscreen.h
@@ -3,6 +3,7 @@
#include <stdbool.h>
+#include "nvim/buffer_defs.h"
#include "nvim/drawline.h"
#include "nvim/macros.h"
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index c1fb3f7470..7f29e615ab 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -48,12 +48,12 @@
#include "nvim/normal.h"
#include "nvim/ops.h"
#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/os/input.h"
#include "nvim/plines.h"
#include "nvim/popupmenu.h"
#include "nvim/pos.h"
#include "nvim/search.h"
-#include "nvim/spell.h"
#include "nvim/state.h"
#include "nvim/strings.h"
#include "nvim/syntax.h"
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index c30009606f..0bf26b2451 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -10,6 +10,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/stat.h>
#include "auto/config.h"
#include "nvim/api/private/converter.h"
@@ -30,7 +31,6 @@
#include "nvim/eval/typval.h"
#include "nvim/eval/userfunc.h"
#include "nvim/eval/vars.h"
-#include "nvim/event/loop.h"
#include "nvim/event/multiqueue.h"
#include "nvim/event/process.h"
#include "nvim/ex_cmds.h"
@@ -60,7 +60,7 @@
#include "nvim/msgpack_rpc/channel_defs.h"
#include "nvim/ops.h"
#include "nvim/option.h"
-#include "nvim/option_defs.h"
+#include "nvim/option_vars.h"
#include "nvim/optionstr.h"
#include "nvim/os/fileio.h"
#include "nvim/os/fs_defs.h"
diff --git a/src/nvim/eval.h b/src/nvim/eval.h
index 5fbfc4702c..be69cd5657 100644
--- a/src/nvim/eval.h
+++ b/src/nvim/eval.h
@@ -10,6 +10,7 @@
#include "nvim/event/time.h"
#include "nvim/ex_cmds_defs.h"
#include "nvim/hashtab.h"
+#include "nvim/macros.h"
#include "nvim/os/fileio.h"
#include "nvim/os/stdpaths_defs.h"
diff --git a/src/nvim/eval/decode.c b/src/nvim/eval/decode.c
index 70a629ea91..9c47e06f69 100644
--- a/src/nvim/eval/decode.c
+++ b/src/nvim/eval/decode.c
@@ -19,7 +19,6 @@
#include "nvim/eval/typval_defs.h"
#include "nvim/garray.h"
#include "nvim/gettext.h"
-#include "nvim/hashtab.h"
#include "nvim/macros.h"
#include "nvim/mbyte.h"
#include "nvim/memory.h"
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index 93075cf0e2..5bfce7c272 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -63,12 +63,12 @@
#include "nvim/gettext.h"
#include "nvim/globals.h"
#include "nvim/grid.h"
-#include "nvim/hashtab.h"
#include "nvim/highlight_defs.h"
#include "nvim/highlight_group.h"
#include "nvim/indent.h"
#include "nvim/indent_c.h"
#include "nvim/input.h"
+#include "nvim/insexpand.h"
#include "nvim/keycodes.h"
#include "nvim/lua/executor.h"
#include "nvim/macros.h"
@@ -76,12 +76,10 @@
#include "nvim/mark.h"
#include "nvim/math.h"
#include "nvim/mbyte.h"
-#include "nvim/memfile_defs.h"
#include "nvim/memline.h"
#include "nvim/memory.h"
#include "nvim/menu.h"
#include "nvim/message.h"
-#include "nvim/mouse.h"
#include "nvim/move.h"
#include "nvim/msgpack_rpc/channel.h"
#include "nvim/msgpack_rpc/channel_defs.h"
@@ -89,6 +87,7 @@
#include "nvim/normal.h"
#include "nvim/ops.h"
#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/optionstr.h"
#include "nvim/os/dl.h"
#include "nvim/os/fileio.h"
@@ -3172,6 +3171,9 @@ static void f_has(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
"windows",
"winaltkeys",
"writebackup",
+#ifdef HAVE_XATTR
+ "xattr",
+#endif
"nvim",
};
diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c
index ba2c23ffe8..1ff90dd201 100644
--- a/src/nvim/eval/typval.c
+++ b/src/nvim/eval/typval.c
@@ -33,6 +33,7 @@
#include "nvim/message.h"
#include "nvim/os/input.h"
#include "nvim/pos.h"
+#include "nvim/strings.h"
#include "nvim/types.h"
#include "nvim/vim.h"
@@ -49,6 +50,14 @@ typedef struct {
bool item_compare_func_err;
} sortinfo_T;
+/// Structure representing one list item, used for sort array.
+typedef struct {
+ listitem_T *item; ///< Sorted list item.
+ int idx; ///< Sorted list item index.
+} ListSortItem;
+
+typedef int (*ListSorter)(const void *, const void *);
+
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "eval/typval.c.generated.h"
#endif
diff --git a/src/nvim/eval/typval_defs.h b/src/nvim/eval/typval_defs.h
index 4099877539..d5e8cb0109 100644
--- a/src/nvim/eval/typval_defs.h
+++ b/src/nvim/eval/typval_defs.h
@@ -273,6 +273,12 @@ typedef struct {
linenr_T sc_lnum; ///< line number
} sctx_T;
+/// Stores an identifier of a script or channel that last set an option.
+typedef struct {
+ sctx_T script_ctx; /// script context where the option was last set
+ uint64_t channel_id; /// Only used when script_id is SID_API_CLIENT.
+} LastSet;
+
/// Maximum number of function arguments
enum { MAX_FUNC_ARGS = 20, };
/// Short variable name length
@@ -367,12 +373,4 @@ typedef struct list_stack_S {
struct list_stack_S *prev;
} list_stack_T;
-/// Structure representing one list item, used for sort array.
-typedef struct {
- listitem_T *item; ///< Sorted list item.
- int idx; ///< Sorted list item index.
-} ListSortItem;
-
-typedef int (*ListSorter)(const void *, const void *);
-
#endif // NVIM_EVAL_TYPVAL_DEFS_H
diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c
index 0fe2396f8a..8d85c55e15 100644
--- a/src/nvim/eval/userfunc.c
+++ b/src/nvim/eval/userfunc.c
@@ -13,7 +13,6 @@
#include "lauxlib.h"
#include "nvim/ascii.h"
#include "nvim/autocmd.h"
-#include "nvim/buffer_defs.h"
#include "nvim/charset.h"
#include "nvim/debugger.h"
#include "nvim/eval.h"
@@ -26,18 +25,19 @@
#include "nvim/ex_docmd.h"
#include "nvim/ex_eval.h"
#include "nvim/ex_getln.h"
+#include "nvim/garray.h"
#include "nvim/getchar.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
+#include "nvim/hashtab.h"
#include "nvim/insexpand.h"
#include "nvim/keycodes.h"
#include "nvim/lua/executor.h"
#include "nvim/macros.h"
#include "nvim/mbyte.h"
-#include "nvim/memline_defs.h"
#include "nvim/memory.h"
#include "nvim/message.h"
-#include "nvim/option_defs.h"
+#include "nvim/option_vars.h"
#include "nvim/os/input.h"
#include "nvim/path.h"
#include "nvim/profile.h"
diff --git a/src/nvim/eval/vars.c b/src/nvim/eval/vars.c
index 64ba37eaac..f9dcfb3d9d 100644
--- a/src/nvim/eval/vars.c
+++ b/src/nvim/eval/vars.c
@@ -8,6 +8,7 @@
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
+#include <stdlib.h>
#include <string.h>
#include "nvim/ascii.h"
@@ -19,7 +20,6 @@
#include "nvim/eval/encode.h"
#include "nvim/eval/funcs.h"
#include "nvim/eval/typval.h"
-#include "nvim/eval/typval_defs.h"
#include "nvim/eval/userfunc.h"
#include "nvim/eval/vars.h"
#include "nvim/eval/window.h"
@@ -27,6 +27,7 @@
#include "nvim/ex_cmds_defs.h"
#include "nvim/ex_docmd.h"
#include "nvim/ex_eval.h"
+#include "nvim/garray.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
#include "nvim/hashtab.h"
@@ -35,6 +36,7 @@
#include "nvim/message.h"
#include "nvim/ops.h"
#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/os/os.h"
#include "nvim/search.h"
#include "nvim/strings.h"
diff --git a/src/nvim/eval/window.c b/src/nvim/eval/window.c
index 26f5414565..f64809f2ef 100644
--- a/src/nvim/eval/window.c
+++ b/src/nvim/eval/window.c
@@ -22,11 +22,9 @@
#include "nvim/gettext.h"
#include "nvim/globals.h"
#include "nvim/macros.h"
-#include "nvim/memline_defs.h"
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/move.h"
-#include "nvim/option_defs.h"
#include "nvim/pos.h"
#include "nvim/types.h"
#include "nvim/vim.h"
diff --git a/src/nvim/eval/window.h b/src/nvim/eval/window.h
index 995f0a55a9..671c8fbf79 100644
--- a/src/nvim/eval/window.h
+++ b/src/nvim/eval/window.h
@@ -11,6 +11,7 @@
#include "nvim/globals.h"
#include "nvim/mark.h"
#include "nvim/option_defs.h"
+#include "nvim/option_vars.h"
#include "nvim/os/os.h"
#include "nvim/pos.h"
#include "nvim/vim.h"
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index e9d8947bd3..127397d9fa 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -66,6 +66,7 @@
#include "nvim/normal.h"
#include "nvim/ops.h"
#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/optionstr.h"
#include "nvim/os/fs_defs.h"
#include "nvim/os/input.h"
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c
index 84ca0faf88..199a5bdd43 100644
--- a/src/nvim/ex_cmds2.c
+++ b/src/nvim/ex_cmds2.c
@@ -20,7 +20,6 @@
#include "nvim/channel.h"
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
-#include "nvim/eval/typval_defs.h"
#include "nvim/eval/vars.h"
#include "nvim/ex_cmds.h"
#include "nvim/ex_cmds2.h"
@@ -33,13 +32,11 @@
#include "nvim/highlight_defs.h"
#include "nvim/macros.h"
#include "nvim/mark.h"
-#include "nvim/memline_defs.h"
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/move.h"
#include "nvim/normal.h"
-#include "nvim/option.h"
-#include "nvim/optionstr.h"
+#include "nvim/option_vars.h"
#include "nvim/os/os_defs.h"
#include "nvim/path.h"
#include "nvim/pos.h"
diff --git a/src/nvim/ex_cmds_defs.h b/src/nvim/ex_cmds_defs.h
index 4280ff70b9..78f880db56 100644
--- a/src/nvim/ex_cmds_defs.h
+++ b/src/nvim/ex_cmds_defs.h
@@ -245,6 +245,7 @@ struct expand {
int xp_numfiles; // number of files found by file name completion
int xp_col; // cursor position in line
int xp_selected; // selected index in completion
+ char *xp_orig; // originally expanded string
char **xp_files; // list of files
char *xp_line; // text being completed
#define EXPAND_BUF_LEN 256
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index c7ee71719d..02783e032b 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -18,6 +18,7 @@
#include "nvim/ascii.h"
#include "nvim/autocmd.h"
#include "nvim/buffer.h"
+#include "nvim/buffer_defs.h"
#include "nvim/change.h"
#include "nvim/charset.h"
#include "nvim/cmdexpand.h"
@@ -28,7 +29,6 @@
#include "nvim/edit.h"
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
-#include "nvim/eval/typval_defs.h"
#include "nvim/eval/userfunc.h"
#include "nvim/event/loop.h"
#include "nvim/ex_cmds.h"
@@ -48,11 +48,11 @@
#include "nvim/highlight_group.h"
#include "nvim/input.h"
#include "nvim/keycodes.h"
+#include "nvim/lua/executor.h"
#include "nvim/macros.h"
#include "nvim/main.h"
#include "nvim/mark.h"
#include "nvim/mbyte.h"
-#include "nvim/memfile_defs.h"
#include "nvim/memline.h"
#include "nvim/memory.h"
#include "nvim/message.h"
@@ -61,6 +61,7 @@
#include "nvim/normal.h"
#include "nvim/ops.h"
#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/optionstr.h"
#include "nvim/os/input.h"
#include "nvim/os/os.h"
diff --git a/src/nvim/ex_docmd.h b/src/nvim/ex_docmd.h
index 711fc4ba52..0fd14c81d3 100644
--- a/src/nvim/ex_docmd.h
+++ b/src/nvim/ex_docmd.h
@@ -5,6 +5,7 @@
#include "nvim/buffer_defs.h"
#include "nvim/ex_cmds_defs.h"
+#include "nvim/getchar_defs.h"
#include "nvim/globals.h"
// flags for do_cmdline()
diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c
index 49bdf1088a..b49563f44d 100644
--- a/src/nvim/ex_eval.c
+++ b/src/nvim/ex_eval.c
@@ -16,7 +16,6 @@
#include "nvim/debugger.h"
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
-#include "nvim/eval/typval_defs.h"
#include "nvim/eval/userfunc.h"
#include "nvim/ex_cmds_defs.h"
#include "nvim/ex_docmd.h"
@@ -26,12 +25,11 @@
#include "nvim/globals.h"
#include "nvim/memory.h"
#include "nvim/message.h"
-#include "nvim/option_defs.h"
+#include "nvim/option_vars.h"
#include "nvim/pos.h"
#include "nvim/regexp.h"
#include "nvim/runtime.h"
#include "nvim/strings.h"
-#include "nvim/types.h"
#include "nvim/vim.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index b3010bea11..6fa607d569 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -7,6 +7,7 @@
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
@@ -45,6 +46,7 @@
#include "nvim/highlight_group.h"
#include "nvim/keycodes.h"
#include "nvim/macros.h"
+#include "nvim/map.h"
#include "nvim/mapping.h"
#include "nvim/mark.h"
#include "nvim/mbyte.h"
@@ -56,6 +58,8 @@
#include "nvim/normal.h"
#include "nvim/ops.h"
#include "nvim/option.h"
+#include "nvim/option_defs.h"
+#include "nvim/option_vars.h"
#include "nvim/optionstr.h"
#include "nvim/os/input.h"
#include "nvim/os/os.h"
diff --git a/src/nvim/ex_getln.h b/src/nvim/ex_getln.h
index b21fb0506d..aaafedcb4b 100644
--- a/src/nvim/ex_getln.h
+++ b/src/nvim/ex_getln.h
@@ -6,6 +6,7 @@
#include "klib/kvec.h"
#include "nvim/eval/typval_defs.h"
#include "nvim/ex_cmds_defs.h"
+#include "nvim/option_defs.h"
#include "nvim/types.h"
struct cmdline_info;
diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c
index e2a4f73840..bbe57b486d 100644
--- a/src/nvim/ex_session.c
+++ b/src/nvim/ex_session.c
@@ -7,9 +7,7 @@
// :mkview
// :mksession
-#include <assert.h>
#include <inttypes.h>
-#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
@@ -30,10 +28,10 @@
#include "nvim/globals.h"
#include "nvim/macros.h"
#include "nvim/mapping.h"
-#include "nvim/mark_defs.h"
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/os/os.h"
#include "nvim/path.h"
#include "nvim/pos.h"
diff --git a/src/nvim/extmark.c b/src/nvim/extmark.c
index 5140fe199e..fd9c2e8fe0 100644
--- a/src/nvim/extmark.c
+++ b/src/nvim/extmark.c
@@ -31,6 +31,7 @@
#include <assert.h>
#include <sys/types.h>
+#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/buffer.h"
#include "nvim/buffer_defs.h"
diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c
index 338edbe719..7a46341797 100644
--- a/src/nvim/file_search.c
+++ b/src/nvim/file_search.c
@@ -47,16 +47,15 @@
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
+#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "nvim/ascii.h"
#include "nvim/autocmd.h"
-#include "nvim/buffer_defs.h"
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
-#include "nvim/eval/typval_defs.h"
#include "nvim/file_search.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
@@ -65,12 +64,12 @@
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/os/fs_defs.h"
#include "nvim/os/input.h"
#include "nvim/os/os.h"
#include "nvim/path.h"
#include "nvim/strings.h"
-#include "nvim/types.h"
#include "nvim/vim.h"
#include "nvim/window.h"
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index 5cda5e48ec..4e8b7be4aa 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -47,6 +47,7 @@
#include "nvim/message.h"
#include "nvim/move.h"
#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/optionstr.h"
#include "nvim/os/fs_defs.h"
#include "nvim/os/input.h"
diff --git a/src/nvim/fold.c b/src/nvim/fold.c
index d874e904d0..6a9dbe9edc 100644
--- a/src/nvim/fold.c
+++ b/src/nvim/fold.c
@@ -12,7 +12,10 @@
#include <stdlib.h>
#include <string.h>
+#include "klib/kvec.h"
#include "nvim/api/extmark.h"
+#include "nvim/api/private/defs.h"
+#include "nvim/api/private/helpers.h"
#include "nvim/ascii.h"
#include "nvim/buffer_defs.h"
#include "nvim/buffer_updates.h"
@@ -24,7 +27,6 @@
#include "nvim/drawscreen.h"
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
-#include "nvim/eval/typval_defs.h"
#include "nvim/ex_session.h"
#include "nvim/extmark.h"
#include "nvim/fold.h"
@@ -39,9 +41,10 @@
#include "nvim/message.h"
#include "nvim/move.h"
#include "nvim/ops.h"
-#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/os/input.h"
#include "nvim/plines.h"
+#include "nvim/pos.h"
#include "nvim/search.h"
#include "nvim/strings.h"
#include "nvim/syntax.h"
diff --git a/src/nvim/fold.h b/src/nvim/fold.h
index cf44cf14c3..ee7501f845 100644
--- a/src/nvim/fold.h
+++ b/src/nvim/fold.h
@@ -4,6 +4,7 @@
#include <stdio.h>
#include "nvim/buffer_defs.h"
+#include "nvim/fold_defs.h"
#include "nvim/garray.h"
#include "nvim/macros.h"
#include "nvim/pos.h"
diff --git a/src/nvim/garray.c b/src/nvim/garray.c
index aa9a44d410..4df6ec2431 100644
--- a/src/nvim/garray.c
+++ b/src/nvim/garray.c
@@ -5,6 +5,7 @@
///
/// Functions for handling growing arrays.
+#include <stdint.h>
#include <string.h>
#include "nvim/garray.h"
@@ -12,7 +13,6 @@
#include "nvim/memory.h"
#include "nvim/path.h"
#include "nvim/strings.h"
-#include "nvim/types.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "garray.c.generated.h" // IWYU pragma: export
diff --git a/src/nvim/generators/gen_options.lua b/src/nvim/generators/gen_options.lua
index cb6f9b6af9..0932a1357f 100644
--- a/src/nvim/generators/gen_options.lua
+++ b/src/nvim/generators/gen_options.lua
@@ -188,7 +188,19 @@ local function dump_option(i, o)
w(' },')
end
-w('static vimoption_T options[] = {')
+w([[
+#include "nvim/ex_getln.h"
+#include "nvim/insexpand.h"
+#include "nvim/mapping.h"
+#include "nvim/ops.h"
+#include "nvim/option.h"
+#include "nvim/optionstr.h"
+#include "nvim/quickfix.h"
+#include "nvim/runtime.h"
+#include "nvim/tag.h"
+#include "nvim/window.h"
+
+static vimoption_T options[] = {]])
for i, o in ipairs(options.options) do
dump_option(i, o)
end
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index 76aa012d2d..b696f8ab37 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -5,9 +5,10 @@
// file, manipulations with redo buffer and stuff buffer.
#include <assert.h>
-#include <inttypes.h>
+#include <limits.h>
#include <stdbool.h>
#include <stddef.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -24,7 +25,6 @@
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
#include "nvim/eval/typval_defs.h"
-#include "nvim/event/loop.h"
#include "nvim/event/multiqueue.h"
#include "nvim/ex_cmds.h"
#include "nvim/ex_docmd.h"
@@ -48,7 +48,7 @@
#include "nvim/move.h"
#include "nvim/normal.h"
#include "nvim/ops.h"
-#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/os/fileio.h"
#include "nvim/os/input.h"
#include "nvim/os/os.h"
diff --git a/src/nvim/grid.c b/src/nvim/grid.c
index 1d9cd80ec3..712688368b 100644
--- a/src/nvim/grid.c
+++ b/src/nvim/grid.c
@@ -13,17 +13,23 @@
#include <assert.h>
#include <limits.h>
+#include <stdint.h>
#include <stdlib.h>
+#include <string.h>
+#include "nvim/api/private/defs.h"
#include "nvim/arabic.h"
+#include "nvim/ascii.h"
#include "nvim/buffer_defs.h"
#include "nvim/drawscreen.h"
#include "nvim/globals.h"
#include "nvim/grid.h"
#include "nvim/highlight.h"
#include "nvim/log.h"
+#include "nvim/map.h"
+#include "nvim/memory.h"
#include "nvim/message.h"
-#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/types.h"
#include "nvim/ui.h"
#include "nvim/vim.h"
diff --git a/src/nvim/grid.h b/src/nvim/grid.h
index 9cdc6c6677..6591d8acc0 100644
--- a/src/nvim/grid.h
+++ b/src/nvim/grid.h
@@ -10,6 +10,7 @@
#include "nvim/macros.h"
#include "nvim/mbyte.h"
#include "nvim/memory.h"
+#include "nvim/pos.h"
/// By default, all windows are drawn on a single rectangular grid, represented by
/// this ScreenGrid instance. In multigrid mode each window will have its own
diff --git a/src/nvim/hashtab.c b/src/nvim/hashtab.c
index 5b987e7c34..8f82220942 100644
--- a/src/nvim/hashtab.c
+++ b/src/nvim/hashtab.c
@@ -27,10 +27,10 @@
#include <string.h>
#include "nvim/ascii.h"
+#include "nvim/gettext.h"
#include "nvim/hashtab.h"
#include "nvim/memory.h"
#include "nvim/message.h"
-#include "nvim/types.h"
#include "nvim/vim.h"
// Magic value for algorithm that walks through the array.
diff --git a/src/nvim/help.c b/src/nvim/help.c
index a32a03de52..d8b6afec27 100644
--- a/src/nvim/help.c
+++ b/src/nvim/help.c
@@ -4,6 +4,7 @@
// help.c: functions for Vim help
#include <stdbool.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -16,6 +17,7 @@
#include "nvim/ex_cmds.h"
#include "nvim/ex_cmds_defs.h"
#include "nvim/ex_docmd.h"
+#include "nvim/extmark_defs.h"
#include "nvim/fileio.h"
#include "nvim/garray.h"
#include "nvim/gettext.h"
@@ -28,6 +30,7 @@
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/optionstr.h"
#include "nvim/os/input.h"
#include "nvim/os/os.h"
diff --git a/src/nvim/highlight.c b/src/nvim/highlight.c
index 3728db31d8..14239f44cc 100644
--- a/src/nvim/highlight.c
+++ b/src/nvim/highlight.c
@@ -5,11 +5,10 @@
#include <assert.h>
#include <inttypes.h>
-#include <limits.h>
#include <string.h>
-#include "klib/kvec.h"
#include "lauxlib.h"
+#include "nvim/api/keysets.h"
#include "nvim/api/private/defs.h"
#include "nvim/api/private/dispatch.h"
#include "nvim/api/private/helpers.h"
@@ -22,7 +21,6 @@
#include "nvim/highlight.h"
#include "nvim/highlight_defs.h"
#include "nvim/highlight_group.h"
-#include "nvim/log.h"
#include "nvim/lua/executor.h"
#include "nvim/macros.h"
#include "nvim/map.h"
diff --git a/src/nvim/highlight.h b/src/nvim/highlight.h
index 5a4a90035c..fc311b4269 100644
--- a/src/nvim/highlight.h
+++ b/src/nvim/highlight.h
@@ -8,6 +8,7 @@
#include "nvim/buffer_defs.h"
#include "nvim/highlight_defs.h"
#include "nvim/option_defs.h"
+#include "nvim/option_vars.h"
#include "nvim/ui.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
diff --git a/src/nvim/highlight_group.c b/src/nvim/highlight_group.c
index c097c6a524..080dc79e0e 100644
--- a/src/nvim/highlight_group.c
+++ b/src/nvim/highlight_group.c
@@ -10,12 +10,13 @@
#include <stdlib.h>
#include <string.h>
+#include "klib/kvec.h"
+#include "nvim/api/keysets.h"
#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/api/private/validate.h"
#include "nvim/ascii.h"
#include "nvim/autocmd.h"
-#include "nvim/buffer_defs.h"
#include "nvim/charset.h"
#include "nvim/cursor_shape.h"
#include "nvim/decoration_provider.h"
@@ -28,7 +29,6 @@
#include "nvim/garray.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
-#include "nvim/grid_defs.h"
#include "nvim/highlight.h"
#include "nvim/highlight_group.h"
#include "nvim/lua/executor.h"
@@ -37,6 +37,7 @@
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/os/time.h"
#include "nvim/runtime.h"
#include "nvim/strings.h"
diff --git a/src/nvim/indent.c b/src/nvim/indent.c
index 5bd265834c..b7bc23cda5 100644
--- a/src/nvim/indent.c
+++ b/src/nvim/indent.c
@@ -4,6 +4,7 @@
#include <assert.h>
#include <limits.h>
#include <stdbool.h>
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>
@@ -31,6 +32,7 @@
#include "nvim/message.h"
#include "nvim/move.h"
#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/optionstr.h"
#include "nvim/os/input.h"
#include "nvim/plines.h"
diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c
index 1671bf009a..7f67a24ef1 100644
--- a/src/nvim/indent_c.c
+++ b/src/nvim/indent_c.c
@@ -20,6 +20,7 @@
#include "nvim/memline.h"
#include "nvim/memory.h"
#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/plines.h"
#include "nvim/pos.h"
#include "nvim/search.h"
diff --git a/src/nvim/input.c b/src/nvim/input.c
index e867da7e1e..955cb0a21c 100644
--- a/src/nvim/input.c
+++ b/src/nvim/input.c
@@ -5,6 +5,7 @@
// like yes/no or number prompts.
#include <stdbool.h>
+#include <stdint.h>
#include <string.h>
#include "nvim/ascii.h"
@@ -21,7 +22,6 @@
#include "nvim/message.h"
#include "nvim/mouse.h"
#include "nvim/os/input.h"
-#include "nvim/types.h"
#include "nvim/ui.h"
#include "nvim/vim.h"
diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c
index e1e1750e8e..4a6c819015 100644
--- a/src/nvim/insexpand.c
+++ b/src/nvim/insexpand.c
@@ -23,7 +23,6 @@
#include "nvim/edit.h"
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
-#include "nvim/eval/typval_defs.h"
#include "nvim/eval/userfunc.h"
#include "nvim/ex_cmds_defs.h"
#include "nvim/ex_docmd.h"
@@ -47,6 +46,8 @@
#include "nvim/message.h"
#include "nvim/move.h"
#include "nvim/option.h"
+#include "nvim/option_defs.h"
+#include "nvim/option_vars.h"
#include "nvim/os/fs.h"
#include "nvim/os/input.h"
#include "nvim/os/time.h"
diff --git a/src/nvim/insexpand.h b/src/nvim/insexpand.h
index 83ba14e0d2..e09004f032 100644
--- a/src/nvim/insexpand.h
+++ b/src/nvim/insexpand.h
@@ -4,6 +4,7 @@
#include <stdbool.h>
#include "nvim/macros.h"
+#include "nvim/option_defs.h"
#include "nvim/vim.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
diff --git a/src/nvim/keycodes.c b/src/nvim/keycodes.c
index 55cd22f181..d23fcaf368 100644
--- a/src/nvim/keycodes.c
+++ b/src/nvim/keycodes.c
@@ -15,14 +15,12 @@
#include "nvim/gettext.h"
#include "nvim/globals.h"
#include "nvim/keycodes.h"
-#include "nvim/log.h"
#include "nvim/macros.h"
#include "nvim/mbyte.h"
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/mouse.h"
#include "nvim/strings.h"
-#include "nvim/types.h"
#include "nvim/vim.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
diff --git a/src/nvim/keycodes.h b/src/nvim/keycodes.h
index 7c143fc99e..9806808438 100644
--- a/src/nvim/keycodes.h
+++ b/src/nvim/keycodes.h
@@ -5,6 +5,7 @@
#include "nvim/ascii.h"
#include "nvim/option_defs.h"
+#include "nvim/option_vars.h"
#include "nvim/strings.h"
// Keycode definitions for special keys.
diff --git a/src/nvim/linematch.c b/src/nvim/linematch.c
index e22cc2d9a1..897a263bf2 100644
--- a/src/nvim/linematch.c
+++ b/src/nvim/linematch.c
@@ -5,6 +5,7 @@
#include <math.h>
#include <stdbool.h>
#include <stddef.h>
+#include <stdint.h>
#include <string.h>
#include "nvim/linematch.h"
diff --git a/src/nvim/lua/converter.c b/src/nvim/lua/converter.c
index 385ac11546..c041fdb26c 100644
--- a/src/nvim/lua/converter.c
+++ b/src/nvim/lua/converter.c
@@ -22,7 +22,6 @@
#include "nvim/eval/typval_defs.h"
#include "nvim/eval/typval_encode.h"
#include "nvim/eval/userfunc.h"
-#include "nvim/garray.h"
#include "nvim/gettext.h"
#include "nvim/lua/converter.h"
#include "nvim/lua/executor.h"
diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c
index 32706b74f1..18da7af416 100644
--- a/src/nvim/lua/executor.c
+++ b/src/nvim/lua/executor.c
@@ -7,6 +7,8 @@
#include <lua.h>
#include <lualib.h>
#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <tree_sitter/api.h>
#include <uv.h>
@@ -17,7 +19,6 @@
#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/ascii.h"
-#include "nvim/buffer_defs.h"
#include "nvim/change.h"
#include "nvim/cursor.h"
#include "nvim/drawscreen.h"
@@ -48,7 +49,7 @@
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/msgpack_rpc/channel.h"
-#include "nvim/option_defs.h"
+#include "nvim/option_vars.h"
#include "nvim/os/fileio.h"
#include "nvim/os/os.h"
#include "nvim/path.h"
@@ -59,7 +60,6 @@
#include "nvim/ui.h"
#include "nvim/undo.h"
#include "nvim/usercmd.h"
-#include "nvim/version.h"
#include "nvim/vim.h"
#include "nvim/window.h"
diff --git a/src/nvim/lua/executor.h b/src/nvim/lua/executor.h
index f340d9d0d8..b132a0d147 100644
--- a/src/nvim/lua/executor.h
+++ b/src/nvim/lua/executor.h
@@ -13,6 +13,7 @@
#include "nvim/func_attr.h"
#include "nvim/lua/converter.h"
#include "nvim/macros.h"
+#include "nvim/map.h"
#include "nvim/types.h"
#include "nvim/usercmd.h"
diff --git a/src/nvim/lua/secure.c b/src/nvim/lua/secure.c
index 2552e21884..194c80fdc9 100644
--- a/src/nvim/lua/secure.c
+++ b/src/nvim/lua/secure.c
@@ -1,13 +1,17 @@
// 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
-#include <lauxlib.h>
#include <lua.h>
-#include <lualib.h>
+#include <stdbool.h>
+#include <string.h>
#include "nvim/charset.h"
+#include "nvim/ex_cmds_defs.h"
+#include "nvim/gettext.h"
+#include "nvim/globals.h"
#include "nvim/lua/executor.h"
#include "nvim/lua/secure.h"
+#include "nvim/memory.h"
#include "nvim/message.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
diff --git a/src/nvim/lua/spell.c b/src/nvim/lua/spell.c
index 37f1c5216d..04304719d0 100644
--- a/src/nvim/lua/spell.c
+++ b/src/nvim/lua/spell.c
@@ -16,7 +16,6 @@
#include "nvim/lua/spell.h"
#include "nvim/message.h"
#include "nvim/spell.h"
-#include "nvim/types.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "lua/spell.c.generated.h" // IWYU pragma: export
diff --git a/src/nvim/lua/stdlib.c b/src/nvim/lua/stdlib.c
index f175a7abb0..7690853d57 100644
--- a/src/nvim/lua/stdlib.c
+++ b/src/nvim/lua/stdlib.c
@@ -15,7 +15,6 @@
# include "bit.h"
#endif
-#include "auto/config.h"
#include "cjson/lua_cjson.h"
#include "mpack/lmpack.h"
#include "nvim/api/private/defs.h"
@@ -23,7 +22,6 @@
#include "nvim/ascii.h"
#include "nvim/buffer_defs.h"
#include "nvim/eval/typval.h"
-#include "nvim/eval/typval_defs.h"
#include "nvim/eval/vars.h"
#include "nvim/ex_eval.h"
#include "nvim/fold.h"
diff --git a/src/nvim/lua/treesitter.c b/src/nvim/lua/treesitter.c
index d255dd56e5..265c4bf5ca 100644
--- a/src/nvim/lua/treesitter.c
+++ b/src/nvim/lua/treesitter.c
@@ -6,6 +6,7 @@
// trees and nodes, and could be broken out as a reusable lua package
#include <assert.h>
+#include <ctype.h>
#include <lauxlib.h>
#include <limits.h>
#include <lua.h>
@@ -20,7 +21,6 @@
#include "nvim/api/private/helpers.h"
#include "nvim/buffer_defs.h"
#include "nvim/globals.h"
-#include "nvim/lua/executor.h"
#include "nvim/lua/treesitter.h"
#include "nvim/macros.h"
#include "nvim/map.h"
diff --git a/src/nvim/lua/xdiff.c b/src/nvim/lua/xdiff.c
index b5575fe202..000aad85d1 100644
--- a/src/nvim/lua/xdiff.c
+++ b/src/nvim/lua/xdiff.c
@@ -4,6 +4,7 @@
#include <lauxlib.h>
#include <lua.h>
#include <stdbool.h>
+#include <stdint.h>
#include <string.h>
#include "luaconf.h"
diff --git a/src/nvim/main.c b/src/nvim/main.c
index c41683f3c5..f6fd3abaec 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -16,7 +16,6 @@
#include <stdlib.h>
#include <string.h>
-#include "auto/config.h"
#include "nvim/arglist.h"
#include "nvim/ascii.h"
#include "nvim/autocmd.h"
@@ -29,7 +28,6 @@
#include "nvim/drawscreen.h"
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
-#include "nvim/eval/typval_defs.h"
#include "nvim/eval/userfunc.h"
#include "nvim/event/multiqueue.h"
#include "nvim/event/stream.h"
@@ -53,7 +51,6 @@
#include "nvim/macros.h"
#include "nvim/main.h"
#include "nvim/mark.h"
-#include "nvim/memfile_defs.h"
#include "nvim/memline.h"
#include "nvim/memory.h"
#include "nvim/message.h"
@@ -62,14 +59,13 @@
#include "nvim/normal.h"
#include "nvim/ops.h"
#include "nvim/option.h"
-#include "nvim/option_defs.h"
+#include "nvim/option_vars.h"
#include "nvim/optionstr.h"
#include "nvim/os/fileio.h"
#include "nvim/os/input.h"
#include "nvim/os/lang.h"
#include "nvim/os/os.h"
#include "nvim/os/stdpaths_defs.h"
-#include "nvim/os/time.h"
#include "nvim/path.h"
#include "nvim/popupmenu.h"
#include "nvim/pos.h"
diff --git a/src/nvim/map.c b/src/nvim/map.c
index 54f1969df8..87b4d10314 100644
--- a/src/nvim/map.c
+++ b/src/nvim/map.c
@@ -9,11 +9,9 @@
// Map and Set does not make its own copy of the key or value.
#include <stdbool.h>
-#include <stdlib.h>
#include <string.h>
#include "auto/config.h"
-#include "nvim/gettext.h"
#include "nvim/map.h"
#include "nvim/memory.h"
diff --git a/src/nvim/map_glyph_cache.c b/src/nvim/map_glyph_cache.c
index 6dcbfe0532..0d0f5ddd73 100644
--- a/src/nvim/map_glyph_cache.c
+++ b/src/nvim/map_glyph_cache.c
@@ -8,8 +8,18 @@
// are always NUL terminated, though. Thus, it is enough to store an index into
// this array, and use strlen(), to retrive an interned key.
+#include <assert.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
+#include "nvim/ascii.h"
+#include "nvim/macros.h"
#include "nvim/map.h"
+#include "nvim/memory.h"
uint32_t mh_find_bucket_glyph(Set(glyph) *set, String key, bool put)
{
diff --git a/src/nvim/mapping.c b/src/nvim/mapping.c
index a19dbe78c5..1fb91d85b4 100644
--- a/src/nvim/mapping.c
+++ b/src/nvim/mapping.c
@@ -4,14 +4,16 @@
// mapping.c: Code for mappings and abbreviations.
#include <assert.h>
-#include <inttypes.h>
#include <lauxlib.h>
#include <limits.h>
#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include "nvim/api/keysets.h"
#include "nvim/api/private/converter.h"
#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
@@ -37,11 +39,14 @@
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/option_defs.h"
+#include "nvim/option_vars.h"
#include "nvim/pos.h"
#include "nvim/regexp.h"
+#include "nvim/regexp_defs.h"
#include "nvim/runtime.h"
#include "nvim/search.h"
#include "nvim/strings.h"
+#include "nvim/types.h"
#include "nvim/vim.h"
/// List used for abbreviations.
diff --git a/src/nvim/mark.c b/src/nvim/mark.c
index 20d60b44ec..913c9b2a29 100644
--- a/src/nvim/mark.c
+++ b/src/nvim/mark.c
@@ -17,7 +17,6 @@
#include "nvim/diff.h"
#include "nvim/edit.h"
#include "nvim/eval/typval.h"
-#include "nvim/eval/typval_defs.h"
#include "nvim/ex_cmds_defs.h"
#include "nvim/extmark.h"
#include "nvim/extmark_defs.h"
@@ -32,7 +31,7 @@
#include "nvim/message.h"
#include "nvim/move.h"
#include "nvim/normal.h"
-#include "nvim/option_defs.h"
+#include "nvim/option_vars.h"
#include "nvim/os/input.h"
#include "nvim/os/os.h"
#include "nvim/path.h"
@@ -40,7 +39,6 @@
#include "nvim/sign.h"
#include "nvim/strings.h"
#include "nvim/textobject.h"
-#include "nvim/undo_defs.h"
#include "nvim/vim.h"
// This file contains routines to maintain and manipulate marks.
diff --git a/src/nvim/marktree.c b/src/nvim/marktree.c
index 627efa9e96..197cc21308 100644
--- a/src/nvim/marktree.c
+++ b/src/nvim/marktree.c
@@ -46,6 +46,7 @@
// at the repo root.
#include <assert.h>
+#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -55,9 +56,10 @@
#include "nvim/marktree.h"
#include "nvim/memory.h"
#include "nvim/pos.h"
-
// only for debug functions
+#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
+#include "nvim/macros.h"
#define T MT_BRANCH_FACTOR
#define ILEN (sizeof(MTNode) + (2 * T) * sizeof(void *))
diff --git a/src/nvim/marktree.h b/src/nvim/marktree.h
index f53a54f3cc..6f157936cb 100644
--- a/src/nvim/marktree.h
+++ b/src/nvim/marktree.h
@@ -12,7 +12,6 @@
#include "nvim/map.h"
#include "nvim/pos.h"
#include "nvim/types.h"
-
// only for debug functions:
#include "api/private/defs.h"
diff --git a/src/nvim/match.c b/src/nvim/match.c
index 6d5873bc85..d54e2ce58a 100644
--- a/src/nvim/match.c
+++ b/src/nvim/match.c
@@ -15,7 +15,6 @@
#include "nvim/drawscreen.h"
#include "nvim/eval/funcs.h"
#include "nvim/eval/typval.h"
-#include "nvim/eval/typval_defs.h"
#include "nvim/eval/window.h"
#include "nvim/ex_cmds_defs.h"
#include "nvim/ex_docmd.h"
@@ -30,7 +29,7 @@
#include "nvim/memline.h"
#include "nvim/memory.h"
#include "nvim/message.h"
-#include "nvim/option_defs.h"
+#include "nvim/option_vars.h"
#include "nvim/pos.h"
#include "nvim/profile.h"
#include "nvim/regexp.h"
diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c
index 3f035974a1..7b7c822b3b 100644
--- a/src/nvim/mbyte.c
+++ b/src/nvim/mbyte.c
@@ -31,6 +31,7 @@
#include <iconv.h>
#include <locale.h>
#include <stdbool.h>
+#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -59,7 +60,7 @@
#include "nvim/memline.h"
#include "nvim/memory.h"
#include "nvim/message.h"
-#include "nvim/option_defs.h"
+#include "nvim/option_vars.h"
#include "nvim/optionstr.h"
#include "nvim/os/os.h"
#include "nvim/os/os_defs.h"
diff --git a/src/nvim/memfile.c b/src/nvim/memfile.c
index 6722d6bd8a..8c36a890de 100644
--- a/src/nvim/memfile.c
+++ b/src/nvim/memfile.c
@@ -45,13 +45,14 @@
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
+#include <sys/stat.h>
#include "nvim/assert.h"
#include "nvim/buffer_defs.h"
#include "nvim/fileio.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
-#include "nvim/macros.h"
+#include "nvim/map.h"
#include "nvim/memfile.h"
#include "nvim/memfile_defs.h"
#include "nvim/memline.h"
diff --git a/src/nvim/memline.c b/src/nvim/memline.c
index 230019c45c..7bfa6db4ef 100644
--- a/src/nvim/memline.c
+++ b/src/nvim/memline.c
@@ -39,6 +39,7 @@
#include <fcntl.h>
#include <inttypes.h>
#include <stdbool.h>
+#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
@@ -55,7 +56,6 @@
#include "nvim/drawscreen.h"
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
-#include "nvim/eval/typval_defs.h"
#include "nvim/ex_cmds_defs.h"
#include "nvim/fileio.h"
#include "nvim/getchar.h"
@@ -65,6 +65,7 @@
#include "nvim/input.h"
#include "nvim/macros.h"
#include "nvim/main.h"
+#include "nvim/map.h"
#include "nvim/mark.h"
#include "nvim/mbyte.h"
#include "nvim/memfile.h"
@@ -72,6 +73,7 @@
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/os/fs.h"
#include "nvim/os/input.h"
#include "nvim/os/os.h"
@@ -82,7 +84,6 @@
#include "nvim/spell.h"
#include "nvim/statusline.h"
#include "nvim/strings.h"
-#include "nvim/types.h"
#include "nvim/ui.h"
#include "nvim/undo.h"
#include "nvim/version.h"
diff --git a/src/nvim/memory.c b/src/nvim/memory.c
index 6b4d290863..997f465f02 100644
--- a/src/nvim/memory.c
+++ b/src/nvim/memory.c
@@ -29,6 +29,7 @@
#include "nvim/memfile.h"
#include "nvim/memory.h"
#include "nvim/message.h"
+#include "nvim/option_vars.h"
#include "nvim/sign.h"
#include "nvim/ui.h"
#include "nvim/usercmd.h"
@@ -656,7 +657,6 @@ char *arena_memdupz(Arena *arena, const char *buf, size_t size)
# include "nvim/cmdhist.h"
# include "nvim/diff.h"
# include "nvim/edit.h"
-# include "nvim/eval/typval.h"
# include "nvim/ex_cmds.h"
# include "nvim/ex_docmd.h"
# include "nvim/ex_getln.h"
diff --git a/src/nvim/menu.c b/src/nvim/menu.c
index f51f2999a3..2204a0a291 100644
--- a/src/nvim/menu.c
+++ b/src/nvim/menu.c
@@ -11,12 +11,10 @@
#include "nvim/ascii.h"
#include "nvim/autocmd.h"
-#include "nvim/buffer_defs.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
-#include "nvim/eval/typval_defs.h"
#include "nvim/ex_cmds_defs.h"
#include "nvim/ex_docmd.h"
#include "nvim/garray.h"
@@ -31,14 +29,13 @@
#include "nvim/menu.h"
#include "nvim/menu_defs.h"
#include "nvim/message.h"
-#include "nvim/option_defs.h"
+#include "nvim/option_vars.h"
#include "nvim/popupmenu.h"
#include "nvim/pos.h"
#include "nvim/state.h"
#include "nvim/strings.h"
#include "nvim/types.h"
#include "nvim/ui.h"
-#include "nvim/undo_defs.h"
#include "nvim/vim.h"
#define MENUDEPTH 10 // maximum depth of menus
diff --git a/src/nvim/message.c b/src/nvim/message.c
index 44fcd83af8..68ea49d53b 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -20,7 +20,6 @@
#include "nvim/drawscreen.h"
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
-#include "nvim/eval/typval_defs.h"
#include "nvim/event/defs.h"
#include "nvim/event/loop.h"
#include "nvim/event/multiqueue.h"
@@ -44,8 +43,10 @@
#include "nvim/mouse.h"
#include "nvim/ops.h"
#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/os/input.h"
#include "nvim/os/os.h"
+#include "nvim/os/time.h"
#include "nvim/pos.h"
#include "nvim/regexp.h"
#include "nvim/runtime.h"
diff --git a/src/nvim/mouse.c b/src/nvim/mouse.c
index 9b09a3fdf3..0433031393 100644
--- a/src/nvim/mouse.c
+++ b/src/nvim/mouse.c
@@ -16,7 +16,6 @@
#include "nvim/edit.h"
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
-#include "nvim/eval/typval_defs.h"
#include "nvim/ex_docmd.h"
#include "nvim/fold.h"
#include "nvim/getchar.h"
@@ -34,6 +33,7 @@
#include "nvim/normal.h"
#include "nvim/ops.h"
#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/plines.h"
#include "nvim/popupmenu.h"
#include "nvim/pos.h"
@@ -41,7 +41,6 @@
#include "nvim/state.h"
#include "nvim/statusline.h"
#include "nvim/strings.h"
-#include "nvim/syntax.h"
#include "nvim/types.h"
#include "nvim/ui.h"
#include "nvim/ui_compositor.h"
diff --git a/src/nvim/move.c b/src/nvim/move.c
index 97fd472850..8efb038a55 100644
--- a/src/nvim/move.c
+++ b/src/nvim/move.c
@@ -14,16 +14,16 @@
#include <limits.h>
#include <stdbool.h>
#include <stddef.h>
+#include <stdint.h>
#include "nvim/ascii.h"
#include "nvim/buffer.h"
-#include "nvim/charset.h"
#include "nvim/cursor.h"
#include "nvim/diff.h"
+#include "nvim/drawline.h"
#include "nvim/drawscreen.h"
#include "nvim/edit.h"
#include "nvim/eval/typval.h"
-#include "nvim/eval/typval_defs.h"
#include "nvim/eval/window.h"
#include "nvim/fold.h"
#include "nvim/getchar.h"
@@ -33,11 +33,12 @@
#include "nvim/highlight.h"
#include "nvim/macros.h"
#include "nvim/mbyte.h"
-#include "nvim/memline_defs.h"
+#include "nvim/memline.h"
#include "nvim/message.h"
#include "nvim/mouse.h"
#include "nvim/move.h"
#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/plines.h"
#include "nvim/popupmenu.h"
#include "nvim/pos.h"
diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c
index fb24100f3a..597aa56fa7 100644
--- a/src/nvim/msgpack_rpc/channel.c
+++ b/src/nvim/msgpack_rpc/channel.c
@@ -24,6 +24,7 @@
#include "nvim/event/rstream.h"
#include "nvim/event/stream.h"
#include "nvim/event/wstream.h"
+#include "nvim/globals.h"
#include "nvim/log.h"
#include "nvim/main.h"
#include "nvim/map.h"
diff --git a/src/nvim/msgpack_rpc/helpers.c b/src/nvim/msgpack_rpc/helpers.c
index 9afa3ea02a..5a3f31b7f5 100644
--- a/src/nvim/msgpack_rpc/helpers.c
+++ b/src/nvim/msgpack_rpc/helpers.c
@@ -11,7 +11,6 @@
#include "klib/kvec.h"
#include "msgpack/pack.h"
-#include "nvim/api/keysets.h"
#include "nvim/api/private/helpers.h"
#include "nvim/assert.h"
#include "nvim/event/wstream.h"
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index 834204e5e1..715b98377a 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -17,7 +17,6 @@
#include <string.h>
#include <time.h>
-#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/ascii.h"
#include "nvim/autocmd.h"
@@ -57,6 +56,7 @@
#include "nvim/normal.h"
#include "nvim/ops.h"
#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/os/input.h"
#include "nvim/os/time.h"
#include "nvim/plines.h"
@@ -73,7 +73,6 @@
#include "nvim/tag.h"
#include "nvim/textformat.h"
#include "nvim/textobject.h"
-#include "nvim/types.h"
#include "nvim/ui.h"
#include "nvim/undo.h"
#include "nvim/vim.h"
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index d42ce03f9a..5d3e285e3b 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -49,6 +49,8 @@
#include "nvim/normal.h"
#include "nvim/ops.h"
#include "nvim/option.h"
+#include "nvim/option_defs.h"
+#include "nvim/option_vars.h"
#include "nvim/os/input.h"
#include "nvim/os/time.h"
#include "nvim/plines.h"
diff --git a/src/nvim/ops.h b/src/nvim/ops.h
index e378d2f7b5..ae8b8b53e8 100644
--- a/src/nvim/ops.h
+++ b/src/nvim/ops.h
@@ -11,6 +11,7 @@
#include "nvim/extmark.h"
#include "nvim/macros.h"
#include "nvim/normal.h"
+#include "nvim/option_defs.h"
#include "nvim/os/time.h"
#include "nvim/pos.h"
#include "nvim/types.h"
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 22825dd7a7..eef5e66aeb 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -21,7 +21,6 @@
#define IN_OPTION_C
#include <assert.h>
-#include <ctype.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
@@ -30,6 +29,7 @@
#include <string.h>
#include "auto/config.h"
+#include "klib/kvec.h"
#include "nvim/api/extmark.h"
#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
@@ -46,7 +46,6 @@
#include "nvim/drawscreen.h"
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
-#include "nvim/eval/typval_defs.h"
#include "nvim/ex_cmds_defs.h"
#include "nvim/ex_docmd.h"
#include "nvim/ex_getln.h"
@@ -77,6 +76,7 @@
#include "nvim/ops.h"
#include "nvim/option.h"
#include "nvim/option_defs.h"
+#include "nvim/option_vars.h"
#include "nvim/optionstr.h"
#include "nvim/os/input.h"
#include "nvim/os/lang.h"
@@ -84,7 +84,6 @@
#include "nvim/path.h"
#include "nvim/popupmenu.h"
#include "nvim/pos.h"
-#include "nvim/quickfix.h"
#include "nvim/regexp.h"
#include "nvim/runtime.h"
#include "nvim/search.h"
@@ -92,7 +91,6 @@
#include "nvim/spell.h"
#include "nvim/spellfile.h"
#include "nvim/spellsuggest.h"
-#include "nvim/statusline.h"
#include "nvim/strings.h"
#include "nvim/tag.h"
#include "nvim/terminal.h"
@@ -2039,74 +2037,149 @@ static const char *did_set_force_off(bool *doskip)
return NULL;
}
-/// Process the updated 'langremap' option value.
-static const char *did_set_langremap(optset_T *args FUNC_ATTR_UNUSED)
+/// Process the updated 'arabic' option value.
+static const char *did_set_arabic(optset_T *args)
{
- // 'langremap' -> !'langnoremap'
- p_lnr = !p_lrm;
+ win_T *win = (win_T *)args->os_win;
+ const char *errmsg = NULL;
+
+ if (win->w_p_arab) {
+ // 'arabic' is set, handle various sub-settings.
+ if (!p_tbidi) {
+ // set rightleft mode
+ if (!win->w_p_rl) {
+ win->w_p_rl = true;
+ changed_window_setting();
+ }
+
+ // Enable Arabic shaping (major part of what Arabic requires)
+ if (!p_arshape) {
+ p_arshape = true;
+ redraw_all_later(UPD_NOT_VALID);
+ }
+ }
+
+ // Arabic requires a utf-8 encoding, inform the user if it's not
+ // set.
+ if (strcmp(p_enc, "utf-8") != 0) {
+ static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'");
+
+ msg_source(HL_ATTR(HLF_W));
+ msg(_(w_arabic), HL_ATTR(HLF_W));
+ set_vim_var_string(VV_WARNINGMSG, _(w_arabic), -1);
+ }
+
+ // set 'delcombine'
+ p_deco = true;
+
+ // Force-set the necessary keymap for arabic.
+ errmsg = set_option_value("keymap", STATIC_CSTR_AS_OPTVAL("arabic"), OPT_LOCAL);
+ } else {
+ // 'arabic' is reset, handle various sub-settings.
+ if (!p_tbidi) {
+ // reset rightleft mode
+ if (win->w_p_rl) {
+ win->w_p_rl = false;
+ changed_window_setting();
+ }
+
+ // 'arabicshape' isn't reset, it is a global option and
+ // another window may still need it "on".
+ }
+
+ // 'delcombine' isn't reset, it is a global option and another
+ // window may still want it "on".
+
+ // Revert to the default keymap
+ curbuf->b_p_iminsert = B_IMODE_NONE;
+ curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
+ }
+
+ return errmsg;
+}
+
+/// Process the updated 'autochdir' option value.
+static const char *did_set_autochdir(optset_T *args FUNC_ATTR_UNUSED)
+{
+ // Change directories when the 'acd' option is set now.
+ do_autochdir();
return NULL;
}
-/// Process the updated 'langnoremap' option value.
-static const char *did_set_langnoremap(optset_T *args FUNC_ATTR_UNUSED)
+/// Process the updated 'binary' option value.
+static const char *did_set_binary(optset_T *args)
{
- // 'langnoremap' -> !'langremap'
- p_lrm = !p_lnr;
+ buf_T *buf = (buf_T *)args->os_buf;
+
+ // when 'bin' is set also set some other options
+ set_options_bin((int)args->os_oldval.boolean, buf->b_p_bin, args->os_flags);
+ redraw_titles();
+
return NULL;
}
-/// Process the updated 'undofile' option value.
-static const char *did_set_undofile(optset_T *args)
+/// Called when the 'breakat' option changes value.
+static const char *did_set_breakat(optset_T *args FUNC_ATTR_UNUSED)
{
- // Only take action when the option was set.
- if (!curbuf->b_p_udf && !p_udf) {
- return NULL;
+ for (int i = 0; i < 256; i++) {
+ breakat_flags[i] = false;
}
- // When reset we do not delete the undo file, the option may be set again
- // without making any changes in between.
- uint8_t hash[UNDO_HASH_SIZE];
-
- FOR_ALL_BUFFERS(bp) {
- // When 'undofile' is set globally: for every buffer, otherwise
- // only for the current buffer: Try to read in the undofile,
- // if one exists, the buffer wasn't changed and the buffer was
- // loaded
- if ((curbuf == bp
- || (args->os_flags & OPT_GLOBAL) || args->os_flags == 0)
- && !bufIsChanged(bp) && bp->b_ml.ml_mfp != NULL) {
- u_compute_hash(bp, hash);
- u_read_undo(NULL, hash, bp->b_fname);
+ if (p_breakat != NULL) {
+ for (char *p = p_breakat; *p; p++) {
+ breakat_flags[(uint8_t)(*p)] = true;
}
}
return NULL;
}
-/// Process the updated 'readonly' option value.
-static const char *did_set_readonly(optset_T *args)
+/// Process the updated 'buflisted' option value.
+static const char *did_set_buflisted(optset_T *args)
{
- // when 'readonly' is reset globally, also reset readonlymode
- if (!curbuf->b_p_ro && (args->os_flags & OPT_LOCAL) == 0) {
- readonlymode = false;
+ buf_T *buf = (buf_T *)args->os_buf;
+
+ // when 'buflisted' changes, trigger autocommands
+ if (args->os_oldval.boolean != buf->b_p_bl) {
+ apply_autocmds(buf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE,
+ NULL, NULL, true, buf);
}
+ return NULL;
+}
- // when 'readonly' is set may give W10 again
- if (curbuf->b_p_ro) {
- curbuf->b_did_warn = false;
+/// Process the new 'cmdheight' option value.
+static const char *did_set_cmdheight(optset_T *args)
+{
+ OptInt old_value = args->os_oldval.number;
+
+ if (ui_has(kUIMessages)) {
+ p_ch = 0;
+ }
+ if (p_ch > Rows - min_rows() + 1) {
+ p_ch = Rows - min_rows() + 1;
}
- redraw_titles();
+ // if p_ch changed value, change the command line height
+ // Only compute the new window layout when startup has been
+ // completed. Otherwise the frame sizes may be wrong.
+ if ((p_ch != old_value
+ || tabline_height() + global_stl_height() + topframe->fr_height != Rows - p_ch)
+ && full_screen) {
+ command_height();
+ }
return NULL;
}
-/// Process the updated 'modifiable' option value.
-static const char *did_set_modifiable(optset_T *args FUNC_ATTR_UNUSED)
+/// Process the updated 'diff' option value.
+static const char *did_set_diff(optset_T *args)
{
- // when 'modifiable' is changed, redraw the window title
- redraw_titles();
-
+ win_T *win = (win_T *)args->os_win;
+ // May add or remove the buffer from the list of diff buffers.
+ diff_buf_adjust(win);
+ if (foldmethodIsDiff(win)) {
+ foldUpdateAll(win);
+ }
return NULL;
}
@@ -2119,46 +2192,175 @@ static const char *did_set_eof_eol_fixeol_bomb(optset_T *args FUNC_ATTR_UNUSED)
return NULL;
}
-/// Process the updated 'binary' option value.
-static const char *did_set_binary(optset_T *args)
+/// Process the updated 'equalalways' option value.
+static const char *did_set_equalalways(optset_T *args)
+{
+ win_T *win = (win_T *)args->os_win;
+ if (p_ea && !args->os_oldval.boolean) {
+ win_equal(win, false, 0);
+ }
+
+ return NULL;
+}
+
+/// Process the new 'foldlevel' option value.
+static const char *did_set_foldlevel(optset_T *args FUNC_ATTR_UNUSED)
+{
+ newFoldLevel();
+ return NULL;
+}
+
+/// Process the new 'foldminlines' option value.
+static const char *did_set_foldminlines(optset_T *args)
+{
+ win_T *win = (win_T *)args->os_win;
+ foldUpdateAll(win);
+ return NULL;
+}
+
+/// Process the new 'foldnestmax' option value.
+static const char *did_set_foldnestmax(optset_T *args)
+{
+ win_T *win = (win_T *)args->os_win;
+ if (foldmethodIsSyntax(win) || foldmethodIsIndent(win)) {
+ foldUpdateAll(win);
+ }
+ return NULL;
+}
+
+/// Process the new 'helpheight' option value.
+static const char *did_set_helpheight(optset_T *args)
+{
+ // Change window height NOW
+ if (!ONE_WINDOW) {
+ buf_T *buf = (buf_T *)args->os_buf;
+ win_T *win = (win_T *)args->os_win;
+ if (buf->b_help && win->w_height < p_hh) {
+ win_setheight((int)p_hh);
+ }
+ }
+
+ return NULL;
+}
+
+/// Process the updated 'hlsearch' option value.
+static const char *did_set_hlsearch(optset_T *args FUNC_ATTR_UNUSED)
+{
+ // when 'hlsearch' is set or reset: reset no_hlsearch
+ set_no_hlsearch(false);
+ return NULL;
+}
+
+/// Process the updated 'ignorecase' option value.
+static const char *did_set_ignorecase(optset_T *args FUNC_ATTR_UNUSED)
+{
+ // when 'ignorecase' is set or reset and 'hlsearch' is set, redraw
+ if (p_hls) {
+ redraw_all_later(UPD_SOME_VALID);
+ }
+ return NULL;
+}
+
+/// Process the new 'iminset' option value.
+static const char *did_set_iminsert(optset_T *args FUNC_ATTR_UNUSED)
+{
+ showmode();
+ // Show/unshow value of 'keymap' in status lines.
+ status_redraw_curbuf();
+
+ return NULL;
+}
+
+/// Process the updated 'langnoremap' option value.
+static const char *did_set_langnoremap(optset_T *args FUNC_ATTR_UNUSED)
+{
+ // 'langnoremap' -> !'langremap'
+ p_lrm = !p_lnr;
+ return NULL;
+}
+
+/// Process the updated 'langremap' option value.
+static const char *did_set_langremap(optset_T *args FUNC_ATTR_UNUSED)
+{
+ // 'langremap' -> !'langnoremap'
+ p_lnr = !p_lrm;
+ return NULL;
+}
+
+/// Process the new 'laststatus' option value.
+static const char *did_set_laststatus(optset_T *args)
+{
+ OptInt old_value = args->os_oldval.number;
+ OptInt value = args->os_newval.number;
+
+ // When switching to global statusline, decrease topframe height
+ // Also clear the cmdline to remove the ruler if there is one
+ if (value == 3 && old_value != 3) {
+ frame_new_height(topframe, topframe->fr_height - STATUS_HEIGHT, false, false);
+ (void)win_comp_pos();
+ clear_cmdline = true;
+ }
+ // When switching from global statusline, increase height of topframe by STATUS_HEIGHT
+ // in order to to re-add the space that was previously taken by the global statusline
+ if (old_value == 3 && value != 3) {
+ frame_new_height(topframe, topframe->fr_height + STATUS_HEIGHT, false, false);
+ (void)win_comp_pos();
+ }
+
+ last_status(false); // (re)set last window status line.
+ return NULL;
+}
+
+/// Process the updated 'lisp' option value.
+static const char *did_set_lisp(optset_T *args)
{
buf_T *buf = (buf_T *)args->os_buf;
+ // When 'lisp' option changes include/exclude '-' in keyword characters.
+ (void)buf_init_chartab(buf, false); // ignore errors
+ return NULL;
+}
- // when 'bin' is set also set some other options
- set_options_bin((int)args->os_oldval.boolean, buf->b_p_bin, args->os_flags);
+/// Process the updated 'modifiable' option value.
+static const char *did_set_modifiable(optset_T *args FUNC_ATTR_UNUSED)
+{
+ // when 'modifiable' is changed, redraw the window title
redraw_titles();
return NULL;
}
-/// Process the updated 'buflisted' option value.
-static const char *did_set_buflisted(optset_T *args)
+/// Process the updated 'modified' option value.
+static const char *did_set_modified(optset_T *args)
{
buf_T *buf = (buf_T *)args->os_buf;
-
- // when 'buflisted' changes, trigger autocommands
- if (args->os_oldval.boolean != buf->b_p_bl) {
- apply_autocmds(buf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE,
- NULL, NULL, true, buf);
+ if (!args->os_newval.boolean) {
+ save_file_ff(buf); // Buffer is unchanged
}
+ redraw_titles();
+ modified_was_set = (int)args->os_newval.boolean;
return NULL;
}
-/// Process the updated 'swapfile' option value.
-static const char *did_set_swapfile(optset_T *args)
+/// Process the updated 'number' or 'relativenumber' option value.
+static const char *did_set_number_relativenumber(optset_T *args)
{
- buf_T *buf = (buf_T *)args->os_buf;
- // when 'swf' is set, create swapfile, when reset remove swapfile
- if (buf->b_p_swf && p_uc) {
- ml_open_file(buf); // create the swap file
- } else {
- // no need to reset curbuf->b_may_swap, ml_open_file() will check
- // buf->b_p_swf
- mf_close_file(buf, true); // remove the swap file
+ win_T *win = (win_T *)args->os_win;
+ if (*win->w_p_stc != NUL) {
+ // When 'relativenumber'/'number' is changed and 'statuscolumn' is set, reset width.
+ win->w_nrwidth_line_count = 0;
}
return NULL;
}
+/// Process the new 'numberwidth' option value.
+static const char *did_set_numberwidth(optset_T *args)
+{
+ win_T *win = (win_T *)args->os_win;
+ win->w_nrwidth_line_count = 0; // trigger a redraw
+
+ return NULL;
+}
+
/// Process the updated 'paste' option value.
static const char *did_set_paste(optset_T *args FUNC_ATTR_UNUSED)
{
@@ -2288,39 +2490,6 @@ static const char *did_set_paste(optset_T *args FUNC_ATTR_UNUSED)
return NULL;
}
-/// Process the updated 'ignorecase' option value.
-static const char *did_set_ignorecase(optset_T *args FUNC_ATTR_UNUSED)
-{
- // when 'ignorecase' is set or reset and 'hlsearch' is set, redraw
- if (p_hls) {
- redraw_all_later(UPD_SOME_VALID);
- }
- return NULL;
-}
-
-/// Process the updated 'hlsearch' option value.
-static const char *did_set_hlsearch(optset_T *args FUNC_ATTR_UNUSED)
-{
- // when 'hlsearch' is set or reset: reset no_hlsearch
- set_no_hlsearch(false);
- return NULL;
-}
-
-/// Process the updated 'scrollbind' option value.
-static const char *did_set_scrollbind(optset_T *args)
-{
- win_T *win = (win_T *)args->os_win;
-
- // when 'scrollbind' is set: snapshot the current position to avoid a jump
- // at the end of normal_cmd()
- if (!win->w_p_scb) {
- return NULL;
- }
- do_check_scrollbind(false);
- win->w_scbind_pos = win->w_topline;
- return NULL;
-}
-
/// Process the updated 'previewwindow' option value.
static const char *did_set_previewwindow(optset_T *args)
{
@@ -2342,32 +2511,63 @@ static const char *did_set_previewwindow(optset_T *args)
return NULL;
}
-/// Process the updated 'lisp' option value.
-static const char *did_set_lisp(optset_T *args)
+/// Process the new 'pumblend' option value.
+static const char *did_set_pumblend(optset_T *args FUNC_ATTR_UNUSED)
{
- buf_T *buf = (buf_T *)args->os_buf;
- // When 'lisp' option changes include/exclude '-' in keyword characters.
- (void)buf_init_chartab(buf, false); // ignore errors
+ p_pb = MAX(MIN(p_pb, 100), 0);
+ hl_invalidate_blends();
+ pum_grid.blending = (p_pb > 0);
+ if (pum_drawn()) {
+ pum_redraw();
+ }
+
return NULL;
}
-/// Process the updated 'title' or the 'icon' option value.
-static const char *did_set_title_icon(optset_T *args FUNC_ATTR_UNUSED)
+/// Process the updated 'readonly' option value.
+static const char *did_set_readonly(optset_T *args)
{
- // when 'title' changed, may need to change the title; same for 'icon'
- did_set_title();
+ // when 'readonly' is reset globally, also reset readonlymode
+ if (!curbuf->b_p_ro && (args->os_flags & OPT_LOCAL) == 0) {
+ readonlymode = false;
+ }
+
+ // when 'readonly' is set may give W10 again
+ if (curbuf->b_p_ro) {
+ curbuf->b_did_warn = false;
+ }
+
+ redraw_titles();
+
return NULL;
}
-/// Process the updated 'modified' option value.
-static const char *did_set_modified(optset_T *args)
+/// Process the new 'scrollback' option value.
+static const char *did_set_scrollback(optset_T *args)
{
buf_T *buf = (buf_T *)args->os_buf;
- if (!args->os_newval.boolean) {
- save_file_ff(buf); // Buffer is unchanged
+ OptInt old_value = args->os_oldval.number;
+ OptInt value = args->os_newval.number;
+
+ if (buf->terminal && value < old_value) {
+ // Force the scrollback to take immediate effect only when decreasing it.
+ on_scrollback_option_changed(buf->terminal);
}
- redraw_titles();
- modified_was_set = (int)args->os_newval.boolean;
+ return NULL;
+}
+
+/// Process the updated 'scrollbind' option value.
+static const char *did_set_scrollbind(optset_T *args)
+{
+ win_T *win = (win_T *)args->os_win;
+
+ // when 'scrollbind' is set: snapshot the current position to avoid a jump
+ // at the end of normal_cmd()
+ if (!win->w_p_scb) {
+ return NULL;
+ }
+ do_check_scrollbind(false);
+ win->w_scbind_pos = win->w_topline;
return NULL;
}
@@ -2393,46 +2593,43 @@ static const char *did_set_shellslash(optset_T *args FUNC_ATTR_UNUSED)
}
#endif
-/// Process the updated 'wrap' option value.
-static const char *did_set_wrap(optset_T *args)
+/// Process the new 'shiftwidth' or the 'tabstop' option value.
+static const char *did_set_shiftwidth_tabstop(optset_T *args)
{
+ buf_T *buf = (buf_T *)args->os_buf;
win_T *win = (win_T *)args->os_win;
+ OptInt *pp = (OptInt *)args->os_varp;
- // If 'wrap' is set, set w_leftcol to zero.
- if (win->w_p_wrap) {
- win->w_leftcol = 0;
+ if (foldmethodIsIndent(win)) {
+ foldUpdateAll(win);
}
- return NULL;
-}
-
-/// Process the updated 'equalalways' option value.
-static const char *did_set_equalalways(optset_T *args)
-{
- win_T *win = (win_T *)args->os_win;
- if (p_ea && !args->os_oldval.boolean) {
- win_equal(win, false, 0);
+ // When 'shiftwidth' changes, or it's zero and 'tabstop' changes:
+ // parse 'cinoptions'.
+ if (pp == &buf->b_p_sw || buf->b_p_sw == 0) {
+ parse_cino(buf);
}
return NULL;
}
-/// Process the updated 'autochdir' option value.
-static const char *did_set_autochdir(optset_T *args FUNC_ATTR_UNUSED)
+/// Process the new 'showtabline' option value.
+static const char *did_set_showtabline(optset_T *args FUNC_ATTR_UNUSED)
{
- // Change directories when the 'acd' option is set now.
- do_autochdir();
+ // (re)set tab page line
+ win_new_screen_rows(); // recompute window positions and heights
return NULL;
}
-/// Process the updated 'diff' option value.
-static const char *did_set_diff(optset_T *args)
+/// Process the updated 'smoothscroll' option value.
+static const char *did_set_smoothscroll(optset_T *args FUNC_ATTR_UNUSED)
{
win_T *win = (win_T *)args->os_win;
- // May add or remove the buffer from the list of diff buffers.
- diff_buf_adjust(win);
- if (foldmethodIsDiff(win)) {
- foldUpdateAll(win);
+ if (win->w_p_sms) {
+ return NULL;
}
+
+ win->w_skipcol = 0;
+ changed_line_abv_curs_win(win);
return NULL;
}
@@ -2447,74 +2644,189 @@ static const char *did_set_spell(optset_T *args)
return NULL;
}
-/// Process the updated 'arabic' option value.
-static const char *did_set_arabic(optset_T *args)
+/// Process the updated 'swapfile' option value.
+static const char *did_set_swapfile(optset_T *args)
{
- win_T *win = (win_T *)args->os_win;
- const char *errmsg = NULL;
+ buf_T *buf = (buf_T *)args->os_buf;
+ // when 'swf' is set, create swapfile, when reset remove swapfile
+ if (buf->b_p_swf && p_uc) {
+ ml_open_file(buf); // create the swap file
+ } else {
+ // no need to reset curbuf->b_may_swap, ml_open_file() will check
+ // buf->b_p_swf
+ mf_close_file(buf, true); // remove the swap file
+ }
+ return NULL;
+}
- if (win->w_p_arab) {
- // 'arabic' is set, handle various sub-settings.
- if (!p_tbidi) {
- // set rightleft mode
- if (!win->w_p_rl) {
- win->w_p_rl = true;
- changed_window_setting();
- }
+/// Process the new 'textwidth' option value.
+static const char *did_set_textwidth(optset_T *args FUNC_ATTR_UNUSED)
+{
+ FOR_ALL_TAB_WINDOWS(tp, wp) {
+ check_colorcolumn(wp);
+ }
- // Enable Arabic shaping (major part of what Arabic requires)
- if (!p_arshape) {
- p_arshape = true;
- redraw_all_later(UPD_NOT_VALID);
- }
- }
+ return NULL;
+}
- // Arabic requires a utf-8 encoding, inform the user if it's not
- // set.
- if (strcmp(p_enc, "utf-8") != 0) {
- static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'");
+/// Process the updated 'title' or the 'icon' option value.
+static const char *did_set_title_icon(optset_T *args FUNC_ATTR_UNUSED)
+{
+ // when 'title' changed, may need to change the title; same for 'icon'
+ did_set_title();
+ return NULL;
+}
- msg_source(HL_ATTR(HLF_W));
- msg(_(w_arabic), HL_ATTR(HLF_W));
- set_vim_var_string(VV_WARNINGMSG, _(w_arabic), -1);
- }
+/// Process the new 'titlelen' option value.
+static const char *did_set_titlelen(optset_T *args)
+{
+ OptInt old_value = args->os_oldval.number;
- // set 'delcombine'
- p_deco = true;
+ // if 'titlelen' has changed, redraw the title
+ if (starting != NO_SCREEN && old_value != p_titlelen) {
+ need_maketitle = true;
+ }
- // Force-set the necessary keymap for arabic.
- errmsg = set_option_value("keymap", STATIC_CSTR_AS_OPTVAL("arabic"), OPT_LOCAL);
- } else {
- // 'arabic' is reset, handle various sub-settings.
- if (!p_tbidi) {
- // reset rightleft mode
- if (win->w_p_rl) {
- win->w_p_rl = false;
- changed_window_setting();
- }
+ return NULL;
+}
- // 'arabicshape' isn't reset, it is a global option and
- // another window may still need it "on".
+/// Process the updated 'undofile' option value.
+static const char *did_set_undofile(optset_T *args)
+{
+ // Only take action when the option was set.
+ if (!curbuf->b_p_udf && !p_udf) {
+ return NULL;
+ }
+
+ // When reset we do not delete the undo file, the option may be set again
+ // without making any changes in between.
+ uint8_t hash[UNDO_HASH_SIZE];
+
+ FOR_ALL_BUFFERS(bp) {
+ // When 'undofile' is set globally: for every buffer, otherwise
+ // only for the current buffer: Try to read in the undofile,
+ // if one exists, the buffer wasn't changed and the buffer was
+ // loaded
+ if ((curbuf == bp
+ || (args->os_flags & OPT_GLOBAL) || args->os_flags == 0)
+ && !bufIsChanged(bp) && bp->b_ml.ml_mfp != NULL) {
+ u_compute_hash(bp, hash);
+ u_read_undo(NULL, hash, bp->b_fname);
}
+ }
- // 'delcombine' isn't reset, it is a global option and another
- // window may still want it "on".
+ return NULL;
+}
- // Revert to the default keymap
- curbuf->b_p_iminsert = B_IMODE_NONE;
- curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
+/// Process the new global 'undolevels' option value.
+const char *did_set_global_undolevels(OptInt value, OptInt old_value)
+{
+ // sync undo before 'undolevels' changes
+ // use the old value, otherwise u_sync() may not work properly
+ p_ul = old_value;
+ u_sync(true);
+ p_ul = value;
+ return NULL;
+}
+
+/// Process the new buffer local 'undolevels' option value.
+const char *did_set_buflocal_undolevels(buf_T *buf, OptInt value, OptInt old_value)
+{
+ // use the old value, otherwise u_sync() may not work properly
+ buf->b_p_ul = old_value;
+ u_sync(true);
+ buf->b_p_ul = value;
+ return NULL;
+}
+
+/// Process the new 'undolevels' option value.
+static const char *did_set_undolevels(optset_T *args)
+{
+ buf_T *buf = (buf_T *)args->os_buf;
+ OptInt *pp = (OptInt *)args->os_varp;
+
+ if (pp == &p_ul) { // global 'undolevels'
+ did_set_global_undolevels(args->os_newval.number, args->os_oldval.number);
+ } else if (pp == &curbuf->b_p_ul) { // buffer local 'undolevels'
+ did_set_buflocal_undolevels(buf, args->os_newval.number, args->os_oldval.number);
}
- return errmsg;
+ return NULL;
}
-/// Process the updated 'number' or 'relativenumber' option value.
-static const char *did_set_number_relativenumber(optset_T *args)
+/// Process the new 'updatecount' option value.
+static const char *did_set_updatecount(optset_T *args)
+{
+ OptInt old_value = args->os_oldval.number;
+
+ // when 'updatecount' changes from zero to non-zero, open swap files
+ if (p_uc && !old_value) {
+ ml_open_files();
+ }
+
+ return NULL;
+}
+
+/// Process the new 'winblend' option value.
+static const char *did_set_winblend(optset_T *args)
{
win_T *win = (win_T *)args->os_win;
- if (*win->w_p_stc != NUL) {
- // When 'relativenumber'/'number' is changed and 'statuscolumn' is set, reset width.
- win->w_nrwidth_line_count = 0;
+ OptInt old_value = args->os_oldval.number;
+ OptInt value = args->os_newval.number;
+
+ if (value != old_value) {
+ win->w_p_winbl = MAX(MIN(win->w_p_winbl, 100), 0);
+ win->w_hl_needs_update = true;
+ check_blending(curwin);
+ }
+
+ return NULL;
+}
+
+/// Process the new 'window' option value.
+static const char *did_set_window(optset_T *args FUNC_ATTR_UNUSED)
+{
+ if (p_window < 1) {
+ p_window = Rows - 1;
+ } else if (p_window >= Rows) {
+ p_window = Rows - 1;
+ }
+ return NULL;
+}
+
+/// Process the new 'winheight' value.
+static const char *did_set_winheight(optset_T *args)
+{
+ // Change window height NOW
+ if (!ONE_WINDOW) {
+ win_T *win = (win_T *)args->os_win;
+ if (win->w_height < p_wh) {
+ win_setheight((int)p_wh);
+ }
+ }
+
+ return NULL;
+}
+
+/// Process the new 'winwidth' option value.
+static const char *did_set_winwidth(optset_T *args)
+{
+ win_T *win = (win_T *)args->os_win;
+
+ if (!ONE_WINDOW && win->w_width < p_wiw) {
+ win_setwidth((int)p_wiw);
+ }
+ return NULL;
+}
+
+/// Process the updated 'wrap' option value.
+static const char *did_set_wrap(optset_T *args)
+{
+ win_T *win = (win_T *)args->os_win;
+
+ // If 'wrap' is set, set w_leftcol to zero.
+ if (win->w_p_wrap) {
+ win->w_leftcol = 0;
}
return NULL;
}
@@ -2608,304 +2920,6 @@ static const char *set_bool_option(const int opt_idx, char *const varp, const in
return errmsg;
}
-/// Process the new 'winheight' value.
-static const char *did_set_winheight(optset_T *args)
-{
- // Change window height NOW
- if (!ONE_WINDOW) {
- win_T *win = (win_T *)args->os_win;
- if (win->w_height < p_wh) {
- win_setheight((int)p_wh);
- }
- }
-
- return NULL;
-}
-
-/// Process the new 'helpheight' option value.
-static const char *did_set_helpheight(optset_T *args)
-{
- // Change window height NOW
- if (!ONE_WINDOW) {
- buf_T *buf = (buf_T *)args->os_buf;
- win_T *win = (win_T *)args->os_win;
- if (buf->b_help && win->w_height < p_hh) {
- win_setheight((int)p_hh);
- }
- }
-
- return NULL;
-}
-
-/// Process the new 'winwidth' option value.
-static const char *did_set_winwidth(optset_T *args)
-{
- win_T *win = (win_T *)args->os_win;
-
- if (!ONE_WINDOW && win->w_width < p_wiw) {
- win_setwidth((int)p_wiw);
- }
- return NULL;
-}
-
-/// Process the new 'laststatus' option value.
-static const char *did_set_laststatus(optset_T *args)
-{
- OptInt old_value = args->os_oldval.number;
- OptInt value = args->os_newval.number;
-
- // When switching to global statusline, decrease topframe height
- // Also clear the cmdline to remove the ruler if there is one
- if (value == 3 && old_value != 3) {
- frame_new_height(topframe, topframe->fr_height - STATUS_HEIGHT, false, false);
- (void)win_comp_pos();
- clear_cmdline = true;
- }
- // When switching from global statusline, increase height of topframe by STATUS_HEIGHT
- // in order to to re-add the space that was previously taken by the global statusline
- if (old_value == 3 && value != 3) {
- frame_new_height(topframe, topframe->fr_height + STATUS_HEIGHT, false, false);
- (void)win_comp_pos();
- }
-
- last_status(false); // (re)set last window status line.
- return NULL;
-}
-
-/// Process the new 'showtabline' option value.
-static const char *did_set_showtabline(optset_T *args FUNC_ATTR_UNUSED)
-{
- // (re)set tab page line
- win_new_screen_rows(); // recompute window positions and heights
- return NULL;
-}
-
-/// Process the updated 'smoothscroll' option value.
-static const char *did_set_smoothscroll(optset_T *args FUNC_ATTR_UNUSED)
-{
- win_T *win = (win_T *)args->os_win;
- if (win->w_p_sms) {
- return NULL;
- }
-
- win->w_skipcol = 0;
- changed_line_abv_curs_win(win);
- return NULL;
-}
-
-/// Process the new 'foldlevel' option value.
-static const char *did_set_foldlevel(optset_T *args FUNC_ATTR_UNUSED)
-{
- newFoldLevel();
- return NULL;
-}
-
-/// Process the new 'foldminlines' option value.
-static const char *did_set_foldminlines(optset_T *args)
-{
- win_T *win = (win_T *)args->os_win;
- foldUpdateAll(win);
- return NULL;
-}
-
-/// Process the new 'foldnestmax' option value.
-static const char *did_set_foldnestmax(optset_T *args)
-{
- win_T *win = (win_T *)args->os_win;
- if (foldmethodIsSyntax(win) || foldmethodIsIndent(win)) {
- foldUpdateAll(win);
- }
- return NULL;
-}
-
-/// Process the new 'shiftwidth' or the 'tabstop' option value.
-static const char *did_set_shiftwidth_tabstop(optset_T *args)
-{
- buf_T *buf = (buf_T *)args->os_buf;
- win_T *win = (win_T *)args->os_win;
- OptInt *pp = (OptInt *)args->os_varp;
-
- if (foldmethodIsIndent(win)) {
- foldUpdateAll(win);
- }
- // When 'shiftwidth' changes, or it's zero and 'tabstop' changes:
- // parse 'cinoptions'.
- if (pp == &buf->b_p_sw || buf->b_p_sw == 0) {
- parse_cino(buf);
- }
-
- return NULL;
-}
-
-/// Process the new 'iminset' option value.
-static const char *did_set_iminsert(optset_T *args FUNC_ATTR_UNUSED)
-{
- showmode();
- // Show/unshow value of 'keymap' in status lines.
- status_redraw_curbuf();
-
- return NULL;
-}
-
-/// Process the new 'window' option value.
-static const char *did_set_window(optset_T *args FUNC_ATTR_UNUSED)
-{
- if (p_window < 1) {
- p_window = Rows - 1;
- } else if (p_window >= Rows) {
- p_window = Rows - 1;
- }
- return NULL;
-}
-
-/// Process the new 'titlelen' option value.
-static const char *did_set_titlelen(optset_T *args)
-{
- OptInt old_value = args->os_oldval.number;
-
- // if 'titlelen' has changed, redraw the title
- if (starting != NO_SCREEN && old_value != p_titlelen) {
- need_maketitle = true;
- }
-
- return NULL;
-}
-
-/// Process the new 'cmdheight' option value.
-static const char *did_set_cmdheight(optset_T *args)
-{
- OptInt old_value = args->os_oldval.number;
-
- if (ui_has(kUIMessages)) {
- p_ch = 0;
- }
- if (p_ch > Rows - min_rows() + 1) {
- p_ch = Rows - min_rows() + 1;
- }
-
- // if p_ch changed value, change the command line height
- // Only compute the new window layout when startup has been
- // completed. Otherwise the frame sizes may be wrong.
- if ((p_ch != old_value
- || tabline_height() + global_stl_height() + topframe->fr_height != Rows - p_ch)
- && full_screen) {
- command_height();
- }
-
- return NULL;
-}
-
-/// Process the new 'updatecount' option value.
-static const char *did_set_updatecount(optset_T *args)
-{
- OptInt old_value = args->os_oldval.number;
-
- // when 'updatecount' changes from zero to non-zero, open swap files
- if (p_uc && !old_value) {
- ml_open_files();
- }
-
- return NULL;
-}
-
-/// Process the new 'pumblend' option value.
-static const char *did_set_pumblend(optset_T *args FUNC_ATTR_UNUSED)
-{
- p_pb = MAX(MIN(p_pb, 100), 0);
- hl_invalidate_blends();
- pum_grid.blending = (p_pb > 0);
- if (pum_drawn()) {
- pum_redraw();
- }
-
- return NULL;
-}
-
-/// Process the new global 'undolevels' option value.
-const char *did_set_global_undolevels(OptInt value, OptInt old_value)
-{
- // sync undo before 'undolevels' changes
- // use the old value, otherwise u_sync() may not work properly
- p_ul = old_value;
- u_sync(true);
- p_ul = value;
- return NULL;
-}
-
-/// Process the new buffer local 'undolevels' option value.
-const char *did_set_buflocal_undolevels(buf_T *buf, OptInt value, OptInt old_value)
-{
- // use the old value, otherwise u_sync() may not work properly
- buf->b_p_ul = old_value;
- u_sync(true);
- buf->b_p_ul = value;
- return NULL;
-}
-
-/// Process the new 'scrollback' option value.
-static const char *did_set_scrollback(optset_T *args)
-{
- buf_T *buf = (buf_T *)args->os_buf;
- OptInt old_value = args->os_oldval.number;
- OptInt value = args->os_newval.number;
-
- if (buf->terminal && value < old_value) {
- // Force the scrollback to take immediate effect only when decreasing it.
- on_scrollback_option_changed(buf->terminal);
- }
- return NULL;
-}
-
-/// Process the new 'numberwidth' option value.
-static const char *did_set_numberwidth(optset_T *args)
-{
- win_T *win = (win_T *)args->os_win;
- win->w_nrwidth_line_count = 0; // trigger a redraw
-
- return NULL;
-}
-
-/// Process the new 'textwidth' option value.
-static const char *did_set_textwidth(optset_T *args FUNC_ATTR_UNUSED)
-{
- FOR_ALL_TAB_WINDOWS(tp, wp) {
- check_colorcolumn(wp);
- }
-
- return NULL;
-}
-
-/// Process the new 'winblend' option value.
-static const char *did_set_winblend(optset_T *args)
-{
- win_T *win = (win_T *)args->os_win;
- OptInt old_value = args->os_oldval.number;
- OptInt value = args->os_newval.number;
-
- if (value != old_value) {
- win->w_p_winbl = MAX(MIN(win->w_p_winbl, 100), 0);
- win->w_hl_needs_update = true;
- check_blending(curwin);
- }
-
- return NULL;
-}
-
-/// Process the new 'undolevels' option value.
-static const char *did_set_undolevels(optset_T *args)
-{
- buf_T *buf = (buf_T *)args->os_buf;
- OptInt *pp = (OptInt *)args->os_varp;
-
- if (pp == &p_ul) { // global 'undolevels'
- did_set_global_undolevels(args->os_newval.number, args->os_oldval.number);
- } else if (pp == &curbuf->b_p_ul) { // buffer local 'undolevels'
- did_set_buflocal_undolevels(buf, args->os_newval.number, args->os_oldval.number);
- }
-
- return NULL;
-}
-
/// Check the bounds of numeric options.
static const char *check_num_option_bounds(OptInt *pp, OptInt old_value, long old_Rows,
char *errbuf, size_t errbuflen, const char *errmsg)
@@ -5746,22 +5760,6 @@ void reset_option_was_set(const char *name)
options[idx].flags &= ~P_WAS_SET;
}
-/// Called when the 'breakat' option changes value.
-static const char *did_set_breakat(optset_T *args FUNC_ATTR_UNUSED)
-{
- for (int i = 0; i < 256; i++) {
- breakat_flags[i] = false;
- }
-
- if (p_breakat != NULL) {
- for (char *p = p_breakat; *p; p++) {
- breakat_flags[(uint8_t)(*p)] = true;
- }
- }
-
- return NULL;
-}
-
/// fill_culopt_flags() -- called when 'culopt' changes value
int fill_culopt_flags(char *val, win_T *wp)
{
diff --git a/src/nvim/option.h b/src/nvim/option.h
index 4b8329ad1c..9e3bf25bc3 100644
--- a/src/nvim/option.h
+++ b/src/nvim/option.h
@@ -1,15 +1,95 @@
#ifndef NVIM_OPTION_H
#define NVIM_OPTION_H
+#include <stdint.h>
+
#include "nvim/api/private/helpers.h"
+#include "nvim/eval/typval_defs.h"
#include "nvim/ex_cmds_defs.h"
+#include "nvim/option_defs.h"
+
+/// The options that are local to a window or buffer have "indir" set to one of
+/// these values. Special values:
+/// PV_NONE: global option.
+/// PV_WIN is added: window-local option
+/// PV_BUF is added: buffer-local option
+/// PV_BOTH is added: global option which also has a local value.
+enum {
+ PV_BOTH = 0x1000,
+ PV_WIN = 0x2000,
+ PV_BUF = 0x4000,
+ PV_MASK = 0x0fff,
+};
+#define OPT_WIN(x) (idopt_T)(PV_WIN + (int)(x))
+#define OPT_BUF(x) (idopt_T)(PV_BUF + (int)(x))
+#define OPT_BOTH(x) (idopt_T)(PV_BOTH + (int)(x))
+
+/// WV_ and BV_ values get typecasted to this for the "indir" field
+typedef enum {
+ PV_NONE = 0,
+ PV_MAXVAL = 0xffff, ///< to avoid warnings for value out of range
+} idopt_T;
+
+// 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 *)-1)
+
+typedef struct vimoption {
+ char *fullname; ///< full option name
+ char *shortname; ///< permissible abbreviation
+ uint32_t flags; ///< see above
+ void *var; ///< global option: pointer to variable;
+ ///< window-local option: VAR_WIN;
+ ///< buffer-local option: global value
+ idopt_T indir; ///< global option: PV_NONE;
+ ///< local option: indirect option index
+ ///< callback function to invoke after an option is modified to validate and
+ ///< apply the new value.
+ opt_did_set_cb_T opt_did_set_cb;
+ void *def_val; ///< default values for variable (neovim!!)
+ LastSet last_set; ///< script in which the option was last set
+} vimoption_T;
+
+/// flags for buf_copy_options()
+enum {
+ BCO_ENTER = 1, ///< going to enter the buffer
+ BCO_ALWAYS = 2, ///< always copy the options
+ BCO_NOHELP = 4, ///< don't touch the help related options
+};
+
+/// Flags for option-setting functions
+///
+/// When OPT_GLOBAL and OPT_LOCAL are both missing, set both local and global
+/// values, get local value.
+typedef enum {
+ OPT_FREE = 0x01, ///< Free old value if it was allocated.
+ OPT_GLOBAL = 0x02, ///< Use global value.
+ OPT_LOCAL = 0x04, ///< Use local value.
+ OPT_MODELINE = 0x08, ///< Option in modeline.
+ OPT_WINONLY = 0x10, ///< Only set window-local options.
+ OPT_NOWIN = 0x20, ///< Don’t set window-local options.
+ OPT_ONECOLUMN = 0x40, ///< list options one per line
+ OPT_NO_REDRAW = 0x80, ///< ignore redraw flags on option
+ OPT_SKIPRTP = 0x100, ///< "skiprtp" in 'sessionoptions'
+} OptionFlags;
-// flags for buf_copy_options()
-#define BCO_ENTER 1 // going to enter the buffer
-#define BCO_ALWAYS 2 // always copy the options
-#define BCO_NOHELP 4 // don't touch the help related options
+/// Return value from get_option_value_strict
+enum {
+ SOPT_BOOL = 0x01, ///< Boolean option
+ SOPT_NUM = 0x02, ///< Number option
+ SOPT_STRING = 0x04, ///< String option
+ SOPT_GLOBAL = 0x08, ///< Option has global value
+ SOPT_WIN = 0x10, ///< Option has window-local value
+ SOPT_BUF = 0x20, ///< Option has buffer-local value
+ SOPT_UNSET = 0x40, ///< Option does not have local value set
+};
-#define MAX_NUMBERWIDTH 20 // used for 'numberwidth' and 'statuscolumn'
+/// Option types for various functions in option.c
+enum {
+ SREQ_GLOBAL = 0, ///< Request global option value
+ SREQ_WIN = 1, ///< Request window-local option value
+ SREQ_BUF = 2, ///< Request buffer-local option value
+};
// OptVal helper macros.
#define NIL_OPTVAL ((OptVal) { .type = kOptValTypeNil })
diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h
index 1640bcb36b..f078f6073c 100644
--- a/src/nvim/option_defs.h
+++ b/src/nvim/option_defs.h
@@ -3,1019 +3,69 @@
#include "nvim/api/private/defs.h"
#include "nvim/eval/typval_defs.h"
-#include "nvim/macros.h"
#include "nvim/types.h"
-// option_defs.h: definition of global variables for settable options
-
-// Option Flags
-#define P_BOOL 0x01U ///< the option is boolean
-#define P_NUM 0x02U ///< the option is numeric
-#define P_STRING 0x04U ///< the option is a string
-#define P_ALLOCED 0x08U ///< the string option is in allocated memory,
- ///< must use free_string_option() when
- ///< assigning new value. Not set if default is
- ///< the same.
-#define P_EXPAND 0x10U ///< environment expansion. NOTE: P_EXPAND can
- ///< never be used for local or hidden options
-#define P_NODEFAULT 0x40U ///< don't set to default value
-#define P_DEF_ALLOCED 0x80U ///< default value is in allocated memory, must
- ///< use free() when assigning new value
-#define P_WAS_SET 0x100U ///< option has been set/reset
-#define P_NO_MKRC 0x200U ///< don't include in :mkvimrc output
-
-// when option changed, what to display:
-#define P_UI_OPTION 0x400U ///< send option to remote UI
-#define P_RTABL 0x800U ///< redraw tabline
-#define P_RSTAT 0x1000U ///< redraw status lines
-#define P_RWIN 0x2000U ///< redraw current window and recompute text
-#define P_RBUF 0x4000U ///< redraw current buffer and recompute text
-#define P_RALL 0x6000U ///< redraw all windows
-#define P_RCLR 0x7000U ///< clear and redraw all
-
-#define P_COMMA 0x8000U ///< comma separated list
-#define P_ONECOMMA 0x18000U ///< P_COMMA and cannot have two consecutive
- ///< commas
-#define P_NODUP 0x20000U ///< don't allow duplicate strings
-#define P_FLAGLIST 0x40000U ///< list of single-char flags
-
-#define P_SECURE 0x80000U ///< cannot change in modeline or secure mode
-#define P_GETTEXT 0x100000U ///< expand default value with _()
-#define P_NOGLOB 0x200000U ///< do not use local value for global vimrc
-#define P_NFNAME 0x400000U ///< only normal file name chars allowed
-#define P_INSECURE 0x800000U ///< option was set from a modeline
-#define P_PRI_MKRC 0x1000000U ///< priority for :mkvimrc (setting option
- ///< has side effects)
-#define P_NO_ML 0x2000000U ///< not allowed in modeline
-#define P_CURSWANT 0x4000000U ///< update curswant required; not needed
- ///< when there is a redraw flag
-#define P_NDNAME 0x8000000U ///< only normal dir name chars allowed
-#define P_RWINONLY 0x10000000U ///< only redraw current window
-#define P_MLE 0x20000000U ///< under control of 'modelineexpr'
-#define P_FUNC 0x40000000U ///< accept a function reference or a lambda
-
-#define P_NO_DEF_EXP 0x80000000U ///< Do not expand default value.
-
-/// Flags for option-setting functions
-///
-/// When OPT_GLOBAL and OPT_LOCAL are both missing, set both local and global
-/// values, get local value.
+/// Option value type
typedef enum {
- OPT_FREE = 0x01, ///< Free old value if it was allocated.
- OPT_GLOBAL = 0x02, ///< Use global value.
- OPT_LOCAL = 0x04, ///< Use local value.
- OPT_MODELINE = 0x08, ///< Option in modeline.
- OPT_WINONLY = 0x10, ///< Only set window-local options.
- OPT_NOWIN = 0x20, ///< Don’t set window-local options.
- OPT_ONECOLUMN = 0x40, ///< list options one per line
- OPT_NO_REDRAW = 0x80, ///< ignore redraw flags on option
- OPT_SKIPRTP = 0x100, ///< "skiprtp" in 'sessionoptions'
-} OptionFlags;
-
-// Return value from get_option_value_strict
-#define SOPT_BOOL 0x01 // Boolean option
-#define SOPT_NUM 0x02 // Number option
-#define SOPT_STRING 0x04 // String option
-#define SOPT_GLOBAL 0x08 // Option has global value
-#define SOPT_WIN 0x10 // Option has window-local value
-#define SOPT_BUF 0x20 // Option has buffer-local value
-#define SOPT_UNSET 0x40 // Option does not have local value set
-
-// Option types for various functions in option.c
-#define SREQ_GLOBAL 0 // Request global option value
-#define SREQ_WIN 1 // Request window-local option value
-#define SREQ_BUF 2 // Request buffer-local option value
-
-#define HIGHLIGHT_INIT \
- "8:SpecialKey,~:EndOfBuffer,z:TermCursor,Z:TermCursorNC,@:NonText,d:Directory,e:ErrorMsg," \
- "i:IncSearch,l:Search,y:CurSearch,m:MoreMsg,M:ModeMsg,n:LineNr,a:LineNrAbove,b:LineNrBelow," \
- "N:CursorLineNr,G:CursorLineSign,O:CursorLineFold" \
- "r:Question,s:StatusLine,S:StatusLineNC,c:VertSplit,t:Title,v:Visual,V:VisualNOS,w:WarningMsg," \
- "W:WildMenu,f:Folded,F:FoldColumn,A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText,>:SignColumn," \
- "-:Conceal,B:SpellBad,P:SpellCap,R:SpellRare,L:SpellLocal,+:Pmenu,=:PmenuSel," \
- "[:PmenuKind,]:PmenuKindSel,{:PmenuExtra,}:PmenuExtraSel,x:PmenuSbar,X:PmenuThumb," \
- "*:TabLine,#:TabLineSel,_:TabLineFill,!:CursorColumn,.:CursorLine,o:ColorColumn," \
- "q:QuickFixLine,0:Whitespace,I:NormalNC"
-
-// Default values for 'errorformat'.
-// The "%f|%l| %m" one is used for when the contents of the quickfix window is
-// written to a file.
-#ifdef MSWIN
-# define DFLT_EFM \
- "%f(%l) \\=: %t%*\\D%n: %m,%*[^\"]\"%f\"%*\\D%l: %m,%f(%l) \\=: %m,%*[^ ] %f %l: %m,%f:%l:%c:%m,%f(%l):%m,%f:%l:%m,%f|%l| %m"
-#else
-# define DFLT_EFM \
- "%*[^\"]\"%f\"%*\\D%l: %m,\"%f\"%*\\D%l: %m,%-Gg%\\?make[%*\\d]: *** [%f:%l:%m,%-Gg%\\?make: *** [%f:%l:%m,%-G%f:%l: (Each undeclared identifier is reported only once,%-G%f:%l: for each function it appears in.),%-GIn file included from %f:%l:%c:,%-GIn file included from %f:%l:%c\\,,%-GIn file included from %f:%l:%c,%-GIn file included from %f:%l,%-G%*[ ]from %f:%l:%c,%-G%*[ ]from %f:%l:,%-G%*[ ]from %f:%l\\,,%-G%*[ ]from %f:%l,%f:%l:%c:%m,%f(%l):%m,%f:%l:%m,\"%f\"\\, line %l%*\\D%c%*[^ ] %m,%D%*\\a[%*\\d]: Entering directory %*[`']%f',%X%*\\a[%*\\d]: Leaving directory %*[`']%f',%D%*\\a: Entering directory %*[`']%f',%X%*\\a: Leaving directory %*[`']%f',%DMaking %*\\a in %f,%f|%l| %m"
-#endif
-
-#define DFLT_GREPFORMAT "%f:%l:%m,%f:%l%m,%f %l%m"
-
-// default values for b_p_ff 'fileformat' and p_ffs 'fileformats'
-#define FF_DOS "dos"
-#define FF_MAC "mac"
-#define FF_UNIX "unix"
-
-#ifdef USE_CRNL
-# define DFLT_FF "dos"
-# define DFLT_FFS_VIM "dos,unix"
-# define DFLT_FFS_VI "dos,unix" // also autodetect in compatible mode
-#else
-# define DFLT_FF "unix"
-# define DFLT_FFS_VIM "unix,dos"
-# define DFLT_FFS_VI ""
-#endif
-
-// Possible values for 'encoding'
-#define ENC_UCSBOM "ucs-bom" // check for BOM at start of file
-
-// default value for 'encoding'
-#define ENC_DFLT "utf-8"
-
-// end-of-line style
-#define EOL_UNKNOWN (-1) // not defined yet
-#define EOL_UNIX 0 // NL
-#define EOL_DOS 1 // CR NL
-#define EOL_MAC 2 // CR
-
-// Formatting options for p_fo 'formatoptions'
-#define FO_WRAP 't'
-#define FO_WRAP_COMS 'c'
-#define FO_RET_COMS 'r'
-#define FO_OPEN_COMS 'o'
-#define FO_NO_OPEN_COMS '/'
-#define FO_Q_COMS 'q'
-#define FO_Q_NUMBER 'n'
-#define FO_Q_SECOND '2'
-#define FO_INS_VI 'v'
-#define FO_INS_LONG 'l'
-#define FO_INS_BLANK 'b'
-#define FO_MBYTE_BREAK 'm' // break before/after multi-byte char
-#define FO_MBYTE_JOIN 'M' // no space before/after multi-byte char
-#define FO_MBYTE_JOIN2 'B' // no space between multi-byte chars
-#define FO_ONE_LETTER '1'
-#define FO_WHITE_PAR 'w' // trailing white space continues paragr.
-#define FO_AUTO 'a' // automatic formatting
-#define FO_RIGOROUS_TW ']' // respect textwidth rigorously
-#define FO_REMOVE_COMS 'j' // remove comment leaders when joining lines
-#define FO_PERIOD_ABBR 'p' // don't break a single space after a period
-
-#define DFLT_FO_VI "vt"
-#define DFLT_FO_VIM "tcqj"
-#define FO_ALL "tcro/q2vlb1mMBn,aw]jp" // for do_set()
-
-// characters for the p_cpo option:
-#define CPO_ALTREAD 'a' // ":read" sets alternate file name
-#define CPO_ALTWRITE 'A' // ":write" sets alternate file name
-#define CPO_BAR 'b' // "\|" ends a mapping
-#define CPO_BSLASH 'B' // backslash in mapping is not special
-#define CPO_SEARCH 'c'
-#define CPO_CONCAT 'C' // Don't concatenate sourced lines
-#define CPO_DOTTAG 'd' // "./tags" in 'tags' is in current dir
-#define CPO_DIGRAPH 'D' // No digraph after "r", "f", etc.
-#define CPO_EXECBUF 'e'
-#define CPO_EMPTYREGION 'E' // operating on empty region is an error
-#define CPO_FNAMER 'f' // set file name for ":r file"
-#define CPO_FNAMEW 'F' // set file name for ":w file"
-#define CPO_INTMOD 'i' // interrupt a read makes buffer modified
-#define CPO_INDENT 'I' // remove auto-indent more often
-#define CPO_ENDOFSENT 'J' // need two spaces to detect end of sentence
-#define CPO_KOFFSET 'K' // don't wait for key code in mappings
-#define CPO_LITERAL 'l' // take char after backslash in [] literal
-#define CPO_LISTWM 'L' // 'list' changes wrapmargin
-#define CPO_SHOWMATCH 'm'
-#define CPO_MATCHBSL 'M' // "%" ignores use of backslashes
-#define CPO_NUMCOL 'n' // 'number' column also used for text
-#define CPO_LINEOFF 'o'
-#define CPO_OVERNEW 'O' // silently overwrite new file
-#define CPO_LISP 'p' // 'lisp' indenting
-#define CPO_FNAMEAPP 'P' // set file name for ":w >>file"
-#define CPO_JOINCOL 'q' // with "3J" use column after first join
-#define CPO_REDO 'r'
-#define CPO_REMMARK 'R' // remove marks when filtering
-#define CPO_BUFOPT 's'
-#define CPO_BUFOPTGLOB 'S'
-#define CPO_TAGPAT 't' // tag pattern is used for "n"
-#define CPO_UNDO 'u' // "u" undoes itself
-#define CPO_BACKSPACE 'v' // "v" keep deleted text
-#define CPO_FWRITE 'W' // "w!" doesn't overwrite readonly files
-#define CPO_ESC 'x'
-#define CPO_REPLCNT 'X' // "R" with a count only deletes chars once
-#define CPO_YANK 'y'
-#define CPO_KEEPRO 'Z' // don't reset 'readonly' on ":w!"
-#define CPO_DOLLAR '$'
-#define CPO_FILTER '!'
-#define CPO_MATCH '%'
-#define CPO_PLUS '+' // ":write file" resets 'modified'
-#define CPO_REGAPPEND '>' // insert NL when appending to a register
-#define CPO_SCOLON ';' // using "," and ";" will skip over char if
- // cursor would not move
-#define CPO_CHANGEW '_' // "cw" special-case
-// default values for Vim and Vi
-#define CPO_VIM "aABceFs_"
-#define CPO_VI "aAbBcCdDeEfFiIJKlLmMnoOpPqrRsStuvWxXyZ$!%+>;_"
-
-// characters for p_ww option:
-#define WW_ALL "bshl<>[],~"
-
-// characters for p_mouse option:
-#define MOUSE_NORMAL 'n' // use mouse in Normal mode
-#define MOUSE_VISUAL 'v' // use mouse in Visual/Select mode
-#define MOUSE_INSERT 'i' // use mouse in Insert mode
-#define MOUSE_COMMAND 'c' // use mouse in Command-line mode
-#define MOUSE_HELP 'h' // use mouse in help buffers
-#define MOUSE_RETURN 'r' // use mouse for hit-return message
-#define MOUSE_A "nvich" // used for 'a' flag
-#define MOUSE_ALL "anvichr" // all possible characters
-#define MOUSE_NONE ' ' // don't use Visual selection
-#define MOUSE_NONEF 'x' // forced modeless selection
-
-// default vertical and horizontal mouse scroll values.
-// Note: This should be in sync with the default mousescroll option.
-#define MOUSESCROLL_VERT_DFLT 3
-#define MOUSESCROLL_HOR_DFLT 6
-
-#define COCU_ALL "nvic" // flags for 'concealcursor'
-
-/// characters for p_shm option:
-enum {
- SHM_RO = 'r', ///< Readonly.
- SHM_MOD = 'm', ///< Modified.
- SHM_LINES = 'l', ///< "L" instead of "lines".
- SHM_WRI = 'w', ///< "[w]" instead of "written".
- SHM_ABBREVIATIONS = 'a', ///< Use abbreviations from #SHM_ALL_ABBREVIATIONS.
- SHM_WRITE = 'W', ///< Don't use "written" at all.
- SHM_TRUNC = 't', ///< Truncate file messages.
- SHM_TRUNCALL = 'T', ///< Truncate all messages.
- SHM_OVER = 'o', ///< Overwrite file messages.
- SHM_OVERALL = 'O', ///< Overwrite more messages.
- SHM_SEARCH = 's', ///< No search hit bottom messages.
- SHM_ATTENTION = 'A', ///< No ATTENTION messages.
- SHM_INTRO = 'I', ///< Intro messages.
- SHM_COMPLETIONMENU = 'c', ///< Completion menu messages.
- SHM_COMPLETIONSCAN = 'C', ///< Completion scanning messages.
- SHM_RECORDING = 'q', ///< Short recording message.
- SHM_FILEINFO = 'F', ///< No file info messages.
- SHM_SEARCHCOUNT = 'S', ///< No search stats: '[1/10]'
-};
-/// Represented by 'a' flag.
-#define SHM_ALL_ABBREVIATIONS ((char[]) { \
- SHM_RO, SHM_MOD, SHM_LINES, SHM_WRI, \
- 0 })
-
-// characters for p_go:
-#define GO_ASEL 'a' // autoselect
-#define GO_ASELML 'A' // autoselect modeless selection
-#define GO_BOT 'b' // use bottom scrollbar
-#define GO_CONDIALOG 'c' // use console dialog
-#define GO_DARKTHEME 'd' // use dark theme variant
-#define GO_TABLINE 'e' // may show tabline
-#define GO_FORG 'f' // start GUI in foreground
-#define GO_GREY 'g' // use grey menu items
-#define GO_HORSCROLL 'h' // flexible horizontal scrolling
-#define GO_ICON 'i' // use Vim icon
-#define GO_LEFT 'l' // use left scrollbar
-#define GO_VLEFT 'L' // left scrollbar with vert split
-#define GO_MENUS 'm' // use menu bar
-#define GO_NOSYSMENU 'M' // don't source system menu
-#define GO_POINTER 'p' // pointer enter/leave callbacks
-#define GO_ASELPLUS 'P' // autoselectPlus
-#define GO_RIGHT 'r' // use right scrollbar
-#define GO_VRIGHT 'R' // right scrollbar with vert split
-#define GO_TOOLBAR 'T' // add toolbar
-#define GO_FOOTER 'F' // add footer
-#define GO_VERTICAL 'v' // arrange dialog buttons vertically
-#define GO_KEEPWINSIZE 'k' // keep GUI window size
-#define GO_ALL "!aAbcdefFghilLmMpPrRtTvk" // all possible flags for 'go'
-
-// flags for 'comments' option
-#define COM_NEST 'n' // comments strings nest
-#define COM_BLANK 'b' // needs blank after string
-#define COM_START 's' // start of comment
-#define COM_MIDDLE 'm' // middle of comment
-#define COM_END 'e' // end of comment
-#define COM_AUTO_END 'x' // last char of end closes comment
-#define COM_FIRST 'f' // first line comment only
-#define COM_LEFT 'l' // left adjusted
-#define COM_RIGHT 'r' // right adjusted
-#define COM_NOBACK 'O' // don't use for "O" command
-#define COM_ALL "nbsmexflrO" // all flags for 'comments' option
-#define COM_MAX_LEN 50 // maximum length of a part
-
-/// 'statusline' option flags
-enum {
- STL_FILEPATH = 'f', ///< Path of file in buffer.
- STL_FULLPATH = 'F', ///< Full path of file in buffer.
- STL_FILENAME = 't', ///< Last part (tail) of file path.
- STL_COLUMN = 'c', ///< Column og cursor.
- STL_VIRTCOL = 'v', ///< Virtual column.
- STL_VIRTCOL_ALT = 'V', ///< - with 'if different' display.
- STL_LINE = 'l', ///< Line number of cursor.
- STL_NUMLINES = 'L', ///< Number of lines in buffer.
- STL_BUFNO = 'n', ///< Current buffer number.
- STL_KEYMAP = 'k', ///< 'keymap' when active.
- STL_OFFSET = 'o', ///< Offset of character under cursor.
- STL_OFFSET_X = 'O', ///< - in hexadecimal.
- STL_BYTEVAL = 'b', ///< Byte value of character.
- STL_BYTEVAL_X = 'B', ///< - in hexadecimal.
- STL_ROFLAG = 'r', ///< Readonly flag.
- STL_ROFLAG_ALT = 'R', ///< - other display.
- STL_HELPFLAG = 'h', ///< Window is showing a help file.
- STL_HELPFLAG_ALT = 'H', ///< - other display.
- STL_FILETYPE = 'y', ///< 'filetype'.
- STL_FILETYPE_ALT = 'Y', ///< - other display.
- STL_PREVIEWFLAG = 'w', ///< Window is showing the preview buf.
- STL_PREVIEWFLAG_ALT = 'W', ///< - other display.
- STL_MODIFIED = 'm', ///< Modified flag.
- STL_MODIFIED_ALT = 'M', ///< - other display.
- STL_QUICKFIX = 'q', ///< Quickfix window description.
- STL_PERCENTAGE = 'p', ///< Percentage through file.
- STL_ALTPERCENT = 'P', ///< Percentage as TOP BOT ALL or NN%.
- STL_ARGLISTSTAT = 'a', ///< Argument list status as (x of y).
- STL_PAGENUM = 'N', ///< Page number (when printing).
- STL_SHOWCMD = 'S', ///< 'showcmd' buffer
- STL_FOLDCOL = 'C', ///< Fold column for 'statuscolumn'
- STL_SIGNCOL = 's', ///< Sign column for 'statuscolumn'
- STL_VIM_EXPR = '{', ///< Start of expression to substitute.
- STL_SEPARATE = '=', ///< Separation between alignment sections.
- STL_TRUNCMARK = '<', ///< Truncation mark if line is too long.
- STL_USER_HL = '*', ///< Highlight from (User)1..9 or 0.
- STL_HIGHLIGHT = '#', ///< Highlight name.
- STL_TABPAGENR = 'T', ///< Tab page label nr.
- STL_TABCLOSENR = 'X', ///< Tab page close nr.
- STL_CLICK_FUNC = '@', ///< Click region start.
-};
-/// C string containing all 'statusline' option flags
-#define STL_ALL ((char[]) { \
- STL_FILEPATH, STL_FULLPATH, STL_FILENAME, STL_COLUMN, STL_VIRTCOL, \
- STL_VIRTCOL_ALT, STL_LINE, STL_NUMLINES, STL_BUFNO, STL_KEYMAP, STL_OFFSET, \
- STL_OFFSET_X, STL_BYTEVAL, STL_BYTEVAL_X, STL_ROFLAG, STL_ROFLAG_ALT, \
- STL_HELPFLAG, STL_HELPFLAG_ALT, STL_FILETYPE, STL_FILETYPE_ALT, \
- STL_PREVIEWFLAG, STL_PREVIEWFLAG_ALT, STL_MODIFIED, STL_MODIFIED_ALT, \
- STL_QUICKFIX, STL_PERCENTAGE, STL_ALTPERCENT, STL_ARGLISTSTAT, STL_PAGENUM, \
- STL_SHOWCMD, STL_FOLDCOL, STL_SIGNCOL, STL_VIM_EXPR, STL_SEPARATE, \
- STL_TRUNCMARK, STL_USER_HL, STL_HIGHLIGHT, STL_TABPAGENR, STL_TABCLOSENR, \
- STL_CLICK_FUNC, STL_TABPAGENR, STL_TABCLOSENR, STL_CLICK_FUNC, \
- 0, })
-
-// flags used for parsed 'wildmode'
-#define WIM_FULL 0x01
-#define WIM_LONGEST 0x02
-#define WIM_LIST 0x04
-#define WIM_BUFLASTUSED 0x08
-
-// arguments for can_bs()
-// each defined char should be unique over all values
-// except for BS_START, that intentionally also matches BS_NOSTOP
-// because BS_NOSTOP behaves exactly the same except it
-// does not stop at the start of the insert point
-#define BS_INDENT 'i' // "Indent"
-#define BS_EOL 'l' // "eoL"
-#define BS_START 's' // "Start"
-#define BS_NOSTOP 'p' // "nostoP
-
-// flags for the 'culopt' option
-#define CULOPT_LINE 0x01 // Highlight complete line
-#define CULOPT_SCRLINE 0x02 // Highlight screen line
-#define CULOPT_NBR 0x04 // Highlight Number column
-
-#define LISPWORD_VALUE \
- "defun,define,defmacro,set!,lambda,if,case,let,flet,let*,letrec,do,do*,define-syntax,let-syntax,letrec-syntax,destructuring-bind,defpackage,defparameter,defstruct,deftype,defvar,do-all-symbols,do-external-symbols,do-symbols,dolist,dotimes,ecase,etypecase,eval-when,labels,macrolet,multiple-value-bind,multiple-value-call,multiple-value-prog1,multiple-value-setq,prog1,progv,typecase,unless,unwind-protect,when,with-input-from-string,with-open-file,with-open-stream,with-output-to-string,with-package-iterator,define-condition,handler-bind,handler-case,restart-bind,restart-case,with-simple-restart,store-value,use-value,muffle-warning,abort,continue,with-slots,with-slots*,with-accessors,with-accessors*,defclass,defmethod,print-unreadable-object"
-
-// The following are actual variables for the options
-
-EXTERN char *p_ambw; ///< 'ambiwidth'
-EXTERN int p_acd; ///< 'autochdir'
-EXTERN int p_ai; ///< 'autoindent'
-EXTERN int p_bin; ///< 'binary'
-EXTERN int p_bomb; ///< 'bomb'
-EXTERN int p_bl; ///< 'buflisted'
-EXTERN int p_cin; ///< 'cindent'
-EXTERN OptInt p_channel; ///< 'channel'
-EXTERN char *p_cink; ///< 'cinkeys'
-EXTERN char *p_cinsd; ///< 'cinscopedecls'
-EXTERN char *p_cinw; ///< 'cinwords'
-EXTERN char *p_cfu; ///< 'completefunc'
-EXTERN char *p_ofu; ///< 'omnifunc'
-EXTERN char *p_tsrfu; ///< 'thesaurusfunc'
-EXTERN int p_ci; ///< 'copyindent'
-EXTERN int p_ar; // 'autoread'
-EXTERN int p_aw; // 'autowrite'
-EXTERN int p_awa; // 'autowriteall'
-EXTERN char *p_bs; // 'backspace'
-EXTERN char *p_bg; // 'background'
-EXTERN int p_bk; // 'backup'
-EXTERN char *p_bkc; // 'backupcopy'
-EXTERN unsigned bkc_flags; ///< flags from 'backupcopy'
-#define BKC_YES 0x001
-#define BKC_AUTO 0x002
-#define BKC_NO 0x004
-#define BKC_BREAKSYMLINK 0x008
-#define BKC_BREAKHARDLINK 0x010
-EXTERN char *p_bdir; // 'backupdir'
-EXTERN char *p_bex; // 'backupext'
-EXTERN char *p_bo; // 'belloff'
-EXTERN char breakat_flags[256]; // which characters are in 'breakat'
-EXTERN unsigned bo_flags;
-
-// values for the 'belloff' option
-#define BO_ALL 0x0001
-#define BO_BS 0x0002
-#define BO_CRSR 0x0004
-#define BO_COMPL 0x0008
-#define BO_COPY 0x0010
-#define BO_CTRLG 0x0020
-#define BO_ERROR 0x0040
-#define BO_ESC 0x0080
-#define BO_EX 0x0100
-#define BO_HANGUL 0x0200
-#define BO_IM 0x0400
-#define BO_LANG 0x0800
-#define BO_MESS 0x1000
-#define BO_MATCH 0x2000
-#define BO_OPER 0x4000
-#define BO_REG 0x8000
-#define BO_SH 0x10000
-#define BO_SPELL 0x20000
-#define BO_WILD 0x40000
-
-EXTERN char *p_bsk; // 'backupskip'
-EXTERN char *p_breakat; // 'breakat'
-EXTERN char *p_bh; ///< 'bufhidden'
-EXTERN char *p_bt; ///< 'buftype'
-EXTERN char *p_cmp; // 'casemap'
-EXTERN unsigned cmp_flags;
-#define CMP_INTERNAL 0x001
-#define CMP_KEEPASCII 0x002
-EXTERN char *p_enc; // 'encoding'
-EXTERN int p_deco; // 'delcombine'
-EXTERN char *p_ccv; // 'charconvert'
-EXTERN char *p_cino; ///< 'cinoptions'
-EXTERN char *p_cedit; // 'cedit'
-EXTERN char *p_cb; // 'clipboard'
-EXTERN unsigned cb_flags;
-#define CB_UNNAMED 0x001
-#define CB_UNNAMEDPLUS 0x002
-#define CB_UNNAMEDMASK (CB_UNNAMED | CB_UNNAMEDPLUS)
-EXTERN OptInt p_cwh; // 'cmdwinheight'
-EXTERN OptInt p_ch; // 'cmdheight'
-EXTERN char *p_cms; ///< 'commentstring'
-EXTERN char *p_cpt; ///< 'complete'
-EXTERN OptInt p_columns; // 'columns'
-EXTERN int p_confirm; // 'confirm'
-EXTERN char *p_cot; // 'completeopt'
-#ifdef BACKSLASH_IN_FILENAME
-EXTERN char *p_csl; // 'completeslash'
-#endif
-EXTERN OptInt p_pb; // 'pumblend'
-EXTERN OptInt p_ph; // 'pumheight'
-EXTERN OptInt p_pw; // 'pumwidth'
-EXTERN char *p_com; ///< 'comments'
-EXTERN char *p_cpo; // 'cpoptions'
-EXTERN char *p_debug; // 'debug'
-EXTERN char *p_def; // 'define'
-EXTERN char *p_inc;
-EXTERN char *p_dip; // 'diffopt'
-EXTERN char *p_dex; // 'diffexpr'
-EXTERN char *p_dict; // 'dictionary'
-EXTERN int p_dg; // 'digraph'
-EXTERN char *p_dir; // 'directory'
-EXTERN char *p_dy; // 'display'
-EXTERN unsigned dy_flags;
-#define DY_LASTLINE 0x001
-#define DY_TRUNCATE 0x002
-#define DY_UHEX 0x004
-// legacy flag, not used
-#define DY_MSGSEP 0x008
-EXTERN int p_ed; // 'edcompatible'
-EXTERN char *p_ead; // 'eadirection'
-EXTERN int p_emoji; // 'emoji'
-EXTERN int p_ea; // 'equalalways'
-EXTERN char *p_ep; // 'equalprg'
-EXTERN int p_eb; // 'errorbells'
-EXTERN char *p_ef; // 'errorfile'
-EXTERN char *p_efm; // 'errorformat'
-EXTERN char *p_gefm; // 'grepformat'
-EXTERN char *p_gp; // 'grepprg'
-EXTERN int p_eof; ///< 'endoffile'
-EXTERN int p_eol; ///< 'endofline'
-EXTERN char *p_ei; // 'eventignore'
-EXTERN int p_et; ///< 'expandtab'
-EXTERN int p_exrc; // 'exrc'
-EXTERN char *p_fenc; ///< 'fileencoding'
-EXTERN char *p_fencs; // 'fileencodings'
-EXTERN char *p_ff; ///< 'fileformat'
-EXTERN char *p_ffs; // 'fileformats'
-EXTERN int p_fic; // 'fileignorecase'
-EXTERN char *p_ft; ///< 'filetype'
-EXTERN char *p_fcs; ///< 'fillchar'
-EXTERN int p_fixeol; ///< 'fixendofline'
-EXTERN char *p_fcl; // 'foldclose'
-EXTERN OptInt p_fdls; // 'foldlevelstart'
-EXTERN char *p_fdo; // 'foldopen'
-EXTERN unsigned fdo_flags;
-#define FDO_ALL 0x001
-#define FDO_BLOCK 0x002
-#define FDO_HOR 0x004
-#define FDO_MARK 0x008
-#define FDO_PERCENT 0x010
-#define FDO_QUICKFIX 0x020
-#define FDO_SEARCH 0x040
-#define FDO_TAG 0x080
-#define FDO_INSERT 0x100
-#define FDO_UNDO 0x200
-#define FDO_JUMP 0x400
-EXTERN char *p_fex; ///< 'formatexpr'
-EXTERN char *p_flp; ///< 'formatlistpat'
-EXTERN char *p_fo; ///< 'formatoptions'
-EXTERN char *p_fp; // 'formatprg'
-EXTERN int p_fs; // 'fsync'
-EXTERN int p_gd; // 'gdefault'
-EXTERN char *p_guicursor; // 'guicursor'
-EXTERN char *p_guifont; // 'guifont'
-EXTERN char *p_guifontwide; // 'guifontwide'
-EXTERN char *p_hf; // 'helpfile'
-EXTERN OptInt p_hh; // 'helpheight'
-EXTERN char *p_hlg; // 'helplang'
-EXTERN int p_hid; // 'hidden'
-EXTERN char *p_hl; // 'highlight'
-EXTERN int p_hls; // 'hlsearch'
-EXTERN OptInt p_hi; // 'history'
-EXTERN int p_arshape; // 'arabicshape'
-EXTERN int p_icon; // 'icon'
-EXTERN char *p_iconstring; // 'iconstring'
-EXTERN int p_ic; // 'ignorecase'
-EXTERN OptInt p_iminsert; ///< 'iminsert'
-EXTERN OptInt p_imsearch; ///< 'imsearch'
-EXTERN int p_inf; ///< 'infercase'
-EXTERN char *p_inex; ///< 'includeexpr'
-EXTERN int p_is; // 'incsearch'
-EXTERN char *p_inde; ///< 'indentexpr'
-EXTERN char *p_indk; ///< 'indentkeys'
-EXTERN char *p_icm; // 'inccommand'
-EXTERN char *p_isf; // 'isfname'
-EXTERN char *p_isi; // 'isident'
-EXTERN char *p_isk; ///< 'iskeyword'
-EXTERN char *p_isp; // 'isprint'
-EXTERN int p_js; // 'joinspaces'
-EXTERN char *p_jop; // 'jumpooptions'
-EXTERN unsigned jop_flags;
-#define JOP_STACK 0x01
-#define JOP_VIEW 0x02
-EXTERN char *p_keymap; ///< 'keymap'
-EXTERN char *p_kp; // 'keywordprg'
-EXTERN char *p_km; // 'keymodel'
-EXTERN char *p_langmap; // 'langmap'
-EXTERN int p_lnr; // 'langnoremap'
-EXTERN int p_lrm; // 'langremap'
-EXTERN char *p_lm; // 'langmenu'
-EXTERN OptInt p_lines; // 'lines'
-EXTERN OptInt p_linespace; // 'linespace'
-EXTERN int p_lisp; ///< 'lisp'
-EXTERN char *p_lop; ///< 'lispoptions'
-EXTERN char *p_lispwords; // 'lispwords'
-EXTERN OptInt p_ls; // 'laststatus'
-EXTERN OptInt p_stal; // 'showtabline'
-EXTERN char *p_lcs; // 'listchars'
-
-EXTERN int p_lz; // 'lazyredraw'
-EXTERN int p_lpl; // 'loadplugins'
-EXTERN int p_magic; // 'magic'
-EXTERN char *p_menc; // 'makeencoding'
-EXTERN char *p_mef; // 'makeef'
-EXTERN char *p_mp; // 'makeprg'
-EXTERN char *p_mps; ///< 'matchpairs'
-EXTERN OptInt p_mat; // 'matchtime'
-EXTERN OptInt p_mco; // 'maxcombine'
-EXTERN OptInt p_mfd; // 'maxfuncdepth'
-EXTERN OptInt p_mmd; // 'maxmapdepth'
-EXTERN OptInt p_mmp; // 'maxmempattern'
-EXTERN OptInt p_mis; // 'menuitems'
-EXTERN char *p_msm; // 'mkspellmem'
-EXTERN int p_ml; ///< 'modeline'
-EXTERN int p_mle; // 'modelineexpr'
-EXTERN OptInt p_mls; // 'modelines'
-EXTERN int p_ma; ///< 'modifiable'
-EXTERN int p_mod; ///< 'modified'
-EXTERN char *p_mouse; // 'mouse'
-EXTERN char *p_mousem; // 'mousemodel'
-EXTERN int p_mousemev; ///< 'mousemoveevent'
-EXTERN int p_mousef; // 'mousefocus'
-EXTERN char *p_mousescroll; // 'mousescroll'
-EXTERN OptInt p_mousescroll_vert INIT(= MOUSESCROLL_VERT_DFLT);
-EXTERN OptInt p_mousescroll_hor INIT(= MOUSESCROLL_HOR_DFLT);
-EXTERN OptInt p_mouset; // 'mousetime'
-EXTERN int p_more; // 'more'
-EXTERN char *p_nf; ///< 'nrformats'
-EXTERN char *p_opfunc; // 'operatorfunc'
-EXTERN char *p_para; // 'paragraphs'
-EXTERN int p_paste; // 'paste'
-EXTERN char *p_pex; // 'patchexpr'
-EXTERN char *p_pm; // 'patchmode'
-EXTERN char *p_path; // 'path'
-EXTERN char *p_cdpath; // 'cdpath'
-EXTERN int p_pi; ///< 'preserveindent'
-EXTERN OptInt p_pyx; // 'pyxversion'
-EXTERN char *p_qe; ///< 'quoteescape'
-EXTERN int p_ro; ///< 'readonly'
-EXTERN char *p_rdb; // 'redrawdebug'
-EXTERN unsigned rdb_flags;
-#define RDB_COMPOSITOR 0x001
-#define RDB_NOTHROTTLE 0x002
-#define RDB_INVALID 0x004
-#define RDB_NODELTA 0x008
-#define RDB_LINE 0x010
-#define RDB_FLUSH 0x020
-#define RDB_INTERSECT 0x040
-
-EXTERN OptInt p_rdt; // 'redrawtime'
-EXTERN OptInt p_re; // 'regexpengine'
-EXTERN OptInt p_report; // 'report'
-EXTERN OptInt p_pvh; // 'previewheight'
-EXTERN int p_ari; // 'allowrevins'
-EXTERN int p_ri; // 'revins'
-EXTERN int p_ru; // 'ruler'
-EXTERN char *p_ruf; // 'rulerformat'
-EXTERN char *p_pp; // 'packpath'
-EXTERN char *p_qftf; // 'quickfixtextfunc'
-EXTERN char *p_rtp; // 'runtimepath'
-EXTERN OptInt p_scbk; // 'scrollback'
-EXTERN OptInt p_sj; // 'scrolljump'
-EXTERN OptInt p_so; // 'scrolloff'
-EXTERN char *p_sbo; // 'scrollopt'
-EXTERN char *p_sections; // 'sections'
-EXTERN int p_secure; // 'secure'
-EXTERN char *p_sel; // 'selection'
-EXTERN char *p_slm; // 'selectmode'
-EXTERN char *p_ssop; // 'sessionoptions'
-EXTERN unsigned ssop_flags;
-
-#define SSOP_BUFFERS 0x001
-#define SSOP_WINPOS 0x002
-#define SSOP_RESIZE 0x004
-#define SSOP_WINSIZE 0x008
-#define SSOP_LOCALOPTIONS 0x010
-#define SSOP_OPTIONS 0x020
-#define SSOP_HELP 0x040
-#define SSOP_BLANK 0x080
-#define SSOP_GLOBALS 0x100
-#define SSOP_SLASH 0x200 // Deprecated, always set.
-#define SSOP_UNIX 0x400 // Deprecated, always set.
-#define SSOP_SESDIR 0x800
-#define SSOP_CURDIR 0x1000
-#define SSOP_FOLDS 0x2000
-#define SSOP_CURSOR 0x4000
-#define SSOP_TABPAGES 0x8000
-#define SSOP_TERMINAL 0x10000
-#define SSOP_SKIP_RTP 0x20000
-
-EXTERN char *p_sh; // 'shell'
-EXTERN char *p_shcf; // 'shellcmdflag'
-EXTERN char *p_sp; // 'shellpipe'
-EXTERN char *p_shq; // 'shellquote'
-EXTERN char *p_sxq; // 'shellxquote'
-EXTERN char *p_sxe; // 'shellxescape'
-EXTERN char *p_srr; // 'shellredir'
-EXTERN int p_stmp; // 'shelltemp'
-#ifdef BACKSLASH_IN_FILENAME
-EXTERN int p_ssl; // 'shellslash'
-#endif
-EXTERN char *p_stl; // 'statusline'
-EXTERN char *p_wbr; // 'winbar'
-EXTERN int p_sr; // 'shiftround'
-EXTERN OptInt p_sw; ///< 'shiftwidth'
-EXTERN char *p_shm; // 'shortmess'
-EXTERN char *p_sbr; // 'showbreak'
-EXTERN int p_sc; // 'showcmd'
-EXTERN char *p_sloc; // 'showcmdloc'
-EXTERN int p_sft; // 'showfulltag'
-EXTERN int p_sm; // 'showmatch'
-EXTERN int p_smd; // 'showmode'
-EXTERN OptInt p_ss; // 'sidescroll'
-EXTERN OptInt p_siso; // 'sidescrolloff'
-EXTERN int p_scs; // 'smartcase'
-EXTERN int p_si; ///< 'smartindent'
-EXTERN int p_sta; // 'smarttab'
-EXTERN OptInt p_sts; ///< 'softtabstop'
-EXTERN int p_sb; // 'splitbelow'
-EXTERN char *p_sua; ///< 'suffixesadd'
-EXTERN int p_swf; ///< 'swapfile'
-EXTERN OptInt p_smc; ///< 'synmaxcol'
-EXTERN OptInt p_tpm; // 'tabpagemax'
-EXTERN char *p_tal; // 'tabline'
-EXTERN char *p_tpf; // 'termpastefilter'
-EXTERN unsigned tpf_flags; ///< flags from 'termpastefilter'
-#define TPF_BS 0x001
-#define TPF_HT 0x002
-#define TPF_FF 0x004
-#define TPF_ESC 0x008
-#define TPF_DEL 0x010
-#define TPF_C0 0x020
-#define TPF_C1 0x040
-EXTERN char *p_tfu; ///< 'tagfunc'
-EXTERN char *p_spc; ///< 'spellcapcheck'
-EXTERN char *p_spf; ///< 'spellfile'
-EXTERN char *p_spk; ///< 'splitkeep'
-EXTERN char *p_spl; ///< 'spelllang'
-EXTERN char *p_spo; // 'spelloptions'
-EXTERN unsigned spo_flags;
-EXTERN char *p_sps; // 'spellsuggest'
-EXTERN int p_spr; // 'splitright'
-EXTERN int p_sol; // 'startofline'
-EXTERN char *p_su; // 'suffixes'
-EXTERN char *p_swb; // 'switchbuf'
-EXTERN unsigned swb_flags;
-// Keep in sync with p_swb_values in optionstr.c
-#define SWB_USEOPEN 0x001
-#define SWB_USETAB 0x002
-#define SWB_SPLIT 0x004
-#define SWB_NEWTAB 0x008
-#define SWB_VSPLIT 0x010
-#define SWB_USELAST 0x020
-EXTERN char *p_syn; ///< 'syntax'
-EXTERN OptInt p_ts; ///< 'tabstop'
-EXTERN int p_tbs; ///< 'tagbsearch'
-EXTERN char *p_tc; ///< 'tagcase'
-EXTERN unsigned tc_flags; ///< flags from 'tagcase'
-#define TC_FOLLOWIC 0x01
-#define TC_IGNORE 0x02
-#define TC_MATCH 0x04
-#define TC_FOLLOWSCS 0x08
-#define TC_SMART 0x10
-EXTERN OptInt p_tl; ///< 'taglength'
-EXTERN int p_tr; ///< 'tagrelative'
-EXTERN char *p_tags; ///< 'tags'
-EXTERN int p_tgst; ///< 'tagstack'
-EXTERN int p_tbidi; ///< 'termbidi'
-EXTERN OptInt p_tw; ///< 'textwidth'
-EXTERN int p_to; ///< 'tildeop'
-EXTERN int p_timeout; ///< 'timeout'
-EXTERN OptInt p_tm; ///< 'timeoutlen'
-EXTERN int p_title; ///< 'title'
-EXTERN OptInt p_titlelen; ///< 'titlelen'
-EXTERN char *p_titleold; ///< 'titleold'
-EXTERN char *p_titlestring; ///< 'titlestring'
-EXTERN char *p_tsr; ///< 'thesaurus'
-EXTERN int p_tgc; ///< 'termguicolors'
-EXTERN int p_ttimeout; ///< 'ttimeout'
-EXTERN OptInt p_ttm; ///< 'ttimeoutlen'
-EXTERN char *p_udir; ///< 'undodir'
-EXTERN int p_udf; ///< 'undofile'
-EXTERN OptInt p_ul; ///< 'undolevels'
-EXTERN OptInt p_ur; ///< 'undoreload'
-EXTERN OptInt p_uc; ///< 'updatecount'
-EXTERN OptInt p_ut; ///< 'updatetime'
-EXTERN char *p_shada; ///< 'shada'
-EXTERN char *p_shadafile; ///< 'shadafile'
-EXTERN char *p_vsts; ///< 'varsofttabstop'
-EXTERN char *p_vts; ///< 'vartabstop'
-EXTERN char *p_vdir; ///< 'viewdir'
-EXTERN char *p_vop; ///< 'viewoptions'
-EXTERN unsigned vop_flags; ///< uses SSOP_ flags
-EXTERN int p_vb; ///< 'visualbell'
-EXTERN char *p_ve; ///< 'virtualedit'
-EXTERN unsigned ve_flags;
-#define VE_BLOCK 5U // includes "all"
-#define VE_INSERT 6U // includes "all"
-#define VE_ALL 4U
-#define VE_ONEMORE 8U
-#define VE_NONE 16U // "none"
-#define VE_NONEU 32U // "NONE"
-EXTERN OptInt p_verbose; // 'verbose'
-#ifdef IN_OPTION_C
-char *p_vfile = ""; // used before options are initialized
-#else
-extern char *p_vfile; // 'verbosefile'
-#endif
-EXTERN int p_warn; // 'warn'
-EXTERN char *p_wop; // 'wildoptions'
-EXTERN unsigned wop_flags;
-#define WOP_TAGFILE 0x01
-#define WOP_PUM 0x02
-#define WOP_FUZZY 0x04
-EXTERN OptInt p_window; // 'window'
-EXTERN char *p_wak; // 'winaltkeys'
-EXTERN char *p_wig; // 'wildignore'
-EXTERN char *p_ww; // 'whichwrap'
-EXTERN OptInt p_wc; // 'wildchar'
-EXTERN OptInt p_wcm; // 'wildcharm'
-EXTERN int p_wic; // 'wildignorecase'
-EXTERN char *p_wim; // 'wildmode'
-EXTERN int p_wmnu; // 'wildmenu'
-EXTERN OptInt p_wh; // 'winheight'
-EXTERN OptInt p_wmh; // 'winminheight'
-EXTERN OptInt p_wmw; // 'winminwidth'
-EXTERN OptInt p_wiw; // 'winwidth'
-EXTERN OptInt p_wm; ///< 'wrapmargin'
-EXTERN int p_ws; // 'wrapscan'
-EXTERN int p_write; // 'write'
-EXTERN int p_wa; // 'writeany'
-EXTERN int p_wb; // 'writebackup'
-EXTERN OptInt p_wd; // 'writedelay'
-EXTERN int p_cdh; // 'cdhome'
-
-EXTERN int p_force_on; ///< options that cannot be turned off.
-EXTERN int p_force_off; ///< options that cannot be turned on.
-
-//
-// "indir" values for buffer-local options.
-// These need to be defined globally, so that the BV_COUNT can be used with
-// b_p_scriptID[].
-//
-enum {
- BV_AI = 0,
- BV_AR,
- BV_BH,
- BV_BKC,
- BV_BT,
- BV_EFM,
- BV_GP,
- BV_MP,
- BV_BIN,
- BV_BL,
- BV_BOMB,
- BV_CHANNEL,
- BV_CI,
- BV_CIN,
- BV_CINK,
- BV_CINO,
- BV_CINW,
- BV_CINSD,
- BV_CM,
- BV_CMS,
- BV_COM,
- BV_CPT,
- BV_DICT,
- BV_TSR,
- BV_CSL,
- BV_CFU,
- BV_DEF,
- BV_INC,
- BV_EOF,
- BV_EOL,
- BV_FIXEOL,
- BV_EP,
- BV_ET,
- BV_FENC,
- BV_FP,
- BV_BEXPR,
- BV_FEX,
- BV_FF,
- BV_FLP,
- BV_FO,
- BV_FT,
- BV_IMI,
- BV_IMS,
- BV_INDE,
- BV_INDK,
- BV_INEX,
- BV_INF,
- BV_ISK,
- BV_KMAP,
- BV_KP,
- BV_LISP,
- BV_LOP,
- BV_LW,
- BV_MENC,
- BV_MA,
- BV_ML,
- BV_MOD,
- BV_MPS,
- BV_NF,
- BV_OFU,
- BV_PATH,
- BV_PI,
- BV_QE,
- BV_RO,
- BV_SCBK,
- BV_SI,
- BV_SMC,
- BV_SYN,
- BV_SPC,
- BV_SPF,
- BV_SPL,
- BV_SPO,
- BV_STS,
- BV_SUA,
- BV_SW,
- BV_SWF,
- BV_TFU,
- BV_TSRFU,
- BV_TAGS,
- BV_TC,
- BV_TS,
- BV_TW,
- BV_TX,
- BV_UDF,
- BV_UL,
- BV_WM,
- BV_VSTS,
- BV_VTS,
- BV_COUNT, // must be the last one
-};
-
-// "indir" values for window-local options.
-// These need to be defined globally, so that the WV_COUNT can be used in the
-// window structure.
-enum {
- WV_LIST = 0,
- WV_ARAB,
- WV_COCU,
- WV_COLE,
- WV_CRBIND,
- WV_BRI,
- WV_BRIOPT,
- WV_DIFF,
- WV_FDC,
- WV_FEN,
- WV_FDI,
- WV_FDL,
- WV_FDM,
- WV_FML,
- WV_FDN,
- WV_FDE,
- WV_FDT,
- WV_FMR,
- WV_LBR,
- WV_NU,
- WV_RNU,
- WV_VE,
- WV_NUW,
- WV_PVW,
- WV_RL,
- WV_RLC,
- WV_SCBIND,
- WV_SCROLL,
- WV_SMS,
- WV_SISO,
- WV_SO,
- WV_SPELL,
- WV_CUC,
- WV_CUL,
- WV_CULOPT,
- WV_CC,
- WV_SBR,
- WV_STC,
- WV_STL,
- WV_WFH,
- WV_WFW,
- WV_WRAP,
- WV_SCL,
- WV_WINHL,
- WV_LCS,
- WV_FCS,
- WV_WINBL,
- WV_WBR,
- WV_COUNT, // must be the last one
-};
-
-// Value for b_p_ul indicating the global value must be used.
-#define NO_LOCAL_UNDOLEVEL (-123456)
+ kOptValTypeNil = 0,
+ kOptValTypeBoolean,
+ kOptValTypeNumber,
+ kOptValTypeString,
+} OptValType;
-#define SB_MAX 100000 // Maximum 'scrollback' value.
+/// Option value
+typedef struct {
+ OptValType type;
-#define TABSTOP_MAX 9999
+ union {
+ // boolean options are actually tri-states because they have a third "None" value.
+ TriState boolean;
+ OptInt number;
+ String string;
+ } data;
+} OptVal;
-// Argument for the callback function (opt_did_set_cb_T) invoked after an
-// option value is modified.
+/// Argument for the callback function (opt_did_set_cb_T) invoked after an
+/// option value is modified.
typedef struct {
- // Pointer to the option variable. The variable can be an OptInt (numeric
- // option), an int (boolean option) or a char pointer (string option).
+ /// Pointer to the option variable. The variable can be an OptInt (numeric
+ /// option), an int (boolean option) or a char pointer (string option).
void *os_varp;
int os_idx;
int os_flags;
- // old value of the option (can be a string, number or a boolean)
+ /// old value of the option (can be a string, number or a boolean)
union {
const OptInt number;
const bool boolean;
const char *string;
} os_oldval;
- // new value of the option (can be a string, number or a boolean)
+ /// new value of the option (can be a string, number or a boolean)
union {
const OptInt number;
const bool boolean;
const char *string;
} os_newval;
- // When set by the called function: Stop processing the option further.
- // Currently only used for boolean options.
- int os_doskip;
+ /// When set by the called function: Stop processing the option further.
+ /// Currently only used for boolean options.
+ bool os_doskip;
- // Option value was checked to be safe, no need to set P_INSECURE
- // Used for the 'keymap', 'filetype' and 'syntax' options.
+ /// Option value was checked to be safe, no need to set P_INSECURE
+ /// Used for the 'keymap', 'filetype' and 'syntax' options.
bool os_value_checked;
- // Option value changed. Used for the 'filetype' and 'syntax' options.
+ /// Option value changed. Used for the 'filetype' and 'syntax' options.
bool os_value_changed;
- // Used by the 'isident', 'iskeyword', 'isprint' and 'isfname' options.
- // Set to true if the character table is modified when processing the
- // option and need to be restored because of a failure.
- int os_restore_chartab;
+ /// Used by the 'isident', 'iskeyword', 'isprint' and 'isfname' options.
+ /// Set to true if the character table is modified when processing the
+ /// option and need to be restored because of a failure.
+ bool os_restore_chartab;
- // If the value specified for an option is not valid and the error message
- // is parameterized, then the "os_errbuf" buffer is used to store the error
- // message (when it is not NULL).
+ /// If the value specified for an option is not valid and the error message
+ /// is parameterized, then the "os_errbuf" buffer is used to store the error
+ /// message (when it is not NULL).
char *os_errbuf;
size_t os_errbuflen;
@@ -1030,70 +80,4 @@ typedef struct {
/// Otherwise returns an error message.
typedef const char *(*opt_did_set_cb_T)(optset_T *args);
-/// Stores an identifier of a script or channel that last set an option.
-typedef struct {
- sctx_T script_ctx; /// script context where the option was last set
- uint64_t channel_id; /// Only used when script_id is SID_API_CLIENT.
-} LastSet;
-
-// WV_ and BV_ values get typecasted to this for the "indir" field
-typedef enum {
- PV_NONE = 0,
- PV_MAXVAL = 0xffff, // to avoid warnings for value out of range
-} idopt_T;
-
-typedef struct vimoption {
- char *fullname; // full option name
- char *shortname; // permissible abbreviation
- uint32_t flags; // see above
- void *var; // global option: pointer to variable;
- // window-local option: VAR_WIN;
- // buffer-local option: global value
- idopt_T indir; // global option: PV_NONE;
- // local option: indirect option index
- // callback function to invoke after an option is modified to validate and
- // apply the new value.
- opt_did_set_cb_T opt_did_set_cb;
- void *def_val; // default values for variable (neovim!!)
- LastSet last_set; // script in which the option was last set
-} vimoption_T;
-
-// The options that are local to a window or buffer have "indir" set to one of
-// these values. Special values:
-// PV_NONE: global option.
-// PV_WIN is added: window-local option
-// PV_BUF is added: buffer-local option
-// PV_BOTH is added: global option which also has a local value.
-#define PV_BOTH 0x1000
-#define PV_WIN 0x2000
-#define PV_BUF 0x4000
-#define PV_MASK 0x0fff
-#define OPT_WIN(x) (idopt_T)(PV_WIN + (int)(x))
-#define OPT_BUF(x) (idopt_T)(PV_BUF + (int)(x))
-#define OPT_BOTH(x) (idopt_T)(PV_BOTH + (int)(x))
-
-// 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 *)-1)
-
-// Option value type
-typedef enum {
- kOptValTypeNil = 0,
- kOptValTypeBoolean,
- kOptValTypeNumber,
- kOptValTypeString,
-} OptValType;
-
-// Option value
-typedef struct {
- OptValType type;
-
- union {
- // Vim boolean options are actually tri-states because they have a third "None" value.
- TriState boolean;
- OptInt number;
- String string;
- } data;
-} OptVal;
-
#endif // NVIM_OPTION_DEFS_H
diff --git a/src/nvim/option_vars.h b/src/nvim/option_vars.h
new file mode 100644
index 0000000000..d8bbce21b3
--- /dev/null
+++ b/src/nvim/option_vars.h
@@ -0,0 +1,946 @@
+#ifndef NVIM_OPTION_VARS_H
+#define NVIM_OPTION_VARS_H
+
+#include "nvim/macros.h"
+#include "nvim/types.h"
+
+// option_vars.h: definition of global variables for settable options
+
+// Option Flags
+#define P_BOOL 0x01U ///< the option is boolean
+#define P_NUM 0x02U ///< the option is numeric
+#define P_STRING 0x04U ///< the option is a string
+#define P_ALLOCED 0x08U ///< the string option is in allocated memory,
+ ///< must use free_string_option() when
+ ///< assigning new value. Not set if default is
+ ///< the same.
+#define P_EXPAND 0x10U ///< environment expansion. NOTE: P_EXPAND can
+ ///< never be used for local or hidden options
+#define P_NODEFAULT 0x40U ///< don't set to default value
+#define P_DEF_ALLOCED 0x80U ///< default value is in allocated memory, must
+ ///< use free() when assigning new value
+#define P_WAS_SET 0x100U ///< option has been set/reset
+#define P_NO_MKRC 0x200U ///< don't include in :mkvimrc output
+
+// when option changed, what to display:
+#define P_UI_OPTION 0x400U ///< send option to remote UI
+#define P_RTABL 0x800U ///< redraw tabline
+#define P_RSTAT 0x1000U ///< redraw status lines
+#define P_RWIN 0x2000U ///< redraw current window and recompute text
+#define P_RBUF 0x4000U ///< redraw current buffer and recompute text
+#define P_RALL 0x6000U ///< redraw all windows
+#define P_RCLR 0x7000U ///< clear and redraw all
+
+#define P_COMMA 0x8000U ///< comma separated list
+#define P_ONECOMMA 0x18000U ///< P_COMMA and cannot have two consecutive
+ ///< commas
+#define P_NODUP 0x20000U ///< don't allow duplicate strings
+#define P_FLAGLIST 0x40000U ///< list of single-char flags
+
+#define P_SECURE 0x80000U ///< cannot change in modeline or secure mode
+#define P_GETTEXT 0x100000U ///< expand default value with _()
+#define P_NOGLOB 0x200000U ///< do not use local value for global vimrc
+#define P_NFNAME 0x400000U ///< only normal file name chars allowed
+#define P_INSECURE 0x800000U ///< option was set from a modeline
+#define P_PRI_MKRC 0x1000000U ///< priority for :mkvimrc (setting option
+ ///< has side effects)
+#define P_NO_ML 0x2000000U ///< not allowed in modeline
+#define P_CURSWANT 0x4000000U ///< update curswant required; not needed
+ ///< when there is a redraw flag
+#define P_NDNAME 0x8000000U ///< only normal dir name chars allowed
+#define P_RWINONLY 0x10000000U ///< only redraw current window
+#define P_MLE 0x20000000U ///< under control of 'modelineexpr'
+#define P_FUNC 0x40000000U ///< accept a function reference or a lambda
+
+#define P_NO_DEF_EXP 0x80000000U ///< Do not expand default value.
+
+#define HIGHLIGHT_INIT \
+ "8:SpecialKey,~:EndOfBuffer,z:TermCursor,Z:TermCursorNC,@:NonText,d:Directory,e:ErrorMsg," \
+ "i:IncSearch,l:Search,y:CurSearch,m:MoreMsg,M:ModeMsg,n:LineNr,a:LineNrAbove,b:LineNrBelow," \
+ "N:CursorLineNr,G:CursorLineSign,O:CursorLineFold" \
+ "r:Question,s:StatusLine,S:StatusLineNC,c:VertSplit,t:Title,v:Visual,V:VisualNOS,w:WarningMsg," \
+ "W:WildMenu,f:Folded,F:FoldColumn,A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText,>:SignColumn," \
+ "-:Conceal,B:SpellBad,P:SpellCap,R:SpellRare,L:SpellLocal,+:Pmenu,=:PmenuSel," \
+ "[:PmenuKind,]:PmenuKindSel,{:PmenuExtra,}:PmenuExtraSel,x:PmenuSbar,X:PmenuThumb," \
+ "*:TabLine,#:TabLineSel,_:TabLineFill,!:CursorColumn,.:CursorLine,o:ColorColumn," \
+ "q:QuickFixLine,0:Whitespace,I:NormalNC"
+
+// Default values for 'errorformat'.
+// The "%f|%l| %m" one is used for when the contents of the quickfix window is
+// written to a file.
+#ifdef MSWIN
+# define DFLT_EFM \
+ "%f(%l) \\=: %t%*\\D%n: %m,%*[^\"]\"%f\"%*\\D%l: %m,%f(%l) \\=: %m,%*[^ ] %f %l: %m,%f:%l:%c:%m,%f(%l):%m,%f:%l:%m,%f|%l| %m"
+#else
+# define DFLT_EFM \
+ "%*[^\"]\"%f\"%*\\D%l: %m,\"%f\"%*\\D%l: %m,%-Gg%\\?make[%*\\d]: *** [%f:%l:%m,%-Gg%\\?make: *** [%f:%l:%m,%-G%f:%l: (Each undeclared identifier is reported only once,%-G%f:%l: for each function it appears in.),%-GIn file included from %f:%l:%c:,%-GIn file included from %f:%l:%c\\,,%-GIn file included from %f:%l:%c,%-GIn file included from %f:%l,%-G%*[ ]from %f:%l:%c,%-G%*[ ]from %f:%l:,%-G%*[ ]from %f:%l\\,,%-G%*[ ]from %f:%l,%f:%l:%c:%m,%f(%l):%m,%f:%l:%m,\"%f\"\\, line %l%*\\D%c%*[^ ] %m,%D%*\\a[%*\\d]: Entering directory %*[`']%f',%X%*\\a[%*\\d]: Leaving directory %*[`']%f',%D%*\\a: Entering directory %*[`']%f',%X%*\\a: Leaving directory %*[`']%f',%DMaking %*\\a in %f,%f|%l| %m"
+#endif
+
+#define DFLT_GREPFORMAT "%f:%l:%m,%f:%l%m,%f %l%m"
+
+// default values for b_p_ff 'fileformat' and p_ffs 'fileformats'
+#define FF_DOS "dos"
+#define FF_MAC "mac"
+#define FF_UNIX "unix"
+
+#ifdef USE_CRNL
+# define DFLT_FF "dos"
+# define DFLT_FFS_VIM "dos,unix"
+# define DFLT_FFS_VI "dos,unix" // also autodetect in compatible mode
+#else
+# define DFLT_FF "unix"
+# define DFLT_FFS_VIM "unix,dos"
+# define DFLT_FFS_VI ""
+#endif
+
+// Possible values for 'encoding'
+#define ENC_UCSBOM "ucs-bom" // check for BOM at start of file
+
+// default value for 'encoding'
+#define ENC_DFLT "utf-8"
+
+// end-of-line style
+#define EOL_UNKNOWN (-1) // not defined yet
+#define EOL_UNIX 0 // NL
+#define EOL_DOS 1 // CR NL
+#define EOL_MAC 2 // CR
+
+// Formatting options for p_fo 'formatoptions'
+#define FO_WRAP 't'
+#define FO_WRAP_COMS 'c'
+#define FO_RET_COMS 'r'
+#define FO_OPEN_COMS 'o'
+#define FO_NO_OPEN_COMS '/'
+#define FO_Q_COMS 'q'
+#define FO_Q_NUMBER 'n'
+#define FO_Q_SECOND '2'
+#define FO_INS_VI 'v'
+#define FO_INS_LONG 'l'
+#define FO_INS_BLANK 'b'
+#define FO_MBYTE_BREAK 'm' // break before/after multi-byte char
+#define FO_MBYTE_JOIN 'M' // no space before/after multi-byte char
+#define FO_MBYTE_JOIN2 'B' // no space between multi-byte chars
+#define FO_ONE_LETTER '1'
+#define FO_WHITE_PAR 'w' // trailing white space continues paragr.
+#define FO_AUTO 'a' // automatic formatting
+#define FO_RIGOROUS_TW ']' // respect textwidth rigorously
+#define FO_REMOVE_COMS 'j' // remove comment leaders when joining lines
+#define FO_PERIOD_ABBR 'p' // don't break a single space after a period
+
+#define DFLT_FO_VI "vt"
+#define DFLT_FO_VIM "tcqj"
+#define FO_ALL "tcro/q2vlb1mMBn,aw]jp" // for do_set()
+
+// characters for the p_cpo option:
+#define CPO_ALTREAD 'a' // ":read" sets alternate file name
+#define CPO_ALTWRITE 'A' // ":write" sets alternate file name
+#define CPO_BAR 'b' // "\|" ends a mapping
+#define CPO_BSLASH 'B' // backslash in mapping is not special
+#define CPO_SEARCH 'c'
+#define CPO_CONCAT 'C' // Don't concatenate sourced lines
+#define CPO_DOTTAG 'd' // "./tags" in 'tags' is in current dir
+#define CPO_DIGRAPH 'D' // No digraph after "r", "f", etc.
+#define CPO_EXECBUF 'e'
+#define CPO_EMPTYREGION 'E' // operating on empty region is an error
+#define CPO_FNAMER 'f' // set file name for ":r file"
+#define CPO_FNAMEW 'F' // set file name for ":w file"
+#define CPO_INTMOD 'i' // interrupt a read makes buffer modified
+#define CPO_INDENT 'I' // remove auto-indent more often
+#define CPO_ENDOFSENT 'J' // need two spaces to detect end of sentence
+#define CPO_KOFFSET 'K' // don't wait for key code in mappings
+#define CPO_LITERAL 'l' // take char after backslash in [] literal
+#define CPO_LISTWM 'L' // 'list' changes wrapmargin
+#define CPO_SHOWMATCH 'm'
+#define CPO_MATCHBSL 'M' // "%" ignores use of backslashes
+#define CPO_NUMCOL 'n' // 'number' column also used for text
+#define CPO_LINEOFF 'o'
+#define CPO_OVERNEW 'O' // silently overwrite new file
+#define CPO_LISP 'p' // 'lisp' indenting
+#define CPO_FNAMEAPP 'P' // set file name for ":w >>file"
+#define CPO_JOINCOL 'q' // with "3J" use column after first join
+#define CPO_REDO 'r'
+#define CPO_REMMARK 'R' // remove marks when filtering
+#define CPO_BUFOPT 's'
+#define CPO_BUFOPTGLOB 'S'
+#define CPO_TAGPAT 't' // tag pattern is used for "n"
+#define CPO_UNDO 'u' // "u" undoes itself
+#define CPO_BACKSPACE 'v' // "v" keep deleted text
+#define CPO_FWRITE 'W' // "w!" doesn't overwrite readonly files
+#define CPO_ESC 'x'
+#define CPO_REPLCNT 'X' // "R" with a count only deletes chars once
+#define CPO_YANK 'y'
+#define CPO_KEEPRO 'Z' // don't reset 'readonly' on ":w!"
+#define CPO_DOLLAR '$'
+#define CPO_FILTER '!'
+#define CPO_MATCH '%'
+#define CPO_PLUS '+' // ":write file" resets 'modified'
+#define CPO_REGAPPEND '>' // insert NL when appending to a register
+#define CPO_SCOLON ';' // using "," and ";" will skip over char if
+ // cursor would not move
+#define CPO_CHANGEW '_' // "cw" special-case
+// default values for Vim and Vi
+#define CPO_VIM "aABceFs_"
+#define CPO_VI "aAbBcCdDeEfFiIJKlLmMnoOpPqrRsStuvWxXyZ$!%+>;_"
+
+// characters for p_ww option:
+#define WW_ALL "bshl<>[],~"
+
+// characters for p_mouse option:
+#define MOUSE_NORMAL 'n' // use mouse in Normal mode
+#define MOUSE_VISUAL 'v' // use mouse in Visual/Select mode
+#define MOUSE_INSERT 'i' // use mouse in Insert mode
+#define MOUSE_COMMAND 'c' // use mouse in Command-line mode
+#define MOUSE_HELP 'h' // use mouse in help buffers
+#define MOUSE_RETURN 'r' // use mouse for hit-return message
+#define MOUSE_A "nvich" // used for 'a' flag
+#define MOUSE_ALL "anvichr" // all possible characters
+#define MOUSE_NONE ' ' // don't use Visual selection
+#define MOUSE_NONEF 'x' // forced modeless selection
+
+// default vertical and horizontal mouse scroll values.
+// Note: This should be in sync with the default mousescroll option.
+#define MOUSESCROLL_VERT_DFLT 3
+#define MOUSESCROLL_HOR_DFLT 6
+
+#define COCU_ALL "nvic" // flags for 'concealcursor'
+
+/// characters for p_shm option:
+enum {
+ SHM_RO = 'r', ///< Readonly.
+ SHM_MOD = 'm', ///< Modified.
+ SHM_LINES = 'l', ///< "L" instead of "lines".
+ SHM_WRI = 'w', ///< "[w]" instead of "written".
+ SHM_ABBREVIATIONS = 'a', ///< Use abbreviations from #SHM_ALL_ABBREVIATIONS.
+ SHM_WRITE = 'W', ///< Don't use "written" at all.
+ SHM_TRUNC = 't', ///< Truncate file messages.
+ SHM_TRUNCALL = 'T', ///< Truncate all messages.
+ SHM_OVER = 'o', ///< Overwrite file messages.
+ SHM_OVERALL = 'O', ///< Overwrite more messages.
+ SHM_SEARCH = 's', ///< No search hit bottom messages.
+ SHM_ATTENTION = 'A', ///< No ATTENTION messages.
+ SHM_INTRO = 'I', ///< Intro messages.
+ SHM_COMPLETIONMENU = 'c', ///< Completion menu messages.
+ SHM_COMPLETIONSCAN = 'C', ///< Completion scanning messages.
+ SHM_RECORDING = 'q', ///< Short recording message.
+ SHM_FILEINFO = 'F', ///< No file info messages.
+ SHM_SEARCHCOUNT = 'S', ///< No search stats: '[1/10]'
+};
+/// Represented by 'a' flag.
+#define SHM_ALL_ABBREVIATIONS ((char[]) { \
+ SHM_RO, SHM_MOD, SHM_LINES, SHM_WRI, \
+ 0 })
+
+// characters for p_go:
+#define GO_ASEL 'a' // autoselect
+#define GO_ASELML 'A' // autoselect modeless selection
+#define GO_BOT 'b' // use bottom scrollbar
+#define GO_CONDIALOG 'c' // use console dialog
+#define GO_DARKTHEME 'd' // use dark theme variant
+#define GO_TABLINE 'e' // may show tabline
+#define GO_FORG 'f' // start GUI in foreground
+#define GO_GREY 'g' // use grey menu items
+#define GO_HORSCROLL 'h' // flexible horizontal scrolling
+#define GO_ICON 'i' // use Vim icon
+#define GO_LEFT 'l' // use left scrollbar
+#define GO_VLEFT 'L' // left scrollbar with vert split
+#define GO_MENUS 'm' // use menu bar
+#define GO_NOSYSMENU 'M' // don't source system menu
+#define GO_POINTER 'p' // pointer enter/leave callbacks
+#define GO_ASELPLUS 'P' // autoselectPlus
+#define GO_RIGHT 'r' // use right scrollbar
+#define GO_VRIGHT 'R' // right scrollbar with vert split
+#define GO_TOOLBAR 'T' // add toolbar
+#define GO_FOOTER 'F' // add footer
+#define GO_VERTICAL 'v' // arrange dialog buttons vertically
+#define GO_KEEPWINSIZE 'k' // keep GUI window size
+#define GO_ALL "!aAbcdefFghilLmMpPrRtTvk" // all possible flags for 'go'
+
+// flags for 'comments' option
+#define COM_NEST 'n' // comments strings nest
+#define COM_BLANK 'b' // needs blank after string
+#define COM_START 's' // start of comment
+#define COM_MIDDLE 'm' // middle of comment
+#define COM_END 'e' // end of comment
+#define COM_AUTO_END 'x' // last char of end closes comment
+#define COM_FIRST 'f' // first line comment only
+#define COM_LEFT 'l' // left adjusted
+#define COM_RIGHT 'r' // right adjusted
+#define COM_NOBACK 'O' // don't use for "O" command
+#define COM_ALL "nbsmexflrO" // all flags for 'comments' option
+#define COM_MAX_LEN 50 // maximum length of a part
+
+/// 'statusline' option flags
+enum {
+ STL_FILEPATH = 'f', ///< Path of file in buffer.
+ STL_FULLPATH = 'F', ///< Full path of file in buffer.
+ STL_FILENAME = 't', ///< Last part (tail) of file path.
+ STL_COLUMN = 'c', ///< Column og cursor.
+ STL_VIRTCOL = 'v', ///< Virtual column.
+ STL_VIRTCOL_ALT = 'V', ///< - with 'if different' display.
+ STL_LINE = 'l', ///< Line number of cursor.
+ STL_NUMLINES = 'L', ///< Number of lines in buffer.
+ STL_BUFNO = 'n', ///< Current buffer number.
+ STL_KEYMAP = 'k', ///< 'keymap' when active.
+ STL_OFFSET = 'o', ///< Offset of character under cursor.
+ STL_OFFSET_X = 'O', ///< - in hexadecimal.
+ STL_BYTEVAL = 'b', ///< Byte value of character.
+ STL_BYTEVAL_X = 'B', ///< - in hexadecimal.
+ STL_ROFLAG = 'r', ///< Readonly flag.
+ STL_ROFLAG_ALT = 'R', ///< - other display.
+ STL_HELPFLAG = 'h', ///< Window is showing a help file.
+ STL_HELPFLAG_ALT = 'H', ///< - other display.
+ STL_FILETYPE = 'y', ///< 'filetype'.
+ STL_FILETYPE_ALT = 'Y', ///< - other display.
+ STL_PREVIEWFLAG = 'w', ///< Window is showing the preview buf.
+ STL_PREVIEWFLAG_ALT = 'W', ///< - other display.
+ STL_MODIFIED = 'm', ///< Modified flag.
+ STL_MODIFIED_ALT = 'M', ///< - other display.
+ STL_QUICKFIX = 'q', ///< Quickfix window description.
+ STL_PERCENTAGE = 'p', ///< Percentage through file.
+ STL_ALTPERCENT = 'P', ///< Percentage as TOP BOT ALL or NN%.
+ STL_ARGLISTSTAT = 'a', ///< Argument list status as (x of y).
+ STL_PAGENUM = 'N', ///< Page number (when printing).
+ STL_SHOWCMD = 'S', ///< 'showcmd' buffer
+ STL_FOLDCOL = 'C', ///< Fold column for 'statuscolumn'
+ STL_SIGNCOL = 's', ///< Sign column for 'statuscolumn'
+ STL_VIM_EXPR = '{', ///< Start of expression to substitute.
+ STL_SEPARATE = '=', ///< Separation between alignment sections.
+ STL_TRUNCMARK = '<', ///< Truncation mark if line is too long.
+ STL_USER_HL = '*', ///< Highlight from (User)1..9 or 0.
+ STL_HIGHLIGHT = '#', ///< Highlight name.
+ STL_TABPAGENR = 'T', ///< Tab page label nr.
+ STL_TABCLOSENR = 'X', ///< Tab page close nr.
+ STL_CLICK_FUNC = '@', ///< Click region start.
+};
+/// C string containing all 'statusline' option flags
+#define STL_ALL ((char[]) { \
+ STL_FILEPATH, STL_FULLPATH, STL_FILENAME, STL_COLUMN, STL_VIRTCOL, \
+ STL_VIRTCOL_ALT, STL_LINE, STL_NUMLINES, STL_BUFNO, STL_KEYMAP, STL_OFFSET, \
+ STL_OFFSET_X, STL_BYTEVAL, STL_BYTEVAL_X, STL_ROFLAG, STL_ROFLAG_ALT, \
+ STL_HELPFLAG, STL_HELPFLAG_ALT, STL_FILETYPE, STL_FILETYPE_ALT, \
+ STL_PREVIEWFLAG, STL_PREVIEWFLAG_ALT, STL_MODIFIED, STL_MODIFIED_ALT, \
+ STL_QUICKFIX, STL_PERCENTAGE, STL_ALTPERCENT, STL_ARGLISTSTAT, STL_PAGENUM, \
+ STL_SHOWCMD, STL_FOLDCOL, STL_SIGNCOL, STL_VIM_EXPR, STL_SEPARATE, \
+ STL_TRUNCMARK, STL_USER_HL, STL_HIGHLIGHT, STL_TABPAGENR, STL_TABCLOSENR, \
+ STL_CLICK_FUNC, STL_TABPAGENR, STL_TABCLOSENR, STL_CLICK_FUNC, \
+ 0, })
+
+// flags used for parsed 'wildmode'
+#define WIM_FULL 0x01
+#define WIM_LONGEST 0x02
+#define WIM_LIST 0x04
+#define WIM_BUFLASTUSED 0x08
+
+// arguments for can_bs()
+// each defined char should be unique over all values
+// except for BS_START, that intentionally also matches BS_NOSTOP
+// because BS_NOSTOP behaves exactly the same except it
+// does not stop at the start of the insert point
+#define BS_INDENT 'i' // "Indent"
+#define BS_EOL 'l' // "eoL"
+#define BS_START 's' // "Start"
+#define BS_NOSTOP 'p' // "nostoP
+
+// flags for the 'culopt' option
+#define CULOPT_LINE 0x01 // Highlight complete line
+#define CULOPT_SCRLINE 0x02 // Highlight screen line
+#define CULOPT_NBR 0x04 // Highlight Number column
+
+#define LISPWORD_VALUE \
+ "defun,define,defmacro,set!,lambda,if,case,let,flet,let*,letrec,do,do*,define-syntax,let-syntax,letrec-syntax,destructuring-bind,defpackage,defparameter,defstruct,deftype,defvar,do-all-symbols,do-external-symbols,do-symbols,dolist,dotimes,ecase,etypecase,eval-when,labels,macrolet,multiple-value-bind,multiple-value-call,multiple-value-prog1,multiple-value-setq,prog1,progv,typecase,unless,unwind-protect,when,with-input-from-string,with-open-file,with-open-stream,with-output-to-string,with-package-iterator,define-condition,handler-bind,handler-case,restart-bind,restart-case,with-simple-restart,store-value,use-value,muffle-warning,abort,continue,with-slots,with-slots*,with-accessors,with-accessors*,defclass,defmethod,print-unreadable-object"
+
+// The following are actual variables for the options
+
+EXTERN char *p_ambw; ///< 'ambiwidth'
+EXTERN int p_acd; ///< 'autochdir'
+EXTERN int p_ai; ///< 'autoindent'
+EXTERN int p_bin; ///< 'binary'
+EXTERN int p_bomb; ///< 'bomb'
+EXTERN int p_bl; ///< 'buflisted'
+EXTERN int p_cin; ///< 'cindent'
+EXTERN OptInt p_channel; ///< 'channel'
+EXTERN char *p_cink; ///< 'cinkeys'
+EXTERN char *p_cinsd; ///< 'cinscopedecls'
+EXTERN char *p_cinw; ///< 'cinwords'
+EXTERN char *p_cfu; ///< 'completefunc'
+EXTERN char *p_ofu; ///< 'omnifunc'
+EXTERN char *p_tsrfu; ///< 'thesaurusfunc'
+EXTERN int p_ci; ///< 'copyindent'
+EXTERN int p_ar; ///< 'autoread'
+EXTERN int p_aw; ///< 'autowrite'
+EXTERN int p_awa; ///< 'autowriteall'
+EXTERN char *p_bs; ///< 'backspace'
+EXTERN char *p_bg; ///< 'background'
+EXTERN int p_bk; ///< 'backup'
+EXTERN char *p_bkc; ///< 'backupcopy'
+EXTERN unsigned bkc_flags; ///< flags from 'backupcopy'
+#define BKC_YES 0x001
+#define BKC_AUTO 0x002
+#define BKC_NO 0x004
+#define BKC_BREAKSYMLINK 0x008
+#define BKC_BREAKHARDLINK 0x010
+EXTERN char *p_bdir; ///< 'backupdir'
+EXTERN char *p_bex; ///< 'backupext'
+EXTERN char *p_bo; ///< 'belloff'
+EXTERN char breakat_flags[256]; ///< which characters are in 'breakat'
+EXTERN unsigned bo_flags;
+
+// values for the 'belloff' option
+#define BO_ALL 0x0001
+#define BO_BS 0x0002
+#define BO_CRSR 0x0004
+#define BO_COMPL 0x0008
+#define BO_COPY 0x0010
+#define BO_CTRLG 0x0020
+#define BO_ERROR 0x0040
+#define BO_ESC 0x0080
+#define BO_EX 0x0100
+#define BO_HANGUL 0x0200
+#define BO_IM 0x0400
+#define BO_LANG 0x0800
+#define BO_MESS 0x1000
+#define BO_MATCH 0x2000
+#define BO_OPER 0x4000
+#define BO_REG 0x8000
+#define BO_SH 0x10000
+#define BO_SPELL 0x20000
+#define BO_WILD 0x40000
+
+EXTERN char *p_bsk; ///< 'backupskip'
+EXTERN char *p_breakat; ///< 'breakat'
+EXTERN char *p_bh; ///< 'bufhidden'
+EXTERN char *p_bt; ///< 'buftype'
+EXTERN char *p_cmp; ///< 'casemap'
+EXTERN unsigned cmp_flags;
+#define CMP_INTERNAL 0x001
+#define CMP_KEEPASCII 0x002
+EXTERN char *p_enc; ///< 'encoding'
+EXTERN int p_deco; ///< 'delcombine'
+EXTERN char *p_ccv; ///< 'charconvert'
+EXTERN char *p_cino; ///< 'cinoptions'
+EXTERN char *p_cedit; ///< 'cedit'
+EXTERN char *p_cb; ///< 'clipboard'
+EXTERN unsigned cb_flags;
+#define CB_UNNAMED 0x001
+#define CB_UNNAMEDPLUS 0x002
+#define CB_UNNAMEDMASK (CB_UNNAMED | CB_UNNAMEDPLUS)
+EXTERN OptInt p_cwh; ///< 'cmdwinheight'
+EXTERN OptInt p_ch; ///< 'cmdheight'
+EXTERN char *p_cms; ///< 'commentstring'
+EXTERN char *p_cpt; ///< 'complete'
+EXTERN OptInt p_columns; ///< 'columns'
+EXTERN int p_confirm; ///< 'confirm'
+EXTERN char *p_cot; ///< 'completeopt'
+#ifdef BACKSLASH_IN_FILENAME
+EXTERN char *p_csl; ///< 'completeslash'
+#endif
+EXTERN OptInt p_pb; ///< 'pumblend'
+EXTERN OptInt p_ph; ///< 'pumheight'
+EXTERN OptInt p_pw; ///< 'pumwidth'
+EXTERN char *p_com; ///< 'comments'
+EXTERN char *p_cpo; ///< 'cpoptions'
+EXTERN char *p_debug; ///< 'debug'
+EXTERN char *p_def; ///< 'define'
+EXTERN char *p_inc;
+EXTERN char *p_dip; ///< 'diffopt'
+EXTERN char *p_dex; ///< 'diffexpr'
+EXTERN char *p_dict; ///< 'dictionary'
+EXTERN int p_dg; ///< 'digraph'
+EXTERN char *p_dir; ///< 'directory'
+EXTERN char *p_dy; ///< 'display'
+EXTERN unsigned dy_flags;
+#define DY_LASTLINE 0x001
+#define DY_TRUNCATE 0x002
+#define DY_UHEX 0x004
+// legacy flag, not used
+#define DY_MSGSEP 0x008
+EXTERN int p_ed; ///< 'edcompatible'
+EXTERN char *p_ead; ///< 'eadirection'
+EXTERN int p_emoji; ///< 'emoji'
+EXTERN int p_ea; ///< 'equalalways'
+EXTERN char *p_ep; ///< 'equalprg'
+EXTERN int p_eb; ///< 'errorbells'
+EXTERN char *p_ef; ///< 'errorfile'
+EXTERN char *p_efm; ///< 'errorformat'
+EXTERN char *p_gefm; ///< 'grepformat'
+EXTERN char *p_gp; ///< 'grepprg'
+EXTERN int p_eof; ///< 'endoffile'
+EXTERN int p_eol; ///< 'endofline'
+EXTERN char *p_ei; ///< 'eventignore'
+EXTERN int p_et; ///< 'expandtab'
+EXTERN int p_exrc; ///< 'exrc'
+EXTERN char *p_fenc; ///< 'fileencoding'
+EXTERN char *p_fencs; ///< 'fileencodings'
+EXTERN char *p_ff; ///< 'fileformat'
+EXTERN char *p_ffs; ///< 'fileformats'
+EXTERN int p_fic; ///< 'fileignorecase'
+EXTERN char *p_ft; ///< 'filetype'
+EXTERN char *p_fcs; ///< 'fillchar'
+EXTERN int p_fixeol; ///< 'fixendofline'
+EXTERN char *p_fcl; ///< 'foldclose'
+EXTERN OptInt p_fdls; ///< 'foldlevelstart'
+EXTERN char *p_fdo; ///< 'foldopen'
+EXTERN unsigned fdo_flags;
+#define FDO_ALL 0x001
+#define FDO_BLOCK 0x002
+#define FDO_HOR 0x004
+#define FDO_MARK 0x008
+#define FDO_PERCENT 0x010
+#define FDO_QUICKFIX 0x020
+#define FDO_SEARCH 0x040
+#define FDO_TAG 0x080
+#define FDO_INSERT 0x100
+#define FDO_UNDO 0x200
+#define FDO_JUMP 0x400
+EXTERN char *p_fex; ///< 'formatexpr'
+EXTERN char *p_flp; ///< 'formatlistpat'
+EXTERN char *p_fo; ///< 'formatoptions'
+EXTERN char *p_fp; ///< 'formatprg'
+EXTERN int p_fs; ///< 'fsync'
+EXTERN int p_gd; ///< 'gdefault'
+EXTERN char *p_guicursor; ///< 'guicursor'
+EXTERN char *p_guifont; ///< 'guifont'
+EXTERN char *p_guifontwide; ///< 'guifontwide'
+EXTERN char *p_hf; ///< 'helpfile'
+EXTERN OptInt p_hh; ///< 'helpheight'
+EXTERN char *p_hlg; ///< 'helplang'
+EXTERN int p_hid; ///< 'hidden'
+EXTERN char *p_hl; ///< 'highlight'
+EXTERN int p_hls; ///< 'hlsearch'
+EXTERN OptInt p_hi; ///< 'history'
+EXTERN int p_arshape; ///< 'arabicshape'
+EXTERN int p_icon; ///< 'icon'
+EXTERN char *p_iconstring; ///< 'iconstring'
+EXTERN int p_ic; ///< 'ignorecase'
+EXTERN OptInt p_iminsert; ///< 'iminsert'
+EXTERN OptInt p_imsearch; ///< 'imsearch'
+EXTERN int p_inf; ///< 'infercase'
+EXTERN char *p_inex; ///< 'includeexpr'
+EXTERN int p_is; ///< 'incsearch'
+EXTERN char *p_inde; ///< 'indentexpr'
+EXTERN char *p_indk; ///< 'indentkeys'
+EXTERN char *p_icm; ///< 'inccommand'
+EXTERN char *p_isf; ///< 'isfname'
+EXTERN char *p_isi; ///< 'isident'
+EXTERN char *p_isk; ///< 'iskeyword'
+EXTERN char *p_isp; ///< 'isprint'
+EXTERN int p_js; ///< 'joinspaces'
+EXTERN char *p_jop; ///< 'jumpooptions'
+EXTERN unsigned jop_flags;
+#define JOP_STACK 0x01
+#define JOP_VIEW 0x02
+EXTERN char *p_keymap; ///< 'keymap'
+EXTERN char *p_kp; ///< 'keywordprg'
+EXTERN char *p_km; ///< 'keymodel'
+EXTERN char *p_langmap; ///< 'langmap'
+EXTERN int p_lnr; ///< 'langnoremap'
+EXTERN int p_lrm; ///< 'langremap'
+EXTERN char *p_lm; ///< 'langmenu'
+EXTERN OptInt p_lines; ///< 'lines'
+EXTERN OptInt p_linespace; ///< 'linespace'
+EXTERN int p_lisp; ///< 'lisp'
+EXTERN char *p_lop; ///< 'lispoptions'
+EXTERN char *p_lispwords; ///< 'lispwords'
+EXTERN OptInt p_ls; ///< 'laststatus'
+EXTERN OptInt p_stal; ///< 'showtabline'
+EXTERN char *p_lcs; ///< 'listchars'
+
+EXTERN int p_lz; ///< 'lazyredraw'
+EXTERN int p_lpl; ///< 'loadplugins'
+EXTERN int p_magic; ///< 'magic'
+EXTERN char *p_menc; ///< 'makeencoding'
+EXTERN char *p_mef; ///< 'makeef'
+EXTERN char *p_mp; ///< 'makeprg'
+EXTERN char *p_mps; ///< 'matchpairs'
+EXTERN OptInt p_mat; ///< 'matchtime'
+EXTERN OptInt p_mco; ///< 'maxcombine'
+EXTERN OptInt p_mfd; ///< 'maxfuncdepth'
+EXTERN OptInt p_mmd; ///< 'maxmapdepth'
+EXTERN OptInt p_mmp; ///< 'maxmempattern'
+EXTERN OptInt p_mis; ///< 'menuitems'
+EXTERN char *p_msm; ///< 'mkspellmem'
+EXTERN int p_ml; ///< 'modeline'
+EXTERN int p_mle; ///< 'modelineexpr'
+EXTERN OptInt p_mls; ///< 'modelines'
+EXTERN int p_ma; ///< 'modifiable'
+EXTERN int p_mod; ///< 'modified'
+EXTERN char *p_mouse; ///< 'mouse'
+EXTERN char *p_mousem; ///< 'mousemodel'
+EXTERN int p_mousemev; ///< 'mousemoveevent'
+EXTERN int p_mousef; ///< 'mousefocus'
+EXTERN char *p_mousescroll; ///< 'mousescroll'
+EXTERN OptInt p_mousescroll_vert INIT(= MOUSESCROLL_VERT_DFLT);
+EXTERN OptInt p_mousescroll_hor INIT(= MOUSESCROLL_HOR_DFLT);
+EXTERN OptInt p_mouset; ///< 'mousetime'
+EXTERN int p_more; ///< 'more'
+EXTERN char *p_nf; ///< 'nrformats'
+EXTERN char *p_opfunc; ///< 'operatorfunc'
+EXTERN char *p_para; ///< 'paragraphs'
+EXTERN int p_paste; ///< 'paste'
+EXTERN char *p_pex; ///< 'patchexpr'
+EXTERN char *p_pm; ///< 'patchmode'
+EXTERN char *p_path; ///< 'path'
+EXTERN char *p_cdpath; ///< 'cdpath'
+EXTERN int p_pi; ///< 'preserveindent'
+EXTERN OptInt p_pyx; ///< 'pyxversion'
+EXTERN char *p_qe; ///< 'quoteescape'
+EXTERN int p_ro; ///< 'readonly'
+EXTERN char *p_rdb; ///< 'redrawdebug'
+EXTERN unsigned rdb_flags;
+#define RDB_COMPOSITOR 0x001
+#define RDB_NOTHROTTLE 0x002
+#define RDB_INVALID 0x004
+#define RDB_NODELTA 0x008
+#define RDB_LINE 0x010
+#define RDB_FLUSH 0x020
+#define RDB_INTERSECT 0x040
+
+EXTERN OptInt p_rdt; ///< 'redrawtime'
+EXTERN OptInt p_re; ///< 'regexpengine'
+EXTERN OptInt p_report; ///< 'report'
+EXTERN OptInt p_pvh; ///< 'previewheight'
+EXTERN int p_ari; ///< 'allowrevins'
+EXTERN int p_ri; ///< 'revins'
+EXTERN int p_ru; ///< 'ruler'
+EXTERN char *p_ruf; ///< 'rulerformat'
+EXTERN char *p_pp; ///< 'packpath'
+EXTERN char *p_qftf; ///< 'quickfixtextfunc'
+EXTERN char *p_rtp; ///< 'runtimepath'
+EXTERN OptInt p_scbk; ///< 'scrollback'
+EXTERN OptInt p_sj; ///< 'scrolljump'
+EXTERN OptInt p_so; ///< 'scrolloff'
+EXTERN char *p_sbo; ///< 'scrollopt'
+EXTERN char *p_sections; ///< 'sections'
+EXTERN int p_secure; ///< 'secure'
+EXTERN char *p_sel; ///< 'selection'
+EXTERN char *p_slm; ///< 'selectmode'
+EXTERN char *p_ssop; ///< 'sessionoptions'
+EXTERN unsigned ssop_flags;
+
+#define SSOP_BUFFERS 0x001
+#define SSOP_WINPOS 0x002
+#define SSOP_RESIZE 0x004
+#define SSOP_WINSIZE 0x008
+#define SSOP_LOCALOPTIONS 0x010
+#define SSOP_OPTIONS 0x020
+#define SSOP_HELP 0x040
+#define SSOP_BLANK 0x080
+#define SSOP_GLOBALS 0x100
+#define SSOP_SLASH 0x200 // Deprecated, always set.
+#define SSOP_UNIX 0x400 // Deprecated, always set.
+#define SSOP_SESDIR 0x800
+#define SSOP_CURDIR 0x1000
+#define SSOP_FOLDS 0x2000
+#define SSOP_CURSOR 0x4000
+#define SSOP_TABPAGES 0x8000
+#define SSOP_TERMINAL 0x10000
+#define SSOP_SKIP_RTP 0x20000
+
+EXTERN char *p_sh; ///< 'shell'
+EXTERN char *p_shcf; ///< 'shellcmdflag'
+EXTERN char *p_sp; ///< 'shellpipe'
+EXTERN char *p_shq; ///< 'shellquote'
+EXTERN char *p_sxq; ///< 'shellxquote'
+EXTERN char *p_sxe; ///< 'shellxescape'
+EXTERN char *p_srr; ///< 'shellredir'
+EXTERN int p_stmp; ///< 'shelltemp'
+#ifdef BACKSLASH_IN_FILENAME
+EXTERN int p_ssl; ///< 'shellslash'
+#endif
+EXTERN char *p_stl; ///< 'statusline'
+EXTERN char *p_wbr; ///< 'winbar'
+EXTERN int p_sr; ///< 'shiftround'
+EXTERN OptInt p_sw; ///< 'shiftwidth'
+EXTERN char *p_shm; ///< 'shortmess'
+EXTERN char *p_sbr; ///< 'showbreak'
+EXTERN int p_sc; ///< 'showcmd'
+EXTERN char *p_sloc; ///< 'showcmdloc'
+EXTERN int p_sft; ///< 'showfulltag'
+EXTERN int p_sm; ///< 'showmatch'
+EXTERN int p_smd; ///< 'showmode'
+EXTERN OptInt p_ss; ///< 'sidescroll'
+EXTERN OptInt p_siso; ///< 'sidescrolloff'
+EXTERN int p_scs; ///< 'smartcase'
+EXTERN int p_si; ///< 'smartindent'
+EXTERN int p_sta; ///< 'smarttab'
+EXTERN OptInt p_sts; ///< 'softtabstop'
+EXTERN int p_sb; ///< 'splitbelow'
+EXTERN char *p_sua; ///< 'suffixesadd'
+EXTERN int p_swf; ///< 'swapfile'
+EXTERN OptInt p_smc; ///< 'synmaxcol'
+EXTERN OptInt p_tpm; ///< 'tabpagemax'
+EXTERN char *p_tal; ///< 'tabline'
+EXTERN char *p_tpf; ///< 'termpastefilter'
+EXTERN unsigned tpf_flags; ///< flags from 'termpastefilter'
+#define TPF_BS 0x001
+#define TPF_HT 0x002
+#define TPF_FF 0x004
+#define TPF_ESC 0x008
+#define TPF_DEL 0x010
+#define TPF_C0 0x020
+#define TPF_C1 0x040
+EXTERN char *p_tfu; ///< 'tagfunc'
+EXTERN char *p_spc; ///< 'spellcapcheck'
+EXTERN char *p_spf; ///< 'spellfile'
+EXTERN char *p_spk; ///< 'splitkeep'
+EXTERN char *p_spl; ///< 'spelllang'
+EXTERN char *p_spo; ///< 'spelloptions'
+EXTERN unsigned spo_flags;
+EXTERN char *p_sps; ///< 'spellsuggest'
+EXTERN int p_spr; ///< 'splitright'
+EXTERN int p_sol; ///< 'startofline'
+EXTERN char *p_su; ///< 'suffixes'
+EXTERN char *p_swb; ///< 'switchbuf'
+EXTERN unsigned swb_flags;
+// Keep in sync with p_swb_values in optionstr.c
+#define SWB_USEOPEN 0x001
+#define SWB_USETAB 0x002
+#define SWB_SPLIT 0x004
+#define SWB_NEWTAB 0x008
+#define SWB_VSPLIT 0x010
+#define SWB_USELAST 0x020
+EXTERN char *p_syn; ///< 'syntax'
+EXTERN OptInt p_ts; ///< 'tabstop'
+EXTERN int p_tbs; ///< 'tagbsearch'
+EXTERN char *p_tc; ///< 'tagcase'
+EXTERN unsigned tc_flags; ///< flags from 'tagcase'
+#define TC_FOLLOWIC 0x01
+#define TC_IGNORE 0x02
+#define TC_MATCH 0x04
+#define TC_FOLLOWSCS 0x08
+#define TC_SMART 0x10
+EXTERN OptInt p_tl; ///< 'taglength'
+EXTERN int p_tr; ///< 'tagrelative'
+EXTERN char *p_tags; ///< 'tags'
+EXTERN int p_tgst; ///< 'tagstack'
+EXTERN int p_tbidi; ///< 'termbidi'
+EXTERN OptInt p_tw; ///< 'textwidth'
+EXTERN int p_to; ///< 'tildeop'
+EXTERN int p_timeout; ///< 'timeout'
+EXTERN OptInt p_tm; ///< 'timeoutlen'
+EXTERN int p_title; ///< 'title'
+EXTERN OptInt p_titlelen; ///< 'titlelen'
+EXTERN char *p_titleold; ///< 'titleold'
+EXTERN char *p_titlestring; ///< 'titlestring'
+EXTERN char *p_tsr; ///< 'thesaurus'
+EXTERN int p_tgc; ///< 'termguicolors'
+EXTERN int p_ttimeout; ///< 'ttimeout'
+EXTERN OptInt p_ttm; ///< 'ttimeoutlen'
+EXTERN char *p_udir; ///< 'undodir'
+EXTERN int p_udf; ///< 'undofile'
+EXTERN OptInt p_ul; ///< 'undolevels'
+EXTERN OptInt p_ur; ///< 'undoreload'
+EXTERN OptInt p_uc; ///< 'updatecount'
+EXTERN OptInt p_ut; ///< 'updatetime'
+EXTERN char *p_shada; ///< 'shada'
+EXTERN char *p_shadafile; ///< 'shadafile'
+EXTERN char *p_vsts; ///< 'varsofttabstop'
+EXTERN char *p_vts; ///< 'vartabstop'
+EXTERN char *p_vdir; ///< 'viewdir'
+EXTERN char *p_vop; ///< 'viewoptions'
+EXTERN unsigned vop_flags; ///< uses SSOP_ flags
+EXTERN int p_vb; ///< 'visualbell'
+EXTERN char *p_ve; ///< 'virtualedit'
+EXTERN unsigned ve_flags;
+#define VE_BLOCK 5U // includes "all"
+#define VE_INSERT 6U // includes "all"
+#define VE_ALL 4U
+#define VE_ONEMORE 8U
+#define VE_NONE 16U // "none"
+#define VE_NONEU 32U // "NONE"
+EXTERN OptInt p_verbose; ///< 'verbose'
+#ifdef IN_OPTION_C
+char *p_vfile = ""; ///< used before options are initialized
+#else
+extern char *p_vfile; ///< 'verbosefile'
+#endif
+EXTERN int p_warn; ///< 'warn'
+EXTERN char *p_wop; ///< 'wildoptions'
+EXTERN unsigned wop_flags;
+#define WOP_TAGFILE 0x01
+#define WOP_PUM 0x02
+#define WOP_FUZZY 0x04
+EXTERN OptInt p_window; ///< 'window'
+EXTERN char *p_wak; ///< 'winaltkeys'
+EXTERN char *p_wig; ///< 'wildignore'
+EXTERN char *p_ww; ///< 'whichwrap'
+EXTERN OptInt p_wc; ///< 'wildchar'
+EXTERN OptInt p_wcm; ///< 'wildcharm'
+EXTERN int p_wic; ///< 'wildignorecase'
+EXTERN char *p_wim; ///< 'wildmode'
+EXTERN int p_wmnu; ///< 'wildmenu'
+EXTERN OptInt p_wh; ///< 'winheight'
+EXTERN OptInt p_wmh; ///< 'winminheight'
+EXTERN OptInt p_wmw; ///< 'winminwidth'
+EXTERN OptInt p_wiw; ///< 'winwidth'
+EXTERN OptInt p_wm; ///< 'wrapmargin'
+EXTERN int p_ws; ///< 'wrapscan'
+EXTERN int p_write; ///< 'write'
+EXTERN int p_wa; ///< 'writeany'
+EXTERN int p_wb; ///< 'writebackup'
+EXTERN OptInt p_wd; ///< 'writedelay'
+EXTERN int p_cdh; ///< 'cdhome'
+
+EXTERN int p_force_on; ///< options that cannot be turned off.
+EXTERN int p_force_off; ///< options that cannot be turned on.
+
+/// "indir" values for buffer-local options.
+/// These need to be defined globally, so that the BV_COUNT can be used with
+/// b_p_script_stx[].
+enum {
+ BV_AI = 0,
+ BV_AR,
+ BV_BH,
+ BV_BKC,
+ BV_BT,
+ BV_EFM,
+ BV_GP,
+ BV_MP,
+ BV_BIN,
+ BV_BL,
+ BV_BOMB,
+ BV_CHANNEL,
+ BV_CI,
+ BV_CIN,
+ BV_CINK,
+ BV_CINO,
+ BV_CINW,
+ BV_CINSD,
+ BV_CM,
+ BV_CMS,
+ BV_COM,
+ BV_CPT,
+ BV_DICT,
+ BV_TSR,
+ BV_CSL,
+ BV_CFU,
+ BV_DEF,
+ BV_INC,
+ BV_EOF,
+ BV_EOL,
+ BV_FIXEOL,
+ BV_EP,
+ BV_ET,
+ BV_FENC,
+ BV_FP,
+ BV_BEXPR,
+ BV_FEX,
+ BV_FF,
+ BV_FLP,
+ BV_FO,
+ BV_FT,
+ BV_IMI,
+ BV_IMS,
+ BV_INDE,
+ BV_INDK,
+ BV_INEX,
+ BV_INF,
+ BV_ISK,
+ BV_KMAP,
+ BV_KP,
+ BV_LISP,
+ BV_LOP,
+ BV_LW,
+ BV_MENC,
+ BV_MA,
+ BV_ML,
+ BV_MOD,
+ BV_MPS,
+ BV_NF,
+ BV_OFU,
+ BV_PATH,
+ BV_PI,
+ BV_QE,
+ BV_RO,
+ BV_SCBK,
+ BV_SI,
+ BV_SMC,
+ BV_SYN,
+ BV_SPC,
+ BV_SPF,
+ BV_SPL,
+ BV_SPO,
+ BV_STS,
+ BV_SUA,
+ BV_SW,
+ BV_SWF,
+ BV_TFU,
+ BV_TSRFU,
+ BV_TAGS,
+ BV_TC,
+ BV_TS,
+ BV_TW,
+ BV_TX,
+ BV_UDF,
+ BV_UL,
+ BV_WM,
+ BV_VSTS,
+ BV_VTS,
+ BV_COUNT, // must be the last one
+};
+
+/// "indir" values for window-local options.
+/// These need to be defined globally, so that the WV_COUNT can be used in the
+/// window structure.
+enum {
+ WV_LIST = 0,
+ WV_ARAB,
+ WV_COCU,
+ WV_COLE,
+ WV_CRBIND,
+ WV_BRI,
+ WV_BRIOPT,
+ WV_DIFF,
+ WV_FDC,
+ WV_FEN,
+ WV_FDI,
+ WV_FDL,
+ WV_FDM,
+ WV_FML,
+ WV_FDN,
+ WV_FDE,
+ WV_FDT,
+ WV_FMR,
+ WV_LBR,
+ WV_NU,
+ WV_RNU,
+ WV_VE,
+ WV_NUW,
+ WV_PVW,
+ WV_RL,
+ WV_RLC,
+ WV_SCBIND,
+ WV_SCROLL,
+ WV_SMS,
+ WV_SISO,
+ WV_SO,
+ WV_SPELL,
+ WV_CUC,
+ WV_CUL,
+ WV_CULOPT,
+ WV_CC,
+ WV_SBR,
+ WV_STC,
+ WV_STL,
+ WV_WFH,
+ WV_WFW,
+ WV_WRAP,
+ WV_SCL,
+ WV_WINHL,
+ WV_LCS,
+ WV_FCS,
+ WV_WINBL,
+ WV_WBR,
+ WV_COUNT, // must be the last one
+};
+
+// Value for b_p_ul indicating the global value must be used.
+#define NO_LOCAL_UNDOLEVEL (-123456)
+
+#define SB_MAX 100000 // Maximum 'scrollback' value.
+
+#define MAX_NUMBERWIDTH 20 // used for 'numberwidth' and 'statuscolumn'
+
+#define TABSTOP_MAX 9999
+
+#endif // NVIM_OPTION_VARS_H
diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c
index 44d558312e..750941da07 100644
--- a/src/nvim/optionstr.c
+++ b/src/nvim/optionstr.c
@@ -28,29 +28,25 @@
#include "nvim/indent.h"
#include "nvim/indent_c.h"
#include "nvim/insexpand.h"
-#include "nvim/keycodes.h"
#include "nvim/macros.h"
-#include "nvim/mapping.h"
#include "nvim/mbyte.h"
#include "nvim/memline.h"
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/mouse.h"
#include "nvim/move.h"
-#include "nvim/ops.h"
#include "nvim/option.h"
#include "nvim/option_defs.h"
+#include "nvim/option_vars.h"
#include "nvim/optionstr.h"
#include "nvim/os/os.h"
#include "nvim/pos.h"
-#include "nvim/quickfix.h"
#include "nvim/runtime.h"
#include "nvim/spell.h"
#include "nvim/spellfile.h"
#include "nvim/spellsuggest.h"
-#include "nvim/statusline.h"
#include "nvim/strings.h"
-#include "nvim/tag.h"
+#include "nvim/types.h"
#include "nvim/ui.h"
#include "nvim/vim.h"
#include "nvim/window.h"
@@ -523,71 +519,6 @@ static bool valid_filetype(const char *val)
return valid_name(val, ".-_");
}
-/// Handle setting 'mousescroll'.
-/// @return error message, NULL if it's OK.
-const char *did_set_mousescroll(optset_T *args FUNC_ATTR_UNUSED)
-{
- OptInt vertical = -1;
- OptInt horizontal = -1;
-
- char *string = p_mousescroll;
-
- while (true) {
- char *end = vim_strchr(string, ',');
- size_t length = end ? (size_t)(end - string) : strlen(string);
-
- // Both "ver:" and "hor:" are 4 bytes long.
- // They should be followed by at least one digit.
- if (length <= 4) {
- return e_invarg;
- }
-
- OptInt *direction;
-
- if (memcmp(string, "ver:", 4) == 0) {
- direction = &vertical;
- } else if (memcmp(string, "hor:", 4) == 0) {
- direction = &horizontal;
- } else {
- return e_invarg;
- }
-
- // If the direction has already been set, this is a duplicate.
- if (*direction != -1) {
- return e_invarg;
- }
-
- // Verify that only digits follow the colon.
- for (size_t i = 4; i < length; i++) {
- if (!ascii_isdigit(string[i])) {
- return N_("E5080: Digit expected");
- }
- }
-
- string += 4;
- *direction = getdigits_int(&string, false, -1);
-
- // Num options are generally kept within the signed int range.
- // We know this number won't be negative because we've already checked for
- // a minus sign. We'll allow 0 as a means of disabling mouse scrolling.
- if (*direction == -1) {
- return e_invarg;
- }
-
- if (!end) {
- break;
- }
-
- string = end + 1;
- }
-
- // If a direction wasn't set, fallback to the default value.
- p_mousescroll_vert = (vertical == -1) ? MOUSESCROLL_VERT_DFLT : vertical;
- p_mousescroll_hor = (horizontal == -1) ? MOUSESCROLL_HOR_DFLT : horizontal;
-
- return NULL;
-}
-
/// Handle setting 'signcolumn' for value 'val'
///
/// @return OK when the value is valid, FAIL otherwise
@@ -699,6 +630,81 @@ static bool check_illegal_path_names(char *val, uint32_t flags)
&& strpbrk(val, "*?[|;&<>\r\n") != NULL));
}
+/// An option that accepts a list of flags is changed.
+/// e.g. 'viewoptions', 'switchbuf', 'casemap', etc.
+static const char *did_set_opt_flags(char *val, char **values, unsigned *flagp, bool list)
+{
+ if (opt_strings_flags(val, values, flagp, list) != OK) {
+ return e_invarg;
+ }
+ return NULL;
+}
+
+/// An option that accepts a list of string values is changed.
+/// e.g. 'nrformats', 'scrollopt', 'wildoptions', etc.
+static const char *did_set_opt_strings(char *val, char **values, bool list)
+{
+ return did_set_opt_flags(val, values, NULL, list);
+}
+
+/// An option which is a list of flags is set. Valid values are in "flags".
+static const char *did_set_option_listflag(char *val, char *flags, char *errbuf, size_t errbuflen)
+{
+ for (char *s = val; *s; s++) {
+ if (vim_strchr(flags, (uint8_t)(*s)) == NULL) {
+ return illegal_char(errbuf, errbuflen, (uint8_t)(*s));
+ }
+ }
+
+ return NULL;
+}
+
+/// The 'ambiwidth' option is changed.
+const char *did_set_ambiwidth(optset_T *args FUNC_ATTR_UNUSED)
+{
+ if (check_opt_strings(p_ambw, p_ambw_values, false) != OK) {
+ return e_invarg;
+ }
+ return check_chars_options();
+}
+
+/// The 'background' option is changed.
+const char *did_set_background(optset_T *args FUNC_ATTR_UNUSED)
+{
+ if (check_opt_strings(p_bg, p_bg_values, false) != OK) {
+ return e_invarg;
+ }
+
+ int dark = (*p_bg == 'd');
+
+ init_highlight(false, false);
+
+ if (dark != (*p_bg == 'd') && get_var_value("g:colors_name") != NULL) {
+ // The color scheme must have set 'background' back to another
+ // value, that's not what we want here. Disable the color
+ // scheme and set the colors again.
+ do_unlet(S_LEN("g:colors_name"), true);
+ free_string_option(p_bg);
+ p_bg = xstrdup((dark ? "dark" : "light"));
+ check_string_option(&p_bg);
+ init_highlight(false, false);
+ }
+ return NULL;
+}
+
+/// The 'backspace' option is changed.
+const char *did_set_backspace(optset_T *args FUNC_ATTR_UNUSED)
+{
+ if (ascii_isdigit(*p_bs)) {
+ if (*p_bs != '2') {
+ return e_invarg;
+ }
+ } else if (check_opt_strings(p_bs, p_bs_values, true) != OK) {
+ return e_invarg;
+ }
+ return NULL;
+}
+
/// The 'backupcopy' option is changed.
const char *did_set_backupcopy(optset_T *args)
{
@@ -750,12 +756,6 @@ const char *did_set_belloff(optset_T *args FUNC_ATTR_UNUSED)
return did_set_opt_flags(p_bo, p_bo_values, &bo_flags, true);
}
-/// The 'termpastefilter' option is changed.
-const char *did_set_termpastefilter(optset_T *args FUNC_ATTR_UNUSED)
-{
- return did_set_opt_flags(p_tpf, p_tpf_values, &tpf_flags, true);
-}
-
/// The 'breakindentopt' option is changed.
const char *did_set_breakindentopt(optset_T *args)
{
@@ -771,160 +771,236 @@ const char *did_set_breakindentopt(optset_T *args)
return NULL;
}
-/// The 'isident' or the 'iskeyword' or the 'isprint' or the 'isfname' option is
-/// changed.
-const char *did_set_isopt(optset_T *args)
+/// The 'bufhidden' option is changed.
+const char *did_set_bufhidden(optset_T *args)
{
buf_T *buf = (buf_T *)args->os_buf;
- // 'isident', 'iskeyword', 'isprint or 'isfname' option: refill g_chartab[]
- // If the new option is invalid, use old value.
- // 'lisp' option: refill g_chartab[] for '-' char
- if (buf_init_chartab(buf, true) == FAIL) {
- args->os_restore_chartab = true; // need to restore it below
- return e_invarg; // error in value
- }
- return NULL;
+ return did_set_opt_strings(buf->b_p_bh, p_bufhidden_values, false);
}
-/// The 'helpfile' option is changed.
-const char *did_set_helpfile(optset_T *args FUNC_ATTR_UNUSED)
+/// The 'buftype' option is changed.
+const char *did_set_buftype(optset_T *args)
{
- // May compute new values for $VIM and $VIMRUNTIME
- if (didset_vim) {
- vim_unsetenv_ext("VIM");
+ buf_T *buf = (buf_T *)args->os_buf;
+ win_T *win = (win_T *)args->os_win;
+ // When 'buftype' is set, check for valid value.
+ if ((buf->terminal && buf->b_p_bt[0] != 't')
+ || (!buf->terminal && buf->b_p_bt[0] == 't')
+ || check_opt_strings(buf->b_p_bt, p_buftype_values, false) != OK) {
+ return e_invarg;
}
- if (didset_vimruntime) {
- vim_unsetenv_ext("VIMRUNTIME");
+ if (win->w_status_height || global_stl_height()) {
+ win->w_redr_status = true;
+ redraw_later(win, UPD_VALID);
}
+ buf->b_help = (buf->b_p_bt[0] == 'h');
+ redraw_titles();
return NULL;
}
-/// The 'cursorlineopt' option is changed.
-const char *did_set_cursorlineopt(optset_T *args)
+/// The 'casemap' option is changed.
+const char *did_set_casemap(optset_T *args FUNC_ATTR_UNUSED)
{
- win_T *win = (win_T *)args->os_win;
- char **varp = (char **)args->os_varp;
+ return did_set_opt_flags(p_cmp, p_cmp_values, &cmp_flags, true);
+}
- if (**varp == NUL || fill_culopt_flags(*varp, win) != OK) {
- return e_invarg;
+/// The global 'listchars' or 'fillchars' option is changed.
+static const char *did_set_global_listfillchars(win_T *win, char *val, bool opt_lcs, int opt_flags)
+{
+ const char *errmsg = NULL;
+ char **local_ptr = opt_lcs ? &win->w_p_lcs : &win->w_p_fcs;
+
+ // only apply the global value to "win" when it does not have a
+ // local value
+ if (opt_lcs) {
+ errmsg = set_listchars_option(win, val, **local_ptr == NUL || !(opt_flags & OPT_GLOBAL));
+ } else {
+ errmsg = set_fillchars_option(win, val, **local_ptr == NUL || !(opt_flags & OPT_GLOBAL));
+ }
+ if (errmsg != NULL) {
+ return errmsg;
}
- return NULL;
-}
+ // If the current window is set to use the global
+ // 'listchars'/'fillchars' value, clear the window-local value.
+ if (!(opt_flags & OPT_GLOBAL)) {
+ clear_string_option(local_ptr);
+ }
-/// The 'helplang' option is changed.
-const char *did_set_helplang(optset_T *args FUNC_ATTR_UNUSED)
-{
- // Check for "", "ab", "ab,cd", etc.
- for (char *s = p_hlg; *s != NUL; s += 3) {
- if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL)) {
- return e_invarg;
- }
- if (s[2] == NUL) {
- break;
+ FOR_ALL_TAB_WINDOWS(tp, wp) {
+ // If the current window has a local value need to apply it
+ // again, it was changed when setting the global value.
+ // If no error was returned above, we don't expect an error
+ // here, so ignore the return value.
+ if (opt_lcs) {
+ if (*wp->w_p_lcs == NUL) {
+ (void)set_listchars_option(wp, wp->w_p_lcs, true);
+ }
+ } else {
+ if (*wp->w_p_fcs == NUL) {
+ (void)set_fillchars_option(wp, wp->w_p_fcs, true);
+ }
}
}
+
+ redraw_all_later(UPD_NOT_VALID);
+
return NULL;
}
-/// The 'highlight' option is changed.
-const char *did_set_highlight(optset_T *args)
+/// The 'fillchars' option or the 'listchars' option is changed.
+const char *did_set_chars_option(optset_T *args)
{
+ win_T *win = (win_T *)args->os_win;
char **varp = (char **)args->os_varp;
+ const char *errmsg = NULL;
- if (strcmp(*varp, HIGHLIGHT_INIT) != 0) {
- return e_unsupportedoption;
+ if (varp == &p_lcs // global 'listchars'
+ || varp == &p_fcs) { // global 'fillchars'
+ errmsg = did_set_global_listfillchars(win, *varp, varp == &p_lcs, args->os_flags);
+ } else if (varp == &win->w_p_lcs) { // local 'listchars'
+ errmsg = set_listchars_option(win, *varp, true);
+ } else if (varp == &win->w_p_fcs) { // local 'fillchars'
+ errmsg = set_fillchars_option(win, *varp, true);
}
- return NULL;
+
+ return errmsg;
}
-static const char *did_set_opt_flags(char *val, char **values, unsigned *flagp, bool list)
+/// The 'cinoptions' option is changed.
+const char *did_set_cinoptions(optset_T *args FUNC_ATTR_UNUSED)
{
- if (opt_strings_flags(val, values, flagp, list) != OK) {
- return e_invarg;
- }
+ // TODO(vim): recognize errors
+ parse_cino(curbuf);
+
return NULL;
}
-static const char *did_set_opt_strings(char *val, char **values, bool list)
+/// The 'clipboard' option is changed.
+const char *did_set_clipboard(optset_T *args FUNC_ATTR_UNUSED)
{
- return did_set_opt_flags(val, values, NULL, list);
+ return did_set_opt_flags(p_cb, p_cb_values, &cb_flags, true);
}
-/// The 'selectmode' option is changed.
-const char *did_set_selectmode(optset_T *args FUNC_ATTR_UNUSED)
+/// The 'colorcolumn' option is changed.
+const char *did_set_colorcolumn(optset_T *args)
{
- return did_set_opt_strings(p_slm, p_slm_values, true);
+ win_T *win = (win_T *)args->os_win;
+ return check_colorcolumn(win);
}
-/// The 'inccommand' option is changed.
-const char *did_set_inccommand(optset_T *args FUNC_ATTR_UNUSED)
+/// The 'comments' option is changed.
+const char *did_set_comments(optset_T *args)
{
- return did_set_opt_strings(p_icm, p_icm_values, false);
+ char **varp = (char **)args->os_varp;
+ char *errmsg = NULL;
+ for (char *s = *varp; *s;) {
+ while (*s && *s != ':') {
+ if (vim_strchr(COM_ALL, (uint8_t)(*s)) == NULL
+ && !ascii_isdigit(*s) && *s != '-') {
+ errmsg = illegal_char(args->os_errbuf, args->os_errbuflen, (uint8_t)(*s));
+ break;
+ }
+ s++;
+ }
+ if (*s++ == NUL) {
+ errmsg = N_("E524: Missing colon");
+ } else if (*s == ',' || *s == NUL) {
+ errmsg = N_("E525: Zero length string");
+ }
+ if (errmsg != NULL) {
+ break;
+ }
+ while (*s && *s != ',') {
+ if (*s == '\\' && s[1] != NUL) {
+ s++;
+ }
+ s++;
+ }
+ s = skip_to_option_part(s);
+ }
+ return errmsg;
}
-/// The 'sessionoptions' option is changed.
-const char *did_set_sessionoptions(optset_T *args)
+/// The 'commentstring' option is changed.
+const char *did_set_commentstring(optset_T *args)
{
- if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, true) != OK) {
- return e_invarg;
- }
- if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR)) {
- // Don't allow both "sesdir" and "curdir".
- const char *oldval = args->os_oldval.string;
- (void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, true);
- return e_invarg;
+ char **varp = (char **)args->os_varp;
+
+ if (**varp != NUL && strstr(*varp, "%s") == NULL) {
+ return N_("E537: 'commentstring' must be empty or contain %s");
}
return NULL;
}
-/// The 'ambiwidth' option is changed.
-const char *did_set_ambiwidth(optset_T *args FUNC_ATTR_UNUSED)
+/// The 'complete' option is changed.
+const char *did_set_complete(optset_T *args)
{
- if (check_opt_strings(p_ambw, p_ambw_values, false) != OK) {
- return e_invarg;
+ char **varp = (char **)args->os_varp;
+
+ // check if it is a valid value for 'complete' -- Acevedo
+ for (char *s = *varp; *s;) {
+ while (*s == ',' || *s == ' ') {
+ s++;
+ }
+ if (!*s) {
+ break;
+ }
+ if (vim_strchr(".wbuksid]tU", (uint8_t)(*s)) == NULL) {
+ return illegal_char(args->os_errbuf, args->os_errbuflen, (uint8_t)(*s));
+ }
+ if (*++s != NUL && *s != ',' && *s != ' ') {
+ if (s[-1] == 'k' || s[-1] == 's') {
+ // skip optional filename after 'k' and 's'
+ while (*s && *s != ',' && *s != ' ') {
+ if (*s == '\\' && s[1] != NUL) {
+ s++;
+ }
+ s++;
+ }
+ } else {
+ if (args->os_errbuf != NULL) {
+ vim_snprintf(args->os_errbuf, args->os_errbuflen,
+ _("E535: Illegal character after <%c>"),
+ *--s);
+ return args->os_errbuf;
+ }
+ return "";
+ }
+ }
}
- return check_chars_options();
+ return NULL;
}
-/// The 'background' option is changed.
-const char *did_set_background(optset_T *args FUNC_ATTR_UNUSED)
+/// The 'completeopt' option is changed.
+const char *did_set_completeopt(optset_T *args FUNC_ATTR_UNUSED)
{
- if (check_opt_strings(p_bg, p_bg_values, false) != OK) {
+ if (check_opt_strings(p_cot, p_cot_values, true) != OK) {
return e_invarg;
}
-
- int dark = (*p_bg == 'd');
-
- init_highlight(false, false);
-
- if (dark != (*p_bg == 'd') && get_var_value("g:colors_name") != NULL) {
- // The color scheme must have set 'background' back to another
- // value, that's not what we want here. Disable the color
- // scheme and set the colors again.
- do_unlet(S_LEN("g:colors_name"), true);
- free_string_option(p_bg);
- p_bg = xstrdup((dark ? "dark" : "light"));
- check_string_option(&p_bg);
- init_highlight(false, false);
- }
+ completeopt_was_set();
return NULL;
}
-/// The 'whichwrap' option is changed.
-const char *did_set_whichwrap(optset_T *args)
+#ifdef BACKSLASH_IN_FILENAME
+/// The 'completeslash' option is changed.
+const char *did_set_completeslash(optset_T *args)
{
- char **varp = (char **)args->os_varp;
-
- return did_set_option_listflag(*varp, WW_ALL, args->os_errbuf, args->os_errbuflen);
+ buf_T *buf = (buf_T *)args->os_buf;
+ if (check_opt_strings(p_csl, p_csl_values, false) != OK
+ || check_opt_strings(buf->b_p_csl, p_csl_values, false) != OK) {
+ return e_invarg;
+ }
+ return NULL;
}
+#endif
-/// The 'shortmess' option is changed.
-const char *did_set_shortmess(optset_T *args)
+/// The 'concealcursor' option is changed.
+const char *did_set_concealcursor(optset_T *args)
{
char **varp = (char **)args->os_varp;
- return did_set_option_listflag(*varp, SHM_ALL, args->os_errbuf, args->os_errbuflen);
+ return did_set_option_listflag(*varp, COCU_ALL, args->os_errbuf, args->os_errbuflen);
}
/// The 'cpoptions' option is changed.
@@ -935,66 +1011,42 @@ const char *did_set_cpoptions(optset_T *args)
return did_set_option_listflag(*varp, CPO_VI, args->os_errbuf, args->os_errbuflen);
}
-/// The 'clipboard' option is changed.
-const char *did_set_clipboard(optset_T *args FUNC_ATTR_UNUSED)
-{
- return did_set_opt_flags(p_cb, p_cb_values, &cb_flags, true);
-}
-
-/// The 'foldopen' option is changed.
-const char *did_set_foldopen(optset_T *args FUNC_ATTR_UNUSED)
-{
- return did_set_opt_flags(p_fdo, p_fdo_values, &fdo_flags, true);
-}
-
-/// The 'formatoptions' option is changed.
-const char *did_set_formatoptions(optset_T *args)
-{
- char **varp = (char **)args->os_varp;
-
- return did_set_option_listflag(*varp, FO_ALL, args->os_errbuf, args->os_errbuflen);
-}
-
-/// The 'concealcursor' option is changed.
-const char *did_set_concealcursor(optset_T *args)
+/// The 'cursorlineopt' option is changed.
+const char *did_set_cursorlineopt(optset_T *args)
{
+ win_T *win = (win_T *)args->os_win;
char **varp = (char **)args->os_varp;
- return did_set_option_listflag(*varp, COCU_ALL, args->os_errbuf, args->os_errbuflen);
-}
-
-/// The 'mouse' option is changed.
-const char *did_set_mouse(optset_T *args)
-{
- char **varp = (char **)args->os_varp;
+ if (**varp == NUL || fill_culopt_flags(*varp, win) != OK) {
+ return e_invarg;
+ }
- return did_set_option_listflag(*varp, MOUSE_ALL, args->os_errbuf, args->os_errbuflen);
+ return NULL;
}
-/// The 'wildmode' option is changed.
-const char *did_set_wildmode(optset_T *args FUNC_ATTR_UNUSED)
+/// The 'debug' option is changed.
+const char *did_set_debug(optset_T *args FUNC_ATTR_UNUSED)
{
- if (check_opt_wim() == FAIL) {
- return e_invarg;
- }
- return NULL;
+ return did_set_opt_strings(p_debug, p_debug_values, false);
}
-/// The 'winaltkeys' option is changed.
-const char *did_set_winaltkeys(optset_T *args FUNC_ATTR_UNUSED)
+/// The 'diffopt' option is changed.
+const char *did_set_diffopt(optset_T *args FUNC_ATTR_UNUSED)
{
- if (*p_wak == NUL || check_opt_strings(p_wak, p_wak_values, false) != OK) {
+ if (diffopt_changed() == FAIL) {
return e_invarg;
}
return NULL;
}
-/// The 'eventignore' option is changed.
-const char *did_set_eventignore(optset_T *args FUNC_ATTR_UNUSED)
+/// The 'display' option is changed.
+const char *did_set_display(optset_T *args FUNC_ATTR_UNUSED)
{
- if (check_ei() == FAIL) {
+ if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, true) != OK) {
return e_invarg;
}
+ (void)init_chartab();
+ msg_grid_validate();
return NULL;
}
@@ -1046,6 +1098,229 @@ const char *did_set_encoding(optset_T *args)
return NULL;
}
+/// The 'eventignore' option is changed.
+const char *did_set_eventignore(optset_T *args FUNC_ATTR_UNUSED)
+{
+ if (check_ei() == FAIL) {
+ return e_invarg;
+ }
+ return NULL;
+}
+
+/// The 'fileformat' option is changed.
+const char *did_set_fileformat(optset_T *args)
+{
+ buf_T *buf = (buf_T *)args->os_buf;
+ char **varp = (char **)args->os_varp;
+ const char *oldval = args->os_oldval.string;
+ int opt_flags = args->os_flags;
+ if (!MODIFIABLE(buf) && !(opt_flags & OPT_GLOBAL)) {
+ return e_modifiable;
+ } else if (check_opt_strings(*varp, p_ff_values, false) != OK) {
+ return e_invarg;
+ }
+ redraw_titles();
+ // update flag in swap file
+ ml_setflags(buf);
+ // Redraw needed when switching to/from "mac": a CR in the text
+ // will be displayed differently.
+ if (get_fileformat(buf) == EOL_MAC || *oldval == 'm') {
+ redraw_buf_later(buf, UPD_NOT_VALID);
+ }
+ return NULL;
+}
+
+/// The 'fileformats' option is changed.
+const char *did_set_fileformats(optset_T *args)
+{
+ return did_set_opt_strings(p_ffs, p_ff_values, true);
+}
+
+/// The 'filetype' or the 'syntax' option is changed.
+const char *did_set_filetype_or_syntax(optset_T *args)
+{
+ char **varp = (char **)args->os_varp;
+
+ if (!valid_filetype(*varp)) {
+ return e_invarg;
+ }
+
+ args->os_value_changed = strcmp(args->os_oldval.string, *varp) != 0;
+
+ // Since we check the value, there is no need to set P_INSECURE,
+ // even when the value comes from a modeline.
+ args->os_value_checked = true;
+
+ return NULL;
+}
+
+/// The 'foldclose' option is changed.
+const char *did_set_foldclose(optset_T *args FUNC_ATTR_UNUSED)
+{
+ return did_set_opt_strings(p_fcl, p_fcl_values, true);
+}
+
+/// The 'foldcolumn' option is changed.
+const char *did_set_foldcolumn(optset_T *args)
+{
+ char **varp = (char **)args->os_varp;
+ if (**varp == NUL || check_opt_strings(*varp, p_fdc_values, false) != OK) {
+ return e_invarg;
+ }
+ return NULL;
+}
+
+/// The 'foldexpr' option is changed.
+const char *did_set_foldexpr(optset_T *args)
+{
+ win_T *win = (win_T *)args->os_win;
+ (void)did_set_optexpr(args);
+ if (foldmethodIsExpr(win)) {
+ foldUpdateAll(win);
+ }
+ return NULL;
+}
+
+/// The 'foldignore' option is changed.
+const char *did_set_foldignore(optset_T *args)
+{
+ win_T *win = (win_T *)args->os_win;
+ if (foldmethodIsIndent(win)) {
+ foldUpdateAll(win);
+ }
+ return NULL;
+}
+
+/// The 'foldmarker' option is changed.
+const char *did_set_foldmarker(optset_T *args)
+{
+ win_T *win = (win_T *)args->os_win;
+ char **varp = (char **)args->os_varp;
+ char *p = vim_strchr(*varp, ',');
+
+ if (p == NULL) {
+ return e_comma_required;
+ }
+
+ if (p == *varp || p[1] == NUL) {
+ return e_invarg;
+ }
+
+ if (foldmethodIsMarker(win)) {
+ foldUpdateAll(win);
+ }
+
+ return NULL;
+}
+
+/// The 'foldmethod' option is changed.
+const char *did_set_foldmethod(optset_T *args)
+{
+ win_T *win = (win_T *)args->os_win;
+ char **varp = (char **)args->os_varp;
+ if (check_opt_strings(*varp, p_fdm_values, false) != OK
+ || *win->w_p_fdm == NUL) {
+ return e_invarg;
+ }
+ foldUpdateAll(win);
+ if (foldmethodIsDiff(win)) {
+ newFoldLevel();
+ }
+ return NULL;
+}
+
+/// The 'foldopen' option is changed.
+const char *did_set_foldopen(optset_T *args FUNC_ATTR_UNUSED)
+{
+ return did_set_opt_flags(p_fdo, p_fdo_values, &fdo_flags, true);
+}
+
+/// The 'formatoptions' option is changed.
+const char *did_set_formatoptions(optset_T *args)
+{
+ char **varp = (char **)args->os_varp;
+
+ return did_set_option_listflag(*varp, FO_ALL, args->os_errbuf, args->os_errbuflen);
+}
+
+/// The 'guicursor' option is changed.
+const char *did_set_guicursor(optset_T *args FUNC_ATTR_UNUSED)
+{
+ return parse_shape_opt(SHAPE_CURSOR);
+}
+
+/// The 'helpfile' option is changed.
+const char *did_set_helpfile(optset_T *args FUNC_ATTR_UNUSED)
+{
+ // May compute new values for $VIM and $VIMRUNTIME
+ if (didset_vim) {
+ vim_unsetenv_ext("VIM");
+ }
+ if (didset_vimruntime) {
+ vim_unsetenv_ext("VIMRUNTIME");
+ }
+ return NULL;
+}
+
+/// The 'helplang' option is changed.
+const char *did_set_helplang(optset_T *args FUNC_ATTR_UNUSED)
+{
+ // Check for "", "ab", "ab,cd", etc.
+ for (char *s = p_hlg; *s != NUL; s += 3) {
+ if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL)) {
+ return e_invarg;
+ }
+ if (s[2] == NUL) {
+ break;
+ }
+ }
+ return NULL;
+}
+
+/// The 'highlight' option is changed.
+const char *did_set_highlight(optset_T *args)
+{
+ char **varp = (char **)args->os_varp;
+
+ if (strcmp(*varp, HIGHLIGHT_INIT) != 0) {
+ return e_unsupportedoption;
+ }
+ return NULL;
+}
+
+/// The 'iconstring' option is changed.
+const char *did_set_iconstring(optset_T *args)
+{
+ return did_set_titleiconstring(args, STL_IN_ICON);
+}
+
+/// The 'inccommand' option is changed.
+const char *did_set_inccommand(optset_T *args FUNC_ATTR_UNUSED)
+{
+ return did_set_opt_strings(p_icm, p_icm_values, false);
+}
+
+/// The 'isident' or the 'iskeyword' or the 'isprint' or the 'isfname' option is
+/// changed.
+const char *did_set_isopt(optset_T *args)
+{
+ buf_T *buf = (buf_T *)args->os_buf;
+ // 'isident', 'iskeyword', 'isprint or 'isfname' option: refill g_chartab[]
+ // If the new option is invalid, use old value.
+ // 'lisp' option: refill g_chartab[] for '-' char
+ if (buf_init_chartab(buf, true) == FAIL) {
+ args->os_restore_chartab = true; // need to restore it below
+ return e_invarg; // error in value
+ }
+ return NULL;
+}
+
+/// The 'jumpoptions' option is changed.
+const char *did_set_jumpoptions(optset_T *args FUNC_ATTR_UNUSED)
+{
+ return did_set_opt_flags(p_jop, p_jop_values, &jop_flags, true);
+}
+
/// The 'keymap' option has changed.
const char *did_set_keymap(optset_T *args)
{
@@ -1098,33 +1373,26 @@ const char *did_set_keymap(optset_T *args)
return errmsg;
}
-/// The 'fileformat' option is changed.
-const char *did_set_fileformat(optset_T *args)
+/// The 'keymodel' option is changed.
+const char *did_set_keymodel(optset_T *args FUNC_ATTR_UNUSED)
{
- buf_T *buf = (buf_T *)args->os_buf;
- char **varp = (char **)args->os_varp;
- const char *oldval = args->os_oldval.string;
- int opt_flags = args->os_flags;
- if (!MODIFIABLE(buf) && !(opt_flags & OPT_GLOBAL)) {
- return e_modifiable;
- } else if (check_opt_strings(*varp, p_ff_values, false) != OK) {
+ if (check_opt_strings(p_km, p_km_values, true) != OK) {
return e_invarg;
}
- redraw_titles();
- // update flag in swap file
- ml_setflags(buf);
- // Redraw needed when switching to/from "mac": a CR in the text
- // will be displayed differently.
- if (get_fileformat(buf) == EOL_MAC || *oldval == 'm') {
- redraw_buf_later(buf, UPD_NOT_VALID);
- }
+ km_stopsel = (vim_strchr(p_km, 'o') != NULL);
+ km_startsel = (vim_strchr(p_km, 'a') != NULL);
return NULL;
}
-/// The 'fileformats' option is changed.
-const char *did_set_fileformats(optset_T *args)
+/// The 'lispoptions' option is changed.
+const char *did_set_lispoptions(optset_T *args)
{
- return did_set_opt_strings(p_ffs, p_ff_values, true);
+ char **varp = (char **)args->os_varp;
+
+ if (**varp != NUL && strcmp(*varp, "expr:0") != 0 && strcmp(*varp, "expr:1") != 0) {
+ return e_invarg;
+ }
+ return NULL;
}
/// The 'matchpairs' option is changed.
@@ -1154,150 +1422,183 @@ const char *did_set_matchpairs(optset_T *args)
return NULL;
}
-/// The 'cinoptions' option is changed.
-const char *did_set_cinoptions(optset_T *args FUNC_ATTR_UNUSED)
+/// The 'mkspellmem' option is changed.
+const char *did_set_mkspellmem(optset_T *args FUNC_ATTR_UNUSED)
{
- // TODO(vim): recognize errors
- parse_cino(curbuf);
-
+ if (spell_check_msm() != OK) {
+ return e_invarg;
+ }
return NULL;
}
-/// The 'colorcolumn' option is changed.
-const char *did_set_colorcolumn(optset_T *args)
+/// The 'mouse' option is changed.
+const char *did_set_mouse(optset_T *args)
{
- win_T *win = (win_T *)args->os_win;
- return check_colorcolumn(win);
+ char **varp = (char **)args->os_varp;
+
+ return did_set_option_listflag(*varp, MOUSE_ALL, args->os_errbuf, args->os_errbuflen);
}
-const char *did_set_comments(optset_T *args)
+/// The 'mousemodel' option is changed.
+const char *did_set_mousemodel(optset_T *args FUNC_ATTR_UNUSED)
{
- char **varp = (char **)args->os_varp;
- char *errmsg = NULL;
- for (char *s = *varp; *s;) {
- while (*s && *s != ':') {
- if (vim_strchr(COM_ALL, (uint8_t)(*s)) == NULL
- && !ascii_isdigit(*s) && *s != '-') {
- errmsg = illegal_char(args->os_errbuf, args->os_errbuflen, (uint8_t)(*s));
- break;
- }
- s++;
- }
- if (*s++ == NUL) {
- errmsg = N_("E524: Missing colon");
- } else if (*s == ',' || *s == NUL) {
- errmsg = N_("E525: Zero length string");
- }
- if (errmsg != NULL) {
- break;
- }
- while (*s && *s != ',') {
- if (*s == '\\' && s[1] != NUL) {
- s++;
- }
- s++;
- }
- s = skip_to_option_part(s);
- }
- return errmsg;
+ return did_set_opt_strings(p_mousem, p_mousem_values, false);
}
-/// The global 'listchars' or 'fillchars' option is changed.
-static const char *did_set_global_listfillchars(win_T *win, char *val, bool opt_lcs, int opt_flags)
+/// Handle setting 'mousescroll'.
+/// @return error message, NULL if it's OK.
+const char *did_set_mousescroll(optset_T *args FUNC_ATTR_UNUSED)
{
- const char *errmsg = NULL;
- char **local_ptr = opt_lcs ? &win->w_p_lcs : &win->w_p_fcs;
+ OptInt vertical = -1;
+ OptInt horizontal = -1;
- // only apply the global value to "win" when it does not have a
- // local value
- if (opt_lcs) {
- errmsg = set_listchars_option(win, val, **local_ptr == NUL || !(opt_flags & OPT_GLOBAL));
- } else {
- errmsg = set_fillchars_option(win, val, **local_ptr == NUL || !(opt_flags & OPT_GLOBAL));
- }
- if (errmsg != NULL) {
- return errmsg;
- }
+ char *string = p_mousescroll;
- // If the current window is set to use the global
- // 'listchars'/'fillchars' value, clear the window-local value.
- if (!(opt_flags & OPT_GLOBAL)) {
- clear_string_option(local_ptr);
- }
+ while (true) {
+ char *end = vim_strchr(string, ',');
+ size_t length = end ? (size_t)(end - string) : strlen(string);
- FOR_ALL_TAB_WINDOWS(tp, wp) {
- // If the current window has a local value need to apply it
- // again, it was changed when setting the global value.
- // If no error was returned above, we don't expect an error
- // here, so ignore the return value.
- if (opt_lcs) {
- if (*wp->w_p_lcs == NUL) {
- (void)set_listchars_option(wp, wp->w_p_lcs, true);
- }
+ // Both "ver:" and "hor:" are 4 bytes long.
+ // They should be followed by at least one digit.
+ if (length <= 4) {
+ return e_invarg;
+ }
+
+ OptInt *direction;
+
+ if (memcmp(string, "ver:", 4) == 0) {
+ direction = &vertical;
+ } else if (memcmp(string, "hor:", 4) == 0) {
+ direction = &horizontal;
} else {
- if (*wp->w_p_fcs == NUL) {
- (void)set_fillchars_option(wp, wp->w_p_fcs, true);
+ return e_invarg;
+ }
+
+ // If the direction has already been set, this is a duplicate.
+ if (*direction != -1) {
+ return e_invarg;
+ }
+
+ // Verify that only digits follow the colon.
+ for (size_t i = 4; i < length; i++) {
+ if (!ascii_isdigit(string[i])) {
+ return N_("E5080: Digit expected");
}
}
+
+ string += 4;
+ *direction = getdigits_int(&string, false, -1);
+
+ // Num options are generally kept within the signed int range.
+ // We know this number won't be negative because we've already checked for
+ // a minus sign. We'll allow 0 as a means of disabling mouse scrolling.
+ if (*direction == -1) {
+ return e_invarg;
+ }
+
+ if (!end) {
+ break;
+ }
+
+ string = end + 1;
}
- redraw_all_later(UPD_NOT_VALID);
+ // If a direction wasn't set, fallback to the default value.
+ p_mousescroll_vert = (vertical == -1) ? MOUSESCROLL_VERT_DFLT : vertical;
+ p_mousescroll_hor = (horizontal == -1) ? MOUSESCROLL_HOR_DFLT : horizontal;
return NULL;
}
-/// Handle the new value of 'fillchars'.
-const char *set_fillchars_option(win_T *wp, char *val, int apply)
+/// The 'nrformats' option is changed.
+const char *did_set_nrformats(optset_T *args)
{
- return set_chars_option(wp, val, false, apply);
+ char **varp = (char **)args->os_varp;
+
+ return did_set_opt_strings(*varp, p_nf_values, true);
}
-/// Handle the new value of 'listchars'.
-const char *set_listchars_option(win_T *wp, char *val, int apply)
+/// One of the '*expr' options is changed:, 'diffexpr', 'foldexpr', 'foldtext',
+/// 'formatexpr', 'includeexpr', 'indentexpr', 'patchexpr' and 'charconvert'.
+const char *did_set_optexpr(optset_T *args)
{
- return set_chars_option(wp, val, true, apply);
+ char **varp = (char **)args->os_varp;
+
+ // If the option value starts with <SID> or s:, then replace that with
+ // the script identifier.
+ char *name = get_scriptlocal_funcname(*varp);
+ if (name != NULL) {
+ free_string_option(*varp);
+ *varp = name;
+ }
+ return NULL;
}
-/// The 'fillchars' option or the 'listchars' option is changed.
-const char *did_set_chars_option(optset_T *args)
+/// The 'redrawdebug' option is changed.
+const char *did_set_redrawdebug(optset_T *args FUNC_ATTR_UNUSED)
+{
+ return did_set_opt_flags(p_rdb, p_rdb_values, &rdb_flags, true);
+}
+
+/// The 'rightleftcmd' option is changed.
+const char *did_set_rightleftcmd(optset_T *args)
{
- win_T *win = (win_T *)args->os_win;
char **varp = (char **)args->os_varp;
- const char *errmsg = NULL;
- if (varp == &p_lcs // global 'listchars'
- || varp == &p_fcs) { // global 'fillchars'
- errmsg = did_set_global_listfillchars(win, *varp, varp == &p_lcs, args->os_flags);
- } else if (varp == &win->w_p_lcs) { // local 'listchars'
- errmsg = set_listchars_option(win, *varp, true);
- } else if (varp == &win->w_p_fcs) { // local 'fillchars'
- errmsg = set_fillchars_option(win, *varp, true);
+ // Currently only "search" is a supported value.
+ if (**varp != NUL && strcmp(*varp, "search") != 0) {
+ return e_invarg;
}
- return errmsg;
+ return NULL;
}
-/// The 'verbosefile' option is changed.
-const char *did_set_verbosefile(optset_T *args)
+/// The 'rulerformat' option is changed.
+const char *did_set_rulerformat(optset_T *args)
{
- verbose_stop();
- if (*p_vfile != NUL && verbose_open() == FAIL) {
- return (char *)e_invarg;
+ return did_set_statustabline_rulerformat(args, true, false);
+}
+
+/// The 'scrollopt' option is changed.
+const char *did_set_scrollopt(optset_T *args FUNC_ATTR_UNUSED)
+{
+ return did_set_opt_strings(p_sbo, p_scbopt_values, true);
+}
+
+/// The 'selection' option is changed.
+const char *did_set_selection(optset_T *args FUNC_ATTR_UNUSED)
+{
+ if (*p_sel == NUL || check_opt_strings(p_sel, p_sel_values, false) != OK) {
+ return e_invarg;
}
return NULL;
}
-/// The 'viewoptions' option is changed.
-const char *did_set_viewoptions(optset_T *args FUNC_ATTR_UNUSED)
+/// The 'selectmode' option is changed.
+const char *did_set_selectmode(optset_T *args FUNC_ATTR_UNUSED)
{
- return did_set_opt_flags(p_vop, p_ssop_values, &vop_flags, true);
+ return did_set_opt_strings(p_slm, p_slm_values, true);
}
-static int shada_idx = -1;
+/// The 'sessionoptions' option is changed.
+const char *did_set_sessionoptions(optset_T *args)
+{
+ if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, true) != OK) {
+ return e_invarg;
+ }
+ if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR)) {
+ // Don't allow both "sesdir" and "curdir".
+ const char *oldval = args->os_oldval.string;
+ (void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, true);
+ return e_invarg;
+ }
+ return NULL;
+}
static const char *did_set_shada(vimoption_T **opt, int *opt_idx, bool *free_oldval, char *errbuf,
size_t errbuflen)
{
+ static int shada_idx = -1;
// TODO(ZyX-I): Remove this code in the future, alongside with &viminfo
// option.
*opt_idx = (((*opt)->fullname[0] == 'v')
@@ -1352,6 +1653,14 @@ static const char *did_set_shada(vimoption_T **opt, int *opt_idx, bool *free_old
return NULL;
}
+/// The 'shortmess' option is changed.
+const char *did_set_shortmess(optset_T *args)
+{
+ char **varp = (char **)args->os_varp;
+
+ return did_set_option_listflag(*varp, SHM_ALL, args->os_errbuf, args->os_errbuflen);
+}
+
/// The 'showbreak' option is changed.
const char *did_set_showbreak(optset_T *args)
{
@@ -1366,63 +1675,37 @@ const char *did_set_showbreak(optset_T *args)
return NULL;
}
-/// The 'titlestring' or the 'iconstring' option is changed.
-static const char *did_set_titleiconstring(optset_T *args, int flagval)
-{
- char **varp = (char **)args->os_varp;
-
- // NULL => statusline syntax
- if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL) {
- stl_syntax |= flagval;
- } else {
- stl_syntax &= ~flagval;
- }
- did_set_title();
-
- return NULL;
-}
-
-/// The 'titlestring' option is changed.
-const char *did_set_titlestring(optset_T *args)
-{
- return did_set_titleiconstring(args, STL_IN_TITLE);
-}
-
-/// The 'iconstring' option is changed.
-const char *did_set_iconstring(optset_T *args)
+/// The 'showcmdloc' option is changed.
+const char *did_set_showcmdloc(optset_T *args FUNC_ATTR_UNUSED)
{
- return did_set_titleiconstring(args, STL_IN_ICON);
+ return did_set_opt_strings(p_sloc, p_sloc_values, true);
}
-/// The 'selection' option is changed.
-const char *did_set_selection(optset_T *args FUNC_ATTR_UNUSED)
+/// The 'signcolumn' option is changed.
+const char *did_set_signcolumn(optset_T *args)
{
- if (*p_sel == NUL || check_opt_strings(p_sel, p_sel_values, false) != OK) {
+ win_T *win = (win_T *)args->os_win;
+ char **varp = (char **)args->os_varp;
+ const char *oldval = args->os_oldval.string;
+ if (check_signcolumn(*varp) != OK) {
return e_invarg;
}
- return NULL;
-}
-
-/// The 'keymodel' option is changed.
-const char *did_set_keymodel(optset_T *args FUNC_ATTR_UNUSED)
-{
- if (check_opt_strings(p_km, p_km_values, true) != OK) {
- return e_invarg;
+ // When changing the 'signcolumn' to or from 'number', recompute the
+ // width of the number column if 'number' or 'relativenumber' is set.
+ if (((*oldval == 'n' && *(oldval + 1) == 'u')
+ || (*win->w_p_scl == 'n' && *(win->w_p_scl + 1) == 'u'))
+ && (win->w_p_nu || win->w_p_rnu)) {
+ win->w_nrwidth_line_count = 0;
}
- km_stopsel = (vim_strchr(p_km, 'o') != NULL);
- km_startsel = (vim_strchr(p_km, 'a') != NULL);
return NULL;
}
-/// The 'display' option is changed.
-const char *did_set_display(optset_T *args FUNC_ATTR_UNUSED)
+/// The 'spellcapcheck' option is changed.
+const char *did_set_spellcapcheck(optset_T *args)
{
- if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, true) != OK) {
- return e_invarg;
- }
- (void)init_chartab();
- msg_grid_validate();
- return NULL;
+ win_T *win = (win_T *)args->os_win;
+ // When 'spellcapcheck' is set compile the regexp program.
+ return compile_cap_prog(win->w_s);
}
/// The 'spellfile' option is changed.
@@ -1438,6 +1721,7 @@ const char *did_set_spellfile(optset_T *args)
return did_set_spell_option(true);
}
+/// The 'spelllang' option is changed.
const char *did_set_spelllang(optset_T *args)
{
char **varp = (char **)args->os_varp;
@@ -1450,14 +1734,6 @@ const char *did_set_spelllang(optset_T *args)
return did_set_spell_option(false);
}
-/// The 'spellcapcheck' option is changed.
-const char *did_set_spellcapcheck(optset_T *args)
-{
- win_T *win = (win_T *)args->os_win;
- // When 'spellcapcheck' is set compile the regexp program.
- return compile_cap_prog(win->w_s);
-}
-
/// The 'spelloptions' option is changed.
const char *did_set_spelloptions(optset_T *args)
{
@@ -1484,52 +1760,16 @@ const char *did_set_splitkeep(optset_T *args FUNC_ATTR_UNUSED)
return did_set_opt_strings(p_spk, p_spk_values, false);
}
-/// The 'mkspellmem' option is changed.
-const char *did_set_mkspellmem(optset_T *args FUNC_ATTR_UNUSED)
-{
- if (spell_check_msm() != OK) {
- return e_invarg;
- }
- return NULL;
-}
-
-/// The 'mousemodel' option is changed.
-const char *did_set_mousemodel(optset_T *args FUNC_ATTR_UNUSED)
-{
- return did_set_opt_strings(p_mousem, p_mousem_values, false);
-}
-
-/// The 'bufhidden' option is changed.
-const char *did_set_bufhidden(optset_T *args)
-{
- buf_T *buf = (buf_T *)args->os_buf;
- return did_set_opt_strings(buf->b_p_bh, p_bufhidden_values, false);
-}
-
-/// The 'buftype' option is changed.
-const char *did_set_buftype(optset_T *args)
+/// The 'statuscolumn' option is changed.
+const char *did_set_statuscolumn(optset_T *args)
{
- buf_T *buf = (buf_T *)args->os_buf;
- win_T *win = (win_T *)args->os_win;
- // When 'buftype' is set, check for valid value.
- if ((buf->terminal && buf->b_p_bt[0] != 't')
- || (!buf->terminal && buf->b_p_bt[0] == 't')
- || check_opt_strings(buf->b_p_bt, p_buftype_values, false) != OK) {
- return e_invarg;
- }
- if (win->w_status_height || global_stl_height()) {
- win->w_redr_status = true;
- redraw_later(win, UPD_VALID);
- }
- buf->b_help = (buf->b_p_bt[0] == 'h');
- redraw_titles();
- return NULL;
+ return did_set_statustabline_rulerformat(args, false, true);
}
-/// The 'casemap' option is changed.
-const char *did_set_casemap(optset_T *args FUNC_ATTR_UNUSED)
+/// The 'statusline' option is changed.
+const char *did_set_statusline(optset_T *args)
{
- return did_set_opt_flags(p_cmp, p_cmp_values, &cmp_flags, true);
+ return did_set_statustabline_rulerformat(args, false, false);
}
/// The 'statusline', 'winbar', 'tabline', 'rulerformat' or 'statuscolumn' option is changed.
@@ -1571,10 +1811,10 @@ static const char *did_set_statustabline_rulerformat(optset_T *args, bool rulerf
return errmsg;
}
-/// The 'statusline' option is changed.
-const char *did_set_statusline(optset_T *args)
+/// The 'switchbuf' option is changed.
+const char *did_set_switchbuf(optset_T *args FUNC_ATTR_UNUSED)
{
- return did_set_statustabline_rulerformat(args, false, false);
+ return did_set_opt_flags(p_swb, p_swb_values, &swb_flags, true);
}
/// The 'tabline' option is changed.
@@ -1583,146 +1823,6 @@ const char *did_set_tabline(optset_T *args)
return did_set_statustabline_rulerformat(args, false, false);
}
-/// The 'rulerformat' option is changed.
-const char *did_set_rulerformat(optset_T *args)
-{
- return did_set_statustabline_rulerformat(args, true, false);
-}
-
-/// The 'winbar' option is changed.
-const char *did_set_winbar(optset_T *args)
-{
- return did_set_statustabline_rulerformat(args, false, false);
-}
-
-/// The 'statuscolumn' option is changed.
-const char *did_set_statuscolumn(optset_T *args)
-{
- return did_set_statustabline_rulerformat(args, false, true);
-}
-
-/// The 'scrollopt' option is changed.
-const char *did_set_scrollopt(optset_T *args FUNC_ATTR_UNUSED)
-{
- return did_set_opt_strings(p_sbo, p_scbopt_values, true);
-}
-
-/// The 'complete' option is changed.
-const char *did_set_complete(optset_T *args)
-{
- char **varp = (char **)args->os_varp;
-
- // check if it is a valid value for 'complete' -- Acevedo
- for (char *s = *varp; *s;) {
- while (*s == ',' || *s == ' ') {
- s++;
- }
- if (!*s) {
- break;
- }
- if (vim_strchr(".wbuksid]tU", (uint8_t)(*s)) == NULL) {
- return illegal_char(args->os_errbuf, args->os_errbuflen, (uint8_t)(*s));
- }
- if (*++s != NUL && *s != ',' && *s != ' ') {
- if (s[-1] == 'k' || s[-1] == 's') {
- // skip optional filename after 'k' and 's'
- while (*s && *s != ',' && *s != ' ') {
- if (*s == '\\' && s[1] != NUL) {
- s++;
- }
- s++;
- }
- } else {
- if (args->os_errbuf != NULL) {
- vim_snprintf(args->os_errbuf, args->os_errbuflen,
- _("E535: Illegal character after <%c>"),
- *--s);
- return args->os_errbuf;
- }
- return "";
- }
- }
- }
- return NULL;
-}
-
-/// The 'completeopt' option is changed.
-const char *did_set_completeopt(optset_T *args FUNC_ATTR_UNUSED)
-{
- if (check_opt_strings(p_cot, p_cot_values, true) != OK) {
- return e_invarg;
- }
- completeopt_was_set();
- return NULL;
-}
-
-#ifdef BACKSLASH_IN_FILENAME
-/// The 'completeslash' option is changed.
-const char *did_set_completeslash(optset_T *args)
-{
- buf_T *buf = (buf_T *)args->os_buf;
- if (check_opt_strings(p_csl, p_csl_values, false) != OK
- || check_opt_strings(buf->b_p_csl, p_csl_values, false) != OK) {
- return e_invarg;
- }
- return NULL;
-}
-#endif
-
-/// The 'showcmdloc' option is changed.
-const char *did_set_showcmdloc(optset_T *args FUNC_ATTR_UNUSED)
-{
- return did_set_opt_strings(p_sloc, p_sloc_values, true);
-}
-
-/// The 'signcolumn' option is changed.
-const char *did_set_signcolumn(optset_T *args)
-{
- win_T *win = (win_T *)args->os_win;
- char **varp = (char **)args->os_varp;
- const char *oldval = args->os_oldval.string;
- if (check_signcolumn(*varp) != OK) {
- return e_invarg;
- }
- // When changing the 'signcolumn' to or from 'number', recompute the
- // width of the number column if 'number' or 'relativenumber' is set.
- if (((*oldval == 'n' && *(oldval + 1) == 'u')
- || (*win->w_p_scl == 'n' && *(win->w_p_scl + 1) == 'u'))
- && (win->w_p_nu || win->w_p_rnu)) {
- win->w_nrwidth_line_count = 0;
- }
- return NULL;
-}
-
-/// The 'foldcolumn' option is changed.
-const char *did_set_foldcolumn(optset_T *args)
-{
- char **varp = (char **)args->os_varp;
- if (**varp == NUL || check_opt_strings(*varp, p_fdc_values, false) != OK) {
- return e_invarg;
- }
- return NULL;
-}
-
-/// The 'backspace' option is changed.
-const char *did_set_backspace(optset_T *args FUNC_ATTR_UNUSED)
-{
- if (ascii_isdigit(*p_bs)) {
- if (*p_bs != '2') {
- return e_invarg;
- }
- } else if (check_opt_strings(p_bs, p_bs_values, true) != OK) {
- return e_invarg;
- }
- return NULL;
-}
-
-/// The 'switchbuf' option is changed.
-const char *did_set_switchbuf(optset_T *args FUNC_ATTR_UNUSED)
-{
- return did_set_opt_flags(p_swb, p_swb_values, &swb_flags, true);
-}
-
/// The 'tagcase' option is changed.
const char *did_set_tagcase(optset_T *args)
{
@@ -1750,177 +1850,32 @@ const char *did_set_tagcase(optset_T *args)
return NULL;
}
-/// The 'debug' option is changed.
-const char *did_set_debug(optset_T *args FUNC_ATTR_UNUSED)
-{
- return did_set_opt_strings(p_debug, p_debug_values, false);
-}
-
-/// The 'diffopt' option is changed.
-const char *did_set_diffopt(optset_T *args FUNC_ATTR_UNUSED)
-{
- if (diffopt_changed() == FAIL) {
- return e_invarg;
- }
- return NULL;
-}
-
-/// The 'foldmethod' option is changed.
-const char *did_set_foldmethod(optset_T *args)
-{
- win_T *win = (win_T *)args->os_win;
- char **varp = (char **)args->os_varp;
- if (check_opt_strings(*varp, p_fdm_values, false) != OK
- || *win->w_p_fdm == NUL) {
- return e_invarg;
- }
- foldUpdateAll(win);
- if (foldmethodIsDiff(win)) {
- newFoldLevel();
- }
- return NULL;
-}
-
-/// The 'foldmarker' option is changed.
-const char *did_set_foldmarker(optset_T *args)
+/// The 'termpastefilter' option is changed.
+const char *did_set_termpastefilter(optset_T *args FUNC_ATTR_UNUSED)
{
- win_T *win = (win_T *)args->os_win;
- char **varp = (char **)args->os_varp;
- char *p = vim_strchr(*varp, ',');
-
- if (p == NULL) {
- return e_comma_required;
- }
-
- if (p == *varp || p[1] == NUL) {
- return e_invarg;
- }
-
- if (foldmethodIsMarker(win)) {
- foldUpdateAll(win);
- }
-
- return NULL;
+ return did_set_opt_flags(p_tpf, p_tpf_values, &tpf_flags, true);
}
-/// The 'commentstring' option is changed.
-const char *did_set_commentstring(optset_T *args)
+/// The 'titlestring' or the 'iconstring' option is changed.
+static const char *did_set_titleiconstring(optset_T *args, int flagval)
{
char **varp = (char **)args->os_varp;
- if (**varp != NUL && strstr(*varp, "%s") == NULL) {
- return N_("E537: 'commentstring' must be empty or contain %s");
- }
- return NULL;
-}
-
-/// The 'foldignore' option is changed.
-const char *did_set_foldignore(optset_T *args)
-{
- win_T *win = (win_T *)args->os_win;
- if (foldmethodIsIndent(win)) {
- foldUpdateAll(win);
- }
- return NULL;
-}
-
-/// The 'virtualedit' option is changed.
-const char *did_set_virtualedit(optset_T *args)
-{
- win_T *win = (win_T *)args->os_win;
-
- char *ve = p_ve;
- unsigned *flags = &ve_flags;
-
- if (args->os_flags & OPT_LOCAL) {
- ve = win->w_p_ve;
- flags = &win->w_ve_flags;
- }
-
- if ((args->os_flags & OPT_LOCAL) && *ve == NUL) {
- // make the local value empty: use the global value
- *flags = 0;
+ // NULL => statusline syntax
+ if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL) {
+ stl_syntax |= flagval;
} else {
- if (opt_strings_flags(ve, p_ve_values, flags, true) != OK) {
- return e_invarg;
- } else if (strcmp(ve, args->os_oldval.string) != 0) {
- // Recompute cursor position in case the new 've' setting
- // changes something.
- validate_virtcol_win(win);
- // XXX: this only works when win == curwin
- coladvance(win->w_virtcol);
- }
- }
- return NULL;
-}
-
-/// The 'jumpoptions' option is changed.
-const char *did_set_jumpoptions(optset_T *args FUNC_ATTR_UNUSED)
-{
- return did_set_opt_flags(p_jop, p_jop_values, &jop_flags, true);
-}
-
-/// The 'redrawdebug' option is changed.
-const char *did_set_redrawdebug(optset_T *args FUNC_ATTR_UNUSED)
-{
- return did_set_opt_flags(p_rdb, p_rdb_values, &rdb_flags, true);
-}
-
-/// The 'wildoptions' option is changed.
-const char *did_set_wildoptions(optset_T *args FUNC_ATTR_UNUSED)
-{
- return did_set_opt_flags(p_wop, p_wop_values, &wop_flags, true);
-}
-
-/// The 'lispoptions' option is changed.
-const char *did_set_lispoptions(optset_T *args)
-{
- char **varp = (char **)args->os_varp;
-
- if (**varp != NUL && strcmp(*varp, "expr:0") != 0 && strcmp(*varp, "expr:1") != 0) {
- return e_invarg;
- }
- return NULL;
-}
-
-/// The 'rightleftcmd' option is changed.
-const char *did_set_rightleftcmd(optset_T *args)
-{
- char **varp = (char **)args->os_varp;
-
- // Currently only "search" is a supported value.
- if (**varp != NUL && strcmp(*varp, "search") != 0) {
- return e_invarg;
- }
-
- return NULL;
-}
-
-/// The 'filetype' or the 'syntax' option is changed.
-const char *did_set_filetype_or_syntax(optset_T *args)
-{
- char **varp = (char **)args->os_varp;
-
- if (!valid_filetype(*varp)) {
- return e_invarg;
+ stl_syntax &= ~flagval;
}
-
- args->os_value_changed = strcmp(args->os_oldval.string, *varp) != 0;
-
- // Since we check the value, there is no need to set P_INSECURE,
- // even when the value comes from a modeline.
- args->os_value_checked = true;
+ did_set_title();
return NULL;
}
-const char *did_set_winhl(optset_T *args)
+/// The 'titlestring' option is changed.
+const char *did_set_titlestring(optset_T *args)
{
- win_T *win = (win_T *)args->os_win;
- if (!parse_winhl_opt(win)) {
- return e_invarg;
- }
- return NULL;
+ return did_set_titleiconstring(args, STL_IN_TITLE);
}
/// The 'varsofttabstop' option is changed.
@@ -1987,62 +1942,97 @@ const char *did_set_vartabstop(optset_T *args)
return NULL;
}
-/// The 'nrformats' option is changed.
-const char *did_set_nrformats(optset_T *args)
+/// The 'verbosefile' option is changed.
+const char *did_set_verbosefile(optset_T *args)
{
- char **varp = (char **)args->os_varp;
+ verbose_stop();
+ if (*p_vfile != NUL && verbose_open() == FAIL) {
+ return (char *)e_invarg;
+ }
+ return NULL;
+}
- return did_set_opt_strings(*varp, p_nf_values, true);
+/// The 'viewoptions' option is changed.
+const char *did_set_viewoptions(optset_T *args FUNC_ATTR_UNUSED)
+{
+ return did_set_opt_flags(p_vop, p_ssop_values, &vop_flags, true);
}
-/// One of the '*expr' options is changed:, 'diffexpr', 'foldexpr', 'foldtext',
-/// 'formatexpr', 'includeexpr', 'indentexpr', 'patchexpr' and 'charconvert'.
-const char *did_set_optexpr(optset_T *args)
+/// The 'virtualedit' option is changed.
+const char *did_set_virtualedit(optset_T *args)
{
- char **varp = (char **)args->os_varp;
+ win_T *win = (win_T *)args->os_win;
- // If the option value starts with <SID> or s:, then replace that with
- // the script identifier.
- char *name = get_scriptlocal_funcname(*varp);
- if (name != NULL) {
- free_string_option(*varp);
- *varp = name;
+ char *ve = p_ve;
+ unsigned *flags = &ve_flags;
+
+ if (args->os_flags & OPT_LOCAL) {
+ ve = win->w_p_ve;
+ flags = &win->w_ve_flags;
+ }
+
+ if ((args->os_flags & OPT_LOCAL) && *ve == NUL) {
+ // make the local value empty: use the global value
+ *flags = 0;
+ } else {
+ if (opt_strings_flags(ve, p_ve_values, flags, true) != OK) {
+ return e_invarg;
+ } else if (strcmp(ve, args->os_oldval.string) != 0) {
+ // Recompute cursor position in case the new 've' setting
+ // changes something.
+ validate_virtcol_win(win);
+ // XXX: this only works when win == curwin
+ coladvance(win->w_virtcol);
+ }
}
return NULL;
}
-/// The 'foldexpr' option is changed.
-const char *did_set_foldexpr(optset_T *args)
+/// The 'whichwrap' option is changed.
+const char *did_set_whichwrap(optset_T *args)
{
- win_T *win = (win_T *)args->os_win;
- (void)did_set_optexpr(args);
- if (foldmethodIsExpr(win)) {
- foldUpdateAll(win);
+ char **varp = (char **)args->os_varp;
+
+ return did_set_option_listflag(*varp, WW_ALL, args->os_errbuf, args->os_errbuflen);
+}
+
+/// The 'wildmode' option is changed.
+const char *did_set_wildmode(optset_T *args FUNC_ATTR_UNUSED)
+{
+ if (check_opt_wim() == FAIL) {
+ return e_invarg;
}
return NULL;
}
-/// The 'foldclose' option is changed.
-const char *did_set_foldclose(optset_T *args FUNC_ATTR_UNUSED)
+/// The 'wildoptions' option is changed.
+const char *did_set_wildoptions(optset_T *args FUNC_ATTR_UNUSED)
{
- return did_set_opt_strings(p_fcl, p_fcl_values, true);
+ return did_set_opt_flags(p_wop, p_wop_values, &wop_flags, true);
}
-/// An option which is a list of flags is set. Valid values are in 'flags'.
-static const char *did_set_option_listflag(char *val, char *flags, char *errbuf, size_t errbuflen)
+/// The 'winaltkeys' option is changed.
+const char *did_set_winaltkeys(optset_T *args FUNC_ATTR_UNUSED)
{
- for (char *s = val; *s; s++) {
- if (vim_strchr(flags, (uint8_t)(*s)) == NULL) {
- return illegal_char(errbuf, errbuflen, (uint8_t)(*s));
- }
+ if (*p_wak == NUL || check_opt_strings(p_wak, p_wak_values, false) != OK) {
+ return e_invarg;
}
-
return NULL;
}
-const char *did_set_guicursor(optset_T *args FUNC_ATTR_UNUSED)
+/// The 'winbar' option is changed.
+const char *did_set_winbar(optset_T *args)
{
- return parse_shape_opt(SHAPE_CURSOR);
+ return did_set_statustabline_rulerformat(args, false, false);
+}
+
+const char *did_set_winhl(optset_T *args)
+{
+ win_T *win = (win_T *)args->os_win;
+ if (!parse_winhl_opt(win)) {
+ return e_invarg;
+ }
+ return NULL;
}
// When 'syntax' is set, load the syntax of that name
@@ -2303,6 +2293,48 @@ static int get_encoded_char_adv(const char **p)
return c;
}
+struct chars_tab {
+ int *cp; ///< char value
+ const char *name; ///< char id
+ int def; ///< default value
+ int fallback; ///< default value when "def" isn't single-width
+};
+
+static fcs_chars_T fcs_chars;
+static const struct chars_tab fcs_tab[] = {
+ { &fcs_chars.stl, "stl", ' ', NUL },
+ { &fcs_chars.stlnc, "stlnc", ' ', NUL },
+ { &fcs_chars.wbr, "wbr", ' ', NUL },
+ { &fcs_chars.horiz, "horiz", 0x2500, '-' }, // ─
+ { &fcs_chars.horizup, "horizup", 0x2534, '-' }, // ┴
+ { &fcs_chars.horizdown, "horizdown", 0x252c, '-' }, // ┬
+ { &fcs_chars.vert, "vert", 0x2502, '|' }, // │
+ { &fcs_chars.vertleft, "vertleft", 0x2524, '|' }, // ┤
+ { &fcs_chars.vertright, "vertright", 0x251c, '|' }, // ├
+ { &fcs_chars.verthoriz, "verthoriz", 0x253c, '+' }, // ┼
+ { &fcs_chars.fold, "fold", 0x00b7, '-' }, // ·
+ { &fcs_chars.foldopen, "foldopen", '-', NUL },
+ { &fcs_chars.foldclosed, "foldclose", '+', NUL },
+ { &fcs_chars.foldsep, "foldsep", 0x2502, '|' }, // │
+ { &fcs_chars.diff, "diff", '-', NUL },
+ { &fcs_chars.msgsep, "msgsep", ' ', NUL },
+ { &fcs_chars.eob, "eob", '~', NUL },
+ { &fcs_chars.lastline, "lastline", '@', NUL },
+};
+
+static lcs_chars_T lcs_chars;
+static const struct chars_tab lcs_tab[] = {
+ { &lcs_chars.eol, "eol", NUL, NUL },
+ { &lcs_chars.ext, "extends", NUL, NUL },
+ { &lcs_chars.nbsp, "nbsp", NUL, NUL },
+ { &lcs_chars.prec, "precedes", NUL, NUL },
+ { &lcs_chars.space, "space", NUL, NUL },
+ { &lcs_chars.tab2, "tab", NUL, NUL },
+ { &lcs_chars.lead, "lead", NUL, NUL },
+ { &lcs_chars.trail, "trail", NUL, NUL },
+ { &lcs_chars.conceal, "conceal", NUL, NUL },
+};
+
/// Handle setting 'listchars' or 'fillchars'.
/// Assume monocell characters
///
@@ -2318,47 +2350,7 @@ static const char *set_chars_option(win_T *wp, const char *value, const bool is_
int multispace_len = 0; // Length of lcs-multispace string
int lead_multispace_len = 0; // Length of lcs-leadmultispace string
- struct chars_tab {
- int *cp; ///< char value
- char *name; ///< char id
- int def; ///< default value
- };
-
- // XXX: Characters taking 2 columns is forbidden (TUI limitation?). Set old defaults in this case.
- struct chars_tab fcs_tab[] = {
- { &wp->w_p_fcs_chars.stl, "stl", ' ' },
- { &wp->w_p_fcs_chars.stlnc, "stlnc", ' ' },
- { &wp->w_p_fcs_chars.wbr, "wbr", ' ' },
- { &wp->w_p_fcs_chars.horiz, "horiz", char2cells(0x2500) == 1 ? 0x2500 : '-' }, // ─
- { &wp->w_p_fcs_chars.horizup, "horizup", char2cells(0x2534) == 1 ? 0x2534 : '-' }, // ┴
- { &wp->w_p_fcs_chars.horizdown, "horizdown", char2cells(0x252c) == 1 ? 0x252c : '-' }, // ┬
- { &wp->w_p_fcs_chars.vert, "vert", char2cells(0x2502) == 1 ? 0x2502 : '|' }, // │
- { &wp->w_p_fcs_chars.vertleft, "vertleft", char2cells(0x2524) == 1 ? 0x2524 : '|' }, // ┤
- { &wp->w_p_fcs_chars.vertright, "vertright", char2cells(0x251c) == 1 ? 0x251c : '|' }, // ├
- { &wp->w_p_fcs_chars.verthoriz, "verthoriz", char2cells(0x253c) == 1 ? 0x253c : '+' }, // ┼
- { &wp->w_p_fcs_chars.fold, "fold", char2cells(0x00b7) == 1 ? 0x00b7 : '-' }, // ·
- { &wp->w_p_fcs_chars.foldopen, "foldopen", '-' },
- { &wp->w_p_fcs_chars.foldclosed, "foldclose", '+' },
- { &wp->w_p_fcs_chars.foldsep, "foldsep", char2cells(0x2502) == 1 ? 0x2502 : '|' }, // │
- { &wp->w_p_fcs_chars.diff, "diff", '-' },
- { &wp->w_p_fcs_chars.msgsep, "msgsep", ' ' },
- { &wp->w_p_fcs_chars.eob, "eob", '~' },
- { &wp->w_p_fcs_chars.lastline, "lastline", '@' },
- };
-
- struct chars_tab lcs_tab[] = {
- { &wp->w_p_lcs_chars.eol, "eol", NUL },
- { &wp->w_p_lcs_chars.ext, "extends", NUL },
- { &wp->w_p_lcs_chars.nbsp, "nbsp", NUL },
- { &wp->w_p_lcs_chars.prec, "precedes", NUL },
- { &wp->w_p_lcs_chars.space, "space", NUL },
- { &wp->w_p_lcs_chars.tab2, "tab", NUL },
- { &wp->w_p_lcs_chars.lead, "lead", NUL },
- { &wp->w_p_lcs_chars.trail, "trail", NUL },
- { &wp->w_p_lcs_chars.conceal, "conceal", NUL },
- };
-
- struct chars_tab *tab;
+ const struct chars_tab *tab;
int entries;
if (is_listchars) {
tab = lcs_tab;
@@ -2380,31 +2372,32 @@ static const char *set_chars_option(win_T *wp, const char *value, const bool is_
// After checking that the value is valid: set defaults
for (int i = 0; i < entries; i++) {
if (tab[i].cp != NULL) {
- *(tab[i].cp) = tab[i].def;
+ // XXX: Characters taking 2 columns is forbidden (TUI limitation?).
+ // Set old defaults in this case.
+ *(tab[i].cp) = char2cells(tab[i].def) == 1 ? tab[i].def : tab[i].fallback;
}
}
+
if (is_listchars) {
- wp->w_p_lcs_chars.tab1 = NUL;
- wp->w_p_lcs_chars.tab3 = NUL;
+ lcs_chars.tab1 = NUL;
+ lcs_chars.tab3 = NUL;
- xfree(wp->w_p_lcs_chars.multispace);
if (multispace_len > 0) {
- wp->w_p_lcs_chars.multispace = xmalloc(((size_t)multispace_len + 1) * sizeof(int));
- wp->w_p_lcs_chars.multispace[multispace_len] = NUL;
+ lcs_chars.multispace = xmalloc(((size_t)multispace_len + 1) * sizeof(int));
+ lcs_chars.multispace[multispace_len] = NUL;
} else {
- wp->w_p_lcs_chars.multispace = NULL;
+ lcs_chars.multispace = NULL;
}
- xfree(wp->w_p_lcs_chars.leadmultispace);
if (lead_multispace_len > 0) {
- wp->w_p_lcs_chars.leadmultispace
- = xmalloc(((size_t)lead_multispace_len + 1) * sizeof(int));
- wp->w_p_lcs_chars.leadmultispace[lead_multispace_len] = NUL;
+ lcs_chars.leadmultispace = xmalloc(((size_t)lead_multispace_len + 1) * sizeof(int));
+ lcs_chars.leadmultispace[lead_multispace_len] = NUL;
} else {
- wp->w_p_lcs_chars.leadmultispace = NULL;
+ lcs_chars.leadmultispace = NULL;
}
}
}
+
const char *p = value;
while (*p) {
int i;
@@ -2419,7 +2412,7 @@ static const char *set_chars_option(win_T *wp, const char *value, const bool is_
return e_invarg;
}
int c2 = 0, c3 = 0;
- if (tab[i].cp == &wp->w_p_lcs_chars.tab2) {
+ if (tab[i].cp == &lcs_chars.tab2) {
if (*s == NUL) {
return e_invarg;
}
@@ -2434,12 +2427,13 @@ static const char *set_chars_option(win_T *wp, const char *value, const bool is_
}
}
}
+
if (*s == ',' || *s == NUL) {
if (round > 0) {
- if (tab[i].cp == &wp->w_p_lcs_chars.tab2) {
- wp->w_p_lcs_chars.tab1 = c1;
- wp->w_p_lcs_chars.tab2 = c2;
- wp->w_p_lcs_chars.tab3 = c3;
+ if (tab[i].cp == &lcs_chars.tab2) {
+ lcs_chars.tab1 = c1;
+ lcs_chars.tab2 = c2;
+ lcs_chars.tab3 = c3;
} else if (tab[i].cp != NULL) {
*(tab[i].cp) = c1;
}
@@ -2479,7 +2473,7 @@ static const char *set_chars_option(win_T *wp, const char *value, const bool is_
while (*s != NUL && *s != ',') {
int c1 = get_encoded_char_adv(&s);
if (p == last_multispace) {
- wp->w_p_lcs_chars.multispace[multispace_pos++] = c1;
+ lcs_chars.multispace[multispace_pos++] = c1;
}
}
p = s;
@@ -2510,7 +2504,7 @@ static const char *set_chars_option(win_T *wp, const char *value, const bool is_
while (*s != NUL && *s != ',') {
int c1 = get_encoded_char_adv(&s);
if (p == last_lmultispace) {
- wp->w_p_lcs_chars.leadmultispace[multispace_pos++] = c1;
+ lcs_chars.leadmultispace[multispace_pos++] = c1;
}
}
p = s;
@@ -2526,6 +2520,19 @@ static const char *set_chars_option(win_T *wp, const char *value, const bool is_
}
}
+ if (apply) {
+ if (is_listchars) {
+ xfree(wp->w_p_lcs_chars.multispace);
+ xfree(wp->w_p_lcs_chars.leadmultispace);
+ wp->w_p_lcs_chars = lcs_chars;
+ } else {
+ wp->w_p_fcs_chars = fcs_chars;
+ }
+ } else if (is_listchars) {
+ xfree(lcs_chars.multispace);
+ xfree(lcs_chars.leadmultispace);
+ }
+
return NULL; // no error
}
@@ -2551,3 +2558,15 @@ const char *check_chars_options(void)
}
return NULL;
}
+
+/// Handle the new value of 'fillchars'.
+const char *set_fillchars_option(win_T *wp, char *val, bool apply)
+{
+ return set_chars_option(wp, val, false, apply);
+}
+
+/// Handle the new value of 'listchars'.
+const char *set_listchars_option(win_T *wp, char *val, bool apply)
+{
+ return set_chars_option(wp, val, true, apply);
+}
diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c
index 10fe3cb114..b03509a313 100644
--- a/src/nvim/os/env.c
+++ b/src/nvim/os/env.c
@@ -25,7 +25,7 @@
#include "nvim/map.h"
#include "nvim/memory.h"
#include "nvim/message.h"
-#include "nvim/option_defs.h"
+#include "nvim/option_vars.h"
#include "nvim/os/os.h"
#include "nvim/path.h"
#include "nvim/strings.h"
diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c
index c95b5defaa..476ede2046 100644
--- a/src/nvim/os/fs.c
+++ b/src/nvim/os/fs.c
@@ -18,6 +18,8 @@
# include <shlobj.h>
#endif
+#include "auto/config.h"
+
#if defined(HAVE_ACL)
# ifdef HAVE_SYS_ACL_H
# include <sys/acl.h>
@@ -27,16 +29,18 @@
# endif
#endif
-#include "auto/config.h"
+#ifdef HAVE_XATTR
+# include <sys/xattr.h>
+#endif
+
#include "nvim/ascii.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
#include "nvim/log.h"
#include "nvim/macros.h"
-#include "nvim/main.h"
#include "nvim/memory.h"
#include "nvim/message.h"
-#include "nvim/option_defs.h"
+#include "nvim/option_vars.h"
#include "nvim/os/fs_defs.h"
#include "nvim/os/os.h"
#include "nvim/path.h"
@@ -56,6 +60,17 @@
# include "os/fs.c.generated.h"
#endif
+#ifdef HAVE_XATTR
+static const char e_xattr_erange[]
+ = N_("E1506: Buffer too small to copy xattr value or key");
+static const char e_xattr_enotsup[]
+ = N_("E1507: Extended attributes are not supported by the filesystem");
+static const char e_xattr_e2big[]
+ = N_("E1508: Size of the extended attribute value is larger than the maximum size allowed");
+static const char e_xattr_other[]
+ = N_("E1509: Error occured when reading or writing extended attribute");
+#endif
+
struct iovec;
#define RUN_UV_FS_FUNC(ret, func, ...) \
@@ -744,6 +759,84 @@ int os_setperm(const char *const name, int perm)
return (r == kLibuvSuccess ? OK : FAIL);
}
+#ifdef HAVE_XATTR
+/// Copy extended attributes from_file to to_file
+void os_copy_xattr(const char *from_file, const char *to_file)
+{
+ if (from_file == NULL) {
+ return;
+ }
+
+ // get the length of the extended attributes
+ ssize_t size = listxattr((char *)from_file, NULL, 0);
+ // not supported or no attributes to copy
+ if (errno == ENOTSUP || size <= 0) {
+ return;
+ }
+ char *xattr_buf = xmalloc((size_t)size);
+ size = listxattr(from_file, xattr_buf, (size_t)size);
+ ssize_t tsize = size;
+
+ errno = 0;
+
+ ssize_t max_vallen = 0;
+ char *val = NULL;
+ const char *errmsg = NULL;
+
+ for (int round = 0; round < 2; round++) {
+ char *key = xattr_buf;
+ if (round == 1) {
+ size = tsize;
+ }
+
+ while (size > 0) {
+ ssize_t vallen = getxattr(from_file, key, val, round ? (size_t)max_vallen : 0);
+ // only set the attribute in the second round
+ if (vallen >= 0 && round
+ && setxattr(to_file, key, val, (size_t)vallen, 0) == 0) {
+ //
+ } else if (errno) {
+ switch (errno) {
+ case E2BIG:
+ errmsg = e_xattr_e2big;
+ goto error_exit;
+ case ENOTSUP:
+ errmsg = e_xattr_enotsup;
+ goto error_exit;
+ case ERANGE:
+ errmsg = e_xattr_erange;
+ goto error_exit;
+ default:
+ errmsg = e_xattr_other;
+ goto error_exit;
+ }
+ }
+
+ if (round == 0 && vallen > max_vallen) {
+ max_vallen = vallen;
+ }
+
+ // add one for terminating null
+ ssize_t keylen = (ssize_t)strlen(key) + 1;
+ size -= keylen;
+ key += keylen;
+ }
+ if (round) {
+ break;
+ }
+
+ val = xmalloc((size_t)max_vallen + 1);
+ }
+error_exit:
+ xfree(xattr_buf);
+ xfree(val);
+
+ if (errmsg != NULL) {
+ emsg(_(errmsg));
+ }
+}
+#endif
+
// Return a pointer to the ACL of file "fname" in allocated memory.
// Return NULL if the ACL is not available for whatever reason.
vim_acl_T os_get_acl(const char *fname)
diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c
index 6310b90f04..03418f4548 100644
--- a/src/nvim/os/input.c
+++ b/src/nvim/os/input.c
@@ -11,7 +11,6 @@
#include "nvim/api/private/defs.h"
#include "nvim/ascii.h"
#include "nvim/autocmd.h"
-#include "nvim/buffer_defs.h"
#include "nvim/event/loop.h"
#include "nvim/event/multiqueue.h"
#include "nvim/event/rstream.h"
@@ -24,8 +23,9 @@
#include "nvim/macros.h"
#include "nvim/main.h"
#include "nvim/msgpack_rpc/channel.h"
-#include "nvim/option_defs.h"
+#include "nvim/option_vars.h"
#include "nvim/os/input.h"
+#include "nvim/os/os_defs.h"
#include "nvim/os/time.h"
#include "nvim/profile.h"
#include "nvim/rbuffer.h"
diff --git a/src/nvim/os/input.h b/src/nvim/os/input.h
index 6f25efdc7b..af17aabd90 100644
--- a/src/nvim/os/input.h
+++ b/src/nvim/os/input.h
@@ -6,6 +6,7 @@
#include "nvim/api/private/defs.h"
#include "nvim/event/multiqueue.h"
+#include "nvim/macros.h"
EXTERN bool used_stdin INIT(= false);
diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c
index 9b7b013edf..d885c8476f 100644
--- a/src/nvim/os/shell.c
+++ b/src/nvim/os/shell.c
@@ -11,7 +11,6 @@
#include "auto/config.h"
#include "klib/kvec.h"
#include "nvim/ascii.h"
-#include "nvim/buffer_defs.h"
#include "nvim/charset.h"
#include "nvim/eval.h"
#include "nvim/eval/typval_defs.h"
@@ -32,7 +31,7 @@
#include "nvim/memline.h"
#include "nvim/memory.h"
#include "nvim/message.h"
-#include "nvim/option_defs.h"
+#include "nvim/option_vars.h"
#include "nvim/os/fs.h"
#include "nvim/os/os_defs.h"
#include "nvim/os/shell.h"
diff --git a/src/nvim/os/signal.c b/src/nvim/os/signal.c
index 56fd2125c2..4c4ac9df1e 100644
--- a/src/nvim/os/signal.c
+++ b/src/nvim/os/signal.c
@@ -9,7 +9,6 @@
#endif
#include "nvim/autocmd.h"
-#include "nvim/buffer_defs.h"
#include "nvim/eval.h"
#include "nvim/event/signal.h"
#include "nvim/globals.h"
diff --git a/src/nvim/os/stdpaths.c b/src/nvim/os/stdpaths.c
index b129eb445a..fa474b67dd 100644
--- a/src/nvim/os/stdpaths.c
+++ b/src/nvim/os/stdpaths.c
@@ -1,11 +1,13 @@
// 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
+#include <assert.h>
#include <stdbool.h>
#include <string.h>
#include "nvim/ascii.h"
#include "nvim/fileio.h"
+#include "nvim/globals.h"
#include "nvim/memory.h"
#include "nvim/os/os.h"
#include "nvim/os/stdpaths_defs.h"
diff --git a/src/nvim/os/time.c b/src/nvim/os/time.c
index 0c3b254b9a..ac98f0cf9a 100644
--- a/src/nvim/os/time.c
+++ b/src/nvim/os/time.c
@@ -4,7 +4,6 @@
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
-#include <stdlib.h>
#include <string.h>
#include <time.h>
@@ -15,7 +14,6 @@
#include "nvim/gettext.h"
#include "nvim/globals.h"
#include "nvim/log.h"
-#include "nvim/macros.h"
#include "nvim/main.h"
#include "nvim/memory.h"
#include "nvim/os/input.h"
diff --git a/src/nvim/path.c b/src/nvim/path.c
index 3b36c2a550..21f0543756 100644
--- a/src/nvim/path.c
+++ b/src/nvim/path.c
@@ -2,7 +2,6 @@
// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
#include <assert.h>
-#include <ctype.h>
#include <limits.h>
#include <stdbool.h>
#include <stddef.h>
@@ -12,10 +11,10 @@
#include "auto/config.h"
#include "nvim/ascii.h"
-#include "nvim/buffer_defs.h"
#include "nvim/charset.h"
#include "nvim/cmdexpand.h"
#include "nvim/eval.h"
+#include "nvim/eval/typval_defs.h"
#include "nvim/ex_docmd.h"
#include "nvim/file_search.h"
#include "nvim/fileio.h"
@@ -27,6 +26,7 @@
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/os/fs_defs.h"
#include "nvim/os/input.h"
#include "nvim/os/os.h"
@@ -35,7 +35,6 @@
#include "nvim/pos.h"
#include "nvim/regexp.h"
#include "nvim/strings.h"
-#include "nvim/types.h"
#include "nvim/vim.h"
#include "nvim/window.h"
diff --git a/src/nvim/plines.c b/src/nvim/plines.c
index 8cadb5a81a..97782b39bc 100644
--- a/src/nvim/plines.c
+++ b/src/nvim/plines.c
@@ -3,9 +3,9 @@
// plines.c: calculate the vertical and horizontal size of text in a window
-#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
+#include <stdint.h>
#include <string.h>
#include "nvim/ascii.h"
@@ -21,6 +21,7 @@
#include "nvim/memline.h"
#include "nvim/move.h"
#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/plines.h"
#include "nvim/pos.h"
#include "nvim/state.h"
diff --git a/src/nvim/popupmenu.c b/src/nvim/popupmenu.c
index 3be2f4cd9f..af4ffd7829 100644
--- a/src/nvim/popupmenu.c
+++ b/src/nvim/popupmenu.c
@@ -6,7 +6,6 @@
/// Popup menu (PUM)
#include <assert.h>
-#include <limits.h>
#include <stdbool.h>
#include <string.h>
@@ -17,9 +16,9 @@
#include "nvim/charset.h"
#include "nvim/drawscreen.h"
#include "nvim/eval/typval.h"
-#include "nvim/eval/typval_defs.h"
#include "nvim/ex_cmds.h"
#include "nvim/getchar.h"
+#include "nvim/gettext.h"
#include "nvim/globals.h"
#include "nvim/grid.h"
#include "nvim/highlight.h"
@@ -32,6 +31,7 @@
#include "nvim/message.h"
#include "nvim/move.h"
#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/popupmenu.h"
#include "nvim/pos.h"
#include "nvim/strings.h"
diff --git a/src/nvim/profile.c b/src/nvim/profile.c
index d8ba4741bc..3162a446c0 100644
--- a/src/nvim/profile.c
+++ b/src/nvim/profile.c
@@ -24,7 +24,6 @@
#include "nvim/keycodes.h"
#include "nvim/memory.h"
#include "nvim/message.h"
-#include "nvim/option_defs.h"
#include "nvim/os/os.h"
#include "nvim/os/time.h"
#include "nvim/pos.h"
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index a02c0eface..e6d5831dd3 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -23,7 +23,6 @@
#include "nvim/edit.h"
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
-#include "nvim/eval/typval_defs.h"
#include "nvim/eval/window.h"
#include "nvim/ex_cmds.h"
#include "nvim/ex_cmds2.h"
@@ -33,6 +32,7 @@
#include "nvim/ex_getln.h"
#include "nvim/fileio.h"
#include "nvim/fold.h"
+#include "nvim/garray.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
#include "nvim/help.h"
@@ -41,13 +41,14 @@
#include "nvim/macros.h"
#include "nvim/mark.h"
#include "nvim/mbyte.h"
-#include "nvim/memfile_defs.h"
#include "nvim/memline.h"
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/move.h"
#include "nvim/normal.h"
#include "nvim/option.h"
+#include "nvim/option_defs.h"
+#include "nvim/option_vars.h"
#include "nvim/optionstr.h"
#include "nvim/os/fs_defs.h"
#include "nvim/os/input.h"
diff --git a/src/nvim/quickfix.h b/src/nvim/quickfix.h
index 0da43e436c..70b013be9c 100644
--- a/src/nvim/quickfix.h
+++ b/src/nvim/quickfix.h
@@ -2,6 +2,7 @@
#define NVIM_QUICKFIX_H
#include "nvim/ex_cmds_defs.h"
+#include "nvim/option_defs.h"
#include "nvim/types.h"
// flags for skip_vimgrep_pat()
diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c
index de72c95fb2..3f792cd8d5 100644
--- a/src/nvim/regexp.c
+++ b/src/nvim/regexp.c
@@ -20,7 +20,6 @@
#include "nvim/charset.h"
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
-#include "nvim/eval/typval_defs.h"
#include "nvim/eval/userfunc.h"
#include "nvim/garray.h"
#include "nvim/gettext.h"
@@ -32,7 +31,7 @@
#include "nvim/memline.h"
#include "nvim/memory.h"
#include "nvim/message.h"
-#include "nvim/option_defs.h"
+#include "nvim/option_vars.h"
#include "nvim/os/input.h"
#include "nvim/plines.h"
#include "nvim/pos.h"
@@ -40,7 +39,6 @@
#include "nvim/regexp_defs.h"
#include "nvim/strings.h"
#include "nvim/types.h"
-#include "nvim/undo_defs.h"
#include "nvim/vim.h"
#ifdef REGEXP_DEBUG
diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c
index e6a04c899c..12cf08636f 100644
--- a/src/nvim/runtime.c
+++ b/src/nvim/runtime.c
@@ -9,6 +9,7 @@
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
+#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <uv.h>
@@ -17,7 +18,6 @@
#include "nvim/api/private/helpers.h"
#include "nvim/ascii.h"
#include "nvim/autocmd.h"
-#include "nvim/buffer_defs.h"
#include "nvim/charset.h"
#include "nvim/cmdexpand.h"
#include "nvim/debugger.h"
@@ -31,6 +31,7 @@
#include "nvim/getchar.h"
#include "nvim/gettext.h"
#include "nvim/globals.h"
+#include "nvim/hashtab.h"
#include "nvim/lua/executor.h"
#include "nvim/macros.h"
#include "nvim/map.h"
@@ -39,6 +40,8 @@
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/option.h"
+#include "nvim/option_defs.h"
+#include "nvim/option_vars.h"
#include "nvim/os/input.h"
#include "nvim/os/os.h"
#include "nvim/os/stdpaths_defs.h"
diff --git a/src/nvim/runtime.h b/src/nvim/runtime.h
index 23a9f468db..7308ef5f75 100644
--- a/src/nvim/runtime.h
+++ b/src/nvim/runtime.h
@@ -9,6 +9,7 @@
#include "nvim/ex_cmds_defs.h"
#include "nvim/ex_eval_defs.h"
#include "nvim/garray.h"
+#include "nvim/option_defs.h"
#include "nvim/pos.h"
#include "nvim/types.h"
diff --git a/src/nvim/search.c b/src/nvim/search.c
index 87a591ea35..2d13ad3f0d 100644
--- a/src/nvim/search.c
+++ b/src/nvim/search.c
@@ -43,6 +43,7 @@
#include "nvim/move.h"
#include "nvim/normal.h"
#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/os/fs.h"
#include "nvim/os/input.h"
#include "nvim/os/time.h"
diff --git a/src/nvim/shada.c b/src/nvim/shada.c
index 4fe9498af9..14d35d9b59 100644
--- a/src/nvim/shada.c
+++ b/src/nvim/shada.c
@@ -25,7 +25,6 @@
#include "nvim/eval/decode.h"
#include "nvim/eval/encode.h"
#include "nvim/eval/typval.h"
-#include "nvim/eval/typval_defs.h"
#include "nvim/ex_cmds.h"
#include "nvim/ex_docmd.h"
#include "nvim/fileio.h"
@@ -43,6 +42,7 @@
#include "nvim/normal.h"
#include "nvim/ops.h"
#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/os/fileio.h"
#include "nvim/os/fs_defs.h"
#include "nvim/os/os.h"
diff --git a/src/nvim/sign.c b/src/nvim/sign.c
index 7fde0b3f62..96af14bfc6 100644
--- a/src/nvim/sign.c
+++ b/src/nvim/sign.c
@@ -7,6 +7,7 @@
#include <inttypes.h>
#include <stdbool.h>
+#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -20,7 +21,6 @@
#include "nvim/edit.h"
#include "nvim/eval/funcs.h"
#include "nvim/eval/typval.h"
-#include "nvim/eval/typval_defs.h"
#include "nvim/ex_cmds_defs.h"
#include "nvim/ex_docmd.h"
#include "nvim/fold.h"
@@ -31,7 +31,6 @@
#include "nvim/highlight_group.h"
#include "nvim/macros.h"
#include "nvim/mbyte.h"
-#include "nvim/memline_defs.h"
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/move.h"
diff --git a/src/nvim/spell.c b/src/nvim/spell.c
index 1c7707995f..a97b9c6a0a 100644
--- a/src/nvim/spell.c
+++ b/src/nvim/spell.c
@@ -90,6 +90,7 @@
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/os/fs.h"
#include "nvim/os/input.h"
#include "nvim/os/os_defs.h"
diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c
index e8ae6703c7..f1df2e56f3 100644
--- a/src/nvim/spellfile.c
+++ b/src/nvim/spellfile.c
@@ -231,12 +231,12 @@
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
+#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
-#include "auto/config.h"
#include "nvim/arglist.h"
#include "nvim/ascii.h"
#include "nvim/buffer.h"
@@ -254,6 +254,7 @@
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/os/input.h"
#include "nvim/os/os.h"
#include "nvim/os/time.h"
@@ -265,7 +266,6 @@
#include "nvim/spell_defs.h"
#include "nvim/spellfile.h"
#include "nvim/strings.h"
-#include "nvim/types.h"
#include "nvim/ui.h"
#include "nvim/undo.h"
#include "nvim/vim.h"
diff --git a/src/nvim/spellsuggest.c b/src/nvim/spellsuggest.c
index 1da61bbb2f..2ee93b4934 100644
--- a/src/nvim/spellsuggest.c
+++ b/src/nvim/spellsuggest.c
@@ -7,6 +7,7 @@
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
+#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -18,7 +19,6 @@
#include "nvim/cursor.h"
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
-#include "nvim/eval/typval_defs.h"
#include "nvim/fileio.h"
#include "nvim/garray.h"
#include "nvim/getchar.h"
@@ -34,6 +34,7 @@
#include "nvim/message.h"
#include "nvim/normal.h"
#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/os/fs.h"
#include "nvim/os/input.h"
#include "nvim/os/os_defs.h"
diff --git a/src/nvim/state.c b/src/nvim/state.c
index 9a65e25a90..424fda2ede 100644
--- a/src/nvim/state.c
+++ b/src/nvim/state.c
@@ -7,13 +7,10 @@
#include "nvim/ascii.h"
#include "nvim/autocmd.h"
-#include "nvim/buffer_defs.h"
#include "nvim/drawscreen.h"
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
-#include "nvim/eval/typval_defs.h"
#include "nvim/event/defs.h"
-#include "nvim/event/loop.h"
#include "nvim/event/multiqueue.h"
#include "nvim/getchar.h"
#include "nvim/globals.h"
@@ -23,6 +20,7 @@
#include "nvim/macros.h"
#include "nvim/main.h"
#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/os/input.h"
#include "nvim/state.h"
#include "nvim/strings.h"
diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c
index 407bf71417..1529b63812 100644
--- a/src/nvim/statusline.c
+++ b/src/nvim/statusline.c
@@ -16,6 +16,7 @@
#include "nvim/buffer_defs.h"
#include "nvim/charset.h"
#include "nvim/digraph.h"
+#include "nvim/drawline.h"
#include "nvim/drawscreen.h"
#include "nvim/eval.h"
#include "nvim/eval/typval_defs.h"
@@ -30,9 +31,9 @@
#include "nvim/memline.h"
#include "nvim/memory.h"
#include "nvim/message.h"
-#include "nvim/move.h"
#include "nvim/normal.h"
#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/optionstr.h"
#include "nvim/os/os.h"
#include "nvim/path.h"
@@ -41,7 +42,6 @@
#include "nvim/sign.h"
#include "nvim/statusline.h"
#include "nvim/strings.h"
-#include "nvim/types.h"
#include "nvim/ui.h"
#include "nvim/undo.h"
#include "nvim/vim.h"
diff --git a/src/nvim/strings.c b/src/nvim/strings.c
index 7e4d07bd00..0d307a760f 100644
--- a/src/nvim/strings.c
+++ b/src/nvim/strings.c
@@ -21,6 +21,7 @@
#include "nvim/ex_docmd.h"
#include "nvim/garray.h"
#include "nvim/gettext.h"
+#include "nvim/globals.h"
#include "nvim/macros.h"
#include "nvim/math.h"
#include "nvim/mbyte.h"
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index 10f808ad6b..9b238e6ff9 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -6,6 +6,7 @@
#include <assert.h>
#include <inttypes.h>
#include <stdbool.h>
+#include <stddef.h>
#include <stdlib.h>
#include <string.h>
@@ -33,7 +34,7 @@
#include "nvim/memline.h"
#include "nvim/memory.h"
#include "nvim/message.h"
-#include "nvim/option_defs.h"
+#include "nvim/option_vars.h"
#include "nvim/optionstr.h"
#include "nvim/os/input.h"
#include "nvim/path.h"
diff --git a/src/nvim/tag.c b/src/nvim/tag.c
index a95b104027..636d16d4e6 100644
--- a/src/nvim/tag.c
+++ b/src/nvim/tag.c
@@ -20,7 +20,6 @@
#include "nvim/drawscreen.h"
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
-#include "nvim/eval/typval_defs.h"
#include "nvim/ex_cmds.h"
#include "nvim/ex_cmds_defs.h"
#include "nvim/ex_docmd.h"
@@ -42,6 +41,8 @@
#include "nvim/message.h"
#include "nvim/move.h"
#include "nvim/option.h"
+#include "nvim/option_defs.h"
+#include "nvim/option_vars.h"
#include "nvim/optionstr.h"
#include "nvim/os/input.h"
#include "nvim/os/os.h"
diff --git a/src/nvim/tag.h b/src/nvim/tag.h
index e08145f727..90ef0384a1 100644
--- a/src/nvim/tag.h
+++ b/src/nvim/tag.h
@@ -2,6 +2,7 @@
#define NVIM_TAG_H
#include "nvim/ex_cmds_defs.h"
+#include "nvim/option_defs.h"
#include "nvim/types.h"
// Values for do_tag().
diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c
index 0f27445a53..169525da20 100644
--- a/src/nvim/terminal.c
+++ b/src/nvim/terminal.c
@@ -59,8 +59,6 @@
#include "nvim/drawscreen.h"
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
-#include "nvim/eval/typval_defs.h"
-#include "nvim/event/loop.h"
#include "nvim/event/multiqueue.h"
#include "nvim/event/time.h"
#include "nvim/ex_docmd.h"
@@ -81,6 +79,7 @@
#include "nvim/normal.h"
#include "nvim/ops.h"
#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/optionstr.h"
#include "nvim/pos.h"
#include "nvim/state.h"
diff --git a/src/nvim/textformat.c b/src/nvim/textformat.c
index 6d82179796..0de62440f9 100644
--- a/src/nvim/textformat.c
+++ b/src/nvim/textformat.c
@@ -31,13 +31,13 @@
#include "nvim/normal.h"
#include "nvim/ops.h"
#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/os/input.h"
#include "nvim/pos.h"
#include "nvim/search.h"
#include "nvim/strings.h"
#include "nvim/textformat.h"
#include "nvim/textobject.h"
-#include "nvim/types.h"
#include "nvim/undo.h"
#include "nvim/vim.h"
#include "nvim/window.h"
diff --git a/src/nvim/textobject.c b/src/nvim/textobject.c
index c40888b85d..18a56c74ca 100644
--- a/src/nvim/textobject.c
+++ b/src/nvim/textobject.c
@@ -9,7 +9,6 @@
#include <string.h>
#include "nvim/ascii.h"
-#include "nvim/buffer_defs.h"
#include "nvim/cursor.h"
#include "nvim/drawscreen.h"
#include "nvim/edit.h"
@@ -24,7 +23,7 @@
#include "nvim/memory.h"
#include "nvim/move.h"
#include "nvim/normal.h"
-#include "nvim/option_defs.h"
+#include "nvim/option_vars.h"
#include "nvim/pos.h"
#include "nvim/search.h"
#include "nvim/strings.h"
diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c
index 6e2cf6a0c2..487f8b010e 100644
--- a/src/nvim/tui/input.c
+++ b/src/nvim/tui/input.c
@@ -5,6 +5,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <uv.h>
#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
@@ -16,8 +17,7 @@
#include "nvim/main.h"
#include "nvim/map.h"
#include "nvim/memory.h"
-#include "nvim/option.h"
-#include "nvim/os/input.h"
+#include "nvim/option_vars.h"
#include "nvim/os/os.h"
#include "nvim/tui/input.h"
#include "nvim/tui/input_defs.h"
diff --git a/src/nvim/tui/input.h b/src/nvim/tui/input.h
index 5c0181362b..f631860e74 100644
--- a/src/nvim/tui/input.h
+++ b/src/nvim/tui/input.h
@@ -12,6 +12,7 @@
#include "nvim/rbuffer.h"
#include "nvim/tui/input_defs.h"
#include "nvim/tui/tui.h"
+#include "nvim/types.h"
typedef enum {
kExtkeysNone,
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
index db15cdb053..944c1d14c2 100644
--- a/src/nvim/tui/tui.c
+++ b/src/nvim/tui/tui.c
@@ -25,7 +25,6 @@
#include "nvim/event/stream.h"
#include "nvim/globals.h"
#include "nvim/grid.h"
-#include "nvim/grid_defs.h"
#include "nvim/highlight_defs.h"
#include "nvim/log.h"
#include "nvim/macros.h"
diff --git a/src/nvim/ui.c b/src/nvim/ui.c
index fc40d6fcfe..954d933d9c 100644
--- a/src/nvim/ui.c
+++ b/src/nvim/ui.c
@@ -30,6 +30,7 @@
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/os/time.h"
#include "nvim/strings.h"
#include "nvim/ui.h"
diff --git a/src/nvim/ui_client.c b/src/nvim/ui_client.c
index cc564f4777..8e60af478b 100644
--- a/src/nvim/ui_client.c
+++ b/src/nvim/ui_client.c
@@ -7,6 +7,8 @@
#include <stdint.h>
#include <stdlib.h>
+#include "nvim/api/keysets.h"
+#include "nvim/api/private/dispatch.h"
#include "nvim/api/private/helpers.h"
#include "nvim/channel.h"
#include "nvim/eval.h"
diff --git a/src/nvim/ui_compositor.c b/src/nvim/ui_compositor.c
index 007d1822fc..0f26e269ae 100644
--- a/src/nvim/ui_compositor.c
+++ b/src/nvim/ui_compositor.c
@@ -17,7 +17,6 @@
#include "klib/kvec.h"
#include "nvim/api/private/defs.h"
#include "nvim/ascii.h"
-#include "nvim/buffer_defs.h"
#include "nvim/globals.h"
#include "nvim/grid.h"
#include "nvim/highlight.h"
@@ -26,7 +25,7 @@
#include "nvim/macros.h"
#include "nvim/memory.h"
#include "nvim/message.h"
-#include "nvim/option_defs.h"
+#include "nvim/option_vars.h"
#include "nvim/os/time.h"
#include "nvim/types.h"
#include "nvim/ui.h"
diff --git a/src/nvim/undo.c b/src/nvim/undo.c
index f8e1dffe8c..5396bfcda2 100644
--- a/src/nvim/undo.c
+++ b/src/nvim/undo.c
@@ -95,7 +95,6 @@
#include "nvim/edit.h"
#include "nvim/eval/funcs.h"
#include "nvim/eval/typval.h"
-#include "nvim/eval/typval_defs.h"
#include "nvim/ex_cmds_defs.h"
#include "nvim/ex_docmd.h"
#include "nvim/ex_getln.h"
@@ -113,6 +112,7 @@
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/option.h"
+#include "nvim/option_vars.h"
#include "nvim/os/fs_defs.h"
#include "nvim/os/input.h"
#include "nvim/os/os.h"
diff --git a/src/nvim/usercmd.c b/src/nvim/usercmd.c
index 8672aa88f7..131b1ce3ef 100644
--- a/src/nvim/usercmd.c
+++ b/src/nvim/usercmd.c
@@ -30,7 +30,7 @@
#include "nvim/memory.h"
#include "nvim/menu.h"
#include "nvim/message.h"
-#include "nvim/option_defs.h"
+#include "nvim/option_vars.h"
#include "nvim/os/input.h"
#include "nvim/runtime.h"
#include "nvim/strings.h"
diff --git a/src/nvim/version.c b/src/nvim/version.c
index 437434f92a..20bbcb2f8a 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -9,11 +9,11 @@
#include <assert.h>
#include <limits.h>
#include <stdbool.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
-#include "auto/config.h"
#include "auto/versiondef.h" // version info generated by the build system
#include "auto/versiondef_git.h"
#include "nvim/api/private/defs.h"
@@ -31,8 +31,7 @@
#include "nvim/mbyte.h"
#include "nvim/memory.h"
#include "nvim/message.h"
-#include "nvim/option_defs.h"
-#include "nvim/os/os_defs.h"
+#include "nvim/option_vars.h"
#include "nvim/strings.h"
#include "nvim/version.h"
#include "nvim/vim.h"
diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c
index b53508bc6c..0ab58a8b37 100644
--- a/src/nvim/viml/parser/expressions.c
+++ b/src/nvim/viml/parser/expressions.c
@@ -61,7 +61,6 @@
#include "nvim/ascii.h"
#include "nvim/assert.h"
#include "nvim/charset.h"
-#include "nvim/eval/typval.h"
#include "nvim/gettext.h"
#include "nvim/keycodes.h"
#include "nvim/macros.h"
@@ -938,7 +937,6 @@ static const char *intchar2str(const int ch)
}
#ifdef UNIT_TESTING
-# include <stdio.h>
REAL_FATTR_UNUSED
static inline void viml_pexpr_debug_print_ast_node(const ExprASTNode *const *const eastnode_p,
diff --git a/src/nvim/window.c b/src/nvim/window.c
index bcec916e01..41199306fa 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -27,7 +27,6 @@
#include "nvim/edit.h"
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
-#include "nvim/eval/typval_defs.h"
#include "nvim/eval/vars.h"
#include "nvim/eval/window.h"
#include "nvim/ex_cmds.h"
@@ -52,13 +51,14 @@
#include "nvim/mark.h"
#include "nvim/match.h"
#include "nvim/mbyte.h"
-#include "nvim/memline_defs.h"
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/mouse.h"
#include "nvim/move.h"
#include "nvim/normal.h"
#include "nvim/option.h"
+#include "nvim/option_defs.h"
+#include "nvim/option_vars.h"
#include "nvim/optionstr.h"
#include "nvim/os/os.h"
#include "nvim/os/os_defs.h"
@@ -990,9 +990,13 @@ void ui_ext_win_position(win_T *wp, bool validate)
wp->w_grid_alloc.zindex = wp->w_float_config.zindex;
if (ui_has(kUIMultigrid)) {
String anchor = cstr_as_string((char *)float_anchor_str[c.anchor]);
- ui_call_win_float_pos(wp->w_grid_alloc.handle, wp->handle, anchor,
- grid->handle, row, col, c.focusable,
- wp->w_grid_alloc.zindex);
+ if (!c.hide) {
+ ui_call_win_float_pos(wp->w_grid_alloc.handle, wp->handle, anchor,
+ grid->handle, row, col, c.focusable,
+ wp->w_grid_alloc.zindex);
+ } else {
+ ui_call_win_hide(wp->w_grid_alloc.handle);
+ }
} else {
bool valid = (wp->w_redr_type == 0);
if (!valid && !validate) {
@@ -1014,13 +1018,18 @@ void ui_ext_win_position(win_T *wp, bool validate)
}
wp->w_winrow = comp_row;
wp->w_wincol = comp_col;
- ui_comp_put_grid(&wp->w_grid_alloc, comp_row, comp_col,
- wp->w_height_outer, wp->w_width_outer, valid, false);
- ui_check_cursor_grid(wp->w_grid_alloc.handle);
- wp->w_grid_alloc.focusable = wp->w_float_config.focusable;
- if (!valid) {
- wp->w_grid_alloc.valid = false;
- redraw_later(wp, UPD_NOT_VALID);
+
+ if (!c.hide) {
+ ui_comp_put_grid(&wp->w_grid_alloc, comp_row, comp_col,
+ wp->w_height_outer, wp->w_width_outer, valid, false);
+ ui_check_cursor_grid(wp->w_grid_alloc.handle);
+ wp->w_grid_alloc.focusable = wp->w_float_config.focusable;
+ if (!valid) {
+ wp->w_grid_alloc.valid = false;
+ redraw_later(wp, UPD_NOT_VALID);
+ }
+ } else {
+ ui_comp_remove_grid(&wp->w_grid_alloc);
}
}
} else {
diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua
index 6db9e7af3e..18c8a7370f 100644
--- a/test/functional/ui/float_spec.lua
+++ b/test/functional/ui/float_spec.lua
@@ -1172,14 +1172,14 @@ describe('float window', function()
it('return their configuration', function()
local buf = meths.create_buf(false, false)
local win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=3, col=5, zindex=60})
- local expected = {anchor='NW', col=5, external=false, focusable=true, height=2, relative='editor', row=3, width=20, zindex=60}
+ local expected = {anchor='NW', col=5, external=false, focusable=true, height=2, relative='editor', row=3, width=20, zindex=60, hide=false}
eq(expected, meths.win_get_config(win))
- eq({relative='', external=false, focusable=true}, meths.win_get_config(0))
+ eq({relative='', external=false, focusable=true, hide=false}, meths.win_get_config(0))
if multigrid then
meths.win_set_config(win, {external=true, width=10, height=1})
- eq({external=true,focusable=true,width=10,height=1,relative=''}, meths.win_get_config(win))
+ eq({external=true,focusable=true,width=10,height=1,relative='',hide=false}, meths.win_get_config(win))
end
end)
@@ -4281,7 +4281,7 @@ describe('float window', function()
|
]]}
end
- eq({relative='win', width=12, height=1, bufpos={1,32}, anchor='NW',
+ eq({relative='win', width=12, height=1, bufpos={1,32}, anchor='NW', hide=false,
external=false, col=0, row=1, win=firstwin, focusable=true, zindex=50}, meths.win_get_config(win))
feed('<c-e>')
@@ -10809,6 +10809,124 @@ describe('float window', function()
]]}
end
end)
+
+ it('float window with hide option', function()
+ local buf = meths.create_buf(false,false)
+ local win = meths.open_win(buf, false, {relative='editor', width=10, height=2, row=2, col=5, hide = true})
+ local expected_pos = {
+ [4]={{id=1001}, 'NW', 1, 2, 5, true},
+ }
+
+ if multigrid then
+ screen:expect{grid=[[
+ ## grid 1
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [3:----------------------------------------]|
+ ## grid 2
+ ^ |
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ ## grid 3
+ |
+
+ ## grid 4 (hidden)
+ {1: }|
+ {2:~ }|
+ ]], float_pos = {}}
+ else
+ screen:expect([[
+ ^ |
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ |
+ ]])
+ end
+
+ meths.win_set_config(win, {hide = false})
+ if multigrid then
+ screen:expect{grid=[[
+ ## grid 1
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [3:----------------------------------------]|
+ ## grid 2
+ ^ |
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ ## grid 3
+ |
+
+ ## grid 4
+ {1: }|
+ {2:~ }|
+ ]], float_pos = expected_pos}
+ else
+ screen:expect([[
+ ^ |
+ {0:~ }|
+ {0:~ }{1: }{0: }|
+ {0:~ }{2:~ }{0: }|
+ {0:~ }|
+ {0:~ }|
+ |
+ ]])
+ end
+
+ meths.win_set_config(win, {hide=true})
+ if multigrid then
+ screen:expect{grid=[[
+ ## grid 1
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [3:----------------------------------------]|
+ ## grid 2
+ ^ |
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ ## grid 3
+ |
+
+ ## grid 4 (hidden)
+ {1: }|
+ {2:~ }|
+ ]], float_pos = {}}
+ else
+ screen:expect([[
+ ^ |
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ |
+ ]])
+ end
+ end)
end
describe('with ext_multigrid', function()
diff --git a/test/old/testdir/test.sh b/test/old/testdir/test.sh
index affdc308d1..6e7fa9db18 100644
--- a/test/old/testdir/test.sh
+++ b/test/old/testdir/test.sh
@@ -85,7 +85,5 @@ valgrind_check() {
}
check_sanitizer() {
- if test -n "${CLANG_SANITIZER}"; then
- check_logs "${1}" "*san.*" | cat
- fi
+ check_logs "${1}" "*san.*"
}
diff --git a/test/old/testdir/test_cmdline.vim b/test/old/testdir/test_cmdline.vim
index a85c8229af..54f5dd500b 100644
--- a/test/old/testdir/test_cmdline.vim
+++ b/test/old/testdir/test_cmdline.vim
@@ -3702,4 +3702,20 @@ func Test_custom_completion()
delfunc Check_customlist_completion
endfunc
+func Test_custom_completion_with_glob()
+ func TestGlobComplete(A, L, P)
+ return split(glob('Xglob*'), "\n")
+ endfunc
+
+ command -nargs=* -complete=customlist,TestGlobComplete TestGlobComplete :
+ call writefile([], 'Xglob1', 'D')
+ call writefile([], 'Xglob2', 'D')
+
+ call feedkeys(":TestGlobComplete \<Tab> \<Tab>\<C-N> \<Tab>\<C-P>;\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"TestGlobComplete Xglob1 Xglob2 ;', @:)
+
+ delcommand TestGlobComplete
+ delfunc TestGlobComplete
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_writefile.vim b/test/old/testdir/test_writefile.vim
index 312d45e18f..1e0556c92d 100644
--- a/test/old/testdir/test_writefile.vim
+++ b/test/old/testdir/test_writefile.vim
@@ -990,4 +990,27 @@ func Test_wq_quitpre_autocommand()
call delete('Xsomefile')
endfunc
+func Test_write_with_xattr_support()
+ CheckLinux
+ CheckFeature xattr
+ CheckExecutable setfattr
+
+ let contents = ["file with xattrs", "line two"]
+ call writefile(contents, 'Xwattr.txt', 'D')
+ " write a couple of xattr
+ call system('setfattr -n user.cookie -v chocolate Xwattr.txt')
+ call system('setfattr -n user.frieda -v bar Xwattr.txt')
+ call system('setfattr -n user.empty Xwattr.txt')
+
+ set backupcopy=no writebackup& backup&
+ sp Xwattr.txt
+ w
+ $r! getfattr -d %
+ let expected = ['file with xattrs', 'line two', '# file: Xwattr.txt', 'user.cookie="chocolate"', 'user.empty=""', 'user.frieda="bar"', '']
+ call assert_equal(expected, getline(1,'$'))
+
+ set backupcopy&
+ bw!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/unit/buffer_spec.lua b/test/unit/buffer_spec.lua
index a54ea8c656..6e08a09295 100644
--- a/test/unit/buffer_spec.lua
+++ b/test/unit/buffer_spec.lua
@@ -1,15 +1,11 @@
-
local helpers = require("test.unit.helpers")(after_each)
local itp = helpers.gen_itp(it)
local to_cstr = helpers.to_cstr
-local get_str = helpers.ffi.string
local eq = helpers.eq
local NULL = helpers.NULL
-local globals = helpers.cimport("./src/nvim/globals.h")
local buffer = helpers.cimport("./src/nvim/buffer.h")
-local stl = helpers.cimport("./src/nvim/statusline.h")
describe('buffer functions', function()
@@ -210,276 +206,4 @@ describe('buffer functions', function()
close_buffer(NULL, buf2, buffer.DOBUF_WIPE, 0, 0)
end)
end)
-
- describe('build_stl_str_hl', function()
- local buffer_byte_size = 100
- local STL_INITIAL_ITEMS = 20
- local output_buffer = ''
-
- -- This function builds the statusline
- --
- -- @param arg Optional arguments are:
- -- .pat The statusline format string
- -- .fillchar The fill character used in the statusline
- -- .maximum_cell_count The number of cells available in the statusline
- local function build_stl_str_hl(arg)
- output_buffer = to_cstr(string.rep(" ", buffer_byte_size))
-
- local pat = arg.pat or ''
- local fillchar = arg.fillchar or (' '):byte()
- local maximum_cell_count = arg.maximum_cell_count or buffer_byte_size
-
- return stl.build_stl_str_hl(globals.curwin,
- output_buffer,
- buffer_byte_size,
- to_cstr(pat),
- NULL,
- 0,
- fillchar,
- maximum_cell_count,
- NULL,
- NULL,
- NULL)
- end
-
- -- Use this function to simplify testing the comparison between
- -- the format string and the resulting statusline.
- --
- -- @param description The description of what the test should be doing
- -- @param statusline_cell_count The number of cells available in the statusline
- -- @param input_stl The format string for the statusline
- -- @param expected_stl The expected result string for the statusline
- --
- -- @param arg Options can be placed in an optional dictionary as the last parameter
- -- .expected_cell_count The expected number of cells build_stl_str_hl will return
- -- .expected_byte_length The expected byte length of the string (defaults to byte length of expected_stl)
- -- .file_name The name of the file to be tested (useful in %f type tests)
- -- .fillchar The character that will be used to fill any 'extra' space in the stl
- local function statusline_test (description,
- statusline_cell_count,
- input_stl,
- expected_stl,
- arg)
-
- -- arg is the optional parameter
- -- so we either fill in option with arg or an empty dictionary
- local option = arg or {}
-
- local fillchar = option.fillchar or (' '):byte()
- local expected_cell_count = option.expected_cell_count or statusline_cell_count
- local expected_byte_length = option.expected_byte_length or #expected_stl
-
- itp(description, function()
- if option.file_name then
- buffer.setfname(globals.curbuf, to_cstr(option.file_name), NULL, 1)
- else
- buffer.setfname(globals.curbuf, nil, NULL, 1)
- end
-
- local result_cell_count = build_stl_str_hl{pat=input_stl,
- maximum_cell_count=statusline_cell_count,
- fillchar=fillchar}
-
- eq(expected_stl, get_str(output_buffer, expected_byte_length))
- eq(expected_cell_count, result_cell_count)
- end)
- end
-
- -- expression testing
- statusline_test('Should expand expression', 2,
- '%!expand(20+1)', '21')
- statusline_test('Should expand broken expression to itself', 11,
- '%!expand(20+1', 'expand(20+1')
-
- -- file name testing
- statusline_test('should print no file name', 10,
- '%f', '[No Name]',
- {expected_cell_count=9})
- statusline_test('should print the relative file name', 30,
- '%f', 'test/unit/buffer_spec.lua',
- {file_name='test/unit/buffer_spec.lua', expected_cell_count=25})
- statusline_test('should print the full file name', 40,
- '%F', '/test/unit/buffer_spec.lua',
- {file_name='/test/unit/buffer_spec.lua', expected_cell_count=26})
-
- -- fillchar testing
- statusline_test('should handle `!` as a fillchar', 10,
- 'abcde%=', 'abcde!!!!!',
- {fillchar=('!'):byte()})
- statusline_test('should handle `~` as a fillchar', 10,
- '%=abcde', '~~~~~abcde',
- {fillchar=('~'):byte()})
- statusline_test('should put fillchar `!` in between text', 10,
- 'abc%=def', 'abc!!!!def',
- {fillchar=('!'):byte()})
- statusline_test('should put fillchar `~` in between text', 10,
- 'abc%=def', 'abc~~~~def',
- {fillchar=('~'):byte()})
- statusline_test('should put fillchar `━` in between text', 10,
- 'abc%=def', 'abc━━━━def',
- {fillchar=0x2501})
- statusline_test('should handle zero-fillchar as a space', 10,
- 'abcde%=', 'abcde ',
- {fillchar=0})
- statusline_test('should print the tail file name', 80,
- '%t', 'buffer_spec.lua',
- {file_name='test/unit/buffer_spec.lua', expected_cell_count=15})
-
- -- standard text testing
- statusline_test('should copy plain text', 80,
- 'this is a test', 'this is a test',
- {expected_cell_count=14})
-
- -- line number testing
- statusline_test('should print the buffer number', 80,
- '%n', '1',
- {expected_cell_count=1})
- statusline_test('should print the current line number in the buffer', 80,
- '%l', '0',
- {expected_cell_count=1})
- statusline_test('should print the number of lines in the buffer', 80,
- '%L', '1',
- {expected_cell_count=1})
-
- -- truncation testing
- statusline_test('should truncate when standard text pattern is too long', 10,
- '0123456789abcde', '<6789abcde')
- statusline_test('should truncate when using =', 10,
- 'abcdef%=ghijkl', 'abcdef<jkl')
- statusline_test('should truncate centered text when using ==', 10,
- 'abcde%=gone%=fghij', 'abcde<ghij')
- statusline_test('should respect the `<` marker', 10,
- 'abc%<defghijkl', 'abc<ghijkl')
- statusline_test('should truncate at `<` with one `=`, test 1', 10,
- 'abc%<def%=ghijklmno', 'abc<jklmno')
- statusline_test('should truncate at `<` with one `=`, test 2', 10,
- 'abcdef%=ghijkl%<mno', 'abcdefghi>')
- statusline_test('should truncate at `<` with one `=`, test 3', 10,
- 'abc%<def%=ghijklmno', 'abc<jklmno')
- statusline_test('should truncate at `<` with one `=`, test 4', 10,
- 'abc%<def%=ghij', 'abcdefghij')
- statusline_test('should truncate at `<` with one `=`, test 4', 10,
- 'abc%<def%=ghijk', 'abc<fghijk')
-
- statusline_test('should truncate at `<` with many `=`, test 4', 10,
- 'ab%<cdef%=g%=h%=ijk', 'ab<efghijk')
-
- statusline_test('should truncate at the first `<`', 10,
- 'abc%<def%<ghijklm', 'abc<hijklm')
-
- statusline_test('should ignore trailing %', 3, 'abc%', 'abc')
-
- -- alignment testing with fillchar
- local function statusline_test_align (description,
- statusline_cell_count,
- input_stl,
- expected_stl,
- arg)
- arg = arg or {}
- statusline_test(description .. ' without fillchar',
- statusline_cell_count, input_stl, expected_stl:gsub('%~', ' '), arg)
- arg.fillchar = ('!'):byte()
- statusline_test(description .. ' with fillchar `!`',
- statusline_cell_count, input_stl, expected_stl:gsub('%~', '!'), arg)
- arg.fillchar = 0x2501
- statusline_test(description .. ' with fillchar `━`',
- statusline_cell_count, input_stl, expected_stl:gsub('%~', '━'), arg)
- end
-
- statusline_test_align('should right align when using =', 20,
- 'neo%=vim', 'neo~~~~~~~~~~~~~~vim')
- statusline_test_align('should, when possible, center text when using %=text%=', 20,
- 'abc%=neovim%=def', 'abc~~~~neovim~~~~def')
- statusline_test_align('should handle uneven spacing in the buffer when using %=text%=', 20,
- 'abc%=neo_vim%=def', 'abc~~~neo_vim~~~~def')
- statusline_test_align('should have equal spaces even with non-equal sides when using =', 20,
- 'foobar%=test%=baz', 'foobar~~~test~~~~baz')
- statusline_test_align('should have equal spaces even with longer right side when using =', 20,
- 'a%=test%=longtext', 'a~~~test~~~~longtext')
- statusline_test_align('should handle an empty left side when using ==', 20,
- '%=test%=baz', '~~~~~~test~~~~~~~baz')
- statusline_test_align('should handle an empty right side when using ==', 20,
- 'foobar%=test%=', 'foobar~~~~~test~~~~~')
- statusline_test_align('should handle consecutive empty ==', 20,
- '%=%=test%=', '~~~~~~~~~~test~~~~~~')
- statusline_test_align('should handle an = alone', 20,
- '%=', '~~~~~~~~~~~~~~~~~~~~')
- statusline_test_align('should right align text when it is alone with =', 20,
- '%=foo', '~~~~~~~~~~~~~~~~~foo')
- statusline_test_align('should left align text when it is alone with =', 20,
- 'foo%=', 'foo~~~~~~~~~~~~~~~~~')
-
- statusline_test_align('should approximately center text when using %=text%=', 21,
- 'abc%=neovim%=def', 'abc~~~~neovim~~~~~def')
- statusline_test_align('should completely fill the buffer when using %=text%=', 21,
- 'abc%=neo_vim%=def', 'abc~~~~neo_vim~~~~def')
- statusline_test_align('should have equal spacing even with non-equal sides when using =', 21,
- 'foobar%=test%=baz', 'foobar~~~~test~~~~baz')
- statusline_test_align('should have equal spacing even with longer right side when using =', 21,
- 'a%=test%=longtext', 'a~~~~test~~~~longtext')
- statusline_test_align('should handle an empty left side when using ==', 21,
- '%=test%=baz', '~~~~~~~test~~~~~~~baz')
- statusline_test_align('should handle an empty right side when using ==', 21,
- 'foobar%=test%=', 'foobar~~~~~test~~~~~~')
-
- statusline_test_align('should quadrant the text when using 3 %=', 40,
- 'abcd%=n%=eovim%=ef', 'abcd~~~~~~~~~n~~~~~~~~~eovim~~~~~~~~~~ef')
- statusline_test_align('should work well with %t', 40,
- '%t%=right_aligned', 'buffer_spec.lua~~~~~~~~~~~~right_aligned',
- {file_name='test/unit/buffer_spec.lua'})
- statusline_test_align('should work well with %t and regular text', 40,
- 'l%=m_l %t m_r%=r', 'l~~~~~~~m_l buffer_spec.lua m_r~~~~~~~~r',
- {file_name='test/unit/buffer_spec.lua'})
- statusline_test_align('should work well with %=, %t, %L, and %l', 40,
- '%t %= %L %= %l', 'buffer_spec.lua ~~~~~~~~~ 1 ~~~~~~~~~~ 0',
- {file_name='test/unit/buffer_spec.lua'})
-
- statusline_test_align('should quadrant the text when using 3 %=', 41,
- 'abcd%=n%=eovim%=ef', 'abcd~~~~~~~~~n~~~~~~~~~eovim~~~~~~~~~~~ef')
- statusline_test_align('should work well with %t', 41,
- '%t%=right_aligned', 'buffer_spec.lua~~~~~~~~~~~~~right_aligned',
- {file_name='test/unit/buffer_spec.lua'})
- statusline_test_align('should work well with %t and regular text', 41,
- 'l%=m_l %t m_r%=r', 'l~~~~~~~~m_l buffer_spec.lua m_r~~~~~~~~r',
- {file_name='test/unit/buffer_spec.lua'})
- statusline_test_align('should work well with %=, %t, %L, and %l', 41,
- '%t %= %L %= %l', 'buffer_spec.lua ~~~~~~~~~~ 1 ~~~~~~~~~~ 0',
- {file_name='test/unit/buffer_spec.lua'})
-
- statusline_test_align('should work with 10 %=', 50,
- 'aaaa%=b%=c%=d%=e%=fg%=hi%=jk%=lmnop%=qrstuv%=wxyz',
- 'aaaa~~b~~c~~d~~e~~fg~~hi~~jk~~lmnop~~qrstuv~~~wxyz')
-
- -- stl item testing
- local tabline = ''
- for i= 1, 1000 do
- tabline = tabline .. (i % 2 == 0 and '%#TabLineSel#' or '%#TabLineFill#') .. tostring(i % 2)
- end
- statusline_test('should handle a large amount of any items', 20,
- tabline,
- '<1010101010101010101') -- Should not show any error
- statusline_test('should handle a larger amount of = than stl initial item', 20,
- ('%='):rep(STL_INITIAL_ITEMS * 5),
- ' ') -- Should not show any error
- statusline_test('should handle many extra characters', 20,
- 'a' .. ('a'):rep(STL_INITIAL_ITEMS * 5),
- '<aaaaaaaaaaaaaaaaaaa') -- Does not show any error
- statusline_test('should handle many extra characters and flags', 20,
- 'a' .. ('%=a'):rep(STL_INITIAL_ITEMS * 2),
- 'a<aaaaaaaaaaaaaaaaaa') -- Should not show any error
-
-
- -- multi-byte testing
- statusline_test('should handle multibyte characters', 10,
- 'Ĉ%=x', 'Ĉ x')
- statusline_test('should handle multibyte characters and different fillchars', 10,
- 'Ą%=mid%=end', 'Ą@mid@@end',
- {fillchar=('@'):byte()})
-
- -- escaping % testing
- statusline_test('should handle escape of %', 4, 'abc%%', 'abc%')
- statusline_test('case where escaped % does not fit', 3, 'abc%%abcabc', '<bc')
- statusline_test('escaped % is first', 1, '%%', '%')
-
- end)
end)
diff --git a/test/unit/keycodes_spec.lua b/test/unit/keycodes_spec.lua
index 5bf27c9232..4da3d37aaa 100644
--- a/test/unit/keycodes_spec.lua
+++ b/test/unit/keycodes_spec.lua
@@ -5,7 +5,7 @@ local ffi = helpers.ffi
local eq = helpers.eq
local neq = helpers.neq
-local keymap = helpers.cimport('./src/nvim/keycodes.h')
+local keycodes = helpers.cimport('./src/nvim/keycodes.h')
local NULL = helpers.NULL
describe('keycodes.c', function()
@@ -16,12 +16,12 @@ describe('keycodes.c', function()
itp('no keycode', function()
srcp[0] = 'abc'
- eq(0, keymap.find_special_key(srcp, 3, modp, 0, NULL))
+ eq(0, keycodes.find_special_key(srcp, 3, modp, 0, NULL))
end)
itp('keycode with multiple modifiers', function()
srcp[0] = '<C-M-S-A>'
- neq(0, keymap.find_special_key(srcp, 9, modp, 0, NULL))
+ neq(0, keycodes.find_special_key(srcp, 9, modp, 0, NULL))
neq(0, modp[0])
end)
@@ -29,22 +29,22 @@ describe('keycodes.c', function()
-- Compare other capitalizations to this.
srcp[0] = '<C-A>'
local all_caps_key =
- keymap.find_special_key(srcp, 5, modp, 0, NULL)
+ keycodes.find_special_key(srcp, 5, modp, 0, NULL)
local all_caps_mod = modp[0]
srcp[0] = '<C-a>'
eq(all_caps_key,
- keymap.find_special_key(srcp, 5, modp, 0, NULL))
+ keycodes.find_special_key(srcp, 5, modp, 0, NULL))
eq(all_caps_mod, modp[0])
srcp[0] = '<c-A>'
eq(all_caps_key,
- keymap.find_special_key(srcp, 5, modp, 0, NULL))
+ keycodes.find_special_key(srcp, 5, modp, 0, NULL))
eq(all_caps_mod, modp[0])
srcp[0] = '<c-a>'
eq(all_caps_key,
- keymap.find_special_key(srcp, 5, modp, 0, NULL))
+ keycodes.find_special_key(srcp, 5, modp, 0, NULL))
eq(all_caps_mod, modp[0])
end)
@@ -52,20 +52,20 @@ describe('keycodes.c', function()
-- Unescaped with in_string=false
srcp[0] = '<C-">'
eq(string.byte('"'),
- keymap.find_special_key(srcp, 5, modp, 0, NULL))
+ keycodes.find_special_key(srcp, 5, modp, 0, NULL))
-- Unescaped with in_string=true
- eq(0, keymap.find_special_key(srcp, 5, modp, keymap.FSK_IN_STRING, NULL))
+ eq(0, keycodes.find_special_key(srcp, 5, modp, keycodes.FSK_IN_STRING, NULL))
-- Escaped with in_string=false
srcp[0] = '<C-\\">'
-- Should fail because the key is invalid
-- (more than 1 non-modifier character).
- eq(0, keymap.find_special_key(srcp, 6, modp, 0, NULL))
+ eq(0, keycodes.find_special_key(srcp, 6, modp, 0, NULL))
-- Escaped with in_string=true
eq(string.byte('"'),
- keymap.find_special_key(srcp, 6, modp, keymap.FSK_IN_STRING, NULL))
+ keycodes.find_special_key(srcp, 6, modp, keycodes.FSK_IN_STRING, NULL))
end)
end)
diff --git a/test/unit/optionstr_spec.lua b/test/unit/optionstr_spec.lua
index f8122f4fe0..2e7198a63a 100644
--- a/test/unit/optionstr_spec.lua
+++ b/test/unit/optionstr_spec.lua
@@ -4,10 +4,10 @@ local itp = helpers.gen_itp(it)
local to_cstr = helpers.to_cstr
local eq = helpers.eq
-local option = helpers.cimport("./src/nvim/optionstr.h")
+local optionstr = helpers.cimport("./src/nvim/optionstr.h")
local check_ff_value = function(ff)
- return option.check_ff_value(to_cstr(ff))
+ return optionstr.check_ff_value(to_cstr(ff))
end
describe('check_ff_value', function()
diff --git a/test/unit/os/fs_spec.lua b/test/unit/os/fs_spec.lua
index 3a40e97755..8f45d2b0c7 100644
--- a/test/unit/os/fs_spec.lua
+++ b/test/unit/os/fs_spec.lua
@@ -22,10 +22,6 @@ local endswith = helpers.endswith
local NODE_NORMAL = 0
local NODE_WRITABLE = 1
-cimport('./src/nvim/os/shell.h')
-cimport('./src/nvim/option_defs.h')
-cimport('./src/nvim/main.h')
-cimport('./src/nvim/fileio.h')
local fs = cimport('./src/nvim/os/os.h', './src/nvim/path.h')
cppimport('sys/stat.h')
cppimport('fcntl.h')
diff --git a/test/unit/os/shell_spec.lua b/test/unit/os/shell_spec.lua
index 29a2b78491..3fb1afed44 100644
--- a/test/unit/os/shell_spec.lua
+++ b/test/unit/os/shell_spec.lua
@@ -2,7 +2,7 @@ local helpers = require('test.unit.helpers')(after_each)
local itp = helpers.gen_itp(it)
local cimported = helpers.cimport(
'./src/nvim/os/shell.h',
- './src/nvim/option_defs.h',
+ './src/nvim/option_vars.h',
'./src/nvim/main.h',
'./src/nvim/memory.h'
)
diff --git a/test/unit/path_spec.lua b/test/unit/path_spec.lua
index f9ce1ff099..23f71cfe78 100644
--- a/test/unit/path_spec.lua
+++ b/test/unit/path_spec.lua
@@ -15,7 +15,7 @@ local mkdir = helpers.mkdir
cimport('string.h')
local cimp = cimport('./src/nvim/os/os.h', './src/nvim/path.h')
-local options = cimport('./src/nvim/option_defs.h')
+local options = cimport('./src/nvim/option_vars.h')
local length = 0
local buffer = nil
diff --git a/test/unit/statusline_spec.lua b/test/unit/statusline_spec.lua
new file mode 100644
index 0000000000..a124a588e9
--- /dev/null
+++ b/test/unit/statusline_spec.lua
@@ -0,0 +1,282 @@
+local helpers = require("test.unit.helpers")(after_each)
+local itp = helpers.gen_itp(it)
+
+local to_cstr = helpers.to_cstr
+local get_str = helpers.ffi.string
+local eq = helpers.eq
+local NULL = helpers.NULL
+
+local buffer = helpers.cimport("./src/nvim/buffer.h")
+local globals = helpers.cimport("./src/nvim/globals.h")
+local stl = helpers.cimport("./src/nvim/statusline.h")
+
+describe('build_stl_str_hl', function()
+ local buffer_byte_size = 100
+ local STL_INITIAL_ITEMS = 20
+ local output_buffer = ''
+
+ -- This function builds the statusline
+ --
+ -- @param arg Optional arguments are:
+ -- .pat The statusline format string
+ -- .fillchar The fill character used in the statusline
+ -- .maximum_cell_count The number of cells available in the statusline
+ local function build_stl_str_hl(arg)
+ output_buffer = to_cstr(string.rep(" ", buffer_byte_size))
+
+ local pat = arg.pat or ''
+ local fillchar = arg.fillchar or (' '):byte()
+ local maximum_cell_count = arg.maximum_cell_count or buffer_byte_size
+
+ return stl.build_stl_str_hl(globals.curwin,
+ output_buffer,
+ buffer_byte_size,
+ to_cstr(pat),
+ NULL,
+ 0,
+ fillchar,
+ maximum_cell_count,
+ NULL,
+ NULL,
+ NULL)
+ end
+
+ -- Use this function to simplify testing the comparison between
+ -- the format string and the resulting statusline.
+ --
+ -- @param description The description of what the test should be doing
+ -- @param statusline_cell_count The number of cells available in the statusline
+ -- @param input_stl The format string for the statusline
+ -- @param expected_stl The expected result string for the statusline
+ --
+ -- @param arg Options can be placed in an optional dictionary as the last parameter
+ -- .expected_cell_count The expected number of cells build_stl_str_hl will return
+ -- .expected_byte_length The expected byte length of the string (defaults to byte length of expected_stl)
+ -- .file_name The name of the file to be tested (useful in %f type tests)
+ -- .fillchar The character that will be used to fill any 'extra' space in the stl
+ local function statusline_test(description,
+ statusline_cell_count,
+ input_stl,
+ expected_stl,
+ arg)
+
+ -- arg is the optional parameter
+ -- so we either fill in option with arg or an empty dictionary
+ local option = arg or {}
+
+ local fillchar = option.fillchar or (' '):byte()
+ local expected_cell_count = option.expected_cell_count or statusline_cell_count
+ local expected_byte_length = option.expected_byte_length or #expected_stl
+
+ itp(description, function()
+ if option.file_name then
+ buffer.setfname(globals.curbuf, to_cstr(option.file_name), NULL, 1)
+ else
+ buffer.setfname(globals.curbuf, nil, NULL, 1)
+ end
+
+ local result_cell_count = build_stl_str_hl{pat=input_stl,
+ maximum_cell_count=statusline_cell_count,
+ fillchar=fillchar}
+
+ eq(expected_stl, get_str(output_buffer, expected_byte_length))
+ eq(expected_cell_count, result_cell_count)
+ end)
+ end
+
+ -- expression testing
+ statusline_test('Should expand expression', 2,
+ '%!expand(20+1)', '21')
+ statusline_test('Should expand broken expression to itself', 11,
+ '%!expand(20+1', 'expand(20+1')
+
+ -- file name testing
+ statusline_test('should print no file name', 10,
+ '%f', '[No Name]',
+ {expected_cell_count=9})
+ statusline_test('should print the relative file name', 30,
+ '%f', 'test/unit/buffer_spec.lua',
+ {file_name='test/unit/buffer_spec.lua', expected_cell_count=25})
+ statusline_test('should print the full file name', 40,
+ '%F', '/test/unit/buffer_spec.lua',
+ {file_name='/test/unit/buffer_spec.lua', expected_cell_count=26})
+
+ -- fillchar testing
+ statusline_test('should handle `!` as a fillchar', 10,
+ 'abcde%=', 'abcde!!!!!',
+ {fillchar=('!'):byte()})
+ statusline_test('should handle `~` as a fillchar', 10,
+ '%=abcde', '~~~~~abcde',
+ {fillchar=('~'):byte()})
+ statusline_test('should put fillchar `!` in between text', 10,
+ 'abc%=def', 'abc!!!!def',
+ {fillchar=('!'):byte()})
+ statusline_test('should put fillchar `~` in between text', 10,
+ 'abc%=def', 'abc~~~~def',
+ {fillchar=('~'):byte()})
+ statusline_test('should put fillchar `━` in between text', 10,
+ 'abc%=def', 'abc━━━━def',
+ {fillchar=0x2501})
+ statusline_test('should handle zero-fillchar as a space', 10,
+ 'abcde%=', 'abcde ',
+ {fillchar=0})
+ statusline_test('should print the tail file name', 80,
+ '%t', 'buffer_spec.lua',
+ {file_name='test/unit/buffer_spec.lua', expected_cell_count=15})
+
+ -- standard text testing
+ statusline_test('should copy plain text', 80,
+ 'this is a test', 'this is a test',
+ {expected_cell_count=14})
+
+ -- line number testing
+ statusline_test('should print the buffer number', 80,
+ '%n', '1',
+ {expected_cell_count=1})
+ statusline_test('should print the current line number in the buffer', 80,
+ '%l', '0',
+ {expected_cell_count=1})
+ statusline_test('should print the number of lines in the buffer', 80,
+ '%L', '1',
+ {expected_cell_count=1})
+
+ -- truncation testing
+ statusline_test('should truncate when standard text pattern is too long', 10,
+ '0123456789abcde', '<6789abcde')
+ statusline_test('should truncate when using =', 10,
+ 'abcdef%=ghijkl', 'abcdef<jkl')
+ statusline_test('should truncate centered text when using ==', 10,
+ 'abcde%=gone%=fghij', 'abcde<ghij')
+ statusline_test('should respect the `<` marker', 10,
+ 'abc%<defghijkl', 'abc<ghijkl')
+ statusline_test('should truncate at `<` with one `=`, test 1', 10,
+ 'abc%<def%=ghijklmno', 'abc<jklmno')
+ statusline_test('should truncate at `<` with one `=`, test 2', 10,
+ 'abcdef%=ghijkl%<mno', 'abcdefghi>')
+ statusline_test('should truncate at `<` with one `=`, test 3', 10,
+ 'abc%<def%=ghijklmno', 'abc<jklmno')
+ statusline_test('should truncate at `<` with one `=`, test 4', 10,
+ 'abc%<def%=ghij', 'abcdefghij')
+ statusline_test('should truncate at `<` with one `=`, test 4', 10,
+ 'abc%<def%=ghijk', 'abc<fghijk')
+
+ statusline_test('should truncate at `<` with many `=`, test 4', 10,
+ 'ab%<cdef%=g%=h%=ijk', 'ab<efghijk')
+
+ statusline_test('should truncate at the first `<`', 10,
+ 'abc%<def%<ghijklm', 'abc<hijklm')
+
+ statusline_test('should ignore trailing %', 3, 'abc%', 'abc')
+
+ -- alignment testing with fillchar
+ local function statusline_test_align(description,
+ statusline_cell_count,
+ input_stl,
+ expected_stl,
+ arg)
+ arg = arg or {}
+ statusline_test(description .. ' without fillchar',
+ statusline_cell_count, input_stl, expected_stl:gsub('%~', ' '), arg)
+ arg.fillchar = ('!'):byte()
+ statusline_test(description .. ' with fillchar `!`',
+ statusline_cell_count, input_stl, expected_stl:gsub('%~', '!'), arg)
+ arg.fillchar = 0x2501
+ statusline_test(description .. ' with fillchar `━`',
+ statusline_cell_count, input_stl, expected_stl:gsub('%~', '━'), arg)
+ end
+
+ statusline_test_align('should right align when using =', 20,
+ 'neo%=vim', 'neo~~~~~~~~~~~~~~vim')
+ statusline_test_align('should, when possible, center text when using %=text%=', 20,
+ 'abc%=neovim%=def', 'abc~~~~neovim~~~~def')
+ statusline_test_align('should handle uneven spacing in the buffer when using %=text%=', 20,
+ 'abc%=neo_vim%=def', 'abc~~~neo_vim~~~~def')
+ statusline_test_align('should have equal spaces even with non-equal sides when using =', 20,
+ 'foobar%=test%=baz', 'foobar~~~test~~~~baz')
+ statusline_test_align('should have equal spaces even with longer right side when using =', 20,
+ 'a%=test%=longtext', 'a~~~test~~~~longtext')
+ statusline_test_align('should handle an empty left side when using ==', 20,
+ '%=test%=baz', '~~~~~~test~~~~~~~baz')
+ statusline_test_align('should handle an empty right side when using ==', 20,
+ 'foobar%=test%=', 'foobar~~~~~test~~~~~')
+ statusline_test_align('should handle consecutive empty ==', 20,
+ '%=%=test%=', '~~~~~~~~~~test~~~~~~')
+ statusline_test_align('should handle an = alone', 20,
+ '%=', '~~~~~~~~~~~~~~~~~~~~')
+ statusline_test_align('should right align text when it is alone with =', 20,
+ '%=foo', '~~~~~~~~~~~~~~~~~foo')
+ statusline_test_align('should left align text when it is alone with =', 20,
+ 'foo%=', 'foo~~~~~~~~~~~~~~~~~')
+
+ statusline_test_align('should approximately center text when using %=text%=', 21,
+ 'abc%=neovim%=def', 'abc~~~~neovim~~~~~def')
+ statusline_test_align('should completely fill the buffer when using %=text%=', 21,
+ 'abc%=neo_vim%=def', 'abc~~~~neo_vim~~~~def')
+ statusline_test_align('should have equal spacing even with non-equal sides when using =', 21,
+ 'foobar%=test%=baz', 'foobar~~~~test~~~~baz')
+ statusline_test_align('should have equal spacing even with longer right side when using =', 21,
+ 'a%=test%=longtext', 'a~~~~test~~~~longtext')
+ statusline_test_align('should handle an empty left side when using ==', 21,
+ '%=test%=baz', '~~~~~~~test~~~~~~~baz')
+ statusline_test_align('should handle an empty right side when using ==', 21,
+ 'foobar%=test%=', 'foobar~~~~~test~~~~~~')
+
+ statusline_test_align('should quadrant the text when using 3 %=', 40,
+ 'abcd%=n%=eovim%=ef', 'abcd~~~~~~~~~n~~~~~~~~~eovim~~~~~~~~~~ef')
+ statusline_test_align('should work well with %t', 40,
+ '%t%=right_aligned', 'buffer_spec.lua~~~~~~~~~~~~right_aligned',
+ {file_name='test/unit/buffer_spec.lua'})
+ statusline_test_align('should work well with %t and regular text', 40,
+ 'l%=m_l %t m_r%=r', 'l~~~~~~~m_l buffer_spec.lua m_r~~~~~~~~r',
+ {file_name='test/unit/buffer_spec.lua'})
+ statusline_test_align('should work well with %=, %t, %L, and %l', 40,
+ '%t %= %L %= %l', 'buffer_spec.lua ~~~~~~~~~ 1 ~~~~~~~~~~ 0',
+ {file_name='test/unit/buffer_spec.lua'})
+
+ statusline_test_align('should quadrant the text when using 3 %=', 41,
+ 'abcd%=n%=eovim%=ef', 'abcd~~~~~~~~~n~~~~~~~~~eovim~~~~~~~~~~~ef')
+ statusline_test_align('should work well with %t', 41,
+ '%t%=right_aligned', 'buffer_spec.lua~~~~~~~~~~~~~right_aligned',
+ {file_name='test/unit/buffer_spec.lua'})
+ statusline_test_align('should work well with %t and regular text', 41,
+ 'l%=m_l %t m_r%=r', 'l~~~~~~~~m_l buffer_spec.lua m_r~~~~~~~~r',
+ {file_name='test/unit/buffer_spec.lua'})
+ statusline_test_align('should work well with %=, %t, %L, and %l', 41,
+ '%t %= %L %= %l', 'buffer_spec.lua ~~~~~~~~~~ 1 ~~~~~~~~~~ 0',
+ {file_name='test/unit/buffer_spec.lua'})
+
+ statusline_test_align('should work with 10 %=', 50,
+ 'aaaa%=b%=c%=d%=e%=fg%=hi%=jk%=lmnop%=qrstuv%=wxyz',
+ 'aaaa~~b~~c~~d~~e~~fg~~hi~~jk~~lmnop~~qrstuv~~~wxyz')
+
+ -- stl item testing
+ local tabline = ''
+ for i = 1, 1000 do
+ tabline = tabline .. (i % 2 == 0 and '%#TabLineSel#' or '%#TabLineFill#') .. tostring(i % 2)
+ end
+ statusline_test('should handle a large amount of any items', 20,
+ tabline,
+ '<1010101010101010101') -- Should not show any error
+ statusline_test('should handle a larger amount of = than stl initial item', 20,
+ ('%='):rep(STL_INITIAL_ITEMS * 5),
+ ' ') -- Should not show any error
+ statusline_test('should handle many extra characters', 20,
+ 'a' .. ('a'):rep(STL_INITIAL_ITEMS * 5),
+ '<aaaaaaaaaaaaaaaaaaa') -- Does not show any error
+ statusline_test('should handle many extra characters and flags', 20,
+ 'a' .. ('%=a'):rep(STL_INITIAL_ITEMS * 2),
+ 'a<aaaaaaaaaaaaaaaaaa') -- Should not show any error
+
+ -- multi-byte testing
+ statusline_test('should handle multibyte characters', 10,
+ 'Ĉ%=x', 'Ĉ x')
+ statusline_test('should handle multibyte characters and different fillchars', 10,
+ 'Ą%=mid%=end', 'Ą@mid@@end',
+ {fillchar=('@'):byte()})
+
+ -- escaping % testing
+ statusline_test('should handle escape of %', 4, 'abc%%', 'abc%')
+ statusline_test('case where escaped % does not fit', 3, 'abc%%abcabc', '<bc')
+ statusline_test('escaped % is first', 1, '%%', '%')
+
+end)
diff --git a/test/unit/undo_spec.lua b/test/unit/undo_spec.lua
index 9261eca19d..ee4203b94c 100644
--- a/test/unit/undo_spec.lua
+++ b/test/unit/undo_spec.lua
@@ -11,10 +11,7 @@ local neq = helpers.neq
local eq = helpers.eq
local mkdir = helpers.mkdir
-cimport('./src/nvim/ex_cmds_defs.h')
-cimport('./src/nvim/buffer_defs.h')
-local options = cimport('./src/nvim/option_defs.h')
--- TODO: remove: local vim = cimport('./src/nvim/vim.h')
+local options = cimport('./src/nvim/option_vars.h')
local undo = cimport('./src/nvim/undo.h')
local buffer = cimport('./src/nvim/buffer.h')