aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.git-blame-ignore-revs7
-rw-r--r--.github/workflows/commitlint.yml5
-rw-r--r--.github/workflows/labeler.yml4
-rw-r--r--cmake/RunTests.cmake1
-rw-r--r--runtime/autoload/health.vim23
-rw-r--r--runtime/autoload/health/provider.vim2
-rw-r--r--runtime/autoload/provider/pythonx.vim2
-rw-r--r--runtime/doc/autocmd.txt36
-rw-r--r--runtime/doc/change.txt6
-rw-r--r--runtime/doc/diagnostic.txt24
-rw-r--r--runtime/doc/editing.txt7
-rw-r--r--runtime/doc/eval.txt333
-rw-r--r--runtime/doc/nvim_terminal_emulator.txt6
-rw-r--r--runtime/doc/options.txt8
-rw-r--r--runtime/doc/pattern.txt2
-rw-r--r--runtime/doc/usr_41.txt2
-rw-r--r--runtime/doc/various.txt2
-rw-r--r--runtime/filetype.vim7
-rw-r--r--runtime/ftplugin/context.vim67
-rw-r--r--runtime/ftplugin/csh.vim49
-rw-r--r--runtime/ftplugin/tcsh.vim21
-rw-r--r--runtime/ftplugin/tmux.vim3
-rw-r--r--runtime/ftplugin/toml.vim23
-rw-r--r--runtime/indent/hamster.vim21
-rw-r--r--runtime/indent/sqlanywhere.vim22
-rw-r--r--runtime/indent/tcsh.vim13
-rw-r--r--runtime/lua/vim/diagnostic.lua104
-rw-r--r--runtime/lua/vim/lsp.lua112
-rw-r--r--runtime/lua/vim/lsp/rpc.lua5
-rw-r--r--runtime/lua/vim/lsp/util.lua1
-rw-r--r--runtime/lua/vim/uri.lua11
-rw-r--r--runtime/syntax/css.vim27
-rw-r--r--runtime/syntax/tcsh.vim66
-rw-r--r--runtime/syntax/tmux.vim103
-rw-r--r--runtime/syntax/toml.vim81
-rw-r--r--scripts/lintcommit.lua2
-rw-r--r--scripts/squash_typos.py94
-rw-r--r--src/mpack/conv.c1
-rw-r--r--src/mpack/lmpack.c6
-rw-r--r--src/nvim/api/buffer.c43
-rw-r--r--src/nvim/api/private/defs.h6
-rw-r--r--src/nvim/api/private/dispatch.c2
-rw-r--r--src/nvim/api/private/helpers.c70
-rw-r--r--src/nvim/api/private/helpers.h12
-rw-r--r--src/nvim/api/vim.c8
-rw-r--r--src/nvim/api/win_config.c2
-rw-r--r--src/nvim/arabic.h4
-rw-r--r--src/nvim/ascii.h2
-rw-r--r--src/nvim/assert.h40
-rw-r--r--src/nvim/autocmd.h30
-rw-r--r--src/nvim/buffer.c30
-rw-r--r--src/nvim/buffer.h48
-rw-r--r--src/nvim/buffer_defs.h325
-rw-r--r--src/nvim/change.c8
-rw-r--r--src/nvim/channel.c4
-rw-r--r--src/nvim/channel.h46
-rw-r--r--src/nvim/charset.h6
-rw-r--r--src/nvim/context.h1
-rw-r--r--src/nvim/cursor_shape.c5
-rw-r--r--src/nvim/cursor_shape.h44
-rw-r--r--src/nvim/debugger.c6
-rw-r--r--src/nvim/decoration.h8
-rw-r--r--src/nvim/diff.h2
-rw-r--r--src/nvim/digraph.c4
-rw-r--r--src/nvim/digraph.h2
-rw-r--r--src/nvim/edit.c8
-rw-r--r--src/nvim/edit.h38
-rw-r--r--src/nvim/eval.c98
-rw-r--r--src/nvim/eval.h260
-rw-r--r--src/nvim/eval.lua214
-rw-r--r--src/nvim/eval/decode.h3
-rw-r--r--src/nvim/eval/encode.c19
-rw-r--r--src/nvim/eval/encode.h6
-rw-r--r--src/nvim/eval/funcs.c45
-rw-r--r--src/nvim/eval/typval.c6
-rw-r--r--src/nvim/eval/typval.h177
-rw-r--r--src/nvim/eval/typval_encode.c.h789
-rw-r--r--src/nvim/eval/typval_encode.h38
-rw-r--r--src/nvim/eval/userfunc.h2
-rw-r--r--src/nvim/event/defs.h2
-rw-r--r--src/nvim/event/loop.h5
-rw-r--r--src/nvim/event/process.h2
-rw-r--r--src/nvim/event/rstream.h1
-rw-r--r--src/nvim/event/stream.h3
-rw-r--r--src/nvim/event/wstream.h3
-rw-r--r--src/nvim/ex_cmds.c31
-rw-r--r--src/nvim/ex_cmds.h14
-rw-r--r--src/nvim/ex_cmds2.c94
-rw-r--r--src/nvim/ex_cmds2.h25
-rw-r--r--src/nvim/ex_cmds_defs.h26
-rw-r--r--src/nvim/ex_docmd.c18
-rw-r--r--src/nvim/ex_docmd.h2
-rw-r--r--src/nvim/ex_eval.h56
-rw-r--r--src/nvim/ex_getln.c2
-rw-r--r--src/nvim/ex_getln.h2
-rw-r--r--src/nvim/ex_session.c2
-rw-r--r--src/nvim/extmark.c2
-rw-r--r--src/nvim/extmark.h2
-rw-r--r--src/nvim/extmark_defs.h2
-rw-r--r--src/nvim/file_search.c6
-rw-r--r--src/nvim/file_search.h14
-rw-r--r--src/nvim/fileio.h2
-rw-r--r--src/nvim/fold.c3
-rw-r--r--src/nvim/fold.h6
-rw-r--r--src/nvim/func_attr.h26
-rw-r--r--src/nvim/garray.c12
-rw-r--r--src/nvim/garray.h4
-rw-r--r--src/nvim/getchar.c14
-rw-r--r--src/nvim/getchar.h4
-rw-r--r--src/nvim/globals.h223
-rw-r--r--src/nvim/grid_defs.h6
-rw-r--r--src/nvim/hardcopy.c2
-rw-r--r--src/nvim/hardcopy.h16
-rw-r--r--src/nvim/hashtab.h20
-rw-r--r--src/nvim/highlight.c4
-rw-r--r--src/nvim/highlight.h5
-rw-r--r--src/nvim/iconv.h18
-rw-r--r--src/nvim/if_cscope.c6
-rw-r--r--src/nvim/if_cscope.h4
-rw-r--r--src/nvim/if_cscope_defs.h14
-rw-r--r--src/nvim/indent.c2
-rw-r--r--src/nvim/indent_c.c2
-rw-r--r--src/nvim/keymap.h30
-rw-r--r--src/nvim/lib/kbtree.h2
-rw-r--r--src/nvim/lib/khash.h2
-rw-r--r--src/nvim/lib/klist.h2
-rw-r--r--src/nvim/lib/kvec.h2
-rw-r--r--src/nvim/lib/queue.h2
-rw-r--r--src/nvim/lib/ringbuf.h2
-rw-r--r--src/nvim/log.h10
-rw-r--r--src/nvim/lua/converter.c6
-rw-r--r--src/nvim/lua/converter.h2
-rw-r--r--src/nvim/lua/executor.h16
-rw-r--r--src/nvim/lua/treesitter.c10
-rw-r--r--src/nvim/lua/treesitter.h2
-rw-r--r--src/nvim/lua/xdiff.h2
-rw-r--r--src/nvim/macros.h68
-rw-r--r--src/nvim/main.c16
-rw-r--r--src/nvim/main.h2
-rw-r--r--src/nvim/map.h6
-rw-r--r--src/nvim/mark.c7
-rw-r--r--src/nvim/mark.h56
-rw-r--r--src/nvim/mark_defs.h6
-rw-r--r--src/nvim/marktree.c14
-rw-r--r--src/nvim/marktree.h5
-rw-r--r--src/nvim/math.c1
-rw-r--r--src/nvim/mbyte.h26
-rw-r--r--src/nvim/memfile_defs.h4
-rw-r--r--src/nvim/memline.c2
-rw-r--r--src/nvim/memline.h4
-rw-r--r--src/nvim/memline_defs.h8
-rw-r--r--src/nvim/memory.h2
-rw-r--r--src/nvim/menu.c2
-rw-r--r--src/nvim/menu.h6
-rw-r--r--src/nvim/message.c4
-rw-r--r--src/nvim/message.h18
-rw-r--r--src/nvim/misc1.c10
-rw-r--r--src/nvim/misc1.h14
-rw-r--r--src/nvim/mouse.c12
-rw-r--r--src/nvim/mouse.h2
-rw-r--r--src/nvim/move.c1
-rw-r--r--src/nvim/move.h1
-rw-r--r--src/nvim/msgpack_rpc/channel.h4
-rw-r--r--src/nvim/msgpack_rpc/channel_defs.h4
-rw-r--r--src/nvim/msgpack_rpc/helpers.c91
-rw-r--r--src/nvim/msgpack_rpc/helpers.h8
-rw-r--r--src/nvim/normal.h43
-rw-r--r--src/nvim/ops.c22
-rw-r--r--src/nvim/ops.h10
-rw-r--r--src/nvim/option.c12
-rw-r--r--src/nvim/option.h8
-rw-r--r--src/nvim/option_defs.h436
-rw-r--r--src/nvim/os/input.h2
-rw-r--r--src/nvim/os/os.h4
-rw-r--r--src/nvim/os/os_defs.h2
-rw-r--r--src/nvim/os/os_win_console.c26
-rw-r--r--src/nvim/os/process.h1
-rw-r--r--src/nvim/os/time.h2
-rw-r--r--src/nvim/os/unix_defs.h2
-rw-r--r--src/nvim/os/win_defs.h7
-rw-r--r--src/nvim/os_unix.h2
-rw-r--r--src/nvim/path.c5
-rw-r--r--src/nvim/path.h28
-rw-r--r--src/nvim/popupmnu.h4
-rw-r--r--src/nvim/pos.h8
-rw-r--r--src/nvim/profile.h4
-rw-r--r--src/nvim/quickfix.c4
-rw-r--r--src/nvim/quickfix.h4
-rw-r--r--src/nvim/rbuffer.h30
-rw-r--r--src/nvim/regexp.c2
-rw-r--r--src/nvim/regexp.h2
-rw-r--r--src/nvim/regexp_defs.h30
-rw-r--r--src/nvim/regexp_nfa.c2
-rw-r--r--src/nvim/runtime.c51
-rw-r--r--src/nvim/screen.c9
-rw-r--r--src/nvim/screen.h14
-rw-r--r--src/nvim/search.h48
-rw-r--r--src/nvim/sha256.h2
-rw-r--r--src/nvim/shada.c53
-rw-r--r--src/nvim/sign.c10
-rw-r--r--src/nvim/sign.h1
-rw-r--r--src/nvim/sign_defs.h33
-rw-r--r--src/nvim/spell.c4
-rw-r--r--src/nvim/spell.h2
-rw-r--r--src/nvim/spell_defs.h78
-rw-r--r--src/nvim/spellfile.c2
-rw-r--r--src/nvim/spellfile.h2
-rw-r--r--src/nvim/state.c2
-rw-r--r--src/nvim/state.h4
-rw-r--r--src/nvim/strings.h4
-rw-r--r--src/nvim/syntax.c37
-rw-r--r--src/nvim/syntax.h44
-rw-r--r--src/nvim/syntax_defs.h32
-rw-r--r--src/nvim/tag.c4
-rw-r--r--src/nvim/tag.h32
-rw-r--r--src/nvim/terminal.c23
-rw-r--r--src/nvim/terminal.h2
-rw-r--r--src/nvim/testdir/samples/memfile_test.c2
-rw-r--r--src/nvim/testdir/test_arglist.vim2
-rw-r--r--src/nvim/testdir/test_breakindent.vim6
-rw-r--r--src/nvim/testdir/test_bufline.vim8
-rw-r--r--src/nvim/testdir/test_bufwintabinfo.vim6
-rw-r--r--src/nvim/testdir/test_changelist.vim4
-rw-r--r--src/nvim/testdir/test_clientserver.vim12
-rw-r--r--src/nvim/testdir/test_cmdline.vim2
-rw-r--r--src/nvim/testdir/test_cursor_func.vim6
-rw-r--r--src/nvim/testdir/test_edit.vim6
-rw-r--r--src/nvim/testdir/test_environ.vim2
-rw-r--r--src/nvim/testdir/test_escaped_glob.vim6
-rw-r--r--src/nvim/testdir/test_expand_func.vim9
-rw-r--r--src/nvim/testdir/test_expr.vim4
-rw-r--r--src/nvim/testdir/test_filetype.vim21
-rw-r--r--src/nvim/testdir/test_findfile.vim4
-rw-r--r--src/nvim/testdir/test_float_func.vim1
-rw-r--r--src/nvim/testdir/test_fnameescape.vim2
-rw-r--r--src/nvim/testdir/test_fnamemodify.vim2
-rw-r--r--src/nvim/testdir/test_fold.vim8
-rw-r--r--src/nvim/testdir/test_functions.vim102
-rw-r--r--src/nvim/testdir/test_getcwd.vim4
-rw-r--r--src/nvim/testdir/test_getvar.vim8
-rw-r--r--src/nvim/testdir/test_glob2regpat.vim2
-rw-r--r--src/nvim/testdir/test_history.vim8
-rw-r--r--src/nvim/testdir/test_jumplist.vim2
-rw-r--r--src/nvim/testdir/test_lispwords.vim3
-rw-r--r--src/nvim/testdir/test_listdict.vim2
-rw-r--r--src/nvim/testdir/test_maparg.vim42
-rw-r--r--src/nvim/testdir/test_match.vim8
-rw-r--r--src/nvim/testdir/test_perl.vim2
-rw-r--r--src/nvim/testdir/test_prompt_buffer.vim7
-rw-r--r--src/nvim/testdir/test_python2.vim2
-rw-r--r--src/nvim/testdir/test_python3.vim2
-rw-r--r--src/nvim/testdir/test_pyx2.vim2
-rw-r--r--src/nvim/testdir/test_reltime.vim6
-rw-r--r--src/nvim/testdir/test_rename.vim2
-rw-r--r--src/nvim/testdir/test_search.vim2
-rw-r--r--src/nvim/testdir/test_stat.vim6
-rw-r--r--src/nvim/testdir/test_syn_attr.vim2
-rw-r--r--src/nvim/testdir/test_tagjump.vim2
-rw-r--r--src/nvim/testdir/test_true_false.vim2
-rw-r--r--src/nvim/testdir/test_utf8.vim2
-rw-r--r--src/nvim/testdir/test_vimscript.vim2
-rw-r--r--src/nvim/tui/input.h2
-rw-r--r--src/nvim/tui/terminfo_defs.h2
-rw-r--r--src/nvim/tui/tui.c28
-rw-r--r--src/nvim/types.h2
-rw-r--r--src/nvim/ugrid.h2
-rw-r--r--src/nvim/ui.h5
-rw-r--r--src/nvim/ui_bridge.h4
-rw-r--r--src/nvim/ui_compositor.c8
-rw-r--r--src/nvim/ui_compositor.h2
-rw-r--r--src/nvim/undo.c2
-rw-r--r--src/nvim/undo.h2
-rw-r--r--src/nvim/undo_defs.h44
-rw-r--r--src/nvim/version.c10
-rw-r--r--src/nvim/version.h4
-rw-r--r--src/nvim/vim.h17
-rw-r--r--src/nvim/viml/parser/expressions.h16
-rw-r--r--src/nvim/viml/parser/parser.h31
-rw-r--r--src/nvim/window.c2
-rw-r--r--src/nvim/window.h30
-rw-r--r--src/uncrustify.cfg19
-rw-r--r--test/functional/api/vim_spec.lua45
-rw-r--r--test/functional/ex_cmds/source_spec.lua20
-rw-r--r--test/functional/fixtures/fake-lsp-server.lua29
-rw-r--r--test/functional/legacy/delete_spec.lua9
-rw-r--r--test/functional/legacy/expand_spec.lua2
-rw-r--r--test/functional/legacy/file_perm_spec.lua7
-rw-r--r--test/functional/legacy/fnamemodify_spec.lua11
-rw-r--r--test/functional/lua/api_spec.lua4
-rw-r--r--test/functional/lua/buffer_updates_spec.lua96
-rw-r--r--test/functional/lua/diagnostic_spec.lua110
-rw-r--r--test/functional/lua/luaeval_spec.lua7
-rw-r--r--test/functional/lua/uri_spec.lua17
-rw-r--r--test/functional/plugin/health_spec.lua4
-rw-r--r--test/functional/plugin/lsp_spec.lua81
-rw-r--r--test/functional/terminal/buffer_spec.lua24
-rw-r--r--test/functional/terminal/ex_terminal_spec.lua15
-rw-r--r--test/functional/terminal/mouse_spec.lua10
-rw-r--r--test/functional/terminal/window_split_tab_spec.lua2
-rw-r--r--test/functional/vimscript/json_functions_spec.lua8
-rw-r--r--third-party/CMakeLists.txt4
301 files changed, 4120 insertions, 3118 deletions
diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs
index e5ee140301..bbca6b3339 100644
--- a/.git-blame-ignore-revs
+++ b/.git-blame-ignore-revs
@@ -29,3 +29,10 @@ d5b66e88601b4d2fde5d905f9d12847126ba4449
30fefee684e641a0c6867446c6de30efa2f0a126
f4ca3a29ddcb0c98e8e09c45a6342af709f8cc45
48e67b229415b4e2b3315bd00b817e5f9ab970c8
+7a26eb8a567cbc831d4f629f9eccb767a44436b8
+2f9b9e61d7417183f2d9f36d804247c0926be9d4
+c0767bd4f3ce7b34bb77da0657c49ba10ba1b32e
+d90fb1c0bfc1e64c783c385a79e7de87013dadba
+9c268263b1792d00b3ffdfd7495af2575862656e
+8c74c895b300bcee5fa937a2329d1d4756567b42
+40be47e0faef7aa015eb4ba44ceb1ee1a03e97cf
diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml
index 4c9c526946..09df580b45 100644
--- a/.github/workflows/commitlint.yml
+++ b/.github/workflows/commitlint.yml
@@ -1,8 +1,11 @@
name: "Commit Linter"
-on: pull_request
+on:
+ pull_request:
+ types: [opened, synchronize, reopened, ready_for_review]
jobs:
lint-commits:
runs-on: ubuntu-latest
+ if: github.event.pull_request.draft == false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml
index c7a331c657..4aa56f5d0e 100644
--- a/.github/workflows/labeler.yml
+++ b/.github/workflows/labeler.yml
@@ -24,7 +24,7 @@ jobs:
- run: gh pr checkout ${{ github.event.pull_request.number }}
# Extract type and try to add it as a label
- - run: gh pr edit --add-label "$(echo "${{ github.event.pull_request.title }}" | sed -E 's|([[:alpha:]]+)(\(.*\))?:.*|\1|')" || true
+ - run: gh pr edit --add-label "$(echo "${{ github.event.pull_request.title }}" | sed -E 's|([[:alpha:]]+)(\(.*\))?!?:.*|\1|')" || true
# Extract scope and try to add it as a label
- - run: gh pr edit --add-label "$(echo "${{ github.event.pull_request.title }}" | sed -E 's|[[:alpha:]]+\((.+)\):.*|\1|')" || true
+ - run: gh pr edit --add-label "$(echo "${{ github.event.pull_request.title }}" | sed -E 's|[[:alpha:]]+\((.+)\)!?:.*|\1|')" || true
diff --git a/cmake/RunTests.cmake b/cmake/RunTests.cmake
index 0c48a77b9a..e78392562f 100644
--- a/cmake/RunTests.cmake
+++ b/cmake/RunTests.cmake
@@ -10,6 +10,7 @@ set(ENV{VIMRUNTIME} ${WORKING_DIR}/runtime)
set(ENV{NVIM_RPLUGIN_MANIFEST} ${BUILD_DIR}/Xtest_rplugin_manifest)
set(ENV{XDG_CONFIG_HOME} ${BUILD_DIR}/Xtest_xdg/config)
set(ENV{XDG_DATA_HOME} ${BUILD_DIR}/Xtest_xdg/share)
+unset(ENV{XDG_DATA_DIRS})
if(NOT DEFINED ENV{NVIM_LOG_FILE})
set(ENV{NVIM_LOG_FILE} ${BUILD_DIR}/.nvimlog)
diff --git a/runtime/autoload/health.vim b/runtime/autoload/health.vim
index 579db62cb8..73c1459f86 100644
--- a/runtime/autoload/health.vim
+++ b/runtime/autoload/health.vim
@@ -181,21 +181,20 @@ function! s:get_healthcheck(plugin_names) abort
let health_list = s:get_healthcheck_list(a:plugin_names)
let healthchecks = {}
for c in health_list
- let name = c[0]
- let existent = get(healthchecks, name, [])
- " If an entry with the same name exists and is from vim, prefer Lua so
- " overwrite it.
- if existent != []
- if existent[1] == "v"
- let healthchecks[name] = c[1:]
- else
- continue
- endif
+ let normalized_name = substitute(c[0], '-', '_', 'g')
+ let existent = get(healthchecks, normalized_name, [])
+ " Prefer Lua over vim entries
+ if existent != [] && existent[2] == 'l'
+ continue
else
- let healthchecks[name] = c[1:]
+ let healthchecks[normalized_name] = c
endif
endfor
- return healthchecks
+ let output = {}
+ for v in values(healthchecks)
+ let output[v[0]] = v[1:]
+ endfor
+ return output
endfunction
" Returns list of lists [ [{name}, {func}, {type}] ] representing healthchecks
diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim
index 001379c85d..7b4dce3441 100644
--- a/runtime/autoload/health/provider.vim
+++ b/runtime/autoload/health/provider.vim
@@ -710,7 +710,7 @@ function! s:check_perl() abort
let latest_cpan = s:system(latest_cpan_cmd)
if s:shell_error || empty(latest_cpan)
- call health#report_error('Failed to run: '. latest_cpan_cmd,
+ call health#report_error('Failed to run: '. join(latest_cpan_cmd, " "),
\ ["Make sure you're connected to the internet.",
\ 'Are you behind a firewall or proxy?'])
return
diff --git a/runtime/autoload/provider/pythonx.vim b/runtime/autoload/provider/pythonx.vim
index c292b374b6..0eeb35cba8 100644
--- a/runtime/autoload/provider/pythonx.vim
+++ b/runtime/autoload/provider/pythonx.vim
@@ -96,7 +96,7 @@ function! provider#pythonx#CheckForModule(prog, module, major_version) abort
if prog_version !~ '^' . a:major_version
return [0, prog_path . ' is Python ' . prog_version . ' and cannot provide Python '
\ . a:major_version . '.']
- elseif prog_version =~ '^' . a:major_version && prog_version < min_version
+ elseif prog_version =~ '^' . a:major_version && str2nr(prog_version[2:]) < str2nr(min_version[2:])
return [0, prog_path . ' is Python ' . prog_version . ' and cannot provide Python >= '
\ . min_version . '.']
endif
diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt
index de74ee891e..5923dada43 100644
--- a/runtime/doc/autocmd.txt
+++ b/runtime/doc/autocmd.txt
@@ -630,7 +630,7 @@ FilterReadPre Before reading a file from a filter command.
*FilterWritePost*
FilterWritePost After writing a file for a filter command or
making a diff with an external diff (see
- DiffUpdated for internal diff).
+ |DiffUpdated| for internal diff).
Vim checks the pattern against the name of
the current buffer as with FilterWritePre.
Not triggered when 'shelltemp' is off.
@@ -683,23 +683,6 @@ InsertCharPre When a character is typed in Insert mode,
Cannot change the text. |textlock|
Not triggered when 'paste' is set.
- *TextYankPost*
-TextYankPost Just after a |yank| or |deleting| command, but not
- if the black hole register |quote_| is used nor
- for |setreg()|. Pattern must be *.
- Sets these |v:event| keys:
- inclusive
- operator
- regcontents
- regname
- regtype
- visual
- The `inclusive` flag combined with the |'[|
- and |']| marks can be used to calculate the
- precise region of the operation.
-
- Non-recursive (event cannot trigger itself).
- Cannot change the text. |textlock|
*InsertEnter*
InsertEnter Just before starting Insert mode. Also for
Replace mode and Virtual Replace mode. The
@@ -948,6 +931,23 @@ TextChangedP After a change was made to the text in the
current buffer in Insert mode, only when the
popup menu is visible. Otherwise the same as
TextChanged.
+ *TextYankPost*
+TextYankPost Just after a |yank| or |deleting| command, but not
+ if the black hole register |quote_| is used nor
+ for |setreg()|. Pattern must be *.
+ Sets these |v:event| keys:
+ inclusive
+ operator
+ regcontents
+ regname
+ regtype
+ visual
+ The `inclusive` flag combined with the |'[|
+ and |']| marks can be used to calculate the
+ precise region of the operation.
+
+ Non-recursive (event cannot trigger itself).
+ Cannot change the text. |textlock|
*User*
User Not executed automatically. Use |:doautocmd|
to trigger this, typically for "custom events"
diff --git a/runtime/doc/change.txt b/runtime/doc/change.txt
index 2b799e3e27..ffdd8427f9 100644
--- a/runtime/doc/change.txt
+++ b/runtime/doc/change.txt
@@ -1129,9 +1129,6 @@ a register, a paste on a visual selected area will paste that single line on
each of the selected lines (thus replacing the blockwise selected region by a
block of the pasted line).
-Use |zP|/|zp| to paste a blockwise yanked register without appending trailing
-spaces.
-
*blockwise-register*
If you use a blockwise Visual mode command to get the text into the register,
the block of text will be inserted before ("P") or after ("p") the cursor
@@ -1142,6 +1139,9 @@ this happen. However, if the width of the block is not a multiple of a <Tab>
width and the text after the inserted block contains <Tab>s, that text may be
misaligned.
+Use |zP|/|zp| to paste a blockwise yanked register without appending trailing
+spaces.
+
Note that after a charwise yank command, Vim leaves the cursor on the first
yanked character that is closest to the start of the buffer. This means that
"yl" doesn't move the cursor, but "yh" moves the cursor one character left.
diff --git a/runtime/doc/diagnostic.txt b/runtime/doc/diagnostic.txt
index 75c8a2ad6f..17d317522b 100644
--- a/runtime/doc/diagnostic.txt
+++ b/runtime/doc/diagnostic.txt
@@ -254,12 +254,31 @@ config({opts}, {namespace}) *vim.diagnostic.config()*
Configure diagnostic options globally or for a specific
diagnostic namespace.
+ Configuration can be specified globally, per-namespace, or
+ ephemerally (i.e. only for a single call to
+ |vim.diagnostic.set()| or |vim.diagnostic.show()|). Ephemeral
+ configuration has highest priority, followed by namespace
+ configuration, and finally global configuration.
+
+ For example, if a user enables virtual text globally with >
+
+ vim.diagnostic.config({virt_text = true})
+<
+
+ and a diagnostic producer sets diagnostics with >
+
+ vim.diagnostic.set(ns, 0, diagnostics, {virt_text = false})
+<
+
+ then virtual text will not be enabled for those diagnostics.
+
Note:
Each of the configuration options below accepts one of the
following:
• `false` : Disable this feature
• `true` : Enable this feature, use default settings.
- • `table` : Enable this feature with overrides.
+ • `table` : Enable this feature with overrides. Use an
+ empty table to use default values.
• `function` : Function with signature (namespace, bufnr)
that returns any of the above.
@@ -460,8 +479,9 @@ match({str}, {pat}, {groups}, {severity_map}, {defaults})
For example, consider a line of output from a linter: >
WARNING filename:27:3: Variable 'foo' does not exist
+<
- < This can be parsed into a diagnostic |diagnostic-structure|
+ This can be parsed into a diagnostic |diagnostic-structure|
with: >
local s = "WARNING filename:27:3: Variable 'foo' does not exist"
diff --git a/runtime/doc/editing.txt b/runtime/doc/editing.txt
index 0e7e461a61..f91e4f0627 100644
--- a/runtime/doc/editing.txt
+++ b/runtime/doc/editing.txt
@@ -1310,7 +1310,7 @@ change anything for the current directory.
When |:lcd| has been used for a window, the specified directory becomes the
current directory for that window. Windows where the |:lcd| command has not
been used stick to the global or tab-local directory. When jumping to another
-window the current directory will become the last specified local current
+window the current directory is changed to the last specified local current
directory. If none was specified, the global or tab-local directory is used.
When changing tabs the same behaviour applies. If the current tab has no
@@ -1467,6 +1467,11 @@ It is also possible that you modified the file yourself, from another edit
session or with another command (e.g., a filter command). Then you will know
which version of the file you want to keep.
+The accuracy of the time check depends on the filesystem. On Unix it is
+usually sub-second. With old file sytems and on MS-Windows it is normally one
+second. Use has('nanotime') check if sub-second time stamp checks are
+available.
+
There is one situation where you get the message while there is nothing wrong:
On a Win32 system on the day daylight saving time starts. There is something
in the Win32 libraries that confuses Vim about the hour time difference. The
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index fe19bb3134..e956ccaa77 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -1204,7 +1204,7 @@ next method: >
mylist->filter(filterexpr)->map(mapexpr)->sort()->join()
<
Example of using a lambda: >
- GetPercentage->{x -> x * 100}()->printf('%d%%')
+ GetPercentage()->{x -> x * 100}()->printf('%d%%')
<
When using -> the |expr7| operators will be applied first, thus: >
-1.234->string()
@@ -2505,7 +2505,7 @@ keys({dict}) List keys in {dict}
len({expr}) Number the length of {expr}
libcall({lib}, {func}, {arg}) String call {func} in library {lib} with {arg}
libcallnr({lib}, {func}, {arg}) Number idem, but return a Number
-line({expr}) Number line nr of cursor, last line or mark
+line({expr} [, {winid}]) Number line nr of cursor, last line or mark
line2byte({lnum}) Number byte count of line {lnum}
lispindent({lnum}) Number Lisp indent for line {lnum}
list2str({list} [, {utf8}]) String turn numbers in {list} into a String
@@ -3831,6 +3831,9 @@ escape({string}, {chars}) *escape()*
c:\\program\ files\\vim
< Also see |shellescape()| and |fnameescape()|.
+ Can also be used as a |method|: >
+ GetText()->escape(' \')
+<
*eval()*
eval({string}) Evaluate {string} and return the result. Especially useful to
turn the result of |string()| back into the original value.
@@ -3870,6 +3873,9 @@ executable({expr}) *executable()*
-1 not implemented on this system
|exepath()| can be used to get the full path of an executable.
+ Can also be used as a |method|: >
+ GetCommand()->executable()
+
execute({command} [, {silent}]) *execute()*
Execute {command} and capture its output.
If {command} is a |String|, returns {command} output.
@@ -3897,12 +3903,18 @@ execute({command} [, {silent}]) *execute()*
To execute a command in another window than the current one
use `win_execute()`.
+ Can also be used as a |method|: >
+ GetCommand()->execute()
+
exepath({expr}) *exepath()*
Returns the full path of {expr} if it is an executable and
given as a (partial or full) path or is found in $PATH.
Returns empty string otherwise.
If {expr} starts with "./" the |current-directory| is used.
+ Can also be used as a |method|: >
+ GetCommand()->exepath()
+
*exists()*
exists({expr}) The result is a Number, which is |TRUE| if {expr} is
defined, zero otherwise.
@@ -3988,6 +4000,9 @@ exists({expr}) The result is a Number, which is |TRUE| if {expr} is
< This doesn't check for existence of the "bufcount" variable,
but gets the value of "bufcount", and checks if that exists.
+ Can also be used as a |method|: >
+ Varname()->exists()
+
exp({expr}) *exp()*
Return the exponential of {expr} as a |Float| in the range
[0, inf].
@@ -4094,6 +4109,9 @@ expand({string} [, {nosuf} [, {list}]]) *expand()*
See |glob()| for finding existing files. See |system()| for
getting the raw output of an external command.
+ Can also be used as a |method|: >
+ Getpattern()->expand()
+
expandcmd({expr}) *expandcmd()*
Expand special items in {expr} like what is done for an Ex
command such as `:edit`. This expands special keywords, like
@@ -4101,6 +4119,9 @@ expandcmd({expr}) *expandcmd()*
{expr}. "~user" and "~/path" are only expanded at the start.
Returns the expanded string. Example: >
:echo expandcmd('make %<.o')
+
+< Can also be used as a |method|: >
+ GetCommand()->expandcmd()
<
extend({expr1}, {expr2} [, {expr3}]) *extend()*
{expr1} and {expr2} must be both |Lists| or both
@@ -4186,6 +4207,9 @@ feedkeys({string} [, {mode}]) *feedkeys()*
Return value is always 0.
+ Can also be used as a |method|: >
+ GetInput()->feedkeys()
+
filereadable({file}) *filereadable()*
The result is a Number, which is |TRUE| when a file with the
name {file} exists, and can be read. If {file} doesn't exist,
@@ -4199,12 +4223,17 @@ filereadable({file}) *filereadable()*
echo filereadable(expand('~/.vimrc'))
1
+< Can also be used as a |method|: >
+ GetName()->filereadable()
+
filewritable({file}) *filewritable()*
The result is a Number, which is 1 when a file with the
name {file} exists, and can be written. If {file} doesn't
exist, or is not writable, the result is 0. If {file} is a
directory, and we can write to it, the result is 2.
+ Can also be used as a |method|: >
+ GetName()->filewriteable()
filter({expr1}, {expr2}) *filter()*
{expr1} must be a |List|, |Blob|, or a |Dictionary|.
@@ -4275,6 +4304,9 @@ finddir({name} [, {path} [, {count}]]) *finddir()*
This is quite similar to the ex-command `:find`.
+ Can also be used as a |method|: >
+ GetName()->finddir()
+
findfile({name} [, {path} [, {count}]]) *findfile()*
Just like |finddir()|, but find a file instead of a directory.
Uses 'suffixesadd'.
@@ -4283,6 +4315,9 @@ findfile({name} [, {path} [, {count}]]) *findfile()*
< Searches from the directory of the current file upwards until
it finds the file "tags.vim".
+ Can also be used as a |method|: >
+ GetName()->findfile()
+
flatten({list} [, {maxdepth}]) *flatten()*
Flatten {list} up to {maxdepth} levels. Without {maxdepth}
the result is a |List| without nesting, as if {maxdepth} is
@@ -4372,6 +4407,9 @@ fnameescape({string}) *fnameescape()*
:exe "edit " . fnameescape(fname)
< results in executing: >
edit \+some\ str\%nge\|name
+<
+ Can also be used as a |method|: >
+ GetName()->fnameescape()
fnamemodify({fname}, {mods}) *fnamemodify()*
Modify file name {fname} according to {mods}. {mods} is a
@@ -4385,6 +4423,9 @@ fnamemodify({fname}, {mods}) *fnamemodify()*
Note: Environment variables don't work in {fname}, use
|expand()| first then.
+ Can also be used as a |method|: >
+ GetName()->fnamemodify(':p:h')
+
foldclosed({lnum}) *foldclosed()*
The result is a Number. If the line {lnum} is in a closed
fold, the result is the number of the first line in that fold.
@@ -4392,6 +4433,9 @@ foldclosed({lnum}) *foldclosed()*
{lnum} is used like with |getline()|. Thus "." is the current
line, "'m" mark m, etc.
+ Can also be used as a |method|: >
+ GetLnum()->foldclosed()
+
foldclosedend({lnum}) *foldclosedend()*
The result is a Number. If the line {lnum} is in a closed
fold, the result is the number of the last line in that fold.
@@ -4399,6 +4443,9 @@ foldclosedend({lnum}) *foldclosedend()*
{lnum} is used like with |getline()|. Thus "." is the current
line, "'m" mark m, etc.
+ Can also be used as a |method|: >
+ GetLnum()->foldclosedend()
+
foldlevel({lnum}) *foldlevel()*
The result is a Number, which is the foldlevel of line {lnum}
in the current buffer. For nested folds the deepest level is
@@ -4411,6 +4458,9 @@ foldlevel({lnum}) *foldlevel()*
{lnum} is used like with |getline()|. Thus "." is the current
line, "'m" mark m, etc.
+ Can also be used as a |method|: >
+ GetLnum()->foldlevel()
+
*foldtext()*
foldtext() Returns a String, to be displayed for a closed fold. This is
the default function used for the 'foldtext' option and should
@@ -4436,6 +4486,9 @@ foldtextresult({lnum}) *foldtextresult()*
line, "'m" mark m, etc.
Useful when exporting folded text, e.g., to HTML.
+ Can also be used as a |method|: >
+ GetLnum()->foldtextresult()
+<
*foreground()*
foreground() Move the Vim window to the foreground. Useful when sent from
a client to a Vim server. |remote_send()|
@@ -4454,6 +4507,9 @@ funcref({name} [, {arglist}] [, {dict}])
Also for autoloaded functions. {name} cannot be a builtin
function.
+ Can also be used as a |method|: >
+ GetFuncname()->funcref([arg])
+<
*function()* *E700* *E922* *E923*
function({name} [, {arglist}] [, {dict}])
Return a |Funcref| variable that refers to function {name}.
@@ -4503,7 +4559,9 @@ function({name} [, {arglist}] [, {dict}])
call Func(500)
< Invokes the function as with: >
call context.Callback('one', 500)
-
+<
+ Can also be used as a |method|: >
+ GetFuncname()->function([arg])
garbagecollect([{atexit}]) *garbagecollect()*
Cleanup unused |Lists| and |Dictionaries| that have circular
@@ -4643,6 +4701,9 @@ getbufline({buf}, {lnum} [, {end}])
Example: >
:let lines = getbufline(bufnr("myfile"), 1, "$")
+< Can also be used as a |method|: >
+ GetBufnr()->getbufline(lnum)
+
getbufvar({buf}, {varname} [, {def}]) *getbufvar()*
The result is the value of option or local buffer variable
{varname} in buffer {buf}. Note that the name without "b:"
@@ -4663,8 +4724,11 @@ getbufvar({buf}, {varname} [, {def}]) *getbufvar()*
Examples: >
:let bufmodified = getbufvar(1, "&mod")
:echo "todo myvar = " . getbufvar("todo", "myvar")
+
+< Can also be used as a |method|: >
+ GetBufnr()->getbufvar(varname)
<
-getchangelist({buf}) *getchangelist()*
+getchangelist([{buf}]) *getchangelist()*
Returns the |changelist| for the buffer {buf}. For the use
of {buf}, see |bufname()| above. If buffer {buf} doesn't
exist, an empty list is returned.
@@ -4680,6 +4744,9 @@ getchangelist({buf}) *getchangelist()*
position refers to the position in the list. For other
buffers, it is set to the length of the list.
+ Can also be used as a |method|: >
+ GetBufnr()->getchangelist()
+
getchar([expr]) *getchar()*
Get a single character from the user or input stream.
If [expr] is omitted, wait until a character is available.
@@ -4890,6 +4957,9 @@ getcompletion({pat}, {type} [, {filtered}]) *getcompletion()*
If there are no matches, an empty list is returned. An
invalid value for {type} produces an error.
+ Can also be used as a |method|: >
+ GetPattern()->getcompletion('color')
+<
*getcurpos()*
getcurpos() Get the position of the cursor. This is like getpos('.'), but
includes an extra "curswant" in the list:
@@ -4918,6 +4988,9 @@ getcwd([{winnr}[, {tabnr}]]) *getcwd()*
< If {winnr} is -1 it is ignored, only the tab is resolved.
{winnr} can be the window number or the |window-ID|.
+ Can also be used as a |method|: >
+ GetWinnr()->getcwd()
+
getenv({name}) *getenv()*
Return the value of environment variable {name}. The {name}
argument is a string, without a leading '$'. Example: >
@@ -4927,6 +5000,9 @@ getenv({name}) *getenv()*
is different from a variable set to an empty string.
See also |expr-env|.
+ Can also be used as a |method|: >
+ GetVarname()->getenv()
+
getfontname([{name}]) *getfontname()*
Without an argument returns the name of the normal font being
used. Like what is used for the Normal highlight group
@@ -4954,6 +5030,9 @@ getfperm({fname}) *getfperm()*
< This will hopefully (from a security point of view) display
the string "rw-r--r--" or even "rw-------".
+ Can also be used as a |method|: >
+ GetFilename()->getfperm()
+<
For setting permissions use |setfperm()|.
getfsize({fname}) *getfsize()*
@@ -4964,6 +5043,9 @@ getfsize({fname}) *getfsize()*
If the size of {fname} is too big to fit in a Number then -2
is returned.
+ Can also be used as a |method|: >
+ GetFilename()->getfsize()
+
getftime({fname}) *getftime()*
The result is a Number, which is the last modification time of
the given file {fname}. The value is measured as seconds
@@ -4971,6 +5053,9 @@ getftime({fname}) *getftime()*
|localtime()| and |strftime()|.
If the file {fname} can't be found -1 is returned.
+ Can also be used as a |method|: >
+ GetFilename()->getftime()
+
getftype({fname}) *getftype()*
The result is a String, which is a description of the kind of
file of the given file {fname}.
@@ -4991,6 +5076,9 @@ getftype({fname}) *getftype()*
systems that support it. On some systems only "dir" and
"file" are returned.
+ Can also be used as a |method|: >
+ GetFilename()->getftype()
+
getjumplist([{winnr} [, {tabnr}]]) *getjumplist()*
Returns the |jumplist| for the specified window.
@@ -5010,7 +5098,10 @@ getjumplist([{winnr} [, {tabnr}]]) *getjumplist()*
filename filename if available
lnum line number
- *getline()*
+ Can also be used as a |method|: >
+ GetWinnr()->getjumplist()
+
+< *getline()*
getline({lnum} [, {end}])
Without {end} the result is a String, which is line {lnum}
from the current buffer. Example: >
@@ -5033,6 +5124,9 @@ getline({lnum} [, {end}])
:let end = search("^$") - 1
:let lines = getline(start, end)
+< Can also be used as a |method|: >
+ ComputeLnum()->getline()
+
< To get lines from another buffer see |getbufline()|
getloclist({nr},[, {what}]) *getloclist()*
@@ -5163,6 +5257,8 @@ getpos({expr}) Get the position for String {expr}. For possible values of
call setpos("'a", save_a_mark)
< Also see |getcurpos()| and |setpos()|.
+ Can also be used as a |method|: >
+ GetMark()->getpos()
getqflist([{what}]) *getqflist()*
Returns a |List| with all the current quickfix errors. Each
@@ -5281,6 +5377,9 @@ getreg([{regname} [, 1 [, {list}]]]) *getreg()*
If {regname} is not specified, |v:register| is used.
+ Can also be used as a |method|: >
+ GetRegname()->getreg()
+
getreginfo([{regname}]) *getreginfo()*
Returns detailed information about register {regname} as a
Dictionary with the following entries:
@@ -5319,6 +5418,9 @@ getregtype([{regname}]) *getregtype()*
The {regname} argument is a string. If {regname} is not
specified, |v:register| is used.
+ Can also be used as a |method|: >
+ GetRegname()->getregtype()
+
gettabinfo([{tabnr}]) *gettabinfo()*
If {tabnr} is not specified, then information about all the
tab pages is returned as a |List|. Each List item is a
@@ -5332,6 +5434,9 @@ gettabinfo([{tabnr}]) *gettabinfo()*
tabpage-local variables
windows List of |window-ID|s in the tab page.
+ Can also be used as a |method|: >
+ GetTabnr()->gettabinfo()
+
gettabvar({tabnr}, {varname} [, {def}]) *gettabvar()*
Get the value of a tab-local variable {varname} in tab page
{tabnr}. |t:var|
@@ -5342,6 +5447,9 @@ gettabvar({tabnr}, {varname} [, {def}]) *gettabvar()*
When the tab or variable doesn't exist {def} or an empty
string is returned, there is no error message.
+ Can also be used as a |method|: >
+ GetTabnr()->gettabvar(varname)
+
gettabwinvar({tabnr}, {winnr}, {varname} [, {def}]) *gettabwinvar()*
Get the value of window-local variable {varname} in window
{winnr} in tab page {tabnr}.
@@ -5368,6 +5476,9 @@ gettabwinvar({tabnr}, {winnr}, {varname} [, {def}]) *gettabwinvar()*
To obtain all window-local variables use: >
gettabwinvar({tabnr}, {winnr}, '&')
+< Can also be used as a |method|: >
+ GetTabnr()->gettabwinvar(winnr, varname)
+
gettagstack([{winnr}]) *gettagstack()*
The result is a Dict, which is the tag stack of window {winnr}.
{winnr} can be the window number or the |window-ID|.
@@ -5396,6 +5507,9 @@ gettagstack([{winnr}]) *gettagstack()*
See |tagstack| for more information about the tag stack.
+ Can also be used as a |method|: >
+ GetWinnr()->gettagstack()
+
getwininfo([{winid}]) *getwininfo()*
Returns information about windows as a |List| with Dictionaries.
@@ -5427,6 +5541,9 @@ getwininfo([{winid}]) *getwininfo()*
winrow topmost screen line of the window;
"row" from |win_screenpos()|
+ Can also be used as a |method|: >
+ GetWinnr()->getwininfo()
+
getwinpos([{timeout}]) *getwinpos()*
The result is a |List| with two numbers, the result of
|getwinposx()| and |getwinposy()| combined:
@@ -5447,6 +5564,9 @@ getwinpos([{timeout}]) *getwinpos()*
" Do some work here
endwhile
<
+ Can also be used as a |method|: >
+ GetTimeout()->getwinpos()
+<
*getwinposx()*
getwinposx() The result is a Number, which is the X coordinate in pixels of
the left hand side of the GUI Vim window. The result will be
@@ -5464,6 +5584,9 @@ getwinvar({winnr}, {varname} [, {def}]) *getwinvar()*
Examples: >
:let list_is_on = getwinvar(2, '&list')
:echo "myvar = " . getwinvar(1, 'myvar')
+
+< Can also be used as a |method|: >
+ GetWinnr()->getwinvar(varname)
<
glob({expr} [, {nosuf} [, {list} [, {alllinks}]]]) *glob()*
Expand the file wildcards in {expr}. See |wildcards| for the
@@ -5501,6 +5624,9 @@ glob({expr} [, {nosuf} [, {list} [, {alllinks}]]]) *glob()*
See |expand()| for expanding special Vim variables. See
|system()| for getting the raw output of an external command.
+ Can also be used as a |method|: >
+ GetExpr()->glob()
+
glob2regpat({string}) *glob2regpat()*
Convert a file pattern, as used by glob(), into a search
pattern. The result can be used to match with a string that
@@ -5513,7 +5639,9 @@ glob2regpat({string}) *glob2regpat()*
Note that the result depends on the system. On MS-Windows
a backslash usually means a path separator.
- *globpath()*
+ Can also be used as a |method|: >
+ GetExpr()->glob2regpat()
+< *globpath()*
globpath({path}, {expr} [, {nosuf} [, {list} [, {allinks}]]])
Perform glob() for String {expr} on all directories in {path}
and concatenate the results. Example: >
@@ -5549,6 +5677,10 @@ globpath({path}, {expr} [, {nosuf} [, {list} [, {allinks}]]])
< Upwards search and limiting the depth of "**" is not
supported, thus using 'path' will not always work properly.
+ Can also be used as a |method|, the base is passed as the
+ second argument: >
+ GetExpr()->globpath(&rtp)
+<
*has()*
has({feature}) Returns 1 if {feature} is supported, 0 otherwise. The
{feature} argument is a feature name like "nvim-0.2.1" or
@@ -5631,6 +5763,9 @@ haslocaldir([{winnr}[, {tabnr}]]) *haslocaldir()*
{winnr} can be the window number or the |window-ID|.
If {winnr} is -1 it is ignored, only the tab is resolved.
+ Can also be used as a |method|: >
+ GetWinnr()->haslocaldir()
+
hasmapto({what} [, {mode} [, {abbr}]]) *hasmapto()*
The result is a Number, which is TRUE if there is a mapping
that contains {what} in somewhere in the rhs (what it is
@@ -5645,7 +5780,9 @@ hasmapto({what} [, {mode} [, {abbr}]]) *hasmapto()*
If no matching mapping is found FALSE is returned.
The following characters are recognized in {mode}:
n Normal mode
- v Visual mode
+ v Visual and Select mode
+ x Visual mode
+ s Select mode
o Operator-pending mode
i Insert mode
l Language-Argument ("r", "f", "t", etc.)
@@ -5660,6 +5797,9 @@ hasmapto({what} [, {mode} [, {abbr}]]) *hasmapto()*
< This installs the mapping to "\ABCdoit" only if there isn't
already a mapping to "\ABCdoit".
+ Can also be used as a |method|: >
+ GetRHS()->hasmapto()
+
histadd({history}, {item}) *histadd()*
Add the String {item} to the history {history} which can be
one of: *hist-names*
@@ -5681,6 +5821,10 @@ histadd({history}, {item}) *histadd()*
:let date=input("Enter date: ")
< This function is not available in the |sandbox|.
+ Can also be used as a |method|, the base is used for the
+ second argument: >
+ GetPattern()->histadd('search')
+
histdel({history} [, {item}]) *histdel()*
Clear {history}, i.e. delete all its entries. See |hist-names|
for the possible values of {history}.
@@ -5712,6 +5856,9 @@ histdel({history} [, {item}]) *histdel()*
the "n" command and 'hlsearch': >
:call histdel("search", -1)
:let @/ = histget("search", -1)
+<
+ Can also be used as a |method|: >
+ GetHistory()->histdel()
histget({history} [, {index}]) *histget()*
The result is a String, the entry with Number {index} from
@@ -5728,6 +5875,9 @@ histget({history} [, {index}]) *histget()*
the {num}th entry from the output of |:history|. >
:command -nargs=1 H execute histget("cmd", 0+<args>)
<
+ Can also be used as a |method|: >
+ GetHistory()->histget()
+
histnr({history}) *histnr()*
The result is the Number of the current entry in {history}.
See |hist-names| for the possible values of {history}.
@@ -5735,6 +5885,9 @@ histnr({history}) *histnr()*
Example: >
:let inp_index = histnr("expr")
+
+< Can also be used as a |method|: >
+ GetHistory()->histnr()
<
hlexists({name}) *hlexists()*
The result is a Number, which is TRUE if a highlight group
@@ -5743,6 +5896,9 @@ hlexists({name}) *hlexists()*
been defined for it, it may also have been used for a syntax
item.
+ Can also be used as a |method|: >
+ GetName()->hlexists()
+<
*hlID()*
hlID({name}) The result is a Number, which is the ID of the highlight group
with name {name}. When the highlight group doesn't exist,
@@ -5751,6 +5907,9 @@ hlID({name}) The result is a Number, which is the ID of the highlight group
group. For example, to get the background color of the
"Comment" group: >
:echo synIDattr(synIDtrans(hlID("Comment")), "bg")
+<
+ Can also be used as a |method|: >
+ GetName()->hlID()
hostname() *hostname()*
The result is a String, which is the name of the machine on
@@ -5769,6 +5928,9 @@ iconv({string}, {from}, {to}) *iconv()*
from/to UCS-2 is automatically changed to use UTF-8. You
cannot use UCS-2 in a string anyway, because of the NUL bytes.
+ Can also be used as a |method|: >
+ GetText()->iconv('latin1', 'utf-8')
+<
*indent()*
indent({lnum}) The result is a Number, which is indent of line {lnum} in the
current buffer. The indent is counted in spaces, the value
@@ -5776,6 +5938,8 @@ indent({lnum}) The result is a Number, which is indent of line {lnum} in the
|getline()|.
When {lnum} is invalid -1 is returned.
+ Can also be used as a |method|: >
+ GetLnum()->indent()
index({object}, {expr} [, {start} [, {ic}]]) *index()*
If {object} is a |List| return the lowest index where the item
@@ -5796,6 +5960,8 @@ index({object}, {expr} [, {start} [, {ic}]]) *index()*
:let idx = index(words, "the")
:if index(numbers, 123) >= 0
+< Can also be used as a |method|: >
+ GetObject()->index(what)
input({prompt} [, {text} [, {completion}]]) *input()*
input({opts})
@@ -5908,6 +6074,9 @@ input({opts})
: call inputrestore()
:endfunction
+< Can also be used as a |method|: >
+ GetPrompt()->input()
+
inputlist({textlist}) *inputlist()*
{textlist} must be a |List| of strings. This |List| is
displayed, one string per line. The user will be prompted to
@@ -5925,6 +6094,9 @@ inputlist({textlist}) *inputlist()*
let color = inputlist(['Select color:', '1. red',
\ '2. green', '3. blue'])
+< Can also be used as a |method|: >
+ GetChoices()->inputlist()
+
inputrestore() *inputrestore()*
Restore typeahead that was saved with a previous |inputsave()|.
Should be called the same number of times inputsave() is
@@ -5950,6 +6122,9 @@ inputsecret({prompt} [, {text}]) *inputsecret()*
typed on the command-line in response to the issued prompt.
NOTE: Command-line completion is not supported.
+ Can also be used as a |method|: >
+ GetPrompt()->inputsecret()
+
insert({object}, {item} [, {idx}]) *insert()*
When {object} is a |List| or a |Blob| insert {item} at the start
of it.
@@ -5996,6 +6171,9 @@ isdirectory({directory}) *isdirectory()*
exist, or isn't a directory, the result is |FALSE|. {directory}
is any expression, which is used as a String.
+ Can also be used as a |method|: >
+ GetName()->isdirectory()
+
isinf({expr}) *isinf()*
Return 1 if {expr} is a positive infinity, or -1 a negative
infinity, otherwise 0. >
@@ -6021,6 +6199,9 @@ islocked({expr}) *islocked()* *E786*
< When {expr} is a variable that does not exist you get an error
message. Use |exists()| to check for existence.
+ Can also be used as a |method|: >
+ GetName()->islocked()
+
id({expr}) *id()*
Returns a |String| which is a unique identifier of the
container type (|List|, |Dict|, |Blob| and |Partial|). It is
@@ -6205,6 +6386,9 @@ json_decode({expr}) *json_decode()*
recommended and the only one required to be supported.
Non-UTF-8 characters are an error.
+ Can also be used as a |method|: >
+ ReadObject()->json_decode()
+
json_encode({expr}) *json_encode()*
Convert {expr} into a JSON string. Accepts
|msgpack-special-dict| as the input. Will not convert
@@ -6217,6 +6401,9 @@ json_encode({expr}) *json_encode()*
or special escapes like "\t", other are dumped as-is.
|Blob|s are converted to arrays of the individual bytes.
+ Can also be used as a |method|: >
+ GetObject()->json_encode()
+
keys({dict}) *keys()*
Return a |List| with all the keys of {dict}. The |List| is in
arbitrary order. Also see |items()| and |values()|.
@@ -6280,6 +6467,10 @@ libcall({libname}, {funcname}, {argument})
object code must be compiled as position-independent ('PIC').
Examples: >
:echo libcall("libc.so", "getenv", "HOME")
+
+< Can also be used as a |method|, where the base is passed as
+ the argument to the called function: >
+ GetValue()->libcall("libc.so", "getenv")
<
*libcallnr()*
libcallnr({libname}, {funcname}, {argument})
@@ -6290,8 +6481,12 @@ libcallnr({libname}, {funcname}, {argument})
:call libcallnr("libc.so", "printf", "Hello World!\n")
:call libcallnr("libc.so", "sleep", 10)
<
- *line()*
-line({expr}) The result is a Number, which is the line number of the file
+ Can also be used as a |method|, where the base is passed as
+ the argument to the called function: >
+ GetValue()->libcallnr("libc.so", "printf")
+<
+line({expr} [, {winid}]) *line()*
+ The result is a Number, which is the line number of the file
position given with {expr}. The {expr} argument is a string.
The accepted positions are:
. the cursor position
@@ -6310,10 +6505,16 @@ line({expr}) The result is a Number, which is the line number of the file
then applies to another buffer.
To get the column number use |col()|. To get both use
|getpos()|.
+ With the optional {winid} argument the values are obtained for
+ that window instead of the current window.
Examples: >
line(".") line number of the cursor
+ line(".", winid) idem, in window "winid"
line("'t") line number of mark t
line("'" . marker) line number of mark marker
+<
+ Can also be used as a |method|: >
+ GetValue()->line()
line2byte({lnum}) *line2byte()*
Return the byte count from the start of the buffer for line
@@ -6328,6 +6529,9 @@ line2byte({lnum}) *line2byte()*
|getline()|. When {lnum} is invalid -1 is returned.
Also see |byte2line()|, |go| and |:goto|.
+ Can also be used as a |method|: >
+ GetLnum()->line2byte()
+
lispindent({lnum}) *lispindent()*
Get the amount of indent for line {lnum} according the lisp
indenting rules, as with 'lisp'.
@@ -6335,6 +6539,9 @@ lispindent({lnum}) *lispindent()*
relevant. {lnum} is used just like in |getline()|.
When {lnum} is invalid, -1 is returned.
+ Can also be used as a |method|: >
+ GetLnum()->lispindent()
+
list2str({list} [, {utf8}]) *list2str()*
Convert each number in {list} to a character string can
concatenate them all. Examples: >
@@ -6349,6 +6556,9 @@ list2str({list} [, {utf8}]) *list2str()*
With UTF-8 composing characters work as expected: >
list2str([97, 769]) returns "á"
<
+ Can also be used as a |method|: >
+ GetList()->list2str()
+
localtime() *localtime()*
Return the current time, measured as seconds since 1st Jan
1970. See also |strftime()|, |strptime()| and |getftime()|.
@@ -6383,6 +6593,9 @@ luaeval({expr}[, {expr}])
Evaluate Lua expression {expr} and return its result converted
to Vim data structures. See |lua-eval| for more details.
+ Can also be used as a |method|: >
+ GetExpr()->luaeval()
+
map({expr1}, {expr2}) *map()*
{expr1} must be a |List|, |Blob| or |Dictionary|.
Replace each item in {expr1} with the result of evaluating
@@ -6490,6 +6703,8 @@ maparg({name} [, {mode} [, {abbr} [, {dict}]]]) *maparg()*
mapped, and have it do the original mapping too. Sketch: >
exe 'nnoremap <Tab> ==' . maparg('<Tab>', 'n')
+< Can also be used as a |method|: >
+ GetKey()->maparg('n')
mapcheck({name} [, {mode} [, {abbr}]]) *mapcheck()*
Check if there is a mapping that matches with {name} in mode
@@ -6524,6 +6739,9 @@ mapcheck({name} [, {mode} [, {abbr}]]) *mapcheck()*
< This avoids adding the "_vv" mapping when there already is a
mapping for "_v" or for "_vvv".
+ Can also be used as a |method|: >
+ GetKey()->mapcheck('n')
+
match({expr}, {pat} [, {start} [, {count}]]) *match()*
When {expr} is a |List| then this returns the index of the
first item where {pat} matches. Each item is used as a
@@ -6586,6 +6804,9 @@ match({expr}, {pat} [, {start} [, {count}]]) *match()*
zero matches at the start instead of a number of matches
further down in the text.
+ Can also be used as a |method|: >
+ GetList()->match('word')
+<
*matchadd()* *E798* *E799* *E801* *E957*
matchadd({group}, {pattern}[, {priority}[, {id} [, {dict}]]])
Defines a pattern to be highlighted in the current window (a
@@ -6641,6 +6862,9 @@ matchadd({group}, {pattern}[, {priority}[, {id} [, {dict}]]])
available from |getmatches()|. All matches can be deleted in
one operation by |clearmatches()|.
+ Can also be used as a |method|: >
+ GetGroup()->matchadd('TODO')
+<
*matchaddpos()*
matchaddpos({group}, {pos} [, {priority} [, {id} [, {dict}]]])
Same as |matchadd()|, but requires a list of positions {pos}
@@ -6679,6 +6903,9 @@ matchaddpos({group}, {pos} [, {priority} [, {id} [, {dict}]]])
< Matches added by |matchaddpos()| are returned by
|getmatches()|.
+ Can also be used as a |method|: >
+ GetGroup()->matchaddpos([23, 11])
+
matcharg({nr}) *matcharg()*
Selects the {nr} match item, as set with a |:match|,
|:2match| or |:3match| command.
@@ -6691,6 +6918,9 @@ matcharg({nr}) *matcharg()*
Highlighting matches using the |:match| commands are limited
to three matches. |matchadd()| does not have this limitation.
+ Can also be used as a |method|: >
+ GetMatch()->matcharg()
+
matchdelete({id} [, {win}]) *matchdelete()* *E802* *E803*
Deletes a match with ID {id} previously defined by |matchadd()|
or one of the |:match| commands. Returns 0 if successful,
@@ -6699,6 +6929,9 @@ matchdelete({id} [, {win}]) *matchdelete()* *E802* *E803*
If {win} is specified, use the window with this number or
window ID instead of the current window.
+ Can also be used as a |method|: >
+ GetMatch()->matchdelete()
+
matchend({expr}, {pat} [, {start} [, {count}]]) *matchend()*
Same as |match()|, but return the index of first character
after the match. Example: >
@@ -6718,6 +6951,9 @@ matchend({expr}, {pat} [, {start} [, {count}]]) *matchend()*
< result is "-1".
When {expr} is a |List| the result is equal to |match()|.
+ Can also be used as a |method|: >
+ GetText()->matchend('word')
+
matchlist({expr}, {pat} [, {start} [, {count}]]) *matchlist()*
Same as |match()|, but return a |List|. The first item in the
list is the matched string, same as what matchstr() would
@@ -6728,6 +6964,9 @@ matchlist({expr}, {pat} [, {start} [, {count}]]) *matchlist()*
< Results in: ['acd', 'a', '', 'c', 'd', '', '', '', '', '']
When there is no match an empty list is returned.
+ Can also be used as a |method|: >
+ GetList()->matchlist('word')
+
matchstr({expr}, {pat} [, {start} [, {count}]]) *matchstr()*
Same as |match()|, but return the matched string. Example: >
:echo matchstr("testing", "ing")
@@ -6741,6 +6980,9 @@ matchstr({expr}, {pat} [, {start} [, {count}]]) *matchstr()*
When {expr} is a |List| then the matching item is returned.
The type isn't changed, it's not necessarily a String.
+ Can also be used as a |method|: >
+ GetText()->matchstr('word')
+
matchstrpos({expr}, {pat} [, {start} [, {count}]]) *matchstrpos()*
Same as |matchstr()|, but return the matched string, the start
position and the end position of the match. Example: >
@@ -6759,6 +7001,9 @@ matchstrpos({expr}, {pat} [, {start} [, {count}]]) *matchstrpos()*
< result is ["x", 1, 2, 3].
The type isn't changed, it's not necessarily a String.
+ Can also be used as a |method|: >
+ GetText()->matchstrpos('word')
+
*max()*
max({expr}) Return the maximum value of all items in {expr}.
{expr} can be a |List| or a |Dictionary|. For a Dictionary,
@@ -6849,6 +7094,9 @@ mkdir({name} [, {path} [, {prot}]])
successful or FALSE if the directory creation failed or partly
failed.
+ Can also be used as a |method|: >
+ GetName()->mkdir()
+<
*mode()*
mode([expr]) Return a string that indicates the current mode.
If [expr] is supplied and it evaluates to a non-zero Number or
@@ -6864,6 +7112,8 @@ mode([expr]) Return a string that indicates the current mode.
niI Normal using |i_CTRL-O| in |Insert-mode|
niR Normal using |i_CTRL-O| in |Replace-mode|
niV Normal using |i_CTRL-O| in |Virtual-Replace-mode|
+ nt Normal in |terminal-emulator| (insert goes to
+ Terminal mode)
v Visual by character
vs Visual by character using |v_CTRL-O| in Select mode
V Visual by line
@@ -6898,6 +7148,9 @@ mode([expr]) Return a string that indicates the current mode.
the leading character(s).
Also see |visualmode()|.
+ Can also be used as a |method|: >
+ DoFull()->mode()
+
msgpackdump({list} [, {type}]) *msgpackdump()*
Convert a list of VimL objects to msgpack. Returned value is a
|readfile()|-style list. When {type} contains "B", a |Blob| is
@@ -7000,6 +7253,9 @@ nextnonblank({lnum}) *nextnonblank()*
{lnum} is used like with |getline()|.
See also |prevnonblank()|.
+ Can also be used as a |method|: >
+ GetLnum()->nextnonblank()
+
nr2char({expr} [, {utf8}]) *nr2char()*
Return a string with a single character, which has the number
value {expr}. Examples: >
@@ -7014,6 +7270,9 @@ nr2char({expr} [, {utf8}]) *nr2char()*
characters. nr2char(0) is a real NUL and terminates the
string, thus results in an empty string.
+ Can also be used as a |method|: >
+ GetNumber()->nr2char()
+
nvim_...({...}) *E5555* *nvim_...()* *eval-api*
Call nvim |api| functions. The type checking of arguments will
be stricter than for most other builtins. For instance,
@@ -7042,6 +7301,9 @@ pathshorten({path}) *pathshorten()*
< ~/.c/n/a/file1.vim ~
It doesn't matter if the path exists or not.
+ Can also be used as a |method|: >
+ GetDirectories()->pathshorten()
+
perleval({expr}) *perleval()*
Evaluate |perl| expression {expr} and return its result
converted to Vim data structures.
@@ -7057,6 +7319,9 @@ perleval({expr}) *perleval()*
:echo perleval('[1 .. 4]')
< [1, 2, 3, 4]
+ Can also be used as a |method|: >
+ GetExpr()->perleval()
+
pow({x}, {y}) *pow()*
Return the power of {x} to the exponent {y} as a |Float|.
{x} and {y} must evaluate to a |Float| or a |Number|.
@@ -7080,6 +7345,8 @@ prevnonblank({lnum}) *prevnonblank()*
{lnum} is used like with |getline()|.
Also see |nextnonblank()|.
+ Can also be used as a |method|: >
+ GetLnum()->prevnonblank()
printf({fmt}, {expr1} ...) *printf()*
Return a String with {fmt}, where "%" items are replaced by
@@ -7312,6 +7579,9 @@ prompt_setcallback({buf}, {expr}) *prompt_setcallback()*
endif
endfunc
+< Can also be used as a |method|: >
+ GetBuffer()->prompt_setcallback(callback)
+
prompt_setinterrupt({buf}, {expr}) *prompt_setinterrupt()*
Set a callback for buffer {buf} to {expr}. When {expr} is an
empty string the callback is removed. This has only effect if
@@ -7321,12 +7591,18 @@ prompt_setinterrupt({buf}, {expr}) *prompt_setinterrupt()*
mode. Without setting a callback Vim will exit Insert mode,
as in any buffer.
+ Can also be used as a |method|: >
+ GetBuffer()->prompt_setinterrupt(callback)
+
prompt_setprompt({buf}, {text}) *prompt_setprompt()*
Set prompt for buffer {buf} to {text}. You most likely want
{text} to end in a space.
The result is only visible if {buf} has 'buftype' set to
"prompt". Example: >
call prompt_setprompt(bufnr(''), 'command: ')
+<
+ Can also be used as a |method|: >
+ GetBuffer()->prompt_setprompt('command: ')
pum_getpos() *pum_getpos()*
If the popup menu (see |ins-completion-menu|) is not visible,
@@ -7357,6 +7633,9 @@ py3eval({expr}) *py3eval()*
Dictionaries are represented as Vim |Dictionary| type with
keys converted to strings.
+ Can also be used as a |method|: >
+ GetExpr()->py3eval()
+<
*E858* *E859*
pyeval({expr}) *pyeval()*
Evaluate Python expression {expr} and return its result
@@ -7367,12 +7646,18 @@ pyeval({expr}) *pyeval()*
Dictionaries are represented as Vim |Dictionary| type,
non-string keys result in error.
+ Can also be used as a |method|: >
+ GetExpr()->pyeval()
+
pyxeval({expr}) *pyxeval()*
Evaluate Python expression {expr} and return its result
converted to Vim data structures.
Uses Python 2 or 3, see |python_x| and 'pyxversion'.
See also: |pyeval()|, |py3eval()|
+ Can also be used as a |method|: >
+ GetExpr()->pyxeval()
+<
*E726* *E727*
range({expr} [, {max} [, {stride}]]) *range()*
Returns a |List| with Numbers:
@@ -7392,6 +7677,9 @@ range({expr} [, {max} [, {stride}]]) *range()*
range(0) " []
range(2, 0) " error!
<
+ Can also be used as a |method|: >
+ GetExpr()->range()
+<
*readdir()*
readdir({directory} [, {expr}])
Return a list with file and directory names in {directory}.
@@ -7419,6 +7707,9 @@ readdir({directory} [, {expr}])
endfunction
echo s:tree(".")
<
+ Can also be used as a |method|: >
+ GetDirName()->readdir()
+<
*readfile()*
readfile({fname} [, {type} [, {max}]])
Read file {fname} and return a |List|, each line of the file
@@ -7452,6 +7743,9 @@ readfile({fname} [, {type} [, {max}]])
the result is an empty list.
Also see |writefile()|.
+ Can also be used as a |method|: >
+ GetFileName()->readfile()
+
reg_executing() *reg_executing()*
Returns the single letter name of the register being executed.
Returns an empty string when no register is being executed.
@@ -7479,6 +7773,9 @@ reltime([{start} [, {end}]]) *reltime()*
The {start} and {end} arguments must be values returned by
reltime().
+ Can also be used as a |method|: >
+ GetStart()->reltime()
+<
Note: |localtime()| returns the current (non-relative) time.
reltimefloat({time}) *reltimefloat()*
@@ -7492,6 +7789,9 @@ reltimefloat({time}) *reltimefloat()*
Also see |profiling|.
If there is an error an empty string is returned
+ Can also be used as a |method|: >
+ reltime(start)->reltimefloat()
+
reltimestr({time}) *reltimestr()*
Return a String that represents the time value of {time}.
This is the number of seconds, a dot and the number of
@@ -7506,6 +7806,9 @@ reltimestr({time}) *reltimestr()*
< Also see |profiling|.
If there is an error an empty string is returned
+ Can also be used as a |method|: >
+ reltime(start)->reltimestr()
+<
*remote_expr()* *E449*
remote_expr({server}, {string} [, {idvar} [, {timeout}]])
Send the {string} to {server}. The string is sent as an
@@ -7638,6 +7941,9 @@ rename({from}, {to}) *rename()*
NOTE: If {to} exists it is overwritten without warning.
This function is not available in the |sandbox|.
+ Can also be used as a |method|: >
+ GetOldName()->rename(newname)
+
repeat({expr}, {count}) *repeat()*
Repeat {expr} {count} times and return the concatenated
result. Example: >
@@ -7664,6 +7970,9 @@ resolve({filename}) *resolve()* *E655*
current directory (provided the result is still a relative
path name) and also keeps a trailing path separator.
+ Can also be used as a |method|: >
+ GetName()->resolve()
+<
*reverse()*
reverse({object})
Reverse the order of items in {object} in-place.
@@ -7718,6 +8027,9 @@ rubyeval({expr}) *rubyeval()*
Other objects are represented as strings resulted from their
"Object#to_s" method.
+ Can also be used as a |method|: >
+ GetRubyExpr()->rubyeval()
+
screenattr({row}, {col}) *screenattr()*
Like |screenchar()|, but return the attribute. This is a rather
arbitrary number that can only be used to compare to the
@@ -8281,6 +8593,9 @@ setfperm({fname}, {mode}) *setfperm()* *chmod*
Returns non-zero for success, zero for failure.
+ Can also be used as a |method|: >
+ GetFilename()->setfperm(mode)
+<
To read permissions see |getfperm()|.
setline({lnum}, {text}) *setline()*
diff --git a/runtime/doc/nvim_terminal_emulator.txt b/runtime/doc/nvim_terminal_emulator.txt
index 5ad69d1122..e83b17f9a0 100644
--- a/runtime/doc/nvim_terminal_emulator.txt
+++ b/runtime/doc/nvim_terminal_emulator.txt
@@ -53,7 +53,7 @@ next key is sent unless it is <C-N>. Use <C-\><C-N> to return to normal-mode.
Terminal-mode forces these local options:
- 'nocursorline'
+ 'cursorlineopt' = number
'nocursorcolumn'
'scrolloff' = 0
'sidescrolloff' = 0
@@ -171,7 +171,7 @@ program window A terminal window for the executed program. When "run" is
The current window is used to show the source code. When gdb pauses the
source file location will be displayed, if possible. A sign is used to
-highlight the current position, using highlight group debugPC.
+highlight the current position, using highlight group debugPC.
If the buffer in the current window is modified, another window will be opened
to display the current gdb position.
@@ -222,7 +222,7 @@ Put focus on the gdb window and type: >
run
Vim will start running in the program window. Put focus there and type: >
:help gui
-Gdb will run into the ex_help breakpoint. The source window now shows the
+Gdb will run into the ex_help breakpoint. The source window now shows the
ex_cmds.c file. A red "1 " marker will appear in the signcolumn where the
breakpoint was set. The line where the debugger stopped is highlighted. You
can now step through the program. You will see the highlighting move as the
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index 85be6eddaa..3520d40591 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -1409,9 +1409,9 @@ A jump table for the options with a short description can be found at |Q_op|.
When this option is set it overrules 'shellslash' for completion:
- When this option is set to "slash", a forward slash is used for path
completion in insert mode. This is useful when editing HTML tag, or
- Makefile with 'noshellslash' on Windows.
+ Makefile with 'noshellslash' on MS-Windows.
- When this option is set to "backslash", backslash is used. This is
- useful when editing a batch file with 'shellslash' set on Windows.
+ useful when editing a batch file with 'shellslash' set on MS-Windows.
- When this option is empty, same character is used as for
'shellslash'.
For Insert mode completion the buffer-local value is used. For
@@ -5981,13 +5981,13 @@ A jump table for the options with a short description can be found at |Q_op|.
return value of expr contains % items they will get expanded.
The expression can contain the } character, the end of
expression is denoted by %}.
- The For example: >
+ For example: >
func! Stl_filename() abort
return "%t"
endfunc
< `stl=%{Stl_filename()}` results in `"%t"`
`stl=%{%Stl_filename()%}` results in `"Name of current file"`
- } - End of `{%` expression
+ %} - End of `{%` expression
( - Start of item group. Can be used for setting the width and
alignment of a section. Must be followed by %) somewhere.
) - End of item group. No width fields allowed.
diff --git a/runtime/doc/pattern.txt b/runtime/doc/pattern.txt
index c49cc6d540..dfed39dba6 100644
--- a/runtime/doc/pattern.txt
+++ b/runtime/doc/pattern.txt
@@ -977,7 +977,7 @@ $ At end of pattern or in front of "\|", "\)" or "\n" ('magic' on):
/.*\%17v
< Column 17 is highlighted by 'hlsearch' because there is another match
where ".*" matches zero characters.
-<
+
Character classes:
\i identifier character (see 'isident' option) */\i*
diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt
index 5d70834ddc..c575dd9fd8 100644
--- a/runtime/doc/usr_41.txt
+++ b/runtime/doc/usr_41.txt
@@ -1804,7 +1804,7 @@ First of all you must choose a name for your plugin. The features provided
by the plugin should be clear from its name. And it should be unlikely that
someone else writes a plugin with the same name but which does something
different. And please limit the name to 8 characters, to avoid problems on
-old Windows systems.
+old MS-Windows systems.
A script that corrects typing mistakes could be called "typecorr.vim". We
will use it here as an example.
diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt
index b06fa7518c..5484e27797 100644
--- a/runtime/doc/various.txt
+++ b/runtime/doc/various.txt
@@ -168,7 +168,7 @@ g8 Print the hex values of the bytes used in the
*:z!*
:[range]z![+-^.=][count]
- Like ":z:", but when [count] is not specified, it
+ Like ":z", but when [count] is not specified, it
defaults to the Vim window height minus one.
:[range]z[!]#[+-^.=][count] *:z#*
diff --git a/runtime/filetype.vim b/runtime/filetype.vim
index c86ca9646b..75354968e9 100644
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -703,6 +703,7 @@ au BufNewFile,BufRead *.gpi setf gnuplot
" Go (Google)
au BufNewFile,BufRead *.go setf go
+au BufNewFile,BufRead Gopkg.lock setf toml
" GrADS scripts
au BufNewFile,BufRead *.gs setf grads
@@ -1283,7 +1284,7 @@ au BufNewFile,BufRead *.rcp setf pilrc
au BufNewFile,BufRead .pinerc,pinerc,.pinercex,pinercex setf pine
" Pipenv Pipfiles
-au BufNewFile,BufRead Pipfile setf config
+au BufNewFile,BufRead Pipfile setf toml
au BufNewFile,BufRead Pipfile.lock setf json
" PL/1, PL/I
@@ -1517,6 +1518,7 @@ au BufNewFile,BufRead [rR]antfile,*.rant,[rR]akefile,*.rake setf ruby
" Rust
au BufNewFile,BufRead *.rs setf rust
+au BufNewFile,BufRead Cargo.lock,*/.cargo/config,*/.cargo/credentials setf toml
" S-lang (or shader language, or SmallLisp)
au BufNewFile,BufRead *.sl setf slang
@@ -2301,6 +2303,9 @@ au BufNewFile,BufRead .tcshrc* call dist#ft#SetFileTypeShell("tcsh")
" csh scripts ending in a star
au BufNewFile,BufRead .login*,.cshrc* call dist#ft#CSH()
+" tmux configuration with arbitrary extension
+au BufNewFile,BufRead {.,}tmux*.conf* setf tmux
+
" VHDL
au BufNewFile,BufRead *.vhdl_[0-9]* call s:StarSetf('vhdl')
diff --git a/runtime/ftplugin/context.vim b/runtime/ftplugin/context.vim
index 10f1ae1648..37f7240d7b 100644
--- a/runtime/ftplugin/context.vim
+++ b/runtime/ftplugin/context.vim
@@ -2,7 +2,7 @@
" Language: ConTeXt typesetting engine
" Maintainer: Nicola Vitacolonna <nvitacolonna@gmail.com>
" Former Maintainers: Nikolai Weibull <now@bitwi.se>
-" Latest Revision: 2016 Oct 30
+" Latest Revision: 2021 Oct 15
if exists("b:did_ftplugin")
finish
@@ -17,7 +17,6 @@ if !exists('current_compiler')
endif
let b:undo_ftplugin = "setl com< cms< def< inc< sua< fo< ofu<"
- \ . "| unlet! b:match_ignorecase b:match_words b:match_skip"
setlocal comments=b:%D,b:%C,b:%M,:% commentstring=%\ %s formatoptions+=tjcroql2
if get(b:, 'context_metapost', get(g:, 'context_metapost', 1))
@@ -35,11 +34,12 @@ let &l:include = '^\s*\\\%(input\|component\|product\|project\|environment\)'
setlocal suffixesadd=.tex
-if exists("loaded_matchit")
+if exists("loaded_matchit") && !exists("b:match_words")
let b:match_ignorecase = 0
let b:match_skip = 'r:\\\@<!\%(\\\\\)*%'
let b:match_words = '(:),\[:],{:},\\(:\\),\\\[:\\],' .
\ '\\start\(\a\+\):\\stop\1'
+ let b:undo_ftplugin .= " | unlet! b:match_ignorecase b:match_words b:match_skip"
endif
let s:context_regex = {
@@ -57,19 +57,28 @@ function! s:move_around(count, what, flags, visual)
call map(range(2, a:count), 'search(s:context_regex[a:what], a:flags)')
endfunction
-" Move around macros.
-nnoremap <silent><buffer> [[ :<C-U>call <SID>move_around(v:count1, "beginsection", "bW", v:false) <CR>
-vnoremap <silent><buffer> [[ :<C-U>call <SID>move_around(v:count1, "beginsection", "bW", v:true) <CR>
-nnoremap <silent><buffer> ]] :<C-U>call <SID>move_around(v:count1, "beginsection", "W", v:false) <CR>
-vnoremap <silent><buffer> ]] :<C-U>call <SID>move_around(v:count1, "beginsection", "W", v:true) <CR>
-nnoremap <silent><buffer> [] :<C-U>call <SID>move_around(v:count1, "endsection", "bW", v:false) <CR>
-vnoremap <silent><buffer> [] :<C-U>call <SID>move_around(v:count1, "endsection", "bW", v:true) <CR>
-nnoremap <silent><buffer> ][ :<C-U>call <SID>move_around(v:count1, "endsection", "W", v:false) <CR>
-vnoremap <silent><buffer> ][ :<C-U>call <SID>move_around(v:count1, "endsection", "W", v:true) <CR>
-nnoremap <silent><buffer> [{ :<C-U>call <SID>move_around(v:count1, "beginblock", "bW", v:false) <CR>
-vnoremap <silent><buffer> [{ :<C-U>call <SID>move_around(v:count1, "beginblock", "bW", v:true) <CR>
-nnoremap <silent><buffer> ]} :<C-U>call <SID>move_around(v:count1, "endblock", "W", v:false) <CR>
-vnoremap <silent><buffer> ]} :<C-U>call <SID>move_around(v:count1, "endblock", "W", v:true) <CR>
+if !exists("no_plugin_maps") && !exists("no_context_maps")
+ " Move around macros.
+ nnoremap <silent><buffer> [[ :<C-U>call <SID>move_around(v:count1, "beginsection", "bW", v:false) <CR>
+ vnoremap <silent><buffer> [[ :<C-U>call <SID>move_around(v:count1, "beginsection", "bW", v:true) <CR>
+ nnoremap <silent><buffer> ]] :<C-U>call <SID>move_around(v:count1, "beginsection", "W", v:false) <CR>
+ vnoremap <silent><buffer> ]] :<C-U>call <SID>move_around(v:count1, "beginsection", "W", v:true) <CR>
+ nnoremap <silent><buffer> [] :<C-U>call <SID>move_around(v:count1, "endsection", "bW", v:false) <CR>
+ vnoremap <silent><buffer> [] :<C-U>call <SID>move_around(v:count1, "endsection", "bW", v:true) <CR>
+ nnoremap <silent><buffer> ][ :<C-U>call <SID>move_around(v:count1, "endsection", "W", v:false) <CR>
+ vnoremap <silent><buffer> ][ :<C-U>call <SID>move_around(v:count1, "endsection", "W", v:true) <CR>
+ nnoremap <silent><buffer> [{ :<C-U>call <SID>move_around(v:count1, "beginblock", "bW", v:false) <CR>
+ vnoremap <silent><buffer> [{ :<C-U>call <SID>move_around(v:count1, "beginblock", "bW", v:true) <CR>
+ nnoremap <silent><buffer> ]} :<C-U>call <SID>move_around(v:count1, "endblock", "W", v:false) <CR>
+ vnoremap <silent><buffer> ]} :<C-U>call <SID>move_around(v:count1, "endblock", "W", v:true) <CR>
+
+ let b:undo_ftplugin .= " | sil! exe 'nunmap <buffer> [[' | sil! exe 'vunmap <buffer> [['" .
+ \ " | sil! exe 'nunmap <buffer> ]]' | sil! exe 'vunmap <buffer> ]]'" .
+ \ " | sil! exe 'nunmap <buffer> []' | sil! exe 'vunmap <buffer> []'" .
+ \ " | sil! exe 'nunmap <buffer> ][' | sil! exe 'vunmap <buffer> ]['" .
+ \ " | sil! exe 'nunmap <buffer> [{' | sil! exe 'vunmap <buffer> [{'" .
+ \ " | sil! exe 'nunmap <buffer> ]}' | sil! exe 'vunmap <buffer> ]}'"
+end
" Other useful mappings
if get(g:, 'context_mappings', 1)
@@ -81,16 +90,22 @@ if get(g:, 'context_mappings', 1)
call cursor(search(s:tp_regex, 'W') - 1, 1)
endf
- " Reflow paragraphs with commands like gqtp ("gq TeX paragraph")
- onoremap <silent><buffer> tp :<c-u>call <sid>tp()<cr>
- " Select TeX paragraph
- vnoremap <silent><buffer> tp <esc>:<c-u>call <sid>tp()<cr>
-
- " $...$ text object
- onoremap <silent><buffer> i$ :<c-u>normal! T$vt$<cr>
- onoremap <silent><buffer> a$ :<c-u>normal! F$vf$<cr>
- vnoremap <buffer> i$ T$ot$
- vnoremap <buffer> a$ F$of$
+ if !exists("no_plugin_maps") && !exists("no_context_maps")
+ " Reflow paragraphs with commands like gqtp ("gq TeX paragraph")
+ onoremap <silent><buffer> tp :<c-u>call <sid>tp()<cr>
+ " Select TeX paragraph
+ vnoremap <silent><buffer> tp <esc>:<c-u>call <sid>tp()<cr>
+
+ " $...$ text object
+ onoremap <silent><buffer> i$ :<c-u>normal! T$vt$<cr>
+ onoremap <silent><buffer> a$ :<c-u>normal! F$vf$<cr>
+ vnoremap <buffer> i$ T$ot$
+ vnoremap <buffer> a$ F$of$
+
+ let b:undo_ftplugin .= " | sil! exe 'ounmap <buffer> tp' | sil! exe 'vunmap <buffer> tp'" .
+ \ " | sil! exe 'ounmap <buffer> i$' | sil! exe 'vunmap <buffer> i$'" .
+ \ " | sil! exe 'ounmap <buffer> a$' | sil! exe 'vunmap <buffer> a$'"
+ endif
endif
" Commands for asynchronous typesetting
diff --git a/runtime/ftplugin/csh.vim b/runtime/ftplugin/csh.vim
index 4ae09f91be..929823219c 100644
--- a/runtime/ftplugin/csh.vim
+++ b/runtime/ftplugin/csh.vim
@@ -1,21 +1,23 @@
" Vim filetype plugin file
-" Language: csh
-" Maintainer: Dan Sharp <dwsharp at users dot sourceforge dot net>
-" Last Changed: 20 Jan 2009
-" URL: http://dwsharp.users.sourceforge.net/vim/ftplugin
+" Language: csh
+" Maintainer: Doug Kearns <dougkearns@gmail.com>
+" Previous Maintainer: Dan Sharp <dwsharp at users dot sourceforge dot net>
+" Contributor: Johannes Zellner <johannes@zellner.org>
+" Last Change: 2021 Oct 15
if exists("b:did_ftplugin") | finish | endif
let b:did_ftplugin = 1
-" Make sure the continuation lines below do not cause problems in
-" compatibility mode.
let s:save_cpo = &cpo
set cpo-=C
+setlocal comments=:#
setlocal commentstring=#%s
setlocal formatoptions-=t
setlocal formatoptions+=crql
+let b:undo_ftplugin = "setlocal com< cms< fo<"
+
" Csh: thanks to Johannes Zellner
" - Both foreach and end must appear alone on separate lines.
" - The words else and endif must appear at the beginning of input lines;
@@ -23,26 +25,27 @@ setlocal formatoptions+=crql
" - Each case label and the default label must appear at the start of a
" line.
" - while and end must appear alone on their input lines.
-if exists("loaded_matchit")
- let b:match_words =
- \ '^\s*\<if\>.*(.*).*\<then\>:'.
- \ '^\s*\<else\>\s\+\<if\>.*(.*).*\<then\>:^\s*\<else\>:'.
- \ '^\s*\<endif\>,'.
- \ '\%(^\s*\<foreach\>\s\+\S\+\|^s*\<while\>\).*(.*):'.
- \ '\<break\>:\<continue\>:^\s*\<end\>,'.
- \ '^\s*\<switch\>.*(.*):^\s*\<case\>\s\+:^\s*\<default\>:^\s*\<endsw\>'
+if exists("loaded_matchit") && !exists("b:match_words")
+ let s:line_start = '\%(^\s*\)\@<='
+ let b:match_words =
+ \ s:line_start .. 'if\s*(.*)\s*then\>:' ..
+ \ s:line_start .. 'else\s\+if\s*(.*)\s*then\>:' .. s:line_start .. 'else\>:' ..
+ \ s:line_start .. 'endif\>,' ..
+ \ s:line_start .. '\%(\<foreach\s\+\h\w*\|while\)\s*(:' ..
+ \ '\<break\>:\<continue\>:' ..
+ \ s:line_start .. 'end\>,' ..
+ \ s:line_start .. 'switch\s*(:' ..
+ \ s:line_start .. 'case\s\+:' .. s:line_start .. 'default\>:\<breaksw\>:' ..
+ \ s:line_start .. 'endsw\>'
+ unlet s:line_start
+ let b:undo_ftplugin ..= " | unlet b:match_words"
endif
-" Change the :browse e filter to primarily show csh-related files.
-if has("gui_win32")
- let b:browsefilter="csh Scripts (*.csh)\t*.csh\n" .
- \ "All Files (*.*)\t*.*\n"
+if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
+ let b:browsefilter="csh Scripts (*.csh)\t*.csh\n" ..
+ \ "All Files (*.*)\t*.*\n"
+ let b:undo_ftplugin ..= " | unlet b:browsefilter"
endif
-" Undo the stuff we changed.
-let b:undo_ftplugin = "setlocal commentstring< formatoptions<" .
- \ " | unlet! b:match_words b:browsefilter"
-
-" Restore the saved compatibility options.
let &cpo = s:save_cpo
unlet s:save_cpo
diff --git a/runtime/ftplugin/tcsh.vim b/runtime/ftplugin/tcsh.vim
index 7e2d959932..33f1aabf68 100644
--- a/runtime/ftplugin/tcsh.vim
+++ b/runtime/ftplugin/tcsh.vim
@@ -1,19 +1,17 @@
" Vim filetype plugin file
-" Language: tcsh
-" Maintainer: Dan Sharp <dwsharp at users dot sourceforge dot net>
-" Last Changed: 20 Jan 2009
-" URL: http://dwsharp.users.sourceforge.net/vim/ftplugin
+" Language: tcsh
+" Maintainer: Doug Kearns <dougkearns@gmail.com>
+" Previous Maintainer: Dan Sharp <dwsharp at users dot sourceforge dot net>
+" Last Change: 2021 Oct 15
if exists("b:did_ftplugin") | finish | endif
-" Make sure the continuation lines below do not cause problems in
-" compatibility mode.
let s:save_cpo = &cpo
set cpo-=C
" Define some defaults in case the included ftplugins don't set them.
let s:undo_ftplugin = ""
-let s:browsefilter = "csh Files (*.csh)\t*.csh\n" .
+let s:browsefilter = "csh Files (*.csh)\t*.csh\n" ..
\ "All Files (*.*)\t*.*\n"
runtime! ftplugin/csh.vim ftplugin/csh_*.vim ftplugin/csh/*.vim
@@ -27,14 +25,11 @@ if exists("b:browsefilter")
let s:browsefilter = b:browsefilter
endif
-" Change the :browse e filter to primarily show tcsh-related files.
-if has("gui_win32")
- let b:browsefilter="tcsh Scripts (*.tcsh)\t*.tcsh\n" . s:browsefilter
+if (has("gui_win32") || has("gui_gtk"))
+ let b:browsefilter="tcsh Scripts (*.tcsh)\t*.tcsh\n" .. s:browsefilter
endif
-" Undo the stuff we changed.
-let b:undo_ftplugin = "unlet! b:browsefilter | " . s:undo_ftplugin
+let b:undo_ftplugin = "unlet! b:browsefilter | " .. s:undo_ftplugin
-" Restore the saved compatibility options.
let &cpo = s:save_cpo
unlet s:save_cpo
diff --git a/runtime/ftplugin/tmux.vim b/runtime/ftplugin/tmux.vim
index ed9154924b..5c3461fefb 100644
--- a/runtime/ftplugin/tmux.vim
+++ b/runtime/ftplugin/tmux.vim
@@ -9,4 +9,7 @@ if exists("b:did_ftplugin")
endif
let b:did_ftplugin = 1
+let b:undo_ftplugin = "setlocal comments< commentstring<"
+
+setlocal comments=:#
setlocal commentstring=#\ %s
diff --git a/runtime/ftplugin/toml.vim b/runtime/ftplugin/toml.vim
new file mode 100644
index 0000000000..1ef09a16e3
--- /dev/null
+++ b/runtime/ftplugin/toml.vim
@@ -0,0 +1,23 @@
+" Vim filetype plugin
+" Language: TOML
+" Homepage: https://github.com/cespare/vim-toml
+" Maintainer: Aman Verma
+" Author: Kevin Ballard <kevin@sb.org>
+" Last Change: Sep 21, 2021
+
+if exists('b:did_ftplugin')
+ finish
+endif
+let b:did_ftplugin = 1
+
+let s:save_cpo = &cpo
+set cpo&vim
+let b:undo_ftplugin = 'setlocal commentstring< comments<'
+
+setlocal commentstring=#\ %s
+setlocal comments=:#
+
+let &cpo = s:save_cpo
+unlet s:save_cpo
+
+" vim: et sw=2 sts=2
diff --git a/runtime/indent/hamster.vim b/runtime/indent/hamster.vim
index b27a173924..ae5c3fdedd 100644
--- a/runtime/indent/hamster.vim
+++ b/runtime/indent/hamster.vim
@@ -1,8 +1,14 @@
" Vim indent file
" Language: Hamster Script
-" Version: 2.0.6.0
-" Last Change: Wed Nov 08 2006 12:02:42 PM
-" Maintainer: David Fishburn <fishburn@ianywhere.com>
+" Version: 2.0.6.1
+" Last Change: 2021 Oct 11
+" Maintainer: David Fishburn <dfishburn dot vim at gmail dot com>
+" Download: https://www.vim.org/scripts/script.php?script_id=1099
+"
+" 2.0.6.1 (Oct 2021)
+" Added b:undo_indent
+" Added cpo check
+"
" Only load this indent file when no other was loaded.
if exists("b:did_indent")
@@ -14,12 +20,17 @@ setlocal indentkeys+==~if,=~else,=~endif,=~endfor,=~endwhile
setlocal indentkeys+==~do,=~until,=~while,=~repeat,=~for,=~loop
setlocal indentkeys+==~sub,=~endsub
+let b:undo_indent = "setl indentkeys<"
+
" Define the appropriate indent function but only once
setlocal indentexpr=HamGetFreeIndent()
if exists("*HamGetFreeIndent")
finish
endif
+let s:keepcpo = &cpo
+set cpo&vim
+
function HamGetIndent(lnum)
let ind = indent(a:lnum)
let prevline=getline(a:lnum)
@@ -52,4 +63,8 @@ function HamGetFreeIndent()
return ind
endfunction
+" Restore:
+let &cpo = s:keepcpo
+unlet s:keepcpo
+
" vim:sw=2 tw=80
diff --git a/runtime/indent/sqlanywhere.vim b/runtime/indent/sqlanywhere.vim
index d39fa3240e..4772b5951b 100644
--- a/runtime/indent/sqlanywhere.vim
+++ b/runtime/indent/sqlanywhere.vim
@@ -1,9 +1,8 @@
" Vim indent file
" Language: SQL
" Maintainer: David Fishburn <dfishburn dot vim at gmail dot com>
-" Last Change By Maintainer: 2017 Jun 13
-" Last Change: by Stephen Wall, #5578, 2020 Jun 07
-" Version: 3.0
+" Last Change: 2021 Oct 11
+" Version: 4.0
" Download: http://vim.sourceforge.net/script.php?script_id=495
" Notes:
@@ -21,6 +20,9 @@
" it, this can leave the indent hanging to the right one too many.
"
" History:
+" 4.0 (Oct 2021)
+" Added b:undo_indent
+"
" 3.0 (Dec 2012)
" Added cpo check
"
@@ -56,10 +58,13 @@ setlocal indentkeys+==~end,=~else,=~elseif,=~elsif,0=~when,0=)
" in the indentkeys is typed
setlocal indentexpr=GetSQLIndent()
+let b:undo_indent = "setl indentexpr< indentkeys<"
+
" Only define the functions once.
if exists("*GetSQLIndent")
finish
endif
+
let s:keepcpo= &cpo
set cpo&vim
@@ -68,14 +73,9 @@ set cpo&vim
" IS is excluded, since it is difficult to determine when the
" ending block is (especially for procedures/functions).
let s:SQLBlockStart = '^\s*\%('.
- \ 'if\>.*\<then\|'.
- \ 'then\|else\>\|'.
- \ 'elseif\>.*\<then\|'.
- \ 'elsif\>.(\<then\|'.
- \ 'while\>.*\<loop\|'.
- \ 'for\>.*\<loop\|'.
- \ 'foreach\>.*\<loop\|'.
- \ 'loop\|do\|declare\|begin\|'.
+ \ 'if\|else\|elseif\|elsif\|'.
+ \ 'while\|loop\|do\|for\|'.
+ \ 'begin\|'.
\ 'case\|when\|merge\|exception'.
\ '\)\>'
let s:SQLBlockEnd = '^\s*\(end\)\>'
diff --git a/runtime/indent/tcsh.vim b/runtime/indent/tcsh.vim
index 025d9c805d..93d96e7789 100644
--- a/runtime/indent/tcsh.vim
+++ b/runtime/indent/tcsh.vim
@@ -1,7 +1,8 @@
" Vim indent file
" Language: C-shell (tcsh)
-" Maintainer: Doug Kearns <a@b.com> where a=dougkearns, b=gmail
-" Last Modified: Sun 26 Sep 2021 12:38:38 PM EDT
+" Maintainer: Doug Kearns <dougkearns@gmail.com>
+" Previous Maintainer: Gautam Iyer <gi1242+vim@NoSpam.com> where NoSpam=gmail (Original Author)
+" Last Change: 2021 Oct 15
" Only load this indent file when no other was loaded.
if exists("b:did_indent")
@@ -11,7 +12,9 @@ endif
let b:did_indent = 1
setlocal indentexpr=TcshGetIndent()
-setlocal indentkeys+=e,0=end,0=endsw indentkeys-=0{,0},0),:,0#
+setlocal indentkeys+=e,0=end
+setlocal indentkeys-=0{,0},0),:,0#
+
let b:undo_indent = "setl inde< indk<"
" Only define the function once.
@@ -40,9 +43,9 @@ function TcshGetIndent()
let ind = ind - shiftwidth()
endif
- " Subtract indent if current line has on end, endif, case commands
+ " Subtract indent if current line has on end, endif, endsw, case commands
let line = getline(v:lnum)
- if line =~ '\v^\s*%(else|end|endif)\s*$'
+ if line =~ '\v^\s*%(else|end|endif|endsw)\s*$'
let ind = ind - shiftwidth()
endif
diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua
index c7c8c1878e..326932d982 100644
--- a/runtime/lua/vim/diagnostic.lua
+++ b/runtime/lua/vim/diagnostic.lua
@@ -27,7 +27,10 @@ local global_diagnostic_options = {
---@private
local function to_severity(severity)
- return type(severity) == 'string' and M.severity[string.upper(severity)] or severity
+ if type(severity) == 'string' then
+ return assert(M.severity[string.upper(severity)], string.format("Invalid severity: %s", severity))
+ end
+ return severity
end
---@private
@@ -90,28 +93,6 @@ local function reformat_diagnostics(format, diagnostics)
return formatted
end
----@private
-local function resolve_optional_value(option, namespace, bufnr)
- local enabled_val = {}
-
- if not option then
- return false
- elseif option == true then
- return enabled_val
- elseif type(option) == 'function' then
- local val = option(namespace, bufnr)
- if val == true then
- return enabled_val
- else
- return val
- end
- elseif type(option) == 'table' then
- return option
- else
- error("Unexpected option type: " .. vim.inspect(option))
- end
-end
-
local all_namespaces = {}
---@private
@@ -125,9 +106,7 @@ local function get_namespace(ns)
end
end
- if not name then
- return vim.notify("namespace does not exist or is anonymous", vim.log.levels.ERROR)
- end
+ assert(name, "namespace does not exist or is anonymous")
all_namespaces[ns] = {
name = name,
@@ -139,12 +118,46 @@ local function get_namespace(ns)
end
---@private
+local function enabled_value(option, namespace)
+ local ns = get_namespace(namespace)
+ if type(ns.opts[option]) == "table" then
+ return ns.opts[option]
+ end
+
+ if type(global_diagnostic_options[option]) == "table" then
+ return global_diagnostic_options[option]
+ end
+
+ return {}
+end
+
+---@private
+local function resolve_optional_value(option, value, namespace, bufnr)
+ if not value then
+ return false
+ elseif value == true then
+ return enabled_value(option, namespace)
+ elseif type(value) == 'function' then
+ local val = value(namespace, bufnr)
+ if val == true then
+ return enabled_value(option, namespace)
+ else
+ return val
+ end
+ elseif type(value) == 'table' then
+ return value
+ else
+ error("Unexpected option type: " .. vim.inspect(value))
+ end
+end
+
+---@private
local function get_resolved_options(opts, namespace, bufnr)
local ns = get_namespace(namespace)
local resolved = vim.tbl_extend('keep', opts or {}, ns.opts, global_diagnostic_options)
for k in pairs(global_diagnostic_options) do
if resolved[k] ~= nil then
- resolved[k] = resolve_optional_value(resolved[k], namespace, bufnr)
+ resolved[k] = resolve_optional_value(k, resolved[k], namespace, bufnr)
end
end
return resolved
@@ -398,6 +411,17 @@ local function show_diagnostics(opts, diagnostics)
diagnostics = prefix_source(opts.source, diagnostics)
end
+ -- Use global setting for severity_sort since 'show_diagnostics' is namespace
+ -- independent
+ local severity_sort = global_diagnostic_options.severity_sort
+ if severity_sort then
+ if type(severity_sort) == "table" and severity_sort.reverse then
+ table.sort(diagnostics, function(a, b) return a.severity > b.severity end)
+ else
+ table.sort(diagnostics, function(a, b) return a.severity < b.severity end)
+ end
+ end
+
for i, diagnostic in ipairs(diagnostics) do
local prefix = string.format("%d. ", i)
local hiname = floating_highlight_map[diagnostic.severity]
@@ -510,6 +534,9 @@ local function diagnostic_move_pos(opts, pos)
return
end
+ -- Save position in the window's jumplist
+ vim.api.nvim_win_call(win_id, function() vim.cmd("normal! m'") end)
+
vim.api.nvim_win_set_cursor(win_id, {pos[1] + 1, pos[2]})
if enable_popup then
@@ -527,10 +554,27 @@ end
--- Configure diagnostic options globally or for a specific diagnostic
--- namespace.
---
+--- Configuration can be specified globally, per-namespace, or ephemerally
+--- (i.e. only for a single call to |vim.diagnostic.set()| or
+--- |vim.diagnostic.show()|). Ephemeral configuration has highest priority,
+--- followed by namespace configuration, and finally global configuration.
+---
+--- For example, if a user enables virtual text globally with
+--- <pre>
+--- vim.diagnostic.config({virt_text = true})
+--- </pre>
+---
+--- and a diagnostic producer sets diagnostics with
+--- <pre>
+--- vim.diagnostic.set(ns, 0, diagnostics, {virt_text = false})
+--- </pre>
+---
+--- then virtual text will not be enabled for those diagnostics.
+---
---@note Each of the configuration options below accepts one of the following:
--- - `false`: Disable this feature
--- - `true`: Enable this feature, use default settings.
---- - `table`: Enable this feature with overrides.
+--- - `table`: Enable this feature with overrides. Use an empty table to use default values.
--- - `function`: Function with signature (namespace, bufnr) that returns any of the above.
---
---@param opts table Configuration table with the following keys:
@@ -638,8 +682,6 @@ function M.set(namespace, bufnr, diagnostics, opts)
if vim.api.nvim_buf_is_loaded(bufnr) then
M.show(namespace, bufnr, diagnostics, opts)
- elseif opts then
- M.config(opts, namespace)
end
vim.api.nvim_command("doautocmd <nomodeline> User DiagnosticsChanged")
@@ -1140,7 +1182,6 @@ function M.show_position_diagnostics(opts, bufnr, position)
local diagnostics = M.get(bufnr, opts)
clamp_line_numbers(bufnr, diagnostics)
local position_diagnostics = vim.tbl_filter(match_position_predicate, diagnostics)
- table.sort(position_diagnostics, function(a, b) return a.severity < b.severity end)
return show_diagnostics(opts, position_diagnostics)
end
@@ -1263,6 +1304,7 @@ end
--- <pre>
--- WARNING filename:27:3: Variable 'foo' does not exist
--- </pre>
+---
--- This can be parsed into a diagnostic |diagnostic-structure|
--- with:
--- <pre>
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua
index c7a88a0993..9c35351608 100644
--- a/runtime/lua/vim/lsp.lua
+++ b/runtime/lua/vim/lsp.lua
@@ -41,6 +41,7 @@ lsp._request_name_to_capability = {
['textDocument/documentSymbol'] = 'document_symbol';
['textDocument/prepareCallHierarchy'] = 'call_hierarchy';
['textDocument/rename'] = 'rename';
+ ['textDocument/prepareRename'] = 'rename';
['textDocument/codeAction'] = 'code_action';
['textDocument/codeLens'] = 'code_lens';
['codeLens/resolve'] = 'code_lens_resolve';
@@ -85,7 +86,7 @@ end
function lsp._unsupported_method(method)
local msg = string.format("method %s is not supported by any of the servers registered for the current buffer", method)
log.warn(msg)
- return lsp.rpc_response_error(protocol.ErrorCodes.MethodNotFound, msg)
+ return msg
end
---@private
@@ -130,15 +131,28 @@ local all_client_active_buffers = {}
---@param bufnr (Number) of buffer
---@param fn (function({client}, {client_id}, {bufnr}) Function to run on
---each client attached to that buffer.
-local function for_each_buffer_client(bufnr, fn)
+---@param restrict_client_ids table list of client ids on which to restrict function application.
+local function for_each_buffer_client(bufnr, fn, restrict_client_ids)
validate {
fn = { fn, 'f' };
+ restrict_client_ids = { restrict_client_ids, 't' , true};
}
bufnr = resolve_bufnr(bufnr)
local client_ids = all_buffer_active_clients[bufnr]
if not client_ids or tbl_isempty(client_ids) then
return
end
+
+ if restrict_client_ids and #restrict_client_ids > 0 then
+ local filtered_client_ids = {}
+ for client_id in pairs(client_ids) do
+ if vim.tbl_contains(restrict_client_ids, client_id) then
+ filtered_client_ids[client_id] = true
+ end
+ end
+ client_ids = filtered_client_ids
+ end
+
for client_id in pairs(client_ids) do
local client = active_clients[client_id]
if client then
@@ -1254,33 +1268,33 @@ function lsp.buf_request(bufnr, method, params, handler)
method = { method, 's' };
handler = { handler, 'f', true };
}
- local client_request_ids = {}
+ local supported_clients = {}
local method_supported = false
- for_each_buffer_client(bufnr, function(client, client_id, resolved_bufnr)
+ for_each_buffer_client(bufnr, function(client, client_id)
if client.supports_method(method) then
method_supported = true
- local request_success, request_id = client.request(method, params, handler, resolved_bufnr)
-
- -- This could only fail if the client shut down in the time since we looked
- -- it up and we did the request, which should be rare.
- if request_success then
- client_request_ids[client_id] = request_id
- end
+ table.insert(supported_clients, client_id)
end
end)
- -- if has client but no clients support the given method, call the callback with the proper
- -- error message.
+ -- if has client but no clients support the given method, notify the user
if not tbl_isempty(all_buffer_active_clients[resolve_bufnr(bufnr)] or {}) and not method_supported then
- local unsupported_err = lsp._unsupported_method(method)
- handler = handler or lsp.handlers[method]
- if handler then
- handler(unsupported_err, nil, {method=method, bufnr=bufnr})
- end
+ vim.notify(lsp._unsupported_method(method), vim.log.levels.ERROR)
+ vim.api.nvim_command("redraw")
return
end
+ local client_request_ids = {}
+ for_each_buffer_client(bufnr, function(client, client_id, resolved_bufnr)
+ local request_success, request_id = client.request(method, params, handler, resolved_bufnr)
+ -- This could only fail if the client shut down in the time since we looked
+ -- it up and we did the request, which should be rare.
+ if request_success then
+ client_request_ids[client_id] = request_id
+ end
+ end, supported_clients)
+
local function _cancel_all_requests()
for client_id, request_id in pairs(client_request_ids) do
local client = active_clients[client_id]
@@ -1308,12 +1322,13 @@ function lsp.buf_request_all(bufnr, method, params, callback)
local request_results = {}
local result_count = 0
local expected_result_count = 0
- local cancel, client_request_ids
- local set_expected_result_count = once(function()
- for _ in pairs(client_request_ids) do
- expected_result_count = expected_result_count + 1
- end
+ local set_expected_result_count = once(function ()
+ for_each_buffer_client(bufnr, function(client)
+ if client.supports_method(method) then
+ expected_result_count = expected_result_count + 1
+ end
+ end)
end)
local function _sync_handler(err, result, ctx)
@@ -1326,7 +1341,7 @@ function lsp.buf_request_all(bufnr, method, params, callback)
end
end
- client_request_ids, cancel = lsp.buf_request(bufnr, method, params, _sync_handler)
+ local _, cancel = lsp.buf_request(bufnr, method, params, _sync_handler)
return cancel
end
@@ -1383,6 +1398,29 @@ function lsp.buf_notify(bufnr, method, params)
return resp
end
+
+---@private
+local function adjust_start_col(lnum, line, items, encoding)
+ local min_start_char = nil
+ for _, item in pairs(items) do
+ if item.textEdit and item.textEdit.range.start.line == lnum - 1 then
+ if min_start_char and min_start_char ~= item.textEdit.range.start.character then
+ return nil
+ end
+ min_start_char = item.textEdit.range.start.character
+ end
+ end
+ if min_start_char then
+ if encoding == 'utf-8' then
+ return min_start_char
+ else
+ return vim.str_byteindex(line, min_start_char, encoding == 'utf-16')
+ end
+ else
+ return nil
+ end
+end
+
--- Implements 'omnifunc' compatible LSP completion.
---
---@see |complete-functions|
@@ -1418,17 +1456,37 @@ function lsp.omnifunc(findstart, base)
-- Get the start position of the current keyword
local textMatch = vim.fn.match(line_to_cursor, '\\k*$')
- local prefix = line_to_cursor:sub(textMatch+1)
local params = util.make_position_params()
local items = {}
- lsp.buf_request(bufnr, 'textDocument/completion', params, function(err, result)
+ lsp.buf_request(bufnr, 'textDocument/completion', params, function(err, result, ctx)
if err or not result or vim.fn.mode() ~= "i" then return end
+
+ -- Completion response items may be relative to a position different than `textMatch`.
+ -- Concrete example, with sumneko/lua-language-server:
+ --
+ -- require('plenary.asy|
+ -- ▲ ▲ ▲
+ -- │ │ └── cursor_pos: 20
+ -- │ └────── textMatch: 17
+ -- └────────────── textEdit.range.start.character: 9
+ -- .newText = 'plenary.async'
+ -- ^^^
+ -- prefix (We'd remove everything not starting with `asy`,
+ -- so we'd eliminate the `plenary.async` result
+ --
+ -- `adjust_start_col` is used to prefer the language server boundary.
+ --
+ local client = lsp.get_client_by_id(ctx.client_id)
+ local encoding = client and client.offset_encoding or 'utf-16'
+ local candidates = util.extract_completion_items(result)
+ local startbyte = adjust_start_col(pos[1], line, candidates, encoding) or textMatch
+ local prefix = line:sub(startbyte + 1, pos[2])
local matches = util.text_document_completion_list_to_complete_items(result, prefix)
-- TODO(ashkan): is this the best way to do this?
vim.list_extend(items, matches)
- vim.fn.complete(textMatch+1, items)
+ vim.fn.complete(startbyte + 1, items)
end)
-- Return -2 to signal that we should continue completion so that we can
diff --git a/runtime/lua/vim/lsp/rpc.lua b/runtime/lua/vim/lsp/rpc.lua
index b1bdb24def..d9a684a738 100644
--- a/runtime/lua/vim/lsp/rpc.lua
+++ b/runtime/lua/vim/lsp/rpc.lua
@@ -466,15 +466,12 @@ local function start(cmd, cmd_args, dispatchers, extra_spawn_params)
-- We sent a number, so we expect a number.
local result_id = tonumber(decoded.id)
- -- Do not surface RequestCancelled or ContentModified to users, it is RPC-internal.
+ -- Do not surface RequestCancelled to users, it is RPC-internal.
if decoded.error then
local mute_error = false
if decoded.error.code == protocol.ErrorCodes.RequestCancelled then
local _ = log.debug() and log.debug("Received cancellation ack", decoded)
mute_error = true
- elseif decoded.error.code == protocol.ErrorCodes.ContentModified then
- local _ = log.debug() and log.debug("Received content modified ack", decoded)
- mute_error = true
end
if mute_error then
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua
index fca956fb57..3751f94caf 100644
--- a/runtime/lua/vim/lsp/util.lua
+++ b/runtime/lua/vim/lsp/util.lua
@@ -193,6 +193,7 @@ function M.get_progress_messages()
title = ctx.title or "empty title",
message = ctx.message,
percentage = ctx.percentage,
+ done = ctx.done,
progress = true,
}
table.insert(new_messages, new_report)
diff --git a/runtime/lua/vim/uri.lua b/runtime/lua/vim/uri.lua
index a3e79a0f2b..5d8d4fa169 100644
--- a/runtime/lua/vim/uri.lua
+++ b/runtime/lua/vim/uri.lua
@@ -75,13 +75,22 @@ local function uri_from_fname(path)
end
local URI_SCHEME_PATTERN = '^([a-zA-Z]+[a-zA-Z0-9+-.]*):.*'
+local WINDOWS_URI_SCHEME_PATTERN = '^([a-zA-Z]+[a-zA-Z0-9+-.]*):[a-zA-Z]:.*'
--- Get a URI from a bufnr
---@param bufnr (number): Buffer number
---@return URI
local function uri_from_bufnr(bufnr)
local fname = vim.api.nvim_buf_get_name(bufnr)
- local scheme = fname:match(URI_SCHEME_PATTERN)
+ local volume_path = fname:match("^([a-zA-Z]:).*")
+ local is_windows = volume_path ~= nil
+ local scheme
+ if is_windows then
+ fname = fname:gsub("\\", "/")
+ scheme = fname:match(WINDOWS_URI_SCHEME_PATTERN)
+ else
+ scheme = fname:match(URI_SCHEME_PATTERN)
+ end
if scheme then
return fname
else
diff --git a/runtime/syntax/css.vim b/runtime/syntax/css.vim
index 19326d01e4..67ad1ea335 100644
--- a/runtime/syntax/css.vim
+++ b/runtime/syntax/css.vim
@@ -2,12 +2,12 @@
" Language: Cascading Style Sheets
" Previous Contributor List:
" Jules Wang <w.jq0722@gmail.com>
-" Claudio Fleiner <claudio@fleiner.com> (Maintainer)
+" Claudio Fleiner <claudio@fleiner.com>
" Yeti (Add full CSS2, HTML4 support)
" Nikolai Weibull (Add CSS2 support)
-" URL: https://github.com/jsit/css.vim
+" URL: https://github.com/vim-language-dept/css-syntax.vim
" Maintainer: Jay Sitter <jay@jaysitter.com>
-" Last Change: 2019 Jul. 29
+" Last Change: 2021 Oct 15
" quit when a syntax file was already loaded
if !exists("main_syntax")
@@ -23,6 +23,8 @@ let s:cpo_save = &cpo
set cpo&vim
syn case ignore
+" Add dash to allowed keyword characters.
+syn iskeyword @,48-57,_,192-255,-
" HTML4 tags
syn keyword cssTagName abbr address area a b base
@@ -32,7 +34,7 @@ syn keyword cssTagName dfn div dl dt em fieldset form
syn keyword cssTagName h1 h2 h3 h4 h5 h6 head hr html img i
syn keyword cssTagName iframe input ins isindex kbd label legend li
syn keyword cssTagName link map menu meta noscript ol optgroup
-syn keyword cssTagName option p param pre q s samp script small
+syn keyword cssTagName option p param picture pre q s samp script small
syn keyword cssTagName span strong sub sup tbody td
syn keyword cssTagName textarea tfoot th thead title tr ul u var
syn keyword cssTagName object svg
@@ -127,7 +129,7 @@ syn region cssURL contained matchgroup=cssFunctionName start="\<\(uri\|url\|loca
syn region cssFunction contained matchgroup=cssFunctionName start="\<\(var\|calc\)\s*(" end=")" contains=cssCustomProp,cssValue.*,cssFunction,cssColor,cssStringQ,cssStringQQ oneline
syn region cssFunction contained matchgroup=cssFunctionName start="\<\(rgb\|clip\|attr\|counter\|rect\|cubic-bezier\|steps\)\s*(" end=")" oneline contains=cssValueInteger,cssValueNumber,cssValueLength,cssFunctionComma
syn region cssFunction contained matchgroup=cssFunctionName start="\<\(rgba\|hsl\|hsla\|color-stop\|from\|to\)\s*(" end=")" oneline contains=cssColor,cssValueInteger,cssValueNumber,cssValueLength,cssFunctionComma,cssFunction
-syn region cssFunction contained matchgroup=cssFunctionName start="\<\(linear-\|radial-\)\=\gradient\s*(" end=")" oneline contains=cssColor,cssValueInteger,cssValueNumber,cssValueLength,cssFunction,cssGradientAttr,cssFunctionComma
+syn region cssFunction contained matchgroup=cssFunctionName start="\<\(linear-\|radial-\|conic-\)\=\gradient\s*(" end=")" oneline contains=cssColor,cssValueInteger,cssValueNumber,cssValueLength,cssFunction,cssGradientAttr,cssFunctionComma
syn region cssFunction contained matchgroup=cssFunctionName start="\<\(matrix\(3d\)\=\|scale\(3d\|X\|Y\|Z\)\=\|translate\(3d\|X\|Y\|Z\)\=\|skew\(X\|Y\)\=\|rotate\(3d\|X\|Y\|Z\)\=\|perspective\)\s*(" end=")" oneline contains=cssValueInteger,cssValueNumber,cssValueLength,cssValueAngle,cssFunctionComma
syn region cssFunction contained matchgroup=cssFunctionName start="\<\(blur\|brightness\|contrast\|drop-shadow\|grayscale\|hue-rotate\|invert\|opacity\|saturate\|sepia\)\s*(" end=")" oneline contains=cssValueInteger,cssValueNumber,cssValueLength,cssValueAngle,cssFunctionComma
syn keyword cssGradientAttr contained top bottom left right cover center middle ellipse at
@@ -220,7 +222,7 @@ syn keyword cssFlexibleBoxProp contained order
syn match cssFlexibleBoxAttr contained "\<\(row\|column\|wrap\)\(-reverse\)\=\>"
syn keyword cssFlexibleBoxAttr contained nowrap stretch baseline center
syn match cssFlexibleBoxAttr contained "\<flex\(-\(start\|end\)\)\=\>"
-syn match cssFlexibleBoxAttr contained "\<space\(-\(between\|around\)\)\=\>"
+syn match cssFlexibleBoxAttr contained "\<space\(-\(between\|around\|evenly\)\)\=\>"
" CSS Fonts Module Level 3
" http://www.w3.org/TR/css-fonts-3/
@@ -234,9 +236,7 @@ syn keyword cssFontAttr contained larger smaller
syn match cssFontAttr contained "\<\(x\{1,2\}-\)\=\(large\|small\)\>"
syn match cssFontAttr contained "\<small-\(caps\|caption\)\>"
" font-family attributes
-syn match cssFontAttr contained "\<\(sans-\)\=serif\>"
-syn keyword cssFontAttr contained Antiqua Arial Black Book Charcoal Comic Courier Dingbats Gadget Geneva Georgia Grande Helvetica Impact Linotype Lucida MS Monaco Neue New Palatino Roboto Roman Symbol Tahoma Times Trebuchet Verdana Webdings Wingdings York Zapf
-syn keyword cssFontAttr contained cursive fantasy monospace
+syn keyword cssFontAttr contained sans-serif serif cursive fantasy monospace
" font-feature-settings attributes
syn keyword cssFontAttr contained on off
" font-stretch attributes
@@ -283,6 +283,7 @@ syn match cssGridProp contained "\<grid\>"
syn match cssGridProp contained "\<grid-template\(-\(columns\|rows\|areas\)\)\=\>"
syn match cssGridProp contained "\<grid-\(column\|row\)\(-\(start\|end\|gap\)\)\=\>"
syn match cssGridProp contained "\<grid-\(area\|gap\)\>"
+syn match cssGridProp contained "\<gap\>"
syn match cssGridProp contained "\<grid-auto-\(flow\|rows\|columns\)\>"
syn match cssHyerlinkProp contained "\<target\(-\(name\|new\|position\)\)\=\>"
@@ -294,6 +295,10 @@ syn match cssListAttr contained "\<\(decimal\(-leading-zero\)\=\|cjk-ideographic
syn keyword cssListAttr contained disc circle square hebrew armenian georgian
syn keyword cssListAttr contained inside outside
+" object-fit https://www.w3.org/TR/css-images-3/#the-object-fit
+syn match cssObjectProp contained "\<object-\(fit\|position\)\>"
+syn keyword cssObjectAttr contained fill contain cover scale-down
+
syn keyword cssPositioningProp contained bottom clear clip display float left
syn keyword cssPositioningProp contained position right top visibility
syn match cssPositioningProp contained "\<z-index\>"
@@ -303,7 +308,7 @@ syn keyword cssPositioningAttr contained left right both
syn match cssPositioningAttr contained "\<list-item\>"
syn match cssPositioningAttr contained "\<inline\(-\(block\|box\|table\|grid\|flex\)\)\=\>"
syn match cssPositioningAttr contained "\<flow\(-root\)\=\>"
-syn keyword cssPositioningAttr contained static relative absolute fixed subgrid
+syn keyword cssPositioningAttr contained static relative absolute fixed subgrid sticky
syn keyword cssPrintAttr contained landscape portrait crop cross always
@@ -548,6 +553,7 @@ hi def link cssMarqueeProp cssProp
hi def link cssMultiColumnProp cssProp
hi def link cssPagedMediaProp cssProp
hi def link cssPositioningProp cssProp
+hi def link cssObjectProp cssProp
hi def link cssPrintProp cssProp
hi def link cssRubyProp cssProp
hi def link cssSpeechProp cssProp
@@ -581,6 +587,7 @@ hi def link cssMultiColumnAttr cssAttr
hi def link cssPaddingAttr cssAttr
hi def link cssPagedMediaAttr cssAttr
hi def link cssPositioningAttr cssAttr
+hi def link cssObjectAttr cssAttr
hi def link cssGradientAttr cssAttr
hi def link cssPrintAttr cssAttr
hi def link cssRubyAttr cssAttr
diff --git a/runtime/syntax/tcsh.vim b/runtime/syntax/tcsh.vim
index 27c6417fd0..6837125129 100644
--- a/runtime/syntax/tcsh.vim
+++ b/runtime/syntax/tcsh.vim
@@ -1,8 +1,9 @@
-" tcsh.vim: Vim syntax file for tcsh scripts
-" Maintainer: Doug Kearns <dougkearns@NoSpam.com> where NoSpam=gmail
-" Author: Gautam Iyer <gi1242+vim@NoSpam.com> where NoSpam=gmail
-" Modified: Sun 26 Sep 2021 12:40:55 PM EDT
-"
+" Vim syntax file
+" Language: tcsh scripts
+" Maintainer: Doug Kearns <dougkearns@gmail.com>
+" Previous Maintainer: Gautam Iyer <gi1242+vim@NoSpam.com> where NoSpam=gmail (Original Author)
+" Last Change: 2021 Oct 15
+
" Description: We break up each statement into a "command" and an "end" part.
" All groups are either a "command" or part of the "end" of a statement (ie
" everything after the "command"). This is because blindly highlighting tcsh
@@ -20,36 +21,36 @@ endif
let s:oldcpo = &cpo
set cpo&vim " Line continuation is used
-setlocal iskeyword+=-
+syn iskeyword @,48-57,_,192-255,-
syn case match
-" ----- Clusters -----
+" ----- Clusters ----- {{{1
syn cluster tcshModifiers contains=tcshModifier,tcshModifierError
syn cluster tcshQuoteList contains=tcshDQuote,tcshSQuote,tcshBQuote
-syn cluster tcshStatementEnds contains=@tcshQuoteList,tcshComment,@tcshVarList,tcshRedir,tcshMeta,tcshHereDoc,tcshSpecial,tcshArguement
+syn cluster tcshStatementEnds contains=@tcshQuoteList,tcshComment,@tcshVarList,tcshRedir,tcshMeta,tcshHereDoc,tcshSpecial,tcshArgument
syn cluster tcshStatements contains=tcshBuiltin,tcshCommands,tcshIf,tcshWhile
syn cluster tcshVarList contains=tcshUsrVar,tcshArgv,tcshSubst
syn cluster tcshConditions contains=tcshCmdSubst,tcshParenExpr,tcshOperator,tcshNumber,@tcshVarList
-" ----- Errors -----
+" ----- Errors ----- {{{1
" Define first, so can be easily overridden.
syn match tcshError contained '\v\S.+'
-" ----- Statements -----
+" ----- Statements ----- {{{1
" Tcsh commands: Any filename / modifiable variable (must be first!)
syn match tcshCommands '\v[a-zA-Z0-9\\./_$:-]+' contains=tcshSpecial,tcshUsrVar,tcshArgv,tcshVarError nextgroup=tcshStatementEnd
" Builtin commands except those treated specially. Currently (un)set(env),
" (un)alias, if, while, else, bindkey
-syn keyword tcshBuiltin nextgroup=tcshStatementEnd alloc bg break breaksw builtins bye case cd chdir complete continue default dirs echo echotc end endif endsw eval exec exit fg filetest foreach getspath getxvers glob goto hashstat history hup inlib jobs kill limit log login logout ls ls-F migrate newgrp nice nohup notify onintr popd printenv pushd rehash repeat rootnode sched setpath setspath settc setty setxvers shift source stop suspend switch telltc time umask uncomplete unhash universe unlimit ver wait warp watchlog where which
+syn keyword tcshBuiltin nextgroup=tcshStatementEnd alloc bg break breaksw builtins bye case cd chdir complete continue default dirs echo echotc end endif endsw eval exec exit fg filetest foreach getspath getxvers glob goto hashstat history hup inlib jobs kill limit log login logout ls ls-F migrate newgrp nice nohup notify onintr popd printenv pushd rehash repeat rootnode sched setpath setspath settc setty setxvers shift source stop suspend switch telltc termname time umask uncomplete unhash universe unlimit ver wait warp watchlog where which
" StatementEnd is anything after a built-in / command till the lexical end of a
" statement (;, |, ||, |&, && or end of line)
syn region tcshStatementEnd transparent contained matchgroup=tcshBuiltin start='' end='\v\\@<!(;|\|[|&]?|\&\&|$)' contains=@tcshStatementEnds
" set expressions (Contains shell variables)
-syn keyword tcshShellVar contained afsuser ampm argv autocorrect autoexpand autolist autologout backslash_quote catalog cdpath color colorcat command complete continue continue_args correct cwd dextract dirsfile dirstack dspmbyte dunique echo echo_style edit ellipsis fignore filec gid group histchars histdup histfile histlit history home ignoreeof implicitcd inputmode killdup killring listflags listjobs listlinks listmax listmaxrows loginsh logout mail matchbeep nobeep noclobber noding noglob nokanji nonomatch nostat notify oid owd path printexitvalue prompt prompt2 prompt3 promptchars pushdtohome pushdsilent recexact recognize_only_executables rmstar rprompt savedirs savehist sched shell shlvl status symlinks tcsh term time tperiod tty uid user verbose version visiblebell watch who wordchars
+syn keyword tcshShellVar contained addsuffix afsuser ampm anyerror argv autocorrect autoexpand autolist autologout autorehash backslash_quote catalog cdpath cdtohome color colorcat command compat_expr complete continue continue_args correct csubstnonl cwd dextract dirsfile dirstack dspmbyte dunique echo echo_style edit editors ellipsis euid euser fignore filec gid globdot globstar group highlight histchars histdup histfile histlit history home ignoreeof implicitcd inputmode killdup killring listflags listjobs listlinks listmax listmaxrows loginsh logout mail matchbeep nobeep noclobber noding noglob nokanji nonomatch nostat notify oid owd padhour parseoctal path printexitvalue prompt prompt2 prompt3 promptchars pushdtohome pushdsilent recexact recognize_only_executables rmstar rprompt savedirs savehist sched shell shlvl status symlinks tcsh term time tperiod tty uid user verbose version vimode visiblebell watch who wordchars
syn keyword tcshBuiltin nextgroup=tcshSetEnd set unset
syn region tcshSetEnd contained transparent matchgroup=tcshBuiltin start='' skip='\\$' end='$\|;' contains=tcshShellVar,@tcshStatementEnds
@@ -96,14 +97,15 @@ syn keyword tcshBindkeyFuncs contained backward-char backward-delete-char
\ history-search-forward insert-last-word i-search-fwd
\ i-search-back keyboard-quit kill-line kill-region
\ kill-whole-line list-choices list-choices-raw list-glob
- \ list-or-eof load-average magic-space newline normalize-path
- \ normalize-command overwrite-mode prefix-meta quoted-insert
- \ redisplay run-fg-editor run-help self-insert-command
- \ sequence-lead-in set-mark-command spell-word spell-line
- \ stuff-char toggle-literal-history transpose-chars
- \ transpose-gosling tty-dsusp tty-flush-output tty-sigintr
- \ tty-sigquit tty-sigtsusp tty-start-output tty-stop-output
- \ undefined-key universal-argument up-history upcase-word
+ \ list-or-eof load-average magic-space newline newline-and-hold
+ \ newline-and-down-history normalize-path normalize-command
+ \ overwrite-mode prefix-meta quoted-insert redisplay
+ \ run-fg-editor run-help self-insert-command sequence-lead-in
+ \ set-mark-command spell-word spell-line stuff-char
+ \ toggle-literal-history transpose-chars transpose-gosling
+ \ tty-dsusp tty-flush-output tty-sigintr tty-sigquit tty-sigtsusp
+ \ tty-start-output tty-stop-output undefined-key
+ \ universal-argument up-history upcase-word
\ vi-beginning-of-next-word vi-add vi-add-at-eol vi-chg-case
\ vi-chg-meta vi-chg-to-eol vi-cmd-mode vi-cmd-mode-complete
\ vi-delprev vi-delmeta vi-endword vi-eword vi-char-back
@@ -116,7 +118,7 @@ syn keyword tcshBindkeyFuncs contained backward-char backward-delete-char
\ e_paste_from_clipboard e_dosify_next e_dosify_prev e_page_up
\ e_page_down
syn keyword tcshBuiltin nextgroup=tcshBindkeyEnd bindkey
-syn region tcshBindkeyEnd contained transparent matchgroup=tcshBuiltin start='' skip='\\$' end='$' contains=@tcshQuoteList,tcshComment,@tcshVarList,tcshMeta,tcshSpecial,tcshArguement,tcshBindkeyFuncs
+syn region tcshBindkeyEnd contained transparent matchgroup=tcshBuiltin start='' skip='\\$' end='$' contains=@tcshQuoteList,tcshComment,@tcshVarList,tcshMeta,tcshSpecial,tcshArgument,tcshBindkeyFuncs
" Expressions start with @.
syn match tcshExprStart '\v\@\s+' nextgroup=tcshExprVar
@@ -126,20 +128,20 @@ syn match tcshExprOp contained '\v\s*\=' nextgroup=tcshExprEnd
syn match tcshExprEnd contained '\v.*$'hs=e+1 contains=@tcshConditions
syn match tcshExprEnd contained '\v.{-};'hs=e contains=@tcshConditions
-" ----- Comments: -----
+" ----- Comments: ----- {{{1
syn match tcshComment '#\s.*' contains=tcshTodo,tcshCommentTi,@Spell
syn match tcshComment '\v#($|\S.*)' contains=tcshTodo,tcshCommentTi
syn match tcshSharpBang '^#! .*$'
syn match tcshCommentTi contained '\v#\s*\u\w*(\s+\u\w*)*:'hs=s+1 contains=tcshTodo
syn match tcshTodo contained '\v\c<todo>'
-" ----- Strings -----
+" ----- Strings ----- {{{1
" Tcsh does not allow \" in strings unless the "backslash_quote" shell
" variable is set. Set the vim variable "tcsh_backslash_quote" to 0 if you
" want VIM to assume that no backslash quote constructs exist.
" Backquotes are treated as commands, and are not contained in anything
-if(exists('tcsh_backslash_quote') && tcsh_backslash_quote == 0)
+if exists('tcsh_backslash_quote') && tcsh_backslash_quote == 0
syn region tcshSQuote keepend contained start="\v\\@<!'" end="'"
syn region tcshDQuote keepend contained start='\v\\@<!"' end='"' contains=@tcshVarList,tcshSpecial,@Spell
syn region tcshBQuote keepend start='\v\\@<!`' end='`' contains=@tcshStatements
@@ -149,7 +151,7 @@ else
syn region tcshBQuote keepend matchgroup=tcshBQuoteGrp start='\v\\@<!`' skip='\v\\\\|\\`' end='`' contains=@tcshStatements
endif
-" ----- Variables -----
+" ----- Variables ----- {{{1
" Variable Errors. Must come first! \$ constructs will be flagged by
" tcshSpecial, so we don't consider them here.
syn match tcshVarError '\v\$\S*' contained
@@ -171,7 +173,7 @@ syn match tcshSubst contained '\v\$\{[%#?]%(\h\w*|\d+)%(:\S*)?\}' contains=tcshM
syn match tcshModifierError contained '\v:\S*'
syn match tcshModifier contained '\v:[ag]?[htreuls&qx]' nextgroup=@tcshModifiers
-" ----- Operators / Specials -----
+" ----- Operators / Specials ----- {{{1
" Standard redirects (except <<) [<, >, >>, >>&, >>!, >>&!]
syn match tcshRedir contained '\v\<|\>\>?\&?!?'
@@ -190,13 +192,13 @@ syn match tcshOperator contained '&&\|!\~\|!=\|<<\|<=\|==\|=\~\|>=\|>>\|\*\|\^\|
syn match tcshNumber contained '\v<-?\d+>'
" Arguments
-syn match tcshArguement contained '\v\s@<=-(\w|-)*'
+syn match tcshArgument contained '\v\s@<=-(\w|-)*'
" Special characters. \xxx, or backslashed characters.
"syn match tcshSpecial contained '\v\\@<!\\(\d{3}|.)'
syn match tcshSpecial contained '\v\\%([0-7]{3}|.)'
-" ----- Synchronising -----
+" ----- Synchronising ----- {{{1
if exists('tcsh_minlines')
if tcsh_minlines == 'fromstart'
syn sync fromstart
@@ -207,6 +209,7 @@ else
syn sync minlines=100 " Some completions can be quite long
endif
+" ----- Highlighting ----- {{{1
" Define highlighting of syntax groups
hi def link tcshError Error
hi def link tcshBuiltin Statement
@@ -233,17 +236,20 @@ hi def link tcshVarError Error
hi def link tcshUsrVar Type
hi def link tcshArgv tcshUsrVar
hi def link tcshSubst tcshUsrVar
-hi def link tcshModifier tcshArguement
+hi def link tcshModifier tcshArgument
hi def link tcshModifierError tcshVarError
hi def link tcshMeta tcshSubst
hi def link tcshRedir tcshOperator
hi def link tcshHereDoc tcshSQuote
hi def link tcshOperator Operator
hi def link tcshNumber Number
-hi def link tcshArguement Special
+hi def link tcshArgument Special
hi def link tcshSpecial SpecialChar
+" }}}
let &cpo = s:oldcpo
unlet s:oldcpo
let b:current_syntax = 'tcsh'
+
+" vim: nowrap sw=2 sts=2 ts=8 noet fdm=marker:
diff --git a/runtime/syntax/tmux.vim b/runtime/syntax/tmux.vim
index 4f435ab923..867c033cb5 100644
--- a/runtime/syntax/tmux.vim
+++ b/runtime/syntax/tmux.vim
@@ -1,5 +1,5 @@
" Language: tmux(1) configuration file
-" Version: 3.0 (git-48cbbb87)
+" Version: 3.2a (git-44ada9cd)
" URL: https://github.com/ericpruitt/tmux.vim/
" Maintainer: Eric Pruitt <eric.pruitt@gmail.com>
" License: 2-Clause BSD (http://opensource.org/licenses/BSD-2-Clause)
@@ -30,14 +30,14 @@ syn match tmuxVariable /\w\+=/ display
syn match tmuxVariableExpansion /\${\=\w\+}\=/ display
syn match tmuxControl /%\(if\|elif\|else\|endif\)/
-syn region tmuxComment start=/#/ skip=/\\\@<!\\$/ end=/$/ contains=tmuxTodo
+syn region tmuxComment start=/#/ skip=/\\\@<!\\$/ end=/$/ contains=tmuxTodo,@Spell
-syn region tmuxString start=+"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=tmuxFormatString
-syn region tmuxString start=+'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end='$' contains=tmuxFormatString
+syn region tmuxString start=+"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=tmuxFormatString,@Spell
+syn region tmuxString start=+'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end='$' contains=tmuxFormatString,@Spell
" TODO: Figure out how escaping works inside of #(...) and #{...} blocks.
syn region tmuxFormatString start=/#[#DFhHIPSTW]/ end=// contained keepend
-syn region tmuxFormatString start=/#{/ skip=/#{.\{-}}/ end=/}/ contained keepend
+syn region tmuxFormatString start=/#{/ skip=/#{.\{-}}/ end=/}/ keepend
syn region tmuxFormatString start=/#(/ skip=/#(.\{-})/ end=/)/ contained keepend
hi def link tmuxFormatString Identifier
@@ -55,62 +55,69 @@ hi def link tmuxTodo Todo
hi def link tmuxVariable Identifier
hi def link tmuxVariableExpansion Identifier
-" Make the foreground of colourXXX keywords match the color they represent.
+" Make the foreground of colourXXX keywords match the color they represent
+" when g:tmux_syntax_colors is unset or set to a non-zero value.
" Darker colors have their background set to white.
-for s:i in range(0, 255)
- let s:bg = (!s:i || s:i == 16 || (s:i > 231 && s:i < 235)) ? 15 : "none"
- exec "syn match tmuxColour" . s:i . " /\\<colour" . s:i . "\\>/ display"
-\ " | highlight tmuxColour" . s:i . " ctermfg=" . s:i . " ctermbg=" . s:bg
-endfor
+if get(g:, "tmux_syntax_colors", 1)
+ for s:i in range(0, 255)
+ let s:bg = (!s:i || s:i == 16 || (s:i > 231 && s:i < 235)) ? 15 : "none"
+ exec "syn match tmuxColour" . s:i . " /\\<colour" . s:i . "\\>/ display"
+\ " | highlight tmuxColour" . s:i . " ctermfg=" . s:i . " ctermbg=" . s:bg
+ endfor
+endif
syn keyword tmuxOptions
-\ backspace buffer-limit command-alias default-terminal escape-time
-\ exit-empty activity-action assume-paste-time base-index bell-action
-\ default-command default-shell default-size destroy-unattached
+\ backspace buffer-limit command-alias copy-command default-terminal editor
+\ escape-time exit-empty activity-action assume-paste-time base-index
+\ bell-action default-command default-shell default-size destroy-unattached
\ detach-on-destroy display-panes-active-colour display-panes-colour
-\ display-panes-time display-time exit-unattached focus-events history-file
-\ history-limit key-table lock-after-time lock-command message-command-style
-\ message-limit message-style aggressive-resize allow-rename
-\ alternate-screen automatic-rename automatic-rename-format
-\ clock-mode-colour clock-mode-style main-pane-height main-pane-width
-\ mode-keys mode-style monitor-activity monitor-bell monitor-silence mouse
-\ other-pane-height other-pane-width pane-active-border-style
-\ pane-base-index pane-border-format pane-border-status pane-border-style
-\ prefix prefix2 remain-on-exit renumber-windows repeat-time set-clipboard
-\ set-titles set-titles-string silence-action status status-bg status-fg
-\ status-format status-interval status-justify status-keys status-left
-\ status-left-length status-left-style status-position status-right
-\ status-right-length status-right-style status-style synchronize-panes
-\ terminal-overrides update-environment user-keys visual-activity
-\ visual-bell visual-silence window-active-style window-size
-\ window-status-activity-style window-status-bell-style
+\ display-panes-time display-time exit-unattached extended-keys focus-events
+\ history-file history-limit key-table lock-after-time lock-command
+\ message-command-style message-limit message-style aggressive-resize
+\ allow-rename alternate-screen automatic-rename automatic-rename-format
+\ clock-mode-colour clock-mode-style copy-mode-current-match-style
+\ copy-mode-mark-style copy-mode-match-style main-pane-height
+\ main-pane-width mode-keys mode-style monitor-activity monitor-bell
+\ monitor-silence mouse other-pane-height other-pane-width
+\ pane-active-border-style pane-base-index pane-border-format
+\ pane-border-lines pane-border-status pane-border-style pane-colours prefix
+\ prefix2 prompt-history-limit remain-on-exit renumber-windows repeat-time
+\ set-clipboard set-titles set-titles-string silence-action status status-bg
+\ status-fg status-format status-interval status-justify status-keys
+\ status-left status-left-length status-left-style status-position
+\ status-right status-right-length status-right-style status-style
+\ synchronize-panes terminal-features terminal-overrides update-environment
+\ user-keys visual-activity visual-bell visual-silence window-active-style
+\ window-size window-status-activity-style window-status-bell-style
\ window-status-current-format window-status-current-style
\ window-status-format window-status-last-style window-status-separator
-\ window-status-style window-style word-separators wrap-search xterm-keys
+\ window-status-style window-style word-separators wrap-search
syn keyword tmuxCommands
\ attach attach-session bind bind-key break-pane breakp capture-pane
\ capturep choose-buffer choose-client choose-tree clear-history clearhist
-\ clock-mode command-prompt confirm confirm-before copy-mode detach
-\ detach-client display display-menu display-message display-panes displayp
-\ find-window findw if if-shell join-pane joinp kill-pane kill-server
-\ kill-session kill-window killp has-session has killw link-window linkw
-\ list-buffers list-clients list-commands list-keys list-panes list-sessions
-\ list-windows load-buffer loadb lock lock-client lock-server lock-session
-\ lockc last-pane lastp locks ls last-window last lsb lsc delete-buffer
-\ deleteb lscm lsk lsp lsw menu move-pane move-window movep movew new
-\ new-session new-window neww next next-layout next-window nextl
-\ paste-buffer pasteb pipe-pane pipep prev previous-layout previous-window
-\ prevl refresh refresh-client rename rename-session rename-window renamew
-\ resize-pane resize-window resizep resizew respawn-pane respawn-window
-\ respawnp respawnw rotate-window rotatew run run-shell save-buffer saveb
+\ clock-mode command-prompt confirm confirm-before copy-mode customize-mode
+\ detach detach-client display display-menu display-message display-panes
+\ display-popup displayp find-window findw if if-shell join-pane joinp
+\ kill-pane kill-server kill-session kill-window killp has has-session killw
+\ link-window linkw list-buffers list-clients list-commands list-keys
+\ list-panes list-sessions list-windows load-buffer loadb lock lock-client
+\ lock-server lock-session lockc last-pane lastp locks ls last last-window
+\ lsb delete-buffer deleteb lsc lscm lsk lsp lsw menu move-pane move-window
+\ clear-prompt-history clearphist movep movew new new-session new-window
+\ neww next next-layout next-window nextl paste-buffer pasteb pipe-pane
+\ pipep popup prev previous-layout previous-window prevl refresh
+\ refresh-client rename rename-session rename-window renamew resize-pane
+\ resize-window resizep resizew respawn-pane respawn-window respawnp
+\ respawnw rotate-window rotatew run run-shell save-buffer saveb
\ select-layout select-pane select-window selectl selectp selectw send
\ send-keys send-prefix set set-buffer set-environment set-hook set-option
\ set-window-option setb setenv setw show show-buffer show-environment
-\ show-hooks show-messages show-options show-window-options showb showenv
-\ showmsgs showw source source-file split-window splitw start start-server
-\ suspend-client suspendc swap-pane swap-window swapp swapw switch-client
-\ switchc unbind unbind-key unlink-window unlinkw wait wait-for
+\ show-hooks show-messages show-options show-prompt-history
+\ show-window-options showb showenv showmsgs showphist showw source
+\ source-file split-window splitw start start-server suspend-client suspendc
+\ swap-pane swap-window swapp swapw switch-client switchc unbind unbind-key
+\ unlink-window unlinkw wait wait-for
let &cpo = s:original_cpo
unlet! s:original_cpo s:bg s:i
diff --git a/runtime/syntax/toml.vim b/runtime/syntax/toml.vim
new file mode 100644
index 0000000000..bcb1b0b9c9
--- /dev/null
+++ b/runtime/syntax/toml.vim
@@ -0,0 +1,81 @@
+" Vim syntax file
+" Language: TOML
+" Homepage: https://github.com/cespare/vim-toml
+" Maintainer: Aman Verma
+" Previous Maintainer: Caleb Spare <cespare@gmail.com>
+" Last Change: Oct 8, 2021
+
+if exists('b:current_syntax')
+ finish
+endif
+
+syn match tomlEscape /\\[btnfr"/\\]/ display contained
+syn match tomlEscape /\\u\x\{4}/ contained
+syn match tomlEscape /\\U\x\{8}/ contained
+syn match tomlLineEscape /\\$/ contained
+
+" Basic strings
+syn region tomlString oneline start=/"/ skip=/\\\\\|\\"/ end=/"/ contains=tomlEscape
+" Multi-line basic strings
+syn region tomlString start=/"""/ end=/"""/ contains=tomlEscape,tomlLineEscape
+" Literal strings
+syn region tomlString oneline start=/'/ end=/'/
+" Multi-line literal strings
+syn region tomlString start=/'''/ end=/'''/
+
+syn match tomlInteger /[+-]\=\<[1-9]\(_\=\d\)*\>/ display
+syn match tomlInteger /[+-]\=\<0\>/ display
+syn match tomlInteger /[+-]\=\<0x[[:xdigit:]]\(_\=[[:xdigit:]]\)*\>/ display
+syn match tomlInteger /[+-]\=\<0o[0-7]\(_\=[0-7]\)*\>/ display
+syn match tomlInteger /[+-]\=\<0b[01]\(_\=[01]\)*\>/ display
+syn match tomlInteger /[+-]\=\<\(inf\|nan\)\>/ display
+
+syn match tomlFloat /[+-]\=\<\d\(_\=\d\)*\.\d\+\>/ display
+syn match tomlFloat /[+-]\=\<\d\(_\=\d\)*\(\.\d\(_\=\d\)*\)\=[eE][+-]\=\d\(_\=\d\)*\>/ display
+
+syn match tomlBoolean /\<\%(true\|false\)\>/ display
+
+" https://tools.ietf.org/html/rfc3339
+syn match tomlDate /\d\{4\}-\d\{2\}-\d\{2\}/ display
+syn match tomlDate /\d\{2\}:\d\{2\}:\d\{2\}\%(\.\d\+\)\?/ display
+syn match tomlDate /\d\{4\}-\d\{2\}-\d\{2\}[T ]\d\{2\}:\d\{2\}:\d\{2\}\%(\.\d\+\)\?\%(Z\|[+-]\d\{2\}:\d\{2\}\)\?/ display
+
+syn match tomlDotInKey /\v[^.]+\zs\./ contained display
+syn match tomlKey /\v(^|[{,])\s*\zs[[:alnum:]._-]+\ze\s*\=/ contains=tomlDotInKey display
+syn region tomlKeyDq oneline start=/\v(^|[{,])\s*\zs"/ end=/"\ze\s*=/ contains=tomlEscape
+syn region tomlKeySq oneline start=/\v(^|[{,])\s*\zs'/ end=/'\ze\s*=/
+
+syn region tomlTable oneline start=/^\s*\[[^\[]/ end=/\]/ contains=tomlKey,tomlKeyDq,tomlKeySq,tomlDotInKey
+
+syn region tomlTableArray oneline start=/^\s*\[\[/ end=/\]\]/ contains=tomlKey,tomlKeyDq,tomlKeySq,tomlDotInKey
+
+syn region tomlKeyValueArray start=/=\s*\[\zs/ end=/\]/ contains=@tomlValue
+
+syn region tomlArray start=/\[/ end=/\]/ contains=@tomlValue contained
+
+syn cluster tomlValue contains=tomlArray,tomlString,tomlInteger,tomlFloat,tomlBoolean,tomlDate,tomlComment
+
+syn keyword tomlTodo TODO FIXME XXX BUG contained
+
+syn match tomlComment /#.*/ contains=@Spell,tomlTodo
+
+hi def link tomlComment Comment
+hi def link tomlTodo Todo
+hi def link tomlTableArray Title
+hi def link tomlTable Title
+hi def link tomlDotInKey Normal
+hi def link tomlKeySq Identifier
+hi def link tomlKeyDq Identifier
+hi def link tomlKey Identifier
+hi def link tomlDate Constant
+hi def link tomlBoolean Boolean
+hi def link tomlFloat Float
+hi def link tomlInteger Number
+hi def link tomlString String
+hi def link tomlLineEscape SpecialChar
+hi def link tomlEscape SpecialChar
+
+syn sync minlines=500
+let b:current_syntax = 'toml'
+
+" vim: et sw=2 sts=2
diff --git a/scripts/lintcommit.lua b/scripts/lintcommit.lua
index 98f9da246c..c30a1b10da 100644
--- a/scripts/lintcommit.lua
+++ b/scripts/lintcommit.lua
@@ -106,7 +106,7 @@ end
function M.main(opt)
_trace = not opt or not not opt.trace
- local branch = run({'git', 'branch', '--show-current'}, 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})
if not ancestor then
diff --git a/scripts/squash_typos.py b/scripts/squash_typos.py
index 26be6010a2..b403a9b7c8 100644
--- a/scripts/squash_typos.py
+++ b/scripts/squash_typos.py
@@ -22,24 +22,40 @@ def get_authors_and_emails_from_pr():
# Get a list of all authors involved in the pull request (including co-authors).
authors = subprocess.check_output(
- ["gh", "pr", "view", "--json", "commits", "--jq", ".[][].authors.[].name"],
+ [
+ "gh",
+ "pr",
+ "view",
+ os.environ["PR_NUMBER"],
+ "--json",
+ "commits",
+ "--jq",
+ ".[][].authors.[].name",
+ ],
text=True,
).splitlines()
# Get a list of emails of the aforementioned authors.
emails = subprocess.check_output(
- ["gh", "pr", "view", "--json", "commits", "--jq", ".[][].authors.[].email"],
+ [
+ "gh",
+ "pr",
+ "view",
+ os.environ["PR_NUMBER"],
+ "--json",
+ "commits",
+ "--jq",
+ ".[][].authors.[].email",
+ ],
text=True,
).splitlines()
- authors_and_emails_unique = {
- (author, mail) for author, mail in zip(authors, emails)
- }
+ authors_and_emails = [(author, mail) for author, mail in zip(authors, emails)]
- return sorted(authors_and_emails_unique)
+ return authors_and_emails
-def rebase_squash_branch_onto_pr():
+def rebase_onto_pr():
"""
Rebase current branch onto the PR.
@@ -49,9 +65,7 @@ def rebase_squash_branch_onto_pr():
# Check out the pull request.
subprocess.call(["gh", "pr", "checkout", os.environ["PR_NUMBER"]])
- # Rebase onto master
- default_branch = f"{os.environ['GITHUB_BASE_REF']}"
- subprocess.check_call(["git", "rebase", default_branch])
+ rebase_onto_master()
# Change back to the original branch.
subprocess.call(["git", "switch", "-"])
@@ -87,7 +101,7 @@ def rebase_squash_branch_onto_pr():
)
-def rebase_squash_branch_onto_master():
+def rebase_onto_master():
"""
Rebase current branch onto the master i.e. make sure current branch is up
@@ -99,7 +113,7 @@ def rebase_squash_branch_onto_master():
subprocess.check_call(["git", "rebase", default_branch])
-def squash_all_commits():
+def squash_all_commits(message_body_before):
"""
Squash all commits on the PR into a single commit. Credit all authors by
@@ -111,8 +125,11 @@ def squash_all_commits():
subprocess.call(["git", "reset", "--soft", default_branch])
authors_and_emails = get_authors_and_emails_from_pr()
- commit_message_coauthors = "\n" + "\n".join(
- [f"Co-authored-by: {i[0]} <{i[1]}>" for i in authors_and_emails]
+ commit_message_coauthors = (
+ "\n"
+ + "\n".join([f"Co-authored-by: {i[0]} <{i[1]}>" for i in authors_and_emails])
+ + "\n"
+ + message_body_before
)
subprocess.call(
["git", "commit", "-m", "chore: typo fixes", "-m", commit_message_coauthors]
@@ -164,7 +181,7 @@ def checkout_branch(branch):
return False
-def get_all_pr_urls(squash_branch_exists):
+def get_all_pr_urls(pr_branch_exists):
"""
Return a list of URLs for the pull requests with the typo fixes. If a
@@ -173,7 +190,7 @@ def get_all_pr_urls(squash_branch_exists):
"""
all_pr_urls = ""
- if squash_branch_exists:
+ if pr_branch_exists:
all_pr_urls += subprocess.check_output(
["gh", "pr", "view", "--json", "body", "--jq", ".body"], text=True
)
@@ -187,15 +204,21 @@ def get_all_pr_urls(squash_branch_exists):
def main():
- squash_branch = "marvim/squash-typos"
+ pr_branch = "marvim/squash-typos"
- squash_branch_exists = checkout_branch(squash_branch)
+ pr_branch_exists = checkout_branch(pr_branch)
- rebase_squash_branch_onto_master()
- force_push(squash_branch)
+ rebase_onto_master()
+ force_push(pr_branch)
+
+ message_body_before = "\n".join(
+ subprocess.check_output(
+ ["git", "log", "--format=%B", "-n1", pr_branch], text=True
+ ).splitlines()[2:]
+ )
- rebase_squash_branch_onto_pr()
- force_push(squash_branch)
+ rebase_onto_pr()
+ force_push(pr_branch)
subprocess.call(
[
@@ -204,20 +227,37 @@ def main():
"create",
"--fill",
"--head",
- squash_branch,
+ pr_branch,
"--title",
"chore: typo fixes (automated)",
- ]
+ ],
+ text=True,
)
- squash_all_commits()
- force_push(squash_branch)
+ squash_all_commits(message_body_before)
+ force_push(pr_branch)
- all_pr_urls = get_all_pr_urls(squash_branch_exists)
+ all_pr_urls = get_all_pr_urls(pr_branch_exists)
subprocess.call(["gh", "pr", "edit", "--add-label", "typo", "--body", all_pr_urls])
subprocess.call(["gh", "pr", "close", os.environ["PR_NUMBER"]])
+ squash_url = subprocess.check_output(
+ ["gh", "pr", "view", "--json", "url", "--jq", ".url"], text=True
+ ).strip()
+ subprocess.call(
+ [
+ "gh",
+ "pr",
+ "comment",
+ os.environ["PR_NUMBER"],
+ "--body",
+ f"Thank you for your contribution! We collect all typo fixes \
+ into a single pull request and merge it once it gets big enough: \
+ {squash_url}",
+ ]
+ )
+
if __name__ == "__main__":
main()
diff --git a/src/mpack/conv.c b/src/mpack/conv.c
index 31297a8784..6bd446ca49 100644
--- a/src/mpack/conv.c
+++ b/src/mpack/conv.c
@@ -301,7 +301,6 @@ MPACK_API double mpack_unpack_number(mpack_token_t t)
*/
if (!hi) {
assert(t.length <= 4);
- hi = 0;
lo = (~lo & (((mpack_uint32_t)1 << ((t.length * 8) - 1)) - 1));
} else {
hi = ~hi;
diff --git a/src/mpack/lmpack.c b/src/mpack/lmpack.c
index 4b0e132a3a..24d27fd17a 100644
--- a/src/mpack/lmpack.c
+++ b/src/mpack/lmpack.c
@@ -204,14 +204,14 @@ static void lmpack_pushnil(lua_State *L)
static mpack_uint32_t lmpack_objlen(lua_State *L, int *is_array)
{
size_t len, max;
- int isarr, type;
+ int isarr;
lua_Number n;
#ifndef NDEBUG
int top = lua_gettop(L);
assert(top);
#endif
- if ((type = lua_type(L, -1)) != LUA_TTABLE) {
+ if ((lua_type(L, -1)) != LUA_TTABLE) {
#if LUA_VERSION_NUM >= 502
len = lua_rawlen(L, -1);
#elif LUA_VERSION_NUM == 501
@@ -445,7 +445,6 @@ static int lmpack_unpacker_unpack_str(lua_State *L, Unpacker *unpacker,
if (rv == MPACK_NOMEM) {
unpacker->parser = lmpack_grow_parser(unpacker->parser);
if (!unpacker->parser) {
- unpacker->unpacking = 0;
return luaL_error(L, "failed to grow Unpacker capacity");
}
}
@@ -799,7 +798,6 @@ static int lmpack_packer_pack(lua_State *L)
if (result == MPACK_NOMEM) {
packer->parser = lmpack_grow_parser(packer->parser);
if (!packer->parser) {
- packer->packing = 0;
return luaL_error(L, "Failed to grow Packer capacity");
}
}
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c
index 3ab7e6b778..31d44c68bf 100644
--- a/src/nvim/api/buffer.c
+++ b/src/nvim/api/buffer.c
@@ -418,7 +418,7 @@ void nvim_buf_set_lines(uint64_t channel_id, Buffer buffer, Integer start, Integ
try_start();
aco_save_T aco;
- aucmd_prepbuf(&aco, (buf_T *)buf);
+ aucmd_prepbuf(&aco, buf);
if (!MODIFIABLE(buf)) {
api_set_error(err, kErrorTypeException, "Buffer is not 'modifiable'");
@@ -624,7 +624,8 @@ void nvim_buf_set_text(uint64_t channel_id, Buffer buffer, Integer start_row, In
if (replacement.size == 1) {
firstlen += last_part_len;
}
- char *first = xmallocz(firstlen), *last = NULL;
+ char *first = xmallocz(firstlen);
+ char *last = NULL;
memcpy(first, str_at_start, (size_t)start_col);
memcpy(first+start_col, first_item.data, first_item.size);
memchrsub(first+start_col, NUL, NL, first_item.size);
@@ -637,7 +638,7 @@ void nvim_buf_set_text(uint64_t channel_id, Buffer buffer, Integer start_row, In
memcpy(last+last_item.size, str_at_end+end_col, last_part_len);
}
- char **lines = (new_len != 0) ? xcalloc(new_len, sizeof(char *)) : NULL;
+ char **lines = xcalloc(new_len, sizeof(char *));
lines[0] = first;
new_byte += (bcount_t)(first_item.size);
for (size_t i = 1; i < new_len-1; i++) {
@@ -656,7 +657,7 @@ void nvim_buf_set_text(uint64_t channel_id, Buffer buffer, Integer start_row, In
try_start();
aco_save_T aco;
- aucmd_prepbuf(&aco, (buf_T *)buf);
+ aucmd_prepbuf(&aco, buf);
if (!MODIFIABLE(buf)) {
api_set_error(err, kErrorTypeException, "Buffer is not 'modifiable'");
@@ -1165,8 +1166,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, Error *err)
+Boolean nvim_buf_set_mark(Buffer buffer, String name, Integer line, Integer col, Error *err)
FUNC_API_SINCE(8)
{
bool res = false;
@@ -1340,7 +1340,7 @@ ArrayOf(Integer) nvim_buf_get_extmark_by_id(Buffer buffer, Integer ns_id,
if (extmark.row < 0) {
return rv;
}
- return extmark_to_array(extmark, false, (bool)details);
+ return extmark_to_array(extmark, false, details);
}
/// Gets extmarks in "traversal order" from a |charwise| region defined by
@@ -1561,23 +1561,24 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer
Dict(set_extmark) *opts, Error *err)
FUNC_API_SINCE(7)
{
+ Decoration decor = DECORATION_INIT;
+
buf_T *buf = find_buffer_by_handle(buffer, err);
if (!buf) {
- return 0;
+ goto error;
}
if (!ns_initialized((uint64_t)ns_id)) {
api_set_error(err, kErrorTypeValidation, "Invalid ns_id");
- return 0;
+ goto error;
}
-
uint64_t id = 0;
if (opts->id.type == kObjectTypeInteger && opts->id.data.integer > 0) {
id = (uint64_t)opts->id.data.integer;
} else if (HAS_KEY(opts->id)) {
- api_set_error(err, kErrorTypeValidation, "id is not a positive integer");
- goto error;
+ api_set_error(err, kErrorTypeValidation, "id is not a positive integer");
+ goto error;
}
int line2 = -1;
@@ -1608,8 +1609,6 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer
goto error;
}
- Decoration decor = DECORATION_INIT;
-
if (HAS_KEY(opts->hl_group)) {
decor.hl_id = object_to_hl_id(opts->hl_group, "hl_group", err);
if (ERROR_SET(err)) {
@@ -1655,10 +1654,10 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer
}
#define OPTION_TO_BOOL(target, name, val) \
- target = api_object_to_bool(opts-> name, #name, val, err); \
- if (ERROR_SET(err)) { \
- goto error; \
- }
+ target = api_object_to_bool(opts-> name, #name, val, err); \
+ if (ERROR_SET(err)) { \
+ goto error; \
+ }
OPTION_TO_BOOL(decor.virt_text_hide, virt_text_hide, false);
OPTION_TO_BOOL(decor.hl_eol, hl_eol, false);
@@ -1741,7 +1740,7 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer
if (line < 0 || line > buf->b_ml.ml_line_count) {
api_set_error(err, kErrorTypeValidation, "line value outside range");
- return 0;
+ goto error;
} else if (line < buf->b_ml.ml_line_count) {
len = ephemeral ? MAXCOL : STRLEN(ml_get_buf(buf, (linenr_T)line+1, false));
}
@@ -1750,7 +1749,7 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer
col = (Integer)len;
} else if (col < -1 || col > (Integer)len) {
api_set_error(err, kErrorTypeValidation, "col value outside range");
- return 0;
+ goto error;
}
if (col2 >= 0) {
@@ -1904,7 +1903,7 @@ Integer nvim_buf_add_highlight(Buffer buffer, Integer ns_id, String hl_group, In
int hl_id = 0;
if (hl_group.size > 0) {
- hl_id = syn_check_group((char_u *)hl_group.data, (int)hl_group.size);
+ hl_id = syn_check_group(hl_group.data, (int)hl_group.size);
} else {
return ns_id;
}
@@ -1983,7 +1982,7 @@ Object nvim_buf_call(Buffer buffer, LuaRef fun, Error *err)
}
try_start();
aco_save_T aco;
- aucmd_prepbuf(&aco, (buf_T *)buf);
+ aucmd_prepbuf(&aco, buf);
Array args = ARRAY_DICT_INIT;
Object res = nlua_call_ref(fun, NULL, args, true, err);
diff --git a/src/nvim/api/private/defs.h b/src/nvim/api/private/defs.h
index 8346e01558..663d1e16b5 100644
--- a/src/nvim/api/private/defs.h
+++ b/src/nvim/api/private/defs.h
@@ -1,15 +1,15 @@
#ifndef NVIM_API_PRIVATE_DEFS_H
#define NVIM_API_PRIVATE_DEFS_H
-#include <stdint.h>
#include <stdbool.h>
+#include <stdint.h>
#include <string.h>
#include "nvim/func_attr.h"
#include "nvim/types.h"
-#define ARRAY_DICT_INIT {.size = 0, .capacity = 0, .items = NULL}
-#define STRING_INIT {.data = NULL, .size = 0}
+#define ARRAY_DICT_INIT { .size = 0, .capacity = 0, .items = NULL }
+#define STRING_INIT { .data = NULL, .size = 0 }
#define OBJECT_INIT { .type = kObjectTypeNil }
#define ERROR_INIT { .type = kErrorTypeNone, .msg = NULL }
#define REMOTE_TYPE(type) typedef handle_T type
diff --git a/src/nvim/api/private/dispatch.c b/src/nvim/api/private/dispatch.c
index ee0cdc4c07..519bf8ff14 100644
--- a/src/nvim/api/private/dispatch.c
+++ b/src/nvim/api/private/dispatch.c
@@ -14,8 +14,8 @@
#include "nvim/api/tabpage.h"
#include "nvim/api/ui.h"
#include "nvim/api/vim.h"
-#include "nvim/api/window.h"
#include "nvim/api/win_config.h"
+#include "nvim/api/window.h"
#include "nvim/log.h"
#include "nvim/map.h"
#include "nvim/msgpack_rpc/helpers.h"
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c
index 46ef41cc38..b2529db5be 100644
--- a/src/nvim/api/private/helpers.c
+++ b/src/nvim/api/private/helpers.c
@@ -4,9 +4,9 @@
#include <assert.h>
#include <inttypes.h>
#include <stdbool.h>
+#include <stddef.h>
#include <stdlib.h>
#include <string.h>
-#include <stddef.h>
#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
@@ -818,13 +818,6 @@ Array string_to_array(const String input, bool crlf)
void modify_keymap(Buffer buffer, bool is_unmap, String mode, String lhs, String rhs,
Dict(keymap) *opts, Error *err)
{
- char *err_msg = NULL; // the error message to report, if any
- char *err_arg = NULL; // argument for the error message format string
- ErrorType err_type = kErrorTypeNone;
-
- char_u *lhs_buf = NULL;
- char_u *rhs_buf = NULL;
-
bool global = (buffer == -1);
if (global) {
buffer = 0;
@@ -838,10 +831,10 @@ void modify_keymap(Buffer buffer, bool is_unmap, String mode, String lhs, String
MapArguments parsed_args = MAP_ARGUMENTS_INIT;
if (opts) {
#define KEY_TO_BOOL(name) \
- parsed_args. name = api_object_to_bool(opts-> name, #name, false, err); \
- if (ERROR_SET(err)) { \
- goto fail_and_free; \
- }
+ parsed_args. name = api_object_to_bool(opts-> name, #name, false, err); \
+ if (ERROR_SET(err)) { \
+ goto fail_and_free; \
+ }
KEY_TO_BOOL(nowait);
KEY_TO_BOOL(noremap);
@@ -858,17 +851,13 @@ void modify_keymap(Buffer buffer, bool is_unmap, String mode, String lhs, String
CPO_TO_CPO_FLAGS, &parsed_args);
if (parsed_args.lhs_len > MAXMAPLEN) {
- err_msg = "LHS exceeds maximum map length: %s";
- err_arg = lhs.data;
- err_type = kErrorTypeValidation;
- goto fail_with_message;
+ api_set_error(err, kErrorTypeValidation, "LHS exceeds maximum map length: %s", lhs.data);
+ goto fail_and_free;
}
if (mode.size > 1) {
- err_msg = "Shortname is too long: %s";
- err_arg = mode.data;
- err_type = kErrorTypeValidation;
- goto fail_with_message;
+ api_set_error(err, kErrorTypeValidation, "Shortname is too long: %s", mode.data);
+ goto fail_and_free;
}
int mode_val; // integer value of the mapping mode, to be passed to do_map()
char_u *p = (char_u *)((mode.size) ? mode.data : "m");
@@ -880,18 +869,14 @@ void modify_keymap(Buffer buffer, bool is_unmap, String mode, String lhs, String
&& mode.size > 0) {
// get_map_mode() treats unrecognized mode shortnames as ":map".
// This is an error unless the given shortname was empty string "".
- err_msg = "Invalid mode shortname: \"%s\"";
- err_arg = (char *)p;
- err_type = kErrorTypeValidation;
- goto fail_with_message;
+ api_set_error(err, kErrorTypeValidation, "Invalid mode shortname: \"%s\"", (char *)p);
+ goto fail_and_free;
}
}
if (parsed_args.lhs_len == 0) {
- err_msg = "Invalid (empty) LHS";
- err_arg = "";
- err_type = kErrorTypeValidation;
- goto fail_with_message;
+ api_set_error(err, kErrorTypeValidation, "Invalid (empty) LHS");
+ goto fail_and_free;
}
bool is_noremap = parsed_args.noremap;
@@ -904,16 +889,13 @@ void modify_keymap(Buffer buffer, bool is_unmap, String mode, String lhs, String
// the given RHS was nonempty and not a <Nop>, but was parsed as if it
// were empty?
assert(false && "Failed to parse nonempty RHS!");
- err_msg = "Parsing of nonempty RHS failed: %s";
- err_arg = rhs.data;
- err_type = kErrorTypeException;
- goto fail_with_message;
+ api_set_error(err, kErrorTypeValidation, "Parsing of nonempty RHS failed: %s", rhs.data);
+ goto fail_and_free;
}
} else if (is_unmap && parsed_args.rhs_len) {
- err_msg = "Gave nonempty RHS in unmap command: %s";
- err_arg = (char *)parsed_args.rhs;
- err_type = kErrorTypeValidation;
- goto fail_with_message;
+ api_set_error(err, kErrorTypeValidation,
+ "Gave nonempty RHS in unmap command: %s", parsed_args.rhs);
+ goto fail_and_free;
}
// buf_do_map() reads noremap/unmap as its own argument.
@@ -942,19 +924,7 @@ void modify_keymap(Buffer buffer, bool is_unmap, String mode, String lhs, String
goto fail_and_free;
} // switch
- xfree(lhs_buf);
- xfree(rhs_buf);
- xfree(parsed_args.rhs);
- xfree(parsed_args.orig_rhs);
-
- return;
-
-fail_with_message:
- api_set_error(err, err_type, err_msg, err_arg);
-
fail_and_free:
- xfree(lhs_buf);
- xfree(rhs_buf);
xfree(parsed_args.rhs);
xfree(parsed_args.orig_rhs);
return;
@@ -1589,7 +1559,7 @@ int object_to_hl_id(Object obj, const char *what, Error *err)
{
if (obj.type == kObjectTypeString) {
String str = obj.data.string;
- return str.size ? syn_check_group((char_u *)str.data, (int)str.size) : 0;
+ return str.size ? syn_check_group(str.data, (int)str.size) : 0;
} else if (obj.type == kObjectTypeInteger) {
return MAX((int)obj.data.integer, 0);
} else {
@@ -1623,7 +1593,7 @@ HlMessage parse_hl_msg(Array chunks, Error *err)
String hl = chunk.items[1].data.string;
if (hl.size > 0) {
// TODO(bfredl): use object_to_hl_id and allow integer
- int hl_id = syn_check_group((char_u *)hl.data, (int)hl.size);
+ int hl_id = syn_check_group(hl.data, (int)hl.size);
attr = hl_id > 0 ? syn_id2attr(hl_id) : 0;
}
}
diff --git a/src/nvim/api/private/helpers.h b/src/nvim/api/private/helpers.h
index 2cdd80bffe..08d2c8d90c 100644
--- a/src/nvim/api/private/helpers.h
+++ b/src/nvim/api/private/helpers.h
@@ -4,12 +4,12 @@
#include <stdbool.h>
#include "nvim/api/private/defs.h"
-#include "nvim/vim.h"
-#include "nvim/getchar.h"
-#include "nvim/memory.h"
#include "nvim/decoration.h"
#include "nvim/ex_eval.h"
+#include "nvim/getchar.h"
#include "nvim/lib/kvec.h"
+#include "nvim/memory.h"
+#include "nvim/vim.h"
#define OBJECT_OBJ(o) o
@@ -76,7 +76,7 @@
name.size = fixsize; \
name.items = name##__items; \
-#define STATIC_CSTR_AS_STRING(s) ((String) {.data = s, .size = sizeof(s) - 1})
+#define STATIC_CSTR_AS_STRING(s) ((String) { .data = s, .size = sizeof(s) - 1 })
/// Create a new String instance, putting data in allocated memory
///
@@ -137,12 +137,12 @@ typedef struct {
msg_list = &private_msg_list; \
private_msg_list = NULL; \
code \
- msg_list = saved_msg_list; /* Restore the exception context. */ \
+ msg_list = saved_msg_list; /* Restore the exception context. */ \
} while (0)
#ifdef INCLUDE_GENERATED_DECLARATIONS
-# include "keysets.h.generated.h"
# include "api/private/helpers.h.generated.h"
+# include "keysets.h.generated.h"
#endif
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index 9b39b18c4e..44552bcb26 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -195,7 +195,7 @@ Dictionary nvim_get_hl_by_id(Integer hl_id, Boolean rgb, Error *err)
Integer nvim_get_hl_id_by_name(String name)
FUNC_API_SINCE(7)
{
- return syn_check_group((const char_u *)name.data, (int)name.size);
+ return syn_check_group(name.data, (int)name.size);
}
Dictionary nvim__get_hl_defs(Integer ns_id, Error *err)
@@ -227,7 +227,7 @@ Dictionary nvim__get_hl_defs(Integer ns_id, Error *err)
void nvim_set_hl(Integer ns_id, String name, Dictionary val, Error *err)
FUNC_API_SINCE(7)
{
- int hl_id = syn_check_group( (char_u *)(name.data), (int)name.size);
+ int hl_id = syn_check_group(name.data, (int)name.size);
int link_id = -1;
HlAttrs attrs = dict2hlattrs(val, true, &link_id, err);
@@ -712,7 +712,7 @@ Object nvim_call_dict_function(Object dict, String fn, Array args, Error *err)
}
fn = (String) {
.data = (char *)di->di_tv.vval.v_string,
- .size = strlen((char *)di->di_tv.vval.v_string),
+ .size = STRLEN(di->di_tv.vval.v_string),
};
}
@@ -2846,7 +2846,7 @@ Array nvim_get_mark(String name, Error *err)
bufnr = mark.fmark.fnum;
filename = (char *)buflist_nr2name(bufnr, true, true);
allocated = true;
- // Marks comes from shada
+ // Marks comes from shada
} else {
filename = (char *)mark.fname;
bufnr = 0;
diff --git a/src/nvim/api/win_config.c b/src/nvim/api/win_config.c
index d82e7e8a03..d8105810aa 100644
--- a/src/nvim/api/win_config.c
+++ b/src/nvim/api/win_config.c
@@ -616,7 +616,7 @@ static bool parse_float_config(Dict(float_config) *config, FloatConfig *fconfig,
fconfig->style = kWinStyleUnused;
} else if (striequal(config->style.data.string.data, "minimal")) {
fconfig->style = kWinStyleMinimal;
- } else {
+ } else {
api_set_error(err, kErrorTypeValidation, "Invalid value of 'style' key");
}
} else if (HAS_KEY(config->style)) {
diff --git a/src/nvim/arabic.h b/src/nvim/arabic.h
index 7ea728ed47..eaab463777 100644
--- a/src/nvim/arabic.h
+++ b/src/nvim/arabic.h
@@ -6,8 +6,8 @@
/// Whether c belongs to the range of Arabic characters that might be shaped.
static inline bool arabic_char(int c)
{
- // return c >= a_HAMZA && c <= a_MINI_ALEF;
- return c >= 0x0621 && c <= 0x0670;
+ // return c >= a_HAMZA && c <= a_MINI_ALEF;
+ return c >= 0x0621 && c <= 0x0670;
}
#ifdef INCLUDE_GENERATED_DECLARATIONS
diff --git a/src/nvim/ascii.h b/src/nvim/ascii.h
index 7b5e82cd3f..44ed94d2fc 100644
--- a/src/nvim/ascii.h
+++ b/src/nvim/ascii.h
@@ -3,8 +3,8 @@
#include <stdbool.h>
-#include "nvim/macros.h"
#include "nvim/func_attr.h"
+#include "nvim/macros.h"
#include "nvim/os/os_defs.h"
// Definitions of various common control characters.
diff --git a/src/nvim/assert.h b/src/nvim/assert.h
index 1361879876..fc1a4be164 100644
--- a/src/nvim/assert.h
+++ b/src/nvim/assert.h
@@ -49,11 +49,11 @@
#define STATIC_ASSERT_PRAGMA_START
#define STATIC_ASSERT_PRAGMA_END
#define STATIC_ASSERT(cond, msg) \
- do { \
- STATIC_ASSERT_PRAGMA_START \
- STATIC_ASSERT_STATEMENT(cond, msg); \
- STATIC_ASSERT_PRAGMA_END \
- } while (0)
+ do { \
+ STATIC_ASSERT_PRAGMA_START \
+ STATIC_ASSERT_STATEMENT(cond, msg); \
+ STATIC_ASSERT_PRAGMA_END \
+ } while (0)
// the easiest case, when the mode is C11 (generic compiler) or Clang
// advertises explicit support for c_static_assert, meaning it won't warn.
@@ -68,19 +68,19 @@
# undef STATIC_ASSERT_PRAGMA_START
-#if __GNUC__ >= 6
-# define STATIC_ASSERT_PRAGMA_START \
- _Pragma("GCC diagnostic push") \
- _Pragma("GCC diagnostic ignored \"-Wpedantic\"")
-#else
-# define STATIC_ASSERT_PRAGMA_START \
- _Pragma("GCC diagnostic push") \
- _Pragma("GCC diagnostic ignored \"-pedantic\"")
-#endif
+# if __GNUC__ >= 6
+# define STATIC_ASSERT_PRAGMA_START \
+ _Pragma("GCC diagnostic push")\
+ _Pragma("GCC diagnostic ignored \"-Wpedantic\"")
+# else
+# define STATIC_ASSERT_PRAGMA_START \
+ _Pragma("GCC diagnostic push")\
+ _Pragma("GCC diagnostic ignored \"-pedantic\"")
+# endif
# undef STATIC_ASSERT_PRAGMA_END
# define STATIC_ASSERT_PRAGMA_END \
- _Pragma("GCC diagnostic pop")
+ _Pragma("GCC diagnostic pop")
// the same goes for clang in C99 mode, but we suppress a different warning
#elif defined(__clang__) && __has_extension(c_static_assert)
@@ -89,12 +89,12 @@
# undef STATIC_ASSERT_PRAGMA_START
# define STATIC_ASSERT_PRAGMA_START \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Wc11-extensions\"")
+ _Pragma("clang diagnostic push")\
+ _Pragma("clang diagnostic ignored \"-Wc11-extensions\"")
# undef STATIC_ASSERT_PRAGMA_END
# define STATIC_ASSERT_PRAGMA_END \
- _Pragma("clang diagnostic pop")
+ _Pragma("clang diagnostic pop")
// TODO(aktau): verify that this works, don't have MSVC on hand.
#elif _MSC_VER >= 1600
@@ -113,14 +113,14 @@
// These can't be used after statements in c89.
#ifdef __COUNTER__
# define STATIC_ASSERT_EXPR(e, m) \
- ((enum { ASSERT_CONCAT(static_assert_, __COUNTER__) = 1/(!!(e)) }) 0)
+ ((enum { ASSERT_CONCAT(static_assert_, __COUNTER__) = 1/(!!(e)) }) 0)
#else
// This can't be used twice on the same line so ensure if using in headers
// that the headers are not included twice (by wrapping in #ifndef...#endif)
// Note it doesn't cause an issue when used on same line of separate modules
// compiled with gcc -combine -fwhole-program.
# define STATIC_ASSERT_EXPR(e, m) \
- ((enum { ASSERT_CONCAT(assert_line_, __LINE__) = 1/(!!(e)) }) 0)
+ ((enum { ASSERT_CONCAT(assert_line_, __LINE__) = 1/(!!(e)) }) 0)
#endif
/// @def STRICT_ADD
diff --git a/src/nvim/autocmd.h b/src/nvim/autocmd.h
index 1c0f88f08f..ac12e2acf3 100644
--- a/src/nvim/autocmd.h
+++ b/src/nvim/autocmd.h
@@ -17,22 +17,22 @@ typedef struct {
} aco_save_T;
typedef struct AutoCmd {
- char_u *cmd; // Command to be executed (NULL when
- // command has been removed)
+ char_u *cmd; // Command to be executed (NULL when
+ // command has been removed)
bool once; // "One shot": removed after execution
bool nested; // If autocommands nest here
bool last; // last command in list
sctx_T script_ctx; // script context where defined
- struct AutoCmd *next; // Next AutoCmd in list
+ struct AutoCmd *next; // Next AutoCmd in list
} AutoCmd;
typedef struct AutoPat {
- struct AutoPat *next; // next AutoPat in AutoPat list; MUST
- // be the first entry
- char_u *pat; // pattern as typed (NULL when pattern
- // has been removed)
- regprog_T *reg_prog; // compiled regprog for pattern
- AutoCmd *cmds; // list of commands to do
+ struct AutoPat *next; // next AutoPat in AutoPat list; MUST
+ // be the first entry
+ char_u *pat; // pattern as typed (NULL when pattern
+ // has been removed)
+ regprog_T *reg_prog; // compiled regprog for pattern
+ AutoCmd *cmds; // list of commands to do
int group; // group ID
int patlen; // strlen() of pat
int buflocal_nr; // !=0 for buffer-local AutoPat
@@ -48,16 +48,16 @@ typedef struct AutoPat {
/// Struct used to keep status while executing autocommands for an event.
///
typedef struct AutoPatCmd {
- AutoPat *curpat; // next AutoPat to examine
- AutoCmd *nextcmd; // next AutoCmd to execute
+ AutoPat *curpat; // next AutoPat to examine
+ AutoCmd *nextcmd; // next AutoCmd to execute
int group; // group being used
- char_u *fname; // fname to match with
- char_u *sfname; // sfname to match with
- char_u *tail; // tail of fname
+ char_u *fname; // fname to match with
+ char_u *sfname; // sfname to match with
+ char_u *tail; // tail of fname
event_T event; // current event
int arg_bufnr; // initially equal to <abuf>, set to zero when
// buf is deleted
- struct AutoPatCmd *next; // chain of active apc-s for auto-invalidation
+ struct AutoPatCmd *next; // chain of active apc-s for auto-invalidation
} AutoPatCmd;
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index d7473be8fa..1de54e0736 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -2553,8 +2553,6 @@ void buflist_setfpos(buf_T *const buf, win_T *const win, linenr_T lnum, colnr_T
if (wip->wi_next) {
wip->wi_next->wi_prev = wip;
}
-
- return;
}
@@ -2713,21 +2711,21 @@ void buflist_list(exarg_T *eap)
const bool job_running = buf->terminal && terminal_running(buf->terminal);
// skip unspecified buffers
- if ((!buf->b_p_bl && !eap->forceit && !strchr((char *)eap->arg, 'u'))
- || (strchr((char *)eap->arg, 'u') && buf->b_p_bl)
- || (strchr((char *)eap->arg, '+')
+ if ((!buf->b_p_bl && !eap->forceit && !vim_strchr(eap->arg, 'u'))
+ || (vim_strchr(eap->arg, 'u') && buf->b_p_bl)
+ || (vim_strchr(eap->arg, '+')
&& ((buf->b_flags & BF_READERR) || !bufIsChanged(buf)))
- || (strchr((char *)eap->arg, 'a')
+ || (vim_strchr(eap->arg, 'a')
&& (buf->b_ml.ml_mfp == NULL || buf->b_nwindows == 0))
- || (strchr((char *)eap->arg, 'h')
+ || (vim_strchr(eap->arg, 'h')
&& (buf->b_ml.ml_mfp == NULL || buf->b_nwindows != 0))
- || (strchr((char *)eap->arg, 'R') && (!is_terminal || !job_running))
- || (strchr((char *)eap->arg, 'F') && (!is_terminal || job_running))
- || (strchr((char *)eap->arg, '-') && buf->b_p_ma)
- || (strchr((char *)eap->arg, '=') && !buf->b_p_ro)
- || (strchr((char *)eap->arg, 'x') && !(buf->b_flags & BF_READERR))
- || (strchr((char *)eap->arg, '%') && buf != curbuf)
- || (strchr((char *)eap->arg, '#')
+ || (vim_strchr(eap->arg, 'R') && (!is_terminal || !job_running))
+ || (vim_strchr(eap->arg, 'F') && (!is_terminal || job_running))
+ || (vim_strchr(eap->arg, '-') && buf->b_p_ma)
+ || (vim_strchr(eap->arg, '=') && !buf->b_p_ro)
+ || (vim_strchr(eap->arg, 'x') && !(buf->b_flags & BF_READERR))
+ || (vim_strchr(eap->arg, '%') && buf != curbuf)
+ || (vim_strchr(eap->arg, '#')
&& (buf == curbuf || curwin->w_alt_fnum != buf->b_fnum))) {
continue;
}
@@ -3237,7 +3235,7 @@ void maketitle(void)
int use_sandbox = false;
int save_called_emsg = called_emsg;
- use_sandbox = was_set_insecurely(curwin, (char_u *)"titlestring", 0);
+ use_sandbox = was_set_insecurely(curwin, "titlestring", 0);
called_emsg = false;
build_stl_str_hl(curwin, (char_u *)buf, sizeof(buf),
p_titlestring, use_sandbox,
@@ -3355,7 +3353,7 @@ void maketitle(void)
int use_sandbox = false;
int save_called_emsg = called_emsg;
- use_sandbox = was_set_insecurely(curwin, (char_u *)"iconstring", 0);
+ use_sandbox = was_set_insecurely(curwin, "iconstring", 0);
called_emsg = false;
build_stl_str_hl(curwin, icon_str, sizeof(buf),
p_iconstring, use_sandbox,
diff --git a/src/nvim/buffer.h b/src/nvim/buffer.h
index 02a2ac36f7..0484c8550d 100644
--- a/src/nvim/buffer.h
+++ b/src/nvim/buffer.h
@@ -1,21 +1,21 @@
#ifndef NVIM_BUFFER_H
#define NVIM_BUFFER_H
-#include "nvim/vim.h"
-#include "nvim/window.h"
-#include "nvim/pos.h" // for linenr_T
+#include "nvim/eval.h"
#include "nvim/ex_cmds_defs.h" // for exarg_T
-#include "nvim/screen.h" // for StlClickRecord
#include "nvim/func_attr.h"
-#include "nvim/eval.h"
#include "nvim/macros.h"
#include "nvim/memline.h"
+#include "nvim/pos.h" // for linenr_T
+#include "nvim/screen.h" // for StlClickRecord
+#include "nvim/vim.h"
+#include "nvim/window.h"
// Values for buflist_getfile()
enum getf_values {
- GETF_SETMARK = 0x01, // set pcmark before jumping
- GETF_ALT = 0x02, // jumping to alternate file (not buf num)
- GETF_SWITCH = 0x04, // respect 'switchbuf' settings when jumping
+ GETF_SETMARK = 0x01, // set pcmark before jumping
+ GETF_ALT = 0x02, // jumping to alternate file (not buf num)
+ GETF_SWITCH = 0x04, // respect 'switchbuf' settings when jumping
};
// Return values of getfile()
@@ -41,26 +41,26 @@ enum bln_values {
// Values for action argument for do_buffer()
enum dobuf_action_values {
- DOBUF_GOTO = 0, // go to specified buffer
- DOBUF_SPLIT = 1, // split window and go to specified buffer
- DOBUF_UNLOAD = 2, // unload specified buffer(s)
- DOBUF_DEL = 3, // delete specified buffer(s) from buflist
- DOBUF_WIPE = 4, // delete specified buffer(s) really
+ DOBUF_GOTO = 0, // go to specified buffer
+ DOBUF_SPLIT = 1, // split window and go to specified buffer
+ DOBUF_UNLOAD = 2, // unload specified buffer(s)
+ DOBUF_DEL = 3, // delete specified buffer(s) from buflist
+ DOBUF_WIPE = 4, // delete specified buffer(s) really
};
// Values for start argument for do_buffer()
enum dobuf_start_values {
- DOBUF_CURRENT = 0, // "count" buffer from current buffer
- DOBUF_FIRST = 1, // "count" buffer from first buffer
- DOBUF_LAST = 2, // "count" buffer from last buffer
- DOBUF_MOD = 3, // "count" mod. buffer from current buffer
+ DOBUF_CURRENT = 0, // "count" buffer from current buffer
+ DOBUF_FIRST = 1, // "count" buffer from first buffer
+ DOBUF_LAST = 2, // "count" buffer from last buffer
+ DOBUF_MOD = 3, // "count" mod. buffer from current buffer
};
// flags for buf_freeall()
enum bfa_values {
- BFA_DEL = 1, // buffer is going to be deleted
- BFA_WIPE = 2, // buffer is going to be wiped out
- BFA_KEEP_UNDO = 4, // do not free undo information
+ BFA_DEL = 1, // buffer is going to be deleted
+ BFA_WIPE = 2, // buffer is going to be wiped out
+ BFA_KEEP_UNDO = 4, // do not free undo information
};
#ifdef INCLUDE_GENERATED_DECLARATIONS
@@ -75,14 +75,12 @@ static inline void buf_set_changedtick(buf_T *const buf,
///
/// @param[out] buf Buffer to set changedtick in.
/// @param[in] changedtick New value.
-static inline void buf_set_changedtick(buf_T *const buf,
- const varnumber_T changedtick)
+static inline void buf_set_changedtick(buf_T *const buf, const varnumber_T changedtick)
{
typval_T old_val = buf->changedtick_di.di_tv;
#ifndef NDEBUG
- dictitem_T *const changedtick_di = tv_dict_find(
- buf->b_vars, S_LEN("changedtick"));
+ dictitem_T *const changedtick_di = tv_dict_find(buf->b_vars, S_LEN("changedtick"));
assert(changedtick_di != NULL);
assert(changedtick_di->di_tv.v_type == VAR_NUMBER);
assert(changedtick_di->di_tv.v_lock == VAR_FIXED);
@@ -132,7 +130,7 @@ static inline void buf_inc_changedtick(buf_T *const buf)
static inline bool buf_is_empty(buf_T *buf)
{
return buf->b_ml.ml_line_count == 1
- && *ml_get_buf(buf, (linenr_T)1, false) == '\0';
+ && *ml_get_buf(buf, (linenr_T)1, false) == '\0';
}
#endif // NVIM_BUFFER_H
diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h
index 0264a60117..2c411553b8 100644
--- a/src/nvim/buffer_defs.h
+++ b/src/nvim/buffer_defs.h
@@ -6,14 +6,14 @@
// for FILE
#include <stdio.h>
-typedef struct file_buffer buf_T; // Forward declaration
+typedef struct file_buffer buf_T; // Forward declaration
// Reference to a buffer that stores the value of buf_free_count.
// bufref_valid() only needs to check "buf" when the count differs.
typedef struct {
buf_T *br_buf;
- int br_fnum;
- int br_buf_free_count;
+ int br_fnum;
+ int br_buf_free_count;
} bufref_T;
// for garray_T
@@ -111,16 +111,15 @@ typedef uint16_t disptick_T; // display tick type
// for synstate_T (needs reg_extmatch_T, win_T, buf_T)
#include "nvim/syntax_defs.h"
// for sign_entry_T
-#include "nvim/sign_defs.h"
-
#include "nvim/os/fs_defs.h" // for FileID
+#include "nvim/sign_defs.h"
#include "nvim/terminal.h" // for Terminal
/*
* The taggy struct is used to store the information about a :tag command.
*/
typedef struct taggy {
- char_u *tagname; // tag name
+ char_u *tagname; // tag name
fmark_T fmark; // cursor position BEFORE ":tag"
int cur_match; // match number
int cur_fnum; // buffer number used for cur_match
@@ -161,45 +160,45 @@ typedef struct
*/
typedef struct {
int wo_arab;
-# define w_p_arab w_onebuf_opt.wo_arab // 'arabic'
+#define w_p_arab w_onebuf_opt.wo_arab // 'arabic'
int wo_bri;
-# define w_p_bri w_onebuf_opt.wo_bri // 'breakindent'
+#define w_p_bri w_onebuf_opt.wo_bri // 'breakindent'
char_u *wo_briopt;
-# define w_p_briopt w_onebuf_opt.wo_briopt // 'breakindentopt'
+#define w_p_briopt w_onebuf_opt.wo_briopt // 'breakindentopt'
int wo_diff;
-# define w_p_diff w_onebuf_opt.wo_diff // 'diff'
+#define w_p_diff w_onebuf_opt.wo_diff // 'diff'
char_u *wo_fdc;
-# define w_p_fdc w_onebuf_opt.wo_fdc // 'foldcolumn'
+#define w_p_fdc w_onebuf_opt.wo_fdc // 'foldcolumn'
char_u *wo_fdc_save;
-# define w_p_fdc_save w_onebuf_opt.wo_fdc_save // 'fdc' saved for diff mode
+#define w_p_fdc_save w_onebuf_opt.wo_fdc_save // 'fdc' saved for diff mode
int wo_fen;
-# define w_p_fen w_onebuf_opt.wo_fen // 'foldenable'
+#define w_p_fen w_onebuf_opt.wo_fen // 'foldenable'
int wo_fen_save;
// 'foldenable' saved for diff mode
-# define w_p_fen_save w_onebuf_opt.wo_fen_save
- char_u *wo_fdi;
-# define w_p_fdi w_onebuf_opt.wo_fdi // 'foldignore'
+#define w_p_fen_save w_onebuf_opt.wo_fen_save
+ char_u *wo_fdi;
+#define w_p_fdi w_onebuf_opt.wo_fdi // 'foldignore'
long wo_fdl;
-# define w_p_fdl w_onebuf_opt.wo_fdl // 'foldlevel'
+#define w_p_fdl w_onebuf_opt.wo_fdl // 'foldlevel'
int wo_fdl_save;
// 'foldlevel' state saved for diff mode
-# define w_p_fdl_save w_onebuf_opt.wo_fdl_save
- char_u *wo_fdm;
-# define w_p_fdm w_onebuf_opt.wo_fdm // 'foldmethod'
- char_u *wo_fdm_save;
-# define w_p_fdm_save w_onebuf_opt.wo_fdm_save // 'fdm' saved for diff mode
+#define w_p_fdl_save w_onebuf_opt.wo_fdl_save
+ char_u *wo_fdm;
+#define w_p_fdm w_onebuf_opt.wo_fdm // 'foldmethod'
+ char_u *wo_fdm_save;
+#define w_p_fdm_save w_onebuf_opt.wo_fdm_save // 'fdm' saved for diff mode
long wo_fml;
-# define w_p_fml w_onebuf_opt.wo_fml // 'foldminlines'
+#define w_p_fml w_onebuf_opt.wo_fml // 'foldminlines'
long wo_fdn;
-# define w_p_fdn w_onebuf_opt.wo_fdn // 'foldnestmax'
- char_u *wo_fde;
-# define w_p_fde w_onebuf_opt.wo_fde // 'foldexpr'
- char_u *wo_fdt;
-# define w_p_fdt w_onebuf_opt.wo_fdt // 'foldtext'
- char_u *wo_fmr;
-# define w_p_fmr w_onebuf_opt.wo_fmr // 'foldmarker'
+#define w_p_fdn w_onebuf_opt.wo_fdn // 'foldnestmax'
+ char_u *wo_fde;
+#define w_p_fde w_onebuf_opt.wo_fde // 'foldexpr'
+ char_u *wo_fdt;
+#define w_p_fdt w_onebuf_opt.wo_fdt // 'foldtext'
+ char_u *wo_fmr;
+#define w_p_fmr w_onebuf_opt.wo_fmr // 'foldmarker'
int wo_lbr;
-# define w_p_lbr w_onebuf_opt.wo_lbr // 'linebreak'
+#define w_p_lbr w_onebuf_opt.wo_lbr // 'linebreak'
int wo_list;
#define w_p_list w_onebuf_opt.wo_list // 'list'
int wo_nu;
@@ -207,64 +206,64 @@ typedef struct {
int wo_rnu;
#define w_p_rnu w_onebuf_opt.wo_rnu // 'relativenumber'
long wo_nuw;
-# define w_p_nuw w_onebuf_opt.wo_nuw // 'numberwidth'
+#define w_p_nuw w_onebuf_opt.wo_nuw // 'numberwidth'
int wo_wfh;
-# define w_p_wfh w_onebuf_opt.wo_wfh // 'winfixheight'
+#define w_p_wfh w_onebuf_opt.wo_wfh // 'winfixheight'
int wo_wfw;
-# define w_p_wfw w_onebuf_opt.wo_wfw // 'winfixwidth'
+#define w_p_wfw w_onebuf_opt.wo_wfw // 'winfixwidth'
int wo_pvw;
-# define w_p_pvw w_onebuf_opt.wo_pvw // 'previewwindow'
+#define w_p_pvw w_onebuf_opt.wo_pvw // 'previewwindow'
int wo_rl;
-# define w_p_rl w_onebuf_opt.wo_rl // 'rightleft'
- char_u *wo_rlc;
-# define w_p_rlc w_onebuf_opt.wo_rlc // 'rightleftcmd'
+#define w_p_rl w_onebuf_opt.wo_rl // 'rightleft'
+ char_u *wo_rlc;
+#define w_p_rlc w_onebuf_opt.wo_rlc // 'rightleftcmd'
long wo_scr;
#define w_p_scr w_onebuf_opt.wo_scr // 'scroll'
int wo_spell;
-# define w_p_spell w_onebuf_opt.wo_spell // 'spell'
+#define w_p_spell w_onebuf_opt.wo_spell // 'spell'
int wo_cuc;
-# define w_p_cuc w_onebuf_opt.wo_cuc // 'cursorcolumn'
+#define w_p_cuc w_onebuf_opt.wo_cuc // 'cursorcolumn'
int wo_cul;
-# define w_p_cul w_onebuf_opt.wo_cul // 'cursorline'
- char_u *wo_culopt;
-# define w_p_culopt w_onebuf_opt.wo_culopt // 'cursorlineopt'
- char_u *wo_cc;
-# define w_p_cc w_onebuf_opt.wo_cc // 'colorcolumn'
- char_u *wo_sbr;
-# define w_p_sbr w_onebuf_opt.wo_sbr // 'showbreak'
- char_u *wo_stl;
+#define w_p_cul w_onebuf_opt.wo_cul // 'cursorline'
+ char_u *wo_culopt;
+#define w_p_culopt w_onebuf_opt.wo_culopt // 'cursorlineopt'
+ char_u *wo_cc;
+#define w_p_cc w_onebuf_opt.wo_cc // 'colorcolumn'
+ char_u *wo_sbr;
+#define w_p_sbr w_onebuf_opt.wo_sbr // 'showbreak'
+ char_u *wo_stl;
#define w_p_stl w_onebuf_opt.wo_stl // 'statusline'
int wo_scb;
-# define w_p_scb w_onebuf_opt.wo_scb // 'scrollbind'
+#define w_p_scb w_onebuf_opt.wo_scb // 'scrollbind'
int wo_diff_saved; // options were saved for starting diff mode
-# define w_p_diff_saved w_onebuf_opt.wo_diff_saved
+#define w_p_diff_saved w_onebuf_opt.wo_diff_saved
int wo_scb_save; // 'scrollbind' saved for diff mode
-# define w_p_scb_save w_onebuf_opt.wo_scb_save
+#define w_p_scb_save w_onebuf_opt.wo_scb_save
int wo_wrap;
#define w_p_wrap w_onebuf_opt.wo_wrap // 'wrap'
int wo_wrap_save; // 'wrap' state saved for diff mode
-# define w_p_wrap_save w_onebuf_opt.wo_wrap_save
- char_u *wo_cocu; // 'concealcursor'
-# define w_p_cocu w_onebuf_opt.wo_cocu
+#define w_p_wrap_save w_onebuf_opt.wo_wrap_save
+ char_u *wo_cocu; // 'concealcursor'
+#define w_p_cocu w_onebuf_opt.wo_cocu
long wo_cole; // 'conceallevel'
-# define w_p_cole w_onebuf_opt.wo_cole
+#define w_p_cole w_onebuf_opt.wo_cole
int wo_crb;
-# define w_p_crb w_onebuf_opt.wo_crb // 'cursorbind'
+#define w_p_crb w_onebuf_opt.wo_crb // 'cursorbind'
int wo_crb_save; // 'cursorbind' state saved for diff mode
-# define w_p_crb_save w_onebuf_opt.wo_crb_save
+#define w_p_crb_save w_onebuf_opt.wo_crb_save
char_u *wo_scl;
-# define w_p_scl w_onebuf_opt.wo_scl // 'signcolumn'
+#define w_p_scl w_onebuf_opt.wo_scl // 'signcolumn'
char_u *wo_winhl;
-# define w_p_winhl w_onebuf_opt.wo_winhl // 'winhighlight'
+#define w_p_winhl w_onebuf_opt.wo_winhl // 'winhighlight'
char_u *wo_fcs;
-# define w_p_fcs w_onebuf_opt.wo_fcs // 'fillchars'
+#define w_p_fcs w_onebuf_opt.wo_fcs // 'fillchars'
char_u *wo_lcs;
-# define w_p_lcs w_onebuf_opt.wo_lcs // 'listchars'
+#define w_p_lcs w_onebuf_opt.wo_lcs // 'listchars'
long wo_winbl;
-# define w_p_winbl w_onebuf_opt.wo_winbl // 'winblend'
+#define w_p_winbl w_onebuf_opt.wo_winbl // 'winblend'
LastSet wo_script_ctx[WV_COUNT]; // SCTXs for window-local options
-# define w_p_script_ctx w_onebuf_opt.wo_script_ctx
+#define w_p_script_ctx w_onebuf_opt.wo_script_ctx
} winopt_T;
/*
@@ -278,9 +277,9 @@ typedef struct {
* most-recently-used order.
*/
struct wininfo_S {
- wininfo_T *wi_next; // next entry or NULL for last entry
- wininfo_T *wi_prev; // previous entry or NULL for first entry
- win_T *wi_win; // pointer to window that did set wi_fpos
+ wininfo_T *wi_next; // next entry or NULL for last entry
+ wininfo_T *wi_prev; // previous entry or NULL for first entry
+ win_T *wi_win; // pointer to window that did set wi_fpos
pos_T wi_fpos; // last cursor position in the file
bool wi_optset; // true when wi_opt has useful values
winopt_T wi_opt; // local window options
@@ -306,11 +305,11 @@ typedef struct arglist {
//
// TODO(Felipe): move aentry_T to another header
typedef struct argentry {
- char_u *ae_fname; // file name as specified
+ char_u *ae_fname; // file name as specified
int ae_fnum; // buffer number with expanded file name
} aentry_T;
-# define ALIST(win) (win)->w_alist
+#define ALIST(win) (win)->w_alist
#define GARGLIST ((aentry_T *)global_alist.al_ga.ga_data)
#define ARGLIST ((aentry_T *)ALIST(curwin)->al_ga.ga_data)
#define WARGLIST(wp) ((aentry_T *)ALIST(wp)->al_ga.ga_data)
@@ -323,8 +322,8 @@ typedef struct argentry {
* Used for the typeahead buffer: typebuf.
*/
typedef struct {
- char_u *tb_buf; // buffer for typed characters
- char_u *tb_noremap; // mapping flags for characters in tb_buf[]
+ char_u *tb_buf; // buffer for typed characters
+ char_u *tb_noremap; // mapping flags for characters in tb_buf[]
int tb_buflen; // size of tb_buf[]
int tb_off; // current position in tb_buf[]
int tb_len; // number of valid bytes in tb_buf[]
@@ -350,10 +349,10 @@ typedef struct {
*/
typedef struct mapblock mapblock_T;
struct mapblock {
- mapblock_T *m_next; // next mapblock in list
- char_u *m_keys; // mapped from, lhs
- char_u *m_str; // mapped to, rhs
- char_u *m_orig_str; // rhs as entered by the user
+ mapblock_T *m_next; // next mapblock in list
+ char_u *m_keys; // mapped from, lhs
+ char_u *m_str; // mapped to, rhs
+ char_u *m_orig_str; // rhs as entered by the user
int m_keylen; // strlen(m_keys)
int m_mode; // valid mode
int m_noremap; // if non-zero no re-mapping for m_str
@@ -366,7 +365,7 @@ struct mapblock {
/// Used for highlighting in the status line.
typedef struct stl_hlrec stl_hlrec_t;
struct stl_hlrec {
- char_u *start;
+ char_u *start;
int userhl; // 0: no HL, 1-9: User HL, < 0 for syn ID
};
@@ -403,7 +402,7 @@ struct stl_item {
#define SYNFLD_MINIMUM 1 // use lowest local minimum level on line
// avoid #ifdefs for when b_spell is not available
-# define B_SPELL(buf) ((buf)->b_spell)
+#define B_SPELL(buf) ((buf)->b_spell)
typedef struct qf_info_S qf_info_T;
@@ -440,8 +439,8 @@ typedef struct {
long b_syn_sync_minlines; // minimal sync lines offset
long b_syn_sync_maxlines; // maximal sync lines offset
long b_syn_sync_linebreaks; // offset for multi-line pattern
- char_u *b_syn_linecont_pat; // line continuation pattern
- regprog_T *b_syn_linecont_prog; // line continuation program
+ char_u *b_syn_linecont_pat; // line continuation pattern
+ regprog_T *b_syn_linecont_prog; // line continuation program
syn_time_T b_syn_linecont_time;
int b_syn_linecont_ic; // ignore-case flag for above
int b_syn_topgrp; // for ":syntax include"
@@ -460,10 +459,10 @@ typedef struct {
// b_sst_freecount number of free entries in b_sst_array[]
// b_sst_check_lnum entries after this lnum need to be checked for
// validity (MAXLNUM means no check needed)
- synstate_T *b_sst_array;
+ synstate_T *b_sst_array;
int b_sst_len;
- synstate_T *b_sst_first;
- synstate_T *b_sst_firstfree;
+ synstate_T *b_sst_first;
+ synstate_T *b_sst_firstfree;
int b_sst_freecount;
linenr_T b_sst_check_lnum;
disptick_T b_sst_lasttick; // last display tick
@@ -471,12 +470,12 @@ typedef struct {
// for spell checking
garray_T b_langp; // list of pointers to slang_T, see spell.c
bool b_spell_ismw[256]; // flags: is midword char
- char_u *b_spell_ismw_mb; // multi-byte midword chars
- char_u *b_p_spc; // 'spellcapcheck'
- regprog_T *b_cap_prog; // program for 'spellcapcheck'
- char_u *b_p_spf; // 'spellfile'
- char_u *b_p_spl; // 'spelllang'
- char_u *b_p_spo; // 'spelloptions'
+ char_u *b_spell_ismw_mb; // multi-byte midword chars
+ char_u *b_p_spc; // 'spellcapcheck'
+ regprog_T *b_cap_prog; // program for 'spellcapcheck'
+ char_u *b_p_spf; // 'spellfile'
+ char_u *b_p_spl; // 'spelllang'
+ char_u *b_p_spo; // 'spelloptions'
int b_cjk; // all CJK letters as OK
char_u b_syn_chartab[32]; // syntax iskeyword option
char_u *b_syn_isk; // iskeyword option
@@ -521,8 +520,8 @@ struct file_buffer {
memline_T b_ml; // associated memline (also contains line count
- buf_T *b_next; // links in list of buffers
- buf_T *b_prev;
+ buf_T *b_next; // links in list of buffers
+ buf_T *b_prev;
int b_nwindows; // nr of windows open on this buffer
@@ -538,11 +537,11 @@ struct file_buffer {
// b_fname is the same as b_sfname, unless ":cd" has been done,
// then it is the same as b_ffname (NULL for no name).
//
- char_u *b_ffname; // full path file name, allocated
- char_u *b_sfname; // short file name, allocated, may be equal to
- // b_ffname
- char_u *b_fname; // current file name, points to b_ffname or
- // b_sfname
+ char_u *b_ffname; // full path file name, allocated
+ char_u *b_sfname; // short file name, allocated, may be equal to
+ // b_ffname
+ char_u *b_fname; // current file name, points to b_ffname or
+ // b_sfname
bool file_id_valid;
FileID file_id;
@@ -577,7 +576,7 @@ struct file_buffer {
// change
long b_mod_xlines; // number of extra buffer lines inserted;
// negative when lines were deleted
- wininfo_T *b_wininfo; // list of last used info for each window
+ wininfo_T *b_wininfo; // list of last used info for each window
int b_mod_tick_syn; // last display tick syntax was updated
int b_mod_tick_decor; // last display tick decoration providers
// where invoked
@@ -614,10 +613,10 @@ struct file_buffer {
uint64_t b_chartab[4];
// Table used for mappings local to a buffer.
- mapblock_T *(b_maphash[MAX_MAPHASH]);
+ mapblock_T *(b_maphash[MAX_MAPHASH]);
// First abbreviation local to a buffer.
- mapblock_T *b_first_abbr;
+ mapblock_T *b_first_abbr;
// User commands local to the buffer.
garray_T b_ucmds;
/*
@@ -632,10 +631,10 @@ struct file_buffer {
/*
* The following only used in undo.c.
*/
- u_header_T *b_u_oldhead; // pointer to oldest header
- u_header_T *b_u_newhead; // pointer to newest header; may not be valid
- // if b_u_curhead is not NULL
- u_header_T *b_u_curhead; // pointer to current header
+ u_header_T *b_u_oldhead; // pointer to oldest header
+ u_header_T *b_u_newhead; // pointer to newest header; may not be valid
+ // if b_u_curhead is not NULL
+ u_header_T *b_u_curhead; // pointer to current header
int b_u_numhead; // current number of headers
bool b_u_synced; // entry lists are synced
long b_u_seq_last; // last used undo sequence number
@@ -647,7 +646,7 @@ struct file_buffer {
/*
* variables for "U" command in undo.c
*/
- char_u *b_u_line_ptr; // saved line for "U" command
+ char_u *b_u_line_ptr; // saved line for "U" command
linenr_T b_u_line_lnum; // line number of line in u_line
colnr_T b_u_line_colnr; // optional column number
@@ -659,11 +658,11 @@ struct file_buffer {
#define B_IMODE_USE_INSERT -1 // Use b_p_iminsert value for search
#define B_IMODE_NONE 0 // Input via none
#define B_IMODE_LMAP 1 // Input via langmap
-# define B_IMODE_LAST 1
+#define B_IMODE_LAST 1
int16_t b_kmap_state; // using "lmap" mappings
-# define KEYMAP_INIT 1 // 'keymap' was set, call keymap_init()
-# define KEYMAP_LOADED 2 // 'keymap' mappings have been loaded
+#define KEYMAP_INIT 1 // 'keymap' was set, call keymap_init()
+#define KEYMAP_LOADED 2 // 'keymap' mappings have been loaded
garray_T b_kmap_ga; // the keymap table
/*
@@ -818,7 +817,7 @@ struct file_buffer {
int b_start_eol; // last line had eol when it was read
int b_start_ffc; // first char of 'ff' when edit started
- char_u *b_start_fenc; // 'fileencoding' when edit started or NULL
+ char_u *b_start_fenc; // 'fileencoding' when edit started or NULL
int b_bad_char; // "++bad=" argument when edit started or 0
int b_start_bomb; // 'bomb' when it was read
@@ -901,7 +900,7 @@ struct file_buffer {
/*
* Stuff for diff mode.
*/
-# define DB_COUNT 8 // up to four buffers can be diff'ed
+#define DB_COUNT 8 // up to four buffers can be diff'ed
/*
* Each diffblock defines where a block of lines starts in each of the buffers
@@ -919,14 +918,14 @@ struct file_buffer {
*/
typedef struct diffblock_S diff_T;
struct diffblock_S {
- diff_T *df_next;
+ diff_T *df_next;
linenr_T df_lnum[DB_COUNT]; // line number in buffer
linenr_T df_count[DB_COUNT]; // nr of inserted/changed lines
};
#define SNAP_HELP_IDX 0
-# define SNAP_AUCMD_IDX 1
-# define SNAP_COUNT 2
+#define SNAP_AUCMD_IDX 1
+#define SNAP_COUNT 2
/// Tab pages point to the top frame of each tab page.
/// Note: Most values are NOT valid for the current tab page! Use "curwin",
@@ -935,25 +934,25 @@ struct diffblock_S {
typedef struct tabpage_S tabpage_T;
struct tabpage_S {
handle_T handle;
- tabpage_T *tp_next; ///< next tabpage or NULL
- frame_T *tp_topframe; ///< topframe for the windows
- win_T *tp_curwin; ///< current window in this Tab page
- win_T *tp_prevwin; ///< previous window in this Tab page
- win_T *tp_firstwin; ///< first window in this Tab page
- win_T *tp_lastwin; ///< last window in this Tab page
+ tabpage_T *tp_next; ///< next tabpage or NULL
+ frame_T *tp_topframe; ///< topframe for the windows
+ win_T *tp_curwin; ///< current window in this Tab page
+ win_T *tp_prevwin; ///< previous window in this Tab page
+ win_T *tp_firstwin; ///< first window in this Tab page
+ win_T *tp_lastwin; ///< last window in this Tab page
long tp_old_Rows; ///< Rows when Tab page was left
long tp_old_Columns; ///< Columns when Tab page was left
long tp_ch_used; ///< value of 'cmdheight' when frame size
///< was set
- diff_T *tp_first_diff;
- buf_T *(tp_diffbuf[DB_COUNT]);
+ diff_T *tp_first_diff;
+ buf_T *(tp_diffbuf[DB_COUNT]);
int tp_diff_invalid; ///< list of diffs is outdated
int tp_diff_update; ///< update diffs before redrawing
- frame_T *(tp_snapshot[SNAP_COUNT]); ///< window layout snapshots
+ frame_T *(tp_snapshot[SNAP_COUNT]); ///< window layout snapshots
ScopeDictDictItem tp_winvar; ///< Variable for "t:" Dictionary.
- dict_T *tp_vars; ///< Internal variables, local to tab page.
- char_u *tp_localdir; ///< Absolute path of local cwd or NULL.
+ dict_T *tp_vars; ///< Internal variables, local to tab page.
+ char_u *tp_localdir; ///< Absolute path of local cwd or NULL.
};
/*
@@ -986,14 +985,14 @@ struct frame_S {
int fr_newwidth; // new width used in win_equal_rec()
int fr_height;
int fr_newheight; // new height used in win_equal_rec()
- frame_T *fr_parent; // containing frame or NULL
- frame_T *fr_next; // frame right or below in same parent, NULL
- // for last
- frame_T *fr_prev; // frame left or above in same parent, NULL
- // for first
+ frame_T *fr_parent; // containing frame or NULL
+ frame_T *fr_next; // frame right or below in same parent, NULL
+ // for last
+ frame_T *fr_prev; // frame left or above in same parent, NULL
+ // for first
// fr_child and fr_win are mutually exclusive
- frame_T *fr_child; // first contained frame
- win_T *fr_win; // window that fills this frame
+ frame_T *fr_child; // first contained frame
+ win_T *fr_win; // window that fills this frame
};
#define FR_LEAF 0 // frame is a leaf
@@ -1009,7 +1008,7 @@ struct frame_S {
typedef struct {
regmmatch_T rm; // points to the regexp program; contains last found
// match (may continue in next line)
- buf_T *buf; // the buffer to search for a match
+ buf_T *buf; // the buffer to search for a match
linenr_T lnum; // the line to search for a match
int attr; // attributes to be used for a match
int attr_cur; // attributes currently active in win_line()
@@ -1026,9 +1025,9 @@ typedef struct {
/// Same as lpos_T, but with additional field len.
typedef struct
{
- linenr_T lnum; ///< line number
- colnr_T col; ///< column number
- int len; ///< length: 0 - to the end of line
+ linenr_T lnum; ///< line number
+ colnr_T col; ///< column number
+ int len; ///< length: 0 - to the end of line
} llpos_T;
/// posmatch_T provides an array for storing match items for matchaddpos()
@@ -1036,10 +1035,10 @@ typedef struct
typedef struct posmatch posmatch_T;
struct posmatch
{
- llpos_T pos[MAXPOSMATCH]; ///< array of positions
- int cur; ///< internal position counter
- linenr_T toplnum; ///< top buffer line
- linenr_T botlnum; ///< bottom buffer line
+ llpos_T pos[MAXPOSMATCH]; ///< array of positions
+ int cur; ///< internal position counter
+ linenr_T toplnum; ///< top buffer line
+ linenr_T botlnum; ///< bottom buffer line
};
/*
@@ -1144,20 +1143,20 @@ typedef struct VimMenu vimmenu_T;
struct VimMenu {
int modes; ///< Which modes is this menu visible for
int enabled; ///< for which modes the menu is enabled
- char_u *name; ///< Name of menu, possibly translated
- char_u *dname; ///< Displayed Name ("name" without '&')
- char_u *en_name; ///< "name" untranslated, NULL when
- ///< was not translated
- char_u *en_dname; ///< NULL when "dname" untranslated
+ char_u *name; ///< Name of menu, possibly translated
+ char_u *dname; ///< Displayed Name ("name" without '&')
+ char_u *en_name; ///< "name" untranslated, NULL when
+ ///< was not translated
+ char_u *en_dname; ///< NULL when "dname" untranslated
int mnemonic; ///< mnemonic key (after '&')
- char_u *actext; ///< accelerator text (after TAB)
+ char_u *actext; ///< accelerator text (after TAB)
long priority; ///< Menu order priority
- char_u *strings[MENU_MODES]; ///< Mapped string for each mode
+ char_u *strings[MENU_MODES]; ///< Mapped string for each mode
int noremap[MENU_MODES]; ///< A \ref REMAP_VALUES flag for each mode
bool silent[MENU_MODES]; ///< A silent flag for each mode
- vimmenu_T *children; ///< Children of sub-menu
- vimmenu_T *parent; ///< Parent of menu
- vimmenu_T *next; ///< Next item in menu
+ vimmenu_T *children; ///< Children of sub-menu
+ vimmenu_T *parent; ///< Parent of menu
+ vimmenu_T *next; ///< Next item in menu
};
/// Structure which contains all information that belongs to a window.
@@ -1166,10 +1165,10 @@ struct VimMenu {
struct window_S {
handle_T handle; ///< unique identifier for the window
- buf_T *w_buffer; ///< buffer we are a window into (used
- ///< often, keep it the first item!)
+ buf_T *w_buffer; ///< buffer we are a window into (used
+ ///< often, keep it the first item!)
- synblock_T *w_s; ///< for :ownsyntax
+ synblock_T *w_s; ///< for :ownsyntax
int w_hl_id_normal; ///< 'winhighlight' normal id
int w_hl_attr_normal; ///< 'winhighlight' normal final attrs
@@ -1179,12 +1178,12 @@ struct window_S {
int w_hl_needs_update; ///< attrs need to be recalculated
- win_T *w_prev; ///< link to previous window
- win_T *w_next; ///< link to next window
+ win_T *w_prev; ///< link to previous window
+ win_T *w_next; ///< link to next window
bool w_closing; ///< window is being closed, don't let
/// autocommands close it too.
- frame_T *w_frame; ///< frame containing this window
+ frame_T *w_frame; ///< frame containing this window
pos_T w_cursor; ///< cursor position in buffer
@@ -1345,7 +1344,7 @@ struct window_S {
* This is used for efficient redrawing.
*/
int w_lines_valid; // number of valid entries
- wline_T *w_lines;
+ wline_T *w_lines;
garray_T w_folds; // array of nested folds
bool w_fold_manual; // when true: some folds are opened/closed
@@ -1377,13 +1376,13 @@ struct window_S {
int w_alt_fnum; // alternate file (for # and CTRL-^)
- alist_T *w_alist; // pointer to arglist for this window
+ alist_T *w_alist; // pointer to arglist for this window
int w_arg_idx; // current index in argument list (can be
// out of range!)
int w_arg_idx_invalid; // editing another file than w_arg_idx
- char_u *w_localdir; /* absolute path of local directory or
- NULL */
+ char_u *w_localdir; /* absolute path of local directory or
+ NULL */
// Options local to a window.
// They are local because they influence the layout of the window or
// depend on the window layout.
@@ -1396,10 +1395,10 @@ struct window_S {
uint32_t w_p_stl_flags; // flags for 'statusline'
uint32_t w_p_fde_flags; // flags for 'foldexpr'
uint32_t w_p_fdt_flags; // flags for 'foldtext'
- int *w_p_cc_cols; // array of columns to highlight or NULL
- char_u w_p_culopt_flags; // flags for cursorline highlighting
- long w_p_siso; // 'sidescrolloff' local value
- long w_p_so; // 'scrolloff' local value
+ int *w_p_cc_cols; // array of columns to highlight or NULL
+ char_u w_p_culopt_flags; // flags for cursorline highlighting
+ long w_p_siso; // 'sidescrolloff' local value
+ long w_p_so; // 'scrolloff' local value
int w_briopt_min; // minimum width for breakindent
int w_briopt_shift; // additional shift for breakindent
@@ -1463,10 +1462,10 @@ struct window_S {
* was computed. */
int w_nrwidth_width; // nr of chars to print line count.
- qf_info_T *w_llist; // Location list for this window
+ qf_info_T *w_llist; // Location list for this window
// Location list reference used in the location list window.
// In a non-location list window, w_llist_ref is NULL.
- qf_info_T *w_llist_ref;
+ qf_info_T *w_llist_ref;
};
static inline int win_hl_attr(win_T *wp, int hlf)
@@ -1476,6 +1475,6 @@ static inline int win_hl_attr(win_T *wp, int hlf)
/// Macros defined in Vim, but not in Neovim
#define CHANGEDTICK(buf) \
- (=== Include buffer.h & use buf_(get|set|inc)_changedtick ===)
+ (=== Include buffer.h & use buf_(get|set|inc) _changedtick ===)
#endif // NVIM_BUFFER_DEFS_H
diff --git a/src/nvim/change.c b/src/nvim/change.c
index 4ac5edeaa9..2450c56838 100644
--- a/src/nvim/change.c
+++ b/src/nvim/change.c
@@ -413,7 +413,11 @@ void deleted_lines(linenr_T lnum, long count)
/// be triggered to display the cursor.
void deleted_lines_mark(linenr_T lnum, long count)
{
- mark_adjust(lnum, (linenr_T)(lnum + count - 1), (long)MAXLNUM, -count,
+ // if we deleted the entire buffer, we need to implicity add a new empty line
+ bool made_empty = (count > 0) && curbuf->b_ml.ml_flags & ML_EMPTY;
+
+ mark_adjust(lnum, (linenr_T)(lnum + count - 1), (long)MAXLNUM,
+ -count + (made_empty?1:0),
kExtmarkUndo);
changed_lines(lnum, 0, lnum + count, -count, true);
}
@@ -625,7 +629,7 @@ void ins_char_bytes(char_u *buf, size_t charlen)
// Copy bytes before the cursor.
if (col > 0) {
- memmove(newp, oldp, (size_t)col);
+ memmove(newp, oldp, col);
}
// Copy bytes after the changed character(s).
diff --git a/src/nvim/channel.c b/src/nvim/channel.c
index 30243a3102..db0a2ff64c 100644
--- a/src/nvim/channel.c
+++ b/src/nvim/channel.c
@@ -87,7 +87,7 @@ bool channel_close(uint64_t id, ChannelPart part, const char **error)
break;
case kChannelStreamProc:
- proc = (Process *)&chan->stream.proc;
+ proc = &chan->stream.proc;
if (part == kChannelPartStdin || close_main) {
stream_may_close(&proc->in);
}
@@ -335,7 +335,7 @@ Channel *channel_job_start(char **argv, CallbackReader on_stdout, CallbackReader
chan->stream.uv = libuv_process_init(&main_loop, chan);
}
- Process *proc = (Process *)&chan->stream.proc;
+ Process *proc = &chan->stream.proc;
proc->argv = argv;
proc->cb = channel_process_exit_cb;
proc->events = chan->events;
diff --git a/src/nvim/channel.h b/src/nvim/channel.h
index 9bc0df3615..4f51a7fc78 100644
--- a/src/nvim/channel.h
+++ b/src/nvim/channel.h
@@ -1,13 +1,13 @@
#ifndef NVIM_CHANNEL_H
#define NVIM_CHANNEL_H
-#include "nvim/main.h"
-#include "nvim/event/socket.h"
-#include "nvim/event/process.h"
-#include "nvim/os/pty_process.h"
-#include "nvim/event/libuv_process.h"
#include "nvim/eval/typval.h"
+#include "nvim/event/libuv_process.h"
+#include "nvim/event/process.h"
+#include "nvim/event/socket.h"
+#include "nvim/main.h"
#include "nvim/msgpack_rpc/channel_defs.h"
+#include "nvim/os/pty_process.h"
#define CHAN_STDIO 1
#define CHAN_STDERR 2
@@ -105,18 +105,18 @@ static inline Stream *channel_instream(Channel *chan)
FUNC_ATTR_NONNULL_ALL
{
switch (chan->streamtype) {
- case kChannelStreamProc:
- return &chan->stream.proc.in;
+ case kChannelStreamProc:
+ return &chan->stream.proc.in;
- case kChannelStreamSocket:
- return &chan->stream.socket;
+ case kChannelStreamSocket:
+ return &chan->stream.socket;
- case kChannelStreamStdio:
- return &chan->stream.stdio.out;
+ case kChannelStreamStdio:
+ return &chan->stream.stdio.out;
- case kChannelStreamInternal:
- case kChannelStreamStderr:
- abort();
+ case kChannelStreamInternal:
+ case kChannelStreamStderr:
+ abort();
}
abort();
}
@@ -125,18 +125,18 @@ static inline Stream *channel_outstream(Channel *chan)
FUNC_ATTR_NONNULL_ALL
{
switch (chan->streamtype) {
- case kChannelStreamProc:
- return &chan->stream.proc.out;
+ case kChannelStreamProc:
+ return &chan->stream.proc.out;
- case kChannelStreamSocket:
- return &chan->stream.socket;
+ case kChannelStreamSocket:
+ return &chan->stream.socket;
- case kChannelStreamStdio:
- return &chan->stream.stdio.in;
+ case kChannelStreamStdio:
+ return &chan->stream.stdio.in;
- case kChannelStreamInternal:
- case kChannelStreamStderr:
- abort();
+ case kChannelStreamInternal:
+ case kChannelStreamStderr:
+ abort();
}
abort();
}
diff --git a/src/nvim/charset.h b/src/nvim/charset.h
index 2fef4d78a2..47d89717e8 100644
--- a/src/nvim/charset.h
+++ b/src/nvim/charset.h
@@ -1,11 +1,11 @@
#ifndef NVIM_CHARSET_H
#define NVIM_CHARSET_H
-#include "nvim/types.h"
-#include "nvim/pos.h"
#include "nvim/buffer_defs.h"
#include "nvim/eval/typval.h"
#include "nvim/option_defs.h"
+#include "nvim/pos.h"
+#include "nvim/types.h"
/// Return the folded-case equivalent of the given character
///
@@ -13,7 +13,7 @@
///
/// @return Folded variant.
#define CH_FOLD(c) \
- utf_fold((sizeof(c) == sizeof(char)) \
+ utf_fold((sizeof(c) == sizeof(char)) \
?((int)(uint8_t)(c)) \
:((int)(c)))
diff --git a/src/nvim/context.h b/src/nvim/context.h
index 7edd63ced2..c2deca12c9 100644
--- a/src/nvim/context.h
+++ b/src/nvim/context.h
@@ -2,6 +2,7 @@
#define NVIM_CONTEXT_H
#include <msgpack.h>
+
#include "nvim/api/private/defs.h"
#include "nvim/lib/kvec.h"
diff --git a/src/nvim/cursor_shape.c b/src/nvim/cursor_shape.c
index 128bc480da..18cade1052 100644
--- a/src/nvim/cursor_shape.c
+++ b/src/nvim/cursor_shape.c
@@ -230,12 +230,11 @@ char_u *parse_shape_opt(int what)
slashp = vim_strchr(p, '/');
if (slashp != NULL && slashp < endp) {
// "group/langmap_group"
- i = syn_check_group(p, (int)(slashp - p));
+ i = syn_check_group((char *)p, (int)(slashp - p));
p = slashp + 1;
}
if (round == 2) {
- shape_table[idx].id = syn_check_group(p,
- (int)(endp - p));
+ shape_table[idx].id = syn_check_group((char *)p, (int)(endp - p));
shape_table[idx].id_lm = shape_table[idx].id;
if (slashp != NULL && slashp < endp) {
shape_table[idx].id = i;
diff --git a/src/nvim/cursor_shape.h b/src/nvim/cursor_shape.h
index a23fa6836d..06eaa431a0 100644
--- a/src/nvim/cursor_shape.h
+++ b/src/nvim/cursor_shape.h
@@ -1,36 +1,36 @@
#ifndef NVIM_CURSOR_SHAPE_H
#define NVIM_CURSOR_SHAPE_H
-#include "nvim/types.h"
#include "nvim/api/private/defs.h"
+#include "nvim/types.h"
/// struct to store values from 'guicursor' and 'mouseshape'
/// Indexes in shape_table[]
typedef enum {
-SHAPE_IDX_N = 0, ///< Normal mode
-SHAPE_IDX_V = 1, ///< Visual mode
-SHAPE_IDX_I = 2, ///< Insert mode
-SHAPE_IDX_R = 3, ///< Replace mode
-SHAPE_IDX_C = 4, ///< Command line Normal mode
-SHAPE_IDX_CI = 5, ///< Command line Insert mode
-SHAPE_IDX_CR = 6, ///< Command line Replace mode
-SHAPE_IDX_O = 7, ///< Operator-pending mode
-SHAPE_IDX_VE = 8, ///< Visual mode with 'selection' exclusive
-SHAPE_IDX_CLINE = 9, ///< On command line
-SHAPE_IDX_STATUS = 10, ///< On status line
-SHAPE_IDX_SDRAG = 11, ///< dragging a status line
-SHAPE_IDX_VSEP = 12, ///< On vertical separator line
-SHAPE_IDX_VDRAG = 13, ///< dragging a vertical separator line
-SHAPE_IDX_MORE = 14, ///< Hit-return or More
-SHAPE_IDX_MOREL = 15, ///< Hit-return or More in last line
-SHAPE_IDX_SM = 16, ///< showing matching paren
-SHAPE_IDX_COUNT = 17
+ SHAPE_IDX_N = 0, ///< Normal mode
+ SHAPE_IDX_V = 1, ///< Visual mode
+ SHAPE_IDX_I = 2, ///< Insert mode
+ SHAPE_IDX_R = 3, ///< Replace mode
+ SHAPE_IDX_C = 4, ///< Command line Normal mode
+ SHAPE_IDX_CI = 5, ///< Command line Insert mode
+ SHAPE_IDX_CR = 6, ///< Command line Replace mode
+ SHAPE_IDX_O = 7, ///< Operator-pending mode
+ SHAPE_IDX_VE = 8, ///< Visual mode with 'selection' exclusive
+ SHAPE_IDX_CLINE = 9, ///< On command line
+ SHAPE_IDX_STATUS = 10, ///< On status line
+ SHAPE_IDX_SDRAG = 11, ///< dragging a status line
+ SHAPE_IDX_VSEP = 12, ///< On vertical separator line
+ SHAPE_IDX_VDRAG = 13, ///< dragging a vertical separator line
+ SHAPE_IDX_MORE = 14, ///< Hit-return or More
+ SHAPE_IDX_MOREL = 15, ///< Hit-return or More in last line
+ SHAPE_IDX_SM = 16, ///< showing matching paren
+ SHAPE_IDX_COUNT = 17
} ModeShape;
typedef enum {
-SHAPE_BLOCK = 0, ///< block cursor
-SHAPE_HOR = 1, ///< horizontal bar cursor
-SHAPE_VER = 2 ///< vertical bar cursor
+ SHAPE_BLOCK = 0, ///< block cursor
+ SHAPE_HOR = 1, ///< horizontal bar cursor
+ SHAPE_VER = 2 ///< vertical bar cursor
} CursorShape;
#define MSHAPE_NUMBERED 1000 // offset for shapes identified by number
diff --git a/src/nvim/debugger.c b/src/nvim/debugger.c
index 58b1d9ce7f..aeaf2555b1 100644
--- a/src/nvim/debugger.c
+++ b/src/nvim/debugger.c
@@ -390,7 +390,7 @@ static char_u *debug_skipped_name;
/// Called from do_one_cmd() before executing a command.
void dbg_check_breakpoint(exarg_T *eap)
{
- char_u *p;
+ char *p;
debug_skipped = false;
if (debug_breakpoint_name != NULL) {
@@ -399,9 +399,9 @@ void dbg_check_breakpoint(exarg_T *eap)
if (debug_breakpoint_name[0] == K_SPECIAL
&& debug_breakpoint_name[1] == KS_EXTRA
&& debug_breakpoint_name[2] == KE_SNR) {
- p = (char_u *)"<SNR>";
+ p = "<SNR>";
} else {
- p = (char_u *)"";
+ p = "";
}
smsg(_("Breakpoint in \"%s%s\" line %" PRId64),
p,
diff --git a/src/nvim/decoration.h b/src/nvim/decoration.h
index 35f5af87ed..e44fbab0a5 100644
--- a/src/nvim/decoration.h
+++ b/src/nvim/decoration.h
@@ -1,9 +1,9 @@
#ifndef NVIM_DECORATION_H
#define NVIM_DECORATION_H
-#include "nvim/pos.h"
#include "nvim/buffer_defs.h"
#include "nvim/extmark_defs.h"
+#include "nvim/pos.h"
// actual Decoration data is in extmark_defs.h
@@ -82,9 +82,9 @@ EXTERN DecorState decor_state INIT(= { 0 });
EXTERN bool provider_active INIT(= false);
#define DECORATION_PROVIDER_INIT(ns_id) (DecorProvider) \
- { ns_id, false, LUA_NOREF, LUA_NOREF, \
- LUA_NOREF, LUA_NOREF, LUA_NOREF, \
- LUA_NOREF, -1 }
+ { ns_id, false, LUA_NOREF, LUA_NOREF, \
+ LUA_NOREF, LUA_NOREF, LUA_NOREF, \
+ LUA_NOREF, -1 }
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "decoration.h.generated.h"
diff --git a/src/nvim/diff.h b/src/nvim/diff.h
index 99a60381bd..53fc5aa077 100644
--- a/src/nvim/diff.h
+++ b/src/nvim/diff.h
@@ -1,8 +1,8 @@
#ifndef NVIM_DIFF_H
#define NVIM_DIFF_H
-#include "nvim/pos.h"
#include "nvim/ex_cmds_defs.h"
+#include "nvim/pos.h"
// Value set from 'diffopt'.
EXTERN int diff_context INIT(= 6); // context for folds
diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c
index b0fc4ee463..0fa6ebcd94 100644
--- a/src/nvim/digraph.c
+++ b/src/nvim/digraph.c
@@ -1843,12 +1843,12 @@ char_u *keymap_init(void)
vim_snprintf(buf, buflen, "keymap/%s_%s.vim",
curbuf->b_p_keymap, p_enc);
- if (source_runtime((char_u *)buf, 0) == FAIL) {
+ if (source_runtime(buf, 0) == FAIL) {
// try finding "keymap/'keymap'.vim" in 'runtimepath'
vim_snprintf(buf, buflen, "keymap/%s.vim",
curbuf->b_p_keymap);
- if (source_runtime((char_u *)buf, 0) == FAIL) {
+ if (source_runtime(buf, 0) == FAIL) {
xfree(buf);
return (char_u *)N_("E544: Keymap file not found");
}
diff --git a/src/nvim/digraph.h b/src/nvim/digraph.h
index 1b73ccaf3f..71330ae9b1 100644
--- a/src/nvim/digraph.h
+++ b/src/nvim/digraph.h
@@ -1,8 +1,8 @@
#ifndef NVIM_DIGRAPH_H
#define NVIM_DIGRAPH_H
-#include "nvim/types.h"
#include "nvim/ex_cmds_defs.h"
+#include "nvim/types.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "digraph.h.generated.h"
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index 5ac733285d..ea49222a93 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -5123,7 +5123,7 @@ static int ins_complete(int c, bool enable_pum)
))) {
prefix = (char_u *)"";
}
- STRCPY((char *)compl_pattern, prefix);
+ STRCPY(compl_pattern, prefix);
(void)quote_meta(compl_pattern + STRLEN(prefix),
line + compl_col, compl_length);
} else if (--startcol < 0
@@ -5152,13 +5152,13 @@ static int ins_complete(int c, bool enable_pum)
* xmalloc(7) is enough -- Acevedo
*/
compl_pattern = xmalloc(7);
- STRCPY((char *)compl_pattern, "\\<");
+ STRCPY(compl_pattern, "\\<");
(void)quote_meta(compl_pattern + 2, line + compl_col, 1);
- STRCAT((char *)compl_pattern, "\\k");
+ STRCAT(compl_pattern, "\\k");
} else {
compl_pattern = xmalloc(quote_meta(NULL, line + compl_col,
compl_length) + 2);
- STRCPY((char *)compl_pattern, "\\<");
+ STRCPY(compl_pattern, "\\<");
(void)quote_meta(compl_pattern + 2, line + compl_col,
compl_length);
}
diff --git a/src/nvim/edit.h b/src/nvim/edit.h
index ef5dce738a..894e23ee9f 100644
--- a/src/nvim/edit.h
+++ b/src/nvim/edit.h
@@ -24,27 +24,27 @@ typedef enum {
typedef int (*IndentGetter)(void);
-/* Values for in_cinkeys() */
+// Values for in_cinkeys()
#define KEY_OPEN_FORW 0x101
#define KEY_OPEN_BACK 0x102
-#define KEY_COMPLETE 0x103 /* end of completion */
-
-/* Values for change_indent() */
-#define INDENT_SET 1 /* set indent */
-#define INDENT_INC 2 /* increase indent */
-#define INDENT_DEC 3 /* decrease indent */
-
-/* flags for beginline() */
-#define BL_WHITE 1 /* cursor on first non-white in the line */
-#define BL_SOL 2 /* use 'sol' option */
-#define BL_FIX 4 /* don't leave cursor on a NUL */
-
-/* flags for insertchar() */
-#define INSCHAR_FORMAT 1 /* force formatting */
-#define INSCHAR_DO_COM 2 /* format comments */
-#define INSCHAR_CTRLV 4 /* char typed just after CTRL-V */
-#define INSCHAR_NO_FEX 8 /* don't use 'formatexpr' */
-#define INSCHAR_COM_LIST 16 /* format comments with list/2nd line indent */
+#define KEY_COMPLETE 0x103 // end of completion
+
+// Values for change_indent()
+#define INDENT_SET 1 // set indent
+#define INDENT_INC 2 // increase indent
+#define INDENT_DEC 3 // decrease indent
+
+// flags for beginline()
+#define BL_WHITE 1 // cursor on first non-white in the line
+#define BL_SOL 2 // use 'sol' option
+#define BL_FIX 4 // don't leave cursor on a NUL
+
+// flags for insertchar()
+#define INSCHAR_FORMAT 1 // force formatting
+#define INSCHAR_DO_COM 2 // format comments
+#define INSCHAR_CTRLV 4 // char typed just after CTRL-V
+#define INSCHAR_NO_FEX 8 // don't use 'formatexpr'
+#define INSCHAR_COM_LIST 16 // format comments with list/2nd line indent
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "edit.h.generated.h"
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index a281c09042..e6a3901dcf 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -1191,7 +1191,7 @@ int eval_foldexpr(char_u *arg, int *cp)
{
typval_T tv;
varnumber_T retval;
- int use_sandbox = was_set_insecurely(curwin, (char_u *)"foldexpr", OPT_LOCAL);
+ int use_sandbox = was_set_insecurely(curwin, "foldexpr", OPT_LOCAL);
++emsg_off;
if (use_sandbox) {
@@ -5899,17 +5899,17 @@ void prepare_assert_error(garray_T *gap)
ga_init(gap, 1, 100);
if (sourcing_name != NULL) {
- ga_concat(gap, sourcing_name);
+ ga_concat(gap, (char *)sourcing_name);
if (sourcing_lnum > 0) {
- ga_concat(gap, (char_u *)" ");
+ ga_concat(gap, " ");
}
}
if (sourcing_lnum > 0) {
vim_snprintf(buf, ARRAY_SIZE(buf), "line %" PRId64, (int64_t)sourcing_lnum);
- ga_concat(gap, (char_u *)buf);
+ ga_concat(gap, buf);
}
if (sourcing_name != NULL || sourcing_lnum > 0) {
- ga_concat(gap, (char_u *)": ");
+ ga_concat(gap, ": ");
}
}
@@ -5923,27 +5923,27 @@ static void ga_concat_esc(garray_T *gap, const char_u *p, int clen)
if (clen > 1) {
memmove(buf, p, clen);
buf[clen] = NUL;
- ga_concat(gap, buf);
+ ga_concat(gap, (char *)buf);
} else {
switch (*p) {
case BS:
- ga_concat(gap, (char_u *)"\\b"); break;
+ ga_concat(gap, "\\b"); break;
case ESC:
- ga_concat(gap, (char_u *)"\\e"); break;
+ ga_concat(gap, "\\e"); break;
case FF:
- ga_concat(gap, (char_u *)"\\f"); break;
+ ga_concat(gap, "\\f"); break;
case NL:
- ga_concat(gap, (char_u *)"\\n"); break;
+ ga_concat(gap, "\\n"); break;
case TAB:
- ga_concat(gap, (char_u *)"\\t"); break;
+ ga_concat(gap, "\\t"); break;
case CAR:
- ga_concat(gap, (char_u *)"\\r"); break;
+ ga_concat(gap, "\\r"); break;
case '\\':
- ga_concat(gap, (char_u *)"\\\\"); break;
+ ga_concat(gap, "\\\\"); break;
default:
if (*p < ' ') {
vim_snprintf((char *)buf, NUMBUFLEN, "\\x%02x", *p);
- ga_concat(gap, buf);
+ ga_concat(gap, (char *)buf);
} else {
ga_append(gap, *p);
}
@@ -5960,7 +5960,7 @@ static void ga_concat_shorten_esc(garray_T *gap, const char_u *str)
char_u buf[NUMBUFLEN];
if (str == NULL) {
- ga_concat(gap, (char_u *)"NULL");
+ ga_concat(gap, "NULL");
return;
}
@@ -5974,12 +5974,12 @@ static void ga_concat_shorten_esc(garray_T *gap, const char_u *str)
s += clen;
}
if (same_len > 20) {
- ga_concat(gap, (char_u *)"\\[");
+ ga_concat(gap, "\\[");
ga_concat_esc(gap, p, clen);
- ga_concat(gap, (char_u *)" occurs ");
+ ga_concat(gap, " occurs ");
vim_snprintf((char *)buf, NUMBUFLEN, "%d", same_len);
- ga_concat(gap, buf);
- ga_concat(gap, (char_u *)" times]");
+ ga_concat(gap, (char *)buf);
+ ga_concat(gap, " times]");
p = s - 1;
} else {
ga_concat_esc(gap, p, clen);
@@ -5995,17 +5995,17 @@ void fill_assert_error(garray_T *gap, typval_T *opt_msg_tv, char_u *exp_str, typ
if (opt_msg_tv->v_type != VAR_UNKNOWN) {
tofree = (char_u *)encode_tv2echo(opt_msg_tv, NULL);
- ga_concat(gap, tofree);
+ ga_concat(gap, (char *)tofree);
xfree(tofree);
- ga_concat(gap, (char_u *)": ");
+ ga_concat(gap, ": ");
}
if (atype == ASSERT_MATCH || atype == ASSERT_NOTMATCH) {
- ga_concat(gap, (char_u *)"Pattern ");
+ ga_concat(gap, "Pattern ");
} else if (atype == ASSERT_NOTEQUAL) {
- ga_concat(gap, (char_u *)"Expected not equal to ");
+ ga_concat(gap, "Expected not equal to ");
} else {
- ga_concat(gap, (char_u *)"Expected ");
+ ga_concat(gap, "Expected ");
}
if (exp_str == NULL) {
@@ -6018,11 +6018,11 @@ void fill_assert_error(garray_T *gap, typval_T *opt_msg_tv, char_u *exp_str, typ
if (atype != ASSERT_NOTEQUAL) {
if (atype == ASSERT_MATCH) {
- ga_concat(gap, (char_u *)" does not match ");
+ ga_concat(gap, " does not match ");
} else if (atype == ASSERT_NOTMATCH) {
- ga_concat(gap, (char_u *)" does match ");
+ ga_concat(gap, " does match ");
} else {
- ga_concat(gap, (char_u *)" but got ");
+ ga_concat(gap, " but got ");
}
tofree = (char_u *)encode_tv2string(got_tv, NULL);
ga_concat_shorten_esc(gap, tofree);
@@ -6126,21 +6126,21 @@ int assert_equalfile(typval_T *argvars)
prepare_assert_error(&ga);
if (argvars[2].v_type != VAR_UNKNOWN) {
char *const tofree = encode_tv2echo(&argvars[2], NULL);
- ga_concat(&ga, (char_u *)tofree);
+ ga_concat(&ga, tofree);
xfree(tofree);
- ga_concat(&ga, (char_u *)": ");
+ ga_concat(&ga, ": ");
}
- ga_concat(&ga, IObuff);
+ ga_concat(&ga, (char *)IObuff);
if (lineidx > 0) {
line1[lineidx] = NUL;
line2[lineidx] = NUL;
- ga_concat(&ga, (char_u *)" after \"");
- ga_concat(&ga, (char_u *)line1);
+ ga_concat(&ga, " after \"");
+ ga_concat(&ga, line1);
if (STRCMP(line1, line2) != 0) {
- ga_concat(&ga, (char_u *)"\" vs \"");
- ga_concat(&ga, (char_u *)line2);
+ ga_concat(&ga, "\" vs \"");
+ ga_concat(&ga, line2);
}
- ga_concat(&ga, (char_u *)"\"");
+ ga_concat(&ga, "\"");
}
assert_error(&ga);
ga_clear(&ga);
@@ -6166,13 +6166,13 @@ int assert_inrange(typval_T *argvars)
prepare_assert_error(&ga);
if (argvars[3].v_type != VAR_UNKNOWN) {
char_u *const tofree = (char_u *)encode_tv2string(&argvars[3], NULL);
- ga_concat(&ga, tofree);
+ ga_concat(&ga, (char *)tofree);
xfree(tofree);
} else {
char msg[80];
vim_snprintf(msg, sizeof(msg), "Expected range %g - %g, but got %g",
flower, fupper, factual);
- ga_concat(&ga, (char_u *)msg);
+ ga_concat(&ga, msg);
}
assert_error(&ga);
ga_clear(&ga);
@@ -6238,7 +6238,7 @@ int assert_exception(typval_T *argvars)
const char *const error = tv_get_string_chk(&argvars[0]);
if (vimvars[VV_EXCEPTION].vv_str == NULL) {
prepare_assert_error(&ga);
- ga_concat(&ga, (char_u *)"v:exception is not set");
+ ga_concat(&ga, "v:exception is not set");
assert_error(&ga);
ga_clear(&ga);
return 1;
@@ -6259,10 +6259,10 @@ static void assert_append_cmd_or_arg(garray_T *gap, typval_T *argvars, const cha
{
if (argvars[1].v_type != VAR_UNKNOWN && argvars[2].v_type != VAR_UNKNOWN) {
char *const tofree = encode_tv2echo(&argvars[2], NULL);
- ga_concat(gap, (char_u *)tofree);
+ ga_concat(gap, tofree);
xfree(tofree);
} else {
- ga_concat(gap, (char_u *)cmd);
+ ga_concat(gap, cmd);
}
}
@@ -6280,11 +6280,11 @@ int assert_beeps(typval_T *argvars, bool no_beep)
garray_T ga;
prepare_assert_error(&ga);
if (no_beep) {
- ga_concat(&ga, (const char_u *)"command did beep: ");
+ ga_concat(&ga, "command did beep: ");
} else {
- ga_concat(&ga, (const char_u *)"command did not beep: ");
+ ga_concat(&ga, "command did not beep: ");
}
- ga_concat(&ga, (const char_u *)cmd);
+ ga_concat(&ga, cmd);
assert_error(&ga);
ga_clear(&ga);
ret = 1;
@@ -6312,7 +6312,7 @@ int assert_fails(typval_T *argvars)
do_cmdline_cmd(cmd);
if (!called_emsg) {
prepare_assert_error(&ga);
- ga_concat(&ga, (const char_u *)"command did not fail: ");
+ ga_concat(&ga, "command did not fail: ");
assert_append_cmd_or_arg(&ga, argvars, cmd);
assert_error(&ga);
ga_clear(&ga);
@@ -6326,7 +6326,7 @@ int assert_fails(typval_T *argvars)
prepare_assert_error(&ga);
fill_assert_error(&ga, &argvars[2], NULL, &argvars[1],
&vimvars[VV_ERRMSG].vv_tv, ASSERT_OTHER);
- ga_concat(&ga, (char_u *)": ");
+ ga_concat(&ga, ": ");
assert_append_cmd_or_arg(&ga, argvars, cmd);
assert_error(&ga);
ga_clear(&ga);
@@ -9191,8 +9191,12 @@ static hashtab_T *find_var_ht_dict(const char *name, const size_t name_len, cons
} else if (*name == 'l' && funccal != NULL) { // local variable
*d = &funccal->l_vars;
} else if (*name == 's' // script variable
- && current_sctx.sc_sid > 0
+ && (current_sctx.sc_sid > 0 || current_sctx.sc_sid == SID_STR)
&& current_sctx.sc_sid <= ga_scripts.ga_len) {
+ // For anonymous scripts without a script item, create one now so script vars can be used
+ if (current_sctx.sc_sid == SID_STR) {
+ new_script_item(NULL, &current_sctx.sc_sid);
+ }
*d = &SCRIPT_SV(current_sctx.sc_sid)->sv_dict;
}
@@ -10224,7 +10228,7 @@ bool script_autoload(const char *const name, const size_t name_len, const bool r
}
// Try loading the package from $VIMRUNTIME/autoload/<name>.vim
- if (source_runtime((char_u *)scriptname, 0) == OK) {
+ if (source_runtime(scriptname, 0) == OK) {
ret = true;
}
}
diff --git a/src/nvim/eval.h b/src/nvim/eval.h
index 2452a0a8c8..3d656656de 100644
--- a/src/nvim/eval.h
+++ b/src/nvim/eval.h
@@ -3,7 +3,7 @@
#include "nvim/buffer_defs.h"
#include "nvim/channel.h"
-#include "nvim/eval/funcs.h" // For FunPtr
+#include "nvim/eval/funcs.h" // For FunPtr
#include "nvim/event/time.h" // For TimeWatcher
#include "nvim/ex_cmds_defs.h" // For exarg_T
#include "nvim/os/fileio.h" // For FileDescriptor
@@ -24,46 +24,46 @@ EXTERN ufunc_T dumuf;
/*
* Structure returned by get_lval() and used by set_var_lval().
* For a plain name:
- * "name" points to the variable name.
- * "exp_name" is NULL.
- * "tv" is NULL
+ * "name" points to the variable name.
+ * "exp_name" is NULL.
+ * "tv" is NULL
* For a magic braces name:
- * "name" points to the expanded variable name.
- * "exp_name" is non-NULL, to be freed later.
- * "tv" is NULL
+ * "name" points to the expanded variable name.
+ * "exp_name" is non-NULL, to be freed later.
+ * "tv" is NULL
* For an index in a list:
- * "name" points to the (expanded) variable name.
- * "exp_name" NULL or non-NULL, to be freed later.
- * "tv" points to the (first) list item value
- * "li" points to the (first) list item
- * "range", "n1", "n2" and "empty2" indicate what items are used.
+ * "name" points to the (expanded) variable name.
+ * "exp_name" NULL or non-NULL, to be freed later.
+ * "tv" points to the (first) list item value
+ * "li" points to the (first) list item
+ * "range", "n1", "n2" and "empty2" indicate what items are used.
* For an existing Dict item:
- * "name" points to the (expanded) variable name.
- * "exp_name" NULL or non-NULL, to be freed later.
- * "tv" points to the dict item value
- * "newkey" is NULL
+ * "name" points to the (expanded) variable name.
+ * "exp_name" NULL or non-NULL, to be freed later.
+ * "tv" points to the dict item value
+ * "newkey" is NULL
* For a non-existing Dict item:
- * "name" points to the (expanded) variable name.
- * "exp_name" NULL or non-NULL, to be freed later.
- * "tv" points to the Dictionary typval_T
- * "newkey" is the key for the new item.
+ * "name" points to the (expanded) variable name.
+ * "exp_name" NULL or non-NULL, to be freed later.
+ * "tv" points to the Dictionary typval_T
+ * "newkey" is the key for the new item.
*/
typedef struct lval_S {
- const char *ll_name; ///< Start of variable name (can be NULL).
- size_t ll_name_len; ///< Length of the .ll_name.
- char *ll_exp_name; ///< NULL or expanded name in allocated memory.
- typval_T *ll_tv; ///< Typeval of item being used. If "newkey"
- ///< isn't NULL it's the Dict to which to add the item.
- listitem_T *ll_li; ///< The list item or NULL.
- list_T *ll_list; ///< The list or NULL.
- bool ll_range; ///< true when a [i:j] range was used.
- bool ll_empty2; ///< Second index is empty: [i:].
- long ll_n1; ///< First index for list.
- long ll_n2; ///< Second index for list range.
- dict_T *ll_dict; ///< The Dictionary or NULL.
- dictitem_T *ll_di; ///< The dictitem or NULL.
- char_u *ll_newkey; ///< New key for Dict in allocated memory or NULL.
- blob_T *ll_blob; ///< The Blob or NULL.
+ const char *ll_name; ///< Start of variable name (can be NULL).
+ size_t ll_name_len; ///< Length of the .ll_name.
+ char *ll_exp_name; ///< NULL or expanded name in allocated memory.
+ typval_T *ll_tv; ///< Typeval of item being used. If "newkey"
+ ///< isn't NULL it's the Dict to which to add the item.
+ listitem_T *ll_li; ///< The list item or NULL.
+ list_T *ll_list; ///< The list or NULL.
+ bool ll_range; ///< true when a [i:j] range was used.
+ bool ll_empty2; ///< Second index is empty: [i:].
+ long ll_n1; ///< First index for list.
+ long ll_n2; ///< Second index for list range.
+ dict_T *ll_dict; ///< The Dictionary or NULL.
+ dictitem_T *ll_di; ///< The dictitem or NULL.
+ char_u *ll_newkey; ///< New key for Dict in allocated memory or NULL.
+ blob_T *ll_blob; ///< The Blob or NULL.
} lval_T;
/// enum used by var_flavour()
@@ -75,100 +75,100 @@ typedef enum {
/// Defines for Vim variables
typedef enum {
- VV_COUNT,
- VV_COUNT1,
- VV_PREVCOUNT,
- VV_ERRMSG,
- VV_WARNINGMSG,
- VV_STATUSMSG,
- VV_SHELL_ERROR,
- VV_THIS_SESSION,
- VV_VERSION,
- VV_LNUM,
- VV_TERMRESPONSE,
- VV_FNAME,
- VV_LANG,
- VV_LC_TIME,
- VV_CTYPE,
- VV_CC_FROM,
- VV_CC_TO,
- VV_FNAME_IN,
- VV_FNAME_OUT,
- VV_FNAME_NEW,
- VV_FNAME_DIFF,
- VV_CMDARG,
- VV_FOLDSTART,
- VV_FOLDEND,
- VV_FOLDDASHES,
- VV_FOLDLEVEL,
- VV_PROGNAME,
- VV_SEND_SERVER,
- VV_DYING,
- VV_EXCEPTION,
- VV_THROWPOINT,
- VV_REG,
- VV_CMDBANG,
- VV_INSERTMODE,
- VV_VAL,
- VV_KEY,
- VV_PROFILING,
- VV_FCS_REASON,
- VV_FCS_CHOICE,
- VV_BEVAL_BUFNR,
- VV_BEVAL_WINNR,
- VV_BEVAL_WINID,
- VV_BEVAL_LNUM,
- VV_BEVAL_COL,
- VV_BEVAL_TEXT,
- VV_SCROLLSTART,
- VV_SWAPNAME,
- VV_SWAPCHOICE,
- VV_SWAPCOMMAND,
- VV_CHAR,
- VV_MOUSE_WIN,
- VV_MOUSE_WINID,
- VV_MOUSE_LNUM,
- VV_MOUSE_COL,
- VV_OP,
- VV_SEARCHFORWARD,
- VV_HLSEARCH,
- VV_OLDFILES,
- VV_WINDOWID,
- VV_PROGPATH,
- VV_COMPLETED_ITEM,
- VV_OPTION_NEW,
- VV_OPTION_OLD,
- VV_OPTION_TYPE,
- VV_ERRORS,
- VV_FALSE,
- VV_TRUE,
- VV_NULL,
- VV_NUMBERMAX,
- VV_NUMBERMIN,
- VV_NUMBERSIZE,
- VV_VIM_DID_ENTER,
- VV_TESTING,
- VV_TYPE_NUMBER,
- VV_TYPE_STRING,
- VV_TYPE_FUNC,
- VV_TYPE_LIST,
- VV_TYPE_DICT,
- VV_TYPE_FLOAT,
- VV_TYPE_BOOL,
- VV_TYPE_BLOB,
- VV_EVENT,
- VV_ECHOSPACE,
- VV_ARGV,
- VV_COLLATE,
- VV_EXITING,
- // Neovim
- VV_STDERR,
- VV_MSGPACK_TYPES,
- VV__NULL_STRING, // String with NULL value. For test purposes only.
- VV__NULL_LIST, // List with NULL value. For test purposes only.
- VV__NULL_DICT, // Dictionary with NULL value. For test purposes only.
- VV__NULL_BLOB, // Blob with NULL value. For test purposes only.
- VV_LUA,
+ VV_COUNT,
+ VV_COUNT1,
+ VV_PREVCOUNT,
+ VV_ERRMSG,
+ VV_WARNINGMSG,
+ VV_STATUSMSG,
+ VV_SHELL_ERROR,
+ VV_THIS_SESSION,
+ VV_VERSION,
+ VV_LNUM,
+ VV_TERMRESPONSE,
+ VV_FNAME,
+ VV_LANG,
+ VV_LC_TIME,
+ VV_CTYPE,
+ VV_CC_FROM,
+ VV_CC_TO,
+ VV_FNAME_IN,
+ VV_FNAME_OUT,
+ VV_FNAME_NEW,
+ VV_FNAME_DIFF,
+ VV_CMDARG,
+ VV_FOLDSTART,
+ VV_FOLDEND,
+ VV_FOLDDASHES,
+ VV_FOLDLEVEL,
+ VV_PROGNAME,
+ VV_SEND_SERVER,
+ VV_DYING,
+ VV_EXCEPTION,
+ VV_THROWPOINT,
+ VV_REG,
+ VV_CMDBANG,
+ VV_INSERTMODE,
+ VV_VAL,
+ VV_KEY,
+ VV_PROFILING,
+ VV_FCS_REASON,
+ VV_FCS_CHOICE,
+ VV_BEVAL_BUFNR,
+ VV_BEVAL_WINNR,
+ VV_BEVAL_WINID,
+ VV_BEVAL_LNUM,
+ VV_BEVAL_COL,
+ VV_BEVAL_TEXT,
+ VV_SCROLLSTART,
+ VV_SWAPNAME,
+ VV_SWAPCHOICE,
+ VV_SWAPCOMMAND,
+ VV_CHAR,
+ VV_MOUSE_WIN,
+ VV_MOUSE_WINID,
+ VV_MOUSE_LNUM,
+ VV_MOUSE_COL,
+ VV_OP,
+ VV_SEARCHFORWARD,
+ VV_HLSEARCH,
+ VV_OLDFILES,
+ VV_WINDOWID,
+ VV_PROGPATH,
+ VV_COMPLETED_ITEM,
+ VV_OPTION_NEW,
+ VV_OPTION_OLD,
+ VV_OPTION_TYPE,
+ VV_ERRORS,
+ VV_FALSE,
+ VV_TRUE,
+ VV_NULL,
+ VV_NUMBERMAX,
+ VV_NUMBERMIN,
+ VV_NUMBERSIZE,
+ VV_VIM_DID_ENTER,
+ VV_TESTING,
+ VV_TYPE_NUMBER,
+ VV_TYPE_STRING,
+ VV_TYPE_FUNC,
+ VV_TYPE_LIST,
+ VV_TYPE_DICT,
+ VV_TYPE_FLOAT,
+ VV_TYPE_BOOL,
+ VV_TYPE_BLOB,
+ VV_EVENT,
+ VV_ECHOSPACE,
+ VV_ARGV,
+ VV_COLLATE,
+ VV_EXITING,
+ // Neovim
+ VV_STDERR,
+ VV_MSGPACK_TYPES,
+ VV__NULL_STRING, // String with NULL value. For test purposes only.
+ VV__NULL_LIST, // List with NULL value. For test purposes only.
+ VV__NULL_DICT, // Dictionary with NULL value. For test purposes only.
+ VV__NULL_BLOB, // Blob with NULL value. For test purposes only.
+ VV_LUA,
} VimVarIndex;
/// All recognized msgpack types
@@ -208,7 +208,7 @@ typedef enum {
} GetLvalFlags;
/// flags for find_name_end()
-#define FNE_INCL_BR 1 /* find_name_end(): include [] in name */
+#define FNE_INCL_BR 1 // find_name_end(): include [] in name
#define FNE_CHECK_START 2 /* find_name_end(): check name starts with
valid character */
diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua
index c6ac27b269..70aa2bb1f8 100644
--- a/src/nvim/eval.lua
+++ b/src/nvim/eval.lua
@@ -102,44 +102,44 @@ return {
diff_hlID={args=2, base=1},
empty={args=1, base=1},
environ={},
- escape={args=2},
+ escape={args=2, base=1},
eval={args=1, base=1},
eventhandler={},
- executable={args=1},
- execute={args={1, 2}},
- exepath={args=1},
- exists={args=1},
+ executable={args=1, base=1},
+ execute={args={1, 2}, base=1},
+ exepath={args=1, base=1},
+ exists={args=1, base=1},
exp={args=1, base=1, func="float_op_wrapper", data="&exp"},
- expand={args={1, 3}},
- expandcmd={args=1},
+ expand={args={1, 3}, base=1},
+ expandcmd={args=1, base=1},
extend={args={2, 3}, base=1},
- feedkeys={args={1, 2}},
- file_readable={args=1, func='f_filereadable'}, -- obsolete
- filereadable={args=1},
- filewritable={args=1},
+ feedkeys={args={1, 2}, base=1},
+ file_readable={args=1, base=1, func='f_filereadable'}, -- obsolete
+ filereadable={args=1, base=1},
+ filewritable={args=1, base=1},
filter={args=2, base=1},
- finddir={args={1, 3}},
- findfile={args={1, 3}},
+ finddir={args={1, 3}, base=1},
+ findfile={args={1, 3}, base=1},
flatten={args={1, 2}},
float2nr={args=1, base=1},
floor={args=1, base=1, func="float_op_wrapper", data="&floor"},
fmod={args=2, base=1},
- fnameescape={args=1},
- fnamemodify={args=2},
- foldclosed={args=1},
- foldclosedend={args=1},
- foldlevel={args=1},
+ fnameescape={args=1, base=1},
+ fnamemodify={args=2, base=1},
+ foldclosed={args=1, base=1},
+ foldclosedend={args=1, base=1},
+ foldlevel={args=1, base=1},
foldtext={},
- foldtextresult={args=1},
+ foldtextresult={args=1, base=1},
foreground={},
- funcref={args={1, 3}},
- ['function']={args={1, 3}},
+ funcref={args={1, 3}, base=1},
+ ['function']={args={1, 3}, base=1},
garbagecollect={args={0, 1}},
get={args={2, 3}, base=1},
getbufinfo={args={0, 1}},
- getbufline={args={2, 3}},
- getbufvar={args={2, 3}},
- getchangelist={args={1, 1}},
+ getbufline={args={2, 3}, base=1},
+ getbufvar={args={2, 3}, base=1},
+ getchangelist={args={0, 1}, base=1},
getchar={args={0, 1}},
getcharmod={},
getcharsearch={},
@@ -148,67 +148,67 @@ return {
getcmdpos={},
getcmdtype={},
getcmdwintype={},
- getcompletion={args={2, 3}},
+ getcompletion={args={2, 3}, base=1},
getcurpos={},
- getcwd={args={0,2}},
- getenv={args={1}},
+ getcwd={args={0, 2}, base=1},
+ getenv={args={1}, base=1},
getfontname={args={0, 1}},
- getfperm={args=1},
- getfsize={args=1},
- getftime={args=1},
- getftype={args=1},
- getjumplist={args={0, 2}},
- getline={args={1, 2}},
+ getfperm={args=1, base=1},
+ getfsize={args=1, base=1},
+ getftime={args=1, base=1},
+ getftype={args=1, base=1},
+ getjumplist={args={0, 2}, base=1},
+ getline={args={1, 2}, base=1},
getloclist={args={1, 2}},
getmarklist={args={0, 1}},
getmatches={args={0, 1}},
getmousepos={},
getpid={},
- getpos={args=1},
+ getpos={args=1, base=1},
getqflist={args={0, 1}},
- getreg={args={0, 3}},
+ getreg={args={0, 3}, base=1},
getreginfo={args={0, 1}, base=1},
- getregtype={args={0, 1}},
- gettabinfo={args={0, 1}},
- gettabvar={args={2, 3}},
- gettabwinvar={args={3, 4}},
- gettagstack={args={0, 1}},
- getwininfo={args={0, 1}},
- getwinpos={args={0, 1}},
+ getregtype={args={0, 1}, base=1},
+ gettabinfo={args={0, 1}, base=1},
+ gettabvar={args={2, 3}, base=1},
+ gettabwinvar={args={3, 4}, base=1},
+ gettagstack={args={0, 1}, base=1},
+ getwininfo={args={0, 1}, base=1},
+ getwinpos={args={0, 1}, base=1},
getwinposx={},
getwinposy={},
- getwinvar={args={2, 3}},
- glob={args={1, 4}},
- glob2regpat={args=1},
- globpath={args={2, 5}},
+ getwinvar={args={2, 3}, base=1},
+ glob={args={1, 4}, base=1},
+ glob2regpat={args=1, base=1},
+ globpath={args={2, 5}, base=2},
has={args=1},
has_key={args=2, base=1},
- haslocaldir={args={0,2}},
- hasmapto={args={1, 3}},
- highlightID={args=1, func='f_hlID'}, -- obsolete
- highlight_exists={args=1, func='f_hlexists'}, -- obsolete
- histadd={args=2},
- histdel={args={1, 2}},
- histget={args={1, 2}},
- histnr={args=1},
- hlID={args=1},
- hlexists={args=1},
+ haslocaldir={args={0, 2}, base=1},
+ hasmapto={args={1, 3}, base=1},
+ highlightID={args=1, base=1, func='f_hlID'}, -- obsolete
+ highlight_exists={args=1, base=1, func='f_hlexists'}, -- obsolete
+ histadd={args=2, base=2},
+ histdel={args={1, 2}, base=1},
+ histget={args={1, 2}, base=1},
+ histnr={args=1, base=1},
+ hlID={args=1, base=1},
+ hlexists={args=1, base=1},
hostname={},
- iconv={args=3},
- indent={args=1},
+ iconv={args=3, base=1},
+ indent={args=1, base=1},
index={args={2, 4}, base=1},
- input={args={1, 3}},
- inputdialog={args={1, 3}},
- inputlist={args=1},
+ input={args={1, 3}, base=1},
+ inputdialog={args={1, 3}, base=1},
+ inputlist={args=1, base=1},
inputrestore={},
inputsave={},
- inputsecret={args={1, 2}},
+ inputsecret={args={1, 2}, base=1},
insert={args={2, 3}, base=1},
interrupt={args=0},
invert={args=1, base=1},
- isdirectory={args=1},
+ isdirectory={args=1, base=1},
isinf={args=1, base=1},
- islocked={args=1},
+ islocked={args=1, base=1},
isnan={args=1, base=1},
id={args=1},
items={args=1, base=1},
@@ -220,76 +220,76 @@ return {
jobstop={args=1},
jobwait={args={1, 2}},
join={args={1, 2}, base=1},
- json_decode={args=1},
- json_encode={args=1},
+ json_decode={args=1, base=1},
+ json_encode={args=1, base=1},
keys={args=1, base=1},
last_buffer_nr={}, -- obsolete
len={args=1, base=1},
- libcall={args=3},
- libcallnr={args=3},
- line={args={1, 2}},
- line2byte={args=1},
- lispindent={args=1},
- list2str={args={1, 2}},
+ libcall={args=3, base=3},
+ libcallnr={args=3, base=3},
+ line={args={1, 2}, base=1},
+ line2byte={args=1, base=1},
+ lispindent={args=1, base=1},
+ list2str={args={1, 2}, base=1},
localtime={},
log={args=1, base=1, func="float_op_wrapper", data="&log"},
log10={args=1, base=1, func="float_op_wrapper", data="&log10"},
- luaeval={args={1, 2}},
+ luaeval={args={1, 2}, base=1},
map={args=2, base=1},
- maparg={args={1, 4}},
- mapcheck={args={1, 3}},
- match={args={2, 4}},
- matchadd={args={2, 5}},
- matchaddpos={args={2, 5}},
- matcharg={args=1},
- matchdelete={args={1, 2}},
- matchend={args={2, 4}},
- matchlist={args={2, 4}},
- matchstr={args={2, 4}},
- matchstrpos={args={2,4}},
+ maparg={args={1, 4}, base=1},
+ mapcheck={args={1, 3}, base=1},
+ match={args={2, 4}, base=1},
+ matchadd={args={2, 5}, base=1},
+ matchaddpos={args={2, 5}, base=1},
+ matcharg={args=1, base=1},
+ matchdelete={args={1, 2}, base=1},
+ matchend={args={2, 4}, base=1},
+ matchlist={args={2, 4}, base=1},
+ matchstr={args={2, 4}, base=1},
+ matchstrpos={args={2,4}, base=1},
max={args=1, base=1},
menu_get={args={1, 2}},
min={args=1, base=1},
- mkdir={args={1, 3}},
- mode={args={0, 1}},
+ mkdir={args={1, 3}, base=1},
+ mode={args={0, 1}, base=1},
msgpackdump={args={1, 2}},
msgpackparse={args=1},
- nextnonblank={args=1},
- nr2char={args={1, 2}},
+ nextnonblank={args=1, base=1},
+ nr2char={args={1, 2}, base=1},
['or']={args=2, base=1},
- pathshorten={args=1},
+ pathshorten={args=1, base=1},
pow={args=2, base=1},
- prevnonblank={args=1},
+ prevnonblank={args=1, base=1},
printf={args=varargs(1), base=2},
prompt_getprompt={args=1},
- prompt_setcallback={args={2, 2}},
- prompt_setinterrupt={args={2, 2}},
- prompt_setprompt={args={2, 2}},
+ prompt_setcallback={args={2, 2}, base=1},
+ prompt_setinterrupt={args={2, 2}, base=1},
+ prompt_setprompt={args={2, 2}, base=1},
pum_getpos={},
pumvisible={},
- py3eval={args=1},
- pyeval={args=1},
- pyxeval={args=1},
- perleval={args=1},
- range={args={1, 3}},
- readdir={args={1, 2}},
- readfile={args={1, 3}},
+ py3eval={args=1, base=1},
+ pyeval={args=1, base=1},
+ pyxeval={args=1, base=1},
+ perleval={args=1, base=1},
+ range={args={1, 3}, base=1},
+ readdir={args={1, 2}, base=1},
+ readfile={args={1, 3}, base=1},
reg_executing={},
reg_recording={},
- reltime={args={0, 2}},
- reltimefloat={args=1},
- reltimestr={args=1},
+ reltime={args={0, 2}, base=1},
+ reltimefloat={args=1, base=1},
+ reltimestr={args=1, base=1},
remove={args={2, 3}, base=1},
- rename={args=2},
+ rename={args=2, base=1},
['repeat']={args=2, base=1},
- resolve={args=1},
+ resolve={args=1, base=1},
reverse={args=1, base=1},
round={args=1, base=1, func="float_op_wrapper", data="&round"},
rpcnotify={args=varargs(2)},
rpcrequest={args=varargs(2)},
rpcstart={args={1, 2}},
rpcstop={args=1},
- rubyeval={args=1},
+ rubyeval={args=1, base=1},
screenattr={args=2},
screenchar={args=2},
screenchars={args=2},
@@ -311,7 +311,7 @@ return {
setcharsearch={args=1},
setcmdpos={args=1},
setenv={args=2},
- setfperm={args=2},
+ setfperm={args=2, base=1},
setline={args=2},
setloclist={args={2, 4}},
setmatches={args={1, 2}},
diff --git a/src/nvim/eval/decode.h b/src/nvim/eval/decode.h
index 77fc4c78c2..f1be5a1f69 100644
--- a/src/nvim/eval/decode.h
+++ b/src/nvim/eval/decode.h
@@ -1,9 +1,8 @@
#ifndef NVIM_EVAL_DECODE_H
#define NVIM_EVAL_DECODE_H
-#include <stddef.h>
-
#include <msgpack.h>
+#include <stddef.h>
#include "nvim/eval/typval.h"
#include "nvim/globals.h"
diff --git a/src/nvim/eval/encode.c b/src/nvim/eval/encode.c
index 5ef0045659..2d4d9fdea9 100644
--- a/src/nvim/eval/encode.c
+++ b/src/nvim/eval/encode.c
@@ -29,7 +29,6 @@
#include "nvim/message.h"
#include "nvim/vim.h" // For _()
-#define ga_concat(a, b) ga_concat(a, (char_u *)b)
#define utf_ptr2char(b) utf_ptr2char((char_u *)b)
#define utf_ptr2len(b) ((size_t)utf_ptr2len((char_u *)b))
#define utf_char2len(b) ((size_t)utf_char2len(b))
@@ -142,7 +141,7 @@ static int conv_error(const char *const msg, const MPConvStack *const mpstack,
char *const key = encode_tv2string(&key_tv, NULL);
vim_snprintf((char *)IObuff, IOSIZE, key_msg, key);
xfree(key);
- ga_concat(&msg_ga, IObuff);
+ ga_concat(&msg_ga, (char *)IObuff);
break;
}
case kMPConvPairs:
@@ -163,7 +162,7 @@ static int conv_error(const char *const msg, const MPConvStack *const mpstack,
|| (TV_LIST_ITEM_TV(li)->v_type != VAR_LIST
&& tv_list_len(TV_LIST_ITEM_TV(li)->vval.v_list) <= 0)) {
vim_snprintf((char *)IObuff, IOSIZE, idx_msg, idx);
- ga_concat(&msg_ga, IObuff);
+ ga_concat(&msg_ga, (char *)IObuff);
} else {
assert(li != NULL);
listitem_T *const first_item =
@@ -173,7 +172,7 @@ static int conv_error(const char *const msg, const MPConvStack *const mpstack,
char *const key = encode_tv2echo(&key_tv, NULL);
vim_snprintf((char *)IObuff, IOSIZE, key_pair_msg, key, idx);
xfree(key);
- ga_concat(&msg_ga, IObuff);
+ ga_concat(&msg_ga, (char *)IObuff);
}
break;
}
@@ -193,7 +192,7 @@ static int conv_error(const char *const msg, const MPConvStack *const mpstack,
case kMPConvPartialList: {
const int idx = (int)(v.data.a.arg - v.data.a.argv) - 1;
vim_snprintf((char *)IObuff, IOSIZE, partial_arg_i_msg, idx);
- ga_concat(&msg_ga, IObuff);
+ ga_concat(&msg_ga, (char *)IObuff);
break;
}
}
@@ -355,20 +354,20 @@ int encode_read_from_list(ListReaderState *const state, char *const buf, const s
const float_T flt_ = (flt); \
switch (xfpclassify(flt_)) { \
case FP_NAN: { \
- ga_concat(gap, (char_u *)"str2float('nan')"); \
+ ga_concat(gap, "str2float('nan')"); \
break; \
} \
case FP_INFINITE: { \
if (flt_ < 0) { \
ga_append(gap, '-'); \
} \
- ga_concat(gap, (char_u *)"str2float('inf')"); \
+ ga_concat(gap, "str2float('inf')"); \
break; \
} \
default: { \
char numbuf[NUMBUFLEN]; \
vim_snprintf(numbuf, ARRAY_SIZE(numbuf), "%g", flt_); \
- ga_concat(gap, (char_u *)numbuf); \
+ ga_concat(gap, numbuf); \
} \
} \
} while (0)
@@ -569,7 +568,7 @@ int encode_read_from_list(ListReaderState *const state, char *const buf, const s
default: { \
char numbuf[NUMBUFLEN]; \
vim_snprintf(numbuf, ARRAY_SIZE(numbuf), "%g", flt_); \
- ga_concat(gap, (char_u *)numbuf); \
+ ga_concat(gap, numbuf); \
break; \
} \
} \
@@ -874,7 +873,7 @@ char *encode_tv2echo(typval_T *tv, size_t *len)
ga_init(&ga, (int)sizeof(char), 80);
if (tv->v_type == VAR_STRING || tv->v_type == VAR_FUNC) {
if (tv->vval.v_string != NULL) {
- ga_concat(&ga, tv->vval.v_string);
+ ga_concat(&ga, (char *)tv->vval.v_string);
}
} else {
const int eve_ret = encode_vim_to_echo(&ga, tv, N_(":echo argument"));
diff --git a/src/nvim/eval/encode.h b/src/nvim/eval/encode.h
index 596bb49ae0..8755ff48ac 100644
--- a/src/nvim/eval/encode.h
+++ b/src/nvim/eval/encode.h
@@ -1,9 +1,8 @@
#ifndef NVIM_EVAL_ENCODE_H
#define NVIM_EVAL_ENCODE_H
-#include <stddef.h>
-
#include <msgpack.h>
+#include <stddef.h>
#include "nvim/eval.h"
#include "nvim/garray.h"
@@ -49,8 +48,7 @@ static inline ListReaderState encode_init_lrstate(const list_T *const list)
.offset = 0,
.li_length = (TV_LIST_ITEM_TV(tv_list_first(list))->vval.v_string == NULL
? 0
- : STRLEN(TV_LIST_ITEM_TV(
- tv_list_first(list))->vval.v_string)),
+ : STRLEN(TV_LIST_ITEM_TV(tv_list_first(list))->vval.v_string)),
};
}
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index 50e0b0b258..da129c1170 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -491,7 +491,7 @@ static void f_assert_report(typval_T *argvars, typval_T *rettv, FunPtr fptr)
garray_T ga;
prepare_assert_error(&ga);
- ga_concat(&ga, (const char_u *)tv_get_string(&argvars[0]));
+ ga_concat(&ga, tv_get_string(&argvars[0]));
assert_error(&ga);
ga_clear(&ga);
rettv->vval.v_number = 1;
@@ -3088,10 +3088,16 @@ f_getbufvar_end:
static void f_getchangelist(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
tv_list_alloc_ret(rettv, 2);
- vim_ignored = tv_get_number(&argvars[0]); // issue errmsg if type error
- emsg_off++;
- const buf_T *const buf = tv_get_buf(&argvars[0], false);
- emsg_off--;
+
+ const buf_T *buf;
+ if (argvars[0].v_type == VAR_UNKNOWN) {
+ buf = curbuf;
+ } else {
+ vim_ignored = tv_get_number(&argvars[0]); // issue errmsg if type error
+ emsg_off++;
+ buf = tv_get_buf(&argvars[0], false);
+ emsg_off--;
+ }
if (buf == NULL) {
return;
}
@@ -3741,7 +3747,7 @@ static void f_getmatches(typval_T *argvars, typval_T *rettv, FunPtr fptr)
if (cur->conceal_char) {
char buf[MB_MAXBYTES + 1];
- buf[utf_char2bytes((int)cur->conceal_char, (char_u *)buf)] = NUL;
+ buf[utf_char2bytes(cur->conceal_char, (char_u *)buf)] = NUL;
tv_dict_add_str(dict, S_LEN("conceal"), buf);
}
@@ -4356,7 +4362,7 @@ static void f_globpath(typval_T *argvars, typval_T *rettv, FunPtr fptr)
globpath((char_u *)tv_get_string(&argvars[0]), (char_u *)file, &ga, flags);
if (rettv->v_type == VAR_STRING) {
- rettv->vval.v_string = ga_concat_strings_sep(&ga, "\n");
+ rettv->vval.v_string = (char_u *)ga_concat_strings_sep(&ga, "\n");
} else {
tv_list_alloc_ret(rettv, ga.ga_len);
for (int i = 0; i < ga.ga_len; i++) {
@@ -5230,7 +5236,7 @@ static void f_jobpid(typval_T *argvars, typval_T *rettv, FunPtr fptr)
return;
}
- Process *proc = (Process *)&data->stream.proc;
+ Process *proc = &data->stream.proc;
rettv->vval.v_number = proc->pid;
}
@@ -5528,7 +5534,7 @@ static void f_jobstop(typval_T *argvars, typval_T *rettv, FunPtr fptr)
// Ignore return code, but show error later.
(void)channel_close(data->id, kChannelPartRpc, &error);
}
- process_stop((Process *)&data->stream.proc);
+ process_stop(&data->stream.proc);
rettv->vval.v_number = 1;
if (error) {
EMSG(error);
@@ -5903,7 +5909,7 @@ static void f_list2str(typval_T *argvars, typval_T *rettv, FunPtr fptr)
TV_LIST_ITER_CONST(l, li, {
buf[utf_char2bytes(tv_get_number(TV_LIST_ITEM_TV(li)), buf)] = NUL;
- ga_concat(&ga, buf);
+ ga_concat(&ga, (char *)buf);
});
ga_append(&ga, NUL);
@@ -6135,7 +6141,7 @@ static void find_some_match(typval_T *const argvars, typval_T *const rettv,
}
}
- match = vim_regexec_nl(&regmatch, str, (colnr_T)startcol);
+ match = vim_regexec_nl(&regmatch, str, startcol);
if (match && --nth <= 0) {
break;
@@ -6346,7 +6352,7 @@ static void f_matcharg(typval_T *argvars, typval_T *rettv, FunPtr fptr)
: 0));
if (id >= 1 && id <= 3) {
- matchitem_T *const m = (matchitem_T *)get_match(curwin, id);
+ matchitem_T *const m = get_match(curwin, id);
if (m != NULL) {
tv_list_append_string(rettv->vval.v_list,
@@ -6993,7 +6999,7 @@ static void f_range(typval_T *argvars, typval_T *rettv, FunPtr fptr)
} else {
tv_list_alloc_ret(rettv, (end - start) / stride);
for (i = start; stride > 0 ? i <= end : i >= end; i += stride) {
- tv_list_append_number(rettv->vval.v_list, (varnumber_T)i);
+ tv_list_append_number(rettv->vval.v_list, i);
}
}
}
@@ -7296,7 +7302,7 @@ static void f_getreginfo(typval_T *argvars, typval_T *rettv, FunPtr fptr)
if (list == NULL) {
return;
}
- tv_dict_add_list(dict, S_LEN("regcontents"), list);
+ (void)tv_dict_add_list(dict, S_LEN("regcontents"), list);
char buf[NUMBUFLEN + 2];
buf[0] = NUL;
@@ -7315,14 +7321,15 @@ static void f_getreginfo(typval_T *argvars, typval_T *rettv, FunPtr fptr)
case kMTUnknown:
abort();
}
- tv_dict_add_str(dict, S_LEN("regtype"), buf);
+ (void)tv_dict_add_str(dict, S_LEN("regtype"), buf);
buf[0] = get_register_name(get_unname_register());
buf[1] = NUL;
if (regname == '"') {
- tv_dict_add_str(dict, S_LEN("points_to"), buf);
+ (void)tv_dict_add_str(dict, S_LEN("points_to"), buf);
} else {
- tv_dict_add_bool(dict, S_LEN("isunnamed"), regname == buf[0] ? kBoolVarTrue : kBoolVarFalse);
+ (void)tv_dict_add_bool(dict, S_LEN("isunnamed"),
+ regname == buf[0] ? kBoolVarTrue : kBoolVarFalse);
}
}
@@ -12005,10 +12012,10 @@ static void f_winrestcmd(typval_T *argvars, typval_T *rettv, FunPtr fptr)
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
snprintf((char *)buf, sizeof(buf), "%dresize %d|", winnr,
wp->w_height);
- ga_concat(&ga, buf);
+ ga_concat(&ga, (char *)buf);
snprintf((char *)buf, sizeof(buf), "vert %dresize %d|", winnr,
wp->w_width);
- ga_concat(&ga, buf);
+ ga_concat(&ga, (char *)buf);
winnr++;
}
}
diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c
index 4c8789964f..6300ce6150 100644
--- a/src/nvim/eval/typval.c
+++ b/src/nvim/eval/typval.c
@@ -789,12 +789,12 @@ static int list_join_inner(garray_T *const gap, list_T *const l, const char *con
if (first) {
first = false;
} else {
- ga_concat(gap, (const char_u *)sep);
+ ga_concat(gap, sep);
}
const Join *const p = ((const Join *)join_gap->ga_data) + i;
if (p->s != NULL) {
- ga_concat(gap, p->s);
+ ga_concat(gap, (char *)p->s);
}
line_breakcheck();
}
@@ -2861,7 +2861,7 @@ bool tv_equal(typval_T *const tv1, typval_T *const tv2, const bool ic, const boo
char buf2[NUMBUFLEN];
const char *s1 = tv_get_string_buf(tv1, buf1);
const char *s2 = tv_get_string_buf(tv2, buf2);
- return mb_strcmp_ic((bool)ic, s1, s2) == 0;
+ return mb_strcmp_ic(ic, s1, s2) == 0;
}
case VAR_BOOL:
return tv1->vval.v_bool == tv2->vval.v_bool;
diff --git a/src/nvim/eval/typval.h b/src/nvim/eval/typval.h
index 5aecaccee9..a28feffd0b 100644
--- a/src/nvim/eval/typval.h
+++ b/src/nvim/eval/typval.h
@@ -1,23 +1,23 @@
#ifndef NVIM_EVAL_TYPVAL_H
#define NVIM_EVAL_TYPVAL_H
+#include <assert.h>
#include <inttypes.h>
+#include <stdbool.h>
#include <stddef.h>
#include <string.h>
-#include <stdbool.h>
-#include <assert.h>
-#include "nvim/types.h"
-#include "nvim/hashtab.h"
-#include "nvim/garray.h"
-#include "nvim/mbyte.h"
#include "nvim/func_attr.h"
-#include "nvim/lib/queue.h"
-#include "nvim/profile.h" // for proftime_T
-#include "nvim/pos.h" // for linenr_T
+#include "nvim/garray.h"
#include "nvim/gettext.h"
-#include "nvim/message.h"
+#include "nvim/hashtab.h"
+#include "nvim/lib/queue.h"
#include "nvim/macros.h"
+#include "nvim/mbyte.h"
+#include "nvim/message.h"
+#include "nvim/pos.h" // for linenr_T
+#include "nvim/profile.h" // for proftime_T
+#include "nvim/types.h"
#ifdef LOG_LIST_ACTIONS
# include "nvim/memory.h"
#endif
@@ -156,8 +156,8 @@ typedef enum {
typedef struct listitem_S listitem_T;
struct listitem_S {
- listitem_T *li_next; ///< Next item in list.
- listitem_T *li_prev; ///< Previous item in list.
+ listitem_T *li_next; ///< Next item in list.
+ listitem_T *li_prev; ///< Previous item in list.
typval_T li_tv; ///< Item value.
};
@@ -195,25 +195,25 @@ typedef struct {
} staticList10_T;
#define TV_LIST_STATIC10_INIT { \
- .sl_list = { \
- .lv_first = NULL, \
- .lv_last = NULL, \
- .lv_refcount = 0, \
- .lv_len = 0, \
- .lv_watch = NULL, \
- .lv_idx_item = NULL, \
- .lv_lock = VAR_FIXED, \
- .lv_used_next = NULL, \
- .lv_used_prev = NULL, \
- }, \
- }
+ .sl_list = { \
+ .lv_first = NULL, \
+ .lv_last = NULL, \
+ .lv_refcount = 0, \
+ .lv_len = 0, \
+ .lv_watch = NULL, \
+ .lv_idx_item = NULL, \
+ .lv_lock = VAR_FIXED, \
+ .lv_used_next = NULL, \
+ .lv_used_prev = NULL, \
+ }, \
+}
#define TV_DICTITEM_STRUCT(...) \
- struct { \
- typval_T di_tv; /* Structure that holds scope dictionary itself. */ \
- uint8_t di_flags; /* Flags. */ \
- char_u di_key[__VA_ARGS__]; /* Key value. */ \
- }
+ struct { \
+ typval_T di_tv; /* Structure that holds scope dictionary itself. */ \
+ uint8_t di_flags; /* Flags. */ \
+ char_u di_key[__VA_ARGS__]; /* Key value. */ \
+ }
/// Structure to hold a scope dictionary
///
@@ -321,40 +321,40 @@ struct funccall_S {
/// Structure to hold info for a user function.
struct ufunc {
- int uf_varargs; ///< variable nr of arguments
- int uf_flags;
- int uf_calls; ///< nr of active calls
- bool uf_cleared; ///< func_clear() was already called
- garray_T uf_args; ///< arguments
- garray_T uf_def_args; ///< default argument expressions
- garray_T uf_lines; ///< function lines
- int uf_profiling; ///< true when func is being profiled
- int uf_prof_initialized;
+ int uf_varargs; ///< variable nr of arguments
+ int uf_flags;
+ int uf_calls; ///< nr of active calls
+ bool uf_cleared; ///< func_clear() was already called
+ garray_T uf_args; ///< arguments
+ garray_T uf_def_args; ///< default argument expressions
+ garray_T uf_lines; ///< function lines
+ int uf_profiling; ///< true when func is being profiled
+ int uf_prof_initialized;
// Managing cfuncs
- cfunc_T uf_cb; ///< C function extension callback
+ cfunc_T uf_cb; ///< C function extension callback
cfunc_free_T uf_cb_free; ///< C function extension free callback
- void *uf_cb_state; ///< State of C function extension.
+ void *uf_cb_state; ///< State of C function extension.
// Profiling the function as a whole.
- int uf_tm_count; ///< nr of calls
- proftime_T uf_tm_total; ///< time spent in function + children
- proftime_T uf_tm_self; ///< time spent in function itself
- proftime_T uf_tm_children; ///< time spent in children this call
+ int uf_tm_count; ///< nr of calls
+ proftime_T uf_tm_total; ///< time spent in function + children
+ proftime_T uf_tm_self; ///< time spent in function itself
+ proftime_T uf_tm_children; ///< time spent in children this call
// Profiling the function per line.
- int *uf_tml_count; ///< nr of times line was executed
- proftime_T *uf_tml_total; ///< time spent in a line + children
- proftime_T *uf_tml_self; ///< time spent in a line itself
- proftime_T uf_tml_start; ///< start time for current line
- proftime_T uf_tml_children; ///< time spent in children for this line
- proftime_T uf_tml_wait; ///< start wait time for current line
- int uf_tml_idx; ///< index of line being timed; -1 if none
- int uf_tml_execed; ///< line being timed was executed
- sctx_T uf_script_ctx; ///< SCTX where function was defined,
- ///< used for s: variables
- int uf_refcount; ///< reference count, see func_name_refcount()
- funccall_T *uf_scoped; ///< l: local variables for closure
- char_u uf_name[]; ///< Name of function (actual size equals name);
- ///< can start with <SNR>123_
- ///< (<SNR> is K_SPECIAL KS_EXTRA KE_SNR)
+ int *uf_tml_count; ///< nr of times line was executed
+ proftime_T *uf_tml_total; ///< time spent in a line + children
+ proftime_T *uf_tml_self; ///< time spent in a line itself
+ proftime_T uf_tml_start; ///< start time for current line
+ proftime_T uf_tml_children; ///< time spent in children for this line
+ proftime_T uf_tml_wait; ///< start wait time for current line
+ int uf_tml_idx; ///< index of line being timed; -1 if none
+ int uf_tml_execed; ///< line being timed was executed
+ sctx_T uf_script_ctx; ///< SCTX where function was defined,
+ ///< used for s: variables
+ int uf_refcount; ///< reference count, see func_name_refcount()
+ funccall_T *uf_scoped; ///< l: local variables for closure
+ char_u uf_name[]; ///< Name of function (actual size equals name);
+ ///< can start with <SNR>123_
+ ///< (<SNR> is K_SPECIAL KS_EXTRA KE_SNR)
};
struct partial_S {
@@ -452,10 +452,8 @@ static inline void list_log(const list_T *const l,
/// @param[in] li1 List item 1.
/// @param[in] li2 List item 2, often used for integers and not list items.
/// @param[in] action Logged action.
-static inline void list_log(const list_T *const l,
- const listitem_T *const li1,
- const listitem_T *const li2,
- const char *const action)
+static inline void list_log(const list_T *const l, const listitem_T *const li1,
+ const listitem_T *const li2, const char *const action)
{
ListLog *tgt;
if (list_log_first == NULL) {
@@ -484,7 +482,7 @@ static inline void list_log(const list_T *const l,
/// Convert a hashitem pointer to a dictitem pointer
#define TV_DICT_HI2DI(hi) \
- ((dictitem_T *)((hi)->hi_key - offsetof(dictitem_T, di_key)))
+ ((dictitem_T *)((hi)->hi_key - offsetof(dictitem_T, di_key)))
static inline void tv_list_ref(list_T *const l)
REAL_FATTR_ALWAYS_INLINE;
@@ -538,8 +536,7 @@ static inline VarLockStatus tv_list_locked(const list_T *const l)
///
/// @param[out] l List to modify.
/// @param[in] lock New lock status.
-static inline void tv_list_set_lock(list_T *const l,
- const VarLockStatus lock)
+static inline void tv_list_set_lock(list_T *const l, const VarLockStatus lock)
{
if (l == NULL) {
assert(lock == VAR_FIXED);
@@ -554,8 +551,7 @@ static inline void tv_list_set_lock(list_T *const l,
///
/// @param[out] l List to modify.
/// @param[in] copyid New copyID.
-static inline void tv_list_set_copyid(list_T *const l,
- const int copyid)
+static inline void tv_list_set_copyid(list_T *const l, const int copyid)
FUNC_ATTR_NONNULL_ALL
{
l->lv_copyID = copyid;
@@ -793,10 +789,10 @@ static inline void tv_init(typval_T *const tv)
}
#define TV_INITIAL_VALUE \
- ((typval_T) { \
- .v_type = VAR_UNKNOWN, \
- .v_lock = VAR_UNLOCKED, \
- })
+ ((typval_T) { \
+ .v_type = VAR_UNKNOWN, \
+ .v_lock = VAR_UNLOCKED, \
+ })
/// Empty string
///
@@ -815,16 +811,16 @@ extern bool tv_in_free_unref_items;
/// @param li Name of the variable with current listitem_T entry.
/// @param code Cycle body.
#define _TV_LIST_ITER_MOD(modifier, l, li, code) \
- do { \
- modifier list_T *const l_ = (l); \
- list_log(l_, NULL, NULL, "iter" #modifier); \
- if (l_ != NULL) { \
- for (modifier listitem_T *li = l_->lv_first; \
- li != NULL; li = li->li_next) { \
- code \
- } \
+ do { \
+ modifier list_T *const l_ = (l); \
+ list_log(l_, NULL, NULL, "iter" #modifier); \
+ if (l_ != NULL) { \
+ for (modifier listitem_T *li = l_->lv_first; \
+ li != NULL; li = li->li_next) { \
+ code \
} \
- } while (0)
+ } \
+ } while (0)
/// Iterate over a list
///
@@ -835,7 +831,7 @@ extern bool tv_in_free_unref_items;
/// @param li Name of the variable with current listitem_T entry.
/// @param code Cycle body.
#define TV_LIST_ITER(l, li, code) \
- _TV_LIST_ITER_MOD(, l, li, code)
+ _TV_LIST_ITER_MOD(, l, li, code)
/// Iterate over a list
///
@@ -846,7 +842,7 @@ extern bool tv_in_free_unref_items;
/// @param li Name of the variable with current listitem_T entry.
/// @param code Cycle body.
#define TV_LIST_ITER_CONST(l, li, code) \
- _TV_LIST_ITER_MOD(const, l, li, code)
+ _TV_LIST_ITER_MOD(const, l, li, code)
// Below macros are macros to avoid duplicating code for functionally identical
// const and non-const function variants.
@@ -883,14 +879,14 @@ extern bool tv_in_free_unref_items;
/// @param di Name of the variable with current dictitem_T entry.
/// @param code Cycle body.
#define TV_DICT_ITER(d, di, code) \
- HASHTAB_ITER(&(d)->dv_hashtab, di##hi_, { \
+ HASHTAB_ITER(&(d)->dv_hashtab, di##hi_, { \
+ { \
+ dictitem_T *const di = TV_DICT_HI2DI(di##hi_); \
{ \
- dictitem_T *const di = TV_DICT_HI2DI(di##hi_); \
- { \
- code \
- } \
+ code \
} \
- })
+ } \
+ })
static inline bool tv_get_float_chk(const typval_T *const tv,
float_T *const ret_f)
@@ -907,8 +903,7 @@ bool emsgf(const char *const fmt, ...);
/// @param[out] ret_f Location where resulting float is stored.
///
/// @return true in case of success, false if tv is not a number or float.
-static inline bool tv_get_float_chk(const typval_T *const tv,
- float_T *const ret_f)
+static inline bool tv_get_float_chk(const typval_T *const tv, float_T *const ret_f)
{
if (tv->v_type == VAR_FLOAT) {
*ret_f = tv->vval.v_float;
diff --git a/src/nvim/eval/typval_encode.c.h b/src/nvim/eval/typval_encode.c.h
index cd1be1eecc..ece51cb046 100644
--- a/src/nvim/eval/typval_encode.c.h
+++ b/src/nvim/eval/typval_encode.c.h
@@ -240,15 +240,15 @@
///
/// This name will only be used by one of the above macros which are defined by
/// the caller. Functions defined here do not use first argument directly.
-#include <stddef.h>
-#include <inttypes.h>
#include <assert.h>
+#include <inttypes.h>
+#include <stddef.h>
-#include "nvim/lib/kvec.h"
-#include "nvim/eval/typval.h"
#include "nvim/eval/encode.h"
-#include "nvim/func_attr.h"
+#include "nvim/eval/typval.h"
#include "nvim/eval/typval_encode.h"
+#include "nvim/func_attr.h"
+#include "nvim/lib/kvec.h"
/// Dummy variable used because some macros need lvalue
///
@@ -257,12 +257,12 @@
const dict_T *const TYPVAL_ENCODE_NODICT_VAR = NULL;
static inline int _TYPVAL_ENCODE_CHECK_SELF_REFERENCE(
- TYPVAL_ENCODE_FIRST_ARG_TYPE TYPVAL_ENCODE_FIRST_ARG_NAME,
- void *const val, int *const val_copyID,
- const MPConvStack *const mpstack, const int copyID,
- const MPConvStackValType conv_type,
- const char *const objname)
- REAL_FATTR_NONNULL_ARG(2, 3, 4, 7) REAL_FATTR_WARN_UNUSED_RESULT
+ TYPVAL_ENCODE_FIRST_ARG_TYPE TYPVAL_ENCODE_FIRST_ARG_NAME,
+ void *const val, int *const val_copyID,
+ const MPConvStack *const mpstack, const int copyID,
+ const MPConvStackValType conv_type,
+ const char *const objname)
+REAL_FATTR_NONNULL_ARG(2, 3, 4, 7) REAL_FATTR_WARN_UNUSED_RESULT
REAL_FATTR_ALWAYS_INLINE;
/// Function for checking whether container references itself
@@ -280,11 +280,9 @@ static inline int _TYPVAL_ENCODE_CHECK_SELF_REFERENCE(
///
/// @return NOTDONE in case of success, what to return in case of failure.
static inline int _TYPVAL_ENCODE_CHECK_SELF_REFERENCE(
- TYPVAL_ENCODE_FIRST_ARG_TYPE TYPVAL_ENCODE_FIRST_ARG_NAME,
- void *const val, int *const val_copyID,
- const MPConvStack *const mpstack, const int copyID,
- const MPConvStackValType conv_type,
- const char *const objname)
+ TYPVAL_ENCODE_FIRST_ARG_TYPE TYPVAL_ENCODE_FIRST_ARG_NAME, void *const val, int *const val_copyID,
+ const MPConvStack *const mpstack, const int copyID, const MPConvStackValType conv_type,
+ const char *const objname)
{
if (*val_copyID == copyID) {
TYPVAL_ENCODE_CONV_RECURSE(val, conv_type);
@@ -295,11 +293,11 @@ static inline int _TYPVAL_ENCODE_CHECK_SELF_REFERENCE(
}
static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE(
- TYPVAL_ENCODE_FIRST_ARG_TYPE TYPVAL_ENCODE_FIRST_ARG_NAME,
- MPConvStack *const mpstack, MPConvStackVal *const cur_mpsv,
- typval_T *const tv, const int copyID,
- const char *const objname)
- REAL_FATTR_NONNULL_ARG(2, 4, 6) REAL_FATTR_WARN_UNUSED_RESULT;
+ TYPVAL_ENCODE_FIRST_ARG_TYPE TYPVAL_ENCODE_FIRST_ARG_NAME,
+ MPConvStack *const mpstack, MPConvStackVal *const cur_mpsv,
+ typval_T *const tv, const int copyID,
+ const char *const objname)
+REAL_FATTR_NONNULL_ARG(2, 4, 6) REAL_FATTR_WARN_UNUSED_RESULT;
/// Convert single value
///
@@ -319,42 +317,35 @@ static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE(
///
/// @return OK in case of success, FAIL in case of failure.
static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE(
- TYPVAL_ENCODE_FIRST_ARG_TYPE TYPVAL_ENCODE_FIRST_ARG_NAME,
- MPConvStack *const mpstack, MPConvStackVal *const cur_mpsv,
- typval_T *const tv, const int copyID,
- const char *const objname)
+ TYPVAL_ENCODE_FIRST_ARG_TYPE TYPVAL_ENCODE_FIRST_ARG_NAME, MPConvStack *const mpstack,
+ MPConvStackVal *const cur_mpsv, typval_T *const tv, const int copyID, const char *const objname)
{
switch (tv->v_type) {
- case VAR_STRING: {
- TYPVAL_ENCODE_CONV_STRING(tv, tv->vval.v_string, tv_strlen(tv));
- break;
- }
- case VAR_NUMBER: {
- TYPVAL_ENCODE_CONV_NUMBER(tv, tv->vval.v_number);
- break;
- }
- case VAR_FLOAT: {
- TYPVAL_ENCODE_CONV_FLOAT(tv, tv->vval.v_float);
- break;
- }
- case VAR_BLOB: {
- TYPVAL_ENCODE_CONV_BLOB(tv, tv->vval.v_blob,
- tv_blob_len(tv->vval.v_blob));
- break;
- }
- case VAR_FUNC: {
- TYPVAL_ENCODE_CONV_FUNC_START(tv, tv->vval.v_string);
- TYPVAL_ENCODE_CONV_FUNC_BEFORE_ARGS(tv, 0);
- TYPVAL_ENCODE_CONV_FUNC_BEFORE_SELF(tv, -1);
- TYPVAL_ENCODE_CONV_FUNC_END(tv);
- break;
- }
- case VAR_PARTIAL: {
- partial_T *const pt = tv->vval.v_partial;
- (void)pt;
- TYPVAL_ENCODE_CONV_FUNC_START( // -V547
- tv, (pt == NULL ? NULL : partial_name(pt)));
- _mp_push(*mpstack, ((MPConvStackVal) { // -V779
+ case VAR_STRING:
+ TYPVAL_ENCODE_CONV_STRING(tv, tv->vval.v_string, tv_strlen(tv));
+ break;
+ case VAR_NUMBER:
+ TYPVAL_ENCODE_CONV_NUMBER(tv, tv->vval.v_number);
+ break;
+ case VAR_FLOAT:
+ TYPVAL_ENCODE_CONV_FLOAT(tv, tv->vval.v_float);
+ break;
+ case VAR_BLOB:
+ TYPVAL_ENCODE_CONV_BLOB(tv, tv->vval.v_blob,
+ tv_blob_len(tv->vval.v_blob));
+ break;
+ case VAR_FUNC:
+ TYPVAL_ENCODE_CONV_FUNC_START(tv, tv->vval.v_string);
+ TYPVAL_ENCODE_CONV_FUNC_BEFORE_ARGS(tv, 0);
+ TYPVAL_ENCODE_CONV_FUNC_BEFORE_SELF(tv, -1);
+ TYPVAL_ENCODE_CONV_FUNC_END(tv);
+ break;
+ case VAR_PARTIAL: {
+ partial_T *const pt = tv->vval.v_partial;
+ (void)pt;
+ TYPVAL_ENCODE_CONV_FUNC_START( // -V547
+ tv, (pt == NULL ? NULL : partial_name(pt)));
+ _mp_push(*mpstack, ((MPConvStackVal) { // -V779
.type = kMPConvPartial,
.tv = tv,
.saved_copyID = copyID - 1,
@@ -365,19 +356,19 @@ static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE(
},
},
}));
+ break;
+ }
+ case VAR_LIST: {
+ if (tv->vval.v_list == NULL || tv_list_len(tv->vval.v_list) == 0) {
+ TYPVAL_ENCODE_CONV_EMPTY_LIST(tv);
break;
}
- case VAR_LIST: {
- if (tv->vval.v_list == NULL || tv_list_len(tv->vval.v_list) == 0) {
- TYPVAL_ENCODE_CONV_EMPTY_LIST(tv);
- break;
- }
- const int saved_copyID = tv_list_copyid(tv->vval.v_list);
- _TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE(tv->vval.v_list, lv_copyID, copyID,
- kMPConvList);
- TYPVAL_ENCODE_CONV_LIST_START(tv, tv_list_len(tv->vval.v_list));
- assert(saved_copyID != copyID);
- _mp_push(*mpstack, ((MPConvStackVal) {
+ const int saved_copyID = tv_list_copyid(tv->vval.v_list);
+ _TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE(tv->vval.v_list, lv_copyID, copyID,
+ kMPConvList);
+ TYPVAL_ENCODE_CONV_LIST_START(tv, tv_list_len(tv->vval.v_list));
+ assert(saved_copyID != copyID);
+ _mp_push(*mpstack, ((MPConvStackVal) {
.type = kMPConvList,
.tv = tv,
.saved_copyID = saved_copyID,
@@ -388,159 +379,151 @@ static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE(
},
},
}));
- TYPVAL_ENCODE_CONV_REAL_LIST_AFTER_START(tv, _mp_last(*mpstack));
+ TYPVAL_ENCODE_CONV_REAL_LIST_AFTER_START(tv, _mp_last(*mpstack));
+ break;
+ }
+ case VAR_BOOL:
+ switch (tv->vval.v_bool) {
+ case kBoolVarTrue:
+ case kBoolVarFalse:
+ TYPVAL_ENCODE_CONV_BOOL(tv, tv->vval.v_bool == kBoolVarTrue);
break;
}
- case VAR_BOOL: {
- switch (tv->vval.v_bool) {
- case kBoolVarTrue:
- case kBoolVarFalse: {
- TYPVAL_ENCODE_CONV_BOOL(tv, tv->vval.v_bool == kBoolVarTrue);
- break;
- }
- }
+ break;
+ case VAR_SPECIAL:
+ switch (tv->vval.v_special) {
+ case kSpecialVarNull:
+ TYPVAL_ENCODE_CONV_NIL(tv); // -V1037
break;
}
- case VAR_SPECIAL: {
- switch (tv->vval.v_special) {
- case kSpecialVarNull: {
- TYPVAL_ENCODE_CONV_NIL(tv); // -V1037
+ break;
+ case VAR_DICT: {
+ if (tv->vval.v_dict == NULL
+ || tv->vval.v_dict->dv_hashtab.ht_used == 0) {
+ TYPVAL_ENCODE_CONV_EMPTY_DICT(tv, tv->vval.v_dict);
+ break;
+ }
+ const dictitem_T *type_di;
+ const dictitem_T *val_di;
+ if (TYPVAL_ENCODE_ALLOW_SPECIALS
+ && tv->vval.v_dict->dv_hashtab.ht_used == 2
+ && (type_di = tv_dict_find((dict_T *)tv->vval.v_dict,
+ S_LEN("_TYPE"))) != NULL
+ && type_di->di_tv.v_type == VAR_LIST
+ && (val_di = tv_dict_find((dict_T *)tv->vval.v_dict,
+ S_LEN("_VAL"))) != NULL) {
+ size_t i;
+ for (i = 0; i < ARRAY_SIZE(eval_msgpack_type_lists); i++) {
+ if (type_di->di_tv.vval.v_list == eval_msgpack_type_lists[i]) {
break;
}
}
- break;
- }
- case VAR_DICT: {
- if (tv->vval.v_dict == NULL
- || tv->vval.v_dict->dv_hashtab.ht_used == 0) {
- TYPVAL_ENCODE_CONV_EMPTY_DICT(tv, tv->vval.v_dict);
- break;
+ if (i == ARRAY_SIZE(eval_msgpack_type_lists)) {
+ goto _convert_one_value_regular_dict;
}
- const dictitem_T *type_di;
- const dictitem_T *val_di;
- if (TYPVAL_ENCODE_ALLOW_SPECIALS
- && tv->vval.v_dict->dv_hashtab.ht_used == 2
- && (type_di = tv_dict_find((dict_T *)tv->vval.v_dict,
- S_LEN("_TYPE"))) != NULL
- && type_di->di_tv.v_type == VAR_LIST
- && (val_di = tv_dict_find((dict_T *)tv->vval.v_dict,
- S_LEN("_VAL"))) != NULL) {
- size_t i;
- for (i = 0; i < ARRAY_SIZE(eval_msgpack_type_lists); i++) {
- if (type_di->di_tv.vval.v_list == eval_msgpack_type_lists[i]) {
- break;
- }
+ switch ((MessagePackType)i) {
+ case kMPNil:
+ TYPVAL_ENCODE_CONV_NIL(tv);
+ break;
+ case kMPBoolean:
+ if (val_di->di_tv.v_type != VAR_NUMBER) {
+ goto _convert_one_value_regular_dict;
}
- if (i == ARRAY_SIZE(eval_msgpack_type_lists)) {
+ TYPVAL_ENCODE_CONV_BOOL(tv, val_di->di_tv.vval.v_number);
+ break;
+ case kMPInteger: {
+ const list_T *val_list;
+ varnumber_T sign;
+ varnumber_T highest_bits;
+ varnumber_T high_bits;
+ varnumber_T low_bits;
+ // List of 4 integers; first is signed (should be 1 or -1, but
+ // this is not checked), second is unsigned and have at most
+ // one (sign is -1) or two (sign is 1) non-zero bits (number of
+ // bits is not checked), other unsigned and have at most 31
+ // non-zero bits (number of bits is not checked).
+ if (val_di->di_tv.v_type != VAR_LIST
+ || tv_list_len(val_list = val_di->di_tv.vval.v_list) != 4) {
goto _convert_one_value_regular_dict;
}
- switch ((MessagePackType)i) {
- case kMPNil: {
- TYPVAL_ENCODE_CONV_NIL(tv);
- break;
- }
- case kMPBoolean: {
- if (val_di->di_tv.v_type != VAR_NUMBER) {
- goto _convert_one_value_regular_dict;
- }
- TYPVAL_ENCODE_CONV_BOOL(tv, val_di->di_tv.vval.v_number);
- break;
- }
- case kMPInteger: {
- const list_T *val_list;
- varnumber_T sign;
- varnumber_T highest_bits;
- varnumber_T high_bits;
- varnumber_T low_bits;
- // List of 4 integers; first is signed (should be 1 or -1, but
- // this is not checked), second is unsigned and have at most
- // one (sign is -1) or two (sign is 1) non-zero bits (number of
- // bits is not checked), other unsigned and have at most 31
- // non-zero bits (number of bits is not checked).
- if (val_di->di_tv.v_type != VAR_LIST
- || tv_list_len(val_list = val_di->di_tv.vval.v_list) != 4) {
- goto _convert_one_value_regular_dict;
- }
- const listitem_T *const sign_li = tv_list_first(val_list);
- if (TV_LIST_ITEM_TV(sign_li)->v_type != VAR_NUMBER
- || (sign = TV_LIST_ITEM_TV(sign_li)->vval.v_number) == 0) {
- goto _convert_one_value_regular_dict;
- }
+ const listitem_T *const sign_li = tv_list_first(val_list);
+ if (TV_LIST_ITEM_TV(sign_li)->v_type != VAR_NUMBER
+ || (sign = TV_LIST_ITEM_TV(sign_li)->vval.v_number) == 0) {
+ goto _convert_one_value_regular_dict;
+ }
- const listitem_T *const highest_bits_li = (
- TV_LIST_ITEM_NEXT(val_list, sign_li));
- if (TV_LIST_ITEM_TV(highest_bits_li)->v_type != VAR_NUMBER
- || ((highest_bits
- = TV_LIST_ITEM_TV(highest_bits_li)->vval.v_number)
- < 0)) {
- goto _convert_one_value_regular_dict;
- }
+ const listitem_T *const highest_bits_li = (
+ TV_LIST_ITEM_NEXT(val_list, sign_li));
+ if (TV_LIST_ITEM_TV(highest_bits_li)->v_type != VAR_NUMBER
+ || ((highest_bits
+ = TV_LIST_ITEM_TV(highest_bits_li)->vval.v_number)
+ < 0)) {
+ goto _convert_one_value_regular_dict;
+ }
- const listitem_T *const high_bits_li = (
- TV_LIST_ITEM_NEXT(val_list, highest_bits_li));
- if (TV_LIST_ITEM_TV(high_bits_li)->v_type != VAR_NUMBER
- || ((high_bits = TV_LIST_ITEM_TV(high_bits_li)->vval.v_number)
- < 0)) {
- goto _convert_one_value_regular_dict;
- }
+ const listitem_T *const high_bits_li = (
+ TV_LIST_ITEM_NEXT(val_list, highest_bits_li));
+ if (TV_LIST_ITEM_TV(high_bits_li)->v_type != VAR_NUMBER
+ || ((high_bits = TV_LIST_ITEM_TV(high_bits_li)->vval.v_number)
+ < 0)) {
+ goto _convert_one_value_regular_dict;
+ }
- const listitem_T *const low_bits_li = tv_list_last(val_list);
- if (TV_LIST_ITEM_TV(low_bits_li)->v_type != VAR_NUMBER
- || ((low_bits = TV_LIST_ITEM_TV(low_bits_li)->vval.v_number)
- < 0)) {
- goto _convert_one_value_regular_dict;
- }
+ const listitem_T *const low_bits_li = tv_list_last(val_list);
+ if (TV_LIST_ITEM_TV(low_bits_li)->v_type != VAR_NUMBER
+ || ((low_bits = TV_LIST_ITEM_TV(low_bits_li)->vval.v_number)
+ < 0)) {
+ goto _convert_one_value_regular_dict;
+ }
- const uint64_t number = ((uint64_t)(((uint64_t)highest_bits) << 62)
- | (uint64_t)(((uint64_t)high_bits) << 31)
- | (uint64_t)low_bits);
- if (sign > 0) {
- TYPVAL_ENCODE_CONV_UNSIGNED_NUMBER(tv, number);
- } else {
- TYPVAL_ENCODE_CONV_NUMBER(tv, -number);
- }
- break;
- }
- case kMPFloat: {
- if (val_di->di_tv.v_type != VAR_FLOAT) {
- goto _convert_one_value_regular_dict;
- }
- TYPVAL_ENCODE_CONV_FLOAT(tv, val_di->di_tv.vval.v_float);
- break;
- }
- case kMPString:
- case kMPBinary: {
- const bool is_string = ((MessagePackType)i == kMPString);
- if (val_di->di_tv.v_type != VAR_LIST) {
- goto _convert_one_value_regular_dict;
- }
- size_t len;
- char *buf;
- if (!encode_vim_list_to_buf(val_di->di_tv.vval.v_list, &len,
- &buf)) {
- goto _convert_one_value_regular_dict;
- }
- if (is_string) {
- TYPVAL_ENCODE_CONV_STR_STRING(tv, buf, len);
- } else { // -V523
- TYPVAL_ENCODE_CONV_STRING(tv, buf, len);
- }
- xfree(buf);
- break;
- }
- case kMPArray: {
- if (val_di->di_tv.v_type != VAR_LIST) {
- goto _convert_one_value_regular_dict;
- }
- const int saved_copyID = tv_list_copyid(val_di->di_tv.vval.v_list);
- _TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE(val_di->di_tv.vval.v_list,
- lv_copyID, copyID,
- kMPConvList);
- TYPVAL_ENCODE_CONV_LIST_START(
- tv, tv_list_len(val_di->di_tv.vval.v_list));
- assert(saved_copyID != copyID && saved_copyID != copyID - 1);
- _mp_push(*mpstack, ((MPConvStackVal) {
+ const uint64_t number = ((uint64_t)(((uint64_t)highest_bits) << 62)
+ | (uint64_t)(((uint64_t)high_bits) << 31)
+ | (uint64_t)low_bits);
+ if (sign > 0) {
+ TYPVAL_ENCODE_CONV_UNSIGNED_NUMBER(tv, number);
+ } else {
+ TYPVAL_ENCODE_CONV_NUMBER(tv, -number);
+ }
+ break;
+ }
+ case kMPFloat:
+ if (val_di->di_tv.v_type != VAR_FLOAT) {
+ goto _convert_one_value_regular_dict;
+ }
+ TYPVAL_ENCODE_CONV_FLOAT(tv, val_di->di_tv.vval.v_float);
+ break;
+ case kMPString:
+ case kMPBinary: {
+ const bool is_string = ((MessagePackType)i == kMPString);
+ if (val_di->di_tv.v_type != VAR_LIST) {
+ goto _convert_one_value_regular_dict;
+ }
+ size_t len;
+ char *buf;
+ if (!encode_vim_list_to_buf(val_di->di_tv.vval.v_list, &len,
+ &buf)) {
+ goto _convert_one_value_regular_dict;
+ }
+ if (is_string) {
+ TYPVAL_ENCODE_CONV_STR_STRING(tv, buf, len);
+ } else { // -V523
+ TYPVAL_ENCODE_CONV_STRING(tv, buf, len);
+ }
+ xfree(buf);
+ break;
+ }
+ case kMPArray: {
+ if (val_di->di_tv.v_type != VAR_LIST) {
+ goto _convert_one_value_regular_dict;
+ }
+ const int saved_copyID = tv_list_copyid(val_di->di_tv.vval.v_list);
+ _TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE(val_di->di_tv.vval.v_list,
+ lv_copyID, copyID,
+ kMPConvList);
+ TYPVAL_ENCODE_CONV_LIST_START(tv, tv_list_len(val_di->di_tv.vval.v_list));
+ assert(saved_copyID != copyID && saved_copyID != copyID - 1);
+ _mp_push(*mpstack, ((MPConvStackVal) {
.tv = tv,
.type = kMPConvList,
.saved_copyID = saved_copyID,
@@ -551,31 +534,31 @@ static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE(
},
},
}));
- break;
- }
- case kMPMap: {
- if (val_di->di_tv.v_type != VAR_LIST) {
- goto _convert_one_value_regular_dict;
- }
- list_T *const val_list = val_di->di_tv.vval.v_list;
- if (val_list == NULL || tv_list_len(val_list) == 0) {
- TYPVAL_ENCODE_CONV_EMPTY_DICT( // -V501
- tv, TYPVAL_ENCODE_NODICT_VAR);
- break;
- }
- TV_LIST_ITER_CONST(val_list, li, {
+ break;
+ }
+ case kMPMap: {
+ if (val_di->di_tv.v_type != VAR_LIST) {
+ goto _convert_one_value_regular_dict;
+ }
+ list_T *const val_list = val_di->di_tv.vval.v_list;
+ if (val_list == NULL || tv_list_len(val_list) == 0) {
+ TYPVAL_ENCODE_CONV_EMPTY_DICT( // -V501
+ tv, TYPVAL_ENCODE_NODICT_VAR);
+ break;
+ }
+ TV_LIST_ITER_CONST(val_list, li, {
if (TV_LIST_ITEM_TV(li)->v_type != VAR_LIST
|| tv_list_len(TV_LIST_ITEM_TV(li)->vval.v_list) != 2) {
goto _convert_one_value_regular_dict;
}
});
- const int saved_copyID = tv_list_copyid(val_di->di_tv.vval.v_list);
- _TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE(val_list, lv_copyID, copyID,
- kMPConvPairs);
- TYPVAL_ENCODE_CONV_DICT_START(tv, TYPVAL_ENCODE_NODICT_VAR,
- tv_list_len(val_list));
- assert(saved_copyID != copyID && saved_copyID != copyID - 1);
- _mp_push(*mpstack, ((MPConvStackVal) {
+ const int saved_copyID = tv_list_copyid(val_di->di_tv.vval.v_list);
+ _TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE(val_list, lv_copyID, copyID,
+ kMPConvPairs);
+ TYPVAL_ENCODE_CONV_DICT_START(tv, TYPVAL_ENCODE_NODICT_VAR,
+ tv_list_len(val_list));
+ assert(saved_copyID != copyID && saved_copyID != copyID - 1);
+ _mp_push(*mpstack, ((MPConvStackVal) {
.tv = tv,
.type = kMPConvPairs,
.saved_copyID = saved_copyID,
@@ -586,46 +569,45 @@ static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE(
},
},
}));
- break;
- }
- case kMPExt: {
- const list_T *val_list;
- varnumber_T type;
- if (val_di->di_tv.v_type != VAR_LIST
- || tv_list_len((val_list = val_di->di_tv.vval.v_list)) != 2
- || (TV_LIST_ITEM_TV(tv_list_first(val_list))->v_type
- != VAR_NUMBER)
- || ((type
- = TV_LIST_ITEM_TV(tv_list_first(val_list))->vval.v_number)
- > INT8_MAX)
- || type < INT8_MIN
- || (TV_LIST_ITEM_TV(tv_list_last(val_list))->v_type
- != VAR_LIST)) {
- goto _convert_one_value_regular_dict;
- }
- size_t len;
- char *buf;
- if (!(
- encode_vim_list_to_buf(
- TV_LIST_ITEM_TV(tv_list_last(val_list))->vval.v_list, &len,
- &buf))) {
- goto _convert_one_value_regular_dict;
- }
- TYPVAL_ENCODE_CONV_EXT_STRING(tv, buf, len, type);
- xfree(buf);
- break;
- }
+ break;
+ }
+ case kMPExt: {
+ const list_T *val_list;
+ varnumber_T type;
+ if (val_di->di_tv.v_type != VAR_LIST
+ || tv_list_len((val_list = val_di->di_tv.vval.v_list)) != 2
+ || (TV_LIST_ITEM_TV(tv_list_first(val_list))->v_type
+ != VAR_NUMBER)
+ || ((type
+ = TV_LIST_ITEM_TV(tv_list_first(val_list))->vval.v_number)
+ > INT8_MAX)
+ || type < INT8_MIN
+ || (TV_LIST_ITEM_TV(tv_list_last(val_list))->v_type
+ != VAR_LIST)) {
+ goto _convert_one_value_regular_dict;
+ }
+ size_t len;
+ char *buf;
+ if (!(
+ encode_vim_list_to_buf(TV_LIST_ITEM_TV(tv_list_last(val_list))->vval.v_list, &len,
+ &buf))) {
+ goto _convert_one_value_regular_dict;
}
+ TYPVAL_ENCODE_CONV_EXT_STRING(tv, buf, len, type);
+ xfree(buf);
break;
}
+ }
+ break;
+ }
_convert_one_value_regular_dict: {}
- const int saved_copyID = tv->vval.v_dict->dv_copyID;
- _TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE(tv->vval.v_dict, dv_copyID, copyID,
- kMPConvDict);
- TYPVAL_ENCODE_CONV_DICT_START(tv, tv->vval.v_dict,
- tv->vval.v_dict->dv_hashtab.ht_used);
- assert(saved_copyID != copyID);
- _mp_push(*mpstack, ((MPConvStackVal) {
+ const int saved_copyID = tv->vval.v_dict->dv_copyID;
+ _TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE(tv->vval.v_dict, dv_copyID, copyID,
+ kMPConvDict);
+ TYPVAL_ENCODE_CONV_DICT_START(tv, tv->vval.v_dict,
+ tv->vval.v_dict->dv_hashtab.ht_used);
+ assert(saved_copyID != copyID);
+ _mp_push(*mpstack, ((MPConvStackVal) {
.tv = tv,
.type = kMPConvDict,
.saved_copyID = saved_copyID,
@@ -638,14 +620,13 @@ _convert_one_value_regular_dict: {}
},
},
}));
- TYPVAL_ENCODE_CONV_REAL_DICT_AFTER_START(tv, tv->vval.v_dict,
- _mp_last(*mpstack));
- break;
- }
- case VAR_UNKNOWN: {
- internal_error(STR(_TYPVAL_ENCODE_CONVERT_ONE_VALUE) "()");
- return FAIL;
- }
+ TYPVAL_ENCODE_CONV_REAL_DICT_AFTER_START(tv, tv->vval.v_dict,
+ _mp_last(*mpstack));
+ break;
+ }
+ case VAR_UNKNOWN:
+ internal_error(STR(_TYPVAL_ENCODE_CONVERT_ONE_VALUE) "()");
+ return FAIL;
}
typval_encode_stop_converting_one_item:
return OK;
@@ -654,9 +635,9 @@ typval_encode_stop_converting_one_item:
}
TYPVAL_ENCODE_SCOPE int _TYPVAL_ENCODE_ENCODE(
- TYPVAL_ENCODE_FIRST_ARG_TYPE TYPVAL_ENCODE_FIRST_ARG_NAME,
- typval_T *const tv, const char *const objname)
- REAL_FATTR_NONNULL_ARG(2, 3) REAL_FATTR_WARN_UNUSED_RESULT;
+ TYPVAL_ENCODE_FIRST_ARG_TYPE TYPVAL_ENCODE_FIRST_ARG_NAME,
+ typval_T *const tv, const char *const objname)
+REAL_FATTR_NONNULL_ARG(2, 3) REAL_FATTR_WARN_UNUSED_RESULT;
/// Convert the whole typval
///
@@ -668,8 +649,8 @@ TYPVAL_ENCODE_SCOPE int _TYPVAL_ENCODE_ENCODE(
///
/// @return OK in case of success, FAIL in case of failure.
TYPVAL_ENCODE_SCOPE int _TYPVAL_ENCODE_ENCODE(
- TYPVAL_ENCODE_FIRST_ARG_TYPE TYPVAL_ENCODE_FIRST_ARG_NAME,
- typval_T *const top_tv, const char *const objname)
+ TYPVAL_ENCODE_FIRST_ARG_TYPE TYPVAL_ENCODE_FIRST_ARG_NAME, typval_T *const top_tv,
+ const char *const objname)
{
const int copyID = get_copyID();
MPConvStack mpstack;
@@ -687,125 +668,121 @@ typval_encode_stop_converting_one_item:
MPConvStackVal *cur_mpsv = &_mp_last(mpstack);
typval_T *tv = NULL;
switch (cur_mpsv->type) {
- case kMPConvDict: {
- if (!cur_mpsv->data.d.todo) {
- (void)_mp_pop(mpstack);
- cur_mpsv->data.d.dict->dv_copyID = cur_mpsv->saved_copyID;
- TYPVAL_ENCODE_CONV_DICT_END(cur_mpsv->tv, *cur_mpsv->data.d.dictp);
- continue;
- } else if (cur_mpsv->data.d.todo
- != cur_mpsv->data.d.dict->dv_hashtab.ht_used) {
- TYPVAL_ENCODE_CONV_DICT_BETWEEN_ITEMS(cur_mpsv->tv,
- *cur_mpsv->data.d.dictp);
- }
- while (HASHITEM_EMPTY(cur_mpsv->data.d.hi)) {
- cur_mpsv->data.d.hi++;
- }
- dictitem_T *const di = TV_DICT_HI2DI(cur_mpsv->data.d.hi);
- cur_mpsv->data.d.todo--;
+ case kMPConvDict: {
+ if (!cur_mpsv->data.d.todo) {
+ (void)_mp_pop(mpstack);
+ cur_mpsv->data.d.dict->dv_copyID = cur_mpsv->saved_copyID;
+ TYPVAL_ENCODE_CONV_DICT_END(cur_mpsv->tv, *cur_mpsv->data.d.dictp);
+ continue;
+ } else if (cur_mpsv->data.d.todo
+ != cur_mpsv->data.d.dict->dv_hashtab.ht_used) {
+ TYPVAL_ENCODE_CONV_DICT_BETWEEN_ITEMS(cur_mpsv->tv,
+ *cur_mpsv->data.d.dictp);
+ }
+ while (HASHITEM_EMPTY(cur_mpsv->data.d.hi)) {
cur_mpsv->data.d.hi++;
- TYPVAL_ENCODE_CONV_STR_STRING(NULL, &di->di_key[0],
- strlen((char *)&di->di_key[0]));
- TYPVAL_ENCODE_CONV_DICT_AFTER_KEY(cur_mpsv->tv,
- *cur_mpsv->data.d.dictp);
- tv = &di->di_tv;
- break;
}
- case kMPConvList: {
- if (cur_mpsv->data.l.li == NULL) {
- (void)_mp_pop(mpstack);
- tv_list_set_copyid(cur_mpsv->data.l.list, cur_mpsv->saved_copyID);
- TYPVAL_ENCODE_CONV_LIST_END(cur_mpsv->tv);
- continue;
- } else if (cur_mpsv->data.l.li
- != tv_list_first(cur_mpsv->data.l.list)) {
- TYPVAL_ENCODE_CONV_LIST_BETWEEN_ITEMS(cur_mpsv->tv);
- }
- tv = TV_LIST_ITEM_TV(cur_mpsv->data.l.li);
- cur_mpsv->data.l.li = TV_LIST_ITEM_NEXT(cur_mpsv->data.l.list,
- cur_mpsv->data.l.li);
- break;
+ dictitem_T *const di = TV_DICT_HI2DI(cur_mpsv->data.d.hi);
+ cur_mpsv->data.d.todo--;
+ cur_mpsv->data.d.hi++;
+ TYPVAL_ENCODE_CONV_STR_STRING(NULL, &di->di_key[0],
+ strlen((char *)&di->di_key[0]));
+ TYPVAL_ENCODE_CONV_DICT_AFTER_KEY(cur_mpsv->tv,
+ *cur_mpsv->data.d.dictp);
+ tv = &di->di_tv;
+ break;
+ }
+ case kMPConvList:
+ if (cur_mpsv->data.l.li == NULL) {
+ (void)_mp_pop(mpstack);
+ tv_list_set_copyid(cur_mpsv->data.l.list, cur_mpsv->saved_copyID);
+ TYPVAL_ENCODE_CONV_LIST_END(cur_mpsv->tv);
+ continue;
+ } else if (cur_mpsv->data.l.li
+ != tv_list_first(cur_mpsv->data.l.list)) {
+ TYPVAL_ENCODE_CONV_LIST_BETWEEN_ITEMS(cur_mpsv->tv);
}
- case kMPConvPairs: {
- if (cur_mpsv->data.l.li == NULL) {
- (void)_mp_pop(mpstack);
- tv_list_set_copyid(cur_mpsv->data.l.list, cur_mpsv->saved_copyID);
- TYPVAL_ENCODE_CONV_DICT_END(cur_mpsv->tv, TYPVAL_ENCODE_NODICT_VAR);
- continue;
- } else if (cur_mpsv->data.l.li
- != tv_list_first(cur_mpsv->data.l.list)) {
- TYPVAL_ENCODE_CONV_DICT_BETWEEN_ITEMS(
- cur_mpsv->tv, TYPVAL_ENCODE_NODICT_VAR);
- }
- const list_T *const kv_pair = (
- TV_LIST_ITEM_TV(cur_mpsv->data.l.li)->vval.v_list);
- TYPVAL_ENCODE_SPECIAL_DICT_KEY_CHECK(
- encode_vim_to__error_ret, *TV_LIST_ITEM_TV(tv_list_first(kv_pair)));
- if (
- _TYPVAL_ENCODE_CONVERT_ONE_VALUE(
- TYPVAL_ENCODE_FIRST_ARG_NAME, &mpstack, cur_mpsv,
- TV_LIST_ITEM_TV(tv_list_first(kv_pair)), copyID, objname)
- == FAIL) {
- goto encode_vim_to__error_ret;
- }
- TYPVAL_ENCODE_CONV_DICT_AFTER_KEY(cur_mpsv->tv,
- TYPVAL_ENCODE_NODICT_VAR);
- tv = TV_LIST_ITEM_TV(tv_list_last(kv_pair));
- cur_mpsv->data.l.li = TV_LIST_ITEM_NEXT(cur_mpsv->data.l.list,
- cur_mpsv->data.l.li);
- break;
+ tv = TV_LIST_ITEM_TV(cur_mpsv->data.l.li);
+ cur_mpsv->data.l.li = TV_LIST_ITEM_NEXT(cur_mpsv->data.l.list,
+ cur_mpsv->data.l.li);
+ break;
+ case kMPConvPairs: {
+ if (cur_mpsv->data.l.li == NULL) {
+ (void)_mp_pop(mpstack);
+ tv_list_set_copyid(cur_mpsv->data.l.list, cur_mpsv->saved_copyID);
+ TYPVAL_ENCODE_CONV_DICT_END(cur_mpsv->tv, TYPVAL_ENCODE_NODICT_VAR);
+ continue;
+ } else if (cur_mpsv->data.l.li
+ != tv_list_first(cur_mpsv->data.l.list)) {
+ TYPVAL_ENCODE_CONV_DICT_BETWEEN_ITEMS(cur_mpsv->tv, TYPVAL_ENCODE_NODICT_VAR);
}
- case kMPConvPartial: {
- partial_T *const pt = cur_mpsv->data.p.pt;
- tv = cur_mpsv->tv;
- (void)tv;
- switch (cur_mpsv->data.p.stage) {
- case kMPConvPartialArgs: {
- TYPVAL_ENCODE_CONV_FUNC_BEFORE_ARGS(tv,
- pt == NULL ? 0 : pt->pt_argc);
- cur_mpsv->data.p.stage = kMPConvPartialSelf;
- if (pt != NULL && pt->pt_argc > 0) {
- TYPVAL_ENCODE_CONV_LIST_START(NULL, pt->pt_argc);
- _mp_push(mpstack, ((MPConvStackVal) {
- .type = kMPConvPartialList,
- .tv = NULL,
- .saved_copyID = copyID - 1,
- .data = {
- .a = {
- .arg = pt->pt_argv,
- .argv = pt->pt_argv,
- .todo = (size_t)pt->pt_argc,
- },
+ const list_T *const kv_pair = (
+ TV_LIST_ITEM_TV(cur_mpsv->data.l.li)->vval.v_list);
+ TYPVAL_ENCODE_SPECIAL_DICT_KEY_CHECK(encode_vim_to__error_ret,
+ *TV_LIST_ITEM_TV(tv_list_first(kv_pair)));
+ if (
+ _TYPVAL_ENCODE_CONVERT_ONE_VALUE(TYPVAL_ENCODE_FIRST_ARG_NAME, &mpstack, cur_mpsv,
+ TV_LIST_ITEM_TV(tv_list_first(kv_pair)), copyID, objname)
+ == FAIL) {
+ goto encode_vim_to__error_ret;
+ }
+ TYPVAL_ENCODE_CONV_DICT_AFTER_KEY(cur_mpsv->tv,
+ TYPVAL_ENCODE_NODICT_VAR);
+ tv = TV_LIST_ITEM_TV(tv_list_last(kv_pair));
+ cur_mpsv->data.l.li = TV_LIST_ITEM_NEXT(cur_mpsv->data.l.list,
+ cur_mpsv->data.l.li);
+ break;
+ }
+ case kMPConvPartial: {
+ partial_T *const pt = cur_mpsv->data.p.pt;
+ tv = cur_mpsv->tv;
+ (void)tv;
+ switch (cur_mpsv->data.p.stage) {
+ case kMPConvPartialArgs:
+ TYPVAL_ENCODE_CONV_FUNC_BEFORE_ARGS(tv,
+ pt == NULL ? 0 : pt->pt_argc);
+ cur_mpsv->data.p.stage = kMPConvPartialSelf;
+ if (pt != NULL && pt->pt_argc > 0) {
+ TYPVAL_ENCODE_CONV_LIST_START(NULL, pt->pt_argc);
+ _mp_push(mpstack, ((MPConvStackVal) {
+ .type = kMPConvPartialList,
+ .tv = NULL,
+ .saved_copyID = copyID - 1,
+ .data = {
+ .a = {
+ .arg = pt->pt_argv,
+ .argv = pt->pt_argv,
+ .todo = (size_t)pt->pt_argc,
},
- }));
+ },
+ }));
+ }
+ break;
+ case kMPConvPartialSelf: {
+ cur_mpsv->data.p.stage = kMPConvPartialEnd;
+ dict_T *const dict = pt == NULL ? NULL : pt->pt_dict;
+ if (dict != NULL) {
+ TYPVAL_ENCODE_CONV_FUNC_BEFORE_SELF(tv, dict->dv_hashtab.ht_used);
+ if (dict->dv_hashtab.ht_used == 0) {
+ TYPVAL_ENCODE_CONV_EMPTY_DICT(NULL, pt->pt_dict);
+ continue;
+ }
+ const int saved_copyID = dict->dv_copyID;
+ const int te_csr_ret = _TYPVAL_ENCODE_CHECK_SELF_REFERENCE(TYPVAL_ENCODE_FIRST_ARG_NAME,
+ dict, &dict->dv_copyID,
+ &mpstack, copyID, kMPConvDict,
+ objname);
+ if (te_csr_ret != NOTDONE) {
+ if (te_csr_ret == FAIL) {
+ goto encode_vim_to__error_ret;
+ } else {
+ continue;
}
- break;
}
- case kMPConvPartialSelf: {
- cur_mpsv->data.p.stage = kMPConvPartialEnd;
- dict_T *const dict = pt == NULL ? NULL : pt->pt_dict;
- if (dict != NULL) {
- TYPVAL_ENCODE_CONV_FUNC_BEFORE_SELF(tv, dict->dv_hashtab.ht_used);
- if (dict->dv_hashtab.ht_used == 0) {
- TYPVAL_ENCODE_CONV_EMPTY_DICT(NULL, pt->pt_dict);
- continue;
- }
- const int saved_copyID = dict->dv_copyID;
- const int te_csr_ret = _TYPVAL_ENCODE_CHECK_SELF_REFERENCE(
- TYPVAL_ENCODE_FIRST_ARG_NAME,
- dict, &dict->dv_copyID, &mpstack, copyID, kMPConvDict,
- objname);
- if (te_csr_ret != NOTDONE) {
- if (te_csr_ret == FAIL) {
- goto encode_vim_to__error_ret;
- } else {
- continue;
- }
- }
- TYPVAL_ENCODE_CONV_DICT_START(NULL, pt->pt_dict,
- dict->dv_hashtab.ht_used);
- assert(saved_copyID != copyID && saved_copyID != copyID - 1);
- _mp_push(mpstack, ((MPConvStackVal) {
+ TYPVAL_ENCODE_CONV_DICT_START(NULL, pt->pt_dict,
+ dict->dv_hashtab.ht_used);
+ assert(saved_copyID != copyID && saved_copyID != copyID - 1);
+ _mp_push(mpstack, ((MPConvStackVal) {
.type = kMPConvDict,
.tv = NULL,
.saved_copyID = saved_copyID,
@@ -818,33 +795,31 @@ typval_encode_stop_converting_one_item:
},
},
}));
- TYPVAL_ENCODE_CONV_REAL_DICT_AFTER_START(NULL, pt->pt_dict,
- _mp_last(mpstack));
- } else {
- TYPVAL_ENCODE_CONV_FUNC_BEFORE_SELF(tv, -1);
- }
- break;
- }
- case kMPConvPartialEnd: {
- TYPVAL_ENCODE_CONV_FUNC_END(tv);
- (void)_mp_pop(mpstack);
- break;
- }
+ TYPVAL_ENCODE_CONV_REAL_DICT_AFTER_START(NULL, pt->pt_dict,
+ _mp_last(mpstack));
+ } else {
+ TYPVAL_ENCODE_CONV_FUNC_BEFORE_SELF(tv, -1);
}
- continue;
+ break;
}
- case kMPConvPartialList: {
- if (!cur_mpsv->data.a.todo) {
- (void)_mp_pop(mpstack);
- TYPVAL_ENCODE_CONV_LIST_END(NULL);
- continue;
- } else if (cur_mpsv->data.a.argv != cur_mpsv->data.a.arg) {
- TYPVAL_ENCODE_CONV_LIST_BETWEEN_ITEMS(NULL);
- }
- tv = cur_mpsv->data.a.arg++;
- cur_mpsv->data.a.todo--;
+ case kMPConvPartialEnd:
+ TYPVAL_ENCODE_CONV_FUNC_END(tv);
+ (void)_mp_pop(mpstack);
break;
}
+ continue;
+ }
+ case kMPConvPartialList:
+ if (!cur_mpsv->data.a.todo) {
+ (void)_mp_pop(mpstack);
+ TYPVAL_ENCODE_CONV_LIST_END(NULL);
+ continue;
+ } else if (cur_mpsv->data.a.argv != cur_mpsv->data.a.arg) {
+ TYPVAL_ENCODE_CONV_LIST_BETWEEN_ITEMS(NULL);
+ }
+ tv = cur_mpsv->data.a.arg++;
+ cur_mpsv->data.a.todo--;
+ break;
}
assert(tv != NULL);
if (_TYPVAL_ENCODE_CONVERT_ONE_VALUE(TYPVAL_ENCODE_FIRST_ARG_NAME, &mpstack,
diff --git a/src/nvim/eval/typval_encode.h b/src/nvim/eval/typval_encode.h
index 3475f6d8b3..d5cf431870 100644
--- a/src/nvim/eval/typval_encode.h
+++ b/src/nvim/eval/typval_encode.h
@@ -5,14 +5,14 @@
#ifndef NVIM_EVAL_TYPVAL_ENCODE_H
#define NVIM_EVAL_TYPVAL_ENCODE_H
-#include <stddef.h>
+#include <assert.h>
#include <inttypes.h>
+#include <stddef.h>
#include <string.h>
-#include <assert.h>
-#include "nvim/lib/kvec.h"
#include "nvim/eval/typval.h"
#include "nvim/func_attr.h"
+#include "nvim/lib/kvec.h"
/// Type of the stack entry
typedef enum {
@@ -87,7 +87,7 @@ static inline size_t tv_strlen(const typval_T *const tv)
assert(tv->v_type == VAR_STRING);
return (tv->vval.v_string == NULL
? 0
- : strlen((char *) tv->vval.v_string));
+ : strlen((char *)tv->vval.v_string));
}
/// Code for checking whether container references itself
@@ -100,19 +100,19 @@ static inline size_t tv_strlen(const typval_T *const tv)
/// @param conv_type Type of the conversion, @see MPConvStackValType.
#define _TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE(val, copyID_attr, copyID, \
conv_type) \
- do { \
- const int te_csr_ret = _TYPVAL_ENCODE_CHECK_SELF_REFERENCE( \
- TYPVAL_ENCODE_FIRST_ARG_NAME, \
- (val), &(val)->copyID_attr, mpstack, copyID, conv_type, objname); \
- if (te_csr_ret != NOTDONE) { \
- return te_csr_ret; \
- } \
- } while (0)
+ do { \
+ const int te_csr_ret = _TYPVAL_ENCODE_CHECK_SELF_REFERENCE(TYPVAL_ENCODE_FIRST_ARG_NAME, \
+ (val), &(val)->copyID_attr, mpstack, \
+ copyID, conv_type, objname); \
+ if (te_csr_ret != NOTDONE) { \
+ return te_csr_ret; \
+ } \
+ } while (0)
#define _TYPVAL_ENCODE_FUNC_NAME_INNER_2(pref, name, suf) \
- pref##name##suf
+ pref##name##suf
#define _TYPVAL_ENCODE_FUNC_NAME_INNER(pref, name, suf) \
- _TYPVAL_ENCODE_FUNC_NAME_INNER_2(pref, name, suf)
+ _TYPVAL_ENCODE_FUNC_NAME_INNER_2(pref, name, suf)
/// Construct function name, possibly using macros
///
@@ -125,22 +125,22 @@ static inline size_t tv_strlen(const typval_T *const tv)
///
/// @return Concat: pref + #TYPVAL_ENCODE_NAME + suf.
#define _TYPVAL_ENCODE_FUNC_NAME(pref, suf) \
- _TYPVAL_ENCODE_FUNC_NAME_INNER(pref, TYPVAL_ENCODE_NAME, suf)
+ _TYPVAL_ENCODE_FUNC_NAME_INNER(pref, TYPVAL_ENCODE_NAME, suf)
/// Self reference checker function name
#define _TYPVAL_ENCODE_CHECK_SELF_REFERENCE \
- _TYPVAL_ENCODE_FUNC_NAME(_typval_encode_, _check_self_reference)
+ _TYPVAL_ENCODE_FUNC_NAME(_typval_encode_, _check_self_reference)
/// Entry point function name
#define _TYPVAL_ENCODE_ENCODE \
- _TYPVAL_ENCODE_FUNC_NAME(encode_vim_to_, )
+ _TYPVAL_ENCODE_FUNC_NAME(encode_vim_to_, )
/// Name of the …convert_one_value function
#define _TYPVAL_ENCODE_CONVERT_ONE_VALUE \
- _TYPVAL_ENCODE_FUNC_NAME(_typval_encode_, _convert_one_value)
+ _TYPVAL_ENCODE_FUNC_NAME(_typval_encode_, _convert_one_value)
/// Name of the dummy const dict_T *const variable
#define TYPVAL_ENCODE_NODICT_VAR \
- _TYPVAL_ENCODE_FUNC_NAME(_typval_encode_, _nodict_var)
+ _TYPVAL_ENCODE_FUNC_NAME(_typval_encode_, _nodict_var)
#endif // NVIM_EVAL_TYPVAL_ENCODE_H
diff --git a/src/nvim/eval/userfunc.h b/src/nvim/eval/userfunc.h
index 3f111343d2..ed86aaad4a 100644
--- a/src/nvim/eval/userfunc.h
+++ b/src/nvim/eval/userfunc.h
@@ -8,7 +8,7 @@
typedef struct {
dict_T *fd_dict; ///< Dictionary used.
char_u *fd_newkey; ///< New key in "dict" in allocated memory.
- dictitem_T *fd_di; ///< Dictionary item used.
+ dictitem_T *fd_di; ///< Dictionary item used.
} funcdict_T;
typedef struct funccal_entry funccal_entry_T;
diff --git a/src/nvim/event/defs.h b/src/nvim/event/defs.h
index fdd4f17d5c..cf079681d0 100644
--- a/src/nvim/event/defs.h
+++ b/src/nvim/event/defs.h
@@ -11,7 +11,7 @@ typedef struct message {
argv_callback handler;
void *argv[EVENT_HANDLER_MAX_ARGC];
} Event;
-typedef void(*event_scheduler)(Event event, void *data);
+typedef void (*event_scheduler)(Event event, void *data);
#define VA_EVENT_INIT(event, h, a) \
do { \
diff --git a/src/nvim/event/loop.h b/src/nvim/event/loop.h
index f5dd23ac8b..03cf7e489a 100644
--- a/src/nvim/event/loop.h
+++ b/src/nvim/event/loop.h
@@ -2,12 +2,11 @@
#define NVIM_EVENT_LOOP_H
#include <stdint.h>
-
#include <uv.h>
+#include "nvim/event/multiqueue.h"
#include "nvim/lib/klist.h"
#include "nvim/os/time.h"
-#include "nvim/event/multiqueue.h"
typedef void * WatcherPtr;
@@ -65,7 +64,7 @@ typedef struct loop {
break; \
} else if (remaining > 0) { \
uint64_t now = os_hrtime(); \
- remaining -= (int) ((now - before) / 1000000); \
+ remaining -= (int)((now - before) / 1000000); \
before = now; \
if (remaining <= 0) { \
break; \
diff --git a/src/nvim/event/process.h b/src/nvim/event/process.h
index 20c02e4900..2b22cd95dc 100644
--- a/src/nvim/event/process.h
+++ b/src/nvim/event/process.h
@@ -1,10 +1,10 @@
#ifndef NVIM_EVENT_PROCESS_H
#define NVIM_EVENT_PROCESS_H
+#include "nvim/eval/typval.h"
#include "nvim/event/loop.h"
#include "nvim/event/rstream.h"
#include "nvim/event/wstream.h"
-#include "nvim/eval/typval.h"
typedef enum {
kProcessTypeUv,
diff --git a/src/nvim/event/rstream.h b/src/nvim/event/rstream.h
index f30ad79ee5..77418c59a2 100644
--- a/src/nvim/event/rstream.h
+++ b/src/nvim/event/rstream.h
@@ -3,7 +3,6 @@
#include <stdbool.h>
#include <stddef.h>
-
#include <uv.h>
#include "nvim/event/loop.h"
diff --git a/src/nvim/event/stream.h b/src/nvim/event/stream.h
index a5c33a66a2..02e816b4be 100644
--- a/src/nvim/event/stream.h
+++ b/src/nvim/event/stream.h
@@ -3,7 +3,6 @@
#include <stdbool.h>
#include <stddef.h>
-
#include <uv.h>
#include "nvim/event/loop.h"
@@ -18,7 +17,7 @@ typedef struct stream Stream;
/// @param data User-defined data
/// @param eof If the stream reached EOF.
typedef void (*stream_read_cb)(Stream *stream, RBuffer *buf, size_t count,
- void *data, bool eof);
+ void *data, bool eof);
/// Type of function called when the Stream has information about a write
/// request.
diff --git a/src/nvim/event/wstream.h b/src/nvim/event/wstream.h
index 9008de0d97..d599d29913 100644
--- a/src/nvim/event/wstream.h
+++ b/src/nvim/event/wstream.h
@@ -1,9 +1,8 @@
#ifndef NVIM_EVENT_WSTREAM_H
#define NVIM_EVENT_WSTREAM_H
-#include <stdint.h>
#include <stdbool.h>
-
+#include <stdint.h>
#include <uv.h>
#include "nvim/event/loop.h"
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index cab4b353dc..4a23f284cc 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -702,11 +702,11 @@ void ex_sort(exarg_T *eap)
mark_adjust(eap->line2, MAXLNUM, -deleted, 0L, kExtmarkNOOP);
}
- extmark_splice(curbuf, eap->line1-1, 0,
- count, 0, old_count,
- lnum - eap->line2, 0, new_count, kExtmarkUndo);
-
if (change_occurred || deleted != 0) {
+ extmark_splice(curbuf, eap->line1-1, 0,
+ count, 0, old_count,
+ lnum - eap->line2, 0, new_count, kExtmarkUndo);
+
changed_lines(eap->line1, 0, eap->line2 + 1, -deleted, true);
}
@@ -1439,11 +1439,11 @@ static void do_filter(linenr_T line1, linenr_T line2, exarg_T *eap, char_u *cmd,
if (linecount > p_report) {
if (do_in) {
- vim_snprintf((char *)msg_buf, sizeof(msg_buf),
+ vim_snprintf(msg_buf, sizeof(msg_buf),
_("%" PRId64 " lines filtered"), (int64_t)linecount);
- if (msg(msg_buf) && !msg_scroll) {
+ if (msg((char_u *)msg_buf) && !msg_scroll) {
// save message to display it after redraw
- set_keep_msg(msg_buf, 0);
+ set_keep_msg((char_u *)msg_buf, 0);
}
} else {
msgmore((long)linecount);
@@ -4409,7 +4409,7 @@ skip:
pre_src_id = (int)nvim_create_namespace((String)STRING_INIT);
}
if (pre_hl_id == 0) {
- pre_hl_id = syn_check_group((char_u *)S_LEN("Substitute"));
+ pre_hl_id = syn_check_group(S_LEN("Substitute"));
}
curbuf->b_changed = save_b_changed; // preserve 'modified' during preview
preview_buf = show_sub(eap, old_cursor, &preview_lines,
@@ -4451,24 +4451,24 @@ bool do_sub_msg(bool count_only)
*msg_buf = NUL;
}
if (sub_nsubs == 1) {
- vim_snprintf_add((char *)msg_buf, sizeof(msg_buf),
+ vim_snprintf_add(msg_buf, sizeof(msg_buf),
"%s", count_only ? _("1 match") : _("1 substitution"));
} else {
- vim_snprintf_add((char *)msg_buf, sizeof(msg_buf),
+ vim_snprintf_add(msg_buf, sizeof(msg_buf),
count_only ? _("%" PRId64 " matches")
: _("%" PRId64 " substitutions"),
(int64_t)sub_nsubs);
}
if (sub_nlines == 1) {
- vim_snprintf_add((char *)msg_buf, sizeof(msg_buf),
+ vim_snprintf_add(msg_buf, sizeof(msg_buf),
"%s", _(" on 1 line"));
} else {
- vim_snprintf_add((char *)msg_buf, sizeof(msg_buf),
+ vim_snprintf_add(msg_buf, sizeof(msg_buf),
_(" on %" PRId64 " lines"), (int64_t)sub_nlines);
}
- if (msg(msg_buf)) {
+ if (msg((char_u *)msg_buf)) {
// save message to display it after redraw
- set_keep_msg(msg_buf, 0);
+ set_keep_msg((char_u *)msg_buf, 0);
}
return true;
}
@@ -5800,8 +5800,7 @@ void ex_helptags(exarg_T *eap)
}
if (STRCMP(eap->arg, "ALL") == 0) {
- do_in_path(p_rtp, (char_u *)"doc", DIP_ALL + DIP_DIR,
- helptags_cb, &add_help_tags);
+ do_in_path(p_rtp, "doc", DIP_ALL + DIP_DIR, helptags_cb, &add_help_tags);
} else {
ExpandInit(&xpc);
xpc.xp_context = EXPAND_DIRECTORIES;
diff --git a/src/nvim/ex_cmds.h b/src/nvim/ex_cmds.h
index 1b54b3a898..c34ffa1d3b 100644
--- a/src/nvim/ex_cmds.h
+++ b/src/nvim/ex_cmds.h
@@ -3,11 +3,11 @@
#include <stdbool.h>
-#include "nvim/os/time.h"
-#include "nvim/pos.h"
-#include "nvim/eval/typval.h"
#include "nvim/buffer_defs.h"
+#include "nvim/eval/typval.h"
#include "nvim/ex_cmds_defs.h"
+#include "nvim/os/time.h"
+#include "nvim/pos.h"
// flags for do_ecmd()
#define ECMD_HIDE 0x01 // don't free the current buffer
@@ -18,10 +18,10 @@
#define ECMD_ADDBUF 0x10 // don't edit, just add to buffer list
#define ECMD_ALTBUF 0x20 // like ECMD_ADDBUF and set the alternate file
-/* for lnum argument in do_ecmd() */
-#define ECMD_LASTL (linenr_T)0 /* use last position in loaded file */
-#define ECMD_LAST (linenr_T)-1 /* use last position in all files */
-#define ECMD_ONE (linenr_T)1 /* use first line */
+// for lnum argument in do_ecmd()
+#define ECMD_LASTL (linenr_T)0 // use last position in loaded file
+#define ECMD_LAST (linenr_T)-1 // use last position in all files
+#define ECMD_ONE (linenr_T)1 // use first line
/// Previous :substitute replacement string definition
typedef struct {
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c
index 46b86fbc84..5d40d7a16a 100644
--- a/src/nvim/ex_cmds2.c
+++ b/src/nvim/ex_cmds2.c
@@ -52,33 +52,7 @@
#include "nvim/version.h"
#include "nvim/window.h"
-
/// Growarray to store info about already sourced scripts.
-/// Also store the dev/ino, so that we don't have to stat() each
-/// script when going through the list.
-typedef struct scriptitem_S {
- char_u *sn_name;
- bool file_id_valid;
- FileID file_id;
- bool sn_prof_on; ///< true when script is/was profiled
- bool sn_pr_force; ///< forceit: profile functions in this script
- proftime_T sn_pr_child; ///< time set when going into first child
- int sn_pr_nest; ///< nesting for sn_pr_child
- // profiling the script as a whole
- int sn_pr_count; ///< nr of times sourced
- proftime_T sn_pr_total; ///< time spent in script + children
- proftime_T sn_pr_self; ///< time spent in script itself
- proftime_T sn_pr_start; ///< time at script start
- proftime_T sn_pr_children; ///< time in children after script start
- // profiling the script per line
- garray_T sn_prl_ga; ///< things stored for every line
- proftime_T sn_prl_start; ///< start time for current line
- proftime_T sn_prl_children; ///< time spent in children for this line
- proftime_T sn_prl_wait; ///< wait start time for current line
- linenr_T sn_prl_idx; ///< index of line being timed; -1 if none
- int sn_prl_execed; ///< line being timed was executed
-} scriptitem_T;
-
static garray_T script_items = { 0, 0, sizeof(scriptitem_T), 4, NULL };
#define SCRIPT_ITEM(id) (((scriptitem_T *)script_items.ga_data)[(id) - 1])
@@ -1640,10 +1614,10 @@ void ex_compiler(exarg_T *eap)
do_unlet(S_LEN("b:current_compiler"), true);
snprintf((char *)buf, bufsize, "compiler/%s.vim", eap->arg);
- if (source_runtime(buf, DIP_ALL) == FAIL) {
+ if (source_runtime((char *)buf, DIP_ALL) == FAIL) {
// Try lua compiler
snprintf((char *)buf, bufsize, "compiler/%s.lua", eap->arg);
- if (source_runtime(buf, DIP_ALL) == FAIL) {
+ if (source_runtime((char *)buf, DIP_ALL) == FAIL) {
EMSG2(_("E666: compiler not supported: %s"), eap->arg);
}
}
@@ -1823,7 +1797,7 @@ static void cmd_source(char_u *fname, exarg_T *eap)
|| eap->cstack->cs_idx >= 0);
// ":source" read ex commands
- } else if (do_source(fname, false, DOSO_NONE) == FAIL) {
+ } else if (do_source((char *)fname, false, DOSO_NONE) == FAIL) {
EMSG2(_(e_notopen), fname);
}
}
@@ -1939,6 +1913,29 @@ static char_u *get_str_line(int c, void *cookie, int indent, bool do_concat)
return ga.ga_data;
}
+/// Create a new script item and allocate script-local vars. @see new_script_vars
+///
+/// @param name File name of the script. NULL for anonymous :source.
+/// @param[out] sid_out SID of the new item.
+/// @return pointer to the created script item.
+scriptitem_T *new_script_item(char_u *const name, scid_T *const sid_out)
+{
+ static scid_T last_current_SID = 0;
+ const scid_T sid = ++last_current_SID;
+ if (sid_out != NULL) {
+ *sid_out = sid;
+ }
+ ga_grow(&script_items, (int)(sid - script_items.ga_len));
+ while (script_items.ga_len < sid) {
+ script_items.ga_len++;
+ SCRIPT_ITEM(script_items.ga_len).sn_name = NULL;
+ SCRIPT_ITEM(script_items.ga_len).sn_prof_on = false;
+ }
+ SCRIPT_ITEM(sid).sn_name = name;
+ new_script_vars(sid); // Allocate the local script variables to use for this script.
+ return &SCRIPT_ITEM(sid);
+}
+
static int source_using_linegetter(void *cookie, LineGetter fgetline, const char *traceback_name)
{
char_u *save_sourcing_name = sourcing_name;
@@ -1984,7 +1981,7 @@ static void cmd_source_buffer(const exarg_T *const eap)
if (ga.ga_len > 400) {
ga_set_growsize(&ga, MAX(ga.ga_len, 8000));
}
- ga_concat(&ga, ml_get(curr_lnum));
+ ga_concat(&ga, (char *)ml_get(curr_lnum));
ga_append(&ga, NL);
}
((char_u *)ga.ga_data)[ga.ga_len - 1] = NUL;
@@ -2027,7 +2024,7 @@ int do_source_str(const char *cmd, const char *traceback_name)
/// @param is_vimrc DOSO_ value
///
/// @return FAIL if file could not be opened, OK otherwise
-int do_source(char_u *fname, int check_other, int is_vimrc)
+int do_source(char *fname, int check_other, int is_vimrc)
{
struct source_cookie cookie;
char_u *save_sourcing_name;
@@ -2036,14 +2033,13 @@ int do_source(char_u *fname, int check_other, int is_vimrc)
char_u *fname_exp;
char_u *firstline = NULL;
int retval = FAIL;
- static scid_T last_current_SID = 0;
static int last_current_SID_seq = 0;
int save_debug_break_level = debug_break_level;
scriptitem_T *si = NULL;
proftime_T wait_start;
bool trigger_source_post = false;
- p = expand_env_save(fname);
+ p = expand_env_save((char_u *)fname);
if (p == NULL) {
return retval;
}
@@ -2183,15 +2179,7 @@ int do_source(char_u *fname, int check_other, int is_vimrc)
}
}
if (current_sctx.sc_sid == 0) {
- current_sctx.sc_sid = ++last_current_SID;
- ga_grow(&script_items, (int)(current_sctx.sc_sid - script_items.ga_len));
- while (script_items.ga_len < current_sctx.sc_sid) {
- script_items.ga_len++;
- SCRIPT_ITEM(script_items.ga_len).sn_name = NULL;
- SCRIPT_ITEM(script_items.ga_len).sn_prof_on = false;
- }
- si = &SCRIPT_ITEM(current_sctx.sc_sid);
- si->sn_name = fname_exp;
+ si = new_script_item(fname_exp, &current_sctx.sc_sid);
fname_exp = vim_strsave(si->sn_name); // used for autocmd
if (file_id_ok) {
si->file_id_valid = true;
@@ -2199,9 +2187,6 @@ int do_source(char_u *fname, int check_other, int is_vimrc)
} else {
si->file_id_valid = false;
}
-
- // Allocate the local script variables to use for this script.
- new_script_vars(current_sctx.sc_sid);
}
if (l_do_profiling == PROF_YES) {
@@ -2375,16 +2360,21 @@ char_u *get_scriptname(LastSet last_set, bool *should_free)
case SID_LUA:
return (char_u *)_("Lua");
case SID_API_CLIENT:
- vim_snprintf((char *)IObuff, IOSIZE,
- _("API client (channel id %" PRIu64 ")"),
- last_set.channel_id);
+ snprintf((char *)IObuff, IOSIZE, _("API client (channel id %" PRIu64 ")"), last_set.channel_id);
return IObuff;
case SID_STR:
return (char_u *)_("anonymous :source");
- default:
+ default: {
+ char_u *const sname = SCRIPT_ITEM(last_set.script_ctx.sc_sid).sn_name;
+ if (sname == NULL) {
+ snprintf((char *)IObuff, IOSIZE, _("anonymous :source (script id %d)"),
+ last_set.script_ctx.sc_sid);
+ return IObuff;
+ }
+
*should_free = true;
- return home_replace_save(NULL,
- SCRIPT_ITEM(last_set.script_ctx.sc_sid).sn_name);
+ return home_replace_save(NULL, sname);
+ }
}
}
@@ -2459,7 +2449,7 @@ char_u *getsourceline(int c, void *cookie, int indent, bool do_concat)
garray_T ga;
ga_init(&ga, (int)sizeof(char_u), 400);
- ga_concat(&ga, line);
+ ga_concat(&ga, (char *)line);
while (sp->nextline != NULL
&& concat_continued_line(&ga, 400, sp->nextline,
STRLEN(sp->nextline))) {
diff --git a/src/nvim/ex_cmds2.h b/src/nvim/ex_cmds2.h
index de4e1429b7..d426ff28f8 100644
--- a/src/nvim/ex_cmds2.h
+++ b/src/nvim/ex_cmds2.h
@@ -16,6 +16,31 @@
#define CCGD_ALLBUF 8 // may write all buffers
#define CCGD_EXCMD 16 // may suggest using !
+/// Also store the dev/ino, so that we don't have to stat() each
+/// script when going through the list.
+typedef struct scriptitem_S {
+ char_u *sn_name;
+ bool file_id_valid;
+ FileID file_id;
+ bool sn_prof_on; ///< true when script is/was profiled
+ bool sn_pr_force; ///< forceit: profile functions in this script
+ proftime_T sn_pr_child; ///< time set when going into first child
+ int sn_pr_nest; ///< nesting for sn_pr_child
+ // profiling the script as a whole
+ int sn_pr_count; ///< nr of times sourced
+ proftime_T sn_pr_total; ///< time spent in script + children
+ proftime_T sn_pr_self; ///< time spent in script itself
+ proftime_T sn_pr_start; ///< time at script start
+ proftime_T sn_pr_children; ///< time in children after script start
+ // profiling the script per line
+ garray_T sn_prl_ga; ///< things stored for every line
+ proftime_T sn_prl_start; ///< start time for current line
+ proftime_T sn_prl_children; ///< time spent in children for this line
+ proftime_T sn_prl_wait; ///< wait start time for current line
+ linenr_T sn_prl_idx; ///< index of line being timed; -1 if none
+ int sn_prl_execed; ///< line being timed was executed
+} scriptitem_T;
+
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "ex_cmds2.h.generated.h"
#endif
diff --git a/src/nvim/ex_cmds_defs.h b/src/nvim/ex_cmds_defs.h
index d64b14c9c5..171f8ed5cd 100644
--- a/src/nvim/ex_cmds_defs.h
+++ b/src/nvim/ex_cmds_defs.h
@@ -4,8 +4,8 @@
#include <stdbool.h>
#include <stdint.h>
-#include "nvim/pos.h" // for linenr_T
#include "nvim/normal.h"
+#include "nvim/pos.h" // for linenr_T
#include "nvim/regexp_defs.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
@@ -83,10 +83,10 @@ typedef enum {
typedef struct exarg exarg_T;
-/* behavior for bad character, "++bad=" argument */
-#define BAD_REPLACE '?' /* replace it with '?' (default) */
-#define BAD_KEEP -1 /* leave it */
-#define BAD_DROP -2 /* erase it */
+// behavior for bad character, "++bad=" argument
+#define BAD_REPLACE '?' // replace it with '?' (default)
+#define BAD_KEEP -1 // leave it
+#define BAD_DROP -2 // erase it
typedef void (*ex_func_T)(exarg_T *eap);
@@ -130,8 +130,8 @@ typedef struct {
eslist_T *cs_emsg_silent_list; // saved values of "emsg_silent"
int cs_lflags; // loop flags: CSL_ flags
} cstack_T;
-# define cs_rettv cs_pend.csp_rv
-# define cs_exception cs_pend.csp_ex
+#define cs_rettv cs_pend.csp_rv
+#define cs_exception cs_pend.csp_ex
// Flags for the cs_lflags item in cstack_T.
enum {
@@ -143,10 +143,10 @@ enum {
/// Arguments used for Ex commands.
struct exarg {
- char_u *arg; ///< argument of the command
- char_u *nextcmd; ///< next command (NULL if none)
- char_u *cmd; ///< the name of the command (except for :make)
- char_u **cmdlinep; ///< pointer to pointer of allocated cmdline
+ char_u *arg; ///< argument of the command
+ char_u *nextcmd; ///< next command (NULL if none)
+ char_u *cmd; ///< the name of the command (except for :make)
+ char_u **cmdlinep; ///< pointer to pointer of allocated cmdline
cmdidx_T cmdidx; ///< the index for the command
uint32_t argt; ///< flags for the command
int skip; ///< don't execute the command, only parse it
@@ -156,7 +156,7 @@ struct exarg {
linenr_T line2; ///< the second line number or count
cmd_addr_T addr_type; ///< type of the count/range
int flags; ///< extra flags after count: EXFLAG_
- char_u *do_ecmd_cmd; ///< +command arg to be used in edited file
+ char_u *do_ecmd_cmd; ///< +command arg to be used in edited file
linenr_T do_ecmd_lnum; ///< the line number in an edited file
int append; ///< TRUE with ":w >>file" command
int usefilter; ///< TRUE with ":w !command" and ":r!command"
@@ -170,7 +170,7 @@ struct exarg {
int useridx; ///< user command index
char_u *errmsg; ///< returned error message
LineGetter getline; ///< Function used to get the next line
- void *cookie; ///< argument for getline()
+ void *cookie; ///< argument for getline()
cstack_T *cstack; ///< condition stack for ":if" etc.
long verbose_save; ///< saved value of p_verbose
int save_msg_silent; ///< saved value of msg_silent
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index bf77711642..5193391442 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -9433,14 +9433,14 @@ static void ex_filetype(exarg_T *eap)
}
if (STRCMP(arg, "on") == 0 || STRCMP(arg, "detect") == 0) {
if (*arg == 'o' || !filetype_detect) {
- source_runtime((char_u *)FILETYPE_FILE, DIP_ALL);
+ source_runtime(FILETYPE_FILE, DIP_ALL);
filetype_detect = kTrue;
if (plugin) {
- source_runtime((char_u *)FTPLUGIN_FILE, DIP_ALL);
+ source_runtime(FTPLUGIN_FILE, DIP_ALL);
filetype_plugin = kTrue;
}
if (indent) {
- source_runtime((char_u *)INDENT_FILE, DIP_ALL);
+ source_runtime(INDENT_FILE, DIP_ALL);
filetype_indent = kTrue;
}
}
@@ -9451,15 +9451,15 @@ static void ex_filetype(exarg_T *eap)
} else if (STRCMP(arg, "off") == 0) {
if (plugin || indent) {
if (plugin) {
- source_runtime((char_u *)FTPLUGOF_FILE, DIP_ALL);
+ source_runtime(FTPLUGOF_FILE, DIP_ALL);
filetype_plugin = kFalse;
}
if (indent) {
- source_runtime((char_u *)INDOFF_FILE, DIP_ALL);
+ source_runtime(INDOFF_FILE, DIP_ALL);
filetype_indent = kFalse;
}
} else {
- source_runtime((char_u *)FTOFF_FILE, DIP_ALL);
+ source_runtime(FTOFF_FILE, DIP_ALL);
filetype_detect = kFalse;
}
} else {
@@ -9471,15 +9471,15 @@ static void ex_filetype(exarg_T *eap)
void filetype_maybe_enable(void)
{
if (filetype_detect == kNone) {
- source_runtime((char_u *)FILETYPE_FILE, true);
+ source_runtime(FILETYPE_FILE, true);
filetype_detect = kTrue;
}
if (filetype_plugin == kNone) {
- source_runtime((char_u *)FTPLUGIN_FILE, true);
+ source_runtime(FTPLUGIN_FILE, true);
filetype_plugin = kTrue;
}
if (filetype_indent == kNone) {
- source_runtime((char_u *)INDENT_FILE, true);
+ source_runtime(INDENT_FILE, true);
filetype_indent = kTrue;
}
}
diff --git a/src/nvim/ex_docmd.h b/src/nvim/ex_docmd.h
index 8a78ca0337..7ec4fad277 100644
--- a/src/nvim/ex_docmd.h
+++ b/src/nvim/ex_docmd.h
@@ -13,7 +13,7 @@
#define DOCMD_KEEPLINE 0x20 // keep typed line for repeating with "."
#define DOCMD_PREVIEW 0x40 // during 'inccommand' preview
-/* defines for eval_vars() */
+// defines for eval_vars()
#define VALID_PATH 1
#define VALID_HEAD 2
diff --git a/src/nvim/ex_eval.h b/src/nvim/ex_eval.h
index d8388c9156..d3ba43a469 100644
--- a/src/nvim/ex_eval.h
+++ b/src/nvim/ex_eval.h
@@ -1,22 +1,22 @@
#ifndef NVIM_EX_EVAL_H
#define NVIM_EX_EVAL_H
-#include "nvim/pos.h" // for linenr_T
#include "nvim/ex_cmds_defs.h" // for exarg_T
+#include "nvim/pos.h" // for linenr_T
/* There is no CSF_IF, the lack of CSF_WHILE, CSF_FOR and CSF_TRY means ":if"
* was used. */
-# define CSF_TRUE 0x0001 /* condition was TRUE */
-# define CSF_ACTIVE 0x0002 /* current state is active */
-# define CSF_ELSE 0x0004 /* ":else" has been passed */
-# define CSF_WHILE 0x0008 /* is a ":while" */
-# define CSF_FOR 0x0010 /* is a ":for" */
+#define CSF_TRUE 0x0001 // condition was TRUE
+#define CSF_ACTIVE 0x0002 // current state is active
+#define CSF_ELSE 0x0004 // ":else" has been passed
+#define CSF_WHILE 0x0008 // is a ":while"
+#define CSF_FOR 0x0010 // is a ":for"
-# define CSF_TRY 0x0100 /* is a ":try" */
-# define CSF_FINALLY 0x0200 /* ":finally" has been passed */
-# define CSF_THROWN 0x0400 /* exception thrown to this try conditional */
-# define CSF_CAUGHT 0x0800 /* exception caught by this try conditional */
-# define CSF_SILENT 0x1000 /* "emsg_silent" reset by ":try" */
+#define CSF_TRY 0x0100 // is a ":try"
+#define CSF_FINALLY 0x0200 // ":finally" has been passed
+#define CSF_THROWN 0x0400 // exception thrown to this try conditional
+#define CSF_CAUGHT 0x0800 // exception caught by this try conditional
+#define CSF_SILENT 0x1000 // "emsg_silent" reset by ":try"
/* Note that CSF_ELSE is only used when CSF_TRY and CSF_WHILE are unset
* (an ":if"), and CSF_SILENT is only used when CSF_TRY is set. */
@@ -24,14 +24,14 @@
* What's pending for being reactivated at the ":endtry" of this try
* conditional:
*/
-# define CSTP_NONE 0 /* nothing pending in ":finally" clause */
-# define CSTP_ERROR 1 /* an error is pending */
-# define CSTP_INTERRUPT 2 /* an interrupt is pending */
-# define CSTP_THROW 4 /* a throw is pending */
-# define CSTP_BREAK 8 /* ":break" is pending */
-# define CSTP_CONTINUE 16 /* ":continue" is pending */
-# define CSTP_RETURN 24 /* ":return" is pending */
-# define CSTP_FINISH 32 /* ":finish" is pending */
+#define CSTP_NONE 0 // nothing pending in ":finally" clause
+#define CSTP_ERROR 1 // an error is pending
+#define CSTP_INTERRUPT 2 // an interrupt is pending
+#define CSTP_THROW 4 // a throw is pending
+#define CSTP_BREAK 8 // ":break" is pending
+#define CSTP_CONTINUE 16 // ":continue" is pending
+#define CSTP_RETURN 24 // ":return" is pending
+#define CSTP_FINISH 32 // ":finish" is pending
/*
* A list of error messages that can be converted to an exception. "throw_msg"
@@ -40,9 +40,9 @@
* message in the list. See cause_errthrow() below.
*/
struct msglist {
- char_u *msg; /* original message */
- char_u *throw_msg; /* msg to throw: usually original one */
- struct msglist *next; /* next of several messages in a row */
+ char_u *msg; // original message
+ char_u *throw_msg; // msg to throw: usually original one
+ struct msglist *next; // next of several messages in a row
};
// The exception types.
@@ -60,11 +60,11 @@ typedef enum
typedef struct vim_exception except_T;
struct vim_exception {
except_type_T type; // exception type
- char_u *value; // exception value
- struct msglist *messages; // message(s) causing error exception
- char_u *throw_name; // name of the throw point
+ char_u *value; // exception value
+ struct msglist *messages; // message(s) causing error exception
+ char_u *throw_name; // name of the throw point
linenr_T throw_lnum; // line number of the throw point
- except_T *caught; // next exception on the caught stack
+ except_T *caught; // next exception on the caught stack
};
/*
@@ -74,8 +74,8 @@ struct vim_exception {
*/
typedef struct cleanup_stuff cleanup_T;
struct cleanup_stuff {
- int pending; /* error/interrupt/exception state */
- except_T *exception; /* exception value */
+ int pending; // error/interrupt/exception state
+ except_T *exception; // exception value
};
#ifdef INCLUDE_GENERATED_DECLARATIONS
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 14522a4cba..62a4d48645 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -6595,7 +6595,7 @@ char *script_get(exarg_T *const eap, size_t *const lenp)
}
if (!eap->skip) {
- ga_concat(&ga, (const char_u *)theline);
+ ga_concat(&ga, theline);
ga_append(&ga, '\n');
}
xfree(theline);
diff --git a/src/nvim/ex_getln.h b/src/nvim/ex_getln.h
index 3727aa5e62..fe2bf958b5 100644
--- a/src/nvim/ex_getln.h
+++ b/src/nvim/ex_getln.h
@@ -7,7 +7,7 @@
#include "nvim/os/time.h"
#include "nvim/regexp_defs.h"
-/* Values for nextwild() and ExpandOne(). See ExpandOne() for meaning. */
+// Values for nextwild() and ExpandOne(). See ExpandOne() for meaning.
#define WILD_FREE 1
#define WILD_EXPAND_FREE 2
#define WILD_EXPAND_KEEP 3
diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c
index 4aadd77d45..1e1da6a9a3 100644
--- a/src/nvim/ex_session.c
+++ b/src/nvim/ex_session.c
@@ -859,7 +859,7 @@ void ex_loadview(exarg_T *eap)
{
char *fname = get_view_file(*eap->arg);
if (fname != NULL) {
- if (do_source((char_u *)fname, false, DOSO_NONE) == FAIL) {
+ if (do_source(fname, false, DOSO_NONE) == FAIL) {
EMSG2(_(e_notopen), fname);
}
xfree(fname);
diff --git a/src/nvim/extmark.c b/src/nvim/extmark.c
index cf01c305d7..dc73e34111 100644
--- a/src/nvim/extmark.c
+++ b/src/nvim/extmark.c
@@ -723,7 +723,7 @@ void extmark_move_region(buf_T *buf, int start_row, colnr_T start_col, bcount_t
uint64_t src2ns(Integer *src_id)
{
if (*src_id == 0) {
- *src_id = (Integer)nvim_create_namespace((String)STRING_INIT);
+ *src_id = nvim_create_namespace((String)STRING_INIT);
}
if (*src_id < 0) {
return UINT64_MAX;
diff --git a/src/nvim/extmark.h b/src/nvim/extmark.h
index 1bc42322a3..aee679a9c7 100644
--- a/src/nvim/extmark.h
+++ b/src/nvim/extmark.h
@@ -1,10 +1,10 @@
#ifndef NVIM_EXTMARK_H
#define NVIM_EXTMARK_H
-#include "nvim/pos.h"
#include "nvim/buffer_defs.h"
#include "nvim/extmark_defs.h"
#include "nvim/marktree.h"
+#include "nvim/pos.h"
EXTERN int extmark_splice_pending INIT(= 0);
diff --git a/src/nvim/extmark_defs.h b/src/nvim/extmark_defs.h
index 2da4f3dc00..c0a4f4014f 100644
--- a/src/nvim/extmark_defs.h
+++ b/src/nvim/extmark_defs.h
@@ -1,8 +1,8 @@
#ifndef NVIM_EXTMARK_DEFS_H
#define NVIM_EXTMARK_DEFS_H
-#include "nvim/types.h"
#include "nvim/lib/kvec.h"
+#include "nvim/types.h"
typedef struct Decoration Decoration;
diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c
index d364895ea4..5458d8acf2 100644
--- a/src/nvim/file_search.c
+++ b/src/nvim/file_search.c
@@ -1664,13 +1664,13 @@ int vim_chdirfile(char_u *fname)
/// Change directory to "new_dir". Search 'cdpath' for relative directory names.
int vim_chdir(char_u *new_dir)
{
- char_u *dir_name = find_directory_in_path(new_dir, STRLEN(new_dir),
- FNAME_MESS, curbuf->b_ffname);
+ char *dir_name = (char *)find_directory_in_path(new_dir, STRLEN(new_dir),
+ FNAME_MESS, curbuf->b_ffname);
if (dir_name == NULL) {
return -1;
}
- int r = os_chdir((char *)dir_name);
+ int r = os_chdir(dir_name);
xfree(dir_name);
return r;
}
diff --git a/src/nvim/file_search.h b/src/nvim/file_search.h
index b128029123..4d4e723922 100644
--- a/src/nvim/file_search.h
+++ b/src/nvim/file_search.h
@@ -1,15 +1,15 @@
#ifndef NVIM_FILE_SEARCH_H
#define NVIM_FILE_SEARCH_H
-#include <stdlib.h> // for size_t
+#include <stdlib.h> // for size_t
-#include "nvim/types.h" // for char_u
-#include "nvim/globals.h" // for CdScope
+#include "nvim/globals.h" // for CdScope
+#include "nvim/types.h" // for char_u
-/* Flags for find_file_*() functions. */
-#define FINDFILE_FILE 0 /* only files */
-#define FINDFILE_DIR 1 /* only directories */
-#define FINDFILE_BOTH 2 /* files and directories */
+// Flags for find_file_*() functions.
+#define FINDFILE_FILE 0 // only files
+#define FINDFILE_DIR 1 // only directories
+#define FINDFILE_BOTH 2 // files and directories
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "file_search.h.generated.h"
diff --git a/src/nvim/fileio.h b/src/nvim/fileio.h
index 71149bdcc1..9bfec44ef3 100644
--- a/src/nvim/fileio.h
+++ b/src/nvim/fileio.h
@@ -1,9 +1,9 @@
#ifndef NVIM_FILEIO_H
#define NVIM_FILEIO_H
+#include "nvim/autocmd.h"
#include "nvim/buffer_defs.h"
#include "nvim/os/os.h"
-#include "nvim/autocmd.h"
// Values for readfile() flags
#define READ_NEW 0x01 // read a file into a new buffer
diff --git a/src/nvim/fold.c b/src/nvim/fold.c
index e3b692c63c..e141f9bb62 100644
--- a/src/nvim/fold.c
+++ b/src/nvim/fold.c
@@ -1838,8 +1838,7 @@ char_u *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume, foldinfo_T foldin
curbuf = wp->w_buffer;
emsg_silent++; // handle exceptions, but don't display errors
- text = eval_to_string_safe(wp->w_p_fdt, NULL,
- was_set_insecurely(wp, (char_u *)"foldtext", OPT_LOCAL));
+ text = eval_to_string_safe(wp->w_p_fdt, NULL, was_set_insecurely(wp, "foldtext", OPT_LOCAL));
emsg_silent--;
if (text == NULL || did_emsg) {
diff --git a/src/nvim/fold.h b/src/nvim/fold.h
index 37fab4da60..a96ea8a039 100644
--- a/src/nvim/fold.h
+++ b/src/nvim/fold.h
@@ -3,17 +3,17 @@
#include <stdio.h>
-#include "nvim/pos.h"
+#include "nvim/buffer_defs.h"
#include "nvim/garray.h"
+#include "nvim/pos.h"
#include "nvim/types.h"
-#include "nvim/buffer_defs.h"
/*
* Info used to pass info about a fold from the fold-detection code to the
* code that displays the foldcolumn.
*/
typedef struct foldinfo {
- linenr_T fi_lnum; /* line number where fold starts */
+ linenr_T fi_lnum; // line number where fold starts
int fi_level; /* level of the fold; when this is zero the
other fields are invalid */
int fi_low_level; /* lowest fold level that starts in the same
diff --git a/src/nvim/func_attr.h b/src/nvim/func_attr.h
index e0b0610646..afbd87f2be 100644
--- a/src/nvim/func_attr.h
+++ b/src/nvim/func_attr.h
@@ -1,24 +1,24 @@
-// If DEFINE_FUNC_ATTRIBUTES macro is not defined then all function attributes
+// If DEFINE_FUNC_ATTRIBUTES macro is not defined then all function attributes
// are defined as empty values.
//
-// If DO_NOT_DEFINE_EMPTY_ATTRIBUTES then empty macros are not defined. Thus
-// undefined DEFINE_FUNC_ATTRIBUTES and defined DO_NOT_DEFINE_EMPTY_ATTRIBUTES
-// leaves file with untouched FUNC_ATTR_* macros. This variant is used for
+// If DO_NOT_DEFINE_EMPTY_ATTRIBUTES then empty macros are not defined. Thus
+// undefined DEFINE_FUNC_ATTRIBUTES and defined DO_NOT_DEFINE_EMPTY_ATTRIBUTES
+// leaves file with untouched FUNC_ATTR_* macros. This variant is used for
// scripts/gendeclarations.lua.
//
-// Empty macros are used for *.c files. (undefined DEFINE_FUNC_ATTRIBUTES and
+// Empty macros are used for *.c files. (undefined DEFINE_FUNC_ATTRIBUTES and
// undefined DO_NOT_DEFINE_EMPTY_ATTRIBUTES)
//
-// Macros defined as __attribute__((*)) are used by generated header files.
-// (defined DEFINE_FUNC_ATTRIBUTES and undefined
+// Macros defined as __attribute__((*)) are used by generated header files.
+// (defined DEFINE_FUNC_ATTRIBUTES and undefined
// DO_NOT_DEFINE_EMPTY_ATTRIBUTES)
//
-// Defined DEFINE_FUNC_ATTRIBUTES and defined DO_NOT_DEFINE_EMPTY_ATTRIBUTES is
+// Defined DEFINE_FUNC_ATTRIBUTES and defined DO_NOT_DEFINE_EMPTY_ATTRIBUTES is
// not used by anything.
-// FUNC_ATTR_* macros should be in *.c files for declarations generator. If you
-// define a function for which declaration is not generated by
-// gendeclarations.lua (e.g. template hash implementation) then you should use
+// FUNC_ATTR_* macros should be in *.c files for declarations generator. If you
+// define a function for which declaration is not generated by
+// gendeclarations.lua (e.g. template hash implementation) then you should use
// REAL_FATTR_* macros.
// gcc and clang expose their version as follows:
@@ -134,10 +134,10 @@
# if NVIM_HAS_ATTRIBUTE(no_sanitize_undefined)
# define REAL_FATTR_NO_SANITIZE_UNDEFINED \
- __attribute__((no_sanitize_undefined))
+ __attribute__((no_sanitize_undefined))
# elif NVIM_HAS_ATTRIBUTE(no_sanitize)
# define REAL_FATTR_NO_SANITIZE_UNDEFINED \
- __attribute__((no_sanitize("undefined")))
+ __attribute__((no_sanitize("undefined")))
# endif
# endif
diff --git a/src/nvim/garray.c b/src/nvim/garray.c
index bc3b7211c9..7a3cc4a944 100644
--- a/src/nvim/garray.c
+++ b/src/nvim/garray.c
@@ -143,14 +143,14 @@ void ga_remove_duplicate_strings(garray_T *gap)
/// @param sep
///
/// @returns the concatenated strings
-char_u *ga_concat_strings_sep(const garray_T *gap, const char *sep)
+char *ga_concat_strings_sep(const garray_T *gap, const char *sep)
FUNC_ATTR_NONNULL_RET
{
const size_t nelem = (size_t)gap->ga_len;
const char **strings = gap->ga_data;
if (nelem == 0) {
- return (char_u *)xstrdup("");
+ return xstrdup("");
}
size_t len = 0;
@@ -169,7 +169,7 @@ char_u *ga_concat_strings_sep(const garray_T *gap, const char *sep)
}
strcpy(s, strings[nelem - 1]);
- return (char_u *)ret;
+ return ret;
}
/// For a growing array that contains a list of strings: concatenate all the
@@ -180,7 +180,7 @@ char_u *ga_concat_strings_sep(const garray_T *gap, const char *sep)
/// @returns the concatenated strings
char_u *ga_concat_strings(const garray_T *gap) FUNC_ATTR_NONNULL_RET
{
- return ga_concat_strings_sep(gap, ",");
+ return (char_u *)ga_concat_strings_sep(gap, ",");
}
/// Concatenate a string to a growarray which contains characters.
@@ -192,13 +192,13 @@ char_u *ga_concat_strings(const garray_T *gap) FUNC_ATTR_NONNULL_RET
///
/// @param gap
/// @param s
-void ga_concat(garray_T *gap, const char_u *restrict s)
+void ga_concat(garray_T *gap, const char *restrict s)
{
if (s == NULL) {
return;
}
- ga_concat_len(gap, (const char *restrict)s, strlen((char *)s));
+ ga_concat_len(gap, s, STRLEN(s));
}
/// Concatenate a string to a growarray which contains characters
diff --git a/src/nvim/garray.h b/src/nvim/garray.h
index e2cbdd4eab..56bd5c9130 100644
--- a/src/nvim/garray.h
+++ b/src/nvim/garray.h
@@ -3,8 +3,8 @@
#include <stddef.h> // for size_t
-#include "nvim/types.h" // for char_u
#include "nvim/log.h"
+#include "nvim/types.h" // for char_u
/// Structure used for growing arrays.
/// This is used to store information that only grows, is deleted all at
@@ -68,6 +68,6 @@ static inline void *ga_append_via_ptr(garray_T *gap, size_t item_size)
/// garray.
///
/// @param gap the garray to be freed
-#define GA_DEEP_CLEAR_PTR(gap) GA_DEEP_CLEAR(gap, void*, FREE_PTR_PTR)
+#define GA_DEEP_CLEAR_PTR(gap) GA_DEEP_CLEAR(gap, void *, FREE_PTR_PTR)
#endif // NVIM_GARRAY_H
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index f5f8a307d1..eb836b9005 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -293,7 +293,6 @@ static void add_buff(buffheader_T *const buf, const char *const s, ptrdiff_t sle
buf->bh_curr->b_next = p;
buf->bh_curr = p;
}
- return;
}
/*
@@ -2661,12 +2660,11 @@ void set_maparg_lhs_rhs(const char_u *orig_lhs, const size_t orig_lhs_len, const
char_u *replaced = replace_termcodes(orig_lhs, orig_lhs_len, &lhs_buf,
true, true, true, cpo_flags);
mapargs->lhs_len = STRLEN(replaced);
- xstrlcpy((char *)mapargs->lhs, (char *)replaced, sizeof(mapargs->lhs));
+ STRLCPY(mapargs->lhs, replaced, sizeof(mapargs->lhs));
mapargs->orig_rhs_len = orig_rhs_len;
mapargs->orig_rhs = xcalloc(mapargs->orig_rhs_len + 1, sizeof(char_u));
- xstrlcpy((char *)mapargs->orig_rhs, (char *)orig_rhs,
- mapargs->orig_rhs_len + 1);
+ STRLCPY(mapargs->orig_rhs, orig_rhs, mapargs->orig_rhs_len + 1);
if (STRICMP(orig_rhs, "<nop>") == 0) { // "<Nop>" means nothing
mapargs->rhs = xcalloc(1, sizeof(char_u)); // single null-char
@@ -2678,7 +2676,7 @@ void set_maparg_lhs_rhs(const char_u *orig_lhs, const size_t orig_lhs_len, const
mapargs->rhs_len = STRLEN(replaced);
mapargs->rhs_is_noop = false;
mapargs->rhs = xcalloc(mapargs->rhs_len + 1, sizeof(char_u));
- xstrlcpy((char *)mapargs->rhs, (char *)replaced, mapargs->rhs_len + 1);
+ STRLCPY(mapargs->rhs, replaced, mapargs->rhs_len + 1);
}
xfree(lhs_buf);
@@ -2786,7 +2784,7 @@ int str_to_mapargs(const char_u *strargs, bool is_unmap, MapArguments *mapargs)
// (e.g. "<Space>" is longer than ' '), so first copy into a buffer.
size_t orig_lhs_len = (size_t)(lhs_end - to_parse);
char_u *lhs_to_replace = xcalloc(orig_lhs_len + 1, sizeof(char_u));
- xstrlcpy((char *)lhs_to_replace, (char *)to_parse, orig_lhs_len + 1);
+ STRLCPY(lhs_to_replace, to_parse, orig_lhs_len + 1);
size_t orig_rhs_len = STRLEN(rhs_start);
set_maparg_lhs_rhs(lhs_to_replace, orig_lhs_len,
@@ -4471,7 +4469,7 @@ static char_u *translate_mapping(char_u *str, int cpo_flags)
str += 2;
}
if (IS_SPECIAL(c) || modifiers) { // special key
- ga_concat(&ga, get_special_key_name(c, modifiers));
+ ga_concat(&ga, (char *)get_special_key_name(c, modifiers));
continue; // for (str)
}
}
@@ -4565,7 +4563,7 @@ char_u *getcmdkeycmd(int promptc, void *cookie, int indent, bool do_concat)
aborted = true;
} else if (IS_SPECIAL(c1)) {
if (c1 == K_SNR) {
- ga_concat(&line_ga, (char_u *)"<SNR>");
+ ga_concat(&line_ga, "<SNR>");
} else {
EMSG2(e_cmdmap_key, get_special_key_name(c1, cmod));
aborted = true;
diff --git a/src/nvim/getchar.h b/src/nvim/getchar.h
index 83fa00977f..4e9dd2eab7 100644
--- a/src/nvim/getchar.h
+++ b/src/nvim/getchar.h
@@ -1,10 +1,10 @@
#ifndef NVIM_GETCHAR_H
#define NVIM_GETCHAR_H
-#include "nvim/os/fileio.h"
-#include "nvim/types.h"
#include "nvim/buffer_defs.h"
#include "nvim/ex_cmds_defs.h"
+#include "nvim/os/fileio.h"
+#include "nvim/types.h"
#include "nvim/vim.h"
/// Values for "noremap" argument of ins_typebuf()
diff --git a/src/nvim/globals.h b/src/nvim/globals.h
index 4d54907a75..8a36b3bedd 100644
--- a/src/nvim/globals.h
+++ b/src/nvim/globals.h
@@ -1,23 +1,23 @@
#ifndef NVIM_GLOBALS_H
#define NVIM_GLOBALS_H
-#include <stdbool.h>
#include <inttypes.h>
+#include <stdbool.h>
-#include "nvim/macros.h"
+#include "nvim/event/loop.h"
#include "nvim/ex_eval.h"
#include "nvim/iconv.h"
+#include "nvim/macros.h"
#include "nvim/mbyte.h"
#include "nvim/menu.h"
+#include "nvim/os/os_defs.h"
#include "nvim/syntax_defs.h"
#include "nvim/types.h"
-#include "nvim/event/loop.h"
-#include "nvim/os/os_defs.h"
#define IOSIZE (1024+1) // file I/O and sprintf buffer size
-# define MSG_BUF_LEN 480 // length of buffer for small messages
-# define MSG_BUF_CLEN (MSG_BUF_LEN / 6) // cell length (worst case: utf-8
+#define MSG_BUF_LEN 480 // length of buffer for small messages
+#define MSG_BUF_CLEN (MSG_BUF_LEN / 6) // cell length (worst case: utf-8
// takes 6 bytes for one cell)
#ifdef WIN32
@@ -169,16 +169,16 @@ EXTERN bool compl_busy INIT(= false);
// List of flags for method of completion.
EXTERN int compl_cont_status INIT(= 0);
-# define CONT_ADDING 1 // "normal" or "adding" expansion
-# define CONT_INTRPT (2 + 4) // a ^X interrupted the current expansion
- // it's set only iff N_ADDS is set
-# define CONT_N_ADDS 4 // next ^X<> will add-new or expand-current
-# define CONT_S_IPOS 8 // next ^X<> will set initial_pos?
- // if so, word-wise-expansion will set SOL
-# define CONT_SOL 16 // pattern includes start of line, just for
- // word-wise expansion, not set for ^X^L
-# define CONT_LOCAL 32 // for ctrl_x_mode 0, ^X^P/^X^N do a local
- // expansion, (eg use complete=.)
+#define CONT_ADDING 1 // "normal" or "adding" expansion
+#define CONT_INTRPT (2 + 4) // a ^X interrupted the current expansion
+ // it's set only iff N_ADDS is set
+#define CONT_N_ADDS 4 // next ^X<> will add-new or expand-current
+#define CONT_S_IPOS 8 // next ^X<> will set initial_pos?
+ // if so, word-wise-expansion will set SOL
+#define CONT_SOL 16 // pattern includes start of line, just for
+ // word-wise expansion, not set for ^X^L
+#define CONT_LOCAL 32 // for ctrl_x_mode 0, ^X^P/^X^N do a local
+ // expansion, (eg use complete=.)
EXTERN char_u *edit_submode INIT(= NULL); // msg for CTRL-X submode
EXTERN char_u *edit_submode_pre INIT(= NULL); // prepended to edit_submode
@@ -335,7 +335,7 @@ EXTERN int garbage_collect_at_exit INIT(= false);
#define SID_WINLAYOUT -7 // changing window size
#define SID_LUA -8 // for Lua scripts/chunks
#define SID_API_CLIENT -9 // for API clients
-#define SID_STR -10 // for sourcing a string
+#define SID_STR -10 // for sourcing a string with no script item
// Script CTX being sourced or was sourced to define the current function.
EXTERN sctx_T current_sctx INIT(= { 0 COMMA 0 COMMA 0 });
@@ -405,7 +405,7 @@ EXTERN int mouse_dragging INIT(= 0); // extending Visual area with
// mouse dragging
// The root of the menu hierarchy.
-EXTERN vimmenu_T *root_menu INIT(= NULL);
+EXTERN vimmenu_T *root_menu INIT(= NULL);
// While defining the system menu, sys_menu is true. This avoids
// overruling of menus that the user already defined.
EXTERN int sys_menu INIT(= false);
@@ -417,48 +417,48 @@ EXTERN int updating_screen INIT(= 0);
// All windows are linked in a list. firstwin points to the first entry,
// lastwin to the last entry (can be the same as firstwin) and curwin to the
// currently active window.
-EXTERN win_T *firstwin; // first window
-EXTERN win_T *lastwin; // last window
-EXTERN win_T *prevwin INIT(= NULL); // previous window
-# define ONE_WINDOW (firstwin == lastwin)
-# define FOR_ALL_FRAMES(frp, first_frame) \
+EXTERN win_T *firstwin; // first window
+EXTERN win_T *lastwin; // last window
+EXTERN win_T *prevwin INIT(= NULL); // previous window
+#define ONE_WINDOW (firstwin == lastwin)
+#define FOR_ALL_FRAMES(frp, first_frame) \
for (frp = first_frame; frp != NULL; frp = frp->fr_next) // NOLINT
// When using this macro "break" only breaks out of the inner loop. Use "goto"
// to break out of the tabpage loop.
-# define FOR_ALL_TAB_WINDOWS(tp, wp) \
+#define FOR_ALL_TAB_WINDOWS(tp, wp) \
FOR_ALL_TABS(tp) \
- FOR_ALL_WINDOWS_IN_TAB(wp, tp)
+ FOR_ALL_WINDOWS_IN_TAB(wp, tp)
// -V:FOR_ALL_WINDOWS_IN_TAB:501
-# define FOR_ALL_WINDOWS_IN_TAB(wp, tp) \
+#define FOR_ALL_WINDOWS_IN_TAB(wp, tp) \
for (win_T *wp = ((tp) == curtab) \
? firstwin : (tp)->tp_firstwin; wp != NULL; wp = wp->w_next)
-EXTERN win_T *curwin; // currently active window
+EXTERN win_T *curwin; // currently active window
-EXTERN win_T *aucmd_win; // window used in aucmd_prepbuf()
+EXTERN win_T *aucmd_win; // window used in aucmd_prepbuf()
EXTERN int aucmd_win_used INIT(= false); // aucmd_win is being used
// The window layout is kept in a tree of frames. topframe points to the top
// of the tree.
-EXTERN frame_T *topframe; // top of the window frame tree
+EXTERN frame_T *topframe; // top of the window frame tree
// Tab pages are alternative topframes. "first_tabpage" points to the first
// one in the list, "curtab" is the current one.
-EXTERN tabpage_T *first_tabpage;
-EXTERN tabpage_T *lastused_tabpage;
-EXTERN tabpage_T *curtab;
+EXTERN tabpage_T *first_tabpage;
+EXTERN tabpage_T *lastused_tabpage;
+EXTERN tabpage_T *curtab;
EXTERN bool redraw_tabline INIT(= false); // need to redraw tabline
// Iterates over all tabs in the tab list
-# define FOR_ALL_TABS(tp) for (tabpage_T *tp = first_tabpage; tp != NULL; tp = tp->tp_next)
+#define FOR_ALL_TABS(tp) for (tabpage_T *tp = first_tabpage; tp != NULL; tp = tp->tp_next)
// All buffers are linked in a list. 'firstbuf' points to the first entry,
// 'lastbuf' to the last entry and 'curbuf' to the currently active buffer.
EXTERN buf_T *firstbuf INIT(= NULL); // first buffer
-EXTERN buf_T *lastbuf INIT(= NULL); // last buffer
-EXTERN buf_T *curbuf INIT(= NULL); // currently active buffer
+EXTERN buf_T *lastbuf INIT(= NULL); // last buffer
+EXTERN buf_T *curbuf INIT(= NULL); // currently active buffer
// Iterates over all buffers in the buffer list.
#define FOR_ALL_BUFFERS(buf) \
@@ -593,16 +593,16 @@ EXTERN int inhibit_delete_count INIT(= 0);
// These flags are set based upon 'fileencoding'.
// The characters are internally stored as UTF-8
// to avoid trouble with NUL bytes.
-# define DBCS_JPN 932 // japan
-# define DBCS_JPNU 9932 // euc-jp
-# define DBCS_KOR 949 // korea
-# define DBCS_KORU 9949 // euc-kr
-# define DBCS_CHS 936 // chinese
-# define DBCS_CHSU 9936 // euc-cn
-# define DBCS_CHT 950 // taiwan
-# define DBCS_CHTU 9950 // euc-tw
-# define DBCS_2BYTE 1 // 2byte-
-# define DBCS_DEBUG -1
+#define DBCS_JPN 932 // japan
+#define DBCS_JPNU 9932 // euc-jp
+#define DBCS_KOR 949 // korea
+#define DBCS_KORU 9949 // euc-kr
+#define DBCS_CHS 936 // chinese
+#define DBCS_CHSU 9936 // euc-cn
+#define DBCS_CHT 950 // taiwan
+#define DBCS_CHTU 9950 // euc-tw
+#define DBCS_2BYTE 1 // 2byte-
+#define DBCS_DEBUG -1
/// Encoding used when 'fencs' is set to "default"
EXTERN char_u *fenc_default INIT(= NULL);
@@ -669,12 +669,12 @@ EXTERN bool swap_exists_did_quit INIT(= false);
EXTERN char_u IObuff[IOSIZE]; ///< Buffer for sprintf, I/O, etc.
EXTERN char_u NameBuff[MAXPATHL]; ///< Buffer for expanding file names
-EXTERN char_u msg_buf[MSG_BUF_LEN]; ///< Small buffer for messages
+EXTERN char msg_buf[MSG_BUF_LEN]; ///< Small buffer for messages
EXTERN char os_buf[ ///< Buffer for the os/ layer
#if MAXPATHL > IOSIZE
-MAXPATHL
+ MAXPATHL
#else
-IOSIZE
+ IOSIZE
#endif
];
@@ -746,7 +746,7 @@ EXTERN bool g_tag_at_cursor INIT(= false); // whether the tag command comes
EXTERN int replace_offset INIT(= 0); // offset for replace_push()
-EXTERN char_u *escape_chars INIT(= (char_u *)" \t\\\"|");
+EXTERN char_u *escape_chars INIT(= (char_u *)" \t\\\"|");
// need backslash in cmd line
EXTERN int keep_help_flag INIT(= false); // doing :ta from help file
@@ -754,7 +754,7 @@ EXTERN int keep_help_flag INIT(= false); // doing :ta from help file
// When a string option is NULL (which only happens in out-of-memory
// situations), it is set to empty_option, to avoid having to check for NULL
// everywhere.
-EXTERN char_u *empty_option INIT(= (char_u *)"");
+EXTERN char_u *empty_option INIT(= (char_u *)"");
EXTERN bool redir_off INIT(= false); // no redirection for a moment
EXTERN FILE *redir_fd INIT(= NULL); // message redirection file
@@ -787,7 +787,7 @@ extern char_u *compiled_sys;
// When a window has a local directory, the absolute path of the global
// current directory is stored here (in allocated memory). If the current
// directory is not a local directory, globaldir is NULL.
-EXTERN char_u *globaldir INIT(= NULL);
+EXTERN char_u *globaldir INIT(= NULL);
// Whether 'keymodel' contains "stopsel" and "startsel".
EXTERN bool km_stopsel INIT(= false);
@@ -810,8 +810,8 @@ EXTERN linenr_T sub_nlines; // total number of lines changed
EXTERN char_u wim_flags[4];
// whether titlestring and iconstring contains statusline syntax
-# define STL_IN_ICON 1
-# define STL_IN_TITLE 2
+#define STL_IN_ICON 1
+#define STL_IN_TITLE 2
EXTERN int stl_syntax INIT(= 0);
// don't use 'hlsearch' temporarily
@@ -846,15 +846,16 @@ EXTERN linenr_T spell_redraw_lnum INIT(= 0);
// The error messages that can be shared are included here.
// Excluded are errors that are only used once and debugging messages.
EXTERN char_u e_abort[] INIT(= N_("E470: Command aborted"));
-EXTERN char_u e_afterinit[] INIT(= N_(
- "E905: Cannot set this option after startup"));
+EXTERN char_u e_afterinit[] INIT(= N_("E905: Cannot set this option after startup"));
EXTERN char_u e_api_spawn_failed[] INIT(= N_("E903: Could not spawn API job"));
EXTERN char_u e_argreq[] INIT(= N_("E471: Argument required"));
EXTERN char_u e_backslash[] INIT(= N_("E10: \\ should be followed by /, ? or &"));
-EXTERN char_u e_cmdwin[] INIT(= N_(
- "E11: Invalid in command-line window; <CR> executes, CTRL-C quits"));
-EXTERN char_u e_curdir[] INIT(= N_(
- "E12: Command not allowed from exrc/vimrc in current dir or tag search"));
+EXTERN char_u e_cmdwin[] INIT(=
+ N_(
+ "E11: Invalid in command-line window; <CR> executes, CTRL-C quits"));
+EXTERN char_u e_curdir[] INIT(=
+ N_(
+ "E12: Command not allowed from exrc/vimrc in current dir or tag search"));
EXTERN char_u e_endif[] INIT(= N_("E171: Missing :endif"));
EXTERN char_u e_endtry[] INIT(= N_("E600: Missing :endtry"));
EXTERN char_u e_endwhile[] INIT(= N_("E170: Missing :endwhile"));
@@ -869,8 +870,7 @@ EXTERN char_u e_interr[] INIT(= N_("Interrupted"));
EXTERN char_u e_invarg[] INIT(= N_("E474: Invalid argument"));
EXTERN char_u e_invarg2[] INIT(= N_("E475: Invalid argument: %s"));
EXTERN char_u e_invargval[] INIT(= N_("E475: Invalid value for argument %s"));
-EXTERN char_u e_invargNval[] INIT(= N_(
- "E475: Invalid value for argument %s: %s"));
+EXTERN char_u e_invargNval[] INIT(= N_("E475: Invalid value for argument %s: %s"));
EXTERN char_u e_duparg2[] INIT(= N_("E983: Duplicate argument: %s"));
EXTERN char_u e_invexpr2[] INIT(= N_("E15: Invalid expression: %s"));
EXTERN char_u e_invrange[] INIT(= N_("E16: Invalid range"));
@@ -880,24 +880,21 @@ EXTERN char_u e_no_spell[] INIT(= N_("E756: Spell checking is not possible"));
EXTERN char_u e_invchan[] INIT(= N_("E900: Invalid channel id"));
EXTERN char_u e_invchanjob[] INIT(= N_("E900: Invalid channel id: not a job"));
EXTERN char_u e_jobtblfull[] INIT(= N_("E901: Job table is full"));
-EXTERN char_u e_jobspawn[] INIT(= N_(
- "E903: Process failed to start: %s: \"%s\""));
+EXTERN char_u e_jobspawn[] INIT(= N_("E903: Process failed to start: %s: \"%s\""));
EXTERN char_u e_channotpty[] INIT(= N_("E904: channel is not a pty"));
-EXTERN char_u e_stdiochan2[] INIT(= N_(
- "E905: Couldn't open stdio channel: %s"));
+EXTERN char_u e_stdiochan2[] INIT(= N_("E905: Couldn't open stdio channel: %s"));
EXTERN char_u e_invstream[] INIT(= N_("E906: invalid stream for channel"));
-EXTERN char_u e_invstreamrpc[] INIT(= N_(
- "E906: invalid stream for rpc channel, use 'rpc'"));
-EXTERN char_u e_streamkey[] INIT(= N_(
- "E5210: dict key '%s' already set for buffered stream in channel %"
- PRIu64));
+EXTERN char_u e_invstreamrpc[] INIT(= N_("E906: invalid stream for rpc channel, use 'rpc'"));
+EXTERN char_u e_streamkey[] INIT(=
+ N_(
+ "E5210: dict key '%s' already set for buffered stream in channel %"
+ PRIu64));
EXTERN char_u e_libcall[] INIT(= N_("E364: Library call failed for \"%s()\""));
EXTERN char e_fsync[] INIT(= N_("E667: Fsync failed: %s"));
EXTERN char_u e_mkdir[] INIT(= N_("E739: Cannot create directory %s: %s"));
EXTERN char_u e_markinval[] INIT(= N_("E19: Mark has invalid line number"));
EXTERN char_u e_marknotset[] INIT(= N_("E20: Mark not set"));
-EXTERN char_u e_modifiable[] INIT(= N_(
- "E21: Cannot make changes, 'modifiable' is off"));
+EXTERN char_u e_modifiable[] INIT(= N_("E21: Cannot make changes, 'modifiable' is off"));
EXTERN char_u e_nesting[] INIT(= N_("E22: Scripts nested too deep"));
EXTERN char_u e_noalt[] INIT(= N_("E23: No alternate file"));
EXTERN char_u e_noabbr[] INIT(= N_("E24: No such abbreviation"));
@@ -909,8 +906,7 @@ EXTERN char_u e_nomap[] INIT(= N_("E31: No such mapping"));
EXTERN char_u e_nomatch[] INIT(= N_("E479: No match"));
EXTERN char_u e_nomatch2[] INIT(= N_("E480: No match: %s"));
EXTERN char_u e_noname[] INIT(= N_("E32: No file name"));
-EXTERN char_u e_nopresub[] INIT(= N_(
- "E33: No previous substitute regular expression"));
+EXTERN char_u e_nopresub[] INIT(= N_("E33: No previous substitute regular expression"));
EXTERN char_u e_noprev[] INIT(= N_("E34: No previous command"));
EXTERN char_u e_noprevre[] INIT(= N_("E35: No previous regular expression"));
EXTERN char_u e_norange[] INIT(= N_("E481: No range allowed"));
@@ -926,36 +922,30 @@ EXTERN char_u e_outofmem[] INIT(= N_("E41: Out of memory!"));
EXTERN char_u e_patnotf[] INIT(= N_("Pattern not found"));
EXTERN char_u e_patnotf2[] INIT(= N_("E486: Pattern not found: %s"));
EXTERN char_u e_positive[] INIT(= N_("E487: Argument must be positive"));
-EXTERN char_u e_prev_dir[] INIT(= N_(
- "E459: Cannot go back to previous directory"));
+EXTERN char_u e_prev_dir[] INIT(= N_("E459: Cannot go back to previous directory"));
EXTERN char_u e_quickfix[] INIT(= N_("E42: No Errors"));
EXTERN char_u e_loclist[] INIT(= N_("E776: No location list"));
EXTERN char_u e_re_damg[] INIT(= N_("E43: Damaged match string"));
EXTERN char_u e_re_corr[] INIT(= N_("E44: Corrupted regexp program"));
-EXTERN char_u e_readonly[] INIT(= N_(
- "E45: 'readonly' option is set (add ! to override)"));
-EXTERN char_u e_readonlyvar[] INIT(= N_(
- "E46: Cannot change read-only variable \"%.*s\""));
+EXTERN char_u e_readonly[] INIT(= N_("E45: 'readonly' option is set (add ! to override)"));
+EXTERN char_u e_readonlyvar[] INIT(= N_("E46: Cannot change read-only variable \"%.*s\""));
EXTERN char_u e_stringreq[] INIT(= N_("E928: String required"));
EXTERN char_u e_dictreq[] INIT(= N_("E715: Dictionary required"));
EXTERN char_u e_blobidx[] INIT(= N_("E979: Blob index out of range: %" PRId64));
EXTERN char_u e_invalblob[] INIT(= N_("E978: Invalid operation for Blob"));
-EXTERN char_u e_toomanyarg[] INIT(= N_(
- "E118: Too many arguments for function: %s"));
-EXTERN char_u e_dictkey[] INIT(= N_(
- "E716: Key not present in Dictionary: \"%s\""));
+EXTERN char_u e_toomanyarg[] INIT(= N_("E118: Too many arguments for function: %s"));
+EXTERN char_u e_dictkey[] INIT(= N_("E716: Key not present in Dictionary: \"%s\""));
EXTERN char_u e_listreq[] INIT(= N_("E714: List required"));
EXTERN char_u e_listblobreq[] INIT(= N_("E897: List or Blob required"));
-EXTERN char_u e_listdictarg[] INIT(= N_(
- "E712: Argument of %s must be a List or Dictionary"));
-EXTERN char_u e_listdictblobarg[] INIT(= N_(
- "E896: Argument of %s must be a List, Dictionary or Blob"));
+EXTERN char_u e_listdictarg[] INIT(= N_("E712: Argument of %s must be a List or Dictionary"));
+EXTERN char_u e_listdictblobarg[] INIT(=
+ N_(
+ "E896: Argument of %s must be a List, Dictionary or Blob"));
EXTERN char_u e_readerrf[] INIT(= N_("E47: Error while reading errorfile"));
EXTERN char_u e_sandbox[] INIT(= N_("E48: Not allowed in sandbox"));
EXTERN char_u e_secure[] INIT(= N_("E523: Not allowed here"));
-EXTERN char_u e_screenmode[] INIT(= N_(
- "E359: Screen mode setting not supported"));
+EXTERN char_u e_screenmode[] INIT(= N_("E359: Screen mode setting not supported"));
EXTERN char_u e_scroll[] INIT(= N_("E49: Invalid scroll size"));
EXTERN char_u e_shellempty[] INIT(= N_("E91: 'shell' option is empty"));
EXTERN char_u e_signdata[] INIT(= N_("E255: Couldn't read in sign data!"));
@@ -969,57 +959,44 @@ EXTERN char_u e_trailing[] INIT(= N_("E488: Trailing characters"));
EXTERN char_u e_trailing2[] INIT(= N_("E488: Trailing characters: %s"));
EXTERN char_u e_umark[] INIT(= N_("E78: Unknown mark"));
EXTERN char_u e_wildexpand[] INIT(= N_("E79: Cannot expand wildcards"));
-EXTERN char_u e_winheight[] INIT(= N_(
- "E591: 'winheight' cannot be smaller than 'winminheight'"));
-EXTERN char_u e_winwidth[] INIT(= N_(
- "E592: 'winwidth' cannot be smaller than 'winminwidth'"));
+EXTERN char_u e_winheight[] INIT(= N_("E591: 'winheight' cannot be smaller than 'winminheight'"));
+EXTERN char_u e_winwidth[] INIT(= N_("E592: 'winwidth' cannot be smaller than 'winminwidth'"));
EXTERN char_u e_write[] INIT(= N_("E80: Error while writing"));
EXTERN char_u e_zerocount[] INIT(= N_("E939: Positive count required"));
-EXTERN char_u e_usingsid[] INIT(= N_(
- "E81: Using <SID> not in a script context"));
+EXTERN char_u e_usingsid[] INIT(= N_("E81: Using <SID> not in a script context"));
EXTERN char_u e_missingparen[] INIT(= N_("E107: Missing parentheses: %s"));
-EXTERN char_u e_maxmempat[] INIT(= N_(
- "E363: pattern uses more memory than 'maxmempattern'"));
+EXTERN char_u e_maxmempat[] INIT(= N_("E363: pattern uses more memory than 'maxmempattern'"));
EXTERN char_u e_emptybuf[] INIT(= N_("E749: empty buffer"));
EXTERN char_u e_nobufnr[] INIT(= N_("E86: Buffer %" PRId64 " does not exist"));
-EXTERN char_u e_invalpat[] INIT(= N_(
- "E682: Invalid search pattern or delimiter"));
+EXTERN char_u e_invalpat[] INIT(= N_("E682: Invalid search pattern or delimiter"));
EXTERN char_u e_bufloaded[] INIT(= N_("E139: File is loaded in another buffer"));
EXTERN char_u e_notset[] INIT(= N_("E764: Option '%s' is not set"));
EXTERN char_u e_invalidreg[] INIT(= N_("E850: Invalid register name"));
-EXTERN char_u e_dirnotf[] INIT(= N_(
- "E919: Directory not found in '%s': \"%s\""));
-EXTERN char_u e_au_recursive[] INIT(= N_(
- "E952: Autocommand caused recursive behavior"));
-EXTERN char_u e_autocmd_close[] INIT(= N_(
- "E813: Cannot close autocmd window"));
+EXTERN char_u e_dirnotf[] INIT(= N_("E919: Directory not found in '%s': \"%s\""));
+EXTERN char_u e_au_recursive[] INIT(= N_("E952: Autocommand caused recursive behavior"));
+EXTERN char_u e_autocmd_close[] INIT(= N_("E813: Cannot close autocmd window"));
EXTERN char_u e_unsupportedoption[] INIT(= N_("E519: Option not supported"));
EXTERN char_u e_fnametoolong[] INIT(= N_("E856: Filename too long"));
EXTERN char_u e_float_as_string[] INIT(= N_("E806: using Float as a String"));
-EXTERN char_u e_autocmd_err[] INIT(=N_(
- "E5500: autocmd has thrown an exception: %s"));
-EXTERN char_u e_cmdmap_err[] INIT(=N_(
- "E5520: <Cmd> mapping must end with <CR>"));
-EXTERN char_u e_cmdmap_repeated[] INIT(=N_(
- "E5521: <Cmd> mapping must end with <CR> before second <Cmd>"));
-EXTERN char_u e_cmdmap_key[] INIT(=N_(
- "E5522: <Cmd> mapping must not include %s key"));
+EXTERN char_u e_autocmd_err[] INIT(=N_("E5500: autocmd has thrown an exception: %s"));
+EXTERN char_u e_cmdmap_err[] INIT(=N_("E5520: <Cmd> mapping must end with <CR>"));
+EXTERN char_u
+e_cmdmap_repeated[] INIT(=N_("E5521: <Cmd> mapping must end with <CR> before second <Cmd>"));
+EXTERN char_u e_cmdmap_key[] INIT(=N_("E5522: <Cmd> mapping must not include %s key"));
-EXTERN char_u e_api_error[] INIT(=N_(
- "E5555: API call: %s"));
+EXTERN char_u e_api_error[] INIT(=N_("E5555: API call: %s"));
-EXTERN char e_luv_api_disabled[] INIT(=N_(
- "E5560: %s must not be called in a lua loop callback"));
+EXTERN char e_luv_api_disabled[] INIT(=N_("E5560: %s must not be called in a lua loop callback"));
EXTERN char_u e_floatonly[] INIT(=N_(
- "E5601: Cannot close window, only floating window would remain"));
-EXTERN char_u e_floatexchange[] INIT(=N_(
- "E5602: Cannot exchange or rotate float"));
+ "E5601: Cannot close window, only floating window would remain"));
+EXTERN char_u e_floatexchange[] INIT(=N_("E5602: Cannot exchange or rotate float"));
-EXTERN char e_cannot_define_autocommands_for_all_events[] INIT(= N_(
- "E1155: Cannot define autocommands for ALL events"));
+EXTERN char e_cannot_define_autocommands_for_all_events[] INIT(=
+ N_(
+ "E1155: Cannot define autocommands for ALL events"));
EXTERN char top_bot_msg[] INIT(= N_("search hit TOP, continuing at BOTTOM"));
EXTERN char bot_top_msg[] INIT(= N_("search hit BOTTOM, continuing at TOP"));
diff --git a/src/nvim/grid_defs.h b/src/nvim/grid_defs.h
index dee096214f..bf0a5d63a8 100644
--- a/src/nvim/grid_defs.h
+++ b/src/nvim/grid_defs.h
@@ -48,10 +48,10 @@ typedef struct ScreenGrid ScreenGrid;
struct ScreenGrid {
handle_T handle;
- schar_T *chars;
- sattr_T *attrs;
+ schar_T *chars;
+ sattr_T *attrs;
unsigned *line_offset;
- char_u *line_wraps;
+ char_u *line_wraps;
// last column that was drawn (not cleared with the default background).
// only used when "throttled" is set. Not allocated by grid_alloc!
diff --git a/src/nvim/hardcopy.c b/src/nvim/hardcopy.c
index 9d9ffa550a..99e0bff81c 100644
--- a/src/nvim/hardcopy.c
+++ b/src/nvim/hardcopy.c
@@ -551,7 +551,7 @@ static void prt_header(prt_settings_T *const psettings, const int pagenum, const
curwin->w_botline = lnum + 63;
printer_page_num = pagenum;
- use_sandbox = was_set_insecurely(curwin, (char_u *)"printheader", 0);
+ use_sandbox = was_set_insecurely(curwin, "printheader", 0);
build_stl_str_hl(curwin, tbuf, (size_t)width + IOSIZE,
p_header, use_sandbox,
' ', width, NULL, NULL);
diff --git a/src/nvim/hardcopy.h b/src/nvim/hardcopy.h
index c6a3321b08..eba769d342 100644
--- a/src/nvim/hardcopy.h
+++ b/src/nvim/hardcopy.h
@@ -4,9 +4,9 @@
#include <stdint.h>
#include <stdlib.h> // for size_t
+#include "nvim/ex_cmds_defs.h" // for exarg_T
#include "nvim/globals.h" // for TriState
#include "nvim/types.h" // for char_u
-#include "nvim/ex_cmds_defs.h" // for exarg_T
/*
* Structure to hold printing color and font attributes.
@@ -34,19 +34,19 @@ typedef struct {
int modec;
int do_syntax;
int user_abort;
- char_u *jobname;
- char_u *outfile;
- char_u *arguments;
+ char_u *jobname;
+ char_u *outfile;
+ char_u *arguments;
} prt_settings_T;
/*
* Generic option table item, only used for printer at the moment.
*/
typedef struct {
- const char *name;
+ const char *name;
int hasnum;
int number;
- char_u *string; /* points into option string */
+ char_u *string; // points into option string
int strlen;
int present;
} option_table_T;
@@ -67,13 +67,13 @@ typedef struct {
#define OPT_PRINT_FORMFEED 13
#define OPT_PRINT_NUM_OPTIONS 14
-/* For prt_get_unit(). */
+// For prt_get_unit().
#define PRT_UNIT_NONE -1
#define PRT_UNIT_PERC 0
#define PRT_UNIT_INCH 1
#define PRT_UNIT_MM 2
#define PRT_UNIT_POINT 3
-#define PRT_UNIT_NAMES {"pc", "in", "mm", "pt"}
+#define PRT_UNIT_NAMES { "pc", "in", "mm", "pt" }
#define PRINT_NUMBER_WIDTH 8
diff --git a/src/nvim/hashtab.h b/src/nvim/hashtab.h
index c82a6cc121..7740a3e431 100644
--- a/src/nvim/hashtab.h
+++ b/src/nvim/hashtab.h
@@ -77,18 +77,18 @@ typedef struct hashtable_S {
/// @param hi Name of the variable with current hashtab entry.
/// @param code Cycle body.
#define HASHTAB_ITER(ht, hi, code) \
- do { \
- hashtab_T *const hi##ht_ = (ht); \
- size_t hi##todo_ = hi##ht_->ht_used; \
- for (hashitem_T *hi = hi##ht_->ht_array; hi##todo_; hi++) { \
- if (!HASHITEM_EMPTY(hi)) { \
- hi##todo_--; \
- { \
- code \
- } \
+ do { \
+ hashtab_T *const hi##ht_ = (ht); \
+ size_t hi##todo_ = hi##ht_->ht_used; \
+ for (hashitem_T *hi = hi##ht_->ht_array; hi##todo_; hi++) { \
+ if (!HASHITEM_EMPTY(hi)) { \
+ hi##todo_--; \
+ { \
+ code \
} \
} \
- } while (0)
+ } \
+ } while (0)
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "hashtab.h.generated.h"
diff --git a/src/nvim/highlight.c b/src/nvim/highlight.c
index bb325b3f25..737e668e81 100644
--- a/src/nvim/highlight.c
+++ b/src/nvim/highlight.c
@@ -306,7 +306,7 @@ void update_window_hl(win_T *wp, bool invalid)
// syntax group! It needs at least 10 layers of special casing! Noooooo!
//
// haha, theme engine go brrr
- int normality = syn_check_group((const char_u *)S_LEN("Normal"));
+ int normality = syn_check_group(S_LEN("Normal"));
int ns_attr = ns_get_hl(-1, normality, false, false);
if (ns_attr > 0) {
// TODO(bfredl): hantera NormalNC and so on
@@ -890,7 +890,7 @@ HlAttrs dict2hlattrs(Dictionary dict, bool use_rgb, int *link_id, Error *err)
} else if (link_id && strequal(key, "link")) {
if (val.type == kObjectTypeString) {
String str = val.data.string;
- *link_id = syn_check_group((const char_u *)str.data, (int)str.size);
+ *link_id = syn_check_group(str.data, (int)str.size);
} else if (val.type == kObjectTypeInteger) {
// TODO(bfredl): validate range?
*link_id = (int)val.data.integer;
diff --git a/src/nvim/highlight.h b/src/nvim/highlight.h
index a237ddbc34..ae63f83d65 100644
--- a/src/nvim/highlight.h
+++ b/src/nvim/highlight.h
@@ -2,15 +2,16 @@
#define NVIM_HIGHLIGHT_H
#include <stdbool.h>
-#include "nvim/highlight_defs.h"
+
#include "nvim/api/private/defs.h"
+#include "nvim/highlight_defs.h"
#include "nvim/ui.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "highlight.h.generated.h"
#endif
-# define HL_SET_DEFAULT_COLORS(rgb_fg, rgb_bg, rgb_sp) \
+#define HL_SET_DEFAULT_COLORS(rgb_fg, rgb_bg, rgb_sp) \
do { \
bool dark_ = (*p_bg == 'd'); \
rgb_fg = rgb_fg != -1 ? rgb_fg : (dark_ ? 0xFFFFFF : 0x000000); \
diff --git a/src/nvim/iconv.h b/src/nvim/iconv.h
index a7c9ad4040..509f83c415 100644
--- a/src/nvim/iconv.h
+++ b/src/nvim/iconv.h
@@ -4,17 +4,17 @@
#include "auto/config.h"
#ifdef HAVE_ICONV
-# include <errno.h>
-# include <iconv.h>
+# include <errno.h>
+# include <iconv.h>
// define some missing constants if necessary
-# ifndef EILSEQ
-# define EILSEQ 123
-# endif
-# define ICONV_ERRNO errno
-# define ICONV_E2BIG E2BIG
-# define ICONV_EINVAL EINVAL
-# define ICONV_EILSEQ EILSEQ
+# ifndef EILSEQ
+# define EILSEQ 123
+# endif
+# define ICONV_ERRNO errno
+# define ICONV_E2BIG E2BIG
+# define ICONV_EINVAL EINVAL
+# define ICONV_EILSEQ EILSEQ
#endif
#endif // NVIM_ICONV_H
diff --git a/src/nvim/if_cscope.c b/src/nvim/if_cscope.c
index 76dcb58236..f236b966ca 100644
--- a/src/nvim/if_cscope.c
+++ b/src/nvim/if_cscope.c
@@ -1294,7 +1294,7 @@ static int cs_kill(exarg_T *eap)
}
}
} else {
- cs_kill_execute((size_t)i, stok);
+ cs_kill_execute(i, stok);
}
}
@@ -1559,8 +1559,8 @@ static void cs_fill_results(char *tagstr, size_t totmatches, int *nummatches_a,
assert(totmatches > 0);
buf = xmalloc(CSREAD_BUFSIZE);
- matches = xmalloc(sizeof(char *) * (size_t)totmatches);
- cntxts = xmalloc(sizeof(char *) * (size_t)totmatches);
+ matches = xmalloc(sizeof(char *) * totmatches);
+ cntxts = xmalloc(sizeof(char *) * totmatches);
for (size_t i = 0; i < csinfo_size; i++) {
if (nummatches_a[i] < 1) {
diff --git a/src/nvim/if_cscope.h b/src/nvim/if_cscope.h
index e20462576a..8dbc78943f 100644
--- a/src/nvim/if_cscope.h
+++ b/src/nvim/if_cscope.h
@@ -1,8 +1,8 @@
#ifndef NVIM_IF_CSCOPE_H
#define NVIM_IF_CSCOPE_H
-#include "nvim/types.h" // for char_u and expand_T
-#include "nvim/ex_cmds_defs.h" // for exarg_T
+#include "nvim/ex_cmds_defs.h" // for exarg_T
+#include "nvim/types.h" // for char_u and expand_T
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "if_cscope.h.generated.h"
diff --git a/src/nvim/if_cscope_defs.h b/src/nvim/if_cscope_defs.h
index d2d8b0fb62..39cfd807f9 100644
--- a/src/nvim/if_cscope_defs.h
+++ b/src/nvim/if_cscope_defs.h
@@ -13,9 +13,9 @@
# include <sys/types.h> // pid_t
#endif
-#include "nvim/os/os_defs.h"
-#include "nvim/os/fs_defs.h"
#include "nvim/ex_cmds_defs.h"
+#include "nvim/os/fs_defs.h"
+#include "nvim/os/os_defs.h"
#define CSCOPE_SUCCESS 0
#define CSCOPE_FAILURE -1
@@ -40,11 +40,11 @@ typedef struct csi {
#if defined(UNIX)
pid_t pid; // PID of the connected cscope process
#else
- DWORD pid; // PID of the connected cscope process
- HANDLE hProc; // cscope process handle
- DWORD nVolume; // Volume serial number, instead of st_dev
- DWORD nIndexHigh; // st_ino has no meaning on Windows
- DWORD nIndexLow;
+ DWORD pid; // PID of the connected cscope process
+ HANDLE hProc; // cscope process handle
+ DWORD nVolume; // Volume serial number, instead of st_dev
+ DWORD nIndexHigh; // st_ino has no meaning on Windows
+ DWORD nIndexLow;
#endif
FileID file_id;
diff --git a/src/nvim/indent.c b/src/nvim/indent.c
index a3ee3983e5..f49aff6643 100644
--- a/src/nvim/indent.c
+++ b/src/nvim/indent.c
@@ -533,7 +533,7 @@ int get_expr_indent(void)
colnr_T save_curswant;
int save_set_curswant;
int save_State;
- int use_sandbox = was_set_insecurely(curwin, (char_u *)"indentexpr", OPT_LOCAL);
+ int use_sandbox = was_set_insecurely(curwin, "indentexpr", OPT_LOCAL);
// Save and restore cursor position and curswant, in case it was changed
// * via :normal commands.
diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c
index 25c27743f3..3e3e07e9d6 100644
--- a/src/nvim/indent_c.c
+++ b/src/nvim/indent_c.c
@@ -1,6 +1,8 @@
// This is an open source non-commercial project. Dear PVS-Studio, please check
// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
+// uncrustify:off
+
#include <assert.h>
#include <inttypes.h>
diff --git a/src/nvim/keymap.h b/src/nvim/keymap.h
index 9fc44f6f84..f2de341976 100644
--- a/src/nvim/keymap.h
+++ b/src/nvim/keymap.h
@@ -41,31 +41,31 @@
/*
* NUL cannot be in the input string, therefore it is replaced by
- * K_SPECIAL KS_ZERO KE_FILLER
+ * K_SPECIAL KS_ZERO KE_FILLER
*/
#define KS_ZERO 255
/*
* K_SPECIAL cannot be in the input string, therefore it is replaced by
- * K_SPECIAL KS_SPECIAL KE_FILLER
+ * K_SPECIAL KS_SPECIAL KE_FILLER
*/
#define KS_SPECIAL 254
/*
* KS_EXTRA is used for keys that have no termcap name
- * K_SPECIAL KS_EXTRA KE_xxx
+ * K_SPECIAL KS_EXTRA KE_xxx
*/
#define KS_EXTRA 253
/*
* KS_MODIFIER is used when a modifier is given for a (special) key
- * K_SPECIAL KS_MODIFIER bitmask
+ * K_SPECIAL KS_MODIFIER bitmask
*/
#define KS_MODIFIER 252
/*
* These are used for the GUI
- * K_SPECIAL KS_xxx KE_FILLER
+ * K_SPECIAL KS_xxx KE_FILLER
*/
#define KS_MOUSE 251
#define KS_MENU 250
@@ -170,8 +170,8 @@ enum key_extra {
, KE_MOUSE = 43 // mouse event start
- // Symbols for pseudo keys which are translated from the real key symbols
- // above.
+ // Symbols for pseudo keys which are translated from the real key symbols
+ // above.
, KE_LEFTMOUSE = 44 // Left mouse button click
, KE_LEFTDRAG = 45 // Drag with left mouse button down
, KE_LEFTRELEASE = 46 // Left mouse button release
@@ -187,7 +187,7 @@ enum key_extra {
, KE_TAB = 54 // unshifted TAB key
, KE_S_TAB_OLD = 55 // shifted TAB key (no longer used)
- // , KE_SNIFF_UNUSED = 56 // obsolete
+ // , KE_SNIFF_UNUSED = 56 // obsolete
, KE_XF1 = 57 // extra vt100 function keys for xterm
, KE_XF2 = 58
, KE_XF3 = 59
@@ -209,9 +209,9 @@ enum key_extra {
, KE_S_XF3 = 73
, KE_S_XF4 = 74
- // NOTE: The scroll wheel events are inverted: i.e. UP is the same as
- // moving the actual scroll wheel down, LEFT is the same as moving the
- // scroll wheel right.
+ // NOTE: The scroll wheel events are inverted: i.e. UP is the same as
+ // moving the actual scroll wheel down, LEFT is the same as moving the
+ // scroll wheel right.
, KE_MOUSEDOWN = 75 // scroll wheel pseudo-button Down
, KE_MOUSEUP = 76 // scroll wheel pseudo-button Up
, KE_MOUSELEFT = 77 // scroll wheel pseudo-button Left
@@ -238,12 +238,12 @@ enum key_extra {
, KE_X2RELEASE = 94
, KE_DROP = 95 // DnD data is available
- // , KE_CURSORHOLD = 96 // CursorHold event
+ // , KE_CURSORHOLD = 96 // CursorHold event
, KE_NOP = 97 // no-op: does nothing
- // , KE_FOCUSGAINED = 98 // focus gained
- // , KE_FOCUSLOST = 99 // focus lost
+ // , KE_FOCUSGAINED = 98 // focus gained
+ // , KE_FOCUSLOST = 99 // focus lost
, KE_MOUSEMOVE = 100 // mouse moved with no button down
- // , KE_CANCEL = 101 // return from vgetc
+ // , KE_CANCEL = 101 // return from vgetc
, KE_EVENT = 102 // event
, KE_COMMAND = 104 // <Cmd> special key
};
diff --git a/src/nvim/lib/kbtree.h b/src/nvim/lib/kbtree.h
index bef37f8ba9..6b10db0bbc 100644
--- a/src/nvim/lib/kbtree.h
+++ b/src/nvim/lib/kbtree.h
@@ -1,3 +1,5 @@
+// uncrustify:off
+
/*-
* Copyright 1997-1999, 2001, John-Mark Gurney.
* 2008-2009, Attractive Chaos <attractor@live.co.uk>
diff --git a/src/nvim/lib/khash.h b/src/nvim/lib/khash.h
index c999511543..381903c855 100644
--- a/src/nvim/lib/khash.h
+++ b/src/nvim/lib/khash.h
@@ -1,3 +1,5 @@
+// uncrustify:off
+
/* The MIT License
Copyright (c) 2008, 2009, 2011 by Attractive Chaos <attractor@live.co.uk>
diff --git a/src/nvim/lib/klist.h b/src/nvim/lib/klist.h
index b80f4be3c2..a2d7e91af3 100644
--- a/src/nvim/lib/klist.h
+++ b/src/nvim/lib/klist.h
@@ -1,3 +1,5 @@
+// uncrustify:off
+
/* The MIT License
Copyright (c) 2008-2009, by Attractive Chaos <attractor@live.co.uk>
diff --git a/src/nvim/lib/kvec.h b/src/nvim/lib/kvec.h
index 5bd09930a3..0a7260b2e5 100644
--- a/src/nvim/lib/kvec.h
+++ b/src/nvim/lib/kvec.h
@@ -1,3 +1,5 @@
+// uncrustify:off
+
// The MIT License
//
// Copyright (c) 2008, by Attractive Chaos <attractor@live.co.uk>
diff --git a/src/nvim/lib/queue.h b/src/nvim/lib/queue.h
index 452998a5a4..bc4e9c4a82 100644
--- a/src/nvim/lib/queue.h
+++ b/src/nvim/lib/queue.h
@@ -1,3 +1,5 @@
+// uncrustify:off
+
// Queue implemented by circularly-linked list.
//
// Adapted from libuv. Simpler and more efficient than klist.h for implementing
diff --git a/src/nvim/lib/ringbuf.h b/src/nvim/lib/ringbuf.h
index cb79eaf742..4eab44aa6a 100644
--- a/src/nvim/lib/ringbuf.h
+++ b/src/nvim/lib/ringbuf.h
@@ -1,3 +1,5 @@
+// uncrustify:off
+
/// Macros-based ring buffer implementation.
///
/// Supported functions:
diff --git a/src/nvim/log.h b/src/nvim/log.h
index 654b682de8..81e39d1cdd 100644
--- a/src/nvim/log.h
+++ b/src/nvim/log.h
@@ -1,8 +1,8 @@
#ifndef NVIM_LOG_H
#define NVIM_LOG_H
-#include <stdio.h>
#include <stdbool.h>
+#include <stdio.h>
#include "auto/config.h"
#include "nvim/macros.h"
@@ -10,10 +10,10 @@
// USDT probes. Example invocation:
// NVIM_PROBE(nvim_foo_bar, 1, string.data);
#if defined(HAVE_SYS_SDT_H)
-#include <sys/sdt.h> // NOLINT
-#define NVIM_PROBE(name, n, ...) STAP_PROBE##n(neovim, name, __VA_ARGS__)
+# include <sys/sdt.h> // NOLINT
+# define NVIM_PROBE(name, n, ...) STAP_PROBE##n(neovim, name, __VA_ARGS__)
#else
-#define NVIM_PROBE(name, n, ...)
+# define NVIM_PROBE(name, n, ...)
#endif
@@ -33,7 +33,7 @@
#define ELOGN(...)
#ifndef MIN_LOG_LEVEL
-# define MIN_LOG_LEVEL INFO_LOG_LEVEL
+# define MIN_LOG_LEVEL INFO_LOG_LEVEL
#endif
#define LOG(level, ...) logmsg((level), NULL, __func__, __LINE__, true, \
diff --git a/src/nvim/lua/converter.c b/src/nvim/lua/converter.c
index fd4cfc4c31..ca3c4f604a 100644
--- a/src/nvim/lua/converter.c
+++ b/src/nvim/lua/converter.c
@@ -1303,6 +1303,12 @@ void nlua_init_types(lua_State *const lstate)
void nlua_pop_keydict(lua_State *L, void *retval, field_hash hashy, Error *err)
{
+ if (!lua_istable(L, -1)) {
+ api_set_error(err, kErrorTypeValidation, "Expected lua table");
+ lua_pop(L, -1);
+ return;
+ }
+
lua_pushnil(L); // [dict, nil]
while (lua_next(L, -2)) {
// [dict, key, value]
diff --git a/src/nvim/lua/converter.h b/src/nvim/lua/converter.h
index 43a7e06019..1c9e60e4b2 100644
--- a/src/nvim/lua/converter.h
+++ b/src/nvim/lua/converter.h
@@ -6,8 +6,8 @@
#include <stdint.h>
#include "nvim/api/private/defs.h"
-#include "nvim/func_attr.h"
#include "nvim/eval.h"
+#include "nvim/func_attr.h"
typedef struct {
LuaRef func_ref;
diff --git a/src/nvim/lua/executor.h b/src/nvim/lua/executor.h
index ea774ac2e3..a1f66bd02b 100644
--- a/src/nvim/lua/executor.h
+++ b/src/nvim/lua/executor.h
@@ -1,13 +1,13 @@
#ifndef NVIM_LUA_EXECUTOR_H
#define NVIM_LUA_EXECUTOR_H
-#include <lua.h>
#include <lauxlib.h>
+#include <lua.h>
#include "nvim/api/private/defs.h"
-#include "nvim/func_attr.h"
#include "nvim/eval/typval.h"
#include "nvim/ex_cmds_defs.h"
+#include "nvim/func_attr.h"
#include "nvim/lua/converter.h"
// Generated by msgpack-gen.lua
@@ -19,12 +19,12 @@ EXTERN LuaRef nlua_empty_dict_ref INIT(= LUA_NOREF);
EXTERN int nlua_refcount INIT(= 0);
#define set_api_error(s, err) \
- do { \
- Error *err_ = (err); \
- err_->type = kErrorTypeException; \
- err_->set = true; \
- memcpy(&err_->msg[0], s, sizeof(s)); \
- } while (0)
+ do { \
+ Error *err_ = (err); \
+ err_->type = kErrorTypeException; \
+ err_->set = true; \
+ memcpy(&err_->msg[0], s, sizeof(s)); \
+ } while (0)
#define NLUA_CLEAR_REF(x) \
do { \
diff --git a/src/nvim/lua/treesitter.c b/src/nvim/lua/treesitter.c
index 37929093e3..bd978cc8ab 100644
--- a/src/nvim/lua/treesitter.c
+++ b/src/nvim/lua/treesitter.c
@@ -30,6 +30,7 @@
typedef struct {
TSQueryCursor *cursor;
int predicated_match;
+ int max_match_id;
} TSLua_cursor;
#ifdef INCLUDE_GENERATED_DECLARATIONS
@@ -1055,6 +1056,8 @@ static int query_next_match(lua_State *L)
static int query_next_capture(lua_State *L)
{
+ // Upvalues are:
+ // [ cursor, node, query, current_match ]
TSLua_cursor *ud = lua_touserdata(L, lua_upvalueindex(1));
TSQueryCursor *cursor = ud->cursor;
@@ -1078,9 +1081,13 @@ static int query_next_capture(lua_State *L)
lua_pushinteger(L, capture.index+1); // [index]
push_node(L, capture.node, lua_upvalueindex(2)); // [index, node]
+ // Now check if we need to run the predicates
uint32_t n_pred;
ts_query_predicates_for_pattern(query, match.pattern_index, &n_pred);
- if (n_pred > 0 && capture_index == 0) {
+
+ if (n_pred > 0 && (ud->max_match_id < (int)match.id)) {
+ ud->max_match_id = match.id;
+
lua_pushvalue(L, lua_upvalueindex(4)); // [index, node, match]
set_match(L, &match, lua_upvalueindex(2));
lua_pushinteger(L, match.pattern_index+1);
@@ -1127,6 +1134,7 @@ static int node_rawquery(lua_State *L)
TSLua_cursor *ud = lua_newuserdata(L, sizeof(*ud)); // [udata]
ud->cursor = cursor;
ud->predicated_match = -1;
+ ud->max_match_id = -1;
lua_getfield(L, LUA_REGISTRYINDEX, TS_META_QUERYCURSOR);
lua_setmetatable(L, -2); // [udata]
diff --git a/src/nvim/lua/treesitter.h b/src/nvim/lua/treesitter.h
index 812166f67b..b69fb9dfae 100644
--- a/src/nvim/lua/treesitter.h
+++ b/src/nvim/lua/treesitter.h
@@ -1,9 +1,9 @@
#ifndef NVIM_LUA_TREESITTER_H
#define NVIM_LUA_TREESITTER_H
+#include <lauxlib.h>
#include <lua.h>
#include <lualib.h>
-#include <lauxlib.h>
#include "tree_sitter/api.h"
diff --git a/src/nvim/lua/xdiff.h b/src/nvim/lua/xdiff.h
index cae7c98e81..b172d2f922 100644
--- a/src/nvim/lua/xdiff.h
+++ b/src/nvim/lua/xdiff.h
@@ -1,9 +1,9 @@
#ifndef NVIM_LUA_XDIFF_H
#define NVIM_LUA_XDIFF_H
+#include <lauxlib.h>
#include <lua.h>
#include <lualib.h>
-#include <lauxlib.h>
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "lua/xdiff.h.generated.h"
diff --git a/src/nvim/macros.h b/src/nvim/macros.h
index e1aa1b7704..50ee91dc36 100644
--- a/src/nvim/macros.h
+++ b/src/nvim/macros.h
@@ -43,15 +43,15 @@
#define TOLOWER_LOC tolower
// toupper() and tolower() for ASCII only and ignore the current locale.
-# define TOUPPER_ASC(c) (((c) < 'a' || (c) > 'z') ? (c) : (c) - ('a' - 'A'))
-# define TOLOWER_ASC(c) (((c) < 'A' || (c) > 'Z') ? (c) : (c) + ('a' - 'A'))
+#define TOUPPER_ASC(c) (((c) < 'a' || (c) > 'z') ? (c) : (c) - ('a' - 'A'))
+#define TOLOWER_ASC(c) (((c) < 'A' || (c) > 'Z') ? (c) : (c) + ('a' - 'A'))
// Like isalpha() but reject non-ASCII characters. Can't be used with a
// special key (negative value).
-# define ASCII_ISLOWER(c) ((unsigned)(c) >= 'a' && (unsigned)(c) <= 'z')
-# define ASCII_ISUPPER(c) ((unsigned)(c) >= 'A' && (unsigned)(c) <= 'Z')
-# define ASCII_ISALPHA(c) (ASCII_ISUPPER(c) || ASCII_ISLOWER(c))
-# define ASCII_ISALNUM(c) (ASCII_ISALPHA(c) || ascii_isdigit(c))
+#define ASCII_ISLOWER(c) ((unsigned)(c) >= 'a' && (unsigned)(c) <= 'z')
+#define ASCII_ISUPPER(c) ((unsigned)(c) >= 'A' && (unsigned)(c) <= 'Z')
+#define ASCII_ISALPHA(c) (ASCII_ISUPPER(c) || ASCII_ISLOWER(c))
+#define ASCII_ISALNUM(c) (ASCII_ISALPHA(c) || ascii_isdigit(c))
// Returns empty string if it is NULL.
#define EMPTY_IF_NULL(x) ((x) ? (x) : (char_u *)"")
@@ -62,7 +62,7 @@
// Don't apply 'langmap' if the character comes from the Stuff buffer or from a
// mapping and the langnoremap option was set.
// The do-while is just to ignore a ';' after the macro.
-# define LANGMAP_ADJUST(c, condition) \
+#define LANGMAP_ADJUST(c, condition) \
do { \
if (*p_langmap \
&& (condition) \
@@ -71,9 +71,9 @@
&& (c) >= 0) \
{ \
if ((c) < 256) \
- c = langmap_mapchar[c]; \
+ c = langmap_mapchar[c]; \
else \
- c = langmap_adjust_mb(c); \
+ c = langmap_adjust_mb(c); \
} \
} while (0)
@@ -90,9 +90,9 @@
# define mch_open_rw(n, f) os_open((n), (f), 0)
#endif
-# define REPLACE_NORMAL(s) (((s) & REPLACE_FLAG) && !((s) & VREPLACE_FLAG))
+#define REPLACE_NORMAL(s) (((s) & REPLACE_FLAG) && !((s) & VREPLACE_FLAG))
-# define UTF_COMPOSINGLIKE(p1, p2) utf_composinglike((p1), (p2))
+#define UTF_COMPOSINGLIKE(p1, p2) utf_composinglike((p1), (p2))
// MB_PTR_ADV(): advance a pointer to the next character, taking care of
// multi-byte characters if needed.
@@ -102,22 +102,22 @@
// PTR2CHAR(): get character from pointer.
// Advance multi-byte pointer, skip over composing chars.
-# define MB_PTR_ADV(p) (p += mb_ptr2len((char_u *)p))
+#define MB_PTR_ADV(p) (p += mb_ptr2len((char_u *)p))
// Advance multi-byte pointer, do not skip over composing chars.
-# define MB_CPTR_ADV(p) (p += utf_ptr2len(p))
+#define MB_CPTR_ADV(p) (p += utf_ptr2len(p))
// Backup multi-byte pointer. Only use with "p" > "s" !
-# define MB_PTR_BACK(s, p) \
- (p -= utf_head_off((char_u *)s, (char_u *)p - 1) + 1)
+#define MB_PTR_BACK(s, p) \
+ (p -= utf_head_off((char_u *)s, (char_u *)p - 1) + 1)
// get length of multi-byte char, not including composing chars
-# define MB_CPTR2LEN(p) utf_ptr2len(p)
+#define MB_CPTR2LEN(p) utf_ptr2len(p)
-# define MB_COPY_CHAR(f, t) mb_copy_char((const char_u **)(&f), &t);
+#define MB_COPY_CHAR(f, t) mb_copy_char((const char_u **)(&f), &t);
-# define MB_CHARLEN(p) mb_charlen(p)
-# define MB_CHAR2LEN(c) mb_char2len(c)
-# define PTR2CHAR(p) utf_ptr2char(p)
+#define MB_CHARLEN(p) mb_charlen(p)
+#define MB_CHAR2LEN(c) mb_char2len(c)
+#define PTR2CHAR(p) utf_ptr2char(p)
-# define RESET_BINDING(wp) \
+#define RESET_BINDING(wp) \
do { \
(wp)->w_p_scb = false; \
(wp)->w_p_crb = false; \
@@ -132,8 +132,8 @@
///
/// -V:ARRAY_SIZE:1063
#define ARRAY_SIZE(arr) \
- ((sizeof(arr)/sizeof((arr)[0])) \
- / ((size_t)(!(sizeof(arr) % sizeof((arr)[0])))))
+ ((sizeof(arr)/sizeof((arr)[0])) \
+ / ((size_t)(!(sizeof(arr) % sizeof((arr)[0])))))
/// Get last array entry
///
@@ -156,7 +156,7 @@
#ifndef __has_attribute
# define NVIM_HAS_ATTRIBUTE(x) 0
#elif defined(__clang__) && __clang__ == 1 \
- && (__clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ <= 5))
+ && (__clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ <= 5))
// Starting in Clang 3.6, __has_attribute was fixed to only report true for
// GNU-style attributes. Prior to that, it reported true if _any_ backend
// supported the attribute.
@@ -166,7 +166,7 @@
#endif
#if NVIM_HAS_ATTRIBUTE(fallthrough) \
- && (!defined(__apple_build_version__) || __apple_build_version__ >= 7000000)
+ && (!defined(__apple_build_version__) || __apple_build_version__ >= 7000000)
# define FALLTHROUGH {} __attribute__((fallthrough))
#else
# define FALLTHROUGH
@@ -204,29 +204,29 @@
///
#if defined(__clang__) && __clang__ == 1
# define PRAGMA_DIAG_PUSH_IGNORE_MISSING_PROTOTYPES \
- _Pragma("clang diagnostic push") \
+ _Pragma("clang diagnostic push")\
_Pragma("clang diagnostic ignored \"-Wmissing-prototypes\"")
# ifdef HAVE_WIMPLICIT_FALLTHROUGH_FLAG
# define PRAGMA_DIAG_PUSH_IGNORE_IMPLICIT_FALLTHROUGH \
- _Pragma("clang diagnostic push") \
- _Pragma("clang diagnostic ignored \"-Wimplicit-fallthrough\"")
+ _Pragma("clang diagnostic push")\
+ _Pragma("clang diagnostic ignored \"-Wimplicit-fallthrough\"")
# else
# define PRAGMA_DIAG_PUSH_IGNORE_IMPLICIT_FALLTHROUGH \
- _Pragma("clang diagnostic push")
+ _Pragma("clang diagnostic push")
# endif
# define PRAGMA_DIAG_POP \
- _Pragma("clang diagnostic pop")
+ _Pragma("clang diagnostic pop")
#elif defined(__GNUC__)
# define PRAGMA_DIAG_PUSH_IGNORE_MISSING_PROTOTYPES \
- _Pragma("GCC diagnostic push") \
+ _Pragma("GCC diagnostic push")\
_Pragma("GCC diagnostic ignored \"-Wmissing-prototypes\"")
# ifdef HAVE_WIMPLICIT_FALLTHROUGH_FLAG
# define PRAGMA_DIAG_PUSH_IGNORE_IMPLICIT_FALLTHROUGH \
- _Pragma("GCC diagnostic push") \
- _Pragma("GCC diagnostic ignored \"-Wimplicit-fallthrough\"")
+ _Pragma("GCC diagnostic push")\
+ _Pragma("GCC diagnostic ignored \"-Wimplicit-fallthrough\"")
# else
# define PRAGMA_DIAG_PUSH_IGNORE_IMPLICIT_FALLTHROUGH \
- _Pragma("GCC diagnostic push")
+ _Pragma("GCC diagnostic push")
# endif
# define PRAGMA_DIAG_POP \
_Pragma("GCC diagnostic pop")
diff --git a/src/nvim/main.c b/src/nvim/main.c
index 50ec6c1d88..00a43c9c79 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -1700,7 +1700,7 @@ static void do_system_initialization(void)
memcpy(vimrc, dir, dir_len);
vimrc[dir_len] = PATHSEP;
memcpy(vimrc + dir_len + 1, path_tail, sizeof(path_tail));
- if (do_source((char_u *)vimrc, false, DOSO_NONE) != FAIL) {
+ if (do_source(vimrc, false, DOSO_NONE) != FAIL) {
xfree(vimrc);
xfree(config_dirs);
return;
@@ -1712,7 +1712,7 @@ static void do_system_initialization(void)
#ifdef SYS_VIMRC_FILE
// Get system wide defaults, if the file name is defined.
- (void)do_source((char_u *)SYS_VIMRC_FILE, false, DOSO_NONE);
+ (void)do_source(SYS_VIMRC_FILE, false, DOSO_NONE);
#endif
}
@@ -1741,7 +1741,7 @@ static bool do_user_initialization(void)
// init.lua
if (os_path_exists(init_lua_path)
- && do_source(init_lua_path, true, DOSO_VIMRC)) {
+ && do_source((char *)init_lua_path, true, DOSO_VIMRC)) {
if (os_path_exists(user_vimrc)) {
EMSG3(_("E5422: Conflicting configs: \"%s\" \"%s\""), init_lua_path,
user_vimrc);
@@ -1754,7 +1754,7 @@ static bool do_user_initialization(void)
xfree(init_lua_path);
// init.vim
- if (do_source(user_vimrc, true, DOSO_VIMRC) != FAIL) {
+ if (do_source((char *)user_vimrc, true, DOSO_VIMRC) != FAIL) {
do_exrc = p_exrc;
if (do_exrc) {
do_exrc = (path_full_compare((char_u *)VIMRC_FILE, user_vimrc,
@@ -1782,7 +1782,7 @@ static bool do_user_initialization(void)
memmove(vimrc, dir, dir_len);
vimrc[dir_len] = PATHSEP;
memmove(vimrc + dir_len + 1, path_tail, sizeof(path_tail));
- if (do_source((char_u *)vimrc, true, DOSO_VIMRC) != FAIL) {
+ if (do_source(vimrc, true, DOSO_VIMRC) != FAIL) {
do_exrc = p_exrc;
if (do_exrc) {
do_exrc = (path_full_compare((char_u *)VIMRC_FILE, (char_u *)vimrc,
@@ -1814,7 +1814,7 @@ static void source_startup_scripts(const mparm_T *const parmp)
|| strequal(parmp->use_vimrc, "NORC")) {
// Do nothing.
} else {
- if (do_source((char_u *)parmp->use_vimrc, false, DOSO_NONE) != OK) {
+ if (do_source(parmp->use_vimrc, false, DOSO_NONE) != OK) {
EMSG2(_("E282: Cannot read from \"%s\""), parmp->use_vimrc);
}
}
@@ -1835,7 +1835,7 @@ static void source_startup_scripts(const mparm_T *const parmp)
#endif
secure = p_secure;
- if (do_source((char_u *)VIMRC_FILE, true, DOSO_VIMRC) == FAIL) {
+ if (do_source(VIMRC_FILE, true, DOSO_VIMRC) == FAIL) {
#if defined(UNIX)
// if ".exrc" is not owned by user set 'secure' mode
if (!file_owned(EXRC_FILE)) {
@@ -1844,7 +1844,7 @@ static void source_startup_scripts(const mparm_T *const parmp)
secure = 0;
}
#endif
- (void)do_source((char_u *)EXRC_FILE, false, DOSO_NONE);
+ (void)do_source(EXRC_FILE, false, DOSO_NONE);
}
}
if (secure == 2) {
diff --git a/src/nvim/main.h b/src/nvim/main.h
index d387e6d668..f73af5c288 100644
--- a/src/nvim/main.h
+++ b/src/nvim/main.h
@@ -1,8 +1,8 @@
#ifndef NVIM_MAIN_H
#define NVIM_MAIN_H
-#include "nvim/normal.h"
#include "nvim/event/loop.h"
+#include "nvim/normal.h"
// Maximum number of commands from + or -c arguments.
#define MAX_ARG_CMDS 10
diff --git a/src/nvim/map.h b/src/nvim/map.h
index d6515878a2..6ed341ac76 100644
--- a/src/nvim/map.h
+++ b/src/nvim/map.h
@@ -3,11 +3,11 @@
#include <stdbool.h>
-#include "nvim/map_defs.h"
-#include "nvim/extmark_defs.h"
#include "nvim/api/private/defs.h"
#include "nvim/api/private/dispatch.h"
+#include "nvim/extmark_defs.h"
#include "nvim/highlight_defs.h"
+#include "nvim/map_defs.h"
#if defined(__NetBSD__)
# undef uint64_t
@@ -60,7 +60,7 @@ MAP_DECLS(String, handle_T)
MAP_DECLS(ColorKey, ColorItem)
#define MAP_INIT { { 0, 0, 0, 0, NULL, NULL, NULL } }
-#define map_init(k, v, map) do { *(map) = (Map(k, v))MAP_INIT; } while (false)
+#define map_init(k, v, map) do { *(map) = (Map(k, v)) MAP_INIT; } while (false)
#define map_destroy(T, U) map_##T##_##U##_destroy
#define map_get(T, U) map_##T##_##U##_get
diff --git a/src/nvim/mark.c b/src/nvim/mark.c
index 57532c9cac..ea9acdf31a 100644
--- a/src/nvim/mark.c
+++ b/src/nvim/mark.c
@@ -1035,9 +1035,10 @@ static void mark_adjust_internal(linenr_T line1, linenr_T line2, long amount, lo
}
sign_mark_adjust(line1, line2, amount, amount_after);
- if (op != kExtmarkNOOP) {
- extmark_adjust(curbuf, line1, line2, amount, amount_after, op);
- }
+ }
+
+ if (op != kExtmarkNOOP) {
+ extmark_adjust(curbuf, line1, line2, amount, amount_after, op);
}
// previous context mark
diff --git a/src/nvim/mark.h b/src/nvim/mark.h
index b3d9b5d95a..a55f733d9a 100644
--- a/src/nvim/mark.h
+++ b/src/nvim/mark.h
@@ -1,55 +1,55 @@
#ifndef NVIM_MARK_H
#define NVIM_MARK_H
-#include "nvim/macros.h"
#include "nvim/ascii.h"
#include "nvim/buffer_defs.h"
+#include "nvim/ex_cmds_defs.h" // for exarg_T
+#include "nvim/extmark_defs.h"
#include "nvim/func_attr.h"
+#include "nvim/macros.h"
#include "nvim/mark_defs.h"
-#include "nvim/extmark_defs.h"
#include "nvim/memory.h"
-#include "nvim/pos.h"
#include "nvim/os/time.h"
-#include "nvim/ex_cmds_defs.h" // for exarg_T
+#include "nvim/pos.h"
/// Set fmark using given value
#define SET_FMARK(fmarkp_, mark_, fnum_) \
- do { \
- fmark_T *const fmarkp__ = fmarkp_; \
- fmarkp__->mark = mark_; \
- fmarkp__->fnum = fnum_; \
- fmarkp__->timestamp = os_time(); \
- fmarkp__->additional_data = NULL; \
- } while (0)
+ do { \
+ fmark_T *const fmarkp__ = fmarkp_; \
+ fmarkp__->mark = mark_; \
+ fmarkp__->fnum = fnum_; \
+ fmarkp__->timestamp = os_time(); \
+ fmarkp__->additional_data = NULL; \
+ } while (0)
/// Free and set fmark using given value
#define RESET_FMARK(fmarkp_, mark_, fnum_) \
- do { \
- fmark_T *const fmarkp___ = fmarkp_; \
- free_fmark(*fmarkp___); \
- SET_FMARK(fmarkp___, mark_, fnum_); \
- } while (0)
+ do { \
+ fmark_T *const fmarkp___ = fmarkp_; \
+ free_fmark(*fmarkp___); \
+ SET_FMARK(fmarkp___, mark_, fnum_); \
+ } while (0)
/// Clear given fmark
#define CLEAR_FMARK(fmarkp_) \
- RESET_FMARK(fmarkp_, ((pos_T) { 0, 0, 0 }), 0)
+ RESET_FMARK(fmarkp_, ((pos_T) { 0, 0, 0 }), 0)
/// Set given extended mark (regular mark + file name)
#define SET_XFMARK(xfmarkp_, mark_, fnum_, fname_) \
- do { \
- xfmark_T *const xfmarkp__ = xfmarkp_; \
- xfmarkp__->fname = fname_; \
- SET_FMARK(&(xfmarkp__->fmark), mark_, fnum_); \
- } while (0)
+ do { \
+ xfmark_T *const xfmarkp__ = xfmarkp_; \
+ xfmarkp__->fname = fname_; \
+ SET_FMARK(&(xfmarkp__->fmark), mark_, fnum_); \
+ } while (0)
/// Free and set given extended mark (regular mark + file name)
#define RESET_XFMARK(xfmarkp_, mark_, fnum_, fname_) \
- do { \
- xfmark_T *const xfmarkp__ = xfmarkp_; \
- free_xfmark(*xfmarkp__); \
- xfmarkp__->fname = fname_; \
- SET_FMARK(&(xfmarkp__->fmark), mark_, fnum_); \
- } while (0)
+ do { \
+ xfmark_T *const xfmarkp__ = xfmarkp_; \
+ free_xfmark(*xfmarkp__); \
+ xfmarkp__->fname = fname_; \
+ SET_FMARK(&(xfmarkp__->fmark), mark_, fnum_); \
+ } while (0)
/// Convert mark name to the offset
static inline int mark_global_index(const char name)
diff --git a/src/nvim/mark_defs.h b/src/nvim/mark_defs.h
index 2cb489501e..51199a09e0 100644
--- a/src/nvim/mark_defs.h
+++ b/src/nvim/mark_defs.h
@@ -1,9 +1,9 @@
#ifndef NVIM_MARK_DEFS_H
#define NVIM_MARK_DEFS_H
-#include "nvim/pos.h"
-#include "nvim/os/time.h"
#include "nvim/eval/typval.h"
+#include "nvim/os/time.h"
+#include "nvim/pos.h"
/*
* marks: positions in a file
@@ -42,7 +42,7 @@ typedef struct filemark {
/// Structure defining extended mark (mark with file name attached)
typedef struct xfilemark {
fmark_T fmark; ///< Actual mark.
- char_u *fname; ///< File name, used when fnum == 0.
+ char_u *fname; ///< File name, used when fnum == 0.
} xfmark_T;
#endif // NVIM_MARK_DEFS_H
diff --git a/src/nvim/marktree.c b/src/nvim/marktree.c
index ebe4478bc8..fd7012e895 100644
--- a/src/nvim/marktree.c
+++ b/src/nvim/marktree.c
@@ -837,8 +837,8 @@ bool marktree_splice(MarkTree *b, int start_line, int start_col, int old_extent_
int old_extent_col, int new_extent_line, int new_extent_col)
{
mtpos_t start = { start_line, start_col };
- mtpos_t old_extent = { (int)old_extent_line, old_extent_col };
- mtpos_t new_extent = { (int)new_extent_line, new_extent_col };
+ mtpos_t old_extent = { old_extent_line, old_extent_col };
+ mtpos_t new_extent = { new_extent_line, new_extent_col };
bool may_delete = (old_extent.row != 0 || old_extent.col != 0);
bool same_line = old_extent.row == 0 && new_extent.row == 0;
@@ -1168,8 +1168,7 @@ char *mt_inspect_rec(MarkTree *b)
void mt_inspect_node(MarkTree *b, garray_T *ga, mtnode_t *n, mtpos_t off)
{
static char buf[1024];
-#define GA_PUT(x) ga_concat(ga, (char_u *)(x))
- GA_PUT("[");
+ ga_concat(ga, "[");
if (n->level) {
mt_inspect_node(b, ga, n->ptr[0], off);
}
@@ -1177,14 +1176,13 @@ void mt_inspect_node(MarkTree *b, garray_T *ga, mtnode_t *n, mtpos_t off)
mtpos_t p = n->key[i].pos;
unrelative(off, &p);
snprintf((char *)buf, sizeof(buf), "%d/%d", p.row, p.col);
- GA_PUT(buf);
+ ga_concat(ga, buf);
if (n->level) {
mt_inspect_node(b, ga, n->ptr[i+1], p);
} else {
- GA_PUT(",");
+ ga_concat(ga, ",");
}
}
- GA_PUT("]");
-#undef GA_PUT
+ ga_concat(ga, "]");
}
diff --git a/src/nvim/marktree.h b/src/nvim/marktree.h
index 7af23765c3..02f73b8052 100644
--- a/src/nvim/marktree.h
+++ b/src/nvim/marktree.h
@@ -2,9 +2,10 @@
#define NVIM_MARKTREE_H
#include <stdint.h>
-#include "nvim/pos.h"
-#include "nvim/map.h"
+
#include "nvim/garray.h"
+#include "nvim/map.h"
+#include "nvim/pos.h"
#define MT_MAX_DEPTH 20
#define MT_BRANCH_FACTOR 10
diff --git a/src/nvim/math.c b/src/nvim/math.c
index 791f1f9373..63a29509bd 100644
--- a/src/nvim/math.c
+++ b/src/nvim/math.c
@@ -2,7 +2,6 @@
// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
#include <math.h>
-
#include <stdint.h>
#include <string.h>
diff --git a/src/nvim/mbyte.h b/src/nvim/mbyte.h
index 536d58be1f..9926f27411 100644
--- a/src/nvim/mbyte.h
+++ b/src/nvim/mbyte.h
@@ -1,12 +1,12 @@
#ifndef NVIM_MBYTE_H
#define NVIM_MBYTE_H
-#include <stdint.h>
#include <stdbool.h>
+#include <stdint.h>
#include <string.h>
-#include "nvim/iconv.h"
#include "nvim/func_attr.h"
+#include "nvim/iconv.h"
#include "nvim/os/os_defs.h" // For indirect
#include "nvim/types.h" // for char_u
@@ -22,21 +22,21 @@
// max length of an unicode char
#define MB_MAXCHAR 6
-/* properties used in enc_canon_table[] (first three mutually exclusive) */
+// properties used in enc_canon_table[] (first three mutually exclusive)
#define ENC_8BIT 0x01
#define ENC_DBCS 0x02
#define ENC_UNICODE 0x04
-#define ENC_ENDIAN_B 0x10 /* Unicode: Big endian */
-#define ENC_ENDIAN_L 0x20 /* Unicode: Little endian */
+#define ENC_ENDIAN_B 0x10 // Unicode: Big endian
+#define ENC_ENDIAN_L 0x20 // Unicode: Little endian
-#define ENC_2BYTE 0x40 /* Unicode: UCS-2 */
-#define ENC_4BYTE 0x80 /* Unicode: UCS-4 */
-#define ENC_2WORD 0x100 /* Unicode: UTF-16 */
+#define ENC_2BYTE 0x40 // Unicode: UCS-2
+#define ENC_4BYTE 0x80 // Unicode: UCS-4
+#define ENC_2WORD 0x100 // Unicode: UTF-16
-#define ENC_LATIN1 0x200 /* Latin1 */
-#define ENC_LATIN9 0x400 /* Latin9 */
-#define ENC_MACROMAN 0x800 /* Mac Roman (not Macro Man! :-) */
+#define ENC_LATIN1 0x200 // Latin1
+#define ENC_LATIN9 0x400 // Latin9
+#define ENC_MACROMAN 0x800 // Mac Roman (not Macro Man! :-)
// TODO(bfredl): eventually we should keep only one of the namings
#define mb_ptr2len utfc_ptr2len
@@ -63,9 +63,9 @@ typedef enum {
typedef struct {
int vc_type; ///< Zero or more ConvFlags.
int vc_factor; ///< Maximal expansion factor.
-# ifdef HAVE_ICONV
+#ifdef HAVE_ICONV
iconv_t vc_fd; ///< Value for CONV_ICONV.
-# endif
+#endif
bool vc_fail; ///< What to do with invalid characters: if true, fail,
///< otherwise use '?'.
} vimconv_T;
diff --git a/src/nvim/memfile_defs.h b/src/nvim/memfile_defs.h
index 3eaa7d83e0..537d3e5f65 100644
--- a/src/nvim/memfile_defs.h
+++ b/src/nvim/memfile_defs.h
@@ -1,12 +1,12 @@
#ifndef NVIM_MEMFILE_DEFS_H
#define NVIM_MEMFILE_DEFS_H
-#include <stdint.h>
#include <stdbool.h>
+#include <stdint.h>
#include <stdlib.h>
-#include "nvim/types.h"
#include "nvim/pos.h"
+#include "nvim/types.h"
/// A block number.
///
diff --git a/src/nvim/memline.c b/src/nvim/memline.c
index 9bc39f5e32..0874af5ee1 100644
--- a/src/nvim/memline.c
+++ b/src/nvim/memline.c
@@ -1272,7 +1272,6 @@ theend:
apply_autocmds(EVENT_BUFREADPOST, NULL, curbuf->b_fname, FALSE, curbuf);
apply_autocmds(EVENT_BUFWINENTER, NULL, curbuf->b_fname, FALSE, curbuf);
}
- return;
}
/// Find the names of swap files in current directory and the directory given
@@ -2798,7 +2797,6 @@ void ml_clearmarked(void)
}
lowest_marked = 0;
- return;
}
size_t ml_flush_deleted_bytes(buf_T *buf, size_t *codepoints, size_t *codeunits)
diff --git a/src/nvim/memline.h b/src/nvim/memline.h
index a239c6a031..441adf3e87 100644
--- a/src/nvim/memline.h
+++ b/src/nvim/memline.h
@@ -1,9 +1,9 @@
#ifndef NVIM_MEMLINE_H
#define NVIM_MEMLINE_H
+#include "nvim/buffer_defs.h" // for buf_T
+#include "nvim/pos.h" // for pos_T, linenr_T, colnr_T
#include "nvim/types.h"
-#include "nvim/pos.h" // for pos_T, linenr_T, colnr_T
-#include "nvim/buffer_defs.h" // for buf_T
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "memline.h.generated.h"
diff --git a/src/nvim/memline_defs.h b/src/nvim/memline_defs.h
index dc4755f83d..922a2c98d1 100644
--- a/src/nvim/memline_defs.h
+++ b/src/nvim/memline_defs.h
@@ -43,9 +43,9 @@ typedef struct ml_chunksize {
typedef struct memline {
linenr_T ml_line_count; // number of lines in the buffer
- memfile_T *ml_mfp; // pointer to associated memfile
+ memfile_T *ml_mfp; // pointer to associated memfile
- infoptr_T *ml_stack; // stack of pointer blocks (array of IPTRs)
+ infoptr_T *ml_stack; // stack of pointer blocks (array of IPTRs)
int ml_stack_top; // current top of ml_stack
int ml_stack_size; // total number of entries in ml_stack
@@ -56,11 +56,11 @@ typedef struct memline {
int ml_flags;
linenr_T ml_line_lnum; // line number of cached line, 0 if not valid
- char_u *ml_line_ptr; // pointer to cached line
+ char_u *ml_line_ptr; // pointer to cached line
size_t ml_line_offset; // cached byte offset of ml_line_lnum
int ml_line_offset_ff; // fileformat of cached line
- bhdr_T *ml_locked; // block used by last ml_get
+ bhdr_T *ml_locked; // block used by last ml_get
linenr_T ml_locked_low; // first line in ml_locked
linenr_T ml_locked_high; // last line in ml_locked
int ml_locked_lineadd; // number of lines inserted in ml_locked
diff --git a/src/nvim/memory.h b/src/nvim/memory.h
index 5b39d002c9..a4be2643d8 100644
--- a/src/nvim/memory.h
+++ b/src/nvim/memory.h
@@ -2,8 +2,8 @@
#define NVIM_MEMORY_H
#include <stdbool.h> // for bool
-#include <stdint.h> // for uint8_t
#include <stddef.h> // for size_t
+#include <stdint.h> // for uint8_t
#include <time.h> // for time_t
/// `malloc()` function signature
diff --git a/src/nvim/menu.c b/src/nvim/menu.c
index acea557a6e..d89f58163f 100644
--- a/src/nvim/menu.c
+++ b/src/nvim/menu.c
@@ -857,7 +857,7 @@ static void show_menus_recursive(vimmenu_T *menu, int modes, int depth)
MSG_PUTS(" ");
}
if (menu->priority) {
- msg_outnum((long)menu->priority);
+ msg_outnum(menu->priority);
MSG_PUTS(" ");
}
// Same highlighting as for directories!?
diff --git a/src/nvim/menu.h b/src/nvim/menu.h
index 642d9aafac..5c65918d79 100644
--- a/src/nvim/menu.h
+++ b/src/nvim/menu.h
@@ -1,10 +1,10 @@
#ifndef NVIM_MENU_H
#define NVIM_MENU_H
-#include <stdbool.h> // for bool
+#include <stdbool.h> // for bool
-#include "nvim/types.h" // for char_u and expand_T
-#include "nvim/ex_cmds_defs.h" // for exarg_T
+#include "nvim/ex_cmds_defs.h" // for exarg_T
+#include "nvim/types.h" // for char_u and expand_T
/// @}
/// note MENU_INDEX_TIP is not a 'real' mode
diff --git a/src/nvim/message.c b/src/nvim/message.c
index edde51e770..c4aab18c35 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -1609,7 +1609,7 @@ char *str2special_save(const char *const str, const bool replace_spaces, const b
const char *p = str;
while (*p != NUL) {
- ga_concat(&ga, (const char_u *)str2special(&p, replace_spaces, replace_lt));
+ ga_concat(&ga, str2special(&p, replace_spaces, replace_lt));
}
ga_append(&ga, NUL);
return (char *)ga.ga_data;
@@ -2363,7 +2363,7 @@ void msg_reset_scroll(void)
// non-displayed part of msg_grid is considered invalid.
for (int i = 0; i < MIN(msg_scrollsize(), msg_grid.Rows); i++) {
grid_clear_line(&msg_grid, msg_grid.line_offset[i],
- (int)msg_grid.Columns, false);
+ msg_grid.Columns, false);
}
}
} else {
diff --git a/src/nvim/message.h b/src/nvim/message.h
index 377c725fa1..6d4d030500 100644
--- a/src/nvim/message.h
+++ b/src/nvim/message.h
@@ -1,15 +1,15 @@
#ifndef NVIM_MESSAGE_H
#define NVIM_MESSAGE_H
-#include <stdbool.h>
#include <stdarg.h>
+#include <stdbool.h>
#include <stddef.h>
-#include "nvim/macros.h"
-#include "nvim/types.h"
-#include "nvim/grid_defs.h"
#include "nvim/api/private/defs.h"
+#include "nvim/grid_defs.h"
#include "nvim/lib/kvec.h"
+#include "nvim/macros.h"
+#include "nvim/types.h"
/*
* Types of dialogs passed to do_dialog().
@@ -19,7 +19,7 @@
#define VIM_WARNING 2
#define VIM_INFO 3
#define VIM_QUESTION 4
-#define VIM_LAST_TYPE 4 /* sentinel value */
+#define VIM_LAST_TYPE 4 // sentinel value
/*
* Return values for functions like vim_dialogyesno()
@@ -42,16 +42,16 @@
#define EMSG(s) emsg((char_u *)(s))
/// Like #EMSG, but for messages with one "%s" inside
-#define EMSG2(s, p) emsgf((const char *) (s), (p))
+#define EMSG2(s, p) emsgf((const char *)(s), (p))
/// Like #EMSG, but for messages with two "%s" inside
-#define EMSG3(s, p, q) emsgf((const char *) (s), (p), (q))
+#define EMSG3(s, p, q) emsgf((const char *)(s), (p), (q))
/// Like #EMSG, but for messages with one "%" PRId64 inside
-#define EMSGN(s, n) emsgf((const char *) (s), (int64_t)(n))
+#define EMSGN(s, n) emsgf((const char *)(s), (int64_t)(n))
/// Like #EMSG, but for messages with one "%" PRIu64 inside
-#define EMSGU(s, n) emsgf((const char *) (s), (uint64_t)(n))
+#define EMSGU(s, n) emsgf((const char *)(s), (uint64_t)(n))
/// Like #EMSG, but for internal messages
#define IEMSG(s) iemsg((const char *)(s))
diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c
index 2dfe5df325..40db5b7cf3 100644
--- a/src/nvim/misc1.c
+++ b/src/nvim/misc1.c
@@ -696,18 +696,18 @@ void msgmore(long n)
}
} else {
if (n > 0) {
- vim_snprintf((char *)msg_buf, MSG_BUF_LEN,
+ vim_snprintf(msg_buf, MSG_BUF_LEN,
_("%" PRId64 " more lines"), (int64_t)pn);
} else {
- vim_snprintf((char *)msg_buf, MSG_BUF_LEN,
+ vim_snprintf(msg_buf, MSG_BUF_LEN,
_("%" PRId64 " fewer lines"), (int64_t)pn);
}
}
if (got_int) {
- xstrlcat((char *)msg_buf, _(" (Interrupted)"), MSG_BUF_LEN);
+ xstrlcat(msg_buf, _(" (Interrupted)"), MSG_BUF_LEN);
}
- if (msg(msg_buf)) {
- set_keep_msg(msg_buf, 0);
+ if (msg((char_u *)msg_buf)) {
+ set_keep_msg((char_u *)msg_buf, 0);
keep_msg_more = true;
}
}
diff --git a/src/nvim/misc1.h b/src/nvim/misc1.h
index f0f66854d8..4ce142c4c5 100644
--- a/src/nvim/misc1.h
+++ b/src/nvim/misc1.h
@@ -1,15 +1,15 @@
#ifndef NVIM_MISC1_H
#define NVIM_MISC1_H
-#include "nvim/vim.h"
#include "nvim/os/shell.h"
+#include "nvim/vim.h"
-/* flags for open_line() */
-#define OPENLINE_DELSPACES 1 /* delete spaces after cursor */
-#define OPENLINE_DO_COM 2 /* format comments */
-#define OPENLINE_KEEPTRAIL 4 /* keep trailing spaces */
-#define OPENLINE_MARKFIX 8 /* fix mark positions */
-#define OPENLINE_COM_LIST 16 /* format comments with list/2nd line indent */
+// flags for open_line()
+#define OPENLINE_DELSPACES 1 // delete spaces after cursor
+#define OPENLINE_DO_COM 2 // format comments
+#define OPENLINE_KEEPTRAIL 4 // keep trailing spaces
+#define OPENLINE_MARKFIX 8 // fix mark positions
+#define OPENLINE_COM_LIST 16 // format comments with list/2nd line indent
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "misc1.h.generated.h"
diff --git a/src/nvim/mouse.c b/src/nvim/mouse.c
index cd9f5fc83e..f02c000e82 100644
--- a/src/nvim/mouse.c
+++ b/src/nvim/mouse.c
@@ -682,8 +682,8 @@ static int mouse_adjust_click(win_T *wp, int row, int col)
vcol = offset;
-#define incr() nudge++; ptr_end += utfc_ptr2len(ptr_end)
-#define decr() nudge--; ptr_end -= utfc_ptr2len(ptr_end)
+#define INCR() nudge++; ptr_end += utfc_ptr2len(ptr_end)
+#define DECR() nudge--; ptr_end -= utfc_ptr2len(ptr_end)
while (ptr < ptr_end && *ptr != NUL) {
cwidth = win_chartabsize(curwin, ptr, vcol);
@@ -692,7 +692,7 @@ static int mouse_adjust_click(win_T *wp, int row, int col)
// A tab will "absorb" any previous adjustments.
cwidth = MIN(cwidth, nudge);
while (cwidth > 0) {
- decr();
+ DECR();
cwidth--;
}
}
@@ -700,20 +700,20 @@ static int mouse_adjust_click(win_T *wp, int row, int col)
matchid = syn_get_concealed_id(wp, lnum, (colnr_T)(ptr - line));
if (matchid != 0) {
if (wp->w_p_cole == 3) {
- incr();
+ INCR();
} else {
if (!(row > 0 && ptr == ptr_row_offset)
&& (wp->w_p_cole == 1 || (wp->w_p_cole == 2
&& (wp->w_p_lcs_chars.conceal != NUL
|| syn_get_sub_char() != NUL)))) {
// At least one placeholder character will be displayed.
- decr();
+ DECR();
}
prev_matchid = matchid;
while (prev_matchid == matchid && *ptr != NUL) {
- incr();
+ INCR();
ptr += utfc_ptr2len(ptr);
matchid = syn_get_concealed_id(wp, lnum, (colnr_T)(ptr - line));
}
diff --git a/src/nvim/mouse.h b/src/nvim/mouse.h
index 6c5bc5dc0e..bf4f9c57e5 100644
--- a/src/nvim/mouse.h
+++ b/src/nvim/mouse.h
@@ -3,8 +3,8 @@
#include <stdbool.h>
-#include "nvim/vim.h"
#include "nvim/buffer_defs.h"
+#include "nvim/vim.h"
// jump_to_mouse() returns one of first four these values, possibly with
// some of the other three added.
diff --git a/src/nvim/move.c b/src/nvim/move.c
index c4f8e81fa3..918e0a5c4f 100644
--- a/src/nvim/move.c
+++ b/src/nvim/move.c
@@ -2104,7 +2104,6 @@ static void get_scroll_overlap(lineoff_T *lp, int dir)
} else {
*lp = loff2; // 2 lines overlap
}
- return;
}
// Scroll 'scroll' lines up or down.
diff --git a/src/nvim/move.h b/src/nvim/move.h
index 3670dc9086..dd944e39ee 100644
--- a/src/nvim/move.h
+++ b/src/nvim/move.h
@@ -2,6 +2,7 @@
#define NVIM_MOVE_H
#include <stdbool.h>
+
#include "nvim/vim.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
diff --git a/src/nvim/msgpack_rpc/channel.h b/src/nvim/msgpack_rpc/channel.h
index 90e1c7d48b..eb0de47437 100644
--- a/src/nvim/msgpack_rpc/channel.h
+++ b/src/nvim/msgpack_rpc/channel.h
@@ -5,10 +5,10 @@
#include <uv.h>
#include "nvim/api/private/defs.h"
-#include "nvim/event/socket.h"
+#include "nvim/channel.h"
#include "nvim/event/process.h"
+#include "nvim/event/socket.h"
#include "nvim/vim.h"
-#include "nvim/channel.h"
#define METHOD_MAXLEN 512
diff --git a/src/nvim/msgpack_rpc/channel_defs.h b/src/nvim/msgpack_rpc/channel_defs.h
index de328af1ce..6647779db9 100644
--- a/src/nvim/msgpack_rpc/channel_defs.h
+++ b/src/nvim/msgpack_rpc/channel_defs.h
@@ -1,13 +1,13 @@
#ifndef NVIM_MSGPACK_RPC_CHANNEL_DEFS_H
#define NVIM_MSGPACK_RPC_CHANNEL_DEFS_H
+#include <msgpack.h>
#include <stdbool.h>
#include <uv.h>
-#include <msgpack.h>
#include "nvim/api/private/defs.h"
-#include "nvim/event/socket.h"
#include "nvim/event/process.h"
+#include "nvim/event/socket.h"
#include "nvim/vim.h"
typedef struct Channel Channel;
diff --git a/src/nvim/msgpack_rpc/helpers.c b/src/nvim/msgpack_rpc/helpers.c
index 549016e751..f805858904 100644
--- a/src/nvim/msgpack_rpc/helpers.c
+++ b/src/nvim/msgpack_rpc/helpers.c
@@ -22,42 +22,6 @@
static msgpack_zone zone;
static msgpack_sbuffer sbuffer;
-#define HANDLE_TYPE_CONVERSION_IMPL(t, lt) \
- static bool msgpack_rpc_to_##lt(const msgpack_object *const obj, \
- Integer *const arg) \
- FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT \
- { \
- if (obj->type != MSGPACK_OBJECT_EXT \
- || obj->via.ext.type + EXT_OBJECT_TYPE_SHIFT != kObjectType##t) { \
- return false; \
- } \
- \
- msgpack_object data; \
- msgpack_unpack_return ret = msgpack_unpack(obj->via.ext.ptr, \
- obj->via.ext.size, \
- NULL, \
- &zone, \
- &data); \
- \
- if (ret != MSGPACK_UNPACK_SUCCESS) { \
- return false; \
- } \
- \
- *arg = (handle_T)data.via.i64; \
- return true; \
- } \
- \
- static void msgpack_rpc_from_##lt(Integer o, msgpack_packer *res) \
- FUNC_ATTR_NONNULL_ARG(2) \
- { \
- msgpack_packer pac; \
- msgpack_packer_init(&pac, &sbuffer, msgpack_sbuffer_write); \
- msgpack_pack_int64(&pac, (handle_T)o); \
- msgpack_pack_ext(res, sbuffer.size, \
- kObjectType##t - EXT_OBJECT_TYPE_SHIFT); \
- msgpack_pack_ext_body(res, sbuffer.data, sbuffer.size); \
- msgpack_sbuffer_clear(&sbuffer); \
- }
void msgpack_rpc_helpers_init(void)
{
@@ -65,10 +29,6 @@ void msgpack_rpc_helpers_init(void)
msgpack_sbuffer_init(&sbuffer);
}
-HANDLE_TYPE_CONVERSION_IMPL(Buffer, buffer)
-HANDLE_TYPE_CONVERSION_IMPL(Window, window)
-HANDLE_TYPE_CONVERSION_IMPL(Tabpage, tabpage)
-
typedef struct {
const msgpack_object *mobj;
Object *aobj;
@@ -226,28 +186,18 @@ case type: { \
break;
}
case MSGPACK_OBJECT_EXT:
- switch ((ObjectType)(cur.mobj->via.ext.type + EXT_OBJECT_TYPE_SHIFT)) {
- case kObjectTypeBuffer:
- cur.aobj->type = kObjectTypeBuffer;
- ret = msgpack_rpc_to_buffer(cur.mobj, &cur.aobj->data.integer);
- break;
- case kObjectTypeWindow:
- cur.aobj->type = kObjectTypeWindow;
- ret = msgpack_rpc_to_window(cur.mobj, &cur.aobj->data.integer);
- break;
- case kObjectTypeTabpage:
- cur.aobj->type = kObjectTypeTabpage;
- ret = msgpack_rpc_to_tabpage(cur.mobj, &cur.aobj->data.integer);
- break;
- case kObjectTypeNil:
- case kObjectTypeBoolean:
- case kObjectTypeInteger:
- case kObjectTypeFloat:
- case kObjectTypeString:
- case kObjectTypeArray:
- case kObjectTypeDictionary:
- case kObjectTypeLuaRef:
- break;
+ if (0 <= cur.mobj->via.ext.type && cur.mobj->via.ext.type <= EXT_OBJECT_TYPE_MAX) {
+ cur.aobj->type = (ObjectType)(cur.mobj->via.ext.type + EXT_OBJECT_TYPE_SHIFT);
+ msgpack_object data;
+ msgpack_unpack_return status = msgpack_unpack(cur.mobj->via.ext.ptr, cur.mobj->via.ext.size,
+ NULL, &zone, &data);
+
+ if (status != MSGPACK_UNPACK_SUCCESS || data.type != MSGPACK_OBJECT_POSITIVE_INTEGER) {
+ ret = false;
+ break;
+ }
+ cur.aobj->data.integer = (handle_T)data.via.i64;
+ ret = true;
}
break;
#undef STR_CASE
@@ -349,6 +299,17 @@ void msgpack_rpc_from_string(const String result, msgpack_packer *res)
}
}
+static void msgpack_rpc_from_handle(ObjectType type, Integer o, msgpack_packer *res)
+ FUNC_ATTR_NONNULL_ARG(3)
+{
+ msgpack_packer pac;
+ msgpack_packer_init(&pac, &sbuffer, msgpack_sbuffer_write);
+ msgpack_pack_int64(&pac, (handle_T)o);
+ msgpack_pack_ext(res, sbuffer.size, (int8_t)(type - EXT_OBJECT_TYPE_SHIFT));
+ msgpack_pack_ext_body(res, sbuffer.data, sbuffer.size);
+ msgpack_sbuffer_clear(&sbuffer);
+}
+
typedef struct {
const Object *aobj;
bool container;
@@ -393,13 +354,9 @@ void msgpack_rpc_from_object(const Object result, msgpack_packer *const res)
msgpack_rpc_from_string(cur.aobj->data.string, res);
break;
case kObjectTypeBuffer:
- msgpack_rpc_from_buffer(cur.aobj->data.integer, res);
- break;
case kObjectTypeWindow:
- msgpack_rpc_from_window(cur.aobj->data.integer, res);
- break;
case kObjectTypeTabpage:
- msgpack_rpc_from_tabpage(cur.aobj->data.integer, res);
+ msgpack_rpc_from_handle(cur.aobj->type, cur.aobj->data.integer, res);
break;
case kObjectTypeArray: {
const size_t size = cur.aobj->data.array.size;
diff --git a/src/nvim/msgpack_rpc/helpers.h b/src/nvim/msgpack_rpc/helpers.h
index 0e4cd1be6d..e5fd92374d 100644
--- a/src/nvim/msgpack_rpc/helpers.h
+++ b/src/nvim/msgpack_rpc/helpers.h
@@ -1,13 +1,12 @@
#ifndef NVIM_MSGPACK_RPC_HELPERS_H
#define NVIM_MSGPACK_RPC_HELPERS_H
-#include <stdint.h>
-#include <stdbool.h>
-
#include <msgpack.h>
+#include <stdbool.h>
+#include <stdint.h>
-#include "nvim/event/wstream.h"
#include "nvim/api/private/defs.h"
+#include "nvim/event/wstream.h"
/// Value by which objects represented as EXT type are shifted
///
@@ -15,6 +14,7 @@
/// buffer/window/tabpage block inside ObjectType enum. This block yet cannot be
/// split or reordered.
#define EXT_OBJECT_TYPE_SHIFT kObjectTypeBuffer
+#define EXT_OBJECT_TYPE_MAX (kObjectTypeTabpage - EXT_OBJECT_TYPE_SHIFT)
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "msgpack_rpc/helpers.h.generated.h"
diff --git a/src/nvim/normal.h b/src/nvim/normal.h
index 8e15e909d4..fbcc6da75b 100644
--- a/src/nvim/normal.h
+++ b/src/nvim/normal.h
@@ -2,13 +2,14 @@
#define NVIM_NORMAL_H
#include <stdbool.h>
-#include "nvim/pos.h"
+
#include "nvim/buffer_defs.h" // for win_T
+#include "nvim/pos.h"
-/* Values for find_ident_under_cursor() */
-#define FIND_IDENT 1 /* find identifier (word) */
-#define FIND_STRING 2 /* find any string (WORD) */
-#define FIND_EVAL 4 /* include "->", "[]" and "." */
+// Values for find_ident_under_cursor()
+#define FIND_IDENT 1 // find identifier (word)
+#define FIND_STRING 2 // find any string (WORD)
+#define FIND_EVAL 4 // include "->", "[]" and "."
/// Motion types, used for operators and for yank/delete registers.
///
@@ -56,24 +57,24 @@ typedef struct oparg_S {
* Arguments for Normal mode commands.
*/
typedef struct cmdarg_S {
- oparg_T *oap; /* Operator arguments */
- int prechar; /* prefix character (optional, always 'g') */
- int cmdchar; /* command character */
- int nchar; /* next command character (optional) */
- int ncharC1; /* first composing character (optional) */
- int ncharC2; /* second composing character (optional) */
- int extra_char; /* yet another character (optional) */
- long opcount; /* count before an operator */
- long count0; /* count before command, default 0 */
- long count1; /* count before command, default 1 */
- int arg; /* extra argument from nv_cmds[] */
- int retval; /* return: CA_* values */
- char_u *searchbuf; /* return: pointer to search pattern or NULL */
+ oparg_T *oap; // Operator arguments
+ int prechar; // prefix character (optional, always 'g')
+ int cmdchar; // command character
+ int nchar; // next command character (optional)
+ int ncharC1; // first composing character (optional)
+ int ncharC2; // second composing character (optional)
+ int extra_char; // yet another character (optional)
+ long opcount; // count before an operator
+ long count0; // count before command, default 0
+ long count1; // count before command, default 1
+ int arg; // extra argument from nv_cmds[]
+ int retval; // return: CA_* values
+ char_u *searchbuf; // return: pointer to search pattern or NULL
} cmdarg_T;
-/* values for retval: */
-#define CA_COMMAND_BUSY 1 /* skip restarting edit() once */
-#define CA_NO_ADJ_OP_END 2 /* don't adjust operator end */
+// values for retval:
+#define CA_COMMAND_BUSY 1 // skip restarting edit() once
+#define CA_NO_ADJ_OP_END 2 // don't adjust operator end
#ifdef INCLUDE_GENERATED_DECLARATIONS
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index 8d36bc9aa4..55c34586cb 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -2817,17 +2817,17 @@ static void do_autocmd_textyankpost(oparg_T *oap, yankreg_T *reg)
tv_list_append_string(list, (const char *)reg->y_array[i], -1);
}
tv_list_set_lock(list, VAR_FIXED);
- tv_dict_add_list(dict, S_LEN("regcontents"), list);
+ (void)tv_dict_add_list(dict, S_LEN("regcontents"), list);
// Register type.
char buf[NUMBUFLEN+2];
format_reg_type(reg->y_type, reg->y_width, buf, ARRAY_SIZE(buf));
- tv_dict_add_str(dict, S_LEN("regtype"), buf);
+ (void)tv_dict_add_str(dict, S_LEN("regtype"), buf);
// Name of requested register, or empty string for unnamed operation.
buf[0] = (char)oap->regname;
buf[1] = NUL;
- tv_dict_add_str(dict, S_LEN("regname"), buf);
+ (void)tv_dict_add_str(dict, S_LEN("regname"), buf);
// Motion type: inclusive or exclusive.
tv_dict_add_bool(dict, S_LEN("inclusive"),
@@ -2836,11 +2836,11 @@ static void do_autocmd_textyankpost(oparg_T *oap, yankreg_T *reg)
// Kind of operation: yank, delete, change).
buf[0] = (char)get_op_char(oap->op_type);
buf[1] = NUL;
- tv_dict_add_str(dict, S_LEN("operator"), buf);
+ (void)tv_dict_add_str(dict, S_LEN("operator"), buf);
// Selection type: visual or not.
- tv_dict_add_bool(dict, S_LEN("visual"),
- oap->is_VIsual ? kBoolVarTrue : kBoolVarFalse);
+ (void)tv_dict_add_bool(dict, S_LEN("visual"),
+ oap->is_VIsual ? kBoolVarTrue : kBoolVarFalse);
tv_dict_set_keys_readonly(dict);
textlock++;
@@ -4252,7 +4252,7 @@ void op_formatexpr(oparg_T *oap)
/// @param c character to be inserted
int fex_format(linenr_T lnum, long count, int c)
{
- int use_sandbox = was_set_insecurely(curwin, (char_u *)"formatexpr", OPT_LOCAL);
+ int use_sandbox = was_set_insecurely(curwin, "formatexpr", OPT_LOCAL);
int r;
char_u *fex;
@@ -4816,7 +4816,7 @@ void op_addsub(oparg_T *oap, linenr_T Prenum1, bool g_cmd)
if (change_cnt == 1) {
MSG(_("1 line changed"));
} else {
- smsg((char *)_("%" PRId64 " lines changed"), (int64_t)change_cnt);
+ smsg(_("%" PRId64 " lines changed"), (int64_t)change_cnt);
}
}
}
@@ -6055,7 +6055,7 @@ bool prepare_yankreg_from_object(yankreg_T *reg, String regtype, size_t lines)
void finish_yankreg_from_object(yankreg_T *reg, bool clipboard_adjust)
{
- if (reg->y_size > 0 && strlen((char *)reg->y_array[reg->y_size-1]) == 0) {
+ if (reg->y_size > 0 && STRLEN(reg->y_array[reg->y_size-1]) == 0) {
// a known-to-be charwise yank might have a final linebreak
// but otherwise there is no line after the final newline
if (reg->y_type != kMTCharWise) {
@@ -6120,7 +6120,7 @@ static bool get_clipboard(int name, yankreg_T **target, bool quiet)
goto err;
}
char_u *regtype = TV_LIST_ITEM_TV(tv_list_last(res))->vval.v_string;
- if (regtype == NULL || strlen((char *)regtype) > 1) {
+ if (regtype == NULL || STRLEN(regtype) > 1) {
goto err;
}
switch (regtype[0]) {
@@ -6163,7 +6163,7 @@ static bool get_clipboard(int name, yankreg_T **target, bool quiet)
reg->y_array[tv_idx++] = (char_u *)xstrdupnul((const char *)TV_LIST_ITEM_TV(li)->vval.v_string);
});
- if (reg->y_size > 0 && strlen((char *)reg->y_array[reg->y_size-1]) == 0) {
+ if (reg->y_size > 0 && STRLEN(reg->y_array[reg->y_size-1]) == 0) {
// a known-to-be charwise yank might have a final linebreak
// but otherwise there is no line after the final newline
if (reg->y_type != kMTCharWise) {
diff --git a/src/nvim/ops.h b/src/nvim/ops.h
index 5b87746921..11049b72c0 100644
--- a/src/nvim/ops.h
+++ b/src/nvim/ops.h
@@ -3,14 +3,14 @@
#include <stdbool.h>
-#include "nvim/macros.h"
#include "nvim/ascii.h"
-#include "nvim/types.h"
-#include "nvim/extmark.h"
#include "nvim/eval/typval.h"
+#include "nvim/ex_cmds_defs.h" // for exarg_T
+#include "nvim/extmark.h"
+#include "nvim/macros.h"
+#include "nvim/normal.h" // for MotionType and oparg_T
#include "nvim/os/time.h"
-#include "nvim/normal.h" // for MotionType and oparg_T
-#include "nvim/ex_cmds_defs.h" // for exarg_T
+#include "nvim/types.h"
typedef int (*Indenter)(void);
diff --git a/src/nvim/option.c b/src/nvim/option.c
index e6c7e416fb..9466e841ce 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -2072,9 +2072,9 @@ static void check_string_option(char_u **pp)
/// Return true when option "opt" was set from a modeline or in secure mode.
/// Return false when it wasn't.
/// Return -1 for an unknown option.
-int was_set_insecurely(win_T *const wp, char_u *opt, int opt_flags)
+int was_set_insecurely(win_T *const wp, char *opt, int opt_flags)
{
- int idx = findoption((const char *)opt);
+ int idx = findoption(opt);
if (idx >= 0) {
uint32_t *flagp = insecure_flag(wp, idx, opt_flags);
@@ -3288,7 +3288,7 @@ ambw_end:
if (p > q) {
vim_snprintf((char *)fname, sizeof(fname), "spell/%.*s.vim",
(int)(p - q), q);
- source_runtime(fname, DIP_ALL);
+ source_runtime((char *)fname, DIP_ALL);
}
}
}
@@ -3745,7 +3745,7 @@ static bool parse_winhl_opt(win_T *wp)
char *hi = colon+1;
char *commap = xstrchrnul(hi, ',');
int len = (int)(commap-hi);
- int hl_id = len ? syn_check_group((char_u *)hi, len) : -1;
+ int hl_id = len ? syn_check_group(hi, len) : -1;
if (strncmp("Normal", p, nlen) == 0) {
w_hl_id_normal = hl_id;
@@ -3899,7 +3899,7 @@ static char *set_bool_option(const int opt_idx, char_u *const varp, const int va
// when 'buflisted' changes, trigger autocommands
apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE,
NULL, NULL, true, curbuf);
- } else if ((int *)varp == (int *)&curbuf->b_p_swf) {
+ } else if ((int *)varp == &curbuf->b_p_swf) {
// when 'swf' is set, create swapfile, when reset remove swapfile
if (curbuf->b_p_swf && p_uc) {
ml_open_file(curbuf); // create the swap file
@@ -6509,8 +6509,6 @@ void set_context_in_set_cmd(expand_T *xp, char_u *arg, int opt_flags)
break;
}
}
-
- return;
}
int ExpandSettings(expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***file)
diff --git a/src/nvim/option.h b/src/nvim/option.h
index c6ee03e052..452494172f 100644
--- a/src/nvim/option.h
+++ b/src/nvim/option.h
@@ -3,10 +3,10 @@
#include "nvim/ex_cmds_defs.h" // for exarg_T
-/* flags for buf_copy_options() */
-#define BCO_ENTER 1 /* going to enter the buffer */
-#define BCO_ALWAYS 2 /* always copy the options */
-#define BCO_NOHELP 4 /* don't touch the help related options */
+// flags for buf_copy_options()
+#define BCO_ENTER 1 // going to enter the buffer
+#define BCO_ALWAYS 2 // always copy the options
+#define BCO_NOHELP 4 // don't touch the help related options
/// Flags for option-setting functions
///
diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h
index e588d3f373..2f931fed04 100644
--- a/src/nvim/option_defs.h
+++ b/src/nvim/option_defs.h
@@ -1,9 +1,9 @@
#ifndef NVIM_OPTION_DEFS_H
#define NVIM_OPTION_DEFS_H
-#include "nvim/types.h"
-#include "nvim/macros.h" // For EXTERN
#include "eval/typval.h" // For scid_T
+#include "nvim/macros.h" // For EXTERN
+#include "nvim/types.h"
// option_defs.h: definition of global variables for settable options
@@ -25,9 +25,11 @@
// The "%f|%l| %m" one is used for when the contents of the quickfix window is
// written to a file.
#ifdef WIN32
-# define DFLT_EFM "%f(%l) \\=: %t%*\\D%n: %m,%*[^\"]\"%f\"%*\\D%l: %m,%f(%l) \\=: %m,%*[^ ] %f %l: %m,%f:%l:%c:%m,%f(%l):%m,%f:%l:%m,%f|%l| %m"
+# define DFLT_EFM \
+ "%f(%l) \\=: %t%*\\D%n: %m,%*[^\"]\"%f\"%*\\D%l: %m,%f(%l) \\=: %m,%*[^ ] %f %l: %m,%f:%l:%c:%m,%f(%l):%m,%f:%l:%m,%f|%l| %m"
#else
-# define DFLT_EFM "%*[^\"]\"%f\"%*\\D%l: %m,\"%f\"%*\\D%l: %m,%-G%f:%l: (Each undeclared identifier is reported only once,%-G%f:%l: for each function it appears in.),%-GIn file included from %f:%l:%c:,%-GIn file included from %f:%l:%c\\,,%-GIn file included from %f:%l:%c,%-GIn file included from %f:%l,%-G%*[ ]from %f:%l:%c,%-G%*[ ]from %f:%l:,%-G%*[ ]from %f:%l\\,,%-G%*[ ]from %f:%l,%f:%l:%c:%m,%f(%l):%m,%f:%l:%m,\"%f\"\\, line %l%*\\D%c%*[^ ] %m,%D%*\\a[%*\\d]: Entering directory %*[`']%f',%X%*\\a[%*\\d]: Leaving directory %*[`']%f',%D%*\\a: Entering directory %*[`']%f',%X%*\\a: Leaving directory %*[`']%f',%DMaking %*\\a in %f,%f|%l| %m"
+# define DFLT_EFM \
+ "%*[^\"]\"%f\"%*\\D%l: %m,\"%f\"%*\\D%l: %m,%-G%f:%l: (Each undeclared identifier is reported only once,%-G%f:%l: for each function it appears in.),%-GIn file included from %f:%l:%c:,%-GIn file included from %f:%l:%c\\,,%-GIn file included from %f:%l:%c,%-GIn file included from %f:%l,%-G%*[ ]from %f:%l:%c,%-G%*[ ]from %f:%l:,%-G%*[ ]from %f:%l\\,,%-G%*[ ]from %f:%l,%f:%l:%c:%m,%f(%l):%m,%f:%l:%m,\"%f\"\\, line %l%*\\D%c%*[^ ] %m,%D%*\\a[%*\\d]: Entering directory %*[`']%f',%X%*\\a[%*\\d]: Leaving directory %*[`']%f',%D%*\\a: Entering directory %*[`']%f',%X%*\\a: Leaving directory %*[`']%f',%DMaking %*\\a in %f,%f|%l| %m"
#endif
#define DFLT_GREPFORMAT "%f:%l:%m,%f:%l%m,%f %l%m"
@@ -42,17 +44,17 @@
# define DFLT_FFS_VIM "dos,unix"
# define DFLT_FFS_VI "dos,unix" // also autodetect in compatible mode
#else
-# define DFLT_FF "unix"
-# define DFLT_FFS_VIM "unix,dos"
-# define DFLT_FFS_VI ""
+# define DFLT_FF "unix"
+# define DFLT_FFS_VIM "unix,dos"
+# define DFLT_FFS_VI ""
#endif
// Possible values for 'encoding'
-# define ENC_UCSBOM "ucs-bom" // check for BOM at start of file
+#define ENC_UCSBOM "ucs-bom" // check for BOM at start of file
// default value for 'encoding'
-# define ENC_DFLT "utf-8"
+#define ENC_DFLT "utf-8"
// end-of-line style
#define EOL_UNKNOWN -1 // not defined yet
@@ -179,9 +181,9 @@ enum {
};
/// Represented by 'a' flag.
#define SHM_ALL_ABBREVIATIONS ((char_u[]) { \
- SHM_RO, SHM_MOD, SHM_FILE, SHM_LAST, SHM_TEXT, SHM_LINES, SHM_NEW, SHM_WRI, \
- 0, \
-})
+ SHM_RO, SHM_MOD, SHM_FILE, SHM_LAST, SHM_TEXT, SHM_LINES, SHM_NEW, SHM_WRI, \
+ 0, \
+ })
// characters for p_go:
#define GO_ASEL 'a' // autoselect
@@ -264,16 +266,16 @@ enum {
};
/// C string containing all 'statusline' option flags
#define STL_ALL ((char_u[]) { \
- STL_FILEPATH, STL_FULLPATH, STL_FILENAME, STL_COLUMN, STL_VIRTCOL, \
- STL_VIRTCOL_ALT, STL_LINE, STL_NUMLINES, STL_BUFNO, STL_KEYMAP, STL_OFFSET, \
- STL_OFFSET_X, STL_BYTEVAL, STL_BYTEVAL_X, STL_ROFLAG, STL_ROFLAG_ALT, \
- STL_HELPFLAG, STL_HELPFLAG_ALT, STL_FILETYPE, STL_FILETYPE_ALT, \
- STL_PREVIEWFLAG, STL_PREVIEWFLAG_ALT, STL_MODIFIED, STL_MODIFIED_ALT, \
- STL_QUICKFIX, STL_PERCENTAGE, STL_ALTPERCENT, STL_ARGLISTSTAT, STL_PAGENUM, \
- STL_VIM_EXPR, STL_SEPARATE, STL_TRUNCMARK, STL_USER_HL, STL_HIGHLIGHT, \
- STL_TABPAGENR, STL_TABCLOSENR, STL_CLICK_FUNC, \
- 0, \
-})
+ STL_FILEPATH, STL_FULLPATH, STL_FILENAME, STL_COLUMN, STL_VIRTCOL, \
+ STL_VIRTCOL_ALT, STL_LINE, STL_NUMLINES, STL_BUFNO, STL_KEYMAP, STL_OFFSET, \
+ STL_OFFSET_X, STL_BYTEVAL, STL_BYTEVAL_X, STL_ROFLAG, STL_ROFLAG_ALT, \
+ STL_HELPFLAG, STL_HELPFLAG_ALT, STL_FILETYPE, STL_FILETYPE_ALT, \
+ STL_PREVIEWFLAG, STL_PREVIEWFLAG_ALT, STL_MODIFIED, STL_MODIFIED_ALT, \
+ STL_QUICKFIX, STL_PERCENTAGE, STL_ALTPERCENT, STL_ARGLISTSTAT, STL_PAGENUM, \
+ STL_VIM_EXPR, STL_SEPARATE, STL_TRUNCMARK, STL_USER_HL, STL_HIGHLIGHT, \
+ STL_TABPAGENR, STL_TABCLOSENR, STL_CLICK_FUNC, \
+ 0, \
+ })
// flags used for parsed 'wildmode'
#define WIM_FULL 0x01
@@ -305,36 +307,36 @@ enum {
EXTERN long p_aleph; // 'aleph'
EXTERN int p_acd; // 'autochdir'
-EXTERN char_u *p_ambw; // 'ambiwidth'
+EXTERN char_u *p_ambw; // 'ambiwidth'
EXTERN int p_ar; // 'autoread'
EXTERN int p_aw; // 'autowrite'
EXTERN int p_awa; // 'autowriteall'
-EXTERN char_u *p_bs; // 'backspace'
-EXTERN char_u *p_bg; // 'background'
+EXTERN char_u *p_bs; // 'backspace'
+EXTERN char_u *p_bg; // 'background'
EXTERN int p_bk; // 'backup'
-EXTERN char_u *p_bkc; // 'backupcopy'
+EXTERN char_u *p_bkc; // 'backupcopy'
EXTERN unsigned int bkc_flags; ///< flags from 'backupcopy'
#ifdef IN_OPTION_C
static char *(p_bkc_values[]) =
-{"yes", "auto", "no", "breaksymlink", "breakhardlink", NULL};
+{ "yes", "auto", "no", "breaksymlink", "breakhardlink", NULL };
#endif
-# define BKC_YES 0x001
-# define BKC_AUTO 0x002
-# define BKC_NO 0x004
-# define BKC_BREAKSYMLINK 0x008
-# define BKC_BREAKHARDLINK 0x010
+#define BKC_YES 0x001
+#define BKC_AUTO 0x002
+#define BKC_NO 0x004
+#define BKC_BREAKSYMLINK 0x008
+#define BKC_BREAKHARDLINK 0x010
EXTERN char_u *p_bdir; // 'backupdir'
EXTERN char_u *p_bex; // 'backupext'
EXTERN char_u *p_bo; // 'belloff'
EXTERN char breakat_flags[256]; // which characters are in 'breakat'
EXTERN unsigned bo_flags;
-# ifdef IN_OPTION_C
-static char *(p_bo_values[]) = {"all", "backspace", "cursor", "complete",
- "copy", "ctrlg", "error", "esc", "ex",
- "hangul", "insertmode", "lang", "mess",
- "showmatch", "operator", "register", "shell",
- "spell", "wildmode", NULL};
-# endif
+#ifdef IN_OPTION_C
+static char *(p_bo_values[]) = { "all", "backspace", "cursor", "complete",
+ "copy", "ctrlg", "error", "esc", "ex",
+ "hangul", "insertmode", "lang", "mess",
+ "showmatch", "operator", "register", "shell",
+ "spell", "wildmode", NULL };
+#endif
// values for the 'belloff' option
#define BO_ALL 0x0001
@@ -357,61 +359,61 @@ static char *(p_bo_values[]) = {"all", "backspace", "cursor", "complete",
#define BO_SPELL 0x20000
#define BO_WILD 0x40000
-EXTERN char_u *p_bsk; // 'backupskip'
-EXTERN char_u *p_breakat; // 'breakat'
-EXTERN char_u *p_cmp; // 'casemap'
+EXTERN char_u *p_bsk; // 'backupskip'
+EXTERN char_u *p_breakat; // 'breakat'
+EXTERN char_u *p_cmp; // 'casemap'
EXTERN unsigned cmp_flags;
-# ifdef IN_OPTION_C
-static char *(p_cmp_values[]) = {"internal", "keepascii", NULL};
-# endif
-# define CMP_INTERNAL 0x001
-# define CMP_KEEPASCII 0x002
-EXTERN char_u *p_enc; // 'encoding'
+#ifdef IN_OPTION_C
+static char *(p_cmp_values[]) = { "internal", "keepascii", NULL };
+#endif
+#define CMP_INTERNAL 0x001
+#define CMP_KEEPASCII 0x002
+EXTERN char_u *p_enc; // 'encoding'
EXTERN int p_deco; // 'delcombine'
-EXTERN char_u *p_ccv; // 'charconvert'
-EXTERN char_u *p_cedit; // 'cedit'
-EXTERN char_u *p_cb; // 'clipboard'
+EXTERN char_u *p_ccv; // 'charconvert'
+EXTERN char_u *p_cedit; // 'cedit'
+EXTERN char_u *p_cb; // 'clipboard'
EXTERN unsigned cb_flags;
#ifdef IN_OPTION_C
-static char *(p_cb_values[]) = {"unnamed", "unnamedplus", NULL};
+static char *(p_cb_values[]) = { "unnamed", "unnamedplus", NULL };
#endif
-# define CB_UNNAMED 0x001
-# define CB_UNNAMEDPLUS 0x002
-# define CB_UNNAMEDMASK (CB_UNNAMED | CB_UNNAMEDPLUS)
+#define CB_UNNAMED 0x001
+#define CB_UNNAMEDPLUS 0x002
+#define CB_UNNAMEDMASK (CB_UNNAMED | CB_UNNAMEDPLUS)
EXTERN long p_cwh; // 'cmdwinheight'
EXTERN long p_ch; // 'cmdheight'
EXTERN long p_columns; // 'columns'
EXTERN int p_confirm; // 'confirm'
-EXTERN char_u *p_cot; // 'completeopt'
-# ifdef BACKSLASH_IN_FILENAME
-EXTERN char_u *p_csl; // 'completeslash'
-# endif
+EXTERN char_u *p_cot; // 'completeopt'
+#ifdef BACKSLASH_IN_FILENAME
+EXTERN char_u *p_csl; // 'completeslash'
+#endif
EXTERN long p_pb; // 'pumblend'
EXTERN long p_ph; // 'pumheight'
EXTERN long p_pw; // 'pumwidth'
-EXTERN char_u *p_cpo; // 'cpoptions'
-EXTERN char_u *p_csprg; // 'cscopeprg'
+EXTERN char_u *p_cpo; // 'cpoptions'
+EXTERN char_u *p_csprg; // 'cscopeprg'
EXTERN int p_csre; // 'cscoperelative'
-EXTERN char_u *p_csqf; // 'cscopequickfix'
-# define CSQF_CMDS "sgdctefia"
-# define CSQF_FLAGS "+-0"
+EXTERN char_u *p_csqf; // 'cscopequickfix'
+#define CSQF_CMDS "sgdctefia"
+#define CSQF_FLAGS "+-0"
EXTERN int p_cst; // 'cscopetag'
EXTERN long p_csto; // 'cscopetagorder'
EXTERN long p_cspc; // 'cscopepathcomp'
EXTERN int p_csverbose; // 'cscopeverbose'
-EXTERN char_u *p_debug; // 'debug'
-EXTERN char_u *p_def; // 'define'
-EXTERN char_u *p_inc;
-EXTERN char_u *p_dip; // 'diffopt'
-EXTERN char_u *p_dex; // 'diffexpr'
-EXTERN char_u *p_dict; // 'dictionary'
+EXTERN char_u *p_debug; // 'debug'
+EXTERN char_u *p_def; // 'define'
+EXTERN char_u *p_inc;
+EXTERN char_u *p_dip; // 'diffopt'
+EXTERN char_u *p_dex; // 'diffexpr'
+EXTERN char_u *p_dict; // 'dictionary'
EXTERN int p_dg; // 'digraph'
-EXTERN char_u *p_dir; // 'directory'
-EXTERN char_u *p_dy; // 'display'
+EXTERN char_u *p_dir; // 'directory'
+EXTERN char_u *p_dy; // 'display'
EXTERN unsigned dy_flags;
#ifdef IN_OPTION_C
static char *(p_dy_values[]) = { "lastline", "truncate", "uhex", "msgsep",
- NULL };
+ NULL };
#endif
#define DY_LASTLINE 0x001
#define DY_TRUNCATE 0x002
@@ -420,72 +422,72 @@ static char *(p_dy_values[]) = { "lastline", "truncate", "uhex", "msgsep",
#define DY_MSGSEP 0x008
EXTERN int p_ed; // 'edcompatible'
EXTERN int p_emoji; // 'emoji'
-EXTERN char_u *p_ead; // 'eadirection'
+EXTERN char_u *p_ead; // 'eadirection'
EXTERN int p_ea; // 'equalalways'
-EXTERN char_u *p_ep; // 'equalprg'
+EXTERN char_u *p_ep; // 'equalprg'
EXTERN int p_eb; // 'errorbells'
-EXTERN char_u *p_ef; // 'errorfile'
-EXTERN char_u *p_efm; // 'errorformat'
-EXTERN char_u *p_gefm; // 'grepformat'
-EXTERN char_u *p_gp; // 'grepprg'
-EXTERN char_u *p_ei; // 'eventignore'
+EXTERN char_u *p_ef; // 'errorfile'
+EXTERN char_u *p_efm; // 'errorformat'
+EXTERN char_u *p_gefm; // 'grepformat'
+EXTERN char_u *p_gp; // 'grepprg'
+EXTERN char_u *p_ei; // 'eventignore'
EXTERN int p_exrc; // 'exrc'
-EXTERN char_u *p_fencs; // 'fileencodings'
-EXTERN char_u *p_ffs; // 'fileformats'
+EXTERN char_u *p_fencs; // 'fileencodings'
+EXTERN char_u *p_ffs; // 'fileformats'
EXTERN int p_fic; // 'fileignorecase'
-EXTERN char_u *p_fcl; // 'foldclose'
+EXTERN char_u *p_fcl; // 'foldclose'
EXTERN long p_fdls; // 'foldlevelstart'
-EXTERN char_u *p_fdo; // 'foldopen'
+EXTERN char_u *p_fdo; // 'foldopen'
EXTERN unsigned fdo_flags;
-# ifdef IN_OPTION_C
-static char *(p_fdo_values[]) = {"all", "block", "hor", "mark", "percent",
- "quickfix", "search", "tag", "insert",
- "undo", "jump", NULL};
-# endif
-# define FDO_ALL 0x001
-# define FDO_BLOCK 0x002
-# define FDO_HOR 0x004
-# define FDO_MARK 0x008
-# define FDO_PERCENT 0x010
-# define FDO_QUICKFIX 0x020
-# define FDO_SEARCH 0x040
-# define FDO_TAG 0x080
-# define FDO_INSERT 0x100
-# define FDO_UNDO 0x200
-# define FDO_JUMP 0x400
-EXTERN char_u *p_fp; // 'formatprg'
+#ifdef IN_OPTION_C
+static char *(p_fdo_values[]) = { "all", "block", "hor", "mark", "percent",
+ "quickfix", "search", "tag", "insert",
+ "undo", "jump", NULL };
+#endif
+#define FDO_ALL 0x001
+#define FDO_BLOCK 0x002
+#define FDO_HOR 0x004
+#define FDO_MARK 0x008
+#define FDO_PERCENT 0x010
+#define FDO_QUICKFIX 0x020
+#define FDO_SEARCH 0x040
+#define FDO_TAG 0x080
+#define FDO_INSERT 0x100
+#define FDO_UNDO 0x200
+#define FDO_JUMP 0x400
+EXTERN char_u *p_fp; // 'formatprg'
EXTERN int p_fs; // 'fsync'
EXTERN int p_gd; // 'gdefault'
-EXTERN char_u *p_pdev; // 'printdevice'
-EXTERN char_u *p_penc; // 'printencoding'
-EXTERN char_u *p_pexpr; // 'printexpr'
-EXTERN char_u *p_pmfn; // 'printmbfont'
-EXTERN char_u *p_pmcs; // 'printmbcharset'
-EXTERN char_u *p_pfn; // 'printfont'
-EXTERN char_u *p_popt; // 'printoptions'
-EXTERN char_u *p_header; // 'printheader'
-EXTERN char_u *p_guicursor; // 'guicursor'
-EXTERN char_u *p_guifont; // 'guifont'
-EXTERN char_u *p_guifontwide; // 'guifontwide'
-EXTERN char_u *p_hf; // 'helpfile'
+EXTERN char_u *p_pdev; // 'printdevice'
+EXTERN char_u *p_penc; // 'printencoding'
+EXTERN char_u *p_pexpr; // 'printexpr'
+EXTERN char_u *p_pmfn; // 'printmbfont'
+EXTERN char_u *p_pmcs; // 'printmbcharset'
+EXTERN char_u *p_pfn; // 'printfont'
+EXTERN char_u *p_popt; // 'printoptions'
+EXTERN char_u *p_header; // 'printheader'
+EXTERN char_u *p_guicursor; // 'guicursor'
+EXTERN char_u *p_guifont; // 'guifont'
+EXTERN char_u *p_guifontwide; // 'guifontwide'
+EXTERN char_u *p_hf; // 'helpfile'
EXTERN long p_hh; // 'helpheight'
-EXTERN char_u *p_hlg; // 'helplang'
+EXTERN char_u *p_hlg; // 'helplang'
EXTERN int p_hid; // 'hidden'
-EXTERN char_u *p_hl; // 'highlight'
+EXTERN char_u *p_hl; // 'highlight'
EXTERN int p_hls; // 'hlsearch'
EXTERN long p_hi; // 'history'
EXTERN int p_hkmap; // 'hkmap'
EXTERN int p_hkmapp; // 'hkmapp'
EXTERN int p_arshape; // 'arabicshape'
EXTERN int p_icon; // 'icon'
-EXTERN char_u *p_iconstring; // 'iconstring'
+EXTERN char_u *p_iconstring; // 'iconstring'
EXTERN int p_ic; // 'ignorecase'
EXTERN int p_is; // 'incsearch'
-EXTERN char_u *p_icm; // 'inccommand'
+EXTERN char_u *p_icm; // 'inccommand'
EXTERN int p_im; // 'insertmode'
-EXTERN char_u *p_isf; // 'isfname'
-EXTERN char_u *p_isi; // 'isident'
-EXTERN char_u *p_isp; // 'isprint'
+EXTERN char_u *p_isf; // 'isfname'
+EXTERN char_u *p_isi; // 'isident'
+EXTERN char_u *p_isp; // 'isprint'
EXTERN int p_js; // 'joinspaces'
EXTERN char_u *p_jop; // 'jumpooptions'
EXTERN unsigned jop_flags;
@@ -493,26 +495,26 @@ EXTERN unsigned jop_flags;
static char *(p_jop_values[]) = { "stack", NULL };
#endif
#define JOP_STACK 0x01
-EXTERN char_u *p_kp; // 'keywordprg'
-EXTERN char_u *p_km; // 'keymodel'
-EXTERN char_u *p_langmap; // 'langmap'
+EXTERN char_u *p_kp; // 'keywordprg'
+EXTERN char_u *p_km; // 'keymodel'
+EXTERN char_u *p_langmap; // 'langmap'
EXTERN int p_lnr; // 'langnoremap'
EXTERN int p_lrm; // 'langremap'
-EXTERN char_u *p_lm; // 'langmenu'
-EXTERN long p_lines; // 'lines'
-EXTERN long p_linespace; // 'linespace'
-EXTERN char_u *p_lispwords; // 'lispwords'
+EXTERN char_u *p_lm; // 'langmenu'
+EXTERN long p_lines; // 'lines'
+EXTERN long p_linespace; // 'linespace'
+EXTERN char_u *p_lispwords; // 'lispwords'
EXTERN long p_ls; // 'laststatus'
EXTERN long p_stal; // 'showtabline'
-EXTERN char_u *p_lcs; // 'listchars'
+EXTERN char_u *p_lcs; // 'listchars'
EXTERN int p_lz; // 'lazyredraw'
EXTERN int p_lpl; // 'loadplugins'
EXTERN int p_magic; // 'magic'
-EXTERN char_u *p_menc; // 'makeencoding'
-EXTERN char_u *p_mef; // 'makeef'
-EXTERN char_u *p_mp; // 'makeprg'
-EXTERN char_u *p_cc; // 'colorcolumn'
+EXTERN char_u *p_menc; // 'makeencoding'
+EXTERN char_u *p_mef; // 'makeef'
+EXTERN char_u *p_mp; // 'makeprg'
+EXTERN char_u *p_cc; // 'colorcolumn'
EXTERN int p_cc_cols[256]; // array for 'colorcolumn' columns
EXTERN long p_mat; // 'matchtime'
EXTERN long p_mco; // 'maxcombine'
@@ -520,26 +522,26 @@ EXTERN long p_mfd; // 'maxfuncdepth'
EXTERN long p_mmd; // 'maxmapdepth'
EXTERN long p_mmp; // 'maxmempattern'
EXTERN long p_mis; // 'menuitems'
-EXTERN char_u *p_msm; // 'mkspellmem'
+EXTERN char_u *p_msm; // 'mkspellmem'
EXTERN long p_mle; // 'modelineexpr'
EXTERN long p_mls; // 'modelines'
-EXTERN char_u *p_mouse; // 'mouse'
-EXTERN char_u *p_mousem; // 'mousemodel'
+EXTERN char_u *p_mouse; // 'mouse'
+EXTERN char_u *p_mousem; // 'mousemodel'
EXTERN long p_mousef; // 'mousefocus'
EXTERN long p_mouset; // 'mousetime'
EXTERN int p_more; // 'more'
-EXTERN char_u *p_opfunc; // 'operatorfunc'
-EXTERN char_u *p_para; // 'paragraphs'
+EXTERN char_u *p_opfunc; // 'operatorfunc'
+EXTERN char_u *p_para; // 'paragraphs'
EXTERN int p_paste; // 'paste'
-EXTERN char_u *p_pt; // 'pastetoggle'
-EXTERN char_u *p_pex; // 'patchexpr'
-EXTERN char_u *p_pm; // 'patchmode'
-EXTERN char_u *p_path; // 'path'
-EXTERN char_u *p_cdpath; // 'cdpath'
+EXTERN char_u *p_pt; // 'pastetoggle'
+EXTERN char_u *p_pex; // 'patchexpr'
+EXTERN char_u *p_pm; // 'patchmode'
+EXTERN char_u *p_path; // 'path'
+EXTERN char_u *p_cdpath; // 'cdpath'
EXTERN long p_pyx; // 'pyxversion'
EXTERN char_u *p_rdb; // 'redrawdebug'
EXTERN unsigned rdb_flags;
-# ifdef IN_OPTION_C
+#ifdef IN_OPTION_C
static char *(p_rdb_values[]) = {
"compositor",
"nothrottle",
@@ -547,11 +549,11 @@ static char *(p_rdb_values[]) = {
"nodelta",
NULL
};
-# endif
-# define RDB_COMPOSITOR 0x001
-# define RDB_NOTHROTTLE 0x002
-# define RDB_INVALID 0x004
-# define RDB_NODELTA 0x008
+#endif
+#define RDB_COMPOSITOR 0x001
+#define RDB_NOTHROTTLE 0x002
+#define RDB_INVALID 0x004
+#define RDB_NODELTA 0x008
EXTERN long p_rdt; // 'redrawtime'
EXTERN int p_remap; // 'remap'
@@ -561,21 +563,21 @@ EXTERN long p_pvh; // 'previewheight'
EXTERN int p_ari; // 'allowrevins'
EXTERN int p_ri; // 'revins'
EXTERN int p_ru; // 'ruler'
-EXTERN char_u *p_ruf; // 'rulerformat'
-EXTERN char_u *p_pp; // 'packpath'
-EXTERN char_u *p_qftf; // 'quickfixtextfunc'
-EXTERN char_u *p_rtp; // 'runtimepath'
+EXTERN char_u *p_ruf; // 'rulerformat'
+EXTERN char_u *p_pp; // 'packpath'
+EXTERN char_u *p_qftf; // 'quickfixtextfunc'
+EXTERN char_u *p_rtp; // 'runtimepath'
EXTERN long p_scbk; // 'scrollback'
EXTERN long p_sj; // 'scrolljump'
EXTERN long p_so; // 'scrolloff'
-EXTERN char_u *p_sbo; // 'scrollopt'
-EXTERN char_u *p_sections; // 'sections'
+EXTERN char_u *p_sbo; // 'scrollopt'
+EXTERN char_u *p_sections; // 'sections'
EXTERN int p_secure; // 'secure'
-EXTERN char_u *p_sel; // 'selection'
-EXTERN char_u *p_slm; // 'selectmode'
-EXTERN char_u *p_ssop; // 'sessionoptions'
+EXTERN char_u *p_sel; // 'selection'
+EXTERN char_u *p_slm; // 'selectmode'
+EXTERN char_u *p_ssop; // 'sessionoptions'
EXTERN unsigned ssop_flags;
-# ifdef IN_OPTION_C
+#ifdef IN_OPTION_C
// Also used for 'viewoptions'! Keep in sync with SSOP_ flags.
static char *(p_ssop_values[]) = {
"buffers", "winpos", "resize", "winsize",
@@ -583,41 +585,41 @@ static char *(p_ssop_values[]) = {
"sesdir", "curdir", "folds", "cursor", "tabpages", "terminal", "skiprtp",
NULL
};
-# endif
-# define SSOP_BUFFERS 0x001
-# define SSOP_WINPOS 0x002
-# define SSOP_RESIZE 0x004
-# define SSOP_WINSIZE 0x008
-# define SSOP_LOCALOPTIONS 0x010
-# define SSOP_OPTIONS 0x020
-# define SSOP_HELP 0x040
-# define SSOP_BLANK 0x080
-# define SSOP_GLOBALS 0x100
-# define SSOP_SLASH 0x200 // Deprecated, always set.
-# define SSOP_UNIX 0x400 // Deprecated, always set.
-# define SSOP_SESDIR 0x800
-# define SSOP_CURDIR 0x1000
-# define SSOP_FOLDS 0x2000
-# define SSOP_CURSOR 0x4000
-# define SSOP_TABPAGES 0x8000
-# define SSOP_TERMINAL 0x10000
-# define SSOP_SKIP_RTP 0x20000
-
-EXTERN char_u *p_sh; // 'shell'
-EXTERN char_u *p_shcf; // 'shellcmdflag'
-EXTERN char_u *p_sp; // 'shellpipe'
-EXTERN char_u *p_shq; // 'shellquote'
-EXTERN char_u *p_sxq; // 'shellxquote'
-EXTERN char_u *p_sxe; // 'shellxescape'
-EXTERN char_u *p_srr; // 'shellredir'
+#endif
+#define SSOP_BUFFERS 0x001
+#define SSOP_WINPOS 0x002
+#define SSOP_RESIZE 0x004
+#define SSOP_WINSIZE 0x008
+#define SSOP_LOCALOPTIONS 0x010
+#define SSOP_OPTIONS 0x020
+#define SSOP_HELP 0x040
+#define SSOP_BLANK 0x080
+#define SSOP_GLOBALS 0x100
+#define SSOP_SLASH 0x200 // Deprecated, always set.
+#define SSOP_UNIX 0x400 // Deprecated, always set.
+#define SSOP_SESDIR 0x800
+#define SSOP_CURDIR 0x1000
+#define SSOP_FOLDS 0x2000
+#define SSOP_CURSOR 0x4000
+#define SSOP_TABPAGES 0x8000
+#define SSOP_TERMINAL 0x10000
+#define SSOP_SKIP_RTP 0x20000
+
+EXTERN char_u *p_sh; // 'shell'
+EXTERN char_u *p_shcf; // 'shellcmdflag'
+EXTERN char_u *p_sp; // 'shellpipe'
+EXTERN char_u *p_shq; // 'shellquote'
+EXTERN char_u *p_sxq; // 'shellxquote'
+EXTERN char_u *p_sxe; // 'shellxescape'
+EXTERN char_u *p_srr; // 'shellredir'
EXTERN int p_stmp; // 'shelltemp'
#ifdef BACKSLASH_IN_FILENAME
EXTERN int p_ssl; // 'shellslash'
#endif
-EXTERN char_u *p_stl; // 'statusline'
+EXTERN char_u *p_stl; // 'statusline'
EXTERN int p_sr; // 'shiftround'
-EXTERN char_u *p_shm; // 'shortmess'
-EXTERN char_u *p_sbr; // 'showbreak'
+EXTERN char_u *p_shm; // 'shortmess'
+EXTERN char_u *p_sbr; // 'showbreak'
EXTERN int p_sc; // 'showcmd'
EXTERN int p_sft; // 'showfulltag'
EXTERN int p_sm; // 'showmatch'
@@ -628,29 +630,29 @@ EXTERN int p_scs; // 'smartcase'
EXTERN int p_sta; // 'smarttab'
EXTERN int p_sb; // 'splitbelow'
EXTERN long p_tpm; // 'tabpagemax'
-EXTERN char_u *p_tal; // 'tabline'
-EXTERN char_u *p_tpf; // 'termpastefilter'
+EXTERN char_u *p_tal; // 'tabline'
+EXTERN char_u *p_tpf; // 'termpastefilter'
EXTERN unsigned int tpf_flags; ///< flags from 'termpastefilter'
#ifdef IN_OPTION_C
static char *(p_tpf_values[]) =
- { "BS", "HT", "FF", "ESC", "DEL", "C0", "C1", NULL };
+{ "BS", "HT", "FF", "ESC", "DEL", "C0", "C1", NULL };
#endif
-# define TPF_BS 0x001
-# define TPF_HT 0x002
-# define TPF_FF 0x004
-# define TPF_ESC 0x008
-# define TPF_DEL 0x010
-# define TPF_C0 0x020
-# define TPF_C1 0x040
-EXTERN char_u *p_sps; // 'spellsuggest'
+#define TPF_BS 0x001
+#define TPF_HT 0x002
+#define TPF_FF 0x004
+#define TPF_ESC 0x008
+#define TPF_DEL 0x010
+#define TPF_C0 0x020
+#define TPF_C1 0x040
+EXTERN char_u *p_sps; // 'spellsuggest'
EXTERN int p_spr; // 'splitright'
EXTERN int p_sol; // 'startofline'
-EXTERN char_u *p_su; // 'suffixes'
-EXTERN char_u *p_swb; // 'switchbuf'
+EXTERN char_u *p_su; // 'suffixes'
+EXTERN char_u *p_swb; // 'switchbuf'
EXTERN unsigned swb_flags;
#ifdef IN_OPTION_C
static char *(p_swb_values[]) =
- { "useopen", "usetab", "split", "newtab", "vsplit", "uselast", NULL };
+{ "useopen", "usetab", "split", "newtab", "vsplit", "uselast", NULL };
#endif
#define SWB_USEOPEN 0x001
#define SWB_USETAB 0x002
@@ -663,7 +665,7 @@ EXTERN char_u *p_tc; ///< 'tagcase'
EXTERN unsigned tc_flags; ///< flags from 'tagcase'
#ifdef IN_OPTION_C
static char *(p_tc_values[]) =
- { "followic", "ignore", "match", "followscs", "smart", NULL };
+{ "followic", "ignore", "match", "followscs", "smart", NULL };
#endif
#define TC_FOLLOWIC 0x01
#define TC_IGNORE 0x02
@@ -701,35 +703,35 @@ EXTERN unsigned vop_flags; ///< uses SSOP_ flags
EXTERN int p_vb; ///< 'visualbell'
EXTERN char_u *p_ve; ///< 'virtualedit'
EXTERN unsigned ve_flags;
-# ifdef IN_OPTION_C
-static char *(p_ve_values[]) = {"block", "insert", "all", "onemore", NULL};
-# endif
-# define VE_BLOCK 5 // includes "all"
-# define VE_INSERT 6 // includes "all"
-# define VE_ALL 4
-# define VE_ONEMORE 8
+#ifdef IN_OPTION_C
+static char *(p_ve_values[]) = { "block", "insert", "all", "onemore", NULL };
+#endif
+#define VE_BLOCK 5 // includes "all"
+#define VE_INSERT 6 // includes "all"
+#define VE_ALL 4
+#define VE_ONEMORE 8
EXTERN long p_verbose; // 'verbose'
#ifdef IN_OPTION_C
char_u *p_vfile = (char_u *)""; // used before options are initialized
#else
-extern char_u *p_vfile; // 'verbosefile'
+extern char_u *p_vfile; // 'verbosefile'
#endif
EXTERN int p_warn; // 'warn'
-EXTERN char_u *p_wop; // 'wildoptions'
+EXTERN char_u *p_wop; // 'wildoptions'
EXTERN unsigned wop_flags;
-# ifdef IN_OPTION_C
+#ifdef IN_OPTION_C
static char *(p_wop_values[]) = { "tagfile", "pum", NULL };
#endif
#define WOP_TAGFILE 0x01
#define WOP_PUM 0x02
EXTERN long p_window; // 'window'
-EXTERN char_u *p_wak; // 'winaltkeys'
-EXTERN char_u *p_wig; // 'wildignore'
-EXTERN char_u *p_ww; // 'whichwrap'
+EXTERN char_u *p_wak; // 'winaltkeys'
+EXTERN char_u *p_wig; // 'wildignore'
+EXTERN char_u *p_ww; // 'whichwrap'
EXTERN long p_wc; // 'wildchar'
EXTERN long p_wcm; // 'wildcharm'
EXTERN int p_wic; // 'wildignorecase'
-EXTERN char_u *p_wim; // 'wildmode'
+EXTERN char_u *p_wim; // 'wildmode'
EXTERN int p_wmnu; // 'wildmenu'
EXTERN long p_wh; // 'winheight'
EXTERN long p_wmh; // 'winminheight'
diff --git a/src/nvim/os/input.h b/src/nvim/os/input.h
index d571965408..7026781407 100644
--- a/src/nvim/os/input.h
+++ b/src/nvim/os/input.h
@@ -1,8 +1,8 @@
#ifndef NVIM_OS_INPUT_H
#define NVIM_OS_INPUT_H
-#include <stdint.h>
#include <stdbool.h>
+#include <stdint.h>
#include "nvim/api/private/defs.h"
#include "nvim/event/multiqueue.h"
diff --git a/src/nvim/os/os.h b/src/nvim/os/os.h
index 3e89e5a94a..bff2936f8e 100644
--- a/src/nvim/os/os.h
+++ b/src/nvim/os/os.h
@@ -9,11 +9,11 @@
#include "nvim/vim.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
+# include "os/env.h.generated.h"
# include "os/fs.h.generated.h"
# include "os/mem.h.generated.h"
-# include "os/env.h.generated.h"
-# include "os/users.h.generated.h"
# include "os/stdpaths.h.generated.h"
+# include "os/users.h.generated.h"
#endif
#endif // NVIM_OS_OS_H
diff --git a/src/nvim/os/os_defs.h b/src/nvim/os/os_defs.h
index 1b7859b0d3..8049b3b80e 100644
--- a/src/nvim/os/os_defs.h
+++ b/src/nvim/os/os_defs.h
@@ -16,7 +16,7 @@
#define BASENAMELEN (NAME_MAX - 5)
// Use the system path length if it makes sense.
-# define DEFAULT_MAXPATHL 4096
+#define DEFAULT_MAXPATHL 4096
#if defined(PATH_MAX) && (PATH_MAX > DEFAULT_MAXPATHL)
# define MAXPATHL PATH_MAX
#else
diff --git a/src/nvim/os/os_win_console.c b/src/nvim/os/os_win_console.c
index 2c9cb699fc..18e2e02b81 100644
--- a/src/nvim/os/os_win_console.c
+++ b/src/nvim/os/os_win_console.c
@@ -46,29 +46,3 @@ void os_replace_stdout_and_stderr_to_conout(void)
const int conerr_fd = _open_osfhandle((intptr_t)conout_handle, 0);
assert(conerr_fd == STDERR_FILENO);
}
-
-void os_set_vtp(bool enable)
-{
- static TriState is_legacy = kNone;
- if (is_legacy == kNone) {
- uv_tty_vtermstate_t state;
- uv_tty_get_vterm_state(&state);
- is_legacy = (state == UV_TTY_UNSUPPORTED) ? kTrue : kFalse;
- }
- if (!is_legacy && !os_has_vti()) {
- uv_tty_set_vterm_state(enable ? UV_TTY_SUPPORTED : UV_TTY_UNSUPPORTED);
- }
-}
-
-static bool os_has_vti(void)
-{
- static TriState has_vti = kNone;
- if (has_vti == kNone) {
- HANDLE handle = (HANDLE)_get_osfhandle(input_global_fd());
- DWORD dwMode;
- if (handle != INVALID_HANDLE_VALUE && GetConsoleMode(handle, &dwMode)) {
- has_vti = !!(dwMode & ENABLE_VIRTUAL_TERMINAL_INPUT) ? kTrue : kFalse;
- }
- }
- return has_vti == kTrue;
-}
diff --git a/src/nvim/os/process.h b/src/nvim/os/process.h
index 1722d56bd3..faa4762cf1 100644
--- a/src/nvim/os/process.h
+++ b/src/nvim/os/process.h
@@ -2,6 +2,7 @@
#define NVIM_OS_PROCESS_H
#include <stddef.h>
+
#include "nvim/api/private/defs.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
diff --git a/src/nvim/os/time.h b/src/nvim/os/time.h
index ad4886446a..1b6c667dbb 100644
--- a/src/nvim/os/time.h
+++ b/src/nvim/os/time.h
@@ -1,8 +1,8 @@
#ifndef NVIM_OS_TIME_H
#define NVIM_OS_TIME_H
-#include <stdint.h>
#include <stdbool.h>
+#include <stdint.h>
#include <time.h>
typedef uint64_t Timestamp;
diff --git a/src/nvim/os/unix_defs.h b/src/nvim/os/unix_defs.h
index 60a2dfa882..4ed3b51694 100644
--- a/src/nvim/os/unix_defs.h
+++ b/src/nvim/os/unix_defs.h
@@ -1,8 +1,8 @@
#ifndef NVIM_OS_UNIX_DEFS_H
#define NVIM_OS_UNIX_DEFS_H
-#include <unistd.h>
#include <sys/param.h>
+#include <unistd.h>
// POSIX.1-2008 says that NAME_MAX should be in here
#include <limits.h>
diff --git a/src/nvim/os/win_defs.h b/src/nvim/os/win_defs.h
index 66d72de08d..efef77be7b 100644
--- a/src/nvim/os/win_defs.h
+++ b/src/nvim/os/win_defs.h
@@ -7,11 +7,14 @@
// winsock2.h must be first to avoid incompatibilities
// with winsock.h (included by windows.h)
+
+// uncrustify:off
#include <winsock2.h>
-#include <windows.h>
-#include <sys/stat.h>
+// uncrustify:on
#include <io.h>
#include <stdio.h>
+#include <sys/stat.h>
+#include <windows.h>
// Windows does not have S_IFLNK but libuv defines it
// and sets the flag for us when calling uv_fs_stat.
diff --git a/src/nvim/os_unix.h b/src/nvim/os_unix.h
index d627b16ec0..aae05f7fcc 100644
--- a/src/nvim/os_unix.h
+++ b/src/nvim/os_unix.h
@@ -1,8 +1,8 @@
#ifndef NVIM_OS_UNIX_H
#define NVIM_OS_UNIX_H
-#include "nvim/types.h" // for vim_acl_T
#include "nvim/os/shell.h"
+#include "nvim/types.h" // for vim_acl_T
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "os_unix.h.generated.h"
diff --git a/src/nvim/path.c b/src/nvim/path.c
index 60c7ea7fa4..5b1793b111 100644
--- a/src/nvim/path.c
+++ b/src/nvim/path.c
@@ -1658,8 +1658,7 @@ static char *eval_includeexpr(const char *const ptr, const size_t len)
{
set_vim_var_string(VV_FNAME, ptr, (ptrdiff_t)len);
char *res = (char *)eval_to_string_safe(curbuf->b_p_inex, NULL,
- was_set_insecurely(curwin, (char_u *)"includeexpr",
- OPT_LOCAL));
+ was_set_insecurely(curwin, "includeexpr", OPT_LOCAL));
set_vim_var_string(VV_FNAME, NULL, 0);
return res;
}
@@ -2038,7 +2037,7 @@ char_u *path_shorten_fname(char_u *full_path, char_u *dir_name)
}
assert(dir_name != NULL);
- size_t len = strlen((char *)dir_name);
+ size_t len = STRLEN(dir_name);
// If dir_name is a path head, full_path can always be made relative.
if (len == (size_t)path_head_length() && is_path_head(dir_name)) {
diff --git a/src/nvim/path.h b/src/nvim/path.h
index 15abd19646..5d81e68caa 100644
--- a/src/nvim/path.h
+++ b/src/nvim/path.h
@@ -2,22 +2,22 @@
#define NVIM_PATH_H
#include "nvim/func_attr.h"
-#include "nvim/types.h"
#include "nvim/garray.h"
+#include "nvim/types.h"
-/* Flags for expand_wildcards() */
-#define EW_DIR 0x01 /* include directory names */
-#define EW_FILE 0x02 /* include file names */
-#define EW_NOTFOUND 0x04 /* include not found names */
-#define EW_ADDSLASH 0x08 /* append slash to directory name */
-#define EW_KEEPALL 0x10 /* keep all matches */
-#define EW_SILENT 0x20 /* don't print "1 returned" from shell */
-#define EW_EXEC 0x40 /* executable files */
-#define EW_PATH 0x80 /* search in 'path' too */
-#define EW_ICASE 0x100 /* ignore case */
-#define EW_NOERROR 0x200 /* no error for bad regexp */
-#define EW_NOTWILD 0x400 /* add match with literal name if exists */
-#define EW_KEEPDOLLAR 0x800 /* do not escape $, $var is expanded */
+// Flags for expand_wildcards()
+#define EW_DIR 0x01 // include directory names
+#define EW_FILE 0x02 // include file names
+#define EW_NOTFOUND 0x04 // include not found names
+#define EW_ADDSLASH 0x08 // append slash to directory name
+#define EW_KEEPALL 0x10 // keep all matches
+#define EW_SILENT 0x20 // don't print "1 returned" from shell
+#define EW_EXEC 0x40 // executable files
+#define EW_PATH 0x80 // search in 'path' too
+#define EW_ICASE 0x100 // ignore case
+#define EW_NOERROR 0x200 // no error for bad regexp
+#define EW_NOTWILD 0x400 // add match with literal name if exists
+#define EW_KEEPDOLLAR 0x800 // do not escape $, $var is expanded
/* Note: mostly EW_NOTFOUND and EW_SILENT are mutually exclusive: EW_NOTFOUND
* is used when executing commands and EW_SILENT for interactive expanding. */
#define EW_ALLLINKS 0x1000 // also links not pointing to existing file
diff --git a/src/nvim/popupmnu.h b/src/nvim/popupmnu.h
index 7956e50a93..7d3f4c6f51 100644
--- a/src/nvim/popupmnu.h
+++ b/src/nvim/popupmnu.h
@@ -1,10 +1,10 @@
#ifndef NVIM_POPUPMNU_H
#define NVIM_POPUPMNU_H
-#include "nvim/vim.h"
-#include "nvim/macros.h"
#include "nvim/grid_defs.h"
+#include "nvim/macros.h"
#include "nvim/types.h"
+#include "nvim/vim.h"
/// Used for popup menu items.
typedef struct {
diff --git a/src/nvim/pos.h b/src/nvim/pos.h
index b7c4b6ef92..2fbd049aa0 100644
--- a/src/nvim/pos.h
+++ b/src/nvim/pos.h
@@ -26,8 +26,8 @@ enum { MINCOL = 1 };
* position in file or buffer
*/
typedef struct {
- linenr_T lnum; /* line number */
- colnr_T col; /* column number */
+ linenr_T lnum; // line number
+ colnr_T col; // column number
colnr_T coladd;
} pos_T;
@@ -36,8 +36,8 @@ typedef struct {
* Same, but without coladd.
*/
typedef struct {
- linenr_T lnum; /* line number */
- colnr_T col; /* column number */
+ linenr_T lnum; // line number
+ colnr_T col; // column number
} lpos_T;
#endif // NVIM_POS_H
diff --git a/src/nvim/profile.h b/src/nvim/profile.h
index 7b378577ce..17c35c5eb7 100644
--- a/src/nvim/profile.h
+++ b/src/nvim/profile.h
@@ -7,8 +7,8 @@
typedef uint64_t proftime_T;
#define TIME_MSG(s) do { \
- if (time_fd != NULL) time_msg(s, NULL); \
- } while (0)
+ if (time_fd != NULL) time_msg(s, NULL); \
+} while (0)
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "profile.h.generated.h"
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index 046e6dbd12..53be2c04e2 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -1628,8 +1628,8 @@ static int qf_parse_multiline_pfx(int idx, qf_list_T *qfl, qffields_T *fields)
return QF_FAIL;
}
if (*fields->errmsg) {
- size_t textlen = strlen((char *)qfprev->qf_text);
- size_t errlen = strlen((char *)fields->errmsg);
+ size_t textlen = STRLEN(qfprev->qf_text);
+ size_t errlen = STRLEN(fields->errmsg);
qfprev->qf_text = xrealloc(qfprev->qf_text, textlen + errlen + 2);
qfprev->qf_text[textlen] = '\n';
STRCPY(qfprev->qf_text + textlen + 1, fields->errmsg);
diff --git a/src/nvim/quickfix.h b/src/nvim/quickfix.h
index fdeb8d1a2f..f5178e332a 100644
--- a/src/nvim/quickfix.h
+++ b/src/nvim/quickfix.h
@@ -1,10 +1,10 @@
#ifndef NVIM_QUICKFIX_H
#define NVIM_QUICKFIX_H
-#include "nvim/types.h"
#include "nvim/ex_cmds_defs.h"
+#include "nvim/types.h"
-/* flags for skip_vimgrep_pat() */
+// flags for skip_vimgrep_pat()
#define VGR_GLOBAL 1
#define VGR_NOJUMP 2
diff --git a/src/nvim/rbuffer.h b/src/nvim/rbuffer.h
index a8dfcac580..cc690050ab 100644
--- a/src/nvim/rbuffer.h
+++ b/src/nvim/rbuffer.h
@@ -38,17 +38,17 @@
// create infinite loops
#define RBUFFER_UNTIL_EMPTY(buf, rptr, rcnt) \
for (size_t rcnt = 0, _r = 1; _r; _r = 0) /* NOLINT(readability/braces) */ \
- for ( /* NOLINT(readability/braces) */ \
- char *rptr = rbuffer_read_ptr(buf, &rcnt); \
- buf->size; \
- rptr = rbuffer_read_ptr(buf, &rcnt))
+ for ( /* NOLINT(readability/braces) */ \
+ char *rptr = rbuffer_read_ptr(buf, &rcnt); \
+ buf->size; \
+ rptr = rbuffer_read_ptr(buf, &rcnt))
#define RBUFFER_UNTIL_FULL(buf, wptr, wcnt) \
for (size_t wcnt = 0, _r = 1; _r; _r = 0) /* NOLINT(readability/braces) */ \
- for ( /* NOLINT(readability/braces) */ \
- char *wptr = rbuffer_write_ptr(buf, &wcnt); \
- rbuffer_space(buf); \
- wptr = rbuffer_write_ptr(buf, &wcnt))
+ for ( /* NOLINT(readability/braces) */ \
+ char *wptr = rbuffer_write_ptr(buf, &wcnt); \
+ rbuffer_space(buf); \
+ wptr = rbuffer_write_ptr(buf, &wcnt))
// Iteration
@@ -56,23 +56,23 @@
for (size_t i = 0; /* NOLINT(readability/braces) */ \
i < buf->size; \
i = buf->size) \
- for (char c = 0; /* NOLINT(readability/braces) */ \
- i < buf->size ? ((int)(c = *rbuffer_get(buf, i))) || 1 : 0; \
- i++)
+ for (char c = 0; /* NOLINT(readability/braces) */ \
+ i < buf->size ? ((int)(c = *rbuffer_get(buf, i))) || 1 : 0; \
+ i++)
#define RBUFFER_EACH_REVERSE(buf, c, i) \
for (size_t i = buf->size; /* NOLINT(readability/braces) */ \
i != SIZE_MAX; \
i = SIZE_MAX) \
- for (char c = 0; /* NOLINT(readability/braces) */ \
- i-- > 0 ? ((int)(c = *rbuffer_get(buf, i))) || 1 : 0; \
- )
+ for (char c = 0; /* NOLINT(readability/braces) */ \
+ i-- > 0 ? ((int)(c = *rbuffer_get(buf, i))) || 1 : 0; \
+ )
typedef struct rbuffer RBuffer;
/// Type of function invoked during certain events:
/// - When the RBuffer switches to the full state
/// - When the RBuffer switches to the non-full state
-typedef void(*rbuffer_callback)(RBuffer *buf, void *data);
+typedef void (*rbuffer_callback)(RBuffer *buf, void *data);
struct rbuffer {
rbuffer_callback full_cb, nonfull_cb;
diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c
index eca6739f5c..24dc86e034 100644
--- a/src/nvim/regexp.c
+++ b/src/nvim/regexp.c
@@ -1,6 +1,8 @@
// This is an open source non-commercial project. Dear PVS-Studio, please check
// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
+// uncrustify:off
+
/*
* Handling of regular expressions: vim_regcomp(), vim_regexec(), vim_regsub()
*
diff --git a/src/nvim/regexp.h b/src/nvim/regexp.h
index 74ed34188c..9527afed58 100644
--- a/src/nvim/regexp.h
+++ b/src/nvim/regexp.h
@@ -1,9 +1,9 @@
#ifndef NVIM_REGEXP_H
#define NVIM_REGEXP_H
-#include "nvim/types.h"
#include "nvim/buffer_defs.h"
#include "nvim/regexp_defs.h"
+#include "nvim/types.h"
// Second argument for vim_regcomp().
#define RE_MAGIC 1 ///< 'magic' option
diff --git a/src/nvim/regexp_defs.h b/src/nvim/regexp_defs.h
index a729a91555..1d112bd64a 100644
--- a/src/nvim/regexp_defs.h
+++ b/src/nvim/regexp_defs.h
@@ -15,8 +15,8 @@
#include <stdbool.h>
#include "nvim/pos.h"
-#include "nvim/types.h"
#include "nvim/profile.h"
+#include "nvim/types.h"
/*
* The number of sub-matches is limited to 10.
@@ -53,7 +53,7 @@ typedef struct reg_extmatch reg_extmatch_T;
/// always 0.
/// When there is no match, the line number is -1.
typedef struct {
- regprog_T *regprog;
+ regprog_T *regprog;
lpos_T startpos[NSUBEXP];
lpos_T endpos[NSUBEXP];
int rmm_ic;
@@ -90,7 +90,7 @@ typedef struct {
int regstart;
char_u reganch;
- char_u *regmust;
+ char_u *regmust;
int regmlen;
char_u reghasz;
char_u program[1]; // actually longer..
@@ -101,8 +101,8 @@ typedef struct {
typedef struct nfa_state nfa_state_T;
struct nfa_state {
int c;
- nfa_state_T *out;
- nfa_state_T *out1;
+ nfa_state_T *out;
+ nfa_state_T *out1;
int id;
int lastlist[2]; // 0: normal, 1: recursive
int val;
@@ -119,16 +119,16 @@ typedef struct {
unsigned re_flags;
bool re_in_use;
- nfa_state_T *start; // points into state[]
+ nfa_state_T *start; // points into state[]
int reganch; // pattern starts with ^
int regstart; // char at start of pattern
- char_u *match_text; // plain text to match with
+ char_u *match_text; // plain text to match with
int has_zend; // pattern contains \ze
int has_backref; // pattern contains \1 .. \9
int reghasz;
- char_u *pattern;
+ char_u *pattern;
int nsubexp; // number of ()
int nstate;
nfa_state_T state[1]; // actually longer..
@@ -140,10 +140,10 @@ typedef struct {
* When there is no match, the pointer is NULL.
*/
typedef struct {
- regprog_T *regprog;
- char_u *startp[NSUBEXP];
- char_u *endp[NSUBEXP];
- bool rm_ic;
+ regprog_T *regprog;
+ char_u *startp[NSUBEXP];
+ char_u *endp[NSUBEXP];
+ bool rm_ic;
} regmatch_T;
/*
@@ -153,16 +153,16 @@ typedef struct {
*/
struct reg_extmatch {
int16_t refcnt;
- char_u *matches[NSUBEXP];
+ char_u *matches[NSUBEXP];
};
struct regengine {
- regprog_T *(*regcomp)(char_u *, int);
+ regprog_T *(*regcomp)(char_u *, int);
void (*regfree)(regprog_T *);
int (*regexec_nl)(regmatch_T *, char_u *, colnr_T, bool);
long (*regexec_multi)(regmmatch_T *, win_T *, buf_T *, linenr_T, colnr_T,
proftime_T *, int *);
- char_u *expr;
+ char_u *expr;
};
#endif // NVIM_REGEXP_DEFS_H
diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c
index 7550ff64ef..c8b7190b4a 100644
--- a/src/nvim/regexp_nfa.c
+++ b/src/nvim/regexp_nfa.c
@@ -1,6 +1,8 @@
// This is an open source non-commercial project. Dear PVS-Studio, please check
// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
+// uncrustify:off
+
/*
* NFA regular expression implementation.
*
diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c
index 0e2d23e69b..67df0c9258 100644
--- a/src/nvim/runtime.c
+++ b/src/nvim/runtime.c
@@ -47,13 +47,13 @@ void ex_runtime(exarg_T *eap)
arg = skipwhite(arg + len);
}
- source_runtime(arg, flags);
+ source_runtime((char *)arg, flags);
}
static void source_callback(char_u *fname, void *cookie)
{
- (void)do_source(fname, false, DOSO_NONE);
+ (void)do_source((char *)fname, false, DOSO_NONE);
}
/// Find the file "name" in all directories in "path" and invoke
@@ -64,7 +64,7 @@ static void source_callback(char_u *fname, void *cookie)
/// When "flags" has DIP_ERR: give an error message if there is no match.
///
/// return FAIL when no file could be sourced, OK otherwise.
-int do_in_path(char_u *path, char_u *name, int flags, DoInRuntimepathCB callback, void *cookie)
+int do_in_path(char_u *path, char *name, int flags, DoInRuntimepathCB callback, void *cookie)
{
char_u *tail;
int num_files;
@@ -79,8 +79,7 @@ int do_in_path(char_u *path, char_u *name, int flags, DoInRuntimepathCB callback
{
if (p_verbose > 10 && name != NULL) {
verbose_enter();
- smsg(_("Searching for \"%s\" in \"%s\""),
- (char *)name, (char *)path);
+ smsg(_("Searching for \"%s\" in \"%s\""), name, (char *)path);
verbose_leave();
}
@@ -109,7 +108,7 @@ int do_in_path(char_u *path, char_u *name, int flags, DoInRuntimepathCB callback
tail = buf + STRLEN(buf);
// Loop over all patterns in "name"
- char_u *np = name;
+ char_u *np = (char_u *)name;
while (*np != NUL && ((flags & DIP_ALL) || !did_one)) {
// Append the pattern from "name" to buf[].
assert(MAXPATHL >= (tail - buf));
@@ -281,16 +280,16 @@ int do_in_path_and_pp(char_u *path, char_u *name, int flags, DoInRuntimepathCB c
int done = FAIL;
if ((flags & DIP_NORTP) == 0) {
- done |= do_in_path(path, (name && !*name) ? NULL : name, flags, callback, cookie);
+ done |= do_in_path(path, (char *)((name && !*name) ? NULL : name), flags, callback, cookie);
}
if ((done == FAIL || (flags & DIP_ALL)) && (flags & DIP_START)) {
char *start_dir = "pack/*/start/*/%s%s"; // NOLINT
size_t len = STRLEN(start_dir) + STRLEN(name) + 6;
- char_u *s = xmallocz(len); // TODO(bfredl): get rid of random allocations
+ char *s = xmallocz(len); // TODO(bfredl): get rid of random allocations
char *suffix = (flags & DIP_AFTER) ? "after/" : "";
- vim_snprintf((char *)s, len, start_dir, suffix, name);
+ vim_snprintf(s, len, start_dir, suffix, name);
done |= do_in_path(p_pp, s, flags & ~DIP_AFTER, callback, cookie);
xfree(s);
@@ -300,7 +299,7 @@ int do_in_path_and_pp(char_u *path, char_u *name, int flags, DoInRuntimepathCB c
len = STRLEN(start_dir) + STRLEN(name) + 6;
s = xmallocz(len);
- vim_snprintf((char *)s, len, start_dir, suffix, name);
+ vim_snprintf(s, len, start_dir, suffix, name);
done |= do_in_path(p_pp, s, flags & ~DIP_AFTER, callback, cookie);
xfree(s);
@@ -310,9 +309,9 @@ int do_in_path_and_pp(char_u *path, char_u *name, int flags, DoInRuntimepathCB c
if ((done == FAIL || (flags & DIP_ALL)) && (flags & DIP_OPT)) {
char *opt_dir = "pack/*/opt/*/%s"; // NOLINT
size_t len = STRLEN(opt_dir) + STRLEN(name);
- char_u *s = xmallocz(len);
+ char *s = xmallocz(len);
- vim_snprintf((char *)s, len, opt_dir, name);
+ vim_snprintf(s, len, opt_dir, name);
done |= do_in_path(p_pp, s, flags, callback, cookie);
xfree(s);
@@ -322,7 +321,7 @@ int do_in_path_and_pp(char_u *path, char_u *name, int flags, DoInRuntimepathCB c
len = STRLEN(opt_dir) + STRLEN(name);
s = xmallocz(len);
- vim_snprintf((char *)s, len, opt_dir, name);
+ vim_snprintf(s, len, opt_dir, name);
done |= do_in_path(p_pp, s, flags, callback, cookie);
xfree(s);
@@ -332,8 +331,8 @@ int do_in_path_and_pp(char_u *path, char_u *name, int flags, DoInRuntimepathCB c
return done;
}
-static void push_path(RuntimeSearchPath *search_path, Map(String, handle_T) *rtp_used,
- char *entry, bool after)
+static void push_path(RuntimeSearchPath *search_path, Map(String, handle_T) *rtp_used, char *entry,
+ bool after)
{
handle_T h = map_get(String, handle_T)(rtp_used, cstr_as_string(entry));
if (h == 0) {
@@ -374,7 +373,7 @@ static void expand_pack_entry(RuntimeSearchPath *search_path, Map(String, handle
if (STRLEN(pack_entry) + STRLEN(start_pat[i]) + 1 > MAXPATHL) {
continue;
}
- xstrlcpy(buf, (char *)pack_entry, MAXPATHL);
+ STRLCPY(buf, pack_entry, MAXPATHL);
xstrlcat(buf, start_pat[i], sizeof buf);
expand_rtp_entry(search_path, rtp_used, buf, false);
size_t after_size = STRLEN(buf)+7;
@@ -515,9 +514,9 @@ int do_in_runtimepath(char_u *name, int flags, DoInRuntimepathCB callback, void
/// When "flags" has DIP_ALL: source all files, otherwise only the first one.
///
/// return FAIL when no file could be sourced, OK otherwise.
-int source_runtime(char_u *name, int flags)
+int source_runtime(char *name, int flags)
{
- return do_in_runtimepath(name, flags, source_callback, NULL);
+ return do_in_runtimepath((char_u *)name, flags, source_callback, NULL);
}
/// Just like source_runtime(), but use "path" instead of 'runtimepath'.
@@ -535,7 +534,7 @@ static void source_all_matches(char_u *pat)
if (gen_expand_wildcards(1, &pat, &num_files, &files, EW_FILE) == OK) {
for (int i = 0; i < num_files; i++) {
- (void)do_source(files[i], false, DOSO_NONE);
+ (void)do_source((char *)files[i], false, DOSO_NONE);
}
FreeWild(num_files, files);
}
@@ -791,7 +790,7 @@ static void add_pack_start_dir(char_u *fname, void *cookie)
if (STRLEN(fname) + STRLEN(start_pat[i]) + 1 > MAXPATHL) {
continue;
}
- xstrlcpy((char *)buf, (char *)fname, MAXPATHL);
+ STRLCPY(buf, fname, MAXPATHL);
xstrlcat((char *)buf, start_pat[i], sizeof buf);
if (pack_has_entries(buf)) {
add_pack_dir_to_rtp(buf, true);
@@ -804,9 +803,9 @@ static void add_pack_start_dir(char_u *fname, void *cookie)
void load_start_packages(void)
{
did_source_packages = true;
- do_in_path(p_pp, (char_u *)"pack/*/start/*", DIP_ALL + DIP_DIR, // NOLINT
+ do_in_path(p_pp, "pack/*/start/*", DIP_ALL + DIP_DIR, // NOLINT
add_start_pack_plugin, &APP_LOAD);
- do_in_path(p_pp, (char_u *)"start/*", DIP_ALL + DIP_DIR, // NOLINT
+ do_in_path(p_pp, "start/*", DIP_ALL + DIP_DIR, // NOLINT
add_start_pack_plugin, &APP_LOAD);
}
@@ -849,8 +848,8 @@ void load_plugins(void)
}
TIME_MSG("loading packages");
- source_runtime(plugin_pattern_vim, DIP_ALL | DIP_AFTER);
- source_runtime(plugin_pattern_lua, DIP_ALL | DIP_AFTER);
+ source_runtime((char *)plugin_pattern_vim, DIP_ALL | DIP_AFTER);
+ source_runtime((char *)plugin_pattern_lua, DIP_ALL | DIP_AFTER);
TIME_MSG("loading after plugins");
}
}
@@ -873,9 +872,7 @@ void ex_packadd(exarg_T *eap)
vim_snprintf(pat, len, plugpat, round == 1 ? "start" : "opt", eap->arg);
// The first round don't give a "not found" error, in the second round
// only when nothing was found in the first round.
- res = do_in_path(p_pp, (char_u *)pat,
- DIP_ALL + DIP_DIR
- + (round == 2 && res == FAIL ? DIP_ERR : 0),
+ res = do_in_path(p_pp, pat, DIP_ALL + DIP_DIR + (round == 2 && res == FAIL ? DIP_ERR : 0),
round == 1 ? add_start_pack_plugin : add_opt_pack_plugin,
eap->forceit ? &APP_ADD_DIR : &APP_BOTH);
xfree(pat);
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index a1d03b363d..63f3267d8a 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -2208,7 +2208,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc
if (provider_err) {
Decoration err_decor = DECORATION_INIT;
- int hl_err = syn_check_group((char_u *)S_LEN("ErrorMsg"));
+ int hl_err = syn_check_group(S_LEN("ErrorMsg"));
kv_push(err_decor.virt_text,
((VirtTextChunk){ .text = provider_err,
.hl_id = hl_err }));
@@ -5465,7 +5465,7 @@ static void win_redr_custom(win_T *wp, bool draw_ruler)
fillchar = ' ';
attr = HL_ATTR(HLF_TPF);
maxwidth = Columns;
- use_sandbox = was_set_insecurely(wp, (char_u *)"tabline", 0);
+ use_sandbox = was_set_insecurely(wp, "tabline", 0);
} else {
row = W_ENDROW(wp);
fillchar = fillchar_status(&attr, wp);
@@ -5500,15 +5500,14 @@ static void win_redr_custom(win_T *wp, bool draw_ruler)
attr = HL_ATTR(HLF_MSG);
}
- use_sandbox = was_set_insecurely(wp, (char_u *)"rulerformat", 0);
+ use_sandbox = was_set_insecurely(wp, "rulerformat", 0);
} else {
if (*wp->w_p_stl != NUL) {
stl = wp->w_p_stl;
} else {
stl = p_stl;
}
- use_sandbox = was_set_insecurely(wp, (char_u *)"statusline",
- *wp->w_p_stl == NUL ? 0 : OPT_LOCAL);
+ use_sandbox = was_set_insecurely(wp, "statusline", *wp->w_p_stl == NUL ? 0 : OPT_LOCAL);
}
col += wp->w_wincol;
diff --git a/src/nvim/screen.h b/src/nvim/screen.h
index 5f339b9ae2..d704a6eb8a 100644
--- a/src/nvim/screen.h
+++ b/src/nvim/screen.h
@@ -3,10 +3,10 @@
#include <stdbool.h>
-#include "nvim/types.h"
#include "nvim/buffer_defs.h"
#include "nvim/grid_defs.h"
#include "nvim/pos.h"
+#include "nvim/types.h"
/*
* flags for update_screen()
@@ -14,12 +14,12 @@
*/
#define VALID 10 /* buffer not changed, or changes marked
with b_mod_* */
-#define INVERTED 20 /* redisplay inverted part that changed */
-#define INVERTED_ALL 25 /* redisplay whole inverted part */
-#define REDRAW_TOP 30 /* display first w_upd_rows screen lines */
-#define SOME_VALID 35 /* like NOT_VALID but may scroll */
-#define NOT_VALID 40 /* buffer needs complete redraw */
-#define CLEAR 50 /* screen messed up, clear it */
+#define INVERTED 20 // redisplay inverted part that changed
+#define INVERTED_ALL 25 // redisplay whole inverted part
+#define REDRAW_TOP 30 // display first w_upd_rows screen lines
+#define SOME_VALID 35 // like NOT_VALID but may scroll
+#define NOT_VALID 40 // buffer needs complete redraw
+#define CLEAR 50 // screen messed up, clear it
/// By default, all widows are draw on a single rectangular grid, represented by
/// this ScreenGrid instance. In multigrid mode each window will have its own
diff --git a/src/nvim/search.h b/src/nvim/search.h
index 0dbaf79c37..85bcda84a4 100644
--- a/src/nvim/search.h
+++ b/src/nvim/search.h
@@ -4,14 +4,14 @@
#include <stdbool.h>
#include <stdint.h>
-#include "nvim/vim.h"
#include "nvim/buffer_defs.h"
#include "nvim/eval/funcs.h"
#include "nvim/eval/typval.h"
#include "nvim/normal.h"
#include "nvim/os/time.h"
+#include "nvim/vim.h"
-/* Values for the find_pattern_in_path() function args 'type' and 'action': */
+// Values for the find_pattern_in_path() function args 'type' and 'action':
#define FIND_ANY 1
#define FIND_DEFINE 2
#define CHECK_PATH 3
@@ -37,18 +37,18 @@
#define SEARCH_PEEK 0x800 ///< peek for typed char, cancel search
#define SEARCH_COL 0x1000 ///< start at specified column instead of zero
-/* Values for flags argument for findmatchlimit() */
-#define FM_BACKWARD 0x01 /* search backwards */
-#define FM_FORWARD 0x02 /* search forwards */
-#define FM_BLOCKSTOP 0x04 /* stop at start/end of block */
-#define FM_SKIPCOMM 0x08 /* skip comments */
+// Values for flags argument for findmatchlimit()
+#define FM_BACKWARD 0x01 // search backwards
+#define FM_FORWARD 0x02 // search forwards
+#define FM_BLOCKSTOP 0x04 // stop at start/end of block
+#define FM_SKIPCOMM 0x08 // skip comments
-/* Values for sub_cmd and which_pat argument for search_regcomp() */
-/* Also used for which_pat argument for searchit() */
-#define RE_SEARCH 0 /* save/use pat in/from search_pattern */
-#define RE_SUBST 1 /* save/use pat in/from subst_pattern */
-#define RE_BOTH 2 /* save pat in both patterns */
-#define RE_LAST 2 /* use last used pattern if "pat" is NULL */
+// Values for sub_cmd and which_pat argument for search_regcomp()
+// Also used for which_pat argument for searchit()
+#define RE_SEARCH 0 // save/use pat in/from search_pattern
+#define RE_SUBST 1 // save/use pat in/from subst_pattern
+#define RE_BOTH 2 // save pat in both patterns
+#define RE_LAST 2 // use last used pattern if "pat" is NULL
// Values for searchcount()
#define SEARCH_STAT_DEF_TIMEOUT 40L
@@ -78,21 +78,21 @@ typedef struct spat {
/// Optional extra arguments for searchit().
typedef struct {
- linenr_T sa_stop_lnum; ///< stop after this line number when != 0
- proftime_T *sa_tm; ///< timeout limit or NULL
- int sa_timed_out; ///< set when timed out
- int sa_wrapped; ///< search wrapped around
+ linenr_T sa_stop_lnum; ///< stop after this line number when != 0
+ proftime_T *sa_tm; ///< timeout limit or NULL
+ int sa_timed_out; ///< set when timed out
+ int sa_wrapped; ///< search wrapped around
} searchit_arg_T;
typedef struct searchstat
{
- int cur; // current position of found words
- int cnt; // total count of found words
- bool exact_match; // true if matched exactly on specified position
- int incomplete; // 0: search was fully completed
- // 1: recomputing was timed out
- // 2: max count exceeded
- int last_maxcount; // the max count of the last search
+ int cur; // current position of found words
+ int cnt; // total count of found words
+ bool exact_match; // true if matched exactly on specified position
+ int incomplete; // 0: search was fully completed
+ // 1: recomputing was timed out
+ // 2: max count exceeded
+ int last_maxcount; // the max count of the last search
} searchstat_T;
#ifdef INCLUDE_GENERATED_DECLARATIONS
diff --git a/src/nvim/sha256.h b/src/nvim/sha256.h
index deb881a288..b52d300de6 100644
--- a/src/nvim/sha256.h
+++ b/src/nvim/sha256.h
@@ -1,8 +1,8 @@
#ifndef NVIM_SHA256_H
#define NVIM_SHA256_H
-#include <stdint.h> // for uint32_t
#include <stddef.h>
+#include <stdint.h> // for uint32_t
#include "nvim/types.h" // for char_u
diff --git a/src/nvim/shada.c b/src/nvim/shada.c
index 2d65db8437..10f93913ad 100644
--- a/src/nvim/shada.c
+++ b/src/nvim/shada.c
@@ -65,11 +65,6 @@ KHASH_SET_INIT_INT64(bufset)
KHASH_MAP_INIT_STR(fnamebufs, buf_T *)
KHASH_SET_INIT_STR(strset)
-#define find_shada_parameter(...) \
- ((const char *)find_shada_parameter(__VA_ARGS__))
-#define path_try_shorten_fname(b) \
- ((char *)path_try_shorten_fname((char_u *)b))
-
#define SEARCH_KEY_MAGIC "sm"
#define SEARCH_KEY_SMARTCASE "sc"
#define SEARCH_KEY_HAS_LINE_OFFSET "sl"
@@ -609,20 +604,6 @@ static inline void hmll_insert(HMLList *const hmll, HMLListEntry *hmll_entry, co
}
}
-/// Iterate over HMLList in backward direction
-///
-/// @param hmll Pointer to the list.
-/// @param cur_entry Name of the variable to iterate over, must be already
-/// defined.
-/// @param code Code to execute on each iteration.
-///
-/// @return `for` cycle header (use `HMLL_FORALL(hmll, cur_entry) {body}`).
-#define HMLL_ITER_BACK(hmll, cur_entry, code) \
- for (cur_entry = (hmll)->last; cur_entry != NULL; \
- cur_entry = cur_entry->prev) { \
- code \
- }
-
/// Free linked list
///
/// @param[in] hmll List to free.
@@ -966,11 +947,12 @@ static void hms_insert(HistoryMergerState *const hms_p, const ShadaEntry entry,
}
}
HMLListEntry *insert_after;
- HMLL_ITER_BACK(hmll, insert_after, {
+ // Iterate over HMLList in backward direction
+ for (insert_after = hmll->last; insert_after != NULL; insert_after = insert_after->prev) {
if (insert_after->data.timestamp <= entry.timestamp) {
break;
}
- })
+ }
hmll_insert(hmll, insert_after, entry, can_free_entry);
}
@@ -1346,7 +1328,8 @@ static void shada_read(ShaDaReadDef *const sd_reader, const int flags)
}
case kSDItemBufferList:
for (size_t i = 0; i < cur_entry.data.buffer_list.size; i++) {
- char *const sfname = path_try_shorten_fname(cur_entry.data.buffer_list.buffers[i].fname);
+ char *const sfname =
+ (char *)path_try_shorten_fname((char_u *)cur_entry.data.buffer_list.buffers[i].fname);
buf_T *const buf =
buflist_new((char_u *)cur_entry.data.buffer_list.buffers[i].fname, (char_u *)sfname, 0,
BLN_LISTED);
@@ -1488,7 +1471,7 @@ static char *shada_filename(const char *file)
if (p_shadafile != NULL && *p_shadafile != NUL) {
file = p_shadafile;
} else {
- if ((file = find_shada_parameter('n')) == NULL || *file == NUL) {
+ if ((file = (char *)find_shada_parameter('n')) == NULL || *file == NUL) {
file = shada_get_default_file();
}
// XXX It used to be one level lower, so that whatever is in
@@ -1508,14 +1491,6 @@ static char *shada_filename(const char *file)
msgpack_pack_str(spacker, sizeof(s) - 1); \
msgpack_pack_str_body(spacker, s, sizeof(s) - 1); \
} while (0)
-#define PACK_STRING(s) \
- do { \
- const String s_ = (s); \
- msgpack_pack_str(spacker, s_.size); \
- if (s_.size) { \
- msgpack_pack_str_body(spacker, s_.data, s_.size); \
- } \
- } while (0)
#define PACK_BIN(s) \
do { \
const String s_ = (s); \
@@ -1796,7 +1771,11 @@ static ShaDaWriteResult shada_pack_entry(msgpack_packer *const packer, ShadaEntr
case kSDItemHeader:
msgpack_pack_map(spacker, entry.data.header.size);
for (size_t i = 0; i < entry.data.header.size; i++) {
- PACK_STRING(entry.data.header.items[i].key);
+ const String s = entry.data.header.items[i].key;
+ msgpack_pack_str(spacker, s.size);
+ if (s.size) {
+ msgpack_pack_str_body(spacker, s.data, s.size);
+ }
const Object obj = entry.data.header.items[i].value;
switch (obj.type) {
case kObjectTypeString:
@@ -1842,7 +1821,6 @@ shada_pack_entry_error:
msgpack_sbuffer_destroy(&sbuf);
return ret;
}
-#undef PACK_STRING
/// Write single ShaDa entry and free it afterwards
///
@@ -2423,7 +2401,7 @@ static inline void shada_initialize_registers(WriteMergerState *const wms, int m
.data = {
.reg = {
.contents = (char **)reg.y_array,
- .contents_size = (size_t)reg.y_size,
+ .contents_size = reg.y_size,
.type = reg.y_type,
.width = (size_t)(reg.y_type == kMTBlockWise ? reg.y_width : 0),
.additional_data = reg.additional_data,
@@ -2943,7 +2921,6 @@ shada_write_exit:
return ret;
}
-#undef IGNORE_BUF
#undef PACK_STATIC_STR
/// Write ShaDa file to a given location
@@ -3410,8 +3387,7 @@ static ShaDaReadResult msgpack_read_uint64(ShaDaReadDef *const sd_reader, const
sizeof(*un.data.via.map.ptr)); \
ad_ga.ga_len++; \
}
-#define CONVERTED(str, len) (xmemdupz((str), (len)))
-#define BIN_CONVERTED(b) CONVERTED(b.ptr, b.size)
+#define BIN_CONVERTED(b) (xmemdupz((b.ptr), (b.size)))
#define SET_ADDITIONAL_DATA(tgt, name) \
do { \
if (ad_ga.ga_len) { \
@@ -3968,7 +3944,6 @@ shada_read_next_item_error:
goto shada_read_next_item_end;
}
#undef BIN_CONVERTED
-#undef CONVERTED
#undef CHECK_KEY
#undef BOOLEAN_KEY
#undef CONVERTED_STRING_KEY
@@ -4003,7 +3978,7 @@ static bool shada_removable(const char *name)
char *new_name = (char *)home_replace_save(NULL, (char_u *)name);
for (p = (char *)p_shada; *p; ) {
- (void)(char *)copy_option_part((char_u **)&p, (char_u *)part, ARRAY_SIZE(part), ", ");
+ (void)copy_option_part((char_u **)&p, (char_u *)part, ARRAY_SIZE(part), ", ");
if (part[0] == 'r') {
home_replace(NULL, (char_u *)(part + 1), (char_u *)NameBuff, MAXPATHL, true);
size_t n = STRLEN(NameBuff);
diff --git a/src/nvim/sign.c b/src/nvim/sign.c
index 25427de6bf..1b100161bf 100644
--- a/src/nvim/sign.c
+++ b/src/nvim/sign.c
@@ -902,7 +902,7 @@ static int sign_define_init_text(sign_T *sp, char_u *text)
/// Define a new sign or update an existing sign
int sign_define_by_name(char_u *name, char_u *icon, char_u *linehl, char_u *text, char_u *texthl,
- char_u *numhl)
+ char *numhl)
{
sign_T *sp_prev;
sign_T *sp;
@@ -940,11 +940,11 @@ int sign_define_by_name(char_u *name, char_u *icon, char_u *linehl, char_u *text
}
if (linehl != NULL) {
- sp->sn_line_hl = syn_check_group(linehl, (int)STRLEN(linehl));
+ sp->sn_line_hl = syn_check_group((char *)linehl, (int)STRLEN(linehl));
}
if (texthl != NULL) {
- sp->sn_text_hl = syn_check_group(texthl, (int)STRLEN(texthl));
+ sp->sn_text_hl = syn_check_group((char *)texthl, (int)STRLEN(texthl));
}
if (numhl != NULL) {
@@ -1167,7 +1167,7 @@ static void sign_define_cmd(char_u *sign_name, char_u *cmdline)
}
if (!failed) {
- sign_define_by_name(sign_name, icon, linehl, text, texthl, numhl);
+ sign_define_by_name(sign_name, icon, linehl, text, texthl, (char *)numhl);
}
xfree(icon);
@@ -1871,7 +1871,7 @@ int sign_define_from_dict(const char *name_arg, dict_T *dict)
}
if (sign_define_by_name((char_u *)name, (char_u *)icon, (char_u *)linehl,
- (char_u *)text, (char_u *)texthl, (char_u *)numhl)
+ (char_u *)text, (char_u *)texthl, numhl)
== OK) {
retval = 0;
}
diff --git a/src/nvim/sign.h b/src/nvim/sign.h
index e3a5a27c74..9044c2d0bb 100644
--- a/src/nvim/sign.h
+++ b/src/nvim/sign.h
@@ -2,6 +2,7 @@
#define NVIM_SIGN_H
#include <stdbool.h>
+
#include "nvim/buffer_defs.h"
#include "nvim/ex_cmds_defs.h"
#include "nvim/sign_defs.h"
diff --git a/src/nvim/sign_defs.h b/src/nvim/sign_defs.h
index 721b2db25b..f3ec2c45f6 100644
--- a/src/nvim/sign_defs.h
+++ b/src/nvim/sign_defs.h
@@ -2,6 +2,7 @@
#define NVIM_SIGN_DEFS_H
#include <stdbool.h>
+
#include "nvim/pos.h"
#include "nvim/types.h"
@@ -10,9 +11,9 @@
// Sign group
typedef struct signgroup_S
{
- uint16_t sg_refcount; // number of signs in this group
- int sg_next_sign_id; // next sign id for this group
- char_u sg_name[1]; // sign group name
+ uint16_t sg_refcount; // number of signs in this group
+ int sg_next_sign_id; // next sign id for this group
+ char_u sg_name[1]; // sign group name
} signgroup_T;
// Macros to get the sign group structure from the group name
@@ -22,23 +23,23 @@ typedef struct signgroup_S
typedef struct sign_entry sign_entry_T;
struct sign_entry {
- int se_id; // unique identifier for each placed sign
- int se_typenr; // typenr of sign
- int se_priority; // priority for highlighting
- bool se_has_text_or_icon; // has text or icon
- linenr_T se_lnum; // line number which has this sign
- signgroup_T *se_group; // sign group
- sign_entry_T *se_next; // next entry in a list of signs
- sign_entry_T *se_prev; // previous entry -- for easy reordering
+ int se_id; // unique identifier for each placed sign
+ int se_typenr; // typenr of sign
+ int se_priority; // priority for highlighting
+ bool se_has_text_or_icon; // has text or icon
+ linenr_T se_lnum; // line number which has this sign
+ signgroup_T *se_group; // sign group
+ sign_entry_T *se_next; // next entry in a list of signs
+ sign_entry_T *se_prev; // previous entry -- for easy reordering
};
/// Sign attributes. Used by the screen refresh routines.
typedef struct sign_attrs_S {
- int sat_typenr;
- char_u *sat_text;
- int sat_texthl;
- int sat_linehl;
- int sat_numhl;
+ int sat_typenr;
+ char_u *sat_text;
+ int sat_texthl;
+ int sat_linehl;
+ int sat_numhl;
} sign_attrs_T;
#define SIGN_SHOW_MAX 9
diff --git a/src/nvim/spell.c b/src/nvim/spell.c
index 450ec891ad..9ed421c8a0 100644
--- a/src/nvim/spell.c
+++ b/src/nvim/spell.c
@@ -2924,8 +2924,8 @@ void spell_suggest(int count)
// Get the list of suggestions. Limit to 'lines' - 2 or the number in
// 'spellsuggest', whatever is smaller.
- if (sps_limit > (int)Rows - 2) {
- limit = (int)Rows - 2;
+ if (sps_limit > Rows - 2) {
+ limit = Rows - 2;
} else {
limit = sps_limit;
}
diff --git a/src/nvim/spell.h b/src/nvim/spell.h
index e93c82b91d..f941f0e5e7 100644
--- a/src/nvim/spell.h
+++ b/src/nvim/spell.h
@@ -3,9 +3,9 @@
#include <stdbool.h>
-#include "nvim/spell_defs.h"
#include "nvim/ex_cmds_defs.h"
#include "nvim/globals.h"
+#include "nvim/spell_defs.h"
#include "nvim/vim.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
diff --git a/src/nvim/spell_defs.h b/src/nvim/spell_defs.h
index f07f5673f9..78aa6bf199 100644
--- a/src/nvim/spell_defs.h
+++ b/src/nvim/spell_defs.h
@@ -20,9 +20,9 @@
// is 8 bytes we could use something smaller, but what?
typedef int idx_T;
-# define SPL_FNAME_TMPL "%s.%s.spl"
-# define SPL_FNAME_ADD ".add."
-# define SPL_FNAME_ASCII ".ascii."
+#define SPL_FNAME_TMPL "%s.%s.spl"
+#define SPL_FNAME_ADD ".add."
+#define SPL_FNAME_ASCII ".ascii."
// Flags used for a word. Only the lowest byte can be used, the region byte
// comes above it.
@@ -71,22 +71,22 @@ typedef int idx_T;
// si_repsal, sl_rep, and si_sal. Not for sl_sal!
// One replacement: from "ft_from" to "ft_to".
typedef struct fromto_S {
- char_u *ft_from;
- char_u *ft_to;
+ char_u *ft_from;
+ char_u *ft_to;
} fromto_T;
// Info from "SAL" entries in ".aff" file used in sl_sal.
// The info is split for quick processing by spell_soundfold().
// Note that "sm_oneof" and "sm_rules" point into sm_lead.
typedef struct salitem_S {
- char_u *sm_lead; // leading letters
+ char_u *sm_lead; // leading letters
int sm_leadlen; // length of "sm_lead"
- char_u *sm_oneof; // letters from () or NULL
- char_u *sm_rules; // rules like ^, $, priority
- char_u *sm_to; // replacement.
- int *sm_lead_w; // wide character copy of "sm_lead"
- int *sm_oneof_w; // wide character copy of "sm_oneof"
- int *sm_to_w; // wide character copy of "sm_to"
+ char_u *sm_oneof; // letters from () or NULL
+ char_u *sm_rules; // rules like ^, $, priority
+ char_u *sm_to; // replacement.
+ int *sm_lead_w; // wide character copy of "sm_lead"
+ int *sm_oneof_w; // wide character copy of "sm_oneof"
+ int *sm_to_w; // wide character copy of "sm_to"
} salitem_T;
typedef int salfirst_T;
@@ -113,25 +113,25 @@ typedef int salfirst_T;
typedef struct slang_S slang_T;
struct slang_S {
- slang_T *sl_next; // next language
- char_u *sl_name; // language name "en", "en.rare", "nl", etc.
- char_u *sl_fname; // name of .spl file
+ slang_T *sl_next; // next language
+ char_u *sl_name; // language name "en", "en.rare", "nl", etc.
+ char_u *sl_fname; // name of .spl file
bool sl_add; // true if it's a .add file.
- char_u *sl_fbyts; // case-folded word bytes
- long sl_fbyts_len; // length of sl_fbyts
- idx_T *sl_fidxs; // case-folded word indexes
- char_u *sl_kbyts; // keep-case word bytes
- idx_T *sl_kidxs; // keep-case word indexes
- char_u *sl_pbyts; // prefix tree word bytes
- idx_T *sl_pidxs; // prefix tree word indexes
+ char_u *sl_fbyts; // case-folded word bytes
+ long sl_fbyts_len; // length of sl_fbyts
+ idx_T *sl_fidxs; // case-folded word indexes
+ char_u *sl_kbyts; // keep-case word bytes
+ idx_T *sl_kidxs; // keep-case word indexes
+ char_u *sl_pbyts; // prefix tree word bytes
+ idx_T *sl_pidxs; // prefix tree word indexes
- char_u *sl_info; // infotext string or NULL
+ char_u *sl_info; // infotext string or NULL
char_u sl_regions[MAXREGIONS * 2 + 1];
- // table with up to 8 region names plus NUL
+ // table with up to 8 region names plus NUL
- char_u *sl_midword; // MIDWORD string or NULL
+ char_u *sl_midword; // MIDWORD string or NULL
hashtab_T sl_wordcount; // hashtable with word count, wordcount_T
@@ -140,17 +140,17 @@ struct slang_S {
int sl_compsylmax; // COMPOUNDSYLMAX (default: MAXWLEN)
int sl_compoptions; // COMP_* flags
garray_T sl_comppat; // CHECKCOMPOUNDPATTERN items
- regprog_T *sl_compprog; // COMPOUNDRULE turned into a regexp progrm
- // (NULL when no compounding)
- char_u *sl_comprules; // all COMPOUNDRULE concatenated (or NULL)
- char_u *sl_compstartflags; // flags for first compound word
- char_u *sl_compallflags; // all flags for compound words
+ regprog_T *sl_compprog; // COMPOUNDRULE turned into a regexp progrm
+ // (NULL when no compounding)
+ char_u *sl_comprules; // all COMPOUNDRULE concatenated (or NULL)
+ char_u *sl_compstartflags; // flags for first compound word
+ char_u *sl_compallflags; // all flags for compound words
bool sl_nobreak; // When true: no spaces between words
- char_u *sl_syllable; // SYLLABLE repeatable chars or NULL
+ char_u *sl_syllable; // SYLLABLE repeatable chars or NULL
garray_T sl_syl_items; // syllable items
int sl_prefixcnt; // number of items in "sl_prefprog"
- regprog_T **sl_prefprog; // table with regprogs for prefixes
+ regprog_T **sl_prefprog; // table with regprogs for prefixes
garray_T sl_rep; // list of fromto_T entries from REP lines
int16_t sl_rep_first[256]; // indexes where byte first appears, -1 if
@@ -171,9 +171,9 @@ struct slang_S {
// Info from the .sug file. Loaded on demand.
time_t sl_sugtime; // timestamp for .sug file
- char_u *sl_sbyts; // soundfolded word bytes
- idx_T *sl_sidxs; // soundfolded word indexes
- buf_T *sl_sugbuf; // buffer with word number table
+ char_u *sl_sbyts; // soundfolded word bytes
+ idx_T *sl_sidxs; // soundfolded word indexes
+ buf_T *sl_sugbuf; // buffer with word number table
bool sl_sugloaded; // true when .sug file was loaded or failed to
// load
@@ -186,9 +186,9 @@ struct slang_S {
// Structure used in "b_langp", filled from 'spelllang'.
typedef struct langp_S {
- slang_T *lp_slang; // info for this language
- slang_T *lp_sallang; // language used for sound folding or NULL
- slang_T *lp_replang; // language used for REP items or NULL
+ slang_T *lp_slang; // info for this language
+ slang_T *lp_sallang; // language used for sound folding or NULL
+ slang_T *lp_replang; // language used for REP items or NULL
int lp_region; // bitmask for region or REGION_ALL
} langp_T;
@@ -268,7 +268,7 @@ typedef struct trystate_S {
#define SPELL_TOFOLD(c) ((c) >= 128 ? utf_fold(c) : (int)spelltab.st_fold[c])
#define SPELL_TOUPPER(c) ((c) >= 128 ? mb_toupper(c) \
- : (int)spelltab.st_upper[c])
+ : (int)spelltab.st_upper[c])
#define SPELL_ISUPPER(c) ((c) >= 128 ? mb_isupper(c) : spelltab.st_isu[c])
diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c
index 50b12f9dcc..e3a6236ae4 100644
--- a/src/nvim/spellfile.c
+++ b/src/nvim/spellfile.c
@@ -2659,7 +2659,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
// We simply concatenate all the MAP strings, separated by
// slashes.
- ga_concat(&spin->si_map, items[1]);
+ ga_concat(&spin->si_map, (char *)items[1]);
ga_append(&spin->si_map, '/');
}
}
diff --git a/src/nvim/spellfile.h b/src/nvim/spellfile.h
index 633ee014a7..235bc07f61 100644
--- a/src/nvim/spellfile.h
+++ b/src/nvim/spellfile.h
@@ -3,9 +3,9 @@
#include <stdbool.h>
+#include "nvim/ex_cmds_defs.h"
#include "nvim/spell_defs.h"
#include "nvim/types.h"
-#include "nvim/ex_cmds_defs.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "spellfile.h.generated.h"
diff --git a/src/nvim/state.c b/src/nvim/state.c
index 04271d750c..4eb0073873 100644
--- a/src/nvim/state.c
+++ b/src/nvim/state.c
@@ -195,6 +195,8 @@ char *get_mode(void)
|| restart_edit == 'V') {
buf[1] = 'i';
buf[2] = (char)restart_edit;
+ } else if (curbuf->terminal) {
+ buf[1] = 't';
}
}
diff --git a/src/nvim/state.h b/src/nvim/state.h
index 8027514148..b93d57d035 100644
--- a/src/nvim/state.h
+++ b/src/nvim/state.h
@@ -5,8 +5,8 @@
typedef struct vim_state VimState;
-typedef int(*state_check_callback)(VimState *state);
-typedef int(*state_execute_callback)(VimState *state, int key);
+typedef int (*state_check_callback)(VimState *state);
+typedef int (*state_execute_callback)(VimState *state, int key);
struct vim_state {
state_check_callback check;
diff --git a/src/nvim/strings.h b/src/nvim/strings.h
index f2876c6307..893b0ea269 100644
--- a/src/nvim/strings.h
+++ b/src/nvim/strings.h
@@ -1,12 +1,12 @@
#ifndef NVIM_STRINGS_H
#define NVIM_STRINGS_H
-#include <stdbool.h>
#include <stdarg.h>
+#include <stdbool.h>
#include <string.h>
-#include "nvim/types.h"
#include "nvim/eval/typval.h"
+#include "nvim/types.h"
/// Append string to string and return pointer to the next byte
///
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index ecbfbf8a93..3afc2aff52 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -4390,8 +4390,8 @@ static void syn_cmd_include(exarg_T *eap, int syncing)
prev_toplvl_grp = curwin->w_s->b_syn_topgrp;
curwin->w_s->b_syn_topgrp = sgl_id;
if (source
- ? do_source(eap->arg, false, DOSO_NONE) == FAIL
- : source_runtime(eap->arg, DIP_ALL) == FAIL) {
+ ? do_source((char *)eap->arg, false, DOSO_NONE) == FAIL
+ : source_runtime((char *)eap->arg, DIP_ALL) == FAIL) {
EMSG2(_(e_notopen), eap->arg);
}
curwin->w_s->b_syn_topgrp = prev_toplvl_grp;
@@ -4420,7 +4420,7 @@ static void syn_cmd_keyword(exarg_T *eap, int syncing)
if (eap->skip) {
syn_id = -1;
} else {
- syn_id = syn_check_group(arg, (int)(group_name_end - arg));
+ syn_id = syn_check_group((char *)arg, (int)(group_name_end - arg));
}
if (syn_id != 0) {
// Allocate a buffer, for removing backslashes in the keyword.
@@ -4557,7 +4557,7 @@ static void syn_cmd_match(exarg_T *eap, int syncing)
if (!ends_excmd(*rest) || eap->skip) {
rest = NULL;
} else {
- if ((syn_id = syn_check_group(arg, (int)(group_name_end - arg))) != 0) {
+ if ((syn_id = syn_check_group((char *)arg, (int)(group_name_end - arg))) != 0) {
syn_incl_toplevel(syn_id, &syn_opt_arg.flags);
/*
* Store the pattern in the syn_items list
@@ -4706,7 +4706,7 @@ static void syn_cmd_region(exarg_T *eap, int syncing)
if ((p - rest == 4 && STRNCMP(rest, "NONE", 4) == 0) || eap->skip) {
matchgroup_id = 0;
} else {
- matchgroup_id = syn_check_group(rest, (int)(p - rest));
+ matchgroup_id = syn_check_group((char *)rest, (int)(p - rest));
if (matchgroup_id == 0) {
illegal = true;
break;
@@ -4765,7 +4765,7 @@ static void syn_cmd_region(exarg_T *eap, int syncing)
rest = NULL;
} else {
ga_grow(&(curwin->w_s->b_syn_patterns), pat_count);
- if ((syn_id = syn_check_group(arg, (int)(group_name_end - arg))) != 0) {
+ if ((syn_id = syn_check_group((char *)arg, (int)(group_name_end - arg))) != 0) {
syn_incl_toplevel(syn_id, &syn_opt_arg.flags);
/*
* Store the start/skip/end in the syn_items list
@@ -5261,8 +5261,7 @@ static void syn_cmd_sync(exarg_T *eap, int syncing)
if (!ends_excmd(*next_arg)) {
arg_end = skiptowhite(next_arg);
if (!eap->skip) {
- curwin->w_s->b_syn_sync_id = syn_check_group(next_arg,
- (int)(arg_end - next_arg));
+ curwin->w_s->b_syn_sync_id = syn_check_group((char *)next_arg, (int)(arg_end - next_arg));
}
next_arg = skipwhite(arg_end);
} else if (!eap->skip) {
@@ -5444,7 +5443,7 @@ static int get_id_list(char_u **const arg, const int keylen, int16_t **const lis
* Handle full group name.
*/
if (vim_strpbrk(name + 1, (char_u *)"\\.*^$~[") == NULL) {
- id = syn_check_group(name + 1, (int)(end - p));
+ id = syn_check_group((char *)(name + 1), (int)(end - p));
} else {
// Handle match of regexp with group names.
*name = '^';
@@ -6614,10 +6613,10 @@ int load_colors(char_u *name)
buf = xmalloc(buflen);
apply_autocmds(EVENT_COLORSCHEMEPRE, name, curbuf->b_fname, false, curbuf);
snprintf((char *)buf, buflen, "colors/%s.vim", name);
- retval = source_runtime(buf, DIP_START + DIP_OPT);
+ retval = source_runtime((char *)buf, DIP_START + DIP_OPT);
if (retval == FAIL) {
snprintf((char *)buf, buflen, "colors/%s.lua", name);
- retval = source_runtime(buf, DIP_START + DIP_OPT);
+ retval = source_runtime((char *)buf, DIP_START + DIP_OPT);
}
xfree(buf);
apply_autocmds(EVENT_COLORSCHEME, name, curbuf->b_fname, false, curbuf);
@@ -6810,13 +6809,11 @@ void do_highlight(const char *line, const bool forceit, const bool init)
return;
}
- from_id = syn_check_group((const char_u *)from_start,
- (int)(from_end - from_start));
+ from_id = syn_check_group(from_start, (int)(from_end - from_start));
if (strncmp(to_start, "NONE", 4) == 0) {
to_id = 0;
} else {
- to_id = syn_check_group((const char_u *)to_start,
- (int)(to_end - to_start));
+ to_id = syn_check_group(to_start, (int)(to_end - to_start));
}
if (from_id > 0) {
@@ -6877,7 +6874,7 @@ void do_highlight(const char *line, const bool forceit, const bool init)
}
// Find the group name in the table. If it does not exist yet, add it.
- id = syn_check_group((const char_u *)line, (int)(name_end - line));
+ id = syn_check_group(line, (int)(name_end - line));
if (id == 0) { // Failed (out of memory).
return;
}
@@ -7681,11 +7678,11 @@ char_u *syn_id2name(int id)
/// @param len length of \p pp
///
/// @return 0 for failure else the id of the group
-int syn_check_group(const char_u *name, int len)
+int syn_check_group(const char *name, int len)
{
- int id = syn_name2id_len(name, len);
+ int id = syn_name2id_len((char_u *)name, len);
if (id == 0) { // doesn't exist yet
- return syn_add_group(vim_strnsave(name, len));
+ return syn_add_group(vim_strnsave((char_u *)name, len));
}
return id;
}
@@ -7885,7 +7882,7 @@ void highlight_changed(void)
/// Translate builtin highlight groups into attributes for quick lookup.
for (int hlf = 0; hlf < HLF_COUNT; hlf++) {
- id = syn_check_group((char_u *)hlf_names[hlf], STRLEN(hlf_names[hlf]));
+ id = syn_check_group(hlf_names[hlf], STRLEN(hlf_names[hlf]));
if (id == 0) {
abort();
}
diff --git a/src/nvim/syntax.h b/src/nvim/syntax.h
index 38f848f178..15fc084a0a 100644
--- a/src/nvim/syntax.h
+++ b/src/nvim/syntax.h
@@ -3,31 +3,31 @@
#include <stdbool.h>
-#include "nvim/globals.h"
#include "nvim/buffer_defs.h"
#include "nvim/ex_cmds_defs.h"
+#include "nvim/globals.h"
-#define HL_CONTAINED 0x01 /* not used on toplevel */
-#define HL_TRANSP 0x02 /* has no highlighting */
-#define HL_ONELINE 0x04 /* match within one line only */
-#define HL_HAS_EOL 0x08 /* end pattern that matches with $ */
-#define HL_SYNC_HERE 0x10 /* sync point after this item (syncing only) */
-#define HL_SYNC_THERE 0x20 /* sync point at current line (syncing only) */
-#define HL_MATCH 0x40 /* use match ID instead of item ID */
-#define HL_SKIPNL 0x80 /* nextgroup can skip newlines */
-#define HL_SKIPWHITE 0x100 /* nextgroup can skip white space */
-#define HL_SKIPEMPTY 0x200 /* nextgroup can skip empty lines */
-#define HL_KEEPEND 0x400 /* end match always kept */
-#define HL_EXCLUDENL 0x800 /* exclude NL from match */
-#define HL_DISPLAY 0x1000 /* only used for displaying, not syncing */
-#define HL_FOLD 0x2000 /* define fold */
-#define HL_EXTEND 0x4000 /* ignore a keepend */
-#define HL_MATCHCONT 0x8000 /* match continued from previous line */
-#define HL_TRANS_CONT 0x10000 /* transparent item without contains arg */
-#define HL_CONCEAL 0x20000 /* can be concealed */
-#define HL_CONCEALENDS 0x40000 /* can be concealed */
-
-#define SYN_GROUP_STATIC(s) syn_check_group((char_u *)S_LEN(s))
+#define HL_CONTAINED 0x01 // not used on toplevel
+#define HL_TRANSP 0x02 // has no highlighting
+#define HL_ONELINE 0x04 // match within one line only
+#define HL_HAS_EOL 0x08 // end pattern that matches with $
+#define HL_SYNC_HERE 0x10 // sync point after this item (syncing only)
+#define HL_SYNC_THERE 0x20 // sync point at current line (syncing only)
+#define HL_MATCH 0x40 // use match ID instead of item ID
+#define HL_SKIPNL 0x80 // nextgroup can skip newlines
+#define HL_SKIPWHITE 0x100 // nextgroup can skip white space
+#define HL_SKIPEMPTY 0x200 // nextgroup can skip empty lines
+#define HL_KEEPEND 0x400 // end match always kept
+#define HL_EXCLUDENL 0x800 // exclude NL from match
+#define HL_DISPLAY 0x1000 // only used for displaying, not syncing
+#define HL_FOLD 0x2000 // define fold
+#define HL_EXTEND 0x4000 // ignore a keepend
+#define HL_MATCHCONT 0x8000 // match continued from previous line
+#define HL_TRANS_CONT 0x10000 // transparent item without contains arg
+#define HL_CONCEAL 0x20000 // can be concealed
+#define HL_CONCEALENDS 0x40000 // can be concealed
+
+#define SYN_GROUP_STATIC(s) syn_check_group(S_LEN(s))
typedef struct {
char *name;
diff --git a/src/nvim/syntax_defs.h b/src/nvim/syntax_defs.h
index 5ee0611d58..526be905e9 100644
--- a/src/nvim/syntax_defs.h
+++ b/src/nvim/syntax_defs.h
@@ -3,18 +3,18 @@
#include "nvim/highlight_defs.h"
-# define SST_MIN_ENTRIES 150 /* minimal size for state stack array */
-# define SST_MAX_ENTRIES 1000 /* maximal size for state stack array */
-# define SST_FIX_STATES 7 /* size of sst_stack[]. */
-# define SST_DIST 16 /* normal distance between entries */
-# define SST_INVALID (synstate_T *)-1 /* invalid syn_state pointer */
+#define SST_MIN_ENTRIES 150 // minimal size for state stack array
+#define SST_MAX_ENTRIES 1000 // maximal size for state stack array
+#define SST_FIX_STATES 7 // size of sst_stack[].
+#define SST_DIST 16 // normal distance between entries
+#define SST_INVALID (synstate_T *)-1 // invalid syn_state pointer
typedef struct syn_state synstate_T;
#include "nvim/buffer_defs.h"
#include "nvim/regexp_defs.h"
-/* struct passed to in_id_list() */
+// struct passed to in_id_list()
struct sp_syn {
int inc_tag; // ":syn include" unique tag
int16_t id; // highlight group ID of item
@@ -27,7 +27,7 @@ struct sp_syn {
typedef struct keyentry keyentry_T;
struct keyentry {
- keyentry_T *ke_next; // next entry with identical "keyword[]"
+ keyentry_T *ke_next; // next entry with identical "keyword[]"
struct sp_syn k_syn; // struct passed to in_id_list()
int16_t *next_list; // ID list for next match (if non-zero)
int flags;
@@ -39,11 +39,11 @@ struct keyentry {
* Struct used to store one state of the state stack.
*/
typedef struct buf_state {
- int bs_idx; /* index of pattern */
- int bs_flags; /* flags for pattern */
- int bs_seqnr; /* stores si_seqnr */
- int bs_cchar; /* stores si_cchar */
- reg_extmatch_T *bs_extmatch; /* external matches from start pattern */
+ int bs_idx; // index of pattern
+ int bs_flags; // flags for pattern
+ int bs_seqnr; // stores si_seqnr
+ int bs_cchar; // stores si_cchar
+ reg_extmatch_T *bs_extmatch; // external matches from start pattern
} bufstate_T;
/*
@@ -51,11 +51,11 @@ typedef struct buf_state {
* Used by b_sst_array[].
*/
struct syn_state {
- synstate_T *sst_next; /* next entry in used or free list */
- linenr_T sst_lnum; /* line number for this state */
+ synstate_T *sst_next; // next entry in used or free list
+ linenr_T sst_lnum; // line number for this state
union {
- bufstate_T sst_stack[SST_FIX_STATES]; /* short state stack */
- garray_T sst_ga; /* growarray for long state stack */
+ bufstate_T sst_stack[SST_FIX_STATES]; // short state stack
+ garray_T sst_ga; // growarray for long state stack
} sst_union;
int sst_next_flags; // flags for sst_next_list
int sst_stacksize; // number of states on the stack
diff --git a/src/nvim/tag.c b/src/nvim/tag.c
index 3b29d62191..83b06e2f6d 100644
--- a/src/nvim/tag.c
+++ b/src/nvim/tag.c
@@ -906,7 +906,7 @@ static int add_llist_tags(char_u *tag, int num_matches, char_u **matches)
if (len > 128) {
len = 128;
}
- xstrlcpy((char *)tag_name, (const char *)tagp.tagname, len + 1);
+ STRLCPY(tag_name, tagp.tagname, len + 1);
tag_name[len] = NUL;
// Save the tag file name
@@ -914,7 +914,7 @@ static int add_llist_tags(char_u *tag, int num_matches, char_u **matches)
if (p == NULL) {
continue;
}
- xstrlcpy((char *)fname, (const char *)p, MAXPATHL);
+ STRLCPY(fname, p, MAXPATHL);
XFREE_CLEAR(p);
// Get the line number or the search pattern used to locate
diff --git a/src/nvim/tag.h b/src/nvim/tag.h
index 9f671043b3..64bacceb1b 100644
--- a/src/nvim/tag.h
+++ b/src/nvim/tag.h
@@ -1,24 +1,24 @@
#ifndef NVIM_TAG_H
#define NVIM_TAG_H
-#include "nvim/types.h"
#include "nvim/ex_cmds_defs.h"
+#include "nvim/types.h"
/*
* Values for do_tag().
*/
-#define DT_TAG 1 /* jump to newer position or same tag again */
-#define DT_POP 2 /* jump to older position */
-#define DT_NEXT 3 /* jump to next match of same tag */
-#define DT_PREV 4 /* jump to previous match of same tag */
-#define DT_FIRST 5 /* jump to first match of same tag */
-#define DT_LAST 6 /* jump to first match of same tag */
-#define DT_SELECT 7 /* jump to selection from list */
-#define DT_HELP 8 /* like DT_TAG, but no wildcards */
-#define DT_JUMP 9 /* jump to new tag or selection from list */
-#define DT_CSCOPE 10 /* cscope find command (like tjump) */
-#define DT_LTAG 11 /* tag using location list */
-#define DT_FREE 99 /* free cached matches */
+#define DT_TAG 1 // jump to newer position or same tag again
+#define DT_POP 2 // jump to older position
+#define DT_NEXT 3 // jump to next match of same tag
+#define DT_PREV 4 // jump to previous match of same tag
+#define DT_FIRST 5 // jump to first match of same tag
+#define DT_LAST 6 // jump to first match of same tag
+#define DT_SELECT 7 // jump to selection from list
+#define DT_HELP 8 // like DT_TAG, but no wildcards
+#define DT_JUMP 9 // jump to new tag or selection from list
+#define DT_CSCOPE 10 // cscope find command (like tjump)
+#define DT_LTAG 11 // tag using location list
+#define DT_FREE 99 // free cached matches
//
// flags for find_tags().
@@ -40,11 +40,11 @@
* Structure used for get_tagfname().
*/
typedef struct {
- char_u *tn_tags; /* value of 'tags' when starting */
- char_u *tn_np; /* current position in tn_tags */
+ char_u *tn_tags; // value of 'tags' when starting
+ char_u *tn_np; // current position in tn_tags
int tn_did_filefind_init;
int tn_hf_idx;
- void *tn_search_ctx;
+ void *tn_search_ctx;
} tagname_T;
diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c
index 6f19a9209e..fb025265f2 100644
--- a/src/nvim/terminal.c
+++ b/src/nvim/terminal.c
@@ -358,11 +358,21 @@ void terminal_enter(void)
// Disable these options in terminal-mode. They are nonsense because cursor is
// placed at end of buffer to "follow" output. #11072
win_T *save_curwin = curwin;
- int save_w_p_cul = curwin->w_p_cul;
+ bool save_w_p_cul = curwin->w_p_cul;
+ char_u *save_w_p_culopt = NULL;
+ char_u save_w_p_culopt_flags = curwin->w_p_culopt_flags;
int save_w_p_cuc = curwin->w_p_cuc;
long save_w_p_so = curwin->w_p_so;
long save_w_p_siso = curwin->w_p_siso;
- curwin->w_p_cul = false;
+ if (curwin->w_p_cul && curwin->w_p_culopt_flags & CULOPT_NBR) {
+ if (strcmp((char *)curwin->w_p_culopt, "number")) {
+ save_w_p_culopt = curwin->w_p_culopt;
+ curwin->w_p_culopt = (char_u *)xstrdup("number");
+ }
+ curwin->w_p_culopt_flags = CULOPT_NBR;
+ } else {
+ curwin->w_p_cul = false;
+ }
curwin->w_p_cuc = false;
curwin->w_p_so = 0;
curwin->w_p_siso = 0;
@@ -386,9 +396,16 @@ void terminal_enter(void)
if (save_curwin == curwin) { // save_curwin may be invalid (window closed)!
curwin->w_p_cul = save_w_p_cul;
+ if (save_w_p_culopt) {
+ xfree(curwin->w_p_culopt);
+ curwin->w_p_culopt = save_w_p_culopt;
+ }
+ curwin->w_p_culopt_flags = save_w_p_culopt_flags;
curwin->w_p_cuc = save_w_p_cuc;
curwin->w_p_so = save_w_p_so;
curwin->w_p_siso = save_w_p_siso;
+ } else if (save_w_p_culopt) {
+ xfree(save_w_p_culopt);
}
// draw the unfocused cursor
@@ -1224,7 +1241,7 @@ static bool send_mouse_event(Terminal *term, int c)
mouse_action(term, button, row, col - offset, drag, 0);
size_t len = vterm_output_read(term->vt, term->textbuf,
sizeof(term->textbuf));
- terminal_send(term, term->textbuf, (size_t)len);
+ terminal_send(term, term->textbuf, len);
return false;
}
diff --git a/src/nvim/terminal.h b/src/nvim/terminal.h
index f2b0e232c3..001adbadc3 100644
--- a/src/nvim/terminal.h
+++ b/src/nvim/terminal.h
@@ -1,8 +1,8 @@
#ifndef NVIM_TERMINAL_H
#define NVIM_TERMINAL_H
-#include <stddef.h>
#include <stdbool.h>
+#include <stddef.h>
#include <stdint.h>
typedef struct terminal Terminal;
diff --git a/src/nvim/testdir/samples/memfile_test.c b/src/nvim/testdir/samples/memfile_test.c
index 7023064637..73f67fb250 100644
--- a/src/nvim/testdir/samples/memfile_test.c
+++ b/src/nvim/testdir/samples/memfile_test.c
@@ -1,6 +1,8 @@
// This is an open source non-commercial project. Dear PVS-Studio, please check
// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
+// uncrustify:off
+
/* vi:set ts=8 sts=4 sw=4 noet:
*
* VIM - Vi IMproved by Bram Moolenaar
diff --git a/src/nvim/testdir/test_arglist.vim b/src/nvim/testdir/test_arglist.vim
index 01d8f32893..8fd60d6a5a 100644
--- a/src/nvim/testdir/test_arglist.vim
+++ b/src/nvim/testdir/test_arglist.vim
@@ -88,7 +88,7 @@ func Test_argadd_empty_curbuf()
argadd Xargadd
call assert_equal(curbuf, bufnr('%'))
call assert_equal('', bufname('%'))
- call assert_equal(1, line('$'))
+ call assert_equal(1, '$'->line())
rew
call assert_notequal(curbuf, '%'->bufnr())
call assert_equal('Xargadd', '%'->bufname())
diff --git a/src/nvim/testdir/test_breakindent.vim b/src/nvim/testdir/test_breakindent.vim
index 97b570e64f..277050876e 100644
--- a/src/nvim/testdir/test_breakindent.vim
+++ b/src/nvim/testdir/test_breakindent.vim
@@ -418,8 +418,8 @@ endfunc
func Test_breakindent11()
" test strdisplaywidth()
call s:test_windows('setl cpo-=n sbr=>> nu nuw=4 nolist briopt= ts=4')
- let text=getline(2)
- let width = strlen(text[1:])+indent(2)+strlen(&sbr)*3 " text wraps 3 times
+ let text = getline(2)
+ let width = strlen(text[1:]) + indent(2) + strlen(&sbr) * 3 " text wraps 3 times
call assert_equal(width, strdisplaywidth(text))
call s:close_windows('set sbr=')
endfunc
@@ -431,7 +431,7 @@ func Test_breakindent11_vartabs()
" test strdisplaywidth()
call s:test_windows('setl cpo-=n sbr=>> nu nuw=4 nolist briopt= ts=4 vts=4')
let text = getline(2)
- let width = strlen(text[1:])+indent(2)+strlen(&sbr)*3 " text wraps 3 times
+ let width = strlen(text[1:]) + 2->indent() + strlen(&sbr) * 3 " text wraps 3 times
call assert_equal(width, strdisplaywidth(text))
call s:close_windows('set sbr= vts&')
endfunc
diff --git a/src/nvim/testdir/test_bufline.vim b/src/nvim/testdir/test_bufline.vim
index b4e8a0bc71..765ae17736 100644
--- a/src/nvim/testdir/test_bufline.vim
+++ b/src/nvim/testdir/test_bufline.vim
@@ -9,7 +9,7 @@ func Test_setbufline_getbufline()
hide
call assert_equal(0, setbufline(b, 1, ['foo', 'bar']))
call assert_equal(['foo'], getbufline(b, 1))
- call assert_equal(['bar'], getbufline(b, 2))
+ call assert_equal(['bar'], getbufline(b, '$'))
call assert_equal(['foo', 'bar'], getbufline(b, 1, 2))
exe "bd!" b
call assert_equal([], getbufline(b, 1, 2))
@@ -21,7 +21,7 @@ func Test_setbufline_getbufline()
call assert_equal(1, setbufline(b, 5, ['x']))
call assert_equal(1, setbufline(1234, 1, ['x']))
call assert_equal(0, setbufline(b, 4, ['d', 'e']))
- call assert_equal(['c'], getbufline(b, 3))
+ call assert_equal(['c'], b->getbufline(3))
call assert_equal(['d'], getbufline(b, 4))
call assert_equal(['e'], getbufline(b, 5))
call assert_equal([], getbufline(b, 6))
@@ -82,6 +82,7 @@ func Test_appendbufline()
call setline(1, ['a', 'b', 'c'])
let b = bufnr('%')
wincmd w
+ call assert_equal(1, appendbufline(b, -1, ['x']))
call assert_equal(1, appendbufline(b, 4, ['x']))
call assert_equal(1, appendbufline(1234, 1, ['x']))
call assert_equal(0, appendbufline(b, 3, ['d', 'e']))
@@ -104,8 +105,11 @@ func Test_deletebufline()
exe "bd!" b
call assert_equal(1, b->deletebufline(1))
+ call assert_equal(1, deletebufline(-1, 1))
+
split Xtest
call setline(1, ['a', 'b', 'c'])
+ call cursor(line('$'), 1)
let b = bufnr('%')
wincmd w
call assert_equal(1, deletebufline(b, 4))
diff --git a/src/nvim/testdir/test_bufwintabinfo.vim b/src/nvim/testdir/test_bufwintabinfo.vim
index 4b5b55e6bf..bb672cf0ec 100644
--- a/src/nvim/testdir/test_bufwintabinfo.vim
+++ b/src/nvim/testdir/test_bufwintabinfo.vim
@@ -77,7 +77,7 @@ function Test_getbufwintabinfo()
call assert_equal('green', winlist[2].variables.signal)
call assert_equal(w4_id, winlist[3].winid)
- let winfo = getwininfo(w5_id)[0]
+ let winfo = w5_id->getwininfo()[0]
call assert_equal(2, winfo.tabnr)
call assert_equal([], getwininfo(3))
@@ -88,7 +88,7 @@ function Test_getbufwintabinfo()
call assert_equal(2, tablist[1].tabnr)
call assert_equal('build', tablist[0].variables.space)
call assert_equal(w2_id, tablist[0].windows[0])
- call assert_equal([], gettabinfo(3))
+ call assert_equal([], 3->gettabinfo())
tabonly | only
@@ -106,7 +106,7 @@ function Test_getbufwintabinfo()
endfunction
function Test_get_buf_options()
- let opts = getbufvar(bufnr('%'), '&')
+ let opts = bufnr()->getbufvar('&')
call assert_equal(v:t_dict, type(opts))
call assert_equal(8, opts.tabstop)
endfunc
diff --git a/src/nvim/testdir/test_changelist.vim b/src/nvim/testdir/test_changelist.vim
index dd6ea9600c..ce77c1f3c7 100644
--- a/src/nvim/testdir/test_changelist.vim
+++ b/src/nvim/testdir/test_changelist.vim
@@ -8,8 +8,8 @@ func Test_getchangelist()
bwipe!
enew
- call assert_equal([], getchangelist(10))
- call assert_equal([[], 0], getchangelist('%'))
+ call assert_equal([], 10->getchangelist())
+ call assert_equal([[], 0], getchangelist())
call writefile(['line1', 'line2', 'line3'], 'Xfile1.txt')
call writefile(['line1', 'line2', 'line3'], 'Xfile2.txt')
diff --git a/src/nvim/testdir/test_clientserver.vim b/src/nvim/testdir/test_clientserver.vim
index 53704bd094..f3db472b03 100644
--- a/src/nvim/testdir/test_clientserver.vim
+++ b/src/nvim/testdir/test_clientserver.vim
@@ -34,7 +34,7 @@ func Test_client_server()
" When using valgrind it takes much longer.
call WaitForAssert({-> assert_match(name, serverlist())})
- call remote_foreground(name)
+ eval name->remote_foreground()
call remote_send(name, ":let testvar = 'yes'\<CR>")
call WaitFor('remote_expr("' . name . '", "exists(\"testvar\") ? testvar : \"\"", "", 1) == "yes"')
@@ -53,7 +53,7 @@ func Test_client_server()
endif
" Wait for the server to be up and answering requests.
sleep 100m
- call WaitForAssert({-> assert_true(remote_expr(name, "v:version", "", 1) != "")})
+ call WaitForAssert({-> assert_true(name->remote_expr("v:version", "", 1) != "")})
call remote_send(name, ":let testvar = 'maybe'\<CR>")
call WaitForAssert({-> assert_equal('maybe', remote_expr(name, "testvar", "", 2))})
@@ -72,7 +72,7 @@ func Test_client_server()
" Expression evaluated locally.
if v:servername == ''
- call remote_startserver('MYSELF')
+ eval 'MYSELF'->remote_startserver()
" May get MYSELF1 when running the test again.
call assert_match('MYSELF', v:servername)
endif
@@ -80,11 +80,11 @@ func Test_client_server()
call assert_equal('myself', remote_expr(v:servername, 'testvar'))
call remote_send(name, ":call server2client(expand('<client>'), 'got it')\<CR>", 'g:myserverid')
- call assert_equal('got it', remote_read(g:myserverid, 2))
+ call assert_equal('got it', g:myserverid->remote_read(2))
call remote_send(name, ":call server2client(expand('<client>'), 'another')\<CR>", 'g:myserverid')
let peek_result = 'nothing'
- let r = remote_peek(g:myserverid, 'peek_result')
+ let r = g:myserverid->remote_peek('peek_result')
" unpredictable whether the result is already available.
if r > 0
call assert_equal('another', peek_result)
@@ -98,7 +98,7 @@ func Test_client_server()
call assert_equal('another', g:peek_result)
call assert_equal('another', remote_read(g:myserverid, 2))
- call remote_send(name, ":qa!\<CR>")
+ eval name->remote_send(":qa!\<CR>")
try
call WaitForAssert({-> assert_equal("dead", job_status(job))})
finally
diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim
index 5a6824b5c1..ffca415282 100644
--- a/src/nvim/testdir/test_cmdline.vim
+++ b/src/nvim/testdir/test_cmdline.vim
@@ -260,7 +260,7 @@ func Test_getcompletion()
endif
let groupcount = len(getcompletion('', 'event'))
call assert_true(groupcount > 0)
- let matchcount = len(getcompletion('File', 'event'))
+ let matchcount = len('File'->getcompletion('event'))
call assert_true(matchcount > 0)
call assert_true(groupcount > matchcount)
diff --git a/src/nvim/testdir/test_cursor_func.vim b/src/nvim/testdir/test_cursor_func.vim
index 53b7da517e..46847e0663 100644
--- a/src/nvim/testdir/test_cursor_func.vim
+++ b/src/nvim/testdir/test_cursor_func.vim
@@ -25,6 +25,12 @@ func Test_move_cursor()
call cursor(9, 1)
call assert_equal([4, 1, 0, 1], getcurpos()[1:])
+ call setline(1, ["\<TAB>"])
+ call cursor(1, 1, 1)
+ call assert_equal([1, 1, 1], getcurpos()[1:3])
+
+ call assert_equal(-1, cursor(-1, -1))
+
quit!
endfunc
diff --git a/src/nvim/testdir/test_edit.vim b/src/nvim/testdir/test_edit.vim
index e1393e875b..2b389c015f 100644
--- a/src/nvim/testdir/test_edit.vim
+++ b/src/nvim/testdir/test_edit.vim
@@ -201,11 +201,11 @@ func Test_edit_07()
endfu
au InsertCharPre <buffer> :call DoIt()
call feedkeys("A\<f5>\<c-p>u\<cr>\<c-l>\<cr>", 'tx')
- call assert_equal(["Jan\<c-l>",''], getline(1,'$'))
+ call assert_equal(["Jan\<c-l>",''], 1->getline('$'))
%d
call setline(1, 'J')
call feedkeys("A\<f5>\<c-p>u\<down>\<c-l>\<cr>", 'tx')
- call assert_equal(["January"], getline(1,'$'))
+ call assert_equal(["January"], 1->getline('$'))
delfu ListMonths
delfu DoIt
@@ -348,7 +348,7 @@ func Test_edit_12()
call cursor(2, 4)
call feedkeys("R^\<c-d>", 'tnix')
call assert_equal(["\tabc", "def"], getline(1, '$'))
- call assert_equal([0, 2, 2, 0], getpos('.'))
+ call assert_equal([0, 2, 2, 0], '.'->getpos())
%d
call setline(1, ["\tabc", "\t\tdef"])
call cursor(2, 2)
diff --git a/src/nvim/testdir/test_environ.vim b/src/nvim/testdir/test_environ.vim
index a25d83753c..cc15b63824 100644
--- a/src/nvim/testdir/test_environ.vim
+++ b/src/nvim/testdir/test_environ.vim
@@ -15,7 +15,7 @@ endfunc
func Test_getenv()
unlet! $TESTENV
- call assert_equal(v:null, getenv('TESTENV'))
+ call assert_equal(v:null, 'TESTENV'->getenv())
let $TESTENV = 'foo'
call assert_equal('foo', getenv('TESTENV'))
endfunc
diff --git a/src/nvim/testdir/test_escaped_glob.vim b/src/nvim/testdir/test_escaped_glob.vim
index 2bfd82c296..1a4fd8bdab 100644
--- a/src/nvim/testdir/test_escaped_glob.vim
+++ b/src/nvim/testdir/test_escaped_glob.vim
@@ -16,7 +16,7 @@ function Test_glob()
" Execute these commands in the sandbox, so that using the shell fails.
" Setting 'shell' to an invalid name causes a memory leak.
sandbox call assert_equal("", glob('Xxx\{'))
- sandbox call assert_equal("", glob('Xxx\$'))
+ sandbox call assert_equal("", 'Xxx\$'->glob())
w! Xxx\{
" } to fix highlighting
w! Xxx\$
@@ -28,7 +28,7 @@ endfunction
function Test_globpath()
sandbox call assert_equal(expand("sautest/autoload/globone.vim\nsautest/autoload/globtwo.vim"),
- \ globpath('sautest/autoload', 'glob*.vim'))
+ \ globpath('sautest/autoload', 'glob*.vim'))
sandbox call assert_equal([expand('sautest/autoload/globone.vim'), expand('sautest/autoload/globtwo.vim')],
- \ globpath('sautest/autoload', 'glob*.vim', 0, 1))
+ \ 'glob*.vim'->globpath('sautest/autoload', 0, 1))
endfunction
diff --git a/src/nvim/testdir/test_expand_func.vim b/src/nvim/testdir/test_expand_func.vim
index 9588d3b89d..44d2c156d5 100644
--- a/src/nvim/testdir/test_expand_func.vim
+++ b/src/nvim/testdir/test_expand_func.vim
@@ -37,6 +37,15 @@ func Test_expand_sflnum()
delcommand Flnum
endfunc
+func Test_expand()
+ new
+ call assert_equal("", expand('%:S'))
+ call assert_equal('3', '<slnum>'->expand())
+ call assert_equal(['4'], expand('<slnum>', v:false, v:true))
+ " Don't add any line above this, otherwise <slnum> will change.
+ quit
+endfunc
+
func Test_expand_sfile()
call assert_match('test_expand_func\.vim$', s:sfile)
call assert_match('^function .*\.\.Test_expand_sfile$', expand('<sfile>'))
diff --git a/src/nvim/testdir/test_expr.vim b/src/nvim/testdir/test_expr.vim
index c49285621a..6343c47fde 100644
--- a/src/nvim/testdir/test_expr.vim
+++ b/src/nvim/testdir/test_expr.vim
@@ -147,7 +147,7 @@ function Test_printf_spec_s()
call assert_equal(string(value), printf('%s', value))
" funcref
- call assert_equal('printf', printf('%s', function('printf')))
+ call assert_equal('printf', printf('%s', 'printf'->function()))
" partial
call assert_equal(string(function('printf', ['%s'])), printf('%s', function('printf', ['%s'])))
@@ -477,7 +477,7 @@ func Test_funcref()
endfunc
call assert_equal(2, OneByName())
call assert_equal(1, OneByRef())
- let OneByRef = funcref('One')
+ let OneByRef = 'One'->funcref()
call assert_equal(2, OneByRef())
call assert_fails('echo funcref("{")', 'E475:')
let OneByRef = funcref("One", repeat(["foo"], 20))
diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim
index cca89cbd6d..18e59bb6b7 100644
--- a/src/nvim/testdir/test_filetype.vim
+++ b/src/nvim/testdir/test_filetype.vim
@@ -112,7 +112,7 @@ let s:filename_checks = {
\ 'coco': ['file.atg'],
\ 'conaryrecipe': ['file.recipe'],
\ 'conf': ['auto.master'],
- \ 'config': ['configure.in', 'configure.ac', 'Pipfile', '/etc/hostname.file'],
+ \ 'config': ['configure.in', 'configure.ac', '/etc/hostname.file'],
\ 'context': ['tex/context/any/file.tex', 'file.mkii', 'file.mkiv', 'file.mkvi', 'file.mkxl', 'file.mklx'],
\ 'cpp': ['file.cxx', 'file.c++', 'file.hh', 'file.hxx', 'file.hpp', 'file.ipp', 'file.moc', 'file.tcc', 'file.inl', 'file.tlh'],
\ 'crm': ['file.crm'],
@@ -503,8 +503,8 @@ let s:filename_checks = {
\ 'tidy': ['.tidyrc', 'tidyrc', 'tidy.conf'],
\ 'tilde': ['file.t.html'],
\ 'tli': ['file.tli'],
- \ 'tmux': ['tmuxfile.conf', '.tmuxfile.conf', '.tmux-file.conf', '.tmux.conf', 'tmux-file.conf', 'tmux.conf'],
- \ 'toml': ['file.toml'],
+ \ 'tmux': ['tmuxfile.conf', '.tmuxfile.conf', '.tmux-file.conf', '.tmux.conf', 'tmux-file.conf', 'tmux.conf', 'tmux.conf.local'],
+ \ 'toml': ['file.toml', 'Gopkg.lock', 'Pipfile', '/home/user/.cargo/config'],
\ 'tpp': ['file.tpp'],
\ 'treetop': ['file.treetop'],
\ 'trustees': ['trustees.conf'],
@@ -554,6 +554,7 @@ let s:filename_checks = {
\ 'xml': ['/etc/blkid.tab', '/etc/blkid.tab.old', 'file.xmi', 'file.csproj', 'file.csproj.user', 'file.ui', 'file.tpm', '/etc/xdg/menus/file.menu', 'fglrxrc', 'file.xlf', 'file.xliff', 'file.xul', 'file.wsdl', 'file.wpl', 'any/etc/blkid.tab', 'any/etc/blkid.tab.old', 'any/etc/xdg/menus/file.menu'],
\ 'xmodmap': ['anyXmodmap', 'Xmodmap', 'some-Xmodmap', 'some-xmodmap', 'some-xmodmap-file', 'xmodmap', 'xmodmap-file'],
\ 'xf86conf': ['xorg.conf', 'xorg.conf-4'],
+ \ 'xpm': ['file.xpm'],
\ 'xpm2': ['file.xpm2'],
\ 'xquery': ['file.xq', 'file.xql', 'file.xqm', 'file.xquery', 'file.xqy'],
\ 'xs': ['file.xs'],
@@ -568,7 +569,6 @@ let s:filename_checks = {
\ 'zsh': ['.zprofile', '/etc/zprofile', '.zfbfmarks', 'file.zsh', '.zcompdump', '.zlogin', '.zlogout', '.zshenv', '.zshrc', '.zcompdump-file', '.zlog', '.zlog-file', '.zsh', '.zsh-file', 'any/etc/zprofile', 'zlog', 'zlog-file', 'zsh', 'zsh-file'],
\
\ 'help': [$VIMRUNTIME . '/doc/help.txt'],
- \ 'xpm': ['file.xpm'],
\ }
let s:filename_case_checks = {
@@ -918,4 +918,17 @@ func Test_m_file()
call delete('Xfile.m')
filetype off
endfunc
+
+func Test_xpm_file()
+ filetype on
+
+ call writefile(['this is XPM2'], 'file.xpm')
+ split file.xpm
+ call assert_equal('xpm2', &filetype)
+ bwipe!
+
+ call delete('file.xpm')
+ filetype off
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_findfile.vim b/src/nvim/testdir/test_findfile.vim
index 2195bf527e..d92706dbe5 100644
--- a/src/nvim/testdir/test_findfile.vim
+++ b/src/nvim/testdir/test_findfile.vim
@@ -50,7 +50,7 @@ func Test_findfile()
set path=.
call assert_equal('Xdir2/foo', findfile('foo'))
call assert_equal('', findfile('bar'))
- call assert_equal('Xdir2/foobar', findfile('foobar'))
+ call assert_equal('Xdir2/foobar', 'foobar'->findfile())
" Empty {path} 2nd argument is the same as no 2nd argument.
call assert_equal('Xdir2/foo', findfile('foo', ''))
@@ -138,7 +138,7 @@ func Test_finddir()
cd Xdir1
call assert_equal('Xdir2', finddir('Xdir2'))
- call assert_equal('', finddir('Xdir3'))
+ call assert_equal('', 'Xdir3'->finddir())
" Files should not be found (findfile() finds them).
call assert_equal('', finddir('foo'))
diff --git a/src/nvim/testdir/test_float_func.vim b/src/nvim/testdir/test_float_func.vim
index 78675d7016..1e0c75c49d 100644
--- a/src/nvim/testdir/test_float_func.vim
+++ b/src/nvim/testdir/test_float_func.vim
@@ -15,6 +15,7 @@ func Test_abs()
call assert_equal("str2float('inf')", string(abs(1.0/0.0)))
call assert_equal("str2float('inf')", string(abs(-1.0/0.0)))
call assert_equal("str2float('nan')", string(abs(0.0/0.0)))
+ call assert_equal('12', string(abs('12abc')))
call assert_equal('12', string(abs('-12abc')))
call assert_fails("call abs([])", 'E745:')
call assert_fails("call abs({})", 'E728:')
diff --git a/src/nvim/testdir/test_fnameescape.vim b/src/nvim/testdir/test_fnameescape.vim
index 0bafdc29fb..cdb96ba5ff 100644
--- a/src/nvim/testdir/test_fnameescape.vim
+++ b/src/nvim/testdir/test_fnameescape.vim
@@ -13,7 +13,7 @@ func Test_fnameescape()
let fname = 'Xemark!'
let status = v:false
try
- exe "w! " . fnameescape(fname)
+ exe "w! " . fname->fnameescape()
let status = v:true
endtry
call assert_true(status, "ExclamationMark")
diff --git a/src/nvim/testdir/test_fnamemodify.vim b/src/nvim/testdir/test_fnamemodify.vim
index fe1df8fd4a..411f7ebbb3 100644
--- a/src/nvim/testdir/test_fnamemodify.vim
+++ b/src/nvim/testdir/test_fnamemodify.vim
@@ -13,7 +13,7 @@ func Test_fnamemodify()
call assert_equal('a', fnamemodify('../testdir/a', ':.'))
call assert_equal('~/testdir/test.out', fnamemodify('test.out', ':~'))
call assert_equal('~/testdir/a', fnamemodify('../testdir/a', ':~'))
- call assert_equal('a', fnamemodify('../testdir/a', ':t'))
+ call assert_equal('a', '../testdir/a'->fnamemodify(':t'))
call assert_equal('', fnamemodify('.', ':p:t'))
call assert_equal('test.out', fnamemodify('test.out', ':p:t'))
call assert_equal('out', fnamemodify('test.out', ':p:e'))
diff --git a/src/nvim/testdir/test_fold.vim b/src/nvim/testdir/test_fold.vim
index 2cc5b47cb0..5586fe2151 100644
--- a/src/nvim/testdir/test_fold.vim
+++ b/src/nvim/testdir/test_fold.vim
@@ -88,7 +88,7 @@ func Test_indent_fold2()
setl fen fdm=marker
2
norm! >>
- let a=map(range(1,5), 'foldclosed(v:val)')
+ let a=map(range(1,5), 'v:val->foldclosed()')
call assert_equal([-1,-1,-1,4,4], a)
bw!
endfunc
@@ -132,7 +132,7 @@ func Test_indent_fold_with_read()
call assert_equal(0, foldlevel(3))
call assert_equal(0, foldlevel(4))
call assert_equal(1, foldlevel(5))
- call assert_equal(7, foldclosedend(5))
+ call assert_equal(7, 5->foldclosedend())
bwipe!
set foldmethod&
@@ -207,7 +207,7 @@ func Test_update_folds_expr_read()
%foldclose
call assert_equal(2, foldclosedend(1))
call assert_equal(0, foldlevel(3))
- call assert_equal(0, foldlevel(4))
+ call assert_equal(0, 4->foldlevel())
call assert_equal(6, foldclosedend(5))
call assert_equal(10, foldclosedend(7))
call assert_equal(14, foldclosedend(11))
@@ -663,7 +663,7 @@ func Test_fold_move()
call assert_equal(10, foldclosed(10))
call assert_equal(11, foldclosedend(10))
call assert_equal('+-- 2 lines: Line2', foldtextresult(2))
- call assert_equal('+-- 2 lines: Line8', foldtextresult(10))
+ call assert_equal('+-- 2 lines: Line8', 10->foldtextresult())
set fdm& sw& fdl&
enew!
diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim
index 366615821c..a0e9f780c6 100644
--- a/src/nvim/testdir/test_functions.vim
+++ b/src/nvim/testdir/test_functions.vim
@@ -56,6 +56,7 @@ func Test_empty()
endif
call assert_equal(0, empty(function('Test_empty')))
+ call assert_equal(0, empty(function('Test_empty', [0])))
endfunc
func Test_len()
@@ -294,7 +295,7 @@ func Test_resolve_unix()
call delete('Xlink')
silent !ln -s -f Xlink2/ Xlink1
- call assert_equal('Xlink2', resolve('Xlink1'))
+ call assert_equal('Xlink2', 'Xlink1'->resolve())
call assert_equal('Xlink2/', resolve('Xlink1/'))
call delete('Xlink1')
@@ -359,10 +360,10 @@ endfunc
func Test_pathshorten()
call assert_equal('', pathshorten(''))
call assert_equal('foo', pathshorten('foo'))
- call assert_equal('/foo', pathshorten('/foo'))
+ call assert_equal('/foo', '/foo'->pathshorten())
call assert_equal('f/', pathshorten('foo/'))
call assert_equal('f/bar', pathshorten('foo/bar'))
- call assert_equal('f/b/foobar', pathshorten('foo/bar/foobar'))
+ call assert_equal('f/b/foobar', 'foo/bar/foobar'->pathshorten())
call assert_equal('/f/b/foobar', pathshorten('/foo/bar/foobar'))
call assert_equal('.f/bar', pathshorten('.foo/bar'))
call assert_equal('~f/bar', pathshorten('~foo/bar'))
@@ -657,8 +658,8 @@ func Test_mode()
exe "normal gRabc\<C-X>\<C-L>\<F2>\<Esc>u"
call assert_equal('R-Rvc', g:current_modes)
- call assert_equal('n', mode(0))
- call assert_equal('n', mode(1))
+ call assert_equal('n', 0->mode())
+ call assert_equal('n', 1->mode())
" i_CTRL-O
exe "normal i\<C-O>:call Save_mode()\<Cr>\<Esc>"
@@ -710,6 +711,14 @@ func Test_mode()
call assert_equal('c-cv', g:current_modes)
" How to test Ex mode?
+ if has('terminal')
+ term
+ call feedkeys("\<C-W>N", 'xt')
+ call assert_equal('n', mode())
+ call assert_equal('nt', mode(1))
+ call feedkeys("aexit\<CR>", 'xt')
+ endif
+
bwipe!
iunmap <F2>
xunmap <F2>
@@ -814,7 +823,7 @@ endfunc
func Test_match_func()
call assert_equal(4, match('testing', 'ing'))
- call assert_equal(4, match('testing', 'ing', 2))
+ call assert_equal(4, 'testing'->match('ing', 2))
call assert_equal(-1, match('testing', 'ing', 5))
call assert_equal(-1, match('testing', 'ing', 8))
call assert_equal(1, match(['vim', 'testing', 'execute'], 'ing'))
@@ -823,7 +832,7 @@ endfunc
func Test_matchend()
call assert_equal(7, matchend('testing', 'ing'))
- call assert_equal(7, matchend('testing', 'ing', 2))
+ call assert_equal(7, 'testing'->matchend('ing', 2))
call assert_equal(-1, matchend('testing', 'ing', 5))
call assert_equal(-1, matchend('testing', 'ing', 8))
call assert_equal(match(['vim', 'testing', 'execute'], 'ing'), matchend(['vim', 'testing', 'execute'], 'ing'))
@@ -832,13 +841,13 @@ endfunc
func Test_matchlist()
call assert_equal(['acd', 'a', '', 'c', 'd', '', '', '', '', ''], matchlist('acd', '\(a\)\?\(b\)\?\(c\)\?\(.*\)'))
- call assert_equal(['d', '', '', '', 'd', '', '', '', '', ''], matchlist('acd', '\(a\)\?\(b\)\?\(c\)\?\(.*\)', 2))
+ call assert_equal(['d', '', '', '', 'd', '', '', '', '', ''], 'acd'->matchlist('\(a\)\?\(b\)\?\(c\)\?\(.*\)', 2))
call assert_equal([], matchlist('acd', '\(a\)\?\(b\)\?\(c\)\?\(.*\)', 4))
endfunc
func Test_matchstr()
call assert_equal('ing', matchstr('testing', 'ing'))
- call assert_equal('ing', matchstr('testing', 'ing', 2))
+ call assert_equal('ing', 'testing'->matchstr('ing', 2))
call assert_equal('', matchstr('testing', 'ing', 5))
call assert_equal('', matchstr('testing', 'ing', 8))
call assert_equal('testing', matchstr(['vim', 'testing', 'execute'], 'ing'))
@@ -847,7 +856,7 @@ endfunc
func Test_matchstrpos()
call assert_equal(['ing', 4, 7], matchstrpos('testing', 'ing'))
- call assert_equal(['ing', 4, 7], matchstrpos('testing', 'ing', 2))
+ call assert_equal(['ing', 4, 7], 'testing'->matchstrpos('ing', 2))
call assert_equal(['', -1, -1], matchstrpos('testing', 'ing', 5))
call assert_equal(['', -1, -1], matchstrpos('testing', 'ing', 8))
call assert_equal(['ing', 1, 4, 7], matchstrpos(['vim', 'testing', 'execute'], 'ing'))
@@ -868,21 +877,21 @@ Test
call assert_equal(0, nextnonblank(-1))
call assert_equal(0, nextnonblank(0))
call assert_equal(1, nextnonblank(1))
- call assert_equal(4, nextnonblank(2))
+ call assert_equal(4, 2->nextnonblank())
call assert_equal(4, nextnonblank(3))
call assert_equal(4, nextnonblank(4))
call assert_equal(6, nextnonblank(5))
call assert_equal(6, nextnonblank(6))
call assert_equal(7, nextnonblank(7))
- call assert_equal(0, nextnonblank(8))
+ call assert_equal(0, 8->nextnonblank())
call assert_equal(0, prevnonblank(-1))
call assert_equal(0, prevnonblank(0))
- call assert_equal(1, prevnonblank(1))
+ call assert_equal(1, 1->prevnonblank())
call assert_equal(1, prevnonblank(2))
call assert_equal(1, prevnonblank(3))
call assert_equal(4, prevnonblank(4))
- call assert_equal(4, prevnonblank(5))
+ call assert_equal(4, 5->prevnonblank())
call assert_equal(6, prevnonblank(6))
call assert_equal(7, prevnonblank(7))
call assert_equal(0, prevnonblank(8))
@@ -904,7 +913,7 @@ func Test_byte2line_line2byte()
call assert_equal([-1, -1, 1, 1, 2, 2, 2, 3, 3, -1],
\ map(range(-1, 8), 'v:val->byte2line()'))
call assert_equal([-1, -1, 1, 3, 6, 8, -1],
- \ map(range(-1, 5), 'line2byte(v:val)'))
+ \ map(range(-1, 5), 'v:val->line2byte()'))
set fileformat=dos
call assert_equal([-1, -1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, -1],
@@ -999,6 +1008,7 @@ func Test_count()
call assert_equal(1, count(l, 'a', 0, 1))
call assert_equal(2, count(l, 'a', 1, 1))
call assert_fails('call count(l, "a", 0, 10)', 'E684:')
+ call assert_fails('call count(l, "a", [])', 'E745:')
let d = {1: 'a', 2: 'a', 3: 'A', 4: 'b'}
call assert_equal(2, count(d, 'a'))
@@ -1026,6 +1036,8 @@ func Test_count()
call assert_equal(2, count("foo", "O", 1))
call assert_equal(2, count("fooooo", "oo"))
call assert_equal(0, count("foo", ""))
+
+ call assert_fails('call count(0, 0)', 'E712:')
endfunc
func Test_changenr()
@@ -1053,7 +1065,7 @@ func Test_filewritable()
call assert_equal(0, filewritable('Xfilewritable'))
call assert_notequal(0, setfperm('Xfilewritable', 'rw-r-----'))
- call assert_equal(1, filewritable('Xfilewritable'))
+ call assert_equal(1, 'Xfilewritable'->filewritable())
call assert_equal(0, filewritable('doesnotexist'))
@@ -1064,12 +1076,12 @@ endfunc
func Test_Executable()
if has('win32')
call assert_equal(1, executable('notepad'))
- call assert_equal(1, executable('notepad.exe'))
+ call assert_equal(1, 'notepad.exe'->executable())
call assert_equal(0, executable('notepad.exe.exe'))
call assert_equal(0, executable('shell32.dll'))
call assert_equal(0, executable('win.ini'))
elseif has('unix')
- call assert_equal(1, executable('cat'))
+ call assert_equal(1, 'cat'->executable())
call assert_equal(0, executable('nodogshere'))
" get "cat" path and remove the leading /
@@ -1078,8 +1090,7 @@ func Test_Executable()
" check that the relative path works in /
lcd /
call assert_equal(1, executable(catcmd))
- " let result = catcmd->exepath()
- let result = exepath(catcmd)
+ let result = catcmd->exepath()
" when using chroot looking for sbin/cat can return bin/cat, that is OK
if catcmd =~ '\<sbin\>' && result =~ '\<bin\>'
call assert_equal('/' .. substitute(catcmd, '\<sbin\>', 'bin', ''), result)
@@ -1124,7 +1135,7 @@ endfunc
func Test_hlexists()
call assert_equal(0, hlexists('does_not_exist'))
- " call assert_equal(0, hlexists('Number'))
+ " call assert_equal(0, 'Number'->hlexists())
call assert_equal(0, highlight_exists('does_not_exist'))
" call assert_equal(0, highlight_exists('Number'))
syntax on
@@ -1157,7 +1168,7 @@ endfunc
func Test_inputlist()
call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>1\<cr>", 'tx')
call assert_equal(1, c)
- call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>2\<cr>", 'tx')
+ call feedkeys(":let c = ['Select color:', '1. red', '2. green', '3. blue']->inputlist()\<cr>2\<cr>", 'tx')
call assert_equal(2, c)
call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', '3. blue'])\<cr>3\<cr>", 'tx')
call assert_equal(3, c)
@@ -1289,7 +1300,7 @@ func Test_trim()
call assert_fails('call trim(" vim ", " ", -1)', 'E475:')
call assert_fails('call trim(" vim ", " ", 3)', 'E475:')
- let chars = join(map(range(1, 0x20) + [0xa0], {n -> nr2char(n)}), '')
+ let chars = join(map(range(1, 0x20) + [0xa0], {n -> n->nr2char()}), '')
call assert_equal("x", trim(chars . "x" . chars))
endfunc
@@ -1303,7 +1314,7 @@ func Test_func_range_with_edit()
" is invalid in that buffer.
call writefile(['just one line'], 'Xfuncrange2')
new
- call setline(1, range(10))
+ call setline(1, 10->range())
write Xfuncrange1
call assert_fails('5,8call EditAnotherFile()', 'E16:')
@@ -1316,7 +1327,7 @@ func Test_func_exists_on_reload()
call writefile(['func ExistingFunction()', 'echo "yes"', 'endfunc'], 'Xfuncexists')
call assert_equal(0, exists('*ExistingFunction'))
source Xfuncexists
- call assert_equal(1, exists('*ExistingFunction'))
+ call assert_equal(1, '*ExistingFunction'->exists())
" Redefining a function when reloading a script is OK.
source Xfuncexists
call assert_equal(1, exists('*ExistingFunction'))
@@ -1347,7 +1358,7 @@ func Test_func_sandbox()
sandbox let F = {-> 'hello'}
call assert_equal('hello', F())
- sandbox let F = {-> execute("normal ix\<Esc>")}
+ sandbox let F = {-> "normal ix\<Esc>"->execute()}
call assert_fails('call F()', 'E48:')
unlet F
@@ -1410,7 +1421,7 @@ func Test_reg_executing_and_recording()
let g:regs = []
func TestFunc() abort
let g:regs += [reg_executing()]
- let g:typed = input('?')
+ let g:typed = '?'->input()
let g:regs += [reg_executing()]
endfunc
call feedkeys("@qy\<CR>", 'xt')
@@ -1426,6 +1437,25 @@ func Test_reg_executing_and_recording()
unlet s:reg_stat
endfunc
+func Test_inputsecret()
+ map W :call TestFunc()<CR>
+ let @q = "W"
+ let g:typed1 = ''
+ let g:typed2 = ''
+ let g:regs = []
+ func TestFunc() abort
+ let g:typed1 = '?'->inputsecret()
+ let g:typed2 = inputsecret('password: ')
+ endfunc
+ call feedkeys("@qsomething\<CR>else\<CR>", 'xt')
+ call assert_equal("something", g:typed1)
+ call assert_equal("else", g:typed2)
+ delfunc TestFunc
+ unmap W
+ unlet g:typed1
+ unlet g:typed2
+endfunc
+
func Test_getchar()
call feedkeys('a', '')
call assert_equal(char2nr('a'), getchar())
@@ -1483,17 +1513,17 @@ func Test_libcall_libcallnr()
endif
if has('win32')
- call assert_equal($USERPROFILE, libcall(libc, 'getenv', 'USERPROFILE'))
+ call assert_equal($USERPROFILE, 'USERPROFILE'->libcall(libc, 'getenv'))
else
- call assert_equal($HOME, libcall(libc, 'getenv', 'HOME'))
+ call assert_equal($HOME, 'HOME'->libcall(libc, 'getenv'))
endif
" If function returns NULL, libcall() should return an empty string.
call assert_equal('', libcall(libc, 'getenv', 'X_ENV_DOES_NOT_EXIT'))
" Test libcallnr() with string and integer argument.
- call assert_equal(4, libcallnr(libc, 'strlen', 'abcd'))
- call assert_equal(char2nr('A'), libcallnr(libc, 'toupper', char2nr('a')))
+ call assert_equal(4, 'abcd'->libcallnr(libc, 'strlen'))
+ call assert_equal(char2nr('A'), char2nr('a')->libcallnr(libc, 'toupper'))
call assert_fails("call libcall(libc, 'Xdoesnotexist_', '')", 'E364:')
call assert_fails("call libcallnr(libc, 'Xdoesnotexist_', '')", 'E364:')
@@ -1556,7 +1586,7 @@ func Test_readdir()
call assert_equal(['bar.txt', 'dir', 'foo.txt'], sort(files))
" Only results containing "f"
- let files = readdir('Xdir', { x -> stridx(x, 'f') !=- 1 })
+ let files = 'Xdir'->readdir({ x -> stridx(x, 'f') !=- 1 })
call assert_equal(['foo.txt'], sort(files))
" Only .txt files
@@ -1589,6 +1619,14 @@ func Test_call()
call assert_fails("call call('Mylen', [], 0)", 'E715:')
endfunc
+func Test_char2nr()
+ call assert_equal(12354, char2nr('あ', 1))
+endfunc
+
+func Test_eventhandler()
+ call assert_equal(0, eventhandler())
+endfunc
+
" Test for the eval() function
func Test_eval()
call assert_fails("call eval('5 a')", 'E488:')
diff --git a/src/nvim/testdir/test_getcwd.vim b/src/nvim/testdir/test_getcwd.vim
index ca098781e4..2ff396b641 100644
--- a/src/nvim/testdir/test_getcwd.vim
+++ b/src/nvim/testdir/test_getcwd.vim
@@ -17,7 +17,7 @@ func GetCwdInfo(win, tab)
let lflag = haslocaldir(a:win)
else
let dirname = fnamemodify(getcwd(a:win, a:tab), mod)
- let lflag = haslocaldir(a:win, a:tab)
+ let lflag = a:win->haslocaldir(a:tab)
endif
return bufname . ' ' . dirname . ' ' . lflag
endfunc
@@ -35,7 +35,7 @@ function SetUp()
" we start from a clean state.
call delete("Xtopdir", "rf")
new
- call mkdir('Xtopdir')
+ eval 'Xtopdir'->mkdir()
cd Xtopdir
let g:topdir = getcwd()
call mkdir('Xdir1')
diff --git a/src/nvim/testdir/test_getvar.vim b/src/nvim/testdir/test_getvar.vim
index 3b61d68ebc..5a96548893 100644
--- a/src/nvim/testdir/test_getvar.vim
+++ b/src/nvim/testdir/test_getvar.vim
@@ -12,8 +12,8 @@ func Test_var()
let def_str = "Chance"
call assert_equal('Dance', getwinvar(1, 'var_str'))
call assert_equal('Dance', getwinvar(1, 'var_str', def_str))
- call assert_equal({'var_str': 'Dance'}, getwinvar(1, ''))
- call assert_equal({'var_str': 'Dance'}, getwinvar(1, '', def_str))
+ call assert_equal({'var_str': 'Dance'}, 1->getwinvar(''))
+ call assert_equal({'var_str': 'Dance'}, 1->getwinvar('', def_str))
unlet w:var_str
call assert_equal('Chance', getwinvar(1, 'var_str', def_str))
call assert_equal({}, getwinvar(1, ''))
@@ -31,7 +31,7 @@ func Test_var()
let t:other = 777
let def_list = [4, 5, 6, 7]
tabrewind
- call assert_equal([1, 2, 3], gettabvar(3, 'var_list'))
+ call assert_equal([1, 2, 3], 3->gettabvar('var_list'))
call assert_equal([1, 2, 3], gettabvar(3, 'var_list', def_list))
call assert_equal({'var_list': [1, 2, 3], 'other': 777}, gettabvar(3, ''))
call assert_equal({'var_list': [1, 2, 3], 'other': 777},
@@ -61,7 +61,7 @@ func Test_var()
let def_dict = {'dict2': 'newval'}
wincmd b
tabrewind
- call assert_equal({'dict': 'tabwin'}, gettabwinvar(2, 3, 'var_dict'))
+ call assert_equal({'dict': 'tabwin'}, 2->gettabwinvar(3, 'var_dict'))
call assert_equal({'dict': 'tabwin'},
\ gettabwinvar(2, 3, 'var_dict', def_dict))
call assert_equal({'var_dict': {'dict': 'tabwin'}}, gettabwinvar(2, 3, ''))
diff --git a/src/nvim/testdir/test_glob2regpat.vim b/src/nvim/testdir/test_glob2regpat.vim
index 354f239ef1..a423a4a9f0 100644
--- a/src/nvim/testdir/test_glob2regpat.vim
+++ b/src/nvim/testdir/test_glob2regpat.vim
@@ -10,7 +10,7 @@ endfunc
func Test_glob2regpat_valid()
call assert_equal('^foo\.', glob2regpat('foo.*'))
- call assert_equal('^foo.$', glob2regpat('foo?'))
+ call assert_equal('^foo.$', 'foo?'->glob2regpat())
call assert_equal('\.vim$', glob2regpat('*.vim'))
call assert_equal('^[abc]$', glob2regpat('[abc]'))
call assert_equal('^foo bar$', glob2regpat('foo\ bar'))
diff --git a/src/nvim/testdir/test_history.vim b/src/nvim/testdir/test_history.vim
index 16aad9889e..2f0dc2dae1 100644
--- a/src/nvim/testdir/test_history.vim
+++ b/src/nvim/testdir/test_history.vim
@@ -13,7 +13,7 @@ function History_Tests(hist)
call assert_equal(-1, histnr(a:hist))
call assert_equal('', histget(a:hist))
- call assert_true(histadd(a:hist, 'ls'))
+ call assert_true('ls'->histadd(a:hist))
call assert_true(histadd(a:hist, 'buffers'))
call assert_equal('buffers', histget(a:hist))
call assert_equal('ls', histget(a:hist, -2))
@@ -22,14 +22,14 @@ function History_Tests(hist)
call assert_equal('', histget(a:hist, -5))
call assert_equal(2, histnr(a:hist))
call assert_true(histdel(a:hist, 2))
- call assert_false(histdel(a:hist, 7))
+ call assert_false(a:hist->histdel(7))
call assert_equal(1, histnr(a:hist))
call assert_equal('ls', histget(a:hist, -1))
call assert_true(histadd(a:hist, 'buffers'))
call assert_true(histadd(a:hist, 'ls'))
- call assert_equal('ls', histget(a:hist, -1))
- call assert_equal(4, histnr(a:hist))
+ call assert_equal('ls', a:hist->histget(-1))
+ call assert_equal(4, a:hist->histnr())
let a=execute('history ' . a:hist)
call assert_match("^\n # \\S* history\n 3 buffers\n> 4 ls$", a)
diff --git a/src/nvim/testdir/test_jumplist.vim b/src/nvim/testdir/test_jumplist.vim
index be1af5e705..9cfbbe2029 100644
--- a/src/nvim/testdir/test_jumplist.vim
+++ b/src/nvim/testdir/test_jumplist.vim
@@ -39,7 +39,7 @@ func Test_getjumplist()
" Traverse the jump list and verify the results
5
exe "normal \<C-O>"
- call assert_equal(2, getjumplist(1)[1])
+ call assert_equal(2, 1->getjumplist()[1])
exe "normal 2\<C-O>"
call assert_equal(0, getjumplist(1, 1)[1])
exe "normal 3\<C-I>"
diff --git a/src/nvim/testdir/test_lispwords.vim b/src/nvim/testdir/test_lispwords.vim
index 4c05504cf1..aa5a738bdf 100644
--- a/src/nvim/testdir/test_lispwords.vim
+++ b/src/nvim/testdir/test_lispwords.vim
@@ -43,6 +43,9 @@ func Test_lisp_indent()
\ ',@body',
\ '(princ "</a>")))'
\ ])
+ call assert_equal(7, lispindent(2))
+ call assert_equal(5, 6->lispindent())
+
set lisp
set lispwords&
let save_copt = &cpoptions
diff --git a/src/nvim/testdir/test_listdict.vim b/src/nvim/testdir/test_listdict.vim
index ae035fa519..f6c404d390 100644
--- a/src/nvim/testdir/test_listdict.vim
+++ b/src/nvim/testdir/test_listdict.vim
@@ -573,7 +573,7 @@ func Test_lockvar_script_autoload()
set rtp+=./sautest
lockvar g:footest#x
unlockvar g:footest#x
- call assert_equal(-1, islocked('g:footest#x'))
+ call assert_equal(-1, 'g:footest#x'->islocked())
call assert_equal(0, exists('g:footest#x'))
call assert_equal(1, g:footest#x)
let &rtp = old_rtp
diff --git a/src/nvim/testdir/test_maparg.vim b/src/nvim/testdir/test_maparg.vim
index 238d2f900d..5b082198cf 100644
--- a/src/nvim/testdir/test_maparg.vim
+++ b/src/nvim/testdir/test_maparg.vim
@@ -1,5 +1,6 @@
" Tests for maparg().
" Also test utf8 map with a 0x80 byte.
+" Also test mapcheck()
function s:SID()
return str2nr(matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze_SID$'))
@@ -22,7 +23,7 @@ function Test_maparg()
call assert_equal({'silent': 1, 'noremap': 1, 'script': 1, 'lhs': 'bar', 'mode': 'v',
\ 'nowait': 0, 'expr': 1, 'sid': sid, 'lnum': lnum + 2,
\ 'rhs': 'isbar', 'buffer': 1},
- \ maparg('bar', '', 0, 1))
+ \ 'bar'->maparg('', 0, 1))
let lnum = expand('<sflnum>')
map <buffer> <nowait> foo bar
call assert_equal({'silent': 0, 'noremap': 0, 'script': 0, 'lhs': 'foo', 'mode': ' ',
@@ -51,6 +52,45 @@ function Test_maparg()
unmap abc
endfunction
+func Test_mapcheck()
+ call assert_equal('', mapcheck('a'))
+ call assert_equal('', mapcheck('abc'))
+ call assert_equal('', mapcheck('ax'))
+ call assert_equal('', mapcheck('b'))
+
+ map a something
+ call assert_equal('something', mapcheck('a'))
+ call assert_equal('something', mapcheck('a', 'n'))
+ call assert_equal('', mapcheck('a', 'c'))
+ call assert_equal('', mapcheck('a', 'i'))
+ call assert_equal('something', 'abc'->mapcheck())
+ call assert_equal('something', 'ax'->mapcheck())
+ call assert_equal('', mapcheck('b'))
+ unmap a
+
+ map ab foobar
+ call assert_equal('foobar', mapcheck('a'))
+ call assert_equal('foobar', mapcheck('abc'))
+ call assert_equal('', mapcheck('ax'))
+ call assert_equal('', mapcheck('b'))
+ unmap ab
+
+ map abc barfoo
+ call assert_equal('barfoo', mapcheck('a'))
+ call assert_equal('barfoo', mapcheck('a', 'n', 0))
+ call assert_equal('', mapcheck('a', 'n', 1))
+ call assert_equal('barfoo', mapcheck('abc'))
+ call assert_equal('', mapcheck('ax'))
+ call assert_equal('', mapcheck('b'))
+ unmap abc
+
+ abbr ab abbrev
+ call assert_equal('abbrev', mapcheck('a', 'i', 1))
+ call assert_equal('', mapcheck('a', 'n', 1))
+ call assert_equal('', mapcheck('a', 'i', 0))
+ unabbr ab
+endfunc
+
function Test_range_map()
new
" Outside of the range, minimum
diff --git a/src/nvim/testdir/test_match.vim b/src/nvim/testdir/test_match.vim
index 505a052a19..70271aa32f 100644
--- a/src/nvim/testdir/test_match.vim
+++ b/src/nvim/testdir/test_match.vim
@@ -14,7 +14,7 @@ function Test_match()
2match MyGroup2 /FIXME/
3match MyGroup3 /XXX/
call assert_equal(['MyGroup1', 'TODO'], matcharg(1))
- call assert_equal(['MyGroup2', 'FIXME'], matcharg(2))
+ call assert_equal(['MyGroup2', 'FIXME'], 2->matcharg())
call assert_equal(['MyGroup3', 'XXX'], matcharg(3))
" --- Check that "matcharg()" returns an empty list if the argument is not 1,
@@ -43,7 +43,7 @@ function Test_match()
" --- Check that "matchdelete()" deletes the matches defined in the previous
" --- test correctly.
call matchdelete(m1)
- call matchdelete(m2)
+ eval m2->matchdelete()
call matchdelete(m3)
call assert_equal([], getmatches())
@@ -55,7 +55,7 @@ function Test_match()
" --- Check that "clearmatches()" clears all matches defined by ":match" and
" --- "matchadd()".
let m1 = matchadd("MyGroup1", "TODO")
- let m2 = matchadd("MyGroup2", "FIXME", 42)
+ let m2 = "MyGroup2"->matchadd("FIXME", 42)
let m3 = matchadd("MyGroup3", "XXX", 60, 17)
match MyGroup1 /COFFEE/
2match MyGroup2 /HUMPPA/
@@ -117,7 +117,7 @@ function Test_match()
call clearmatches()
call setline(1, 'abcdΣabcdef')
- call matchaddpos("MyGroup1", [[1, 4, 2], [1, 9, 2]])
+ eval "MyGroup1"->matchaddpos([[1, 4, 2], [1, 9, 2]])
1
redraw!
let v1 = screenattr(1, 1)
diff --git a/src/nvim/testdir/test_perl.vim b/src/nvim/testdir/test_perl.vim
index 872194a804..b911a982f9 100644
--- a/src/nvim/testdir/test_perl.vim
+++ b/src/nvim/testdir/test_perl.vim
@@ -32,7 +32,7 @@ endfunc
funct Test_VIM_Blob()
call assert_equal('0z', perleval('VIM::Blob("")'))
- call assert_equal('0z31326162', perleval('VIM::Blob("12ab")'))
+ call assert_equal('0z31326162', 'VIM::Blob("12ab")'->perleval())
call assert_equal('0z00010203', perleval('VIM::Blob("\x00\x01\x02\x03")'))
call assert_equal('0z8081FEFF', perleval('VIM::Blob("\x80\x81\xfe\xff")'))
endfunc
diff --git a/src/nvim/testdir/test_prompt_buffer.vim b/src/nvim/testdir/test_prompt_buffer.vim
index 6fc5850be3..3da46eb1a6 100644
--- a/src/nvim/testdir/test_prompt_buffer.vim
+++ b/src/nvim/testdir/test_prompt_buffer.vim
@@ -110,11 +110,8 @@ func Test_prompt_garbage_collect()
new
set buftype=prompt
- " Nvim doesn't support method call syntax yet.
- " eval bufnr('')->prompt_setcallback(function('MyPromptCallback', [{}]))
- " eval bufnr('')->prompt_setinterrupt(function('MyPromptInterrupt', [{}]))
- eval prompt_setcallback(bufnr(''), function('MyPromptCallback', [{}]))
- eval prompt_setinterrupt(bufnr(''), function('MyPromptInterrupt', [{}]))
+ eval bufnr('')->prompt_setcallback(function('MyPromptCallback', [{}]))
+ eval bufnr('')->prompt_setinterrupt(function('MyPromptInterrupt', [{}]))
call test_garbagecollect_now()
" Must not crash
call feedkeys("\<CR>\<C-C>", 'xt')
diff --git a/src/nvim/testdir/test_python2.vim b/src/nvim/testdir/test_python2.vim
index 5895ac85a8..ae8bc57c7f 100644
--- a/src/nvim/testdir/test_python2.vim
+++ b/src/nvim/testdir/test_python2.vim
@@ -59,7 +59,7 @@ func Test_vim_function()
try
py f = vim.Function('\x80\xfdR' + vim.eval('s:foo()'))
- call assert_equal(name, pyeval('f.name'))
+ call assert_equal(name, 'f.name'->pyeval())
catch
call assert_false(v:exception)
endtry
diff --git a/src/nvim/testdir/test_python3.vim b/src/nvim/testdir/test_python3.vim
index 637648817c..54da3d2eba 100644
--- a/src/nvim/testdir/test_python3.vim
+++ b/src/nvim/testdir/test_python3.vim
@@ -59,7 +59,7 @@ func Test_vim_function()
try
py3 f = vim.Function(b'\x80\xfdR' + vim.eval('s:foo()').encode())
- call assert_equal(name, py3eval('f.name'))
+ call assert_equal(name, 'f.name'->py3eval())
catch
call assert_false(v:exception)
endtry
diff --git a/src/nvim/testdir/test_pyx2.vim b/src/nvim/testdir/test_pyx2.vim
index 10ff3b6e58..b6ed80f842 100644
--- a/src/nvim/testdir/test_pyx2.vim
+++ b/src/nvim/testdir/test_pyx2.vim
@@ -35,7 +35,7 @@ endfunc
func Test_pyxeval()
pyx import sys
- call assert_match(s:py2pattern, split(pyxeval('sys.version'))[0])
+ call assert_match(s:py2pattern, split('sys.version'->pyxeval())[0])
endfunc
diff --git a/src/nvim/testdir/test_reltime.vim b/src/nvim/testdir/test_reltime.vim
index 2ef2fbba23..37b9e783c6 100644
--- a/src/nvim/testdir/test_reltime.vim
+++ b/src/nvim/testdir/test_reltime.vim
@@ -8,11 +8,11 @@ func Test_reltime()
let now = reltime()
sleep 10m
let later = reltime()
- let elapsed = reltime(now)
+ let elapsed = now->reltime()
call assert_true(reltimestr(elapsed) =~ '0\.0')
- call assert_true(reltimestr(elapsed) != '0.0')
+ call assert_true(elapsed->reltimestr() != '0.0')
call assert_true(reltimefloat(elapsed) < 0.1)
- call assert_true(reltimefloat(elapsed) > 0.0)
+ call assert_true(elapsed->reltimefloat() > 0.0)
let same = reltime(now, now)
call assert_equal('0.000', split(reltimestr(same))[0][:4])
diff --git a/src/nvim/testdir/test_rename.vim b/src/nvim/testdir/test_rename.vim
index 2311caf790..3887fcfabf 100644
--- a/src/nvim/testdir/test_rename.vim
+++ b/src/nvim/testdir/test_rename.vim
@@ -25,7 +25,7 @@ func Test_rename_file_ignore_case()
set fileignorecase
call writefile(['foo'], 'Xrename')
- call assert_equal(0, rename('Xrename', 'XRENAME'))
+ call assert_equal(0, 'Xrename'->rename('XRENAME'))
call assert_equal(['foo'], readfile('XRENAME'))
diff --git a/src/nvim/testdir/test_search.vim b/src/nvim/testdir/test_search.vim
index 5ba24d047c..7570049e7c 100644
--- a/src/nvim/testdir/test_search.vim
+++ b/src/nvim/testdir/test_search.vim
@@ -1338,7 +1338,7 @@ func Test_search_display_pattern()
call cursor(1, 1)
let @/ = 'foo'
- let pat = escape(@/, '()*?'. '\s\+')
+ let pat = @/->escape('()*?'. '\s\+')
let g:a = execute(':unsilent :norm! n')
call assert_match(pat, g:a)
diff --git a/src/nvim/testdir/test_stat.vim b/src/nvim/testdir/test_stat.vim
index 5b7df33d2c..170358e023 100644
--- a/src/nvim/testdir/test_stat.vim
+++ b/src/nvim/testdir/test_stat.vim
@@ -10,7 +10,7 @@ func CheckFileTime(doSleep)
let fl = ['Hello World!']
for fname in fnames
call writefile(fl, fname)
- call add(times, getftime(fname))
+ call add(times, fname->getftime())
if a:doSleep
sleep 1
endif
@@ -19,8 +19,8 @@ func CheckFileTime(doSleep)
let time_correct = (times[0] <= times[1] && times[1] <= times[2])
if a:doSleep || time_correct
call assert_true(time_correct, printf('Expected %s <= %s <= %s', times[0], times[1], times[2]))
- call assert_equal(strlen(fl[0] . "\n"), getfsize(fnames[0]))
- call assert_equal('file', getftype(fnames[0]))
+ call assert_equal(strlen(fl[0] . "\n"), fnames[0]->getfsize())
+ call assert_equal('file', fnames[0]->getftype())
call assert_equal('rw-', getfperm(fnames[0])[0:2])
let result = 1
endif
diff --git a/src/nvim/testdir/test_syn_attr.vim b/src/nvim/testdir/test_syn_attr.vim
index 353054fec8..fa0b08fde5 100644
--- a/src/nvim/testdir/test_syn_attr.vim
+++ b/src/nvim/testdir/test_syn_attr.vim
@@ -8,7 +8,7 @@ func Test_missing_attr()
call assert_equal('1', synIDattr(hlID("Mine"), "inverse", 'cterm'))
hi Mine cterm=standout gui=undercurl
call assert_equal('1', synIDattr(hlID("Mine"), "standout", 'cterm'))
- call assert_equal('1', synIDattr(hlID("Mine"), "undercurl", 'gui'))
+ call assert_equal('1', synIDattr("Mine"->hlID(), "undercurl", 'gui'))
hi Mine gui=strikethrough
call assert_equal('1', synIDattr(hlID("Mine"), "strikethrough", 'gui'))
hi Mine cterm=NONE gui=NONE
diff --git a/src/nvim/testdir/test_tagjump.vim b/src/nvim/testdir/test_tagjump.vim
index 0fa7f85f0d..15182893e9 100644
--- a/src/nvim/testdir/test_tagjump.vim
+++ b/src/nvim/testdir/test_tagjump.vim
@@ -316,7 +316,7 @@ func Test_getsettagstack()
enew | only
call settagstack(1, {'items' : []})
call assert_equal(0, gettagstack(1).length)
- call assert_equal([], gettagstack(1).items)
+ call assert_equal([], 1->gettagstack().items)
" Error cases
call assert_equal({}, gettagstack(100))
call assert_equal(-1, settagstack(100, {'items' : []}))
diff --git a/src/nvim/testdir/test_true_false.vim b/src/nvim/testdir/test_true_false.vim
index 315ba188cb..f3c7fff4a6 100644
--- a/src/nvim/testdir/test_true_false.vim
+++ b/src/nvim/testdir/test_true_false.vim
@@ -104,7 +104,7 @@ func Test_true_false_arg()
call Try_arg_true_false('maparg("asdf", "i", %v%)', "", "asdff")
call Try_arg_true_false('FilterMapArg(maparg("asdf", "i", 1, %v%))', "asdff", {'rhs': 'asdff'})
- call Try_arg_true_false('hasmapto("asdf", "i", %v%)', 0, 1)
+ call Try_arg_true_false('"asdf"->hasmapto("i", %v%)', 0, 1)
new colored
call setline(1, '<here>')
diff --git a/src/nvim/testdir/test_utf8.vim b/src/nvim/testdir/test_utf8.vim
index 735efac36d..da72da087f 100644
--- a/src/nvim/testdir/test_utf8.vim
+++ b/src/nvim/testdir/test_utf8.vim
@@ -111,7 +111,7 @@ func Test_list2str_str2list_utf8()
let s = "\u304b\u3099\u3044"
let l = [0x304b, 0x3099, 0x3044]
call assert_equal(l, str2list(s, 1))
- call assert_equal(s, list2str(l, 1))
+ call assert_equal(s, l->list2str(1))
if &enc ==# 'utf-8'
call assert_equal(str2list(s), str2list(s, 1))
call assert_equal(list2str(l), list2str(l, 1))
diff --git a/src/nvim/testdir/test_vimscript.vim b/src/nvim/testdir/test_vimscript.vim
index b18ce563d3..34733f127f 100644
--- a/src/nvim/testdir/test_vimscript.vim
+++ b/src/nvim/testdir/test_vimscript.vim
@@ -635,7 +635,7 @@ function! MSG(enr, emsg)
if v:errmsg == ""
Xout "Message missing."
else
- let v:errmsg = escape(v:errmsg, '"')
+ let v:errmsg = v:errmsg->escape('"')
Xout "Unexpected message:" v:errmsg
endif
endif
diff --git a/src/nvim/tui/input.h b/src/nvim/tui/input.h
index ed76455189..2a8ea32a88 100644
--- a/src/nvim/tui/input.h
+++ b/src/nvim/tui/input.h
@@ -2,8 +2,8 @@
#define NVIM_TUI_INPUT_H
#include <stdbool.h>
-
#include <termkey.h>
+
#include "nvim/event/stream.h"
#include "nvim/event/time.h"
diff --git a/src/nvim/tui/terminfo_defs.h b/src/nvim/tui/terminfo_defs.h
index 8d77dc7225..40261058dc 100644
--- a/src/nvim/tui/terminfo_defs.h
+++ b/src/nvim/tui/terminfo_defs.h
@@ -1,6 +1,8 @@
// This is an open source non-commercial project. Dear PVS-Studio, please check
// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
+// uncrustify:off
+
//
// Generated by scripts/update_terminfo.sh and ncurses 6.1.20180127
//
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
index 803ff23cea..612eaf6667 100644
--- a/src/nvim/tui/tui.c
+++ b/src/nvim/tui/tui.c
@@ -1019,22 +1019,8 @@ static void tui_mouse_on(UI *ui)
{
TUIData *data = ui->data;
if (!data->mouse_enabled) {
-#ifdef WIN32
- // Windows versions with vtp(ENABLE_VIRTUAL_TERMINAL_PROCESSING) and
- // no vti(ENABLE_VIRTUAL_TERMINAL_INPUT) will need to use mouse tracking of
- // libuv. For this reason, vtp (vterm) state of libuv is temporarily
- // disabled because the control sequence needs to be processed by libuv
- // instead of Windows vtp.
- // ref. https://docs.microsoft.com/en-us/windows/console/setconsolemode
- flush_buf(ui);
- os_set_vtp(false);
-#endif
unibi_out_ext(ui, data->unibi_ext.enable_mouse);
data->mouse_enabled = true;
-#ifdef WIN32
- flush_buf(ui);
- os_set_vtp(true);
-#endif
}
}
@@ -1042,22 +1028,8 @@ static void tui_mouse_off(UI *ui)
{
TUIData *data = ui->data;
if (data->mouse_enabled) {
-#ifdef WIN32
- // Windows versions with vtp(ENABLE_VIRTUAL_TERMINAL_PROCESSING) and
- // no vti(ENABLE_VIRTUAL_TERMINAL_INPUT) will need to use mouse tracking of
- // libuv. For this reason, vtp (vterm) state of libuv is temporarily
- // disabled because the control sequence needs to be processed by libuv
- // instead of Windows vtp.
- // ref. https://docs.microsoft.com/en-us/windows/console/setconsolemode
- flush_buf(ui);
- os_set_vtp(false);
-#endif
unibi_out_ext(ui, data->unibi_ext.disable_mouse);
data->mouse_enabled = false;
-#ifdef WIN32
- flush_buf(ui);
- os_set_vtp(true);
-#endif
}
}
diff --git a/src/nvim/types.h b/src/nvim/types.h
index 2dbeecbf6d..604155c33e 100644
--- a/src/nvim/types.h
+++ b/src/nvim/types.h
@@ -1,8 +1,8 @@
#ifndef NVIM_TYPES_H
#define NVIM_TYPES_H
-#include <stdint.h>
#include <stdbool.h>
+#include <stdint.h>
// dummy to pass an ACL to a function
typedef void *vim_acl_T;
diff --git a/src/nvim/ugrid.h b/src/nvim/ugrid.h
index 19c2e99ebb..ae11153c61 100644
--- a/src/nvim/ugrid.h
+++ b/src/nvim/ugrid.h
@@ -1,8 +1,8 @@
#ifndef NVIM_UGRID_H
#define NVIM_UGRID_H
-#include "nvim/ui.h"
#include "nvim/globals.h"
+#include "nvim/ui.h"
typedef struct ucell UCell;
typedef struct ugrid UGrid;
diff --git a/src/nvim/ui.h b/src/nvim/ui.h
index d00243d35f..7cc0bd9eff 100644
--- a/src/nvim/ui.h
+++ b/src/nvim/ui.h
@@ -1,12 +1,12 @@
#ifndef NVIM_UI_H
#define NVIM_UI_H
-#include <stddef.h>
#include <stdbool.h>
+#include <stddef.h>
#include <stdint.h>
-#include "nvim/globals.h"
#include "nvim/api/private/defs.h"
+#include "nvim/globals.h"
#include "nvim/highlight_defs.h"
typedef enum {
@@ -70,6 +70,7 @@ struct ui_t {
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "ui.h.generated.h"
+
# include "ui_events_call.h.generated.h"
#endif
diff --git a/src/nvim/ui_bridge.h b/src/nvim/ui_bridge.h
index dba461550f..a62ed15621 100644
--- a/src/nvim/ui_bridge.h
+++ b/src/nvim/ui_bridge.h
@@ -5,11 +5,11 @@
#include <uv.h>
-#include "nvim/ui.h"
#include "nvim/event/defs.h"
+#include "nvim/ui.h"
typedef struct ui_bridge_data UIBridgeData;
-typedef void(*ui_main_fn)(UIBridgeData *bridge, UI *ui);
+typedef void (*ui_main_fn)(UIBridgeData *bridge, UI *ui);
struct ui_bridge_data {
UI bridge; // actual UI passed to ui_attach
UI *ui; // UI pointer that will have its callback called in
diff --git a/src/nvim/ui_compositor.c b/src/nvim/ui_compositor.c
index 7a0f68cfeb..d7becb4fd4 100644
--- a/src/nvim/ui_compositor.c
+++ b/src/nvim/ui_compositor.c
@@ -89,10 +89,10 @@ void ui_comp_init(void)
void ui_comp_syn_init(void)
{
- dbghl_normal = syn_check_group((char_u *)S_LEN("RedrawDebugNormal"));
- dbghl_clear = syn_check_group((char_u *)S_LEN("RedrawDebugClear"));
- dbghl_composed = syn_check_group((char_u *)S_LEN("RedrawDebugComposed"));
- dbghl_recompose = syn_check_group((char_u *)S_LEN("RedrawDebugRecompose"));
+ dbghl_normal = syn_check_group(S_LEN("RedrawDebugNormal"));
+ dbghl_clear = syn_check_group(S_LEN("RedrawDebugClear"));
+ dbghl_composed = syn_check_group(S_LEN("RedrawDebugComposed"));
+ dbghl_recompose = syn_check_group(S_LEN("RedrawDebugRecompose"));
}
void ui_comp_attach(UI *ui)
diff --git a/src/nvim/ui_compositor.h b/src/nvim/ui_compositor.h
index 70e01c3a21..01538105cb 100644
--- a/src/nvim/ui_compositor.h
+++ b/src/nvim/ui_compositor.h
@@ -1,8 +1,8 @@
#ifndef NVIM_UI_COMPOSITOR_H
#define NVIM_UI_COMPOSITOR_H
-#include "nvim/ui.h"
#include "nvim/event/defs.h"
+#include "nvim/ui.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "ui_compositor.h.generated.h"
diff --git a/src/nvim/undo.c b/src/nvim/undo.c
index d83c2438e6..43e6325aa5 100644
--- a/src/nvim/undo.c
+++ b/src/nvim/undo.c
@@ -3083,6 +3083,8 @@ void u_undoline(void)
oldp = u_save_line(curbuf->b_u_line_lnum);
ml_replace(curbuf->b_u_line_lnum, curbuf->b_u_line_ptr, true);
changed_bytes(curbuf->b_u_line_lnum, 0);
+ extmark_splice_cols(curbuf, (int)curbuf->b_u_line_lnum-1, 0, (colnr_T)STRLEN(oldp),
+ (colnr_T)STRLEN(curbuf->b_u_line_ptr), kExtmarkUndo);
xfree(curbuf->b_u_line_ptr);
curbuf->b_u_line_ptr = oldp;
diff --git a/src/nvim/undo.h b/src/nvim/undo.h
index 802cdc5583..f494d4de86 100644
--- a/src/nvim/undo.h
+++ b/src/nvim/undo.h
@@ -1,8 +1,8 @@
#ifndef NVIM_UNDO_H
#define NVIM_UNDO_H
-#include "nvim/undo_defs.h"
#include "nvim/ex_cmds_defs.h"
+#include "nvim/undo_defs.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "undo.h.generated.h"
diff --git a/src/nvim/undo_defs.h b/src/nvim/undo_defs.h
index b46295a15d..3267b2f71e 100644
--- a/src/nvim/undo_defs.h
+++ b/src/nvim/undo_defs.h
@@ -3,32 +3,32 @@
#include <time.h> // for time_t
-#include "nvim/pos.h"
#include "nvim/extmark_defs.h"
#include "nvim/mark_defs.h"
+#include "nvim/pos.h"
typedef struct u_header u_header_T;
-/* Structure to store info about the Visual area. */
+// Structure to store info about the Visual area.
typedef struct {
- pos_T vi_start; /* start pos of last VIsual */
- pos_T vi_end; /* end position of last VIsual */
- int vi_mode; /* VIsual_mode of last VIsual */
- colnr_T vi_curswant; /* MAXCOL from w_curswant */
+ pos_T vi_start; // start pos of last VIsual
+ pos_T vi_end; // end position of last VIsual
+ int vi_mode; // VIsual_mode of last VIsual
+ colnr_T vi_curswant; // MAXCOL from w_curswant
} visualinfo_T;
#include "nvim/buffer_defs.h"
typedef struct u_entry u_entry_T;
struct u_entry {
- u_entry_T *ue_next; /* pointer to next entry in list */
- linenr_T ue_top; /* number of line above undo block */
- linenr_T ue_bot; /* number of line below undo block */
- linenr_T ue_lcount; /* linecount when u_save called */
- char_u **ue_array; /* array of lines in undo block */
- long ue_size; /* number of lines in ue_array */
+ u_entry_T *ue_next; // pointer to next entry in list
+ linenr_T ue_top; // number of line above undo block
+ linenr_T ue_bot; // number of line below undo block
+ linenr_T ue_lcount; // linecount when u_save called
+ char_u **ue_array; // array of lines in undo block
+ long ue_size; // number of lines in ue_array
#ifdef U_DEBUG
- int ue_magic; /* magic number to check allocation */
+ int ue_magic; // magic number to check allocation
#endif
};
@@ -36,26 +36,26 @@ struct u_header {
/* The following have a pointer and a number. The number is used when
* reading the undo file in u_read_undo() */
union {
- u_header_T *ptr; /* pointer to next undo header in list */
+ u_header_T *ptr; // pointer to next undo header in list
long seq;
} uh_next;
union {
- u_header_T *ptr; /* pointer to previous header in list */
+ u_header_T *ptr; // pointer to previous header in list
long seq;
} uh_prev;
union {
- u_header_T *ptr; /* pointer to next header for alt. redo */
+ u_header_T *ptr; // pointer to next header for alt. redo
long seq;
} uh_alt_next;
union {
- u_header_T *ptr; /* pointer to previous header for alt. redo */
+ u_header_T *ptr; // pointer to previous header for alt. redo
long seq;
} uh_alt_prev;
- long uh_seq; /* sequence number, higher == newer undo */
- int uh_walk; /* used by undo_time() */
- u_entry_T *uh_entry; /* pointer to first entry */
- u_entry_T *uh_getbot_entry; /* pointer to where ue_bot must be set */
- pos_T uh_cursor; /* cursor position before saving */
+ long uh_seq; // sequence number, higher == newer undo
+ int uh_walk; // used by undo_time()
+ u_entry_T *uh_entry; // pointer to first entry
+ u_entry_T *uh_getbot_entry; // pointer to where ue_bot must be set
+ pos_T uh_cursor; // cursor position before saving
long uh_cursor_vcol;
int uh_flags; // see below
fmark_T uh_namedm[NMARKS]; // marks before undo/after redo
diff --git a/src/nvim/version.c b/src/nvim/version.c
index bc06ef0b98..9e2358c9a3 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -2017,9 +2017,9 @@ void ex_version(exarg_T *eap)
/// When "wrap" is TRUE wrap the string in [].
/// @param s
/// @param wrap
-static void version_msg_wrap(char_u *s, int wrap)
+static void version_msg_wrap(char *s, int wrap)
{
- int len = vim_strsize(s) + (wrap ? 2 : 0);
+ int len = vim_strsize((char_u *)s) + (wrap ? 2 : 0);
if (!got_int
&& (len < Columns)
@@ -2032,7 +2032,7 @@ static void version_msg_wrap(char_u *s, int wrap)
if (wrap) {
msg_puts("[");
}
- msg_puts((char *)s);
+ msg_puts(s);
if (wrap) {
msg_puts("]");
}
@@ -2041,7 +2041,7 @@ static void version_msg_wrap(char_u *s, int wrap)
static void version_msg(char *s)
{
- version_msg_wrap((char_u *)s, false);
+ version_msg_wrap(s, false);
}
/// List all features.
@@ -2082,7 +2082,7 @@ void list_in_columns(char_u **items, int size, int current)
if (Columns < width) {
// Not enough screen columns - show one per line
for (i = 0; i < item_count; i++) {
- version_msg_wrap(items[i], i == current);
+ version_msg_wrap((char *)items[i], i == current);
if (msg_col > 0 && i < item_count - 1) {
msg_putchar('\n');
}
diff --git a/src/nvim/version.h b/src/nvim/version.h
index 4af038dd6c..c3c884a078 100644
--- a/src/nvim/version.h
+++ b/src/nvim/version.h
@@ -5,8 +5,8 @@
#include "nvim/macros.h"
// defined in version.c
-extern char* Version;
-extern char* longVersion;
+extern char * Version;
+extern char * longVersion;
//
// Vim version number, name, etc. Patchlevel is defined in version.c.
diff --git a/src/nvim/vim.h b/src/nvim/vim.h
index 62536a0600..7d49ca6ff1 100644
--- a/src/nvim/vim.h
+++ b/src/nvim/vim.h
@@ -1,8 +1,8 @@
#ifndef NVIM_VIM_H
#define NVIM_VIM_H
-#include "nvim/types.h"
#include "nvim/pos.h" // for linenr_T, MAXCOL, etc...
+#include "nvim/types.h"
// Some defines from the old feature.h
#define SESSION_FILE "Session.vim"
@@ -30,11 +30,10 @@ enum { NUMBUFLEN = 65 };
#define ROOT_UID 0
+#include "nvim/gettext.h"
#include "nvim/keymap.h"
#include "nvim/macros.h"
-#include "nvim/gettext.h"
-
// special attribute addition: Put message in history
#define MSG_HIST 0x1000
@@ -57,8 +56,8 @@ enum { NUMBUFLEN = 65 };
#define REPLACE_FLAG 0x40 // Replace mode flag
#define REPLACE (REPLACE_FLAG + INSERT)
-# define VREPLACE_FLAG 0x80 // Virtual-replace mode flag
-# define VREPLACE (REPLACE_FLAG + VREPLACE_FLAG + INSERT)
+#define VREPLACE_FLAG 0x80 // Virtual-replace mode flag
+#define VREPLACE (REPLACE_FLAG + VREPLACE_FLAG + INSERT)
#define LREPLACE (REPLACE_FLAG + LANGMAP)
#define NORMAL_BUSY (0x100 + NORMAL) // Normal mode, busy with a command
@@ -251,7 +250,7 @@ enum { FOLD_TEXT_LEN = 51 }; //!< buffer size for get_foldtext()
#define STRNCAT(d, s, n) strncat((char *)(d), (char *)(s), (size_t)(n))
#define STRLCAT(d, s, n) xstrlcat((char *)(d), (char *)(s), (size_t)(n))
-# define vim_strpbrk(s, cs) (char_u *)strpbrk((char *)(s), (char *)(cs))
+#define vim_strpbrk(s, cs) (char_u *)strpbrk((char *)(s), (char *)(cs))
// Character used as separated in autoload function/variable names.
#define AUTOLOAD_CHAR '#'
@@ -260,7 +259,7 @@ enum { FOLD_TEXT_LEN = 51 }; //!< buffer size for get_foldtext()
// Prefer using emsgf(), because perror() may send the output to the wrong
// destination and mess up the screen.
-#define PERROR(msg) (void) emsgf("%s: %s", msg, strerror(errno))
+#define PERROR(msg) (void)emsgf("%s: %s", msg, strerror(errno))
#define SHOWCMD_COLS 10 // columns needed by shown command
@@ -301,16 +300,16 @@ enum { FOLD_TEXT_LEN = 51 }; //!< buffer size for get_foldtext()
# define mch_msg(str) printf("%s", (str))
#endif
-#include "nvim/globals.h" // global variables and messages
#include "nvim/buffer_defs.h" // buffer and windows
#include "nvim/ex_cmds_defs.h" // Ex command defines
+#include "nvim/globals.h" // global variables and messages
// Lowest number used for window ID. Cannot have this many windows per tab.
#define LOWEST_WIN_ID 1000
// BSD is supposed to cover FreeBSD and similar systems.
#if (defined(BSD) || defined(__FreeBSD_kernel__)) \
- && (defined(S_ISCHR) || defined(S_IFCHR))
+ && (defined(S_ISCHR) || defined(S_IFCHR))
# define OPEN_CHR_FILES
#endif
diff --git a/src/nvim/viml/parser/expressions.h b/src/nvim/viml/parser/expressions.h
index 838a742271..325df643e7 100644
--- a/src/nvim/viml/parser/expressions.h
+++ b/src/nvim/viml/parser/expressions.h
@@ -1,13 +1,13 @@
#ifndef NVIM_VIML_PARSER_EXPRESSIONS_H
#define NVIM_VIML_PARSER_EXPRESSIONS_H
+#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
-#include <stdbool.h>
+#include "nvim/eval/typval.h"
#include "nvim/types.h"
#include "nvim/viml/parser/parser.h"
-#include "nvim/eval/typval.h"
// Defines whether to ignore case:
// == kCCStrategyUseOption
@@ -80,7 +80,7 @@ typedef enum {
} ExprAssignmentType;
#define EXPR_OPT_SCOPE_LIST \
- ((char[]){ kExprOptScopeGlobal, kExprOptScopeLocal })
+ ((char[]){ kExprOptScopeGlobal, kExprOptScopeLocal })
/// All possible variable scopes
typedef enum {
@@ -96,11 +96,11 @@ typedef enum {
} ExprVarScope;
#define EXPR_VAR_SCOPE_LIST \
- ((char[]) { \
- kExprVarScopeScript, kExprVarScopeGlobal, kExprVarScopeVim, \
- kExprVarScopeBuffer, kExprVarScopeWindow, kExprVarScopeTabpage, \
- kExprVarScopeLocal, kExprVarScopeBuffer, kExprVarScopeArguments, \
- })
+ ((char[]) { \
+ kExprVarScopeScript, kExprVarScopeGlobal, kExprVarScopeVim, \
+ kExprVarScopeBuffer, kExprVarScopeWindow, kExprVarScopeTabpage, \
+ kExprVarScopeLocal, kExprVarScopeBuffer, kExprVarScopeArguments, \
+ })
/// Lexer token
typedef struct {
diff --git a/src/nvim/viml/parser/parser.h b/src/nvim/viml/parser/parser.h
index 7ac49709d8..b2933c3781 100644
--- a/src/nvim/viml/parser/parser.h
+++ b/src/nvim/viml/parser/parser.h
@@ -1,12 +1,12 @@
#ifndef NVIM_VIML_PARSER_PARSER_H
#define NVIM_VIML_PARSER_PARSER_H
+#include <assert.h>
#include <stdbool.h>
#include <stddef.h>
-#include <assert.h>
-#include "nvim/lib/kvec.h"
#include "nvim/func_attr.h"
+#include "nvim/lib/kvec.h"
#include "nvim/mbyte.h"
#include "nvim/memory.h"
@@ -82,9 +82,9 @@ typedef struct {
} ParserState;
static inline void viml_parser_init(
- ParserState *const ret_pstate,
- const ParserLineGetter get_line, void *const cookie,
- ParserHighlight *const colors)
+ ParserState *const ret_pstate,
+ const ParserLineGetter get_line, void *const cookie,
+ ParserHighlight *const colors)
REAL_FATTR_ALWAYS_INLINE REAL_FATTR_NONNULL_ARG(1, 2);
/// Initialize a new parser state instance
@@ -94,10 +94,8 @@ static inline void viml_parser_init(
/// @param[in] cookie Argument for the get_line function.
/// @param[in] colors Where to save highlighting. May be NULL if it is not
/// needed.
-static inline void viml_parser_init(
- ParserState *const ret_pstate,
- const ParserLineGetter get_line, void *const cookie,
- ParserHighlight *const colors)
+static inline void viml_parser_init(ParserState *const ret_pstate, const ParserLineGetter get_line,
+ void *const cookie, ParserHighlight *const colors)
{
*ret_pstate = (ParserState) {
.reader = {
@@ -194,8 +192,7 @@ static inline void viml_parser_advance(ParserState *const pstate,
///
/// @param pstate Parser state to advance.
/// @param[in] len Number of bytes to advance.
-static inline void viml_parser_advance(ParserState *const pstate,
- const size_t len)
+static inline void viml_parser_advance(ParserState *const pstate, const size_t len)
{
assert(pstate->pos.line == kv_size(pstate->reader.lines) - 1);
const ParserLine pline = kv_last(pstate->reader.lines);
@@ -219,10 +216,8 @@ static inline void viml_parser_highlight(ParserState *const pstate,
/// @param[in] start Start position of the highlight.
/// @param[in] len Highlighting chunk length.
/// @param[in] group Highlight group.
-static inline void viml_parser_highlight(ParserState *const pstate,
- const ParserPosition start,
- const size_t len,
- const char *const group)
+static inline void viml_parser_highlight(ParserState *const pstate, const ParserPosition start,
+ const size_t len, const char *const group)
{
if (pstate->colors == NULL || len == 0) {
return;
@@ -231,9 +226,9 @@ static inline void viml_parser_highlight(ParserState *const pstate,
|| kv_Z(*pstate->colors, 0).start.line < start.line
|| kv_Z(*pstate->colors, 0).end_col <= start.col);
kvi_push(*pstate->colors, ((ParserHighlightChunk) {
- .start = start,
- .end_col = start.col + len,
- .group = group,
+ .start = start,
+ .end_col = start.col + len,
+ .group = group,
}));
}
diff --git a/src/nvim/window.c b/src/nvim/window.c
index 0a242c2795..5d43c5d284 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -6693,7 +6693,7 @@ int match_add(win_T *wp, const char *const grp, const char *const pat, int prio,
cur = cur->next;
}
}
- if ((hlg_id = syn_check_group((const char_u *)grp, strlen(grp))) == 0) {
+ if ((hlg_id = syn_check_group(grp, strlen(grp))) == 0) {
return -1;
}
if (pat != NULL && (regprog = vim_regcomp((char_u *)pat, RE_MAGIC)) == NULL) {
diff --git a/src/nvim/window.h b/src/nvim/window.h
index 82b3fe5e88..7e465a9f08 100644
--- a/src/nvim/window.h
+++ b/src/nvim/window.h
@@ -5,11 +5,11 @@
#include "nvim/buffer_defs.h"
-/* Values for file_name_in_line() */
-#define FNAME_MESS 1 /* give error message */
-#define FNAME_EXP 2 /* expand to path */
-#define FNAME_HYP 4 /* check for hypertext link */
-#define FNAME_INCL 8 /* apply 'includeexpr' */
+// Values for file_name_in_line()
+#define FNAME_MESS 1 // give error message
+#define FNAME_EXP 2 // expand to path
+#define FNAME_HYP 4 // check for hypertext link
+#define FNAME_INCL 8 // apply 'includeexpr'
#define FNAME_REL 16 /* ".." and "./" are relative to the (current)
file instead of the current directory */
#define FNAME_UNESC 32 // remove backslashes used for escaping
@@ -17,20 +17,20 @@
/*
* arguments for win_split()
*/
-#define WSP_ROOM 1 /* require enough room */
-#define WSP_VERT 2 /* split vertically */
-#define WSP_TOP 4 /* window at top-left of shell */
-#define WSP_BOT 8 /* window at bottom-right of shell */
-#define WSP_HELP 16 /* creating the help window */
-#define WSP_BELOW 32 /* put new window below/right */
-#define WSP_ABOVE 64 /* put new window above/left */
-#define WSP_NEWLOC 128 /* don't copy location list */
+#define WSP_ROOM 1 // require enough room
+#define WSP_VERT 2 // split vertically
+#define WSP_TOP 4 // window at top-left of shell
+#define WSP_BOT 8 // window at bottom-right of shell
+#define WSP_HELP 16 // creating the help window
+#define WSP_BELOW 32 // put new window below/right
+#define WSP_ABOVE 64 // put new window above/left
+#define WSP_NEWLOC 128 // don't copy location list
/*
* Minimum screen size
*/
-#define MIN_COLUMNS 12 /* minimal columns for screen */
-#define MIN_LINES 2 /* minimal lines for screen */
+#define MIN_COLUMNS 12 // minimal columns for screen
+#define MIN_LINES 2 // minimal lines for screen
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "window.h.generated.h"
diff --git a/src/uncrustify.cfg b/src/uncrustify.cfg
index db0c50ff22..7dbaec7d67 100644
--- a/src/uncrustify.cfg
+++ b/src/uncrustify.cfg
@@ -1,4 +1,4 @@
-# Uncrustify-0.73.0-195-1f883c691
+# Uncrustify-0.73.0-199-0dfafb27
#
# General options
@@ -44,12 +44,12 @@ disable_processing_nl_cont = false # true/false
# file.
#
# Default: *INDENT-OFF*
-disable_processing_cmt = "uncrustify:indent-off" # string
+disable_processing_cmt = "uncrustify:off" # string
# Specify the marker used in comments to (re)enable processing in a file.
#
# Default: *INDENT-ON*
-enable_processing_cmt = "uncrustify:indent-on" # string
+enable_processing_cmt = "uncrustify:on" # string
# Enable parsing of digraphs.
enable_digraphs = false # true/false
@@ -472,9 +472,13 @@ sp_after_class_colon = ignore # ignore/add/remove/force/not_defined
sp_before_class_colon = ignore # ignore/add/remove/force/not_defined
# Add or remove space after class constructor ':'.
+#
+# Default: add
sp_after_constr_colon = ignore # ignore/add/remove/force/not_defined
# Add or remove space before class constructor ':'.
+#
+# Default: add
sp_before_constr_colon = ignore # ignore/add/remove/force/not_defined
# Add or remove space before case ':'.
@@ -1103,11 +1107,16 @@ indent_class_on_colon = false # true/false
# Whether to indent the stuff after a leading class initializer colon.
indent_constr_colon = false # true/false
-# Virtual indent from the ':' for member initializers.
+# Virtual indent from the ':' for leading member initializers.
#
# Default: 2
indent_ctor_init_leading = 2 # unsigned number
+# Virtual indent from the ':' for following member initializers.
+#
+# Default: 2
+indent_ctor_init_following = 2 # unsigned number
+
# Additional indent for constructor initializer list.
# Negative values decrease indent down to the first column.
indent_ctor_init = 0 # number
@@ -3298,5 +3307,5 @@ set QUESTION REAL_FATTR_CONST
set QUESTION REAL_FATTR_NONNULL_ALL
set QUESTION REAL_FATTR_PURE
set QUESTION REAL_FATTR_WARN_UNUSED_RESULT
-# option(s) with 'not default' value: 62
+# option(s) with 'not default' value: 64
#
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index 6b644ed519..d8914a3ab7 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -91,6 +91,14 @@ describe('API', function()
nvim('exec', 'set nowrap', false)
eq('nowrap\n\tLast set from anonymous :source',
nvim('exec', 'verbose set wrap?', true))
+
+ -- Using script var to force creation of a script item
+ nvim('exec', [[
+ let s:a = 1
+ set nowrap
+ ]], false)
+ eq('nowrap\n\tLast set from anonymous :source (script id 1)',
+ nvim('exec', 'verbose set wrap?', true))
end)
it('multiline input', function()
@@ -132,6 +140,43 @@ describe('API', function()
-- try no spaces before continuations to catch off-by-one error
nvim('exec', 'let ab = #{\n\\a: 98,\n"\\ b: 2\n\\}', false)
eq({a = 98}, request('nvim_eval', 'g:ab'))
+
+ -- Script scope (s:)
+ eq('ahoy! script-scoped varrrrr', nvim('exec', [[
+ let s:pirate = 'script-scoped varrrrr'
+ function! s:avast_ye_hades(s) abort
+ return a:s .. ' ' .. s:pirate
+ endfunction
+ echo <sid>avast_ye_hades('ahoy!')
+ ]], true))
+
+ eq('ahoy! script-scoped varrrrr', nvim('exec', [[
+ let s:pirate = 'script-scoped varrrrr'
+ function! Avast_ye_hades(s) abort
+ return a:s .. ' ' .. s:pirate
+ endfunction
+ echo nvim_exec('echo Avast_ye_hades(''ahoy!'')', 1)
+ ]], true))
+
+ eq('Vim(call):E5555: API call: Vim(echo):E121: Undefined variable: s:pirate',
+ pcall_err(request, 'nvim_exec', [[
+ let s:pirate = 'script-scoped varrrrr'
+ call nvim_exec('echo s:pirate', 1)
+ ]], false))
+
+ -- Script items are created only on script var access
+ eq('1\n0', nvim('exec', [[
+ echo expand("<SID>")->empty()
+ let s:a = 123
+ echo expand("<SID>")->empty()
+ ]], true))
+
+ eq('1\n0', nvim('exec', [[
+ echo expand("<SID>")->empty()
+ function s:a() abort
+ endfunction
+ echo expand("<SID>")->empty()
+ ]], true))
end)
it('non-ASCII input', function()
diff --git a/test/functional/ex_cmds/source_spec.lua b/test/functional/ex_cmds/source_spec.lua
index bdf6ae76d1..fa650d611b 100644
--- a/test/functional/ex_cmds/source_spec.lua
+++ b/test/functional/ex_cmds/source_spec.lua
@@ -25,12 +25,19 @@ describe(':source', function()
let b = #{
\ k: "v"
"\ (o_o)
- \ }]])
+ \ }
+ let c = expand("<SID>")->empty()
+ let s:s = 0zbeef.cafe
+ let d = s:s]])
command('source')
eq('2', meths.exec('echo a', true))
eq("{'k': 'v'}", meths.exec('echo b', true))
+ -- Script items are created only on script var access
+ eq("1", meths.exec('echo c', true))
+ eq("0zBEEFCAFE", meths.exec('echo d', true))
+
exec('set cpoptions+=C')
eq('Vim(let):E15: Invalid expression: #{', exc_exec('source'))
end)
@@ -43,7 +50,11 @@ describe(':source', function()
let b = #{
"\ (>_<)
\ K: "V"
- \ }]])
+ \ }
+ function! s:C() abort
+ return expand("<SID>") .. "C()"
+ endfunction
+ let D = {-> s:C()}]])
-- Source the 2nd line only
feed('ggjV')
@@ -55,6 +66,11 @@ describe(':source', function()
feed_command(':source')
eq('4', meths.exec('echo a', true))
eq("{'K': 'V'}", meths.exec('echo b', true))
+ eq("<SNR>1_C()", meths.exec('echo D()', true))
+
+ -- Source last line only
+ feed_command(':$source')
+ eq('Vim(echo):E117: Unknown function: s:C', exc_exec('echo D()'))
exec('set cpoptions+=C')
eq('Vim(let):E15: Invalid expression: #{', exc_exec("'<,'>source"))
diff --git a/test/functional/fixtures/fake-lsp-server.lua b/test/functional/fixtures/fake-lsp-server.lua
index 8e03d9a46e..9abf478070 100644
--- a/test/functional/fixtures/fake-lsp-server.lua
+++ b/test/functional/fixtures/fake-lsp-server.lua
@@ -246,6 +246,35 @@ function tests.capabilities_for_client_supports_method()
}
end
+function tests.check_forward_request_cancelled()
+ skeleton {
+ on_init = function(_)
+ return { capabilities = {} }
+ end;
+ body = function()
+ expect_request("error_code_test", function()
+ return {code = -32800}, nil, {method = "error_code_test", client_id=1}
+ end)
+ notify('finish')
+ end;
+ }
+end
+
+function tests.check_forward_content_modified()
+ skeleton {
+ on_init = function(_)
+ return { capabilities = {} }
+ end;
+ body = function()
+ expect_request("error_code_test", function()
+ return {code = -32801}, nil, {method = "error_code_test", client_id=1}
+ end)
+ expect_notification('finish')
+ notify('finish')
+ end;
+ }
+end
+
function tests.basic_finish()
skeleton {
on_init = function(params)
diff --git a/test/functional/legacy/delete_spec.lua b/test/functional/legacy/delete_spec.lua
index f2ced8942d..141d9583e6 100644
--- a/test/functional/legacy/delete_spec.lua
+++ b/test/functional/legacy/delete_spec.lua
@@ -1,6 +1,7 @@
local helpers = require('test.functional.helpers')(after_each)
local clear, source = helpers.clear, helpers.source
local eq, eval, command = helpers.eq, helpers.eval, helpers.command
+local exc_exec = helpers.exc_exec
describe('Test for delete()', function()
before_each(clear)
@@ -38,7 +39,7 @@ describe('Test for delete()', function()
eq(eval("['a', 'b']"), eval("readfile('Xdir1/Xfile')"))
eq(1, eval("isdirectory('Xdir1/subdir')"))
eq(eval("['a', 'b']"), eval("readfile('Xdir1/subdir/Xfile')"))
- eq(1, eval("isdirectory('Xdir1/empty')"))
+ eq(1, eval("'Xdir1/empty'->isdirectory()"))
eq(0, eval("delete('Xdir1', 'rf')"))
eq(0, eval("isdirectory('Xdir1')"))
eq(-1, eval("delete('Xdir1', 'd')"))
@@ -114,4 +115,10 @@ describe('Test for delete()', function()
eq(0, eval("delete('Xdir4/Xfile')"))
eq(0, eval("delete('Xdir4', 'd')"))
end)
+
+ it('gives correct emsgs', function()
+ eq('Vim(call):E474: Invalid argument', exc_exec("call delete('')"))
+ eq('Vim(call):E15: Invalid expression: 0',
+ exc_exec("call delete('foo', 0)"))
+ end)
end)
diff --git a/test/functional/legacy/expand_spec.lua b/test/functional/legacy/expand_spec.lua
index f238128b31..cd3713eabe 100644
--- a/test/functional/legacy/expand_spec.lua
+++ b/test/functional/legacy/expand_spec.lua
@@ -81,7 +81,7 @@ describe('expand file name', function()
call assert_equal('e Xfile1', expandcmd('e %'))
edit Xfile2
edit Xfile1
- call assert_equal('e Xfile2', expandcmd('e #'))
+ call assert_equal('e Xfile2', 'e #'->expandcmd())
edit Xfile2
edit Xfile3
edit Xfile4
diff --git a/test/functional/legacy/file_perm_spec.lua b/test/functional/legacy/file_perm_spec.lua
index 8fdee95e91..ccdbfe0534 100644
--- a/test/functional/legacy/file_perm_spec.lua
+++ b/test/functional/legacy/file_perm_spec.lua
@@ -3,7 +3,7 @@ require('os')
local helpers = require('test.functional.helpers')(after_each)
local clear, call, eq = helpers.clear, helpers.call, helpers.eq
-local neq, exc_exec = helpers.neq, helpers.exc_exec
+local neq, exc_exec, eval = helpers.neq, helpers.exc_exec, helpers.eval
describe('Test getting and setting file permissions', function()
local tempfile = helpers.tmpname()
@@ -14,11 +14,12 @@ describe('Test getting and setting file permissions', function()
end)
it('file permissions', function()
+ -- eval() is used to test VimL method syntax for setfperm() and getfperm()
eq('', call('getfperm', tempfile))
- eq(0, call('setfperm', tempfile, 'r--------'))
+ eq(0, eval("'" .. tempfile .. "'->setfperm('r--------')"))
call('writefile', {'one'}, tempfile)
- eq(9, call('len', call('getfperm', tempfile)))
+ eq(9, eval("len('" .. tempfile .. "'->getfperm())"))
eq(1, call('setfperm', tempfile, 'rwx------'))
if helpers.is_os('win') then
diff --git a/test/functional/legacy/fnamemodify_spec.lua b/test/functional/legacy/fnamemodify_spec.lua
index 7e859bf0cf..6a5538c26f 100644
--- a/test/functional/legacy/fnamemodify_spec.lua
+++ b/test/functional/legacy/fnamemodify_spec.lua
@@ -60,12 +60,6 @@ describe('filename modifiers', function()
call assert_equal("'abc\\\ndef'", fnamemodify("abc\ndef", ':S'))
endif
endfunc
-
- func Test_expand()
- new
- call assert_equal("", expand('%:S'))
- quit
- endfunc
]=])
end)
@@ -73,9 +67,4 @@ describe('filename modifiers', function()
call('Test_fnamemodify')
expected_empty()
end)
-
- it('works for :S in an unnamed buffer', function()
- call('Test_expand')
- expected_empty()
- end)
end)
diff --git a/test/functional/lua/api_spec.lua b/test/functional/lua/api_spec.lua
index fdf79d55b2..8551c3d2a0 100644
--- a/test/functional/lua/api_spec.lua
+++ b/test/functional/lua/api_spec.lua
@@ -194,6 +194,10 @@ describe('luaeval(vim.api.…)', function()
exc_exec([[call luaeval("vim.api.nvim__id_dictionary(1)")]]))
eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Unexpected type',
exc_exec([[call luaeval("vim.api.nvim__id_dictionary({[vim.type_idx]=vim.types.array})")]]))
+
+ eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Expected lua table',
+ exc_exec([[call luaeval("vim.api.nvim_set_keymap('', '', '', '')")]]))
+
-- TODO: check for errors with Tabpage argument
-- TODO: check for errors with Window argument
-- TODO: check for errors with Buffer argument
diff --git a/test/functional/lua/buffer_updates_spec.lua b/test/functional/lua/buffer_updates_spec.lua
index 073927bf22..c83a50b78b 100644
--- a/test/functional/lua/buffer_updates_spec.lua
+++ b/test/functional/lua/buffer_updates_spec.lua
@@ -1050,6 +1050,102 @@ describe('lua: nvim_buf_attach on_bytes', function()
}
end)
+ it("sends updates on U", function()
+ feed("ggiAAA<cr>BBB")
+ feed("<esc>gg$a CCC")
+
+ local check_events = setup_eventcheck(verify, nil)
+
+ feed("ggU")
+
+ check_events {
+ { "test1", "bytes", 1, 6, 0, 7, 7, 0, 0, 0, 0, 3, 3 };
+ }
+ end)
+
+ it("delete in completely empty buffer", function()
+ local check_events = setup_eventcheck(verify, nil)
+
+ command "delete"
+ check_events { }
+ end)
+
+ it("delete the only line of a buffer", function()
+ local check_events = setup_eventcheck(verify, {"AAA"})
+
+ command "delete"
+ check_events {
+ { "test1", "bytes", 1, 3, 0, 0, 0, 1, 0, 4, 1, 0, 1 };
+ }
+ end)
+
+ it("delete the last line of a buffer with two lines", function()
+ local check_events = setup_eventcheck(verify, {"AAA", "BBB"})
+
+ command "2delete"
+ check_events {
+ { "test1", "bytes", 1, 3, 1, 0, 4, 1, 0, 4, 0, 0, 0 };
+ }
+ end)
+
+ it(":sort lines", function()
+ local check_events = setup_eventcheck(verify, {"CCC", "BBB", "AAA"})
+
+ command "%sort"
+ check_events {
+ { "test1", "bytes", 1, 3, 0, 0, 0, 3, 0, 12, 3, 0, 12 };
+ }
+ end)
+
+ it("handles already sorted lines", function()
+ local check_events = setup_eventcheck(verify, {"AAA", "BBB", "CCC"})
+
+ command "%sort"
+ check_events { }
+ end)
+
+ local function test_lockmarks(mode)
+ local description = (mode ~= "") and mode or "(baseline)"
+ it("test_lockmarks " .. description .. " %delete _", function()
+ local check_events = setup_eventcheck(verify, {"AAA", "BBB", "CCC"})
+
+ command(mode .. " %delete _")
+ check_events {
+ { "test1", "bytes", 1, 3, 0, 0, 0, 3, 0, 12, 1, 0, 1 };
+ }
+ end)
+
+ it("test_lockmarks " .. description .. " append()", function()
+ local check_events = setup_eventcheck(verify)
+
+ command(mode .. " call append(0, 'CCC')")
+ check_events {
+ { "test1", "bytes", 1, 2, 0, 0, 0, 0, 0, 0, 1, 0, 4 };
+ }
+
+ command(mode .. " call append(1, 'BBBB')")
+ check_events {
+ { "test1", "bytes", 1, 3, 1, 0, 4, 0, 0, 0, 1, 0, 5 };
+ }
+
+ command(mode .. " call append(2, '')")
+ check_events {
+ { "test1", "bytes", 1, 4, 2, 0, 9, 0, 0, 0, 1, 0, 1 };
+ }
+
+ command(mode .. " $delete _")
+ check_events {
+ { "test1", "bytes", 1, 5, 3, 0, 10, 1, 0, 1, 0, 0, 0 };
+ }
+
+ eq("CCC|BBBB|", table.concat(meths.buf_get_lines(0, 0, -1, true), "|"))
+ end)
+ end
+
+ -- check that behavior is identical with and without "lockmarks"
+ test_lockmarks ""
+ test_lockmarks "lockmarks"
+
teardown(function()
os.remove "Xtest-reload"
os.remove "Xtest-undofile"
diff --git a/test/functional/lua/diagnostic_spec.lua b/test/functional/lua/diagnostic_spec.lua
index 45aa4915cd..33469597a1 100644
--- a/test/functional/lua/diagnostic_spec.lua
+++ b/test/functional/lua/diagnostic_spec.lua
@@ -473,6 +473,78 @@ describe('vim.diagnostic', function()
end)
describe('config()', function()
+ it('works with global, namespace, and ephemeral options', function()
+ eq(1, exec_lua [[
+ vim.diagnostic.config({
+ virtual_text = false,
+ })
+
+ vim.diagnostic.config({
+ virtual_text = true,
+ underline = false,
+ }, diagnostic_ns)
+
+ vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, {
+ make_error('Some Error', 4, 4, 4, 4),
+ })
+
+ return count_extmarks(diagnostic_bufnr, diagnostic_ns)
+ ]])
+
+ eq(1, exec_lua [[
+ vim.diagnostic.config({
+ virtual_text = false,
+ })
+
+ vim.diagnostic.config({
+ virtual_text = false,
+ underline = false,
+ }, diagnostic_ns)
+
+ vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, {
+ make_error('Some Error', 4, 4, 4, 4),
+ }, {virtual_text = true})
+
+ return count_extmarks(diagnostic_bufnr, diagnostic_ns)
+ ]])
+
+ eq(0, exec_lua [[
+ vim.diagnostic.config({
+ virtual_text = false,
+ })
+
+ vim.diagnostic.config({
+ virtual_text = {severity=vim.diagnostic.severity.ERROR},
+ underline = false,
+ }, diagnostic_ns)
+
+ vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, {
+ make_warning('Some Warning', 4, 4, 4, 4),
+ }, {virtual_text = true})
+
+ return count_extmarks(diagnostic_bufnr, diagnostic_ns)
+ ]])
+
+ eq(1, exec_lua [[
+ vim.diagnostic.config({
+ virtual_text = false,
+ })
+
+ vim.diagnostic.config({
+ virtual_text = {severity=vim.diagnostic.severity.ERROR},
+ underline = false,
+ }, diagnostic_ns)
+
+ vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, {
+ make_warning('Some Warning', 4, 4, 4, 4),
+ }, {
+ virtual_text = {} -- An empty table uses default values
+ })
+
+ return count_extmarks(diagnostic_bufnr, diagnostic_ns)
+ ]])
+ end)
+
it('can use functions for config values', function()
exec_lua [[
vim.diagnostic.config({
@@ -1013,6 +1085,44 @@ describe('vim.diagnostic', function()
return lines
]])
end)
+
+ it('respects severity_sort', function()
+ exec_lua [[vim.api.nvim_win_set_buf(0, diagnostic_bufnr)]]
+
+ eq({"1. Syntax error", "2. Info", "3. Error", "4. Warning"}, exec_lua [[
+ local diagnostics = {
+ make_error("Syntax error", 0, 1, 0, 3),
+ make_info('Info', 0, 3, 0, 4),
+ make_error('Error', 0, 2, 0, 2),
+ make_warning('Warning', 0, 0, 0, 1),
+ }
+
+ vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, diagnostics)
+
+ vim.diagnostic.config({severity_sort = false})
+
+ local popup_bufnr, winnr = vim.diagnostic.show_line_diagnostics { show_header = false }
+ local lines = vim.api.nvim_buf_get_lines(popup_bufnr, 0, -1, false)
+ vim.api.nvim_win_close(winnr, true)
+ return lines
+ ]])
+
+ eq({"1. Syntax error", "2. Error", "3. Warning", "4. Info"}, exec_lua [[
+ vim.diagnostic.config({severity_sort = true})
+ local popup_bufnr, winnr = vim.diagnostic.show_line_diagnostics { show_header = false }
+ local lines = vim.api.nvim_buf_get_lines(popup_bufnr, 0, -1, false)
+ vim.api.nvim_win_close(winnr, true)
+ return lines
+ ]])
+
+ eq({"1. Info", "2. Warning", "3. Error", "4. Syntax error"}, exec_lua [[
+ vim.diagnostic.config({severity_sort = { reverse = true } })
+ local popup_bufnr, winnr = vim.diagnostic.show_line_diagnostics { show_header = false }
+ local lines = vim.api.nvim_buf_get_lines(popup_bufnr, 0, -1, false)
+ vim.api.nvim_win_close(winnr, true)
+ return lines
+ ]])
+ end)
end)
describe('setloclist()', function()
diff --git a/test/functional/lua/luaeval_spec.lua b/test/functional/lua/luaeval_spec.lua
index 255e99032f..0675ec9abd 100644
--- a/test/functional/lua/luaeval_spec.lua
+++ b/test/functional/lua/luaeval_spec.lua
@@ -86,14 +86,15 @@ describe('luaeval()', function()
-- meaningful later.
it('correctly evaluates scalars', function()
+ -- Also test method call (->) syntax
eq(1, funcs.luaeval('1'))
- eq(0, eval('type(luaeval("1"))'))
+ eq(0, eval('"1"->luaeval()->type()'))
eq(1.5, funcs.luaeval('1.5'))
- eq(5, eval('type(luaeval("1.5"))'))
+ eq(5, eval('"1.5"->luaeval()->type()'))
eq("test", funcs.luaeval('"test"'))
- eq(1, eval('type(luaeval("\'test\'"))'))
+ eq(1, eval('"\'test\'"->luaeval()->type()'))
eq('', funcs.luaeval('""'))
eq('\000', funcs.luaeval([['\0']]))
diff --git a/test/functional/lua/uri_spec.lua b/test/functional/lua/uri_spec.lua
index 052a8a1ecd..81f1820986 100644
--- a/test/functional/lua/uri_spec.lua
+++ b/test/functional/lua/uri_spec.lua
@@ -2,6 +2,7 @@ local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local exec_lua = helpers.exec_lua
local eq = helpers.eq
+local write_file = require('test.helpers').write_file
describe('URI methods', function()
before_each(function()
@@ -158,6 +159,22 @@ describe('URI methods', function()
end)
+ describe('uri from bufnr', function()
+ it('Windows paths should not be treated as uris', function()
+ if not helpers.iswin() then return end
+
+ local file = helpers.tmpname()
+ write_file(file, 'Test content')
+ local test_case = string.format([[
+ local file = '%s'
+ return vim.uri_from_bufnr(vim.fn.bufadd(file))
+ ]], file)
+ local expected_uri = 'file:///' .. file:gsub("\\", "/")
+ eq(expected_uri, exec_lua(test_case))
+ os.remove(file)
+ end)
+ end)
+
describe('uri to bufnr', function()
it('uri_to_bufnr & uri_from_bufnr returns original uri for non-file uris', function()
local uri = 'jdt://contents/java.base/java.util/List.class?=sql/%5C/home%5C/user%5C/.jabba%5C/jdk%5C/openjdk%5C@1.14.0%5C/lib%5C/jrt-fs.jar%60java.base=/javadoc_location=/https:%5C/%5C/docs.oracle.com%5C/en%5C/java%5C/javase%5C/14%5C/docs%5C/api%5C/=/%3Cjava.util(List.class'
diff --git a/test/functional/plugin/health_spec.lua b/test/functional/plugin/health_spec.lua
index 45fcf945f4..b84e9d1533 100644
--- a/test/functional/plugin/health_spec.lua
+++ b/test/functional/plugin/health_spec.lua
@@ -208,12 +208,12 @@ describe('health.vim', function()
^ |
{Heading:foo: } |
{Bar:========================================================================}|
- {Bullet: -} {Error:ERROR:} No healthcheck found for "foo" plugin. |
+ {Bullet: -} {Error:ERROR}: No healthcheck found for "foo" plugin. |
|
{Heading:success1: health#success1#check} |
{Bar:========================================================================}|
{Heading2:##}{Heading: report 1} |
- {Bullet: -} {Ok:OK:} everything is fine |
+ {Bullet: -} {Ok:OK}: everything is fine |
|
]]}
end)
diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua
index 8f9b194690..81ef8a9733 100644
--- a/test/functional/plugin/lsp_spec.lua
+++ b/test/functional/plugin/lsp_spec.lua
@@ -405,7 +405,7 @@ describe('LSP', function()
}
end)
- it('should call unsupported_method when trying to call an unsupported method', function()
+ it('should not call unsupported_method when trying to call an unsupported method', function()
local expected_handlers = {
{NIL, {}, {method="shutdown", client_id=1}};
}
@@ -415,24 +415,12 @@ describe('LSP', function()
exec_lua([=[
BUFFER = vim.api.nvim_get_current_buf()
lsp.buf_attach_client(BUFFER, TEST_RPC_CLIENT_ID)
- vim.lsp.handlers['textDocument/typeDefinition'] = function(err, result, ctx)
- local method = ctx.method
- vim.lsp._last_lsp_handler = { err = err; method = method }
- end
- vim.lsp._unsupported_method = function(method)
- vim.lsp._last_unsupported_method = method
- return 'fake-error'
- end
- vim.lsp.buf.type_definition()
+ vim.lsp.handlers['textDocument/typeDefinition'] = function() end
]=])
end;
on_init = function(client)
client.stop()
- local method = exec_lua("return vim.lsp._last_unsupported_method")
- eq("textDocument/typeDefinition", method)
- local lsp_cb_call = exec_lua("return vim.lsp._last_lsp_handler")
- eq("fake-error", lsp_cb_call.err)
- eq("textDocument/typeDefinition", lsp_cb_call.method)
+ exec_lua("vim.lsp.buf.type_definition()")
exec_lua [[
vim.api.nvim_command(BUFFER.."bwipeout")
]]
@@ -447,7 +435,7 @@ describe('LSP', function()
}
end)
- it('shouldn\'t call unsupported_method when no client and trying to call an unsupported method', function()
+ it('should not call unsupported_method when no client and trying to call an unsupported method', function()
local expected_handlers = {
{NIL, {}, {method="shutdown", client_id=1}};
}
@@ -455,20 +443,12 @@ describe('LSP', function()
test_name = "capabilities_for_client_supports_method";
on_setup = function()
exec_lua([=[
- vim.lsp.handlers['textDocument/typeDefinition'] = function(err, method)
- vim.lsp._last_lsp_handler = { err = err; method = method }
- end
- vim.lsp._unsupported_method = function(method)
- vim.lsp._last_unsupported_method = method
- return 'fake-error'
- end
- vim.lsp.buf.type_definition()
+ vim.lsp.handlers['textDocument/typeDefinition'] = function() end
]=])
end;
on_init = function(client)
client.stop()
- eq(NIL, exec_lua("return vim.lsp._last_unsupported_method"))
- eq(NIL, exec_lua("return vim.lsp._last_lsp_handler"))
+ exec_lua("vim.lsp.buf.type_definition()")
end;
on_exit = function(code, signal)
eq(0, code, "exit code", fake_lsp_logfile)
@@ -480,6 +460,55 @@ describe('LSP', function()
}
end)
+ it('should not forward RequestCancelled to callback', function()
+ local expected_handlers = {
+ {NIL, {}, {method="finish", client_id=1}};
+ }
+ local client
+ test_rpc_server {
+ test_name = "check_forward_request_cancelled";
+ on_init = function(_client)
+ _client.request("error_code_test")
+ client = _client
+ end;
+ on_exit = function(code, signal)
+ eq(0, code, "exit code", fake_lsp_logfile)
+ eq(0, signal, "exit signal", fake_lsp_logfile)
+ eq(0, #expected_handlers, "did not call expected handler")
+ end;
+ on_handler = function(err, _, ctx)
+ eq(table.remove(expected_handlers), {err, {}, ctx}, "expected handler")
+ if ctx.method == 'finish' then client.stop() end
+ end;
+ }
+ end)
+
+ it('should forward ContentModified to callback', function()
+ local expected_handlers = {
+ {NIL, {}, {method="finish", client_id=1}};
+ {{code = -32801}, NIL, {method = "error_code_test", client_id=1}};
+ }
+ local client
+ test_rpc_server {
+ test_name = "check_forward_content_modified";
+ on_init = function(_client)
+ _client.request("error_code_test")
+ client = _client
+ end;
+ on_exit = function(code, signal)
+ eq(0, code, "exit code", fake_lsp_logfile)
+ eq(0, signal, "exit signal", fake_lsp_logfile)
+ eq(0, #expected_handlers, "did not call expected handler")
+ end;
+ on_handler = function(err, _, ctx)
+ eq(table.remove(expected_handlers), {err, _, ctx}, "expected handler")
+ -- if ctx.method == 'error_code_test' then client.notify("finish") end
+ if ctx.method ~= 'finish' then client.notify('finish') end
+ if ctx.method == 'finish' then client.stop() end
+ end;
+ }
+ end)
+
it('should not send didOpen if the buffer closes before init', function()
local expected_handlers = {
{NIL, {}, {method="shutdown", client_id=1}};
diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua
index 103ae59b8e..7dcca231ee 100644
--- a/test/functional/terminal/buffer_spec.lua
+++ b/test/functional/terminal/buffer_spec.lua
@@ -22,14 +22,28 @@ describe(':terminal buffer', function()
it('terminal-mode forces various options', function()
feed([[<C-\><C-N>]])
- command('setlocal cursorline cursorcolumn scrolloff=4 sidescrolloff=7')
- eq({ 1, 1, 4, 7 }, eval('[&l:cursorline, &l:cursorcolumn, &l:scrolloff, &l:sidescrolloff]'))
- eq('n', eval('mode()'))
+ command('setlocal cursorline cursorlineopt=both cursorcolumn scrolloff=4 sidescrolloff=7')
+ eq({ 'both', 1, 1, 4, 7 }, eval('[&l:cursorlineopt, &l:cursorline, &l:cursorcolumn, &l:scrolloff, &l:sidescrolloff]'))
+ eq('nt', eval('mode(1)'))
-- Enter terminal-mode ("insert" mode in :terminal).
feed('i')
- eq('t', eval('mode()'))
- eq({ 0, 0, 0, 0 }, eval('[&l:cursorline, &l:cursorcolumn, &l:scrolloff, &l:sidescrolloff]'))
+ eq('t', eval('mode(1)'))
+ eq({ 'number', 1, 0, 0, 0 }, eval('[&l:cursorlineopt, &l:cursorline, &l:cursorcolumn, &l:scrolloff, &l:sidescrolloff]'))
+ end)
+
+ it('terminal-mode does not change cursorlineopt if cursorline is disabled', function()
+ feed([[<C-\><C-N>]])
+ command('setlocal nocursorline cursorlineopt=both')
+ feed('i')
+ eq({ 0, 'both' }, eval('[&l:cursorline, &l:cursorlineopt]'))
+ end)
+
+ it('terminal-mode disables cursorline when cursorlineopt is only set to "line', function()
+ feed([[<C-\><C-N>]])
+ command('setlocal cursorline cursorlineopt=line')
+ feed('i')
+ eq({ 0, 'line' }, eval('[&l:cursorline, &l:cursorlineopt]'))
end)
describe('when a new file is edited', function()
diff --git a/test/functional/terminal/ex_terminal_spec.lua b/test/functional/terminal/ex_terminal_spec.lua
index 707c355069..065dd72485 100644
--- a/test/functional/terminal/ex_terminal_spec.lua
+++ b/test/functional/terminal/ex_terminal_spec.lua
@@ -96,19 +96,28 @@ describe(':terminal', function()
eq(3, #jumps)
end)
+ it('nvim_get_mode() in :terminal', function()
+ command(':terminal')
+ eq({ blocking=false, mode='nt' }, nvim('get_mode'))
+ feed('i')
+ eq({ blocking=false, mode='t' }, nvim('get_mode'))
+ feed([[<C-\><C-N>]])
+ eq({ blocking=false, mode='nt' }, nvim('get_mode'))
+ end)
+
it(':stopinsert RPC request exits terminal-mode #7807', function()
command(':terminal')
feed('i[tui] insert-mode')
eq({ blocking=false, mode='t' }, nvim('get_mode'))
command('stopinsert')
- eq({ blocking=false, mode='n' }, nvim('get_mode'))
+ eq({ blocking=false, mode='nt' }, nvim('get_mode'))
end)
it(':stopinsert in normal mode doesn\'t break insert mode #9889', function()
command(':terminal')
- eq({ blocking=false, mode='n' }, nvim('get_mode'))
+ eq({ blocking=false, mode='nt' }, nvim('get_mode'))
command(':stopinsert')
- eq({ blocking=false, mode='n' }, nvim('get_mode'))
+ eq({ blocking=false, mode='nt' }, nvim('get_mode'))
feed('a')
eq({ blocking=false, mode='t' }, nvim('get_mode'))
end)
diff --git a/test/functional/terminal/mouse_spec.lua b/test/functional/terminal/mouse_spec.lua
index 0eb5901b3b..3d8441b93c 100644
--- a/test/functional/terminal/mouse_spec.lua
+++ b/test/functional/terminal/mouse_spec.lua
@@ -33,16 +33,16 @@ describe(':terminal mouse', function()
describe('when the terminal has focus', function()
it('will exit focus on mouse-scroll', function()
- eq('t', eval('mode()'))
+ eq('t', eval('mode(1)'))
feed('<ScrollWheelUp><0,0>')
- eq('n', eval('mode()'))
+ eq('nt', eval('mode(1)'))
end)
it('will exit focus on <C-\\> + mouse-scroll', function()
- eq('t', eval('mode()'))
+ eq('t', eval('mode(1)'))
feed('<C-\\>')
feed('<ScrollWheelUp><0,0>')
- eq('n', eval('mode()'))
+ eq('nt', eval('mode(1)'))
end)
describe('with mouse events enabled by the program', function()
@@ -94,7 +94,7 @@ describe(':terminal mouse', function()
-- When the display area such as a number is clicked, it returns to the
-- normal mode.
feed('<LeftMouse><3,0>')
- eq('n', eval('mode()'))
+ eq('nt', eval('mode(1)'))
screen:expect([[
{7: 11 }^line28 |
{7: 12 }line29 |
diff --git a/test/functional/terminal/window_split_tab_spec.lua b/test/functional/terminal/window_split_tab_spec.lua
index 188afa1e84..c92107082e 100644
--- a/test/functional/terminal/window_split_tab_spec.lua
+++ b/test/functional/terminal/window_split_tab_spec.lua
@@ -111,7 +111,7 @@ describe(':terminal', function()
command('terminal')
feed('a<Cmd>wincmd j<CR>')
eq(2, eval("winnr()"))
- eq('t', eval('mode()'))
+ eq('t', eval('mode(1)'))
end)
end)
diff --git a/test/functional/vimscript/json_functions_spec.lua b/test/functional/vimscript/json_functions_spec.lua
index c3b607b544..5d1597f53d 100644
--- a/test/functional/vimscript/json_functions_spec.lua
+++ b/test/functional/vimscript/json_functions_spec.lua
@@ -168,7 +168,8 @@ describe('json_decode() function', function()
end)
it('parses floating-point numbers', function()
- eq('100000.0', eval('string(json_decode("100000.0"))'))
+ -- Also test method call (->) syntax
+ eq('100000.0', eval('"100000.0"->json_decode()->string()'))
eq(100000.5, funcs.json_decode('100000.5'))
eq(-100000.5, funcs.json_decode('-100000.5'))
eq(-100000.5e50, funcs.json_decode('-100000.5e50'))
@@ -549,11 +550,12 @@ describe('json_encode() function', function()
end)
it('dumps floats', function()
- eq('0.0', eval('json_encode(0.0)'))
+ -- Also test method call (->) syntax
+ eq('0.0', eval('0.0->json_encode()'))
eq('10.5', funcs.json_encode(10.5))
eq('-10.5', funcs.json_encode(-10.5))
eq('-1.0e-5', funcs.json_encode(-1e-5))
- eq('1.0e50', eval('json_encode(1.0e50)'))
+ eq('1.0e50', eval('1.0e50->json_encode()'))
end)
it('fails to dump NaN and infinite values', function()
diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt
index 12e429da24..29ff0daa8d 100644
--- a/third-party/CMakeLists.txt
+++ b/third-party/CMakeLists.txt
@@ -203,8 +203,8 @@ set(LIBICONV_SHA256 ccf536620a45458d26ba83887a983b96827001e92a13847b45e4925cc891
set(TREESITTER_C_URL https://github.com/tree-sitter/tree-sitter-c/archive/5aa0bbb.tar.gz)
set(TREESITTER_C_SHA256 a5dcb37460d83002dfae7f9a208170ddbc9a047f231b9d6b75da7d36d707db2f)
-set(TREESITTER_URL https://github.com/tree-sitter/tree-sitter/archive/v0.20.0.tar.gz)
-set(TREESITTER_SHA256 4a8070b9de17c3b8096181fe8530320ab3e8cca685d8bee6a3e8d164b5fb47da)
+set(TREESITTER_URL https://github.com/tree-sitter/tree-sitter/archive/7890a29db0b186b7b21a0a95d99fa6c562b8316b.tar.gz)
+set(TREESITTER_SHA256 634006b0336a5eef1b07d2f80a4d4f8ac1522bf15759ec3e5dda0032a734fb19)
if(USE_BUNDLED_UNIBILIUM)
include(BuildUnibilium)