aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/test.yml3
-rw-r--r--.luacheckrc1
-rw-r--r--.stylua.toml2
-rw-r--r--.styluaignore10
-rw-r--r--CMakeLists.txt19
-rw-r--r--Makefile5
-rw-r--r--cmake/Format.cmake65
-rw-r--r--cmake/Util.cmake1
-rw-r--r--contrib/flake.lock12
-rw-r--r--runtime/colors/default.vim12
-rw-r--r--runtime/colors/vim.vim269
-rw-r--r--runtime/doc/api.txt18
-rw-r--r--runtime/doc/dev_theme.txt103
-rw-r--r--runtime/doc/news.txt4
-rw-r--r--runtime/doc/treesitter.txt2
-rw-r--r--runtime/doc/vim_diff.txt2
-rw-r--r--runtime/ftplugin/help.lua4
-rw-r--r--runtime/lua/vim/_meta/api.lua20
-rw-r--r--runtime/lua/vim/_meta/api_keysets.lua22
-rw-r--r--runtime/lua/vim/filetype.lua1
-rw-r--r--runtime/lua/vim/treesitter.lua3
-rw-r--r--runtime/syntax/pacmanlog.vim41
-rwxr-xr-xscripts/bump_deps.lua53
-rwxr-xr-xscripts/gen_eval_files.lua72
-rw-r--r--scripts/gen_filetype.lua102
-rw-r--r--scripts/gen_help_html.lua341
-rw-r--r--scripts/lintcommit.lua67
-rw-r--r--scripts/lua2dox.lua55
-rwxr-xr-xscripts/vimpatch.lua10
-rwxr-xr-xsrc/clint.py5
-rw-r--r--src/nvim/CMakeLists.txt11
-rw-r--r--src/nvim/api/buffer.c111
-rw-r--r--src/nvim/api/command.c6
-rw-r--r--src/nvim/api/deprecated.c7
-rw-r--r--src/nvim/api/deprecated.h1
-rw-r--r--src/nvim/api/dispatch_deprecated.lua132
-rw-r--r--src/nvim/api/extmark.c26
-rw-r--r--src/nvim/api/keysets_defs.h32
-rw-r--r--src/nvim/api/vim.c50
-rw-r--r--src/nvim/auevents.lua300
-rw-r--r--src/nvim/autocmd.h6
-rw-r--r--src/nvim/buffer_defs.h2
-rw-r--r--src/nvim/change.c2
-rw-r--r--src/nvim/channel.c17
-rw-r--r--src/nvim/decoration.c1
-rw-r--r--src/nvim/decoration.h2
-rw-r--r--src/nvim/drawscreen.c2
-rw-r--r--src/nvim/edit.c3
-rw-r--r--src/nvim/eval.lua16
-rw-r--r--src/nvim/ex_cmds.lua4478
-rw-r--r--src/nvim/extmark.h8
-rw-r--r--src/nvim/generators/c_grammar.lua90
-rw-r--r--src/nvim/generators/dump_bin_array.lua4
-rw-r--r--src/nvim/generators/gen_api_dispatch.lua507
-rw-r--r--src/nvim/generators/gen_api_ui_events.lua110
-rw-r--r--src/nvim/generators/gen_char_blob.lua31
-rw-r--r--src/nvim/generators/gen_declarations.lua154
-rw-r--r--src/nvim/generators/gen_eval.lua43
-rw-r--r--src/nvim/generators/gen_events.lua10
-rw-r--r--src/nvim/generators/gen_ex_cmds.lua81
-rw-r--r--src/nvim/generators/gen_options.lua107
-rw-r--r--src/nvim/generators/gen_unicode_tables.lua33
-rw-r--r--src/nvim/generators/gen_vimvim.lua16
-rw-r--r--src/nvim/generators/hashy.lua83
-rw-r--r--src/nvim/generators/preload.lua4
-rw-r--r--src/nvim/highlight_group.c527
-rw-r--r--src/nvim/insexpand.c34
-rw-r--r--src/nvim/lib/ringbuf.h290
-rw-r--r--src/nvim/marktree.c15
-rw-r--r--src/nvim/marktree.h83
-rw-r--r--src/nvim/marktree_defs.h83
-rw-r--r--src/nvim/plines.c1
-rw-r--r--src/nvim/plines.h4
-rw-r--r--src/nvim/terminal.c8
-rw-r--r--src/nvim/terminal.h2
-rw-r--r--test/benchmark/autocmd_spec.lua56
-rw-r--r--test/benchmark/bench_regexp_spec.lua3
-rw-r--r--test/benchmark/treesitter_spec.lua7
-rw-r--r--test/busted/outputHandlers/nvim.lua95
-rw-r--r--test/client/msgpack_rpc_stream.lua52
-rw-r--r--test/client/session.lua28
-rw-r--r--test/client/uv_stream.lua27
-rw-r--r--test/functional/api/buffer_updates_spec.lua2
-rw-r--r--test/functional/api/highlight_spec.lua2
-rw-r--r--test/functional/autocmd/focus_spec.lua6
-rw-r--r--test/functional/core/main_spec.lua19
-rw-r--r--test/functional/helpers.lua5
-rw-r--r--test/functional/legacy/scroll_opt_spec.lua20
-rw-r--r--test/functional/lua/buffer_updates_spec.lua6
-rw-r--r--test/functional/terminal/api_spec.lua2
-rw-r--r--test/functional/terminal/buffer_spec.lua6
-rw-r--r--test/functional/terminal/cursor_spec.lua661
-rw-r--r--test/functional/terminal/tui_spec.lua67
-rw-r--r--test/functional/treesitter/node_spec.lua14
-rw-r--r--test/functional/ui/cursor_spec.lua2
-rw-r--r--test/functional/ui/embed_spec.lua36
-rw-r--r--test/functional/ui/float_spec.lua10
-rw-r--r--test/functional/ui/hlstate_spec.lua2
-rw-r--r--test/functional/ui/output_spec.lua2
-rw-r--r--test/functional/ui/quickfix_spec.lua6
-rw-r--r--test/functional/ui/screen_basic_spec.lua26
-rw-r--r--test/helpers.lua228
-rw-r--r--test/lua_runner.lua28
-rw-r--r--test/old/testdir/runtest.vim2
-rw-r--r--test/old/testdir/setup.vim3
-rw-r--r--test/old/testdir/test_filetype.vim1
-rw-r--r--test/old/testdir/test_highlight.vim1
-rw-r--r--test/old/testdir/test_scroll_opt.vim19
-rw-r--r--test/old/testdir/test_syntax.vim2
-rw-r--r--test/unit/api/helpers.lua99
-rw-r--r--test/unit/api/private_helpers_spec.lua76
-rw-r--r--test/unit/buffer_spec.lua46
-rw-r--r--test/unit/charset/vim_str2nr_spec.lua584
-rw-r--r--test/unit/eval/decode_spec.lua41
-rw-r--r--test/unit/eval/encode_spec.lua39
-rw-r--r--test/unit/eval/helpers.lua285
-rw-r--r--test/unit/eval/tricks_spec.lua3
-rw-r--r--test/unit/eval/tv_clear_spec.lua14
-rw-r--r--test/unit/eval/typval_spec.lua1547
-rw-r--r--test/unit/fileio_spec.lua25
-rw-r--r--test/unit/formatc.lua199
-rw-r--r--test/unit/garray_spec.lua57
-rw-r--r--test/unit/helpers.lua155
-rw-r--r--test/unit/indent_spec.lua8
-rw-r--r--test/unit/keycodes_spec.lua28
-rw-r--r--test/unit/marktree_spec.lua279
-rw-r--r--test/unit/mbyte_spec.lua137
-rw-r--r--test/unit/memory_spec.lua30
-rw-r--r--test/unit/message_spec.lua9
-rw-r--r--test/unit/msgpack_spec.lua40
-rw-r--r--test/unit/multiqueue_spec.lua6
-rw-r--r--test/unit/optionstr_spec.lua17
-rw-r--r--test/unit/os/env_spec.lua19
-rw-r--r--test/unit/os/fileio_spec.lua36
-rw-r--r--test/unit/os/fs_spec.lua221
-rw-r--r--test/unit/os/shell_spec.lua50
-rw-r--r--test/unit/path_spec.lua67
-rw-r--r--test/unit/preprocess.lua101
-rw-r--r--test/unit/profile_spec.lua92
-rw-r--r--test/unit/rbuffer_spec.lua54
-rw-r--r--test/unit/search_spec.lua40
-rw-r--r--test/unit/set.lua6
-rw-r--r--test/unit/statusline_spec.lua542
-rw-r--r--test/unit/strings_spec.lua89
-rw-r--r--test/unit/undo_spec.lua57
-rw-r--r--test/unit/viml/expressions/lexer_spec.lua603
-rw-r--r--test/unit/viml/expressions/parser_spec.lua380
-rw-r--r--test/unit/viml/expressions/parser_tests.lua235
-rw-r--r--test/unit/viml/helpers.lua59
149 files changed, 9299 insertions, 7379 deletions
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 67d33fc1f6..82fc31e874 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -39,8 +39,7 @@ jobs:
- name: Install stylua
run: |
- URL=$(curl -L https://api.github.com/repos/JohnnyMorganz/StyLua/releases/latest | jq -r '.assets[] | select(.name == "stylua-linux-x86_64.zip") | .browser_download_url')
- wget --directory-prefix="$BIN_DIR" "$URL"
+ wget --directory-prefix="$BIN_DIR" https://github.com/JohnnyMorganz/StyLua/releases/latest/download/stylua-linux-x86_64.zip
(cd "$BIN_DIR"; unzip stylua*.zip)
- name: Build third-party deps
diff --git a/.luacheckrc b/.luacheckrc
index 701f461dc4..d54c61e9e7 100644
--- a/.luacheckrc
+++ b/.luacheckrc
@@ -47,5 +47,6 @@ exclude_files = {
'runtime/lua/vim/_meta/vimfn.lua',
'runtime/lua/vim/_meta/api.lua',
'runtime/lua/vim/re.lua',
+ 'runtime/lua/coxpcall.lua',
'src/nvim/eval.lua',
}
diff --git a/.stylua.toml b/.stylua.toml
index a2b3447506..22d6d3e6fc 100644
--- a/.stylua.toml
+++ b/.stylua.toml
@@ -3,4 +3,4 @@ line_endings = "Unix"
indent_type = "Spaces"
indent_width = 2
quote_style = "AutoPreferSingle"
-call_parentheses = "Always"
+call_parentheses = "Input"
diff --git a/.styluaignore b/.styluaignore
index c9303e07ce..53f7ea2812 100644
--- a/.styluaignore
+++ b/.styluaignore
@@ -2,6 +2,10 @@
/runtime/lua/coxpcall.lua
/runtime/lua/vim/_meta
/runtime/lua/vim/re.lua
-/scripts
-/src
-/test
+
+/test/functional
+/test/functional/fixtures/lua/syntax_error.lua
+/test/functional/legacy/030_fileformats_spec.lua
+/test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua
+/test/functional/legacy/093_mksession_cursor_cols_latin1_spec.lua
+/test/functional/lua/luaeval_spec.lua
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 475a1a2c3e..b5e4796a9d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -226,9 +226,6 @@ add_glob_target(
FLAGS -ll ${PROJECT_SOURCE_DIR}/test/lua_runner.lua ${CMAKE_BINARY_DIR}/usr luacheck -q
GLOB_DIRS runtime/ scripts/ src/ test/
GLOB_PAT *.lua
- EXCLUDE
- runtime/lua/vim/_meta/.*
- runtime/lua/coxpcall.lua
TOUCH_STRATEGY SINGLE)
add_dependencies(lintlua-luacheck lua-dev-deps)
@@ -236,10 +233,8 @@ add_glob_target(
TARGET lintlua-stylua
COMMAND ${STYLUA_PRG}
FLAGS --color=always --check --respect-ignores
- GLOB_DIRS runtime/
+ GLOB_DIRS runtime/ scripts/ src/ test/unit/
GLOB_PAT *.lua
- EXCLUDE
- /runtime/lua/vim/_meta
TOUCH_STRATEGY SINGLE)
add_custom_target(lintlua)
@@ -261,12 +256,12 @@ add_custom_target(lint)
add_dependencies(lint lintc lintlua lintsh lintcommit)
# Format
-add_custom_target(formatlua
- COMMAND ${CMAKE_COMMAND}
- -D FORMAT_PRG=${STYLUA_PRG}
- -D LANG=lua
- -P ${PROJECT_SOURCE_DIR}/cmake/Format.cmake
- WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
+add_glob_target(
+ TARGET formatlua
+ COMMAND ${STYLUA_PRG}
+ FLAGS --respect-ignores
+ GLOB_DIRS runtime/ scripts/ src/ test/unit/
+ GLOB_PAT *.lua)
add_custom_target(format)
add_dependencies(format formatc formatlua)
diff --git a/Makefile b/Makefile
index 9d9c0c7816..0a807e65da 100644
--- a/Makefile
+++ b/Makefile
@@ -142,16 +142,13 @@ iwyu: build/.ran-cmake
cmake --preset iwyu
cmake --build build > build/iwyu.log
iwyu-fix-includes --only_re="src/nvim" --ignore_re="(src/nvim/eval/encode.c|src/nvim/auto/|src/nvim/os/lang.c|src/nvim/map.c\
- |src/nvim/api/extmark.h\
|src/nvim/api/private/helpers.h\
|src/nvim/api/private/validate.h\
|src/nvim/assert_defs.h\
- |src/nvim/autocmd.h\
|src/nvim/buffer.h\
|src/nvim/buffer_defs.h\
|src/nvim/channel.h\
|src/nvim/charset.h\
- |src/nvim/decoration.h\
|src/nvim/drawline.h\
|src/nvim/eval.h\
|src/nvim/eval/encode.h\
@@ -169,7 +166,6 @@ iwyu: build/.ran-cmake
|src/nvim/event/stream.h\
|src/nvim/event/time.h\
|src/nvim/event/wstream.h\
- |src/nvim/extmark.h\
|src/nvim/garray.h\
|src/nvim/globals.h\
|src/nvim/grid.h\
@@ -188,7 +184,6 @@ iwyu: build/.ran-cmake
|src/nvim/os/pty_conpty_win.h\
|src/nvim/os/pty_process_unix.h\
|src/nvim/os/pty_process_win.h\
- |src/nvim/plines.h\
|src/nvim/tui/input.h\
|src/nvim/ui.h\
|src/nvim/viml/parser/expressions.h\
diff --git a/cmake/Format.cmake b/cmake/Format.cmake
deleted file mode 100644
index 7097e5766f..0000000000
--- a/cmake/Format.cmake
+++ /dev/null
@@ -1,65 +0,0 @@
-# Returns a list of all files that has been changed in current branch compared
-# to master branch. This includes unstaged, staged and committed files.
-function(get_changed_files outvar)
- execute_process(
- COMMAND git branch --show-current
- OUTPUT_VARIABLE current_branch
- OUTPUT_STRIP_TRAILING_WHITESPACE)
-
- execute_process(
- COMMAND git merge-base master HEAD
- OUTPUT_VARIABLE ancestor_commit
- OUTPUT_STRIP_TRAILING_WHITESPACE)
-
- # Changed files that have been committed
- execute_process(
- COMMAND git diff --diff-filter=d --name-only ${ancestor_commit}...${current_branch}
- OUTPUT_VARIABLE committed_files
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- separate_arguments(committed_files NATIVE_COMMAND ${committed_files})
-
- # Unstaged files
- execute_process(
- COMMAND git diff --diff-filter=d --name-only
- OUTPUT_VARIABLE unstaged_files
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- separate_arguments(unstaged_files NATIVE_COMMAND ${unstaged_files})
-
- # Staged files
- execute_process(
- COMMAND git diff --diff-filter=d --cached --name-only
- OUTPUT_VARIABLE staged_files
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- separate_arguments(staged_files NATIVE_COMMAND ${staged_files})
-
- set(files ${committed_files} ${unstaged_files} ${staged_files})
- list(REMOVE_DUPLICATES files)
-
- set(${outvar} "${files}" PARENT_SCOPE)
-endfunction()
-
-get_changed_files(changed_files)
-
-if(LANG STREQUAL c)
- list(FILTER changed_files INCLUDE REGEX "\\.[ch]$")
- list(FILTER changed_files INCLUDE REGEX "^src/nvim/")
-
- if(changed_files)
- if(FORMAT_PRG)
- execute_process(COMMAND ${FORMAT_PRG} -c "src/uncrustify.cfg" --replace --no-backup ${changed_files})
- else()
- message(STATUS "Uncrustify not found. Skip formatting C files.")
- endif()
- endif()
-elseif(LANG STREQUAL lua)
- list(FILTER changed_files INCLUDE REGEX "\\.lua$")
- list(FILTER changed_files INCLUDE REGEX "^runtime/")
-
- if(changed_files)
- if(FORMAT_PRG)
- execute_process(COMMAND ${FORMAT_PRG} ${changed_files})
- else()
- message(STATUS "Stylua not found. Skip formatting lua files.")
- endif()
- endif()
-endif()
diff --git a/cmake/Util.cmake b/cmake/Util.cmake
index 01d34d6752..4723ad7e08 100644
--- a/cmake/Util.cmake
+++ b/cmake/Util.cmake
@@ -75,6 +75,7 @@ function(add_glob_target)
list(APPEND ARG_FILES ${globfiles})
endforeach()
+ list(APPEND ARG_EXCLUDE runtime/lua/vim/_meta) # only generated files, always ignore
foreach(exclude_pattern ${ARG_EXCLUDE})
list(FILTER ARG_FILES EXCLUDE REGEX ${exclude_pattern})
endforeach()
diff --git a/contrib/flake.lock b/contrib/flake.lock
index 554dc22bdb..893f1d5b05 100644
--- a/contrib/flake.lock
+++ b/contrib/flake.lock
@@ -5,11 +5,11 @@
"systems": "systems"
},
"locked": {
- "lastModified": 1685518550,
- "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=",
+ "lastModified": 1694529238,
+ "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
"owner": "numtide",
"repo": "flake-utils",
- "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef",
+ "rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
"type": "github"
},
"original": {
@@ -20,11 +20,11 @@
},
"nixpkgs": {
"locked": {
- "lastModified": 1686226982,
- "narHash": "sha256-nLuiPoeiVfqqzeq9rmXxpybh77VS37dsY/k8N2LoxVg=",
+ "lastModified": 1701253981,
+ "narHash": "sha256-ztaDIyZ7HrTAfEEUt9AtTDNoCYxUdSd6NrRHaYOIxtk=",
"owner": "nixos",
"repo": "nixpkgs",
- "rev": "a64b73e07d4aa65cfcbda29ecf78eaf9e72e44bd",
+ "rev": "e92039b55bcd58469325ded85d4f58dd5a4eaf58",
"type": "github"
},
"original": {
diff --git a/runtime/colors/default.vim b/runtime/colors/default.vim
index d2960fa78b..fac120ccf5 100644
--- a/runtime/colors/default.vim
+++ b/runtime/colors/default.vim
@@ -1,12 +1,10 @@
-" Vim color file
-" Maintainer: The Vim Project <https://github.com/vim/vim>
-" Last Change: 2023 Aug 10
-" Former Maintainer: Bram Moolenaar <Bram@vim.org>
+" Neovim color file
+" Maintainer: The Neovim Project <https://github.com/neovim/neovim>
+" Last Change: 2023 Dec 01
-" This is the default color scheme. It doesn't define the Normal
-" highlighting, it uses whatever the colors used to be.
+" This is the default color scheme.
-" Set 'background' back to the default. The value can't always be estimated
+" Set 'background' back to the default. The value can't always be estimated
" and is then guessed.
hi clear Normal
set bg&
diff --git a/runtime/colors/vim.vim b/runtime/colors/vim.vim
new file mode 100644
index 0000000000..3418abe424
--- /dev/null
+++ b/runtime/colors/vim.vim
@@ -0,0 +1,269 @@
+" Name: vim
+" Description: Vim's default color scheme
+" Author: Bram Moolenaar <Bram@vim.org>
+" Maintainer: The Vim Project <https://github.com/vim/vim>
+" Website: https://github.com/vim/vim
+" License: Same as Vim
+" Last Updated: 2023 Aug 10
+
+" This is Vim's default color scheme. It doesn't define the Normal
+" highlighting, it uses whatever the colors used to be.
+
+hi clear
+let g:colors_name = 'vim'
+
+" General
+hi Conceal guifg=LightGrey guibg=DarkGrey guisp=NONE gui=NONE ctermfg=LightGrey ctermbg=DarkGrey cterm=NONE
+hi Cursor guifg=bg guibg=fg guisp=NONE gui=NONE ctermfg=bg ctermbg=fg cterm=NONE
+hi lCursor guifg=bg guibg=fg guisp=NONE gui=NONE ctermfg=bg ctermbg=fg cterm=NONE
+hi DiffText guifg=NONE guibg=Red guisp=NONE gui=bold ctermfg=NONE ctermbg=Red cterm=bold
+hi ErrorMsg guifg=White guibg=Red guisp=NONE gui=NONE ctermfg=White ctermbg=DarkRed cterm=NONE
+hi IncSearch guifg=NONE guibg=NONE guisp=NONE gui=reverse ctermfg=NONE ctermbg=NONE cterm=reverse
+hi ModeMsg guifg=NONE guibg=NONE guisp=NONE gui=bold ctermfg=NONE ctermbg=NONE cterm=bold
+hi NonText guifg=Blue guibg=NONE guisp=NONE gui=bold ctermfg=Blue ctermbg=NONE cterm=NONE
+hi Normal guifg=NONE guibg=NONE guisp=NONE gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE
+hi PmenuSbar guifg=NONE guibg=Grey guisp=NONE gui=NONE ctermfg=NONE ctermbg=Grey cterm=NONE
+hi StatusLine guifg=NONE guibg=NONE guisp=NONE gui=reverse,bold ctermfg=NONE ctermbg=NONE cterm=reverse,bold
+hi StatusLineNC guifg=NONE guibg=NONE guisp=NONE gui=reverse ctermfg=NONE ctermbg=NONE cterm=reverse
+hi TabLineFill guifg=NONE guibg=NONE guisp=NONE gui=reverse ctermfg=NONE ctermbg=NONE cterm=reverse
+hi TabLineSel guifg=NONE guibg=NONE guisp=NONE gui=bold ctermfg=NONE ctermbg=NONE cterm=bold
+hi TermCursor guifg=NONE guibg=NONE guisp=NONE gui=reverse ctermfg=NONE ctermbg=NONE cterm=reverse
+hi WinBar guifg=NONE guibg=NONE guisp=NONE gui=bold ctermfg=NONE ctermbg=NONE cterm=bold
+hi WildMenu guifg=Black guibg=Yellow guisp=NONE gui=NONE ctermfg=Black ctermbg=Yellow cterm=NONE
+hi! link VertSplit Normal
+hi! link WinSeparator VertSplit
+hi! link WinBarNC WinBar
+hi! link EndOfBuffer NonText
+hi! link LineNrAbove LineNr
+hi! link LineNrBelow LineNr
+hi! link QuickFixLine Search
+hi! link CursorLineSign SignColumn
+hi! link CursorLineFold FoldColumn
+hi! link CurSearch Search
+hi! link PmenuKind Pmenu
+hi! link PmenuKindSel PmenuSel
+hi! link PmenuExtra Pmenu
+hi! link PmenuExtraSel PmenuSel
+hi! link Substitute Search
+hi! link Whitespace NonText
+hi! link MsgSeparator StatusLine
+hi! link NormalFloat Pmenu
+hi! link FloatBorder WinSeparator
+hi! link FloatTitle Title
+hi! link FloatFooter Title
+hi FloatShadow guifg=NONE guibg=Black guisp=NONE gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE blend=80
+hi FloatShadowThrough guifg=NONE guibg=Black guisp=NONE gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE blend=100
+hi RedrawDebugNormal guifg=NONE guibg=NONE guisp=NONE gui=reverse ctermfg=NONE ctermbg=NONE cterm=reverse
+hi RedrawDebugClear guifg=NONE guibg=Yellow guisp=NONE gui=NONE ctermfg=NONE ctermbg=Yellow cterm=NONE
+hi RedrawDebugComposed guifg=NONE guibg=Green guisp=NONE gui=NONE ctermfg=NONE ctermbg=Green cterm=NONE
+hi RedrawDebugRecompose guifg=NONE guibg=Red guisp=NONE gui=NONE ctermfg=NONE ctermbg=Red cterm=NONE
+hi Error guifg=White guibg=Red guisp=NONE gui=NONE ctermfg=White ctermbg=Red cterm=NONE term=reverse
+hi Todo guifg=Blue guibg=Yellow guisp=NONE gui=NONE ctermfg=Black ctermbg=Yellow cterm=NONE term=standout
+hi! link String Constant
+hi! link Character Constant
+hi! link Number Constant
+hi! link Boolean Constant
+hi! link Float Number
+hi! link Function Identifier
+hi! link Conditional Statement
+hi! link Repeat Statement
+hi! link Label Statement
+hi! link Operator Statement
+hi! link Keyword Statement
+hi! link Exception Statement
+hi! link Include PreProc
+hi! link Define PreProc
+hi! link Macro PreProc
+hi! link PreCondit PreProc
+hi! link StorageClass Type
+hi! link Structure Type
+hi! link Typedef Type
+hi! link Tag Special
+hi! link SpecialChar Special
+hi! link Delimiter Special
+hi! link SpecialComment Special
+hi! link Debug Special
+hi DiagnosticError guifg=Red guibg=NONE guisp=NONE gui=NONE ctermfg=1 ctermbg=NONE cterm=NONE
+hi DiagnosticWarn guifg=Orange guibg=NONE guisp=NONE gui=NONE ctermfg=3 ctermbg=NONE cterm=NONE
+hi DiagnosticInfo guifg=LightBlue guibg=NONE guisp=NONE gui=NONE ctermfg=4 ctermbg=NONE cterm=NONE
+hi DiagnosticHint guifg=LightGrey guibg=NONE guisp=NONE gui=NONE ctermfg=7 ctermbg=NONE cterm=NONE
+hi DiagnosticOk guifg=LightGreen guibg=NONE guisp=NONE gui=NONE ctermfg=10 ctermbg=NONE cterm=NONE
+hi DiagnosticUnderlineError guifg=NONE guibg=NONE guisp=Red gui=underline ctermfg=NONE ctermbg=NONE cterm=underline
+hi DiagnosticUnderlineWarn guifg=NONE guibg=NONE guisp=Orange gui=underline ctermfg=NONE ctermbg=NONE cterm=underline
+hi DiagnosticUnderlineInfo guifg=NONE guibg=NONE guisp=LightBlue gui=underline ctermfg=NONE ctermbg=NONE cterm=underline
+hi DiagnosticUnderlineHint guifg=NONE guibg=NONE guisp=LightGrey gui=underline ctermfg=NONE ctermbg=NONE cterm=underline
+hi DiagnosticUnderlineOk guifg=NONE guibg=NONE guisp=LightGreen gui=underline ctermfg=NONE ctermbg=NONE cterm=underline
+hi! link DiagnosticVirtualTextError DiagnosticError
+hi! link DiagnosticVirtualTextWarn DiagnosticWarn
+hi! link DiagnosticVirtualTextInfo DiagnosticInfo
+hi! link DiagnosticVirtualTextHint DiagnosticHint
+hi! link DiagnosticVirtualTextOk DiagnosticOk
+hi! link DiagnosticFloatingError DiagnosticError
+hi! link DiagnosticFloatingWarn DiagnosticWarn
+hi! link DiagnosticFloatingInfo DiagnosticInfo
+hi! link DiagnosticFloatingHint DiagnosticHint
+hi! link DiagnosticFloatingOk DiagnosticOk
+hi! link DiagnosticSignError DiagnosticError
+hi! link DiagnosticSignWarn DiagnosticWarn
+hi! link DiagnosticSignInfo DiagnosticInfo
+hi! link DiagnosticSignHint DiagnosticHint
+hi! link DiagnosticSignOk DiagnosticOk
+hi DiagnosticDeprecated guifg=NONE guibg=NONE guisp=Red gui=strikethrough ctermfg=NONE ctermbg=NONE cterm=strikethrough
+hi! link DiagnosticUnnecessary Comment
+hi! link LspInlayHint NonText
+hi! link SnippetTabstop Visual
+
+" Text
+hi! link @text.literal Comment
+hi! link @text.reference Identifier
+hi! link @text.title Title
+hi! link @text.uri Underlined
+hi! link @text.underline Underlined
+hi! link @text.todo Todo
+
+" Miscs
+hi! link @comment Comment
+hi! link @punctuation Delimiter
+
+" Constants
+hi! link @constant Constant
+hi! link @constant.builtin Special
+hi! link @constant.macro Define
+hi! link @define Define
+hi! link @macro Macro
+hi! link @string String
+hi! link @string.escape SpecialChar
+hi! link @string.special SpecialChar
+hi! link @character Character
+hi! link @character.special SpecialChar
+hi! link @number Number
+hi! link @boolean Boolean
+hi! link @float Float
+
+" Functions
+hi! link @function Function
+hi! link @function.builtin Special
+hi! link @function.macro Macro
+hi! link @parameter Identifier
+hi! link @method Function
+hi! link @field Identifier
+hi! link @property Identifier
+hi! link @constructor Special
+
+" Keywords
+hi! link @conditional Conditional
+hi! link @repeat Repeat
+hi! link @label Label
+hi! link @operator Operator
+hi! link @keyword Keyword
+hi! link @exception Exception
+
+hi! link @variable Identifier
+hi! link @type Type
+hi! link @type.definition Typedef
+hi! link @storageclass StorageClass
+hi! link @namespace Identifier
+hi! link @include Include
+hi! link @preproc PreProc
+hi! link @debug Debug
+hi! link @tag Tag
+
+" LSP semantic tokens
+hi! link @lsp.type.class Structure
+hi! link @lsp.type.comment Comment
+hi! link @lsp.type.decorator Function
+hi! link @lsp.type.enum Structure
+hi! link @lsp.type.enumMember Constant
+hi! link @lsp.type.function Function
+hi! link @lsp.type.interface Structure
+hi! link @lsp.type.macro Macro
+hi! link @lsp.type.method Function
+hi! link @lsp.type.namespace Structure
+hi! link @lsp.type.parameter Identifier
+hi! link @lsp.type.property Identifier
+hi! link @lsp.type.struct Structure
+hi! link @lsp.type.type Type
+hi! link @lsp.type.typeParameter TypeDef
+hi! link @lsp.type.variable Identifier
+
+if &background ==# 'light'
+ " Default colors only used with a light background.
+ hi ColorColumn guifg=NONE guibg=LightRed guisp=NONE gui=NONE ctermfg=NONE ctermbg=LightRed cterm=NONE
+ hi CursorColumn guifg=NONE guibg=Grey90 guisp=NONE gui=NONE ctermfg=NONE ctermbg=LightGrey cterm=NONE
+ hi CursorLine guifg=NONE guibg=Grey90 guisp=NONE gui=NONE ctermfg=NONE ctermbg=NONE cterm=underline
+ hi CursorLineNr guifg=Brown guibg=NONE guisp=NONE gui=bold ctermfg=Brown ctermbg=NONE cterm=underline
+ hi DiffAdd guifg=NONE guibg=LightBlue guisp=NONE gui=NONE ctermfg=NONE ctermbg=LightBlue cterm=NONE
+ hi DiffChange guifg=NONE guibg=LightMagenta guisp=NONE gui=NONE ctermfg=NONE ctermbg=LightMagenta cterm=NONE
+ hi DiffDelete guifg=Blue guibg=LightCyan guisp=NONE gui=bold ctermfg=Blue ctermbg=LightCyan cterm=NONE
+ hi Directory guifg=Blue guibg=NONE guisp=NONE gui=NONE ctermfg=DarkBlue ctermbg=NONE cterm=NONE
+ hi FoldColumn guifg=DarkBlue guibg=Grey guisp=NONE gui=NONE ctermfg=DarkBlue ctermbg=Grey cterm=NONE
+ hi Folded guifg=DarkBlue guibg=LightGrey guisp=NONE gui=NONE ctermfg=DarkBlue ctermbg=Grey cterm=NONE
+ hi LineNr guifg=Brown guibg=NONE guisp=NONE gui=NONE ctermfg=Brown ctermbg=NONE cterm=NONE
+ hi MatchParen guifg=NONE guibg=Cyan guisp=NONE gui=NONE ctermfg=NONE ctermbg=Cyan cterm=NONE
+ hi MoreMsg guifg=SeaGreen guibg=NONE guisp=NONE gui=bold ctermfg=DarkGreen ctermbg=NONE cterm=NONE
+ hi Pmenu guifg=NONE guibg=LightMagenta guisp=NONE gui=NONE ctermfg=Black ctermbg=LightMagenta cterm=NONE
+ hi PmenuSel guifg=NONE guibg=Grey guisp=NONE gui=NONE ctermfg=Black ctermbg=LightGrey cterm=NONE blend=NONE
+ hi PmenuThumb guifg=NONE guibg=Black guisp=NONE gui=NONE ctermfg=NONE ctermbg=Black cterm=NONE
+ hi Question guifg=SeaGreen guibg=NONE guisp=NONE gui=bold ctermfg=DarkGreen ctermbg=NONE cterm=NONE
+ hi Search guifg=NONE guibg=Yellow guisp=NONE gui=NONE ctermfg=NONE ctermbg=Yellow cterm=NONE
+ hi SignColumn guifg=DarkBlue guibg=Grey guisp=NONE gui=NONE ctermfg=DarkBlue ctermbg=Grey cterm=NONE
+ hi SpecialKey guifg=Blue guibg=NONE guisp=NONE gui=NONE ctermfg=DarkBlue ctermbg=NONE cterm=NONE
+ hi SpellBad guifg=NONE guibg=NONE guisp=Red gui=undercurl ctermfg=NONE ctermbg=LightRed cterm=NONE
+ hi SpellCap guifg=NONE guibg=NONE guisp=Blue gui=undercurl ctermfg=NONE ctermbg=LightBlue cterm=NONE
+ hi SpellLocal guifg=NONE guibg=NONE guisp=DarkCyan gui=undercurl ctermfg=NONE ctermbg=Cyan cterm=NONE
+ hi SpellRare guifg=NONE guibg=NONE guisp=Magenta gui=undercurl ctermfg=NONE ctermbg=LightMagenta cterm=NONE
+ hi TabLine guifg=NONE guibg=LightGrey guisp=NONE gui=underline ctermfg=black ctermbg=LightGrey cterm=underline
+ hi Title guifg=Magenta guibg=NONE guisp=NONE gui=bold ctermfg=DarkMagenta ctermbg=NONE cterm=NONE
+ hi Visual guifg=NONE guibg=LightGrey guisp=NONE gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE
+ hi WarningMsg guifg=Red guibg=NONE guisp=NONE gui=NONE ctermfg=DarkRed ctermbg=NONE cterm=NONE
+ hi Comment guifg=Blue guibg=NONE guisp=NONE gui=NONE ctermfg=DarkBlue ctermbg=NONE cterm=NONE term=bold
+ hi Constant guifg=Magenta guibg=NONE guisp=NONE gui=NONE ctermfg=DarkRed ctermbg=NONE cterm=NONE term=underline
+ hi Special guifg=#6a5acd guibg=NONE guisp=NONE gui=NONE ctermfg=DarkMagenta ctermbg=NONE cterm=NONE term=bold
+ hi Identifier guifg=DarkCyan guibg=NONE guisp=NONE gui=NONE ctermfg=DarkCyan ctermbg=NONE cterm=NONE term=underline
+ hi Statement guifg=Brown guibg=NONE guisp=NONE gui=bold ctermfg=Brown ctermbg=NONE cterm=NONE term=bold
+ hi PreProc guifg=#6a0dad guibg=NONE guisp=NONE gui=NONE ctermfg=DarkMagenta ctermbg=NONE cterm=NONE term=underline
+ hi Type guifg=SeaGreen guibg=NONE guisp=NONE gui=bold ctermfg=DarkGreen ctermbg=NONE cterm=NONE term=underline
+ hi Underlined guifg=SlateBlue guibg=NONE guisp=NONE gui=underline ctermfg=DarkMagenta ctermbg=NONE cterm=underline term=underline
+ hi Ignore guifg=bg guibg=NONE guisp=NONE gui=NONE ctermfg=white ctermbg=NONE cterm=NONE term=NONE
+else
+ " Default colors only used with a dark background.
+ hi ColorColumn guifg=NONE guibg=DarkRed guisp=NONE gui=NONE ctermfg=NONE ctermbg=DarkRed cterm=NONE
+ hi CursorColumn guifg=NONE guibg=Grey40 guisp=NONE gui=NONE ctermfg=NONE ctermbg=DarkGrey cterm=NONE
+ hi CursorLine guifg=NONE guibg=Grey40 guisp=NONE gui=NONE ctermfg=NONE ctermbg=NONE cterm=underline
+ hi CursorLineNr guifg=Yellow guibg=NONE guisp=NONE gui=bold ctermfg=Yellow ctermbg=NONE cterm=underline
+ hi DiffAdd guifg=NONE guibg=DarkBlue guisp=NONE gui=NONE ctermfg=NONE ctermbg=DarkBlue cterm=NONE
+ hi DiffChange guifg=NONE guibg=DarkMagenta guisp=NONE gui=NONE ctermfg=NONE ctermbg=DarkMagenta cterm=NONE
+ hi DiffDelete guifg=Blue guibg=DarkCyan guisp=NONE gui=bold ctermfg=Blue ctermbg=DarkCyan cterm=NONE
+ hi Directory guifg=Cyan guibg=NONE guisp=NONE gui=NONE ctermfg=LightCyan ctermbg=NONE cterm=NONE
+ hi FoldColumn guifg=Cyan guibg=Grey guisp=NONE gui=NONE ctermfg=Cyan ctermbg=DarkGrey cterm=NONE
+ hi Folded guifg=Cyan guibg=DarkGrey guisp=NONE gui=NONE ctermfg=Cyan ctermbg=DarkGrey cterm=NONE
+ hi LineNr guifg=Yellow guibg=NONE guisp=NONE gui=NONE ctermfg=Yellow ctermbg=NONE cterm=NONE
+ hi MatchParen guifg=NONE guibg=DarkCyan guisp=NONE gui=NONE ctermfg=NONE ctermbg=DarkCyan cterm=NONE
+ hi MoreMsg guifg=SeaGreen guibg=NONE guisp=NONE gui=bold ctermfg=LightGreen ctermbg=NONE cterm=NONE
+ hi Pmenu guifg=NONE guibg=Magenta guisp=NONE gui=NONE ctermfg=Black ctermbg=Magenta cterm=NONE
+ hi PmenuSel guifg=NONE guibg=DarkGrey guisp=NONE gui=NONE ctermfg=DarkGrey ctermbg=Black cterm=NONE blend=NONE
+ hi PmenuThumb guifg=NONE guibg=White guisp=NONE gui=NONE ctermfg=NONE ctermbg=White cterm=NONE
+ hi Question guifg=Green guibg=NONE guisp=NONE gui=bold ctermfg=LightGreen ctermbg=NONE cterm=NONE
+ hi Search guifg=Black guibg=Yellow guisp=NONE gui=NONE ctermfg=Black ctermbg=Yellow cterm=NONE
+ hi SignColumn guifg=Cyan guibg=Grey guisp=NONE gui=NONE ctermfg=Cyan ctermbg=DarkGrey cterm=NONE
+ hi SpecialKey guifg=Cyan guibg=NONE guisp=NONE gui=NONE ctermfg=LightBlue ctermbg=NONE cterm=NONE
+ hi SpellBad guifg=NONE guibg=NONE guisp=Red gui=undercurl ctermfg=NONE ctermbg=Red cterm=NONE
+ hi SpellCap guifg=NONE guibg=NONE guisp=Blue gui=undercurl ctermfg=NONE ctermbg=Blue cterm=NONE
+ hi SpellLocal guifg=NONE guibg=NONE guisp=Cyan gui=undercurl ctermfg=NONE ctermbg=Cyan cterm=NONE
+ hi SpellRare guifg=NONE guibg=NONE guisp=Magenta gui=undercurl ctermfg=NONE ctermbg=Magenta cterm=NONE
+ hi TabLine guifg=NONE guibg=DarkGrey guisp=NONE gui=underline ctermfg=white ctermbg=DarkGrey cterm=underline
+ hi Title guifg=Magenta guibg=NONE guisp=NONE gui=bold ctermfg=LightMagenta ctermbg=NONE cterm=NONE
+ hi Visual guifg=NONE guibg=DarkGrey guisp=NONE gui=NONE ctermfg=NONE ctermbg=NONE cterm=NONE
+ hi WarningMsg guifg=Red guibg=NONE guisp=NONE gui=NONE ctermfg=LightRed ctermbg=NONE cterm=NONE
+ hi Comment guifg=#80a0ff guibg=NONE guisp=NONE gui=NONE ctermfg=Cyan ctermbg=NONE cterm=NONE term=bold
+ hi Constant guifg=#ffa0a0 guibg=NONE guisp=NONE gui=NONE ctermfg=Magenta ctermbg=NONE cterm=NONE term=underline
+ hi Special guifg=Orange guibg=NONE guisp=NONE gui=NONE ctermfg=LightRed ctermbg=NONE cterm=NONE term=bold
+ hi Identifier guifg=#40ffff guibg=NONE guisp=NONE gui=NONE ctermfg=Cyan ctermbg=NONE cterm=bold term=underline
+ hi Statement guifg=#ffff60 guibg=NONE guisp=NONE gui=bold ctermfg=Yellow ctermbg=NONE cterm=NONE term=bold
+ hi PreProc guifg=#ff80ff guibg=NONE guisp=NONE gui=NONE ctermfg=LightBlue ctermbg=NONE cterm=NONE term=underline
+ hi Type guifg=#60ff60 guibg=NONE guisp=NONE gui=bold ctermfg=LightGreen ctermbg=NONE cterm=NONE term=underline
+ hi Underlined guifg=#80a0ff guibg=NONE guisp=NONE gui=underline ctermfg=LightBlue ctermbg=NONE cterm=underline term=underline
+ hi Ignore guifg=bg guibg=NONE guisp=NONE gui=NONE ctermfg=black ctermbg=NONE cterm=NONE term=NONE
+endif
+
+" vim: sw=2
diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt
index ba3b7c0915..4aba1f8141 100644
--- a/runtime/doc/api.txt
+++ b/runtime/doc/api.txt
@@ -1006,7 +1006,7 @@ nvim_get_keymap({mode}) *nvim_get_keymap()*
Array of |maparg()|-like dictionaries describing mappings. The
"buffer" key is always zero.
-nvim_get_mark({name}, {opts}) *nvim_get_mark()*
+nvim_get_mark({name}, {*opts}) *nvim_get_mark()*
Returns a `(row, col, buffer, buffername)` tuple representing the position
of the uppercase/file named mark. "End of line" column position is
returned as |v:maxcol| (big number). See |mark-motions|.
@@ -1204,7 +1204,7 @@ nvim_notify({msg}, {log_level}, {opts}) *nvim_notify()*
• {log_level} The log level
• {opts} Reserved for future use.
-nvim_open_term({buffer}, {opts}) *nvim_open_term()*
+nvim_open_term({buffer}, {*opts}) *nvim_open_term()*
Open a terminal instance in a buffer
By default (and currently the only option) the terminal will not be
@@ -1305,7 +1305,7 @@ nvim_replace_termcodes({str}, {from_part}, {do_lt}, {special})
• cpoptions
*nvim_select_popupmenu_item()*
-nvim_select_popupmenu_item({item}, {insert}, {finish}, {opts})
+nvim_select_popupmenu_item({item}, {insert}, {finish}, {*opts})
Selects an item in the completion popup menu.
If neither |ins-completion| nor |cmdline-completion| popup menu is active
@@ -1878,7 +1878,7 @@ nvim_get_commands({*opts}) *nvim_get_commands()*
See also: ~
• |nvim_get_all_options_info()|
-nvim_parse_cmd({str}, {opts}) *nvim_parse_cmd()*
+nvim_parse_cmd({str}, {*opts}) *nvim_parse_cmd()*
Parse command line.
Doesn't check the validity of command arguments.
@@ -2057,7 +2057,7 @@ affected.
You can use |nvim_buf_is_loaded()| or |nvim_buf_line_count()| to check
whether a buffer is loaded.
-nvim_buf_attach({buffer}, {send_buffer}, {opts}) *nvim_buf_attach()*
+nvim_buf_attach({buffer}, {send_buffer}, {*opts}) *nvim_buf_attach()*
Activates buffer-update events on a channel, or as Lua callbacks.
Example (Lua): capture buffer updates in a global `events` variable (use
@@ -2193,7 +2193,7 @@ nvim_buf_del_var({buffer}, {name}) *nvim_buf_del_var()*
• {buffer} Buffer handle, or 0 for current buffer
• {name} Variable name
-nvim_buf_delete({buffer}, {opts}) *nvim_buf_delete()*
+nvim_buf_delete({buffer}, {*opts}) *nvim_buf_delete()*
Deletes the buffer. See |:bwipeout|
Attributes: ~
@@ -2310,7 +2310,7 @@ nvim_buf_get_offset({buffer}, {index}) *nvim_buf_get_offset()*
*nvim_buf_get_text()*
nvim_buf_get_text({buffer}, {start_row}, {start_col}, {end_row}, {end_col},
- {opts})
+ {*opts})
Gets a range from the buffer.
This differs from |nvim_buf_get_lines()| in that it allows retrieving only
@@ -2412,7 +2412,7 @@ nvim_buf_set_lines({buffer}, {start}, {end}, {strict_indexing}, {replacement})
• |nvim_buf_set_text()|
*nvim_buf_set_mark()*
-nvim_buf_set_mark({buffer}, {name}, {line}, {col}, {opts})
+nvim_buf_set_mark({buffer}, {name}, {line}, {col}, {*opts})
Sets a named mark in the given buffer, all marks are allowed
file/uppercase, visual, last change, etc. See |mark-motions|.
@@ -2553,7 +2553,7 @@ nvim_buf_del_extmark({buffer}, {ns_id}, {id}) *nvim_buf_del_extmark()*
true if the extmark was found, else false
*nvim_buf_get_extmark_by_id()*
-nvim_buf_get_extmark_by_id({buffer}, {ns_id}, {id}, {opts})
+nvim_buf_get_extmark_by_id({buffer}, {ns_id}, {id}, {*opts})
Gets the position (0-indexed) of an |extmark|.
Parameters: ~
diff --git a/runtime/doc/dev_theme.txt b/runtime/doc/dev_theme.txt
new file mode 100644
index 0000000000..04ec3f293c
--- /dev/null
+++ b/runtime/doc/dev_theme.txt
@@ -0,0 +1,103 @@
+*dev_theme.txt* Nvim
+
+
+ NVIM REFERENCE MANUAL
+
+
+Nvim theme style guide *dev-theme*
+
+This is style guide for developers working on Nvim's default color scheme.
+
+License: CC-By 3.0 https://creativecommons.org/licenses/by/3.0/
+
+ Type |gO| to see the table of contents.
+
+==============================================================================
+Design
+
+- Be "Neovim branded", i.e. have mostly "green-blue" feel plus one or two
+ colors reserved for very occasional user attention.
+
+- Be extra minimal for 'notermguicolors' (256 colors) while allowing a bit
+ more shades when 'termguicolors' is set (true colors).
+
+- Be accessible, i.e. have high enough contrast ratio (as defined in
+ https://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef).
+ This means to have value at least 7 for |hl-Normal| and 4.5 for some common
+ cases (|hl-Visual|, `Comment` with set 'cursorline', colored syntax, `Diff*`,
+ |hl-Search|).
+
+- Be suitable for dark and light backgrounds via exchange of dark and light
+ palettes.
+
+- Be usable, i.e. provide enough visual feedback for common objects.
+
+
+==============================================================================
+Palettes
+
+- There are two separate palettes: dark and light. They all contain the same
+ set of colors exported as `NvimDark*` and `NvimLight*` colors respectively.
+
+- The dark palette is used for background in the dark color scheme and for
+ foreground in the light color scheme; and vice versa. This introduces
+ recognizable visual system without too standing out.
+
+- Actual computation of palettes should be done in a perceptually uniform
+ color space. Oklch is a good choice.
+
+- Each palette has the following colors (descriptions are for dark background;
+ reverse for light one):
+
+ - Four shades of "colored" greys for general UI. In 256 colors they are
+ exact greys; in true colors they are shades of "cold" grey.
+
+ - Dark ones (from darkest to lightest) are reserved as background for
+ |hl-NormalFloat| (considered as "black"), |hl-Normal| (background),
+ |hl-CursorLine|, |hl-Visual|.
+
+ - Light ones (also from darkest to lightest) are reserved for
+ `Comment`, |hl-StatusLine|/|hl-TabLine|, |hl-Normal| (foreground),
+ and color considered as "white".
+
+- Six colors to provide enough terminal colors: red, yellow, green, cyan,
+ blue, magenta.
+ They should have (reasonably) similar lightness and chroma to make them
+ visually coherent. Lightness should be as equal to the palette's basic grey
+ (which is used for |hl-Normal|) as possible. They should have (reasonably)
+ different hues to make them visually separable.
+
+- Each palette color should have a 256 colors variant with closest color
+ computed based on the perceptually uniform distance measure.
+
+
+==============================================================================
+Highlight groups
+
+Use:
+
+- Grey shades for general UI according to their design.
+
+- Bold text for keywords (`Statement` highlight group). This is an important
+ choice to increase accessibility for people with color deficiencies, as it
+ doesn't rely on actual color.
+
+- Green for strings, |hl-DiffAdd| (as background), |hl-DiagnosticOk|, and some
+ minor text UI elements.
+
+- Cyan as main syntax color, i.e. for function usage (`Function` highlight
+ group), |hl-DiffText|, |hl-DiagnosticInfo|, and some minor text UI elements.
+
+- Red to generally mean high user attention, i.e. errors; in particular for
+ |hl-ErrorMsg|, |hl-DiffDelete|, |hl-DiagnosticError|.
+
+- Yellow very sparingly only with true colors to mean mild user attention,
+ i.e. warnings. That is, |hl-DiagnosticWarn| and |hl-WarningMsg|.
+
+- Blue very sparingly only with true colors as |hl-DiagnosticHint| and some
+ additional important syntax group (like `Identifier`).
+
+- Magenta very carefully (if at all).
+
+
+ vim:tw=78:ts=8:et:ft=help:norl:
diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt
index 825e5ba41f..e38707fa76 100644
--- a/runtime/doc/news.txt
+++ b/runtime/doc/news.txt
@@ -95,6 +95,9 @@ The following changes may require adaptations in user config or plugins.
• Legacy and extmark signs are displayed and listed with the same priority:
line number -> priority -> sign id -> recently placed
+• Default color scheme has been updated to be "Neovim branded" and accessible.
+ Use `:colorscheme vim` to revert to the old legacy color scheme.
+
==============================================================================
BREAKING CHANGES IN HEAD *news-breaking-dev*
@@ -266,6 +269,7 @@ The following changes to existing APIs or features add new behavior.
vim.g.query_lint_on = {}
<
• Enabled treesitter highlighting for treesitter query files.
+ • Enabled treesitter highlighting for help files.
• The `workspace/didChangeWatchedFiles` LSP client capability is now enabled
by default.
diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt
index 9bdc6b8d24..e3836a357b 100644
--- a/runtime/doc/treesitter.txt
+++ b/runtime/doc/treesitter.txt
@@ -616,6 +616,8 @@ get_node({opts}) *vim.treesitter.get_node()*
• pos table|nil 0-indexed (row, col) tuple. Defaults to cursor
position in the current window. Required if {bufnr} is not
the current buffer
+ • lang string|nil Parser language. (default: from buffer
+ filetype)
• ignore_injections boolean Ignore injected languages (default
true)
diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt
index cf9b3cf0e5..f6dfe3b14a 100644
--- a/runtime/doc/vim_diff.txt
+++ b/runtime/doc/vim_diff.txt
@@ -30,6 +30,8 @@ Defaults *nvim-defaults*
":filetype off" to |init.vim|.
- Syntax highlighting is enabled by default. This can be disabled by adding
":syntax off" to |init.vim|.
+- Default color scheme has been updated. This can be reversed by adding
+ ":colorscheme vim" to |init.vim|.
- 'autoindent' is enabled
- 'autoread' is enabled (works in all UIs, including terminal)
diff --git a/runtime/ftplugin/help.lua b/runtime/ftplugin/help.lua
index 4cc3386167..bf3408c2d9 100644
--- a/runtime/ftplugin/help.lua
+++ b/runtime/ftplugin/help.lua
@@ -1,3 +1,7 @@
+-- use treesitter over syntax (for highlighted code blocks)
+vim.treesitter.start()
+
+-- add custom highlights for list in `:h highlight-groups`
if vim.endswith(vim.fs.normalize(vim.api.nvim_buf_get_name(0)), '/doc/syntax.txt') then
require('vim.vimhelp').highlight_groups()
end
diff --git a/runtime/lua/vim/_meta/api.lua b/runtime/lua/vim/_meta/api.lua
index 49269ba631..4ad0a2e791 100644
--- a/runtime/lua/vim/_meta/api.lua
+++ b/runtime/lua/vim/_meta/api.lua
@@ -151,7 +151,7 @@ function vim.api.nvim_buf_add_highlight(buffer, ns_id, hl_group, line, col_start
--- `nvim_buf_lines_event`. Else the first notification
--- will be `nvim_buf_changedtick_event`. Not for Lua
--- callbacks.
---- @param opts table<string,function> Optional parameters.
+--- @param opts vim.api.keyset.buf_attach Optional parameters.
--- • on_lines: Lua callback invoked on change. Return `true` to detach. Args:
--- • the string "lines"
--- • buffer handle
@@ -284,7 +284,7 @@ function vim.api.nvim_buf_del_var(buffer, name) end
--- Deletes the buffer. See `:bwipeout`
---
--- @param buffer integer Buffer handle, or 0 for current buffer
---- @param opts table<string,any> Optional parameters. Keys:
+--- @param opts vim.api.keyset.buf_delete Optional parameters. Keys:
--- • force: Force deletion and ignore unsaved changes.
--- • unload: Unloaded only, do not delete. See `:bunload`
function vim.api.nvim_buf_delete(buffer, opts) end
@@ -307,7 +307,7 @@ function vim.api.nvim_buf_get_commands(buffer, opts) end
--- @param buffer integer Buffer handle, or 0 for current buffer
--- @param ns_id integer Namespace id from `nvim_create_namespace()`
--- @param id integer Extmark id
---- @param opts table<string,any> Optional parameters. Keys:
+--- @param opts vim.api.keyset.get_extmark Optional parameters. Keys:
--- • details: Whether to include the details dict
--- • hl_name: Whether to include highlight group name instead
--- of id, true if omitted
@@ -440,7 +440,7 @@ function vim.api.nvim_buf_get_option(buffer, name) end
--- @param start_col integer Starting column (byte offset) on first line
--- @param end_row integer Last line index, inclusive
--- @param end_col integer Ending column (byte offset) on last line, exclusive
---- @param opts table<string,any> Optional parameters. Currently unused.
+--- @param opts vim.api.keyset.empty Optional parameters. Currently unused.
--- @return string[]
function vim.api.nvim_buf_get_text(buffer, start_row, start_col, end_row, end_col, opts) end
@@ -626,7 +626,7 @@ function vim.api.nvim_buf_set_lines(buffer, start, end_, strict_indexing, replac
--- @param name string Mark name
--- @param line integer Line number
--- @param col integer Column/row number
---- @param opts table<string,any> Optional parameters. Reserved for future use.
+--- @param opts vim.api.keyset.empty Optional parameters. Reserved for future use.
--- @return boolean
function vim.api.nvim_buf_set_mark(buffer, name, line, col, opts) end
@@ -675,7 +675,7 @@ function vim.api.nvim_buf_set_var(buffer, name, value) end
--- @param src_id integer
--- @param line integer
--- @param chunks any[]
---- @param opts table<string,any>
+--- @param opts vim.api.keyset.empty
--- @return integer
function vim.api.nvim_buf_set_virtual_text(buffer, src_id, line, chunks, opts) end
@@ -1241,7 +1241,7 @@ function vim.api.nvim_get_keymap(mode) end
--- Marks are (1,0)-indexed. `api-indexing`
---
--- @param name string Mark name
---- @param opts table<string,any> Optional parameters. Reserved for future use.
+--- @param opts vim.api.keyset.empty Optional parameters. Reserved for future use.
--- @return any[]
function vim.api.nvim_get_mark(name, opts) end
@@ -1439,7 +1439,7 @@ function vim.api.nvim_notify(msg, log_level, opts) end
--- virtual terminal having the intended size.
---
--- @param buffer integer the buffer to use (expected to be empty)
---- @param opts table<string,function> Optional parameters.
+--- @param opts vim.api.keyset.open_term Optional parameters.
--- • on_input: Lua callback for input sent, i e keypresses in
--- terminal mode. Note: keypresses are sent raw as they would
--- be to the pty master end. For instance, a carriage return
@@ -1602,7 +1602,7 @@ function vim.api.nvim_out_write(str) end
--- Doesn't check the validity of command arguments.
---
--- @param str string Command line string to parse. Cannot contain "\n".
---- @param opts table<string,any> Optional parameters. Reserved for future use.
+--- @param opts vim.api.keyset.empty Optional parameters. Reserved for future use.
--- @return table<string,any>
function vim.api.nvim_parse_cmd(str, opts) end
@@ -1685,7 +1685,7 @@ function vim.api.nvim_replace_termcodes(str, from_part, do_lt, special) end
--- inserted in the buffer. Ignored for `cmdline-completion`.
--- @param finish boolean Finish the completion and dismiss the popup menu. Implies
--- {insert}.
---- @param opts table<string,any> Optional parameters. Reserved for future use.
+--- @param opts vim.api.keyset.empty Optional parameters. Reserved for future use.
function vim.api.nvim_select_popupmenu_item(item, insert, finish, opts) end
--- Sets the current buffer.
diff --git a/runtime/lua/vim/_meta/api_keysets.lua b/runtime/lua/vim/_meta/api_keysets.lua
index f69e5a92c7..6a3e574455 100644
--- a/runtime/lua/vim/_meta/api_keysets.lua
+++ b/runtime/lua/vim/_meta/api_keysets.lua
@@ -3,6 +3,19 @@
-- DO NOT EDIT
error('Cannot require a meta file')
+--- @class vim.api.keyset.buf_attach
+--- @field on_lines? function
+--- @field on_bytes? function
+--- @field on_changedtick? function
+--- @field on_detach? function
+--- @field on_reload? function
+--- @field utf_sizes? boolean
+--- @field preview? boolean
+
+--- @class vim.api.keyset.buf_delete
+--- @field force? boolean
+--- @field unload? boolean
+
--- @class vim.api.keyset.clear_autocmds
--- @field buffer? integer
--- @field event? any
@@ -74,6 +87,8 @@ error('Cannot require a meta file')
--- @class vim.api.keyset.echo_opts
--- @field verbose? boolean
+--- @class vim.api.keyset.empty
+
--- @class vim.api.keyset.eval_statusline
--- @field winid? integer
--- @field maxwidth? integer
@@ -124,6 +139,10 @@ error('Cannot require a meta file')
--- @class vim.api.keyset.get_commands
--- @field builtin? boolean
+--- @class vim.api.keyset.get_extmark
+--- @field details? boolean
+--- @field hl_name? boolean
+
--- @class vim.api.keyset.get_extmarks
--- @field limit? integer
--- @field details? boolean
@@ -196,6 +215,9 @@ error('Cannot require a meta file')
--- @field desc? string
--- @field replace_keycodes? boolean
+--- @class vim.api.keyset.open_term
+--- @field on_input? function
+
--- @class vim.api.keyset.option
--- @field scope? string
--- @field win? integer
diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua
index 60882d4432..e64923ab54 100644
--- a/runtime/lua/vim/filetype.lua
+++ b/runtime/lua/vim/filetype.lua
@@ -1394,6 +1394,7 @@ local filename = {
octaverc = 'octave',
['octave.conf'] = 'octave',
opam = 'opam',
+ ['pacman.log'] = 'pacmanlog',
['/etc/pam.conf'] = 'pamconf',
['pam_env.conf'] = 'pamenv',
['.pam_environment'] = 'pamenv',
diff --git a/runtime/lua/vim/treesitter.lua b/runtime/lua/vim/treesitter.lua
index e7a66c00b2..7b795380fe 100644
--- a/runtime/lua/vim/treesitter.lua
+++ b/runtime/lua/vim/treesitter.lua
@@ -362,6 +362,7 @@ end
--- - bufnr integer|nil Buffer number (nil or 0 for current buffer)
--- - pos table|nil 0-indexed (row, col) tuple. Defaults to cursor position in the
--- current window. Required if {bufnr} is not the current buffer
+--- - lang string|nil Parser language. (default: from buffer filetype)
--- - ignore_injections boolean Ignore injected languages (default true)
---
---@return TSNode | nil Node at the given position
@@ -392,7 +393,7 @@ function M.get_node(opts)
local ts_range = { row, col, row, col }
- local root_lang_tree = M.get_parser(bufnr)
+ local root_lang_tree = M.get_parser(bufnr, opts.lang)
if not root_lang_tree then
return
end
diff --git a/runtime/syntax/pacmanlog.vim b/runtime/syntax/pacmanlog.vim
new file mode 100644
index 0000000000..98abd58685
--- /dev/null
+++ b/runtime/syntax/pacmanlog.vim
@@ -0,0 +1,41 @@
+" Vim syntax file
+" Language: pacman.log
+" Maintainer: Ronan Pigott <ronan@rjp.ie>
+" Last Change: 2023 Dec 04
+
+if exists("b:current_syntax")
+ finish
+endif
+
+syn sync maxlines=1
+syn region pacmanlogMsg start='\S' end='$' keepend contains=pacmanlogTransaction,pacmanlogALPMMsg
+syn region pacmanlogTag start='\['hs=s+1 end='\]'he=e-1 keepend nextgroup=pacmanlogMsg
+syn region pacmanlogTime start='^\['hs=s+1 end='\]'he=e-1 keepend nextgroup=pacmanlogTag
+
+syn match pacmanlogPackageName '\v[a-z0-9@_+.-]+' contained skipwhite nextgroup=pacmanlogPackageVersion
+syn match pacmanlogPackageVersion '(.*)' contained
+
+syn match pacmanlogTransaction 'transaction \v(started|completed)$' contained
+syn match pacmanlogInstalled '\v(re)?installed' contained nextgroup=pacmanlogPackageName
+syn match pacmanlogUpgraded 'upgraded' contained nextgroup=pacmanlogPackageName
+syn match pacmanlogDowngraded 'downgraded' contained nextgroup=pacmanlogPackageName
+syn match pacmanlogRemoved 'removed' contained nextgroup=pacmanlogPackageName
+syn match pacmanlogWarning 'warning:.*$' contained
+
+syn region pacmanlogALPMMsg start='\v(\[ALPM\] )@<=(transaction|(re)?installed|upgraded|downgraded|removed|warning)>' end='$' contained
+ \ contains=pacmanlogTransaction,pacmanlogInstalled,pacmanlogUpgraded,pacmanlogDowngraded,pacmanlogRemoved,pacmanlogWarning,pacmanlogPackageName,pacmanlogPackgeVersion
+
+hi def link pacmanlogTime String
+hi def link pacmanlogTag Type
+
+hi def link pacmanlogTransaction Special
+hi def link pacmanlogInstalled Identifier
+hi def link pacmanlogRemoved Repeat
+hi def link pacmanlogUpgraded pacmanlogInstalled
+hi def link pacmanlogDowngraded pacmanlogRemoved
+hi def link pacmanlogWarning WarningMsg
+
+hi def link pacmanlogPackageName Normal
+hi def link pacmanlogPackageVersion Comment
+
+let b:current_syntax = "pacmanlog"
diff --git a/scripts/bump_deps.lua b/scripts/bump_deps.lua
index 076ad374cf..c5294893e0 100755
--- a/scripts/bump_deps.lua
+++ b/scripts/bump_deps.lua
@@ -138,9 +138,10 @@ local function get_archive_info(repo, ref)
'Failed to download archive from GitHub'
)
- local shacmd = (vim.fn.executable('sha256sum') == 1
- and{ 'sha256sum', archive_path }
- or { 'shasum', '-a', '256', archive_path })
+ local shacmd = (
+ vim.fn.executable('sha256sum') == 1 and { 'sha256sum', archive_path }
+ or { 'shasum', '-a', '256', archive_path }
+ )
local archive_sha = run(shacmd):gmatch('%w+')()
return { url = archive_url, sha = archive_sha }
end
@@ -152,18 +153,7 @@ local function write_cmakelists_line(symbol, kind, value)
'sed',
'-i',
'-e',
- 's/'
- .. symbol
- .. '_'
- .. kind
- .. '.*$'
- .. '/'
- .. symbol
- .. '_'
- .. kind
- .. ' '
- .. value
- .. '/',
+ 's/' .. symbol .. '_' .. kind .. '.*$' .. '/' .. symbol .. '_' .. kind .. ' ' .. value .. '/',
deps_file,
}, 'Failed to write ' .. deps_file)
end
@@ -203,16 +193,13 @@ local function update_cmakelists(dependency, archive, comment)
p('Updating ' .. dependency.name .. ' to ' .. archive.url .. '\n')
write_cmakelists_line(dependency.symbol, 'URL', archive.url:gsub('/', '\\/'))
write_cmakelists_line(dependency.symbol, 'SHA256', archive.sha)
- run_die(
- {
- 'git',
- 'commit',
- deps_file,
- '-m',
- commit_prefix .. 'bump ' .. dependency.name .. ' to ' .. comment,
- },
- 'git failed to commit'
- )
+ run_die({
+ 'git',
+ 'commit',
+ deps_file,
+ '-m',
+ commit_prefix .. 'bump ' .. dependency.name .. ' to ' .. comment,
+ }, 'git failed to commit')
end
local function verify_cmakelists_committed()
@@ -318,9 +305,9 @@ function M.commit(dependency_name, commit)
end
function M.version(dependency_name, version)
- vim.validate{
- dependency_name={dependency_name,'s'},
- version={version,'s'},
+ vim.validate {
+ dependency_name = { dependency_name, 's' },
+ version = { version, 's' },
}
local dependency = assert(get_dependency(dependency_name))
verify_cmakelists_committed()
@@ -384,7 +371,7 @@ function M.submit_pr()
end
local function usage()
- local this_script = _G.arg[0]:match("[^/]*.lua$")
+ local this_script = _G.arg[0]:match('[^/]*.lua$')
print(([=[
Bump Nvim dependencies
@@ -421,13 +408,13 @@ local function parseargs()
elseif _G.arg[i] == '--pr' then
args.pr = true
elseif _G.arg[i] == '--branch' then
- args.branch = _G.arg[i+1]
+ args.branch = _G.arg[i + 1]
elseif _G.arg[i] == '--dep' then
- args.dep = _G.arg[i+1]
+ args.dep = _G.arg[i + 1]
elseif _G.arg[i] == '--version' then
- args.version = _G.arg[i+1]
+ args.version = _G.arg[i + 1]
elseif _G.arg[i] == '--commit' then
- args.commit = _G.arg[i+1]
+ args.commit = _G.arg[i + 1]
elseif _G.arg[i] == '--head' then
args.head = true
end
diff --git a/scripts/gen_eval_files.lua b/scripts/gen_eval_files.lua
index e331dd996e..dddc7d000c 100755
--- a/scripts/gen_eval_files.lua
+++ b/scripts/gen_eval_files.lua
@@ -1,7 +1,7 @@
-- Generator for various vimdoc and Lua type files
local DEP_API_METADATA = 'build/api_metadata.mpack'
-local DEP_API_DOC = 'runtime/doc/api.mpack'
+local DEP_API_DOC = 'runtime/doc/api.mpack'
--- @class vim.api.metadata
--- @field name string
@@ -302,7 +302,7 @@ local function get_api_keysets_meta()
for _, k in ipairs(keysets) do
local params = {}
for _, key in ipairs(k.keys) do
- table.insert(params, {key..'?', api_type(k.types[key] or 'any')})
+ table.insert(params, { key .. '?', api_type(k.types[key] or 'any') })
end
ret[k.name] = {
signature = 'NA',
@@ -396,7 +396,7 @@ local function render_sig_and_tag(name, fun, write)
local tag = table.concat(tags, ' ')
local siglen = #fun.signature
- local conceal_offset = 2*(#tags - 1)
+ local conceal_offset = 2 * (#tags - 1)
local tag_pad_len = math.max(1, 80 - #tag + conceal_offset)
if siglen + #tag > 80 then
@@ -473,7 +473,7 @@ local function render_option_default(d, vimdoc)
end
end
- if dt == "" or dt == nil or type(dt) == 'function' then
+ if dt == '' or dt == nil or type(dt) == 'function' then
dt = d.meta
end
@@ -481,22 +481,22 @@ local function render_option_default(d, vimdoc)
if not vimdoc then
v = vim.inspect(dt) --[[@as string]]
else
- v = type(dt) == 'string' and '"'..dt..'"' or tostring(dt)
+ v = type(dt) == 'string' and '"' .. dt .. '"' or tostring(dt)
end
--- @type table<string, string|false>
local envvars = {
TMPDIR = false,
VIMRUNTIME = false,
- XDG_CONFIG_HOME = vim.env.HOME..'/.local/config',
- XDG_DATA_HOME = vim.env.HOME..'/.local/share',
- XDG_STATE_HOME = vim.env.HOME..'/.local/state',
+ XDG_CONFIG_HOME = vim.env.HOME .. '/.local/config',
+ XDG_DATA_HOME = vim.env.HOME .. '/.local/share',
+ XDG_STATE_HOME = vim.env.HOME .. '/.local/state',
}
for name, default in pairs(envvars) do
local value = vim.env[name] or default
if value then
- v = v:gsub(vim.pesc(value), '$'..name)
+ v = v:gsub(vim.pesc(value), '$' .. name)
end
end
@@ -509,26 +509,26 @@ end
local function render_option_meta(_f, opt, write)
write('')
for _, l in ipairs(split(norm_text(opt.desc))) do
- write('--- '..l)
+ write('--- ' .. l)
end
- write('--- @type '..OPTION_TYPES[opt.type])
- write('vim.o.'..opt.full_name..' = '..render_option_default(opt.defaults))
+ write('--- @type ' .. OPTION_TYPES[opt.type])
+ write('vim.o.' .. opt.full_name .. ' = ' .. render_option_default(opt.defaults))
if opt.abbreviation then
- write('vim.o.'..opt.abbreviation..' = vim.o.'..opt.full_name)
+ write('vim.o.' .. opt.abbreviation .. ' = vim.o.' .. opt.full_name)
end
for _, s in pairs {
- {'wo', 'window'},
- {'bo', 'buffer'},
- {'go', 'global'},
+ { 'wo', 'window' },
+ { 'bo', 'buffer' },
+ { 'go', 'global' },
} do
local id, scope = s[1], s[2]
if vim.list_contains(opt.scope, scope) or (id == 'go' and #opt.scope > 1) then
- local pfx = 'vim.'..id..'.'
- write(pfx..opt.full_name..' = vim.o.'..opt.full_name)
+ local pfx = 'vim.' .. id .. '.'
+ write(pfx .. opt.full_name .. ' = vim.o.' .. opt.full_name)
if opt.abbreviation then
- write(pfx..opt.abbreviation..' = '..pfx..opt.full_name)
+ write(pfx .. opt.abbreviation .. ' = ' .. pfx .. opt.full_name)
end
end
end
@@ -541,14 +541,14 @@ local function scope_to_doc(s)
global = 'global',
buffer = 'local to buffer',
window = 'local to window',
- tab = 'local to tab page'
+ tab = 'local to tab page',
}
if #s == 1 then
return m[s[1]]
end
assert(s[1] == 'global')
- return 'global or '..m[s[2]]..' |global-local|'
+ return 'global or ' .. m[s[2]] .. ' |global-local|'
end
-- @param o vim.option_meta
@@ -602,23 +602,23 @@ local function build_option_tags(opt)
--- @type string[]
local tags = { opt.full_name }
- tags[#tags+1] = opt.abbreviation
+ tags[#tags + 1] = opt.abbreviation
if opt.type == 'bool' then
for i = 1, #tags do
- tags[#tags+1] = 'no'..tags[i]
+ tags[#tags + 1] = 'no' .. tags[i]
end
end
for i, t in ipairs(tags) do
- tags[i] = "'"..t.."'"
+ tags[i] = "'" .. t .. "'"
end
for _, t in ipairs(opt.tags or {}) do
- tags[#tags+1] = t
+ tags[#tags + 1] = t
end
for i, t in ipairs(tags) do
- tags[i] = "*"..t.."*"
+ tags[i] = '*' .. t .. '*'
end
return tags
@@ -630,10 +630,10 @@ end
local function render_option_doc(_f, opt, write)
local tags = build_option_tags(opt)
local tag_str = table.concat(tags, ' ')
- local conceal_offset = 2*(#tags - 1)
+ local conceal_offset = 2 * (#tags - 1)
local tag_pad = string.rep('\t', math.ceil((64 - #tag_str + conceal_offset) / 8))
-- local pad = string.rep(' ', 80 - #tag_str + conceal_offset)
- write(tag_pad..tag_str)
+ write(tag_pad .. tag_str)
local name_str --- @type string
if opt.abbreviation then
@@ -649,19 +649,19 @@ local function render_option_doc(_f, opt, write)
if opt.defaults.doc then
local deflen = #string.format('%s%s%s (', name_str, pad, otype)
--- @type string
- v = v:gsub('\n', '\n'..string.rep(' ', deflen - 2))
+ v = v:gsub('\n', '\n' .. string.rep(' ', deflen - 2))
end
write(string.format('%s%s%s\t(default %s)', name_str, pad, otype, v))
else
write(string.format('%s\t%s', name_str, otype))
end
- write('\t\t\t'..scope_to_doc(opt.scope)..scope_more_doc(opt))
+ write('\t\t\t' .. scope_to_doc(opt.scope) .. scope_more_doc(opt))
for _, l in ipairs(split(opt.desc)) do
if l == '<' or l:match('^<%s') then
write(l)
else
- write('\t'..l:gsub('\\<', '<'))
+ write('\t' .. l:gsub('\\<', '<'))
end
end
end
@@ -751,21 +751,21 @@ local CONFIG = {
header = { '' },
from = 'A jump table for the options with a short description can be found at |Q_op|.',
footer = {
- ' vim:tw=78:ts=8:noet:ft=help:norl:'
+ ' vim:tw=78:ts=8:noet:ft=help:norl:',
},
funcs = get_option_meta,
render = render_option_doc,
- }
+ },
}
--- @param elem nvim.gen_eval_files.elem
local function render(elem)
- print('Rendering '..elem.path)
- local from_lines = {} --- @type string[]
+ print('Rendering ' .. elem.path)
+ local from_lines = {} --- @type string[]
local from = elem.from
if from then
for line in io.lines(elem.path) do
- from_lines[#from_lines+1] = line
+ from_lines[#from_lines + 1] = line
if line:match(from) then
break
end
diff --git a/scripts/gen_filetype.lua b/scripts/gen_filetype.lua
index 42478a1082..18b53f1ea4 100644
--- a/scripts/gen_filetype.lua
+++ b/scripts/gen_filetype.lua
@@ -8,18 +8,18 @@ if do_not_run then
return
end
-local filetype_vim = "runtime/filetype.vim"
-local filetype_lua = "runtime/lua/vim/filetype.lua"
+local filetype_vim = 'runtime/filetype.vim'
+local filetype_lua = 'runtime/lua/vim/filetype.lua'
local keywords = {
- ["for"] = true,
- ["or"] = true,
- ["and"] = true,
- ["end"] = true,
- ["do"] = true,
- ["if"] = true,
- ["while"] = true,
- ["repeat"] = true,
+ ['for'] = true,
+ ['or'] = true,
+ ['and'] = true,
+ ['end'] = true,
+ ['do'] = true,
+ ['if'] = true,
+ ['while'] = true,
+ ['repeat'] = true,
}
local sections = {
@@ -28,42 +28,42 @@ local sections = {
pattern = { str = {}, func = {} },
}
-local specialchars = "%*%?\\%$%[%]%{%}"
+local specialchars = '%*%?\\%$%[%]%{%}'
local function add_pattern(pat, ft)
local ok = true
-- Patterns that start or end with { or } confuse splitting on commas and make parsing harder, so just skip those
- if not string.find(pat, "^%{") and not string.find(pat, "%}$") then
- for part in string.gmatch(pat, "[^,]+") do
- if not string.find(part, "[" .. specialchars .. "]") then
- if type(ft) == "string" then
+ if not string.find(pat, '^%{') and not string.find(pat, '%}$') then
+ for part in string.gmatch(pat, '[^,]+') do
+ if not string.find(part, '[' .. specialchars .. ']') then
+ if type(ft) == 'string' then
sections.filename.str[part] = ft
else
sections.filename.func[part] = ft
end
- elseif string.match(part, "^%*%.[^%./" .. specialchars .. "]+$") then
- if type(ft) == "string" then
+ elseif string.match(part, '^%*%.[^%./' .. specialchars .. ']+$') then
+ if type(ft) == 'string' then
sections.extension.str[part:sub(3)] = ft
else
sections.extension.func[part:sub(3)] = ft
end
else
- if string.match(part, "^%*/[^" .. specialchars .. "]+$") then
+ if string.match(part, '^%*/[^' .. specialchars .. ']+$') then
-- For patterns matching */some/pattern we want to easily match files
-- with path /some/pattern, so include those in filename detection
- if type(ft) == "string" then
+ if type(ft) == 'string' then
sections.filename.str[part:sub(2)] = ft
else
sections.filename.func[part:sub(2)] = ft
end
end
- if string.find(part, "^[%w-_.*?%[%]/]+$") then
- local p = part:gsub("%.", "%%."):gsub("%*", ".*"):gsub("%?", ".")
+ if string.find(part, '^[%w-_.*?%[%]/]+$') then
+ local p = part:gsub('%.', '%%.'):gsub('%*', '.*'):gsub('%?', '.')
-- Insert into array to maintain order rather than setting
-- key-value directly
- if type(ft) == "string" then
+ if type(ft) == 'string' then
sections.pattern.str[p] = ft
else
sections.pattern.func[p] = ft
@@ -80,14 +80,16 @@ end
local function parse_line(line)
local pat, ft
- pat, ft = line:match("^%s*au%a* Buf[%a,]+%s+(%S+)%s+setf%s+(%S+)")
+ pat, ft = line:match('^%s*au%a* Buf[%a,]+%s+(%S+)%s+setf%s+(%S+)')
if pat then
return add_pattern(pat, ft)
else
local func
- pat, func = line:match("^%s*au%a* Buf[%a,]+%s+(%S+)%s+call%s+(%S+)")
+ pat, func = line:match('^%s*au%a* Buf[%a,]+%s+(%S+)%s+call%s+(%S+)')
if pat then
- return add_pattern(pat, function() return func end)
+ return add_pattern(pat, function()
+ return func
+ end)
end
end
end
@@ -95,12 +97,12 @@ end
local unparsed = {}
local full_line
for line in io.lines(filetype_vim) do
- local cont = string.match(line, "^%s*\\%s*(.*)$")
+ local cont = string.match(line, '^%s*\\%s*(.*)$')
if cont then
- full_line = full_line .. " " .. cont
+ full_line = full_line .. ' ' .. cont
else
if full_line then
- if not parse_line(full_line) and string.find(full_line, "^%s*au%a* Buf") then
+ if not parse_line(full_line) and string.find(full_line, '^%s*au%a* Buf') then
table.insert(unparsed, full_line)
end
end
@@ -109,40 +111,46 @@ for line in io.lines(filetype_vim) do
end
if #unparsed > 0 then
- print("Failed to parse the following patterns:")
+ print('Failed to parse the following patterns:')
for _, v in ipairs(unparsed) do
print(v)
end
end
local function add_item(indent, key, ft)
- if type(ft) == "string" then
- if string.find(key, "%A") or keywords[key] then
- key = string.format("[\"%s\"]", key)
+ if type(ft) == 'string' then
+ if string.find(key, '%A') or keywords[key] then
+ key = string.format('["%s"]', key)
end
return string.format([[%s%s = "%s",]], indent, key, ft)
- elseif type(ft) == "function" then
+ elseif type(ft) == 'function' then
local func = ft()
- if string.find(key, "%A") or keywords[key] then
- key = string.format("[\"%s\"]", key)
+ if string.find(key, '%A') or keywords[key] then
+ key = string.format('["%s"]', key)
end
-- Right now only a single argument is supported, which covers
-- everything in filetype.vim as of this writing
- local arg = string.match(func, "%((.*)%)$")
- func = string.gsub(func, "%(.*$", "")
- if arg == "" then
+ local arg = string.match(func, '%((.*)%)$')
+ func = string.gsub(func, '%(.*$', '')
+ if arg == '' then
-- Function with no arguments, call the function directly
return string.format([[%s%s = function() vim.fn["%s"]() end,]], indent, key, func)
elseif string.match(arg, [[^(["']).*%1$]]) then
-- String argument
- if func == "s:StarSetf" then
+ if func == 's:StarSetf' then
return string.format([[%s%s = starsetf(%s),]], indent, key, arg)
else
return string.format([[%s%s = function() vim.fn["%s"](%s) end,]], indent, key, func, arg)
end
- elseif string.find(arg, "%(") then
+ elseif string.find(arg, '%(') then
-- Function argument
- return string.format([[%s%s = function() vim.fn["%s"](vim.fn.%s) end,]], indent, key, func, arg)
+ return string.format(
+ [[%s%s = function() vim.fn["%s"](vim.fn.%s) end,]],
+ indent,
+ key,
+ func,
+ arg
+ )
else
assert(false, arg)
end
@@ -153,7 +161,7 @@ do
local lines = {}
local start = false
for line in io.lines(filetype_lua) do
- if line:match("^%s+-- END [A-Z]+$") then
+ if line:match('^%s+-- END [A-Z]+$') then
start = false
end
@@ -161,14 +169,14 @@ do
table.insert(lines, line)
end
- local indent, section = line:match("^(%s+)-- BEGIN ([A-Z]+)$")
+ local indent, section = line:match('^(%s+)-- BEGIN ([A-Z]+)$')
if section then
start = true
local t = sections[string.lower(section)]
local sorted = {}
for k, v in pairs(t.str) do
- table.insert(sorted, {[k] = v})
+ table.insert(sorted, { [k] = v })
end
table.sort(sorted, function(a, b)
@@ -182,7 +190,7 @@ do
sorted = {}
for k, v in pairs(t.func) do
- table.insert(sorted, {[k] = v})
+ table.insert(sorted, { [k] = v })
end
table.sort(sorted, function(a, b)
@@ -195,7 +203,7 @@ do
end
end
end
- local f = io.open(filetype_lua, "w")
- f:write(table.concat(lines, "\n") .. "\n")
+ local f = io.open(filetype_lua, 'w')
+ f:write(table.concat(lines, '\n') .. '\n')
f:close()
end
diff --git a/scripts/gen_help_html.lua b/scripts/gen_help_html.lua
index 633207e018..9369711b0f 100644
--- a/scripts/gen_help_html.lua
+++ b/scripts/gen_help_html.lua
@@ -60,26 +60,26 @@ local new_layout = {
-- TODO: These known invalid |links| require an update to the relevant docs.
local exclude_invalid = {
- ["'string'"] = "eval.txt",
+ ["'string'"] = 'eval.txt',
Query = 'treesitter.txt',
matchit = 'vim_diff.txt',
- ["set!"] = "treesitter.txt",
+ ['set!'] = 'treesitter.txt',
}
-- False-positive "invalid URLs".
local exclude_invalid_urls = {
- ["http://"] = "usr_23.txt",
- ["http://."] = "usr_23.txt",
- ["http://aspell.net/man-html/Affix-Compression.html"] = "spell.txt",
- ["http://aspell.net/man-html/Phonetic-Code.html"] = "spell.txt",
- ["http://canna.sourceforge.jp/"] = "mbyte.txt",
- ["http://gnuada.sourceforge.net"] = "ft_ada.txt",
- ["http://lua-users.org/wiki/StringLibraryTutorial"] = "lua.txt",
- ["http://michael.toren.net/code/"] = "pi_tar.txt",
- ["http://papp.plan9.de"] = "syntax.txt",
- ["http://wiki.services.openoffice.org/wiki/Dictionaries"] = "spell.txt",
- ["http://www.adapower.com"] = "ft_ada.txt",
- ["http://www.jclark.com/"] = "quickfix.txt",
+ ['http://'] = 'usr_23.txt',
+ ['http://.'] = 'usr_23.txt',
+ ['http://aspell.net/man-html/Affix-Compression.html'] = 'spell.txt',
+ ['http://aspell.net/man-html/Phonetic-Code.html'] = 'spell.txt',
+ ['http://canna.sourceforge.jp/'] = 'mbyte.txt',
+ ['http://gnuada.sourceforge.net'] = 'ft_ada.txt',
+ ['http://lua-users.org/wiki/StringLibraryTutorial'] = 'lua.txt',
+ ['http://michael.toren.net/code/'] = 'pi_tar.txt',
+ ['http://papp.plan9.de'] = 'syntax.txt',
+ ['http://wiki.services.openoffice.org/wiki/Dictionaries'] = 'spell.txt',
+ ['http://www.adapower.com'] = 'ft_ada.txt',
+ ['http://www.jclark.com/'] = 'quickfix.txt',
}
-- Deprecated, brain-damaged files that I don't care about.
@@ -98,19 +98,18 @@ local function tofile(fname, text)
end
local function html_esc(s)
- return s:gsub(
- '&', '&amp;'):gsub(
- '<', '&lt;'):gsub(
- '>', '&gt;')
+ return s:gsub('&', '&amp;'):gsub('<', '&lt;'):gsub('>', '&gt;')
end
local function url_encode(s)
-- Credit: tpope / vim-unimpaired
-- NOTE: these chars intentionally *not* escaped: ' ( )
- return vim.fn.substitute(vim.fn.iconv(s, 'latin1', 'utf-8'),
+ return vim.fn.substitute(
+ vim.fn.iconv(s, 'latin1', 'utf-8'),
[=[[^A-Za-z0-9()'_.~-]]=],
[=[\="%".printf("%02X",char2nr(submatch(0)))]=],
- 'g')
+ 'g'
+ )
end
local function expandtabs(s)
@@ -131,7 +130,7 @@ local function to_heading_tag(text)
end
local function basename_noext(f)
- return vim.fs.basename(f:gsub('%.txt', ''))
+ return vim.fs.basename(f:gsub('%.txt', ''))
end
local function is_blank(s)
@@ -151,7 +150,7 @@ local function fix_url(url)
local removed_chars = ''
local fixed_url = url
-- Remove up to one of each char from end of the URL, in this order.
- for _, c in ipairs({ '.', ')', }) do
+ for _, c in ipairs({ '.', ')' }) do
if fixed_url:sub(-1) == c then
removed_chars = c .. removed_chars
fixed_url = fixed_url:sub(1, -2)
@@ -162,7 +161,7 @@ end
--- Checks if a given line is a "noise" line that doesn't look good in HTML form.
local function is_noise(line, noise_lines)
- if (
+ if
-- First line is always noise.
(noise_lines ~= nil and vim.tbl_count(noise_lines) == 0)
or line:find('Type .*gO.* to see the table of contents')
@@ -177,7 +176,7 @@ local function is_noise(line, noise_lines)
or line:find('^%s*vim?%:.*ft=help')
or line:find('^%s*vim?%:.*filetype=help')
or line:find('[*>]local%-additions[*<]')
- ) then
+ then
-- table.insert(stats.noise_lines, getbuflinestr(root, opt.buf, 0))
table.insert(noise_lines or {}, line)
return true
@@ -188,28 +187,32 @@ end
--- Creates a github issue URL at neovim/tree-sitter-vimdoc with prefilled content.
local function get_bug_url_vimdoc(fname, to_fname, sample_text)
local this_url = string.format('https://neovim.io/doc/user/%s', vim.fs.basename(to_fname))
- local bug_url = ('https://github.com/neovim/tree-sitter-vimdoc/issues/new?labels=bug&title=parse+error%3A+'
- ..vim.fs.basename(fname)
- ..'+&body=Found+%60tree-sitter-vimdoc%60+parse+error+at%3A+'
- ..this_url
- ..'%0D%0DContext%3A%0D%0D%60%60%60%0D'
- ..url_encode(sample_text)
- ..'%0D%60%60%60')
+ local bug_url = (
+ 'https://github.com/neovim/tree-sitter-vimdoc/issues/new?labels=bug&title=parse+error%3A+'
+ .. vim.fs.basename(fname)
+ .. '+&body=Found+%60tree-sitter-vimdoc%60+parse+error+at%3A+'
+ .. this_url
+ .. '%0D%0DContext%3A%0D%0D%60%60%60%0D'
+ .. url_encode(sample_text)
+ .. '%0D%60%60%60'
+ )
return bug_url
end
--- Creates a github issue URL at neovim/neovim with prefilled content.
local function get_bug_url_nvim(fname, to_fname, sample_text, token_name)
local this_url = string.format('https://neovim.io/doc/user/%s', vim.fs.basename(to_fname))
- local bug_url = ('https://github.com/neovim/neovim/issues/new?labels=bug&title=user+docs+HTML%3A+'
- ..vim.fs.basename(fname)
- ..'+&body=%60gen_help_html.lua%60+problem+at%3A+'
- ..this_url
- ..'%0D'
- ..(token_name and '+unhandled+token%3A+%60'..token_name..'%60' or '')
- ..'%0DContext%3A%0D%0D%60%60%60%0D'
- ..url_encode(sample_text)
- ..'%0D%60%60%60')
+ local bug_url = (
+ 'https://github.com/neovim/neovim/issues/new?labels=bug&title=user+docs+HTML%3A+'
+ .. vim.fs.basename(fname)
+ .. '+&body=%60gen_help_html.lua%60+problem+at%3A+'
+ .. this_url
+ .. '%0D'
+ .. (token_name and '+unhandled+token%3A+%60' .. token_name .. '%60' or '')
+ .. '%0DContext%3A%0D%0D%60%60%60%0D'
+ .. url_encode(sample_text)
+ .. '%0D%60%60%60'
+ )
return bug_url
end
@@ -274,9 +277,11 @@ end
local function get_tagname(node, bufnr)
local text = vim.treesitter.get_node_text(node, bufnr)
- local tag = (node:type() == 'optionlink' or node:parent():type() == 'optionlink') and ("'%s'"):format(text) or text
- local helpfile = vim.fs.basename(tagmap[tag]) or nil -- "api.txt"
- local helppage = get_helppage(helpfile) -- "api.html"
+ local tag = (node:type() == 'optionlink' or node:parent():type() == 'optionlink')
+ and ("'%s'"):format(text)
+ or text
+ local helpfile = vim.fs.basename(tagmap[tag]) or nil -- "api.txt"
+ local helppage = get_helppage(helpfile) -- "api.html"
return helppage, tag
end
@@ -295,11 +300,9 @@ local function ignore_parse_error(fname, s)
if ignore_errors[vim.fs.basename(fname)] then
return true
end
- return (
- -- Ignore parse errors for unclosed tag.
- -- This is common in vimdocs and is treated as plaintext by :help.
- s:find("^[`'|*]")
- )
+ -- Ignore parse errors for unclosed tag.
+ -- This is common in vimdocs and is treated as plaintext by :help.
+ return s:find("^[`'|*]")
end
local function has_ancestor(node, ancestor_name)
@@ -377,10 +380,11 @@ local function visit_validate(root, level, lang_tree, opt, stats)
-- Flatten the sample text to a single, truncated line.
sample_text = vim.trim(sample_text):gsub('[\t\n]', ' '):sub(1, 80)
table.insert(stats.parse_errors, sample_text)
- elseif (node_name == 'word' or node_name == 'uppercase_name')
- and (not vim.tbl_contains({'codespan', 'taglink', 'tag'}, parent))
+ elseif
+ (node_name == 'word' or node_name == 'uppercase_name')
+ and (not vim.tbl_contains({ 'codespan', 'taglink', 'tag' }, parent))
then
- local text_nopunct = vim.fn.trim(text, '.,', 0) -- Ignore some punctuation.
+ local text_nopunct = vim.fn.trim(text, '.,', 0) -- Ignore some punctuation.
if spell_dict[text_nopunct] then
invalid_spelling[text_nopunct] = invalid_spelling[text_nopunct] or {}
invalid_spelling[text_nopunct][vim.fs.basename(opt.fname)] = node_text(root:parent())
@@ -399,7 +403,7 @@ local function fix_tab_after_conceal(text, next_node_text)
-- Vim tabs take into account the two concealed characters even though they
-- are invisible, so we need to add back in the two spaces if this is
-- followed by a tab to make the tab alignment to match Vim's behavior.
- if string.sub(next_node_text,1,1) == '\t' then
+ if string.sub(next_node_text, 1, 1) == '\t' then
text = text .. ' '
end
return text
@@ -411,9 +415,15 @@ local function visit_node(root, level, lang_tree, headings, opt, stats)
local node_name = (root.named and root:named()) and root:type() or nil
-- Previous sibling kind (string).
- local prev = root:prev_sibling() and (root:prev_sibling().named and root:prev_sibling():named()) and root:prev_sibling():type() or nil
+ local prev = root:prev_sibling()
+ and (root:prev_sibling().named and root:prev_sibling():named())
+ and root:prev_sibling():type()
+ or nil
-- Next sibling kind (string).
- local next_ = root:next_sibling() and (root:next_sibling().named and root:next_sibling():named()) and root:next_sibling():type() or nil
+ local next_ = root:next_sibling()
+ and (root:next_sibling().named and root:next_sibling():named())
+ and root:next_sibling():type()
+ or nil
-- Parent kind (string).
local parent = root:parent() and root:parent():type() or nil
local text = ''
@@ -450,7 +460,7 @@ local function visit_node(root, level, lang_tree, headings, opt, stats)
trimmed = trim(text)
end
- if node_name == 'help_file' then -- root node
+ if node_name == 'help_file' then -- root node
return text
elseif node_name == 'url' then
local fixed_url, removed_chars = fix_url(trimmed)
@@ -459,18 +469,22 @@ local function visit_node(root, level, lang_tree, headings, opt, stats)
return text
elseif node_name == 'h1' or node_name == 'h2' or node_name == 'h3' then
if is_noise(text, stats.noise_lines) then
- return '' -- Discard common "noise" lines.
+ return '' -- Discard common "noise" lines.
end
-- Remove "===" and tags from ToC text.
local hname = (node_text():gsub('%-%-%-%-+', ''):gsub('%=%=%=%=+', ''):gsub('%*.*%*', ''))
-- Use the first *tag* node as the heading anchor, if any.
local tagnode = first(root, 'tag')
-- Use the *tag* as the heading anchor id, if possible.
- local tagname = tagnode and url_encode(node_text(tagnode:child(1), false)) or to_heading_tag(hname)
+ local tagname = tagnode and url_encode(node_text(tagnode:child(1), false))
+ or to_heading_tag(hname)
if node_name == 'h1' or #headings == 0 then
table.insert(headings, { name = hname, subheadings = {}, tag = tagname })
else
- table.insert(headings[#headings].subheadings, { name = hname, subheadings = {}, tag = tagname })
+ table.insert(
+ headings[#headings].subheadings,
+ { name = hname, subheadings = {}, tag = tagname }
+ )
end
local el = node_name == 'h1' and 'h2' or 'h3'
return ('<%s id="%s" class="help-heading">%s</%s>\n'):format(el, tagname, text, el)
@@ -490,11 +504,16 @@ local function visit_node(root, level, lang_tree, headings, opt, stats)
end
return string.format('<div class="help-para">\n%s\n</div>\n', text)
elseif node_name == 'line' then
- if (parent ~= 'codeblock' or parent ~= 'code') and (is_blank(text) or is_noise(text, stats.noise_lines)) then
- return '' -- Discard common "noise" lines.
+ if
+ (parent ~= 'codeblock' or parent ~= 'code')
+ and (is_blank(text) or is_noise(text, stats.noise_lines))
+ then
+ return '' -- Discard common "noise" lines.
end
-- XXX: Avoid newlines (too much whitespace) after block elements in old (preformatted) layout.
- local div = opt.old and root:child(0) and vim.list_contains({'column_heading', 'h1', 'h2', 'h3'}, root:child(0):type())
+ local div = opt.old
+ and root:child(0)
+ and vim.list_contains({ 'column_heading', 'h1', 'h2', 'h3' }, root:child(0):type())
return string.format('%s%s', div and trim(text) or text, div and '' or '\n')
elseif node_name == 'line_li' then
local sib = root:prev_sibling()
@@ -520,12 +539,17 @@ local function visit_node(root, level, lang_tree, headings, opt, stats)
if ignored then
return text
end
- local s = ('%s<a href="%s#%s">%s</a>'):format(ws(), helppage, url_encode(tagname), html_esc(tagname))
+ local s = ('%s<a href="%s#%s">%s</a>'):format(
+ ws(),
+ helppage,
+ url_encode(tagname),
+ html_esc(tagname)
+ )
if opt.old and node_name == 'taglink' then
s = fix_tab_after_conceal(s, node_text(root:next_sibling()))
end
return s
- elseif vim.list_contains({'codespan', 'keycode'}, node_name) then
+ elseif vim.list_contains({ 'codespan', 'keycode' }, node_name) then
if root:has_error() then
return text
end
@@ -541,24 +565,28 @@ local function visit_node(root, level, lang_tree, headings, opt, stats)
elseif node_name == 'language' then
language = node_text(root)
return ''
- elseif node_name == 'code' then -- Highlighted codeblock (child).
+ elseif node_name == 'code' then -- Highlighted codeblock (child).
if is_blank(text) then
return ''
end
local code
if language then
- code = ('<pre><code class="language-%s">%s</code></pre>'):format(language,trim(trim_indent(text), 2))
+ code = ('<pre><code class="language-%s">%s</code></pre>'):format(
+ language,
+ trim(trim_indent(text), 2)
+ )
language = nil
else
code = ('<pre>%s</pre>'):format(trim(trim_indent(text), 2))
end
return code
- elseif node_name == 'tag' then -- anchor
+ elseif node_name == 'tag' then -- anchor
if root:has_error() then
return text
end
- local in_heading = vim.list_contains({'h1', 'h2', 'h3'}, parent)
- local cssclass = (not in_heading and get_indent(node_text()) > 8) and 'help-tag-right' or 'help-tag'
+ local in_heading = vim.list_contains({ 'h1', 'h2', 'h3' }, parent)
+ local cssclass = (not in_heading and get_indent(node_text()) > 8) and 'help-tag-right'
+ or 'help-tag'
local tagname = node_text(root:child(1), false)
if vim.tbl_count(stats.first_tags) < 2 then
-- Force the first 2 tags in the doc to be anchored at the main heading.
@@ -567,14 +595,29 @@ local function visit_node(root, level, lang_tree, headings, opt, stats)
end
local el = in_heading and 'span' or 'code'
local encoded_tagname = url_encode(tagname)
- local s = ('%s<%s id="%s" class="%s"><a href="#%s">%s</a></%s>'):format(ws(), el, encoded_tagname, cssclass, encoded_tagname, trimmed, el)
+ local s = ('%s<%s id="%s" class="%s"><a href="#%s">%s</a></%s>'):format(
+ ws(),
+ el,
+ encoded_tagname,
+ cssclass,
+ encoded_tagname,
+ trimmed,
+ el
+ )
if opt.old then
- s = fix_tab_after_conceal(s, node_text(root:next_sibling()))
+ s = fix_tab_after_conceal(s, node_text(root:next_sibling()))
end
if in_heading and prev ~= 'tag' then
-- Don't set "id", let the heading use the tag as its "id" (used by search engines).
- s = ('%s<%s class="%s"><a href="#%s">%s</a></%s>'):format(ws(), el, cssclass, encoded_tagname, trimmed, el)
+ s = ('%s<%s class="%s"><a href="#%s">%s</a></%s>'):format(
+ ws(),
+ el,
+ cssclass,
+ encoded_tagname,
+ trimmed,
+ el
+ )
-- Start the <span> container for tags in a heading.
-- This makes "justify-content:space-between" right-align the tags.
-- <h2>foo bar<span>tag1 tag2</span></h2>
@@ -593,11 +636,17 @@ local function visit_node(root, level, lang_tree, headings, opt, stats)
local sample_text = level > 0 and getbuflinestr(root, opt.buf, 3) or '[top level!]'
table.insert(stats.parse_errors, sample_text)
return ('<a class="parse-error" target="_blank" title="Report bug... (parse error)" href="%s">%s</a>'):format(
- get_bug_url_vimdoc(opt.fname, opt.to_fname, sample_text), trimmed)
- else -- Unknown token.
+ get_bug_url_vimdoc(opt.fname, opt.to_fname, sample_text),
+ trimmed
+ )
+ else -- Unknown token.
local sample_text = level > 0 and getbuflinestr(root, opt.buf, 3) or '[top level!]'
return ('<a class="unknown-token" target="_blank" title="Report bug... (unhandled token "%s")" href="%s">%s</a>'):format(
- node_name, get_bug_url_nvim(opt.fname, opt.to_fname, sample_text, node_name), trimmed), ('unknown-token:"%s"'):format(node_name)
+ node_name,
+ get_bug_url_nvim(opt.fname, opt.to_fname, sample_text, node_name),
+ trimmed
+ ),
+ ('unknown-token:"%s"'):format(node_name)
end
end
@@ -605,9 +654,11 @@ local function get_helpfiles(include)
local dir = './build/runtime/doc'
local rv = {}
for f, type in vim.fs.dir(dir) do
- if (vim.endswith(f, '.txt')
- and type == 'file'
- and (not include or vim.list_contains(include, f))) then
+ if
+ vim.endswith(f, '.txt')
+ and type == 'file'
+ and (not include or vim.list_contains(include, f))
+ then
local fullpath = vim.fn.fnamemodify(('%s/%s'):format(dir, f), ':p')
table.insert(rv, fullpath)
end
@@ -633,7 +684,7 @@ end
--- Use the vimdoc parser defined in the build, not whatever happens to be installed on the system.
local function ensure_runtimepath()
if not vim.o.runtimepath:find('build/lib/nvim/') then
- vim.cmd[[set runtimepath^=./build/lib/nvim/]]
+ vim.cmd [[set runtimepath^=./build/lib/nvim/]]
end
end
@@ -645,11 +696,11 @@ end
local function parse_buf(fname, parser_path)
local buf
if type(fname) == 'string' then
- vim.cmd('split '..vim.fn.fnameescape(fname)) -- Filename.
+ vim.cmd('split ' .. vim.fn.fnameescape(fname)) -- Filename.
buf = vim.api.nvim_get_current_buf()
else
buf = fname
- vim.cmd('sbuffer '..tostring(fname)) -- Buffer number.
+ vim.cmd('sbuffer ' .. tostring(fname)) -- Buffer number.
end
if parser_path then
vim.treesitter.language.add('vimdoc', { path = parser_path })
@@ -671,7 +722,7 @@ local function validate_one(fname, parser_path)
}
local lang_tree, buf = parse_buf(fname, parser_path)
for _, tree in ipairs(lang_tree:trees()) do
- visit_validate(tree:root(), 0, tree, { buf = buf, fname = fname, }, stats)
+ visit_validate(tree:root(), 0, tree, { buf = buf, fname = fname }, stats)
end
lang_tree:destroy()
vim.cmd.close()
@@ -690,10 +741,10 @@ local function gen_one(fname, to_fname, old, commit, parser_path)
local stats = {
noise_lines = {},
parse_errors = {},
- first_tags = {}, -- Track the first few tags in doc.
+ first_tags = {}, -- Track the first few tags in doc.
}
local lang_tree, buf = parse_buf(fname, parser_path)
- local headings = {} -- Headings (for ToC). 2-dimensional: h1 contains h2/h3.
+ local headings = {} -- Headings (for ToC). 2-dimensional: h1 contains h2/h3.
local title = to_titlecase(basename_noext(fname))
local html = ([[
@@ -777,9 +828,17 @@ local function gen_one(fname, to_fname, old, commit, parser_path)
local main = ''
for _, tree in ipairs(lang_tree:trees()) do
- main = main .. (visit_node(tree:root(), 0, tree, headings,
- { buf = buf, old = old, fname = fname, to_fname = to_fname, indent = 1, },
- stats))
+ main = main
+ .. (
+ visit_node(
+ tree:root(),
+ 0,
+ tree,
+ headings,
+ { buf = buf, old = old, fname = fname, to_fname = to_fname, indent = 1 },
+ stats
+ )
+ )
end
main = ([[
@@ -809,7 +868,14 @@ local function gen_one(fname, to_fname, old, commit, parser_path)
<hr/>
%s
</div>
- ]]):format(logo_svg, stats.first_tags[2] or '', stats.first_tags[1] or '', title, vim.fs.basename(fname), main)
+ ]]):format(
+ logo_svg,
+ stats.first_tags[2] or '',
+ stats.first_tags[1] or '',
+ title,
+ vim.fs.basename(fname),
+ main
+ )
local toc = [[
<div class="col-narrow toc">
@@ -819,13 +885,16 @@ local function gen_one(fname, to_fname, old, commit, parser_path)
<hr/>
]]
- local n = 0 -- Count of all headings + subheadings.
- for _, h1 in ipairs(headings) do n = n + 1 + #h1.subheadings end
+ local n = 0 -- Count of all headings + subheadings.
+ for _, h1 in ipairs(headings) do
+ n = n + 1 + #h1.subheadings
+ end
for _, h1 in ipairs(headings) do
toc = toc .. ('<div class="help-toc-h1"><a href="#%s">%s</a>\n'):format(h1.tag, h1.name)
- if n < 30 or #headings < 10 then -- Show subheadings only if there aren't too many.
+ if n < 30 or #headings < 10 then -- Show subheadings only if there aren't too many.
for _, h2 in ipairs(h1.subheadings) do
- toc = toc .. ('<div class="help-toc-h2"><a href="#%s">%s</a></div>\n'):format(h2.tag, h2.name)
+ toc = toc
+ .. ('<div class="help-toc-h2"><a href="#%s">%s</a></div>\n'):format(h2.tag, h2.name)
end
end
toc = toc .. '</div>'
@@ -859,11 +928,16 @@ local function gen_one(fname, to_fname, old, commit, parser_path)
</footer>
]]):format(
- os.date('%Y-%m-%d %H:%M'), commit, commit:sub(1, 7), #stats.parse_errors, bug_link,
- html_esc(table.concat(stats.noise_lines, '\n')), #stats.noise_lines)
+ os.date('%Y-%m-%d %H:%M'),
+ commit,
+ commit:sub(1, 7),
+ #stats.parse_errors,
+ bug_link,
+ html_esc(table.concat(stats.noise_lines, '\n')),
+ #stats.noise_lines
+ )
- html = ('%s%s%s</div>\n%s</body>\n</html>\n'):format(
- html, main, toc, footer)
+ html = ('%s%s%s</div>\n%s</body>\n</html>\n'):format(html, main, toc, footer)
vim.cmd('q!')
lang_tree:destroy()
return html, stats
@@ -1038,9 +1112,15 @@ function M._test()
helpfiles = get_helpfiles()
local function ok(cond, expected, actual)
- assert((not expected and not actual) or (expected and actual), 'if "expected" is given, "actual" is also required')
+ assert(
+ (not expected and not actual) or (expected and actual),
+ 'if "expected" is given, "actual" is also required'
+ )
if expected then
- return assert(cond, ('expected %s, got: %s'):format(vim.inspect(expected), vim.inspect(actual)))
+ return assert(
+ cond,
+ ('expected %s, got: %s'):format(vim.inspect(expected), vim.inspect(actual))
+ )
else
return assert(cond)
end
@@ -1050,7 +1130,11 @@ function M._test()
end
ok(vim.tbl_count(tagmap) > 3000, '>3000', vim.tbl_count(tagmap))
- ok(vim.endswith(tagmap['vim.diagnostic.set()'], 'diagnostic.txt'), tagmap['vim.diagnostic.set()'], 'diagnostic.txt')
+ ok(
+ vim.endswith(tagmap['vim.diagnostic.set()'], 'diagnostic.txt'),
+ tagmap['vim.diagnostic.set()'],
+ 'diagnostic.txt'
+ )
ok(vim.endswith(tagmap['%:s'], 'cmdline.txt'), tagmap['%:s'], 'cmdline.txt')
ok(is_noise([[vim:tw=78:isk=!-~,^*,^\|,^\":ts=8:noet:ft=help:norl:]]))
ok(is_noise([[ NVIM REFERENCE MANUAL by Thiago de Arruda ]]))
@@ -1060,7 +1144,10 @@ function M._test()
eq(1, get_indent(' a'))
eq(2, get_indent(' a\n b\n c\n'))
eq(5, get_indent(' a\n \n b\n c\n d\n e\n'))
- eq('a\n \n b\n c\n d\n e\n', trim_indent(' a\n \n b\n c\n d\n e\n'))
+ eq(
+ 'a\n \n b\n c\n d\n e\n',
+ trim_indent(' a\n \n b\n c\n d\n e\n')
+ )
local fixed_url, removed_chars = fix_url('https://example.com).')
eq('https://example.com', fixed_url)
@@ -1093,12 +1180,24 @@ end
---
--- @returns info dict
function M.gen(help_dir, to_dir, include, commit, parser_path)
- vim.validate{
- help_dir={help_dir, function(d) return vim.fn.isdirectory(vim.fn.expand(d)) == 1 end, 'valid directory'},
- to_dir={to_dir, 's'},
- include={include, 't', true},
- commit={commit, 's', true},
- parser_path={parser_path, function(f) return f == nil or vim.fn.filereadable(vim.fn.expand(f)) == 1 end, 'valid vimdoc.{so,dll} filepath'},
+ vim.validate {
+ help_dir = {
+ help_dir,
+ function(d)
+ return vim.fn.isdirectory(vim.fn.expand(d)) == 1
+ end,
+ 'valid directory',
+ },
+ to_dir = { to_dir, 's' },
+ include = { include, 't', true },
+ commit = { commit, 's', true },
+ parser_path = {
+ parser_path,
+ function(f)
+ return f == nil or vim.fn.filereadable(vim.fn.expand(f)) == 1
+ end,
+ 'valid vimdoc.{so,dll} filepath',
+ },
}
local err_count = 0
@@ -1117,7 +1216,13 @@ function M.gen(help_dir, to_dir, include, commit, parser_path)
local to_fname = ('%s/%s'):format(to_dir, get_helppage(helpfile))
local html, stats = gen_one(f, to_fname, not new_layout[helpfile], commit or '?', parser_path)
tofile(to_fname, html)
- print(('generated (%-4s errors): %-15s => %s'):format(#stats.parse_errors, helpfile, vim.fs.basename(to_fname)))
+ print(
+ ('generated (%-4s errors): %-15s => %s'):format(
+ #stats.parse_errors,
+ helpfile,
+ vim.fs.basename(to_fname)
+ )
+ )
err_count = err_count + #stats.parse_errors
end
print(('generated %d html pages'):format(#helpfiles))
@@ -1139,10 +1244,22 @@ end
--
-- @returns results dict
function M.validate(help_dir, include, parser_path)
- vim.validate{
- help_dir={help_dir, function(d) return vim.fn.isdirectory(vim.fn.expand(d)) == 1 end, 'valid directory'},
- include={include, 't', true},
- parser_path={parser_path, function(f) return f == nil or vim.fn.filereadable(vim.fn.expand(f)) == 1 end, 'valid vimdoc.{so,dll} filepath'},
+ vim.validate {
+ help_dir = {
+ help_dir,
+ function(d)
+ return vim.fn.isdirectory(vim.fn.expand(d)) == 1
+ end,
+ 'valid directory',
+ },
+ include = { include, 't', true },
+ parser_path = {
+ parser_path,
+ function(f)
+ return f == nil or vim.fn.filereadable(vim.fn.expand(f)) == 1
+ end,
+ 'valid vimdoc.{so,dll} filepath',
+ },
}
local err_count = 0
local files_to_errors = {}
@@ -1157,7 +1274,9 @@ function M.validate(help_dir, include, parser_path)
print(('validated (%-4s errors): %s'):format(#rv.parse_errors, helpfile))
if #rv.parse_errors > 0 then
files_to_errors[helpfile] = rv.parse_errors
- vim.print(('%s'):format(vim.iter(rv.parse_errors):fold('', function(s, v) return s..'\n '..v end)))
+ vim.print(('%s'):format(vim.iter(rv.parse_errors):fold('', function(s, v)
+ return s .. '\n ' .. v
+ end)))
end
err_count = err_count + #rv.parse_errors
end
diff --git a/scripts/lintcommit.lua b/scripts/lintcommit.lua
index a3ad4657e9..96f6304247 100644
--- a/scripts/lintcommit.lua
+++ b/scripts/lintcommit.lua
@@ -16,7 +16,7 @@ local _trace = false
-- Print message
local function p(s)
vim.cmd('set verbose=1')
- vim.api.nvim_echo({{s, ''}}, false, {})
+ vim.api.nvim_echo({ { s, '' } }, false, {})
vim.cmd('set verbose=0')
end
@@ -25,7 +25,7 @@ end
-- Prints `cmd` if `trace` is enabled.
local function run(cmd, or_die)
if _trace then
- p('run: '..vim.inspect(cmd))
+ p('run: ' .. vim.inspect(cmd))
end
local rv = vim.trim(vim.fn.system(cmd)) or ''
if vim.v.shell_error ~= 0 then
@@ -43,14 +43,14 @@ end
local function validate_commit(commit_message)
-- Return nil if the commit message starts with "fixup" as it signifies it's
-- a work in progress and shouldn't be linted yet.
- if vim.startswith(commit_message, "fixup") then
+ if vim.startswith(commit_message, 'fixup') then
return nil
end
- local commit_split = vim.split(commit_message, ":", {plain = true})
+ local commit_split = vim.split(commit_message, ':', { plain = true })
-- Return nil if the type is vim-patch since most of the normal rules don't
-- apply.
- if commit_split[1] == "vim-patch" then
+ if commit_split[1] == 'vim-patch' then
return nil
end
@@ -81,32 +81,34 @@ local function validate_commit(commit_message)
end
-- Check if commit introduces a breaking change.
- if vim.endswith(before_colon, "!") then
+ if vim.endswith(before_colon, '!') then
before_colon = before_colon:sub(1, -2)
end
-- Check if type is correct
- local type = vim.split(before_colon, "(", {plain = true})[1]
- local allowed_types = {'build', 'ci', 'docs', 'feat', 'fix', 'perf', 'refactor', 'revert', 'test', 'vim-patch'}
+ local type = vim.split(before_colon, '(', { plain = true })[1]
+ local allowed_types =
+ { 'build', 'ci', 'docs', 'feat', 'fix', 'perf', 'refactor', 'revert', 'test', 'vim-patch' }
if not vim.tbl_contains(allowed_types, type) then
return string.format(
[[Invalid commit type "%s". Allowed types are:
%s.
If none of these seem appropriate then use "fix"]],
type,
- vim.inspect(allowed_types))
+ vim.inspect(allowed_types)
+ )
end
-- Check if scope is appropriate
- if before_colon:match("%(") then
- local scope = vim.trim(commit_message:match("%((.-)%)"))
+ if before_colon:match('%(') then
+ local scope = vim.trim(commit_message:match('%((.-)%)'))
if scope == '' then
return [[Scope can't be empty]]
end
- if vim.startswith(scope, "nvim_") then
- return [[Scope should be "api" instead of "nvim_..."]]
+ if vim.startswith(scope, 'nvim_') then
+ return [[Scope should be "api" instead of "nvim_..."]]
end
local alternative_scope = {
@@ -123,17 +125,17 @@ local function validate_commit(commit_message)
end
-- Check that description doesn't end with a period
- if vim.endswith(after_colon, ".") then
+ if vim.endswith(after_colon, '.') then
return [[Description ends with a period (".").]]
end
-- Check that description starts with a whitespace.
- if after_colon:sub(1,1) ~= " " then
+ if after_colon:sub(1, 1) ~= ' ' then
return [[There should be a whitespace after the colon.]]
end
-- Check that description doesn't start with multiple whitespaces.
- if after_colon:sub(1,2) == " " then
+ if after_colon:sub(1, 2) == ' ' then
return [[There should only be one whitespace after the colon.]]
end
@@ -143,7 +145,7 @@ local function validate_commit(commit_message)
end
-- Check that description isn't just whitespaces
- if vim.trim(after_colon) == "" then
+ if vim.trim(after_colon) == '' then
return [[Description shouldn't be empty.]]
end
@@ -154,25 +156,25 @@ end
function M.main(opt)
_trace = not opt or not not opt.trace
- local branch = run({'git', 'rev-parse', '--abbrev-ref', 'HEAD'}, true)
+ local branch = run({ 'git', 'rev-parse', '--abbrev-ref', 'HEAD' }, true)
-- TODO(justinmk): check $GITHUB_REF
- local ancestor = run({'git', 'merge-base', 'origin/master', branch})
+ local ancestor = run({ 'git', 'merge-base', 'origin/master', branch })
if not ancestor then
- ancestor = run({'git', 'merge-base', 'upstream/master', branch})
+ ancestor = run({ 'git', 'merge-base', 'upstream/master', branch })
end
- local commits_str = run({'git', 'rev-list', ancestor..'..'..branch}, true)
+ local commits_str = run({ 'git', 'rev-list', ancestor .. '..' .. branch }, true)
assert(commits_str)
local commits = {} --- @type string[]
- for substring in commits_str:gmatch("%S+") do
- table.insert(commits, substring)
+ for substring in commits_str:gmatch('%S+') do
+ table.insert(commits, substring)
end
local failed = 0
for _, commit_id in ipairs(commits) do
- local msg = run({'git', 'show', '-s', '--format=%s' , commit_id})
+ local msg = run({ 'git', 'show', '-s', '--format=%s', commit_id })
if vim.v.shell_error ~= 0 then
- p('Invalid commit-id: '..commit_id..'"')
+ p('Invalid commit-id: ' .. commit_id .. '"')
else
local invalid_msg = validate_commit(msg)
if invalid_msg then
@@ -183,20 +185,22 @@ function M.main(opt)
p('\n')
end
- p(string.format([[
+ p(string.format(
+ [[
Invalid commit message: "%s"
Commit: %s
%s
]],
msg,
commit_id,
- invalid_msg))
+ invalid_msg
+ ))
end
end
end
if failed > 0 then
- p([[
+ p([[
See also:
https://github.com/neovim/neovim/blob/master/CONTRIBUTING.md#commit-messages
@@ -259,7 +263,7 @@ function M._test()
['feat(:grep/:make)'] = false,
['feat(:grep'] = false,
['feat(:grep/:make'] = false,
- ['ci: you\'re saying this commit message just goes on and on and on and on and on and on for way too long?'] = false,
+ ["ci: you're saying this commit message just goes on and on and on and on and on and on for way too long?"] = false,
}
local failed = 0
@@ -267,14 +271,15 @@ function M._test()
local is_valid = (nil == validate_commit(message))
if is_valid ~= expected then
failed = failed + 1
- p(string.format('[ FAIL ]: expected=%s, got=%s\n input: "%s"', expected, is_valid, message))
+ p(
+ string.format('[ FAIL ]: expected=%s, got=%s\n input: "%s"', expected, is_valid, message)
+ )
end
end
if failed > 0 then
os.exit(1)
end
-
end
--- @class LintcommitOptions
diff --git a/scripts/lua2dox.lua b/scripts/lua2dox.lua
index 1c8bc5a3cb..c4ad7fbb03 100644
--- a/scripts/lua2dox.lua
+++ b/scripts/lua2dox.lua
@@ -59,9 +59,12 @@ local TAGGED_TYPES = { 'TSNode', 'LanguageTree' }
-- Document these as 'table'
local ALIAS_TYPES = {
- 'Range', 'Range4', 'Range6', 'TSMetadata',
+ 'Range',
+ 'Range4',
+ 'Range6',
+ 'TSMetadata',
'vim.filetype.add.filetypes',
- 'vim.filetype.match.args'
+ 'vim.filetype.match.args',
}
local debug_outfile = nil --- @type string?
@@ -103,7 +106,7 @@ function StreamRead.new(filename)
-- syphon lines to our table
local filecontents = {} --- @type string[]
for line in io.lines(filename) do
- filecontents[#filecontents+1] = line
+ filecontents[#filecontents + 1] = line
end
return setmetatable({
@@ -176,9 +179,15 @@ local function process_magic(line, generics)
local magic_split = vim.split(magic, ' ', { plain = true })
local directive = magic_split[1]
- if vim.list_contains({
- 'cast', 'diagnostic', 'overload', 'meta', 'type'
- }, directive) then
+ if
+ vim.list_contains({
+ 'cast',
+ 'diagnostic',
+ 'overload',
+ 'meta',
+ 'type',
+ }, directive)
+ then
-- Ignore LSP directives
return '// gg:"' .. line .. '"'
end
@@ -202,8 +211,7 @@ local function process_magic(line, generics)
if directive == 'param' then
for _, type in ipairs(TYPES) do
magic = magic:gsub('^param%s+([a-zA-Z_?]+)%s+.*%((' .. type .. ')%)', 'param %1 %2')
- magic =
- magic:gsub('^param%s+([a-zA-Z_?]+)%s+.*%((' .. type .. '|nil)%)', 'param %1 %2')
+ magic = magic:gsub('^param%s+([a-zA-Z_?]+)%s+.*%((' .. type .. '|nil)%)', 'param %1 %2')
end
magic_split = vim.split(magic, ' ', { plain = true })
type_index = 3
@@ -225,7 +233,7 @@ local function process_magic(line, generics)
-- fix optional parameters
if magic_split[2]:find('%?$') then
if not ty:find('nil') then
- ty = ty .. '|nil'
+ ty = ty .. '|nil'
end
magic_split[2] = magic_split[2]:sub(1, -2)
end
@@ -240,18 +248,15 @@ local function process_magic(line, generics)
end
for _, type in ipairs(ALIAS_TYPES) do
- ty = ty:gsub('^'..type..'$', 'table') --- @type string
+ ty = ty:gsub('^' .. type .. '$', 'table') --- @type string
end
-- surround some types by ()
for _, type in ipairs(TYPES) do
- ty = ty
- :gsub('^(' .. type .. '|nil):?$', '(%1)')
- :gsub('^(' .. type .. '):?$', '(%1)')
+ ty = ty:gsub('^(' .. type .. '|nil):?$', '(%1)'):gsub('^(' .. type .. '):?$', '(%1)')
end
magic_split[type_index] = ty
-
end
magic = table.concat(magic_split, ' ')
@@ -281,7 +286,7 @@ local function process_block_comment(line, in_stream)
-- easier to program
in_stream:ungetLine(vim.trim(line:sub(closeSquare + 2)))
end
- comment_parts[#comment_parts+1] = thisComment
+ comment_parts[#comment_parts + 1] = thisComment
end
local comment = table.concat(comment_parts)
@@ -303,7 +308,7 @@ local function process_function_header(line)
if fn:sub(1, 1) == '(' then
-- it's an anonymous function
- return '// ZZ: '..line
+ return '// ZZ: ' .. line
end
-- fn has a name, so is interesting
@@ -330,10 +335,7 @@ local function process_function_header(line)
comma = ', '
end
- fn = fn:sub(1, paren_start)
- .. 'self'
- .. comma
- .. fn:sub(paren_start + 1)
+ fn = fn:sub(1, paren_start) .. 'self' .. comma .. fn:sub(paren_start + 1)
end
if line:match('local') then
@@ -357,7 +359,7 @@ local function process_line(line, in_stream, generics)
return process_magic(line:sub(4), generics)
end
- if vim.startswith(line, '--'..'[[') then -- it's a long comment
+ if vim.startswith(line, '--' .. '[[') then -- it's a long comment
return process_block_comment(line:sub(5), in_stream)
end
@@ -375,7 +377,7 @@ local function process_line(line, in_stream, generics)
local v = line_raw:match('^([A-Za-z][.a-zA-Z_]*)%s+%=')
if v and v:match('%.') then
-- Special: this lets gen_vimdoc.py handle tables.
- return 'table '..v..'() {}'
+ return 'table ' .. v .. '() {}'
end
end
@@ -418,7 +420,7 @@ local TApp = {
timestamp = os.date('%c %Z', os.time()),
name = 'Lua2DoX',
version = '0.2 20130128',
- copyright = 'Copyright (c) Simon Dales 2012-13'
+ copyright = 'Copyright (c) Simon Dales 2012-13',
}
setmetatable(TApp, { __index = TApp })
@@ -447,12 +449,15 @@ if arg[1] == '--help' then
elseif arg[1] == '--version' then
writeln(TApp:getVersion())
writeln(TApp.copyright)
-else -- It's a filter.
+else -- It's a filter.
local filename = arg[1]
if arg[2] == '--outdir' then
local outdir = arg[3]
- if type(outdir) ~= 'string' or (0 ~= vim.fn.filereadable(outdir) and 0 == vim.fn.isdirectory(outdir)) then
+ if
+ type(outdir) ~= 'string'
+ or (0 ~= vim.fn.filereadable(outdir) and 0 == vim.fn.isdirectory(outdir))
+ then
error(('invalid --outdir: "%s"'):format(tostring(outdir)))
end
vim.fn.mkdir(outdir, 'p')
diff --git a/scripts/vimpatch.lua b/scripts/vimpatch.lua
index 836f672f6e..cbec50fc17 100755
--- a/scripts/vimpatch.lua
+++ b/scripts/vimpatch.lua
@@ -10,13 +10,13 @@ local function systemlist(...)
local err = nvim.nvim_get_vvar('shell_error')
local args_str = nvim.nvim_call_function('string', ...)
if 0 ~= err then
- error('command failed: '..args_str)
+ error('command failed: ' .. args_str)
end
return rv
end
local function vimpatch_sh_list_numbers()
- return systemlist( { { 'bash', '-c', 'scripts/vim-patch.sh -M', } } )
+ return systemlist({ { 'bash', '-c', 'scripts/vim-patch.sh -M' } })
end
-- Generates the lines to be inserted into the src/version.c
@@ -55,9 +55,9 @@ local function patch_version_c()
nvim.nvim_command('silent normal! j0d/};\rk')
-- Insert the lines.
nvim.nvim_call_function('append', {
- nvim.nvim_eval('line(".")'),
- lines,
- })
+ nvim.nvim_eval('line(".")'),
+ lines,
+ })
nvim.nvim_command('silent write')
end
diff --git a/src/clint.py b/src/clint.py
index 596e2d8a26..ed5aaf43d2 100755
--- a/src/clint.py
+++ b/src/clint.py
@@ -900,16 +900,13 @@ def CheckIncludes(filename, lines, error):
# These should be synced with the ignored headers in the `iwyu` target in
# the Makefile.
check_includes_ignore = [
- "src/nvim/api/extmark.h",
"src/nvim/api/private/helpers.h",
"src/nvim/api/private/validate.h",
"src/nvim/assert_defs.h",
- "src/nvim/autocmd.h",
"src/nvim/buffer.h",
"src/nvim/buffer_defs.h",
"src/nvim/channel.h",
"src/nvim/charset.h",
- "src/nvim/decoration.h",
"src/nvim/drawline.h",
"src/nvim/eval.h",
"src/nvim/eval/encode.h",
@@ -927,7 +924,6 @@ def CheckIncludes(filename, lines, error):
"src/nvim/event/stream.h",
"src/nvim/event/time.h",
"src/nvim/event/wstream.h",
- "src/nvim/extmark.h",
"src/nvim/garray.h",
"src/nvim/globals.h",
"src/nvim/grid.h",
@@ -946,7 +942,6 @@ def CheckIncludes(filename, lines, error):
"src/nvim/os/pty_conpty_win.h",
"src/nvim/os/pty_process_unix.h",
"src/nvim/os/pty_process_win.h",
- "src/nvim/plines.h",
"src/nvim/tui/input.h",
"src/nvim/ui.h",
"src/nvim/viml/parser/expressions.h",
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt
index 6a01632040..0cdce539eb 100644
--- a/src/nvim/CMakeLists.txt
+++ b/src/nvim/CMakeLists.txt
@@ -879,12 +879,11 @@ add_glob_target(
FLAGS -c ${UNCRUSTIFY_CONFIG} -q --check
FILES ${LINT_NVIM_SOURCES})
-add_custom_target(formatc
- COMMAND ${CMAKE_COMMAND}
- -D FORMAT_PRG=${UNCRUSTIFY_PRG}
- -D LANG=c
- -P ${PROJECT_SOURCE_DIR}/cmake/Format.cmake
- WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
+add_glob_target(
+ TARGET formatc
+ COMMAND ${UNCRUSTIFY_PRG}
+ FLAGS -c ${UNCRUSTIFY_CONFIG} --replace --no-backup
+ FILES ${LINT_NVIM_SOURCES})
add_dependencies(lintc-uncrustify uncrustify_update_config)
add_dependencies(formatc uncrustify_update_config)
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c
index 9d0ac5d6ef..99d261e73d 100644
--- a/src/nvim/api/buffer.c
+++ b/src/nvim/api/buffer.c
@@ -12,6 +12,7 @@
#include "nvim/api/buffer.h"
#include "nvim/api/keysets_defs.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_defs.h"
@@ -152,7 +153,7 @@ Integer nvim_buf_line_count(Buffer buffer, Error *err)
/// @return False if attach failed (invalid parameter, or buffer isn't loaded);
/// otherwise True. TODO: LUA_API_NO_EVAL
Boolean nvim_buf_attach(uint64_t channel_id, Buffer buffer, Boolean send_buffer,
- DictionaryOf(LuaRef) opts, Error *err)
+ Dict(buf_attach) *opts, Error *err)
FUNC_API_SINCE(4)
{
buf_T *buf = find_buffer_by_handle(buffer, err);
@@ -161,64 +162,40 @@ Boolean nvim_buf_attach(uint64_t channel_id, Buffer buffer, Boolean send_buffer,
return false;
}
- bool is_lua = (channel_id == LUA_INTERNAL_CALL);
BufUpdateCallbacks cb = BUF_UPDATE_CALLBACKS_INIT;
- struct {
- const char *name;
- LuaRef *dest;
- } cbs[] = {
- { "on_lines", &cb.on_lines },
- { "on_bytes", &cb.on_bytes },
- { "on_changedtick", &cb.on_changedtick },
- { "on_detach", &cb.on_detach },
- { "on_reload", &cb.on_reload },
- { NULL, NULL },
- };
-
- for (size_t i = 0; i < opts.size; i++) {
- String k = opts.items[i].key;
- Object *v = &opts.items[i].value;
- bool key_used = false;
- if (is_lua) {
- for (size_t j = 0; cbs[j].name; j++) {
- if (strequal(cbs[j].name, k.data)) {
- VALIDATE_T(cbs[j].name, kObjectTypeLuaRef, v->type, {
- goto error;
- });
- *(cbs[j].dest) = v->data.luaref;
- v->data.luaref = LUA_NOREF;
- key_used = true;
- break;
- }
- }
- if (key_used) {
- continue;
- } else if (strequal("utf_sizes", k.data)) {
- VALIDATE_T("utf_sizes", kObjectTypeBoolean, v->type, {
- goto error;
- });
- cb.utf_sizes = v->data.boolean;
- key_used = true;
- } else if (strequal("preview", k.data)) {
- VALIDATE_T("preview", kObjectTypeBoolean, v->type, {
- goto error;
- });
- cb.preview = v->data.boolean;
- key_used = true;
- }
+ if (channel_id == LUA_INTERNAL_CALL) {
+ if (HAS_KEY(opts, buf_attach, on_lines)) {
+ cb.on_lines = opts->on_lines;
+ opts->on_lines = LUA_NOREF;
}
- VALIDATE_S(key_used, "'opts' key", k.data, {
- goto error;
- });
+ if (HAS_KEY(opts, buf_attach, on_bytes)) {
+ cb.on_bytes = opts->on_bytes;
+ opts->on_bytes = LUA_NOREF;
+ }
+
+ if (HAS_KEY(opts, buf_attach, on_changedtick)) {
+ cb.on_changedtick = opts->on_changedtick;
+ opts->on_changedtick = LUA_NOREF;
+ }
+
+ if (HAS_KEY(opts, buf_attach, on_detach)) {
+ cb.on_detach = opts->on_detach;
+ opts->on_detach = LUA_NOREF;
+ }
+
+ if (HAS_KEY(opts, buf_attach, on_reload)) {
+ cb.on_reload = opts->on_reload;
+ opts->on_reload = LUA_NOREF;
+ }
+
+ cb.utf_sizes = opts->utf_sizes;
+
+ cb.preview = opts->preview;
}
return buf_updates_register(buf, channel_id, cb, send_buffer);
-
-error:
- buffer_update_callbacks_free(cb);
- return false;
}
/// Deactivates buffer-update events on the channel.
@@ -781,16 +758,12 @@ early_end:
ArrayOf(String) nvim_buf_get_text(uint64_t channel_id, Buffer buffer,
Integer start_row, Integer start_col,
Integer end_row, Integer end_col,
- Dictionary opts, lua_State *lstate,
+ Dict(empty) *opts, lua_State *lstate,
Error *err)
FUNC_API_SINCE(9)
{
Array rv = ARRAY_DICT_INIT;
- VALIDATE((opts.size == 0), "%s", "opts dict isn't empty", {
- return rv;
- });
-
buf_T *buf = find_buffer_by_handle(buffer, err);
if (!buf) {
@@ -1081,7 +1054,7 @@ Boolean nvim_buf_is_loaded(Buffer buffer)
/// @param opts Optional parameters. Keys:
/// - force: Force deletion and ignore unsaved changes.
/// - unload: Unloaded only, do not delete. See |:bunload|
-void nvim_buf_delete(Buffer buffer, Dictionary opts, Error *err)
+void nvim_buf_delete(Buffer buffer, Dict(buf_delete) *opts, Error *err)
FUNC_API_SINCE(7)
FUNC_API_TEXTLOCK
{
@@ -1091,25 +1064,9 @@ void nvim_buf_delete(Buffer buffer, Dictionary opts, Error *err)
return;
}
- bool force = false;
- bool unload = false;
- for (size_t i = 0; i < opts.size; i++) {
- String k = opts.items[i].key;
- Object v = opts.items[i].value;
- if (strequal("force", k.data)) {
- force = api_object_to_bool(v, "force", false, err);
- } else if (strequal("unload", k.data)) {
- unload = api_object_to_bool(v, "unload", false, err);
- } else {
- VALIDATE_S(false, "'opts' key", k.data, {
- return;
- });
- }
- }
+ bool force = opts->force;
- if (ERROR_SET(err)) {
- return;
- }
+ bool unload = opts->unload;
int result = do_buffer(unload ? DOBUF_UNLOAD : DOBUF_WIPE,
DOBUF_FIRST,
@@ -1193,7 +1150,7 @@ Boolean nvim_buf_del_mark(Buffer buffer, String name, Error *err)
/// @return true if the mark was set, else false.
/// @see |nvim_buf_del_mark()|
/// @see |nvim_buf_get_mark()|
-Boolean nvim_buf_set_mark(Buffer buffer, String name, Integer line, Integer col, Dictionary opts,
+Boolean nvim_buf_set_mark(Buffer buffer, String name, Integer line, Integer col, Dict(empty) *opts,
Error *err)
FUNC_API_SINCE(8)
{
diff --git a/src/nvim/api/command.c b/src/nvim/api/command.c
index 7116f4bce0..abb589ecdf 100644
--- a/src/nvim/api/command.c
+++ b/src/nvim/api/command.c
@@ -94,15 +94,11 @@
/// - "belowright": |:belowright|.
/// - "topleft": |:topleft|.
/// - "botright": |:botright|.
-Dictionary nvim_parse_cmd(String str, Dictionary opts, Error *err)
+Dictionary nvim_parse_cmd(String str, Dict(empty) *opts, Error *err)
FUNC_API_SINCE(10) FUNC_API_FAST
{
Dictionary result = ARRAY_DICT_INIT;
- VALIDATE((opts.size == 0), "%s", "opts dict isn't empty", {
- return result;
- });
-
// Parse command line
exarg_T ea;
CmdParseInfo cmdinfo;
diff --git a/src/nvim/api/deprecated.c b/src/nvim/api/deprecated.c
index 11795033cc..d6a76617a7 100644
--- a/src/nvim/api/deprecated.c
+++ b/src/nvim/api/deprecated.c
@@ -126,7 +126,7 @@ void nvim_buf_clear_highlight(Buffer buffer, Integer ns_id, Integer line_start,
/// @param[out] err Error details, if any
/// @return The ns_id that was used
Integer nvim_buf_set_virtual_text(Buffer buffer, Integer src_id, Integer line, Array chunks,
- Dictionary opts, Error *err)
+ Dict(empty) *opts, Error *err)
FUNC_API_SINCE(5)
FUNC_API_DEPRECATED_SINCE(8)
{
@@ -140,11 +140,6 @@ Integer nvim_buf_set_virtual_text(Buffer buffer, Integer src_id, Integer line, A
return 0;
}
- if (opts.size > 0) {
- api_set_error(err, kErrorTypeValidation, "opts dict isn't empty");
- return 0;
- }
-
uint32_t ns_id = src2ns(&src_id);
int width;
diff --git a/src/nvim/api/deprecated.h b/src/nvim/api/deprecated.h
index e20d8304e0..c879794bb3 100644
--- a/src/nvim/api/deprecated.h
+++ b/src/nvim/api/deprecated.h
@@ -2,6 +2,7 @@
#include <stdint.h> // IWYU pragma: keep
+#include "nvim/api/keysets_defs.h" // IWYU pragma: keep
#include "nvim/api/private/defs.h" // IWYU pragma: keep
#ifdef INCLUDE_GENERATED_DECLARATIONS
diff --git a/src/nvim/api/dispatch_deprecated.lua b/src/nvim/api/dispatch_deprecated.lua
index 5650a77ac0..7a92789f79 100644
--- a/src/nvim/api/dispatch_deprecated.lua
+++ b/src/nvim/api/dispatch_deprecated.lua
@@ -1,69 +1,69 @@
local deprecated_aliases = {
- nvim_buf_add_highlight="buffer_add_highlight",
- nvim_buf_clear_highlight="buffer_clear_highlight",
- nvim_buf_get_lines="buffer_get_lines",
- nvim_buf_get_mark="buffer_get_mark",
- nvim_buf_get_name="buffer_get_name",
- nvim_buf_get_number="buffer_get_number",
- nvim_buf_get_option="buffer_get_option",
- nvim_buf_get_var="buffer_get_var",
- nvim_buf_is_valid="buffer_is_valid",
- nvim_buf_line_count="buffer_line_count",
- nvim_buf_set_lines="buffer_set_lines",
- nvim_buf_set_name="buffer_set_name",
- nvim_buf_set_option="buffer_set_option",
- nvim_call_function="vim_call_function",
- nvim_command="vim_command",
- nvim_command_output="vim_command_output",
- nvim_del_current_line="vim_del_current_line",
- nvim_err_write="vim_err_write",
- nvim_err_writeln="vim_report_error",
- nvim_eval="vim_eval",
- nvim_feedkeys="vim_feedkeys",
- nvim_get_api_info="vim_get_api_info",
- nvim_get_color_by_name="vim_name_to_color",
- nvim_get_color_map="vim_get_color_map",
- nvim_get_current_buf="vim_get_current_buffer",
- nvim_get_current_line="vim_get_current_line",
- nvim_get_current_tabpage="vim_get_current_tabpage",
- nvim_get_current_win="vim_get_current_window",
- nvim_get_option="vim_get_option",
- nvim_get_var="vim_get_var",
- nvim_get_vvar="vim_get_vvar",
- nvim_input="vim_input",
- nvim_list_bufs="vim_get_buffers",
- nvim_list_runtime_paths="vim_list_runtime_paths",
- nvim_list_tabpages="vim_get_tabpages",
- nvim_list_wins="vim_get_windows",
- nvim_out_write="vim_out_write",
- nvim_replace_termcodes="vim_replace_termcodes",
- nvim_set_current_buf="vim_set_current_buffer",
- nvim_set_current_dir="vim_change_directory",
- nvim_set_current_line="vim_set_current_line",
- nvim_set_current_tabpage="vim_set_current_tabpage",
- nvim_set_current_win="vim_set_current_window",
- nvim_set_option="vim_set_option",
- nvim_strwidth="vim_strwidth",
- nvim_subscribe="vim_subscribe",
- nvim_tabpage_get_var="tabpage_get_var",
- nvim_tabpage_get_win="tabpage_get_window",
- nvim_tabpage_is_valid="tabpage_is_valid",
- nvim_tabpage_list_wins="tabpage_get_windows",
- nvim_ui_detach="ui_detach",
- nvim_ui_try_resize="ui_try_resize",
- nvim_unsubscribe="vim_unsubscribe",
- nvim_win_get_buf="window_get_buffer",
- nvim_win_get_cursor="window_get_cursor",
- nvim_win_get_height="window_get_height",
- nvim_win_get_option="window_get_option",
- nvim_win_get_position="window_get_position",
- nvim_win_get_tabpage="window_get_tabpage",
- nvim_win_get_var="window_get_var",
- nvim_win_get_width="window_get_width",
- nvim_win_is_valid="window_is_valid",
- nvim_win_set_cursor="window_set_cursor",
- nvim_win_set_height="window_set_height",
- nvim_win_set_option="window_set_option",
- nvim_win_set_width="window_set_width",
+ nvim_buf_add_highlight = 'buffer_add_highlight',
+ nvim_buf_clear_highlight = 'buffer_clear_highlight',
+ nvim_buf_get_lines = 'buffer_get_lines',
+ nvim_buf_get_mark = 'buffer_get_mark',
+ nvim_buf_get_name = 'buffer_get_name',
+ nvim_buf_get_number = 'buffer_get_number',
+ nvim_buf_get_option = 'buffer_get_option',
+ nvim_buf_get_var = 'buffer_get_var',
+ nvim_buf_is_valid = 'buffer_is_valid',
+ nvim_buf_line_count = 'buffer_line_count',
+ nvim_buf_set_lines = 'buffer_set_lines',
+ nvim_buf_set_name = 'buffer_set_name',
+ nvim_buf_set_option = 'buffer_set_option',
+ nvim_call_function = 'vim_call_function',
+ nvim_command = 'vim_command',
+ nvim_command_output = 'vim_command_output',
+ nvim_del_current_line = 'vim_del_current_line',
+ nvim_err_write = 'vim_err_write',
+ nvim_err_writeln = 'vim_report_error',
+ nvim_eval = 'vim_eval',
+ nvim_feedkeys = 'vim_feedkeys',
+ nvim_get_api_info = 'vim_get_api_info',
+ nvim_get_color_by_name = 'vim_name_to_color',
+ nvim_get_color_map = 'vim_get_color_map',
+ nvim_get_current_buf = 'vim_get_current_buffer',
+ nvim_get_current_line = 'vim_get_current_line',
+ nvim_get_current_tabpage = 'vim_get_current_tabpage',
+ nvim_get_current_win = 'vim_get_current_window',
+ nvim_get_option = 'vim_get_option',
+ nvim_get_var = 'vim_get_var',
+ nvim_get_vvar = 'vim_get_vvar',
+ nvim_input = 'vim_input',
+ nvim_list_bufs = 'vim_get_buffers',
+ nvim_list_runtime_paths = 'vim_list_runtime_paths',
+ nvim_list_tabpages = 'vim_get_tabpages',
+ nvim_list_wins = 'vim_get_windows',
+ nvim_out_write = 'vim_out_write',
+ nvim_replace_termcodes = 'vim_replace_termcodes',
+ nvim_set_current_buf = 'vim_set_current_buffer',
+ nvim_set_current_dir = 'vim_change_directory',
+ nvim_set_current_line = 'vim_set_current_line',
+ nvim_set_current_tabpage = 'vim_set_current_tabpage',
+ nvim_set_current_win = 'vim_set_current_window',
+ nvim_set_option = 'vim_set_option',
+ nvim_strwidth = 'vim_strwidth',
+ nvim_subscribe = 'vim_subscribe',
+ nvim_tabpage_get_var = 'tabpage_get_var',
+ nvim_tabpage_get_win = 'tabpage_get_window',
+ nvim_tabpage_is_valid = 'tabpage_is_valid',
+ nvim_tabpage_list_wins = 'tabpage_get_windows',
+ nvim_ui_detach = 'ui_detach',
+ nvim_ui_try_resize = 'ui_try_resize',
+ nvim_unsubscribe = 'vim_unsubscribe',
+ nvim_win_get_buf = 'window_get_buffer',
+ nvim_win_get_cursor = 'window_get_cursor',
+ nvim_win_get_height = 'window_get_height',
+ nvim_win_get_option = 'window_get_option',
+ nvim_win_get_position = 'window_get_position',
+ nvim_win_get_tabpage = 'window_get_tabpage',
+ nvim_win_get_var = 'window_get_var',
+ nvim_win_get_width = 'window_get_width',
+ nvim_win_is_valid = 'window_is_valid',
+ nvim_win_set_cursor = 'window_set_cursor',
+ nvim_win_set_height = 'window_set_height',
+ nvim_win_set_option = 'window_set_option',
+ nvim_win_set_width = 'window_set_width',
}
return deprecated_aliases
diff --git a/src/nvim/api/extmark.c b/src/nvim/api/extmark.c
index 80b1546329..ec47d7227e 100644
--- a/src/nvim/api/extmark.c
+++ b/src/nvim/api/extmark.c
@@ -187,7 +187,7 @@ static Array extmark_to_array(MTPair extmark, bool id, bool add_dict, bool hl_na
/// @return 0-indexed (row, col) tuple or empty list () if extmark id was
/// absent
ArrayOf(Integer) nvim_buf_get_extmark_by_id(Buffer buffer, Integer ns_id,
- Integer id, Dictionary opts,
+ Integer id, Dict(get_extmark) *opts,
Error *err)
FUNC_API_SINCE(7)
{
@@ -203,27 +203,9 @@ ArrayOf(Integer) nvim_buf_get_extmark_by_id(Buffer buffer, Integer ns_id,
return rv;
});
- bool details = false;
- bool hl_name = true;
- for (size_t i = 0; i < opts.size; i++) {
- String k = opts.items[i].key;
- Object *v = &opts.items[i].value;
- if (strequal("details", k.data)) {
- details = api_object_to_bool(*v, "details", false, err);
- if (ERROR_SET(err)) {
- return rv;
- }
- } else if (strequal("hl_name", k.data)) {
- hl_name = api_object_to_bool(*v, "hl_name", false, err);
- if (ERROR_SET(err)) {
- return rv;
- }
- } else {
- VALIDATE_S(false, "'opts' key", k.data, {
- return rv;
- });
- }
- }
+ bool details = opts->details;
+
+ bool hl_name = GET_BOOL_OR_TRUE(opts, get_extmark, hl_name);
MTPair extmark = extmark_from_id(buf, (uint32_t)ns_id, (uint32_t)id);
if (extmark.start.pos.row < 0) {
diff --git a/src/nvim/api/keysets_defs.h b/src/nvim/api/keysets_defs.h
index e59eda5686..d1cbe43de0 100644
--- a/src/nvim/api/keysets_defs.h
+++ b/src/nvim/api/keysets_defs.h
@@ -3,6 +3,10 @@
#include "nvim/api/private/defs.h"
typedef struct {
+ OptionalKeys is_set__empty_;
+} Dict(empty);
+
+typedef struct {
OptionalKeys is_set__context_;
Array types;
} Dict(context);
@@ -52,6 +56,12 @@ typedef struct {
} Dict(set_extmark);
typedef struct {
+ OptionalKeys is_set__get_extmark_;
+ Boolean details;
+ Boolean hl_name;
+} Dict(get_extmark);
+
+typedef struct {
OptionalKeys is_set__get_extmarks_;
Integer limit;
Boolean details;
@@ -313,3 +323,25 @@ typedef struct {
typedef struct {
Boolean output;
} Dict(exec_opts);
+
+typedef struct {
+ OptionalKeys is_set__buf_attach_;
+ LuaRef on_lines;
+ LuaRef on_bytes;
+ LuaRef on_changedtick;
+ LuaRef on_detach;
+ LuaRef on_reload;
+ Boolean utf_sizes;
+ Boolean preview;
+} Dict(buf_attach);
+
+typedef struct {
+ OptionalKeys is_set__buf_delete_;
+ Boolean force;
+ Boolean unload;
+} Dict(buf_delete);
+
+typedef struct {
+ OptionalKeys is_set__open_term_;
+ LuaRef on_input;
+} Dict(open_term);
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index 270f2e4432..0842469c59 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -987,7 +987,7 @@ fail:
/// ["input", term, bufnr, data]
/// @param[out] err Error details, if any
/// @return Channel id, or 0 on error
-Integer nvim_open_term(Buffer buffer, DictionaryOf(LuaRef) opts, Error *err)
+Integer nvim_open_term(Buffer buffer, Dict(open_term) *opts, Error *err)
FUNC_API_SINCE(7)
FUNC_API_TEXTLOCK_ALLOW_CMDWIN
{
@@ -1002,33 +1002,25 @@ Integer nvim_open_term(Buffer buffer, DictionaryOf(LuaRef) opts, Error *err)
}
LuaRef cb = LUA_NOREF;
- for (size_t i = 0; i < opts.size; i++) {
- String k = opts.items[i].key;
- Object *v = &opts.items[i].value;
- if (strequal("on_input", k.data)) {
- VALIDATE_T("on_input", kObjectTypeLuaRef, v->type, {
- return 0;
- });
- cb = v->data.luaref;
- v->data.luaref = LUA_NOREF;
- break;
- } else {
- VALIDATE_S(false, "'opts' key", k.data, {});
- }
+
+ if (HAS_KEY(opts, open_term, on_input)) {
+ cb = opts->on_input;
+ opts->on_input = LUA_NOREF;
}
- TerminalOptions topts;
Channel *chan = channel_alloc(kChannelStreamInternal);
chan->stream.internal.cb = cb;
chan->stream.internal.closed = false;
- topts.data = chan;
- // NB: overridden in terminal_check_size if a window is already
- // displaying the buffer
- topts.width = (uint16_t)MAX(curwin->w_width_inner - win_col_off(curwin), 0);
- topts.height = (uint16_t)curwin->w_height_inner;
- topts.write_cb = term_write;
- topts.resize_cb = term_resize;
- topts.close_cb = term_close;
+ TerminalOptions topts = {
+ .data = chan,
+ // NB: overridden in terminal_check_size if a window is already
+ // displaying the buffer
+ .width = (uint16_t)MAX(curwin->w_width_inner - win_col_off(curwin), 0),
+ .height = (uint16_t)curwin->w_height_inner,
+ .write_cb = term_write,
+ .resize_cb = term_resize,
+ .close_cb = term_close,
+ };
channel_incref(chan);
terminal_open(&chan->term, buf, topts);
if (chan->term != NULL) {
@@ -1038,7 +1030,7 @@ Integer nvim_open_term(Buffer buffer, DictionaryOf(LuaRef) opts, Error *err)
return (Integer)chan->id;
}
-static void term_write(char *buf, size_t size, void *data) // NOLINT(readability-non-const-parameter)
+static void term_write(const char *buf, size_t size, void *data)
{
Channel *chan = data;
LuaRef cb = chan->stream.internal.cb;
@@ -1048,7 +1040,7 @@ static void term_write(char *buf, size_t size, void *data) // NOLINT(readabilit
MAXSIZE_TEMP_ARRAY(args, 3);
ADD_C(args, INTEGER_OBJ((Integer)chan->id));
ADD_C(args, BUFFER_OBJ(terminal_buf(chan->term)));
- ADD_C(args, STRING_OBJ(((String){ .data = buf, .size = size })));
+ ADD_C(args, STRING_OBJ(((String){ .data = (char *)buf, .size = size })));
textlock++;
nlua_call_ref(cb, "input", args, false, NULL);
textlock--;
@@ -1940,14 +1932,10 @@ Object nvim_get_proc(Integer pid, Error *err)
/// @param finish Finish the completion and dismiss the popup menu. Implies {insert}.
/// @param opts Optional parameters. Reserved for future use.
/// @param[out] err Error details, if any
-void nvim_select_popupmenu_item(Integer item, Boolean insert, Boolean finish, Dictionary opts,
+void nvim_select_popupmenu_item(Integer item, Boolean insert, Boolean finish, Dict(empty) *opts,
Error *err)
FUNC_API_SINCE(6)
{
- VALIDATE((opts.size == 0), "%s", "opts dict isn't empty", {
- return;
- });
-
if (finish) {
insert = true;
}
@@ -2048,7 +2036,7 @@ Boolean nvim_del_mark(String name, Error *err)
/// not set.
/// @see |nvim_buf_set_mark()|
/// @see |nvim_del_mark()|
-Array nvim_get_mark(String name, Dictionary opts, Error *err)
+Array nvim_get_mark(String name, Dict(empty) *opts, Error *err)
FUNC_API_SINCE(8)
{
Array rv = ARRAY_DICT_INIT;
diff --git a/src/nvim/auevents.lua b/src/nvim/auevents.lua
index 696df7c534..11d1597236 100644
--- a/src/nvim/auevents.lua
+++ b/src/nvim/auevents.lua
@@ -1,172 +1,172 @@
return {
events = {
- 'BufAdd', -- after adding a buffer to the buffer list
- 'BufDelete', -- deleting a buffer from the buffer list
- 'BufEnter', -- after entering a buffer
- 'BufFilePost', -- after renaming a buffer
- 'BufFilePre', -- before renaming a buffer
- 'BufHidden', -- just after buffer becomes hidden
- 'BufLeave', -- before leaving a buffer
- 'BufModifiedSet', -- after the 'modified' state of a buffer changes
- 'BufNew', -- after creating any buffer
- 'BufNewFile', -- when creating a buffer for a new file
- 'BufReadCmd', -- read buffer using command
- 'BufReadPost', -- after reading a buffer
- 'BufReadPre', -- before reading a buffer
- 'BufUnload', -- just before unloading a buffer
- 'BufWinEnter', -- after showing a buffer in a window
- 'BufWinLeave', -- just after buffer removed from window
- 'BufWipeout', -- just before really deleting a buffer
- 'BufWriteCmd', -- write buffer using command
- 'BufWritePost', -- after writing a buffer
- 'BufWritePre', -- before writing a buffer
- 'ChanInfo', -- info was received about channel
- 'ChanOpen', -- channel was opened
- 'CmdUndefined', -- command undefined
- 'CmdWinEnter', -- after entering the cmdline window
- 'CmdWinLeave', -- before leaving the cmdline window
- 'CmdlineChanged', -- command line was modified
- 'CmdlineEnter', -- after entering cmdline mode
- 'CmdlineLeave', -- before leaving cmdline mode
- 'ColorScheme', -- after loading a colorscheme
- 'ColorSchemePre', -- before loading a colorscheme
- 'CompleteChanged', -- after popup menu changed
- 'CompleteDone', -- after finishing insert complete
- 'CompleteDonePre', -- idem, before clearing info
- 'CursorHold', -- cursor in same position for a while
- 'CursorHoldI', -- idem, in Insert mode
- 'CursorMoved', -- cursor was moved
- 'CursorMovedI', -- cursor was moved in Insert mode
- 'DiagnosticChanged', -- diagnostics in a buffer were modified
- 'DiffUpdated', -- diffs have been updated
- 'DirChanged', -- directory changed
- 'DirChangedPre', -- directory is going to change
- 'EncodingChanged', -- after changing the 'encoding' option
- 'ExitPre', -- before exiting
- 'FileAppendCmd', -- append to a file using command
- 'FileAppendPost', -- after appending to a file
- 'FileAppendPre', -- before appending to a file
- 'FileChangedRO', -- before first change to read-only file
- 'FileChangedShell', -- after shell command that changed file
- 'FileChangedShellPost', -- after (not) reloading changed file
- 'FileReadCmd', -- read from a file using command
- 'FileReadPost', -- after reading a file
- 'FileReadPre', -- before reading a file
- 'FileType', -- new file type detected (user defined)
- 'FileWriteCmd', -- write to a file using command
- 'FileWritePost', -- after writing a file
- 'FileWritePre', -- before writing a file
- 'FilterReadPost', -- after reading from a filter
- 'FilterReadPre', -- before reading from a filter
- 'FilterWritePost', -- after writing to a filter
- 'FilterWritePre', -- before writing to a filter
- 'FocusGained', -- got the focus
- 'FocusLost', -- lost the focus to another app
- 'FuncUndefined', -- if calling a function which doesn't exist
- 'GUIEnter', -- after starting the GUI
- 'GUIFailed', -- after starting the GUI failed
- 'InsertChange', -- when changing Insert/Replace mode
- 'InsertCharPre', -- before inserting a char
- 'InsertEnter', -- when entering Insert mode
- 'InsertLeave', -- just after leaving Insert mode
- 'InsertLeavePre', -- just before leaving Insert mode
- 'LspAttach', -- after an LSP client attaches to a buffer
- 'LspDetach', -- after an LSP client detaches from a buffer
- 'LspRequest', -- after an LSP request is started, canceled, or completed
- 'LspNotify', -- after an LSP notice has been sent to the server
- 'LspTokenUpdate', -- after a visible LSP token is updated
- 'LspProgress', -- after a LSP progress update
- 'MenuPopup', -- just before popup menu is displayed
- 'ModeChanged', -- after changing the mode
- 'OptionSet', -- after setting any option
- 'QuickFixCmdPost', -- after :make, :grep etc.
- 'QuickFixCmdPre', -- before :make, :grep etc.
- 'QuitPre', -- before :quit
- 'RecordingEnter', -- when starting to record a macro
- 'RecordingLeave', -- just before a macro stops recording
- 'RemoteReply', -- upon string reception from a remote vim
- 'SafeState', -- going to wait for a character
- 'SearchWrapped', -- after the search wrapped around
- 'SessionLoadPost', -- after loading a session file
- 'ShellCmdPost', -- after ":!cmd"
- 'ShellFilterPost', -- after ":1,2!cmd", ":w !cmd", ":r !cmd".
- 'Signal', -- after nvim process received a signal
- 'SourceCmd', -- sourcing a Vim script using command
- 'SourcePost', -- after sourcing a Vim script
- 'SourcePre', -- before sourcing a Vim script
- 'SpellFileMissing', -- spell file missing
- 'StdinReadPost', -- after reading from stdin
- 'StdinReadPre', -- before reading from stdin
- 'SwapExists', -- found existing swap file
- 'Syntax', -- syntax selected
- 'TabClosed', -- a tab has closed
- 'TabEnter', -- after entering a tab page
- 'TabLeave', -- before leaving a tab page
- 'TabNew', -- when creating a new tab
- 'TabNewEntered', -- after entering a new tab
- 'TermChanged', -- after changing 'term'
- 'TermClose', -- after the process exits
- 'TermEnter', -- after entering Terminal mode
- 'TermLeave', -- after leaving Terminal mode
- 'TermOpen', -- after opening a terminal buffer
- 'TermResponse', -- after setting "v:termresponse"
- 'TextChanged', -- text was modified
- 'TextChangedI', -- text was modified in Insert mode(no popup)
- 'TextChangedP', -- text was modified in Insert mode(popup)
- 'TextChangedT', -- text was modified in Terminal mode
- 'TextYankPost', -- after a yank or delete was done (y, d, c)
- 'UIEnter', -- after UI attaches
- 'UILeave', -- after UI detaches
- 'User', -- user defined autocommand
- 'VimEnter', -- after starting Vim
- 'VimLeave', -- before exiting Vim
- 'VimLeavePre', -- before exiting Vim and writing ShaDa file
- 'VimResized', -- after Vim window was resized
- 'VimResume', -- after Nvim is resumed
- 'VimSuspend', -- before Nvim is suspended
- 'WinClosed', -- after closing a window
- 'WinEnter', -- after entering a window
- 'WinLeave', -- before leaving a window
- 'WinNew', -- when entering a new window
- 'WinResized', -- after a window was resized
- 'WinScrolled', -- after a window was scrolled or resized
+ 'BufAdd', -- after adding a buffer to the buffer list
+ 'BufDelete', -- deleting a buffer from the buffer list
+ 'BufEnter', -- after entering a buffer
+ 'BufFilePost', -- after renaming a buffer
+ 'BufFilePre', -- before renaming a buffer
+ 'BufHidden', -- just after buffer becomes hidden
+ 'BufLeave', -- before leaving a buffer
+ 'BufModifiedSet', -- after the 'modified' state of a buffer changes
+ 'BufNew', -- after creating any buffer
+ 'BufNewFile', -- when creating a buffer for a new file
+ 'BufReadCmd', -- read buffer using command
+ 'BufReadPost', -- after reading a buffer
+ 'BufReadPre', -- before reading a buffer
+ 'BufUnload', -- just before unloading a buffer
+ 'BufWinEnter', -- after showing a buffer in a window
+ 'BufWinLeave', -- just after buffer removed from window
+ 'BufWipeout', -- just before really deleting a buffer
+ 'BufWriteCmd', -- write buffer using command
+ 'BufWritePost', -- after writing a buffer
+ 'BufWritePre', -- before writing a buffer
+ 'ChanInfo', -- info was received about channel
+ 'ChanOpen', -- channel was opened
+ 'CmdUndefined', -- command undefined
+ 'CmdWinEnter', -- after entering the cmdline window
+ 'CmdWinLeave', -- before leaving the cmdline window
+ 'CmdlineChanged', -- command line was modified
+ 'CmdlineEnter', -- after entering cmdline mode
+ 'CmdlineLeave', -- before leaving cmdline mode
+ 'ColorScheme', -- after loading a colorscheme
+ 'ColorSchemePre', -- before loading a colorscheme
+ 'CompleteChanged', -- after popup menu changed
+ 'CompleteDone', -- after finishing insert complete
+ 'CompleteDonePre', -- idem, before clearing info
+ 'CursorHold', -- cursor in same position for a while
+ 'CursorHoldI', -- idem, in Insert mode
+ 'CursorMoved', -- cursor was moved
+ 'CursorMovedI', -- cursor was moved in Insert mode
+ 'DiagnosticChanged', -- diagnostics in a buffer were modified
+ 'DiffUpdated', -- diffs have been updated
+ 'DirChanged', -- directory changed
+ 'DirChangedPre', -- directory is going to change
+ 'EncodingChanged', -- after changing the 'encoding' option
+ 'ExitPre', -- before exiting
+ 'FileAppendCmd', -- append to a file using command
+ 'FileAppendPost', -- after appending to a file
+ 'FileAppendPre', -- before appending to a file
+ 'FileChangedRO', -- before first change to read-only file
+ 'FileChangedShell', -- after shell command that changed file
+ 'FileChangedShellPost', -- after (not) reloading changed file
+ 'FileReadCmd', -- read from a file using command
+ 'FileReadPost', -- after reading a file
+ 'FileReadPre', -- before reading a file
+ 'FileType', -- new file type detected (user defined)
+ 'FileWriteCmd', -- write to a file using command
+ 'FileWritePost', -- after writing a file
+ 'FileWritePre', -- before writing a file
+ 'FilterReadPost', -- after reading from a filter
+ 'FilterReadPre', -- before reading from a filter
+ 'FilterWritePost', -- after writing to a filter
+ 'FilterWritePre', -- before writing to a filter
+ 'FocusGained', -- got the focus
+ 'FocusLost', -- lost the focus to another app
+ 'FuncUndefined', -- if calling a function which doesn't exist
+ 'GUIEnter', -- after starting the GUI
+ 'GUIFailed', -- after starting the GUI failed
+ 'InsertChange', -- when changing Insert/Replace mode
+ 'InsertCharPre', -- before inserting a char
+ 'InsertEnter', -- when entering Insert mode
+ 'InsertLeave', -- just after leaving Insert mode
+ 'InsertLeavePre', -- just before leaving Insert mode
+ 'LspAttach', -- after an LSP client attaches to a buffer
+ 'LspDetach', -- after an LSP client detaches from a buffer
+ 'LspRequest', -- after an LSP request is started, canceled, or completed
+ 'LspNotify', -- after an LSP notice has been sent to the server
+ 'LspTokenUpdate', -- after a visible LSP token is updated
+ 'LspProgress', -- after a LSP progress update
+ 'MenuPopup', -- just before popup menu is displayed
+ 'ModeChanged', -- after changing the mode
+ 'OptionSet', -- after setting any option
+ 'QuickFixCmdPost', -- after :make, :grep etc.
+ 'QuickFixCmdPre', -- before :make, :grep etc.
+ 'QuitPre', -- before :quit
+ 'RecordingEnter', -- when starting to record a macro
+ 'RecordingLeave', -- just before a macro stops recording
+ 'RemoteReply', -- upon string reception from a remote vim
+ 'SafeState', -- going to wait for a character
+ 'SearchWrapped', -- after the search wrapped around
+ 'SessionLoadPost', -- after loading a session file
+ 'ShellCmdPost', -- after ":!cmd"
+ 'ShellFilterPost', -- after ":1,2!cmd", ":w !cmd", ":r !cmd".
+ 'Signal', -- after nvim process received a signal
+ 'SourceCmd', -- sourcing a Vim script using command
+ 'SourcePost', -- after sourcing a Vim script
+ 'SourcePre', -- before sourcing a Vim script
+ 'SpellFileMissing', -- spell file missing
+ 'StdinReadPost', -- after reading from stdin
+ 'StdinReadPre', -- before reading from stdin
+ 'SwapExists', -- found existing swap file
+ 'Syntax', -- syntax selected
+ 'TabClosed', -- a tab has closed
+ 'TabEnter', -- after entering a tab page
+ 'TabLeave', -- before leaving a tab page
+ 'TabNew', -- when creating a new tab
+ 'TabNewEntered', -- after entering a new tab
+ 'TermChanged', -- after changing 'term'
+ 'TermClose', -- after the process exits
+ 'TermEnter', -- after entering Terminal mode
+ 'TermLeave', -- after leaving Terminal mode
+ 'TermOpen', -- after opening a terminal buffer
+ 'TermResponse', -- after setting "v:termresponse"
+ 'TextChanged', -- text was modified
+ 'TextChangedI', -- text was modified in Insert mode(no popup)
+ 'TextChangedP', -- text was modified in Insert mode(popup)
+ 'TextChangedT', -- text was modified in Terminal mode
+ 'TextYankPost', -- after a yank or delete was done (y, d, c)
+ 'UIEnter', -- after UI attaches
+ 'UILeave', -- after UI detaches
+ 'User', -- user defined autocommand
+ 'VimEnter', -- after starting Vim
+ 'VimLeave', -- before exiting Vim
+ 'VimLeavePre', -- before exiting Vim and writing ShaDa file
+ 'VimResized', -- after Vim window was resized
+ 'VimResume', -- after Nvim is resumed
+ 'VimSuspend', -- before Nvim is suspended
+ 'WinClosed', -- after closing a window
+ 'WinEnter', -- after entering a window
+ 'WinLeave', -- before leaving a window
+ 'WinNew', -- when entering a new window
+ 'WinResized', -- after a window was resized
+ 'WinScrolled', -- after a window was scrolled or resized
},
aliases = {
{
'BufCreate',
- 'BufAdd'
+ 'BufAdd',
},
{
'BufRead',
- 'BufReadPost'
+ 'BufReadPost',
},
{
'BufWrite',
- 'BufWritePre'
+ 'BufWritePre',
},
{
'FileEncoding',
- 'EncodingChanged'
+ 'EncodingChanged',
},
},
-- List of nvim-specific events or aliases for the purpose of generating
-- syntax file
nvim_specific = {
- BufModifiedSet=true,
- DiagnosticChanged=true,
- LspAttach=true,
- LspDetach=true,
- LspNotify=true,
- LspRequest=true,
- LspProgress=true,
- LspTokenUpdate=true,
- RecordingEnter=true,
- RecordingLeave=true,
- Signal=true,
- TabNewEntered=true,
- TermClose=true,
- TermOpen=true,
- UIEnter=true,
- UILeave=true,
+ BufModifiedSet = true,
+ DiagnosticChanged = true,
+ LspAttach = true,
+ LspDetach = true,
+ LspNotify = true,
+ LspRequest = true,
+ LspProgress = true,
+ LspTokenUpdate = true,
+ RecordingEnter = true,
+ RecordingLeave = true,
+ Signal = true,
+ TabNewEntered = true,
+ TermClose = true,
+ TermOpen = true,
+ UIEnter = true,
+ UILeave = true,
},
}
diff --git a/src/nvim/autocmd.h b/src/nvim/autocmd.h
index 8ff4d75ddf..ea8f32feb2 100644
--- a/src/nvim/autocmd.h
+++ b/src/nvim/autocmd.h
@@ -1,9 +1,10 @@
#pragma once
#include <stdbool.h>
-#include <stddef.h>
-#include <stdint.h>
+#include <stddef.h> // IWYU pragma: keep
+#include <stdint.h> // IWYU pragma: keep
+#include "klib/kvec.h"
#include "nvim/api/private/defs.h" // IWYU pragma: keep
#include "nvim/autocmd_defs.h" // IWYU pragma: export
#include "nvim/buffer_defs.h"
@@ -12,7 +13,6 @@
#include "nvim/ex_cmds_defs.h" // IWYU pragma: keep
#include "nvim/macros_defs.h"
#include "nvim/pos_defs.h"
-#include "nvim/types_defs.h"
// Set by the apply_autocmds_group function if the given event is equal to
// EVENT_FILETYPE. Used by the readfile function in order to determine if
diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h
index b26d42385b..7402e66403 100644
--- a/src/nvim/buffer_defs.h
+++ b/src/nvim/buffer_defs.h
@@ -26,7 +26,7 @@ typedef struct {
#include "nvim/map_defs.h"
#include "nvim/mapping_defs.h"
#include "nvim/mark_defs.h"
-#include "nvim/marktree.h"
+#include "nvim/marktree_defs.h"
#include "nvim/option_vars.h"
#include "nvim/pos_defs.h"
#include "nvim/statusline_defs.h"
diff --git a/src/nvim/change.c b/src/nvim/change.c
index efc2db1413..c528ffba20 100644
--- a/src/nvim/change.c
+++ b/src/nvim/change.c
@@ -1839,11 +1839,11 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment)
curwin->w_cursor.lnum = old_cursor.lnum + 1;
}
if (did_append) {
- changed_lines(curbuf, curwin->w_cursor.lnum, 0, curwin->w_cursor.lnum, 1, true);
// bail out and just get the final length of the line we just manipulated
bcount_t extra = (bcount_t)strlen(ml_get(curwin->w_cursor.lnum));
extmark_splice(curbuf, (int)curwin->w_cursor.lnum - 1, 0,
0, 0, 0, 1, 0, 1 + extra, kExtmarkUndo);
+ changed_lines(curbuf, curwin->w_cursor.lnum, 0, curwin->w_cursor.lnum, 1, true);
}
curbuf_splice_pending--;
diff --git a/src/nvim/channel.c b/src/nvim/channel.c
index 24793bcb2a..767c8d29b8 100644
--- a/src/nvim/channel.c
+++ b/src/nvim/channel.c
@@ -794,19 +794,20 @@ static void channel_callback_call(Channel *chan, CallbackReader *reader)
/// and `buf` is assumed to be a new, unmodified buffer.
void channel_terminal_open(buf_T *buf, Channel *chan)
{
- TerminalOptions topts;
- topts.data = chan;
- topts.width = chan->stream.pty.width;
- topts.height = chan->stream.pty.height;
- topts.write_cb = term_write;
- topts.resize_cb = term_resize;
- topts.close_cb = term_close;
+ TerminalOptions topts = {
+ .data = chan,
+ .width = chan->stream.pty.width,
+ .height = chan->stream.pty.height,
+ .write_cb = term_write,
+ .resize_cb = term_resize,
+ .close_cb = term_close,
+ };
buf->b_p_channel = (OptInt)chan->id; // 'channel' option
channel_incref(chan);
terminal_open(&chan->term, buf, topts);
}
-static void term_write(char *buf, size_t size, void *data)
+static void term_write(const char *buf, size_t size, void *data)
{
Channel *chan = data;
if (chan->stream.proc.in.closed) {
diff --git a/src/nvim/decoration.c b/src/nvim/decoration.c
index 11204a1b31..ccba8bd607 100644
--- a/src/nvim/decoration.c
+++ b/src/nvim/decoration.c
@@ -14,6 +14,7 @@
#include "nvim/grid.h"
#include "nvim/highlight.h"
#include "nvim/highlight_group.h"
+#include "nvim/marktree.h"
#include "nvim/memory.h"
#include "nvim/move.h"
#include "nvim/option_vars.h"
diff --git a/src/nvim/decoration.h b/src/nvim/decoration.h
index e5bac169dc..92e0cbc76b 100644
--- a/src/nvim/decoration.h
+++ b/src/nvim/decoration.h
@@ -8,7 +8,7 @@
#include "nvim/buffer_defs.h"
#include "nvim/decoration_defs.h" // IWYU pragma: export
#include "nvim/macros_defs.h"
-#include "nvim/marktree.h"
+#include "nvim/marktree_defs.h"
#include "nvim/pos_defs.h" // IWYU pragma: keep
#include "nvim/types_defs.h"
diff --git a/src/nvim/drawscreen.c b/src/nvim/drawscreen.c
index fd1589f0c5..85f62db774 100644
--- a/src/nvim/drawscreen.c
+++ b/src/nvim/drawscreen.c
@@ -2644,6 +2644,8 @@ int number_width(win_T *wp)
/// e.g. if must_redraw is UPD_CLEAR, type UPD_NOT_VALID will do nothing.
void redraw_later(win_T *wp, int type)
{
+ // curwin may have been set to NULL when exiting
+ assert(wp != NULL || exiting);
if (!exiting && wp->w_redr_type < type) {
wp->w_redr_type = type;
if (type >= UPD_NOT_VALID) {
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index dd7cd9a573..ba2885a162 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -444,8 +444,11 @@ static int insert_check(VimState *state)
// is detected when the cursor column is smaller after inserting something.
// Don't do this when the topline changed already, it has already been
// adjusted (by insertchar() calling open_line())).
+ // Also don't do this when 'smoothscroll' is set, as the window should then
+ // be scrolled by screen lines.
if (curbuf->b_mod_set
&& curwin->w_p_wrap
+ && !curwin->w_p_sms
&& !s->did_backspace
&& curwin->w_topline == s->old_topline
&& curwin->w_topfill == s->old_topfill) {
diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua
index 55f4721c3a..59423808be 100644
--- a/src/nvim/eval.lua
+++ b/src/nvim/eval.lua
@@ -2114,7 +2114,7 @@ M.funcs = {
name = 'execute',
params = {
{ 'command', 'string|string[]' },
- { 'silent', "''|'silent'|'silent!'" }
+ { 'silent', "''|'silent'|'silent!'" },
},
returns = 'string',
signature = 'execute({command} [, {silent}])',
@@ -4519,7 +4519,7 @@ M.funcs = {
name = 'getwininfo',
params = { { 'winid', 'integer' } },
signature = 'getwininfo([{winid}])',
- returns = 'vim.fn.getwininfo.ret.item[]'
+ returns = 'vim.fn.getwininfo.ret.item[]',
},
getwinpos = {
args = { 0, 1 },
@@ -6297,7 +6297,7 @@ M.funcs = {
]],
name = 'maplist',
params = {},
- signature = 'maplist([{abbr}])'
+ signature = 'maplist([{abbr}])',
},
mapnew = {
args = 2,
@@ -9905,7 +9905,7 @@ M.funcs = {
name = 'sign_jump',
params = { { 'id', 'integer' }, { 'group', 'string' }, { 'buf', 'integer|string' } },
signature = 'sign_jump({id}, {group}, {buf})',
- returns = 'integer'
+ returns = 'integer',
},
sign_place = {
args = { 4, 5 },
@@ -9968,7 +9968,7 @@ M.funcs = {
{ 'dict', 'vim.fn.sign_place.dict' },
},
signature = 'sign_place({id}, {group}, {name}, {buf} [, {dict}])',
- returns = 'integer'
+ returns = 'integer',
},
sign_placelist = {
args = 1,
@@ -10035,7 +10035,7 @@ M.funcs = {
name = 'sign_placelist',
params = { { 'list', 'vim.fn.sign_placelist.list.item[]' } },
signature = 'sign_placelist({list})',
- returns = 'integer[]'
+ returns = 'integer[]',
},
sign_undefine = {
args = { 0, 1 },
@@ -10570,7 +10570,7 @@ M.funcs = {
signature = 'stdpath({what})',
},
state = {
- args = {0, 1},
+ args = { 0, 1 },
base = 1,
desc = [=[
Return a string which contains characters indicating the
@@ -12698,7 +12698,7 @@ M.funcs = {
name = 'winsaveview',
params = {},
signature = 'winsaveview()',
- returns = 'vim.fn.winsaveview.ret'
+ returns = 'vim.fn.winsaveview.ret',
},
winwidth = {
args = 1,
diff --git a/src/nvim/ex_cmds.lua b/src/nvim/ex_cmds.lua
index 4859a70553..551d228862 100644
--- a/src/nvim/ex_cmds.lua
+++ b/src/nvim/ex_cmds.lua
@@ -4,3358 +4,3358 @@ local module = {}
-- Description of the values below is contained in ex_cmds_defs.h file.
-- "EX_" prefix is omitted.
-local RANGE = 0x001
-local BANG = 0x002
-local EXTRA = 0x004
-local XFILE = 0x008
-local NOSPC = 0x010
-local DFLALL = 0x020
-local WHOLEFOLD = 0x040
-local NEEDARG = 0x080
-local TRLBAR = 0x100
-local REGSTR = 0x200
-local COUNT = 0x400
-local NOTRLCOM = 0x800
-local ZEROR = 0x1000
-local CTRLV = 0x2000
-local CMDARG = 0x4000
-local BUFNAME = 0x8000
-local BUFUNL = 0x10000
-local ARGOPT = 0x20000
-local SBOXOK = 0x40000
-local CMDWIN = 0x80000
-local MODIFY = 0x100000
-local FLAGS = 0x200000
-local LOCK_OK = 0x1000000
-local PREVIEW = 0x8000000
-local FILES = bit.bor(XFILE, EXTRA)
-local WORD1 = bit.bor(EXTRA, NOSPC)
-local FILE1 = bit.bor(FILES, NOSPC)
+local RANGE = 0x001
+local BANG = 0x002
+local EXTRA = 0x004
+local XFILE = 0x008
+local NOSPC = 0x010
+local DFLALL = 0x020
+local WHOLEFOLD = 0x040
+local NEEDARG = 0x080
+local TRLBAR = 0x100
+local REGSTR = 0x200
+local COUNT = 0x400
+local NOTRLCOM = 0x800
+local ZEROR = 0x1000
+local CTRLV = 0x2000
+local CMDARG = 0x4000
+local BUFNAME = 0x8000
+local BUFUNL = 0x10000
+local ARGOPT = 0x20000
+local SBOXOK = 0x40000
+local CMDWIN = 0x80000
+local MODIFY = 0x100000
+local FLAGS = 0x200000
+local LOCK_OK = 0x1000000
+local PREVIEW = 0x8000000
+local FILES = bit.bor(XFILE, EXTRA)
+local WORD1 = bit.bor(EXTRA, NOSPC)
+local FILE1 = bit.bor(FILES, NOSPC)
module.flags = {
RANGE = RANGE,
DFLALL = DFLALL,
- PREVIEW = PREVIEW
+ PREVIEW = PREVIEW,
}
-- The following table is described in ex_cmds_defs.h file.
module.cmds = {
{
- command='append',
- flags=bit.bor(BANG, RANGE, ZEROR, TRLBAR, CMDWIN, LOCK_OK, MODIFY),
- addr_type='ADDR_LINES',
- func='ex_append',
+ command = 'append',
+ flags = bit.bor(BANG, RANGE, ZEROR, TRLBAR, CMDWIN, LOCK_OK, MODIFY),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_append',
},
{
- command='abbreviate',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_abbreviate',
+ command = 'abbreviate',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_abbreviate',
},
{
- command='abclear',
- flags=bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_abclear',
+ command = 'abclear',
+ flags = bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_abclear',
},
{
- command='aboveleft',
- flags=bit.bor(NEEDARG, EXTRA, NOTRLCOM),
- addr_type='ADDR_NONE',
- func='ex_wrongmodifier',
+ command = 'aboveleft',
+ flags = bit.bor(NEEDARG, EXTRA, NOTRLCOM),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_wrongmodifier',
},
{
- command='all',
- flags=bit.bor(BANG, RANGE, COUNT, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_all',
+ command = 'all',
+ flags = bit.bor(BANG, RANGE, COUNT, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_all',
},
{
- command='amenu',
- flags=bit.bor(RANGE, ZEROR, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_OTHER',
- func='ex_menu',
+ command = 'amenu',
+ flags = bit.bor(RANGE, ZEROR, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_menu',
},
{
- command='anoremenu',
- flags=bit.bor(RANGE, ZEROR, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_OTHER',
- func='ex_menu',
+ command = 'anoremenu',
+ flags = bit.bor(RANGE, ZEROR, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_menu',
},
{
- command='args',
- flags=bit.bor(BANG, FILES, CMDARG, ARGOPT, TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_args',
+ command = 'args',
+ flags = bit.bor(BANG, FILES, CMDARG, ARGOPT, TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_args',
},
{
- command='argadd',
- flags=bit.bor(BANG, RANGE, ZEROR, FILES, TRLBAR),
- addr_type='ADDR_ARGUMENTS',
- func='ex_argadd',
+ command = 'argadd',
+ flags = bit.bor(BANG, RANGE, ZEROR, FILES, TRLBAR),
+ addr_type = 'ADDR_ARGUMENTS',
+ func = 'ex_argadd',
},
{
- command='argdelete',
- flags=bit.bor(BANG, RANGE, FILES, TRLBAR),
- addr_type='ADDR_ARGUMENTS',
- func='ex_argdelete',
+ command = 'argdelete',
+ flags = bit.bor(BANG, RANGE, FILES, TRLBAR),
+ addr_type = 'ADDR_ARGUMENTS',
+ func = 'ex_argdelete',
},
{
- command='argdo',
- flags=bit.bor(BANG, NEEDARG, EXTRA, NOTRLCOM, RANGE, DFLALL),
- addr_type='ADDR_ARGUMENTS',
- func='ex_listdo',
+ command = 'argdo',
+ flags = bit.bor(BANG, NEEDARG, EXTRA, NOTRLCOM, RANGE, DFLALL),
+ addr_type = 'ADDR_ARGUMENTS',
+ func = 'ex_listdo',
},
{
- command='argdedupe',
- flags=TRLBAR,
- addr_type='ADDR_NONE',
- func='ex_argdedupe',
+ command = 'argdedupe',
+ flags = TRLBAR,
+ addr_type = 'ADDR_NONE',
+ func = 'ex_argdedupe',
},
{
- command='argedit',
- flags=bit.bor(BANG, NEEDARG, RANGE, ZEROR, FILES, CMDARG, ARGOPT, TRLBAR),
- addr_type='ADDR_ARGUMENTS',
- func='ex_argedit',
+ command = 'argedit',
+ flags = bit.bor(BANG, NEEDARG, RANGE, ZEROR, FILES, CMDARG, ARGOPT, TRLBAR),
+ addr_type = 'ADDR_ARGUMENTS',
+ func = 'ex_argedit',
},
{
- command='argglobal',
- flags=bit.bor(BANG, FILES, CMDARG, ARGOPT, TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_args',
+ command = 'argglobal',
+ flags = bit.bor(BANG, FILES, CMDARG, ARGOPT, TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_args',
},
{
- command='arglocal',
- flags=bit.bor(BANG, FILES, CMDARG, ARGOPT, TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_args',
+ command = 'arglocal',
+ flags = bit.bor(BANG, FILES, CMDARG, ARGOPT, TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_args',
},
{
- command='argument',
- flags=bit.bor(BANG, RANGE, COUNT, EXTRA, CMDARG, ARGOPT, TRLBAR),
- addr_type='ADDR_ARGUMENTS',
- func='ex_argument',
+ command = 'argument',
+ flags = bit.bor(BANG, RANGE, COUNT, EXTRA, CMDARG, ARGOPT, TRLBAR),
+ addr_type = 'ADDR_ARGUMENTS',
+ func = 'ex_argument',
},
{
- command='ascii',
- flags=bit.bor(TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='do_ascii',
+ command = 'ascii',
+ flags = bit.bor(TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'do_ascii',
},
{
- command='autocmd',
- flags=bit.bor(BANG, EXTRA, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_autocmd',
+ command = 'autocmd',
+ flags = bit.bor(BANG, EXTRA, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_autocmd',
},
{
- command='augroup',
- flags=bit.bor(BANG, WORD1, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_autocmd',
+ command = 'augroup',
+ flags = bit.bor(BANG, WORD1, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_autocmd',
},
{
- command='aunmenu',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_menu',
+ command = 'aunmenu',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_menu',
},
{
- command='buffer',
- flags=bit.bor(BANG, RANGE, BUFNAME, BUFUNL, COUNT, EXTRA, CMDARG, TRLBAR),
- addr_type='ADDR_BUFFERS',
- func='ex_buffer',
+ command = 'buffer',
+ flags = bit.bor(BANG, RANGE, BUFNAME, BUFUNL, COUNT, EXTRA, CMDARG, TRLBAR),
+ addr_type = 'ADDR_BUFFERS',
+ func = 'ex_buffer',
},
{
- command='bNext',
- flags=bit.bor(BANG, RANGE, COUNT, CMDARG, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_bprevious',
+ command = 'bNext',
+ flags = bit.bor(BANG, RANGE, COUNT, CMDARG, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_bprevious',
},
{
- command='ball',
- flags=bit.bor(RANGE, COUNT, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_buffer_all',
+ command = 'ball',
+ flags = bit.bor(RANGE, COUNT, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_buffer_all',
},
{
- command='badd',
- flags=bit.bor(NEEDARG, FILE1, CMDARG, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_edit',
+ command = 'badd',
+ flags = bit.bor(NEEDARG, FILE1, CMDARG, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_edit',
},
{
- command='balt',
- flags=bit.bor(NEEDARG, FILE1, CMDARG, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_edit',
+ command = 'balt',
+ flags = bit.bor(NEEDARG, FILE1, CMDARG, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_edit',
},
{
- command='bdelete',
- flags=bit.bor(BANG, RANGE, BUFNAME, COUNT, EXTRA, TRLBAR),
- addr_type='ADDR_BUFFERS',
- func='ex_bunload',
+ command = 'bdelete',
+ flags = bit.bor(BANG, RANGE, BUFNAME, COUNT, EXTRA, TRLBAR),
+ addr_type = 'ADDR_BUFFERS',
+ func = 'ex_bunload',
},
{
- command='belowright',
- flags=bit.bor(NEEDARG, EXTRA, NOTRLCOM),
- addr_type='ADDR_NONE',
- func='ex_wrongmodifier',
+ command = 'belowright',
+ flags = bit.bor(NEEDARG, EXTRA, NOTRLCOM),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_wrongmodifier',
},
{
- command='bfirst',
- flags=bit.bor(BANG, RANGE, CMDARG, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_brewind',
+ command = 'bfirst',
+ flags = bit.bor(BANG, RANGE, CMDARG, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_brewind',
},
{
- command='blast',
- flags=bit.bor(BANG, RANGE, CMDARG, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_blast',
+ command = 'blast',
+ flags = bit.bor(BANG, RANGE, CMDARG, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_blast',
},
{
- command='bmodified',
- flags=bit.bor(BANG, RANGE, COUNT, CMDARG, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_bmodified',
+ command = 'bmodified',
+ flags = bit.bor(BANG, RANGE, COUNT, CMDARG, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_bmodified',
},
{
- command='bnext',
- flags=bit.bor(BANG, RANGE, COUNT, CMDARG, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_bnext',
+ command = 'bnext',
+ flags = bit.bor(BANG, RANGE, COUNT, CMDARG, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_bnext',
},
{
- command='botright',
- flags=bit.bor(NEEDARG, EXTRA, NOTRLCOM),
- addr_type='ADDR_NONE',
- func='ex_wrongmodifier',
+ command = 'botright',
+ flags = bit.bor(NEEDARG, EXTRA, NOTRLCOM),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_wrongmodifier',
},
{
- command='bprevious',
- flags=bit.bor(BANG, RANGE, COUNT, CMDARG, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_bprevious',
+ command = 'bprevious',
+ flags = bit.bor(BANG, RANGE, COUNT, CMDARG, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_bprevious',
},
{
- command='brewind',
- flags=bit.bor(BANG, RANGE, CMDARG, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_brewind',
+ command = 'brewind',
+ flags = bit.bor(BANG, RANGE, CMDARG, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_brewind',
},
{
- command='break',
- flags=bit.bor(TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_break',
+ command = 'break',
+ flags = bit.bor(TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_break',
},
{
- command='breakadd',
- flags=bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_breakadd',
+ command = 'breakadd',
+ flags = bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_breakadd',
},
{
- command='breakdel',
- flags=bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_breakdel',
+ command = 'breakdel',
+ flags = bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_breakdel',
},
{
- command='breaklist',
- flags=bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_breaklist',
+ command = 'breaklist',
+ flags = bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_breaklist',
},
{
- command='browse',
- flags=bit.bor(NEEDARG, EXTRA, NOTRLCOM, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_wrongmodifier',
+ command = 'browse',
+ flags = bit.bor(NEEDARG, EXTRA, NOTRLCOM, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_wrongmodifier',
},
{
- command='buffers',
- flags=bit.bor(BANG, EXTRA, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='buflist_list',
+ command = 'buffers',
+ flags = bit.bor(BANG, EXTRA, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'buflist_list',
},
{
- command='bufdo',
- flags=bit.bor(BANG, NEEDARG, EXTRA, NOTRLCOM, RANGE, DFLALL),
- addr_type='ADDR_BUFFERS',
- func='ex_listdo',
+ command = 'bufdo',
+ flags = bit.bor(BANG, NEEDARG, EXTRA, NOTRLCOM, RANGE, DFLALL),
+ addr_type = 'ADDR_BUFFERS',
+ func = 'ex_listdo',
},
{
- command='bunload',
- flags=bit.bor(BANG, RANGE, BUFNAME, COUNT, EXTRA, TRLBAR),
- addr_type='ADDR_LOADED_BUFFERS',
- func='ex_bunload',
+ command = 'bunload',
+ flags = bit.bor(BANG, RANGE, BUFNAME, COUNT, EXTRA, TRLBAR),
+ addr_type = 'ADDR_LOADED_BUFFERS',
+ func = 'ex_bunload',
},
{
- command='bwipeout',
- flags=bit.bor(BANG, RANGE, BUFNAME, BUFUNL, COUNT, EXTRA, TRLBAR),
- addr_type='ADDR_BUFFERS',
- func='ex_bunload',
+ command = 'bwipeout',
+ flags = bit.bor(BANG, RANGE, BUFNAME, BUFUNL, COUNT, EXTRA, TRLBAR),
+ addr_type = 'ADDR_BUFFERS',
+ func = 'ex_bunload',
},
{
- command='change',
- flags=bit.bor(BANG, WHOLEFOLD, RANGE, COUNT, TRLBAR, CMDWIN, LOCK_OK, MODIFY),
- addr_type='ADDR_LINES',
- func='ex_change',
+ command = 'change',
+ flags = bit.bor(BANG, WHOLEFOLD, RANGE, COUNT, TRLBAR, CMDWIN, LOCK_OK, MODIFY),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_change',
},
{
- command='cNext',
- flags=bit.bor(RANGE, COUNT, TRLBAR, BANG),
- addr_type='ADDR_UNSIGNED',
- func='ex_cnext',
+ command = 'cNext',
+ flags = bit.bor(RANGE, COUNT, TRLBAR, BANG),
+ addr_type = 'ADDR_UNSIGNED',
+ func = 'ex_cnext',
},
{
- command='cNfile',
- flags=bit.bor(RANGE, COUNT, TRLBAR, BANG),
- addr_type='ADDR_UNSIGNED',
- func='ex_cnext',
+ command = 'cNfile',
+ flags = bit.bor(RANGE, COUNT, TRLBAR, BANG),
+ addr_type = 'ADDR_UNSIGNED',
+ func = 'ex_cnext',
},
{
- command='cabbrev',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_abbreviate',
+ command = 'cabbrev',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_abbreviate',
},
{
- command='cabclear',
- flags=bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_abclear',
+ command = 'cabclear',
+ flags = bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_abclear',
},
{
- command='cabove',
- flags=bit.bor(RANGE, COUNT, TRLBAR),
- addr_type='ADDR_UNSIGNED',
- func='ex_cbelow',
+ command = 'cabove',
+ flags = bit.bor(RANGE, COUNT, TRLBAR),
+ addr_type = 'ADDR_UNSIGNED',
+ func = 'ex_cbelow',
},
{
- command='caddbuffer',
- flags=bit.bor(RANGE, WORD1, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_cbuffer',
+ command = 'caddbuffer',
+ flags = bit.bor(RANGE, WORD1, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_cbuffer',
},
{
- command='caddexpr',
- flags=bit.bor(NEEDARG, WORD1, NOTRLCOM),
- addr_type='ADDR_NONE',
- func='ex_cexpr',
+ command = 'caddexpr',
+ flags = bit.bor(NEEDARG, WORD1, NOTRLCOM),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_cexpr',
},
{
- command='caddfile',
- flags=bit.bor(TRLBAR, FILE1),
- addr_type='ADDR_NONE',
- func='ex_cfile',
+ command = 'caddfile',
+ flags = bit.bor(TRLBAR, FILE1),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_cfile',
},
{
- command='cafter',
- flags=bit.bor(RANGE, COUNT, TRLBAR),
- addr_type='ADDR_UNSIGNED',
- func='ex_cbelow',
+ command = 'cafter',
+ flags = bit.bor(RANGE, COUNT, TRLBAR),
+ addr_type = 'ADDR_UNSIGNED',
+ func = 'ex_cbelow',
},
{
- command='call',
- flags=bit.bor(RANGE, NEEDARG, EXTRA, NOTRLCOM, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_call',
+ command = 'call',
+ flags = bit.bor(RANGE, NEEDARG, EXTRA, NOTRLCOM, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_call',
},
{
- command='catch',
- flags=bit.bor(EXTRA, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_catch',
+ command = 'catch',
+ flags = bit.bor(EXTRA, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_catch',
},
{
- command='cbuffer',
- flags=bit.bor(BANG, RANGE, WORD1, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_cbuffer',
+ command = 'cbuffer',
+ flags = bit.bor(BANG, RANGE, WORD1, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_cbuffer',
},
{
- command='cbefore',
- flags=bit.bor(RANGE, COUNT, TRLBAR),
- addr_type='ADDR_UNSIGNED',
- func='ex_cbelow',
+ command = 'cbefore',
+ flags = bit.bor(RANGE, COUNT, TRLBAR),
+ addr_type = 'ADDR_UNSIGNED',
+ func = 'ex_cbelow',
},
{
- command='cbelow',
- flags=bit.bor(RANGE, COUNT, TRLBAR),
- addr_type='ADDR_UNSIGNED',
- func='ex_cbelow',
+ command = 'cbelow',
+ flags = bit.bor(RANGE, COUNT, TRLBAR),
+ addr_type = 'ADDR_UNSIGNED',
+ func = 'ex_cbelow',
},
{
- command='cbottom',
- flags=bit.bor(TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_cbottom',
+ command = 'cbottom',
+ flags = bit.bor(TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_cbottom',
},
{
- command='cc',
- flags=bit.bor(RANGE, COUNT, TRLBAR, BANG),
- addr_type='ADDR_QUICKFIX',
- func='ex_cc',
+ command = 'cc',
+ flags = bit.bor(RANGE, COUNT, TRLBAR, BANG),
+ addr_type = 'ADDR_QUICKFIX',
+ func = 'ex_cc',
},
{
- command='cclose',
- flags=bit.bor(TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_cclose',
+ command = 'cclose',
+ flags = bit.bor(TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_cclose',
},
{
- command='cd',
- flags=bit.bor(BANG, FILE1, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_cd',
+ command = 'cd',
+ flags = bit.bor(BANG, FILE1, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_cd',
},
{
- command='cdo',
- flags=bit.bor(BANG, NEEDARG, EXTRA, NOTRLCOM, RANGE, DFLALL),
- addr_type='ADDR_QUICKFIX_VALID',
- func='ex_listdo',
+ command = 'cdo',
+ flags = bit.bor(BANG, NEEDARG, EXTRA, NOTRLCOM, RANGE, DFLALL),
+ addr_type = 'ADDR_QUICKFIX_VALID',
+ func = 'ex_listdo',
},
{
- command='center',
- flags=bit.bor(TRLBAR, RANGE, WHOLEFOLD, EXTRA, CMDWIN, LOCK_OK, MODIFY),
- addr_type='ADDR_LINES',
- func='ex_align',
+ command = 'center',
+ flags = bit.bor(TRLBAR, RANGE, WHOLEFOLD, EXTRA, CMDWIN, LOCK_OK, MODIFY),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_align',
},
{
- command='cexpr',
- flags=bit.bor(NEEDARG, WORD1, NOTRLCOM, BANG),
- addr_type='ADDR_NONE',
- func='ex_cexpr',
+ command = 'cexpr',
+ flags = bit.bor(NEEDARG, WORD1, NOTRLCOM, BANG),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_cexpr',
},
{
- command='cfile',
- flags=bit.bor(TRLBAR, FILE1, BANG),
- addr_type='ADDR_NONE',
- func='ex_cfile',
+ command = 'cfile',
+ flags = bit.bor(TRLBAR, FILE1, BANG),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_cfile',
},
-- Even though 'cfdo' is alphabetically lower than 'cfile', it is after
-- 'cfile' in this cmd list to support the existing ":cf" abbreviation.
{
- command='cfdo',
- flags=bit.bor(BANG, NEEDARG, EXTRA, NOTRLCOM, RANGE, DFLALL),
- addr_type='ADDR_QUICKFIX_VALID',
- func='ex_listdo',
+ command = 'cfdo',
+ flags = bit.bor(BANG, NEEDARG, EXTRA, NOTRLCOM, RANGE, DFLALL),
+ addr_type = 'ADDR_QUICKFIX_VALID',
+ func = 'ex_listdo',
},
{
- command='cfirst',
- flags=bit.bor(RANGE, COUNT, TRLBAR, BANG),
- addr_type='ADDR_UNSIGNED',
- func='ex_cc',
+ command = 'cfirst',
+ flags = bit.bor(RANGE, COUNT, TRLBAR, BANG),
+ addr_type = 'ADDR_UNSIGNED',
+ func = 'ex_cc',
},
{
- command='cgetfile',
- flags=bit.bor(TRLBAR, FILE1),
- addr_type='ADDR_NONE',
- func='ex_cfile',
+ command = 'cgetfile',
+ flags = bit.bor(TRLBAR, FILE1),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_cfile',
},
{
- command='cgetbuffer',
- flags=bit.bor(RANGE, WORD1, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_cbuffer',
+ command = 'cgetbuffer',
+ flags = bit.bor(RANGE, WORD1, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_cbuffer',
},
{
- command='cgetexpr',
- flags=bit.bor(NEEDARG, WORD1, NOTRLCOM),
- addr_type='ADDR_NONE',
- func='ex_cexpr',
+ command = 'cgetexpr',
+ flags = bit.bor(NEEDARG, WORD1, NOTRLCOM),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_cexpr',
},
{
- command='chdir',
- flags=bit.bor(BANG, FILE1, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_cd',
+ command = 'chdir',
+ flags = bit.bor(BANG, FILE1, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_cd',
},
{
- command='changes',
- flags=bit.bor(TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_changes',
+ command = 'changes',
+ flags = bit.bor(TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_changes',
},
{
- command='checkhealth',
- flags=bit.bor(EXTRA, TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_checkhealth',
+ command = 'checkhealth',
+ flags = bit.bor(EXTRA, TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_checkhealth',
},
{
- command='checkpath',
- flags=bit.bor(TRLBAR, BANG, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_checkpath',
+ command = 'checkpath',
+ flags = bit.bor(TRLBAR, BANG, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_checkpath',
},
{
- command='checktime',
- flags=bit.bor(RANGE, BUFNAME, COUNT, EXTRA, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_checktime',
+ command = 'checktime',
+ flags = bit.bor(RANGE, BUFNAME, COUNT, EXTRA, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_checktime',
},
{
- command='chistory',
- flags=bit.bor(RANGE, COUNT, TRLBAR),
- addr_type='ADDR_UNSIGNED',
- func='qf_history',
+ command = 'chistory',
+ flags = bit.bor(RANGE, COUNT, TRLBAR),
+ addr_type = 'ADDR_UNSIGNED',
+ func = 'qf_history',
},
{
- command='clist',
- flags=bit.bor(BANG, EXTRA, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='qf_list',
+ command = 'clist',
+ flags = bit.bor(BANG, EXTRA, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'qf_list',
},
{
- command='clast',
- flags=bit.bor(RANGE, COUNT, TRLBAR, BANG),
- addr_type='ADDR_UNSIGNED',
- func='ex_cc',
+ command = 'clast',
+ flags = bit.bor(RANGE, COUNT, TRLBAR, BANG),
+ addr_type = 'ADDR_UNSIGNED',
+ func = 'ex_cc',
},
{
- command='close',
- flags=bit.bor(BANG, RANGE, COUNT, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_WINDOWS',
- func='ex_close',
+ command = 'close',
+ flags = bit.bor(BANG, RANGE, COUNT, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_WINDOWS',
+ func = 'ex_close',
},
{
- command='clearjumps',
- flags=bit.bor(TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_clearjumps',
+ command = 'clearjumps',
+ flags = bit.bor(TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_clearjumps',
},
{
- command='cmap',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_map',
+ command = 'cmap',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_map',
},
{
- command='cmapclear',
- flags=bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_mapclear',
+ command = 'cmapclear',
+ flags = bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_mapclear',
},
{
- command='cmenu',
- flags=bit.bor(RANGE, ZEROR, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_OTHER',
- func='ex_menu',
+ command = 'cmenu',
+ flags = bit.bor(RANGE, ZEROR, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_menu',
},
{
- command='cnext',
- flags=bit.bor(RANGE, COUNT, TRLBAR, BANG),
- addr_type='ADDR_UNSIGNED',
- func='ex_cnext',
+ command = 'cnext',
+ flags = bit.bor(RANGE, COUNT, TRLBAR, BANG),
+ addr_type = 'ADDR_UNSIGNED',
+ func = 'ex_cnext',
},
{
- command='cnewer',
- flags=bit.bor(RANGE, COUNT, TRLBAR),
- addr_type='ADDR_UNSIGNED',
- func='qf_age',
+ command = 'cnewer',
+ flags = bit.bor(RANGE, COUNT, TRLBAR),
+ addr_type = 'ADDR_UNSIGNED',
+ func = 'qf_age',
},
{
- command='cnfile',
- flags=bit.bor(RANGE, COUNT, TRLBAR, BANG),
- addr_type='ADDR_UNSIGNED',
- func='ex_cnext',
+ command = 'cnfile',
+ flags = bit.bor(RANGE, COUNT, TRLBAR, BANG),
+ addr_type = 'ADDR_UNSIGNED',
+ func = 'ex_cnext',
},
{
- command='cnoremap',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_map',
+ command = 'cnoremap',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_map',
},
{
- command='cnoreabbrev',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_abbreviate',
+ command = 'cnoreabbrev',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_abbreviate',
},
{
- command='cnoremenu',
- flags=bit.bor(RANGE, ZEROR, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_OTHER',
- func='ex_menu',
+ command = 'cnoremenu',
+ flags = bit.bor(RANGE, ZEROR, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_menu',
},
{
- command='copy',
- flags=bit.bor(RANGE, WHOLEFOLD, EXTRA, TRLBAR, CMDWIN, LOCK_OK, MODIFY),
- addr_type='ADDR_LINES',
- func='ex_copymove',
+ command = 'copy',
+ flags = bit.bor(RANGE, WHOLEFOLD, EXTRA, TRLBAR, CMDWIN, LOCK_OK, MODIFY),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_copymove',
},
{
- command='colder',
- flags=bit.bor(RANGE, COUNT, TRLBAR),
- addr_type='ADDR_UNSIGNED',
- func='qf_age',
+ command = 'colder',
+ flags = bit.bor(RANGE, COUNT, TRLBAR),
+ addr_type = 'ADDR_UNSIGNED',
+ func = 'qf_age',
},
{
- command='colorscheme',
- flags=bit.bor(WORD1, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_colorscheme',
+ command = 'colorscheme',
+ flags = bit.bor(WORD1, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_colorscheme',
},
{
- command='command',
- flags=bit.bor(EXTRA, BANG, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_command',
+ command = 'command',
+ flags = bit.bor(EXTRA, BANG, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_command',
},
{
- command='comclear',
- flags=bit.bor(TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_comclear',
+ command = 'comclear',
+ flags = bit.bor(TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_comclear',
},
{
- command='compiler',
- flags=bit.bor(BANG, TRLBAR, WORD1, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_compiler',
+ command = 'compiler',
+ flags = bit.bor(BANG, TRLBAR, WORD1, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_compiler',
},
{
- command='continue',
- flags=bit.bor(TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_continue',
+ command = 'continue',
+ flags = bit.bor(TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_continue',
},
{
- command='confirm',
- flags=bit.bor(NEEDARG, EXTRA, NOTRLCOM, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_wrongmodifier',
+ command = 'confirm',
+ flags = bit.bor(NEEDARG, EXTRA, NOTRLCOM, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_wrongmodifier',
},
{
- command='const',
- flags=bit.bor(EXTRA, NOTRLCOM, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_let',
+ command = 'const',
+ flags = bit.bor(EXTRA, NOTRLCOM, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_let',
},
{
- command='copen',
- flags=bit.bor(RANGE, COUNT, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_copen',
+ command = 'copen',
+ flags = bit.bor(RANGE, COUNT, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_copen',
},
{
- command='cprevious',
- flags=bit.bor(RANGE, COUNT, TRLBAR, BANG),
- addr_type='ADDR_UNSIGNED',
- func='ex_cnext',
+ command = 'cprevious',
+ flags = bit.bor(RANGE, COUNT, TRLBAR, BANG),
+ addr_type = 'ADDR_UNSIGNED',
+ func = 'ex_cnext',
},
{
- command='cpfile',
- flags=bit.bor(RANGE, COUNT, TRLBAR, BANG),
- addr_type='ADDR_OTHER',
- func='ex_cnext',
+ command = 'cpfile',
+ flags = bit.bor(RANGE, COUNT, TRLBAR, BANG),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_cnext',
},
{
- command='cquit',
- flags=bit.bor(RANGE, COUNT, ZEROR, TRLBAR, BANG),
- addr_type='ADDR_UNSIGNED',
- func='ex_cquit',
+ command = 'cquit',
+ flags = bit.bor(RANGE, COUNT, ZEROR, TRLBAR, BANG),
+ addr_type = 'ADDR_UNSIGNED',
+ func = 'ex_cquit',
},
{
- command='crewind',
- flags=bit.bor(RANGE, COUNT, TRLBAR, BANG),
- addr_type='ADDR_UNSIGNED',
- func='ex_cc',
+ command = 'crewind',
+ flags = bit.bor(RANGE, COUNT, TRLBAR, BANG),
+ addr_type = 'ADDR_UNSIGNED',
+ func = 'ex_cc',
},
{
- command='cunmap',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_unmap',
+ command = 'cunmap',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_unmap',
},
{
- command='cunabbrev',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_abbreviate',
+ command = 'cunabbrev',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_abbreviate',
},
{
- command='cunmenu',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_menu',
+ command = 'cunmenu',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_menu',
},
{
- command='cwindow',
- flags=bit.bor(RANGE, COUNT, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_cwindow',
+ command = 'cwindow',
+ flags = bit.bor(RANGE, COUNT, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_cwindow',
},
{
- command='delete',
- flags=bit.bor(RANGE, WHOLEFOLD, REGSTR, COUNT, TRLBAR, CMDWIN, LOCK_OK, MODIFY),
- addr_type='ADDR_LINES',
- func='ex_operators',
+ command = 'delete',
+ flags = bit.bor(RANGE, WHOLEFOLD, REGSTR, COUNT, TRLBAR, CMDWIN, LOCK_OK, MODIFY),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_operators',
},
{
- command='delmarks',
- flags=bit.bor(BANG, EXTRA, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_delmarks',
+ command = 'delmarks',
+ flags = bit.bor(BANG, EXTRA, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_delmarks',
},
{
- command='debug',
- flags=bit.bor(NEEDARG, EXTRA, NOTRLCOM, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_debug',
+ command = 'debug',
+ flags = bit.bor(NEEDARG, EXTRA, NOTRLCOM, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_debug',
},
{
- command='debuggreedy',
- flags=bit.bor(RANGE, ZEROR, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_OTHER',
- func='ex_debuggreedy',
+ command = 'debuggreedy',
+ flags = bit.bor(RANGE, ZEROR, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_debuggreedy',
},
{
- command='defer',
- flags=bit.bor(NEEDARG, EXTRA, NOTRLCOM, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_call',
+ command = 'defer',
+ flags = bit.bor(NEEDARG, EXTRA, NOTRLCOM, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_call',
},
{
- command='delcommand',
- flags=bit.bor(BANG, NEEDARG, WORD1, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_delcommand',
+ command = 'delcommand',
+ flags = bit.bor(BANG, NEEDARG, WORD1, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_delcommand',
},
{
- command='delfunction',
- flags=bit.bor(BANG, NEEDARG, WORD1, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_delfunction',
+ command = 'delfunction',
+ flags = bit.bor(BANG, NEEDARG, WORD1, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_delfunction',
},
{
- command='display',
- flags=bit.bor(EXTRA, NOTRLCOM, TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_display',
+ command = 'display',
+ flags = bit.bor(EXTRA, NOTRLCOM, TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_display',
},
{
- command='diffupdate',
- flags=bit.bor(BANG, TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_diffupdate',
+ command = 'diffupdate',
+ flags = bit.bor(BANG, TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_diffupdate',
},
{
- command='diffget',
- flags=bit.bor(RANGE, EXTRA, TRLBAR, MODIFY),
- addr_type='ADDR_LINES',
- func='ex_diffgetput',
+ command = 'diffget',
+ flags = bit.bor(RANGE, EXTRA, TRLBAR, MODIFY),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_diffgetput',
},
{
- command='diffoff',
- flags=bit.bor(BANG, TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_diffoff',
+ command = 'diffoff',
+ flags = bit.bor(BANG, TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_diffoff',
},
{
- command='diffpatch',
- flags=bit.bor(EXTRA, FILE1, TRLBAR, MODIFY),
- addr_type='ADDR_NONE',
- func='ex_diffpatch',
+ command = 'diffpatch',
+ flags = bit.bor(EXTRA, FILE1, TRLBAR, MODIFY),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_diffpatch',
},
{
- command='diffput',
- flags=bit.bor(RANGE, EXTRA, TRLBAR),
- addr_type='ADDR_LINES',
- func='ex_diffgetput',
+ command = 'diffput',
+ flags = bit.bor(RANGE, EXTRA, TRLBAR),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_diffgetput',
},
{
- command='diffsplit',
- flags=bit.bor(EXTRA, FILE1, TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_diffsplit',
+ command = 'diffsplit',
+ flags = bit.bor(EXTRA, FILE1, TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_diffsplit',
},
{
- command='diffthis',
- flags=bit.bor(TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_diffthis',
+ command = 'diffthis',
+ flags = bit.bor(TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_diffthis',
},
{
- command='digraphs',
- flags=bit.bor(BANG, EXTRA, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_digraphs',
+ command = 'digraphs',
+ flags = bit.bor(BANG, EXTRA, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_digraphs',
},
{
- command='djump',
- flags=bit.bor(BANG, RANGE, DFLALL, WHOLEFOLD, EXTRA),
- addr_type='ADDR_LINES',
- func='ex_findpat',
+ command = 'djump',
+ flags = bit.bor(BANG, RANGE, DFLALL, WHOLEFOLD, EXTRA),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_findpat',
},
{
- command='dlist',
- flags=bit.bor(BANG, RANGE, DFLALL, WHOLEFOLD, EXTRA, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_findpat',
+ command = 'dlist',
+ flags = bit.bor(BANG, RANGE, DFLALL, WHOLEFOLD, EXTRA, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_findpat',
},
{
- command='doautocmd',
- flags=bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_doautocmd',
+ command = 'doautocmd',
+ flags = bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_doautocmd',
},
{
- command='doautoall',
- flags=bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_doautoall',
+ command = 'doautoall',
+ flags = bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_doautoall',
},
{
- command='drop',
- flags=bit.bor(FILES, CMDARG, NEEDARG, ARGOPT, TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_drop',
+ command = 'drop',
+ flags = bit.bor(FILES, CMDARG, NEEDARG, ARGOPT, TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_drop',
},
{
- command='dsearch',
- flags=bit.bor(BANG, RANGE, DFLALL, WHOLEFOLD, EXTRA, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_findpat',
+ command = 'dsearch',
+ flags = bit.bor(BANG, RANGE, DFLALL, WHOLEFOLD, EXTRA, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_findpat',
},
{
- command='dsplit',
- flags=bit.bor(BANG, RANGE, DFLALL, WHOLEFOLD, EXTRA),
- addr_type='ADDR_LINES',
- func='ex_findpat',
+ command = 'dsplit',
+ flags = bit.bor(BANG, RANGE, DFLALL, WHOLEFOLD, EXTRA),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_findpat',
},
{
- command='edit',
- flags=bit.bor(BANG, FILE1, CMDARG, ARGOPT, TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_edit',
+ command = 'edit',
+ flags = bit.bor(BANG, FILE1, CMDARG, ARGOPT, TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_edit',
},
{
- command='earlier',
- flags=bit.bor(TRLBAR, EXTRA, NOSPC, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_later',
+ command = 'earlier',
+ flags = bit.bor(TRLBAR, EXTRA, NOSPC, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_later',
},
{
- command='echo',
- flags=bit.bor(EXTRA, NOTRLCOM, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_echo',
+ command = 'echo',
+ flags = bit.bor(EXTRA, NOTRLCOM, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_echo',
},
{
- command='echoerr',
- flags=bit.bor(EXTRA, NOTRLCOM, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_execute',
+ command = 'echoerr',
+ flags = bit.bor(EXTRA, NOTRLCOM, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_execute',
},
{
- command='echohl',
- flags=bit.bor(EXTRA, TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_echohl',
+ command = 'echohl',
+ flags = bit.bor(EXTRA, TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_echohl',
},
{
- command='echomsg',
- flags=bit.bor(EXTRA, NOTRLCOM, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_execute',
+ command = 'echomsg',
+ flags = bit.bor(EXTRA, NOTRLCOM, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_execute',
},
{
- command='echon',
- flags=bit.bor(EXTRA, NOTRLCOM, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_echo',
+ command = 'echon',
+ flags = bit.bor(EXTRA, NOTRLCOM, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_echo',
},
{
- command='else',
- flags=bit.bor(TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_else',
+ command = 'else',
+ flags = bit.bor(TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_else',
},
{
- command='elseif',
- flags=bit.bor(EXTRA, NOTRLCOM, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_else',
+ command = 'elseif',
+ flags = bit.bor(EXTRA, NOTRLCOM, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_else',
},
{
- command='emenu',
- flags=bit.bor(NEEDARG, EXTRA, TRLBAR, NOTRLCOM, RANGE, CMDWIN, LOCK_OK),
- addr_type='ADDR_OTHER',
- func='ex_emenu',
+ command = 'emenu',
+ flags = bit.bor(NEEDARG, EXTRA, TRLBAR, NOTRLCOM, RANGE, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_emenu',
},
{
- command='endif',
- flags=bit.bor(TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_endif',
+ command = 'endif',
+ flags = bit.bor(TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_endif',
},
{
- command='endfunction',
- flags=bit.bor(TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_endfunction',
+ command = 'endfunction',
+ flags = bit.bor(TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_endfunction',
},
{
- command='endfor',
- flags=bit.bor(TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_endwhile',
+ command = 'endfor',
+ flags = bit.bor(TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_endwhile',
},
{
- command='endtry',
- flags=bit.bor(TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_endtry',
+ command = 'endtry',
+ flags = bit.bor(TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_endtry',
},
{
- command='endwhile',
- flags=bit.bor(TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_endwhile',
+ command = 'endwhile',
+ flags = bit.bor(TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_endwhile',
},
{
- command='enew',
- flags=bit.bor(BANG, TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_edit',
+ command = 'enew',
+ flags = bit.bor(BANG, TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_edit',
},
{
- command='eval',
- flags=bit.bor(EXTRA, NOTRLCOM, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_eval',
+ command = 'eval',
+ flags = bit.bor(EXTRA, NOTRLCOM, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_eval',
},
{
- command='ex',
- flags=bit.bor(BANG, FILE1, CMDARG, ARGOPT, TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_edit',
+ command = 'ex',
+ flags = bit.bor(BANG, FILE1, CMDARG, ARGOPT, TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_edit',
},
{
- command='execute',
- flags=bit.bor(EXTRA, NOTRLCOM, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_execute',
+ command = 'execute',
+ flags = bit.bor(EXTRA, NOTRLCOM, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_execute',
},
{
- command='exit',
- flags=bit.bor(RANGE, WHOLEFOLD, BANG, FILE1, ARGOPT, DFLALL, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_exit',
+ command = 'exit',
+ flags = bit.bor(RANGE, WHOLEFOLD, BANG, FILE1, ARGOPT, DFLALL, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_exit',
},
{
- command='exusage',
- flags=bit.bor(TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_exusage',
+ command = 'exusage',
+ flags = bit.bor(TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_exusage',
},
{
- command='file',
- flags=bit.bor(RANGE, ZEROR, BANG, FILE1, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_file',
+ command = 'file',
+ flags = bit.bor(RANGE, ZEROR, BANG, FILE1, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_file',
},
{
- command='files',
- flags=bit.bor(BANG, EXTRA, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='buflist_list',
+ command = 'files',
+ flags = bit.bor(BANG, EXTRA, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'buflist_list',
},
{
- command='filetype',
- flags=bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_filetype',
+ command = 'filetype',
+ flags = bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_filetype',
},
{
- command='filter',
- flags=bit.bor(BANG, NEEDARG, EXTRA, NOTRLCOM),
- addr_type='ADDR_NONE',
- func='ex_wrongmodifier',
+ command = 'filter',
+ flags = bit.bor(BANG, NEEDARG, EXTRA, NOTRLCOM),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_wrongmodifier',
},
{
- command='find',
- flags=bit.bor(RANGE, BANG, FILE1, CMDARG, ARGOPT, TRLBAR, NEEDARG),
- addr_type='ADDR_OTHER',
- func='ex_find',
+ command = 'find',
+ flags = bit.bor(RANGE, BANG, FILE1, CMDARG, ARGOPT, TRLBAR, NEEDARG),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_find',
},
{
- command='finally',
- flags=bit.bor(TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_finally',
+ command = 'finally',
+ flags = bit.bor(TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_finally',
},
{
- command='finish',
- flags=bit.bor(TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_finish',
+ command = 'finish',
+ flags = bit.bor(TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_finish',
},
{
- command='first',
- flags=bit.bor(EXTRA, BANG, CMDARG, ARGOPT, TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_rewind',
+ command = 'first',
+ flags = bit.bor(EXTRA, BANG, CMDARG, ARGOPT, TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_rewind',
},
{
- command='fold',
- flags=bit.bor(RANGE, WHOLEFOLD, TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_fold',
+ command = 'fold',
+ flags = bit.bor(RANGE, WHOLEFOLD, TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_fold',
},
{
- command='foldclose',
- flags=bit.bor(RANGE, BANG, WHOLEFOLD, TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_foldopen',
+ command = 'foldclose',
+ flags = bit.bor(RANGE, BANG, WHOLEFOLD, TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_foldopen',
},
{
- command='folddoopen',
- flags=bit.bor(RANGE, DFLALL, NEEDARG, EXTRA, NOTRLCOM),
- addr_type='ADDR_LINES',
- func='ex_folddo',
+ command = 'folddoopen',
+ flags = bit.bor(RANGE, DFLALL, NEEDARG, EXTRA, NOTRLCOM),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_folddo',
},
{
- command='folddoclosed',
- flags=bit.bor(RANGE, DFLALL, NEEDARG, EXTRA, NOTRLCOM),
- addr_type='ADDR_LINES',
- func='ex_folddo',
+ command = 'folddoclosed',
+ flags = bit.bor(RANGE, DFLALL, NEEDARG, EXTRA, NOTRLCOM),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_folddo',
},
{
- command='foldopen',
- flags=bit.bor(RANGE, BANG, WHOLEFOLD, TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_foldopen',
+ command = 'foldopen',
+ flags = bit.bor(RANGE, BANG, WHOLEFOLD, TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_foldopen',
},
{
- command='for',
- flags=bit.bor(EXTRA, NOTRLCOM, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_while',
+ command = 'for',
+ flags = bit.bor(EXTRA, NOTRLCOM, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_while',
},
{
- command='function',
- flags=bit.bor(EXTRA, BANG, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_function',
+ command = 'function',
+ flags = bit.bor(EXTRA, BANG, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_function',
},
{
- command='fclose',
- flags=bit.bor(BANG, RANGE),
- addr_type='ADDR_OTHER',
- func='ex_fclose',
+ command = 'fclose',
+ flags = bit.bor(BANG, RANGE),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_fclose',
},
{
- command='global',
- flags=bit.bor(RANGE, WHOLEFOLD, BANG, EXTRA, DFLALL, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_global',
+ command = 'global',
+ flags = bit.bor(RANGE, WHOLEFOLD, BANG, EXTRA, DFLALL, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_global',
},
{
- command='goto',
- flags=bit.bor(RANGE, COUNT, TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_OTHER',
- func='ex_goto',
+ command = 'goto',
+ flags = bit.bor(RANGE, COUNT, TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_goto',
},
{
- command='grep',
- flags=bit.bor(RANGE, BANG, NEEDARG, EXTRA, NOTRLCOM, TRLBAR, XFILE),
- addr_type='ADDR_OTHER',
- func='ex_make',
+ command = 'grep',
+ flags = bit.bor(RANGE, BANG, NEEDARG, EXTRA, NOTRLCOM, TRLBAR, XFILE),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_make',
},
{
- command='grepadd',
- flags=bit.bor(RANGE, BANG, NEEDARG, EXTRA, NOTRLCOM, TRLBAR, XFILE),
- addr_type='ADDR_OTHER',
- func='ex_make',
+ command = 'grepadd',
+ flags = bit.bor(RANGE, BANG, NEEDARG, EXTRA, NOTRLCOM, TRLBAR, XFILE),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_make',
},
{
- command='gui',
- flags=bit.bor(BANG, FILES, CMDARG, ARGOPT, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_nogui',
+ command = 'gui',
+ flags = bit.bor(BANG, FILES, CMDARG, ARGOPT, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_nogui',
},
{
- command='gvim',
- flags=bit.bor(BANG, FILES, CMDARG, ARGOPT, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_nogui',
+ command = 'gvim',
+ flags = bit.bor(BANG, FILES, CMDARG, ARGOPT, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_nogui',
},
{
- command='help',
- flags=bit.bor(BANG, EXTRA, NOTRLCOM),
- addr_type='ADDR_NONE',
- func='ex_help',
+ command = 'help',
+ flags = bit.bor(BANG, EXTRA, NOTRLCOM),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_help',
},
{
- command='helpclose',
- flags=bit.bor(RANGE, COUNT, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_helpclose',
+ command = 'helpclose',
+ flags = bit.bor(RANGE, COUNT, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_helpclose',
},
{
- command='helpgrep',
- flags=bit.bor(EXTRA, NOTRLCOM, NEEDARG),
- addr_type='ADDR_NONE',
- func='ex_helpgrep',
+ command = 'helpgrep',
+ flags = bit.bor(EXTRA, NOTRLCOM, NEEDARG),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_helpgrep',
},
{
- command='helptags',
- flags=bit.bor(NEEDARG, FILES, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_helptags',
+ command = 'helptags',
+ flags = bit.bor(NEEDARG, FILES, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_helptags',
},
{
- command='highlight',
- flags=bit.bor(BANG, EXTRA, TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_highlight',
+ command = 'highlight',
+ flags = bit.bor(BANG, EXTRA, TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_highlight',
},
{
- command='hide',
- flags=bit.bor(BANG, RANGE, COUNT, EXTRA, TRLBAR),
- addr_type='ADDR_WINDOWS',
- func='ex_hide',
+ command = 'hide',
+ flags = bit.bor(BANG, RANGE, COUNT, EXTRA, TRLBAR),
+ addr_type = 'ADDR_WINDOWS',
+ func = 'ex_hide',
},
{
- command='history',
- flags=bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_history',
+ command = 'history',
+ flags = bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_history',
},
{
- command='horizontal',
- flags=bit.bor(NEEDARG, EXTRA, NOTRLCOM),
- addr_type='ADDR_NONE',
- func='ex_wrongmodifier',
+ command = 'horizontal',
+ flags = bit.bor(NEEDARG, EXTRA, NOTRLCOM),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_wrongmodifier',
},
{
- command='insert',
- flags=bit.bor(BANG, RANGE, TRLBAR, CMDWIN, LOCK_OK, MODIFY),
- addr_type='ADDR_LINES',
- func='ex_append',
+ command = 'insert',
+ flags = bit.bor(BANG, RANGE, TRLBAR, CMDWIN, LOCK_OK, MODIFY),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_append',
},
{
- command='iabbrev',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_abbreviate',
+ command = 'iabbrev',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_abbreviate',
},
{
- command='iabclear',
- flags=bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_abclear',
+ command = 'iabclear',
+ flags = bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_abclear',
},
{
- command='if',
- flags=bit.bor(EXTRA, NOTRLCOM, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_if',
+ command = 'if',
+ flags = bit.bor(EXTRA, NOTRLCOM, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_if',
},
{
- command='ijump',
- flags=bit.bor(BANG, RANGE, DFLALL, WHOLEFOLD, EXTRA),
- addr_type='ADDR_LINES',
- func='ex_findpat',
+ command = 'ijump',
+ flags = bit.bor(BANG, RANGE, DFLALL, WHOLEFOLD, EXTRA),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_findpat',
},
{
- command='ilist',
- flags=bit.bor(BANG, RANGE, DFLALL, WHOLEFOLD, EXTRA, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_findpat',
+ command = 'ilist',
+ flags = bit.bor(BANG, RANGE, DFLALL, WHOLEFOLD, EXTRA, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_findpat',
},
{
- command='imap',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_map',
+ command = 'imap',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_map',
},
{
- command='imapclear',
- flags=bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_mapclear',
+ command = 'imapclear',
+ flags = bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_mapclear',
},
{
- command='imenu',
- flags=bit.bor(RANGE, ZEROR, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_OTHER',
- func='ex_menu',
+ command = 'imenu',
+ flags = bit.bor(RANGE, ZEROR, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_menu',
},
{
- command='inoremap',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_map',
+ command = 'inoremap',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_map',
},
{
- command='inoreabbrev',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_abbreviate',
+ command = 'inoreabbrev',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_abbreviate',
},
{
- command='inoremenu',
- flags=bit.bor(RANGE, ZEROR, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_OTHER',
- func='ex_menu',
+ command = 'inoremenu',
+ flags = bit.bor(RANGE, ZEROR, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_menu',
},
{
- command='intro',
- flags=bit.bor(TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_intro',
+ command = 'intro',
+ flags = bit.bor(TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_intro',
},
{
- command='isearch',
- flags=bit.bor(BANG, RANGE, DFLALL, WHOLEFOLD, EXTRA, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_findpat',
+ command = 'isearch',
+ flags = bit.bor(BANG, RANGE, DFLALL, WHOLEFOLD, EXTRA, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_findpat',
},
{
- command='isplit',
- flags=bit.bor(BANG, RANGE, DFLALL, WHOLEFOLD, EXTRA),
- addr_type='ADDR_LINES',
- func='ex_findpat',
+ command = 'isplit',
+ flags = bit.bor(BANG, RANGE, DFLALL, WHOLEFOLD, EXTRA),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_findpat',
},
{
- command='iunmap',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_unmap',
+ command = 'iunmap',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_unmap',
},
{
- command='iunabbrev',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_abbreviate',
+ command = 'iunabbrev',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_abbreviate',
},
{
- command='iunmenu',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_menu',
+ command = 'iunmenu',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_menu',
},
{
- command='join',
- flags=bit.bor(BANG, RANGE, WHOLEFOLD, COUNT, FLAGS, TRLBAR, CMDWIN, LOCK_OK, MODIFY),
- addr_type='ADDR_LINES',
- func='ex_join',
+ command = 'join',
+ flags = bit.bor(BANG, RANGE, WHOLEFOLD, COUNT, FLAGS, TRLBAR, CMDWIN, LOCK_OK, MODIFY),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_join',
},
{
- command='jumps',
- flags=bit.bor(TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_jumps',
+ command = 'jumps',
+ flags = bit.bor(TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_jumps',
},
{
- command='k',
- flags=bit.bor(RANGE, WORD1, TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_mark',
+ command = 'k',
+ flags = bit.bor(RANGE, WORD1, TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_mark',
},
{
- command='keepmarks',
- flags=bit.bor(NEEDARG, EXTRA, NOTRLCOM),
- addr_type='ADDR_NONE',
- func='ex_wrongmodifier',
+ command = 'keepmarks',
+ flags = bit.bor(NEEDARG, EXTRA, NOTRLCOM),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_wrongmodifier',
},
{
- command='keepjumps',
- flags=bit.bor(NEEDARG, EXTRA, NOTRLCOM),
- addr_type='ADDR_NONE',
- func='ex_wrongmodifier',
+ command = 'keepjumps',
+ flags = bit.bor(NEEDARG, EXTRA, NOTRLCOM),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_wrongmodifier',
},
{
- command='keeppatterns',
- flags=bit.bor(NEEDARG, EXTRA, NOTRLCOM),
- addr_type='ADDR_NONE',
- func='ex_wrongmodifier',
+ command = 'keeppatterns',
+ flags = bit.bor(NEEDARG, EXTRA, NOTRLCOM),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_wrongmodifier',
},
{
- command='keepalt',
- flags=bit.bor(NEEDARG, EXTRA, NOTRLCOM),
- addr_type='ADDR_NONE',
- func='ex_wrongmodifier',
+ command = 'keepalt',
+ flags = bit.bor(NEEDARG, EXTRA, NOTRLCOM),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_wrongmodifier',
},
{
- command='list',
- flags=bit.bor(RANGE, WHOLEFOLD, COUNT, FLAGS, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_print',
+ command = 'list',
+ flags = bit.bor(RANGE, WHOLEFOLD, COUNT, FLAGS, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_print',
},
{
- command='lNext',
- flags=bit.bor(RANGE, COUNT, TRLBAR, BANG),
- addr_type='ADDR_UNSIGNED',
- func='ex_cnext',
+ command = 'lNext',
+ flags = bit.bor(RANGE, COUNT, TRLBAR, BANG),
+ addr_type = 'ADDR_UNSIGNED',
+ func = 'ex_cnext',
},
{
- command='lNfile',
- flags=bit.bor(RANGE, COUNT, TRLBAR, BANG),
- addr_type='ADDR_UNSIGNED',
- func='ex_cnext',
+ command = 'lNfile',
+ flags = bit.bor(RANGE, COUNT, TRLBAR, BANG),
+ addr_type = 'ADDR_UNSIGNED',
+ func = 'ex_cnext',
},
{
- command='last',
- flags=bit.bor(EXTRA, BANG, CMDARG, ARGOPT, TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_last',
+ command = 'last',
+ flags = bit.bor(EXTRA, BANG, CMDARG, ARGOPT, TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_last',
},
{
- command='labove',
- flags=bit.bor(RANGE, COUNT, TRLBAR),
- addr_type='ADDR_UNSIGNED',
- func='ex_cbelow',
+ command = 'labove',
+ flags = bit.bor(RANGE, COUNT, TRLBAR),
+ addr_type = 'ADDR_UNSIGNED',
+ func = 'ex_cbelow',
},
{
- command='language',
- flags=bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_language',
+ command = 'language',
+ flags = bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_language',
},
{
- command='laddexpr',
- flags=bit.bor(NEEDARG, WORD1, NOTRLCOM),
- addr_type='ADDR_NONE',
- func='ex_cexpr',
+ command = 'laddexpr',
+ flags = bit.bor(NEEDARG, WORD1, NOTRLCOM),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_cexpr',
},
{
- command='laddbuffer',
- flags=bit.bor(RANGE, WORD1, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_cbuffer',
+ command = 'laddbuffer',
+ flags = bit.bor(RANGE, WORD1, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_cbuffer',
},
{
- command='laddfile',
- flags=bit.bor(TRLBAR, FILE1),
- addr_type='ADDR_NONE',
- func='ex_cfile',
+ command = 'laddfile',
+ flags = bit.bor(TRLBAR, FILE1),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_cfile',
},
{
- command='lafter',
- flags=bit.bor(RANGE, COUNT, TRLBAR),
- addr_type='ADDR_UNSIGNED',
- func='ex_cbelow',
+ command = 'lafter',
+ flags = bit.bor(RANGE, COUNT, TRLBAR),
+ addr_type = 'ADDR_UNSIGNED',
+ func = 'ex_cbelow',
},
{
- command='later',
- flags=bit.bor(TRLBAR, EXTRA, NOSPC, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_later',
+ command = 'later',
+ flags = bit.bor(TRLBAR, EXTRA, NOSPC, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_later',
},
{
- command='lbuffer',
- flags=bit.bor(BANG, RANGE, WORD1, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_cbuffer',
+ command = 'lbuffer',
+ flags = bit.bor(BANG, RANGE, WORD1, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_cbuffer',
},
{
- command='lbefore',
- flags=bit.bor(RANGE, COUNT, TRLBAR),
- addr_type='ADDR_UNSIGNED',
- func='ex_cbelow',
+ command = 'lbefore',
+ flags = bit.bor(RANGE, COUNT, TRLBAR),
+ addr_type = 'ADDR_UNSIGNED',
+ func = 'ex_cbelow',
},
{
- command='lbelow',
- flags=bit.bor(RANGE, COUNT, TRLBAR),
- addr_type='ADDR_UNSIGNED',
- func='ex_cbelow',
+ command = 'lbelow',
+ flags = bit.bor(RANGE, COUNT, TRLBAR),
+ addr_type = 'ADDR_UNSIGNED',
+ func = 'ex_cbelow',
},
{
- command='lbottom',
- flags=bit.bor(TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_cbottom',
+ command = 'lbottom',
+ flags = bit.bor(TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_cbottom',
},
{
- command='lcd',
- flags=bit.bor(BANG, FILE1, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_cd',
+ command = 'lcd',
+ flags = bit.bor(BANG, FILE1, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_cd',
},
{
- command='lchdir',
- flags=bit.bor(BANG, FILE1, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_cd',
+ command = 'lchdir',
+ flags = bit.bor(BANG, FILE1, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_cd',
},
{
- command='lclose',
- flags=bit.bor(RANGE, COUNT, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_cclose',
+ command = 'lclose',
+ flags = bit.bor(RANGE, COUNT, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_cclose',
},
{
- command='ldo',
- flags=bit.bor(BANG, NEEDARG, EXTRA, NOTRLCOM, RANGE, DFLALL),
- addr_type='ADDR_QUICKFIX_VALID',
- func='ex_listdo',
+ command = 'ldo',
+ flags = bit.bor(BANG, NEEDARG, EXTRA, NOTRLCOM, RANGE, DFLALL),
+ addr_type = 'ADDR_QUICKFIX_VALID',
+ func = 'ex_listdo',
},
{
- command='left',
- flags=bit.bor(TRLBAR, RANGE, WHOLEFOLD, EXTRA, CMDWIN, LOCK_OK, MODIFY),
- addr_type='ADDR_LINES',
- func='ex_align',
+ command = 'left',
+ flags = bit.bor(TRLBAR, RANGE, WHOLEFOLD, EXTRA, CMDWIN, LOCK_OK, MODIFY),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_align',
},
{
- command='leftabove',
- flags=bit.bor(NEEDARG, EXTRA, NOTRLCOM),
- addr_type='ADDR_NONE',
- func='ex_wrongmodifier',
+ command = 'leftabove',
+ flags = bit.bor(NEEDARG, EXTRA, NOTRLCOM),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_wrongmodifier',
},
{
- command='let',
- flags=bit.bor(EXTRA, NOTRLCOM, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_let',
+ command = 'let',
+ flags = bit.bor(EXTRA, NOTRLCOM, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_let',
},
{
- command='lexpr',
- flags=bit.bor(NEEDARG, WORD1, NOTRLCOM, BANG),
- addr_type='ADDR_NONE',
- func='ex_cexpr',
+ command = 'lexpr',
+ flags = bit.bor(NEEDARG, WORD1, NOTRLCOM, BANG),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_cexpr',
},
{
- command='lfile',
- flags=bit.bor(TRLBAR, FILE1, BANG),
- addr_type='ADDR_NONE',
- func='ex_cfile',
+ command = 'lfile',
+ flags = bit.bor(TRLBAR, FILE1, BANG),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_cfile',
},
-- Even though 'lfdo' is alphabetically lower than 'lfile', it is after
-- 'lfile' in this cmd list to support the existing ":lf" abbreviation.
{
- command='lfdo',
- flags=bit.bor(BANG, NEEDARG, EXTRA, NOTRLCOM, RANGE, DFLALL),
- addr_type='ADDR_QUICKFIX_VALID',
- func='ex_listdo',
+ command = 'lfdo',
+ flags = bit.bor(BANG, NEEDARG, EXTRA, NOTRLCOM, RANGE, DFLALL),
+ addr_type = 'ADDR_QUICKFIX_VALID',
+ func = 'ex_listdo',
},
{
- command='lfirst',
- flags=bit.bor(RANGE, COUNT, TRLBAR, BANG),
- addr_type='ADDR_UNSIGNED',
- func='ex_cc',
+ command = 'lfirst',
+ flags = bit.bor(RANGE, COUNT, TRLBAR, BANG),
+ addr_type = 'ADDR_UNSIGNED',
+ func = 'ex_cc',
},
{
- command='lgetfile',
- flags=bit.bor(TRLBAR, FILE1),
- addr_type='ADDR_NONE',
- func='ex_cfile',
+ command = 'lgetfile',
+ flags = bit.bor(TRLBAR, FILE1),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_cfile',
},
{
- command='lgetbuffer',
- flags=bit.bor(RANGE, WORD1, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_cbuffer',
+ command = 'lgetbuffer',
+ flags = bit.bor(RANGE, WORD1, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_cbuffer',
},
{
- command='lgetexpr',
- flags=bit.bor(NEEDARG, WORD1, NOTRLCOM),
- addr_type='ADDR_NONE',
- func='ex_cexpr',
+ command = 'lgetexpr',
+ flags = bit.bor(NEEDARG, WORD1, NOTRLCOM),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_cexpr',
},
{
- command='lgrep',
- flags=bit.bor(RANGE, BANG, NEEDARG, EXTRA, NOTRLCOM, TRLBAR, XFILE),
- addr_type='ADDR_OTHER',
- func='ex_make',
+ command = 'lgrep',
+ flags = bit.bor(RANGE, BANG, NEEDARG, EXTRA, NOTRLCOM, TRLBAR, XFILE),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_make',
},
{
- command='lgrepadd',
- flags=bit.bor(RANGE, BANG, NEEDARG, EXTRA, NOTRLCOM, TRLBAR, XFILE),
- addr_type='ADDR_OTHER',
- func='ex_make',
+ command = 'lgrepadd',
+ flags = bit.bor(RANGE, BANG, NEEDARG, EXTRA, NOTRLCOM, TRLBAR, XFILE),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_make',
},
{
- command='lhelpgrep',
- flags=bit.bor(EXTRA, NOTRLCOM, NEEDARG),
- addr_type='ADDR_NONE',
- func='ex_helpgrep',
+ command = 'lhelpgrep',
+ flags = bit.bor(EXTRA, NOTRLCOM, NEEDARG),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_helpgrep',
},
{
- command='lhistory',
- flags=bit.bor(RANGE, COUNT, TRLBAR),
- addr_type='ADDR_UNSIGNED',
- func='qf_history',
+ command = 'lhistory',
+ flags = bit.bor(RANGE, COUNT, TRLBAR),
+ addr_type = 'ADDR_UNSIGNED',
+ func = 'qf_history',
},
{
- command='ll',
- flags=bit.bor(RANGE, COUNT, TRLBAR, BANG),
- addr_type='ADDR_QUICKFIX',
- func='ex_cc',
+ command = 'll',
+ flags = bit.bor(RANGE, COUNT, TRLBAR, BANG),
+ addr_type = 'ADDR_QUICKFIX',
+ func = 'ex_cc',
},
{
- command='llast',
- flags=bit.bor(RANGE, COUNT, TRLBAR, BANG),
- addr_type='ADDR_UNSIGNED',
- func='ex_cc',
+ command = 'llast',
+ flags = bit.bor(RANGE, COUNT, TRLBAR, BANG),
+ addr_type = 'ADDR_UNSIGNED',
+ func = 'ex_cc',
},
{
- command='llist',
- flags=bit.bor(BANG, EXTRA, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='qf_list',
+ command = 'llist',
+ flags = bit.bor(BANG, EXTRA, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'qf_list',
},
{
- command='lmap',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_map',
+ command = 'lmap',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_map',
},
{
- command='lmapclear',
- flags=bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_mapclear',
+ command = 'lmapclear',
+ flags = bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_mapclear',
},
{
- command='lmake',
- flags=bit.bor(BANG, EXTRA, NOTRLCOM, TRLBAR, XFILE),
- addr_type='ADDR_NONE',
- func='ex_make',
+ command = 'lmake',
+ flags = bit.bor(BANG, EXTRA, NOTRLCOM, TRLBAR, XFILE),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_make',
},
{
- command='lnoremap',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_map',
+ command = 'lnoremap',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_map',
},
{
- command='lnext',
- flags=bit.bor(RANGE, COUNT, TRLBAR, BANG),
- addr_type='ADDR_UNSIGNED',
- func='ex_cnext',
+ command = 'lnext',
+ flags = bit.bor(RANGE, COUNT, TRLBAR, BANG),
+ addr_type = 'ADDR_UNSIGNED',
+ func = 'ex_cnext',
},
{
- command='lnewer',
- flags=bit.bor(RANGE, COUNT, TRLBAR),
- addr_type='ADDR_UNSIGNED',
- func='qf_age',
+ command = 'lnewer',
+ flags = bit.bor(RANGE, COUNT, TRLBAR),
+ addr_type = 'ADDR_UNSIGNED',
+ func = 'qf_age',
},
{
- command='lnfile',
- flags=bit.bor(RANGE, COUNT, TRLBAR, BANG),
- addr_type='ADDR_UNSIGNED',
- func='ex_cnext',
+ command = 'lnfile',
+ flags = bit.bor(RANGE, COUNT, TRLBAR, BANG),
+ addr_type = 'ADDR_UNSIGNED',
+ func = 'ex_cnext',
},
{
- command='loadview',
- flags=bit.bor(FILE1, TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_loadview',
+ command = 'loadview',
+ flags = bit.bor(FILE1, TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_loadview',
},
{
- command='loadkeymap',
- flags=bit.bor(CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_loadkeymap',
+ command = 'loadkeymap',
+ flags = bit.bor(CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_loadkeymap',
},
{
- command='lockmarks',
- flags=bit.bor(NEEDARG, EXTRA, NOTRLCOM),
- addr_type='ADDR_NONE',
- func='ex_wrongmodifier',
+ command = 'lockmarks',
+ flags = bit.bor(NEEDARG, EXTRA, NOTRLCOM),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_wrongmodifier',
},
{
- command='lockvar',
- flags=bit.bor(BANG, EXTRA, NEEDARG, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_lockvar',
+ command = 'lockvar',
+ flags = bit.bor(BANG, EXTRA, NEEDARG, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_lockvar',
},
{
- command='lolder',
- flags=bit.bor(RANGE, COUNT, TRLBAR),
- addr_type='ADDR_UNSIGNED',
- func='qf_age',
+ command = 'lolder',
+ flags = bit.bor(RANGE, COUNT, TRLBAR),
+ addr_type = 'ADDR_UNSIGNED',
+ func = 'qf_age',
},
{
- command='lopen',
- flags=bit.bor(RANGE, COUNT, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_copen',
+ command = 'lopen',
+ flags = bit.bor(RANGE, COUNT, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_copen',
},
{
- command='lprevious',
- flags=bit.bor(RANGE, COUNT, TRLBAR, BANG),
- addr_type='ADDR_UNSIGNED',
- func='ex_cnext',
+ command = 'lprevious',
+ flags = bit.bor(RANGE, COUNT, TRLBAR, BANG),
+ addr_type = 'ADDR_UNSIGNED',
+ func = 'ex_cnext',
},
{
- command='lpfile',
- flags=bit.bor(RANGE, COUNT, TRLBAR, BANG),
- addr_type='ADDR_OTHER',
- func='ex_cnext',
+ command = 'lpfile',
+ flags = bit.bor(RANGE, COUNT, TRLBAR, BANG),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_cnext',
},
{
- command='lrewind',
- flags=bit.bor(RANGE, COUNT, TRLBAR, BANG),
- addr_type='ADDR_UNSIGNED',
- func='ex_cc',
+ command = 'lrewind',
+ flags = bit.bor(RANGE, COUNT, TRLBAR, BANG),
+ addr_type = 'ADDR_UNSIGNED',
+ func = 'ex_cc',
},
{
- command='ltag',
- flags=bit.bor(TRLBAR, BANG, WORD1),
- addr_type='ADDR_NONE',
- func='ex_tag',
+ command = 'ltag',
+ flags = bit.bor(TRLBAR, BANG, WORD1),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_tag',
},
{
- command='lunmap',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_unmap',
+ command = 'lunmap',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_unmap',
},
{
- command='lua',
- flags=bit.bor(RANGE, EXTRA, NEEDARG, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_lua',
+ command = 'lua',
+ flags = bit.bor(RANGE, EXTRA, NEEDARG, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_lua',
},
{
- command='luado',
- flags=bit.bor(RANGE, DFLALL, EXTRA, NEEDARG, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_luado',
+ command = 'luado',
+ flags = bit.bor(RANGE, DFLALL, EXTRA, NEEDARG, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_luado',
},
{
- command='luafile',
- flags=bit.bor(RANGE, FILE1, NEEDARG, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_luafile',
+ command = 'luafile',
+ flags = bit.bor(RANGE, FILE1, NEEDARG, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_luafile',
},
{
- command='lvimgrep',
- flags=bit.bor(RANGE, BANG, NEEDARG, EXTRA, NOTRLCOM, TRLBAR, XFILE, LOCK_OK),
- addr_type='ADDR_OTHER',
- func='ex_vimgrep',
+ command = 'lvimgrep',
+ flags = bit.bor(RANGE, BANG, NEEDARG, EXTRA, NOTRLCOM, TRLBAR, XFILE, LOCK_OK),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_vimgrep',
},
{
- command='lvimgrepadd',
- flags=bit.bor(RANGE, BANG, NEEDARG, EXTRA, NOTRLCOM, TRLBAR, XFILE, LOCK_OK),
- addr_type='ADDR_OTHER',
- func='ex_vimgrep',
+ command = 'lvimgrepadd',
+ flags = bit.bor(RANGE, BANG, NEEDARG, EXTRA, NOTRLCOM, TRLBAR, XFILE, LOCK_OK),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_vimgrep',
},
{
- command='lwindow',
- flags=bit.bor(RANGE, COUNT, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_cwindow',
+ command = 'lwindow',
+ flags = bit.bor(RANGE, COUNT, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_cwindow',
},
{
- command='ls',
- flags=bit.bor(BANG, EXTRA, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='buflist_list',
+ command = 'ls',
+ flags = bit.bor(BANG, EXTRA, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'buflist_list',
},
{
- command='move',
- flags=bit.bor(RANGE, WHOLEFOLD, EXTRA, TRLBAR, CMDWIN, LOCK_OK, MODIFY),
- addr_type='ADDR_LINES',
- func='ex_copymove',
+ command = 'move',
+ flags = bit.bor(RANGE, WHOLEFOLD, EXTRA, TRLBAR, CMDWIN, LOCK_OK, MODIFY),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_copymove',
},
{
- command='mark',
- flags=bit.bor(RANGE, WORD1, TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_mark',
+ command = 'mark',
+ flags = bit.bor(RANGE, WORD1, TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_mark',
},
{
- command='make',
- flags=bit.bor(BANG, EXTRA, NOTRLCOM, TRLBAR, XFILE),
- addr_type='ADDR_NONE',
- func='ex_make',
+ command = 'make',
+ flags = bit.bor(BANG, EXTRA, NOTRLCOM, TRLBAR, XFILE),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_make',
},
{
- command='map',
- flags=bit.bor(BANG, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_map',
+ command = 'map',
+ flags = bit.bor(BANG, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_map',
},
{
- command='mapclear',
- flags=bit.bor(EXTRA, BANG, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_mapclear',
+ command = 'mapclear',
+ flags = bit.bor(EXTRA, BANG, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_mapclear',
},
{
- command='marks',
- flags=bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_marks',
+ command = 'marks',
+ flags = bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_marks',
},
{
- command='match',
- flags=bit.bor(RANGE, EXTRA, CMDWIN, LOCK_OK),
- addr_type='ADDR_OTHER',
- func='ex_match',
+ command = 'match',
+ flags = bit.bor(RANGE, EXTRA, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_match',
},
{
- command='menu',
- flags=bit.bor(RANGE, ZEROR, BANG, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_OTHER',
- func='ex_menu',
+ command = 'menu',
+ flags = bit.bor(RANGE, ZEROR, BANG, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_menu',
},
{
- command='menutranslate',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_menutranslate',
+ command = 'menutranslate',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_menutranslate',
},
{
- command='messages',
- flags=bit.bor(EXTRA, TRLBAR, RANGE, CMDWIN, LOCK_OK),
- addr_type='ADDR_OTHER',
- func='ex_messages',
+ command = 'messages',
+ flags = bit.bor(EXTRA, TRLBAR, RANGE, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_messages',
},
{
- command='mkexrc',
- flags=bit.bor(BANG, FILE1, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_mkrc',
+ command = 'mkexrc',
+ flags = bit.bor(BANG, FILE1, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_mkrc',
},
{
- command='mksession',
- flags=bit.bor(BANG, FILE1, TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_mkrc',
+ command = 'mksession',
+ flags = bit.bor(BANG, FILE1, TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_mkrc',
},
{
- command='mkspell',
- flags=bit.bor(BANG, NEEDARG, EXTRA, NOTRLCOM, TRLBAR, XFILE),
- addr_type='ADDR_NONE',
- func='ex_mkspell',
+ command = 'mkspell',
+ flags = bit.bor(BANG, NEEDARG, EXTRA, NOTRLCOM, TRLBAR, XFILE),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_mkspell',
},
{
- command='mkvimrc',
- flags=bit.bor(BANG, FILE1, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_mkrc',
+ command = 'mkvimrc',
+ flags = bit.bor(BANG, FILE1, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_mkrc',
},
{
- command='mkview',
- flags=bit.bor(BANG, FILE1, TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_mkrc',
+ command = 'mkview',
+ flags = bit.bor(BANG, FILE1, TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_mkrc',
},
{
- command='mode',
- flags=bit.bor(WORD1, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_mode',
+ command = 'mode',
+ flags = bit.bor(WORD1, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_mode',
},
{
- command='mzscheme',
- flags=bit.bor(RANGE, EXTRA, DFLALL, NEEDARG, CMDWIN, LOCK_OK, SBOXOK),
- addr_type='ADDR_LINES',
- func='ex_script_ni',
+ command = 'mzscheme',
+ flags = bit.bor(RANGE, EXTRA, DFLALL, NEEDARG, CMDWIN, LOCK_OK, SBOXOK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_script_ni',
},
{
- command='mzfile',
- flags=bit.bor(RANGE, FILE1, NEEDARG, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_ni',
+ command = 'mzfile',
+ flags = bit.bor(RANGE, FILE1, NEEDARG, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_ni',
},
{
- command='next',
- flags=bit.bor(RANGE, BANG, FILES, CMDARG, ARGOPT, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_next',
+ command = 'next',
+ flags = bit.bor(RANGE, BANG, FILES, CMDARG, ARGOPT, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_next',
},
{
- command='new',
- flags=bit.bor(BANG, FILE1, RANGE, CMDARG, ARGOPT, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_splitview',
+ command = 'new',
+ flags = bit.bor(BANG, FILE1, RANGE, CMDARG, ARGOPT, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_splitview',
},
{
- command='nmap',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_map',
+ command = 'nmap',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_map',
},
{
- command='nmapclear',
- flags=bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_mapclear',
+ command = 'nmapclear',
+ flags = bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_mapclear',
},
{
- command='nmenu',
- flags=bit.bor(RANGE, ZEROR, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_OTHER',
- func='ex_menu',
+ command = 'nmenu',
+ flags = bit.bor(RANGE, ZEROR, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_menu',
},
{
- command='nnoremap',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_map',
+ command = 'nnoremap',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_map',
},
{
- command='nnoremenu',
- flags=bit.bor(RANGE, ZEROR, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_OTHER',
- func='ex_menu',
+ command = 'nnoremenu',
+ flags = bit.bor(RANGE, ZEROR, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_menu',
},
{
- command='noremap',
- flags=bit.bor(BANG, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_map',
+ command = 'noremap',
+ flags = bit.bor(BANG, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_map',
},
{
- command='noautocmd',
- flags=bit.bor(NEEDARG, EXTRA, NOTRLCOM),
- addr_type='ADDR_NONE',
- func='ex_wrongmodifier',
+ command = 'noautocmd',
+ flags = bit.bor(NEEDARG, EXTRA, NOTRLCOM),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_wrongmodifier',
},
{
- command='nohlsearch',
- flags=bit.bor(TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_nohlsearch',
+ command = 'nohlsearch',
+ flags = bit.bor(TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_nohlsearch',
},
{
- command='noreabbrev',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_abbreviate',
+ command = 'noreabbrev',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_abbreviate',
},
{
- command='noremenu',
- flags=bit.bor(RANGE, ZEROR, BANG, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_OTHER',
- func='ex_menu',
+ command = 'noremenu',
+ flags = bit.bor(RANGE, ZEROR, BANG, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_menu',
},
{
- command='noswapfile',
- flags=bit.bor(NEEDARG, EXTRA, NOTRLCOM),
- addr_type='ADDR_NONE',
- func='ex_wrongmodifier',
+ command = 'noswapfile',
+ flags = bit.bor(NEEDARG, EXTRA, NOTRLCOM),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_wrongmodifier',
},
{
- command='normal',
- flags=bit.bor(RANGE, BANG, EXTRA, NEEDARG, NOTRLCOM, CTRLV, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_normal',
+ command = 'normal',
+ flags = bit.bor(RANGE, BANG, EXTRA, NEEDARG, NOTRLCOM, CTRLV, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_normal',
},
{
- command='number',
- flags=bit.bor(RANGE, WHOLEFOLD, COUNT, FLAGS, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_print',
+ command = 'number',
+ flags = bit.bor(RANGE, WHOLEFOLD, COUNT, FLAGS, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_print',
},
{
- command='nunmap',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_unmap',
+ command = 'nunmap',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_unmap',
},
{
- command='nunmenu',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_menu',
+ command = 'nunmenu',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_menu',
},
{
- command='oldfiles',
- flags=bit.bor(BANG, TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_oldfiles',
+ command = 'oldfiles',
+ flags = bit.bor(BANG, TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_oldfiles',
},
{
- command='omap',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_map',
+ command = 'omap',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_map',
},
{
- command='omapclear',
- flags=bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_mapclear',
+ command = 'omapclear',
+ flags = bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_mapclear',
},
{
- command='omenu',
- flags=bit.bor(RANGE, ZEROR, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_OTHER',
- func='ex_menu',
+ command = 'omenu',
+ flags = bit.bor(RANGE, ZEROR, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_menu',
},
{
- command='only',
- flags=bit.bor(BANG, RANGE, COUNT, TRLBAR),
- addr_type='ADDR_WINDOWS',
- func='ex_only',
+ command = 'only',
+ flags = bit.bor(BANG, RANGE, COUNT, TRLBAR),
+ addr_type = 'ADDR_WINDOWS',
+ func = 'ex_only',
},
{
- command='onoremap',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_map',
+ command = 'onoremap',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_map',
},
{
- command='onoremenu',
- flags=bit.bor(RANGE, ZEROR, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_OTHER',
- func='ex_menu',
+ command = 'onoremenu',
+ flags = bit.bor(RANGE, ZEROR, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_menu',
},
{
- command='options',
- flags=bit.bor(TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_options',
+ command = 'options',
+ flags = bit.bor(TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_options',
},
{
- command='ounmap',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_unmap',
+ command = 'ounmap',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_unmap',
},
{
- command='ounmenu',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_menu',
+ command = 'ounmenu',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_menu',
},
{
- command='ownsyntax',
- flags=bit.bor(EXTRA, NOTRLCOM, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_ownsyntax',
+ command = 'ownsyntax',
+ flags = bit.bor(EXTRA, NOTRLCOM, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_ownsyntax',
},
{
- command='print',
- flags=bit.bor(RANGE, WHOLEFOLD, COUNT, FLAGS, TRLBAR, CMDWIN, LOCK_OK, SBOXOK),
- addr_type='ADDR_LINES',
- func='ex_print',
+ command = 'print',
+ flags = bit.bor(RANGE, WHOLEFOLD, COUNT, FLAGS, TRLBAR, CMDWIN, LOCK_OK, SBOXOK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_print',
},
{
- command='packadd',
- flags=bit.bor(BANG, FILE1, NEEDARG, TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_packadd',
+ command = 'packadd',
+ flags = bit.bor(BANG, FILE1, NEEDARG, TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_packadd',
},
{
- command='packloadall',
- flags=bit.bor(BANG, TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_packloadall',
+ command = 'packloadall',
+ flags = bit.bor(BANG, TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_packloadall',
},
{
- command='pclose',
- flags=bit.bor(BANG, TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_pclose',
+ command = 'pclose',
+ flags = bit.bor(BANG, TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_pclose',
},
{
- command='perl',
- flags=bit.bor(RANGE, EXTRA, DFLALL, NEEDARG, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_perl',
+ command = 'perl',
+ flags = bit.bor(RANGE, EXTRA, DFLALL, NEEDARG, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_perl',
},
{
- command='perldo',
- flags=bit.bor(RANGE, EXTRA, DFLALL, NEEDARG, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_perldo',
+ command = 'perldo',
+ flags = bit.bor(RANGE, EXTRA, DFLALL, NEEDARG, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_perldo',
},
{
- command='perlfile',
- flags=bit.bor(RANGE, FILE1, NEEDARG, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_perlfile',
+ command = 'perlfile',
+ flags = bit.bor(RANGE, FILE1, NEEDARG, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_perlfile',
},
{
- command='pedit',
- flags=bit.bor(BANG, FILE1, CMDARG, ARGOPT, TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_pedit',
+ command = 'pedit',
+ flags = bit.bor(BANG, FILE1, CMDARG, ARGOPT, TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_pedit',
},
{
- command='pop',
- flags=bit.bor(RANGE, BANG, COUNT, TRLBAR, ZEROR),
- addr_type='ADDR_OTHER',
- func='ex_tag',
+ command = 'pop',
+ flags = bit.bor(RANGE, BANG, COUNT, TRLBAR, ZEROR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_tag',
},
{
- command='popup',
- flags=bit.bor(NEEDARG, EXTRA, BANG, TRLBAR, NOTRLCOM, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_popup',
+ command = 'popup',
+ flags = bit.bor(NEEDARG, EXTRA, BANG, TRLBAR, NOTRLCOM, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_popup',
},
{
- command='ppop',
- flags=bit.bor(RANGE, BANG, COUNT, TRLBAR, ZEROR),
- addr_type='ADDR_OTHER',
- func='ex_ptag',
+ command = 'ppop',
+ flags = bit.bor(RANGE, BANG, COUNT, TRLBAR, ZEROR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_ptag',
},
{
- command='preserve',
- flags=bit.bor(TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_preserve',
+ command = 'preserve',
+ flags = bit.bor(TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_preserve',
},
{
- command='previous',
- flags=bit.bor(EXTRA, RANGE, COUNT, BANG, CMDARG, ARGOPT, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_previous',
+ command = 'previous',
+ flags = bit.bor(EXTRA, RANGE, COUNT, BANG, CMDARG, ARGOPT, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_previous',
},
{
- command='profile',
- flags=bit.bor(BANG, EXTRA, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_profile',
+ command = 'profile',
+ flags = bit.bor(BANG, EXTRA, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_profile',
},
{
- command='profdel',
- flags=bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_breakdel',
+ command = 'profdel',
+ flags = bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_breakdel',
},
{
- command='psearch',
- flags=bit.bor(BANG, RANGE, WHOLEFOLD, DFLALL, EXTRA),
- addr_type='ADDR_LINES',
- func='ex_psearch',
+ command = 'psearch',
+ flags = bit.bor(BANG, RANGE, WHOLEFOLD, DFLALL, EXTRA),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_psearch',
},
{
- command='ptag',
- flags=bit.bor(RANGE, BANG, WORD1, TRLBAR, ZEROR),
- addr_type='ADDR_OTHER',
- func='ex_ptag',
+ command = 'ptag',
+ flags = bit.bor(RANGE, BANG, WORD1, TRLBAR, ZEROR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_ptag',
},
{
- command='ptNext',
- flags=bit.bor(RANGE, BANG, TRLBAR, ZEROR),
- addr_type='ADDR_OTHER',
- func='ex_ptag',
+ command = 'ptNext',
+ flags = bit.bor(RANGE, BANG, TRLBAR, ZEROR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_ptag',
},
{
- command='ptfirst',
- flags=bit.bor(RANGE, BANG, TRLBAR, ZEROR),
- addr_type='ADDR_OTHER',
- func='ex_ptag',
+ command = 'ptfirst',
+ flags = bit.bor(RANGE, BANG, TRLBAR, ZEROR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_ptag',
},
{
- command='ptjump',
- flags=bit.bor(BANG, TRLBAR, WORD1),
- addr_type='ADDR_NONE',
- func='ex_ptag',
+ command = 'ptjump',
+ flags = bit.bor(BANG, TRLBAR, WORD1),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_ptag',
},
{
- command='ptlast',
- flags=bit.bor(BANG, TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_ptag',
+ command = 'ptlast',
+ flags = bit.bor(BANG, TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_ptag',
},
{
- command='ptnext',
- flags=bit.bor(RANGE, BANG, TRLBAR, ZEROR),
- addr_type='ADDR_OTHER',
- func='ex_ptag',
+ command = 'ptnext',
+ flags = bit.bor(RANGE, BANG, TRLBAR, ZEROR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_ptag',
},
{
- command='ptprevious',
- flags=bit.bor(RANGE, BANG, TRLBAR, ZEROR),
- addr_type='ADDR_OTHER',
- func='ex_ptag',
+ command = 'ptprevious',
+ flags = bit.bor(RANGE, BANG, TRLBAR, ZEROR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_ptag',
},
{
- command='ptrewind',
- flags=bit.bor(RANGE, BANG, TRLBAR, ZEROR),
- addr_type='ADDR_OTHER',
- func='ex_ptag',
+ command = 'ptrewind',
+ flags = bit.bor(RANGE, BANG, TRLBAR, ZEROR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_ptag',
},
{
- command='ptselect',
- flags=bit.bor(BANG, TRLBAR, WORD1),
- addr_type='ADDR_NONE',
- func='ex_ptag',
+ command = 'ptselect',
+ flags = bit.bor(BANG, TRLBAR, WORD1),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_ptag',
},
{
- command='put',
- flags=bit.bor(RANGE, WHOLEFOLD, BANG, REGSTR, TRLBAR, ZEROR, CMDWIN, LOCK_OK, MODIFY),
- addr_type='ADDR_LINES',
- func='ex_put',
+ command = 'put',
+ flags = bit.bor(RANGE, WHOLEFOLD, BANG, REGSTR, TRLBAR, ZEROR, CMDWIN, LOCK_OK, MODIFY),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_put',
},
{
- command='pwd',
- flags=bit.bor(TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_pwd',
+ command = 'pwd',
+ flags = bit.bor(TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_pwd',
},
{
- command='python',
- flags=bit.bor(RANGE, EXTRA, NEEDARG, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_python3',
+ command = 'python',
+ flags = bit.bor(RANGE, EXTRA, NEEDARG, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_python3',
},
{
- command='pydo',
- flags=bit.bor(RANGE, DFLALL, EXTRA, NEEDARG, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_pydo3',
+ command = 'pydo',
+ flags = bit.bor(RANGE, DFLALL, EXTRA, NEEDARG, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_pydo3',
},
{
- command='pyfile',
- flags=bit.bor(RANGE, FILE1, NEEDARG, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_py3file',
+ command = 'pyfile',
+ flags = bit.bor(RANGE, FILE1, NEEDARG, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_py3file',
},
{
- command='py3',
- flags=bit.bor(RANGE, EXTRA, NEEDARG, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_python3',
+ command = 'py3',
+ flags = bit.bor(RANGE, EXTRA, NEEDARG, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_python3',
},
{
- command='py3do',
- flags=bit.bor(RANGE, DFLALL, EXTRA, NEEDARG, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_pydo3',
+ command = 'py3do',
+ flags = bit.bor(RANGE, DFLALL, EXTRA, NEEDARG, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_pydo3',
},
{
- command='python3',
- flags=bit.bor(RANGE, EXTRA, NEEDARG, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_python3',
+ command = 'python3',
+ flags = bit.bor(RANGE, EXTRA, NEEDARG, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_python3',
},
{
- command='py3file',
- flags=bit.bor(RANGE, FILE1, NEEDARG, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_py3file',
+ command = 'py3file',
+ flags = bit.bor(RANGE, FILE1, NEEDARG, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_py3file',
},
{
- command='pyx',
- flags=bit.bor(RANGE, EXTRA, NEEDARG, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_python3',
+ command = 'pyx',
+ flags = bit.bor(RANGE, EXTRA, NEEDARG, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_python3',
},
{
- command='pyxdo',
- flags=bit.bor(RANGE, DFLALL, EXTRA, NEEDARG, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_pydo3',
+ command = 'pyxdo',
+ flags = bit.bor(RANGE, DFLALL, EXTRA, NEEDARG, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_pydo3',
},
{
- command='pythonx',
- flags=bit.bor(RANGE, EXTRA, NEEDARG, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_python3',
+ command = 'pythonx',
+ flags = bit.bor(RANGE, EXTRA, NEEDARG, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_python3',
},
{
- command='pyxfile',
- flags=bit.bor(RANGE, FILE1, NEEDARG, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_py3file',
+ command = 'pyxfile',
+ flags = bit.bor(RANGE, FILE1, NEEDARG, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_py3file',
},
{
- command='quit',
- flags=bit.bor(BANG, RANGE, COUNT, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_WINDOWS',
- func='ex_quit',
+ command = 'quit',
+ flags = bit.bor(BANG, RANGE, COUNT, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_WINDOWS',
+ func = 'ex_quit',
},
{
- command='quitall',
- flags=bit.bor(BANG, TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_quit_all',
+ command = 'quitall',
+ flags = bit.bor(BANG, TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_quit_all',
},
{
- command='qall',
- flags=bit.bor(BANG, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_quit_all',
+ command = 'qall',
+ flags = bit.bor(BANG, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_quit_all',
},
{
- command='read',
- flags=bit.bor(BANG, RANGE, WHOLEFOLD, FILE1, ARGOPT, TRLBAR, ZEROR, CMDWIN, LOCK_OK, MODIFY),
- addr_type='ADDR_LINES',
- func='ex_read',
+ command = 'read',
+ flags = bit.bor(BANG, RANGE, WHOLEFOLD, FILE1, ARGOPT, TRLBAR, ZEROR, CMDWIN, LOCK_OK, MODIFY),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_read',
},
{
- command='recover',
- flags=bit.bor(BANG, FILE1, TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_recover',
+ command = 'recover',
+ flags = bit.bor(BANG, FILE1, TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_recover',
},
{
- command='redo',
- flags=bit.bor(TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_redo',
+ command = 'redo',
+ flags = bit.bor(TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_redo',
},
{
- command='redir',
- flags=bit.bor(BANG, FILES, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_redir',
+ command = 'redir',
+ flags = bit.bor(BANG, FILES, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_redir',
},
{
- command='redraw',
- flags=bit.bor(BANG, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_redraw',
+ command = 'redraw',
+ flags = bit.bor(BANG, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_redraw',
},
{
- command='redrawstatus',
- flags=bit.bor(BANG, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_redrawstatus',
+ command = 'redrawstatus',
+ flags = bit.bor(BANG, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_redrawstatus',
},
{
- command='redrawtabline',
- flags=bit.bor(TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_redrawtabline',
+ command = 'redrawtabline',
+ flags = bit.bor(TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_redrawtabline',
},
{
- command='registers',
- flags=bit.bor(EXTRA, NOTRLCOM, TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_display',
+ command = 'registers',
+ flags = bit.bor(EXTRA, NOTRLCOM, TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_display',
},
{
- command='resize',
- flags=bit.bor(RANGE, TRLBAR, WORD1, CMDWIN, LOCK_OK),
- addr_type='ADDR_OTHER',
- func='ex_resize',
+ command = 'resize',
+ flags = bit.bor(RANGE, TRLBAR, WORD1, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_resize',
},
{
- command='retab',
- flags=bit.bor(TRLBAR, RANGE, WHOLEFOLD, DFLALL, BANG, WORD1, CMDWIN, LOCK_OK, MODIFY),
- addr_type='ADDR_LINES',
- func='ex_retab',
+ command = 'retab',
+ flags = bit.bor(TRLBAR, RANGE, WHOLEFOLD, DFLALL, BANG, WORD1, CMDWIN, LOCK_OK, MODIFY),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_retab',
},
{
- command='return',
- flags=bit.bor(EXTRA, NOTRLCOM, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_return',
+ command = 'return',
+ flags = bit.bor(EXTRA, NOTRLCOM, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_return',
},
{
- command='rewind',
- flags=bit.bor(EXTRA, BANG, CMDARG, ARGOPT, TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_rewind',
+ command = 'rewind',
+ flags = bit.bor(EXTRA, BANG, CMDARG, ARGOPT, TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_rewind',
},
{
- command='right',
- flags=bit.bor(TRLBAR, RANGE, WHOLEFOLD, EXTRA, CMDWIN, LOCK_OK, MODIFY),
- addr_type='ADDR_LINES',
- func='ex_align',
+ command = 'right',
+ flags = bit.bor(TRLBAR, RANGE, WHOLEFOLD, EXTRA, CMDWIN, LOCK_OK, MODIFY),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_align',
},
{
- command='rightbelow',
- flags=bit.bor(NEEDARG, EXTRA, NOTRLCOM),
- addr_type='ADDR_NONE',
- func='ex_wrongmodifier',
+ command = 'rightbelow',
+ flags = bit.bor(NEEDARG, EXTRA, NOTRLCOM),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_wrongmodifier',
},
{
- command='rshada',
- flags=bit.bor(BANG, FILE1, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_shada',
+ command = 'rshada',
+ flags = bit.bor(BANG, FILE1, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_shada',
},
{
- command='runtime',
- flags=bit.bor(BANG, NEEDARG, FILES, TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_runtime',
+ command = 'runtime',
+ flags = bit.bor(BANG, NEEDARG, FILES, TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_runtime',
},
{
- command='rundo',
- flags=bit.bor(NEEDARG, FILE1),
- addr_type='ADDR_NONE',
- func='ex_rundo',
+ command = 'rundo',
+ flags = bit.bor(NEEDARG, FILE1),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_rundo',
},
{
- command='ruby',
- flags=bit.bor(RANGE, EXTRA, NEEDARG, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_ruby',
+ command = 'ruby',
+ flags = bit.bor(RANGE, EXTRA, NEEDARG, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_ruby',
},
{
- command='rubydo',
- flags=bit.bor(RANGE, DFLALL, EXTRA, NEEDARG, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_rubydo',
+ command = 'rubydo',
+ flags = bit.bor(RANGE, DFLALL, EXTRA, NEEDARG, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_rubydo',
},
{
- command='rubyfile',
- flags=bit.bor(RANGE, FILE1, NEEDARG, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_rubyfile',
+ command = 'rubyfile',
+ flags = bit.bor(RANGE, FILE1, NEEDARG, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_rubyfile',
},
{
- command='rviminfo',
- flags=bit.bor(BANG, FILE1, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_shada',
+ command = 'rviminfo',
+ flags = bit.bor(BANG, FILE1, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_shada',
},
{
- command='substitute',
- flags=bit.bor(RANGE, WHOLEFOLD, EXTRA, CMDWIN, LOCK_OK, PREVIEW),
- addr_type='ADDR_LINES',
- func='ex_substitute',
- preview_func='ex_substitute_preview',
+ command = 'substitute',
+ flags = bit.bor(RANGE, WHOLEFOLD, EXTRA, CMDWIN, LOCK_OK, PREVIEW),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_substitute',
+ preview_func = 'ex_substitute_preview',
},
{
- command='sNext',
- flags=bit.bor(EXTRA, RANGE, COUNT, BANG, CMDARG, ARGOPT, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_previous',
+ command = 'sNext',
+ flags = bit.bor(EXTRA, RANGE, COUNT, BANG, CMDARG, ARGOPT, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_previous',
},
{
- command='sargument',
- flags=bit.bor(BANG, RANGE, COUNT, EXTRA, CMDARG, ARGOPT, TRLBAR),
- addr_type='ADDR_ARGUMENTS',
- func='ex_argument',
+ command = 'sargument',
+ flags = bit.bor(BANG, RANGE, COUNT, EXTRA, CMDARG, ARGOPT, TRLBAR),
+ addr_type = 'ADDR_ARGUMENTS',
+ func = 'ex_argument',
},
{
- command='sall',
- flags=bit.bor(BANG, RANGE, COUNT, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_all',
+ command = 'sall',
+ flags = bit.bor(BANG, RANGE, COUNT, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_all',
},
{
- command='sandbox',
- flags=bit.bor(NEEDARG, EXTRA, NOTRLCOM),
- addr_type='ADDR_NONE',
- func='ex_wrongmodifier',
+ command = 'sandbox',
+ flags = bit.bor(NEEDARG, EXTRA, NOTRLCOM),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_wrongmodifier',
},
{
- command='saveas',
- flags=bit.bor(BANG, FILE1, ARGOPT, CMDWIN, LOCK_OK, TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_write',
+ command = 'saveas',
+ flags = bit.bor(BANG, FILE1, ARGOPT, CMDWIN, LOCK_OK, TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_write',
},
{
- command='sbuffer',
- flags=bit.bor(BANG, RANGE, BUFNAME, BUFUNL, COUNT, EXTRA, CMDARG, TRLBAR),
- addr_type='ADDR_BUFFERS',
- func='ex_buffer',
+ command = 'sbuffer',
+ flags = bit.bor(BANG, RANGE, BUFNAME, BUFUNL, COUNT, EXTRA, CMDARG, TRLBAR),
+ addr_type = 'ADDR_BUFFERS',
+ func = 'ex_buffer',
},
{
- command='sbNext',
- flags=bit.bor(RANGE, COUNT, CMDARG, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_bprevious',
+ command = 'sbNext',
+ flags = bit.bor(RANGE, COUNT, CMDARG, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_bprevious',
},
{
- command='sball',
- flags=bit.bor(RANGE, COUNT, CMDARG, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_buffer_all',
+ command = 'sball',
+ flags = bit.bor(RANGE, COUNT, CMDARG, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_buffer_all',
},
{
- command='sbfirst',
- flags=bit.bor(CMDARG, TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_brewind',
+ command = 'sbfirst',
+ flags = bit.bor(CMDARG, TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_brewind',
},
{
- command='sblast',
- flags=bit.bor(CMDARG, TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_blast',
+ command = 'sblast',
+ flags = bit.bor(CMDARG, TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_blast',
},
{
- command='sbmodified',
- flags=bit.bor(RANGE, COUNT, CMDARG, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_bmodified',
+ command = 'sbmodified',
+ flags = bit.bor(RANGE, COUNT, CMDARG, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_bmodified',
},
{
- command='sbnext',
- flags=bit.bor(RANGE, COUNT, CMDARG, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_bnext',
+ command = 'sbnext',
+ flags = bit.bor(RANGE, COUNT, CMDARG, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_bnext',
},
{
- command='sbprevious',
- flags=bit.bor(RANGE, COUNT, CMDARG, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_bprevious',
+ command = 'sbprevious',
+ flags = bit.bor(RANGE, COUNT, CMDARG, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_bprevious',
},
{
- command='sbrewind',
- flags=bit.bor(CMDARG, TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_brewind',
+ command = 'sbrewind',
+ flags = bit.bor(CMDARG, TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_brewind',
},
{
- command='scriptnames',
- flags=bit.bor(BANG, FILES, RANGE, COUNT, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_OTHER',
- func='ex_scriptnames',
+ command = 'scriptnames',
+ flags = bit.bor(BANG, FILES, RANGE, COUNT, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_scriptnames',
},
{
- command='scriptencoding',
- flags=bit.bor(WORD1, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_scriptencoding',
+ command = 'scriptencoding',
+ flags = bit.bor(WORD1, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_scriptencoding',
},
{
- command='set',
- flags=bit.bor(BANG, TRLBAR, EXTRA, CMDWIN, LOCK_OK, SBOXOK),
- addr_type='ADDR_NONE',
- func='ex_set',
+ command = 'set',
+ flags = bit.bor(BANG, TRLBAR, EXTRA, CMDWIN, LOCK_OK, SBOXOK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_set',
},
{
- command='setfiletype',
- flags=bit.bor(TRLBAR, EXTRA, NEEDARG, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_setfiletype',
+ command = 'setfiletype',
+ flags = bit.bor(TRLBAR, EXTRA, NEEDARG, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_setfiletype',
},
{
- command='setglobal',
- flags=bit.bor(BANG, TRLBAR, EXTRA, CMDWIN, LOCK_OK, SBOXOK),
- addr_type='ADDR_NONE',
- func='ex_set',
+ command = 'setglobal',
+ flags = bit.bor(BANG, TRLBAR, EXTRA, CMDWIN, LOCK_OK, SBOXOK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_set',
},
{
- command='setlocal',
- flags=bit.bor(BANG, TRLBAR, EXTRA, CMDWIN, LOCK_OK, SBOXOK),
- addr_type='ADDR_NONE',
- func='ex_set',
+ command = 'setlocal',
+ flags = bit.bor(BANG, TRLBAR, EXTRA, CMDWIN, LOCK_OK, SBOXOK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_set',
},
{
- command='sfind',
- flags=bit.bor(BANG, FILE1, RANGE, CMDARG, ARGOPT, TRLBAR, NEEDARG),
- addr_type='ADDR_OTHER',
- func='ex_splitview',
+ command = 'sfind',
+ flags = bit.bor(BANG, FILE1, RANGE, CMDARG, ARGOPT, TRLBAR, NEEDARG),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_splitview',
},
{
- command='sfirst',
- flags=bit.bor(EXTRA, BANG, CMDARG, ARGOPT, TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_rewind',
+ command = 'sfirst',
+ flags = bit.bor(EXTRA, BANG, CMDARG, ARGOPT, TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_rewind',
},
{
- command='simalt',
- flags=bit.bor(NEEDARG, WORD1, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_ni',
+ command = 'simalt',
+ flags = bit.bor(NEEDARG, WORD1, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_ni',
},
{
- command='sign',
- flags=bit.bor(NEEDARG, RANGE, EXTRA, CMDWIN, LOCK_OK),
- addr_type='ADDR_OTHER',
- func='ex_sign',
+ command = 'sign',
+ flags = bit.bor(NEEDARG, RANGE, EXTRA, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_sign',
},
{
- command='silent',
- flags=bit.bor(NEEDARG, EXTRA, BANG, NOTRLCOM, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_wrongmodifier',
+ command = 'silent',
+ flags = bit.bor(NEEDARG, EXTRA, BANG, NOTRLCOM, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_wrongmodifier',
},
{
- command='sleep',
- flags=bit.bor(BANG, RANGE, COUNT, EXTRA, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_OTHER',
- func='ex_sleep',
+ command = 'sleep',
+ flags = bit.bor(BANG, RANGE, COUNT, EXTRA, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_sleep',
},
{
- command='slast',
- flags=bit.bor(EXTRA, BANG, CMDARG, ARGOPT, TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_last',
+ command = 'slast',
+ flags = bit.bor(EXTRA, BANG, CMDARG, ARGOPT, TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_last',
},
{
- command='smagic',
- flags=bit.bor(RANGE, WHOLEFOLD, EXTRA, CMDWIN, LOCK_OK, PREVIEW),
- addr_type='ADDR_LINES',
- func='ex_submagic',
- preview_func='ex_submagic_preview',
+ command = 'smagic',
+ flags = bit.bor(RANGE, WHOLEFOLD, EXTRA, CMDWIN, LOCK_OK, PREVIEW),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_submagic',
+ preview_func = 'ex_submagic_preview',
},
{
- command='smap',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_map',
+ command = 'smap',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_map',
},
{
- command='smapclear',
- flags=bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_mapclear',
+ command = 'smapclear',
+ flags = bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_mapclear',
},
{
- command='smenu',
- flags=bit.bor(RANGE, ZEROR, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_OTHER',
- func='ex_menu',
+ command = 'smenu',
+ flags = bit.bor(RANGE, ZEROR, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_menu',
},
{
- command='snext',
- flags=bit.bor(RANGE, BANG, FILES, CMDARG, ARGOPT, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_next',
+ command = 'snext',
+ flags = bit.bor(RANGE, BANG, FILES, CMDARG, ARGOPT, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_next',
},
{
- command='snomagic',
- flags=bit.bor(RANGE, WHOLEFOLD, EXTRA, CMDWIN, LOCK_OK, PREVIEW),
- addr_type='ADDR_LINES',
- func='ex_submagic',
- preview_func='ex_submagic_preview',
+ command = 'snomagic',
+ flags = bit.bor(RANGE, WHOLEFOLD, EXTRA, CMDWIN, LOCK_OK, PREVIEW),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_submagic',
+ preview_func = 'ex_submagic_preview',
},
{
- command='snoremap',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_map',
+ command = 'snoremap',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_map',
},
{
- command='snoremenu',
- flags=bit.bor(RANGE, ZEROR, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_OTHER',
- func='ex_menu',
+ command = 'snoremenu',
+ flags = bit.bor(RANGE, ZEROR, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_menu',
},
{
- command='source',
- flags=bit.bor(RANGE, DFLALL, WHOLEFOLD, BANG, FILE1, TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_source',
+ command = 'source',
+ flags = bit.bor(RANGE, DFLALL, WHOLEFOLD, BANG, FILE1, TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_source',
},
{
- command='sort',
- flags=bit.bor(RANGE, DFLALL, WHOLEFOLD, BANG, EXTRA, NOTRLCOM, MODIFY),
- addr_type='ADDR_LINES',
- func='ex_sort',
+ command = 'sort',
+ flags = bit.bor(RANGE, DFLALL, WHOLEFOLD, BANG, EXTRA, NOTRLCOM, MODIFY),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_sort',
},
{
- command='split',
- flags=bit.bor(BANG, FILE1, RANGE, CMDARG, ARGOPT, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_splitview',
+ command = 'split',
+ flags = bit.bor(BANG, FILE1, RANGE, CMDARG, ARGOPT, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_splitview',
},
{
- command='spellgood',
- flags=bit.bor(BANG, RANGE, NEEDARG, EXTRA, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_spell',
+ command = 'spellgood',
+ flags = bit.bor(BANG, RANGE, NEEDARG, EXTRA, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_spell',
},
{
- command='spelldump',
- flags=bit.bor(BANG, TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_spelldump',
+ command = 'spelldump',
+ flags = bit.bor(BANG, TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_spelldump',
},
{
- command='spellinfo',
- flags=bit.bor(TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_spellinfo',
+ command = 'spellinfo',
+ flags = bit.bor(TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_spellinfo',
},
{
- command='spellrepall',
- flags=bit.bor(TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_spellrepall',
+ command = 'spellrepall',
+ flags = bit.bor(TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_spellrepall',
},
{
- command='spellrare',
- flags=bit.bor(BANG, RANGE, NEEDARG, EXTRA, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_spell',
+ command = 'spellrare',
+ flags = bit.bor(BANG, RANGE, NEEDARG, EXTRA, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_spell',
},
{
- command='spellundo',
- flags=bit.bor(BANG, RANGE, NEEDARG, EXTRA, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_spell',
+ command = 'spellundo',
+ flags = bit.bor(BANG, RANGE, NEEDARG, EXTRA, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_spell',
},
{
- command='spellwrong',
- flags=bit.bor(BANG, RANGE, NEEDARG, EXTRA, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_spell',
+ command = 'spellwrong',
+ flags = bit.bor(BANG, RANGE, NEEDARG, EXTRA, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_spell',
},
{
- command='sprevious',
- flags=bit.bor(EXTRA, RANGE, COUNT, BANG, CMDARG, ARGOPT, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_previous',
+ command = 'sprevious',
+ flags = bit.bor(EXTRA, RANGE, COUNT, BANG, CMDARG, ARGOPT, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_previous',
},
{
- command='srewind',
- flags=bit.bor(EXTRA, BANG, CMDARG, ARGOPT, TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_rewind',
+ command = 'srewind',
+ flags = bit.bor(EXTRA, BANG, CMDARG, ARGOPT, TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_rewind',
},
{
- command='stop',
- flags=bit.bor(TRLBAR, BANG, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_stop',
+ command = 'stop',
+ flags = bit.bor(TRLBAR, BANG, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_stop',
},
{
- command='stag',
- flags=bit.bor(RANGE, BANG, WORD1, TRLBAR, ZEROR),
- addr_type='ADDR_OTHER',
- func='ex_stag',
+ command = 'stag',
+ flags = bit.bor(RANGE, BANG, WORD1, TRLBAR, ZEROR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_stag',
},
{
- command='startinsert',
- flags=bit.bor(BANG, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_startinsert',
+ command = 'startinsert',
+ flags = bit.bor(BANG, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_startinsert',
},
{
- command='startgreplace',
- flags=bit.bor(BANG, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_startinsert',
+ command = 'startgreplace',
+ flags = bit.bor(BANG, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_startinsert',
},
{
- command='startreplace',
- flags=bit.bor(BANG, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_startinsert',
+ command = 'startreplace',
+ flags = bit.bor(BANG, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_startinsert',
},
{
- command='stopinsert',
- flags=bit.bor(BANG, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_stopinsert',
+ command = 'stopinsert',
+ flags = bit.bor(BANG, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_stopinsert',
},
{
- command='stjump',
- flags=bit.bor(BANG, TRLBAR, WORD1),
- addr_type='ADDR_NONE',
- func='ex_stag',
+ command = 'stjump',
+ flags = bit.bor(BANG, TRLBAR, WORD1),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_stag',
},
{
- command='stselect',
- flags=bit.bor(BANG, TRLBAR, WORD1),
- addr_type='ADDR_NONE',
- func='ex_stag',
+ command = 'stselect',
+ flags = bit.bor(BANG, TRLBAR, WORD1),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_stag',
},
{
- command='sunhide',
- flags=bit.bor(RANGE, COUNT, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_buffer_all',
+ command = 'sunhide',
+ flags = bit.bor(RANGE, COUNT, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_buffer_all',
},
{
- command='sunmap',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_unmap',
+ command = 'sunmap',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_unmap',
},
{
- command='sunmenu',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_menu',
+ command = 'sunmenu',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_menu',
},
{
- command='suspend',
- flags=bit.bor(TRLBAR, BANG, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_stop',
+ command = 'suspend',
+ flags = bit.bor(TRLBAR, BANG, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_stop',
},
{
- command='sview',
- flags=bit.bor(BANG, FILE1, RANGE, CMDARG, ARGOPT, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_splitview',
+ command = 'sview',
+ flags = bit.bor(BANG, FILE1, RANGE, CMDARG, ARGOPT, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_splitview',
},
{
- command='swapname',
- flags=bit.bor(TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_swapname',
+ command = 'swapname',
+ flags = bit.bor(TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_swapname',
},
{
- command='syntax',
- flags=bit.bor(EXTRA, NOTRLCOM, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_syntax',
+ command = 'syntax',
+ flags = bit.bor(EXTRA, NOTRLCOM, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_syntax',
},
{
- command='syntime',
- flags=bit.bor(NEEDARG, WORD1, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_syntime',
+ command = 'syntime',
+ flags = bit.bor(NEEDARG, WORD1, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_syntime',
},
{
- command='syncbind',
- flags=bit.bor(TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_syncbind',
+ command = 'syncbind',
+ flags = bit.bor(TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_syncbind',
},
{
- command='t',
- flags=bit.bor(RANGE, WHOLEFOLD, EXTRA, TRLBAR, CMDWIN, LOCK_OK, MODIFY),
- addr_type='ADDR_LINES',
- func='ex_copymove',
+ command = 't',
+ flags = bit.bor(RANGE, WHOLEFOLD, EXTRA, TRLBAR, CMDWIN, LOCK_OK, MODIFY),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_copymove',
},
{
- command='tcd',
- flags=bit.bor(BANG, FILE1, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_cd',
+ command = 'tcd',
+ flags = bit.bor(BANG, FILE1, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_cd',
},
{
- command='tchdir',
- flags=bit.bor(BANG, FILE1, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_cd',
+ command = 'tchdir',
+ flags = bit.bor(BANG, FILE1, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_cd',
},
{
- command='tNext',
- flags=bit.bor(RANGE, BANG, TRLBAR, ZEROR),
- addr_type='ADDR_OTHER',
- func='ex_tag',
+ command = 'tNext',
+ flags = bit.bor(RANGE, BANG, TRLBAR, ZEROR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_tag',
},
{
- command='tag',
- flags=bit.bor(RANGE, BANG, WORD1, TRLBAR, ZEROR),
- addr_type='ADDR_OTHER',
- func='ex_tag',
+ command = 'tag',
+ flags = bit.bor(RANGE, BANG, WORD1, TRLBAR, ZEROR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_tag',
},
{
- command='tags',
- flags=bit.bor(TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='do_tags',
+ command = 'tags',
+ flags = bit.bor(TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'do_tags',
},
{
- command='tab',
- flags=bit.bor(NEEDARG, EXTRA, NOTRLCOM),
- addr_type='ADDR_NONE',
- func='ex_wrongmodifier',
+ command = 'tab',
+ flags = bit.bor(NEEDARG, EXTRA, NOTRLCOM),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_wrongmodifier',
},
{
- command='tabclose',
- flags=bit.bor(BANG, RANGE, ZEROR, EXTRA, NOSPC, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_TABS',
- func='ex_tabclose',
+ command = 'tabclose',
+ flags = bit.bor(BANG, RANGE, ZEROR, EXTRA, NOSPC, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_TABS',
+ func = 'ex_tabclose',
},
{
- command='tabdo',
- flags=bit.bor(NEEDARG, EXTRA, NOTRLCOM, RANGE, DFLALL),
- addr_type='ADDR_TABS',
- func='ex_listdo',
+ command = 'tabdo',
+ flags = bit.bor(NEEDARG, EXTRA, NOTRLCOM, RANGE, DFLALL),
+ addr_type = 'ADDR_TABS',
+ func = 'ex_listdo',
},
{
- command='tabedit',
- flags=bit.bor(BANG, FILE1, RANGE, ZEROR, CMDARG, ARGOPT, TRLBAR),
- addr_type='ADDR_TABS',
- func='ex_splitview',
+ command = 'tabedit',
+ flags = bit.bor(BANG, FILE1, RANGE, ZEROR, CMDARG, ARGOPT, TRLBAR),
+ addr_type = 'ADDR_TABS',
+ func = 'ex_splitview',
},
{
- command='tabfind',
- flags=bit.bor(BANG, FILE1, RANGE, ZEROR, CMDARG, ARGOPT, NEEDARG, TRLBAR),
- addr_type='ADDR_TABS',
- func='ex_splitview',
+ command = 'tabfind',
+ flags = bit.bor(BANG, FILE1, RANGE, ZEROR, CMDARG, ARGOPT, NEEDARG, TRLBAR),
+ addr_type = 'ADDR_TABS',
+ func = 'ex_splitview',
},
{
- command='tabfirst',
- flags=bit.bor(TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_tabnext',
+ command = 'tabfirst',
+ flags = bit.bor(TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_tabnext',
},
{
- command='tabmove',
- flags=bit.bor(RANGE, ZEROR, EXTRA, NOSPC, TRLBAR),
- addr_type='ADDR_TABS',
- func='ex_tabmove',
+ command = 'tabmove',
+ flags = bit.bor(RANGE, ZEROR, EXTRA, NOSPC, TRLBAR),
+ addr_type = 'ADDR_TABS',
+ func = 'ex_tabmove',
},
{
- command='tablast',
- flags=bit.bor(TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_tabnext',
+ command = 'tablast',
+ flags = bit.bor(TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_tabnext',
},
{
- command='tabnext',
- flags=bit.bor(RANGE, ZEROR, EXTRA, NOSPC, TRLBAR),
- addr_type='ADDR_TABS',
- func='ex_tabnext',
+ command = 'tabnext',
+ flags = bit.bor(RANGE, ZEROR, EXTRA, NOSPC, TRLBAR),
+ addr_type = 'ADDR_TABS',
+ func = 'ex_tabnext',
},
{
- command='tabnew',
- flags=bit.bor(BANG, FILE1, RANGE, ZEROR, CMDARG, ARGOPT, TRLBAR),
- addr_type='ADDR_TABS',
- func='ex_splitview',
+ command = 'tabnew',
+ flags = bit.bor(BANG, FILE1, RANGE, ZEROR, CMDARG, ARGOPT, TRLBAR),
+ addr_type = 'ADDR_TABS',
+ func = 'ex_splitview',
},
{
- command='tabonly',
- flags=bit.bor(BANG, RANGE, ZEROR, EXTRA, NOSPC, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_TABS',
- func='ex_tabonly',
+ command = 'tabonly',
+ flags = bit.bor(BANG, RANGE, ZEROR, EXTRA, NOSPC, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_TABS',
+ func = 'ex_tabonly',
},
{
- command='tabprevious',
- flags=bit.bor(RANGE, ZEROR, EXTRA, NOSPC, TRLBAR),
- addr_type='ADDR_TABS_RELATIVE',
- func='ex_tabnext',
+ command = 'tabprevious',
+ flags = bit.bor(RANGE, ZEROR, EXTRA, NOSPC, TRLBAR),
+ addr_type = 'ADDR_TABS_RELATIVE',
+ func = 'ex_tabnext',
},
{
- command='tabNext',
- flags=bit.bor(RANGE, ZEROR, EXTRA, NOSPC, TRLBAR),
- addr_type='ADDR_TABS_RELATIVE',
- func='ex_tabnext',
+ command = 'tabNext',
+ flags = bit.bor(RANGE, ZEROR, EXTRA, NOSPC, TRLBAR),
+ addr_type = 'ADDR_TABS_RELATIVE',
+ func = 'ex_tabnext',
},
{
- command='tabrewind',
- flags=bit.bor(TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_tabnext',
+ command = 'tabrewind',
+ flags = bit.bor(TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_tabnext',
},
{
- command='tabs',
- flags=bit.bor(TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_tabs',
+ command = 'tabs',
+ flags = bit.bor(TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_tabs',
},
{
- command='tcl',
- flags=bit.bor(RANGE, EXTRA, NEEDARG, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_script_ni',
+ command = 'tcl',
+ flags = bit.bor(RANGE, EXTRA, NEEDARG, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_script_ni',
},
{
- command='tcldo',
- flags=bit.bor(RANGE, DFLALL, EXTRA, NEEDARG, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_ni',
+ command = 'tcldo',
+ flags = bit.bor(RANGE, DFLALL, EXTRA, NEEDARG, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_ni',
},
{
- command='tclfile',
- flags=bit.bor(RANGE, FILE1, NEEDARG, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_ni',
+ command = 'tclfile',
+ flags = bit.bor(RANGE, FILE1, NEEDARG, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_ni',
},
{
- command='terminal',
- flags=bit.bor(BANG, FILES, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_terminal',
+ command = 'terminal',
+ flags = bit.bor(BANG, FILES, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_terminal',
},
{
- command='tfirst',
- flags=bit.bor(RANGE, BANG, TRLBAR, ZEROR),
- addr_type='ADDR_OTHER',
- func='ex_tag',
+ command = 'tfirst',
+ flags = bit.bor(RANGE, BANG, TRLBAR, ZEROR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_tag',
},
{
- command='throw',
- flags=bit.bor(EXTRA, NEEDARG, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_throw',
+ command = 'throw',
+ flags = bit.bor(EXTRA, NEEDARG, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_throw',
},
{
- command='tjump',
- flags=bit.bor(BANG, TRLBAR, WORD1),
- addr_type='ADDR_NONE',
- func='ex_tag',
+ command = 'tjump',
+ flags = bit.bor(BANG, TRLBAR, WORD1),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_tag',
},
{
- command='tlast',
- flags=bit.bor(BANG, TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_tag',
+ command = 'tlast',
+ flags = bit.bor(BANG, TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_tag',
},
{
- command='tlmenu',
- flags=bit.bor(RANGE, ZEROR, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_OTHER',
- func='ex_menu',
+ command = 'tlmenu',
+ flags = bit.bor(RANGE, ZEROR, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_menu',
},
{
- command='tlnoremenu',
- flags=bit.bor(RANGE, ZEROR, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_OTHER',
- func='ex_menu',
+ command = 'tlnoremenu',
+ flags = bit.bor(RANGE, ZEROR, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_menu',
},
{
- command='tlunmenu',
- flags=bit.bor(RANGE, ZEROR, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_OTHER',
- func='ex_menu',
+ command = 'tlunmenu',
+ flags = bit.bor(RANGE, ZEROR, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_menu',
},
{
- command='tmenu',
- flags=bit.bor(RANGE, ZEROR, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_OTHER',
- func='ex_menu',
+ command = 'tmenu',
+ flags = bit.bor(RANGE, ZEROR, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_menu',
},
{
- command='tmap',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_map',
+ command = 'tmap',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_map',
},
{
- command='tmapclear',
- flags=bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_mapclear',
+ command = 'tmapclear',
+ flags = bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_mapclear',
},
{
- command='tnext',
- flags=bit.bor(RANGE, BANG, TRLBAR, ZEROR),
- addr_type='ADDR_OTHER',
- func='ex_tag',
+ command = 'tnext',
+ flags = bit.bor(RANGE, BANG, TRLBAR, ZEROR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_tag',
},
{
- command='tnoremap',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_map',
+ command = 'tnoremap',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_map',
},
{
- command='topleft',
- flags=bit.bor(NEEDARG, EXTRA, NOTRLCOM),
- addr_type='ADDR_NONE',
- func='ex_wrongmodifier',
+ command = 'topleft',
+ flags = bit.bor(NEEDARG, EXTRA, NOTRLCOM),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_wrongmodifier',
},
{
- command='tprevious',
- flags=bit.bor(RANGE, BANG, TRLBAR, ZEROR),
- addr_type='ADDR_OTHER',
- func='ex_tag',
+ command = 'tprevious',
+ flags = bit.bor(RANGE, BANG, TRLBAR, ZEROR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_tag',
},
{
- command='trewind',
- flags=bit.bor(RANGE, BANG, TRLBAR, ZEROR),
- addr_type='ADDR_OTHER',
- func='ex_tag',
+ command = 'trewind',
+ flags = bit.bor(RANGE, BANG, TRLBAR, ZEROR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_tag',
},
{
- command='trust',
- flags=bit.bor(EXTRA, FILE1, TRLBAR, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_trust',
+ command = 'trust',
+ flags = bit.bor(EXTRA, FILE1, TRLBAR, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_trust',
},
{
- command='try',
- flags=bit.bor(TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_try',
+ command = 'try',
+ flags = bit.bor(TRLBAR, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_try',
},
{
- command='tselect',
- flags=bit.bor(BANG, TRLBAR, WORD1),
- addr_type='ADDR_NONE',
- func='ex_tag',
+ command = 'tselect',
+ flags = bit.bor(BANG, TRLBAR, WORD1),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_tag',
},
{
- command='tunmenu',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_menu',
+ command = 'tunmenu',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_menu',
},
{
- command='tunmap',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_unmap',
+ command = 'tunmap',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_unmap',
},
{
- command='undo',
- flags=bit.bor(BANG, RANGE, COUNT, ZEROR, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_OTHER',
- func='ex_undo',
+ command = 'undo',
+ flags = bit.bor(BANG, RANGE, COUNT, ZEROR, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_undo',
},
{
- command='undojoin',
- flags=bit.bor(TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_undojoin',
+ command = 'undojoin',
+ flags = bit.bor(TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_undojoin',
},
{
- command='undolist',
- flags=bit.bor(TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_undolist',
+ command = 'undolist',
+ flags = bit.bor(TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_undolist',
},
{
- command='unabbreviate',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_abbreviate',
+ command = 'unabbreviate',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_abbreviate',
},
{
- command='unhide',
- flags=bit.bor(RANGE, COUNT, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_buffer_all',
+ command = 'unhide',
+ flags = bit.bor(RANGE, COUNT, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_buffer_all',
},
{
- command='unlet',
- flags=bit.bor(BANG, EXTRA, NEEDARG, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_unlet',
+ command = 'unlet',
+ flags = bit.bor(BANG, EXTRA, NEEDARG, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_unlet',
},
{
- command='unlockvar',
- flags=bit.bor(BANG, EXTRA, NEEDARG, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_lockvar',
+ command = 'unlockvar',
+ flags = bit.bor(BANG, EXTRA, NEEDARG, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_lockvar',
},
{
- command='unmap',
- flags=bit.bor(BANG, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_unmap',
+ command = 'unmap',
+ flags = bit.bor(BANG, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_unmap',
},
{
- command='unmenu',
- flags=bit.bor(BANG, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_menu',
+ command = 'unmenu',
+ flags = bit.bor(BANG, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_menu',
},
{
- command='unsilent',
- flags=bit.bor(NEEDARG, EXTRA, NOTRLCOM, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_wrongmodifier',
+ command = 'unsilent',
+ flags = bit.bor(NEEDARG, EXTRA, NOTRLCOM, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_wrongmodifier',
},
{
- command='update',
- flags=bit.bor(RANGE, WHOLEFOLD, BANG, FILE1, ARGOPT, DFLALL, TRLBAR),
- addr_type='ADDR_LINES',
- func='ex_update',
+ command = 'update',
+ flags = bit.bor(RANGE, WHOLEFOLD, BANG, FILE1, ARGOPT, DFLALL, TRLBAR),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_update',
},
{
- command='vglobal',
- flags=bit.bor(RANGE, WHOLEFOLD, EXTRA, DFLALL, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_global',
+ command = 'vglobal',
+ flags = bit.bor(RANGE, WHOLEFOLD, EXTRA, DFLALL, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_global',
},
{
- command='version',
- flags=bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_version',
+ command = 'version',
+ flags = bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_version',
},
{
- command='verbose',
- flags=bit.bor(NEEDARG, RANGE, EXTRA, NOTRLCOM, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_OTHER',
- func='ex_wrongmodifier',
+ command = 'verbose',
+ flags = bit.bor(NEEDARG, RANGE, EXTRA, NOTRLCOM, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_wrongmodifier',
},
{
- command='vertical',
- flags=bit.bor(NEEDARG, EXTRA, NOTRLCOM),
- addr_type='ADDR_NONE',
- func='ex_wrongmodifier',
+ command = 'vertical',
+ flags = bit.bor(NEEDARG, EXTRA, NOTRLCOM),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_wrongmodifier',
},
{
- command='visual',
- flags=bit.bor(BANG, FILE1, CMDARG, ARGOPT, TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_edit',
+ command = 'visual',
+ flags = bit.bor(BANG, FILE1, CMDARG, ARGOPT, TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_edit',
},
{
- command='view',
- flags=bit.bor(BANG, FILE1, CMDARG, ARGOPT, TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_edit',
+ command = 'view',
+ flags = bit.bor(BANG, FILE1, CMDARG, ARGOPT, TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_edit',
},
{
- command='vimgrep',
- flags=bit.bor(RANGE, BANG, NEEDARG, EXTRA, NOTRLCOM, TRLBAR, XFILE, LOCK_OK),
- addr_type='ADDR_OTHER',
- func='ex_vimgrep',
+ command = 'vimgrep',
+ flags = bit.bor(RANGE, BANG, NEEDARG, EXTRA, NOTRLCOM, TRLBAR, XFILE, LOCK_OK),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_vimgrep',
},
{
- command='vimgrepadd',
- flags=bit.bor(RANGE, BANG, NEEDARG, EXTRA, NOTRLCOM, TRLBAR, XFILE, LOCK_OK),
- addr_type='ADDR_OTHER',
- func='ex_vimgrep',
+ command = 'vimgrepadd',
+ flags = bit.bor(RANGE, BANG, NEEDARG, EXTRA, NOTRLCOM, TRLBAR, XFILE, LOCK_OK),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_vimgrep',
},
{
- command='viusage',
- flags=bit.bor(TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_viusage',
+ command = 'viusage',
+ flags = bit.bor(TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_viusage',
},
{
- command='vmap',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_map',
+ command = 'vmap',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_map',
},
{
- command='vmapclear',
- flags=bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_mapclear',
+ command = 'vmapclear',
+ flags = bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_mapclear',
},
{
- command='vmenu',
- flags=bit.bor(RANGE, ZEROR, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_OTHER',
- func='ex_menu',
+ command = 'vmenu',
+ flags = bit.bor(RANGE, ZEROR, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_menu',
},
{
- command='vnoremap',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_map',
+ command = 'vnoremap',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_map',
},
{
- command='vnew',
- flags=bit.bor(BANG, FILE1, RANGE, CMDARG, ARGOPT, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_splitview',
+ command = 'vnew',
+ flags = bit.bor(BANG, FILE1, RANGE, CMDARG, ARGOPT, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_splitview',
},
{
- command='vnoremenu',
- flags=bit.bor(RANGE, ZEROR, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_OTHER',
- func='ex_menu',
+ command = 'vnoremenu',
+ flags = bit.bor(RANGE, ZEROR, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_menu',
},
{
- command='vsplit',
- flags=bit.bor(BANG, FILE1, RANGE, CMDARG, ARGOPT, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_splitview',
+ command = 'vsplit',
+ flags = bit.bor(BANG, FILE1, RANGE, CMDARG, ARGOPT, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_splitview',
},
{
- command='vunmap',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_unmap',
+ command = 'vunmap',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_unmap',
},
{
- command='vunmenu',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_menu',
+ command = 'vunmenu',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_menu',
},
{
- command='write',
- flags=bit.bor(RANGE, WHOLEFOLD, BANG, FILE1, ARGOPT, DFLALL, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_write',
+ command = 'write',
+ flags = bit.bor(RANGE, WHOLEFOLD, BANG, FILE1, ARGOPT, DFLALL, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_write',
},
{
- command='wNext',
- flags=bit.bor(RANGE, WHOLEFOLD, BANG, FILE1, ARGOPT, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_wnext',
+ command = 'wNext',
+ flags = bit.bor(RANGE, WHOLEFOLD, BANG, FILE1, ARGOPT, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_wnext',
},
{
- command='wall',
- flags=bit.bor(BANG, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='do_wqall',
+ command = 'wall',
+ flags = bit.bor(BANG, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'do_wqall',
},
{
- command='while',
- flags=bit.bor(EXTRA, NOTRLCOM, SBOXOK, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_while',
+ command = 'while',
+ flags = bit.bor(EXTRA, NOTRLCOM, SBOXOK, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_while',
},
{
- command='winsize',
- flags=bit.bor(EXTRA, NEEDARG, TRLBAR),
- addr_type='ADDR_NONE',
- func='ex_winsize',
+ command = 'winsize',
+ flags = bit.bor(EXTRA, NEEDARG, TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_winsize',
},
{
- command='wincmd',
- flags=bit.bor(NEEDARG, WORD1, RANGE, COUNT, CMDWIN, LOCK_OK),
- addr_type='ADDR_OTHER',
- func='ex_wincmd',
+ command = 'wincmd',
+ flags = bit.bor(NEEDARG, WORD1, RANGE, COUNT, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_wincmd',
},
{
- command='windo',
- flags=bit.bor(NEEDARG, EXTRA, NOTRLCOM, RANGE, DFLALL),
- addr_type='ADDR_WINDOWS',
- func='ex_listdo',
+ command = 'windo',
+ flags = bit.bor(NEEDARG, EXTRA, NOTRLCOM, RANGE, DFLALL),
+ addr_type = 'ADDR_WINDOWS',
+ func = 'ex_listdo',
},
{
- command='winpos',
- flags=bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_ni',
+ command = 'winpos',
+ flags = bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_ni',
},
{
- command='wnext',
- flags=bit.bor(RANGE, BANG, FILE1, ARGOPT, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_wnext',
+ command = 'wnext',
+ flags = bit.bor(RANGE, BANG, FILE1, ARGOPT, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_wnext',
},
{
- command='wprevious',
- flags=bit.bor(RANGE, BANG, FILE1, ARGOPT, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_wnext',
+ command = 'wprevious',
+ flags = bit.bor(RANGE, BANG, FILE1, ARGOPT, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_wnext',
},
{
- command='wq',
- flags=bit.bor(RANGE, WHOLEFOLD, BANG, FILE1, ARGOPT, DFLALL, TRLBAR),
- addr_type='ADDR_LINES',
- func='ex_exit',
+ command = 'wq',
+ flags = bit.bor(RANGE, WHOLEFOLD, BANG, FILE1, ARGOPT, DFLALL, TRLBAR),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_exit',
},
{
- command='wqall',
- flags=bit.bor(BANG, FILE1, ARGOPT, TRLBAR),
- addr_type='ADDR_NONE',
- func='do_wqall',
+ command = 'wqall',
+ flags = bit.bor(BANG, FILE1, ARGOPT, TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'do_wqall',
},
{
- command='wshada',
- flags=bit.bor(BANG, FILE1, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_shada',
+ command = 'wshada',
+ flags = bit.bor(BANG, FILE1, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_shada',
},
{
- command='wundo',
- flags=bit.bor(BANG, NEEDARG, FILE1),
- addr_type='ADDR_NONE',
- func='ex_wundo',
+ command = 'wundo',
+ flags = bit.bor(BANG, NEEDARG, FILE1),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_wundo',
},
{
- command='wviminfo',
- flags=bit.bor(BANG, FILE1, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_shada',
+ command = 'wviminfo',
+ flags = bit.bor(BANG, FILE1, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_shada',
},
{
- command='xit',
- flags=bit.bor(RANGE, WHOLEFOLD, BANG, FILE1, ARGOPT, DFLALL, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_exit',
+ command = 'xit',
+ flags = bit.bor(RANGE, WHOLEFOLD, BANG, FILE1, ARGOPT, DFLALL, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_exit',
},
{
- command='xall',
- flags=bit.bor(BANG, TRLBAR),
- addr_type='ADDR_NONE',
- func='do_wqall',
+ command = 'xall',
+ flags = bit.bor(BANG, TRLBAR),
+ addr_type = 'ADDR_NONE',
+ func = 'do_wqall',
},
{
- command='xmap',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_map',
+ command = 'xmap',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_map',
},
{
- command='xmapclear',
- flags=bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_mapclear',
+ command = 'xmapclear',
+ flags = bit.bor(EXTRA, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_mapclear',
},
{
- command='xmenu',
- flags=bit.bor(RANGE, ZEROR, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_OTHER',
- func='ex_menu',
+ command = 'xmenu',
+ flags = bit.bor(RANGE, ZEROR, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_menu',
},
{
- command='xnoremap',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_map',
+ command = 'xnoremap',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_map',
},
{
- command='xnoremenu',
- flags=bit.bor(RANGE, ZEROR, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_OTHER',
- func='ex_menu',
+ command = 'xnoremenu',
+ flags = bit.bor(RANGE, ZEROR, EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_menu',
},
{
- command='xunmap',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_unmap',
+ command = 'xunmap',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_unmap',
},
{
- command='xunmenu',
- flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
- addr_type='ADDR_NONE',
- func='ex_menu',
+ command = 'xunmenu',
+ flags = bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_NONE',
+ func = 'ex_menu',
},
{
- command='yank',
- flags=bit.bor(RANGE, WHOLEFOLD, REGSTR, COUNT, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_operators',
+ command = 'yank',
+ flags = bit.bor(RANGE, WHOLEFOLD, REGSTR, COUNT, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_operators',
},
{
- command='z',
- flags=bit.bor(RANGE, WHOLEFOLD, BANG, EXTRA, FLAGS, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_z',
+ command = 'z',
+ flags = bit.bor(RANGE, WHOLEFOLD, BANG, EXTRA, FLAGS, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_z',
},
-- commands that don't start with a letter
{
- command='!',
- enum='CMD_bang',
- flags=bit.bor(RANGE, WHOLEFOLD, BANG, FILES, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_bang',
+ command = '!',
+ enum = 'CMD_bang',
+ flags = bit.bor(RANGE, WHOLEFOLD, BANG, FILES, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_bang',
},
{
- command='#',
- enum='CMD_pound',
- flags=bit.bor(RANGE, WHOLEFOLD, COUNT, FLAGS, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_print',
+ command = '#',
+ enum = 'CMD_pound',
+ flags = bit.bor(RANGE, WHOLEFOLD, COUNT, FLAGS, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_print',
},
{
- command='&',
- enum='CMD_and',
- flags=bit.bor(RANGE, WHOLEFOLD, EXTRA, CMDWIN, LOCK_OK, MODIFY),
- addr_type='ADDR_LINES',
- func='ex_substitute',
+ command = '&',
+ enum = 'CMD_and',
+ flags = bit.bor(RANGE, WHOLEFOLD, EXTRA, CMDWIN, LOCK_OK, MODIFY),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_substitute',
},
{
- command='<',
- enum='CMD_lshift',
- flags=bit.bor(RANGE, WHOLEFOLD, COUNT, FLAGS, TRLBAR, CMDWIN, LOCK_OK, MODIFY),
- addr_type='ADDR_LINES',
- func='ex_operators',
+ command = '<',
+ enum = 'CMD_lshift',
+ flags = bit.bor(RANGE, WHOLEFOLD, COUNT, FLAGS, TRLBAR, CMDWIN, LOCK_OK, MODIFY),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_operators',
},
{
- command='=',
- enum='CMD_equal',
- flags=bit.bor(RANGE, EXTRA, DFLALL, ARGOPT, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_equal',
+ command = '=',
+ enum = 'CMD_equal',
+ flags = bit.bor(RANGE, EXTRA, DFLALL, ARGOPT, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_equal',
},
{
- command='>',
- enum='CMD_rshift',
- flags=bit.bor(RANGE, WHOLEFOLD, COUNT, FLAGS, TRLBAR, CMDWIN, LOCK_OK, MODIFY),
- addr_type='ADDR_LINES',
- func='ex_operators',
+ command = '>',
+ enum = 'CMD_rshift',
+ flags = bit.bor(RANGE, WHOLEFOLD, COUNT, FLAGS, TRLBAR, CMDWIN, LOCK_OK, MODIFY),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_operators',
},
{
- command='@',
- enum='CMD_at',
- flags=bit.bor(RANGE, WHOLEFOLD, EXTRA, TRLBAR, CMDWIN, LOCK_OK),
- addr_type='ADDR_LINES',
- func='ex_at',
+ command = '@',
+ enum = 'CMD_at',
+ flags = bit.bor(RANGE, WHOLEFOLD, EXTRA, TRLBAR, CMDWIN, LOCK_OK),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_at',
},
{
- command='~',
- enum='CMD_tilde',
- flags=bit.bor(RANGE, WHOLEFOLD, EXTRA, CMDWIN, LOCK_OK, MODIFY),
- addr_type='ADDR_LINES',
- func='ex_substitute',
+ command = '~',
+ enum = 'CMD_tilde',
+ flags = bit.bor(RANGE, WHOLEFOLD, EXTRA, CMDWIN, LOCK_OK, MODIFY),
+ addr_type = 'ADDR_LINES',
+ func = 'ex_substitute',
},
-- commands that start with an uppercase letter
{
- command='Next',
- flags=bit.bor(EXTRA, RANGE, COUNT, BANG, CMDARG, ARGOPT, TRLBAR),
- addr_type='ADDR_OTHER',
- func='ex_previous',
+ command = 'Next',
+ flags = bit.bor(EXTRA, RANGE, COUNT, BANG, CMDARG, ARGOPT, TRLBAR),
+ addr_type = 'ADDR_OTHER',
+ func = 'ex_previous',
},
}
diff --git a/src/nvim/extmark.h b/src/nvim/extmark.h
index 1a7a1ddeff..5ba079bd12 100644
--- a/src/nvim/extmark.h
+++ b/src/nvim/extmark.h
@@ -1,17 +1,15 @@
#pragma once
#include <stdbool.h>
-#include <stddef.h>
#include <stdint.h>
#include "klib/kvec.h"
-#include "nvim/buffer_defs.h"
-#include "nvim/decoration.h"
+#include "nvim/buffer_defs.h" // IWYU pragma: keep
+#include "nvim/decoration_defs.h" // IWYU pragma: keep
#include "nvim/extmark_defs.h" // IWYU pragma: export
#include "nvim/macros_defs.h"
-#include "nvim/marktree.h"
+#include "nvim/marktree_defs.h" // IWYU pragma: keep
#include "nvim/pos_defs.h"
-#include "nvim/types_defs.h"
EXTERN int curbuf_splice_pending INIT( = 0);
diff --git a/src/nvim/generators/c_grammar.lua b/src/nvim/generators/c_grammar.lua
index f33da452ff..1720b32919 100644
--- a/src/nvim/generators/c_grammar.lua
+++ b/src/nvim/generators/c_grammar.lua
@@ -17,50 +17,70 @@ local fill = ws ^ 0
local c_comment = P('//') * (not_nl ^ 0)
local c_preproc = P('#') * (not_nl ^ 0)
local dllexport = P('DLLEXPORT') * (ws ^ 1)
-local typed_container =
- (P('ArrayOf(') + P('DictionaryOf(') + P('Dict(')) * ((any - P(')')) ^ 1) * P(')')
-local c_id = (
- typed_container +
- (letter * (alpha ^ 0))
-)
+local typed_container = (P('ArrayOf(') + P('DictionaryOf(') + P('Dict('))
+ * ((any - P(')')) ^ 1)
+ * P(')')
+local c_id = (typed_container + (letter * (alpha ^ 0)))
local c_void = P('void')
local c_param_type = (
- ((P('Error') * fill * P('*') * fill) * Cc('error')) +
- ((P('Arena') * fill * P('*') * fill) * Cc('arena')) +
- ((P('lua_State') * fill * P('*') * fill) * Cc('lstate')) +
- C((P('const ') ^ -1) * (c_id) * (ws ^ 1) * P('*')) +
- (C(c_id) * (ws ^ 1))
- )
+ ((P('Error') * fill * P('*') * fill) * Cc('error'))
+ + ((P('Arena') * fill * P('*') * fill) * Cc('arena'))
+ + ((P('lua_State') * fill * P('*') * fill) * Cc('lstate'))
+ + C((P('const ') ^ -1) * c_id * (ws ^ 1) * P('*'))
+ + (C(c_id) * (ws ^ 1))
+)
local c_type = (C(c_void) * (ws ^ 1)) + c_param_type
local c_param = Ct(c_param_type * C(c_id))
local c_param_list = c_param * (fill * (P(',') * fill * c_param) ^ 0)
local c_params = Ct(c_void + c_param_list)
local c_proto = Ct(
- (dllexport ^ -1) *
- Cg(c_type, 'return_type') * Cg(c_id, 'name') *
- fill * P('(') * fill * Cg(c_params, 'parameters') * fill * P(')') *
- Cg(Cc(false), 'fast') *
- (fill * Cg((P('FUNC_API_SINCE(') * C(num ^ 1)) * P(')'), 'since') ^ -1) *
- (fill * Cg((P('FUNC_API_DEPRECATED_SINCE(') * C(num ^ 1)) * P(')'),
- 'deprecated_since') ^ -1) *
- (fill * Cg((P('FUNC_API_FAST') * Cc(true)), 'fast') ^ -1) *
- (fill * Cg((P('FUNC_API_NOEXPORT') * Cc(true)), 'noexport') ^ -1) *
- (fill * Cg((P('FUNC_API_REMOTE_ONLY') * Cc(true)), 'remote_only') ^ -1) *
- (fill * Cg((P('FUNC_API_LUA_ONLY') * Cc(true)), 'lua_only') ^ -1) *
- (fill * (Cg(P('FUNC_API_TEXTLOCK_ALLOW_CMDWIN') * Cc(true), 'textlock_allow_cmdwin') +
- Cg(P('FUNC_API_TEXTLOCK') * Cc(true), 'textlock')) ^ -1) *
- (fill * Cg((P('FUNC_API_REMOTE_IMPL') * Cc(true)), 'remote_impl') ^ -1) *
- (fill * Cg((P('FUNC_API_COMPOSITOR_IMPL') * Cc(true)), 'compositor_impl') ^ -1) *
- (fill * Cg((P('FUNC_API_CLIENT_IMPL') * Cc(true)), 'client_impl') ^ -1) *
- (fill * Cg((P('FUNC_API_CLIENT_IGNORE') * Cc(true)), 'client_ignore') ^ -1) *
- fill * P(';')
- )
+ (dllexport ^ -1)
+ * Cg(c_type, 'return_type')
+ * Cg(c_id, 'name')
+ * fill
+ * P('(')
+ * fill
+ * Cg(c_params, 'parameters')
+ * fill
+ * P(')')
+ * Cg(Cc(false), 'fast')
+ * (fill * Cg((P('FUNC_API_SINCE(') * C(num ^ 1)) * P(')'), 'since') ^ -1)
+ * (fill * Cg((P('FUNC_API_DEPRECATED_SINCE(') * C(num ^ 1)) * P(')'), 'deprecated_since') ^ -1)
+ * (fill * Cg((P('FUNC_API_FAST') * Cc(true)), 'fast') ^ -1)
+ * (fill * Cg((P('FUNC_API_NOEXPORT') * Cc(true)), 'noexport') ^ -1)
+ * (fill * Cg((P('FUNC_API_REMOTE_ONLY') * Cc(true)), 'remote_only') ^ -1)
+ * (fill * Cg((P('FUNC_API_LUA_ONLY') * Cc(true)), 'lua_only') ^ -1)
+ * (fill * (Cg(P('FUNC_API_TEXTLOCK_ALLOW_CMDWIN') * Cc(true), 'textlock_allow_cmdwin') + Cg(
+ P('FUNC_API_TEXTLOCK') * Cc(true),
+ 'textlock'
+ )) ^ -1)
+ * (fill * Cg((P('FUNC_API_REMOTE_IMPL') * Cc(true)), 'remote_impl') ^ -1)
+ * (fill * Cg((P('FUNC_API_COMPOSITOR_IMPL') * Cc(true)), 'compositor_impl') ^ -1)
+ * (fill * Cg((P('FUNC_API_CLIENT_IMPL') * Cc(true)), 'client_impl') ^ -1)
+ * (fill * Cg((P('FUNC_API_CLIENT_IGNORE') * Cc(true)), 'client_ignore') ^ -1)
+ * fill
+ * P(';')
+)
local c_field = Ct(Cg(c_id, 'type') * ws * Cg(c_id, 'name') * fill * P(';') * fill)
local c_keyset = Ct(
- P('typedef') * ws * P('struct') * fill * P('{') * fill *
- Cg(Ct(c_field ^ 1), 'fields') *
- P('}') * fill * P('Dict') * fill * P('(') * Cg(c_id, 'keyset_name') * fill * P(')') * P(';'))
+ P('typedef')
+ * ws
+ * P('struct')
+ * fill
+ * P('{')
+ * fill
+ * Cg(Ct(c_field ^ 1), 'fields')
+ * P('}')
+ * fill
+ * P('Dict')
+ * fill
+ * P('(')
+ * Cg(c_id, 'keyset_name')
+ * fill
+ * P(')')
+ * P(';')
+)
local grammar = Ct((c_proto + c_comment + c_preproc + ws + c_keyset) ^ 1)
-return {grammar=grammar, typed_container=typed_container}
+return { grammar = grammar, typed_container = typed_container }
diff --git a/src/nvim/generators/dump_bin_array.lua b/src/nvim/generators/dump_bin_array.lua
index bee5aba73f..c6cda25e73 100644
--- a/src/nvim/generators/dump_bin_array.lua
+++ b/src/nvim/generators/dump_bin_array.lua
@@ -1,10 +1,10 @@
local function dump_bin_array(output, name, data)
output:write([[
- static const uint8_t ]]..name..[[[] = {
+ static const uint8_t ]] .. name .. [[[] = {
]])
for i = 1, #data do
- output:write(string.byte(data, i)..', ')
+ output:write(string.byte(data, i) .. ', ')
if i % 10 == 0 then
output:write('\n ')
end
diff --git a/src/nvim/generators/gen_api_dispatch.lua b/src/nvim/generators/gen_api_dispatch.lua
index 81b5096557..7cec118243 100644
--- a/src/nvim/generators/gen_api_dispatch.lua
+++ b/src/nvim/generators/gen_api_dispatch.lua
@@ -1,6 +1,6 @@
local mpack = vim.mpack
-local hashy = require'generators.hashy'
+local hashy = require 'generators.hashy'
assert(#arg >= 5)
-- output h file with generated dispatch functions (dispatch_wrappers.generated.h)
@@ -23,16 +23,20 @@ local function_names = {}
local c_grammar = require('generators.c_grammar')
-local function startswith(String,Start)
- return string.sub(String,1,string.len(Start))==Start
+local function startswith(String, Start)
+ return string.sub(String, 1, string.len(Start)) == Start
end
local function add_function(fn)
- local public = startswith(fn.name, "nvim_") or fn.deprecated_since
+ local public = startswith(fn.name, 'nvim_') or fn.deprecated_since
if public and not fn.noexport then
functions[#functions + 1] = fn
function_names[fn.name] = true
- if #fn.parameters >= 2 and fn.parameters[2][1] == 'Array' and fn.parameters[2][2] == 'uidata' then
+ if
+ #fn.parameters >= 2
+ and fn.parameters[2][1] == 'Array'
+ and fn.parameters[2][2] == 'uidata'
+ then
-- function receives the "args" as a parameter
fn.receives_array_args = true
-- remove the args parameter
@@ -70,7 +74,7 @@ local function add_keyset(val)
local types = {}
local is_set_name = 'is_set__' .. val.keyset_name .. '_'
local has_optional = false
- for i,field in ipairs(val.fields) do
+ for i, field in ipairs(val.fields) do
if field.type ~= 'Object' then
types[field.name] = field.type
end
@@ -80,14 +84,17 @@ local function add_keyset(val)
if i > 1 then
error("'is_set__{type}_' must be first if present")
elseif field.name ~= is_set_name then
- error(val.keyset_name..": name of first key should be "..is_set_name)
+ error(val.keyset_name .. ': name of first key should be ' .. is_set_name)
elseif field.type ~= 'OptionalKeys' then
- error("'"..is_set_name.."' must have type 'OptionalKeys'")
+ error("'" .. is_set_name .. "' must have type 'OptionalKeys'")
end
has_optional = true
end
end
- table.insert(keysets, {name=val.keyset_name, keys=keys, types=types, has_optional=has_optional})
+ table.insert(
+ keysets,
+ { name = val.keyset_name, keys = keys, types = types, has_optional = has_optional }
+ )
end
-- read each input file, parse and append to the api metadata
@@ -97,7 +104,7 @@ for i = 6, #arg do
for part in string.gmatch(full_path, '[^/]+') do
parts[#parts + 1] = part
end
- headers[#headers + 1] = parts[#parts - 1]..'/'..parts[#parts]
+ headers[#headers + 1] = parts[#parts - 1] .. '/' .. parts[#parts]
local input = io.open(full_path, 'rb')
@@ -123,14 +130,14 @@ end
-- Export functions under older deprecated names.
-- These will be removed eventually.
-local deprecated_aliases = require("api.dispatch_deprecated")
-for _,f in ipairs(shallowcopy(functions)) do
+local deprecated_aliases = require('api.dispatch_deprecated')
+for _, f in ipairs(shallowcopy(functions)) do
local ismethod = false
- if startswith(f.name, "nvim_") then
- if startswith(f.name, "nvim__") or f.name == "nvim_error_event" then
+ if startswith(f.name, 'nvim_') then
+ if startswith(f.name, 'nvim__') or f.name == 'nvim_error_event' then
f.since = -1
elseif f.since == nil then
- print("Function "..f.name.." lacks since field.\n")
+ print('Function ' .. f.name .. ' lacks since field.\n')
os.exit(1)
end
f.since = tonumber(f.since)
@@ -138,16 +145,16 @@ for _,f in ipairs(shallowcopy(functions)) do
f.deprecated_since = tonumber(f.deprecated_since)
end
- if startswith(f.name, "nvim_buf_") then
+ if startswith(f.name, 'nvim_buf_') then
ismethod = true
- elseif startswith(f.name, "nvim_win_") then
+ elseif startswith(f.name, 'nvim_win_') then
ismethod = true
- elseif startswith(f.name, "nvim_tabpage_") then
+ elseif startswith(f.name, 'nvim_tabpage_') then
ismethod = true
end
f.remote = f.remote_only or not f.lua_only
f.lua = f.lua_only or not f.remote_only
- f.eval = (not f.lua_only) and (not f.remote_only)
+ f.eval = (not f.lua_only) and not f.remote_only
else
f.deprecated_since = tonumber(f.deprecated_since)
assert(f.deprecated_since == 1)
@@ -159,56 +166,59 @@ for _,f in ipairs(shallowcopy(functions)) do
if newname ~= nil then
if function_names[newname] then
-- duplicate
- print("Function "..f.name.." has deprecated alias\n"
- ..newname.." which has a separate implementation.\n"..
- "Please remove it from src/nvim/api/dispatch_deprecated.lua")
+ print(
+ 'Function '
+ .. f.name
+ .. ' has deprecated alias\n'
+ .. newname
+ .. ' which has a separate implementation.\n'
+ .. 'Please remove it from src/nvim/api/dispatch_deprecated.lua'
+ )
os.exit(1)
end
local newf = shallowcopy(f)
newf.name = newname
- if newname == "ui_try_resize" then
+ if newname == 'ui_try_resize' then
-- The return type was incorrectly set to Object in 0.1.5.
-- Keep it that way for clients that rely on this.
- newf.return_type = "Object"
+ newf.return_type = 'Object'
end
newf.impl_name = f.name
newf.lua = false
newf.eval = false
newf.since = 0
newf.deprecated_since = 1
- functions[#functions+1] = newf
+ functions[#functions + 1] = newf
end
end
-- don't expose internal attributes like "impl_name" in public metadata
-local exported_attributes = {'name', 'return_type', 'method',
- 'since', 'deprecated_since'}
+local exported_attributes = { 'name', 'return_type', 'method', 'since', 'deprecated_since' }
local exported_functions = {}
-for _,f in ipairs(functions) do
- if not (startswith(f.name, "nvim__") or f.name == "nvim_error_event" or f.name == "redraw") then
+for _, f in ipairs(functions) do
+ if not (startswith(f.name, 'nvim__') or f.name == 'nvim_error_event' or f.name == 'redraw') then
local f_exported = {}
- for _,attr in ipairs(exported_attributes) do
+ for _, attr in ipairs(exported_attributes) do
f_exported[attr] = f[attr]
end
f_exported.parameters = {}
- for i,param in ipairs(f.parameters) do
- if param[1] == "DictionaryOf(LuaRef)" then
- param = {"Dictionary", param[2]}
- elseif startswith(param[1], "Dict(") then
- param = {"Dictionary", param[2]}
+ for i, param in ipairs(f.parameters) do
+ if param[1] == 'DictionaryOf(LuaRef)' then
+ param = { 'Dictionary', param[2] }
+ elseif startswith(param[1], 'Dict(') then
+ param = { 'Dictionary', param[2] }
end
f_exported.parameters[i] = param
end
- exported_functions[#exported_functions+1] = f_exported
+ exported_functions[#exported_functions + 1] = f_exported
end
end
-
-- serialize the API metadata using msgpack and embed into the resulting
-- binary for easy querying by clients
local funcs_metadata_output = io.open(funcs_metadata_outputf, 'wb')
local packed = mpack.encode(exported_functions)
-local dump_bin_array = require("generators.dump_bin_array")
+local dump_bin_array = require('generators.dump_bin_array')
dump_bin_array(funcs_metadata_output, 'funcs_metadata', packed)
funcs_metadata_output:close()
@@ -246,67 +256,81 @@ output:write([[
]])
-for _,k in ipairs(keysets) do
+for _, k in ipairs(keysets) do
local c_name = {}
- for i = 1,#k.keys do
+ for i = 1, #k.keys do
-- some keys, like "register" are c keywords and get
-- escaped with a trailing _ in the struct.
- if vim.endswith(k.keys[i], "_") then
+ if vim.endswith(k.keys[i], '_') then
local orig = k.keys[i]
- k.keys[i] = string.sub(k.keys[i],1, #(k.keys[i]) - 1)
+ k.keys[i] = string.sub(k.keys[i], 1, #k.keys[i] - 1)
c_name[k.keys[i]] = orig
k.types[k.keys[i]] = k.types[orig]
end
end
- local neworder, hashfun = hashy.hashy_hash(k.name, k.keys, function (idx)
- return k.name.."_table["..idx.."].str"
+ local neworder, hashfun = hashy.hashy_hash(k.name, k.keys, function(idx)
+ return k.name .. '_table[' .. idx .. '].str'
end)
- keysets_defs:write("extern KeySetLink "..k.name.."_table[];\n")
+ keysets_defs:write('extern KeySetLink ' .. k.name .. '_table[];\n')
local function typename(type)
if type ~= nil then
- return "kObjectType"..type
+ return 'kObjectType' .. type
else
- return "kObjectTypeNil"
+ return 'kObjectTypeNil'
end
end
- output:write("KeySetLink "..k.name.."_table[] = {\n")
+ output:write('KeySetLink ' .. k.name .. '_table[] = {\n')
for i, key in ipairs(neworder) do
local ind = -1
if k.has_optional then
ind = i
- keysets_defs:write("#define KEYSET_OPTIDX_"..k.name.."__"..key.." "..ind.."\n")
- end
- output:write(' {"'..key..'", offsetof(KeyDict_'..k.name..", "..(c_name[key] or key).."), "..typename(k.types[key])..", "..ind.."},\n")
+ keysets_defs:write('#define KEYSET_OPTIDX_' .. k.name .. '__' .. key .. ' ' .. ind .. '\n')
+ end
+ output:write(
+ ' {"'
+ .. key
+ .. '", offsetof(KeyDict_'
+ .. k.name
+ .. ', '
+ .. (c_name[key] or key)
+ .. '), '
+ .. typename(k.types[key])
+ .. ', '
+ .. ind
+ .. '},\n'
+ )
end
- output:write(' {NULL, 0, kObjectTypeNil, -1},\n')
- output:write("};\n\n")
+ output:write(' {NULL, 0, kObjectTypeNil, -1},\n')
+ output:write('};\n\n')
output:write(hashfun)
output:write([[
-KeySetLink *KeyDict_]]..k.name..[[_get_field(const char *str, size_t len)
+KeySetLink *KeyDict_]] .. k.name .. [[_get_field(const char *str, size_t len)
{
- int hash = ]]..k.name..[[_hash(str, len);
+ int hash = ]] .. k.name .. [[_hash(str, len);
if (hash == -1) {
return NULL;
}
- return &]]..k.name..[[_table[hash];
+ return &]] .. k.name .. [[_table[hash];
}
]])
- keysets_defs:write("#define api_free_keydict_"..k.name.."(x) api_free_keydict(x, "..k.name.."_table)\n")
+ keysets_defs:write(
+ '#define api_free_keydict_' .. k.name .. '(x) api_free_keydict(x, ' .. k.name .. '_table)\n'
+ )
end
local function real_type(type)
local rv = type
- local rmatch = string.match(type, "Dict%(([_%w]+)%)")
+ local rmatch = string.match(type, 'Dict%(([_%w]+)%)')
if rmatch then
- return "KeyDict_"..rmatch
+ return 'KeyDict_' .. rmatch
elseif c_grammar.typed_container:match(rv) then
if rv:match('Array') then
rv = 'Array'
@@ -333,24 +357,30 @@ for i = 1, #functions do
if fn.impl_name == nil and fn.remote then
local args = {}
- output:write('Object handle_'..fn.name..'(uint64_t channel_id, Array args, Arena* arena, Error *error)')
+ output:write(
+ 'Object handle_' .. fn.name .. '(uint64_t channel_id, Array args, Arena* arena, Error *error)'
+ )
output:write('\n{')
output:write('\n#ifdef NVIM_LOG_DEBUG')
- output:write('\n DLOG("RPC: ch %" PRIu64 ": invoke '..fn.name..'", channel_id);')
+ output:write('\n DLOG("RPC: ch %" PRIu64 ": invoke ' .. fn.name .. '", channel_id);')
output:write('\n#endif')
output:write('\n Object ret = NIL;')
-- Declare/initialize variables that will hold converted arguments
for j = 1, #fn.parameters do
local param = fn.parameters[j]
local rt = real_type(param[1])
- local converted = 'arg_'..j
- output:write('\n '..rt..' '..converted..';')
+ local converted = 'arg_' .. j
+ output:write('\n ' .. rt .. ' ' .. converted .. ';')
end
output:write('\n')
if not fn.receives_array_args then
- output:write('\n if (args.size != '..#fn.parameters..') {')
- output:write('\n api_set_error(error, kErrorTypeException, \
- "Wrong number of arguments: expecting '..#fn.parameters..' but got %zu", args.size);')
+ output:write('\n if (args.size != ' .. #fn.parameters .. ') {')
+ output:write(
+ '\n api_set_error(error, kErrorTypeException, \
+ "Wrong number of arguments: expecting '
+ .. #fn.parameters
+ .. ' but got %zu", args.size);'
+ )
output:write('\n goto cleanup;')
output:write('\n }\n')
end
@@ -359,55 +389,121 @@ for i = 1, #functions do
for j = 1, #fn.parameters do
local converted, param
param = fn.parameters[j]
- converted = 'arg_'..j
+ converted = 'arg_' .. j
local rt = real_type(param[1])
if rt == 'Object' then
- output:write('\n '..converted..' = args.items['..(j - 1)..'];\n')
+ output:write('\n ' .. converted .. ' = args.items[' .. (j - 1) .. '];\n')
elseif rt:match('^KeyDict_') then
converted = '&' .. converted
- output:write('\n if (args.items['..(j - 1)..'].type == kObjectTypeDictionary) {') --luacheck: ignore 631
- output:write('\n memset('..converted..', 0, sizeof(*'..converted..'));') -- TODO: neeeee
- output:write('\n if (!api_dict_to_keydict('..converted..', '..rt..'_get_field, args.items['..(j - 1)..'].data.dictionary, error)) {')
+ output:write('\n if (args.items[' .. (j - 1) .. '].type == kObjectTypeDictionary) {') --luacheck: ignore 631
+ output:write('\n memset(' .. converted .. ', 0, sizeof(*' .. converted .. '));') -- TODO: neeeee
+ output:write(
+ '\n if (!api_dict_to_keydict('
+ .. converted
+ .. ', '
+ .. rt
+ .. '_get_field, args.items['
+ .. (j - 1)
+ .. '].data.dictionary, error)) {'
+ )
output:write('\n goto cleanup;')
output:write('\n }')
- output:write('\n } else if (args.items['..(j - 1)..'].type == kObjectTypeArray && args.items['..(j - 1)..'].data.array.size == 0) {') --luacheck: ignore 631
- output:write('\n memset('..converted..', 0, sizeof(*'..converted..'));')
+ output:write(
+ '\n } else if (args.items['
+ .. (j - 1)
+ .. '].type == kObjectTypeArray && args.items['
+ .. (j - 1)
+ .. '].data.array.size == 0) {'
+ ) --luacheck: ignore 631
+ output:write('\n memset(' .. converted .. ', 0, sizeof(*' .. converted .. '));')
output:write('\n } else {')
- output:write('\n api_set_error(error, kErrorTypeException, \
- "Wrong type for argument '..j..' when calling '..fn.name..', expecting '..param[1]..'");')
+ output:write(
+ '\n api_set_error(error, kErrorTypeException, \
+ "Wrong type for argument '
+ .. j
+ .. ' when calling '
+ .. fn.name
+ .. ', expecting '
+ .. param[1]
+ .. '");'
+ )
output:write('\n goto cleanup;')
output:write('\n }\n')
else
if rt:match('^Buffer$') or rt:match('^Window$') or rt:match('^Tabpage$') then
-- Buffer, Window, and Tabpage have a specific type, but are stored in integer
- output:write('\n if (args.items['..
- (j - 1)..'].type == kObjectType'..rt..' && args.items['..(j - 1)..'].data.integer >= 0) {')
- output:write('\n '..converted..' = (handle_T)args.items['..(j - 1)..'].data.integer;')
+ output:write(
+ '\n if (args.items['
+ .. (j - 1)
+ .. '].type == kObjectType'
+ .. rt
+ .. ' && args.items['
+ .. (j - 1)
+ .. '].data.integer >= 0) {'
+ )
+ output:write(
+ '\n ' .. converted .. ' = (handle_T)args.items[' .. (j - 1) .. '].data.integer;'
+ )
else
- output:write('\n if (args.items['..(j - 1)..'].type == kObjectType'..rt..') {')
- output:write('\n '..converted..' = args.items['..(j - 1)..'].data.'..attr_name(rt)..';')
+ output:write('\n if (args.items[' .. (j - 1) .. '].type == kObjectType' .. rt .. ') {')
+ output:write(
+ '\n '
+ .. converted
+ .. ' = args.items['
+ .. (j - 1)
+ .. '].data.'
+ .. attr_name(rt)
+ .. ';'
+ )
end
- if rt:match('^Buffer$') or rt:match('^Window$') or rt:match('^Tabpage$') or rt:match('^Boolean$') then
+ if
+ rt:match('^Buffer$')
+ or rt:match('^Window$')
+ or rt:match('^Tabpage$')
+ or rt:match('^Boolean$')
+ then
-- accept nonnegative integers for Booleans, Buffers, Windows and Tabpages
- output:write('\n } else if (args.items['..
- (j - 1)..'].type == kObjectTypeInteger && args.items['..(j - 1)..'].data.integer >= 0) {')
- output:write('\n '..converted..' = (handle_T)args.items['..(j - 1)..'].data.integer;')
+ output:write(
+ '\n } else if (args.items['
+ .. (j - 1)
+ .. '].type == kObjectTypeInteger && args.items['
+ .. (j - 1)
+ .. '].data.integer >= 0) {'
+ )
+ output:write(
+ '\n ' .. converted .. ' = (handle_T)args.items[' .. (j - 1) .. '].data.integer;'
+ )
end
if rt:match('^Float$') then
-- accept integers for Floats
- output:write('\n } else if (args.items['..
- (j - 1)..'].type == kObjectTypeInteger) {')
- output:write('\n '..converted..' = (Float)args.items['..(j - 1)..'].data.integer;')
+ output:write('\n } else if (args.items[' .. (j - 1) .. '].type == kObjectTypeInteger) {')
+ output:write(
+ '\n ' .. converted .. ' = (Float)args.items[' .. (j - 1) .. '].data.integer;'
+ )
end
-- accept empty lua tables as empty dictionaries
if rt:match('^Dictionary') then
- output:write('\n } else if (args.items['..(j - 1)..'].type == kObjectTypeArray && args.items['..(j - 1)..'].data.array.size == 0) {') --luacheck: ignore 631
- output:write('\n '..converted..' = (Dictionary)ARRAY_DICT_INIT;')
+ output:write(
+ '\n } else if (args.items['
+ .. (j - 1)
+ .. '].type == kObjectTypeArray && args.items['
+ .. (j - 1)
+ .. '].data.array.size == 0) {'
+ ) --luacheck: ignore 631
+ output:write('\n ' .. converted .. ' = (Dictionary)ARRAY_DICT_INIT;')
end
output:write('\n } else {')
- output:write('\n api_set_error(error, kErrorTypeException, \
- "Wrong type for argument '..j..' when calling '..fn.name..', expecting '..param[1]..'");')
+ output:write(
+ '\n api_set_error(error, kErrorTypeException, \
+ "Wrong type for argument '
+ .. j
+ .. ' when calling '
+ .. fn.name
+ .. ', expecting '
+ .. param[1]
+ .. '");'
+ )
output:write('\n goto cleanup;')
output:write('\n }\n')
end
@@ -431,11 +527,11 @@ for i = 1, #functions do
output:write('\n ')
if fn.return_type ~= 'void' then
-- has a return value, prefix the call with a declaration
- output:write(fn.return_type..' rv = ')
+ output:write(fn.return_type .. ' rv = ')
end
-- write the function name and the opening parenthesis
- output:write(fn.name..'(')
+ output:write(fn.name .. '(')
if fn.receives_channel_id then
-- if the function receives the channel id, pass it as first argument
@@ -455,7 +551,7 @@ for i = 1, #functions do
else
if fn.receives_array_args then
if #args > 0 or fn.call_fail then
- output:write('args, '..call_args)
+ output:write('args, ' .. call_args)
else
output:write('args')
end
@@ -465,7 +561,7 @@ for i = 1, #functions do
end
if fn.arena_return then
- output:write(', arena')
+ output:write(', arena')
end
if fn.has_lua_imp then
@@ -492,36 +588,45 @@ for i = 1, #functions do
end
if fn.return_type ~= 'void' then
- output:write('\n ret = '..string.upper(real_type(fn.return_type))..'_OBJ(rv);')
+ output:write('\n ret = ' .. string.upper(real_type(fn.return_type)) .. '_OBJ(rv);')
end
- output:write('\n\ncleanup:');
+ output:write('\n\ncleanup:')
- output:write('\n return ret;\n}\n\n');
+ output:write('\n return ret;\n}\n\n')
end
end
local remote_fns = {}
-for _,fn in ipairs(functions) do
+for _, fn in ipairs(functions) do
if fn.remote then
remote_fns[fn.name] = fn
end
end
-remote_fns.redraw = {impl_name="ui_client_redraw", fast=true}
+remote_fns.redraw = { impl_name = 'ui_client_redraw', fast = true }
local names = vim.tbl_keys(remote_fns)
table.sort(names)
-local hashorder, hashfun = hashy.hashy_hash("msgpack_rpc_get_handler_for", names, function (idx)
- return "method_handlers["..idx.."].name"
+local hashorder, hashfun = hashy.hashy_hash('msgpack_rpc_get_handler_for', names, function(idx)
+ return 'method_handlers[' .. idx .. '].name'
end)
-output:write("const MsgpackRpcRequestHandler method_handlers[] = {\n")
+output:write('const MsgpackRpcRequestHandler method_handlers[] = {\n')
for n, name in ipairs(hashorder) do
local fn = remote_fns[name]
- fn.handler_id = n-1
- output:write(' { .name = "'..name..'", .fn = handle_'.. (fn.impl_name or fn.name)..
- ', .fast = '..tostring(fn.fast)..', .arena_return = '..tostring(not not fn.arena_return)..'},\n')
+ fn.handler_id = n - 1
+ output:write(
+ ' { .name = "'
+ .. name
+ .. '", .fn = handle_'
+ .. (fn.impl_name or fn.name)
+ .. ', .fast = '
+ .. tostring(fn.fast)
+ .. ', .arena_return = '
+ .. tostring(not not fn.arena_return)
+ .. '},\n'
+ )
end
-output:write("};\n\n")
+output:write('};\n\n')
output:write(hashfun)
output:close()
@@ -534,7 +639,7 @@ mpack_output:close()
local function include_headers(output_handle, headers_to_include)
for i = 1, #headers_to_include do
if headers_to_include[i]:sub(-12) ~= '.generated.h' then
- output_handle:write('\n#include "nvim/'..headers_to_include[i]..'"')
+ output_handle:write('\n#include "nvim/' .. headers_to_include[i] .. '"')
end
end
end
@@ -572,7 +677,10 @@ local lua_c_functions = {}
local function process_function(fn)
local lua_c_function_name = ('nlua_api_%s'):format(fn.name)
- write_shifted_output(output, string.format([[
+ write_shifted_output(
+ output,
+ string.format(
+ [[
static int %s(lua_State *lstate)
{
@@ -582,71 +690,108 @@ local function process_function(fn)
api_set_error(&err, kErrorTypeValidation, "Expected %i argument%s");
goto exit_0;
}
- ]], lua_c_function_name, #fn.parameters, #fn.parameters,
- (#fn.parameters == 1) and '' or 's'))
+ ]],
+ lua_c_function_name,
+ #fn.parameters,
+ #fn.parameters,
+ (#fn.parameters == 1) and '' or 's'
+ )
+ )
lua_c_functions[#lua_c_functions + 1] = {
- binding=lua_c_function_name,
- api=fn.name
+ binding = lua_c_function_name,
+ api = fn.name,
}
if not fn.fast then
- write_shifted_output(output, string.format([[
+ write_shifted_output(
+ output,
+ string.format(
+ [[
if (!nlua_is_deferred_safe()) {
return luaL_error(lstate, e_luv_api_disabled, "%s");
}
- ]], fn.name))
+ ]],
+ fn.name
+ )
+ )
end
if fn.textlock then
- write_shifted_output(output, [[
+ write_shifted_output(
+ output,
+ [[
if (text_locked()) {
api_set_error(&err, kErrorTypeException, "%s", get_text_locked_msg());
goto exit_0;
}
- ]])
+ ]]
+ )
elseif fn.textlock_allow_cmdwin then
- write_shifted_output(output, [[
+ write_shifted_output(
+ output,
+ [[
if (textlock != 0 || expr_map_locked()) {
api_set_error(&err, kErrorTypeException, "%s", e_textlock);
goto exit_0;
}
- ]])
+ ]]
+ )
end
local cparams = ''
local free_code = {}
- for j = #fn.parameters,1,-1 do
+ for j = #fn.parameters, 1, -1 do
local param = fn.parameters[j]
local cparam = string.format('arg%u', j)
local param_type = real_type(param[1])
local lc_param_type = real_type(param[1]):lower()
- local extra = param_type == "Dictionary" and "false, " or ""
- if param[1] == "Object" or param[1] == "DictionaryOf(LuaRef)" then
- extra = "true, "
+ local extra = param_type == 'Dictionary' and 'false, ' or ''
+ if param[1] == 'Object' or param[1] == 'DictionaryOf(LuaRef)' then
+ extra = 'true, '
end
local errshift = 0
local seterr = ''
if string.match(param_type, '^KeyDict_') then
- write_shifted_output(output, string.format([[
- %s %s = { 0 }; nlua_pop_keydict(lstate, &%s, %s_get_field, &err_param, &err);]], param_type, cparam, cparam, param_type))
- cparam = '&'..cparam
+ write_shifted_output(
+ output,
+ string.format(
+ [[
+ %s %s = { 0 }; nlua_pop_keydict(lstate, &%s, %s_get_field, &err_param, &err);]],
+ param_type,
+ cparam,
+ cparam,
+ param_type
+ )
+ )
+ cparam = '&' .. cparam
errshift = 1 -- free incomplete dict on error
else
- write_shifted_output(output, string.format([[
- const %s %s = nlua_pop_%s(lstate, %s&err);]], param[1], cparam, param_type, extra))
+ write_shifted_output(
+ output,
+ string.format(
+ [[
+ const %s %s = nlua_pop_%s(lstate, %s&err);]],
+ param[1],
+ cparam,
+ param_type,
+ extra
+ )
+ )
seterr = [[
- err_param = "]]..param[2]..[[";]]
+ err_param = "]] .. param[2] .. [[";]]
end
- write_shifted_output(output, string.format([[
+ write_shifted_output(
+ output,
+ string.format([[
- if (ERROR_SET(&err)) {]]..seterr..[[
+ if (ERROR_SET(&err)) {]] .. seterr .. [[
goto exit_%u;
}
- ]], #fn.parameters - j + errshift))
- free_code[#free_code + 1] = ('api_free_%s(%s);'):format(
- lc_param_type, cparam)
+ ]], #fn.parameters - j + errshift)
+ )
+ free_code[#free_code + 1] = ('api_free_%s(%s);'):format(lc_param_type, cparam)
cparams = cparam .. ', ' .. cparams
end
if fn.receives_channel_id then
@@ -654,9 +799,12 @@ local function process_function(fn)
end
if fn.arena_return then
cparams = cparams .. '&arena, '
- write_shifted_output(output, [[
+ write_shifted_output(
+ output,
+ [[
Arena arena = ARENA_EMPTY;
- ]])
+ ]]
+ )
end
if fn.has_lua_imp then
@@ -675,8 +823,7 @@ local function process_function(fn)
if i == 1 and not string.match(real_type(fn.parameters[1][1]), '^KeyDict_') then
free_at_exit_code = free_at_exit_code .. ('\n %s'):format(code)
else
- free_at_exit_code = free_at_exit_code .. ('\n exit_%u:\n %s'):format(
- rev_i, code)
+ free_at_exit_code = free_at_exit_code .. ('\n exit_%u:\n %s'):format(rev_i, code)
end
end
local err_throw_code = [[
@@ -704,45 +851,86 @@ local function process_function(fn)
end
local free_retval
if fn.arena_return then
- free_retval = "arena_mem_free(arena_finish(&arena));"
+ free_retval = 'arena_mem_free(arena_finish(&arena));'
else
- free_retval = "api_free_"..return_type:lower().."(ret);"
+ free_retval = 'api_free_' .. return_type:lower() .. '(ret);'
end
- write_shifted_output(output, string.format([[
+ write_shifted_output(
+ output,
+ string.format(
+ [[
const %s ret = %s(%s);
- ]], fn.return_type, fn.name, cparams))
+ ]],
+ fn.return_type,
+ fn.name,
+ cparams
+ )
+ )
if fn.has_lua_imp then
-- only push onto the Lua stack if we haven't already
- write_shifted_output(output, string.format([[
+ write_shifted_output(
+ output,
+ string.format(
+ [[
if (lua_gettop(lstate) == 0) {
nlua_push_%s(lstate, ret, true);
}
- ]], return_type))
+ ]],
+ return_type
+ )
+ )
else
local special = (fn.since ~= nil and fn.since < 11)
- write_shifted_output(output, string.format([[
+ write_shifted_output(
+ output,
+ string.format(
+ [[
nlua_push_%s(lstate, ret, %s);
- ]], return_type, tostring(special)))
+ ]],
+ return_type,
+ tostring(special)
+ )
+ )
end
- write_shifted_output(output, string.format([[
+ write_shifted_output(
+ output,
+ string.format(
+ [[
%s
%s
%s
return 1;
- ]], free_retval, free_at_exit_code, err_throw_code))
+ ]],
+ free_retval,
+ free_at_exit_code,
+ err_throw_code
+ )
+ )
else
- write_shifted_output(output, string.format([[
+ write_shifted_output(
+ output,
+ string.format(
+ [[
%s(%s);
%s
%s
return 0;
- ]], fn.name, cparams, free_at_exit_code, err_throw_code))
+ ]],
+ fn.name,
+ cparams,
+ free_at_exit_code,
+ err_throw_code
+ )
+ )
end
- write_shifted_output(output, [[
+ write_shifted_output(
+ output,
+ [[
}
- ]])
+ ]]
+ )
end
for _, fn in ipairs(functions) do
@@ -751,18 +939,25 @@ for _, fn in ipairs(functions) do
end
end
-output:write(string.format([[
+output:write(string.format(
+ [[
void nlua_add_api_functions(lua_State *lstate)
REAL_FATTR_NONNULL_ALL;
void nlua_add_api_functions(lua_State *lstate)
{
lua_createtable(lstate, 0, %u);
-]], #lua_c_functions))
+]],
+ #lua_c_functions
+))
for _, func in ipairs(lua_c_functions) do
- output:write(string.format([[
+ output:write(string.format(
+ [[
lua_pushcfunction(lstate, &%s);
- lua_setfield(lstate, -2, "%s");]], func.binding, func.api))
+ lua_setfield(lstate, -2, "%s");]],
+ func.binding,
+ func.api
+ ))
end
output:write([[
diff --git a/src/nvim/generators/gen_api_ui_events.lua b/src/nvim/generators/gen_api_ui_events.lua
index e2af5f8d44..89f8c654f4 100644
--- a/src/nvim/generators/gen_api_ui_events.lua
+++ b/src/nvim/generators/gen_api_ui_events.lua
@@ -10,11 +10,11 @@ local client_output = io.open(arg[5], 'wb')
local c_grammar = require('generators.c_grammar')
local events = c_grammar.grammar:match(input:read('*all'))
-local hashy = require'generators.hashy'
+local hashy = require 'generators.hashy'
local function write_signature(output, ev, prefix, notype)
- output:write('('..prefix)
- if prefix == "" and #ev.parameters == 0 then
+ output:write('(' .. prefix)
+ if prefix == '' and #ev.parameters == 0 then
output:write('void')
end
for j = 1, #ev.parameters do
@@ -23,7 +23,7 @@ local function write_signature(output, ev, prefix, notype)
end
local param = ev.parameters[j]
if not notype then
- output:write(param[1]..' ')
+ output:write(param[1] .. ' ')
end
output:write(param[2])
end
@@ -35,26 +35,28 @@ local function write_arglist(output, ev)
local param = ev.parameters[j]
local kind = string.upper(param[1])
output:write(' ADD_C(args, ')
- output:write(kind..'_OBJ('..param[2]..')')
+ output:write(kind .. '_OBJ(' .. param[2] .. ')')
output:write(');\n')
end
end
local function call_ui_event_method(output, ev)
- output:write('void ui_client_event_'..ev.name..'(Array args)\n{\n')
+ output:write('void ui_client_event_' .. ev.name .. '(Array args)\n{\n')
local hlattrs_args_count = 0
if #ev.parameters > 0 then
- output:write(' if (args.size < '..(#ev.parameters))
+ output:write(' if (args.size < ' .. #ev.parameters)
for j = 1, #ev.parameters do
local kind = ev.parameters[j][1]
- if kind ~= "Object" then
- if kind == 'HlAttrs' then kind = 'Dictionary' end
- output:write('\n || args.items['..(j-1)..'].type != kObjectType'..kind..'')
+ if kind ~= 'Object' then
+ if kind == 'HlAttrs' then
+ kind = 'Dictionary'
+ end
+ output:write('\n || args.items[' .. (j - 1) .. '].type != kObjectType' .. kind .. '')
end
end
output:write(') {\n')
- output:write(' ELOG("Error handling ui event \''..ev.name..'\'");\n')
+ output:write(' ELOG("Error handling ui event \'' .. ev.name .. '\'");\n')
output:write(' return;\n')
output:write(' }\n')
end
@@ -62,23 +64,29 @@ local function call_ui_event_method(output, ev)
for j = 1, #ev.parameters do
local param = ev.parameters[j]
local kind = param[1]
- output:write(' '..kind..' arg_'..j..' = ')
+ output:write(' ' .. kind .. ' arg_' .. j .. ' = ')
if kind == 'HlAttrs' then
-- The first HlAttrs argument is rgb_attrs and second is cterm_attrs
- output:write('ui_client_dict2hlattrs(args.items['..(j-1)..'].data.dictionary, '..(hlattrs_args_count == 0 and 'true' or 'false')..');\n')
+ output:write(
+ 'ui_client_dict2hlattrs(args.items['
+ .. (j - 1)
+ .. '].data.dictionary, '
+ .. (hlattrs_args_count == 0 and 'true' or 'false')
+ .. ');\n'
+ )
hlattrs_args_count = hlattrs_args_count + 1
elseif kind == 'Object' then
- output:write('args.items['..(j-1)..'];\n')
+ output:write('args.items[' .. (j - 1) .. '];\n')
elseif kind == 'Window' then
- output:write('(Window)args.items['..(j-1)..'].data.integer;\n')
+ output:write('(Window)args.items[' .. (j - 1) .. '].data.integer;\n')
else
- output:write('args.items['..(j-1)..'].data.'..string.lower(kind)..';\n')
+ output:write('args.items[' .. (j - 1) .. '].data.' .. string.lower(kind) .. ';\n')
end
end
- output:write(' tui_'..ev.name..'(tui')
+ output:write(' tui_' .. ev.name .. '(tui')
for j = 1, #ev.parameters do
- output:write(', arg_'..j)
+ output:write(', arg_' .. j)
end
output:write(');\n')
@@ -90,78 +98,81 @@ for i = 1, #events do
assert(ev.return_type == 'void')
if ev.since == nil and not ev.noexport then
- print("Ui event "..ev.name.." lacks since field.\n")
+ print('Ui event ' .. ev.name .. ' lacks since field.\n')
os.exit(1)
end
ev.since = tonumber(ev.since)
if not ev.remote_only then
-
if not ev.remote_impl and not ev.noexport then
- remote_output:write('void remote_ui_'..ev.name)
+ remote_output:write('void remote_ui_' .. ev.name)
write_signature(remote_output, ev, 'UI *ui')
remote_output:write('\n{\n')
remote_output:write(' UIData *data = ui->data;\n')
remote_output:write(' Array args = data->call_buf;\n')
write_arglist(remote_output, ev)
- remote_output:write(' push_call(ui, "'..ev.name..'", args);\n')
+ remote_output:write(' push_call(ui, "' .. ev.name .. '", args);\n')
remote_output:write('}\n\n')
end
end
if not (ev.remote_only and ev.remote_impl) then
- call_output:write('void ui_call_'..ev.name)
+ call_output:write('void ui_call_' .. ev.name)
write_signature(call_output, ev, '')
call_output:write('\n{\n')
if ev.remote_only then
call_output:write(' Array args = call_buf;\n')
write_arglist(call_output, ev)
- call_output:write(' ui_call_event("'..ev.name..'", args);\n')
+ call_output:write(' ui_call_event("' .. ev.name .. '", args);\n')
elseif ev.compositor_impl then
- call_output:write(' ui_comp_'..ev.name)
+ call_output:write(' ui_comp_' .. ev.name)
write_signature(call_output, ev, '', true)
- call_output:write(";\n")
+ call_output:write(';\n')
call_output:write(' UI_CALL')
- write_signature(call_output, ev, '!ui->composed, '..ev.name..', ui', true)
- call_output:write(";\n")
+ write_signature(call_output, ev, '!ui->composed, ' .. ev.name .. ', ui', true)
+ call_output:write(';\n')
else
call_output:write(' UI_CALL')
- write_signature(call_output, ev, 'true, '..ev.name..', ui', true)
- call_output:write(";\n")
+ write_signature(call_output, ev, 'true, ' .. ev.name .. ', ui', true)
+ call_output:write(';\n')
end
- call_output:write("}\n\n")
+ call_output:write('}\n\n')
end
if ev.compositor_impl then
- call_output:write('void ui_composed_call_'..ev.name)
+ call_output:write('void ui_composed_call_' .. ev.name)
write_signature(call_output, ev, '')
call_output:write('\n{\n')
call_output:write(' UI_CALL')
- write_signature(call_output, ev, 'ui->composed, '..ev.name..', ui', true)
- call_output:write(";\n")
- call_output:write("}\n\n")
+ write_signature(call_output, ev, 'ui->composed, ' .. ev.name .. ', ui', true)
+ call_output:write(';\n')
+ call_output:write('}\n\n')
end
- if (not ev.remote_only) and (not ev.noexport) and (not ev.client_impl) and (not ev.client_ignore) then
+ if (not ev.remote_only) and not ev.noexport and not ev.client_impl and not ev.client_ignore then
call_ui_event_method(client_output, ev)
end
end
local client_events = {}
-for _,ev in ipairs(events) do
- if (not ev.noexport) and ((not ev.remote_only) or ev.client_impl) and (not ev.client_ignore) then
+for _, ev in ipairs(events) do
+ if (not ev.noexport) and ((not ev.remote_only) or ev.client_impl) and not ev.client_ignore then
client_events[ev.name] = ev
end
end
-local hashorder, hashfun = hashy.hashy_hash("ui_client_handler", vim.tbl_keys(client_events), function (idx)
- return "event_handlers["..idx.."].name"
-end)
+local hashorder, hashfun = hashy.hashy_hash(
+ 'ui_client_handler',
+ vim.tbl_keys(client_events),
+ function(idx)
+ return 'event_handlers[' .. idx .. '].name'
+ end
+)
-client_output:write("static const UIClientHandler event_handlers[] = {\n")
+client_output:write('static const UIClientHandler event_handlers[] = {\n')
for _, name in ipairs(hashorder) do
- client_output:write(' { .name = "'..name..'", .fn = ui_client_event_'..name..'},\n')
+ client_output:write(' { .name = "' .. name .. '", .fn = ui_client_event_' .. name .. '},\n')
end
client_output:write('\n};\n\n')
@@ -172,25 +183,24 @@ remote_output:close()
client_output:close()
-- don't expose internal attributes like "impl_name" in public metadata
-local exported_attributes = {'name', 'parameters',
- 'since', 'deprecated_since'}
+local exported_attributes = { 'name', 'parameters', 'since', 'deprecated_since' }
local exported_events = {}
-for _,ev in ipairs(events) do
+for _, ev in ipairs(events) do
local ev_exported = {}
- for _,attr in ipairs(exported_attributes) do
+ for _, attr in ipairs(exported_attributes) do
ev_exported[attr] = ev[attr]
end
- for _,p in ipairs(ev_exported.parameters) do
+ for _, p in ipairs(ev_exported.parameters) do
if p[1] == 'HlAttrs' then
p[1] = 'Dictionary'
end
end
if not ev.noexport then
- exported_events[#exported_events+1] = ev_exported
+ exported_events[#exported_events + 1] = ev_exported
end
end
local packed = mpack.encode(exported_events)
-local dump_bin_array = require("generators.dump_bin_array")
+local dump_bin_array = require('generators.dump_bin_array')
dump_bin_array(metadata_output, 'ui_events_metadata', packed)
metadata_output:close()
diff --git a/src/nvim/generators/gen_char_blob.lua b/src/nvim/generators/gen_char_blob.lua
index 11f6cbcc13..c40e0d6e82 100644
--- a/src/nvim/generators/gen_char_blob.lua
+++ b/src/nvim/generators/gen_char_blob.lua
@@ -1,6 +1,6 @@
if arg[1] == '--help' then
print('Usage:')
- print(' '..arg[0]..' [-c] target source varname [source varname]...')
+ print(' ' .. arg[0] .. ' [-c] target source varname [source varname]...')
print('')
print('Generates C file with big uint8_t blob.')
print('Blob will be stored in a static const array named varname.')
@@ -12,7 +12,7 @@ end
local options = {}
while true do
- local opt = string.match(arg[1], "^-(%w)")
+ local opt = string.match(arg[1], '^-(%w)')
if not opt then
break
end
@@ -36,33 +36,33 @@ for argi = 2, #arg, 2 do
local source_file = arg[argi]
local modname = arg[argi + 1]
if modnames[modname] then
- error(string.format("modname %q is already specified for file %q", modname, modnames[modname]))
+ error(string.format('modname %q is already specified for file %q', modname, modnames[modname]))
end
modnames[modname] = source_file
- local varname = string.gsub(modname,'%.','_dot_').."_module"
+ local varname = string.gsub(modname, '%.', '_dot_') .. '_module'
target:write(('static const uint8_t %s[] = {\n'):format(varname))
local output
if options.c then
- local luac = os.getenv("LUAC_PRG")
- if luac and luac ~= "" then
- output = io.popen(luac:format(source_file), "r"):read("*a")
+ local luac = os.getenv('LUAC_PRG')
+ if luac and luac ~= '' then
+ output = io.popen(luac:format(source_file), 'r'):read('*a')
elseif warn_on_missing_compiler then
- print("LUAC_PRG is missing, embedding raw source")
+ print('LUAC_PRG is missing, embedding raw source')
warn_on_missing_compiler = false
end
end
if not output then
- local source = io.open(source_file, "r")
- or error(string.format("source_file %q doesn't exist", source_file))
- output = source:read("*a")
+ local source = io.open(source_file, 'r')
+ or error(string.format("source_file %q doesn't exist", source_file))
+ output = source:read('*a')
source:close()
end
local num_bytes = 0
- local MAX_NUM_BYTES = 15 -- 78 / 5: maximum number of bytes on one line
+ local MAX_NUM_BYTES = 15 -- 78 / 5: maximum number of bytes on one line
target:write(' ')
local increase_num_bytes
@@ -81,8 +81,11 @@ for argi = 2, #arg, 2 do
end
target:write(' 0};\n')
- if modname ~= "_" then
- table.insert(index_items, ' { "'..modname..'", '..varname..', sizeof '..varname..' },\n\n')
+ if modname ~= '_' then
+ table.insert(
+ index_items,
+ ' { "' .. modname .. '", ' .. varname .. ', sizeof ' .. varname .. ' },\n\n'
+ )
end
end
diff --git a/src/nvim/generators/gen_declarations.lua b/src/nvim/generators/gen_declarations.lua
index fecca5191e..9fd2750f52 100644
--- a/src/nvim/generators/gen_declarations.lua
+++ b/src/nvim/generators/gen_declarations.lua
@@ -5,9 +5,9 @@ local preproc_fname = arg[4]
local lpeg = vim.lpeg
-local fold = function (func, ...)
+local fold = function(func, ...)
local result = nil
- for _, v in ipairs({...}) do
+ for _, v in ipairs({ ... }) do
if result == nil then
result = v
else
@@ -17,144 +17,112 @@ local fold = function (func, ...)
return result
end
-local folder = function (func)
- return function (...)
+local folder = function(func)
+ return function(...)
return fold(func, ...)
end
end
local lit = lpeg.P
local set = function(...)
- return lpeg.S(fold(function (a, b) return a .. b end, ...))
+ return lpeg.S(fold(function(a, b)
+ return a .. b
+ end, ...))
end
local any_character = lpeg.P(1)
-local rng = function(s, e) return lpeg.R(s .. e) end
-local concat = folder(function (a, b) return a * b end)
-local branch = folder(function (a, b) return a + b end)
-local one_or_more = function(v) return v ^ 1 end
-local two_or_more = function(v) return v ^ 2 end
-local any_amount = function(v) return v ^ 0 end
-local one_or_no = function(v) return v ^ -1 end
+local rng = function(s, e)
+ return lpeg.R(s .. e)
+end
+local concat = folder(function(a, b)
+ return a * b
+end)
+local branch = folder(function(a, b)
+ return a + b
+end)
+local one_or_more = function(v)
+ return v ^ 1
+end
+local two_or_more = function(v)
+ return v ^ 2
+end
+local any_amount = function(v)
+ return v ^ 0
+end
+local one_or_no = function(v)
+ return v ^ -1
+end
local look_behind = lpeg.B
-local look_ahead = function(v) return #v end
-local neg_look_ahead = function(v) return -v end
-local neg_look_behind = function(v) return -look_behind(v) end
+local look_ahead = function(v)
+ return #v
+end
+local neg_look_ahead = function(v)
+ return -v
+end
+local neg_look_behind = function(v)
+ return -look_behind(v)
+end
-local w = branch(
- rng('a', 'z'),
- rng('A', 'Z'),
- lit('_')
-)
-local aw = branch(
- w,
- rng('0', '9')
-)
+local w = branch(rng('a', 'z'), rng('A', 'Z'), lit('_'))
+local aw = branch(w, rng('0', '9'))
local s = set(' ', '\n', '\t')
local raw_word = concat(w, any_amount(aw))
-local right_word = concat(
- raw_word,
- neg_look_ahead(aw)
-)
+local right_word = concat(raw_word, neg_look_ahead(aw))
local word = branch(
concat(
branch(lit('ArrayOf('), lit('DictionaryOf('), lit('Dict(')), -- typed container macro
one_or_more(any_character - lit(')')),
lit(')')
),
- concat(
- neg_look_behind(aw),
- right_word
- )
-)
-local inline_comment = concat(
- lit('/*'),
- any_amount(concat(
- neg_look_ahead(lit('*/')),
- any_character
- )),
- lit('*/')
+ concat(neg_look_behind(aw), right_word)
)
+local inline_comment =
+ concat(lit('/*'), any_amount(concat(neg_look_ahead(lit('*/')), any_character)), lit('*/'))
local spaces = any_amount(branch(
s,
-- Comments are really handled by preprocessor, so the following is not needed
inline_comment,
- concat(
- lit('//'),
- any_amount(concat(
- neg_look_ahead(lit('\n')),
- any_character
- )),
- lit('\n')
- ),
+ concat(lit('//'), any_amount(concat(neg_look_ahead(lit('\n')), any_character)), lit('\n')),
-- Linemarker inserted by preprocessor
- concat(
- lit('# '),
- any_amount(concat(
- neg_look_ahead(lit('\n')),
- any_character
- )),
- lit('\n')
- )
+ concat(lit('# '), any_amount(concat(neg_look_ahead(lit('\n')), any_character)), lit('\n'))
))
-local typ_part = concat(
- word,
- any_amount(concat(
- spaces,
- lit('*')
- )),
- spaces
-)
+local typ_part = concat(word, any_amount(concat(spaces, lit('*'))), spaces)
local typ_id = two_or_more(typ_part)
-local arg = typ_id -- argument name is swallowed by typ
+local arg = typ_id -- argument name is swallowed by typ
local pattern = concat(
any_amount(branch(set(' ', '\t'), inline_comment)),
- typ_id, -- return type with function name
+ typ_id, -- return type with function name
spaces,
lit('('),
spaces,
- one_or_no(branch( -- function arguments
+ one_or_no(branch( -- function arguments
concat(
- arg, -- first argument, does not require comma
- any_amount(concat( -- following arguments, start with a comma
+ arg, -- first argument, does not require comma
+ any_amount(concat( -- following arguments, start with a comma
spaces,
lit(','),
spaces,
arg,
- any_amount(concat(
- lit('['),
- spaces,
- any_amount(aw),
- spaces,
- lit(']')
- ))
+ any_amount(concat(lit('['), spaces, any_amount(aw), spaces, lit(']')))
)),
- one_or_no(concat(
- spaces,
- lit(','),
- spaces,
- lit('...')
- ))
+ one_or_no(concat(spaces, lit(','), spaces, lit('...')))
),
- lit('void') -- also accepts just void
+ lit('void') -- also accepts just void
)),
spaces,
lit(')'),
- any_amount(concat( -- optional attributes
+ any_amount(concat( -- optional attributes
spaces,
lit('FUNC_'),
any_amount(aw),
- one_or_no(concat( -- attribute argument
+ one_or_no(concat( -- attribute argument
spaces,
lit('('),
- any_amount(concat(
- neg_look_ahead(lit(')')),
- any_character
- )),
+ any_amount(concat(neg_look_ahead(lit(')')), any_character)),
lit(')')
))
)),
- look_ahead(concat( -- definition must be followed by "{"
+ look_ahead(concat( -- definition must be followed by "{"
spaces,
lit('{')
))
@@ -198,10 +166,9 @@ Additionally uses the following environment variables:
end
local preproc_f = io.open(preproc_fname)
-local text = preproc_f:read("*all")
+local text = preproc_f:read('*all')
preproc_f:close()
-
local non_static = [[
#define DEFINE_FUNC_ATTRIBUTES
#include "nvim/func_attr.h"
@@ -289,8 +256,7 @@ while init ~= nil do
declaration = declaration .. ';'
if os.getenv('NVIM_GEN_DECLARATIONS_LINE_NUMBERS') == '1' then
- declaration = declaration .. (' // %s/%s:%u'):format(
- curdir, curfile, declline)
+ declaration = declaration .. (' // %s/%s:%u'):format(curdir, curfile, declline)
end
declaration = declaration .. '\n'
if declaration:sub(1, 6) == 'static' then
diff --git a/src/nvim/generators/gen_eval.lua b/src/nvim/generators/gen_eval.lua
index 7b272c337e..1ce7f1af9d 100644
--- a/src/nvim/generators/gen_eval.lua
+++ b/src/nvim/generators/gen_eval.lua
@@ -8,7 +8,7 @@ local funcsfname = autodir .. '/funcs.generated.h'
--Will generate funcs.generated.h with definition of functions static const array.
-local hashy = require'generators.hashy'
+local hashy = require 'generators.hashy'
local hashpipe = assert(io.open(funcsfname, 'wb'))
@@ -48,18 +48,18 @@ hashpipe:write([[
local funcs = require('eval').funcs
for _, func in pairs(funcs) do
if func.float_func then
- func.func = "float_op_wrapper"
- func.data = "{ .float_func = &"..func.float_func.." }"
+ func.func = 'float_op_wrapper'
+ func.data = '{ .float_func = &' .. func.float_func .. ' }'
end
end
-local metadata = mpack.decode(io.open(metadata_file, 'rb'):read("*all"))
-for _,fun in ipairs(metadata) do
+local metadata = mpack.decode(io.open(metadata_file, 'rb'):read('*all'))
+for _, fun in ipairs(metadata) do
if fun.eval then
funcs[fun.name] = {
- args=#fun.parameters,
- func='api_wrapper',
- data='{ .api_handler = &method_handlers['..fun.handler_id..'] }'
+ args = #fun.parameters,
+ func = 'api_wrapper',
+ data = '{ .api_handler = &method_handlers[' .. fun.handler_id .. '] }',
}
end
end
@@ -74,28 +74,37 @@ local funcsdata = assert(io.open(funcs_file, 'w'))
funcsdata:write(mpack.encode(func_names))
funcsdata:close()
-local neworder, hashfun = hashy.hashy_hash("find_internal_func", func_names, function (idx)
- return "functions["..idx.."].name"
+local neworder, hashfun = hashy.hashy_hash('find_internal_func', func_names, function(idx)
+ return 'functions[' .. idx .. '].name'
end)
-hashpipe:write("static const EvalFuncDef functions[] = {\n")
+hashpipe:write('static const EvalFuncDef functions[] = {\n')
for _, name in ipairs(neworder) do
local def = funcs[name]
local args = def.args or 0
if type(args) == 'number' then
- args = {args, args}
+ args = { args, args }
elseif #args == 1 then
args[2] = 'MAX_FUNC_ARGS'
end
- local base = def.base or "BASE_NONE"
+ local base = def.base or 'BASE_NONE'
local func = def.func or ('f_' .. name)
- local data = def.data or "{ .null = NULL }"
+ local data = def.data or '{ .null = NULL }'
local fast = def.fast and 'true' or 'false'
- hashpipe:write((' { "%s", %s, %s, %s, %s, &%s, %s },\n')
- :format(name, args[1], args[2], base, fast, func, data))
+ hashpipe:write(
+ (' { "%s", %s, %s, %s, %s, &%s, %s },\n'):format(
+ name,
+ args[1],
+ args[2],
+ base,
+ fast,
+ func,
+ data
+ )
+ )
end
hashpipe:write(' { NULL, 0, 0, BASE_NONE, false, NULL, { .null = NULL } },\n')
-hashpipe:write("};\n\n")
+hashpipe:write('};\n\n')
hashpipe:write(hashfun)
hashpipe:close()
diff --git a/src/nvim/generators/gen_events.lua b/src/nvim/generators/gen_events.lua
index 4763a2f463..ee48e918e8 100644
--- a/src/nvim/generators/gen_events.lua
+++ b/src/nvim/generators/gen_events.lua
@@ -22,7 +22,7 @@ static const struct event_name {
for i, event in ipairs(events) do
enum_tgt:write(('\n EVENT_%s = %u,'):format(event:upper(), i - 1))
names_tgt:write(('\n {%u, "%s", EVENT_%s},'):format(#event, event, event:upper()))
- if i == #events then -- Last item.
+ if i == #events then -- Last item.
enum_tgt:write(('\n NUM_EVENTS = %u,'):format(i))
end
end
@@ -41,15 +41,15 @@ names_tgt:write('\n};\n')
do
names_tgt:write('\nstatic AutoCmdVec autocmds[NUM_EVENTS] = {\n ')
local line_len = 1
- for _ = 1,((#events) - 1) do
- line_len = line_len + #(' KV_INITIAL_VALUE,')
+ for _ = 1, (#events - 1) do
+ line_len = line_len + #' KV_INITIAL_VALUE,'
if line_len > 80 then
names_tgt:write('\n ')
- line_len = 1 + #(' KV_INITIAL_VALUE,')
+ line_len = 1 + #' KV_INITIAL_VALUE,'
end
names_tgt:write(' KV_INITIAL_VALUE,')
end
- if line_len + #(' KV_INITIAL_VALUE') > 80 then
+ if line_len + #' KV_INITIAL_VALUE' > 80 then
names_tgt:write('\n KV_INITIAL_VALUE')
else
names_tgt:write(' KV_INITIAL_VALUE')
diff --git a/src/nvim/generators/gen_ex_cmds.lua b/src/nvim/generators/gen_ex_cmds.lua
index ae8c952648..e8d1aac182 100644
--- a/src/nvim/generators/gen_ex_cmds.lua
+++ b/src/nvim/generators/gen_ex_cmds.lua
@@ -21,24 +21,32 @@ local a_to_z = byte_z - byte_a + 1
-- Table giving the index of the first command in cmdnames[] to lookup
-- based on the first letter of a command.
-local cmdidxs1_out = string.format([[
+local cmdidxs1_out = string.format(
+ [[
static const uint16_t cmdidxs1[%u] = {
-]], a_to_z)
+]],
+ a_to_z
+)
-- Table giving the index of the first command in cmdnames[] to lookup
-- based on the first 2 letters of a command.
-- Values in cmdidxs2[c1][c2] are relative to cmdidxs1[c1] so that they
-- fit in a byte.
-local cmdidxs2_out = string.format([[
+local cmdidxs2_out = string.format(
+ [[
static const uint8_t cmdidxs2[%u][%u] = {
/* a b c d e f g h i j k l m n o p q r s t u v w x y z */
-]], a_to_z, a_to_z)
+]],
+ a_to_z,
+ a_to_z
+)
enumfile:write([[
// IWYU pragma: private, include "nvim/ex_cmds_defs.h"
typedef enum CMD_index {
]])
-defsfile:write(string.format([[
+defsfile:write(string.format(
+ [[
#include "nvim/arglist.h"
#include "nvim/autocmd.h"
#include "nvim/buffer.h"
@@ -79,23 +87,34 @@ defsfile:write(string.format([[
static const int command_count = %u;
static CommandDefinition cmdnames[%u] = {
-]], #defs, #defs))
+]],
+ #defs,
+ #defs
+))
local cmds, cmdidxs1, cmdidxs2 = {}, {}, {}
for _, cmd in ipairs(defs) do
if bit.band(cmd.flags, flags.RANGE) == flags.RANGE then
- assert(cmd.addr_type ~= 'ADDR_NONE',
- string.format('ex_cmds.lua:%s: Using RANGE with ADDR_NONE\n', cmd.command))
+ assert(
+ cmd.addr_type ~= 'ADDR_NONE',
+ string.format('ex_cmds.lua:%s: Using RANGE with ADDR_NONE\n', cmd.command)
+ )
else
- assert(cmd.addr_type == 'ADDR_NONE',
- string.format('ex_cmds.lua:%s: Missing ADDR_NONE\n', cmd.command))
+ assert(
+ cmd.addr_type == 'ADDR_NONE',
+ string.format('ex_cmds.lua:%s: Missing ADDR_NONE\n', cmd.command)
+ )
end
if bit.band(cmd.flags, flags.DFLALL) == flags.DFLALL then
- assert(cmd.addr_type ~= 'ADDR_OTHER' and cmd.addr_type ~= 'ADDR_NONE',
- string.format('ex_cmds.lua:%s: Missing misplaced DFLALL\n', cmd.command))
+ assert(
+ cmd.addr_type ~= 'ADDR_OTHER' and cmd.addr_type ~= 'ADDR_NONE',
+ string.format('ex_cmds.lua:%s: Missing misplaced DFLALL\n', cmd.command)
+ )
end
if bit.band(cmd.flags, flags.PREVIEW) == flags.PREVIEW then
- assert(cmd.preview_func ~= nil,
- string.format('ex_cmds.lua:%s: Missing preview_func\n', cmd.command))
+ assert(
+ cmd.preview_func ~= nil,
+ string.format('ex_cmds.lua:%s: Missing preview_func\n', cmd.command)
+ )
end
local enumname = cmd.enum or ('CMD_' .. cmd.command)
local byte_cmd = cmd.command:sub(1, 1):byte()
@@ -104,12 +123,13 @@ for _, cmd in ipairs(defs) do
end
local preview_func
if cmd.preview_func then
- preview_func = string.format("&%s", cmd.preview_func)
+ preview_func = string.format('&%s', cmd.preview_func)
else
- preview_func = "NULL"
+ preview_func = 'NULL'
end
enumfile:write(' ' .. enumname .. ',\n')
- defsfile:write(string.format([[
+ defsfile:write(string.format(
+ [[
[%s] = {
.cmd_name = "%s",
.cmd_func = (ex_func_T)&%s,
@@ -117,7 +137,14 @@ for _, cmd in ipairs(defs) do
.cmd_argt = %uL,
.cmd_addr_type = %s
},
-]], enumname, cmd.command, cmd.func, preview_func, cmd.flags, cmd.addr_type))
+]],
+ enumname,
+ cmd.command,
+ cmd.func,
+ preview_func,
+ cmd.flags,
+ cmd.addr_type
+ ))
end
for i = #cmds, 1, -1 do
local cmd = cmds[i]
@@ -141,10 +168,12 @@ for i = byte_a, byte_z do
cmdidxs2_out = cmdidxs2_out .. ' /* ' .. c1 .. ' */ {'
for j = byte_a, byte_z do
local c2 = string.char(j)
- cmdidxs2_out = cmdidxs2_out ..
- ((cmdidxs2[c1] and cmdidxs2[c1][c2])
- and string.format('%3d', cmdidxs2[c1][c2] - cmdidxs1[c1])
- or ' 0') .. ','
+ cmdidxs2_out = cmdidxs2_out
+ .. ((cmdidxs2[c1] and cmdidxs2[c1][c2]) and string.format(
+ '%3d',
+ cmdidxs2[c1][c2] - cmdidxs1[c1]
+ ) or ' 0')
+ .. ','
end
cmdidxs2_out = cmdidxs2_out .. ' },\n'
end
@@ -154,8 +183,12 @@ enumfile:write([[
CMD_USER_BUF = -2
} cmdidx_T;
]])
-defsfile:write(string.format([[
+defsfile:write(string.format(
+ [[
};
%s};
%s};
-]], cmdidxs1_out, cmdidxs2_out))
+]],
+ cmdidxs1_out,
+ cmdidxs2_out
+))
diff --git a/src/nvim/generators/gen_options.lua b/src/nvim/generators/gen_options.lua
index 26ade2745d..3a355634f3 100644
--- a/src/nvim/generators/gen_options.lua
+++ b/src/nvim/generators/gen_options.lua
@@ -15,37 +15,37 @@ local options = require('options')
local cstr = options.cstr
-local type_flags={
- bool='P_BOOL',
- number='P_NUM',
- string='P_STRING',
+local type_flags = {
+ bool = 'P_BOOL',
+ number = 'P_NUM',
+ string = 'P_STRING',
}
-local redraw_flags={
- ui_option='P_UI_OPTION',
- tabline='P_RTABL',
- statuslines='P_RSTAT',
- current_window='P_RWIN',
- current_window_only='P_RWINONLY',
- current_buffer='P_RBUF',
- all_windows='P_RALL',
- curswant='P_CURSWANT',
+local redraw_flags = {
+ ui_option = 'P_UI_OPTION',
+ tabline = 'P_RTABL',
+ statuslines = 'P_RSTAT',
+ current_window = 'P_RWIN',
+ current_window_only = 'P_RWINONLY',
+ current_buffer = 'P_RBUF',
+ all_windows = 'P_RALL',
+ curswant = 'P_CURSWANT',
}
-local list_flags={
- comma='P_COMMA',
- onecomma='P_ONECOMMA',
- commacolon='P_COMMA|P_COLON',
- onecommacolon='P_ONECOMMA|P_COLON',
- flags='P_FLAGLIST',
- flagscomma='P_COMMA|P_FLAGLIST',
+local list_flags = {
+ comma = 'P_COMMA',
+ onecomma = 'P_ONECOMMA',
+ commacolon = 'P_COMMA|P_COLON',
+ onecommacolon = 'P_ONECOMMA|P_COLON',
+ flags = 'P_FLAGLIST',
+ flagscomma = 'P_COMMA|P_FLAGLIST',
}
--- @param o vim.option_meta
--- @return string
local function get_flags(o)
--- @type string[]
- local ret = {type_flags[o.type]}
+ local ret = { type_flags[o.type] }
local add_flag = function(f)
ret[1] = ret[1] .. '|' .. f
end
@@ -64,19 +64,19 @@ local function get_flags(o)
end
end
for _, flag_desc in ipairs({
- {'alloced'},
- {'nodefault'},
- {'no_mkrc'},
- {'secure'},
- {'gettext'},
- {'noglob'},
- {'normal_fname_chars', 'P_NFNAME'},
- {'normal_dname_chars', 'P_NDNAME'},
- {'pri_mkrc'},
- {'deny_in_modelines', 'P_NO_ML'},
- {'deny_duplicates', 'P_NODUP'},
- {'modelineexpr', 'P_MLE'},
- {'func'}
+ { 'alloced' },
+ { 'nodefault' },
+ { 'no_mkrc' },
+ { 'secure' },
+ { 'gettext' },
+ { 'noglob' },
+ { 'normal_fname_chars', 'P_NFNAME' },
+ { 'normal_dname_chars', 'P_NDNAME' },
+ { 'pri_mkrc' },
+ { 'deny_in_modelines', 'P_NO_ML' },
+ { 'deny_duplicates', 'P_NODUP' },
+ { 'modelineexpr', 'P_MLE' },
+ { 'func' },
}) do
local key_name = flag_desc[1]
local def_name = flag_desc[2] or ('P_' .. key_name:upper())
@@ -108,20 +108,28 @@ local function get_cond(c, base_string)
end
local value_dumpers = {
- ['function']=function(v) return v() end,
- string=cstr,
- boolean=function(v) return v and 'true' or 'false' end,
- number=function(v) return ('%iL'):format(v) end,
- ['nil']=function(_) return '0' end,
+ ['function'] = function(v)
+ return v()
+ end,
+ string = cstr,
+ boolean = function(v)
+ return v and 'true' or 'false'
+ end,
+ number = function(v)
+ return ('%iL'):format(v)
+ end,
+ ['nil'] = function(_)
+ return '0'
+ end,
}
local get_value = function(v)
return '(void *) ' .. value_dumpers[type(v)](v)
end
-local get_defaults = function(d,n)
+local get_defaults = function(d, n)
if d == nil then
- error("option '"..n.."' should have a default value")
+ error("option '" .. n .. "' should have a default value")
end
return get_value(d)
end
@@ -153,20 +161,21 @@ local function dump_option(i, o)
if #o.scope == 1 and o.scope[1] == 'global' then
w(' .indir=PV_NONE')
else
- assert (#o.scope == 1 or #o.scope == 2)
- assert (#o.scope == 1 or o.scope[1] == 'global')
+ assert(#o.scope == 1 or #o.scope == 2)
+ assert(#o.scope == 1 or o.scope[1] == 'global')
local min_scope = o.scope[#o.scope]
- local varname = o.pv_name or o.varname or (
- 'p_' .. (o.abbreviation or o.full_name))
+ local varname = o.pv_name or o.varname or ('p_' .. (o.abbreviation or o.full_name))
local pv_name = (
- 'OPT_' .. min_scope:sub(1, 3):upper() .. '(' .. (
- min_scope:sub(1, 1):upper() .. 'V_' .. varname:sub(3):upper()
- ) .. ')'
+ 'OPT_'
+ .. min_scope:sub(1, 3):upper()
+ .. '('
+ .. (min_scope:sub(1, 1):upper() .. 'V_' .. varname:sub(3):upper())
+ .. ')'
)
if #o.scope == 2 then
pv_name = 'OPT_BOTH(' .. pv_name .. ')'
end
- table.insert(defines, { 'PV_' .. varname:sub(3):upper() , pv_name})
+ table.insert(defines, { 'PV_' .. varname:sub(3):upper(), pv_name })
w(' .indir=' .. pv_name)
end
if o.cb then
diff --git a/src/nvim/generators/gen_unicode_tables.lua b/src/nvim/generators/gen_unicode_tables.lua
index 9ad99c8029..6cedb5db50 100644
--- a/src/nvim/generators/gen_unicode_tables.lua
+++ b/src/nvim/generators/gen_unicode_tables.lua
@@ -60,12 +60,10 @@ local fp_lines_to_lists = function(fp, n, has_comments)
if not line then
break
end
- if (not has_comments
- or (line:sub(1, 1) ~= '#' and not line:match('^%s*$'))) then
+ if not has_comments or (line:sub(1, 1) ~= '#' and not line:match('^%s*$')) then
local l = split_on_semicolons(line)
if #l ~= n then
- io.stderr:write(('Found %s items in line %u, expected %u\n'):format(
- #l, i, n))
+ io.stderr:write(('Found %s items in line %u, expected %u\n'):format(#l, i, n))
io.stderr:write('Line: ' .. line .. '\n')
return nil
end
@@ -93,15 +91,13 @@ end
local make_range = function(start, end_, step, add)
if step and add then
- return (' {0x%x, 0x%x, %d, %d},\n'):format(
- start, end_, step == 0 and -1 or step, add)
+ return (' {0x%x, 0x%x, %d, %d},\n'):format(start, end_, step == 0 and -1 or step, add)
else
return (' {0x%04x, 0x%04x},\n'):format(start, end_)
end
end
-local build_convert_table = function(ut_fp, props, cond_func, nl_index,
- table_name)
+local build_convert_table = function(ut_fp, props, cond_func, nl_index, table_name)
ut_fp:write('static const convertStruct ' .. table_name .. '[] = {\n')
local start = -1
local end_ = -1
@@ -137,8 +133,7 @@ local build_case_table = function(ut_fp, dataprops, table_name, index)
local cond_func = function(p)
return p[index] ~= ''
end
- return build_convert_table(ut_fp, dataprops, cond_func, index,
- 'to' .. table_name)
+ return build_convert_table(ut_fp, dataprops, cond_func, index, 'to' .. table_name)
end
local build_fold_table = function(ut_fp, foldprops)
@@ -154,7 +149,7 @@ local build_combining_table = function(ut_fp, dataprops)
local end_ = -1
for _, p in ipairs(dataprops) do
-- The 'Mc' property was removed, it does take up space.
- if (({Mn=true, Me=true})[p[3]]) then
+ if ({ Mn = true, Me = true })[p[3]] then
local n = tonumber(p[1], 16)
if start >= 0 and end_ + 1 == n then
-- Continue with the same range.
@@ -175,8 +170,7 @@ local build_combining_table = function(ut_fp, dataprops)
ut_fp:write('};\n')
end
-local build_width_table = function(ut_fp, dataprops, widthprops, widths,
- table_name)
+local build_width_table = function(ut_fp, dataprops, widthprops, widths, table_name)
ut_fp:write('static const struct interval ' .. table_name .. '[] = {\n')
local start = -1
local end_ = -1
@@ -208,13 +202,13 @@ local build_width_table = function(ut_fp, dataprops, widthprops, widths,
-- Only use the char when it’s not a composing char.
-- But use all chars from a range.
local dp = dataprops[dataidx]
- if (n_last > n) or (not (({Mn=true, Mc=true, Me=true})[dp[3]])) then
+ if (n_last > n) or not ({ Mn = true, Mc = true, Me = true })[dp[3]] then
if start >= 0 and end_ + 1 == n then -- luacheck: ignore 542
-- Continue with the same range.
else
if start >= 0 then
ut_fp:write(make_range(start, end_))
- table.insert(ret, {start, end_})
+ table.insert(ret, { start, end_ })
end
start = n
end
@@ -224,7 +218,7 @@ local build_width_table = function(ut_fp, dataprops, widthprops, widths,
end
if start >= 0 then
ut_fp:write(make_range(start, end_))
- table.insert(ret, {start, end_})
+ table.insert(ret, { start, end_ })
end
ut_fp:write('};\n')
return ret
@@ -316,10 +310,9 @@ local eaw_fp = io.open(eastasianwidth_fname, 'r')
local widthprops = parse_width_props(eaw_fp)
eaw_fp:close()
-local doublewidth = build_width_table(ut_fp, dataprops, widthprops,
- {W=true, F=true}, 'doublewidth')
-local ambiwidth = build_width_table(ut_fp, dataprops, widthprops,
- {A=true}, 'ambiguous')
+local doublewidth =
+ build_width_table(ut_fp, dataprops, widthprops, { W = true, F = true }, 'doublewidth')
+local ambiwidth = build_width_table(ut_fp, dataprops, widthprops, { A = true }, 'ambiguous')
local emoji_fp = io.open(emoji_fname, 'r')
local emojiprops = parse_emoji_props(emoji_fp)
diff --git a/src/nvim/generators/gen_vimvim.lua b/src/nvim/generators/gen_vimvim.lua
index 29355d3cda..4d1c82a322 100644
--- a/src/nvim/generators/gen_vimvim.lua
+++ b/src/nvim/generators/gen_vimvim.lua
@@ -41,12 +41,14 @@ end
-- Exclude these from the vimCommand keyword list, they are handled specially
-- in syntax/vim.vim (vimAugroupKey, vimAutoCmd, vimGlobal, vimSubst). #9327
local function is_special_cased_cmd(cmd)
- return (cmd == 'augroup'
- or cmd == 'autocmd'
- or cmd == 'doautocmd'
- or cmd == 'doautoall'
- or cmd == 'global'
- or cmd == 'substitute')
+ return (
+ cmd == 'augroup'
+ or cmd == 'autocmd'
+ or cmd == 'doautocmd'
+ or cmd == 'doautoall'
+ or cmd == 'global'
+ or cmd == 'substitute'
+ )
end
local vimcmd_start = 'syn keyword vimCommand contained '
@@ -133,7 +135,7 @@ end
w('\n\nsyn case match')
local vimfun_start = 'syn keyword vimFuncName contained '
w('\n\n' .. vimfun_start)
-local funcs = mpack.decode(io.open(funcs_file, 'rb'):read("*all"))
+local funcs = mpack.decode(io.open(funcs_file, 'rb'):read('*all'))
for _, name in ipairs(funcs) do
if name then
if lld.line_length > 850 then
diff --git a/src/nvim/generators/hashy.lua b/src/nvim/generators/hashy.lua
index b10bafb9f9..711e695742 100644
--- a/src/nvim/generators/hashy.lua
+++ b/src/nvim/generators/hashy.lua
@@ -3,7 +3,6 @@
local M = {}
_G.d = M
-
local function setdefault(table, key)
local val = table[key]
if val == nil then
@@ -16,28 +15,30 @@ end
function M.build_pos_hash(strings)
local len_buckets = {}
local maxlen = 0
- for _,s in ipairs(strings) do
- table.insert(setdefault(len_buckets, #s),s)
- if #s > maxlen then maxlen = #s end
+ for _, s in ipairs(strings) do
+ table.insert(setdefault(len_buckets, #s), s)
+ if #s > maxlen then
+ maxlen = #s
+ end
end
local len_pos_buckets = {}
local worst_buck_size = 0
- for len = 1,maxlen do
+ for len = 1, maxlen do
local strs = len_buckets[len]
if strs then
-- the best position so far generates `best_bucket`
-- with `minsize` worst case collisions
- local bestpos, minsize, best_bucket = nil, #strs*2, nil
- for pos = 1,len do
+ local bestpos, minsize, best_bucket = nil, #strs * 2, nil
+ for pos = 1, len do
local try_bucket = {}
- for _,str in ipairs(strs) do
+ for _, str in ipairs(strs) do
local poschar = string.sub(str, pos, pos)
table.insert(setdefault(try_bucket, poschar), str)
end
local maxsize = 1
- for _,pos_strs in pairs(try_bucket) do
+ for _, pos_strs in pairs(try_bucket) do
maxsize = math.max(maxsize, #pos_strs)
end
if maxsize < minsize then
@@ -46,7 +47,7 @@ function M.build_pos_hash(strings)
best_bucket = try_bucket
end
end
- len_pos_buckets[len] = {bestpos, best_bucket}
+ len_pos_buckets[len] = { bestpos, best_bucket }
worst_buck_size = math.max(worst_buck_size, minsize)
end
end
@@ -55,73 +56,79 @@ end
function M.switcher(put, tab, maxlen, worst_buck_size)
local neworder = {}
- put " switch (len) {\n"
+ put ' switch (len) {\n'
local bucky = worst_buck_size > 1
- for len = 1,maxlen do
+ for len = 1, maxlen do
local vals = tab[len]
if vals then
- put(" case "..len..": ")
+ put(' case ' .. len .. ': ')
local pos, posbuck = unpack(vals)
local keys = vim.tbl_keys(posbuck)
if #keys > 1 then
table.sort(keys)
- put("switch (str["..(pos-1).."]) {\n")
- for _,c in ipairs(keys) do
+ put('switch (str[' .. (pos - 1) .. ']) {\n')
+ for _, c in ipairs(keys) do
local buck = posbuck[c]
local startidx = #neworder
vim.list_extend(neworder, buck)
local endidx = #neworder
- put(" case '"..c.."': ")
- put("low = "..startidx.."; ")
- if bucky then put("high = "..endidx.."; ") end
- put "break;\n"
+ put(" case '" .. c .. "': ")
+ put('low = ' .. startidx .. '; ')
+ if bucky then
+ put('high = ' .. endidx .. '; ')
+ end
+ put 'break;\n'
end
- put " default: break;\n"
- put " }\n "
+ put ' default: break;\n'
+ put ' }\n '
else
- local startidx = #neworder
- table.insert(neworder, posbuck[keys[1]][1])
- local endidx = #neworder
- put("low = "..startidx.."; ")
- if bucky then put("high = "..endidx.."; ") end
+ local startidx = #neworder
+ table.insert(neworder, posbuck[keys[1]][1])
+ local endidx = #neworder
+ put('low = ' .. startidx .. '; ')
+ if bucky then
+ put('high = ' .. endidx .. '; ')
+ end
end
- put "break;\n"
+ put 'break;\n'
end
end
- put " default: break;\n"
- put " }\n"
+ put ' default: break;\n'
+ put ' }\n'
return neworder
end
function M.hashy_hash(name, strings, access)
local stats = {}
- local put = function(str) table.insert(stats, str) end
+ local put = function(str)
+ table.insert(stats, str)
+ end
local len_pos_buckets, maxlen, worst_buck_size = M.build_pos_hash(strings)
- put("int "..name.."_hash(const char *str, size_t len)\n{\n")
+ put('int ' .. name .. '_hash(const char *str, size_t len)\n{\n')
if worst_buck_size > 1 then
- put(" int low = 0, high = 0;\n")
+ put(' int low = 0, high = 0;\n')
else
- put(" int low = -1;\n")
+ put(' int low = -1;\n')
end
local neworder = M.switcher(put, len_pos_buckets, maxlen, worst_buck_size)
if worst_buck_size > 1 then
- put ([[
+ put([[
for (int i = low; i < high; i++) {
- if (!memcmp(str, ]]..access("i")..[[, len)) {
+ if (!memcmp(str, ]] .. access('i') .. [[, len)) {
return i;
}
}
return -1;
]])
else
- put ([[
- if (low < 0 || memcmp(str, ]]..access("low")..[[, len)) {
+ put([[
+ if (low < 0 || memcmp(str, ]] .. access('low') .. [[, len)) {
return -1;
}
return low;
]])
end
- put "}\n\n"
+ put '}\n\n'
return neworder, table.concat(stats)
end
diff --git a/src/nvim/generators/preload.lua b/src/nvim/generators/preload.lua
index 4b7fde2c39..721d2880b8 100644
--- a/src/nvim/generators/preload.lua
+++ b/src/nvim/generators/preload.lua
@@ -1,7 +1,7 @@
local srcdir = table.remove(arg, 1)
local nlualib = table.remove(arg, 1)
-package.path = srcdir .. '/src/nvim/?.lua;' ..srcdir .. '/runtime/lua/?.lua;' .. package.path
-_G.vim = require'vim.shared'
+package.path = srcdir .. '/src/nvim/?.lua;' .. srcdir .. '/runtime/lua/?.lua;' .. package.path
+_G.vim = require 'vim.shared'
_G.vim.inspect = require 'vim.inspect'
package.cpath = package.cpath .. ';' .. nlualib
require 'nlua0'
diff --git a/src/nvim/highlight_group.c b/src/nvim/highlight_group.c
index 3953a459bc..3bd4aa4f64 100644
--- a/src/nvim/highlight_group.c
+++ b/src/nvim/highlight_group.c
@@ -135,263 +135,321 @@ static const char e_missing_argument_str[]
// they still work when the runtime files can't be found.
static const char *highlight_init_both[] = {
- "Conceal ctermbg=DarkGrey ctermfg=LightGrey guibg=DarkGrey guifg=LightGrey",
- "Cursor guibg=fg guifg=bg",
- "lCursor guibg=fg guifg=bg",
- "DiffText cterm=bold ctermbg=Red gui=bold guibg=Red",
- "ErrorMsg ctermbg=DarkRed ctermfg=White guibg=Red guifg=White",
- "IncSearch cterm=reverse gui=reverse",
- "ModeMsg cterm=bold gui=bold",
- "NonText ctermfg=Blue gui=bold guifg=Blue",
- "Normal cterm=NONE gui=NONE",
- "PmenuSbar ctermbg=Grey guibg=Grey",
- "StatusLine cterm=reverse,bold gui=reverse,bold",
- "StatusLineNC cterm=reverse gui=reverse",
- "TabLineFill cterm=reverse gui=reverse",
- "TabLineSel cterm=bold gui=bold",
- "TermCursor cterm=reverse gui=reverse",
- "WinBar cterm=bold gui=bold",
- "WildMenu ctermbg=Yellow ctermfg=Black guibg=Yellow guifg=Black",
- "default link VertSplit Normal",
- "default link WinSeparator VertSplit",
- "default link WinBarNC WinBar",
- "default link EndOfBuffer NonText",
- "default link LineNrAbove LineNr",
- "default link LineNrBelow LineNr",
- "default link QuickFixLine Search",
- "default link CursorLineSign SignColumn",
+ "Cursor guibg=fg guifg=bg",
+ "CursorLineNr gui=bold cterm=bold",
+ "QuickFixLine gui=bold cterm=bold",
+ "RedrawDebugNormal gui=reverse cterm=reverse",
+ "TabLineSel gui=bold cterm=bold",
+ "TermCursor gui=reverse cterm=reverse",
+ "Title gui=bold cterm=bold",
+ "Underlined gui=underline cterm=underline",
+ "lCursor guibg=fg guifg=bg",
+
+ // UI
+ "default link CurSearch Search",
+ "default link CursorIM Cursor",
"default link CursorLineFold FoldColumn",
- "default link CurSearch Search",
- "default link PmenuKind Pmenu",
- "default link PmenuKindSel PmenuSel",
- "default link PmenuExtra Pmenu",
- "default link PmenuExtraSel PmenuSel",
- "default link Substitute Search",
- "default link Whitespace NonText",
- "default link MsgSeparator StatusLine",
- "default link NormalFloat Pmenu",
- "default link FloatBorder WinSeparator",
- "default link FloatTitle Title",
- "default link FloatFooter Title",
- "default FloatShadow blend=80 guibg=Black",
- "default FloatShadowThrough blend=100 guibg=Black",
- "RedrawDebugNormal cterm=reverse gui=reverse",
- "RedrawDebugClear ctermbg=Yellow guibg=Yellow",
- "RedrawDebugComposed ctermbg=Green guibg=Green",
- "RedrawDebugRecompose ctermbg=Red guibg=Red",
- "Error term=reverse cterm=NONE ctermfg=White ctermbg=Red gui=NONE guifg=White guibg=Red",
- "Todo term=standout cterm=NONE ctermfg=Black ctermbg=Yellow gui=NONE guifg=Blue guibg=Yellow",
- "default link String Constant",
- "default link Character Constant",
- "default link Number Constant",
- "default link Boolean Constant",
- "default link Float Number",
- "default link Function Identifier",
- "default link Conditional Statement",
- "default link Repeat Statement",
- "default link Label Statement",
- "default link Operator Statement",
- "default link Keyword Statement",
- "default link Exception Statement",
- "default link Include PreProc",
- "default link Define PreProc",
- "default link Macro PreProc",
- "default link PreCondit PreProc",
- "default link StorageClass Type",
- "default link Structure Type",
- "default link Typedef Type",
- "default link Tag Special",
- "default link SpecialChar Special",
- "default link Delimiter Special",
+ "default link CursorLineSign SignColumn",
+ "default link EndOfBuffer NonText",
+ "default link FloatBorder NormalFloat",
+ "default link FloatFooter Title",
+ "default link FloatTitle Title",
+ "default link FoldColumn SignColumn",
+ "default link IncSearch Search",
+ "default link LineNrAbove LineNr",
+ "default link LineNrBelow LineNr",
+ "default link MsgSeparator StatusLine",
+ "default link MsgArea NONE",
+ "default link NormalNC NONE",
+ "default link PmenuExtra Pmenu",
+ "default link PmenuExtraSel PmenuSel",
+ "default link PmenuKind Pmenu",
+ "default link PmenuKindSel PmenuSel",
+ "default link PmenuSbar Pmenu",
+ "default link Substitute Search",
+ "default link TabLineFill TabLine",
+ "default link TermCursorNC NONE",
+ "default link VertSplit WinSeparator",
+ "default link VisualNOS Visual",
+ "default link Whitespace NonText",
+ "default link WildMenu PmenuSel",
+ "default link WinBar StatusLine",
+ "default link WinBarNC StatusLineNC",
+ "default link WinSeparator Normal",
+
+ // Syntax
+ "default link Character Constant",
+ "default link Number Constant",
+ "default link Boolean Constant",
+ "default link Float Number",
+ "default link Conditional Statement",
+ "default link Repeat Statement",
+ "default link Label Statement",
+ "default link Keyword Statement",
+ "default link Exception Statement",
+ "default link Include PreProc",
+ "default link Define PreProc",
+ "default link Macro PreProc",
+ "default link PreCondit PreProc",
+ "default link StorageClass Type",
+ "default link Structure Type",
+ "default link Typedef Type",
+ "default link Tag Special",
+ "default link SpecialChar Special",
"default link SpecialComment Special",
- "default link Debug Special",
- "default DiagnosticError ctermfg=1 guifg=Red",
- "default DiagnosticWarn ctermfg=3 guifg=Orange",
- "default DiagnosticInfo ctermfg=4 guifg=LightBlue",
- "default DiagnosticHint ctermfg=7 guifg=LightGrey",
- "default DiagnosticOk ctermfg=10 guifg=LightGreen",
- "default DiagnosticUnderlineError cterm=underline gui=underline guisp=Red",
- "default DiagnosticUnderlineWarn cterm=underline gui=underline guisp=Orange",
- "default DiagnosticUnderlineInfo cterm=underline gui=underline guisp=LightBlue",
- "default DiagnosticUnderlineHint cterm=underline gui=underline guisp=LightGrey",
- "default DiagnosticUnderlineOk cterm=underline gui=underline guisp=LightGreen",
- "default link DiagnosticVirtualTextError DiagnosticError",
- "default link DiagnosticVirtualTextWarn DiagnosticWarn",
- "default link DiagnosticVirtualTextInfo DiagnosticInfo",
- "default link DiagnosticVirtualTextHint DiagnosticHint",
- "default link DiagnosticVirtualTextOk DiagnosticOk",
- "default link DiagnosticFloatingError DiagnosticError",
- "default link DiagnosticFloatingWarn DiagnosticWarn",
- "default link DiagnosticFloatingInfo DiagnosticInfo",
- "default link DiagnosticFloatingHint DiagnosticHint",
- "default link DiagnosticFloatingOk DiagnosticOk",
- "default link DiagnosticSignError DiagnosticError",
- "default link DiagnosticSignWarn DiagnosticWarn",
- "default link DiagnosticSignInfo DiagnosticInfo",
- "default link DiagnosticSignHint DiagnosticHint",
- "default link DiagnosticSignOk DiagnosticOk",
- "default DiagnosticDeprecated cterm=strikethrough gui=strikethrough guisp=Red",
- "default link DiagnosticUnnecessary Comment",
- "default link LspInlayHint NonText",
+ "default link Debug Special",
+ "default link Ignore Normal",
+ "default link LspInlayHint NonText",
"default link SnippetTabstop Visual",
+ // Diagnostic
+ "default link DiagnosticVirtualTextError DiagnosticError",
+ "default link DiagnosticVirtualTextWarn DiagnosticWarn",
+ "default link DiagnosticVirtualTextInfo DiagnosticInfo",
+ "default link DiagnosticVirtualTextHint DiagnosticHint",
+ "default link DiagnosticVirtualTextOk DiagnosticOk",
+ "default link DiagnosticSignError DiagnosticError",
+ "default link DiagnosticSignWarn DiagnosticWarn",
+ "default link DiagnosticSignInfo DiagnosticInfo",
+ "default link DiagnosticSignHint DiagnosticHint",
+ "default link DiagnosticSignOk DiagnosticOk",
+ "default link DiagnosticUnnecessary Comment",
+
// Text
- "default link @text.literal Comment",
+ "default link @text.literal Comment",
"default link @text.reference Identifier",
- "default link @text.title Title",
- "default link @text.uri Underlined",
+ "default link @text.title Title",
+ "default link @text.uri Underlined",
"default link @text.underline Underlined",
- "default link @text.todo Todo",
+ "default link @text.todo Todo",
// Miscs
- "default link @comment Comment",
+ "default link @comment Comment",
"default link @punctuation Delimiter",
// Constants
- "default link @constant Constant",
- "default link @constant.builtin Special",
- "default link @constant.macro Define",
- "default link @define Define",
- "default link @macro Macro",
- "default link @string String",
- "default link @string.escape SpecialChar",
- "default link @string.special SpecialChar",
- "default link @character Character",
+ "default link @constant Constant",
+ "default link @constant.builtin Special",
+ "default link @constant.macro Define",
+ "default link @define Define",
+ "default link @macro Macro",
+ "default link @string String",
+ "default link @string.escape SpecialChar",
+ "default link @string.special SpecialChar",
+ "default link @character Character",
"default link @character.special SpecialChar",
- "default link @number Number",
- "default link @boolean Boolean",
- "default link @float Float",
+ "default link @number Number",
+ "default link @boolean Boolean",
+ "default link @float Float",
// Functions
- "default link @function Function",
+ "default link @function Function",
"default link @function.builtin Special",
- "default link @function.macro Macro",
- "default link @parameter Identifier",
- "default link @method Function",
- "default link @field Identifier",
- "default link @property Identifier",
- "default link @constructor Special",
+ "default link @function.macro Macro",
+ "default link @parameter Identifier",
+ "default link @method Function",
+ "default link @field Identifier",
+ "default link @property Identifier",
+ "default link @constructor Special",
// Keywords
"default link @conditional Conditional",
- "default link @repeat Repeat",
- "default link @label Label",
- "default link @operator Operator",
- "default link @keyword Keyword",
- "default link @exception Exception",
-
- "default link @variable Identifier",
- "default link @type Type",
+ "default link @repeat Repeat",
+ "default link @label Label",
+ "default link @operator Operator",
+ "default link @keyword Keyword",
+ "default link @exception Exception",
+
+ "default link @variable NONE", // don't highlight to reduce visual overload
+ "default link @type Type",
"default link @type.definition Typedef",
- "default link @storageclass StorageClass",
- "default link @namespace Identifier",
- "default link @include Include",
- "default link @preproc PreProc",
- "default link @debug Debug",
- "default link @tag Tag",
+ "default link @storageclass StorageClass",
+ "default link @namespace Identifier",
+ "default link @include Include",
+ "default link @preproc PreProc",
+ "default link @debug Debug",
+ "default link @tag Tag",
// LSP semantic tokens
- "default link @lsp.type.class Structure",
- "default link @lsp.type.comment Comment",
- "default link @lsp.type.decorator Function",
- "default link @lsp.type.enum Structure",
- "default link @lsp.type.enumMember Constant",
- "default link @lsp.type.function Function",
- "default link @lsp.type.interface Structure",
- "default link @lsp.type.macro Macro",
- "default link @lsp.type.method Function",
- "default link @lsp.type.namespace Structure",
- "default link @lsp.type.parameter Identifier",
- "default link @lsp.type.property Identifier",
- "default link @lsp.type.struct Structure",
- "default link @lsp.type.type Type",
+ "default link @lsp.type.class Structure",
+ "default link @lsp.type.comment Comment",
+ "default link @lsp.type.decorator Function",
+ "default link @lsp.type.enum Structure",
+ "default link @lsp.type.enumMember Constant",
+ "default link @lsp.type.function Function",
+ "default link @lsp.type.interface Structure",
+ "default link @lsp.type.macro Macro",
+ "default link @lsp.type.method Function",
+ "default link @lsp.type.namespace Structure",
+ "default link @lsp.type.parameter Identifier",
+ "default link @lsp.type.property Identifier",
+ "default link @lsp.type.struct Structure",
+ "default link @lsp.type.type Type",
"default link @lsp.type.typeParameter TypeDef",
- "default link @lsp.type.variable Identifier",
+ "default link @lsp.type.variable NONE", // don't highlight to reduce visual overload
NULL
};
// Default colors only used with a light background.
static const char *highlight_init_light[] = {
- "ColorColumn ctermbg=LightRed guibg=LightRed",
- "CursorColumn ctermbg=LightGrey guibg=Grey90",
- "CursorLine cterm=underline guibg=Grey90",
- "CursorLineNr cterm=underline ctermfg=Brown gui=bold guifg=Brown",
- "DiffAdd ctermbg=LightBlue guibg=LightBlue",
- "DiffChange ctermbg=LightMagenta guibg=LightMagenta",
- "DiffDelete ctermfg=Blue ctermbg=LightCyan gui=bold guifg=Blue guibg=LightCyan",
- "Directory ctermfg=DarkBlue guifg=Blue",
- "FoldColumn ctermbg=Grey ctermfg=DarkBlue guibg=Grey guifg=DarkBlue",
- "Folded ctermbg=Grey ctermfg=DarkBlue guibg=LightGrey guifg=DarkBlue",
- "LineNr ctermfg=Brown guifg=Brown",
- "MatchParen ctermbg=Cyan guibg=Cyan",
- "MoreMsg ctermfg=DarkGreen gui=bold guifg=SeaGreen",
- "Pmenu ctermbg=LightMagenta ctermfg=Black guibg=LightMagenta",
- "PmenuSel ctermbg=LightGrey ctermfg=Black guibg=Grey",
- "PmenuThumb ctermbg=Black guibg=Black",
- "Question ctermfg=DarkGreen gui=bold guifg=SeaGreen",
- "Search ctermbg=Yellow ctermfg=NONE guibg=Yellow guifg=NONE",
- "SignColumn ctermbg=Grey ctermfg=DarkBlue guibg=Grey guifg=DarkBlue",
- "SpecialKey ctermfg=DarkBlue guifg=Blue",
- "SpellBad ctermbg=LightRed guisp=Red gui=undercurl",
- "SpellCap ctermbg=LightBlue guisp=Blue gui=undercurl",
- "SpellLocal ctermbg=Cyan guisp=DarkCyan gui=undercurl",
- "SpellRare ctermbg=LightMagenta guisp=Magenta gui=undercurl",
- "TabLine cterm=underline ctermfg=black ctermbg=LightGrey gui=underline guibg=LightGrey",
- "Title ctermfg=DarkMagenta gui=bold guifg=Magenta",
- "Visual guibg=LightGrey",
- "WarningMsg ctermfg=DarkRed guifg=Red",
- "Comment term=bold cterm=NONE ctermfg=DarkBlue ctermbg=NONE gui=NONE guifg=Blue guibg=NONE",
- "Constant term=underline cterm=NONE ctermfg=DarkRed ctermbg=NONE gui=NONE guifg=Magenta guibg=NONE",
- "Special term=bold cterm=NONE ctermfg=DarkMagenta ctermbg=NONE gui=NONE guifg=#6a5acd guibg=NONE",
- "Identifier term=underline cterm=NONE ctermfg=DarkCyan ctermbg=NONE gui=NONE guifg=DarkCyan guibg=NONE",
- "Statement term=bold cterm=NONE ctermfg=Brown ctermbg=NONE gui=bold guifg=Brown guibg=NONE",
- "PreProc term=underline cterm=NONE ctermfg=DarkMagenta ctermbg=NONE gui=NONE guifg=#6a0dad guibg=NONE",
- "Type term=underline cterm=NONE ctermfg=DarkGreen ctermbg=NONE gui=bold guifg=SeaGreen guibg=NONE",
- "Underlined term=underline cterm=underline ctermfg=DarkMagenta gui=underline guifg=SlateBlue",
- "Ignore term=NONE cterm=NONE ctermfg=white ctermbg=NONE gui=NONE guifg=bg guibg=NONE",
+ "Normal guifg=NvimDarkGrey2 ctermfg=234 guibg=NvimLightGrey2 ctermbg=253",
+
+ // UI
+ "ColorColumn guibg=NvimLightGrey4 ctermbg=247",
+ "Conceal guifg=NvimLightGrey4 ctermfg=247",
+ "CursorColumn guibg=NvimLightGrey3 ctermbg=251",
+ "CursorLine guibg=NvimLightGrey3 ctermbg=251",
+ "DiffAdd guifg=NvimDarkGrey1 ctermfg=232 guibg=NvimLightGreen ctermbg=158",
+ "DiffChange guifg=NvimDarkGrey1 ctermfg=232 guibg=NvimLightGrey4 ctermbg=247",
+ "DiffDelete guifg=NvimDarkRed ctermfg=52 gui=bold cterm=bold",
+ "DiffText guifg=NvimDarkGrey1 ctermfg=232 guibg=NvimLightCyan ctermbg=123",
+ "Directory guifg=NvimDarkCyan ctermfg=30",
+ "ErrorMsg guifg=NvimDarkRed ctermfg=52",
+ "FloatShadow guibg=NvimLightGrey1 ctermbg=255 blend=80",
+ "FloatShadowThrough guibg=NvimLightGrey1 ctermbg=255 blend=100",
+ "Folded guifg=NvimDarkGrey4 ctermfg=239 guibg=NvimLightGrey3 ctermbg=251",
+ "LineNr guifg=NvimLightGrey4 ctermfg=247",
+ "MatchParen guibg=NvimLightGrey4 ctermbg=247 gui=bold cterm=bold",
+ "ModeMsg guifg=NvimDarkGreen ctermfg=22",
+ "MoreMsg guifg=NvimDarkCyan ctermfg=30",
+ "NonText guifg=NvimLightGrey4 ctermfg=247",
+ "NormalFloat guifg=NvimDarkGrey2 ctermfg=234 guibg=NvimLightGrey1 ctermbg=255",
+ "Pmenu guifg=NvimDarkGrey2 ctermfg=234 guibg=NvimLightGrey3 ctermbg=251",
+ "PmenuSel guifg=NvimLightGrey3 ctermfg=251 guibg=NvimDarkGrey2 ctermbg=234 blend=0",
+ "PmenuThumb guibg=NvimLightGrey4 ctermbg=247",
+ "Question guifg=NvimDarkCyan ctermfg=30",
+ "RedrawDebugClear guibg=NvimLightCyan ctermbg=123",
+ "RedrawDebugComposed guibg=NvimLightGreen ctermbg=158",
+ "RedrawDebugRecompose guibg=NvimLightRed ctermbg=217",
+ "Search guifg=NvimDarkGrey1 ctermfg=232 guibg=NvimLightYellow ctermbg=222",
+ "SignColumn guifg=NvimLightGrey4 ctermfg=247",
+ "SpecialKey guifg=NvimLightGrey4 ctermfg=247",
+ "SpellBad guisp=NvimDarkRed gui=undercurl cterm=undercurl",
+ "SpellCap guisp=NvimDarkYellow gui=undercurl cterm=undercurl",
+ "SpellLocal guisp=NvimDarkGreen gui=undercurl cterm=undercurl",
+ "SpellRare guisp=NvimDarkCyan gui=undercurl cterm=undercurl",
+ "StatusLine guifg=NvimDarkGrey3 ctermfg=236 guibg=NvimLightGrey1 ctermbg=255",
+ "StatusLineNC guifg=NvimDarkGrey4 ctermfg=239 guibg=NvimLightGrey1 ctermbg=255",
+ "TabLine guifg=NvimDarkGrey3 ctermfg=236 guibg=NvimLightGrey1 ctermbg=255",
+ "Visual guibg=NvimLightGrey4 ctermbg=247",
+ "WarningMsg guifg=NvimDarkYellow ctermfg=52", // In 256 colors fall back to red
+
+ // Syntax
+ "Comment guifg=NvimDarkGrey4 ctermfg=239",
+ "Constant guifg=NvimDarkGrey2 ctermfg=234",
+ "String guifg=NvimDarkGreen ctermfg=22",
+ "Identifier guifg=NvimDarkBlue ctermfg=NONE", // No fallback in 256 colors to reduce noise
+ "Function guifg=NvimDarkCyan ctermfg=30",
+ "Statement guifg=NvimDarkGrey2 ctermfg=234 gui=bold cterm=bold",
+ "Operator guifg=NvimDarkGrey2 ctermfg=234",
+ "PreProc guifg=NvimDarkGrey2 ctermfg=234",
+ "Type guifg=NvimDarkGrey2 ctermfg=234",
+ "Special guifg=NvimDarkGrey2 ctermfg=234",
+ "Delimiter guifg=NvimDarkGrey2 ctermfg=234",
+ "Error guifg=NvimDarkGrey1 ctermfg=232 guibg=NvimLightRed ctermbg=217",
+ "Todo guifg=NvimDarkGrey1 ctermfg=232 gui=bold cterm=bold",
+
+ // Diagnostic
+ "DiagnosticError guifg=NvimDarkRed ctermfg=52",
+ "DiagnosticWarn guifg=NvimDarkYellow ctermfg=52", // In 256 colors fall back to red
+ "DiagnosticInfo guifg=NvimDarkCyan ctermfg=30",
+ "DiagnosticHint guifg=NvimDarkBlue ctermfg=30", // In 256 colors fall back to cyan
+ "DiagnosticOk guifg=NvimDarkGreen ctermfg=22",
+ "DiagnosticUnderlineError guisp=NvimDarkRed gui=underline cterm=underline",
+ "DiagnosticUnderlineWarn guisp=NvimDarkYellow gui=underline cterm=underline",
+ "DiagnosticUnderlineInfo guisp=NvimDarkCyan gui=underline cterm=underline",
+ "DiagnosticUnderlineHint guisp=NvimDarkBlue gui=underline cterm=underline", // In 256 colors fall back to cyan
+ "DiagnosticUnderlineOk guisp=NvimDarkGreen gui=underline cterm=underline",
+ "DiagnosticFloatingError guifg=NvimDarkRed ctermfg=52 guibg=NvimLightGrey1 ctermbg=255",
+ // In 256 colors fall back to red
+ "DiagnosticFloatingWarn guifg=NvimDarkYellow ctermfg=52 guibg=NvimLightGrey1 ctermbg=255",
+ "DiagnosticFloatingInfo guifg=NvimDarkCyan ctermfg=30 guibg=NvimLightGrey1 ctermbg=255",
+ // In 256 colors fall back to cyan
+ "DiagnosticFloatingHint guifg=NvimDarkBlue ctermfg=30 guibg=NvimLightGrey1 ctermbg=255",
+ "DiagnosticFloatingOk guifg=NvimDarkGreen ctermfg=22 guibg=NvimLightGrey1 ctermbg=255",
+ "DiagnosticDeprecated guisp=NvimDarkRed gui=strikethrough cterm=strikethrough",
NULL
};
// Default colors only used with a dark background.
static const char *highlight_init_dark[] = {
- "ColorColumn ctermbg=DarkRed guibg=DarkRed",
- "CursorColumn ctermbg=DarkGrey guibg=Grey40",
- "CursorLine cterm=underline guibg=Grey40",
- "CursorLineNr cterm=underline ctermfg=Yellow gui=bold guifg=Yellow",
- "DiffAdd ctermbg=DarkBlue guibg=DarkBlue",
- "DiffChange ctermbg=DarkMagenta guibg=DarkMagenta",
- "DiffDelete ctermfg=Blue ctermbg=DarkCyan gui=bold guifg=Blue guibg=DarkCyan",
- "Directory ctermfg=LightCyan guifg=Cyan",
- "FoldColumn ctermbg=DarkGrey ctermfg=Cyan guibg=Grey guifg=Cyan",
- "Folded ctermbg=DarkGrey ctermfg=Cyan guibg=DarkGrey guifg=Cyan",
- "LineNr ctermfg=Yellow guifg=Yellow",
- "MatchParen ctermbg=DarkCyan guibg=DarkCyan",
- "MoreMsg ctermfg=LightGreen gui=bold guifg=SeaGreen",
- "Pmenu ctermbg=Magenta ctermfg=Black guibg=Magenta",
- "PmenuSel ctermbg=Black ctermfg=DarkGrey guibg=DarkGrey",
- "PmenuThumb ctermbg=White guibg=White",
- "Question ctermfg=LightGreen gui=bold guifg=Green",
- "Search ctermbg=Yellow ctermfg=Black guibg=Yellow guifg=Black",
- "SignColumn ctermbg=DarkGrey ctermfg=Cyan guibg=Grey guifg=Cyan",
- "SpecialKey ctermfg=LightBlue guifg=Cyan",
- "SpellBad ctermbg=Red guisp=Red gui=undercurl",
- "SpellCap ctermbg=Blue guisp=Blue gui=undercurl",
- "SpellLocal ctermbg=Cyan guisp=Cyan gui=undercurl",
- "SpellRare ctermbg=Magenta guisp=Magenta gui=undercurl",
- "TabLine cterm=underline ctermfg=white ctermbg=DarkGrey gui=underline guibg=DarkGrey",
- "Title ctermfg=LightMagenta gui=bold guifg=Magenta",
- "Visual guibg=DarkGrey",
- "WarningMsg ctermfg=LightRed guifg=Red",
- "Comment term=bold cterm=NONE ctermfg=Cyan ctermbg=NONE gui=NONE guifg=#80a0ff guibg=NONE",
- "Constant term=underline cterm=NONE ctermfg=Magenta ctermbg=NONE gui=NONE guifg=#ffa0a0 guibg=NONE",
- "Special term=bold cterm=NONE ctermfg=LightRed ctermbg=NONE gui=NONE guifg=Orange guibg=NONE",
- "Identifier term=underline cterm=bold ctermfg=Cyan ctermbg=NONE gui=NONE guifg=#40ffff guibg=NONE",
- "Statement term=bold cterm=NONE ctermfg=Yellow ctermbg=NONE gui=bold guifg=#ffff60 guibg=NONE",
- "PreProc term=underline cterm=NONE ctermfg=LightBlue ctermbg=NONE gui=NONE guifg=#ff80ff guibg=NONE",
- "Type term=underline cterm=NONE ctermfg=LightGreen ctermbg=NONE gui=bold guifg=#60ff60 guibg=NONE",
- "Underlined term=underline cterm=underline ctermfg=LightBlue gui=underline guifg=#80a0ff",
- "Ignore term=NONE cterm=NONE ctermfg=black ctermbg=NONE gui=NONE guifg=bg guibg=NONE",
+ "Normal guifg=NvimLightGrey2 ctermfg=253 guibg=NvimDarkGrey2 ctermbg=234",
+
+ // UI
+ "ColorColumn guibg=NvimDarkGrey4 ctermbg=239",
+ "Conceal guifg=NvimDarkGrey4 ctermfg=239",
+ "CursorColumn guibg=NvimDarkGrey3 ctermbg=236",
+ "CursorLine guibg=NvimDarkGrey3 ctermbg=236",
+ "DiffAdd guifg=NvimLightGrey1 ctermfg=255 guibg=NvimDarkGreen ctermbg=22",
+ "DiffChange guifg=NvimLightGrey1 ctermfg=255 guibg=NvimDarkGrey4 ctermbg=239",
+ "DiffDelete guifg=NvimLightRed ctermfg=217 gui=bold cterm=bold",
+ "DiffText guifg=NvimLightGrey1 ctermfg=255 guibg=NvimDarkCyan ctermbg=30",
+ "Directory guifg=NvimLightCyan ctermfg=123",
+ "ErrorMsg guifg=NvimLightRed ctermfg=217",
+ "FloatShadow guibg=NvimDarkGrey1 ctermbg=232 blend=80",
+ "FloatShadowThrough guibg=NvimDarkGrey1 ctermbg=232 blend=100",
+ "Folded guifg=NvimLightGrey4 ctermfg=247 guibg=NvimDarkGrey3 ctermbg=236",
+ "LineNr guifg=NvimDarkGrey4 ctermfg=239",
+ "MatchParen guibg=NvimDarkGrey4 ctermbg=239 gui=bold cterm=bold",
+ "ModeMsg guifg=NvimLightGreen ctermfg=158",
+ "MoreMsg guifg=NvimLightCyan ctermfg=123",
+ "NonText guifg=NvimDarkGrey4 ctermfg=239",
+ "NormalFloat guifg=NvimLightGrey2 ctermfg=253 guibg=NvimDarkGrey1 ctermbg=232",
+ "Pmenu guifg=NvimLightGrey2 ctermfg=253 guibg=NvimDarkGrey3 ctermbg=236",
+ "PmenuSel guifg=NvimDarkGrey3 ctermfg=236 guibg=NvimLightGrey2 ctermbg=253 blend=0",
+ "PmenuThumb guibg=NvimDarkGrey4 ctermbg=239",
+ "Question guifg=NvimLightCyan ctermfg=123",
+ "RedrawDebugClear guibg=NvimDarkCyan ctermbg=30",
+ "RedrawDebugComposed guibg=NvimDarkGreen ctermbg=22",
+ "RedrawDebugRecompose guibg=NvimDarkRed ctermbg=52",
+ "Search guifg=NvimLightGrey1 ctermfg=255 guibg=NvimDarkYellow ctermbg=58",
+ "SignColumn guifg=NvimDarkGrey4 ctermfg=239",
+ "SpecialKey guifg=NvimDarkGrey4 ctermfg=239",
+ "SpellBad guisp=NvimLightRed gui=undercurl cterm=undercurl",
+ "SpellCap guisp=NvimLightYellow gui=undercurl cterm=undercurl",
+ "SpellLocal guisp=NvimLightGreen gui=undercurl cterm=undercurl",
+ "SpellRare guisp=NvimLightCyan gui=undercurl cterm=undercurl",
+ "StatusLine guifg=NvimLightGrey3 ctermfg=251 guibg=NvimDarkGrey1 ctermbg=232",
+ "StatusLineNC guifg=NvimLightGrey4 ctermfg=247 guibg=NvimDarkGrey1 ctermbg=232",
+ "TabLine guifg=NvimLightGrey3 ctermfg=251 guibg=NvimDarkGrey1 ctermbg=232",
+ "Visual guibg=NvimDarkGrey4 ctermbg=239",
+ "WarningMsg guifg=NvimLightYellow ctermfg=217", // In 256 colors fall back to red
+
+ // Syntax
+ "Comment guifg=NvimLightGrey4 ctermfg=247",
+ "Constant guifg=NvimLightGrey2 ctermfg=253",
+ "String guifg=NvimLightGreen ctermfg=158",
+ "Identifier guifg=NvimLightBlue ctermfg=NONE", // No fallback in 256 colors to reduce noise
+ "Function guifg=NvimLightCyan ctermfg=123",
+ "Statement guifg=NvimLightGrey2 ctermfg=253 gui=bold cterm=bold",
+ "Operator guifg=NvimLightGrey2 ctermfg=253",
+ "PreProc guifg=NvimLightGrey2 ctermfg=253",
+ "Type guifg=NvimLightGrey2 ctermfg=253",
+ "Special guifg=NvimLightGrey2 ctermfg=253",
+ "Delimiter guifg=NvimLightGrey2 ctermfg=253",
+ "Error guifg=NvimLightGrey1 ctermfg=255 guibg=NvimDarkRed ctermbg=52",
+ "Todo guifg=NvimLightGrey1 ctermfg=255 gui=bold cterm=bold",
+
+ // Diagnostic
+ "DiagnosticError guifg=NvimLightRed ctermfg=217",
+ "DiagnosticWarn guifg=NvimLightYellow ctermfg=217", // In 256 colors fall back to red
+ "DiagnosticInfo guifg=NvimLightCyan ctermfg=123",
+ "DiagnosticHint guifg=NvimLightBlue ctermfg=123", // In 256 colors fall back to cyan
+ "DiagnosticOk guifg=NvimLightGreen ctermfg=158",
+ "DiagnosticUnderlineError guisp=NvimLightRed gui=underline cterm=underline",
+ "DiagnosticUnderlineWarn guisp=NvimLightYellow gui=underline cterm=underline", // In 256 colors fall back to red
+ "DiagnosticUnderlineInfo guisp=NvimLightCyan gui=underline cterm=underline",
+ "DiagnosticUnderlineHint guisp=NvimLightBlue gui=underline cterm=underline",
+ "DiagnosticUnderlineOk guisp=NvimLightGreen gui=underline cterm=underline",
+ "DiagnosticFloatingError guifg=NvimLightRed ctermfg=217 guibg=NvimDarkGrey1 ctermbg=232",
+ // In 256 colors fall back to red
+ "DiagnosticFloatingWarn guifg=NvimLightYellow ctermfg=217 guibg=NvimDarkGrey1 ctermbg=232",
+ "DiagnosticFloatingInfo guifg=NvimLightCyan ctermfg=123 guibg=NvimDarkGrey1 ctermbg=232",
+ // In 256 colors fall back to cyan
+ "DiagnosticFloatingHint guifg=NvimLightBlue ctermfg=123 guibg=NvimDarkGrey1 ctermbg=232",
+ "DiagnosticFloatingOk guifg=NvimLightGreen ctermfg=158 guibg=NvimDarkGrey1 ctermbg=232",
+ "DiagnosticDeprecated guisp=NvimLightRed gui=strikethrough cterm=strikethrough",
NULL
};
@@ -2828,6 +2886,29 @@ color_name_table_T color_name_table[] = {
{ "NavajoWhite4", RGB_(0x8b, 0x79, 0x5e) },
{ "Navy", RGB_(0x00, 0x00, 0x80) },
{ "NavyBlue", RGB_(0x0, 0x0, 0x80) },
+ // Default Neovim palettes.
+ // Dark/light palette is used for background in dark/light color scheme and
+ // for foreground in light/dark color scheme.
+ { "NvimDarkBlue", RGB_(0x00, 0x50, 0x78) }, // cterm=24
+ { "NvimDarkCyan", RGB_(0x00, 0x76, 0x76) }, // cterm=30
+ { "NvimDarkGreen", RGB_(0x01, 0x58, 0x25) }, // cterm=22
+ { "NvimDarkGrey1", RGB_(0x0a, 0x0b, 0x10) }, // cterm=232
+ { "NvimDarkGrey2", RGB_(0x1c, 0x1d, 0x23) }, // cterm=234
+ { "NvimDarkGrey3", RGB_(0x2c, 0x2e, 0x33) }, // cterm=236
+ { "NvimDarkGrey4", RGB_(0x4f, 0x52, 0x58) }, // cterm=239
+ { "NvimDarkMagenta", RGB_(0x4c, 0x00, 0x49) }, // cterm=53
+ { "NvimDarkRed", RGB_(0x5e, 0x00, 0x09) }, // cterm=52
+ { "NvimDarkYellow", RGB_(0x6e, 0x56, 0x00) }, // cterm=58
+ { "NvimLightBlue", RGB_(0x9f, 0xd8, 0xff) }, // cterm=153
+ { "NvimLightCyan", RGB_(0x83, 0xef, 0xef) }, // cterm=123
+ { "NvimLightGreen", RGB_(0xaa, 0xed, 0xb7) }, // cterm=158
+ { "NvimLightGrey1", RGB_(0xeb, 0xee, 0xf5) }, // cterm=255
+ { "NvimLightGrey2", RGB_(0xd7, 0xda, 0xe1) }, // cterm=253
+ { "NvimLightGrey3", RGB_(0xc4, 0xc6, 0xcd) }, // cterm=251
+ { "NvimLightGrey4", RGB_(0x9b, 0x9e, 0xa4) }, // cterm=247
+ { "NvimLightMagenta", RGB_(0xff, 0xc3, 0xfa) }, // cterm=189
+ { "NvimLightRed", RGB_(0xff, 0xbc, 0xb5) }, // cterm=217
+ { "NvimLightYellow", RGB_(0xf4, 0xd8, 0x8c) }, // cterm=222
{ "OldLace", RGB_(0xfd, 0xf5, 0xe6) },
{ "Olive", RGB_(0x80, 0x80, 0x00) },
{ "OliveDrab", RGB_(0x6b, 0x8e, 0x23) },
diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c
index a59ba1b6d9..8791aeb10c 100644
--- a/src/nvim/insexpand.c
+++ b/src/nvim/insexpand.c
@@ -747,6 +747,16 @@ int ins_compl_add_infercase(char *str_arg, int len, bool icase, char *fname, Dir
return res;
}
+/// free cptext
+static inline void free_cptext(char *const *const cptext)
+{
+ if (cptext != NULL) {
+ for (size_t i = 0; i < CPT_COUNT; i++) {
+ xfree(cptext[i]);
+ }
+ }
+}
+
/// Add a match to the list of matches
///
/// @param[in] str text of the match to add
@@ -784,16 +794,10 @@ static int ins_compl_add(char *const str, int len, char *const fname, char *cons
} else {
os_breakcheck();
}
-#define FREE_CPTEXT(cptext, cptext_allocated) \
- do { \
- if ((cptext) != NULL && (cptext_allocated)) { \
- for (size_t i = 0; i < CPT_COUNT; i++) { \
- xfree((cptext)[i]); \
- } \
- } \
- } while (0)
if (got_int) {
- FREE_CPTEXT(cptext, cptext_allocated);
+ if (cptext_allocated) {
+ free_cptext(cptext);
+ }
return FAIL;
}
if (len < 0) {
@@ -807,7 +811,9 @@ static int ins_compl_add(char *const str, int len, char *const fname, char *cons
if (!match_at_original_text(match)
&& strncmp(match->cp_str, str, (size_t)len) == 0
&& ((int)strlen(match->cp_str) <= len || match->cp_str[len] == NUL)) {
- FREE_CPTEXT(cptext, cptext_allocated);
+ if (cptext_allocated) {
+ free_cptext(cptext);
+ }
return NOTDONE;
}
match = match->cp_next;
@@ -1552,9 +1558,7 @@ static void ins_compl_free(void)
if (match->cp_flags & CP_FREE_FNAME) {
xfree(match->cp_fname);
}
- for (int i = 0; i < CPT_COUNT; i++) {
- xfree(match->cp_text[i]);
- }
+ free_cptext(match->cp_text);
tv_clear(&match->cp_user_data);
xfree(match);
} while (compl_curr_match != NULL && !is_first_match(compl_curr_match));
@@ -2459,9 +2463,7 @@ static int ins_compl_add_tv(typval_T *const tv, const Direction dir, bool fast)
CLEAR_FIELD(cptext);
}
if (word == NULL || (!empty && *word == NUL)) {
- for (size_t i = 0; i < CPT_COUNT; i++) {
- xfree(cptext[i]);
- }
+ free_cptext(cptext);
tv_clear(&user_data);
return FAIL;
}
diff --git a/src/nvim/lib/ringbuf.h b/src/nvim/lib/ringbuf.h
deleted file mode 100644
index c8abccfeb4..0000000000
--- a/src/nvim/lib/ringbuf.h
+++ /dev/null
@@ -1,290 +0,0 @@
-/// Macros-based ring buffer implementation.
-///
-/// Supported functions:
-///
-/// - new: allocates new ring buffer.
-/// - dealloc: free ring buffer itself.
-/// - free: free ring buffer and all its elements.
-/// - push: adds element to the end of the buffer.
-/// - length: get buffer length.
-/// - size: size of the ring buffer.
-/// - idx: get element at given index.
-/// - idx_p: get pointer to the element at given index.
-/// - insert: insert element at given position.
-/// - remove: remove element from given position.
-
-#pragma once
-
-#include <assert.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <string.h>
-
-#include "nvim/func_attr.h"
-#include "nvim/memory.h"
-
-#define _RINGBUF_LENGTH(rb) \
- ((rb)->first == NULL ? 0 \
- : ((rb)->next == (rb)->first) ? (size_t)((rb)->buf_end - (rb)->buf) + 1 \
- : ((rb)->next > (rb)->first) ? (size_t)((rb)->next - (rb)->first) \
- : (size_t)((rb)->next - (rb)->buf + (rb)->buf_end - (rb)->first + 1))
-
-#define _RINGBUF_NEXT(rb, var) \
- ((var) == (rb)->buf_end ? (rb)->buf : (var) + 1)
-#define _RINGBUF_PREV(rb, var) \
- ((var) == (rb)->buf ? (rb)->buf_end : (var) - 1)
-
-/// Iterate over all ringbuf values
-///
-/// @param rb Ring buffer to iterate over.
-/// @param RBType Type of the ring buffer element.
-/// @param varname Variable name.
-#define RINGBUF_FORALL(rb, RBType, varname) \
- size_t varname##_length_fa_ = _RINGBUF_LENGTH(rb); \
- for (RBType *varname = ((rb)->first == NULL ? (rb)->next : (rb)->first); \
- varname##_length_fa_; \
- (varname = _RINGBUF_NEXT(rb, varname)), \
- varname##_length_fa_--)
-
-/// Iterate over all ringbuf values, from end to the beginning
-///
-/// Unlike previous RINGBUF_FORALL uses already defined variable, in place of
-/// defining variable in the cycle body.
-///
-/// @param rb Ring buffer to iterate over.
-/// @param RBType Type of the ring buffer element.
-/// @param varname Variable name.
-#define RINGBUF_ITER_BACK(rb, RBType, varname) \
- size_t varname##_length_ib_ = _RINGBUF_LENGTH(rb); \
- for (varname = ((rb)->next == (rb)->buf ? (rb)->buf_end : (rb)->next - 1); \
- varname##_length_ib_; \
- (varname = _RINGBUF_PREV(rb, varname)), \
- varname##_length_ib_--)
-
-/// Define a ring buffer structure
-///
-/// @param TypeName Ring buffer type name. Actual type name will be
-/// `{TypeName}RingBuffer`.
-/// @param RBType Type of the single ring buffer element.
-#define RINGBUF_TYPEDEF(TypeName, RBType) \
- typedef struct { \
- RBType *buf; \
- RBType *next; \
- RBType *first; \
- RBType *buf_end; \
- } TypeName##RingBuffer;
-
-/// Dummy item free macros, for use in RINGBUF_INIT
-///
-/// This macros actually does nothing.
-///
-/// @param[in] item Item to be freed.
-#define RINGBUF_DUMMY_FREE(item)
-
-/// Static ring buffer
-///
-/// @warning Ring buffers created with this macros must neither be freed nor
-/// deallocated.
-///
-/// @param scope Ring buffer scope.
-/// @param TypeName Ring buffer type name.
-/// @param RBType Type of the single ring buffer element.
-/// @param varname Variable name.
-/// @param rbsize Ring buffer size.
-#define RINGBUF_STATIC(scope, TypeName, RBType, varname, rbsize) \
- static RBType _##varname##_buf[rbsize]; \
- scope TypeName##RingBuffer varname = { \
- .buf = _##varname##_buf, \
- .next = _##varname##_buf, \
- .first = NULL, \
- .buf_end = _##varname##_buf + rbsize - 1, \
- };
-
-/// Initialize a new ring buffer
-///
-/// @param TypeName Ring buffer type name. Actual type name will be
-/// `{TypeName}RingBuffer`.
-/// @param funcprefix Prefix for all ring buffer functions. Function name will
-/// look like `{funcprefix}_rb_{function_name}`.
-/// @param RBType Type of the single ring buffer element.
-/// @param rbfree Function used to free ring buffer element. May be
-/// a macros like `#define RBFREE(item)` (to skip freeing).
-///
-/// Intended function signature: `void *rbfree(RBType *)`;
-#define RINGBUF_INIT(TypeName, funcprefix, RBType, rbfree) \
- static inline TypeName##RingBuffer funcprefix##_rb_new(const size_t size) \
- REAL_FATTR_WARN_UNUSED_RESULT; \
- static inline TypeName##RingBuffer funcprefix##_rb_new(const size_t size) \
- { \
- assert(size != 0); \
- RBType *buf = xmalloc(size * sizeof(RBType)); \
- return (TypeName##RingBuffer) { \
- .buf = buf, \
- .next = buf, \
- .first = NULL, \
- .buf_end = buf + size - 1, \
- }; \
- } \
- static inline void funcprefix##_rb_free(TypeName##RingBuffer *const rb) \
- REAL_FATTR_UNUSED; \
- static inline void funcprefix##_rb_free(TypeName##RingBuffer *const rb) \
- { \
- if (rb == NULL) { \
- return; \
- } \
- RINGBUF_FORALL(rb, RBType, rbitem) { \
- rbfree(rbitem); \
- } \
- XFREE_CLEAR(rb->buf); \
- } \
- static inline void funcprefix##_rb_dealloc(TypeName##RingBuffer *const rb) \
- REAL_FATTR_UNUSED; \
- static inline void funcprefix##_rb_dealloc(TypeName##RingBuffer *const rb) \
- { \
- XFREE_CLEAR(rb->buf); \
- } \
- static inline void funcprefix##_rb_push(TypeName##RingBuffer *const rb, \
- RBType item) \
- REAL_FATTR_NONNULL_ARG(1); \
- static inline void funcprefix##_rb_push(TypeName##RingBuffer *const rb, \
- RBType item) \
- { \
- if (rb->next == rb->first) { \
- rbfree(rb->first); \
- rb->first = _RINGBUF_NEXT(rb, rb->first); \
- } else if (rb->first == NULL) { \
- rb->first = rb->next; \
- } \
- *rb->next = item; \
- rb->next = _RINGBUF_NEXT(rb, rb->next); \
- } \
- static inline ptrdiff_t funcprefix##_rb_find_idx(const TypeName##RingBuffer *const rb, \
- const RBType *const item_p) \
- REAL_FATTR_NONNULL_ALL REAL_FATTR_PURE REAL_FATTR_UNUSED; \
- static inline ptrdiff_t funcprefix##_rb_find_idx(const TypeName##RingBuffer *const rb, \
- const RBType *const item_p) \
- { \
- assert(rb->buf <= item_p); \
- assert(rb->buf_end >= item_p); \
- if (rb->first == NULL) { \
- return -1; \
- } else if (item_p >= rb->first) { \
- return item_p - rb->first; \
- } else { \
- return item_p - rb->buf + rb->buf_end - rb->first + 1; \
- } \
- } \
- static inline size_t funcprefix##_rb_size(const TypeName##RingBuffer *const rb) \
- REAL_FATTR_NONNULL_ALL REAL_FATTR_PURE; \
- static inline size_t funcprefix##_rb_size(const TypeName##RingBuffer *const rb) \
- { \
- return (size_t)(rb->buf_end - rb->buf) + 1; \
- } \
- static inline size_t funcprefix##_rb_length(const TypeName##RingBuffer *const rb) \
- REAL_FATTR_NONNULL_ALL REAL_FATTR_PURE; \
- static inline size_t funcprefix##_rb_length(const TypeName##RingBuffer *const rb) \
- { \
- return _RINGBUF_LENGTH(rb); \
- } \
- static inline RBType *funcprefix##_rb_idx_p(const TypeName##RingBuffer *const rb, \
- const size_t idx) \
- REAL_FATTR_NONNULL_ALL REAL_FATTR_PURE; \
- static inline RBType *funcprefix##_rb_idx_p(const TypeName##RingBuffer *const rb, \
- const size_t idx) \
- { \
- assert(idx <= funcprefix##_rb_size(rb)); \
- assert(idx <= funcprefix##_rb_length(rb)); \
- if (rb->first + idx > rb->buf_end) { \
- return rb->buf + ((rb->first + idx) - (rb->buf_end + 1)); \
- } else { \
- return rb->first + idx; \
- } \
- } \
- static inline RBType funcprefix##_rb_idx(const TypeName##RingBuffer *const rb, \
- const size_t idx) \
- REAL_FATTR_NONNULL_ALL REAL_FATTR_PURE REAL_FATTR_UNUSED; \
- static inline RBType funcprefix##_rb_idx(const TypeName##RingBuffer *const rb, \
- const size_t idx) \
- { \
- return *funcprefix##_rb_idx_p(rb, idx); \
- } \
- static inline void funcprefix##_rb_insert(TypeName##RingBuffer *const rb, \
- const size_t idx, \
- RBType item) \
- REAL_FATTR_NONNULL_ARG(1) REAL_FATTR_UNUSED; \
- static inline void funcprefix##_rb_insert(TypeName##RingBuffer *const rb, \
- const size_t idx, \
- RBType item) \
- { \
- assert(idx <= funcprefix##_rb_size(rb)); \
- assert(idx <= funcprefix##_rb_length(rb)); \
- const size_t length = funcprefix##_rb_length(rb); \
- if (idx == length) { \
- funcprefix##_rb_push(rb, item); \
- return; \
- } \
- RBType *const insertpos = funcprefix##_rb_idx_p(rb, idx); \
- if (insertpos == rb->next) { \
- funcprefix##_rb_push(rb, item); \
- return; \
- } \
- if (length == funcprefix##_rb_size(rb)) { \
- rbfree(rb->first); \
- } \
- if (insertpos < rb->next) { \
- memmove(insertpos + 1, insertpos, \
- (size_t)((uintptr_t)rb->next - (uintptr_t)insertpos)); \
- } else { \
- assert(insertpos > rb->first); \
- assert(rb->next <= rb->first); \
- memmove(rb->buf + 1, rb->buf, \
- (size_t)((uintptr_t)rb->next - (uintptr_t)rb->buf)); \
- *rb->buf = *rb->buf_end; \
- memmove(insertpos + 1, insertpos, \
- (size_t)((uintptr_t)(rb->buf_end + 1) - (uintptr_t)insertpos)); \
- } \
- *insertpos = item; \
- if (length == funcprefix##_rb_size(rb)) { \
- rb->first = _RINGBUF_NEXT(rb, rb->first); \
- } \
- rb->next = _RINGBUF_NEXT(rb, rb->next); \
- } \
- static inline void funcprefix##_rb_remove(TypeName##RingBuffer *const rb, \
- const size_t idx) \
- REAL_FATTR_NONNULL_ARG(1) REAL_FATTR_UNUSED; \
- static inline void funcprefix##_rb_remove(TypeName##RingBuffer *const rb, \
- const size_t idx) \
- { \
- assert(idx < funcprefix##_rb_size(rb)); \
- assert(idx < funcprefix##_rb_length(rb)); \
- RBType *const rmpos = funcprefix##_rb_idx_p(rb, idx); \
- rbfree(rmpos); \
- if (rmpos == rb->next - 1) { \
- rb->next--; \
- if (rb->first == rb->next) { \
- rb->first = NULL; \
- rb->next = rb->buf; \
- } \
- } else if (rmpos == rb->first) { \
- rb->first = _RINGBUF_NEXT(rb, rb->first); \
- if (rb->first == rb->next) { \
- rb->first = NULL; \
- rb->next = rb->buf; \
- } \
- } else if (rb->first < rb->next || rb->next == rb->buf) { \
- assert(rmpos > rb->first); \
- assert(rmpos <= _RINGBUF_PREV(rb, rb->next)); \
- memmove(rb->first + 1, rb->first, \
- (size_t)((uintptr_t)rmpos - (uintptr_t)rb->first)); \
- rb->first = _RINGBUF_NEXT(rb, rb->first); \
- } else if (rmpos < rb->next) { \
- memmove(rmpos, rmpos + 1, \
- (size_t)((uintptr_t)rb->next - (uintptr_t)rmpos)); \
- rb->next = _RINGBUF_PREV(rb, rb->next); \
- } else { \
- assert(rb->first < rb->buf_end); \
- memmove(rb->first + 1, rb->first, \
- (size_t)((uintptr_t)rmpos - (uintptr_t)rb->first)); \
- rb->first = _RINGBUF_NEXT(rb, rb->first); \
- } \
- }
diff --git a/src/nvim/marktree.c b/src/nvim/marktree.c
index f14da1b605..fa5e7dcbe2 100644
--- a/src/nvim/marktree.c
+++ b/src/nvim/marktree.c
@@ -50,15 +50,15 @@
#include <sys/types.h>
#include "klib/kvec.h"
-#include "nvim/garray.h"
+#include "nvim/macros_defs.h"
+#include "nvim/map_defs.h"
#include "nvim/marktree.h"
#include "nvim/memory.h"
#include "nvim/pos_defs.h"
// only for debug functions
#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
-#include "nvim/garray_defs.h"
-#include "nvim/macros_defs.h"
+#include "nvim/garray.h"
#define T MT_BRANCH_FACTOR
#define ILEN (sizeof(MTNode) + (2 * T) * sizeof(void *))
@@ -2200,7 +2200,12 @@ String mt_inspect(MarkTree *b, bool keys, bool dot)
return ga_take_string(ga);
}
-void mt_inspect_node(MarkTree *b, garray_T *ga, bool keys, MTNode *n, MTPos off)
+static inline uint64_t mt_dbg_id(uint64_t id)
+{
+ return (id >> 1) & 0xffffffff;
+}
+
+static void mt_inspect_node(MarkTree *b, garray_T *ga, bool keys, MTNode *n, MTPos off)
{
static char buf[1024];
GA_PUT("[");
@@ -2240,7 +2245,7 @@ void mt_inspect_node(MarkTree *b, garray_T *ga, bool keys, MTNode *n, MTPos off)
ga_concat(ga, "]");
}
-void mt_inspect_dotfile_node(MarkTree *b, garray_T *ga, MTNode *n, MTPos off, char *parent)
+static void mt_inspect_dotfile_node(MarkTree *b, garray_T *ga, MTNode *n, MTPos off, char *parent)
{
static char buf[1024];
char namebuf[64];
diff --git a/src/nvim/marktree.h b/src/nvim/marktree.h
index c76359d3f9..46d60a2b69 100644
--- a/src/nvim/marktree.h
+++ b/src/nvim/marktree.h
@@ -1,69 +1,15 @@
#pragma once
#include <stdbool.h>
-#include <stddef.h>
+#include <stddef.h> // IWYU pragma: keep
#include <stdint.h>
-#include "klib/kvec.h"
#include "nvim/decoration_defs.h"
-#include "nvim/garray_defs.h" // IWYU pragma: keep
-#include "nvim/map_defs.h"
+#include "nvim/marktree_defs.h" // IWYU pragma: export
#include "nvim/pos_defs.h" // IWYU pragma: keep
// only for debug functions:
#include "nvim/api/private/defs.h" // IWYU pragma: keep
-#define MT_MAX_DEPTH 20
-#define MT_BRANCH_FACTOR 10
-// note max branch is actually 2*MT_BRANCH_FACTOR
-// and strictly this is ceil(log2(2*MT_BRANCH_FACTOR + 1))
-// as we need a pseudo-index for "right before this node"
-#define MT_LOG2_BRANCH 5
-
-typedef struct {
- int32_t row;
- int32_t col;
-} MTPos;
-#define MTPos(r, c) ((MTPos){ .row = (r), .col = (c) })
-
-typedef struct mtnode_s MTNode;
-
-typedef struct {
- MTPos pos;
- int lvl;
- MTNode *x;
- int i;
- struct {
- int oldcol;
- int i;
- } s[MT_MAX_DEPTH];
-
- size_t intersect_idx;
- MTPos intersect_pos;
- MTPos intersect_pos_x;
-} MarkTreeIter;
-
-#define marktree_itr_valid(itr) ((itr)->x != NULL)
-// access raw key: flags in MT_FLAG_EXTERNAL_MASK and decor_data are safe to modify.
-#define mt_itr_rawkey(itr) ((itr)->x->key[(itr)->i])
-
-// Internal storage
-//
-// NB: actual marks have flags > 0, so we can use (row,col,0) pseudo-key for
-// "space before (row,col)"
-typedef struct {
- MTPos pos;
- uint32_t ns;
- uint32_t id;
- uint16_t flags;
- DecorInlineData decor_data; // "ext" tag in flags
-} MTKey;
-
-typedef struct {
- MTKey start;
- MTPos end_pos;
- bool end_right_gravity;
-} MTPair;
-
#define MT_INVALID_KEY (MTKey) { { -1, -1 }, 0, 0, 0, { .hl = DECOR_HIGHLIGHT_INLINE_INIT } }
#define MT_FLAG_REAL (((uint16_t)1) << 0)
@@ -179,31 +125,6 @@ static inline DecorInline mt_decor(MTKey key)
return (DecorInline){ .ext = key.flags & MT_FLAG_DECOR_EXT, .data = key.decor_data };
}
-typedef kvec_withinit_t(uint64_t, 4) Intersection;
-
-struct mtnode_s {
- int32_t n;
- int16_t level;
- int16_t p_idx; // index in parent
- Intersection intersect;
- // TODO(bfredl): we could consider having a only-sometimes-valid
- // index into parent for faster "cached" lookup.
- MTNode *parent;
- MTKey key[2 * MT_BRANCH_FACTOR - 1];
- MTNode *ptr[];
-};
-
-static inline uint64_t mt_dbg_id(uint64_t id)
-{
- return (id>>1)&0xffffffff;
-}
-
-typedef struct {
- MTNode *root;
- size_t n_keys, n_nodes;
- PMap(uint64_t) id2node[1];
-} MarkTree;
-
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "marktree.h.generated.h"
#endif
diff --git a/src/nvim/marktree_defs.h b/src/nvim/marktree_defs.h
new file mode 100644
index 0000000000..8aa1b1e376
--- /dev/null
+++ b/src/nvim/marktree_defs.h
@@ -0,0 +1,83 @@
+#pragma once
+
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+
+#include "klib/kvec.h"
+#include "nvim/decoration_defs.h"
+#include "nvim/map_defs.h"
+
+enum {
+ MT_MAX_DEPTH = 20,
+ MT_BRANCH_FACTOR = 10,
+ // note max branch is actually 2*MT_BRANCH_FACTOR
+ // and strictly this is ceil(log2(2*MT_BRANCH_FACTOR + 1))
+ // as we need a pseudo-index for "right before this node"
+ MT_LOG2_BRANCH = 5,
+};
+
+typedef struct {
+ int32_t row;
+ int32_t col;
+} MTPos;
+#define MTPos(r, c) ((MTPos){ .row = (r), .col = (c) })
+
+typedef struct mtnode_s MTNode;
+
+typedef struct {
+ MTPos pos;
+ int lvl;
+ MTNode *x;
+ int i;
+ struct {
+ int oldcol;
+ int i;
+ } s[MT_MAX_DEPTH];
+
+ size_t intersect_idx;
+ MTPos intersect_pos;
+ MTPos intersect_pos_x;
+} MarkTreeIter;
+
+#define marktree_itr_valid(itr) ((itr)->x != NULL)
+// access raw key: flags in MT_FLAG_EXTERNAL_MASK and decor_data are safe to modify.
+#define mt_itr_rawkey(itr) ((itr)->x->key[(itr)->i])
+
+// Internal storage
+//
+// NB: actual marks have flags > 0, so we can use (row,col,0) pseudo-key for
+// "space before (row,col)"
+typedef struct {
+ MTPos pos;
+ uint32_t ns;
+ uint32_t id;
+ uint16_t flags;
+ DecorInlineData decor_data; // "ext" tag in flags
+} MTKey;
+
+typedef struct {
+ MTKey start;
+ MTPos end_pos;
+ bool end_right_gravity;
+} MTPair;
+
+typedef kvec_withinit_t(uint64_t, 4) Intersection;
+
+struct mtnode_s {
+ int32_t n;
+ int16_t level;
+ int16_t p_idx; // index in parent
+ Intersection intersect;
+ // TODO(bfredl): we could consider having a only-sometimes-valid
+ // index into parent for faster "cached" lookup.
+ MTNode *parent;
+ MTKey key[2 * MT_BRANCH_FACTOR - 1];
+ MTNode *ptr[];
+};
+
+typedef struct {
+ MTNode *root;
+ size_t n_keys, n_nodes;
+ PMap(uint64_t) id2node[1];
+} MarkTree;
diff --git a/src/nvim/plines.c b/src/nvim/plines.c
index fbddb1ab4a..cbfaa4ace3 100644
--- a/src/nvim/plines.c
+++ b/src/nvim/plines.c
@@ -14,6 +14,7 @@
#include "nvim/indent.h"
#include "nvim/macros_defs.h"
#include "nvim/mark.h"
+#include "nvim/marktree.h"
#include "nvim/mbyte.h"
#include "nvim/memline.h"
#include "nvim/move.h"
diff --git a/src/nvim/plines.h b/src/nvim/plines.h
index 6aede88c8b..7227db4524 100644
--- a/src/nvim/plines.h
+++ b/src/nvim/plines.h
@@ -1,10 +1,10 @@
#pragma once
#include <stdbool.h>
-#include <stdint.h>
+#include <stdint.h> // IWYU pragma: keep
#include "nvim/buffer_defs.h"
-#include "nvim/marktree.h"
+#include "nvim/marktree_defs.h"
#include "nvim/pos_defs.h" // IWYU pragma: keep
/// Argument for lbr_chartabsize().
diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c
index 03a7744b18..fda6aa41e8 100644
--- a/src/nvim/terminal.c
+++ b/src/nvim/terminal.c
@@ -188,7 +188,7 @@ void terminal_teardown(void)
static void term_output_callback(const char *s, size_t len, void *user_data)
{
- terminal_send((Terminal *)user_data, (char *)s, len);
+ terminal_send((Terminal *)user_data, s, len);
}
// public API {{{
@@ -680,7 +680,7 @@ void terminal_destroy(Terminal **termpp)
}
}
-void terminal_send(Terminal *term, char *data, size_t size)
+static void terminal_send(Terminal *term, const char *data, size_t size)
{
if (term->closed) {
return;
@@ -762,7 +762,7 @@ void terminal_paste(int count, char **y_array, size_t y_size)
vterm_keyboard_end_paste(curbuf->terminal->vt);
}
-void terminal_send_key(Terminal *term, int c)
+static void terminal_send_key(Terminal *term, int c)
{
VTermModifier mod = VTERM_MOD_NONE;
@@ -780,7 +780,7 @@ void terminal_send_key(Terminal *term, int c)
}
}
-void terminal_receive(Terminal *term, char *data, size_t len)
+void terminal_receive(Terminal *term, const char *data, size_t len)
{
if (!data) {
return;
diff --git a/src/nvim/terminal.h b/src/nvim/terminal.h
index 66cad7ee7a..db62bd2a5b 100644
--- a/src/nvim/terminal.h
+++ b/src/nvim/terminal.h
@@ -4,7 +4,7 @@
#include <stdint.h>
typedef struct terminal Terminal;
-typedef void (*terminal_write_cb)(char *buffer, size_t size, void *data);
+typedef void (*terminal_write_cb)(const char *buffer, size_t size, void *data);
typedef void (*terminal_resize_cb)(uint16_t width, uint16_t height, void *data);
typedef void (*terminal_close_cb)(void *data);
diff --git a/test/benchmark/autocmd_spec.lua b/test/benchmark/autocmd_spec.lua
index cd1af23640..b3421d86eb 100644
--- a/test/benchmark/autocmd_spec.lua
+++ b/test/benchmark/autocmd_spec.lua
@@ -27,7 +27,8 @@ describe('autocmd perf', function()
end)
it('nvim_create_autocmd, nvim_del_autocmd (same pattern)', function()
- exec_lua([[
+ exec_lua(
+ [[
local N = ...
local ids = {}
@@ -45,11 +46,14 @@ describe('autocmd perf', function()
vim.api.nvim_del_autocmd(ids[i])
end
stop('nvim_del_autocmd')
- ]], N)
+ ]],
+ N
+ )
end)
it('nvim_create_autocmd, nvim_del_autocmd (unique patterns)', function()
- exec_lua([[
+ exec_lua(
+ [[
local N = ...
local ids = {}
@@ -67,11 +71,14 @@ describe('autocmd perf', function()
vim.api.nvim_del_autocmd(ids[i])
end
stop('nvim_del_autocmd')
- ]], N)
+ ]],
+ N
+ )
end)
it('nvim_create_autocmd + nvim_del_autocmd', function()
- exec_lua([[
+ exec_lua(
+ [[
local N = ...
start()
@@ -83,11 +90,14 @@ describe('autocmd perf', function()
vim.api.nvim_del_autocmd(id)
end
stop('nvim_create_autocmd + nvim_del_autocmd')
- ]], N)
+ ]],
+ N
+ )
end)
it('nvim_exec_autocmds (same pattern)', function()
- exec_lua([[
+ exec_lua(
+ [[
local N = ...
for i = 1, N do
@@ -100,11 +110,14 @@ describe('autocmd perf', function()
start()
vim.api.nvim_exec_autocmds('User', { pattern = 'Benchmark', modeline = false })
stop('nvim_exec_autocmds')
- ]], N)
+ ]],
+ N
+ )
end)
it('nvim_del_augroup_by_id', function()
- exec_lua([[
+ exec_lua(
+ [[
local N = ...
local group = vim.api.nvim_create_augroup('Benchmark', {})
@@ -119,11 +132,14 @@ describe('autocmd perf', function()
start()
vim.api.nvim_del_augroup_by_id(group)
stop('nvim_del_augroup_by_id')
- ]], N)
+ ]],
+ N
+ )
end)
it('nvim_del_augroup_by_name', function()
- exec_lua([[
+ exec_lua(
+ [[
local N = ...
local group = vim.api.nvim_create_augroup('Benchmark', {})
@@ -138,11 +154,14 @@ describe('autocmd perf', function()
start()
vim.api.nvim_del_augroup_by_name('Benchmark')
stop('nvim_del_augroup_by_id')
- ]], N)
+ ]],
+ N
+ )
end)
it(':autocmd, :autocmd! (same pattern)', function()
- exec_lua([[
+ exec_lua(
+ [[
local N = ...
start()
@@ -154,11 +173,14 @@ describe('autocmd perf', function()
start()
vim.cmd('autocmd! User Benchmark')
stop(':autocmd!')
- ]], N)
+ ]],
+ N
+ )
end)
it(':autocmd, :autocmd! (unique patterns)', function()
- exec_lua([[
+ exec_lua(
+ [[
local N = ...
start()
@@ -170,6 +192,8 @@ describe('autocmd perf', function()
start()
vim.cmd('autocmd! User')
stop(':autocmd!')
- ]], N)
+ ]],
+ N
+ )
end)
end)
diff --git a/test/benchmark/bench_regexp_spec.lua b/test/benchmark/bench_regexp_spec.lua
index 6128549f0f..4a7c50557b 100644
--- a/test/benchmark/bench_regexp_spec.lua
+++ b/test/benchmark/bench_regexp_spec.lua
@@ -10,8 +10,7 @@ local result_file = 'benchmark.out'
local sample_file = 'test/old/testdir/samples/re.freeze.txt'
-- Vim script code that does both the work and the benchmarking of that work.
-local measure_cmd =
- [[call Measure(%d, ']] .. sample_file .. [[', '\s\+\%%#\@<!$', '+5')]]
+local measure_cmd = [[call Measure(%d, ']] .. sample_file .. [[', '\s\+\%%#\@<!$', '+5')]]
local measure_script = [[
func Measure(re, file, pattern, arg)
let sstart = reltime()
diff --git a/test/benchmark/treesitter_spec.lua b/test/benchmark/treesitter_spec.lua
index 6d82f5de8d..7c9906a7b2 100644
--- a/test/benchmark/treesitter_spec.lua
+++ b/test/benchmark/treesitter_spec.lua
@@ -4,14 +4,13 @@ local clear = helpers.clear
local exec_lua = helpers.exec_lua
describe('treesitter perf', function()
-
setup(function()
clear()
end)
it('can handle large folds', function()
- helpers.command'edit ./src/nvim/eval.c'
- exec_lua[[
+ helpers.command 'edit ./src/nvim/eval.c'
+ exec_lua [[
local parser = vim.treesitter.get_parser(0, "c", {})
vim.treesitter.highlighter.new(parser)
@@ -47,7 +46,5 @@ describe('treesitter perf', function()
return vim.uv.hrtime() - start
]]
-
end)
-
end)
diff --git a/test/busted/outputHandlers/nvim.lua b/test/busted/outputHandlers/nvim.lua
index 4bfa21fe49..28855df261 100644
--- a/test/busted/outputHandlers/nvim.lua
+++ b/test/busted/outputHandlers/nvim.lua
@@ -1,12 +1,21 @@
local pretty = require 'pl.pretty'
local global_helpers = require('test.helpers')
-local colors = setmetatable({}, {__index = function() return function(s) return s == nil and '' or tostring(s) end end})
+local colors = setmetatable({}, {
+ __index = function()
+ return function(s)
+ return s == nil and '' or tostring(s)
+ end
+ end,
+})
local enable_colors = true
-if os.getenv "TEST_COLORS" then
- local test_colors = os.getenv("TEST_COLORS"):lower()
- local disable_colors = test_colors == 'false' or test_colors == '0' or test_colors == 'no' or test_colors == 'off'
+if os.getenv 'TEST_COLORS' then
+ local test_colors = os.getenv('TEST_COLORS'):lower()
+ local disable_colors = test_colors == 'false'
+ or test_colors == '0'
+ or test_colors == 'no'
+ or test_colors == 'off'
enable_colors = not disable_colors
end
if enable_colors then
@@ -18,49 +27,73 @@ return function(options)
local handler = require 'busted.outputHandlers.base'()
local c = {
- succ = function(s) return colors.bright(colors.green(s)) end,
- skip = function(s) return colors.bright(colors.yellow(s)) end,
- fail = function(s) return colors.bright(colors.magenta(s)) end,
- errr = function(s) return colors.bright(colors.red(s)) end,
+ succ = function(s)
+ return colors.bright(colors.green(s))
+ end,
+ skip = function(s)
+ return colors.bright(colors.yellow(s))
+ end,
+ fail = function(s)
+ return colors.bright(colors.magenta(s))
+ end,
+ errr = function(s)
+ return colors.bright(colors.red(s))
+ end,
test = tostring,
file = colors.cyan,
time = colors.dim,
note = colors.yellow,
- sect = function(s) return colors.green(colors.dim(s)) end,
+ sect = function(s)
+ return colors.green(colors.dim(s))
+ end,
nmbr = colors.bright,
}
local repeatSuiteString = '\nRepeating all tests (run %d of %d) . . .\n\n'
- local randomizeString = c.note('Note: Randomizing test order with a seed of %d.\n')
- local globalSetup = c.sect('--------') .. ' Global test environment setup.\n'
- local fileStartString = c.sect('--------') .. ' Running tests from ' .. c.file('%s') .. '\n'
- local runString = c.sect('RUN ') .. ' ' .. c.test('%s') .. ': '
- local successString = c.succ('OK') .. '\n'
- local skippedString = c.skip('SKIP') .. '\n'
- local failureString = c.fail('FAIL') .. '\n'
- local errorString = c.errr('ERR') .. '\n'
- local fileEndString = c.sect('--------') .. ' '.. c.nmbr('%d') .. ' %s from ' .. c.file('%s') .. ' ' .. c.time('(%.2f ms total)') .. '\n\n'
- local globalTeardown = c.sect('--------') .. ' Global test environment teardown.\n'
- local suiteEndString = c.sect('========') .. ' ' .. c.nmbr('%d') .. ' %s from ' .. c.nmbr('%d') .. ' test %s ran. ' .. c.time('(%.2f ms total)') .. '\n'
- local successStatus = c.succ('PASSED ') .. ' ' .. c.nmbr('%d') .. ' %s.\n'
- local timeString = c.time('%.2f ms')
+ local randomizeString = c.note('Note: Randomizing test order with a seed of %d.\n')
+ local globalSetup = c.sect('--------') .. ' Global test environment setup.\n'
+ local fileStartString = c.sect('--------') .. ' Running tests from ' .. c.file('%s') .. '\n'
+ local runString = c.sect('RUN ') .. ' ' .. c.test('%s') .. ': '
+ local successString = c.succ('OK') .. '\n'
+ local skippedString = c.skip('SKIP') .. '\n'
+ local failureString = c.fail('FAIL') .. '\n'
+ local errorString = c.errr('ERR') .. '\n'
+ local fileEndString = c.sect('--------')
+ .. ' '
+ .. c.nmbr('%d')
+ .. ' %s from '
+ .. c.file('%s')
+ .. ' '
+ .. c.time('(%.2f ms total)')
+ .. '\n\n'
+ local globalTeardown = c.sect('--------') .. ' Global test environment teardown.\n'
+ local suiteEndString = c.sect('========')
+ .. ' '
+ .. c.nmbr('%d')
+ .. ' %s from '
+ .. c.nmbr('%d')
+ .. ' test %s ran. '
+ .. c.time('(%.2f ms total)')
+ .. '\n'
+ local successStatus = c.succ('PASSED ') .. ' ' .. c.nmbr('%d') .. ' %s.\n'
+ local timeString = c.time('%.2f ms')
local summaryStrings = {
skipped = {
header = c.skip('SKIPPED ') .. ' ' .. c.nmbr('%d') .. ' %s, listed below:\n',
- test = c.skip('SKIPPED ') .. ' %s\n',
+ test = c.skip('SKIPPED ') .. ' %s\n',
footer = ' ' .. c.nmbr('%d') .. ' SKIPPED %s\n',
},
failure = {
header = c.fail('FAILED ') .. ' ' .. c.nmbr('%d') .. ' %s, listed below:\n',
- test = c.fail('FAILED ') .. ' %s\n',
+ test = c.fail('FAILED ') .. ' %s\n',
footer = ' ' .. c.nmbr('%d') .. ' FAILED %s\n',
},
error = {
header = c.errr('ERROR ') .. ' ' .. c.nmbr('%d') .. ' %s, listed below:\n',
- test = c.errr('ERROR ') .. ' %s\n',
+ test = c.errr('ERROR ') .. ' %s\n',
footer = ' ' .. c.nmbr('%d') .. ' %s\n',
},
}
@@ -107,8 +140,10 @@ return function(options)
local getFileLine = function(element)
local fileline = ''
if element.trace or element.trace.short_src then
- fileline = colors.cyan(element.trace.short_src) .. ' @ ' ..
- colors.cyan(element.trace.currentline) .. ': '
+ fileline = colors.cyan(element.trace.short_src)
+ .. ' @ '
+ .. colors.cyan(element.trace.currentline)
+ .. ': '
end
return fileline
end
@@ -219,7 +254,9 @@ return function(options)
local elapsedTime_ms = getElapsedTime(file)
local tests = (fileTestCount == 1 and 'test' or 'tests')
fileCount = fileCount + 1
- io.write(fileEndString:format(fileTestCount, tests, vim.fs.normalize(file.name), elapsedTime_ms))
+ io.write(
+ fileEndString:format(fileTestCount, tests, vim.fs.normalize(file.name), elapsedTime_ms)
+ )
io.flush()
return nil, true
end
@@ -256,7 +293,7 @@ return function(options)
errorCount = errorCount + 1
string = errorString .. failureDescription(handler.errors[#handler.errors])
else
- string = "unexpected test status! ("..status..")"
+ string = 'unexpected test status! (' .. status .. ')'
end
write_status(element, string)
diff --git a/test/client/msgpack_rpc_stream.lua b/test/client/msgpack_rpc_stream.lua
index 5711616b17..ff054ae62b 100644
--- a/test/client/msgpack_rpc_stream.lua
+++ b/test/client/msgpack_rpc_stream.lua
@@ -3,13 +3,19 @@ local mpack = require('mpack')
-- temporary hack to be able to manipulate buffer/window/tabpage
local Buffer = {}
Buffer.__index = Buffer
-function Buffer.new(id) return setmetatable({id=id}, Buffer) end
+function Buffer.new(id)
+ return setmetatable({ id = id }, Buffer)
+end
local Window = {}
Window.__index = Window
-function Window.new(id) return setmetatable({id=id}, Window) end
+function Window.new(id)
+ return setmetatable({ id = id }, Window)
+end
local Tabpage = {}
Tabpage.__index = Tabpage
-function Tabpage.new(id) return setmetatable({id=id}, Tabpage) end
+function Tabpage.new(id)
+ return setmetatable({ id = id }, Tabpage)
+end
local Response = {}
Response.__index = Response
@@ -17,7 +23,7 @@ Response.__index = Response
function Response.new(msgpack_rpc_stream, request_id)
return setmetatable({
_msgpack_rpc_stream = msgpack_rpc_stream,
- _request_id = request_id
+ _request_id = request_id,
}, Response)
end
@@ -41,19 +47,31 @@ function MsgpackRpcStream.new(stream)
_stream = stream,
_pack = mpack.Packer({
ext = {
- [Buffer] = function(o) return 0, mpack.encode(o.id) end,
- [Window] = function(o) return 1, mpack.encode(o.id) end,
- [Tabpage] = function(o) return 2, mpack.encode(o.id) end
- }
+ [Buffer] = function(o)
+ return 0, mpack.encode(o.id)
+ end,
+ [Window] = function(o)
+ return 1, mpack.encode(o.id)
+ end,
+ [Tabpage] = function(o)
+ return 2, mpack.encode(o.id)
+ end,
+ },
}),
_session = mpack.Session({
unpack = mpack.Unpacker({
ext = {
- [0] = function(_c, s) return Buffer.new(mpack.decode(s)) end,
- [1] = function(_c, s) return Window.new(mpack.decode(s)) end,
- [2] = function(_c, s) return Tabpage.new(mpack.decode(s)) end
- }
- })
+ [0] = function(_c, s)
+ return Buffer.new(mpack.decode(s))
+ end,
+ [1] = function(_c, s)
+ return Window.new(mpack.decode(s))
+ end,
+ [2] = function(_c, s)
+ return Tabpage.new(mpack.decode(s))
+ end,
+ },
+ }),
}),
}, MsgpackRpcStream)
end
@@ -67,7 +85,7 @@ function MsgpackRpcStream:write(method, args, response_cb)
data = self._session:notify()
end
- data = data .. self._pack(method) .. self._pack(args)
+ data = data .. self._pack(method) .. self._pack(args)
self._stream:write(data)
end
@@ -80,12 +98,10 @@ function MsgpackRpcStream:read_start(request_cb, notification_cb, eof_cb)
local pos = 1
local len = #data
while pos <= len do
- type, id_or_cb, method_or_error, args_or_result, pos =
- self._session:receive(data, pos)
+ type, id_or_cb, method_or_error, args_or_result, pos = self._session:receive(data, pos)
if type == 'request' or type == 'notification' then
if type == 'request' then
- request_cb(method_or_error, args_or_result, Response.new(self,
- id_or_cb))
+ request_cb(method_or_error, args_or_result, Response.new(self, id_or_cb))
else
notification_cb(method_or_error, args_or_result)
end
diff --git a/test/client/session.lua b/test/client/session.lua
index b1bf5ea75e..78909d1061 100644
--- a/test/client/session.lua
+++ b/test/client/session.lua
@@ -7,7 +7,7 @@ if package.loaded['jit'] then
-- luajit pcall is already coroutine safe
Session.safe_pcall = pcall
else
- Session.safe_pcall = require'coxpcall'.pcall
+ Session.safe_pcall = require 'coxpcall'.pcall
end
local function resume(co, ...)
@@ -25,7 +25,7 @@ local function resume(co, ...)
end
local function coroutine_exec(func, ...)
- local args = {...}
+ local args = { ... }
local on_complete
if #args > 0 and type(args[#args]) == 'function' then
@@ -50,18 +50,18 @@ function Session.new(stream)
_pending_messages = {},
_prepare = uv.new_prepare(),
_timer = uv.new_timer(),
- _is_running = false
+ _is_running = false,
}, Session)
end
function Session:next_message(timeout)
local function on_request(method, args, response)
- table.insert(self._pending_messages, {'request', method, args, response})
+ table.insert(self._pending_messages, { 'request', method, args, response })
uv.stop()
end
local function on_notification(method, args)
- table.insert(self._pending_messages, {'notification', method, args})
+ table.insert(self._pending_messages, { 'notification', method, args })
uv.stop()
end
@@ -83,11 +83,11 @@ function Session:next_message(timeout)
end
function Session:notify(method, ...)
- self._msgpack_rpc_stream:write(method, {...})
+ self._msgpack_rpc_stream:write(method, { ... })
end
function Session:request(method, ...)
- local args = {...}
+ local args = { ... }
local err, result
if self._is_running then
err, result = self:_yielding_request(method, args)
@@ -141,8 +141,12 @@ function Session:stop()
end
function Session:close(signal)
- if not self._timer:is_closing() then self._timer:close() end
- if not self._prepare:is_closing() then self._prepare:close() end
+ if not self._timer:is_closing() then
+ self._timer:close()
+ end
+ if not self._prepare:is_closing() then
+ self._prepare:close()
+ end
self._msgpack_rpc_stream:close(signal)
self.closed = true
end
@@ -159,11 +163,11 @@ function Session:_blocking_request(method, args)
local err, result
local function on_request(method_, args_, response)
- table.insert(self._pending_messages, {'request', method_, args_, response})
+ table.insert(self._pending_messages, { 'request', method_, args_, response })
end
local function on_notification(method_, args_)
- table.insert(self._pending_messages, {'notification', method_, args_})
+ table.insert(self._pending_messages, { 'notification', method_, args_ })
end
self._msgpack_rpc_stream:write(method, args, function(e, r)
@@ -187,7 +191,7 @@ function Session:_run(request_cb, notification_cb, timeout)
end
self._msgpack_rpc_stream:read_start(request_cb, notification_cb, function()
uv.stop()
- self.eof_err = {1, "EOF was received from Nvim. Likely the Nvim process crashed."}
+ self.eof_err = { 1, 'EOF was received from Nvim. Likely the Nvim process crashed.' }
end)
uv.run()
self._prepare:stop()
diff --git a/test/client/uv_stream.lua b/test/client/uv_stream.lua
index cea77f0dbd..f37a0ec3ce 100644
--- a/test/client/uv_stream.lua
+++ b/test/client/uv_stream.lua
@@ -6,7 +6,7 @@ StdioStream.__index = StdioStream
function StdioStream.open()
local self = setmetatable({
_in = uv.new_pipe(false),
- _out = uv.new_pipe(false)
+ _out = uv.new_pipe(false),
}, StdioStream)
self._in:open(0)
self._out:open(1)
@@ -42,9 +42,9 @@ function SocketStream.open(file)
local socket = uv.new_pipe(false)
local self = setmetatable({
_socket = socket,
- _stream_error = nil
+ _stream_error = nil,
}, SocketStream)
- uv.pipe_connect(socket, file, function (err)
+ uv.pipe_connect(socket, file, function(err)
self._stream_error = self._stream_error or err
end)
return self
@@ -54,15 +54,14 @@ function SocketStream.connect(host, port)
local socket = uv.new_tcp()
local self = setmetatable({
_socket = socket,
- _stream_error = nil
+ _stream_error = nil,
}, SocketStream)
- uv.tcp_connect(socket, host, port, function (err)
+ uv.tcp_connect(socket, host, port, function(err)
self._stream_error = self._stream_error or err
end)
return self
end
-
function SocketStream:write(data)
if self._stream_error then
error(self._stream_error)
@@ -102,9 +101,9 @@ ChildProcessStream.__index = ChildProcessStream
function ChildProcessStream.spawn(argv, env, io_extra)
local self = setmetatable({
- _child_stdin = uv.new_pipe(false);
- _child_stdout = uv.new_pipe(false);
- _exiting = false;
+ _child_stdin = uv.new_pipe(false),
+ _child_stdout = uv.new_pipe(false),
+ _exiting = false,
}, ChildProcessStream)
local prog = argv[1]
local args = {}
@@ -112,7 +111,7 @@ function ChildProcessStream.spawn(argv, env, io_extra)
args[#args + 1] = argv[i]
end
self._proc, self._pid = uv.spawn(prog, {
- stdio = {self._child_stdin, self._child_stdout, 2, io_extra},
+ stdio = { self._child_stdin, self._child_stdout, 2, io_extra },
args = args,
env = env,
}, function(status, signal)
@@ -154,7 +153,7 @@ function ChildProcessStream:close(signal)
self._child_stdin:close()
self._child_stdout:close()
if type(signal) == 'string' then
- self._proc:kill('sig'..signal)
+ self._proc:kill('sig' .. signal)
end
while self.status == nil do
uv.run 'once'
@@ -163,7 +162,7 @@ function ChildProcessStream:close(signal)
end
return {
- StdioStream = StdioStream;
- ChildProcessStream = ChildProcessStream;
- SocketStream = SocketStream;
+ StdioStream = StdioStream,
+ ChildProcessStream = ChildProcessStream,
+ SocketStream = SocketStream,
}
diff --git a/test/functional/api/buffer_updates_spec.lua b/test/functional/api/buffer_updates_spec.lua
index 80e29c1ff2..bf76db432f 100644
--- a/test/functional/api/buffer_updates_spec.lua
+++ b/test/functional/api/buffer_updates_spec.lua
@@ -762,7 +762,7 @@ describe('API: buffer events:', function()
it('returns a proper error on nonempty options dict', function()
clear()
local b = editoriginal(false)
- eq("Invalid 'opts' key: 'builtin'", pcall_err(buffer, 'attach', b, false, {builtin="asfd"}))
+ eq("Invalid key: 'builtin'", pcall_err(buffer, 'attach', b, false, {builtin="asfd"}))
end)
it('nvim_buf_attach returns response after delay #8634', function()
diff --git a/test/functional/api/highlight_spec.lua b/test/functional/api/highlight_spec.lua
index 7d7d07e30e..c9edbf825d 100644
--- a/test/functional/api/highlight_spec.lua
+++ b/test/functional/api/highlight_spec.lua
@@ -561,7 +561,7 @@ describe('API: get highlight', function()
end)
it('can correctly detect links', function()
- command('hi String guifg=#a6e3a1')
+ command('hi String guifg=#a6e3a1 ctermfg=NONE')
command('hi link @string string')
command('hi link @string.cpp @string')
eq({ fg = 10937249 }, meths.get_hl(0, { name = 'String' }))
diff --git a/test/functional/autocmd/focus_spec.lua b/test/functional/autocmd/focus_spec.lua
index 33e4d88c7b..c72842f14b 100644
--- a/test/functional/autocmd/focus_spec.lua
+++ b/test/functional/autocmd/focus_spec.lua
@@ -14,8 +14,10 @@ describe('autoread TUI FocusGained/FocusLost', function()
before_each(function()
clear()
- screen = thelpers.screen_setup(0, '["'..nvim_prog
- ..'", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile noshowcmd noruler"]')
+ screen = thelpers.screen_setup(
+ 0,
+ '["'..nvim_prog..'", "-u", "NONE", "-i", "NONE", "--cmd", "colorscheme vim", "--cmd", "set noswapfile noshowcmd noruler"]'
+ )
end)
teardown(function()
diff --git a/test/functional/core/main_spec.lua b/test/functional/core/main_spec.lua
index 19c7a93730..d705d56575 100644
--- a/test/functional/core/main_spec.lua
+++ b/test/functional/core/main_spec.lua
@@ -70,17 +70,18 @@ describe('command-line option', function()
-- data from the terminal #18181
funcs.termopen(string.format([[echo "" | %s]], table.concat(args, " ")))
screen:expect([[
- ^ |
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {1:~ }|
- {2:[No Name] 0,0-1 All}|
- |
+ {1:^ }|
+ {2:~ }|
+ {2:~ }|
+ {2:~ }|
+ {2:~ }|
+ {3:[No Name] 0,0-1 All}|
+ {1: }|
|
]], {
- [1] = {foreground = tonumber('0x4040ff'), fg_indexed=true},
- [2] = {bold = true, reverse = true}
+ [1] = {bg_indexed = true, foreground = Screen.colors.Grey91, background = tonumber('0x161616'), fg_indexed = true},
+ [2] = {bg_indexed = true, foreground = Screen.colors.Gray30, background = tonumber('0x161616'), fg_indexed = true},
+ [3] = {bg_indexed = true, foreground = tonumber('0xd2d2d2'), background = Screen.colors.Black , fg_indexed = true},
})
feed('i:cq<CR>')
screen:expect([[
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua
index dcaaa664b9..2bff1d16f8 100644
--- a/test/functional/helpers.lua
+++ b/test/functional/helpers.lua
@@ -38,6 +38,11 @@ module.nvim_argv = {
'--cmd', module.nvim_set,
'--cmd', 'mapclear',
'--cmd', 'mapclear!',
+ -- Make screentest work after changing to the new default color scheme
+ -- Source 'vim' color scheme without side effects
+ -- TODO: rewrite tests
+ '--cmd', 'lua f=io.open("runtime/colors/vim.vim", "r"); l=f:read("*a"); f:close(); vim.api.nvim_exec2(l, {})',
+ '--cmd', 'unlet g:colors_name',
'--embed'}
-- Directory containing nvim.
diff --git a/test/functional/legacy/scroll_opt_spec.lua b/test/functional/legacy/scroll_opt_spec.lua
index 8ac1141c2b..91dbc120d8 100644
--- a/test/functional/legacy/scroll_opt_spec.lua
+++ b/test/functional/legacy/scroll_opt_spec.lua
@@ -1096,6 +1096,26 @@ describe('smoothscroll', function()
]])
end)
+ it('works in Insert mode at bottom of window', function()
+ screen:try_resize(40, 9)
+ exec([[
+ call setline(1, repeat([repeat('A very long line ...', 10)], 5))
+ set wrap smoothscroll scrolloff=0
+ ]])
+ feed('Go123456789<CR>')
+ screen:expect([[
+ <<<ery long line ...A very long line ...|
+ A very long line ...A very long line ...|
+ A very long line ...A very long line ...|
+ A very long line ...A very long line ...|
+ A very long line ...A very long line ...|
+ A very long line ...A very long line ...|
+ 123456789 |
+ ^ |
+ -- INSERT -- |
+ ]])
+ end)
+
it('<<< marker shows with tabline, winbar and splits', function()
screen:try_resize(40, 12)
exec([[
diff --git a/test/functional/lua/buffer_updates_spec.lua b/test/functional/lua/buffer_updates_spec.lua
index 51e4548edb..a3f637e4de 100644
--- a/test/functional/lua/buffer_updates_spec.lua
+++ b/test/functional/lua/buffer_updates_spec.lua
@@ -418,7 +418,7 @@ describe('lua: nvim_buf_attach on_bytes', function()
-- meths.set_option_value('autoindent', true, {})
feed 'Go'
check_events {
- { "test1", "bytes", 1, 4, 7, 0, 114, 0, 0, 0, 1, 0, 1 };
+ { "test1", "bytes", 1, 3, 7, 0, 114, 0, 0, 0, 1, 0, 1 };
}
feed '<cr>'
check_events {
@@ -431,7 +431,7 @@ describe('lua: nvim_buf_attach on_bytes', function()
meths.set_option_value('autoindent', true, {})
feed 'Go'
check_events {
- { "test1", "bytes", 1, 4, 7, 0, 114, 0, 0, 0, 1, 0, 5 };
+ { "test1", "bytes", 1, 3, 7, 0, 114, 0, 0, 0, 1, 0, 5 };
}
feed '<cr>'
check_events {
@@ -476,7 +476,7 @@ describe('lua: nvim_buf_attach on_bytes', function()
feed 'ggo' -- goto first line to continue testing
check_events {
- { "test1", "bytes", 1, 6, 1, 0, 11, 0, 0, 0, 1, 0, 4 };
+ { "test1", "bytes", 1, 5, 1, 0, 11, 0, 0, 0, 1, 0, 4 };
}
feed '<CR>'
diff --git a/test/functional/terminal/api_spec.lua b/test/functional/terminal/api_spec.lua
index 93641fc576..c278b2ad0e 100644
--- a/test/functional/terminal/api_spec.lua
+++ b/test/functional/terminal/api_spec.lua
@@ -12,7 +12,7 @@ describe('api', function()
helpers.clear()
os.remove(socket_name)
screen = child_session.screen_setup(0, '["'..helpers.nvim_prog
- ..'", "-u", "NONE", "-i", "NONE", "--cmd", "'..helpers.nvim_set..'"]')
+ ..'", "-u", "NONE", "-i", "NONE", "--cmd", "colorscheme vim", "--cmd", "'..helpers.nvim_set..'"]')
end)
after_each(function()
os.remove(socket_name)
diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua
index 6d8c214d87..423e7bdf21 100644
--- a/test/functional/terminal/buffer_spec.lua
+++ b/test/functional/terminal/buffer_spec.lua
@@ -446,8 +446,10 @@ end)
describe('terminal input', function()
it('sends various special keys with modifiers', function()
clear()
- local screen = thelpers.screen_setup(0,
- string.format([=[["%s", "-u", "NONE", "-i", "NONE", "--cmd", "startinsert"]]=], nvim_prog))
+ local screen = thelpers.screen_setup(
+ 0,
+ string.format([=[["%s", "-u", "NONE", "-i", "NONE", "--cmd", 'colorscheme vim', "--cmd", "startinsert"]]=], nvim_prog)
+ )
screen:expect{grid=[[
{1: } |
{4:~ }|
diff --git a/test/functional/terminal/cursor_spec.lua b/test/functional/terminal/cursor_spec.lua
index 8285bcc26e..95081b7189 100644
--- a/test/functional/terminal/cursor_spec.lua
+++ b/test/functional/terminal/cursor_spec.lua
@@ -188,16 +188,22 @@ describe('buffer cursor position is correct in terminal without number column',
..[[", "-u", "NONE", "-i", "NONE", "-E", "--cmd", "let @r = ']]..str..[['", ]]
-- <Left> and <Right> don't always work
..[["--cmd", "cnoremap <C-X> <Left>", "--cmd", "cnoremap <C-O> <Right>"]]..']', 70)
+ screen:set_default_attr_ids({
+ [1] = {foreground = 253, background = 11};
+ [3] = {bold = true},
+ [16] = {background = 234, foreground = 253};
+ [17] = {reverse = true, background = 234, foreground = 253};
+ })
-- Also check for real cursor position, as it is used for stuff like input methods
screen._handle_busy_start = function() end
screen._handle_busy_stop = function() end
screen:expect([[
- |
- |
- |
- |
- Entering Ex mode. Type "visual" to go to Normal mode. |
- :{1:^ } |
+ {16: }|
+ {16: }|
+ {16: }|
+ {16: }|
+ {16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {16::}{17:^ }{16: }|
{3:-- TERMINAL --} |
]])
end
@@ -212,23 +218,23 @@ describe('buffer cursor position is correct in terminal without number column',
it('at the end', function()
feed('<C-R>r')
screen:expect([[
- |
- |
- |
- |
- Entering Ex mode. Type "visual" to go to Normal mode. |
- :aaaaaaaa{1:^ } |
+ {16: }|
+ {16: }|
+ {16: }|
+ {16: }|
+ {16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {16::aaaaaaaa}{17:^ }{16: }|
{3:-- TERMINAL --} |
]])
eq({6, 9}, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
- |
- |
- |
- |
- Entering Ex mode. Type "visual" to go to Normal mode. |
- :aaaaaaa^a{2: } |
+ {16: }|
+ {16: }|
+ {16: }|
+ {16: }|
+ {16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {16::aaaaaaa^a}{1: }{16: }|
|
]])
eq({6, 8}, eval('nvim_win_get_cursor(0)'))
@@ -237,23 +243,23 @@ describe('buffer cursor position is correct in terminal without number column',
it('near the end', function()
feed('<C-R>r<C-X><C-X>')
screen:expect([[
- |
- |
- |
- |
- Entering Ex mode. Type "visual" to go to Normal mode. |
- :aaaaaa{1:^a}a |
+ {16: }|
+ {16: }|
+ {16: }|
+ {16: }|
+ {16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {16::aaaaaa}{17:^a}{16:a }|
{3:-- TERMINAL --} |
]])
eq({6, 7}, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
- |
- |
- |
- |
- Entering Ex mode. Type "visual" to go to Normal mode. |
- :aaaaa^a{2:a}a |
+ {16: }|
+ {16: }|
+ {16: }|
+ {16: }|
+ {16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {16::aaaaa^a}{1:a}{16:a }|
|
]])
eq({6, 6}, eval('nvim_win_get_cursor(0)'))
@@ -262,23 +268,23 @@ describe('buffer cursor position is correct in terminal without number column',
it('near the start', function()
feed('<C-R>r<C-B><C-O>')
screen:expect([[
- |
- |
- |
- |
- Entering Ex mode. Type "visual" to go to Normal mode. |
- :a{1:^a}aaaaaa |
+ {16: }|
+ {16: }|
+ {16: }|
+ {16: }|
+ {16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {16::a}{17:^a}{16:aaaaaa }|
{3:-- TERMINAL --} |
]])
eq({6, 2}, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
- |
- |
- |
- |
- Entering Ex mode. Type "visual" to go to Normal mode. |
- :^a{2:a}aaaaaa |
+ {16: }|
+ {16: }|
+ {16: }|
+ {16: }|
+ {16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {16::^a}{1:a}{16:aaaaaa }|
|
]])
eq({6, 1}, eval('nvim_win_get_cursor(0)'))
@@ -293,23 +299,23 @@ describe('buffer cursor position is correct in terminal without number column',
it('at the end', function()
feed('<C-R>r')
screen:expect([[
- |
- |
- |
- |
- Entering Ex mode. Type "visual" to go to Normal mode. |
- :µµµµµµµµ{1:^ } |
+ {16: }|
+ {16: }|
+ {16: }|
+ {16: }|
+ {16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {16::µµµµµµµµ}{17:^ }{16: }|
{3:-- TERMINAL --} |
]])
eq({6, 17}, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
- |
- |
- |
- |
- Entering Ex mode. Type "visual" to go to Normal mode. |
- :µµµµµµµ^µ{2: } |
+ {16: }|
+ {16: }|
+ {16: }|
+ {16: }|
+ {16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {16::µµµµµµµ^µ}{1: }{16: }|
|
]])
eq({6, 15}, eval('nvim_win_get_cursor(0)'))
@@ -318,23 +324,23 @@ describe('buffer cursor position is correct in terminal without number column',
it('near the end', function()
feed('<C-R>r<C-X><C-X>')
screen:expect([[
- |
- |
- |
- |
- Entering Ex mode. Type "visual" to go to Normal mode. |
- :µµµµµµ{1:^µ}µ |
+ {16: }|
+ {16: }|
+ {16: }|
+ {16: }|
+ {16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {16::µµµµµµ}{17:^µ}{16:µ }|
{3:-- TERMINAL --} |
]])
eq({6, 13}, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
- |
- |
- |
- |
- Entering Ex mode. Type "visual" to go to Normal mode. |
- :µµµµµ^µ{2:µ}µ |
+ {16: }|
+ {16: }|
+ {16: }|
+ {16: }|
+ {16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {16::µµµµµ^µ}{1:µ}{16:µ }|
|
]])
eq({6, 11}, eval('nvim_win_get_cursor(0)'))
@@ -343,23 +349,23 @@ describe('buffer cursor position is correct in terminal without number column',
it('near the start', function()
feed('<C-R>r<C-B><C-O>')
screen:expect([[
- |
- |
- |
- |
- Entering Ex mode. Type "visual" to go to Normal mode. |
- :µ{1:^µ}µµµµµµ |
+ {16: }|
+ {16: }|
+ {16: }|
+ {16: }|
+ {16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {16::µ}{17:^µ}{16:µµµµµµ }|
{3:-- TERMINAL --} |
]])
eq({6, 3}, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
- |
- |
- |
- |
- Entering Ex mode. Type "visual" to go to Normal mode. |
- :^µ{2:µ}µµµµµµ |
+ {16: }|
+ {16: }|
+ {16: }|
+ {16: }|
+ {16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {16::^µ}{1:µ}{16:µµµµµµ }|
|
]])
eq({6, 1}, eval('nvim_win_get_cursor(0)'))
@@ -376,23 +382,23 @@ describe('buffer cursor position is correct in terminal without number column',
it('at the end', function()
feed('<C-R>r')
screen:expect([[
- |
- |
- |
- |
- Entering Ex mode. Type "visual" to go to Normal mode. |
- :µ̳µ̳µ̳µ̳µ̳µ̳µ̳µ̳{1:^ } |
+ {16: }|
+ {16: }|
+ {16: }|
+ {16: }|
+ {16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {16::µ̳µ̳µ̳µ̳µ̳µ̳µ̳µ̳}{17:^ }{16: }|
{3:-- TERMINAL --} |
]])
eq({6, 33}, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
- |
- |
- |
- |
- Entering Ex mode. Type "visual" to go to Normal mode. |
- :µ̳µ̳µ̳µ̳µ̳µ̳µ̳^µ̳{2: } |
+ {16: }|
+ {16: }|
+ {16: }|
+ {16: }|
+ {16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {16::µ̳µ̳µ̳µ̳µ̳µ̳µ̳^µ̳}{1: }{16: }|
|
]])
eq({6, 29}, eval('nvim_win_get_cursor(0)'))
@@ -401,23 +407,23 @@ describe('buffer cursor position is correct in terminal without number column',
it('near the end', function()
feed('<C-R>r<C-X><C-X>')
screen:expect([[
- |
- |
- |
- |
- Entering Ex mode. Type "visual" to go to Normal mode. |
- :µ̳µ̳µ̳µ̳µ̳µ̳{1:^µ̳}µ̳ |
+ {16: }|
+ {16: }|
+ {16: }|
+ {16: }|
+ {16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {16::µ̳µ̳µ̳µ̳µ̳µ̳}{17:^µ̳}{16:µ̳ }|
{3:-- TERMINAL --} |
]])
eq({6, 25}, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
- |
- |
- |
- |
- Entering Ex mode. Type "visual" to go to Normal mode. |
- :µ̳µ̳µ̳µ̳µ̳^µ̳{2:µ̳}µ̳ |
+ {16: }|
+ {16: }|
+ {16: }|
+ {16: }|
+ {16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {16::µ̳µ̳µ̳µ̳µ̳^µ̳}{1:µ̳}{16:µ̳ }|
|
]])
eq({6, 21}, eval('nvim_win_get_cursor(0)'))
@@ -426,23 +432,23 @@ describe('buffer cursor position is correct in terminal without number column',
it('near the start', function()
feed('<C-R>r<C-B><C-O>')
screen:expect([[
- |
- |
- |
- |
- Entering Ex mode. Type "visual" to go to Normal mode. |
- :µ̳{1:^µ̳}µ̳µ̳µ̳µ̳µ̳µ̳ |
+ {16: }|
+ {16: }|
+ {16: }|
+ {16: }|
+ {16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {16::µ̳}{17:^µ̳}{16:µ̳µ̳µ̳µ̳µ̳µ̳ }|
{3:-- TERMINAL --} |
]])
eq({6, 5}, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
- |
- |
- |
- |
- Entering Ex mode. Type "visual" to go to Normal mode. |
- :^µ̳{2:µ̳}µ̳µ̳µ̳µ̳µ̳µ̳ |
+ {16: }|
+ {16: }|
+ {16: }|
+ {16: }|
+ {16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {16::^µ̳}{1:µ̳}{16:µ̳µ̳µ̳µ̳µ̳µ̳ }|
|
]])
eq({6, 1}, eval('nvim_win_get_cursor(0)'))
@@ -459,23 +465,23 @@ describe('buffer cursor position is correct in terminal without number column',
it('at the end', function()
feed('<C-R>r')
screen:expect([[
- |
- |
- |
- |
- Entering Ex mode. Type "visual" to go to Normal mode. |
- :哦哦哦哦哦哦哦哦{1:^ } |
+ {16: }|
+ {16: }|
+ {16: }|
+ {16: }|
+ {16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {16::哦哦哦哦哦哦哦哦}{17:^ }{16: }|
{3:-- TERMINAL --} |
]])
eq({6, 25}, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
- |
- |
- |
- |
- Entering Ex mode. Type "visual" to go to Normal mode. |
- :哦哦哦哦哦哦哦^哦{2: } |
+ {16: }|
+ {16: }|
+ {16: }|
+ {16: }|
+ {16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {16::哦哦哦哦哦哦哦^哦}{1: }{16: }|
|
]])
eq({6, 22}, eval('nvim_win_get_cursor(0)'))
@@ -484,23 +490,23 @@ describe('buffer cursor position is correct in terminal without number column',
it('near the end', function()
feed('<C-R>r<C-X><C-X>')
screen:expect([[
- |
- |
- |
- |
- Entering Ex mode. Type "visual" to go to Normal mode. |
- :哦哦哦哦哦哦{1:^哦}哦 |
+ {16: }|
+ {16: }|
+ {16: }|
+ {16: }|
+ {16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {16::哦哦哦哦哦哦}{17:^哦}{16:哦 }|
{3:-- TERMINAL --} |
]])
eq({6, 19}, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
- |
- |
- |
- |
- Entering Ex mode. Type "visual" to go to Normal mode. |
- :哦哦哦哦哦^哦{2:哦}哦 |
+ {16: }|
+ {16: }|
+ {16: }|
+ {16: }|
+ {16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {16::哦哦哦哦哦^哦}{1:哦}{16:哦 }|
|
]])
eq({6, 16}, eval('nvim_win_get_cursor(0)'))
@@ -509,23 +515,23 @@ describe('buffer cursor position is correct in terminal without number column',
it('near the start', function()
feed('<C-R>r<C-B><C-O>')
screen:expect([[
- |
- |
- |
- |
- Entering Ex mode. Type "visual" to go to Normal mode. |
- :哦{1:^哦}哦哦哦哦哦哦 |
+ {16: }|
+ {16: }|
+ {16: }|
+ {16: }|
+ {16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {16::哦}{17:^哦}{16:哦哦哦哦哦哦 }|
{3:-- TERMINAL --} |
]])
eq({6, 4}, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
- |
- |
- |
- |
- Entering Ex mode. Type "visual" to go to Normal mode. |
- :^哦{2:哦}哦哦哦哦哦哦 |
+ {16: }|
+ {16: }|
+ {16: }|
+ {16: }|
+ {16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {16::^哦}{1:哦}{16:哦哦哦哦哦哦 }|
|
]])
eq({6, 1}, eval('nvim_win_get_cursor(0)'))
@@ -536,24 +542,24 @@ describe('buffer cursor position is correct in terminal without number column',
setup_ex_register('aaaaaaaa ')
feed('<C-R>r')
screen:expect([[
- |
- |
- |
- |
- Entering Ex mode. Type "visual" to go to Normal mode. |
- :aaaaaaaa {1:^ } |
+ {16: }|
+ {16: }|
+ {16: }|
+ {16: }|
+ {16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {16::aaaaaaaa }{17:^ }{16: }|
{3:-- TERMINAL --} |
]])
matches('^:aaaaaaaa [ ]*$', eval('nvim_get_current_line()'))
eq({6, 13}, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
- |
- |
- |
- |
- Entering Ex mode. Type "visual" to go to Normal mode. |
- :aaaaaaaa ^ {2: } |
+ {16: }|
+ {16: }|
+ {16: }|
+ {16: }|
+ {16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {16::aaaaaaaa ^ }{1: }{16: }|
|
]])
eq({6, 12}, eval('nvim_win_get_cursor(0)'))
@@ -568,16 +574,23 @@ describe('buffer cursor position is correct in terminal with number column', fun
..[[", "-u", "NONE", "-i", "NONE", "-E", "--cmd", "let @r = ']]..str..[['", ]]
-- <Left> and <Right> don't always work
..[["--cmd", "cnoremap <C-X> <Left>", "--cmd", "cnoremap <C-O> <Right>"]]..']', 70)
+ screen:set_default_attr_ids({
+ [1] = {foreground = 253, background = 11};
+ [3] = {bold = true},
+ [7] = {foreground = 130};
+ [16] = {background = 234, foreground = 253};
+ [17] = {reverse = true, background = 234, foreground = 253};
+ })
-- Also check for real cursor position, as it is used for stuff like input methods
screen._handle_busy_start = function() end
screen._handle_busy_stop = function() end
screen:expect([[
- {7: 1 } |
- {7: 2 } |
- {7: 3 } |
- {7: 4 } |
- {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:{1:^ } |
+ {7: 1 }{16: }|
+ {7: 2 }{16: }|
+ {7: 3 }{16: }|
+ {7: 4 }{16: }|
+ {7: 5 }{16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {7: 6 }{16::}{17:^ }{16: }|
{3:-- TERMINAL --} |
]])
end
@@ -595,23 +608,23 @@ describe('buffer cursor position is correct in terminal with number column', fun
it('at the end', function()
feed('<C-R>r')
screen:expect([[
- {7: 1 } |
- {7: 2 } |
- {7: 3 } |
- {7: 4 } |
- {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:aaaaaaaa{1:^ } |
+ {7: 1 }{16: }|
+ {7: 2 }{16: }|
+ {7: 3 }{16: }|
+ {7: 4 }{16: }|
+ {7: 5 }{16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {7: 6 }{16::aaaaaaaa}{17:^ }{16: }|
{3:-- TERMINAL --} |
]])
eq({6, 9}, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
- {7: 1 } |
- {7: 2 } |
- {7: 3 } |
- {7: 4 } |
- {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:aaaaaaa^a{2: } |
+ {7: 1 }{16: }|
+ {7: 2 }{16: }|
+ {7: 3 }{16: }|
+ {7: 4 }{16: }|
+ {7: 5 }{16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {7: 6 }{16::aaaaaaa^a}{1: }{16: }|
|
]])
eq({6, 8}, eval('nvim_win_get_cursor(0)'))
@@ -620,23 +633,23 @@ describe('buffer cursor position is correct in terminal with number column', fun
it('near the end', function()
feed('<C-R>r<C-X><C-X>')
screen:expect([[
- {7: 1 } |
- {7: 2 } |
- {7: 3 } |
- {7: 4 } |
- {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:aaaaaa{1:^a}a |
+ {7: 1 }{16: }|
+ {7: 2 }{16: }|
+ {7: 3 }{16: }|
+ {7: 4 }{16: }|
+ {7: 5 }{16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {7: 6 }{16::aaaaaa}{17:^a}{16:a }|
{3:-- TERMINAL --} |
]])
eq({6, 7}, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
- {7: 1 } |
- {7: 2 } |
- {7: 3 } |
- {7: 4 } |
- {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:aaaaa^a{2:a}a |
+ {7: 1 }{16: }|
+ {7: 2 }{16: }|
+ {7: 3 }{16: }|
+ {7: 4 }{16: }|
+ {7: 5 }{16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {7: 6 }{16::aaaaa^a}{1:a}{16:a }|
|
]])
eq({6, 6}, eval('nvim_win_get_cursor(0)'))
@@ -645,23 +658,23 @@ describe('buffer cursor position is correct in terminal with number column', fun
it('near the start', function()
feed('<C-R>r<C-B><C-O>')
screen:expect([[
- {7: 1 } |
- {7: 2 } |
- {7: 3 } |
- {7: 4 } |
- {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:a{1:^a}aaaaaa |
+ {7: 1 }{16: }|
+ {7: 2 }{16: }|
+ {7: 3 }{16: }|
+ {7: 4 }{16: }|
+ {7: 5 }{16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {7: 6 }{16::a}{17:^a}{16:aaaaaa }|
{3:-- TERMINAL --} |
]])
eq({6, 2}, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
- {7: 1 } |
- {7: 2 } |
- {7: 3 } |
- {7: 4 } |
- {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:^a{2:a}aaaaaa |
+ {7: 1 }{16: }|
+ {7: 2 }{16: }|
+ {7: 3 }{16: }|
+ {7: 4 }{16: }|
+ {7: 5 }{16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {7: 6 }{16::^a}{1:a}{16:aaaaaa }|
|
]])
eq({6, 1}, eval('nvim_win_get_cursor(0)'))
@@ -676,23 +689,23 @@ describe('buffer cursor position is correct in terminal with number column', fun
it('at the end', function()
feed('<C-R>r')
screen:expect([[
- {7: 1 } |
- {7: 2 } |
- {7: 3 } |
- {7: 4 } |
- {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:µµµµµµµµ{1:^ } |
+ {7: 1 }{16: }|
+ {7: 2 }{16: }|
+ {7: 3 }{16: }|
+ {7: 4 }{16: }|
+ {7: 5 }{16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {7: 6 }{16::µµµµµµµµ}{17:^ }{16: }|
{3:-- TERMINAL --} |
]])
eq({6, 17}, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
- {7: 1 } |
- {7: 2 } |
- {7: 3 } |
- {7: 4 } |
- {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:µµµµµµµ^µ{2: } |
+ {7: 1 }{16: }|
+ {7: 2 }{16: }|
+ {7: 3 }{16: }|
+ {7: 4 }{16: }|
+ {7: 5 }{16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {7: 6 }{16::µµµµµµµ^µ}{1: }{16: }|
|
]])
eq({6, 15}, eval('nvim_win_get_cursor(0)'))
@@ -701,23 +714,23 @@ describe('buffer cursor position is correct in terminal with number column', fun
it('near the end', function()
feed('<C-R>r<C-X><C-X>')
screen:expect([[
- {7: 1 } |
- {7: 2 } |
- {7: 3 } |
- {7: 4 } |
- {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:µµµµµµ{1:^µ}µ |
+ {7: 1 }{16: }|
+ {7: 2 }{16: }|
+ {7: 3 }{16: }|
+ {7: 4 }{16: }|
+ {7: 5 }{16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {7: 6 }{16::µµµµµµ}{17:^µ}{16:µ }|
{3:-- TERMINAL --} |
]])
eq({6, 13}, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
- {7: 1 } |
- {7: 2 } |
- {7: 3 } |
- {7: 4 } |
- {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:µµµµµ^µ{2:µ}µ |
+ {7: 1 }{16: }|
+ {7: 2 }{16: }|
+ {7: 3 }{16: }|
+ {7: 4 }{16: }|
+ {7: 5 }{16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {7: 6 }{16::µµµµµ^µ}{1:µ}{16:µ }|
|
]])
eq({6, 11}, eval('nvim_win_get_cursor(0)'))
@@ -726,23 +739,23 @@ describe('buffer cursor position is correct in terminal with number column', fun
it('near the start', function()
feed('<C-R>r<C-B><C-O>')
screen:expect([[
- {7: 1 } |
- {7: 2 } |
- {7: 3 } |
- {7: 4 } |
- {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:µ{1:^µ}µµµµµµ |
+ {7: 1 }{16: }|
+ {7: 2 }{16: }|
+ {7: 3 }{16: }|
+ {7: 4 }{16: }|
+ {7: 5 }{16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {7: 6 }{16::µ}{17:^µ}{16:µµµµµµ }|
{3:-- TERMINAL --} |
]])
eq({6, 3}, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
- {7: 1 } |
- {7: 2 } |
- {7: 3 } |
- {7: 4 } |
- {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:^µ{2:µ}µµµµµµ |
+ {7: 1 }{16: }|
+ {7: 2 }{16: }|
+ {7: 3 }{16: }|
+ {7: 4 }{16: }|
+ {7: 5 }{16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {7: 6 }{16::^µ}{1:µ}{16:µµµµµµ }|
|
]])
eq({6, 1}, eval('nvim_win_get_cursor(0)'))
@@ -759,23 +772,23 @@ describe('buffer cursor position is correct in terminal with number column', fun
it('at the end', function()
feed('<C-R>r')
screen:expect([[
- {7: 1 } |
- {7: 2 } |
- {7: 3 } |
- {7: 4 } |
- {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:µ̳µ̳µ̳µ̳µ̳µ̳µ̳µ̳{1:^ } |
+ {7: 1 }{16: }|
+ {7: 2 }{16: }|
+ {7: 3 }{16: }|
+ {7: 4 }{16: }|
+ {7: 5 }{16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {7: 6 }{16::µ̳µ̳µ̳µ̳µ̳µ̳µ̳µ̳}{17:^ }{16: }|
{3:-- TERMINAL --} |
]])
eq({6, 33}, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
- {7: 1 } |
- {7: 2 } |
- {7: 3 } |
- {7: 4 } |
- {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:µ̳µ̳µ̳µ̳µ̳µ̳µ̳^µ̳{2: } |
+ {7: 1 }{16: }|
+ {7: 2 }{16: }|
+ {7: 3 }{16: }|
+ {7: 4 }{16: }|
+ {7: 5 }{16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {7: 6 }{16::µ̳µ̳µ̳µ̳µ̳µ̳µ̳^µ̳}{1: }{16: }|
|
]])
eq({6, 29}, eval('nvim_win_get_cursor(0)'))
@@ -784,23 +797,23 @@ describe('buffer cursor position is correct in terminal with number column', fun
it('near the end', function()
feed('<C-R>r<C-X><C-X>')
screen:expect([[
- {7: 1 } |
- {7: 2 } |
- {7: 3 } |
- {7: 4 } |
- {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:µ̳µ̳µ̳µ̳µ̳µ̳{1:^µ̳}µ̳ |
+ {7: 1 }{16: }|
+ {7: 2 }{16: }|
+ {7: 3 }{16: }|
+ {7: 4 }{16: }|
+ {7: 5 }{16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {7: 6 }{16::µ̳µ̳µ̳µ̳µ̳µ̳}{17:^µ̳}{16:µ̳ }|
{3:-- TERMINAL --} |
]])
eq({6, 25}, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
- {7: 1 } |
- {7: 2 } |
- {7: 3 } |
- {7: 4 } |
- {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:µ̳µ̳µ̳µ̳µ̳^µ̳{2:µ̳}µ̳ |
+ {7: 1 }{16: }|
+ {7: 2 }{16: }|
+ {7: 3 }{16: }|
+ {7: 4 }{16: }|
+ {7: 5 }{16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {7: 6 }{16::µ̳µ̳µ̳µ̳µ̳^µ̳}{1:µ̳}{16:µ̳ }|
|
]])
eq({6, 21}, eval('nvim_win_get_cursor(0)'))
@@ -809,23 +822,23 @@ describe('buffer cursor position is correct in terminal with number column', fun
it('near the start', function()
feed('<C-R>r<C-B><C-O>')
screen:expect([[
- {7: 1 } |
- {7: 2 } |
- {7: 3 } |
- {7: 4 } |
- {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:µ̳{1:^µ̳}µ̳µ̳µ̳µ̳µ̳µ̳ |
+ {7: 1 }{16: }|
+ {7: 2 }{16: }|
+ {7: 3 }{16: }|
+ {7: 4 }{16: }|
+ {7: 5 }{16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {7: 6 }{16::µ̳}{17:^µ̳}{16:µ̳µ̳µ̳µ̳µ̳µ̳ }|
{3:-- TERMINAL --} |
]])
eq({6, 5}, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
- {7: 1 } |
- {7: 2 } |
- {7: 3 } |
- {7: 4 } |
- {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:^µ̳{2:µ̳}µ̳µ̳µ̳µ̳µ̳µ̳ |
+ {7: 1 }{16: }|
+ {7: 2 }{16: }|
+ {7: 3 }{16: }|
+ {7: 4 }{16: }|
+ {7: 5 }{16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {7: 6 }{16::^µ̳}{1:µ̳}{16:µ̳µ̳µ̳µ̳µ̳µ̳ }|
|
]])
eq({6, 1}, eval('nvim_win_get_cursor(0)'))
@@ -842,23 +855,23 @@ describe('buffer cursor position is correct in terminal with number column', fun
it('at the end', function()
feed('<C-R>r')
screen:expect([[
- {7: 1 } |
- {7: 2 } |
- {7: 3 } |
- {7: 4 } |
- {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:哦哦哦哦哦哦哦哦{1:^ } |
+ {7: 1 }{16: }|
+ {7: 2 }{16: }|
+ {7: 3 }{16: }|
+ {7: 4 }{16: }|
+ {7: 5 }{16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {7: 6 }{16::哦哦哦哦哦哦哦哦}{17:^ }{16: }|
{3:-- TERMINAL --} |
]])
eq({6, 25}, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
- {7: 1 } |
- {7: 2 } |
- {7: 3 } |
- {7: 4 } |
- {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:哦哦哦哦哦哦哦^哦{2: } |
+ {7: 1 }{16: }|
+ {7: 2 }{16: }|
+ {7: 3 }{16: }|
+ {7: 4 }{16: }|
+ {7: 5 }{16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {7: 6 }{16::哦哦哦哦哦哦哦^哦}{1: }{16: }|
|
]])
eq({6, 22}, eval('nvim_win_get_cursor(0)'))
@@ -867,23 +880,23 @@ describe('buffer cursor position is correct in terminal with number column', fun
it('near the end', function()
feed('<C-R>r<C-X><C-X>')
screen:expect([[
- {7: 1 } |
- {7: 2 } |
- {7: 3 } |
- {7: 4 } |
- {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:哦哦哦哦哦哦{1:^哦}哦 |
+ {7: 1 }{16: }|
+ {7: 2 }{16: }|
+ {7: 3 }{16: }|
+ {7: 4 }{16: }|
+ {7: 5 }{16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {7: 6 }{16::哦哦哦哦哦哦}{17:^哦}{16:哦 }|
{3:-- TERMINAL --} |
]])
eq({6, 19}, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
- {7: 1 } |
- {7: 2 } |
- {7: 3 } |
- {7: 4 } |
- {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:哦哦哦哦哦^哦{2:哦}哦 |
+ {7: 1 }{16: }|
+ {7: 2 }{16: }|
+ {7: 3 }{16: }|
+ {7: 4 }{16: }|
+ {7: 5 }{16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {7: 6 }{16::哦哦哦哦哦^哦}{1:哦}{16:哦 }|
|
]])
eq({6, 16}, eval('nvim_win_get_cursor(0)'))
@@ -892,23 +905,23 @@ describe('buffer cursor position is correct in terminal with number column', fun
it('near the start', function()
feed('<C-R>r<C-B><C-O>')
screen:expect([[
- {7: 1 } |
- {7: 2 } |
- {7: 3 } |
- {7: 4 } |
- {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:哦{1:^哦}哦哦哦哦哦哦 |
+ {7: 1 }{16: }|
+ {7: 2 }{16: }|
+ {7: 3 }{16: }|
+ {7: 4 }{16: }|
+ {7: 5 }{16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {7: 6 }{16::哦}{17:^哦}{16:哦哦哦哦哦哦 }|
{3:-- TERMINAL --} |
]])
eq({6, 4}, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
- {7: 1 } |
- {7: 2 } |
- {7: 3 } |
- {7: 4 } |
- {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:^哦{2:哦}哦哦哦哦哦哦 |
+ {7: 1 }{16: }|
+ {7: 2 }{16: }|
+ {7: 3 }{16: }|
+ {7: 4 }{16: }|
+ {7: 5 }{16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {7: 6 }{16::^哦}{1:哦}{16:哦哦哦哦哦哦 }|
|
]])
eq({6, 1}, eval('nvim_win_get_cursor(0)'))
@@ -919,24 +932,24 @@ describe('buffer cursor position is correct in terminal with number column', fun
setup_ex_register('aaaaaaaa ')
feed('<C-R>r')
screen:expect([[
- {7: 1 } |
- {7: 2 } |
- {7: 3 } |
- {7: 4 } |
- {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:aaaaaaaa {1:^ } |
+ {7: 1 }{16: }|
+ {7: 2 }{16: }|
+ {7: 3 }{16: }|
+ {7: 4 }{16: }|
+ {7: 5 }{16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {7: 6 }{16::aaaaaaaa }{17:^ }{16: }|
{3:-- TERMINAL --} |
]])
matches('^:aaaaaaaa [ ]*$', eval('nvim_get_current_line()'))
eq({6, 13}, eval('nvim_win_get_cursor(0)'))
feed([[<C-\><C-N>]])
screen:expect([[
- {7: 1 } |
- {7: 2 } |
- {7: 3 } |
- {7: 4 } |
- {7: 5 }Entering Ex mode. Type "visual" to go to Normal mode. |
- {7: 6 }:aaaaaaaa ^ {2: } |
+ {7: 1 }{16: }|
+ {7: 2 }{16: }|
+ {7: 3 }{16: }|
+ {7: 4 }{16: }|
+ {7: 5 }{16:Entering Ex mode. Type "visual" to go to Normal mode. }|
+ {7: 6 }{16::aaaaaaaa ^ }{1: }{16: }|
|
]])
eq({6, 12}, eval('nvim_win_get_cursor(0)'))
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua
index 96ae0c4662..e0216a22a7 100644
--- a/test/functional/terminal/tui_spec.lua
+++ b/test/functional/terminal/tui_spec.lua
@@ -40,8 +40,12 @@ describe('TUI', function()
clear()
local child_server = new_pipename()
screen = thelpers.screen_setup(0,
- string.format([=[["%s", "--listen", "%s", "-u", "NONE", "-i", "NONE", "--cmd", "%s laststatus=2 background=dark"]]=],
- nvim_prog, child_server, nvim_set))
+ string.format(
+ [=[["%s", "--listen", "%s", "-u", "NONE", "-i", "NONE", "--cmd", "%s laststatus=2 background=dark", "--cmd", "colorscheme vim"]]=],
+ nvim_prog,
+ child_server,
+ nvim_set
+ ))
screen:expect([[
{1: } |
{4:~ }|
@@ -1826,7 +1830,7 @@ describe('TUI', function()
})
screen:attach()
exec([[
- call termopen([v:progpath, '--clean', '--cmd', 'let start = reltime() | while v:true | if reltimefloat(reltime(start)) > 2 | break | endif | endwhile'])
+ call termopen([v:progpath, '--clean', '--cmd', 'colorscheme vim', '--cmd', 'let start = reltime() | while v:true | if reltimefloat(reltime(start)) > 2 | break | endif | endwhile'])
sleep 500m
vs new
]])
@@ -1852,7 +1856,7 @@ describe('TUI', function()
write_file(script_file, [=[
local ffi = require('ffi')
ffi.cdef([[int execl(const char *, const char *, ...);]])
- ffi.C.execl(vim.v.progpath, 'Xargv0nvim', '--clean')
+ ffi.C.execl(vim.v.progpath, 'Xargv0nvim', '--clean', '--cmd', 'colorscheme vim')
]=])
finally(function()
os.remove(script_file)
@@ -1870,12 +1874,12 @@ describe('TUI', function()
]]}
feed_data(':put =v:argv + [v:progname]\n')
screen:expect{grid=[[
- Xargv0nvim |
- --embed |
--clean |
+ --cmd |
+ colorscheme vim |
{1:X}argv0nvim |
- {5:[No Name] [+] 5,1 Bot}|
- 4 more lines |
+ {5:[No Name] [+] 7,1 Bot}|
+ 6 more lines |
{3:-- TERMINAL --} |
]]}
end)
@@ -1899,8 +1903,11 @@ describe('TUI', function()
end)
it('<C-h> #10134', function()
- local screen = thelpers.screen_setup(0, '["'..nvim_prog
- ..[[", "-u", "NONE", "-i", "NONE", "--cmd", "set noruler", "--cmd", ':nnoremap <C-h> :echomsg "\<C-h\>"<CR>']]..']')
+ local screen = thelpers.screen_setup(
+ 0,
+ '["'..nvim_prog..[[", "-u", "NONE", "-i", "NONE", "--cmd", "colorscheme vim", ]]
+ ..[["--cmd", "set noruler", "--cmd", ':nnoremap <C-h> :echomsg "\<C-h\>"<CR>']]..']'
+ )
screen:expect{grid=[[
{1: } |
{4:~ }|
@@ -1924,8 +1931,12 @@ describe('TUI', function()
end)
it('draws line with many trailing spaces correctly #24955', function()
- local screen = thelpers.screen_setup(0, '["'..nvim_prog..[[", "-u", "NONE", "-i", "NONE"]]
- ..[[, "--cmd", "call setline(1, ['1st line' .. repeat(' ', 153), '2nd line'])"]]..']', 80)
+ local screen = thelpers.screen_setup(
+ 0,
+ '["'..nvim_prog..[[", "-u", "NONE", "-i", "NONE", "--cmd", "colorscheme vim"]]
+ ..[[, "--cmd", "call setline(1, ['1st line' .. repeat(' ', 153), '2nd line'])"]]..']',
+ 80
+ )
screen:expect{grid=[[
{1:1}st line |
|
@@ -1953,6 +1964,7 @@ describe('TUI UIEnter/UILeave', function()
clear()
local screen = thelpers.screen_setup(0,
'["'..nvim_prog..'", "-u", "NONE", "-i", "NONE"'
+ ..[[, "--cmd", "colorscheme vim"]]
..[[, "--cmd", "set noswapfile noshowcmd noruler"]]
..[[, "--cmd", "let g:evs = []"]]
..[[, "--cmd", "autocmd UIEnter * :call add(g:evs, 'UIEnter')"]]
@@ -1991,7 +2003,8 @@ describe('TUI FocusGained/FocusLost', function()
local child_server = new_pipename()
screen = thelpers.screen_setup(0,
string.format(
- [=[["%s", "--listen", "%s", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile noshowcmd noruler"]]=],
+ '["%s", "--listen", "%s", "-u", "NONE", "-i", "NONE", "--cmd", "colorscheme vim", '
+ ..'"--cmd", "set noswapfile noshowcmd noruler"]',
nvim_prog, child_server))
screen:expect([[
{1: } |
@@ -2198,14 +2211,16 @@ describe("TUI 't_Co' (terminal colors)", function()
-- This is ugly because :term/termopen() forces TERM=xterm-256color.
-- TODO: Revisit this after jobstart/termopen accept `env` dict.
screen = thelpers.screen_setup(0, string.format(
- [=[['sh', '-c', 'LANG=C TERM=%s %s %s -u NONE -i NONE --cmd "%s"']]=],
+ [=[['sh', '-c', 'LANG=C TERM=%s %s %s -u NONE -i NONE --cmd "colorscheme vim" --cmd "%s"']]=],
term or "",
(colorterm ~= nil and "COLORTERM="..colorterm or ""),
nvim_prog,
nvim_set))
local tline
- if maxcolors == 8 or maxcolors == 16 then
+ if maxcolors == 8 then
+ tline = "{9:~ }"
+ elseif maxcolors == 16 then
tline = "~ "
else
tline = "{4:~ }"
@@ -2528,7 +2543,7 @@ describe("TUI", function()
-- This is ugly because :term/termopen() forces TERM=xterm-256color.
-- TODO: Revisit this after jobstart/termopen accept `env` dict.
local cmd = string.format(
- [=[['sh', '-c', 'LANG=C %s -u NONE -i NONE %s --cmd "%s"']]=],
+ [=[['sh', '-c', 'LANG=C %s -u NONE -i NONE %s --cmd "colorscheme vim" --cmd "%s"']]=],
nvim_prog,
extra_args or "",
nvim_set)
@@ -2591,7 +2606,7 @@ describe('TUI bg color', function()
local function setup_bg_test()
clear()
screen = thelpers.screen_setup(0, '["'..nvim_prog
- ..'", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile", '
+ ..'", "-u", "NONE", "-i", "NONE", "--cmd", "colorscheme vim", "--cmd", "set noswapfile", '
..'"-c", "autocmd OptionSet background echo \\"did OptionSet, yay!\\""]')
end
@@ -2712,8 +2727,13 @@ describe("TUI as a client", function()
set_session(server_super)
local server_pipe = new_pipename()
local screen_server = thelpers.screen_setup(0,
- string.format([=[["%s", "--listen", "%s", "-u", "NONE", "-i", "NONE", "--cmd", "%s laststatus=2 background=dark"]]=],
- nvim_prog, server_pipe, nvim_set))
+ string.format(
+ '["%s", "--listen", "%s", "-u", "NONE", "-i", "NONE", "--cmd", "colorscheme vim", '
+ ..'"--cmd", "%s laststatus=2 background=dark"]',
+ nvim_prog,
+ server_pipe,
+ nvim_set
+ ))
feed_data("iHello, World")
screen_server:expect{grid=[[
@@ -2839,8 +2859,13 @@ describe("TUI as a client", function()
set_session(server_super)
local server_pipe = new_pipename()
local screen_server = thelpers.screen_setup(0,
- string.format([=[["%s", "--listen", "%s", "-u", "NONE", "-i", "NONE", "--cmd", "%s laststatus=2 background=dark"]]=],
- nvim_prog, server_pipe, nvim_set))
+ string.format(
+ '["%s", "--listen", "%s", "-u", "NONE", "-i", "NONE", "--cmd", "colorscheme vim", '
+ ..'"--cmd", "%s laststatus=2 background=dark"]',
+ nvim_prog,
+ server_pipe,
+ nvim_set
+ ))
screen_server:expect{grid=[[
{1: } |
{4:~ }|
diff --git a/test/functional/treesitter/node_spec.lua b/test/functional/treesitter/node_spec.lua
index eef75d0e91..16ead69649 100644
--- a/test/functional/treesitter/node_spec.lua
+++ b/test/functional/treesitter/node_spec.lua
@@ -40,6 +40,20 @@ describe('treesitter node API', function()
assert_alive()
end)
+ it('get_node() with lang given', function()
+ -- this buffer doesn't have filetype set!
+ insert('local foo = function() end')
+ exec_lua([[
+ node = vim.treesitter.get_node({
+ bufnr = 0,
+ pos = { 0, 6 }, -- on "foo"
+ lang = 'lua',
+ })
+ ]])
+ eq('foo', lua_eval('vim.treesitter.query.get_node_text(node, 0)'))
+ eq('identifier', lua_eval('node:type()'))
+ end)
+
it('can move between siblings', function()
insert([[
int main(int x, int y, int z) {
diff --git a/test/functional/ui/cursor_spec.lua b/test/functional/ui/cursor_spec.lua
index 05057ca080..7bec5eaac6 100644
--- a/test/functional/ui/cursor_spec.lua
+++ b/test/functional/ui/cursor_spec.lua
@@ -215,7 +215,7 @@ describe('ui/cursor', function()
m.hl_id = 64
m.attr = {background = Screen.colors.DarkGray}
end
- if m.id_lm then m.id_lm = 67 end
+ if m.id_lm then m.id_lm = 69 end
end
-- Assert the new expectation.
diff --git a/test/functional/ui/embed_spec.lua b/test/functional/ui/embed_spec.lua
index 9729f65355..3bc3af9853 100644
--- a/test/functional/ui/embed_spec.lua
+++ b/test/functional/ui/embed_spec.lua
@@ -26,6 +26,12 @@ local function test_embed(ext_linegrid)
[3] = {bold = true, foreground = Screen.colors.Blue1},
[4] = {bold = true, foreground = Screen.colors.Green},
[5] = {bold = true, reverse = true},
+ [6] = {foreground = Screen.colors.NvimDarkGrey3, background = Screen.colors.NvimLightGrey1};
+ [7] = {foreground = Screen.colors.NvimDarkRed};
+ [8] = {foreground = Screen.colors.NvimDarkCyan};
+ [9] = {foreground = Screen.colors.NvimLightGrey3, background = Screen.colors.NvimDarkGrey1};
+ [10] = {foreground = Screen.colors.NvimLightRed};
+ [11] = {foreground = Screen.colors.NvimLightCyan};
})
end
@@ -36,10 +42,10 @@ local function test_embed(ext_linegrid)
|
|
|
- |
- Error detected while processing pre-vimrc command line: |
- E121: Undefined variable: invalid |
- Press ENTER or type command to continue^ |
+ {6: }|
+ {7:Error detected while processing pre-vimrc command line:} |
+ {7:E121: Undefined variable: invalid} |
+ {8:Press ENTER or type command to continue}^ |
]])
feed('<cr>')
@@ -64,11 +70,11 @@ local function test_embed(ext_linegrid)
|
|
|
- {5: }|
- Error detected while processing pre-vimrc command line: |
- foo |
- {1:bar} |
- {4:Press ENTER or type command to continue}^ |
+ {9: }|
+ {7:Error detected while processing pre-vimrc command line:} |
+ {7:foo} |
+ {10:bar} |
+ {11:Press ENTER or type command to continue}^ |
]])
end)
@@ -78,11 +84,11 @@ local function test_embed(ext_linegrid)
|
|
|
- |
- Error detected while processing pre-vimrc command line: |
- foo |
- bar |
- Press ENTER or type command to continue^ |
+ {6: }|
+ {7:Error detected while processing pre-vimrc command line:} |
+ {7:foo} |
+ {7:bar} |
+ {8:Press ENTER or type command to continue}^ |
]], condition=function()
eq(Screen.colors.Green, screen.default_colors.rgb_bg)
end}
@@ -144,7 +150,7 @@ describe('--embed --listen UI', function()
helpers.skip(helpers.is_os('win'))
clear()
local child_server = assert(helpers.new_pipename())
- funcs.jobstart({nvim_prog, '--embed', '--listen', child_server, '--clean'})
+ funcs.jobstart({nvim_prog, '--embed', '--listen', child_server, '--clean', '--cmd', 'colorscheme vim'})
retry(nil, nil, function() neq(nil, uv.fs_stat(child_server)) end)
local child_session = helpers.connect(child_server)
diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua
index 2902b4a4a5..eca8ee6422 100644
--- a/test/functional/ui/float_spec.lua
+++ b/test/functional/ui/float_spec.lua
@@ -1185,7 +1185,7 @@ describe('float window', function()
it('defaults to NormalFloat highlight and inherited options', function()
command('set number')
- command('hi NormalFloat guibg=#333333')
+ command('hi NormalFloat guibg=#333333 guifg=NONE')
feed('ix<cr>y<cr><esc>gg')
local win = meths.open_win(0, false, {relative='editor', width=20, height=4, row=4, col=10})
if multigrid then
@@ -1271,7 +1271,7 @@ describe('float window', function()
command('set colorcolumn=1')
command('set cursorline')
command('set foldcolumn=1')
- command('hi NormalFloat guibg=#333333')
+ command('hi NormalFloat guibg=#333333 guifg=NONE')
feed('ix<cr>y<cr><esc>gg')
local win = meths.open_win(0, false, {relative='editor', width=20, height=4, row=4, col=10, style='minimal'})
if multigrid then
@@ -1399,7 +1399,7 @@ describe('float window', function()
command('set colorcolumn=1')
command('set cursorline')
command('set foldcolumn=1')
- command('hi NormalFloat guibg=#333333')
+ command('hi NormalFloat guibg=#333333 guifg=NONE')
feed('ix<cr>y<cr><esc>gg')
local win = meths.open_win(0, false, {relative='editor', width=20, height=4, row=4, col=10, style='minimal'})
if multigrid then
@@ -1528,7 +1528,7 @@ describe('float window', function()
command('set cursorline')
command('set foldcolumn=1')
command('set statuscolumn=%l%s%C')
- command('hi NormalFloat guibg=#333333')
+ command('hi NormalFloat guibg=#333333 guifg=NONE')
feed('ix<cr>y<cr><esc>gg')
meths.open_win(0, false, {relative='editor', width=20, height=4, row=4, col=10, style='minimal'})
if multigrid then
@@ -5921,7 +5921,7 @@ describe('float window', function()
describe('float shown after pum', function()
local win
before_each(function()
- command('hi NormalFloat guibg=#333333')
+ command('hi NormalFloat guibg=#333333 guifg=NONE')
feed('i')
funcs.complete(1, {'aa', 'word', 'longtext'})
if multigrid then
diff --git a/test/functional/ui/hlstate_spec.lua b/test/functional/ui/hlstate_spec.lua
index 55f873e827..b35d61744f 100644
--- a/test/functional/ui/hlstate_spec.lua
+++ b/test/functional/ui/hlstate_spec.lua
@@ -72,7 +72,7 @@ describe('ext_hlstate detailed highlights', function()
[6] = {{}, {{hi_name = "StatusLineNC", ui_name = "StatusLineNC", kind = "ui"}}},
[7] = {{}, {{hi_name = "MsgArea", ui_name = "MsgArea", kind = "ui"}}},
})
- command("hi clear VertSplit")
+ command("hi clear WinSeparator")
command("vsplit")
screen:expect([[
diff --git a/test/functional/ui/output_spec.lua b/test/functional/ui/output_spec.lua
index 7b93b74eac..1dbbe76bac 100644
--- a/test/functional/ui/output_spec.lua
+++ b/test/functional/ui/output_spec.lua
@@ -22,7 +22,7 @@ describe("shell command :!", function()
before_each(function()
clear()
screen = child_session.screen_setup(0, '["'..helpers.nvim_prog..
- '", "-u", "NONE", "-i", "NONE", "--cmd", "'..helpers.nvim_set..'"]')
+ '", "-u", "NONE", "-i", "NONE", "--cmd", "colorscheme vim", "--cmd", "'..helpers.nvim_set..'"]')
screen:expect([[
{1: } |
{4:~ }|
diff --git a/test/functional/ui/quickfix_spec.lua b/test/functional/ui/quickfix_spec.lua
index df43871e60..9f072915e2 100644
--- a/test/functional/ui/quickfix_spec.lua
+++ b/test/functional/ui/quickfix_spec.lua
@@ -89,7 +89,7 @@ describe('quickfix selection highlight', function()
end)
it('using QuickFixLine highlight group', function()
- command('highlight QuickFixLine guibg=Red')
+ command('highlight QuickFixLine guibg=Red guifg=NONE gui=NONE')
command('copen')
@@ -124,7 +124,7 @@ describe('quickfix selection highlight', function()
it('combines with CursorLine', function()
command('set cursorline')
- command('highlight QuickFixLine guifg=Red')
+ command('highlight QuickFixLine guifg=Red guibg=NONE gui=NONE')
command('highlight CursorLine guibg=Fuchsia')
command('copen')
@@ -160,7 +160,7 @@ describe('quickfix selection highlight', function()
it('QuickFixLine background takes precedence over CursorLine', function()
command('set cursorline')
- command('highlight QuickFixLine guibg=Red')
+ command('highlight QuickFixLine guibg=Red guifg=NONE gui=NONE')
command('highlight CursorLine guibg=Fuchsia')
command('copen')
diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua
index 7cc1accd3f..4ef7565ec5 100644
--- a/test/functional/ui/screen_basic_spec.lua
+++ b/test/functional/ui/screen_basic_spec.lua
@@ -8,9 +8,15 @@ local funcs, meths = helpers.funcs, helpers.meths
describe('screen', function()
local screen
- local nvim_argv = {helpers.nvim_prog, '-u', 'NONE', '-i', 'NONE', '-N',
- '--cmd', 'set shortmess+=I background=light noswapfile belloff= noshowcmd noruler',
- '--embed'}
+ local nvim_argv = {
+ helpers.nvim_prog,
+ '-u', 'NONE',
+ '-i', 'NONE',
+ '-N',
+ '--cmd', 'set shortmess+=I background=light noswapfile belloff= noshowcmd noruler',
+ '--cmd', 'colorscheme vim',
+ '--embed',
+ }
before_each(function()
local screen_nvim = spawn(nvim_argv)
@@ -997,9 +1003,15 @@ describe('Screen default colors', function()
local function startup(light, termcolors)
local extra = (light and ' background=light') or ''
- local nvim_argv = {helpers.nvim_prog, '-u', 'NONE', '-i', 'NONE', '-N',
- '--cmd', 'set shortmess+=I noswapfile belloff= noshowcmd noruler'..extra,
- '--embed'}
+ local nvim_argv = {
+ helpers.nvim_prog,
+ '-u', 'NONE',
+ '-i', 'NONE',
+ '-N',
+ '--cmd', 'set shortmess+=I noswapfile belloff= noshowcmd noruler'..extra,
+ '--cmd', 'colorscheme vim',
+ '--embed',
+ }
local screen_nvim = spawn(nvim_argv)
set_session(screen_nvim)
screen = Screen.new()
@@ -1017,7 +1029,7 @@ describe('Screen default colors', function()
it('can be set to light', function()
startup(true, false)
screen:expect{condition=function()
- eq({rgb_fg=Screen.colors.White, rgb_bg=0, rgb_sp=Screen.colors.Red,
+ eq({rgb_bg=Screen.colors.White, rgb_fg=0, rgb_sp=Screen.colors.Red,
cterm_bg=0, cterm_fg=0}, screen.default_colors)
end}
end)
diff --git a/test/helpers.lua b/test/helpers.lua
index f9405c011d..d4ea8b27a3 100644
--- a/test/helpers.lua
+++ b/test/helpers.lua
@@ -25,7 +25,7 @@ local module = {
local function relpath(p)
p = vim.fs.normalize(p)
local cwd = luv.cwd()
- return p:gsub("^" .. cwd)
+ return p:gsub('^' .. cwd)
end
--- @param path string
@@ -60,7 +60,7 @@ function module.argss_to_cmd(...)
for i = 1, select('#', ...) do
local arg = select(i, ...)
if type(arg) == 'string' then
- cmd = cmd .. ' ' ..shell_quote(arg)
+ cmd = cmd .. ' ' .. shell_quote(arg)
else
for _, subarg in ipairs(arg) do
cmd = cmd .. ' ' .. shell_quote(subarg)
@@ -92,19 +92,19 @@ function module.retry(max, max_ms, fn)
if status then
return result
end
- luv.update_time() -- Update cached value of luv.now() (libuv: uv_now()).
+ luv.update_time() -- Update cached value of luv.now() (libuv: uv_now()).
if (max and tries >= max) or (luv.now() - start_time > timeout) then
- busted.fail(string.format("retry() attempts: %d\n%s", tries, tostring(result)), 2)
+ busted.fail(string.format('retry() attempts: %d\n%s', tries, tostring(result)), 2)
end
tries = tries + 1
- luv.sleep(20) -- Avoid hot loop...
+ luv.sleep(20) -- Avoid hot loop...
end
end
local check_logs_useless_lines = {
- ['Warning: noted but unhandled ioctl']=1,
- ['could cause spurious value errors to appear']=2,
- ['See README_MISSING_SYSCALL_OR_IOCTL for guidance']=3,
+ ['Warning: noted but unhandled ioctl'] = 1,
+ ['could cause spurious value errors to appear'] = 2,
+ ['See README_MISSING_SYSCALL_OR_IOCTL for guidance'] = 3,
}
function module.eq(expected, actual, context)
@@ -120,7 +120,10 @@ end
--- @param expected (any) description of expected result
--- @param actual (any) description of actual result
function module.ok(cond, expected, actual)
- assert((not expected and not actual) or (expected and actual), 'if "expected" is given, "actual" is also required')
+ assert(
+ (not expected and not actual) or (expected and actual),
+ 'if "expected" is given, "actual" is also required'
+ )
local msg = expected and ('expected %s, got: %s'):format(expected, tostring(actual)) or nil
return assert(cond, msg)
end
@@ -129,7 +132,7 @@ local function epicfail(state, arguments, _)
state.failure_message = arguments[1]
return false
end
-assert:register("assertion", "epicfail", epicfail)
+assert:register('assertion', 'epicfail', epicfail)
function module.fail(msg)
return assert.epicfail(msg)
end
@@ -157,14 +160,26 @@ function module.assert_log(pat, logfile, nrlines, inverse)
module.retry(nil, 1000, function()
local lines = module.read_file_list(logfile, -nrlines) or {}
- local msg = string.format('Pattern %q %sfound in log (last %d lines): %s:\n%s',
- pat, (inverse and '' or 'not '), nrlines, logfile, ' '..table.concat(lines, '\n '))
- for _,line in ipairs(lines) do
+ local msg = string.format(
+ 'Pattern %q %sfound in log (last %d lines): %s:\n%s',
+ pat,
+ (inverse and '' or 'not '),
+ nrlines,
+ logfile,
+ ' ' .. table.concat(lines, '\n ')
+ )
+ for _, line in ipairs(lines) do
if line:match(pat) then
- if inverse then error(msg) else return end
+ if inverse then
+ error(msg)
+ else
+ return
+ end
end
end
- if not inverse then error(msg) end
+ if not inverse then
+ error(msg)
+ end
end)
end
@@ -186,9 +201,10 @@ function module.pcall(fn, ...)
-- C:/long/path/foo.lua:186: Expected string, got number
-- to:
-- .../foo.lua:0: Expected string, got number
- local errmsg = tostring(rv):gsub('([%s<])vim[/\\]([^%s:/\\]+):%d+', '%1\xffvim\xff%2:0')
- :gsub('[^%s<]-[/\\]([^%s:/\\]+):%d+', '.../%1:0')
- :gsub('\xffvim\xff', 'vim/')
+ local errmsg = tostring(rv)
+ :gsub('([%s<])vim[/\\]([^%s:/\\]+):%d+', '%1\xffvim\xff%2:0')
+ :gsub('[^%s<]-[/\\]([^%s:/\\]+):%d+', '.../%1:0')
+ :gsub('\xffvim\xff', 'vim/')
-- Scrub numbers in paths/stacktraces:
-- shared.lua:0: in function 'gsplit'
@@ -233,9 +249,10 @@ end
function module.pcall_err_withtrace(fn, ...)
local errmsg = module.pcall_err_withfile(fn, ...)
- return errmsg:gsub('^%.%.%./helpers%.lua:0: ', '')
- :gsub('^Error executing lua:- ' ,'')
- :gsub('^%[string "<nvim>"%]:0: ' ,'')
+ return errmsg
+ :gsub('^%.%.%./helpers%.lua:0: ', '')
+ :gsub('^Error executing lua:- ', '')
+ :gsub('^%[string "<nvim>"%]:0: ', '')
end
function module.pcall_err(...)
@@ -243,7 +260,7 @@ function module.pcall_err(...)
end
function module.remove_trace(s)
- return (s:gsub("\n%s*stack traceback:.*", ""))
+ return (s:gsub('\n%s*stack traceback:.*', ''))
end
-- initial_path: directory to recurse into
@@ -251,12 +268,14 @@ end
-- exc_re: exclude pattern(s) (string or table)
function module.glob(initial_path, re, exc_re)
exc_re = type(exc_re) == 'table' and exc_re or { exc_re }
- local paths_to_check = {initial_path}
+ local paths_to_check = { initial_path }
local ret = {}
local checked_files = {}
local function is_excluded(path)
for _, pat in pairs(exc_re) do
- if path:match(pat) then return true end
+ if path:match(pat) then
+ return true
+ end
end
return false
end
@@ -318,7 +337,7 @@ function module.check_logs()
out:write(start_msg .. '\n')
if status then
for line in f:lines() do
- out:write('= '..line..'\n')
+ out:write('= ' .. line .. '\n')
end
f:close()
else
@@ -331,9 +350,10 @@ function module.check_logs()
end
end
end
- assert(0 == #runtime_errors, string.format(
- 'Found runtime errors in logfile(s): %s',
- table.concat(runtime_errors, ', ')))
+ assert(
+ 0 == #runtime_errors,
+ string.format('Found runtime errors in logfile(s): %s', table.concat(runtime_errors, ', '))
+ )
end
function module.sysname()
@@ -344,18 +364,16 @@ function module.sysname()
end
function module.is_os(s)
- if not (s == 'win'
- or s == 'mac'
- or s == 'freebsd'
- or s == 'openbsd'
- or s == 'bsd') then
- error('unknown platform: '..tostring(s))
- end
- return not not ((s == 'win' and (module.sysname():find('windows') or module.sysname():find('mingw')))
+ if not (s == 'win' or s == 'mac' or s == 'freebsd' or s == 'openbsd' or s == 'bsd') then
+ error('unknown platform: ' .. tostring(s))
+ end
+ return not not (
+ (s == 'win' and (module.sysname():find('windows') or module.sysname():find('mingw')))
or (s == 'mac' and module.sysname() == 'darwin')
or (s == 'freebsd' and module.sysname() == 'freebsd')
or (s == 'openbsd' and module.sysname() == 'openbsd')
- or (s == 'bsd' and module.sysname():find('bsd')))
+ or (s == 'bsd' and module.sysname():find('bsd'))
+ )
end
local function tmpdir_get()
@@ -371,7 +389,7 @@ end
module.tmpname = (function()
local seq = 0
local tmpdir = tmpdir_get()
- return (function()
+ return function()
if tmpdir_is_local(tmpdir) then
-- Cannot control os.tmpname() dir, so hack our own tmpname() impl.
seq = seq + 1
@@ -384,15 +402,15 @@ module.tmpname = (function()
if module.is_os('win') and fname:sub(1, 2) == '\\s' then
-- In Windows tmpname() returns a filename starting with
-- special sequence \s, prepend $TEMP path
- return tmpdir..fname
+ return tmpdir .. fname
elseif fname:match('^/tmp') and module.is_os('mac') then
-- In OS X /tmp links to /private/tmp
- return '/private'..fname
+ return '/private' .. fname
else
return fname
end
end
- end)
+ end
end)()
function module.hasenv(name)
@@ -417,14 +435,17 @@ function module.check_cores(app, force) -- luacheck: ignore
end
app = app or 'build/bin/nvim' -- luacheck: ignore
local initial_path, re, exc_re
- local gdb_db_cmd = 'gdb -n -batch -ex "thread apply all bt full" "$_NVIM_TEST_APP" -c "$_NVIM_TEST_CORE"'
+ local gdb_db_cmd =
+ 'gdb -n -batch -ex "thread apply all bt full" "$_NVIM_TEST_APP" -c "$_NVIM_TEST_CORE"'
local lldb_db_cmd = 'lldb -Q -o "bt all" -f "$_NVIM_TEST_APP" -c "$_NVIM_TEST_CORE"'
local random_skip = false
-- Workspace-local $TMPDIR, scrubbed and pattern-escaped.
-- "./Xtest-tmpdir/" => "Xtest%-tmpdir"
- local local_tmpdir = (tmpdir_is_local(tmpdir_get())
- and relpath(tmpdir_get()):gsub('^[ ./]+',''):gsub('%/+$',''):gsub('([^%w])', '%%%1')
- or nil)
+ local local_tmpdir = (
+ tmpdir_is_local(tmpdir_get())
+ and relpath(tmpdir_get()):gsub('^[ ./]+', ''):gsub('%/+$', ''):gsub('([^%w])', '%%%1')
+ or nil
+ )
local db_cmd
if module.hasenv('NVIM_TEST_CORE_GLOB_DIRECTORY') then
initial_path = os.getenv('NVIM_TEST_CORE_GLOB_DIRECTORY')
@@ -444,7 +465,7 @@ function module.check_cores(app, force) -- luacheck: ignore
else
re = '/core[^/]*$'
end
- exc_re = { '^/%.deps$', '^/%'..deps_prefix()..'$', local_tmpdir, '^/%node_modules$' }
+ exc_re = { '^/%.deps$', '^/%' .. deps_prefix() .. '$', local_tmpdir, '^/%node_modules$' }
db_cmd = gdb_db_cmd
random_skip = true
end
@@ -457,7 +478,7 @@ function module.check_cores(app, force) -- luacheck: ignore
local found_cores = 0
local out = io.stdout
for _, core in ipairs(cores) do
- local len = 80 - #core - #('Core file ') - 2
+ local len = 80 - #core - #'Core file ' - 2
local esigns = ('='):rep(len / 2)
out:write(('\n%s Core file %s %s\n'):format(esigns, core, esigns))
out:flush()
@@ -471,7 +492,7 @@ function module.check_cores(app, force) -- luacheck: ignore
end
tests_skipped = 0
if found_cores > 0 then
- error("crash detected (see above)")
+ error('crash detected (see above)')
end
end
@@ -597,9 +618,9 @@ function module.dedent(str, leave_indent)
-- create a pattern for the indent
indent = indent:gsub('%s', '[ \t]')
-- strip it from the first line
- str = str:gsub('^'..indent, left_indent)
+ str = str:gsub('^' .. indent, left_indent)
-- strip it from the remaining lines
- str = str:gsub('[\n]'..indent, '\n' .. left_indent)
+ str = str:gsub('[\n]' .. indent, '\n' .. left_indent)
return str
end
@@ -611,13 +632,38 @@ local function format_float(v)
end
local SUBTBL = {
- '\\000', '\\001', '\\002', '\\003', '\\004',
- '\\005', '\\006', '\\007', '\\008', '\\t',
- '\\n', '\\011', '\\012', '\\r', '\\014',
- '\\015', '\\016', '\\017', '\\018', '\\019',
- '\\020', '\\021', '\\022', '\\023', '\\024',
- '\\025', '\\026', '\\027', '\\028', '\\029',
- '\\030', '\\031',
+ '\\000',
+ '\\001',
+ '\\002',
+ '\\003',
+ '\\004',
+ '\\005',
+ '\\006',
+ '\\007',
+ '\\008',
+ '\\t',
+ '\\n',
+ '\\011',
+ '\\012',
+ '\\r',
+ '\\014',
+ '\\015',
+ '\\016',
+ '\\017',
+ '\\018',
+ '\\019',
+ '\\020',
+ '\\021',
+ '\\022',
+ '\\023',
+ '\\024',
+ '\\025',
+ '\\026',
+ '\\027',
+ '\\028',
+ '\\029',
+ '\\030',
+ '\\031',
}
-- Formats Lua value `v`.
@@ -647,13 +693,14 @@ function module.format_luav(v, indent, opts)
if opts.literal_strings then
ret = v
else
- local quote = opts.dquote_strings and '"' or '\''
- ret = quote .. tostring(v):gsub(
- opts.dquote_strings and '["\\]' or '[\'\\]',
- '\\%0'):gsub(
- '[%z\1-\31]', function(match)
+ local quote = opts.dquote_strings and '"' or "'"
+ ret = quote
+ .. tostring(v)
+ :gsub(opts.dquote_strings and '["\\]' or "['\\]", '\\%0')
+ :gsub('[%z\1-\31]', function(match)
return SUBTBL[match:byte() + 1]
- end) .. quote
+ end)
+ .. quote
end
elseif type(v) == 'table' then
if v == module.REMOVE_THIS then
@@ -664,8 +711,7 @@ function module.format_luav(v, indent, opts)
local non_empty = false
local format_luav = module.format_luav
for i, subv in ipairs(v) do
- ret = ('%s%s%s,%s'):format(ret, next_indent,
- format_luav(subv, next_indent_arg, opts), nl)
+ ret = ('%s%s%s,%s'):format(ret, next_indent, format_luav(subv, next_indent_arg, opts), nl)
processed_keys[i] = true
non_empty = true
end
@@ -674,8 +720,7 @@ function module.format_luav(v, indent, opts)
if type(k) == 'string' and k:match('^[a-zA-Z_][a-zA-Z0-9_]*$') then
ret = ret .. next_indent .. k .. ' = '
else
- ret = ('%s%s[%s] = '):format(ret, next_indent,
- format_luav(k, nil, opts))
+ ret = ('%s%s[%s] = '):format(ret, next_indent, format_luav(k, nil, opts))
end
ret = ret .. format_luav(subv, next_indent_arg, opts) .. ',' .. nl
non_empty = true
@@ -684,7 +729,7 @@ function module.format_luav(v, indent, opts)
if nl == ' ' and non_empty then
ret = ret:sub(1, -3)
end
- ret = ret .. indent .. '}'
+ ret = ret .. indent .. '}'
end
elseif type(v) == 'number' then
if v % 1 == 0 then
@@ -709,7 +754,7 @@ end
-- Commit: 520c0b91a528
function module.format_string(fmt, ...)
local i = 0
- local args = {...}
+ local args = { ... }
local function getarg()
i = i + 1
return args[i]
@@ -728,7 +773,7 @@ function module.format_string(fmt, ...)
-- Builtin %q is replaced here as it gives invalid and inconsistent with
-- luajit results for e.g. "\e" on lua: luajit transforms that into `\27`,
-- lua leaves as-is.
- arg = module.format_luav(arg, nil, {dquote_strings = (subfmt:sub(-1) == 'q')})
+ arg = module.format_luav(arg, nil, { dquote_strings = (subfmt:sub(-1) == 'q') })
subfmt = subfmt:sub(1, -2) .. 's'
end
if subfmt == '%e' then
@@ -767,27 +812,27 @@ end
function module.hexdump(str)
local len = string.len(str)
- local dump = ""
- local hex = ""
- local asc = ""
+ local dump = ''
+ local hex = ''
+ local asc = ''
for i = 1, len do
if 1 == i % 8 then
- dump = dump .. hex .. asc .. "\n"
- hex = string.format("%04x: ", i - 1)
- asc = ""
+ dump = dump .. hex .. asc .. '\n'
+ hex = string.format('%04x: ', i - 1)
+ asc = ''
end
local ord = string.byte(str, i)
- hex = hex .. string.format("%02x ", ord)
+ hex = hex .. string.format('%02x ', ord)
if ord >= 32 and ord <= 126 then
asc = asc .. string.char(ord)
else
- asc = asc .. "."
+ asc = asc .. '.'
end
end
- return dump .. hex .. string.rep(" ", 8 - len % 8) .. asc
+ return dump .. hex .. string.rep(' ', 8 - len % 8) .. asc
end
-- Reads text lines from `filename` into a table.
@@ -805,16 +850,16 @@ function module.read_file_list(filename, start)
-- There is no need to read more than the last 2MB of the log file, so seek
-- to that.
- local file_size = file:seek("end")
+ local file_size = file:seek('end')
local offset = file_size - 2000000
if offset < 0 then
offset = 0
end
- file:seek("set", offset)
+ file:seek('set', offset)
local lines = {}
local i = 1
- local line = file:read("*l")
+ local line = file:read('*l')
while line ~= nil do
if i >= start then
table.insert(lines, line)
@@ -823,7 +868,7 @@ function module.read_file_list(filename, start)
end
end
i = i + 1
- line = file:read("*l")
+ line = file:read('*l')
end
file:close()
return lines
@@ -875,13 +920,16 @@ function module.read_nvim_log(logfile, ci_rename)
local is_ci = module.is_ci()
local keep = is_ci and 100 or 10
local lines = module.read_file_list(logfile, -keep) or {}
- local log = (('-'):rep(78)..'\n'
- ..string.format('$NVIM_LOG_FILE: %s\n', logfile)
- ..(#lines > 0 and '(last '..tostring(keep)..' lines)\n' or '(empty)\n'))
- for _,line in ipairs(lines) do
- log = log..line..'\n'
- end
- log = log..('-'):rep(78)..'\n'
+ local log = (
+ ('-'):rep(78)
+ .. '\n'
+ .. string.format('$NVIM_LOG_FILE: %s\n', logfile)
+ .. (#lines > 0 and '(last ' .. tostring(keep) .. ' lines)\n' or '(empty)\n')
+ )
+ for _, line in ipairs(lines) do
+ log = log .. line .. '\n'
+ end
+ log = log .. ('-'):rep(78) .. '\n'
if is_ci and ci_rename then
os.rename(logfile, logfile .. '.displayed')
end
diff --git a/test/lua_runner.lua b/test/lua_runner.lua
index 686df9feec..158412b04c 100644
--- a/test/lua_runner.lua
+++ b/test/lua_runner.lua
@@ -1,9 +1,13 @@
local platform = vim.uv.os_uname()
local deps_install_dir = table.remove(_G.arg, 1)
local subcommand = table.remove(_G.arg, 1)
-local suffix = (platform and platform.sysname:lower():find'windows') and '.dll' or '.so'
-package.path = deps_install_dir.."/share/lua/5.1/?.lua;"..deps_install_dir.."/share/lua/5.1/?/init.lua;"..package.path
-package.cpath = deps_install_dir.."/lib/lua/5.1/?"..suffix..";"..package.cpath;
+local suffix = (platform and platform.sysname:lower():find 'windows') and '.dll' or '.so'
+package.path = deps_install_dir
+ .. '/share/lua/5.1/?.lua;'
+ .. deps_install_dir
+ .. '/share/lua/5.1/?/init.lua;'
+ .. package.path
+package.cpath = deps_install_dir .. '/lib/lua/5.1/?' .. suffix .. ';' .. package.cpath
local uv = vim.uv
@@ -15,14 +19,14 @@ local system = {}
package.loaded['system.core'] = system
function system.monotime()
uv.update_time()
- return uv.now()*1e-3
+ return uv.now() * 1e-3
end
function system.gettime()
local sec, usec = uv.gettimeofday()
- return sec+usec*1e-6
+ return sec + usec * 1e-6
end
function system.sleep(sec)
- uv.sleep(sec*1e3)
+ uv.sleep(sec * 1e3)
end
local term = {}
@@ -31,7 +35,7 @@ function term.isatty(_)
return uv.guess_handle(1) == 'tty'
end
-local lfs = {_VERSION = 'fake'}
+local lfs = { _VERSION = 'fake' }
package.loaded['lfs'] = lfs
function lfs.attributes(path, attr)
@@ -39,9 +43,11 @@ function lfs.attributes(path, attr)
if attr == 'mode' then
return stat and stat.type or ''
elseif attr == 'modification' then
- if not stat then return nil end
+ if not stat then
+ return nil
+ end
local mtime = stat.mtime
- return mtime.sec + mtime.nsec*1e-9
+ return mtime.sec + mtime.nsec * 1e-9
else
error('not implemented')
end
@@ -74,9 +80,9 @@ function lfs.mkdir(dir)
return uv.fs_mkdir(dir, 493) -- octal 755
end
-if subcommand == "busted" then
+if subcommand == 'busted' then
require 'busted.runner'({ standalone = false })
-elseif subcommand == "luacheck" then
+elseif subcommand == 'luacheck' then
require 'luacheck.main'
else
error 'unknown subcommand'
diff --git a/test/old/testdir/runtest.vim b/test/old/testdir/runtest.vim
index 928bf7693f..2d8ba60a7e 100644
--- a/test/old/testdir/runtest.vim
+++ b/test/old/testdir/runtest.vim
@@ -120,6 +120,8 @@ lang mess C
" Nvim: append runtime from build dir, which contains the generated doc/tags.
let &runtimepath ..= ',' .. expand($BUILD_DIR) .. '/runtime/'
+" Nvim: append libdir from build dir, which contains the bundled TS parsers.
+let &runtimepath ..= ',' .. expand($BUILD_DIR) .. '/lib/nvim/'
let s:t_bold = &t_md
let s:t_normal = &t_me
diff --git a/test/old/testdir/setup.vim b/test/old/testdir/setup.vim
index 7546b342e6..091fb95806 100644
--- a/test/old/testdir/setup.vim
+++ b/test/old/testdir/setup.vim
@@ -93,3 +93,6 @@ let $HOME = expand(getcwd() . '/XfakeHOME')
if !isdirectory($HOME)
call mkdir($HOME)
endif
+
+" Use Vim's default color scheme
+colorscheme vim
diff --git a/test/old/testdir/test_filetype.vim b/test/old/testdir/test_filetype.vim
index c77ccac3a1..4288a5bde5 100644
--- a/test/old/testdir/test_filetype.vim
+++ b/test/old/testdir/test_filetype.vim
@@ -471,6 +471,7 @@ func s:GetFilenameChecks() abort
\ 'opl': ['file.OPL', 'file.OPl', 'file.OpL', 'file.Opl', 'file.oPL', 'file.oPl', 'file.opL', 'file.opl'],
\ 'ora': ['file.ora'],
\ 'org': ['file.org', 'file.org_archive'],
+ \ 'pacmanlog': ['pacman.log'],
\ 'pamconf': ['/etc/pam.conf', '/etc/pam.d/file', 'any/etc/pam.conf', 'any/etc/pam.d/file'],
\ 'pamenv': ['/etc/security/pam_env.conf', '/home/user/.pam_environment', '.pam_environment', 'pam_env.conf'],
\ 'papp': ['file.papp', 'file.pxml', 'file.pxsl'],
diff --git a/test/old/testdir/test_highlight.vim b/test/old/testdir/test_highlight.vim
index a83dc34063..f7f4d9832b 100644
--- a/test/old/testdir/test_highlight.vim
+++ b/test/old/testdir/test_highlight.vim
@@ -810,6 +810,7 @@ endfunc
" Test for :highlight command errors
func Test_highlight_cmd_errors()
if has('gui_running') || has('nvim')
+ hi! Normal ctermfg=NONE ctermbg=NONE
" This test doesn't fail in the MS-Windows console version.
call assert_fails('hi Xcomment ctermfg=fg', 'E419:')
call assert_fails('hi Xcomment ctermfg=bg', 'E420:')
diff --git a/test/old/testdir/test_scroll_opt.vim b/test/old/testdir/test_scroll_opt.vim
index f2e7bc6b56..a1987ed3c9 100644
--- a/test/old/testdir/test_scroll_opt.vim
+++ b/test/old/testdir/test_scroll_opt.vim
@@ -923,7 +923,7 @@ func Test_smoothscroll_cursor_top()
exe "norm G3\<C-E>k"
END
call writefile(lines, 'XSmoothScrollCursorTop', 'D')
- let buf = RunVimInTerminal('-u NONE -S XSmoothScrollCursorTop', #{rows: 12, cols:40})
+ let buf = RunVimInTerminal('-u NONE -S XSmoothScrollCursorTop', #{rows: 12, cols: 40})
call VerifyScreenDump(buf, 'Test_smoothscroll_cursor_top', {})
call StopVimInTerminal(buf)
@@ -942,10 +942,25 @@ func Test_smoothscroll_crash()
exe "norm! 0\<c-e>"
END
call writefile(lines, 'XSmoothScrollCrash', 'D')
- let buf = RunVimInTerminal('-u NONE -S XSmoothScrollCrash', #{rows: 12, cols:40})
+ let buf = RunVimInTerminal('-u NONE -S XSmoothScrollCrash', #{rows: 12, cols: 40})
call term_sendkeys(buf, "2\<C-E>\<C-L>")
call StopVimInTerminal(buf)
endfunc
+func Test_smoothscroll_insert_bottom()
+ CheckScreendump
+
+ let lines =<< trim END
+ call setline(1, repeat([repeat('A very long line ...', 10)], 5))
+ set wrap smoothscroll scrolloff=0
+ END
+ call writefile(lines, 'XSmoothScrollInsertBottom', 'D')
+ let buf = RunVimInTerminal('-u NONE -S XSmoothScrollInsertBottom', #{rows: 9, cols: 40})
+ call term_sendkeys(buf, "Go123456789\<CR>")
+ call VerifyScreenDump(buf, 'Test_smoothscroll_insert_bottom', {})
+
+ call StopVimInTerminal(buf)
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_syntax.vim b/test/old/testdir/test_syntax.vim
index 76a21adc57..10dc798df7 100644
--- a/test/old/testdir/test_syntax.vim
+++ b/test/old/testdir/test_syntax.vim
@@ -214,7 +214,7 @@ endfunc
func Test_echohl_completion()
call feedkeys(":echohl no\<C-A>\<C-B>\"\<CR>", 'tx')
" call assert_equal('"echohl NonText Normal none', @:)
- call assert_equal('"echohl NonText Normal NormalFloat none', @:)
+ call assert_equal('"echohl NonText Normal NormalFloat NormalNC none', @:)
endfunc
func Test_syntax_arg_skipped()
diff --git a/test/unit/api/helpers.lua b/test/unit/api/helpers.lua
index 3d306d2b1b..23c5db43f7 100644
--- a/test/unit/api/helpers.lua
+++ b/test/unit/api/helpers.lua
@@ -13,9 +13,11 @@ local int_type = eval_helpers.int_type
local flt_type = eval_helpers.flt_type
local type_key = eval_helpers.type_key
-local api = cimport('./src/nvim/api/private/defs.h',
- './src/nvim/api/private/helpers.h',
- './src/nvim/memory.h')
+local api = cimport(
+ './src/nvim/api/private/defs.h',
+ './src/nvim/api/private/helpers.h',
+ './src/nvim/memory.h'
+)
local obj2lua
@@ -27,8 +29,8 @@ local function init_obj2lua_tab()
end
obj2lua_tab = {
[tonumber(api.kObjectTypeArray)] = function(obj)
- local ret = {[type_key]=list_type}
- for i = 1,tonumber(obj.data.array.size) do
+ local ret = { [type_key] = list_type }
+ for i = 1, tonumber(obj.data.array.size) do
ret[i] = obj2lua(obj.data.array.items[i - 1])
end
if ret[1] then
@@ -38,7 +40,7 @@ local function init_obj2lua_tab()
end,
[tonumber(api.kObjectTypeDictionary)] = function(obj)
local ret = {}
- for i = 1,tonumber(obj.data.dictionary.size) do
+ for i = 1, tonumber(obj.data.dictionary.size) do
local kv_pair = obj.data.dictionary.items[i - 1]
ret[ffi.string(kv_pair.key.data, kv_pair.key.size)] = obj2lua(kv_pair.value)
end
@@ -58,7 +60,7 @@ local function init_obj2lua_tab()
return tonumber(obj.data.floating)
end,
[tonumber(api.kObjectTypeInteger)] = function(obj)
- return {[type_key]=int_type, value=tonumber(obj.data.integer)}
+ return { [type_key] = int_type, value = tonumber(obj.data.integer) }
end,
[tonumber(api.kObjectTypeString)] = function(obj)
return ffi.string(obj.data.string.data, obj.data.string.size)
@@ -68,32 +70,38 @@ end
obj2lua = function(obj)
init_obj2lua_tab()
- return ((obj2lua_tab[tonumber(obj['type'])] or function(obj_inner)
- assert(false, 'Converting ' .. tostring(tonumber(obj_inner['type'])) .. ' is not implementing yet')
- end)(obj))
+ return (
+ (obj2lua_tab[tonumber(obj['type'])] or function(obj_inner)
+ assert(
+ false,
+ 'Converting ' .. tostring(tonumber(obj_inner['type'])) .. ' is not implementing yet'
+ )
+ end)(obj)
+ )
end
local obj = function(typ, data)
- return ffi.gc(ffi.new('Object', {['type']=typ, data=data}),
- api.api_free_object)
+ return ffi.gc(ffi.new('Object', { ['type'] = typ, data = data }), api.api_free_object)
end
local lua2obj
local lua2obj_type_tab = {
[int_type] = function(l)
- return obj(api.kObjectTypeInteger, {integer=l.value})
+ return obj(api.kObjectTypeInteger, { integer = l.value })
end,
[flt_type] = function(l)
- return obj(api.kObjectTypeFloat, {floating=l})
+ return obj(api.kObjectTypeFloat, { floating = l })
end,
[list_type] = function(l)
local len = #l
- local arr = obj(api.kObjectTypeArray, {array={
- size=len,
- capacity=len,
- items=ffi.cast('Object *', api.xmalloc(len * ffi.sizeof('Object'))),
- }})
+ local arr = obj(api.kObjectTypeArray, {
+ array = {
+ size = len,
+ capacity = len,
+ items = ffi.cast('Object *', api.xmalloc(len * ffi.sizeof('Object'))),
+ },
+ })
for i = 1, len do
arr.data.array.items[i - 1] = ffi.gc(lua2obj(l[i]), nil)
end
@@ -103,21 +111,23 @@ local lua2obj_type_tab = {
local kvs = {}
for k, v in pairs(l) do
if type(k) == 'string' then
- kvs[#kvs + 1] = {k, v}
+ kvs[#kvs + 1] = { k, v }
end
end
local len = #kvs
- local dct = obj(api.kObjectTypeDictionary, {dictionary={
- size=len,
- capacity=len,
- items=ffi.cast('KeyValuePair *',
- api.xmalloc(len * ffi.sizeof('KeyValuePair'))),
- }})
+ local dct = obj(api.kObjectTypeDictionary, {
+ dictionary = {
+ size = len,
+ capacity = len,
+ items = ffi.cast('KeyValuePair *', api.xmalloc(len * ffi.sizeof('KeyValuePair'))),
+ },
+ })
for i = 1, len do
local key, val = unpack(kvs[i])
dct.data.dictionary.items[i - 1] = ffi.new(
- 'KeyValuePair', {key=ffi.gc(lua2obj(key), nil).data.string,
- value=ffi.gc(lua2obj(val), nil)})
+ 'KeyValuePair',
+ { key = ffi.gc(lua2obj(key), nil).data.string, value = ffi.gc(lua2obj(val), nil) }
+ )
end
return dct
end,
@@ -137,28 +147,31 @@ lua2obj = function(l)
elseif type(l) == 'number' then
return lua2obj_type_tab[flt_type](l)
elseif type(l) == 'boolean' then
- return obj(api.kObjectTypeBoolean, {boolean=l})
+ return obj(api.kObjectTypeBoolean, { boolean = l })
elseif type(l) == 'string' then
- return obj(api.kObjectTypeString, {string={
- size=#l,
- data=api.xmemdupz(to_cstr(l), #l),
- }})
+ return obj(
+ api.kObjectTypeString,
+ { string = {
+ size = #l,
+ data = api.xmemdupz(to_cstr(l), #l),
+ } }
+ )
elseif l == nil or l == nil_value then
- return obj(api.kObjectTypeNil, {integer=0})
+ return obj(api.kObjectTypeNil, { integer = 0 })
end
end
return {
- list_type=list_type,
- dict_type=dict_type,
- func_type=func_type,
- int_type=int_type,
- flt_type=flt_type,
+ list_type = list_type,
+ dict_type = dict_type,
+ func_type = func_type,
+ int_type = int_type,
+ flt_type = flt_type,
- nil_value=nil_value,
+ nil_value = nil_value,
- type_key=type_key,
+ type_key = type_key,
- obj2lua=obj2lua,
- lua2obj=lua2obj,
+ obj2lua = obj2lua,
+ lua2obj = lua2obj,
}
diff --git a/test/unit/api/private_helpers_spec.lua b/test/unit/api/private_helpers_spec.lua
index dbb4b3ae5a..80ca9ddc5b 100644
--- a/test/unit/api/private_helpers_spec.lua
+++ b/test/unit/api/private_helpers_spec.lua
@@ -42,49 +42,61 @@ describe('vim_to_object', function()
simple_test('converts -1.5', -1.5)
simple_test('converts empty string', '')
simple_test('converts non-empty string', 'foobar')
- simple_test('converts integer 10', {[type_key]=int_type, value=10})
+ simple_test('converts integer 10', { [type_key] = int_type, value = 10 })
simple_test('converts empty dictionary', {})
- simple_test('converts dictionary with scalar values', {test=10, test2=true, test3='test'})
- simple_test('converts dictionary with containers inside', {test={}, test2={1, 2}})
- simple_test('converts empty list', {[type_key]=list_type})
- simple_test('converts list with scalar values', {1, 2, 'test', 'foo'})
- simple_test('converts list with containers inside', {{}, {test={}, test3={test4=true}}})
+ simple_test('converts dictionary with scalar values', { test = 10, test2 = true, test3 = 'test' })
+ simple_test('converts dictionary with containers inside', { test = {}, test2 = { 1, 2 } })
+ simple_test('converts empty list', { [type_key] = list_type })
+ simple_test('converts list with scalar values', { 1, 2, 'test', 'foo' })
+ simple_test(
+ 'converts list with containers inside',
+ { {}, { test = {}, test3 = { test4 = true } } }
+ )
local dct = {}
dct.dct = dct
- different_output_test('outputs nil for nested dictionaries (1 level)', dct, {dct=nil_value})
+ different_output_test('outputs nil for nested dictionaries (1 level)', dct, { dct = nil_value })
local lst = {}
lst[1] = lst
- different_output_test('outputs nil for nested lists (1 level)', lst, {nil_value})
-
- local dct2 = {test=true, dict=nil_value}
- dct2.dct = {dct2}
- different_output_test('outputs nil for nested dictionaries (2 level, in list)',
- dct2, {dct={nil_value}, test=true, dict=nil_value})
-
- local dct3 = {test=true, dict=nil_value}
- dct3.dct = {dctin=dct3}
- different_output_test('outputs nil for nested dictionaries (2 level, in dict)',
- dct3, {dct={dctin=nil_value}, test=true, dict=nil_value})
+ different_output_test('outputs nil for nested lists (1 level)', lst, { nil_value })
+
+ local dct2 = { test = true, dict = nil_value }
+ dct2.dct = { dct2 }
+ different_output_test(
+ 'outputs nil for nested dictionaries (2 level, in list)',
+ dct2,
+ { dct = { nil_value }, test = true, dict = nil_value }
+ )
+
+ local dct3 = { test = true, dict = nil_value }
+ dct3.dct = { dctin = dct3 }
+ different_output_test(
+ 'outputs nil for nested dictionaries (2 level, in dict)',
+ dct3,
+ { dct = { dctin = nil_value }, test = true, dict = nil_value }
+ )
local lst2 = {}
- lst2[1] = {lst2}
- different_output_test('outputs nil for nested lists (2 level, in list)', lst2, {{nil_value}})
+ lst2[1] = { lst2 }
+ different_output_test('outputs nil for nested lists (2 level, in list)', lst2, { { nil_value } })
- local lst3 = {nil, true, false, 'ttest'}
- lst3[1] = {lst=lst3}
- different_output_test('outputs nil for nested lists (2 level, in dict)',
- lst3, {{lst=nil_value}, true, false, 'ttest'})
+ local lst3 = { nil, true, false, 'ttest' }
+ lst3[1] = { lst = lst3 }
+ different_output_test(
+ 'outputs nil for nested lists (2 level, in dict)',
+ lst3,
+ { { lst = nil_value }, true, false, 'ttest' }
+ )
itp('outputs empty list for NULL list', function()
- local tt = typvalt('VAR_LIST', {v_list=NULL})
+ local tt = typvalt('VAR_LIST', { v_list = NULL })
eq(nil, tt.vval.v_list)
- eq({[type_key]=list_type}, obj2lua(api.vim_to_object(tt)))
+ eq({ [type_key] = list_type }, obj2lua(api.vim_to_object(tt)))
end)
itp('outputs empty dict for NULL dict', function()
- local tt = typvalt('VAR_DICT', {v_dict=NULL})
+ local tt = typvalt('VAR_DICT', { v_dict = NULL })
eq(nil, tt.vval.v_dict)
eq({}, obj2lua(api.vim_to_object(tt)))
end)
@@ -92,15 +104,15 @@ describe('vim_to_object', function()
itp('regression: partials in a list', function()
local llist = {
{
- [type_key]=func_type,
- value='printf',
- args={'%s'},
- dict={v=1},
+ [type_key] = func_type,
+ value = 'printf',
+ args = { '%s' },
+ dict = { v = 1 },
},
{},
}
local list = lua2typvalt(llist)
eq(llist, typvalt2lua(list))
- eq({nil_value, {}}, obj2lua(api.vim_to_object(list)))
+ eq({ nil_value, {} }, obj2lua(api.vim_to_object(list)))
end)
end)
diff --git a/test/unit/buffer_spec.lua b/test/unit/buffer_spec.lua
index 6e08a09295..1ef3e97165 100644
--- a/test/unit/buffer_spec.lua
+++ b/test/unit/buffer_spec.lua
@@ -1,14 +1,13 @@
-local helpers = require("test.unit.helpers")(after_each)
+local helpers = require('test.unit.helpers')(after_each)
local itp = helpers.gen_itp(it)
local to_cstr = helpers.to_cstr
-local eq = helpers.eq
-local NULL = helpers.NULL
+local eq = helpers.eq
+local NULL = helpers.NULL
-local buffer = helpers.cimport("./src/nvim/buffer.h")
+local buffer = helpers.cimport('./src/nvim/buffer.h')
describe('buffer functions', function()
-
local buflist_new = function(file, flags)
local c_file = to_cstr(file)
return buffer.buflist_new(c_file, c_file, 1, flags)
@@ -36,7 +35,6 @@ describe('buffer functions', function()
end)
describe('buf_valid', function()
-
itp('should view NULL as an invalid buffer', function()
eq(false, buffer.buf_valid(NULL))
end)
@@ -72,11 +70,9 @@ describe('buffer functions', function()
end)
end)
-
describe('buflist_findpat', function()
-
local ALLOW_UNLISTED = 1
- local ONLY_LISTED = 0
+ local ONLY_LISTED = 0
local buflist_findpat = function(pat, allow_unlisted)
return buffer.buflist_findpat(to_cstr(pat), NULL, allow_unlisted, 0, 0)
@@ -95,9 +91,9 @@ describe('buffer functions', function()
local buf2 = buflist_new(path2, buffer.BLN_LISTED)
local buf3 = buflist_new(path3, buffer.BLN_LISTED)
- eq(buf1.handle, buflist_findpat("test", ONLY_LISTED))
- eq(buf2.handle, buflist_findpat("file", ONLY_LISTED))
- eq(buf3.handle, buflist_findpat("path", ONLY_LISTED))
+ eq(buf1.handle, buflist_findpat('test', ONLY_LISTED))
+ eq(buf2.handle, buflist_findpat('file', ONLY_LISTED))
+ eq(buf3.handle, buflist_findpat('path', ONLY_LISTED))
close_buffer(NULL, buf1, buffer.DOBUF_WIPE, 0, 0)
close_buffer(NULL, buf2, buffer.DOBUF_WIPE, 0, 0)
@@ -111,7 +107,7 @@ describe('buffer functions', function()
local buf3 = buflist_new(path3, buffer.BLN_LISTED)
-- Then: buf2 is the buffer that is found
- eq(buf2.handle, buflist_findpat("test", ONLY_LISTED))
+ eq(buf2.handle, buflist_findpat('test', ONLY_LISTED))
--}
--{ When: We close buf2
@@ -121,7 +117,7 @@ describe('buffer functions', function()
local buf1 = buflist_new(path1, buffer.BLN_LISTED)
-- Then: buf3 is found since 'file' appears at the end of the name
- eq(buf3.handle, buflist_findpat("file", ONLY_LISTED))
+ eq(buf3.handle, buflist_findpat('file', ONLY_LISTED))
--}
close_buffer(NULL, buf1, buffer.DOBUF_WIPE, 0, 0)
@@ -133,7 +129,7 @@ describe('buffer functions', function()
local buf2 = buflist_new(path2, buffer.BLN_LISTED)
local buf3 = buflist_new(path3, buffer.BLN_LISTED)
- eq(buf3.handle, buflist_findpat("_test_", ONLY_LISTED))
+ eq(buf3.handle, buflist_findpat('_test_', ONLY_LISTED))
close_buffer(NULL, buf1, buffer.DOBUF_WIPE, 0, 0)
close_buffer(NULL, buf2, buffer.DOBUF_WIPE, 0, 0)
@@ -145,25 +141,25 @@ describe('buffer functions', function()
local buf3 = buflist_new(path3, buffer.BLN_LISTED)
-- Then: We should find the buffer when it is given a unique pattern
- eq(buf3.handle, buflist_findpat("_test_", ONLY_LISTED))
+ eq(buf3.handle, buflist_findpat('_test_', ONLY_LISTED))
--}
--{ When: We unlist the buffer
close_buffer(NULL, buf3, buffer.DOBUF_DEL, 0, 0)
-- Then: It should not find the buffer when searching only listed buffers
- eq(-1, buflist_findpat("_test_", ONLY_LISTED))
+ eq(-1, buflist_findpat('_test_', ONLY_LISTED))
-- And: It should find the buffer when including unlisted buffers
- eq(buf3.handle, buflist_findpat("_test_", ALLOW_UNLISTED))
+ eq(buf3.handle, buflist_findpat('_test_', ALLOW_UNLISTED))
--}
--{ When: We wipe the buffer
close_buffer(NULL, buf3, buffer.DOBUF_WIPE, 0, 0)
-- Then: It should not find the buffer at all
- eq(-1, buflist_findpat("_test_", ONLY_LISTED))
- eq(-1, buflist_findpat("_test_", ALLOW_UNLISTED))
+ eq(-1, buflist_findpat('_test_', ONLY_LISTED))
+ eq(-1, buflist_findpat('_test_', ALLOW_UNLISTED))
--}
end)
@@ -173,7 +169,7 @@ describe('buffer functions', function()
local buf2 = buflist_new(path2, buffer.BLN_LISTED)
-- Then: The first buffer is preferred when both are listed
- eq(buf1.handle, buflist_findpat("test", ONLY_LISTED))
+ eq(buf1.handle, buflist_findpat('test', ONLY_LISTED))
--}
--{ When: The first buffer is unlisted
@@ -181,13 +177,13 @@ describe('buffer functions', function()
-- Then: The second buffer is preferred because
-- unlisted buffers are not allowed
- eq(buf2.handle, buflist_findpat("test", ONLY_LISTED))
+ eq(buf2.handle, buflist_findpat('test', ONLY_LISTED))
--}
--{ When: We allow unlisted buffers
-- Then: The second buffer is still preferred
-- because listed buffers are preferred to unlisted
- eq(buf2.handle, buflist_findpat("test", ALLOW_UNLISTED))
+ eq(buf2.handle, buflist_findpat('test', ALLOW_UNLISTED))
--}
--{ When: We unlist the second buffer
@@ -196,10 +192,10 @@ describe('buffer functions', function()
-- Then: The first buffer is preferred again
-- because buf1 matches better which takes precedence
-- when both buffers have the same listing status.
- eq(buf1.handle, buflist_findpat("test", ALLOW_UNLISTED))
+ eq(buf1.handle, buflist_findpat('test', ALLOW_UNLISTED))
-- And: Neither buffer is returned when ignoring unlisted
- eq(-1, buflist_findpat("test", ONLY_LISTED))
+ eq(-1, buflist_findpat('test', ONLY_LISTED))
--}
close_buffer(NULL, buf1, buffer.DOBUF_WIPE, 0, 0)
diff --git a/test/unit/charset/vim_str2nr_spec.lua b/test/unit/charset/vim_str2nr_spec.lua
index fc40fa39d4..ad87d026e5 100644
--- a/test/unit/charset/vim_str2nr_spec.lua
+++ b/test/unit/charset/vim_str2nr_spec.lua
@@ -1,4 +1,4 @@
-local helpers = require("test.unit.helpers")(after_each)
+local helpers = require('test.unit.helpers')(after_each)
local bit = require('bit')
local itp = helpers.gen_itp(it)
@@ -26,10 +26,10 @@ local ucnt = 4242
local function arginit(arg)
if arg == 'unum' then
ucnt = ucnt + 1
- return ARGTYPES[arg]({ucnt})
+ return ARGTYPES[arg]({ ucnt })
else
icnt = icnt - 1
- return ARGTYPES[arg]({icnt})
+ return ARGTYPES[arg]({ icnt })
end
end
@@ -44,7 +44,9 @@ local function argreset(arg, args)
end
local function test_vim_str2nr(s, what, exp, maxlen, strict)
- if strict == nil then strict = true end
+ if strict == nil then
+ strict = true
+ end
local bits = {}
for k, _ in pairs(exp) do
bits[#bits + 1] = k
@@ -54,7 +56,7 @@ local function test_vim_str2nr(s, what, exp, maxlen, strict)
for k, _ in pairs(ARGTYPES) do
args[k] = arginit(k)
end
- for case = 0, ((2 ^ (#bits)) - 1) do
+ for case = 0, ((2 ^ #bits) - 1) do
local cv = {}
for b = 0, (#bits - 1) do
if bit.band(case, (2 ^ b)) == 0 then
@@ -66,9 +68,17 @@ local function test_vim_str2nr(s, what, exp, maxlen, strict)
lib.vim_str2nr(s, cv.pre, cv.len, what, cv.num, cv.unum, maxlen, strict, nil)
for cck, ccv in pairs(cv) do
if exp[cck] ~= tonumber(ccv[0]) then
- error(('Failed check (%s = %d) in test (s=%s, w=%u, m=%d, strict=%s): %d'):format(
- cck, exp[cck], s, tonumber(what), maxlen, tostring(strict), tonumber(ccv[0])
- ))
+ error(
+ ('Failed check (%s = %d) in test (s=%s, w=%u, m=%d, strict=%s): %d'):format(
+ cck,
+ exp[cck],
+ s,
+ tonumber(what),
+ maxlen,
+ tostring(strict),
+ tonumber(ccv[0])
+ )
+ )
end
end
end
@@ -82,18 +92,48 @@ end
describe('vim_str2nr()', function()
itp('works fine when it has nothing to do', function()
- test_vim_str2nr('', 0, {len = 0, num = 0, unum = 0, pre = 0}, 0)
- test_vim_str2nr('', lib.STR2NR_ALL, {len = 0, num = 0, unum = 0, pre = 0}, 0)
- test_vim_str2nr('', lib.STR2NR_BIN, {len = 0, num = 0, unum = 0, pre = 0}, 0)
- test_vim_str2nr('', lib.STR2NR_OCT, {len = 0, num = 0, unum = 0, pre = 0}, 0)
- test_vim_str2nr('', lib.STR2NR_OOCT, {len = 0, num = 0, unum = 0, pre = 0}, 0)
- test_vim_str2nr('', lib.STR2NR_HEX, {len = 0, num = 0, unum = 0, pre = 0}, 0)
- test_vim_str2nr('', lib.STR2NR_FORCE + lib.STR2NR_DEC, {len = 0, num = 0, unum = 0, pre = 0}, 0)
- test_vim_str2nr('', lib.STR2NR_FORCE + lib.STR2NR_BIN, {len = 0, num = 0, unum = 0, pre = 0}, 0)
- test_vim_str2nr('', lib.STR2NR_FORCE + lib.STR2NR_OCT, {len = 0, num = 0, unum = 0, pre = 0}, 0)
- test_vim_str2nr('', lib.STR2NR_FORCE + lib.STR2NR_OOCT, {len = 0, num = 0, unum = 0, pre = 0}, 0)
- test_vim_str2nr('', lib.STR2NR_FORCE + lib.STR2NR_OCT + lib.STR2NR_OOCT, {len = 0, num = 0, unum = 0, pre = 0}, 0)
- test_vim_str2nr('', lib.STR2NR_FORCE + lib.STR2NR_HEX, {len = 0, num = 0, unum = 0, pre = 0}, 0)
+ test_vim_str2nr('', 0, { len = 0, num = 0, unum = 0, pre = 0 }, 0)
+ test_vim_str2nr('', lib.STR2NR_ALL, { len = 0, num = 0, unum = 0, pre = 0 }, 0)
+ test_vim_str2nr('', lib.STR2NR_BIN, { len = 0, num = 0, unum = 0, pre = 0 }, 0)
+ test_vim_str2nr('', lib.STR2NR_OCT, { len = 0, num = 0, unum = 0, pre = 0 }, 0)
+ test_vim_str2nr('', lib.STR2NR_OOCT, { len = 0, num = 0, unum = 0, pre = 0 }, 0)
+ test_vim_str2nr('', lib.STR2NR_HEX, { len = 0, num = 0, unum = 0, pre = 0 }, 0)
+ test_vim_str2nr(
+ '',
+ lib.STR2NR_FORCE + lib.STR2NR_DEC,
+ { len = 0, num = 0, unum = 0, pre = 0 },
+ 0
+ )
+ test_vim_str2nr(
+ '',
+ lib.STR2NR_FORCE + lib.STR2NR_BIN,
+ { len = 0, num = 0, unum = 0, pre = 0 },
+ 0
+ )
+ test_vim_str2nr(
+ '',
+ lib.STR2NR_FORCE + lib.STR2NR_OCT,
+ { len = 0, num = 0, unum = 0, pre = 0 },
+ 0
+ )
+ test_vim_str2nr(
+ '',
+ lib.STR2NR_FORCE + lib.STR2NR_OOCT,
+ { len = 0, num = 0, unum = 0, pre = 0 },
+ 0
+ )
+ test_vim_str2nr(
+ '',
+ lib.STR2NR_FORCE + lib.STR2NR_OCT + lib.STR2NR_OOCT,
+ { len = 0, num = 0, unum = 0, pre = 0 },
+ 0
+ )
+ test_vim_str2nr(
+ '',
+ lib.STR2NR_FORCE + lib.STR2NR_HEX,
+ { len = 0, num = 0, unum = 0, pre = 0 },
+ 0
+ )
end)
itp('works with decimal numbers', function()
for _, flags in ipairs({
@@ -110,30 +150,30 @@ describe('vim_str2nr()', function()
lib.STR2NR_FORCE + lib.STR2NR_DEC,
}) do
-- Check that all digits are recognized
- test_vim_str2nr( '12345', flags, {len = 5, num = 12345, unum = 12345, pre = 0}, 0)
- test_vim_str2nr( '67890', flags, {len = 5, num = 67890, unum = 67890, pre = 0}, 0)
- test_vim_str2nr( '12345A', flags, {len = 0}, 0)
- test_vim_str2nr( '67890A', flags, {len = 0}, 0)
- test_vim_str2nr( '12345A', flags, {len = 5, num = 12345, unum = 12345, pre = 0}, 0, false)
- test_vim_str2nr( '67890A', flags, {len = 5, num = 67890, unum = 67890, pre = 0}, 0, false)
-
- test_vim_str2nr( '42', flags, {len = 2, num = 42, unum = 42, pre = 0}, 0)
- test_vim_str2nr( '42', flags, {len = 1, num = 4, unum = 4, pre = 0}, 1)
- test_vim_str2nr( '42', flags, {len = 2, num = 42, unum = 42, pre = 0}, 2)
- test_vim_str2nr( '42', flags, {len = 2, num = 42, unum = 42, pre = 0}, 3) -- includes NUL byte in maxlen
-
- test_vim_str2nr( '42x', flags, {len = 0}, 0)
- test_vim_str2nr( '42x', flags, {len = 0}, 3)
- test_vim_str2nr( '42x', flags, {len = 2, num = 42, unum = 42, pre = 0}, 0, false)
- test_vim_str2nr( '42x', flags, {len = 2, num = 42, unum = 42, pre = 0}, 3, false)
-
- test_vim_str2nr('-42', flags, {len = 3, num = -42, unum = 42, pre = 0}, 3)
- test_vim_str2nr('-42', flags, {len = 1, num = 0, unum = 0, pre = 0}, 1)
-
- test_vim_str2nr('-42x', flags, {len = 0}, 0)
- test_vim_str2nr('-42x', flags, {len = 0}, 4)
- test_vim_str2nr('-42x', flags, {len = 3, num = -42, unum = 42, pre = 0}, 0, false)
- test_vim_str2nr('-42x', flags, {len = 3, num = -42, unum = 42, pre = 0}, 4, false)
+ test_vim_str2nr('12345', flags, { len = 5, num = 12345, unum = 12345, pre = 0 }, 0)
+ test_vim_str2nr('67890', flags, { len = 5, num = 67890, unum = 67890, pre = 0 }, 0)
+ test_vim_str2nr('12345A', flags, { len = 0 }, 0)
+ test_vim_str2nr('67890A', flags, { len = 0 }, 0)
+ test_vim_str2nr('12345A', flags, { len = 5, num = 12345, unum = 12345, pre = 0 }, 0, false)
+ test_vim_str2nr('67890A', flags, { len = 5, num = 67890, unum = 67890, pre = 0 }, 0, false)
+
+ test_vim_str2nr('42', flags, { len = 2, num = 42, unum = 42, pre = 0 }, 0)
+ test_vim_str2nr('42', flags, { len = 1, num = 4, unum = 4, pre = 0 }, 1)
+ test_vim_str2nr('42', flags, { len = 2, num = 42, unum = 42, pre = 0 }, 2)
+ test_vim_str2nr('42', flags, { len = 2, num = 42, unum = 42, pre = 0 }, 3) -- includes NUL byte in maxlen
+
+ test_vim_str2nr('42x', flags, { len = 0 }, 0)
+ test_vim_str2nr('42x', flags, { len = 0 }, 3)
+ test_vim_str2nr('42x', flags, { len = 2, num = 42, unum = 42, pre = 0 }, 0, false)
+ test_vim_str2nr('42x', flags, { len = 2, num = 42, unum = 42, pre = 0 }, 3, false)
+
+ test_vim_str2nr('-42', flags, { len = 3, num = -42, unum = 42, pre = 0 }, 3)
+ test_vim_str2nr('-42', flags, { len = 1, num = 0, unum = 0, pre = 0 }, 1)
+
+ test_vim_str2nr('-42x', flags, { len = 0 }, 0)
+ test_vim_str2nr('-42x', flags, { len = 0 }, 4)
+ test_vim_str2nr('-42x', flags, { len = 3, num = -42, unum = 42, pre = 0 }, 0, false)
+ test_vim_str2nr('-42x', flags, { len = 3, num = -42, unum = 42, pre = 0 }, 4, false)
end
end)
itp('works with binary numbers', function()
@@ -154,66 +194,66 @@ describe('vim_str2nr()', function()
BIN = ('B'):byte()
end
- test_vim_str2nr( '0b101', flags, {len = 5, num = 5, unum = 5, pre = bin}, 0)
- test_vim_str2nr( '0b101', flags, {len = 1, num = 0, unum = 0, pre = 0 }, 1)
- test_vim_str2nr( '0b101', flags, {len = 0}, 2)
- test_vim_str2nr( '0b101', flags, {len = 1, num = 0, unum = 0, pre = 0 }, 2, false)
- test_vim_str2nr( '0b101', flags, {len = 3, num = 1, unum = 1, pre = bin}, 3)
- test_vim_str2nr( '0b101', flags, {len = 4, num = 2, unum = 2, pre = bin}, 4)
- test_vim_str2nr( '0b101', flags, {len = 5, num = 5, unum = 5, pre = bin}, 5)
- test_vim_str2nr( '0b101', flags, {len = 5, num = 5, unum = 5, pre = bin}, 6)
-
- test_vim_str2nr( '0b1012', flags, {len = 0}, 0)
- test_vim_str2nr( '0b1012', flags, {len = 0}, 6)
- test_vim_str2nr( '0b1012', flags, {len = 5, num = 5, unum = 5, pre = bin}, 0, false)
- test_vim_str2nr( '0b1012', flags, {len = 5, num = 5, unum = 5, pre = bin}, 6, false)
-
- test_vim_str2nr('-0b101', flags, {len = 6, num = -5, unum = 5, pre = bin}, 0)
- test_vim_str2nr('-0b101', flags, {len = 1, num = 0, unum = 0, pre = 0 }, 1)
- test_vim_str2nr('-0b101', flags, {len = 2, num = 0, unum = 0, pre = 0 }, 2)
- test_vim_str2nr('-0b101', flags, {len = 0}, 3)
- test_vim_str2nr('-0b101', flags, {len = 2, num = 0, unum = 0, pre = 0 }, 3, false)
- test_vim_str2nr('-0b101', flags, {len = 4, num = -1, unum = 1, pre = bin}, 4)
- test_vim_str2nr('-0b101', flags, {len = 5, num = -2, unum = 2, pre = bin}, 5)
- test_vim_str2nr('-0b101', flags, {len = 6, num = -5, unum = 5, pre = bin}, 6)
- test_vim_str2nr('-0b101', flags, {len = 6, num = -5, unum = 5, pre = bin}, 7)
-
- test_vim_str2nr('-0b1012', flags, {len = 0}, 0)
- test_vim_str2nr('-0b1012', flags, {len = 0}, 7)
- test_vim_str2nr('-0b1012', flags, {len = 6, num = -5, unum = 5, pre = bin}, 0, false)
- test_vim_str2nr('-0b1012', flags, {len = 6, num = -5, unum = 5, pre = bin}, 7, false)
-
- test_vim_str2nr( '0B101', flags, {len = 5, num = 5, unum = 5, pre = BIN}, 0)
- test_vim_str2nr( '0B101', flags, {len = 1, num = 0, unum = 0, pre = 0 }, 1)
- test_vim_str2nr( '0B101', flags, {len = 0}, 2)
- test_vim_str2nr( '0B101', flags, {len = 1, num = 0, unum = 0, pre = 0 }, 2, false)
- test_vim_str2nr( '0B101', flags, {len = 3, num = 1, unum = 1, pre = BIN}, 3)
- test_vim_str2nr( '0B101', flags, {len = 4, num = 2, unum = 2, pre = BIN}, 4)
- test_vim_str2nr( '0B101', flags, {len = 5, num = 5, unum = 5, pre = BIN}, 5)
- test_vim_str2nr( '0B101', flags, {len = 5, num = 5, unum = 5, pre = BIN}, 6)
-
- test_vim_str2nr( '0B1012', flags, {len = 0}, 0)
- test_vim_str2nr( '0B1012', flags, {len = 0}, 6)
- test_vim_str2nr( '0B1012', flags, {len = 5, num = 5, unum = 5, pre = BIN}, 0, false)
- test_vim_str2nr( '0B1012', flags, {len = 5, num = 5, unum = 5, pre = BIN}, 6, false)
-
- test_vim_str2nr('-0B101', flags, {len = 6, num = -5, unum = 5, pre = BIN}, 0)
- test_vim_str2nr('-0B101', flags, {len = 1, num = 0, unum = 0, pre = 0 }, 1)
- test_vim_str2nr('-0B101', flags, {len = 2, num = 0, unum = 0, pre = 0 }, 2)
- test_vim_str2nr('-0B101', flags, {len = 0}, 3)
- test_vim_str2nr('-0B101', flags, {len = 2, num = 0, unum = 0, pre = 0 }, 3, false)
- test_vim_str2nr('-0B101', flags, {len = 4, num = -1, unum = 1, pre = BIN}, 4)
- test_vim_str2nr('-0B101', flags, {len = 5, num = -2, unum = 2, pre = BIN}, 5)
- test_vim_str2nr('-0B101', flags, {len = 6, num = -5, unum = 5, pre = BIN}, 6)
- test_vim_str2nr('-0B101', flags, {len = 6, num = -5, unum = 5, pre = BIN}, 7)
-
- test_vim_str2nr('-0B1012', flags, {len = 0}, 0)
- test_vim_str2nr('-0B1012', flags, {len = 0}, 7)
- test_vim_str2nr('-0B1012', flags, {len = 6, num = -5, unum = 5, pre = BIN}, 0, false)
- test_vim_str2nr('-0B1012', flags, {len = 6, num = -5, unum = 5, pre = BIN}, 7, false)
+ test_vim_str2nr('0b101', flags, { len = 5, num = 5, unum = 5, pre = bin }, 0)
+ test_vim_str2nr('0b101', flags, { len = 1, num = 0, unum = 0, pre = 0 }, 1)
+ test_vim_str2nr('0b101', flags, { len = 0 }, 2)
+ test_vim_str2nr('0b101', flags, { len = 1, num = 0, unum = 0, pre = 0 }, 2, false)
+ test_vim_str2nr('0b101', flags, { len = 3, num = 1, unum = 1, pre = bin }, 3)
+ test_vim_str2nr('0b101', flags, { len = 4, num = 2, unum = 2, pre = bin }, 4)
+ test_vim_str2nr('0b101', flags, { len = 5, num = 5, unum = 5, pre = bin }, 5)
+ test_vim_str2nr('0b101', flags, { len = 5, num = 5, unum = 5, pre = bin }, 6)
+
+ test_vim_str2nr('0b1012', flags, { len = 0 }, 0)
+ test_vim_str2nr('0b1012', flags, { len = 0 }, 6)
+ test_vim_str2nr('0b1012', flags, { len = 5, num = 5, unum = 5, pre = bin }, 0, false)
+ test_vim_str2nr('0b1012', flags, { len = 5, num = 5, unum = 5, pre = bin }, 6, false)
+
+ test_vim_str2nr('-0b101', flags, { len = 6, num = -5, unum = 5, pre = bin }, 0)
+ test_vim_str2nr('-0b101', flags, { len = 1, num = 0, unum = 0, pre = 0 }, 1)
+ test_vim_str2nr('-0b101', flags, { len = 2, num = 0, unum = 0, pre = 0 }, 2)
+ test_vim_str2nr('-0b101', flags, { len = 0 }, 3)
+ test_vim_str2nr('-0b101', flags, { len = 2, num = 0, unum = 0, pre = 0 }, 3, false)
+ test_vim_str2nr('-0b101', flags, { len = 4, num = -1, unum = 1, pre = bin }, 4)
+ test_vim_str2nr('-0b101', flags, { len = 5, num = -2, unum = 2, pre = bin }, 5)
+ test_vim_str2nr('-0b101', flags, { len = 6, num = -5, unum = 5, pre = bin }, 6)
+ test_vim_str2nr('-0b101', flags, { len = 6, num = -5, unum = 5, pre = bin }, 7)
+
+ test_vim_str2nr('-0b1012', flags, { len = 0 }, 0)
+ test_vim_str2nr('-0b1012', flags, { len = 0 }, 7)
+ test_vim_str2nr('-0b1012', flags, { len = 6, num = -5, unum = 5, pre = bin }, 0, false)
+ test_vim_str2nr('-0b1012', flags, { len = 6, num = -5, unum = 5, pre = bin }, 7, false)
+
+ test_vim_str2nr('0B101', flags, { len = 5, num = 5, unum = 5, pre = BIN }, 0)
+ test_vim_str2nr('0B101', flags, { len = 1, num = 0, unum = 0, pre = 0 }, 1)
+ test_vim_str2nr('0B101', flags, { len = 0 }, 2)
+ test_vim_str2nr('0B101', flags, { len = 1, num = 0, unum = 0, pre = 0 }, 2, false)
+ test_vim_str2nr('0B101', flags, { len = 3, num = 1, unum = 1, pre = BIN }, 3)
+ test_vim_str2nr('0B101', flags, { len = 4, num = 2, unum = 2, pre = BIN }, 4)
+ test_vim_str2nr('0B101', flags, { len = 5, num = 5, unum = 5, pre = BIN }, 5)
+ test_vim_str2nr('0B101', flags, { len = 5, num = 5, unum = 5, pre = BIN }, 6)
+
+ test_vim_str2nr('0B1012', flags, { len = 0 }, 0)
+ test_vim_str2nr('0B1012', flags, { len = 0 }, 6)
+ test_vim_str2nr('0B1012', flags, { len = 5, num = 5, unum = 5, pre = BIN }, 0, false)
+ test_vim_str2nr('0B1012', flags, { len = 5, num = 5, unum = 5, pre = BIN }, 6, false)
+
+ test_vim_str2nr('-0B101', flags, { len = 6, num = -5, unum = 5, pre = BIN }, 0)
+ test_vim_str2nr('-0B101', flags, { len = 1, num = 0, unum = 0, pre = 0 }, 1)
+ test_vim_str2nr('-0B101', flags, { len = 2, num = 0, unum = 0, pre = 0 }, 2)
+ test_vim_str2nr('-0B101', flags, { len = 0 }, 3)
+ test_vim_str2nr('-0B101', flags, { len = 2, num = 0, unum = 0, pre = 0 }, 3, false)
+ test_vim_str2nr('-0B101', flags, { len = 4, num = -1, unum = 1, pre = BIN }, 4)
+ test_vim_str2nr('-0B101', flags, { len = 5, num = -2, unum = 2, pre = BIN }, 5)
+ test_vim_str2nr('-0B101', flags, { len = 6, num = -5, unum = 5, pre = BIN }, 6)
+ test_vim_str2nr('-0B101', flags, { len = 6, num = -5, unum = 5, pre = BIN }, 7)
+
+ test_vim_str2nr('-0B1012', flags, { len = 0 }, 0)
+ test_vim_str2nr('-0B1012', flags, { len = 0 }, 7)
+ test_vim_str2nr('-0B1012', flags, { len = 6, num = -5, unum = 5, pre = BIN }, 0, false)
+ test_vim_str2nr('-0B1012', flags, { len = 6, num = -5, unum = 5, pre = BIN }, 7, false)
if flags > lib.STR2NR_FORCE then
- test_vim_str2nr('-101', flags, {len = 4, num = -5, unum = 5, pre = 0}, 0)
+ test_vim_str2nr('-101', flags, { len = 4, num = -5, unum = 5, pre = 0 }, 0)
end
end
end)
@@ -236,42 +276,42 @@ describe('vim_str2nr()', function()
end
-- Check that all digits are recognized
- test_vim_str2nr( '012345670', flags, {len = 9, num = 2739128, unum = 2739128, pre = oct}, 0)
-
- test_vim_str2nr( '054', flags, {len = 3, num = 44, unum = 44, pre = oct}, 0)
- test_vim_str2nr( '054', flags, {len = 1, num = 0, unum = 0, pre = 0 }, 1)
- test_vim_str2nr( '054', flags, {len = 2, num = 5, unum = 5, pre = oct}, 2)
- test_vim_str2nr( '054', flags, {len = 3, num = 44, unum = 44, pre = oct}, 3)
- test_vim_str2nr( '0548', flags, {len = 3, num = 44, unum = 44, pre = oct}, 3)
- test_vim_str2nr( '054', flags, {len = 3, num = 44, unum = 44, pre = oct}, 4)
-
- test_vim_str2nr( '054x', flags, {len = 0}, 4)
- test_vim_str2nr( '054x', flags, {len = 0}, 0)
- test_vim_str2nr( '054x', flags, {len = 3, num = 44, unum = 44, pre = oct}, 4, false)
- test_vim_str2nr( '054x', flags, {len = 3, num = 44, unum = 44, pre = oct}, 0, false)
-
- test_vim_str2nr('-054', flags, {len = 4, num = -44, unum = 44, pre = oct}, 0)
- test_vim_str2nr('-054', flags, {len = 1, num = 0, unum = 0, pre = 0 }, 1)
- test_vim_str2nr('-054', flags, {len = 2, num = 0, unum = 0, pre = 0 }, 2)
- test_vim_str2nr('-054', flags, {len = 3, num = -5, unum = 5, pre = oct}, 3)
- test_vim_str2nr('-054', flags, {len = 4, num = -44, unum = 44, pre = oct}, 4)
- test_vim_str2nr('-0548', flags, {len = 4, num = -44, unum = 44, pre = oct}, 4)
- test_vim_str2nr('-054', flags, {len = 4, num = -44, unum = 44, pre = oct}, 5)
-
- test_vim_str2nr('-054x', flags, {len = 0}, 5)
- test_vim_str2nr('-054x', flags, {len = 0}, 0)
- test_vim_str2nr('-054x', flags, {len = 4, num = -44, unum = 44, pre = oct}, 5, false)
- test_vim_str2nr('-054x', flags, {len = 4, num = -44, unum = 44, pre = oct}, 0, false)
+ test_vim_str2nr('012345670', flags, { len = 9, num = 2739128, unum = 2739128, pre = oct }, 0)
+
+ test_vim_str2nr('054', flags, { len = 3, num = 44, unum = 44, pre = oct }, 0)
+ test_vim_str2nr('054', flags, { len = 1, num = 0, unum = 0, pre = 0 }, 1)
+ test_vim_str2nr('054', flags, { len = 2, num = 5, unum = 5, pre = oct }, 2)
+ test_vim_str2nr('054', flags, { len = 3, num = 44, unum = 44, pre = oct }, 3)
+ test_vim_str2nr('0548', flags, { len = 3, num = 44, unum = 44, pre = oct }, 3)
+ test_vim_str2nr('054', flags, { len = 3, num = 44, unum = 44, pre = oct }, 4)
+
+ test_vim_str2nr('054x', flags, { len = 0 }, 4)
+ test_vim_str2nr('054x', flags, { len = 0 }, 0)
+ test_vim_str2nr('054x', flags, { len = 3, num = 44, unum = 44, pre = oct }, 4, false)
+ test_vim_str2nr('054x', flags, { len = 3, num = 44, unum = 44, pre = oct }, 0, false)
+
+ test_vim_str2nr('-054', flags, { len = 4, num = -44, unum = 44, pre = oct }, 0)
+ test_vim_str2nr('-054', flags, { len = 1, num = 0, unum = 0, pre = 0 }, 1)
+ test_vim_str2nr('-054', flags, { len = 2, num = 0, unum = 0, pre = 0 }, 2)
+ test_vim_str2nr('-054', flags, { len = 3, num = -5, unum = 5, pre = oct }, 3)
+ test_vim_str2nr('-054', flags, { len = 4, num = -44, unum = 44, pre = oct }, 4)
+ test_vim_str2nr('-0548', flags, { len = 4, num = -44, unum = 44, pre = oct }, 4)
+ test_vim_str2nr('-054', flags, { len = 4, num = -44, unum = 44, pre = oct }, 5)
+
+ test_vim_str2nr('-054x', flags, { len = 0 }, 5)
+ test_vim_str2nr('-054x', flags, { len = 0 }, 0)
+ test_vim_str2nr('-054x', flags, { len = 4, num = -44, unum = 44, pre = oct }, 5, false)
+ test_vim_str2nr('-054x', flags, { len = 4, num = -44, unum = 44, pre = oct }, 0, false)
if flags > lib.STR2NR_FORCE then
- test_vim_str2nr('-54', flags, {len = 3, num = -44, unum = 44, pre = 0}, 0)
- test_vim_str2nr('-0548', flags, {len = 0}, 5)
- test_vim_str2nr('-0548', flags, {len = 0}, 0)
- test_vim_str2nr('-0548', flags, {len = 4, num = -44, unum = 44, pre = 0}, 5, false)
- test_vim_str2nr('-0548', flags, {len = 4, num = -44, unum = 44, pre = 0}, 0, false)
+ test_vim_str2nr('-54', flags, { len = 3, num = -44, unum = 44, pre = 0 }, 0)
+ test_vim_str2nr('-0548', flags, { len = 0 }, 5)
+ test_vim_str2nr('-0548', flags, { len = 0 }, 0)
+ test_vim_str2nr('-0548', flags, { len = 4, num = -44, unum = 44, pre = 0 }, 5, false)
+ test_vim_str2nr('-0548', flags, { len = 4, num = -44, unum = 44, pre = 0 }, 0, false)
else
- test_vim_str2nr('-0548', flags, {len = 5, num = -548, unum = 548, pre = 0}, 5)
- test_vim_str2nr('-0548', flags, {len = 5, num = -548, unum = 548, pre = 0}, 0)
+ test_vim_str2nr('-0548', flags, { len = 5, num = -548, unum = 548, pre = 0 }, 5)
+ test_vim_str2nr('-0548', flags, { len = 5, num = -548, unum = 548, pre = 0 }, 0)
end
end
end)
@@ -298,73 +338,73 @@ describe('vim_str2nr()', function()
OCT = ('O'):byte()
end
- test_vim_str2nr( '0o054', flags, {len = 5, num = 44, unum = 44, pre = oct}, 0)
- test_vim_str2nr( '0o054', flags, {len = 1, num = 0, unum = 0, pre = 0 }, 1)
- test_vim_str2nr( '0o054', flags, {len = 0}, 2)
- test_vim_str2nr( '0o054', flags, {len = 3, num = 0, unum = 0, pre = oct}, 3)
- test_vim_str2nr( '0o054', flags, {len = 4, num = 5, unum = 5, pre = oct}, 4)
- test_vim_str2nr( '0o054', flags, {len = 5, num = 44, unum = 44, pre = oct}, 5)
- test_vim_str2nr( '0o0548', flags, {len = 5, num = 44, unum = 44, pre = oct}, 5)
- test_vim_str2nr( '0o054', flags, {len = 5, num = 44, unum = 44, pre = oct}, 6)
-
- test_vim_str2nr( '0o054x', flags, {len = 0}, 6)
- test_vim_str2nr( '0o054x', flags, {len = 0}, 0)
- test_vim_str2nr( '0o054x', flags, {len = 5, num = 44, unum = 44, pre = oct}, 6, false)
- test_vim_str2nr( '0o054x', flags, {len = 5, num = 44, unum = 44, pre = oct}, 0, false)
-
- test_vim_str2nr('-0o054', flags, {len = 6, num = -44, unum = 44, pre = oct}, 0)
- test_vim_str2nr('-0o054', flags, {len = 1, num = 0, unum = 0, pre = 0 }, 1)
- test_vim_str2nr('-0o054', flags, {len = 2, num = 0, unum = 0, pre = 0 }, 2)
- test_vim_str2nr('-0o054', flags, {len = 0}, 3)
- test_vim_str2nr('-0o054', flags, {len = 4, num = 0, unum = 0, pre = oct}, 4)
- test_vim_str2nr('-0o054', flags, {len = 5, num = -5, unum = 5, pre = oct}, 5)
- test_vim_str2nr('-0o054', flags, {len = 6, num = -44, unum = 44, pre = oct}, 6)
- test_vim_str2nr('-0o0548', flags, {len = 6, num = -44, unum = 44, pre = oct}, 6)
- test_vim_str2nr('-0o054', flags, {len = 6, num = -44, unum = 44, pre = oct}, 7)
-
- test_vim_str2nr('-0o054x', flags, {len = 0}, 7)
- test_vim_str2nr('-0o054x', flags, {len = 0}, 0)
- test_vim_str2nr('-0o054x', flags, {len = 6, num = -44, unum = 44, pre = oct}, 7, false)
- test_vim_str2nr('-0o054x', flags, {len = 6, num = -44, unum = 44, pre = oct}, 0, false)
-
- test_vim_str2nr( '0O054', flags, {len = 5, num = 44, unum = 44, pre = OCT}, 0)
- test_vim_str2nr( '0O054', flags, {len = 1, num = 0, unum = 0, pre = 0 }, 1)
- test_vim_str2nr( '0O054', flags, {len = 0}, 2)
- test_vim_str2nr( '0O054', flags, {len = 3, num = 0, unum = 0, pre = OCT}, 3)
- test_vim_str2nr( '0O054', flags, {len = 4, num = 5, unum = 5, pre = OCT}, 4)
- test_vim_str2nr( '0O054', flags, {len = 5, num = 44, unum = 44, pre = OCT}, 5)
- test_vim_str2nr( '0O0548', flags, {len = 5, num = 44, unum = 44, pre = OCT}, 5)
- test_vim_str2nr( '0O054', flags, {len = 5, num = 44, unum = 44, pre = OCT}, 6)
-
- test_vim_str2nr( '0O054x', flags, {len = 0}, 6)
- test_vim_str2nr( '0O054x', flags, {len = 0}, 0)
- test_vim_str2nr( '0O054x', flags, {len = 5, num = 44, unum = 44, pre = OCT}, 6, false)
- test_vim_str2nr( '0O054x', flags, {len = 5, num = 44, unum = 44, pre = OCT}, 0, false)
-
- test_vim_str2nr('-0O054', flags, {len = 6, num = -44, unum = 44, pre = OCT}, 0)
- test_vim_str2nr('-0O054', flags, {len = 1, num = 0, unum = 0, pre = 0 }, 1)
- test_vim_str2nr('-0O054', flags, {len = 2, num = 0, unum = 0, pre = 0 }, 2)
- test_vim_str2nr('-0O054', flags, {len = 0}, 3)
- test_vim_str2nr('-0O054', flags, {len = 4, num = 0, unum = 0, pre = OCT}, 4)
- test_vim_str2nr('-0O054', flags, {len = 5, num = -5, unum = 5, pre = OCT}, 5)
- test_vim_str2nr('-0O054', flags, {len = 6, num = -44, unum = 44, pre = OCT}, 6)
- test_vim_str2nr('-0O0548', flags, {len = 6, num = -44, unum = 44, pre = OCT}, 6)
- test_vim_str2nr('-0O054', flags, {len = 6, num = -44, unum = 44, pre = OCT}, 7)
-
- test_vim_str2nr('-0O054x', flags, {len = 0}, 7)
- test_vim_str2nr('-0O054x', flags, {len = 0}, 0)
- test_vim_str2nr('-0O054x', flags, {len = 6, num = -44, unum = 44, pre = OCT}, 7, false)
- test_vim_str2nr('-0O054x', flags, {len = 6, num = -44, unum = 44, pre = OCT}, 0, false)
+ test_vim_str2nr('0o054', flags, { len = 5, num = 44, unum = 44, pre = oct }, 0)
+ test_vim_str2nr('0o054', flags, { len = 1, num = 0, unum = 0, pre = 0 }, 1)
+ test_vim_str2nr('0o054', flags, { len = 0 }, 2)
+ test_vim_str2nr('0o054', flags, { len = 3, num = 0, unum = 0, pre = oct }, 3)
+ test_vim_str2nr('0o054', flags, { len = 4, num = 5, unum = 5, pre = oct }, 4)
+ test_vim_str2nr('0o054', flags, { len = 5, num = 44, unum = 44, pre = oct }, 5)
+ test_vim_str2nr('0o0548', flags, { len = 5, num = 44, unum = 44, pre = oct }, 5)
+ test_vim_str2nr('0o054', flags, { len = 5, num = 44, unum = 44, pre = oct }, 6)
+
+ test_vim_str2nr('0o054x', flags, { len = 0 }, 6)
+ test_vim_str2nr('0o054x', flags, { len = 0 }, 0)
+ test_vim_str2nr('0o054x', flags, { len = 5, num = 44, unum = 44, pre = oct }, 6, false)
+ test_vim_str2nr('0o054x', flags, { len = 5, num = 44, unum = 44, pre = oct }, 0, false)
+
+ test_vim_str2nr('-0o054', flags, { len = 6, num = -44, unum = 44, pre = oct }, 0)
+ test_vim_str2nr('-0o054', flags, { len = 1, num = 0, unum = 0, pre = 0 }, 1)
+ test_vim_str2nr('-0o054', flags, { len = 2, num = 0, unum = 0, pre = 0 }, 2)
+ test_vim_str2nr('-0o054', flags, { len = 0 }, 3)
+ test_vim_str2nr('-0o054', flags, { len = 4, num = 0, unum = 0, pre = oct }, 4)
+ test_vim_str2nr('-0o054', flags, { len = 5, num = -5, unum = 5, pre = oct }, 5)
+ test_vim_str2nr('-0o054', flags, { len = 6, num = -44, unum = 44, pre = oct }, 6)
+ test_vim_str2nr('-0o0548', flags, { len = 6, num = -44, unum = 44, pre = oct }, 6)
+ test_vim_str2nr('-0o054', flags, { len = 6, num = -44, unum = 44, pre = oct }, 7)
+
+ test_vim_str2nr('-0o054x', flags, { len = 0 }, 7)
+ test_vim_str2nr('-0o054x', flags, { len = 0 }, 0)
+ test_vim_str2nr('-0o054x', flags, { len = 6, num = -44, unum = 44, pre = oct }, 7, false)
+ test_vim_str2nr('-0o054x', flags, { len = 6, num = -44, unum = 44, pre = oct }, 0, false)
+
+ test_vim_str2nr('0O054', flags, { len = 5, num = 44, unum = 44, pre = OCT }, 0)
+ test_vim_str2nr('0O054', flags, { len = 1, num = 0, unum = 0, pre = 0 }, 1)
+ test_vim_str2nr('0O054', flags, { len = 0 }, 2)
+ test_vim_str2nr('0O054', flags, { len = 3, num = 0, unum = 0, pre = OCT }, 3)
+ test_vim_str2nr('0O054', flags, { len = 4, num = 5, unum = 5, pre = OCT }, 4)
+ test_vim_str2nr('0O054', flags, { len = 5, num = 44, unum = 44, pre = OCT }, 5)
+ test_vim_str2nr('0O0548', flags, { len = 5, num = 44, unum = 44, pre = OCT }, 5)
+ test_vim_str2nr('0O054', flags, { len = 5, num = 44, unum = 44, pre = OCT }, 6)
+
+ test_vim_str2nr('0O054x', flags, { len = 0 }, 6)
+ test_vim_str2nr('0O054x', flags, { len = 0 }, 0)
+ test_vim_str2nr('0O054x', flags, { len = 5, num = 44, unum = 44, pre = OCT }, 6, false)
+ test_vim_str2nr('0O054x', flags, { len = 5, num = 44, unum = 44, pre = OCT }, 0, false)
+
+ test_vim_str2nr('-0O054', flags, { len = 6, num = -44, unum = 44, pre = OCT }, 0)
+ test_vim_str2nr('-0O054', flags, { len = 1, num = 0, unum = 0, pre = 0 }, 1)
+ test_vim_str2nr('-0O054', flags, { len = 2, num = 0, unum = 0, pre = 0 }, 2)
+ test_vim_str2nr('-0O054', flags, { len = 0 }, 3)
+ test_vim_str2nr('-0O054', flags, { len = 4, num = 0, unum = 0, pre = OCT }, 4)
+ test_vim_str2nr('-0O054', flags, { len = 5, num = -5, unum = 5, pre = OCT }, 5)
+ test_vim_str2nr('-0O054', flags, { len = 6, num = -44, unum = 44, pre = OCT }, 6)
+ test_vim_str2nr('-0O0548', flags, { len = 6, num = -44, unum = 44, pre = OCT }, 6)
+ test_vim_str2nr('-0O054', flags, { len = 6, num = -44, unum = 44, pre = OCT }, 7)
+
+ test_vim_str2nr('-0O054x', flags, { len = 0 }, 7)
+ test_vim_str2nr('-0O054x', flags, { len = 0 }, 0)
+ test_vim_str2nr('-0O054x', flags, { len = 6, num = -44, unum = 44, pre = OCT }, 7, false)
+ test_vim_str2nr('-0O054x', flags, { len = 6, num = -44, unum = 44, pre = OCT }, 0, false)
if flags > lib.STR2NR_FORCE then
- test_vim_str2nr('-0548', flags, {len = 0}, 5)
- test_vim_str2nr('-0548', flags, {len = 0}, 0)
- test_vim_str2nr('-0548', flags, {len = 4, num = -44, unum = 44, pre = 0}, 5, false)
- test_vim_str2nr('-0548', flags, {len = 4, num = -44, unum = 44, pre = 0}, 0, false)
- test_vim_str2nr('-055', flags, {len = 4, num = -45, unum = 45, pre = 0}, 0)
+ test_vim_str2nr('-0548', flags, { len = 0 }, 5)
+ test_vim_str2nr('-0548', flags, { len = 0 }, 0)
+ test_vim_str2nr('-0548', flags, { len = 4, num = -44, unum = 44, pre = 0 }, 5, false)
+ test_vim_str2nr('-0548', flags, { len = 4, num = -44, unum = 44, pre = 0 }, 0, false)
+ test_vim_str2nr('-055', flags, { len = 4, num = -45, unum = 45, pre = 0 }, 0)
else
- test_vim_str2nr('-0548', flags, {len = 5, num = -548, unum = 548, pre = 0}, 5)
- test_vim_str2nr('-0548', flags, {len = 5, num = -548, unum = 548, pre = 0}, 0)
+ test_vim_str2nr('-0548', flags, { len = 5, num = -548, unum = 548, pre = 0 }, 5)
+ test_vim_str2nr('-0548', flags, { len = 5, num = -548, unum = 548, pre = 0 }, 0)
end
end
end)
@@ -387,92 +427,92 @@ describe('vim_str2nr()', function()
end
-- Check that all digits are recognized
- test_vim_str2nr('0x12345', flags, {len = 7, num = 74565, unum = 74565, pre = hex}, 0)
- test_vim_str2nr('0x67890', flags, {len = 7, num = 424080, unum = 424080, pre = hex}, 0)
- test_vim_str2nr('0xABCDEF', flags, {len = 8, num = 11259375, unum = 11259375, pre = hex}, 0)
- test_vim_str2nr('0xabcdef', flags, {len = 8, num = 11259375, unum = 11259375, pre = hex}, 0)
-
- test_vim_str2nr( '0x101', flags, {len = 5, num = 257, unum =257, pre = hex}, 0)
- test_vim_str2nr( '0x101', flags, {len = 1, num = 0, unum = 0, pre = 0 }, 1)
- test_vim_str2nr( '0x101', flags, {len = 0}, 2)
- test_vim_str2nr( '0x101', flags, {len = 1, num = 0, unum = 0, pre = 0 }, 2, false)
- test_vim_str2nr( '0x101', flags, {len = 3, num = 1, unum = 1, pre = hex}, 3)
- test_vim_str2nr( '0x101', flags, {len = 4, num = 16, unum = 16, pre = hex}, 4)
- test_vim_str2nr( '0x101', flags, {len = 5, num = 257, unum =257, pre = hex}, 5)
- test_vim_str2nr( '0x101', flags, {len = 5, num = 257, unum =257, pre = hex}, 6)
-
- test_vim_str2nr( '0x101G', flags, {len = 0}, 0)
- test_vim_str2nr( '0x101G', flags, {len = 0}, 6)
- test_vim_str2nr( '0x101G', flags, {len = 5, num = 257, unum =257, pre = hex}, 0, false)
- test_vim_str2nr( '0x101G', flags, {len = 5, num = 257, unum =257, pre = hex}, 6, false)
-
- test_vim_str2nr('-0x101', flags, {len = 6, num =-257, unum =257, pre = hex}, 0)
- test_vim_str2nr('-0x101', flags, {len = 1, num = 0, unum = 0, pre = 0 }, 1)
- test_vim_str2nr('-0x101', flags, {len = 2, num = 0, unum = 0, pre = 0 }, 2)
- test_vim_str2nr('-0x101', flags, {len = 0}, 3)
- test_vim_str2nr('-0x101', flags, {len = 2, num = 0, unum = 0, pre = 0 }, 3, false)
- test_vim_str2nr('-0x101', flags, {len = 4, num = -1, unum = 1, pre = hex}, 4)
- test_vim_str2nr('-0x101', flags, {len = 5, num = -16, unum = 16, pre = hex}, 5)
- test_vim_str2nr('-0x101', flags, {len = 6, num =-257, unum =257, pre = hex}, 6)
- test_vim_str2nr('-0x101', flags, {len = 6, num =-257, unum =257, pre = hex}, 7)
-
- test_vim_str2nr('-0x101G', flags, {len = 0}, 0)
- test_vim_str2nr('-0x101G', flags, {len = 0}, 7)
- test_vim_str2nr('-0x101G', flags, {len = 6, num =-257, unum =257, pre = hex}, 0, false)
- test_vim_str2nr('-0x101G', flags, {len = 6, num =-257, unum =257, pre = hex}, 7, false)
-
- test_vim_str2nr( '0X101', flags, {len = 5, num = 257, unum =257, pre = HEX}, 0)
- test_vim_str2nr( '0X101', flags, {len = 1, num = 0, unum = 0, pre = 0 }, 1)
- test_vim_str2nr( '0X101', flags, {len = 0}, 2)
- test_vim_str2nr( '0X101', flags, {len = 1, num = 0, unum = 0, pre = 0 }, 2, false)
- test_vim_str2nr( '0X101', flags, {len = 3, num = 1, unum = 1, pre = HEX}, 3)
- test_vim_str2nr( '0X101', flags, {len = 4, num = 16, unum = 16, pre = HEX}, 4)
- test_vim_str2nr( '0X101', flags, {len = 5, num = 257, unum =257, pre = HEX}, 5)
- test_vim_str2nr( '0X101', flags, {len = 5, num = 257, unum =257, pre = HEX}, 6)
-
- test_vim_str2nr( '0X101G', flags, {len = 0}, 0)
- test_vim_str2nr( '0X101G', flags, {len = 0}, 6)
- test_vim_str2nr( '0X101G', flags, {len = 5, num = 257, unum =257, pre = HEX}, 0, false)
- test_vim_str2nr( '0X101G', flags, {len = 5, num = 257, unum =257, pre = HEX}, 6, false)
-
- test_vim_str2nr('-0X101', flags, {len = 6, num =-257, unum =257, pre = HEX}, 0)
- test_vim_str2nr('-0X101', flags, {len = 1, num = 0, unum = 0, pre = 0 }, 1)
- test_vim_str2nr('-0X101', flags, {len = 2, num = 0, unum = 0, pre = 0 }, 2)
- test_vim_str2nr('-0X101', flags, {len = 0}, 3)
- test_vim_str2nr('-0X101', flags, {len = 2, num = 0, unum = 0, pre = 0 }, 3, false)
- test_vim_str2nr('-0X101', flags, {len = 4, num = -1, unum = 1, pre = HEX}, 4)
- test_vim_str2nr('-0X101', flags, {len = 5, num = -16, unum = 16, pre = HEX}, 5)
- test_vim_str2nr('-0X101', flags, {len = 6, num =-257, unum =257, pre = HEX}, 6)
- test_vim_str2nr('-0X101', flags, {len = 6, num =-257, unum =257, pre = HEX}, 7)
-
- test_vim_str2nr('-0X101G', flags, {len = 0}, 0)
- test_vim_str2nr('-0X101G', flags, {len = 0}, 7)
- test_vim_str2nr('-0X101G', flags, {len = 6, num =-257, unum =257, pre = HEX}, 0, false)
- test_vim_str2nr('-0X101G', flags, {len = 6, num =-257, unum =257, pre = HEX}, 7, false)
+ test_vim_str2nr('0x12345', flags, { len = 7, num = 74565, unum = 74565, pre = hex }, 0)
+ test_vim_str2nr('0x67890', flags, { len = 7, num = 424080, unum = 424080, pre = hex }, 0)
+ test_vim_str2nr('0xABCDEF', flags, { len = 8, num = 11259375, unum = 11259375, pre = hex }, 0)
+ test_vim_str2nr('0xabcdef', flags, { len = 8, num = 11259375, unum = 11259375, pre = hex }, 0)
+
+ test_vim_str2nr('0x101', flags, { len = 5, num = 257, unum = 257, pre = hex }, 0)
+ test_vim_str2nr('0x101', flags, { len = 1, num = 0, unum = 0, pre = 0 }, 1)
+ test_vim_str2nr('0x101', flags, { len = 0 }, 2)
+ test_vim_str2nr('0x101', flags, { len = 1, num = 0, unum = 0, pre = 0 }, 2, false)
+ test_vim_str2nr('0x101', flags, { len = 3, num = 1, unum = 1, pre = hex }, 3)
+ test_vim_str2nr('0x101', flags, { len = 4, num = 16, unum = 16, pre = hex }, 4)
+ test_vim_str2nr('0x101', flags, { len = 5, num = 257, unum = 257, pre = hex }, 5)
+ test_vim_str2nr('0x101', flags, { len = 5, num = 257, unum = 257, pre = hex }, 6)
+
+ test_vim_str2nr('0x101G', flags, { len = 0 }, 0)
+ test_vim_str2nr('0x101G', flags, { len = 0 }, 6)
+ test_vim_str2nr('0x101G', flags, { len = 5, num = 257, unum = 257, pre = hex }, 0, false)
+ test_vim_str2nr('0x101G', flags, { len = 5, num = 257, unum = 257, pre = hex }, 6, false)
+
+ test_vim_str2nr('-0x101', flags, { len = 6, num = -257, unum = 257, pre = hex }, 0)
+ test_vim_str2nr('-0x101', flags, { len = 1, num = 0, unum = 0, pre = 0 }, 1)
+ test_vim_str2nr('-0x101', flags, { len = 2, num = 0, unum = 0, pre = 0 }, 2)
+ test_vim_str2nr('-0x101', flags, { len = 0 }, 3)
+ test_vim_str2nr('-0x101', flags, { len = 2, num = 0, unum = 0, pre = 0 }, 3, false)
+ test_vim_str2nr('-0x101', flags, { len = 4, num = -1, unum = 1, pre = hex }, 4)
+ test_vim_str2nr('-0x101', flags, { len = 5, num = -16, unum = 16, pre = hex }, 5)
+ test_vim_str2nr('-0x101', flags, { len = 6, num = -257, unum = 257, pre = hex }, 6)
+ test_vim_str2nr('-0x101', flags, { len = 6, num = -257, unum = 257, pre = hex }, 7)
+
+ test_vim_str2nr('-0x101G', flags, { len = 0 }, 0)
+ test_vim_str2nr('-0x101G', flags, { len = 0 }, 7)
+ test_vim_str2nr('-0x101G', flags, { len = 6, num = -257, unum = 257, pre = hex }, 0, false)
+ test_vim_str2nr('-0x101G', flags, { len = 6, num = -257, unum = 257, pre = hex }, 7, false)
+
+ test_vim_str2nr('0X101', flags, { len = 5, num = 257, unum = 257, pre = HEX }, 0)
+ test_vim_str2nr('0X101', flags, { len = 1, num = 0, unum = 0, pre = 0 }, 1)
+ test_vim_str2nr('0X101', flags, { len = 0 }, 2)
+ test_vim_str2nr('0X101', flags, { len = 1, num = 0, unum = 0, pre = 0 }, 2, false)
+ test_vim_str2nr('0X101', flags, { len = 3, num = 1, unum = 1, pre = HEX }, 3)
+ test_vim_str2nr('0X101', flags, { len = 4, num = 16, unum = 16, pre = HEX }, 4)
+ test_vim_str2nr('0X101', flags, { len = 5, num = 257, unum = 257, pre = HEX }, 5)
+ test_vim_str2nr('0X101', flags, { len = 5, num = 257, unum = 257, pre = HEX }, 6)
+
+ test_vim_str2nr('0X101G', flags, { len = 0 }, 0)
+ test_vim_str2nr('0X101G', flags, { len = 0 }, 6)
+ test_vim_str2nr('0X101G', flags, { len = 5, num = 257, unum = 257, pre = HEX }, 0, false)
+ test_vim_str2nr('0X101G', flags, { len = 5, num = 257, unum = 257, pre = HEX }, 6, false)
+
+ test_vim_str2nr('-0X101', flags, { len = 6, num = -257, unum = 257, pre = HEX }, 0)
+ test_vim_str2nr('-0X101', flags, { len = 1, num = 0, unum = 0, pre = 0 }, 1)
+ test_vim_str2nr('-0X101', flags, { len = 2, num = 0, unum = 0, pre = 0 }, 2)
+ test_vim_str2nr('-0X101', flags, { len = 0 }, 3)
+ test_vim_str2nr('-0X101', flags, { len = 2, num = 0, unum = 0, pre = 0 }, 3, false)
+ test_vim_str2nr('-0X101', flags, { len = 4, num = -1, unum = 1, pre = HEX }, 4)
+ test_vim_str2nr('-0X101', flags, { len = 5, num = -16, unum = 16, pre = HEX }, 5)
+ test_vim_str2nr('-0X101', flags, { len = 6, num = -257, unum = 257, pre = HEX }, 6)
+ test_vim_str2nr('-0X101', flags, { len = 6, num = -257, unum = 257, pre = HEX }, 7)
+
+ test_vim_str2nr('-0X101G', flags, { len = 0 }, 0)
+ test_vim_str2nr('-0X101G', flags, { len = 0 }, 7)
+ test_vim_str2nr('-0X101G', flags, { len = 6, num = -257, unum = 257, pre = HEX }, 0, false)
+ test_vim_str2nr('-0X101G', flags, { len = 6, num = -257, unum = 257, pre = HEX }, 7, false)
if flags > lib.STR2NR_FORCE then
- test_vim_str2nr('-101', flags, {len = 4, num = -257, unum = 257, pre = 0}, 0)
+ test_vim_str2nr('-101', flags, { len = 4, num = -257, unum = 257, pre = 0 }, 0)
end
end
end)
-- Test_str2nr() in test_functions.vim already tests normal usage
itp('works with weirdly quoted numbers', function()
local flags = lib.STR2NR_DEC + lib.STR2NR_QUOTE
- test_vim_str2nr("'027", flags, {len = 0}, 0)
- test_vim_str2nr("'027", flags, {len = 0}, 0, false)
- test_vim_str2nr("1'2'3'4", flags, {len = 7, num = 1234, unum = 1234, pre = 0}, 0)
+ test_vim_str2nr("'027", flags, { len = 0 }, 0)
+ test_vim_str2nr("'027", flags, { len = 0 }, 0, false)
+ test_vim_str2nr("1'2'3'4", flags, { len = 7, num = 1234, unum = 1234, pre = 0 }, 0)
-- counter-intuitive, but like Vim, strict=true should partially accept
-- these: (' and - are not alphanumeric)
- test_vim_str2nr("7''331", flags, {len = 1, num = 7, unum = 7, pre = 0}, 0)
- test_vim_str2nr("123'x4", flags, {len = 3, num = 123, unum = 123, pre = 0}, 0)
- test_vim_str2nr("1337'", flags, {len = 4, num = 1337, unum = 1337, pre = 0}, 0)
- test_vim_str2nr("-'", flags, {len = 1, num = 0, unum = 0, pre = 0}, 0)
+ test_vim_str2nr("7''331", flags, { len = 1, num = 7, unum = 7, pre = 0 }, 0)
+ test_vim_str2nr("123'x4", flags, { len = 3, num = 123, unum = 123, pre = 0 }, 0)
+ test_vim_str2nr("1337'", flags, { len = 4, num = 1337, unum = 1337, pre = 0 }, 0)
+ test_vim_str2nr("-'", flags, { len = 1, num = 0, unum = 0, pre = 0 }, 0)
flags = lib.STR2NR_HEX + lib.STR2NR_QUOTE
local hex = ('x'):byte()
- test_vim_str2nr("0x'abcd", flags, {len = 0}, 0)
- test_vim_str2nr("0x'abcd", flags, {len = 1, num = 0, unum = 0, pre = 0}, 0, false)
- test_vim_str2nr("0xab''cd", flags, {len = 4, num = 171, unum = 171, pre = hex}, 0)
+ test_vim_str2nr("0x'abcd", flags, { len = 0 }, 0)
+ test_vim_str2nr("0x'abcd", flags, { len = 1, num = 0, unum = 0, pre = 0 }, 0, false)
+ test_vim_str2nr("0xab''cd", flags, { len = 4, num = 171, unum = 171, pre = hex }, 0)
end)
end)
diff --git a/test/unit/eval/decode_spec.lua b/test/unit/eval/decode_spec.lua
index 0c444b33f2..5a8374a2a6 100644
--- a/test/unit/eval/decode_spec.lua
+++ b/test/unit/eval/decode_spec.lua
@@ -6,9 +6,13 @@ local eq = helpers.eq
local neq = helpers.neq
local ffi = helpers.ffi
-local decode = cimport('./src/nvim/eval/decode.h', './src/nvim/eval/typval.h',
- './src/nvim/globals.h', './src/nvim/memory.h',
- './src/nvim/message.h')
+local decode = cimport(
+ './src/nvim/eval/decode.h',
+ './src/nvim/eval/typval.h',
+ './src/nvim/globals.h',
+ './src/nvim/memory.h',
+ './src/nvim/message.h'
+)
describe('json_decode_string()', function()
local char = function(c)
@@ -16,7 +20,7 @@ describe('json_decode_string()', function()
end
itp('does not overflow when running with `n…`, `t…`, `f…`', function()
- local rettv = ffi.new('typval_T', {v_type=decode.VAR_UNKNOWN})
+ local rettv = ffi.new('typval_T', { v_type = decode.VAR_UNKNOWN })
decode.emsg_silent = 1
-- This will not crash, but if `len` argument will be ignored it will parse
-- `null` as `null` and if not it will parse `null` as `n`.
@@ -43,7 +47,7 @@ describe('json_decode_string()', function()
end)
itp('does not overflow and crash when running with `n`, `t`, `f`', function()
- local rettv = ffi.new('typval_T', {v_type=decode.VAR_UNKNOWN})
+ local rettv = ffi.new('typval_T', { v_type = decode.VAR_UNKNOWN })
decode.emsg_silent = 1
eq(0, decode.json_decode_string(char('n'), 1, rettv))
eq(decode.VAR_UNKNOWN, rettv.v_type)
@@ -54,7 +58,7 @@ describe('json_decode_string()', function()
end)
itp('does not overflow when running with `"…`', function()
- local rettv = ffi.new('typval_T', {v_type=decode.VAR_UNKNOWN})
+ local rettv = ffi.new('typval_T', { v_type = decode.VAR_UNKNOWN })
decode.emsg_silent = 1
eq(0, decode.json_decode_string('"t"', 2, rettv))
eq(decode.VAR_UNKNOWN, rettv.v_type)
@@ -63,7 +67,7 @@ describe('json_decode_string()', function()
end)
local check_failure = function(s, len, msg)
- local rettv = ffi.new('typval_T', {v_type=decode.VAR_UNKNOWN})
+ local rettv = ffi.new('typval_T', { v_type = decode.VAR_UNKNOWN })
eq(0, decode.json_decode_string(s, len, rettv))
eq(decode.VAR_UNKNOWN, rettv.v_type)
neq(nil, decode.last_msg_hist)
@@ -74,8 +78,7 @@ describe('json_decode_string()', function()
collectgarbage('restart')
check_failure(']test', 1, 'E474: No container to close: ]')
check_failure('[}test', 2, 'E474: Closing list with curly bracket: }')
- check_failure('{]test', 2,
- 'E474: Closing dictionary with square bracket: ]')
+ check_failure('{]test', 2, 'E474: Closing dictionary with square bracket: ]')
check_failure('[1,]test', 4, 'E474: Trailing comma: ]')
check_failure('{"1":}test', 6, 'E474: Expected value after colon: }')
check_failure('{"1"}test', 5, 'E474: Expected value: }')
@@ -93,16 +96,20 @@ describe('json_decode_string()', function()
check_failure('ttest', 1, 'E474: Expected true: t')
check_failure('ftest', 1, 'E474: Expected false: f')
check_failure('"\\test', 2, 'E474: Unfinished escape sequence: "\\')
- check_failure('"\\u"test', 4,
- 'E474: Unfinished unicode escape sequence: "\\u"')
- check_failure('"\\uXXXX"est', 8,
- 'E474: Expected four hex digits after \\u: \\uXXXX"')
+ check_failure('"\\u"test', 4, 'E474: Unfinished unicode escape sequence: "\\u"')
+ check_failure('"\\uXXXX"est', 8, 'E474: Expected four hex digits after \\u: \\uXXXX"')
check_failure('"\\?"test', 4, 'E474: Unknown escape sequence: \\?"')
check_failure(
- '"\t"test', 3,
- 'E474: ASCII control characters cannot be present inside string: \t"')
+ '"\t"test',
+ 3,
+ 'E474: ASCII control characters cannot be present inside string: \t"'
+ )
check_failure('"\194"test', 3, 'E474: Only UTF-8 strings allowed: \194"')
- check_failure('"\252\144\128\128\128\128"test', 8, 'E474: Only UTF-8 code points up to U+10FFFF are allowed to appear unescaped: \252\144\128\128\128\128"')
+ check_failure(
+ '"\252\144\128\128\128\128"test',
+ 8,
+ 'E474: Only UTF-8 code points up to U+10FFFF are allowed to appear unescaped: \252\144\128\128\128\128"'
+ )
check_failure('"test', 1, 'E474: Expected string end: "')
check_failure('-test', 1, 'E474: Missing number after minus sign: -')
check_failure('-1.test', 3, 'E474: Missing number after decimal dot: -1.')
@@ -117,7 +124,7 @@ describe('json_decode_string()', function()
end)
itp('does not overflow and crash when running with `"`', function()
- local rettv = ffi.new('typval_T', {v_type=decode.VAR_UNKNOWN})
+ local rettv = ffi.new('typval_T', { v_type = decode.VAR_UNKNOWN })
decode.emsg_silent = 1
eq(0, decode.json_decode_string(char('"'), 1, rettv))
eq(decode.VAR_UNKNOWN, rettv.v_type)
diff --git a/test/unit/eval/encode_spec.lua b/test/unit/eval/encode_spec.lua
index 058c55093e..498346d7cc 100644
--- a/test/unit/eval/encode_spec.lua
+++ b/test/unit/eval/encode_spec.lua
@@ -22,80 +22,83 @@ describe('encode_list_write()', function()
itp('writes empty string', function()
local l = list()
eq(0, encode_list_write(l, ''))
- eq({[type_key]=list_type}, lst2tbl(l))
+ eq({ [type_key] = list_type }, lst2tbl(l))
end)
itp('writes ASCII string literal with printable characters', function()
local l = list()
eq(0, encode_list_write(l, 'abc'))
- eq({'abc'}, lst2tbl(l))
+ eq({ 'abc' }, lst2tbl(l))
end)
itp('writes string starting with NL', function()
local l = list()
eq(0, encode_list_write(l, '\nabc'))
- eq({null_string, 'abc'}, lst2tbl(l))
+ eq({ null_string, 'abc' }, lst2tbl(l))
end)
itp('writes string starting with NL twice', function()
local l = list()
eq(0, encode_list_write(l, '\nabc'))
- eq({null_string, 'abc'}, lst2tbl(l))
+ eq({ null_string, 'abc' }, lst2tbl(l))
eq(0, encode_list_write(l, '\nabc'))
- eq({null_string, 'abc', 'abc'}, lst2tbl(l))
+ eq({ null_string, 'abc', 'abc' }, lst2tbl(l))
end)
itp('writes string ending with NL', function()
local l = list()
eq(0, encode_list_write(l, 'abc\n'))
- eq({'abc', null_string}, lst2tbl(l))
+ eq({ 'abc', null_string }, lst2tbl(l))
end)
itp('writes string ending with NL twice', function()
local l = list()
eq(0, encode_list_write(l, 'abc\n'))
- eq({'abc', null_string}, lst2tbl(l))
+ eq({ 'abc', null_string }, lst2tbl(l))
eq(0, encode_list_write(l, 'abc\n'))
- eq({'abc', 'abc', null_string}, lst2tbl(l))
+ eq({ 'abc', 'abc', null_string }, lst2tbl(l))
end)
itp('writes string starting, ending and containing NL twice', function()
local l = list()
eq(0, encode_list_write(l, '\na\nb\n'))
- eq({null_string, 'a', 'b', null_string}, lst2tbl(l))
+ eq({ null_string, 'a', 'b', null_string }, lst2tbl(l))
eq(0, encode_list_write(l, '\na\nb\n'))
- eq({null_string, 'a', 'b', null_string, 'a', 'b', null_string}, lst2tbl(l))
+ eq({ null_string, 'a', 'b', null_string, 'a', 'b', null_string }, lst2tbl(l))
end)
itp('writes string starting, ending and containing NUL with NL between twice', function()
local l = list()
eq(0, encode_list_write(l, '\0\n\0\n\0'))
- eq({'\n', '\n', '\n'}, lst2tbl(l))
+ eq({ '\n', '\n', '\n' }, lst2tbl(l))
eq(0, encode_list_write(l, '\0\n\0\n\0'))
- eq({'\n', '\n', '\n\n', '\n', '\n'}, lst2tbl(l))
+ eq({ '\n', '\n', '\n\n', '\n', '\n' }, lst2tbl(l))
end)
itp('writes string starting, ending and containing NL with NUL between twice', function()
local l = list()
eq(0, encode_list_write(l, '\n\0\n\0\n'))
- eq({null_string, '\n', '\n', null_string}, lst2tbl(l))
+ eq({ null_string, '\n', '\n', null_string }, lst2tbl(l))
eq(0, encode_list_write(l, '\n\0\n\0\n'))
- eq({null_string, '\n', '\n', null_string, '\n', '\n', null_string}, lst2tbl(l))
+ eq({ null_string, '\n', '\n', null_string, '\n', '\n', null_string }, lst2tbl(l))
end)
itp('writes string containing a single NL twice', function()
local l = list()
eq(0, encode_list_write(l, '\n'))
- eq({null_string, null_string}, lst2tbl(l))
+ eq({ null_string, null_string }, lst2tbl(l))
eq(0, encode_list_write(l, '\n'))
- eq({null_string, null_string, null_string}, lst2tbl(l))
+ eq({ null_string, null_string, null_string }, lst2tbl(l))
end)
itp('writes string containing a few NLs twice', function()
local l = list()
eq(0, encode_list_write(l, '\n\n\n'))
- eq({null_string, null_string, null_string, null_string}, lst2tbl(l))
+ eq({ null_string, null_string, null_string, null_string }, lst2tbl(l))
eq(0, encode_list_write(l, '\n\n\n'))
- eq({null_string, null_string, null_string, null_string, null_string, null_string, null_string}, lst2tbl(l))
+ eq(
+ { null_string, null_string, null_string, null_string, null_string, null_string, null_string },
+ lst2tbl(l)
+ )
end)
end)
diff --git a/test/unit/eval/helpers.lua b/test/unit/eval/helpers.lua
index 883f01bd84..6402e1f8c9 100644
--- a/test/unit/eval/helpers.lua
+++ b/test/unit/eval/helpers.lua
@@ -6,21 +6,25 @@ local to_cstr = helpers.to_cstr
local ffi = helpers.ffi
local eq = helpers.eq
-local eval = cimport('./src/nvim/eval.h', './src/nvim/eval/typval.h',
- './src/nvim/hashtab.h', './src/nvim/memory.h')
-
-local null_string = {[true]='NULL string'}
-local null_list = {[true]='NULL list'}
-local null_dict = {[true]='NULL dict'}
-local type_key = {[true]='type key'}
-local locks_key = {[true]='locks key'}
-local list_type = {[true]='list type'}
-local dict_type = {[true]='dict type'}
-local func_type = {[true]='func type'}
-local int_type = {[true]='int type'}
-local flt_type = {[true]='flt type'}
-
-local nil_value = {[true]='nil'}
+local eval = cimport(
+ './src/nvim/eval.h',
+ './src/nvim/eval/typval.h',
+ './src/nvim/hashtab.h',
+ './src/nvim/memory.h'
+)
+
+local null_string = { [true] = 'NULL string' }
+local null_list = { [true] = 'NULL list' }
+local null_dict = { [true] = 'NULL dict' }
+local type_key = { [true] = 'type key' }
+local locks_key = { [true] = 'locks key' }
+local list_type = { [true] = 'list type' }
+local dict_type = { [true] = 'dict type' }
+local func_type = { [true] = 'func type' }
+local int_type = { [true] = 'int type' }
+local flt_type = { [true] = 'flt type' }
+
+local nil_value = { [true] = 'nil' }
local lua2typvalt
@@ -35,11 +39,13 @@ end
local function li_alloc(nogc)
local gcfunc = tv_list_item_free
- if nogc then gcfunc = nil end
+ if nogc then
+ gcfunc = nil
+ end
local li = ffi.gc(tv_list_item_alloc(), gcfunc)
li.li_next = nil
li.li_prev = nil
- li.li_tv = {v_type=eval.VAR_UNKNOWN, v_lock=eval.VAR_UNLOCKED}
+ li.li_tv = { v_type = eval.VAR_UNKNOWN, v_lock = eval.VAR_UNLOCKED }
return li
end
@@ -121,11 +127,11 @@ local function partial2lua(pt, processed)
end
end
return {
- [type_key]=func_type,
- value=value,
- auto=auto,
- args=argv,
- dict=dict,
+ [type_key] = func_type,
+ value = value,
+ auto = auto,
+ args = argv,
+ dict = dict,
}
end
@@ -148,7 +154,7 @@ local function typvalt2lua_tab_init()
})[tonumber(t.vval.v_special)]
end,
[tonumber(eval.VAR_NUMBER)] = function(t)
- return {[type_key]=int_type, value=tonumber(t.vval.v_number)}
+ return { [type_key] = int_type, value = tonumber(t.vval.v_number) }
end,
[tonumber(eval.VAR_FLOAT)] = function(t)
return tonumber(t.vval.v_float)
@@ -168,7 +174,7 @@ local function typvalt2lua_tab_init()
return dct2tbl(t.vval.v_dict, processed)
end,
[tonumber(eval.VAR_FUNC)] = function(t, processed)
- return {[type_key]=func_type, value=typvalt2lua_tab[eval.VAR_STRING](t, processed or {})}
+ return { [type_key] = func_type, value = typvalt2lua_tab[eval.VAR_STRING](t, processed or {}) }
end,
[tonumber(eval.VAR_PARTIAL)] = function(t, processed)
local p_key = ptr2key(t)
@@ -182,15 +188,17 @@ end
typvalt2lua = function(t, processed)
typvalt2lua_tab_init()
- return ((typvalt2lua_tab[tonumber(t.v_type)] or function(t_inner)
- assert(false, 'Converting ' .. tonumber(t_inner.v_type) .. ' was not implemented yet')
- end)(t, processed or {}))
+ return (
+ (typvalt2lua_tab[tonumber(t.v_type)] or function(t_inner)
+ assert(false, 'Converting ' .. tonumber(t_inner.v_type) .. ' was not implemented yet')
+ end)(t, processed or {})
+ )
end
local function list_iter(l)
local init_s = {
- idx=0,
- li=l.lv_first,
+ idx = 0,
+ li = l.lv_first,
}
local function f(s, _)
-- (listitem_T *) NULL is equal to nil, but yet it is not false.
@@ -222,7 +230,7 @@ lst2tbl = function(l, processed)
if processed[p_key] then
return processed[p_key]
end
- local ret = {[type_key]=list_type}
+ local ret = { [type_key] = list_type }
processed[p_key] = ret
for i, li in list_iter(l) do
ret[i] = typvalt2lua(li.li_tv, processed)
@@ -238,11 +246,13 @@ local hi_key_removed = nil
local function dict_iter(d, return_hi)
hi_key_removed = hi_key_removed or eval._hash_key_removed()
local init_s = {
- todo=d.dv_hashtab.ht_used,
- hi=d.dv_hashtab.ht_array,
+ todo = d.dv_hashtab.ht_used,
+ hi = d.dv_hashtab.ht_array,
}
local function f(s, _)
- if s.todo == 0 then return nil end
+ if s.todo == 0 then
+ return nil
+ end
while s.todo > 0 do
if s.hi.hi_key ~= nil and s.hi.hi_key ~= hi_key_removed then
local key = ffi.string(s.hi.hi_key)
@@ -250,8 +260,7 @@ local function dict_iter(d, return_hi)
if return_hi then
ret = s.hi
else
- ret = ffi.cast('dictitem_T*',
- s.hi.hi_key - ffi.offsetof('dictitem_T', 'di_key'))
+ ret = ffi.cast('dictitem_T*', s.hi.hi_key - ffi.offsetof('dictitem_T', 'di_key'))
end
s.todo = s.todo - 1
s.hi = s.hi + 1
@@ -269,7 +278,7 @@ local function first_di(d)
end
local function dict_items(d)
- local ret = {[0]=0}
+ local ret = { [0] = 0 }
for k, hi in dict_iter(d) do
ret[k] = hi
ret[0] = ret[0] + 1
@@ -301,12 +310,12 @@ local typvalt = function(typ, vval)
elseif type(typ) == 'string' then
typ = eval[typ]
end
- return ffi.gc(ffi.new('typval_T', {v_type=typ, vval=vval}), eval.tv_clear)
+ return ffi.gc(ffi.new('typval_T', { v_type = typ, vval = vval }), eval.tv_clear)
end
local lua2typvalt_type_tab = {
[int_type] = function(l, _)
- return typvalt(eval.VAR_NUMBER, {v_number=l.value})
+ return typvalt(eval.VAR_NUMBER, { v_number = l.value })
end,
[flt_type] = function(l, processed)
return lua2typvalt(l.value, processed)
@@ -314,31 +323,34 @@ local lua2typvalt_type_tab = {
[list_type] = function(l, processed)
if processed[l] then
processed[l].lv_refcount = processed[l].lv_refcount + 1
- return typvalt(eval.VAR_LIST, {v_list=processed[l]})
+ return typvalt(eval.VAR_LIST, { v_list = processed[l] })
end
local lst = populate_list(eval.tv_list_alloc(#l), l, processed)
- return typvalt(eval.VAR_LIST, {v_list=lst})
+ return typvalt(eval.VAR_LIST, { v_list = lst })
end,
[dict_type] = function(l, processed)
if processed[l] then
processed[l].dv_refcount = processed[l].dv_refcount + 1
- return typvalt(eval.VAR_DICT, {v_dict=processed[l]})
+ return typvalt(eval.VAR_DICT, { v_dict = processed[l] })
end
local dct = populate_dict(eval.tv_dict_alloc(), l, processed)
- return typvalt(eval.VAR_DICT, {v_dict=dct})
+ return typvalt(eval.VAR_DICT, { v_dict = dct })
end,
[func_type] = function(l, processed)
if processed[l] then
processed[l].pt_refcount = processed[l].pt_refcount + 1
- return typvalt(eval.VAR_PARTIAL, {v_partial=processed[l]})
+ return typvalt(eval.VAR_PARTIAL, { v_partial = processed[l] })
end
if l.args or l.dict then
- local pt = populate_partial(ffi.gc(ffi.cast('partial_T*',
- eval.xcalloc(1, ffi.sizeof('partial_T'))), nil), l, processed)
- return typvalt(eval.VAR_PARTIAL, {v_partial=pt})
+ local pt = populate_partial(
+ ffi.gc(ffi.cast('partial_T*', eval.xcalloc(1, ffi.sizeof('partial_T'))), nil),
+ l,
+ processed
+ )
+ return typvalt(eval.VAR_PARTIAL, { v_partial = pt })
else
return typvalt(eval.VAR_FUNC, {
- v_string=eval.xmemdupz(to_cstr(l.value), #l.value)
+ v_string = eval.xmemdupz(to_cstr(l.value), #l.value),
})
end
end,
@@ -349,12 +361,12 @@ local special_vals = nil
lua2typvalt = function(l, processed)
if not special_vals then
special_vals = {
- [null_string] = {'VAR_STRING', {v_string=ffi.cast('char*', nil)}},
- [null_list] = {'VAR_LIST', {v_list=ffi.cast('list_T*', nil)}},
- [null_dict] = {'VAR_DICT', {v_dict=ffi.cast('dict_T*', nil)}},
- [nil_value] = {'VAR_SPECIAL', {v_special=eval.kSpecialVarNull}},
- [true] = {'VAR_BOOL', {v_bool=eval.kBoolVarTrue}},
- [false] = {'VAR_BOOL', {v_bool=eval.kBoolVarFalse}},
+ [null_string] = { 'VAR_STRING', { v_string = ffi.cast('char*', nil) } },
+ [null_list] = { 'VAR_LIST', { v_list = ffi.cast('list_T*', nil) } },
+ [null_dict] = { 'VAR_DICT', { v_dict = ffi.cast('dict_T*', nil) } },
+ [nil_value] = { 'VAR_SPECIAL', { v_special = eval.kSpecialVarNull } },
+ [true] = { 'VAR_BOOL', { v_bool = eval.kBoolVarTrue } },
+ [false] = { 'VAR_BOOL', { v_bool = eval.kBoolVarFalse } },
}
for k, v in pairs(special_vals) do
@@ -382,9 +394,9 @@ lua2typvalt = function(l, processed)
end
end
elseif type(l) == 'number' then
- return typvalt(eval.VAR_FLOAT, {v_float=l})
+ return typvalt(eval.VAR_FLOAT, { v_float = l })
elseif type(l) == 'string' then
- return typvalt(eval.VAR_STRING, {v_string=eval.xmemdupz(to_cstr(l), #l)})
+ return typvalt(eval.VAR_STRING, { v_string = eval.xmemdupz(to_cstr(l), #l) })
elseif type(l) == 'cdata' then
local tv = typvalt(eval.VAR_UNKNOWN)
eval.tv_copy(l, tv)
@@ -408,43 +420,64 @@ local function alloc_len(len, get_ptr)
end
local alloc_logging_helpers = {
- list = function(l) return {func='calloc', args={1, ffi.sizeof('list_T')}, ret=void(l)} end,
- li = function(li) return {func='malloc', args={ffi.sizeof('listitem_T')}, ret=void(li)} end,
- dict = function(d) return {func='calloc', args={1, ffi.sizeof('dict_T')}, ret=void(d)} end,
+ list = function(l)
+ return { func = 'calloc', args = { 1, ffi.sizeof('list_T') }, ret = void(l) }
+ end,
+ li = function(li)
+ return { func = 'malloc', args = { ffi.sizeof('listitem_T') }, ret = void(li) }
+ end,
+ dict = function(d)
+ return { func = 'calloc', args = { 1, ffi.sizeof('dict_T') }, ret = void(d) }
+ end,
di = function(di, size)
- size = alloc_len(size, function() return di.di_key end)
- return {func='malloc', args={ffi.offsetof('dictitem_T', 'di_key') + size + 1}, ret=void(di)}
+ size = alloc_len(size, function()
+ return di.di_key
+ end)
+ return {
+ func = 'malloc',
+ args = { ffi.offsetof('dictitem_T', 'di_key') + size + 1 },
+ ret = void(di),
+ }
end,
str = function(s, size)
- size = alloc_len(size, function() return s end)
- return {func='malloc', args={size + 1}, ret=void(s)}
+ size = alloc_len(size, function()
+ return s
+ end)
+ return { func = 'malloc', args = { size + 1 }, ret = void(s) }
end,
- dwatcher = function(w) return {func='malloc', args={ffi.sizeof('DictWatcher')}, ret=void(w)} end,
+ dwatcher = function(w)
+ return { func = 'malloc', args = { ffi.sizeof('DictWatcher') }, ret = void(w) }
+ end,
- freed = function(p) return {func='free', args={type(p) == 'table' and p or void(p)}} end,
+ freed = function(p)
+ return { func = 'free', args = { type(p) == 'table' and p or void(p) } }
+ end,
-- lua_…: allocated by this file, not by some Neovim function
- lua_pt = function(pt) return {func='calloc', args={1, ffi.sizeof('partial_T')}, ret=void(pt)} end,
+ lua_pt = function(pt)
+ return { func = 'calloc', args = { 1, ffi.sizeof('partial_T') }, ret = void(pt) }
+ end,
lua_tvs = function(argv, argc)
argc = alloc_len(argc)
- return {func='malloc', args={ffi.sizeof('typval_T')*argc}, ret=void(argv)}
+ return { func = 'malloc', args = { ffi.sizeof('typval_T') * argc }, ret = void(argv) }
end,
}
local function int(n)
- return {[type_key]=int_type, value=n}
+ return { [type_key] = int_type, value = n }
end
local function list(...)
- return populate_list(ffi.gc(eval.tv_list_alloc(select('#', ...)),
- eval.tv_list_unref),
- {...}, {})
+ return populate_list(
+ ffi.gc(eval.tv_list_alloc(select('#', ...)), eval.tv_list_unref),
+ { ... },
+ {}
+ )
end
local function dict(d)
- return populate_dict(ffi.gc(eval.tv_dict_alloc(), eval.tv_dict_free),
- d or {}, {})
+ return populate_dict(ffi.gc(eval.tv_dict_alloc(), eval.tv_dict_free), d or {}, {})
end
local callback2tbl_type_tab = nil
@@ -454,14 +487,16 @@ local function init_callback2tbl_type_tab()
return
end
callback2tbl_type_tab = {
- [tonumber(eval.kCallbackNone)] = function(_) return {type='none'} end,
+ [tonumber(eval.kCallbackNone)] = function(_)
+ return { type = 'none' }
+ end,
[tonumber(eval.kCallbackFuncref)] = function(cb)
- return {type='fref', fref=ffi.string(cb.data.funcref)}
+ return { type = 'fref', fref = ffi.string(cb.data.funcref) }
end,
[tonumber(eval.kCallbackPartial)] = function(cb)
local lua_pt = partial2lua(cb.data.partial)
- return {type='pt', fref=ffi.string(lua_pt.value), pt=lua_pt}
- end
+ return { type = 'pt', fref = ffi.string(lua_pt.value), pt = lua_pt }
+ end,
}
end
@@ -473,15 +508,18 @@ end
local function tbl2callback(tbl)
local ret = nil
if tbl.type == 'none' then
- ret = ffi.new('Callback[1]', {{type=eval.kCallbackNone}})
+ ret = ffi.new('Callback[1]', { { type = eval.kCallbackNone } })
elseif tbl.type == 'fref' then
- ret = ffi.new('Callback[1]', {{type=eval.kCallbackFuncref,
- data={funcref=eval.xstrdup(tbl.fref)}}})
+ ret = ffi.new(
+ 'Callback[1]',
+ { { type = eval.kCallbackFuncref, data = { funcref = eval.xstrdup(tbl.fref) } } }
+ )
elseif tbl.type == 'pt' then
- local pt = ffi.gc(ffi.cast('partial_T*',
- eval.xcalloc(1, ffi.sizeof('partial_T'))), nil)
- ret = ffi.new('Callback[1]', {{type=eval.kCallbackPartial,
- data={partial=populate_partial(pt, tbl.pt, {})}}})
+ local pt = ffi.gc(ffi.cast('partial_T*', eval.xcalloc(1, ffi.sizeof('partial_T'))), nil)
+ ret = ffi.new(
+ 'Callback[1]',
+ { { type = eval.kCallbackPartial, data = { partial = populate_partial(pt, tbl.pt, {}) } } }
+ )
else
assert(false)
end
@@ -495,24 +533,23 @@ local function dict_watchers(d)
local qs = {}
local key_patterns = {}
while q ~= h do
- local qitem = ffi.cast('DictWatcher *',
- ffi.cast('char *', q) - ffi.offsetof('DictWatcher', 'node'))
+ local qitem =
+ ffi.cast('DictWatcher *', ffi.cast('char *', q) - ffi.offsetof('DictWatcher', 'node'))
ret[#ret + 1] = {
- cb=callback2tbl(qitem.callback),
- pat=ffi.string(qitem.key_pattern, qitem.key_pattern_len),
- busy=qitem.busy,
+ cb = callback2tbl(qitem.callback),
+ pat = ffi.string(qitem.key_pattern, qitem.key_pattern_len),
+ busy = qitem.busy,
}
qs[#qs + 1] = qitem
- key_patterns[#key_patterns + 1] = {qitem.key_pattern, qitem.key_pattern_len}
+ key_patterns[#key_patterns + 1] = { qitem.key_pattern, qitem.key_pattern_len }
q = q.next
end
return ret, qs, key_patterns
end
local function eval0(expr)
- local tv = ffi.gc(ffi.new('typval_T', {v_type=eval.VAR_UNKNOWN}),
- eval.tv_clear)
- local evalarg = ffi.new('evalarg_T', {eval_flags = eval.EVAL_EVALUATE})
+ local tv = ffi.gc(ffi.new('typval_T', { v_type = eval.VAR_UNKNOWN }), eval.tv_clear)
+ local evalarg = ffi.new('evalarg_T', { eval_flags = eval.EVAL_EVALUATE })
if eval.eval0(to_cstr(expr), tv, nil, evalarg) == 0 then
return nil
else
@@ -521,49 +558,49 @@ local function eval0(expr)
end
return {
- int=int,
+ int = int,
- null_string=null_string,
- null_list=null_list,
- null_dict=null_dict,
- list_type=list_type,
- dict_type=dict_type,
- func_type=func_type,
- int_type=int_type,
- flt_type=flt_type,
+ null_string = null_string,
+ null_list = null_list,
+ null_dict = null_dict,
+ list_type = list_type,
+ dict_type = dict_type,
+ func_type = func_type,
+ int_type = int_type,
+ flt_type = flt_type,
- nil_value=nil_value,
+ nil_value = nil_value,
- type_key=type_key,
- locks_key=locks_key,
+ type_key = type_key,
+ locks_key = locks_key,
- list=list,
- dict=dict,
- lst2tbl=lst2tbl,
- dct2tbl=dct2tbl,
+ list = list,
+ dict = dict,
+ lst2tbl = lst2tbl,
+ dct2tbl = dct2tbl,
- lua2typvalt=lua2typvalt,
- typvalt2lua=typvalt2lua,
+ lua2typvalt = lua2typvalt,
+ typvalt2lua = typvalt2lua,
- typvalt=typvalt,
+ typvalt = typvalt,
- li_alloc=li_alloc,
- tv_list_item_free=tv_list_item_free,
+ li_alloc = li_alloc,
+ tv_list_item_free = tv_list_item_free,
- dict_iter=dict_iter,
- list_iter=list_iter,
- first_di=first_di,
+ dict_iter = dict_iter,
+ list_iter = list_iter,
+ first_di = first_di,
- alloc_logging_helpers=alloc_logging_helpers,
+ alloc_logging_helpers = alloc_logging_helpers,
- list_items=list_items,
- dict_items=dict_items,
+ list_items = list_items,
+ dict_items = dict_items,
- dict_watchers=dict_watchers,
- tbl2callback=tbl2callback,
- callback2tbl=callback2tbl,
+ dict_watchers = dict_watchers,
+ tbl2callback = tbl2callback,
+ callback2tbl = callback2tbl,
- eval0=eval0,
+ eval0 = eval0,
- empty_list = {[type_key]=list_type},
+ empty_list = { [type_key] = list_type },
}
diff --git a/test/unit/eval/tricks_spec.lua b/test/unit/eval/tricks_spec.lua
index 7aa0f0f6e6..ed26fd44e4 100644
--- a/test/unit/eval/tricks_spec.lua
+++ b/test/unit/eval/tricks_spec.lua
@@ -8,8 +8,7 @@ local eq = helpers.eq
local eval0 = eval_helpers.eval0
-local eval = cimport('./src/nvim/eval.h', './src/nvim/eval/typval.h',
- './src/nvim/memory.h')
+local eval = cimport('./src/nvim/eval.h', './src/nvim/eval/typval.h', './src/nvim/memory.h')
describe('NULL typval_T', function()
itp('is produced by $XXX_UNEXISTENT_VAR_XXX', function()
diff --git a/test/unit/eval/tv_clear_spec.lua b/test/unit/eval/tv_clear_spec.lua
index ca37301b32..a34cf6082a 100644
--- a/test/unit/eval/tv_clear_spec.lua
+++ b/test/unit/eval/tv_clear_spec.lua
@@ -28,8 +28,8 @@ end)
describe('tv_clear()', function()
itp('successfully frees all lists in [&l [1], *l, *l]', function()
- local l_inner = {1}
- local list = {l_inner, l_inner, l_inner}
+ local l_inner = { 1 }
+ local list = { l_inner, l_inner, l_inner }
local list_tv = ffi.gc(lua2typvalt(list), nil)
local list_p = list_tv.vval.v_list
local lis = list_items(list_p)
@@ -55,8 +55,8 @@ describe('tv_clear()', function()
})
end)
itp('successfully frees all lists in [&l [], *l, *l]', function()
- local l_inner = {[type_key]=list_type}
- local list = {l_inner, l_inner, l_inner}
+ local l_inner = { [type_key] = list_type }
+ local list = { l_inner, l_inner, l_inner }
local list_tv = ffi.gc(lua2typvalt(list), nil)
local list_p = list_tv.vval.v_list
local lis = list_items(list_p)
@@ -80,7 +80,7 @@ describe('tv_clear()', function()
end)
itp('successfully frees all dictionaries in [&d {}, *d]', function()
local d_inner = {}
- local list = {d_inner, d_inner}
+ local list = { d_inner, d_inner }
local list_tv = ffi.gc(lua2typvalt(list), nil)
local list_p = list_tv.vval.v_list
local lis = list_items(list_p)
@@ -101,8 +101,8 @@ describe('tv_clear()', function()
})
end)
itp('successfully frees all dictionaries in [&d {a: 1}, *d]', function()
- local d_inner = {a=1}
- local list = {d_inner, d_inner}
+ local d_inner = { a = 1 }
+ local list = { d_inner, d_inner }
local list_tv = ffi.gc(lua2typvalt(list), nil)
local list_p = list_tv.vval.v_list
local lis = list_items(list_p)
diff --git a/test/unit/eval/typval_spec.lua b/test/unit/eval/typval_spec.lua
index 34a1299725..da70b8feba 100644
--- a/test/unit/eval/typval_spec.lua
+++ b/test/unit/eval/typval_spec.lua
@@ -41,21 +41,25 @@ local callback2tbl = eval_helpers.callback2tbl
local tbl2callback = eval_helpers.tbl2callback
local dict_watchers = eval_helpers.dict_watchers
-local lib = cimport('./src/nvim/eval/typval.h', './src/nvim/memory.h',
- './src/nvim/mbyte.h', './src/nvim/garray.h',
- './src/nvim/eval.h', './src/nvim/vim_defs.h',
- './src/nvim/globals.h')
+local lib = cimport(
+ './src/nvim/eval/typval.h',
+ './src/nvim/memory.h',
+ './src/nvim/mbyte.h',
+ './src/nvim/garray.h',
+ './src/nvim/eval.h',
+ './src/nvim/vim_defs.h',
+ './src/nvim/globals.h'
+)
local function vimconv_alloc()
- return ffi.gc(
- ffi.cast('vimconv_T*', lib.xcalloc(1, ffi.sizeof('vimconv_T'))), function(vc)
- lib.convert_setup(vc, nil, nil)
- lib.xfree(vc)
- end)
+ return ffi.gc(ffi.cast('vimconv_T*', lib.xcalloc(1, ffi.sizeof('vimconv_T'))), function(vc)
+ lib.convert_setup(vc, nil, nil)
+ lib.xfree(vc)
+ end)
end
local function list_watch_alloc(li)
- return ffi.cast('listwatch_T*', ffi.new('listwatch_T[1]', {{lw_item=li}}))
+ return ffi.cast('listwatch_T*', ffi.new('listwatch_T[1]', { { lw_item = li } }))
end
local function list_watch(l, li)
@@ -66,12 +70,14 @@ end
local function get_alloc_rets(exp_log, res)
setmetatable(res, {
- __index={
- freed=function(r, n) return {func='free', args={r[n]}} end
- }
+ __index = {
+ freed = function(r, n)
+ return { func = 'free', args = { r[n] } }
+ end,
+ },
})
- for i = 1,#exp_log do
- if ({malloc=true, calloc=true})[exp_log[i].func] then
+ for i = 1, #exp_log do
+ if ({ malloc = true, calloc = true })[exp_log[i].func] then
res[#res + 1] = exp_log[i].ret
end
end
@@ -89,8 +95,7 @@ after_each(function()
end)
local function ga_alloc(itemsize, growsize)
- local ga = ffi.gc(ffi.cast('garray_T*', ffi.new('garray_T[1]', {})),
- lib.ga_clear)
+ local ga = ffi.gc(ffi.cast('garray_T*', ffi.new('garray_T[1]', {})), lib.ga_clear)
lib.ga_init(ga, itemsize or 1, growsize or 80)
return ga
end
@@ -100,7 +105,7 @@ local function check_emsg(f, msg)
if saved_last_msg_hist == nil then
saved_last_msg_hist = nil
end
- local ret = {f()}
+ local ret = { f() }
local last_msg = lib.last_msg_hist ~= nil and ffi.string(lib.last_msg_hist.msg) or nil
if msg ~= nil then
eq(msg, last_msg)
@@ -167,8 +172,9 @@ describe('typval.c', function()
a.str(lis[4].li_tv.vval.v_string, 1),
a.li(lis[4]),
})
- local strings = map(function(li) return li.li_tv.vval.v_string end,
- lis)
+ local strings = map(function(li)
+ return li.li_tv.vval.v_string
+ end, lis)
eq(lis[2], lib.tv_list_item_remove(l, lis[1]))
alloc_log:check({
@@ -213,20 +219,26 @@ describe('typval.c', function()
})
eq(lis[5], lib.tv_list_item_remove(l, lis[4]))
- alloc_log:check({a.freed(lis[4])})
- eq({lis[1], lis[5], lis[7]}, {lws[1].lw_item, lws[2].lw_item, lws[3].lw_item})
+ alloc_log:check({ a.freed(lis[4]) })
+ eq({ lis[1], lis[5], lis[7] }, { lws[1].lw_item, lws[2].lw_item, lws[3].lw_item })
eq(lis[3], lib.tv_list_item_remove(l, lis[2]))
- alloc_log:check({a.freed(lis[2])})
- eq({lis[1], lis[5], lis[7]}, {lws[1].lw_item, lws[2].lw_item, lws[3].lw_item})
+ alloc_log:check({ a.freed(lis[2]) })
+ eq({ lis[1], lis[5], lis[7] }, { lws[1].lw_item, lws[2].lw_item, lws[3].lw_item })
eq(nil, lib.tv_list_item_remove(l, lis[7]))
- alloc_log:check({a.freed(lis[7])})
- eq({lis[1], lis[5], nil}, {lws[1].lw_item, lws[2].lw_item, lws[3].lw_item == nil and nil})
+ alloc_log:check({ a.freed(lis[7]) })
+ eq(
+ { lis[1], lis[5], nil },
+ { lws[1].lw_item, lws[2].lw_item, lws[3].lw_item == nil and nil }
+ )
eq(lis[3], lib.tv_list_item_remove(l, lis[1]))
- alloc_log:check({a.freed(lis[1])})
- eq({lis[3], lis[5], nil}, {lws[1].lw_item, lws[2].lw_item, lws[3].lw_item == nil and nil})
+ alloc_log:check({ a.freed(lis[1]) })
+ eq(
+ { lis[3], lis[5], nil },
+ { lws[1].lw_item, lws[2].lw_item, lws[3].lw_item == nil and nil }
+ )
lib.tv_list_watch_remove(l, lws[2])
lib.tv_list_watch_remove(l, lws[3])
@@ -285,7 +297,7 @@ describe('typval.c', function()
alloc_log:check(get_alloc_rets({
a.list(l1),
a.li(l1.lv_first),
- a.str(l1.lv_last.li_tv.vval.v_string, #('abc')),
+ a.str(l1.lv_last.li_tv.vval.v_string, #'abc'),
a.li(l1.lv_last),
a.list(l2),
a.dict(l2.lv_first.li_tv.vval.v_dict),
@@ -324,7 +336,7 @@ describe('typval.c', function()
alloc_log:check(get_alloc_rets({
a.list(l1),
a.li(l1.lv_first),
- a.str(l1.lv_last.li_tv.vval.v_string, #('abc')),
+ a.str(l1.lv_last.li_tv.vval.v_string, #'abc'),
a.li(l1.lv_last),
a.list(l2),
a.dict(l2.lv_first.li_tv.vval.v_dict),
@@ -348,8 +360,7 @@ describe('typval.c', function()
end)
end)
describe('free_contents()', function()
- itp('recursively frees list, except for the list structure itself',
- function()
+ itp('recursively frees list, except for the list structure itself', function()
local l1 = ffi.gc(list(1, 'abc'), nil)
local l2 = ffi.gc(list({}), nil)
local l3 = ffi.gc(list(empty_list), nil)
@@ -357,7 +368,7 @@ describe('typval.c', function()
alloc_log:check(get_alloc_rets({
a.list(l1),
a.li(l1.lv_first),
- a.str(l1.lv_last.li_tv.vval.v_string, #('abc')),
+ a.str(l1.lv_last.li_tv.vval.v_string, #'abc'),
a.li(l1.lv_last),
a.list(l2),
a.dict(l2.lv_first.li_tv.vval.v_dict),
@@ -406,7 +417,7 @@ describe('typval.c', function()
end)
describe('drop_items()', function()
itp('works', function()
- local l_tv = lua2typvalt({1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13})
+ local l_tv = lua2typvalt({ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 })
local l = l_tv.vval.v_list
local lis = list_items(l)
-- Three watchers: pointing to first, middle and last elements.
@@ -418,20 +429,29 @@ describe('typval.c', function()
alloc_log:clear()
lib.tv_list_drop_items(l, lis[1], lis[3])
- eq({4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, typvalt2lua(l_tv))
- eq({lis[4], lis[7], lis[13]}, {lws[1].lw_item, lws[2].lw_item, lws[3].lw_item})
+ eq({ 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 }, typvalt2lua(l_tv))
+ eq({ lis[4], lis[7], lis[13] }, { lws[1].lw_item, lws[2].lw_item, lws[3].lw_item })
lib.tv_list_drop_items(l, lis[11], lis[13])
- eq({4, 5, 6, 7, 8, 9, 10}, typvalt2lua(l_tv))
- eq({lis[4], lis[7], nil}, {lws[1].lw_item, lws[2].lw_item, lws[3].lw_item == nil and nil})
+ eq({ 4, 5, 6, 7, 8, 9, 10 }, typvalt2lua(l_tv))
+ eq(
+ { lis[4], lis[7], nil },
+ { lws[1].lw_item, lws[2].lw_item, lws[3].lw_item == nil and nil }
+ )
lib.tv_list_drop_items(l, lis[6], lis[8])
- eq({4, 5, 9, 10}, typvalt2lua(l_tv))
- eq({lis[4], lis[9], nil}, {lws[1].lw_item, lws[2].lw_item, lws[3].lw_item == nil and nil})
+ eq({ 4, 5, 9, 10 }, typvalt2lua(l_tv))
+ eq(
+ { lis[4], lis[9], nil },
+ { lws[1].lw_item, lws[2].lw_item, lws[3].lw_item == nil and nil }
+ )
lib.tv_list_drop_items(l, lis[4], lis[10])
eq(empty_list, typvalt2lua(l_tv))
- eq({true, true, true}, {lws[1].lw_item == nil, lws[2].lw_item == nil, lws[3].lw_item == nil})
+ eq(
+ { true, true, true },
+ { lws[1].lw_item == nil, lws[2].lw_item == nil, lws[3].lw_item == nil }
+ )
lib.tv_list_watch_remove(l, lws[1])
lib.tv_list_watch_remove(l, lws[2])
@@ -442,10 +462,13 @@ describe('typval.c', function()
end)
describe('remove_items()', function()
itp('works', function()
- local l_tv = lua2typvalt({'1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13'})
+ local l_tv =
+ lua2typvalt({ '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13' })
local l = l_tv.vval.v_list
local lis = list_items(l)
- local strings = map(function(li) return li.li_tv.vval.v_string end, lis)
+ local strings = map(function(li)
+ return li.li_tv.vval.v_string
+ end, lis)
-- Three watchers: pointing to first, middle and last elements.
local lws = {
list_watch(l, lis[1]),
@@ -455,8 +478,8 @@ describe('typval.c', function()
alloc_log:clear()
lib.tv_list_remove_items(l, lis[1], lis[3])
- eq({'4', '5', '6', '7', '8', '9', '10', '11', '12', '13'}, typvalt2lua(l_tv))
- eq({lis[4], lis[7], lis[13]}, {lws[1].lw_item, lws[2].lw_item, lws[3].lw_item})
+ eq({ '4', '5', '6', '7', '8', '9', '10', '11', '12', '13' }, typvalt2lua(l_tv))
+ eq({ lis[4], lis[7], lis[13] }, { lws[1].lw_item, lws[2].lw_item, lws[3].lw_item })
alloc_log:check({
a.freed(strings[1]),
a.freed(lis[1]),
@@ -467,8 +490,11 @@ describe('typval.c', function()
})
lib.tv_list_remove_items(l, lis[11], lis[13])
- eq({'4', '5', '6', '7', '8', '9', '10'}, typvalt2lua(l_tv))
- eq({lis[4], lis[7], nil}, {lws[1].lw_item, lws[2].lw_item, lws[3].lw_item == nil and nil})
+ eq({ '4', '5', '6', '7', '8', '9', '10' }, typvalt2lua(l_tv))
+ eq(
+ { lis[4], lis[7], nil },
+ { lws[1].lw_item, lws[2].lw_item, lws[3].lw_item == nil and nil }
+ )
alloc_log:check({
a.freed(strings[11]),
a.freed(lis[11]),
@@ -479,8 +505,11 @@ describe('typval.c', function()
})
lib.tv_list_remove_items(l, lis[6], lis[8])
- eq({'4', '5', '9', '10'}, typvalt2lua(l_tv))
- eq({lis[4], lis[9], nil}, {lws[1].lw_item, lws[2].lw_item, lws[3].lw_item == nil and nil})
+ eq({ '4', '5', '9', '10' }, typvalt2lua(l_tv))
+ eq(
+ { lis[4], lis[9], nil },
+ { lws[1].lw_item, lws[2].lw_item, lws[3].lw_item == nil and nil }
+ )
alloc_log:check({
a.freed(strings[6]),
a.freed(lis[6]),
@@ -492,7 +521,10 @@ describe('typval.c', function()
lib.tv_list_remove_items(l, lis[4], lis[10])
eq(empty_list, typvalt2lua(l_tv))
- eq({true, true, true}, {lws[1].lw_item == nil, lws[2].lw_item == nil, lws[3].lw_item == nil})
+ eq(
+ { true, true, true },
+ { lws[1].lw_item == nil, lws[2].lw_item == nil, lws[3].lw_item == nil }
+ )
alloc_log:check({
a.freed(strings[4]),
a.freed(lis[4]),
@@ -514,28 +546,28 @@ describe('typval.c', function()
describe('insert', function()
describe('()', function()
itp('works', function()
- local l_tv = lua2typvalt({1, 2, 3, 4, 5, 6, 7})
+ local l_tv = lua2typvalt({ 1, 2, 3, 4, 5, 6, 7 })
local l = l_tv.vval.v_list
local lis = list_items(l)
local li
li = li_alloc(true)
- li.li_tv = {v_type=lib.VAR_FLOAT, vval={v_float=100500}}
+ li.li_tv = { v_type = lib.VAR_FLOAT, vval = { v_float = 100500 } }
lib.tv_list_insert(l, li, nil)
eq(l.lv_last, li)
- eq({1, 2, 3, 4, 5, 6, 7, 100500}, typvalt2lua(l_tv))
+ eq({ 1, 2, 3, 4, 5, 6, 7, 100500 }, typvalt2lua(l_tv))
li = li_alloc(true)
- li.li_tv = {v_type=lib.VAR_FLOAT, vval={v_float=0}}
+ li.li_tv = { v_type = lib.VAR_FLOAT, vval = { v_float = 0 } }
lib.tv_list_insert(l, li, lis[1])
eq(l.lv_first, li)
- eq({0, 1, 2, 3, 4, 5, 6, 7, 100500}, typvalt2lua(l_tv))
+ eq({ 0, 1, 2, 3, 4, 5, 6, 7, 100500 }, typvalt2lua(l_tv))
li = li_alloc(true)
- li.li_tv = {v_type=lib.VAR_FLOAT, vval={v_float=4.5}}
+ li.li_tv = { v_type = lib.VAR_FLOAT, vval = { v_float = 4.5 } }
lib.tv_list_insert(l, li, lis[5])
eq(list_items(l)[6], li)
- eq({0, 1, 2, 3, 4, 4.5, 5, 6, 7, 100500}, typvalt2lua(l_tv))
+ eq({ 0, 1, 2, 3, 4, 4.5, 5, 6, 7, 100500 }, typvalt2lua(l_tv))
end)
itp('works with an empty list', function()
local l_tv = lua2typvalt(empty_list)
@@ -545,10 +577,10 @@ describe('typval.c', function()
eq(nil, l.lv_last)
local li = li_alloc(true)
- li.li_tv = {v_type=lib.VAR_FLOAT, vval={v_float=100500}}
+ li.li_tv = { v_type = lib.VAR_FLOAT, vval = { v_float = 100500 } }
lib.tv_list_insert(l, li, nil)
eq(l.lv_last, li)
- eq({100500}, typvalt2lua(l_tv))
+ eq({ 100500 }, typvalt2lua(l_tv))
end)
end)
describe('tv()', function()
@@ -577,7 +609,7 @@ describe('typval.c', function()
a.str(l.lv_first.li_tv.vval.v_string, 'test'),
})
- eq({'test', empty_list}, typvalt2lua(l_tv))
+ eq({ 'test', empty_list }, typvalt2lua(l_tv))
end)
end)
end)
@@ -602,7 +634,7 @@ describe('typval.c', function()
a.li(l.lv_last),
})
- eq({{1}, null_list}, typvalt2lua(l_tv))
+ eq({ { 1 }, null_list }, typvalt2lua(l_tv))
end)
end)
describe('dict()', function()
@@ -610,7 +642,7 @@ describe('typval.c', function()
local l_tv = lua2typvalt(empty_list)
local l = l_tv.vval.v_list
- local l_d_tv = lua2typvalt({test=1})
+ local l_d_tv = lua2typvalt({ test = 1 })
local l_d = l_d_tv.vval.v_dict
alloc_log:clear()
eq(1, l_d.dv_refcount)
@@ -626,7 +658,7 @@ describe('typval.c', function()
a.li(l.lv_last),
})
- eq({{test=1}, null_dict}, typvalt2lua(l_tv))
+ eq({ { test = 1 }, null_dict }, typvalt2lua(l_tv))
end)
end)
describe('string()', function()
@@ -657,7 +689,7 @@ describe('typval.c', function()
a.li(l.lv_last),
})
- eq({'tes', null_string, null_string, 'test'}, typvalt2lua(l_tv))
+ eq({ 'tes', null_string, null_string, 'test' }, typvalt2lua(l_tv))
end)
end)
describe('allocated string()', function()
@@ -682,7 +714,7 @@ describe('typval.c', function()
a.li(l.lv_last),
})
- eq({'test', null_string, null_string}, typvalt2lua(l_tv))
+ eq({ 'test', null_string, null_string }, typvalt2lua(l_tv))
end)
end)
describe('number()', function()
@@ -701,7 +733,7 @@ describe('typval.c', function()
a.li(l.lv_last),
})
- eq({int(-100500), int(100500)}, typvalt2lua(l_tv))
+ eq({ int(-100500), int(100500) }, typvalt2lua(l_tv))
end)
end)
describe('tv()', function()
@@ -730,7 +762,7 @@ describe('typval.c', function()
a.str(l.lv_last.li_tv.vval.v_string, 'test'),
})
- eq({empty_list, 'test'}, typvalt2lua(l_tv))
+ eq({ empty_list, 'test' }, typvalt2lua(l_tv))
end)
end)
describe('owned tv()', function()
@@ -761,7 +793,7 @@ describe('typval.c', function()
a.li(l.lv_last),
})
- eq({empty_list, 'test'}, typvalt2lua(l_tv))
+ eq({ empty_list, 'test' }, typvalt2lua(l_tv))
end)
end)
end)
@@ -777,7 +809,7 @@ describe('typval.c', function()
end)
itp('copies list correctly without converting items', function()
do
- local v = {{['«']='»'}, {'„'}, 1, '“', null_string, null_list, null_dict}
+ local v = { { ['«'] = '»' }, { '„' }, 1, '“', null_string, null_list, null_dict }
local l_tv = lua2typvalt(v)
local l = l_tv.vval.v_list
local lis = list_items(l)
@@ -821,7 +853,7 @@ describe('typval.c', function()
a.list(l_deepcopy1),
a.li(lis_deepcopy1[1]),
a.dict(lis_deepcopy1[1].li_tv.vval.v_dict),
- a.di(di_deepcopy1, #('«')),
+ a.di(di_deepcopy1, #'«'),
a.str(di_deepcopy1.di_tv.vval.v_string, #v[1]['«']),
a.li(lis_deepcopy1[2]),
a.list(lis_deepcopy1[2].li_tv.vval.v_list),
@@ -842,7 +874,7 @@ describe('typval.c', function()
-- UTF-8 ↔ latin1 conversions needs no iconv
eq(OK, lib.convert_setup(vc, to_cstr('utf-8'), to_cstr('latin1')))
- local v = {{['«']='»'}, {'„'}, 1, '“', null_string, null_list, null_dict}
+ local v = { { ['«'] = '»' }, { '„' }, 1, '“', null_string, null_list, null_dict }
local l_tv = lua2typvalt(v)
local l = l_tv.vval.v_list
local lis = list_items(l)
@@ -857,8 +889,10 @@ describe('typval.c', function()
local lis_deepcopy1 = list_items(l_deepcopy1)
neq(lis[1].li_tv.vval.v_dict, lis_deepcopy1[1].li_tv.vval.v_dict)
neq(lis[2].li_tv.vval.v_list, lis_deepcopy1[2].li_tv.vval.v_list)
- eq({{['\171']='\187'}, {'\191'}, 1, '\191', null_string, null_list, null_dict},
- lst2tbl(l_deepcopy1))
+ eq(
+ { { ['\171'] = '\187' }, { '\191' }, 1, '\191', null_string, null_list, null_dict },
+ lst2tbl(l_deepcopy1)
+ )
local di_deepcopy1 = first_di(lis_deepcopy1[1].li_tv.vval.v_dict)
alloc_log:clear_tmp_allocs()
alloc_log:check({
@@ -881,18 +915,18 @@ describe('typval.c', function()
end)
itp('returns different/same containers with(out) copyID', function()
local l_inner_tv = lua2typvalt(empty_list)
- local l_tv = lua2typvalt({l_inner_tv, l_inner_tv})
+ local l_tv = lua2typvalt({ l_inner_tv, l_inner_tv })
eq(3, l_inner_tv.vval.v_list.lv_refcount)
local l = l_tv.vval.v_list
eq(l.lv_first.li_tv.vval.v_list, l.lv_last.li_tv.vval.v_list)
local l_copy1 = tv_list_copy(nil, l, true, 0)
neq(l_copy1.lv_first.li_tv.vval.v_list, l_copy1.lv_last.li_tv.vval.v_list)
- eq({empty_list, empty_list}, lst2tbl(l_copy1))
+ eq({ empty_list, empty_list }, lst2tbl(l_copy1))
local l_copy2 = tv_list_copy(nil, l, true, 2)
eq(l_copy2.lv_first.li_tv.vval.v_list, l_copy2.lv_last.li_tv.vval.v_list)
- eq({empty_list, empty_list}, lst2tbl(l_copy2))
+ eq({ empty_list, empty_list }, lst2tbl(l_copy2))
eq(3, l_inner_tv.vval.v_list.lv_refcount)
end)
@@ -934,7 +968,7 @@ describe('typval.c', function()
})
eq(1, l.lv_refcount)
eq(2, l.lv_last.li_tv.vval.v_dict.dv_refcount)
- eq({1, {}, 1, {}}, lst2tbl(l))
+ eq({ 1, {}, 1, {} }, lst2tbl(l))
l = list(1, {})
alloc_log:clear()
@@ -946,7 +980,7 @@ describe('typval.c', function()
a.li(l.lv_last.li_prev.li_prev),
a.li(l.lv_last.li_prev),
})
- eq({1, 1, {}, {}}, lst2tbl(l))
+ eq({ 1, 1, {}, {} }, lst2tbl(l))
eq(1, l.lv_refcount)
eq(2, l.lv_last.li_tv.vval.v_dict.dv_refcount)
@@ -960,7 +994,7 @@ describe('typval.c', function()
a.li(l.lv_first),
a.li(l.lv_first.li_next),
})
- eq({1, {}, 1, {}}, lst2tbl(l))
+ eq({ 1, {}, 1, {} }, lst2tbl(l))
eq(1, l.lv_refcount)
eq(2, l.lv_last.li_tv.vval.v_dict.dv_refcount)
end)
@@ -973,28 +1007,25 @@ describe('typval.c', function()
eq(1, el.lv_refcount)
lib.tv_list_extend(l, el, nil)
- alloc_log:check({
- })
+ alloc_log:check({})
eq(1, l.lv_refcount)
eq(1, l.lv_last.li_tv.vval.v_dict.dv_refcount)
eq(1, el.lv_refcount)
- eq({1, {}}, lst2tbl(l))
+ eq({ 1, {} }, lst2tbl(l))
lib.tv_list_extend(l, el, l.lv_first)
- alloc_log:check({
- })
+ alloc_log:check({})
eq(1, l.lv_refcount)
eq(1, l.lv_last.li_tv.vval.v_dict.dv_refcount)
eq(1, el.lv_refcount)
- eq({1, {}}, lst2tbl(l))
+ eq({ 1, {} }, lst2tbl(l))
lib.tv_list_extend(l, el, l.lv_last)
- alloc_log:check({
- })
+ alloc_log:check({})
eq(1, l.lv_refcount)
eq(1, l.lv_last.li_tv.vval.v_dict.dv_refcount)
eq(1, el.lv_refcount)
- eq({1, {}}, lst2tbl(l))
+ eq({ 1, {} }, lst2tbl(l))
end)
itp('can extend list with another non-empty list', function()
local l
@@ -1014,7 +1045,7 @@ describe('typval.c', function()
})
eq(1, l2.lv_refcount)
eq(2, l2.lv_last.li_tv.vval.v_list.lv_refcount)
- eq({1, {}, 42, empty_list}, lst2tbl(l))
+ eq({ 1, {}, 42, empty_list }, lst2tbl(l))
lib.tv_list_free(l)
eq(1, l2.lv_last.li_tv.vval.v_list.lv_refcount)
@@ -1030,7 +1061,7 @@ describe('typval.c', function()
})
eq(1, l2.lv_refcount)
eq(2, l2.lv_last.li_tv.vval.v_list.lv_refcount)
- eq({42, empty_list, 1, {}}, lst2tbl(l))
+ eq({ 42, empty_list, 1, {} }, lst2tbl(l))
lib.tv_list_free(l)
eq(1, l2.lv_last.li_tv.vval.v_list.lv_refcount)
@@ -1046,7 +1077,7 @@ describe('typval.c', function()
})
eq(1, l2.lv_refcount)
eq(2, l2.lv_last.li_tv.vval.v_list.lv_refcount)
- eq({1, 42, empty_list, {}}, lst2tbl(l))
+ eq({ 1, 42, empty_list, {} }, lst2tbl(l))
lib.tv_list_free(l)
eq(1, l2.lv_last.li_tv.vval.v_list.lv_refcount)
end)
@@ -1062,7 +1093,7 @@ describe('typval.c', function()
eq(OK, lib.tv_list_concat(nil, l, rettv1))
eq(1, l.lv_refcount)
eq(tonumber(lib.VAR_LIST), tonumber(rettv1.v_type))
- eq({1, {}}, typvalt2lua(rettv1))
+ eq({ 1, {} }, typvalt2lua(rettv1))
eq(1, rettv1.vval.v_list.lv_refcount)
alloc_log:check({
a.list(rettv1.vval.v_list),
@@ -1075,7 +1106,7 @@ describe('typval.c', function()
eq(OK, lib.tv_list_concat(l, nil, rettv2))
eq(1, l.lv_refcount)
eq(tonumber(lib.VAR_LIST), tonumber(rettv2.v_type))
- eq({1, {}}, typvalt2lua(rettv2))
+ eq({ 1, {} }, typvalt2lua(rettv2))
eq(1, rettv2.vval.v_list.lv_refcount)
alloc_log:check({
a.list(rettv2.vval.v_list),
@@ -1112,7 +1143,7 @@ describe('typval.c', function()
a.li(rettv.vval.v_list.lv_last.li_prev),
a.li(rettv.vval.v_list.lv_last),
})
- eq({1, {}, 3, empty_list}, typvalt2lua(rettv))
+ eq({ 1, {}, 3, empty_list }, typvalt2lua(rettv))
end)
itp('can concatenate list with itself', function()
local l = list(1, {})
@@ -1131,7 +1162,7 @@ describe('typval.c', function()
a.li(rettv.vval.v_list.lv_last.li_prev),
a.li(rettv.vval.v_list.lv_last),
})
- eq({1, {}, 1, {}}, typvalt2lua(rettv))
+ eq({ 1, {}, 1, {} }, typvalt2lua(rettv))
end)
itp('can concatenate empty non-NULL lists', function()
local l = list(1, {})
@@ -1154,7 +1185,7 @@ describe('typval.c', function()
a.li(rettv1.vval.v_list.lv_first),
a.li(rettv1.vval.v_list.lv_last),
})
- eq({1, {}}, typvalt2lua(rettv1))
+ eq({ 1, {} }, typvalt2lua(rettv1))
local rettv2 = typvalt()
eq(OK, lib.tv_list_concat(le, l, rettv2))
@@ -1167,7 +1198,7 @@ describe('typval.c', function()
a.li(rettv2.vval.v_list.lv_first),
a.li(rettv2.vval.v_list.lv_last),
})
- eq({1, {}}, typvalt2lua(rettv2))
+ eq({ 1, {} }, typvalt2lua(rettv2))
local rettv3 = typvalt()
eq(OK, lib.tv_list_concat(le, le, rettv3))
@@ -1257,15 +1288,15 @@ describe('typval.c', function()
-- indicates that tv_equal_recurse_limit and recursive_cnt were set which
-- is essential. This argument will be set when comparing inner lists.
itp('compares lists correctly when case is not ignored', function()
- local l1 = list('abc', {1, 2, 'Abc'}, 'def')
- local l2 = list('abc', {1, 2, 'Abc'})
- local l3 = list('abc', {1, 2, 'Abc'}, 'Def')
- local l4 = list('abc', {1, 2, 'Abc', 4}, 'def')
- local l5 = list('Abc', {1, 2, 'Abc'}, 'def')
- local l6 = list('abc', {1, 2, 'Abc'}, 'def')
- local l7 = list('abc', {1, 2, 'abc'}, 'def')
+ local l1 = list('abc', { 1, 2, 'Abc' }, 'def')
+ local l2 = list('abc', { 1, 2, 'Abc' })
+ local l3 = list('abc', { 1, 2, 'Abc' }, 'Def')
+ local l4 = list('abc', { 1, 2, 'Abc', 4 }, 'def')
+ local l5 = list('Abc', { 1, 2, 'Abc' }, 'def')
+ local l6 = list('abc', { 1, 2, 'Abc' }, 'def')
+ local l7 = list('abc', { 1, 2, 'abc' }, 'def')
local l8 = list('abc', nil, 'def')
- local l9 = list('abc', {1, 2, nil}, 'def')
+ local l9 = list('abc', { 1, 2, nil }, 'def')
eq(true, lib.tv_list_equal(l1, l1, false, false))
eq(false, lib.tv_list_equal(l1, l2, false, false))
@@ -1278,15 +1309,15 @@ describe('typval.c', function()
eq(false, lib.tv_list_equal(l1, l9, false, false))
end)
itp('compares lists correctly when case is ignored', function()
- local l1 = list('abc', {1, 2, 'Abc'}, 'def')
- local l2 = list('abc', {1, 2, 'Abc'})
- local l3 = list('abc', {1, 2, 'Abc'}, 'Def')
- local l4 = list('abc', {1, 2, 'Abc', 4}, 'def')
- local l5 = list('Abc', {1, 2, 'Abc'}, 'def')
- local l6 = list('abc', {1, 2, 'Abc'}, 'def')
- local l7 = list('abc', {1, 2, 'abc'}, 'def')
+ local l1 = list('abc', { 1, 2, 'Abc' }, 'def')
+ local l2 = list('abc', { 1, 2, 'Abc' })
+ local l3 = list('abc', { 1, 2, 'Abc' }, 'Def')
+ local l4 = list('abc', { 1, 2, 'Abc', 4 }, 'def')
+ local l5 = list('Abc', { 1, 2, 'Abc' }, 'def')
+ local l6 = list('abc', { 1, 2, 'Abc' }, 'def')
+ local l7 = list('abc', { 1, 2, 'abc' }, 'def')
local l8 = list('abc', nil, 'def')
- local l9 = list('abc', {1, 2, nil}, 'def')
+ local l9 = list('abc', { 1, 2, nil }, 'def')
eq(true, lib.tv_list_equal(l1, l1, true, false))
eq(false, lib.tv_list_equal(l1, l2, true, false))
@@ -1355,7 +1386,7 @@ describe('typval.c', function()
describe('nr()', function()
local function tv_list_find_nr(l, n, msg)
return check_emsg(function()
- local err = ffi.new('bool[1]', {false})
+ local err = ffi.new('bool[1]', { false })
local ret = lib.tv_list_find_nr(l, n, err)
return (err[0] == true), ret
end, msg)
@@ -1364,10 +1395,10 @@ describe('typval.c', function()
local l = list(int(1), int(2), int(3), int(4), int(5))
alloc_log:clear()
- eq({false, 1}, {tv_list_find_nr(l, -5)})
- eq({false, 5}, {tv_list_find_nr(l, 4)})
- eq({false, 3}, {tv_list_find_nr(l, 2)})
- eq({false, 3}, {tv_list_find_nr(l, -3)})
+ eq({ false, 1 }, { tv_list_find_nr(l, -5) })
+ eq({ false, 5 }, { tv_list_find_nr(l, 4) })
+ eq({ false, 3 }, { tv_list_find_nr(l, 2) })
+ eq({ false, 3 }, { tv_list_find_nr(l, -3) })
alloc_log:check({})
end)
@@ -1375,10 +1406,10 @@ describe('typval.c', function()
local l = list('1', '2', '3', '4', '5')
alloc_log:clear()
- eq({false, 1}, {tv_list_find_nr(l, -5)})
- eq({false, 5}, {tv_list_find_nr(l, 4)})
- eq({false, 3}, {tv_list_find_nr(l, 2)})
- eq({false, 3}, {tv_list_find_nr(l, -3)})
+ eq({ false, 1 }, { tv_list_find_nr(l, -5) })
+ eq({ false, 5 }, { tv_list_find_nr(l, 4) })
+ eq({ false, 3 }, { tv_list_find_nr(l, 2) })
+ eq({ false, 3 }, { tv_list_find_nr(l, -3) })
alloc_log:check({})
end)
@@ -1386,15 +1417,15 @@ describe('typval.c', function()
local l = list(null_string)
alloc_log:clear()
- eq({false, 0}, {tv_list_find_nr(l, 0)})
+ eq({ false, 0 }, { tv_list_find_nr(l, 0) })
alloc_log:check({})
end)
itp('errors out on NULL lists', function()
- eq({true, -1}, {tv_list_find_nr(nil, -5)})
- eq({true, -1}, {tv_list_find_nr(nil, 4)})
- eq({true, -1}, {tv_list_find_nr(nil, 2)})
- eq({true, -1}, {tv_list_find_nr(nil, -3)})
+ eq({ true, -1 }, { tv_list_find_nr(nil, -5) })
+ eq({ true, -1 }, { tv_list_find_nr(nil, 4) })
+ eq({ true, -1 }, { tv_list_find_nr(nil, 2) })
+ eq({ true, -1 }, { tv_list_find_nr(nil, -3) })
alloc_log:check({})
end)
@@ -1402,20 +1433,20 @@ describe('typval.c', function()
local l = list(int(1), int(2), int(3), int(4), int(5))
alloc_log:clear()
- eq({true, -1}, {tv_list_find_nr(l, -6)})
- eq({true, -1}, {tv_list_find_nr(l, 5)})
+ eq({ true, -1 }, { tv_list_find_nr(l, -6) })
+ eq({ true, -1 }, { tv_list_find_nr(l, 5) })
alloc_log:check({})
end)
itp('errors out on invalid types', function()
local l = list(1, empty_list, {})
- eq({true, 0}, {tv_list_find_nr(l, 0, 'E805: Using a Float as a Number')})
- eq({true, 0}, {tv_list_find_nr(l, 1, 'E745: Using a List as a Number')})
- eq({true, 0}, {tv_list_find_nr(l, 2, 'E728: Using a Dictionary as a Number')})
- eq({true, 0}, {tv_list_find_nr(l, -1, 'E728: Using a Dictionary as a Number')})
- eq({true, 0}, {tv_list_find_nr(l, -2, 'E745: Using a List as a Number')})
- eq({true, 0}, {tv_list_find_nr(l, -3, 'E805: Using a Float as a Number')})
+ eq({ true, 0 }, { tv_list_find_nr(l, 0, 'E805: Using a Float as a Number') })
+ eq({ true, 0 }, { tv_list_find_nr(l, 1, 'E745: Using a List as a Number') })
+ eq({ true, 0 }, { tv_list_find_nr(l, 2, 'E728: Using a Dictionary as a Number') })
+ eq({ true, 0 }, { tv_list_find_nr(l, -1, 'E728: Using a Dictionary as a Number') })
+ eq({ true, 0 }, { tv_list_find_nr(l, -2, 'E745: Using a List as a Number') })
+ eq({ true, 0 }, { tv_list_find_nr(l, -3, 'E805: Using a Float as a Number') })
end)
end)
local function tv_list_find_str(l, n, msg)
@@ -1439,7 +1470,7 @@ describe('typval.c', function()
eq('3', tv_list_find_str(l, 2))
eq('3', tv_list_find_str(l, -3))
- alloc_log:check({a.freed(alloc_log.null), a.freed(alloc_log.null)})
+ alloc_log:check({ a.freed(alloc_log.null), a.freed(alloc_log.null) })
end)
itp('returns string when used with VAR_STRING items', function()
local l = list('1', '2', '3', '4', '5')
@@ -1499,7 +1530,7 @@ describe('typval.c', function()
itp('works with an empty key', function()
local d = dict({})
eq({}, dict_watchers(d))
- local cb = ffi.gc(tbl2callback({type='none'}), nil)
+ local cb = ffi.gc(tbl2callback({ type = 'none' }), nil)
alloc_log:clear()
lib.tv_dict_watcher_add(d, '*', 0, cb[0])
local ws, qs = dict_watchers(d)
@@ -1508,7 +1539,7 @@ describe('typval.c', function()
a.dwatcher(qs[1]),
a.str(key_p, 0),
})
- eq({{busy=false, cb={type='none'}, pat=''}}, ws)
+ eq({ { busy = false, cb = { type = 'none' }, pat = '' } }, ws)
eq(true, lib.tv_dict_watcher_remove(d, 'x', 0, cb[0]))
alloc_log:check({
a.freed(key_p),
@@ -1519,19 +1550,29 @@ describe('typval.c', function()
itp('works with multiple callbacks', function()
local d = dict({})
eq({}, dict_watchers(d))
- alloc_log:check({a.dict(d)})
+ alloc_log:check({ a.dict(d) })
local cbs = {}
- cbs[1] = {'te', ffi.gc(tbl2callback({type='none'}), nil)}
+ cbs[1] = { 'te', ffi.gc(tbl2callback({ type = 'none' }), nil) }
alloc_log:check({})
- cbs[2] = {'foo', ffi.gc(tbl2callback({type='fref', fref='tr'}), nil)}
+ cbs[2] = { 'foo', ffi.gc(tbl2callback({ type = 'fref', fref = 'tr' }), nil) }
alloc_log:check({
- a.str(cbs[2][2].data.funcref, #('tr')),
+ a.str(cbs[2][2].data.funcref, #'tr'),
})
- cbs[3] = {'te', ffi.gc(tbl2callback({type='pt', fref='tr', pt={
- value='tr',
- args={'test'},
- dict={},
- }}), nil)}
+ cbs[3] = {
+ 'te',
+ ffi.gc(
+ tbl2callback({
+ type = 'pt',
+ fref = 'tr',
+ pt = {
+ value = 'tr',
+ args = { 'test' },
+ dict = {},
+ },
+ }),
+ nil
+ ),
+ }
local pt3 = cbs[3][2].data.partial
local pt3_argv = pt3.pt_argv
local pt3_dict = pt3.pt_dict
@@ -1540,22 +1581,32 @@ describe('typval.c', function()
alloc_log:check({
a.lua_pt(pt3),
a.lua_tvs(pt3_argv, pt3.pt_argc),
- a.str(pt3_str_arg, #('test')),
+ a.str(pt3_str_arg, #'test'),
a.dict(pt3_dict),
- a.str(pt3_name, #('tr')),
+ a.str(pt3_name, #'tr'),
})
for _, v in ipairs(cbs) do
- lib.tv_dict_watcher_add(d, v[1], #(v[1]), v[2][0])
+ lib.tv_dict_watcher_add(d, v[1], #v[1], v[2][0])
end
local ws, qs, kps = dict_watchers(d)
- eq({{busy=false, pat=cbs[1][1], cb={type='none'}},
- {busy=false, pat=cbs[2][1], cb={type='fref', fref='tr'}},
- {busy=false, pat=cbs[3][1], cb={type='pt', fref='tr', pt={
- [type_key]=func_type,
- value='tr',
- args={'test'},
- dict={},
- }}}}, ws)
+ eq({
+ { busy = false, pat = cbs[1][1], cb = { type = 'none' } },
+ { busy = false, pat = cbs[2][1], cb = { type = 'fref', fref = 'tr' } },
+ {
+ busy = false,
+ pat = cbs[3][1],
+ cb = {
+ type = 'pt',
+ fref = 'tr',
+ pt = {
+ [type_key] = func_type,
+ value = 'tr',
+ args = { 'test' },
+ dict = {},
+ },
+ },
+ },
+ }, ws)
alloc_log:check({
a.dwatcher(qs[1]),
a.str(kps[1][1], kps[1][2]),
@@ -1571,13 +1622,23 @@ describe('typval.c', function()
a.freed(qs[2]),
})
eq(false, lib.tv_dict_watcher_remove(d, cbs[2][1], #cbs[2][1], cbs[2][2][0]))
- eq({{busy=false, pat=cbs[1][1], cb={type='none'}},
- {busy=false, pat=cbs[3][1], cb={type='pt', fref='tr', pt={
- [type_key]=func_type,
- value='tr',
- args={'test'},
- dict={},
- }}}}, dict_watchers(d))
+ eq({
+ { busy = false, pat = cbs[1][1], cb = { type = 'none' } },
+ {
+ busy = false,
+ pat = cbs[3][1],
+ cb = {
+ type = 'pt',
+ fref = 'tr',
+ pt = {
+ [type_key] = func_type,
+ value = 'tr',
+ args = { 'test' },
+ dict = {},
+ },
+ },
+ },
+ }, dict_watchers(d))
eq(true, lib.tv_dict_watcher_remove(d, cbs[3][1], #cbs[3][1], cbs[3][2][0]))
alloc_log:check({
a.freed(pt3_str_arg),
@@ -1589,7 +1650,7 @@ describe('typval.c', function()
a.freed(qs[3]),
})
eq(false, lib.tv_dict_watcher_remove(d, cbs[3][1], #cbs[3][1], cbs[3][2][0]))
- eq({{busy=false, pat=cbs[1][1], cb={type='none'}}}, dict_watchers(d))
+ eq({ { busy = false, pat = cbs[1][1], cb = { type = 'none' } } }, dict_watchers(d))
eq(true, lib.tv_dict_watcher_remove(d, cbs[1][1], #cbs[1][1], cbs[1][2][0]))
alloc_log:check({
a.freed(kps[1][1]),
@@ -1615,14 +1676,14 @@ describe('typval.c', function()
di = ffi.gc(lib.tv_dict_item_alloc_len(s, len or #s), nil)
end
eq(s:sub(1, len), ffi.string(di.di_key))
- alloc_log:check({a.di(di, len)})
+ alloc_log:check({ a.di(di, len) })
if tv then
di.di_tv = ffi.gc(tv, nil)
else
di.di_tv.v_type = lib.VAR_UNKNOWN
end
lib.tv_dict_item_free(di)
- alloc_log:check(concat_tables(more_frees, {a.freed(di)}))
+ alloc_log:check(concat_tables(more_frees, { a.freed(di) }))
end
local function check_tv_dict_item_alloc(s, tv, more_frees)
return check_tv_dict_item_alloc_len(s, nil, tv, more_frees)
@@ -1634,26 +1695,30 @@ describe('typval.c', function()
check_tv_dict_item_alloc_len('', 0)
check_tv_dict_item_alloc_len('TEST', 2)
local tv = lua2typvalt('test')
- alloc_log:check({a.str(tv.vval.v_string, #('test'))})
- check_tv_dict_item_alloc('', tv, {a.freed(tv.vval.v_string)})
+ alloc_log:check({ a.str(tv.vval.v_string, #'test') })
+ check_tv_dict_item_alloc('', tv, { a.freed(tv.vval.v_string) })
tv = lua2typvalt('test')
- alloc_log:check({a.str(tv.vval.v_string, #('test'))})
- check_tv_dict_item_alloc_len('', 0, tv, {a.freed(tv.vval.v_string)})
+ alloc_log:check({ a.str(tv.vval.v_string, #'test') })
+ check_tv_dict_item_alloc_len('', 0, tv, { a.freed(tv.vval.v_string) })
end)
end)
describe('add()/remove()', function()
itp('works', function()
local d = dict()
eq({}, dct2tbl(d))
- alloc_log:check({a.dict(d)})
+ alloc_log:check({ a.dict(d) })
local di = ffi.gc(lib.tv_dict_item_alloc(''), nil)
local tv = lua2typvalt('test')
di.di_tv = ffi.gc(tv, nil)
- alloc_log:check({a.di(di, ''), a.str(tv.vval.v_string, 'test')})
+ alloc_log:check({ a.di(di, ''), a.str(tv.vval.v_string, 'test') })
eq(OK, lib.tv_dict_add(d, di))
alloc_log:check({})
- eq(FAIL, check_emsg(function() return lib.tv_dict_add(d, di) end,
- 'E685: Internal error: hash_add(): duplicate key ""'))
+ eq(
+ FAIL,
+ check_emsg(function()
+ return lib.tv_dict_add(d, di)
+ end, 'E685: Internal error: hash_add(): duplicate key ""')
+ )
alloc_log:clear()
lib.tv_dict_item_remove(d, di)
alloc_log:check({
@@ -1679,28 +1744,28 @@ describe('typval.c', function()
end)
itp('works with empty key', function()
local lua_d = {
- ['']=0,
- t=1,
- te=2,
- tes=3,
- test=4,
- testt=5,
+ [''] = 0,
+ t = 1,
+ te = 2,
+ tes = 3,
+ test = 4,
+ testt = 5,
}
local d = dict(lua_d)
alloc_log:clear()
eq(lua_d, dct2tbl(d))
alloc_log:check({})
local dis = dict_items(d)
- eq({0, '', dis['']}, {tv_dict_find(d, '', 0)})
+ eq({ 0, '', dis[''] }, { tv_dict_find(d, '', 0) })
end)
itp('works with len properly', function()
local lua_d = {
- ['']=0,
- t=1,
- te=2,
- tes=3,
- test=4,
- testt=5,
+ [''] = 0,
+ t = 1,
+ te = 2,
+ tes = 3,
+ test = 4,
+ testt = 5,
}
local d = dict(lua_d)
alloc_log:clear()
@@ -1708,80 +1773,125 @@ describe('typval.c', function()
alloc_log:check({})
for i = 0, 5 do
local v, k = tv_dict_find(d, 'testt', i)
- eq({i, ('testt'):sub(1, i)}, {v, k})
+ eq({ i, ('testt'):sub(1, i) }, { v, k })
end
- eq(nil, tv_dict_find(d, 'testt', 6)) -- Should take NUL byte
+ eq(nil, tv_dict_find(d, 'testt', 6)) -- Should take NUL byte
eq(5, tv_dict_find(d, 'testt', -1))
alloc_log:check({})
end)
end)
describe('get_number()', function()
itp('works with NULL dict', function()
- eq(0, check_emsg(function() return lib.tv_dict_get_number(nil, 'test') end,
- nil))
+ eq(
+ 0,
+ check_emsg(function()
+ return lib.tv_dict_get_number(nil, 'test')
+ end, nil)
+ )
end)
itp('works', function()
- local d = ffi.gc(dict({test={}}), nil)
- eq(0, check_emsg(function() return lib.tv_dict_get_number(d, 'test') end,
- 'E728: Using a Dictionary as a Number'))
- d = ffi.gc(dict({tes=int(42), t=44, te='43'}), nil)
+ local d = ffi.gc(dict({ test = {} }), nil)
+ eq(
+ 0,
+ check_emsg(function()
+ return lib.tv_dict_get_number(d, 'test')
+ end, 'E728: Using a Dictionary as a Number')
+ )
+ d = ffi.gc(dict({ tes = int(42), t = 44, te = '43' }), nil)
alloc_log:clear()
- eq(0, check_emsg(function() return lib.tv_dict_get_number(d, 'test') end,
- nil))
- eq(42, check_emsg(function() return lib.tv_dict_get_number(d, 'tes') end,
- nil))
- eq(43, check_emsg(function() return lib.tv_dict_get_number(d, 'te') end,
- nil))
+ eq(
+ 0,
+ check_emsg(function()
+ return lib.tv_dict_get_number(d, 'test')
+ end, nil)
+ )
+ eq(
+ 42,
+ check_emsg(function()
+ return lib.tv_dict_get_number(d, 'tes')
+ end, nil)
+ )
+ eq(
+ 43,
+ check_emsg(function()
+ return lib.tv_dict_get_number(d, 'te')
+ end, nil)
+ )
alloc_log:check({})
- eq(0, check_emsg(function() return lib.tv_dict_get_number(d, 't') end,
- 'E805: Using a Float as a Number'))
+ eq(
+ 0,
+ check_emsg(function()
+ return lib.tv_dict_get_number(d, 't')
+ end, 'E805: Using a Float as a Number')
+ )
end)
end)
describe('get_string()', function()
itp('works with NULL dict', function()
- eq(nil, check_emsg(function() return lib.tv_dict_get_string(nil, 'test', false) end,
- nil))
+ eq(
+ nil,
+ check_emsg(function()
+ return lib.tv_dict_get_string(nil, 'test', false)
+ end, nil)
+ )
end)
itp('works', function()
- local d = ffi.gc(dict({test={}}), nil)
- eq('', ffi.string(check_emsg(function() return lib.tv_dict_get_string(d, 'test', false) end,
- 'E731: Using a Dictionary as a String')))
- d = ffi.gc(dict({tes=int(42), t=44, te='43', xx=int(45)}), nil)
+ local d = ffi.gc(dict({ test = {} }), nil)
+ eq(
+ '',
+ ffi.string(check_emsg(function()
+ return lib.tv_dict_get_string(d, 'test', false)
+ end, 'E731: Using a Dictionary as a String'))
+ )
+ d = ffi.gc(dict({ tes = int(42), t = 44, te = '43', xx = int(45) }), nil)
alloc_log:clear()
local dis = dict_items(d)
- eq(nil, check_emsg(function() return lib.tv_dict_get_string(d, 'test', false) end,
- nil))
- local s42 = check_emsg(function() return lib.tv_dict_get_string(d, 'tes', false) end,
- nil)
+ eq(
+ nil,
+ check_emsg(function()
+ return lib.tv_dict_get_string(d, 'test', false)
+ end, nil)
+ )
+ local s42 = check_emsg(function()
+ return lib.tv_dict_get_string(d, 'tes', false)
+ end, nil)
eq('42', ffi.string(s42))
- local s45 = check_emsg(function() return lib.tv_dict_get_string(d, 'xx', false) end,
- nil)
+ local s45 = check_emsg(function()
+ return lib.tv_dict_get_string(d, 'xx', false)
+ end, nil)
eq(s42, s45)
eq('45', ffi.string(s45))
eq('45', ffi.string(s42))
- local s43 = check_emsg(function() return lib.tv_dict_get_string(d, 'te', false) end,
- nil)
+ local s43 = check_emsg(function()
+ return lib.tv_dict_get_string(d, 'te', false)
+ end, nil)
eq('43', ffi.string(s43))
neq(s42, s43)
eq(s43, dis.te.di_tv.vval.v_string)
alloc_log:check({})
- local s44 = check_emsg(function() return lib.tv_dict_get_string(d, 't', false) end,
- nil)
+ local s44 = check_emsg(function()
+ return lib.tv_dict_get_string(d, 't', false)
+ end, nil)
eq('44.0', ffi.string(s44))
- alloc_log:check({a.freed(alloc_log.null), a.freed(alloc_log.null)})
+ alloc_log:check({ a.freed(alloc_log.null), a.freed(alloc_log.null) })
end)
itp('allocates a string copy when requested', function()
local function tv_dict_get_string_alloc(d, key, emsg, is_float)
alloc_log:clear()
- local ret = check_emsg(function() return lib.tv_dict_get_string(d, key, true) end,
- emsg)
+ local ret = check_emsg(function()
+ return lib.tv_dict_get_string(d, key, true)
+ end, emsg)
local s_ret = (ret ~= nil) and ffi.string(ret) or nil
if not emsg then
if s_ret then
if is_float then
- alloc_log:check({a.freed(alloc_log.null), a.freed(alloc_log.null), a.str(ret, s_ret)})
+ alloc_log:check({
+ a.freed(alloc_log.null),
+ a.freed(alloc_log.null),
+ a.str(ret, s_ret),
+ })
else
- alloc_log:check({a.str(ret, s_ret)})
+ alloc_log:check({ a.str(ret, s_ret) })
end
else
alloc_log:check({})
@@ -1790,9 +1900,9 @@ describe('typval.c', function()
lib.xfree(ret)
return s_ret
end
- local d = ffi.gc(dict({test={}}), nil)
+ local d = ffi.gc(dict({ test = {} }), nil)
eq('', tv_dict_get_string_alloc(d, 'test', 'E731: Using a Dictionary as a String'))
- d = ffi.gc(dict({tes=int(42), t=44, te='43', xx=int(45)}), nil)
+ d = ffi.gc(dict({ tes = int(42), t = 44, te = '43', xx = int(45) }), nil)
alloc_log:clear()
eq(nil, tv_dict_get_string_alloc(d, 'test'))
eq('42', tv_dict_get_string_alloc(d, 'tes'))
@@ -1805,12 +1915,13 @@ describe('typval.c', function()
local function tv_dict_get_string_buf(d, key, is_float, buf, emsg)
buf = buf or ffi.gc(lib.xmalloc(lib.NUMBUFLEN), lib.xfree)
alloc_log:clear()
- local ret = check_emsg(function() return lib.tv_dict_get_string_buf(d, key, buf) end,
- emsg)
+ local ret = check_emsg(function()
+ return lib.tv_dict_get_string_buf(d, key, buf)
+ end, emsg)
local s_ret = (ret ~= nil) and ffi.string(ret) or nil
if not emsg then
if is_float then
- alloc_log:check({a.freed(alloc_log.null), a.freed(alloc_log.null)})
+ alloc_log:check({ a.freed(alloc_log.null), a.freed(alloc_log.null) })
else
alloc_log:check({})
end
@@ -1822,12 +1933,12 @@ describe('typval.c', function()
end)
itp('works', function()
local lua_d = {
- ['']={},
- t=1,
- te=int(2),
- tes=empty_list,
- test='tset',
- testt=5,
+ [''] = {},
+ t = 1,
+ te = int(2),
+ tes = empty_list,
+ test = 'tset',
+ testt = 5,
}
local d = dict(lua_d)
alloc_log:clear()
@@ -1851,12 +1962,13 @@ describe('typval.c', function()
def = def or ffi.gc(lib.xstrdup('DEFAULT'), lib.xfree)
len = len or #key
alloc_log:clear()
- local ret = check_emsg(function() return lib.tv_dict_get_string_buf_chk(d, key, len, buf, def) end,
- emsg)
+ local ret = check_emsg(function()
+ return lib.tv_dict_get_string_buf_chk(d, key, len, buf, def)
+ end, emsg)
local s_ret = (ret ~= nil) and ffi.string(ret) or nil
if not emsg then
if is_float then
- alloc_log:check({a.freed(alloc_log.null), a.freed(alloc_log.null)})
+ alloc_log:check({ a.freed(alloc_log.null), a.freed(alloc_log.null) })
else
alloc_log:check({})
end
@@ -1868,12 +1980,12 @@ describe('typval.c', function()
end)
itp('works', function()
local lua_d = {
- ['']={},
- t=1,
- te=int(2),
- tes=empty_list,
- test='tset',
- testt=5,
+ [''] = {},
+ t = 1,
+ te = int(2),
+ tes = empty_list,
+ test = 'tset',
+ testt = 5,
}
local d = dict(lua_d)
alloc_log:clear()
@@ -1901,7 +2013,8 @@ describe('typval.c', function()
describe('get_callback()', function()
local function tv_dict_get_callback(d, key, key_len, emsg)
key_len = key_len or #key
- local cb = ffi.gc(ffi.cast('Callback*', lib.xmalloc(ffi.sizeof('Callback'))), lib.callback_free)
+ local cb =
+ ffi.gc(ffi.cast('Callback*', lib.xmalloc(ffi.sizeof('Callback'))), lib.callback_free)
alloc_log:clear()
local ret = check_emsg(function()
return lib.tv_dict_get_callback(d, key, key_len, cb)
@@ -1910,35 +2023,59 @@ describe('typval.c', function()
return cb_lua, ret
end
itp('works with NULL dict', function()
- eq({{type='none'}, true}, {tv_dict_get_callback(nil, '')})
+ eq({ { type = 'none' }, true }, { tv_dict_get_callback(nil, '') })
end)
itp('works', function()
local lua_d = {
- ['']='tr',
- t=int(1),
- te={[type_key]=func_type, value='tr'},
- tes={[type_key]=func_type, value='tr', args={'a', 'b'}},
- test={[type_key]=func_type, value='Test', dict={test=1}, args={}},
- testt={[type_key]=func_type, value='Test', dict={test=1}, args={1}},
+ [''] = 'tr',
+ t = int(1),
+ te = { [type_key] = func_type, value = 'tr' },
+ tes = { [type_key] = func_type, value = 'tr', args = { 'a', 'b' } },
+ test = { [type_key] = func_type, value = 'Test', dict = { test = 1 }, args = {} },
+ testt = { [type_key] = func_type, value = 'Test', dict = { test = 1 }, args = { 1 } },
}
local d = dict(lua_d)
eq(lua_d, dct2tbl(d))
- eq({{type='fref', fref='tr'}, true},
- {tv_dict_get_callback(d, '', -1)})
- eq({{type='none'}, true},
- {tv_dict_get_callback(d, 'x', -1)})
- eq({{type='fref', fref='tr'}, true},
- {tv_dict_get_callback(d, 'testt', 0)})
- eq({{type='none'}, false},
- {tv_dict_get_callback(d, 'test', 1, 'E6000: Argument is not a function or function name')})
- eq({{type='fref', fref='tr'}, true},
- {tv_dict_get_callback(d, 'testt', 2)})
- eq({{ type='pt', fref='tr', pt={ [type_key]=func_type, value='tr', args={ 'a', 'b' } } }, true},
- {tv_dict_get_callback(d, 'testt', 3)})
- eq({{ type='pt', fref='Test', pt={ [type_key]=func_type, value='Test', dict={ test=1 }, args={} } }, true},
- {tv_dict_get_callback(d, 'testt', 4)})
- eq({{ type='pt', fref='Test', pt={ [type_key]=func_type, value='Test', dict={ test=1 }, args={1} } }, true},
- {tv_dict_get_callback(d, 'testt', 5)})
+ eq({ { type = 'fref', fref = 'tr' }, true }, { tv_dict_get_callback(d, '', -1) })
+ eq({ { type = 'none' }, true }, { tv_dict_get_callback(d, 'x', -1) })
+ eq({ { type = 'fref', fref = 'tr' }, true }, { tv_dict_get_callback(d, 'testt', 0) })
+ eq({ { type = 'none' }, false }, {
+ tv_dict_get_callback(
+ d,
+ 'test',
+ 1,
+ 'E6000: Argument is not a function or function name'
+ ),
+ })
+ eq({ { type = 'fref', fref = 'tr' }, true }, { tv_dict_get_callback(d, 'testt', 2) })
+ eq({
+ {
+ type = 'pt',
+ fref = 'tr',
+ pt = {
+ [type_key] = func_type,
+ value = 'tr',
+ args = { 'a', 'b' },
+ },
+ },
+ true,
+ }, { tv_dict_get_callback(d, 'testt', 3) })
+ eq({
+ {
+ type = 'pt',
+ fref = 'Test',
+ pt = { [type_key] = func_type, value = 'Test', dict = { test = 1 }, args = {} },
+ },
+ true,
+ }, { tv_dict_get_callback(d, 'testt', 4) })
+ eq({
+ {
+ type = 'pt',
+ fref = 'Test',
+ pt = { [type_key] = func_type, value = 'Test', dict = { test = 1 }, args = { 1 } },
+ },
+ true,
+ }, { tv_dict_get_callback(d, 'testt', 5) })
end)
end)
end)
@@ -1946,22 +2083,26 @@ describe('typval.c', function()
describe('()', function()
itp('works', function()
local di = lib.tv_dict_item_alloc_len('t-est', 5)
- alloc_log:check({a.di(di, 't-est')})
+ alloc_log:check({ a.di(di, 't-est') })
di.di_tv.v_type = lib.VAR_NUMBER
di.di_tv.vval.v_number = 42
- local d = dict({test=10})
+ local d = dict({ test = 10 })
local dis = dict_items(d)
alloc_log:check({
a.dict(d),
- a.di(dis.test, 'test')
+ a.di(dis.test, 'test'),
})
- eq({test=10}, dct2tbl(d))
+ eq({ test = 10 }, dct2tbl(d))
alloc_log:clear()
eq(OK, lib.tv_dict_add(d, di))
alloc_log:check({})
- eq({test=10, ['t-est']=int(42)}, dct2tbl(d))
- eq(FAIL, check_emsg(function() return lib.tv_dict_add(d, di) end,
- 'E685: Internal error: hash_add(): duplicate key "t-est"'))
+ eq({ test = 10, ['t-est'] = int(42) }, dct2tbl(d))
+ eq(
+ FAIL,
+ check_emsg(function()
+ return lib.tv_dict_add(d, di)
+ end, 'E685: Internal error: hash_add(): duplicate key "t-est"')
+ )
end)
end)
describe('list()', function()
@@ -1969,21 +2110,29 @@ describe('typval.c', function()
local l = list(1, 2, 3)
alloc_log:clear()
eq(1, l.lv_refcount)
- local d = dict({test=10})
+ local d = dict({ test = 10 })
alloc_log:clear()
- eq({test=10}, dct2tbl(d))
+ eq({ test = 10 }, dct2tbl(d))
eq(OK, lib.tv_dict_add_list(d, 'testt', 3, l))
local dis = dict_items(d)
- alloc_log:check({a.di(dis.tes, 'tes')})
- eq({test=10, tes={1, 2, 3}}, dct2tbl(d))
+ alloc_log:check({ a.di(dis.tes, 'tes') })
+ eq({ test = 10, tes = { 1, 2, 3 } }, dct2tbl(d))
eq(2, l.lv_refcount)
- eq(FAIL, check_emsg(function() return lib.tv_dict_add_list(d, 'testt', 3, l) end,
- 'E685: Internal error: hash_add(): duplicate key "tes"'))
+ eq(
+ FAIL,
+ check_emsg(function()
+ return lib.tv_dict_add_list(d, 'testt', 3, l)
+ end, 'E685: Internal error: hash_add(): duplicate key "tes"')
+ )
eq(2, l.lv_refcount)
alloc_log:clear()
lib.emsg_skip = lib.emsg_skip + 1
- eq(FAIL, check_emsg(function() return lib.tv_dict_add_list(d, 'testt', 3, l) end,
- nil))
+ eq(
+ FAIL,
+ check_emsg(function()
+ return lib.tv_dict_add_list(d, 'testt', 3, l)
+ end, nil)
+ )
eq(2, l.lv_refcount)
lib.emsg_skip = lib.emsg_skip - 1
alloc_log:clear_tmp_allocs()
@@ -1992,24 +2141,32 @@ describe('typval.c', function()
end)
describe('dict()', function()
itp('works', function()
- local d2 = dict({foo=42})
+ local d2 = dict({ foo = 42 })
alloc_log:clear()
eq(1, d2.dv_refcount)
- local d = dict({test=10})
+ local d = dict({ test = 10 })
alloc_log:clear()
- eq({test=10}, dct2tbl(d))
+ eq({ test = 10 }, dct2tbl(d))
eq(OK, lib.tv_dict_add_dict(d, 'testt', 3, d2))
local dis = dict_items(d)
- alloc_log:check({a.di(dis.tes, 'tes')})
- eq({test=10, tes={foo=42}}, dct2tbl(d))
+ alloc_log:check({ a.di(dis.tes, 'tes') })
+ eq({ test = 10, tes = { foo = 42 } }, dct2tbl(d))
eq(2, d2.dv_refcount)
- eq(FAIL, check_emsg(function() return lib.tv_dict_add_dict(d, 'testt', 3, d2) end,
- 'E685: Internal error: hash_add(): duplicate key "tes"'))
+ eq(
+ FAIL,
+ check_emsg(function()
+ return lib.tv_dict_add_dict(d, 'testt', 3, d2)
+ end, 'E685: Internal error: hash_add(): duplicate key "tes"')
+ )
eq(2, d2.dv_refcount)
alloc_log:clear()
lib.emsg_skip = lib.emsg_skip + 1
- eq(FAIL, check_emsg(function() return lib.tv_dict_add_dict(d, 'testt', 3, d2) end,
- nil))
+ eq(
+ FAIL,
+ check_emsg(function()
+ return lib.tv_dict_add_dict(d, 'testt', 3, d2)
+ end, nil)
+ )
eq(2, d2.dv_refcount)
lib.emsg_skip = lib.emsg_skip - 1
alloc_log:clear_tmp_allocs()
@@ -2018,19 +2175,27 @@ describe('typval.c', function()
end)
describe('nr()', function()
itp('works', function()
- local d = dict({test=10})
+ local d = dict({ test = 10 })
alloc_log:clear()
- eq({test=10}, dct2tbl(d))
+ eq({ test = 10 }, dct2tbl(d))
eq(OK, lib.tv_dict_add_nr(d, 'testt', 3, 2))
local dis = dict_items(d)
- alloc_log:check({a.di(dis.tes, 'tes')})
- eq({test=10, tes=int(2)}, dct2tbl(d))
- eq(FAIL, check_emsg(function() return lib.tv_dict_add_nr(d, 'testt', 3, 2) end,
- 'E685: Internal error: hash_add(): duplicate key "tes"'))
+ alloc_log:check({ a.di(dis.tes, 'tes') })
+ eq({ test = 10, tes = int(2) }, dct2tbl(d))
+ eq(
+ FAIL,
+ check_emsg(function()
+ return lib.tv_dict_add_nr(d, 'testt', 3, 2)
+ end, 'E685: Internal error: hash_add(): duplicate key "tes"')
+ )
alloc_log:clear()
lib.emsg_skip = lib.emsg_skip + 1
- eq(FAIL, check_emsg(function() return lib.tv_dict_add_nr(d, 'testt', 3, 2) end,
- nil))
+ eq(
+ FAIL,
+ check_emsg(function()
+ return lib.tv_dict_add_nr(d, 'testt', 3, 2)
+ end, nil)
+ )
lib.emsg_skip = lib.emsg_skip - 1
alloc_log:clear_tmp_allocs()
alloc_log:check({})
@@ -2038,19 +2203,27 @@ describe('typval.c', function()
end)
describe('float()', function()
itp('works', function()
- local d = dict({test=10})
+ local d = dict({ test = 10 })
alloc_log:clear()
- eq({test=10}, dct2tbl(d))
+ eq({ test = 10 }, dct2tbl(d))
eq(OK, lib.tv_dict_add_float(d, 'testt', 3, 1.5))
local dis = dict_items(d)
- alloc_log:check({a.di(dis.tes, 'tes')})
- eq({test=10, tes=1.5}, dct2tbl(d))
- eq(FAIL, check_emsg(function() return lib.tv_dict_add_float(d, 'testt', 3, 1.5) end,
- 'E685: Internal error: hash_add(): duplicate key "tes"'))
+ alloc_log:check({ a.di(dis.tes, 'tes') })
+ eq({ test = 10, tes = 1.5 }, dct2tbl(d))
+ eq(
+ FAIL,
+ check_emsg(function()
+ return lib.tv_dict_add_float(d, 'testt', 3, 1.5)
+ end, 'E685: Internal error: hash_add(): duplicate key "tes"')
+ )
alloc_log:clear()
lib.emsg_skip = lib.emsg_skip + 1
- eq(FAIL, check_emsg(function() return lib.tv_dict_add_float(d, 'testt', 3, 1.5) end,
- nil))
+ eq(
+ FAIL,
+ check_emsg(function()
+ return lib.tv_dict_add_float(d, 'testt', 3, 1.5)
+ end, nil)
+ )
lib.emsg_skip = lib.emsg_skip - 1
alloc_log:clear_tmp_allocs()
alloc_log:check({})
@@ -2058,22 +2231,30 @@ describe('typval.c', function()
end)
describe('str()', function()
itp('works', function()
- local d = dict({test=10})
+ local d = dict({ test = 10 })
alloc_log:clear()
- eq({test=10}, dct2tbl(d))
+ eq({ test = 10 }, dct2tbl(d))
eq(OK, lib.tv_dict_add_str(d, 'testt', 3, 'TEST'))
local dis = dict_items(d)
alloc_log:check({
a.str(dis.tes.di_tv.vval.v_string, 'TEST'),
a.di(dis.tes, 'tes'),
})
- eq({test=10, tes='TEST'}, dct2tbl(d))
- eq(FAIL, check_emsg(function() return lib.tv_dict_add_str(d, 'testt', 3, 'TEST') end,
- 'E685: Internal error: hash_add(): duplicate key "tes"'))
+ eq({ test = 10, tes = 'TEST' }, dct2tbl(d))
+ eq(
+ FAIL,
+ check_emsg(function()
+ return lib.tv_dict_add_str(d, 'testt', 3, 'TEST')
+ end, 'E685: Internal error: hash_add(): duplicate key "tes"')
+ )
alloc_log:clear()
lib.emsg_skip = lib.emsg_skip + 1
- eq(FAIL, check_emsg(function() return lib.tv_dict_add_str(d, 'testt', 3, 'TEST') end,
- nil))
+ eq(
+ FAIL,
+ check_emsg(function()
+ return lib.tv_dict_add_str(d, 'testt', 3, 'TEST')
+ end, nil)
+ )
lib.emsg_skip = lib.emsg_skip - 1
alloc_log:clear_tmp_allocs()
alloc_log:check({})
@@ -2081,8 +2262,8 @@ describe('typval.c', function()
end)
describe('allocated_str()', function()
itp('works', function()
- local d = dict({test=10})
- eq({test=10}, dct2tbl(d))
+ local d = dict({ test = 10 })
+ eq({ test = 10 }, dct2tbl(d))
alloc_log:clear()
local s1 = lib.xstrdup('TEST')
local s2 = lib.xstrdup('TEST')
@@ -2097,13 +2278,21 @@ describe('typval.c', function()
alloc_log:check({
a.di(dis.tes, 'tes'),
})
- eq({test=10, tes='TEST'}, dct2tbl(d))
- eq(FAIL, check_emsg(function() return lib.tv_dict_add_allocated_str(d, 'testt', 3, s2) end,
- 'E685: Internal error: hash_add(): duplicate key "tes"'))
+ eq({ test = 10, tes = 'TEST' }, dct2tbl(d))
+ eq(
+ FAIL,
+ check_emsg(function()
+ return lib.tv_dict_add_allocated_str(d, 'testt', 3, s2)
+ end, 'E685: Internal error: hash_add(): duplicate key "tes"')
+ )
alloc_log:clear()
lib.emsg_skip = lib.emsg_skip + 1
- eq(FAIL, check_emsg(function() return lib.tv_dict_add_allocated_str(d, 'testt', 3, s3) end,
- nil))
+ eq(
+ FAIL,
+ check_emsg(function()
+ return lib.tv_dict_add_allocated_str(d, 'testt', 3, s3)
+ end, nil)
+ )
lib.emsg_skip = lib.emsg_skip - 1
alloc_log:clear_tmp_allocs()
alloc_log:check({
@@ -2115,7 +2304,7 @@ describe('typval.c', function()
describe('clear()', function()
itp('works', function()
local d = dict()
- alloc_log:check({a.dict(d)})
+ alloc_log:check({ a.dict(d) })
eq({}, dct2tbl(d))
lib.tv_dict_clear(d)
eq({}, dct2tbl(d))
@@ -2123,32 +2312,34 @@ describe('typval.c', function()
local dis = dict_items(d)
local di = dis.TES
local di_s = di.di_tv.vval.v_string
- alloc_log:check({a.str(di_s), a.di(di)})
- eq({TES='tEsT'}, dct2tbl(d))
+ alloc_log:check({ a.str(di_s), a.di(di) })
+ eq({ TES = 'tEsT' }, dct2tbl(d))
lib.tv_dict_clear(d)
- alloc_log:check({a.freed(di_s), a.freed(di)})
+ alloc_log:check({ a.freed(di_s), a.freed(di) })
eq({}, dct2tbl(d))
end)
end)
describe('extend()', function()
local function tv_dict_extend(d1, d2, action, emsg)
- action = action or "force"
- check_emsg(function() return lib.tv_dict_extend(d1, d2, action) end, emsg)
+ action = action or 'force'
+ check_emsg(function()
+ return lib.tv_dict_extend(d1, d2, action)
+ end, emsg)
end
itp('works', function()
local d1 = dict()
- alloc_log:check({a.dict(d1)})
+ alloc_log:check({ a.dict(d1) })
eq({}, dct2tbl(d1))
local d2 = dict()
- alloc_log:check({a.dict(d2)})
+ alloc_log:check({ a.dict(d2) })
eq({}, dct2tbl(d2))
tv_dict_extend(d1, d2, 'error')
tv_dict_extend(d1, d2, 'keep')
tv_dict_extend(d1, d2, 'force')
alloc_log:check({})
- d1 = dict({a='TEST'})
- eq({a='TEST'}, dct2tbl(d1))
+ d1 = dict({ a = 'TEST' })
+ eq({ a = 'TEST' }, dct2tbl(d1))
local dis1 = dict_items(d1)
local a1_s = dis1.a.di_tv.vval.v_string
alloc_log:clear_tmp_allocs()
@@ -2157,8 +2348,8 @@ describe('typval.c', function()
a.di(dis1.a),
a.str(a1_s),
})
- d2 = dict({a='TSET'})
- eq({a='TSET'}, dct2tbl(d2))
+ d2 = dict({ a = 'TSET' })
+ eq({ a = 'TSET' }, dct2tbl(d2))
local dis2 = dict_items(d2)
local a2_s = dis2.a.di_tv.vval.v_string
alloc_log:clear_tmp_allocs()
@@ -2169,72 +2360,66 @@ describe('typval.c', function()
})
tv_dict_extend(d1, d2, 'error', 'E737: Key already exists: a')
- eq({a='TEST'}, dct2tbl(d1))
- eq({a='TSET'}, dct2tbl(d2))
+ eq({ a = 'TEST' }, dct2tbl(d1))
+ eq({ a = 'TSET' }, dct2tbl(d2))
alloc_log:clear()
tv_dict_extend(d1, d2, 'keep')
alloc_log:check({})
- eq({a='TEST'}, dct2tbl(d1))
- eq({a='TSET'}, dct2tbl(d2))
+ eq({ a = 'TEST' }, dct2tbl(d1))
+ eq({ a = 'TSET' }, dct2tbl(d2))
tv_dict_extend(d1, d2, 'force')
alloc_log:check({
a.freed(a1_s),
a.str(dis1.a.di_tv.vval.v_string),
})
- eq({a='TSET'}, dct2tbl(d1))
- eq({a='TSET'}, dct2tbl(d2))
+ eq({ a = 'TSET' }, dct2tbl(d1))
+ eq({ a = 'TSET' }, dct2tbl(d2))
end)
pending('disallows overriding builtin or user functions: here be the dragons', function()
-- pending: see TODO below
local d = dict()
d.dv_scope = lib.VAR_DEF_SCOPE
local f_lua = {
- [type_key]=func_type,
- value='tr',
+ [type_key] = func_type,
+ value = 'tr',
}
local f_tv = lua2typvalt(f_lua)
local p_lua = {
- [type_key]=func_type,
- value='tr',
- args={1},
+ [type_key] = func_type,
+ value = 'tr',
+ args = { 1 },
}
local p_tv = lua2typvalt(p_lua)
eq(lib.VAR_PARTIAL, p_tv.v_type)
- local d2 = dict({tr=f_tv})
- local d3 = dict({tr=p_tv})
- local d4 = dict({['TEST:THIS']=p_tv})
- local d5 = dict({Test=f_tv})
- local d6 = dict({Test=p_tv})
+ local d2 = dict({ tr = f_tv })
+ local d3 = dict({ tr = p_tv })
+ local d4 = dict({ ['TEST:THIS'] = p_tv })
+ local d5 = dict({ Test = f_tv })
+ local d6 = dict({ Test = p_tv })
eval0([[execute("function Test()\nendfunction")]])
-- TODO: test breaks at this point
- tv_dict_extend(d, d2, 'force',
- 'E704: Funcref variable name must start with a capital: tr')
- tv_dict_extend(d, d3, 'force',
- 'E704: Funcref variable name must start with a capital: tr')
- tv_dict_extend(d, d4, 'force',
- 'E461: Illegal variable name: TEST:THIS')
- tv_dict_extend(d, d5, 'force',
- 'E705: Variable name conflicts with existing function: Test')
- tv_dict_extend(d, d6, 'force',
- 'E705: Variable name conflicts with existing function: Test')
+ tv_dict_extend(d, d2, 'force', 'E704: Funcref variable name must start with a capital: tr')
+ tv_dict_extend(d, d3, 'force', 'E704: Funcref variable name must start with a capital: tr')
+ tv_dict_extend(d, d4, 'force', 'E461: Illegal variable name: TEST:THIS')
+ tv_dict_extend(d, d5, 'force', 'E705: Variable name conflicts with existing function: Test')
+ tv_dict_extend(d, d6, 'force', 'E705: Variable name conflicts with existing function: Test')
eq({}, dct2tbl(d))
d.dv_scope = lib.VAR_SCOPE
- tv_dict_extend(d, d4, 'force',
- 'E461: Illegal variable name: TEST:THIS')
+ tv_dict_extend(d, d4, 'force', 'E461: Illegal variable name: TEST:THIS')
eq({}, dct2tbl(d))
tv_dict_extend(d, d2, 'force')
- eq({tr=f_lua}, dct2tbl(d))
+ eq({ tr = f_lua }, dct2tbl(d))
tv_dict_extend(d, d3, 'force')
- eq({tr=p_lua}, dct2tbl(d))
+ eq({ tr = p_lua }, dct2tbl(d))
tv_dict_extend(d, d5, 'force')
- eq({tr=p_lua, Test=f_lua}, dct2tbl(d))
+ eq({ tr = p_lua, Test = f_lua }, dct2tbl(d))
tv_dict_extend(d, d6, 'force')
- eq({tr=p_lua, Test=p_lua}, dct2tbl(d))
+ eq({ tr = p_lua, Test = p_lua }, dct2tbl(d))
end)
itp('cares about locks and read-only items', function()
- local d_lua = {tv_locked=1, tv_fixed=2, di_ro=3, di_ro_sbx=4}
+ local d_lua = { tv_locked = 1, tv_fixed = 2, di_ro = 3, di_ro_sbx = 4 }
local d = dict(d_lua)
local dis = dict_items(d)
dis.tv_locked.di_tv.v_lock = lib.VAR_LOCKED
@@ -2242,14 +2427,19 @@ describe('typval.c', function()
dis.di_ro.di_flags = bit.bor(dis.di_ro.di_flags, lib.DI_FLAGS_RO)
dis.di_ro_sbx.di_flags = bit.bor(dis.di_ro_sbx.di_flags, lib.DI_FLAGS_RO_SBX)
lib.sandbox = true
- local d1 = dict({tv_locked=41})
- local d2 = dict({tv_fixed=42})
- local d3 = dict({di_ro=43})
- local d4 = dict({di_ro_sbx=44})
+ local d1 = dict({ tv_locked = 41 })
+ local d2 = dict({ tv_fixed = 42 })
+ local d3 = dict({ di_ro = 43 })
+ local d4 = dict({ di_ro_sbx = 44 })
tv_dict_extend(d, d1, 'force', 'E741: Value is locked: extend() argument')
tv_dict_extend(d, d2, 'force', 'E742: Cannot change value of extend() argument')
tv_dict_extend(d, d3, 'force', 'E46: Cannot change read-only variable "extend() argument"')
- tv_dict_extend(d, d4, 'force', 'E794: Cannot set variable in the sandbox: "extend() argument"')
+ tv_dict_extend(
+ d,
+ d4,
+ 'force',
+ 'E794: Cannot set variable in the sandbox: "extend() argument"'
+ )
eq(d_lua, dct2tbl(d))
lib.sandbox = false
tv_dict_extend(d, d4, 'force')
@@ -2264,20 +2454,20 @@ describe('typval.c', function()
itp('works', function()
eq(true, tv_dict_equal(nil, nil))
local d1 = dict()
- alloc_log:check({a.dict(d1)})
+ alloc_log:check({ a.dict(d1) })
eq(1, d1.dv_refcount)
eq(true, tv_dict_equal(nil, d1))
eq(true, tv_dict_equal(d1, nil))
eq(true, tv_dict_equal(d1, d1))
eq(1, d1.dv_refcount)
alloc_log:check({})
- local d_upper = dict({a='TEST'})
+ local d_upper = dict({ a = 'TEST' })
local dis_upper = dict_items(d_upper)
- local d_lower = dict({a='test'})
+ local d_lower = dict({ a = 'test' })
local dis_lower = dict_items(d_lower)
- local d_kupper_upper = dict({A='TEST'})
+ local d_kupper_upper = dict({ A = 'TEST' })
local dis_kupper_upper = dict_items(d_kupper_upper)
- local d_kupper_lower = dict({A='test'})
+ local d_kupper_lower = dict({ A = 'test' })
local dis_kupper_lower = dict_items(d_kupper_lower)
alloc_log:clear_tmp_allocs()
alloc_log:check({
@@ -2320,7 +2510,15 @@ describe('typval.c', function()
end)
itp('copies dict correctly without converting items', function()
do
- local v = {a={['«']='»'}, b={'„'}, ['1']=1, ['«»']='“', ns=null_string, nl=null_list, nd=null_dict}
+ local v = {
+ a = { ['«'] = '»' },
+ b = { '„' },
+ ['1'] = 1,
+ ['«»'] = '“',
+ ns = null_string,
+ nl = null_list,
+ nd = null_dict,
+ }
local d_tv = lua2typvalt(v)
local d = d_tv.vval.v_dict
local dis = dict_items(d)
@@ -2358,7 +2556,15 @@ describe('typval.c', function()
-- UTF-8 ↔ latin1 conversions need no iconv
eq(OK, lib.convert_setup(vc, to_cstr('utf-8'), to_cstr('latin1')))
- local v = {a={['«']='»'}, b={'„'}, ['1']=1, ['«»']='“', ns=null_string, nl=null_list, nd=null_dict}
+ local v = {
+ a = { ['«'] = '»' },
+ b = { '„' },
+ ['1'] = 1,
+ ['«»'] = '“',
+ ns = null_string,
+ nl = null_list,
+ nd = null_dict,
+ }
local d_tv = lua2typvalt(v)
local d = d_tv.vval.v_dict
local dis = dict_items(d)
@@ -2373,14 +2579,21 @@ describe('typval.c', function()
local dis_deepcopy1 = dict_items(d_deepcopy1)
neq(dis.a.di_tv.vval.v_dict, dis_deepcopy1.a.di_tv.vval.v_dict)
neq(dis.b.di_tv.vval.v_list, dis_deepcopy1.b.di_tv.vval.v_list)
- eq({a={['\171']='\187'}, b={'\191'}, ['1']=1, ['\171\187']='\191', ns=null_string, nl=null_list, nd=null_dict},
- dct2tbl(d_deepcopy1))
+ eq({
+ a = { ['\171'] = '\187' },
+ b = { '\191' },
+ ['1'] = 1,
+ ['\171\187'] = '\191',
+ ns = null_string,
+ nl = null_list,
+ nd = null_dict,
+ }, dct2tbl(d_deepcopy1))
alloc_log:clear_tmp_allocs()
alloc_log:clear()
end)
itp('returns different/same containers with(out) copyID', function()
local d_inner_tv = lua2typvalt({})
- local d_tv = lua2typvalt({a=d_inner_tv, b=d_inner_tv})
+ local d_tv = lua2typvalt({ a = d_inner_tv, b = d_inner_tv })
eq(3, d_inner_tv.vval.v_dict.dv_refcount)
local d = d_tv.vval.v_dict
local dis = dict_items(d)
@@ -2389,12 +2602,12 @@ describe('typval.c', function()
local d_copy1 = tv_dict_copy(nil, d, true, 0)
local dis_copy1 = dict_items(d_copy1)
neq(dis_copy1.a.di_tv.vval.v_dict, dis_copy1.b.di_tv.vval.v_dict)
- eq({a={}, b={}}, dct2tbl(d_copy1))
+ eq({ a = {}, b = {} }, dct2tbl(d_copy1))
local d_copy2 = tv_dict_copy(nil, d, true, 2)
local dis_copy2 = dict_items(d_copy2)
eq(dis_copy2.a.di_tv.vval.v_dict, dis_copy2.b.di_tv.vval.v_dict)
- eq({a={}, b={}}, dct2tbl(d_copy2))
+ eq({ a = {}, b = {} }, dct2tbl(d_copy2))
eq(3, d_inner_tv.vval.v_dict.dv_refcount)
end)
@@ -2420,9 +2633,9 @@ describe('typval.c', function()
end)
describe('set_keys_readonly()', function()
itp('works', function()
- local d = dict({a=true})
+ local d = dict({ a = true })
local dis = dict_items(d)
- alloc_log:check({a.dict(d), a.di(dis.a)})
+ alloc_log:check({ a.dict(d), a.di(dis.a) })
eq(0, bit.band(dis.a.di_flags, lib.DI_FLAGS_RO))
eq(0, bit.band(dis.a.di_flags, lib.DI_FLAGS_FIX))
lib.tv_dict_set_keys_readonly(d)
@@ -2472,23 +2685,52 @@ describe('typval.c', function()
local dd_d = nil
dd.dd = dd
for _, v in ipairs({
- {nil_value},
- {null_string, nil, function() return {a.freed(alloc_log.null)} end},
- {0},
- {int(0)},
- {true},
- {false},
- {'true', function(tv) return {a.str(tv.vval.v_string)} end},
- {{}, function(tv) return {a.dict(tv.vval.v_dict)} end},
- {empty_list, function(tv) return {a.list(tv.vval.v_list)} end},
- {ll, function(tv)
- ll_l = tv.vval.v_list
- return {a.list(tv.vval.v_list), a.li(tv.vval.v_list.lv_first)}
- end, defalloc},
- {dd, function(tv)
- dd_d = tv.vval.v_dict
- return {a.dict(tv.vval.v_dict), a.di(first_di(tv.vval.v_dict))}
- end, defalloc},
+ { nil_value },
+ {
+ null_string,
+ nil,
+ function()
+ return { a.freed(alloc_log.null) }
+ end,
+ },
+ { 0 },
+ { int(0) },
+ { true },
+ { false },
+ {
+ 'true',
+ function(tv)
+ return { a.str(tv.vval.v_string) }
+ end,
+ },
+ {
+ {},
+ function(tv)
+ return { a.dict(tv.vval.v_dict) }
+ end,
+ },
+ {
+ empty_list,
+ function(tv)
+ return { a.list(tv.vval.v_list) }
+ end,
+ },
+ {
+ ll,
+ function(tv)
+ ll_l = tv.vval.v_list
+ return { a.list(tv.vval.v_list), a.li(tv.vval.v_list.lv_first) }
+ end,
+ defalloc,
+ },
+ {
+ dd,
+ function(tv)
+ dd_d = tv.vval.v_dict
+ return { a.dict(tv.vval.v_dict), a.di(first_di(tv.vval.v_dict)) }
+ end,
+ defalloc,
+ },
}) do
local tv = lua2typvalt(v[1])
local alloc_rets = {}
@@ -2503,26 +2745,45 @@ describe('typval.c', function()
describe('copy()', function()
itp('works', function()
local function strallocs(tv)
- return {a.str(tv.vval.v_string)}
+ return { a.str(tv.vval.v_string) }
end
for _, v in ipairs({
- {nil_value},
- {null_string},
- {0},
- {int(0)},
- {true},
- {false},
- {{}, function(tv) return {a.dict(tv.vval.v_dict)} end, nil, function(from, to)
- eq(2, to.vval.v_dict.dv_refcount)
- eq(to.vval.v_dict, from.vval.v_dict)
- end},
- {empty_list, function(tv) return {a.list(tv.vval.v_list)} end, nil, function(from, to)
- eq(2, to.vval.v_list.lv_refcount)
- eq(to.vval.v_list, from.vval.v_list)
- end},
- {'test', strallocs, strallocs, function(from, to)
- neq(to.vval.v_string, from.vval.v_string)
- end},
+ { nil_value },
+ { null_string },
+ { 0 },
+ { int(0) },
+ { true },
+ { false },
+ {
+ {},
+ function(tv)
+ return { a.dict(tv.vval.v_dict) }
+ end,
+ nil,
+ function(from, to)
+ eq(2, to.vval.v_dict.dv_refcount)
+ eq(to.vval.v_dict, from.vval.v_dict)
+ end,
+ },
+ {
+ empty_list,
+ function(tv)
+ return { a.list(tv.vval.v_list) }
+ end,
+ nil,
+ function(from, to)
+ eq(2, to.vval.v_list.lv_refcount)
+ eq(to.vval.v_list, from.vval.v_list)
+ end,
+ },
+ {
+ 'test',
+ strallocs,
+ strallocs,
+ function(from, to)
+ neq(to.vval.v_string, from.vval.v_string)
+ end,
+ },
}) do
local from = lua2typvalt(v[1])
alloc_log:check((v[2] or defalloc)(from))
@@ -2540,9 +2801,9 @@ describe('typval.c', function()
describe('item_lock()', function()
itp('does not alter VAR_PARTIAL', function()
local p_tv = lua2typvalt({
- [type_key]=func_type,
- value='tr',
- dict={},
+ [type_key] = func_type,
+ value = 'tr',
+ dict = {},
})
lib.tv_item_lock(p_tv, -1, true, false)
eq(lib.VAR_UNLOCKED, p_tv.vval.v_partial.pt_dict.dv_lock)
@@ -2641,18 +2902,18 @@ describe('typval.c', function()
end
itp('works', function()
eq(false, tv_check_lock(lib.VAR_UNLOCKED, 'test', 3))
- eq(true, tv_check_lock(lib.VAR_LOCKED, 'test', 3,
- 'E741: Value is locked: tes'))
- eq(true, tv_check_lock(lib.VAR_FIXED, 'test', 3,
- 'E742: Cannot change value of tes'))
- eq(true, tv_check_lock(lib.VAR_LOCKED, nil, 0,
- 'E741: Value is locked: Unknown'))
- eq(true, tv_check_lock(lib.VAR_FIXED, nil, 0,
- 'E742: Cannot change value of Unknown'))
- eq(true, tv_check_lock(lib.VAR_LOCKED, nil, lib.kTVCstring,
- 'E741: Value is locked: Unknown'))
- eq(true, tv_check_lock(lib.VAR_FIXED, 'test', lib.kTVCstring,
- 'E742: Cannot change value of test'))
+ eq(true, tv_check_lock(lib.VAR_LOCKED, 'test', 3, 'E741: Value is locked: tes'))
+ eq(true, tv_check_lock(lib.VAR_FIXED, 'test', 3, 'E742: Cannot change value of tes'))
+ eq(true, tv_check_lock(lib.VAR_LOCKED, nil, 0, 'E741: Value is locked: Unknown'))
+ eq(true, tv_check_lock(lib.VAR_FIXED, nil, 0, 'E742: Cannot change value of Unknown'))
+ eq(
+ true,
+ tv_check_lock(lib.VAR_LOCKED, nil, lib.kTVCstring, 'E741: Value is locked: Unknown')
+ )
+ eq(
+ true,
+ tv_check_lock(lib.VAR_FIXED, 'test', lib.kTVCstring, 'E742: Cannot change value of test')
+ )
end)
end)
describe('equal()', function()
@@ -2683,15 +2944,15 @@ describe('typval.c', function()
-- indicates that tv_equal_recurse_limit and recursive_cnt were set which
-- is essential. This argument will be set when comparing inner lists.
itp('compares lists correctly when case is not ignored', function()
- local l1 = lua2typvalt({'abc', {1, 2, 'Abc'}, 'def'})
- local l2 = lua2typvalt({'abc', {1, 2, 'Abc'}})
- local l3 = lua2typvalt({'abc', {1, 2, 'Abc'}, 'Def'})
- local l4 = lua2typvalt({'abc', {1, 2, 'Abc', 4}, 'def'})
- local l5 = lua2typvalt({'Abc', {1, 2, 'Abc'}, 'def'})
- local l6 = lua2typvalt({'abc', {1, 2, 'Abc'}, 'def'})
- local l7 = lua2typvalt({'abc', {1, 2, 'abc'}, 'def'})
- local l8 = lua2typvalt({'abc', nil, 'def'})
- local l9 = lua2typvalt({'abc', {1, 2, nil}, 'def'})
+ local l1 = lua2typvalt({ 'abc', { 1, 2, 'Abc' }, 'def' })
+ local l2 = lua2typvalt({ 'abc', { 1, 2, 'Abc' } })
+ local l3 = lua2typvalt({ 'abc', { 1, 2, 'Abc' }, 'Def' })
+ local l4 = lua2typvalt({ 'abc', { 1, 2, 'Abc', 4 }, 'def' })
+ local l5 = lua2typvalt({ 'Abc', { 1, 2, 'Abc' }, 'def' })
+ local l6 = lua2typvalt({ 'abc', { 1, 2, 'Abc' }, 'def' })
+ local l7 = lua2typvalt({ 'abc', { 1, 2, 'abc' }, 'def' })
+ local l8 = lua2typvalt({ 'abc', nil, 'def' })
+ local l9 = lua2typvalt({ 'abc', { 1, 2, nil }, 'def' })
eq(true, lib.tv_equal(l1, l1, false, false))
eq(false, lib.tv_equal(l1, l2, false, false))
@@ -2704,15 +2965,15 @@ describe('typval.c', function()
eq(false, lib.tv_equal(l1, l9, false, false))
end)
itp('compares lists correctly when case is ignored', function()
- local l1 = lua2typvalt({'abc', {1, 2, 'Abc'}, 'def'})
- local l2 = lua2typvalt({'abc', {1, 2, 'Abc'}})
- local l3 = lua2typvalt({'abc', {1, 2, 'Abc'}, 'Def'})
- local l4 = lua2typvalt({'abc', {1, 2, 'Abc', 4}, 'def'})
- local l5 = lua2typvalt({'Abc', {1, 2, 'Abc'}, 'def'})
- local l6 = lua2typvalt({'abc', {1, 2, 'Abc'}, 'def'})
- local l7 = lua2typvalt({'abc', {1, 2, 'abc'}, 'def'})
- local l8 = lua2typvalt({'abc', nil, 'def'})
- local l9 = lua2typvalt({'abc', {1, 2, nil}, 'def'})
+ local l1 = lua2typvalt({ 'abc', { 1, 2, 'Abc' }, 'def' })
+ local l2 = lua2typvalt({ 'abc', { 1, 2, 'Abc' } })
+ local l3 = lua2typvalt({ 'abc', { 1, 2, 'Abc' }, 'Def' })
+ local l4 = lua2typvalt({ 'abc', { 1, 2, 'Abc', 4 }, 'def' })
+ local l5 = lua2typvalt({ 'Abc', { 1, 2, 'Abc' }, 'def' })
+ local l6 = lua2typvalt({ 'abc', { 1, 2, 'Abc' }, 'def' })
+ local l7 = lua2typvalt({ 'abc', { 1, 2, 'abc' }, 'def' })
+ local l8 = lua2typvalt({ 'abc', nil, 'def' })
+ local l9 = lua2typvalt({ 'abc', { 1, 2, nil }, 'def' })
eq(true, lib.tv_equal(l1, l1, true, false))
eq(false, lib.tv_equal(l1, l2, true, false))
@@ -2732,20 +2993,20 @@ describe('typval.c', function()
eq(true, tv_equal(nd, nd))
alloc_log:check({})
local d1 = lua2typvalt({})
- alloc_log:check({a.dict(d1.vval.v_dict)})
+ alloc_log:check({ a.dict(d1.vval.v_dict) })
eq(1, d1.vval.v_dict.dv_refcount)
eq(true, tv_equal(nd, d1))
eq(true, tv_equal(d1, nd))
eq(true, tv_equal(d1, d1))
eq(1, d1.vval.v_dict.dv_refcount)
alloc_log:check({})
- local d_upper = lua2typvalt({a='TEST'})
+ local d_upper = lua2typvalt({ a = 'TEST' })
local dis_upper = dict_items(d_upper.vval.v_dict)
- local d_lower = lua2typvalt({a='test'})
+ local d_lower = lua2typvalt({ a = 'test' })
local dis_lower = dict_items(d_lower.vval.v_dict)
- local d_kupper_upper = lua2typvalt({A='TEST'})
+ local d_kupper_upper = lua2typvalt({ A = 'TEST' })
local dis_kupper_upper = dict_items(d_kupper_upper.vval.v_dict)
- local d_kupper_lower = lua2typvalt({A='test'})
+ local d_kupper_lower = lua2typvalt({ A = 'test' })
local dis_kupper_lower = dict_items(d_kupper_lower.vval.v_dict)
alloc_log:clear_tmp_allocs()
alloc_log:check({
@@ -2781,24 +3042,31 @@ describe('typval.c', function()
itp('works', function()
local tv = typvalt()
local mem = lib.xmalloc(1)
- tv.vval.v_list = mem -- Should crash when actually accessed
+ tv.vval.v_list = mem -- Should crash when actually accessed
alloc_log:clear()
for _, v in ipairs({
- {lib.VAR_NUMBER, nil},
- {lib.VAR_FLOAT, 'E805: Expected a Number or a String, Float found'},
- {lib.VAR_PARTIAL, 'E703: Expected a Number or a String, Funcref found'},
- {lib.VAR_FUNC, 'E703: Expected a Number or a String, Funcref found'},
- {lib.VAR_LIST, 'E745: Expected a Number or a String, List found'},
- {lib.VAR_DICT, 'E728: Expected a Number or a String, Dictionary found'},
- {lib.VAR_SPECIAL, 'E5300: Expected a Number or a String'},
- {lib.VAR_UNKNOWN, 'E685: Internal error: tv_check_str_or_nr(UNKNOWN)'},
+ { lib.VAR_NUMBER, nil },
+ { lib.VAR_FLOAT, 'E805: Expected a Number or a String, Float found' },
+ { lib.VAR_PARTIAL, 'E703: Expected a Number or a String, Funcref found' },
+ { lib.VAR_FUNC, 'E703: Expected a Number or a String, Funcref found' },
+ { lib.VAR_LIST, 'E745: Expected a Number or a String, List found' },
+ { lib.VAR_DICT, 'E728: Expected a Number or a String, Dictionary found' },
+ { lib.VAR_SPECIAL, 'E5300: Expected a Number or a String' },
+ { lib.VAR_UNKNOWN, 'E685: Internal error: tv_check_str_or_nr(UNKNOWN)' },
}) do
local typ = v[1]
local emsg = v[2]
local ret = true
- if emsg then ret = false end
+ if emsg then
+ ret = false
+ end
tv.v_type = typ
- eq(ret, check_emsg(function() return lib.tv_check_str_or_nr(tv) end, emsg))
+ eq(
+ ret,
+ check_emsg(function()
+ return lib.tv_check_str_or_nr(tv)
+ end, emsg)
+ )
if emsg then
alloc_log:clear()
else
@@ -2811,24 +3079,31 @@ describe('typval.c', function()
itp('works', function()
local tv = typvalt()
local mem = lib.xmalloc(1)
- tv.vval.v_list = mem -- Should crash when actually accessed
+ tv.vval.v_list = mem -- Should crash when actually accessed
alloc_log:clear()
for _, v in ipairs({
- {lib.VAR_NUMBER, nil},
- {lib.VAR_FLOAT, 'E805: Using a Float as a Number'},
- {lib.VAR_PARTIAL, 'E703: Using a Funcref as a Number'},
- {lib.VAR_FUNC, 'E703: Using a Funcref as a Number'},
- {lib.VAR_LIST, 'E745: Using a List as a Number'},
- {lib.VAR_DICT, 'E728: Using a Dictionary as a Number'},
- {lib.VAR_SPECIAL, nil},
- {lib.VAR_UNKNOWN, 'E685: using an invalid value as a Number'},
+ { lib.VAR_NUMBER, nil },
+ { lib.VAR_FLOAT, 'E805: Using a Float as a Number' },
+ { lib.VAR_PARTIAL, 'E703: Using a Funcref as a Number' },
+ { lib.VAR_FUNC, 'E703: Using a Funcref as a Number' },
+ { lib.VAR_LIST, 'E745: Using a List as a Number' },
+ { lib.VAR_DICT, 'E728: Using a Dictionary as a Number' },
+ { lib.VAR_SPECIAL, nil },
+ { lib.VAR_UNKNOWN, 'E685: using an invalid value as a Number' },
}) do
local typ = v[1]
local emsg = v[2]
local ret = true
- if emsg then ret = false end
+ if emsg then
+ ret = false
+ end
tv.v_type = typ
- eq(ret, check_emsg(function() return lib.tv_check_num(tv) end, emsg))
+ eq(
+ ret,
+ check_emsg(function()
+ return lib.tv_check_num(tv)
+ end, emsg)
+ )
if emsg then
alloc_log:clear()
else
@@ -2841,25 +3116,32 @@ describe('typval.c', function()
itp('works', function()
local tv = typvalt()
local mem = lib.xmalloc(1)
- tv.vval.v_list = mem -- Should crash when actually accessed
+ tv.vval.v_list = mem -- Should crash when actually accessed
alloc_log:clear()
for _, v in ipairs({
- {lib.VAR_NUMBER, nil},
- {lib.VAR_FLOAT, nil},
- {lib.VAR_PARTIAL, 'E729: Using a Funcref as a String'},
- {lib.VAR_FUNC, 'E729: Using a Funcref as a String'},
- {lib.VAR_LIST, 'E730: Using a List as a String'},
- {lib.VAR_DICT, 'E731: Using a Dictionary as a String'},
- {lib.VAR_BOOL, nil},
- {lib.VAR_SPECIAL, nil},
- {lib.VAR_UNKNOWN, 'E908: Using an invalid value as a String'},
+ { lib.VAR_NUMBER, nil },
+ { lib.VAR_FLOAT, nil },
+ { lib.VAR_PARTIAL, 'E729: Using a Funcref as a String' },
+ { lib.VAR_FUNC, 'E729: Using a Funcref as a String' },
+ { lib.VAR_LIST, 'E730: Using a List as a String' },
+ { lib.VAR_DICT, 'E731: Using a Dictionary as a String' },
+ { lib.VAR_BOOL, nil },
+ { lib.VAR_SPECIAL, nil },
+ { lib.VAR_UNKNOWN, 'E908: Using an invalid value as a String' },
}) do
local typ = v[1]
local emsg = v[2]
local ret = true
- if emsg then ret = false end
+ if emsg then
+ ret = false
+ end
tv.v_type = typ
- eq(ret, check_emsg(function() return lib.tv_check_str(tv) end, emsg))
+ eq(
+ ret,
+ check_emsg(function()
+ return lib.tv_check_str(tv)
+ end, emsg)
+ )
if emsg then
alloc_log:clear()
else
@@ -2873,24 +3155,29 @@ describe('typval.c', function()
describe('number()', function()
itp('works', function()
for _, v in ipairs({
- {lib.VAR_NUMBER, {v_number=42}, nil, 42},
- {lib.VAR_STRING, {v_string=to_cstr('100500')}, nil, 100500},
- {lib.VAR_FLOAT, {v_float=42.53}, 'E805: Using a Float as a Number', 0},
- {lib.VAR_PARTIAL, {v_partial=NULL}, 'E703: Using a Funcref as a Number', 0},
- {lib.VAR_FUNC, {v_string=NULL}, 'E703: Using a Funcref as a Number', 0},
- {lib.VAR_LIST, {v_list=NULL}, 'E745: Using a List as a Number', 0},
- {lib.VAR_DICT, {v_dict=NULL}, 'E728: Using a Dictionary as a Number', 0},
- {lib.VAR_SPECIAL, {v_special=lib.kSpecialVarNull}, nil, 0},
- {lib.VAR_BOOL, {v_bool=lib.kBoolVarTrue}, nil, 1},
- {lib.VAR_BOOL, {v_bool=lib.kBoolVarFalse}, nil, 0},
- {lib.VAR_UNKNOWN, nil, 'E685: Internal error: tv_get_number(UNKNOWN)', 0},
+ { lib.VAR_NUMBER, { v_number = 42 }, nil, 42 },
+ { lib.VAR_STRING, { v_string = to_cstr('100500') }, nil, 100500 },
+ { lib.VAR_FLOAT, { v_float = 42.53 }, 'E805: Using a Float as a Number', 0 },
+ { lib.VAR_PARTIAL, { v_partial = NULL }, 'E703: Using a Funcref as a Number', 0 },
+ { lib.VAR_FUNC, { v_string = NULL }, 'E703: Using a Funcref as a Number', 0 },
+ { lib.VAR_LIST, { v_list = NULL }, 'E745: Using a List as a Number', 0 },
+ { lib.VAR_DICT, { v_dict = NULL }, 'E728: Using a Dictionary as a Number', 0 },
+ { lib.VAR_SPECIAL, { v_special = lib.kSpecialVarNull }, nil, 0 },
+ { lib.VAR_BOOL, { v_bool = lib.kBoolVarTrue }, nil, 1 },
+ { lib.VAR_BOOL, { v_bool = lib.kBoolVarFalse }, nil, 0 },
+ { lib.VAR_UNKNOWN, nil, 'E685: Internal error: tv_get_number(UNKNOWN)', 0 },
}) do
-- Using to_cstr, cannot free with tv_clear
local tv = ffi.gc(typvalt(v[1], v[2]), nil)
alloc_log:check({})
local emsg = v[3]
local ret = v[4]
- eq(ret, check_emsg(function() return lib.tv_get_number(tv) end, emsg))
+ eq(
+ ret,
+ check_emsg(function()
+ return lib.tv_get_number(tv)
+ end, emsg)
+ )
if emsg then
alloc_log:clear()
else
@@ -2902,28 +3189,31 @@ describe('typval.c', function()
describe('number_chk()', function()
itp('works', function()
for _, v in ipairs({
- {lib.VAR_NUMBER, {v_number=42}, nil, 42},
- {lib.VAR_STRING, {v_string=to_cstr('100500')}, nil, 100500},
- {lib.VAR_FLOAT, {v_float=42.53}, 'E805: Using a Float as a Number', 0},
- {lib.VAR_PARTIAL, {v_partial=NULL}, 'E703: Using a Funcref as a Number', 0},
- {lib.VAR_FUNC, {v_string=NULL}, 'E703: Using a Funcref as a Number', 0},
- {lib.VAR_LIST, {v_list=NULL}, 'E745: Using a List as a Number', 0},
- {lib.VAR_DICT, {v_dict=NULL}, 'E728: Using a Dictionary as a Number', 0},
- {lib.VAR_SPECIAL, {v_special=lib.kSpecialVarNull}, nil, 0},
- {lib.VAR_BOOL, {v_bool=lib.kBoolVarTrue}, nil, 1},
- {lib.VAR_BOOL, {v_bool=lib.kBoolVarFalse}, nil, 0},
- {lib.VAR_UNKNOWN, nil, 'E685: Internal error: tv_get_number(UNKNOWN)', 0},
+ { lib.VAR_NUMBER, { v_number = 42 }, nil, 42 },
+ { lib.VAR_STRING, { v_string = to_cstr('100500') }, nil, 100500 },
+ { lib.VAR_FLOAT, { v_float = 42.53 }, 'E805: Using a Float as a Number', 0 },
+ { lib.VAR_PARTIAL, { v_partial = NULL }, 'E703: Using a Funcref as a Number', 0 },
+ { lib.VAR_FUNC, { v_string = NULL }, 'E703: Using a Funcref as a Number', 0 },
+ { lib.VAR_LIST, { v_list = NULL }, 'E745: Using a List as a Number', 0 },
+ { lib.VAR_DICT, { v_dict = NULL }, 'E728: Using a Dictionary as a Number', 0 },
+ { lib.VAR_SPECIAL, { v_special = lib.kSpecialVarNull }, nil, 0 },
+ { lib.VAR_BOOL, { v_bool = lib.kBoolVarTrue }, nil, 1 },
+ { lib.VAR_BOOL, { v_bool = lib.kBoolVarFalse }, nil, 0 },
+ { lib.VAR_UNKNOWN, nil, 'E685: Internal error: tv_get_number(UNKNOWN)', 0 },
}) do
-- Using to_cstr, cannot free with tv_clear
local tv = ffi.gc(typvalt(v[1], v[2]), nil)
alloc_log:check({})
local emsg = v[3]
- local ret = {v[4], not not emsg}
- eq(ret, check_emsg(function()
- local err = ffi.new('bool[1]', {false})
- local res = lib.tv_get_number_chk(tv, err)
- return {res, err[0]}
- end, emsg))
+ local ret = { v[4], not not emsg }
+ eq(
+ ret,
+ check_emsg(function()
+ local err = ffi.new('bool[1]', { false })
+ local res = lib.tv_get_number_chk(tv, err)
+ return { res, err[0] }
+ end, emsg)
+ )
if emsg then
alloc_log:clear()
else
@@ -2935,18 +3225,18 @@ describe('typval.c', function()
describe('lnum()', function()
itp('works', function()
for _, v in ipairs({
- {lib.VAR_NUMBER, {v_number=42}, nil, 42},
- {lib.VAR_STRING, {v_string=to_cstr('100500')}, nil, 100500},
- {lib.VAR_STRING, {v_string=to_cstr('.')}, nil, 46},
- {lib.VAR_FLOAT, {v_float=42.53}, 'E805: Using a Float as a Number', -1},
- {lib.VAR_PARTIAL, {v_partial=NULL}, 'E703: Using a Funcref as a Number', -1},
- {lib.VAR_FUNC, {v_string=NULL}, 'E703: Using a Funcref as a Number', -1},
- {lib.VAR_LIST, {v_list=NULL}, 'E745: Using a List as a Number', -1},
- {lib.VAR_DICT, {v_dict=NULL}, 'E728: Using a Dictionary as a Number', -1},
- {lib.VAR_SPECIAL, {v_special=lib.kSpecialVarNull}, nil, 0},
- {lib.VAR_BOOL, {v_bool=lib.kBoolVarTrue}, nil, 1},
- {lib.VAR_BOOL, {v_bool=lib.kBoolVarFalse}, nil, 0},
- {lib.VAR_UNKNOWN, nil, 'E685: Internal error: tv_get_number(UNKNOWN)', -1},
+ { lib.VAR_NUMBER, { v_number = 42 }, nil, 42 },
+ { lib.VAR_STRING, { v_string = to_cstr('100500') }, nil, 100500 },
+ { lib.VAR_STRING, { v_string = to_cstr('.') }, nil, 46 },
+ { lib.VAR_FLOAT, { v_float = 42.53 }, 'E805: Using a Float as a Number', -1 },
+ { lib.VAR_PARTIAL, { v_partial = NULL }, 'E703: Using a Funcref as a Number', -1 },
+ { lib.VAR_FUNC, { v_string = NULL }, 'E703: Using a Funcref as a Number', -1 },
+ { lib.VAR_LIST, { v_list = NULL }, 'E745: Using a List as a Number', -1 },
+ { lib.VAR_DICT, { v_dict = NULL }, 'E728: Using a Dictionary as a Number', -1 },
+ { lib.VAR_SPECIAL, { v_special = lib.kSpecialVarNull }, nil, 0 },
+ { lib.VAR_BOOL, { v_bool = lib.kBoolVarTrue }, nil, 1 },
+ { lib.VAR_BOOL, { v_bool = lib.kBoolVarFalse }, nil, 0 },
+ { lib.VAR_UNKNOWN, nil, 'E685: Internal error: tv_get_number(UNKNOWN)', -1 },
}) do
lib.curwin.w_cursor.lnum = 46
-- Using to_cstr, cannot free with tv_clear
@@ -2954,7 +3244,12 @@ describe('typval.c', function()
alloc_log:check({})
local emsg = v[3]
local ret = v[4]
- eq(ret, check_emsg(function() return lib.tv_get_lnum(tv) end, emsg))
+ eq(
+ ret,
+ check_emsg(function()
+ return lib.tv_get_lnum(tv)
+ end, emsg)
+ )
if emsg then
alloc_log:clear()
else
@@ -2966,24 +3261,49 @@ describe('typval.c', function()
describe('float()', function()
itp('works', function()
for _, v in ipairs({
- {lib.VAR_NUMBER, {v_number=42}, nil, 42},
- {lib.VAR_STRING, {v_string=to_cstr('100500')}, 'E892: Using a String as a Float', 0},
- {lib.VAR_FLOAT, {v_float=42.53}, nil, 42.53},
- {lib.VAR_PARTIAL, {v_partial=NULL}, 'E891: Using a Funcref as a Float', 0},
- {lib.VAR_FUNC, {v_string=NULL}, 'E891: Using a Funcref as a Float', 0},
- {lib.VAR_LIST, {v_list=NULL}, 'E893: Using a List as a Float', 0},
- {lib.VAR_DICT, {v_dict=NULL}, 'E894: Using a Dictionary as a Float', 0},
- {lib.VAR_SPECIAL, {v_special=lib.kSpecialVarNull}, 'E907: Using a special value as a Float', 0},
- {lib.VAR_BOOL, {v_bool=lib.kBoolVarTrue}, 'E362: Using a boolean value as a Float', 0},
- {lib.VAR_BOOL, {v_bool=lib.kBoolVarFalse}, 'E362: Using a boolean value as a Float', 0},
- {lib.VAR_UNKNOWN, nil, 'E685: Internal error: tv_get_float(UNKNOWN)', 0},
+ { lib.VAR_NUMBER, { v_number = 42 }, nil, 42 },
+ {
+ lib.VAR_STRING,
+ { v_string = to_cstr('100500') },
+ 'E892: Using a String as a Float',
+ 0,
+ },
+ { lib.VAR_FLOAT, { v_float = 42.53 }, nil, 42.53 },
+ { lib.VAR_PARTIAL, { v_partial = NULL }, 'E891: Using a Funcref as a Float', 0 },
+ { lib.VAR_FUNC, { v_string = NULL }, 'E891: Using a Funcref as a Float', 0 },
+ { lib.VAR_LIST, { v_list = NULL }, 'E893: Using a List as a Float', 0 },
+ { lib.VAR_DICT, { v_dict = NULL }, 'E894: Using a Dictionary as a Float', 0 },
+ {
+ lib.VAR_SPECIAL,
+ { v_special = lib.kSpecialVarNull },
+ 'E907: Using a special value as a Float',
+ 0,
+ },
+ {
+ lib.VAR_BOOL,
+ { v_bool = lib.kBoolVarTrue },
+ 'E362: Using a boolean value as a Float',
+ 0,
+ },
+ {
+ lib.VAR_BOOL,
+ { v_bool = lib.kBoolVarFalse },
+ 'E362: Using a boolean value as a Float',
+ 0,
+ },
+ { lib.VAR_UNKNOWN, nil, 'E685: Internal error: tv_get_float(UNKNOWN)', 0 },
}) do
-- Using to_cstr, cannot free with tv_clear
local tv = ffi.gc(typvalt(v[1], v[2]), nil)
alloc_log:check({})
local emsg = v[3]
local ret = v[4]
- eq(ret, check_emsg(function() return lib.tv_get_float(tv) end, emsg))
+ eq(
+ ret,
+ check_emsg(function()
+ return lib.tv_get_float(tv)
+ end, emsg)
+ )
if emsg then
alloc_log:clear()
else
@@ -3001,24 +3321,31 @@ describe('typval.c', function()
alloc_log:check({})
local emsg = v[3]
local ret = v[4]
- eq(ret, check_emsg(function()
- local res, buf = fn(tv)
- if tv.v_type == lib.VAR_NUMBER or tv.v_type == lib.VAR_FLOAT
- or tv.v_type == lib.VAR_SPECIAL or tv.v_type == lib.VAR_BOOL then
- eq(buf, res)
- else
- neq(buf, res)
- end
- if res ~= nil then
- return ffi.string(res)
- else
- return nil
- end
- end, emsg))
+ eq(
+ ret,
+ check_emsg(function()
+ local res, buf = fn(tv)
+ if
+ tv.v_type == lib.VAR_NUMBER
+ or tv.v_type == lib.VAR_FLOAT
+ or tv.v_type == lib.VAR_SPECIAL
+ or tv.v_type == lib.VAR_BOOL
+ then
+ eq(buf, res)
+ else
+ neq(buf, res)
+ end
+ if res ~= nil then
+ return ffi.string(res)
+ else
+ return nil
+ end
+ end, emsg)
+ )
if emsg then
alloc_log:clear()
elseif tv.v_type == lib.VAR_FLOAT then
- alloc_log:check({a.freed(alloc_log.null), a.freed(alloc_log.null)})
+ alloc_log:check({ a.freed(alloc_log.null), a.freed(alloc_log.null) })
else
alloc_log:check({})
end
@@ -3030,17 +3357,17 @@ describe('typval.c', function()
local buf_chk = lib.tv_get_string_chk(lua2typvalt(int(1)))
neq(buf, buf_chk)
test_string_fn({
- {lib.VAR_NUMBER, {v_number=42}, nil, '42'},
- {lib.VAR_STRING, {v_string=to_cstr('100500')}, nil, '100500'},
- {lib.VAR_FLOAT, {v_float=42.53}, nil, '42.53'},
- {lib.VAR_PARTIAL, {v_partial=NULL}, 'E729: Using a Funcref as a String', ''},
- {lib.VAR_FUNC, {v_string=NULL}, 'E729: Using a Funcref as a String', ''},
- {lib.VAR_LIST, {v_list=NULL}, 'E730: Using a List as a String', ''},
- {lib.VAR_DICT, {v_dict=NULL}, 'E731: Using a Dictionary as a String', ''},
- {lib.VAR_SPECIAL, {v_special=lib.kSpecialVarNull}, nil, 'v:null'},
- {lib.VAR_BOOL, {v_bool=lib.kBoolVarTrue}, nil, 'v:true'},
- {lib.VAR_BOOL, {v_bool=lib.kBoolVarFalse}, nil, 'v:false'},
- {lib.VAR_UNKNOWN, nil, 'E908: Using an invalid value as a String', ''},
+ { lib.VAR_NUMBER, { v_number = 42 }, nil, '42' },
+ { lib.VAR_STRING, { v_string = to_cstr('100500') }, nil, '100500' },
+ { lib.VAR_FLOAT, { v_float = 42.53 }, nil, '42.53' },
+ { lib.VAR_PARTIAL, { v_partial = NULL }, 'E729: Using a Funcref as a String', '' },
+ { lib.VAR_FUNC, { v_string = NULL }, 'E729: Using a Funcref as a String', '' },
+ { lib.VAR_LIST, { v_list = NULL }, 'E730: Using a List as a String', '' },
+ { lib.VAR_DICT, { v_dict = NULL }, 'E731: Using a Dictionary as a String', '' },
+ { lib.VAR_SPECIAL, { v_special = lib.kSpecialVarNull }, nil, 'v:null' },
+ { lib.VAR_BOOL, { v_bool = lib.kBoolVarTrue }, nil, 'v:true' },
+ { lib.VAR_BOOL, { v_bool = lib.kBoolVarFalse }, nil, 'v:false' },
+ { lib.VAR_UNKNOWN, nil, 'E908: Using an invalid value as a String', '' },
}, function(tv)
return lib.tv_get_string(tv), buf
end)
@@ -3050,17 +3377,17 @@ describe('typval.c', function()
itp('works', function()
local buf = lib.tv_get_string_chk(lua2typvalt(int(1)))
test_string_fn({
- {lib.VAR_NUMBER, {v_number=42}, nil, '42'},
- {lib.VAR_STRING, {v_string=to_cstr('100500')}, nil, '100500'},
- {lib.VAR_FLOAT, {v_float=42.53}, nil, '42.53'},
- {lib.VAR_PARTIAL, {v_partial=NULL}, 'E729: Using a Funcref as a String', nil},
- {lib.VAR_FUNC, {v_string=NULL}, 'E729: Using a Funcref as a String', nil},
- {lib.VAR_LIST, {v_list=NULL}, 'E730: Using a List as a String', nil},
- {lib.VAR_DICT, {v_dict=NULL}, 'E731: Using a Dictionary as a String', nil},
- {lib.VAR_SPECIAL, {v_special=lib.kSpecialVarNull}, nil, 'v:null'},
- {lib.VAR_BOOL, {v_bool=lib.kBoolVarTrue}, nil, 'v:true'},
- {lib.VAR_BOOL, {v_bool=lib.kBoolVarFalse}, nil, 'v:false'},
- {lib.VAR_UNKNOWN, nil, 'E908: Using an invalid value as a String', nil},
+ { lib.VAR_NUMBER, { v_number = 42 }, nil, '42' },
+ { lib.VAR_STRING, { v_string = to_cstr('100500') }, nil, '100500' },
+ { lib.VAR_FLOAT, { v_float = 42.53 }, nil, '42.53' },
+ { lib.VAR_PARTIAL, { v_partial = NULL }, 'E729: Using a Funcref as a String', nil },
+ { lib.VAR_FUNC, { v_string = NULL }, 'E729: Using a Funcref as a String', nil },
+ { lib.VAR_LIST, { v_list = NULL }, 'E730: Using a List as a String', nil },
+ { lib.VAR_DICT, { v_dict = NULL }, 'E731: Using a Dictionary as a String', nil },
+ { lib.VAR_SPECIAL, { v_special = lib.kSpecialVarNull }, nil, 'v:null' },
+ { lib.VAR_BOOL, { v_bool = lib.kBoolVarTrue }, nil, 'v:true' },
+ { lib.VAR_BOOL, { v_bool = lib.kBoolVarFalse }, nil, 'v:false' },
+ { lib.VAR_UNKNOWN, nil, 'E908: Using an invalid value as a String', nil },
}, function(tv)
return lib.tv_get_string_chk(tv), buf
end)
@@ -3069,19 +3396,19 @@ describe('typval.c', function()
describe('string_buf()', function()
itp('works', function()
test_string_fn({
- {lib.VAR_NUMBER, {v_number=42}, nil, '42'},
- {lib.VAR_STRING, {v_string=to_cstr('100500')}, nil, '100500'},
- {lib.VAR_FLOAT, {v_float=42.53}, nil, '42.53'},
- {lib.VAR_PARTIAL, {v_partial=NULL}, 'E729: Using a Funcref as a String', ''},
- {lib.VAR_FUNC, {v_string=NULL}, 'E729: Using a Funcref as a String', ''},
- {lib.VAR_LIST, {v_list=NULL}, 'E730: Using a List as a String', ''},
- {lib.VAR_DICT, {v_dict=NULL}, 'E731: Using a Dictionary as a String', ''},
- {lib.VAR_SPECIAL, {v_special=lib.kSpecialVarNull}, nil, 'v:null'},
- {lib.VAR_BOOL, {v_bool=lib.kBoolVarTrue}, nil, 'v:true'},
- {lib.VAR_BOOL, {v_bool=lib.kBoolVarFalse}, nil, 'v:false'},
- {lib.VAR_UNKNOWN, nil, 'E908: Using an invalid value as a String', ''},
+ { lib.VAR_NUMBER, { v_number = 42 }, nil, '42' },
+ { lib.VAR_STRING, { v_string = to_cstr('100500') }, nil, '100500' },
+ { lib.VAR_FLOAT, { v_float = 42.53 }, nil, '42.53' },
+ { lib.VAR_PARTIAL, { v_partial = NULL }, 'E729: Using a Funcref as a String', '' },
+ { lib.VAR_FUNC, { v_string = NULL }, 'E729: Using a Funcref as a String', '' },
+ { lib.VAR_LIST, { v_list = NULL }, 'E730: Using a List as a String', '' },
+ { lib.VAR_DICT, { v_dict = NULL }, 'E731: Using a Dictionary as a String', '' },
+ { lib.VAR_SPECIAL, { v_special = lib.kSpecialVarNull }, nil, 'v:null' },
+ { lib.VAR_BOOL, { v_bool = lib.kBoolVarTrue }, nil, 'v:true' },
+ { lib.VAR_BOOL, { v_bool = lib.kBoolVarFalse }, nil, 'v:false' },
+ { lib.VAR_UNKNOWN, nil, 'E908: Using an invalid value as a String', '' },
}, function(tv)
- local buf = ffi.new('char[?]', lib.NUMBUFLEN, {0})
+ local buf = ffi.new('char[?]', lib.NUMBUFLEN, { 0 })
return lib.tv_get_string_buf(tv, buf), buf
end)
end)
@@ -3089,19 +3416,19 @@ describe('typval.c', function()
describe('string_buf_chk()', function()
itp('works', function()
test_string_fn({
- {lib.VAR_NUMBER, {v_number=42}, nil, '42'},
- {lib.VAR_STRING, {v_string=to_cstr('100500')}, nil, '100500'},
- {lib.VAR_FLOAT, {v_float=42.53}, nil, '42.53'},
- {lib.VAR_PARTIAL, {v_partial=NULL}, 'E729: Using a Funcref as a String', nil},
- {lib.VAR_FUNC, {v_string=NULL}, 'E729: Using a Funcref as a String', nil},
- {lib.VAR_LIST, {v_list=NULL}, 'E730: Using a List as a String', nil},
- {lib.VAR_DICT, {v_dict=NULL}, 'E731: Using a Dictionary as a String', nil},
- {lib.VAR_SPECIAL, {v_special=lib.kSpecialVarNull}, nil, 'v:null'},
- {lib.VAR_BOOL, {v_bool=lib.kBoolVarTrue}, nil, 'v:true'},
- {lib.VAR_BOOL, {v_bool=lib.kBoolVarFalse}, nil, 'v:false'},
- {lib.VAR_UNKNOWN, nil, 'E908: Using an invalid value as a String', nil},
+ { lib.VAR_NUMBER, { v_number = 42 }, nil, '42' },
+ { lib.VAR_STRING, { v_string = to_cstr('100500') }, nil, '100500' },
+ { lib.VAR_FLOAT, { v_float = 42.53 }, nil, '42.53' },
+ { lib.VAR_PARTIAL, { v_partial = NULL }, 'E729: Using a Funcref as a String', nil },
+ { lib.VAR_FUNC, { v_string = NULL }, 'E729: Using a Funcref as a String', nil },
+ { lib.VAR_LIST, { v_list = NULL }, 'E730: Using a List as a String', nil },
+ { lib.VAR_DICT, { v_dict = NULL }, 'E731: Using a Dictionary as a String', nil },
+ { lib.VAR_SPECIAL, { v_special = lib.kSpecialVarNull }, nil, 'v:null' },
+ { lib.VAR_BOOL, { v_bool = lib.kBoolVarTrue }, nil, 'v:true' },
+ { lib.VAR_BOOL, { v_bool = lib.kBoolVarFalse }, nil, 'v:false' },
+ { lib.VAR_UNKNOWN, nil, 'E908: Using an invalid value as a String', nil },
}, function(tv)
- local buf = ffi.new('char[?]', lib.NUMBUFLEN, {0})
+ local buf = ffi.new('char[?]', lib.NUMBUFLEN, { 0 })
return lib.tv_get_string_buf_chk(tv, buf), buf
end)
end)
diff --git a/test/unit/fileio_spec.lua b/test/unit/fileio_spec.lua
index 066d013b19..1284f84222 100644
--- a/test/unit/fileio_spec.lua
+++ b/test/unit/fileio_spec.lua
@@ -1,24 +1,23 @@
-local helpers = require("test.unit.helpers")(after_each)
+local helpers = require('test.unit.helpers')(after_each)
local itp = helpers.gen_itp(it)
--{:cimport, :internalize, :eq, :neq, :ffi, :lib, :cstr, :to_cstr} = require 'test.unit.helpers'
-local eq = helpers.eq
-local ffi = helpers.ffi
+local eq = helpers.eq
+local ffi = helpers.ffi
local to_cstr = helpers.to_cstr
-local NULL = helpers.NULL
+local NULL = helpers.NULL
-local fileio = helpers.cimport("./src/nvim/fileio.h")
+local fileio = helpers.cimport('./src/nvim/fileio.h')
describe('file_pat functions', function()
describe('file_pat_to_reg_pat', function()
-
local file_pat_to_reg_pat = function(pat)
local res = fileio.file_pat_to_reg_pat(to_cstr(pat), NULL, NULL, 0)
return ffi.string(res)
end
itp('returns ^path$ regex for literal path input', function()
- eq( '^path$', file_pat_to_reg_pat('path'))
+ eq('^path$', file_pat_to_reg_pat('path'))
end)
itp('does not prepend ^ when there is a starting glob (*)', function()
@@ -34,13 +33,15 @@ describe('file_pat functions', function()
end)
itp('replaces the bash any character (?) with the regex any character (.)', function()
- eq('^foo.bar$', file_pat_to_reg_pat('foo?bar'))
+ eq('^foo.bar$', file_pat_to_reg_pat('foo?bar'))
end)
- itp('replaces a glob (*) in the middle of a path with regex multiple any character (.*)',
- function()
- eq('^foo.*bar$', file_pat_to_reg_pat('foo*bar'))
- end)
+ itp(
+ 'replaces a glob (*) in the middle of a path with regex multiple any character (.*)',
+ function()
+ eq('^foo.*bar$', file_pat_to_reg_pat('foo*bar'))
+ end
+ )
itp([[unescapes \? to ?]], function()
eq('^foo?bar$', file_pat_to_reg_pat([[foo\?bar]]))
diff --git a/test/unit/formatc.lua b/test/unit/formatc.lua
index c94f0d88f7..6bb58c68c3 100644
--- a/test/unit/formatc.lua
+++ b/test/unit/formatc.lua
@@ -24,103 +24,145 @@ SOFTWARE. --]]
-- work.
-- see: http://lua-users.org/wiki/LpegRecipes
-local lpeg = require "lpeg"
+local lpeg = require 'lpeg'
local C, P, R, S, V = lpeg.C, lpeg.P, lpeg.R, lpeg.S, lpeg.V
local Carg, Cc, Cp, Ct = lpeg.Carg, lpeg.Cc, lpeg.Cp, lpeg.Ct
-local tokens = P { "tokens";
+local tokens = P {
+ 'tokens',
-- Comment of form /* ... */
- comment = Ct(P"/*" * C((V"newline" + (1 - P"*/"))^0) * P"*/" * Cc"comment"),
+ comment = Ct(P '/*' * C((V 'newline' + (1 - P '*/')) ^ 0) * P '*/' * Cc 'comment'),
-- Single line comment
- line_comment = Ct(P"//" * C((1 - V"newline")^0) * Cc"comment_line"),
+ line_comment = Ct(P '//' * C((1 - V 'newline') ^ 0) * Cc 'comment_line'),
-- Single platform independent line break which increments line number
- newline = (P"\r\n" + P"\n\r" + S"\r\n") * (Cp() * Carg(1)) / function(pos, state)
+ newline = (P '\r\n' + P '\n\r' + S '\r\n') * (Cp() * Carg(1)) / function(pos, state)
state.line = state.line + 1
state.line_start = pos
end,
-- Line continuation
- line_extend = Ct(C(P[[\]] * V"newline") * Cc"line_extend"),
+ line_extend = Ct(C(P [[\]] * V 'newline') * Cc 'line_extend'),
-- Whitespace of any length (includes newlines)
- whitespace = Ct(C((S" \t" + V"newline")^1) * Cc"whitespace"),
+ whitespace = Ct(C((S ' \t' + V 'newline') ^ 1) * Cc 'whitespace'),
-- Special form of #include with filename followed in angled brackets (matches 3 tokens)
- include = Ct(C(P"#include") * Cc"preprocessor") *
- Ct(C(S" \t"^1) * Cc"whitespace") *
- Ct(C(P"<" * (1 - P">")^1 * P">") * Cc"string"),
+ include = Ct(C(P '#include') * Cc 'preprocessor') * Ct(C(S ' \t' ^ 1) * Cc 'whitespace') * Ct(
+ C(P '<' * (1 - P '>') ^ 1 * P '>') * Cc 'string'
+ ),
-- Preprocessor instruction
- preprocessor = V"include" +
- Ct(C(P"#" * P" "^0 * ( P"define" + P"elif" + P"else" + P"endif" + P"#" +
- P"error" + P"ifdef" + P"ifndef" + P"if" + P"import" +
- P"include" + P"line" + P"pragma" + P"undef" + P"using" +
- P"pragma"
- ) * #S" \r\n\t") * Cc"preprocessor"),
+ preprocessor = V 'include'
+ + Ct(
+ C(
+ P '#'
+ * P ' ' ^ 0
+ * (P 'define' + P 'elif' + P 'else' + P 'endif' + P '#' + P 'error' + P 'ifdef' + P 'ifndef' + P 'if' + P 'import' + P 'include' + P 'line' + P 'pragma' + P 'undef' + P 'using' + P 'pragma')
+ * #S ' \r\n\t'
+ ) * Cc 'preprocessor'
+ ),
-- Identifier of form [a-zA-Z_][a-zA-Z0-9_]*
- identifier = Ct(C(R("az","AZ","__") * R("09","az","AZ","__")^0) * Cc"identifier"),
+ identifier = Ct(C(R('az', 'AZ', '__') * R('09', 'az', 'AZ', '__') ^ 0) * Cc 'identifier'),
-- Single character in a string
- sstring_char = R("\001&","([","]\255") + (P"\\" * S[[ntvbrfa\?'"0x]]),
- dstring_char = R("\001!","#[","]\255") + (P"\\" * S[[ntvbrfa\?'"0x]]),
+ sstring_char = R('\001&', '([', ']\255') + (P '\\' * S [[ntvbrfa\?'"0x]]),
+ dstring_char = R('\001!', '#[', ']\255') + (P '\\' * S [[ntvbrfa\?'"0x]]),
-- String literal
- string = Ct(C(P"'" * (V"sstring_char" + P'"')^0 * P"'" +
- P'"' * (V"dstring_char" + P"'")^0 * P'"') * Cc"string"),
+ string = Ct(
+ C(
+ P "'" * (V 'sstring_char' + P '"') ^ 0 * P "'"
+ + P '"' * (V 'dstring_char' + P "'") ^ 0 * P '"'
+ ) * Cc 'string'
+ ),
-- Operator
- operator = Ct(C(P">>=" + P"<<=" + P"..." +
- P"::" + P"<<" + P">>" + P"<=" + P">=" + P"==" + P"!=" +
- P"||" + P"&&" + P"++" + P"--" + P"->" + P"+=" + P"-=" +
- P"*=" + P"/=" + P"|=" + P"&=" + P"^=" + S"+-*/=<>%^|&.?:!~,") * Cc"operator"),
+ operator = Ct(
+ C(
+ P '>>='
+ + P '<<='
+ + P '...'
+ + P '::'
+ + P '<<'
+ + P '>>'
+ + P '<='
+ + P '>='
+ + P '=='
+ + P '!='
+ + P '||'
+ + P '&&'
+ + P '++'
+ + P '--'
+ + P '->'
+ + P '+='
+ + P '-='
+ + P '*='
+ + P '/='
+ + P '|='
+ + P '&='
+ + P '^='
+ + S '+-*/=<>%^|&.?:!~,'
+ ) * Cc 'operator'
+ ),
-- Misc. char (token type is the character itself)
- char = Ct(C(S"[]{}();") / function(x) return x, x end),
+ char = Ct(C(S '[]{}();') / function(x)
+ return x, x
+ end),
-- Hex, octal or decimal number
- int = Ct(C((P"0x" * R("09","af","AF")^1) + (P"0" * R"07"^0) + R"09"^1) * Cc"integer"),
+ int = Ct(
+ C((P '0x' * R('09', 'af', 'AF') ^ 1) + (P '0' * R '07' ^ 0) + R '09' ^ 1) * Cc 'integer'
+ ),
-- Floating point number
- f_exponent = S"eE" + S"+-"^-1 * R"09"^1,
- f_terminator = S"fFlL",
- float = Ct(C(
- R"09"^1 * V"f_exponent" * V"f_terminator"^-1 +
- R"09"^0 * P"." * R"09"^1 * V"f_exponent"^-1 * V"f_terminator"^-1 +
- R"09"^1 * P"." * R"09"^0 * V"f_exponent"^-1 * V"f_terminator"^-1
- ) * Cc"float"),
+ f_exponent = S 'eE' + S '+-' ^ -1 * R '09' ^ 1,
+ f_terminator = S 'fFlL',
+ float = Ct(
+ C(
+ R '09' ^ 1 * V 'f_exponent' * V 'f_terminator' ^ -1
+ + R '09' ^ 0 * P '.' * R '09' ^ 1 * V 'f_exponent' ^ -1 * V 'f_terminator' ^ -1
+ + R '09' ^ 1 * P '.' * R '09' ^ 0 * V 'f_exponent' ^ -1 * V 'f_terminator' ^ -1
+ ) * Cc 'float'
+ ),
-- Any token
- token = V"comment" +
- V"line_comment" +
- V"identifier" +
- V"whitespace" +
- V"line_extend" +
- V"preprocessor" +
- V"string" +
- V"char" +
- V"operator" +
- V"float" +
- V"int",
+ token = V 'comment'
+ + V 'line_comment'
+ + V 'identifier'
+ + V 'whitespace'
+ + V 'line_extend'
+ + V 'preprocessor'
+ + V 'string'
+ + V 'char'
+ + V 'operator'
+ + V 'float'
+ + V 'int',
-- Error for when nothing else matches
error = (Cp() * C(P(1) ^ -8) * Carg(1)) / function(pos, where, state)
- error(("Tokenising error on line %i, position %i, near '%s'")
- :format(state.line, pos - state.line_start + 1, where))
+ error(
+ ("Tokenising error on line %i, position %i, near '%s'"):format(
+ state.line,
+ pos - state.line_start + 1,
+ where
+ )
+ )
end,
-- Match end of input or throw error
- finish = -P(1) + V"error",
+ finish = -P(1) + V 'error',
-- Match stream of tokens into a table
- tokens = Ct(V"token" ^ 0) * V"finish",
+ tokens = Ct(V 'token' ^ 0) * V 'finish',
}
local function TokeniseC(str)
- return tokens:match(str, 1, {line = 1, line_start = 1})
+ return tokens:match(str, 1, { line = 1, line_start = 1 })
end
local function set(t)
@@ -131,11 +173,38 @@ local function set(t)
return s
end
-local C_keywords = set { -- luacheck: ignore
- "break", "case", "char", "const", "continue", "default", "do", "double",
- "else", "enum", "extern", "float", "for", "goto", "if", "int", "long",
- "register", "return", "short", "signed", "sizeof", "static", "struct",
- "switch", "typedef", "union", "unsigned", "void", "volatile", "while",
+local C_keywords = set { -- luacheck: ignore
+ 'break',
+ 'case',
+ 'char',
+ 'const',
+ 'continue',
+ 'default',
+ 'do',
+ 'double',
+ 'else',
+ 'enum',
+ 'extern',
+ 'float',
+ 'for',
+ 'goto',
+ 'if',
+ 'int',
+ 'long',
+ 'register',
+ 'return',
+ 'short',
+ 'signed',
+ 'sizeof',
+ 'static',
+ 'struct',
+ 'switch',
+ 'typedef',
+ 'union',
+ 'unsigned',
+ 'void',
+ 'volatile',
+ 'while',
}
-- Very primitive C formatter that tries to put "things" inside braces on one
@@ -174,7 +243,7 @@ local function formatc(str)
-- if we're not inside a block, we're at the basic statement level,
-- and ';' indicates we're at the end of a statement, so we put end
-- it with a newline.
- token[1] = token[1] .. "\n"
+ token[1] = token[1] .. '\n'
end_at_brace = false
end
elseif typ == 'identifier' then
@@ -194,20 +263,20 @@ local function formatc(str)
-- if we're not inside a block, we're at the basic statement level,
-- and ';' indicates we're at the end of a statement, so we put end
-- it with a newline.
- token[1] = ";\n"
+ token[1] = ';\n'
end
elseif typ == 'whitespace' then
-- replace all whitespace by one space
- local repl = " "
+ local repl = ' '
-- except when allow_on_nl is true and there's a newline in the whitespace
- if string.find(token[1], "[\r\n]+") and allow_one_nl == true then
+ if string.find(token[1], '[\r\n]+') and allow_one_nl == true then
-- in that case we replace all whitespace by one newline
- repl = "\n"
+ repl = '\n'
allow_one_nl = false
end
- token[1] = string.gsub(token[1], "%s+", repl)
+ token[1] = string.gsub(token[1], '%s+', repl)
end
result[#result + 1] = token[1]
end
@@ -216,8 +285,8 @@ local function formatc(str)
end
-- standalone operation (very handy for debugging)
-local function standalone(...) -- luacheck: ignore
- local Preprocess = require("preprocess")
+local function standalone(...) -- luacheck: ignore
+ local Preprocess = require('preprocess')
Preprocess.add_to_include_path('./../../src')
Preprocess.add_to_include_path('./../../build/include')
Preprocess.add_to_include_path('./../../.deps/usr/include')
@@ -226,9 +295,9 @@ local function standalone(...) -- luacheck: ignore
local formatted
if #arg == 2 and arg[2] == 'no' then
- formatted = raw
+ formatted = raw
else
- formatted = formatc(raw)
+ formatted = formatc(raw)
end
print(formatted)
diff --git a/test/unit/garray_spec.lua b/test/unit/garray_spec.lua
index 5d41dd39ec..0f947c42b8 100644
--- a/test/unit/garray_spec.lua
+++ b/test/unit/garray_spec.lua
@@ -1,4 +1,4 @@
-local helpers = require("test.unit.helpers")(after_each)
+local helpers = require('test.unit.helpers')(after_each)
local itp = helpers.gen_itp(it)
local cimport = helpers.cimport
@@ -47,7 +47,7 @@ local ga_size = function(garr)
return ga_len(garr) * ga_itemsize(garr)
end
-local ga_maxsize = function(garr) -- luacheck: ignore
+local ga_maxsize = function(garr) -- luacheck: ignore
return ga_maxlen(garr) * ga_itemsize(garr)
end
@@ -157,7 +157,9 @@ local ga_append_ints = function(garr, ...)
end
-- enhanced constructors
-local garray_ctype = function(...) return ffi.typeof('garray_T[1]')(...) end
+local garray_ctype = function(...)
+ return ffi.typeof('garray_T[1]')(...)
+end
local new_garray = function()
local garr = garray_ctype()
return ffi.gc(garr, ga_clear)
@@ -165,7 +167,7 @@ end
local new_string_garray = function()
local garr = garray_ctype()
- ga_init(garr, ffi.sizeof("unsigned char *"), 1)
+ ga_init(garr, ffi.sizeof('unsigned char *'), 1)
return ffi.gc(garr, ga_clear_strings)
end
@@ -182,7 +184,6 @@ local ga_scramble = function(garr)
end
describe('garray', function()
-
describe('ga_init', function()
itp('initializes the values of the garray', function()
local garr = new_garray()
@@ -199,9 +200,9 @@ describe('garray', function()
local function new_and_grow(itemsize_, growsize_, req)
local garr = new_garray()
ga_init(garr, itemsize_, growsize_)
- eq(0, ga_size(garr)) -- should be 0 at first
- eq(NULL, ga_data(garr)) -- should be NULL
- ga_grow(garr, req) -- add space for `req` items
+ eq(0, ga_size(garr)) -- should be 0 at first
+ eq(NULL, ga_data(garr)) -- should be NULL
+ ga_grow(garr, req) -- add space for `req` items
return garr
end
@@ -210,8 +211,8 @@ describe('garray', function()
growsize = 4
local grow_by = growsize - 1
local garr = new_and_grow(itemsize, growsize, grow_by)
- neq(NULL, ga_data(garr)) -- data should be a ptr to memory
- eq(growsize, ga_maxlen(garr)) -- we requested LESS than growsize, so...
+ neq(NULL, ga_data(garr)) -- data should be a ptr to memory
+ eq(growsize, ga_maxlen(garr)) -- we requested LESS than growsize, so...
end)
itp('grows by num items if num > growsize', function()
@@ -219,8 +220,8 @@ describe('garray', function()
growsize = 4
local grow_by = growsize + 1
local garr = new_and_grow(itemsize, growsize, grow_by)
- neq(NULL, ga_data(garr)) -- data should be a ptr to memory
- eq(grow_by, ga_maxlen(garr)) -- we requested MORE than growsize, so...
+ neq(NULL, ga_data(garr)) -- data should be a ptr to memory
+ eq(grow_by, ga_maxlen(garr)) -- we requested MORE than growsize, so...
end)
itp('does not grow when nothing is requested', function()
@@ -252,7 +253,7 @@ describe('garray', function()
-- this is the actual ga_append, the others are just emulated lua
-- versions
local garr = new_garray()
- ga_init(garr, ffi.sizeof("uint8_t"), 1)
+ ga_init(garr, ffi.sizeof('uint8_t'), 1)
ga_append(garr, 'h')
ga_append(garr, 'e')
ga_append(garr, 'l')
@@ -265,13 +266,13 @@ describe('garray', function()
itp('can append integers', function()
local garr = new_garray()
- ga_init(garr, ffi.sizeof("int"), 1)
+ ga_init(garr, ffi.sizeof('int'), 1)
local input = {
-20,
94,
867615,
90927,
- 86
+ 86,
}
ga_append_ints(garr, unpack(input))
local ints = ga_data_as_ints(garr)
@@ -283,11 +284,11 @@ describe('garray', function()
itp('can append strings to a growing array of strings', function()
local garr = new_string_garray()
local input = {
- "some",
- "str",
- "\r\n\r●●●●●●,,,",
- "hmm",
- "got it"
+ 'some',
+ 'str',
+ '\r\n\r●●●●●●,,,',
+ 'hmm',
+ 'got it',
}
ga_append_strings(garr, unpack(input))
-- check that we can get the same strings out of the array
@@ -301,8 +302,8 @@ describe('garray', function()
describe('ga_concat', function()
itp('concatenates the parameter to the growing byte array', function()
local garr = new_garray()
- ga_init(garr, ffi.sizeof("char"), 1)
- local str = "ohwell●●"
+ ga_init(garr, ffi.sizeof('char'), 1)
+ local str = 'ohwell●●'
local loop = 5
for _ = 1, loop do
ga_concat(garr, str)
@@ -331,21 +332,21 @@ describe('garray', function()
describe('ga_concat_strings', function()
itp('returns an empty string when concatenating an empty array', function()
- test_concat_fn({ }, ga_concat_strings)
+ test_concat_fn({}, ga_concat_strings)
end)
itp('can concatenate a non-empty array', function()
test_concat_fn({
'oh',
'my',
- 'neovim'
+ 'neovim',
}, ga_concat_strings)
end)
end)
describe('ga_concat_strings_sep', function()
itp('returns an empty string when concatenating an empty array', function()
- test_concat_fn({ }, ga_concat_strings_sep, '---')
+ test_concat_fn({}, ga_concat_strings_sep, '---')
end)
itp('can concatenate a non-empty array', function()
@@ -353,7 +354,7 @@ describe('garray', function()
test_concat_fn({
'oh',
'my',
- 'neovim'
+ 'neovim',
}, ga_concat_strings_sep, sep)
end)
end)
@@ -370,13 +371,13 @@ describe('garray', function()
'bbb',
'ccc',
'ccc',
- 'ddd●●'
+ 'ddd●●',
}
local sorted_dedup_input = {
'aaa',
'bbb',
'ccc',
- 'ddd●●'
+ 'ddd●●',
}
ga_append_strings(garr, unpack(input))
ga_remove_duplicate_strings(garr)
diff --git a/test/unit/helpers.lua b/test/unit/helpers.lua
index 8d581dac49..0bd6b85570 100644
--- a/test/unit/helpers.lua
+++ b/test/unit/helpers.lua
@@ -49,7 +49,7 @@ local function child_call(func, ret)
return function(...)
local child_calls = child_calls_mod or child_calls_init
if child_pid ~= 0 then
- child_calls[#child_calls + 1] = {func=func, args={...}}
+ child_calls[#child_calls + 1] = { func = func, args = { ... } }
return ret
else
return func(...)
@@ -62,7 +62,7 @@ end
--- @param func function
local function child_call_once(func, ...)
if child_pid ~= 0 then
- child_calls_mod_once[#child_calls_mod_once + 1] = { func = func, args = {...} }
+ child_calls_mod_once[#child_calls_mod_once + 1] = { func = func, args = { ... } }
else
func(...)
end
@@ -75,7 +75,7 @@ local child_cleanups_mod_once = nil --- @type ChildCall[]?
local function child_cleanup_once(func, ...)
local child_cleanups = child_cleanups_mod_once
if child_pid ~= 0 then
- child_cleanups[#child_cleanups + 1] = {func=func, args={...}}
+ child_cleanups[#child_cleanups + 1] = { func = func, args = { ... } }
else
func(...)
end
@@ -133,25 +133,28 @@ local pragma_pack_id = 1
local function filter_complex_blocks(body)
local result = {} --- @type string[]
- for line in body:gmatch("[^\r\n]+") do
- if not (string.find(line, "(^)", 1, true) ~= nil
- or string.find(line, "_ISwupper", 1, true)
- or string.find(line, "_Float")
- or string.find(line, "__s128")
- or string.find(line, "__u128")
- or string.find(line, "msgpack_zone_push_finalizer")
- or string.find(line, "msgpack_unpacker_reserve_buffer")
- or string.find(line, "value_init_")
- or string.find(line, "UUID_NULL") -- static const uuid_t UUID_NULL = {...}
- or string.find(line, "inline _Bool")) then
+ for line in body:gmatch('[^\r\n]+') do
+ if
+ not (
+ string.find(line, '(^)', 1, true) ~= nil
+ or string.find(line, '_ISwupper', 1, true)
+ or string.find(line, '_Float')
+ or string.find(line, '__s128')
+ or string.find(line, '__u128')
+ or string.find(line, 'msgpack_zone_push_finalizer')
+ or string.find(line, 'msgpack_unpacker_reserve_buffer')
+ or string.find(line, 'value_init_')
+ or string.find(line, 'UUID_NULL') -- static const uuid_t UUID_NULL = {...}
+ or string.find(line, 'inline _Bool')
+ )
+ then
result[#result + 1] = line
end
end
- return table.concat(result, "\n")
+ return table.concat(result, '\n')
end
-
local cdef = ffi.cdef
local cimportstr
@@ -184,9 +187,8 @@ local function cimport(...)
previous_defines = previous_defines_init
cdefs = cdefs_init
end
- for _, path in ipairs({...}) do
- if not (path:sub(1, 1) == '/' or path:sub(1, 1) == '.'
- or path:sub(2, 2) == ':') then
+ for _, path in ipairs({ ... }) do
+ if not (path:sub(1, 1) == '/' or path:sub(1, 1) == '.' or path:sub(2, 2) == ':') then
path = './' .. path
end
if not preprocess_cache[path] then
@@ -205,15 +207,15 @@ local function cimport(...)
body = filter_complex_blocks(body)
-- add the formatted lines to a set
local new_cdefs = Set:new()
- for line in body:gmatch("[^\r\n]+") do
+ for line in body:gmatch('[^\r\n]+') do
line = trim(line)
-- give each #pragma pack an unique id, so that they don't get removed
-- if they are inserted into the set
-- (they are needed in the right order with the struct definitions,
-- otherwise luajit has wrong memory layouts for the sturcts)
- if line:match("#pragma%s+pack") then
+ if line:match('#pragma%s+pack') then
--- @type string
- line = line .. " // " .. pragma_pack_id
+ line = line .. ' // ' .. pragma_pack_id
pragma_pack_id = pragma_pack_id + 1
end
new_cdefs:add(line)
@@ -277,13 +279,13 @@ end
local function alloc_log_new()
local log = {
- log={}, --- @type ChildCallLog[]
- lib=cimport('./src/nvim/memory.h'), --- @type table<string,function>
- original_functions={}, --- @type table<string,function>
- null={['\0:is_null']=true},
+ log = {}, --- @type ChildCallLog[]
+ lib = cimport('./src/nvim/memory.h'), --- @type table<string,function>
+ original_functions = {}, --- @type table<string,function>
+ null = { ['\0:is_null'] = true },
}
- local allocator_functions = {'malloc', 'free', 'calloc', 'realloc'}
+ local allocator_functions = { 'malloc', 'free', 'calloc', 'realloc' }
function log:save_original_functions()
for _, funcname in ipairs(allocator_functions) do
@@ -301,7 +303,7 @@ local function alloc_log_new()
local kk = k
self.lib['mem_' .. k] = function(...)
--- @type ChildCallLog
- local log_entry = { func = kk, args = {...} }
+ local log_entry = { func = kk, args = { ... } }
self.log[#self.log + 1] = log_entry
if kk == 'free' then
self.original_functions[kk](...)
@@ -314,7 +316,9 @@ local function alloc_log_new()
log_entry.args[i] = self.null
end
end
- if self.hook then self:hook(log_entry) end
+ if self.hook then
+ self:hook(log_entry)
+ end
if log_entry.ret then
return log_entry.ret
end
@@ -355,7 +359,7 @@ local function alloc_log_new()
end
end
table.sort(toremove)
- for i = #toremove,1,-1 do
+ for i = #toremove, 1, -1 do
table.remove(self.log, toremove[i])
end
end
@@ -365,11 +369,9 @@ local function alloc_log_new()
log:set_mocks()
end
- function log:before_each()
- end
+ function log:before_each() end
- function log:after_each()
- end
+ function log:after_each() end
log:setup()
@@ -397,13 +399,12 @@ function sc.fork()
end
function sc.pipe()
- local ret = ffi.new('int[2]', {-1, -1})
+ local ret = ffi.new('int[2]', { -1, -1 })
ffi.errno(0)
local res = ffi.C.pipe(ret)
- if (res ~= 0) then
+ if res ~= 0 then
local err = ffi.errno(0)
- assert(res == 0, ("pipe() error: %u: %s"):format(
- err, ffi.string(ffi.C.strerror(err))))
+ assert(res == 0, ('pipe() error: %u: %s'):format(err, ffi.string(ffi.C.strerror(err))))
end
assert(ret[0] ~= -1 and ret[1] ~= -1)
return ret[0], ret[1]
@@ -411,19 +412,16 @@ end
--- @return string
function sc.read(rd, len)
- local ret = ffi.new('char[?]', len, {0})
+ local ret = ffi.new('char[?]', len, { 0 })
local total_bytes_read = 0
ffi.errno(0)
while total_bytes_read < len do
- local bytes_read = tonumber(ffi.C.read(
- rd,
- ffi.cast('void*', ret + total_bytes_read),
- len - total_bytes_read))
+ local bytes_read =
+ tonumber(ffi.C.read(rd, ffi.cast('void*', ret + total_bytes_read), len - total_bytes_read))
if bytes_read == -1 then
local err = ffi.errno(0)
if err ~= ffi.C.kPOSIXErrnoEINTR then
- assert(false, ("read() error: %u: %s"):format(
- err, ffi.string(ffi.C.strerror(err))))
+ assert(false, ('read() error: %u: %s'):format(err, ffi.string(ffi.C.strerror(err))))
end
elseif bytes_read == 0 then
break
@@ -439,15 +437,16 @@ function sc.write(wr, s)
local total_bytes_written = 0
ffi.errno(0)
while total_bytes_written < #s do
- local bytes_written = tonumber(ffi.C.write(
- wr,
- ffi.cast('void*', wbuf + total_bytes_written),
- #s - total_bytes_written))
+ local bytes_written = tonumber(
+ ffi.C.write(wr, ffi.cast('void*', wbuf + total_bytes_written), #s - total_bytes_written)
+ )
if bytes_written == -1 then
local err = ffi.errno(0)
if err ~= ffi.C.kPOSIXErrnoEINTR then
- assert(false, ("write() error: %u: %s ('%s')"):format(
- err, ffi.string(ffi.C.strerror(err)), s))
+ assert(
+ false,
+ ("write() error: %u: %s ('%s')"):format(err, ffi.string(ffi.C.strerror(err)), s)
+ )
end
elseif bytes_written == 0 then
break
@@ -464,7 +463,7 @@ sc.close = ffi.C.close
--- @return integer
function sc.wait(pid)
ffi.errno(0)
- local stat_loc = ffi.new('int[1]', {0})
+ local stat_loc = ffi.new('int[1]', { 0 })
while true do
local r = ffi.C.waitpid(pid, stat_loc, ffi.C.kPOSIXWaitWUNTRACED)
if r == -1 then
@@ -472,8 +471,7 @@ function sc.wait(pid)
if err == ffi.C.kPOSIXErrnoECHILD then
break
elseif err ~= ffi.C.kPOSIXErrnoEINTR then
- assert(false, ("waitpid() error: %u: %s"):format(
- err, ffi.string(ffi.C.strerror(err))))
+ assert(false, ('waitpid() error: %u: %s'):format(err, ffi.string(ffi.C.strerror(err))))
end
else
assert(r == pid)
@@ -489,7 +487,7 @@ sc.exit = ffi.C._exit
local function format_list(lst)
local ret = {} --- @type string[]
for _, v in ipairs(lst) do
- ret[#ret+1] = assert:format({v, n=1})[1]
+ ret[#ret + 1] = assert:format({ v, n = 1 })[1]
end
return table.concat(ret, ', ')
end
@@ -498,9 +496,8 @@ if os.getenv('NVIM_TEST_PRINT_SYSCALLS') == '1' then
for k_, v_ in pairs(sc) do
(function(k, v)
sc[k] = function(...)
- local rets = {v(...)}
- io.stderr:write(('%s(%s) = %s\n'):format(k, format_list({...}),
- format_list(rets)))
+ local rets = { v(...) }
+ io.stderr:write(('%s(%s) = %s\n'):format(k, format_list({ ... }), format_list(rets)))
return unpack(rets)
end
end)(k_, v_)
@@ -512,9 +509,13 @@ local function just_fail(_)
end
say:set('assertion.just_fail.positive', '%s')
say:set('assertion.just_fail.negative', '%s')
-assert:register('assertion', 'just_fail', just_fail,
- 'assertion.just_fail.positive',
- 'assertion.just_fail.negative')
+assert:register(
+ 'assertion',
+ 'just_fail',
+ just_fail,
+ 'assertion.just_fail.positive',
+ 'assertion.just_fail.negative'
+)
local hook_fnamelen = 30
local hook_sfnamelen = 30
@@ -561,7 +562,7 @@ local function child_sethook(wr)
local info = nil --- @type debuginfo?
if use_prev then
info = prev_info
- elseif reason ~= 'tail return' then -- tail return
+ elseif reason ~= 'tail return' then -- tail return
info = debug.getinfo(2, 'nSl')
end
@@ -609,17 +610,20 @@ local function child_sethook(wr)
-- assert(-1 <= lnum and lnum <= 99999)
local lnum_s = lnum == -1 and 'nknwn' or ('%u'):format(lnum)
--- @type string
- local msg = ( -- lua does not support %*
+ local msg = ( -- lua does not support %*
''
.. msgchar
.. whatchar
.. namewhatchar
.. ' '
- .. source .. (' '):rep(hook_sfnamelen - #source)
+ .. source
+ .. (' '):rep(hook_sfnamelen - #source)
.. ':'
- .. funcname .. (' '):rep(hook_fnamelen - #funcname)
+ .. funcname
+ .. (' '):rep(hook_fnamelen - #funcname)
.. ':'
- .. ('0'):rep(hook_numlen - #lnum_s) .. lnum_s
+ .. ('0'):rep(hook_numlen - #lnum_s)
+ .. lnum_s
.. '\n'
)
-- eq(hook_msglen, #msg)
@@ -742,16 +746,16 @@ local function itp_parent(rd, pid, allow_failure, location)
sc.close(rd)
if not ok then
if allow_failure then
- io.stderr:write('Errorred out ('..status..'):\n' .. tostring(emsg) .. '\n')
+ io.stderr:write('Errorred out (' .. status .. '):\n' .. tostring(emsg) .. '\n')
os.execute([[
sh -c "source ci/common/test.sh
check_core_dumps --delete \"]] .. Paths.test_luajit_prg .. [[\""]])
else
- error(tostring(emsg)..'\nexit code: '..status)
+ error(tostring(emsg) .. '\nexit code: ' .. status)
end
elseif status ~= 0 then
if not allow_failure then
- error("child process errored out with status "..status.."!\n\n"..location)
+ error('child process errored out with status ' .. status .. '!\n\n' .. location)
end
end
end
@@ -760,7 +764,9 @@ local function gen_itp(it)
child_calls_mod = {}
child_calls_mod_once = {}
child_cleanups_mod_once = {}
- preprocess_cache_mod = map(function(v) return v end, preprocess_cache_init)
+ preprocess_cache_mod = map(function(v)
+ return v
+ end, preprocess_cache_init)
previous_defines_mod = previous_defines_init
cdefs_mod = cdefs_init:copy()
local function itp(name, func, allow_failure)
@@ -794,8 +800,7 @@ local function cppimport(path)
return cimport(Paths.test_source_path .. '/test/includes/pre/' .. path)
end
-cimport('./src/nvim/types.h', './src/nvim/main.h', './src/nvim/os/time.h',
- './src/nvim/os/fs.h')
+cimport('./src/nvim/types.h', './src/nvim/main.h', './src/nvim/os/time.h', './src/nvim/os/fs.h')
local function conv_enum(etab, eval)
local n = tonumber(eval)
@@ -844,7 +849,7 @@ local function ptr2addr(ptr)
return tonumber(ffi.cast('intptr_t', ffi.cast('void *', ptr)))
end
-local s = ffi.new('char[64]', {0})
+local s = ffi.new('char[64]', { 0 })
local function ptr2key(ptr)
ffi.C.snprintf(s, ffi.sizeof(s), '%p', ffi.cast('void *', ptr))
@@ -853,7 +858,9 @@ end
local function is_asan()
cimport('./src/nvim/version.h')
- local status, res = pcall(function() return lib.version_cflags end)
+ local status, res = pcall(function()
+ return lib.version_cflags
+ end)
if status then
return ffi.string(res):match('-fsanitize=[a-z,]*address')
else
diff --git a/test/unit/indent_spec.lua b/test/unit/indent_spec.lua
index ec86822b55..f93f6d7581 100644
--- a/test/unit/indent_spec.lua
+++ b/test/unit/indent_spec.lua
@@ -1,10 +1,10 @@
-local helpers = require("test.unit.helpers")(after_each)
+local helpers = require('test.unit.helpers')(after_each)
local itp = helpers.gen_itp(it)
-local eq = helpers.eq
+local eq = helpers.eq
-local indent = helpers.cimport("./src/nvim/indent.h")
-local globals = helpers.cimport("./src/nvim/globals.h")
+local indent = helpers.cimport('./src/nvim/indent.h')
+local globals = helpers.cimport('./src/nvim/globals.h')
describe('get_sts_value', function()
itp([[returns 'softtabstop' when it is non-negative]], function()
diff --git a/test/unit/keycodes_spec.lua b/test/unit/keycodes_spec.lua
index 4da3d37aaa..4a81c62ac1 100644
--- a/test/unit/keycodes_spec.lua
+++ b/test/unit/keycodes_spec.lua
@@ -1,15 +1,14 @@
-local helpers = require("test.unit.helpers")(after_each)
+local helpers = require('test.unit.helpers')(after_each)
local itp = helpers.gen_itp(it)
-local ffi = helpers.ffi
-local eq = helpers.eq
-local neq = helpers.neq
+local ffi = helpers.ffi
+local eq = helpers.eq
+local neq = helpers.neq
local keycodes = helpers.cimport('./src/nvim/keycodes.h')
local NULL = helpers.NULL
describe('keycodes.c', function()
-
describe('find_special_key()', function()
local srcp = ffi.new('const unsigned char *[1]')
local modp = ffi.new('int[1]')
@@ -28,31 +27,26 @@ describe('keycodes.c', function()
itp('case-insensitive', function()
-- Compare other capitalizations to this.
srcp[0] = '<C-A>'
- local all_caps_key =
- keycodes.find_special_key(srcp, 5, modp, 0, NULL)
+ local all_caps_key = keycodes.find_special_key(srcp, 5, modp, 0, NULL)
local all_caps_mod = modp[0]
srcp[0] = '<C-a>'
- eq(all_caps_key,
- keycodes.find_special_key(srcp, 5, modp, 0, NULL))
+ eq(all_caps_key, keycodes.find_special_key(srcp, 5, modp, 0, NULL))
eq(all_caps_mod, modp[0])
srcp[0] = '<c-A>'
- eq(all_caps_key,
- keycodes.find_special_key(srcp, 5, modp, 0, NULL))
+ eq(all_caps_key, keycodes.find_special_key(srcp, 5, modp, 0, NULL))
eq(all_caps_mod, modp[0])
srcp[0] = '<c-a>'
- eq(all_caps_key,
- keycodes.find_special_key(srcp, 5, modp, 0, NULL))
+ eq(all_caps_key, keycodes.find_special_key(srcp, 5, modp, 0, NULL))
eq(all_caps_mod, modp[0])
end)
itp('double-quote in keycode #7411', function()
-- Unescaped with in_string=false
srcp[0] = '<C-">'
- eq(string.byte('"'),
- keycodes.find_special_key(srcp, 5, modp, 0, NULL))
+ eq(string.byte('"'), keycodes.find_special_key(srcp, 5, modp, 0, NULL))
-- Unescaped with in_string=true
eq(0, keycodes.find_special_key(srcp, 5, modp, keycodes.FSK_IN_STRING, NULL))
@@ -64,9 +58,7 @@ describe('keycodes.c', function()
eq(0, keycodes.find_special_key(srcp, 6, modp, 0, NULL))
-- Escaped with in_string=true
- eq(string.byte('"'),
- keycodes.find_special_key(srcp, 6, modp, keycodes.FSK_IN_STRING, NULL))
+ eq(string.byte('"'), keycodes.find_special_key(srcp, 6, modp, keycodes.FSK_IN_STRING, NULL))
end)
end)
-
end)
diff --git a/test/unit/marktree_spec.lua b/test/unit/marktree_spec.lua
index 3f9dd4df12..6c70225f0a 100644
--- a/test/unit/marktree_spec.lua
+++ b/test/unit/marktree_spec.lua
@@ -1,15 +1,17 @@
-local helpers = require("test.unit.helpers")(after_each)
+local helpers = require('test.unit.helpers')(after_each)
local itp = helpers.gen_itp(it)
-local ffi = helpers.ffi
-local eq = helpers.eq
-local ok = helpers.ok
+local ffi = helpers.ffi
+local eq = helpers.eq
+local ok = helpers.ok
-local lib = helpers.cimport("./src/nvim/marktree.h")
+local lib = helpers.cimport('./src/nvim/marktree.h')
local function tablelength(t)
local count = 0
- for _ in pairs(t) do count = count + 1 end
+ for _ in pairs(t) do
+ count = count + 1
+ end
return count
end
@@ -32,15 +34,27 @@ local function shadoworder(tree, shadow, iter, giveorder)
local mark = lib.marktree_itr_current(iter)
local id = tonumber(mark.id)
local spos = shadow[id]
- if (mark.pos.row ~= spos[1] or mark.pos.col ~= spos[2]) then
- error("invalid pos for "..id..":("..mark.pos.row..", "..mark.pos.col..") instead of ("..spos[1]..", "..spos[2]..")")
+ if mark.pos.row ~= spos[1] or mark.pos.col ~= spos[2] then
+ error(
+ 'invalid pos for '
+ .. id
+ .. ':('
+ .. mark.pos.row
+ .. ', '
+ .. mark.pos.col
+ .. ') instead of ('
+ .. spos[1]
+ .. ', '
+ .. spos[2]
+ .. ')'
+ )
end
if lib.mt_right_test(mark) ~= spos[3] then
- error("invalid gravity for "..id..":("..mark.pos.row..", "..mark.pos.col..")")
+ error('invalid gravity for ' .. id .. ':(' .. mark.pos.row .. ', ' .. mark.pos.col .. ')')
end
if count > 0 then
if not pos_leq(last, spos) then
- error("DISORDER")
+ error('DISORDER')
end
end
count = count + 1
@@ -52,17 +66,21 @@ local function shadoworder(tree, shadow, iter, giveorder)
until not lib.marktree_itr_next(tree, iter)
local shadowlen = tablelength(shadow)
if shadowlen ~= count then
- error("missed some keys? (shadow "..shadowlen..", tree "..count..")")
+ error('missed some keys? (shadow ' .. shadowlen .. ', tree ' .. count .. ')')
end
return id2pos, pos2id
end
local function shadowsplice(shadow, start, old_extent, new_extent)
- local old_end = {start[1] + old_extent[1],
- (old_extent[1] == 0 and start[2] or 0) + old_extent[2]}
- local new_end = {start[1] + new_extent[1],
- (new_extent[1] == 0 and start[2] or 0) + new_extent[2]}
- local delta = {new_end[1] - old_end[1], new_end[2] - old_end[2]}
+ local old_end = {
+ start[1] + old_extent[1],
+ (old_extent[1] == 0 and start[2] or 0) + old_extent[2],
+ }
+ local new_end = {
+ start[1] + new_extent[1],
+ (new_extent[1] == 0 and start[2] or 0) + new_extent[2],
+ }
+ local delta = { new_end[1] - old_end[1], new_end[2] - old_end[2] }
for _, pos in pairs(shadow) do
if pos_leq(start, pos) then
if pos_leq(pos, old_end) then
@@ -83,7 +101,15 @@ local function shadowsplice(shadow, start, old_extent, new_extent)
end
local function dosplice(tree, shadow, start, old_extent, new_extent)
- lib.marktree_splice(tree, start[1], start[2], old_extent[1], old_extent[2], new_extent[1], new_extent[2])
+ lib.marktree_splice(
+ tree,
+ start[1],
+ start[2],
+ old_extent[1],
+ old_extent[2],
+ new_extent[1],
+ new_extent[2]
+ )
shadowsplice(shadow, start, old_extent, new_extent)
end
@@ -98,7 +124,7 @@ local function put(tree, row, col, gravitate, end_row, end_col, end_gravitate)
end_col = end_col or -1
end_gravitate = end_gravitate or false
- lib.marktree_put_test(tree, ns, my_id, row, col, gravitate, end_row, end_col, end_gravitate);
+ lib.marktree_put_test(tree, ns, my_id, row, col, gravitate, end_row, end_col, end_gravitate)
return my_id
end
@@ -108,18 +134,18 @@ describe('marktree', function()
end)
itp('works', function()
- local tree = ffi.new("MarkTree[1]") -- zero initialized by luajit
+ local tree = ffi.new('MarkTree[1]') -- zero initialized by luajit
local shadow = {}
- local iter = ffi.new("MarkTreeIter[1]")
- local iter2 = ffi.new("MarkTreeIter[1]")
+ local iter = ffi.new('MarkTreeIter[1]')
+ local iter2 = ffi.new('MarkTreeIter[1]')
- for i = 1,100 do
- for j = 1,100 do
- local gravitate = (i%2) > 0
+ for i = 1, 100 do
+ for j = 1, 100 do
+ local gravitate = (i % 2) > 0
local id = put(tree, j, i, gravitate)
ok(id > 0)
eq(nil, shadow[id])
- shadow[id] = {j,i,gravitate}
+ shadow[id] = { j, i, gravitate }
end
-- checking every insert is too slow, but this is ok
lib.marktree_check(tree)
@@ -133,7 +159,7 @@ describe('marktree', function()
eq({}, pos2id) -- not set if not requested
eq({}, id2pos)
- for i,ipos in pairs(shadow) do
+ for i, ipos in pairs(shadow) do
local p = lib.marktree_lookup_ns(tree, ns, i, false, iter)
eq(ipos[1], p.pos.row)
eq(ipos[2], p.pos.col)
@@ -145,7 +171,7 @@ describe('marktree', function()
-- local k2 = lib.marktree_itr_current(iter)
end
- for i,ipos in pairs(shadow) do
+ for i, ipos in pairs(shadow) do
lib.marktree_itr_get(tree, ipos[1], ipos[2], iter)
local k = lib.marktree_itr_current(iter)
eq(i, tonumber(k.id))
@@ -160,9 +186,9 @@ describe('marktree', function()
shadow[tonumber(del.id)] = nil
shadoworder(tree, shadow, iter)
- for _, ci in ipairs({0,-1,1,-2,2,-10,10}) do
- for i = 1,100 do
- lib.marktree_itr_get(tree, i, 50+ci, iter)
+ for _, ci in ipairs({ 0, -1, 1, -2, 2, -10, 10 }) do
+ for i = 1, 100 do
+ lib.marktree_itr_get(tree, i, 50 + ci, iter)
local k = lib.marktree_itr_current(iter)
local id = tonumber(k.id)
eq(shadow[id][1], k.pos.row)
@@ -177,14 +203,14 @@ describe('marktree', function()
-- NB: this is quite rudimentary. We rely on
-- functional tests exercising splicing quite a bit
lib.marktree_check(tree)
- dosplice(tree, shadow, {2,2}, {0,5}, {1, 2})
+ dosplice(tree, shadow, { 2, 2 }, { 0, 5 }, { 1, 2 })
lib.marktree_check(tree)
shadoworder(tree, shadow, iter)
- dosplice(tree, shadow, {30,2}, {30,5}, {1, 2})
+ dosplice(tree, shadow, { 30, 2 }, { 30, 5 }, { 1, 2 })
lib.marktree_check(tree)
shadoworder(tree, shadow, iter)
- dosplice(tree, shadow, {5,3}, {0,2}, {0, 5})
+ dosplice(tree, shadow, { 5, 3 }, { 0, 2 }, { 0, 5 })
shadoworder(tree, shadow, iter)
lib.marktree_check(tree)
@@ -209,7 +235,7 @@ describe('marktree', function()
-- Check iterator validity for 2 specific edge cases:
-- https://github.com/neovim/neovim/pull/14719
lib.marktree_clear(tree)
- for i = 1,20 do
+ for i = 1, 20 do
put(tree, i, i, false)
end
@@ -224,46 +250,60 @@ describe('marktree', function()
itp("'intersect_mov' function works correctly", function()
local function mov(x, y, w)
- local xa = ffi.new("uint64_t[?]", #x)
- for i, xi in ipairs(x) do xa[i-1] = xi end
- local ya = ffi.new("uint64_t[?]", #y)
- for i, yi in ipairs(y) do ya[i-1] = yi end
- local wa = ffi.new("uint64_t[?]", #w)
- for i, wi in ipairs(w) do wa[i-1] = wi end
+ local xa = ffi.new('uint64_t[?]', #x)
+ for i, xi in ipairs(x) do
+ xa[i - 1] = xi
+ end
+ local ya = ffi.new('uint64_t[?]', #y)
+ for i, yi in ipairs(y) do
+ ya[i - 1] = yi
+ end
+ local wa = ffi.new('uint64_t[?]', #w)
+ for i, wi in ipairs(w) do
+ wa[i - 1] = wi
+ end
local dummy_size = #x + #y + #w
- local wouta = ffi.new("uint64_t[?]", dummy_size)
- local douta = ffi.new("uint64_t[?]", dummy_size)
- local wsize = ffi.new("size_t[1]")
+ local wouta = ffi.new('uint64_t[?]', dummy_size)
+ local douta = ffi.new('uint64_t[?]', dummy_size)
+ local wsize = ffi.new('size_t[1]')
wsize[0] = dummy_size
- local dsize = ffi.new("size_t[1]")
+ local dsize = ffi.new('size_t[1]')
dsize[0] = dummy_size
local status = lib.intersect_mov_test(xa, #x, ya, #y, wa, #w, wouta, wsize, douta, dsize)
- if status == 0 then error'wowza' end
+ if status == 0 then
+ error 'wowza'
+ end
local wout, dout = {}, {}
- for i = 0,tonumber(wsize[0])-1 do table.insert(wout, tonumber(wouta[i])) end
- for i = 0,tonumber(dsize[0])-1 do table.insert(dout, tonumber(douta[i])) end
- return {wout, dout}
+ for i = 0, tonumber(wsize[0]) - 1 do
+ table.insert(wout, tonumber(wouta[i]))
+ end
+ for i = 0, tonumber(dsize[0]) - 1 do
+ table.insert(dout, tonumber(douta[i]))
+ end
+ return { wout, dout }
end
- eq({{}, {}}, mov({}, {2, 3}, {2, 3}))
- eq({{2, 3}, {}}, mov({}, {}, {2, 3}))
- eq({{2, 3}, {}}, mov({2, 3}, {}, {}))
- eq({{}, {2,3}}, mov({}, {2,3}, {}))
-
- eq({{1, 5}, {}}, mov({1,2,5}, {2, 3}, {3}))
- eq({{1, 2}, {}}, mov({1,2,5}, {5, 10}, {10}))
- eq({{1, 2}, {5}}, mov({1,2}, {5, 10}, {10}))
- eq({{1,3,5,7,9}, {2,4,6,8,10}}, mov({1,3,5,7,9}, {2,4,6,8,10}, {}))
- eq({{1,3,5,7,9}, {2,6,10}}, mov({1,3,5,7,9}, {2,4,6,8,10}, {4, 8}))
- eq({{1,4,7}, {2,5,8}}, mov({1,3,4,6,7,9}, {2,3,5,6,8,9}, {}))
- eq({{1,4,7}, {}}, mov({1,3,4,6,7,9}, {2,3,5,6,8,9}, {2,5,8}))
- eq({{0,1,4,7,10}, {}}, mov({1,3,4,6,7,9}, {2,3,5,6,8,9}, {0,2,5,8,10}))
+ eq({ {}, {} }, mov({}, { 2, 3 }, { 2, 3 }))
+ eq({ { 2, 3 }, {} }, mov({}, {}, { 2, 3 }))
+ eq({ { 2, 3 }, {} }, mov({ 2, 3 }, {}, {}))
+ eq({ {}, { 2, 3 } }, mov({}, { 2, 3 }, {}))
+
+ eq({ { 1, 5 }, {} }, mov({ 1, 2, 5 }, { 2, 3 }, { 3 }))
+ eq({ { 1, 2 }, {} }, mov({ 1, 2, 5 }, { 5, 10 }, { 10 }))
+ eq({ { 1, 2 }, { 5 } }, mov({ 1, 2 }, { 5, 10 }, { 10 }))
+ eq({ { 1, 3, 5, 7, 9 }, { 2, 4, 6, 8, 10 } }, mov({ 1, 3, 5, 7, 9 }, { 2, 4, 6, 8, 10 }, {}))
+ eq({ { 1, 3, 5, 7, 9 }, { 2, 6, 10 } }, mov({ 1, 3, 5, 7, 9 }, { 2, 4, 6, 8, 10 }, { 4, 8 }))
+ eq({ { 1, 4, 7 }, { 2, 5, 8 } }, mov({ 1, 3, 4, 6, 7, 9 }, { 2, 3, 5, 6, 8, 9 }, {}))
+ eq({ { 1, 4, 7 }, {} }, mov({ 1, 3, 4, 6, 7, 9 }, { 2, 3, 5, 6, 8, 9 }, { 2, 5, 8 }))
+ eq(
+ { { 0, 1, 4, 7, 10 }, {} },
+ mov({ 1, 3, 4, 6, 7, 9 }, { 2, 3, 5, 6, 8, 9 }, { 0, 2, 5, 8, 10 })
+ )
end)
-
local function check_intersections(tree)
lib.marktree_check(tree)
-- to debug stuff disable this branch
@@ -279,13 +319,13 @@ describe('marktree', function()
if not val then
local str2 = lib.mt_inspect(tree, true, true)
local dot2 = ffi.string(str2.data, str2.size)
- print("actual:\n\n".."Xafile.dot".."\n\nexpected:\n\n".."Xefile.dot".."\n")
- print("nivå", tree[0].root.level);
+ print('actual:\n\n' .. 'Xafile.dot' .. '\n\nexpected:\n\n' .. 'Xefile.dot' .. '\n')
+ print('nivå', tree[0].root.level)
io.stdout:flush()
- local afil = io.open("Xafile.dot", "wb")
+ local afil = io.open('Xafile.dot', 'wb')
afil:write(dot1)
afil:close()
- local efil = io.open("Xefile.dot", "wb")
+ local efil = io.open('Xefile.dot', 'wb')
efil:write(dot2)
efil:close()
ok(false)
@@ -295,28 +335,28 @@ describe('marktree', function()
end
itp('works with intersections', function()
- local tree = ffi.new("MarkTree[1]") -- zero initialized by luajit
+ local tree = ffi.new('MarkTree[1]') -- zero initialized by luajit
local ids = {}
- for i = 1,80 do
- table.insert(ids, put(tree, 1, i, false, 2, 100-i, false))
+ for i = 1, 80 do
+ table.insert(ids, put(tree, 1, i, false, 2, 100 - i, false))
check_intersections(tree)
end
- for i = 1,80 do
+ for i = 1, 80 do
lib.marktree_del_pair_test(tree, ns, ids[i])
check_intersections(tree)
end
ids = {}
- for i = 1,80 do
- table.insert(ids, put(tree, 1, i, false, 2, 100-i, false))
+ for i = 1, 80 do
+ table.insert(ids, put(tree, 1, i, false, 2, 100 - i, false))
check_intersections(tree)
end
- for i = 1,10 do
- for j = 1,8 do
- local ival = (j-1)*10+i
+ for i = 1, 10 do
+ for j = 1, 8 do
+ local ival = (j - 1) * 10 + i
lib.marktree_del_pair_test(tree, ns, ids[ival])
check_intersections(tree)
end
@@ -324,12 +364,12 @@ describe('marktree', function()
end)
itp('works with intersections with a big tree', function()
- local tree = ffi.new("MarkTree[1]") -- zero initialized by luajit
+ local tree = ffi.new('MarkTree[1]') -- zero initialized by luajit
local ids = {}
- for i = 1,1000 do
- table.insert(ids, put(tree, 1, i, false, 2, 1000-i, false))
+ for i = 1, 1000 do
+ table.insert(ids, put(tree, 1, i, false, 2, 1000 - i, false))
if i % 10 == 1 then
check_intersections(tree)
end
@@ -339,13 +379,13 @@ describe('marktree', function()
eq(2000, tree[0].n_keys)
ok(tree[0].root.level >= 2)
- local iter = ffi.new("MarkTreeIter[1]")
+ local iter = ffi.new('MarkTreeIter[1]')
local k = 0
- for i = 1,20 do
- for j = 1,50 do
+ for i = 1, 20 do
+ for j = 1, 50 do
k = k + 1
- local ival = (j-1)*20+i
+ local ival = (j - 1) * 20 + i
if false == true then -- if there actually is a failure, this branch will fail out at the actual spot of the error
lib.marktree_lookup_ns(tree, ns, ids[ival], false, iter)
lib.marktree_del_itr(tree, iter, false)
@@ -367,10 +407,10 @@ describe('marktree', function()
end)
itp('works with intersections and marktree_splice', function()
- local tree = ffi.new("MarkTree[1]") -- zero initialized by luajit
+ local tree = ffi.new('MarkTree[1]') -- zero initialized by luajit
- for i = 1,1000 do
- put(tree, 1, i, false, 2, 1000-i, false)
+ for i = 1, 1000 do
+ put(tree, 1, i, false, 2, 1000 - i, false)
if i % 10 == 1 then
check_intersections(tree)
end
@@ -380,15 +420,15 @@ describe('marktree', function()
eq(2000, tree[0].n_keys)
ok(tree[0].root.level >= 2)
- for _ = 1,10 do
+ for _ = 1, 10 do
lib.marktree_splice(tree, 0, 0, 0, 100, 0, 0)
check_intersections(tree)
end
end)
itp('marktree_move should preserve key order', function()
- local tree = ffi.new("MarkTree[1]") -- zero initialized by luajit
- local iter = ffi.new("MarkTreeIter[1]")
+ local tree = ffi.new('MarkTree[1]') -- zero initialized by luajit
+ local iter = ffi.new('MarkTreeIter[1]')
local ids = {}
-- new index and old index look the same, but still have to move because
@@ -405,31 +445,30 @@ describe('marktree', function()
end)
itp('works with intersections and marktree_move', function()
- local tree = ffi.new("MarkTree[1]") -- zero initialized by luajit
+ local tree = ffi.new('MarkTree[1]') -- zero initialized by luajit
local ids = {}
- for i = 1,1000 do
- table.insert(ids, put(tree, 1, i, false, 2, 1000-i, false))
+ for i = 1, 1000 do
+ table.insert(ids, put(tree, 1, i, false, 2, 1000 - i, false))
if i % 10 == 1 then
check_intersections(tree)
end
end
- local iter = ffi.new("MarkTreeIter[1]")
- for i = 1,1000 do
- local which = i%2
+ local iter = ffi.new('MarkTreeIter[1]')
+ for i = 1, 1000 do
+ local which = i % 2
lib.marktree_lookup_ns(tree, ns, ids[i], which, iter)
- lib.marktree_move(tree, iter, 1+which, 500+i)
+ lib.marktree_move(tree, iter, 1 + which, 500 + i)
if i % 10 == 1 then
check_intersections(tree)
end
end
-
end)
itp('works with intersections with a even bigger tree', function()
- local tree = ffi.new("MarkTree[1]") -- zero initialized by luajit
+ local tree = ffi.new('MarkTree[1]') -- zero initialized by luajit
local ids = {}
@@ -441,21 +480,21 @@ describe('marktree', function()
at_row[i] = {}
end
- local size = 1000*size_factor
+ local size = 1000 * size_factor
local k = 1
while k <= size do
- for row1 = 1,9 do
- for row2 = row1,10 do -- note row2 can be == row1, leads to empty ranges being tested when k > size/2
+ for row1 = 1, 9 do
+ for row2 = row1, 10 do -- note row2 can be == row1, leads to empty ranges being tested when k > size/2
if k > size then
break
end
- local id = put(tree, row1, k, false, row2, size-k, false)
+ local id = put(tree, row1, k, false, row2, size - k, false)
table.insert(ids, id)
- for i = row1+1, row2 do
+ for i = row1 + 1, row2 do
table.insert(at_row[i], id)
end
--if tree[0].root.level == 4 then error("kk"..k) end
- if k % 100*size_factor == 1 or (k < 2000 and k%100 == 1) then
+ if k % 100 * size_factor == 1 or (k < 2000 and k % 100 == 1) then
check_intersections(tree)
end
k = k + 1
@@ -463,13 +502,13 @@ describe('marktree', function()
end
end
- eq(2*size, tree[0].n_keys)
+ eq(2 * size, tree[0].n_keys)
ok(tree[0].root.level >= 3)
check_intersections(tree)
- local iter = ffi.new("MarkTreeIter[1]")
- local pair = ffi.new("MTPair[1]")
- for i = 1,10 do
+ local iter = ffi.new('MarkTreeIter[1]')
+ local pair = ffi.new('MTPair[1]')
+ for i = 1, 10 do
-- use array as set and not {[id]=true} map, to detect duplicates
local set = {}
eq(true, ffi.C.marktree_itr_get_overlap(tree, i, 0, iter))
@@ -482,14 +521,14 @@ describe('marktree', function()
end
k = 0
- for i = 1,100 do
- for j = 1,(10*size_factor) do
+ for i = 1, 100 do
+ for j = 1, (10 * size_factor) do
k = k + 1
- local ival = (j-1)*100+i
+ local ival = (j - 1) * 100 + i
lib.marktree_del_pair_test(tree, ns, ids[ival])
-- just a few stickprov, if there is trouble we need to check
-- everyone using the code in the "big tree" case above
- if k % 100*size_factor == 0 or (k > 3000 and k % 200 == 0) then
+ if k % 100 * size_factor == 0 or (k > 3000 and k % 200 == 0) then
check_intersections(tree)
end
end
@@ -499,7 +538,7 @@ describe('marktree', function()
end)
itp('works with intersections with a even bigger tree and splice', function()
- local tree = ffi.new("MarkTree[1]") -- zero initialized by luajit
+ local tree = ffi.new('MarkTree[1]') -- zero initialized by luajit
-- too much overhead on ASAN
local size_factor = helpers.is_asan() and 3 or 10
@@ -509,20 +548,20 @@ describe('marktree', function()
at_row[i] = {}
end
- local size = 1000*size_factor
+ local size = 1000 * size_factor
local k = 1
while k <= size do
- for row1 = 1,9 do
- for row2 = row1,10 do -- note row2 can be == row1, leads to empty ranges being tested when k > size/2
+ for row1 = 1, 9 do
+ for row2 = row1, 10 do -- note row2 can be == row1, leads to empty ranges being tested when k > size/2
if k > size then
break
end
- local id = put(tree, row1, k, false, row2, size-k, false)
- for i = row1+1, row2 do
+ local id = put(tree, row1, k, false, row2, size - k, false)
+ for i = row1 + 1, row2 do
table.insert(at_row[i], id)
end
--if tree[0].root.level == 4 then error("kk"..k) end
- if k % 100*size_factor == 1 or (k < 2000 and k%100 == 1) then
+ if k % 100 * size_factor == 1 or (k < 2000 and k % 100 == 1) then
check_intersections(tree)
end
k = k + 1
@@ -530,11 +569,11 @@ describe('marktree', function()
end
end
- eq(2*size, tree[0].n_keys)
+ eq(2 * size, tree[0].n_keys)
ok(tree[0].root.level >= 3)
check_intersections(tree)
- for _ = 1,10 do
+ for _ = 1, 10 do
for j = 3, 8 do
lib.marktree_splice(tree, j, 0, 0, 200, 0, 0)
check_intersections(tree)
diff --git a/test/unit/mbyte_spec.lua b/test/unit/mbyte_spec.lua
index cd94624570..67220d7c19 100644
--- a/test/unit/mbyte_spec.lua
+++ b/test/unit/mbyte_spec.lua
@@ -1,8 +1,8 @@
-local helpers = require("test.unit.helpers")(after_each)
+local helpers = require('test.unit.helpers')(after_each)
local itp = helpers.gen_itp(it)
-local ffi = helpers.ffi
-local eq = helpers.eq
+local ffi = helpers.ffi
+local eq = helpers.eq
local lib = helpers.cimport('./src/nvim/mbyte.h', './src/nvim/charset.h', './src/nvim/grid.h')
@@ -16,13 +16,12 @@ describe('mbyte', function()
return table.concat(s)
end
- before_each(function()
- end)
+ before_each(function() end)
itp('utf_ptr2char', function()
-- For strings with length 1 the first byte is returned.
for c = 0, 255 do
- eq(c, lib.utf_ptr2char(to_string({c, 0})))
+ eq(c, lib.utf_ptr2char(to_string({ c, 0 })))
end
-- Some ill formed byte sequences that should not be recognized as UTF-8
@@ -48,126 +47,160 @@ describe('mbyte', function()
describe('utfc_ptr2schar_len', function()
local function test_seq(seq)
- local firstc = ffi.new("int[1]")
- local buf = ffi.new("char[32]")
+ local firstc = ffi.new('int[1]')
+ local buf = ffi.new('char[32]')
lib.schar_get(buf, lib.utfc_ptr2schar_len(to_string(seq), #seq, firstc))
- return {ffi.string(buf), firstc[0]}
+ return { ffi.string(buf), firstc[0] }
end
local function byte(val)
- return {string.char(val), val}
+ return { string.char(val), val }
end
itp('1-byte sequences', function()
- eq({'', 0}, test_seq{0})
+ eq({ '', 0 }, test_seq { 0 })
for c = 1, 127 do
- eq(byte(c), test_seq{c})
+ eq(byte(c), test_seq { c })
end
for c = 128, 255 do
- eq({'', c}, test_seq{c})
+ eq({ '', c }, test_seq { c })
end
end)
itp('2-byte sequences', function()
-- No combining characters
- eq(byte(0x7f), test_seq{0x7f, 0x7f})
+ eq(byte(0x7f), test_seq { 0x7f, 0x7f })
-- No combining characters
- eq(byte(0x7f), test_seq{0x7f, 0x80})
+ eq(byte(0x7f), test_seq { 0x7f, 0x80 })
-- No UTF-8 sequence
- eq({'', 0xc2}, test_seq{0xc2, 0x7f})
+ eq({ '', 0xc2 }, test_seq { 0xc2, 0x7f })
-- One UTF-8 character
- eq({'\xc2\x80', 0x80}, test_seq{0xc2, 0x80})
+ eq({ '\xc2\x80', 0x80 }, test_seq { 0xc2, 0x80 })
-- No UTF-8 sequence
- eq({'', 0xc2}, test_seq{0xc2, 0xc0})
+ eq({ '', 0xc2 }, test_seq { 0xc2, 0xc0 })
end)
itp('3-byte sequences', function()
-- No second UTF-8 character
- eq(byte(0x7f), test_seq{0x7f, 0x80, 0x80})
+ eq(byte(0x7f), test_seq { 0x7f, 0x80, 0x80 })
-- No combining character
- eq(byte(0x7f), test_seq{0x7f, 0xc2, 0x80})
+ eq(byte(0x7f), test_seq { 0x7f, 0xc2, 0x80 })
-- Combining character is U+0300
- eq({"\x7f\xcc\x80", 0x7f}, test_seq{0x7f, 0xcc, 0x80})
+ eq({ '\x7f\xcc\x80', 0x7f }, test_seq { 0x7f, 0xcc, 0x80 })
-- No UTF-8 sequence
- eq({'', 0xc2}, test_seq{0xc2, 0x7f, 0xcc})
+ eq({ '', 0xc2 }, test_seq { 0xc2, 0x7f, 0xcc })
-- Incomplete combining character
- eq({"\xc2\x80", 0x80}, test_seq{0xc2, 0x80, 0xcc})
+ eq({ '\xc2\x80', 0x80 }, test_seq { 0xc2, 0x80, 0xcc })
-- One UTF-8 character (composing only)
- eq({" \xe2\x83\x90", 0x20d0}, test_seq{0xe2, 0x83, 0x90})
+ eq({ ' \xe2\x83\x90', 0x20d0 }, test_seq { 0xe2, 0x83, 0x90 })
end)
itp('4-byte sequences', function()
-
-- No following combining character
- eq(byte(0x7f), test_seq{0x7f, 0x7f, 0xcc, 0x80})
+ eq(byte(0x7f), test_seq { 0x7f, 0x7f, 0xcc, 0x80 })
-- No second UTF-8 character
- eq(byte(0x7f), test_seq{0x7f, 0xc2, 0xcc, 0x80})
+ eq(byte(0x7f), test_seq { 0x7f, 0xc2, 0xcc, 0x80 })
-- Combining character U+0300
- eq({"\x7f\xcc\x80", 0x7f}, test_seq{0x7f, 0xcc, 0x80, 0xcc})
+ eq({ '\x7f\xcc\x80', 0x7f }, test_seq { 0x7f, 0xcc, 0x80, 0xcc })
-- No UTF-8 sequence
- eq({'', 0xc2}, test_seq{0xc2, 0x7f, 0xcc, 0x80})
+ eq({ '', 0xc2 }, test_seq { 0xc2, 0x7f, 0xcc, 0x80 })
-- No following UTF-8 character
- eq({"\xc2\x80", 0x80}, test_seq{0xc2, 0x80, 0xcc, 0xcc})
+ eq({ '\xc2\x80', 0x80 }, test_seq { 0xc2, 0x80, 0xcc, 0xcc })
-- Combining character U+0301
- eq({"\xc2\x80\xcc\x81", 0x80}, test_seq{0xc2, 0x80, 0xcc, 0x81})
+ eq({ '\xc2\x80\xcc\x81', 0x80 }, test_seq { 0xc2, 0x80, 0xcc, 0x81 })
-- One UTF-8 character
- eq({"\xf4\x80\x80\x80", 0x100000}, test_seq{0xf4, 0x80, 0x80, 0x80})
+ eq({ '\xf4\x80\x80\x80', 0x100000 }, test_seq { 0xf4, 0x80, 0x80, 0x80 })
end)
itp('5+-byte sequences', function()
-- No following combining character
- eq(byte(0x7f), test_seq{0x7f, 0x7f, 0xcc, 0x80, 0x80})
+ eq(byte(0x7f), test_seq { 0x7f, 0x7f, 0xcc, 0x80, 0x80 })
-- No second UTF-8 character
- eq(byte(0x7f), test_seq{0x7f, 0xc2, 0xcc, 0x80, 0x80})
+ eq(byte(0x7f), test_seq { 0x7f, 0xc2, 0xcc, 0x80, 0x80 })
-- Combining character U+0300
- eq({"\x7f\xcc\x80", 0x7f}, test_seq{0x7f, 0xcc, 0x80, 0xcc, 0x00})
+ eq({ '\x7f\xcc\x80', 0x7f }, test_seq { 0x7f, 0xcc, 0x80, 0xcc, 0x00 })
-- Combining characters U+0300 and U+0301
- eq({"\x7f\xcc\x80\xcc\x81", 0x7f}, test_seq{0x7f, 0xcc, 0x80, 0xcc, 0x81})
+ eq({ '\x7f\xcc\x80\xcc\x81', 0x7f }, test_seq { 0x7f, 0xcc, 0x80, 0xcc, 0x81 })
-- Combining characters U+0300, U+0301, U+0302
- eq({"\x7f\xcc\x80\xcc\x81\xcc\x82", 0x7f}, test_seq{0x7f, 0xcc, 0x80, 0xcc, 0x81, 0xcc, 0x82})
+ eq(
+ { '\x7f\xcc\x80\xcc\x81\xcc\x82', 0x7f },
+ test_seq { 0x7f, 0xcc, 0x80, 0xcc, 0x81, 0xcc, 0x82 }
+ )
-- Combining characters U+0300, U+0301, U+0302, U+0303
- eq({"\x7f\xcc\x80\xcc\x81\xcc\x82\xcc\x83", 0x7f}, test_seq{0x7f, 0xcc, 0x80, 0xcc, 0x81, 0xcc, 0x82, 0xcc, 0x83})
+ eq(
+ { '\x7f\xcc\x80\xcc\x81\xcc\x82\xcc\x83', 0x7f },
+ test_seq { 0x7f, 0xcc, 0x80, 0xcc, 0x81, 0xcc, 0x82, 0xcc, 0x83 }
+ )
-- Combining characters U+0300, U+0301, U+0302, U+0303, U+0304
- eq({"\x7f\xcc\x80\xcc\x81\xcc\x82\xcc\x83\xcc\x84", 0x7f}, test_seq{0x7f, 0xcc, 0x80, 0xcc, 0x81, 0xcc, 0x82, 0xcc, 0x83, 0xcc, 0x84})
+ eq(
+ { '\x7f\xcc\x80\xcc\x81\xcc\x82\xcc\x83\xcc\x84', 0x7f },
+ test_seq { 0x7f, 0xcc, 0x80, 0xcc, 0x81, 0xcc, 0x82, 0xcc, 0x83, 0xcc, 0x84 }
+ )
-- Combining characters U+0300, U+0301, U+0302, U+0303, U+0304, U+0305
- eq({"\x7f\xcc\x80\xcc\x81\xcc\x82\xcc\x83\xcc\x84\xcc\x85", 0x7f}, test_seq{0x7f, 0xcc, 0x80, 0xcc, 0x81, 0xcc, 0x82, 0xcc, 0x83, 0xcc, 0x84, 0xcc, 0x85})
+ eq(
+ { '\x7f\xcc\x80\xcc\x81\xcc\x82\xcc\x83\xcc\x84\xcc\x85', 0x7f },
+ test_seq { 0x7f, 0xcc, 0x80, 0xcc, 0x81, 0xcc, 0x82, 0xcc, 0x83, 0xcc, 0x84, 0xcc, 0x85 }
+ )
-- Combining characters U+0300, U+0301, U+0302, U+0303, U+0304, U+0305, U+0306
- eq({"\x7f\xcc\x80\xcc\x81\xcc\x82\xcc\x83\xcc\x84\xcc\x85\xcc\x86", 0x7f}, test_seq{0x7f, 0xcc, 0x80, 0xcc, 0x81, 0xcc, 0x82, 0xcc, 0x83, 0xcc, 0x84, 0xcc, 0x85, 0xcc, 0x86})
+ eq(
+ { '\x7f\xcc\x80\xcc\x81\xcc\x82\xcc\x83\xcc\x84\xcc\x85\xcc\x86', 0x7f },
+ test_seq {
+ 0x7f,
+ 0xcc,
+ 0x80,
+ 0xcc,
+ 0x81,
+ 0xcc,
+ 0x82,
+ 0xcc,
+ 0x83,
+ 0xcc,
+ 0x84,
+ 0xcc,
+ 0x85,
+ 0xcc,
+ 0x86,
+ }
+ )
-- Only three following combining characters U+0300, U+0301, U+0302
- eq({"\x7f\xcc\x80\xcc\x81\xcc\x82", 0x7f}, test_seq{0x7f, 0xcc, 0x80, 0xcc, 0x81, 0xcc, 0x82, 0xc2, 0x80, 0xcc, 0x84, 0xcc, 0x85})
+ eq(
+ { '\x7f\xcc\x80\xcc\x81\xcc\x82', 0x7f },
+ test_seq { 0x7f, 0xcc, 0x80, 0xcc, 0x81, 0xcc, 0x82, 0xc2, 0x80, 0xcc, 0x84, 0xcc, 0x85 }
+ )
-- No UTF-8 sequence
- eq({'', 0xc2}, test_seq{0xc2, 0x7f, 0xcc, 0x80, 0x80})
+ eq({ '', 0xc2 }, test_seq { 0xc2, 0x7f, 0xcc, 0x80, 0x80 })
-- No following UTF-8 character
- eq({"\xc2\x80", 0x80}, test_seq{0xc2, 0x80, 0xcc, 0xcc, 0x80})
+ eq({ '\xc2\x80', 0x80 }, test_seq { 0xc2, 0x80, 0xcc, 0xcc, 0x80 })
-- Combining character U+0301
- eq({"\xc2\x80\xcc\x81", 0x80}, test_seq{0xc2, 0x80, 0xcc, 0x81, 0x7f})
+ eq({ '\xc2\x80\xcc\x81', 0x80 }, test_seq { 0xc2, 0x80, 0xcc, 0x81, 0x7f })
-- Combining character U+0301
- eq({"\xc2\x80\xcc\x81", 0x80}, test_seq{0xc2, 0x80, 0xcc, 0x81, 0xcc})
+ eq({ '\xc2\x80\xcc\x81', 0x80 }, test_seq { 0xc2, 0x80, 0xcc, 0x81, 0xcc })
-- One UTF-8 character
- eq({"\xf4\x80\x80\x80", 0x100000}, test_seq{0xf4, 0x80, 0x80, 0x80, 0x7f})
+ eq({ '\xf4\x80\x80\x80', 0x100000 }, test_seq { 0xf4, 0x80, 0x80, 0x80, 0x7f })
-- One UTF-8 character
- eq({"\xf4\x80\x80\x80", 0x100000}, test_seq{0xf4, 0x80, 0x80, 0x80, 0x80})
+ eq({ '\xf4\x80\x80\x80', 0x100000 }, test_seq { 0xf4, 0x80, 0x80, 0x80, 0x80 })
-- One UTF-8 character
- eq({"\xf4\x80\x80\x80", 0x100000}, test_seq{0xf4, 0x80, 0x80, 0x80, 0xcc})
+ eq({ '\xf4\x80\x80\x80', 0x100000 }, test_seq { 0xf4, 0x80, 0x80, 0x80, 0xcc })
-- Combining characters U+1AB0 and U+0301
- eq({"\xf4\x80\x80\x80\xe1\xaa\xb0\xcc\x81", 0x100000}, test_seq{0xf4, 0x80, 0x80, 0x80, 0xe1, 0xaa, 0xb0, 0xcc, 0x81})
+ eq(
+ { '\xf4\x80\x80\x80\xe1\xaa\xb0\xcc\x81', 0x100000 },
+ test_seq { 0xf4, 0x80, 0x80, 0x80, 0xe1, 0xaa, 0xb0, 0xcc, 0x81 }
+ )
end)
-
end)
-
end)
diff --git a/test/unit/memory_spec.lua b/test/unit/memory_spec.lua
index bd72c8bf47..8be55fdbf3 100644
--- a/test/unit/memory_spec.lua
+++ b/test/unit/memory_spec.lua
@@ -1,4 +1,4 @@
-local helpers = require("test.unit.helpers")(after_each)
+local helpers = require('test.unit.helpers')(after_each)
local itp = helpers.gen_itp(it)
local cimport = helpers.cimport
@@ -11,7 +11,7 @@ local cimp = cimport('stdlib.h', './src/nvim/memory.h')
describe('xstrlcat()', function()
local function test_xstrlcat(dst, src, dsize)
- assert.is_true(dsize >= 1 + string.len(dst)) -- sanity check for tests
+ assert.is_true(dsize >= 1 + string.len(dst)) -- sanity check for tests
local dst_cstr = cstr(dsize, dst)
local src_cstr = to_cstr(src)
eq(string.len(dst .. src), cimp.xstrlcat(dst_cstr, src_cstr, dsize))
@@ -19,34 +19,32 @@ describe('xstrlcat()', function()
end
local function test_xstrlcat_overlap(dst, src_idx, dsize)
- assert.is_true(dsize >= 1 + string.len(dst)) -- sanity check for tests
+ assert.is_true(dsize >= 1 + string.len(dst)) -- sanity check for tests
local dst_cstr = cstr(dsize, dst)
- local src_cstr = dst_cstr + src_idx -- pointer into `dst` (overlaps)
- eq(string.len(dst) + string.len(dst) - src_idx,
- cimp.xstrlcat(dst_cstr, src_cstr, dsize))
+ local src_cstr = dst_cstr + src_idx -- pointer into `dst` (overlaps)
+ eq(string.len(dst) + string.len(dst) - src_idx, cimp.xstrlcat(dst_cstr, src_cstr, dsize))
return ffi.string(dst_cstr)
end
itp('concatenates strings', function()
eq('ab', test_xstrlcat('a', 'b', 3))
eq('ab', test_xstrlcat('a', 'b', 4096))
- eq('ABCיהZdefgiיהZ', test_xstrlcat('ABCיהZ', 'defgiיהZ', 4096))
- eq('b', test_xstrlcat('', 'b', 4096))
- eq('a', test_xstrlcat('a', '', 4096))
+ eq('ABCיהZdefgiיהZ', test_xstrlcat('ABCיהZ', 'defgiיהZ', 4096))
+ eq('b', test_xstrlcat('', 'b', 4096))
+ eq('a', test_xstrlcat('a', '', 4096))
end)
itp('concatenates overlapping strings', function()
- eq('abcabc', test_xstrlcat_overlap('abc', 0, 7))
- eq('abca', test_xstrlcat_overlap('abc', 0, 5))
- eq('abcb', test_xstrlcat_overlap('abc', 1, 5))
- eq('abcc', test_xstrlcat_overlap('abc', 2, 10))
- eq('abcabc', test_xstrlcat_overlap('abc', 0, 2343))
+ eq('abcabc', test_xstrlcat_overlap('abc', 0, 7))
+ eq('abca', test_xstrlcat_overlap('abc', 0, 5))
+ eq('abcb', test_xstrlcat_overlap('abc', 1, 5))
+ eq('abcc', test_xstrlcat_overlap('abc', 2, 10))
+ eq('abcabc', test_xstrlcat_overlap('abc', 0, 2343))
end)
itp('truncates if `dsize` is too small', function()
eq('a', test_xstrlcat('a', 'b', 2))
eq('', test_xstrlcat('', 'b', 1))
- eq('ABCיהZd', test_xstrlcat('ABCיהZ', 'defgiיהZ', 10))
+ eq('ABCיהZd', test_xstrlcat('ABCיהZ', 'defgiיהZ', 10))
end)
-
end)
diff --git a/test/unit/message_spec.lua b/test/unit/message_spec.lua
index 0d5268d199..71aa74d90d 100644
--- a/test/unit/message_spec.lua
+++ b/test/unit/message_spec.lua
@@ -1,12 +1,11 @@
-local helpers = require("test.unit.helpers")(after_each)
+local helpers = require('test.unit.helpers')(after_each)
local itp = helpers.gen_itp(it)
local ffi = helpers.ffi
local eq = helpers.eq
local to_cstr = helpers.to_cstr
-local cimp = helpers.cimport('./src/nvim/message.h', './src/nvim/memory.h',
- './src/nvim/strings.h')
+local cimp = helpers.cimport('./src/nvim/message.h', './src/nvim/memory.h', './src/nvim/strings.h')
describe('trunc_string', function()
local buflen = 40
@@ -34,8 +33,8 @@ describe('trunc_string', function()
{ ['desc'] = 'by copy', ['func'] = test_copy },
}
- for _,t in ipairs(permutations) do
- describe('populates buf '..t.desc, function()
+ for _, t in ipairs(permutations) do
+ describe('populates buf ' .. t.desc, function()
itp('with a small string', function()
t.func('text', 'text')
end)
diff --git a/test/unit/msgpack_spec.lua b/test/unit/msgpack_spec.lua
index c573714714..bd663a3c75 100644
--- a/test/unit/msgpack_spec.lua
+++ b/test/unit/msgpack_spec.lua
@@ -35,32 +35,36 @@ end
describe('msgpack', function()
describe('unpacker', function()
- itp('does not crash when paused between `cells` and `wrap` params of `grid_line` #25184', function()
- -- [kMessageTypeNotification, "redraw", [
- -- ["grid_line",
- -- [2, 0, 0, [[" " , 0, 77]], false]
- -- ]
- -- ]]
- local payload =
- '\x93\x02\xa6\x72\x65\x64\x72\x61\x77\x91\x92\xa9\x67\x72\x69\x64\x5f\x6c\x69\x6e\x65\x95\x02\x00\x00\x91\x93\xa1\x20\x00\x4d\xc2'
+ itp(
+ 'does not crash when paused between `cells` and `wrap` params of `grid_line` #25184',
+ function()
+ -- [kMessageTypeNotification, "redraw", [
+ -- ["grid_line",
+ -- [2, 0, 0, [[" " , 0, 77]], false]
+ -- ]
+ -- ]]
+ local payload =
+ '\x93\x02\xa6\x72\x65\x64\x72\x61\x77\x91\x92\xa9\x67\x72\x69\x64\x5f\x6c\x69\x6e\x65\x95\x02\x00\x00\x91\x93\xa1\x20\x00\x4d\xc2'
- local unpacker = make_unpacker()
- lib.unpacker_init(unpacker)
+ local unpacker = make_unpacker()
+ lib.unpacker_init(unpacker)
- unpacker_goto(unpacker, payload, payload:len() - 1)
- local finished = unpacker_advance(unpacker)
- eq(finished, false)
+ unpacker_goto(unpacker, payload, payload:len() - 1)
+ local finished = unpacker_advance(unpacker)
+ eq(finished, false)
- unpacker[0].read_size = unpacker[0].read_size + 1
- finished = unpacker_advance(unpacker)
- eq(finished, true)
- end)
+ unpacker[0].read_size = unpacker[0].read_size + 1
+ finished = unpacker_advance(unpacker)
+ eq(finished, true)
+ end
+ )
itp('does not crash when parsing grid_line event with 0 `cells` #25184', function()
local unpacker = make_unpacker()
lib.unpacker_init(unpacker)
- unpacker_goto(unpacker,
+ unpacker_goto(
+ unpacker,
-- [kMessageTypeNotification, "redraw", [
-- ["grid_line",
-- [2, 0, 0, [], false]
diff --git a/test/unit/multiqueue_spec.lua b/test/unit/multiqueue_spec.lua
index bb08a8386f..f6d11ebed0 100644
--- a/test/unit/multiqueue_spec.lua
+++ b/test/unit/multiqueue_spec.lua
@@ -1,4 +1,4 @@
-local helpers = require("test.unit.helpers")(after_each)
+local helpers = require('test.unit.helpers')(after_each)
local itp = helpers.gen_itp(it)
local child_call_once = helpers.child_call_once
@@ -6,9 +6,9 @@ local cimport = helpers.cimport
local ffi = helpers.ffi
local eq = helpers.eq
-local multiqueue = cimport("./test/unit/fixtures/multiqueue.h")
+local multiqueue = cimport('./test/unit/fixtures/multiqueue.h')
-describe("multiqueue (multi-level event-queue)", function()
+describe('multiqueue (multi-level event-queue)', function()
local parent, child1, child2, child3
local function put(q, str)
diff --git a/test/unit/optionstr_spec.lua b/test/unit/optionstr_spec.lua
index 2e7198a63a..7666db910e 100644
--- a/test/unit/optionstr_spec.lua
+++ b/test/unit/optionstr_spec.lua
@@ -1,28 +1,27 @@
-local helpers = require("test.unit.helpers")(after_each)
+local helpers = require('test.unit.helpers')(after_each)
local itp = helpers.gen_itp(it)
local to_cstr = helpers.to_cstr
-local eq = helpers.eq
+local eq = helpers.eq
-local optionstr = helpers.cimport("./src/nvim/optionstr.h")
+local optionstr = helpers.cimport('./src/nvim/optionstr.h')
local check_ff_value = function(ff)
return optionstr.check_ff_value(to_cstr(ff))
end
describe('check_ff_value', function()
-
itp('views empty string as valid', function()
- eq(1, check_ff_value(""))
+ eq(1, check_ff_value(''))
end)
itp('views "unix", "dos" and "mac" as valid', function()
- eq(1, check_ff_value("unix"))
- eq(1, check_ff_value("dos"))
- eq(1, check_ff_value("mac"))
+ eq(1, check_ff_value('unix'))
+ eq(1, check_ff_value('dos'))
+ eq(1, check_ff_value('mac'))
end)
itp('views "foo" as invalid', function()
- eq(0, check_ff_value("foo"))
+ eq(0, check_ff_value('foo'))
end)
end)
diff --git a/test/unit/os/env_spec.lua b/test/unit/os/env_spec.lua
index 24b92edee5..2c638fcb37 100644
--- a/test/unit/os/env_spec.lua
+++ b/test/unit/os/env_spec.lua
@@ -62,7 +62,7 @@ describe('env.c', function()
eq('non-empty', os.getenv(name))
end)
- itp("`overwrite` behavior", function()
+ itp('`overwrite` behavior', function()
local name = 'NVIM_UNIT_TEST_SETENV_2N'
local value = 'NVIM_UNIT_TEST_SETENV_2V'
local value_updated = 'NVIM_UNIT_TEST_SETENV_2V_UPDATED'
@@ -79,7 +79,7 @@ describe('env.c', function()
itp('appends :/foo/bar to $PATH', function()
local original_path = os.getenv('PATH')
eq(true, cimp.os_setenv_append_path(to_cstr('/foo/bar/baz.exe')))
- eq(original_path..':/foo/bar', os.getenv('PATH'))
+ eq(original_path .. ':/foo/bar', os.getenv('PATH'))
end)
itp('avoids redundant separator when appending to $PATH #7377', function()
@@ -166,7 +166,7 @@ describe('env.c', function()
local test_value = 'NVIM_UNIT_TEST_GETENVNAME_AT_INDEX_1V'
os_setenv(test_name, test_value, 1)
local i = 0
- local names = { }
+ local names = {}
local found_name = false
local name = cimp.os_getenvname_at_index(i)
while name ~= NULL do
@@ -245,7 +245,7 @@ describe('env.c', function()
local input = '~/foo ~ foo'
local homedir = cstr(255, '')
cimp.expand_env_esc(to_cstr('~'), homedir, 255, false, true, NULL)
- local output_expected = ffi.string(homedir) .. "/foo ~ foo"
+ local output_expected = ffi.string(homedir) .. '/foo ~ foo'
local output = cstr(255, '')
cimp.expand_env_esc(to_cstr(input), output, 255, false, true, NULL)
eq(ffi.string(output), ffi.string(output_expected))
@@ -256,7 +256,7 @@ describe('env.c', function()
local dst = cstr(255, '')
cimp.expand_env_esc(to_cstr('~'), dst, 255, false, true, NULL)
local homedir = ffi.string(dst)
- local output_expected = homedir .. "/foo " .. homedir .. " foo"
+ local output_expected = homedir .. '/foo ' .. homedir .. ' foo'
local output = cstr(255, '')
cimp.expand_env_esc(input, output, 255, false, false, NULL)
eq(output_expected, ffi.string(output))
@@ -267,8 +267,9 @@ describe('env.c', function()
cimp.os_get_username(name_out, 100)
local curuser = ffi.string(name_out)
- local src = to_cstr("~"..curuser.."/Vcs/django-rest-framework/rest_framework/renderers.py")
- local dst = cstr(256, "~"..curuser)
+ local src =
+ to_cstr('~' .. curuser .. '/Vcs/django-rest-framework/rest_framework/renderers.py')
+ local dst = cstr(256, '~' .. curuser)
cimp.expand_env_esc(src, dst, 256, false, false, NULL)
local len = string.len(ffi.string(dst))
assert.True(len > 56)
@@ -283,7 +284,7 @@ describe('env.c', function()
cimp.expand_env_esc(input, output, 5, false, true, NULL)
-- Make sure the first few characters are copied properly and that there is a
-- terminating null character
- for i=0,3 do
+ for i = 0, 3 do
eq(input[i], output[i])
end
eq(0, output[4])
@@ -304,7 +305,7 @@ describe('env.c', function()
-- terminating null character
-- expand_env_esc SHOULD NOT expand the variable if there is not enough space to
-- contain the result
- for i=0,3 do
+ for i = 0, 3 do
eq(output[i], input[i])
end
eq(output[4], 0)
diff --git a/test/unit/os/fileio_spec.lua b/test/unit/os/fileio_spec.lua
index fd30ca70da..30e4fad88f 100644
--- a/test/unit/os/fileio_spec.lua
+++ b/test/unit/os/fileio_spec.lua
@@ -26,7 +26,7 @@ local linkb = dir .. '/broken.lnk'
local filec = dir .. '/created-file.dat'
before_each(function()
- mkdir(dir);
+ mkdir(dir)
local f1 = io.open(file1, 'w')
f1:write(fcontents)
@@ -56,7 +56,7 @@ local function file_open(fname, flags, mode)
end
local function file_open_new(fname, flags, mode)
- local ret1 = ffi.new('int[?]', 1, {0})
+ local ret1 = ffi.new('int[?]', 1, { 0 })
local ret2 = ffi.gc(m.file_open_new(ret1, fname, flags, mode), nil)
return ret1[0], ret2
end
@@ -68,7 +68,7 @@ local function file_open_fd(fd, flags)
end
local function file_open_fd_new(fd, flags)
- local ret1 = ffi.new('int[?]', 1, {0})
+ local ret1 = ffi.new('int[?]', 1, { 0 })
local ret2 = ffi.gc(m.file_open_fd_new(ret1, fd, flags), nil)
return ret1[0], ret2
end
@@ -116,7 +116,7 @@ describe('file_open_fd', function()
local fd = m.os_open(file1, m.kO_RDONLY, 0)
local err, fp = file_open_fd(fd, m.kFileReadOnly)
eq(0, err)
- eq({#fcontents, fcontents}, {file_read(fp, #fcontents)})
+ eq({ #fcontents, fcontents }, { file_read(fp, #fcontents) })
eq(0, m.file_close(fp, false))
end)
itp('can use file descriptor returned by os_open for writing', function()
@@ -136,7 +136,7 @@ describe('file_open_fd_new', function()
local fd = m.os_open(file1, m.kO_RDONLY, 0)
local err, fp = file_open_fd_new(fd, m.kFileReadOnly)
eq(0, err)
- eq({#fcontents, fcontents}, {file_read(fp, #fcontents)})
+ eq({ #fcontents, fcontents }, { file_read(fp, #fcontents) })
eq(0, m.file_free(fp, false))
end)
itp('can use file descriptor returned by os_open for writing', function()
@@ -193,7 +193,9 @@ describe('file_open', function()
local err, _ = file_open(linkf, m.kFileNoSymlink, 384)
-- err is UV_EMLINK in FreeBSD, but if I use `ok(err == m.UV_ELOOP or err ==
-- m.UV_EMLINK)`, then I loose the ability to see actual `err` value.
- if err ~= m.UV_ELOOP then eq(m.UV_EMLINK, err) end
+ if err ~= m.UV_ELOOP then
+ eq(m.UV_EMLINK, err)
+ end
end)
itp('can open an existing file write-only with kFileCreate', function()
@@ -249,8 +251,7 @@ describe('file_open', function()
eq(nil, attrs)
end)
- itp('can truncate an existing file with kFileTruncate when opening a symlink',
- function()
+ itp('can truncate an existing file with kFileTruncate when opening a symlink', function()
local err, fp = file_open(linkf, m.kFileTruncate, 384)
eq(0, err)
eq(true, fp.wr)
@@ -356,10 +357,9 @@ describe('file_read', function()
local exp_s = fcontents:sub(shift + 1, shift + size)
if shift + size >= #fcontents then
exp_err = #fcontents - shift
- exp_s = (fcontents:sub(shift + 1, shift + size)
- .. (('\0'):rep(size - exp_err)))
+ exp_s = (fcontents:sub(shift + 1, shift + size) .. (('\0'):rep(size - exp_err)))
end
- eq({exp_err, exp_s}, {file_read(fp, size)})
+ eq({ exp_err, exp_s }, { file_read(fp, size) })
shift = shift + size
end
eq(0, m.file_close(fp, false))
@@ -369,8 +369,8 @@ describe('file_read', function()
local err, fp = file_open(file1, 0, 384)
eq(0, err)
eq(false, fp.wr)
- eq({#fcontents, fcontents}, {file_read(fp, #fcontents)})
- eq({0, ('\0'):rep(#fcontents)}, {file_read(fp, #fcontents)})
+ eq({ #fcontents, fcontents }, { file_read(fp, #fcontents) })
+ eq({ 0, ('\0'):rep(#fcontents) }, { file_read(fp, #fcontents) })
eq(0, m.file_close(fp, false))
end)
@@ -378,9 +378,8 @@ describe('file_read', function()
local err, fp = file_open(file1, 0, 384)
eq(0, err)
eq(false, fp.wr)
- eq({5, fcontents:sub(1, 5)}, {file_read(fp, 5)})
- eq({#fcontents - 5, fcontents:sub(6) .. (('\0'):rep(5))},
- {file_read(fp, #fcontents)})
+ eq({ 5, fcontents:sub(1, 5) }, { file_read(fp, 5) })
+ eq({ #fcontents - 5, fcontents:sub(6) .. (('\0'):rep(5)) }, { file_read(fp, #fcontents) })
eq(0, m.file_close(fp, false))
end)
@@ -395,10 +394,9 @@ describe('file_read', function()
local exp_s = fcontents:sub(shift + 1, shift + size)
if shift + size >= #fcontents then
exp_err = #fcontents - shift
- exp_s = (fcontents:sub(shift + 1, shift + size)
- .. (('\0'):rep(size - exp_err)))
+ exp_s = (fcontents:sub(shift + 1, shift + size) .. (('\0'):rep(size - exp_err)))
end
- eq({exp_err, exp_s}, {file_read(fp, size)})
+ eq({ exp_err, exp_s }, { file_read(fp, size) })
shift = shift + size
end
eq(0, m.file_close(fp, false))
diff --git a/test/unit/os/fs_spec.lua b/test/unit/os/fs_spec.lua
index 8f45d2b0c7..8e20c0a883 100644
--- a/test/unit/os/fs_spec.lua
+++ b/test/unit/os/fs_spec.lua
@@ -68,7 +68,7 @@ describe('fs.c', function()
end
before_each(function()
- mkdir('unit-test-directory');
+ mkdir('unit-test-directory')
io.open('unit-test-directory/test.file', 'w'):close()
@@ -115,8 +115,8 @@ describe('fs.c', function()
eq(OK, fs.os_dirname(expected_cwd, length))
-- os_chdir returns 0 for success, not OK (1).
- neq(0, fs.os_chdir('~')) -- fail
- neq(0, fs.os_chdir('~/')) -- fail
+ neq(0, fs.os_chdir('~')) -- fail
+ neq(0, fs.os_chdir('~/')) -- fail
eq(OK, fs.os_dirname(cwd, length))
-- CWD did not change.
@@ -284,31 +284,34 @@ describe('fs.c', function()
end)
-- Some systems may not have `id` utility.
- if (os.execute('id -G > /dev/null 2>&1') ~= 0) then
+ if os.execute('id -G > /dev/null 2>&1') ~= 0 then
pending('skipped (missing `id` utility)', function() end)
else
- itp('owner of a file may change the group of the file to any group of which that owner is a member', function()
- local file_gid = luv.fs_stat(filename).gid
-
- -- Gets ID of any group of which current user is a member except the
- -- group that owns the file.
- local id_fd = io.popen('id -G')
- local new_gid = id_fd:read('*n')
- if (new_gid == file_gid) then
- new_gid = id_fd:read('*n')
+ itp(
+ 'owner of a file may change the group of the file to any group of which that owner is a member',
+ function()
+ local file_gid = luv.fs_stat(filename).gid
+
+ -- Gets ID of any group of which current user is a member except the
+ -- group that owns the file.
+ local id_fd = io.popen('id -G')
+ local new_gid = id_fd:read('*n')
+ if new_gid == file_gid then
+ new_gid = id_fd:read('*n')
+ end
+ id_fd:close()
+
+ -- User can be a member of only one group.
+ -- In that case we can not perform this test.
+ if new_gid then
+ eq(0, (os_fchown(filename, -1, new_gid)))
+ eq(new_gid, luv.fs_stat(filename).gid)
+ end
end
- id_fd:close()
-
- -- User can be a member of only one group.
- -- In that case we can not perform this test.
- if new_gid then
- eq(0, (os_fchown(filename, -1, new_gid)))
- eq(new_gid, luv.fs_stat(filename).gid)
- end
- end)
+ )
end
- if (ffi.os == 'Windows' or ffi.C.geteuid() == 0) then
+ if ffi.os == 'Windows' or ffi.C.geteuid() == 0 then
pending('skipped (uv_fs_chown is no-op on Windows)', function() end)
else
itp('returns nonzero if process has not enough permissions', function()
@@ -318,7 +321,6 @@ describe('fs.c', function()
end
end)
-
describe('os_file_is_readable', function()
itp('returns false if the file is not readable', function()
local perm = os_getperm('unit-test-directory/test.file')
@@ -330,13 +332,11 @@ describe('fs.c', function()
end)
itp('returns false if the file does not exist', function()
- eq(false, os_file_is_readable(
- 'unit-test-directory/what_are_you_smoking.gif'))
+ eq(false, os_file_is_readable('unit-test-directory/what_are_you_smoking.gif'))
end)
itp('returns true if the file is readable', function()
- eq(true, os_file_is_readable(
- 'unit-test-directory/test.file'))
+ eq(true, os_file_is_readable('unit-test-directory/test.file'))
end)
end)
@@ -387,7 +387,7 @@ describe('fs.c', function()
else
buf = ffi.new('char[?]', size + 1, ('\0'):rep(size))
end
- local eof = ffi.new('bool[?]', 1, {true})
+ local eof = ffi.new('bool[?]', 1, { true })
local ret2 = fs.os_read(fd, eof, buf, size, false)
local ret1 = eof[0]
local ret3 = ''
@@ -400,16 +400,16 @@ describe('fs.c', function()
local bufs = {}
for i, size in ipairs(sizes) do
bufs[i] = {
- iov_base=ffi.new('char[?]', size + 1, ('\0'):rep(size)),
- iov_len=size,
+ iov_base = ffi.new('char[?]', size + 1, ('\0'):rep(size)),
+ iov_len = size,
}
end
local iov = ffi.new('struct iovec[?]', #sizes, bufs)
- local eof = ffi.new('bool[?]', 1, {true})
+ local eof = ffi.new('bool[?]', 1, { true })
local ret2 = fs.os_readv(fd, eof, iov, #sizes, false)
local ret1 = eof[0]
local ret3 = {}
- for i = 1,#sizes do
+ for i = 1, #sizes do
-- Warning: iov may not be used.
ret3[i] = ffi.string(bufs[i].iov_base, bufs[i].iov_len)
end
@@ -445,7 +445,7 @@ describe('fs.c', function()
eq(OK, (os_rename(test, not_exist)))
eq(false, (os_path_exists(test)))
eq(true, (os_path_exists(not_exist)))
- eq(OK, (os_rename(not_exist, test))) -- restore test file
+ eq(OK, (os_rename(not_exist, test))) -- restore test file
end)
itp('fail if source file does not exist', function()
@@ -494,14 +494,19 @@ describe('fs.c', function()
local dup0 = fs.os_dup(0)
local dup1 = fs.os_dup(1)
local dup2 = fs.os_dup(2)
- local tbl = {[0]=true, [1]=true, [2]=true,
- [tonumber(dup0)]=true, [tonumber(dup1)]=true,
- [tonumber(dup2)]=true}
+ local tbl = {
+ [0] = true,
+ [1] = true,
+ [2] = true,
+ [tonumber(dup0)] = true,
+ [tonumber(dup1)] = true,
+ [tonumber(dup2)] = true,
+ }
local i = 0
for _, _ in pairs(tbl) do
i = i + 1
end
- eq(i, 6) -- All fds must be unique
+ eq(i, 6) -- All fds must be unique
end)
end)
@@ -522,12 +527,15 @@ describe('fs.c', function()
eq(ffi.C.UV_ENOENT, (os_open('non-existing-file', ffi.C.kO_RDWR, 0)))
end)
- itp('returns non-negative for O_CREAT on a non-existing file which then can be closed', function()
- assert_file_does_not_exist(new_file)
- local fd = os_open(new_file, ffi.C.kO_CREAT, 0)
- assert.is_true(0 <= fd)
- eq(0, os_close(fd))
- end)
+ itp(
+ 'returns non-negative for O_CREAT on a non-existing file which then can be closed',
+ function()
+ assert_file_does_not_exist(new_file)
+ local fd = os_open(new_file, ffi.C.kO_CREAT, 0)
+ assert.is_true(0 <= fd)
+ eq(0, os_close(fd))
+ end
+ )
itp('returns non-negative for O_CREAT on a existing file which then can be closed', function()
assert_file_exists(existing_file)
@@ -544,7 +552,7 @@ describe('fs.c', function()
itp('sets `rwx` permissions for O_CREAT 700 which then can be closed', function()
assert_file_does_not_exist(new_file)
--create the file
- local fd = os_open(new_file, ffi.C.kO_CREAT, tonumber("700", 8))
+ local fd = os_open(new_file, ffi.C.kO_CREAT, tonumber('700', 8))
--verify permissions
eq(33216, luv.fs_stat(new_file).mode)
eq(0, os_close(fd))
@@ -553,17 +561,20 @@ describe('fs.c', function()
itp('sets `rw` permissions for O_CREAT 600 which then can be closed', function()
assert_file_does_not_exist(new_file)
--create the file
- local fd = os_open(new_file, ffi.C.kO_CREAT, tonumber("600", 8))
+ local fd = os_open(new_file, ffi.C.kO_CREAT, tonumber('600', 8))
--verify permissions
eq(33152, luv.fs_stat(new_file).mode)
eq(0, os_close(fd))
end)
- itp('returns a non-negative file descriptor for an existing file which then can be closed', function()
- local fd = os_open(existing_file, ffi.C.kO_RDWR, 0)
- assert.is_true(0 <= fd)
- eq(0, os_close(fd))
- end)
+ itp(
+ 'returns a non-negative file descriptor for an existing file which then can be closed',
+ function()
+ local fd = os_open(existing_file, ffi.C.kO_RDWR, 0)
+ assert.is_true(0 <= fd)
+ eq(0, os_close(fd))
+ end
+ )
end)
describe('os_close', function()
@@ -589,43 +600,48 @@ describe('fs.c', function()
itp('can read zero bytes from a file', function()
local fd = os_open(file, ffi.C.kO_RDONLY, 0)
ok(fd >= 0)
- eq({false, 0, ''}, {os_read(fd, nil)})
- eq({false, 0, ''}, {os_read(fd, 0)})
+ eq({ false, 0, '' }, { os_read(fd, nil) })
+ eq({ false, 0, '' }, { os_read(fd, 0) })
eq(0, os_close(fd))
end)
itp('can read from a file multiple times', function()
local fd = os_open(file, ffi.C.kO_RDONLY, 0)
ok(fd >= 0)
- eq({false, 2, '\000\001'}, {os_read(fd, 2)})
- eq({false, 2, '\002\003'}, {os_read(fd, 2)})
+ eq({ false, 2, '\000\001' }, { os_read(fd, 2) })
+ eq({ false, 2, '\002\003' }, { os_read(fd, 2) })
eq(0, os_close(fd))
end)
itp('can read the whole file at once and then report eof', function()
local fd = os_open(file, ffi.C.kO_RDONLY, 0)
ok(fd >= 0)
- eq({false, #fcontents, fcontents}, {os_read(fd, #fcontents)})
- eq({true, 0, ('\0'):rep(#fcontents)}, {os_read(fd, #fcontents)})
+ eq({ false, #fcontents, fcontents }, { os_read(fd, #fcontents) })
+ eq({ true, 0, ('\0'):rep(#fcontents) }, { os_read(fd, #fcontents) })
eq(0, os_close(fd))
end)
itp('can read the whole file in two calls, one partially', function()
local fd = os_open(file, ffi.C.kO_RDONLY, 0)
ok(fd >= 0)
- eq({false, #fcontents * 3/4, fcontents:sub(1, #fcontents * 3/4)},
- {os_read(fd, #fcontents * 3/4)})
- eq({true,
- (#fcontents * 1/4),
- fcontents:sub(#fcontents * 3/4 + 1) .. ('\0'):rep(#fcontents * 2/4)},
- {os_read(fd, #fcontents * 3/4)})
+ eq(
+ { false, #fcontents * 3 / 4, fcontents:sub(1, #fcontents * 3 / 4) },
+ { os_read(fd, #fcontents * 3 / 4) }
+ )
+ eq({
+ true,
+ (#fcontents * 1 / 4),
+ fcontents:sub(#fcontents * 3 / 4 + 1) .. ('\0'):rep(#fcontents * 2 / 4),
+ }, { os_read(fd, #fcontents * 3 / 4) })
eq(0, os_close(fd))
end)
end)
describe('os_readv', function()
-- Function may be absent
- if not pcall(function() return fs.os_readv end) then
+ if not pcall(function()
+ return fs.os_readv
+ end) then
return
end
local file = 'test-unit-os-fs_spec-os_readv.dat'
@@ -643,45 +659,53 @@ describe('fs.c', function()
itp('can read zero bytes from a file', function()
local fd = os_open(file, ffi.C.kO_RDONLY, 0)
ok(fd >= 0)
- eq({false, 0, {}}, {os_readv(fd, {})})
- eq({false, 0, {'', '', ''}}, {os_readv(fd, {0, 0, 0})})
+ eq({ false, 0, {} }, { os_readv(fd, {}) })
+ eq({ false, 0, { '', '', '' } }, { os_readv(fd, { 0, 0, 0 }) })
eq(0, os_close(fd))
end)
itp('can read from a file multiple times to a differently-sized buffers', function()
local fd = os_open(file, ffi.C.kO_RDONLY, 0)
ok(fd >= 0)
- eq({false, 2, {'\000\001'}}, {os_readv(fd, {2})})
- eq({false, 5, {'\002\003', '\004\005\006'}}, {os_readv(fd, {2, 3})})
+ eq({ false, 2, { '\000\001' } }, { os_readv(fd, { 2 }) })
+ eq({ false, 5, { '\002\003', '\004\005\006' } }, { os_readv(fd, { 2, 3 }) })
eq(0, os_close(fd))
end)
itp('can read the whole file at once and then report eof', function()
local fd = os_open(file, ffi.C.kO_RDONLY, 0)
ok(fd >= 0)
- eq({false,
- #fcontents,
- {fcontents:sub(1, #fcontents * 1/4),
- fcontents:sub(#fcontents * 1/4 + 1, #fcontents * 3/4),
- fcontents:sub(#fcontents * 3/4 + 1, #fcontents * 15/16),
- fcontents:sub(#fcontents * 15/16 + 1, #fcontents)}},
- {os_readv(fd, {#fcontents * 1/4,
- #fcontents * 2/4,
- #fcontents * 3/16,
- #fcontents * 1/16})})
- eq({true, 0, {'\0'}}, {os_readv(fd, {1})})
+ eq({
+ false,
+ #fcontents,
+ {
+ fcontents:sub(1, #fcontents * 1 / 4),
+ fcontents:sub(#fcontents * 1 / 4 + 1, #fcontents * 3 / 4),
+ fcontents:sub(#fcontents * 3 / 4 + 1, #fcontents * 15 / 16),
+ fcontents:sub(#fcontents * 15 / 16 + 1, #fcontents),
+ },
+ }, {
+ os_readv(
+ fd,
+ { #fcontents * 1 / 4, #fcontents * 2 / 4, #fcontents * 3 / 16, #fcontents * 1 / 16 }
+ ),
+ })
+ eq({ true, 0, { '\0' } }, { os_readv(fd, { 1 }) })
eq(0, os_close(fd))
end)
itp('can read the whole file in two calls, one partially', function()
local fd = os_open(file, ffi.C.kO_RDONLY, 0)
ok(fd >= 0)
- eq({false, #fcontents * 3/4, {fcontents:sub(1, #fcontents * 3/4)}},
- {os_readv(fd, {#fcontents * 3/4})})
- eq({true,
- (#fcontents * 1/4),
- {fcontents:sub(#fcontents * 3/4 + 1) .. ('\0'):rep(#fcontents * 2/4)}},
- {os_readv(fd, {#fcontents * 3/4})})
+ eq(
+ { false, #fcontents * 3 / 4, { fcontents:sub(1, #fcontents * 3 / 4) } },
+ { os_readv(fd, { #fcontents * 3 / 4 }) }
+ )
+ eq({
+ true,
+ (#fcontents * 1 / 4),
+ { fcontents:sub(#fcontents * 3 / 4 + 1) .. ('\0'):rep(#fcontents * 2 / 4) },
+ }, { os_readv(fd, { #fcontents * 3 / 4 }) })
eq(0, os_close(fd))
end)
end)
@@ -744,8 +768,8 @@ describe('fs.c', function()
end
local function os_mkdir_recurse(path, mode)
- local failed_str = ffi.new('char *[1]', {nil})
- local created_str = ffi.new('char *[1]', {nil})
+ local failed_str = ffi.new('char *[1]', { nil })
+ local created_str = ffi.new('char *[1]', { nil })
local ret = fs.os_mkdir_recurse(path, mode, failed_str, created_str)
local failed_dir = failed_str[0]
if failed_dir ~= nil then
@@ -784,8 +808,7 @@ describe('fs.c', function()
itp('fails to create a directory where there is a file', function()
local mode = ffi.C.kS_IRUSR + ffi.C.kS_IWUSR + ffi.C.kS_IXUSR
- local ret, failed_dir, created_dir = os_mkdir_recurse(
- 'unit-test-directory/test.file', mode)
+ local ret, failed_dir, created_dir = os_mkdir_recurse('unit-test-directory/test.file', mode)
neq(0, ret)
eq('unit-test-directory/test.file', failed_dir)
eq(nil, created_dir)
@@ -793,8 +816,8 @@ describe('fs.c', function()
itp('fails to create a directory where there is a file in path', function()
local mode = ffi.C.kS_IRUSR + ffi.C.kS_IWUSR + ffi.C.kS_IXUSR
- local ret, failed_dir, created_dir = os_mkdir_recurse(
- 'unit-test-directory/test.file/test', mode)
+ local ret, failed_dir, created_dir =
+ os_mkdir_recurse('unit-test-directory/test.file/test', mode)
neq(0, ret)
eq('unit-test-directory/test.file', failed_dir)
eq(nil, created_dir)
@@ -802,8 +825,8 @@ describe('fs.c', function()
itp('succeeds to create a directory', function()
local mode = ffi.C.kS_IRUSR + ffi.C.kS_IWUSR + ffi.C.kS_IXUSR
- local ret, failed_dir, created_dir = os_mkdir_recurse(
- 'unit-test-directory/new-dir-recurse', mode)
+ local ret, failed_dir, created_dir =
+ os_mkdir_recurse('unit-test-directory/new-dir-recurse', mode)
eq(0, ret)
eq(nil, failed_dir)
ok(endswith(created_dir, 'unit-test-directory/new-dir-recurse'))
@@ -814,8 +837,8 @@ describe('fs.c', function()
itp('succeeds to create a directory ending with ///', function()
local mode = ffi.C.kS_IRUSR + ffi.C.kS_IWUSR + ffi.C.kS_IXUSR
- local ret, failed_dir, created_dir = os_mkdir_recurse(
- 'unit-test-directory/new-dir-recurse///', mode)
+ local ret, failed_dir, created_dir =
+ os_mkdir_recurse('unit-test-directory/new-dir-recurse///', mode)
eq(0, ret)
eq(nil, failed_dir)
ok(endswith(created_dir, 'unit-test-directory/new-dir-recurse'))
@@ -826,8 +849,8 @@ describe('fs.c', function()
itp('succeeds to create a directory ending with /', function()
local mode = ffi.C.kS_IRUSR + ffi.C.kS_IWUSR + ffi.C.kS_IXUSR
- local ret, failed_dir, created_dir = os_mkdir_recurse(
- 'unit-test-directory/new-dir-recurse/', mode)
+ local ret, failed_dir, created_dir =
+ os_mkdir_recurse('unit-test-directory/new-dir-recurse/', mode)
eq(0, ret)
eq(nil, failed_dir)
ok(endswith(created_dir, 'unit-test-directory/new-dir-recurse'))
@@ -838,8 +861,8 @@ describe('fs.c', function()
itp('succeeds to create a directory tree', function()
local mode = ffi.C.kS_IRUSR + ffi.C.kS_IWUSR + ffi.C.kS_IXUSR
- local ret, failed_dir, created_dir = os_mkdir_recurse(
- 'unit-test-directory/new-dir-recurse/1/2/3', mode)
+ local ret, failed_dir, created_dir =
+ os_mkdir_recurse('unit-test-directory/new-dir-recurse/1/2/3', mode)
eq(0, ret)
eq(nil, failed_dir)
ok(endswith(created_dir, 'unit-test-directory/new-dir-recurse'))
diff --git a/test/unit/os/shell_spec.lua b/test/unit/os/shell_spec.lua
index 3fb1afed44..ae162f2317 100644
--- a/test/unit/os/shell_spec.lua
+++ b/test/unit/os/shell_spec.lua
@@ -21,9 +21,7 @@ describe('shell functions', function()
end)
local function shell_build_argv(cmd, extra_args)
- local res = cimported.shell_build_argv(
- cmd and to_cstr(cmd),
- extra_args and to_cstr(extra_args))
+ local res = cimported.shell_build_argv(cmd and to_cstr(cmd), extra_args and to_cstr(extra_args))
-- `res` is zero-indexed (C pointer, not Lua table)!
local argc = 0
local ret = {}
@@ -40,9 +38,7 @@ describe('shell functions', function()
local function shell_argv_to_str(argv_table)
-- C string array (char **).
- local argv = (argv_table
- and ffi.new("char*[?]", #argv_table+1)
- or NULL)
+ local argv = (argv_table and ffi.new('char*[?]', #argv_table + 1) or NULL)
local argc = 1
while argv_table ~= nil and argv_table[argc] ~= nil do
@@ -64,8 +60,7 @@ describe('shell functions', function()
local output = ffi.new('char *[1]')
local nread = ffi.new('size_t[1]')
- local argv = ffi.cast('char**',
- cimported.shell_build_argv(to_cstr(cmd), nil))
+ local argv = ffi.cast('char**', cimported.shell_build_argv(to_cstr(cmd), nil))
local status = cimported.os_system(argv, input_or, input_len, output, nread)
return status, intern(output[0], nread[0])
@@ -101,37 +96,35 @@ describe('shell functions', function()
describe('shell_build_argv', function()
itp('works with NULL arguments', function()
- eq({'/bin/sh'}, shell_build_argv(nil, nil))
+ eq({ '/bin/sh' }, shell_build_argv(nil, nil))
end)
itp('works with cmd', function()
- eq({'/bin/sh', '-c', 'abc def'}, shell_build_argv('abc def', nil))
+ eq({ '/bin/sh', '-c', 'abc def' }, shell_build_argv('abc def', nil))
end)
itp('works with extra_args', function()
- eq({'/bin/sh', 'ghi jkl'}, shell_build_argv(nil, 'ghi jkl'))
+ eq({ '/bin/sh', 'ghi jkl' }, shell_build_argv(nil, 'ghi jkl'))
end)
itp('works with cmd and extra_args', function()
- eq({'/bin/sh', 'ghi jkl', '-c', 'abc def'}, shell_build_argv('abc def', 'ghi jkl'))
+ eq({ '/bin/sh', 'ghi jkl', '-c', 'abc def' }, shell_build_argv('abc def', 'ghi jkl'))
end)
itp('splits and unquotes &shell and &shellcmdflag', function()
cimported.p_sh = to_cstr('/Program" "Files/zsh -f')
cimported.p_shcf = to_cstr('-x -o "sh word split" "-"c')
- eq({'/Program Files/zsh', '-f',
- 'ghi jkl',
- '-x', '-o', 'sh word split',
- '-c', 'abc def'},
- shell_build_argv('abc def', 'ghi jkl'))
+ eq(
+ { '/Program Files/zsh', '-f', 'ghi jkl', '-x', '-o', 'sh word split', '-c', 'abc def' },
+ shell_build_argv('abc def', 'ghi jkl')
+ )
end)
itp('applies shellxescape (p_sxe) and shellxquote (p_sxq)', function()
cimported.p_sxq = to_cstr('(')
cimported.p_sxe = to_cstr('"&|<>()@^')
- local argv = ffi.cast('char**',
- cimported.shell_build_argv(to_cstr('echo &|<>()@^'), nil))
+ local argv = ffi.cast('char**', cimported.shell_build_argv(to_cstr('echo &|<>()@^'), nil))
eq(ffi.string(argv[0]), '/bin/sh')
eq(ffi.string(argv[1]), '-c')
eq(ffi.string(argv[2]), '(echo ^&^|^<^>^(^)^@^^)')
@@ -142,8 +135,7 @@ describe('shell functions', function()
cimported.p_sxq = to_cstr('"(')
cimported.p_sxe = to_cstr('"&|<>()@^')
- local argv = ffi.cast('char**', cimported.shell_build_argv(
- to_cstr('echo -n some text'), nil))
+ local argv = ffi.cast('char**', cimported.shell_build_argv(to_cstr('echo -n some text'), nil))
eq(ffi.string(argv[0]), '/bin/sh')
eq(ffi.string(argv[1]), '-c')
eq(ffi.string(argv[2]), '"(echo -n some text)"')
@@ -154,8 +146,7 @@ describe('shell functions', function()
cimported.p_sxq = to_cstr('"')
cimported.p_sxe = to_cstr('')
- local argv = ffi.cast('char**', cimported.shell_build_argv(
- to_cstr('echo -n some text'), nil))
+ local argv = ffi.cast('char**', cimported.shell_build_argv(to_cstr('echo -n some text'), nil))
eq(ffi.string(argv[0]), '/bin/sh')
eq(ffi.string(argv[1]), '-c')
eq(ffi.string(argv[2]), '"echo -n some text"')
@@ -163,8 +154,7 @@ describe('shell functions', function()
end)
itp('with empty shellxquote/shellxescape', function()
- local argv = ffi.cast('char**', cimported.shell_build_argv(
- to_cstr('echo -n some text'), nil))
+ local argv = ffi.cast('char**', cimported.shell_build_argv(to_cstr('echo -n some text'), nil))
eq(ffi.string(argv[0]), '/bin/sh')
eq(ffi.string(argv[1]), '-c')
eq(ffi.string(argv[2]), 'echo -n some text')
@@ -176,9 +166,11 @@ describe('shell functions', function()
eq('', shell_argv_to_str({ nil }))
eq("''", shell_argv_to_str({ '' }))
eq("'foo' '' 'bar'", shell_argv_to_str({ 'foo', '', 'bar' }))
- eq("'/bin/sh' '-c' 'abc def'", shell_argv_to_str({'/bin/sh', '-c', 'abc def'}))
- eq("'abc def' 'ghi jkl'", shell_argv_to_str({'abc def', 'ghi jkl'}))
- eq("'/bin/sh' '-c' 'abc def' '"..('x'):rep(225).."...",
- shell_argv_to_str({'/bin/sh', '-c', 'abc def', ('x'):rep(999)}))
+ eq("'/bin/sh' '-c' 'abc def'", shell_argv_to_str({ '/bin/sh', '-c', 'abc def' }))
+ eq("'abc def' 'ghi jkl'", shell_argv_to_str({ 'abc def', 'ghi jkl' }))
+ eq(
+ "'/bin/sh' '-c' 'abc def' '" .. ('x'):rep(225) .. '...',
+ shell_argv_to_str({ '/bin/sh', '-c', 'abc def', ('x'):rep(999) })
+ )
end)
end)
diff --git a/test/unit/path_spec.lua b/test/unit/path_spec.lua
index 23f71cfe78..7614b4dd9c 100644
--- a/test/unit/path_spec.lua
+++ b/test/unit/path_spec.lua
@@ -184,7 +184,7 @@ describe('path.c', function()
itp('returns the executable name of an invocation given a relative invocation', function()
local invk, len = invocation_path_tail('directory/exe a b c')
- compare("exe a b c", invk, len)
+ compare('exe a b c', invk, len)
eq(3, len)
end)
@@ -202,7 +202,7 @@ describe('path.c', function()
itp('does not count arguments to the executable as part of its path', function()
local invk, len = invocation_path_tail('exe a/b\\c')
- compare("exe a/b\\c", invk, len)
+ compare('exe a/b\\c', invk, len)
eq(3, len)
end)
@@ -212,17 +212,17 @@ describe('path.c', function()
end)
itp('is equivalent to path_tail when args do not contain a path separator', function()
- local ptail = cimp.path_tail(to_cstr("a/b/c x y z"))
+ local ptail = cimp.path_tail(to_cstr('a/b/c x y z'))
neq(NULL, ptail)
local tail = ffi.string(ptail)
- local invk, _ = invocation_path_tail("a/b/c x y z")
+ local invk, _ = invocation_path_tail('a/b/c x y z')
eq(tail, ffi.string(invk))
end)
itp('is not equivalent to path_tail when args contain a path separator', function()
- local ptail = cimp.path_tail(to_cstr("a/b/c x y/z"))
+ local ptail = cimp.path_tail(to_cstr('a/b/c x y/z'))
neq(NULL, ptail)
- local invk, _ = invocation_path_tail("a/b/c x y/z")
+ local invk, _ = invocation_path_tail('a/b/c x y/z')
neq((ffi.string(ptail)), (ffi.string(invk)))
end)
end)
@@ -304,12 +304,12 @@ end)
describe('path.c path_guess_exepath', function()
local cwd = luv.cwd()
- for _,name in ipairs({'./nvim', '.nvim', 'foo/nvim'}) do
- itp('"'..name..'" returns name catenated with CWD', function()
+ for _, name in ipairs({ './nvim', '.nvim', 'foo/nvim' }) do
+ itp('"' .. name .. '" returns name catenated with CWD', function()
local bufsize = 255
local buf = cstr(bufsize, '')
cimp.path_guess_exepath(name, buf, bufsize)
- eq(cwd..'/'..name, ffi.string(buf))
+ eq(cwd .. '/' .. name, ffi.string(buf))
end)
end
@@ -331,10 +331,10 @@ describe('path.c path_guess_exepath', function()
itp('does not crash if $PATH item exceeds MAXPATHL', function()
local orig_path_env = os.getenv('PATH')
- local name = 'cat' -- Some executable in $PATH.
+ local name = 'cat' -- Some executable in $PATH.
local bufsize = 255
local buf = cstr(bufsize, '')
- local insane_path = orig_path_env..':'..(("x/"):rep(4097))
+ local insane_path = orig_path_env .. ':' .. (('x/'):rep(4097))
cimp.os_setenv('PATH', insane_path, true)
cimp.path_guess_exepath(name, buf, bufsize)
@@ -345,7 +345,7 @@ describe('path.c path_guess_exepath', function()
end)
itp('returns full path found in $PATH', function()
- local name = 'cat' -- Some executable in $PATH.
+ local name = 'cat' -- Some executable in $PATH.
local bufsize = 255
local buf = cstr(bufsize, '')
cimp.path_guess_exepath(name, buf, bufsize)
@@ -356,7 +356,7 @@ end)
describe('path.c', function()
setup(function()
- mkdir('unit-test-directory');
+ mkdir('unit-test-directory')
io.open('unit-test-directory/test.file', 'w'):close()
-- Since the tests are executed, they are called by an executable. We use
@@ -365,7 +365,7 @@ describe('path.c', function()
-- Split absolute_executable into a directory and the actual file name for
-- later usage.
- local directory, executable_name = string.match(absolute_executable, '^(.*)/(.*)$') -- luacheck: ignore
+ local directory, executable_name = string.match(absolute_executable, '^(.*)/(.*)$') -- luacheck: ignore
end)
teardown(function()
@@ -441,18 +441,21 @@ describe('path.c', function()
eq(OK, result)
end)
- itp('enters given directory (instead of just concatenating the strings) if possible and if path contains a slash', function()
- local old_dir = luv.cwd()
- luv.chdir('..')
- local expected = luv.cwd() .. '/test.file'
- luv.chdir(old_dir)
- local filename = '../test.file'
- local buflen = get_buf_len(expected, filename)
- local do_expand = 1
- local buf, result = vim_FullName(filename, buflen, do_expand)
- eq(expected, ffi.string(buf))
- eq(OK, result)
- end)
+ itp(
+ 'enters given directory (instead of just concatenating the strings) if possible and if path contains a slash',
+ function()
+ local old_dir = luv.cwd()
+ luv.chdir('..')
+ local expected = luv.cwd() .. '/test.file'
+ luv.chdir(old_dir)
+ local filename = '../test.file'
+ local buflen = get_buf_len(expected, filename)
+ local do_expand = 1
+ local buf, result = vim_FullName(filename, buflen, do_expand)
+ eq(expected, ffi.string(buf))
+ eq(OK, result)
+ end
+ )
itp('just copies the path if it is already absolute and force=0', function()
local absolute_path = '/absolute/path'
@@ -544,8 +547,12 @@ describe('path.c', function()
return ffi.string(c_file)
end
- before_each(function() mkdir('CamelCase') end)
- after_each(function() luv.fs_rmdir('CamelCase') end)
+ before_each(function()
+ mkdir('CamelCase')
+ end)
+ after_each(function()
+ luv.fs_rmdir('CamelCase')
+ end)
if ffi.os == 'Windows' or ffi.os == 'OSX' then
itp('Corrects the case of file names in Mac and Windows', function()
@@ -565,14 +572,14 @@ describe('path.c', function()
local path1 = cstr(100, 'path1')
local to_append = to_cstr('path2')
eq(OK, (cimp.append_path(path1, to_append, 100)))
- eq("path1/path2", (ffi.string(path1)))
+ eq('path1/path2', (ffi.string(path1)))
end)
itp('joins given paths without adding an unnecessary slash', function()
local path1 = cstr(100, 'path1/')
local to_append = to_cstr('path2')
eq(OK, cimp.append_path(path1, to_append, 100))
- eq("path1/path2", (ffi.string(path1)))
+ eq('path1/path2', (ffi.string(path1)))
end)
itp('fails and uses filename if there is not enough space left for to_append', function()
diff --git a/test/unit/preprocess.lua b/test/unit/preprocess.lua
index e356695c14..6294114e1e 100644
--- a/test/unit/preprocess.lua
+++ b/test/unit/preprocess.lua
@@ -1,7 +1,7 @@
-- helps managing loading different headers into the LuaJIT ffi. Untested on
-- windows, will probably need quite a bit of adjustment to run there.
-local ffi = require("ffi")
+local ffi = require('ffi')
local global_helpers = require('test.helpers')
local argss_to_cmd = global_helpers.argss_to_cmd
@@ -12,37 +12,37 @@ local repeated_read_cmd = global_helpers.repeated_read_cmd
--- @type Compiler[]
local ccs = {}
-local env_cc = os.getenv("CC")
+local env_cc = os.getenv('CC')
if env_cc then
- table.insert(ccs, {path = {"/usr/bin/env", env_cc}, type = "gcc"})
+ table.insert(ccs, { path = { '/usr/bin/env', env_cc }, type = 'gcc' })
end
-if ffi.os == "Windows" then
- table.insert(ccs, {path = {"cl"}, type = "msvc"})
+if ffi.os == 'Windows' then
+ table.insert(ccs, { path = { 'cl' }, type = 'msvc' })
end
-table.insert(ccs, {path = {"/usr/bin/env", "cc"}, type = "gcc"})
-table.insert(ccs, {path = {"/usr/bin/env", "gcc"}, type = "gcc"})
-table.insert(ccs, {path = {"/usr/bin/env", "gcc-4.9"}, type = "gcc"})
-table.insert(ccs, {path = {"/usr/bin/env", "gcc-4.8"}, type = "gcc"})
-table.insert(ccs, {path = {"/usr/bin/env", "gcc-4.7"}, type = "gcc"})
-table.insert(ccs, {path = {"/usr/bin/env", "clang"}, type = "clang"})
-table.insert(ccs, {path = {"/usr/bin/env", "icc"}, type = "gcc"})
+table.insert(ccs, { path = { '/usr/bin/env', 'cc' }, type = 'gcc' })
+table.insert(ccs, { path = { '/usr/bin/env', 'gcc' }, type = 'gcc' })
+table.insert(ccs, { path = { '/usr/bin/env', 'gcc-4.9' }, type = 'gcc' })
+table.insert(ccs, { path = { '/usr/bin/env', 'gcc-4.8' }, type = 'gcc' })
+table.insert(ccs, { path = { '/usr/bin/env', 'gcc-4.7' }, type = 'gcc' })
+table.insert(ccs, { path = { '/usr/bin/env', 'clang' }, type = 'clang' })
+table.insert(ccs, { path = { '/usr/bin/env', 'icc' }, type = 'gcc' })
-- parse Makefile format dependencies into a Lua table
--- @param deps string
--- @return string[]
local function parse_make_deps(deps)
-- remove line breaks and line concatenators
- deps = deps:gsub("\n", ""):gsub("\\", "")
+ deps = deps:gsub('\n', ''):gsub('\\', '')
-- remove the Makefile "target:" element
- deps = deps:gsub(".+:", "")
+ deps = deps:gsub('.+:', '')
-- remove redundant spaces
- deps = deps:gsub(" +", " ")
+ deps = deps:gsub(' +', ' ')
-- split according to token (space in this case)
local headers = {} --- @type string[]
- for token in deps:gmatch("[^%s]+") do
+ for token in deps:gmatch('[^%s]+') do
-- headers[token] = true
headers[#headers + 1] = token
end
@@ -50,9 +50,9 @@ local function parse_make_deps(deps)
-- resolve path redirections (..) to normalize all paths
for i, v in ipairs(headers) do
-- double dots (..)
- headers[i] = v:gsub("/[^/%s]+/%.%.", "")
+ headers[i] = v:gsub('/[^/%s]+/%.%.', '')
-- single dot (.)
- headers[i] = v:gsub("%./", "")
+ headers[i] = v:gsub('%./', '')
end
return headers
@@ -80,7 +80,7 @@ local function headerize(headers, global)
formatted[#formatted + 1] = string.format(fmt, hdr)
end
- return table.concat(formatted, "\n")
+ return table.concat(formatted, '\n')
end
--- @class Gcc
@@ -90,8 +90,8 @@ end
--- @field get_declarations_extra_flags string[]
local Gcc = {
preprocessor_extra_flags = {},
- get_defines_extra_flags = {'-std=c99', '-dM', '-E'},
- get_declarations_extra_flags = {'-std=c99', '-P', '-E'},
+ get_defines_extra_flags = { '-std=c99', '-dM', '-E' },
+ get_declarations_extra_flags = { '-std=c99', '-P', '-E' },
}
--- @param name string
@@ -115,13 +115,13 @@ end
function Gcc:init_defines()
-- preprocessor flags that will hopefully make the compiler produce C
-- declarations that the LuaJIT ffi understands.
- self:define('aligned', {'ARGS'}, '')
- self:define('__attribute__', {'ARGS'}, '')
- self:define('__asm', {'ARGS'}, '')
- self:define('__asm__', {'ARGS'}, '')
+ self:define('aligned', { 'ARGS' }, '')
+ self:define('__attribute__', { 'ARGS' }, '')
+ self:define('__asm', { 'ARGS' }, '')
+ self:define('__asm__', { 'ARGS' }, '')
self:define('__inline__', nil, '')
self:define('EXTERN', nil, 'extern')
- self:define('INIT', {'...'}, '')
+ self:define('INIT', { '...' }, '')
self:define('_GNU_SOURCE')
self:define('INCLUDE_GENERATED_DECLARATIONS')
self:define('UNIT_TESTING')
@@ -158,9 +158,9 @@ end
--- @return string[]?
function Gcc:dependencies(hdr)
--- @type string
- local cmd = argss_to_cmd(self.path, {'-M', hdr}) .. ' 2>&1'
+ local cmd = argss_to_cmd(self.path, { '-M', hdr }) .. ' 2>&1'
local out = assert(io.popen(cmd))
- local deps = out:read("*a")
+ local deps = out:read('*a')
out:close()
if deps then
return parse_make_deps(deps)
@@ -174,10 +174,14 @@ function Gcc:filter_standard_defines(defines)
local pseudoheader_fname = 'tmp_empty_pseudoheader.h'
local pseudoheader_file = assert(io.open(pseudoheader_fname, 'w'))
pseudoheader_file:close()
- local standard_defines = assert(repeated_read_cmd(self.path,
- self.preprocessor_extra_flags,
- self.get_defines_extra_flags,
- {pseudoheader_fname}))
+ local standard_defines = assert(
+ repeated_read_cmd(
+ self.path,
+ self.preprocessor_extra_flags,
+ self.get_defines_extra_flags,
+ { pseudoheader_fname }
+ )
+ )
os.remove(pseudoheader_fname)
self.standard_defines = {} --- @type table<string,true>
for line in standard_defines:gmatch('[^\n]+') do
@@ -192,7 +196,7 @@ function Gcc:filter_standard_defines(defines)
end
end
- return table.concat(ret, "\n")
+ return table.concat(ret, '\n')
end
--- returns a stream representing a preprocessed form of the passed-in headers.
@@ -202,24 +206,33 @@ end
--- @return string, string
function Gcc:preprocess(previous_defines, ...)
-- create pseudo-header
- local pseudoheader = headerize({...}, false)
+ local pseudoheader = headerize({ ... }, false)
local pseudoheader_fname = 'tmp_pseudoheader.h'
local pseudoheader_file = assert(io.open(pseudoheader_fname, 'w'))
pseudoheader_file:write(previous_defines)
- pseudoheader_file:write("\n")
+ pseudoheader_file:write('\n')
pseudoheader_file:write(pseudoheader)
pseudoheader_file:flush()
pseudoheader_file:close()
- local defines = assert(repeated_read_cmd(self.path, self.preprocessor_extra_flags,
- self.get_defines_extra_flags,
- {pseudoheader_fname}))
+ local defines = assert(
+ repeated_read_cmd(
+ self.path,
+ self.preprocessor_extra_flags,
+ self.get_defines_extra_flags,
+ { pseudoheader_fname }
+ )
+ )
defines = self:filter_standard_defines(defines)
- local declarations = assert(repeated_read_cmd(self.path,
- self.preprocessor_extra_flags,
- self.get_declarations_extra_flags,
- {pseudoheader_fname}))
+ local declarations = assert(
+ repeated_read_cmd(
+ self.path,
+ self.preprocessor_extra_flags,
+ self.get_declarations_extra_flags,
+ { pseudoheader_fname }
+ )
+ )
os.remove(pseudoheader_fname)
@@ -233,10 +246,10 @@ end
--- @return Gcc?
local function find_best_cc(compilers)
for _, meta in pairs(compilers) do
- local version = assert(io.popen(tostring(meta.path) .. " -v 2>&1"))
+ local version = assert(io.popen(tostring(meta.path) .. ' -v 2>&1'))
version:close()
if version then
- return Gcc:new({path = meta.path})
+ return Gcc:new({ path = meta.path })
end
end
end
diff --git a/test/unit/profile_spec.lua b/test/unit/profile_spec.lua
index 08e5cedbab..011d3632d5 100644
--- a/test/unit/profile_spec.lua
+++ b/test/unit/profile_spec.lua
@@ -10,11 +10,11 @@ local prof = cimport('./src/nvim/profile.h')
local function split(inputstr, sep)
if sep == nil then
- sep = "%s"
+ sep = '%s'
end
local t, i = {}, 1
- for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
+ for str in string.gmatch(inputstr, '([^' .. sep .. ']+)') do
t[i] = str
i = i + 1
end
@@ -23,36 +23,44 @@ local function split(inputstr, sep)
end
local function trim(s)
- local from = s:match"^%s*()"
- return from > #s and "" or s:match(".*%S", from)
+ local from = s:match '^%s*()'
+ return from > #s and '' or s:match('.*%S', from)
end
local function starts(str, start)
- return string.sub(str, 1, string.len(start)) == start
+ return string.sub(str, 1, string.len(start)) == start
end
local function cmp_assert(v1, v2, op, opstr)
local res = op(v1, v2)
if res == false then
- print(string.format("expected: %f %s %f", v1, opstr, v2))
+ print(string.format('expected: %f %s %f', v1, opstr, v2))
end
assert.is_true(res)
end
-local function lt(a, b) -- luacheck: ignore
- cmp_assert(a, b, function(x, y) return x < y end, "<")
+local function lt(a, b) -- luacheck: ignore
+ cmp_assert(a, b, function(x, y)
+ return x < y
+ end, '<')
end
-local function lte(a, b) -- luacheck: ignore
- cmp_assert(a, b, function(x, y) return x <= y end, "<=")
+local function lte(a, b) -- luacheck: ignore
+ cmp_assert(a, b, function(x, y)
+ return x <= y
+ end, '<=')
end
-local function gt(a, b) -- luacheck: ignore
- cmp_assert(a, b, function(x, y) return x > y end, ">")
+local function gt(a, b) -- luacheck: ignore
+ cmp_assert(a, b, function(x, y)
+ return x > y
+ end, '>')
end
local function gte(a, b)
- cmp_assert(a, b, function(x, y) return x >= y end, ">=")
+ cmp_assert(a, b, function(x, y)
+ return x >= y
+ end, '>=')
end
-- missing functions:
@@ -61,21 +69,43 @@ end
-- profile_set_wait
-- profile_sub_wait
describe('profiling related functions', function()
- local function profile_start() return prof.profile_start() end
- local function profile_end(t) return prof.profile_end(t) end
- local function profile_zero() return prof.profile_zero() end
- local function profile_setlimit(ms) return prof.profile_setlimit(ms) end
- local function profile_passed_limit(t) return prof.profile_passed_limit(t) end
- local function profile_add(t1, t2) return prof.profile_add(t1, t2) end
- local function profile_sub(t1, t2) return prof.profile_sub(t1, t2) end
- local function profile_divide(t, cnt) return prof.profile_divide(t, cnt) end
- local function profile_cmp(t1, t2) return prof.profile_cmp(t1, t2) end
- local function profile_equal(t1, t2) return prof.profile_equal(t1, t2) end
- local function profile_msg(t) return ffi.string(prof.profile_msg(t)) end
-
- local function toseconds(t) -- luacheck: ignore
+ local function profile_start()
+ return prof.profile_start()
+ end
+ local function profile_end(t)
+ return prof.profile_end(t)
+ end
+ local function profile_zero()
+ return prof.profile_zero()
+ end
+ local function profile_setlimit(ms)
+ return prof.profile_setlimit(ms)
+ end
+ local function profile_passed_limit(t)
+ return prof.profile_passed_limit(t)
+ end
+ local function profile_add(t1, t2)
+ return prof.profile_add(t1, t2)
+ end
+ local function profile_sub(t1, t2)
+ return prof.profile_sub(t1, t2)
+ end
+ local function profile_divide(t, cnt)
+ return prof.profile_divide(t, cnt)
+ end
+ local function profile_cmp(t1, t2)
+ return prof.profile_cmp(t1, t2)
+ end
+ local function profile_equal(t1, t2)
+ return prof.profile_equal(t1, t2)
+ end
+ local function profile_msg(t)
+ return ffi.string(prof.profile_msg(t))
+ end
+
+ local function toseconds(t) -- luacheck: ignore
local str = trim(profile_msg(t))
- local spl = split(str, ".")
+ local spl = split(str, '.')
local s, us = spl[1], spl[2]
return tonumber(s) + tonumber(us) / 1000000
end
@@ -199,14 +229,14 @@ describe('profiling related functions', function()
describe('profile_msg', function()
itp('prints the zero time as 0.00000', function()
local str = trim(profile_msg(profile_zero()))
- eq(str, "0.000000")
+ eq(str, '0.000000')
end)
itp('prints the time passed, in seconds.microsends', function()
local start = profile_start()
local endt = profile_end(start)
local str = trim(profile_msg(endt))
- local spl = split(str, ".")
+ local spl = split(str, '.')
-- string has two parts (before dot and after dot)
eq(2, #spl)
@@ -215,11 +245,11 @@ describe('profiling related functions', function()
-- zero seconds have passed (if this is not true, either LuaJIT is too
-- slow or the profiling functions are too slow and need to be fixed)
- eq(s, "0")
+ eq(s, '0')
-- more or less the same goes for the microsecond part, if it doesn't
-- start with 0, it's too slow.
- assert.is_true(starts(us, "0"))
+ assert.is_true(starts(us, '0'))
end)
end)
diff --git a/test/unit/rbuffer_spec.lua b/test/unit/rbuffer_spec.lua
index e9104dd5c4..328e5b93da 100644
--- a/test/unit/rbuffer_spec.lua
+++ b/test/unit/rbuffer_spec.lua
@@ -1,4 +1,4 @@
-local helpers = require("test.unit.helpers")(after_each)
+local helpers = require('test.unit.helpers')(after_each)
local itp = helpers.gen_itp(it)
local eq = helpers.eq
@@ -7,7 +7,7 @@ local cstr = helpers.cstr
local to_cstr = helpers.to_cstr
local child_call_once = helpers.child_call_once
-local rbuffer = helpers.cimport("./test/unit/fixtures/rbuffer.h")
+local rbuffer = helpers.cimport('./test/unit/fixtures/rbuffer.h')
describe('rbuffer functions', function()
local capacity = 16
@@ -56,7 +56,7 @@ describe('rbuffer functions', function()
describe('with empty buffer in one contiguous chunk', function()
itp('is called once with the empty chunk', function()
collect_write_chunks()
- eq({'0000000000000000'}, chunks)
+ eq({ '0000000000000000' }, chunks)
end)
end)
@@ -64,7 +64,7 @@ describe('rbuffer functions', function()
itp('is called once with the empty chunk', function()
write('string')
collect_write_chunks()
- eq({'0000000000'}, chunks)
+ eq({ '0000000000' }, chunks)
end)
end)
@@ -81,7 +81,7 @@ describe('rbuffer functions', function()
write('1234567890')
read(8)
collect_write_chunks()
- eq({'000000', '12345678'}, chunks)
+ eq({ '000000', '12345678' }, chunks)
end)
end)
@@ -90,7 +90,7 @@ describe('rbuffer functions', function()
write('12345678')
read(8)
collect_write_chunks()
- eq({'00000000', '12345678'}, chunks)
+ eq({ '00000000', '12345678' }, chunks)
end)
end)
@@ -129,7 +129,7 @@ describe('rbuffer functions', function()
itp('is called once with the filled chunk', function()
write('string')
collect_read_chunks()
- eq({'string'}, chunks)
+ eq({ 'string' }, chunks)
end)
end)
@@ -137,7 +137,7 @@ describe('rbuffer functions', function()
itp('is called once with the filled chunk', function()
write('abcdefghijklmnopq')
collect_read_chunks()
- eq({'abcdefghijklmnop'}, chunks)
+ eq({ 'abcdefghijklmnop' }, chunks)
end)
end)
@@ -147,7 +147,7 @@ describe('rbuffer functions', function()
read(10)
write('long string')
collect_read_chunks()
- eq({'long s', 'tring'}, chunks)
+ eq({ 'long s', 'tring' }, chunks)
end)
end)
@@ -157,7 +157,7 @@ describe('rbuffer functions', function()
read(8)
write('abcdefghijklmnopq')
collect_read_chunks()
- eq({'abcdefgh', 'ijklmnop'}, chunks)
+ eq({ 'abcdefgh', 'ijklmnop' }, chunks)
end)
end)
end)
@@ -167,7 +167,7 @@ describe('rbuffer functions', function()
local function collect_chars()
rbuffer.ut_rbuffer_each(rbuf, function(c, i)
- table.insert(chars, {string.char(c), tonumber(i)})
+ table.insert(chars, { string.char(c), tonumber(i) })
end)
end
before_each(function()
@@ -187,8 +187,19 @@ describe('rbuffer functions', function()
read(10)
write('long string')
collect_chars()
- eq({{'l', 0}, {'o', 1}, {'n', 2}, {'g', 3}, {' ', 4}, {'s', 5},
- {'t', 6}, {'r', 7}, {'i', 8}, {'n', 9}, {'g', 10}}, chars)
+ eq({
+ { 'l', 0 },
+ { 'o', 1 },
+ { 'n', 2 },
+ { 'g', 3 },
+ { ' ', 4 },
+ { 's', 5 },
+ { 't', 6 },
+ { 'r', 7 },
+ { 'i', 8 },
+ { 'n', 9 },
+ { 'g', 10 },
+ }, chars)
end)
end)
end)
@@ -198,7 +209,7 @@ describe('rbuffer functions', function()
local function collect_chars()
rbuffer.ut_rbuffer_each_reverse(rbuf, function(c, i)
- table.insert(chars, {string.char(c), tonumber(i)})
+ table.insert(chars, { string.char(c), tonumber(i) })
end)
end
before_each(function()
@@ -218,8 +229,19 @@ describe('rbuffer functions', function()
read(10)
write('long string')
collect_chars()
- eq({{'g', 10}, {'n', 9}, {'i', 8}, {'r', 7}, {'t', 6}, {'s', 5},
- {' ', 4}, {'g', 3}, {'n', 2}, {'o', 1}, {'l', 0}}, chars)
+ eq({
+ { 'g', 10 },
+ { 'n', 9 },
+ { 'i', 8 },
+ { 'r', 7 },
+ { 't', 6 },
+ { 's', 5 },
+ { ' ', 4 },
+ { 'g', 3 },
+ { 'n', 2 },
+ { 'o', 1 },
+ { 'l', 0 },
+ }, chars)
end)
end)
end)
diff --git a/test/unit/search_spec.lua b/test/unit/search_spec.lua
index be905bf5f0..efe49f974a 100644
--- a/test/unit/search_spec.lua
+++ b/test/unit/search_spec.lua
@@ -1,42 +1,42 @@
-local helpers = require("test.unit.helpers")(after_each)
+local helpers = require('test.unit.helpers')(after_each)
local itp = helpers.gen_itp(it)
local to_cstr = helpers.to_cstr
-local eq = helpers.eq
+local eq = helpers.eq
-local search = helpers.cimport("./src/nvim/search.h")
+local search = helpers.cimport('./src/nvim/search.h')
local globals = helpers.cimport('./src/nvim/globals.h')
local ffi = helpers.ffi
itp('pat_has_uppercase', function()
-- works on empty string
- eq(false, search.pat_has_uppercase(to_cstr("")))
+ eq(false, search.pat_has_uppercase(to_cstr('')))
-- works with utf uppercase
- eq(false, search.pat_has_uppercase(to_cstr("ä")))
- eq(true, search.pat_has_uppercase(to_cstr("Ä")))
- eq(true, search.pat_has_uppercase(to_cstr("äaÅ")))
+ eq(false, search.pat_has_uppercase(to_cstr('ä')))
+ eq(true, search.pat_has_uppercase(to_cstr('Ä')))
+ eq(true, search.pat_has_uppercase(to_cstr('äaÅ')))
-- works when pat ends with backslash
- eq(false, search.pat_has_uppercase(to_cstr("\\")))
- eq(false, search.pat_has_uppercase(to_cstr("ab$\\")))
+ eq(false, search.pat_has_uppercase(to_cstr('\\')))
+ eq(false, search.pat_has_uppercase(to_cstr('ab$\\')))
-- skips escaped characters
- eq(false, search.pat_has_uppercase(to_cstr("\\Ab")))
- eq(true, search.pat_has_uppercase(to_cstr("\\AU")))
+ eq(false, search.pat_has_uppercase(to_cstr('\\Ab')))
+ eq(true, search.pat_has_uppercase(to_cstr('\\AU')))
-- skips _X escaped characters
- eq(false, search.pat_has_uppercase(to_cstr("\\_Ab")))
- eq(true, search.pat_has_uppercase(to_cstr("\\_AU")))
+ eq(false, search.pat_has_uppercase(to_cstr('\\_Ab')))
+ eq(true, search.pat_has_uppercase(to_cstr('\\_AU')))
-- skips %X escaped characters
- eq(false, search.pat_has_uppercase(to_cstr("aa\\%Ab")))
- eq(true, search.pat_has_uppercase(to_cstr("aab\\%AU")))
+ eq(false, search.pat_has_uppercase(to_cstr('aa\\%Ab')))
+ eq(true, search.pat_has_uppercase(to_cstr('aab\\%AU')))
end)
describe('search_regcomp', function()
- local search_regcomp = function(pat, pat_save, pat_use, options )
- local regmatch = ffi.new("regmmatch_T")
+ local search_regcomp = function(pat, pat_save, pat_use, options)
+ local regmatch = ffi.new('regmmatch_T')
local fail = search.search_regcomp(to_cstr(pat), nil, pat_save, pat_use, options, regmatch)
return fail, regmatch
end
@@ -45,13 +45,13 @@ describe('search_regcomp', function()
return helpers.internalize(search.get_search_pat())
end
- itp("accepts regexp pattern with invalid utf", function()
+ itp('accepts regexp pattern with invalid utf', function()
--crafted to call reverse_text with invalid utf
globals.curwin.w_onebuf_opt.wo_rl = 1
globals.curwin.w_onebuf_opt.wo_rlc = to_cstr('s')
globals.cmdmod.cmod_flags = globals.CMOD_KEEPPATTERNS
- local fail = search_regcomp("a\192", 0,0,0)
+ local fail = search_regcomp('a\192', 0, 0, 0)
eq(1, fail)
- eq("\192a", get_search_pat())
+ eq('\192a', get_search_pat())
end)
end)
diff --git a/test/unit/set.lua b/test/unit/set.lua
index 7c30be32aa..f93238cc47 100644
--- a/test/unit/set.lua
+++ b/test/unit/set.lua
@@ -33,7 +33,7 @@ end
--- @return Set
function Set:copy()
- local obj = {nelem = self.nelem, tbl = {}, items = {}} --- @type Set
+ local obj = { nelem = self.nelem, tbl = {}, items = {} } --- @type Set
for k, v in pairs(self.tbl) do
obj.tbl[k] = v
end
@@ -128,13 +128,13 @@ function Set:to_table()
-- there might be gaps in @tbl, so we have to be careful and sort first
local keys = {} --- @type string[]
for idx, _ in pairs(self.tbl) do
- keys[#keys+1] = idx
+ keys[#keys + 1] = idx
end
table.sort(keys)
local copy = {} --- @type string[]
for _, idx in ipairs(keys) do
- copy[#copy+1] = self.tbl[idx]
+ copy[#copy + 1] = self.tbl[idx]
end
return copy
end
diff --git a/test/unit/statusline_spec.lua b/test/unit/statusline_spec.lua
index a124a588e9..c8dc4f84e3 100644
--- a/test/unit/statusline_spec.lua
+++ b/test/unit/statusline_spec.lua
@@ -1,14 +1,14 @@
-local helpers = require("test.unit.helpers")(after_each)
+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 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")
+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
@@ -22,23 +22,25 @@ describe('build_stl_str_hl', function()
-- .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))
+ 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)
+ 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
@@ -54,12 +56,7 @@ describe('build_stl_str_hl', function()
-- .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)
-
+ 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 {}
@@ -75,9 +72,11 @@ describe('build_stl_str_hl', function()
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}
+ 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)
@@ -85,198 +84,383 @@ describe('build_stl_str_hl', function()
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')
+ 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})
+ 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})
+ 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})
+ 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})
+ 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 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 `<` 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 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)
+ 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)
+ 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)
+ 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)
+ 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 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 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 %=',
+ 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 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,
+ 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')
+ '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,
+ 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,
+ ' '
+ ) -- 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,
+ '<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
+ '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()})
+ 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/strings_spec.lua b/test/unit/strings_spec.lua
index 6d7aceb4b2..eea669c964 100644
--- a/test/unit/strings_spec.lua
+++ b/test/unit/strings_spec.lua
@@ -1,4 +1,4 @@
-local helpers = require("test.unit.helpers")(after_each)
+local helpers = require('test.unit.helpers')(after_each)
local itp = helpers.gen_itp(it)
local cimport = helpers.cimport
@@ -6,8 +6,7 @@ local eq = helpers.eq
local ffi = helpers.ffi
local to_cstr = helpers.to_cstr
-local strings = cimport('stdlib.h', './src/nvim/strings.h',
- './src/nvim/memory.h')
+local strings = cimport('stdlib.h', './src/nvim/strings.h', './src/nvim/memory.h')
describe('vim_strsave_escaped()', function()
local vim_strsave_escaped = function(s, chars)
@@ -21,19 +20,19 @@ describe('vim_strsave_escaped()', function()
end
itp('precedes by a backslash all chars from second argument', function()
- eq([[\a\b\c\d]], vim_strsave_escaped('abcd','abcd'))
+ eq([[\a\b\c\d]], vim_strsave_escaped('abcd', 'abcd'))
end)
itp('precedes by a backslash chars only from second argument', function()
- eq([[\a\bcd]], vim_strsave_escaped('abcd','ab'))
+ eq([[\a\bcd]], vim_strsave_escaped('abcd', 'ab'))
end)
itp('returns a copy of passed string if second argument is empty', function()
- eq('text \n text', vim_strsave_escaped('text \n text',''))
+ eq('text \n text', vim_strsave_escaped('text \n text', ''))
end)
itp('returns an empty string if first argument is empty string', function()
- eq('', vim_strsave_escaped('','\r'))
+ eq('', vim_strsave_escaped('', '\r'))
end)
itp('returns a copy of passed string if it does not contain chars from 2nd argument', function()
@@ -148,14 +147,30 @@ describe('vim_snprintf()', function()
end
end
- local function i(n) return ffi.cast('int', n) end
- local function l(n) return ffi.cast('long', n) end
- local function ll(n) return ffi.cast('long long', n) end
- local function z(n) return ffi.cast('ptrdiff_t', n) end
- local function u(n) return ffi.cast('unsigned', n) end
- local function ul(n) return ffi.cast('unsigned long', n) end
- local function ull(n) return ffi.cast('unsigned long long', n) end
- local function uz(n) return ffi.cast('size_t', n) end
+ local function i(n)
+ return ffi.cast('int', n)
+ end
+ local function l(n)
+ return ffi.cast('long', n)
+ end
+ local function ll(n)
+ return ffi.cast('long long', n)
+ end
+ local function z(n)
+ return ffi.cast('ptrdiff_t', n)
+ end
+ local function u(n)
+ return ffi.cast('unsigned', n)
+ end
+ local function ul(n)
+ return ffi.cast('unsigned long', n)
+ end
+ local function ull(n)
+ return ffi.cast('unsigned long long', n)
+ end
+ local function uz(n)
+ return ffi.cast('size_t', n)
+ end
itp('truncation', function()
for bsize = 0, 14 do
@@ -232,49 +247,51 @@ describe('vim_snprintf()', function()
end)
end)
-describe('strcase_save()' , function()
+describe('strcase_save()', function()
local strcase_save = function(input_string, upper)
local res = strings.strcase_save(to_cstr(input_string), upper)
return ffi.string(res)
end
itp('decodes overlong encoded characters.', function()
- eq("A", strcase_save("\xc1\x81", true))
- eq("a", strcase_save("\xc1\x81", false))
+ eq('A', strcase_save('\xc1\x81', true))
+ eq('a', strcase_save('\xc1\x81', false))
end)
end)
-describe("reverse_text", function()
+describe('reverse_text', function()
local reverse_text = function(str)
return helpers.internalize(strings.reverse_text(to_cstr(str)))
end
- itp("handles empty string", function()
- eq("", reverse_text(""))
+ itp('handles empty string', function()
+ eq('', reverse_text(''))
end)
- itp("handles simple cases", function()
- eq("a", reverse_text("a"))
- eq("ba", reverse_text("ab"))
+ itp('handles simple cases', function()
+ eq('a', reverse_text('a'))
+ eq('ba', reverse_text('ab'))
end)
- itp("handles multibyte characters", function()
- eq("bα", reverse_text("αb"))
- eq("Yötön yö", reverse_text("öy nötöY"))
+ itp('handles multibyte characters', function()
+ eq('bα', reverse_text('αb'))
+ eq('Yötön yö', reverse_text('öy nötöY'))
end)
- itp("handles combining chars", function()
- local utf8_COMBINING_RING_ABOVE = "\204\138"
- local utf8_COMBINING_RING_BELOW = "\204\165"
- eq("bba" .. utf8_COMBINING_RING_ABOVE .. utf8_COMBINING_RING_BELOW .. "aa",
- reverse_text("aaa" .. utf8_COMBINING_RING_ABOVE .. utf8_COMBINING_RING_BELOW .. "bb"))
+ itp('handles combining chars', function()
+ local utf8_COMBINING_RING_ABOVE = '\204\138'
+ local utf8_COMBINING_RING_BELOW = '\204\165'
+ eq(
+ 'bba' .. utf8_COMBINING_RING_ABOVE .. utf8_COMBINING_RING_BELOW .. 'aa',
+ reverse_text('aaa' .. utf8_COMBINING_RING_ABOVE .. utf8_COMBINING_RING_BELOW .. 'bb')
+ )
end)
- itp("treats invalid utf as separate characters", function()
- eq("\192ba", reverse_text("ab\192"))
+ itp('treats invalid utf as separate characters', function()
+ eq('\192ba', reverse_text('ab\192'))
end)
- itp("treats an incomplete utf continuation sequence as valid", function()
- eq("\194ba", reverse_text("ab\194"))
+ itp('treats an incomplete utf continuation sequence as valid', function()
+ eq('\194ba', reverse_text('ab\194'))
end)
end)
diff --git a/test/unit/undo_spec.lua b/test/unit/undo_spec.lua
index ee4203b94c..220a4733df 100644
--- a/test/unit/undo_spec.lua
+++ b/test/unit/undo_spec.lua
@@ -23,7 +23,7 @@ local buffer_hash = nil
child_call_once(function()
if old_p_udir == nil then
- old_p_udir = options.p_udir -- save the old value of p_udir (undodir)
+ old_p_udir = options.p_udir -- save the old value of p_udir (undodir)
end
-- create a new buffer
@@ -39,21 +39,20 @@ child_call_once(function()
undo.u_compute_hash(file_buffer, buffer_hash)
end)
-
describe('u_write_undo', function()
setup(function()
mkdir('unit-test-directory')
luv.chdir('unit-test-directory')
- options.p_udir = to_cstr(luv.cwd()) -- set p_udir to be the test dir
+ options.p_udir = to_cstr(luv.cwd()) -- set p_udir to be the test dir
end)
teardown(function()
luv.chdir('..')
local success, err = luv.fs_rmdir('unit-test-directory')
if not success then
- print(err) -- inform tester if directory fails to delete
+ print(err) -- inform tester if directory fails to delete
end
- options.p_udir = old_p_udir --restore old p_udir
+ options.p_udir = old_p_udir --restore old p_udir
end)
-- Lua wrapper for u_write_undo
@@ -68,24 +67,24 @@ describe('u_write_undo', function()
itp('writes an undo file to undodir given a buffer and hash', function()
u_write_undo(nil, false, file_buffer, buffer_hash)
local correct_name = ffi.string(undo.u_get_undo_file_name(file_buffer.b_ffname, false))
- local undo_file = io.open(correct_name, "r")
+ local undo_file = io.open(correct_name, 'r')
neq(undo_file, nil)
- local success, err = os.remove(correct_name) -- delete the file now that we're done with it.
+ local success, err = os.remove(correct_name) -- delete the file now that we're done with it.
if not success then
- print(err) -- inform tester if undofile fails to delete
+ print(err) -- inform tester if undofile fails to delete
end
end)
itp('writes a correctly-named undo file to undodir given a name, buffer, and hash', function()
- local correct_name = "undofile.test"
+ local correct_name = 'undofile.test'
u_write_undo(correct_name, false, file_buffer, buffer_hash)
- local undo_file = io.open(correct_name, "r")
+ local undo_file = io.open(correct_name, 'r')
neq(undo_file, nil)
- local success, err = os.remove(correct_name) -- delete the file now that we're done with it.
+ local success, err = os.remove(correct_name) -- delete the file now that we're done with it.
if not success then
- print(err) -- inform tester if undofile fails to delete
+ print(err) -- inform tester if undofile fails to delete
end
end)
@@ -96,9 +95,9 @@ describe('u_write_undo', function()
itp('writes the undofile with the same permissions as the original file', function()
-- Create Test file and set permissions
- local test_file_name = "./test.file"
- local test_permission_file = io.open(test_file_name, "w")
- test_permission_file:write("testing permissions")
+ local test_file_name = './test.file'
+ local test_permission_file = io.open(test_file_name, 'w')
+ test_permission_file:write('testing permissions')
test_permission_file:close()
local test_permissions = luv.fs_stat(test_file_name).mode
@@ -119,17 +118,17 @@ describe('u_write_undo', function()
-- delete the file now that we're done with it.
local success, err = os.remove(test_file_name)
if not success then
- print(err) -- inform tester if undofile fails to delete
+ print(err) -- inform tester if undofile fails to delete
end
success, err = os.remove(undo_file_name)
if not success then
- print(err) -- inform tester if undofile fails to delete
+ print(err) -- inform tester if undofile fails to delete
end
end)
itp('writes an undofile only readable by the user if the buffer is unnamed', function()
local correct_permissions = 33152
- local undo_file_name = "test.undo"
+ local undo_file_name = 'test.undo'
-- Create vim buffer
file_buffer = buffer.buflist_new(nil, nil, 1, buffer.BLN_LISTED)
@@ -144,12 +143,12 @@ describe('u_write_undo', function()
-- delete the file now that we're done with it.
local success, err = os.remove(undo_file_name)
if not success then
- print(err) -- inform tester if undofile fails to delete
+ print(err) -- inform tester if undofile fails to delete
end
end)
itp('forces writing undo file for :wundo! command', function()
- local file_contents = "testing permissions"
+ local file_contents = 'testing permissions'
-- Write a text file where the undofile should go
local correct_name = ffi.string(undo.u_get_undo_file_name(file_buffer.b_ffname, false))
helpers.write_file(correct_name, file_contents, true, false)
@@ -160,9 +159,9 @@ describe('u_write_undo', function()
local undo_file_contents = helpers.read_file(correct_name)
neq(file_contents, undo_file_contents)
- local success, deletion_err = os.remove(correct_name) -- delete the file now that we're done with it.
+ local success, deletion_err = os.remove(correct_name) -- delete the file now that we're done with it.
if not success then
- print(deletion_err) -- inform tester if undofile fails to delete
+ print(deletion_err) -- inform tester if undofile fails to delete
end
end)
@@ -172,17 +171,17 @@ describe('u_write_undo', function()
local file_last_modified = luv.fs_stat(correct_name).mtime.sec
- sleep(1000) -- Ensure difference in timestamps.
- file_buffer.b_u_numhead = 1 -- Mark it as if there are changes
+ sleep(1000) -- Ensure difference in timestamps.
+ file_buffer.b_u_numhead = 1 -- Mark it as if there are changes
u_write_undo(nil, false, file_buffer, buffer_hash)
local file_last_modified_2 = luv.fs_stat(correct_name).mtime.sec
-- print(file_last_modified, file_last_modified_2)
neq(file_last_modified, file_last_modified_2)
- local success, err = os.remove(correct_name) -- delete the file now that we're done with it.
+ local success, err = os.remove(correct_name) -- delete the file now that we're done with it.
if not success then
- print(err) -- inform tester if undofile fails to delete
+ print(err) -- inform tester if undofile fails to delete
end
end)
@@ -195,16 +194,16 @@ describe('u_write_undo', function()
end)
itp('does not write an undo file if there is no undo information for the buffer', function()
- file_buffer.b_u_numhead = 0 -- Mark it as if there is no undo information
+ file_buffer.b_u_numhead = 0 -- Mark it as if there is no undo information
local correct_name = ffi.string(undo.u_get_undo_file_name(file_buffer.b_ffname, false))
- local existing_file = io.open(correct_name,"r")
+ local existing_file = io.open(correct_name, 'r')
if existing_file then
existing_file:close()
os.remove(correct_name)
end
u_write_undo(nil, false, file_buffer, buffer_hash)
- local undo_file = io.open(correct_name, "r")
+ local undo_file = io.open(correct_name, 'r')
eq(undo_file, nil)
end)
diff --git a/test/unit/viml/expressions/lexer_spec.lua b/test/unit/viml/expressions/lexer_spec.lua
index 358e858d61..96052a5ce1 100644
--- a/test/unit/viml/expressions/lexer_spec.lua
+++ b/test/unit/viml/expressions/lexer_spec.lua
@@ -83,24 +83,23 @@ local function eltkn2lua(pstate, tkn)
type = conv_eltkn_type(tkn.type),
}
pstate_set_str(pstate, tkn.start, tkn.len, ret)
- if not ret.error and (#(ret.str) ~= ret.len) then
+ if not ret.error and (#ret.str ~= ret.len) then
ret.error = '#str /= len'
end
if ret.type == 'Comparison' then
ret.data = {
type = conv_cmp_type(tkn.data.cmp.type),
ccs = conv_ccs(tkn.data.cmp.ccs),
- inv = (not not tkn.data.cmp.inv),
+ inv = not not tkn.data.cmp.inv,
}
elseif ret.type == 'Multiplication' then
ret.data = { type = conv_enum(eltkn_mul_type_tab, tkn.data.mul.type) }
elseif bracket_types[ret.type] then
- ret.data = { closing = (not not tkn.data.brc.closing) }
+ ret.data = { closing = not not tkn.data.brc.closing }
elseif ret.type == 'Register' then
ret.data = { name = intchar2lua(tkn.data.reg.name) }
- elseif (ret.type == 'SingleQuotedString'
- or ret.type == 'DoubleQuotedString') then
- ret.data = { closed = (not not tkn.data.str.closed) }
+ elseif ret.type == 'SingleQuotedString' or ret.type == 'DoubleQuotedString' then
+ ret.data = { closed = not not tkn.data.str.closed }
elseif ret.type == 'Option' then
ret.data = {
scope = conv_enum(eltkn_opt_scope_tab, tkn.data.opt.scope),
@@ -109,16 +108,15 @@ local function eltkn2lua(pstate, tkn)
elseif ret.type == 'PlainIdentifier' then
ret.data = {
scope = intchar2lua(tkn.data.var.scope),
- autoload = (not not tkn.data.var.autoload),
+ autoload = not not tkn.data.var.autoload,
}
elseif ret.type == 'Number' then
ret.data = {
- is_float = (not not tkn.data.num.is_float),
+ is_float = not not tkn.data.num.is_float,
base = tonumber(tkn.data.num.base),
}
- ret.data.val = tonumber(tkn.data.num.is_float
- and tkn.data.num.val.floating
- or tkn.data.num.val.integer)
+ ret.data.val =
+ tonumber(tkn.data.num.is_float and tkn.data.num.val.floating or tkn.data.num.val.integer)
elseif ret.type == 'Assignment' then
ret.data = { type = conv_expr_asgn_type(tkn.data.ass.type) }
elseif ret.type == 'Invalid' then
@@ -150,156 +148,263 @@ describe('Expressions lexer', function()
end
end
local function singl_eltkn_test(typ, str, data)
- local pstate = new_pstate({str})
- eq({data=data, len=#str, start={col=0, line=0}, str=str, type=typ},
- next_eltkn(pstate, flags))
+ local pstate = new_pstate({ str })
+ eq(
+ { data = data, len = #str, start = { col = 0, line = 0 }, str = str, type = typ },
+ next_eltkn(pstate, flags)
+ )
check_advance(pstate, #str, 0)
- if not (
+ if
+ not (
typ == 'Spacing'
or (typ == 'Register' and str == '@')
- or ((typ == 'SingleQuotedString' or typ == 'DoubleQuotedString')
- and not data.closed)
- ) then
- pstate = new_pstate({str .. ' '})
- eq({data=data, len=#str, start={col=0, line=0}, str=str, type=typ},
- next_eltkn(pstate, flags))
+ or ((typ == 'SingleQuotedString' or typ == 'DoubleQuotedString') and not data.closed)
+ )
+ then
+ pstate = new_pstate({ str .. ' ' })
+ eq(
+ { data = data, len = #str, start = { col = 0, line = 0 }, str = str, type = typ },
+ next_eltkn(pstate, flags)
+ )
check_advance(pstate, #str, 0)
end
- pstate = new_pstate({'x' .. str})
+ pstate = new_pstate({ 'x' .. str })
pstate.pos.col = 1
- eq({data=data, len=#str, start={col=1, line=0}, str=str, type=typ},
- next_eltkn(pstate, flags))
+ eq(
+ { data = data, len = #str, start = { col = 1, line = 0 }, str = str, type = typ },
+ next_eltkn(pstate, flags)
+ )
check_advance(pstate, #str, 1)
end
local function scope_test(scope)
- singl_eltkn_test('PlainIdentifier', scope .. ':test#var', {autoload=true, scope=scope})
- singl_eltkn_test('PlainIdentifier', scope .. ':', {autoload=false, scope=scope})
+ singl_eltkn_test('PlainIdentifier', scope .. ':test#var', { autoload = true, scope = scope })
+ singl_eltkn_test('PlainIdentifier', scope .. ':', { autoload = false, scope = scope })
end
local function comparison_test(op, inv_op, cmp_type)
- singl_eltkn_test('Comparison', op, {type=cmp_type, inv=false, ccs='UseOption'})
- singl_eltkn_test('Comparison', inv_op, {type=cmp_type, inv=true, ccs='UseOption'})
- singl_eltkn_test('Comparison', op .. '#', {type=cmp_type, inv=false, ccs='MatchCase'})
- singl_eltkn_test('Comparison', inv_op .. '#', {type=cmp_type, inv=true, ccs='MatchCase'})
- singl_eltkn_test('Comparison', op .. '?', {type=cmp_type, inv=false, ccs='IgnoreCase'})
- singl_eltkn_test('Comparison', inv_op .. '?', {type=cmp_type, inv=true, ccs='IgnoreCase'})
+ singl_eltkn_test('Comparison', op, { type = cmp_type, inv = false, ccs = 'UseOption' })
+ singl_eltkn_test('Comparison', inv_op, { type = cmp_type, inv = true, ccs = 'UseOption' })
+ singl_eltkn_test('Comparison', op .. '#', { type = cmp_type, inv = false, ccs = 'MatchCase' })
+ singl_eltkn_test(
+ 'Comparison',
+ inv_op .. '#',
+ { type = cmp_type, inv = true, ccs = 'MatchCase' }
+ )
+ singl_eltkn_test('Comparison', op .. '?', { type = cmp_type, inv = false, ccs = 'IgnoreCase' })
+ singl_eltkn_test(
+ 'Comparison',
+ inv_op .. '?',
+ { type = cmp_type, inv = true, ccs = 'IgnoreCase' }
+ )
end
local function simple_test(pstate_arg, exp_type, exp_len, exp)
local pstate = new_pstate(pstate_arg)
exp = shallowcopy(exp)
exp.type = exp_type
- exp.len = exp_len or #(pstate_arg[0])
+ exp.len = exp_len or #pstate_arg[0]
exp.start = { col = 0, line = 0 }
eq(exp, next_eltkn(pstate, flags))
end
local function stable_tests()
- singl_eltkn_test('Parenthesis', '(', {closing=false})
- singl_eltkn_test('Parenthesis', ')', {closing=true})
- singl_eltkn_test('Bracket', '[', {closing=false})
- singl_eltkn_test('Bracket', ']', {closing=true})
- singl_eltkn_test('FigureBrace', '{', {closing=false})
- singl_eltkn_test('FigureBrace', '}', {closing=true})
+ singl_eltkn_test('Parenthesis', '(', { closing = false })
+ singl_eltkn_test('Parenthesis', ')', { closing = true })
+ singl_eltkn_test('Bracket', '[', { closing = false })
+ singl_eltkn_test('Bracket', ']', { closing = true })
+ singl_eltkn_test('FigureBrace', '{', { closing = false })
+ singl_eltkn_test('FigureBrace', '}', { closing = true })
singl_eltkn_test('Question', '?')
singl_eltkn_test('Colon', ':')
singl_eltkn_test('Dot', '.')
- singl_eltkn_test('Assignment', '.=', {type='Concat'})
+ singl_eltkn_test('Assignment', '.=', { type = 'Concat' })
singl_eltkn_test('Plus', '+')
- singl_eltkn_test('Assignment', '+=', {type='Add'})
+ singl_eltkn_test('Assignment', '+=', { type = 'Add' })
singl_eltkn_test('Comma', ',')
- singl_eltkn_test('Multiplication', '*', {type='Mul'})
- singl_eltkn_test('Multiplication', '/', {type='Div'})
- singl_eltkn_test('Multiplication', '%', {type='Mod'})
+ singl_eltkn_test('Multiplication', '*', { type = 'Mul' })
+ singl_eltkn_test('Multiplication', '/', { type = 'Div' })
+ singl_eltkn_test('Multiplication', '%', { type = 'Mod' })
singl_eltkn_test('Spacing', ' \t\t \t\t')
singl_eltkn_test('Spacing', ' ')
singl_eltkn_test('Spacing', '\t')
- singl_eltkn_test('Invalid', '\x01\x02\x03', {error='E15: Invalid control character present in input: %.*s'})
- singl_eltkn_test('Number', '0123', {is_float=false, base=8, val=83})
- singl_eltkn_test('Number', '01234567', {is_float=false, base=8, val=342391})
- singl_eltkn_test('Number', '012345678', {is_float=false, base=10, val=12345678})
- singl_eltkn_test('Number', '0x123', {is_float=false, base=16, val=291})
- singl_eltkn_test('Number', '0x56FF', {is_float=false, base=16, val=22271})
- singl_eltkn_test('Number', '0xabcdef', {is_float=false, base=16, val=11259375})
- singl_eltkn_test('Number', '0xABCDEF', {is_float=false, base=16, val=11259375})
- singl_eltkn_test('Number', '0x0', {is_float=false, base=16, val=0})
- singl_eltkn_test('Number', '00', {is_float=false, base=8, val=0})
- singl_eltkn_test('Number', '0b0', {is_float=false, base=2, val=0})
- singl_eltkn_test('Number', '0b010111', {is_float=false, base=2, val=23})
- singl_eltkn_test('Number', '0b100111', {is_float=false, base=2, val=39})
- singl_eltkn_test('Number', '0', {is_float=false, base=10, val=0})
- singl_eltkn_test('Number', '9', {is_float=false, base=10, val=9})
+ singl_eltkn_test(
+ 'Invalid',
+ '\x01\x02\x03',
+ { error = 'E15: Invalid control character present in input: %.*s' }
+ )
+ singl_eltkn_test('Number', '0123', { is_float = false, base = 8, val = 83 })
+ singl_eltkn_test('Number', '01234567', { is_float = false, base = 8, val = 342391 })
+ singl_eltkn_test('Number', '012345678', { is_float = false, base = 10, val = 12345678 })
+ singl_eltkn_test('Number', '0x123', { is_float = false, base = 16, val = 291 })
+ singl_eltkn_test('Number', '0x56FF', { is_float = false, base = 16, val = 22271 })
+ singl_eltkn_test('Number', '0xabcdef', { is_float = false, base = 16, val = 11259375 })
+ singl_eltkn_test('Number', '0xABCDEF', { is_float = false, base = 16, val = 11259375 })
+ singl_eltkn_test('Number', '0x0', { is_float = false, base = 16, val = 0 })
+ singl_eltkn_test('Number', '00', { is_float = false, base = 8, val = 0 })
+ singl_eltkn_test('Number', '0b0', { is_float = false, base = 2, val = 0 })
+ singl_eltkn_test('Number', '0b010111', { is_float = false, base = 2, val = 23 })
+ singl_eltkn_test('Number', '0b100111', { is_float = false, base = 2, val = 39 })
+ singl_eltkn_test('Number', '0', { is_float = false, base = 10, val = 0 })
+ singl_eltkn_test('Number', '9', { is_float = false, base = 10, val = 9 })
singl_eltkn_test('Env', '$abc')
singl_eltkn_test('Env', '$')
- singl_eltkn_test('PlainIdentifier', 'test', {autoload=false, scope=0})
- singl_eltkn_test('PlainIdentifier', '_test', {autoload=false, scope=0})
- singl_eltkn_test('PlainIdentifier', '_test_foo', {autoload=false, scope=0})
- singl_eltkn_test('PlainIdentifier', 't', {autoload=false, scope=0})
- singl_eltkn_test('PlainIdentifier', 'test5', {autoload=false, scope=0})
- singl_eltkn_test('PlainIdentifier', 't0', {autoload=false, scope=0})
- singl_eltkn_test('PlainIdentifier', 'test#var', {autoload=true, scope=0})
- singl_eltkn_test('PlainIdentifier', 'test#var#val###', {autoload=true, scope=0})
- singl_eltkn_test('PlainIdentifier', 't#####', {autoload=true, scope=0})
+ singl_eltkn_test('PlainIdentifier', 'test', { autoload = false, scope = 0 })
+ singl_eltkn_test('PlainIdentifier', '_test', { autoload = false, scope = 0 })
+ singl_eltkn_test('PlainIdentifier', '_test_foo', { autoload = false, scope = 0 })
+ singl_eltkn_test('PlainIdentifier', 't', { autoload = false, scope = 0 })
+ singl_eltkn_test('PlainIdentifier', 'test5', { autoload = false, scope = 0 })
+ singl_eltkn_test('PlainIdentifier', 't0', { autoload = false, scope = 0 })
+ singl_eltkn_test('PlainIdentifier', 'test#var', { autoload = true, scope = 0 })
+ singl_eltkn_test('PlainIdentifier', 'test#var#val###', { autoload = true, scope = 0 })
+ singl_eltkn_test('PlainIdentifier', 't#####', { autoload = true, scope = 0 })
singl_eltkn_test('And', '&&')
singl_eltkn_test('Or', '||')
- singl_eltkn_test('Invalid', '&', {error='E112: Option name missing: %.*s'})
- singl_eltkn_test('Option', '&opt', {scope='Unspecified', name='opt'})
- singl_eltkn_test('Option', '&t_xx', {scope='Unspecified', name='t_xx'})
- singl_eltkn_test('Option', '&t_\r\r', {scope='Unspecified', name='t_\r\r'})
- singl_eltkn_test('Option', '&t_\t\t', {scope='Unspecified', name='t_\t\t'})
- singl_eltkn_test('Option', '&t_ ', {scope='Unspecified', name='t_ '})
- singl_eltkn_test('Option', '&g:opt', {scope='Global', name='opt'})
- singl_eltkn_test('Option', '&l:opt', {scope='Local', name='opt'})
- singl_eltkn_test('Invalid', '&l:', {error='E112: Option name missing: %.*s'})
- singl_eltkn_test('Invalid', '&g:', {error='E112: Option name missing: %.*s'})
- singl_eltkn_test('Register', '@', {name=-1})
- singl_eltkn_test('Register', '@a', {name='a'})
- singl_eltkn_test('Register', '@\r', {name=13})
- singl_eltkn_test('Register', '@ ', {name=' '})
- singl_eltkn_test('Register', '@\t', {name=9})
- singl_eltkn_test('SingleQuotedString', '\'test', {closed=false})
- singl_eltkn_test('SingleQuotedString', '\'test\'', {closed=true})
- singl_eltkn_test('SingleQuotedString', '\'\'\'\'', {closed=true})
- singl_eltkn_test('SingleQuotedString', '\'x\'\'\'', {closed=true})
- singl_eltkn_test('SingleQuotedString', '\'\'\'x\'', {closed=true})
- singl_eltkn_test('SingleQuotedString', '\'\'\'', {closed=false})
- singl_eltkn_test('SingleQuotedString', '\'x\'\'', {closed=false})
- singl_eltkn_test('SingleQuotedString', '\'\'\'x', {closed=false})
- singl_eltkn_test('DoubleQuotedString', '"test', {closed=false})
- singl_eltkn_test('DoubleQuotedString', '"test"', {closed=true})
- singl_eltkn_test('DoubleQuotedString', '"\\""', {closed=true})
- singl_eltkn_test('DoubleQuotedString', '"x\\""', {closed=true})
- singl_eltkn_test('DoubleQuotedString', '"\\"x"', {closed=true})
- singl_eltkn_test('DoubleQuotedString', '"\\"', {closed=false})
- singl_eltkn_test('DoubleQuotedString', '"x\\"', {closed=false})
- singl_eltkn_test('DoubleQuotedString', '"\\"x', {closed=false})
+ singl_eltkn_test('Invalid', '&', { error = 'E112: Option name missing: %.*s' })
+ singl_eltkn_test('Option', '&opt', { scope = 'Unspecified', name = 'opt' })
+ singl_eltkn_test('Option', '&t_xx', { scope = 'Unspecified', name = 't_xx' })
+ singl_eltkn_test('Option', '&t_\r\r', { scope = 'Unspecified', name = 't_\r\r' })
+ singl_eltkn_test('Option', '&t_\t\t', { scope = 'Unspecified', name = 't_\t\t' })
+ singl_eltkn_test('Option', '&t_ ', { scope = 'Unspecified', name = 't_ ' })
+ singl_eltkn_test('Option', '&g:opt', { scope = 'Global', name = 'opt' })
+ singl_eltkn_test('Option', '&l:opt', { scope = 'Local', name = 'opt' })
+ singl_eltkn_test('Invalid', '&l:', { error = 'E112: Option name missing: %.*s' })
+ singl_eltkn_test('Invalid', '&g:', { error = 'E112: Option name missing: %.*s' })
+ singl_eltkn_test('Register', '@', { name = -1 })
+ singl_eltkn_test('Register', '@a', { name = 'a' })
+ singl_eltkn_test('Register', '@\r', { name = 13 })
+ singl_eltkn_test('Register', '@ ', { name = ' ' })
+ singl_eltkn_test('Register', '@\t', { name = 9 })
+ singl_eltkn_test('SingleQuotedString', "'test", { closed = false })
+ singl_eltkn_test('SingleQuotedString', "'test'", { closed = true })
+ singl_eltkn_test('SingleQuotedString', "''''", { closed = true })
+ singl_eltkn_test('SingleQuotedString', "'x'''", { closed = true })
+ singl_eltkn_test('SingleQuotedString', "'''x'", { closed = true })
+ singl_eltkn_test('SingleQuotedString', "'''", { closed = false })
+ singl_eltkn_test('SingleQuotedString', "'x''", { closed = false })
+ singl_eltkn_test('SingleQuotedString', "'''x", { closed = false })
+ singl_eltkn_test('DoubleQuotedString', '"test', { closed = false })
+ singl_eltkn_test('DoubleQuotedString', '"test"', { closed = true })
+ singl_eltkn_test('DoubleQuotedString', '"\\""', { closed = true })
+ singl_eltkn_test('DoubleQuotedString', '"x\\""', { closed = true })
+ singl_eltkn_test('DoubleQuotedString', '"\\"x"', { closed = true })
+ singl_eltkn_test('DoubleQuotedString', '"\\"', { closed = false })
+ singl_eltkn_test('DoubleQuotedString', '"x\\"', { closed = false })
+ singl_eltkn_test('DoubleQuotedString', '"\\"x', { closed = false })
singl_eltkn_test('Not', '!')
- singl_eltkn_test('Assignment', '=', {type='Plain'})
+ singl_eltkn_test('Assignment', '=', { type = 'Plain' })
comparison_test('==', '!=', 'Equal')
comparison_test('=~', '!~', 'Matches')
comparison_test('>', '<=', 'Greater')
comparison_test('>=', '<', 'GreaterOrEqual')
singl_eltkn_test('Minus', '-')
- singl_eltkn_test('Assignment', '-=', {type='Subtract'})
+ singl_eltkn_test('Assignment', '-=', { type = 'Subtract' })
singl_eltkn_test('Arrow', '->')
- singl_eltkn_test('Invalid', '~', {error='E15: Unidentified character: %.*s'})
- simple_test({{data=nil, size=0}}, 'EOC', 0, {error='start.col >= #pstr'})
- simple_test({''}, 'EOC', 0, {error='start.col >= #pstr'})
- simple_test({'2.'}, 'Number', 1, {data={is_float=false, base=10, val=2}, str='2'})
- simple_test({'2e5'}, 'Number', 1, {data={is_float=false, base=10, val=2}, str='2'})
- simple_test({'2.x'}, 'Number', 1, {data={is_float=false, base=10, val=2}, str='2'})
- simple_test({'2.2.'}, 'Number', 1, {data={is_float=false, base=10, val=2}, str='2'})
- simple_test({'2.0x'}, 'Number', 1, {data={is_float=false, base=10, val=2}, str='2'})
- simple_test({'2.0e'}, 'Number', 1, {data={is_float=false, base=10, val=2}, str='2'})
- simple_test({'2.0e+'}, 'Number', 1, {data={is_float=false, base=10, val=2}, str='2'})
- simple_test({'2.0e-'}, 'Number', 1, {data={is_float=false, base=10, val=2}, str='2'})
- simple_test({'2.0e+x'}, 'Number', 1, {data={is_float=false, base=10, val=2}, str='2'})
- simple_test({'2.0e-x'}, 'Number', 1, {data={is_float=false, base=10, val=2}, str='2'})
- simple_test({'2.0e+1a'}, 'Number', 1, {data={is_float=false, base=10, val=2}, str='2'})
- simple_test({'2.0e-1a'}, 'Number', 1, {data={is_float=false, base=10, val=2}, str='2'})
- simple_test({'0b102'}, 'Number', 4, {data={is_float=false, base=2, val=2}, str='0b10'})
- simple_test({'10F'}, 'Number', 2, {data={is_float=false, base=10, val=10}, str='10'})
- simple_test({'0x0123456789ABCDEFG'}, 'Number', 18, {data={is_float=false, base=16, val=81985529216486895}, str='0x0123456789ABCDEF'})
- simple_test({{data='00', size=2}}, 'Number', 2, {data={is_float=false, base=8, val=0}, str='00'})
- simple_test({{data='009', size=2}}, 'Number', 2, {data={is_float=false, base=8, val=0}, str='00'})
- simple_test({{data='01', size=1}}, 'Number', 1, {data={is_float=false, base=10, val=0}, str='0'})
+ singl_eltkn_test('Invalid', '~', { error = 'E15: Unidentified character: %.*s' })
+ simple_test({ { data = nil, size = 0 } }, 'EOC', 0, { error = 'start.col >= #pstr' })
+ simple_test({ '' }, 'EOC', 0, { error = 'start.col >= #pstr' })
+ simple_test(
+ { '2.' },
+ 'Number',
+ 1,
+ { data = { is_float = false, base = 10, val = 2 }, str = '2' }
+ )
+ simple_test(
+ { '2e5' },
+ 'Number',
+ 1,
+ { data = { is_float = false, base = 10, val = 2 }, str = '2' }
+ )
+ simple_test(
+ { '2.x' },
+ 'Number',
+ 1,
+ { data = { is_float = false, base = 10, val = 2 }, str = '2' }
+ )
+ simple_test(
+ { '2.2.' },
+ 'Number',
+ 1,
+ { data = { is_float = false, base = 10, val = 2 }, str = '2' }
+ )
+ simple_test(
+ { '2.0x' },
+ 'Number',
+ 1,
+ { data = { is_float = false, base = 10, val = 2 }, str = '2' }
+ )
+ simple_test(
+ { '2.0e' },
+ 'Number',
+ 1,
+ { data = { is_float = false, base = 10, val = 2 }, str = '2' }
+ )
+ simple_test(
+ { '2.0e+' },
+ 'Number',
+ 1,
+ { data = { is_float = false, base = 10, val = 2 }, str = '2' }
+ )
+ simple_test(
+ { '2.0e-' },
+ 'Number',
+ 1,
+ { data = { is_float = false, base = 10, val = 2 }, str = '2' }
+ )
+ simple_test(
+ { '2.0e+x' },
+ 'Number',
+ 1,
+ { data = { is_float = false, base = 10, val = 2 }, str = '2' }
+ )
+ simple_test(
+ { '2.0e-x' },
+ 'Number',
+ 1,
+ { data = { is_float = false, base = 10, val = 2 }, str = '2' }
+ )
+ simple_test(
+ { '2.0e+1a' },
+ 'Number',
+ 1,
+ { data = { is_float = false, base = 10, val = 2 }, str = '2' }
+ )
+ simple_test(
+ { '2.0e-1a' },
+ 'Number',
+ 1,
+ { data = { is_float = false, base = 10, val = 2 }, str = '2' }
+ )
+ simple_test(
+ { '0b102' },
+ 'Number',
+ 4,
+ { data = { is_float = false, base = 2, val = 2 }, str = '0b10' }
+ )
+ simple_test(
+ { '10F' },
+ 'Number',
+ 2,
+ { data = { is_float = false, base = 10, val = 10 }, str = '10' }
+ )
+ simple_test({ '0x0123456789ABCDEFG' }, 'Number', 18, {
+ data = { is_float = false, base = 16, val = 81985529216486895 },
+ str = '0x0123456789ABCDEF',
+ })
+ simple_test(
+ { { data = '00', size = 2 } },
+ 'Number',
+ 2,
+ { data = { is_float = false, base = 8, val = 0 }, str = '00' }
+ )
+ simple_test(
+ { { data = '009', size = 2 } },
+ 'Number',
+ 2,
+ { data = { is_float = false, base = 8, val = 0 }, str = '00' }
+ )
+ simple_test(
+ { { data = '01', size = 1 } },
+ 'Number',
+ 1,
+ { data = { is_float = false, base = 10, val = 0 }, str = '0' }
+ )
end
local function regular_scope_tests()
@@ -312,29 +417,104 @@ describe('Expressions lexer', function()
scope_test('l')
scope_test('a')
- simple_test({'g:'}, 'PlainIdentifier', 2, {data={scope='g', autoload=false}, str='g:'})
- simple_test({'g:is#foo'}, 'PlainIdentifier', 8, {data={scope='g', autoload=true}, str='g:is#foo'})
- simple_test({'g:isnot#foo'}, 'PlainIdentifier', 11, {data={scope='g', autoload=true}, str='g:isnot#foo'})
+ simple_test(
+ { 'g:' },
+ 'PlainIdentifier',
+ 2,
+ { data = { scope = 'g', autoload = false }, str = 'g:' }
+ )
+ simple_test(
+ { 'g:is#foo' },
+ 'PlainIdentifier',
+ 8,
+ { data = { scope = 'g', autoload = true }, str = 'g:is#foo' }
+ )
+ simple_test(
+ { 'g:isnot#foo' },
+ 'PlainIdentifier',
+ 11,
+ { data = { scope = 'g', autoload = true }, str = 'g:isnot#foo' }
+ )
end
local function regular_is_tests()
comparison_test('is', 'isnot', 'Identical')
- simple_test({'is'}, 'Comparison', 2, {data={type='Identical', inv=false, ccs='UseOption'}, str='is'})
- simple_test({'isnot'}, 'Comparison', 5, {data={type='Identical', inv=true, ccs='UseOption'}, str='isnot'})
- simple_test({'is?'}, 'Comparison', 3, {data={type='Identical', inv=false, ccs='IgnoreCase'}, str='is?'})
- simple_test({'isnot?'}, 'Comparison', 6, {data={type='Identical', inv=true, ccs='IgnoreCase'}, str='isnot?'})
- simple_test({'is#'}, 'Comparison', 3, {data={type='Identical', inv=false, ccs='MatchCase'}, str='is#'})
- simple_test({'isnot#'}, 'Comparison', 6, {data={type='Identical', inv=true, ccs='MatchCase'}, str='isnot#'})
- simple_test({'is#foo'}, 'Comparison', 3, {data={type='Identical', inv=false, ccs='MatchCase'}, str='is#'})
- simple_test({'isnot#foo'}, 'Comparison', 6, {data={type='Identical', inv=true, ccs='MatchCase'}, str='isnot#'})
+ simple_test(
+ { 'is' },
+ 'Comparison',
+ 2,
+ { data = { type = 'Identical', inv = false, ccs = 'UseOption' }, str = 'is' }
+ )
+ simple_test(
+ { 'isnot' },
+ 'Comparison',
+ 5,
+ { data = { type = 'Identical', inv = true, ccs = 'UseOption' }, str = 'isnot' }
+ )
+ simple_test(
+ { 'is?' },
+ 'Comparison',
+ 3,
+ { data = { type = 'Identical', inv = false, ccs = 'IgnoreCase' }, str = 'is?' }
+ )
+ simple_test(
+ { 'isnot?' },
+ 'Comparison',
+ 6,
+ { data = { type = 'Identical', inv = true, ccs = 'IgnoreCase' }, str = 'isnot?' }
+ )
+ simple_test(
+ { 'is#' },
+ 'Comparison',
+ 3,
+ { data = { type = 'Identical', inv = false, ccs = 'MatchCase' }, str = 'is#' }
+ )
+ simple_test(
+ { 'isnot#' },
+ 'Comparison',
+ 6,
+ { data = { type = 'Identical', inv = true, ccs = 'MatchCase' }, str = 'isnot#' }
+ )
+ simple_test(
+ { 'is#foo' },
+ 'Comparison',
+ 3,
+ { data = { type = 'Identical', inv = false, ccs = 'MatchCase' }, str = 'is#' }
+ )
+ simple_test(
+ { 'isnot#foo' },
+ 'Comparison',
+ 6,
+ { data = { type = 'Identical', inv = true, ccs = 'MatchCase' }, str = 'isnot#' }
+ )
end
local function regular_number_tests()
- simple_test({'2.0'}, 'Number', 1, {data={is_float=false, base=10, val=2}, str='2'})
- simple_test({'2.0e5'}, 'Number', 1, {data={is_float=false, base=10, val=2}, str='2'})
- simple_test({'2.0e+5'}, 'Number', 1, {data={is_float=false, base=10, val=2}, str='2'})
- simple_test({'2.0e-5'}, 'Number', 1, {data={is_float=false, base=10, val=2}, str='2'})
+ simple_test(
+ { '2.0' },
+ 'Number',
+ 1,
+ { data = { is_float = false, base = 10, val = 2 }, str = '2' }
+ )
+ simple_test(
+ { '2.0e5' },
+ 'Number',
+ 1,
+ { data = { is_float = false, base = 10, val = 2 }, str = '2' }
+ )
+ simple_test(
+ { '2.0e+5' },
+ 'Number',
+ 1,
+ { data = { is_float = false, base = 10, val = 2 }, str = '2' }
+ )
+ simple_test(
+ { '2.0e-5' },
+ 'Number',
+ 1,
+ { data = { is_float = false, base = 10, val = 2 }, str = '2' }
+ )
end
local function regular_eoc_tests()
@@ -369,7 +549,12 @@ describe('Expressions lexer', function()
regular_is_tests()
regular_number_tests()
- simple_test({'g:'}, 'PlainIdentifier', 1, {data={scope=0, autoload=false}, str='g'})
+ simple_test(
+ { 'g:' },
+ 'PlainIdentifier',
+ 1,
+ { data = { scope = 0, autoload = false }, str = 'g' }
+ )
end)
itp('allows floats', function()
flags = tonumber(lib.kELFlagAllowFloat)
@@ -379,20 +564,72 @@ describe('Expressions lexer', function()
regular_scope_tests()
regular_is_tests()
- simple_test({'2.2'}, 'Number', 3, {data={is_float=true, base=10, val=2.2}, str='2.2'})
- simple_test({'2.0e5'}, 'Number', 5, {data={is_float=true, base=10, val=2e5}, str='2.0e5'})
- simple_test({'2.0e+5'}, 'Number', 6, {data={is_float=true, base=10, val=2e5}, str='2.0e+5'})
- simple_test({'2.0e-5'}, 'Number', 6, {data={is_float=true, base=10, val=2e-5}, str='2.0e-5'})
- simple_test({'2.500000e-5'}, 'Number', 11, {data={is_float=true, base=10, val=2.5e-5}, str='2.500000e-5'})
- simple_test({'2.5555e2'}, 'Number', 8, {data={is_float=true, base=10, val=2.5555e2}, str='2.5555e2'})
- simple_test({'2.5555e+2'}, 'Number', 9, {data={is_float=true, base=10, val=2.5555e2}, str='2.5555e+2'})
- simple_test({'2.5555e-2'}, 'Number', 9, {data={is_float=true, base=10, val=2.5555e-2}, str='2.5555e-2'})
- simple_test({{data='2.5e-5', size=3}},
- 'Number', 3, {data={is_float=true, base=10, val=2.5}, str='2.5'})
- simple_test({{data='2.5e5', size=4}},
- 'Number', 1, {data={is_float=false, base=10, val=2}, str='2'})
- simple_test({{data='2.5e-50', size=6}},
- 'Number', 6, {data={is_float=true, base=10, val=2.5e-5}, str='2.5e-5'})
+ simple_test(
+ { '2.2' },
+ 'Number',
+ 3,
+ { data = { is_float = true, base = 10, val = 2.2 }, str = '2.2' }
+ )
+ simple_test(
+ { '2.0e5' },
+ 'Number',
+ 5,
+ { data = { is_float = true, base = 10, val = 2e5 }, str = '2.0e5' }
+ )
+ simple_test(
+ { '2.0e+5' },
+ 'Number',
+ 6,
+ { data = { is_float = true, base = 10, val = 2e5 }, str = '2.0e+5' }
+ )
+ simple_test(
+ { '2.0e-5' },
+ 'Number',
+ 6,
+ { data = { is_float = true, base = 10, val = 2e-5 }, str = '2.0e-5' }
+ )
+ simple_test(
+ { '2.500000e-5' },
+ 'Number',
+ 11,
+ { data = { is_float = true, base = 10, val = 2.5e-5 }, str = '2.500000e-5' }
+ )
+ simple_test(
+ { '2.5555e2' },
+ 'Number',
+ 8,
+ { data = { is_float = true, base = 10, val = 2.5555e2 }, str = '2.5555e2' }
+ )
+ simple_test(
+ { '2.5555e+2' },
+ 'Number',
+ 9,
+ { data = { is_float = true, base = 10, val = 2.5555e2 }, str = '2.5555e+2' }
+ )
+ simple_test(
+ { '2.5555e-2' },
+ 'Number',
+ 9,
+ { data = { is_float = true, base = 10, val = 2.5555e-2 }, str = '2.5555e-2' }
+ )
+ simple_test(
+ { { data = '2.5e-5', size = 3 } },
+ 'Number',
+ 3,
+ { data = { is_float = true, base = 10, val = 2.5 }, str = '2.5' }
+ )
+ simple_test(
+ { { data = '2.5e5', size = 4 } },
+ 'Number',
+ 1,
+ { data = { is_float = false, base = 10, val = 2 }, str = '2' }
+ )
+ simple_test(
+ { { data = '2.5e-50', size = 6 } },
+ 'Number',
+ 6,
+ { data = { is_float = true, base = 10, val = 2.5e-5 }, str = '2.5e-5' }
+ )
end)
itp('treats `is` as an identifier', function()
flags = tonumber(lib.kELFlagIsNotCmp)
@@ -402,14 +639,54 @@ describe('Expressions lexer', function()
regular_scope_tests()
regular_number_tests()
- simple_test({'is'}, 'PlainIdentifier', 2, {data={scope=0, autoload=false}, str='is'})
- simple_test({'isnot'}, 'PlainIdentifier', 5, {data={scope=0, autoload=false}, str='isnot'})
- simple_test({'is?'}, 'PlainIdentifier', 2, {data={scope=0, autoload=false}, str='is'})
- simple_test({'isnot?'}, 'PlainIdentifier', 5, {data={scope=0, autoload=false}, str='isnot'})
- simple_test({'is#'}, 'PlainIdentifier', 3, {data={scope=0, autoload=true}, str='is#'})
- simple_test({'isnot#'}, 'PlainIdentifier', 6, {data={scope=0, autoload=true}, str='isnot#'})
- simple_test({'is#foo'}, 'PlainIdentifier', 6, {data={scope=0, autoload=true}, str='is#foo'})
- simple_test({'isnot#foo'}, 'PlainIdentifier', 9, {data={scope=0, autoload=true}, str='isnot#foo'})
+ simple_test(
+ { 'is' },
+ 'PlainIdentifier',
+ 2,
+ { data = { scope = 0, autoload = false }, str = 'is' }
+ )
+ simple_test(
+ { 'isnot' },
+ 'PlainIdentifier',
+ 5,
+ { data = { scope = 0, autoload = false }, str = 'isnot' }
+ )
+ simple_test(
+ { 'is?' },
+ 'PlainIdentifier',
+ 2,
+ { data = { scope = 0, autoload = false }, str = 'is' }
+ )
+ simple_test(
+ { 'isnot?' },
+ 'PlainIdentifier',
+ 5,
+ { data = { scope = 0, autoload = false }, str = 'isnot' }
+ )
+ simple_test(
+ { 'is#' },
+ 'PlainIdentifier',
+ 3,
+ { data = { scope = 0, autoload = true }, str = 'is#' }
+ )
+ simple_test(
+ { 'isnot#' },
+ 'PlainIdentifier',
+ 6,
+ { data = { scope = 0, autoload = true }, str = 'isnot#' }
+ )
+ simple_test(
+ { 'is#foo' },
+ 'PlainIdentifier',
+ 6,
+ { data = { scope = 0, autoload = true }, str = 'is#foo' }
+ )
+ simple_test(
+ { 'isnot#foo' },
+ 'PlainIdentifier',
+ 9,
+ { data = { scope = 0, autoload = true }, str = 'isnot#foo' }
+ )
end)
itp('forbids EOC', function()
flags = tonumber(lib.kELFlagForbidEOC)
@@ -419,8 +696,8 @@ describe('Expressions lexer', function()
regular_is_tests()
regular_number_tests()
- singl_eltkn_test('Invalid', '|', {error='E15: Unexpected EOC character: %.*s'})
- singl_eltkn_test('Invalid', '\0', {error='E15: Unexpected EOC character: %.*s'})
- singl_eltkn_test('Invalid', '\n', {error='E15: Unexpected EOC character: %.*s'})
+ singl_eltkn_test('Invalid', '|', { error = 'E15: Unexpected EOC character: %.*s' })
+ singl_eltkn_test('Invalid', '\0', { error = 'E15: Unexpected EOC character: %.*s' })
+ singl_eltkn_test('Invalid', '\n', { error = 'E15: Unexpected EOC character: %.*s' })
end)
end)
diff --git a/test/unit/viml/expressions/parser_spec.lua b/test/unit/viml/expressions/parser_spec.lua
index 51a703b593..ae12136a5c 100644
--- a/test/unit/viml/expressions/parser_spec.lua
+++ b/test/unit/viml/expressions/parser_spec.lua
@@ -25,100 +25,99 @@ local conv_cmp_type = viml_helpers.conv_cmp_type
local pstate_set_str = viml_helpers.pstate_set_str
local conv_expr_asgn_type = viml_helpers.conv_expr_asgn_type
-local lib = cimport('./src/nvim/viml/parser/expressions.h',
- './src/nvim/syntax.h')
+local lib = cimport('./src/nvim/viml/parser/expressions.h', './src/nvim/syntax.h')
local alloc_log = alloc_log_new()
local predefined_hl_defs = {
-- From highlight_init_both
- Conceal=true,
- Cursor=true,
- lCursor=true,
- DiffText=true,
- ErrorMsg=true,
- IncSearch=true,
- ModeMsg=true,
- NonText=true,
- PmenuSbar=true,
- StatusLine=true,
- StatusLineNC=true,
- TabLineFill=true,
- TabLineSel=true,
- TermCursor=true,
- VertSplit=true,
- WildMenu=true,
- WinSeparator=true,
- EndOfBuffer=true,
- QuickFixLine=true,
- Substitute=true,
- Whitespace=true,
- Error=true,
- Todo=true,
- String=true,
- Character=true,
- Number=true,
- Boolean=true,
- Float=true,
- Function=true,
- Conditional=true,
- Repeat=true,
- Label=true,
- Operator=true,
- Keyword=true,
- Exception=true,
- Include=true,
- Define=true,
- Macro=true,
- PreCondit=true,
- StorageClass=true,
- Structure=true,
- Typedef=true,
- Tag=true,
- SpecialChar=true,
- Delimiter=true,
- SpecialComment=true,
- Debug=true,
+ Conceal = true,
+ Cursor = true,
+ lCursor = true,
+ DiffText = true,
+ ErrorMsg = true,
+ IncSearch = true,
+ ModeMsg = true,
+ NonText = true,
+ PmenuSbar = true,
+ StatusLine = true,
+ StatusLineNC = true,
+ TabLineFill = true,
+ TabLineSel = true,
+ TermCursor = true,
+ VertSplit = true,
+ WildMenu = true,
+ WinSeparator = true,
+ EndOfBuffer = true,
+ QuickFixLine = true,
+ Substitute = true,
+ Whitespace = true,
+ Error = true,
+ Todo = true,
+ String = true,
+ Character = true,
+ Number = true,
+ Boolean = true,
+ Float = true,
+ Function = true,
+ Conditional = true,
+ Repeat = true,
+ Label = true,
+ Operator = true,
+ Keyword = true,
+ Exception = true,
+ Include = true,
+ Define = true,
+ Macro = true,
+ PreCondit = true,
+ StorageClass = true,
+ Structure = true,
+ Typedef = true,
+ Tag = true,
+ SpecialChar = true,
+ Delimiter = true,
+ SpecialComment = true,
+ Debug = true,
-- From highlight_init_(dark|light)
- ColorColumn=true,
- CursorColumn=true,
- CursorLine=true,
- CursorLineNr=true,
- DiffAdd=true,
- DiffChange=true,
- DiffDelete=true,
- Directory=true,
- FoldColumn=true,
- Folded=true,
- LineNr=true,
- MatchParen=true,
- MoreMsg=true,
- Pmenu=true,
- PmenuSel=true,
- PmenuThumb=true,
- Question=true,
- Search=true,
- SignColumn=true,
- SpecialKey=true,
- SpellBad=true,
- SpellCap=true,
- SpellLocal=true,
- SpellRare=true,
- TabLine=true,
- Title=true,
- Visual=true,
- WarningMsg=true,
- Normal=true,
- Comment=true,
- Constant=true,
- Special=true,
- Identifier=true,
- Statement=true,
- PreProc=true,
- Type=true,
- Underlined=true,
- Ignore=true,
+ ColorColumn = true,
+ CursorColumn = true,
+ CursorLine = true,
+ CursorLineNr = true,
+ DiffAdd = true,
+ DiffChange = true,
+ DiffDelete = true,
+ Directory = true,
+ FoldColumn = true,
+ Folded = true,
+ LineNr = true,
+ MatchParen = true,
+ MoreMsg = true,
+ Pmenu = true,
+ PmenuSel = true,
+ PmenuThumb = true,
+ Question = true,
+ Search = true,
+ SignColumn = true,
+ SpecialKey = true,
+ SpellBad = true,
+ SpellCap = true,
+ SpellLocal = true,
+ SpellRare = true,
+ TabLine = true,
+ Title = true,
+ Visual = true,
+ WarningMsg = true,
+ Normal = true,
+ Comment = true,
+ Constant = true,
+ Special = true,
+ Identifier = true,
+ Statement = true,
+ PreProc = true,
+ Type = true,
+ Underlined = true,
+ Ignore = true,
}
local nvim_hl_defs = {}
@@ -136,22 +135,18 @@ child_call_once(function()
-- linking, otherwise it will be created as cleared. So existence
-- of the group is checked here and not in the next pass over
-- nvim_hl_defs.
- eq(true, not not (nvim_hl_defs[grp_link]
- or predefined_hl_defs[grp_link]))
- eq(false, not not (nvim_hl_defs[new_grp]
- or predefined_hl_defs[new_grp]))
- nvim_hl_defs[new_grp] = {'link', grp_link}
+ eq(true, not not (nvim_hl_defs[grp_link] or predefined_hl_defs[grp_link]))
+ eq(false, not not (nvim_hl_defs[new_grp] or predefined_hl_defs[new_grp]))
+ nvim_hl_defs[new_grp] = { 'link', grp_link }
else
local new_grp, grp_args = s:match('^(%w+) (.*)')
neq(nil, new_grp)
- eq(false, not not (nvim_hl_defs[new_grp]
- or predefined_hl_defs[new_grp]))
- nvim_hl_defs[new_grp] = {'definition', grp_args}
+ eq(false, not not (nvim_hl_defs[new_grp] or predefined_hl_defs[new_grp]))
+ nvim_hl_defs[new_grp] = { 'definition', grp_args }
end
end)
if not err then
- msg = format_string(
- 'Error while processing string %s at position %u:\n%s', s, i, msg)
+ msg = format_string('Error while processing string %s at position %u:\n%s', s, i, msg)
error(msg)
end
i = i + 1
@@ -185,12 +180,12 @@ local function hls_to_hl_fs(hls)
local col_shift = col - next_col
assert(col_shift >= 0)
next_col = col + #str
- ret[i] = format_string('hl(%r, %r%s)',
- group,
- str,
- (col_shift == 0
- and ''
- or (', %u'):format(col_shift)))
+ ret[i] = format_string(
+ 'hl(%r, %r%s)',
+ group,
+ str,
+ (col_shift == 0 and '' or (', %u'):format(col_shift))
+ )
end
return ret
end
@@ -205,9 +200,9 @@ local function format_check(expr, format_check_data, opts)
dig_len = #opts.funcname + 2
else
print(format_string('\n_check_parsing(%r, %r, {', opts, expr))
- dig_len = #('_check_parsing(, \'') + #(format_string('%r', opts))
+ dig_len = #"_check_parsing(, '" + #(format_string('%r', opts))
end
- local digits = ' --' .. (' '):rep(dig_len - #(' --'))
+ local digits = ' --' .. (' '):rep(dig_len - #' --')
local digits2 = digits:sub(1, -10)
for i = 0, #expr - 1 do
if i % 10 == 0 then
@@ -240,10 +235,9 @@ local function format_check(expr, format_check_data, opts)
diffs[flags] = dictdiff(zdata, v)
if diffs[flags] then
if flags == 3 + zflags then
- if (dictdiff(format_check_data[1 + zflags],
- format_check_data[3 + zflags]) == nil
- or dictdiff(format_check_data[2 + zflags],
- format_check_data[3 + zflags]) == nil)
+ if
+ dictdiff(format_check_data[1 + zflags], format_check_data[3 + zflags]) == nil
+ or dictdiff(format_check_data[2 + zflags], format_check_data[3 + zflags]) == nil
then
diffs[flags] = nil
else
@@ -268,7 +262,7 @@ local function format_check(expr, format_check_data, opts)
end
if diff.hl_fs then
print(' hl_fs = ' .. format_luav(diff.hl_fs, ' ', {
- literal_strings=true
+ literal_strings = true,
}) .. ',')
end
print(' },')
@@ -280,47 +274,54 @@ local function format_check(expr, format_check_data, opts)
end
local east_node_type_tab
-make_enum_conv_tab(lib, {
- 'kExprNodeMissing',
- 'kExprNodeOpMissing',
- 'kExprNodeTernary',
- 'kExprNodeTernaryValue',
- 'kExprNodeRegister',
- 'kExprNodeSubscript',
- 'kExprNodeListLiteral',
- 'kExprNodeUnaryPlus',
- 'kExprNodeBinaryPlus',
- 'kExprNodeNested',
- 'kExprNodeCall',
- 'kExprNodePlainIdentifier',
- 'kExprNodePlainKey',
- 'kExprNodeComplexIdentifier',
- 'kExprNodeUnknownFigure',
- 'kExprNodeLambda',
- 'kExprNodeDictLiteral',
- 'kExprNodeCurlyBracesIdentifier',
- 'kExprNodeComma',
- 'kExprNodeColon',
- 'kExprNodeArrow',
- 'kExprNodeComparison',
- 'kExprNodeConcat',
- 'kExprNodeConcatOrSubscript',
- 'kExprNodeInteger',
- 'kExprNodeFloat',
- 'kExprNodeSingleQuotedString',
- 'kExprNodeDoubleQuotedString',
- 'kExprNodeOr',
- 'kExprNodeAnd',
- 'kExprNodeUnaryMinus',
- 'kExprNodeBinaryMinus',
- 'kExprNodeNot',
- 'kExprNodeMultiplication',
- 'kExprNodeDivision',
- 'kExprNodeMod',
- 'kExprNodeOption',
- 'kExprNodeEnvironment',
- 'kExprNodeAssignment',
-}, 'kExprNode', function(ret) east_node_type_tab = ret end)
+make_enum_conv_tab(
+ lib,
+ {
+ 'kExprNodeMissing',
+ 'kExprNodeOpMissing',
+ 'kExprNodeTernary',
+ 'kExprNodeTernaryValue',
+ 'kExprNodeRegister',
+ 'kExprNodeSubscript',
+ 'kExprNodeListLiteral',
+ 'kExprNodeUnaryPlus',
+ 'kExprNodeBinaryPlus',
+ 'kExprNodeNested',
+ 'kExprNodeCall',
+ 'kExprNodePlainIdentifier',
+ 'kExprNodePlainKey',
+ 'kExprNodeComplexIdentifier',
+ 'kExprNodeUnknownFigure',
+ 'kExprNodeLambda',
+ 'kExprNodeDictLiteral',
+ 'kExprNodeCurlyBracesIdentifier',
+ 'kExprNodeComma',
+ 'kExprNodeColon',
+ 'kExprNodeArrow',
+ 'kExprNodeComparison',
+ 'kExprNodeConcat',
+ 'kExprNodeConcatOrSubscript',
+ 'kExprNodeInteger',
+ 'kExprNodeFloat',
+ 'kExprNodeSingleQuotedString',
+ 'kExprNodeDoubleQuotedString',
+ 'kExprNodeOr',
+ 'kExprNodeAnd',
+ 'kExprNodeUnaryMinus',
+ 'kExprNodeBinaryMinus',
+ 'kExprNodeNot',
+ 'kExprNodeMultiplication',
+ 'kExprNodeDivision',
+ 'kExprNodeMod',
+ 'kExprNodeOption',
+ 'kExprNodeEnvironment',
+ 'kExprNodeAssignment',
+ },
+ 'kExprNode',
+ function(ret)
+ east_node_type_tab = ret
+ end
+)
local function conv_east_node_type(typ)
return conv_enum(east_node_type_tab, typ)
@@ -346,25 +347,35 @@ local function eastnode2lua(pstate, eastnode, checked_nodes)
ret_str = ('%u:%u:%s'):format(str.start.line, str.start.col, str.str)
end
if typ == 'Register' then
- typ = typ .. ('(name=%s)'):format(
- tostring(intchar2lua(eastnode.data.reg.name)))
+ typ = typ .. ('(name=%s)'):format(tostring(intchar2lua(eastnode.data.reg.name)))
elseif typ == 'PlainIdentifier' then
- typ = typ .. ('(scope=%s,ident=%s)'):format(
- tostring(intchar2lua(eastnode.data.var.scope)),
- ffi.string(eastnode.data.var.ident, eastnode.data.var.ident_len))
+ typ = typ
+ .. ('(scope=%s,ident=%s)'):format(
+ tostring(intchar2lua(eastnode.data.var.scope)),
+ ffi.string(eastnode.data.var.ident, eastnode.data.var.ident_len)
+ )
elseif typ == 'PlainKey' then
- typ = typ .. ('(key=%s)'):format(
- ffi.string(eastnode.data.var.ident, eastnode.data.var.ident_len))
- elseif (typ == 'UnknownFigure' or typ == 'DictLiteral'
- or typ == 'CurlyBracesIdentifier' or typ == 'Lambda') then
- typ = typ .. ('(%s)'):format(
- (eastnode.data.fig.type_guesses.allow_lambda and '\\' or '-')
- .. (eastnode.data.fig.type_guesses.allow_dict and 'd' or '-')
- .. (eastnode.data.fig.type_guesses.allow_ident and 'i' or '-'))
+ typ = typ
+ .. ('(key=%s)'):format(ffi.string(eastnode.data.var.ident, eastnode.data.var.ident_len))
+ elseif
+ typ == 'UnknownFigure'
+ or typ == 'DictLiteral'
+ or typ == 'CurlyBracesIdentifier'
+ or typ == 'Lambda'
+ then
+ typ = typ
+ .. ('(%s)'):format(
+ (eastnode.data.fig.type_guesses.allow_lambda and '\\' or '-')
+ .. (eastnode.data.fig.type_guesses.allow_dict and 'd' or '-')
+ .. (eastnode.data.fig.type_guesses.allow_ident and 'i' or '-')
+ )
elseif typ == 'Comparison' then
- typ = typ .. ('(type=%s,inv=%u,ccs=%s)'):format(
- conv_cmp_type(eastnode.data.cmp.type), eastnode.data.cmp.inv and 1 or 0,
- conv_ccs(eastnode.data.cmp.ccs))
+ typ = typ
+ .. ('(type=%s,inv=%u,ccs=%s)'):format(
+ conv_cmp_type(eastnode.data.cmp.type),
+ eastnode.data.cmp.inv and 1 or 0,
+ conv_ccs(eastnode.data.cmp.ccs)
+ )
elseif typ == 'Integer' then
typ = typ .. ('(val=%u)'):format(tonumber(eastnode.data.num.value))
elseif typ == 'Float' then
@@ -380,11 +391,13 @@ local function eastnode2lua(pstate, eastnode, checked_nodes)
typ = ('%s(scope=%s,ident=%s)'):format(
typ,
tostring(intchar2lua(eastnode.data.opt.scope)),
- ffi.string(eastnode.data.opt.ident, eastnode.data.opt.ident_len))
+ ffi.string(eastnode.data.opt.ident, eastnode.data.opt.ident_len)
+ )
elseif typ == 'Environment' then
typ = ('%s(ident=%s)'):format(
typ,
- ffi.string(eastnode.data.env.ident, eastnode.data.env.ident_len))
+ ffi.string(eastnode.data.env.ident, eastnode.data.env.ident_len)
+ )
elseif typ == 'Assignment' then
typ = ('%s(%s)'):format(typ, conv_expr_asgn_type(eastnode.data.ass.type))
end
@@ -433,22 +446,21 @@ local function phl2lua(pstate)
local ret = {}
for i = 0, (tonumber(pstate.colors.size) - 1) do
local chunk = pstate.colors.items[i]
- local chunk_tbl = pstate_set_str(
- pstate, chunk.start, chunk.end_col - chunk.start.col, {
- group = ffi.string(chunk.group),
- })
+ local chunk_tbl = pstate_set_str(pstate, chunk.start, chunk.end_col - chunk.start.col, {
+ group = ffi.string(chunk.group),
+ })
ret[i + 1] = ('%s:%u:%u:%s'):format(
chunk_tbl.group,
chunk_tbl.start.line,
chunk_tbl.start.col,
- chunk_tbl.str)
+ chunk_tbl.str
+ )
end
return ret
end
describe('Expressions parser', function()
- local function _check_parsing(opts, str, exp_ast, exp_highlighting_fs,
- nz_flags_exps)
+ local function _check_parsing(opts, str, exp_ast, exp_highlighting_fs, nz_flags_exps)
local zflags = opts.flags[1]
nz_flags_exps = nz_flags_exps or {}
local format_check_data = {}
@@ -460,12 +472,12 @@ describe('Expressions parser', function()
end
alloc_log:check({})
- local pstate = new_pstate({str})
+ local pstate = new_pstate({ str })
local east = lib.viml_pexpr_parse(pstate, flags)
local ast = east2lua(str, pstate, east)
local hls = phl2lua(pstate)
if exp_ast == nil then
- format_check_data[flags] = {ast=ast, hl_fs=hls_to_hl_fs(hls)}
+ format_check_data[flags] = { ast = ast, hl_fs = hls_to_hl_fs(hls) }
else
local exps = {
ast = exp_ast,
@@ -499,8 +511,7 @@ describe('Expressions parser', function()
alloc_log:check({})
end)
if not err then
- msg = format_string('Error while processing test (%r, %u):\n%s',
- str, flags, msg)
+ msg = format_string('Error while processing test (%r, %u):\n%s', str, flags, msg)
error(msg)
end
end
@@ -514,16 +525,11 @@ describe('Expressions parser', function()
error(('Unknown group: Nvim%s'):format(group))
end
local col = next_col + (shift or 0)
- return (('%s:%u:%u:%s'):format(
- 'Nvim' .. group,
- 0,
- col,
- str)), (col + #str)
+ return (('%s:%u:%u:%s'):format('Nvim' .. group, 0, col, str)), (col + #str)
end
end
local function fmtn(typ, args, rest)
return ('%s(%s)%s'):format(typ, args, rest)
end
- require('test.unit.viml.expressions.parser_tests')(
- itp, _check_parsing, hl, fmtn)
+ require('test.unit.viml.expressions.parser_tests')(itp, _check_parsing, hl, fmtn)
end)
diff --git a/test/unit/viml/expressions/parser_tests.lua b/test/unit/viml/expressions/parser_tests.lua
index da61672bb1..a10e1098b5 100644
--- a/test/unit/viml/expressions/parser_tests.lua
+++ b/test/unit/viml/expressions/parser_tests.lua
@@ -4,12 +4,12 @@ local REMOVE_THIS = global_helpers.REMOVE_THIS
return function(itp, _check_parsing, hl, fmtn)
local function check_parsing(...)
- return _check_parsing({flags={0, 1, 2, 3}, funcname='check_parsing'}, ...)
+ return _check_parsing({ flags = { 0, 1, 2, 3 }, funcname = 'check_parsing' }, ...)
end
local function check_asgn_parsing(...)
return _check_parsing({
- flags={4, 5, 6, 7},
- funcname='check_asgn_parsing',
+ flags = { 4, 5, 6, 7 },
+ funcname = 'check_asgn_parsing',
}, ...)
end
itp('works with + and @a', function()
@@ -142,7 +142,7 @@ return function(itp, _check_parsing, hl, fmtn)
len = 2,
err = REMOVE_THIS,
ast = {
- 'Register(name=a):0:0:@a'
+ 'Register(name=a):0:0:@a',
},
},
hl_fs = {
@@ -174,7 +174,7 @@ return function(itp, _check_parsing, hl, fmtn)
len = 6,
err = REMOVE_THIS,
ast = {
- 'Register(name=a):0:0: @a'
+ 'Register(name=a):0:0: @a',
},
},
hl_fs = {
@@ -541,7 +541,7 @@ return function(itp, _check_parsing, hl, fmtn)
children = {
{
'Nested:0:4:(',
- children = { 'Register(name=b):0:5:@b' }
+ children = { 'Register(name=b):0:5:@b' },
},
},
},
@@ -579,7 +579,7 @@ return function(itp, _check_parsing, hl, fmtn)
children = {
{
'Nested:0:4:(',
- children = { 'Register(name=b):0:5:@b' }
+ children = { 'Register(name=b):0:5:@b' },
},
},
},
@@ -600,13 +600,13 @@ return function(itp, _check_parsing, hl, fmtn)
hl('BinaryPlus', '+'),
hl('Register', '@c'),
})
- check_parsing(
- '@a + (@b + @c) + @d(@e) + (+@f) + ((+@g(@h))(@j)(@k))(@l)', {--[[
+ check_parsing('@a + (@b + @c) + @d(@e) + (+@f) + ((+@g(@h))(@j)(@k))(@l)', {--[[
| | | | | | | | || | | || | | ||| || || || ||
000000000011111111112222222222333333333344444444445555555
012345678901234567890123456789012345678901234567890123456
]]
- ast = {{
+ ast = {
+ {
'BinaryPlus:0:31: +',
children = {
{
@@ -696,45 +696,46 @@ return function(itp, _check_parsing, hl, fmtn)
},
},
},
- }},
- }, {
- hl('Register', '@a'),
- hl('BinaryPlus', '+', 1),
- hl('NestingParenthesis', '(', 1),
- hl('Register', '@b'),
- hl('BinaryPlus', '+', 1),
- hl('Register', '@c', 1),
- hl('NestingParenthesis', ')'),
- hl('BinaryPlus', '+', 1),
- hl('Register', '@d', 1),
- hl('CallingParenthesis', '('),
- hl('Register', '@e'),
- hl('CallingParenthesis', ')'),
- hl('BinaryPlus', '+', 1),
- hl('NestingParenthesis', '(', 1),
- hl('UnaryPlus', '+'),
- hl('Register', '@f'),
- hl('NestingParenthesis', ')'),
- hl('BinaryPlus', '+', 1),
- hl('NestingParenthesis', '(', 1),
- hl('NestingParenthesis', '('),
- hl('UnaryPlus', '+'),
- hl('Register', '@g'),
- hl('CallingParenthesis', '('),
- hl('Register', '@h'),
- hl('CallingParenthesis', ')'),
- hl('NestingParenthesis', ')'),
- hl('CallingParenthesis', '('),
- hl('Register', '@j'),
- hl('CallingParenthesis', ')'),
- hl('CallingParenthesis', '('),
- hl('Register', '@k'),
- hl('CallingParenthesis', ')'),
- hl('NestingParenthesis', ')'),
- hl('CallingParenthesis', '('),
- hl('Register', '@l'),
- hl('CallingParenthesis', ')'),
- })
+ },
+ },
+ }, {
+ hl('Register', '@a'),
+ hl('BinaryPlus', '+', 1),
+ hl('NestingParenthesis', '(', 1),
+ hl('Register', '@b'),
+ hl('BinaryPlus', '+', 1),
+ hl('Register', '@c', 1),
+ hl('NestingParenthesis', ')'),
+ hl('BinaryPlus', '+', 1),
+ hl('Register', '@d', 1),
+ hl('CallingParenthesis', '('),
+ hl('Register', '@e'),
+ hl('CallingParenthesis', ')'),
+ hl('BinaryPlus', '+', 1),
+ hl('NestingParenthesis', '(', 1),
+ hl('UnaryPlus', '+'),
+ hl('Register', '@f'),
+ hl('NestingParenthesis', ')'),
+ hl('BinaryPlus', '+', 1),
+ hl('NestingParenthesis', '(', 1),
+ hl('NestingParenthesis', '('),
+ hl('UnaryPlus', '+'),
+ hl('Register', '@g'),
+ hl('CallingParenthesis', '('),
+ hl('Register', '@h'),
+ hl('CallingParenthesis', ')'),
+ hl('NestingParenthesis', ')'),
+ hl('CallingParenthesis', '('),
+ hl('Register', '@j'),
+ hl('CallingParenthesis', ')'),
+ hl('CallingParenthesis', '('),
+ hl('Register', '@k'),
+ hl('CallingParenthesis', ')'),
+ hl('NestingParenthesis', ')'),
+ hl('CallingParenthesis', '('),
+ hl('Register', '@l'),
+ hl('CallingParenthesis', ')'),
+ })
check_parsing('@a)', {
-- 012
ast = {
@@ -1078,25 +1079,25 @@ return function(itp, _check_parsing, hl, fmtn)
end)
itp('works with variable names, including curly braces ones', function()
check_parsing('var', {
- ast = {
- 'PlainIdentifier(scope=0,ident=var):0:0:var',
- },
+ ast = {
+ 'PlainIdentifier(scope=0,ident=var):0:0:var',
+ },
}, {
hl('IdentifierName', 'var'),
})
check_parsing('g:var', {
- ast = {
- 'PlainIdentifier(scope=g,ident=var):0:0:g:var',
- },
+ ast = {
+ 'PlainIdentifier(scope=g,ident=var):0:0:g:var',
+ },
}, {
hl('IdentifierScope', 'g'),
hl('IdentifierScopeDelimiter', ':'),
hl('IdentifierName', 'var'),
})
check_parsing('g:', {
- ast = {
- 'PlainIdentifier(scope=g,ident=):0:0:g:',
- },
+ ast = {
+ 'PlainIdentifier(scope=g,ident=):0:0:g:',
+ },
}, {
hl('IdentifierScope', 'g'),
hl('IdentifierScopeDelimiter', ':'),
@@ -1141,7 +1142,7 @@ return function(itp, _check_parsing, hl, fmtn)
children = {
{
'OpMissing:0:3:',
- children={
+ children = {
'PlainIdentifier(scope=a,ident=):0:1:a:',
'Register(name=b):0:3:@b',
},
@@ -1783,7 +1784,7 @@ return function(itp, _check_parsing, hl, fmtn)
{
'Comma:0:3:,',
children = {
- 'PlainIdentifier(scope=0,ident=b):0:2:b',
+ 'PlainIdentifier(scope=0,ident=b):0:2:b',
{
'Comma:0:5:,',
children = {
@@ -1819,7 +1820,7 @@ return function(itp, _check_parsing, hl, fmtn)
{
'Comma:0:3:,',
children = {
- 'PlainIdentifier(scope=0,ident=b):0:2:b',
+ 'PlainIdentifier(scope=0,ident=b):0:2:b',
{
'Comma:0:5:,',
children = {
@@ -2851,7 +2852,7 @@ return function(itp, _check_parsing, hl, fmtn)
},
err = {
arg = '{a : b',
- msg = 'E723: Missing end of Dictionary \'}\': %.*s',
+ msg = "E723: Missing end of Dictionary '}': %.*s",
},
}, {
hl('Dict', '{'),
@@ -3182,7 +3183,7 @@ return function(itp, _check_parsing, hl, fmtn)
},
err = {
arg = '?b',
- msg = 'E109: Missing \':\' after \'?\': %.*s',
+ msg = "E109: Missing ':' after '?': %.*s",
},
}, {
hl('IdentifierName', 'a'),
@@ -3207,7 +3208,7 @@ return function(itp, _check_parsing, hl, fmtn)
},
err = {
arg = '?b:',
- msg = 'E109: Missing \':\' after \'?\': %.*s',
+ msg = "E109: Missing ':' after '?': %.*s",
},
}, {
hl('IdentifierName', 'a'),
@@ -4840,7 +4841,7 @@ return function(itp, _check_parsing, hl, fmtn)
},
err = {
arg = '[1',
- msg = 'E697: Missing end of List \']\': %.*s',
+ msg = "E697: Missing end of List ']': %.*s",
},
}, {
hl('List', '['),
@@ -4848,15 +4849,15 @@ return function(itp, _check_parsing, hl, fmtn)
})
end)
itp('works with strings', function()
- check_parsing('\'abc\'', {
+ check_parsing("'abc'", {
-- 01234
ast = {
- fmtn('SingleQuotedString', 'val="abc"', ':0:0:\'abc\''),
+ fmtn('SingleQuotedString', 'val="abc"', ":0:0:'abc'"),
},
}, {
- hl('SingleQuote', '\''),
+ hl('SingleQuote', "'"),
hl('SingleQuotedBody', 'abc'),
- hl('SingleQuote', '\''),
+ hl('SingleQuote', "'"),
})
check_parsing('"abc"', {
-- 01234
@@ -4868,14 +4869,14 @@ return function(itp, _check_parsing, hl, fmtn)
hl('DoubleQuotedBody', 'abc'),
hl('DoubleQuote', '"'),
})
- check_parsing('\'\'', {
+ check_parsing("''", {
-- 01
ast = {
- fmtn('SingleQuotedString', 'val=NULL', ':0:0:\'\''),
+ fmtn('SingleQuotedString', 'val=NULL', ":0:0:''"),
},
}, {
- hl('SingleQuote', '\''),
- hl('SingleQuote', '\''),
+ hl('SingleQuote', "'"),
+ hl('SingleQuote', "'"),
})
check_parsing('""', {
-- 01
@@ -4898,17 +4899,17 @@ return function(itp, _check_parsing, hl, fmtn)
}, {
hl('InvalidDoubleQuote', '"'),
})
- check_parsing('\'', {
+ check_parsing("'", {
-- 0
ast = {
- fmtn('SingleQuotedString', 'val=NULL', ':0:0:\''),
+ fmtn('SingleQuotedString', 'val=NULL', ":0:0:'"),
},
err = {
- arg = '\'',
+ arg = "'",
msg = 'E115: Missing single quote: %.*s',
},
}, {
- hl('InvalidSingleQuote', '\''),
+ hl('InvalidSingleQuote', "'"),
})
check_parsing('"a', {
-- 01
@@ -4923,71 +4924,71 @@ return function(itp, _check_parsing, hl, fmtn)
hl('InvalidDoubleQuote', '"'),
hl('InvalidDoubleQuotedBody', 'a'),
})
- check_parsing('\'a', {
+ check_parsing("'a", {
-- 01
ast = {
- fmtn('SingleQuotedString', 'val="a"', ':0:0:\'a'),
+ fmtn('SingleQuotedString', 'val="a"', ":0:0:'a"),
},
err = {
- arg = '\'a',
+ arg = "'a",
msg = 'E115: Missing single quote: %.*s',
},
}, {
- hl('InvalidSingleQuote', '\''),
+ hl('InvalidSingleQuote', "'"),
hl('InvalidSingleQuotedBody', 'a'),
})
- check_parsing('\'abc\'\'def\'', {
+ check_parsing("'abc''def'", {
-- 0123456789
ast = {
- fmtn('SingleQuotedString', 'val="abc\'def"', ':0:0:\'abc\'\'def\''),
+ fmtn('SingleQuotedString', 'val="abc\'def"', ":0:0:'abc''def'"),
},
}, {
- hl('SingleQuote', '\''),
+ hl('SingleQuote', "'"),
hl('SingleQuotedBody', 'abc'),
- hl('SingleQuotedQuote', '\'\''),
+ hl('SingleQuotedQuote', "''"),
hl('SingleQuotedBody', 'def'),
- hl('SingleQuote', '\''),
+ hl('SingleQuote', "'"),
})
- check_parsing('\'abc\'\'', {
+ check_parsing("'abc''", {
-- 012345
ast = {
- fmtn('SingleQuotedString', 'val="abc\'"', ':0:0:\'abc\'\''),
+ fmtn('SingleQuotedString', 'val="abc\'"', ":0:0:'abc''"),
},
err = {
- arg = '\'abc\'\'',
+ arg = "'abc''",
msg = 'E115: Missing single quote: %.*s',
},
}, {
- hl('InvalidSingleQuote', '\''),
+ hl('InvalidSingleQuote', "'"),
hl('InvalidSingleQuotedBody', 'abc'),
- hl('InvalidSingleQuotedQuote', '\'\''),
+ hl('InvalidSingleQuotedQuote', "''"),
})
- check_parsing('\'\'\'\'\'\'\'\'', {
+ check_parsing("''''''''", {
-- 01234567
ast = {
- fmtn('SingleQuotedString', 'val="\'\'\'"', ':0:0:\'\'\'\'\'\'\'\''),
+ fmtn('SingleQuotedString', "val=\"'''\"", ":0:0:''''''''"),
},
}, {
- hl('SingleQuote', '\''),
- hl('SingleQuotedQuote', '\'\''),
- hl('SingleQuotedQuote', '\'\''),
- hl('SingleQuotedQuote', '\'\''),
- hl('SingleQuote', '\''),
+ hl('SingleQuote', "'"),
+ hl('SingleQuotedQuote', "''"),
+ hl('SingleQuotedQuote', "''"),
+ hl('SingleQuotedQuote', "''"),
+ hl('SingleQuote', "'"),
})
- check_parsing('\'\'\'a\'\'\'\'bc\'', {
+ check_parsing("'''a''''bc'", {
-- 01234567890
-- 0 1
ast = {
- fmtn('SingleQuotedString', 'val="\'a\'\'bc"', ':0:0:\'\'\'a\'\'\'\'bc\''),
+ fmtn('SingleQuotedString', "val=\"'a''bc\"", ":0:0:'''a''''bc'"),
},
}, {
- hl('SingleQuote', '\''),
- hl('SingleQuotedQuote', '\'\''),
+ hl('SingleQuote', "'"),
+ hl('SingleQuotedQuote', "''"),
hl('SingleQuotedBody', 'a'),
- hl('SingleQuotedQuote', '\'\''),
- hl('SingleQuotedQuote', '\'\''),
+ hl('SingleQuotedQuote', "''"),
+ hl('SingleQuotedQuote', "''"),
hl('SingleQuotedBody', 'bc'),
- hl('SingleQuote', '\''),
+ hl('SingleQuote', "'"),
})
check_parsing('"\\"\\"\\"\\""', {
-- 0123456789
@@ -5006,7 +5007,11 @@ return function(itp, _check_parsing, hl, fmtn)
-- 0123456789012345678901234
-- 0 1 2
ast = {
- fmtn('DoubleQuotedString', 'val="abc\\"def\\"ghi\\"jkl\\"mno"', ':0:0:"abc\\"def\\"ghi\\"jkl\\"mno"'),
+ fmtn(
+ 'DoubleQuotedString',
+ 'val="abc\\"def\\"ghi\\"jkl\\"mno"',
+ ':0:0:"abc\\"def\\"ghi\\"jkl\\"mno"'
+ ),
},
}, {
hl('DoubleQuote', '"'),
@@ -6977,8 +6982,7 @@ return function(itp, _check_parsing, hl, fmtn)
arg = '\0002&A:\000',
msg = 'E15: Expected value, got EOC: %.*s',
},
- }, {
- }, {
+ }, {}, {
[2] = {
ast = {
len = REMOVE_THIS,
@@ -7025,7 +7029,7 @@ return function(itp, _check_parsing, hl, fmtn)
},
},
})
- check_parsing({data='01', size=1}, {
+ check_parsing({ data = '01', size = 1 }, {
len = 1,
ast = {
'Integer(val=0):0:0:0',
@@ -7033,7 +7037,7 @@ return function(itp, _check_parsing, hl, fmtn)
}, {
hl('Number', '0'),
})
- check_parsing({data='001', size=2}, {
+ check_parsing({ data = '001', size = 2 }, {
len = 2,
ast = {
'Integer(val=0):0:0:00',
@@ -7076,8 +7080,7 @@ return function(itp, _check_parsing, hl, fmtn)
arg = '|"\\U\\',
msg = 'E15: Expected value, got EOC: %.*s',
},
- }, {
- }, {
+ }, {}, {
[2] = {
ast = {
len = REMOVE_THIS,
@@ -7109,8 +7112,7 @@ return function(itp, _check_parsing, hl, fmtn)
arg = '|"\\e"',
msg = 'E15: Expected value, got EOC: %.*s',
},
- }, {
- }, {
+ }, {}, {
[2] = {
ast = {
len = REMOVE_THIS,
@@ -7142,8 +7144,7 @@ return function(itp, _check_parsing, hl, fmtn)
arg = '|\029',
msg = 'E15: Expected value, got EOC: %.*s',
},
- }, {
- }, {
+ }, {}, {
[2] = {
ast = {
len = REMOVE_THIS,
@@ -7373,7 +7374,7 @@ return function(itp, _check_parsing, hl, fmtn)
hl_fs = {
[2] = REMOVE_THIS,
[3] = REMOVE_THIS,
- }
+ },
},
})
diff --git a/test/unit/viml/helpers.lua b/test/unit/viml/helpers.lua
index 9d8102e023..92661e3027 100644
--- a/test/unit/viml/helpers.lua
+++ b/test/unit/viml/helpers.lua
@@ -76,7 +76,7 @@ local function pstate_set_str(pstate, start, len, ret)
ret = ret or {}
ret.start = {
line = tonumber(start.line),
- col = tonumber(start.col)
+ col = tonumber(start.col),
}
ret.len = tonumber(len)
ret.str, ret.error = pstate_str(pstate, start, len)
@@ -84,36 +84,57 @@ local function pstate_set_str(pstate, start, len, ret)
end
local eltkn_cmp_type_tab
-make_enum_conv_tab(lib, {
- 'kExprCmpEqual',
- 'kExprCmpMatches',
- 'kExprCmpGreater',
- 'kExprCmpGreaterOrEqual',
- 'kExprCmpIdentical',
-}, 'kExprCmp', function(ret) eltkn_cmp_type_tab = ret end)
+make_enum_conv_tab(
+ lib,
+ {
+ 'kExprCmpEqual',
+ 'kExprCmpMatches',
+ 'kExprCmpGreater',
+ 'kExprCmpGreaterOrEqual',
+ 'kExprCmpIdentical',
+ },
+ 'kExprCmp',
+ function(ret)
+ eltkn_cmp_type_tab = ret
+ end
+)
local function conv_cmp_type(typ)
return conv_enum(eltkn_cmp_type_tab, typ)
end
local ccs_tab
-make_enum_conv_tab(lib, {
- 'kCCStrategyUseOption',
- 'kCCStrategyMatchCase',
- 'kCCStrategyIgnoreCase',
-}, 'kCCStrategy', function(ret) ccs_tab = ret end)
+make_enum_conv_tab(
+ lib,
+ {
+ 'kCCStrategyUseOption',
+ 'kCCStrategyMatchCase',
+ 'kCCStrategyIgnoreCase',
+ },
+ 'kCCStrategy',
+ function(ret)
+ ccs_tab = ret
+ end
+)
local function conv_ccs(ccs)
return conv_enum(ccs_tab, ccs)
end
local expr_asgn_type_tab
-make_enum_conv_tab(lib, {
- 'kExprAsgnPlain',
- 'kExprAsgnAdd',
- 'kExprAsgnSubtract',
- 'kExprAsgnConcat',
-}, 'kExprAsgn', function(ret) expr_asgn_type_tab = ret end)
+make_enum_conv_tab(
+ lib,
+ {
+ 'kExprAsgnPlain',
+ 'kExprAsgnAdd',
+ 'kExprAsgnSubtract',
+ 'kExprAsgnConcat',
+ },
+ 'kExprAsgn',
+ function(ret)
+ expr_asgn_type_tab = ret
+ end
+)
local function conv_expr_asgn_type(expr_asgn_type)
return conv_enum(expr_asgn_type_tab, expr_asgn_type)