aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.asan-blacklist1
-rw-r--r--.gitignore5
-rw-r--r--BACKERS.md2
-rw-r--r--CMakeLists.txt130
-rw-r--r--CONTRIBUTING.md9
-rw-r--r--Makefile7
-rw-r--r--README.md14
-rwxr-xr-xclint.py257
-rw-r--r--cmake/FindLibUV.cmake21
-rw-r--r--cmake/FindLuaJit.cmake2
-rw-r--r--cmake/GenerateHelptags.cmake.in2
-rw-r--r--cmake/GetGitRevisionDescription.cmake8
-rw-r--r--cmake/RunTestsLint.cmake11
-rw-r--r--config/CMakeLists.txt5
-rw-r--r--config/config.h.in3
-rw-r--r--config/versiondef.h.in5
-rw-r--r--contrib/YouCompleteMe/README.md4
-rw-r--r--contrib/local.mk.example15
-rw-r--r--man/nvim.150
-rw-r--r--runtime/CMakeLists.txt2
-rw-r--r--runtime/autoload/getscript.vim667
-rw-r--r--runtime/autoload/msgpack.vim820
-rw-r--r--runtime/autoload/provider/python.vim2
-rw-r--r--runtime/autoload/provider/python3.vim2
-rw-r--r--runtime/autoload/remote/host.vim17
-rw-r--r--runtime/autoload/shada.vim696
-rw-r--r--runtime/autoload/spellfile.vim8
-rw-r--r--runtime/autoload/tutor.vim7
-rw-r--r--runtime/doc/Makefile2
-rw-r--r--runtime/doc/arabic.txt26
-rw-r--r--runtime/doc/autocmd.txt38
-rw-r--r--runtime/doc/cmdline.txt8
-rw-r--r--runtime/doc/debug.txt2
-rw-r--r--runtime/doc/develop.txt254
-rw-r--r--runtime/doc/diff.txt2
-rw-r--r--runtime/doc/editing.txt4
-rw-r--r--runtime/doc/eval.txt82
-rw-r--r--runtime/doc/farsi.txt9
-rw-r--r--runtime/doc/filetype.txt170
-rw-r--r--runtime/doc/fold.txt4
-rw-r--r--runtime/doc/ft_ada.txt2
-rw-r--r--runtime/doc/ft_sql.txt25
-rw-r--r--runtime/doc/gui.txt32
-rw-r--r--runtime/doc/gui_w32.txt2
-rw-r--r--runtime/doc/help.txt4
-rw-r--r--runtime/doc/helphelp.txt2
-rw-r--r--runtime/doc/if_cscop.txt16
-rw-r--r--runtime/doc/indent.txt10
-rw-r--r--runtime/doc/index.txt3
-rw-r--r--runtime/doc/insert.txt42
-rw-r--r--runtime/doc/map.txt4
-rw-r--r--runtime/doc/mbyte.txt6
-rw-r--r--runtime/doc/message.txt2
-rw-r--r--runtime/doc/mlang.txt2
-rw-r--r--runtime/doc/motion.txt9
-rw-r--r--runtime/doc/nvim_from_vim.txt5
-rw-r--r--runtime/doc/nvim_python.txt3
-rw-r--r--runtime/doc/nvim_terminal_emulator.txt15
-rw-r--r--runtime/doc/options.txt244
-rw-r--r--runtime/doc/os_mac.txt116
-rw-r--r--runtime/doc/os_unix.txt57
-rw-r--r--runtime/doc/pi_getscript.txt482
-rw-r--r--runtime/doc/pi_msgpack.txt139
-rw-r--r--runtime/doc/pi_spec.txt6
-rw-r--r--runtime/doc/print.txt12
-rw-r--r--runtime/doc/quickfix.txt2
-rw-r--r--runtime/doc/quickref.txt5
-rw-r--r--runtime/doc/quotes.txt2
-rw-r--r--runtime/doc/recover.txt2
-rw-r--r--runtime/doc/remote_plugin.txt5
-rw-r--r--runtime/doc/repeat.txt12
-rw-r--r--runtime/doc/spell.txt16
-rw-r--r--runtime/doc/starting.txt117
-rw-r--r--runtime/doc/syntax.txt119
-rw-r--r--runtime/doc/term.txt2
-rw-r--r--runtime/doc/tips.txt4
-rw-r--r--runtime/doc/todo.txt4903
-rw-r--r--runtime/doc/usr_01.txt5
-rw-r--r--runtime/doc/usr_03.txt2
-rw-r--r--runtime/doc/usr_05.txt60
-rw-r--r--runtime/doc/usr_06.txt10
-rw-r--r--runtime/doc/usr_21.txt40
-rw-r--r--runtime/doc/usr_30.txt6
-rw-r--r--runtime/doc/usr_31.txt2
-rw-r--r--runtime/doc/usr_40.txt2
-rw-r--r--runtime/doc/usr_41.txt18
-rw-r--r--runtime/doc/usr_42.txt2
-rw-r--r--runtime/doc/usr_43.txt25
-rw-r--r--runtime/doc/usr_44.txt6
-rw-r--r--runtime/doc/usr_45.txt4
-rw-r--r--runtime/doc/various.txt6
-rw-r--r--runtime/doc/vi_diff.txt550
-rw-r--r--runtime/doc/vim_diff.txt18
-rw-r--r--runtime/doc/windows.txt22
-rw-r--r--runtime/filetype.vim7
-rw-r--r--runtime/ftplugin/kconfig.vim13
-rw-r--r--runtime/ftplugin/shada.vim18
-rw-r--r--runtime/ftplugin/spec.vim32
-rw-r--r--runtime/ftplugin/tutor.vim3
-rw-r--r--runtime/ftplugin/zsh.vim9
-rw-r--r--runtime/indent/javascript.vim6
-rw-r--r--runtime/indent/zsh.vim9
-rw-r--r--runtime/optwin.vim7
-rw-r--r--runtime/plugin/getscriptPlugin.vim41
-rw-r--r--runtime/plugin/shada.vim39
-rw-r--r--runtime/syntax/cpp.vim2
-rw-r--r--runtime/syntax/css.vim127
-rw-r--r--runtime/syntax/debchangelog.vim15
-rw-r--r--runtime/syntax/debcontrol.vim4
-rw-r--r--runtime/syntax/debsources.vim34
-rw-r--r--runtime/syntax/groovy.vim2
-rw-r--r--runtime/syntax/kconfig.vim7
-rw-r--r--runtime/syntax/po.vim8
-rw-r--r--runtime/syntax/rc.vim9
-rw-r--r--runtime/syntax/shada.vim125
-rw-r--r--runtime/syntax/vhdl.vim49
-rw-r--r--runtime/syntax/vim.vim2
-rw-r--r--runtime/syntax/zsh.vim189
-rw-r--r--runtime/tutor/en/vim-01-beginner.tutor13
-rwxr-xr-xscripts/shadacat.py23
-rwxr-xr-xscripts/vim-patch.sh4
-rw-r--r--src/nvim/README.md190
-rw-r--r--src/nvim/api/buffer.c1
-rw-r--r--src/nvim/ascii.h7
-rw-r--r--src/nvim/auevents.lua9
-rw-r--r--src/nvim/buffer.c1019
-rw-r--r--src/nvim/buffer_defs.h1
-rw-r--r--src/nvim/diff.c1
-rw-r--r--src/nvim/edit.c1814
-rw-r--r--src/nvim/eval.c578
-rw-r--r--src/nvim/eval.h44
-rw-r--r--src/nvim/eval_defs.h4
-rw-r--r--src/nvim/event/socket.c2
-rw-r--r--src/nvim/event/stream.c2
-rw-r--r--src/nvim/ex_cmds.c16
-rw-r--r--src/nvim/ex_cmds.lua34
-rw-r--r--src/nvim/ex_cmds2.c104
-rw-r--r--src/nvim/ex_cmds_defs.h6
-rw-r--r--src/nvim/ex_docmd.c75
-rw-r--r--src/nvim/ex_eval.c8
-rw-r--r--src/nvim/ex_getln.c2581
-rw-r--r--src/nvim/file_search.c1
-rw-r--r--src/nvim/fileio.c59
-rw-r--r--src/nvim/fold.c9
-rw-r--r--src/nvim/getchar.c10
-rw-r--r--src/nvim/globals.h62
-rw-r--r--src/nvim/hardcopy.c9
-rw-r--r--src/nvim/if_cscope.c3
-rw-r--r--src/nvim/keymap.c5
-rw-r--r--src/nvim/keymap.h9
-rw-r--r--src/nvim/log.c2
-rw-r--r--src/nvim/log.h2
-rw-r--r--src/nvim/macros.h11
-rw-r--r--src/nvim/main.c448
-rw-r--r--src/nvim/mark.c38
-rw-r--r--src/nvim/mbyte.c10
-rw-r--r--src/nvim/memfile.c9
-rw-r--r--src/nvim/memline.c139
-rw-r--r--src/nvim/memline_defs.h2
-rw-r--r--src/nvim/memory.c3
-rw-r--r--src/nvim/menu.c10
-rw-r--r--src/nvim/message.c9
-rw-r--r--src/nvim/misc1.c10
-rw-r--r--src/nvim/misc2.c11
-rw-r--r--src/nvim/move.c7
-rw-r--r--src/nvim/normal.c1500
-rw-r--r--src/nvim/normal.h4
-rw-r--r--src/nvim/ops.c12
-rw-r--r--src/nvim/option.c452
-rw-r--r--src/nvim/option_defs.h1
-rw-r--r--src/nvim/options.lua27
-rw-r--r--src/nvim/os/env.c101
-rw-r--r--src/nvim/os/fs.c44
-rw-r--r--src/nvim/os/fs_defs.h4
-rw-r--r--src/nvim/os/input.c42
-rw-r--r--src/nvim/os/os.h2
-rw-r--r--src/nvim/os/os_defs.h30
-rw-r--r--src/nvim/os/shell.c3
-rw-r--r--src/nvim/os/signal.c12
-rw-r--r--src/nvim/os/stdpaths.c108
-rw-r--r--src/nvim/os/stdpaths_defs.h14
-rw-r--r--src/nvim/os/unix_defs.h53
-rw-r--r--src/nvim/os/win_defs.h17
-rw-r--r--src/nvim/os_unix.c8
-rw-r--r--src/nvim/path.c64
-rw-r--r--src/nvim/po/CMakeLists.txt2
-rw-r--r--src/nvim/popupmnu.c2
-rw-r--r--src/nvim/quickfix.c9
-rw-r--r--src/nvim/regexp_nfa.c9
-rw-r--r--src/nvim/screen.c9
-rw-r--r--src/nvim/search.c28
-rw-r--r--src/nvim/shada.c374
-rw-r--r--src/nvim/spell.c7
-rw-r--r--src/nvim/state.c62
-rw-r--r--src/nvim/state.h20
-rw-r--r--src/nvim/strings.c2
-rw-r--r--src/nvim/syntax.c9
-rw-r--r--src/nvim/tag.c9
-rw-r--r--src/nvim/terminal.c168
-rw-r--r--src/nvim/terminal.h9
-rw-r--r--src/nvim/testdir/test49.vim2
-rw-r--r--src/nvim/testdir/test53.in4
-rw-r--r--src/nvim/testdir/test53.ok1
-rw-r--r--src/nvim/testdir/unix.vim3
-rw-r--r--src/nvim/tui/input.c32
-rw-r--r--src/nvim/tui/tui.c35
-rw-r--r--src/nvim/types.h7
-rw-r--r--src/nvim/ui_bridge.c19
-rw-r--r--src/nvim/ui_bridge.h4
-rw-r--r--src/nvim/undo.c247
-rw-r--r--src/nvim/version.c194
-rw-r--r--src/nvim/version.h1
-rw-r--r--src/nvim/vim.h7
-rw-r--r--src/nvim/window.c9
-rw-r--r--test/.luacheckrc13
-rw-r--r--test/benchmark/bench_re_freeze_spec.lua2
-rw-r--r--test/functional/api/menu_spec.lua2
-rw-r--r--test/functional/api/server_requests_spec.lua6
-rw-r--r--test/functional/api/vim_spec.lua20
-rw-r--r--test/functional/api/window_spec.lua8
-rw-r--r--test/functional/autocmd/tabclose_spec.lua5
-rw-r--r--test/functional/autocmd/tabnew_spec.lua6
-rw-r--r--test/functional/autocmd/tabnewentered_spec.lua6
-rw-r--r--test/functional/autocmd/termclose_spec.lua28
-rw-r--r--test/functional/clipboard/clipboard_provider_spec.lua1
-rw-r--r--test/functional/dict_notifications_spec.lua257
-rw-r--r--test/functional/eval/glob_spec.lua1
-rw-r--r--test/functional/eval/msgpack_functions_spec.lua12
-rw-r--r--test/functional/ex_cmds/grep_spec.lua5
-rw-r--r--test/functional/ex_cmds/oldfiles_spec.lua94
-rw-r--r--test/functional/ex_cmds/profile_spec.lua51
-rw-r--r--test/functional/ex_cmds/quit_spec.lua2
-rw-r--r--test/functional/ex_cmds/recover_spec.lua7
-rw-r--r--test/functional/ex_cmds/sign_spec.lua4
-rw-r--r--test/functional/ex_cmds/wundo_spec.lua17
-rw-r--r--test/functional/ex_cmds/wviminfo_spec.lua6
-rw-r--r--test/functional/helpers.lua25
-rw-r--r--test/functional/job/job_spec.lua12
-rw-r--r--test/functional/legacy/003_cindent_spec.lua2
-rw-r--r--test/functional/legacy/009_bufleave_autocommand_spec.lua2
-rw-r--r--test/functional/legacy/015_alignment_spec.lua2
-rw-r--r--test/functional/legacy/022_line_ending_spec.lua2
-rw-r--r--test/functional/legacy/023_edit_arguments_spec.lua2
-rw-r--r--test/functional/legacy/026_execute_while_if_spec.lua2
-rw-r--r--test/functional/legacy/027_expand_file_names_spec.lua6
-rw-r--r--test/functional/legacy/029_join_spec.lua2
-rw-r--r--test/functional/legacy/031_close_commands_spec.lua2
-rw-r--r--test/functional/legacy/038_virtual_replace_spec.lua2
-rw-r--r--test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua2
-rw-r--r--test/functional/legacy/046_multi_line_regexps_spec.lua2
-rw-r--r--test/functional/legacy/051_highlight_spec.lua2
-rw-r--r--test/functional/legacy/056_script_local_function_spec.lua2
-rw-r--r--test/functional/legacy/060_exists_and_has_functions_spec.lua4
-rw-r--r--test/functional/legacy/061_undo_tree_spec.lua9
-rw-r--r--test/functional/legacy/063_match_and_matchadd_spec.lua9
-rw-r--r--test/functional/legacy/065_float_and_logic_operators_spec.lua2
-rw-r--r--test/functional/legacy/067_augroup_exists_spec.lua2
-rw-r--r--test/functional/legacy/072_undo_file_spec.lua4
-rw-r--r--test/functional/legacy/074_global_var_in_viminfo_spec.lua2
-rw-r--r--test/functional/legacy/075_maparg_spec.lua2
-rw-r--r--test/functional/legacy/077_mf_hash_grow_spec.lua2
-rw-r--r--test/functional/legacy/078_swapfile_recover_spec.lua6
-rw-r--r--test/functional/legacy/080_substitute_spec.lua2
-rw-r--r--test/functional/legacy/082_string_comparison_spec.lua2
-rw-r--r--test/functional/legacy/084_curswant_spec.lua4
-rw-r--r--test/functional/legacy/089_number_relnumber_findfile_spec.lua2
-rw-r--r--test/functional/legacy/090_sha256_spec.lua4
-rw-r--r--test/functional/legacy/091_context_variables_spec.lua4
-rw-r--r--test/functional/legacy/092_mksession_cursor_cols_utf8_spec.lua2
-rw-r--r--test/functional/legacy/093_mksession_cursor_cols_latin1_spec.lua2
-rw-r--r--test/functional/legacy/095_regexp_multibyte_spec.lua4
-rw-r--r--test/functional/legacy/096_location_list_spec.lua2
-rw-r--r--test/functional/legacy/097_glob_path_spec.lua2
-rw-r--r--test/functional/legacy/098_scrollbind_spec.lua4
-rw-r--r--test/functional/legacy/100_undo_level_spec.lua4
-rw-r--r--test/functional/legacy/101_hlsearch_spec.lua3
-rw-r--r--test/functional/legacy/102_fnameescape_spec.lua2
-rw-r--r--test/functional/legacy/103_visual_mode_reset_spec.lua4
-rw-r--r--test/functional/legacy/105_filename_modifiers_spec.lua2
-rw-r--r--test/functional/legacy/106_errorformat_spec.lua2
-rw-r--r--test/functional/legacy/107_adjust_window_and_contents_spec.lua4
-rw-r--r--test/functional/legacy/autocmd_option_spec.lua277
-rw-r--r--test/functional/legacy/fixeol_spec.lua72
-rw-r--r--test/functional/legacy/listlbr_utf8_spec.lua4
-rw-r--r--test/functional/legacy/mapping_spec.lua28
-rw-r--r--test/functional/legacy/nested_function_spec.lua2
-rw-r--r--test/functional/legacy/qf_title_spec.lua4
-rw-r--r--test/functional/legacy/signs_spec.lua1
-rw-r--r--test/functional/legacy/writefile_spec.lua1
-rw-r--r--test/functional/normal/K_spec.lua5
-rw-r--r--test/functional/plugin/helpers.lua41
-rw-r--r--test/functional/plugin/msgpack_spec.lua699
-rw-r--r--test/functional/plugin/shada_spec.lua2850
-rw-r--r--test/functional/provider/define_spec.lua70
-rw-r--r--test/functional/provider/python3_spec.lua1
-rw-r--r--test/functional/provider/python_spec.lua1
-rw-r--r--test/functional/server/server_spec.lua3
-rw-r--r--test/functional/shada/buffers_spec.lua47
-rw-r--r--test/functional/shada/compatibility_spec.lua15
-rw-r--r--test/functional/shada/errors_spec.lua5
-rw-r--r--test/functional/shada/helpers.lua14
-rw-r--r--test/functional/shada/history_spec.lua22
-rw-r--r--test/functional/shada/marks_spec.lua20
-rw-r--r--test/functional/shada/merging_spec.lua10
-rw-r--r--test/functional/shell/viml_system_spec.lua4
-rw-r--r--test/functional/terminal/altscreen_spec.lua1
-rw-r--r--test/functional/terminal/buffer_spec.lua1
-rw-r--r--test/functional/terminal/cursor_spec.lua2
-rw-r--r--test/functional/terminal/ex_terminal_spec.lua9
-rw-r--r--test/functional/terminal/helpers.lua2
-rw-r--r--test/functional/terminal/highlight_spec.lua2
-rw-r--r--test/functional/terminal/mouse_spec.lua5
-rw-r--r--test/functional/terminal/scrollback_spec.lua2
-rw-r--r--test/functional/terminal/tui_spec.lua186
-rw-r--r--test/functional/terminal/window_spec.lua4
-rw-r--r--test/functional/terminal/window_split_tab_spec.lua3
-rw-r--r--test/functional/ui/highlight_spec.lua2
-rw-r--r--test/functional/ui/input_spec.lua1
-rw-r--r--test/functional/ui/screen.lua40
-rw-r--r--test/functional/ui/screen_basic_spec.lua5
-rw-r--r--test/functional/ui/searchhl_spec.lua4
-rw-r--r--test/functional/viml/completion_spec.lua2
-rw-r--r--test/includes/CMakeLists.txt1
-rw-r--r--test/includes/pre/sys/errno.h4
-rw-r--r--test/includes/pre/uv-errno.h4
-rw-r--r--test/unit/buffer_spec.lua98
-rw-r--r--test/unit/fileio_spec.lua1
-rw-r--r--test/unit/formatc.lua12
-rw-r--r--test/unit/garray_spec.lua19
-rw-r--r--test/unit/helpers.lua16
-rw-r--r--test/unit/os/env_spec.lua8
-rw-r--r--test/unit/os/fs_spec.lua71
-rw-r--r--test/unit/os/shell_spec.lua4
-rw-r--r--test/unit/os/users_spec.lua8
-rw-r--r--test/unit/path_spec.lua80
-rw-r--r--test/unit/preprocess.lua4
-rw-r--r--test/unit/profile_spec.lua26
-rw-r--r--test/unit/set.lua2
-rw-r--r--third-party/cmake/BuildLibuv.cmake6
-rw-r--r--third-party/cmake/BuildLuajit.cmake2
-rw-r--r--third-party/cmake/BuildLuarocks.cmake13
341 files changed, 15159 insertions, 12939 deletions
diff --git a/.asan-blacklist b/.asan-blacklist
index bd977dfe17..63558170b3 100644
--- a/.asan-blacklist
+++ b/.asan-blacklist
@@ -1,2 +1,3 @@
# libuv queue.h pointer arithmetic is not accepted by asan
fun:queue_node_data
+fun:dictwatcher_node_data
diff --git a/.gitignore b/.gitignore
index ee4a579f91..70899dfa8d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -38,6 +38,9 @@ tags
# Folder generated by the unit tests
/test/includes/post/
+# generated by luacheck during `make testlint'
+/test/.luacheckcache
+
# luarocks, not added as a subtree because of the large number of blobs
/third-party/luarocks
@@ -60,8 +63,6 @@ local.mk
# runtime/doc
/runtime/doc/*.html
-/runtime/doc/**/*.man
-/runtime/doc/tags
/runtime/doc/tags.ref
/runtime/doc/doctags
/runtime/doc/errors.log
diff --git a/BACKERS.md b/BACKERS.md
index 10c6f42f27..6cfcb0b407 100644
--- a/BACKERS.md
+++ b/BACKERS.md
@@ -104,7 +104,7 @@ Thank you to everyone who backed our [Bountysource fundraiser](https://www.bount
- Michael Ulm www.mulm.at
- Mikael Jansson http://mikaelj.se
- Mikkel Høgh http://mikkel.hoegh.org/
-- Ming Liu http://www.codingupfengshui.io
+- Ming Liu http://ming.codes
- Holger Peters http://www.holger-peters.de
- Alexander Myshov http://myshov.com/
- Darren Cheng http://sanguinerane.com/
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 348e138a06..f06d060560 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -38,31 +38,36 @@ endif()
# Set available build types for CMake GUIs.
# A different build type can still be set by -DCMAKE_BUILD_TYPE=...
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY
- STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
+ STRINGS "Debug" "Dev" "Release" "MinSizeRel" "RelWithDebInfo")
# Set default build type.
if(NOT CMAKE_BUILD_TYPE)
- message(STATUS "CMAKE_BUILD_TYPE not given; setting to 'RelWithDebInfo'.")
- set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build." FORCE)
+ message(STATUS "CMAKE_BUILD_TYPE not given, defaulting to 'Dev'.")
+ set(CMAKE_BUILD_TYPE "Dev" CACHE STRING "Choose the type of build." FORCE)
endif()
# Version tokens
+# - In a git repo, these tokens are _ignored_.
+# - If the current HEAD is tagged, the tag name is used.
+# - Otherwise the result of `git describe` is used.
+# - If not in a git repo (e.g. a tarball) these tokens set the version string.
+set(NVIM_VERSION_MAJOR 0)
+set(NVIM_VERSION_MINOR 1)
+set(NVIM_VERSION_PATCH 1)
+
+file(TO_CMAKE_PATH ${CMAKE_CURRENT_LIST_DIR}/.git FORCED_GIT_DIR)
include(GetGitRevisionDescription)
-file(TO_NATIVE_PATH ${CMAKE_CURRENT_LIST_DIR}/.git GIT_DIR)
get_git_head_revision(GIT_REFSPEC NVIM_VERSION_COMMIT)
-if(NOT NVIM_VERSION_COMMIT)
- set(NVIM_VERSION_COMMIT "?")
-endif()
-set(NVIM_VERSION_MAJOR 0)
-set(NVIM_VERSION_MINOR 0)
-set(NVIM_VERSION_PATCH 0)
-set(NVIM_VERSION_PRERELEASE "-alpha")
-# TODO(justinmk): UTC time would be nice here #1071
-git_timestamp(GIT_TIMESTAMP)
-# TODO(justinmk): do not set this for "release" builds #1071
-if(GIT_TIMESTAMP)
- set(NVIM_VERSION_BUILD "+${GIT_TIMESTAMP}")
+if(NVIM_VERSION_COMMIT) # is a git repo
+ git_get_exact_tag(NVIM_VERSION_MEDIUM)
+ if(NVIM_VERSION_MEDIUM) # is a tagged release
+ unset(NVIM_VERSION_COMMIT)
+ else() # is a dev build
+ git_describe(NVIM_VERSION_MEDIUM)
+ get_git_head_revision(GIT_REFSPEC NVIM_VERSION_COMMIT)
+ endif()
endif()
+
set(NVIM_VERSION_BUILD_TYPE "${CMAKE_BUILD_TYPE}")
# NVIM_VERSION_CFLAGS set further below.
@@ -74,6 +79,57 @@ if(CMAKE_C_FLAGS_RELEASE MATCHES "-O3")
string(REPLACE "-O3" "-O2" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
endif()
+# Disable logging for release-type builds.
+if(NOT CMAKE_C_FLAGS_RELEASE MATCHES DDISABLE_LOG)
+ set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DDISABLE_LOG")
+endif()
+if(NOT CMAKE_C_FLAGS_MINSIZEREL MATCHES DDISABLE_LOG)
+ set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -DDISABLE_LOG")
+endif()
+if(NOT CMAKE_C_FLAGS_RELWITHDEBINFO MATCHES DDISABLE_LOG)
+ set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -DDISABLE_LOG")
+endif()
+
+# Enable assertions for RelWithDebInfo.
+if(CMAKE_C_FLAGS_RELWITHDEBINFO MATCHES DNDEBUG)
+ string(REPLACE "-DNDEBUG" "" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
+endif()
+
+# Set build flags for custom Dev build type.
+# -DNDEBUG purposely omitted because we want assertions.
+if(MSVC)
+ SET(CMAKE_C_FLAGS_DEV ""
+ CACHE STRING "Flags used by the compiler during development (optimized, but with debug info and logging) builds."
+ FORCE)
+else()
+ if(CMAKE_COMPILER_IS_GNUCC)
+ check_c_compiler_flag(-Og HAS_OG_FLAG)
+ else()
+ set(HAS_OG_FLAG 0)
+ endif()
+
+ if(HAS_OG_FLAG)
+ set(CMAKE_C_FLAGS_DEV "-Og -g"
+ CACHE STRING "Flags used by the compiler during development (optimized, but with debug info and logging) builds."
+ FORCE)
+ else()
+ set(CMAKE_C_FLAGS_DEV "-O2 -g"
+ CACHE STRING "Flags used by the compiler during development (optimized, but with debug info and logging) builds."
+ FORCE)
+ endif()
+endif()
+SET(CMAKE_EXE_LINKER_FLAGS_DEV ""
+ CACHE STRING "Flags used for linking binaries during development (optimized, but with debug info and logging) builds."
+ FORCE)
+SET(CMAKE_SHARED_LINKER_FLAGS_DEV ""
+ CACHE STRING "Flags used by the shared libraries linker during development (optimized, but with debug info and logging) builds."
+ FORCE)
+
+MARK_AS_ADVANCED(
+ CMAKE_C_FLAGS_DEV
+ CMAKE_EXE_LINKER_FLAGS_DEV
+ CMAKE_SHARED_LINKER_FLAGS_DEV)
+
# Enable -Wconversion.
if(NOT MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion")
@@ -177,22 +233,6 @@ if(TRAVIS_CI_BUILD)
add_definitions(-Werror)
endif()
-if(CMAKE_COMPILER_IS_GNUCC)
- check_c_compiler_flag(-Og HAS_OG_FLAG)
-else()
- set(HAS_OG_FLAG 0)
-endif()
-
-# Set custom build flags for RelWithDebInfo.
-# -DNDEBUG purposely omitted because we want assertions.
-if(HAS_OG_FLAG)
- set(CMAKE_C_FLAGS_RELWITHDEBINFO "-Og -g"
- CACHE STRING "Flags used by the compiler during release builds with debug info." FORCE)
-elseif(NOT MSVC)
- set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g"
- CACHE STRING "Flags used by the compiler during release builds with debug info." FORCE)
-endif()
-
if(CMAKE_BUILD_TYPE MATCHES Debug)
set(DEBUG 1)
else()
@@ -260,12 +300,16 @@ if((CLANG_ASAN_UBSAN OR CLANG_MSAN OR CLANG_TSAN) AND NOT CMAKE_C_COMPILER_ID MA
message(FATAL_ERROR "Sanitizers are only supported for Clang.")
endif()
-if(CLANG_ASAN_UBSAN OR CLANG_MSAN OR CLANG_TSAN)
- message(STATUS "Sanitizers have been enabled; don't use jemalloc.")
-else()
- find_package(JeMalloc)
- if(JEMALLOC_FOUND)
- include_directories(SYSTEM ${JEMALLOC_INCLUDE_DIRS})
+option(ENABLE_JEMALLOC "enable jemalloc" ON)
+
+if (ENABLE_JEMALLOC)
+ if(CLANG_ASAN_UBSAN OR CLANG_MSAN OR CLANG_TSAN)
+ message(STATUS "Sanitizers have been enabled; don't use jemalloc.")
+ else()
+ find_package(JeMalloc)
+ if(JEMALLOC_FOUND)
+ include_directories(SYSTEM ${JEMALLOC_INCLUDE_DIRS})
+ endif()
endif()
endif()
@@ -321,6 +365,8 @@ if(NOT BUSTED_OUTPUT_TYPE)
set(BUSTED_OUTPUT_TYPE "utfTerminal")
endif()
+find_program(LUACHECK_PRG luacheck)
+
include(InstallHelpers)
file(GLOB MANPAGES
@@ -411,3 +457,11 @@ if(BUSTED_PRG)
-P ${PROJECT_SOURCE_DIR}/cmake/RunTests.cmake
DEPENDS ${BENCHMARK_PREREQS})
endif()
+
+if(LUACHECK_PRG)
+ add_custom_target(testlint
+ COMMAND ${CMAKE_COMMAND}
+ -DLUACHECK_PRG=${LUACHECK_PRG}
+ -DTEST_DIR=${CMAKE_CURRENT_SOURCE_DIR}/test
+ -P ${PROJECT_SOURCE_DIR}/cmake/RunTestsLint.cmake)
+endif()
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 21ab0869e2..aa88837290 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -27,9 +27,9 @@ If your issue isn't mentioned there:
[Troubleshooting#build-issues][wiki-troubleshooting-build-issues].
- For runtime issues, see
[Troubleshooting#runtime-issues][wiki-troubleshooting-runtime-issues].
- If your issue isn't mentioned there, try to reproduce your it using
- `nvim` with the smallest possible `nvimrc` (or none at all via `nvim -u
- NONE`), to rule out bugs in plugins you're using.
+ If your issue isn't mentioned there, try reproducing it using `nvim`
+ with the smallest possible `vimrc` (or none at all via `nvim -u NONE`),
+ to rule out bugs in plugins you're using.
If you're using a plugin manager, comment out your plugins, then add
them back in one by one.
@@ -47,8 +47,6 @@ Include as much detail as possible; we generally need to know:
## Submitting contributions
-- If you're a first-time contributor, please sign the [Neovim Contributor
- License Agreement (CLA)][cla] before submitting your pull request.
- Make it clear in the issue tracker what you are working on.
- Be descriptive in your pull request description: what is it for, why is it
needed, etc.
@@ -176,7 +174,6 @@ as context, use the `-W` argument as well.
You may find it easier to instead use an interactive program for code reviews,
such as [`tig`][tig].
-[cla]: https://docs.google.com/forms/d/1u54bpbwzneDIRltFx1TGi2evKxY3w0cOV3vlpj8DPbg/viewform
[clang-format]: http://clang.llvm.org/docs/ClangFormat.html
[clint]: clint.py
[entry-level]: https://github.com/neovim/neovim/issues?labels=entry-level&state=open
diff --git a/Makefile b/Makefile
index 45065769fb..1fc15e1312 100644
--- a/Makefile
+++ b/Makefile
@@ -86,7 +86,8 @@ oldtest: | nvim
functionaltest: | nvim
+$(BUILD_CMD) -C build functionaltest
-test: functionaltest
+testlint: | nvim
+ $(BUILD_CMD) -C build testlint
unittest: | nvim
+$(BUILD_CMD) -C build unittest
@@ -94,6 +95,8 @@ unittest: | nvim
benchmark: | nvim
+$(BUILD_CMD) -C build benchmark
+test: functionaltest unittest
+
clean:
+test -d build && $(BUILD_CMD) -C build clean || true
$(MAKE) -C src/nvim/testdir clean
@@ -110,4 +113,4 @@ lint:
-DLINT_SUPPRESS_URL="$(DOC_DOWNLOAD_URL_BASE)$(CLINT_ERRORS_FILE_PATH)" \
-P cmake/RunLint.cmake
-.PHONY: test functionaltest unittest lint clean distclean nvim libnvim cmake deps install
+.PHONY: test testlint functionaltest unittest lint clean distclean nvim libnvim cmake deps install
diff --git a/README.md b/README.md
index 51b919f3d5..c6f668c425 100644
--- a/README.md
+++ b/README.md
@@ -29,10 +29,12 @@ For lots more details, see
### What's been done so far
-- [Terminal emulator](http://neovim.io/doc/user/nvim_terminal_emulator.html)
-- [Job control](https://github.com/neovim/neovim/pull/2247)
-- MessagePack-based remote API
-- Performance, reliability, portability
+- Automatic [history merge](https://github.com/neovim/neovim/pull/2506) between multiple editor instances
+- [XDG-compliant](https://github.com/neovim/neovim/pull/3470) configuration
+- Embedded [terminal emulator](https://neovim.io/doc/user/nvim_terminal_emulator.html)
+- Asynchronous [job control](https://github.com/neovim/neovim/pull/2247)
+- [MessagePack](https://msgpack.org) remote API
+- [Pushdown automaton](https://github.com/neovim/neovim/pull/3413) for state transitions
See the [progress page](https://github.com/neovim/neovim/wiki/Progress) for a comprehensive list.
@@ -58,8 +60,8 @@ more. See [the wiki](https://github.com/neovim/neovim/wiki/Installing-Neovim)!
Neovim is licensed under the terms of the Apache 2.0 license, except for
parts that were contributed under the Vim license.
-- Contributions committed before [b17d96][license-commit] by authors who did
- not sign the Contributor License Agreement (CLA) remain under the Vim license.
+- Contributions committed before [b17d96][license-commit] remain under the Vim
+ license.
- Contributions committed after [b17d96][license-commit] are licensed under
Apache 2.0 unless those contributions were copied from Vim (identified in
diff --git a/clint.py b/clint.py
index 0eaab6e3f6..d507837e58 100755
--- a/clint.py
+++ b/clint.py
@@ -198,6 +198,8 @@ _ERROR_CATEGORIES = [
'runtime/printf',
'runtime/printf_format',
'runtime/threadsafe_fn',
+ 'syntax/parenthesis',
+ 'whitespace/alignment',
'whitespace/blank_line',
'whitespace/braces',
'whitespace/comma',
@@ -213,7 +215,7 @@ _ERROR_CATEGORIES = [
'whitespace/parens',
'whitespace/semicolon',
'whitespace/tab',
- 'whitespace/todo'
+ 'whitespace/todo',
]
# The default state of the category filter. This is overrided by the --filter=
@@ -826,9 +828,9 @@ def Error(filename, linenum, category, confidence, message):
_RE_PATTERN_CLEANSE_LINE_ESCAPES = re.compile(
r'\\([abfnrtv?"\\\']|\d+|x[0-9a-fA-F]+)')
# Matches strings. Escape codes should already be removed by ESCAPES.
-_RE_PATTERN_CLEANSE_LINE_DOUBLE_QUOTES = re.compile(r'"[^"]*"')
+_RE_PATTERN_CLEANSE_LINE_DOUBLE_QUOTES = re.compile(r'"([^"]*)"')
# Matches characters. Escape codes should already be removed by ESCAPES.
-_RE_PATTERN_CLEANSE_LINE_SINGLE_QUOTES = re.compile(r"'.'")
+_RE_PATTERN_CLEANSE_LINE_SINGLE_QUOTES = re.compile(r"'(.)'")
# Matches multi-line C++ comments.
# This RE is a little bit more complicated than one might expect, because we
# have to take care of space removals tools so we can handle comments inside
@@ -923,39 +925,48 @@ def CleanseComments(line):
class CleansedLines(object):
- """Holds 3 copies of all lines with different preprocessing applied to them.
+ """Holds 5 copies of all lines with different preprocessing applied to them.
1) elided member contains lines without strings and comments,
2) lines member contains lines without comments, and
- 3) raw_lines member contains all the lines without processing.
+ 3) raw_lines member contains all the lines with multiline comments replaced.
+ 4) init_lines member contains all the lines without processing.
+ 5) elided_with_space_strings is like elided, but with string literals
+ looking like `" "`.
All these three members are of <type 'list'>, and of the same length.
"""
- def __init__(self, lines):
+ def __init__(self, lines, init_lines):
self.elided = []
self.lines = []
self.raw_lines = lines
self.num_lines = len(lines)
+ self.init_lines = init_lines
self.lines_without_raw_strings = lines
+ self.elided_with_space_strings = []
for linenum in range(len(self.lines_without_raw_strings)):
self.lines.append(CleanseComments(
self.lines_without_raw_strings[linenum]))
elided = self._CollapseStrings(
self.lines_without_raw_strings[linenum])
self.elided.append(CleanseComments(elided))
+ elided = CleanseComments(self._CollapseStrings(
+ self.lines_without_raw_strings[linenum], True))
+ self.elided_with_space_strings.append(elided)
def NumLines(self):
"""Returns the number of lines represented."""
return self.num_lines
@staticmethod
- def _CollapseStrings(elided):
+ def _CollapseStrings(elided, keep_spaces=False):
"""Collapses strings and chars on a line to simple "" or '' blocks.
We nix strings first so we're not fooled by text like '"http://"'
Args:
elided: The line being processed.
+ keep_spaces: If true, collapse to
Returns:
The line with collapsed strings.
@@ -964,12 +975,75 @@ class CleansedLines(object):
# Remove escaped characters first to make quote/single quote
# collapsing basic. Things that look like escaped characters
# shouldn't occur outside of strings and chars.
- elided = _RE_PATTERN_CLEANSE_LINE_ESCAPES.sub('', elided)
- elided = _RE_PATTERN_CLEANSE_LINE_SINGLE_QUOTES.sub("''", elided)
- elided = _RE_PATTERN_CLEANSE_LINE_DOUBLE_QUOTES.sub('""', elided)
+ elided = _RE_PATTERN_CLEANSE_LINE_ESCAPES.sub(
+ '' if not keep_spaces else lambda m: ' ' * len(m.group(0)),
+ elided)
+ elided = _RE_PATTERN_CLEANSE_LINE_SINGLE_QUOTES.sub(
+ "''" if not keep_spaces
+ else lambda m: "'" + (' ' * len(m.group(1))) + "'",
+ elided)
+ elided = _RE_PATTERN_CLEANSE_LINE_DOUBLE_QUOTES.sub(
+ '""' if not keep_spaces
+ else lambda m: '"' + (' ' * len(m.group(1))) + '"',
+ elided)
return elided
+BRACES = {
+ '(': ')',
+ '{': '}',
+ '[': ']',
+ # '<': '>', C++-specific pair removed
+}
+
+
+CLOSING_BRACES = dict(((v, k) for k, v in BRACES.items()))
+
+
+def GetExprBracesPosition(clean_lines, linenum, pos):
+ """List positions of all kinds of braces
+
+ If input points to ( or { or [ then function proceeds until finding the
+ position which closes it.
+
+ Args:
+ clean_lines: A CleansedLines instance containing the file.
+ linenum: Current line number.
+ pos: A position on the line.
+
+ Yields:
+ A tuple (linenum, pos, brace, depth) that points to each brace.
+ Additionally each new line (linenum, pos, 's', depth) is yielded, for each
+ line end (linenum, pos, 'e', depth) is yielded and at the very end it
+ yields (linenum, pos, None, None).
+ """
+ depth = 0
+ yielded_line_start = True
+ startpos = pos
+ while linenum < clean_lines.NumLines() - 1:
+ line = clean_lines.elided_with_space_strings[linenum]
+ if not line.startswith('#') or yielded_line_start:
+ # Ignore #ifdefs, but not if it is macros that are checked
+ for i, brace in enumerate(line[startpos:]):
+ pos = i + startpos
+ if brace != ' ' and not yielded_line_start:
+ yield (linenum, pos, 's', depth)
+ yielded_line_start = True
+ if brace in BRACES:
+ depth += 1
+ yield (linenum, pos, brace, depth)
+ elif brace in CLOSING_BRACES:
+ yield (linenum, pos, brace, depth)
+ depth -= 1
+ if depth == 0:
+ yield (linenum, pos, None, None)
+ return
+ yield (linenum, len(line) - 1, 'e', depth)
+ yielded_line_start = False
+ startpos = 0
+ linenum += 1
+
+
def FindEndOfExpressionInLine(line, startpos, depth, startchar, endchar):
"""Find the position just after the matching endchar.
@@ -995,9 +1069,9 @@ def FindEndOfExpressionInLine(line, startpos, depth, startchar, endchar):
def CloseExpression(clean_lines, linenum, pos):
- """If input points to ( or { or [ or <, finds the position that closes it.
+ """If input points to ( or { or [, finds the position that closes it.
- If lines[linenum][pos] points to a '(' or '{' or '[' or '<', finds the
+ If lines[linenum][pos] points to a '(' or '{' or '[', finds the
linenum/pos that correspond to the closing of the expression.
Args:
@@ -1014,16 +1088,9 @@ def CloseExpression(clean_lines, linenum, pos):
line = clean_lines.elided[linenum]
startchar = line[pos]
- if startchar not in '({[<':
+ if startchar not in BRACES:
return (line, clean_lines.NumLines(), -1)
- if startchar == '(':
- endchar = ')'
- if startchar == '[':
- endchar = ']'
- if startchar == '{':
- endchar = '}'
- if startchar == '<':
- endchar = '>'
+ endchar = BRACES[startchar]
# Check first line
(end_pos, num_open) = FindEndOfExpressionInLine(
@@ -1300,6 +1367,23 @@ def CheckForMultilineCommentsAndStrings(filename, clean_lines, linenum, error):
'Use C++11 raw strings or concatenation instead.')
+def CheckForOldStyleComments(filename, line, linenum, error):
+ """Logs an error if we see /*-style comment
+
+ Args:
+ filename: The name of the current file.
+ line: The text of the line to check.
+ linenum: The number of the line to check.
+ error: The function to call with any errors found.
+ """
+ if line.find('/*') >= 0 and line[-1] != '\\':
+ error(filename, linenum, 'readability/old_style_comment', 5,
+ '/*-style comment found, it should be replaced with //-style. '
+ '/*-style comments are only allowed inside macros. '
+ 'Note that you should not use /*-style comments to document '
+ 'macros itself, use doxygen-style comments for this.')
+
+
threading_list = (
('asctime(', 'os_asctime_r('),
('ctime(', 'os_ctime_r('),
@@ -1968,6 +2052,92 @@ def FindPreviousMatchingAngleBracket(clean_lines, linenum, init_prefix):
return False
+def CheckExpressionAlignment(filename, clean_lines, linenum, error, startpos=0):
+ """Checks for the correctness of alignment inside expressions
+
+ Args:
+ filename: The name of the current file.
+ clean_lines: A CleansedLines instance containing the file.
+ linenum: The number of the line to check.
+ error: The function to call with any errors found.
+ startpos: Position where to start searching for expression start.
+ """
+ level_starts = {}
+ line = clean_lines.elided_with_space_strings[linenum]
+ prev_line_start = Search(r'\S', line).start()
+ depth_line_starts = {}
+ pos = min([
+ idx
+ for idx in (
+ line.find(k, startpos)
+ for k in BRACES
+ if k != '{'
+ )
+ if idx >= 0
+ ] + [len(line) + 1])
+ if pos == len(line) + 1:
+ return
+ ignore_error_levels = set()
+ firstlinenum = linenum
+ for linenum, pos, brace, depth in GetExprBracesPosition(
+ clean_lines, linenum, pos
+ ):
+ line = clean_lines.elided_with_space_strings[linenum]
+ if depth is None:
+ if pos < len(line) - 1:
+ CheckExpressionAlignment(filename, clean_lines, linenum, error,
+ pos + 1)
+ return
+ elif depth <= 0:
+ error(filename, linenum, 'syntax/parenthesis', 4,
+ 'Unbalanced parenthesis')
+ return
+ if brace == 's':
+ assert firstlinenum != linenum
+ if level_starts[depth][1]:
+ if line[pos] == BRACES[depth_line_starts[depth][1]]:
+ if pos != depth_line_starts[depth][0]:
+ if depth not in ignore_error_levels:
+ error(filename, linenum, 'whitespace/indent', 2,
+ 'End of the inner expression should have '
+ 'the same indent as start')
+ else:
+ if (pos != depth_line_starts[depth][0] + 4
+ and not (depth_line_starts[depth][1] == '{'
+ and pos == depth_line_starts[depth][0] + 2)):
+ if depth not in ignore_error_levels:
+ error(filename, linenum, 'whitespace/indent', 2,
+ 'Inner expression indentation should be 4')
+ else:
+ if (pos != level_starts[depth][0] + 1
+ + (level_starts[depth][2] == '{')):
+ if depth not in ignore_error_levels:
+ error(filename, linenum, 'whitespace/alignment', 2,
+ 'Inner expression should be aligned '
+ 'as opening brace + 1 (+ 2 in case of {)')
+ prev_line_start = pos
+ elif brace == 'e':
+ pass
+ else:
+ opening = brace in BRACES
+ if opening:
+ # Only treat {} as part of the expression if it is preceded by
+ # "=" (brace initializer) or "(type)" (construct like (struct
+ # foo) { ... }).
+ if brace == '{' and not (Search(
+ r'(?:= *|\((?:struct )?\w+(\s*\[\w*\])?\)) *$',
+ line[:pos])
+ ):
+ ignore_error_levels.add(depth)
+ line_ended_with_opening = (
+ pos == len(line) - 2 * (line.endswith(' \\')) - 1)
+ level_starts[depth] = (pos, line_ended_with_opening, brace)
+ if line_ended_with_opening:
+ depth_line_starts[depth] = (prev_line_start, brace)
+ else:
+ del level_starts[depth]
+
+
def CheckSpacing(filename, clean_lines, linenum, nesting_state, error):
"""Checks for the correctness of various spacing issues in the code.
@@ -1975,7 +2145,8 @@ def CheckSpacing(filename, clean_lines, linenum, nesting_state, error):
if/for/while/switch, no spaces around parens in function calls, two
spaces between code and comment, don't start a block with a blank
line, don't end a function with a blank line, don't add a blank line
- after public/protected/private, don't have too many blank lines in a row.
+ after public/protected/private, don't have too many blank lines in a row,
+ spaces after {, spaces before }.
Args:
filename: The name of the current file.
@@ -2236,6 +2407,10 @@ def CheckSpacing(filename, clean_lines, linenum, nesting_state, error):
# Next we will look for issues with function calls.
CheckSpacingForFunctionCall(filename, line, linenum, error)
+ # Check whether everything inside expressions is aligned correctly
+ if any((line.find(k) >= 0 for k in BRACES if k != '{')):
+ CheckExpressionAlignment(filename, clean_lines, linenum, error)
+
# Except after an opening paren, or after another opening brace (in case of
# an initializer list, for instance), you should have spaces before your
# braces. And since you should never have braces at the beginning of a line,
@@ -2292,8 +2467,6 @@ def CheckSpacing(filename, clean_lines, linenum, nesting_state, error):
'Extra space before [')
# You shouldn't have a space before a semicolon at the end of the line.
- # There's a special case for "for" since the style guide allows space before
- # the semicolon there.
if Search(r':\s*;\s*$', line):
error(filename, linenum, 'whitespace/semicolon', 5,
'Semicolon defining empty statement. Use {} instead.')
@@ -2301,12 +2474,18 @@ def CheckSpacing(filename, clean_lines, linenum, nesting_state, error):
error(filename, linenum, 'whitespace/semicolon', 5,
'Line contains only semicolon. If this should be an empty'
' statement, use {} instead.')
- elif (Search(r'\s+;\s*$', line) and
- not Search(r'\bfor\b', line)):
+ elif Search(r'\s+;\s*$', line):
error(filename, linenum, 'whitespace/semicolon', 5,
'Extra space before last semicolon. If this should be an empty '
'statement, use {} instead.')
+ if Search(r'\{(?!\})\S', line):
+ error(filename, linenum, 'whitespace/braces', 5,
+ 'Missing space after {')
+ if Search(r'\S(?<!\{)\}', line):
+ error(filename, linenum, 'whitespace/braces', 5,
+ 'Missing space before }')
+
def GetPreviousNonBlankLine(clean_lines, linenum):
"""Return the most recent non-blank line and its line number.
@@ -2361,11 +2540,27 @@ def CheckBraces(filename, clean_lines, linenum, error):
' of the previous line')
# An else clause should be on the same line as the preceding closing brace.
+ # If there is no preceding closing brace, there should be one.
if Match(r'\s*else\s*', line):
prevline = GetPreviousNonBlankLine(clean_lines, linenum)[0]
if Match(r'\s*}\s*$', prevline):
error(filename, linenum, 'whitespace/newline', 4,
'An else should appear on the same line as the preceding }')
+ else:
+ error(filename, linenum, 'readability/braces', 5,
+ 'An else should always have braces before it')
+
+ # If should always have a brace
+ for blockstart in ('if', 'while', 'for'):
+ if Match(r'\s*{0}[^{{]*$'.format(blockstart), line):
+ pos = line.find(blockstart)
+ pos = line.find('(', pos)
+ if pos > 0:
+ (endline, _, endpos) = CloseExpression(
+ clean_lines, linenum, pos)
+ if endline[endpos:].find('{') == -1:
+ error(filename, linenum, 'readability/braces', 5,
+ '{0} should always use braces'.format(blockstart))
# If braces come on one side of an else, they should be on both.
# However, we have to worry about "else if" that spans multiple lines!
@@ -3026,12 +3221,14 @@ def ProcessLine(filename, file_extension, clean_lines, line,
arguments : filename, clean_lines, line, error
"""
raw_lines = clean_lines.raw_lines
+ init_lines = clean_lines.init_lines
ParseNolintSuppressions(filename, raw_lines[line], line, error)
nesting_state.Update(filename, clean_lines, line, error)
if nesting_state.stack and nesting_state.stack[-1].inline_asm != _NO_ASM:
return
CheckForFunctionLengths(filename, clean_lines, line, function_state, error)
CheckForMultilineCommentsAndStrings(filename, clean_lines, line, error)
+ CheckForOldStyleComments(filename, init_lines[line], line, error)
CheckStyle(
filename, clean_lines, line, file_extension, nesting_state, error)
CheckLanguage(filename, clean_lines, line, file_extension, include_state,
@@ -3072,12 +3269,12 @@ def ProcessFileData(filename, file_extension, lines, error,
for line in range(1, len(lines)):
ParseKnownErrorSuppressions(filename, lines, line)
- if _cpplint_state.record_errors_file:
- raw_lines = lines[:]
+ init_lines = lines[:]
+ if _cpplint_state.record_errors_file:
def RecordedError(filename, linenum, category, confidence, message):
if not IsErrorSuppressedByNolint(category, linenum):
- key = raw_lines[linenum - 1 if linenum else 0:linenum + 2]
+ key = init_lines[linenum - 1 if linenum else 0:linenum + 2]
err = [filename, key, category]
json.dump(err, _cpplint_state.record_errors_file)
_cpplint_state.record_errors_file.write('\n')
@@ -3089,7 +3286,7 @@ def ProcessFileData(filename, file_extension, lines, error,
CheckForHeaderGuard(filename, lines, error)
RemoveMultiLineComments(filename, lines, error)
- clean_lines = CleansedLines(lines)
+ clean_lines = CleansedLines(lines, init_lines)
for line in range(clean_lines.NumLines()):
ProcessLine(filename, file_extension, clean_lines, line,
include_state, function_state, nesting_state, error,
diff --git a/cmake/FindLibUV.cmake b/cmake/FindLibUV.cmake
index 8542100e67..dcdd5e48b7 100644
--- a/cmake/FindLibUV.cmake
+++ b/cmake/FindLibUV.cmake
@@ -59,11 +59,6 @@ if(HAVE_LIBDL)
list(APPEND LIBUV_LIBRARIES dl)
endif()
-check_library_exists(iphlpapi GetAdaptersAddresses "iphlpapi.h" HAVE_LIBIPHLPAPI)
-if(HAVE_LIBIPHLPAPI)
- list(APPEND LIBUV_LIBRARIES iphlpapi)
-endif()
-
check_library_exists(kstat kstat_lookup "kstat.h" HAVE_LIBKSTAT)
if(HAVE_LIBKSTAT)
list(APPEND LIBUV_LIBRARIES kstat)
@@ -84,11 +79,6 @@ if(HAVE_LIBPERFSTAT)
list(APPEND LIBUV_LIBRARIES perfstat)
endif()
-check_library_exists(psapi GetProcessMemoryInfo "psapi.h" HAVE_LIBPSAPI)
-if(HAVE_LIBPSAPI)
- list(APPEND LIBUV_LIBRARIES psapi)
-endif()
-
check_library_exists(rt clock_gettime "time.h" HAVE_LIBRT)
if(HAVE_LIBRT)
list(APPEND LIBUV_LIBRARIES rt)
@@ -99,13 +89,12 @@ if(HAVE_LIBSENDFILE)
list(APPEND LIBUV_LIBRARIES sendfile)
endif()
-check_library_exists(userenv GetUserProfileDirectoryW "userenv.h" HAVE_LIBUSERENV)
-if(HAVE_LIBUSERENV)
+if(WIN32)
+ # check_library_exists() does not work for Win32 API calls in X86 due to name
+ # mangling calling conventions
+ list(APPEND LIBUV_LIBRARIES iphlpapi)
+ list(APPEND LIBUV_LIBRARIES psapi)
list(APPEND LIBUV_LIBRARIES userenv)
-endif()
-
-check_library_exists(ws2_32 WSAStartup "winsock2.h" HAVE_LIBWS232)
-if(HAVE_LIBWS232)
list(APPEND LIBUV_LIBRARIES ws2_32)
endif()
diff --git a/cmake/FindLuaJit.cmake b/cmake/FindLuaJit.cmake
index 59642d11b9..e9ff53ab62 100644
--- a/cmake/FindLuaJit.cmake
+++ b/cmake/FindLuaJit.cmake
@@ -34,7 +34,7 @@ endif()
if(MSVC)
list(APPEND LUAJIT_NAMES lua51)
elseif(MINGW)
- list(APPEND LUAJIT_NAMES libluajit)
+ list(APPEND LUAJIT_NAMES libluajit libluajit-5.1)
else()
list(APPEND LUAJIT_NAMES luajit-5.1)
endif()
diff --git a/cmake/GenerateHelptags.cmake.in b/cmake/GenerateHelptags.cmake.in
index 0df10d730e..3ced2c0b17 100644
--- a/cmake/GenerateHelptags.cmake.in
+++ b/cmake/GenerateHelptags.cmake.in
@@ -25,7 +25,7 @@ file(WRITE ${EMPTY_FILE} "")
execute_process(
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/bin/nvim
-u NONE
- -esX
+ -es
-c "helptags ++t ."
-c quit
WORKING_DIRECTORY ${HELPTAGS_WORKING_DIRECTORY}
diff --git a/cmake/GetGitRevisionDescription.cmake b/cmake/GetGitRevisionDescription.cmake
index 1e0968ec3b..5044c682e4 100644
--- a/cmake/GetGitRevisionDescription.cmake
+++ b/cmake/GetGitRevisionDescription.cmake
@@ -42,7 +42,13 @@ set(__get_git_revision_description YES)
get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH)
function(get_git_dir _gitdir)
- # check GIT_DIR in environment first
+ # check FORCED_GIT_DIR first
+ if(FORCED_GIT_DIR)
+ set(${_gitdir} ${FORCED_GIT_DIR} PARENT_SCOPE)
+ return()
+ endif()
+
+ # check GIT_DIR in environment
set(GIT_DIR $ENV{GIT_DIR})
if(NOT GIT_DIR)
set(GIT_PARENT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
diff --git a/cmake/RunTestsLint.cmake b/cmake/RunTestsLint.cmake
new file mode 100644
index 0000000000..cf5465803e
--- /dev/null
+++ b/cmake/RunTestsLint.cmake
@@ -0,0 +1,11 @@
+execute_process(
+ COMMAND ${LUACHECK_PRG} -q ${TEST_DIR}
+ WORKING_DIRECTORY ${TEST_DIR}
+ ERROR_VARIABLE err
+ RESULT_VARIABLE res
+ ${EXTRA_ARGS})
+
+if(NOT res EQUAL 0)
+ message(STATUS "Output to stderr:\n${err}")
+ message(FATAL_ERROR "Linting tests failed with error: ${res}.")
+endif()
diff --git a/config/CMakeLists.txt b/config/CMakeLists.txt
index b780291264..3d7660ed58 100644
--- a/config/CMakeLists.txt
+++ b/config/CMakeLists.txt
@@ -51,7 +51,10 @@ if(JEMALLOC_FOUND)
set(HAVE_JEMALLOC 1)
endif()
-check_function_exists(putenv HAVE_PUTENV)
+check_function_exists(_putenv_s HAVE_PUTENV_S)
+if(WIN32 AND NOT HAVE_PUTENV_S)
+ message(SEND_ERROR "_putenv_s() function not found on your system.")
+endif()
check_function_exists(opendir HAVE_OPENDIR)
check_function_exists(readlink HAVE_READLINK)
check_function_exists(setenv HAVE_SETENV)
diff --git a/config/config.h.in b/config/config.h.in
index f8a795327f..017cb80f2f 100644
--- a/config/config.h.in
+++ b/config/config.h.in
@@ -29,7 +29,7 @@
#cmakedefine HAVE_LOCALE_H
#cmakedefine HAVE_NL_LANGINFO_CODESET
#cmakedefine HAVE_NL_MSG_CAT_CNTR
-#cmakedefine HAVE_PUTENV
+#cmakedefine HAVE_PUTENV_S
#cmakedefine HAVE_PWD_H
#cmakedefine HAVE_READLINK
// TODO: add proper cmake check
@@ -54,7 +54,6 @@
#cmakedefine UNIX
#cmakedefine USE_FNAME_CASE
-#define FEAT_BROWSE
#define FEAT_CSCOPE
#ifndef UNIT_TESTING
diff --git a/config/versiondef.h.in b/config/versiondef.h.in
index a177e599ba..7f37ef72fb 100644
--- a/config/versiondef.h.in
+++ b/config/versiondef.h.in
@@ -5,8 +5,9 @@
#define NVIM_VERSION_MINOR @NVIM_VERSION_MINOR@
#define NVIM_VERSION_PATCH @NVIM_VERSION_PATCH@
#define NVIM_VERSION_PRERELEASE "@NVIM_VERSION_PRERELEASE@"
-#define NVIM_VERSION_BUILD "@NVIM_VERSION_BUILD@"
-#define NVIM_VERSION_COMMIT "@NVIM_VERSION_COMMIT@"
+#cmakedefine NVIM_VERSION_COMMIT "@NVIM_VERSION_COMMIT@"
+#cmakedefine NVIM_VERSION_MEDIUM "@NVIM_VERSION_MEDIUM@"
+
#define NVIM_VERSION_CFLAGS "@NVIM_VERSION_CFLAGS@"
#define NVIM_VERSION_BUILD_TYPE "@NVIM_VERSION_BUILD_TYPE@"
diff --git a/contrib/YouCompleteMe/README.md b/contrib/YouCompleteMe/README.md
index cd6393cd03..0c07440a44 100644
--- a/contrib/YouCompleteMe/README.md
+++ b/contrib/YouCompleteMe/README.md
@@ -2,7 +2,7 @@
## What is this?
-This provides the code necessary to configure vim's YCM plugin to provide C semantic support (completion, go-to-definition, etc) for the Neovim project.
+This provides the code necessary to configure vim's YCM plugin to provide C semantic support (completion, go-to-definition, etc) for developers working on the Neovim project.
## Installation
@@ -17,6 +17,6 @@ cp contrib/YouCompleteMe/ycm_extra_conf.py src/.ycm_extra_conf.py
echo .ycm_extra_conf.py >> .git/info/exclude
make
-(Add the following somewhere in your .nvimrc files)
+(Add the following somewhere in your vimrc)
autocmd FileType c nnoremap <buffer> <silent> <C-]> :YcmCompleter GoTo<cr>
```
diff --git a/contrib/local.mk.example b/contrib/local.mk.example
index 1c3ea4ab40..22aac4fda7 100644
--- a/contrib/local.mk.example
+++ b/contrib/local.mk.example
@@ -7,18 +7,25 @@
# These CFLAGS can be used in addition to those specified in CMakeLists.txt:
# CMAKE_EXTRA_FLAGS="-DCMAKE_C_FLAGS=-ftrapv -Wlogical-op"
+# By default, the jemalloc family of memory allocation functions are used.
+# Uncomment the following to instead use libc memory allocation functions.
+# CMAKE_EXTRA_FLAGS += -DENABLE_JEMALLOC=OFF
+
# Sets the build type; defaults to Debug. Valid values:
#
-# - Debug: Disables optimizations (-O0), enables debug information.
+# - Debug: Disables optimizations (-O0), enables debug information and logging.
#
-# - RelWithDebInfo: Enables all optimizations that do not interfere with
+# - Dev: Enables all optimizations that do not interfere with
# debugging (-Og if available, -O2 and -g if not).
-# Enables debug information.
+# Enables debug information and logging.
+#
+# - RelWithDebInfo: Enables optimizations (-O2) and debug information.
+# Disables logging.
#
# - MinSizeRel: Enables all -O2 optimization that do not typically
# increase code size, and performs further optimizations
# designed to reduce code size (-Os).
-# Disables debug information.
+# Disables debug information and logging.
#
# - Release: Same as RelWithDebInfo, but disables debug information.
#
diff --git a/man/nvim.1 b/man/nvim.1
index 746952c2bf..968da04d52 100644
--- a/man/nvim.1
+++ b/man/nvim.1
@@ -1,4 +1,4 @@
-.Dd October 16, 2015
+.Dd November 11, 2015
.Dt NVIM 1
.Os
.Sh NAME
@@ -173,19 +173,19 @@ See
.It Fl L Op Ar file
Alias for
.Fl r .
-.It Fl u Ar nvimrc
+.It Fl u Ar vimrc
Use
-.Ar nvimrc
+.Ar vimrc
instead of the default of
-.Pa ~/.nvimrc .
+.Pa ~/.config/nvim/init.vim .
If
-.Ar nvimrc
+.Ar vimrc
is
.Cm NORC ,
do not load any initialization files (excluding plugins),
and do not attempt to parse environment variables.
If
-.Ar nvimrc
+.Ar vimrc
is
.Cm NONE ,
loading plugins is also skipped.
@@ -195,7 +195,7 @@ See
Use
.Ar shada
instead of the default of
-.Pa ~/.nvim/shada/main.shada .
+.Pa ~/.local/share/nvim/shada/main.shada .
If
.Ar shada
is
@@ -278,7 +278,7 @@ Like
.Fl c ,
but execute
.Ar command
-before processing any nvimrc.
+before processing any vimrc.
Up to 10 instances of these can be used independently from instances of
.Fl c .
.It Fl S Op Ar session
@@ -337,10 +337,24 @@ Print version information and exit.
.Sh ENVIRONMENT
.Bl -tag -width Fl
.It Ev VIM
-Used to locate various user files, such as the user's nvimrc.
+Used to locate various user files, such as the user's init.vim.
.It Ev VIMRUNTIME
Used to locate run time files, such as on-line documentation and
syntax highlighting definitions.
+.It Ev XDG_CONFIG_HOME
+Path to use for the user-local configuration directory, see
+.Sx FILES .
+Defaults to
+.Pa ~/.config
+if not set.
+.It Ev XDG_DATA_HOME
+Like
+.Ev XDG_CONFIG_HOME ,
+but used to store data not generally edited by the user,
+namely swap, backup, and ShaDa files.
+Defaults to
+.Pa ~/.local/share/nvim
+if not set.
.It Ev VIMINIT
A string of Ex commands to be executed at startup.
For example, the command to quit is
@@ -366,20 +380,26 @@ If defined, assume the host terminal supports 24 bit colors.
Has no effect in GUIs.
.El
.Sh FILES
-.Bl -tag -width Pa
-.It Pa ~/.nvimrc , ~/.nvim/nvimrc
+.Bl -tag -width "~/.config/nvim/init.vim"
+.It Pa ~/.config/nvim/init.vim
The user-local
.Nm
configuration file.
-.It Pa ~/.nvim
+See
+.Ev XDG_CONFIG_HOME
+above.
+.It Pa ~/.config/nvim
The user-local
.Nm
-run time directory.
-.It Pa /etc/nvim/nvimrc
+configuration directory.
+See
+.Ev XDG_CONFIG_HOME
+above.
+.It Pa $VIM/sysinit.vim
The system-global
.Nm
configuration file.
-.It Pa /usr/share/nvim
+.It Pa /usr/local/share/nvim
The system-global
.Nm
runtime directory.
diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt
index 46c5cf8235..ef8e38b553 100644
--- a/runtime/CMakeLists.txt
+++ b/runtime/CMakeLists.txt
@@ -38,7 +38,7 @@ add_custom_command(OUTPUT ${GENERATED_HELP_TAGS}
COMMAND "${PROJECT_BINARY_DIR}/bin/nvim"
-u NONE
-i NONE
- -esX
+ -es
--headless
-c "helptags ++t ."
-c quit
diff --git a/runtime/autoload/getscript.vim b/runtime/autoload/getscript.vim
deleted file mode 100644
index d50bc2edc0..0000000000
--- a/runtime/autoload/getscript.vim
+++ /dev/null
@@ -1,667 +0,0 @@
-" ---------------------------------------------------------------------
-" getscript.vim
-" Author: Charles E. Campbell
-" Date: Jan 21, 2014
-" Version: 36
-" Installing: :help glvs-install
-" Usage: :help glvs
-"
-" GetLatestVimScripts: 642 1 :AutoInstall: getscript.vim
-"redraw!|call inputsave()|call input("Press <cr> to continue")|call inputrestore()
-" ---------------------------------------------------------------------
-" Initialization: {{{1
-" if you're sourcing this file, surely you can't be
-" expecting vim to be in its vi-compatible mode!
-if exists("g:loaded_getscript")
- finish
-endif
-let g:loaded_getscript= "v36"
-if &cp
- echoerr "GetLatestVimScripts is not vi-compatible; not loaded (you need to set nocp)"
- finish
-endif
-if v:version < 702
- echohl WarningMsg
- echo "***warning*** this version of getscript needs vim 7.2"
- echohl Normal
- finish
-endif
-let s:keepcpo = &cpo
-set cpo&vim
-"DechoTabOn
-
-" ---------------------------
-" Global Variables: {{{1
-" ---------------------------
-" Cygwin Detection ------- {{{2
-if !exists("g:getscript_cygwin")
- if has("win32") || has("win95") || has("win64") || has("win16")
- if &shell =~ '\%(\<bash\>\|\<zsh\>\)\%(\.exe\)\=$'
- let g:getscript_cygwin= 1
- else
- let g:getscript_cygwin= 0
- endif
- else
- let g:getscript_cygwin= 0
- endif
-endif
-
-" wget vs curl {{{2
-if !exists("g:GetLatestVimScripts_wget")
- if executable("wget")
- let g:GetLatestVimScripts_wget= "wget"
- elseif executable("curl")
- let g:GetLatestVimScripts_wget= "curl"
- else
- let g:GetLatestVimScripts_wget = 'echo "GetLatestVimScripts needs wget or curl"'
- let g:GetLatestVimScripts_options = ""
- endif
-endif
-
-" options that wget and curl require:
-if !exists("g:GetLatestVimScripts_options")
- if g:GetLatestVimScripts_wget == "wget"
- let g:GetLatestVimScripts_options= "-q -O"
- elseif g:GetLatestVimScripts_wget == "curl"
- let g:GetLatestVimScripts_options= "-s -O"
- else
- let g:GetLatestVimScripts_options= ""
- endif
-endif
-
-" by default, allow autoinstall lines to work
-if !exists("g:GetLatestVimScripts_allowautoinstall")
- let g:GetLatestVimScripts_allowautoinstall= 1
-endif
-
-" set up default scriptaddr address
-if !exists("g:GetLatestVimScripts_scriptaddr")
- let g:GetLatestVimScripts_scriptaddr = 'http://vim.sourceforge.net/script.php?script_id='
-endif
-
-"" For debugging:
-"let g:GetLatestVimScripts_wget = "echo"
-"let g:GetLatestVimScripts_options = "options"
-
-" ---------------------------------------------------------------------
-" Check If AutoInstall Capable: {{{1
-let s:autoinstall= ""
-if g:GetLatestVimScripts_allowautoinstall
-
- if (has("win32") || has("gui_win32") || has("gui_win32s") || has("win16") || has("win64") || has("win32unix") || has("win95")) && &shell != "bash"
- " windows (but not cygwin/bash)
- let s:dotvim= "vimfiles"
- if !exists("g:GetLatestVimScripts_mv")
- let g:GetLatestVimScripts_mv= "ren"
- endif
-
- else
- " unix
- let s:dotvim= ".vim"
- if !exists("g:GetLatestVimScripts_mv")
- let g:GetLatestVimScripts_mv= "mv"
- endif
- endif
-
- if exists("g:GetLatestVimScripts_autoinstalldir") && isdirectory(g:GetLatestVimScripts_autoinstalldir)
- let s:autoinstall= g:GetLatestVimScripts_autoinstalldir"
- elseif exists('$HOME') && isdirectory(expand("$HOME")."/".s:dotvim)
- let s:autoinstall= $HOME."/".s:dotvim
- endif
-" call Decho("s:autoinstall<".s:autoinstall.">")
-"else "Decho
-" call Decho("g:GetLatestVimScripts_allowautoinstall=".g:GetLatestVimScripts_allowautoinstall.": :AutoInstall: disabled")
-endif
-
-" ---------------------------------------------------------------------
-" Public Interface: {{{1
-com! -nargs=0 GetLatestVimScripts call getscript#GetLatestVimScripts()
-com! -nargs=0 GetScript call getscript#GetLatestVimScripts()
-silent! com -nargs=0 GLVS call getscript#GetLatestVimScripts()
-
-" ---------------------------------------------------------------------
-" GetLatestVimScripts: this function gets the latest versions of {{{1
-" scripts based on the list in
-" (first dir in runtimepath)/GetLatest/GetLatestVimScripts.dat
-fun! getscript#GetLatestVimScripts()
-" call Dfunc("GetLatestVimScripts() autoinstall<".s:autoinstall.">")
-
-" insure that wget is executable
- if executable(g:GetLatestVimScripts_wget) != 1
- echoerr "GetLatestVimScripts needs ".g:GetLatestVimScripts_wget." which apparently is not available on your system"
-" call Dret("GetLatestVimScripts : wget not executable/availble")
- return
- endif
-
- " insure that fnameescape() is available
- if !exists("*fnameescape")
- echoerr "GetLatestVimScripts needs fnameescape() (provided by 7.1.299 or later)"
- return
- endif
-
- " Find the .../GetLatest subdirectory under the runtimepath
- for datadir in split(&rtp,',') + ['']
- if isdirectory(datadir."/GetLatest")
-" call Decho("found directory<".datadir.">")
- let datadir= datadir . "/GetLatest"
- break
- endif
- if filereadable(datadir."GetLatestVimScripts.dat")
-" call Decho("found ".datadir."/GetLatestVimScripts.dat")
- break
- endif
- endfor
-
- " Sanity checks: readability and writability
- if datadir == ""
- echoerr 'Missing "GetLatest/" on your runtimepath - see :help glvs-dist-install'
-" call Dret("GetLatestVimScripts : unable to find a GetLatest subdirectory")
- return
- endif
- if filewritable(datadir) != 2
- echoerr "(getLatestVimScripts) Your ".datadir." isn't writable"
-" call Dret("GetLatestVimScripts : non-writable directory<".datadir.">")
- return
- endif
- let datafile= datadir."/GetLatestVimScripts.dat"
- if !filereadable(datafile)
- echoerr "Your data file<".datafile."> isn't readable"
-" call Dret("GetLatestVimScripts : non-readable datafile<".datafile.">")
- return
- endif
- if !filewritable(datafile)
- echoerr "Your data file<".datafile."> isn't writable"
-" call Dret("GetLatestVimScripts : non-writable datafile<".datafile.">")
- return
- endif
- " --------------------
- " Passed sanity checks
- " --------------------
-
-" call Decho("datadir <".datadir.">")
-" call Decho("datafile <".datafile.">")
-
- " don't let any event handlers interfere (like winmanager's, taglist's, etc)
- let eikeep = &ei
- let hlskeep = &hls
- let acdkeep = &acd
- set ei=all hls&vim noacd
-
- " Edit the datafile (ie. GetLatestVimScripts.dat):
- " 1. record current directory (origdir),
- " 2. change directory to datadir,
- " 3. split window
- " 4. edit datafile
- let origdir= getcwd()
-" call Decho("exe cd ".fnameescape(substitute(datadir,'\','/','ge')))
- exe "cd ".fnameescape(substitute(datadir,'\','/','ge'))
- split
-" call Decho("exe e ".fnameescape(substitute(datafile,'\','/','ge')))
- exe "e ".fnameescape(substitute(datafile,'\','/','ge'))
- res 1000
- let s:downloads = 0
- let s:downerrors= 0
-
- " Check on dependencies mentioned in plugins
-" call Decho(" ")
-" call Decho("searching plugins for GetLatestVimScripts dependencies")
- let lastline = line("$")
-" call Decho("lastline#".lastline)
- let firstdir = substitute(&rtp,',.*$','','')
- let plugins = split(globpath(firstdir,"plugin/**/*.vim"),'\n')
- let plugins = plugins + split(globpath(firstdir,"AsNeeded/**/*.vim"),'\n')
- let foundscript = 0
-
- " this loop updates the GetLatestVimScripts.dat file
- " with dependencies explicitly mentioned in the plugins
- " via GetLatestVimScripts: ... lines
- " It reads the plugin script at the end of the GetLatestVimScripts.dat
- " file, examines it, and then removes it.
- for plugin in plugins
-" call Decho(" ")
-" call Decho("plugin<".plugin.">")
-
- " read plugin in
- " evidently a :r creates a new buffer (the "#" buffer) that is subsequently unused -- bwiping it
- $
-" call Decho(".dependency checking<".plugin."> line$=".line("$"))
-" call Decho("..exe silent r ".fnameescape(plugin))
- exe "silent r ".fnameescape(plugin)
- exe "silent bwipe ".bufnr("#")
-
- while search('^"\s\+GetLatestVimScripts:\s\+\d\+\s\+\d\+','W') != 0
- let depscript = substitute(getline("."),'^"\s\+GetLatestVimScripts:\s\+\d\+\s\+\d\+\s\+\(.*\)$','\1','e')
- let depscriptid = substitute(getline("."),'^"\s\+GetLatestVimScripts:\s\+\(\d\+\)\s\+.*$','\1','')
- let llp1 = lastline+1
-" call Decho("..depscript<".depscript.">")
-
- " found a "GetLatestVimScripts: # #" line in the script;
- " check if its already in the datafile by searching backwards from llp1,
- " the (prior to reading in the plugin script) last line plus one of the GetLatestVimScripts.dat file,
- " for the script-id with no wrapping allowed.
- let curline = line(".")
- let noai_script = substitute(depscript,'\s*:AutoInstall:\s*','','e')
- exe llp1
- let srchline = search('^\s*'.depscriptid.'\s\+\d\+\s\+.*$','bW')
- if srchline == 0
- " this second search is taken when, for example, a 0 0 scriptname is to be skipped over
- let srchline= search('\<'.noai_script.'\>','bW')
- endif
-" call Decho("..noai_script<".noai_script."> depscriptid#".depscriptid." srchline#".srchline." curline#".line(".")." lastline#".lastline)
-
- if srchline == 0
- " found a new script to permanently include in the datafile
- let keep_rega = @a
- let @a = substitute(getline(curline),'^"\s\+GetLatestVimScripts:\s\+','','')
- echomsg "Appending <".@a."> to ".datafile." for ".depscript
-" call Decho("..Appending <".@a."> to ".datafile." for ".depscript)
- exe lastline."put a"
- let @a = keep_rega
- let lastline = llp1
- let curline = curline + 1
- let foundscript = foundscript + 1
-" else " Decho
-" call Decho("..found <".noai_script."> (already in datafile at line#".srchline.")")
- endif
-
- let curline = curline + 1
- exe curline
- endwhile
-
- " llp1: last line plus one
- let llp1= lastline + 1
-" call Decho(".deleting lines: ".llp1.",$d")
- exe "silent! ".llp1.",$d"
- endfor
-" call Decho("--- end dependency checking loop --- foundscript=".foundscript)
-" call Decho(" ")
-" call Dredir("BUFFER TEST (GetLatestVimScripts 1)","ls!")
-
- if foundscript == 0
- setlocal nomod
- endif
-
- " --------------------------------------------------------------------
- " Check on out-of-date scripts using GetLatest/GetLatestVimScripts.dat
- " --------------------------------------------------------------------
-" call Decho("begin: checking out-of-date scripts using datafile<".datafile.">")
- setlocal lz
- 1
-" /^-----/,$g/^\s*\d/call Decho(getline("."))
- 1
- /^-----/,$g/^\s*\d/call s:GetOneScript()
-" call Decho("--- end out-of-date checking --- ")
-
- " Final report (an echomsg)
- try
- silent! ?^-------?
- catch /^Vim\%((\a\+)\)\=:E114/
-" call Dret("GetLatestVimScripts : nothing done!")
- return
- endtry
- exe "norm! kz\<CR>"
- redraw!
- let s:msg = ""
- if s:downloads == 1
- let s:msg = "Downloaded one updated script to <".datadir.">"
- elseif s:downloads == 2
- let s:msg= "Downloaded two updated scripts to <".datadir.">"
- elseif s:downloads > 1
- let s:msg= "Downloaded ".s:downloads." updated scripts to <".datadir.">"
- else
- let s:msg= "Everything was already current"
- endif
- if s:downerrors > 0
- let s:msg= s:msg." (".s:downerrors." downloading errors)"
- endif
- echomsg s:msg
- " save the file
- if &mod
- silent! w!
- endif
- q!
-
- " restore events and current directory
- exe "cd ".fnameescape(substitute(origdir,'\','/','ge'))
- let &ei = eikeep
- let &hls = hlskeep
- let &acd = acdkeep
- setlocal nolz
-" call Dredir("BUFFER TEST (GetLatestVimScripts 2)","ls!")
-" call Dret("GetLatestVimScripts : did ".s:downloads." downloads")
-endfun
-
-" ---------------------------------------------------------------------
-" GetOneScript: (Get Latest Vim Script) this function operates {{{1
-" on the current line, interpreting two numbers and text as
-" ScriptID, SourceID, and Filename.
-" It downloads any scripts that have newer versions from vim.sourceforge.net.
-fun! s:GetOneScript(...)
-" call Dfunc("GetOneScript()")
-
- " set options to allow progress to be shown on screen
- let rega= @a
- let t_ti= &t_ti
- let t_te= &t_te
- let rs = &rs
- set t_ti= t_te= nors
-
- " put current line on top-of-screen and interpret it into
- " a script identifer : used to obtain webpage
- " source identifier : used to identify current version
- " and an associated comment: used to report on what's being considered
- if a:0 >= 3
- let scriptid = a:1
- let srcid = a:2
- let fname = a:3
- let cmmnt = ""
-" call Decho("scriptid<".scriptid.">")
-" call Decho("srcid <".srcid.">")
-" call Decho("fname <".fname.">")
- else
- let curline = getline(".")
- if curline =~ '^\s*#'
- let @a= rega
-" call Dret("GetOneScript : skipping a pure comment line")
- return
- endif
- let parsepat = '^\s*\(\d\+\)\s\+\(\d\+\)\s\+\(.\{-}\)\(\s*#.*\)\=$'
- try
- let scriptid = substitute(curline,parsepat,'\1','e')
- catch /^Vim\%((\a\+)\)\=:E486/
- let scriptid= 0
- endtry
- try
- let srcid = substitute(curline,parsepat,'\2','e')
- catch /^Vim\%((\a\+)\)\=:E486/
- let srcid= 0
- endtry
- try
- let fname= substitute(curline,parsepat,'\3','e')
- catch /^Vim\%((\a\+)\)\=:E486/
- let fname= ""
- endtry
- try
- let cmmnt= substitute(curline,parsepat,'\4','e')
- catch /^Vim\%((\a\+)\)\=:E486/
- let cmmnt= ""
- endtry
-" call Decho("curline <".curline.">")
-" call Decho("parsepat<".parsepat.">")
-" call Decho("scriptid<".scriptid.">")
-" call Decho("srcid <".srcid.">")
-" call Decho("fname <".fname.">")
- endif
-
- " plugin author protection from downloading his/her own scripts atop their latest work
- if scriptid == 0 || srcid == 0
- " When looking for :AutoInstall: lines, skip scripts that have 0 0 scriptname
- let @a= rega
-" call Dret("GetOneScript : skipping a scriptid==srcid==0 line")
- return
- endif
-
- let doautoinstall= 0
- if fname =~ ":AutoInstall:"
-" call Decho("case AutoInstall: fname<".fname.">")
- let aicmmnt= substitute(fname,'\s\+:AutoInstall:\s\+',' ','')
-" call Decho("aicmmnt<".aicmmnt."> s:autoinstall=".s:autoinstall)
- if s:autoinstall != ""
- let doautoinstall = g:GetLatestVimScripts_allowautoinstall
- endif
- else
- let aicmmnt= fname
- endif
-" call Decho("aicmmnt<".aicmmnt.">: doautoinstall=".doautoinstall)
-
- exe "norm z\<CR>"
- redraw!
-" call Decho('considering <'.aicmmnt.'> scriptid='.scriptid.' srcid='.srcid)
- echo 'considering <'.aicmmnt.'> scriptid='.scriptid.' srcid='.srcid
-
- " grab a copy of the plugin's vim.sourceforge.net webpage
- let scriptaddr = g:GetLatestVimScripts_scriptaddr.scriptid
- let tmpfile = tempname()
- let v:errmsg = ""
-
- " make up to three tries at downloading the description
- let itry= 1
- while itry <= 3
-" call Decho(".try#".itry." to download description of <".aicmmnt."> with addr=".scriptaddr)
- if has("win32") || has("win16") || has("win95")
-" call Decho(".new|exe silent r!".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".shellescape(tmpfile).' '.shellescape(scriptaddr)."|bw!")
- new|exe "silent r!".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".shellescape(tmpfile).' '.shellescape(scriptaddr)|bw!
- else
-" call Decho(".exe silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".shellescape(tmpfile)." ".shellescape(scriptaddr))
- exe "silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".shellescape(tmpfile)." ".shellescape(scriptaddr)
- endif
- if itry == 1
- exe "silent vsplit ".fnameescape(tmpfile)
- else
- silent! e %
- endif
- setlocal bh=wipe
-
- " find the latest source-id in the plugin's webpage
- silent! 1
- let findpkg= search('Click on the package to download','W')
- if findpkg > 0
- break
- endif
- let itry= itry + 1
- endwhile
-" call Decho(" --- end downloading tries while loop --- itry=".itry)
-
- " testing: did finding "Click on the package..." fail?
- if findpkg == 0 || itry >= 4
- silent q!
- call delete(tmpfile)
- " restore options
- let &t_ti = t_ti
- let &t_te = t_te
- let &rs = rs
- let s:downerrors = s:downerrors + 1
-" call Decho("***warning*** couldn'".'t find "Click on the package..." in description page for <'.aicmmnt.">")
- echomsg "***warning*** couldn'".'t find "Click on the package..." in description page for <'.aicmmnt.">"
-" call Dret("GetOneScript : srch for /Click on the package/ failed")
- let @a= rega
- return
- endif
-" call Decho('found "Click on the package to download"')
-
- let findsrcid= search('src_id=','W')
- if findsrcid == 0
- silent q!
- call delete(tmpfile)
- " restore options
- let &t_ti = t_ti
- let &t_te = t_te
- let &rs = rs
- let s:downerrors = s:downerrors + 1
-" call Decho("***warning*** couldn'".'t find "src_id=" in description page for <'.aicmmnt.">")
- echomsg "***warning*** couldn'".'t find "src_id=" in description page for <'.aicmmnt.">"
- let @a= rega
-" call Dret("GetOneScript : srch for /src_id/ failed")
- return
- endif
-" call Decho('found "src_id=" in description page')
-
- let srcidpat = '^\s*<td class.*src_id=\(\d\+\)">\([^<]\+\)<.*$'
- let latestsrcid= substitute(getline("."),srcidpat,'\1','')
- let sname = substitute(getline("."),srcidpat,'\2','') " script name actually downloaded
-" call Decho("srcidpat<".srcidpat."> latestsrcid<".latestsrcid."> sname<".sname.">")
- silent q!
- call delete(tmpfile)
-
- " convert the strings-of-numbers into numbers
- let srcid = srcid + 0
- let latestsrcid = latestsrcid + 0
-" call Decho("srcid=".srcid." latestsrcid=".latestsrcid." sname<".sname.">")
-
- " has the plugin's most-recent srcid increased, which indicates that it has been updated
- if latestsrcid > srcid
-" call Decho("[latestsrcid=".latestsrcid."] <= [srcid=".srcid."]: need to update <".sname.">")
-
- let s:downloads= s:downloads + 1
- if sname == bufname("%")
- " GetLatestVimScript has to be careful about downloading itself
- let sname= "NEW_".sname
- endif
-
- " -----------------------------------------------------------------------------
- " the plugin has been updated since we last obtained it, so download a new copy
- " -----------------------------------------------------------------------------
-" call Decho(".downloading new <".sname.">")
- echomsg ".downloading new <".sname.">"
- if has("win32") || has("win16") || has("win95")
-" call Decho(".new|exe silent r!".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".shellescape(sname)." ".shellescape('http://vim.sourceforge.net/scripts/download_script.php?src_id='.latestsrcid)."|q")
- new|exe "silent r!".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".shellescape(sname)." ".shellescape('http://vim.sourceforge.net/scripts/download_script.php?src_id='.latestsrcid)|q
- else
-" call Decho(".exe silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".shellescape(sname)." ".shellescape('http://vim.sourceforge.net/scripts/download_script.php?src_id='))
- exe "silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".shellescape(sname)." ".shellescape('http://vim.sourceforge.net/scripts/download_script.php?src_id=').latestsrcid
- endif
-
- " --------------------------------------------------------------------------
- " AutoInstall: only if doautoinstall has been requested by the plugin itself
- " --------------------------------------------------------------------------
-" call Decho("checking if plugin requested autoinstall: doautoinstall=".doautoinstall)
- if doautoinstall
-" call Decho(" ")
-" call Decho("Autoinstall: getcwd<".getcwd()."> filereadable(".sname.")=".filereadable(sname))
- if filereadable(sname)
-" call Decho("<".sname."> is readable")
-" call Decho("exe silent !".g:GetLatestVimScripts_mv." ".shellescape(sname)." ".shellescape(s:autoinstall))
- exe "silent !".g:GetLatestVimScripts_mv." ".shellescape(sname)." ".shellescape(s:autoinstall)
- let curdir = fnameescape(substitute(getcwd(),'\','/','ge'))
- let installdir= curdir."/Installed"
- if !isdirectory(installdir)
- call mkdir(installdir)
- endif
-" call Decho("curdir<".curdir."> installdir<".installdir.">")
-" call Decho("exe cd ".fnameescape(s:autoinstall))
- exe "cd ".fnameescape(s:autoinstall)
-
- " determine target directory for moves
- let firstdir= substitute(&rtp,',.*$','','')
- let pname = substitute(sname,'\..*','.vim','')
-" call Decho("determine tgtdir: is <".firstdir.'/AsNeeded/'.pname." readable?")
- if filereadable(firstdir.'/AsNeeded/'.pname)
- let tgtdir= "AsNeeded"
- else
- let tgtdir= "plugin"
- endif
-" call Decho("tgtdir<".tgtdir."> pname<".pname.">")
-
- " decompress
- if sname =~ '\.bz2$'
-" call Decho("decompress: attempt to bunzip2 ".sname)
- exe "sil !bunzip2 ".shellescape(sname)
- let sname= substitute(sname,'\.bz2$','','')
-" call Decho("decompress: new sname<".sname."> after bunzip2")
- elseif sname =~ '\.gz$'
-" call Decho("decompress: attempt to gunzip ".sname)
- exe "sil !gunzip ".shellescape(sname)
- let sname= substitute(sname,'\.gz$','','')
-" call Decho("decompress: new sname<".sname."> after gunzip")
- elseif sname =~ '\.xz$'
-" call Decho("decompress: attempt to unxz ".sname)
- exe "sil !unxz ".shellescape(sname)
- let sname= substitute(sname,'\.xz$','','')
-" call Decho("decompress: new sname<".sname."> after unxz")
- else
-" call Decho("no decompression needed")
- endif
-
- " distribute archive(.zip, .tar, .vba, ...) contents
- if sname =~ '\.zip$'
-" call Decho("dearchive: attempt to unzip ".sname)
- exe "silent !unzip -o ".shellescape(sname)
- elseif sname =~ '\.tar$'
-" call Decho("dearchive: attempt to untar ".sname)
- exe "silent !tar -xvf ".shellescape(sname)
- elseif sname =~ '\.tgz$'
-" call Decho("dearchive: attempt to untar+gunzip ".sname)
- exe "silent !tar -zxvf ".shellescape(sname)
- elseif sname =~ '\.taz$'
-" call Decho("dearchive: attempt to untar+uncompress ".sname)
- exe "silent !tar -Zxvf ".shellescape(sname)
- elseif sname =~ '\.tbz$'
-" call Decho("dearchive: attempt to untar+bunzip2 ".sname)
- exe "silent !tar -jxvf ".shellescape(sname)
- elseif sname =~ '\.txz$'
-" call Decho("dearchive: attempt to untar+xz ".sname)
- exe "silent !tar -Jxvf ".shellescape(sname)
- elseif sname =~ '\.vba$'
-" call Decho("dearchive: attempt to handle a vimball: ".sname)
- silent 1split
- if exists("g:vimball_home")
- let oldvimballhome= g:vimball_home
- endif
- let g:vimball_home= s:autoinstall
- exe "silent e ".fnameescape(sname)
- silent so %
- silent q
- if exists("oldvimballhome")
- let g:vimball_home= oldvimballhome
- else
- unlet g:vimball_home
- endif
- else
-" call Decho("no dearchiving needed")
- endif
-
- " ---------------------------------------------
- " move plugin to plugin/ or AsNeeded/ directory
- " ---------------------------------------------
- if sname =~ '.vim$'
-" call Decho("dearchive: attempt to simply move ".sname." to ".tgtdir)
- exe "silent !".g:GetLatestVimScripts_mv." ".shellescape(sname)." ".tgtdir
- else
-" call Decho("dearchive: move <".sname."> to installdir<".installdir.">")
- exe "silent !".g:GetLatestVimScripts_mv." ".shellescape(sname)." ".installdir
- endif
- if tgtdir != "plugin"
-" call Decho("exe silent !".g:GetLatestVimScripts_mv." plugin/".shellescape(pname)." ".tgtdir)
- exe "silent !".g:GetLatestVimScripts_mv." plugin/".shellescape(pname)." ".tgtdir
- endif
-
- " helptags step
- let docdir= substitute(&rtp,',.*','','e')."/doc"
-" call Decho("helptags: docdir<".docdir.">")
- exe "helptags ".fnameescape(docdir)
- exe "cd ".fnameescape(curdir)
- endif
- if fname !~ ':AutoInstall:'
- let modline=scriptid." ".latestsrcid." :AutoInstall: ".fname.cmmnt
- else
- let modline=scriptid." ".latestsrcid." ".fname.cmmnt
- endif
- else
- let modline=scriptid." ".latestsrcid." ".fname.cmmnt
- endif
-
- " update the data in the <GetLatestVimScripts.dat> file
- call setline(line("."),modline)
-" call Decho("update data in ".expand("%")."#".line(".").": modline<".modline.">")
-" else " Decho
-" call Decho("[latestsrcid=".latestsrcid."] <= [srcid=".srcid."], no need to update")
- endif
-
- " restore options
- let &t_ti = t_ti
- let &t_te = t_te
- let &rs = rs
- let @a = rega
-" call Dredir("BUFFER TEST (GetOneScript)","ls!")
-
-" call Dret("GetOneScript")
-endfun
-
-" ---------------------------------------------------------------------
-" Restore Options: {{{1
-let &cpo= s:keepcpo
-unlet s:keepcpo
-
-" ---------------------------------------------------------------------
-" Modelines: {{{1
-" vim: ts=8 sts=2 fdm=marker nowrap
diff --git a/runtime/autoload/msgpack.vim b/runtime/autoload/msgpack.vim
new file mode 100644
index 0000000000..e6022922fe
--- /dev/null
+++ b/runtime/autoload/msgpack.vim
@@ -0,0 +1,820 @@
+if exists('g:loaded_msgpack_autoload')
+ finish
+endif
+let g:loaded_msgpack_autoload = 1
+
+""
+" Check that given value is an integer. Respects |msgpack-special-dict|.
+function msgpack#is_int(v) abort
+ return type(a:v) == type(0) || (
+ \type(a:v) == type({}) && get(a:v, '_TYPE') is# v:msgpack_types.integer)
+endfunction
+
+""
+" Check that given value is an unsigned integer. Respects
+" |msgpack-special-dict|.
+function msgpack#is_uint(v) abort
+ return msgpack#is_int(a:v) && (type(a:v) == type(0)
+ \? a:v >= 0
+ \: a:v._VAL[0] > 0)
+endfunction
+
+""
+" True if s:msgpack_init_python() function was already run.
+let s:msgpack_python_initialized = 0
+
+""
+" Cached return of s:msgpack_init_python() used when
+" s:msgpack_python_initialized is true.
+let s:msgpack_python_type = 0
+
+""
+" Create Python functions that are necessary for work. Also defines functions
+" s:msgpack_dict_strftime(format, timestamp) and s:msgpack_dict_strptime(format,
+" string).
+"
+" @return Zero in case no Python is available, empty string if Python-2 is
+" available and string `"3"` if Python-3 is available.
+function s:msgpack_init_python() abort
+ if s:msgpack_python_initialized
+ return s:msgpack_python_type
+ endif
+ let s:msgpack_python_initialized = 1
+ for suf in ['', '3']
+ try
+ execute 'python' . suf
+ \. "def shada_dict_strftime():\n"
+ \. " import datetime\n"
+ \. " import vim\n"
+ \. " fmt = vim.eval('a:format')\n"
+ \. " timestamp = vim.eval('a:timestamp')\n"
+ \. " timestamp = [int(v) for v in timestamp['_VAL']]\n"
+ \. " timestamp = timestamp[0] * (timestamp[1] << 62\n"
+ \. " | timestamp[2] << 31\n"
+ \. " | timestamp[3])\n"
+ \. " time = datetime.datetime.fromtimestamp(timestamp)\n"
+ \. " return time.strftime(fmt)\n"
+ \. "def shada_dict_strptime():\n"
+ \. " import datetime\n"
+ \. " import vim\n"
+ \. " fmt = vim.eval('a:format')\n"
+ \. " timestr = vim.eval('a:string')\n"
+ \. " timestamp = datetime.datetime.strptime(timestr, fmt)\n"
+ \. " timestamp = int(timestamp.timestamp())\n"
+ \. " if timestamp > 2 ** 31:\n"
+ \. " tsabs = abs(timestamp)"
+ \. " return ('{\"_TYPE\": v:msgpack_types.integer,'\n"
+ \. " + '\"_VAL\": [{sign},{v1},{v2},{v3}]}').format(\n"
+ \. " sign=1 if timestamp >= 0 else -1,\n"
+ \. " v1=((tsabs >> 62) & 0x3),\n"
+ \. " v2=((tsabs >> 31) & (2 ** 31 - 1)),\n"
+ \. " v3=(tsabs & (2 ** 31 - 1)))\n"
+ \. " else:\n"
+ \. " return str(timestamp)\n"
+ execute "function s:msgpack_dict_strftime(format, timestamp) abort\n"
+ \. " return py" . suf . "eval('shada_dict_strftime()')\n"
+ \. "endfunction\n"
+ \. "function s:msgpack_dict_strptime(format, string)\n"
+ \. " return eval(py" . suf . "eval('shada_dict_strptime()'))\n"
+ \. "endfunction\n"
+ let s:msgpack_python_type = suf
+ return suf
+ catch
+ continue
+ endtry
+ endfor
+
+ ""
+ " strftime() function for |msgpack-special-dict| values.
+ "
+ " @param[in] format String according to which time should be formatted.
+ " @param[in] timestamp Timestamp (seconds since epoch) to format.
+ "
+ " @return Formatted timestamp.
+ "
+ " @warning Without +python or +python3 this function does not work correctly.
+ " The VimL code contains “reference” implementation which does not
+ " really work because of precision loss.
+ function s:msgpack_dict_strftime(format, timestamp)
+ return msgpack#strftime(a:format, +msgpack#int_dict_to_str(a:timestamp))
+ endfunction
+
+ ""
+ " Function that parses given string according to given format.
+ "
+ " @param[in] format String according to which string was formatted.
+ " @param[in] string Time formatted according to format.
+ "
+ " @return Timestamp.
+ "
+ " @warning Without +python or +python3 this function is able to work only with
+ " 31-bit (32-bit signed) timestamps that have format
+ " `%Y-%m-%dT%H:%M:%S`.
+ function s:msgpack_dict_strptime(format, string)
+ let fmt = '%Y-%m-%dT%H:%M:%S'
+ if a:format isnot# fmt
+ throw 'notimplemented-format:Only ' . fmt . ' format is supported'
+ endif
+ let match = matchlist(a:string,
+ \'\v\C^(\d+)\-(\d+)\-(\d+)T(\d+)\:(\d+)\:(\d+)$')
+ if empty(match)
+ throw 'invalid-string:Given string does not match format ' . a:format
+ endif
+ call map(match, 'str2nr(v:val, 10)')
+ let [year, month, day, hour, minute, second] = match[1:6]
+ " Bisection start and end:
+ "
+ " Start: 365 days in year, 28 days in month, -12 hours tz offset.
+ let bisect_ts_start = (((((year - 1970) * 365
+ \+ (month - 1) * 28
+ \+ (day - 1)) * 24
+ \+ hour - 12) * 60
+ \+ minute) * 60
+ \+ second)
+ if bisect_ts_start < 0
+ let bisect_ts_start = 0
+ endif
+ let start_string = strftime(fmt, bisect_ts_start)
+ if start_string is# a:string
+ return bisect_ts_start
+ endif
+ " End: 366 days in year, 31 day in month, +14 hours tz offset.
+ let bisect_ts_end = (((((year - 1970) * 366
+ \+ (month - 1) * 31
+ \+ (day - 1)) * 24
+ \+ hour + 14) * 60
+ \+ minute) * 60
+ \+ second)
+ let end_string = strftime(fmt, bisect_ts_end)
+ if end_string is# a:string
+ return bisect_ts_end
+ endif
+ if start_string ># end_string
+ throw 'internal-start-gt:Internal error: start > end'
+ endif
+ if start_string is# end_string
+ throw printf('internal-start-eq:Internal error: '
+ \. 'start(%u)==end(%u), but start(%s)!=string(%s)',
+ \bisect_ts_start, bisect_ts_end,
+ \string(start_string), string(a:string))
+ endif
+ if start_string ># a:string
+ throw 'internal-start-string:Internal error: start > string'
+ endif
+ if end_string <# a:string
+ throw 'internal-end-string:Internal error: end < string'
+ endif
+ while 1
+ let bisect_ts_middle = (bisect_ts_start/2) + (bisect_ts_end/2)
+ let middle_string = strftime(fmt, bisect_ts_middle)
+ if a:string is# middle_string
+ return bisect_ts_middle
+ elseif a:string ># middle_string
+ if bisect_ts_middle == bisect_ts_start
+ let bisect_ts_start += 1
+ else
+ let bisect_ts_start = bisect_ts_middle
+ endif
+ else
+ if bisect_ts_middle == bisect_ts_end
+ let bisect_ts_end -= 1
+ else
+ let bisect_ts_end = bisect_ts_middle
+ endif
+ endif
+ if bisect_ts_start >= bisect_ts_end
+ throw 'not-found:Unable to find timestamp'
+ endif
+ endwhile
+ endfunction
+
+ return 0
+endfunction
+
+""
+" Wrapper for strftime() that respects |msgpack-special-dict|. May actually use
+" non-standard strftime() implementations for |msgpack-special-dict| values.
+"
+" @param[in] format Format string.
+" @param[in] timestamp Formatted timestamp.
+function msgpack#strftime(format, timestamp) abort
+ if type(a:timestamp) == type({})
+ call s:msgpack_init_python()
+ return s:msgpack_dict_strftime(a:format, a:timestamp)
+ else
+ return strftime(a:format, a:timestamp)
+ endif
+endfunction
+
+""
+" Parse string according to the format.
+"
+" Requires +python available. If it is not then only supported format is
+" `%Y-%m-%dT%H:%M:%S` because this is the format used by ShaDa plugin. Also in
+" this case bisection will be used (timestamps tried with strftime() up until
+" result matches the string) and only 31-bit (signed 32-bit: with negative
+" timestamps being useless this leaves 31 bits) timestamps will be supported.
+"
+" @param[in] format Time format.
+" @param[in] string Parsed time string. Must match given format.
+"
+" @return Timestamp. Possibly as |msgpack-special-dict|.
+function msgpack#strptime(format, string) abort
+ call s:msgpack_init_python()
+ return s:msgpack_dict_strptime(a:format, a:string)
+endfunction
+
+let s:MSGPACK_HIGHEST_BIT = 1
+let s:MSGPACK_HIGHEST_BIT_NR = 0
+while s:MSGPACK_HIGHEST_BIT * 2 > 0
+ let s:MSGPACK_HIGHEST_BIT = s:MSGPACK_HIGHEST_BIT * 2
+ let s:MSGPACK_HIGHEST_BIT_NR += 1
+endwhile
+
+""
+" Shift given number by given amount of bits
+function s:shift(n, s) abort
+ if a:s == 0
+ return a:n
+ elseif a:s < 0
+ let ret = a:n
+ for _ in range(-a:s)
+ let ret = ret / 2
+ endfor
+ return ret
+ else
+ let ret = a:n
+ for i in range(a:s)
+ let new_ret = ret * 2
+ if new_ret < ret
+ " Overflow: remove highest bit
+ let ret = xor(s:MSGPACK_HIGHEST_BIT, ret) * 2
+ endif
+ let ret = new_ret
+ endfor
+ return ret
+ endif
+endfunction
+
+let s:msgpack_mask_cache = {
+ \s:MSGPACK_HIGHEST_BIT_NR : s:MSGPACK_HIGHEST_BIT - 1}
+
+""
+" Apply a mask where first m bits are ones and other are zeroes to a given
+" number
+function s:mask1(n, m) abort
+ if a:m > s:MSGPACK_HIGHEST_BIT_NR + 1
+ let m = s:MSGPACK_HIGHEST_BIT_NR + 1
+ else
+ let m = a:m
+ endif
+ if !has_key(s:msgpack_mask_cache, m)
+ let p = 0
+ for _ in range(m)
+ let p = p * 2 + 1
+ endfor
+ let s:msgpack_mask_cache[m] = p
+ endif
+ return and(a:n, s:msgpack_mask_cache[m])
+endfunction
+
+""
+" Convert |msgpack-special-dict| that represents integer value to a string. Uses
+" hexadecimal representation starting with 0x because it is the easiest to
+" convert to.
+function msgpack#int_dict_to_str(v) abort
+ let v = a:v._VAL
+ " 64-bit number:
+ " 0000000001111111111222222222233333333334444444444555555555566666
+ " 1234567890123456789012345678901234567890123456789012345678901234
+ " Split in _VAL:
+ " 0000000001111111111222222222233 3333333344444444445555555555666 66
+ " 1234567890123456789012345678901 2345678901234567890123456789012 34
+ " Split by hex digits:
+ " 0000 0000 0111 1111 1112 2222 2222 2333 3333 3334 4444 4444 4555 5555 5556 6666
+ " 1234 5678 9012 3456 7890 1234 5678 9012 3456 7890 1234 5678 9012 3456 7890 1234
+ "
+ " Total split:
+ " _VAL[3] _VAL[2] _VAL[1]
+ " ______________________________________ _______________________________________ __
+ " 0000 0000 0111 1111 1112 2222 2222 233 3 3333 3334 4444 4444 4555 5555 5556 66 66
+ " 1234 5678 9012 3456 7890 1234 5678 901 2 3456 7890 1234 5678 9012 3456 7890 12 34
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^
+ " g4 g3 g2 g1
+ " ********************************** *** * ********************************** ** **
+ " 1 2 3 4 5 6
+ " 1: s:mask1(v[3], 28): first 28 bits of _VAL[3]
+ " 2: s:shift(v[3], -28): last 3 bits of _VAL[3]
+ " 3: s:mask1(v[2], 1): first bit of _VAL[2]
+ " 4: s:mask1(s:shift(v[2], -1), 28): bits 2 .. 29 of _VAL[2]
+ " 5: s:shift(v[2], -29): last 2 bits of _VAL[2]
+ " 6: s:shift(v[1], 2): _VAL[1]
+ let g4 = printf('%07x', s:mask1(v[3], 28))
+ let g3 = printf('%01x', or(s:shift(v[3], -28), s:shift(s:mask1(v[2], 1), 3)))
+ let g2 = printf('%07x', s:mask1(s:shift(v[2], -1), 28))
+ let g1 = printf('%01x', or(s:shift(v[2], -29), s:shift(v[1], 2)))
+ return ((v[0] < 0 ? '-' : '') . '0x' . g1 . g2 . g3 . g4)
+endfunction
+
+""
+" True boolean value.
+let g:msgpack#true = {'_TYPE': v:msgpack_types.boolean, '_VAL': 1}
+lockvar! g:msgpack#true
+
+""
+" False boolean value.
+let g:msgpack#false = {'_TYPE': v:msgpack_types.boolean, '_VAL': 0}
+lockvar! g:msgpack#false
+
+""
+" NIL value.
+let g:msgpack#nil = {'_TYPE': v:msgpack_types.nil, '_VAL': 0}
+lockvar! g:msgpack#nil
+
+""
+" Deduce type of |msgpack-special-dict|.
+"
+" @return zero if given dictionary is not special or name of the key in
+" v:msgpack_types dictionary.
+function msgpack#special_type(v) abort
+ if type(a:v) != type({}) || !has_key(a:v, '_TYPE')
+ return 0
+ endif
+ for [k, v] in items(v:msgpack_types)
+ if a:v._TYPE is v
+ return k
+ endif
+ endfor
+ return 0
+endfunction
+
+""
+" Mapping that maps type() output to type names.
+let s:MSGPACK_STANDARD_TYPES = {
+ \type(0): 'integer',
+ \type(0.0): 'float',
+ \type(''): 'binary',
+ \type([]): 'array',
+ \type({}): 'map',
+\}
+
+""
+" Deduce type of one of items returned by msgpackparse().
+"
+" @return Name of a key in v:msgpack_types.
+function msgpack#type(v) abort
+ let special_type = msgpack#special_type(a:v)
+ if special_type is 0
+ return s:MSGPACK_STANDARD_TYPES[type(a:v)]
+ endif
+ return special_type
+endfunction
+
+""
+" Dump nil value.
+function s:msgpack_dump_nil(v) abort
+ return 'NIL'
+endfunction
+
+""
+" Dump boolean value.
+function s:msgpack_dump_boolean(v) abort
+ return a:v._VAL ? 'TRUE' : 'FALSE'
+endfunction
+
+""
+" Dump integer msgpack value.
+function s:msgpack_dump_integer(v) abort
+ if type(a:v) == type({})
+ return msgpack#int_dict_to_str(a:v)
+ else
+ return string(a:v)
+ endif
+endfunction
+
+""
+" Dump floating-point value.
+function s:msgpack_dump_float(v) abort
+ return string(type(a:v) == type({}) ? a:v._VAL : a:v)
+endfunction
+
+""
+" Dump |msgpack-special-dict| that represents a string. If any additional
+" parameter is given then it dumps binary string.
+function s:msgpack_dump_string(v, ...) abort
+ let ret = [a:0 ? '"' : '="']
+ for v in a:v._VAL
+ call add(
+ \ret,
+ \substitute(
+ \substitute(v, '["\\]', '\\\0', 'g'),
+ \'\n', '\\0', 'g'))
+ call add(ret, '\n')
+ endfor
+ let ret[-1] = '"'
+ return join(ret, '')
+endfunction
+
+""
+" Dump binary string.
+function s:msgpack_dump_binary(v) abort
+ if type(a:v) == type({})
+ return s:msgpack_dump_string(a:v, 1)
+ else
+ return s:msgpack_dump_string({'_VAL': split(a:v, "\n", 1)}, 1)
+ endif
+endfunction
+
+""
+" Dump array value.
+function s:msgpack_dump_array(v) abort
+ let val = type(a:v) == type({}) ? a:v._VAL : a:v
+ return '[' . join(map(val[:], 'msgpack#string(v:val)'), ', ') . ']'
+endfunction
+
+""
+" Dump dictionary value.
+function s:msgpack_dump_map(v) abort
+ let ret = ['{']
+ if msgpack#special_type(a:v) is 0
+ for [k, v] in items(a:v)
+ let ret += [s:msgpack_dump_string({'_VAL': split(k, "\n", 1)}),
+ \': ',
+ \msgpack#string(v),
+ \', ']
+ unlet v
+ endfor
+ if !empty(a:v)
+ call remove(ret, -1)
+ endif
+ else
+ for [k, v] in sort(copy(a:v._VAL))
+ let ret += [msgpack#string(k),
+ \': ',
+ \msgpack#string(v),
+ \', ']
+ unlet k
+ unlet v
+ endfor
+ if !empty(a:v._VAL)
+ call remove(ret, -1)
+ endif
+ endif
+ let ret += ['}']
+ return join(ret, '')
+endfunction
+
+""
+" Dump extension value.
+function s:msgpack_dump_ext(v) abort
+ return printf('+(%i)%s', a:v._VAL[0],
+ \s:msgpack_dump_string({'_VAL': a:v._VAL[1]}, 1))
+endfunction
+
+""
+" Convert msgpack object to a string, like string() function does. Result of the
+" conversion may be passed to msgpack#eval().
+function msgpack#string(v) abort
+ if type(a:v) == type({})
+ let type = msgpack#special_type(a:v)
+ if type is 0
+ let type = 'map'
+ endif
+ else
+ let type = get(s:MSGPACK_STANDARD_TYPES, type(a:v), 0)
+ if type is 0
+ throw printf('msgpack:invtype: Unable to convert value %s', string(a:v))
+ endif
+ endif
+ return s:msgpack_dump_{type}(a:v)
+endfunction
+
+""
+" Copy msgpack object like deepcopy() does, but leave types intact
+function msgpack#deepcopy(obj) abort
+ if type(a:obj) == type([])
+ return map(copy(a:obj), 'msgpack#deepcopy(v:val)')
+ elseif type(a:obj) == type({})
+ let special_type = msgpack#special_type(a:obj)
+ if special_type is 0
+ return map(copy(a:obj), 'msgpack#deepcopy(v:val)')
+ else
+ return {
+ \'_TYPE': v:msgpack_types[special_type],
+ \'_VAL': msgpack#deepcopy(a:obj._VAL)
+ \}
+ endif
+ else
+ return copy(a:obj)
+ endif
+endfunction
+
+""
+" Convert an escaped character to needed value
+function s:msgpack_eval_str_sub(ch) abort
+ if a:ch is# 'n'
+ return '", "'
+ elseif a:ch is# '0'
+ return '\n'
+ else
+ return '\' . a:ch
+ endif
+endfunction
+
+let s:MSGPACK_SPECIAL_OBJECTS = {
+ \'NIL': '{''_TYPE'': v:msgpack_types.nil, ''_VAL'': 0}',
+ \'TRUE': '{''_TYPE'': v:msgpack_types.boolean, ''_VAL'': 1}',
+ \'FALSE': '{''_TYPE'': v:msgpack_types.boolean, ''_VAL'': 0}',
+ \'nan': '(-(1.0/0.0-1.0/0.0))',
+ \'inf': '(1.0/0.0)',
+\}
+
+""
+" Convert msgpack object dumped by msgpack#string() to a VimL object suitable
+" for msgpackdump().
+"
+" @param[in] s String to evaluate.
+" @param[in] special_objs Additional special objects, in the same format as
+" s:MSGPACK_SPECIAL_OBJECTS.
+"
+" @return Any value that msgpackparse() may return.
+function msgpack#eval(s, special_objs) abort
+ let s = a:s
+ let expr = []
+ let context = []
+ while !empty(s)
+ let s = substitute(s, '^\s*', '', '')
+ if s[0] =~# '\v^\h$'
+ let name = matchstr(s, '\v\C^\w+')
+ if has_key(s:MSGPACK_SPECIAL_OBJECTS, name)
+ call add(expr, s:MSGPACK_SPECIAL_OBJECTS[name])
+ elseif has_key(a:special_objs, name)
+ call add(expr, a:special_objs[name])
+ else
+ throw 'name-unknown:Unknown name ' . name . ': ' . s
+ endif
+ let s = s[len(name):]
+ elseif (s[0] is# '-' && s[1] =~# '\v^\d$') || s[0] =~# '\v^\d$'
+ let sign = 1
+ if s[0] is# '-'
+ let s = s[1:]
+ let sign = -1
+ endif
+ if s[0:1] is# '0x'
+ " See comment in msgpack#int_dict_to_str().
+ let s = s[2:]
+ let hexnum = matchstr(s, '\v\C^\x+')
+ if empty(hexnum)
+ throw '0x-empty:Must have number after 0x: ' . s
+ elseif len(hexnum) > 16
+ throw '0x-long:Must have at most 16 hex digits: ' . s
+ endif
+ let s = s[len(hexnum):]
+ let hexnum = repeat('0', 16 - len(hexnum)) . hexnum
+ let g1 = str2nr(hexnum[0], 16)
+ let g2 = str2nr(hexnum[1:7], 16)
+ let g3 = str2nr(hexnum[8], 16)
+ let g4 = str2nr(hexnum[9:15], 16)
+ let v1 = s:shift(g1, -2)
+ let v2 = or(or(s:shift(s:mask1(g1, 2), 29), s:shift(g2, 1)),
+ \s:mask1(s:shift(g3, -3), 1))
+ let v3 = or(s:shift(s:mask1(g3, 3), 28), g4)
+ call add(expr, printf('{''_TYPE'': v:msgpack_types.integer, '.
+ \'''_VAL'': [%i, %u, %u, %u]}',
+ \sign, v1, v2, v3))
+ else
+ let num = matchstr(s, '\v\C^\d+')
+ let s = s[len(num):]
+ if sign == -1
+ call add(expr, '-')
+ endif
+ call add(expr, num)
+ if s[0] is# '.'
+ let dec = matchstr(s, '\v\C^\.\d+%(e[+-]?\d+)?')
+ if empty(dec)
+ throw '0.-nodigits:Decimal dot must be followed by digit(s): ' . s
+ endif
+ let s = s[len(dec):]
+ call add(expr, dec)
+ endif
+ endif
+ elseif s =~# '-\?\%(inf\|nan\)'
+ if s[0] is# '-'
+ call add(expr, '-')
+ let s = s[1:]
+ endif
+ call add(expr, s:MSGPACK_SPECIAL_OBJECTS[s[0:2]])
+ let s = s[3:]
+ elseif stridx('="+', s[0]) != -1
+ let match = matchlist(s, '\v\C^(\=|\+\((\-?\d+)\)|)(\"%(\\.|[^\\"]+)*\")')
+ if empty(match)
+ throw '"-invalid:Invalid string: ' . s
+ endif
+ call add(expr, '{''_TYPE'': v:msgpack_types.')
+ if empty(match[1])
+ call add(expr, 'binary')
+ elseif match[1] is# '='
+ call add(expr, 'string')
+ else
+ call add(expr, 'ext')
+ endif
+ call add(expr, ', ''_VAL'': [')
+ if match[1][0] is# '+'
+ call add(expr, match[2] . ', [')
+ endif
+ call add(expr, substitute(match[3], '\v\C\\(.)',
+ \'\=s:msgpack_eval_str_sub(submatch(1))', 'g'))
+ if match[1][0] is# '+'
+ call add(expr, ']')
+ endif
+ call add(expr, ']}')
+ let s = s[len(match[0]):]
+ elseif s[0] is# '{'
+ call add(context, 'map')
+ call add(expr, '{''_TYPE'': v:msgpack_types.map, ''_VAL'': [')
+ call add(expr, '[')
+ let s = s[1:]
+ elseif s[0] is# '['
+ call add(context, 'array')
+ call add(expr, '[')
+ let s = s[1:]
+ elseif s[0] is# ':'
+ call add(expr, ',')
+ let s = s[1:]
+ elseif s[0] is# ','
+ if context[-1] is# 'array'
+ call add(expr, ',')
+ else
+ call add(expr, '], [')
+ endif
+ let s = s[1:]
+ elseif s[0] is# ']'
+ call remove(context, -1)
+ call add(expr, ']')
+ let s = s[1:]
+ elseif s[0] is# '}'
+ call remove(context, -1)
+ if expr[-1] is# "\x5B"
+ call remove(expr, -1)
+ else
+ call add(expr, ']')
+ endif
+ call add(expr, ']}')
+ let s = s[1:]
+ elseif s[0] is# ''''
+ let char = matchstr(s, '\m\C^''\zs.\ze''')
+ if empty(char)
+ throw 'char-invalid:Invalid integer character literal format: ' . s
+ endif
+ call add(expr, char2nr(char))
+ let s = s[len(char) + 2:]
+ else
+ throw 'unknown:Invalid non-space character: ' . s
+ endif
+ endwhile
+ if empty(expr)
+ throw 'empty:Parsed string is empty'
+ endif
+ return eval(join(expr, ''))
+endfunction
+
+""
+" Check whether two msgpack values are equal
+function msgpack#equal(a, b)
+ let atype = msgpack#type(a:a)
+ let btype = msgpack#type(a:b)
+ if atype isnot# btype
+ return 0
+ endif
+ let aspecial = msgpack#special_type(a:a)
+ let bspecial = msgpack#special_type(a:b)
+ if aspecial is# bspecial
+ if aspecial is# 0
+ if type(a:a) == type({})
+ if len(a:a) != len(a:b)
+ return 0
+ endif
+ if !empty(filter(keys(a:a), '!has_key(a:b, v:val)'))
+ return 0
+ endif
+ for [k, v] in items(a:a)
+ if !msgpack#equal(v, a:b[k])
+ return 0
+ endif
+ unlet v
+ endfor
+ return 1
+ elseif type(a:a) == type([])
+ if len(a:a) != len(a:b)
+ return 0
+ endif
+ let i = 0
+ for asubval in a:a
+ if !msgpack#equal(asubval, a:b[i])
+ return 0
+ endif
+ let i += 1
+ unlet asubval
+ endfor
+ return 1
+ elseif type(a:a) == type(0.0)
+ return (a:a == a:a ? a:a == a:b : string(a:a) ==# string(a:b))
+ else
+ return a:a ==# a:b
+ endif
+ elseif aspecial is# 'map' || aspecial is# 'array'
+ if len(a:a._VAL) != len(a:b._VAL)
+ return 0
+ endif
+ let alist = aspecial is# 'map' ? sort(copy(a:a._VAL)) : a:a._VAL
+ let blist = bspecial is# 'map' ? sort(copy(a:b._VAL)) : a:b._VAL
+ let i = 0
+ for asubval in alist
+ let bsubval = blist[i]
+ if aspecial is# 'map'
+ if !(msgpack#equal(asubval[0], bsubval[0])
+ \&& msgpack#equal(asubval[1], bsubval[1]))
+ return 0
+ endif
+ else
+ if !msgpack#equal(asubval, bsubval)
+ return 0
+ endif
+ endif
+ let i += 1
+ unlet asubval
+ unlet bsubval
+ endfor
+ return 1
+ elseif aspecial is# 'nil'
+ return 1
+ elseif aspecial is# 'float'
+ return (a:a._VAL == a:a._VAL
+ \? (a:a._VAL == a:b._VAL)
+ \: (string(a:a._VAL) ==# string(a:b._VAL)))
+ else
+ return a:a._VAL ==# a:b._VAL
+ endif
+ else
+ if atype is# 'array'
+ let a = aspecial is 0 ? a:a : a:a._VAL
+ let b = bspecial is 0 ? a:b : a:b._VAL
+ return msgpack#equal(a, b)
+ elseif atype is# 'binary'
+ let a = (aspecial is 0 ? split(a:a, "\n", 1) : a:a._VAL)
+ let b = (bspecial is 0 ? split(a:b, "\n", 1) : a:b._VAL)
+ return a ==# b
+ elseif atype is# 'map'
+ if aspecial is 0
+ let akeys = copy(a:a)
+ if len(a:b._VAL) != len(akeys)
+ return 0
+ endif
+ for [k, v] in a:b._VAL
+ if msgpack#type(k) isnot# 'string'
+ " Non-special mapping cannot have non-string keys
+ return 0
+ endif
+ if (empty(k._VAL)
+ \|| k._VAL ==# [""]
+ \|| !empty(filter(copy(k._VAL), 'stridx(v:val, "\n") != -1')))
+ " Non-special mapping cannot have zero byte in key or an empty key
+ return 0
+ endif
+ let kstr = join(k._VAL, "\n")
+ if !has_key(akeys, kstr)
+ " Protects from both missing and duplicate keys
+ return 0
+ endif
+ if !msgpack#equal(akeys[kstr], v)
+ return 0
+ endif
+ call remove(akeys, kstr)
+ unlet k
+ unlet v
+ endfor
+ return 1
+ else
+ return msgpack#equal(a:b, a:a)
+ endif
+ elseif atype is# 'float'
+ let a = aspecial is 0 ? a:a : a:a._VAL
+ let b = bspecial is 0 ? a:b : a:b._VAL
+ return (a == a ? a == b : string(a) ==# string(b))
+ elseif atype is# 'integer'
+ if aspecial is 0
+ let sign = a:a >= 0 ? 1 : -1
+ let a = sign * a:a
+ let v1 = s:mask1(s:shift(a, -62), 2)
+ let v2 = s:mask1(s:shift(a, -31), 31)
+ let v3 = s:mask1(a, 31)
+ return [sign, v1, v2, v3] == a:b._VAL
+ else
+ return msgpack#equal(a:b, a:a)
+ endif
+ else
+ throw printf('internal-invalid-type: %s == %s, but special %s /= %s',
+ \atype, btype, aspecial, bspecial)
+ endif
+ endif
+endfunction
diff --git a/runtime/autoload/provider/python.vim b/runtime/autoload/provider/python.vim
index d4a509864f..b769895357 100644
--- a/runtime/autoload/provider/python.vim
+++ b/runtime/autoload/provider/python.vim
@@ -46,7 +46,7 @@ function! provider#python#Call(method, args)
echohl WarningMsg
echomsg v:exception
echohl None
- finish
+ return
endtry
endif
return call(s:rpcrequest, insert(insert(a:args, 'python_'.a:method), s:host))
diff --git a/runtime/autoload/provider/python3.vim b/runtime/autoload/provider/python3.vim
index f469bf55aa..2952f76b40 100644
--- a/runtime/autoload/provider/python3.vim
+++ b/runtime/autoload/provider/python3.vim
@@ -46,7 +46,7 @@ function! provider#python3#Call(method, args)
echohl WarningMsg
echomsg v:exception
echohl None
- finish
+ return
endtry
endif
return call(s:rpcrequest, insert(insert(a:args, 'python_'.a:method), s:host))
diff --git a/runtime/autoload/remote/host.vim b/runtime/autoload/remote/host.vim
index afbf136861..d04dea180c 100644
--- a/runtime/autoload/remote/host.vim
+++ b/runtime/autoload/remote/host.vim
@@ -168,10 +168,15 @@ function! s:UpdateRemotePlugins()
let hosts = keys(s:hosts)
for host in hosts
if has_key(s:plugin_patterns, host)
- let commands = commands
- \ + ['" '.host.' plugins']
- \ + s:RegistrationCommands(host)
- \ + ['', '']
+ try
+ let commands +=
+ \ ['" '.host.' plugins']
+ \ + s:RegistrationCommands(host)
+ \ + ['', '']
+ catch
+ echomsg v:throwpoint
+ echomsg v:exception
+ endtry
endif
endfor
call writefile(commands, s:remote_plugins_manifest)
@@ -212,9 +217,11 @@ function! s:RequirePythonHost(host)
return channel_id
endif
catch
+ echomsg v:throwpoint
echomsg v:exception
endtry
- throw 'Failed to load Python host. You can try to see what happened '.
+ throw 'Failed to load '. a:host.orig_name . ' host. '.
+ \ 'You can try to see what happened '.
\ 'by starting Neovim with the environment variable '.
\ '$NVIM_PYTHON_LOG_FILE set to a file and opening '.
\ 'the generated log file. Also, the host stderr will be available '.
diff --git a/runtime/autoload/shada.vim b/runtime/autoload/shada.vim
new file mode 100644
index 0000000000..9be85b6f2e
--- /dev/null
+++ b/runtime/autoload/shada.vim
@@ -0,0 +1,696 @@
+if exists('g:loaded_shada_autoload')
+ finish
+endif
+let g:loaded_shada_autoload = 1
+
+""
+" If true keep the old header entry when editing existing ShaDa file.
+"
+" Old header entry will be kept only if it is listed in the opened file. To
+" remove old header entry despite of the setting just remove it from the
+" listing. Setting it to false makes plugin ignore all header entries. Defaults
+" to 1.
+let g:shada#keep_old_header = get(g:, 'shada#keep_old_header', 1)
+
+""
+" If true then first entry will be plugin’s own header entry.
+let g:shada#add_own_header = get(g:, 'shada#add_own_header', 1)
+
+""
+" Dictionary that maps ShaDa types to their names.
+let s:SHADA_ENTRY_NAMES = {
+ \1: 'header',
+ \2: 'search_pattern',
+ \3: 'replacement_string',
+ \4: 'history_entry',
+ \5: 'register',
+ \6: 'variable',
+ \7: 'global_mark',
+ \8: 'jump',
+ \9: 'buffer_list',
+ \10: 'local_mark',
+ \11: 'change',
+\}
+
+""
+" Dictionary that maps ShaDa names to corresponding types
+let s:SHADA_ENTRY_TYPES = {}
+call map(copy(s:SHADA_ENTRY_NAMES),
+ \'extend(s:SHADA_ENTRY_TYPES, {v:val : +v:key})')
+
+""
+" Map that maps entry names to lists of keys that can be used by this entry.
+" Only contains data for entries which are represented as mappings, except for
+" the header.
+let s:SHADA_MAP_ENTRIES = {
+ \'search_pattern': ['sp', 'sh', 'ss', 'sb', 'sm', 'sc', 'sl', 'se', 'so',
+ \ 'su'],
+ \'register': ['n', 'rc', 'rw', 'rt'],
+ \'global_mark': ['n', 'f', 'l', 'c'],
+ \'local_mark': ['f', 'n', 'l', 'c'],
+ \'jump': ['f', 'l', 'c'],
+ \'change': ['f', 'l', 'c'],
+ \'header': [],
+\}
+
+""
+" Like one of the values from s:SHADA_MAP_ENTRIES, but for a single buffer in
+" buffer list entry.
+let s:SHADA_BUFFER_LIST_KEYS = ['f', 'l', 'c']
+
+""
+" List of possible history types. Maps integer values that represent history
+" types to human-readable names.
+let s:SHADA_HISTORY_TYPES = ['command', 'search', 'expression', 'input', 'debug']
+
+""
+" Map that maps entry names to their descriptions. Only for entries which have
+" list as a data type. Description is a list of lists where each entry has item
+" description and item type.
+let s:SHADA_FIXED_ARRAY_ENTRIES = {
+ \'replacement_string': [[':s replacement string', 'bin']],
+ \'history_entry': [
+ \['history type', 'histtype'],
+ \['contents', 'bin'],
+ \['separator', 'intchar'],
+ \],
+ \'variable': [['name', 'bin'], ['value', 'any']],
+\}
+
+""
+" Dictionary that maps enum names to dictionary with enum values. Dictionary
+" with enum values maps enum human-readable names to corresponding values. Enums
+" are used as type names in s:SHADA_FIXED_ARRAY_ENTRIES and
+" s:SHADA_STANDARD_KEYS.
+let s:SHADA_ENUMS = {
+ \'histtype': {
+ \'CMD': 0,
+ \'SEARCH': 1,
+ \'EXPR': 2,
+ \'INPUT': 3,
+ \'DEBUG': 4,
+ \},
+ \'regtype': {
+ \'CHARACTERWISE': 0,
+ \'LINEWISE': 1,
+ \'BLOCKWISE': 2,
+ \}
+\}
+
+""
+" Second argument to msgpack#eval.
+let s:SHADA_SPECIAL_OBJS = {}
+call map(values(s:SHADA_ENUMS),
+ \'extend(s:SHADA_SPECIAL_OBJS, map(copy(v:val), "string(v:val)"))')
+
+""
+" Like s:SHADA_ENUMS, but inner dictionary maps values to names and not names to
+" values.
+let s:SHADA_REV_ENUMS = map(copy(s:SHADA_ENUMS), '{}')
+call map(copy(s:SHADA_ENUMS),
+ \'map(copy(v:val), '
+ \. '"extend(s:SHADA_REV_ENUMS[" . string(v:key) . "], '
+ \. '{v:val : v:key})")')
+
+""
+" Maximum length of ShaDa entry name. Used to arrange entries to the table.
+let s:SHADA_MAX_ENTRY_LENGTH = max(
+ \map(values(s:SHADA_ENTRY_NAMES), 'len(v:val)')
+ \+ [len('unknown (0x)') + 16])
+
+""
+" Object that marks required value.
+let s:SHADA_REQUIRED = []
+
+""
+" Dictionary that maps default key names to their description. Description is
+" a list that contains human-readable hint, key type and default value.
+let s:SHADA_STANDARD_KEYS = {
+ \'sm': ['magic value', 'boolean', g:msgpack#true],
+ \'sc': ['smartcase value', 'boolean', g:msgpack#false],
+ \'sl': ['has line offset', 'boolean', g:msgpack#false],
+ \'se': ['place cursor at end', 'boolean', g:msgpack#false],
+ \'so': ['offset value', 'integer', 0],
+ \'su': ['is last used', 'boolean', g:msgpack#true],
+ \'ss': ['is :s pattern', 'boolean', g:msgpack#false],
+ \'sh': ['v:hlsearch value', 'boolean', g:msgpack#false],
+ \'sp': ['pattern', 'bin', s:SHADA_REQUIRED],
+ \'sb': ['search backward', 'boolean', g:msgpack#false],
+ \'rt': ['type', 'regtype', s:SHADA_ENUMS.regtype.CHARACTERWISE],
+ \'rw': ['block width', 'uint', 0],
+ \'rc': ['contents', 'binarray', s:SHADA_REQUIRED],
+ \'n': ['name', 'intchar', char2nr('"')],
+ \'l': ['line number', 'uint', 1],
+ \'c': ['column', 'uint', 0],
+ \'f': ['file name', 'bin', s:SHADA_REQUIRED],
+\}
+
+""
+" Set of entry types containing entries which require `n` key.
+let s:SHADA_REQUIRES_NAME = {'local_mark': 1, 'global_mark': 1, 'register': 1}
+
+""
+" Maximum width of human-readable hint. Used to arrange data in table.
+let s:SHADA_MAX_HINT_WIDTH = max(map(values(s:SHADA_STANDARD_KEYS),
+ \'len(v:val[0])'))
+
+""
+" Default mark name for the cases when it makes sense (i.e. for local marks).
+let s:SHADA_DEFAULT_MARK_NAME = '"'
+
+""
+" Mapping that maps timestamps represented using msgpack#string to strftime
+" output. Used by s:shada_strftime.
+let s:shada_strftime_cache = {}
+
+""
+" Mapping that maps strftime output from s:shada_strftime to timestamps.
+let s:shada_strptime_cache = {}
+
+""
+" Time format used for displaying ShaDa files.
+let s:SHADA_TIME_FORMAT = '%Y-%m-%dT%H:%M:%S'
+
+""
+" Wrapper around msgpack#strftime that caches its output.
+"
+" Format is hardcoded to s:SHADA_TIME_FORMAT.
+function s:shada_strftime(timestamp) abort
+ let key = msgpack#string(a:timestamp)
+ if has_key(s:shada_strftime_cache, key)
+ return s:shada_strftime_cache[key]
+ endif
+ let val = msgpack#strftime(s:SHADA_TIME_FORMAT, a:timestamp)
+ let s:shada_strftime_cache[key] = val
+ let s:shada_strptime_cache[val] = a:timestamp
+ return val
+endfunction
+
+""
+" Wrapper around msgpack#strftime that uses cache created by s:shada_strftime().
+"
+" Also caches its own results. Format is hardcoded to s:SHADA_TIME_FORMAT.
+function s:shada_strptime(string) abort
+ if has_key(s:shada_strptime_cache, a:string)
+ return s:shada_strptime_cache[a:string]
+ endif
+ let ts = msgpack#strptime(s:SHADA_TIME_FORMAT, a:string)
+ let s:shada_strptime_cache[a:string] = ts
+ return ts
+endfunction
+
+""
+" Check whether given value matches given type.
+"
+" @return Zero if value matches, error message string if it does not.
+function s:shada_check_type(type, val) abort
+ let type = msgpack#type(a:val)
+ if type is# a:type
+ return 0
+ endif
+ if has_key(s:SHADA_ENUMS, a:type)
+ let msg = s:shada_check_type('uint', a:val)
+ if msg isnot 0
+ return msg
+ endif
+ if !has_key(s:SHADA_REV_ENUMS[a:type], a:val)
+ let evals_msg = join(map(sort(items(s:SHADA_REV_ENUMS[a:type])),
+ \'v:val[0] . " (" . v:val[1] . ")"'), ', ')
+ return 'Unexpected enum value: expected one of ' . evals_msg
+ endif
+ return 0
+ elseif a:type is# 'uint'
+ if type isnot# 'integer'
+ return 'Expected integer'
+ endif
+ if !(type(a:val) == type({}) ? a:val._VAL[0] == 1 : a:val >= 0)
+ return 'Value is negative'
+ endif
+ return 0
+ elseif a:type is# 'bin'
+ " Binary string without zero bytes
+ if type isnot# 'binary'
+ return 'Expected binary string'
+ elseif (type(a:val) == type({})
+ \&& !empty(filter(copy(a:val._VAL), 'stridx(v:val, "\n") != -1')))
+ return 'Expected no NUL bytes'
+ endif
+ return 0
+ elseif a:type is# 'intchar'
+ let msg = s:shada_check_type('uint', a:val)
+ if msg isnot# 0
+ return msg
+ endif
+ if a:val > 0 || a:val < 1
+ endif
+ return 0
+ elseif a:type is# 'binarray'
+ if type isnot# 'array'
+ return 'Expected array value'
+ elseif !empty(filter(copy(type(a:val) == type({}) ? a:val._VAL : a:val),
+ \'msgpack#type(v:val) isnot# "binary"'))
+ return 'Expected array of binary strings'
+ else
+ for element in (type(a:val) == type({}) ? a:val._VAL : a:val)
+ if (type(element) == type({})
+ \&& !empty(filter(copy(element._VAL), 'stridx(v:val, "\n") != -1')))
+ return 'Expected no NUL bytes'
+ endif
+ unlet element
+ endfor
+ endif
+ return 0
+ elseif a:type is# 'boolean'
+ return 'Expected boolean'
+ elseif a:type is# 'integer'
+ return 'Expected integer'
+ elseif a:type is# 'any'
+ return 0
+ endif
+ return 'Internal error: unknown type ' . a:type
+endfunction
+
+""
+" Convert msgpack mapping object to a list of strings for
+" s:shada_convert_entry().
+"
+" @param[in] map Mapping to convert.
+" @param[in] default_keys List of keys which have default value in this
+" mapping.
+" @param[in] name Name of the converted entry.
+function s:shada_convert_map(map, default_keys, name) abort
+ let ret = []
+ let keys = copy(a:default_keys)
+ call map(sort(keys(a:map)), 'index(keys, v:val) == -1 ? add(keys, v:val) : 0')
+ let descriptions = map(copy(keys),
+ \'get(s:SHADA_STANDARD_KEYS, v:val, ["", 0, 0])')
+ let max_key_len = max(map(copy(keys), 'len(v:val)'))
+ let max_desc_len = max(map(copy(descriptions),
+ \'v:val[0] is 0 ? 0 : len(v:val[0])'))
+ if max_key_len < len('Key')
+ let max_key_len = len('Key')
+ endif
+ let key_header = 'Key' . repeat('_', max_key_len - len('Key'))
+ if max_desc_len == 0
+ call add(ret, printf(' %% %s %s', key_header, 'Value'))
+ else
+ if max_desc_len < len('Description')
+ let max_desc_len = len('Description')
+ endif
+ let desc_header = ('Description'
+ \. repeat('_', max_desc_len - len('Description')))
+ call add(ret, printf(' %% %s %s %s', key_header, desc_header, 'Value'))
+ endif
+ let i = 0
+ for key in keys
+ let [description, type, default] = descriptions[i]
+ if a:name isnot# 'local_mark' && key is# 'n'
+ unlet default
+ let default = s:SHADA_REQUIRED
+ endif
+ let value = get(a:map, key, default)
+ if (key is# 'n' && !has_key(s:SHADA_REQUIRES_NAME, a:name)
+ \&& value is# s:SHADA_REQUIRED)
+ " Do nothing
+ elseif value is s:SHADA_REQUIRED
+ call add(ret, ' # Required key missing: ' . key)
+ elseif max_desc_len == 0
+ call add(ret, printf(' + %-*s %s',
+ \max_key_len, key,
+ \msgpack#string(value)))
+ else
+ if type isnot 0 && value isnot# default
+ let msg = s:shada_check_type(type, value)
+ if msg isnot 0
+ call add(ret, ' # ' . msg)
+ endif
+ endif
+ let strval = s:shada_string(type, value)
+ if msgpack#type(value) is# 'array' && msg is 0
+ let shift = 2 + 2 + max_key_len + 2 + max_desc_len + 2
+ " Value: 1 2 3 4 5 6:
+ " " + Key Description Value"
+ " 1122333445555555555566
+ if shift + strdisplaywidth(strval, shift) > 80
+ let strval = '@'
+ endif
+ endif
+ call add(ret, printf(' + %-*s %-*s %s',
+ \max_key_len, key,
+ \max_desc_len, description,
+ \strval))
+ if strval is '@'
+ for v in value
+ call add(ret, printf(' | - %s', msgpack#string(v)))
+ unlet v
+ endfor
+ endif
+ endif
+ let i += 1
+ unlet value
+ unlet default
+ endfor
+ return ret
+endfunction
+
+""
+" Wrapper around msgpack#string() which may return string from s:SHADA_REV_ENUMS
+function s:shada_string(type, v) abort
+ if (has_key(s:SHADA_ENUMS, a:type) && type(a:v) == type(0)
+ \&& has_key(s:SHADA_REV_ENUMS[a:type], a:v))
+ return s:SHADA_REV_ENUMS[a:type][a:v]
+ elseif (a:type is# 'intchar' && type(a:v) == type(0)
+ \&& strtrans(nr2char(a:v)) is# nr2char(a:v))
+ return "'" . nr2char(a:v) . "'"
+ else
+ return msgpack#string(a:v)
+ endif
+endfunction
+
+""
+" Evaluate string obtained by s:shada_string().
+function s:shada_eval(s) abort
+ return msgpack#eval(a:s, s:SHADA_SPECIAL_OBJS)
+endfunction
+
+""
+" Convert one ShaDa entry to a list of strings suitable for setline().
+"
+" Returned format looks like this:
+"
+" TODO
+function s:shada_convert_entry(entry) abort
+ if type(a:entry.type) == type({})
+ " |msgpack-special-dict| may only be used if value does not fit into the
+ " default integer type. All known entry types do fit, so it is definitely
+ " unknown entry.
+ let name = 'unknown_(' . msgpack#int_dict_to_str(a:entry.type) . ')'
+ else
+ let name = get(s:SHADA_ENTRY_NAMES, a:entry.type, 0)
+ if name is 0
+ let name = printf('unknown_(0x%x)', a:entry.type)
+ endif
+ endif
+ let title = toupper(name[0]) . tr(name[1:], '_', ' ')
+ let header = printf('%s with timestamp %s:', title,
+ \s:shada_strftime(a:entry.timestamp))
+ let ret = [header]
+ if name[:8] is# 'unknown_(' && name[-1:] is# ')'
+ call add(ret, ' = ' . msgpack#string(a:entry.data))
+ elseif has_key(s:SHADA_FIXED_ARRAY_ENTRIES, name)
+ if type(a:entry.data) != type([])
+ call add(ret, printf(' # Unexpected type: %s instead of array',
+ \msgpack#type(a:entry.data)))
+ call add(ret, ' = ' . msgpack#string(a:entry.data))
+ return ret
+ endif
+ let i = 0
+ let max_desc_len = max(map(copy(s:SHADA_FIXED_ARRAY_ENTRIES[name]),
+ \'len(v:val[0])'))
+ if max_desc_len < len('Description')
+ let max_desc_len = len('Description')
+ endif
+ let desc_header = ('Description'
+ \. repeat('_', max_desc_len - len('Description')))
+ call add(ret, printf(' @ %s %s', desc_header, 'Value'))
+ for value in a:entry.data
+ let [desc, type] = get(s:SHADA_FIXED_ARRAY_ENTRIES[name], i, ['', 0])
+ if (i == 2 && name is# 'history_entry'
+ \&& a:entry.data[0] isnot# s:SHADA_ENUMS.histtype.SEARCH)
+ let [desc, type] = ['', 0]
+ endif
+ if type isnot 0
+ let msg = s:shada_check_type(type, value)
+ if msg isnot 0
+ call add(ret, ' # ' . msg)
+ endif
+ endif
+ call add(ret, printf(' - %-*s %s', max_desc_len, desc,
+ \s:shada_string(type, value)))
+ let i += 1
+ unlet value
+ endfor
+ if (len(a:entry.data) < len(s:SHADA_FIXED_ARRAY_ENTRIES[name])
+ \&& !(name is# 'history_entry'
+ \&& len(a:entry.data) == 2
+ \&& a:entry.data[0] isnot# s:SHADA_ENUMS.histtype.SEARCH))
+ call add(ret, ' # Expected more elements in list')
+ endif
+ elseif has_key(s:SHADA_MAP_ENTRIES, name)
+ if type(a:entry.data) != type({})
+ call add(ret, printf(' # Unexpected type: %s instead of map',
+ \msgpack#type(a:entry.data)))
+ call add(ret, ' = ' . msgpack#string(a:entry.data))
+ return ret
+ endif
+ if msgpack#special_type(a:entry.data) isnot 0
+ call add(ret, ' # Entry is a special dict which is unexpected')
+ call add(ret, ' = ' . msgpack#string(a:entry.data))
+ return ret
+ endif
+ let ret += s:shada_convert_map(a:entry.data, s:SHADA_MAP_ENTRIES[name],
+ \name)
+ elseif name is# 'buffer_list'
+ if type(a:entry.data) != type([])
+ call add(ret, printf(' # Unexpected type: %s instead of array',
+ \msgpack#type(a:entry.data)))
+ call add(ret, ' = ' . msgpack#string(a:entry.data))
+ return ret
+ elseif !empty(filter(copy(a:entry.data),
+ \'type(v:val) != type({}) '
+ \. '|| msgpack#special_type(v:val) isnot 0'))
+ call add(ret, ' # Expected array of maps')
+ call add(ret, ' = ' . msgpack#string(a:entry.data))
+ return ret
+ endif
+ for bufdef in a:entry.data
+ if bufdef isnot a:entry.data[0]
+ call add(ret, '')
+ endif
+ let ret += s:shada_convert_map(bufdef, s:SHADA_BUFFER_LIST_KEYS, name)
+ endfor
+ else
+ throw 'internal-unknown-type:Internal error: unknown type name: ' . name
+ endif
+ return ret
+endfunction
+
+""
+" Order of msgpack objects in one ShaDa entry. Each item in the list is name of
+" the key in dictionaries returned by shada#read().
+let s:SHADA_ENTRY_OBJECT_SEQUENCE = ['type', 'timestamp', 'length', 'data']
+
+""
+" Convert list returned by msgpackparse() to a list of ShaDa objects
+"
+" @param[in] mpack List of VimL objects returned by msgpackparse().
+"
+" @return List of dictionaries with keys type, timestamp, length and data. Each
+" dictionary describes one ShaDa entry.
+function shada#mpack_to_sd(mpack) abort
+ let ret = []
+ let i = 0
+ for element in a:mpack
+ let key = s:SHADA_ENTRY_OBJECT_SEQUENCE[
+ \i % len(s:SHADA_ENTRY_OBJECT_SEQUENCE)]
+ if key is# 'type'
+ call add(ret, {})
+ endif
+ let ret[-1][key] = element
+ if key isnot# 'data'
+ if !msgpack#is_uint(element)
+ throw printf('not-uint:Entry %i has %s element '.
+ \'which is not an unsigned integer',
+ \len(ret), key)
+ endif
+ if key is# 'type' && msgpack#equal(element, 0)
+ throw printf('zero-uint:Entry %i has %s element '.
+ \'which is zero',
+ \len(ret), key)
+ endif
+ endif
+ let i += 1
+ unlet element
+ endfor
+ return ret
+endfunction
+
+""
+" Convert read ShaDa file to a list of lines suitable for setline()
+"
+" @param[in] shada List of ShaDa entries like returned by shada#mpack_to_sd().
+"
+" @return List of strings suitable for setline()-like functions.
+function shada#sd_to_strings(shada) abort
+ let ret = []
+ for entry in a:shada
+ let ret += s:shada_convert_entry(entry)
+ endfor
+ return ret
+endfunction
+
+""
+" Convert a readfile()-like list of strings to a list of lines suitable for
+" setline().
+"
+" @param[in] binstrings List of strings to convert.
+"
+" @return List of lines.
+function shada#get_strings(binstrings) abort
+ return shada#sd_to_strings(shada#mpack_to_sd(msgpackparse(a:binstrings)))
+endfunction
+
+""
+" Convert s:shada_convert_entry() output to original entry.
+function s:shada_convert_strings(strings) abort
+ let strings = copy(a:strings)
+ let match = matchlist(
+ \strings[0],
+ \'\v\C^(.{-})\m with timestamp \(\d\{4}-\d\d-\d\dT\d\d:\d\d:\d\d\):$')
+ if empty(match)
+ throw 'invalid-header:Header has invalid format: ' . strings[0]
+ endif
+ call remove(strings, 0)
+ let title = match[1]
+ let name = tolower(title[0]) . tr(title[1:], ' ', '_')
+ let ret = {}
+ let empty_default = g:msgpack#nil
+ if name[:8] is# 'unknown_(' && name[-1:] is# ')'
+ let ret.type = +name[9:-2]
+ elseif has_key(s:SHADA_ENTRY_TYPES, name)
+ let ret.type = s:SHADA_ENTRY_TYPES[name]
+ if has_key(s:SHADA_MAP_ENTRIES, name)
+ unlet empty_default
+ let empty_default = {}
+ elseif has_key(s:SHADA_FIXED_ARRAY_ENTRIES, name) || name is# 'buffer_list'
+ unlet empty_default
+ let empty_default = []
+ endif
+ else
+ throw 'invalid-type:Unknown type ' . name
+ endif
+ let ret.timestamp = s:shada_strptime(match[2])
+ if empty(strings)
+ let ret.data = empty_default
+ else
+ while !empty(strings)
+ if strings[0][2] is# '='
+ let data = s:shada_eval(strings[0][4:])
+ call remove(strings, 0)
+ elseif strings[0][2] is# '%'
+ if name is# 'buffer_list' && !has_key(ret, 'data')
+ let ret.data = []
+ endif
+ let match = matchlist(
+ \strings[0],
+ \'\m\C^ % \(Key_*\)\( Description_*\)\? Value')
+ if empty(match)
+ throw 'invalid-map-header:Invalid mapping header: ' . strings[0]
+ endif
+ call remove(strings, 0)
+ let key_len = len(match[1])
+ let desc_skip_len = len(match[2])
+ let data = {'_TYPE': v:msgpack_types.map, '_VAL': []}
+ while !empty(strings) && strings[0][2] is# '+'
+ let line = remove(strings, 0)[4:]
+ let key = substitute(line[:key_len - 1], '\v\C\ *$', '', '')
+ let strval = line[key_len + desc_skip_len + 2:]
+ if strval is# '@'
+ let val = []
+ while !empty(strings) && strings[0][2] is# '|'
+ if strings[0][4] isnot# '-'
+ throw ('invalid-array:Expected hyphen-minus at column 5: '
+ \. strings)
+ endif
+ call add(val, s:shada_eval(remove(strings, 0)[5:]))
+ endwhile
+ else
+ let val = s:shada_eval(strval)
+ endif
+ if (has_key(s:SHADA_STANDARD_KEYS, key)
+ \&& s:SHADA_STANDARD_KEYS[key][2] isnot# s:SHADA_REQUIRED
+ \&& msgpack#equal(s:SHADA_STANDARD_KEYS[key][2], val))
+ unlet val
+ continue
+ endif
+ call add(data._VAL, [{'_TYPE': v:msgpack_types.string, '_VAL': [key]},
+ \val])
+ unlet val
+ endwhile
+ elseif strings[0][2] is# '@'
+ let match = matchlist(
+ \strings[0],
+ \'\m\C^ @ \(Description_* \)\?Value')
+ if empty(match)
+ throw 'invalid-array-header:Invalid array header: ' . strings[0]
+ endif
+ call remove(strings, 0)
+ let desc_skip_len = len(match[1])
+ let data = []
+ while !empty(strings) && strings[0][2] is# '-'
+ let val = remove(strings, 0)[4 + desc_skip_len :]
+ call add(data, s:shada_eval(val))
+ endwhile
+ else
+ throw 'invalid-line:Unrecognized line: ' . strings[0]
+ endif
+ if !has_key(ret, 'data')
+ let ret.data = data
+ elseif type(ret.data) == type([])
+ call add(ret.data, data)
+ else
+ let ret.data = [ret.data, data]
+ endif
+ unlet data
+ endwhile
+ endif
+ let ret._data = msgpackdump([ret.data])
+ let ret.length = len(ret._data) - 1
+ for s in ret._data
+ let ret.length += len(s)
+ endfor
+ return ret
+endfunction
+
+""
+" Convert s:shada_sd_to_strings() output to a list of original entries.
+function shada#strings_to_sd(strings) abort
+ let strings = filter(copy(a:strings), 'v:val !~# ''\v^\s*%(\#|$)''')
+ let stringss = []
+ for string in strings
+ if string[0] isnot# ' '
+ call add(stringss, [])
+ endif
+ call add(stringss[-1], string)
+ endfor
+ return map(copy(stringss), 's:shada_convert_strings(v:val)')
+endfunction
+
+""
+" Convert a list of strings to list of strings suitable for writefile().
+function shada#get_binstrings(strings) abort
+ let entries = shada#strings_to_sd(a:strings)
+ if !g:shada#keep_old_header
+ call filter(entries, 'v:val.type != ' . s:SHADA_ENTRY_TYPES.header)
+ endif
+ if g:shada#add_own_header
+ let data = {'version': v:version, 'generator': 'shada.vim'}
+ let dumped_data = msgpackdump([data])
+ let length = len(dumped_data) - 1
+ for s in dumped_data
+ let length += len(s)
+ endfor
+ call insert(entries, {
+ \'type': s:SHADA_ENTRY_TYPES.header,
+ \'timestamp': localtime(),
+ \'length': length,
+ \'data': data,
+ \'_data': dumped_data,
+ \})
+ endif
+ let mpack = []
+ for entry in entries
+ let mpack += map(copy(s:SHADA_ENTRY_OBJECT_SEQUENCE), 'entry[v:val]')
+ endfor
+ return msgpackdump(mpack)
+endfunction
diff --git a/runtime/autoload/spellfile.vim b/runtime/autoload/spellfile.vim
index 5b1079e919..c32dd5df9b 100644
--- a/runtime/autoload/spellfile.vim
+++ b/runtime/autoload/spellfile.vim
@@ -196,9 +196,11 @@ function! spellfile#GetDirChoices()
endfunc
function! spellfile#WritableSpellDir()
- if has("unix")
- " For Unix always use the $HOME/.nvim directory
- return $HOME . "/.nvim/spell"
+ " Always use the $XDG_DATA_HOME/nvim/site directory
+ if exists('$XDG_DATA_HOME')
+ return $XDG_DATA_HOME . "/nvim/site/spell"
+ else
+ return $HOME . "/.local/share/nvim/site/spell"
endif
for dir in split(&rtp, ',')
if filewritable(dir) == 2
diff --git a/runtime/autoload/tutor.vim b/runtime/autoload/tutor.vim
index d2881f7f34..4d5a10a97c 100644
--- a/runtime/autoload/tutor.vim
+++ b/runtime/autoload/tutor.vim
@@ -2,6 +2,12 @@
" Setup: {{{1
function! tutor#SetupVim()
+ if &columns < 90
+ set columns=90
+ endif
+ if !exists('g:did_load_ftplugin') || g:did_load_ftplugin != 1
+ filetype plugin on
+ endif
if has('syntax')
if !exists('g:syntax_on') || g:syntax_on == 0
syntax on
@@ -336,6 +342,7 @@ function! tutor#TutorCmd(tutor_name)
let l:to_open = l:tutors[l:tutor_to_open-1]
endif
+ call tutor#SetupVim()
exe "edit ".l:to_open
endfunction
diff --git a/runtime/doc/Makefile b/runtime/doc/Makefile
index 07b4226151..7423e63673 100644
--- a/runtime/doc/Makefile
+++ b/runtime/doc/Makefile
@@ -20,7 +20,7 @@ all: tags html
# Use Vim to generate the tags file. Can only be used when Vim has been
# compiled and installed. Supports multiple languages.
vimtags: $(DOCS)
- $(VIMEXE) -u NONE -esX -c "helptags ++t ." -c quit
+ $(VIMEXE) -u NONE -es -c "helptags ++t ." -c quit
# Use "doctags" to generate the tags file. Only works for English!
tags: doctags $(DOCS)
diff --git a/runtime/doc/arabic.txt b/runtime/doc/arabic.txt
index 83ce80ec00..6f17b38a7a 100644
--- a/runtime/doc/arabic.txt
+++ b/runtime/doc/arabic.txt
@@ -104,9 +104,9 @@ o Setting the Arabic fonts
font name akin to that used in Linux/Unix systems.
(e.g. -misc-fixed-medium-r-normal--20-200-75-75-c-100-iso10646-1)
- You can append the 'guifont' set command to your .vimrc file
+ You can append the 'guifont' set command to your vimrc file
in order to get the same above noted results. In other words,
- you can include ':set guifont=your_ARABIC_FONT' to your .vimrc
+ you can include ':set guifont=your_ARABIC_FONT' to your vimrc
file.
+ Under the X Window environment, you can also start VIM with
@@ -118,9 +118,9 @@ o Setting the appropriate character Encoding
>
:set encoding=utf-8
<
- to your .vimrc file (entering the command manually into you VIM
+ to your vimrc file (entering the command manually into you VIM
window is highly discouraged). In short, include ':set
- encoding=utf-8' to your .vimrc file.
+ encoding=utf-8' to your vimrc file.
Attempts to use Arabic without UTF-8 will result the following
warning message,
@@ -149,7 +149,7 @@ o Enable Arabic settings [short-cut]
4. enable rightleftcmd mode (affecting the command-line)
5. enable arabicshape mode (do visual character alterations)
- You may also append the command to your .vimrc file and simply
+ You may also append the command to your vimrc file and simply
include ':set arabic' to it.
You are also capable of disabling Arabic support via
@@ -184,8 +184,8 @@ o Enable Arabic settings [short-cut]
:set keymap=arabic
<
in your VIM window. You can also append the 'keymap' set command to
- your .vimrc file. In other words, you can include ':set keymap=arabic'
- to your .vimrc file.
+ your vimrc file. In other words, you can include ':set keymap=arabic'
+ to your vimrc file.
To turn toggle (or switch) your keymapping between Arabic and the
default mapping (English), it is advised that users use the 'CTRL-^'
@@ -206,8 +206,8 @@ o Enable Arabic settings [short-cut]
:set delcombine
<
in our VIM window. You can also append the 'delcombine' set command
- to your .vimrc file. In other words, you can include ':set delcombine'
- to your .vimrc file.
+ to your vimrc file. In other words, you can include ':set delcombine'
+ to your vimrc file.
+ Arabic right-to-left Mode
@@ -221,8 +221,8 @@ o Enable Arabic settings [short-cut]
- While in Left-to-right mode, enter ':set rl' in the command line
('rl' is the abbreviation for rightleft).
- - Put the ':set rl' line in your '.vimrc' file to start Vim in
- right-to-left mode permanently.
+ - Put the ':set rl' line in your vimrc file to start Vim in
+ right-to-left mode permanently.
+ Arabic right-to-left command-line Mode
@@ -248,8 +248,8 @@ o Enable Arabic settings [short-cut]
:set arabicshape
<
in our VIM window. You can also append the 'arabicshape' set
- command to your .vimrc file. In other words, you can include
- ':set arabicshape' to your .vimrc file.
+ command to your vimrc file. In other words, you can include
+ ':set arabicshape' to your vimrc file.
Keymap/Keyboard *arabickeymap*
diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt
index e922d5b601..38d53249d1 100644
--- a/runtime/doc/autocmd.txt
+++ b/runtime/doc/autocmd.txt
@@ -28,7 +28,7 @@ a file, when entering or leaving a buffer or window, and when exiting Vim.
For example, you can create an autocommand to set the 'cindent' option for
files matching *.c. You can also use autocommands to implement advanced
features, such as editing compressed files (see |gzip-example|). The usual
-place to put autocommands is in your .vimrc or .exrc file.
+place to put autocommands is in your vimrc file.
*E203* *E204* *E143* *E855*
WARNING: Using autocommands is very powerful, and may lead to unexpected side
@@ -73,8 +73,8 @@ exception is that "<sfile>" is expanded when the autocmd is defined. Example:
Here Vim expands <sfile> to the name of the file containing this line.
-When your .vimrc file is sourced twice, the autocommands will appear twice.
-To avoid this, put this command in your .vimrc file, before defining
+When your vimrc file is sourced twice, the autocommands will appear twice.
+To avoid this, put this command in your vimrc file, before defining
autocommands: >
:autocmd! " Remove ALL autocommands for the current group.
@@ -251,12 +251,14 @@ Name triggered by ~
|SwapExists| detected an existing swap file
|TermOpen| when a terminal buffer is starting
+|TermClose| when a terminal buffer ends
Options
|FileType| when the 'filetype' option has been set
|Syntax| when the 'syntax' option has been set
|EncodingChanged| after the 'encoding' option has been changed
|TermChanged| after the value of 'term' has changed
+|OptionSet| after setting any option
Startup and exit
|VimEnter| after doing all the startup stuff
@@ -695,7 +697,7 @@ FuncUndefined When a user function is used but it isn't
GUIEnter After starting the GUI successfully, and after
opening the window. It is triggered before
VimEnter when using gvim. Can be used to
- position the window from a .gvimrc file: >
+ position the window from a gvimrc file: >
:autocmd GUIEnter * winpos 100 50
< *GUIFailed*
GUIFailed After starting the GUI failed. Vim may
@@ -744,6 +746,24 @@ MenuPopup Just before showing the popup menu (under the
o Operator-pending
i Insert
c Command line
+ *OptionSet*
+OptionSet After setting an option. The pattern is
+ matched against the long option name.
+ The |v:option_old| variable indicates the
+ old option value, |v:option_new| variable
+ indicates the newly set value, the
+ |v:option_type| variable indicates whether
+ it's global or local scoped and |<amatch>|
+ indicates what option has been set.
+
+ Note: It's a bad idea, to reset an option
+ during this autocommand, since this will
+ probably break plugins. You can always use
+ |noa| to prevent triggering this autocommand.
+ Could be used, to check for existence of the
+ 'backupdir' and 'undodir' options and create
+ directories, if they don't exist yet.
+
*QuickFixCmdPre*
QuickFixCmdPre Before a quickfix command is run (|:make|,
|:lmake|, |:grep|, |:lgrep|, |:grepadd|,
@@ -871,6 +891,8 @@ TermChanged After the value of 'term' has changed. Useful
for re-loading the syntax file to update the
colors, fonts and other terminal-dependent
settings. Executed for all loaded buffers.
+ {Nvim} *TermClose*
+TermClose When a terminal buffer ends.
{Nvim} *TermOpen*
TermOpen When a terminal buffer is starting. This can
be used to configure the terminal emulator by
@@ -907,7 +929,7 @@ UserGettingBored When the user presses the same key 42 times.
Just kidding! :-)
*VimEnter*
VimEnter After doing all the startup stuff, including
- loading .vimrc files, executing the "-c cmd"
+ loading vimrc files, executing the "-c cmd"
arguments, creating all windows and loading
the buffers in them.
*VimLeave*
@@ -994,7 +1016,7 @@ expect.
Environment variables can be used in a pattern: >
:autocmd BufRead $VIMRUNTIME/doc/*.txt set expandtab
And ~ can be used for the home directory (if $HOME is defined): >
- :autocmd BufWritePost ~/.vimrc so ~/.vimrc
+ :autocmd BufWritePost ~/.config/nvim/init.vim so <afile>
:autocmd BufRead ~archive/* set readonly
The environment variable is expanded when the autocommand is defined, not when
the autocommand is executed. This is different from the command!
@@ -1135,7 +1157,7 @@ Example: >
:augroup END
This prevents having the autocommands defined twice (e.g., after sourcing the
-.vimrc file again).
+vimrc file again).
==============================================================================
9. Executing autocommands *autocmd-execute*
@@ -1157,7 +1179,7 @@ option will not cause any commands to be executed.
It's possible to use this inside an autocommand too,
so you can base the autocommands for one extension on
another extension. Example: >
- :au BufEnter *.cpp so ~/.vimrc_cpp
+ :au BufEnter *.cpp so ~/.config/nvim/init_cpp.vim
:au BufEnter *.cpp doau BufEnter x.c
< Be careful to avoid endless loops. See
|autocmd-nested|.
diff --git a/runtime/doc/cmdline.txt b/runtime/doc/cmdline.txt
index 627a7000ec..d85d41a295 100644
--- a/runtime/doc/cmdline.txt
+++ b/runtime/doc/cmdline.txt
@@ -109,7 +109,7 @@ CTRL-W Delete the |word| before the cursor. This depends on the
CTRL-U Remove all characters between the cursor position and
the beginning of the line. Previous versions of vim
deleted all characters on the line. If that is the
- preferred behavior, add the following to your .vimrc: >
+ preferred behavior, add the following to your vimrc: >
:cnoremap <C-U> <C-E><C-U>
<
*c_<Insert>* *c_Insert*
@@ -456,7 +456,7 @@ that take a file name.
If you would like using <S-Tab> for CTRL-P in an xterm, put this command in
your .cshrc: >
xmodmap -e "keysym Tab = Tab Find"
-And this in your .vimrc: >
+And this in your vimrc: >
:cmap <Esc>[1~ <C-P>
==============================================================================
@@ -823,8 +823,8 @@ These modifiers can be given, in this order:
precede any :r or :e.
:r Root of the file name (the last extension removed). When
there is only an extension (file name that starts with '.',
- e.g., ".vimrc"), it is not removed. Can be repeated to remove
- several extensions (last one first).
+ e.g., ".nvimrc"), it is not removed. Can be repeated to
+ remove several extensions (last one first).
:e Extension of the file name. Only makes sense when used alone.
When there is no extension the result is empty.
When there is only an extension (file name that starts with
diff --git a/runtime/doc/debug.txt b/runtime/doc/debug.txt
index 3226fa4599..f03116ffed 100644
--- a/runtime/doc/debug.txt
+++ b/runtime/doc/debug.txt
@@ -52,7 +52,7 @@ Use this command to start Vim:
>
valgrind --log-file=valgrind.log --leak-check=full ./vim
-Note: Vim will run much slower. If your .vimrc is big or you have several
+Note: Vim will run much slower. If your vimrc is big or you have several
plugins you need to be patient for startup, or run with the "-u NONE"
argument.
diff --git a/runtime/doc/develop.txt b/runtime/doc/develop.txt
index 2f96c4c6dc..668790358b 100644
--- a/runtime/doc/develop.txt
+++ b/runtime/doc/develop.txt
@@ -10,11 +10,9 @@ This text is important for those who want to be involved in further developing
Vim.
1. Design goals |design-goals|
-2. Coding style |coding-style|
-3. Design decisions |design-decisions|
-4. Assumptions |design-assumptions|
+2. Design decisions |design-decisions|
-See the file README.txt in the "src" directory for an overview of the source
+See the file "src/nvim/README.md" for a high-level overview of the source
code.
Vim is open source software. Everybody is encouraged to contribute to help
@@ -30,28 +28,6 @@ Note that quite a few items are contradicting. This is intentional. A
balance must be found between them.
-VIM IS... VI COMPATIBLE *design-compatible*
-
-First of all, it should be possible to use Vim as a drop-in replacement for
-Vi. When the user wants to, he can use Vim in compatible mode and hardly
-notice any difference with the original Vi.
-
-Exceptions:
-- We don't reproduce obvious Vi bugs in Vim.
-- There are different versions of Vi. I am using Version 3.7 (6/7/85) as a
- reference. But support for other versions is also included when possible.
- The Vi part of POSIX is not considered a definitive source.
-- Vim adds new commands, you cannot rely on some command to fail because it
- didn't exist in Vi.
-- Vim will have a lot of features that Vi doesn't have. Going back from Vim
- to Vi will be a problem, this cannot be avoided.
-- Some things are hardly ever used (open mode, sending an e-mail when
- crashing, etc.). Those will only be included when someone has a good reason
- why it should be included and it's not too much work.
-- For some items it is debatable whether Vi compatibility should be
- maintained. There will be an option flag for these.
-
-
VIM IS... IMPROVED *design-improved*
The IMproved bits of Vim should make it a better Vi, without becoming a
@@ -122,7 +98,6 @@ fast.
VIM IS... MAINTAINABLE *design-maintain*
- The source code should not become a mess. It should be reliable code.
-- Use the same layout in all files to make it easy to read |coding-style|.
- Use comments in a useful way! Quoting the function name and argument names
is NOT useful. Do explain what they are for.
- Porting to another platform should be made easy, without having to change
@@ -140,216 +115,16 @@ such that most users will enjoy using Vim as it is. Commands and options can
be used to adjust Vim to the desire of the user and its environment.
-VIM IS... NOT *design-not*
-
-- Vim is not a shell or an Operating System. You will not be able to run a
- shell inside Vim or use it to control a debugger. This should work the
- other way around: Use Vim as a component from a shell or in an IDE.
- A satirical way to say this: "Unlike Emacs, Vim does not attempt to include
- everything but the kitchen sink, but some people say that you can clean one
- with it. ;-)"
- To use Vim with gdb see: http://www.agide.org and http://clewn.sf.net.
-- Vim is not a fancy GUI editor that tries to look nice at the cost of
- being less consistent over all platforms. But functional GUI features are
- welcomed.
-
-==============================================================================
-2. Coding style *coding-style*
-
-These are the rules to use when making changes to the Vim source code. Please
-stick to these rules, to keep the sources readable and maintainable.
-
-This list is not complete. Look in the source code for more examples.
-
-
-MAKING CHANGES *style-changes*
-
-The basic steps to make changes to the code:
-1. Adjust the documentation. Doing this first gives you an impression of how
- your changes affect the user.
-2. Make the source code changes.
-3. Check ../doc/todo.txt if the change affects any listed item.
-4. Make a patch with "diff -c" against the unmodified code and docs.
-5. Make a note about what changed and include it with the patch.
-
-
-USE OF COMMON FUNCTIONS *style-functions*
-
-Some functions that are common to use, have a special Vim version. Always
-consider using the Vim version, because they were introduced with a reason.
-
-NORMAL NAME VIM NAME DIFFERENCE OF VIM VERSION
-free() vim_free() Checks for freeing NULL
-malloc() alloc() Checks for out of memory situation
-malloc() lalloc() Like alloc(), but has long argument
-strcpy() STRCPY() Includes cast to (char *), for char_u * args
-strchr() vim_strchr() Accepts special characters
-strrchr() vim_strrchr() Accepts special characters
-isspace() ascii_isspace() Can handle characters > 128
-iswhite() ascii_iswhite() Only true for tab and space
-memcpy() mch_memmove() Handles overlapped copies
-bcopy() mch_memmove() Handles overlapped copies
-memset() vim_memset() Uniform for all systems
-
-
-NAMES *style-names*
-
-Function names can not be more than 31 characters long (because of VMS).
-
-Don't use "delete" as a variable name, C++ doesn't like it.
-
-Because of the requirement that Vim runs on as many systems as possible, we
-need to avoid using names that are already defined by the system. This is a
-list of names that are known to cause trouble. The name is given as a regexp
-pattern.
-
-is.*() POSIX, ctype.h
-to.*() POSIX, ctype.h
-
-d_.* POSIX, dirent.h
-l_.* POSIX, fcntl.h
-gr_.* POSIX, grp.h
-pw_.* POSIX, pwd.h
-sa_.* POSIX, signal.h
-mem.* POSIX, string.h
-str.* POSIX, string.h
-wcs.* POSIX, string.h
-st_.* POSIX, stat.h
-tms_.* POSIX, times.h
-tm_.* POSIX, time.h
-c_.* POSIX, termios.h
-MAX.* POSIX, limits.h
-__.* POSIX, system
-_[A-Z].* POSIX, system
-E[A-Z0-9]* POSIX, errno.h
-
-.*_t POSIX, for typedefs. Use .*_T instead.
-
-wait don't use as argument to a function, conflicts with types.h
-index shadows global declaration
-time shadows global declaration
-new C++ reserved keyword
-try Borland C++ doesn't like it to be used as a variable.
-
-clear Mac curses.h
-echo Mac curses.h
-instr Mac curses.h
-meta Mac curses.h
-newwin Mac curses.h
-nl Mac curses.h
-overwrite Mac curses.h
-refresh Mac curses.h
-scroll Mac curses.h
-typeahead Mac curses.h
-
-basename() GNU string function
-dirname() GNU string function
-get_env_value() Linux system function
-
-
-VARIOUS *style-various*
-
-Typedef'ed names should end in "_T": >
- typedef int some_T;
-Define'ed names should be uppercase: >
- #define SOME_THING
-Features always start with "FEAT_": >
- #define FEAT_FOO
-
-Don't use '\"', some compilers can't handle it. '"' works fine.
-
-Don't use:
- #if HAVE_SOME
-Some compilers can't handle that and complain that "HAVE_SOME" is not defined.
-Use
- #ifdef HAVE_SOME
-or
- #if defined(HAVE_SOME)
-
-
-STYLE *style-examples*
+NVIM IS... NOT *design-not*
-General rule: One statement per line.
+Nvim is not an Operating System; instead it should be composed with other
+tools, or hosted as a component. Marvim once said: "Unlike Emacs, Nvim does
+not attempt to include everything but the kitchen sink, but some people use it
+for plumbing."
-Wrong: if (cond) a = 1;
-
-OK: if (cond)
- a = 1;
-
-Wrong: while (cond);
-
-OK: while (cond)
- ;
-
-Wrong: do a = 1; while (cond);
-
-OK: do
- a = 1;
- while (cond);
-
-
-Functions start with:
-
-Wrong: int function_name(int arg1, int arg2)
-
-OK: /*
- * Explanation of what this function is used for.
- *
- * Return value explanation.
- */
- int
- function_name(arg1, arg2)
- int arg1; /* short comment about arg1 */
- int arg2; /* short comment about arg2 */
- {
- int local; /* comment about local */
-
- local = arg1 * arg2;
-
-NOTE: Don't use ANSI style function declarations. A few people still have to
-use a compiler that doesn't support it.
-
-
-SPACES AND PUNCTUATION *style-spaces*
-
-No space between a function name and the bracket:
-
-Wrong: func (arg);
-OK: func(arg);
-
-Do use a space after if, while, switch, etc.
-
-Wrong: if(arg) for(;;)
-OK: if (arg) for (;;)
-
-Use a space after a comma and semicolon:
-
-Wrong: func(arg1,arg2); for (i = 0;i < 2;++i)
-OK: func(arg1, arg2); for (i = 0; i < 2; ++i)
-
-Use a space before and after '=', '+', '/', etc.
-
-Wrong: var=a*5;
-OK: var = a * 5;
-
-In general: Use empty lines to group lines of code together. Put a comment
-just above the group of lines. This makes it easier to quickly see what is
-being done.
-
-OK: /* Prepare for building the table. */
- get_first_item();
- table_idx = 0;
-
- /* Build the table */
- while (has_item())
- table[table_idx++] = next_item();
-
- /* Finish up. */
- cleanup_items();
- generate_hash(table);
==============================================================================
-3. Design decisions *design-decisions*
+2. Design decisions *design-decisions*
Folding
@@ -484,17 +259,4 @@ This isn't ideal, because the longer Vim is running the higher the counts
become. But in practice it is a noticeable improvement over not using the word
count.
-==============================================================================
-4. Assumptions *design-assumptions*
-
-Size of variables:
-char 8 bit signed
-char_u 8 bit unsigned
-int 32 or 64 bit signed (16 might be possible with limited features)
-unsigned 32 or 64 bit unsigned (16 as with ints)
-long 32 or 64 bit signed, can hold a pointer
-
-Note that some compilers cannot handle long lines or strings. The C89
-standard specifies a limit of 509 characters.
-
vim:tw=78:ts=8:ft=help:norl:
diff --git a/runtime/doc/diff.txt b/runtime/doc/diff.txt
index 250275d80a..54d47eb28a 100644
--- a/runtime/doc/diff.txt
+++ b/runtime/doc/diff.txt
@@ -66,7 +66,7 @@ make changes after loading a file, these will be included in the displayed
diffs. You might have to do ":diffupdate" now and then, not all changes are
immediately taken into account.
-In your .vimrc file you could do something special when Vim was started in
+In your vimrc file you could do something special when Vim was started in
diff mode. You could use a construct like this: >
if &diff
diff --git a/runtime/doc/editing.txt b/runtime/doc/editing.txt
index bb3d89e4ac..ffa3f1d673 100644
--- a/runtime/doc/editing.txt
+++ b/runtime/doc/editing.txt
@@ -1141,8 +1141,8 @@ If you want to always use ":confirm", set the 'confirm' option.
|:mkvimrc|, |:mksession|, |:mkview|, |:split|,
|:vsplit|, |:tabe|, |:tabnew|, |:cfile|, |:cgetfile|,
|:caddfile|, |:lfile|, |:lgetfile|, |:laddfile|,
- |:diffsplit|, |:diffpatch|, |:open|, |:pedit|,
- |:redir|, |:source|, |:update|, |:visual|, |:vsplit|,
+ |:diffsplit|, |:diffpatch|, |:pedit|, |:redir|,
+ |:source|, |:update|, |:visual|, |:vsplit|,
and |:qall| if 'confirm' is set.
{only in Win32, Athena, Motif, GTK and Mac GUI}
When ":browse" is not possible you get an error
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 0a17521c08..4ff0636b61 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -391,7 +391,7 @@ example, to add up all the numbers in a list: >
1.4 Dictionaries ~
- *dict* *Dictionaries* *Dictionary*
+ *Dict* *dict* *Dictionaries* *Dictionary*
A Dictionary is an associative array: Each entry has a key and a value. The
entry can be located with the key. The entries are stored without a specific
ordering.
@@ -1535,6 +1535,15 @@ v:oldfiles List of file names that is loaded from the |shada| file on
than String this will cause trouble.
{only when compiled with the |+shada| feature}
+ *v:option_new*
+v:option_new New value of the option. Valid while executing an |OptionSet|
+ autocommand.
+ *v:option_old*
+v:option_old Old value of the option. Valid while executing an |OptionSet|
+ autocommand.
+ *v:option_type*
+v:option_type Scope of the set command. Valid while executing an
+ |OptionSet| autocommand. Can be either "global" or "local"
*v:operator* *operator-variable*
v:operator The last operator given in Normal mode. This is a single
character except for commands starting with <g> or <z>,
@@ -1763,6 +1772,8 @@ cursor( {lnum}, {col} [, {off}])
cursor( {list}) Number move cursor to position in {list}
deepcopy( {expr} [, {noref}]) any make a full copy of {expr}
delete( {fname}) Number delete file {fname}
+dictwatcheradd({dict}, {pattern}, {callback}) Start watching a dictionary
+dictwatcherdel({dict}, {pattern}, {callback}) Stop watching a dictionary
did_filetype() Number TRUE if FileType autocommand event used
diff_filler( {lnum}) Number diff filler lines about {lnum}
diff_hlID( {lnum}, {col}) Number diff highlighting at {lnum}/{col}
@@ -1870,10 +1881,13 @@ invert( {expr}) Number bitwise invert
isdirectory( {directory}) Number TRUE if {directory} is a directory
islocked( {expr}) Number TRUE if {expr} is locked
items( {dict}) List key-value pairs in {dict}
-job_close({job}) Closes a job with id {job}
-job_send({job}, {data}) Writes {data} to {job}'s stdin
-job_spawn({name}, {prog}[, {argv}])
- Spawns {prog} as a job associated with {name}
+jobclose({job}[, {stream}]) Number Closes a job stream(s)
+jobresize({job}, {width}, {height})
+ Number Resize {job}'s pseudo terminal window
+jobsend({job}, {data}) Number Writes {data} to {job}'s stdin
+jobstart({cmd}[, {opts}]) Number Spawns {cmd} as a job
+jobstop({job}) Number Stops a job
+jobwait({ids}[, {timeout}]) Number Wait for a set of jobs
join( {list} [, {sep}]) String join {list} items into one String
keys( {dict}) List keys in {dict}
len( {expr}) Number the length of {expr}
@@ -2661,6 +2675,44 @@ delete({fname}) *delete()*
To delete a line from the buffer use |:delete|. Use |:exe|
when the line number is in a variable.
+dictwatcheradd({dict}, {pattern}, {callback}) *dictwatcheradd()*
+ Adds a watcher to a dictionary. A dictionary watcher is
+ identified by three components:
+
+ - A dictionary({dict});
+ - A key pattern({pattern}).
+ - A function({callback}).
+
+ After this is called, every change on {dict} and on keys
+ matching {pattern} will result in {callback} being invoked.
+
+ For now {pattern} only accepts very simple patterns that can
+ contain a '*' at the end of the string, in which case it will
+ match every key that begins with the substring before the '*'.
+ That means if '*' is not the last character of {pattern}, only
+ keys that are exactly equal as {pattern} will be matched.
+
+ The {callback} receives three arguments:
+
+ - The dictionary being watched.
+ - The key which changed.
+ - A dictionary containg the new and old values for the key.
+
+ The type of change can be determined by examining the keys
+ present on the third argument:
+
+ - If contains both `old` and `new`, the key was updated.
+ - If it contains only `new`, the key was added.
+ - If it contains only `old`, the key was deleted.
+
+ This function can be used by plugins to implement options with
+ validation and parsing logic.
+
+dictwatcherdel({dict}, {pattern}, {callback}) *dictwatcherdel()*
+ Removes a watcher added with |dictwatcheradd()|. All three
+ arguments must match the ones passed to |dictwatcheradd()| in
+ order for the watcher to be successfully deleted.
+
*did_filetype()*
did_filetype() Returns non-zero when autocommands are being executed and the
FileType event has been triggered at least once. Can be used
@@ -2959,6 +3011,8 @@ extend({expr1}, {expr2} [, {expr3}]) *extend()*
{expr1} is changed when {expr2} is not empty. If necessary
make a copy of {expr1} first.
{expr2} remains unchanged.
+ When {expr1} is locked and {expr2} is not empty the operation
+ fails.
Returns {expr1}.
@@ -3441,7 +3495,7 @@ getfperm({fname}) *getfperm()*
If a user does not have a given permission the flag for this
is replaced with the string "-". Examples: >
:echo getfperm("/etc/passwd")
- :echo getfperm(expand("~/.vimrc"))
+ :echo getfperm(expand("~/.config/nvim/init.vim"))
< This will hopefully (from a security point of view) display
the string "rw-r--r--" or even "rw-------".
@@ -4668,10 +4722,10 @@ msgpackdump({list}) {Nvim} *msgpackdump()*
msgpackparse({list}) {Nvim} *msgpackparse()*
Convert a |readfile()|-style list to a list of VimL objects.
Example: >
- let fname = expand('~/.nvim/shada/main.shada')
+ let fname = expand('~/.config/nvim/shada/main.shada')
let mpack = readfile(fname, 'b')
let shada_objects = msgpackparse(mpack)
-< This will read ~/.nvim/shada/main.shada file to
+< This will read ~/.config/nvim/shada/main.shada file to
`shada_objects` list.
Limitations:
@@ -4770,8 +4824,8 @@ pathshorten({expr}) *pathshorten()*
result. The tail, the file name, is kept as-is. The other
components in the path are reduced to single letters. Leading
'~' and '.' characters are kept. Example: >
- :echo pathshorten('~/.vim/autoload/myfile.vim')
-< ~/.v/a/myfile.vim ~
+ :echo pathshorten('~/.config/nvim/autoload/file1.vim')
+< ~/.v/a/file1.vim ~
It doesn't matter if the path exists or not.
pow({x}, {y}) *pow()*
@@ -6888,7 +6942,6 @@ fname_case Case in file names matters (for MS-DOS and Windows
this is not present).
folding Compiled with |folding| support.
footer Compiled with GUI footer support. |gui-footer|
-fork Compiled to use fork()/exec() instead of system().
gettext Compiled with message translation |multi-lang|
gui Compiled with GUI enabled.
gui_athena Compiled with Athena GUI.
@@ -6947,7 +7000,6 @@ statusline Compiled with support for 'statusline', 'rulerformat'
syntax Compiled with syntax highlighting support |syntax|.
syntax_items There are active syntax highlighting items for the
current buffer.
-system Compiled to use system() instead of fork()/exec().
tag_binary Compiled with binary searching in tags files
|tag-binary-search|.
tag_old_static Compiled with support for old static tags
@@ -7274,8 +7326,8 @@ like this: >
When such a function is called, and it is not defined yet, Vim will search the
"autoload" directories in 'runtimepath' for a script file called
-"filename.vim". For example "~/.vim/autoload/filename.vim". That file should
-then define the function like this: >
+"filename.vim". For example "~/.config/nvim/autoload/filename.vim". That
+file should then define the function like this: >
function filename#funcname()
echo "Done!"
@@ -9080,7 +9132,7 @@ A few options contain an expression. When this expression is evaluated it may
have to be done in the sandbox to avoid a security risk. But the sandbox is
restrictive, thus this only happens when the option was set from an insecure
location. Insecure in this context are:
-- sourcing a .vimrc or .exrc in the current directory
+- sourcing a .nvimrc or .exrc in the current directory
- while executing in the sandbox
- value coming from a modeline
diff --git a/runtime/doc/farsi.txt b/runtime/doc/farsi.txt
index 49d9933f48..d5b371ab40 100644
--- a/runtime/doc/farsi.txt
+++ b/runtime/doc/farsi.txt
@@ -122,8 +122,7 @@ o Setting the Farsi fonts
':set guifont=far-a01' in the Vim window.
You can have 'guifont' set to far-a01 by Vim during the Vim startup
- by appending the ':set guifont=far-a01' into your .vimrc file
- (in case of NT/95/98 platforms _vimrc).
+ by appending the ':set guifont=far-a01' into your vimrc file.
Under the X Window environment, you can also start Vim with the
'-fn far-a01' option.
@@ -139,7 +138,7 @@ o Farsi Keymapping Activation
To activate the Farsi keymapping, set either 'altkeymap' or 'fkmap'.
This is done by entering ':set akm' or ':set fk' in the Vim window.
You can have 'altkeymap' or 'fkmap' set as default by appending ':set akm'
- or ':set fk' in your .vimrc file or _vimrc in case of NT/95/98 platforms.
+ or ':set fk' in your vimrc file.
To turn off the Farsi keymapping as a default second language keymapping,
reset the 'altkeymap' by entering ':set noakm'.
@@ -156,8 +155,8 @@ o right-to-left Farsi Mode
+ While in Left-to-right mode, enter 'set rl' in the command line ('rl' is
the abbreviation for rightleft).
- + Put the 'set rl' line in your '.vimrc' file to start Vim in
- right-to-left mode permanently.
+ + Put the 'set rl' line in your vimrc file to start Vim in right-to-left
+ mode permanently.
Encoding
--------
diff --git a/runtime/doc/filetype.txt b/runtime/doc/filetype.txt
index 33d551d507..baf7550948 100644
--- a/runtime/doc/filetype.txt
+++ b/runtime/doc/filetype.txt
@@ -162,8 +162,7 @@ A. If you want to overrule all default file type checks.
1. Create your user runtime directory. You would normally use the first
item of the 'runtimepath' option. Then create the directory "ftdetect"
inside it. Example for Unix: >
- :!mkdir ~/.vim
- :!mkdir ~/.vim/ftdetect
+ :!mkdir -p ~/.config/nvim/ftdetect
<
2. Create a file that contains an autocommand to detect the file type.
Example: >
@@ -173,7 +172,7 @@ A. If you want to overrule all default file type checks.
check the contents of the file to recognize it.
Write this file as "mine.vim" in the "ftdetect" directory in your user
runtime directory. For example, for Unix: >
- :w ~/.vim/ftdetect/mine.vim
+ :w ~/.config/nvim/ftdetect/mine.vim
< 3. To use the new filetype detection you must restart Vim.
@@ -196,7 +195,7 @@ B. If you want to detect your file after the default file type checks.
C. If your file type can be detected by the file name.
1. Create your user runtime directory. You would normally use the first
item of the 'runtimepath' option. Example for Unix: >
- :!mkdir ~/.vim
+ :!mkdir -p ~/.config/nvim
<
2. Create a file that contains autocommands to detect the file type.
Example: >
@@ -210,7 +209,7 @@ C. If your file type can be detected by the file name.
augroup END
< Write this file as "filetype.vim" in your user runtime directory. For
example, for Unix: >
- :w ~/.vim/filetype.vim
+ :w ~/.config/nvim/filetype.vim
< 3. To use the new filetype detection you must restart Vim.
@@ -224,7 +223,7 @@ D. If your filetype can only be detected by inspecting the contents of the
1. Create your user runtime directory. You would normally use the first
item of the 'runtimepath' option. Example for Unix: >
- :!mkdir ~/.vim
+ :!mkdir -p ~/.config/nvim
<
2. Create a vim script file for doing this. Example: >
if did_filetype() " filetype already set..
@@ -238,7 +237,7 @@ D. If your filetype can only be detected by inspecting the contents of the
< See $VIMRUNTIME/scripts.vim for more examples.
Write this file as "scripts.vim" in your user runtime directory. For
example, for Unix: >
- :w ~/.vim/scripts.vim
+ :w ~/.config/nvim/scripts.vim
<
3. The detection will work right away, no need to restart Vim.
@@ -268,12 +267,12 @@ all loaded. For example, if this command: >
produces this output:
- runtimepath=/etc/vim,~/.vim,/usr/local/share/vim/vim60 ~
+ runtimepath=/etc/vim,~/.config/nvim,/usr/local/share/vim/vim60 ~
then Vim will load all plugins in these directories and below:
/etc/vim/plugin/ ~
- ~/.vim/plugin/ ~
+ ~/.config/nvim/plugin/ ~
/usr/local/share/vim/vim60/plugin/ ~
Note that the last one is the value of $VIMRUNTIME which has been expanded.
@@ -329,7 +328,7 @@ ways to change this:
1. Add a few settings.
You must create a new filetype plugin in a directory early in
'runtimepath'. For Unix, for example you could use this file: >
- vim ~/.vim/ftplugin/fortran.vim
+ vim ~/.config/nvim/ftplugin/fortran.vim
< You can set those settings and mappings that you would like to add. Note
that the global plugin will be loaded after this, it may overrule the
settings that you do here. If this is the case, you need to use one of the
@@ -338,7 +337,7 @@ ways to change this:
2. Make a copy of the plugin and change it.
You must put the copy in a directory early in 'runtimepath'. For Unix, for
example, you could do this: >
- cp $VIMRUNTIME/ftplugin/fortran.vim ~/.vim/ftplugin/fortran.vim
+ cp $VIMRUNTIME/ftplugin/fortran.vim ~/.config/nvim/ftplugin/fortran.vim
< Then you can edit the copied file to your liking. Since the b:did_ftplugin
variable will be set, the global plugin will not be loaded.
A disadvantage of this method is that when the distributed plugin gets
@@ -347,7 +346,7 @@ ways to change this:
3. Overrule the settings after loading the global plugin.
You must create a new filetype plugin in a directory from the end of
'runtimepath'. For Unix, for example, you could use this file: >
- vim ~/.vim/after/ftplugin/fortran.vim
+ vim ~/.config/nvim/after/ftplugin/fortran.vim
< In this file you can change just those settings that you want to change.
==============================================================================
@@ -376,7 +375,7 @@ Global mappings:
NOTE: The global mappings are accessed by sourcing the
ftplugin/changelog.vim file first, e.g. with >
runtime ftplugin/changelog.vim
-< in your |.vimrc|.
+< in your |init.vim|.
<Leader>o Switches to the ChangeLog buffer opened for the
current directory, or opens it in a new buffer if it
exists in the current directory. Then it does the
@@ -478,7 +477,7 @@ FORTRAN *ft-fortran-plugin*
Options:
'expandtab' is switched on to avoid tabs as required by the Fortran
- standards unless the user has set fortran_have_tabs in .vimrc.
+ standards unless the user has set fortran_have_tabs in vimrc.
'textwidth' is set to 72 for fixed source format as required by the
Fortran standards and to 80 for free source format.
'formatoptions' is set to break code and comment lines and to preserve long
@@ -558,6 +557,149 @@ Since the text for this plugin is rather long it has been put in a separate
file: |pi_spec.txt|.
+SHADA *ft-shada*
+
+Allows editing binary |shada-file|s in a nice way. Opened binary files are
+displayed in the following format: >
+
+ Type with timestamp YYYY-mm-ddTHH:MM:SS:
+ % Key__ Description___ Value
+ + fooba foo bar baz fo {msgpack-value}
+ + abcde abc def ghi jk {msgpack-value}
+ Other type with timestamp YYYY-mm-ddTHH:MM:SS:
+ @ Description__ Value
+ - foo bar baz t {msgpack-value}
+ # Expected more elements in list
+ Some other type with timestamp YYYY-mm-ddTHH:MM:SS:
+ # Unexpected type: type instead of map
+ = {msgpack-value}
+
+Filetype plugin defines all |Cmd-event|s. Defined |SourceCmd| event makes
+"source file.shada" be equivalent to "|:rshada| file.shada". |BufWriteCmd|,
+|FileWriteCmd| and |FileAppendCmd| events are affected by the following
+settings:
+
+*g:shada#keep_old_header* Boolean, if set to false all header entries
+ are ignored when writing. Defaults to 1.
+*g:shada#add_own_header* Boolean, if set to true first written entry
+ will always be header entry with two values in
+ a map with attached data: |v:version| attached
+ to "version" key and "shada.vim" attached to
+ "generator" key. Defaults to 1.
+
+Format description:
+
+1. `#` starts a comment. Lines starting with space characters and then `#`
+ are ignored. Plugin may only add comment lines to indicate some errors in
+ ShaDa format. Lines containing no non-whitespace characters are also
+ ignored.
+2. Each entry starts with line that has format "{type} with timestamp
+ {timestamp}:". {timestamp} is |strftime()|-formatted string representing
+ actual UNIX timestamp value. First strftime() argument is equal to
+ `%Y-%m-%dT%H:%M:%S`. When writing this timestamp is parsed using
+ |msgpack#strptime()|, with caching (it remembers which timestamp produced
+ particular strftime() output and uses this value if you did not change
+ timestamp). {type} is one of
+ 1 - Header
+ 2 - Search pattern
+ 3 - Replacement string
+ 4 - History entry
+ 5 - Register
+ 6 - Variable
+ 7 - Global mark
+ 8 - Jump
+ 9 - Buffer list
+ 10 - Local mark
+ 11 - Change
+ * - Unknown (0x{type-hex})
+
+ Each type may be represented using Unknown entry: "Jump with timestamp ..."
+ is the same as "Unknown (0x8) with timestamp ....".
+3. After header there is one of the following lines:
+ 1. " % Key__ Description__ Value": map header. After mapping header
+ follows a table which may contain comments and lines consisting of
+ " +", key, description and |{msgpack-value}|. Key is separated by at
+ least two spaces with description, description is separated by at least
+ two spaces with the value. Each key in the map must be at most as wide
+ as "Key__" header: "Key" allows at most 3-byte keys, "Key__" allows at
+ most 5-byte keys. If keys actually occupy less bytes then the rest is
+ filled with spaces. Keys cannot be empty, end with spaces, contain two
+ consequent spaces inside of them or contain multibyte characters (use
+ "=" format if you need this). Descriptions have the same restrictions
+ on width and contents, except that empty descriptions are allowed.
+ Description column may be omitted.
+
+ When writing description is ignored. Keys with values |msgpack#equal|
+ to default ones are ignored. Order of keys is preserved. All keys are
+ treated as strings (not binary strings).
+
+ Note: specifically for buffer list entries it is allowed to have more
+ then one map header. Each map header starts a new map entry inside
+ buffer list because ShaDa buffer list entry is an array of maps. I.e. >
+
+ Buffer list with timestamp 1970-01-01T00:00:00:
+ % Key Description Value
+ + f file name "/foo"
+ + l line number 1
+ + c column 10
+<
+ is equivalent to >
+
+ Buffer list with timestamp 1970-01-01T00:00:00:
+ = [{="f": "/foo", ="c": 10}]
+<
+ and >
+
+ Buffer list with timestamp 1970-01-01T00:00:00:
+ % Key Description Value
+ + f file name "/foo"
+
+ % Key Description Value
+ + f file name "/bar"
+<
+ is equivalent to >
+
+ Buffer list with timestamp 1970-01-01T00:00:00:
+ = [{="f": "/foo"}, {="f": "/bar"}]
+<
+ Note 2: specifically for register entries special syntax for arrays was
+ designed: >
+
+ Register with timestamp 1970-01-01T00:00:00:
+ % Key Description Value
+ + rc contents @
+ | - "line1"
+ | - "line2"
+<
+ This is equivalent to >
+
+ Register with timestamp 1970-01-01T00:00:00:
+ % Key Description Value
+ + rc contents ["line1", "line2"]
+<
+ Such syntax is automatically used if array representation appears to be
+ too lengthy.
+ 2. " @ Description__ Value": array header. Same as map, but key is
+ omitted and description cannot be omitted. Array entries start with
+ " -". Example: >
+
+ History entry with timestamp 1970-01-01T00:00:00:
+ @ Description_ Value
+ - history type SEARCH
+ - contents "foo"
+ - separator '/'
+<
+ is equivalent to >
+
+ History entry with timestamp 1970-01-01T00:00:00:
+ = [SEARCH, "foo", '/']
+<
+ Note: special array syntax for register entries is not recognized here.
+ 3. " = {msgpack-value}": raw values. |{msgpack-value}| in this case may
+ have absolutely any type. Special array syntax for register entries is
+ not recognized here as well.
+
+
SQL *ft-sql*
Since the text for this plugin is rather long it has been put in a separate
diff --git a/runtime/doc/fold.txt b/runtime/doc/fold.txt
index ef69835462..03dd6a61ba 100644
--- a/runtime/doc/fold.txt
+++ b/runtime/doc/fold.txt
@@ -362,7 +362,7 @@ zX Undo manually opened and closed folds: re-apply 'foldlevel'.
Also forces recomputing folds, like |zx|.
*zm*
-zm Fold more: Subtract one from 'foldlevel'. If 'foldlevel' was
+zm Fold more: Subtract |v:count1| from 'foldlevel'. If 'foldlevel' was
already zero nothing happens.
'foldenable' will be set.
@@ -371,7 +371,7 @@ zM Close all folds: set 'foldlevel' to 0.
'foldenable' will be set.
*zr*
-zr Reduce folding: Add one to 'foldlevel'.
+zr Reduce folding: Add |v:count1| to 'foldlevel'.
*zR*
zR Open all folds. This sets 'foldlevel' to highest fold level.
diff --git a/runtime/doc/ft_ada.txt b/runtime/doc/ft_ada.txt
index dcab23ccb2..1e81acff67 100644
--- a/runtime/doc/ft_ada.txt
+++ b/runtime/doc/ft_ada.txt
@@ -58,7 +58,7 @@ To disable them use ":unlet". Example:
You can just use ":" and type these into the command line to set these
temporarily before loading an Ada file. You can make these option settings
-permanent by adding the "let" command(s), without a colon, to your "~/.vimrc"
+permanent by adding the "let" command(s), without a colon, to your |init.vim|
file.
Even on a slow (90Mhz) PC this mode works quickly, but if you find the
diff --git a/runtime/doc/ft_sql.txt b/runtime/doc/ft_sql.txt
index 2c9c1571d3..75c55269ef 100644
--- a/runtime/doc/ft_sql.txt
+++ b/runtime/doc/ft_sql.txt
@@ -149,7 +149,7 @@ The above will also handle these cases: >
);
By default, the ftplugin only searches for CREATE statements. You can also
-override this via your |vimrc| with the following: >
+override this via your |init.vim| with the following: >
let g:ftplugin_sql_statements = 'create,alter'
The filetype plugin defines three types of comments: >
@@ -227,7 +227,7 @@ you must either create:
3. Manual steps / commands
The majority of people work with only one vendor's database product, it would
-be nice to specify a default in your |vimrc|.
+be nice to specify a default in your |init.vim|.
2.1 SQLSetType *sqlsettype* *SQLSetType*
@@ -273,12 +273,12 @@ This will echo: >
-----------------------
As mentioned earlier, the default syntax rules for Vim is based on Oracle
(PL/SQL). You can override this default by placing one of the following in
-your |vimrc|: >
+your |init.vim|: >
let g:sql_type_default = 'sqlanywhere'
let g:sql_type_default = 'sqlinformix'
let g:sql_type_default = 'mysql'
-If you added the following to your |vimrc|: >
+If you added the following to your |init.vim|: >
let g:sql_type_default = 'sqlinformix'
The next time edit a SQL file the following scripts will be automatically
@@ -304,11 +304,8 @@ To help identify these scripts, try to create the files with a "sql" prefix.
If you decide you wish to create customizations for the SQLite database, you
can create any of the following: >
Unix
- ~/.vim/syntax/sqlite.vim
- ~/.vim/indent/sqlite.vim
- Windows
- $VIM/vimfiles/syntax/sqlite.vim
- $VIM/vimfiles/indent/sqlite.vim
+ ~/.config/nvim/syntax/sqlite.vim
+ ~/.config/nvim/indent/sqlite.vim
No changes are necessary to the SQLSetType function. It will automatically
pickup the new SQL files and load them when you issue the SQLSetType command.
@@ -341,8 +338,8 @@ The defaults static maps are: >
imap <buffer> <C-C>T <C-\><C-O>:call sqlcomplete#Map('sqlType')<CR><C-X><C-O>
imap <buffer> <C-C>s <C-\><C-O>:call sqlcomplete#Map('sqlStatement')<CR><C-X><C-O>
-The use of "<C-C>" can be user chosen by using the following in your |.vimrc| as it
-may not work properly on all platforms: >
+The use of "<C-C>" can be user chosen by using the following in your
+|init.vim| as it may not work properly on all platforms: >
let g:ftplugin_sql_omni_key = '<C-C>'
>
The static maps (which are based on the syntax highlight groups) follow this
@@ -440,7 +437,7 @@ the space bar):
- This allows you to quickly drill down into a
table to view its columns and back again.
- <Right> and <Left> can be also be chosen via
- your |.vimrc| >
+ your |init.vim| >
let g:ftplugin_sql_omni_key_right = '<Right>'
let g:ftplugin_sql_omni_key_left = '<Left>'
@@ -604,7 +601,7 @@ database.
----------------------------
The SQL completion plugin can be customized through various options set in
-your |vimrc|: >
+your |init.vim|: >
omni_sql_no_default_maps
< - Default: This variable is not defined
- If this variable is defined, no maps are created for OMNI
@@ -723,7 +720,7 @@ will be specifying different syntax highlight groups.
If you do not wish the default maps created or the key choices do not work on
your platform (often a case on *nix) you define the following variable in
-your |vimrc|: >
+your |init.vim|: >
let g:omni_sql_no_default_maps = 1
Do no edit ftplugin/sql.vim directly! If you change this file your changes
diff --git a/runtime/doc/gui.txt b/runtime/doc/gui.txt
index 12fca33d64..c74c31d1fa 100644
--- a/runtime/doc/gui.txt
+++ b/runtime/doc/gui.txt
@@ -26,10 +26,10 @@ How to start the GUI depends on the system used. Mostly you can run the
GUI version of Vim with:
gvim [options] [files...]
- *gui-init* *gvimrc* *.gvimrc* *_gvimrc* *$MYGVIMRC*
+ *ginit.vim* *gui-init* *gvimrc* *$MYGVIMRC*
The gvimrc file is where GUI-specific startup commands should be placed. It
-is always sourced after the |vimrc| file. If you have one then the $MYGVIMRC
-environment variable has its name.
+is always sourced after the |init.vim| file. If you have one then the
+$MYGVIMRC environment variable has its name.
When the GUI starts up initializations are carried out, in this order:
- The 'term' option is set to "builtin_gui" and terminal options are reset to
@@ -39,7 +39,7 @@ When the GUI starts up initializations are carried out, in this order:
see |$VIMRUNTIME|. To skip loading the system menu include 'M' in
'guioptions'. *buffers-menu* *no_buffers_menu*
The system menu file includes a "Buffers" menu. If you don't want this, set
- the "no_buffers_menu" variable in your .vimrc (not .gvimrc!): >
+ the "no_buffers_menu" variable in your init.vim (not ginit.vim!): >
:let no_buffers_menu = 1
< NOTE: Switching on syntax highlighting also loads the menu file, thus
disabling the Buffers menu must be done before ":syntax on".
@@ -51,29 +51,22 @@ When the GUI starts up initializations are carried out, in this order:
initializations are skipped. When {gvimrc} is "NONE" no file will be read
for initializations.
- For Unix and MS-Windows, if the system gvimrc exists, it is sourced. The
- name of this file is normally "$VIM/gvimrc". You can check this with
+ name of this file is normally "$VIM/ginit.vim". You can check this with
":version". Also see |$VIM|.
- The following are tried, and only the first one that exists is used:
- If the GVIMINIT environment variable exists and is not empty, it is
executed as an Ex command.
- If the user gvimrc file exists, it is sourced. The name of this file is
- normally "$HOME/.gvimrc". You can check this with ":version".
- - For Win32, when $HOME is not set, "$VIM\_gvimrc" is used.
- - When a "_gvimrc" file is not found, ".gvimrc" is tried too. And vice
- versa.
+ normally "$XDG_CONFIG_HOME/nvim/ginit.vim" ($XDG_CONFIG_HOME defaults to
+ ~/.config).
The name of the first file found is stored in $MYGVIMRC, unless it was
already set.
-- If the 'exrc' option is set (which is NOT the default) the file ./.gvimrc
- is sourced, if it exists and isn't the same file as the system or user
- gvimrc file. If this file is not owned by you, some security restrictions
- apply. When ".gvimrc" is not found, "_gvimrc" is tried too. For Macintosh
- and DOS/Win32 "_gvimrc" is tried first.
NOTE: All but the first one are not carried out if Vim was started with
"-u NONE" and no "-U" argument was given, or when started with "-U NONE".
All this happens AFTER the normal Vim initializations, like reading your
-.vimrc file. See |initialization|.
+vimrc file. See |initialization|.
But the GUI window is only opened after all the initializations have been
carried out. If you want some commands to be executed just after opening the
GUI window, use the |GUIEnter| autocommand event. Example: >
@@ -84,9 +77,8 @@ and initialize other things that you may want to set up differently from the
terminal version.
Recommended place for your personal GUI initializations:
- Unix $HOME/.gvimrc or $HOME/.vim/gvimrc
- MS-DOS and Win32 $HOME/_gvimrc, $HOME/vimfiles/gvimrc
- or $VIM/_gvimrc
+ Unix $XDG_CONFIG_HOME/.config/nvim/ginit.vim
+ (default for $XDG_CONFIG_HOME is ~/.config)
The personal initialization files are searched in the order specified above
and only the first one that is found is read.
@@ -464,7 +456,7 @@ The default menus are read from the file "$VIMRUNTIME/menu.vim". See
Starting off with the default set is a good idea. You can add more items, or,
if you don't like the defaults at all, start with removing all menus
|:unmenu-all|. You can also avoid the default menus being loaded by adding
-this line to your .vimrc file (NOT your .gvimrc file!): >
+this line to your vimrc file (NOT your gvimrc file!): >
:let did_install_default_menus = 1
If you also want to avoid the Syntax menu: >
:let did_install_syntax_menu = 1
@@ -479,7 +471,7 @@ Although this documentation is in the GUI section, you can actually use menus
in console mode too. You will have to load |menu.vim| explicitly then, it is
not done by default. You can use the |:emenu| command and command-line
completion with 'wildmenu' to access the menu entries almost like a real menu
-system. To do this, put these commands in your .vimrc file: >
+system. To do this, put these commands in your vimrc file: >
:source $VIMRUNTIME/menu.vim
:set wildmenu
:set cpo-=<
diff --git a/runtime/doc/gui_w32.txt b/runtime/doc/gui_w32.txt
index 6ae7fa2431..eef0aaefb6 100644
--- a/runtime/doc/gui_w32.txt
+++ b/runtime/doc/gui_w32.txt
@@ -243,7 +243,7 @@ selection. You can use CTRL-Q instead. You can also use CTRL-Q in Insert
mode and Command-line mode to get the old meaning of CTRL-V. But CTRL-Q
doesn't work for terminals when it's used for control flow.
-NOTE: The clipboard support still has a number of bugs. See |todo|.
+NOTE: The clipboard support still has a number of bugs.
==============================================================================
4. Shell Commands *gui-shell-win32*
diff --git a/runtime/doc/help.txt b/runtime/doc/help.txt
index e1c05365f7..766a440cb3 100644
--- a/runtime/doc/help.txt
+++ b/runtime/doc/help.txt
@@ -94,7 +94,6 @@ General subjects ~
|tips.txt| various tips on using Vim
|message.txt| (error) messages and explanations
|quotes.txt| remarks from users of Vim
-|todo.txt| known problems and desired extensions
|develop.txt| development of Vim
|debug.txt| debugging Vim itself
|uganda.txt| Vim distribution conditions and what to do with your money
@@ -160,12 +159,9 @@ Versions ~
|vi_diff.txt| Main differences between Vim and Vi
*sys-file-list*
Remarks about specific systems ~
-|os_mac.txt| Macintosh
-|os_unix.txt| Unix
|os_win32.txt| MS-Windows
*standard-plugin-list*
Standard plugins ~
-|pi_getscript.txt| Downloading latest version of Vim scripts
|pi_gzip.txt| Reading and writing compressed files
|pi_netrw.txt| Reading and writing files over a network
|pi_paren.txt| Highlight matching parens
diff --git a/runtime/doc/helphelp.txt b/runtime/doc/helphelp.txt
index 5267ef852b..dea7dded95 100644
--- a/runtime/doc/helphelp.txt
+++ b/runtime/doc/helphelp.txt
@@ -316,7 +316,7 @@ When referring to a Vim option in the help file, place the option name between
two single quotes, eg. 'statusline'
When referring to any other technical term, such as a filename or function
-parameter, surround it in backticks (`), eg. `~/.path/to/nvimrc`.
+parameter, surround it in backticks (`), eg. `~/.path/to/init.vim`.
HIGHLIGHTING
diff --git a/runtime/doc/if_cscop.txt b/runtime/doc/if_cscop.txt
index 4f8c0e2065..70f8d1c6f3 100644
--- a/runtime/doc/if_cscop.txt
+++ b/runtime/doc/if_cscop.txt
@@ -241,8 +241,8 @@ through your tags file(s).
3. Cscope options *cscope-options*
Use the |:set| command to set all cscope options. Ideally, you would do
-this in one of your startup files (e.g., .vimrc). Some cscope related
-variables are only valid within |.vimrc|. Setting them after vim has
+this in one of your startup files (e.g., vimrc). Some cscope related
+variables are only valid within |init.vim|. Setting them after vim has
started will have no effect!
*cscopeprg* *csprg*
@@ -292,10 +292,10 @@ Examples: >
*cscopeverbose* *csverb*
If 'cscopeverbose' is not set (the default), messages will not be printed
indicating success or failure when adding a cscope database. Ideally, you
-should reset this option in your |.vimrc| before adding any cscope databases,
-and after adding them, set it. From then on, when you add more databases
-within Vim, you will get a (hopefully) useful message should the database fail
-to be added. Examples: >
+should reset this option in your |init.vim| before adding any cscope
+databases, and after adding them, set it. From then on, when you add more
+databases within Vim, you will get a (hopefully) useful message should the
+database fail to be added. Examples: >
:set csverb
:set nocsverb
<
@@ -317,7 +317,7 @@ refer to the cscope man page for more details.
Assuming you have a cscope database, you need to "add" the database to Vim.
This establishes a cscope "connection" and makes it available for Vim to use.
-You can do this in your .vimrc file, or you can do it manually after starting
+You can do this in your vimrc file, or you can do it manually after starting
vim. For example, to add the cscope database "cscope.out", you would do:
:cs add cscope.out
@@ -366,7 +366,7 @@ is not configurable (e.g., you can't do a tselect instead).
==============================================================================
6. Suggested usage *cscope-suggestions*
-Put these entries in your .vimrc (adjust the pathname accordingly to your
+Put these entries in your vimrc (adjust the pathname accordingly to your
setup): >
if has("cscope")
diff --git a/runtime/doc/indent.txt b/runtime/doc/indent.txt
index afa88fd37f..6e96d9b816 100644
--- a/runtime/doc/indent.txt
+++ b/runtime/doc/indent.txt
@@ -718,7 +718,7 @@ also left unindented because continue statements are also used for purposes
other than ending a do loop. Programs such as Tidy can convert structured
do/continue loops to the do/enddo form. Do loops of the do/enddo variety can
be indented. If you use only structured loops of the do/enddo form, you should
-declare this by setting the fortran_do_enddo variable in your .vimrc as
+declare this by setting the fortran_do_enddo variable in your vimrc as
follows >
let fortran_do_enddo=1
@@ -737,7 +737,7 @@ The indenting of program units (subroutines, functions, modules, and program
blocks) is enabled by default but can be suppressed if a lighter, screen-width
preserving indent style is desired. To suppress the indenting of program
units for all fortran files set the global fortran_indent_less variable in
-your .vimrc as follows >
+your vimrc as follows >
let fortran_indent_less=1
@@ -969,7 +969,7 @@ VERILOG *ft-verilog-indent*
General block statements such as if, for, case, always, initial, function,
specify and begin, etc., are indented. The module block statements (first
level blocks) are not indented by default. you can turn on the indent with
-setting a variable in the .vimrc as follows: >
+setting a variable in the vimrc as follows: >
let b:verilog_indent_modules = 1
@@ -1017,7 +1017,7 @@ To turn this off, add >
let g:vhdl_indent_genportmap = 0
-to the .vimrc file, which causes the previous alignment example to change: >
+to the vimrc file, which causes the previous alignment example to change: >
ENTITY sync IS
PORT (
@@ -1041,7 +1041,7 @@ To turn this off, add >
let g:vhdl_indent_rhsassign = 0
-to the .vimrc file, which causes the previous alignment example to change: >
+to the vimrc file, which causes the previous alignment example to change: >
sig_out <= (bus_a(1) AND
(sig_b OR sig_c)) OR
diff --git a/runtime/doc/index.txt b/runtime/doc/index.txt
index 0238d7cc53..75c986efcd 100644
--- a/runtime/doc/index.txt
+++ b/runtime/doc/index.txt
@@ -1359,8 +1359,7 @@ tag command action ~
|:number| :nu[mber] print lines with line number
|:nunmap| :nun[map] like ":unmap" but for Normal mode
|:nunmenu| :nunme[nu] remove menu for Normal mode
-|:oldfiles| :ol[dfiles] list files that have marks in the ShaDa file
-|:open| :o[pen] start open mode (not implemented)
+|:oldfiles| :o[ldfiles] list files that have marks in the ShaDa file
|:omap| :om[ap] like ":map" but for Operator-pending mode
|:omapclear| :omapc[lear] remove all mappings for Operator-pending mode
|:omenu| :ome[nu] add menu for Operator-pending mode
diff --git a/runtime/doc/insert.txt b/runtime/doc/insert.txt
index e4cec778bf..013eb6b97b 100644
--- a/runtime/doc/insert.txt
+++ b/runtime/doc/insert.txt
@@ -1,4 +1,4 @@
-*insert.txt* For Vim version 7.4. Last change: 2014 Aug 04
+*insert.txt* For Vim version 7.4. Last change: 2015 May 22
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -77,9 +77,11 @@ CTRL-W Delete the word before the cursor (see |i_backspacing| about
joining lines). See the section "word motions",
|word-motions|, for the definition of a word.
*i_CTRL-U*
-CTRL-U Delete all entered characters in the current line (see
- |i_backspacing| about joining lines).
-
+CTRL-U Delete all entered characters before the cursor in the current
+ line. If there are no newly entereed characters and
+ 'backspace'is not empty, delete all characters before the
+ cursor in the current line.
+ See |i_backspacing| about joining lines.
*i_CTRL-I* *i_<Tab>* *i_Tab*
<Tab> or CTRL-I Insert a tab. If the 'expandtab' option is on, the
equivalent number of spaces is inserted (use CTRL-V <Tab> to
@@ -363,6 +365,9 @@ CTRL-O execute one command, return to Insert mode *i_CTRL-O*
CTRL-\ CTRL-O like CTRL-O but don't move the cursor *i_CTRL-\_CTRL-O*
CTRL-L when 'insertmode' is set: go to Normal mode *i_CTRL-L*
CTRL-G u break undo sequence, start new change *i_CTRL-G_u*
+CTRL-G U don't break undo with next left/right cursor *i_CTRL-G_U*
+ movement (but only if the cursor stays
+ within same the line)
-----------------------------------------------------------------------
Note: If the cursor keys take you out of Insert mode, check the 'noesckeys'
@@ -402,6 +407,29 @@ that, with CTRL-O u. Another example: >
This breaks undo at each line break. It also expands abbreviations before
this.
+An example for using CTRL-G U: >
+
+ inoremap <Left> <C-G>U<Left>
+ inoremap <Right> <C-G>U<Right>
+ inoremap <expr> <Home> col('.') == match(getline('.'), '\S') + 1 ?
+ \ repeat('<C-G>U<Left>', col('.') - 1) :
+ \ (col('.') < match(getline('.'), '\S') ?
+ \ repeat('<C-G>U<Right>', match(getline('.'), '\S') + 0) :
+ \ repeat('<C-G>U<Left>', col('.') - 1 - match(getline('.'), '\S')))
+ inoremap <expr> <End> repeat('<C-G>U<Right>', col('$') - col('.'))
+ inoremap ( ()<C-G>U<Left>
+
+This makes it possible to use the cursor keys in Insert mode, without breaking
+the undo sequence and therefore using |.| (redo) will work as expected.
+Also entering a text like (with the "(" mapping from above): >
+
+ Lorem ipsum (dolor
+
+will be repeatable by the |.|to the expected
+
+ Lorem ipsum (dolor)
+
+
Using CTRL-O splits undo: the text typed before and after it is undone
separately. If you want to avoid this (e.g., in a mapping) you might be able
to use CTRL-R = |i_CTRL-R|. E.g., to call a function: >
@@ -1257,9 +1285,9 @@ A compiled .exe for MS-Windows can be found at:
If you want to complete system functions you can do something like this. Use
ctags to generate a tags file for all the system header files: >
- % ctags -R -f ~/.vim/systags /usr/include /usr/local/include
+ % ctags -R -f ~/.config/nvim/systags /usr/include /usr/local/include
In your vimrc file add this tags file to the 'tags' option: >
- set tags+=~/.vim/systags
+ set tags+=~/.config/nvim/systags
When using CTRL-X CTRL-O after a name without any "." or "->" it is completed
from the tags file directly. This works for any identifier, also function
@@ -1459,7 +1487,7 @@ minimal language-sensitive completion.
To enable syntax code completion you can run: >
setlocal omnifunc=syntaxcomplete#Complete
-You can automate this by placing the following in your |.vimrc| (after any
+You can automate this by placing the following in your |init.vim| (after any
":filetype" command): >
if has("autocmd") && exists("+omnifunc")
autocmd Filetype *
diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt
index 37e1235a81..ab49b6f889 100644
--- a/runtime/doc/map.txt
+++ b/runtime/doc/map.txt
@@ -435,7 +435,7 @@ last defined. Example: >
:verbose map <C-W>*
n <C-W>* * <C-W><C-S>*
- Last set from /home/abcd/.vimrc
+ Last set from ~/.config/nvim/init.vim
See |:verbose-cmd| for more information.
@@ -1046,7 +1046,7 @@ You type: ab esc ^V^V^V^V^V^[
You see: ab esc ^V^V^[
The command-line contains two actual ^Vs before the ^[. This is
- how it should appear in your .exrc file, if you choose to go that
+ how it should appear in your vimrc file, if you choose to go that
route. The first ^V is there to quote the second ^V; the :ab
command uses ^V as its own quote character, so you can include quoted
whitespace or the | character in the abbreviation. The :ab command
diff --git a/runtime/doc/mbyte.txt b/runtime/doc/mbyte.txt
index 17d96103b8..2e3a0141ac 100644
--- a/runtime/doc/mbyte.txt
+++ b/runtime/doc/mbyte.txt
@@ -222,7 +222,7 @@ To use a locale in Vim only, use the |:language| command: >
:language ko
-Put this in your ~/.vimrc file to use it always.
+Put this in your |init.vim| file to use it always.
Or specify $LANG when starting Vim:
@@ -684,7 +684,7 @@ that works well you can use this command to see its name: >
:set guifont
-Then add a command to your |gvimrc| file to set 'guifont': >
+Then add a command to your |ginit.vim| file to set 'guifont': >
:set guifont=courier_new:h12
@@ -928,7 +928,7 @@ Cursor color when IME or XIM is on *CursorIM*
This works in the same way when using XIM.
You can select cursor color when status is on by using highlight group
- CursorIM. For example, add these lines to your |gvimrc|: >
+ CursorIM. For example, add these lines to your |ginit.vim|: >
if has('multi_byte_ime')
highlight Cursor guifg=NONE guibg=Green
diff --git a/runtime/doc/message.txt b/runtime/doc/message.txt
index a17eee4976..2ef2a67c4a 100644
--- a/runtime/doc/message.txt
+++ b/runtime/doc/message.txt
@@ -216,7 +216,7 @@ there is no different error message for that.
Command not allowed from exrc/vimrc in current dir or tag search
Some commands are not allowed for security reasons. These commands mostly
-come from a .exrc or .vimrc file in the current directory, or from a tags
+come from a .exrc or .nvimrc file in the current directory, or from a tags
file. Also see 'secure'.
*E74* >
diff --git a/runtime/doc/mlang.txt b/runtime/doc/mlang.txt
index 8f765b6ce2..5f4642274c 100644
--- a/runtime/doc/mlang.txt
+++ b/runtime/doc/mlang.txt
@@ -149,7 +149,7 @@ If you find a menu translation file for your language with a different name,
create a file in your own runtime directory to load that one. The name of
that file could be: >
- ~/.vim/lang/menu_<v:lang>.vim
+ ~/.config/nvim/lang/menu_<v:lang>.vim
Check the 'runtimepath' option for directories which are searched. In that
file put a command to load the menu file with the other name: >
diff --git a/runtime/doc/motion.txt b/runtime/doc/motion.txt
index 2e8f0801dc..7f84f2d2a3 100644
--- a/runtime/doc/motion.txt
+++ b/runtime/doc/motion.txt
@@ -1,4 +1,4 @@
-*motion.txt* For Vim version 7.4. Last change: 2014 Feb 11
+*motion.txt* For Vim version 7.4. Last change: 2015 Jun 06
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -171,6 +171,8 @@ CTRL-H or *CTRL-H* *<BS>*
l or *l*
<Right> or *<Right>* *<Space>*
<Space> [count] characters to the right. |exclusive| motion.
+ See the 'whichwrap' option for adjusting the behavior
+ at end of line
*0*
0 To the first character of the line. |exclusive|
@@ -797,7 +799,7 @@ g'{mark} g`{mark}
<
:delm[arks]! Delete all marks for the current buffer, but not marks
- A-Z or 0-9.
+ A-Z or 0-9. Also clear the |changelist|.
A mark is not visible in any way. It is just a position in the file that is
remembered. Do not confuse marks with named registers, they are totally
@@ -877,7 +879,8 @@ was made yet in the current file.
for each opened file.
Only one position is remembered per buffer, not one
for each window. As long as the buffer is visible in
- a window the position won't be changed.
+ a window the position won't be changed. Mark is also
+ reset when |:wshada| is run.
*'^* *`^*
'^ `^ To the position where the cursor was the last time
diff --git a/runtime/doc/nvim_from_vim.txt b/runtime/doc/nvim_from_vim.txt
index 220e67d0e7..299eeb05f5 100644
--- a/runtime/doc/nvim_from_vim.txt
+++ b/runtime/doc/nvim_from_vim.txt
@@ -12,8 +12,9 @@ good.
To start the transition, link your previous configuration so Nvim can use
it:
>
- ln -s ~/.vimrc ~/.nvimrc
- ln -s ~/.vim ~/.nvim
+ mkdir -p ${XDG_CONFIG_HOME:=$HOME/.config}
+ ln -s ~/.vim $XDG_CONFIG_HOME/nvim
+ ln -s ~/.vimrc $XDG_CONFIG_HOME/nvim/init.vim
<
See |nvim-intro|, especially |nvim-python| and |nvim-clipboard|, for
additional software you might need to install to use all of Nvim's features.
diff --git a/runtime/doc/nvim_python.txt b/runtime/doc/nvim_python.txt
index 1c345b4532..a2fc968db4 100644
--- a/runtime/doc/nvim_python.txt
+++ b/runtime/doc/nvim_python.txt
@@ -49,6 +49,9 @@ To use Vim Python 2/3 plugins with Nvim, do the following:
>
$ pip3 install --user neovim
<
+Note: If you previously installed the package, get the latest version by
+ appending the `--upgrade` flag to the commands above.
+
==============================================================================
*g:python_host_prog*
diff --git a/runtime/doc/nvim_terminal_emulator.txt b/runtime/doc/nvim_terminal_emulator.txt
index 850391200e..6ef3aaebaa 100644
--- a/runtime/doc/nvim_terminal_emulator.txt
+++ b/runtime/doc/nvim_terminal_emulator.txt
@@ -62,8 +62,8 @@ with the terminal. For example, here's how to map <Esc> to exit terminal mode:
:tnoremap <Esc> <C-\><C-n>
<
Navigating to other windows is only possible by exiting to normal mode, which
-can be cumbersome with <C-\><C-n> keys. Here are some mappings to improve
-the navigation experience:
+can be cumbersome with <C-\><C-n> keys. To improve the navigation experience,
+you could use the following mappings:
>
:tnoremap <A-h> <C-\><C-n><C-w>h
:tnoremap <A-j> <C-\><C-n><C-w>j
@@ -74,8 +74,9 @@ the navigation experience:
:nnoremap <A-k> <C-w>k
:nnoremap <A-l> <C-w>l
<
-This allows using `Alt+{h,j,k,l}` to navigate between windows no matter if
-they are displaying a normal buffer or a terminal buffer in terminal mode.
+This configuration allows using `Alt+{h,j,k,l}` to navigate between windows no
+matter if they are displaying a normal buffer or a terminal buffer in terminal
+mode.
Mouse input is also fully supported, and has the following behavior:
@@ -97,13 +98,15 @@ variables (set via the |TermOpen| autocmd):
- `{g,b}:terminal_scrollback_buffer_size`: Scrollback buffer size, between 1
and 100000 inclusive. The default is 1000.
- `{g,b}:terminal_color_$NUM`: The terminal color palette, where `$NUM` is the
- color index, between 0 and 255 inclusive. This only affects UIs with RGB
- capabilities; for normal terminals the color index is simply forwarded.
+ color index, between 0 and 255 inclusive. This setting only affects UIs with
+ RGB capabilities; for normal terminals the color index is simply forwarded.
The configuration variables are only processed when the terminal starts, which
is why it needs to be done with the |TermOpen| autocmd or setting global
variables before the terminal is started.
+There is also a corresponding |TermClose| event.
+
The terminal cursor can be highlighted via |hl-TermCursor| and
|hl-TermCursorNC|.
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index a97dbbd898..e171c617db 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -1,4 +1,4 @@
-*options.txt* For Vim version 7.4. Last change: 2014 Dec 17
+*options.txt* For Vim version 7.4. Last change: 2015 Oct 15
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -643,17 +643,6 @@ A jump table for the options with a short description can be found at |Q_op|.
compiled with the |+termresponse| feature and if |t_u7| is set to the
escape sequence to request cursor position report.
- *'antialias'* *'anti'* *'noantialias'* *'noanti'*
-'antialias' 'anti' boolean (default: off)
- global
- {only available when compiled with GUI enabled
- on Mac OS X}
- This option only has an effect in the GUI version of Vim on Mac OS X
- v10.2 or later. When on, Vim will use smooth ("antialiased") fonts,
- which can be easier to read at certain sizes on certain displays.
- Setting this option can sometimes cause problems if 'guifont' is set
- to its default (empty string).
-
*'autochdir'* *'acd'* *'noautochdir'* *'noacd'*
'autochdir' 'acd' boolean (default off)
global
@@ -775,12 +764,12 @@ A jump table for the options with a short description can be found at |Q_op|.
in other cases Vim might not be able to guess the right value.
When starting the GUI, the default value for 'background' will be
- "light". When the value is not set in the .gvimrc, and Vim detects
+ "light". When the value is not set in the gvimrc, and Vim detects
that the background is actually quite dark, 'background' is set to
- "dark". But this happens only AFTER the .gvimrc file has been read
+ "dark". But this happens only AFTER the gvimrc file has been read
(because the window needs to be opened to find the actual background
color). To get around this, force the GUI window to be opened by
- putting a ":gui" command in the .gvimrc file, before where the value
+ putting a ":gui" command in the gvimrc file, before where the value
of 'background' is used (e.g., before ":syntax on").
For MS-DOS and Windows the default is "dark".
@@ -788,7 +777,7 @@ A jump table for the options with a short description can be found at |Q_op|.
"screen.linux", "cygwin" or "putty", or $COLORFGBG suggests a dark
background. Otherwise the default is "light".
- Normally this option would be set in the .vimrc file. Possibly
+ Normally this option would be set in the vimrc file. Possibly
depending on the terminal name. Example: >
:if &term == "pcterm"
: set background=dark
@@ -901,8 +890,7 @@ A jump table for the options with a short description can be found at |Q_op|.
again not rename the file.
*'backupdir'* *'bdir'*
-'backupdir' 'bdir' string (default for MS-DOS and Win32: ".,$TEMP,c:/tmp,c:/temp",
- for Unix: ".,~/tmp,~/")
+'backupdir' 'bdir' string (default ".,$XDG_DATA_HOME/nvim/backup")
global
List of directories for the backup file, separated with commas.
- The backup file will be created in the first directory in the list
@@ -981,65 +969,17 @@ A jump table for the options with a short description can be found at |Q_op|.
the newly created file). Also see 'backupcopy' and |crontab|.
*'balloondelay'* *'bdlay'*
-'balloondelay' 'bdlay' number (default: 600)
- global
- {only available when compiled with the |+balloon_eval|
- feature}
- Delay in milliseconds before a balloon may pop up. See |balloon-eval|.
-
- *'ballooneval'* *'beval'* *'noballooneval'* *'nobeval'*
-'ballooneval' 'beval' boolean (default off)
- global
- {only available when compiled with the |+balloon_eval|
- feature}
- Switch on the |balloon-eval| functionality.
-
- *'balloonexpr'* *'bexpr'*
-'balloonexpr' 'bexpr' string (default "")
- global or local to buffer |global-local|
- {only available when compiled with the |+balloon_eval|
- feature}
- Expression for text to show in evaluation balloon. It is only used
- when 'ballooneval' is on. These variables can be used:
-
- v:beval_bufnr number of the buffer in which balloon is going to show
- v:beval_winnr number of the window
- v:beval_lnum line number
- v:beval_col column number (byte index)
- v:beval_text word under or after the mouse pointer
-
- The evaluation of the expression must not have side effects!
- Example: >
- function! MyBalloonExpr()
- return 'Cursor is at line ' . v:beval_lnum .
- \', column ' . v:beval_col .
- \ ' of file ' . bufname(v:beval_bufnr) .
- \ ' on word "' . v:beval_text . '"'
- endfunction
- set bexpr=MyBalloonExpr()
- set ballooneval
-<
- NOTE: The balloon is displayed only if the cursor is on a text
- character. If the result of evaluating 'balloonexpr' is not empty,
- Vim does not try to send a message to an external debugger (Netbeans
- or Sun Workshop).
-
- The expression will be evaluated in the |sandbox| when set from a
- modeline, see |sandbox-option|.
+'balloondelay' 'bdlay' Removed. {Nvim}
- It is not allowed to change text or jump to another window while
- evaluating 'balloonexpr' |textlock|.
+ *'ballooneval'* *'beval'* *'noballooneval'* *'nobeval'*
+'ballooneval' 'beval' Removed. {Nvim}
- To check whether line breaks in the balloon text work use this check: >
- if has("balloon_multiline")
-< When they are supported "\n" characters will start a new line. If the
- expression evaluates to a |List| this is equal to using each List item
- as a string and putting "\n" in between them.
+ *'balloonexpr'* *'bexpr'*
+'balloonexpr' 'bexpr' Removed. {Nvim}
*'belloff'* *'bo'*
'belloff' 'bo' string (default "")
global
- {not in Vi}
Specifies for which events the bell will not be rung. It is a comma
separated list of items. For each item that is present, the bell
will be silenced. This is most useful to specify specific events in
@@ -1479,7 +1419,7 @@ A jump table for the options with a short description can be found at |Q_op|.
initialization and does not have to be set by hand.
When Vim is running in the GUI or in a resizable window, setting this
option will cause the window size to be changed. When you only want
- to use the size for the GUI, put the command in your |gvimrc| file.
+ to use the size for the GUI, put the command in your |ginit.vim| file.
When you set this option and Vim is unable to change the physical
number of columns of the display, the display may be messed up. For
the GUI it is always possible and Vim limits the number of columns to
@@ -1539,14 +1479,6 @@ A jump table for the options with a short description can be found at |Q_op|.
(gzipped files for example). Unloaded buffers are not scanned for
whole-line completion.
- The default is ".,w,b,u,t,i", which means to scan:
- 1. the current buffer
- 2. buffers in other windows
- 3. other loaded buffers
- 4. unloaded buffers
- 5. tags
- 6. included files
-
As you can see, CTRL-N and CTRL-P can be used to do any 'iskeyword'-
based expansion (e.g., dictionary |i_CTRL-X_CTRL-K|, included patterns
|i_CTRL-X_CTRL-I|, tags |i_CTRL-X_CTRL-]| and normal expansions).
@@ -1629,8 +1561,7 @@ A jump table for the options with a short description can be found at |Q_op|.
1 Each block of concealed text is replaced with one
character. If the syntax item does not have a custom
replacement character defined (see |:syn-cchar|) the
- character defined in 'listchars' is used (default is a
- space).
+ character defined in 'listchars' is used.
It is highlighted with the "Conceal" highlight group.
2 Concealed text is completely hidden unless it has a
custom replacement character defined (see
@@ -2130,12 +2061,12 @@ A jump table for the options with a short description can be found at |Q_op|.
{char2}. See |digraphs|.
*'directory'* *'dir'*
-'directory' 'dir' string (default for MS-DOS and Win32: ".,$TEMP,c:\tmp,c:\temp",
- for Unix: ".,~/tmp,/var/tmp,/tmp")
+'directory' 'dir' string (default "$XDG_DATA_HOME/nvim/swap//")
global
List of directory names for the swap file, separated with commas.
- The swap file will be created in the first directory where this is
- possible.
+ possible. If it is not possible in any directory, but last
+ directory listed in the option does not exist, it is created.
- Empty means that no swap file will be used (recovery is
impossible!).
- A directory "." means to put the swap file in the same directory as
@@ -2247,15 +2178,16 @@ A jump table for the options with a short description can be found at |Q_op|.
'endofline' 'eol' boolean (default on)
local to buffer
When writing a file and this option is off and the 'binary' option
- is on, no <EOL> will be written for the last line in the file. This
- option is automatically set when starting to edit a new file, unless
- the file does not have an <EOL> for the last line in the file, in
- which case it is reset. Normally you don't have to set or reset this
- option. When 'binary' is off the value is not used when writing the
- file. When 'binary' is on it is used to remember the presence of a
- <EOL> for the last line in the file, so that when you write the file
- the situation from the original file can be kept. But you can change
- it if you want to.
+ is on, or 'fixeol' option is off, no <EOL> will be written for the
+ last line in the file. This option is automatically set or reset when
+ starting to edit a new file, depending on whether file has an <EOL>
+ for the last line in the file. Normally you don't have to set or
+ reset this option.
+ When 'binary' is off and 'fixeol' is on the value is not used when
+ writing the file. When 'binary' is on or 'fixeol' is off it is used
+ to remember the presence of a <EOL> for the last line in the file, so
+ that when you write the file the situation from the original file can
+ be kept. But you can change it if you want to.
*'equalalways'* *'ea'* *'noequalalways'* *'noea'*
'equalalways' 'ea' boolean (default on)
@@ -2351,13 +2283,13 @@ A jump table for the options with a short description can be found at |Q_op|.
*'exrc'* *'ex'* *'noexrc'* *'noex'*
'exrc' 'ex' boolean (default off)
global
- Enables the reading of .vimrc, .exrc and .gvimrc in the current
- directory. If you switch this option on you should also consider
- setting the 'secure' option (see |initialization|). Using a local
- .exrc, .vimrc or .gvimrc is a potential security leak, use with care!
- also see |.vimrc| and |gui-init|.
+ Enables the reading of .nvimrc and .exrc in the current directory.
+ If you switch this option on you should also consider setting the
+ 'secure' option (see |initialization|). Using this option comes
+ with a potential security risk, use with care!
This option cannot be set from a |modeline| or in the |sandbox|, for
security reasons.
+ Also see |init.vim| and |gui-init|.
*'fileencoding'* *'fenc'* *E213*
'fileencoding' 'fenc' string (default: "")
@@ -2531,7 +2463,7 @@ A jump table for the options with a short description can be found at |Q_op|.
When 'binary' is set, the value of 'fileformats' is not used.
Note that when Vim starts up with an empty buffer this option is not
- used. Set 'fileformat' in your .vimrc instead.
+ used. Set 'fileformat' in your vimrc instead.
For systems with a Dos-like <EOL> (<CR><NL>), when reading files that
are ":source"ed and for vimrc files, automatic <EOL> detection may be
@@ -2610,6 +2542,17 @@ A jump table for the options with a short description can be found at |Q_op|.
fold:c Folded |hl-Folded|
diff:c DiffDelete |hl-DiffDelete|
+ *'fixendofline'* *'fixeol'* *'nofixendofline'* *'nofixeol'*
+'fixendofline' 'fixeol' boolean (default on)
+ local to buffer
+ {not in Vi}
+ When writing a file and this option is on, <EOL> at the end of file
+ will be restored if missing. Turn this option off if you want to
+ preserve the situation from the original file.
+ When the 'binary' option is set the value of this option doesn't
+ matter.
+ See the 'endofline' option.
+
*'fkmap'* *'fk'* *'nofkmap'* *'nofk'*
'fkmap' 'fk' boolean (default off) *E198*
global
@@ -3211,7 +3154,7 @@ A jump table for the options with a short description can be found at |Q_op|.
'm' Menu bar is present.
*'go-M'*
'M' The system menu "$VIMRUNTIME/menu.vim" is not sourced. Note
- that this flag must be added in the .vimrc file, before
+ that this flag must be added in the vimrc file, before
switching on syntax or filetype recognition (when the |gvimrc|
file is sourced the system menu has already been loaded; the
":syntax on" and ":filetype on" commands load the menu too).
@@ -3835,8 +3778,8 @@ A jump table for the options with a short description can be found at |Q_op|.
option.
Careful: If you change this option, it might break expanding
environment variables. E.g., when '/' is included and Vim tries to
- expand "$HOME/.nvim/shada/main.shada". Maybe you should change
- 'iskeyword' instead.
+ expand "$HOME/.local/share/nvim/shada/main.shada". Maybe you should
+ change 'iskeyword' instead.
*'iskeyword'* *'isk'*
'iskeyword' 'isk' string (Vim default for
@@ -4144,7 +4087,7 @@ A jump table for the options with a short description can be found at |Q_op|.
visible in the first column.
*lcs-conceal*
conceal:c Character to show in place of concealed text, when
- 'conceallevel' is set to 1.
+ 'conceallevel' is set to 1. A space when omitted.
*lcs-nbsp*
nbsp:c Character to show for a non-breakable space (character
0xA0, 160). Left blank when omitted.
@@ -4670,7 +4613,7 @@ A jump table for the options with a short description can be found at |Q_op|.
being set. The same is true for a terminal where Vim handles the
mouse clicks itself.
This option is reset when starting the GUI. Thus if you set it in
- your .vimrc it will work in a terminal, but not in the GUI. Setting
+ your vimrc it will work in a terminal, but not in the GUI. Setting
'paste' in the GUI has side effects: e.g., the Paste toolbar button
will no longer work in Insert mode, because it uses a mapping.
When the 'paste' option is switched on (also when it was already on):
@@ -5010,7 +4953,7 @@ A jump table for the options with a short description can be found at |Q_op|.
happens when executing external commands.
For non-Windows Vim: You can set or reset the 't_ti' and 't_te'
- options in your .vimrc. To disable restoring:
+ options in your vimrc. To disable restoring:
set t_ti= t_te=
To enable restoring (for an xterm):
set t_ti=^[7^[[r^[[?47h t_te=^[[?47l^[8
@@ -5090,14 +5033,23 @@ A jump table for the options with a short description can be found at |Q_op|.
<
*'runtimepath'* *'rtp'* *vimfiles*
'runtimepath' 'rtp' string (default:
- Unix: "$HOME/.vim,
- $VIM/vimfiles,
- $VIMRUNTIME,
- $VIM/vimfiles/after,
- $HOME/.vim/after"
- Macintosh: "$VIM:vimfiles,
- $VIMRUNTIME,
- $VIM:vimfiles:after")
+ Unix: "$XDG_CONFIG_HOME/nvim,
+ $XDG_CONFIG_DIRS[1]/nvim,
+ $XDG_CONFIG_DIRS[2]/nvim,
+ …
+ $XDG_DATA_HOME/nvim,
+ $XDG_DATA_DIRS[1]/nvim/site,
+ $XDG_DATA_DIRS[2]/nvim/site,
+ …
+ $VIMRUNTIME,
+ …
+ $XDG_DATA_DIRS[2]/nvim/site/after,
+ $XDG_DATA_DIRS[1]/nvim/site/after,
+ $XDG_DATA_HOME/nvim/after,
+ …
+ $XDG_CONFIG_DIRS[2]/nvim/after,
+ $XDG_CONFIG_DIRS[1]/nvim/after,
+ $XDG_CONFIG_HOME/nvim/after")
global
This is a list of directories which will be searched for runtime
files:
@@ -5120,18 +5072,23 @@ A jump table for the options with a short description can be found at |Q_op|.
And any other file searched for with the |:runtime| command.
- The defaults for most systems are setup to search five locations:
- 1. In your home directory, for your personal preferences.
- 2. In a system-wide Vim directory, for preferences from the system
- administrator.
- 3. In $VIMRUNTIME, for files distributed with Vim.
+ The defaults for most systems are setup to search these locations:
+ 1. In your home directory (XDG_CONFIG_HOME defaults to $HOME/.config),
+ for your personal preferences.
+ 2. In directories which must contain configuration files according to
+ XDG ($XDG_CONFIG_DIRS). This also contains preferences from system
+ administrator (XDG_CONFIG_DIRS defaults to /etc/xdg).
+ 3. In data home directory, for plugins installed by user.
+ 4. In nvim/site subdirectories for each directory in $XDG_DATA_DIRS.
+ This is for plugins which were installed by system administrator,
+ but are not part of the Neovim distribution. XDG_DATA_DIRS defaults
+ to /usr/local/share/:/usr/share/, so system administrators are
+ expected to install site plugins to /usr/share/nvim/site.
+ 5. In $VIMRUNTIME, for files distributed with Neovim.
*after-directory*
- 4. In the "after" directory in the system-wide Vim directory. This is
- for the system administrator to overrule or add to the distributed
- defaults (rarely needed)
- 5. In the "after" directory in your home directory. This is for
- personal preferences to overrule or add to the distributed defaults
- or system-wide settings (rarely needed).
+ 6, 7, 8, 9. In after/ subdirectories of 1, 2, 3 and 4, with reverse
+ ordering. This is for preferences to overrule or add to the
+ distributed defaults or system-wide settings (rarely needed).
Note that, unlike 'path', no wildcards like "**" are allowed. Normal
wildcards are allowed, but can significantly slow down searching for
@@ -5240,12 +5197,12 @@ A jump table for the options with a short description can be found at |Q_op|.
'secure' boolean (default off)
global
When on, ":autocmd", shell and write commands are not allowed in
- ".vimrc" and ".exrc" in the current directory and map commands are
+ ".nvimrc" and ".exrc" in the current directory and map commands are
displayed. Switch it off only if you know that you will not run into
problems, or when the 'exrc' option is off. On Unix this option is
- only used if the ".vimrc" or ".exrc" is not owned by you. This can be
+ only used if the ".nvimrc" or ".exrc" is not owned by you. This can be
dangerous if the systems allows users to do a "chown". You better set
- 'secure' at the end of your ~/.vimrc then.
+ 'secure' at the end of your |init.vim| then.
This option cannot be set from a |modeline| or in the |sandbox|, for
security reasons.
@@ -5329,8 +5286,8 @@ A jump table for the options with a short description can be found at |Q_op|.
*'shada'* *'sd'* *E526* *E527* *E528*
'shada' 'sd' string (Vim default for
- Win32: '!,100,<50,s10,h,rA:,rB:
- others: '!,100,<50,s10,h
+ Win32: !,'100,<50,s10,h,rA:,rB:
+ others: !,'100,<50,s10,h
Vi default: "")
global
When non-empty, the shada file is read upon startup and written
@@ -5357,9 +5314,9 @@ A jump table for the options with a short description can be found at |Q_op|.
% When included, save and restore the buffer list. If Vim is
started with a file name argument, the buffer list is not
restored. If Vim is started without a file name argument, the
- buffer list is restored from the shada file. Buffers
- without a file name and buffers for help files are not written
- to the shada file.
+ buffer list is restored from the shada file. Quickfix
+ ('buftype'), unlisted ('buflisted'), unnamed and buffers on
+ removable media (|shada-r|) are not saved.
When followed by a number, the number specifies the maximum
number of buffers that are stored. Without a number all
buffers are stored.
@@ -5502,7 +5459,7 @@ A jump table for the options with a short description can be found at |Q_op|.
default becomes "2>&1| tee". This means that stderr is also included.
Before using the 'shell' option a path is removed, thus "/bin/sh" uses
"sh".
- The initialization of this option is done after reading the ".vimrc"
+ The initialization of this option is done after reading the vimrc
and the other initializations, so that when the 'shell' option is set
there, the 'shellpipe' option changes automatically, unless it was
explicitly set before.
@@ -5548,7 +5505,7 @@ A jump table for the options with a short description can be found at |Q_op|.
For Win32, the Unix checks are done and additionally "cmd" is checked
for, which makes the default ">%s 2>&1". Also, the same names with
".exe" appended are checked for.
- The initialization of this option is done after reading the ".vimrc"
+ The initialization of this option is done after reading the vimrc
and the other initializations, so that when the 'shell' option is set
there, the 'shellredir' option changes automatically unless it was
explicitly set before.
@@ -6023,7 +5980,7 @@ A jump table for the options with a short description can be found at |Q_op|.
Only one of "best", "double" or "fast" may be used. The others may
appear several times in any order. Example: >
- :set sps=file:~/.vim/sugg,best,expr:MySuggest()
+ :set sps=file:~/.config/nvim/sugg,best,expr:MySuggest()
<
This option cannot be set from a |modeline| or in the |sandbox|, for
security reasons.
@@ -6198,7 +6155,7 @@ A jump table for the options with a short description can be found at |Q_op|.
Watch out for errors in expressions. They may render Vim unusable!
If you are stuck, hold down ':' or 'Q' to get a prompt, then quit and
- edit your .vimrc or whatever with "vim -u NONE" to get it right.
+ edit your vimrc or whatever with "vim -u NONE" to get it right.
Examples:
Emulate standard status line with 'ruler' set >
@@ -6682,8 +6639,8 @@ A jump table for the options with a short description can be found at |Q_op|.
global
Alias for 'term', see above.
- *'undodir'* *'udir'*
-'undodir' 'udir' string (default ".")
+ *'undodir'* *'udir'* *E926*
+'undodir' 'udir' string (default "$XDG_DATA_HOME/nvim/undo")
global
{only when compiled with the |+persistent_undo| feature}
List of directory names for undo files, separated with commas.
@@ -6692,8 +6649,10 @@ A jump table for the options with a short description can be found at |Q_op|.
"file.txt" is ".file.txt.un~".
For other directories the file name is the full path of the edited
file, with path separators replaced with "%".
- When writing: The first directory that exists is used. "." always
- works, no directories after "." will be used for writing.
+ When writing: The first directory that exists is used. "." always
+ works, no directories after "." will be used for writing. If none of
+ the directories exist Neovim will attempt to create last directory in
+ the list.
When reading all entries are tried to find an undo file. The first
undo file that exists is used. When it cannot be read an error is
given, no further entry is used.
@@ -6804,8 +6763,7 @@ A jump table for the options with a short description can be found at |Q_op|.
displayed when 'verbosefile' is set.
*'viewdir'* *'vdir'*
-'viewdir' 'vdir' string (default for MS-DOS and Win32: "$VIM/vimfiles/view",
- for Unix: "~/.vim/view")
+'viewdir' 'vdir' string (default: "$XDG_DATA_HOME/nvim/view")
global
{not available when compiled without the |+mksession|
feature}
diff --git a/runtime/doc/os_mac.txt b/runtime/doc/os_mac.txt
deleted file mode 100644
index 3eebb7ef0d..0000000000
--- a/runtime/doc/os_mac.txt
+++ /dev/null
@@ -1,116 +0,0 @@
-*os_mac.txt* For Vim version 7.4. Last change: 2006 Apr 30
-
-
- VIM REFERENCE MANUAL by Bram Moolenaar et al.
-
-
- *mac* *Mac* *macintosh* *Macintosh*
-
-This file documents the particularities of the Macintosh version of Vim.
-
-NOTE: This file is a bit outdated. You might find more useful info here:
- http://macvim.org/
-
-1. Filename Convention |mac-filename|
-2. .vimrc an .vim files |mac-vimfile|
-3. FAQ |mac-faq|
-4. Known Lack |mac-lack|
-5. Mac Bug Report |mac-bug|
-6. Compiling Vim |mac-compile|
-
-There was a Mac port for version 3.0 of Vim. Here are the first few lines
-from the old file:
-
-VIM Release Notes
-Initial Macintosh release, VIM version 3.0
-19 October 1994
-
-Eric Fischer
-<enf1@midway.uchicago.edu>, <eric@jcp.uchicago.edu>, <etaoin@uchicago.edu>
-5759 N. Guilford Ave
-Indianapolis IN 46220 USA
-
-==============================================================================
-1. Filename Convention *mac-filename*
-
-Starting with Vim version 7 you can just use the unix path separators with
-Vim. In order to determine if the specified filename is relative to the
-current folder or absolute (i.e. relative to the "Desktop"), the following
-algorithm is used:
-
- If the path start by a "/", the path is absolute
- If the path start by a ":", the path is relative
- If the path doesn't start by neither a "/" nor ":",
- and a ":" is found before a "/" then the path is absolute
->
- :e /HD/text
- :e HD:text
-< Edit the file "text" of the disk "HD" >
- :e :src:main.c
- :e src/main.c
-< Edit the file "main.c" in the folder "src" in the current folder >
- :e os_mac.c
-< Edit the file "os_mac.c" in the current folder.
-
-You can use the |$VIM| and |$VIMRUNTIME| variable. >
-
- :so $VIMRUNTIME/syntax/syntax.vim
-
-==============================================================================
-2. .vimrc and .vim files *mac-vimfile*
-
-It is recommended to use Unix style line separators for Vim scripts, thus a
-single newline character.
-
-When starting up Vim will load the $VIMRUNTIME/macmap.vim script to define
-default command-key mappings.
-
-On older systems files starting with a dot "." are discouraged, thus the rc
-files are named "vimrc" or "_vimrc" and "gvimrc" or "_gvimrc". These files
-can be in any format (mac, dos or unix).
-
-==============================================================================
-3. Mac FAQ *mac-faq*
-
-On the internet: http://macvim.org/OSX/index.php#FAQ
-
-Q: I can't enter non-ASCII character in Apple Terminal.
-A: Under Window Settings, Emulation, make sure that "Escape non-ASCII
- characters" is not checked.
-
-Q: How do I start the GUI from the command line?
-A: Assuming that Vim.app is located in /Applications:
- open /Applications/Vim.app
- Or:
- /Applications/Vim.app/Contents/MacOS/Vim -g {arguments}
-
-Q: How can I set $PATH to something reasonable when I start Vim.app from the
- GUI or with open?
-A: The following trick works with most shells. Put it in your vimrc file.
- This is included in the system vimrc file included with the binaries
- distributed at macvim.org . >
- let s:path = system("echo echo VIMPATH'${PATH}' | $SHELL -l")
- let $PATH = matchstr(s:path, 'VIMPATH\zs.\{-}\ze\n')
-
-==============================================================================
-4. Mac Lack *mac-lack*
-
-In a terminal CTRL-^ needs to be entered as Shift-Control-6. CTRL-@ as
-Shift-Control-2.
-
-==============================================================================
-5. Mac Bug Report *mac-bug*
-
-When reporting any Mac specific bug or feature change, please use the vim-mac
-maillist |vim-mac|. However, you need to be subscribed. An alternative is to
-send a message to the current MacVim maintainers:
-
- mac@vim.org
-
-==============================================================================
-6. Compiling Vim *mac-compile*
-
-See the file "src/INSTALLmac.txt" that comes with the source files.
-
-
- vim:tw=78:ts=8:ft=help:norl:
diff --git a/runtime/doc/os_unix.txt b/runtime/doc/os_unix.txt
deleted file mode 100644
index 604fa5827a..0000000000
--- a/runtime/doc/os_unix.txt
+++ /dev/null
@@ -1,57 +0,0 @@
-*os_unix.txt* For Vim version 7.4. Last change: 2005 Mar 29
-
-
- VIM REFERENCE MANUAL by Bram Moolenaar
-
-
- *unix* *Unix*
-This file contains the particularities for the Unix version of Vim.
-
-For compiling Vim on Unix see "INSTALL" and "Makefile" in the src directory.
-
-The default help file name is "/usr/local/lib/vim/help.txt" The files
-"$HOME/.vimrc" and "$HOME/.exrc" are used for configuration. Additionally
-"/usr/local/etc/vimrc" is used first. If "/usr/local/share" exists it is used
-instead of "/usr/local/lib".
-
-Temporary files (for filtering) are put in "/tmp". If you want to place them
-somewhere else, set the environment variable $TMPDIR to the directory you
-prefer.
-
-With wildcard expansion you can use '~' (home directory) and '$'
-(environment variable).
-
- *fork* *spoon*
-For executing external commands fork()/exec() is used when possible, otherwise
-system() is used, which is a bit slower. The output of ":version" includes
-|+fork| when fork()/exec() is used, |+system()| when system() is used. This
-can be changed at compile time.
-
-Because terminal updating under Unix is often slow (e.g. serial line
-terminal, shell window in suntools), the 'showcmd' and 'ruler' options
-are off by default.
-
-When using Vim in an xterm the mouse clicks can be used by Vim by setting
-'mouse' to "a". If there is access to an X-server gui style copy/paste will
-be used and visual feedback will be provided while dragging with the mouse.
-If you then still want the xterm copy/paste with the mouse, press the shift
-key when using the mouse. See |mouse-using|.
-
- *terminal-colors*
-To use colors in Vim you can use the following example (if your terminal
-supports colors, but "T_Co" is empty or zero): >
- :set t_me=^[[0;1;36m " normal mode (undoes t_mr and t_md)
- :set t_mr=^[[0;1;33;44m " reverse (invert) mode
- :set t_md=^[[1;33;41m " bold mode
- :set t_se=^[[1;36;40m " standout end
- :set t_so=^[[1;32;45m " standout mode
- :set t_ue=^[[0;1;36m " underline end
- :set t_us=^[[1;32m " underline mode start
-[the ^[ is an <Esc>, type CTRL-V <Esc> to enter it]
-
-For real color terminals the ":highlight" command can be used.
-
-The file "tools/vim132" is a shell script that can be used to put Vim in 132
-column mode on a vt100 and lookalikes.
-
- vim:tw=78:ts=8:ft=help:norl:
diff --git a/runtime/doc/pi_getscript.txt b/runtime/doc/pi_getscript.txt
deleted file mode 100644
index 628d9b74e5..0000000000
--- a/runtime/doc/pi_getscript.txt
+++ /dev/null
@@ -1,482 +0,0 @@
-*pi_getscript.txt* For Vim version 7.0. Last change: 2013 Nov 29
->
- GETSCRIPT REFERENCE MANUAL by Charles E. Campbell
-<
-Authors: Charles E. Campbell <NdrOchip@ScampbellPfamilyA.Mbiz>
- (remove NOSPAM from the email address)
- *GetLatestVimScripts-copyright*
-Copyright: (c) 2004-2012 by Charles E. Campbell *glvs-copyright*
- The VIM LICENSE (see |copyright|) applies to the files in this
- package, including getscriptPlugin.vim, getscript.vim,
- GetLatestVimScripts.dist, and pi_getscript.txt, except use "getscript"
- instead of "VIM". Like anything else that's free, getscript and its
- associated files are provided *as is* and comes with no warranty of
- any kind, either expressed or implied. No guarantees of
- merchantability. No guarantees of suitability for any purpose. By
- using this plugin, you agree that in no event will the copyright
- holder be liable for any damages resulting from the use of this
- software. Use at your own risk!
-
-Getscript is a plugin that simplifies retrieval of the latest versions of the
-scripts that you yourself use! Typing |:GLVS| will invoke getscript; it will
-then use the <GetLatestVimScripts.dat> (see |GetLatestVimScripts_dat|) file to
-get the latest versions of scripts listed therein from http://vim.sf.net/.
-
-==============================================================================
-1. Contents *glvs-contents* *glvs* *getscript*
- *GetLatestVimScripts*
-
- 1. Contents........................................: |glvs-contents|
- 2. GetLatestVimScripts -- Getting Started..........: |glvs-install|
- 3. GetLatestVimScripts Usage.......................: |glvs-usage|
- 4. GetLatestVimScripts Data File...................: |glvs-data|
- 5. GetLatestVimScripts Friendly Plugins............: |glvs-plugins|
- 6. GetLatestVimScripts AutoInstall.................: |glvs-autoinstall|
- 7. GetLatestViMScripts Options.....................: |glvs-options|
- 8. GetLatestVimScripts Algorithm...................: |glvs-alg|
- 9. GetLatestVimScripts History.....................: |glvs-hist|
-
-
-==============================================================================
-2. GetLatestVimScripts -- Getting Started *getscript-start*
- *getlatestvimscripts-install*
-
- VERSION FROM VIM DISTRIBUTION *glvs-dist-install*
-
-Vim 7.0 does not include the GetLatestVimScripts.dist file which
-serves as an example and a template. So, you'll need to create
-your own! See |GetLatestVimScripts_dat|.
-
- VERSION FROM VIM SF NET *glvs-install*
-
-NOTE: The last step, that of renaming/moving the GetLatestVimScripts.dist
-file, is for those who have just downloaded GetLatestVimScripts.tar.bz2 for
-the first time.
-
-The GetLatestVimScripts.dist file serves as an example and a template for your
-own personal list. Feel free to remove all the scripts mentioned within it;
-the "important" part of it is the first two lines.
-
-Your computer needs to have wget or curl for GetLatestVimScripts to do its work.
-
- 1. if compressed: gunzip getscript.vba.gz
- 2. Unix:
- vim getscript.vba
- :so %
- :q
- cd ~/.vim/GetLatest
- mv GetLatestVimScripts.dist GetLatestVimScripts.dat
- (edit GetLatestVimScripts.dat to install your own personal
- list of desired plugins -- see |GetLatestVimScripts_dat|)
-
- 3. Windows:
- vim getscript.vba
- :so %
- :q
- cd **path-to-vimfiles**/GetLatest
- mv GetLatestVimScripts.dist GetLatestVimScripts.dat
- (edit GetLatestVimScripts.dat to install your own personal
- list of desired plugins -- see |GetLatestVimScripts_dat|)
-
-
-==============================================================================
-3. GetLatestVimScripts Usage *glvs-usage* *:GLVS*
-
-Unless it has been defined elsewhere, >
-
- :GLVS
-
-will invoke GetLatestVimScripts(). If some other plugin has defined that
-command, then you may type
->
- :GetLatestVimScripts
-<
-The script will attempt to update and, if permitted, will automatically
-install scripts from http://vim.sourceforge.net/. To do so it will peruse a
-file,
->
- .vim/GetLatest/GetLatestVimScripts.dat (unix)
-<
-or >
- ..wherever..\vimfiles\GetLatest\GetLatestVimScripts.dat (windows)
-(see |glvs-data|), and examine plugins in your [.vim|vimfiles]/plugin
-directory (see |glvs-plugins|).
-
-Scripts which have been downloaded will appear in the
-~/.vim/GetLatest (unix) or ..wherever..\vimfiles\GetLatest (windows)
-subdirectory. GetLatestVimScripts will attempt to automatically
-install them if you have the following line in your <.vimrc>: >
-
- let g:GetLatestVimScripts_allowautoinstall=1
-
-The <GetLatestVimScripts.dat> file will be automatically be updated to
-reflect the latest version of script(s) so downloaded.
-(also see |glvs-options|)
-
-
-==============================================================================
-4. GetLatestVimScripts Data File *getscript-data* *glvs-data*
- *:GetLatestVimScripts_dat*
-The data file <GetLatestVimScripts.dat> must have for its first two lines
-the following text:
->
- ScriptID SourceID Filename
- --------------------------
-<
-Following those two lines are three columns; the first two are numeric
-followed by a text column. The GetLatest/GetLatestVimScripts.dist file
-contains an example of such a data file. Anything following a #... is
-ignored, so you may embed comments in the file.
-
-The first number on each line gives the script's ScriptID. When you're about
-to use a web browser to look at scripts on http://vim.sf.net/, just before you
-click on the script's link, you'll see a line resembling
-
- http://vim.sourceforge.net/scripts/script.php?script_id=40
-
-The "40" happens to be a ScriptID that GetLatestVimScripts needs to
-download the associated page, and is assigned by vim.sf.net itself
-during initial uploading of the plugin.
-
-The second number on each line gives the script's SourceID. The SourceID
-records the count of uploaded scripts as determined by vim.sf.net; hence it
-serves to indicate "when" a script was uploaded. Setting the SourceID to 1
-insures that GetLatestVimScripts will assume that the script it has is
-out-of-date.
-
-The SourceID is extracted by GetLatestVimScripts from the script's page on
-vim.sf.net; whenever it is greater than the one stored in the
-GetLatestVimScripts.dat file, the script will be downloaded
-(see |GetLatestVimScripts_dat|).
-
-If your script's author has included a special comment line in his/her plugin,
-the plugin itself will be used by GetLatestVimScripts to build your
-<GetLatestVimScripts.dat> file, including any dependencies on other scripts it
-may have. As an example, consider: >
-
- " GetLatestVimScripts: 884 1 :AutoInstall: AutoAlign.vim
-
-This comment line tells getscript.vim to check vimscript #884 and that the
-script is automatically installable. Getscript will also use this line to
-help build the GetLatestVimScripts.dat file, by including a line such as: >
-
- 884 1 :AutoInstall: AutoAlign.vim
-<
-assuming that such a line isn't already in GetLatestVimScripts.dat file.
-See |glvs-plugins| for more. Thus, GetLatestVimScripts thus provides a
-comprehensive ability to keep your plugins up-to-date!
-
-In summary:
-
- * Optionally tell getscript that it is allowed to build/append a
- GetLatestVimScripts.dat file based upon already installed plugins: >
- let g:GetLatestVimScripts_allowautoinstall=1
-<
- * A line such as >
- " GetLatestVimScripts: 884 1 :AutoInstall: AutoAlign.vim
-< in an already-downloaded plugin constitutes the concurrence of the
- plugin author that getscript may do AutoInstall. Not all plugins
- may be AutoInstall-able, and the plugin's author is best situated
- to know whether or not his/her plugin will AutoInstall properly.
-
- * A line such as >
- 884 1 :AutoInstall: AutoAlign.vim
-< in your GetLatestVimScripts.dat file constitutes your permission
- to getscript to do AutoInstall. AutoInstall requires both your
- and the plugin author's permission. See |GetLatestVimScripts_dat|.
-
-
- *GetLatestVimScripts_dat*
-As an example of a <GetLatestVimScripts.dat> file:
->
- ScriptID SourceID Filename
- --------------------------
- 294 1 :AutoInstall: Align.vim
- 120 2 Decho.vim
- 40 3 DrawIt.tar.gz
- 451 4 EasyAccents.vim
- 195 5 engspchk.vim
- 642 6 GetLatestVimScripts.vim
- 489 7 Manpageview.vim
-<
-Note: the first two lines are required, but essentially act as comments.
-
-
-==============================================================================
-5. GetLatestVimScripts Friendly Plugins *getscript-plugins* *glvs-plugins*
-
- (this section is for plugin authors)~
-
-If a plugin author includes the following comment anywhere in their plugin,
-GetLatestVimScripts will find it and use it to automatically build the user's
-GetLatestVimScripts.dat files:
->
- src_id
- v
- " GetLatestVimScripts: ### ### yourscriptname
- ^
- scriptid
-<
-As an author, you should include such a line in to refer to your own script
-plus any additional lines describing any plugin dependencies it may have.
-Same format, of course!
-
-If your command is auto-installable (see |glvs-autoinstall|), and most scripts
-are, then you may include :AutoInstall: just before "yourscriptname":
->
- src_id
- v
- " GetLatestVimScripts: ### ### :AutoInstall: yourscriptname
- ^
- scriptid
-<
-NOTE: The :AutoInstall: feature requires both the plugin author's and~
- the user's permission to operate!~
-
-GetLatestVimScripts commands for those scripts are then appended, if not
-already present, to the user's GetLatest/GetLatestVimScripts.dat file. It is
-a relatively painless way to automate the acquisition of any scripts your
-plugins depend upon.
-
-Now, as an author, you probably don't want GetLatestVimScripts to download
-your own scripts atop your own copy, thereby overwriting your not-yet-released
-hard work. GetLatestVimScripts provides a solution for this: put
->
- 0 0 yourscriptname
-<
-into your <GetLatestVimScripts.dat> file and GetLatestVimScripts will skip
-examining the "yourscriptname" scripts for those GetLatestVimScripts comment
-lines. As a result, those lines won't be inadvertently installed into your
-<GetLatestVimScripts.dat> file and subsequently used to download your own
-scripts. This is especially important to do if you've included the
-:AutoInstall: option.
-
-Be certain to use the same "yourscriptname" in the "0 0 yourscriptname" line
-as you've used in your GetLatestVimScripts comment!
-
-
-==============================================================================
-6. GetLatestVimScripts AutoInstall *getscript-autoinstall*
- *glvs-autoinstall*
-
-GetLatestVimScripts now supports "AutoInstall". Not all scripts are
-supportive of auto-install, as they may have special things you need to do to
-install them (please refer to the script's "install" directions). On the
-other hand, most scripts will be auto-installable.
-
-To let GetLatestVimScripts do an autoinstall, the data file's comment field
-should begin with (surrounding blanks are ignored): >
-
- :AutoInstall:
-<
-Both colons are needed, and it should begin the comment (yourscriptname)
-field.
-
-One may prevent any autoinstalling by putting the following line in your
-<.vimrc>: >
-
- let g:GetLatestVimScripts_allowautoinstall= 0
-<
-With :AutoInstall: enabled, as it is by default, files which end with
-
- ---.tar.bz2 : decompressed & untarred in .vim/ directory
- ---.vba.bz2 : decompressed in .vim/ directory, then vimball handles it
- ---.vim.bz2 : decompressed & moved into .vim/plugin directory
- ---.tar.gz : decompressed & untarred in .vim/ directory
- ---.vba.gz : decompressed in .vim/ directory, then vimball handles it
- ---.vim.gz : decompressed & moved into .vim/plugin directory
- ---.vba : unzipped in .vim/ directory
- ---.vim : moved to .vim/plugin directory
- ---.zip : unzipped in .vim/ directory
-
-and which merely need to have their components placed by the untar/gunzip or
-move-to-plugin-directory process should be auto-installable. Vimballs, of
-course, should always be auto-installable.
-
-When is a script not auto-installable? Let me give an example:
-
- .vim/after/syntax/blockhl.vim
-
-The <blockhl.vim> script provides block highlighting for C/C++ programs; it is
-available at:
-
- http://vim.sourceforge.net/scripts/script.php?script_id=104
-
-Currently, vim's after/syntax only supports by-filetype scripts (in
-blockhl.vim's case, that's after/syntax/c.vim). Hence, auto-install would
-possibly overwrite the current user's after/syntax/c.vim file.
-
-In my own case, I use <aftersyntax.vim> (renamed to after/syntax/c.vim) to
-allow a after/syntax/c/ directory:
-
- http://vim.sourceforge.net/scripts/script.php?script_id=1023
-
-The script allows multiple syntax files to exist separately in the
-after/syntax/c subdirectory. I can't bundle aftersyntax.vim in and build an
-appropriate tarball for auto-install because of the potential for the
-after/syntax/c.vim contained in it to overwrite a user's c.vim.
-
-
-==============================================================================
-7. GetLatestVimScripts Options *glvs-options*
->
- g:GetLatestVimScripts_wget
-< default= "wget"
- This variable holds the name of the command for obtaining
- scripts.
->
- g:GetLatestVimScripts_options
-< default= "-q -O"
- This variable holds the options to be used with the
- g:GetLatestVimScripts_wget command.
->
- g:GetLatestVimScripts_allowautoinstall
-< default= 1
- This variable indicates whether GetLatestVimScripts is allowed
- to attempt to automatically install scripts. Furthermore, the
- plugin author has to have explicitly indicated that his/her
- plugin is automatically installable (via the :AutoInstall:
- keyword in the GetLatestVimScripts comment line).
->
- g:GetLatestVimScripts_autoinstalldir
-< default= $HOME/.vim (linux)
- default= $HOME/vimfiles (windows)
- Override where :AutoInstall: scripts will be installed.
- Doesn't override vimball installation.
->
- g:GetLatestVimScripts_scriptaddr
-< default='http://vim.sourceforge.net/script.php?script_id='
- Override this if your system needs
- ... ='http://vim.sourceforge.net/script/script.php?script_id='
-
-==============================================================================
-8. GetLatestVimScripts Algorithm *glvs-algorithm* *glvs-alg*
-
-The Vim sourceforge page dynamically creates a page by keying off of the
-so-called script-id. Within the webpage of
-
- http://vim.sourceforge.net/scripts/script.php?script_id=40
-
-is a line specifying the latest source-id (src_id). The source identifier
-numbers are always increasing, hence if the src_id is greater than the one
-recorded for the script in GetLatestVimScripts then it's time to download a
-newer copy of that script.
-
-GetLatestVimScripts will then download the script and update its internal
-database of script ids, source ids, and scriptnames.
-
-The AutoInstall process will:
-
- Move the file from GetLatest/ to the following directory
- Unix : $HOME/.vim
- Windows: $HOME\vimfiles
- if the downloaded file ends with ".bz2"
- bunzip2 it
- else if the downloaded file ends with ".gz"
- gunzip it
- if the resulting file ends with ".zip"
- unzip it
- else if the resulting file ends with ".tar"
- tar -oxvf it
- else if the resulting file ends with ".vim"
- move it to the plugin subdirectory
-
-
-==============================================================================
-9. GetLatestVimScripts History *getscript-history* *glvs-hist* {{{1
-
-v36 Apr 22, 2013 : * (glts) suggested use of plugin/**/*.vim instead of
- plugin/*.vim in globpath() call.
- * (Andy Wokula) got warning message when setting
- g:loaded_getscriptPlugin
-v35 Apr 07, 2012 : * (MengHuan Yu) pointed out that the script url has
- changed (somewhat). However, it doesn't work, and
- the original one does (under Linux). I'll make it
- yet-another-option.
-v34 Jun 23, 2011 : * handles additional decompression options for tarballs
- (tgz taz tbz txz)
-v33 May 31, 2011 : * using fnameescape() instead of escape()
- * *.xz support
-v32 Jun 19, 2010 : * (Jan Steffens) added support for xz compression
-v31 Jun 29, 2008 : * (Bill McCarthy) fixed having hls enabled with getscript
- * (David Schaefer) the acd option interferes with vimballs
- Solution: bypass the acd option
-v30 Jun 13, 2008 : * GLVS now checks for existence of fnameescape() and will
- issue an error message if it is not supported
-v29 Jan 07, 2008 : * Bram M pointed out that cpo is a global option and that
- getscriptPlugin.vim was setting it but not restoring it.
-v28 Jan 02, 2008 : * improved shell quoting character handling, cygwin
- interface, register-a bypass
- Oct 29, 2007 * Bill McCarthy suggested a change to getscript that avoids
- creating pop-up windows
-v24 Apr 16, 2007 : * removed save&restore of the fo option during script
- loading
-v23 Nov 03, 2006 : * ignores comments (#...)
- * handles vimballs
-v22 Oct 13, 2006 : * supports automatic use of curl if wget is not
- available
-v21 May 01, 2006 : * now takes advantage of autoloading.
-v20 Dec 23, 2005 : * Eric Haarbauer found&fixed a bug with unzip use;
- unzip needs the -o flag to overwrite.
-v19 Nov 28, 2005 : * v18's GetLatestVimScript line accessed the wrong
- script! Fixed.
-v18 Mar 21, 2005 : * bugfix to automatic database construction
- * bugfix - nowrapscan caused an error
- (tnx to David Green for the fix)
- Apr 01, 2005 * if shell is bash, "mv" instead of "ren" used in
- :AutoInstall:s, even though its o/s is windows
- Apr 01, 2005 * when downloading errors occurred, GLVS was
- terminating early. It now just goes on to trying
- the next script (after trying three times to
- download a script description page)
- Apr 20, 2005 * bugfix - when a failure to download occurred,
- GetLatestVimScripts would stop early and claim that
- everything was current. Fixed.
-v17 Aug 25, 2004 : * g:GetLatestVimScripts_allowautoinstall, which
- defaults to 1, can be used to prevent all
- :AutoInstall:
-v16 Aug 25, 2004 : * made execution of bunzip2/gunzip/tar/zip silent
- * fixed bug with :AutoInstall: use of helptags
-v15 Aug 24, 2004 : * bugfix: the "0 0 comment" download prevention wasn't
- always preventing downloads (just usually). Fixed.
-v14 Aug 24, 2004 : * bugfix -- helptags was using dotvim, rather than
- s:dotvim. Fixed.
-v13 Aug 23, 2004 : * will skip downloading a file if its scriptid or srcid
- is zero. Useful for script authors; that way their
- own GetLatestVimScripts activity won't overwrite
- their scripts.
-v12 Aug 23, 2004 : * bugfix - a "return" got left in the distribution that
- was intended only for testing. Removed, now works.
- * :AutoInstall: implemented
-v11 Aug 20, 2004 : * GetLatestVimScripts is now a plugin:
- * :GetLatestVimScripts command
- * (runtimepath)/GetLatest/GetLatestVimScripts.dat
- now holds scripts that need updating
-v10 Apr 19, 2004 : * moved history from script to doc
-v9 Jan 23, 2004 : windows (win32/win16/win95) will use
- double quotes ("") whereas other systems will use
- single quotes ('') around the urls in calls via wget
-v8 Dec 01, 2003 : makes three tries at downloading
-v7 Sep 02, 2003 : added error messages if "Click on..." or "src_id="
- not found in downloaded webpage
- Uses t_ti, t_te, and rs to make progress visible
-v6 Aug 06, 2003 : final status messages now display summary of work
- ( "Downloaded someqty scripts" or
- "Everything was current")
- Now GetLatestVimScripts is careful about downloading
- GetLatestVimScripts.vim itself!
- (goes to <NEW_GetLatestVimScripts.vim>)
-v5 Aug 04, 2003 : missing an endif near bottom
-v4 Jun 17, 2003 : redraw! just before each "considering" message
-v3 May 27, 2003 : Protects downloaded files from errant shell
- expansions with single quotes: '...'
-v2 May 14, 2003 : extracts name of item to be obtained from the
- script file. Uses it instead of comment field
- for output filename; comment is used in the
- "considering..." line and is now just a comment!
- * Fixed a bug: a string-of-numbers is not the
- same as a number, so I added zero to them
- and they became numbers. Fixes comparison.
-
-==============================================================================
-vim:tw=78:ts=8:ft=help:fdm=marker
diff --git a/runtime/doc/pi_msgpack.txt b/runtime/doc/pi_msgpack.txt
new file mode 100644
index 0000000000..95d6ff7467
--- /dev/null
+++ b/runtime/doc/pi_msgpack.txt
@@ -0,0 +1,139 @@
+*pi_msgpack.txt* For NeoVim version 0.1.
+
+Author: Nikolay Pavlov <kp-pav@yandex.ru>
+Copyright: (c) 2015 by Nikolay Pavlov
+
+The Apache license applies to the files in this package, including
+runtime/autoload/msgpack.vim, runtime/doc/pi_msgpack.txt and
+test/functional/plugin/msgpack_spec.lua. Like anything else that's free,
+msgpack.vim and its associated files are provided *as is* and comes with no
+warranty of any kind, either expressed or implied. No guarantees of
+merchantability. No guarantees of suitability for any purpose. By using this
+plugin, you agree that in no event will the copyright holder be liable for any
+damages resulting from the use of this software. Use at your own risk!
+
+==============================================================================
+1. Contents *msgpack.vim-contents*
+
+ 1. Contents..............................: |msgpack.vim-contents|
+ 2. Msgpack.vim introduction..............: |msgpack.vim-intro|
+ 3. Msgpack.vim manual....................: |msgpack.vim-manual|
+ Function arguments....................: |msgpack.vim-arguments|
+ msgpack#is_int function...............: |msgpack#is_int()|
+ msgpack#is_uint function..............: |msgpack#is_uint()|
+ msgpack#strftime function.............: |msgpack#strftime()|
+ msgpack#strptime function.............: |msgpack#strptime()|
+ msgpack#int_dict_to_str function......: |msgpack#int_dict_to_str()|
+ msgpack#special_type function.........: |msgpack#special_type()|
+ msgpack#type function.................: |msgpack#type()|
+ msgpack#deepcopy function.............: |msgpack#deepcopy()|
+ msgpack#string function...............: |msgpack#string()|
+ msgpack#eval function.................: |msgpack#eval()|
+ msgpack#equal function................: |msgpack#equal()|
+
+
+==============================================================================
+2. Msgpack.vim introduction *msgpack.vim-intro*
+
+This plugin contains utility functions to be used in conjunction with
+|msgpackdump()| and |msgpackparse()| functions.
+
+==============================================================================
+3. Msgpack.vim manual *msgpack.vim-manual*
+
+FUNCTION ARGUMENTS *msgpack.vim-arguments*
+
+Disambiguation of arguments described below. Note: if e.g. function is listed
+as accepting |{msgpack-integer}| (or anything else) it means that function
+does not check whether argument matches its description.
+
+*{msgpack-value}* Either |msgpack-special-dict| or a regular value, but
+ not function reference.
+*{msgpack-integer}* Any value for which |msgpack#type| will return
+ "integer".
+*{msgpack-special-int}* |msgpack-special-dict| representing integer.
+
+msgpack#is_int({msgpack-value}) *msgpack#is_int()*
+ Returns 1 if given {msgpack-value} is integer value, 0 otherwise.
+
+msgpack#is_uint({msgpack-value}) *msgpack#is_uint()*
+ Returns 1 if given {msgpack-value} is integer value greater or equal
+ to zero, 0 otherwise.
+
+ *msgpack#strftime*
+msgpack#strftime({format}, {msgpack-integer}) *msgpack#strftime()*
+ Same as |strftime()|, but second argument may be
+ |msgpack-special-dict|. Requires |+python| or |+python3| to really
+ work with |msgpack-special-dict|s.
+
+ *msgpack#strptime*
+msgpack#strptime({format}, {time}) *msgpack#strptime()*
+ Reverse of |msgpack#strptime()|: for any time and format
+ |msgpack#equal|( |msgpack#strptime|(format, |msgpack#strftime|(format,
+ time)), time) be true. Requires |+python| or |+python3|, without it
+ only supports non-|msgpack-special-dict| nonnegative times and format
+ equal to `%Y-%m-%dT%H:%M:%S`.
+
+msgpack#int_dict_to_str({msgpack-special-int}) *msgpack#int_dict_to_str()*
+ Function which converts |msgpack-special-dict| integer value to
+ a hexadecimal value like 0x1234567890ABCDEF (always returns exactly 16
+ hexadecimal digits).
+
+msgpack#special_type({msgpack-value}) *msgpack#special_type()*
+ Returns zero if {msgpack-value} is not |msgpack-special-dict|. If it
+ is it returns name of the key in |v:msgpack_types| which represents
+ {msgpack-value} type.
+
+msgpack#type({msgpack-value}) *msgpack#type()*
+ Returns name of the key in |v:msgpack_types| that represents
+ {msgpack-value} type. Never returns zero: this function returns
+ msgpack type which will be dumped by |msgpackdump()| should it receive
+ a list with singe {msgpack-value} as input.
+
+msgpack#deepcopy({msgpack-value}) *msgpack#deepcopy()*
+ Like |deepcopy()|, but works correctly with |msgpack-special-dict|
+ values. Plain |deepcopy()| will destroy all types in
+ |msgpack-special-dict| values because it will copy _TYPE key values,
+ while they should be preserved.
+
+msgpack#string({msgpack-value}) *msgpack#string()*
+ Like |string()|, but saves information about msgpack types. Values
+ dumped by msgpack#string may be read back by |msgpack#eval()|.
+ Returns is the following:
+
+ - Dictionaries are dumped as "{key1: value1, key2: value2}". Note:
+ msgpack allows any values in keys, so with some
+ |msgpack-special-dict| values |msgpack#string()| may produce even
+ "{{1: 2}: 3, [4]: 5}".
+ - Lists are dumped as "[value1, value2]".
+ - Strings are dumped as
+ 1. `"abc"`: binary string.
+ 2. `="abc"`: string.
+ 3. `+(10)"ext"`: extension strings (10 may be replaced with any
+ 8-bit signed integer).
+ Inside strings the following escape sequences may be present: "\0"
+ (represents NUL byte), "\n" (represents line feed) and "\""
+ (represents double quote).
+ - Floating-point and integer values are dumped using |string()| or
+ |msgpack#int_dict_to_str()|.
+ - Booleans are dumped as "TRUE" or "FALSE".
+ - Nil values are dumped as "NIL".
+
+msgpack#eval({string}, {dict}) *msgpack#eval()*
+ Transforms string created by |msgpack#string()| into a value suitable
+ for |msgpackdump()|. Second argument allows adding special values
+ that start with head characters (|/\h|) and contain only word
+ characters (|/\w|). Built-in special values are "TRUE", "FALSE",
+ "NIL", "nan" and "inf" and they cannot be overridden. Map values are
+ always evaluated to |msgpack-special-dict| values, as well as
+ hexadecimal digits. When evaluating maps order of keys is preserved.
+
+ *msgpack#equal*
+msgpack#equal({msgpack-value}, {msgpack-value}) *msgpack#equal()*
+ Returns 1 if given values are equal, 0 otherwise. When comparing
+ msgpack map values order of keys is ignored. Comparing
+ |msgpack-special-dict| with equivalent non-special-dict value
+ evaluates to 1.
+
+==============================================================================
+vim:tw=78:ts=8:ft=help:fdm=marker
diff --git a/runtime/doc/pi_spec.txt b/runtime/doc/pi_spec.txt
index f76841832e..650d1d369b 100644
--- a/runtime/doc/pi_spec.txt
+++ b/runtime/doc/pi_spec.txt
@@ -40,7 +40,7 @@ Setting a map *spec-setting-a-map*
As you should know, you can easily set a map to access any Vim command (or
anything, for that matter). If you don't like the default map of
<LocalLeader>c, you may just set up your own key. The following line
-shows you how you could do this in your .vimrc file, mapping the plugin to
+shows you how you could do this in your vimrc file, mapping the plugin to
the <F5> key:
au FileType spec map <buffer> <F5> <Plug>SpecChangelog
@@ -58,7 +58,7 @@ The format string *spec_chglog_format*
-----------------
You can easily customize how your spec file entry will look like. To do
-this just set the variable "spec_chglog_format" in your .vimrc file like
+this just set the variable "spec_chglog_format" in your vimrc file like
this: >
let spec_chglog_format = "%a %b %d %Y My Name <my@email.com>"
@@ -92,7 +92,7 @@ that it may control if the release has been updated after the last
change in the package or not. If you have not updated the package
version or release, it will ask you if it should update the package
release for you. To turn this feature on, just insert the following
-code in your .vimrc: >
+code in your vimrc: >
let spec_chglog_release_info = 1
diff --git a/runtime/doc/print.txt b/runtime/doc/print.txt
index a6dce56c57..086d05613d 100644
--- a/runtime/doc/print.txt
+++ b/runtime/doc/print.txt
@@ -133,15 +133,17 @@ If there is no error, return zero or an empty string.
The default for non MS-Windows systems is to simply use "lpr" to print the
file: >
- system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice)
- . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error
+ system(['lpr']
+ + (empty(&printdevice)?[]:['-P', &printdevice])
+ + [v:fname_in])
+ . delete(v:fname_in)
+ + v:shell_error
On MS-Dos and MS-Windows machines the default is to copy the file to the
currently specified printdevice: >
- system('copy' . ' ' . v:fname_in . (&printdevice == ''
- ? ' LPT1:' : (' \"' . &printdevice . '\"')))
- . delete(v:fname_in)
+ system(['copy', v:fname_in, empty(&printdevice)?'LPT1':&printdevice])
+ . delete(v:fname_in)
If you change this option, using a function is an easy way to avoid having to
escape all the spaces. Example: >
diff --git a/runtime/doc/quickfix.txt b/runtime/doc/quickfix.txt
index 577b636d32..8c428e44ef 100644
--- a/runtime/doc/quickfix.txt
+++ b/runtime/doc/quickfix.txt
@@ -1277,7 +1277,7 @@ Jikes(TM), a source-to-bytecode Java compiler published by IBM Research,
produces simple multi-line error messages.
An 'errorformat' string matching the produced messages is shown below.
-The following lines can be placed in the user's |vimrc| to overwrite Vim's
+The following lines can be placed in the user's |init.vim| to overwrite Vim's
recognized default formats, or see |:set+=| how to install this format
additionally to the default. >
diff --git a/runtime/doc/quickref.txt b/runtime/doc/quickref.txt
index 1b24efc4f9..ea73b99ad2 100644
--- a/runtime/doc/quickref.txt
+++ b/runtime/doc/quickref.txt
@@ -548,7 +548,7 @@ In Insert or Command-line mode:
settings to [file] (default: ".exrc";
use ! to overwrite)
|:mkvimrc| :mkv[imrc][!] [file]
- same as ":mkexrc", but with default ".vimrc"
+ same as :mkexrc, but with default ".nvimrc"
|:mksession| :mks[ession][!] [file]
like ":mkvimrc", but store current files,
windows, etc. too, to be able to continue
@@ -600,7 +600,6 @@ Short explanation of each option: *option-list*
'allowrevins' 'ari' allow CTRL-_ in Insert and Command-line mode
'altkeymap' 'akm' for default second language (Farsi/Hebrew)
'ambiwidth' 'ambw' what to do with Unicode chars of ambiguous width
-'antialias' 'anti' Mac OS X: use smooth, antialiased fonts
'autochdir' 'acd' change directory to the file in the current window
'arabic' 'arab' for Arabic as a default second language
'arabicshape' 'arshape' do shaping for Arabic characters
@@ -681,7 +680,7 @@ Short explanation of each option: *option-list*
'esckeys' 'ek' recognize function keys in Insert mode
'eventignore' 'ei' autocommand events that are ignored
'expandtab' 'et' use spaces when <Tab> is inserted
-'exrc' 'ex' read .vimrc and .exrc in the current directory
+'exrc' 'ex' read .nvimrc and .exrc in the current directory
'fileencoding' 'fenc' file encoding for multi-byte text
'fileencodings' 'fencs' automatically detected character encodings
'fileformat' 'ff' file format used for file I/O
diff --git a/runtime/doc/quotes.txt b/runtime/doc/quotes.txt
index 11d8550121..28b0e1c623 100644
--- a/runtime/doc/quotes.txt
+++ b/runtime/doc/quotes.txt
@@ -204,7 +204,7 @@ Colon, USA)
VIM is a joy to use, it is so well thought and practical that I wonder why
anybody would use visual development tools. VIM is powerful and elegant, it
looks deceptively simple but is almost as complex as a 747 (especially when I
-look at my growing .vimrc), keep up that wonderful job, VIM is a centerpiece
+look at my growing vimrc), keep up that wonderful job, VIM is a centerpiece
of the free software world. (Louis-David Mitterand, USA)
I cannot believe how great it is to use VIM. I think the guys at work are
diff --git a/runtime/doc/recover.txt b/runtime/doc/recover.txt
index 0b67732cd1..34a579f499 100644
--- a/runtime/doc/recover.txt
+++ b/runtime/doc/recover.txt
@@ -58,7 +58,7 @@ Disadvantages:
message.
If you want to put swap files in a fixed place, put a command resembling the
-following ones in your .vimrc:
+following ones in your vimrc:
:set dir=~/tmp (for Unix)
:set dir=c:\\tmp (for MS-DOS and Win32)
This is also very handy when editing files on floppy. Of course you will have
diff --git a/runtime/doc/remote_plugin.txt b/runtime/doc/remote_plugin.txt
index 9a3fa919ea..139fcd83b9 100644
--- a/runtime/doc/remote_plugin.txt
+++ b/runtime/doc/remote_plugin.txt
@@ -93,8 +93,9 @@ approach with |rpcnotify()|, meaning return values or exceptions raised in the
handler function are ignored.
To test the above plugin, it must be saved in "rplugin/python" in a
-'runtimepath' directory (~/.nvim/rplugin/python/limit.py for example). Then,
-the remote plugin manifest must be generated with `:UpdateRemotePlugins`.
+'runtimepath' directory (~/.config/nvim/rplugin/python/limit.py for example).
+Then, the remote plugin manifest must be generated with
+`:UpdateRemotePlugins`.
==============================================================================
4. Remote plugin manifest *remote-plugin-manifest*
diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt
index 0952de425b..d029391c60 100644
--- a/runtime/doc/repeat.txt
+++ b/runtime/doc/repeat.txt
@@ -274,8 +274,8 @@ nested as deep as the number of files that can be opened at one time (about
You can use the "<sfile>" string (literally, this is not a special key) inside
of the sourced file, in places where a file name is expected. It will be
replaced by the file name of the sourced file. For example, if you have a
-"other.vimrc" file in the same directory as your ".vimrc" file, you can source
-it from your ".vimrc" file with this command: >
+"other.vimrc" file in the same directory as your |init.vim| file, you can
+source it from your |init.vim| file with this command: >
:source <sfile>:h/other.vimrc
In script files terminal-dependent key codes are represented by
@@ -482,7 +482,7 @@ DEFINING BREAKPOINTS
:breaka[dd] file [lnum] {name}
Set a breakpoint in a sourced file. Example: >
- :breakadd file 43 .vimrc
+ :breakadd file 43 init.vim
:breaka[dd] here
Set a breakpoint in the current line of the current file.
@@ -586,6 +586,9 @@ For example, to profile the one_script.vim script file: >
If {fname} already exists it will be silently overwritten.
The variable |v:profiling| is set to one.
+:prof[ile] stop
+ Write the logfile and stop profiling.
+
:prof[ile] pause
Don't profile until the following ":profile continue". Can be
used when doing something that should not be counted (e.g., an
@@ -609,6 +612,9 @@ For example, to profile the one_script.vim script file: >
after this command. A :profile command in the script itself
won't work.
+:prof[ile] dump
+ Don't wait until exiting Vim and write the current state of
+ profiling to the log immediately.
:profd[el] ... *:profd* *:profdel*
Stop profiling for the arguments specified. See |:breakdel|
diff --git a/runtime/doc/spell.txt b/runtime/doc/spell.txt
index 4fbec3694f..a45a97a0fe 100644
--- a/runtime/doc/spell.txt
+++ b/runtime/doc/spell.txt
@@ -307,26 +307,26 @@ Exceptions:
spell file is used.
For example, with these values:
- 'runtimepath' is "~/.vim,/usr/share/vim70,~/.vim/after"
+ 'runtimepath' is "~/.config/nvim,/usr/share/vim70,~/.config/nvim/after"
'encoding' is "iso-8859-2"
'spelllang' is "pl"
Vim will look for:
-1. ~/.vim/spell/pl.iso-8859-2.spl
+1. ~/.config/nvim/spell/pl.iso-8859-2.spl
2. /usr/share/vim70/spell/pl.iso-8859-2.spl
-3. ~/.vim/spell/pl.iso-8859-2.add.spl
+3. ~/.config/nvim/spell/pl.iso-8859-2.add.spl
4. /usr/share/vim70/spell/pl.iso-8859-2.add.spl
-5. ~/.vim/after/spell/pl.iso-8859-2.add.spl
+5. ~/.config/nvim/after/spell/pl.iso-8859-2.add.spl
This assumes 1. is not found and 2. is found.
If 'encoding' is "latin1" Vim will look for:
-1. ~/.vim/spell/pl.latin1.spl
+1. ~/.config/nvim/spell/pl.latin1.spl
2. /usr/share/vim70/spell/pl.latin1.spl
-3. ~/.vim/after/spell/pl.latin1.spl
-4. ~/.vim/spell/pl.ascii.spl
+3. ~/.config/nvim/after/spell/pl.latin1.spl
+4. ~/.config/nvim/spell/pl.ascii.spl
5. /usr/share/vim70/spell/pl.ascii.spl
-6. ~/.vim/after/spell/pl.ascii.spl
+6. ~/.config/nvim/after/spell/pl.ascii.spl
This assumes none of them are found (Polish doesn't make sense when leaving
out the non-ASCII characters).
diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt
index 84bd70db62..f46a258e2e 100644
--- a/runtime/doc/starting.txt
+++ b/runtime/doc/starting.txt
@@ -28,8 +28,6 @@ More generally, Vim is started with:
Option arguments and file name arguments can be mixed, and any number of them
can be given. However, watch out for options that take an argument.
-For compatibility with various Vi versions, see |cmdline-arguments|.
-
Exactly one out of the following five items may be used to choose how to
start editing:
@@ -106,7 +104,7 @@ argument.
--startuptime {fname} *--startuptime*
During startup write timing messages to the file {fname}.
This can be used to find out where time is spent while loading
- your .vimrc, plugins and opening the first file.
+ your |init.vim|, plugins and opening the first file.
When {fname} already exists new messages are appended.
(Only available when compiled with the |+startuptime|
feature).
@@ -232,8 +230,8 @@ argument.
-b Binary mode. File I/O will only recognize <NL> to separate
lines. The 'expandtab' option will be reset. The 'textwidth'
option is set to 0. 'modeline' is reset. The 'binary' option
- is set. This is done after reading the vimrc/exrc files but
- before reading any file in the arglist. See also
+ is set. This is done after reading the init.vim/exrc files
+ but before reading any file in the arglist. See also
|edit-binary|.
*-l*
@@ -312,11 +310,11 @@ argument.
be used to start Vim in a special mode, with special
mappings and settings. A shell alias can be used to make
this easy to use. For example: >
- alias vimc vim -u ~/.c_vimrc !*
+ alias vimc vim -u ~/.config/nvim/c_init.vim !*
< Also consider using autocommands; see |autocommand|.
When {vimrc} is equal to "NONE" (all uppercase), all
initializations from files and environment variables are
- skipped, including reading the |gvimrc| file when the GUI
+ skipped, including reading the |ginit.vim| file when the GUI
starts. Loading plugins is also skipped.
When {vimrc} is equal to "NORC" (all uppercase), this has the
same effect as "NONE", but loading plugins is not skipped.
@@ -373,24 +371,24 @@ accordingly. Vim proceeds in this order:
3. Execute Ex commands, from environment variables and/or files
An environment variable is read as one Ex command line, where multiple
commands must be separated with '|' or "<NL>".
- *vimrc* *exrc*
+ *init.vim* *vimrc* *exrc*
A file that contains initialization commands is called a "vimrc" file.
Each line in a vimrc file is executed as an Ex command line. It is
sometimes also referred to as "exrc" file. They are the same type of
file, but "exrc" is what Vi always used, "vimrc" is a Vim specific
- name. Also see |vimrc-intro|.
+ name, "init.vim" is Neovim specific location for vimrc file. Also see
+ |vimrc-intro|.
Places for your personal initializations:
- Unix $HOME/.vimrc or $HOME/.vim/vimrc
- MS-Windows $HOME/_vimrc, $HOME/vimfiles/vimrc
- or $VIM/_vimrc
+ Unix $XDG_CONFIG_HOME/nvim/init.vim
+ (default for $XDG_CONFIG_HOME is ~/.config)
The files are searched in the order specified above and only the first
one that is found is read.
- RECOMMENDATION: Put all your Vim configuration stuff in the
- $HOME/.vim/ directory ($HOME/vimfiles/ for MS-Windows). That makes it
- easy to copy it to another system.
+ RECOMMENDATION: Put all your Vim configuration stuff in the
+ $HOME/.config/nvim/ directory. That makes it easy to copy it to
+ another system.
If Vim was started with "-u filename", the file "filename" is used.
All following initializations until 4. are skipped. $MYVIMRC is not
@@ -402,44 +400,30 @@ accordingly. Vim proceeds in this order:
initializations until 4. are skipped. Only the "-u" option is
interpreted.
*system-vimrc*
- a. For Unix, MS-DOS, MS-Windows, and Macintosh, the system vimrc file is
- read for initializations. The path of this file is shown with the
+ a. For Unix, MS-Windows, and Macintosh, the system vimrc file is read for
+ initializations. The path of this file is shown with the
":version" command. Mostly it's "$VIM/vimrc".
- For the Macintosh the $VIMRUNTIME/macmap.vim is read.
- *VIMINIT* *.vimrc* *_vimrc* *EXINIT* *.exrc* *_exrc* *$MYVIMRC*
+ *VIMINIT* *EXINIT* *$MYVIMRC*
b. Four places are searched for initializations. The first that exists
is used, the others are ignored. The $MYVIMRC environment variable is
set to the file that was first found, unless $MYVIMRC was already set
and when using VIMINIT.
- The environment variable VIMINIT
The value of $VIMINIT is used as an Ex command line.
- - The user vimrc file(s):
- "$HOME/.vimrc" (for Unix)
- "$HOME/.vim/vimrc" (for Unix)
- "$HOME/_vimrc" (for Win32)
- "$HOME/vimfiles/vimrc" (for Win32)
- "$VIM/_vimrc" (for Win32)
- Note: For Unix, when ".vimrc" does not exist,
- "_vimrc" is also tried, in case an MS-DOS compatible file
- system is used. For MS-DOS and Win32 ".vimrc" is checked
- after "_vimrc", in case long file names are used.
- Note: For MS-DOS and Win32, "$HOME" is checked first. If no
- "_vimrc" or ".vimrc" is found there, "$VIM" is tried.
- See |$VIM| for when $VIM is not set.
+ - The user vimrc file: $XDG_CONFIG_HOME/nvim/init.vim.
+ - Other vimrc file: {xdg_config_dir}/nvim/init.vim where
+ {xdg_config_dir} is one of the directories in $XDG_CONFIG_DIRS.
- The environment variable EXINIT.
The value of $EXINIT is used as an Ex command line.
- - The user exrc file(s). Same as for the user vimrc file, but with
- "vimrc" replaced by "exrc". But only one of ".exrc" and "_exrc" is
- used, depending on the system.
c. If the 'exrc' option is on (which is not the default), the current
directory is searched for three files. The first that exists is used,
the others are ignored.
- - The file ".vimrc" (for Unix)
- "_vimrc" (for Win32)
- - The file "_vimrc" (for Unix)
- ".vimrc" (for Win32)
+ - The file ".nvimrc" (for Unix)
+ "_nvimrc" (for Win32)
+ - The file "_nvimrc" (for Unix)
+ ".nvimrc" (for Win32)
- The file ".exrc" (for Unix)
"_exrc" (for Win32)
@@ -504,12 +488,12 @@ Some hints on using initializations:
Standard setup:
Create a vimrc file to set the default settings and mappings for all your edit
sessions. Put it in a place so that it will be found by 3b:
- ~/.vimrc (Unix)
- $VIM\_vimrc (MS-DOS and Win32)
+ ~/.config/nvim/init.vim (Unix)
+ ~/AppData/Local/nvim/init.vim (Win32)
Local setup:
Put all commands that you need for editing a specific directory only into a
-vimrc file and place it in that directory under the name ".vimrc" ("_vimrc"
+vimrc file and place it in that directory under the name ".nvimrc" ("_nvimrc"
for MS-DOS and Win32). NOTE: To make Vim look for these special files you
have to turn on the option 'exrc'. See |trojan-horse| too.
@@ -517,7 +501,9 @@ System setup:
This only applies if you are managing a Unix system with several users and
want to set the defaults for all users. Create a vimrc file with commands
for default settings and mappings and put it in the place that is given with
-the ":version" command.
+the ":version" command. NOTE: System vimrc file needs specific compilation
+options (one needs to define SYS_VIMRC_FILE macros). If :version command does
+not show anything like this, consider contacting the nvim package maintainer.
Saving the current state of Vim to a file:
Whenever you have changed values of options or when you have created a
@@ -526,7 +512,8 @@ mapping, then you may want to save them in a vimrc file for later use. See
Avoiding setup problems for Vi users:
Vi uses the variable EXINIT and the file "~/.exrc". So if you do not want to
-interfere with Vi, then use the variable VIMINIT and the file "vimrc" instead.
+interfere with Vi, then use the variable VIMINIT and the file init.vim
+instead.
MS-DOS line separators:
On MS-DOS-like systems (MS-DOS itself and Win32), Vim assumes that all
@@ -538,7 +525,7 @@ The $MYVIMRC or $MYGVIMRC file will be set to the first found vimrc and/or
gvimrc file.
Avoiding trojan horses: *trojan-horse*
-While reading the "vimrc" or the "exrc" file in the current directory, some
+While reading the vimrc or the exrc file in the current directory, some
commands can be disabled for security reasons by setting the 'secure' option.
This is always done when executing the command from a tags file. Otherwise it
would be possible that you accidentally use a vimrc or tags file that somebody
@@ -547,8 +534,8 @@ that start a shell, the ones that write to a file, and ":autocmd". The ":map"
commands are echoed, so you can see which keys are being mapped.
If you want Vim to execute all commands in a local vimrc file, you
can reset the 'secure' option in the EXINIT or VIMINIT environment variable or
-in the global "exrc" or "vimrc" file. This is not possible in "vimrc" or
-"exrc" in the current directory, for obvious reasons.
+in the global exrc or vimrc file. This is not possible in vimrc or
+exrc in the current directory, for obvious reasons.
On Unix systems, this only happens if you are not the owner of the
vimrc file. Warning: If you unpack an archive that contains a vimrc or exrc
file, it will be owned by you. You won't have the security protection. Check
@@ -603,7 +590,7 @@ though.
4. $VIM and $VIMRUNTIME
*$VIM*
The environment variable "$VIM" is used to locate various user files for Vim,
-such as the user startup script ".vimrc". This depends on the system, see
+such as the user startup script |init.vim|. This depends on the system, see
|startup|.
To avoid the need for every user to set the $VIM environment variable, Vim
@@ -712,7 +699,7 @@ vimrc file.
directory).
*:mkv* *:mkvimrc*
-:mkv[imrc][!] [file] Like ":mkexrc", but the default is ".vimrc" in the
+:mkv[imrc][!] [file] Like ":mkexrc", but the default is ".nvimrc" in the
current directory. The ":version" command is also
written to the file.
@@ -731,13 +718,13 @@ can be used with different terminals.
Only global mappings are stored, not mappings local to a buffer.
-A common method is to use a default ".vimrc" file, make some modifications
+A common method is to use a default |init.vim| file, make some modifications
with ":map" and ":set" commands and write the modified file. First read the
-default ".vimrc" in with a command like ":source ~piet/.vimrc.Cprogs", change
+default vimrc in with a command like ":source ~piet/.vimrc.Cprogs", change
the settings and then save them in the current directory with ":mkvimrc!". If
-you want to make this file your default .vimrc, move it to your home directory
-(on Unix) or $VIM directory (MS-DOS). You could also use
-autocommands |autocommand| and/or modelines |modeline|.
+you want to make this file your default |init.vim|, move it to
+$XDG_CONFIG_HOME/nvim. You could also use autocommands |autocommand| and/or
+modelines |modeline|.
*vimrc-option-example*
If you only want to add a single option setting to your vimrc, you can use
@@ -1057,10 +1044,8 @@ even if other entries (with known name/type/etc) are merged. |shada-merging|
SHADA FILE NAME *shada-file-name*
-- The default name of the ShaDa file is "$HOME/.nvim/shada/main.shada" for
- Unix, "$HOME\_nvim\shada\main.shada" for MS-DOS and Win32. For the last
- two, when $HOME is not set, "$VIM\_nvim\shada\main.shada" is used. When
- $VIM is also not set, "c:\_nvim\shada\main.shada" is used.
+- The default name of the ShaDa file is "$XDG_DATA_HOME/nvim/shada/main.shada"
+ for Unix. Default for $XDG_DATA_HOME is ~/.local/share.
- The 'n' flag in the 'shada' option can be used to specify another ShaDa
file name |'shada'|.
- The "-i" Vim argument can be used to set another file name, |-i|. When the
@@ -1103,7 +1088,7 @@ do this. This can be useful in order to create a second file, say
"~/.my.shada" which could contain certain settings that you always want when
you first start Neovim. For example, you can preload registers with
particular data, or put certain commands in the command line history. A line
-in your .nvimrc file like >
+in your |init.vim| file like >
:rshada! ~/.my.shada
can be used to load this information. You could even have different ShaDa
files for different types of files (e.g., C code) and load them based on the
@@ -1167,18 +1152,22 @@ running) you have additional options:
empty, marks for up to 100 files will be written.
When you get error "E138: All .tmp.X files exist,
cannot write ShaDa file!" check that no old temp files
- were left behind (e.g. ~/.nvim/shada/main.shada.tmp*).
+ were left behind (e.g.
+ ~/.local/share/nvim/shada/main.shada.tmp*).
+
+ Note: Executing :wshada will reset all |'quote| marks.
*:wv* *:wviminfo*
:wv[iminfo][!] [file] Deprecated alias to |:wshada| command.
- *:ol* *:oldfiles*
-:ol[dfiles] List the files that have marks stored in the ShaDa
+ *:o* *:ol* *:oldfiles*
+:o[ldfiles][!] List the files that have marks stored in the ShaDa
file. This list is read on startup and only changes
afterwards with ":rshada!". Also see |v:oldfiles|.
The number can be used with |c_#<|.
+ Use ! to get a file selection prompt.
-:bro[wse] ol[dfiles][!]
+:bro[wse] o[ldfiles][!]
List file names as with |:oldfiles|, and then prompt
for a number. When the number is valid that file from
the list is edited.
@@ -1241,6 +1230,8 @@ exactly four MessagePack objects:
With |shada-h| or 'nohlsearch'
this key is always false.
sp Binary N/A Actual pattern. Required.
+ sb Boolean false True if search direction is
+ backward.
* any none Other keys are allowed for
compatibility reasons, see
|shada-compatibility|.
diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt
index 8fe6b4b9d1..67550365a3 100644
--- a/runtime/doc/syntax.txt
+++ b/runtime/doc/syntax.txt
@@ -143,14 +143,14 @@ automatically with ":syntax enable", do this:
1. Create your user runtime directory. You would normally use the first item
of the 'runtimepath' option. Example for Unix: >
- mkdir ~/.vim
+ mkdir ~/.config/nvim
2. Create a directory in there called "syntax". For Unix: >
- mkdir ~/.vim/syntax
+ mkdir ~/.config/nvim/syntax
3. Write the Vim syntax file. Or download one from the internet. Then write
it in your syntax directory. For example, for the "mine" syntax: >
- :w ~/.vim/syntax/mine.vim
+ :w ~/.config/nvim/syntax/mine.vim
Now you can start using your syntax file manually: >
:set syntax=mine
@@ -170,8 +170,8 @@ add a few items or change the highlighting, follow these steps:
1. Create your user directory from 'runtimepath', see above.
2. Create a directory in there called "after/syntax". For Unix: >
- mkdir ~/.vim/after
- mkdir ~/.vim/after/syntax
+ mkdir ~/.config/nvim/after
+ mkdir ~/.config/nvim/after/syntax
3. Write a Vim script that contains the commands you want to use. For
example, to change the colors for the C syntax: >
@@ -179,15 +179,15 @@ add a few items or change the highlighting, follow these steps:
4. Write that file in the "after/syntax" directory. Use the name of the
syntax, with ".vim" added. For our C syntax: >
- :w ~/.vim/after/syntax/c.vim
+ :w ~/.config/nvim/after/syntax/c.vim
That's it. The next time you edit a C file the Comment color will be
different. You don't even have to restart Vim.
If you have multiple files, you can use the filetype as the directory name.
All the "*.vim" files in this directory will be used, for example:
- ~/.vim/after/syntax/c/one.vim
- ~/.vim/after/syntax/c/two.vim
+ ~/.config/nvim/after/syntax/c/one.vim
+ ~/.config/nvim/after/syntax/c/two.vim
REPLACING AN EXISTING SYNTAX FILE *mysyntaxfile-replace*
@@ -471,7 +471,7 @@ moves through the buffer, switches windows, and the like: >
vim -E -s -c "let g:html_no_progress=1" -c "syntax on" -c "set ft=c" -c "runtime syntax/2html.vim" -cwqa myfile.c
<
-Note that the -s flag prevents loading your .vimrc and any plugins, so you
+Note that the -s flag prevents loading your vimrc and any plugins, so you
need to explicitly source/enable anything that will affect the HTML
conversion. See |-E| and |-s-ex| for details. It is probably best to create a
script to replace all the -c commands and use it with the -u flag instead of
@@ -874,13 +874,13 @@ for both 3 GL and 4 GL programming. Large number of standard defines/constants
are supported.
Some special violation of coding standards will be signalled when one specify
-in ones |.vimrc|: >
+in ones |init.vim|: >
let baan_code_stds=1
*baan-folding*
Syntax folding can be enabled at various levels through the variables
-mentioned below (Set those in your |.vimrc|). The more complex folding on
+mentioned below (Set those in your |init.vim|). The more complex folding on
source blocks and SQL can be CPU intensive.
To allow any folding and enable folding at function level use: >
@@ -894,8 +894,8 @@ SELECTEMPTY, ... The indentation preceding the begin/end keywords has to
match (spaces are not considered equal to a tab). >
let baan_fold_sql=1
Note: Block folding can result in many small folds. It is suggested to |:set|
-the options 'foldminlines' and 'foldnestmax' in |.vimrc| or use |:setlocal| in
-.../after/syntax/baan.vim (see |after-directory|). Eg: >
+the options 'foldminlines' and 'foldnestmax' in |init.vim| or use |:setlocal|
+in .../after/syntax/baan.vim (see |after-directory|). Eg: >
set foldminlines=5
set foldnestmax=6
@@ -977,7 +977,7 @@ highlighting for cErrInParen and cErrInBracket.
If you want to use folding in your C files, you can add these lines in a file
in the "after" directory in 'runtimepath'. For Unix this would be
-~/.vim/after/syntax/c.vim. >
+~/.config/nvim/after/syntax/c.vim. >
syn sync fromstart
set foldmethod=syntax
@@ -1004,7 +1004,7 @@ chill_minlines like c_minlines
CHANGELOG *changelog.vim* *ft-changelog-syntax*
ChangeLog supports highlighting spaces at the start of a line.
-If you do not like this, add following line to your .vimrc: >
+If you do not like this, add following line to your vimrc: >
let g:changelog_spacing_errors = 0
This works the next time you edit a changelog file. You can also use
"b:changelog_spacing_errors" to set this per buffer (before loading the syntax
@@ -1037,7 +1037,7 @@ COBOL *cobol.vim* *ft-cobol-syntax*
COBOL highlighting has different needs for legacy code than it does for fresh
development. This is due to differences in what is being done (maintenance
versus development) and other factors. To enable legacy code highlighting,
-add this line to your .vimrc: >
+add this line to your vimrc: >
:let cobol_legacy_code = 1
To disable it again, use this: >
:unlet cobol_legacy_code
@@ -1090,7 +1090,7 @@ Cynlib files are C++ files that use the Cynlib class library to enable
hardware modelling and simulation using C++. Typically Cynlib files have a .cc
or a .cpp extension, which makes it very difficult to distinguish them from a
normal C++ file. Thus, to enable Cynlib highlighting for .cc files, add this
-line to your .vimrc file: >
+line to your vimrc file: >
:let cynlib_cyntax_for_cc=1
@@ -1202,7 +1202,7 @@ or >
It can also be done automatically for C, C++, C#, IDL and PHP files by setting
the global or buffer-local variable load_doxygen_syntax. This is done by
-adding the following to your .vimrc. >
+adding the following to your vimrc. >
:let g:load_doxygen_syntax=1
There are a couple of variables that have an effect on syntax highlighting, and
@@ -1355,7 +1355,7 @@ start of a new paragraph, so the ftplugin sets 'tw'=0 (unlimited line length),
and so on. It also includes some keymaps that are disabled by default.
If you want to enable the keymaps that make "j" and "k" and the cursor keys
-move up and down by display lines, add this to your .vimrc: >
+move up and down by display lines, add this to your vimrc: >
:let flexwiki_maps = 1
@@ -1407,10 +1407,10 @@ syntax highlighting will not be correct if the form is incorrectly set.
When you create a new fortran file, the syntax script assumes fixed source
form. If you always use free source form, then >
:let fortran_free_source=1
-in your .vimrc prior to the :syntax on command. If you always use fixed source
+in your vimrc prior to the :syntax on command. If you always use fixed source
form, then >
:let fortran_fixed_source=1
-in your .vimrc prior to the :syntax on command.
+in your vimrc prior to the :syntax on command.
If the form of the source code depends upon the file extension, then it is
most convenient to set fortran_free_source in a ftplugin file. For more
@@ -1426,7 +1426,7 @@ rest in fixed source form, add the following code to your ftplugin file >
unlet! fortran_free_source
endif
Note that this will work only if the "filetype plugin indent on" command
-precedes the "syntax on" command in your .vimrc file.
+precedes the "syntax on" command in your vimrc file.
When you edit an existing fortran file, the syntax script will assume free
source form if the fortran_free_source variable has been set, and assumes
@@ -1446,7 +1446,7 @@ Tabs are not recognized by the Fortran standards. Tabs are not a good idea in
fixed format fortran source code which requires fixed column boundaries.
Therefore, tabs are marked as errors. Nevertheless, some programmers like
using tabs. If your fortran files contain tabs, then you should set the
-variable fortran_have_tabs in your .vimrc with a command such as >
+variable fortran_have_tabs in your vimrc with a command such as >
:let fortran_have_tabs=1
placed prior to the :syntax on command. Unfortunately, the use of tabs will
mean that the syntax file will not be able to detect incorrect margins.
@@ -1492,7 +1492,7 @@ other legacy features excluded from F will be highlighted as todo items and
that free source form will be assumed.
The dialect can be selected in various ways. If all your fortran files use
-the same dialect, set the global variable fortran_dialect in your .vimrc prior
+the same dialect, set the global variable fortran_dialect in your vimrc prior
to your syntax on statement. The case-sensitive, permissible values of
fortran_dialect are "f08" or "F". Invalid values of fortran_dialect are
ignored.
@@ -1509,7 +1509,7 @@ contain the code >
unlet! b:fortran_dialect
endif
Note that this will work only if the "filetype plugin indent on" command
-precedes the "syntax on" command in your .vimrc file.
+precedes the "syntax on" command in your vimrc file.
Finer control is necessary if the file extension does not uniquely identify
the dialect. You can override the default dialect, on a file-by-file basis,
@@ -1561,7 +1561,7 @@ in /usr/X11/lib/X11/, you should add the line >
:let rgb_file = "/usr/X11/lib/X11/rgb.txt"
-to your .vimrc file.
+to your vimrc file.
GSP *gsp.vim* *ft-gsp-syntax*
@@ -1603,7 +1603,7 @@ Haskell code, the latter in both Bird style and TeX style. The Haskell
syntax highlighting will also highlight C preprocessor directives.
If you want to highlight delimiter characters (useful if you have a
-light-coloured background), add to your .vimrc: >
+light-coloured background), add to your vimrc: >
:let hs_highlight_delimiters = 1
To treat True and False as keywords as opposed to ordinary identifiers,
add: >
@@ -1613,21 +1613,21 @@ To also treat the names of primitive types as keywords: >
And to treat the names of even more relatively common types as keywords: >
:let hs_highlight_more_types = 1
If you want to highlight the names of debugging functions, put in
-your .vimrc: >
+your vimrc: >
:let hs_highlight_debug = 1
The Haskell syntax highlighting also highlights C preprocessor
directives, and flags lines that start with # but are not valid
directives as erroneous. This interferes with Haskell's syntax for
operators, as they may start with #. If you want to highlight those
-as operators as opposed to errors, put in your .vimrc: >
+as operators as opposed to errors, put in your vimrc: >
:let hs_allow_hash_operator = 1
The syntax highlighting for literate Haskell code will try to
automatically guess whether your literate Haskell code contains
TeX markup or not, and correspondingly highlight TeX constructs
or nothing at all. You can override this globally by putting
-in your .vimrc >
+in your vimrc >
:let lhs_markup = none
for no highlighting at all, or >
:let lhs_markup = tex
@@ -1720,7 +1720,7 @@ The coloring scheme for HTML/OS works as follows:
Functions and variable names are the same color by default, because VIM
doesn't specify different colors for Functions and Identifiers. To change
this (which is recommended if you want function names to be recognizable in a
-different color) you need to add the following line to either your ~/.vimrc: >
+different color) you need to add the following line to your vimrc: >
:hi Function term=underline cterm=bold ctermfg=LightGray
Of course, the ctermfg can be a different color if you choose.
@@ -1739,7 +1739,7 @@ IA64 *ia64.vim* *intel-itanium* *ft-ia64-syntax*
Highlighting for the Intel Itanium 64 assembly language. See |asm.vim| for
how to recognize this filetype.
-To have *.inc files be recognized as IA64, add this to your .vimrc file: >
+To have *.inc files be recognized as IA64, add this to your vimrc file: >
:let g:filetype_inc = "ia64"
@@ -1901,7 +1901,7 @@ difficulties (such as may happen with large lex files).
LIFELINES *lifelines.vim* *ft-lifelines-syntax*
-To highlight deprecated functions as errors, add in your .vimrc: >
+To highlight deprecated functions as errors, add in your vimrc: >
:let g:lifelines_deprecated = 1
<
@@ -1944,7 +1944,7 @@ LPC *lpc.vim* *ft-lpc-syntax*
LPC stands for a simple, memory-efficient language: Lars Pensj| C. The
file name of LPC is usually *.c. Recognizing these files as LPC would bother
users writing only C programs. If you want to use LPC syntax in Vim, you
-should set a variable in your .vimrc file: >
+should set a variable in your vimrc file: >
:let lpc_syntax_for_c = 1
@@ -2023,13 +2023,13 @@ MAPLE *maple.vim* *ft-maple-syntax*
Maple V, by Waterloo Maple Inc, supports symbolic algebra. The language
supports many packages of functions which are selectively loaded by the user.
The standard set of packages' functions as supplied in Maple V release 4 may be
-highlighted at the user's discretion. Users may place in their .vimrc file: >
+highlighted at the user's discretion. Users may place in their vimrc file: >
:let mvpkg_all= 1
to get all package functions highlighted, or users may select any subset by
choosing a variable/package from the table below and setting that variable to
-1, also in their .vimrc file (prior to sourcing
+1, also in their vimrc file (prior to sourcing
$VIMRUNTIME/syntax/syntax.vim).
Table of Maple V Package Function Selectors >
@@ -2046,7 +2046,7 @@ $VIMRUNTIME/syntax/syntax.vim).
MATHEMATICA *mma.vim* *ft-mma-syntax* *ft-mathematica-syntax*
Empty *.m files will automatically be presumed to be Matlab files unless you
-have the following in your .vimrc: >
+have the following in your vimrc: >
let filetype_m = "mma"
@@ -2172,7 +2172,7 @@ highlighting definition for the syntax groups "nroffDefinition" and
\ gui=reverse,bold
If you want to navigate preprocessor entries in your source file as easily as
-with section markers, you can activate the following option in your .vimrc
+with section markers, you can activate the following option in your vimrc
file: >
let b:preprocs_as_sections = 1
@@ -2625,7 +2625,7 @@ number is that redrawing can become slow.
Vim tries to guess what type a ".r" file is. If it can't be detected (from
comment lines), the default is "r". To make the default rexx add this line to
-your .vimrc: *g:filetype_r*
+your vimrc: *g:filetype_r*
>
:let g:filetype_r = "r"
@@ -2808,7 +2808,7 @@ be shell files but the type is not apparent. Furthermore, on many systems
sh is symbolically linked to "bash" (Linux, Windows+cygwin) or "ksh" (Posix).
One may specify a global default by instantiating one of the following three
-variables in your <.vimrc>:
+variables in your vimrc:
ksh: >
let g:is_kornshell = 1
@@ -2823,7 +2823,7 @@ If there's no "#! ..." line, and the user hasn't availed himself/herself of a
default sh.vim syntax setting as just shown, then syntax/sh.vim will assume
the Bourne shell syntax. No need to quote RFCs or market penetration
statistics in error reports, please -- just select the default version of the
-sh your system uses in your <.vimrc>.
+sh your system uses in your vimrc.
The syntax/sh.vim file provides several levels of syntax-based folding: >
@@ -2869,7 +2869,7 @@ this behavior with: >
You may wish to embed languages into sh. I'll give an example courtesy of
Lorance Stinson on how to do this with awk as an example. Put the following
-file into $HOME/.vim/after/syntax/sh/awkembed.vim: >
+file into $HOME/.config/nvim/after/syntax/sh/awkembed.vim: >
" AWK Embedding: {{{1
" ==============
@@ -2945,7 +2945,7 @@ for how the filetype is detected.
Tcsh does not allow \" in strings unless the "backslash_quote" shell variable
is set. If you want VIM to assume that no backslash quote constructs exist add
-this line to your .vimrc: >
+this line to your vimrc: >
:let tcsh_backslash_quote = 0
@@ -2986,7 +2986,7 @@ TEX *tex.vim* *ft-tex-syntax* *latex-syntax*
As of version 28 of <syntax/tex.vim>, syntax-based folding of parts, chapters,
sections, subsections, etc are supported. Put >
let g:tex_fold_enabled=1
-in your <.vimrc>, and :set fdm=syntax. I suggest doing the latter via a
+in your vimrc, and :set fdm=syntax. I suggest doing the latter via a
modeline at the end of your LaTeX file: >
% vim: fdm=syntax
If your system becomes too slow, then you might wish to look into >
@@ -2997,7 +2997,7 @@ If your system becomes too slow, then you might wish to look into >
If you don't want spell checking anywhere in your LaTeX document, put >
let g:tex_nospell=1
-into your .vimrc. If you merely wish to suppress spell checking inside
+into your vimrc. If you merely wish to suppress spell checking inside
comments only, see |g:tex_comment_nospell|.
*tex-nospell* *g:tex_comment_nospell*
@@ -3005,7 +3005,7 @@ comments only, see |g:tex_comment_nospell|.
Some folks like to include things like source code in comments and so would
prefer that spell checking be disabled in comments in LaTeX files. To do
-this, put the following in your <.vimrc>: >
+this, put the following in your vimrc: >
let g:tex_comment_nospell= 1
If you want to suppress spell checking everywhere inside your LaTeX document,
see |g:tex_nospell|.
@@ -3015,7 +3015,7 @@ see |g:tex_nospell|.
Often verbatim regions are used for things like source code; seldom does
one want source code spell-checked. However, for those of you who do
-want your verbatim zones spell-checked, put the following in your <.vimrc>: >
+want your verbatim zones spell-checked, put the following in your vimrc: >
let g:tex_verbspell= 1
<
*tex-runon* *tex-stopzone*
@@ -3050,7 +3050,7 @@ Finally, if syntax highlighting is still too slow, you may set >
:let g:tex_fast= ""
-in your .vimrc. Used this way, the g:tex_fast variable causes the syntax
+in your vimrc. Used this way, the g:tex_fast variable causes the syntax
highlighting script to avoid defining any regions and associated
synchronization. The result will be much faster syntax highlighting; the
price: you will no longer have as much highlighting or any syntax-based
@@ -3092,7 +3092,7 @@ http://vim.sf.net/.
The <tex.vim> supports lexical error checking of various sorts. Thus,
although the error checking is ofttimes very useful, it can indicate
errors where none actually are. If this proves to be a problem for you,
-you may put in your <.vimrc> the following statement: >
+you may put in your vimrc the following statement: >
let g:tex_no_error=1
and all error checking by <syntax/tex.vim> will be suppressed.
@@ -3122,7 +3122,7 @@ such use of @ as an error. To solve this: >
:let b:tex_stylish = 1
:set ft=tex
-Putting "let g:tex_stylish=1" into your <.vimrc> will make <syntax/tex.vim>
+Putting "let g:tex_stylish=1" into your vimrc will make <syntax/tex.vim>
always accept such use of @.
*tex-cchar* *tex-cole* *tex-conceal*
@@ -3142,7 +3142,7 @@ with |'conceallevel'| at 0 and the other at 2; and both using |'scrollbind'|.
Tex: Selective Conceal Mode~
You may selectively use conceal mode by setting g:tex_conceal in your
-<.vimrc>. By default, g:tex_conceal is set to "admgs" to enable concealment
+vimrc. By default, g:tex_conceal is set to "admgs" to enable concealment
for the following sets of characters: >
a = accents/ligatures
@@ -3193,8 +3193,8 @@ syntax highlighting script handles this with the following logic:
For example, I use Luxi Mono Bold; it doesn't support subscript
characters for "hklmnpst", so I put >
let g:tex_subscripts= "[0-9aeijoruvx,+-/().]"
-< in ~/.vim/ftplugin/tex/tex.vim in order to avoid having inscrutable
- utf-8 glyphs appear.
+< in ~/.config/nvim/ftplugin/tex/tex.vim in order to avoid having
+ inscrutable utf-8 glyphs appear.
TF *tf.vim* *ft-tf-syntax*
@@ -3252,7 +3252,7 @@ The syntax of XF86Config file differs in XFree86 v3.x and v4.x. Both
variants are supported. Automatic detection is used, but is far from perfect.
You may need to specify the version manually. Set the variable
xf86conf_xfree86_version to 3 or 4 according to your XFree86 version in
-your .vimrc. Example: >
+your vimrc. Example: >
:let xf86conf_xfree86_version=3
When using a mix of versions, set the b:xf86conf_xfree86_version variable.
@@ -4646,7 +4646,7 @@ ctermbg={color-nr} *highlight-ctermbg*
When you have set "ctermfg" or "ctermbg" for the Normal group, Vim
needs to reset the color when exiting. This is done with the "op"
termcap entry |t_op|. If this doesn't work correctly, try setting the
- 't_op' option in your .vimrc.
+ 't_op' option in your vimrc.
*E419* *E420*
When Vim knows the normal foreground and background colors, "fg" and
"bg" can be used as color names. This only works after setting the
@@ -4979,7 +4979,8 @@ script file to set these colors. Put this file in a directory in
the default colors. This way these colors will be used after the ":syntax
reset" command.
-For Unix you can use the file ~/.vim/after/syntax/syncolor.vim. Example: >
+For Unix you can use the file ~/.config/nvim/after/syntax/syncolor.vim.
+Example: >
if &background == "light"
highlight comment ctermfg=darkgreen guifg=darkgreen
@@ -5036,7 +5037,7 @@ types.vim: *.[ch]
awk 'BEGIN{printf("syntax keyword Type\t")}\
{printf("%s ", $$1)}END{print ""}' > $@
-And put these lines in your .vimrc: >
+And put these lines in your vimrc: >
" load the types.vim highlighting file, if it exists
autocmd BufRead,BufNewFile *.[ch] let fname = expand('<afile>:p:h') . '/types.vim'
@@ -5078,7 +5079,7 @@ When splitting the window, the new window will use the original syntax.
17. Color xterms *xterm-color* *color-xterm*
Most color xterms have only eight colors. If you don't get colors with the
-default setup, it should work with these lines in your .vimrc: >
+default setup, it should work with these lines in your vimrc: >
:if &term =~ "xterm"
: if has("terminfo")
: set t_Co=8
@@ -5125,7 +5126,7 @@ supports. >
If you only get 8 colors, check the xterm compilation settings.
(Also see |UTF8-xterm| for using this xterm with UTF-8 character encoding).
-This xterm should work with these lines in your .vimrc (for 16 colors): >
+This xterm should work with these lines in your vimrc (for 16 colors): >
:if has("terminfo")
: set t_Co=16
: set t_AB=<Esc>[%?%p1%{8}%<%t%p1%{40}%+%e%p1%{92}%+%;%dm
diff --git a/runtime/doc/term.txt b/runtime/doc/term.txt
index 9aff8f1b84..618d4e5df9 100644
--- a/runtime/doc/term.txt
+++ b/runtime/doc/term.txt
@@ -37,7 +37,7 @@ used. Also see |xterm-screens|.
Settings depending on terminal *term-dependent-settings*
If you want to set options or mappings, depending on the terminal name, you
-can do this best in your .vimrc. Example: >
+can do this best in your vimrc. Example: >
if &term == "xterm"
... xterm maps and settings ...
diff --git a/runtime/doc/tips.txt b/runtime/doc/tips.txt
index 9ed8f1f544..8032af7d0a 100644
--- a/runtime/doc/tips.txt
+++ b/runtime/doc/tips.txt
@@ -98,7 +98,7 @@ What you need:
- An identifier database file called "ID" in the current directory. You can
create it with the shell command "mkid file1 file2 ..".
-Put this in your .vimrc: >
+Put this in your |init.vim|: >
map _u :call ID_search()<Bar>execute "/\\<" . g:word . "\\>"<CR>
map _n :n<Bar>execute "/\\<" . g:word . "\\>"<CR>
@@ -404,7 +404,7 @@ See section |23.4| of the user manual.
If one has a particular extension that one uses for binary files (such as exe,
bin, etc), you may find it helpful to automate the process with the following
-bit of autocmds for your <.vimrc>. Change that "*.bin" to whatever
+bit of autocmds for your |init.vim|. Change that "*.bin" to whatever
comma-separated list of extension(s) you find yourself wanting to edit: >
" vim -b : edit binary using xxd-format!
diff --git a/runtime/doc/todo.txt b/runtime/doc/todo.txt
deleted file mode 100644
index 65e69a901b..0000000000
--- a/runtime/doc/todo.txt
+++ /dev/null
@@ -1,4903 +0,0 @@
-*todo.txt* For Vim version 7.4. Last change: 2014 Dec 06
-
-
- VIM REFERENCE MANUAL by Bram Moolenaar
-
-
- TODO list for Vim *todo*
-
-This is a veeeery long list of known bugs, current work and desired
-improvements. To make it a little bit accessible, the items are grouped by
-subject. In the first column of the line a classification is used to be able
-to look for "the next thing to do":
-
-Priority classification:
-9 next point release
-8 next release
-7 as soon as possible
-6 soon
-5 should be included
-4 nice to have
-3 consider including
-2 maybe not
-1 probably not
-- unclassified
-
- *votes-for-changes*
-See |develop.txt| for development plans. You can vote for which items should
-be worked on, but only if you sponsor Vim development. See |sponsor|.
-
-Issues can also be entered online: http://code.google.com/p/vim/issues/list
-Updates will be forwarded to the vim_dev maillist. Issues entered there will
-not be repeated below, unless there is extra information.
-
- *known-bugs*
--------------------- Known bugs and current work -----------------------
-
-Patch to fix list range assign crash. (Yukihiro Nakadaira, 2014 Dec 1)
-
-Patch to fix range with user command. (Marcin Szamotulski, 2014 Dec 2)
-Update Dec 6, with support for user commands.
-
-When window number in Ex range is too high, give an error?
-Only when backwards compatible.
-
-:s/\n// doesn't change anything. Since 7.4.232? (Eliseo Martínez, 2014 Nov
-28) Patch on Issue 287
-
-Using vim_snprintf() in window.c can be in a function.
-
-Regexp problems:
-- The NFA engine does not implement the time limit passed to
- nfa_regexec_multi()
-- Very slow with a long line and Ruby highlighting. (John Whitley, 2014 Dec 4)
-- Bug with pattern: '\vblock (\d+)\.\n.*\d+%(\1)@<!\.$'
- (Lech Lorens, 2014 Feb 3)
-- Issue 164: freeze on regexp search.
-- Ignorecase not handled properly for multi-byte characters. (Axel Bender,
- 2013 Dec 11)
-- Using \@> and \?. (Brett Stahlman, 2013 Dec 21) Remark from Marcin Szamotulski
- Remark from Brett 2014 Jan 6 and 7.
-- Difference in NFA and old engine. (Brett Stahlman, 2014 Nov 5)
-- Bug when using \>. (Ramel, 2014 Feb 2) (Aaron Bohannon, 2014 Feb 13)
-- NFA regexp doesn't handle \%<v correctly. (Ingo Karkat, 2014 May 12)
-- Does not work with NFA regexp engine:
- \%u, \%x, \%o, \%d followed by a composing character
-- Bug relating to back references. (Ingo Karkat, 2014 Jul 24)
-- Using back reference before the capturing group sometimes works with the old
- engine, can we do this with the new engine? E.g. with
- "/\%(<\1>\)\@<=.*\%(<\/\(\w\+\)>\)\@=" matching text inside HTML tags.
-- Diff highlighting can be very slow. (Issue 309)
-
-Still using freed memory after using setloclist(). (lcd, 2014 Jul 23)
-More info Jul 24. Not clear why.
-
-Patch to make getregtype() return the right size for non-linux systems.
-(Yasuhiro Matsumoto, 2014 Jul 8)
-Breaks test_eval. Inefficient, can we only compute y_width when needed?
-
-Problem that a previous silent ":throw" causes a following try/catch not to
-work. (ZyX, 2013 Sep 28)
-
-Patch to fix recognizing function name. (Ozaki Kiichi, 2014 Nov 28)
-
-":cd C:\Windows\System32\drivers\etc*" does not work, even though the
-directory exists. (Sergio Gallelli, 2013 Dec 29)
-
-The entries added by matchaddpos() are returned by getmatches() but can't be
-set with setmatches(). (lcd47, 2014 Jun 29)
-
-Gvim: when both Tab and CTRL-I are mapped, use CTRL-I not for Tab.
-
-Problem using ":try" inside ":execute". (ZyX, 2013 Sep 15)
-
-Python: ":py raw_input('prompt')" doesn't work. (Manu Hack)
-
-Change behavior of v:hlsearch? Patch from Christian, 2014 Oct 22.
-
-Patch to recover from X server restart: hint on Issue 203 (2014 Nov 21 18:44)
-
-MS-Windows: When editing a file with a leading space, writing it uses the
-wrong name. (Aram, 2014 Nov 7) Vim 7.4.
-
-Add LessCss support. (Jenoma / Alessandro Vioni, 2014 Nov 24)
-Now with updated license, Nov 24.
-
-patch to remove FEAT_OSFILETYPE from fileio.c. (Christian, 2014 Nov 12)
-
-Value returned by virtcol() changes depending on how lines wrap. This is
-inconsistent with the documentation.
-
-Ukrainian vimtutor. (Issue 288)
-
-Regenerate the Unicode tables in mbyte.c.
-Diff from ZyX, 2014 Dec 6.
-
-Patch to fix relative numbers. (Christian Brabandt, 2014 Nov 17)
-Update Nov 26.
-
-Patch to fix wrong formatting if 'linebreak' is set. (Christian Brabandt, 2014
-Nov 12)
-
-Patch to avoid recognizing polkit as hog files. (Issue 292)
-
-Patch to support hex values for setting option value.
-(Zyx, 2015 Nov 6)
-
-On MS-Windows running tests with Mercurial has problems when the fileformat of
-the input files are changed. (Ken Takata, Taro Muraoka, 2014 Sep 25)
-Update Nov 5.
-
-MS-Windows: Crash opening very long file name starting with "\\".
-(Christian Brock, 2012 Jun 29)
-
-Patch for this from Marcin Szamotulski, 2014 Dec 28:
-8 Make the # register writable, so that it can be restored after jumping
- around in windows.
-
-Using CTRL-L while popup menu is visible behaves like CTRL-P, which is wrong.
-Patch by Yasuhiro Matsumoto, 2015 Jan 5.
-Is this right? Comment from Amadeus Demarzi.
-Another patch from Christian, Jan 6.
-Comment from Hirohito Higashi, Jan 6.
-
-Cursorline background color not mixed with character highlight.
-Patch by Yasuhiro Matsumoto, 2014 Dec 3.
-
-Problem using diff syntax with cp932 encoding. Idea from Yasuhiro Matsumoto,
-patch from Ken Takata (2014 Nov 6)
-
-ml_updatechunk() is slow when retrying for another encoding. (John Little,
-2014 Sep 11)
-
-Patch to add a different escape sequence for replace mode.
-(Omar Sandoval, 2014 Nov 30)
-
-Calling setreg() with an empty list doesn't work.
-Patch by Yasuhiro Matsumoto, 2014 Dec 14.
-
-Extended file attributes lost on write (backupcopy=no). Issue 306.
-
-Window height computed incorrectly when Vim is minimized.
-Patch to fix this. (Ingo Karkat, 2014 Dec 19)
-
-Patch to allow values greater than 255 for ctermfg/ctermbg on Windows.
-(Yasuhiro Matsumoto, 2014 Dec 5)
-
-Mixup of highlighting when there is a match and SpellBad. (ZyX, 2015 Jan 1)
-
-When 'balloonexpr' returns a list the result has a trailing newline.
-Just remove one trailing newline. (lcd, 2014 Oct 17)
-
-Make comments in the test Makefile silent. (Kartik Agaram, 2014 Sep 24)
-
-Result of systemlist() does not show whether text ended in line break.
-(Bjorn Linse, 2014 Nov 27)
-
-When in 'comments' "n:x" follows after three-part comment directly it repeats
-any one-character from the previous line. (Kartik Agaram, 2014 Sep 19)
-
-Syntax highlighting slow (hangs) in SASS file. (Niek Bosch, 2013 Aug 21)
-
-Patch to add the EndOfBuffer highlight group, used instead of NonText for "~"
-lines. (Marco Hinz, 2014 Nov 2)
-
-Adding "~" to 'cdpath' doesn't work for completion? (Davido, 2013 Aug 19)
-
-Plugins need to make a lot of effort, lots of mappings, to know what happened
-before pressing the key that triggers a plugin action. How about keeping the
-last N pressed keys, so that they do not need to be mapped?
-
-":q!" should reset modified flag for current buffer, if another buffer is
-modified no need to abandon it again.
-Patch from Yasuhiro Matsumoto, 2014 Nov 21.
-Update from Hirohito Higashi, 2014 Nov 21.
-With test, Nov 23.
-
-Wrong scrolling when using incsearch. Patch by Christian Brabandt, 2014 Dec 4.
-Is this a good solution?
-
-Can assign to s:type when a function s:type has been defined.
-Also the other way around: define a function while a variable with that name
-was already defined.
-(Yasuhiro Matsumoto, 2014 Nov 3)
-
-Patch to make closed folds line up. (Charles Campbell, 2014 Sep 12)
-
-Patch for building a 32bit Vim with 64bit MingW compiler.
-(Michael Soyka, 2014 Oct 15)
-
-Delete old code in os_msdos.c, mch_FullName().
-
-Redo only remembers the last change. Could use "{count}g." to redo an older
-change. How does the user know which change? At least have a way to list
-them: ":repeats".
-
-Patch for glob(), adding slash to normal files. (Ingo Karkat, 2014 Dec 22)
-
-Using "." to repeat an Ex command puts that command in history. Probably
-should not happen. If the command is the result of a mapping it's not put in
-history either. (Jacob Niehus, 2014 Nov 2)
-Patch from Jacob, Nov 2.
-
-"hi link" does not respect groups with GUI settings only. (Mark Lodato, 2014
-Jun 8)
-
-Bug: Autocompleting ":tag/pat" replaces "/pat" with a match but does not
-insert a space. (Micha Mos, 2014 Nov 7)
-
-Patch to add the :bvimgrep command. (Christian Brabandt, 2014 Nov 12)
-Update Dec 6.
-
-Patch to add argument to :cquit. (Thinca, 2014 Oct 12)
-
-No error for missing endwhile. (ZyX, 2014 Mar 20)
-
-start_global_changes() plus end_global_changes() causes problem for
-clip_unnamed_plus. (Jason Pleau, 2014 Sep 12)
-
-Patch to add :arglocal and :arglists. (Marcin Szamotulski, 2014 Aug 6)
-
-PHP syntax is extremely slow. (Anhad Jai Singh, 2014 Jan 19)
-
-Spell files use a latin single quote. Unicode also has another single quote:
-0x2019. (Ron Aaron, 2014 Apr 4)
-New OpenOffice spell files support this with ICONV. But they are not
-compatible with Vim spell files. The old files can no longer be downloaded.
-
-Patch to make FocusGained and FocusLost work in modern terminals. (Hayaki
-Saito, 2013 Apr 24)
-
-Win32: patch to use 64 bit stat() if possible. (Ken Takata, 2014 May 12)
-More tests May 14. Update May 29. Update Aug 10.
-
-The garbage collector may use too much stack. Make set_ref_in_item()
-iterative instead of recursive. Test program by Marc Weber (2013 Dec 10)
-Patch by Ben Fritz, 2014 Jun 22.
-Related: Vim hangs when freeing a lot of objects. Patch by Yasuhiro
-Matsumoto, 2014 Aug 26.
-
-Idea: For a window in the middle (has window above and below it), use
-right-mouse-drag on the status line to move a window up/down without changing
-its height? It's like dragging the status bar above it at the same time.
-
-Can we make ":unlet $VAR" use unsetenv() to delete the env var?
-What for systems that don't have unsetenv()?
-
-Patch to add a :domodeline command. (Christian Brabandt, 2014 Oct 21)
-
-This does not give an error: (Andre Sihera, 2014 Mar 21)
- vim -u NONE 1 2 3 -c 'bufdo if 1 | echo 1'
-This neither: (ZyX)
- vim -u NONE 1 2 3 -c 'bufdo while 1 | echo 1'
-
-'viewdir' default on MS-Windows is not a good choice, it's a system directory.
-Change 'viewdir' to "$HOME/vimfiles/view" and use 'viewdiralt' to also read
-from?
-
-Problem with upwards search on Windows (works OK on Linux). (Brett Stahlman,
-2014 Jun 8)
-
-Patch to load TCL dynamically. (Ken Takata, 2014 Sep 20)
-
-Include a plugin manager with Vim? Neobundle seems to be the best currently.
-Long message about this from ZyX, 2014 Mar 23. And following replies.
-Also see http://vim-wiki.mawercer.de/wiki/topic/vim%20plugin%20managment.html
-User view:
-- Support multiple sources, basically any http:// URL. Be able to look into
- the files before deciding to install.
-- Be able to try out a plugin and remove it again with (almost) no traces.
-- Each plugin needs a "manifest" file that has the version, dependencies
- (including Vim version and features), conflicts, list of files, etc.
- Updater uses that to decide what/how to update.
- Dependencies can use a URL for specific versions, or short name for scripts
- on vim.org.
-- Once a plugin is installed it remembers where it came from, updater checks
- there. Can manually update when really needed.
-- Must be possible to install for one user. Also system wide?
-- Can edit plugin config with Vim. Can temporarily disable a plugin.
-- Run the update manually, find latest version and install.
-- Be able to download without special tools, must work for 95% of users.
-Implementation:
-- Avoid the 'runtimepath' getting long. Need some other way to keep each
- plugin separate.
-- When installing or updating, first figure out what needs to be done. This
- may involve recursively fetching manifest files for dependencies. Then show
- the user what's going to change and ask for OK.
-- Scripts on Vim.org must be able to consist of several files. Is zip format
- sufficient? Upload the manifest? Or refer to a site that has the manifest?
-- Best is to fetch individual files or use a Vimball. Reduces dependency on
- tools that might be missing and allows inspection of the files before
- installing.
-Out of scope:
-- Overview of plugins, ratings, comments, etc. That's another world.
-- Development work on plugins (although diff with distributed version would be
- useful).
-
-Setting the spell file in a session only reads the local additions, not the
-normal spell file. (Enno Nagel, 2014 Mar 29)
-
-CTRL-] in Visual mode uses the selected text as a tag. This does not work
-when preceded with CTRL-W. (Patrick Hemmer, 2014 Jun 28)
-
-When typing the first character of a command, e.g. "f", then using a menu, the
-menu item doesn't work. Clear typeahead when using a menu?
-
-Editing an ascii file as ucs-2 or ucs-4 causes display errors.
-(ZyX, 2014 Mar 30)
-
-":Next 1 some-arg" does not complain about trailing argument. Also for
-various other commands. (ZyX, 2014 Mar 30)
-
-patch to skip sort if no line matches the expression.
-(Christian Brabandt, 2014 Jun 25)
-
-Patch to add sortuniq(). (Cade Forester, 2014 Mar 19)
-Or add uniq() instead? Patch by lcd47, but it has problems.
-
-Patch to support sorting on floating point number. (Alex Jakushev, 2010 Oct
-30)
-
-Patch to support expression argument to sort() instead of a function name.
-Yasuhiro Matsumoto, 2013 May 31.
-Or should we add a more general mechanism, like a lambda() function?
-Patch by Yasuhiro Matsumoto, 2014 Sep 16.
-
-Patch to fix display of listchars on the cursorline. (Nayuri Aohime, 2013)
-Update suggested by Yasuhiro Matsumoto, 2014 Nov 25:
-https://gist.github.com/presuku/d3d6b230b9b6dcfc0477
-
-Patch for XDG base directory support. (Jean François Bignolles, 2014 Mar 4)
-Remark on the docs. Should not be a compile time feature. But then what?
-
-Completion of ":e" is ":earlier", should be ":edit". Complete to the matching
-command instead of doing this alphabetically. (Mikel Jorgensen)
-
-Patch to add v:completed_item. (Shougo Matsu, 2013 Nov 29).
-
-Patch to get MSVC version in a nicer way. (Ken Takata, 2014 Jul 24)
-
-Patch to define macros for hardcoded values. (Elias Diem, 2013 Dec 14)
-
-Several syntax file match "^\s*" which may get underlined if that's in the
-highlight group. Add a "\zs" after it?
-
-Patch to fix temp directories for Windows, so that it works without tweaking.
-Issue 28.
-
-Go through more coverity reports.
-
-Patch to add ":undorecover", get as much text out of the undo file as
-possible. (Christian Brabandt, 2014 Mar 12, update Aug 22)
-
-Updated spec ftplugin. (Matěj Cepl, 2013 Oct 16)
-
-Patch to right-align signs. (James Kolb (email james), 2013 Sep 23)
-
-Patch to handle integer overflow. (Aaron Burrow, 2013 Dec 12)
-
-With "$" in 'cpoptions' the popup menu isn't fully drawn. (Matti Niemenmaa,
-2013 Sep 5)
-
-Patch to add "ntab" item in 'listchars' to repeat first character. (Nathaniel
-Braun, pragm, 2013 Oct 13) A better solution 2014 Mar 5.
-
-Undo message is not always properly displayed. Patch by Ken Takata, 2013 oct
-3. Doesn't work properly according to Yukihiro Nakadaira.
-
-/[b-a] gives error E16, should probably be E769.
-
-7 Windows XP: When using "ClearType" for text smoothing, a column of yellow
- pixels remains when typing spaces in front of a "D" ('guifont' set to
- "lucida_console:h8").
-Patch by Thomas Tuegel, also for GTK, 2013 Nov 24
-
-:help gives example for z?, but it does not work. m? and t? do work.
-
-Python: Extended funcrefs: use func_T* structure in place of char_u* function
-names.
-(ZyX, 2013 Jul 15, update Sep 22, 24, 28; Update 2013 Dec 15, 2014 Jan 6)
-Also fixes Bug: E685 error for func_unref(). (ZyX, 2010 Aug 5)
-
-Patch to add funcref to Lua. (Luis Carvalho, 2013 Sep 4)
-With tests: Sep 5.
-
-Patch to fix that on suckless Terminal mousewheel up does not work.
-(Ralph Eastwood, 2013 Nov 25)
-
-Discussion about canonicalization of Hebrew. (Ron Aaron, 2011 April 10)
-
-Checking runtime scripts: Thilo Six, 2012 Jun 6.
-
-When evaluating expression in backticks, autoload doesn't work.
-(Andy Wokula, 2013 Dec 14)
-
-Using <nr>ifoobar<esc> can slow down Vim. Patch by Christian Brabandt, 2013
-Dec 13.
-
-Fold can't be opened after ":move". (Ein Brown)
-Patch from Christian Brabandt doesn't fix it completely.
-
-Patch from Christian Brabandt to preserve upper case marks when wiping out a
-buffer. (2013 Dec 9)
-
-Patch for drag&drop reordering of GUI tab pages reordering.
-(Ken Takata, 2013 Nov 22, second one, also by Masamichi Abe)
-
-Patch to add option that tells whether small deletes go into the numbered
-registers. (Aryeh Leib Taurog, 2013 Nov 18)
-
-Javascript file where indent gets stuck on: GalaxyMaster, 2012 May 3.
-
-The BufUnload event is triggered when re-using the empty buffer.
-(Pokey Rule, 2013 Jul 22)
-Patch by Marcin Szamotulski, 2013 Jul 22.
-
-The CompleteDone autocommand needs some info passed to it:
-- The word that was selected (empty if abandoned complete)
-- Type of completion: tag, omnifunc, user func.
-
-Patch to allow more types in remote_expr(). (Lech Lorens, 2014 Jan 5)
-Doesn't work for string in list. Other way to pass all types of variables
-reliably?
-
-Using ":call foo#d.f()" doesn't autoload the "foo.vim" file.
-That is, calling a dictionary function on an autoloaded dict.
-Works OK for echo, just not for ":call" and ":call call()". (Ted, 2011 Mar
-17)
-Patch by Christian Brabandt, 2013 Mar 23.
-Not 100% sure this is the right solution.
-
-Problem caused by patch 7.3.638: window->open does not update window
-correctly. Issue 91.
-
-Patch to add {lhs} to :mapclear: clear all maps starting with {lhs}.
-(Christian Brabandt, 2013 Dec 9)
-
-Exception caused by argument of return is not caught by try/catch.
-(David Barnett, 2013 Nov 19)
-
-8 'backupdir' and 'directory' should use $TMPDIR, $TMP and/or $TEMP when
- defined.
-Issue 28.
-
-Patch to fix that 'cedit' is recognized after :normal. (Christian Brabandt,
-2013 Mar 19, later message)
-
-Patch to view coverage of the tests. (Nazri Ramliy, 2013 Feb 15)
-
-Patch to add "Q" and "A" responses to interactive :substitute. They are
-carried over when using :global. (Christian Brabandt, 2013 Jun 19)
-
-Bug with 'cursorline' in diff mode. Line being scrolled into view gets
-highlighted as the cursor line. (Alessandro Ivaldi, 2013 Jun 4)
-
-Two highlighting bugs. (ZyX, 2013 Aug 18)
-
-Patch to add the bufferlist() function. (Yegappan Lakshmanan, 2013 May 5)
-May 17: with winlist() and tabpagelist().
-May 19: with local variables.
-May 28: with options
-
-Patch to support 'u' in interactive substitute. (Christian Brabandt, 2012 Sep
-28) With tests: Oct 9.
-
-Patch from Christian Brabandt to make the "buffer" argument for ":sign place"
-optional. (2013 Jul 12)
-
-Dialog is too big on Linux too. (David Fishburn, 2013 Sep 2)
-
-Patch to allow setting w:quickfix_title via setqflist() and setloclist()
-functions. (Christian Brabandt, 2013 May 8, update May 21)
-Patch to add getlocstack() / setlocstack(). (Christian Brabandt, 2013 May 14)
-Second one. Update May 22.
-Update by Daniel Hahler, 2014 Jul 4, Aug 14, Oct 14, Oct 15.
-
-Patch to make fold updates much faster. (Christian Brabandt, 2012 Dec)
-
-Issue 54: document behavior of -complete, also expands arg.
-
-- Add regex for 'paragraphs' and 'sections': 'parare' and 'sectre'. Combine
- the two into a regex for searching. (Ned Konz)
-Patch by Christian Brabandt, 2013 Apr 20, unfinished.
-
-Bug: findfile("any", "file:///tmp;") does not work.
-
-'ff' is wrong for one-line file without EOL. (Issue 77)
-
-Patch to set antialiasing style on Windows. (Ondrej Balaz, 2013 Mar 14)
-Needs a different check for CLEARTYPE_QUALITY.
-
-In the ATTENTION message about an existing swap file, mention the name of the
-process that is running. It might actually be some other program, e.g. after
-a reboot.
-
-Patch to have text objects defined by arbitrary single characters. (Daniel
-Thau, 2013 Nov 20, 2014 Jan 29, 2014 Jan 31)
-Ben Fritz: problem with 'selection' set to "exclusive".
-Updated to current Vim, not quite right yet. (Ben Fritz, 2014 Mar 27)
-
-Patch to select the next or previous text object if there isn't one under the
-cursor. (Daniel Thau, 2013 Nov 20)
-
-patch to add "combine" flag to syntax commands. (so8res, 2012 Dec 6)
-
-Bug caused by patch 7.3.1288? Issue 183.
-I can't reproduce it.
-
-Syntax update problem in one buffer opened in two windows, bottom window is
-not correctly updated. (Paul Harris, 2012 Feb 27)
-
-Patch to add assignments in cscope. (Uli Meis, Estabrooks, 2012 Sep 1)
-Alternate patch by Gary Johnson, Sep 4.
-
-Patch to add getsid(). (Tyru, 2011 Oct 2) Do we want this? Update Oct 4.
-Or use expand('<sid>')?
-
-Patch to make confirm() display colors. (Christian Brabandt, 2012 Nov 9)
-
-Patch to add functions for signs. (Christian Brabandt, 2013 Jan 27)
-
-Do we need some way (option) to show the sign column even when there are no
-signs? Patch by Christian Brabandt, 2013 Aug 22.
-
-Patch to remove flicker from popup menu. (Yasuhiro Matsumoto, 2013 Aug 15)
-
-Patch to add 'completeselect' option. Specifies how to select a candidate in
-insert completion. (Shougo, 2013 May 29)
-Update to add to existing 'completeopt'. 2013 May 30
-
-Problem with refresh:always in completion. (Tyler Wade, 2013 Mar 17)
-
-b:undo_ftplugin cannot call a script-local function. (Boris Danilov, 2013 Jan
-7)
-
-Win32: The Python interface only works with one version of Python, selected at
-compile time. Can this be made to work with version 2.1 and 2.2 dynamically?
-
-Python: Be able to define a Python function that can be called directly from
-Vim script. Requires converting the arguments and return value, like with
-vim.bindeval().
-
-Patch for :tabcloseleft, after closing a tab go to left tab. (William Bowers,
-2012 Aug 4)
-
-Patch to improve equivalence classes in regexp patterns.
-(Christian Brabandt, 2013 Jan 16, update Jan 17)
-
-Patch with suggestions for starting.txt. (Tony Mechelynck, 2012 Oct 24)
-But use Gnome instead of GTK?
-
-Should be possible to enable/disable matchparen per window or buffer.
-Add a check for b:no_match_paren in Highlight_matching_Pair() (Marcin
-Szamotulski, 2012 Nov 8)
-
-Issue 72: 'autochdir' causes problems for :vimgrep.
-
-Session file creation: 'autochdir' causes trouble. Keep it off until after
-loading all files.
-
-Win32: When 'autochdir' is on and 'encoding' is changed, files on the command
-line are opened again, but from the wrong directory. Apply 'autochdir' only
-after starting up?
-
-Patch to add ":ldo" and ":cdo", execute commands over quickfix list and
-location list. (Yegappan Lakshmanan, 2013 Jun 2)
-
-8 "stl" and "stlnc" in 'fillchars' don't work for multi-byte characters.
- Patch by Christian Wellenbrock, 2013 Jul 5.
-
-MS-Windows resizing problems:
-- Windows window on screen positioning: Patch by Yukihiro Nakadaira, 2012 Jun
- 20. Uses getWindowRect() instead of GetWindowPlacement()
-- Win32: When the taskbar is at the top of the screen creating the tabbar
- causes the window to move unnecessarily. (William E. Skeith III, 2012 Jan
- 12) Patch: 2012 Jan 13 Needs more work (2012 Feb 2)
-
-Patch to use Modern UI 2.0 for the Nsis installer. (Guopeng Wen, 2010 Jul 30)
-Latest version: 2011 May 18
-8 Windows install with NSIS: make it possible to do a silent install, see
- http://nsis.sourceforge.net/Docs/Chapter4.html#4.12
- Version from Guopeng Wen that does this (2010 Dec 27)
-Alternative: MSI installer: https://github.com/petrkle/vim-msi/
-Or the one on Issue 279
-
-'iminsert' global value set when using ":setlocal iminsert"? (Wu, 2012 Jun 23)
-
-Patch to append regexp to tag commands to make it possible to select one out
-of many matches. (Cody Cutler, 2013 Mar 28)
-
-Patch to add tagfunc(). Cleaned up by Christian Brabandt, 2013 Jun 22.
-
-Help for 'b:undo_indent'. (Thilo Six, 2012 May 28)
-Also question if examples are correct.
-
-The input map for CTRL-O in mswin.vim causes problems after CTRL-X CTRL-O.
-Suggestion for another map. (Philip Mat, 2012 Jun 18)
-But use "gi" instead of "a". Or use CTRL-\ CTRL-O.
-
-Patch to support user name completion on MS-Windows. (Yasuhiro Matsumoto, 2012
-Aug 16)
-
-When there are no command line arguments ":next" and ":argu" give E163, which
-is confusing. Should say "the argument list is empty".
-
-xterm supports escape sequences to mark a paste operation. Need to be
-enabled. (Bruno Sutic, 2014 Jul 11) How to know the terminal supports this?
-
-Patch to have the fold and sign column and at the last line of the buffer.
-(Marco Hinz, 2014 Sep 25)
-Alternate suggestion: let all columns continue, also the number column.
-
-Patch to add tests for if_xcmdsrv.c., Jul 8, need some more work. (Brian Burns)
-New tests Jul 13. Update Jul 17. Discussion Jul 18.
-
-When running Vim in silent ex mode, an existing swapfile causes Vim to wait
-for a user action without a prompt. (Maarten Billemont, 2012 Feb 3)
-Do give the prompt? Quit with an error?
-
-Patch to list user digraphs. (Christian Brabandt, 2012 Apr 14)
-
-Patch to add digraph() function. (Christian Brabandt, 2013 Aug 22, update Aug
-24)
-
-Patch for input method status. (Hirohito Higashi, 2012 Apr 18)
-
-Update Vim app icon (for Gnome). (Jakub Steiner, 2013 Dec 6)
-
-Patch to use .png icons for the toolbar on MS-Windows. (Martin Gieseking, 2013
-Apr 18)
-
-":cd" doesn't work when current directory path contains "**".
-finddir() has the same problem. (Yukihiro Nakadaira, 2012 Jan 10)
-Requires a rewrite of the file_file_in_path code.
-
-Should use has("browsefilter") in ftplugins. Requires patch 7.3.593.
-
-Update for vim2html.pl. (Tyru, 2013 Feb 22)
-
-Patch to sort functions starting with '<' after others. Omit dict functions,
-they can't be called. (Yasuhiro Matsumoto, 2011 Oct 11)
-
-Patch to pass list to or(), and() and xor(). (Yasuhiro Matsumoto, 2012 Feb 8)
-
-Patch to improve "it" and "at" text object matching. (Christian Brabandt, 2011
-Nov 20)
-
-`] moves to character after insert, instead of the last inserted character.
-(Yukihiro Nakadaira, 2011 Dec 9)
-
-Plugin for Modeleasy. (Massimiliano Tripoli, 2011 Nov 29)
-
-BufWinLeave triggers too late when quitting last window in a tab page. (Lech
-Lorens, 2012 Feb 21)
-
-Patch for 'transparency' option. (Sergiu Dotenco, 2011 Sep 17)
-Only for MS-Windows. No documentation. Do we want this?
-
-Patch to support cursor shape in Cygwin console. (Ben bgold, 2011 Dec 27)
-
-Patch to support UTF-8 for Hangul. (Shawn Y.H. Kim, 2011 May 1)
-Needs more work. Pinged 2012 Jan 4.
-
-Issue 64: when 'incsearch' is on can't paste LF on command line.
-
-On MS-Windows a temp dir with a & init causes system() to fail. (Ben Fritz,
-2012 Jun 19)
-
-'cursorline' is displayed too short when there are concealed characters and
-'list' is set. (Dennis Preiser)
-Patch 7.3.116 was the wrong solution.
-Christian Brabandt has another incomplete patch. (2011 Jul 13)
-
-With concealed text mouse click doesn't put the cursor in the right position.
-(Herb Sitz) Fix by Christian Brabandt, 2011 Jun 16. Doesn't work properly,
-need to make the change in where RET_WIN_BUF_CHARTABSIZE() is called.
-
-Syntax region with 'concealends' and a 'cchar' value, 'conceallevel' set to 2,
-only one of the two ends gets the cchar displayed. (Brett Stahlman, 2010 Aug
-21, Ben Fritz, 2010 Sep 14)
-
-The :syntax cchar value can only be a single character. It would be useful to
-support combining characters. (Charles Campbell)
-
-'cursorline' works on a text line only. Add 'cursorscreenline' for
-highlighting the screen line. (Christian Brabandt, 2012 Mar 31)
-
-Win32: Patch to use task dialogs when available. (Sergiu Dotenco, 2011 Sep 17)
-New feature, requires testing. Made some remarks.
-
-Win32: Patch for alpha-blended icons and toolbar height. (Sergiu Dotenco, 2011
-Sep 17) Asked for feedback from others.
-
-Win32: Cannot cd into a directory that starts with a space. (Andy Wokula, 2012
-Jan 19)
-
-Need to escape $HOME on Windows? (ZyX, 2011 Jul 21, discussion 2013 Jul 4)
-Can't simply use a backslash, \$HOME has a different meaning already.
-Would be possible to use $$HOME where $HOME is to be used.
-
-"2" in 'formatoptions' not working in comments. (Christian Corneliussen, 2011
-Oct 26)
-
-Bug in repeating Visual "u". (Lawrence Kesteloot, 2010 Dec 20)
-
-With "unamedplus" in 'clipboard' pasting in Visual mode causes error for empty
-register. (Michael Seiwald, 2011 Jun 28) I can't reproduce it.
-
-Windows keys not set properly on Windows 7? (cncyber, 2010 Aug 26)
-
-When using a Vim server, a # in the path causes an error message.
-(Jeff Lanzarotta, 2011 Feb 17)
-
-Setting $HOME on MS-Windows is not very well documented. Suggestion by Ben
-Fritz (2011 Oct 27).
-
-Bug: Windows 7 64 bit system freezes when 'clipboard' set to "unnamed" and
-doing ":g/test/d". Putting every delete on the clipboard? (Robert Chan, 2011
-Jun 17)
-
-When there is a ">" in a line that "gq" wraps to the start of the next line,
-then the following line will pick it up as a leader. Should get the leader
-from the first line, not a wrapped line. (Matt Ackeret, 2012 Feb 27)
-
-Using ":break" or something else that stops executing commands inside a
-":finally" does not rethrow a previously uncaught exception. (ZyX, 2010 Oct
-15)
-
-Vim using lots of memory when joining lines. (John Little, 2010 Dec 3)
-
-BT regexp engine: After trying a \@> match and failing, submatches are not
-cleared. See test64.
-
-Changes to manpage plugin. (Elias Toivanen, 2011 Jul 25)
-
-Patch to make "z=" work when 'spell' is off. Does this have nasty side
-effects? (Christian Brabandt, 2012 Aug 5, Update 2013 Aug 12)
-Would also need to do this for spellbadword() and spellsuggest().
-
-Patch for variable tabstops. On github (Christian Brabandt, 2014 May 15)
-Update Aug 16 (email).
-
-On 64 bit MS-Windows "long" is only 32 bits, but we sometimes need to store a
-64 bits value. Change all number options to use nropt_T and define it to the
-right type.
-
-string() can't parse back "inf" and "nan". Fix documentation or fix code?
-(ZyX, 2010 Aug 23)
-
-Make 'formatprg' global-local. (Sung Pae)
-
-When doing "redir => s:foo" in a script and then "redir END" somewhere else
-(e.g. in a function) it can't find s:foo.
-When a script contains "redir => s:foo" but doesn't end redirection, a
-following "redir" command gives an error for not being able to access s:foo.
-(ZyX, 2011 Mar 27)
-
-When setqflist() uses a filename that triggers a BufReadCmd autocommand Vim
-doesn't jump to the correct line with :cfirst. (ZyX, 2011 Sep 18)
-
-Behavior of i" and a" text objects isn't logical. (Ben Fritz, 2013 Nov 19)
-
-7 Make "ga" show the digraph for a character, if it exists.
-Patch from Christian Brabandt, 2011 Aug 19.
-
-maparg() does not show the <script> flag. When temporarily changing a
-mapping, how to restore the script ID?
-
-Bug in try/catch: return with invalid compare throws error that isn't caught.
-(ZyX, 2011 Jan 26)
-
-When setting a local option value from the global value, add a script ID that
-indicates this, so that ":verbose set" can give a hint. Check with options in
-the help file.
-
-After patch 7.3.097 still get E15. (Yukihiro Nakadaira, 2011 Jan 18)
-Also for another example (ZyX, 2011 Jan 24)
-
-Build problem with small features on Mac OS X 10.6. (Rainer, 2011 Jan 24)
-
-"0g@$" puts '] on last byte of multi-byte. (ZyX, 2011 Jan 22)
-
-Patch to addd TextDeletePost and TextYankPost events. (Philippe Vaucher, 2011
-May 24) Update May 26.
-
-Patch for :tabrecently. (Hirokazu Yoshida, 2012 Jan 30)
-
-Problem with "syn sync grouphere". (Gustavo Niemeyer, 2011 Jan 27)
-
-Loading autoload script even when usage is inside "if 0". (Christian Brabandt,
-2010 Dec 18)
-
-With a filler line in diff mode, it isn't displayed in the column with line
-number, but it is in the sign column. Doesn't look right. (ZyX 2011 Jun 5)
-Patch by Christian Brabandt, 2011 Jun 5. Introduces new problems.
-
-Add jump() function. (Marcin Szamotulski, 2013 Aug 29)
-Is this needed? CTRL-O and CTRL-I do the same, just more difficult to use.
-
-8 Add a command to jump to the next character highlighted with "Error".
-Patch by Christian Brabandt, uses ]e [e ]t and [t. 2011 Aug 9.
-
-8 Add an event like CursorHold that is triggered repeatedly, not just once
- after typing something.
-Need for CursorHold that retriggers. Use a key that doesn't do anything, or a
-function that resets did_cursorhold.
-Patch by Christian Brabandt, 2011 May 6.
-
-Add event for when the text scrolls. A bit like CursorMoved. Also a similar
-one for insert mode. Use the event in matchparen to update the highlight if
-the match scrolls into view.
-
-7 Use "++--", "+++--" for different levels instead of "+---" "+----".
-Patch by Christian Brabandt, 2011 Jul 27.
-Update by Ben Fritz, with fix for TOhtml. (2011 Jul 30)
-
-9 Add %F to 'errorformat': file name without spaces. Useful on Unix to
- avoid matching something up to a time 11:22:33.
-Patch by Christian Brabandt, 2011 Jul 27.
-
-Patch to add up to 99 match groups. (Christian Brabandt, 2010 Dec 22)
-Also add named groups: \%{name}(re) and \%{name}g
-
-In the sandbox it's not allowed to do many things, but it's possible to change
-or set variables. Add a way to prevent variables from being changed in the
-sandbox? E.g.: ":protect g:restore_settings".
-
-Win32: tear-off menu does not work when menu language is German. (Markus
-Bossler, 2011 Mar 2) Fixed by 7.3.095?
-
-Version of netbeans.c for use with MacVim. (Kazuki Sakamoto, 2010 Nov 18)
-
-7.3.014 changed how backslash at end of line works, but still get a NUL when
-there is one backslash. (Ray Frush, 2010 Nov 18) What does the original ex
-do?
-
-Searching mixed with Visual mode doesn't redraw properly. (James Vega, 2010 Nov
-22)
-
-New esperanto spell file can't be processed. (Dominique Pelle, 2011 Jan 30)
-- move compflags to separate growarray?
-- instead of a regexp use a hashtable. Expand '?', '*', '+'. What would be
- the maximum repeat for * and +?
-
-"L'Italie" noted as a spell error at start of the sentence. (Dominique Pelle,
-2011 Feb 27)
-
-Editing a file with a ^M with 'ff' set to "mac", opening a help file, then the
-^M is displayed as ^J sometimes. Getting 'ff' value from wrong window/buffer?
-
-'colorcolumn' has higher priority than hlsearch. Should probably be the other
-way around. (Nazri Ramliy, 2013 Feb 19)
-
-When Vim is put in the background (SIGTSTP) and then gets a SIGHUP it doesn't
-exit. It exists as soon as back in the foreground. (Stephen Liang, 2011 Jan
-9) Caused by vim_handle_signal(SIGNAL_BLOCK); in ui.c.
-
-g` not working correctly when using :edit. It works OK when editing a file on
-the command line. (Ingo Karkat, 2011 Jan 25)
-
-Since patch 7.2.46 Yankring plugin has become very slow, eventually make Vim
-crash? (Raiwil, 2010 Nov 17)
-
-Patch to add FoldedLineNr highlighting: different highlighting for the line
-number of a closed fold. (eXerigumo Clanjor, 2013 Jul 15)
-
-Regexp engine performance:
-- Profiling:
- ./vim -u NONE -s ~/vim/test/ruby.vim
- ./vim -u NONE -s ~/vim/test/loop.vim
- ./vim -u NONE -s ~/vim/test/alsa.vim
- ./vim -s ~/vim/test/todo.vim
- ./vim -s ~/vim/test/xml.vim
- Dominique Pelle: xmlSyncDT is particularly slow (Jun 7)
-- More test files from the src/pkg/regexp/testdata directory in the Go repo.
-- Performance tests:
- - Using asciidoc syntax. (Marek Schimara, 2013 Jun 6)
- - ~/vim/text/FeiqCfg.xml (file from Netjune)
- - ~/vim/text/edl.svg (also XML)
- - glts has five tests. (May 25)
- - ~/vim/test/slowsearch
- - ~/vim/test/rgb.vim
- - search for a.*e*exn in the vim executable. Go to last line to use
- 'hlsearch'.
- - Slow combination of folding and PHP syntax highlighting. Script to
- reproduce it. Caused by "syntax sync fromstart" in combination with patch
- 7.2.274. (Christian Brabandt, 2010 May 27) Generally, folding with
- 'foldmethod' set to "syntax" is slow. Do profiling to find out why.
-
-Patch to add 'systemencoding', convert between 'encoding' and this for file
-names, shell commands and the like. (Kikuchan, 2010 Oct 14)
-Assume the system converts between the actual encoding of the filesystem to
-the system encoding (usually utf-8).
-
-Patch to add GUI colors to the terminal, when it supports it. (ZyX, 2013 Jan
-26, update 2013 Dec 14, another 2014 Nov 22)
-
-Problem producing tags file when hebrew.frx is present. It has a BOM.
-Results in E670. (Tony Mechelynck, 2010 May 2)
-
-'beval' option should be global-local.
-
-setpos() does not restore cursor position after :normal. (Tyru, 2010 Aug 11)
-
-7 The 'directory' option supports changing path separators to "%" to make
- file names unique, also support this for 'backupdir'. (Mikolaj Machowski)
- Patch by Christian Brabandt, 2010 Oct 21.
-
-With "tw=55 fo+=a" typing space before ) doesn't work well. (Scott Mcdermott,
-2010 Oct 24)
-
-Patch to add random number generator. (Hong Xu, 2010 Nov 8, update Nov 10)
-Alternative from Christian Brabandt. (2010 Sep 19)
-
-Messages in message.txt are highlighted as examples.
-
-When using cp850 the NBSP (0xff) is not drawn correctly. (Brett Stahlman, 2010
-Oct 22) 'isprint' is set to "@,161-255".
-
-":echo "\x85" =~# '[\u0085]'" returns 1 instead of 0. (ZyX, 2010 Oct 3)
-
-'cindent' not correct when 'list' is set. (Zdravi Korusef, 2010 Apr 15)
-
-C-indenting: A matching { in a comment is ignored, but intermediate { are not
-checked to be in a comment. Implement FM_SKIPCOMM flag of findmatchlimit().
-Issue 46.
-
-Mac with X11: clipboard doesn't work properly. (Raf, 2010 Aug 16)
-
-Using CompilerSet doesn't record where an option was set from. E.g., in the
-gcc compiler plugin. (Gary Johnson, 2010 Dec 13)
-
-":helpgrep" does not put the cursor in the correct column when preceded by
-accented character. (Tony Mechelynck, 2010 Apr 15)
-
-Don't call check_restricted() for histadd(), setbufvar(), settabvar(),
-setwinvar().
-
-Patch for GVimExt to show an icon. (Dominik Riebeling, 2010 Nov 7)
-
-When writing a file > 2Gbyte, the reported number of bytes is negative.
-(Antonio Colombo, 2010 Dec 18)
-
-Patch: Let rare word highlighting overrule good word highlighting.
-(Jakson A. Aquino, 2010 Jul 30, again 2011 Jul 2)
-
-When 'lines' is 25 and 'scrolloff' is 12, "j" scrolls zero or two lines
-instead of one. (Constantin Pan, 2010 Sep 10)
-
-Gui menu edit/paste in block mode insert only inserts in one line (Bjorn
-Winckler, 2011 May 11)
-Requires a map mode for Insert mode started from blockwise Visual mode.
-
-Writing nested List and Dict in viminfo gives error message and can't be read
-back. (Yukihiro Nakadaira, 2010 Nov 13)
-
-Problem with cursor in the wrong column. (SungHyun Nam, 2010 Mar 11)
-Additional info by Dominique Pelle. (also on 2010 Apr 10)
-
-CreateFile and CreateFileW are used without sharing, filewritable() fails when
-the file was already open (e.g. script is being sourced). Add FILE_SHARE_READ|
-FILE_SHARE_WRITE in mch_access()? (Phillippe Vaucher, 2010 Nov 2)
-
-Is ~/bin (literally) in $PATH supposed to work? (Paul, 2010 March 29)
-Looks like only bash can do it. (Yakov Lerner)
-
-Cscope "cs add" stopped working somewhat before 7.2.438. (Gary Johnson, 2010
-Jun 29) Caused by 7.2.433?
-
-I often see pasted text (from Firefox, to Vim in xterm) appear twice.
-Also, Vim in xterm sometimes loses copy/paste ability (probably after running
-an external command).
-
-Jumplist doesn't work properly in Insert mode? (Jean Johner, 2010 Mar 20)
-
-Problem with transparent cmdline. Also: Terminal title is wrong with
-non-ASCII character. (Lily White, 2010 Mar 7)
-
-iconv() doesn't fail on an illegal character, as documented. (Yongwei Wu, 2009
-Nov 15, example Nov 26) Add argument to specify whether iconv() should fail
-or replace with a character and continue?
-
-Add local time at start of --startuptime output.
-Requires configure check for localtime().
-Use format year-month-day hr:min:sec.
-
-Patch to add "combine" to :syntax, combines highlight attributes. (Nate
-Soares, 2012 Dec 3)
-
-Patch to make ":hi link" also take arguments. (Nate Soares, 2012 Dec 4)
-
-Shell not recognized properly if it ends in "csh -f". (James Vega, 2009 Nov 3)
-Find tail? Might have a / in argument. Find space? Might have space in
-path.
-
-Test 51 fails when language set to German. (Marco, 2011 Jan 9)
-Dominique can't reproduce it.
-
-'ambiwidth' should be global-local.
-
-":function f(x) keepjumps" creates a function where every command is executed
-like it has ":keepjumps" before it.
-
-Coverity: ask someone to create new user: Dominique.
-Check if there are new reported defects: http://scan.coverity.com/rung2.html
-
-Patch to support :undo absolute jump to file save number. (Christian Brabandt,
-2010 Nov 5)
-
-Patch to use 'foldnextmax' also for "marker" foldmethod. (Arnaud Lacombe, 2011
-Jan 7)
-
-Bug with 'incsearch' going to wrong line. (Wolfram Kresse, 2009 Aug 17)
-Only with "vim -u NONE".
-
-Problem with editing file in binary mode. (Ingo Krabbe, 2009 Oct 8)
-
-With 'wildmode' set to "longest:full,full" and pressing Tab once the first
-entry in wildmenu is highlighted, that shouldn't happen. (Yuki Watanabe, 2011
-Feb 12)
-
-Display error when 'tabline' that includes a file name with double-width
-characters. (2010 Aug 14, bootleq)
-
-Problem with stop directory in findfile(). (Adam Simpkins, 2009 Aug 26)
-
-Using ']' as the end of a range in a pattern requires double escaping:
- /[@-\\]] (Andy Wokula, 2011 Jun 28)
-
-Syntax priority problem. (Charles Campbell, 2011 Sep 15)
-
-When completion inserts the first match, it may trigger the line to be folded.
-Disable updating folds while completion is active? (Peter Odding, 2010 Jun 9)
-
-When a:base in 'completefunc' starts with a number it's passed as a number,
-not a string. (Sean Ma) Need to add flag to call_func_retlist() to force a
-string value.
-
-Invalid read error in Farsi mode. (Dominique Pelle, 2009 Aug 2)
-
-For running gvim on an USB stick: avoid the OLE registration. Use a command
-line argument -noregister.
-
-When using an expression in 'statusline' leading white space sometimes goes
-missing (but not always). (ZyX, 2010 Nov 1)
-
-When a mapping exists both for insert mode and lang-insert mode, the last one
-doesn't work. (Tyru, 2010 May 6) Or is this intended?
-
-Still a problem with ":make" in the wrong directory. Caused by ":bufdo".
-(Ajit Thakkar, 2009 Jul 1) More information Jul 9, Jul 15.
-Caused by "doautoall syntaxset BufEnter *" in syntax/nosyntax.vim ?
-There also is a BufLeave/BufEnter aucmd to save/restore view.
-Does the patch to save/restore globaldir work?
-
-":bufdo normal gg" while 'hidden' is set leaves buffers without syntax
-highlighting. Don't disable Syntax autocommands then? Or add a flag/modifier
-to avoid changing 'eventignore'?
-
-Patch for displaying 0x200c and 0x200d. (Ali Gholami Rudi, 2009 May 6)
-Probably needs a bit of work.
-
-Patch to add farsi handling to arabic.c (Ali Gholami Rudi, 2009 May 2)
-Added test, updates, June 23.
-Updated for 7.4: http://litcave.rudi.ir/farsi_vim.diff
-With modification for Tatweel character: https://dpaste.de/VmFw
-Remark from Ameretat Reith (2014 Oct 13)
-
-List of encoding aliases. (Takao Fujiwara, 2009 Jul 18)
-Are they all OK? Update Jul 22.
-
-Win32: Improved Makefile for MSVC. (Leonardo Valeri Manera, 2010 Aug 18)
-
-Win32: Expanding 'path' runs into a maximum size limit. (bgold12, 2009 Nov 15)
-
-Win32: Patch for enabling quick edit mode in console. (Craig Barkhouse, 2010
-Sep 1)
-
-Win32: Patch for using .png files for icons. (Charles Peacech, 2012 Feb 5)
-
-Putting a Visual block while 'visualedit' is "all" does not leave the cursor
-on the first character. (John Beckett, 2010 Aug 7)
-
-Setting 'tags' to "tagsdir/*" does not find "tagsdir/tags". (Steven K. Wong,
-2009 Jul 18)
-
-Patch to add "focusonly" to 'scrollopt', so that scrollbind also applies in
-window that doesn't have focus. (Jonathon Mah, 2009 Jan 12)
-Needs more work.
-
-Problem with <script> mappings (Andy Wokula, 2009 Mar 8)
-
-When starting Vim with "gvim -f -u non_existent_file > foo.txt" there are a
-few control characters in the output. (Dale Wiles, 2009 May 28)
-
-'cmdwinheight' is only used in last window when 'winheight' is a large value.
-(Tony Mechelynck, 2009 Apr 15)
-
-Status line containing winnr() isn't updated when splitting the window (Clark
-J. Wang, 2009 Mar 31)
-
-When $VIMRUNTIME is set in .vimrc, need to reload lang files. Already done
-for GTK, how about others? (Ron Aaron, 2010 Apr 10)
-
-Patch for GTK buttons X1Mouse and X2Mouse. (Christian J. Robinson, 2010 Aug 9)
-
-When 'ft' changes redraw custom status line.
-
-":tab split fname" doesn't set the alternate file in the original window,
-because win_valid() always returns FALSE. Below win_new_tabpage() in
-ex_docmd.c.
-
-Space before comma in function definition not allowed: "function x(a , b)"
-Give a more appropriate error message. Add a remark to the docs.
-
-string_convert() should be able to convert between utf-8 and utf-16le. Used
-for GTK clipboard. Avoid requirement for iconv.
-
-Now that colnr_T is int instead of unsigned, more type casts can be removed.
-
-'delcombine' does not work for the command line. (Tony Mechelynck, 2009 Jul
-20)
-
-Don't load macmap.vim on startup, turn it into a plugin. (Ron Aaron,
-2009 Apr 7) Reminder Apr 14.
-
-Add "no_hlsearch" to winsaveview().
-
-Cursorline highlighting combines with Search ('hlsearch') but not with
-SpellBad. (Jim Karsten, 2009 Mar 18)
-
-When 'foldmethod' is "indent", adding an empty line below a fold and then
-indented text, creates a new fold instead of joining it with the previous one.
-(Evan Laforge, 2009 Oct 17)
-
-Bug: When reloading a buffer changed outside of Vim, BufRead autocommands
-are applied to the wrong buffer/window. (Ben Fritz, 2009 Apr 2, May 11)
-Ignore window options when not in the right window?
-Perhaps we need to use a hidden window for applying autocommands to a buffer
-that doesn't have a window.
-
-When using "ab foo bar" and mapping <Tab> to <Esc>, pressing <Tab> after foo
-doesn't trigger the abbreviation like <Esc> would. (Ramana Kumar, 2009 Sep 6)
-
-getbufvar() to get a window-local option value for a buffer that's not
-displayed in a window should return the value that's stored for that buffer.
-
-":he ctrl_u" can be auto-corrected to ":he ctrl-u".
-
-There should be a way after an abbreviation has expanded to go back to what
-was typed. CTRL-G h ? Would also undo last word or line break inserted
-perhaps. And undo CTRL-W. CTRL-G l would redo.
-
-Diff mode out of sync. (Gary Johnson, 2010 Aug 4)
-
-Support a 'systemencoding' option (for Unix). It specifies the encoding of
-file names. (Kikuchan, 2010 Oct 5). Useful on a latin1 or double-byte Asian
-system when 'encoding' is "utf-8".
-
-Win32: completion of file name ":e c:\!test" results in ":e c:\\!test", which
-does not work. (Nieko Maatjes, 2009 Jan 8, Ingo Karkat, 2009 Jan 22)
-
-opening/closing window causes other window with 'winfixheight' to change
-height. Also happens when there is another window in the frame, if it's not
-very high. (Yegappan Lakshmanan, 2010 Jul 22, Michael Peeters, 2010 Jul 22)
-
-Directory wrong in session file, caused by ":lcd" in BufEnter autocommand.
-(Felix Kater, 2009 Mar 3)
-
-Session file generates error upon loading, cause by --remote-silent-tab.
-(7tommm (ytommm) 2010 Nov 24)
-
-Using ~ works OK on 'a' with composing char, but not on 0x0418 with composing
-char 0x0301. (Tony Mechelynck, 2009 Mar 4)
-
-Searching for composing char works, but not when inside []. (ZyX, Benjamin R.
-Haskell, 2010 Aug 24)
-
-This does not work yet: "a\(%C\)" (get composing characters into a submatch).
-
-A function on a dictionary is not profiled. (ZyX, 2010 Dec 25)
-
-Inconsistent: starting with $LANG set to es_ES.utf-8 gives Spanish
-messages, even though locale is not supported. But ":lang messages
-es_ES.utf-8" gives an error and doesn't switch messages. (Dominique Pelle,
-2009 Jan 26)
-
-When $HOME contains special characters, such as a comma, escape them when used
-in an option. (Michael Hordijk, 2009 May 5)
-Turn "esc" argument of expand_env_esc() into string of chars to be escaped.
-
-Should make 'ignorecase' global-local, so that it makes sense setting it from
-a modeline.
-
-Add cscope target to Makefile. (Tony Mechelynck, 2009 Jun 18, replies by
-Sergey Khorev)
-
-Consider making YankRing or something else that keeps a list of yanked text
-part of standard Vim. The "1 to "9 registers are not sufficient.
-
-netrw: dragging status line causes selection of entry. Should check row
-number to be below last visible line.
-
-After doing "su" $HOME can be the old user's home, thus ~root/file is not
-correct. Don't use it in the swap file.
-
-Completion for ":buf" doesn't work properly on Win32 when 'shellslash' is off.
-(Henrik Ohman, 2009, Jan 29)
-
-shellescape() depends on 'shellslash' for quoting. That doesn't work when
-'shellslash' is set but using cmd.exe. (Ben Fritz)
-Use a different option or let it depend on whether 'shell' looks like a
-unix-like shell?
-
-Bug: in Ex mode (after "Q") backslash before line break, when yanked into a
-register and executed, results in <Nul>: instead of line break.
-(Konrad Schwarz, 2010 Apr 16)
-
-Have a look at patch for utf-8 line breaking. (Yongwei Wu, 2008 Mar 1, Mar 23)
-Now at: http://vimgadgets.sourceforge.net/liblinebreak/
-
-Greek sigma character should be lower cased depending on the context. Can we
-make this work? (Dominique Pelle, 2009 Sep 24)
-
-When changing 'encoding' convert all the swap file names, so that we can
-still delete them. Also convert all buffer file names?
-
-"gqip" in Insert mode has an off-by-one error, causing it to reflow text.
-(Raul Coronado, 2009 Nov 2)
-
-Update src/testdir/main.aap.
-
-Something wrong with session that has "cd" commands and "badd", in such a way
-that Vim doesn't find the edited file in the buffer list, causing the
-ATTENTION message? (Tony Mechelynck, 2008 Dec 1)
-Also: swap files are in ~/tmp/ One has relative file name ".mozilla/...".
-
-Add v:motion_force. (Kana Natsuno, 2008 Dec 6)
-Maybe call it v:motiontype.
-
-MS-Windows: editing the first, empty buffer, 'ffs' set to "unix,dos", ":enew"
-doesn't set 'ff' to "unix". (Ben Fritz, 2008 Dec 5) Reusing the old buffer
-probably causes this.
-
-'scrollbind' is not respected when deleting lines or undo. (Milan Vancura,
-2009 Jan 16)
-
-Patch to support strikethrough next to bold and italic. (Christian Brabandt,
-2013 Jul 30) Update from Ken Takata, 2013 Oct 12.
-
-Having "Syntax" in 'eventignore' for :bufdo may cause problems, e.g. for
-":bufdo e" when buffers are open in windows. ex_listdo(eap) could set the
-option only for when jumping to another buffer, not when the command argument
-is executed.
-
-":pedit %" with a BufReadPre autocommand causes the cursor to move to the
-first line. (Ingo Karkat, 2008 Jul 1) Ian Kelling is working on this.
-Similar problem with ":e". (Marc Montu, 2014 Apr 22)
-
-Wildmenu not deleted: "gvim -u NONE", ":set nocp wildmenu cmdheight=3
-laststatus=2", CTRL-D CTRL-H CTRL-H CTRL-H. (A.Politz, 2008 April 1)
-Works OK with Vim in an xterm.
-
-Cursor line moves in other window when using CTRL-W J that doesn't change
-anything. (Dasn, 2009 Apr 7)
-
-On Unix "glob('does not exist~')" returns the string. Without the "~" it
-doesn't. (John Little, 2008 Nov 9)
-Shell expansion returns unexpanded string?
-Don't use shell when "~" is not at the start?
-
-":unlet $VAR" doesn't work.
-
-When using ":e ++enc=foo file" and the file is already loaded with
-'fileencoding' set to "bar", then do_ecmd() uses that buffer, even though the
-fileencoding differs. Reload the buffer in this situation? Need to check for
-the buffer to be unmodified.
-Unfinished patch by Ian Kelling, 2008 Jul 11. Followup Jul 14, need to have
-another look at it.
-
-c.vim: XXX in a comment is colored yellow, but not when it's after "#if 0".
-(Ilya Dogolazky, 2009 Aug 7)
-
-You can type ":w ++bad=x fname", but the ++bad argument is ignored. Give an
-error message? Or is this easy to implement? (Nathan Stratton Treadway, 2008
-Aug 20) This is in ucs2bytes(), search for 0xBF. Using the ++bad argument is
-at the other match for 0xBF.
-
-When adding "-complete=file" to a user command this also changes how the
-argument is processed for <f-args>. (Ivan Tishchenko, 2008 Aug 19)
-
-Win32: associating a type with Vim doesn't take care of space after a
-backslash? (Robert Vibrant, 2008 Jun 5)
-
-When 'rightleft' is set, cursorcolumn isn't highlighted after the end of a
-line. It's also wrong in folds. (Dominique Pelle, 2010 Aug 21)
-
-Using an insert mode expression mapping, cursor is not in the expected
-position. (ZyX, 2010 Aug 29)
-
-After using <Tab> for command line completion after ":ta blah" and getting E33
-(no tags file), further editing the command to e.g., ":echo 'blah'", the
-command is not executed. Fix by Ian Kelling?
-
-":help s/~" jumps to *s/\~*, while ":help s/\~" doesn't find anything. (Tim
-Chase) Fix by Ian Kelling, 2008 Jul 14.
-
-Use "\U12345678" for 32 bit Unicode characters? (Tony Mechelynck, 2009
-Apr 6) Or use "\u(123456)", similar to Perl.
-
-When mapping : to ; and ; to :, @; doesn't work like @: and @: doesn't work
-either. Matt Wozniski: nv_at() calls do_execreg() which uses
-put_in_typebuf(). Char mapped twice?
-
-Despite adding save_subexpr() this still doesn't work properly:
-Regexp: matchlist('12a4aaa', '^\(.\{-}\)\(\%5c\@<=a\+\)\(.\+\)\?')
-Returns ['12a4', 'aaa', '4aaa'], should be ['12a4', 'aaa', '']
-Backreference not cleared when retrying after \@<= fails?
-(Brett Stahlman, 2008 March 8)
-
-Problem with remote_send(). (Charles Campbell, 2008 Aug 12)
-
-ftplugin for help file should set 'isk' to help file value.
-
-Win32: remote editing fails when the current directory name contains "[".
-(Ivan Tishchenko, Liu Yubao) Suggested patch by Chris Lubinski: Avoid
-escaping characters where the backslash is not removed later. Asked Chris for
-an alternate solution, also for src/ex_getln.c.
-This also fails when the file or directory name contains "%". (Thoml, 2008
-July 7)
-Using --remote-silent while the current directory has a # in the name does not
-work, the # needs to be escaped. (Tramblay Bruno, 2012 Sep 15)
-
-When using remote-silent the -R flag is not passed on. (Axel Bender, 2012 May
-31)
-
-Win32: A --remote command that has a directory name starting with a ( doesn't
-work, the backslash is removed, assuming that it escapes the (. (Valery
-Kondakoff, 2009 May 13)
-
-Problem with 'langmap' being used on the rhs of a mapping. (Nikolai Weibull,
-2008 May 14)
-
-Problem with CTRL-F. (Charles Campbell, 2008 March 21)
-Only happens with "gvim -geometry "160x26+4+27" -u NONE -U NONE prop.c".
-'lines' is 54. (2008 March 27)
-
-Problem with pointer wrapping around in getvcol(). (Wolfgang Kroworsch, 2008
-Oct 19) Check for "col" being "MAXCOL" separately?
-
-Unexpectedly inserting a double quote. (Anton Woellert, 2008 Mar 23)
-Works OK when 'cmdheight' is 2.
-
-8 Use a mechanism similar to omni completion to figure out the kind of tab
- for CTRL-] and jump to the appropriate matching tag (if there are
- several).
- Alternative: be able to define a function that takes the tag name and uses
- taglist() to find the right location. With indication of using CTRL-] so
- that the context can be taken into account. (Robert Webb)
-Patch by Christian Brabandt, 2013 May 31.
-
-Test54 should not use shell commands. Make it portable.
-
-The utf class table is missing some entries:
- 0x2212, minus sign
- 0x2217, star
- 0x2500, bar
- 0x26ab, circle
-
-Visual line mode doesn't highlight properly when 'showbreak' is used and the
-line doesn't fit. (Dasn, 2008 May 1)
-
-Mac: Move Carbon todo items to os_mac.txt. Note that this version is frozen,
-try the Cocoa version.
-
-Mac: After a ":vsplit" the left scrollbar doesn't appear until 'columns' is
-changed or the window is resized.
-
-Mac: Patch for configure: remove arch from ruby link args. (Knezevic, 2008
-Mar 5) Alternative: Kazuki Sakamoto, Mar 7.
-
-C't: On utf-8 system, editing file with umlaut through Gnome results in URL
-with %nn%nn, which is taken as two characters instead of one.
-Try to reproduce at work.
-
-Patch for default choice in file changed dialog. (Bjorn Winckler, 2008 Oct 19)
-Is there a way to list all the files first?
-
-When 'smartcase' is set and using CTRL-L to add to the search pattern it may
-result in no matches. Convert chars to lower case? (Erik Wognsen, 2009 Apr
-16)
-
-Fail to edit file after failed register access. Error flag remains set?
-(Lech Lorens, 2010 Aug 30)
-
-Patch for redo register. (Ben Schmidt, 2007 Oct 19)
-Await response to question to make the register writable.
-
-src/testdir/Make_dos.mak: not all tests are included, e.g., test49, without a
-remark why.
-
-Problem with 'ts' set to 9 and 'showbreak' to ">>>". (Matthew Winn, 2007 Oct
-1)
-
-In the swapfile dialog, add a H(elp) option that gives more info about what
-each choice does. Similar to ":help swap-exists-choices"
-
-try/catch not working for argument of return. (Matt Wozniski, 2008 Sep 15)
-
-try/catch not working when inside a for loop. (ZyX, 2011 Jan 25)
-
-":tab help" always opens a new tab, while ":help" re-uses an existing window.
-Would be more consistent when an existing tab is re-used. (Tony Mechelynck)
-
-Add ":nofold". Range will apply without expanding to closed fold.
-
-Using Aap to build Vim: add remarks about how to set personal preferences.
-Example on http://www.calmar.ws/tmp/aap.html
-
-Syntax highlighting wrong for transparent region. (Doug Kearns, 2007 Feb 26)
-Bug in using a transparent syntax region. (Hanlen in vim-dev maillist, 2007
-Jul 31)
-
-C syntax: {} inside () causes following {} to be highlighted as error.
-(Michalis Giannakidis, 2006 Jun 1)
-
-When 'diffopt' has "context:0" a single deleted line causes two folds to merge
-and mess up syncing. (Austin Jennings, 2008 Jan 31)
-
-Gnome improvements: Edward Catmur, 2007 Jan 7
- Also use Save/Discard for other GUIs
-
-New PHP syntax file, use it? (Peter Hodge)
-
-":echoe" in catch block stops processing, while this doesn't happen outside of
-a catch block. (ZyX, 2011 Jun 2)
-
-'foldcolumn' in modeline applied to wrong window when using a session. (Teemu
-Likonen, March 19)
-
-Test 54 uses shell commands, that doesn't work on non-Unix systems. Use some
-other way to test buffer-local autocommands.
-
-The documentation mentions the priority for ":2match" and ":3match", but it
-appears the last one wins. (John Beckett, 2008 Jul 22) Caused by adding
-matchadd()? Suggested patch by John, 2008 Jul 24.
-
-When 'encoding' is utf-8 the command line is redrawn as a whole on every
-character typed. (Tyler Spivey, 2008 Sep 3) Only redraw cmdline for
-'arabicshape' when there is a character on the command line for which
-(ARABIC_CHAR(u8c)) is TRUE.
-
-Cheng Fang made javacomplete. (2007 Aug 11)
-Asked about latest version: 0.77.1 is on www.vim.org.
-
-Insert mode completion: When editing the text and pressing CTRL-N again goes
-back to originally completed text, edited text is gone. (Peng Yu, 2008 Jul 24)
-Suggestion by Ben Schmidt, 2008 Aug 6.
-
-Problem with compound words? (Bert, 2008 May 6)
-No warning for when flags are defined after they are used in an affix.
-
-Screen redrawing when continuously updating the buffer and resizing the
-terminal. (Yakov Lerner, 2006 Sept 7)
-
-Add option settings to help ftplugin. (David Eggum, 2006 Dec 18)
-
-Autoconf problem: when checking for iconv library we may add -L/usr/local/lib,
-but when compiling further tests -liconv is added without the -L argument,
-that may fail (e.g., sizeof(int)). (Blaine, 2007 Aug 21)
-
-When opening quickfix window, disable spell checking?
-
-Problem with ".add" files when using two languages and restarting Vim. (Raul
-Coronado, 2008 Oct 30)
-
-Popup menu redraw: Instead of first redrawing the text and then drawing the
-popup menu over it, first draw the new popup menu, remember its position and
-size and then redraw the text, skipping the characters under the popup menu.
-This should avoid flicker. Other solution by A.Politz, 2007 Aug 22.
-
-Windows 98: pasting from the clipboard with text from another application has
-a trailing NUL. (Joachim Hofmann) Perhaps the length specified for CF_TEXT
-isn't right?
-
-When a register contains illegal bytes, writing viminfo in utf-8 and reading
-it back doesn't result in utf-8. (Devin Bayer)
-
-Command line completion: Scanning for tags doesn't check for typed key now and
-then? Hangs for about 5 seconds. Appears to be caused by finding include
-files with "foo/**" in 'path'. (Kalisiak, 2006 July 15)
-Additional info: When using the |wildcards| ** globing, vim hangs
-indefinitely on lots of directories. The |file-searching| globing, like in
-":set path=/**" does not hang as often as with globing with |wildcards|, like
-in ":1find /**/file". This is for files that unix "find" can find very
-quickly. Merging the 2 kinds of globing might make this an easier fix. (Ian
-Kelling, 2008 July 4)
-
-When the file name has parenthesis, e.g., "foo (bar).txt", ":!ls '%'" has the
-parenthesis escaped but not the space. That's inconsistent. Either escape
-neither or both. No escaping might be best, because it doesn't depend on
-particularities of the shell. (Zvi Har'El, 2007 Nov 10) (Teemu Likonen, 2008
-Jun 3)
-However, for backwards compatibility escaping might be necessary. Check if
-the user put quotes around the expanded item?
-
-A throw in a function causes missing an endif below the call. (Spiros
-Bousbouras, 2011 May 16)
-
-Error E324 can be given when a cron script has wiped out our temp directory.
-Give a clear error message about this (and tell them not to wipe out /tmp).
-
-Color for cUserLabel should differ from case label, so that a mistake in a
-switch list is noticed:
- switch (i)
- {
- case 1:
- foobar:
- }
-
-Look at http://www.gtk-server.org/ . It has a Vim script implementation.
-
-Netbeans problem. Use "nc -l 127.0.0.1 55555" for the server, then run gvim
-with "gvim -nb:localhost:55555:foo". From nc do: '1:editFile!0 "foo"'. Then
-go to Insert mode and add a few lines. Then backspacing every other time
-moves the cursor instead of deleting. (Chris Kaiser, 2007 Sep 25)
-
-Windows installer should install 32-bit version of right-click handler also on
-64-bit systems. (Brian Cunningham, 2011 Dec 28)
-
-Windows installer could add a "open in new tab of existing Vim" menu entry.
-Gvimext: patch to add "Edit with single Vim &tabbed" menu entry.
-Just have two choices, always using one Vim and selecting between using an
-argument list or opening each file in a separate tab.
-(Erik Falor, 2008 May 21, 2008 Jun 26)
-
-Windows installer: licence text should not use indent, causes bad word wrap.
-(Benjamin Fritz, 2010 Aug 16)
-
-Dos uninstal may delete vim.bat from the wrong directory (e.g., when someone
-makes his own wrapper). Add a magic string with the version number to the
-.bat file and check for it in the uninstaller. E.g.
- # uninstall key: vim7.3*
-
-Changes for Win32 makefile. (Mike Williams, 2007 Jan 22, Alexei Alexandrov,
-2007 Feb 8)
-
-Win32: Can't complete shell command names. Why is setting xp_context in
-set_one_cmd_context() inside #ifndef BACKSLASH_IN_FILENAME?
-
-Win32: Patch for cscope external command. (Mike Williams, 2007 Aug 7)
-
-Win32: XPM support only works with path without spaces. Patch by Mathias
-Michaelis, 2006 Jun 9. Another patch for more path names, 2006 May 31.
-New version: http://members.tcnet.ch/michaelis/vim/patches.zip (also for other
-patches by Mathias, see mail Feb 22)
-
-Win32: compiling with normal features and OLE fails. Patch by Mathias
-Michaelis, 2006 Jun 4.
-
-Win32: after "[I" showing matches, scroll wheel messes up screen. (Tsakiridis,
-2007 Feb 18)
-Patch by Alex Dobrynin, 2007 Jun 3. Also fixes other scroll wheel problems.
-
-Win32: using CTRL-S in Insert mode doesn't remove the "+" from the tab pages
-label. (Tsakiridis, 2007 Feb 18) Patch from Ian Kelling, 2008 Aug 6.
-
-Win32: using "gvim --remote-tab-silent fname" sometimes gives an empty screen
-with the more prompt. Caused by setting the guitablabel? (Thomas Michael
-Engelke, 2007 Dec 20 - 2008 Jan 17)
-
-Win64: Seek error in swap file for a very big file (3 Gbyte). Check storing
-pointer in long and seek offset in 64 bit var.
-Patches from Ken Takata might help (2014 Apr 17)
-
-Win32: patch for fullscreen mode. (Liushaolin, 2008 April 17)
-
-Win32: When 'shell' is bash shellescape() doesn't always do the right thing.
-Depends on 'shellslash', 'shellquote' and 'shellxquote', but shellescape()
-only takes 'shellslash' into account.
-
-Menu item that does "xxd -r" doesn't work when 'fileencoding' is utf-16.
-Check for this and use iconv? (Edward L. Fox, 2007 Sep 12)
-Does the conversion in the other direction work when 'fileencodings' is set
-properly?
-
-Add a few features to xxd. (Vadim Vygonets, 2013 Nov 11)
-Patches: 2013 Nov 19
-1: Add -e: little endian hexdump
-2: Add -o: add offset to displayed position
-3: Change displayed file position width to 8 chars
-
-Cursor displayed in the wrong position when using 'numberwidth'. (James Vega,
-2007 Jun 21)
-
-When $VAR contains a backslash expand('$VAR') removes it. (Teemu Likonen, 2008
-Jun 18)
-
-If the variable "g:x#y#z" exists completion after ":echo g:x#" doesn't work.
-
-Feature request: Command to go to previous tab, like what CTRL-W p does for
-windows. (Adam George)
-
-F1 - F4 in an xterm produce a different escape sequence when used with a
-modifier key. Need to catch three different sequences. Use K_ZF1, like
-K_ZHOME? (Dickey, 2007 Dec 2)
-
-UTF-8: mapping a multi-byte key where the second byte is 0x80 doesn't appear
-to work. (Tony Mechelynck, 2007 March 2)
-
-In debug mode, using CTRL-R = to evaluate a function causes stepping through
-the function. (Hari Krishna Dara, 2006 Jun 28)
-
-C++ indenting wrong with "=". (James Kanze, 2007 Jan 26)
-
-":lockvar" should use copyID to avoid endless loop.
-
-When using --remote-silent and the file name matches 'wildignore' get an E479
-error. without --remote-silent it works fine. (Ben Fritz, 2008 Jun 20)
-
-Gvim: dialog for closing Vim should check if Vim is busy writing a file. Then
-use a different dialog: "busy saving, really quit? yes / no".
-
-":helpgrep" should use the directory from 'helpfile'.
-
-The need_fileinfo flag is messy. Instead make the message right away and put
-it in keep_msg?
-
-Editing a file remotely that matches 'wildignore' results in a "no match"
-error. Should only happen when there are wildcards, not when giving the file
-name literally, and esp. if there is only one name.
-
-Test 61 fails sometimes. This is a timing problem: "sleep 2" sometimes takes
-longer than 2 seconds.
-
-Using ":au CursorMoved * cmd" invokes mch_FullName(), which can be slow.
-Can this be avoided? (Thomas Waba, 2008 Aug 24)
-Also for ":w" without a file name.
-The buffer has the full path in ffname, should pass this to the autocommand.
-
-input() completion should not insert a backslash to escape a space in a file
-name?
-
-Ruby completion is insecure. Can this be fixed?
-
-When 'backupskip' is set from $TEMP special characters need to be escaped.
-(patch by Grembowietz, 2007 Feb 26, not quite right)
-Another problem is that file_pat_to_reg_pat() doesn't recognize "\\", so "\\("
-will be seen as a path separator plus "\(".
-
-gvim d:\path\path\(FILE).xml should not remove the \ before the (.
-This also fails with --remote.
-
-When doing ":quit" the Netbeans "killed" event isn't sent. (Xavier de Gaye,
-2008 Nov 10) call netbeans_file_closed() at the end of buf_freeall(), or in
-all places where buf_freeall() is called?
-
-aucmd_prepbuf() should also use a window in another tab page.
-
-When unloading a buffer in a BufHidden autocommand the hidden flag is reset?
-(Bob Hiestand, 2008 Aug 26, Aug 27)
-
-Substituting an area with a line break with almost the same area does change
-the Visual area. Can this be fixed? (James Vega, 2006 Sept 15)
-
-Spell checking: Add a way to specify punctuation characters. Add the
-superscript numbers by default: 0x2070, 0xb9, 0xb2, 0xb3, 0x2074 - 0x2079.
-
-Spell checking in popup menu: If the only problem is the case of the first
-character, don't offer "ignore" and "add to word list".
-
-Use different pt_br dictionary for spell checking. (Jackson A. Aquino, 2006
-Jun 5)
-
-Use different romanian dictionary for spell checking. (Andrei Popescu, Nov
-2008) Use http://downloads.sourceforge.net/rospell/ro_RO.3.2.zip
-Or the hunspell-ro.3.2.tar.gz file, it also has a iso-8859-2 list.
-
-In a C file with spell checking, in "% integer" "nteger" is seen as an error,
-but "]s" doesn't find it. "nteger" by itself is found. (Ralf Wildenhues, 2008
-Jul 22)
-
-There should be something about spell checking in the user manual.
-
-Spell menu: When using the Popup menu to select a replacement word,
-":spellrepeat" doesn't work. SpellReplace() uses setline(). Can it use "z="
-somehow? Or use a new function.
-
-Mac: Using gvim: netrw window disappears. (Nick Lo, 2006 Jun 21)
-
-Add an option to specify the character to use when a double-width character is
-moved to the next line. Default '>', set to a space to blank it out. Check
-that char is single width when it's set (compare with 'listchars').
-
-The generated vim.bat can avoid the loop for NT. (Carl Zmola, 2006 Sep 3)
-
-When showing a diff between a non-existent file and an existing one, with the
-cursor in the empty buffer, the other buffer only shows the last line. Change
-the "insert" into a change from one line to many? (Yakov Lerner, 2008 May 27)
-
-Add autocommand for when a tabpage is being closed. Also for when a tab page
-has been created.
-
-Using ":make" blocks Vim. Allow running one make in the background (if the
-shell supports it), catch errors in a file and update the error list on the
-fly. A bit like "!make > file&" and repeating ":cf file". ":bgmake",
-background make. ":bgcancel" interrupts it.
-A.Politz may work on this.
-
-These two abbreviations don't give the same result:
- let asdfasdf = "xyz\<Left>"
- cabbr XXX <C-R>=asdfasdf<CR>
- cabbr YYY xyz<Left>
-
-Michael Dietrich: maximized gvim sometimes displays output of external command
-partly. (2006 Dec 7)
-
-In FileChangedShell command it's no longer allowed to switch to another
-buffer. But the changed buffer may differ from the current buffer, how to
-reload it then?
-
-New syntax files for fstab and resolv from Radu Dineiu, David Necas did
-previous version.
-
-For Aap: include a config.arg.example file with hints how to use config.arg.
-
-Command line completion when 'cmdheight' is maximum and 'wildmenu' is set,
-only one buffer line displayed, causes display errors.
-
-Completing with 'wildmenu' and using <Up> and <Down> to move through directory
-tree stops unexpectedly when using ":cd " and entering a directory that
-doesn't contain other directories.
-
-Default for 'background' is wrong when using xterm with 256 colors.
-Table with estimates from Matteo Cavalleri, 2014 Jan 10.
-
-Setting 'background' resets the Normal background color:
- highlight Normal ctermbg=DarkGray
- set background=dark
-This is undesired, 'background' is supposed to tell Vim what the background
-color is, not reset it.
-
-Linux distributions:
-- Suggest compiling xterm with --enable-tcap-query, so that nr of colors is
- known to Vim. 88 colors instead of 16 works better. See ":help
- xfree-xterm".
-- Suggest including bare "vi" and "vim" with X11, syntax, etc.
-
-Completion menu: For a wrapping line, completing a long file name, only the
-start of the path is shown in the menu. Should move the menu to the right to
-show more text of the completions. Shorten the items that don't fit in the
-middle?
-
-When running inside screen it's possible to kill the X server and restart it
-(using pty's the program can keep on running). Vim dies because it loses the
-connection to the X server. Can Vim simply quit using the X server instead of
-dying? Also relevant when running in a console.
-
-Accessing file#var in a function should not need the g: prepended.
-
-When exiting detects a modified buffer, instead of opening the buffer in the
-current tab, use an existing tab, if possible. Like finding a window where
-the buffer is displayed. (Antonios Tsakiridis)
-
-When ":cn" moves to an error in the same line the message isn't shortened.
-Only skip shortening for ":cc"?
-
-Write "making vim work better" for the docs (mostly pointers): *nice*
- - sourcing $VIMRUNTIME/vimrc_example.vim
- - setting 'mouse' to "a"
- - getting colors in xterm
- - compiling Vim with X11, GUI, etc.
-
-Problem with ":call" and dictionary function. Hari Krishna Dara, Charles
-Campbell 2006 Jul 06.
-
-Syntax HL error caused by "containedin". (Peter Hodge, 2006 Oct 6)
-
-A custom completion function in a ":command" cannot be a Funcref. (Andy
-Wokula, 2007 Aug 25)
-
-Problem with using :redir in user command completion function? (Hari Krishna
-Dara, 2006 June 21)
-
-Another resizing problem when setting 'columns' and 'lines' to a very large
-number. (Tony Mechelynck, 2007 Feb 6)
-
-After starting Vim, using '0 to jump somewhere in a file, ":sp" doesn't center
-the cursor line. It works OK after some other commands.
-
-Win32: Is it possible to have both postscript and Win32 printing?
-
-Check: Running Vim in a console and still having connect to the X server for
-copy/paste: is stopping the X server handled gracefully? Should catch the X
-error and stop using the connection to the server.
-
-Problem with 'cdpath' on MS-Windows when a directory is equal to $HOME. (2006
-Jul 26, Gary Johnson)
-
-Using UTF-8 character with ":command" does not work properly. (Matt Wozniski,
-2008 Sep 29)
-
-In the Netbeans interface add a "vimeval" function, so that the other side can
-check the result of has("patch13").
-
-Cursor line at bottom of window instead of halfway through after saving view
-and restoring. Only with 'nowrap'. (Robert Webb, 2008 Aug 25)
-
-Netrw has trouble executing autocommands only for a directory. Add <isdir>
-and <notisdir> to autocommand patterns? Also <isfile>?
-
-Add command modifier that skips wildcard expansion, so that you don't need to
-put backslashes before special chars, only for white space.
-
-Syntax HL: open two windows on the same C code, delete a ")" in one window,
-resulting in highlighted "{" in that window, not in the other.
-
-In mswin.vim: Instead of mapping <C-V> for Insert mode in a complicated way,
-can it be done like ":imap <C-V> <MiddleMouse>" without negative side effects?
-
-When right after "vim file", "M" then CTRL-W v the windows are scrolled
-differently and unexpectedly. Caused by patch 7.2.398?
-
-The magic clipboard format "VimClipboard2" appears in several places. Should
-be only one.
-
-It's difficult to debug numbered functions (function in a Dictionary). Print
-the function name before resolving it to a number?
- let d = {}
- fun! d.foo()
- echo "here"
- endfun
- call d.foo(9)
-
-Add a mark for the other end of the Visual area (VIsual pos). '< and '> are
-only set after Visual moded is ended.
-Also add a variable for the Visual mode. So that this mode and '< '> can be
-used to set what "gv" selects. (Ben Schmidt)
-
-Win32: When running ":make" and 'encoding' differs from the system locale, the
-output should be converted. Esp. when 'encoding' is "utf-8". (Yongwei Wu)
-Should we use 'termencoding' for this?
-
-Win32, NTFS: When editing a specific infostream directly and 'backupcopy' is
-"auto" should detect this situation and work like 'backupcopy' is "yes". File
-name is something like "c:\path\foo.txt:bar", includes a colon. (Alex
-Jakushev, 2008 Feb 1)
-
-printf() uses the field width in bytes. Can it be made character width,
-perhaps with a modifier? What does Posix say?
-
-Small problem displaying diff filler line when opening windows with a script.
-(David Luyer, 2007 Mar 1 ~/Mail/oldmail/mool/in.15872 )
-
-Is it allowed that 'backupext' is empty? Problems when backup is in same dir
-as original file? If it's OK don't compare with 'patchmode'. (Thierry Closen)
-
-Patch for supporting count before CR in quickfix window. (AOYAMA Shotaro, 2007
-Jan 1)
-
-Patch for adding ":lscscope". (Navdeep Parhar, 2007 Apr 26; update 2008 Apr
-23)
-
-":mkview" isn't called with the right buffer argument. Happens when using
-tabs and the autocommand "autocmd BufWinLeave * mkview". (James Vega, 2007
-Jun 18)
-
-xterm should be able to pass focus changes to Vim, so that Vim can check for
-buffers that changed. Perhaps in misc.c, function selectwindow().
-Xterm 224 supports it!
-
-When completing from another file that uses a different encoding completion
-text has the wrong encoding. E.g., when 'encoding' is utf-8 and file is
-latin1. Example from Gombault Damien, 2007 Mar 24.
-
-Is it possible to use "foo#var" instead of "g:foo#var" inside a function?
-
-Syntax HL: When using "nextgroup" and the group has an empty match, there is
-no search at that position for another match. (Lukas Mai, 2008 April 11)
-
-In gvim the backspace key produces a backspace character, but on Linux the
-VERASE key is Delete. Set VERASE to Backspace? (patch by Stephane Chazelas,
-2007 Oct 16)
-
-Create a gvimtutor.1 file and change Makefiles to install it.
-
-When 'encoding' is utf-8 typing text at the end of the line causes previously
-typed characters to be redrawn. Caused by patch 7.1.329. (Tyler Spivey, 2008
-Sep 3, 11)
-
-X11: Putting more than about 262040 characters of text on the clipboard and
-pasting it in another Vim doesn't work. (Dominique Pelle, 2008 Aug 21-23)
-clip_x11_request_selection_cb() is called with zero value and length.
-Also: Get an error message from free() in the process that owns the selection.
-Seems to happen when the selection is requested the second time, but before
-clip_x11_convert_selection_cb() is invoked, thus in X library code.
-
-":vimgrep" does not recognize a recursive symlink. Is it possible to detect
-this, at least for Unix (using device/inode)?
-
-When switching between windows the cursor is often put in the middle.
-Remember the relative position and restore that, just like lnum and col are
-restored. (Luc St-Louis)
-
-Add an option for a minimal text length before inserting a line break for
-'textwidth'. Avoids very short lines when a very long word follows.
-(Kartik Agaram)
-
-
-At next release:
-- Build a huge version by default.
-- Improve plugin handling: Automatic updates, handle dependencies?
- E.g. Vundle: https://github.com/gmarik/vundle
-
-
-More patches:
-- Another patch for Javascript indenting. (Hari Kumar, 2010 Jul 11)
- Needs a few tests.
-- Add 'cscopeignorecase' option. (Liang Wenzhi, 2006 Sept 3)
-- Argument for feedkeys() to prepend to typeahead (Yakov Lerner, 2006 Oct
- 21)
-- Load intl.dll too, not only libintl.dll. (Mike Williams, 2006 May 9, docs
- patch May 10)
-- Extra argument to strtrans() to translate special keys to their name (Eric
- Arnold, 2006 May 22)
-- 'threglookexp' option: only match with first word in thesaurus file.
- (Jakson A. Aquino, 2006 Jun 14)
-- Mac: indicate whether a buffer was modified. (Nicolas Weber, 2006 Jun 30)
-- Allow negative 'nrwidth' for left aligning. (Nathan Laredo, 2006 Aug 16)
-- ml_append_string(): efficiently append to an existing line. (Brad
- Beveridge, 2006 Aug 26) Use in some situations, e.g., when pasting a
- character at a time?
-- recognize hex numbers better. (Mark Manning, 2006 Sep 13)
-- Add <AbbrExpand> key, to expand an abbreviation in a mapping. (Kana
- Natsuno, 2008 Jul 17)
-- Add 'wspara' option, also accept blank lines like empty lines for "{" and
- "}". (Mark Lundquist, 2008 Jul 18)
-- Patch to add CTRL-T to delete part of a path on cmdline. (Adek, 2008 Jul
- 21)
-- Instead of creating a copy of the tutor in all the shell scripts, do it in
- vimtutor.vim. (Jan Minar, 2008 Jul 20)
-- When fsync() fails there is no hint about what went wrong. Patch by Ben
- Schmidt, 2008 Jul 22.
-- testdir/Make_dos_sh.mak for running tests with MingW. (Bill Mccarthy, 2008
- Sep 13)
-- Patch for adding "space" item in 'listchars'. (Jérémie Roquet, 2009 Oct 29,
- Docs patch Oct 30, update David Burgin (glts) 2013 Aug 24, 2014 Oct 10)
-- Replace ccomplete.vim by cppcomplete.vim from www.vim.org? script 1520 by
- Vissale Neang. (Martin Stubenschrott) Asked Vissale to make the scripts
- more friendly for the Vim distribution.
- New version received 2008 Jan 6.
- No maintenance in two years...
-- Patch to open dropped files in new tabs. (Michael Trim, 2010 Aug 3)
-
-Awaiting updated patches:
-9 Mac unicode patch (Da Woon Jung, Eckehard Berns):
- 8 Add patch from Muraoka Taro (Mar 16) to support input method on Mac?
- New patch 2004 Jun 16
- - selecting proportional font breaks display
- - UTF-8 text causes display problems. Font replacement causes this.
- - Command-key mappings do not work. (Alan Schmitt)
- - With 'nopaste' pasting is wrong, with 'paste' Command-V doesn't work.
- (Alan Schmitt)
-9 HTML indenting can be slow. Caused by using searchpair(). Can search()
- be used instead? A.Politz is looking into a solution.
-8 Win32: Add minidump generation. (George Reilly, 2006 Apr 24)
-8 Add ":n" to fnamemodify(): normalize path, remove "../" when possible.
- Aric Blumer has a patch for this. He will update the patch for 6.3.
-7 Completion of network shares, patch by Yasuhiro Matsumoto.
- Update 2004 Sep 6.
- How does this work? Missing comments.
-8 Add a few more command names to the menus. Patch from Jiri Brezina
- (28 feb 2002). Will mess the translations...
-7 ATTENTION dialog choices are more logical when "Delete it" appears
- before "Quit". Patch by Robert Webb, 2004 May 3.
-- Include flipcase patch: ~/vim/patches/wall.flipcase2 ? Make it work
- for multi-byte characters.
-- Win32: add options to print dialog. Patch from Vipin Aravind.
-- Patch to add highlighting for whitespace. (Tom Schumm, 2003 Jul 5)
- use the patch that keeps using HLF_8 if HLF_WS has not
- been given values.
- Add section in help files for these highlight groups?
-8 "fg" and "bg" don't work in an xterm. Get default colors from xterm
- with an ESC sequence.
- xterm can send colors for many things. E.g. for the cursor:
- <Esc>]12;?<Bel>
- Can use this to get the background color and restore the colors on exit.
-7 Add "DefaultFG" and "DefaultBG" for the colors of the menu. (Marcin
- Dalecki has a patch for Motif and Carbon)
-- Add possibility to highlight specific columns (for Fortran). Or put a
- line in between columns (e.g., for 'textwidth').
- Patch to add 'hlcolumn' from Vit Stradal, 2004 May 20.
-8 Add functions:
- gettext() Translate a message. (Patch from Yasuhiro Matsumoto)
- Update 2004 Sep 10
- Another patch from Edward L. Fox (2005 Nov 24)
- Search in 'runtimepath'?
- More docs needed about how to use this.
- How to get the messages into the .po files?
- strchars() Like strlen() and strwidth() but counting characters
- instead of bytes.
- confirm() add "flags" argument, with 'v' for vertical
- layout and 'c' for console dialog. (Haegg)
- Flemming Madsen has a patch for the 'c' flag
- (2003 May 13)
- raisewin() raise gvim window (see HierAssist patch for
- Tcl implementation ~/vim/HierAssist/ )
- taglist() add argument to specify maximum number of matches.
- useful for interactive things or completion.
- col('^') column of first non-white character.
- Can use "len(substitute(getline('.'), '\S.*', '', ''))
- + 1", but that's ugly.
-7 Add patch from Benoit Cerrina to integrate Vim and Perl functions
- better. Now also works for Ruby (2001 Nov 10)
-- Patch from Herculano de Lima Einloft Neto for better formatting of the
- quickfix window (2004 dec 2)
-7 When 'rightleft' is set, the search pattern should be displayed right
- to left as well? See patch of Dec 26. (Nadim Shaikli)
-8 Option to lock all used memory so that it doesn't get swapped to disk
- (uncrypted). Patch by Jason Holt, 2003 May 23. Uses mlock.
-7 Add ! register, for shell commands. (patch from Grenie)
-8 In the gzip plugin, also recognize *.gz.orig, *.gz.bak, etc. Like it's
- done for filetype detection. Patch from Walter Briscoe, 2003 Jul 1.
-7 Add a "-@ filelist" argument: read file names from a file. (David
- Kotchan has a patch for it)
-8 Include a connection to an external program through a pipe? See
- patches from Felbinger for a mathematica interface.
- Or use emacs server kind of thing?
-7 Add ":justify" command. Patch from Vit Stradal 2002 Nov 25.
-- findmatch() should be adjusted for Lisp. See remark at
- get_lisp_indent(). Esp. \( and \) should be skipped. (Dorai Sitaram,
- incomplete patch Mar 18)
-- Patch for "paranoid mode" by Kevin Collins, March 7. Needs much more work.
-
-
-MSDOS and Win32:
-8 Should $USERPROFILE be preferred above $HOMEDRIVE/$HOMEPATH? No, but it's
- a good fallback, thus use:
- $HOME
- $HOMEDRIVE$HOMEPATH
- SHGetSpecialFolderPath(NULL, lpzsPath, CSIDL_APPDATA, FALSE);
- $USERPROFILE
- SHGetSpecialFolderPath(NULL, lpzsPath, CSIDL_COMMON_APPDATA, FALSE);
- $ALLUSERSPROFILE
- $SYSTEMDRIVE\
- C:\
-8 Win32 console: <M-Up> and <M-Down> don't work. (Geddes) We don't have
- special keys for these. Should use modifier + key.
-8 Win32 console: caps-lock makes non-alpha keys work like with shift.
- Should work like in the GUI version.
-8 Environment variables in DOS are not case sensitive. Make a define for
- STRCMP_ENV(), and use it when comparing environment var names.
-8 Setting 'shellslash' has no immediate effect. Change all file names when
- it is set/reset? Or only use it when actually executing a shell command?
-8 When editing a file on a Samba server, case might matter. ":e file"
- followed by ":e FILE" will edit "file" again, even though "FILE" might be
- another one. Set last used name in buflist_new()? Fix do_ecmd(), etc.
-8 When a buffer is editing a file like "ftp://mach/file", which is not going
- to be used like a normal file name, don't change the slashes to
- backslashes. (Ronald Hoellwarth)
-
-
-Win32 console:
-9 When editing a file by its short file name, it should be expanded into its
- long file name, to avoid problems like these: (Mccollister)
- 1) Create a file called ".bashrc" using some other editor.
- 2) Drag that file onto a shortcut or the actual executable.
- 3) Note that the file name is something like BASHRC~1
- 4) Go to File->Save As menu item and type ".bashrc" as the file name.
- 5) Press "Yes" to indicate that I want to overwrite the file.
- 6) Note that the message "File exists (add ! to override)" is displayed
- and the file is not saved.
- Use FindFirstFile() to expand a file name and directory in the path to its
- long name.
-7 Re-install the use of $TERM and support the use of different terminals,
- besides the console.
-8 Use of <altgr> modifier doesn't work? 5.3 was OK. (Garcia-Suarez/Guckes)
-9 Mapping <C-S-Tab> doesn't work correctly. How to see the difference with
- <C-S-i>?
-9 tmpnam() uses file in root of file system: "\asdf". That doesn't work on
- a Netware network drive. Use same function as for Win32 GUI?
-8 In os_win32.h, HAVE_STRICMP and HAVE_STRNICMP are defined only if __GNUC__
- is not defined. Shouldn't that be the other way around?
-7 Use SetConsoleCP() and SetConsoleOutputCP() to implement 'termencoding'?
- Avoids that input and output work differently. Need to be restored when
- exiting.
-
-
-Macintosh:
-7 Loading the Perl library only works on OS/X 10.2 or 10.3, never on both.
- Load the Perl library dynamically see Python sources file dynload_mac
- (Jack)
- dynamic linking: http://developer.apple.com/technotes/tn2002/tn2064.html
-8 inputdialog() doesn't resize when giving more text lines. (David Fishburn,
- 2006 Sept 28)
-8 Define vim_mkdir() for Macintosh.
-8 Define mch_writable() for Macintosh.
-9 When DiskLock is running, using a swap file causes a crash. Appears to be
- a problem with writing a file that starts with a dot. (Giacalone)
-9 In mac_expandpath() check that handling of backslashes is done properly.
-
-
-"Small" problems:
-- Can't disable terminal flow control, to enable the use of CTRL-S and
- CTRL-Q. Add an option for it?
-- When using e_secure in do_one_cmd() mention the command being executed,
- otherwise it's not clear where it comes from.
-- When the quickfix window is open and executing ":echo 'hello'" using the
- Command-line window, the text is immediately removed by the redrawing.
- (Michael Henry, 2008 Nov 1)
- Generic solution: When redrawing while there is a message on the
- cmdline, don't erase the display but draw over the existing text.
- Other solution, redraw after closing the cmdline window, before executing
- the command.
-9 For Turkish vim_tolower() and vim_toupper() also need to use utf_
- functions for characters below 0x80. (Sertacyildiz)
-9 When the last edited file is a help file, using '0 in a new Vim doesn't
- edit the file as a help file. 'filetype' is OK, but 'iskeyword' isn't,
- file isn't readonly, etc.
-8 When an ":edit" is inside a try command and the ATTENTION prompt is used,
- the :catch commands are always executed, also when the file is edited
- normally. Should reset did_emsg and undo side effects. Also make sure
- the ATTENTION message shows up. Servatius Brandt works on this.
-7 Vimtutor leaves escape sequence in terminal. This is the xterm response to
- requesting the version number. (Yasuhiro Matsumoto)
-8 When redirecting and using ":silent" the current column for displaying and
- redirection can be different. Use a separate variable to hold the column
- for redirection.
-7 The messages for "vim --help" and "vim --version" don't use
- 'termencoding'.
-- Could the hit-enter prompt be avoided when a message only overlaps the
- 'showcmd' area? Clear that area when the next cmd is typed.
-8 When 'scrollbind' is set, a window won't scroll horizontally if the cursor
- line is too short. Add a word in 'scrollopt' to allow moving the cursor
- to longer line that is visible. A similar thing is done for the GUI when
- using the horizontal scrollbar.
-7 VisVim can only open one file. Hard to solve: each opened file is passed
- with a separate invocation, would need to use timestamps to know the
- invocations belong together.
-8 When giving a ":bwipeout" command a file-changed dialog may popup for this
- buffer, which is pointless. (Mike Williams)
-8 On MS-Windows ":make" doesn't show output while it is working. Use the
- tee.exe from http://unxutils.sourceforge.net/ ? About 16 Kbyte in the
- UnxUtils.zip archive.
- Alternate one: http://www.pramodx.20m.com/tee_for_win32.htm, but Walter
- Briscoe says it's not as good.
-8 When doing Insert mode completion a mapping cannot recursively call
- edit(), because the completion information is global. Put everything in
- an allocated structure?
-8 Command line completion: buffers "foo.txt" and "../b/foo.txt", completing
- ":buf foo<Tab>" doesn't find the second one. (George V. Reilly)
-7 mb_off2cells() doesn't work correctly on the tail byte of a double-byte
- character. (Yasuhiro Matsumoto) It should return 1 when used on a tail
- byte, like for utf-8. Store second byte of double-byte in ScreenLines2[]
- (like for DBCS_JPNU) and put a zero in the second byte (like for UTF-8).
-7 Inside a function with "perl <<EOF" a line with "$i++" is recognized as an
- ":insert" command, causing the following "endfunction" not to be found.
- Add skipping this perl construction inside function definitions.
-7 When 'ttimeoutlen' is 10 and 'timeoutlen' is 1000, there is a keycode
- "<Esc>a" and a mapping <Esc>x", when typing "<Esc>a" with half a second
- delay should not be interpreted as a keycode. (Hans Ginzel)
-7 ":botright 1 new" twice causes all window heights to be changed. Make the
- bottom window only bigger as much as needed.
-7 The Cygwin and MingW makefiles define "PC", but it's not used anywhere.
- Remove? (Dan Sharp)
-9 User commands use the context of the script they were defined in. This
- causes a "s:var" argument to unexpectedly use a variable in the defining
- script, not the calling script. Add an argument to ":command":
- "-keepcontext". Do replace <SID>, so that a function in the defining
- script can be called.
-8 The Japanese message translations for MS-Windows are called ja.sjis.po,
- but they use encoding cp932. Rename the file and check that it still
- works.
-8 A very long message in confirm() can't be quit. Make this possible with
- CTRL-C.
-8 "gf" always excludes trailing punctuation characters. file_name_in_line()
- is currently fixed to use ".,:;!". Add an option to make this
- configurable?
-8 'hkmap' should probably be global-local.
-9 When "$" is in 'cpoptions' and folding is active, a "C" command changes
- the folds and resets w_lines_valid. The display updating doesn't work
- then. (Pritesh Mistry)
-8 Using ":s" in a function changes the previous replacement string. Save
- "old_sub" in save_search_patterns()?
-8 Should allow multi-byte characters for the delimiter: ":s+a+b+" where "+"
- is a multi-byte character.
-8 When appending to a file and 'patchmode' isn't empty, a backup file is
- always written, even when the original file already exists.
-9 When getting focus while writing a large file, could warn for this file
- being changed outside of Vim. Avoid checking this while the file is being
- written.
-7 The message in bt_dontwrite_msg() could be clearer.
-8 The script ID that is stored with an option and displayed with ":verbose
- set" isn't reset when the option is set internally. For example when
- 'foldlevel' is set from 'foldlevelstart'.
-8 Also store the line number with the script ID and use it for ":verbose",
- so that "set nocompatible" is found when it changes other option values.
- When an option is set indirectly mention the command? E.g. when
- ":diffsplit" sets 'foldmethod'.
-8 In the fileformat dialog, "Cancel" isn't translated. Add a global
- variable for this. (Eduardo Fernandez)
-9 When editing a file with 'readonly' set, there is no check for an existing
- swap file. Then using ":write" (without making any changes) doesn't give
- a warning either. Should check for an existing swap file without creating
- one. Unfinished patch by Ian Kelling, 2008 July 14.
-7 When 'showbreak' is set, the amount of space a Tab occupies changes.
- Should work like 'showbreak' is inserted without changing the Tabs.
-7 When 'mousefocus' is set and switching to another window with a typed
- command, the mouse pointer may be moved to a part of the window that's
- covered by another window and we lose focus. Only move in the y
- direction, not horizontally?
-8 ":hardcopy":
- - Using the cterm_color[] table is wrong when t_colors is > 16.
- - Need to handle unprintable characters.
- - Win32: On a B&W printer syntax highlighting isn't visible. Perform
- dithering to make grey text?
- - Add a flag in 'printoptions' to add an empty page to make the total
- number even. "addempty"? (Mike Williams)
- - Respect 'linebreak'. Perhaps also 'showbreak'?
- - Should interpret CTRL-L as a page break.
- - Grey line numbers are not always readable. Add field in 'printoptions'.
- Default to black when no syntax highlighting.
- - Be able to print a window in diff mode.
- - Be able to specify a colorscheme to use for printing. And a separate
- one for B&W printing (if that can be detected).
-8 In Visual block mode with 'lbr' set, a change command doesn't insert the
- text in following lines where the linebreak changes.
-8 When 'virtualedit' is "block,insert" and encoding is "utf-8", selecting a
- block of one double-wide character, then "d" deletes only half of it.
-8 When 'virtualedit' is set, should "I" in blockwise visual mode also insert
- in lines that don't extend into the block?
-8 With 'virtualedit' set, in Insert mode just after the end of line, CTRL-O
- yh does not yank the last character of the line. (Pavel Papushev)
- Doing "hl" first appears to make it work.
-8 With 'virtualedit' set it's possible to move into the blank area from
- 'linebreak'.
-8 With 'virtualedit' set and 'selection' "exclusive", a Visual selection
- that ends in or after a tab, "d" doesn't delete (part of) the tab.
- (Helmut Stiegler)
-9 When jumping to a tag, the search pattern is put in the history. When
- 'magic' is on, the pattern may not work. Translate the pattern depending
- on p_magic when putting it in the history? Alternative: Store value of
- 'magic' in history. (Margo)
-9 optwin.vim: Restoring a mapping for <Space> or <CR> is not correct for
- ":noremap". Add "mapcmd({string}, {mode})? Use code from ":mkexrc".
-9 incsearch is incorrect for "/that/<Return>/this/;//" (last search pattern
- isn't updated).
-9 Get out-of-memory for ":g/^/,$s//@/" on 1000 lines, this is not handled
- correctly. Get many error messages while redrawing the screen, which
- cause another redraw, etc.
-8 [<C-I> doesn't work when '*' is in 'iskeyword'. find_pattern_in_path()
- must escape special characters in the pattern.
-8 Vim can overwrite a read-only file with ":w!". ":w" can't overwrite an
- existing file, "w!" can, but perhaps not a read-only file? Then use
- ":w!!" for that.
- Or ask for permission to overwrite it (if file can be made writable) and
- restore file to readonly afterwards.
- Overwriting a file for which a swap file exists is similar issue.
-7 X11: Some people prefer to use CLIPBOARD instead of PRIMARY for the normal
- selection. Add an "xclipboard" argument to the 'clipboard' option? (Mark
- Waggoner)
-8 For xterm need to open a connection to the X server to get the window
- title, which can be slow. Can also get the title with "<Esc>[21t", no
- need to use X11 calls. This returns "<Esc>]l{title}<Esc>\".
-6 When the xterm reports the number of colors, a redraw occurs. This is
- annoying on a slow connection. Wait for the xterm to report the number of
- colors before drawing the screen. With a timeout.
-8 When the builtin xterm termcap contains codes that are not wanted, need a
- way to avoid using the builtin termcap.
-8 Xterm sends ^[[H for <Home> and ^[[F for <End> in some mode. Also
- recognize these keys? Mostly useful for xterm simulators, like gnometerm.
- See http://dickey.his.com/xterm/xterm.faq.html#xterm_pc_style.
-8 For xterm also recognize keypad up/down/left/right and insert.
-8 '[ and '] should be set to start/end of line when using a linewise operator
- (e.g., ":w").
-8 CTRL-A can't handle big "long" numbers, they become negative. Check for
- "-" character, if not present, use unsigned long.
-8 Make it possible to disable the special meaning of "#" in the first column
- for ">>".
-8 Add suspending with CTRL-Z at the "more" prompt, and when executing a long
- script in do_cmdline().
-8 When using 'hidden', many swap files will be open. When Vim runs into the
- maximum number of open files, error messages will appear. Detect that
- this problem is present, and close any hidden files that don't have
- changes.
-8 With 'viminfo' set such that the ".viminfo" file is written on a FAT
- filesystem, an illegal file name may be created: ".vim".
-8 For each buffer that is opened, the viminfo file is opened and read to
- check for file marks. This can be slow.
-7 In xterm, recognize both vt100 and vt220 cursor keys. Change
- add_termcode() to not remove an existing entry for a name, when it's
- needed.
- Need a generic solution to recognize different codes for the same key.
-8 Core dump within signal function: gdb doesn't show stack backtrace! Option
- to skip catch_signals()?
-9 Repeating a "cw" with "." doesn't work if the text was pasted from the
- clipboard. (Thomas Jones) It's because the menu/toolbar item exits Insert
- mode and uses "gP". How to fix this without breaking inserting a block of
- text?
-8 In Replace mode pasting from the clipboard (using menu or toolbar) inserts
- all the text. Add ":rmenu"?
-8 Pasting with the mouse in Replace mode inserts the text, instead of
- overwriting, when it is more than one line. Same for using <C-R>.
-9 CTRL-E and CTRL-Y don't work in small window when 'so' is 4 and lines are
- wrapping (Acevedo/in.226). E.g., when using CTRL-E, window height 7,
- window might actually scroll down when last line of buffer is displayed.
- --> Remember if the previous command was "cursor follows screen" or
- "screen follow cursor" and use this in cursupdate().
-7 tilde_replace() can only handle "~/", should also do "~user/".
- Get the list of home directories (from /etc/passwd? Use getpwent()) and
- use some clever algorithm to match a path with that. Find common strings
- in the list?
-8 When dragging status line with mouse, sometimes a jump when first clicking
- on the status line (caused by 'winheight'). Select window on button up,
- instead of on button down.
-8 Dragging the status line doesn't scroll but redraw.
-9 Evaluating 'statusline' in build_stl_str_hl() does not properly check for
- reaching the end of the available buffer.
- Patch to dynamically allocate the buffer for % items. (Eric Arnold, 2006
- May 14)
-8 When performing incremental search, should abort searching as soon as a
- character is typed.
-8 When the value of $MAKE contains a path, configure can't handle this.
- It's an autoconf bug. Remove the path from $MAKE to work around it.
-8 How to set VIMRC_FILE to \"something\" for configure? Why does this not
- work: CFLAGS='-DVIMRC_FILE=\"/mydir/myfile\"' ./configure
-8 The temporary file is sometimes not writable. Check for this, and use an
- alternate name when it isn't. Or add the 'temptemplate' option: template
- for the temp file name ":set temptemplate=/usr/tmp/?????.tmp".
- Also: Win32 version uses Windows temp directory, which might not work for
- cygwin bash.
-7 Get error "*, \+ or \( operand could be empty" for pattern "\(.\)\1\{3}".
- Remember flags for backreferences.
-7 When switching to Daylight Saving Time, Vim complains that a file has been
- changed since last read. Can we use a function that uses GMT?
-7 When completing an environment variable after a '$', check for file names
- that contain a '$' after all have been found.
-8 When "cm" termcap entry is missing, starting gvim shouldn't complain about
- it. (Lohner) Try out with "vt100" entry, cm replaced with cX.
-7 When an include file starts with "../", the check for already visiting
- this file doesn't work. Need to simplify the file name.
-7 The names and comments for the arguments of do_browse() are confusing.
- "dflt" isn't the default file name when "initdir" is not NULL and
- "initdir" is the default path to be used.
-7 When 'scrolloff' is exactly half the window height, "j" causes a scroll of
- two lines at a time. "k" doesn't do this. (Cory T. Echols)
-8 When write_viminfo() is used while there are many orphaned viminfo
- tempfiles writing the viminfo file fails. Give a clear error message so
- that the user knows he has to delete the files.
-7 It's possible to redefine a script-local function with ":func
- <SNR>123_Test()". (Krishna) Disallow this.
-
-
-I can't reproduce these (if you can, let me know how!):
-9 NT 4.0 on NTFS file system: Editing ".bashrc" (drag and drop), file
- disappears. Editing ".xyz" is OK. Also, drag&drop only works for three
- files. (McCollister)
-
-
-Problems that will (probably) not be solved:
-- xterm title: The following scenario may occur (esp. when running the Vim
- test script): Vim 1 sets the title to "file1", then restores the title to
- "xterm" with an ESC sequence when exiting. Vim 2 obtains the old title
- with an X library call, this may result in "file1", because the window
- manager hasn't processed the "xterm" title yet. Can apparently only be
- worked around with a delay.
-- In a terminal with 'mouse' set such that the mouse is active when entering
- a command line, after executing a shell command that scrolls up the
- display and then pressing ":": Selecting text with the mouse works like
- the display wasn't scrolled. Vim doesn't know how much the external
- command scrolled up the display. Use Shift to select text.
-- X windows: When $DISPLAY points to a X server where there is no access
- permission, trying to connect to the X server causes an error message.
- XtOpenDisplay() prints this directly, there is no way to avoid it.
-- Moving the cursor removes color in color-xterm. This is a color-xterm
- problem! color-xterm ver. 6.1 beta 3 and later work properly.
-- In zsh, "gvim&" changes the terminal settings. This is a zsh problem.
- (Jennings)
-- Problem with HPterm under X: old contents of window is lost (Cosentino).
-- Linux: A file with protection r--rw-rw- is seen readonly for others. The
- access() function in GNU libc is probably wrong.
-- MSDOS: When using smartdrive with write-back buffering, writing to a
- readonly floppy will cause problems. How to test for a writable floppy
- first?
-- MSDOS: Both 16 and 32 bit versions: File name expansion doesn't work for
- names that start with a dot. These used to be illegal file names.
-- When doing a CTRL-Z and typing a command for the shell, while Vim is busy
- (e.g. writing a file), the command for the shell is sometimes eaten by Vim,
- because the terminal mode is changed from RAW to CBREAK.
-- An old version of GNU tgoto can't handle the terminfo code for "AF". The
- "%p1" is interpreted as "%p" and "1", causing color not to be working.
- Fix: Change the "%p1" in the "AF" and "AB" terminfo entries to "%p".
- (Benzinger).
-- Win32: All files created on the day of switching from winter to summer
- time cause "changed since editing started" messages. It goes away when
- the file is written again the next day, or the timezone is adjusted.
- Looks like a problem with the Win32 library.
- Rebooting doesn't help. Time stamps look OK in directory. (Penn)
- Is this on FAT (stores wall clock time) or NTFS (stores UTS)?
-- Win32, MS-Windows XP: $HOME uses the wrong drive when the user profiles
- are not on the boot disk. This is caused by a wrong value of $HOMEDRIVE.
- This is a bug in XP, see MSKB article 818134.
-- Win32, MS-Windows: expanding plugin/**/*.vim also picks up
- dir/ctags.vim,v. This is because the short file name is something like
- "ctags~1.vim" and that matches the pattern.
-- When using an xterm that supports the termresponse feature, and the 't_Co'
- termcap option was wrong when Vim started, it will be corrected when the
- termresponse is received. Since the number of colors changes, the
- highlighting needs to be initialized again. This may cause colors defined
- in the vimrc file to be lost.
-- On Windows NT 4.0 the number of files passed to Vim with drag&drop and
- "Edit with Vim" is limited. The maximum command line length is 255 chars.
-
---------------------- extensions and improvements ----------------------
- *extensions-improvements*
-
-Most interesting new features to be added when all bugs have been fixed:
-- Using ":exe edit fname" has escaping problems. Use ":edit ++(fname)".
- Thus use "++=" to give arguments as expressions, comma separated as if
- calling a function.
- With options: ":edit ++(['!', '++enc=abc'], ['+/pat'], fname)".
- Alternative: Make a function for Ex commands: cmd_edit().
-- Add COLUMN NUMBERS to ":" commands ":line1,line2[col1,col2]cmd". Block
- can be selected with CTRL-V. Allow '$' (end of line) for col2.
-- Add DEBUGGER INTERFACE. Implementation for gdb by Xavier de Gaye.
- Should work like an IDE. Try to keep it generic. Now found here:
- http://clewn.sf.net.
- And the idevim plugin/script.
- To be able to start the debugger from inside Vim: For GUI run a program
- with a netbeans connection; for console: start a program that splits the
- terminal, runs the debugger in one window and reconnect Vim I/O to the
- other window.
- Wishes for NetBeans commands:
- - make it possible to have 'defineAnnoType' also handle terminal colors.
- - send 'balloonText' events for the cursor position (using CursorHold ?)
- in terminal mode.
-- ECLIPSE plugin. Problem is: the interface is very complicated. Need to
- implement part in Java and then connect to Vim. Some hints from Alexandru
- Roman, 2004 Dec 15. Should then also work with Oracle Jdeveloper, see JSR
- 198 standard http://www.jcp.org/en/jsr/detail?id=198.
- Eclim does it: http://eclim.sourceforge.net/ (Eric Van Dewoestine)
- Plugin that uses a terminal emulator: http://vimplugin.sf.net
- And another one: http://www.satokar.com/viplugin/index.php
-- STICKY CURSOR: Add a way of scrolling that leaves the cursor where it is.
- Especially when using the scrollbar. Typing a cursor-movement command
- scrolls back to where the cursor is.
-- Scroll commands by screen line. g CTRL-E and g CTRL-Y ? Requires the
- first line to be able to start halfway through.
-8 Add a command to jump to a certain kind of tag. Allow the user to specify
- values for the optional fields. E.g., ":tag size type=m".
- Also allow specifying the file and command, so that the result of
- taglist() can be used.
-- X11: Make it possible to run Vim inside a window of another program.
- This can be done with XReparentWindow(). But how exactly?
-
-
-Documentation:
-8 List of Vim runtime directories. dotvim.txt from Charles Campbell, 2007
- Feb 20.
-8 List of options should mention whether environment variables are expanded
- or not.
-8 Extend usr_27.txt a bit. (Adam Seyfarth)
-7 Add a section on debugging scripts in the user manual.
-9 Make the Reference Manual more precise. For each command mention:
- - change to cursor position and curswant
- - if it can be undone (u/CTRL-R) and redone (.)
- - how it works for folded lines
- - how it works with multi-byte characters
-9 In change.txt, remark about Javadoc isn't right. Right alignment would
- work too.
-8 Spread the windows commands over the other files. For example, ":stag"
- should be with ":tag". Cross-link with tags to avoid too much double
- text.
-8 Add tags for all features, e.g. "gui_running".
-7 MS-Windows: When a wrong command is typed with an ALT key, give a hint to
- look at the help for 'winaltkeys'.
-7 Add a help.vim plugin that maps <Tab> to jump to the next tag in || and
- <C-Tab> (and <S-Tab>) to the previous tag.
- Patch by Balazs Kezes, 2007 Dec 30. Remark from A. Politz.
-- Check text editor compendium for vi and Vim remarks.
-
-
-Help:
-- First try using the ":help" argument literally, before using it as a
- pattern. And then match it as part of a tag.
-- When a help item has multiple matches make it possible to use ":tn" to go
- to the other matches.
-- Support a way to view (and edit) .info files.
-- Default mapping for help files: <Tab> to position cursor on next |:tag|.
-- Implement a "sticky" help window, some help text lines that are always
- displayed in a window with fixed height. (Guckes) Use "~/.vimhelp" file,
- user can edit it to insert his favorite commands, new account can contain a
- default contents.
-- Make 'winminheight' a local option, so that the user can set a minimal
- height for the help window (and other windows).
-- ":help :s^I" should expand to ":help :substitute".
-- Make the help key (<F1>) context sensitive?
-- Learn mode: show short help while typing commands.
-
-
-User Friendlier:
-8 Windows install with install.exe: Use .exe instead of .bat files for
- links, so that command line arguments are passed on unmodified? (Walter
- Briscoe)
-8 Windows install: Be able to associate Vim with a selection of file types?
-8 Windows uninstall: Have uninstal.c delete the vimfiles directories that
- dosinst.c creates. List the contents of the directory (recursively) if
- the user asks for it. Requires an implementation of "rm -rf".
-8 Remember the name of the vimrc file that was used (~/.vimrc, $VIM/_vimrc,
- $HOME/_vimrc, etc.) and add "edit vimrc" to the File menu.
-- Add a way to save local settings and mappings into a new plugin file.
- ":mkplugin <file>"?
-8 Add ":plugininstall" command. Can be used to install a plugin file that
- includes documentation. Let the user select a directory from
- 'runtimepath'.
- " Vim plugin
- <main plugin code>
- " >>> plugin help start <<<
- <plugin docs>
-- Add mappings local to a window: ":map <window> ..."?
-9 Add buffer-local menu. Should offer a choice between removing the menu or
- disabling it. Be careful that tear-offs don't disappear (keep one empty
- item?).
- Alternative: use BufEnter and BufLeave autocommands.
-7 Add the arguments for configure to the ":version" output?
-7 When Vim detects a file is being edited elsewhere and it's a gvim session
- of the same user it should offer a "Raise" button, so that the other gvim
- window can be displayed. (Eduard)
-
-
-Tab pages:
-9 GUI implementation for the tab pages line for other systems.
-7 GUI: Control over the appearance of the text in the labels (bold, color,
- font, etc.)
-8 Make GUI menu in tab pages line configurable. Like the popup menu.
-8 balloons for the tab page labels that are shortened to show the full path.
-7 :tabdup duplicate the tab with all its windows.
-7 Option to put tab line at the left or right? Need an option to specify
- its width. It's like a separate window with ":tabs" output.
-7 Add local variables for each tab page?
-8 Add local options for each tab page? E.g., 'diffopt' could differ between
- tab pages.
-7 Add local highlighting for each tab page?
-7 Add local directory for tab pages? How would this interfere with
- window-local directories?
-
-
-Spell checking:
-- Support more regions? Caolan McNamara argues it's needed for es_XX.
- https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=219777
-- Unicode defines another quote character: 0x2019. Use it as an equivalent
- of a single quote, thus use it as a word character like a quote and match
- with words, replacing the curly quote with a single quote.
-- Could filter &eacute; things for HTML before doing spell checking.
- Similarly for TeX.
-- The Hungarian spell file uses four extra characters in the FOL/UPP/LOW
- items than other spell files with the ISO-8859-2 encoding, that causes
- problem when changing 'spelllang'. There is no obvious way to fix this.
-- Considering Hunspell 1.1.4:
- What does MAXNGRAMSUGS do?
- Is COMPLEXPREFIXES necessary when we have flags for affixes?
-- Support spelling words in CamelCase as if they were two separate words.
- Requires some option to enable it. (Timothy Knox)
-- There is no Finnish spell checking file. For openoffice Voikko is now
- used, which is based on Malaga: http://home.arcor.de/bjoern-beutel/malaga/
- (Teemu Likonen)
-8 ":mkspell" still takes much too long in Hungarian dictionary from
- hunspell. Only solution appears to be to postpone secondary suffixes.
-8 Handle postponed prefix with COMPOUNDPERMITFLAG or COMPOUNDFORBIDFLAG.
- WFP_COMPPERMIT and WFP_COMPFORBID
-8 implement use of <compoptions> in .spl file:
- implement CHECKCOMPOUNDREP: when a compound word seems to be OK apply REP
- items and check if the result is a valid word.
- implement CHECKCOMPOUNDDUP
- implement CHECKCOMPOUNDTRIPLE
- Add CHECKCOMPOUNDCASE: when compounding make leading capital lower case.
- How is it supposed to work?
-- Add a command the repeats ]s and z=, showing the misspelled word in its
- context. Thus to spell-check a whole file.
-- suggestion for "KG" to "kg" when it's keepcase.
-- For flags on affixes: Use a "AFFCOMPSET" flag; means the compound flags of
- the word are not used.
-- Support breakpoint character ? 0xb7 and ignore it? Makes it possible to
- use same wordlist for hyphenation.
-- Compound word is accepted if nr of words is <= COMPOUNDWORDMAX OR nr of
- syllables <= COMPOUNDSYLMAX. Specify using AND in the affix file?
-- NEEDCOMPOUND also used for affix? Or is this called ONLYINCOMPOUND now?
- Or is ONLYINCOMPOUND only for inside a compound, not at start or end?
-- Do we need a flag for the rule that when compounding is done the following
- word doesn't have a capital after a word character, even for Onecap words?
-- New hunspell home page: http://hunspell.sourceforge.net/
- - Version 1.1.0 is out now, look into that.
- - Lots of code depends on LANG, that isn't right. Enable each mechanism
- in the affix file separately.
- - Example with compounding dash is bad, gets in the way of setting
- COMPOUNDMIN and COMPOUNDWORDMAX to a reasonable value.
- - PSEUDOROOT == NEEDAFFIX
- - COMPOUNDROOT -> COMPOUNDED? For a word that already is a compound word
- Or use COMPOUNDED2, COMPOUNDED3, etc.
-- CIRCUMFIX: when a word uses a prefix marked with the CIRCUMFIX flag, then
- the word must also have a suffix marked with the CIRCUMFIX flag. It's a
- bit primitive, since only one flag is used, which doesn't allow matching
- specific prefixes with suffixes.
- Alternative:
- PSFX {flag} {pchop} {padd} {pcond} {schop} {sadd}[/flags] {scond}
- We might not need this at all, you can use the NEEDAFFIX flag and the
- affix which is required.
-- When a suffix has more than one syllable, it may count as a word for
- COMPOUNDWORDMAX.
-- Add flags to count extra syllables in a word. SYLLABLEADD1 SYLLABLEADD2,
- etc.? Or make it possible to specify the syllable count of a word
- directly, e.g., after another slash: /abc/3
-- MORPHO item in affix file: ignore TAB and morphological field after
- word/flags and affix.
-- Implement multiple flags for compound words and CMP item?
- Await comments from other spell checking authors.
-- Also see tklspell: http://tkltrans.sourceforge.net/
-8 Charles Campbell asks for method to add "contained" groups to existing
- syntax items (to add @Spell).
- Add ":syntax contains {pattern} add=@Spell" command? A bit like ":syn
- cluster" but change the contains list directly for matching syntax items.
-- References: MySpell library (in OpenOffice.org).
- http://spellchecker.mozdev.org/source.html
- http://whiteboard.openoffice.org/source/browse/whiteboard/lingucomponent/source/spellcheck/myspell/
- author: Kevin Hendricks <kevin.hendricks@sympatico.ca>
-8 It is currently not possible to mark "can not" as rare, because "can" and
- "not" are good words. Find a way to let "rare" overrule "good"?
-8 Make "en-rare" spell file? Ask Charles Campbell.
-8 The English dictionaries for different regions are not consistent in their
- use of words with a dash.
-7 Insert mode completion mechanism that uses the spell word lists.
-8 Add hl groups to 'spelllang'?
- :set spelllang=en_us,en-rare/SpellRare,en-math/SpellMath
- More complicated: Regions with different languages? E.g., comments
- in English, strings in German (po file).
-
-
-Diff mode:
-9 When making small changes, e.g. deleting a character, update the diff.
- Possibly without running diff.
-9 Instead invoking an external diff program, use builtin code. One can be
- found here: http://www.ioplex.com/~miallen/libmba/dl/src/diff.c
- It's quite big and badly documented though.
-8 Use diff mode to show the changes made in a buffer (compared to the file).
- Use an unnamed buffer, like doing:
- new | set bt=nofile | r # | 0d_ | diffthis | wincmd p | diffthis
- Also show difference with the file when editing started? Should show what
- can be undone. (Tom Popovich)
-7 Add cursor-binding: when moving the cursor in one diff'ed buffer, also
- move it in other diff'ed buffers, so that CTRL-W commands go to the same
- location.
-
-
-Folding:
- (commands still available: zI zJ zK zp zP zq zQ zV zy zY;
- secondary: zB zS zT zZ, z=)
-8 Vertical folds: looks like vertically split windows, but the cursor moves
- through the vertical separator, separator moves when scrolling.
-8 Add "z/" and "z?" for searching in not folded text only.
-9 Add search pattern item to only match in closed or open fold and/or fold
- with certain level. Allows doing ":g/pat/cmd" to work on closed folds.
-8 When a closed fold is displayed open because of 'foldminlines', the
- behavior of commands is still like the fold is closed. How to make the
- user aware of this?
-8 Add an option 'foldskip' with values like 'foldopen' that specifies which
- commands skip over a closed fold.
-8 "H" and "L" count buffer lines instead of window lines. (Servatius Brandt)
-8 Add a way to add fold-plugins. Johannes Zellner has one for VB.
-7 When using manual folding, the undo command should also restore folds.
-- Allow completely hiding a closed fold. E.g., by setting 'foldtext' to an
- empty string. Require showing a character in 'foldcolumn' to avoid the
- missing line goes unnoticed.
- How to implement this?
-- When pressing the down arrow of a scrollbar, a closed fold doesn't scroll
- until after a long time. How to make scrolling with closed folds
- smoother?
-- When creating a session, also store folds for buffers in the buffer list,
- using the wininfo in wi_folds.
-- When currently editing the first file in the argument list the session
- file can contain:
- args version.c main.c
- edit version.c
- Can editing version.c twice be avoided?
-- 'foldmethod' "textobject": fold on sections and paragraph text objects.
-- "zuf": undo change in manual fold. "zUf" redo change in manual fold. How
- to implement this?
-- "zJ" command: add the line or fold below the fold in the fold under the
- cursor.
-- 'foldmethod' "syntax": "fold=3" argument: set fold level for a region or
- match.
-- Apply a new foldlevel to a range of lines. (Steve Litt)
-8 Have some way to restrict commands to not folded text. Also commands like
- searches.
-
-
-Multi-byte characters:
-- When editing a file with both utf-8 and latin1 text Vim always falls back
- to latin1. Add a command to convert the latin1 characters to utf-8?
- :unmix utf-8,latin1 filename
- Would only work when 'encoding' is utf-8.
-9 When the tail byte of a double-byte character is illegal (e.g., a CR), the
- display is messed up (Yasuhiro Matsumoto). Should check for illegal
- double-byte characters and display them differently (display each single
- byte).
-9 'fenc' in modeline problem: add option to reload the file when 'fenc' is
- set to a different value in a modeline? Option can be default on. Could
- it be done with an autocommand?
-8 Add an item in 'fileencodings' to check the first lines of a file for
- the encoding. See Python PEP: http://www.python.org/peps/pep-0263.html.
- To avoid getting a wrong encoding only accept something Emacs-like:
- "-*- coding: enc-na_me.foo -*-" and "-*- coding= enc-na_me.foo -*-"
- Match with "-\*-\s*coding[:=]\s*\([::word::-_.]\+\)\s*-\*-" and use first
- item.
-8 Add an item in 'fileencodings' to check the first line of an XML file for
- the encoding. <?xml version="1.0" encoding="UTF-8"?> Or "charset=UTF-8"?
- For HTML look for "charset=utf-8".
-8 The quickfix file is read without conversion, thus in 'encoding'. Add an
- option to specify the encoding of the errorfile and convert it. Also for
- ":grep" and ":helpgrep".
- More generic solution: support a filter (e.g., by calling a function).
-8 When a file was converted from 'fileencoding' to 'encoding', a tag search
- should also do this on the search pattern. (Andrzej M. Ostruszka)
-8 When filtering changes the encoding 'fileencoding' may not work. E.g.,
- when using xxd and 'fileencoding' is "utf-16". Add an option to set a
- different fileencoding for filter output?
-7 When converting a file fails, mention which byte could not be converted,
- so that the user can fix the problem.
-8 Add configure option to be able to disable using the iconv library. (Udo
- Schweigert)
-9 'aleph' should be set to 1488 for Unicode. (Zvi Har'El)
-8 Should add test for using various commands with multi-byte characters.
-8 'infercase' doesn't work with multi-byte characters.
-8 toupper() function doesn't handle byte count changes.
-7 Searching and composing characters:
- When searching, should order of composing characters be ignored?
- Add a special item to match with a composing character, so that composing
- characters can be manipulated.
-8 Should implement 'delcombine' for command line editing.
-8 Detect overlong UTF-8 sequences and handle them like illegal bytes.
-8 ":s/x/\u\1/" doesn't work, making uppercase isn't done for multi-byte
- characters.
-8 UTF-8: "r" in Visual mode doesn't take composing characters.
-8 UTF-8: When there is a precomposed character in the font, use it instead
- of a character and a composing character. See xterm for an example.
-7 When a character can't be displayed, display its digraph instead.
- 'display' option to specify this.
-7 Use ideas for nl_langinfo() from Markus Kuhn in enc_default():
- (www.cl.cam.ac.uk/~mgk25/ucs/langinfo.c)
-- dbcs_class() only works for Japanese and Korean. Implement this for
- other encodings. The "euc-jp" and "euc-kr" choices might be wrong.
-- Find some way to automatically select the right GUI font or fontset,
- depending on the default value of 'encoding'.
- Irrelevant in the GTK+ 2 GUI so long as UTF-8 is used.
- For Windows, the charset_pairs[] table could be used. But how do we know
- if a font exists?
-- Do keyboard conversion from 'termencoding' to 'encoding' with
- convert_input() for Mac GUI.
-- Add mnemonics from RFC1345 longer than two characters.
- Support CTRL-K _{mnemonic}_
-7 In "-- INSERT (lang) --" show the name of the keymap used instead of
- "lang". (Ilya Dogolazky)
-- Make 'breakat' accept multi-byte characters. Problem: can't use a lookup
- table anymore (breakat_flags[]).
- Simplistic solution: when 'formatoptions' contains "m" also break a line
- at a multi-byte character >= 0x100.
-- Add the possibility to enter mappings which are used whenever normal text
- could be entered. E.g., for "f" command. But not in Normal mode. Sort
- of opposite of 'langmap'. Use ":tmap" command?
-- When breaking a line, take properties of multi-byte characters into
- account. The "linebreak" program from Bruno Haible can do it:
- ftp://ftp.ilog.fr/pub/Users/haible/gnu/linebreak-0.1.tar.gz
- But it's very complicated...
-
-
-Printing:
-7 Implement "undercurl" for printing.
-- Add "page width" to wrap long lines.
-- Win32: use a font dialog for setting 'printfont'. Can reuse the code for
- the 'guifont' dialog, put the common code in a separate function.
-- Add the file timestamp to the page header (with an option). (George
- Reilly)
-- Win32: when 'printfont' is empty use 'guifont'.
-- Unix: Use some dialog box to do the obvious settings (paper size, printer
- name, portrait/landscape, etc).
-- PostScript: Only works for text that can be converted to an 8-bit
- character set. How to support Unicode fully?
-- Allow specifying the paper size, instead of using a standard size. Same
- units as for the margins.
-- Support right-to-left text?
-8 Make the foreground color darkening function preserve the hue of the
- color.
-
-
-Syntax highlighting:
-8 Make ":syn off" use 'runtimepath' instead of $VIMRUNTIME. (Gary Johnson)
- Should do the same for ":syn on" and ":syn manual".
-8 Support "containedin" argument for ":syn include", so that the defined
- cluster can be added to existing syntax items.
-8 C syntax: Don't highlight {} as errors inside () when used like this:
- "({ something })", often used in GCC code.
-7 Add a "startgroup" to a region. Used like "nextgroup" inside the region,
- preferred item at the start of the region. (Charles Campbell)
-8 When editing a new file without a name and giving it a name (by writing
- it) and 'filetype' is not set, detect the filetype. Avoid doing it for
- ":wq file".
-7 For "nextgroup" we have skipwhite, skipnl and skipempty. It would be
- really nice to be able to skip with a pattern. Or skip with a syntax
- group. (Nikolai Weibull, 2007 Feb 27)
-8 Make conversion to HTML faster (Write it in C or pre-compile the script).
-9 There is still a redraw bug somewhere. Probably because a cached state is
- used in a wrong way. I can't reproduce it...
-7 Be able to change only the background highlighting. Useful for Diff* and
- Search highlighting.
-7 When 'number' is set highlight the number of the current line.
- Must be enabled with an option, because it slows down display updating.
-8 Allow the user to add items to the Syntax menu sorted, without having to
- change this for each release.
-8 Add a "matchcontains" for regions: items contained in the start or end
- pattern, but not in the body.
-8 Add a "keepend-contained" argument: Don't change the end of an item this
- one is contained in. Like "keepend" but specified on the contained item,
- instead of the containing item.
-8 cpp.vim: In C++ it's allowed to use {} inside ().
-8 Some syntax files set 'iskeyword'. When switching to another filetype
- this isn't reset. Add a special keyword definition for the syntax rules?
- When this is done, use vim.vim syntax highlighting for help file examples,
- but without ":" in 'iskeyword' for syntax.
- Also need a separate 'iskeyword' for the command line, e.g., in a help
- window ":e /asdf/asdf/" CTRL-W works different.
-8 Add specific syntax item to match with parens/braces that don't have a
- "%" match. :syntax nomatch cMatchError (,{,[,),},] [contained]
-8 Highlight the text between two matching parens (e.g., with a grey
- background) when on one of the parens or in between them.
- Option for the matchparen plugin?
-8 When using a cterm, and no ctermfg or ctermbg are defined, use start/stop
- sequences. Add remark in docs that :if 'term' == "term-name" should be
- used.
-8 Add @spell cluster to String and Comment groups for many languages. Will
- allow spell checking. (Fleiner)
-8 When listing syntax items, try to sort the keywords alphabetically. And
- re-insert the [] if possible.
-8 Make it possible to use color of text for Visual highlight group (like for
- the Cursor).
-8 It would be useful to make the highlight group name an expression. Then
- when there is a match, the expression would be evaluated to find out what
- highlight group to use. Could be used to check if the shell used in a
- password file appears in /etc/shells. (Nikolai Weibull)
- syn match =s:checkShell(v:match) contained 'pattern'
-8 Make it possible to only highlight a sub-expression of a match. Like
- using "\1" in a ":s" command.
-8 Support for deleting syntax items:
- :syn keyword cTodo remove this
- :syn match cTodo remove "pattern"
- :syn region cString remove start="this" end="that"
-8 Add possibility to sync on something else, when the syncing in one way
- doesn't find match. For HTML: When no {script} is found, try looking for
- a '<'. (Fleiner)
-7 Replace the synchronizing method with a state machine specification?
- Should be able to start at any line in the file, search forwards or
- backwards, and use the result of matching a pattern.
-7 Use parsing like awk, so that e.g., a ( without a matching ) can be
- detected.
-8 Make it possible to use "inverted" highlighting, invert the original
- character. For Visual mode. (xterm-selection already does this).
-8 Highlight non-printable characters with "SpecialChar", linked to
- "Special". Display them with the digraph characters, if possible.
-8 Highlight the clipboard-selection with a highlight group.
-8 Be able to reset highlighting to its original (default) values.
-7 Be able to write current highlighting to a file as commands, similar to
- ":mkvimrc".
-8 Improve c.vim:
- - Add check for unterminated strings, with a variable to switch it on:
- "c_strict_ansi".
- - Detect unbalanced "#endif". Requires looking back a long way...
-8 Add an option to restrict the updating of syntax highlighting to the
- current line while in Insert mode.
-8 When guessing value of 'background', the syntax file has already been
- loaded (from the .gvimrc). After changing 'background', load it again?
-8 Add ":syn resync" command, to re-parse the whole file until the current
- display position.
-8 Should support "me" offset for a region start pattern. To be used to
- allow searching for the end pattern inside the match of the end pattern.
- Example: syn region pikeXX start="([^{]" end=")" should work on "()".
-8 When using a regexp for "contains=", should delay matching with it until
- redrawing happens. Set a flag when a group is added, check this flag when
- highlighting starts.
-8 Some terminals can display colors like the GUI. Add some setting to use
- GUI colors for the terminal? With something to define the escape
- sequence.
-7 It's possible for an item to be transparent, so that the colors of an item
- lower on the stack is used. Also do this with highlighting, so that the
- user can set transparent highlighting? E.g. a number in a C comment would
- get the color of a comment, a number in an assignment Normal. (Nikolai
- Weibull)
-7 Add "semitrans": Add highlighting. E.g., make the text bold, but keep the
- colors. And add colors, so that Green+Red becomes Yellow.
- E.g. for this html:
- <B> bold text <I> italic+bold text </B> italic text </I>
-7 CTRL-] checks the highlight group for finding out what the tag is.
-7 Add an explanation how a list of words can be used to highlight misspelled
- words.
-8 Add more command line completion for :syntax.
-8 Add more command line completion for :highlight.
-7 Should find a better way to parse the :syntax and :highlight commands.
- Use tables or lists that can be shared by parsing for execution and
- completion?
-8 Add ColorSchemePost autocommand event, so that scripts can set up their
- highlighting. (Salman Halim)
-7 Add a few sets of colors (e.g. Borland Turbo C one). With a menu to
- select one of the sets.
-8 Add offsets to sub-matches: "\(a*\) *"he=e1-1
- 'e' is end of match 'e1' is end of sub-match 1, 's2' is start of submatch
- 2, etc.
-8 In Insert mode, when there are typeahead characters, postpone the
- highlighting (for "." command).
-8 Syncing on comments isn't 100% correct when / / lines mix with / * and * /.
- For example: What about a line that starts with / / and contains * /?
-8 Ignore / * and * / inside strings, when syncing.
-7 Build a few more syntax files from the file "/usr/share/misc/vgrindefs":
- ISP, LDL, Icon, ratfor. And check "nedit/source/highlight.c".
-6 Add possibility to have background color continue until the right edge of
- the window. Useful for comment blocks and function headings. (Rogall)
-- Make it possible to add "contains" items for all items in a group. Useful
- when extending an already existing syntax file.
-- Add line-continuation pattern for non-syncing items too?
-- Add possibility to highlight the whole line, including the right margin
- (for comment blocks).
-- Add 'hlmatch' option: List of flags:
- 'c': highlight match for character under the cursor.
- 'b': highlight the previous (, and its match.
- 'a': highlight all text from the previous ( until its match.
- Also for {}, <>, etc.?
- 'e': highlight all braces without a match (slow?)
- OR: add an argument "cursor" to the syntax command, which means that the
- region/match/keyword is only highlighted when the cursor is on it.
- (Campbell)
- Or do it like Elvis: define text objects and how to highlight them around
- the cursor. (Iain Truskett)
-7 Make it possible to use all words in the tags files as Keyword.
- Can also be done with a script (but it's slow).
-7 Make it possible to call a ":" command when a match is found. Should
- allow for adding keywords from the text (e.g. variables that are set).
- And allows for sections with different highlighting.
-7 Add highlight group for commandline: "Commandline". Make sure it
- highlights the command line while typing a command, and any output from
- messages. And external commands?
-8 Make a version that works like less, but with highlighting: read stdin for
- text, exit at end of file, don't allow editing, etc. moreim? lessim?
-7 SpecialKey highlighting overrules syntax highlighting. Can't give an
- unprintable char another color. Would be useful for ^M at end of line.
-
-
-Built-in script language:
-8 Make the filename and line number available to script functions, so that
- they can give useful debugging info. The whole call stack would be ideal.
- At least use this for error messages.
-7 Execute a function with standard option values. No need to save and
- restore option values. Especially useful for new options. Problem: how
- to avoid a performance penalty (esp. for string options)?
-8 Add referring to key options with "&t_xx". Both for "echo &t_xx" and
- ":let &t_xx =". Useful for making portable mappings.
-- Add ":let var ?= value", conditional assignment. Patch by Dave Eggum,
- 2006 Dec 11.
-- range for ":exec", pass it on to the executed command. (Webb)
-8 ":{range}source": source the lines from the current file.
- You can already yank lines and use :@" to execute them.
- Most of do_source() would not be used, need a new function.
- It's easy when not doing breakpoints or profiling.
- Requires copying the lines into a list and then creating a function to
- execute lines from the list. Similar to getnextac().
-7 ":include" command: just like ":source" but doesn't start a new scriptID?
- Will be tricky for the list of script names.
-8 Have a look at VSEL. Would it be useful to include? (Bigham)
-8 Add ":fungroup" command, to group function definitions together. When
- encountered, all functions in the group are removed. Suggest using an
- obscure name to avoid name clashes. Require a ":fungroup END" in the same
- sourced file? Assume the group ends at the end of the file. Handle
- nested packages?
- Alternative: Support packages. {package-name}:{function-name}().
- Packages are loaded automatically when first used, from
- $VIMRUNTIME/packages (or use a search path).
-7 Pre-parse or compile Vim scripts into a bytecode.
- 1. Put the bytecode with the original script, with an ":if
- has('bytecode')" around it, so that it's only used with a Vim that
- supports it. Update the code with a command, can be used in an
- autocommand.
- 2. Use a ".vic" file (like Python use .pyc). Create it when writing a
- .vim file. Problem: distribution.
- 3. Use a cache directory for each user. How to recognize which cached
- file belongs to a sourced script?
-7 Add argument to winwidth() to subtract the space taken by 'foldcolumn',
- signs and/or 'number'.
-6 Add ++ and -- operators? They only work on variables (lvals), how to
- implement this?
-8 Add functions:
- has(":command") Check if ":command" works. compare function
- with "ex_ni". E.g. for ":simalt".
- system() With a List argument. Bypasses the shell, use
- exec() directly. (Bob Hiestand)
- escape() Add argument to specify what to escape with.
- modestack() Instead of just the current mode return the
- stack of Insert / CTRL-O / :normal things.
- realname() Get user name (first, last, full)
- user_fullname() patch by Nikolai Weibull, Nov
- 3 2002
- Only add this when also implemented for
- non-Unix systems, otherwise a shell cmd could
- be used.
- get_user_name() gets login name.
- menuprop({name}, {idx}, {what})
- Get menu property of menu {name} item {idx}.
- menuprop("", 1, "name") returns "File".
- menuprop("File", 1, "n") returns "nmenu
- File.Open..." argument.
- Patch by Ilya Sher, 2004 Apr 22
- Return a list of menus and/or a dictionary
- with properties instead.
- mapname({idx}, mode) return the name of the idx'th mapping.
- Patch by Ilya Sher, 2004 Mar 4.
- Return a list instead.
- char2hex() convert char string to hex string.
- base64enc() base 64 encoding
- base64dec() base 64 decoding
- attributes() return file protection flags "drwxrwxrwx"
- filecopy(from, to) Copy a file
- shorten(fname) shorten a file name, like home_replace()
- perl(cmd) call Perl and return string
- inputrl() like input() but right-to-left
- typed() return the characters typed and consumed (to
- find out what happened)
- virtualmode() add argument to obtain whether "$" was used in
- Visual block mode.
- getacp() Win32: get codepage (Glenn Maynard)
- deletebufline() delete line in any buffer
- appendbufline() append line in any buffer
- libcall() Allow more than one argument.
- libcallext() Like libcall(), but using a callback function
- to allow the library to execute a command or
- evaluate an expression.
-7 Make bufname("'0") return the buffer name from mark '0. How to get the
- column and line number? col("'0") currently returns zero.
-8 argc() returns 0 when using "vim -t tag". How to detect that no file was
- specified in any way? To be able to jump to the last edited file.
-8 Pass the command line arguments to Vim scripts in some way. As v:args
- List? Or extra parameter to argv()?
-8 Add command arguments with three dashes, passed on to Vim scripts.
-7 Add optional arguments to user functions:
- :func myFunc(arg1, arg2, arg3 = "blah", arg4 = 17)
-6 User functions: Functions local to buffer "b:func()"?
-8 For Strings add ":let var[{expr}] = {expr}". When past the end of "var"
- just ignore.
-8 The "= register should be writable, if followed by the name of a variable,
- option or environment variable.
-8 ":let &option" should list the value of the option.
-8 ":let Func().foo = value" should work, also when "foo" doesn't exist.
- Also: ":let Func()[foo] = value" should work. Same for a List.
-7 Add synIDlist(), making the whole list of syntax items on the syntax stack
- available as a List.
-8 Add autocommand-event for when a variable is changed:
- :au VarChanged {varname} {commands}
-8 Add "has("gui_capable")", to check if the GUI can be started.
-8 Add possibility to use variables like registers: characterwise (default),
- linewise (when ending in '\n'), blockwise (when ending in '\001'). reg0,
- rega, reg%, etc. Add functions linewise({expr}), blockwise({expr}) and
- charwise({expr}).
-7 Make it possible to do any command on a string variable (make a buffer
- with one line, containing the string). Maybe add an (invisible) scratch
- buffer for this?
- result = scratch(string, command)
- result = apply(string, command)
- result = execute(string, command)
- "command" would use <> notation.
- Does scratch buffer have a number? Or re-use same number?
-7 Add function to generate unique number (date in milliseconds).
-
-
-Robustness:
-6 Add file locking. Lock a file when starting to edit it with flock() or
- fcntl(). This patch has advisory file locking while reading/writing
- the file for Vim 5.4: ~/vim/patches/kahn_file_locking .
- The patch is incomplete (needs support for more systems, autoconf).
- Andy doesn't have time to work on it.
- Disadvantage: Need to find ways to gracefully handle failure to obtain a
- lock. When to release a lock: When buffer is unloaded?
-
-
-Performance:
-7 For string variables up to 3 bytes don't allocate memory, use v_list
- itself as a character array. Use VAR_SSTRING (short string).
-7 Add 'lazysize' option: Above this size Vim doesn't load everything before
- starting to edit a file. Things like 'fileencodings' only work up to this
- size, modelines only work at the top. Useful for large log files where
- you only want to look at the first few pages. Use zero to disable it.
-8 move_lines() copies every line into allocated memory, making reloading a
- buffer a lot slower than re-editing the file. Can the memline be locked
- so that we don't need to make a copy? Or avoid invoking ml_updatechunk(),
- that is taking a lot of time. (Ralf Wildenhues, 2008 Jul 7)
- With a patch, but does it work?
-8 Instead of loading rgb.txt every time a color wasn't recognized load it
- once and keep it in memory. Move the code to a common place to avoid
- repeating it in various system files.
-8 Turn b_syn_ic and b_syn_containedin into b_syn_flags.
-9 Loading menu.vim still takes quite a bit of time. How to make it faster?
-8 in_id_list() takes much time for syntax highlighting. Cache the result?
-7 setpcmark() shifts the jumplist, this takes quite a bit of time when
- jumping around. Instead use an index for the start?
-8 When displaying a space with only foreground highlighting, it's the same
- as a space without attributes. Avoid displaying spaces for the "~" lines
- when starting up in a color terminal.
-8 Profiling shows that in_id_list() is used very often for C code. Can this
- function be improved?
-8 For an existing file, the page size of the swap file is always the
- default, instead of using the block size of the device, because the swap
- file is created only after setting the block size in mf_open(). How can
- this be improved?
-7 C syntax highlighting gets a lot slower after ":set foldmethod=syntax".
- (Charles Campbell) Inserting a "{" is very slow. (dman)
-7 HTML syntax highlighting is slow for long lines. Try displaying
- http://www.theregister.co.uk/content/4/22908.html. (Andre Pang)
-7 Check how performance of loading the wordlist can be improved (adding a
- lot of abbreviations).
-7 MS-DOS console: Add t_DL support, to make scrolling faster.
-7 Compile Ex commands to byte codes. Store byte codes in a vim script file
- at the end, after "compiled:. Make it look like a single comment line
- for old Vim versions. Insert first line "Vim script compiled <timestamp>.
- Only used compiled code when timestamp matches the file stat.
- Add command to compile a vim script and add it to the file in-place.
- Split Ex command executing into a parsing and executing phase.
- Use compiled code for functions, while loops, etc.
-8 When defining autocommands (e.g., from $VIMRUNTIME/filetype.vim), need to
- compare each pattern with all existing patterns. Use a hash code to avoid
- using strcmp() too often?
-7 Include turbo_loader patches, speeding up reading a file?
- Speed up reading a file by reading it into a fixed-size buffer, creating
- the list of indexes in another buffer, and then copying the result into a
- memfile block with two copies. Then read the next block into another
- fixed-size buffer, create the second list of indexes and copy text from
- the two blocks to the memfile block.
-7 do_cmdline(): Avoid that the command line is copied to allocated memory
- and freed again later all the time. For while loops, and for when called
- with an argument that can be messed with.
- Generic solution: Make a struct that contains a pointer and a flag that
- indicates if the pointer should be freed when replaced.
-7 Check that the file size is not more than "sizeof(long)".
-- Further improve finding mappings in maphash[] in vgetorpeek()
-8 Syntax highlighting is slow when deleting lines. Try in
- $VIMRUNTIME/filetype.vim.
-- "out of memory" after deleting (1,$d) and changing (:%s/^/> /) a lot of
- lines (27000) a few times. Memory fragmentation?
-- Have a look at how pdksh does memory allocation (alloc.c). (Dalecki)
-- Do profiling on:
- - :g/pat/normal cmd
- - 1000ii<Esc>
- - deleting 10Mbyte worth of lines (netscape binary)
- - "[i" and "[d" (Yegappan Lakshmanan)
- - ":g/^/m0" on a 450Kbyte file. And the "u".
- - highlighting "~/vim/test/longline.tex", "~/vim/test/scwoop.tcl" and
- "~/vim/test/lockup.pl".
- - loading a syntax file to highlight all words not from a dictionary.
- - editing a Vim script with syntax highlighting on (loading vim.vim).
-7 Screen updating can be further improved by only redrawing lines that were
- changed (and lines after them, when syntax highlighting was used, and it
- changed).
- - On each change, remember start and end of the change.
- - When inserting/deleting lines, remember begin, end, and line count.
-- Use macros/duarte/capicua for profiling. Nvi 1.71 is the fastest!
-- When using a file with one long line (1Mbyte), then do "$hhhh", is still
- very slow. Avoid calling getvcol() for each "h"?
-- Executing a register, e.g. "10000@@" is slow, because ins_typebuf has to
- move the previous commands forward each time. Pass count from
- normal_cmd() down to do_execreg().
-- Repeating insert "1000i-<Esc>" displays --INSERT-- all the time, because of
- the <Esc> at the end. Make this work faster (disable redrawing).
-- Avoid calls to plines() for cursor line, use w_cline_height.
-- After ":set nowrap" remove superfluous redraw with wrong hor. offset if
- cursor is right of the screen.
-8 Make CTRL-C on Unix generate a signal, avoid using select() to check for a
- CTRL-C (it's slow).
-
-
-Code size:
-8 GUI: When NO_CONSOLE is defined, more code can be excluded.
-- Put getline() and cookie in a struct, so only one argument has to be
- passed to do_cmdline() and other functions.
-8 Make a GUI-only version for Unix?
-8 In buf_write _() isn't needed when setting errmsg, do it once when using
- it.
-7 When compiling with a GUI-only version, the code for cterm colors can be
- left out.
-8 When compiled with a GUI-only version, the termcap entries for terminals
- can be removed.
-8 Can the check for libelf in configure.in be removed?
-
-
-Messages:
-8 When using ":q" in a changed file, the error says to "add !". Add the
- command so that beginners understand it: "use :q!".
-8 For 'verbose' level 12 prints commands from source'ed files. How to skip
- lines that aren't executed? Perhaps move the echoing to do_cmdline()?
-8 Use 'report' for ":bdel"? (Krishna) To avoid these messages when using a
- script.
-- Delete message after new command has been entered and have waited for key.
- Perhaps after ten seconds?
-- Make message history available in "msg" variables: msg1, msg2, .. msg9.
-8 When reading from stdin allow suppressing the "reading from stdin"
- message.
-9 Check handling of overwriting of messages and delays:
- Very wrong: errors while redrawing cause endless loop.
- When switching to another file and screen scrolls because of the long
- message and return must be typed, don't scroll the screen back before
- redrawing.
-8 When address range is wrong you only get "Invalid range". Be a bit more
- specific: Negative, beyond last line, reverse range? Include the text.
-8 Make it possible to ignore errors for a moment ('errorignore'?). Another
- option to switch off giving error messages ('errorquiet'?). Also an option
- not to give any messages ('quiet')? Or ":quiet on", ":quiet off".
- Careful: For a severe error (out of memory), and when the user starts
- typing, error messages must be switched back on.
- Also a flag to ignore error messages for shell commands (for mappings).
-- Option to set time for emsg() sleep. Interrupt sleep when key is typed?
- Sleep before second message?
-8 In Ex silent mode or when reading commands from a file, what exactly is
- not printed and what is? Check ":print", ":set all", ":args", ":vers",
- etc. At least there should be no prompt. (Smulders) And don't clear the
- screen when reading commands from stdin. (Kendall)
- --> Make a difference between informative messages, prompts, etc. and
- error messages, printing text, etc.
-8 Window should be redrawn when resizing at the hit-enter prompt.
- Also at the ":tselect" prompt. Find a generic solution for redrawing when
- a prompt is present (with a callback function?).
-
-
-Screen updating:
-7 Add a string to the 'display' option to make CTRL-E and CTRL-Y scroll one
- screen line, also if this means the first line doesn't start with the
- first character (like what happens with a single line that doesn't fit).
-- screen_line():
- - insert/delete character stuff.
- - improve delete rest of line (spaces at end of line).
-- When moving or resizing window, try to avoid a complete redraw (esp. when
- dragging the status line with the mouse).
-- When 'lazyredraw' set, don't echo :ex commands? Need a flag to redraw when
- waiting for a character.
-8 Add a ":refresh [winnr]" command, to force updating a window. Useful from
- an event handler where ":normal" can't be used. Also useful when
- 'lazyredraw' is set in a mapping.
-7 Make 'list' and 'linebreak' work together.
-
-
-Scrolling:
-8 Add "zy" command: scroll horizontally to put the cursor in the middle.
-6 Add option to set the overlap for CTRL-F and CTRL-B. (Garhi)
-- extend 'scrollbind' option: 'scrollopt' words "search", "relative", etc..
- Also 'e'xecute some commands (search, vertical movements) in all bound
- windows.
-7 Add 'scrollbind' feature to make the offset of one window with the next
- one equal to the window height. When editing one file in both windows it
- looks like each window displays a page of the buffer.
-- Allow scrolling by dragging with the mouse (grab a character and move it
- up/down). Like the "hand" in Acrobat reader. Use Alt-LeftMouse for this?
- (Goldfarb)
-- Add command to execute some commands (search, vertical movements) in all
- bound windows.
-- Add 'search' option to 'scrollopt' to allow 'scrollbind' windows to
- be bound by regexp searches
-- Add "z>" and "z<": scroll sideways one screenful. (Campbell)
-- Add option to set the number of lines when not to scroll, instead of the
- fixed number used now (for terminals that scroll slow with a large number
- of lines but not with a single line).
-
-
-Autoconf:
-8 Should use acconfig.h to define prototypes that are used by autoheader.
-8 Some compilers don't give an error for "-OPT:Olimit" but a warning. (Webb)
- Add a check for the warning, so that "Olimit" can be added automatically?
-- Autoconf: Use @datadir@ for the system independent files. Make sure the
- system dependent and system independent files are separated. (Leitner).
-- Add autoconf check for waitpid()/wait4().
-- Remove fcntl() from autoconf, all systems have it?
-- Set default for 'dictionary', add search for dictionary to autoconf.
-
-
-Perl interface:
-8 Rename typemap file to something else?
-7 Make buffers accessed as Perl arrays. (Clark)
-7 Make it possible to compile with non-ANSI C?
-6 Tcl/Tk has the "load" command: load a shared library (.so or .dll).
-
-
-Shared libraries:
-6 Add support for loading shared libraries, and calling functions in it.
- :libload internal-name libname
- :libunload internal-name
- :liblist
- :libcall internal-name function(arg1, arg2, ...)
- :libcall function(arg1, arg2, ...)
- libcall() can have only one integer or String argument at the moment.
-6 Have a look on how Perl handles loading dynamic libraries.
-
-
-Tags:
-9 With ":set tags=./tags,../tags" and a tag appears in both tags files it is
- added twice. Requires figuring out the actual file name for each found
- match. Remove tag_fname from the match and combine it with the fname in
- the match (without expanding or other things that take time). When
- 'tagrelative' is off tag_fname isn't needed at all.
-8 For 'tags' wildcard in the file name is not supported, only in the path.
- This is due to it using |file-searching|. Suboptimal solution would be to
- make the filename or the whole option use |wildcards| globing, better
- would be to merge the 2 kinds of globing. originally (Erik Falor, 2008
- April 18), updated (Ian Kelling, 2008 July 4)
-7 Can CTRL-] (jump to tag) include a following "." and "->" to restrict the
- number of possible matches? Check tags file for an item that has members.
- (Flemming Madsen)
-8 Scope arguments for ":tag", e.g.: ":tag class:cPage open", like Elvis.
-8 When output of ":tselect" is long, getting the more-prompt, should be able
- to type the tag number directly.
-7 Add the possibility to use the "-t {tag}" argument multiple times. Open a
- window for each tag.
-7 Make output of ":tselect" a bit nicer. Use highlighting?
-7 Highlight the "tag 1 of >2" message. New highlight group, or same as "hit
- bottom" search message.
-7 When using ":tag" at the top of the tag stack, should add another entry,
- so CTRL-T can bring you back to where you are now AND to where you were
- before the previous ":tag" command. (Webb)
-- When doing "[^I" or "[^D" add position to tag stack.
-- Add command to put current position to tag stack: ":tpush".
-- Add functions to save and restore the tag stack? Or a command to switch
- to another tag stack? So that you can do something else and come back to
- what you were working on.
-7 When using CTRL-] on someClass::someMethod, separate class from method and
- use ":ta class:someClass someMethod".
- Include C++ tags changes (Bertin). Change "class::func" tag into "func"
- with "class=class"? Docs in oldmail/bertin/in.xxx.
-7 Add ":tagargs", to set values for fields:
- :tagargs class:someclass file:version.c
- :tagargs clear
- These are then the default values (changes the order of priority in tag
- matching).
-7 Support for "gtags" and "global"? With ":rtag" command?
- There is an example for how to do this in Nvi.
- Or do it like Elvis: 'tagprg' and 'tagprgonce' options. (Yamaguchi)
- The Elvis method is far more flexible, do it that way.
-7 Support "col:99" extra field, to position the cursor in that column. With
- a flag in 'cpoptions' to switch it off again.
-7 Better support for jumping to where a function or variable is used. Use
- the id-utils, with a connection to "gid" (Emacs can do it too). Add
- ":idselect", which uses an "ID" database (made by "mkid") like "tselect".
-
-
-Autocommands:
-- Put autocommand event names in a hashtable for faster lookup?
-8 When the SwapExists event is triggered, provide information about the
- swap file, e.g., whether the process is running, file was modified, etc.
- Must be possible to check the situation that it's probably OK to delete
- the swap file. (Marc Merlin)
-8 When all the patterns for an event are "*" there is no need to expand
- buffer names to a full path. This can be slow for NFS.
-7 For autocommand events that trigger multiple times per buffer (e.g.,
- CursorHold), go through the list once and cache the result for a specific
- buffer. Invalidate the cache when adding/deleting autocommands or
- changing the buffer name.
-7 Add TagJump event: do something after jumping to a tag.
-8 Add "TagJumpFile" autocommand: When jumping to another file for a tag.
- Can be used to open "main.c.gz" when "main.c" isn't found.
-8 Use another option than 'updatetime' for the CursorHold event. The two
- things are unrelated for the user (but the implementation is more
- difficult).
-7 Add autocommand event for when a buffer cannot be abandoned. So that the
- user can define the action taking (autowrite, dialog, fail) based on the
- kind of file. (Yakov Lerner) Or is BufLeave sufficient?
-8 Autocommand for when modified files have been found, when getting input
- focus again (e.g., FileChangedFocus).
- Check when: getting focus, jumping to another buffer, ...
-7 Autocommand for when an option is changed. Match buffer name or option
- name?
-8 Autocommands should not change registers. And marks? And the jumplist?
- And anything else? Add a command to save and restore these things.
-8 Add autocommands, user functions and user commands to ":mkvimrc".
-6 Add KeymapChanged event, so that the effects of a different keymap can be
- handled (e.g., other font) (Ron Aaron)
-7 When trying to open a directory, trigger an OpenDirectory event.
-7 Add file type in front of file pattern: <d> for directory, <l> for link,
- <x> for executable, etc. With commas to separate alternatives. The
- autocommand is only executed when both the file type AND the file pattern
- match. (Leonard)
-5 Add option that specifies extensions which are to be discarded from the
- file name. E.g. 'ausuffix', with ".gz,.orig". Such that file.c.gz will
- trigger the "*.c" autocommands. (Belabas)
-7 Add something to break the autocommands for the current event, and for
- what follows. Useful for a "BufWritePre" that wants to avoid writing the
- file.
-8 When editing "tt.gz", which is in DOS format, 'fileformat' stays at
- "unix", thus writing the file changes it. Somehow detect that the read
- command used dos fileformat. Same for 'fileencoding'.
-- Add events to autocommands:
- Error - When an error happens
- NormalEnter - Entering Normal mode
- ReplaceEnter - Entering Replace mode
- CmdEnter - Entering Cmdline mode (with type of cmdline to allow
- different mapping)
- VisualEnter - Entering Visual mode
- *Leave - Leaving a mode (in pair with the above *Enter)
- VimLeaveCheck - Before Vim decides to exit, so that it can be cancelled
- when exiting isn't a good idea.
- CursorHoldC - CursorHold while command-line editing
- WinMoved - when windows have been moved around, e.g, ":wincmd J"
- SearchPost - After doing a search command (e.g. to do "M")
- PreDirChanged/PostDirChanged
- - Before/after ":cd" has been used (for changing the
- window title)
- ShutDown - when the system is about to shut down
- InsertCharPost - user typed a character in Insert mode, after inserting
- the char.
- BufModified - When a buffer becomes modified, or unmodified (for
- putting a [+] in the window title or checking out the
- file from CVS).
- BufFirstChange - When making a change, when 'modified' is set. Can be
- used to do a :preserve for remote files.
- BufChange - after a change was made. Set some variables to indicate
- the position and number of inserted/deleted lines, so
- that marks can be updated. HierAssist has patch to add
- BufChangePre, BufChangePost and RevertBuf. (Shah)
- ViewChanged - triggered when the text scrolls and when the window size
- changes.
- WinResized - After a window has been resized
- WinClose - Just before closing a window
-- Write the file now and then ('autosave'):
- *'autosave'* *'as'* *'noautosave'* *'noas'*
- 'autosave' 'as' number (default 0)
- Automatically write the current buffer to file N seconds after the
- last change has been made and when |'modified'| is still set.
- Default: 0 = do not autosave the buffer.
- Alternative: have 'autosave' use 'updatetime' and 'updatecount' but make
- them save the file itself besides the swapfile.
-
-
-Omni completion:
-- Add a flag to 'complete' to be able to do omni completion with CTRL-N (and
- mix it with other kinds of completion).
-- Ideas from the Vim 7 BOF at SANE:
- - For interpreted languages, use the interpreter to obtain information.
- Should work for Java (Eclipse does this), Python, Tcl, etc.
- Richard Emberson mentioned working on an interface to Java.
- - Check Readline for its completion interface.
-- Ideas from others:
- http://www.wholetomato.com/
- http://www.vim.org/scripts/script.php?script_id=747
- http://sourceforge.net/projects/insenvim
- or http://insenvim.sourceforge.net
- Java, XML, HTML, C++, JSP, SQL, C#
- MS-Windows only, lots of dependencies (e.g. Perl, Internet
- explorer), uses .dll shared libraries.
- For C++ uses $INCLUDE environment var.
- Uses Perl for C++.
- Uses ctags to find the info:
- ctags -f $allTagsFile --fields=+aiKmnsSz --language-force=C++ --C++-kinds=+cefgmnpsut-dlux -u $files
- www.vim.org script 1213 (Java Development Environment) (Fuchuan Wang)
- IComplete: http://www.vim.org/scripts/script.php?script_id=1265
- and http://stud4.tuwien.ac.at/~e0125672/icomplete/
- http://cedet.sourceforge.net/intellisense.shtml (for Emacs)
- Ivan Villanueva has something for Java.
- Emacs: http://www.xref-tech.com/xrefactory/more_c_completion.html
- Completion in .NET framework SharpDevelop: http://www.icsharpcode.net
-- Pre-expand abbreviations, show which abbrevs would match?
-
-
-Insert mode completion/expansion:
-7 When searching in other files the name flash by, too fast to read. Only
- display a name every second or so, like with ":vimgrep".
-7 When expanding file names with an environment variable, add the match with
- the unexpanded var. So $HOME/tm expands to "/home/guy/tmp" and
- "$HOME/tmp"
-8 When there is no word before the cursor but something like "sys." complete
- with "sys.". Works well for C and similar languages.
-9 ^X^L completion doesn't repeat correctly. It uses the first match with
- the last added line, instead of continuing where the last match ended.
- (Webb)
-8 Add option to set different behavior for Insert mode completion:
- - ignore/match case
- - different characters than 'iskeyword'
-8 Add option 'isexpand', containing characters when doing expansion (so that
- "." and "\" can be included, without changing 'iskeyword'). (Goldfarb)
- Also: 'istagword': characters used for CTRL-].
- When 'isexpand' or 'istagword' are empty, use 'iskeyword'.
- Alternative: Use a pattern so that start and end of a keyword can be
- defined, only allow dash in the middle, etc.
-8 Add a command to undo the completion, go back to the original text.
-7 Completion of an abbreviation: Can leave letters out, like what Instant
- text does: www.textware.com
-8 Use the class information in the tags file to do context-sensitive
- completion. After "foo." complete all member functions/variables of
- "foo". Need to search backwards for the class definition of foo.
- Should work for C++ and Java.
- Even more context would be nice: "import java.^N" -> "io", "lang", etc.
-7 When expanding $HOME/dir with ^X^F keep the $HOME (with an option?).
-7 Add CTRL-X command in Insert mode like CTRL-X CTRL-N, that completes WORDS
- instead of words.
-8 Add CTRL-X CTRL-R: complete words from register contents.
-8 Add completion of previously inserted texts (like what CTRL-A does).
- Requires remembering a number of insertions.
-8 Add 'f' flag to 'complete': Expand file names.
- Also apply 'complete' to whole line completion.
-- Add a flag to 'complete' to only scan local header files, not system
- header files. (Andri Moell)
-- Make it possible to search include files in several places. Use the
- 'path' option? Can this be done with the dictionary completion (use
- wildcards in the file name)?
-- Make CTRL-X CTRL-K do a binary search in the dictionary (if it's sorted).
-- Speed up CTRL-X CTRL-K dictionary searching (don't use a regexp?).
-- Set a mark at the position where the match was found (file mark, could
- be in another file).
-- Add CTRL-A command in CTRL-X mode: show all matches.
-- Make CTRL-X CTRL-L use the 'complete' option?
-- Add command in CTRL-X mode to add following words to the completed string
- (e.g. to complete "Pointer->element" with CTRL-X CTRL-P CTRL-W CTRL-W)
-- CTRL-X CTRL-F: Use 'path' to find completions.
-- CTRL-X CTRL-F: Option to use forward slashes on MS-Windows?
-- CTRL-X CTRL-F: Don't replace "$VIM" with the actual value. (Kelly)
-- Allow listing all matches in some way (and picking one from the list).
-
-
-Command line editing:
-7 Add commands (keys) to delete from the cursor to the end of the command
- line.
-8 Custom completion of user commands can't use the standard completion
- functions. Add a hook to invoke a user function that returns the type of
- completion to be done: "file", "tag", "custom", etc.
-- Add flags to 'whichwrap' for command line editing (cursor right at end of
- lines wraps to start of line).
-- Make editing the command line work like Insert mode in a single-line view
- on a buffer that contains the command line history. But this has many
- disadvantages, only implement it when these can be solved. Elvis has run
- into these, see remarks from Steve (~/Mail/oldmail/kirkendall/in.00012).
- - Going back in history and editing a line there would change the history.
- Would still need to keep a copy of the history elsewhere. Like the
- cmdwin does now already.
- - Use CTRL-O to execute one Normal mode command. How to switch to normal
- mode for more commands? <Esc> should cancel the command line. CTRL-T?
- - To allow "/" and "= need to recursively call getcmdline(), overwrite the
- cmdline. But then we are editing a command-line again. How to avoid
- that the user gets confused by the stack of command lines?
- - Use edit() for normal cmdline editing? Would have to integrate
- getcmdline() into edit(). Need to solve conflicts between Insert mode
- and Command-line mode commands. Make it work like Korn shell and tcsh.
- Problems:
- - Insert: completion with 'wildchar'
- - Insert: use cmdline abbreviations
- - Insert: CTRL-D deletes indent instead of listing matches
- - Normal: no CTRL-W commands
- - Normal: no ":" commands?
- - Normal: allow Visual mode only within one line.
- - where to show insert/normal mode message? Change highlighting of
- character in first column?
- - Implementation ideas:
- - Set "curwin" and "curbuf" to the command line window and buffer.
- - curwin->w_topline is always equal to curwin->w_cursor.lnum.
- - never set 'number', no folding, etc. No status line.
- - sync undo after entering a command line?
- - use NV_NOCL flag for commands that are not allowed in Command-line
- Mode.
-
-
-Command line completion:
-8 Change expand_interactively into a flag that is passed as an argument.
-8 With command line completion after '%' and '#', expand current/alternate
- file name, so it can be edited. Also with modifiers, such as "%:h".
-8 When completing command names, either sort them on the long name, or list
- them with the optional part inside [].
-8 Add an option to ignore case when doing interactive completion. So that
- ":e file<Tab>" also lists "Filelist" (sorted after matching case matches).
-7 Completion of ":map x ": fill in the current mapping, so that it can be
- edited. (Sven Guckes)
-- For 'wildmenu': Simplify "../bar" when possible.
-- When using <Up> in wildmenu mode for a submenu, should go back to the
- current menu, not the first one. E.g., ":emenu File.Save<Up>".
-8 When using backtick expansion, the external command may write a greeting
- message. Add an option or commands to remove lines that match a regexp?
-7 When listing matches of files, display the common path separately from the
- file names, if this makes the listing shorter. (Webb)
-- Add command line completion for ":ilist" and friends, show matching
- identifiers (Webb).
-8 Add command line completion for "old value" of a command. ":args <key>"
- would result in the current list of arguments, which you can then edit.
-7 Add command line completion with CTRL-X, just like Insert mode completion.
- Useful for ":s/word/xx/".
-- Add command to go back to the text as it was before completion started.
- Also to be used for <Up> in the command line.
-- Add 'wildlongest' option: Key to use to find longest common match for
- command line completion (default CTRL-L), like 'wildchar'. (Cregut)
- Also: when there are several matches, show them line a CTRL-D.
-
-
-Command line history:
-- Add "KeyWasTyped" flag: It's reset before each command and set when a
- character from the keyboard is consumed. Value is used to decide to put a
- command line in history or not. Put line in history if it didn't
- completely resulted from one mapping.
-- When using ":browse", also put the resulting edit command in the history,
- so that it can be repeated. (Demirel)
-
-
-Insert mode:
-9 When 'autoindent' is set, hitting <CR> twice, while there is text after
- the cursor, doesn't delete the autoindent in the resulting blank line.
- (Rich Wales) This is Vi compatible, but it looks like a bug.
-8 When using CTRL-O in Insert mode, then executing an insert command
- "a" or "i", should we return to Insert mode after <Esc>? (Eggink)
- Perhaps it can be allowed a single time, to be able to do
- "<C-O>10axyz<Esc>". Nesting this further is confusing.
- ":map <F2> 5aabc<Esc>" works only once from Insert mode.
-8 When using CTRL-G CTRL-O do like CTRL-\ CTRL-O, but when returning with
- the cursor in the same position and the text didn't change continue the
- same change, so that "." repeats the whole insert.
-7 Use CTRL-G <count> to repeat what follows. Useful for inserting a
- character multiple times or repeating CTRL-Y.
-- Make 'revins' work in Replace mode.
-9 Can't use multi-byte characters for 'matchpairs'.
-7 Use 'matchpairs' for 'showmatch': When inserting a character check if it
- appears in the rhs of 'matchpairs'.
-- In Insert mode (and command line editing?): Allow undo of the last typed
- character. This is useful for CTRL-U, CTRL-W, delete and backspace, and
- also for characters that wrap to the next line.
- Also: be able to undo CTRL-R (insert register).
- Possibly use 'backspace'="whole" for a mode where at least a <CR> that
- inserts autoindent is undone by a single <BS>.
-- Use CTRL-G in Insert mode for an extra range of commands, like "g" in
- Normal mode.
-- Make 'paste' work without resetting other options, but override their
- value. Avoids problems when changing files and modelines or autocommands
- are used.
-- When typing CTRL-V and a digit higher than 2, only expect two digits.
-- Insert binary numbers with CTRL-V b.
-- Make it possible to undo <BS>, <C-W> and <C-U>. Bash uses CTRL-Y.
-
-
-'cindent', 'smartindent':
-9 Wrapping a variable initialization should have extra indent:
- char * veryLongName =
- "very long string"
- Also check if "cino=+10" is used correctly.
-8 Lisp indenting: "\\" confuses the indenter. (Dorai Sitaram, 2006 May 17)
-8 Why are continuation lines outside of a {} block not indented? E.g.:
- long_type foo =
- value;
-8 Java: Inside an anonymous class, after an "else" or "try" the indent is
- too small. (Vincent Bergbauer)
- Problem of using {} inside (), 'cindent' doesn't work then.
-8 In C++ it's possible to have {} inside (): (Kirshna)
- func(
- new String[] {
- "asdf",
- "asdf"
- }
- );
-8 In C++ a function isn't recognized inside a namespace:
- (Chow Loong Jin)
- namespace {
- int
- func(int arg) {
- }
- }
-6 Add 'cino' flag for this function argument layout: (Spencer Collyer)
- func( arg1
- , arg2
- , arg3
- );
-7 Add separate "(0" option into inside/outside a function (Zellner):
- func(
- int x) // indent like "(4"
- {
- if (a
- && b) // indent like "(0"
-9 Using "{" in a comment: (Helmut Stiegler)
- if (a)
- {
- if (b)
- {
- // {
- }
- } <-- this is indented incorrect
- Problem is that find_start_brace() checks for the matching brace to be in
- a comment, but not braces in between. Requires adding a comment check to
- findmatchlimit().
-- Make smartindenting configurable. Add 'sioptions', e.g. '#' setting the
- indent to 0 should be switched on/off.
-7 Support ANSI style function header, with each argument on its own line.
-- "[p" and "]p" should use 'cindent' code if it's on (only for the first
- line).
-- Add option to 'cindent' to set indent for comments outside of {}?
-- Make a command to line up a comment after a code line with a previous
- comment after a code line. Can 'cindent' do this automatically?
-- When 'cindent'ing a '}', showmatch is done before fixing the indent. It
- looks better when the indent is fixed before the showmatch. (Webb)
-- Add option to make indenting work in comments too (for commented-out
- code), unless the line starts with "*".
-- Don't use 'cindent' when doing formatting with "gq"?
-- When formatting a comment after some text, insert the '*' for the new line
- (indent is correct if 'cindent' is set, but '*' doesn't get inserted).
-8 When 'comments' has both "s1:/*,mb:*,ex:*/" and "s1:(*,mb:*,ex:*)", the
- 'x' flag always uses the first match. Need to continue looking for more
- matches of "*" and remember all characters that could end the comment.
-- For smartindent: When typing 'else' line it up with matching 'if'.
-- 'smartindent': allow patterns in 'cinwords', for e.g. TeX files, where
- lines start with "\item".
-- Support this style of comments (with an option): (Brown)
- /* here is a comment that
- is just autoindented, and
- nothing else */
-- Add words to 'cinwords' to reduce the indent, e.g., "end" or "fi".
-7 Use Tabs for the indent of starting lines, pad with spaces for
- continuation lines. Allows changing 'tabstop' without messing up the
- indents.
- Patch by Lech Lorens, 2010 Mar. Update by James McCoy, 2014 Mar 15.
-
-
-Java:
-8 Can have {} constructs inside parens. Include changes from Steve
- Odendahl?
-8 Recognize "import java.util.Vector" and use $CLASSPATH to find files for
- "[i" commands and friends.
-- For files found with 'include': handle "*" in included name, for Java.
- (Jason)
-- How to make a "package java.util" cause all classes in the package to be
- searched? Also for "import java.util.*". (Mark Brophy)
-
-
-'comments':
-8 When formatting C comments that are after code, the "*" isn't repeated
- like it's done when there is no code. And there is no automatic wrapping.
- Recognize comments that come after code. Should insert the comment leader
- when it's "#" or "//".
- Other way around: when a C command starts with "* 4" the "*" is repeated
- while it should not. Use syntax HL comment recognition?
-7 When using "comments=fg:--", Vim inserts three spaces for a new line.
- When hitting a TAB, these spaces could be removed.
-7 The 'n'esting flag doesn't do the indenting of the last (rightmost) item.
-6 Make strings in 'comments' option a RE, to be able to match more
- complicated things. (Phillipps) Use a special flag to indicate that a
- regexp is used.
-8 Make the 'comments' option with "/* * */" lines only repeat the "*" line
- when there is a "/*" before it? Or include this in 'cindent'?
-
-
-Virtual edit:
-8 Make the horizontal scrollbar work to move the text further left.
-7 Allow specifying it separately for Tabs and beyond end-of-line?
-
-
-Text objects:
-8 Add text object for fold, so that it can be yanked when it's open.
-8 Add test script for text object commands "aw", "iW", etc.
-8 Add text object for part of a CamelHumpedWord and under_scored_word.
- (Scott Graham) "ac" and "au"?
-8 Add a text object for any kind of quoting, also with multi-byte
- characters. Option to specify what quotes are recognized (default: all)
- use "aq" and "iq". Use 'quotepairs' to define pairs of quotes, like
- 'matchpairs'?
-8 Add text object for any kind of parens, also multi-byte ones.
-7 Add text object for current search pattern: "a/" and "i/". Makes it
- possible to turn text highlighted for 'hlsearch' into a Visual area.
-8 Add a way to make an ":omap" for a user-defined text object. Requires
- changing the starting position in oap->start.
-8 Add "gp" and "gP" commands: insert text and make sure there is a single
- space before it, unless at the start of the line, and after it, unless at
- the end of the line or before a ".".
-7 Add objects with backwards extension? Use "I" and "A". Thus "2dAs"
- deletes the current and previous sentence. (Jens Paulus)
-7 Add "g{" and "g}" to move to the first/last character of a paragraph
- (instead of the line just before/after a paragraph as with "{" and "}").
-6 Ignore comment leaders for objects. Make "das" work in reply-email.
-5 Make it possible to use syntax group matches as a text object. For
- example, define a "ccItem" group, then do "da<ccItem>" to delete one.
- Or, maybe just define "dai", delete-an-item, to delete the syntax item the
- cursor is on.
-
-
-Select mode:
-8 In blockwise mode, typed characters are inserted in front of the block,
- backspace deletes a column before the block. (Steve Hall)
-7 Alt-leftmouse starts block mode selection in MS Word.
- See http://vim.wikia.com/wiki/Use_Alt-Mouse_to_select_blockwise.
-7 Add Cmdline-select mode. Like Select mode, but used on the command line.
- - Change gui_send_mouse_event() to pass on mouse events when 'mouse'
- contains 'C' or 'A'.
- - Catch mouse events in ex_getln.c. Also shift-cursor, etc., like in
- normal_cmd().
- - remember start and end of selection in cmdline_info.
- - Typing text replaces the selection.
-
-
-Visual mode:
-8 Support using "." in Visual mode. Use the operator applied to the Visual
- selection, if possible.
-- When dragging the Visual selection with the mouse and 'scrolloff' is zero,
- behave like 'scrolloff' is one, so that the text scrolls when the pointer
- is in the top line.
-- Displaying size of Visual area: use 24-33 column display.
- When selecting multiple lines, up to about a screenful, also count the
- characters.
-8 When using "I" or "A" in Visual block mode, short lines do not get the new
- text. Make it possible to add the text to short lines too, with padding
- where needed.
-7 With a Visual block selected, "2x" deletes a block of double the width,
- "3y" yanks a block of triple width, etc.
-7 When selecting linewise, using "itext" should insert "text" at the start
- of each selected line.
-8 What is "R" supposed to do in Visual mode?
-8 Make Visual mode local to the buffer. Allow changing to another buffer.
- When starting a new Visual selection, remove the Visual selection in any
- other buffer. (Ron Aaron)
-8 Support dragging the Visual area to drop it somewhere else. (Ron Aaron,
- Ben Godfrey)
-7 Support dragging the Visual area to drop it in another program, and
- receive dropped text from another program. (Ben Godfrey)
-7 With blockwise Visual mode and "c", "C", "I", "A", etc., allow the use of
- a <CR>. The entered lines are repeated over the Visual area.
-7 CTRL-V :s should substitute only in the block, not to whole lines. (David
- Young is working on this)
-7 Filtering a block should only apply to the block, not to the whole lines.
- When the number of lines is increased, add lines. When decreased, pad with
- spaces or delete? Use ":`<,`>" on the command line.
-8 After filtering the Visual area, make "gv" select the filtered text?
- Currently "gv" only selects a single line, not useful.
-7 Don't move the cursor when scrolling? Needed when the selection should
- stay the same. Scroll to the cursor at any movement command. With an
- option!
-7 In Visual block mode, need to be able to define a corner on a position
- that doesn't have text? Also: when using the mouse, be able to select
- part of a TAB. Even more: Add a mode where the cursor can be on a screen
- position where there is no text. When typing, add spaces to fill the gap.
- Other solution: Always use curswant, so that you can move the cursor to
- the right column, and then use up/down movements to select the line,
- without changing the column.
-6 ":left" and ":right" should work in Visual block mode.
-7 CTRL-I and CTRL-O should work in Visual mode, but only jump to marks in the
- current buffer.
-7 CTRL-A and CTRL-X should increase/decrease all numbers in the Visual area.
-6 In non-Block mode, "I" should insert the same text in front of each line,
- before the first non-blank, "gI" in column 1.
-6 In non-Block mode, "A" should append the same text after each line.
-6 When in blockwise visual selection (CTRL-V), allow cursor to be placed
- right of the line. Could also allow cursor to be placed anywhere on a TAB
- or other special character.
-6 Add commands to move selected text, without deselecting.
-
-
-More advanced repeating commands:
-- Add "." command for visual mode: redo last visual command (e.g. ":fmt").
-7 Repeating "d:{cmd}" with "." doesn't work. (Benji Fisher) Somehow remember
- the command line so that it can be repeated?
-- Add command to repeat last movement. Including count.
-- Add "." command after operator: repeat last command of same operator. E.g.
- "c." will repeat last change, also when "x" used since then (Webb).
- "y." will repeat last yank.
- "c2." will repeat the last but one change?
- Also: keep history of Normal mode commands, add command to list the history
- and/or pick an older command.
-- History stack for . command? Use "g." command.
-
-
-Mappings and Abbreviations:
-8 When "0" is mapped (it is a movement command) this mapping should not be
- used after typing another number, e.g. "20l". (Charles Campbell)
- Is this possible without disabling the mapping of the following command?
-8 Should mapping <C-A> and <C-S-A> both work?
-7 ":abbr b byte", append "b " to an existing word still expands to "byte".
- This is Vi compatible, but can we avoid it anyway?
-8 To make a mapping work with a prepended "x to select a register, store the
- last _typed_ register name and access it with "&.
-8 Add ":amap", like ":amenu".
-7 Add a mapping that works always, for remapping the keyboard.
-8 Add ":cab!", abbreviations that only apply to Command-line mode and not to
- entering search strings.
-8 Add a flag to ":abbrev" to eat the character that triggers the
- abbreviation. Thus "abb ab xxx" and typing "ab<Space>" inserts "xxx" and
- not the <Space>.
-8 Give a warning when using CTRL-C in the lhs of a mapping. It will never
- (?) work.
-8 Add a way to save a current mapping and restore it later. Use a function
- that returns the mapping command to restore it: mapcmd()? mapcheck() is
- not fool proof. How to handle ambiguous mappings?
-7 Add <0x8f> (hex), <033> (octal) and <123> (decimal) to <> notation?
-7 When someone tries to unmap with a trailing space, and it fails, try
- unmapping without the trailing space. Helps for ":unmap xx | unmap yy".
-6 Context-sensitive abbreviations: Specify syntax group(s) in which the
- abbreviations are to be used.
-- Add mappings that take arguments. Could work like the ":s" command. For
- example, for a mouse escape sequence:
- :mapexp <Esc>{\([0-9]*\),\([0-9]*\); H\1j\2l
-- Add optional <Number> argument for mappings:
- :map <Number>q ^W^W<Number>G
- :map <Number>q<Number>t ^W^W<Number1-1>G<Number2>l
- :map q<Char> :s/<Char>/\u\0/g
- Or implicit:
- :map q <Register>d<Number>$
-- Add command to repeat a whole mapping ("." only repeats the last change in
- a mapping). Also: Repeat a whole insert command, including any mappings
- that it included. Sort-of automatic recording?
-- Include an option (or flag to 'cpoptions') that makes errors in mappings
- not flush the rest of the mapping (like nvi does).
-- Use context sensitiveness of completion to switch abbreviations and
- mappings off for :unab and :unmap.
-6 When using mappings in Insert mode, insert characters for incomplete
- mappings first, then remove them again when a mapping matches. Avoids
- that characters that are the start of some mapping are not shown until you
- hit another character.
-- Add mappings for replace mode: ":rmap". How do we then enter mappings for
- non-replace Insert mode?
-- Add separate mappings for Visual-character/block/line mode?
-- Add 'mapstop' command, to stop recursive mappings.
-- List mappings that have a raw escape sequence both with the name of the key
- for that escape sequence (if there is one) and the sequence itself.
-- List mappings: Once with special keys listed as <>, once with meta chars as
- <M-a>, once with the byte values (octal?). Sort of "spell mapping" command?
-- When entering mappings: Add the possibility to enter meta keys like they
- are displayed, within <>: <M-a>, <~@> or <|a>.
-- Allow multiple arguments to :unmap.
-- Command to show keys that are not used and available for mapping
- ":freekeys".
-- Allow any character except white space in abbreviations lhs (Riehm).
-
-
-Incsearch:
-- Add a limit to the number of lines that are searched for 'incsearch'?
-- When no match is found and the user types more, the screen is redrawn
- anyway. Could skip that. Esp. if the line wraps and the text is scrolled
- up every time.
-- Temporarily open folds to show where the search ends up. Restore the
- folds when going to another line.
-- When incsearch used and hitting return, no need to search again in many
- cases, saves a lot of time in big files. (Slootman wants to work on this?)
- When not using special characters, can continue search from the last match
- (or not at all, when there was no match). See oldmail/webb/in.872.
-- With incsearch, use CTRL-N/CTRL-P to go to next/previous match, some other
- key to copy matched word to search pattern (Alexander Schmid).
-
-
-Searching:
-9 Should have an option for :vimgrep to find lines without a match.
-8 Add "g/" and "gb" to search for a pattern in the Visually selected text?
- "g?" is already used for rot13.
- The vis.vim script has a ":S" command that does something like this.
- Can use "g/" in Normal mode, uses the '< to '> area.
- Use "&/" for searching the text in the Visual area?
-9 Add "v" offset: "/pat/v": search for pattern and start Visual mode on the
- matching text.
-8 Add a modifier to interpret a space like "\_s\+" to make it much easier to
- search for a phrase.
-8 Add a mechanism for recursiveness: "\@(([^()]*\@g[^()]*)\)". \@g stands
- for "go recursive here" and \@( \) marks the recursive part.
- Perl does it this way:
- $paren = qr/ \(( [^()] | (??{ $paren }) )* \) /x;
- Here $paren is evaluated when it's encountered. This is like a regexp
- inside a regexp. In the above terms it would be:
- \@((\([^()]\|\@g\)*)\)
-8 Show the progress every second. Could use the code that checks for CTRL-C
- to find out how much time has passed. Or use SIGALRM. Where to show the
- number?
-8 When using an expression for ":s", set the match position in a v:
- variable. So that you can do ":%s/^/\=v:lnum/" to put a line number
- before each line.
-7 Support for approximate-regexps to find similar words (agrep
- http://www.tgries.de/agrep/ tre: http://laurikari.net/tre/index.html).
-8 Add an item for a big character range, so that one can search for a
- chinese character: \z[234-1234] or \z[XX-YY] or \z[0x23-0x234].
-7 Add an item stack to allow matching (). One side is "push X on
- the stack if previous atom matched". Other side is "match with top of
- stack, pop it when it matches". Use "\@pX" and "\@m"?
- Example: \((\@p).\{-}\@m\)*
-7 Add an option to accept a match at the cursor position. Also for
- search(). (Brett)
-7 Add a flag to "/pat/" to discard an error. Useful to continue a mapping
- when a search fails. Could be "/pat/E" (e is already used for end offset).
-7 Add pattern item to use properties of Unicode characters. In Perl it's
- "\p{L}" for a letter. See Regular Expression Pocket Reference.
-8 Would it be possible to allow ":23,45/pat/flags" to search for "pat" in
- lines 23 to 45? Or does this conflict with Ex range syntax?
-8 Allow identical pairs in 'matchpairs'. Restrict the search to the current
- line.
-7 Allow longer pairs in 'matchpairs'. Use ~/vim/macros/matchit.vim as an
- example.
-8 Make it possible to define the character that "%" checks for in
- #if/#endif. For nmake it's !if/!endif.
-- For "%" command: set hierarchy for which things include other things that
- should be ignored (like "*/" or "#endif" inside /* */).
- Also: use "%" to jump from start to end of syntax region and back.
- Alternative: use matchit.vim
-8 "/:/e+1" gets stuck on a match at the end of the line. Do we care?
-8 A pattern like "\([^a]\+\)\+" takes an awful long time. Recognize that
- the recursive "\+" is meaningless and optimize for it.
- This one is also very slow on "/* some comment */": "^\/\*\(.*[^/]\)*$".
-7 Recognize "[a-z]", "[0-9]", etc. and replace them with the faster "\l" and
- "\d".
-7 Add a way to specify characters in <C-M> or <Key> form. Could be
- \%<C-M>.
-8 Add an argument after ":s/pat/str/" for a range of matches. For example,
- ":s/pat/str/#3-4" to replace only the third and fourth "pat" in a line.
-8 When 'iskeyword' is changed the matches from 'hlsearch' may change. (Benji
- Fisher) redraw if some options are set while 'hlsearch' is set?
-8 Add an option not to use 'hlsearch' highlighting for ":s" and ":g"
- commands. (Kahn) It would work like ":noh" is used after that command.
- Also: An extra flag to do this once, and a flag to keep the existing
- search pattern.
-- Make 'hlsearch' a local/global option, so that it can be disabled in some
- of the windows.
-- Add \%h{group-name}; to search for a specific highlight group.
- Add \%s{syntax-group}; to search for a specific syntax group.
-- Support Perl regexp. Use PCRE (Perl Compatible RE) package. (Shade)
- Or translate the pattern to a Vim one.
- Don't switch on with an option for typed commands/mappings/functions, it's
- too confusing. Use "\@@" in the pattern, to avoid incompatibilities.
-8 Add a way to access the last substitute text, what is used for ":s//~/".
- Can't use the ~ register, it's already used for drag & drop.
-- Remember flags for backreferenced items, so that "*" can be used after it.
- Check with "\(\S\)\1\{3}". (Hemmerling)
-8 Flags that apply to the whole pattern.
- This works for all places where a regexp is used.
- Add "\q" to not store this pattern as the last search pattern?
-- Add flags to search command (also for ":s"?):
- i ignore case
- I use case
- p use Perl regexp syntax (or POSIX?)
- v use Vi regexp syntax
- f forget pattern, don't keep it for "n" command
- F remember pattern, keep it for "n" command
- Perl uses these too:
- e evaluate the right side as an expression (Perl only)
- m multiple line expression (we don't need it)
- o compile only once (Perl only)
- s single line expression (we don't need it)
- x extended regexp (we don't need it)
- When used after ":g" command, backslash needed to avoid confusion with the
- following command.
- Add 'searchflags' for default flags (replaces 'gdefault').
-- Add command to display the last used substitute pattern and last used
- pattern. (Margo) Maybe make it accessible through a register (like "/
- for search string)?
-7 Use T-search algorithm, to speed up searching for strings without special
- characters. See C't article, August 1997.
-- Add 'fuzzycase' option, so that case doesn't matter, and '-' and '_' are
- equivalent (for Unix filenames).
-- Add 'v' flag to search command: enter Visual mode, with the matching text
- as Visual area. (variation on idea from Bertin)
-- Searching: "/this//that/" should find "that" after "this".
-- Add global search commands: Instead of wrapping at the end of the buffer,
- they continue in another buffer. Use flag after search pattern:
- a for the next file in the argument list
- f for file in the buffer list
- w for file edited in a window.
- e.g. "/pat/f". Then "n" and "N" work through files too. "f" flag also for
- ":s/pat/foo/f"??? Then when 'autowrite' and 'hidden' are both not set, ask
- before saving files: "Save modified buffer "/path/file"? (Yes/Hide/No
- Save-all/hide-All/Quit) ".
-- ":s/pat/foo/3": find 3rd match of "pat", like sed. (Thomas Koehler)
-7 When searching with 'n' give message when getting back where the search
- first started. Remember start of search in '/ mark.
-7 Add option that scrolls screen to put cursor in middle of screen after
- search always/when off-screen/never. And after a ":tag" command. Maybe
- specify how many lines below the screen causes a redraw with the cursor in
- the middle (default would be half a screen, zero means always).
-6 Support multiple search buffers, so macros can be made without side
- effects.
-7 From xvim: Allow a newline in search patterns (also for :s, can delete
- newline). Add BOW, EOW, NEWL, NLORANY, NLBUTANY, magic 'n' and 'r', etc.
- [not in xvim:] Add option to switch on matches crossing ONE line boundary.
-7 Add ":iselect", a combination of ":ilist" and ":tselect". (Aaron) (Zellner)
- Also ":dselect".
-
-
-Undo:
-9 ":gundo" command: global undo. Undoes changes spread over multiple files
- in the order they were made. Also ":gredo". Both with a count. Useful
- when tests fail after making changes and you forgot in which files.
-9 After undo/redo, in the message show whether the buffer is modified or
- not.
-8 Use timestamps for undo, so that a version a certain time ago can be found
- and info before some time/date can be flushed. 'undopersist' gives maximum
- time to keep undo: "3h", "1d", "2w", "1y", etc.
-8 Search for pattern in undo tree, showing when it happened and the text
- state, so that you can jump to it.
-8 Undo tree: visually show the tree somehow (Damian Conway)
- Show only the leaves, indicating how many changed from the branch and the
- timestamp?
- Put branch with most recent change on the left, older changes get more
- indent?
-8 See ":e" as a change operation, find the changes and add them to the
- undo info. Also be able to undo the "Reload file" choice for when a file
- was changed outside of Vim.
- Would require doing a diff between the buffer text and the file and
- storing the differences.
- Alternative: before reloading a buffer, store it somewhere. Keep a list
- of about 10 last reloaded buffers.
-- Make it possible to undo all the commands from a mapping, including a
- trailing unfinished command, e.g. for ":map K iX^[r".
-- When accidentally hitting "R" instead of Ctrl-R, further Ctrl-R is not
- possible, even when typing <Esc> immediately. (Grahn) Also for "i", "a",
- etc. Postpone saving for undo until something is really inserted?
-8 When Inserting a lot of text, it can only be undone as a whole. Make undo
- sync points at every line or word. Could recognize the start of a new
- word (white space and then non-white space) and backspacing.
- Can already use CTRL-G u, but that requires remapping a lot of things.
-8 Make undo more memory-efficient: Compare text before and after change,
- only remember the lines that really changed.
-7 Add undo for a range of lines. Can change these back to a previous
- version without changing the rest of the file. Stop doing this when a
- change includes only some of these lines and changes the line count. Need
- to store these undo actions as a separate change that can be undone.
-- For u_save() include the column number. This can be used to set '[ and '].
- And in the future the undo can be made more efficient (Webb).
-- In out-of-memory situations: Free allocated space in undo, and reduce the
- number of undo levels (with confirmation).
-- Instead of [+], give the number of changes since the last write: [+123].
- When undoing to before the last write, change this to a negative number:
- [-99].
-- With undo with simple line delete/insert: optimize screen updating.
-- When executing macro's: Save each line for undo only once.
-- When doing a global substitute, causing almost all lines to be changed,
- undo info becomes very big. Put undo info in swap file??
-
-
-Buffer list:
-7 Command to execute a command in another buffer: ":inbuf {bufname} {cmd}".
- Also for other windows: ":inwin {winnr} {cmd}". How to make sure that
- this works properly for all commands, and still be able to return to the
- current buffer/window? E.g.: ":inbuf xxx only".
-8 Add File.{recent_files} menu entries: Recently edited files.
- Ron Aaron has a plugin for this: mru.vim.
-8 Unix: Check all uses of fnamecmp() and fnamencmp() if they should check
- inode too.
-7 Add another number for a buffer, which is visible for the user. When
- creating a new buffer, use the lowest number not in use (or the highest
- number in use plus one?).
-7 Offer some buffer selection from the command line? Like using ":ls" and
- asking for a buffer number. (Zachmann)
-- When starting to edit a file that is already in the buffer list, use the
- file name argument for the new short file name. (Webb)
-- Add an option to make ":bnext" and ":bprev" wrap around the end of the
- buffer list. Also for ":next" and ":prev"?
-7 Add argument to ":ls" which is a pattern for buffers to list.
- E.g. ":ls *.c". (Thompson)
-7 Add expansion of buffer names, so that "*.c" is expanded to all buffer
- names. Needed for ":bdel *.c", ":bunload *.c", etc.
-8 Support for <afile> where a buffer name is expected.
-8 Some commands don't use line numbers, but buffer numbers. '$'
- should then mean the number of the last buffer. E.g.: "4,$bdel".
-7 Add an option to mostly use slashes in file names. Separately for
- internal use and for when executing an external program?
-8 Some file systems are case-sensitive, some are not. Besides
- 'wildignorecase' there might be more parts inside
- CASE_INSENSITIVE_FILENAME that are useful on Unix.
-
-
-Swap (.swp) files:
-8 If writing to the swap file fails, should try to open one in another
- directory from 'dir'. Useful in case the file system is full and when
- there are short file name problems.
-8 Also use the code to try using a short file name for the backup and swap
- file for the Win32 and Dos 32 bit versions.
-8 When a file is edited by root, add $LOGNAME to know who did su.
-8 When the edited file is a symlink, try to put the swap file in the same
- dir as the actual file. Adjust FullName(). Avoids editing the same file
- twice (e.g. when using quickfix). Also try to make the name of the backup
- file the same as the actual file?
- Use the code for resolve()?
-7 When using 64 bit inode numbers, also store the top 32 bits. Add another
- field for this, using part of bo_fname[], to keep it compatible.
-7 When editing a file on removable media, should put swap file somewhere
- else. Use something like 'r' flag in 'viminfo'. 'diravoid'?
- Also: Be able to specify minimum disk space, skip directory when not
- enough room.
-7 Add a configure check for which directory should be used: /tmp, /var/tmp
- or /var/preserve.
-- Add an option to create a swap file only when making the first change to
- the buffer. (Liang) Or only when the buffer is not read-only.
-- Add option to set "umask" for backup files and swap files (Antwerpen).
- 'backupumask' and 'swapumask'? Or 'umaskback' and 'umaskswap'?
-- When editing a readonly file, don't use a swap file but read parts from the
- original file. Also do this when the file is huge (>'maxmem'). We do
- need to load the file once to count the number of lines? Perhaps keep a
- cached list of which line is where.
-
-
-Viminfo:
-7 Can probably remove the code that checks for a writable viminfo file,
- because we now do the chown() for root, and others can't overwrite someone
- else's viminfo file.
-8 When there is no .viminfo file and someone does "su", runs Vim, a
- root-owned .viminfo file is created. Is there a good way to avoid this?
- Perhaps check the owner of the directory. Only when root?
-8 Add argument to keep the list of buffers when Vim is started with a file
- name. (Schild)
-8 Keep the last used directory of the file browser (File/Open menu).
-8 Remember the last used register for "@@".
-8 Remember the redo buffer, so that "." works after restarting.
-8 Remember a list of last accessed files. To be used in the
- "File.Open Recent" menu. Default is to remember 10 files or so.
- Also remember which files have been read and written. How to display
- this?
-7 Also store the ". register (last inserted text).
-7 Make it possible to store buffer names in viminfo file relative to some
- directory, to make them portable over a network. (Aaron)
-6 Store a snapshot of the currently opened windows. So that when quitting
- Vim, and then starting again (without a file name argument), you see the
- same files in the windows. Use ":mksession" code?
-- Make marks present in .viminfo usable as file marks: Display a list of
- "last visited files" and select one to jump to.
-
-
-Modelines:
-8 Before trying to execute a modeline, check that it looks like one (valid
- option names). If it's very wrong, silently ignore it.
- Ignore a line that starts with "Subject: ".
-- Add an option to whitelist options that are allowed in a modeline. This
- would allow careful users to use modelines, e.g., only allowing
- 'shiftwidth'.
-- Add an option to let modelines only set local options, not global ones
- such as 'encoding'.
-- When an option value is coming from a modeline, do not carry it over to
- another edited file? Would need to remember the value from before the
- modeline setting.
-- Allow setting a variable from a modeline? Only allow using fixed strings,
- no function calls, to avoid a security problem.
-- Allow ":doauto BufRead x.cpp" in modelines, to execute autocommands for
- .cpp files.
-- Support the "abbreviate" command in modelines (Kearns). Careful for
- characters after <Esc>, that is a security leak.
-- Add option setting to ask user if he wants to have the modelines executed
- or not. Same for .exrc in local dir.
-
-
-Sessions:
-8 DOS/Windows: ":mksession" generates a "cd" command where "aa\#bb" means
- directory "#bb" in "aa", but it's used as "aa#bb". (Ronald Hoellwarth)
-7 When there is a "help.txt" window in a session file, restoring that
- session will not get the "LOCAL ADDITIONS" back.
-8 With ":mksession" always store the 'sessionoptions' option, even when
- "options" isn't in it. (St-Amant)
-8 When using ":mksession", also store a command to reset all options to
- their default value, before setting the options that are not at their
- default value.
-7 With ":mksession" also store the tag stack and jump history. (Michal
- Malecki)
-7 Persistent variables: "p:var"; stored in viminfo file and sessions files.
-
-
-Options:
-7 ":with option=value | command": temporarily set an option value and
- restore it after the command has executed.
-8 Make "old" number options that really give a number of effects into string
- options that are a comma separated list. The old number values should
- also be supported.
-8 Add commands to save and restore an option, which also preserves the flag
- that marks if the option was set. Useful to keep the effect of setting
- 'compatible' after ":syntax on" has been used.
-7 There is 'titleold', why is there no 'iconold'? (Chazelas)
-7 Make 'scrolloff' a global-local option, so that it can be different in the
- quickfix window, for example. (Gary Holloway)
- Also do 'sidescrolloff'.
-
-
-External commands:
-8 When filtering text, redirect stderr so that it can't mess up the screen
- and Vim doesn't need to redraw it. Also for ":r !cmd".
-4 Set separate shell for ":sh", piping "range!filter", reading text "r !ls"
- and writing text "w !wc". (Deutsche) Allow arguments for fast start (e.g.
- -f).
-4 Allow direct execution, without using a shell.
-4 Run an external command in the background. But how about I/O in the GUI?
- Careful: don't turn Vim into a shell!
-4 Add feature to disable using a shell or external commands.
-
-
-Multiple Windows:
-7 "vim -oO file ..." use both horizontal and vertical splits.
-8 Add CTRL-W T: go to the top window in the column of the current window.
- And CTRL-W B: go to bottom window.
-7 Use CTRL-W <Tab>, like alt-tab, to switch between buffers. Repeat <Tab>
- to select another buffer (only loaded ones?), <BS> to go back, <Enter> to
- select buffer, <Esc> to go back to original buffer.
-7 Make it possible to edit a new buffer in the preview window. A script can
- then fill it with something. ":popen"?
-7 Add a 'tool' window: behaves like a preview window but there can be
- several. Don't count it in only_one_window(). (Alexei Alexandrov)
-6 Add an option to resize the shell when splitting and/or closing a window.
- ":vsp" would make the shell wider by as many columns as needed for the new
- window. Specify a maximum size (or use the screen size). ":close" would
- shrink the shell by as many columns as come available. (Demirel)
-7 When starting Vim several times, instantiate a Vim server, that allows
- communication between the different Vims. Feels like one Vim running with
- multiple top-level windows. Esp. useful when Vim is started from an IDE
- too. Requires some form of inter process communication.
-- Support a connection to an external viewer. Could call the viewer
- automatically after some seconds of non-activity, or with a command.
- Allow some way of reporting scrolling and cursor positioning in the viewer
- to Vim, so that the link between the viewed and edited text can be made.
-
-
-Marks:
-8 Add ten marks for last changed files: ':0, ':1, etc. One mark per file.
-8 When cursor is first moved because of scrolling, set a mark at this
- position. (Rimon Barr) Use '-.
-8 Add a command to jump to a mark and make the motion inclusive. g'm and g`m?
-8 The '" mark is set to the first line, even when doing ":next" a few times.
- Only set the '" mark when the cursor was really moved in a file.
-8 Make `` and '', which would position the new cursor position in the middle
- of the window, restore the old topline (or relative position) from when
- the mark was set.
-7 Make a list of file marks in a separate window. For listing all buffers,
- matching tags, errors, etc. Normal commands to move around. Add commands
- to jump to the mark (in current window or new window). Start it with
- ":browse marks"?
-6 Add a menu that lists the Marks like ":marks". (Amerige)
-7 For ":jumps", ":tags" and ":marks", for not loaded buffers, remember the
- text at the mark. Highlight the column with the mark.
-7 Highlight each mark in some way (With "Mark" highlight group).
- Or display marks in a separate column, like 'number' does.
-7 Use d"m to delete rectangular area from cursor to mark m (like Vile's \m
- command).
-7 Try to keep marks in the same position when:
- - replacing with a line break, like in ":s/pat/^M/", move marks after the
- line break column to the next line. (Acevedo)
- - inserting/deleting characters in a line.
-5 Include marks for start/end of the current word and section. Useful in
- mappings.
-6 Add "unnamed mark" feature: Like marks for the ":g" command, but place and
- unplace them with commands before doing something with the lines.
- Highlight the marked lines somehow.
-
-
-Digraphs:
-7 Make "ga" show the keymap for a character, if it exists.
- Also show the code of the character after conversion to 'fileencoding'.
-- Use digraph table to tell Vim about the collating sequence of special
- characters?
-8 Add command to remove one or more (all) digraphs. (Brown)
-7 Support different sets of digraphs (depending on the character set?). At
- least Latin1/Unicode, Latin-2, MS-DOS (esp. for Win32).
-
-
-Writing files:
-- In vim_rename(), should lock "from" file when deleting "to" file.
-8 When appending to a file, Vim should also make a backup and a 'patchmode'
- file.
-8 'backupskip' doesn't write a backup file at all, a bit dangerous for some
- applications. Add 'backupelsewhere' to write a backup file in another
- directory? Or add a flag to 'backupdir'?
-6 Add an option to write a new, numbered, backup file each time. Like
- 'patchmode', e.g., 'backupmode'.
-6 Make it possible to write 'patchmode' files to a different directory.
- E.g., ":set patchmode=~/backups/*.orig". (Thomas)
-6 Add an option to prepend something to the backup file name. E.g., "#".
- Or maybe allow a function to modify the backup file name?
-8 Only make a backup when overwriting a file for the first time. Avoids
- losing the original when writing twice. (Slootman)
-7 On non-Unix machines, also overwrite the original file in some situations
- (file system full, it's a link on an NFS partition).
-7 When editing a file, check that it has been change outside of Vim more
- often, not only when writing over it. E.g., at the time the swap file is
- flushed. Or every ten seconds or so (use the time of day, check it before
- waiting for a character to be typed).
-8 When a file was changed since editing started, show this in the status
- line of the window, like "[time]".
- Make it easier to reload all outdated files that don't have changes.
- Automatic and/or with a command.
-
-
-Substitute:
-8 Substitute with hex/unicode number "\%xff" and "\%uabcd". Just like
- "\%uabcd" in search pattern.
-8 Make it easier to replace in all files in the argument list. E.g.:
- ":argsub/oldword/newword/". Works like ":argdo %s/oldword/newword/g|w".
-- :s///p prints the line after a substitution.
-- With :s///c replace \&, ~, etc. when showing the replacement pattern.
-8 With :s///c allow scrolling horizontally when 'nowrap' is effective.
- Also allow a count before the scrolling keys.
-- Add number option to ":s//2": replace second occurrence of string? Or:
- :s///N substitutes N times.
-- Add answers to ":substitute" with 'c' flag, used in a ":global", e.g.:
- ":g/pat1/s/pat2/pat3/cg": 'A' do all remaining replacements, 'Q' don't do
- any replacements, 'u' undo last substitution.
-7 Substitute in a block of text. Use {line}.{column} notation in an Ex
- range, e.g.: ":1.3,$.5s" means to substitute from line 1 column 3 to the
- last line column 5.
-5 Add commands to bookmark lines, display bookmarks, remove bookmarks,
- operate on lines with bookmarks, etc. Like ":global" but with the
- possibility to keep the bookmarks and use them with several commands.
- (Stanislav Sitar)
-
-
-Mouse support:
-8 Add 'o' flag to 'mouse'?
-7 Be able to set a 'mouseshape' for the popup menu.
-8 Add 'mouse' flag, which sets a behavior like Visual mode, but automatic
- yanking at the button-up event. Or like Select mode, but typing gets you
- out of Select mode, instead of replacing the text. (Bhaskar)
-- Using right mouse button to extend a blockwise selection should attach to
- the nearest corner of the rectangle (four possible corners).
-- Precede mouse click by a number to simulate double clicks?!?
-- When mouse click after 'r' command, get character that was pointed to.
-
-
-Argument list:
-6 Add command to put all filenames from the tag files in the argument list.
- When given an argument, only use the files where that argument matches
- (like `grep -l ident`) and jump to the first match.
-6 Add command to form an args list from all the buffers?
-
-
-Registers:
-8 Don't display empty registers with ":display". (Etienne)
-8 Add put command that overwrites existing text. Should also work for
- blocks. Useful to move text around in a table. Works like using "R ^R r"
- for every line.
-6 When yanking into the unnamed registers several times, somehow make the
- previous contents also available (like it's done for deleting). What
- register names to use? g"1, g"2, etc.?
-- When appending to a register, also report the total resulting number of
- lines. Or just say "99 more lines yanked", add the "more".
-- When inserting a register in Insert mode with CTRL-R, don't insert comment
- leader when line wraps?
-- The ":@r" commands should take a range and execute the register for each
- line in the range.
-- Add "P" command to insert contents of unnamed register, move selected text
- to position of previous deleted (to swap foo and bar in " + foo")
-8 Should be able to yank and delete into the "/ register.
- How to take care of the flags (offset, magic)?
-
-
-Debug mode:
-7 Add something to enable debugging when a remote message is received.
-8 Add breakpoints for setting an option
-8 Add breakpoints for assigning to a variable.
-7 Add a watchpoint in the debug mode: An expression that breaks execution
- when evaluating to non-zero. Add the "watchadd expr" command, stop when
- the value of the expression changes. ":watchdel" deletes an item,
- ":watchlist" lists the items. (Charles Campbell)
-7 Store the history from debug mode in viminfo.
-7 Make the debug mode history available with histget() et al.
-
-
-Various improvements:
-7 Add plugins for formatting? Should be able to make a choice depending on
- the language of a file (English/Korean/Japanese/etc.).
- Setting the 'langformat' option to "chinese" would load the
- "format/chinese.vim" plugin.
- The plugin would set 'formatexpr' and define the function being called.
- Edward L. Fox explains how it should be done for most Asian languages.
- (2005 Nov 24)
- Alternative: patch for utf-8 line breaking. (Yongwei Wu, 2008 Feb 23)
-7 [t to move to previous xml/html tag (like "vatov"), ]t to move to next
- ("vatv").
-7 [< to move to previous xml/html tag, e.g., previous <li>. ]< to move to
- next <li>, ]< to next </li>, [< to previous </li>.
-8 Add ":rename" command: rename the file of the current buffer and rename
- the buffer. Buffer may be modified.
-7 Instead of filtering errors with a shell script it should be possible to
- do this with Vim script. A function that filters the raw text that comes
- from the 'makeprg'?
-- Add %b to 'errorformat': buffer number. (Yegappan Lakshmanan / Suresh
- Govindachar)
-7 Add a command that goes back to the position from before jumping to the
- first quickfix location. ":cbefore"?
-7 Allow a window not to have a statusline. Makes it possible to use a
- window as a buffer-tab selection.
-8 Allow non-active windows to have a different statusline. (Yakov Lerner)
-7 Support using ":vert" with User commands. Add expandable items <vert>.
- Do the same for ":browse" and ":confirm"?
- For ":silent" and ":debug" apply to the whole user command.
- More general: need a way to access command modifiers in a user command.
- Assign them to a v: variable?
-7 Add an invisible buffer which can be edited. For use in scripts that want
- to manipulate text without changing the window layout.
-8 Add a command to revert to the saved version of file; undo or redo until
- all changes are gone.
-6 "vim -q -" should read the list of errors from stdin. (Gautam Mudunuri)
-8 Add "--remote-fail": When contacting the server fails, exit Vim.
- Add "--remote-self": When contacting the server fails, do it in this Vim.
- Overrules the default of "--remote-send" to fail and "--remote" to do it
- in this Vim.
-8 When Vim was started without a server, make it possible to start one, as
- if the "--servername" argument was given. ":startserver <name>"?
-8 No address range can be used before the command modifiers. This makes
- them difficult to use in a menu for Visual mode. Accept the range and
- have it apply to the following command.
-8 Add the possibility to set 'fileformats' to force a format and strip other
- CR characters. For example, for "dos" files remove CR characters at the
- end of the line, so that a file with mixed line endings is cleaned up.
- To just not display the CR characters: Add a flag to 'display'?
-7 Some compilers give error messages in which the file name does not have a
- path. Be able to specify that 'path' is used for these files.
-7 Xterm sends <Esc>O3F for <M-End>. Similarly for other <M-Home>, <M-Left>,
- etc. Combinations of Alt, Ctrl and Shift are also possible. Recognize
- these to avoid inserting the raw byte sequence, handle like the key
- without modifier (unless mapped).
-6 Add "gG": like what "gj" is to "j": go to the N'th window line.
-8 Add command like ":normal" that accepts <Key> notation like ":map".
-9 Support ACLs on more systems.
-7 Add ModeMsgVisual, ModeMsgInsert, etc. so that each mode message can be
- highlighted differently.
-7 Add a message area for the user. Set some option to reserve space (above
- the command line?). Use an ":echouser" command to display the message
- (truncated to fit in the space).
-7 Add %s to 'keywordprg': replace with word under the cursor. (Zellner)
-8 Support printing on Unix. Can use "lpansi.c" as an example. (Bookout)
-8 Add put command that replaces the text under it. Esp. for blockwise
- Visual mode.
-7 Enhance termresponse stuff: Add t_CV(?): pattern of term response, use
- regexp: "\e\[[>?][0-9;]*c", but only check just after sending t_RV.
-7 Add "g|" command: move to N'th column from the left margin (after wrapping
- and applying 'leftcol'). Works as "|" like what "g0" is to "0".
-7 Support setting 'equalprg' to a user function name.
-7 Highlight the characters after the end-of-line differently.
-7 When 'whichwrap' contains "l", "$dl" should join lines?
-8 Add an argument to configure to use $CFLAGS and not modify it? (Mooney)
-8 Enabling features is a mix of configure arguments and defines in
- feature.h. How to make this consistent? Feature.h is required for
- non-unix systems. Perhaps let configure define CONF_XXX, and use #ifdef
- CONF_XXX in feature.h? Then what should min-features and max-features do?
-8 Add "g^E" and "g^Y", to scroll a screen-full line up and down.
-6 Add ":timer" command, to set a command to be executed at a certain
- interval, or once after some time has elapsed. (Aaron)
- Perhaps an autocommand event like CursorHold is better?
- Patch to add async functionality. (Geoff Greer, 2013 Sep 1 and later)
-8 Add ":confirm" handling in open_exfile(), for when file already exists.
-8 When quitting with changed files, make the dialog list the changed file
- and allow "write all", "discard all", "write some". The last one would
- then ask "write" or "discard" for each changed file. Patch in HierAssist
- does something like this. (Shah)
-7 Use growarray for replace stack.
-7 Have a look at viH (Hellenic or Greek version of Vim). But a solution
- outside of Vim might be satisfactory (Haritsis).
-3 Make "2d%" work like "d%d%" instead of "d2%"?
-7 "g CTRL-O" jumps back to last used buffer. Skip CTRL-O jumps in the same
- buffer. Make jumplist remember the last ten accessed buffers?
-7 Make it possible to set the size of the jumplist (also to a smaller number
- than the default). (Nikolai Weibull)
-- Add code to disable the CAPS key when going from Insert to Normal mode.
-- Set date/protection/etc. of the patchfile the same as the original file.
-- Use growarray for termcodes[] in term.c
-- Add <window-99>, like <cword> but use filename of 99'th window.
-7 Add a way to change an operator to always work characterwise-inclusive
- (like "v" makes the operator characterwise-exclusive). "x" could be used.
-- Make a set of operations on list of names: expand wildcards, replace home
- dir, append a string, delete a string, etc.
-- Remove using mktemp() and use tmpname() only? Ctags does this.
-- When replacing environment variables, and there is one that is not set,
- turn it into an empty string? Only when expanding options? (Hiebert)
-- Option to set command to be executed instead of producing a beep (e.g. to
- call "play newbeep.au").
-- Add option to show the current function name in the status line. More or
- less what you find with "[[k", like how 'cindent' recognizes a function.
- (Bhatt).
-- "[r" and "]r": like "p" and "P", but replace instead of insert (esp. for
- blockwise registers).
-- Add 'timecheck' option, on by default. Makes it possible to switch off the
- timestamp warning and question. (Dodt).
-- Add an option to set the time after which Vim should check the timestamps
- of the files. Only check when an event occurs (e.g., character typed,
- mouse moved). Useful for non-GUI versions where keyboard focus isn't
- noticeable.
-- Make 'smartcase' work even though 'ic' isn't set (Webb).
-7 When formatting text, allow to break the line at a number of characters.
- Use an option for this: 'breakchars'? Useful for formatting Fortran code.
-- Add flag to 'formatoptions' to be able to format book-style paragraphs
- (first line of paragraph has larger indent, no empty lines between
- paragraphs). Complements the '2' flag. Use '>' flag when larger indent
- starts a new paragraph, use '<' flag when smaller indent starts a new
- paragraph. Both start a new paragraph on any indent change.
-8 The 'a' flag in 'formatoptions' is too dangerous. In some way only do
- auto-formatting in specific regions, e.g. defined by syntax highlighting.
-8 Allow using a trailing space to signal a paragraph that continues on the
- next line (MIME text/plain; format=flowed, RFC 2646). Can be used for
- continuous formatting. Could use 'autoformat' option, which specifies a
- regexp which triggers auto-formatting (for one line).
- ":set autoformat=\\s$".
-- Be able to redefine where a sentence stops. Use a regexp pattern?
-- Support multi-byte characters for sentences. Example from Ben Peterson.
-7 Add command "g)" to go to the end of a sentence, "g(" to go back to the
- end of a sentence. (Servatius Brandt)
-- Be able to redefine where a paragraph starts. For "[[" where the '{' is
- not in column 1.
-6 Add ":cdprev": go back to the previous directory. Need to remember a
- stack of previous directories. We also need ":cdnext".
-7 Should ":cd" for MS-DOS go to $HOME, when it's defined?
-- Make "gq<CR>" work on the last line in the file. Maybe for every operator?
-- Add more redirecting of Ex commands:
- :redir #> bufname
- :redir #>> bufname (append)
-- Give error message when starting :redir: twice or using END when no
- redirection was active.
-- Setting of options, specifically for a buffer or window, with
- ":set window.option" or ":set buffer.option=val". Or use ":buffer.set".
- Also: "buffer.map <F1> quit".
-6 Would it be possible to change the color of the cursor in the Win32
- console? (Klaus Hast)
-- Add :delcr command:
- *:delcr*
- :[range]delcr[!] Check [range] lines (default: whole buffer) for lines
- ending in <CR>. If all lines end in <CR>, or [!] is
- used, remove the <CR> at the end of lines in [range].
- A CTRL-Z at the end of the file is removed. If
- [range] is omitted, or it is the whole file, and all
- lines end in <CR> 'textmode' is set.
-- Should integrate addstar() and file_pat_to_reg_pat().
-- When working over a serial line with 7 bit characters, remove meta
- characters from 'isprint'.
-- Use fchdir() in init_homedir(), like in FullName().
-- In win_update(), when the GUI is active, always use the scrolling area.
- Avoid that the last status line is deleted and needs to be redrawn.
-- That "cTx" fails when the cursor is just after 'x' is Vi compatible, but
- may not be what you expect. Add a flag in 'cpoptions' for this? More
- general: Add an option to allow "c" to work with a null motion.
-- Give better error messages by using errno (strerror()).
-- Give "Usage:" error message when command used with wrong arguments (like
- Nvi).
-- Make 'restorescreen' option also work for xterm (and others), replaces the
- SAVE_XTERM_SCREEN define.
-7 Support for ":winpos" In xterm: report the current window position.
-- Give warning message when using ":set t_xx=asdf" for a termcap code that
- Vim doesn't know about. Add flag in 'shortmess'?
-6 Add ":che <file>", list all the include paths which lead to this file.
-- For a commandline that has several commands (:s, :d, etc.) summarize the
- changes all together instead of for each command (e.g. for the rot13
- macro).
-- Add command like "[I" that also shows the tree of included files.
-- ":set sm^L" results in ":set s", because short names of options are also
- expanded. Is there a better way to do this?
-- Add ":@!" command, to ":@" like what ":source!" is to ":source".
-8 Add ":@:!": repeat last command with forceit set.
-- Add 't_normal': Used whenever t_me, t_se, t_ue or t_Zr is empty.
-- ":cab map test ^V| je", ":cunab map" doesn't work. This is vi compatible!
-- CTRL-W CTRL-E and CTRL-W CTRL-Y should move the current window up or down
- if it is not the first or last window.
-- Include-file-search commands should look in the loaded buffer of a file (if
- there is one) instead of the file itself.
-7 Change 'nrformats' to include the leader for each format. Example:
- nrformats=hex:$,binary:b,octal:0
- Add setting of 'nrformats' to syntax files.
-- 'path' can become very long, don't use NameBuff for expansion.
-- When unhiding a hidden buffer, put the same line at top of the window as
- the one before hiding it. Or: keep the same relative cursor position (so
- many percent down the windows).
-- Make it possible for the 'showbreak' to be displayed at the end of the
- line. Use a comma to separate the part at the end and the start of the
- line? Highlight the linebreak characters, add flag in 'highlight'.
- Make 'showbreak' local to a window.
-- Some string options should be expanded if they have wildcards, e.g.
- 'dictionary' when it is "*.h".
-- Use a specific type for number and boolean options, making it possible to
- change it for specific machines (e.g. when a long is 64 bit).
-- Add option for <Insert> in replace mode going to normal mode. (Nugent)
-- Add a next/previous possibility to "[^I" and friends.
-- Add possibility to change the HOME directory. Use the directory from the
- passwd file? (Antwerpen)
-8 Add commands to push and pop all or individual options. ":setpush tw",
- ":setpop tw", ":setpush all". Maybe pushing/popping all options is
- sufficient. ":setflush" resets the option stack?
- How to handle an aborted mapping? Remember position in tag stack when
- mapping starts, restore it when an error aborts the mapping?
-- "gc": goto character, move absolute character positions forward, also
- counting newlines. "gC" goes backwards (Weigert).
-- When doing CTRL-^, redraw buffer with the same topline. (Demirel) Store
- cursor row and window height to redraw cursor at same percentage of window
- (Webb).
-- Besides remembering the last used line number of a file, also remember the
- column. Use it with CTRL-^ et. al.
-- Check for non-digits when setting a number option (careful when entering
- hex codes like 0xff).
-- Add option to make "." redo the "@r" command, instead of the last command
- executed by it. Also to make "." redo the whole mapping. Basically: redo
- the last TYPED command.
-- Support URL links for ^X^F in Insert mode, like for "gf".
-- Support %name% expansion for "gf" on Windows.
-- Make "gf" work on "file://c:/path/name". "file:/c:/" and "file:///c:/"
- should also work?
-- Add 'urlpath', used like 'path' for when "gf" used on an URL?
-8 When using "gf" on an absolute file name, while editing a remote file
- (starts with scp:// or http://) should prepend the method and machine
- name.
-- When finding an URL or file name, and it doesn't exist, try removing a
- trailing '.'.
-- Add ":path" command modifier. Should work for every command that takes a
- file name argument, to search for the file name in 'path'. Use
- find_file_in_path().
-- Highlight control characters on the screen: Shows the difference between
- CTRL-X and "^" followed by "X" (Colon).
-- Integrate parsing of cmdline command and parsing for expansion.
-- Create a program that can translate a .swp file from any machine into a
- form usable by Vim on the current machine.
-- Add ":noro" command: Reset 'ro' flag for all buffers, except ones that have
- a readonly file. ":noro!" will reset all 'ro' flags.
-- Add a variant of CTRL-V that stops interpretation of more than one
- character. For entering mappings on the command line where a key contains
- several special characters, e.g. a trailing newline.
-- Make '2' option in 'formatoptions' also work inside comments.
-- Add 's' flag to 'formatoptions': Do not break when inside a string. (Dodt)
-- When window size changed (with the mouse) and made too small, set it back
- to the minimal size.
-- Add "]>" and "[<", shift comment at end of line (command; /* comment */).
-- Should not call cursorcmd() for each vgetc() in getcmdline().
-- ":split file1 file2" adds two more windows (Webb).
-- Don't give message "Incomplete last line" when editing binary file.
-- Add ":a", ":i" for preloading of named buffers.
-- When entering text, keep other windows on same buffer updated (when a line
- entered)?
-- Check out how screen does output optimizing. Apparently this is possible
- as an output filter.
-- In dosub() regexec is called twice for the same line. Try to avoid this.
-- Window updating from memline.c: insert/delete/replace line.
-- Optimize ml_append() for speed, esp. for reading a file.
-- V..c should keep indent when 'ai' is set, just like [count]cc.
-- Updatescript() can be done faster with a string instead of a char.
-- Screen updating is inefficient with CTRL-F and CTRL-B when there are long
- lines.
-- Uppercase characters in Ex commands can be made lowercase?
-8 Add option to show characters in text not as "|A" but as decimal ("^129"),
- hex ("\x81") or octal ("\201") or meta (M-x). Nvi has the 'octal' option
- to switch from hex to octal. Vile can show unprintable characters in hex
- or in octal.
-7 Tighter integration with xxd to edit binary files. Make it more
- easy/obvious to use. Command line argument?
-- How does vi detect whether a filter has messed up the screen? Check source.
- After ":w !command" a wait_return?
-- Improve screen updating code for doput() (use s_ins()).
-- With 'p' command on last line: scroll screen up (also for terminals without
- insert line command).
-- Use insert/delete char when terminal supports it.
-- Optimize screen redraw for slow terminals.
-- Optimize "dw" for long row of spaces (say, 30000).
-- Add "-d null" for editing from a script file without displaying.
-- In Insert mode: Remember the characters that were removed with backspace
- and re-insert them one at a time with <key1>, all together with <key2>.
-- Implement 'redraw' option.
-- Add special code to 'sections' option to define something else but '{' or
- '}' as the start of a section (e.g. one shiftwidth to the right).
-7 Allow using Vim in a pipe: "ls | vim -u xxx.vim - | yyy". Only needs
- implementing ":w" to stdout in the buffer that was read from stdin.
- Perhaps writing to stdout will work, since stderr is used for the terminal
- I/O.
-8 Allow opening an unnamed buffer with ":e !cmd" and ":sp !cmd". Vile can
- do it.
-- Add commands like ]] and [[ that do not include the line jumped to.
-- When :unab without matching "from" part and several matching "to" parts,
- delete the entry that was used last, instead of the first in the list.
-- Add text justification option.
-- Set boolean options on/off with ":set paste=off", ":set paste=on".
-- After "inv"ing an option show the value: ":set invpaste" gives "paste is
- off".
-- Check handling of CTRL-V and '\' for ":" commands that do not have TRLBAR.
-- When a file cannot be opened but does exist, give error message.
-- When writing check for file exists but no permission, "Permission denied".
-- If file does not exist, check if directory exists.
-- MSDOS: although t_cv and t_ci are not set, do invert char under cursor.
-- Settings edit mode: make file with ":set opt=xx", edit it, parse it as ex
- commands.
-- ":set -w all": list one option per line.
-- :table command (Webb)
-- Add new operator: clear, make area white (replace with spaces): "g ".
-- Add command to ":read" a file at a certain column (blockwise read?).
-- Add sort of replace mode where case is taken from the old text (Goldfarb).
-- Allow multiple arguments for ":read", read all the files.
-- Support for tabs in specific columns: ":set tabcol=8,20,34,56" (Demirel).
-- Add 'searchdir' option: Directories to search for file name being edited
- (Demirel).
-- Modifier for the put command: Change to linewise, charwise, blockwise, etc.
-- Add commands for saving and restoring options ":set save" "set restore",
- for use in macro's and the like.
-- Keep output from listings in a window, so you can have a look at it while
- working in another window. Put cmdline in a separate window?
-- Add possibility to put output of Ex commands in a buffer or file, e.g. for
- ":set all". ":r :set all"?
-- When the 'equalalways' option is set, creating a new window should not
- result in windows to become bigger. Deleting a window should not result in
- a window to become smaller (Webb).
-- When resizing the whole Vim window, the windows inside should be resized
- proportionally (Webb).
-- Include options directly in option table, no indirect pointers. Use
- mkopttab to make option table?
-- When doing ":w dir", where "dir" is a directory name, write the current
- file into that directory, with the current file name (without the path)?
-- Support for 'dictionary's that are sorted, makes access a lot faster
- (Haritsis).
-- Add "^Vrx" on the command line, replace with contents of register x. Used
- instead of CTRL-R to make repeating possible. (Marinichev)
-- Add "^Vb" on the command line, replace with word before or under the
- cursor?
-- Option to make a .swp file only when a change is made (Templeton).
-- Support mapping for replace mode and "r" command (Vi doesn't do this)?
-5 Add 'ignorefilecase' option: Ignore case when expanding file names.
- ":e ma<Tab>" would also find "Makefile" on Unix.
-8 Sorting of filenames for completion is wrong on systems that ignore
- case of filenames. Add 'ignorefncase' option. When set, case in
- filenames is ignored for sorting them. Patch by Mike Williams:
- ~/vim/patches/ignorefncase. Also change what matches? Or use another
- option name.
-8 Should be able to compile Vim in another directory, with $(srcdir) set to
- where the sources are. Add $(srcdir) in the Makefile in a lot of places.
- (Netherton)
-6 Make it configurable when "J" inserts a space or not. Should not add a
- space after "(", for example.
-5 When inserting spaces after the end-of-line for 'virtualedit', use tabs
- when the user wants this (e.g., add a "tab" field to 'virtualedit').
- (Servatius Brandt)
-
-
-From Elvis:
-- Use "instman.sh" to install manpages?
-- Add ":alias" command.
-- Search patterns:
- \@ match word under cursor.
- but do:
- \@w match the word under the cursor?
- \@W match the WORD under the cursor?
-8 ":window" command:
- :win + next window (up)
- :win ++ idem, wrapping
- :win - previous window (down)
- :win -- idem, wrapping
- :win nr to window number "nr"
- :win name to window editing buffer "name"
-7 ":cc" compiles a single file (default: current one). 'ccprg' option is
- program to use with ":cc". Use ":compile" instead of ":cc"?
-
-
-From xvi:
-- CTRL-_ : swap 8th bit of character.
-- Add egrep-like regex type, like xvi (Ned Konz) or Perl (Emmanuel Mogenet)
-
-
-From vile:
-- When horizontal scrolling, use '>' for lines continuing right of a window.
-- Support putting .swp files in /tmp: Command in rc.local to move .swp files
- from /tmp to some directory before deleting files.
-
-
-Far future and "big" extensions:
-- Instead of using a Makefile and autoconf, use a simple shell script to
- find the C compiler and do everything with C code. Translate something
- like an Aap recipe and configure.in to C. Avoids depending on Python,
- thus will work everywhere. With batch file to find the C compiler it
- would also work on MS-Windows.
-- Make it easy to setup Vim for groups of users: novice vi users, novice
- Vim users, C programmers, xterm users, GUI users,...
-- Change layout of blocks in swap file: Text at the start, with '\n' in
- between lines (just load the file without changes, except for Mac).
- Indexes for lines are from the end of the block backwards. It's the
- current layout mirrored.
-- Make it possible to edit a register, in a window, like a buffer.
-- Add stuff to syntax highlighting to change the text (upper-case keywords,
- set indent, define other highlighting, etc.).
-- Mode to keep C-code formatted all the time (sort of on-line indent).
-- Several top-level windows in one Vim session. Be able to use a different
- font in each top-level window.
-- Allow editing above start and below end of buffer (flag in 'virtualedit').
-- Smart cut/paste: recognize words and adjust spaces before/after them.
-- Add open mode, use it when terminal has no cursor positioning.
-- Special "drawing mode": a line is drawn where the cursor is moved to.
- Backspace deletes along the line (from jvim).
-- Implement ":Bset", set option in all buffers. Also ":Wset", set in all
- windows, ":Aset, set in all arguments and ":Tset", set in all files
- mentioned in the tags file.
- Add buffer/arg range, like in ":2,5B%s/..." (do we really need this???)
- Add search string: "B/*.c/%s/.."? Or ":F/*.c/%s/.."?
-- Support for underlining (underscore-BS-char), bold (char-BS-char) and other
- standout modes switched on/off with , 'overstrike' option (Reiter).
-- Add vertical mode (Paul Jury, Demirel): "5vdw" deletes a word in five
- lines, "3vitextESC" will insert "text" in three lines, etc..
-4 Recognize l, #, p as 'flags' to EX commands:
- :g/RE/#l shall print lines with line numbers and in list format.
- :g/RE/dp shall print lines that are deleted.
- POSIX: Commands where flags shall apply to all lines written: list,
- number, open, print, substitute, visual, &, z. For other commands, flags
- shall apply to the current line after the command completes. Examples:
- :7,10j #l Join the lines 7-10 and print the result in list
-- Allow two or more users to edit the same file at the same time. Changes
- are reflected in each Vim immediately. Could work with local files but
- also over the internet. See http://www.codingmonkeys.de/subethaedit/.
-
-When using "do" or ":diffget" in a buffer with changes in every line an extra
-empty line would appear.
-
-vim:tw=78:sw=4:sts=4:ts=8:ft=help:norl:
-vim: set fo+=n :
diff --git a/runtime/doc/usr_01.txt b/runtime/doc/usr_01.txt
index c6d363ad5f..2fa15331df 100644
--- a/runtime/doc/usr_01.txt
+++ b/runtime/doc/usr_01.txt
@@ -60,10 +60,7 @@ make them visible with: >
It's not required for this tutorial, but we provide an example vimrc you may
use:
-Unix: >
- :!cp -i $VIMRUNTIME/vimrc_example.vim ~/.vimrc
-MS-DOS, MS-Windows: >
- :!copy $VIMRUNTIME/vimrc_example.vim $VIM/_vimrc
+ :!cp -i $VIMRUNTIME/vimrc_example.vim ~/.config/nvim/init.vim
If the file already exists you probably want to keep it.
diff --git a/runtime/doc/usr_03.txt b/runtime/doc/usr_03.txt
index 9de9eb380c..a8139d60ca 100644
--- a/runtime/doc/usr_03.txt
+++ b/runtime/doc/usr_03.txt
@@ -470,7 +470,7 @@ If you like one of the options mentioned before, and set it each time you use
Vim, you can put the command in your Vim startup file. Edit the file, for
example with: >
- :edit ~/.vimrc
+ :edit ~/.config/nvim/init.vim
Then add a line with the command to set the option, just like you typed it in
Vim. Example: >
diff --git a/runtime/doc/usr_05.txt b/runtime/doc/usr_05.txt
index ec8715b8f6..86fcf0cc2f 100644
--- a/runtime/doc/usr_05.txt
+++ b/runtime/doc/usr_05.txt
@@ -22,30 +22,24 @@ Vim's capabilities. Or define your own macros.
Table of contents: |usr_toc.txt|
==============================================================================
-*05.1* The vimrc file *vimrc-intro*
+*05.1* The vimrc file *vimrc-intro*
You probably got tired of typing commands that you use very often. To start
Vim with all your favorite option settings and mappings, you write them in
-what is called the vimrc file. Vim executes the commands in this file when it
-starts up.
+what is called the init.vim file. Vim executes the commands in this file when
+it starts up.
-If you already have a vimrc file (e.g., when your sysadmin has one setup for
-you), you can edit it this way: >
+If you already have a init.vim file (e.g., when your sysadmin has one setup
+for you), you can edit it this way: >
:edit $MYVIMRC
-If you don't have a vimrc file yet, see |vimrc| to find out where you can
-create a vimrc file. Also, the ":version" command mentions the name of the
-"user vimrc file" Vim looks for.
+If you don't have a vimrc file yet, see |init.vim| to find out where you can
+create a vimrc file.
For Unix and Macintosh this file is always used and is recommended:
- ~/.vimrc ~
-
-For MS-DOS and MS-Windows you can use one of these:
-
- $HOME/_vimrc ~
- $VIM/_vimrc ~
+ ~/.config/nvim/init.vim ~
The vimrc file can contain all the commands that you type after a colon. The
most simple ones are for setting options. For example, if you want Vim to
@@ -291,7 +285,6 @@ Where can you find plugins?
- You could write one yourself, see |write-plugin|.
Some plugins come as a vimball archive, see |vimball|.
-Some plugins can be updated automatically, see |getscript|.
USING A GLOBAL PLUGIN
@@ -300,23 +293,20 @@ First read the text in the plugin itself to check for any special conditions.
Then copy the file to your plugin directory:
system plugin directory ~
- Unix ~/.vim/plugin/
- Macintosh $VIM:vimfiles:plugin
- Mac OS X ~/.vim/plugin/
+ Unix ~/.local/share/nvim/site/plugin
Example for Unix (assuming you didn't have a plugin directory yet): >
- mkdir ~/.vim
- mkdir ~/.vim/plugin
- cp /usr/local/share/vim/vim60/macros/justify.vim ~/.vim/plugin
+ mkdir -p ~/.local/share/nvim/site/plugin
+ cp /usr/local/share/vim/vim60/macros/justify.vim ~/.local/share/nvim/site/plugin
That's all! Now you can use the commands defined in this plugin to justify
text.
Instead of putting plugins directly into the plugin/ directory, you may
better organize them by putting them into subdirectories under plugin/.
-As an example, consider using "~/.vim/plugin/perl/*.vim" for all your Perl
-plugins.
+As an example, consider using "~/.local/share/nvim/site/plugin/perl/*.vim" for
+all your Perl plugins.
FILETYPE PLUGINS *add-filetype-plugin* *ftplugins*
@@ -350,25 +340,19 @@ plugins, but the last part is "ftplugin". Suppose you have found a plugin for
the "stuff" filetype, and you are on Unix. Then you can move this file to the
ftplugin directory: >
- mv thefile ~/.vim/ftplugin/stuff.vim
+ mkdir -p ~/.local/share/nvim/site/ftplugin
+ mv thefile ~/.local/share/nvim/site/ftplugin/stuff.vim
If that file already exists you already have a plugin for "stuff". You might
want to check if the existing plugin doesn't conflict with the one you are
adding. If it's OK, you can give the new one another name: >
- mv thefile ~/.vim/ftplugin/stuff_too.vim
+ mv thefile ~/.local/share/nvim/site/ftplugin/stuff_too.vim
The underscore is used to separate the name of the filetype from the rest,
which can be anything. If you use "otherstuff.vim" it wouldn't work, it would
be loaded for the "otherstuff" filetype.
-On MS-DOS you cannot use long filenames. You would run into trouble if you
-add a second plugin and the filetype has more than six characters. You can
-use an extra directory to get around this: >
-
- mkdir $VIM/vimfiles/ftplugin/fortran
- copy thefile $VIM/vimfiles/ftplugin/fortran/too.vim
-
The generic names for the filetype plugins are: >
ftplugin/<filetype>.vim
@@ -378,9 +362,9 @@ The generic names for the filetype plugins are: >
Here "<name>" can be any name that you prefer.
Examples for the "stuff" filetype on Unix: >
- ~/.vim/ftplugin/stuff.vim
- ~/.vim/ftplugin/stuff_def.vim
- ~/.vim/ftplugin/stuff/header.vim
+ ~/.local/share/nvim/site/ftplugin/stuff.vim
+ ~/.local/share/nvim/site/ftplugin/stuff_def.vim
+ ~/.local/share/nvim/site/ftplugin/stuff/header.vim
The <filetype> part is the name of the filetype the plugin is to be used for.
Only files of this filetype will use the settings from the plugin. The <name>
@@ -410,16 +394,16 @@ non-standard place (it usually resides in a sub-folder called `doc/`).
First, create a "doc" directory in one of the directories in 'runtimepath': >
- :!mkdir ~/.vim/doc
+ :!mkdir -p ~/.local/share/nvim/site/doc
Now, copy the help file to the "doc" directory: >
- :!cp my-plugin/my-plugin-doc.txt ~/.vim/doc
+ :!cp my-plugin/my-plugin-doc.txt ~/.local/share/nvim/site/doc
Here comes the trick, which allows you to jump to the subjects in the new help
file. Generate the local tags file with the |:helptags| command: >
- :helptags ~/.vim/doc
+ :helptags ~/.local/share/nvim/site/doc
You can see an entry for the local help file when you do: >
diff --git a/runtime/doc/usr_06.txt b/runtime/doc/usr_06.txt
index 5e3c7726d4..1cb3eb8673 100644
--- a/runtime/doc/usr_06.txt
+++ b/runtime/doc/usr_06.txt
@@ -35,17 +35,17 @@ easy to overview the file. After a while you will find that black&white text
slows you down!
If you always want to use syntax highlighting, put the ":syntax enable"
-command in your |vimrc| file.
+command in your |init.vim| file.
If you want syntax highlighting only when the terminal supports colors, you
-can put this in your |vimrc| file: >
+can put this in your |init.vim| file: >
if &t_Co > 1
syntax enable
endif
If you want syntax highlighting only in the GUI version, put the ":syntax
-enable" command in your |gvimrc| file.
+enable" command in your |ginit.vim| file.
==============================================================================
*06.2* No or wrong colors?
@@ -144,14 +144,14 @@ the GUI use the Edit/Color Scheme menu. You can also type the command: >
want to try out. Look in the directory $VIMRUNTIME/colors.
When you found the color scheme that you like, add the ":colorscheme" command
-to your |vimrc| file.
+to your |init.vim| file.
You could also write your own color scheme. This is how you do it:
1. Select a color scheme that comes close. Copy this file to your own Vim
directory. For Unix, this should work: >
- !mkdir ~/.vim/colors
+ !mkdir -p ~/.config/nvim/colors
!cp $VIMRUNTIME/colors/morning.vim ~/.vim/colors/mine.vim
<
This is done from Vim, because it knows the value of $VIMRUNTIME.
diff --git a/runtime/doc/usr_21.txt b/runtime/doc/usr_21.txt
index 8bc208dc30..f99c3263d0 100644
--- a/runtime/doc/usr_21.txt
+++ b/runtime/doc/usr_21.txt
@@ -70,9 +70,7 @@ difference. Without it executes the program normally, with the range a number
of text lines is filtered through the program.
Executing a whole row of programs this way is possible. But a shell is much
-better at it. You can start a new shell this way: >
-
- :shell
+better at it. You can start a new shell with |:terminal|.
This is similar to using CTRL-Z to suspend Vim. The difference is that a new
shell is started.
@@ -169,7 +167,7 @@ exiting Vim, there is a slightly more complicated way. You can see a list of
files by typing the command: >
:oldfiles
-< 1: ~/.vimrc ~
+< 1: ~/.config/nvim/init.vim ~
2: ~/text/resume.txt ~
3: /tmp/draft ~
@@ -189,7 +187,7 @@ That #<123 thing is a bit complicated when you just want to edit a file.
Fortunately there is a simpler way: >
:browse oldfiles
-< 1: ~/.vimrc ~
+< 1: ~/.config/nvim/init.vim ~
2: ~/text/resume.txt ~
3: /tmp/draft ~
-- More --
@@ -276,13 +274,13 @@ example, use: >
SESSION HERE, SESSION THERE
The obvious way to use sessions is when working on different projects.
-Suppose you store your session files in the directory "~/.vim". You are
-currently working on the "secret" project and have to switch to the "boring"
-project: >
+Suppose you store your session files in the directory "~/.config/nvim". You
+are currently working on the "secret" project and have to switch to the
+"boring" project: >
:wall
- :mksession! ~/.vim/secret.vim
- :source ~/.vim/boring.vim
+ :mksession! ~/.config/nvim/secret.vim
+ :source ~/.config/nvim/boring.vim
This first uses ":wall" to write all modified files. Then the current session
is saved, using ":mksession!". This overwrites the previous session. The
@@ -292,7 +290,7 @@ point. And finally you load the new "boring" session.
If you open help windows, split and close various windows, and generally mess
up the window layout, you can go back to the last saved session: >
- :source ~/.vim/boring.vim
+ :source ~/.config/nvim/boring.vim
Thus you have complete control over whether you want to continue next time
where you are now, by saving the current setup in a session, or keep the
@@ -330,11 +328,11 @@ More about this in the next chapter.
You can resize the windows a bit to your liking. Then save the session with:
>
- :mksession ~/.vim/mine.vim
+ :mksession ~/.config/nvim/mine.vim
Now you can start Vim with this layout: >
- vim -S ~/.vim/mine.vim
+ vim -S ~/.config/nvim/mine.vim
Hint: To open a file you see listed in the explorer window in the empty
window, move the cursor to the filename and press "O". Double clicking with
@@ -346,8 +344,8 @@ UNIX AND MS-WINDOWS
Some people have to do work on MS-Windows systems one day and on Unix another
day. If you are one of them, consider adding "slash" and "unix" to
'sessionoptions'. The session files will then be written in a format that can
-be used on both systems. This is the command to put in your vimrc file: >
-
+be used on both systems. This is the command to put in your |init.vim| file:
+>
:set sessionoptions+=unix,slash
Vim will use the Unix format then, because the MS-Windows Vim can read and
@@ -368,13 +366,13 @@ another session.
You might prefer to keep the info with the session. You will have to do
this yourself then. Example: >
- :mksession! ~/.vim/secret.vim
- :wshada! ~/.vim/secret.shada
+ :mksession! ~/.config/nvim/secret.vim
+ :wshada! ~/.local/share/nvim/shada/secret.shada
And to restore this again: >
- :source ~/.vim/secret.vim
- :rshada! ~/.vim/secret.shada
+ :source ~/.config/nvim/secret.vim
+ :rshada! ~/.local/share/nvim/shada/secret.shada
==============================================================================
*21.5* Views
@@ -423,11 +421,11 @@ to quickly switch to editing another file, with all its options set as you
saved them.
For example, to save the view of the current file: >
- :mkview ~/.vim/main.vim
+ :mkview ~/.config/nvim/main.vim
You can restore it with: >
- :source ~/.vim/main.vim
+ :source ~/.config/nvim/main.vim
==============================================================================
*21.6* Modelines
diff --git a/runtime/doc/usr_30.txt b/runtime/doc/usr_30.txt
index b2be512980..dbac440ecc 100644
--- a/runtime/doc/usr_30.txt
+++ b/runtime/doc/usr_30.txt
@@ -324,11 +324,11 @@ the output of this command: >
Now use the first item, the name before the first comma. Thus if the output
looks like this:
- runtimepath=~/.vim,/usr/local/share/vim/vim60/runtime,~/.vim/after ~
+ runtimepath=~/.config/nvim,/usr/local/share/vim/vim60/runtime,~/.config/nvim/after ~
-You use "~/.vim" for {directory}. Then the resulting file name is:
+You use "~/.config/nvim" for {directory}. Then the resulting file name is:
- ~/.vim/indent/help.vim ~
+ ~/.config/nvim/indent/help.vim ~
Instead of switching the indenting off, you could write your own indent file.
How to do that is explained here: |indent-expression|.
diff --git a/runtime/doc/usr_31.txt b/runtime/doc/usr_31.txt
index 550564e10c..7bcf4d428a 100644
--- a/runtime/doc/usr_31.txt
+++ b/runtime/doc/usr_31.txt
@@ -248,7 +248,7 @@ you can set the 'lines' option to set a different window size: >
You don't want to do this in a terminal, since its size is fixed (except for
an xterm that supports resizing).
The gvimrc file is searched for in the same locations as the vimrc file.
-Normally its name is "~/.gvimrc" for Unix and "$VIM/_gvimrc" for MS-Windows.
+Normally its name is "~/.config/nvim/ginit.vim".
The $MYGVIMRC environment variable is set to it, thus you can use this command
to edit the file, if you have one: >
diff --git a/runtime/doc/usr_40.txt b/runtime/doc/usr_40.txt
index b802c9534a..d3cc792c59 100644
--- a/runtime/doc/usr_40.txt
+++ b/runtime/doc/usr_40.txt
@@ -478,7 +478,7 @@ for you. This triggers the Filetype event. Use this to do something when a
certain type of file is edited. For example, to load a list of abbreviations
for text files: >
- :autocmd Filetype text source ~/.vim/abbrevs.vim
+ :autocmd Filetype text source ~/.config/nvim/abbrevs.vim
When starting to edit a new file, you could make Vim insert a skeleton: >
diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt
index 90b4ba7a9d..fe9d9b4d62 100644
--- a/runtime/doc/usr_41.txt
+++ b/runtime/doc/usr_41.txt
@@ -2051,8 +2051,8 @@ Example: >
Write this single-line file as "ftdetect/foofoo.vim" in the first directory
that appears in 'runtimepath'. For Unix that would be
-"~/.vim/ftdetect/foofoo.vim". The convention is to use the name of the
-filetype for the script name.
+"~/.config/nvim/ftdetect/foofoo.vim". The convention is to use the name of
+the filetype for the script name.
You can make more complicated checks if you like, for example to inspect the
contents of the file to recognize the language. Also see |new-filetype|.
@@ -2122,8 +2122,8 @@ you can write the different setting in a script: >
Now write this in the "after" directory, so that it gets sourced after the
distributed "vim.vim" ftplugin |after-directory|. For Unix this would be
-"~/.vim/after/ftplugin/vim.vim". Note that the default plugin will have set
-"b:did_ftplugin", but it is ignored here.
+"~/.config/nvim/after/ftplugin/vim.vim". Note that the default plugin will
+have set "b:did_ftplugin", but it is ignored here.
OPTIONS
@@ -2289,8 +2289,8 @@ a user to overrule or add to the default file. The default files start with: >
:let current_compiler = "mine"
When you write a compiler file and put it in your personal runtime directory
-(e.g., ~/.vim/compiler for Unix), you set the "current_compiler" variable to
-make the default file skip the settings.
+(e.g., ~/.config/nvim/compiler for Unix), you set the "current_compiler"
+variable to make the default file skip the settings.
*:CompilerSet*
The second mechanism is to use ":set" for ":compiler!" and ":setlocal" for
":compiler". Vim defines the ":CompilerSet" user command for this. However,
@@ -2310,7 +2310,7 @@ runtime directory, use the mechanism mentioned above. When
When you write a compiler plugin to overrule settings from a default plugin,
don't check "current_compiler". This plugin is supposed to be loaded
last, thus it should be in a directory at the end of 'runtimepath'. For Unix
-that could be ~/.vim/after/compiler.
+that could be ~/.config/nvim/after/compiler.
==============================================================================
*41.14* Writing a plugin that loads quickly *write-plugin-quickload*
@@ -2428,7 +2428,7 @@ want to use subdirectories. Example: >
For Unix the library script used for this could be:
- ~/.vim/autoload/netlib/ftp.vim
+ ~/.config/nvim/autoload/netlib/ftp.vim
Where the function is defined like this: >
@@ -2465,8 +2465,6 @@ utility is recommended.
For utmost portability use Vim itself to pack scripts together. This can be
done with the Vimball utility. See |vimball|.
-It's good if you add a line to allow automatic updating. See |glvs-plugins|.
-
==============================================================================
Next chapter: |usr_42.txt| Add new menus
diff --git a/runtime/doc/usr_42.txt b/runtime/doc/usr_42.txt
index b9102f3f7b..c8eac5f062 100644
--- a/runtime/doc/usr_42.txt
+++ b/runtime/doc/usr_42.txt
@@ -311,7 +311,7 @@ with the name "Compile.bmp". For Unix XPM format is used, the file name is
"Compile.xpm". The size must be 18 by 18 pixels. On MS-Windows other sizes
can be used as well, but it will look ugly.
Put the bitmap in the directory "bitmaps" in one of the directories from
-'runtimepath'. E.g., for Unix "~/.vim/bitmaps/Compile.xpm".
+'runtimepath'. E.g., for Unix "~/.config/nvim/bitmaps/Compile.xpm".
You can define tooltips for the items in the toolbar. A tooltip is a short
text that explains what a toolbar item will do. For example "Open file". It
diff --git a/runtime/doc/usr_43.txt b/runtime/doc/usr_43.txt
index 6eaa9c14a5..e61e6af660 100644
--- a/runtime/doc/usr_43.txt
+++ b/runtime/doc/usr_43.txt
@@ -27,22 +27,21 @@ want to set the 'softtabstop' option to 4 and define a mapping to insert a
three-line comment. You do this with only two steps:
*your-runtime-dir*
-1. Create your own runtime directory. On Unix this usually is "~/.vim". In
- this directory create the "ftplugin" directory: >
+1. Create your own runtime directory. On Unix this usually is
+ "~/.config/nvim". In this directory create the "ftplugin" directory: >
- mkdir ~/.vim
- mkdir ~/.vim/ftplugin
+ mkdir -p ~/.config/nvim/ftplugin
<
When you are not on Unix, check the value of the 'runtimepath' option to
see where Vim will look for the "ftplugin" directory: >
- set runtimepath
+ set runtimepath?
< You would normally use the first directory name (before the first comma).
You might want to prepend a directory name to the 'runtimepath' option in
- your |vimrc| file if you don't like the default value.
+ your |init.vim| file if you don't like the default value.
-2. Create the file "~/.vim/ftplugin/c.vim", with the contents: >
+2. Create the file "~/.config/nvim/ftplugin/c.vim", with the contents: >
setlocal softtabstop=4
noremap <buffer> <LocalLeader>c o/**************<CR><CR>/<Esc>
@@ -102,26 +101,26 @@ However, if you now edit a file /usr/share/scripts/README.txt, this is not a
ruby file. The danger of a pattern ending in "*" is that it quickly matches
too many files. To avoid trouble with this, put the filetype.vim file in
another directory, one that is at the end of 'runtimepath'. For Unix for
-example, you could use "~/.vim/after/filetype.vim".
- You now put the detection of text files in ~/.vim/filetype.vim: >
+example, you could use "~/.config/nvim/after/filetype.vim".
+ You now put the detection of text files in ~/.config/nvim/filetype.vim: >
augroup filetypedetect
au BufNewFile,BufRead *.txt setf text
augroup END
That file is found in 'runtimepath' first. Then use this in
-~/.vim/after/filetype.vim, which is found last: >
+~/.config/nvim/after/filetype.vim, which is found last: >
augroup filetypedetect
au BufNewFile,BufRead /usr/share/scripts/* setf ruby
augroup END
What will happen now is that Vim searches for "filetype.vim" files in each
-directory in 'runtimepath'. First ~/.vim/filetype.vim is found. The
+directory in 'runtimepath'. First ~/.config/nvim/filetype.vim is found. The
autocommand to catch *.txt files is defined there. Then Vim finds the
filetype.vim file in $VIMRUNTIME, which is halfway 'runtimepath'. Finally
-~/.vim/after/filetype.vim is found and the autocommand for detecting ruby
-files in /usr/share/scripts is added.
+~/.config/nvim/after/filetype.vim is found and the autocommand for detecting
+ruby files in /usr/share/scripts is added.
When you now edit /usr/share/scripts/README.txt, the autocommands are
checked in the order in which they were defined. The *.txt pattern matches,
thus "setf text" is executed to set the filetype to "text". The pattern for
diff --git a/runtime/doc/usr_44.txt b/runtime/doc/usr_44.txt
index 48f661eb07..a91f92ff4e 100644
--- a/runtime/doc/usr_44.txt
+++ b/runtime/doc/usr_44.txt
@@ -610,11 +610,11 @@ More about synchronizing in the reference manual: |:syn-sync|.
*44.11* Installing a syntax file
When your new syntax file is ready to be used, drop it in a "syntax" directory
-in 'runtimepath'. For Unix that would be "~/.vim/syntax".
+in 'runtimepath'. For Unix that would be "~/.config/nvim/syntax".
The name of the syntax file must be equal to the file type, with ".vim"
added. Thus for the x language, the full path of the file would be:
- ~/.vim/syntax/x.vim ~
+ ~/.config/nvim/syntax/x.vim ~
You must also make the file type be recognized. See |43.2|.
@@ -640,7 +640,7 @@ Write the file with the same name as the original syntax file. In this case
"c.vim". Place it in a directory near the end of 'runtimepath'. This makes
it loaded after the original syntax file. For Unix this would be:
- ~/.vim/after/syntax/c.vim ~
+ ~/.config/nvim/after/syntax/c.vim ~
==============================================================================
*44.12* Portable syntax file layout
diff --git a/runtime/doc/usr_45.txt b/runtime/doc/usr_45.txt
index 808a9fc725..34b607cbd2 100644
--- a/runtime/doc/usr_45.txt
+++ b/runtime/doc/usr_45.txt
@@ -129,7 +129,7 @@ this name, but with all letters made lowercase. Then copy the file to your
own runtime directory, as found early in 'runtimepath'. For example, for Unix
you would do: >
- :!cp $VIMRUNTIME/lang/menu_ko_kr.euckr.vim ~/.vim/lang/menu_nl_be.iso_8859-1.vim
+ :!cp $VIMRUNTIME/lang/menu_ko_kr.euckr.vim ~/.config/nvim/lang/menu_nl_be.iso_8859-1.vim
You will find hints for the translation in "$VIMRUNTIME/lang/README.txt".
@@ -359,7 +359,7 @@ DO-IT-YOURSELF KEYMAPS
You can create your own keymap file. It's not very difficult. Start with
a keymap file that is similar to the language you want to use. Copy it to the
"keymap" directory in your runtime directory. For example, for Unix, you
-would use the directory "~/.vim/keymap".
+would use the directory "~/.config/nvim/keymap".
The name of the keymap file must look like this:
keymap/{name}.vim ~
diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt
index df5d367469..117e977e0d 100644
--- a/runtime/doc/various.txt
+++ b/runtime/doc/various.txt
@@ -33,7 +33,7 @@ CTRL-L Clear and redraw the screen. The redraw may happen
*N<Del>*
<Del> When entering a number: Remove the last digit.
Note: if you like to use <BS> for this, add this
- mapping to your .vimrc: >
+ mapping to your vimrc: >
:map CTRL-V <BS> CTRL-V <Del>
<
:as[cii] or *ga* *:as* *:ascii*
@@ -212,7 +212,7 @@ g8 Print the hex values of the bytes used in the
equivalent to: >
:enew
- :call termopen([&sh, &shcf, '{cmd}'])
+ :call termopen('{cmd}')
:startinsert
<
If no {cmd} is given, 'shellcmdflag' will not be sent
@@ -332,7 +332,6 @@ N *+find_in_path* include file searches: |[I|, |:isearch|,
|CTRL-W_CTRL-I|, |:checkpath|, etc.
N *+folding* |folding|
*+footer* |gui-footer|
- *+fork* Unix only: |fork| shell commands
N *+gettext* message translations |multi-lang|
*+GUI_Athena* Unix only: Athena |GUI|
*+GUI_neXtaw* Unix only: neXtaw |GUI|
@@ -377,7 +376,6 @@ N *+startuptime* |--startuptime| argument
N *+statusline* Options 'statusline', 'rulerformat' and special
formats of 'titlestring' and 'iconstring'
N *+syntax* Syntax highlighting |syntax|
- *+system()* Unix only: opposite of |+fork|
N *+tag_binary* binary searching in tags file |tag-binary-search|
N *+tag_old_static* old method for static tags |tag-old-static|
m *+tag_any_white* any white space allowed in tags file |tag-any-white|
diff --git a/runtime/doc/vi_diff.txt b/runtime/doc/vi_diff.txt
index e76c0163b5..7b61dbe6d7 100644
--- a/runtime/doc/vi_diff.txt
+++ b/runtime/doc/vi_diff.txt
@@ -6,63 +6,14 @@
Differences between Vim and Vi *vi-differences*
-Throughout the help files differences between Vim and Vi/Ex are given in
-curly braces, like "{not in Vi}". This file only lists what has not been
-mentioned in other files and gives an overview.
-
-1. Simulated command |simulated-command|
-2. Missing options |missing-options|
-3. Limits |limits|
-4. The most interesting additions |vim-additions|
-5. Other vim features |other-features|
-6. Command-line arguments |cmdline-arguments|
+1. Limits |limits|
+2. The most interesting additions |vim-additions|
==============================================================================
-1. Simulated command *simulated-command*
-
-This command is in Vi, but Vim only simulates it:
-
- *:o* *:op* *:open*
-:[range]o[pen] Works like |:visual|: end Ex mode.
- {Vi: start editing in open mode}
+1. Limits *limits*
-:[range]o[pen] /pattern/ As above, additionally move the cursor to the
- column where "pattern" matches in the cursor
- line.
-
-Vim does not support open mode, since it's not really useful. For those
-situations where ":open" would start open mode Vim will leave Ex mode, which
-allows executing the same commands, but updates the whole screen instead of
-only one line.
-
-==============================================================================
-2. Missing options *missing-options*
-
-These options are in the Unix Vi, but not in Vim.
-
-autoprint (ap) boolean (default on) *'autoprint'* *'ap'*
-beautify (bf) boolean (default off) *'beautify'* *'bf'*
-flash (fl) boolean (default ??) *'flash'* *'fl'*
-graphic (gr) boolean (default off) *'graphic'* *'gr'*
-hardtabs (ht) number (default 8) *'hardtabs'* *'ht'*
- number of spaces that a <Tab> moves on the display
-mesg boolean (default on) *'mesg'*
-novice boolean (default off) *'novice'*
-open boolean (default on) *'open'*
-optimize (op) boolean (default off) *'optimize'* *'op'*
-redraw boolean (default off) *'redraw'*
-slowopen (slow) boolean (default off) *'slowopen'* *'slow'*
-sourceany boolean (default off) *'sourceany'*
-w300 number (default 23) *'w300'*
-w1200 number (default 23) *'w1200'*
-w9600 number (default 23) *'w9600'*
+Vim has only a few limits for the files that can be edited.
-==============================================================================
-3. Limits *limits*
-
-Vim has only a few limits for the files that can be edited {Vi: can not handle
-<Nul> characters and characters above 128, has limited line length, many other
-limits}.
*E340*
Maximum line length 2147483647 characters
Maximum number of lines 2147483647 lines
@@ -102,21 +53,7 @@ don't want a swap file at all, set 'updatecount' to 0, or use the "-n"
argument when starting Vim.
==============================================================================
-4. The most interesting additions *vim-additions*
-
-Vi compatibility. |'compatible'|
- Although Vim is 99% Vi compatible, some things in Vi can be
- considered to be a bug, or at least need improvement. But still, Vim
- starts in a mode which behaves like the "real" Vi as much as possible.
- To make Vim behave a little bit better, try resetting the 'compatible'
- option:
- :set nocompatible
- Or start Vim with the "-N" argument:
- vim -N
- Vim starts with 'nocompatible' automatically if you have a .vimrc
- file. See |startup|.
- The 'cpoptions' option can be used to set Vi compatibility on/off for
- a number of specific items.
+2. The most interesting additions *vim-additions*
Support for different systems.
Vim can be used on:
@@ -437,482 +374,5 @@ Move cursor beyond lines.
screen, also where there is no text. This is useful to edit tables
and figures easily.
-==============================================================================
-5. Other vim features *other-features*
-
-A random collection of nice extra features.
-
-
-When Vim is started with "-s scriptfile", the characters read from
-"scriptfile" are treated as if you typed them. If end of file is reached
-before the editor exits, further characters are read from the console.
-
-The "-w" option can be used to record all typed characters in a script file.
-This file can then be used to redo the editing, possibly on another file or
-after changing some commands in the script file.
-
-The "-o" option opens a window for each argument. "-o4" opens four windows.
-
-Vi requires several termcap entries to be able to work full-screen. Vim only
-requires the "cm" entry (cursor motion).
-
-
-In command mode:
-
-When the 'showcmd' option is set, the command characters are shown in the last
-line of the screen. They are removed when the command is finished.
-
-If the 'ruler' option is set, the current cursor position is shown in the
-last line of the screen.
-
-"U" still works after having moved off the last changed line and after "u".
-
-Characters with the 8th bit set are displayed. The characters between '~' and
-0xa0 are displayed as "~?", "~@", "~A", etc., unless they are included in the
-'isprint' option.
-
-"][" goes to the next ending of a C function ('}' in column 1).
-"[]" goes to the previous ending of a C function ('}' in column 1).
-
-"]f", "[f" and "gf" start editing the file whose name is under the cursor.
-CTRL-W f splits the window and starts editing the file whose name is under
-the cursor.
-
-"*" searches forward for the identifier under the cursor, "#" backward.
-"K" runs the program defined by the 'keywordprg' option, with the identifier
-under the cursor as argument.
-
-"%" can be preceded with a count. The cursor jumps to the line that
-percentage down in the file. The normal "%" function to jump to the matching
-brace skips braces inside quotes.
-
-With the CTRL-] command, the cursor may be in the middle of the identifier.
-
-The used tags are remembered. Commands that can be used with the tag stack
-are CTRL-T, ":pop" and ":tag". ":tags" lists the tag stack.
-
-The 'tags' option can be set to a list of tag file names. Thus multiple
-tag files can be used. For file names that start with "./", the "./" is
-replaced with the path of the current file. This makes it possible to use a
-tags file in the same directory as the file being edited.
-
-Previously used file names are remembered in the alternate file name list.
-CTRL-^ accepts a count, which is an index in this list.
-":files" command shows the list of alternate file names.
-"#<N>" is replaced with the <N>th alternate file name in the list.
-"#<" is replaced with the current file name without extension.
-
-Search patterns have more features. The <NL> character is seen as part of the
-search pattern and the substitute string of ":s". Vi sees it as the end of
-the command.
-
-Searches can put the cursor on the end of a match and may include a character
-offset.
-
-Count added to "~", ":next", ":Next", "n" and "N".
-
-The command ":next!" with 'autowrite' set does not write the file. In vi the
-file was written, but this is considered to be a bug, because one does not
-expect it and the file is not written with ":rewind!".
-
-In Vi when entering a <CR> in replace mode deletes a character only when 'ai'
-is set (but does not show it until you hit <Esc>). Vim always deletes a
-character (and shows it immediately).
-
-Added :wnext command. Same as ":write" followed by ":next".
-
-The ":w!" command always writes, also when the file is write protected. In Vi
-you would have to do ":!chmod +w %:S" and ":set noro".
-
-When 'tildeop' has been set, "~" is an operator (must be followed by a
-movement command).
-
-With the "J" (join) command you can reset the 'joinspaces' option to have only
-one space after a period (Vi inserts two spaces).
-
-"cw" can be used to change white space formed by several characters (Vi is
-confusing: "cw" only changes one space, while "dw" deletes all white space).
-
-"o" and "O" accept a count for repeating the insert (Vi clears a part of
-display).
-
-Flags after Ex commands not supported (no plans to include it).
-
-On non-UNIX systems ":cd" command shows current directory instead of going to
-the home directory (there isn't one). ":pwd" prints the current directory on
-all systems.
-
-After a ":cd" command the file names (in the argument list, opened files)
-still point to the same files. In Vi ":cd" is not allowed in a changed file;
-otherwise the meaning of file names change.
-
-":source!" command reads Vi commands from a file.
-
-":mkexrc" command writes current modified options and mappings to a ".exrc"
-file. ":mkvimrc" writes to a ".vimrc" file.
-
-No check for "tail recursion" with mappings. This allows things like
-":map! foo ^]foo".
-
-When a mapping starts with number, vi loses the count typed before it (e.g.
-when using the mapping ":map g 4G" the command "7g" goes to line 4). This is
-considered a vi bug. Vim concatenates the counts (in the example it becomes
-"74G"), as most people would expect.
-
-The :put! command inserts the contents of a register above the current line.
-
-The "p" and "P" commands of vi cannot be repeated with "." when the putted
-text is less than a line. In Vim they can always be repeated.
-
-":noremap" command can be used to enter a mapping that will not be remapped.
-This is useful to exchange the meaning of two keys. ":cmap", ":cunmap" and
-":cnoremap" can be used for mapping in command-line editing only. ":imap",
-":iunmap" and ":inoremap" can be used for mapping in insert mode only.
-Similar commands exist for abbreviations: ":noreabbrev", ":iabbrev"
-":cabbrev", ":iunabbrev", ":cunabbrev", ":inoreabbrev", ":cnoreabbrev".
-
-In Vi the command ":map foo bar" would remove a previous mapping
-":map bug foo". This is considered a bug, so it is not included in Vim.
-":unmap! foo" does remove ":map! bug foo", because unmapping would be very
-difficult otherwise (this is vi compatible).
-
-The ':' register contains the last command-line.
-The '%' register contains the current file name.
-The '.' register contains the last inserted text.
-
-":dis" command shows the contents of the yank registers.
-
-CTRL-O/CTRL-I can be used to jump to older/newer positions. These are the
-same positions as used with the '' command, but may be in another file. The
-":jumps" command lists the older positions.
-
-If the 'shiftround' option is set, an indent is rounded to a multiple of
-'shiftwidth' with ">" and "<" commands.
-
-The 'scrolljump' option can be set to the minimum number of lines to scroll
-when the cursor gets off the screen. Use this when scrolling is slow.
-
-The 'scrolloff' option can be set to the minimum number of lines to keep
-above and below the cursor. This gives some context to where you are
-editing. When set to a large number the cursor line is always in the middle
-of the window.
-
-Uppercase marks can be used to jump between files. The ":marks" command lists
-all currently set marks. The commands "']" and "`]" jump to the end of the
-previous operator or end of the text inserted with the put command. "'[" and
-"`[" do jump to the start.
-
-The 'highlight' option can be set for the highlight mode to be used for
-several commands.
-
-The CTRL-A (add) and CTRL-X (subtract) commands are new. The count to the
-command (default 1) is added to/subtracted from the number at or after the
-cursor. That number may be decimal, octal (starts with a '0') or hexadecimal
-(starts with '0x'). Very useful in macros.
-
-With the :set command the prefix "inv" can be used to invert boolean options.
-
-In both Vi and Vim you can create a line break with the ":substitute" command
-by using a CTRL-M. For Vi this means you cannot insert a real CTRL-M in the
-text. With Vim you can put a real CTRL-M in the text by preceding it with a
-CTRL-V.
-
-
-In Insert mode:
-
-If the 'revins' option is set, insert happens backwards. This is for typing
-Hebrew. When inserting normal characters the cursor will not be shifted and
-the text moves rightwards. Backspace, CTRL-W and CTRL-U will also work in
-the opposite direction. CTRL-B toggles the 'revins' option. In replace mode
-'revins' has no effect. Only when enabled at compile time.
-
-The backspace key can be used just like CTRL-D to remove auto-indents.
-
-You can backspace, CTRL-U and CTRL-W over line breaks if the 'backspace' (bs)
-option includes "eol". You can backspace over the start of insert if the
-'backspace' option includes "start".
-
-When the 'paste' option is set, a few options are reset and mapping in insert
-mode and abbreviation are disabled. This allows for pasting text in windowing
-systems without unexpected results. When the 'paste' option is reset, the old
-option values are restored.
-
-CTRL-T/CTRL-D always insert/delete an indent in the current line, no matter
-what column the cursor is in.
-
-CTRL-@ (insert previously inserted text) works always (Vi: only when typed as
-first character).
-
-CTRL-A works like CTRL-@ but does not leave insert mode.
-
-CTRL-R {0-9a-z..} can be used to insert the contents of a register.
-
-When the 'smartindent' option is set, C programs will be better auto-indented.
-With 'cindent' even more.
-
-CTRL-Y and CTRL-E can be used to copy a character from above/below the
-current cursor position.
-
-After CTRL-V you can enter a three digit decimal number. This byte value is
-inserted in the text as a single character. Useful for international
-characters that are not on your keyboard.
-
-When the 'expandtab' (et) option is set, a <Tab> is expanded to the
-appropriate number of spaces.
-
-The window always reflects the contents of the buffer (Vi does not do this
-when changing text and in some other cases).
-
-If Vim is compiled with DIGRAPHS defined, digraphs are supported. A set of
-normal digraphs is included. They are shown with the ":digraph" command.
-More can be added with ":digraph {char1}{char2} {number}". A digraph is
-entered with "CTRL-K {char1} {char2}" or "{char1} BS {char2}" (only when
-'digraph' option is set).
-
-When repeating an insert, e.g. "10atest <Esc>" vi would only handle wrapmargin
-for the first insert. Vim does it for all.
-
-A count to the "i" or "a" command is used for all the text. Vi uses the count
-only for one line. "3iabc<NL>def<Esc>" would insert "abcabcabc<NL>def" in Vi
-but "abc<NL>defabc<NL>defabc<NL>def" in Vim.
-
-
-In Command-line mode:
-
-<Esc> terminates the command-line without executing it. In vi the command
-line would be executed, which is not what most people expect (hitting <Esc>
-should always get you back to command mode). To avoid problems with some
-obscure macros, an <Esc> in a macro will execute the command. If you want a
-typed <Esc> to execute the command like vi does you can fix this with
- ":cmap ^V<Esc> ^V<CR>"
-
-General:
-
-The 'ttimeout' option is like 'timeout', but only works for cursor and
-function keys, not for ordinary mapped characters. The 'timeoutlen' option
-gives the number of milliseconds that is waited for. If the 'esckeys' option
-is not set, cursor and function keys that start with <Esc> are not recognized
-in insert mode.
-
-There is an option for each terminal string. Can be used when termcap is not
-supported or to change individual strings.
-
-The 'fileformat' option can be set to select the <EOL>: "dos" <CR><NL>, "unix"
-<NL> or "mac" <CR>.
-When the 'fileformats' option is not empty, Vim tries to detect the type of
-<EOL> automatically. The 'fileformat' option is set accordingly.
-
-On systems that have no job control (older Unix systems and non-Unix systems)
-the CTRL-Z, ":stop" or ":suspend" command starts a new shell.
-
-The 'columns' and 'lines' options are used to set or get the width and height
-of the display.
-
-Option settings are read from the first and last few lines of the file.
-Option 'modelines' determines how many lines are tried (default is 5). Note
-that this is different from the Vi versions that can execute any Ex command
-in a modeline (a major security problem). |trojan-horse|
-
-If the 'insertmode' option is set (e.g. in .exrc), Vim starts in insert mode.
-And it comes back there, when pressing <Esc>.
-
-Undo information is kept in memory. Available memory limits the number and
-size of change that can be undone. This may be a problem with MS-DOS, but is
-almost never one with Unix and Win32.
-
-If the 'backup' or 'writebackup' option is set: Before a file is overwritten,
-a backup file (.bak) is made. If the "backup" option is set it is left
-behind.
-
-Vim creates a file ending in ".swp" to store parts of the file that have been
-changed or that do not fit in memory. This file can be used to recover from
-an aborted editing session with "vim -r file". Using the swap file can be
-switched off by setting the 'updatecount' option to 0 or starting Vim with
-the "-n" option. Use the 'directory' option for placing the .swp file
-somewhere else.
-
-Error messages are shown at least one second (Vi overwrites error messages).
-
-If Vim gives the |hit-enter| prompt, you can hit any key. Characters other
-than <CR>, <NL> and <Space> are interpreted as the (start of) a command. (Vi
-only accepts a command starting with ':').
-
-The contents of the numbered and unnamed registers is remembered when
-changing files.
-
-The "No lines in buffer" message is a normal message instead of an error
-message, since that may cause a mapping to be aborted.
-
-==============================================================================
-6. Command-line arguments *cmdline-arguments*
-
-Different versions of Vi have different command-line arguments. This can be
-confusing. To help you, this section gives an overview of the differences.
-
-Five variants of Vi will be considered here:
- Elvis Elvis version 2.1b
- Nvi Nvi version 1.79
- Posix Posix 1003.2
- Vi Vi version 3.7 (for Sun 4.1.x)
- Vile Vile version 7.4 (incomplete)
- Vim Vim version 5.2
-
-Only Vim is able to accept options in between and after the file names.
-
-+{command} Elvis, Nvi, Posix, Vi, Vim: Same as "-c {command}".
-
-- Nvi, Posix, Vi: Run Ex in batch mode.
- Vim: Read file from stdin (use -s for batch mode).
-
--- Vim: End of options, only file names are following.
-
---cmd {command} Vim: execute {command} before sourcing vimrc files.
-
---echo-wid Vim: GTK+ echoes the Window ID on stdout
-
---help Vim: show help message and exit.
-
---literal Vim: take file names literally, don't expand wildcards.
-
---nofork Vim: same as -f
-
---noplugin[s] Vim: Skip loading plugins.
-
---remote Vim: edit the files in another Vim server
-
---remote-expr {expr} Vim: evaluate {expr} in another Vim server
-
---remote-send {keys} Vim: send {keys} to a Vim server and exit
-
---remote-silent {file} Vim: edit the files in another Vim server if possible
-
---remote-wait Vim: edit the files in another Vim server and wait for it
-
---remote-wait-silent Vim: like --remote-wait, no complaints if not possible
-
---role {role} Vim: GTK+ 2: set role of main window
-
---serverlist Vim: Output a list of Vim servers and exit
-
---servername {name} Vim: Specify Vim server name
-
---socketid {id} Vim: GTK window socket to run Vim in
-
---windowid {id} Vim: Win32 window ID to run Vim in
-
---version Vim: show version message and exit.
-
--? Vile: print usage summary and exit.
-
--a Elvis: Load all specified file names into a window (use -o for
- Vim).
-
--A Vim: Start in Arabic mode (when compiled with Arabic).
-
--b {blksize} Elvis: Use {blksize} blocksize for the session file.
--b Vim: set 'binary' mode.
-
--C Vim: Compatible mode.
-
--c {command} Elvis, Nvi, Posix, Vim: run {command} as an Ex command after
- loading the edit buffer.
- Vim: allow up to 10 "-c" arguments
-
--d Vim: start with 'diff' set. |diff-mode|
-
--D Vim: debug mode.
-
--e Elvis, Nvi, Vim: Start in Ex mode.
-
--E Vim: Start in improved Ex mode |gQ|.
-
--f Vim: Run GUI in foreground.
--f {session} Elvis: Use {session} as the session file.
-
--F Vim: Start in Farsi mode (when compiled with Farsi).
- Nvi: Fast start, don't read the entire file when editing
- starts.
-
--G {gui} Elvis: Use the {gui} as user interface.
-
--g Vim: Start GUI.
--g N Vile: start editing at line N
-
--h Vim: Give help message.
- Vile: edit the help file
-
--H Vim: start Hebrew mode (when compiled with it).
-
--i Elvis: Start each window in Insert mode.
--i {viminfo} Vim: Use {viminfo} for viminfo file.
-
--L Vim: Same as "-r" (also in some versions of Vi).
-
--l Nvi, Vi, Vim: Set 'lisp' and 'showmatch' options.
-
--m Vim: Modifications not allowed to be written, resets 'write'
- option.
-
--M Vim: Modifications not allowed, resets 'modifiable' and the
- 'write' option.
-
--N Vim: No-compatible mode.
-
--n Vim: No swap file used.
-
--nb[args] Vim: open a NetBeans interface connection
-
--O[N] Vim: Like -o, but use vertically split windows.
-
--o[N] Vim: Open [N] windows, or one for each file.
-
--p[N] Vim: Open [N] tab pages, or one for each file.
-
--P {parent-title} Win32 Vim: open Vim inside a parent application window
-
--q {name} Vim: Use {name} for quickfix error file.
--q{name} Vim: Idem.
-
--R Elvis, Nvi, Posix, Vile, Vim: Set the 'readonly' option.
-
--r Elvis, Nvi, Posix, Vi, Vim: Recovery mode.
-
--S Nvi: Set 'secure' option.
--S {script} Vim: source script after starting up.
-
--s Nvi, Posix, Vim: Same as "-" (silent mode), when in Ex mode.
- Elvis: Sets the 'safer' option.
--s {scriptin} Vim: Read from script file {scriptin}; only when not in Ex
- mode.
--s {pattern} Vile: search for {pattern}
-
--t {tag} Elvis, Nvi, Posix, Vi, Vim: Edit the file containing {tag}.
--t{tag} Vim: Idem.
-
--T {term} Vim: Set terminal name to {term}.
-
--u {vimrc} Vim: Read initializations from {vimrc} file.
-
--U {gvimrc} Vim: Read GUI initializations from {gvimrc} file.
-
--v Nvi, Posix, Vi, Vim: Begin in Normal mode (visual mode, in Vi
- terms).
- Vile: View mode, no changes possible.
-
--V Elvis, Vim: Verbose mode.
--V{nr} Vim: Verbose mode with specified level.
-
--w {size} Elvis, Posix, Nvi, Vi, Vim: Set value of 'window' to {size}.
--w{size} Nvi, Vi: Same as "-w {size}".
--w {name} Vim: Write to script file {name} (must start with non-digit).
-
--W {name} Vim: Append to script file {name}.
-
--X Vim: Don't connect to the X server.
-
--Z Vim: restricted mode
-
-@{cmdfile} Vile: use {cmdfile} as startup file.
-
vim:tw=78:ts=8:ft=help:norl:
diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt
index 3b3f257351..c6e98bc40c 100644
--- a/runtime/doc/vim_diff.txt
+++ b/runtime/doc/vim_diff.txt
@@ -21,10 +21,11 @@ these differences.
==============================================================================
1. Configuration *nvim-configuration*
-- Use `.nvimrc` instead of `.vimrc` for storing configuration.
-- Use `.nvim` instead of `.vim` to store configuration files.
-- Use `.nvim/shada/main.shada` instead of `.viminfo` for persistent session
- information.
+- Use `$XDG_CONFIG_HOME/nvim/init.vim` instead of `.vimrc` for storing
+ configuration.
+- Use `$XDG_CONFIG_HOME/nvim` instead of `.vim` to store configuration files.
+- Use `$XDG_DATA_HOME/nvim/shada/main.shada` instead of `.viminfo` for persistent
+ session information.
==============================================================================
2. Option defaults *nvim-option-defaults*
@@ -105,6 +106,7 @@ Additional differences:
compatibility reasons.
- |:wviminfo| was renamed to |:wshada|, |:rviminfo| to |:rshada|. Old
commands are still kept.
+- |:oldfiles| supports !.
- When writing (|:wshada| without bang or at exit) it merges much more data,
and does this according to the timestamp. Vim merges only marks.
|shada-merging|
@@ -115,6 +117,7 @@ Additional differences:
|shada-error-handling|
- Vim keeps no timestamps at all, neither in viminfo file nor in the instance
itself.
+- ShaDa file keeps search direction (|v:searchforward|), viminfo does not.
==============================================================================
4. New Features *nvim-features-new*
@@ -141,6 +144,8 @@ Events:
|TabNew|
|TabNewEntered|
|TabClosed|
+ |TermOpen|
+ |TermClose|
Highlight groups:
|hl-EndOfBuffer|
@@ -190,13 +195,14 @@ Highlight groups:
|hl-VisualNOS|
Other options:
+ 'antialias'
'cpoptions' ('g', 'w', 'H', '*', '-', 'j', and all POSIX flags were removed)
'guioptions' (only the 't' flag was removed)
'guipty'
'macatsui'
'shelltype'
'shortname'
- 'termencoding'
+ 'termencoding' (Vim 7.4.852 also removed this for Windows)
'textauto'
'textmode'
'toolbar'
@@ -209,12 +215,14 @@ Other commands:
:Print
:fixdel
:mode (no longer accepts an argument)
+ :open
:shell
:tearoff
Other compile-time features:
EBCDIC
Emacs tags support
+ X11 integration (see |x11-selection|)
Nvim does not have a built-in GUI and hence the following aliases have been
removed: gvim, gex, gview, rgvim, rgview
diff --git a/runtime/doc/windows.txt b/runtime/doc/windows.txt
index 95be125c33..c009bec66e 100644
--- a/runtime/doc/windows.txt
+++ b/runtime/doc/windows.txt
@@ -971,9 +971,10 @@ A buffer can also be unlisted. This means it exists, but it is not in the
list of buffers. |unlisted-buffer|
-:files[!] *:files*
-:buffers[!] *:buffers* *:ls*
-:ls[!] Show all buffers. Example:
+:files[!] [flags] *:files*
+:buffers[!] [flags] *:buffers* *:ls*
+:ls[!] [flags]
+ Show all buffers. Example:
1 #h "/test/text" line 1 ~
2u "asdf" line 0 ~
@@ -999,6 +1000,21 @@ list of buffers. |unlisted-buffer|
+ a modified buffer
x a buffer with read errors
+ [flags] can be a combination of the following characters,
+ which restrict the buffers to be listed:
+ + modified buffers
+ - buffers with 'modifiable' off
+ = readonly buffers
+ a active buffers
+ u unlisted buffers (overrides the "!")
+ h hidden buffers
+ x buffers with a read error
+ % current buffer
+ # alternate buffer
+ Combining flags means they are "and"ed together, e.g.:
+ h+ hidden buffers which are modified
+ a+ active buffers which are modified
+
*:bad* *:badd*
:bad[d] [+lnum] {fname}
Add file name {fname} to the buffer list, without loading it.
diff --git a/runtime/filetype.vim b/runtime/filetype.vim
index 9e0e39e3f8..b06e702637 100644
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -495,7 +495,7 @@ au BufNewFile,BufRead *.prg
\ endif
" Clojure
-au BufNewFile,BufRead *.clj,*.cljs setf clojure
+au BufNewFile,BufRead *.clj,*.cljs,*.cljx,*.cljc setf clojure
" Cmake
au BufNewFile,BufRead CMakeLists.txt,*.cmake,*.cmake.in setf cmake
@@ -772,10 +772,9 @@ au BufNewFile,BufRead *.mo,*.gdmo setf gdmo
au BufNewFile,BufRead *.ged,lltxxxxx.txt setf gedcom
" Git
-au BufNewFile,BufRead *.git/COMMIT_EDITMSG setf gitcommit
-au BufNewFile,BufRead *.git/MERGE_MSG setf gitcommit
+au BufNewFile,BufRead COMMIT_EDITMSG setf gitcommit
+au BufNewFile,BufRead MERGE_MSG setf gitcommit
au BufNewFile,BufRead *.git/config,.gitconfig,.gitmodules setf gitconfig
-au BufNewFile,BufRead *.git/modules/*/COMMIT_EDITMSG setf gitcommit
au BufNewFile,BufRead *.git/modules/*/config setf gitconfig
au BufNewFile,BufRead */.config/git/config setf gitconfig
if !empty($XDG_CONFIG_HOME)
diff --git a/runtime/ftplugin/kconfig.vim b/runtime/ftplugin/kconfig.vim
index 1b10c86ae3..940ba7427f 100644
--- a/runtime/ftplugin/kconfig.vim
+++ b/runtime/ftplugin/kconfig.vim
@@ -1,6 +1,10 @@
" Vim filetype plugin file
-" Maintainer: Nikolai Weibull <now@bitwi.se>
-" Latest Revision: 2008-07-09
+" Vim syntax file
+" Maintainer: Christian Brabandt <cb@256bit.org>
+" Previous Maintainer: Nikolai Weibull <now@bitwi.se>
+" Latest Revision: 2015-05-29
+" License: Vim (see :h license)
+" Repository: https://github.com/chrisbra/vim-kconfig
if exists("b:did_ftplugin")
finish
@@ -14,5 +18,10 @@ let b:undo_ftplugin = "setl com< cms< fo<"
setlocal comments=:# commentstring=#\ %s formatoptions-=t formatoptions+=croql
+" For matchit.vim
+if exists("loaded_matchit")
+ let b:match_words = '^\<menu\>:\<endmenu\>,^\<if\>:\<endif\>,^\<choice\>:\<endchoice\>'
+endif
+
let &cpo = s:cpo_save
unlet s:cpo_save
diff --git a/runtime/ftplugin/shada.vim b/runtime/ftplugin/shada.vim
new file mode 100644
index 0000000000..4f908f4701
--- /dev/null
+++ b/runtime/ftplugin/shada.vim
@@ -0,0 +1,18 @@
+if exists('b:did_ftplugin')
+ finish
+endif
+
+let b:did_ftplugin = 1
+
+function! ShaDaIndent(lnum)
+ if a:lnum == 1 || getline(a:lnum) =~# '\mwith timestamp.*:$'
+ return 0
+ else
+ return shiftwidth()
+ endif
+endfunction
+
+setlocal expandtab tabstop=2 softtabstop=2 shiftwidth=2
+setlocal indentexpr=ShaDaIndent(v:lnum) indentkeys=<:>,o,O
+
+let b:undo_ftplugin = 'setlocal et< ts< sts< sw< indentexpr< indentkeys<'
diff --git a/runtime/ftplugin/spec.vim b/runtime/ftplugin/spec.vim
index c3af8a9fca..0b6750de94 100644
--- a/runtime/ftplugin/spec.vim
+++ b/runtime/ftplugin/spec.vim
@@ -20,11 +20,36 @@ endif
noremap <buffer> <unique> <script> <Plug>SpecChangelog :call <SID>SpecChangelog("")<CR>
+if !exists("*s:GetRelVer")
+ function! s:GetRelVer()
+ if has('python')
+python << PYEND
+import sys, datetime, shutil, tempfile
+import vim
+
+try:
+ import rpm
+except ImportError:
+ pass
+else:
+ specfile = vim.current.buffer.name
+ if specfile:
+ spec = rpm.spec(specfile)
+ headers = spec.packages[0].header
+ version = headers['Version']
+ release = ".".join(headers['Release'].split(".")[:-1])
+ vim.command("let ver = " + version)
+ vim.command("let rel = " + release)
+PYEND
+ endif
+ endfunction
+endif
+
if !exists("*s:SpecChangelog")
function s:SpecChangelog(format)
if strlen(a:format) == 0
if !exists("g:spec_chglog_format")
- let email = input("Email address: ")
+ let email = input("Name <email address>: ")
let g:spec_chglog_format = "%a %b %d %Y " . l:email
echo "\r"
endif
@@ -69,6 +94,9 @@ if !exists("*s:SpecChangelog")
else
let include_release_info = 0
endif
+
+ call s:GetRelVer()
+
if (chgline == -1)
let option = confirm("Can't find %changelog. Create one? ","&End of file\n&Here\n&Cancel",3)
if (option == 1)
@@ -83,7 +111,7 @@ if !exists("*s:SpecChangelog")
endif
endif
if (chgline != -1)
- let parsed_format = "* ".strftime(format)
+ let parsed_format = "* ".strftime(format)." - ".ver."-".rel
let release_info = "+ ".name."-".ver."-".rel
let wrong_format = 0
let wrong_release = 0
diff --git a/runtime/ftplugin/tutor.vim b/runtime/ftplugin/tutor.vim
index 0a28d7def4..1579753170 100644
--- a/runtime/ftplugin/tutor.vim
+++ b/runtime/ftplugin/tutor.vim
@@ -21,8 +21,9 @@ setlocal iskeyword=@,-,_
setlocal foldmethod=expr
setlocal foldexpr=tutor#TutorFolds()
-setlocal foldcolumn=3
+setlocal foldcolumn=1
setlocal foldlevel=4
+setlocal nowrap
setlocal statusline=%{toupper(expand('%:t:r'))}\ tutorial%=
setlocal statusline+=%{tutor#InfoText()}
diff --git a/runtime/ftplugin/zsh.vim b/runtime/ftplugin/zsh.vim
index 3970d65cc8..6cbc380dc3 100644
--- a/runtime/ftplugin/zsh.vim
+++ b/runtime/ftplugin/zsh.vim
@@ -1,7 +1,10 @@
" Vim filetype plugin file
-" Language: Zsh shell script
-" Maintainer: Nikolai Weibull <now@bitwi.se>
-" Latest Revision: 2011-01-23
+" Language: Zsh shell script
+" Maintainer: Christian Brabandt <cb@256bit.org>
+" Previous Maintainer: Nikolai Weibull <now@bitwi.se>
+" Latest Revision: 2015-05-29
+" License: Vim (see :h license)
+" Repository: https://github.com/chrisbra/vim-zsh
if exists("b:did_ftplugin")
finish
diff --git a/runtime/indent/javascript.vim b/runtime/indent/javascript.vim
index a83d34b110..21c8fff86c 100644
--- a/runtime/indent/javascript.vim
+++ b/runtime/indent/javascript.vim
@@ -1,7 +1,7 @@
" Vim indent file
" Language: Javascript
-" Maintainer: None! Wanna improve this?
-" Last Change: 2007 Jan 22
+" Maintainer: Going to be Darrick Wiebe
+" Last Change: 2015 Jun 09
" Only load this indent file when no other was loaded.
if exists("b:did_indent")
@@ -12,5 +12,7 @@ let b:did_indent = 1
" C indenting is not too bad.
setlocal cindent
setlocal cinoptions+=j1,J1
+setlocal cinkeys-=0#
+setlocal cinkeys+=0]
let b:undo_indent = "setl cin<"
diff --git a/runtime/indent/zsh.vim b/runtime/indent/zsh.vim
index c5580a10b1..8e30c65c18 100644
--- a/runtime/indent/zsh.vim
+++ b/runtime/indent/zsh.vim
@@ -1,7 +1,10 @@
" Vim indent file
-" Language: Zsh Shell Script
-" Maintainer: Nikolai Weibull <now@bitwi.se>
-" Latest Revision: 2006-04-19
+" Language: Zsh shell script
+" Maintainer: Christian Brabandt <cb@256bit.org>
+" Previous Maintainer: Nikolai Weibull <now@bitwi.se>
+" Latest Revision: 2015-05-29
+" License: Vim (see :h license)
+" Repository: https://github.com/chrisbra/vim-zsh
if exists("b:did_indent")
finish
diff --git a/runtime/optwin.vim b/runtime/optwin.vim
index d1ab204180..dde5dd0c61 100644
--- a/runtime/optwin.vim
+++ b/runtime/optwin.vim
@@ -576,10 +576,6 @@ if has("gui")
endif
call append("$", "guifontwide\tlist of font names to be used for double-wide characters")
call <SID>OptionG("gfw", &gfw)
- if has("mac")
- call append("$", "antialias\tuse smooth, antialiased fonts")
- call <SID>BinOptionG("anti", &anti)
- endif
call append("$", "guioptions\tlist of flags that specify how the GUI works")
call <SID>OptionG("go", &go)
if has("gui_gtk")
@@ -930,6 +926,9 @@ call <SID>BinOptionL("bin")
call append("$", "endofline\tlast line in the file has an end-of-line")
call append("$", "\t(local to buffer)")
call <SID>BinOptionL("eol")
+call append("$", "fixeol\tfixes missing end-of-line at end of text file")
+call append("$", "\t(local to buffer)")
+call <SID>BinOptionL("fixeol")
if has("multi_byte")
call append("$", "bomb\tprepend a Byte Order Mark to the file")
call append("$", "\t(local to buffer)")
diff --git a/runtime/plugin/getscriptPlugin.vim b/runtime/plugin/getscriptPlugin.vim
deleted file mode 100644
index fb0fbeab7b..0000000000
--- a/runtime/plugin/getscriptPlugin.vim
+++ /dev/null
@@ -1,41 +0,0 @@
-" ---------------------------------------------------------------------
-" getscriptPlugin.vim
-" Author: Charles E. Campbell
-" Date: Nov 29, 2013
-" Installing: :help glvs-install
-" Usage: :help glvs
-"
-" GetLatestVimScripts: 642 1 :AutoInstall: getscript.vim
-"
-" (Rom 15:11 WEB) Again, "Praise the Lord, all you Gentiles! Let
-" all the peoples praise Him."
-" ---------------------------------------------------------------------
-" Initialization: {{{1
-" if you're sourcing this file, surely you can't be
-" expecting vim to be in its vi-compatible mode
-if exists("g:loaded_getscriptPlugin")
- finish
-endif
-if &cp
- if &verbose
- echo "GetLatestVimScripts is not vi-compatible; not loaded (you need to set nocp)"
- endif
- finish
-endif
-let g:loaded_getscriptPlugin = "v36"
-let s:keepcpo = &cpo
-set cpo&vim
-
-" ---------------------------------------------------------------------
-" Public Interface: {{{1
-com! -nargs=0 GetLatestVimScripts call getscript#GetLatestVimScripts()
-com! -nargs=0 GetScripts call getscript#GetLatestVimScripts()
-silent! com -nargs=0 GLVS call getscript#GetLatestVimScripts()
-
-" ---------------------------------------------------------------------
-" Restore Options: {{{1
-let &cpo= s:keepcpo
-unlet s:keepcpo
-
-" ---------------------------------------------------------------------
-" vim: ts=8 sts=2 fdm=marker nowrap
diff --git a/runtime/plugin/shada.vim b/runtime/plugin/shada.vim
new file mode 100644
index 0000000000..ae08e01dcb
--- /dev/null
+++ b/runtime/plugin/shada.vim
@@ -0,0 +1,39 @@
+if exists('g:loaded_shada_plugin')
+ finish
+endif
+let g:loaded_shada_plugin = 1
+
+augroup ShaDaCommands
+ autocmd!
+ autocmd BufReadCmd *.shada,*.shada.tmp.[a-z]
+ \ :if !empty(v:cmdarg)|throw '++opt not supported'|endif
+ \ |call setline('.', shada#get_strings(readfile(expand('<afile>'),'b')))
+ \ |setlocal filetype=shada
+ autocmd FileReadCmd *.shada,*.shada.tmp.[a-z]
+ \ :if !empty(v:cmdarg)|throw '++opt not supported'|endif
+ \ |call append("'[", shada#get_strings(readfile(expand('<afile>'), 'b')))
+ autocmd BufWriteCmd *.shada,*.shada.tmp.[a-z]
+ \ :if !empty(v:cmdarg)|throw '++opt not supported'|endif
+ \ |if writefile(shada#get_binstrings(getline(1, '$')),
+ \expand('<afile>'), 'b') == 0
+ \ | let &l:modified = (expand('<afile>') is# bufname(+expand('<abuf>'))
+ \? 0
+ \: stridx(&cpoptions, '+') != -1)
+ \ |endif
+ autocmd FileWriteCmd *.shada,*.shada.tmp.[a-z]
+ \ :if !empty(v:cmdarg)|throw '++opt not supported'|endif
+ \ |call writefile(
+ \shada#get_binstrings(getline(min([line("'["), line("']")]),
+ \max([line("'["), line("']")]))),
+ \expand('<afile>'),
+ \'b')
+ autocmd FileAppendCmd *.shada,*.shada.tmp.[a-z]
+ \ :if !empty(v:cmdarg)|throw '++opt not supported'|endif
+ \ |call writefile(
+ \shada#get_binstrings(getline(min([line("'["), line("']")]),
+ \max([line("'["), line("']")]))),
+ \expand('<afile>'),
+ \'ab')
+ autocmd SourceCmd *.shada,*.shada.tmp.[a-z]
+ \ :execute 'rshada' fnameescape(expand('<afile>'))
+augroup END
diff --git a/runtime/syntax/cpp.vim b/runtime/syntax/cpp.vim
index 04fc73342c..15f0cbb4ff 100644
--- a/runtime/syntax/cpp.vim
+++ b/runtime/syntax/cpp.vim
@@ -63,7 +63,7 @@ if version >= 508 || !exists("did_cpp_syntax_inits")
HiLink cppStructure Structure
HiLink cppBoolean Boolean
HiLink cppConstant Constant
- HiLink cppRawDelimiter Delimiter
+ HiLink cppRawStringDelimiter Delimiter
HiLink cppRawString String
delcommand HiLink
endif
diff --git a/runtime/syntax/css.vim b/runtime/syntax/css.vim
index c6fc6a7ae2..51758ca98f 100644
--- a/runtime/syntax/css.vim
+++ b/runtime/syntax/css.vim
@@ -6,7 +6,7 @@
" Nikolai Weibull (Add CSS2 support)
" Maintainer: Jules Wang <w.jq0722@gmail.com>
" URL: https://github.com/JulesWang/css.vim
-" Last Change: 2013 Nov.27
+" Last Change: 2015 Apr.17
" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
@@ -26,18 +26,19 @@ set cpo&vim
syn case ignore
-" All HTML4 tags
-syn keyword cssTagName abbr acronym address applet area a b base
-syn keyword cssTagName basefont bdo big blockquote body br button
-syn keyword cssTagName caption center cite code col colgroup dd del
-syn keyword cssTagName dfn dir div dl dt em fieldset font form frame
-syn keyword cssTagName frameset h1 h2 h3 h4 h5 h6 head hr html img i
-syn keyword cssTagName iframe img input ins isindex kbd label legend li
-syn keyword cssTagName link map menu meta noframes noscript ol optgroup
-syn keyword cssTagName option p param pre q s samp script select small
-syn keyword cssTagName span strike strong style sub sup table tbody td
-syn keyword cssTagName textarea tfoot th thead title tr tt ul u var
+" HTML4 tags
+syn keyword cssTagName abbr address area a b base
+syn keyword cssTagName bdo blockquote body br button
+syn keyword cssTagName caption cite code col colgroup dd del
+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 span strong sub sup tbody td
+syn keyword cssTagName textarea tfoot th thead title tr ul u var
syn keyword cssTagName object svg
+syn match cssTagName /\<select\>\|\<style\>\|\<table\>/
" 34 HTML5 tags
syn keyword cssTagName article aside audio bdi canvas command data
@@ -47,8 +48,8 @@ syn keyword cssTagName output progress rt rp ruby section
syn keyword cssTagName source summary time track video wbr
" Tags not supported in HTML5
-syn keyword cssDeprecated acronym applet basefont big center dir
-syn keyword cssDeprecated font frame frameset noframes strike tt
+" acronym applet basefont big center dir
+" font frame frameset noframes strike tt
syn match cssTagName "\*"
@@ -70,13 +71,13 @@ endtry
" digits
syn match cssValueInteger contained "[-+]\=\d\+" contains=cssUnitDecorators
syn match cssValueNumber contained "[-+]\=\d\+\(\.\d*\)\=" contains=cssUnitDecorators
-syn match cssValueLength contained "[-+]\=\d\+\(\.\d*\)\=\(%\|mm\|cm\|in\|pt\|pc\|em\|ex\|px\|rem\|dpi\|dppx\|dpcm\)" contains=cssUnitDecorators
-syn match cssValueAngle contained "[-+]\=\d\+\(\.\d*\)\=\(deg\|grad\|rad\)" contains=cssUnitDecorators
-syn match cssValueTime contained "+\=\d\+\(\.\d*\)\=\(ms\|s\)" contains=cssUnitDecorators
-syn match cssValueFrequency contained "+\=\d\+\(\.\d*\)\=\(Hz\|kHz\)" contains=cssUnitDecorators
+syn match cssValueLength contained "[-+]\=\d\+\(\.\d*\)\=\(%\|mm\|cm\|in\|pt\|pc\|em\|ex\|px\|rem\|dpi\|dppx\|dpcm\)\>" contains=cssUnitDecorators
+syn match cssValueAngle contained "[-+]\=\d\+\(\.\d*\)\=\(deg\|grad\|rad\)\>" contains=cssUnitDecorators
+syn match cssValueTime contained "+\=\d\+\(\.\d*\)\=\(ms\|s\)\>" contains=cssUnitDecorators
+syn match cssValueFrequency contained "+\=\d\+\(\.\d*\)\=\(Hz\|kHz\)\>" contains=cssUnitDecorators
-syn match cssIncludeKeyword /@\(-[a-z]+-\)\=\(media\|keyframes\|import\|charset\|namespace\|page\)/ contained
+syn match cssIncludeKeyword /@\(-[a-z]\+-\)\=\(media\|keyframes\|import\|charset\|namespace\|page\)/ contained
" @media
syn region cssInclude start=/@media\>/ end=/\ze{/ skipwhite skipnl contains=cssMediaProp,cssValueLength,cssMediaKeyword,cssValueInteger,cssMediaAttr,cssVendor,cssMediaType,cssIncludeKeyword,cssMediaComma,cssComment nextgroup=cssMediaBlock
syn keyword cssMediaType contained screen print aural braille embossed handheld projection tty tv speech all contained skipwhite skipnl
@@ -86,7 +87,7 @@ syn match cssMediaComma "," skipwhite skipnl contained
" Reference: http://www.w3.org/TR/css3-mediaqueries/
syn keyword cssMediaProp contained width height orientation scan grid
-syn match cssMediaProp contained /\(\(device\)-\)\=aspect-ratio/
+syn match cssMediaProp contained /\(\(max\|min\)-\)\=\(\(device\)-\)\=aspect-ratio/
syn match cssMediaProp contained /\(\(max\|min\)-\)\=device-pixel-ratio/
syn match cssMediaProp contained /\(\(max\|min\)-\)\=device-\(height\|width\)/
syn match cssMediaProp contained /\(\(max\|min\)-\)\=\(height\|width\|resolution\|monochrome\|color\(-index\)\=\)/
@@ -104,7 +105,7 @@ syn keyword cssPageProp contained orphans widows
" @keyframe
" http://www.w3.org/TR/css3-animations/#keyframes
-syn match cssKeyFrame "@\(-[a-z]+-\)\=keyframes\>[^{]*{\@=" nextgroup=cssKeyFrameWrap contains=cssVendor,cssIncludeKeyword skipwhite skipnl transparent
+syn match cssKeyFrame "@\(-[a-z]\+-\)\=keyframes\>[^{]*{\@=" nextgroup=cssKeyFrameWrap contains=cssVendor,cssIncludeKeyword skipwhite skipnl transparent
syn region cssKeyFrameWrap contained transparent matchgroup=cssBraces start="{" end="}" contains=cssKeyFrameSelector
syn match cssKeyFrameSelector /\(\d*%\|from\|to\)\=/ contained skipwhite skipnl nextgroup=cssDefinition
@@ -116,15 +117,27 @@ syn region cssInclude start=/@namespace\>/ end=/\ze;/ transparent contains=cssSt
" @font-face
" http://www.w3.org/TR/css3-fonts/#at-font-face-rule
syn match cssFontDescriptor "@font-face\>" nextgroup=cssFontDescriptorBlock skipwhite skipnl
-syn region cssFontDescriptorBlock contained transparent matchgroup=cssBraces start="{" end="}" contains=cssComment,cssError,cssUnicodeEscape,cssFontProp,cssFontAttr,cssCommonAttr,cssStringQ,cssStringQQ,cssFontDescriptorProp,cssValue.*,cssFontDescriptorFunction,cssUnicodeRange,cssFontDescriptorAttr
-"syn match cssFontDescriptorProp contained "\<\(unicode-range\|unit-per-em\|panose-1\|cap-height\|x-height\|definition-src\)\>"
-"syn keyword cssFontDescriptorProp contained src stemv stemh slope ascent descent widths bbox baseline centerline mathline topline
+syn region cssFontDescriptorBlock contained transparent matchgroup=cssBraces start="{" end="}" contains=cssComment,cssError,cssUnicodeEscape,cssCommonAttr,cssFontDescriptorProp,cssValue.*,cssFontDescriptorFunction,cssFontDescriptorAttr,cssNoise
+
+syn match cssFontDescriptorProp contained "\<font-family\>"
syn keyword cssFontDescriptorProp contained src
+syn match cssFontDescriptorProp contained "\<font-\(style\|weight\|stretch\)\>"
syn match cssFontDescriptorProp contained "\<unicode-range\>"
-syn keyword cssFontDescriptorAttr contained all
+syn match cssFontDescriptorProp contained "\<font-\(variant\|feature-settings\)\>"
+
+" src functions
syn region cssFontDescriptorFunction contained matchgroup=cssFunctionName start="\<\(uri\|url\|local\|format\)\s*(" end=")" contains=cssStringQ,cssStringQQ oneline keepend
-syn match cssUnicodeRange contained "U+[0-9A-Fa-f?]\+"
-syn match cssUnicodeRange contained "U+\x\+-\x\+"
+" font-sytle and font-weight attributes
+syn keyword cssFontDescriptorAttr contained normal italic oblique bold
+" font-stretch attributes
+syn match cssFontDescriptorAttr contained "\<\(\(ultra\|extra\|semi\)-\)\=\(condensed\|expanded\)\>"
+" unicode-range attributes
+syn match cssFontDescriptorAttr contained "U+[0-9A-Fa-f?]\+"
+syn match cssFontDescriptorAttr contained "U+\x\+-\x\+"
+" font-feature-settings attributes
+syn keyword cssFontDescriptorAttr contained on off
+
+
" The 16 basic color names
syn keyword cssColor contained aqua black blue fuchsia gray green lime maroon navy olive purple red silver teal yellow
@@ -133,23 +146,23 @@ syn keyword cssColor contained aqua black blue fuchsia gray green lime maroon na
syn keyword cssColor contained aliceblue antiquewhite aquamarine azure
syn keyword cssColor contained beige bisque blanchedalmond blueviolet brown burlywood
syn keyword cssColor contained cadetblue chartreuse chocolate coral cornflowerblue cornsilk crimson cyan
-syn match cssColor contained /dark\(blue\|cyan\|goldenrod\|gray\|green\|grey\|khaki\)/
-syn match cssColor contained /dark\(magenta\|olivegreen\|orange\|orchid\|red\|salmon\|seagreen\)/
-syn match cssColor contained /darkslate\(blue\|gray\|grey\)/
-syn match cssColor contained /dark\(turquoise\|violet\)/
+syn match cssColor contained /\<dark\(blue\|cyan\|goldenrod\|gray\|green\|grey\|khaki\)\>/
+syn match cssColor contained /\<dark\(magenta\|olivegreen\|orange\|orchid\|red\|salmon\|seagreen\)\>/
+syn match cssColor contained /\<darkslate\(blue\|gray\|grey\)\>/
+syn match cssColor contained /\<dark\(turquoise\|violet\)\>/
syn keyword cssColor contained deeppink deepskyblue dimgray dimgrey dodgerblue firebrick
syn keyword cssColor contained floralwhite forestgreen gainsboro ghostwhite gold
syn keyword cssColor contained goldenrod greenyellow grey honeydew hotpink
syn keyword cssColor contained indianred indigo ivory khaki lavender lavenderblush lawngreen
syn keyword cssColor contained lemonchiffon limegreen linen magenta
-syn match cssColor contained /light\(blue\|coral\|cyan\|goldenrodyellow\|gray\|green\)/
-syn match cssColor contained /light\(grey\|pink\|salmon\|seagreen\|skyblue\|yellow\)/
-syn match cssColor contained /light\(slategray\|slategrey\|steelblue\)/
-syn match cssColor contained /medium\(aquamarine\|blue\|orchid\|purple\|seagreen\)/
-syn match cssColor contained /medium\(slateblue\|springgreen\|turquoise\|violetred\)/
+syn match cssColor contained /\<light\(blue\|coral\|cyan\|goldenrodyellow\|gray\|green\)\>/
+syn match cssColor contained /\<light\(grey\|pink\|salmon\|seagreen\|skyblue\|yellow\)\>/
+syn match cssColor contained /\<light\(slategray\|slategrey\|steelblue\)\>/
+syn match cssColor contained /\<medium\(aquamarine\|blue\|orchid\|purple\|seagreen\)\>/
+syn match cssColor contained /\<medium\(slateblue\|springgreen\|turquoise\|violetred\)\>/
syn keyword cssColor contained midnightblue mintcream mistyrose moccasin navajowhite
syn keyword cssColor contained oldlace olivedrab orange orangered orchid
-syn match cssColor contained /pale\(goldenrod\|green\|turquoise\|violetred\)/
+syn match cssColor contained /\<pale\(goldenrod\|green\|turquoise\|violetred\)\>/
syn keyword cssColor contained papayawhip peachpuff peru pink plum powderblue
syn keyword cssColor contained rosybrown royalblue saddlebrown salmon sandybrown
syn keyword cssColor contained seagreen seashell sienna skyblue slateblue
@@ -167,11 +180,12 @@ syn case ignore
syn match cssImportant contained "!\s*important\>"
syn match cssColor contained "\<transparent\>"
+syn match cssColor contained "\<currentColor\>"
syn match cssColor contained "\<white\>"
syn match cssColor contained "#[0-9A-Fa-f]\{3\}\>" contains=cssUnitDecorators
syn match cssColor contained "#[0-9A-Fa-f]\{6\}\>" contains=cssUnitDecorators
-syn region cssURL contained matchgroup=cssFunctionName start="\<url\s*(" end=")" oneline extend
+syn region cssURL contained matchgroup=cssFunctionName start="\<url\s*(" end=")" contains=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
@@ -196,6 +210,9 @@ syn keyword cssAnimationAttr contained forwards backwards both
" animation-play-state attributes
syn keyword cssAnimationAttr contained running paused
+
+" animation-iteration-count attributes
+syn keyword cssAnimationAttr contained infinite
"------------------------------------------------
" CSS Backgrounds and Borders Module Level 3
" http://www.w3.org/TR/css3-background/
@@ -253,7 +270,7 @@ syn keyword cssDimensionProp contained width
syn match cssFlexibleBoxProp contained "\<box-\(align\|direction\|flex\|ordinal-group\|orient\|pack\|shadow\|sizing\)\>"
syn keyword cssFlexibleBoxAttr contained start end baseline
syn keyword cssFlexibleBoxAttr contained reverse
-syn keyword cssFlexibleBoxAttr contained single mulitple
+syn keyword cssFlexibleBoxAttr contained single multiple
syn keyword cssFlexibleBoxAttr contained horizontal
syn match cssFlexibleBoxAttr contained "\<vertical\(-align\)\@!\>" "escape vertical-align
syn match cssFlexibleBoxAttr contained "\<\(inline\|block\)-axis\>"
@@ -261,6 +278,7 @@ syn match cssFlexibleBoxAttr contained "\<\(inline\|block\)-axis\>"
" CSS Fonts Module Level 3
" http://www.w3.org/TR/css-fonts-3/
syn match cssFontProp contained "\<font\(-\(family\|\|feature-settings\|kerning\|language-override\|size\(-adjust\)\=\|stretch\|style\|synthesis\|variant\(-\(alternates\|caps\|east-asian\|ligatures\|numeric\|position\)\)\=\|weight\)\)\=\>"
+
" font attributes
syn keyword cssFontAttr contained icon menu caption
syn match cssFontAttr contained "\<small-\(caps\|caption\)\>"
@@ -268,27 +286,21 @@ syn match cssFontAttr contained "\<message-box\>"
syn match cssFontAttr contained "\<status-bar\>"
syn keyword cssFontAttr contained larger smaller
syn match cssFontAttr contained "\<\(x\{1,2\}-\)\=\(large\|small\)\>"
-
" 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 Unicode Verdana Webdings Wingdings York Zapf
+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
-
" font-feature-settings attributes
syn keyword cssFontAttr contained on off
-
" font-stretch attributes
syn match cssFontAttr contained "\<\(\(ultra\|extra\|semi\)-\)\=\(condensed\|expanded\)\>"
-
" font-style attributes
syn keyword cssFontAttr contained italic oblique
-
-" font-variant-caps attributes
-syn match cssFontAttr contained "\<\(all-\)\=\(small-\|petite-\|titling-\)caps\>"
-syn keyword cssFontAttr contained unicase
-
+" font-synthesis attributes
+syn keyword cssFontAttr contained weight style
" font-weight attributes
syn keyword cssFontAttr contained bold bolder lighter
+" TODO: font-variant-* attributes
"------------------------------------------------
" Webkit specific property/attributes
@@ -448,7 +460,7 @@ syn match cssMobileTextProp contained "\<text-size-adjust\>"
syn match cssBraces contained "[{}]"
syn match cssError contained "{@<>"
-syn region cssDefinition transparent matchgroup=cssBraces start='{' end='}' contains=cssAttrRegion,css.*Prop,cssComment,cssValue.*,cssColor,cssURL,cssImportant,cssError,cssStringQ,cssStringQQ,cssFunction,cssUnicodeEscape,cssVendor,cssDefinition,cssHacks keepend fold
+syn region cssDefinition transparent matchgroup=cssBraces start='{' end='}' contains=cssAttrRegion,css.*Prop,cssComment,cssValue.*,cssColor,cssURL,cssImportant,cssError,cssStringQ,cssStringQQ,cssFunction,cssUnicodeEscape,cssVendor,cssDefinition,cssHacks,cssNoise fold
syn match cssBraceError "}"
syn match cssAttrComma ","
@@ -466,6 +478,9 @@ syn match cssPseudoClassId contained "\<selection\>"
syn match cssPseudoClassId contained "\<focus\(-inner\)\=\>"
syn match cssPseudoClassId contained "\<\(input-\)\=placeholder\>"
+" Misc highlight groups
+syntax match cssUnitDecorators /\(#\|-\|%\|mm\|cm\|in\|pt\|pc\|em\|ex\|px\|ch\|rem\|vh\|vw\|vmin\|vmax\|dpi\|dppx\|dpcm\|Hz\|kHz\|s\|ms\|deg\|grad\|rad\)/ contained
+syntax match cssNoise contained /\(:\|;\|\/\)/
" Comment
syn region cssComment start="/\*" end="\*/" contains=@Spell fold
@@ -487,17 +502,13 @@ syn match cssVendor contained "\(-\(webkit\|moz\|o\|ms\)-\)"
" http://www.paulirish.com/2009/browser-specific-css-hacks/
syn match cssHacks contained /\(_\|*\)/
-" Misc highlight groups
-syntax match cssUnitDecorators /\(#\|-\|%\|mm\|cm\|in\|pt\|pc\|em\|ex\|px\|rem\|dpi\|dppx\|dpcm\|Hz\|kHz\|s\|ms\|deg\|grad\|rad\)/ contained
-syntax match cssNoise contained /\(:\|;\|\/\)/
-
" Attr Enhance
" Some keywords are both Prop and Attr, so we have to handle them
-syn region cssAttrRegion start=/:/ end=/;/ contained keepend contains=css.*Attr,cssColor,cssImportant,cssValue.*,cssFunction,cssString.*,cssURL,cssComment,cssUnicodeEscape,cssVendor,cssError,cssAttrComma,cssNoise
+syn region cssAttrRegion start=/:/ end=/\ze\(;\|)\|}\)/ contained contains=css.*Attr,cssColor,cssImportant,cssValue.*,cssFunction,cssString.*,cssURL,cssComment,cssUnicodeEscape,cssVendor,cssError,cssAttrComma,cssNoise
" Hack for transition
-" The 'transition' Prop has Props after ':'.
-syn region cssAttrRegion start=/transition\s*:/ end=/;/ contained keepend contains=css.*Prop,css.*Attr,cssColor,cssImportant,cssValue.*,cssFunction,cssString.*,cssURL,cssComment,cssUnicodeEscape,cssVendor,cssError,cssAttrComma,cssNoise
+" 'transition' has Props after ':'.
+syn region cssAttrRegion start=/transition\s*:/ end=/\ze\(;\|)\|}\)/ contained contains=css.*Prop,css.*Attr,cssColor,cssImportant,cssValue.*,cssFunction,cssString.*,cssURL,cssComment,cssUnicodeEscape,cssVendor,cssError,cssAttrComma,cssNoise
if main_syntax == "css"
@@ -635,7 +646,7 @@ if version >= 508 || !exists("did_css_syn_inits")
HiLink cssAttr Constant
HiLink cssUnitDecorators Number
HiLink cssNoise Noise
- HiLink atKeyword Comment
+ HiLink atKeyword PreProc
delcommand HiLink
endif
diff --git a/runtime/syntax/debchangelog.vim b/runtime/syntax/debchangelog.vim
index 6206fa388c..ed3d024499 100644
--- a/runtime/syntax/debchangelog.vim
+++ b/runtime/syntax/debchangelog.vim
@@ -3,7 +3,7 @@
" Maintainer: Debian Vim Maintainers <pkg-vim-maintainers@lists.alioth.debian.org>
" Former Maintainers: Gerfried Fuchs <alfie@ist.org>
" Wichert Akkerman <wakkerma@debian.org>
-" Last Change: 2014 Jul 11
+" Last Change: 2015 Apr 30
" URL: http://anonscm.debian.org/hg/pkg-vim/vim/raw-file/unstable/runtime/syntax/debchangelog.vim
" Standard syntax initialization
@@ -16,10 +16,14 @@ endif
" Case doesn't matter for us
syn case ignore
+let urgency='urgency=\(low\|medium\|high\|critical\)\( [^[:space:],][^,]*\)\='
+let binNMU='binary-only=yes'
+
" Define some common expressions we can use later on
syn match debchangelogName contained "^[[:alnum:]][[:alnum:].+-]\+ "
-syn match debchangelogUrgency contained "; urgency=\(low\|medium\|high\|critical\|emergency\)\( \S.*\)\="
-syn match debchangelogTarget contained "\v %(frozen|unstable|%(testing|%(old)=stable)%(-proposed-updates|-security)=|experimental|squeeze-%(backports%(-sloppy)=|volatile)|wheezy-backports|%(devel|lucid|precise|trusty|utopic)%(-%(security|proposed|updates|backports|commercial|partner))=)+"
+exe 'syn match debchangelogFirstKV contained "; \('.urgency.'\|'.binNMU.'\)"'
+exe 'syn match debchangelogOtherKV contained ", \('.urgency.'\|'.binNMU.'\)"'
+syn match debchangelogTarget contained "\v %(frozen|unstable|sid|%(testing|%(old)=stable)%(-proposed-updates|-security)=|experimental|squeeze-%(backports%(-sloppy)=|volatile|lts|security)|wheezy-%(backports%(-sloppy)=|security)|jessie%(-backports|-security)=|stretch|%(devel|lucid|precise|trusty|utopic)%(-%(security|proposed|updates|backports|commercial|partner))=)+"
syn match debchangelogVersion contained "(.\{-})"
syn match debchangelogCloses contained "closes:\_s*\(bug\)\=#\=\_s\=\d\+\(,\_s*\(bug\)\=#\=\_s\=\d\+\)*"
syn match debchangelogLP contained "\clp:\s\+#\d\+\(,\s*#\d\+\)*"
@@ -27,7 +31,7 @@ syn match debchangelogEmail contained "[_=[:alnum:].+-]\+@[[:alnum:]./\-]\+"
syn match debchangelogEmail contained "<.\{-}>"
" Define the entries that make up the changelog
-syn region debchangelogHeader start="^[^ ]" end="$" contains=debchangelogName,debchangelogUrgency,debchangelogTarget,debchangelogVersion oneline
+syn region debchangelogHeader start="^[^ ]" end="$" contains=debchangelogName,debchangelogFirstKV,debchangelogOtherKV,debchangelogTarget,debchangelogVersion,debchangelogBinNMU oneline
syn region debchangelogFooter start="^ [^ ]" end="$" contains=debchangelogEmail oneline
syn region debchangelogEntry start="^ " end="$" contains=debchangelogCloses,debchangelogLP oneline
@@ -45,7 +49,8 @@ if version >= 508 || !exists("did_debchangelog_syn_inits")
HiLink debchangelogEntry Normal
HiLink debchangelogCloses Statement
HiLink debchangelogLP Statement
- HiLink debchangelogUrgency Identifier
+ HiLink debchangelogFirstKV Identifier
+ HiLink debchangelogOtherKV Identifier
HiLink debchangelogName Comment
HiLink debchangelogVersion Identifier
HiLink debchangelogTarget Identifier
diff --git a/runtime/syntax/debcontrol.vim b/runtime/syntax/debcontrol.vim
index 5d9d45d025..6d140d9bd9 100644
--- a/runtime/syntax/debcontrol.vim
+++ b/runtime/syntax/debcontrol.vim
@@ -3,7 +3,7 @@
" Maintainer: Debian Vim Maintainers <pkg-vim-maintainers@lists.alioth.debian.org>
" Former Maintainers: Gerfried Fuchs <alfie@ist.org>
" Wichert Akkerman <wakkerma@debian.org>
-" Last Change: 2014 May 01
+" Last Change: 2014 Oct 08
" URL: http://anonscm.debian.org/hg/pkg-vim/vim/raw-file/unstable/runtime/syntax/debcontrol.vim
" Standard syntax initialization
@@ -50,7 +50,7 @@ syn match debcontrolDmUpload contained "\cyes"
syn match debcontrolHTTPUrl contained "\vhttps?://[[:alnum:]][-[:alnum:]]*[[:alnum:]]?(\.[[:alnum:]][-[:alnum:]]*[[:alnum:]]?)*\.[[:alpha:]][-[:alnum:]]*[[:alpha:]]?(:\d+)?(/[^[:space:]]*)?$"
syn match debcontrolVcsSvn contained "\vsvn%(\+ssh)?://[[:alnum:]][-[:alnum:]]*[[:alnum:]]?(\.[[:alnum:]][-[:alnum:]]*[[:alnum:]]?)*\.[[:alpha:]][-[:alnum:]]*[[:alpha:]]?(:\d+)?(/[^[:space:]]*)?$"
syn match debcontrolVcsCvs contained "\v%(\-d *)?:pserver:[^@]+\@[[:alnum:]][-[:alnum:]]*[[:alnum:]]?(\.[[:alnum:]][-[:alnum:]]*[[:alnum:]]?)*\.[[:alpha:]][-[:alnum:]]*[[:alpha:]]?:/[^[:space:]]*%( [^[:space:]]+)?$"
-syn match debcontrolVcsGit contained "\v%(git|http)://[[:alnum:]][-[:alnum:]]*[[:alnum:]]?(\.[[:alnum:]][-[:alnum:]]*[[:alnum:]]?)*\.[[:alpha:]][-[:alnum:]]*[[:alpha:]]?(:\d+)?(/[^[:space:]]*)?%(\s+-b\s+[^ ~^:?*[\\]+)?$"
+syn match debcontrolVcsGit contained "\v%(git|https?)://[[:alnum:]][-[:alnum:]]*[[:alnum:]]?(\.[[:alnum:]][-[:alnum:]]*[[:alnum:]]?)*\.[[:alpha:]][-[:alnum:]]*[[:alpha:]]?(:\d+)?(/[^[:space:]]*)?%(\s+-b\s+[^ ~^:?*[\\]+)?$"
" An email address
syn match debcontrolEmail "[_=[:alnum:]\.+-]\+@[[:alnum:]\./\-]\+"
diff --git a/runtime/syntax/debsources.vim b/runtime/syntax/debsources.vim
index e877b06ae4..c8d110c77b 100644
--- a/runtime/syntax/debsources.vim
+++ b/runtime/syntax/debsources.vim
@@ -2,7 +2,7 @@
" Language: Debian sources.list
" Maintainer: Debian Vim Maintainers <pkg-vim-maintainers@lists.alioth.debian.org>
" Former Maintainer: Matthijs Mohlmann <matthijs@cacholong.nl>
-" Last Change: 2014 Jul 11
+" Last Change: 2015 May 25
" URL: http://anonscm.debian.org/hg/pkg-vim/vim/raw-file/unstable/runtime/syntax/debsources.vim
" Standard syntax initialization
@@ -21,15 +21,35 @@ syn match debsourcesKeyword /\(deb-src\|deb\|main\|contrib\|non-free\|res
" Match comments
syn match debsourcesComment /#.*/ contains=@Spell
+let s:cpo = &cpo
+set cpo-=C
+let s:supported = [
+ \ 'oldstable', 'stable', 'testing', 'unstable', 'experimental',
+ \ 'squeeze', 'wheezy', 'jessie', 'stretch', 'sid', 'rc-buggy',
+ \
+ \ 'precise', 'trusty', 'utopic', 'vivid', 'wily', 'devel'
+ \ ]
+let s:unsupported = [
+ \ 'buzz', 'rex', 'bo', 'hamm', 'slink', 'potato',
+ \ 'woody', 'sarge', 'etch', 'lenny',
+ \
+ \ 'warty', 'hoary', 'breezy', 'dapper', 'edgy', 'feisty',
+ \ 'gutsy', 'hardy', 'intrepid', 'jaunty', 'karmic', 'lucid',
+ \ 'maverick', 'natty', 'oneiric', 'quantal', 'raring', 'saucy'
+ \ ]
+let &cpo=s:cpo
+
" Match uri's
syn match debsourcesUri +\(http://\|ftp://\|[rs]sh://\|debtorrent://\|\(cdrom\|copy\|file\):\)[^' <>"]\++
-syn match debsourcesDistrKeyword +\([[:alnum:]_./]*\)\(squeeze\|wheezy\|jessie\|\(old\)\=stable\|testing\|unstable\|sid\|rc-buggy\|experimental\|devel\|lucid\|precise\|trusty\|utopic\)\([-[:alnum:]_./]*\)+
+exe 'syn match debsourcesDistrKeyword +\([[:alnum:]_./]*\)\('. join(s:supported, '\|'). '\)\([-[:alnum:]_./]*\)+'
+exe 'syn match debsourcesUnsupportedDistrKeyword +\([[:alnum:]_./]*\)\('. join(s:unsupported, '\|') .'\)\([-[:alnum:]_./]*\)+'
" Associate our matches and regions with pretty colours
-hi def link debsourcesLine Error
-hi def link debsourcesKeyword Statement
-hi def link debsourcesDistrKeyword Type
-hi def link debsourcesComment Comment
-hi def link debsourcesUri Constant
+hi def link debsourcesLine Error
+hi def link debsourcesKeyword Statement
+hi def link debsourcesDistrKeyword Type
+hi def link debsourcesUnsupportedDistrKeyword WarningMsg
+hi def link debsourcesComment Comment
+hi def link debsourcesUri Constant
let b:current_syntax = "debsources"
diff --git a/runtime/syntax/groovy.vim b/runtime/syntax/groovy.vim
index 2056bd16d0..c745960bd5 100644
--- a/runtime/syntax/groovy.vim
+++ b/runtime/syntax/groovy.vim
@@ -157,7 +157,7 @@ syn match groovyOperator "\.\."
syn match groovyOperator "<\{2,3}"
syn match groovyOperator ">\{2,3}"
syn match groovyOperator "->"
-syn match groovyExternal '^#!.*[/\\]groovy\>'
+syn match groovyLineComment '^\%1l#!.*' " Shebang line
syn match groovyExceptions "\<Exception\>\|\<[A-Z]\{1,}[a-zA-Z0-9]*Exception\>"
" Groovy JDK stuff
diff --git a/runtime/syntax/kconfig.vim b/runtime/syntax/kconfig.vim
index a6ceb1712a..c7a305b73c 100644
--- a/runtime/syntax/kconfig.vim
+++ b/runtime/syntax/kconfig.vim
@@ -1,6 +1,9 @@
" Vim syntax file
-" Maintainer: Nikolai Weibull <now@bitwi.se>
-" Latest Revision: 2009-05-25
+" Maintainer: Christian Brabandt <cb@256bit.org>
+" Previous Maintainer: Nikolai Weibull <now@bitwi.se>
+" Latest Revision: 2015-05-29
+" License: Vim (see :h license)
+" Repository: https://github.com/chrisbra/vim-kconfig
if exists("b:current_syntax")
finish
diff --git a/runtime/syntax/po.vim b/runtime/syntax/po.vim
index c09b960357..2ab13ac0b1 100644
--- a/runtime/syntax/po.vim
+++ b/runtime/syntax/po.vim
@@ -1,7 +1,7 @@
" Vim syntax file
" Language: po (gettext)
" Maintainer: Dwayne Bailey <dwayne@translate.org.za>
-" Last Change: 2012 Apr 30
+" Last Change: 2015 Jun 07
" Contributors: Dwayne Bailey (Most advanced syntax highlighting)
" Leonardo Fontenelle (Spell checking)
" Nam SungHyun <namsh@kldp.org> (Original maintainer)
@@ -52,6 +52,9 @@ syn match poCommentTranslator "^# .*$" contains=poCopyrightUnset
syn match poCommentAutomatic "^#\..*$"
syn match poCommentSources "^#:.*$"
syn match poCommentFlags "^#,.*$" contains=poFlagFuzzy
+syn match poDiffOld '\(^#| "[^{]*+}\|{+[^}]*+}\|{+[^}]*\|"$\)' contained
+syn match poDiffNew '\(^#| "[^{]*-}\|{-[^}]*-}\|{-[^}]*\|"$\)' contained
+syn match poCommentDiff "^#|.*$" contains=poDiffOld,poDiffNew
" Translations (also includes header fields as they appear in a translation msgstr)
syn region poCommentKDE start=+"_: +ms=s+1 end="\\n" end="\"\n^msgstr"me=s-1 contained
@@ -94,8 +97,11 @@ if version >= 508 || !exists("did_po_syn_inits")
HiLink poCommentAutomatic Comment
HiLink poCommentTranslator Comment
HiLink poCommentFlags Special
+ HiLink poCommentDiff Comment
HiLink poCopyrightUnset Todo
HiLink poFlagFuzzy Todo
+ HiLink poDiffOld Todo
+ HiLink poDiffNew Special
HiLink poObsolete Comment
HiLink poStatementMsgid Statement
diff --git a/runtime/syntax/rc.vim b/runtime/syntax/rc.vim
index c3feb97816..a2d5824d3e 100644
--- a/runtime/syntax/rc.vim
+++ b/runtime/syntax/rc.vim
@@ -1,7 +1,10 @@
" Vim syntax file
" Language: M$ Resource files (*.rc)
-" Maintainer: Heiko Erhardt <Heiko.Erhardt@munich.netsurf.de>
-" Last Change: 2001 May 09
+" Maintainer: Christian Brabandt
+" Last Change: 2015-05-29
+" Repository: https://github.com/chrisbra/vim-rc-syntax
+" License: Vim (see :h license)
+" Previous Maintainer: Heiko Erhardt <Heiko.Erhardt@munich.netsurf.de>
" This file is based on the c.vim
@@ -21,7 +24,7 @@ syn keyword rcMainObject MENU ACCELERATORS TOOLBAR DIALOG
syn keyword rcMainObject STRINGTABLE MESSAGETABLE RCDATA DLGINIT DESIGNINFO
syn keyword rcSubObject POPUP MENUITEM SEPARATOR
-syn keyword rcSubObject CONTROL LTEXT CTEXT EDITTEXT
+syn keyword rcSubObject CONTROL LTEXT CTEXT RTEXT EDITTEXT
syn keyword rcSubObject BUTTON PUSHBUTTON DEFPUSHBUTTON GROUPBOX LISTBOX COMBOBOX
syn keyword rcSubObject FILEVERSION PRODUCTVERSION FILEFLAGSMASK FILEFLAGS FILEOS
syn keyword rcSubObject FILETYPE FILESUBTYPE
diff --git a/runtime/syntax/shada.vim b/runtime/syntax/shada.vim
new file mode 100644
index 0000000000..e5325af5b0
--- /dev/null
+++ b/runtime/syntax/shada.vim
@@ -0,0 +1,125 @@
+if exists("b:current_syntax")
+ finish
+endif
+
+syntax match ShaDaEntryHeader
+ \ '^\u.\{-} with timestamp \d\{4}-\d\d-\d\dT\d\d:\d\d:\d\d:$'
+syntax match ShaDaEntryName '^\u.\{-}\ze with' contained
+ \ containedin=ShaDaEntryHeader
+syntax match ShaDaEntryTimestamp 'timestamp \zs\d\{4}-\d\d-\d\dT\d\d:\d\d:\d\d'
+ \ contained containedin=ShaDaEntryHeader
+syntax match ShaDaEntryTimestampNumber '\d\+' contained
+ \ containedin=ShaDaEntryTimestamp
+
+syntax match ShaDaComment '^\s*#.*$'
+
+syntax region ShaDaEntryMapLong start='^ % Key_* Description_* Value$'
+ \ end='^ %\|^\S'me=s-1 contains=ShaDaComment,ShaDaEntryMapLongEntryStart
+syntax region ShaDaEntryMapShort start='^ % Key_* Value$'
+ \ end='^ %\|^\S'me=s-1 contains=ShaDaComment,ShaDaEntryMapShortEntryStart
+syntax match ShaDaEntryMapHeader '^ % Key_* \(Description_* \)\?Value$'
+ \ contained containedin=ShaDaEntryMapLong,ShaDaEntryMapShort
+syntax match ShaDaEntryMapLongEntryStart '^ + 'hs=e-2,he=e-1
+ \ nextgroup=ShaDaEntryMapLongKey
+syntax match ShaDaEntryMapLongKey '\S\+ \+\ze\S'he=e-2 contained
+ \ nextgroup=ShaDaEntryMapLongDescription
+syntax match ShaDaEntryMapLongDescription '.\{-} \ze\S'he=e-2 contained
+ \ nextgroup=@ShaDaEntryMsgpackValue
+syntax match ShaDaEntryMapShortEntryStart '^ + 'hs=e-2,he=e-1 contained
+ \ nextgroup=ShaDaEntryMapShortKey
+syntax match ShaDaEntryMapShortKey '\S\+ \+\ze\S'he=e-2 contained
+ \ nextgroup=@ShaDaEntryMsgpackValue
+syntax match ShaDaEntryMapBinArrayStart '^ | - 'hs=e-4,he=e-1 contained
+ \ containedin=ShaDaEntryMapLong,ShaDaEntryMapShort
+ \ nextgroup=@ShaDaEntryMsgpackValue
+
+syntax region ShaDaEntryArray start='^ @ Description_* Value$'
+ \ end='^\S'me=s-1 keepend
+ \ contains=ShaDaComment,ShaDaEntryArrayEntryStart,ShaDaEntryArrayHeader
+syntax match ShaDaEntryArrayHeader '^ @ Description_* Value$' contained
+syntax match ShaDaEntryArrayEntryStart '^ - 'hs=e-2,he=e-1
+ \ nextgroup=ShaDaEntryArrayDescription
+syntax match ShaDaEntryArrayDescription '.\{-} \ze\S'he=e-2 contained
+ \ nextgroup=@ShaDaEntryMsgpackValue
+
+syntax match ShaDaEntryRawMsgpack '^ = ' nextgroup=@ShaDaEntryMsgpackValue
+
+syntax cluster ShaDaEntryMsgpackValue
+ \ add=ShaDaMsgpackKeyword,ShaDaMsgpackShaDaKeyword
+ \ add=ShaDaMsgpackInteger,ShaDaMsgpackCharacter,ShaDaMsgpackFloat
+ \ add=ShaDaMsgpackBinaryString,ShaDaMsgpackString,ShaDaMsgpackExt
+ \ add=ShaDaMsgpackArray,ShaDaMsgpackMap
+ \ add=ShaDaMsgpackMultilineArray
+syntax keyword ShaDaMsgpackKeyword contained NIL TRUE FALSE
+syntax keyword ShaDaMsgpackShaDaKeyword contained
+ \ CMD SEARCH EXPR INPUT DEBUG
+ \ CHARACTERWISE LINEWISE BLOCKWISE
+syntax region ShaDaMsgpackBinaryString matchgroup=ShaDaMsgpackStringQuotes
+ \ start='"' skip='\\"' end='"' contained keepend
+syntax match ShaDaMsgpackBinaryStringEscape '\\[\\0n"]'
+ \ contained containedin=ShaDaMsgpackBinaryString
+syntax match ShaDaMsgpackString '=' contained nextgroup=ShaDaMsgpackBinaryString
+syntax match ShaDaMsgpackExt '+(-\?\d\+)' contained
+ \ nextgroup=ShaDaMsgpackBinaryString
+syntax match ShaDaMsgpackExtType '-\?\d\+' contained containedin=ShaDaMsgpackExt
+syntax match ShaDaMsgpackCharacter /'.'/ contained
+syntax match ShaDaMsgpackInteger '-\?\%(0x\x\{,16}\|\d\+\)' contained
+syntax match ShaDaMsgpackFloat '-\?\d\+\.\d\+\%(e[+-]\?\d\+\)\?' contained
+syntax region ShaDaMsgpackArray matchgroup=ShaDaMsgpackArrayBraces
+ \ start='\[' end='\]' contained
+ \ contains=@ShaDaEntryMsgpackValue,ShaDaMsgpackComma
+syntax region ShaDaMsgpackMap matchgroup=ShaDaMsgpackMapBraces
+ \ start='{' end='}' contained
+ \ contains=@ShaDaEntryMsgpackValue,ShaDaMsgpackComma,ShaDaMsgpackColon
+syntax match ShaDaMsgpackComma ',' contained
+syntax match ShaDaMsgpackColon ':' contained
+syntax match ShaDaMsgpackMultilineArray '@' contained
+
+hi def link ShaDaComment Comment
+hi def link ShaDaEntryNumber Number
+hi def link ShaDaEntryTimestamp Operator
+hi def link ShaDaEntryName Keyword
+
+hi def link ShaDaEntryMapHeader PreProc
+
+hi def link ShaDaEntryMapEntryStart Label
+hi def link ShaDaEntryMapLongEntryStart ShaDaEntryMapEntryStart
+hi def link ShaDaEntryMapShortEntryStart ShaDaEntryMapEntryStart
+hi def link ShaDaEntryMapBinArrayStart ShaDaEntryMapEntryStart
+hi def link ShaDaEntryArrayEntryStart ShaDaEntryMapEntryStart
+
+hi def link ShaDaEntryMapKey String
+hi def link ShaDaEntryMapLongKey ShaDaEntryMapKey
+hi def link ShaDaEntryMapShortKey ShaDaEntryMapKey
+
+hi def link ShaDaEntryMapDescription Comment
+hi def link ShaDaEntryMapLongDescription ShaDaEntryMapDescription
+hi def link ShaDaEntryMapShortDescription ShaDaEntryMapDescription
+
+hi def link ShaDaEntryArrayHeader PreProc
+
+hi def link ShaDaEntryArrayDescription ShaDaEntryMapDescription
+
+hi def link ShaDaMsgpackKeyword Keyword
+hi def link ShaDaMsgpackShaDaKeyword ShaDaMsgpackKeyword
+hi def link ShaDaMsgpackCharacter Character
+hi def link ShaDaMsgpackInteger Number
+hi def link ShaDaMsgpackFloat Float
+
+hi def link ShaDaMsgpackBinaryString String
+hi def link ShaDaMsgpackBinaryStringEscape SpecialChar
+hi def link ShaDaMsgpackExtType Typedef
+
+hi def link ShaDaMsgpackStringQuotes Operator
+hi def link ShaDaMsgpackString ShaDaMsgpackStringQuotes
+hi def link ShaDaMsgpackExt ShaDaMsgpackStringQuotes
+
+hi def link ShaDaMsgpackMapBraces Operator
+hi def link ShaDaMsgpackArrayBraces ShaDaMsgpackMapBraces
+
+hi def link ShaDaMsgpackComma Operator
+hi def link ShaDaMsgpackColon ShaDaMsgpackComma
+
+hi def link ShaDaMsgpackMultilineArray Operator
+
+let b:current_syntax = "shada"
diff --git a/runtime/syntax/vhdl.vim b/runtime/syntax/vhdl.vim
index db51fa5034..c76b046d8c 100644
--- a/runtime/syntax/vhdl.vim
+++ b/runtime/syntax/vhdl.vim
@@ -3,7 +3,7 @@
" Maintainer: Daniel Kho <daniel.kho@tauhop.com>
" Previous Maintainer: Czo <Olivier.Sirol@lip6.fr>
" Credits: Stephan Hegel <stephan.hegel@snc.siemens.com.cn>
-" Last Changed: 2012 Feb 03 by Thilo Six
+" Last Changed: 2015 Apr 25 by Daniel Kho
" $Id: vhdl.vim,v 1.1 2004/06/13 15:34:56 vimboss Exp $
" VHSIC (Very High Speed Integrated Circuit) Hardware Description Language
@@ -160,10 +160,20 @@ syn match vhdlSpecial "[().,;]"
syn match vhdlTime "\<\d\+\s\+\(\([fpnum]s\)\|\(sec\)\|\(min\)\|\(hr\)\)\>"
syn match vhdlTime "\<\d\+\.\d\+\s\+\(\([fpnum]s\)\|\(sec\)\|\(min\)\|\(hr\)\)\>"
-syn keyword vhdlTodo contained TODO FIXME
-
-syn region vhdlComment start="/\*" end="\*/" contains=vhdlTodo,@Spell
-syn match vhdlComment "--.*" contains=vhdlTodo,@Spell
+syn keyword vhdlTodo contained TODO NOTE
+syn keyword vhdlFixme contained FIXME
+
+" Regex for space is '\s'
+" Any number of spaces: \s*
+" At least one space: \s+
+syn region vhdlComment start="/\*" end="\*/" contains=vhdlTodo,vhdlFixme,@Spell
+syn match vhdlComment "--.*" contains=vhdlTodo,vhdlFixme,@Spell
+syn match vhdlPreProc "/\* synthesis .* \*/"
+syn match vhdlPreProc "/\* pragma .* \*/"
+syn match vhdlPreProc "/\* synopsys .* \*/"
+syn match vhdlPreProc "--\s*synthesis .*"
+syn match vhdlPreProc "--\s*pragma .*"
+syn match vhdlPreProc "--\s*synopsys .*"
" syn match vhdlGlobal "[\'$#~!%@?\^\[\]{}\\]"
"Modify the following as needed. The trade-off is performance versus functionality.
@@ -180,21 +190,22 @@ if version >= 508 || !exists("did_vhdl_syntax_inits")
command -nargs=+ HiLink hi def link <args>
endif
-" HiLink cDefine PreProc
- HiLink vhdlSpecial Special
- HiLink vhdlStatement Statement
- HiLink vhdlCharacter Character
- HiLink vhdlString String
- HiLink vhdlVector Number
- HiLink vhdlBoolean Number
- HiLink vhdlTodo Todo
- HiLink vhdlComment Comment
- HiLink vhdlNumber Number
- HiLink vhdlTime Number
- HiLink vhdlType Type
- HiLink vhdlOperator Special
+ HiLink vhdlSpecial Special
+ HiLink vhdlStatement Statement
+ HiLink vhdlCharacter Character
+ HiLink vhdlString String
+ HiLink vhdlVector Number
+ HiLink vhdlBoolean Number
+ HiLink vhdlTodo Todo
+ HiLink vhdlFixme Fixme
+ HiLink vhdlComment Comment
+ HiLink vhdlNumber Number
+ HiLink vhdlTime Number
+ HiLink vhdlType Type
+ HiLink vhdlOperator Operator
" HiLink vhdlGlobal Error
- HiLink vhdlAttribute Type
+ HiLink vhdlAttribute Special
+ HiLink vhdlPreProc PreProc
delcommand HiLink
endif
diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim
index e23232bbbe..cf51830b68 100644
--- a/runtime/syntax/vim.vim
+++ b/runtime/syntax/vim.vim
@@ -19,7 +19,7 @@ syn cluster vimCommentGroup contains=vimTodo,@Spell
" Special and plugin vim commands {{{2
syn match vimCommand contained "\<z[-+^.=]\="
-syn keyword vimOnlyCommand contained fix[del] sh[ell] P[rint]
+syn keyword vimOnlyCommand contained fix[del] op[en] sh[ell] P[rint]
syn keyword vimStdPlugin contained DiffOrig Man N[ext] S TOhtml XMLent XMLns
" Vim-specific options {{{2
diff --git a/runtime/syntax/zsh.vim b/runtime/syntax/zsh.vim
index 79fd017ee8..5e588e7d6c 100644
--- a/runtime/syntax/zsh.vim
+++ b/runtime/syntax/zsh.vim
@@ -1,7 +1,10 @@
" Vim syntax file
-" Language: Zsh shell script
-" Maintainer: Nikolai Weibull <now@bitwi.se>
-" Latest Revision: 2010-01-23
+" Language: Zsh shell script
+" Maintainer: Christian Brabandt <cb@256bit.org>
+" Previous Maintainer: Nikolai Weibull <now@bitwi.se>
+" Latest Revision: 2015-05-29
+" License: Vim (see :h license)
+" Repository: https://github.com/chrisbra/vim-zsh
if exists("b:current_syntax")
finish
@@ -14,7 +17,7 @@ setlocal iskeyword+=-
syn keyword zshTodo contained TODO FIXME XXX NOTE
-syn region zshComment oneline start='\%(^\|\s\)#' end='$'
+syn region zshComment oneline start='\%(^\|\s*\)#' end='$'
\ contains=zshTodo,@Spell
syn match zshPreProc '^\%1l#\%(!\|compdef\|autoload\).*$'
@@ -30,7 +33,7 @@ syn match zshJobSpec '%\(\d\+\|?\=\w\+\|[%+-]\)'
syn keyword zshPrecommand noglob nocorrect exec command builtin - time
-syn keyword zshDelimiter do done
+syn keyword zshDelimiter do done end
syn keyword zshConditional if then elif else fi case in esac select
@@ -64,7 +67,7 @@ syn region zshHereDoc matchgroup=zshRedir
\ end='^\s*\z1\>'
\ contains=@zshSubst
syn region zshHereDoc matchgroup=zshRedir
- \ start=+<\@<!<<\s*\(["']\)\z(\S\+\)\1+
+ \ start=+<\@<!<<\s*\(["']\)\z(\S\+\)\1+
\ end='^\z1\>'
syn region zshHereDoc matchgroup=zshRedir
\ start=+<\@<!<<-\s*\(["']\)\z(\S\+\)\1+
@@ -121,6 +124,165 @@ syn keyword zshCommands alias autoload bg bindkey break bye cap cd
\ zmodload zparseopts zprof zpty zregexparse
\ zsocket zstyle ztcp
+" Options, generated by: echo ${(j:\n:)options[(I)*]} | sort
+syn case ignore
+syn keyword zshOptions aliases allexport all_export alwayslastprompt
+ \ always_lastprompt alwaystoend always_to_end
+ \ appendhistory append_history autocd autocontinue
+ \ auto_continue autolist auto_list
+ \ automenu auto_menu autonamedirs auto_name_dirs
+ \ autoparamkeys auto_param_keys autoparamslash
+ \ auto_param_slash autopushd auto_pushd autoremoveslash
+ \ auto_remove_slash autoresume auto_resume badpattern
+ \ banghist bang_hist bareglobqual bare_glob_qual
+ \ bashautolist bash_auto_list bashrematch bash_rematch
+ \ beep bgnice braceccl brace_ccl braceexpand brace_expand
+ \ bsdecho bsd_echo caseglob case_glob casematch case_match
+ \ cbases cdablevars cd_able_vars chasedots chase_dots
+ \ chaselinks chase_links checkjobs check_jobs
+ \ clobber combiningchars combining_chars completealiases
+ \ complete_aliases completeinword complete_in_word
+ \ continueonerror continue_on_error correct
+ \ correctall correct_all cprecedences c_precedences
+ \ cshjunkiehistory csh_junkie_history cshjunkieloops
+ \ csh_junkie_loops cshjunkiequotes csh_junkie_quotes
+ \ cshnullcmd csh_null_cmd cshnullglob csh_null_glob
+ \ debugbeforecmd debug_before_cmd dotglob dot_glob dvorak
+ \ emacs equals errexit err_exit errreturn err_return evallineno
+ \ eval_lineno exec extendedglob extended_glob extendedhistory
+ \ extended_history flowcontrol flow_control forcefloat
+ \ force_float functionargzero function_arg_zero glob globalexport
+ \ global_export globalrcs global_rcs globassign glob_assign
+ \ globcomplete glob_complete globdots glob_dots glob_subst
+ \ globsubst hashall hash_all hashcmds hash_cmds hashdirs
+ \ hash_dirs hashexecutablesonly hash_executables_only hashlistall
+ \ hash_list_all histallowclobber hist_allow_clobber histappend
+ \ hist_append histbeep hist_beep hist_expand hist_expire_dups_first
+ \ histexpand histexpiredupsfirst histfcntllock hist_fcntl_lock
+ \ histfindnodups hist_find_no_dups histignorealldups
+ \ hist_ignore_all_dups histignoredups hist_ignore_dups
+ \ histignorespace hist_ignore_space histlexwords hist_lex_words
+ \ histnofunctions hist_no_functions histnostore hist_no_store
+ \ histreduceblanks hist_reduce_blanks histsavebycopy
+ \ hist_save_by_copy histsavenodups hist_save_no_dups
+ \ histsubstpattern hist_subst_pattern histverify hist_verify
+ \ hup ignorebraces ignore_braces ignoreclosebraces ignore_close_braces
+ \ ignoreeof ignore_eof incappendhistory inc_append_history
+ \ incappendhistorytime inc_append_history_time interactive
+ \ interactivecomments interactive_comments ksharrays ksh_arrays
+ \ kshautoload ksh_autoload kshglob ksh_glob kshoptionprint
+ \ ksh_option_print kshtypeset ksh_typeset kshzerosubscript
+ \ ksh_zero_subscript listambiguous list_ambiguous listbeep
+ \ list_beep listpacked list_packed listrowsfirst list_rows_first
+ \ listtypes list_types localloops local_loops localoptions
+ \ local_options localpatterns local_patterns localtraps
+ \ local_traps log login longlistjobs long_list_jobs magicequalsubst
+ \ magic_equal_subst mailwarn mail_warn mail_warning mark_dirs
+ \ mailwarning markdirs menucomplete menu_complete monitor
+ \ multibyte multi_byte multifuncdef multi_func_def multios
+ \ multi_os nomatch no_match notify nullglob null_glob numericglobsort
+ \ numeric_glob_sort octalzeroes octal_zeroes onecmd one_cmd
+ \ overstrike over_strike pathdirs path_dirs pathscript
+ \ path_script physical pipefail pipe_fail posixaliases
+ \ posix_aliases posixargzero posix_arg_zero posixbuiltins
+ \ posix_builtins posixcd posix_cd posixidentifiers posix_identifiers
+ \ posixjobs posix_jobs posixstrings posix_strings posixtraps
+ \ posix_traps printeightbit print_eight_bit printexitvalue
+ \ print_exit_value privileged promptbang prompt_bang promptcr
+ \ prompt_cr promptpercent prompt_percent promptsp prompt_sp
+ \ promptsubst prompt_subst promptvars prompt_vars pushdignoredups
+ \ pushd_ignore_dups pushdminus pushd_minus pushdsilent pushd_silent
+ \ pushdtohome pushd_to_home rcexpandparam rc_expandparam rcquotes
+ \ rc_quotes rcs recexact rec_exact rematchpcre re_match_pcre
+ \ restricted rmstarsilent rm_star_silent rmstarwait rm_star_wait
+ \ sharehistory share_history shfileexpansion sh_file_expansion
+ \ shglob sh_glob shinstdin shin_stdin shnullcmd sh_nullcmd
+ \ shoptionletters sh_option_letters shortloops short_loops shwordsplit
+ \ sh_word_split singlecommand single_command singlelinezle single_line_zle
+ \ sourcetrace source_trace stdin sunkeyboardhack sun_keyboard_hack
+ \ trackall track_all transientrprompt transient_rprompt
+ \ trapsasync trapasync typesetsilent type_set_silent unset verbose vi
+ \ warncreateglobal warn_create_global xtrace zle
+
+syn keyword zshOptions noaliases no_aliases noallexport no_allexport noall_export no_all_export noalwayslastprompt no_alwayslastprompt
+ \ noalways_lastprompt no_always_lastprompt noalwaystoend no_alwaystoend noalways_to_end no_always_to_end
+ \ noappendhistory no_appendhistory noappend_history no_append_history noautocd no_autocd noautocontinue no_autocontinue
+ \ noauto_continue no_auto_continue noautolist no_autolist noauto_list no_auto_list
+ \ noautomenu no_automenu noauto_menu no_auto_menu noautonamedirs no_autonamedirs noauto_name_dirs no_auto_name_dirs
+ \ noautoparamkeys no_autoparamkeys noauto_param_keys no_auto_param_keys noautoparamslash no_autoparamslash
+ \ noauto_param_slash no_auto_param_slash noautopushd no_autopushd noauto_pushd no_auto_pushd noautoremoveslash no_autoremoveslash
+ \ noauto_remove_slash no_auto_remove_slash noautoresume no_autoresume noauto_resume no_auto_resume nobadpattern no_badpattern
+ \ nobanghist no_banghist nobang_hist no_bang_hist nobareglobqual no_bareglobqual nobare_glob_qual no_bare_glob_qual
+ \ nobashautolist no_bashautolist nobash_auto_list no_bash_auto_list nobashrematch no_bashrematch nobash_rematch no_bash_rematch
+ \ nobeep no_beep nobgnice no_bgnice nobraceccl no_braceccl nobrace_ccl no_brace_ccl nobraceexpand no_braceexpand nobrace_expand no_brace_expand
+ \ nobsdecho no_bsdecho nobsd_echo no_bsd_echo nocaseglob no_caseglob nocase_glob no_case_glob nocasematch no_casematch nocase_match no_case_match
+ \ nocbases no_cbases nocdablevars no_cdablevars nocd_able_vars no_cd_able_vars nochasedots no_chasedots nochase_dots no_chase_dots
+ \ nochaselinks no_chaselinks nochase_links no_chase_links nocheckjobs no_checkjobs nocheck_jobs no_check_jobs
+ \ noclobber no_clobber nocombiningchars no_combiningchars nocombining_chars no_combining_chars nocompletealiases no_completealiases
+ \ nocomplete_aliases no_complete_aliases nocompleteinword no_completeinword nocomplete_in_word no_complete_in_word
+ \ nocontinueonerror no_continueonerror nocontinue_on_error no_continue_on_error nocorrect no_correct
+ \ nocorrectall no_correctall nocorrect_all no_correct_all nocprecedences no_cprecedences noc_precedences no_c_precedences
+ \ nocshjunkiehistory no_cshjunkiehistory nocsh_junkie_history no_csh_junkie_history nocshjunkieloops no_cshjunkieloops
+ \ nocsh_junkie_loops no_csh_junkie_loops nocshjunkiequotes no_cshjunkiequotes nocsh_junkie_quotes no_csh_junkie_quotes
+ \ nocshnullcmd no_cshnullcmd nocsh_null_cmd no_csh_null_cmd nocshnullglob no_cshnullglob nocsh_null_glob no_csh_null_glob
+ \ nodebugbeforecmd no_debugbeforecmd nodebug_before_cmd no_debug_before_cmd nodotglob no_dotglob nodot_glob no_dot_glob nodvorak no_dvorak
+ \ noemacs no_emacs noequals no_equals noerrexit no_errexit noerr_exit no_err_exit noerrreturn no_errreturn noerr_return no_err_return noevallineno no_evallineno
+ \ noeval_lineno no_eval_lineno noexec no_exec noextendedglob no_extendedglob noextended_glob no_extended_glob noextendedhistory no_extendedhistory
+ \ noextended_history no_extended_history noflowcontrol no_flowcontrol noflow_control no_flow_control noforcefloat no_forcefloat
+ \ noforce_float no_force_float nofunctionargzero no_functionargzero nofunction_arg_zero no_function_arg_zero noglob no_glob noglobalexport no_globalexport
+ \ noglobal_export no_global_export noglobalrcs no_globalrcs noglobal_rcs no_global_rcs noglobassign no_globassign noglob_assign no_glob_assign
+ \ noglobcomplete no_globcomplete noglob_complete no_glob_complete noglobdots no_globdots noglob_dots no_glob_dots noglob_subst no_glob_subst
+ \ noglobsubst no_globsubst nohashall no_hashall nohash_all no_hash_all nohashcmds no_hashcmds nohash_cmds no_hash_cmds nohashdirs no_hashdirs
+ \ nohash_dirs no_hash_dirs nohashexecutablesonly no_hashexecutablesonly nohash_executables_only no_hash_executables_only nohashlistall no_hashlistall
+ \ nohash_list_all no_hash_list_all nohistallowclobber no_histallowclobber nohist_allow_clobber no_hist_allow_clobber nohistappend no_histappend
+ \ nohist_append no_hist_append nohistbeep no_histbeep nohist_beep no_hist_beep nohist_expand no_hist_expand nohist_expire_dups_first no_hist_expire_dups_first
+ \ nohistexpand no_histexpand nohistexpiredupsfirst no_histexpiredupsfirst nohistfcntllock no_histfcntllock nohist_fcntl_lock no_hist_fcntl_lock
+ \ nohistfindnodups no_histfindnodups nohist_find_no_dups no_hist_find_no_dups nohistignorealldups no_histignorealldups
+ \ nohist_ignore_all_dups no_hist_ignore_all_dups nohistignoredups no_histignoredups nohist_ignore_dups no_hist_ignore_dups
+ \ nohistignorespace no_histignorespace nohist_ignore_space no_hist_ignore_space nohistlexwords no_histlexwords nohist_lex_words no_hist_lex_words
+ \ nohistnofunctions no_histnofunctions nohist_no_functions no_hist_no_functions nohistnostore no_histnostore nohist_no_store no_hist_no_store
+ \ nohistreduceblanks no_histreduceblanks nohist_reduce_blanks no_hist_reduce_blanks nohistsavebycopy no_histsavebycopy
+ \ nohist_save_by_copy no_hist_save_by_copy nohistsavenodups no_histsavenodups nohist_save_no_dups no_hist_save_no_dups
+ \ nohistsubstpattern no_histsubstpattern nohist_subst_pattern no_hist_subst_pattern nohistverify no_histverify nohist_verify no_hist_verify
+ \ nohup no_hup noignorebraces no_ignorebraces noignore_braces no_ignore_braces noignoreclosebraces no_ignoreclosebraces noignore_close_braces no_ignore_close_braces
+ \ noignoreeof no_ignoreeof noignore_eof no_ignore_eof noincappendhistory no_incappendhistory noinc_append_history no_inc_append_history
+ \ noincappendhistorytime no_incappendhistorytime noinc_append_history_time no_inc_append_history_time nointeractive no_interactive
+ \ nointeractivecomments no_interactivecomments nointeractive_comments no_interactive_comments noksharrays no_ksharrays noksh_arrays no_ksh_arrays
+ \ nokshautoload no_kshautoload noksh_autoload no_ksh_autoload nokshglob no_kshglob noksh_glob no_ksh_glob nokshoptionprint no_kshoptionprint
+ \ noksh_option_print no_ksh_option_print nokshtypeset no_kshtypeset noksh_typeset no_ksh_typeset nokshzerosubscript no_kshzerosubscript
+ \ noksh_zero_subscript no_ksh_zero_subscript nolistambiguous no_listambiguous nolist_ambiguous no_list_ambiguous nolistbeep no_listbeep
+ \ nolist_beep no_list_beep nolistpacked no_listpacked nolist_packed no_list_packed nolistrowsfirst no_listrowsfirst nolist_rows_first no_list_rows_first
+ \ nolisttypes no_listtypes nolist_types no_list_types nolocalloops no_localloops nolocal_loops no_local_loops nolocaloptions no_localoptions
+ \ nolocal_options no_local_options nolocalpatterns no_localpatterns nolocal_patterns no_local_patterns nolocaltraps no_localtraps
+ \ nolocal_traps no_local_traps nolog no_log nologin no_login nolonglistjobs no_longlistjobs nolong_list_jobs no_long_list_jobs nomagicequalsubst no_magicequalsubst
+ \ nomagic_equal_subst no_magic_equal_subst nomailwarn no_mailwarn nomail_warn no_mail_warn nomail_warning no_mail_warning nomark_dirs no_mark_dirs
+ \ nomailwarning no_mailwarning nomarkdirs no_markdirs nomenucomplete no_menucomplete nomenu_complete no_menu_complete nomonitor no_monitor
+ \ nomultibyte no_multibyte nomulti_byte no_multi_byte nomultifuncdef no_multifuncdef nomulti_func_def no_multi_func_def nomultios no_multios
+ \ nomulti_os no_multi_os nonomatch no_nomatch nono_match no_no_match nonotify no_notify nonullglob no_nullglob nonull_glob no_null_glob nonumericglobsort no_numericglobsort
+ \ nonumeric_glob_sort no_numeric_glob_sort nooctalzeroes no_octalzeroes nooctal_zeroes no_octal_zeroes noonecmd no_onecmd noone_cmd no_one_cmd
+ \ nooverstrike no_overstrike noover_strike no_over_strike nopathdirs no_pathdirs nopath_dirs no_path_dirs nopathscript no_pathscript
+ \ nopath_script no_path_script nophysical no_physical nopipefail no_pipefail nopipe_fail no_pipe_fail noposixaliases no_posixaliases
+ \ noposix_aliases no_posix_aliases noposixargzero no_posixargzero noposix_arg_zero no_posix_arg_zero noposixbuiltins no_posixbuiltins
+ \ noposix_builtins no_posix_builtins noposixcd no_posixcd noposix_cd no_posix_cd noposixidentifiers no_posixidentifiers noposix_identifiers no_posix_identifiers
+ \ noposixjobs no_posixjobs noposix_jobs no_posix_jobs noposixstrings no_posixstrings noposix_strings no_posix_strings noposixtraps no_posixtraps
+ \ noposix_traps no_posix_traps noprinteightbit no_printeightbit noprint_eight_bit no_print_eight_bit noprintexitvalue no_printexitvalue
+ \ noprint_exit_value no_print_exit_value noprivileged no_privileged nopromptbang no_promptbang noprompt_bang no_prompt_bang nopromptcr no_promptcr
+ \ noprompt_cr no_prompt_cr nopromptpercent no_promptpercent noprompt_percent no_prompt_percent nopromptsp no_promptsp noprompt_sp no_prompt_sp
+ \ nopromptsubst no_promptsubst noprompt_subst no_prompt_subst nopromptvars no_promptvars noprompt_vars no_prompt_vars nopushdignoredups no_pushdignoredups
+ \ nopushd_ignore_dups no_pushd_ignore_dups nopushdminus no_pushdminus nopushd_minus no_pushd_minus nopushdsilent no_pushdsilent nopushd_silent no_pushd_silent
+ \ nopushdtohome no_pushdtohome nopushd_to_home no_pushd_to_home norcexpandparam no_rcexpandparam norc_expandparam no_rc_expandparam norcquotes no_rcquotes
+ \ norc_quotes no_rc_quotes norcs no_rcs norecexact no_recexact norec_exact no_rec_exact norematchpcre no_rematchpcre nore_match_pcre no_re_match_pcre
+ \ norestricted no_restricted normstarsilent no_rmstarsilent norm_star_silent no_rm_star_silent normstarwait no_rmstarwait norm_star_wait no_rm_star_wait
+ \ nosharehistory no_sharehistory noshare_history no_share_history noshfileexpansion no_shfileexpansion nosh_file_expansion no_sh_file_expansion
+ \ noshglob no_shglob nosh_glob no_sh_glob noshinstdin no_shinstdin noshin_stdin no_shin_stdin noshnullcmd no_shnullcmd nosh_nullcmd no_sh_nullcmd
+ \ noshoptionletters no_shoptionletters nosh_option_letters no_sh_option_letters noshortloops no_shortloops noshort_loops no_short_loops noshwordsplit no_shwordsplit
+ \ nosh_word_split no_sh_word_split nosinglecommand no_singlecommand nosingle_command no_single_command nosinglelinezle no_singlelinezle nosingle_line_zle no_single_line_zle
+ \ nosourcetrace no_sourcetrace nosource_trace no_source_trace nostdin no_stdin nosunkeyboardhack no_sunkeyboardhack nosun_keyboard_hack no_sun_keyboard_hack
+ \ notrackall no_trackall notrack_all no_track_all notransientrprompt no_transientrprompt notransient_rprompt no_transient_rprompt
+ \ notrapsasync no_trapsasync notrapasync no_trapasync notypesetsilent no_typesetsilent notype_set_silent no_type_set_silent nounset no_unset noverbose no_verbose novi no_vi
+ \ nowarncreateglobal no_warncreateglobal nowarn_create_global no_warn_create_global noxtrace no_xtrace nozle no_zle
+syn case match
+
syn keyword zshTypes float integer local typeset declare
" XXX: this may be too much
@@ -149,7 +311,7 @@ syn region zshSubst matchgroup=zshSubstDelim start='\${' skip='\\}'
syn region zshOldSubst matchgroup=zshSubstDelim start=+`+ skip=+\\`+
\ end=+`+ contains=TOP,zshOldSubst
-syn sync minlines=50
+syn sync minlines=50 maxlines=90
syn sync match zshHereDocSync grouphere NONE '<<-\=\s*\%(\\\=\S\+\|\(["']\)\S\+\1\)'
syn sync match zshHereDocEndSync groupthere NONE '^\s*EO\a\+\>'
@@ -170,16 +332,8 @@ hi def link zshKeyword Keyword
hi def link zshFunction None
hi def link zshKSHFunction zshFunction
hi def link zshHereDoc String
-if 0
- hi def link zshOperator Operator
-else
- hi def link zshOperator None
-endif
-if 1
- hi def link zshRedir Operator
-else
- hi def link zshRedir None
-endif
+hi def link zshOperator None
+hi def link zshRedir Operator
hi def link zshVariable None
hi def link zshVariableDef zshVariable
hi def link zshDereferencing PreProc
@@ -199,6 +353,7 @@ else
hi def link zshDeref None
endif
hi def link zshCommands Keyword
+hi def link zshOptions Constant
hi def link zshTypes Type
hi def link zshSwitches Special
hi def link zshNumber Number
diff --git a/runtime/tutor/en/vim-01-beginner.tutor b/runtime/tutor/en/vim-01-beginner.tutor
index bda4e3537e..47d4ed06a1 100644
--- a/runtime/tutor/en/vim-01-beginner.tutor
+++ b/runtime/tutor/en/vim-01-beginner.tutor
@@ -7,6 +7,12 @@ IMPORTANT to remember that this tutor is set up to teach by use. That means
that you need to do the exercises to learn them properly. If you only read
the text, you will soon forget what is most important!
+For now, make sure that your Shift-Lock key is NOT depressed and press the `j`{normal}
+key enough times to move the cursor so that Lesson 0 completely fills the
+screen.
+
+# Lesson 0
+
NOTE: The commands in the lessons will modify the text, but those changes won't
be saved. Don't worry about messing things up; just remember that pressing
[<Esc>](<Esc>) and then [u](u) will undo the latest change.
@@ -30,9 +36,7 @@ or press a sequence of keys
Text within <'s and >'s (like `<Enter>`{normal}) describes a key to press instead of text
to type.
-Now, make sure that your Shift-Lock key is NOT depressed and press the `j`{normal}
-key enough times to move the cursor so that Lesson 1.1 completely fills the
-screen.
+Now, move to the next lesson (remember, use j).
## Lesson 1.1: MOVING THE CURSOR
@@ -883,8 +887,7 @@ Vim has many more features than Vi, but most of them are disabled by
default. To start using more features you have to create a "vimrc" file.
1. Start editing the "vimrc" file. This depends on your system:
- `:e ~/.vimrc`{vim} for Unix-like systems
- `:e $VIM/_vimrc`{vim} for Microsoft Windows
+ `:e ~/.config/nvim/init.vim`{vim} for Unix-like systems
2. Now read the example "vimrc" file contents:
`:r $VIMRUNTIME/vimrc_example.vim`{vim}
diff --git a/scripts/shadacat.py b/scripts/shadacat.py
index 4ff493bfbc..2f2cf19f9d 100755
--- a/scripts/shadacat.py
+++ b/scripts/shadacat.py
@@ -60,9 +60,22 @@ def mnormalize(o):
fname = sys.argv[1]
+try:
+ filt = sys.argv[2]
+except IndexError:
+ filt = lambda entry: True
+else:
+ _filt = filt
+ filt = lambda entry: eval(_filt, globals(), {'entry': entry})
+
poswidth = len(str(os.stat(fname).st_size or 1000))
+class FullEntry(dict):
+ def __init__(self, val):
+ self.__dict__.update(val)
+
+
with open(fname, 'rb') as fp:
unpacker = msgpack.Unpacker(file_like=fp, read_size=1)
max_type = max(typ.value for typ in EntryTypes)
@@ -82,5 +95,15 @@ with open(fname, 'rb') as fp:
else:
entry = unpacker.unpack()
typ = EntryTypes(typ)
+ full_entry = FullEntry({
+ 'value': entry,
+ 'timestamp': timestamp,
+ 'time': time,
+ 'length': length,
+ 'pos': pos,
+ 'type': typ,
+ })
+ if not filt(full_entry):
+ continue
print('%*u %13s %s %5u %r' % (
poswidth, pos, typ.name, time.isoformat(), length, mnormalize(entry)))
diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh
index a1b58c7c91..4a567727d8 100755
--- a/scripts/vim-patch.sh
+++ b/scripts/vim-patch.sh
@@ -205,8 +205,8 @@ list_vim_patches() {
echo " To port one of the above patches to Neovim, execute"
echo " this script with the patch revision as argument."
echo
- echo " Examples: '${BASENAME} 7.4.487'"
- echo " '${BASENAME} 1e8ebf870720e7b671f98f22d653009826304c4f'"
+ echo " Examples: '${BASENAME} -p 7.4.487'"
+ echo " '${BASENAME} -p 1e8ebf870720e7b671f98f22d653009826304c4f'"
}
review_pr() {
diff --git a/src/nvim/README.md b/src/nvim/README.md
new file mode 100644
index 0000000000..e4939d94fd
--- /dev/null
+++ b/src/nvim/README.md
@@ -0,0 +1,190 @@
+## Source code overview
+
+Since Neovim has inherited most code from Vim, some information in [its
+README](https://raw.githubusercontent.com/vim/vim/master/src/README.txt) still
+applies.
+
+This document aims to give a high level overview of how Neovim works internally,
+focusing on parts that are different from Vim. Currently this is still a work in
+progress, especially because I have avoided adding too many details about parts
+that are constantly changing. As the code becomes more organized and stable,
+this document will be updated to reflect the changes.
+
+If you are looking for module-specific details, it is best to read the source
+code. Some files are extensively commented at the top(eg: terminal.c,
+screen.c).
+
+### Top-level program loops
+
+First let's understand what a Vim-like program does by analyzing the workflow of
+a typical editing session:
+
+01. Vim dispays the welcome screen
+02. User types: `:`
+03. Vim enters command-line mode
+04. User types: `edit README.txt<CR>`
+05. Vim opens the file and returns to normal mode
+06. User types: `G`
+07. Vim navigates to the end of the file
+09. User types: `5`
+10. Vim enters count-pending mode
+11. User types: `d`
+12. Vim enters operator-pending mode
+13. User types: `w`
+14. Vim deletes 5 words
+15. User types: `g`
+16. Vim enters the "g command mode"
+17. User types: `g`
+18. Vim goes to the beginning of the file
+19. User types: `i`
+20. Vim enters insert mode
+21. User types: `word<ESC>`
+22. Vim inserts "word" at the beginning and returns to normal mode
+
+Note that we have split user actions into sequences of inputs that change the
+state of the editor. While there's no documentation about a "g command
+mode"(step 16), internally it is implemented similarly to "operator-pending
+mode".
+
+From this we can see that Vim has the behavior of a input-driven state
+machine(more specifically, a pushdown automaton since it requires a stack for
+transitioning back from states). Assuming each state has a callback responsible
+for handling keys, this pseudocode(a python-like language) shows a good
+representation of the main program loop:
+
+```py
+def state_enter(state_callback, data):
+ do
+ key = readkey() # read a key from the user
+ while state_callback(data, key) # invoke the callback for the current state
+```
+
+That is, each state is entered by calling `state_enter` and passing a
+state-specific callback and data. Here is a high-level pseudocode for a program
+that implements something like the workflow described above:
+
+```py
+def main()
+ state_enter(normal_state, {}):
+
+def normal_state(data, key):
+ if key == ':':
+ state_enter(command_line_state, {})
+ elif key == 'i':
+ state_enter(insert_state, {})
+ elif key == 'd':
+ state_enter(delete_operator_state, {})
+ elif key == 'g':
+ state_enter(g_command_state, {})
+ elif is_number(key):
+ state_enter(get_operator_count_state, {'count': key})
+ elif key == 'G'
+ jump_to_eof()
+ return true
+
+def command_line_state(data, key):
+ if key == '<cr>':
+ if data['input']:
+ execute_ex_command(data['input'])
+ return false
+ elif key == '<esc>'
+ return false
+
+ if not data['input']:
+ data['input'] = ''
+
+ data['input'] += key
+ return true
+
+def delete_operator_state(data, key):
+ count = data['count'] or 1
+ if key == 'w':
+ delete_word(count)
+ elif key == '$':
+ delete_to_eol(count)
+ return false # return to normal mode
+
+def g_command_state(data, key):
+ if key == 'g':
+ go_top()
+ elif key == 'v':
+ reselect()
+ return false # return to normal mode
+
+def get_operator_count_state(data, key):
+ if is_number(key):
+ data['count'] += key
+ return true
+ unshift_key(key) # return key to the input buffer
+ state_enter(delete_operator_state, data)
+ return false
+
+def insert_state(data, key):
+ if key == '<esc>':
+ return false # exit insert mode
+ self_insert(key)
+ return true
+```
+
+While the actual code is much more complicated, the above gives an idea of how
+Neovim is organized internally. Some states like the `g_command_state` or
+`get_operator_count_state` do not have a dedicated `state_enter` callback, but
+are implicitly embedded into other states(this will change later as we continue
+the refactoring effort). To start reading the actual code, here's the
+recommended order:
+
+1. `state_enter()` function(state.c). This is the actual program loop,
+ note that a `VimState` structure is used, which contains function pointers
+ for the callback and state data.
+2. `main()` function(main.c). After all startup, `normal_enter` is called
+ at the end of function to enter normal mode.
+3. `normal_enter()` function(normal.c) is a small wrapper for setting
+ up the NormalState structure and calling `state_enter`.
+4. `normal_check()` function(normal.c) is called before each iteration of
+ normal mode.
+5. `normal_execute()` function(normal.c) is called when a key is read in normal
+ mode.
+
+The basic structure described for normal mode in 3, 4 and 5 is used for other
+modes managed by the `state_enter` loop:
+
+- command-line mode: `command_line_{enter,check,execute}()`(`ex_getln.c`)
+- insert mode: `insert_{enter,check,execute}()`(`edit.c`)
+- terminal mode: `terminal_{enter,execute}()`(`terminal.c`)
+
+### Async event support
+
+One of the features Neovim added is the support for handling arbitrary
+asynchronous events, which can include:
+
+- msgpack-rpc requests
+- job control callbacks
+- timers(not implemented yet but the support code is already there)
+
+Neovim implements this functionality by entering another event loop while
+waiting for characters, so instead of:
+
+```py
+def state_enter(state_callback, data):
+ do
+ key = readkey() # read a key from the user
+ while state_callback(data, key) # invoke the callback for the current state
+```
+
+Neovim program loop is more like:
+
+```py
+def state_enter(state_callback, data):
+ do
+ event = read_next_event() # read an event from the operating system
+ while state_callback(data, event) # invoke the callback for the current state
+```
+
+where `event` is something the operating system delivers to us, including(but
+not limited to) user input. The `read_next_event()` part is internally
+implemented by libuv, the platform layer used by Neovim.
+
+Since Neovim inherited its code from Vim, the states are not prepared to receive
+"arbitrary events", so we use a special key to represent those(When a state
+receives an "arbitrary event", it normally doesn't do anything other update the
+screen).
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c
index a8446265d0..b7a86af134 100644
--- a/src/nvim/api/buffer.c
+++ b/src/nvim/api/buffer.c
@@ -1,6 +1,5 @@
// Much of this code was adapted from 'if_py_both.h' from the original
// vim source
-#include <errno.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
diff --git a/src/nvim/ascii.h b/src/nvim/ascii.h
index cce52c5250..2b3e94d5a0 100644
--- a/src/nvim/ascii.h
+++ b/src/nvim/ascii.h
@@ -1,10 +1,3 @@
-/*
- * VIM - Vi IMproved by Bram Moolenaar
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- */
-
#ifndef NVIM_ASCII_H
#define NVIM_ASCII_H
diff --git a/src/nvim/auevents.lua b/src/nvim/auevents.lua
index 3d8a75febd..aa4a8d8332 100644
--- a/src/nvim/auevents.lua
+++ b/src/nvim/auevents.lua
@@ -57,6 +57,7 @@ return {
'InsertLeave', -- when leaving Insert mode
'JobActivity', -- when job sent some data
'MenuPopup', -- just before popup menu is displayed
+ 'OptionSet', -- after setting any option
'QuickFixCmdPost', -- after :make, :grep etc.
'QuickFixCmdPre', -- before :make, :grep etc.
'QuitPre', -- before :quit
@@ -77,8 +78,9 @@ return {
'TabNew', -- when creating a new tab
'TabNewEntered', -- after entering a new tab
'TermChanged', -- after changing 'term'
- 'TermResponse', -- after setting "v:termresponse"
+ 'TermClose', -- after the processs exits
'TermOpen', -- after opening a terminal buffer
+ 'TermResponse', -- after setting "v:termresponse"
'TextChanged', -- text was modified
'TextChangedI', -- text was modified in Insert mode
'User', -- user defined autocommand
@@ -98,9 +100,10 @@ return {
-- List of neovim-specific events or aliases for the purpose of generating
-- syntax file
neovim_specific = {
+ TabClosed=true,
TabNew=true,
TabNewEntered=true,
- TabClosed=true,
- TermEnter=true,
+ TermClose=true,
+ TermOpen=true,
},
}
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index b3eba4f5f6..762cd3efd3 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -1,12 +1,4 @@
/*
- * VIM - Vi IMproved by Bram Moolenaar
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- * See README.txt for an overview of the Vim source code.
- */
-
-/*
* buffer.c: functions for dealing with the buffer structure
*/
@@ -25,7 +17,6 @@
*/
#include <stdbool.h>
-#include <errno.h>
#include <string.h>
#include <inttypes.h>
@@ -1423,7 +1414,6 @@ buflist_new (
return NULL;
if (aborting()) /* autocmds may abort script processing */
return NULL;
- /* buf->b_nwindows = 0; why was this here? */
free_buffer_stuff(buf, FALSE); /* delete local variables et al. */
/* Init the options. */
@@ -1484,6 +1474,9 @@ buflist_new (
fmarks_check_names(buf); /* check file marks for this file */
buf->b_p_bl = (flags & BLN_LISTED) ? TRUE : FALSE; /* init 'buflisted' */
if (!(flags & BLN_DUMMY)) {
+ // Tricky: these autocommands may change the buffer list. They could also
+ // split the window with re-using the one empty buffer. This may result in
+ // unexpectedly losing the empty buffer.
apply_autocmds(EVENT_BUFNEW, NULL, NULL, FALSE, buf);
if (!buf_valid(buf)) {
return NULL;
@@ -2159,9 +2152,23 @@ void buflist_list(exarg_T *eap)
int i;
for (buf = firstbuf; buf != NULL && !got_int; buf = buf->b_next) {
- /* skip unlisted buffers, unless ! was used */
- if (!buf->b_p_bl && !eap->forceit)
+ // 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, '+')
+ && ((buf->b_flags & BF_READERR) || !bufIsChanged(buf)))
+ || (strchr((char *)eap->arg, 'a')
+ && (buf->b_ml.ml_mfp == NULL || buf->b_nwindows == 0))
+ || (strchr((char *)eap->arg, 'h')
+ && (buf->b_ml.ml_mfp == NULL || buf->b_nwindows != 0))
+ || (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, '#')
+ && (buf == curbuf || curwin->w_alt_fnum != buf->b_fnum))) {
continue;
+ }
msg_putchar('\n');
if (buf_spname(buf) != NULL)
STRLCPY(NameBuff, buf_spname(buf), MAXPATHL);
@@ -2789,58 +2796,59 @@ void free_titles(void)
# endif
+/// Enumeration specifying the valid numeric bases that can
+/// be used when printing numbers in the status line.
+typedef enum {
+ kNumBaseDecimal = 10,
+ kNumBaseOctal = 8,
+ kNumBaseHexadecimal = 16
+} NumberBase;
-/*
- * Build a string from the status line items in "fmt".
- * Return length of string in screen cells.
- *
- * Normally works for window "wp", except when working for 'tabline' then it
- * is "curwin".
- *
- * Items are drawn interspersed with the text that surrounds it
- * Specials: %-<wid>(xxx%) => group, %= => middle marker, %< => truncation
- * Item: %-<minwid>.<maxwid><itemch> All but <itemch> are optional
- *
- * If maxwidth is not zero, the string will be filled at any middle marker
- * or truncated if too long, fillchar is used for all whitespace.
- */
-int
-build_stl_str_hl (
+
+/// Build a string from the status line items in "fmt".
+/// Return length of string in screen cells.
+///
+/// Normally works for window "wp", except when working for 'tabline' then it
+/// is "curwin".
+///
+/// Items are drawn interspersed with the text that surrounds it
+/// Specials: %-<wid>(xxx%) => group, %= => middle marker, %< => truncation
+/// Item: %-<minwid>.<maxwid><itemch> All but <itemch> are optional
+///
+/// If maxwidth is not zero, the string will be filled at any middle marker
+/// or truncated if too long, fillchar is used for all whitespace.
+///
+/// @param wp The window to build a statusline for
+/// @param out The output buffer to write the statusline to
+/// Note: This should not be NameBuff
+/// @param outlen The length of the output buffer
+/// @param fmt The statusline format string
+/// @param use_sandbox Use a sandboxed environment when evaluating fmt
+/// @param fillchar Character to use when filling empty space in the statusline
+/// @param maxwidth The maximum width to make the statusline
+/// @param hltab HL attributes (can be NULL)
+/// @param tabtab tab page nrs (can be NULL)
+///
+/// @return The final width of the statusline
+int build_stl_str_hl(
win_T *wp,
- char_u *out, /* buffer to write into != NameBuff */
- size_t outlen, /* length of out[] */
+ char_u *out,
+ size_t outlen,
char_u *fmt,
- int use_sandbox, /* "fmt" was set insecurely, use sandbox */
+ int use_sandbox,
int fillchar,
int maxwidth,
- struct stl_hlrec *hltab, /* return: HL attributes (can be NULL) */
- struct stl_hlrec *tabtab /* return: tab page nrs (can be NULL) */
+ struct stl_hlrec *hltab,
+ struct stl_hlrec *tabtab
)
{
- char_u *p;
- char_u *s;
- char_u *t;
- int byteval;
- win_T *o_curwin;
- buf_T *o_curbuf;
- int empty_line;
- colnr_T virtcol;
- long l;
- long n;
- int prevchar_isflag;
- int prevchar_isitem;
- int itemisflag;
- int fillable;
- char_u *str;
- long num;
- int width;
- int itemcnt;
- int curitem;
int groupitem[STL_MAX_ITEM];
- int groupdepth;
struct stl_item {
+ // Where the item starts in the status line output buffer
char_u *start;
+ // The minimum width of the item
int minwid;
+ // The maximum width of the item
int maxwid;
enum {
Normal,
@@ -2852,20 +2860,13 @@ build_stl_str_hl (
Trunc
} type;
} item[STL_MAX_ITEM];
- int minwid;
- int maxwid;
- int zeropad;
- char_u base;
- char_u opt;
+
#define TMPLEN 70
char_u tmp[TMPLEN];
char_u *usefmt = fmt;
- struct stl_hlrec *sp;
- /*
- * When the format starts with "%!" then evaluate it as an expression and
- * use the result as the actual format string.
- */
+ // When the format starts with "%!" then evaluate it as an expression and
+ // use the result as the actual format string.
if (fmt[0] == '%' && fmt[1] == '!') {
usefmt = eval_to_string_safe(fmt + 2, NULL, use_sandbox);
if (usefmt == NULL)
@@ -2874,175 +2875,280 @@ build_stl_str_hl (
if (fillchar == 0)
fillchar = ' ';
- /* Can't handle a multi-byte fill character yet. */
+ // Can't handle a multi-byte fill character yet.
else if (mb_char2len(fillchar) > 1)
fillchar = '-';
- /* Get line & check if empty (cursorpos will show "0-1"). Note that
- * p will become invalid when getting another buffer line. */
- p = ml_get_buf(wp->w_buffer, wp->w_cursor.lnum, FALSE);
- empty_line = (*p == NUL);
+ // Get line & check if empty (cursorpos will show "0-1").
+ char_u *line_ptr = ml_get_buf(wp->w_buffer, wp->w_cursor.lnum, false);
+ bool empty_line = (*line_ptr == NUL);
- /* Get the byte value now, in case we need it below. This is more
- * efficient than making a copy of the line. */
- if (wp->w_cursor.col > (colnr_T)STRLEN(p))
+ // Get the byte value now, in case we need it below. This is more
+ // efficient than making a copy of the line.
+ int byteval;
+ if (wp->w_cursor.col > (colnr_T)STRLEN(line_ptr))
byteval = 0;
else
- byteval = (*mb_ptr2char)(p + wp->w_cursor.col);
-
- groupdepth = 0;
- p = out;
- curitem = 0;
- prevchar_isflag = TRUE;
- prevchar_isitem = FALSE;
- for (s = usefmt; *s; ) {
+ byteval = (*mb_ptr2char)(line_ptr + wp->w_cursor.col);
+
+ int groupdepth = 0;
+
+ int curitem = 0;
+ bool prevchar_isflag = true;
+ bool prevchar_isitem = false;
+
+ // out_p is the current position in the output buffer
+ char_u *out_p = out;
+
+ // out_end_p is the last valid character in the output buffer
+ // Note: The null termination character must occur here or earlier,
+ // so any user-visible characters must occur before here.
+ char_u *out_end_p = (out + outlen) - 1;
+
+
+ // Proceed character by character through the statusline format string
+ // fmt_p is the current positon in the input buffer
+ for (char_u *fmt_p = usefmt; *fmt_p; ) {
if (curitem == STL_MAX_ITEM) {
- /* There are too many items. Add the error code to the statusline
- * to give the user a hint about what went wrong. */
- if (p + 6 < out + outlen) {
- memmove(p, " E541", (size_t)5);
- p += 5;
+ // There are too many items. Add the error code to the statusline
+ // to give the user a hint about what went wrong.
+ if (out_p + 5 < out_end_p) {
+ memmove(out_p, " E541", (size_t)5);
+ out_p += 5;
}
break;
}
- if (*s != NUL && *s != '%')
- prevchar_isflag = prevchar_isitem = FALSE;
+ if (*fmt_p != NUL && *fmt_p != '%') {
+ prevchar_isflag = prevchar_isitem = false;
+ }
+
+ // Copy the formatting verbatim until we reach the end of the string
+ // or find a formatting item (denoted by `%`)
+ // or run out of room in our output buffer.
+ while (*fmt_p != NUL && *fmt_p != '%' && out_p < out_end_p)
+ *out_p++ = *fmt_p++;
- /*
- * Handle up to the next '%' or the end.
- */
- while (*s != NUL && *s != '%' && p + 1 < out + outlen)
- *p++ = *s++;
- if (*s == NUL || p + 1 >= out + outlen)
+ // If we have processed the entire format string or run out of
+ // room in our output buffer, exit the loop.
+ if (*fmt_p == NUL || out_p >= out_end_p)
break;
- /*
- * Handle one '%' item.
- */
- s++;
- if (*s == NUL) /* ignore trailing % */
+ // The rest of this loop will handle a single `%` item.
+ // Note: We increment here to skip over the `%` character we are currently
+ // on so we can process the item's contents.
+ fmt_p++;
+
+ // Ignore `%` at the end of the format string
+ if (*fmt_p == NUL) {
break;
- if (*s == '%') {
- if (p + 1 >= out + outlen)
+ }
+
+ // Two `%` in a row is the escape sequence to print a
+ // single `%` in the output buffer.
+ if (*fmt_p == '%') {
+ // Ignore the character if we're out of room in the output buffer.
+ if (out_p >= out_end_p)
break;
- *p++ = *s++;
- prevchar_isflag = prevchar_isitem = FALSE;
+ *out_p++ = *fmt_p++;
+ prevchar_isflag = prevchar_isitem = false;
continue;
}
- if (*s == STL_MIDDLEMARK) {
- s++;
- if (groupdepth > 0)
+
+ // STL_MIDDLEMARK: Separation place between left and right aligned items.
+ if (*fmt_p == STL_MIDDLEMARK) {
+ fmt_p++;
+ // Ignored when we are inside of a grouping
+ if (groupdepth > 0) {
continue;
+ }
item[curitem].type = Middle;
- item[curitem++].start = p;
+ item[curitem++].start = out_p;
continue;
}
- if (*s == STL_TRUNCMARK) {
- s++;
+
+ // STL_TRUNCMARK: Where to begin truncating if the statusline is too long.
+ if (*fmt_p == STL_TRUNCMARK) {
+ fmt_p++;
item[curitem].type = Trunc;
- item[curitem++].start = p;
+ item[curitem++].start = out_p;
continue;
}
- if (*s == ')') {
- s++;
- if (groupdepth < 1)
+
+ // The end of a grouping
+ if (*fmt_p == ')') {
+ fmt_p++;
+ // Ignore if we are not actually inside a group currently
+ if (groupdepth < 1) {
continue;
+ }
groupdepth--;
- t = item[groupitem[groupdepth]].start;
- *p = NUL;
- l = vim_strsize(t);
+ // Determine how long the group is.
+ // Note: We set the current output position to null
+ // so `vim_strsize` will work.
+ char_u *t = item[groupitem[groupdepth]].start;
+ *out_p = NUL;
+ long group_len = vim_strsize(t);
+
+ // If the group contained internal items
+ // and the group did not have a minimum width,
+ // and if there were no normal items in the group,
+ // move the output pointer back to where the group started.
+ // Note: This erases any non-item characters that were in the group.
+ // Otherwise there would be no reason to do this step.
if (curitem > groupitem[groupdepth] + 1
&& item[groupitem[groupdepth]].minwid == 0) {
- /* remove group if all items are empty */
- for (n = groupitem[groupdepth] + 1; n < curitem; n++)
- if (item[n].type == Normal)
+ bool has_normal_items = false;
+ for (long n = groupitem[groupdepth] + 1; n < curitem; n++) {
+ if (item[n].type == Normal) {
+ has_normal_items = true;
break;
- if (n == curitem) {
- p = t;
- l = 0;
+ }
+ }
+
+ if (!has_normal_items) {
+ out_p = t;
+ group_len = 0;
}
}
- if (l > item[groupitem[groupdepth]].maxwid) {
- /* truncate, remove n bytes of text at the start */
+
+ // If the group is longer than it is allowed to be
+ // truncate by removing bytes from the start of the group text.
+ if (group_len > item[groupitem[groupdepth]].maxwid) {
+ // { Determine the number of bytes to remove
+ long n;
if (has_mbyte) {
/* Find the first character that should be included. */
n = 0;
- while (l >= item[groupitem[groupdepth]].maxwid) {
- l -= ptr2cells(t + n);
+ while (group_len >= item[groupitem[groupdepth]].maxwid) {
+ group_len -= ptr2cells(t + n);
n += (*mb_ptr2len)(t + n);
}
- } else
- n = (long)(p - t) - item[groupitem[groupdepth]].maxwid + 1;
+ } else {
+ n = (long)(out_p - t) - item[groupitem[groupdepth]].maxwid + 1;
+ }
+ // }
+ // Prepend the `<` to indicate that the output was truncated.
*t = '<';
- memmove(t + 1, t + n, (size_t)(p - (t + n)));
- p = p - n + 1;
+
+ // { Move the truncated output
+ memmove(t + 1, t + n, (size_t)(out_p - (t + n)));
+ out_p = out_p - n + 1;
/* Fill up space left over by half a double-wide char. */
- while (++l < item[groupitem[groupdepth]].minwid)
- *p++ = fillchar;
+ while (++group_len < item[groupitem[groupdepth]].minwid)
+ *out_p++ = fillchar;
+ // }
/* correct the start of the items for the truncation */
- for (l = groupitem[groupdepth] + 1; l < curitem; l++) {
- item[l].start -= n;
- if (item[l].start < t)
- item[l].start = t;
+ for (int idx = groupitem[groupdepth] + 1; idx < curitem; idx++) {
+ // Shift everything back by the number of removed bytes
+ item[idx].start -= n;
+
+ // If the item was partially or completely truncated, set its
+ // start to the start of the group
+ if (item[idx].start < t) {
+ item[idx].start = t;
+ }
}
- } else if (abs(item[groupitem[groupdepth]].minwid) > l) {
- /* fill */
- n = item[groupitem[groupdepth]].minwid;
- if (n < 0) {
- /* fill by appending characters */
- n = 0 - n;
- while (l++ < n && p + 1 < out + outlen)
- *p++ = fillchar;
+ // If the group is shorter than the minimum width, add padding characters.
+ } else if (abs(item[groupitem[groupdepth]].minwid) > group_len) {
+ long min_group_width = item[groupitem[groupdepth]].minwid;
+ // If the group is left-aligned, add characters to the right.
+ if (min_group_width < 0) {
+ min_group_width = 0 - min_group_width;
+ while (group_len++ < min_group_width && out_p < out_end_p)
+ *out_p++ = fillchar;
+ // If the group is right-aligned, shift everything to the right and
+ // prepend with filler characters.
} else {
- /* fill by inserting characters */
- memmove(t + n - l, t, (size_t)(p - t));
- l = n - l;
- if (p + l >= out + outlen)
- l = (long)((out + outlen) - p - 1);
- p += l;
- for (n = groupitem[groupdepth] + 1; n < curitem; n++)
- item[n].start += l;
- for (; l > 0; l--)
+ // { Move the group to the right
+ memmove(t + min_group_width - group_len, t, (size_t)(out_p - t));
+ group_len = min_group_width - group_len;
+ if (out_p + group_len >= (out_end_p + 1)) {
+ group_len = (long)(out_end_p - out_p);
+ }
+ out_p += group_len;
+ // }
+
+ // Adjust item start positions
+ for (int n = groupitem[groupdepth] + 1; n < curitem; n++) {
+ item[n].start += group_len;
+ }
+
+ // Prepend the fill characters
+ for (; group_len > 0; group_len--) {
*t++ = fillchar;
+ }
}
}
continue;
}
- minwid = 0;
- maxwid = 9999;
- zeropad = FALSE;
- l = 1;
- if (*s == '0') {
- s++;
- zeropad = TRUE;
+ int minwid = 0;
+ int maxwid = 9999;
+ bool left_align = false;
+
+ // Denotes that numbers should be left-padded with zeros
+ bool zeropad = (*fmt_p == '0');
+ if (zeropad) {
+ fmt_p++;
}
- if (*s == '-') {
- s++;
- l = -1;
+
+ // Denotes that the item should be left-aligned.
+ // This is tracked by using a negative length.
+ if (*fmt_p == '-') {
+ fmt_p++;
+ left_align = true;
}
- if (ascii_isdigit(*s)) {
- minwid = getdigits_int(&s);
+
+ // The first digit group is the item's min width
+ if (ascii_isdigit(*fmt_p)) {
+ minwid = getdigits_int(&fmt_p);
if (minwid < 0) /* overflow */
minwid = 0;
}
- if (*s == STL_USER_HL) {
+
+ // User highlight groups override the min width field
+ // to denote the styling to use.
+ if (*fmt_p == STL_USER_HL) {
item[curitem].type = Highlight;
- item[curitem].start = p;
+ item[curitem].start = out_p;
item[curitem].minwid = minwid > 9 ? 1 : minwid;
- s++;
+ fmt_p++;
curitem++;
continue;
}
- if (*s == STL_TABPAGENR || *s == STL_TABCLOSENR) {
- if (*s == STL_TABCLOSENR) {
+
+ // TABPAGE pairs are used to denote a region that when clicked will
+ // either switch to or close a tab.
+ //
+ // Ex: tabline=%0Ttab\ zero%X
+ // This tabline has a TABPAGENR item with minwid `0`,
+ // which is then closed with a TABCLOSENR item.
+ // Clicking on this region with mouse enabled will switch to tab 0.
+ // Setting the minwid to a different value will switch
+ // to that tab, if it exists
+ //
+ // Ex: tabline=%1Xtab\ one%X
+ // This tabline has a TABCLOSENR item with minwid `1`,
+ // which is then closed with a TABCLOSENR item.
+ // Clicking on this region with mouse enabled will close tab 0.
+ // This is determined by the following formula:
+ // tab to close = (1 - minwid)
+ // This is because for TABPAGENR we use `minwid` = `tab number`.
+ // For TABCLOSENR we store the tab number as a negative value.
+ // Because 0 is a valid TABPAGENR value, we have to
+ // start our numbering at `-1`.
+ // So, `-1` corresponds to us wanting to close tab `0`
+ //
+ // Note: These options are only valid when creating a tabline.
+ if (*fmt_p == STL_TABPAGENR || *fmt_p == STL_TABCLOSENR) {
+ if (*fmt_p == STL_TABCLOSENR) {
if (minwid == 0) {
/* %X ends the close label, go back to the previously
* define tab label nr. */
- for (n = curitem - 1; n >= 0; --n)
+ for (long n = curitem - 1; n >= 0; --n)
if (item[n].type == TabPage && item[n].minwid >= 0) {
minwid = item[n].minwid;
break;
@@ -3052,54 +3158,70 @@ build_stl_str_hl (
minwid = -minwid;
}
item[curitem].type = TabPage;
- item[curitem].start = p;
+ item[curitem].start = out_p;
item[curitem].minwid = minwid;
- s++;
+ fmt_p++;
curitem++;
continue;
}
- if (*s == '.') {
- s++;
- if (ascii_isdigit(*s)) {
- maxwid = getdigits_int(&s);
+
+ // Denotes the end of the minwid
+ // the maxwid may follow immediately after
+ if (*fmt_p == '.') {
+ fmt_p++;
+ if (ascii_isdigit(*fmt_p)) {
+ maxwid = getdigits_int(&fmt_p);
if (maxwid <= 0) /* overflow */
maxwid = 50;
}
}
- minwid = (minwid > 50 ? 50 : minwid) * l;
- if (*s == '(') {
+
+ // Bound the minimum width at 50.
+ // Make the number negative to denote left alignment of the item
+ minwid = (minwid > 50 ? 50 : minwid) * (left_align ? -1 : 1);
+
+ // Denotes the start of a new group
+ if (*fmt_p == '(') {
groupitem[groupdepth++] = curitem;
item[curitem].type = Group;
- item[curitem].start = p;
+ item[curitem].start = out_p;
item[curitem].minwid = minwid;
item[curitem].maxwid = maxwid;
- s++;
+ fmt_p++;
curitem++;
continue;
}
- if (vim_strchr(STL_ALL, *s) == NULL) {
- s++;
+
+ // An invalid item was specified.
+ // Continue processing on the next character of the format string.
+ if (vim_strchr(STL_ALL, *fmt_p) == NULL) {
+ fmt_p++;
continue;
}
- opt = *s++;
-
- /* OK - now for the real work */
- base = 'D';
- itemisflag = FALSE;
- fillable = TRUE;
- num = -1;
- str = NULL;
+
+ // The status line item type
+ char_u opt = *fmt_p++;
+
+ // OK - now for the real work
+ NumberBase base = kNumBaseDecimal;
+ bool itemisflag = false;
+ bool fillable = true;
+ long num = -1;
+ char_u *str = NULL;
switch (opt) {
case STL_FILEPATH:
case STL_FULLPATH:
case STL_FILENAME:
- fillable = FALSE; /* don't change ' ' to fillchar */
- if (buf_spname(wp->w_buffer) != NULL)
+ {
+ // Set fillable to false to that ' ' in the filename will not
+ // get replaced with the fillchar
+ fillable = false;
+ if (buf_spname(wp->w_buffer) != NULL) {
STRLCPY(NameBuff, buf_spname(wp->w_buffer), MAXPATHL);
- else {
- t = (opt == STL_FULLPATH) ? wp->w_buffer->b_ffname
- : wp->w_buffer->b_fname;
- home_replace(wp->w_buffer, t, NameBuff, MAXPATHL, TRUE);
+ } else {
+ char_u *t = (opt == STL_FULLPATH) ? wp->w_buffer->b_ffname
+ : wp->w_buffer->b_fname;
+ home_replace(wp->w_buffer, t, NameBuff, MAXPATHL, true);
}
trans_characters(NameBuff, MAXPATHL);
if (opt != STL_FILENAME)
@@ -3107,42 +3229,59 @@ build_stl_str_hl (
else
str = path_tail(NameBuff);
break;
-
+ }
case STL_VIM_EXPR: /* '{' */
- itemisflag = TRUE;
- t = p;
- while (*s != '}' && *s != NUL && p + 1 < out + outlen)
- *p++ = *s++;
- if (*s != '}') /* missing '}' or out of space */
+ {
+ itemisflag = true;
+
+ // Attempt to copy the expression to evaluate into
+ // the output buffer as a null-terminated string.
+ char_u *t = out_p;
+ while (*fmt_p != '}' && *fmt_p != NUL && out_p < out_end_p)
+ *out_p++ = *fmt_p++;
+ if (*fmt_p != '}') /* missing '}' or out of space */
break;
- s++;
- *p = 0;
- p = t;
+ fmt_p++;
+ *out_p = 0;
+ // Move our position in the output buffer
+ // to the beginning of the expression
+ out_p = t;
+
+ // { Evaluate the expression
+
+ // Store the current buffer number as a string variable
vim_snprintf((char *)tmp, sizeof(tmp), "%d", curbuf->b_fnum);
set_internal_string_var((char_u *)"actual_curbuf", tmp);
- o_curbuf = curbuf;
- o_curwin = curwin;
+ buf_T *o_curbuf = curbuf;
+ win_T *o_curwin = curwin;
curwin = wp;
curbuf = wp->w_buffer;
- str = eval_to_string_safe(p, &t, use_sandbox);
+ // Note: The result stored in `t` is unused.
+ str = eval_to_string_safe(out_p, &t, use_sandbox);
curwin = o_curwin;
curbuf = o_curbuf;
- do_unlet((char_u *)"g:actual_curbuf", TRUE);
+ // Remove the variable we just stored
+ do_unlet((char_u *)"g:actual_curbuf", true);
+
+ // }
+
+ // Check if the evaluated result is a number.
+ // If so, convert the number to an int and free the string.
if (str != NULL && *str != 0) {
if (*skipdigits(str) == NUL) {
num = atoi((char *)str);
xfree(str);
str = NULL;
- itemisflag = FALSE;
+ itemisflag = false;
}
}
break;
-
+ }
case STL_LINE:
num = (wp->w_buffer->b_ml.ml_flags & ML_EMPTY)
? 0L : (long)(wp->w_cursor.lnum);
@@ -3159,21 +3298,23 @@ build_stl_str_hl (
case STL_VIRTCOL:
case STL_VIRTCOL_ALT:
- /* In list mode virtcol needs to be recomputed */
- virtcol = wp->w_virtcol;
+ {
+ // In list mode virtcol needs to be recomputed
+ colnr_T virtcol = wp->w_virtcol;
if (wp->w_p_list && lcs_tab1 == NUL) {
wp->w_p_list = FALSE;
getvcol(wp, &wp->w_cursor, NULL, &virtcol, NULL);
wp->w_p_list = TRUE;
}
++virtcol;
- /* Don't display %V if it's the same as %c. */
+ // Don't display %V if it's the same as %c.
if (opt == STL_VIRTCOL_ALT
&& (virtcol == (colnr_T)(!(State & INSERT) && empty_line
? 0 : (int)wp->w_cursor.col + 1)))
break;
num = (long)virtcol;
break;
+ }
case STL_PERCENTAGE:
num = (int)(((long)wp->w_cursor.lnum * 100L) /
@@ -3181,19 +3322,31 @@ build_stl_str_hl (
break;
case STL_ALTPERCENT:
+ // Store the position percentage in our temporary buffer.
+ // Note: We cannot store the value in `num` because
+ // `get_rel_pos` can return a named position. Ex: "Top"
+ get_rel_pos(wp, tmp, TMPLEN);
str = tmp;
- get_rel_pos(wp, str, TMPLEN);
break;
case STL_ARGLISTSTAT:
- fillable = FALSE;
+ fillable = false;
+
+ // Note: This is important because `append_arg_number` starts appending
+ // at the end of the null-terminated string.
+ // Setting the first byte to null means it will place the argument
+ // number string at the beginning of the buffer.
tmp[0] = 0;
- if (append_arg_number(wp, tmp, (int)sizeof(tmp), FALSE))
+
+ // Note: The call will only return true if it actually
+ // appended data to the `tmp` buffer.
+ if (append_arg_number(wp, tmp, (int)sizeof(tmp), false)) {
str = tmp;
+ }
break;
case STL_KEYMAP:
- fillable = FALSE;
+ fillable = false;
if (get_keymap_str(wp, tmp, TMPLEN))
str = tmp;
break;
@@ -3206,16 +3359,17 @@ build_stl_str_hl (
break;
case STL_OFFSET_X:
- base = 'X';
+ base = kNumBaseHexadecimal;
case STL_OFFSET:
- l = ml_find_line_or_offset(wp->w_buffer, wp->w_cursor.lnum, NULL);
+ {
+ long l = ml_find_line_or_offset(wp->w_buffer, wp->w_cursor.lnum, NULL);
num = (wp->w_buffer->b_ml.ml_flags & ML_EMPTY) || l < 0 ?
0L : l + 1 + (!(State & INSERT) && empty_line ?
0 : (int)wp->w_cursor.col);
break;
-
+ }
case STL_BYTEVAL_X:
- base = 'X';
+ base = kNumBaseHexadecimal;
case STL_BYTEVAL:
num = byteval;
if (num == NL)
@@ -3226,20 +3380,23 @@ build_stl_str_hl (
case STL_ROFLAG:
case STL_ROFLAG_ALT:
- itemisflag = TRUE;
+ itemisflag = true;
if (wp->w_buffer->b_p_ro)
str = (char_u *)((opt == STL_ROFLAG_ALT) ? ",RO" : _("[RO]"));
break;
case STL_HELPFLAG:
case STL_HELPFLAG_ALT:
- itemisflag = TRUE;
+ itemisflag = true;
if (wp->w_buffer->b_help)
str = (char_u *)((opt == STL_HELPFLAG_ALT) ? ",HLP"
: _("[Help]"));
break;
case STL_FILETYPE:
+ // Copy the filetype if it is not null and the formatted string will fit
+ // in the temporary buffer
+ // (including the brackets and null terminating character)
if (*wp->w_buffer->b_p_ft != NUL
&& STRLEN(wp->w_buffer->b_p_ft) < TMPLEN - 3) {
vim_snprintf((char *)tmp, sizeof(tmp), "[%s]",
@@ -3249,20 +3406,26 @@ build_stl_str_hl (
break;
case STL_FILETYPE_ALT:
- itemisflag = TRUE;
+ {
+ itemisflag = true;
+ // Copy the filetype if it is not null and the formatted string will fit
+ // in the temporary buffer
+ // (including the comma and null terminating character)
if (*wp->w_buffer->b_p_ft != NUL
&& STRLEN(wp->w_buffer->b_p_ft) < TMPLEN - 2) {
vim_snprintf((char *)tmp, sizeof(tmp), ",%s",
wp->w_buffer->b_p_ft);
- for (t = tmp; *t != 0; t++)
+ // Uppercase the file extension
+ for (char_u *t = tmp; *t != 0; t++) {
*t = TOUPPER_LOC(*t);
+ }
str = tmp;
}
break;
-
+ }
case STL_PREVIEWFLAG:
case STL_PREVIEWFLAG_ALT:
- itemisflag = TRUE;
+ itemisflag = true;
if (wp->w_p_pvw)
str = (char_u *)((opt == STL_PREVIEWFLAG_ALT) ? ",PRV"
: _("[Preview]"));
@@ -3277,7 +3440,7 @@ build_stl_str_hl (
case STL_MODIFIED:
case STL_MODIFIED_ALT:
- itemisflag = TRUE;
+ itemisflag = true;
switch ((opt == STL_MODIFIED_ALT)
+ bufIsChanged(wp->w_buffer) * 2
+ (!MODIFIABLE(wp->w_buffer)) * 4) {
@@ -3291,212 +3454,362 @@ build_stl_str_hl (
break;
case STL_HIGHLIGHT:
- t = s;
- while (*s != '#' && *s != NUL)
- ++s;
- if (*s == '#') {
+ {
+ // { The name of the highlight is surrounded by `#`
+ char_u *t = fmt_p;
+ while (*fmt_p != '#' && *fmt_p != NUL) {
+ ++fmt_p;
+ }
+ // }
+
+ // Create a highlight item based on the name
+ if (*fmt_p == '#') {
item[curitem].type = Highlight;
- item[curitem].start = p;
- item[curitem].minwid = -syn_namen2id(t, (int)(s - t));
+ item[curitem].start = out_p;
+ item[curitem].minwid = -syn_namen2id(t, (int)(fmt_p - t));
curitem++;
+ fmt_p++;
}
- if (*s != NUL)
- ++s;
continue;
}
+ }
- item[curitem].start = p;
+ // If we made it this far, the item is normal and starts at
+ // our current position in the output buffer.
+ // Non-normal items would have `continued`.
+ item[curitem].start = out_p;
item[curitem].type = Normal;
+
+ // Copy the item string into the output buffer
if (str != NULL && *str) {
- t = str;
+ // { Skip the leading `,` or ` ` if the item is a flag
+ // and the proper conditions are met
+ char_u *t = str;
if (itemisflag) {
if ((t[0] && t[1])
&& ((!prevchar_isitem && *t == ',')
|| (prevchar_isflag && *t == ' ')))
t++;
- prevchar_isflag = TRUE;
+ prevchar_isflag = true;
}
- l = vim_strsize(t);
- if (l > 0)
- prevchar_isitem = TRUE;
+ // }
+
+ long l = vim_strsize(t);
+
+ // If this item is non-empty, record that the last thing
+ // we put in the output buffer was an item
+ if (l > 0) {
+ prevchar_isitem = true;
+ }
+
+ // If the item is too wide, truncate it from the beginning
if (l > maxwid) {
while (l >= maxwid)
if (has_mbyte) {
l -= ptr2cells(t);
t += (*mb_ptr2len)(t);
- } else
+ } else {
l -= byte2cells(*t++);
- if (p + 1 >= out + outlen)
+ }
+
+ // Early out if there isn't enough room for the truncation marker
+ if (out_p >= out_end_p)
break;
- *p++ = '<';
+
+ // Add the truncation marker
+ *out_p++ = '<';
}
+
+ // If the item is right aligned and not wide enough,
+ // pad with fill characters.
if (minwid > 0) {
- for (; l < minwid && p + 1 < out + outlen; l++) {
- /* Don't put a "-" in front of a digit. */
+ for (; l < minwid && out_p < out_end_p; l++) {
+ // Don't put a "-" in front of a digit.
if (l + 1 == minwid && fillchar == '-' && ascii_isdigit(*t))
- *p++ = ' ';
+ *out_p++ = ' ';
else
- *p++ = fillchar;
+ *out_p++ = fillchar;
}
minwid = 0;
- } else
+ } else {
+ // Note: The negative value denotes a left aligned item.
+ // Here we switch the minimum width back to a positive value.
minwid *= -1;
- while (*t && p + 1 < out + outlen) {
- *p++ = *t++;
- /* Change a space by fillchar, unless fillchar is '-' and a
- * digit follows. */
- if (fillable && p[-1] == ' '
+ }
+
+ // { Copy the string text into the output buffer
+ while (*t && out_p < out_end_p) {
+ *out_p++ = *t++;
+ // Change a space by fillchar, unless fillchar is '-' and a
+ // digit follows.
+ if (fillable && out_p[-1] == ' '
&& (!ascii_isdigit(*t) || fillchar != '-'))
- p[-1] = fillchar;
+ out_p[-1] = fillchar;
}
- for (; l < minwid && p + 1 < out + outlen; l++)
- *p++ = fillchar;
- } else if (num >= 0) {
- int nbase = (base == 'D' ? 10 : (base == 'O' ? 8 : 16));
- char_u nstr[20];
+ // }
- if (p + 20 >= out + outlen)
+ // For left-aligned items, fill any remaining space with the fillchar
+ for (; l < minwid && out_p < out_end_p; l++) {
+ *out_p++ = fillchar;
+ }
+
+ // Otherwise if the item is a number, copy that to the output buffer.
+ } else if (num >= 0) {
+ if (out_p + 20 > out_end_p)
break; /* not sufficient space */
- prevchar_isitem = TRUE;
- t = nstr;
+ prevchar_isitem = true;
+
+ // { Build the formatting string
+ char_u nstr[20];
+ char_u *t = nstr;
if (opt == STL_VIRTCOL_ALT) {
*t++ = '-';
minwid--;
}
*t++ = '%';
- if (zeropad)
+ if (zeropad) {
*t++ = '0';
+ }
+
+ // Note: The `*` means we take the width as one of the arguments
*t++ = '*';
- *t++ = nbase == 16 ? base : (char_u)(nbase == 8 ? 'o' : 'd');
+ *t++ = (char_u) (base == kNumBaseHexadecimal ? 'X'
+ : (base == kNumBaseOctal ? 'o'
+ : 'd'));
*t = 0;
+ // }
+
+ // { Determine how many characters the number will take up when printed
+ // Note: We have to cast the base because the compiler uses
+ // unsigned ints for the enum values.
+ long num_chars = 1;
+ for (long n = num; n >= (int) base; n /= (int) base) {
+ num_chars++;
+ }
- for (n = num, l = 1; n >= nbase; n /= nbase)
- l++;
- if (opt == STL_VIRTCOL_ALT)
- l++;
- if (l > maxwid) {
- l += 2;
- n = l - maxwid;
- while (l-- > maxwid)
- num /= nbase;
+ // VIRTCOL_ALT takes up an extra character because
+ // of the `-` we added above.
+ if (opt == STL_VIRTCOL_ALT) {
+ num_chars++;
+ }
+ // }
+
+ size_t remaining_buf_len = (out_end_p - out_p) + 1;
+
+ // If the number is going to take up too much room
+ // Figure out the approximate number in "scientific" type notation.
+ // Ex: 14532 with maxwid of 4 -> '14>3'
+ if (num_chars > maxwid) {
+ // Add two to the width because the power piece will take
+ // two extra characters
+ num_chars += 2;
+
+ // How many extra characters there are
+ long n = num_chars - maxwid;
+
+ // { Reduce the number by base^n
+ while (num_chars-- > maxwid) {
+ num /= base;
+ }
+ // }
+
+ // { Add the format string for the exponent bit
*t++ = '>';
*t++ = '%';
+ // Use the same base as the first number
*t = t[-3];
*++t = 0;
- vim_snprintf((char *)p, outlen - (p - out), (char *)nstr,
+ // }
+
+ vim_snprintf((char *)out_p, remaining_buf_len, (char *)nstr,
0, num, n);
- } else
- vim_snprintf((char *)p, outlen - (p - out), (char *)nstr,
+ } else {
+ vim_snprintf((char *)out_p, remaining_buf_len, (char *)nstr,
minwid, num);
- p += STRLEN(p);
- } else
+ }
+
+ // Advance the output buffer position to the end of the
+ // number we just printed
+ out_p += STRLEN(out_p);
+
+ // Otherwise, there was nothing to print so mark the item as empty
+ } else {
item[curitem].type = Empty;
+ }
- if (opt == STL_VIM_EXPR)
+ // Only free the string buffer if we allocated it.
+ // Note: This is not needed if `str` is pointing at `tmp`
+ if (opt == STL_VIM_EXPR) {
xfree(str);
+ }
if (num >= 0 || (!itemisflag && str && *str))
- prevchar_isflag = FALSE; /* Item not NULL, but not a flag */
+ prevchar_isflag = false; /* Item not NULL, but not a flag */
+
+ // Item processed, move to the next
curitem++;
}
- *p = NUL;
- itemcnt = curitem;
- if (usefmt != fmt)
+ *out_p = NUL;
+ int itemcnt = curitem;
+
+ // Free the format buffer if we allocated it internally
+ if (usefmt != fmt) {
xfree(usefmt);
+ }
+
+ // We have now processed the entire statusline format string.
+ // What follows is post-processing to handle alignment and
+ // highlighting factors.
- width = vim_strsize(out);
+ int width = vim_strsize(out);
if (maxwidth > 0 && width > maxwidth) {
- /* Result is too long, must truncate somewhere. */
- l = 0;
- if (itemcnt == 0)
- s = out;
- else {
- for (; l < itemcnt; l++)
- if (item[l].type == Trunc) {
- /* Truncate at %< item. */
- s = item[l].start;
+ // Result is too long, must truncate somewhere.
+ int item_idx = 0;
+ char_u *trunc_p;
+
+ // If there are no items, truncate from beginning
+ if (itemcnt == 0) {
+ trunc_p = out;
+
+ // Otherwise, look for the truncation item
+ } else {
+ // Default to truncating at the first item
+ trunc_p = item[0].start;
+ item_idx = 0;
+
+ for (int i = 0; i < itemcnt; i++)
+ if (item[i].type == Trunc) {
+ // Truncate at %< item.
+ trunc_p = item[i].start;
+ item_idx = i;
break;
}
- if (l == itemcnt) {
- /* No %< item, truncate first item. */
- s = item[0].start;
- l = 0;
- }
}
- if (width - vim_strsize(s) >= maxwidth) {
- /* Truncation mark is beyond max length */
+ // If the truncation point we found is beyond the maximum
+ // length of the string, truncate the end of the string.
+ if (width - vim_strsize(trunc_p) >= maxwidth) {
+ // If we are using a multi-byte encoding, walk from the beginning of the
+ // string to find the last character that will fit.
if (has_mbyte) {
- s = out;
+ trunc_p = out;
width = 0;
for (;; ) {
- width += ptr2cells(s);
+ width += ptr2cells(trunc_p);
if (width >= maxwidth)
break;
- s += (*mb_ptr2len)(s);
+
+ // Note: Only advance the pointer if the next
+ // character will fit in the available output space
+ trunc_p += (*mb_ptr2len)(trunc_p);
}
- /* Fill up for half a double-wide character. */
- while (++width < maxwidth)
- *s++ = fillchar;
- } else
- s = out + maxwidth - 1;
- for (l = 0; l < itemcnt; l++)
- if (item[l].start > s)
+
+ // Otherwise put the truncation point at the end, leaving enough room
+ // for a single-character truncation marker
+ } else {
+ trunc_p = out + maxwidth - 1;
+ }
+
+ // Ignore any items in the statusline that occur after
+ // the truncation point
+ for (int i = 0; i < itemcnt; i++) {
+ if (item[i].start > trunc_p) {
+ itemcnt = i;
break;
- itemcnt = l;
- *s++ = '>';
- *s = 0;
+ }
+ }
+
+ // Truncate the output
+ *trunc_p++ = '>';
+ *trunc_p = 0;
+
+ // Truncate at the truncation point we found
} else {
+ // { Determine how many bytes to remove
+ long trunc_len;
if (has_mbyte) {
- n = 0;
+ trunc_len = 0;
while (width >= maxwidth) {
- width -= ptr2cells(s + n);
- n += (*mb_ptr2len)(s + n);
+ width -= ptr2cells(trunc_p + trunc_len);
+ trunc_len += (*mb_ptr2len)(trunc_p + trunc_len);
}
- } else
- n = width - maxwidth + 1;
- p = s + n;
- STRMOVE(s + 1, p);
- *s = '<';
+ } else {
+ // Truncate an extra character so we can insert our `<`.
+ trunc_len = (width - maxwidth) + 1;
+ }
+ // }
- /* Fill up for half a double-wide character. */
- while (++width < maxwidth) {
- s = s + STRLEN(s);
- *s++ = fillchar;
- *s = NUL;
+ // { Truncate the string
+ char_u *trunc_end_p = trunc_p + trunc_len;
+ STRMOVE(trunc_p + 1, trunc_end_p);
+
+ // Put a `<` to mark where we truncated at
+ *trunc_p = '<';
+
+ if (width + 1 < maxwidth) {
+ // Advance the pointer to the end of the string
+ trunc_p = trunc_p + STRLEN(trunc_p);
}
- --n; /* count the '<' */
- for (; l < itemcnt; l++) {
- if (item[l].start - n >= s)
- item[l].start -= n;
- else
- item[l].start = s;
+ // Fill up for half a double-wide character.
+ while (++width < maxwidth) {
+ *trunc_p++ = fillchar;
+ *trunc_p = NUL;
}
+ // }
+
+ // { Change the start point for items based on
+ // their position relative to our truncation point
+
+ // Note: The offset is one less than the truncation length because
+ // the truncation marker `<` is not counted.
+ long item_offset = trunc_len - 1;
+
+ for (int i = item_idx; i < itemcnt; i++) {
+ // Items starting at or after the end of the truncated section need
+ // to be moved backwards.
+ if (item[i].start >= trunc_end_p) {
+ item[i].start -= item_offset;
+ // Anything inside the truncated area is set to start
+ // at the `<` truncation character.
+ } else {
+ item[i].start = trunc_p;
+ }
+ }
+ // }
}
width = maxwidth;
- } else if (width < maxwidth && STRLEN(out) + maxwidth - width + 1 <
- outlen) {
- /* Apply STL_MIDDLE if any */
- for (l = 0; l < itemcnt; l++)
- if (item[l].type == Middle)
+
+ // If there is room left in our statusline, and room left in our buffer,
+ // add characters at the middle marker (if there is one) to
+ // fill up the available space.
+ } else if (width < maxwidth
+ && STRLEN(out) + maxwidth - width + 1 < outlen) {
+ for (int item_idx = 0; item_idx < itemcnt; item_idx++) {
+ if (item[item_idx].type == Middle) {
+ // Move the statusline to make room for the middle characters
+ char_u *middle_end = item[item_idx].start + (maxwidth - width);
+ STRMOVE(middle_end, item[item_idx].start);
+
+ // Fill the middle section with our fill character
+ for (char_u *s = item[item_idx].start; s < middle_end; s++)
+ *s = fillchar;
+
+ // Adjust the offset of any items after the middle
+ for (item_idx++; item_idx < itemcnt; item_idx++)
+ item[item_idx].start += maxwidth - width;
+
+ width = maxwidth;
break;
- if (l < itemcnt) {
- p = item[l].start + maxwidth - width;
- STRMOVE(p, item[l].start);
- for (s = item[l].start; s < p; s++)
- *s = fillchar;
- for (l++; l < itemcnt; l++)
- item[l].start += maxwidth - width;
- width = maxwidth;
+ }
}
}
- /* Store the info about highlighting. */
+ // Store the info about highlighting.
if (hltab != NULL) {
- sp = hltab;
- for (l = 0; l < itemcnt; l++) {
+ struct stl_hlrec *sp = hltab;
+ for (long l = 0; l < itemcnt; l++) {
if (item[l].type == Highlight) {
sp->start = item[l].start;
sp->userhl = item[l].minwid;
@@ -3507,10 +3820,10 @@ build_stl_str_hl (
sp->userhl = 0;
}
- /* Store the info about tab pages labels. */
+ // Store the info about tab pages labels.
if (tabtab != NULL) {
- sp = tabtab;
- for (l = 0; l < itemcnt; l++) {
+ struct stl_hlrec *sp = tabtab;
+ for (long l = 0; l < itemcnt; l++) {
if (item[l].type == TabPage) {
sp->start = item[l].start;
sp->userhl = item[l].minwid;
diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h
index 3eabb7ee43..6b5bbe3b00 100644
--- a/src/nvim/buffer_defs.h
+++ b/src/nvim/buffer_defs.h
@@ -612,6 +612,7 @@ struct file_buffer {
char_u *b_p_cfu; /* 'completefunc' */
char_u *b_p_ofu; /* 'omnifunc' */
int b_p_eol; /* 'endofline' */
+ int b_p_fixeol; /* 'fixendofline' */
int b_p_et; /* 'expandtab' */
int b_p_et_nobin; /* b_p_et saved for binary mode */
char_u *b_p_fenc; /* 'fileencoding' */
diff --git a/src/nvim/diff.c b/src/nvim/diff.c
index 6e2b3056e4..d311588ab4 100644
--- a/src/nvim/diff.c
+++ b/src/nvim/diff.c
@@ -2,7 +2,6 @@
///
/// Code for diff'ing two, three or four buffers.
-#include <errno.h>
#include <inttypes.h>
#include <stdbool.h>
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index 2d6dcf4f80..9ba5d96e16 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -1,17 +1,8 @@
/*
- * VIM - Vi IMproved by Bram Moolenaar
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- * See README.txt for an overview of the Vim source code.
- */
-
-/*
* edit.c: functions for Insert mode
*/
#include <assert.h>
-#include <errno.h>
#include <string.h>
#include <inttypes.h>
#include <stdbool.h>
@@ -52,6 +43,7 @@
#include "nvim/search.h"
#include "nvim/spell.h"
#include "nvim/strings.h"
+#include "nvim/state.h"
#include "nvim/syntax.h"
#include "nvim/tag.h"
#include "nvim/ui.h"
@@ -192,6 +184,28 @@ static expand_T compl_xp;
static int compl_opt_refresh_always = FALSE;
+typedef struct insert_state {
+ VimState state;
+ cmdarg_T *ca;
+ int mincol;
+ int cmdchar;
+ int startln;
+ long count;
+ int c;
+ int lastc;
+ int i;
+ bool did_backspace; // previous char was backspace
+ bool line_is_white; // line is empty before insert
+ linenr_T old_topline; // topline before insertion
+ int old_topfill;
+ int inserted_space; // just inserted a space
+ int replaceState;
+ int did_restart_edit; // remember if insert mode was restarted
+ // after a ctrl+o
+ bool nomove;
+ uint8_t *ptr;
+} InsertState;
+
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "edit.c.generated.h"
@@ -228,111 +242,48 @@ static int ins_need_undo; /* call u_save() before inserting a
static int did_add_space = FALSE; /* auto_format() added an extra space
under the cursor */
+static int dont_sync_undo = false; // CTRL-G U prevents syncing undo
+ // for the next left/right cursor
-/*
- * edit(): Start inserting text.
- *
- * "cmdchar" can be:
- * 'i' normal insert command
- * 'a' normal append command
- * 'R' replace command
- * 'r' "r<CR>" command: insert one <CR>. Note: count can be > 1, for redo,
- * but still only one <CR> is inserted. The <Esc> is not used for redo.
- * 'g' "gI" command.
- * 'V' "gR" command for Virtual Replace mode.
- * 'v' "gr" command for single character Virtual Replace mode.
- *
- * This function is not called recursively. For CTRL-O commands, it returns
- * and lets the caller handle the Normal-mode command.
- *
- * Return TRUE if a CTRL-O command caused the return (insert mode pending).
- */
-int
-edit (
- int cmdchar,
- int startln, /* if set, insert at start of line */
- long count
-)
-{
- if (curbuf->terminal) {
- if (ex_normal_busy) {
- // don't enter terminal mode from `ex_normal`, which can result in all
- // kinds of havoc(such as terminal mode recursiveness). Instead, set a
- // flag that allow us to force-set the value of `restart_edit` before
- // `ex_normal` returns
- restart_edit = 'i';
- force_restart_edit = true;
- } else {
- terminal_enter();
- }
- return false;
- }
+static linenr_T o_lnum = 0;
- int c = 0;
- char_u *ptr;
- int lastc;
- int mincol;
- static linenr_T o_lnum = 0;
- int i;
- int did_backspace = TRUE; /* previous char was backspace */
- int line_is_white = FALSE; /* line is empty before insert */
- linenr_T old_topline = 0; /* topline before insertion */
- int old_topfill = -1;
- int inserted_space = FALSE; /* just inserted a space */
- int replaceState = REPLACE;
- int nomove = FALSE; /* don't move cursor on return */
-
- /* Remember whether editing was restarted after CTRL-O. */
+static void insert_enter(InsertState *s)
+{
+ s->did_backspace = true;
+ s->old_topfill = -1;
+ s->replaceState = REPLACE;
+ // Remember whether editing was restarted after CTRL-O
did_restart_edit = restart_edit;
-
- /* sleep before redrawing, needed for "CTRL-O :" that results in an
- * error message */
- check_for_delay(TRUE);
-
+ // sleep before redrawing, needed for "CTRL-O :" that results in an
+ // error message
+ check_for_delay(true);
// set Insstart_orig to Insstart
update_Insstart_orig = true;
- // Don't allow inserting in the sandbox.
- if (sandbox != 0) {
- EMSG(_(e_sandbox));
- return FALSE;
- }
- /* Don't allow changes in the buffer while editing the cmdline. The
- * caller of getcmdline() may get confused. */
- if (textlock != 0) {
- EMSG(_(e_secure));
- return FALSE;
- }
-
- /* Don't allow recursive insert mode when busy with completion. */
- if (compl_started || compl_busy || pum_visible()) {
- EMSG(_(e_secure));
- return FALSE;
- }
- ins_compl_clear(); /* clear stuff for CTRL-X mode */
+ ins_compl_clear(); // clear stuff for CTRL-X mode
- /*
- * Trigger InsertEnter autocommands. Do not do this for "r<CR>" or "grx".
- */
- if (cmdchar != 'r' && cmdchar != 'v') {
+ // Trigger InsertEnter autocommands. Do not do this for "r<CR>" or "grx".
+ if (s->cmdchar != 'r' && s->cmdchar != 'v') {
pos_T save_cursor = curwin->w_cursor;
- if (cmdchar == 'R')
- ptr = (char_u *)"r";
- else if (cmdchar == 'V')
- ptr = (char_u *)"v";
- else
- ptr = (char_u *)"i";
- set_vim_var_string(VV_INSERTMODE, ptr, 1);
+ if (s->cmdchar == 'R') {
+ s->ptr = (char_u *)"r";
+ } else if (s->cmdchar == 'V') {
+ s->ptr = (char_u *)"v";
+ } else {
+ s->ptr = (char_u *)"i";
+ }
+
+ set_vim_var_string(VV_INSERTMODE, s->ptr, 1);
set_vim_var_string(VV_CHAR, NULL, -1); /* clear v:char */
- apply_autocmds(EVENT_INSERTENTER, NULL, NULL, FALSE, curbuf);
-
- /* Make sure the cursor didn't move. Do call check_cursor_col() in
- * case the text was modified. Since Insert mode was not started yet
- * a call to check_cursor_col() may move the cursor, especially with
- * the "A" command, thus set State to avoid that. Also check that the
- * line number is still valid (lines may have been deleted).
- * Do not restore if v:char was set to a non-empty string. */
+ apply_autocmds(EVENT_INSERTENTER, NULL, NULL, false, curbuf);
+
+ // Make sure the cursor didn't move. Do call check_cursor_col() in
+ // case the text was modified. Since Insert mode was not started yet
+ // a call to check_cursor_col() may move the cursor, especially with
+ // the "A" command, thus set State to avoid that. Also check that the
+ // line number is still valid (lines may have been deleted).
+ // Do not restore if v:char was set to a non-empty string.
if (!equalpos(curwin->w_cursor, save_cursor)
&& *get_vim_var_str(VV_CHAR) == NUL
&& save_cursor.lnum <= curbuf->b_ml.ml_line_count) {
@@ -345,899 +296,1041 @@ edit (
}
}
- /* Check if the cursor line needs redrawing before changing State. If
- * 'concealcursor' is "n" it needs to be redrawn without concealing. */
+ // Check if the cursor line needs redrawing before changing State. If
+ // 'concealcursor' is "n" it needs to be redrawn without concealing.
conceal_check_cursur_line();
- /*
- * When doing a paste with the middle mouse button, Insstart is set to
- * where the paste started.
- */
- if (where_paste_started.lnum != 0)
+ // When doing a paste with the middle mouse button, Insstart is set to
+ // where the paste started.
+ if (where_paste_started.lnum != 0) {
Insstart = where_paste_started;
- else {
+ } else {
Insstart = curwin->w_cursor;
- if (startln)
+ if (s->startln) {
Insstart.col = 0;
+ }
}
+
Insstart_textlen = (colnr_T)linetabsize(get_cursor_line_ptr());
Insstart_blank_vcol = MAXCOL;
- if (!did_ai)
+
+ if (!did_ai) {
ai_col = 0;
+ }
- if (cmdchar != NUL && restart_edit == 0) {
+ if (s->cmdchar != NUL && restart_edit == 0) {
ResetRedobuff();
- AppendNumberToRedobuff(count);
- if (cmdchar == 'V' || cmdchar == 'v') {
- /* "gR" or "gr" command */
+ AppendNumberToRedobuff(s->count);
+ if (s->cmdchar == 'V' || s->cmdchar == 'v') {
+ // "gR" or "gr" command
AppendCharToRedobuff('g');
- AppendCharToRedobuff((cmdchar == 'v') ? 'r' : 'R');
+ AppendCharToRedobuff((s->cmdchar == 'v') ? 'r' : 'R');
} else {
- AppendCharToRedobuff(cmdchar);
- if (cmdchar == 'g') /* "gI" command */
+ AppendCharToRedobuff(s->cmdchar);
+ if (s->cmdchar == 'g') { // "gI" command
AppendCharToRedobuff('I');
- else if (cmdchar == 'r') /* "r<CR>" command */
- count = 1; /* insert only one <CR> */
+ } else if (s->cmdchar == 'r') { // "r<CR>" command
+ s->count = 1; // insert only one <CR>
+ }
}
}
- if (cmdchar == 'R') {
+ if (s->cmdchar == 'R') {
if (p_fkmap && p_ri) {
beep_flush();
- EMSG(farsi_text_3); /* encoded in Farsi */
+ EMSG(farsi_text_3); // encoded in Farsi
State = INSERT;
- } else
+ } else {
State = REPLACE;
- } else if (cmdchar == 'V' || cmdchar == 'v') {
+ }
+ } else if (s->cmdchar == 'V' || s->cmdchar == 'v') {
State = VREPLACE;
- replaceState = VREPLACE;
+ s->replaceState = VREPLACE;
orig_line_count = curbuf->b_ml.ml_line_count;
vr_lines_changed = 1;
- } else
+ } else {
State = INSERT;
+ }
- stop_insert_mode = FALSE;
+ stop_insert_mode = false;
- /*
- * Need to recompute the cursor position, it might move when the cursor is
- * on a TAB or special character.
- */
- curs_columns(TRUE);
+ // Need to recompute the cursor position, it might move when the cursor is
+ // on a TAB or special character.
+ curs_columns(true);
- /*
- * Enable langmap or IME, indicated by 'iminsert'.
- * Note that IME may enabled/disabled without us noticing here, thus the
- * 'iminsert' value may not reflect what is actually used. It is updated
- * when hitting <Esc>.
- */
- if (curbuf->b_p_iminsert == B_IMODE_LMAP)
+ // Enable langmap or IME, indicated by 'iminsert'.
+ // Note that IME may enabled/disabled without us noticing here, thus the
+ // 'iminsert' value may not reflect what is actually used. It is updated
+ // when hitting <Esc>.
+ if (curbuf->b_p_iminsert == B_IMODE_LMAP) {
State |= LANGMAP;
+ }
setmouse();
clear_showcmd();
- /* there is no reverse replace mode */
+ // there is no reverse replace mode
revins_on = (State == INSERT && p_ri);
- if (revins_on)
+ if (revins_on) {
undisplay_dollar();
+ }
revins_chars = 0;
revins_legal = 0;
revins_scol = -1;
- /*
- * Handle restarting Insert mode.
- * Don't do this for "CTRL-O ." (repeat an insert): we get here with
- * restart_edit non-zero, and something in the stuff buffer.
- */
+ // Handle restarting Insert mode.
+ // Don't do this for "CTRL-O ." (repeat an insert): we get here with
+ // restart_edit non-zero, and something in the stuff buffer.
if (restart_edit != 0 && stuff_empty()) {
- /*
- * After a paste we consider text typed to be part of the insert for
- * the pasted text. You can backspace over the pasted text too.
- */
- if (where_paste_started.lnum)
- arrow_used = FALSE;
- else
- arrow_used = TRUE;
+ // After a paste we consider text typed to be part of the insert for
+ // the pasted text. You can backspace over the pasted text too.
+ if (where_paste_started.lnum) {
+ arrow_used = false;
+ } else {
+ arrow_used = true;
+ }
restart_edit = 0;
- /*
- * If the cursor was after the end-of-line before the CTRL-O and it is
- * now at the end-of-line, put it after the end-of-line (this is not
- * correct in very rare cases).
- * Also do this if curswant is greater than the current virtual
- * column. Eg after "^O$" or "^O80|".
- */
+ // If the cursor was after the end-of-line before the CTRL-O and it is
+ // now at the end-of-line, put it after the end-of-line (this is not
+ // correct in very rare cases).
+ // Also do this if curswant is greater than the current virtual
+ // column. Eg after "^O$" or "^O80|".
validate_virtcol();
update_curswant();
if (((ins_at_eol && curwin->w_cursor.lnum == o_lnum)
|| curwin->w_curswant > curwin->w_virtcol)
- && *(ptr = get_cursor_line_ptr() + curwin->w_cursor.col) != NUL) {
- if (ptr[1] == NUL)
+ && *(s->ptr = get_cursor_line_ptr() + curwin->w_cursor.col) != NUL) {
+ if (s->ptr[1] == NUL) {
++curwin->w_cursor.col;
- else if (has_mbyte) {
- i = (*mb_ptr2len)(ptr);
- if (ptr[i] == NUL)
- curwin->w_cursor.col += i;
+ } else if (has_mbyte) {
+ s->i = (*mb_ptr2len)(s->ptr);
+ if (s->ptr[s->i] == NUL) {
+ curwin->w_cursor.col += s->i;
+ }
}
}
- ins_at_eol = FALSE;
- } else
- arrow_used = FALSE;
+ ins_at_eol = false;
+ } else {
+ arrow_used = false;
+ }
- /* we are in insert mode now, don't need to start it anymore */
- need_start_insertmode = FALSE;
+ // we are in insert mode now, don't need to start it anymore
+ need_start_insertmode = false;
- /* Need to save the line for undo before inserting the first char. */
- ins_need_undo = TRUE;
+ // Need to save the line for undo before inserting the first char.
+ ins_need_undo = true;
where_paste_started.lnum = 0;
- can_cindent = TRUE;
- /* The cursor line is not in a closed fold, unless 'insertmode' is set or
- * restarting. */
- if (!p_im && did_restart_edit == 0)
+ can_cindent = true;
+ // The cursor line is not in a closed fold, unless 'insertmode' is set or
+ // restarting.
+ if (!p_im && did_restart_edit == 0) {
foldOpenCursor();
+ }
- /*
- * If 'showmode' is set, show the current (insert/replace/..) mode.
- * A warning message for changing a readonly file is given here, before
- * actually changing anything. It's put after the mode, if any.
- */
- i = 0;
- if (p_smd && msg_silent == 0)
- i = showmode();
+ // If 'showmode' is set, show the current (insert/replace/..) mode.
+ // A warning message for changing a readonly file is given here, before
+ // actually changing anything. It's put after the mode, if any.
+ s->i = 0;
+ if (p_smd && msg_silent == 0) {
+ s->i = showmode();
+ }
- if (!p_im && did_restart_edit == 0)
- change_warning(i == 0 ? 0 : i + 1);
+ if (!p_im && did_restart_edit == 0) {
+ change_warning(s->i == 0 ? 0 : s->i + 1);
+ }
ui_cursor_shape(); /* may show different cursor shape */
do_digraph(-1); /* clear digraphs */
- /*
- * Get the current length of the redo buffer, those characters have to be
- * skipped if we want to get to the inserted characters.
- */
- ptr = get_inserted();
- if (ptr == NULL)
+ // Get the current length of the redo buffer, those characters have to be
+ // skipped if we want to get to the inserted characters.
+ s->ptr = get_inserted();
+ if (s->ptr == NULL) {
new_insert_skip = 0;
- else {
- new_insert_skip = (int)STRLEN(ptr);
- xfree(ptr);
+ } else {
+ new_insert_skip = (int)STRLEN(s->ptr);
+ xfree(s->ptr);
}
old_indent = 0;
- /*
- * Main loop in Insert mode: repeat until Insert mode is left.
- */
- for (;; ) {
- if (!revins_legal)
- revins_scol = -1; /* reset on illegal motions */
- else
- revins_legal = 0;
- if (arrow_used) /* don't repeat insert when arrow key used */
- count = 0;
+ do {
+ state_enter(&s->state);
+ // If s->count != 0, `ins_esc` will prepare the redo buffer for reprocessing
+ // and return false, causing `state_enter` to be called again.
+ } while (!ins_esc(&s->count, s->cmdchar, s->nomove));
- if (update_Insstart_orig) {
- Insstart_orig = Insstart;
- }
+ // Always update o_lnum, so that a "CTRL-O ." that adds a line
+ // still puts the cursor back after the inserted text.
+ if (ins_at_eol && gchar_cursor() == NUL) {
+ o_lnum = curwin->w_cursor.lnum;
+ }
- if (stop_insert_mode) {
- /* ":stopinsert" used or 'insertmode' reset */
- count = 0;
- goto doESCkey;
- }
+ if (s->cmdchar != 'r' && s->cmdchar != 'v') {
+ apply_autocmds(EVENT_INSERTLEAVE, NULL, NULL, false, curbuf);
+ }
+ did_cursorhold = false;
+}
- /* set curwin->w_curswant for next K_DOWN or K_UP */
- if (!arrow_used)
- curwin->w_set_curswant = TRUE;
+static int insert_check(VimState *state)
+{
+ InsertState *s = (InsertState *)state;
+
+ // If typed something may trigger CursorHoldI again.
+ if (s->c != K_EVENT) {
+ did_cursorhold = false;
+ }
+
+ // If the cursor was moved we didn't just insert a space */
+ if (arrow_used) {
+ s->inserted_space = false;
+ }
+
+ if (can_cindent && cindent_on() && ctrl_x_mode == 0) {
+ insert_do_cindent(s);
+ }
+
+ if (!revins_legal) {
+ revins_scol = -1; // reset on illegal motions
+ } else {
+ revins_legal = 0;
+ }
+
+ if (arrow_used) { // don't repeat insert when arrow key used
+ s->count = 0;
+ }
+
+ if (update_Insstart_orig) {
+ Insstart_orig = Insstart;
+ }
+
+ if (stop_insert_mode) {
+ // ":stopinsert" used or 'insertmode' reset
+ s->count = 0;
+ return 0; // exit insert mode
+ }
- /* If there is no typeahead may check for timestamps (e.g., for when a
- * menu invoked a shell command). */
- if (stuff_empty()) {
- did_check_timestamps = FALSE;
- if (need_check_timestamps)
- check_timestamps(FALSE);
+ // set curwin->w_curswant for next K_DOWN or K_UP
+ if (!arrow_used) {
+ curwin->w_set_curswant = true;
+ }
+
+ // If there is no typeahead may check for timestamps (e.g., for when a
+ // menu invoked a shell command).
+ if (stuff_empty()) {
+ did_check_timestamps = false;
+ if (need_check_timestamps) {
+ check_timestamps(false);
}
+ }
- /*
- * When emsg() was called msg_scroll will have been set.
- */
- msg_scroll = FALSE;
+ // When emsg() was called msg_scroll will have been set.
+ msg_scroll = false;
- /* Open fold at the cursor line, according to 'foldopen'. */
- if (fdo_flags & FDO_INSERT)
- foldOpenCursor();
- /* Close folds where the cursor isn't, according to 'foldclose' */
- if (!char_avail())
- foldCheckClose();
+ // Open fold at the cursor line, according to 'foldopen'.
+ if (fdo_flags & FDO_INSERT) {
+ foldOpenCursor();
+ }
- /*
- * If we inserted a character at the last position of the last line in
- * the window, scroll the window one line up. This avoids an extra
- * redraw.
- * This is detected when the cursor column is smaller after inserting
- * something.
- * Don't do this when the topline changed already, it has
- * already been adjusted (by insertchar() calling open_line())).
- */
- if (curbuf->b_mod_set
- && curwin->w_p_wrap
- && !did_backspace
- && curwin->w_topline == old_topline
- && curwin->w_topfill == old_topfill
- ) {
- mincol = curwin->w_wcol;
- validate_cursor_col();
-
- if (curwin->w_wcol < mincol - curbuf->b_p_ts
- && curwin->w_wrow == curwin->w_winrow
- + curwin->w_height - 1 - p_so
- && (curwin->w_cursor.lnum != curwin->w_topline
- || curwin->w_topfill > 0
- )) {
- if (curwin->w_topfill > 0)
- --curwin->w_topfill;
- else if (hasFolding(curwin->w_topline, NULL, &old_topline))
- set_topline(curwin, old_topline + 1);
- else
- set_topline(curwin, curwin->w_topline + 1);
+ // Close folds where the cursor isn't, according to 'foldclose'
+ if (!char_avail()) {
+ foldCheckClose();
+ }
+
+ // If we inserted a character at the last position of the last line in the
+ // window, scroll the window one line up. This avoids an extra redraw. This
+ // is detected when the cursor column is smaller after inserting something.
+ // Don't do this when the topline changed already, it has already been
+ // adjusted (by insertchar() calling open_line())).
+ if (curbuf->b_mod_set
+ && curwin->w_p_wrap
+ && !s->did_backspace
+ && curwin->w_topline == s->old_topline
+ && curwin->w_topfill == s->old_topfill) {
+ s->mincol = curwin->w_wcol;
+ validate_cursor_col();
+
+ if (curwin->w_wcol < s->mincol - curbuf->b_p_ts
+ && curwin->w_wrow == curwin->w_winrow
+ + curwin->w_height - 1 - p_so
+ && (curwin->w_cursor.lnum != curwin->w_topline
+ || curwin->w_topfill > 0)) {
+ if (curwin->w_topfill > 0) {
+ --curwin->w_topfill;
+ } else if (hasFolding(curwin->w_topline, NULL, &s->old_topline)) {
+ set_topline(curwin, s->old_topline + 1);
+ } else {
+ set_topline(curwin, curwin->w_topline + 1);
}
}
+ }
- /* May need to adjust w_topline to show the cursor. */
- update_topline();
+ // May need to adjust w_topline to show the cursor.
+ update_topline();
- did_backspace = FALSE;
+ s->did_backspace = false;
- validate_cursor(); /* may set must_redraw */
+ validate_cursor(); // may set must_redraw
- /*
- * Redraw the display when no characters are waiting.
- * Also shows mode, ruler and positions cursor.
- */
- ins_redraw(TRUE);
+ // Redraw the display when no characters are waiting.
+ // Also shows mode, ruler and positions cursor.
+ ins_redraw(true);
- if (curwin->w_p_scb)
- do_check_scrollbind(TRUE);
+ if (curwin->w_p_scb) {
+ do_check_scrollbind(true);
+ }
- if (curwin->w_p_crb)
- do_check_cursorbind();
- update_curswant();
- old_topline = curwin->w_topline;
- old_topfill = curwin->w_topfill;
+ if (curwin->w_p_crb) {
+ do_check_cursorbind();
+ }
+ update_curswant();
+ s->old_topline = curwin->w_topline;
+ s->old_topfill = curwin->w_topfill;
+ s->lastc = s->c; // remember previous char for CTRL-D
- /*
- * Get a character for Insert mode. Ignore K_IGNORE.
- */
- lastc = c; /* remember previous char for CTRL-D */
- input_enable_events();
- do {
- c = safe_vgetc();
- } while (c == K_IGNORE);
- input_disable_events();
+ // After using CTRL-G U the next cursor key will not break undo.
+ if (dont_sync_undo == MAYBE) {
+ dont_sync_undo = true;
+ } else {
+ dont_sync_undo = false;
+ }
- if (c == K_EVENT) {
- c = lastc;
- queue_process_events(loop.events);
- continue;
- }
+ return 1;
+}
- /* Don't want K_CURSORHOLD for the second key, e.g., after CTRL-V. */
- did_cursorhold = TRUE;
+static int insert_execute(VimState *state, int key)
+{
+ if (key == K_IGNORE) {
+ return -1; // get another key
+ }
+ InsertState *s = (InsertState *)state;
+ s->c = key;
- if (p_hkmap && KeyTyped)
- c = hkmap(c); /* Hebrew mode mapping */
- if (p_fkmap && KeyTyped)
- c = fkmap(c); /* Farsi mode mapping */
+ // Don't want K_EVENT with cursorhold for the second key, e.g., after CTRL-V.
+ did_cursorhold = true;
- /*
- * Special handling of keys while the popup menu is visible or wanted
- * and the cursor is still in the completed word. Only when there is
- * a match, skip this when no matches were found.
- */
- if (compl_started
- && pum_wanted()
- && curwin->w_cursor.col >= compl_col
- && (compl_shown_match == NULL
- || compl_shown_match != compl_shown_match->cp_next)) {
- /* BS: Delete one character from "compl_leader". */
- if ((c == K_BS || c == Ctrl_H)
- && curwin->w_cursor.col > compl_col
- && (c = ins_compl_bs()) == NUL)
- continue;
-
- /* When no match was selected or it was edited. */
- if (!compl_used_match) {
- /* CTRL-L: Add one character from the current match to
- * "compl_leader". Except when at the original match and
- * there is nothing to add, CTRL-L works like CTRL-P then. */
- if (c == Ctrl_L
- && (!CTRL_X_MODE_LINE_OR_EVAL(ctrl_x_mode)
- || (int)STRLEN(compl_shown_match->cp_str)
- > curwin->w_cursor.col - compl_col)) {
- ins_compl_addfrommatch();
- continue;
- }
+ if (p_hkmap && KeyTyped) {
+ s->c = hkmap(s->c); // Hebrew mode mapping
+ }
- /* A non-white character that fits in with the current
- * completion: Add to "compl_leader". */
- if (ins_compl_accept_char(c)) {
- /* Trigger InsertCharPre. */
- char_u *str = do_insert_char_pre(c);
- char_u *p;
-
- if (str != NULL) {
- for (p = str; *p != NUL; mb_ptr_adv(p))
- ins_compl_addleader(PTR2CHAR(p));
- xfree(str);
- } else
- ins_compl_addleader(c);
- continue;
- }
+ if (p_fkmap && KeyTyped) {
+ s->c = fkmap(s->c); // Farsi mode mapping
+ }
- /* Pressing CTRL-Y selects the current match. When
- * compl_enter_selects is set the Enter key does the same. */
- if (c == Ctrl_Y || (compl_enter_selects
- && (c == CAR || c == K_KENTER || c == NL))) {
- ins_compl_delete();
- ins_compl_insert();
- }
- }
+ // Special handling of keys while the popup menu is visible or wanted
+ // and the cursor is still in the completed word. Only when there is
+ // a match, skip this when no matches were found.
+ if (compl_started
+ && pum_wanted()
+ && curwin->w_cursor.col >= compl_col
+ && (compl_shown_match == NULL
+ || compl_shown_match != compl_shown_match->cp_next)) {
+ // BS: Delete one character from "compl_leader".
+ if ((s->c == K_BS || s->c == Ctrl_H)
+ && curwin->w_cursor.col > compl_col
+ && (s->c = ins_compl_bs()) == NUL) {
+ return 1; // continue
}
- /* Prepare for or stop CTRL-X mode. This doesn't do completion, but
- * it does fix up the text when finishing completion. */
- compl_get_longest = FALSE;
- if (ins_compl_prep(c))
- continue;
+ // When no match was selected or it was edited.
+ if (!compl_used_match) {
+ // CTRL-L: Add one character from the current match to
+ // "compl_leader". Except when at the original match and
+ // there is nothing to add, CTRL-L works like CTRL-P then.
+ if (s->c == Ctrl_L
+ && (!CTRL_X_MODE_LINE_OR_EVAL(ctrl_x_mode)
+ || (int)STRLEN(compl_shown_match->cp_str)
+ > curwin->w_cursor.col - compl_col)) {
+ ins_compl_addfrommatch();
+ return 1; // continue
+ }
- /* CTRL-\ CTRL-N goes to Normal mode,
- * CTRL-\ CTRL-G goes to mode selected with 'insertmode',
- * CTRL-\ CTRL-O is like CTRL-O but without moving the cursor. */
- if (c == Ctrl_BSL) {
- /* may need to redraw when no more chars available now */
- ins_redraw(FALSE);
- ++no_mapping;
- ++allow_keys;
- c = plain_vgetc();
- --no_mapping;
- --allow_keys;
- if (c != Ctrl_N && c != Ctrl_G && c != Ctrl_O) {
- /* it's something else */
- vungetc(c);
- c = Ctrl_BSL;
- } else if (c == Ctrl_G && p_im)
- continue;
- else {
- if (c == Ctrl_O) {
- ins_ctrl_o();
- ins_at_eol = FALSE; /* cursor keeps its column */
- nomove = TRUE;
+ // A non-white character that fits in with the current
+ // completion: Add to "compl_leader".
+ if (ins_compl_accept_char(s->c)) {
+ // Trigger InsertCharPre.
+ char_u *str = do_insert_char_pre(s->c);
+ char_u *p;
+
+ if (str != NULL) {
+ for (p = str; *p != NUL; mb_ptr_adv(p)) {
+ ins_compl_addleader(PTR2CHAR(p));
+ }
+ xfree(str);
+ } else {
+ ins_compl_addleader(s->c);
}
- count = 0;
- goto doESCkey;
+ return 1; // continue
+ }
+
+ // Pressing CTRL-Y selects the current match. When
+ // compl_enter_selects is set the Enter key does the same.
+ if (s->c == Ctrl_Y
+ || (compl_enter_selects
+ && (s->c == CAR || s->c == K_KENTER || s->c == NL))) {
+ ins_compl_delete();
+ ins_compl_insert();
}
}
+ }
- c = do_digraph(c);
+ // Prepare for or stop CTRL-X mode. This doesn't do completion, but it does
+ // fix up the text when finishing completion.
+ compl_get_longest = false;
+ if (ins_compl_prep(s->c)) {
+ return 1; // continue
+ }
- if ((c == Ctrl_V || c == Ctrl_Q) && ctrl_x_mode == CTRL_X_CMDLINE)
- goto docomplete;
- if (c == Ctrl_V || c == Ctrl_Q) {
- ins_ctrl_v();
- c = Ctrl_V; /* pretend CTRL-V is last typed character */
- continue;
+ // CTRL-\ CTRL-N goes to Normal mode,
+ // CTRL-\ CTRL-G goes to mode selected with 'insertmode',
+ // CTRL-\ CTRL-O is like CTRL-O but without moving the cursor
+ if (s->c == Ctrl_BSL) {
+ // may need to redraw when no more chars available now
+ ins_redraw(false);
+ ++no_mapping;
+ ++allow_keys;
+ s->c = plain_vgetc();
+ --no_mapping;
+ --allow_keys;
+ if (s->c != Ctrl_N && s->c != Ctrl_G && s->c != Ctrl_O) {
+ // it's something else
+ vungetc(s->c);
+ s->c = Ctrl_BSL;
+ } else if (s->c == Ctrl_G && p_im) {
+ return 1; // continue
+ } else {
+ if (s->c == Ctrl_O) {
+ ins_ctrl_o();
+ ins_at_eol = false; // cursor keeps its column
+ s->nomove = true;
+ }
+ s->count = 0;
+ return 0;
}
+ }
- if (cindent_on()
- && ctrl_x_mode == 0
- ) {
- /* A key name preceded by a bang means this key is not to be
- * inserted. Skip ahead to the re-indenting below.
- * A key name preceded by a star means that indenting has to be
- * done before inserting the key. */
- line_is_white = inindent(0);
- if (in_cinkeys(c, '!', line_is_white))
- goto force_cindent;
- if (can_cindent && in_cinkeys(c, '*', line_is_white)
- && stop_arrow() == OK)
- do_c_expr_indent();
- }
+ s->c = do_digraph(s->c);
- if (curwin->w_p_rl)
- switch (c) {
- case K_LEFT: c = K_RIGHT; break;
- case K_S_LEFT: c = K_S_RIGHT; break;
- case K_C_LEFT: c = K_C_RIGHT; break;
- case K_RIGHT: c = K_LEFT; break;
- case K_S_RIGHT: c = K_S_LEFT; break;
- case K_C_RIGHT: c = K_C_LEFT; break;
- }
+ if ((s->c == Ctrl_V || s->c == Ctrl_Q) && ctrl_x_mode == CTRL_X_CMDLINE) {
+ insert_do_complete(s);
+ return 1;
+ }
- /*
- * If 'keymodel' contains "startsel", may start selection. If it
- * does, a CTRL-O and c will be stuffed, we need to get these
- * characters.
- */
- if (ins_start_select(c))
- continue;
+ if (s->c == Ctrl_V || s->c == Ctrl_Q) {
+ ins_ctrl_v();
+ s->c = Ctrl_V; // pretend CTRL-V is last typed character
+ return 1; // continue
+ }
- /*
- * The big switch to handle a character in insert mode.
- */
- switch (c) {
- case ESC: /* End input mode */
- if (echeck_abbr(ESC + ABBR_OFF))
- break;
- /*FALLTHROUGH*/
-
- case Ctrl_C: /* End input mode */
- if (c == Ctrl_C && cmdwin_type != 0) {
- /* Close the cmdline window. */
- cmdwin_result = K_IGNORE;
- got_int = FALSE; /* don't stop executing autocommands et al. */
- nomove = TRUE;
- goto doESCkey;
- }
+ if (cindent_on()
+ && ctrl_x_mode == 0) {
+ // A key name preceded by a bang means this key is not to be
+ // inserted. Skip ahead to the re-indenting below.
+ // A key name preceded by a star means that indenting has to be
+ // done before inserting the key.
+ s->line_is_white = inindent(0);
+ if (in_cinkeys(s->c, '!', s->line_is_white)) {
+ insert_do_cindent(s);
+ return 1; // continue
+ }
-#ifdef UNIX
-do_intr:
-#endif
- // when 'insertmode' set, and not halfway through a mapping, don't leave
- // Insert mode
- if (goto_im()) {
- if (got_int) {
- (void)vgetc(); /* flush all buffers */
- got_int = false;
- } else {
- vim_beep(BO_IM);
- }
- break;
- }
-doESCkey:
- /*
- * This is the ONLY return from edit()!
- */
- /* Always update o_lnum, so that a "CTRL-O ." that adds a line
- * still puts the cursor back after the inserted text. */
- if (ins_at_eol && gchar_cursor() == NUL)
- o_lnum = curwin->w_cursor.lnum;
-
- if (ins_esc(&count, cmdchar, nomove)) {
- if (cmdchar != 'r' && cmdchar != 'v')
- apply_autocmds(EVENT_INSERTLEAVE, NULL, NULL,
- FALSE, curbuf);
- did_cursorhold = FALSE;
- return c == Ctrl_O;
- }
- continue;
+ if (can_cindent && in_cinkeys(s->c, '*', s->line_is_white)
+ && stop_arrow() == OK) {
+ do_c_expr_indent();
+ }
+ }
- case Ctrl_Z: /* suspend when 'insertmode' set */
- if (!p_im)
- goto normalchar; /* insert CTRL-Z as normal char */
- stuffReadbuff((char_u *)":st\r");
- c = Ctrl_O;
- /*FALLTHROUGH*/
-
- case Ctrl_O: /* execute one command */
- if (ctrl_x_mode == CTRL_X_OMNI)
- goto docomplete;
- if (echeck_abbr(Ctrl_O + ABBR_OFF))
- break;
- ins_ctrl_o();
+ if (curwin->w_p_rl)
+ switch (s->c) {
+ case K_LEFT: s->c = K_RIGHT; break;
+ case K_S_LEFT: s->c = K_S_RIGHT; break;
+ case K_C_LEFT: s->c = K_C_RIGHT; break;
+ case K_RIGHT: s->c = K_LEFT; break;
+ case K_S_RIGHT: s->c = K_S_LEFT; break;
+ case K_C_RIGHT: s->c = K_C_LEFT; break;
+ }
- /* don't move the cursor left when 'virtualedit' has "onemore". */
- if (ve_flags & VE_ONEMORE) {
- ins_at_eol = FALSE;
- nomove = TRUE;
- }
- count = 0;
- goto doESCkey;
+ // If 'keymodel' contains "startsel", may start selection. If it
+ // does, a CTRL-O and c will be stuffed, we need to get these
+ // characters.
+ if (ins_start_select(s->c)) {
+ return 1; // continue
+ }
- case K_INS: /* toggle insert/replace mode */
- case K_KINS:
- ins_insert(replaceState);
+ return insert_handle_key(s);
+}
+
+static int insert_handle_key(InsertState *s)
+{
+ // The big switch to handle a character in insert mode.
+ // TODO(tarruda): This could look better if a lookup table is used.
+ // (similar to normal mode `nv_cmds[]`)
+ switch (s->c) {
+ case ESC: // End input mode
+ if (echeck_abbr(ESC + ABBR_OFF)) {
break;
+ }
+ // FALLTHROUGH
+
+ case Ctrl_C: // End input mode
+ if (s->c == Ctrl_C && cmdwin_type != 0) {
+ // Close the cmdline window. */
+ cmdwin_result = K_IGNORE;
+ got_int = false; // don't stop executing autocommands et al
+ s->nomove = true;
+ return 0; // exit insert mode
+ }
- case K_SELECT: /* end of Select mode mapping - ignore */
+ // when 'insertmode' set, and not halfway through a mapping, don't leave
+ // Insert mode
+ if (goto_im()) {
+ if (got_int) {
+ (void)vgetc(); // flush all buffers
+ got_int = false;
+ } else {
+ vim_beep(BO_IM);
+ }
break;
+ }
+ return 0; // exit insert mode
+ case Ctrl_Z: // suspend when 'insertmode' set
+ if (!p_im) {
+ goto normalchar; // insert CTRL-Z as normal char
+ }
+ stuffReadbuff((char_u *)":st\r");
+ s->c = Ctrl_O;
+ // FALLTHROUGH
- case K_HELP: /* Help key works like <ESC> <Help> */
- case K_F1:
- case K_XF1:
- stuffcharReadbuff(K_HELP);
- if (p_im)
- need_start_insertmode = TRUE;
- goto doESCkey;
-
-
- case K_ZERO: /* Insert the previously inserted text. */
- case NUL:
- case Ctrl_A:
- /* For ^@ the trailing ESC will end the insert, unless there is an
- * error. */
- if (stuff_inserted(NUL, 1L, (c == Ctrl_A)) == FAIL
- && c != Ctrl_A && !p_im)
- goto doESCkey; /* quit insert mode */
- inserted_space = FALSE;
+ case Ctrl_O: // execute one command
+ if (ctrl_x_mode == CTRL_X_OMNI) {
+ insert_do_complete(s);
break;
+ }
- case Ctrl_R: /* insert the contents of a register */
- ins_reg();
- auto_format(FALSE, TRUE);
- inserted_space = FALSE;
+ if (echeck_abbr(Ctrl_O + ABBR_OFF)) {
break;
+ }
- case Ctrl_G: /* commands starting with CTRL-G */
- ins_ctrl_g();
- break;
+ ins_ctrl_o();
- case Ctrl_HAT: /* switch input mode and/or langmap */
- ins_ctrl_hat();
- break;
+ // don't move the cursor left when 'virtualedit' has "onemore".
+ if (ve_flags & VE_ONEMORE) {
+ ins_at_eol = false;
+ s->nomove = true;
+ }
- case Ctrl__: /* switch between languages */
- if (!p_ari)
- goto normalchar;
- ins_ctrl_();
- break;
+ s->count = 0;
+ return 0; // exit insert mode
- case Ctrl_D: /* Make indent one shiftwidth smaller. */
- if (ctrl_x_mode == CTRL_X_PATH_DEFINES)
- goto docomplete;
- /* FALLTHROUGH */
+ case K_INS: // toggle insert/replace mode
+ case K_KINS:
+ ins_insert(s->replaceState);
+ break;
- case Ctrl_T: /* Make indent one shiftwidth greater. */
- if (c == Ctrl_T && ctrl_x_mode == CTRL_X_THESAURUS) {
- if (has_compl_option(FALSE))
- goto docomplete;
- break;
- }
- ins_shift(c, lastc);
- auto_format(FALSE, TRUE);
- inserted_space = FALSE;
- break;
+ case K_SELECT: // end of Select mode mapping - ignore
+ break;
- case K_DEL: /* delete character under the cursor */
- case K_KDEL:
- ins_del();
- auto_format(FALSE, TRUE);
- break;
- case K_BS: /* delete character before the cursor */
- case Ctrl_H:
- did_backspace = ins_bs(c, BACKSPACE_CHAR, &inserted_space);
- auto_format(FALSE, TRUE);
- break;
+ case K_HELP: // Help key works like <ESC> <Help>
+ case K_F1:
+ case K_XF1:
+ stuffcharReadbuff(K_HELP);
+ if (p_im) {
+ need_start_insertmode = true;
+ }
+ return 0; // exit insert mode
- case Ctrl_W: /* delete word before the cursor */
- did_backspace = ins_bs(c, BACKSPACE_WORD, &inserted_space);
- auto_format(FALSE, TRUE);
- break;
- case Ctrl_U: /* delete all inserted text in current line */
- /* CTRL-X CTRL-U completes with 'completefunc'. */
- if (ctrl_x_mode == CTRL_X_FUNCTION)
- goto docomplete;
- did_backspace = ins_bs(c, BACKSPACE_LINE, &inserted_space);
- auto_format(FALSE, TRUE);
- inserted_space = FALSE;
- break;
+ case K_ZERO: // Insert the previously inserted text.
+ case NUL:
+ case Ctrl_A:
+ // For ^@ the trailing ESC will end the insert, unless there is an
+ // error.
+ if (stuff_inserted(NUL, 1L, (s->c == Ctrl_A)) == FAIL
+ && s->c != Ctrl_A && !p_im) {
+ return 0; // exit insert mode
+ }
+ s->inserted_space = false;
+ break;
- case K_LEFTMOUSE: /* mouse keys */
- case K_LEFTMOUSE_NM:
- case K_LEFTDRAG:
- case K_LEFTRELEASE:
- case K_LEFTRELEASE_NM:
- case K_MIDDLEMOUSE:
- case K_MIDDLEDRAG:
- case K_MIDDLERELEASE:
- case K_RIGHTMOUSE:
- case K_RIGHTDRAG:
- case K_RIGHTRELEASE:
- case K_X1MOUSE:
- case K_X1DRAG:
- case K_X1RELEASE:
- case K_X2MOUSE:
- case K_X2DRAG:
- case K_X2RELEASE:
- ins_mouse(c);
- break;
+ case Ctrl_R: // insert the contents of a register
+ ins_reg();
+ auto_format(false, true);
+ s->inserted_space = false;
+ break;
- case K_MOUSEDOWN: /* Default action for scroll wheel up: scroll up */
- ins_mousescroll(MSCR_DOWN);
- break;
+ case Ctrl_G: // commands starting with CTRL-G
+ ins_ctrl_g();
+ break;
- case K_MOUSEUP: /* Default action for scroll wheel down: scroll down */
- ins_mousescroll(MSCR_UP);
- break;
+ case Ctrl_HAT: // switch input mode and/or langmap
+ ins_ctrl_hat();
+ break;
- case K_MOUSELEFT: /* Scroll wheel left */
- ins_mousescroll(MSCR_LEFT);
- break;
+ case Ctrl__: // switch between languages
+ if (!p_ari) {
+ goto normalchar;
+ }
+ ins_ctrl_();
+ break;
- case K_MOUSERIGHT: /* Scroll wheel right */
- ins_mousescroll(MSCR_RIGHT);
+ case Ctrl_D: // Make indent one shiftwidth smaller.
+ if (ctrl_x_mode == CTRL_X_PATH_DEFINES) {
+ insert_do_complete(s);
break;
+ }
+ // FALLTHROUGH
- case K_IGNORE: /* Something mapped to nothing */
+ case Ctrl_T: // Make indent one shiftwidth greater.
+ if (s->c == Ctrl_T && ctrl_x_mode == CTRL_X_THESAURUS) {
+ if (has_compl_option(false)) {
+ insert_do_complete(s);
+ }
break;
+ }
+ ins_shift(s->c, s->lastc);
+ auto_format(false, true);
+ s->inserted_space = false;
+ break;
- case K_CURSORHOLD: /* Didn't type something for a while. */
- apply_autocmds(EVENT_CURSORHOLDI, NULL, NULL, FALSE, curbuf);
- did_cursorhold = TRUE;
- break;
+ case K_DEL: // delete character under the cursor
+ case K_KDEL:
+ ins_del();
+ auto_format(false, true);
+ break;
- case K_HOME: /* <Home> */
- case K_KHOME:
- case K_S_HOME:
- case K_C_HOME:
- ins_home(c);
- break;
+ case K_BS: // delete character before the cursor
+ case Ctrl_H:
+ s->did_backspace = ins_bs(s->c, BACKSPACE_CHAR, &s->inserted_space);
+ auto_format(false, true);
+ break;
- case K_END: /* <End> */
- case K_KEND:
- case K_S_END:
- case K_C_END:
- ins_end(c);
- break;
+ case Ctrl_W: // delete word before the cursor
+ s->did_backspace = ins_bs(s->c, BACKSPACE_WORD, &s->inserted_space);
+ auto_format(false, true);
+ break;
- case K_LEFT: /* <Left> */
- if (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL))
- ins_s_left();
- else
- ins_left();
- break;
+ case Ctrl_U: // delete all inserted text in current line
+ // CTRL-X CTRL-U completes with 'completefunc'.
+ if (ctrl_x_mode == CTRL_X_FUNCTION) {
+ insert_do_complete(s);
+ } else {
+ s->did_backspace = ins_bs(s->c, BACKSPACE_LINE, &s->inserted_space);
+ auto_format(false, true);
+ s->inserted_space = false;
+ }
+ break;
+
+ case K_LEFTMOUSE: // mouse keys
+ case K_LEFTMOUSE_NM:
+ case K_LEFTDRAG:
+ case K_LEFTRELEASE:
+ case K_LEFTRELEASE_NM:
+ case K_MIDDLEMOUSE:
+ case K_MIDDLEDRAG:
+ case K_MIDDLERELEASE:
+ case K_RIGHTMOUSE:
+ case K_RIGHTDRAG:
+ case K_RIGHTRELEASE:
+ case K_X1MOUSE:
+ case K_X1DRAG:
+ case K_X1RELEASE:
+ case K_X2MOUSE:
+ case K_X2DRAG:
+ case K_X2RELEASE:
+ ins_mouse(s->c);
+ break;
+
+ case K_MOUSEDOWN: // Default action for scroll wheel up: scroll up
+ ins_mousescroll(MSCR_DOWN);
+ break;
+
+ case K_MOUSEUP: // Default action for scroll wheel down: scroll down
+ ins_mousescroll(MSCR_UP);
+ break;
+
+ case K_MOUSELEFT: // Scroll wheel left
+ ins_mousescroll(MSCR_LEFT);
+ break;
+
+ case K_MOUSERIGHT: // Scroll wheel right
+ ins_mousescroll(MSCR_RIGHT);
+ break;
+
+ case K_IGNORE: // Something mapped to nothing
+ break;
+
+ case K_EVENT: // some event
+ queue_process_events(loop.events);
+ break;
+
+ case K_FOCUSGAINED: // Neovim has been given focus
+ apply_autocmds(EVENT_FOCUSGAINED, NULL, NULL, false, curbuf);
+ break;
+
+ case K_FOCUSLOST: // Neovim has lost focus
+ apply_autocmds(EVENT_FOCUSLOST, NULL, NULL, false, curbuf);
+ break;
+
+ case K_HOME: // <Home>
+ case K_KHOME:
+ case K_S_HOME:
+ case K_C_HOME:
+ ins_home(s->c);
+ break;
+
+ case K_END: // <End>
+ case K_KEND:
+ case K_S_END:
+ case K_C_END:
+ ins_end(s->c);
+ break;
- case K_S_LEFT: /* <S-Left> */
- case K_C_LEFT:
+ case K_LEFT: // <Left>
+ if (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL)) {
ins_s_left();
- break;
+ } else {
+ ins_left(dont_sync_undo == false);
+ }
+ break;
- case K_RIGHT: /* <Right> */
- if (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL))
- ins_s_right();
- else
- ins_right();
- break;
+ case K_S_LEFT: // <S-Left>
+ case K_C_LEFT:
+ ins_s_left();
+ break;
- case K_S_RIGHT: /* <S-Right> */
- case K_C_RIGHT:
+ case K_RIGHT: // <Right>
+ if (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL)) {
ins_s_right();
- break;
+ } else {
+ ins_right(dont_sync_undo == false);
+ }
+ break;
- case K_UP: /* <Up> */
- if (pum_visible())
- goto docomplete;
- if (mod_mask & MOD_MASK_SHIFT)
- ins_pageup();
- else
- ins_up(FALSE);
- break;
+ case K_S_RIGHT: // <S-Right>
+ case K_C_RIGHT:
+ ins_s_right();
+ break;
- case K_S_UP: /* <S-Up> */
- case K_PAGEUP:
- case K_KPAGEUP:
- if (pum_visible())
- goto docomplete;
+ case K_UP: // <Up>
+ if (pum_visible()) {
+ insert_do_complete(s);
+ } else if (mod_mask & MOD_MASK_SHIFT) {
ins_pageup();
- break;
+ } else {
+ ins_up(false);
+ }
+ break;
- case K_DOWN: /* <Down> */
- if (pum_visible())
- goto docomplete;
- if (mod_mask & MOD_MASK_SHIFT)
- ins_pagedown();
- else
- ins_down(FALSE);
- break;
+ case K_S_UP: // <S-Up>
+ case K_PAGEUP:
+ case K_KPAGEUP:
+ if (pum_visible()) {
+ insert_do_complete(s);
+ } else {
+ ins_pageup();
+ }
+ break;
- case K_S_DOWN: /* <S-Down> */
- case K_PAGEDOWN:
- case K_KPAGEDOWN:
- if (pum_visible())
- goto docomplete;
+ case K_DOWN: // <Down>
+ if (pum_visible()) {
+ insert_do_complete(s);
+ } else if (mod_mask & MOD_MASK_SHIFT) {
ins_pagedown();
- break;
+ } else {
+ ins_down(false);
+ }
+ break;
+ case K_S_DOWN: // <S-Down>
+ case K_PAGEDOWN:
+ case K_KPAGEDOWN:
+ if (pum_visible()) {
+ insert_do_complete(s);
+ } else {
+ ins_pagedown();
+ }
+ break;
- case K_S_TAB: /* When not mapped, use like a normal TAB */
- c = TAB;
- /* FALLTHROUGH */
- case TAB: /* TAB or Complete patterns along path */
- if (ctrl_x_mode == CTRL_X_PATH_PATTERNS)
- goto docomplete;
- inserted_space = FALSE;
- if (ins_tab())
- goto normalchar; /* insert TAB as a normal char */
- auto_format(FALSE, TRUE);
+ case K_S_TAB: // When not mapped, use like a normal TAB
+ s->c = TAB;
+ // FALLTHROUGH
+
+ case TAB: // TAB or Complete patterns along path
+ if (ctrl_x_mode == CTRL_X_PATH_PATTERNS) {
+ insert_do_complete(s);
break;
+ }
+ s->inserted_space = false;
+ if (ins_tab()) {
+ goto normalchar; // insert TAB as a normal char
+ }
+ auto_format(false, true);
+ break;
- case K_KENTER: /* <Enter> */
- c = CAR;
- /* FALLTHROUGH */
- case CAR:
- case NL:
- /* In a quickfix window a <CR> jumps to the error under the
- * cursor. */
- if (bt_quickfix(curbuf) && c == CAR) {
- if (curwin->w_llist_ref == NULL) /* quickfix window */
- do_cmdline_cmd(".cc");
- else /* location list window */
- do_cmdline_cmd(".ll");
- break;
+ case K_KENTER: // <Enter>
+ s->c = CAR;
+ // FALLTHROUGH
+ case CAR:
+ case NL:
+ // In a quickfix window a <CR> jumps to the error under the
+ // cursor.
+ if (bt_quickfix(curbuf) && s->c == CAR) {
+ if (curwin->w_llist_ref == NULL) { // quickfix window
+ do_cmdline_cmd(".cc");
+ } else { // location list window
+ do_cmdline_cmd(".ll");
}
- if (cmdwin_type != 0) {
- /* Execute the command in the cmdline window. */
- cmdwin_result = CAR;
- goto doESCkey;
- }
- if (ins_eol(c) && !p_im)
- goto doESCkey; /* out of memory */
- auto_format(FALSE, FALSE);
- inserted_space = FALSE;
break;
+ }
+ if (cmdwin_type != 0) {
+ // Execute the command in the cmdline window.
+ cmdwin_result = CAR;
+ return 0;
+ }
+ if (ins_eol(s->c) && !p_im) {
+ return 0; // out of memory
+ }
+ auto_format(false, false);
+ s->inserted_space = false;
+ break;
- case Ctrl_K: /* digraph or keyword completion */
- if (ctrl_x_mode == CTRL_X_DICTIONARY) {
- if (has_compl_option(TRUE))
- goto docomplete;
- break;
+ case Ctrl_K: // digraph or keyword completion
+ if (ctrl_x_mode == CTRL_X_DICTIONARY) {
+ if (has_compl_option(true)) {
+ insert_do_complete(s);
}
- c = ins_digraph();
- if (c == NUL)
- break;
- goto normalchar;
+ break;
+ }
- case Ctrl_X: /* Enter CTRL-X mode */
- ins_ctrl_x();
+ s->c = ins_digraph();
+ if (s->c == NUL) {
break;
+ }
+ goto normalchar;
- case Ctrl_RSB: /* Tag name completion after ^X */
- if (ctrl_x_mode != CTRL_X_TAGS)
- goto normalchar;
- goto docomplete;
+ case Ctrl_X: // Enter CTRL-X mode
+ ins_ctrl_x();
+ break;
- case Ctrl_F: /* File name completion after ^X */
- if (ctrl_x_mode != CTRL_X_FILES)
- goto normalchar;
- goto docomplete;
+ case Ctrl_RSB: // Tag name completion after ^X
+ if (ctrl_x_mode != CTRL_X_TAGS) {
+ goto normalchar;
+ } else {
+ insert_do_complete(s);
+ }
+ break;
- case 's': /* Spelling completion after ^X */
- case Ctrl_S:
- if (ctrl_x_mode != CTRL_X_SPELL)
- goto normalchar;
- goto docomplete;
-
- case Ctrl_L: /* Whole line completion after ^X */
- if (ctrl_x_mode != CTRL_X_WHOLE_LINE) {
- /* CTRL-L with 'insertmode' set: Leave Insert mode */
- if (p_im) {
- if (echeck_abbr(Ctrl_L + ABBR_OFF))
- break;
- goto doESCkey;
+ case Ctrl_F: // File name completion after ^X
+ if (ctrl_x_mode != CTRL_X_FILES) {
+ goto normalchar;
+ } else {
+ insert_do_complete(s);
+ }
+ break;
+
+ case 's': // Spelling completion after ^X
+ case Ctrl_S:
+ if (ctrl_x_mode != CTRL_X_SPELL) {
+ goto normalchar;
+ } else {
+ insert_do_complete(s);
+ }
+ break;
+
+ case Ctrl_L: // Whole line completion after ^X
+ if (ctrl_x_mode != CTRL_X_WHOLE_LINE) {
+ // CTRL-L with 'insertmode' set: Leave Insert mode
+ if (p_im) {
+ if (echeck_abbr(Ctrl_L + ABBR_OFF)) {
+ break;
}
- goto normalchar;
+ return 0; // exit insert mode
}
- /* FALLTHROUGH */
+ goto normalchar;
+ }
+ // FALLTHROUGH
+
+ case Ctrl_P: // Do previous/next pattern completion
+ case Ctrl_N:
+ // if 'complete' is empty then plain ^P is no longer special,
+ // but it is under other ^X modes
+ if (*curbuf->b_p_cpt == NUL
+ && ctrl_x_mode != 0
+ && !(compl_cont_status & CONT_LOCAL)) {
+ goto normalchar;
+ }
- case Ctrl_P: /* Do previous/next pattern completion */
- case Ctrl_N:
- /* if 'complete' is empty then plain ^P is no longer special,
- * but it is under other ^X modes */
- if (*curbuf->b_p_cpt == NUL
- && ctrl_x_mode != 0
- && !(compl_cont_status & CONT_LOCAL))
- goto normalchar;
-
-docomplete:
- compl_busy = TRUE;
- if (ins_complete(c) == FAIL)
- compl_cont_status = 0;
- compl_busy = FALSE;
- break;
+ insert_do_complete(s);
+ break;
- case Ctrl_Y: /* copy from previous line or scroll down */
- case Ctrl_E: /* copy from next line or scroll up */
- c = ins_ctrl_ey(c);
- break;
+ case Ctrl_Y: // copy from previous line or scroll down
+ case Ctrl_E: // copy from next line or scroll up
+ s->c = ins_ctrl_ey(s->c);
+ break;
- default:
-#ifdef UNIX
- if (c == intr_char) /* special interrupt char */
- goto do_intr;
-#endif
+ default:
normalchar:
- /*
- * Insert a normal character.
- */
- if (!p_paste) {
- /* Trigger InsertCharPre. */
- char_u *str = do_insert_char_pre(c);
- char_u *p;
-
- if (str != NULL) {
- if (*str != NUL && stop_arrow() != FAIL) {
- /* Insert the new value of v:char literally. */
- for (p = str; *p != NUL; mb_ptr_adv(p)) {
- c = PTR2CHAR(p);
- if (c == CAR || c == K_KENTER || c == NL)
- ins_eol(c);
- else
- ins_char(c);
+ // Insert a normal character.
+ if (!p_paste) {
+ // Trigger InsertCharPre.
+ char_u *str = do_insert_char_pre(s->c);
+ char_u *p;
+
+ if (str != NULL) {
+ if (*str != NUL && stop_arrow() != FAIL) {
+ // Insert the new value of v:char literally.
+ for (p = str; *p != NUL; mb_ptr_adv(p)) {
+ s->c = PTR2CHAR(p);
+ if (s->c == CAR || s->c == K_KENTER || s->c == NL) {
+ ins_eol(s->c);
+ } else {
+ ins_char(s->c);
}
- AppendToRedobuffLit(str, -1);
}
- xfree(str);
- c = NUL;
+ AppendToRedobuffLit(str, -1);
}
+ xfree(str);
+ s->c = NUL;
+ }
- /* If the new value is already inserted or an empty string
- * then don't insert any character. */
- if (c == NUL)
- break;
+ // If the new value is already inserted or an empty string
+ // then don't insert any character.
+ if (s->c == NUL)
+ break;
+ }
+ // Try to perform smart-indenting.
+ ins_try_si(s->c);
+
+ if (s->c == ' ') {
+ s->inserted_space = true;
+ if (inindent(0)) {
+ can_cindent = false;
}
- /* Try to perform smart-indenting. */
- ins_try_si(c);
-
- if (c == ' ') {
- inserted_space = TRUE;
- if (inindent(0))
- can_cindent = FALSE;
- if (Insstart_blank_vcol == MAXCOL
- && curwin->w_cursor.lnum == Insstart.lnum)
- Insstart_blank_vcol = get_nolist_virtcol();
+ if (Insstart_blank_vcol == MAXCOL
+ && curwin->w_cursor.lnum == Insstart.lnum) {
+ Insstart_blank_vcol = get_nolist_virtcol();
}
+ }
- /* Insert a normal character and check for abbreviations on a
- * special character. Let CTRL-] expand abbreviations without
- * inserting it. */
- if (vim_iswordc(c) || (!echeck_abbr(
- /* Add ABBR_OFF for characters above 0x100, this is
- * what check_abbr() expects. */
- (has_mbyte && c >= 0x100) ? (c + ABBR_OFF) :
- c) && c != Ctrl_RSB)) {
- insert_special(c, FALSE, FALSE);
- revins_legal++;
- revins_chars++;
- }
+ // Insert a normal character and check for abbreviations on a
+ // special character. Let CTRL-] expand abbreviations without
+ // inserting it.
+ if (vim_iswordc(s->c)
+ || (!echeck_abbr(
+ // Add ABBR_OFF for characters above 0x100, this is
+ // what check_abbr() expects.
+ (has_mbyte && s->c >= 0x100) ? (s->c + ABBR_OFF) : s->c)
+ && s->c != Ctrl_RSB)) {
+ insert_special(s->c, false, false);
+ revins_legal++;
+ revins_chars++;
+ }
- auto_format(FALSE, TRUE);
+ auto_format(false, true);
- /* When inserting a character the cursor line must never be in a
- * closed fold. */
- foldOpenCursor();
- break;
- } /* end of switch (c) */
+ // When inserting a character the cursor line must never be in a
+ // closed fold.
+ foldOpenCursor();
+ break;
+ } // end of switch (s->c)
- /* If typed something may trigger CursorHoldI again. */
- if (c != K_CURSORHOLD)
- did_cursorhold = FALSE;
+ return 1; // continue
+}
- /* If the cursor was moved we didn't just insert a space */
- if (arrow_used)
- inserted_space = FALSE;
+static void insert_do_complete(InsertState *s)
+{
+ compl_busy = true;
+ if (ins_complete(s->c) == FAIL) {
+ compl_cont_status = 0;
+ }
+ compl_busy = false;
+}
- if (can_cindent && cindent_on()
- && ctrl_x_mode == 0
- ) {
-force_cindent:
- /*
- * Indent now if a key was typed that is in 'cinkeys'.
- */
- if (in_cinkeys(c, ' ', line_is_white)) {
- if (stop_arrow() == OK)
- /* re-indent the current line */
- do_c_expr_indent();
- }
+static void insert_do_cindent(InsertState *s)
+{
+ // Indent now if a key was typed that is in 'cinkeys'.
+ if (in_cinkeys(s->c, ' ', s->line_is_white)) {
+ if (stop_arrow() == OK) {
+ // re-indent the current line
+ do_c_expr_indent();
}
+ }
+}
- } /* for (;;) */
- /* NOTREACHED */
+/*
+ * edit(): Start inserting text.
+ *
+ * "cmdchar" can be:
+ * 'i' normal insert command
+ * 'a' normal append command
+ * 'R' replace command
+ * 'r' "r<CR>" command: insert one <CR>. Note: count can be > 1, for redo,
+ * but still only one <CR> is inserted. The <Esc> is not used for redo.
+ * 'g' "gI" command.
+ * 'V' "gR" command for Virtual Replace mode.
+ * 'v' "gr" command for single character Virtual Replace mode.
+ *
+ * This function is not called recursively. For CTRL-O commands, it returns
+ * and lets the caller handle the Normal-mode command.
+ *
+ * Return TRUE if a CTRL-O command caused the return (insert mode pending).
+ */
+int
+edit (
+ int cmdchar,
+ int startln, /* if set, insert at start of line */
+ long count
+)
+{
+ if (curbuf->terminal) {
+ if (ex_normal_busy) {
+ // don't enter terminal mode from `ex_normal`, which can result in all
+ // kinds of havoc(such as terminal mode recursiveness). Instead, set a
+ // flag that allow us to force-set the value of `restart_edit` before
+ // `ex_normal` returns
+ restart_edit = 'i';
+ force_restart_edit = true;
+ } else {
+ terminal_enter();
+ }
+ return false;
+ }
+
+ // Don't allow inserting in the sandbox.
+ if (sandbox != 0) {
+ EMSG(_(e_sandbox));
+ return false;
+ }
+
+ // Don't allow changes in the buffer while editing the cmdline. The
+ // caller of getcmdline() may get confused.
+ if (textlock != 0) {
+ EMSG(_(e_secure));
+ return false;
+ }
+
+ // Don't allow recursive insert mode when busy with completion.
+ if (compl_started || compl_busy || pum_visible()) {
+ EMSG(_(e_secure));
+ return false;
+ }
+
+ InsertState state, *s = &state;
+ memset(s, 0, sizeof(InsertState));
+ s->state.execute = insert_execute;
+ s->state.check = insert_check;
+ s->cmdchar = cmdchar;
+ s->startln = startln;
+ s->count = count;
+ insert_enter(s);
+ return s->c == Ctrl_O;
}
/*
@@ -4924,8 +5017,9 @@ insertchar (
int textwidth;
char_u *p;
int fo_ins_blank;
+ int force_format = flags & INSCHAR_FORMAT;
- textwidth = comp_textwidth(flags & INSCHAR_FORMAT);
+ textwidth = comp_textwidth(force_format);
fo_ins_blank = has_format_option(FO_INS_BLANK);
/*
@@ -4944,7 +5038,7 @@ insertchar (
* before 'textwidth'
*/
if (textwidth > 0
- && ((flags & INSCHAR_FORMAT)
+ && (force_format
|| (!ascii_iswhite(c)
&& !((State & REPLACE_FLAG)
&& !(State & VREPLACE_FLAG)
@@ -4958,8 +5052,11 @@ insertchar (
/* Format with 'formatexpr' when it's set. Use internal formatting
* when 'formatexpr' isn't set or it returns non-zero. */
int do_internal = TRUE;
+ colnr_T virtcol = get_nolist_virtcol()
+ + char2cells(c != NUL ? c : gchar_cursor());
- if (*curbuf->b_p_fex != NUL && (flags & INSCHAR_NO_FEX) == 0) {
+ if (*curbuf->b_p_fex != NUL && (flags & INSCHAR_NO_FEX) == 0
+ && (force_format || virtcol > (colnr_T)textwidth)) {
do_internal = (fex_format(curwin->w_cursor.lnum, 1L, c) != 0);
/* It may be required to save for undo again, e.g. when setline()
* was called. */
@@ -5627,16 +5724,31 @@ static void redo_literal(int c)
AppendCharToRedobuff(c);
}
-/*
- * start_arrow() is called when an arrow key is used in insert mode.
- * For undo/redo it resembles hitting the <ESC> key.
- */
-static void
-start_arrow (
- pos_T *end_insert_pos /* can be NULL */
-)
+// start_arrow() is called when an arrow key is used in insert mode.
+// For undo/redo it resembles hitting the <ESC> key.
+static void start_arrow(pos_T *end_insert_pos /* can be NULL */)
+{
+ start_arrow_common(end_insert_pos, true);
+}
+
+/// Like start_arrow() but with end_change argument.
+/// Will prepare for redo of CTRL-G U if "end_change" is FALSE.
+/// @param end_insert_pos can be NULL
+/// @param end_change end undoable change
+static void start_arrow_with_change(pos_T *end_insert_pos, bool end_change)
{
- if (!arrow_used) { /* something has been inserted */
+ start_arrow_common(end_insert_pos, end_change);
+ if (!end_change) {
+ AppendCharToRedobuff(Ctrl_G);
+ AppendCharToRedobuff('U');
+ }
+}
+
+/// @param end_insert_pos can be NULL
+/// @param end_change end undoable change
+static void start_arrow_common(pos_T *end_insert_pos, bool end_change)
+{
+ if (!arrow_used && end_change) { // something has been inserted
AppendToRedobuff(ESC_STR);
stop_insert(end_insert_pos, FALSE, FALSE);
arrow_used = TRUE; /* this means we stopped the current insert */
@@ -6903,6 +7015,13 @@ static void ins_ctrl_g(void)
Insstart = curwin->w_cursor;
break;
+ // CTRL-G U: do not break undo with the next char.
+ case 'U':
+ // Allow one left/right cursor movement with the next char,
+ // without breaking undo.
+ dont_sync_undo = MAYBE;
+ break;
+
/* Unknown CTRL-G command, reserved for future expansion. */
default: vim_beep(BO_CTRLG);
}
@@ -7312,15 +7431,14 @@ static int ins_bs(int c, int mode, int *inserted_space_p)
* delete newline!
*/
if (curwin->w_cursor.col == 0) {
- lnum = Insstart_orig.lnum;
+ lnum = Insstart.lnum;
if (curwin->w_cursor.lnum == lnum || revins_on) {
if (u_save((linenr_T)(curwin->w_cursor.lnum - 2),
(linenr_T)(curwin->w_cursor.lnum + 1)) == FAIL) {
return FALSE;
}
- --Insstart_orig.lnum;
- Insstart_orig.col = MAXCOL;
- Insstart = Insstart_orig;
+ --Insstart.lnum;
+ Insstart.col = MAXCOL;
}
/*
* In replace mode:
@@ -7649,7 +7767,7 @@ static void ins_mousescroll(int dir)
-static void ins_left(void)
+static void ins_left(bool end_change)
{
pos_T tpos;
@@ -7658,17 +7776,17 @@ static void ins_left(void)
undisplay_dollar();
tpos = curwin->w_cursor;
if (oneleft() == OK) {
- start_arrow(&tpos);
+ start_arrow_with_change(&tpos, end_change);
+ if (!end_change) {
+ AppendCharToRedobuff(K_LEFT);
+ }
/* If exit reversed string, position is fixed */
if (revins_scol != -1 && (int)curwin->w_cursor.col >= revins_scol)
revins_legal++;
revins_chars++;
- }
- /*
- * if 'whichwrap' set for cursor in insert mode may go to
- * previous line
- */
- else if (vim_strchr(p_ww, '[') != NULL && curwin->w_cursor.lnum > 1) {
+ } else if (vim_strchr(p_ww, '[') != NULL && curwin->w_cursor.lnum > 1) {
+ // if 'whichwrap' set for cursor in insert mode may go to previous line.
+ // always break undo when moving upwards/downwards, else undo may break
start_arrow(&tpos);
--(curwin->w_cursor.lnum);
coladvance((colnr_T)MAXCOL);
@@ -7676,6 +7794,7 @@ static void ins_left(void)
} else {
vim_beep(BO_CRSR);
}
+ dont_sync_undo = false;
}
static void ins_home(int c)
@@ -7724,16 +7843,18 @@ static void ins_s_left(void)
}
}
-static void ins_right(void)
+/// @param end_change end undoable change
+static void ins_right(bool end_change)
{
if ((fdo_flags & FDO_HOR) && KeyTyped)
foldOpenCursor();
undisplay_dollar();
- if (gchar_cursor() != NUL
- || virtual_active()
- ) {
- start_arrow(&curwin->w_cursor);
- curwin->w_set_curswant = TRUE;
+ if (gchar_cursor() != NUL || virtual_active()) {
+ start_arrow_with_change(&curwin->w_cursor, end_change);
+ if (!end_change) {
+ AppendCharToRedobuff(K_RIGHT);
+ }
+ curwin->w_set_curswant = true;
if (virtual_active())
oneright();
else {
@@ -7758,6 +7879,7 @@ static void ins_right(void)
} else {
vim_beep(BO_CRSR);
}
+ dont_sync_undo = false;
}
static void ins_s_right(void)
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index a1ac713a75..b60886704e 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -1,18 +1,8 @@
/*
- *
- * VIM - Vi IMproved by Bram Moolenaar
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- * See README.txt for an overview of the Vim source code.
- */
-
-/*
* eval.c: Expression evaluation.
*/
#include <assert.h>
-#include <errno.h>
#include <inttypes.h>
#include <stdarg.h>
#include <string.h>
@@ -98,6 +88,7 @@
#include "nvim/os/input.h"
#include "nvim/event/loop.h"
#include "nvim/lib/kvec.h"
+#include "nvim/lib/queue.h"
#define DICT_MAXNEST 100 /* maximum nesting of lists and dicts */
@@ -228,50 +219,11 @@ static int echo_attr = 0; /* attributes used for ":echo" */
#define GLV_QUIET TFN_QUIET /* no error messages */
#define GLV_NO_AUTOLOAD TFN_NO_AUTOLOAD /* do not use script autoloading */
-/*
- * Structure to hold info for a user function.
- */
-typedef struct ufunc ufunc_T;
-
-struct ufunc {
- int uf_varargs; /* variable nr of arguments */
- int uf_flags;
- int uf_calls; /* nr of active calls */
- garray_T uf_args; /* arguments */
- garray_T uf_lines; /* function lines */
- int uf_profiling; /* TRUE when func is being profiled */
- /* 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 */
- /* 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 */
- scid_T uf_script_ID; /* ID of script where function was defined,
- used for s: variables */
- int uf_refcount; /* for numbered function: reference count */
- char_u uf_name[1]; /* name of function (actually longer); can
- start with <SNR>123_ (<SNR> is K_SPECIAL
- KS_EXTRA KE_SNR) */
-};
-
/* function flags */
#define FC_ABORT 1 /* abort function on error */
#define FC_RANGE 2 /* function accepts range */
#define FC_DICT 4 /* Dict function, uses "self" */
-/*
- * All user-defined functions are found in this hashtable.
- */
-static hashtab_T func_hashtab;
-
/* The names of packages that once were loaded are remembered. */
static garray_T ga_loaded = {0, 0, sizeof(char_u *), 4, NULL};
@@ -279,12 +231,6 @@ static garray_T ga_loaded = {0, 0, sizeof(char_u *), 4, NULL};
static dict_T *first_dict = NULL; /* list of all dicts */
static list_T *first_list = NULL; /* list of all lists */
-/* From user function to hashitem and back. */
-static ufunc_T dumuf;
-#define UF2HIKEY(fp) ((fp)->uf_name)
-#define HIKEY2UF(p) ((ufunc_T *)(p - (dumuf.uf_name - (char_u *)&dumuf)))
-#define HI2UF(hi) HIKEY2UF((hi)->hi_key)
-
#define FUNCARG(fp, j) ((char_u **)(fp->uf_args.ga_data))[j]
#define FUNCLINE(fp, j) ((char_u **)(fp->uf_lines.ga_data))[j]
@@ -427,6 +373,9 @@ static struct vimvar {
{VV_NAME("progpath", VAR_STRING), VV_RO},
{VV_NAME("command_output", VAR_STRING), 0},
{VV_NAME("completed_item", VAR_DICT), VV_RO},
+ {VV_NAME("option_new", VAR_STRING), VV_RO},
+ {VV_NAME("option_old", VAR_STRING), VV_RO},
+ {VV_NAME("option_type", VAR_STRING), VV_RO},
{VV_NAME("msgpack_types", VAR_DICT), VV_RO},
};
@@ -459,6 +408,13 @@ typedef struct {
Queue *events;
} TerminalJobData;
+typedef struct dict_watcher {
+ ufunc_T *callback;
+ char *key_pattern;
+ QUEUE node;
+ bool busy; // prevent recursion if the dict is changed in the callback
+} DictWatcher;
+
/// Structure representing current VimL to messagepack conversion state
typedef struct {
enum {
@@ -2376,6 +2332,14 @@ static void set_var_lval(lval_T *lp, char_u *endp, typval_T *rettv, int copy, ch
: lp->ll_n1 != lp->ll_n2)
EMSG(_("E711: List value has not enough items"));
} else {
+ typval_T oldtv;
+ dict_T *dict = lp->ll_dict;
+ bool watched = is_watched(dict);
+
+ if (watched) {
+ init_tv(&oldtv);
+ }
+
/*
* Assign to a List or Dictionary item.
*/
@@ -2392,22 +2356,38 @@ static void set_var_lval(lval_T *lp, char_u *endp, typval_T *rettv, int copy, ch
return;
}
lp->ll_tv = &di->di_tv;
- } else if (op != NULL && *op != '=') {
- tv_op(lp->ll_tv, rettv, op);
- return;
- } else
- clear_tv(lp->ll_tv);
+ } else {
+ if (watched) {
+ copy_tv(lp->ll_tv, &oldtv);
+ }
- /*
- * Assign the value to the variable or list item.
- */
- if (copy)
+ if (op != NULL && *op != '=') {
+ tv_op(lp->ll_tv, rettv, op);
+ goto notify;
+ } else {
+ clear_tv(lp->ll_tv);
+ }
+ }
+
+ // Assign the value to the variable or list item.
+ if (copy) {
copy_tv(rettv, lp->ll_tv);
- else {
+ } else {
*lp->ll_tv = *rettv;
lp->ll_tv->v_lock = 0;
init_tv(rettv);
}
+
+notify:
+ if (watched) {
+ if (oldtv.v_type == VAR_UNKNOWN) {
+ dictwatcher_notify(dict, (char *)lp->ll_newkey, lp->ll_tv, NULL);
+ } else {
+ dictitem_T *di = lp->ll_di;
+ dictwatcher_notify(dict, (char *)di->di_key, lp->ll_tv, &oldtv);
+ clear_tv(&oldtv);
+ }
+ }
}
}
@@ -2932,12 +2912,31 @@ static int do_unlet_var(lval_T *lp, char_u *name_end, int forceit)
++lp->ll_n1;
}
} else {
- if (lp->ll_list != NULL)
- /* unlet a List item. */
+ if (lp->ll_list != NULL) {
+ // unlet a List item.
listitem_remove(lp->ll_list, lp->ll_li);
- else
- /* unlet a Dictionary item. */
- dictitem_remove(lp->ll_dict, lp->ll_di);
+ } else {
+ // unlet a Dictionary item.
+ dict_T *d = lp->ll_dict;
+ dictitem_T *di = lp->ll_di;
+ bool watched = is_watched(d);
+ char *key = NULL;
+ typval_T oldtv;
+
+ if (watched) {
+ copy_tv(&di->di_tv, &oldtv);
+ // need to save key because dictitem_remove will free it
+ key = xstrdup((char *)di->di_key);
+ }
+
+ dictitem_remove(d, di);
+
+ if (watched) {
+ dictwatcher_notify(d, key, NULL, &oldtv);
+ clear_tv(&oldtv);
+ xfree(key);
+ }
+ }
}
return ret;
@@ -2953,8 +2952,9 @@ int do_unlet(char_u *name, int forceit)
hashitem_T *hi;
char_u *varname;
dictitem_T *di;
+ dict_T *dict;
+ ht = find_var_ht_dict(name, &varname, &dict);
- ht = find_var_ht(name, &varname);
if (ht != NULL && *varname != NUL) {
hi = hash_find(ht, varname);
if (!HASHITEM_EMPTY(hi)) {
@@ -2962,7 +2962,19 @@ int do_unlet(char_u *name, int forceit)
if (var_check_fixed(di->di_flags, name)
|| var_check_ro(di->di_flags, name))
return FAIL;
+ typval_T oldtv;
+ bool watched = is_watched(dict);
+
+ if (watched) {
+ copy_tv(&di->di_tv, &oldtv);
+ }
+
delete_var(ht, hi);
+
+ if (watched) {
+ dictwatcher_notify(dict, (char *)varname, NULL, &oldtv);
+ clear_tv(&oldtv);
+ }
return OK;
}
}
@@ -5639,6 +5651,14 @@ bool garbage_collect(void)
ABORTING(set_ref_in_ht)(&fc->l_avars.dv_hashtab, copyID, NULL);
}
+ // Jobs
+ {
+ TerminalJobData *data;
+ map_foreach_value(jobs, data, {
+ ABORTING(set_ref_dict)(data->self, copyID);
+ })
+ }
+
// v: vars
ABORTING(set_ref_in_ht)(&vimvarht, copyID, NULL);
@@ -5716,8 +5736,7 @@ static int free_unref_items(int copyID)
// Go through the list of dicts and free items without the copyID.
// Don't free dicts that are referenced internally.
for (dict_T *dd = first_dict; dd != NULL; ) {
- if ((dd->dv_copyID & COPYID_MASK) != (copyID & COPYID_MASK)
- && !dd->internal_refcount) {
+ if ((dd->dv_copyID & COPYID_MASK) != (copyID & COPYID_MASK)) {
// Free the Dictionary and ordinary items it contains, but don't
// recurse into Lists and Dictionaries, they will be in the list
// of dicts or list of lists. */
@@ -5958,7 +5977,7 @@ dict_T *dict_alloc(void) FUNC_ATTR_NONNULL_RET
d->dv_scope = 0;
d->dv_refcount = 0;
d->dv_copyID = 0;
- d->internal_refcount = 0;
+ QUEUE_INIT(&d->watchers);
return d;
}
@@ -6025,6 +6044,14 @@ dict_free (
--todo;
}
}
+
+ while (!QUEUE_EMPTY(&d->watchers)) {
+ QUEUE *w = QUEUE_HEAD(&d->watchers);
+ DictWatcher *watcher = dictwatcher_node_data(w);
+ dictwatcher_free(watcher);
+ QUEUE_REMOVE(w);
+ }
+
hash_clear(&d->dv_hashtab);
xfree(d);
}
@@ -6066,10 +6093,11 @@ static void dictitem_remove(dict_T *dict, dictitem_T *item)
hashitem_T *hi;
hi = hash_find(&dict->dv_hashtab, item->di_key);
- if (HASHITEM_EMPTY(hi))
+ if (HASHITEM_EMPTY(hi)) {
EMSG2(_(e_intern2), "dictitem_remove()");
- else
+ } else {
hash_remove(&dict->dv_hashtab, hi);
+ }
dictitem_free(item);
}
@@ -6264,7 +6292,16 @@ static bool get_dict_callback(dict_T *d, char *key, ufunc_T **result)
return false;
}
- uint8_t *name = di->di_tv.vval.v_string;
+ if ((*result = find_ufunc(di->di_tv.vval.v_string)) == NULL) {
+ return false;
+ }
+
+ (*result)->uf_refcount++;
+ return true;
+}
+
+static ufunc_T *find_ufunc(uint8_t *name)
+{
uint8_t *n = name;
ufunc_T *rv = NULL;
if (*n > '9' || *n < '0') {
@@ -6279,13 +6316,10 @@ static bool get_dict_callback(dict_T *d, char *key, ufunc_T **result)
if (!rv) {
EMSG2(_("Function %s doesn't exist"), name);
- *result = NULL;
- return false;
+ return NULL;
}
- rv->uf_refcount++;
- *result = rv;
- return true;
+ return rv;
}
/*
@@ -7098,6 +7132,8 @@ static struct fst {
{"cursor", 1, 3, f_cursor},
{"deepcopy", 1, 2, f_deepcopy},
{"delete", 1, 1, f_delete},
+ {"dictwatcheradd", 3, 3, f_dictwatcheradd},
+ {"dictwatcherdel", 3, 3, f_dictwatcherdel},
{"did_filetype", 0, 0, f_did_filetype},
{"diff_filler", 1, 1, f_diff_filler},
{"diff_hlID", 2, 2, f_diff_hlID},
@@ -8666,6 +8702,110 @@ static void f_delete(typval_T *argvars, typval_T *rettv)
rettv->vval.v_number = os_remove((char *)get_tv_string(&argvars[0]));
}
+// dictwatcheradd(dict, key, funcref) function
+static void f_dictwatcheradd(typval_T *argvars, typval_T *rettv)
+{
+ if (check_restricted() || check_secure()) {
+ return;
+ }
+
+ if (argvars[0].v_type != VAR_DICT) {
+ EMSG2(e_invarg2, "dict");
+ return;
+ }
+
+ if (argvars[1].v_type != VAR_STRING && argvars[1].v_type != VAR_NUMBER) {
+ EMSG2(e_invarg2, "key");
+ return;
+ }
+
+ if (argvars[2].v_type != VAR_FUNC && argvars[2].v_type != VAR_STRING) {
+ EMSG2(e_invarg2, "funcref");
+ return;
+ }
+
+ char *key_pattern = (char *)get_tv_string_chk(argvars + 1);
+ assert(key_pattern);
+ const size_t key_len = STRLEN(argvars[1].vval.v_string);
+
+ if (key_len == 0) {
+ EMSG(_(e_emptykey));
+ return;
+ }
+
+ ufunc_T *func = find_ufunc(argvars[2].vval.v_string);
+ if (!func) {
+ // Invalid function name. Error already reported by `find_ufunc`.
+ return;
+ }
+
+ func->uf_refcount++;
+ DictWatcher *watcher = xmalloc(sizeof(DictWatcher));
+ watcher->key_pattern = xmemdupz(key_pattern, key_len);
+ watcher->callback = func;
+ watcher->busy = false;
+ QUEUE_INSERT_TAIL(&argvars[0].vval.v_dict->watchers, &watcher->node);
+}
+
+// dictwatcherdel(dict, key, funcref) function
+static void f_dictwatcherdel(typval_T *argvars, typval_T *rettv)
+{
+ if (check_restricted() || check_secure()) {
+ return;
+ }
+
+ if (argvars[0].v_type != VAR_DICT) {
+ EMSG2(e_invarg2, "dict");
+ return;
+ }
+
+ if (argvars[1].v_type != VAR_STRING && argvars[1].v_type != VAR_NUMBER) {
+ EMSG2(e_invarg2, "key");
+ return;
+ }
+
+ if (argvars[2].v_type != VAR_FUNC && argvars[2].v_type != VAR_STRING) {
+ EMSG2(e_invarg2, "funcref");
+ return;
+ }
+
+ char *key_pattern = (char *)get_tv_string_chk(argvars + 1);
+ assert(key_pattern);
+ const size_t key_len = STRLEN(argvars[1].vval.v_string);
+
+ if (key_len == 0) {
+ EMSG(_(e_emptykey));
+ return;
+ }
+
+ ufunc_T *func = find_ufunc(argvars[2].vval.v_string);
+ if (!func) {
+ // Invalid function name. Error already reported by `find_ufunc`.
+ return;
+ }
+
+ dict_T *dict = argvars[0].vval.v_dict;
+ QUEUE *w = NULL;
+ DictWatcher *watcher = NULL;
+ bool matched = false;
+ QUEUE_FOREACH(w, &dict->watchers) {
+ watcher = dictwatcher_node_data(w);
+ if (func == watcher->callback
+ && !strcmp(watcher->key_pattern, key_pattern)) {
+ matched = true;
+ break;
+ }
+ }
+
+ if (!matched) {
+ EMSG("Couldn't find a watcher matching key and callback");
+ return;
+ }
+
+ QUEUE_REMOVE(w);
+ dictwatcher_free(watcher);
+}
+
/*
* "did_filetype()" function
*/
@@ -8972,6 +9112,7 @@ void dict_extend(dict_T *d1, dict_T *d2, char_u *action)
dictitem_T *di1;
hashitem_T *hi2;
int todo;
+ bool watched = is_watched(d1);
todo = (int)d2->dv_hashtab.ht_used;
for (hi2 = d2->dv_hashtab.ht_array; todo > 0; ++hi2) {
@@ -8992,14 +9133,30 @@ void dict_extend(dict_T *d1, dict_T *d2, char_u *action)
}
if (di1 == NULL) {
di1 = dictitem_copy(HI2DI(hi2));
- if (dict_add(d1, di1) == FAIL)
+ if (dict_add(d1, di1) == FAIL) {
dictitem_free(di1);
+ }
+
+ if (watched) {
+ dictwatcher_notify(d1, (char *)di1->di_key, &di1->di_tv, NULL);
+ }
} else if (*action == 'e') {
EMSG2(_("E737: Key already exists: %s"), hi2->hi_key);
break;
} else if (*action == 'f' && HI2DI(hi2) != di1) {
+ typval_T oldtv;
+
+ if (watched) {
+ copy_tv(&di1->di_tv, &oldtv);
+ }
+
clear_tv(&di1->di_tv);
copy_tv(&HI2DI(hi2)->di_tv, &di1->di_tv);
+
+ if (watched) {
+ dictwatcher_notify(d1, (char *)di1->di_key, &di1->di_tv, &oldtv);
+ clear_tv(&oldtv);
+ }
}
}
}
@@ -10556,9 +10713,7 @@ static void f_has(typval_T *argvars, typval_T *rettv)
#endif
"arabic",
"autocmd",
-#ifdef FEAT_BROWSE
"browsefilter",
-#endif
"byte_offset",
"cindent",
"cmdline_compl",
@@ -13519,6 +13674,9 @@ static void f_remove(typval_T *argvars, typval_T *rettv)
*rettv = di->di_tv;
init_tv(&di->di_tv);
dictitem_remove(d, di);
+ if (is_watched(d)) {
+ dictwatcher_notify(d, (char *)key, NULL, rettv);
+ }
}
}
}
@@ -16678,10 +16836,11 @@ static void f_undofile(typval_T *argvars, typval_T *rettv)
/* If there is no file name there will be no undo file. */
rettv->vval.v_string = NULL;
} else {
- char_u *ffname = (char_u *)FullName_save((char *)fname, FALSE);
+ char *ffname = FullName_save((char *)fname, false);
- if (ffname != NULL)
- rettv->vval.v_string = u_get_undo_file_name(ffname, FALSE);
+ if (ffname != NULL) {
+ rettv->vval.v_string = (char_u *)u_get_undo_file_name(ffname, false);
+ }
xfree(ffname);
}
}
@@ -18110,53 +18269,67 @@ static dictitem_T *find_var_in_ht(hashtab_T *ht, int htname, char_u *varname, in
return HI2DI(hi);
}
-/*
- * Find the hashtab used for a variable name.
- * Set "varname" to the start of name without ':'.
- */
-static hashtab_T *find_var_ht(char_u *name, char_u **varname)
+// Find the dict and hashtable used for a variable name. Set "varname" to the
+// start of name without ':'.
+static hashtab_T *find_var_ht_dict(char_u *name, uint8_t **varname, dict_T **d)
{
hashitem_T *hi;
+ *d = NULL;
if (name[1] != ':') {
- /* The name must not start with a colon or #. */
- if (name[0] == ':' || name[0] == AUTOLOAD_CHAR)
+ // name has implicit scope
+ if (name[0] == ':' || name[0] == AUTOLOAD_CHAR) {
+ // The name must not start with a colon or #.
return NULL;
+ }
*varname = name;
- /* "version" is "v:version" in all scopes */
+ // "version" is "v:version" in all scopes
hi = hash_find(&compat_hashtab, name);
- if (!HASHITEM_EMPTY(hi))
+ if (!HASHITEM_EMPTY(hi)) {
return &compat_hashtab;
+ }
- if (current_funccal == NULL)
- return &globvarht; /* global variable */
- return &current_funccal->l_vars.dv_hashtab; /* l: variable */
+ *d = current_funccal ? &current_funccal->l_vars : &globvardict;
+ goto end;
}
+
*varname = name + 2;
- if (*name == 'g') /* global variable */
- return &globvarht;
- /* There must be no ':' or '#' in the rest of the name, unless g: is used
- */
- if (vim_strchr(name + 2, ':') != NULL
- || vim_strchr(name + 2, AUTOLOAD_CHAR) != NULL)
+ if (*name == 'g') { // global variable
+ *d = &globvardict;
+ } else if (vim_strchr(name + 2, ':') != NULL
+ || vim_strchr(name + 2, AUTOLOAD_CHAR) != NULL) {
+ // There must be no ':' or '#' in the rest of the name if g: was not used
return NULL;
- if (*name == 'b') /* buffer variable */
- return &curbuf->b_vars->dv_hashtab;
- if (*name == 'w') /* window variable */
- return &curwin->w_vars->dv_hashtab;
- if (*name == 't') /* tab page variable */
- return &curtab->tp_vars->dv_hashtab;
- if (*name == 'v') /* v: variable */
- return &vimvarht;
- if (*name == 'a' && current_funccal != NULL) /* function argument */
- return &current_funccal->l_avars.dv_hashtab;
- if (*name == 'l' && current_funccal != NULL) /* local function variable */
- return &current_funccal->l_vars.dv_hashtab;
- if (*name == 's' /* script variable */
- && current_SID > 0 && current_SID <= ga_scripts.ga_len)
- return &SCRIPT_VARS(current_SID);
- return NULL;
+ }
+
+ if (*name == 'b') { // buffer variable
+ *d = curbuf->b_vars;
+ } else if (*name == 'w') { // window variable
+ *d = curwin->w_vars;
+ } else if (*name == 't') { // tab page variable
+ *d = curtab->tp_vars;
+ } else if (*name == 'v') { // v: variable
+ *d = &vimvardict;
+ } else if (*name == 'a' && current_funccal != NULL) { // function argument
+ *d = &current_funccal->l_avars;
+ } else if (*name == 'l' && current_funccal != NULL) { // local variable
+ *d = &current_funccal->l_vars;
+ } else if (*name == 's' // script variable
+ && current_SID > 0 && current_SID <= ga_scripts.ga_len) {
+ *d = &SCRIPT_SV(current_SID)->sv_dict;
+ }
+
+end:
+ return *d ? &(*d)->dv_hashtab : NULL;
+}
+
+// Find the hashtab used for a variable name.
+// Set "varname" to the start of name without ':'.
+static hashtab_T *find_var_ht(uint8_t *name, uint8_t **varname)
+{
+ dict_T *d;
+ return find_var_ht_dict(name, varname, &d);
}
/*
@@ -18220,6 +18393,7 @@ void init_var_dict(dict_T *dict, dictitem_T *dict_var, int scope)
dict_var->di_tv.v_lock = VAR_FIXED;
dict_var->di_flags = DI_FLAGS_RO | DI_FLAGS_FIX;
dict_var->di_key[0] = NUL;
+ QUEUE_INIT(&dict->watchers);
}
/*
@@ -18352,8 +18526,16 @@ set_var (
dictitem_T *v;
char_u *varname;
hashtab_T *ht;
+ typval_T oldtv;
+ dict_T *dict;
+
+ ht = find_var_ht_dict(name, &varname, &dict);
+ bool watched = is_watched(dict);
+
+ if (watched) {
+ init_tv(&oldtv);
+ }
- ht = find_var_ht(name, &varname);
if (ht == NULL || *varname == NUL) {
EMSG2(_(e_illvar), name);
return;
@@ -18410,6 +18592,9 @@ set_var (
return;
}
+ if (watched) {
+ copy_tv(&v->di_tv, &oldtv);
+ }
clear_tv(&v->di_tv);
} else { /* add a new variable */
/* Can't add "v:" variable. */
@@ -18431,13 +18616,22 @@ set_var (
v->di_flags = 0;
}
- if (copy || tv->v_type == VAR_NUMBER || tv->v_type == VAR_FLOAT)
+ if (copy || tv->v_type == VAR_NUMBER || tv->v_type == VAR_FLOAT) {
copy_tv(tv, &v->di_tv);
- else {
+ } else {
v->di_tv = *tv;
v->di_tv.v_lock = 0;
init_tv(tv);
}
+
+ if (watched) {
+ if (oldtv.v_type == VAR_UNKNOWN) {
+ dictwatcher_notify(dict, (char *)v->di_key, &v->di_tv, NULL);
+ } else {
+ dictwatcher_notify(dict, (char *)v->di_key, &v->di_tv, &oldtv);
+ clear_tv(&oldtv);
+ }
+ }
}
/*
@@ -21013,9 +21207,9 @@ void last_set_msg(scid_T scriptID)
*/
void ex_oldfiles(exarg_T *eap)
{
- list_T *l = vimvars[VV_OLDFILES].vv_list;
+ list_T *l = get_vim_var_list(VV_OLDFILES);
listitem_T *li;
- int nr = 0;
+ long nr = 0;
if (l == NULL)
msg((char_u *)_("No old files"));
@@ -21023,7 +21217,7 @@ void ex_oldfiles(exarg_T *eap)
msg_start();
msg_scroll = TRUE;
for (li = l->lv_first; li != NULL && !got_int; li = li->li_next) {
- msg_outnum((long)++nr);
+ msg_outnum(++nr);
MSG_PUTS(": ");
msg_outtrans(get_tv_string(&li->li_tv));
msg_putchar('\n');
@@ -21033,12 +21227,33 @@ void ex_oldfiles(exarg_T *eap)
/* Assume "got_int" was set to truncate the listing. */
got_int = FALSE;
+ // File selection prompt on ":oldfiles!"
+ if (eap->forceit) {
+ quit_more = false;
+ nr = prompt_for_number(false);
+ msg_starthere();
+ if (nr > 0 && nr <= l->lv_len) {
+ char_u *p = list_find_str(l, nr);
+ if (p == NULL) {
+ return;
+ }
+ p = expand_env_save(p);
+ eap->arg = p;
+ eap->cmdidx = CMD_edit;
+ do_exedit(eap, NULL);
+ xfree(p);
+ }
+ }
}
}
-
-
-
+// reset v:option_new, v:option_old and v:option_type
+void reset_v_option_vars(void)
+{
+ set_vim_var_string(VV_OPTION_NEW, NULL, -1);
+ set_vim_var_string(VV_OPTION_OLD, NULL, -1);
+ set_vim_var_string(VV_OPTION_TYPE, NULL, -1);
+}
/*
* Adjust a filename, according to a string of modifiers.
@@ -21411,7 +21626,6 @@ static inline bool common_job_callbacks(dict_T *vopts, ufunc_T **on_stdout,
if (get_dict_callback(vopts, "on_stdout", on_stdout)
&& get_dict_callback(vopts, "on_stderr", on_stderr)
&& get_dict_callback(vopts, "on_exit", on_exit)) {
- vopts->internal_refcount++;
vopts->dv_refcount++;
return true;
}
@@ -21473,7 +21687,6 @@ static inline void free_term_job_data_event(void **argv)
}
if (data->self) {
- data->self->internal_refcount--;
dict_unref(data->self);
}
queue_free(data->events);
@@ -21569,8 +21782,10 @@ static void on_process_exit(Process *proc, int status, void *d)
TerminalJobData *data = d;
if (data->term && !data->exited) {
data->exited = true;
- terminal_close(data->term,
- _("\r\n[Program exited, press any key to close]"));
+ char msg[22];
+ snprintf(msg, sizeof msg, "\r\n[Process exited %d]", proc->status);
+ terminal_close(data->term, msg);
+ apply_autocmds(EVENT_TERMCLOSE, NULL, NULL, false, curbuf);
}
if (data->status_ptr) {
@@ -21722,7 +21937,7 @@ typval_T eval_call_provider(char *provider, char *method, list_T *arguments)
true,
NULL);
- arguments->lv_refcount--;
+ list_unref(arguments);
// Restore caller scope information
restore_funccal(provider_caller_scope.funccalp);
provider_caller_scope = saved_provider_caller_scope;
@@ -21758,3 +21973,94 @@ bool eval_has_provider(char *name)
return false;
}
+
+// Compute the `DictWatcher` address from a QUEUE node. This only exists because
+// ASAN doesn't handle `QUEUE_DATA` pointer arithmetic, and we blacklist this
+// function on .asan-blacklist.
+static DictWatcher *dictwatcher_node_data(QUEUE *q)
+ FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET
+{
+ return QUEUE_DATA(q, DictWatcher, node);
+}
+
+// Send a change notification to all `dict` watchers that match `key`.
+static void dictwatcher_notify(dict_T *dict, const char *key, typval_T *newtv,
+ typval_T *oldtv)
+ FUNC_ATTR_NONNULL_ARG(1) FUNC_ATTR_NONNULL_ARG(2)
+{
+ typval_T argv[3];
+ for (size_t i = 0; i < ARRAY_SIZE(argv); i++) {
+ init_tv(argv + i);
+ }
+
+ argv[0].v_type = VAR_DICT;
+ argv[0].vval.v_dict = dict;
+ argv[1].v_type = VAR_STRING;
+ argv[1].vval.v_string = (char_u *)xstrdup(key);
+ argv[2].v_type = VAR_DICT;
+ argv[2].vval.v_dict = dict_alloc();
+ argv[2].vval.v_dict->dv_refcount++;
+
+ if (newtv) {
+ dictitem_T *v = dictitem_alloc((char_u *)"new");
+ copy_tv(newtv, &v->di_tv);
+ dict_add(argv[2].vval.v_dict, v);
+ }
+
+ if (oldtv) {
+ dictitem_T *v = dictitem_alloc((char_u *)"old");
+ copy_tv(oldtv, &v->di_tv);
+ dict_add(argv[2].vval.v_dict, v);
+ }
+
+ typval_T rettv;
+
+ QUEUE *w;
+ QUEUE_FOREACH(w, &dict->watchers) {
+ DictWatcher *watcher = dictwatcher_node_data(w);
+ if (!watcher->busy && dictwatcher_matches(watcher, key)) {
+ init_tv(&rettv);
+ watcher->busy = true;
+ call_user_func(watcher->callback, ARRAY_SIZE(argv), argv, &rettv,
+ curwin->w_cursor.lnum, curwin->w_cursor.lnum, NULL);
+ watcher->busy = false;
+ clear_tv(&rettv);
+ }
+ }
+
+ for (size_t i = 1; i < ARRAY_SIZE(argv); i++) {
+ clear_tv(argv + i);
+ }
+}
+
+// Test if `key` matches with with `watcher->key_pattern`
+static bool dictwatcher_matches(DictWatcher *watcher, const char *key)
+ FUNC_ATTR_NONNULL_ALL
+{
+ // For now only allow very simple globbing in key patterns: a '*' at the end
+ // of the string means it should match everything up to the '*' instead of the
+ // whole string.
+ char *nul = strchr(watcher->key_pattern, NUL);
+ size_t len = nul - watcher->key_pattern;
+ if (*(nul - 1) == '*') {
+ return !strncmp(key, watcher->key_pattern, len - 1);
+ } else {
+ return !strcmp(key, watcher->key_pattern);
+ }
+}
+
+// Perform all necessary cleanup for a `DictWatcher` instance.
+static void dictwatcher_free(DictWatcher *watcher)
+ FUNC_ATTR_NONNULL_ALL
+{
+ user_func_unref(watcher->callback);
+ xfree(watcher->key_pattern);
+ xfree(watcher);
+}
+
+// Check if `d` has at least one watcher.
+static bool is_watched(dict_T *d)
+{
+ return d && !QUEUE_EMPTY(&d->watchers);
+}
+
diff --git a/src/nvim/eval.h b/src/nvim/eval.h
index 864daed716..19a1bbb083 100644
--- a/src/nvim/eval.h
+++ b/src/nvim/eval.h
@@ -5,6 +5,47 @@
#include "nvim/profile.h"
+// All user-defined functions are found in this hashtable.
+EXTERN hashtab_T func_hashtab;
+
+// Structure to hold info for a user function.
+typedef struct ufunc ufunc_T;
+
+struct ufunc {
+ int uf_varargs; ///< variable nr of arguments
+ int uf_flags;
+ int uf_calls; ///< nr of active calls
+ garray_T uf_args; ///< arguments
+ garray_T uf_lines; ///< function lines
+ int uf_profiling; ///< true when func is being profiled
+ // 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
+ // 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
+ scid_T uf_script_ID; ///< ID of script where function was defined,
+ // used for s: variables
+ int uf_refcount; ///< for numbered function: reference count
+ char_u uf_name[1]; ///< name of function (actually longer); can
+ // start with <SNR>123_ (<SNR> is K_SPECIAL
+ // KS_EXTRA KE_SNR)
+};
+
+// From user function to hashitem and back.
+EXTERN ufunc_T dumuf;
+#define UF2HIKEY(fp) ((fp)->uf_name)
+#define HIKEY2UF(p) ((ufunc_T *)(p - (dumuf.uf_name - (char_u *)&dumuf)))
+#define HI2UF(hi) HIKEY2UF((hi)->hi_key)
+
/* Defines for Vim variables. These must match vimvars[] in eval.c! */
enum {
VV_COUNT,
@@ -67,6 +108,9 @@ enum {
VV_PROGPATH,
VV_COMMAND_OUTPUT,
VV_COMPLETED_ITEM,
+ VV_OPTION_NEW,
+ VV_OPTION_OLD,
+ VV_OPTION_TYPE,
VV_MSGPACK_TYPES,
VV_LEN, /* number of v: vars */
};
diff --git a/src/nvim/eval_defs.h b/src/nvim/eval_defs.h
index 373f1e6278..ed419268d2 100644
--- a/src/nvim/eval_defs.h
+++ b/src/nvim/eval_defs.h
@@ -5,6 +5,7 @@
#include <stddef.h>
#include "nvim/hashtab.h"
+#include "nvim/lib/queue.h"
typedef int varnumber_T;
typedef double float_T;
@@ -117,8 +118,7 @@ struct dictvar_S {
dict_T *dv_copydict; /* copied dict used by deepcopy() */
dict_T *dv_used_next; /* next dict in used dicts list */
dict_T *dv_used_prev; /* previous dict in used dicts list */
- int internal_refcount; // number of internal references to
- // prevent garbage collection
+ QUEUE watchers; // dictionary key watchers set by user code
};
// structure used for explicit stack while garbage collecting hash tables
diff --git a/src/nvim/event/socket.c b/src/nvim/event/socket.c
index 347e464d25..93cc592683 100644
--- a/src/nvim/event/socket.c
+++ b/src/nvim/event/socket.c
@@ -97,7 +97,7 @@ int socket_watcher_start(SocketWatcher *watcher, int backlog, socket_cb cb)
result = uv_listen(watcher->stream, backlog, connection_cb);
}
- assert(result <= 0); // libuv should have returned -errno or zero.
+ assert(result <= 0); // libuv should return negative error code or zero.
if (result < 0) {
if (result == -EACCES) {
// Libuv converts ENOENT to EACCES for Windows compatibility, but if
diff --git a/src/nvim/event/stream.c b/src/nvim/event/stream.c
index 376eb9fce7..71582ab357 100644
--- a/src/nvim/event/stream.c
+++ b/src/nvim/event/stream.c
@@ -13,7 +13,7 @@
/// Sets the stream associated with `fd` to "blocking" mode.
///
-/// @return `0` on success, or `-errno` on failure.
+/// @return `0` on success, or libuv error code on failure.
int stream_set_blocking(int fd, bool blocking)
{
// Private loop to avoid conflict with existing watcher(s):
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index 5db3880026..d902234ef7 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -1,17 +1,8 @@
/*
- * VIM - Vi IMproved by Bram Moolenaar
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- * See README.txt for an overview of the Vim source code.
- */
-
-/*
* ex_cmds.c: some functions for command line commands
*/
#include <assert.h>
-#include <errno.h>
#include <stdbool.h>
#include <string.h>
#include <stdlib.h>
@@ -62,7 +53,6 @@
#include "nvim/tempfile.h"
#include "nvim/ui.h"
#include "nvim/undo.h"
-#include "nvim/version.h"
#include "nvim/window.h"
#include "nvim/os/os.h"
#include "nvim/os/shell.h"
@@ -2122,7 +2112,6 @@ do_ecmd (
goto theend;
if (buf->b_ml.ml_mfp == NULL) { /* no memfile yet */
oldbuf = FALSE;
- buf->b_nwindows = 0;
} else { /* existing memfile */
oldbuf = TRUE;
(void)buf_check_timestamp(buf, FALSE);
@@ -2148,7 +2137,7 @@ do_ecmd (
* Make the (new) buffer the one used by the current window.
* If the old buffer becomes unused, free it if ECMD_HIDE is FALSE.
* If the current buffer was empty and has no file name, curbuf
- * is returned by buflist_new().
+ * is returned by buflist_new(), nothing to do here.
*/
if (buf != curbuf) {
/*
@@ -2235,8 +2224,7 @@ do_ecmd (
}
xfree(new_name);
au_new_curbuf = NULL;
- } else
- ++curbuf->b_nwindows;
+ }
curwin->w_pcmark.lnum = 1;
curwin->w_pcmark.col = 0;
diff --git a/src/nvim/ex_cmds.lua b/src/nvim/ex_cmds.lua
index 77f7dba81b..b7a3505c99 100644
--- a/src/nvim/ex_cmds.lua
+++ b/src/nvim/ex_cmds.lua
@@ -267,7 +267,7 @@ return {
},
{
command='buffers',
- flags=bit.bor(BANG, TRLBAR, CMDWIN),
+ flags=bit.bor(BANG, EXTRA, TRLBAR, CMDWIN),
addr_type=ADDR_LINES,
func='buflist_list',
},
@@ -885,7 +885,7 @@ return {
},
{
command='files',
- flags=bit.bor(BANG, TRLBAR, CMDWIN),
+ flags=bit.bor(BANG, EXTRA, TRLBAR, CMDWIN),
addr_type=ADDR_LINES,
func='buflist_list',
},
@@ -989,13 +989,13 @@ return {
command='gui',
flags=bit.bor(BANG, FILES, EDITCMD, ARGOPT, TRLBAR, CMDWIN),
addr_type=ADDR_LINES,
- func='ex_gui',
+ func='ex_nogui',
},
{
command='gvim',
flags=bit.bor(BANG, FILES, EDITCMD, ARGOPT, TRLBAR, CMDWIN),
addr_type=ADDR_LINES,
- func='ex_gui',
+ func='ex_nogui',
},
{
command='help',
@@ -1013,7 +1013,7 @@ return {
command='helpfind',
flags=bit.bor(EXTRA, NOTRLCOM),
addr_type=ADDR_LINES,
- func='ex_helpfind',
+ func='ex_ni',
},
{
command='helpgrep',
@@ -1521,7 +1521,7 @@ return {
},
{
command='ls',
- flags=bit.bor(BANG, TRLBAR, CMDWIN),
+ flags=bit.bor(BANG, EXTRA, TRLBAR, CMDWIN),
addr_type=ADDR_LINES,
func='buflist_list',
},
@@ -1643,19 +1643,19 @@ return {
command='nbkey',
flags=bit.bor(EXTRA, NOTADR, NEEDARG),
addr_type=ADDR_LINES,
- func='ex_nbkey',
+ func='ex_ni',
},
{
command='nbclose',
flags=bit.bor(TRLBAR, CMDWIN),
addr_type=ADDR_LINES,
- func='ex_nbclose',
+ func='ex_ni',
},
{
command='nbstart',
flags=bit.bor(WORD1, TRLBAR, CMDWIN),
addr_type=ADDR_LINES,
- func='ex_nbstart',
+ func='ex_ni',
},
{
command='new',
@@ -1754,12 +1754,6 @@ return {
func='ex_menu',
},
{
- command='open',
- flags=bit.bor(RANGE, BANG, EXTRA),
- addr_type=ADDR_LINES,
- func='ex_open',
- },
- {
command='oldfiles',
flags=bit.bor(BANG, TRLBAR, SBOXOK, CMDWIN),
addr_type=ADDR_LINES,
@@ -1865,7 +1859,7 @@ return {
command='popup',
flags=bit.bor(NEEDARG, EXTRA, BANG, TRLBAR, NOTRLCOM, CMDWIN),
addr_type=ADDR_LINES,
- func='ex_popup',
+ func='ex_ni',
},
{
command='ppop',
@@ -1889,13 +1883,13 @@ return {
command='promptfind',
flags=bit.bor(EXTRA, NOTRLCOM, CMDWIN),
addr_type=ADDR_LINES,
- func='gui_mch_find_dialog',
+ func='ex_ni',
},
{
command='promptrepl',
flags=bit.bor(EXTRA, NOTRLCOM, CMDWIN),
addr_type=ADDR_LINES,
- func='gui_mch_replace_dialog',
+ func='ex_ni',
},
{
command='profile',
@@ -2309,7 +2303,7 @@ return {
command='simalt',
flags=bit.bor(NEEDARG, WORD1, TRLBAR, CMDWIN),
addr_type=ADDR_LINES,
- func='ex_simalt',
+ func='ex_ni',
},
{
command='sign',
@@ -3035,7 +3029,7 @@ return {
command='wsverb',
flags=bit.bor(EXTRA, NOTADR, NEEDARG),
addr_type=ADDR_LINES,
- func='ex_wsverb',
+ func='ex_ni',
},
{
command='wshada',
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c
index f172ea54c2..87a6283310 100644
--- a/src/nvim/ex_cmds2.c
+++ b/src/nvim/ex_cmds2.c
@@ -1,17 +1,8 @@
/*
- * VIM - Vi IMproved by Bram Moolenaar
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- * See README.txt for an overview of the Vim source code.
- */
-
-/*
* ex_cmds2.c: some more functions for command line commands
*/
#include <assert.h>
-#include <errno.h>
#include <inttypes.h>
#include <stdbool.h>
#include <string.h>
@@ -21,7 +12,6 @@
#ifdef HAVE_LOCALE_H
# include <locale.h>
#endif
-#include "nvim/version.h"
#include "nvim/ex_cmds2.h"
#include "nvim/buffer.h"
#include "nvim/charset.h"
@@ -762,9 +752,14 @@ void ex_profile(exarg_T *eap)
do_profiling = PROF_YES;
profile_set_wait(profile_zero());
set_vim_var_nr(VV_PROFILING, 1L);
- } else if (do_profiling == PROF_NONE)
+ } else if (do_profiling == PROF_NONE) {
EMSG(_("E750: First use \":profile start {fname}\""));
- else if (STRCMP(eap->arg, "pause") == 0) {
+ } else if (STRCMP(eap->arg, "stop") == 0) {
+ profile_dump();
+ do_profiling = PROF_NONE;
+ set_vim_var_nr(VV_PROFILING, 0L);
+ profile_reset();
+ } else if (STRCMP(eap->arg, "pause") == 0) {
if (do_profiling == PROF_YES)
pause_time = profile_start();
do_profiling = PROF_PAUSED;
@@ -774,6 +769,8 @@ void ex_profile(exarg_T *eap)
profile_set_wait(profile_add(profile_get_wait(), pause_time));
}
do_profiling = PROF_YES;
+ } else if (STRCMP(eap->arg, "dump") == 0) {
+ profile_dump();
} else {
/* The rest is similar to ":breakadd". */
ex_breakadd(eap);
@@ -817,18 +814,14 @@ static enum {
} pexpand_what;
static char *pexpand_cmds[] = {
- "start",
-#define PROFCMD_START 0
- "pause",
-#define PROFCMD_PAUSE 1
"continue",
-#define PROFCMD_CONTINUE 2
- "func",
-#define PROFCMD_FUNC 3
+ "dump",
"file",
-#define PROFCMD_FILE 4
+ "func",
+ "pause",
+ "start",
+ "stop",
NULL
-#define PROFCMD_LAST 5
};
/*
@@ -891,10 +884,63 @@ void profile_dump(void)
}
}
-/*
- * Start profiling script "fp".
- */
-static void script_do_profile(scriptitem_T *si)
+/// Reset all profiling information.
+static void profile_reset(void)
+{
+ // Reset sourced files.
+ for (int id = 1; id <= script_items.ga_len; id++) {
+ scriptitem_T *si = &SCRIPT_ITEM(id);
+ if (si->sn_prof_on) {
+ si->sn_prof_on = 0;
+ si->sn_pr_force = 0;
+ si->sn_pr_child = profile_zero();
+ si->sn_pr_nest = 0;
+ si->sn_pr_count = 0;
+ si->sn_pr_total = profile_zero();
+ si->sn_pr_self = profile_zero();
+ si->sn_pr_start = profile_zero();
+ si->sn_pr_children = profile_zero();
+ ga_clear(&si->sn_prl_ga);
+ si->sn_prl_start = profile_zero();
+ si->sn_prl_children = profile_zero();
+ si->sn_prl_wait = profile_zero();
+ si->sn_prl_idx = -1;
+ si->sn_prl_execed = 0;
+ }
+ }
+
+ // Reset functions.
+ size_t n = func_hashtab.ht_used;
+ hashitem_T *hi = func_hashtab.ht_array;
+
+ for (; n > (size_t)0; hi++) {
+ if (!HASHITEM_EMPTY(hi)) {
+ n--;
+ ufunc_T *uf = HI2UF(hi);
+ if (uf->uf_profiling) {
+ uf->uf_profiling = 0;
+ uf->uf_tm_count = 0;
+ uf->uf_tm_total = profile_zero();
+ uf->uf_tm_self = profile_zero();
+ uf->uf_tm_children = profile_zero();
+ uf->uf_tml_count = NULL;
+ uf->uf_tml_total = NULL;
+ uf->uf_tml_self = NULL;
+ uf->uf_tml_start = profile_zero();
+ uf->uf_tml_children = profile_zero();
+ uf->uf_tml_wait = profile_zero();
+ uf->uf_tml_idx = -1;
+ uf->uf_tml_execed = 0;
+ }
+ }
+ }
+
+ xfree(profile_fname);
+ profile_fname = NULL;
+}
+
+/// Start profiling a script.
+static void profile_init(scriptitem_T *si)
{
si->sn_pr_count = 0;
si->sn_pr_total = profile_zero();
@@ -2357,9 +2403,7 @@ do_source (
*/
p = path_tail(fname_exp);
if ((*p == '.' || *p == '_')
- && (STRICMP(p + 1, "nvimrc") == 0
- || STRICMP(p + 1, "ngvimrc") == 0
- || STRICMP(p + 1, "exrc") == 0)) {
+ && (STRICMP(p + 1, "nvimrc") == 0 || STRICMP(p + 1, "exrc") == 0)) {
if (*p == '_')
*p = '.';
else
@@ -2510,8 +2554,8 @@ do_source (
int forceit;
/* Check if we do profiling for this script. */
- if (!si->sn_prof_on && has_profiling(TRUE, si->sn_name, &forceit)) {
- script_do_profile(si);
+ if (!si->sn_prof_on && has_profiling(true, si->sn_name, &forceit)) {
+ profile_init(si);
si->sn_pr_force = forceit;
}
if (si->sn_prof_on) {
diff --git a/src/nvim/ex_cmds_defs.h b/src/nvim/ex_cmds_defs.h
index 4065cc2fdc..10d2eb688e 100644
--- a/src/nvim/ex_cmds_defs.h
+++ b/src/nvim/ex_cmds_defs.h
@@ -1,9 +1,3 @@
-/*
- * VIM - Vi IMproved by Bram Moolenaar
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- */
#ifndef NVIM_EX_CMDS_DEFS_H
#define NVIM_EX_CMDS_DEFS_H
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index a9262ca6ea..59bda9345e 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -1,12 +1,4 @@
/*
- * VIM - Vi IMproved by Bram Moolenaar
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- * See README.txt for an overview of the Vim source code.
- */
-
-/*
* ex_docmd.c: functions for executing an Ex command line.
*/
@@ -14,7 +6,6 @@
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
-#include <errno.h>
#include <inttypes.h>
#include "nvim/vim.h"
@@ -80,6 +71,9 @@
static int quitmore = 0;
static int ex_pressedreturn = FALSE;
+/* whether ":lcd" was produced for a session */
+static int did_lcd;
+
typedef struct ucmd {
char_u *uc_name; /* The command name */
uint32_t uc_argt; /* The argument type */
@@ -144,23 +138,9 @@ struct dbg_stuff {
# include "ex_docmd.c.generated.h"
#endif
-# define ex_gui ex_nogui
-# define ex_popup ex_ni
-# define ex_simalt ex_ni
-# define gui_mch_find_dialog ex_ni
-# define gui_mch_replace_dialog ex_ni
-# define ex_helpfind ex_ni
-static int did_lcd; /* whether ":lcd" was produced for a session */
#ifndef HAVE_WORKING_LIBINTL
# define ex_language ex_ni
#endif
-# define ex_wsverb ex_ni
-# define ex_nbclose ex_ni
-# define ex_nbkey ex_ni
-# define ex_nbstart ex_ni
-
-
-
/*
* Declare cmdnames[].
@@ -3466,6 +3446,7 @@ static linenr_T get_address(char_u **ptr,
}
if (addr_type != ADDR_LINES) {
EMSG(_(e_invaddr));
+ cmd = NULL;
goto error;
}
if (skip)
@@ -3493,6 +3474,7 @@ static linenr_T get_address(char_u **ptr,
c = *cmd++;
if (addr_type != ADDR_LINES) {
EMSG(_(e_invaddr));
+ cmd = NULL;
goto error;
}
if (skip) { /* skip "/pat/" */
@@ -3536,6 +3518,7 @@ static linenr_T get_address(char_u **ptr,
++cmd;
if (addr_type != ADDR_LINES) {
EMSG(_(e_invaddr));
+ cmd = NULL;
goto error;
}
if (*cmd == '&')
@@ -3607,7 +3590,8 @@ static linenr_T get_address(char_u **ptr,
else
n = getdigits(&cmd);
if (addr_type == ADDR_LOADED_BUFFERS || addr_type == ADDR_BUFFERS)
- lnum = compute_buffer_local_count(addr_type, lnum, (i == '-') ? -1 * n : n);
+ lnum = compute_buffer_local_count(
+ addr_type, lnum, (i == '-') ? -1 * n : n);
else if (i == '-')
lnum -= n;
else
@@ -3675,7 +3659,8 @@ static char_u *invalid_range(exarg_T *eap)
}
break;
case ADDR_ARGUMENTS:
- if (eap->line2 > ARGCOUNT + (!ARGCOUNT)) { // add 1 if ARGCOUNT is 0
+ // add 1 if ARGCOUNT is 0
+ if (eap->line2 > ARGCOUNT + (!ARGCOUNT)) {
return (char_u *)_(e_invrange);
}
break;
@@ -6467,40 +6452,6 @@ static void ex_find(exarg_T *eap)
}
/*
- * ":open" simulation: for now just work like ":visual".
- */
-static void ex_open(exarg_T *eap)
-{
- regmatch_T regmatch;
- char_u *p;
-
- curwin->w_cursor.lnum = eap->line2;
- beginline(BL_SOL | BL_FIX);
- if (*eap->arg == '/') {
- /* ":open /pattern/": put cursor in column found with pattern */
- ++eap->arg;
- p = skip_regexp(eap->arg, '/', p_magic, NULL);
- *p = NUL;
- regmatch.regprog = vim_regcomp(eap->arg, p_magic ? RE_MAGIC : 0);
- if (regmatch.regprog != NULL) {
- regmatch.rm_ic = p_ic;
- p = get_cursor_line_ptr();
- if (vim_regexec(&regmatch, p, (colnr_T)0))
- curwin->w_cursor.col = (colnr_T)(regmatch.startp[0] - p);
- else
- EMSG(_(e_nomatch));
- vim_regfree(regmatch.regprog);
- }
- /* Move to the NUL, ignore any other arguments. */
- eap->arg += STRLEN(eap->arg);
- }
- check_cursor();
-
- eap->cmdidx = CMD_visual;
- do_exedit(eap, NULL);
-}
-
-/*
* ":edit", ":badd", ":visual".
*/
static void ex_edit(exarg_T *eap)
@@ -6544,7 +6495,7 @@ do_exedit (
msg_scroll = 0;
must_redraw = CLEAR;
- main_loop(FALSE, TRUE);
+ normal_enter(false, true);
RedrawingDisabled = rd;
no_wait_return = nwr;
@@ -7193,7 +7144,7 @@ static void ex_wundo(exarg_T *eap)
char_u hash[UNDO_HASH_SIZE];
u_compute_hash(hash);
- u_write_undo(eap->arg, eap->forceit, curbuf, hash);
+ u_write_undo((char *) eap->arg, eap->forceit, curbuf, hash);
}
static void ex_rundo(exarg_T *eap)
@@ -7201,7 +7152,7 @@ static void ex_rundo(exarg_T *eap)
char_u hash[UNDO_HASH_SIZE];
u_compute_hash(hash);
- u_read_undo(eap->arg, hash, NULL);
+ u_read_undo((char *) eap->arg, hash, NULL);
}
/*
diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c
index bea1aecb58..bf67047ae8 100644
--- a/src/nvim/ex_eval.c
+++ b/src/nvim/ex_eval.c
@@ -1,12 +1,4 @@
/*
- * VIM - Vi IMproved by Bram Moolenaar
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- * See README.txt for an overview of the Vim source code.
- */
-
-/*
* ex_eval.c: functions for Ex command line for the +eval feature.
*/
#include <assert.h>
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 50e9ce7c17..6d81f3680a 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -1,17 +1,8 @@
/*
- * VIM - Vi IMproved by Bram Moolenaar
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- * See README.txt for an overview of the Vim source code.
- */
-
-/*
* ex_getln.c: Functions for entering and editing an Ex command line.
*/
#include <assert.h>
-#include <errno.h>
#include <stdbool.h>
#include <string.h>
#include <stdlib.h>
@@ -58,6 +49,7 @@
#include "nvim/screen.h"
#include "nvim/search.h"
#include "nvim/strings.h"
+#include "nvim/state.h"
#include "nvim/syntax.h"
#include "nvim/tag.h"
#include "nvim/window.h"
@@ -91,6 +83,45 @@ struct cmdline_info {
int input_fn; /* when TRUE Invoked for input() function */
};
+typedef struct command_line_state {
+ VimState state;
+ int firstc;
+ long count;
+ int indent;
+ int c;
+ int i;
+ int j;
+ int gotesc; // TRUE when <ESC> just typed
+ int do_abbr; // when TRUE check for abbr.
+ char_u *lookfor; // string to match
+ int hiscnt; // current history line in use
+ int histype; // history type to be used
+ pos_T old_cursor;
+ colnr_T old_curswant;
+ colnr_T old_leftcol;
+ linenr_T old_topline;
+ int old_topfill;
+ linenr_T old_botline;
+ int did_incsearch;
+ int incsearch_postponed;
+ int did_wild_list; // did wild_list() recently
+ int wim_index; // index in wim_flags[]
+ int res;
+ int save_msg_scroll;
+ int save_State; // remember State when called
+ int some_key_typed; // one of the keys was typed
+ // mouse drag and release events are ignored, unless they are
+ // preceded with a mouse down event
+ int ignore_drag_release;
+ int break_ctrl_c;
+ expand_T xpc;
+ long *b_im_ptr;
+ // Everything that may work recursively should save and restore the
+ // current command line in save_ccline. That includes update_screen(), a
+ // custom status line may invoke ":normal".
+ struct cmdline_info save_ccline;
+} CommandLineState;
+
/* The current cmdline_info. It is initialized in getcmdline() and after that
* used by other functions. When invoking getcmdline() recursively it needs
* to be saved with save_cmdline() and restored with restore_cmdline().
@@ -120,1400 +151,1486 @@ static int hislen = 0; /* actual length of history tables */
static int cmd_hkmap = 0; /* Hebrew mapping during command line */
static int cmd_fkmap = 0; /* Farsi mapping during command line */
-
-/*
- * getcmdline() - accept a command line starting with firstc.
- *
- * firstc == ':' get ":" command line.
- * firstc == '/' or '?' get search pattern
- * firstc == '=' get expression
- * firstc == '@' get text for input() function
- * firstc == '>' get text for debug mode
- * firstc == NUL get text for :insert command
- * firstc == -1 like NUL, and break on CTRL-C
- *
- * The line is collected in ccline.cmdbuff, which is reallocated to fit the
- * command line.
- *
- * Careful: getcmdline() can be called recursively!
- *
- * Return pointer to allocated string if there is a commandline, NULL
- * otherwise.
- */
-char_u *
-getcmdline (
- int firstc,
- long count, /* only used for incremental search */
- int indent /* indent for inside conditionals */
-)
+static uint8_t *command_line_enter(int firstc, long count, int indent)
{
- int c;
- int i;
- int j;
- int gotesc = FALSE; /* TRUE when <ESC> just typed */
- int do_abbr; /* when TRUE check for abbr. */
- char_u *lookfor = NULL; /* string to match */
- int hiscnt; /* current history line in use */
- int histype; /* history type to be used */
- pos_T old_cursor;
- colnr_T old_curswant;
- colnr_T old_leftcol;
- linenr_T old_topline;
- int old_topfill;
- linenr_T old_botline;
- int did_incsearch = FALSE;
- int incsearch_postponed = FALSE;
- int did_wild_list = FALSE; /* did wild_list() recently */
- int wim_index = 0; /* index in wim_flags[] */
- int res;
- int save_msg_scroll = msg_scroll;
- int save_State = State; /* remember State when called */
- int some_key_typed = FALSE; /* one of the keys was typed */
- /* mouse drag and release events are ignored, unless they are
- * preceded with a mouse down event */
- int ignore_drag_release = TRUE;
- int break_ctrl_c = FALSE;
- expand_T xpc;
- long *b_im_ptr = NULL;
- /* Everything that may work recursively should save and restore the
- * current command line in save_ccline. That includes update_screen(), a
- * custom status line may invoke ":normal". */
- struct cmdline_info save_ccline;
-
- if (firstc == -1) {
- firstc = NUL;
- break_ctrl_c = TRUE;
+ CommandLineState state, *s = &state;
+ memset(s, 0, sizeof(CommandLineState));
+ s->firstc = firstc;
+ s->count = count;
+ s->indent = indent;
+ s->save_msg_scroll = msg_scroll;
+ s->save_State = State;
+ s->ignore_drag_release = true;
+
+ if (s->firstc == -1) {
+ s->firstc = NUL;
+ s->break_ctrl_c = true;
}
- /* start without Hebrew mapping for a command line */
- if (firstc == ':' || firstc == '=' || firstc == '>')
+
+ // start without Hebrew mapping for a command line
+ if (s->firstc == ':' || s->firstc == '=' || s->firstc == '>') {
cmd_hkmap = 0;
+ }
- ccline.overstrike = FALSE; /* always start in insert mode */
- old_cursor = curwin->w_cursor; /* needs to be restored later */
- old_curswant = curwin->w_curswant;
- old_leftcol = curwin->w_leftcol;
- old_topline = curwin->w_topline;
- old_topfill = curwin->w_topfill;
- old_botline = curwin->w_botline;
+ ccline.overstrike = false; // always start in insert mode
+ s->old_cursor = curwin->w_cursor; // needs to be restored later
+ s->old_curswant = curwin->w_curswant;
+ s->old_leftcol = curwin->w_leftcol;
+ s->old_topline = curwin->w_topline;
+ s->old_topfill = curwin->w_topfill;
+ s->old_botline = curwin->w_botline;
- /*
- * set some variables for redrawcmd()
- */
- ccline.cmdfirstc = (firstc == '@' ? 0 : firstc);
- ccline.cmdindent = (firstc > 0 ? indent : 0);
+ // set some variables for redrawcmd()
+ ccline.cmdfirstc = (s->firstc == '@' ? 0 : s->firstc);
+ ccline.cmdindent = (s->firstc > 0 ? s->indent : 0);
- /* alloc initial ccline.cmdbuff */
- alloc_cmdbuff(exmode_active ? 250 : indent + 1);
+ // alloc initial ccline.cmdbuff
+ alloc_cmdbuff(exmode_active ? 250 : s->indent + 1);
ccline.cmdlen = ccline.cmdpos = 0;
ccline.cmdbuff[0] = NUL;
- /* autoindent for :insert and :append */
- if (firstc <= 0) {
- memset(ccline.cmdbuff, ' ', indent);
- ccline.cmdbuff[indent] = NUL;
- ccline.cmdpos = indent;
- ccline.cmdspos = indent;
- ccline.cmdlen = indent;
+ // autoindent for :insert and :append
+ if (s->firstc <= 0) {
+ memset(ccline.cmdbuff, ' ', s->indent);
+ ccline.cmdbuff[s->indent] = NUL;
+ ccline.cmdpos = s->indent;
+ ccline.cmdspos = s->indent;
+ ccline.cmdlen = s->indent;
}
- ExpandInit(&xpc);
- ccline.xpc = &xpc;
+ ExpandInit(&s->xpc);
+ ccline.xpc = &s->xpc;
if (curwin->w_p_rl && *curwin->w_p_rlc == 's'
- && (firstc == '/' || firstc == '?'))
- cmdmsg_rl = TRUE;
- else
- cmdmsg_rl = FALSE;
+ && (s->firstc == '/' || s->firstc == '?')) {
+ cmdmsg_rl = true;
+ } else {
+ cmdmsg_rl = false;
+ }
- redir_off = TRUE; /* don't redirect the typed command */
+ redir_off = true; // don't redirect the typed command
if (!cmd_silent) {
- i = msg_scrolled;
- msg_scrolled = 0; /* avoid wait_return message */
- gotocmdline(TRUE);
- msg_scrolled += i;
- redrawcmdprompt(); /* draw prompt or indent */
+ s->i = msg_scrolled;
+ msg_scrolled = 0; // avoid wait_return message
+ gotocmdline(true);
+ msg_scrolled += s->i;
+ redrawcmdprompt(); // draw prompt or indent
set_cmdspos();
}
- xpc.xp_context = EXPAND_NOTHING;
- xpc.xp_backslash = XP_BS_NONE;
+ s->xpc.xp_context = EXPAND_NOTHING;
+ s->xpc.xp_backslash = XP_BS_NONE;
#ifndef BACKSLASH_IN_FILENAME
- xpc.xp_shell = FALSE;
+ s->xpc.xp_shell = false;
#endif
if (ccline.input_fn) {
- xpc.xp_context = ccline.xp_context;
- xpc.xp_pattern = ccline.cmdbuff;
- xpc.xp_arg = ccline.xp_arg;
+ s->xpc.xp_context = ccline.xp_context;
+ s->xpc.xp_pattern = ccline.cmdbuff;
+ s->xpc.xp_arg = ccline.xp_arg;
}
- /*
- * Avoid scrolling when called by a recursive do_cmdline(), e.g. when
- * doing ":@0" when register 0 doesn't contain a CR.
- */
- msg_scroll = FALSE;
+ // Avoid scrolling when called by a recursive do_cmdline(), e.g. when
+ // doing ":@0" when register 0 doesn't contain a CR.
+ msg_scroll = false;
State = CMDLINE;
- if (firstc == '/' || firstc == '?' || firstc == '@') {
- /* Use ":lmap" mappings for search pattern and input(). */
- if (curbuf->b_p_imsearch == B_IMODE_USE_INSERT)
- b_im_ptr = &curbuf->b_p_iminsert;
- else
- b_im_ptr = &curbuf->b_p_imsearch;
- if (*b_im_ptr == B_IMODE_LMAP)
+ if (s->firstc == '/' || s->firstc == '?' || s->firstc == '@') {
+ // Use ":lmap" mappings for search pattern and input().
+ if (curbuf->b_p_imsearch == B_IMODE_USE_INSERT) {
+ s->b_im_ptr = &curbuf->b_p_iminsert;
+ } else {
+ s->b_im_ptr = &curbuf->b_p_imsearch;
+ }
+
+ if (*s->b_im_ptr == B_IMODE_LMAP) {
State |= LANGMAP;
+ }
}
setmouse();
- ui_cursor_shape(); /* may show different cursor shape */
+ ui_cursor_shape(); // may show different cursor shape
init_history();
- hiscnt = hislen; /* set hiscnt to impossible history value */
- histype = hist_char2type(firstc);
-
- do_digraph(-1); /* init digraph typeahead */
+ s->hiscnt = hislen; // set hiscnt to impossible history value
+ s->histype = hist_char2type(s->firstc);
+ do_digraph(-1); // init digraph typeahead
// If something above caused an error, reset the flags, we do want to type
// and execute commands. Display may be messed up a bit.
if (did_emsg) {
redrawcmd();
}
- did_emsg = FALSE;
- got_int = FALSE;
- /*
- * Collect the command string, handling editing keys.
- */
- for (;; ) {
- redir_off = TRUE; /* Don't redirect the typed command.
- Repeated, because a ":redir" inside
- completion may switch it on. */
- quit_more = FALSE; /* reset after CTRL-D which had a more-prompt */
+ did_emsg = false;
+ got_int = false;
+ s->state.check = command_line_check;
+ s->state.execute = command_line_execute;
+ state_enter(&s->state);
- cursorcmd(); /* set the cursor on the right spot */
+ cmdmsg_rl = false;
- /* Get a character. Ignore K_IGNORE, it should not do anything, such
- * as stop completion. */
- input_enable_events();
- do {
- c = safe_vgetc();
- } while (c == K_IGNORE || c == K_PASTE);
- input_disable_events();
+ cmd_fkmap = 0;
- if (c == K_EVENT) {
- queue_process_events(loop.events);
- continue;
+ ExpandCleanup(&s->xpc);
+ ccline.xpc = NULL;
+
+ if (s->did_incsearch) {
+ curwin->w_cursor = s->old_cursor;
+ curwin->w_curswant = s->old_curswant;
+ curwin->w_leftcol = s->old_leftcol;
+ curwin->w_topline = s->old_topline;
+ curwin->w_topfill = s->old_topfill;
+ curwin->w_botline = s->old_botline;
+ highlight_match = false;
+ validate_cursor(); // needed for TAB
+ redraw_later(SOME_VALID);
+ }
+
+ if (ccline.cmdbuff != NULL) {
+ // Put line in history buffer (":" and "=" only when it was typed).
+ if (ccline.cmdlen && s->firstc != NUL
+ && (s->some_key_typed || s->histype == HIST_SEARCH)) {
+ add_to_history(s->histype, ccline.cmdbuff, true,
+ s->histype == HIST_SEARCH ? s->firstc : NUL);
+ if (s->firstc == ':') {
+ xfree(new_last_cmdline);
+ new_last_cmdline = vim_strsave(ccline.cmdbuff);
+ }
}
- if (KeyTyped) {
- some_key_typed = TRUE;
- if (cmd_hkmap)
- c = hkmap(c);
- if (cmd_fkmap)
- c = cmdl_fkmap(c);
- if (cmdmsg_rl && !KeyStuffed) {
- /* Invert horizontal movements and operations. Only when
- * typed by the user directly, not when the result of a
- * mapping. */
- switch (c) {
- case K_RIGHT: c = K_LEFT; break;
- case K_S_RIGHT: c = K_S_LEFT; break;
- case K_C_RIGHT: c = K_C_LEFT; break;
- case K_LEFT: c = K_RIGHT; break;
- case K_S_LEFT: c = K_S_RIGHT; break;
- case K_C_LEFT: c = K_C_RIGHT; break;
- }
+ if (s->gotesc) { // abandon command line
+ xfree(ccline.cmdbuff);
+ ccline.cmdbuff = NULL;
+ if (msg_scrolled == 0) {
+ compute_cmdrow();
}
+ MSG("");
+ redraw_cmdline = true;
}
+ }
- /*
- * Ignore got_int when CTRL-C was typed here.
- * Don't ignore it in :global, we really need to break then, e.g., for
- * ":g/pat/normal /pat" (without the <CR>).
- * Don't ignore it for the input() function.
- */
- if ((c == Ctrl_C
-#ifdef UNIX
- || c == intr_char
-#endif
- )
- && firstc != '@'
- && !break_ctrl_c
- && !global_busy)
- got_int = FALSE;
-
- /* free old command line when finished moving around in the history
- * list */
- if (lookfor != NULL
- && c != K_S_DOWN && c != K_S_UP
- && c != K_DOWN && c != K_UP
- && c != K_PAGEDOWN && c != K_PAGEUP
- && c != K_KPAGEDOWN && c != K_KPAGEUP
- && c != K_LEFT && c != K_RIGHT
- && (xpc.xp_numfiles > 0 || (c != Ctrl_P && c != Ctrl_N))) {
- xfree(lookfor);
- lookfor = NULL;
+ // If the screen was shifted up, redraw the whole screen (later).
+ // If the line is too long, clear it, so ruler and shown command do
+ // not get printed in the middle of it.
+ msg_check();
+ msg_scroll = s->save_msg_scroll;
+ redir_off = false;
+
+ // When the command line was typed, no need for a wait-return prompt.
+ if (s->some_key_typed) {
+ need_wait_return = false;
+ }
+
+ State = s->save_State;
+ setmouse();
+ ui_cursor_shape(); // may show different cursor shape
+
+ {
+ char_u *p = ccline.cmdbuff;
+
+ // Make ccline empty, getcmdline() may try to use it.
+ ccline.cmdbuff = NULL;
+ return p;
+ }
+}
+
+static int command_line_check(VimState *state)
+{
+ redir_off = true; // Don't redirect the typed command.
+ // Repeated, because a ":redir" inside
+ // completion may switch it on.
+ quit_more = false; // reset after CTRL-D which had a more-prompt
+
+ cursorcmd(); // set the cursor on the right spot
+ return 1;
+}
+
+static int command_line_execute(VimState *state, int key)
+{
+ if (key == K_IGNORE || key == K_PASTE) {
+ return -1; // get another key
+ }
+
+ CommandLineState *s = (CommandLineState *)state;
+ s->c = key;
+
+ if (s->c == K_EVENT) {
+ queue_process_events(loop.events);
+ return 1;
+ }
+
+ if (KeyTyped) {
+ s->some_key_typed = true;
+ if (cmd_hkmap) {
+ s->c = hkmap(s->c);
}
- /*
- * When there are matching completions to select <S-Tab> works like
- * CTRL-P (unless 'wc' is <S-Tab>).
- */
- if (c != p_wc && c == K_S_TAB && xpc.xp_numfiles > 0)
- c = Ctrl_P;
-
- /* Special translations for 'wildmenu' */
- if (did_wild_list && p_wmnu) {
- if (c == K_LEFT)
- c = Ctrl_P;
- else if (c == K_RIGHT)
- c = Ctrl_N;
+ if (cmd_fkmap) {
+ s->c = cmdl_fkmap(s->c);
}
- /* Hitting CR after "emenu Name.": complete submenu */
- if (xpc.xp_context == EXPAND_MENUNAMES && p_wmnu
- && ccline.cmdpos > 1
- && ccline.cmdbuff[ccline.cmdpos - 1] == '.'
- && ccline.cmdbuff[ccline.cmdpos - 2] != '\\'
- && (c == '\n' || c == '\r' || c == K_KENTER))
- c = K_DOWN;
-
- /* free expanded names when finished walking through matches */
- if (xpc.xp_numfiles != -1
- && !(c == p_wc && KeyTyped) && c != p_wcm
- && c != Ctrl_N && c != Ctrl_P && c != Ctrl_A
- && c != Ctrl_L) {
- (void)ExpandOne(&xpc, NULL, NULL, 0, WILD_FREE);
- did_wild_list = FALSE;
- if (!p_wmnu || (c != K_UP && c != K_DOWN))
- xpc.xp_context = EXPAND_NOTHING;
- wim_index = 0;
- if (p_wmnu && wild_menu_showing != 0) {
- int skt = KeyTyped;
- int old_RedrawingDisabled = RedrawingDisabled;
-
- if (ccline.input_fn)
- RedrawingDisabled = 0;
-
- if (wild_menu_showing == WM_SCROLLED) {
- /* Entered command line, move it up */
- cmdline_row--;
- redrawcmd();
- } else if (save_p_ls != -1) {
- /* restore 'laststatus' and 'winminheight' */
- p_ls = save_p_ls;
- p_wmh = save_p_wmh;
- last_status(FALSE);
- save_cmdline(&save_ccline);
- update_screen(VALID); /* redraw the screen NOW */
- restore_cmdline(&save_ccline);
- redrawcmd();
- save_p_ls = -1;
- } else {
- win_redraw_last_status(topframe);
- redraw_statuslines();
- }
- KeyTyped = skt;
- wild_menu_showing = 0;
- if (ccline.input_fn)
- RedrawingDisabled = old_RedrawingDisabled;
+
+ if (cmdmsg_rl && !KeyStuffed) {
+ // Invert horizontal movements and operations. Only when
+ // typed by the user directly, not when the result of a
+ // mapping.
+ switch (s->c) {
+ case K_RIGHT: s->c = K_LEFT; break;
+ case K_S_RIGHT: s->c = K_S_LEFT; break;
+ case K_C_RIGHT: s->c = K_C_LEFT; break;
+ case K_LEFT: s->c = K_RIGHT; break;
+ case K_S_LEFT: s->c = K_S_RIGHT; break;
+ case K_C_LEFT: s->c = K_C_RIGHT; break;
}
}
+ }
- /* Special translations for 'wildmenu' */
- if (xpc.xp_context == EXPAND_MENUNAMES && p_wmnu) {
- /* Hitting <Down> after "emenu Name.": complete submenu */
- if (c == K_DOWN && ccline.cmdpos > 0
- && ccline.cmdbuff[ccline.cmdpos - 1] == '.')
- c = p_wc;
- else if (c == K_UP) {
- /* Hitting <Up>: Remove one submenu name in front of the
- * cursor */
- int found = FALSE;
-
- j = (int)(xpc.xp_pattern - ccline.cmdbuff);
- i = 0;
- while (--j > 0) {
- /* check for start of menu name */
- if (ccline.cmdbuff[j] == ' '
- && ccline.cmdbuff[j - 1] != '\\') {
- i = j + 1;
+ // Ignore got_int when CTRL-C was typed here.
+ // Don't ignore it in :global, we really need to break then, e.g., for
+ // ":g/pat/normal /pat" (without the <CR>).
+ // Don't ignore it for the input() function.
+ if ((s->c == Ctrl_C)
+ && s->firstc != '@'
+ && !s->break_ctrl_c
+ && !global_busy) {
+ got_int = false;
+ }
+
+ // free old command line when finished moving around in the history
+ // list
+ if (s->lookfor != NULL
+ && s->c != K_S_DOWN && s->c != K_S_UP
+ && s->c != K_DOWN && s->c != K_UP
+ && s->c != K_PAGEDOWN && s->c != K_PAGEUP
+ && s->c != K_KPAGEDOWN && s->c != K_KPAGEUP
+ && s->c != K_LEFT && s->c != K_RIGHT
+ && (s->xpc.xp_numfiles > 0 || (s->c != Ctrl_P && s->c != Ctrl_N))) {
+ xfree(s->lookfor);
+ s->lookfor = NULL;
+ }
+
+ // When there are matching completions to select <S-Tab> works like
+ // CTRL-P (unless 'wc' is <S-Tab>).
+ if (s->c != p_wc && s->c == K_S_TAB && s->xpc.xp_numfiles > 0) {
+ s->c = Ctrl_P;
+ }
+
+ // Special translations for 'wildmenu'
+ if (s->did_wild_list && p_wmnu) {
+ if (s->c == K_LEFT) {
+ s->c = Ctrl_P;
+ } else if (s->c == K_RIGHT) {
+ s->c = Ctrl_N;
+ }
+ }
+
+ // Hitting CR after "emenu Name.": complete submenu
+ if (s->xpc.xp_context == EXPAND_MENUNAMES && p_wmnu
+ && ccline.cmdpos > 1
+ && ccline.cmdbuff[ccline.cmdpos - 1] == '.'
+ && ccline.cmdbuff[ccline.cmdpos - 2] != '\\'
+ && (s->c == '\n' || s->c == '\r' || s->c == K_KENTER)) {
+ s->c = K_DOWN;
+ }
+
+ // free expanded names when finished walking through matches
+ if (s->xpc.xp_numfiles != -1
+ && !(s->c == p_wc && KeyTyped) && s->c != p_wcm
+ && s->c != Ctrl_N && s->c != Ctrl_P && s->c != Ctrl_A
+ && s->c != Ctrl_L) {
+ (void)ExpandOne(&s->xpc, NULL, NULL, 0, WILD_FREE);
+ s->did_wild_list = false;
+ if (!p_wmnu || (s->c != K_UP && s->c != K_DOWN)) {
+ s->xpc.xp_context = EXPAND_NOTHING;
+ }
+ s->wim_index = 0;
+ if (p_wmnu && wild_menu_showing != 0) {
+ int skt = KeyTyped;
+ int old_RedrawingDisabled = RedrawingDisabled;
+
+ if (ccline.input_fn) {
+ RedrawingDisabled = 0;
+ }
+
+ if (wild_menu_showing == WM_SCROLLED) {
+ // Entered command line, move it up
+ cmdline_row--;
+ redrawcmd();
+ } else if (save_p_ls != -1) {
+ // restore 'laststatus' and 'winminheight'
+ p_ls = save_p_ls;
+ p_wmh = save_p_wmh;
+ last_status(false);
+ save_cmdline(&s->save_ccline);
+ update_screen(VALID); // redraw the screen NOW
+ restore_cmdline(&s->save_ccline);
+ redrawcmd();
+ save_p_ls = -1;
+ } else {
+ win_redraw_last_status(topframe);
+ redraw_statuslines();
+ }
+ KeyTyped = skt;
+ wild_menu_showing = 0;
+ if (ccline.input_fn) {
+ RedrawingDisabled = old_RedrawingDisabled;
+ }
+ }
+ }
+
+ // Special translations for 'wildmenu'
+ if (s->xpc.xp_context == EXPAND_MENUNAMES && p_wmnu) {
+ // Hitting <Down> after "emenu Name.": complete submenu
+ if (s->c == K_DOWN && ccline.cmdpos > 0
+ && ccline.cmdbuff[ccline.cmdpos - 1] == '.') {
+ s->c = p_wc;
+ } else if (s->c == K_UP) {
+ // Hitting <Up>: Remove one submenu name in front of the
+ // cursor
+ int found = false;
+
+ s->j = (int)(s->xpc.xp_pattern - ccline.cmdbuff);
+ s->i = 0;
+ while (--s->j > 0) {
+ // check for start of menu name
+ if (ccline.cmdbuff[s->j] == ' '
+ && ccline.cmdbuff[s->j - 1] != '\\') {
+ s->i = s->j + 1;
+ break;
+ }
+
+ // check for start of submenu name
+ if (ccline.cmdbuff[s->j] == '.'
+ && ccline.cmdbuff[s->j - 1] != '\\') {
+ if (found) {
+ s->i = s->j + 1;
break;
- }
- /* check for start of submenu name */
- if (ccline.cmdbuff[j] == '.'
- && ccline.cmdbuff[j - 1] != '\\') {
- if (found) {
- i = j + 1;
- break;
- } else
- found = TRUE;
+ } else {
+ found = true;
}
}
- if (i > 0)
- cmdline_del(i);
- c = p_wc;
- xpc.xp_context = EXPAND_NOTHING;
}
+ if (s->i > 0) {
+ cmdline_del(s->i);
+ }
+ s->c = p_wc;
+ s->xpc.xp_context = EXPAND_NOTHING;
}
- if ((xpc.xp_context == EXPAND_FILES
- || xpc.xp_context == EXPAND_DIRECTORIES
- || xpc.xp_context == EXPAND_SHELLCMD) && p_wmnu) {
- char_u upseg[5];
-
- upseg[0] = PATHSEP;
- upseg[1] = '.';
- upseg[2] = '.';
- upseg[3] = PATHSEP;
- upseg[4] = NUL;
-
- if (c == K_DOWN
- && ccline.cmdpos > 0
- && ccline.cmdbuff[ccline.cmdpos - 1] == PATHSEP
- && (ccline.cmdpos < 3
- || ccline.cmdbuff[ccline.cmdpos - 2] != '.'
- || ccline.cmdbuff[ccline.cmdpos - 3] != '.')) {
- /* go down a directory */
- c = p_wc;
- } else if (STRNCMP(xpc.xp_pattern, upseg + 1, 3) == 0 && c == K_DOWN) {
- /* If in a direct ancestor, strip off one ../ to go down */
- int found = FALSE;
-
- j = ccline.cmdpos;
- i = (int)(xpc.xp_pattern - ccline.cmdbuff);
- while (--j > i) {
- if (has_mbyte)
- j -= (*mb_head_off)(ccline.cmdbuff, ccline.cmdbuff + j);
- if (vim_ispathsep(ccline.cmdbuff[j])) {
- found = TRUE;
- break;
- }
+ }
+ if ((s->xpc.xp_context == EXPAND_FILES
+ || s->xpc.xp_context == EXPAND_DIRECTORIES
+ || s->xpc.xp_context == EXPAND_SHELLCMD) && p_wmnu) {
+ char_u upseg[5];
+
+ upseg[0] = PATHSEP;
+ upseg[1] = '.';
+ upseg[2] = '.';
+ upseg[3] = PATHSEP;
+ upseg[4] = NUL;
+
+ if (s->c == K_DOWN
+ && ccline.cmdpos > 0
+ && ccline.cmdbuff[ccline.cmdpos - 1] == PATHSEP
+ && (ccline.cmdpos < 3
+ || ccline.cmdbuff[ccline.cmdpos - 2] != '.'
+ || ccline.cmdbuff[ccline.cmdpos - 3] != '.')) {
+ // go down a directory
+ s->c = p_wc;
+ } else if (STRNCMP(s->xpc.xp_pattern, upseg + 1, 3) == 0
+ && s->c == K_DOWN) {
+ // If in a direct ancestor, strip off one ../ to go down
+ int found = false;
+
+ s->j = ccline.cmdpos;
+ s->i = (int)(s->xpc.xp_pattern - ccline.cmdbuff);
+ while (--s->j > s->i) {
+ if (has_mbyte) {
+ s->j -= (*mb_head_off)(ccline.cmdbuff, ccline.cmdbuff + s->j);
}
- if (found
- && ccline.cmdbuff[j - 1] == '.'
- && ccline.cmdbuff[j - 2] == '.'
- && (vim_ispathsep(ccline.cmdbuff[j - 3]) || j == i + 2)) {
- cmdline_del(j - 2);
- c = p_wc;
+ if (vim_ispathsep(ccline.cmdbuff[s->j])) {
+ found = true;
+ break;
+ }
+ }
+ if (found
+ && ccline.cmdbuff[s->j - 1] == '.'
+ && ccline.cmdbuff[s->j - 2] == '.'
+ && (vim_ispathsep(ccline.cmdbuff[s->j - 3]) || s->j == s->i + 2)) {
+ cmdline_del(s->j - 2);
+ s->c = p_wc;
+ }
+ } else if (s->c == K_UP) {
+ // go up a directory
+ int found = false;
+
+ s->j = ccline.cmdpos - 1;
+ s->i = (int)(s->xpc.xp_pattern - ccline.cmdbuff);
+ while (--s->j > s->i) {
+ if (has_mbyte) {
+ s->j -= (*mb_head_off)(ccline.cmdbuff, ccline.cmdbuff + s->j);
}
- } else if (c == K_UP) {
- /* go up a directory */
- int found = FALSE;
-
- j = ccline.cmdpos - 1;
- i = (int)(xpc.xp_pattern - ccline.cmdbuff);
- while (--j > i) {
- if (has_mbyte)
- j -= (*mb_head_off)(ccline.cmdbuff, ccline.cmdbuff + j);
- if (vim_ispathsep(ccline.cmdbuff[j])
+ if (vim_ispathsep(ccline.cmdbuff[s->j])
#ifdef BACKSLASH_IN_FILENAME
- && vim_strchr(" *?[{`$%#", ccline.cmdbuff[j + 1])
- == NULL
+ && vim_strchr(" *?[{`$%#", ccline.cmdbuff[s->j + 1])
+ == NULL
#endif
- ) {
- if (found) {
- i = j + 1;
- break;
- } else
- found = TRUE;
+ ) {
+ if (found) {
+ s->i = s->j + 1;
+ break;
+ } else {
+ found = true;
}
}
+ }
- if (!found)
- j = i;
- else if (STRNCMP(ccline.cmdbuff + j, upseg, 4) == 0)
- j += 4;
- else if (STRNCMP(ccline.cmdbuff + j, upseg + 1, 3) == 0
- && j == i)
- j += 3;
- else
- j = 0;
- if (j > 0) {
- /* TODO this is only for DOS/UNIX systems - need to put in
- * machine-specific stuff here and in upseg init */
- cmdline_del(j);
- put_on_cmdline(upseg + 1, 3, FALSE);
- } else if (ccline.cmdpos > i)
- cmdline_del(i);
-
- /* Now complete in the new directory. Set KeyTyped in case the
- * Up key came from a mapping. */
- c = p_wc;
- KeyTyped = TRUE;
+ if (!found) {
+ s->j = s->i;
+ } else if (STRNCMP(ccline.cmdbuff + s->j, upseg, 4) == 0) {
+ s->j += 4;
+ } else if (STRNCMP(ccline.cmdbuff + s->j, upseg + 1, 3) == 0
+ && s->j == s->i) {
+ s->j += 3;
+ } else {
+ s->j = 0;
+ }
+
+ if (s->j > 0) {
+ // TODO(tarruda): this is only for DOS/UNIX systems - need to put in
+ // machine-specific stuff here and in upseg init
+ cmdline_del(s->j);
+ put_on_cmdline(upseg + 1, 3, false);
+ } else if (ccline.cmdpos > s->i) {
+ cmdline_del(s->i);
}
+
+ // Now complete in the new directory. Set KeyTyped in case the
+ // Up key came from a mapping.
+ s->c = p_wc;
+ KeyTyped = true;
}
+ }
+ // CTRL-\ CTRL-N goes to Normal mode, CTRL-\ CTRL-G goes to Insert
+ // mode when 'insertmode' is set, CTRL-\ e prompts for an expression.
+ if (s->c == Ctrl_BSL) {
+ ++no_mapping;
+ ++allow_keys;
+ s->c = plain_vgetc();
+ --no_mapping;
+ --allow_keys;
+ // CTRL-\ e doesn't work when obtaining an expression, unless it
+ // is in a mapping.
+ if (s->c != Ctrl_N && s->c != Ctrl_G && (s->c != 'e'
+ || (ccline.cmdfirstc == '=' &&
+ KeyTyped))) {
+ vungetc(s->c);
+ s->c = Ctrl_BSL;
+ } else if (s->c == 'e') {
+ char_u *p = NULL;
+ int len;
- /* CTRL-\ CTRL-N goes to Normal mode, CTRL-\ CTRL-G goes to Insert
- * mode when 'insertmode' is set, CTRL-\ e prompts for an expression. */
- if (c == Ctrl_BSL) {
- ++no_mapping;
- ++allow_keys;
- c = plain_vgetc();
- --no_mapping;
- --allow_keys;
- /* CTRL-\ e doesn't work when obtaining an expression, unless it
- * is in a mapping. */
- if (c != Ctrl_N && c != Ctrl_G && (c != 'e'
- || (ccline.cmdfirstc == '=' &&
- KeyTyped))) {
- vungetc(c);
- c = Ctrl_BSL;
- } else if (c == 'e') {
- char_u *p = NULL;
- int len;
-
- /*
- * Replace the command line with the result of an expression.
- * Need to save and restore the current command line, to be
- * able to enter a new one...
- */
- if (ccline.cmdpos == ccline.cmdlen)
- new_cmdpos = 99999; /* keep it at the end */
- else
- new_cmdpos = ccline.cmdpos;
-
- save_cmdline(&save_ccline);
- c = get_expr_register();
- restore_cmdline(&save_ccline);
- if (c == '=') {
- /* Need to save and restore ccline. And set "textlock"
- * to avoid nasty things like going to another buffer when
- * evaluating an expression. */
- save_cmdline(&save_ccline);
- ++textlock;
- p = get_expr_line();
- --textlock;
- restore_cmdline(&save_ccline);
-
- if (p != NULL) {
- len = (int)STRLEN(p);
- realloc_cmdbuff(len + 1);
- ccline.cmdlen = len;
- STRCPY(ccline.cmdbuff, p);
- xfree(p);
-
- /* Restore the cursor or use the position set with
- * set_cmdline_pos(). */
- if (new_cmdpos > ccline.cmdlen)
- ccline.cmdpos = ccline.cmdlen;
- else
- ccline.cmdpos = new_cmdpos;
-
- KeyTyped = FALSE; /* Don't do p_wc completion. */
- redrawcmd();
- goto cmdline_changed;
+ // Replace the command line with the result of an expression.
+ // Need to save and restore the current command line, to be
+ // able to enter a new one...
+ if (ccline.cmdpos == ccline.cmdlen) {
+ new_cmdpos = 99999; // keep it at the end
+ } else {
+ new_cmdpos = ccline.cmdpos;
+ }
+
+ save_cmdline(&s->save_ccline);
+ s->c = get_expr_register();
+ restore_cmdline(&s->save_ccline);
+ if (s->c == '=') {
+ // Need to save and restore ccline. And set "textlock"
+ // to avoid nasty things like going to another buffer when
+ // evaluating an expression.
+ save_cmdline(&s->save_ccline);
+ ++textlock;
+ p = get_expr_line();
+ --textlock;
+ restore_cmdline(&s->save_ccline);
+
+ if (p != NULL) {
+ len = (int)STRLEN(p);
+ realloc_cmdbuff(len + 1);
+ ccline.cmdlen = len;
+ STRCPY(ccline.cmdbuff, p);
+ xfree(p);
+
+ // Restore the cursor or use the position set with
+ // set_cmdline_pos().
+ if (new_cmdpos > ccline.cmdlen) {
+ ccline.cmdpos = ccline.cmdlen;
+ } else {
+ ccline.cmdpos = new_cmdpos;
}
+
+ KeyTyped = false; // Don't do p_wc completion.
+ redrawcmd();
+ return command_line_changed(s);
}
- beep_flush();
- got_int = FALSE; /* don't abandon the command line */
- did_emsg = FALSE;
- emsg_on_display = FALSE;
- redrawcmd();
- goto cmdline_not_changed;
- } else {
- if (c == Ctrl_G && p_im && restart_edit == 0)
- restart_edit = 'a';
- gotesc = TRUE; /* will free ccline.cmdbuff after putting it
- in history */
- goto returncmd; /* back to Normal mode */
}
+ beep_flush();
+ got_int = false; // don't abandon the command line
+ did_emsg = false;
+ emsg_on_display = false;
+ redrawcmd();
+ return command_line_not_changed(s);
+ } else {
+ if (s->c == Ctrl_G && p_im && restart_edit == 0) {
+ restart_edit = 'a';
+ }
+ s->gotesc = true; // will free ccline.cmdbuff after putting it
+ // in history
+ return 0; // back to Normal mode
}
+ }
- if (c == cedit_key || c == K_CMDWIN) {
- if (ex_normal_busy == 0 && got_int == FALSE) {
- /*
- * Open a window to edit the command line (and history).
- */
- c = ex_window();
- some_key_typed = TRUE;
+ if (s->c == cedit_key || s->c == K_CMDWIN) {
+ if (ex_normal_busy == 0 && got_int == false) {
+ // Open a window to edit the command line (and history).
+ s->c = ex_window();
+ s->some_key_typed = true;
+ }
+ } else {
+ s->c = do_digraph(s->c);
+ }
+
+ if (s->c == '\n'
+ || s->c == '\r'
+ || s->c == K_KENTER
+ || (s->c == ESC
+ && (!KeyTyped || vim_strchr(p_cpo, CPO_ESC) != NULL))) {
+ // In Ex mode a backslash escapes a newline.
+ if (exmode_active
+ && s->c != ESC
+ && ccline.cmdpos == ccline.cmdlen
+ && ccline.cmdpos > 0
+ && ccline.cmdbuff[ccline.cmdpos - 1] == '\\') {
+ if (s->c == K_KENTER) {
+ s->c = '\n';
}
- } else
- c = do_digraph(c);
-
- if (c == '\n' || c == '\r' || c == K_KENTER || (c == ESC
- && (!KeyTyped ||
- vim_strchr(p_cpo,
- CPO_ESC) !=
- NULL))) {
- /* In Ex mode a backslash escapes a newline. */
- if (exmode_active
- && c != ESC
- && ccline.cmdpos == ccline.cmdlen
- && ccline.cmdpos > 0
- && ccline.cmdbuff[ccline.cmdpos - 1] == '\\') {
- if (c == K_KENTER)
- c = '\n';
- } else {
- gotesc = FALSE; /* Might have typed ESC previously, don't
- truncate the cmdline now. */
- if (ccheck_abbr(c + ABBR_OFF))
- goto cmdline_changed;
- if (!cmd_silent) {
- ui_cursor_goto(msg_row, 0);
- ui_flush();
- }
- break;
+ } else {
+ s->gotesc = false; // Might have typed ESC previously, don't
+ // truncate the cmdline now.
+ if (ccheck_abbr(s->c + ABBR_OFF)) {
+ return command_line_changed(s);
+ }
+
+ if (!cmd_silent) {
+ ui_cursor_goto(msg_row, 0);
+ ui_flush();
}
+ return 0;
}
+ }
- /*
- * Completion for 'wildchar' or 'wildcharm' key.
- * - hitting <ESC> twice means: abandon command line.
- * - wildcard expansion is only done when the 'wildchar' key is really
- * typed, not when it comes from a macro
- */
- if ((c == p_wc && !gotesc && KeyTyped) || c == p_wcm) {
- if (xpc.xp_numfiles > 0) { /* typed p_wc at least twice */
- /* if 'wildmode' contains "list" may still need to list */
- if (xpc.xp_numfiles > 1
- && !did_wild_list
- && (wim_flags[wim_index] & WIM_LIST)) {
- (void)showmatches(&xpc, FALSE);
- redrawcmd();
- did_wild_list = TRUE;
- }
- if (wim_flags[wim_index] & WIM_LONGEST)
- res = nextwild(&xpc, WILD_LONGEST, WILD_NO_BEEP,
- firstc != '@');
- else if (wim_flags[wim_index] & WIM_FULL)
- res = nextwild(&xpc, WILD_NEXT, WILD_NO_BEEP,
- firstc != '@');
- else
- res = OK; /* don't insert 'wildchar' now */
- } else { /* typed p_wc first time */
- wim_index = 0;
- j = ccline.cmdpos;
- /* if 'wildmode' first contains "longest", get longest
- * common part */
- if (wim_flags[0] & WIM_LONGEST)
- res = nextwild(&xpc, WILD_LONGEST, WILD_NO_BEEP,
- firstc != '@');
- else
- res = nextwild(&xpc, WILD_EXPAND_KEEP, WILD_NO_BEEP,
- firstc != '@');
-
- /* if interrupted while completing, behave like it failed */
- if (got_int) {
- (void)vpeekc(); /* remove <C-C> from input stream */
- got_int = FALSE; /* don't abandon the command line */
- (void)ExpandOne(&xpc, NULL, NULL, 0, WILD_FREE);
- xpc.xp_context = EXPAND_NOTHING;
- goto cmdline_changed;
+ // Completion for 'wildchar' or 'wildcharm' key.
+ // - hitting <ESC> twice means: abandon command line.
+ // - wildcard expansion is only done when the 'wildchar' key is really
+ // typed, not when it comes from a macro
+ if ((s->c == p_wc && !s->gotesc && KeyTyped) || s->c == p_wcm) {
+ if (s->xpc.xp_numfiles > 0) { // typed p_wc at least twice
+ // if 'wildmode' contains "list" may still need to list
+ if (s->xpc.xp_numfiles > 1
+ && !s->did_wild_list
+ && (wim_flags[s->wim_index] & WIM_LIST)) {
+ (void)showmatches(&s->xpc, false);
+ redrawcmd();
+ s->did_wild_list = true;
+ }
+
+ if (wim_flags[s->wim_index] & WIM_LONGEST) {
+ s->res = nextwild(&s->xpc, WILD_LONGEST, WILD_NO_BEEP,
+ s->firstc != '@');
+ } else if (wim_flags[s->wim_index] & WIM_FULL) {
+ s->res = nextwild(&s->xpc, WILD_NEXT, WILD_NO_BEEP,
+ s->firstc != '@');
+ } else {
+ s->res = OK; // don't insert 'wildchar' now
+ }
+ } else { // typed p_wc first time
+ s->wim_index = 0;
+ s->j = ccline.cmdpos;
+
+ // if 'wildmode' first contains "longest", get longest
+ // common part
+ if (wim_flags[0] & WIM_LONGEST) {
+ s->res = nextwild(&s->xpc, WILD_LONGEST, WILD_NO_BEEP,
+ s->firstc != '@');
+ } else {
+ s->res = nextwild(&s->xpc, WILD_EXPAND_KEEP, WILD_NO_BEEP,
+ s->firstc != '@');
+ }
+
+ // if interrupted while completing, behave like it failed
+ if (got_int) {
+ (void)vpeekc(); // remove <C-C> from input stream
+ got_int = false; // don't abandon the command line
+ (void)ExpandOne(&s->xpc, NULL, NULL, 0, WILD_FREE);
+ s->xpc.xp_context = EXPAND_NOTHING;
+ return command_line_changed(s);
+ }
+
+ // when more than one match, and 'wildmode' first contains
+ // "list", or no change and 'wildmode' contains "longest,list",
+ // list all matches
+ if (s->res == OK && s->xpc.xp_numfiles > 1) {
+ // a "longest" that didn't do anything is skipped (but not
+ // "list:longest")
+ if (wim_flags[0] == WIM_LONGEST && ccline.cmdpos == s->j) {
+ s->wim_index = 1;
}
+ if ((wim_flags[s->wim_index] & WIM_LIST)
+ || (p_wmnu && (wim_flags[s->wim_index] & WIM_FULL) != 0)) {
+ if (!(wim_flags[0] & WIM_LONGEST)) {
+ int p_wmnu_save = p_wmnu;
+ p_wmnu = 0;
+ // remove match
+ nextwild(&s->xpc, WILD_PREV, 0, s->firstc != '@');
+ p_wmnu = p_wmnu_save;
+ }
- /* when more than one match, and 'wildmode' first contains
- * "list", or no change and 'wildmode' contains "longest,list",
- * list all matches */
- if (res == OK && xpc.xp_numfiles > 1) {
- /* a "longest" that didn't do anything is skipped (but not
- * "list:longest") */
- if (wim_flags[0] == WIM_LONGEST && ccline.cmdpos == j)
- wim_index = 1;
- if ((wim_flags[wim_index] & WIM_LIST)
- || (p_wmnu && (wim_flags[wim_index] & WIM_FULL) != 0)
- ) {
- if (!(wim_flags[0] & WIM_LONGEST)) {
- int p_wmnu_save = p_wmnu;
- p_wmnu = 0;
- /* remove match */
- nextwild(&xpc, WILD_PREV, 0, firstc != '@');
- p_wmnu = p_wmnu_save;
- }
- (void)showmatches(&xpc, p_wmnu
- && ((wim_flags[wim_index] & WIM_LIST) == 0));
- redrawcmd();
- did_wild_list = TRUE;
- if (wim_flags[wim_index] & WIM_LONGEST)
- nextwild(&xpc, WILD_LONGEST, WILD_NO_BEEP,
- firstc != '@');
- else if (wim_flags[wim_index] & WIM_FULL)
- nextwild(&xpc, WILD_NEXT, WILD_NO_BEEP,
- firstc != '@');
- } else {
- vim_beep(BO_WILD);
+ (void)showmatches(&s->xpc, p_wmnu
+ && ((wim_flags[s->wim_index] & WIM_LIST) == 0));
+ redrawcmd();
+ s->did_wild_list = true;
+
+ if (wim_flags[s->wim_index] & WIM_LONGEST) {
+ nextwild(&s->xpc, WILD_LONGEST, WILD_NO_BEEP,
+ s->firstc != '@');
+ } else if (wim_flags[s->wim_index] & WIM_FULL) {
+ nextwild(&s->xpc, WILD_NEXT, WILD_NO_BEEP,
+ s->firstc != '@');
}
- } else if (xpc.xp_numfiles == -1) {
- xpc.xp_context = EXPAND_NOTHING;
+ } else {
+ vim_beep(BO_WILD);
}
+ } else if (s->xpc.xp_numfiles == -1) {
+ s->xpc.xp_context = EXPAND_NOTHING;
}
- if (wim_index < 3)
- ++wim_index;
- if (c == ESC)
- gotesc = TRUE;
- if (res == OK)
- goto cmdline_changed;
}
- gotesc = FALSE;
+ if (s->wim_index < 3) {
+ ++s->wim_index;
+ }
- /* <S-Tab> goes to last match, in a clumsy way */
- if (c == K_S_TAB && KeyTyped) {
- if (nextwild(&xpc, WILD_EXPAND_KEEP, 0, firstc != '@') == OK
- && nextwild(&xpc, WILD_PREV, 0, firstc != '@') == OK
- && nextwild(&xpc, WILD_PREV, 0, firstc != '@') == OK)
- goto cmdline_changed;
+ if (s->c == ESC) {
+ s->gotesc = true;
}
- if (c == NUL || c == K_ZERO) /* NUL is stored as NL */
- c = NL;
+ if (s->res == OK) {
+ return command_line_changed(s);
+ }
+ }
- do_abbr = TRUE; /* default: check for abbreviation */
+ s->gotesc = false;
- /*
- * Big switch for a typed command line character.
- */
- switch (c) {
- case K_BS:
- case Ctrl_H:
- case K_DEL:
- case K_KDEL:
- case Ctrl_W:
- if (cmd_fkmap && c == K_BS)
- c = K_DEL;
- if (c == K_KDEL)
- c = K_DEL;
+ // <S-Tab> goes to last match, in a clumsy way
+ if (s->c == K_S_TAB && KeyTyped) {
+ if (nextwild(&s->xpc, WILD_EXPAND_KEEP, 0, s->firstc != '@') == OK
+ && nextwild(&s->xpc, WILD_PREV, 0, s->firstc != '@') == OK
+ && nextwild(&s->xpc, WILD_PREV, 0, s->firstc != '@') == OK) {
+ return command_line_changed(s);
+ }
+ }
- /*
- * delete current character is the same as backspace on next
- * character, except at end of line
- */
- if (c == K_DEL && ccline.cmdpos != ccline.cmdlen)
- ++ccline.cmdpos;
- if (has_mbyte && c == K_DEL)
- ccline.cmdpos += mb_off_next(ccline.cmdbuff,
- ccline.cmdbuff + ccline.cmdpos);
- if (ccline.cmdpos > 0) {
- char_u *p;
-
- j = ccline.cmdpos;
- p = ccline.cmdbuff + j;
- if (has_mbyte) {
- p = mb_prevptr(ccline.cmdbuff, p);
- if (c == Ctrl_W) {
- while (p > ccline.cmdbuff && ascii_isspace(*p))
- p = mb_prevptr(ccline.cmdbuff, p);
- i = mb_get_class(p);
- while (p > ccline.cmdbuff && mb_get_class(p) == i)
- p = mb_prevptr(ccline.cmdbuff, p);
- if (mb_get_class(p) != i)
- p += (*mb_ptr2len)(p);
+ if (s->c == NUL || s->c == K_ZERO) {
+ // NUL is stored as NL
+ s->c = NL;
+ }
+
+ s->do_abbr = true; // default: check for abbreviation
+ return command_line_handle_key(s);
+}
+
+static int command_line_handle_key(CommandLineState *s)
+{
+ // Big switch for a typed command line character.
+ switch (s->c) {
+ case K_BS:
+ case Ctrl_H:
+ case K_DEL:
+ case K_KDEL:
+ case Ctrl_W:
+ if (cmd_fkmap && s->c == K_BS) {
+ s->c = K_DEL;
+ }
+
+ if (s->c == K_KDEL) {
+ s->c = K_DEL;
+ }
+
+ // delete current character is the same as backspace on next
+ // character, except at end of line
+ if (s->c == K_DEL && ccline.cmdpos != ccline.cmdlen) {
+ ++ccline.cmdpos;
+ }
+
+ if (has_mbyte && s->c == K_DEL) {
+ ccline.cmdpos += mb_off_next(ccline.cmdbuff,
+ ccline.cmdbuff + ccline.cmdpos);
+ }
+
+ if (ccline.cmdpos > 0) {
+ char_u *p;
+
+ s->j = ccline.cmdpos;
+ p = ccline.cmdbuff + s->j;
+ if (has_mbyte) {
+ p = mb_prevptr(ccline.cmdbuff, p);
+
+ if (s->c == Ctrl_W) {
+ while (p > ccline.cmdbuff && ascii_isspace(*p)) {
+ p = mb_prevptr(ccline.cmdbuff, p);
}
- } else if (c == Ctrl_W) {
- while (p > ccline.cmdbuff && ascii_isspace(p[-1]))
- --p;
- i = vim_iswordc(p[-1]);
- while (p > ccline.cmdbuff && !ascii_isspace(p[-1])
- && vim_iswordc(p[-1]) == i)
- --p;
- } else
+
+ s->i = mb_get_class(p);
+ while (p > ccline.cmdbuff && mb_get_class(p) == s->i)
+ p = mb_prevptr(ccline.cmdbuff, p);
+
+ if (mb_get_class(p) != s->i) {
+ p += (*mb_ptr2len)(p);
+ }
+ }
+ } else if (s->c == Ctrl_W) {
+ while (p > ccline.cmdbuff && ascii_isspace(p[-1])) {
--p;
- ccline.cmdpos = (int)(p - ccline.cmdbuff);
- ccline.cmdlen -= j - ccline.cmdpos;
- i = ccline.cmdpos;
- while (i < ccline.cmdlen)
- ccline.cmdbuff[i++] = ccline.cmdbuff[j++];
-
- /* Truncate at the end, required for multi-byte chars. */
- ccline.cmdbuff[ccline.cmdlen] = NUL;
- redrawcmd();
- } else if (ccline.cmdlen == 0 && c != Ctrl_W
- && ccline.cmdprompt == NULL && indent == 0) {
- /* In ex and debug mode it doesn't make sense to return. */
- if (exmode_active
- || ccline.cmdfirstc == '>'
- )
- goto cmdline_not_changed;
-
- xfree(ccline.cmdbuff); /* no commandline to return */
- ccline.cmdbuff = NULL;
- if (!cmd_silent) {
- if (cmdmsg_rl)
- msg_col = Columns;
- else
- msg_col = 0;
- msg_putchar(' '); /* delete ':' */
}
- redraw_cmdline = TRUE;
- goto returncmd; /* back to cmd mode */
- }
- goto cmdline_changed;
- case K_INS:
- case K_KINS:
- /* if Farsi mode set, we are in reverse insert mode -
- Do not change the mode */
- if (cmd_fkmap)
- beep_flush();
- else
- ccline.overstrike = !ccline.overstrike;
-
- ui_cursor_shape(); /* may show different cursor shape */
- goto cmdline_not_changed;
-
- case Ctrl_HAT:
- if (map_to_exists_mode((char_u *)"", LANGMAP, FALSE)) {
- /* ":lmap" mappings exists, toggle use of mappings. */
- State ^= LANGMAP;
- if (b_im_ptr != NULL) {
- if (State & LANGMAP)
- *b_im_ptr = B_IMODE_LMAP;
- else
- *b_im_ptr = B_IMODE_NONE;
- }
+ s->i = vim_iswordc(p[-1]);
+ while (p > ccline.cmdbuff && !ascii_isspace(p[-1])
+ && vim_iswordc(p[-1]) == s->i)
+ --p;
+ } else {
+ --p;
}
- if (b_im_ptr != NULL) {
- if (b_im_ptr == &curbuf->b_p_iminsert)
- set_iminsert_global();
- else
- set_imsearch_global();
+
+ ccline.cmdpos = (int)(p - ccline.cmdbuff);
+ ccline.cmdlen -= s->j - ccline.cmdpos;
+ s->i = ccline.cmdpos;
+
+ while (s->i < ccline.cmdlen) {
+ ccline.cmdbuff[s->i++] = ccline.cmdbuff[s->j++];
}
- ui_cursor_shape(); /* may show different cursor shape */
- /* Show/unshow value of 'keymap' in status lines later. */
- status_redraw_curbuf();
- goto cmdline_not_changed;
-
- /* case '@': only in very old vi */
- case Ctrl_U:
- /* delete all characters left of the cursor */
- j = ccline.cmdpos;
- ccline.cmdlen -= j;
- i = ccline.cmdpos = 0;
- while (i < ccline.cmdlen)
- ccline.cmdbuff[i++] = ccline.cmdbuff[j++];
- /* Truncate at the end, required for multi-byte chars. */
+
+ // Truncate at the end, required for multi-byte chars.
ccline.cmdbuff[ccline.cmdlen] = NUL;
redrawcmd();
- goto cmdline_changed;
-
-
- case ESC: /* get here if p_wc != ESC or when ESC typed twice */
- case Ctrl_C:
- /* In exmode it doesn't make sense to return. Except when
- * ":normal" runs out of characters. */
- if (exmode_active
- && (ex_normal_busy == 0 || typebuf.tb_len > 0)
- )
- goto cmdline_not_changed;
-
- gotesc = TRUE; /* will free ccline.cmdbuff after
- putting it in history */
- goto returncmd; /* back to cmd mode */
-
- case Ctrl_R: /* insert register */
- putcmdline('"', TRUE);
- ++no_mapping;
- i = c = plain_vgetc(); /* CTRL-R <char> */
- if (i == Ctrl_O)
- i = Ctrl_R; /* CTRL-R CTRL-O == CTRL-R CTRL-R */
- if (i == Ctrl_R)
- c = plain_vgetc(); /* CTRL-R CTRL-R <char> */
- --no_mapping;
- /*
- * Insert the result of an expression.
- * Need to save the current command line, to be able to enter
- * a new one...
- */
- new_cmdpos = -1;
- if (c == '=') {
- if (ccline.cmdfirstc == '=') { /* can't do this recursively */
- beep_flush();
- c = ESC;
+ } else if (ccline.cmdlen == 0 && s->c != Ctrl_W
+ && ccline.cmdprompt == NULL && s->indent == 0) {
+ // In ex and debug mode it doesn't make sense to return.
+ if (exmode_active || ccline.cmdfirstc == '>') {
+ return command_line_not_changed(s);
+ }
+
+ xfree(ccline.cmdbuff); // no commandline to return
+ ccline.cmdbuff = NULL;
+ if (!cmd_silent) {
+ if (cmdmsg_rl) {
+ msg_col = Columns;
} else {
- save_cmdline(&save_ccline);
- c = get_expr_register();
- restore_cmdline(&save_ccline);
+ msg_col = 0;
}
+ msg_putchar(' '); // delete ':'
}
- if (c != ESC) { /* use ESC to cancel inserting register */
- cmdline_paste(c, i == Ctrl_R, FALSE);
-
- /* When there was a serious error abort getting the
- * command line. */
- if (aborting()) {
- gotesc = TRUE; /* will free ccline.cmdbuff after
- putting it in history */
- goto returncmd; /* back to cmd mode */
- }
- KeyTyped = FALSE; /* Don't do p_wc completion. */
- if (new_cmdpos >= 0) {
- /* set_cmdline_pos() was used */
- if (new_cmdpos > ccline.cmdlen)
- ccline.cmdpos = ccline.cmdlen;
- else
- ccline.cmdpos = new_cmdpos;
+ redraw_cmdline = true;
+ return 0; // back to cmd mode
+ }
+ return command_line_changed(s);
+
+ case K_INS:
+ case K_KINS:
+ // if Farsi mode set, we are in reverse insert mode -
+ // Do not change the mode
+ if (cmd_fkmap) {
+ beep_flush();
+ } else {
+ ccline.overstrike = !ccline.overstrike;
+ }
+
+ ui_cursor_shape(); // may show different cursor shape
+ return command_line_not_changed(s);
+
+ case Ctrl_HAT:
+ if (map_to_exists_mode((char_u *)"", LANGMAP, false)) {
+ // ":lmap" mappings exists, toggle use of mappings.
+ State ^= LANGMAP;
+ if (s->b_im_ptr != NULL) {
+ if (State & LANGMAP) {
+ *s->b_im_ptr = B_IMODE_LMAP;
+ } else {
+ *s->b_im_ptr = B_IMODE_NONE;
}
}
- redrawcmd();
- goto cmdline_changed;
+ }
- case Ctrl_D:
- if (showmatches(&xpc, FALSE) == EXPAND_NOTHING)
- break; /* Use ^D as normal char instead */
+ if (s->b_im_ptr != NULL) {
+ if (s->b_im_ptr == &curbuf->b_p_iminsert) {
+ set_iminsert_global();
+ } else {
+ set_imsearch_global();
+ }
+ }
+ ui_cursor_shape(); // may show different cursor shape
+ // Show/unshow value of 'keymap' in status lines later.
+ status_redraw_curbuf();
+ return command_line_not_changed(s);
+
+ // case '@': only in very old vi
+ case Ctrl_U:
+ // delete all characters left of the cursor
+ s->j = ccline.cmdpos;
+ ccline.cmdlen -= s->j;
+ s->i = ccline.cmdpos = 0;
+ while (s->i < ccline.cmdlen) {
+ ccline.cmdbuff[s->i++] = ccline.cmdbuff[s->j++];
+ }
- redrawcmd();
- continue; /* don't do incremental search now */
+ // Truncate at the end, required for multi-byte chars.
+ ccline.cmdbuff[ccline.cmdlen] = NUL;
+ redrawcmd();
+ return command_line_changed(s);
- case K_RIGHT:
- case K_S_RIGHT:
- case K_C_RIGHT:
- do {
- if (ccline.cmdpos >= ccline.cmdlen)
- break;
- i = cmdline_charsize(ccline.cmdpos);
- if (KeyTyped && ccline.cmdspos + i >= Columns * Rows)
- break;
- ccline.cmdspos += i;
- if (has_mbyte)
- ccline.cmdpos += (*mb_ptr2len)(ccline.cmdbuff
- + ccline.cmdpos);
- else
- ++ccline.cmdpos;
- } while ((c == K_S_RIGHT || c == K_C_RIGHT
- || (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL)))
- && ccline.cmdbuff[ccline.cmdpos] != ' ');
- if (has_mbyte)
- set_cmdspos_cursor();
- goto cmdline_not_changed;
- case K_LEFT:
- case K_S_LEFT:
- case K_C_LEFT:
- if (ccline.cmdpos == 0)
- goto cmdline_not_changed;
- do {
- --ccline.cmdpos;
- if (has_mbyte) /* move to first byte of char */
- ccline.cmdpos -= (*mb_head_off)(ccline.cmdbuff,
- ccline.cmdbuff + ccline.cmdpos);
- ccline.cmdspos -= cmdline_charsize(ccline.cmdpos);
- } while (ccline.cmdpos > 0
- && (c == K_S_LEFT || c == K_C_LEFT
- || (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL)))
- && ccline.cmdbuff[ccline.cmdpos - 1] != ' ');
- if (has_mbyte)
- set_cmdspos_cursor();
- goto cmdline_not_changed;
+ case ESC: // get here if p_wc != ESC or when ESC typed twice
+ case Ctrl_C:
+ // In exmode it doesn't make sense to return. Except when
+ // ":normal" runs out of characters.
+ if (exmode_active && (ex_normal_busy == 0 || typebuf.tb_len > 0)) {
+ return command_line_not_changed(s);
+ }
- case K_IGNORE:
- /* Ignore mouse event or ex_window() result. */
- goto cmdline_not_changed;
+ s->gotesc = true; // will free ccline.cmdbuff after
+ // putting it in history
+ return 0; // back to cmd mode
+
+ case Ctrl_R: // insert register
+ putcmdline('"', true);
+ ++no_mapping;
+ s->i = s->c = plain_vgetc(); // CTRL-R <char>
+ if (s->i == Ctrl_O) {
+ s->i = Ctrl_R; // CTRL-R CTRL-O == CTRL-R CTRL-R
+ }
+ if (s->i == Ctrl_R) {
+ s->c = plain_vgetc(); // CTRL-R CTRL-R <char>
+ }
+ --no_mapping;
+ // Insert the result of an expression.
+ // Need to save the current command line, to be able to enter
+ // a new one...
+ new_cmdpos = -1;
+ if (s->c == '=') {
+ if (ccline.cmdfirstc == '=') { // can't do this recursively
+ beep_flush();
+ s->c = ESC;
+ } else {
+ save_cmdline(&s->save_ccline);
+ s->c = get_expr_register();
+ restore_cmdline(&s->save_ccline);
+ }
+ }
- case K_MIDDLEDRAG:
- case K_MIDDLERELEASE:
- goto cmdline_not_changed; /* Ignore mouse */
+ if (s->c != ESC) { // use ESC to cancel inserting register
+ cmdline_paste(s->c, s->i == Ctrl_R, false);
- case K_MIDDLEMOUSE:
- if (!mouse_has(MOUSE_COMMAND))
- goto cmdline_not_changed; /* Ignore mouse */
- cmdline_paste(0, TRUE, TRUE);
- redrawcmd();
- goto cmdline_changed;
-
-
- case K_LEFTDRAG:
- case K_LEFTRELEASE:
- case K_RIGHTDRAG:
- case K_RIGHTRELEASE:
- /* Ignore drag and release events when the button-down wasn't
- * seen before. */
- if (ignore_drag_release)
- goto cmdline_not_changed;
- /* FALLTHROUGH */
- case K_LEFTMOUSE:
- case K_RIGHTMOUSE:
- if (c == K_LEFTRELEASE || c == K_RIGHTRELEASE)
- ignore_drag_release = TRUE;
- else
- ignore_drag_release = FALSE;
- if (!mouse_has(MOUSE_COMMAND))
- goto cmdline_not_changed; /* Ignore mouse */
-
- set_cmdspos();
- for (ccline.cmdpos = 0; ccline.cmdpos < ccline.cmdlen;
- ++ccline.cmdpos) {
- i = cmdline_charsize(ccline.cmdpos);
- if (mouse_row <= cmdline_row + ccline.cmdspos / Columns
- && mouse_col < ccline.cmdspos % Columns + i)
- break;
- if (has_mbyte) {
- /* Count ">" for double-wide char that doesn't fit. */
- correct_cmdspos(ccline.cmdpos, i);
- ccline.cmdpos += (*mb_ptr2len)(ccline.cmdbuff
- + ccline.cmdpos) - 1;
+ // When there was a serious error abort getting the
+ // command line.
+ if (aborting()) {
+ s->gotesc = true; // will free ccline.cmdbuff after
+ // putting it in history
+ return 0; // back to cmd mode
+ }
+ KeyTyped = false; // Don't do p_wc completion.
+ if (new_cmdpos >= 0) {
+ // set_cmdline_pos() was used
+ if (new_cmdpos > ccline.cmdlen) {
+ ccline.cmdpos = ccline.cmdlen;
+ } else {
+ ccline.cmdpos = new_cmdpos;
}
- ccline.cmdspos += i;
}
- goto cmdline_not_changed;
-
- /* Mouse scroll wheel: ignored here */
- case K_MOUSEDOWN:
- case K_MOUSEUP:
- case K_MOUSELEFT:
- case K_MOUSERIGHT:
- /* Alternate buttons ignored here */
- case K_X1MOUSE:
- case K_X1DRAG:
- case K_X1RELEASE:
- case K_X2MOUSE:
- case K_X2DRAG:
- case K_X2RELEASE:
- goto cmdline_not_changed;
-
-
-
- case K_SELECT: /* end of Select mode mapping - ignore */
- goto cmdline_not_changed;
-
- case Ctrl_B: /* begin of command line */
- case K_HOME:
- case K_KHOME:
- case K_S_HOME:
- case K_C_HOME:
- ccline.cmdpos = 0;
- set_cmdspos();
- goto cmdline_not_changed;
-
- case Ctrl_E: /* end of command line */
- case K_END:
- case K_KEND:
- case K_S_END:
- case K_C_END:
- ccline.cmdpos = ccline.cmdlen;
- set_cmdspos_cursor();
- goto cmdline_not_changed;
+ }
+ redrawcmd();
+ return command_line_changed(s);
+
+ case Ctrl_D:
+ if (showmatches(&s->xpc, false) == EXPAND_NOTHING) {
+ break; // Use ^D as normal char instead
+ }
+
+ redrawcmd();
+ return 1; // don't do incremental search now
- case Ctrl_A: /* all matches */
- if (nextwild(&xpc, WILD_ALL, 0, firstc != '@') == FAIL)
+ case K_RIGHT:
+ case K_S_RIGHT:
+ case K_C_RIGHT:
+ do {
+ if (ccline.cmdpos >= ccline.cmdlen) {
break;
- goto cmdline_changed;
-
- case Ctrl_L:
- if (p_is && !cmd_silent && (firstc == '/' || firstc == '?')) {
- /* Add a character from under the cursor for 'incsearch' */
- if (did_incsearch
- && !equalpos(curwin->w_cursor, old_cursor)) {
- c = gchar_cursor();
- /* If 'ignorecase' and 'smartcase' are set and the
- * command line has no uppercase characters, convert
- * the character to lowercase */
- if (p_ic && p_scs && !pat_has_uppercase(ccline.cmdbuff))
- c = vim_tolower(c);
- if (c != NUL) {
- if (c == firstc || vim_strchr((char_u *)(
- p_magic ? "\\^$.*[" : "\\^$"), c)
- != NULL) {
- /* put a backslash before special characters */
- stuffcharReadbuff(c);
- c = '\\';
- }
- break;
- }
- }
- goto cmdline_not_changed;
}
- /* completion: longest common part */
- if (nextwild(&xpc, WILD_LONGEST, 0, firstc != '@') == FAIL)
+ s->i = cmdline_charsize(ccline.cmdpos);
+ if (KeyTyped && ccline.cmdspos + s->i >= Columns * Rows) {
break;
- goto cmdline_changed;
+ }
- case Ctrl_N: /* next match */
- case Ctrl_P: /* previous match */
- if (xpc.xp_numfiles > 0) {
- if (nextwild(&xpc, (c == Ctrl_P) ? WILD_PREV : WILD_NEXT,
- 0, firstc != '@') == FAIL)
- break;
- goto cmdline_changed;
+ ccline.cmdspos += s->i;
+ if (has_mbyte) {
+ ccline.cmdpos += (*mb_ptr2len)(ccline.cmdbuff
+ + ccline.cmdpos);
+ } else {
+ ++ccline.cmdpos;
}
+ } while ((s->c == K_S_RIGHT || s->c == K_C_RIGHT
+ || (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL)))
+ && ccline.cmdbuff[ccline.cmdpos] != ' ');
+ if (has_mbyte) {
+ set_cmdspos_cursor();
+ }
+ return command_line_not_changed(s);
- case K_UP:
- case K_DOWN:
- case K_S_UP:
- case K_S_DOWN:
- case K_PAGEUP:
- case K_KPAGEUP:
- case K_PAGEDOWN:
- case K_KPAGEDOWN:
- if (hislen == 0 || firstc == NUL) /* no history */
- goto cmdline_not_changed;
-
- i = hiscnt;
-
- /* save current command string so it can be restored later */
- if (lookfor == NULL) {
- lookfor = vim_strsave(ccline.cmdbuff);
- lookfor[ccline.cmdpos] = NUL;
+ case K_LEFT:
+ case K_S_LEFT:
+ case K_C_LEFT:
+ if (ccline.cmdpos == 0) {
+ return command_line_not_changed(s);
+ }
+ do {
+ --ccline.cmdpos;
+ if (has_mbyte) { // move to first byte of char
+ ccline.cmdpos -= (*mb_head_off)(ccline.cmdbuff,
+ ccline.cmdbuff + ccline.cmdpos);
}
+ ccline.cmdspos -= cmdline_charsize(ccline.cmdpos);
+ } while (ccline.cmdpos > 0
+ && (s->c == K_S_LEFT || s->c == K_C_LEFT
+ || (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL)))
+ && ccline.cmdbuff[ccline.cmdpos - 1] != ' ');
- j = (int)STRLEN(lookfor);
- for (;; ) {
- /* one step backwards */
- if (c == K_UP|| c == K_S_UP || c == Ctrl_P
- || c == K_PAGEUP || c == K_KPAGEUP) {
- if (hiscnt == hislen) /* first time */
- hiscnt = hisidx[histype];
- else if (hiscnt == 0 && hisidx[histype] != hislen - 1)
- hiscnt = hislen - 1;
- else if (hiscnt != hisidx[histype] + 1)
- --hiscnt;
- else { /* at top of list */
- hiscnt = i;
- break;
- }
- } else { /* one step forwards */
- /* on last entry, clear the line */
- if (hiscnt == hisidx[histype]) {
- hiscnt = hislen;
- break;
- }
+ if (has_mbyte) {
+ set_cmdspos_cursor();
+ }
- /* not on a history line, nothing to do */
- if (hiscnt == hislen)
- break;
- if (hiscnt == hislen - 1) /* wrap around */
- hiscnt = 0;
- else
- ++hiscnt;
+ return command_line_not_changed(s);
+
+ case K_IGNORE:
+ // Ignore mouse event or ex_window() result.
+ return command_line_not_changed(s);
+
+
+ case K_MIDDLEDRAG:
+ case K_MIDDLERELEASE:
+ return command_line_not_changed(s); // Ignore mouse
+
+ case K_MIDDLEMOUSE:
+ if (!mouse_has(MOUSE_COMMAND)) {
+ return command_line_not_changed(s); // Ignore mouse
+ }
+ cmdline_paste(0, true, true);
+ redrawcmd();
+ return command_line_changed(s);
+
+
+ case K_LEFTDRAG:
+ case K_LEFTRELEASE:
+ case K_RIGHTDRAG:
+ case K_RIGHTRELEASE:
+ // Ignore drag and release events when the button-down wasn't
+ // seen before.
+ if (s->ignore_drag_release) {
+ return command_line_not_changed(s);
+ }
+ // FALLTHROUGH
+ case K_LEFTMOUSE:
+ case K_RIGHTMOUSE:
+ if (s->c == K_LEFTRELEASE || s->c == K_RIGHTRELEASE) {
+ s->ignore_drag_release = true;
+ } else {
+ s->ignore_drag_release = false;
+ }
+
+ if (!mouse_has(MOUSE_COMMAND)) {
+ return command_line_not_changed(s); // Ignore mouse
+ }
+
+ set_cmdspos();
+ for (ccline.cmdpos = 0; ccline.cmdpos < ccline.cmdlen;
+ ++ccline.cmdpos) {
+ s->i = cmdline_charsize(ccline.cmdpos);
+ if (mouse_row <= cmdline_row + ccline.cmdspos / Columns
+ && mouse_col < ccline.cmdspos % Columns + s->i) {
+ break;
+ }
+
+ if (has_mbyte) {
+ // Count ">" for double-wide char that doesn't fit.
+ correct_cmdspos(ccline.cmdpos, s->i);
+ ccline.cmdpos += (*mb_ptr2len)(ccline.cmdbuff
+ + ccline.cmdpos) - 1;
+ }
+ ccline.cmdspos += s->i;
+ }
+ return command_line_not_changed(s);
+
+ // Mouse scroll wheel: ignored here
+ case K_MOUSEDOWN:
+ case K_MOUSEUP:
+ case K_MOUSELEFT:
+ case K_MOUSERIGHT:
+ // Alternate buttons ignored here
+ case K_X1MOUSE:
+ case K_X1DRAG:
+ case K_X1RELEASE:
+ case K_X2MOUSE:
+ case K_X2DRAG:
+ case K_X2RELEASE:
+ return command_line_not_changed(s);
+
+
+
+ case K_SELECT: // end of Select mode mapping - ignore
+ return command_line_not_changed(s);
+
+ case Ctrl_B: // begin of command line
+ case K_HOME:
+ case K_KHOME:
+ case K_S_HOME:
+ case K_C_HOME:
+ ccline.cmdpos = 0;
+ set_cmdspos();
+ return command_line_not_changed(s);
+
+ case Ctrl_E: // end of command line
+ case K_END:
+ case K_KEND:
+ case K_S_END:
+ case K_C_END:
+ ccline.cmdpos = ccline.cmdlen;
+ set_cmdspos_cursor();
+ return command_line_not_changed(s);
+
+ case Ctrl_A: // all matches
+ if (nextwild(&s->xpc, WILD_ALL, 0, s->firstc != '@') == FAIL)
+ break;
+ return command_line_changed(s);
+
+ case Ctrl_L:
+ if (p_is && !cmd_silent && (s->firstc == '/' || s->firstc == '?')) {
+ // Add a character from under the cursor for 'incsearch'
+ if (s->did_incsearch && !equalpos(curwin->w_cursor, s->old_cursor)) {
+ s->c = gchar_cursor();
+ // If 'ignorecase' and 'smartcase' are set and the
+ // command line has no uppercase characters, convert
+ // the character to lowercase
+ if (p_ic && p_scs && !pat_has_uppercase(ccline.cmdbuff)) {
+ s->c = vim_tolower(s->c);
}
- if (hiscnt < 0 || history[histype][hiscnt].hisstr == NULL) {
- hiscnt = i;
+
+ if (s->c != NUL) {
+ if (s->c == s->firstc
+ || vim_strchr((char_u *)(p_magic ? "\\^$.*[" : "\\^$"), s->c)
+ != NULL) {
+ // put a backslash before special characters
+ stuffcharReadbuff(s->c);
+ s->c = '\\';
+ }
break;
}
- if ((c != K_UP && c != K_DOWN)
- || hiscnt == i
- || STRNCMP(history[histype][hiscnt].hisstr,
- lookfor, (size_t)j) == 0)
- break;
}
+ return command_line_not_changed(s);
+ }
- if (hiscnt != i) { /* jumped to other entry */
- char_u *p;
- int len;
- int old_firstc;
+ // completion: longest common part
+ if (nextwild(&s->xpc, WILD_LONGEST, 0, s->firstc != '@') == FAIL) {
+ break;
+ }
+ return command_line_changed(s);
- xfree(ccline.cmdbuff);
- xpc.xp_context = EXPAND_NOTHING;
- if (hiscnt == hislen)
- p = lookfor; /* back to the old one */
- else
- p = history[histype][hiscnt].hisstr;
-
- if (histype == HIST_SEARCH
- && p != lookfor
- && (old_firstc = p[STRLEN(p) + 1]) != firstc) {
- /* Correct for the separator character used when
- * adding the history entry vs the one used now.
- * First loop: count length.
- * Second loop: copy the characters. */
- for (i = 0; i <= 1; ++i) {
- len = 0;
- for (j = 0; p[j] != NUL; ++j) {
- /* Replace old sep with new sep, unless it is
- * escaped. */
- if (p[j] == old_firstc
- && (j == 0 || p[j - 1] != '\\')) {
- if (i > 0)
- ccline.cmdbuff[len] = firstc;
- } else {
- /* Escape new sep, unless it is already
- * escaped. */
- if (p[j] == firstc
- && (j == 0 || p[j - 1] != '\\')) {
- if (i > 0)
- ccline.cmdbuff[len] = '\\';
- ++len;
- }
- if (i > 0)
- ccline.cmdbuff[len] = p[j];
- }
- ++len;
- }
- if (i == 0) {
- alloc_cmdbuff(len);
- }
- }
- ccline.cmdbuff[len] = NUL;
+ case Ctrl_N: // next match
+ case Ctrl_P: // previous match
+ if (s->xpc.xp_numfiles > 0) {
+ if (nextwild(&s->xpc, (s->c == Ctrl_P) ? WILD_PREV : WILD_NEXT,
+ 0, s->firstc != '@') == FAIL) {
+ break;
+ }
+ return command_line_changed(s);
+ }
+
+ case K_UP:
+ case K_DOWN:
+ case K_S_UP:
+ case K_S_DOWN:
+ case K_PAGEUP:
+ case K_KPAGEUP:
+ case K_PAGEDOWN:
+ case K_KPAGEDOWN:
+ if (hislen == 0 || s->firstc == NUL) {
+ // no history
+ return command_line_not_changed(s);
+ }
+
+ s->i = s->hiscnt;
+
+ // save current command string so it can be restored later
+ if (s->lookfor == NULL) {
+ s->lookfor = vim_strsave(ccline.cmdbuff);
+ s->lookfor[ccline.cmdpos] = NUL;
+ }
+
+ s->j = (int)STRLEN(s->lookfor);
+ for (;; ) {
+ // one step backwards
+ if (s->c == K_UP|| s->c == K_S_UP || s->c == Ctrl_P
+ || s->c == K_PAGEUP || s->c == K_KPAGEUP) {
+ if (s->hiscnt == hislen) {
+ // first time
+ s->hiscnt = hisidx[s->histype];
+ } else if (s->hiscnt == 0 && hisidx[s->histype] != hislen - 1) {
+ s->hiscnt = hislen - 1;
+ } else if (s->hiscnt != hisidx[s->histype] + 1) {
+ --s->hiscnt;
} else {
- alloc_cmdbuff((int)STRLEN(p));
- STRCPY(ccline.cmdbuff, p);
+ // at top of list
+ s->hiscnt = s->i;
+ break;
+ }
+ } else { // one step forwards
+ // on last entry, clear the line
+ if (s->hiscnt == hisidx[s->histype]) {
+ s->hiscnt = hislen;
+ break;
}
- ccline.cmdpos = ccline.cmdlen = (int)STRLEN(ccline.cmdbuff);
- redrawcmd();
- goto cmdline_changed;
- }
- beep_flush();
- goto cmdline_not_changed;
-
- case Ctrl_V:
- case Ctrl_Q:
- ignore_drag_release = TRUE;
- putcmdline('^', TRUE);
- c = get_literal(); /* get next (two) character(s) */
- do_abbr = FALSE; /* don't do abbreviation now */
- /* may need to remove ^ when composing char was typed */
- if (enc_utf8 && utf_iscomposing(c) && !cmd_silent) {
- draw_cmdline(ccline.cmdpos, ccline.cmdlen - ccline.cmdpos);
- msg_putchar(' ');
- cursorcmd();
+ // not on a history line, nothing to do
+ if (s->hiscnt == hislen) {
+ break;
+ }
+
+ if (s->hiscnt == hislen - 1) {
+ // wrap around
+ s->hiscnt = 0;
+ } else {
+ ++s->hiscnt;
+ }
}
- break;
- case Ctrl_K:
- ignore_drag_release = TRUE;
- putcmdline('?', TRUE);
- c = get_digraph(TRUE);
- if (c != NUL)
+ if (s->hiscnt < 0 || history[s->histype][s->hiscnt].hisstr == NULL) {
+ s->hiscnt = s->i;
break;
+ }
- redrawcmd();
- goto cmdline_not_changed;
-
- case Ctrl__: /* CTRL-_: switch language mode */
- if (!p_ari)
+ if ((s->c != K_UP && s->c != K_DOWN)
+ || s->hiscnt == s->i
+ || STRNCMP(history[s->histype][s->hiscnt].hisstr,
+ s->lookfor, (size_t)s->j) == 0) {
break;
- if (p_altkeymap) {
- cmd_fkmap = !cmd_fkmap;
- if (cmd_fkmap) /* in Farsi always in Insert mode */
- ccline.overstrike = FALSE;
- } else /* Hebrew is default */
- cmd_hkmap = !cmd_hkmap;
- goto cmdline_not_changed;
-
- default:
-#ifdef UNIX
- if (c == intr_char) {
- gotesc = TRUE; /* will free ccline.cmdbuff after
- putting it in history */
- goto returncmd; /* back to Normal mode */
}
-#endif
- /*
- * Normal character with no special meaning. Just set mod_mask
- * to 0x0 so that typing Shift-Space in the GUI doesn't enter
- * the string <S-Space>. This should only happen after ^V.
- */
- if (!IS_SPECIAL(c))
- mod_mask = 0x0;
- break;
}
- /*
- * End of switch on command line character.
- * We come here if we have a normal character.
- */
- if (do_abbr && (IS_SPECIAL(c) || !vim_iswordc(c)) && (ccheck_abbr(
- /* Add ABBR_OFF for characters above 0x100, this is
- * what check_abbr() expects. */
- (has_mbyte &&
- c >=
- 0x100) ? (c +
- ABBR_OFF) :
- c) || c ==
- Ctrl_RSB))
- goto cmdline_changed;
+ if (s->hiscnt != s->i) {
+ // jumped to other entry
+ char_u *p;
+ int len;
+ int old_firstc;
- /*
- * put the character in the command line
- */
- if (IS_SPECIAL(c) || mod_mask != 0)
- put_on_cmdline(get_special_key_name(c, mod_mask), -1, TRUE);
- else {
- if (has_mbyte) {
- j = (*mb_char2bytes)(c, IObuff);
- IObuff[j] = NUL; /* exclude composing chars */
- put_on_cmdline(IObuff, j, TRUE);
+ xfree(ccline.cmdbuff);
+ s->xpc.xp_context = EXPAND_NOTHING;
+ if (s->hiscnt == hislen) {
+ p = s->lookfor; // back to the old one
} else {
- IObuff[0] = c;
- put_on_cmdline(IObuff, 1, TRUE);
+ p = history[s->histype][s->hiscnt].hisstr;
}
- }
- goto cmdline_changed;
- /*
- * This part implements incremental searches for "/" and "?"
- * Jump to cmdline_not_changed when a character has been read but the command
- * line did not change. Then we only search and redraw if something changed in
- * the past.
- * Jump to cmdline_changed when the command line did change.
- * (Sorry for the goto's, I know it is ugly).
- */
-cmdline_not_changed:
- if (!incsearch_postponed)
- continue;
+ if (s->histype == HIST_SEARCH
+ && p != s->lookfor
+ && (old_firstc = p[STRLEN(p) + 1]) != s->firstc) {
+ // Correct for the separator character used when
+ // adding the history entry vs the one used now.
+ // First loop: count length.
+ // Second loop: copy the characters.
+ for (s->i = 0; s->i <= 1; ++s->i) {
+ len = 0;
+ for (s->j = 0; p[s->j] != NUL; ++s->j) {
+ // Replace old sep with new sep, unless it is
+ // escaped.
+ if (p[s->j] == old_firstc
+ && (s->j == 0 || p[s->j - 1] != '\\')) {
+ if (s->i > 0) {
+ ccline.cmdbuff[len] = s->firstc;
+ }
+ } else {
+ // Escape new sep, unless it is already
+ // escaped.
+ if (p[s->j] == s->firstc
+ && (s->j == 0 || p[s->j - 1] != '\\')) {
+ if (s->i > 0) {
+ ccline.cmdbuff[len] = '\\';
+ }
+ ++len;
+ }
-cmdline_changed:
- /*
- * 'incsearch' highlighting.
- */
- if (p_is && !cmd_silent && (firstc == '/' || firstc == '?')) {
- pos_T end_pos;
- proftime_T tm;
+ if (s->i > 0) {
+ ccline.cmdbuff[len] = p[s->j];
+ }
+ }
+ ++len;
+ }
- /* if there is a character waiting, search and redraw later */
- if (char_avail()) {
- incsearch_postponed = TRUE;
- continue;
+ if (s->i == 0) {
+ alloc_cmdbuff(len);
+ }
+ }
+ ccline.cmdbuff[len] = NUL;
+ } else {
+ alloc_cmdbuff((int)STRLEN(p));
+ STRCPY(ccline.cmdbuff, p);
}
- incsearch_postponed = FALSE;
- curwin->w_cursor = old_cursor; /* start at old position */
- /* If there is no command line, don't do anything */
- if (ccline.cmdlen == 0)
- i = 0;
- else {
- ui_busy_start();
- ui_flush();
- ++emsg_off; /* So it doesn't beep if bad expr */
- /* Set the time limit to half a second. */
- tm = profile_setlimit(500L);
- i = do_search(NULL, firstc, ccline.cmdbuff, count,
- SEARCH_KEEP + SEARCH_OPT + SEARCH_NOOF + SEARCH_PEEK,
- &tm
- );
- --emsg_off;
- /* if interrupted while searching, behave like it failed */
- if (got_int) {
- (void)vpeekc(); /* remove <C-C> from input stream */
- got_int = FALSE; /* don't abandon the command line */
- i = 0;
- } else if (char_avail())
- /* cancelled searching because a char was typed */
- incsearch_postponed = TRUE;
- ui_busy_stop();
- }
- if (i != 0)
- highlight_match = TRUE; /* highlight position */
- else
- highlight_match = FALSE; /* remove highlight */
-
- /* first restore the old curwin values, so the screen is
- * positioned in the same way as the actual search command */
- curwin->w_leftcol = old_leftcol;
- curwin->w_topline = old_topline;
- curwin->w_topfill = old_topfill;
- curwin->w_botline = old_botline;
- changed_cline_bef_curs();
- update_topline();
-
- if (i != 0) {
- pos_T save_pos = curwin->w_cursor;
-
- /*
- * First move cursor to end of match, then to the start. This
- * moves the whole match onto the screen when 'nowrap' is set.
- */
- curwin->w_cursor.lnum += search_match_lines;
- curwin->w_cursor.col = search_match_endcol;
- if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) {
- curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
- coladvance((colnr_T)MAXCOL);
- }
- validate_cursor();
- end_pos = curwin->w_cursor;
- curwin->w_cursor = save_pos;
- } else
- end_pos = curwin->w_cursor; /* shutup gcc 4 */
+ ccline.cmdpos = ccline.cmdlen = (int)STRLEN(ccline.cmdbuff);
+ redrawcmd();
+ return command_line_changed(s);
+ }
+ beep_flush();
+ return command_line_not_changed(s);
+
+ case Ctrl_V:
+ case Ctrl_Q:
+ s->ignore_drag_release = true;
+ putcmdline('^', true);
+ s->c = get_literal(); // get next (two) character(s)
+ s->do_abbr = false; // don't do abbreviation now
+ // may need to remove ^ when composing char was typed
+ if (enc_utf8 && utf_iscomposing(s->c) && !cmd_silent) {
+ draw_cmdline(ccline.cmdpos, ccline.cmdlen - ccline.cmdpos);
+ msg_putchar(' ');
+ cursorcmd();
+ }
+ break;
- validate_cursor();
- /* May redraw the status line to show the cursor position. */
- if (p_ru && curwin->w_status_height > 0)
- curwin->w_redr_status = TRUE;
+ case Ctrl_K:
+ s->ignore_drag_release = true;
+ putcmdline('?', true);
+ s->c = get_digraph(true);
- save_cmdline(&save_ccline);
- update_screen(SOME_VALID);
- restore_cmdline(&save_ccline);
+ if (s->c != NUL) {
+ break;
+ }
- /* Leave it at the end to make CTRL-R CTRL-W work. */
- if (i != 0)
- curwin->w_cursor = end_pos;
+ redrawcmd();
+ return command_line_not_changed(s);
- msg_starthere();
- redrawcmdline();
- did_incsearch = TRUE;
+ case Ctrl__: // CTRL-_: switch language mode
+ if (!p_ari) {
+ break;
}
-
- if (cmdmsg_rl
- || (p_arshape && !p_tbidi && enc_utf8)
- )
- /* Always redraw the whole command line to fix shaping and
- * right-left typing. Not efficient, but it works.
- * Do it only when there are no characters left to read
- * to avoid useless intermediate redraws. */
- if (vpeekc() == NUL)
- redrawcmd();
+ if (p_altkeymap) {
+ cmd_fkmap = !cmd_fkmap;
+ if (cmd_fkmap) {
+ // in Farsi always in Insert mode
+ ccline.overstrike = false;
+ }
+ } else {
+ // Hebrew is default
+ cmd_hkmap = !cmd_hkmap;
+ }
+ return command_line_not_changed(s);
+
+ case K_FOCUSGAINED: // Neovim has been given focus
+ apply_autocmds(EVENT_FOCUSGAINED, NULL, NULL, false, curbuf);
+ return command_line_not_changed(s);
+
+ case K_FOCUSLOST: // Neovim has lost focus
+ apply_autocmds(EVENT_FOCUSLOST, NULL, NULL, false, curbuf);
+ return command_line_not_changed(s);
+
+ default:
+ // Normal character with no special meaning. Just set mod_mask
+ // to 0x0 so that typing Shift-Space in the GUI doesn't enter
+ // the string <S-Space>. This should only happen after ^V.
+ if (!IS_SPECIAL(s->c)) {
+ mod_mask = 0x0;
+ }
+ break;
}
-returncmd:
-
- cmdmsg_rl = FALSE;
+ // End of switch on command line character.
+ // We come here if we have a normal character.
+ if (s->do_abbr && (IS_SPECIAL(s->c) || !vim_iswordc(s->c))
+ // Add ABBR_OFF for characters above 0x100, this is
+ // what check_abbr() expects.
+ && (ccheck_abbr((has_mbyte && s->c >= 0x100) ?
+ (s->c + ABBR_OFF) : s->c)
+ || s->c == Ctrl_RSB)) {
+ return command_line_changed(s);
+ }
- cmd_fkmap = 0;
+ // put the character in the command line
+ if (IS_SPECIAL(s->c) || mod_mask != 0) {
+ put_on_cmdline(get_special_key_name(s->c, mod_mask), -1, true);
+ } else {
+ if (has_mbyte) {
+ s->j = (*mb_char2bytes)(s->c, IObuff);
+ IObuff[s->j] = NUL; // exclude composing chars
+ put_on_cmdline(IObuff, s->j, true);
+ } else {
+ IObuff[0] = s->c;
+ put_on_cmdline(IObuff, 1, true);
+ }
+ }
+ return command_line_changed(s);
+}
- ExpandCleanup(&xpc);
- ccline.xpc = NULL;
- if (did_incsearch) {
- curwin->w_cursor = old_cursor;
- curwin->w_curswant = old_curswant;
- curwin->w_leftcol = old_leftcol;
- curwin->w_topline = old_topline;
- curwin->w_topfill = old_topfill;
- curwin->w_botline = old_botline;
- highlight_match = FALSE;
- validate_cursor(); /* needed for TAB */
- redraw_later(SOME_VALID);
+static int command_line_not_changed(CommandLineState *s)
+{
+ // This part implements incremental searches for "/" and "?" Jump to
+ // cmdline_not_changed when a character has been read but the command line
+ // did not change. Then we only search and redraw if something changed in
+ // the past. Jump to cmdline_changed when the command line did change.
+ // (Sorry for the goto's, I know it is ugly).
+ if (!s->incsearch_postponed) {
+ return 1;
}
+ return command_line_changed(s);
+}
- if (ccline.cmdbuff != NULL) {
- /*
- * Put line in history buffer (":" and "=" only when it was typed).
- */
- if (ccline.cmdlen && firstc != NUL
- && (some_key_typed || histype == HIST_SEARCH)) {
- add_to_history(histype, ccline.cmdbuff, TRUE,
- histype == HIST_SEARCH ? firstc : NUL);
- if (firstc == ':') {
- xfree(new_last_cmdline);
- new_last_cmdline = vim_strsave(ccline.cmdbuff);
+static int command_line_changed(CommandLineState *s)
+{
+ // 'incsearch' highlighting.
+ if (p_is && !cmd_silent && (s->firstc == '/' || s->firstc == '?')) {
+ pos_T end_pos;
+ proftime_T tm;
+
+ // if there is a character waiting, search and redraw later
+ if (char_avail()) {
+ s->incsearch_postponed = true;
+ return 1;
+ }
+ s->incsearch_postponed = false;
+ curwin->w_cursor = s->old_cursor; // start at old position
+
+ // If there is no command line, don't do anything
+ if (ccline.cmdlen == 0) {
+ s->i = 0;
+ } else {
+ ui_busy_start();
+ ui_flush();
+ ++emsg_off; // So it doesn't beep if bad expr
+ // Set the time limit to half a second.
+ tm = profile_setlimit(500L);
+ s->i = do_search(NULL, s->firstc, ccline.cmdbuff, s->count,
+ SEARCH_KEEP + SEARCH_OPT + SEARCH_NOOF + SEARCH_PEEK,
+ &tm);
+ --emsg_off;
+ // if interrupted while searching, behave like it failed
+ if (got_int) {
+ (void)vpeekc(); // remove <C-C> from input stream
+ got_int = false; // don't abandon the command line
+ s->i = 0;
+ } else if (char_avail()) {
+ // cancelled searching because a char was typed
+ s->incsearch_postponed = true;
}
+ ui_busy_stop();
}
- if (gotesc) { /* abandon command line */
- xfree(ccline.cmdbuff);
- ccline.cmdbuff = NULL;
- if (msg_scrolled == 0)
- compute_cmdrow();
- MSG("");
- redraw_cmdline = TRUE;
+ if (s->i != 0) {
+ highlight_match = true; // highlight position
+ } else {
+ highlight_match = false; // remove highlight
}
- }
- /*
- * If the screen was shifted up, redraw the whole screen (later).
- * If the line is too long, clear it, so ruler and shown command do
- * not get printed in the middle of it.
- */
- msg_check();
- msg_scroll = save_msg_scroll;
- redir_off = FALSE;
+ // first restore the old curwin values, so the screen is
+ // positioned in the same way as the actual search command
+ curwin->w_leftcol = s->old_leftcol;
+ curwin->w_topline = s->old_topline;
+ curwin->w_topfill = s->old_topfill;
+ curwin->w_botline = s->old_botline;
+ changed_cline_bef_curs();
+ update_topline();
+
+ if (s->i != 0) {
+ pos_T save_pos = curwin->w_cursor;
+
+ // First move cursor to end of match, then to the start. This
+ // moves the whole match onto the screen when 'nowrap' is set.
+ curwin->w_cursor.lnum += search_match_lines;
+ curwin->w_cursor.col = search_match_endcol;
+ if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) {
+ curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
+ coladvance((colnr_T)MAXCOL);
+ }
+ validate_cursor();
+ end_pos = curwin->w_cursor;
+ curwin->w_cursor = save_pos;
+ } else {
+ end_pos = curwin->w_cursor; // shutup gcc 4
+ }
- /* When the command line was typed, no need for a wait-return prompt. */
- if (some_key_typed)
- need_wait_return = FALSE;
+ validate_cursor();
+ // May redraw the status line to show the cursor position.
+ if (p_ru && curwin->w_status_height > 0) {
+ curwin->w_redr_status = true;
+ }
- State = save_State;
- setmouse();
- ui_cursor_shape(); /* may show different cursor shape */
+ save_cmdline(&s->save_ccline);
+ update_screen(SOME_VALID);
+ restore_cmdline(&s->save_ccline);
- {
- char_u *p = ccline.cmdbuff;
+ // Leave it at the end to make CTRL-R CTRL-W work.
+ if (s->i != 0) {
+ curwin->w_cursor = end_pos;
+ }
- /* Make ccline empty, getcmdline() may try to use it. */
- ccline.cmdbuff = NULL;
- return p;
+ msg_starthere();
+ redrawcmdline();
+ s->did_incsearch = true;
}
+
+ if (cmdmsg_rl || (p_arshape && !p_tbidi && enc_utf8)) {
+ // Always redraw the whole command line to fix shaping and
+ // right-left typing. Not efficient, but it works.
+ // Do it only when there are no characters left to read
+ // to avoid useless intermediate redraws.
+ if (vpeekc() == NUL) {
+ redrawcmd();
+ }
+ }
+
+ return 1;
+}
+
+/*
+ * getcmdline() - accept a command line starting with firstc.
+ *
+ * firstc == ':' get ":" command line.
+ * firstc == '/' or '?' get search pattern
+ * firstc == '=' get expression
+ * firstc == '@' get text for input() function
+ * firstc == '>' get text for debug mode
+ * firstc == NUL get text for :insert command
+ * firstc == -1 like NUL, and break on CTRL-C
+ *
+ * The line is collected in ccline.cmdbuff, which is reallocated to fit the
+ * command line.
+ *
+ * Careful: getcmdline() can be called recursively!
+ *
+ * Return pointer to allocated string if there is a commandline, NULL
+ * otherwise.
+ */
+char_u *
+getcmdline (
+ int firstc,
+ long count, // only used for incremental search
+ int indent // indent for inside conditionals
+)
+{
+ return command_line_enter(firstc, count, indent);
}
/*
@@ -4943,7 +5060,7 @@ static int ex_window(void)
* Call the main loop until <CR> or CTRL-C is typed.
*/
cmdwin_result = 0;
- main_loop(TRUE, FALSE);
+ normal_enter(true, false);
RedrawingDisabled = i;
diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c
index fbff7d2417..4f345158cf 100644
--- a/src/nvim/file_search.c
+++ b/src/nvim/file_search.c
@@ -45,7 +45,6 @@
*/
#include <assert.h>
-#include <errno.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index a7472b40e2..1a6c85abaa 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -1,12 +1,4 @@
/*
- * VIM - Vi IMproved by Bram Moolenaar
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- * See README.txt for an overview of the Vim source code.
- */
-
-/*
* fileio.c: read from and write to a file
*/
@@ -535,11 +527,7 @@ readfile (
if (!newfile) {
return FAIL;
}
- if (perm < 0
-#ifdef ENOENT
- && errno == ENOENT
-#endif
- ) {
+ if (perm == UV_ENOENT) {
/*
* Set the 'new-file' flag, so that when the file has
* been created by someone else, a ":w" will complain.
@@ -582,11 +570,11 @@ readfile (
return OK; /* a new file is not an error */
} else {
filemess(curbuf, sfname, (char_u *)(
-# ifdef EFBIG
- (errno == EFBIG) ? _("[File too big]") :
-# endif
-# ifdef EOVERFLOW
- (errno == EOVERFLOW) ? _("[File too big]") :
+ (fd == UV_EFBIG) ? _("[File too big]") :
+# if defined(UNIX) && defined(EOVERFLOW)
+ // libuv only returns -errno in Unix and in Windows open() does not
+ // set EOVERFLOW
+ (fd == -EOVERFLOW) ? _("[File too big]") :
# endif
_("[Permission Denied]")), 0);
curbuf->b_p_ro = TRUE; /* must use "w!" now */
@@ -1556,6 +1544,11 @@ rewind_retry:
/* First try finding a NL, for Dos and Unix */
if (try_dos || try_unix) {
for (p = ptr; p < ptr + size; ++p) {
+ // Reset the carriage return counter.
+ if (try_mac) {
+ try_mac = 1;
+ }
+
if (*p == NL) {
if (!try_unix
|| (try_dos && p > ptr && p[-1] == CAR))
@@ -1563,6 +1556,8 @@ rewind_retry:
else
fileformat = EOL_UNIX;
break;
+ } else if (*p == CAR && try_mac) {
+ try_mac++;
}
}
@@ -1583,6 +1578,10 @@ rewind_retry:
if (try_mac > try_unix)
fileformat = EOL_MAC;
}
+ } else if (fileformat == EOL_UNKNOWN && try_mac == 1) {
+ // Looking for CR but found no end-of-line markers at all:
+ // use the default format.
+ fileformat = default_fileformat();
}
}
@@ -1934,10 +1933,10 @@ failed:
check_marks_read();
/*
- * Trick: We remember if the last line of the read didn't have
- * an eol even when 'binary' is off, for when writing it again with
- * 'binary' on. This is required for
- * ":autocmd FileReadPost *.gz set bin|'[,']!gunzip" to work.
+ * We remember if the last line of the read didn't have
+ * an eol even when 'binary' is off, to support turning 'fixeol' off,
+ * or writing the read again with 'binary' on. The latter is required
+ * for ":autocmd FileReadPost *.gz set bin|'[,']!gunzip" to work.
*/
curbuf->b_no_eol_lnum = read_no_eol_lnum;
@@ -3322,7 +3321,7 @@ restore_backup:
/* write failed or last line has no EOL: stop here */
if (end == 0
|| (lnum == end
- && write_bin
+ && (write_bin || !buf->b_p_fixeol)
&& (lnum == buf->b_no_eol_lnum
|| (lnum == buf->b_ml.ml_line_count && !buf->b_p_eol)))) {
++lnum; /* written the line, count it */
@@ -4343,8 +4342,6 @@ void shorten_fnames(int force)
/// @return [allocated] - A new filename, made up from:
/// * fname + ext, if fname not NULL.
/// * current dir + ext, if fname is NULL.
-/// On Windows, and if ext starts with ".", a "_" is
-/// preprended to ext (for filename to be valid).
/// Result is guaranteed to:
/// * be ended by <ext>.
/// * have a basename with at most BASENAMELEN chars:
@@ -4398,15 +4395,6 @@ char *modname(const char *fname, const char *ext, bool prepend_dot)
char *s;
s = ptr + strlen(ptr);
-#if defined(WIN3264)
- // If there is no file name, and the extension starts with '.', put a
- // '_' before the dot, because just ".ext" may be invalid if it's on a
- // FAT partition, and on HPFS it doesn't matter.
- else if ((fname == NULL || *fname == NUL) && *ext == '.') {
- *s++ = '_';
- }
-#endif
-
// Append the extension.
// ext can start with '.' and cannot exceed 3 more characters.
strcpy(s, ext);
@@ -6430,7 +6418,7 @@ apply_autocmds_group (
* invalid.
*/
if (fname_io == NULL) {
- if (event == EVENT_COLORSCHEME)
+ if (event == EVENT_COLORSCHEME || event == EVENT_OPTIONSET)
autocmd_fname = NULL;
else if (fname != NULL && *fname != NUL)
autocmd_fname = fname;
@@ -6480,6 +6468,7 @@ apply_autocmds_group (
if (event == EVENT_COLORSCHEME
|| event == EVENT_FILETYPE
|| event == EVENT_FUNCUNDEFINED
+ || event == EVENT_OPTIONSET
|| event == EVENT_QUICKFIXCMDPOST
|| event == EVENT_QUICKFIXCMDPRE
|| event == EVENT_REMOTEREPLY
diff --git a/src/nvim/fold.c b/src/nvim/fold.c
index b52938075c..2e32e78062 100644
--- a/src/nvim/fold.c
+++ b/src/nvim/fold.c
@@ -1,11 +1,4 @@
-/* vim: set fdm=marker fdl=1 fdc=3
- *
- * VIM - Vi IMproved by Bram Moolenaar
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- * See README.txt for an overview of the Vim source code.
- */
+// vim: set fdm=marker fdl=1 fdc=3
/*
* fold.c: code for folding
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index 990d0fb8e2..44d6c086e7 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -1,12 +1,4 @@
/*
- * VIM - Vi IMproved by Bram Moolenaar
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- * See README.txt for an overview of the Vim source code.
- */
-
-/*
* getchar.c
*
* functions related with getting a character from the user/mapping/redo/...
@@ -1131,7 +1123,7 @@ static void gotchars(char_u *chars, int len)
* - While reading a script file.
* - When no_u_sync is non-zero.
*/
-static void may_sync_undo(void)
+void may_sync_undo(void)
{
if ((!(State & (INSERT + CMDLINE)) || arrow_used)
&& scriptin[curscript] == NULL)
diff --git a/src/nvim/globals.h b/src/nvim/globals.h
index 0ef0a12889..52eebebf41 100644
--- a/src/nvim/globals.h
+++ b/src/nvim/globals.h
@@ -1,10 +1,3 @@
-/*
- * VIM - Vi IMproved by Bram Moolenaar
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- */
-
#ifndef NVIM_GLOBALS_H
#define NVIM_GLOBALS_H
@@ -55,6 +48,57 @@
# endif
#endif
+#ifdef WIN32
+# define _PATHSEPSTR "\\"
+#else
+# define _PATHSEPSTR "/"
+#endif
+
+#ifndef FILETYPE_FILE
+# define FILETYPE_FILE "filetype.vim"
+#endif
+
+#ifndef FTPLUGIN_FILE
+# define FTPLUGIN_FILE "ftplugin.vim"
+#endif
+
+#ifndef INDENT_FILE
+# define INDENT_FILE "indent.vim"
+#endif
+
+#ifndef FTOFF_FILE
+# define FTOFF_FILE "ftoff.vim"
+#endif
+
+#ifndef FTPLUGOF_FILE
+# define FTPLUGOF_FILE "ftplugof.vim"
+#endif
+
+#ifndef INDOFF_FILE
+# define INDOFF_FILE "indoff.vim"
+#endif
+
+#define DFLT_ERRORFILE "errors.err"
+
+#ifndef SYS_VIMRC_FILE
+# define SYS_VIMRC_FILE "$VIM" _PATHSEPSTR "sysinit.vim"
+#endif
+
+#ifndef DFLT_HELPFILE
+# define DFLT_HELPFILE "$VIMRUNTIME" _PATHSEPSTR "doc" _PATHSEPSTR "help.txt"
+#endif
+
+#ifndef SYNTAX_FNAME
+# define SYNTAX_FNAME "$VIMRUNTIME" _PATHSEPSTR "syntax" _PATHSEPSTR "%s.vim"
+#endif
+
+#ifndef EXRC_FILE
+# define EXRC_FILE ".exrc"
+#endif
+
+#ifndef VIMRC_FILE
+# define VIMRC_FILE ".nvimrc"
+#endif
/* Values for "starting" */
#define NO_SCREEN 2 /* no screen updating yet */
@@ -633,7 +677,7 @@ EXTERN int silent_mode INIT(= FALSE);
/* set to TRUE when "-s" commandline argument
* used for ex */
-// Set to true when sourcing of startup scripts (nvimrc) is done.
+// Set to true when sourcing of startup scripts (init.vim) is done.
// Used for options that cannot be changed after startup scripts.
EXTERN bool did_source_startup_scripts INIT(= false);
@@ -998,7 +1042,7 @@ EXTERN int lcs_space INIT(= NUL);
EXTERN int lcs_tab1 INIT(= NUL);
EXTERN int lcs_tab2 INIT(= NUL);
EXTERN int lcs_trail INIT(= NUL);
-EXTERN int lcs_conceal INIT(= '-');
+EXTERN int lcs_conceal INIT(= ' ');
/* Characters from 'fillchars' option */
EXTERN int fill_stl INIT(= ' ');
diff --git a/src/nvim/hardcopy.c b/src/nvim/hardcopy.c
index 819015a85d..ab8959239b 100644
--- a/src/nvim/hardcopy.c
+++ b/src/nvim/hardcopy.c
@@ -1,17 +1,8 @@
/*
- * VIM - Vi IMproved by Bram Moolenaar
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- * See README.txt for an overview of the Vim source code.
- */
-
-/*
* hardcopy.c: printing to paper
*/
#include <assert.h>
-#include <errno.h>
#include <string.h>
#include <inttypes.h>
#include <stdint.h>
diff --git a/src/nvim/if_cscope.c b/src/nvim/if_cscope.c
index e5cbb58608..3585c26ca2 100644
--- a/src/nvim/if_cscope.c
+++ b/src/nvim/if_cscope.c
@@ -4,9 +4,8 @@
*
* The basic idea/structure of cscope for Vim was borrowed from Nvi. There
* might be a few lines of code that look similar to what Nvi has.
- *
- * See README.txt for an overview of the Vim source code.
*/
+
#include <stdbool.h>
#include <assert.h>
diff --git a/src/nvim/keymap.c b/src/nvim/keymap.c
index bf4f5e8c4d..04d6cbf5e3 100644
--- a/src/nvim/keymap.c
+++ b/src/nvim/keymap.c
@@ -1,4 +1,4 @@
-/************************************************************************
+/*
* functions that use lookup tables for various things, generally to do with
* special key codes.
*/
@@ -283,8 +283,9 @@ static struct key_name_entry {
{K_ZERO, (char_u *)"Nul"},
{K_SNR, (char_u *)"SNR"},
{K_PLUG, (char_u *)"Plug"},
- {K_CURSORHOLD, (char_u *)"CursorHold"},
{K_PASTE, (char_u *)"Paste"},
+ {K_FOCUSGAINED, (char_u *)"FocusGained"},
+ {K_FOCUSLOST, (char_u *)"FocusLost"},
{0, NULL}
};
diff --git a/src/nvim/keymap.h b/src/nvim/keymap.h
index 119bff943a..766362d145 100644
--- a/src/nvim/keymap.h
+++ b/src/nvim/keymap.h
@@ -1,10 +1,3 @@
-/*
- * VIM - Vi IMproved by Bram Moolenaar
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- */
-
#ifndef NVIM_KEYMAP_H
#define NVIM_KEYMAP_H
@@ -242,7 +235,6 @@ enum key_extra {
, KE_X2RELEASE
, KE_DROP /* DnD data is available */
- , KE_CURSORHOLD /* CursorHold event */
, KE_NOP /* doesn't do something */
, KE_FOCUSGAINED /* focus gained */
, KE_FOCUSLOST /* focus lost */
@@ -437,7 +429,6 @@ enum key_extra {
#define K_FOCUSGAINED TERMCAP2KEY(KS_EXTRA, KE_FOCUSGAINED)
#define K_FOCUSLOST TERMCAP2KEY(KS_EXTRA, KE_FOCUSLOST)
-#define K_CURSORHOLD TERMCAP2KEY(KS_EXTRA, KE_CURSORHOLD)
#define K_EVENT TERMCAP2KEY(KS_EXTRA, KE_EVENT)
#define K_PASTE TERMCAP2KEY(KS_EXTRA, KE_PASTE)
diff --git a/src/nvim/log.c b/src/nvim/log.c
index 08b6d0483e..5767da03af 100644
--- a/src/nvim/log.c
+++ b/src/nvim/log.c
@@ -14,7 +14,7 @@
# include <unistd.h>
#endif
-#define USR_LOG_FILE "$HOME/.nvimlog"
+#define USR_LOG_FILE "$HOME" _PATHSEPSTR ".nvimlog"
static uv_mutex_t mutex;
diff --git a/src/nvim/log.h b/src/nvim/log.h
index 152e90760e..32b7276f14 100644
--- a/src/nvim/log.h
+++ b/src/nvim/log.h
@@ -19,7 +19,7 @@
#define ELOGN(...)
// Logging is disabled if NDEBUG or DISABLE_LOG is defined.
-#ifdef NDEBUG
+#if !defined(DISABLE_LOG) && defined(NDEBUG)
# define DISABLE_LOG
#endif
diff --git a/src/nvim/macros.h b/src/nvim/macros.h
index d42997650c..26ab5a7de7 100644
--- a/src/nvim/macros.h
+++ b/src/nvim/macros.h
@@ -1,17 +1,6 @@
#ifndef NVIM_MACROS_H
#define NVIM_MACROS_H
-/*
- * VIM - Vi IMproved by Bram Moolenaar
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- */
-
-/*
- * macros.h: macro definitions for often used code
- */
-
#ifndef MIN
# define MIN(X, Y) ((X) < (Y) ? (X) : (Y))
#endif
diff --git a/src/nvim/main.c b/src/nvim/main.c
index d865260295..cef10d12d5 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -1,14 +1,5 @@
-/*
- * VIM - Vi IMproved by Bram Moolenaar
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- * See README.txt for an overview of the Vim source code.
- */
-
#define EXTERN
#include <assert.h>
-#include <errno.h>
#include <stdint.h>
#include <string.h>
#include <stdbool.h>
@@ -54,6 +45,7 @@
#include "nvim/profile.h"
#include "nvim/quickfix.h"
#include "nvim/screen.h"
+#include "nvim/state.h"
#include "nvim/strings.h"
#include "nvim/syntax.h"
#include "nvim/ui.h"
@@ -287,8 +279,8 @@ int main(int argc, char **argv)
* Set the default values for the options that use Rows and Columns.
*/
win_init_size();
- /* Set the 'diff' option now, so that it can be checked for in a .vimrc
- * file. There is no buffer yet though. */
+ // Set the 'diff' option now, so that it can be checked for in a vimrc
+ // file. There is no buffer yet though.
if (params.diff_mode)
diff_win_options(firstwin, FALSE);
@@ -345,7 +337,7 @@ int main(int argc, char **argv)
*/
load_plugins();
- /* Decide about window layout for diff mode after reading vimrc. */
+ // Decide about window layout for diff mode after reading vimrc.
set_window_layout(&params);
/*
@@ -358,10 +350,8 @@ int main(int argc, char **argv)
mch_exit(0);
}
- /*
- * Set a few option defaults after reading .vimrc files:
- * 'title' and 'icon', Unix: 'shellpipe' and 'shellredir'.
- */
+ // Set a few option defaults after reading vimrc files:
+ // 'title' and 'icon', Unix: 'shellpipe' and 'shellredir'.
set_init_3();
TIME_MSG("inits 3");
@@ -530,228 +520,16 @@ int main(int argc, char **argv)
}
TIME_MSG("before starting main loop");
+ ILOG("Starting Neovim main loop.");
/*
* Call the main command loop. This never returns.
*/
- main_loop(FALSE, FALSE);
+ normal_enter(false, false);
return 0;
}
-/*
- * Main loop: Execute Normal mode commands until exiting Vim.
- * Also used to handle commands in the command-line window, until the window
- * is closed.
- * Also used to handle ":visual" command after ":global": execute Normal mode
- * commands, return when entering Ex mode. "noexmode" is TRUE then.
- */
-void
-main_loop (
- int cmdwin, /* TRUE when working in the command-line window */
- int noexmode /* TRUE when return on entering Ex mode */
-)
-{
- oparg_T oa; /* operator arguments */
- int previous_got_int = FALSE; /* "got_int" was TRUE */
- linenr_T conceal_old_cursor_line = 0;
- linenr_T conceal_new_cursor_line = 0;
- int conceal_update_lines = FALSE;
-
- ILOG("Starting Neovim main loop.");
-
- clear_oparg(&oa);
- while (!cmdwin
- || cmdwin_result == 0
- ) {
- if (stuff_empty()) {
- did_check_timestamps = FALSE;
- if (need_check_timestamps)
- check_timestamps(FALSE);
- if (need_wait_return) /* if wait_return still needed ... */
- wait_return(FALSE); /* ... call it now */
- if (need_start_insertmode && goto_im()
- && !VIsual_active
- ) {
- need_start_insertmode = FALSE;
- stuffReadbuff((char_u *)"i"); /* start insert mode next */
- /* skip the fileinfo message now, because it would be shown
- * after insert mode finishes! */
- need_fileinfo = FALSE;
- }
- }
-
- /* Reset "got_int" now that we got back to the main loop. Except when
- * inside a ":g/pat/cmd" command, then the "got_int" needs to abort
- * the ":g" command.
- * For ":g/pat/vi" we reset "got_int" when used once. When used
- * a second time we go back to Ex mode and abort the ":g" command. */
- if (got_int) {
- if (noexmode && global_busy && !exmode_active && previous_got_int) {
- /* Typed two CTRL-C in a row: go back to ex mode as if "Q" was
- * used and keep "got_int" set, so that it aborts ":g". */
- exmode_active = EXMODE_NORMAL;
- State = NORMAL;
- } else if (!global_busy || !exmode_active) {
- if (!quit_more)
- (void)vgetc(); /* flush all buffers */
- got_int = FALSE;
- }
- previous_got_int = TRUE;
- } else
- previous_got_int = FALSE;
-
- if (!exmode_active)
- msg_scroll = FALSE;
- quit_more = FALSE;
-
- /*
- * If skip redraw is set (for ":" in wait_return()), don't redraw now.
- * If there is nothing in the stuff_buffer or do_redraw is TRUE,
- * update cursor and redraw.
- */
- if (skip_redraw || exmode_active)
- skip_redraw = FALSE;
- else if (do_redraw || stuff_empty()) {
- /* Trigger CursorMoved if the cursor moved. */
- if (!finish_op && (
- has_cursormoved()
- ||
- curwin->w_p_cole > 0
- )
- && !equalpos(last_cursormoved, curwin->w_cursor)) {
- if (has_cursormoved())
- apply_autocmds(EVENT_CURSORMOVED, NULL, NULL,
- FALSE, curbuf);
- if (curwin->w_p_cole > 0) {
- conceal_old_cursor_line = last_cursormoved.lnum;
- conceal_new_cursor_line = curwin->w_cursor.lnum;
- conceal_update_lines = TRUE;
- }
- last_cursormoved = curwin->w_cursor;
- }
-
- /* Trigger TextChanged if b_changedtick differs. */
- if (!finish_op && has_textchanged()
- && last_changedtick != curbuf->b_changedtick) {
- if (last_changedtick_buf == curbuf)
- apply_autocmds(EVENT_TEXTCHANGED, NULL, NULL,
- FALSE, curbuf);
- last_changedtick_buf = curbuf;
- last_changedtick = curbuf->b_changedtick;
- }
-
- /* Scroll-binding for diff mode may have been postponed until
- * here. Avoids doing it for every change. */
- if (diff_need_scrollbind) {
- check_scrollbind((linenr_T)0, 0L);
- diff_need_scrollbind = FALSE;
- }
- /* Include a closed fold completely in the Visual area. */
- foldAdjustVisual();
- /*
- * When 'foldclose' is set, apply 'foldlevel' to folds that don't
- * contain the cursor.
- * When 'foldopen' is "all", open the fold(s) under the cursor.
- * This may mark the window for redrawing.
- */
- if (hasAnyFolding(curwin) && !char_avail()) {
- foldCheckClose();
- if (fdo_flags & FDO_ALL)
- foldOpenCursor();
- }
-
- /*
- * Before redrawing, make sure w_topline is correct, and w_leftcol
- * if lines don't wrap, and w_skipcol if lines wrap.
- */
- update_topline();
- validate_cursor();
-
- if (VIsual_active)
- update_curbuf(INVERTED); /* update inverted part */
- else if (must_redraw)
- update_screen(0);
- else if (redraw_cmdline || clear_cmdline)
- showmode();
- redraw_statuslines();
- if (need_maketitle)
- maketitle();
- /* display message after redraw */
- if (keep_msg != NULL) {
- char_u *p;
-
- // msg_attr_keep() will set keep_msg to NULL, must free the string
- // here. Don't reset keep_msg, msg_attr_keep() uses it to check for
- // duplicates.
- p = keep_msg;
- msg_attr(p, keep_msg_attr);
- xfree(p);
- }
- if (need_fileinfo) { /* show file info after redraw */
- fileinfo(FALSE, TRUE, FALSE);
- need_fileinfo = FALSE;
- }
-
- emsg_on_display = FALSE; /* can delete error message now */
- did_emsg = FALSE;
- msg_didany = FALSE; /* reset lines_left in msg_start() */
- may_clear_sb_text(); /* clear scroll-back text on next msg */
- showruler(FALSE);
-
- if (conceal_update_lines
- && (conceal_old_cursor_line != conceal_new_cursor_line
- || conceal_cursor_line(curwin)
- || need_cursor_line_redraw)) {
- if (conceal_old_cursor_line != conceal_new_cursor_line
- && conceal_old_cursor_line
- <= curbuf->b_ml.ml_line_count)
- update_single_line(curwin, conceal_old_cursor_line);
- update_single_line(curwin, conceal_new_cursor_line);
- curwin->w_valid &= ~VALID_CROW;
- }
- setcursor();
-
- do_redraw = FALSE;
-
- /* Now that we have drawn the first screen all the startup stuff
- * has been done, close any file for startup messages. */
- if (time_fd != NULL) {
- TIME_MSG("first screen update");
- TIME_MSG("--- NVIM STARTED ---");
- fclose(time_fd);
- time_fd = NULL;
- }
- }
-
- /*
- * Update w_curswant if w_set_curswant has been set.
- * Postponed until here to avoid computing w_virtcol too often.
- */
- update_curswant();
-
- /*
- * May perform garbage collection when waiting for a character, but
- * only at the very toplevel. Otherwise we may be using a List or
- * Dict internally somewhere.
- * "may_garbage_collect" is reset in vgetc() which is invoked through
- * do_exmode() and normal_cmd().
- */
- may_garbage_collect = (!cmdwin && !noexmode);
- /*
- * If we're invoked as ex, do a round of ex commands.
- * Otherwise, get and execute a normal mode command.
- */
- if (exmode_active) {
- if (noexmode) /* End of ":global/path/visual" commands */
- return;
- do_exmode(exmode_active == EXMODE_VIM);
- } else
- normal_cmd(&oa, TRUE);
- }
-}
-
-
/* Exit properly */
void getout(int exitval)
{
@@ -1148,9 +926,6 @@ static void command_line_scan(mparm_T *parmp)
want_argument = TRUE;
break;
- case 'X': /* "-X" don't connect to X server */
- break;
-
case 'Z': /* "-Z" restricted mode */
restricted = TRUE;
break;
@@ -1551,8 +1326,8 @@ static void create_windows(mparm_T *parmp)
if (parmp->window_count == 0)
parmp->window_count = GARGCOUNT;
if (parmp->window_count > 1) {
- /* Don't change the windows if there was a command in .vimrc that
- * already split some windows */
+ // Don't change the windows if there was a command in vimrc that
+ // already split some windows
if (parmp->window_layout == 0)
parmp->window_layout = WIN_HOR;
if (parmp->window_layout == WIN_TABS) {
@@ -1574,14 +1349,11 @@ static void create_windows(mparm_T *parmp)
getout(1);
do_modelines(0); /* do modelines */
} else {
- /*
- * Open a buffer for windows that don't have one yet.
- * Commands in the .vimrc might have loaded a file or split the window.
- * Watch out for autocommands that delete a window.
- */
- /*
- * Don't execute Win/Buf Enter/Leave autocommands here
- */
+ // Open a buffer for windows that don't have one yet.
+ // Commands in the vimrc might have loaded a file or split the window.
+ // Watch out for autocommands that delete a window.
+ //
+ // Don't execute Win/Buf Enter/Leave autocommands here
++autocmd_no_enter;
++autocmd_no_leave;
dorewind = TRUE;
@@ -1691,8 +1463,8 @@ static void edit_buffers(mparm_T *parmp)
}
advance = TRUE;
- /* Only open the file if there is no file in this window yet (that can
- * happen when .vimrc contains ":sall"). */
+ // Only open the file if there is no file in this window yet (that can
+ // happen when vimrc contains ":sall").
if (curbuf == firstwin->w_buffer || curbuf->b_ffname == NULL) {
curwin->w_arg_idx = arg_idx;
/* Edit file from arg list, if there is one. When "Quit" selected
@@ -1801,117 +1573,125 @@ static void exe_commands(mparm_T *parmp)
TIME_MSG("executing command arguments");
}
-/*
- * Source startup scripts.
- */
-static void source_startup_scripts(mparm_T *parmp)
+/// Source vimrc or do other user initialization
+///
+/// Does one of the following things, stops after whichever succeeds:
+///
+/// 1. Execution of VIMINIT environment variable.
+/// 2. Sourcing user vimrc file ($XDG_CONFIG_HOME/nvim/init.vim).
+/// 3. Sourcing other vimrc files ($XDG_CONFIG_DIRS[1]/nvim/init.vim, …).
+/// 4. Execution of EXINIT environment variable.
+///
+/// @return True if it is needed to attempt to source exrc file according to
+/// 'exrc' option definition.
+static bool do_user_initialization(void)
+ FUNC_ATTR_WARN_UNUSED_RESULT
{
- int i;
+ bool do_exrc = p_exrc;
+ if (process_env("VIMINIT", true) == OK) {
+ do_exrc = p_exrc;
+ return do_exrc;
+ }
+ char_u *user_vimrc = (char_u *)stdpaths_user_conf_subpath("init.vim");
+ if (do_source(user_vimrc, true, DOSO_VIMRC) != FAIL) {
+ do_exrc = p_exrc;
+ if (do_exrc) {
+ do_exrc = (path_full_compare((char_u *)VIMRC_FILE, user_vimrc, false)
+ != kEqualFiles);
+ }
+ xfree(user_vimrc);
+ return do_exrc;
+ }
+ xfree(user_vimrc);
+ char *const config_dirs = stdpaths_get_xdg_var(kXDGConfigDirs);
+ if (config_dirs != NULL) {
+ const void *iter = NULL;
+ do {
+ const char *dir;
+ size_t dir_len;
+ iter = vim_colon_env_iter(config_dirs, iter, &dir, &dir_len);
+ if (dir == NULL || dir_len == 0) {
+ break;
+ }
+ const char path_tail[] = { 'n', 'v', 'i', 'm', PATHSEP,
+ 'i', 'n', 'i', 't', '.', 'v', 'i', 'm', NUL };
+ char *vimrc = xmalloc(dir_len + sizeof(path_tail) + 1);
+ 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) {
+ do_exrc = p_exrc;
+ if (do_exrc) {
+ do_exrc = (path_full_compare((char_u *)VIMRC_FILE, (char_u *)vimrc,
+ false) != kEqualFiles);
+ }
+ xfree(vimrc);
+ xfree(config_dirs);
+ return do_exrc;
+ }
+ xfree(vimrc);
+ } while (iter != NULL);
+ xfree(config_dirs);
+ }
+ if (process_env("EXINIT", false) == OK) {
+ do_exrc = p_exrc;
+ return do_exrc;
+ }
+ return do_exrc;
+}
- /*
- * If -u argument given, use only the initializations from that file and
- * nothing else.
- */
+/// Source startup scripts
+///
+/// @param[in]
+static void source_startup_scripts(const mparm_T *const parmp)
+ FUNC_ATTR_NONNULL_ALL
+{
+ // If -u argument given, use only the initializations from that file and
+ // nothing else.
if (parmp->use_vimrc != NULL) {
if (strcmp(parmp->use_vimrc, "NONE") == 0
|| strcmp(parmp->use_vimrc, "NORC") == 0) {
if (parmp->use_vimrc[2] == 'N')
- p_lpl = FALSE; // don't load plugins either
+ p_lpl = false; // don't load plugins either
} else {
if (do_source((char_u *)parmp->use_vimrc, FALSE, DOSO_NONE) != OK)
EMSG2(_("E282: Cannot read from \"%s\""), parmp->use_vimrc);
}
} else if (!silent_mode) {
-
- /*
- * Get system wide defaults, if the file name is defined.
- */
#ifdef SYS_VIMRC_FILE
- (void)do_source((char_u *)SYS_VIMRC_FILE, FALSE, DOSO_NONE);
-#endif
-
- /*
- * Try to read initialization commands from the following places:
- * - environment variable VIMINIT
- * - user vimrc file (~/.vimrc)
- * - second user vimrc file ($VIM/.vimrc for Dos)
- * - environment variable EXINIT
- * - user exrc file (~/.exrc)
- * - second user exrc file ($VIM/.exrc for Dos)
- * The first that exists is used, the rest is ignored.
- */
- if (process_env("VIMINIT", true) != OK) {
- if (do_source((char_u *)USR_VIMRC_FILE, TRUE, DOSO_VIMRC) == FAIL
-#ifdef USR_VIMRC_FILE2
- && do_source((char_u *)USR_VIMRC_FILE2, TRUE,
- DOSO_VIMRC) == FAIL
-#endif
-#ifdef USR_VIMRC_FILE3
- && do_source((char_u *)USR_VIMRC_FILE3, TRUE,
- DOSO_VIMRC) == FAIL
-#endif
- && process_env("EXINIT", FALSE) == FAIL
- && do_source((char_u *)USR_EXRC_FILE, FALSE, DOSO_NONE) == FAIL) {
-#ifdef USR_EXRC_FILE2
- (void)do_source((char_u *)USR_EXRC_FILE2, FALSE, DOSO_NONE);
+ // Get system wide defaults, if the file name is defined.
+ (void) do_source((char_u *)SYS_VIMRC_FILE, false, DOSO_NONE);
#endif
- }
- }
- /*
- * Read initialization commands from ".vimrc" or ".exrc" in current
- * directory. This is only done if the 'exrc' option is set.
- * Because of security reasons we disallow shell and write commands
- * now, except for unix if the file is owned by the user or 'secure'
- * option has been reset in environment of global ".exrc" or ".vimrc".
- * Only do this if VIMRC_FILE is not the same as USR_VIMRC_FILE or
- * SYS_VIMRC_FILE.
- */
- if (p_exrc) {
+ if (do_user_initialization()) {
+ // Read initialization commands from ".vimrc" or ".exrc" in current
+ // directory. This is only done if the 'exrc' option is set.
+ // Because of security reasons we disallow shell and write commands
+ // now, except for unix if the file is owned by the user or 'secure'
+ // option has been reset in environment of global "exrc" or "vimrc".
+ // Only do this if VIMRC_FILE is not the same as vimrc file sourced in
+ // do_user_initialization.
#if defined(UNIX)
- /* If ".vimrc" file is not owned by user, set 'secure' mode. */
+ // If vimrc file is not owned by user, set 'secure' mode.
if (!file_owned(VIMRC_FILE))
#endif
secure = p_secure;
- i = FAIL;
- if (path_full_compare((char_u *)USR_VIMRC_FILE,
- (char_u *)VIMRC_FILE, FALSE) != kEqualFiles
-#ifdef USR_VIMRC_FILE2
- && path_full_compare((char_u *)USR_VIMRC_FILE2,
- (char_u *)VIMRC_FILE, FALSE) != kEqualFiles
-#endif
-#ifdef USR_VIMRC_FILE3
- && path_full_compare((char_u *)USR_VIMRC_FILE3,
- (char_u *)VIMRC_FILE, FALSE) != kEqualFiles
-#endif
-#ifdef SYS_VIMRC_FILE
- && path_full_compare((char_u *)SYS_VIMRC_FILE,
- (char_u *)VIMRC_FILE, FALSE) != kEqualFiles
-#endif
- )
- i = do_source((char_u *)VIMRC_FILE, TRUE, DOSO_VIMRC);
-
- if (i == FAIL) {
+ if (do_source((char_u *)VIMRC_FILE, true, DOSO_VIMRC) == FAIL) {
#if defined(UNIX)
- /* if ".exrc" is not owned by user set 'secure' mode */
- if (!file_owned(EXRC_FILE))
+ // if ".exrc" is not owned by user set 'secure' mode
+ if (!file_owned(EXRC_FILE)) {
secure = p_secure;
- else
+ } else {
secure = 0;
+ }
#endif
- if ( path_full_compare((char_u *)USR_EXRC_FILE,
- (char_u *)EXRC_FILE, FALSE) != kEqualFiles
-#ifdef USR_EXRC_FILE2
- && path_full_compare((char_u *)USR_EXRC_FILE2,
- (char_u *)EXRC_FILE, FALSE) != kEqualFiles
-#endif
- )
- (void)do_source((char_u *)EXRC_FILE, FALSE, DOSO_NONE);
+ (void)do_source((char_u *)EXRC_FILE, false, DOSO_NONE);
}
}
- if (secure == 2)
- need_wait_return = TRUE;
+ if (secure == 2) {
+ need_wait_return = true;
+ }
secure = 0;
}
did_source_startup_scripts = true;
@@ -2041,8 +1821,8 @@ static void usage(void)
mch_msg(_(" -n No swap file, use memory only\n"));
mch_msg(_(" -r, -L List swap files and exit\n"));
mch_msg(_(" -r <file> Recover crashed session\n"));
- mch_msg(_(" -u <nvimrc> Use <nvimrc> instead of the default\n"));
- mch_msg(_(" -i <shada> Use <shada> instead of the default " SHADA_FILE "\n")); // NOLINT(whitespace/line_length)
+ mch_msg(_(" -u <vimrc> Use <vimrc> instead of the default\n"));
+ mch_msg(_(" -i <shada> Use <shada> instead of the default\n"));
mch_msg(_(" --noplugin Don't load plugin scripts\n"));
mch_msg(_(" -o[N] Open N windows (default: one for each file)\n"));
mch_msg(_(" -O[N] Like -o but split vertically\n"));
@@ -2050,7 +1830,7 @@ static void usage(void)
mch_msg(_(" + Start at end of file\n"));
mch_msg(_(" +<linenum> Start at line <linenum>\n"));
mch_msg(_(" +/<pattern> Start at first occurrence of <pattern>\n"));
- mch_msg(_(" --cmd <command> Execute <command> before loading any nvimrc\n"));
+ mch_msg(_(" --cmd <command> Execute <command> before loading any vimrc\n"));
mch_msg(_(" -c <command> Execute <command> after loading the first file\n"));
mch_msg(_(" -S <session> Source <session> after loading the first file\n"));
mch_msg(_(" -s <scriptin> Read Normal mode commands from <scriptin>\n"));
diff --git a/src/nvim/mark.c b/src/nvim/mark.c
index dd49b311d3..e2f212340c 100644
--- a/src/nvim/mark.c
+++ b/src/nvim/mark.c
@@ -1,17 +1,8 @@
/*
- * VIM - Vi IMproved by Bram Moolenaar
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- * See README.txt for an overview of the Vim source code.
- */
-
-/*
* mark.c: functions for setting marks and jumping to them
*/
#include <assert.h>
-#include <errno.h>
#include <inttypes.h>
#include <string.h>
#include <limits.h>
@@ -546,19 +537,26 @@ int check_mark(pos_T *pos)
return OK;
}
-/*
- * clrallmarks() - clear all marks in the buffer 'buf'
- *
- * Used mainly when trashing the entire buffer during ":e" type commands
- */
-void clrallmarks(buf_T *buf)
+/// Clear all marks and change list in the given buffer
+///
+/// Used mainly when trashing the entire buffer during ":e" type commands.
+///
+/// @param[out] buf Buffer to clear marks in.
+void clrallmarks(buf_T *const buf)
+ FUNC_ATTR_NONNULL_ALL
{
- memset(&(buf->b_namedm[0]), 0, sizeof(buf->b_namedm));
- buf->b_op_start.lnum = 0; /* start/end op mark cleared */
+ for (size_t i = 0; i < NMARKS; i++) {
+ clear_fmark(&buf->b_namedm[i]);
+ }
+ clear_fmark(&buf->b_last_cursor);
+ buf->b_last_cursor.mark.lnum = 1;
+ clear_fmark(&buf->b_last_insert);
+ clear_fmark(&buf->b_last_change);
+ buf->b_op_start.lnum = 0; // start/end op mark cleared
buf->b_op_end.lnum = 0;
- RESET_FMARK(&buf->b_last_cursor, ((pos_T) {1, 0, 0}), 0); // '" mark
- CLEAR_FMARK(&buf->b_last_insert); // '^ mark
- CLEAR_FMARK(&buf->b_last_change); // '. mark
+ for (int i = 0; i < buf->b_changelistlen; i++) {
+ clear_fmark(&buf->b_changelist[i]);
+ }
buf->b_changelistlen = 0;
}
diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c
index 087d2e677c..b02c18c53b 100644
--- a/src/nvim/mbyte.c
+++ b/src/nvim/mbyte.c
@@ -1,13 +1,6 @@
/*
- * VIM - Vi IMproved by Bram Moolenaar
- * Multibyte extensions partly by Sung-Hoon Baek
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- * See README.txt for an overview of the Vim source code.
- */
-/*
* mbyte.c: Code specifically for handling multi-byte characters.
+ * Multibyte extensions partly by Sung-Hoon Baek
*
* The encoding used in the core is set with 'encoding'. When 'encoding' is
* changed, the following four variables are set (for speed).
@@ -71,7 +64,6 @@
* some commands, like ":menutrans"
*/
-#include <errno.h>
#include <inttypes.h>
#include <stdbool.h>
#include <string.h>
diff --git a/src/nvim/memfile.c b/src/nvim/memfile.c
index b6a341d5e8..3df4cbc4a3 100644
--- a/src/nvim/memfile.c
+++ b/src/nvim/memfile.c
@@ -1,11 +1,3 @@
-/*
- * VIM - Vi IMproved by Bram Moolenaar
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- * See README.txt for an overview of the Vim source code.
- */
-
/// An abstraction to handle blocks of memory which can be stored in a file.
/// This is the implementation of a sort of virtual memory.
///
@@ -44,7 +36,6 @@
/// mf_fullname() make file name full path (use before first :cd)
#include <assert.h>
-#include <errno.h>
#include <inttypes.h>
#include <limits.h>
#include <string.h>
diff --git a/src/nvim/memline.c b/src/nvim/memline.c
index d90e91be5d..c91a25df6e 100644
--- a/src/nvim/memline.c
+++ b/src/nvim/memline.c
@@ -1,11 +1,3 @@
-/*
- * VIM - Vi IMproved by Bram Moolenaar
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- * See README.txt for an overview of the Vim source code.
- */
-
/* for debugging */
/* #define CHECK(c, s) if (c) EMSG(s) */
#define CHECK(c, s)
@@ -406,10 +398,12 @@ void ml_setname(buf_T *buf)
* Try all directories in the 'directory' option.
*/
dirp = p_dir;
+ bool found_existing_dir = false;
for (;; ) {
if (*dirp == NUL) /* tried all directories, fail */
break;
- fname = findswapname(buf, &dirp, mfp->mf_fname);
+ fname = (char_u *)findswapname(buf, (char **)&dirp, (char *)mfp->mf_fname,
+ &found_existing_dir);
/* alloc's fname */
if (dirp == NULL) /* out of memory */
break;
@@ -504,13 +498,15 @@ void ml_open_file(buf_T *buf)
* Try all directories in 'directory' option.
*/
dirp = p_dir;
+ bool found_existing_dir = false;
for (;; ) {
if (*dirp == NUL)
break;
- /* There is a small chance that between choosing the swap file name
- * and creating it, another Vim creates the file. In that case the
- * creation will fail and we will use another directory. */
- fname = findswapname(buf, &dirp, NULL); /* allocates fname */
+ // There is a small chance that between choosing the swap file name
+ // and creating it, another Vim creates the file. In that case the
+ // creation will fail and we will use another directory.
+ fname = (char_u *)findswapname(buf, (char **)&dirp, NULL,
+ &found_existing_dir);
if (dirp == NULL)
break; /* out of memory */
if (fname == NULL)
@@ -2986,7 +2982,7 @@ static void ml_lineadd(buf_T *buf, int count)
* If it worked returns OK and the resolved link in "buf[MAXPATHL]".
* Otherwise returns FAIL.
*/
-int resolve_symlink(char_u *fname, char_u *buf)
+int resolve_symlink(const char_u *fname, char_u *buf)
{
char_u tmp[MAXPATHL];
int ret;
@@ -3222,45 +3218,56 @@ static int do_swapexists(buf_T *buf, char_u *fname)
return 0;
}
-/*
- * Find out what name to use for the swap file for buffer 'buf'.
- *
- * Several names are tried to find one that does not exist
- * Returns the name in allocated memory or NULL.
- * When out of memory "dirp" is set to NULL.
- *
- * Note: If BASENAMELEN is not correct, you will get error messages for
- * not being able to open the swap or undo file
- * Note: May trigger SwapExists autocmd, pointers may change!
- */
-static char_u *
-findswapname (
- buf_T *buf,
- char_u **dirp, /* pointer to list of directories */
- char_u *old_fname /* don't give warning for this file name */
-)
+/// Find out what name to use for the swap file for buffer 'buf'.
+///
+/// Several names are tried to find one that does not exist. Last directory in
+/// option is automatically created.
+///
+/// @note If BASENAMELEN is not correct, you will get error messages for
+/// not being able to open the swap or undo file.
+/// @note May trigger SwapExists autocmd, pointers may change!
+///
+/// @param[in] buf Buffer for which swap file names needs to be found.
+/// @param[in,out] dirp Pointer to a list of directories. When out of memory,
+/// is set to NULL. Is advanced to the next directory in
+/// the list otherwise.
+/// @param[in] old_fname Allowed existing swap file name. Except for this
+/// case, name of the non-existing file is used.
+/// @param[in,out] found_existing_dir If points to true, then new directory
+/// for swap file is not created. At first
+/// findswapname() call this argument must
+/// point to false. This parameter may only
+/// be set to true by this function, it is
+/// never set to false.
+///
+/// @return [allocated] Name of the swap file.
+static char *findswapname(buf_T *buf, char **dirp, char *old_fname,
+ bool *found_existing_dir)
+ FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ARG(1, 2, 4)
{
- char_u *fname;
- int n;
- char_u *dir_name;
- char_u *buf_fname = buf->b_fname;
+ char *fname;
+ size_t n;
+ char *dir_name;
+ char *buf_fname = (char *) buf->b_fname;
/*
* Isolate a directory name from *dirp and put it in dir_name.
* First allocate some memory to put the directory name in.
*/
- dir_name = xmalloc(STRLEN(*dirp) + 1);
- (void)copy_option_part(dirp, dir_name, 31000, ",");
+ const size_t dir_len = strlen(*dirp) + 1;
+ dir_name = xmalloc(dir_len);
+ (void)copy_option_part((char_u **) dirp, (char_u *) dir_name, dir_len, ",");
/*
* we try different names until we find one that does not exist yet
*/
- fname = makeswapname(buf_fname, buf->b_ffname, buf, dir_name);
+ fname = (char *)makeswapname((char_u *)buf_fname, buf->b_ffname, buf,
+ (char_u *)dir_name);
for (;; ) {
if (fname == NULL) /* must be out of memory */
break;
- if ((n = (int)STRLEN(fname)) == 0) { /* safety check */
+ if ((n = strlen(fname)) == 0) { /* safety check */
xfree(fname);
fname = NULL;
break;
@@ -3269,7 +3276,7 @@ findswapname (
// Extra security check: When a swap file is a symbolic link, this
// is most likely a symlink attack.
FileInfo file_info;
- bool file_or_link_found = os_fileinfo_link((char *)fname, &file_info);
+ bool file_or_link_found = os_fileinfo_link(fname, &file_info);
if (!file_or_link_found) {
break;
}
@@ -3300,7 +3307,7 @@ findswapname (
* Try to read block 0 from the swap file to get the original
* file name (and inode number).
*/
- fd = os_open((char *)fname, O_RDONLY, 0);
+ fd = os_open(fname, O_RDONLY, 0);
if (fd >= 0) {
if (read_eintr(fd, &b0, sizeof(b0)) == sizeof(b0)) {
/*
@@ -3311,7 +3318,7 @@ findswapname (
if (b0.b0_flags & B0_SAME_DIR) {
if (fnamecmp(path_tail(buf->b_ffname),
path_tail(b0.b0_fname)) != 0
- || !same_directory(fname, buf->b_ffname)) {
+ || !same_directory((char_u *) fname, buf->b_ffname)) {
/* Symlinks may point to the same file even
* when the name differs, need to check the
* inode too. */
@@ -3351,12 +3358,12 @@ findswapname (
* user anyway.
*/
if (swap_exists_action != SEA_NONE
- && has_autocmd(EVENT_SWAPEXISTS, buf_fname, buf))
- choice = do_swapexists(buf, fname);
+ && has_autocmd(EVENT_SWAPEXISTS, (char_u *) buf_fname, buf))
+ choice = do_swapexists(buf, (char_u *) fname);
if (choice == 0) {
/* Show info about the existing swap file. */
- attention_message(buf, fname);
+ attention_message(buf, (char_u *) fname);
/* We don't want a 'q' typed at the more-prompt
* interrupt loading a file. */
@@ -3364,20 +3371,21 @@ findswapname (
}
if (swap_exists_action != SEA_NONE && choice == 0) {
- char_u *name;
+ char *name;
- name = xmalloc(STRLEN(fname)
- + STRLEN(_("Swap file \""))
- + STRLEN(_("\" already exists!")) + 5);
+ const size_t fname_len = strlen(fname);
+ name = xmalloc(fname_len
+ + strlen(_("Swap file \""))
+ + strlen(_("\" already exists!")) + 5);
STRCPY(name, _("Swap file \""));
- home_replace(NULL, fname, name + STRLEN(name),
- 1000, TRUE);
+ home_replace(NULL, (char_u *) fname, (char_u *)&name[strlen(name)],
+ fname_len, true);
STRCAT(name, _("\" already exists!"));
choice = do_dialog(VIM_WARNING,
(char_u *)_("VIM - ATTENTION"),
- name == NULL
- ? (char_u *)_("Swap file already exists!")
- : name,
+ (char_u *)(name == NULL
+ ? _("Swap file already exists!")
+ : name),
# if defined(UNIX)
process_still_running
? (char_u *)_(
@@ -3409,7 +3417,7 @@ findswapname (
swap_exists_action = SEA_RECOVER;
break;
case 4:
- os_remove((char *)fname);
+ os_remove(fname);
break;
case 5:
swap_exists_action = SEA_QUIT;
@@ -3421,7 +3429,7 @@ findswapname (
}
/* If the file was deleted this fname can be used. */
- if (!os_file_exists(fname))
+ if (!os_file_exists((char_u *) fname))
break;
} else
{
@@ -3454,6 +3462,19 @@ findswapname (
--fname[n - 1]; /* ".swo", ".swn", etc. */
}
+ if (os_isdir((char_u *) dir_name)) {
+ *found_existing_dir = true;
+ } else if (!*found_existing_dir && **dirp == NUL) {
+ int ret;
+ char *failed_dir;
+ if ((ret = os_mkdir_recurse(dir_name, 0755, &failed_dir)) != 0) {
+ EMSG3(_("E303: Unable to create directory \"%s\" for swap file, "
+ "recovery impossible: %s"),
+ failed_dir, os_strerror(ret));
+ xfree(failed_dir);
+ }
+ }
+
xfree(dir_name);
return fname;
}
@@ -3933,8 +3954,10 @@ long ml_find_line_or_offset(buf_T *buf, linenr_T lnum, long *offp)
if (ffdos)
size += lnum - 1;
- /* Don't count the last line break if 'bin' and 'noeol'. */
- if (buf->b_p_bin && !buf->b_p_eol && buf->b_ml.ml_line_count == lnum) {
+ /* Don't count the last line break if 'noeol' and ('bin' or
+ * 'nofixeol'). */
+ if ((!buf->b_p_fixeol || buf->b_p_bin) && !buf->b_p_eol
+ && buf->b_ml.ml_line_count == lnum) {
size -= ffdos + 1;
}
}
diff --git a/src/nvim/memline_defs.h b/src/nvim/memline_defs.h
index bcc1c673d2..34a002af5d 100644
--- a/src/nvim/memline_defs.h
+++ b/src/nvim/memline_defs.h
@@ -41,7 +41,7 @@ typedef struct memline {
int ml_flags;
infoptr_T *ml_stack; /* stack of pointer blocks (array of IPTRs) */
- int ml_stack_top; /* current top if ml_stack */
+ int ml_stack_top; /* current top of ml_stack */
int ml_stack_size; /* total number of entries in ml_stack */
linenr_T ml_line_lnum; /* line number of cached line, 0 if not valid */
diff --git a/src/nvim/memory.c b/src/nvim/memory.c
index d25dc7c941..8db47b79c1 100644
--- a/src/nvim/memory.c
+++ b/src/nvim/memory.c
@@ -1,7 +1,6 @@
// Various routines dealing with allocation and deallocation of memory.
#include <assert.h>
-#include <errno.h>
#include <inttypes.h>
#include <string.h>
#include <stdbool.h>
@@ -42,8 +41,6 @@ void try_to_free_memory(void)
clear_sb_text();
// Try to save all buffers and release as many blocks as possible
mf_release_all();
- // cleanup recursive lists/dicts
- garbage_collect();
trying_to_free = false;
}
diff --git a/src/nvim/menu.c b/src/nvim/menu.c
index 9857b8a778..91a72abfc5 100644
--- a/src/nvim/menu.c
+++ b/src/nvim/menu.c
@@ -1,14 +1,6 @@
/*
- * VIM - Vi IMproved by Bram Moolenaar
- * GUI/Motif support by Robert Webb
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- * See README.txt for an overview of the Vim source code.
- */
-
-/*
* Code for menus. Used for the GUI and 'wildmenu'.
+ * GUI/Motif support by Robert Webb
*/
#include <assert.h>
diff --git a/src/nvim/message.c b/src/nvim/message.c
index 5f06506a31..66b8b9b5d2 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -1,17 +1,8 @@
/*
- * VIM - Vi IMproved by Bram Moolenaar
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- * See README.txt for an overview of the Vim source code.
- */
-
-/*
* message.c: functions for displaying messages on the command line
*/
#include <assert.h>
-#include <errno.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdarg.h>
diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c
index 6829e4988c..96ef6cbaef 100644
--- a/src/nvim/misc1.c
+++ b/src/nvim/misc1.c
@@ -1,17 +1,8 @@
/*
- * VIM - Vi IMproved by Bram Moolenaar
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- * See README.txt for an overview of the Vim source code.
- */
-
-/*
* misc1.c: functions that didn't seem to fit elsewhere
*/
#include <assert.h>
-#include <errno.h>
#include <inttypes.h>
#include <stdbool.h>
#include <string.h>
@@ -19,7 +10,6 @@
#include "nvim/vim.h"
#include "nvim/ascii.h"
-#include "nvim/version.h"
#include "nvim/misc1.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
diff --git a/src/nvim/misc2.c b/src/nvim/misc2.c
index d9bc35470f..3c0a1414a6 100644
--- a/src/nvim/misc2.c
+++ b/src/nvim/misc2.c
@@ -1,16 +1,7 @@
/*
- * VIM - Vi IMproved by Bram Moolenaar
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- * See README.txt for an overview of the Vim source code.
- */
-
-/*
* misc2.c: Various functions.
*/
#include <assert.h>
-#include <errno.h>
#include <inttypes.h>
#include <string.h>
@@ -479,7 +470,7 @@ void put_time(FILE *fd, time_t time_)
{
uint8_t buf[8];
time_to_bytes(time_, buf);
- fwrite(buf, sizeof(uint8_t), ARRAY_SIZE(buf), fd);
+ (void)fwrite(buf, sizeof(uint8_t), ARRAY_SIZE(buf), fd);
}
/// Writes time_t to "buf[8]".
diff --git a/src/nvim/move.c b/src/nvim/move.c
index 3831004703..eb55397511 100644
--- a/src/nvim/move.c
+++ b/src/nvim/move.c
@@ -1,11 +1,4 @@
/*
- * VIM - Vi IMproved by Bram Moolenaar
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- * See README.txt for an overview of the Vim source code.
- */
-/*
* move.c: Functions for moving the cursor and scrolling text.
*
* There are two ways to move the cursor:
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index 713aa55500..a2e473fcb8 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -1,18 +1,10 @@
/*
- * VIM - Vi IMproved by Bram Moolenaar
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- * See README.txt for an overview of the Vim source code.
- */
-/*
* normal.c: Contains the main routine for processing characters in command
* mode. Communicates closely with the code in ops.c to handle
* the operators.
*/
#include <assert.h>
-#include <errno.h>
#include <inttypes.h>
#include <string.h>
#include <stdbool.h>
@@ -61,10 +53,35 @@
#include "nvim/mouse.h"
#include "nvim/undo.h"
#include "nvim/window.h"
+#include "nvim/state.h"
#include "nvim/event/loop.h"
#include "nvim/os/time.h"
#include "nvim/os/input.h"
+typedef struct normal_state {
+ VimState state;
+ linenr_T conceal_old_cursor_line;
+ linenr_T conceal_new_cursor_line;
+ bool command_finished;
+ bool ctrl_w;
+ bool need_flushbuf;
+ bool conceal_update_lines;
+ bool set_prevcount;
+ bool previous_got_int; // `got_int` was true
+ bool cmdwin; // command-line window normal mode
+ bool noexmode; // true if the normal mode was pushed from
+ // ex mode(:global or :visual for example)
+ bool toplevel; // top-level normal mode
+ oparg_T oa; // operator arguments
+ cmdarg_T ca; // command arguments
+ int mapped_len;
+ int old_mapped_len;
+ int idx;
+ int c;
+ int old_col;
+ pos_T old_pos;
+} NormalState;
+
/*
* The Visual area is remembered for reselection.
*/
@@ -79,6 +96,14 @@ static int restart_VIsual_select = 0;
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "normal.c.generated.h"
#endif
+
+static inline void normal_state_init(NormalState *s)
+{
+ memset(s, 0, sizeof(NormalState));
+ s->state.check = normal_check;
+ s->state.execute = normal_execute;
+}
+
/*
* nv_*(): functions called to handle Normal and Visual mode commands.
* n_*(): functions called to handle Normal mode commands.
@@ -315,7 +340,9 @@ static const struct nv_cmd {
{K_SELECT, nv_select, 0, 0},
{K_F8, farsi_fkey, 0, 0},
{K_F9, farsi_fkey, 0, 0},
- {K_CURSORHOLD, nv_cursorhold, NV_KEEPREG, 0},
+ {K_EVENT, nv_event, NV_KEEPREG, 0},
+ {K_FOCUSGAINED, nv_focusgained, NV_KEEPREG, 0},
+ {K_FOCUSLOST, nv_focuslost, NV_KEEPREG, 0},
};
/* Number of commands in nv_cmds[]. */
@@ -418,650 +445,946 @@ static int find_command(int cmdchar)
return idx;
}
-/*
- * Execute a command in Normal mode.
- */
-void
-normal_cmd (
- oparg_T *oap,
- bool toplevel /* true when called from main() */
-)
-{
- cmdarg_T ca; /* command arguments */
- int c;
- bool ctrl_w = false; /* got CTRL-W command */
- int old_col = curwin->w_curswant;
- bool need_flushbuf; /* need to call ui_flush() */
- pos_T old_pos; /* cursor position before command */
- int mapped_len;
- static int old_mapped_len = 0;
- int idx;
- bool set_prevcount = false;
+// Normal state entry point. This is called on:
+//
+// - Startup, In this case the function never returns.
+// - The command-line window is opened(`q:`). Returns when `cmdwin_result` != 0.
+// - The :visual command is called from :global in ex mode, `:global/PAT/visual`
+// for example. Returns when re-entering ex mode(because ex mode recursion is
+// not allowed)
+//
+// This used to be called main_loop on main.c
+void normal_enter(bool cmdwin, bool noexmode)
+{
+ NormalState state;
+ normal_state_init(&state);
+ state.cmdwin = cmdwin;
+ state.noexmode = noexmode;
+ state.toplevel = !cmdwin && !noexmode;
+ state_enter(&state.state);
+}
+
+static void normal_prepare(NormalState *s)
+{
+ memset(&s->ca, 0, sizeof(s->ca)); // also resets ca.retval
+ s->ca.oap = &s->oa;
+
+ // Use a count remembered from before entering an operator. After typing "3d"
+ // we return from normal_cmd() and come back here, the "3" is remembered in
+ // "opcount".
+ s->ca.opcount = opcount;
+
+ // If there is an operator pending, then the command we take this time will
+ // terminate it. Finish_op tells us to finish the operation before returning
+ // this time (unless the operation was cancelled).
+ int c = finish_op;
+ finish_op = (s->oa.op_type != OP_NOP);
+ if (finish_op != c) {
+ ui_cursor_shape(); // may show different cursor shape
+ }
- memset(&ca, 0, sizeof(ca)); /* also resets ca.retval */
- ca.oap = oap;
+ // When not finishing an operator and no register name typed, reset the count.
+ if (!finish_op && !s->oa.regname) {
+ s->ca.opcount = 0;
+ s->set_prevcount = true;
+ }
- /* Use a count remembered from before entering an operator. After typing
- * "3d" we return from normal_cmd() and come back here, the "3" is
- * remembered in "opcount". */
- ca.opcount = opcount;
+ // Restore counts from before receiving K_EVENT. This means after
+ // typing "3", handling K_EVENT and then typing "2" we get "32", not
+ // "3 * 2".
+ if (s->oa.prev_opcount > 0 || s->oa.prev_count0 > 0) {
+ s->ca.opcount = s->oa.prev_opcount;
+ s->ca.count0 = s->oa.prev_count0;
+ s->oa.prev_opcount = 0;
+ s->oa.prev_count0 = 0;
+ }
+ s->mapped_len = typebuf_maplen();
+ State = NORMAL_BUSY;
- /*
- * If there is an operator pending, then the command we take this time
- * will terminate it. Finish_op tells us to finish the operation before
- * returning this time (unless the operation was cancelled).
- */
- c = finish_op;
- finish_op = (oap->op_type != OP_NOP);
- if (finish_op != c) {
- ui_cursor_shape(); /* may show different cursor shape */
+ // Set v:count here, when called from main() and not a stuffed command, so
+ // that v:count can be used in an expression mapping when there is no count.
+ // Do set it for redo
+ if (s->toplevel && readbuf1_empty()) {
+ set_vcount_ca(&s->ca, &s->set_prevcount);
}
+}
- /* When not finishing an operator and no register name typed, reset the
- * count. */
- if (!finish_op && !oap->regname) {
- ca.opcount = 0;
- set_prevcount = true;
+static bool normal_handle_special_visual_command(NormalState *s)
+{
+ // when 'keymodel' contains "stopsel" may stop Select/Visual mode
+ if (km_stopsel
+ && (nv_cmds[s->idx].cmd_flags & NV_STS)
+ && !(mod_mask & MOD_MASK_SHIFT)) {
+ end_visual_mode();
+ redraw_curbuf_later(INVERTED);
}
- /* Restore counts from before receiving K_CURSORHOLD. This means after
- * typing "3", handling K_CURSORHOLD and then typing "2" we get "32", not
- * "3 * 2". */
- if (oap->prev_opcount > 0 || oap->prev_count0 > 0) {
- ca.opcount = oap->prev_opcount;
- ca.count0 = oap->prev_count0;
- oap->prev_opcount = 0;
- oap->prev_count0 = 0;
+ // Keys that work different when 'keymodel' contains "startsel"
+ if (km_startsel) {
+ if (nv_cmds[s->idx].cmd_flags & NV_SS) {
+ unshift_special(&s->ca);
+ s->idx = find_command(s->ca.cmdchar);
+ if (s->idx < 0) {
+ // Just in case
+ clearopbeep(&s->oa);
+ return true;
+ }
+ } else if ((nv_cmds[s->idx].cmd_flags & NV_SSS)
+ && (mod_mask & MOD_MASK_SHIFT)) {
+ mod_mask &= ~MOD_MASK_SHIFT;
+ }
}
+ return false;
+}
- mapped_len = typebuf_maplen();
+static bool normal_need_aditional_char(NormalState *s)
+{
+ int flags = nv_cmds[s->idx].cmd_flags;
+ bool pending_op = s->oa.op_type != OP_NOP;
+ int cmdchar = s->ca.cmdchar;
+ return
+ // without NV_NCH we never need to check for an additional char
+ flags & NV_NCH && (
+ // NV_NCH_NOP is set and no operator is pending, get a second char
+ ((flags & NV_NCH_NOP) == NV_NCH_NOP && !pending_op)
+ // NV_NCH_ALW is set, always get a second char
+ || (flags & NV_NCH_ALW) == NV_NCH_ALW
+ // 'q' without a pending operator, recording or executing a register,
+ // needs to be followed by a second char, examples:
+ // - qc => record using register c
+ // - q: => open command-line window
+ || (cmdchar == 'q' && !pending_op && !Recording && !Exec_reg)
+ // 'a' or 'i' after an operator is a text object, examples:
+ // - ciw => change inside word
+ // - da( => delete parenthesis and everything inside.
+ // Also, don't do anything when these keys are received in visual mode
+ // so just get another char.
+ //
+ // TODO(tarruda): Visual state needs to be refactored into a
+ // separate state that "inherits" from normal state.
+ || ((cmdchar == 'a' || cmdchar == 'i') && (pending_op || VIsual_active)));
+}
+
+static bool normal_need_redraw_mode_message(NormalState *s)
+{
+ return (
+ (
+ // 'showmode' is set and messages can be printed
+ p_smd && msg_silent == 0
+ // must restart insert mode(ctrl+o or ctrl+l) or we just entered visual
+ // mode
+ && (restart_edit != 0 || (VIsual_active
+ && s->old_pos.lnum == curwin->w_cursor.lnum
+ && s->old_pos.col == curwin->w_cursor.col))
+ // command-line must be cleared or redrawn
+ && (clear_cmdline || redraw_cmdline)
+ // some message was printed or scrolled
+ && (msg_didout || (msg_didany && msg_scroll))
+ // it is fine to remove the current message
+ && !msg_nowait
+ // the command was the result of direct user input and not a mapping
+ && KeyTyped
+ )
+ ||
+ // must restart insert mode, not in visual mode and error message is
+ // being shown
+ (restart_edit != 0 && !VIsual_active && (msg_scroll && emsg_on_display))
+ )
+ // no register was used
+ && s->oa.regname == 0
+ && !(s->ca.retval & CA_COMMAND_BUSY)
+ && stuff_empty()
+ && typebuf_typed()
+ && emsg_silent == 0
+ && !did_wait_return
+ && s->oa.op_type == OP_NOP;
+}
+
+static void normal_redraw_mode_message(NormalState *s)
+{
+ int save_State = State;
+
+ // Draw the cursor with the right shape here
+ if (restart_edit != 0) {
+ State = INSERT;
+ }
+
+ // If need to redraw, and there is a "keep_msg", redraw before the
+ // delay
+ if (must_redraw && keep_msg != NULL && !emsg_on_display) {
+ char_u *kmsg;
+
+ kmsg = keep_msg;
+ keep_msg = NULL;
+ // showmode() will clear keep_msg, but we want to use it anyway
+ update_screen(0);
+ // now reset it, otherwise it's put in the history again
+ keep_msg = kmsg;
+ msg_attr(kmsg, keep_msg_attr);
+ xfree(kmsg);
+ }
+ setcursor();
+ ui_flush();
+ if (msg_scroll || emsg_on_display) {
+ os_delay(1000L, true); // wait at least one second
+ }
+ os_delay(3000L, false); // wait up to three seconds
+ State = save_State;
+
+ msg_scroll = false;
+ emsg_on_display = false;
+}
+
+// TODO(tarruda): Split into a "normal pending" state that can handle K_EVENT
+static void normal_get_additional_char(NormalState *s)
+{
+ int *cp;
+ bool repl = false; // get character for replace mode
+ bool lit = false; // get extra character literally
+ bool langmap_active = false; // using :lmap mappings
+ int lang; // getting a text character
+
+ ++no_mapping;
+ ++allow_keys; // no mapping for nchar, but allow key codes
+ // Don't generate a CursorHold event here, most commands can't handle
+ // it, e.g., nv_replace(), nv_csearch().
+ did_cursorhold = true;
+ if (s->ca.cmdchar == 'g') {
+ // For 'g' get the next character now, so that we can check for
+ // "gr", "g'" and "g`".
+ s->ca.nchar = plain_vgetc();
+ LANGMAP_ADJUST(s->ca.nchar, true);
+ s->need_flushbuf |= add_to_showcmd(s->ca.nchar);
+ if (s->ca.nchar == 'r' || s->ca.nchar == '\'' || s->ca.nchar == '`'
+ || s->ca.nchar == Ctrl_BSL) {
+ cp = &s->ca.extra_char; // need to get a third character
+ if (s->ca.nchar != 'r') {
+ lit = true; // get it literally
+ } else {
+ repl = true; // get it in replace mode
+ }
+ } else {
+ cp = NULL; // no third character needed
+ }
+ } else {
+ if (s->ca.cmdchar == 'r') {
+ // get it in replace mode
+ repl = true;
+ }
+ cp = &s->ca.nchar;
+ }
+ lang = (repl || (nv_cmds[s->idx].cmd_flags & NV_LANG));
- State = NORMAL_BUSY;
+ // Get a second or third character.
+ if (cp != NULL) {
+ if (repl) {
+ State = REPLACE; // pretend Replace mode
+ ui_cursor_shape(); // show different cursor shape
+ }
+ if (lang && curbuf->b_p_iminsert == B_IMODE_LMAP) {
+ // Allow mappings defined with ":lmap".
+ --no_mapping;
+ --allow_keys;
+ if (repl) {
+ State = LREPLACE;
+ } else {
+ State = LANGMAP;
+ }
+ langmap_active = true;
+ }
- /* Set v:count here, when called from main() and not a stuffed
- * command, so that v:count can be used in an expression mapping
- * when there is no count. Do set it for redo. */
- if (toplevel && readbuf1_empty())
- set_vcount_ca(&ca, &set_prevcount);
+ *cp = plain_vgetc();
- /*
- * Get the command character from the user.
- */
- input_enable_events();
- c = safe_vgetc();
- input_disable_events();
+ if (langmap_active) {
+ // Undo the decrement done above
+ ++no_mapping;
+ ++allow_keys;
+ State = NORMAL_BUSY;
+ }
+ State = NORMAL_BUSY;
+ s->need_flushbuf |= add_to_showcmd(*cp);
+
+ if (!lit) {
+ // Typing CTRL-K gets a digraph.
+ if (*cp == Ctrl_K && ((nv_cmds[s->idx].cmd_flags & NV_LANG)
+ || cp == &s->ca.extra_char)
+ && vim_strchr(p_cpo, CPO_DIGRAPH) == NULL) {
+ s->c = get_digraph(false);
+ if (s->c > 0) {
+ *cp = s->c;
+ // Guessing how to update showcmd here...
+ del_from_showcmd(3);
+ s->need_flushbuf |= add_to_showcmd(*cp);
+ }
+ }
- if (c == K_EVENT) {
- queue_process_events(loop.events);
- return;
- }
+ // adjust chars > 127, except after "tTfFr" commands
+ LANGMAP_ADJUST(*cp, !lang);
+ // adjust Hebrew mapped char
+ if (p_hkmap && lang && KeyTyped) {
+ *cp = hkmap(*cp);
+ }
+ // adjust Farsi mapped char
+ if (p_fkmap && lang && KeyTyped) {
+ *cp = fkmap(*cp);
+ }
+ }
- LANGMAP_ADJUST(c, true);
+ // When the next character is CTRL-\ a following CTRL-N means the
+ // command is aborted and we go to Normal mode.
+ if (cp == &s->ca.extra_char
+ && s->ca.nchar == Ctrl_BSL
+ && (s->ca.extra_char == Ctrl_N || s->ca.extra_char == Ctrl_G)) {
+ s->ca.cmdchar = Ctrl_BSL;
+ s->ca.nchar = s->ca.extra_char;
+ s->idx = find_command(s->ca.cmdchar);
+ } else if ((s->ca.nchar == 'n' || s->ca.nchar == 'N')
+ && s->ca.cmdchar == 'g') {
+ s->ca.oap->op_type = get_op_type(*cp, NUL);
+ } else if (*cp == Ctrl_BSL) {
+ long towait = (p_ttm >= 0 ? p_ttm : p_tm);
+
+ // There is a busy wait here when typing "f<C-\>" and then
+ // something different from CTRL-N. Can't be avoided.
+ while ((s->c = vpeekc()) <= 0 && towait > 0L) {
+ do_sleep(towait > 50L ? 50L : towait);
+ towait -= 50L;
+ }
+ if (s->c > 0) {
+ s->c = plain_vgetc();
+ if (s->c != Ctrl_N && s->c != Ctrl_G) {
+ vungetc(s->c);
+ } else {
+ s->ca.cmdchar = Ctrl_BSL;
+ s->ca.nchar = s->c;
+ s->idx = find_command(s->ca.cmdchar);
+ assert(s->idx >= 0);
+ }
+ }
+ }
- /*
- * If a mapping was started in Visual or Select mode, remember the length
- * of the mapping. This is used below to not return to Insert mode for as
- * long as the mapping is being executed.
- */
- if (restart_edit == 0)
- old_mapped_len = 0;
- else if (old_mapped_len
- || (VIsual_active && mapped_len == 0 && typebuf_maplen() > 0))
- old_mapped_len = typebuf_maplen();
+ // When getting a text character and the next character is a
+ // multi-byte character, it could be a composing character.
+ // However, don't wait for it to arrive. Also, do enable mapping,
+ // because if it's put back with vungetc() it's too late to apply
+ // mapping.
+ no_mapping--;
+ while (enc_utf8 && lang && (s->c = vpeekc()) > 0
+ && (s->c >= 0x100 || MB_BYTE2LEN(vpeekc()) > 1)) {
+ s->c = plain_vgetc();
+ if (!utf_iscomposing(s->c)) {
+ vungetc(s->c); /* it wasn't, put it back */
+ break;
+ } else if (s->ca.ncharC1 == 0) {
+ s->ca.ncharC1 = s->c;
+ } else {
+ s->ca.ncharC2 = s->c;
+ }
+ }
+ no_mapping++;
+ }
+ --no_mapping;
+ --allow_keys;
+}
- if (c == NUL)
- c = K_ZERO;
+static void normal_invert_horizontal(NormalState *s)
+{
+ switch (s->ca.cmdchar) {
+ case 'l': s->ca.cmdchar = 'h'; break;
+ case K_RIGHT: s->ca.cmdchar = K_LEFT; break;
+ case K_S_RIGHT: s->ca.cmdchar = K_S_LEFT; break;
+ case K_C_RIGHT: s->ca.cmdchar = K_C_LEFT; break;
+ case 'h': s->ca.cmdchar = 'l'; break;
+ case K_LEFT: s->ca.cmdchar = K_RIGHT; break;
+ case K_S_LEFT: s->ca.cmdchar = K_S_RIGHT; break;
+ case K_C_LEFT: s->ca.cmdchar = K_C_RIGHT; break;
+ case '>': s->ca.cmdchar = '<'; break;
+ case '<': s->ca.cmdchar = '>'; break;
+ }
+ s->idx = find_command(s->ca.cmdchar);
+}
- /*
- * In Select mode, typed text replaces the selection.
- */
- if (VIsual_active
- && VIsual_select
- && (vim_isprintc(c) || c == NL || c == CAR || c == K_KENTER)) {
- /* Fake a "c"hange command. When "restart_edit" is set (e.g., because
- * 'insertmode' is set) fake a "d"elete command, Insert mode will
- * restart automatically.
- * Insert the typed character in the typeahead buffer, so that it can
- * be mapped in Insert mode. Required for ":lmap" to work. */
- ins_char_typebuf(c);
- if (restart_edit != 0)
- c = 'd';
- else
- c = 'c';
- msg_nowait = true; /* don't delay going to insert mode */
- old_mapped_len = 0; /* do go to Insert mode */
+static bool normal_get_command_count(NormalState *s)
+{
+ if (VIsual_active && VIsual_select) {
+ return false;
}
+ // Handle a count before a command and compute ca.count0.
+ // Note that '0' is a command and not the start of a count, but it's
+ // part of a count after other digits.
+ while ((s->c >= '1' && s->c <= '9') || (s->ca.count0 != 0
+ && (s->c == K_DEL || s->c == K_KDEL || s->c == '0'))) {
+ if (s->c == K_DEL || s->c == K_KDEL) {
+ s->ca.count0 /= 10;
+ del_from_showcmd(4); // delete the digit and ~@%
+ } else {
+ s->ca.count0 = s->ca.count0 * 10 + (s->c - '0');
+ }
- need_flushbuf = add_to_showcmd(c);
+ if (s->ca.count0 < 0) {
+ // got too large!
+ s->ca.count0 = 999999999L;
+ }
-getcount:
- if (!(VIsual_active && VIsual_select)) {
- /*
- * Handle a count before a command and compute ca.count0.
- * Note that '0' is a command and not the start of a count, but it's
- * part of a count after other digits.
- */
- while ( (c >= '1' && c <= '9')
- || (ca.count0 != 0 &&
- (c == K_DEL || c == K_KDEL || c == '0'))) {
- if (c == K_DEL || c == K_KDEL) {
- ca.count0 /= 10;
- del_from_showcmd(4); /* delete the digit and ~@% */
- } else
- ca.count0 = ca.count0 * 10 + (c - '0');
- if (ca.count0 < 0) /* got too large! */
- ca.count0 = 999999999L;
- /* Set v:count here, when called from main() and not a stuffed
- * command, so that v:count can be used in an expression mapping
- * right after the count. Do set it for redo. */
- if (toplevel && readbuf1_empty())
- set_vcount_ca(&ca, &set_prevcount);
- if (ctrl_w) {
- ++no_mapping;
- ++allow_keys; /* no mapping for nchar, but keys */
- }
- ++no_zero_mapping; /* don't map zero here */
- c = plain_vgetc();
- LANGMAP_ADJUST(c, true);
- --no_zero_mapping;
- if (ctrl_w) {
- --no_mapping;
- --allow_keys;
- }
- need_flushbuf |= add_to_showcmd(c);
+ // Set v:count here, when called from main() and not a stuffed
+ // command, so that v:count can be used in an expression mapping
+ // right after the count. Do set it for redo.
+ if (s->toplevel && readbuf1_empty()) {
+ set_vcount_ca(&s->ca, &s->set_prevcount);
}
- /*
- * If we got CTRL-W there may be a/another count
- */
- if (c == Ctrl_W && !ctrl_w && oap->op_type == OP_NOP) {
- ctrl_w = true;
- ca.opcount = ca.count0; /* remember first count */
- ca.count0 = 0;
+ if (s->ctrl_w) {
++no_mapping;
- ++allow_keys; /* no mapping for nchar, but keys */
- c = plain_vgetc(); /* get next character */
- LANGMAP_ADJUST(c, true);
+ ++allow_keys; // no mapping for nchar, but keys
+ }
+
+ ++no_zero_mapping; // don't map zero here
+ s->c = plain_vgetc();
+ LANGMAP_ADJUST(s->c, true);
+ --no_zero_mapping;
+ if (s->ctrl_w) {
--no_mapping;
--allow_keys;
- need_flushbuf |= add_to_showcmd(c);
- goto getcount; /* jump back */
}
+ s->need_flushbuf |= add_to_showcmd(s->c);
}
- if (c == K_CURSORHOLD) {
- /* Save the count values so that ca.opcount and ca.count0 are exactly
- * the same when coming back here after handling K_CURSORHOLD. */
- oap->prev_opcount = ca.opcount;
- oap->prev_count0 = ca.count0;
- } else if (ca.opcount != 0) {
- /*
- * If we're in the middle of an operator (including after entering a
- * yank buffer with '"') AND we had a count before the operator, then
- * that count overrides the current value of ca.count0.
- * What this means effectively, is that commands like "3dw" get turned
- * into "d3w" which makes things fall into place pretty neatly.
- * If you give a count before AND after the operator, they are
- * multiplied.
- */
- if (ca.count0)
- ca.count0 *= ca.opcount;
- else
- ca.count0 = ca.opcount;
+ // If we got CTRL-W there may be a/another count
+ if (s->c == Ctrl_W && !s->ctrl_w && s->oa.op_type == OP_NOP) {
+ s->ctrl_w = true;
+ s->ca.opcount = s->ca.count0; // remember first count
+ s->ca.count0 = 0;
+ ++no_mapping;
+ ++allow_keys; // no mapping for nchar, but keys
+ s->c = plain_vgetc(); // get next character
+ LANGMAP_ADJUST(s->c, true);
+ --no_mapping;
+ --allow_keys;
+ s->need_flushbuf |= add_to_showcmd(s->c);
+ return true;
}
- /*
- * Always remember the count. It will be set to zero (on the next call,
- * above) when there is no pending operator.
- * When called from main(), save the count for use by the "count" built-in
- * variable.
- */
- ca.opcount = ca.count0;
- ca.count1 = (ca.count0 == 0 ? 1 : ca.count0);
-
- /*
- * Only set v:count when called from main() and not a stuffed command.
- * Do set it for redo.
- */
- if (toplevel && readbuf1_empty())
- set_vcount(ca.count0, ca.count1, set_prevcount);
+ return false;
+}
- /*
- * Find the command character in the table of commands.
- * For CTRL-W we already got nchar when looking for a count.
- */
- if (ctrl_w) {
- ca.nchar = c;
- ca.cmdchar = Ctrl_W;
- } else
- ca.cmdchar = c;
- idx = find_command(ca.cmdchar);
- if (idx < 0) {
- /* Not a known command: beep. */
- clearopbeep(oap);
+static void normal_finish_command(NormalState *s)
+{
+ if (s->command_finished) {
goto normal_end;
}
- if (text_locked() && (nv_cmds[idx].cmd_flags & NV_NCW)) {
- // This command is not allowed while editing a cmdline: beep.
- clearopbeep(oap);
- text_locked_msg();
- goto normal_end;
+ // If we didn't start or finish an operator, reset oap->regname, unless we
+ // need it later.
+ if (!finish_op
+ && !s->oa.op_type
+ && (s->idx < 0 || !(nv_cmds[s->idx].cmd_flags & NV_KEEPREG))) {
+ clearop(&s->oa);
+ set_reg_var(get_default_register_name());
}
- if ((nv_cmds[idx].cmd_flags & NV_NCW) && curbuf_locked())
- goto normal_end;
- /*
- * In Visual/Select mode, a few keys are handled in a special way.
- */
- if (VIsual_active) {
- /* when 'keymodel' contains "stopsel" may stop Select/Visual mode */
- if (km_stopsel
- && (nv_cmds[idx].cmd_flags & NV_STS)
- && !(mod_mask & MOD_MASK_SHIFT)) {
- end_visual_mode();
- redraw_curbuf_later(INVERTED);
- }
+ // Get the length of mapped chars again after typing a count, second
+ // character or "z333<cr>".
+ if (s->old_mapped_len > 0) {
+ s->old_mapped_len = typebuf_maplen();
+ }
- /* Keys that work different when 'keymodel' contains "startsel" */
- if (km_startsel) {
- if (nv_cmds[idx].cmd_flags & NV_SS) {
- unshift_special(&ca);
- idx = find_command(ca.cmdchar);
- if (idx < 0) {
- /* Just in case */
- clearopbeep(oap);
- goto normal_end;
- }
- } else if ((nv_cmds[idx].cmd_flags & NV_SSS)
- && (mod_mask & MOD_MASK_SHIFT)) {
- mod_mask &= ~MOD_MASK_SHIFT;
- }
+ // If an operation is pending, handle it...
+ do_pending_operator(&s->ca, s->old_col, false);
+
+ // Wait for a moment when a message is displayed that will be overwritten
+ // by the mode message.
+ // In Visual mode and with "^O" in Insert mode, a short message will be
+ // overwritten by the mode message. Wait a bit, until a key is hit.
+ // In Visual mode, it's more important to keep the Visual area updated
+ // than keeping a message (e.g. from a /pat search).
+ // Only do this if the command was typed, not from a mapping.
+ // Don't wait when emsg_silent is non-zero.
+ // Also wait a bit after an error message, e.g. for "^O:".
+ // Don't redraw the screen, it would remove the message.
+ if (normal_need_redraw_mode_message(s)) {
+ normal_redraw_mode_message(s);
+ }
+
+ // Finish up after executing a Normal mode command.
+normal_end:
+
+ msg_nowait = false;
+
+ // Reset finish_op, in case it was set
+ s->c = finish_op;
+ finish_op = false;
+ // Redraw the cursor with another shape, if we were in Operator-pending
+ // mode or did a replace command.
+ if (s->c || s->ca.cmdchar == 'r') {
+ ui_cursor_shape(); // may show different cursor shape
+ }
+
+ if (s->oa.op_type == OP_NOP && s->oa.regname == 0
+ && s->ca.cmdchar != K_EVENT) {
+ clear_showcmd();
+ }
+
+ checkpcmark(); // check if we moved since setting pcmark
+ xfree(s->ca.searchbuf);
+
+ if (has_mbyte) {
+ mb_adjust_cursor();
+ }
+
+ if (curwin->w_p_scb && s->toplevel) {
+ validate_cursor(); // may need to update w_leftcol
+ do_check_scrollbind(true);
+ }
+
+ if (curwin->w_p_crb && s->toplevel) {
+ validate_cursor(); // may need to update w_leftcol
+ do_check_cursorbind();
+ }
+
+ // May restart edit(), if we got here with CTRL-O in Insert mode (but not
+ // if still inside a mapping that started in Visual mode).
+ // May switch from Visual to Select mode after CTRL-O command.
+ if (s->oa.op_type == OP_NOP
+ && ((restart_edit != 0 && !VIsual_active && s->old_mapped_len == 0)
+ || restart_VIsual_select == 1)
+ && !(s->ca.retval & CA_COMMAND_BUSY)
+ && stuff_empty()
+ && s->oa.regname == 0) {
+ if (restart_VIsual_select == 1) {
+ VIsual_select = true;
+ showmode();
+ restart_VIsual_select = 0;
+ }
+ if (restart_edit != 0 && !VIsual_active && s->old_mapped_len == 0) {
+ (void)edit(restart_edit, false, 1L);
}
}
- if (curwin->w_p_rl && KeyTyped && !KeyStuffed
- && (nv_cmds[idx].cmd_flags & NV_RL)) {
- /* Invert horizontal movements and operations. Only when typed by the
- * user directly, not when the result of a mapping or "x" translated
- * to "dl". */
- switch (ca.cmdchar) {
- case 'l': ca.cmdchar = 'h'; break;
- case K_RIGHT: ca.cmdchar = K_LEFT; break;
- case K_S_RIGHT: ca.cmdchar = K_S_LEFT; break;
- case K_C_RIGHT: ca.cmdchar = K_C_LEFT; break;
- case 'h': ca.cmdchar = 'l'; break;
- case K_LEFT: ca.cmdchar = K_RIGHT; break;
- case K_S_LEFT: ca.cmdchar = K_S_RIGHT; break;
- case K_C_LEFT: ca.cmdchar = K_C_RIGHT; break;
- case '>': ca.cmdchar = '<'; break;
- case '<': ca.cmdchar = '>'; break;
- }
- idx = find_command(ca.cmdchar);
+ if (restart_VIsual_select == 2) {
+ restart_VIsual_select = 1;
}
- /*
- * Get an additional character if we need one.
- */
- if ((nv_cmds[idx].cmd_flags & NV_NCH)
- && (((nv_cmds[idx].cmd_flags & NV_NCH_NOP) == NV_NCH_NOP
- && oap->op_type == OP_NOP)
- || (nv_cmds[idx].cmd_flags & NV_NCH_ALW) == NV_NCH_ALW
- || (ca.cmdchar == 'q'
- && oap->op_type == OP_NOP
- && !Recording
- && !Exec_reg)
- || ((ca.cmdchar == 'a' || ca.cmdchar == 'i')
- && (oap->op_type != OP_NOP
- || VIsual_active
- )))) {
- int *cp;
- bool repl = false; /* get character for replace mode */
- bool lit = false; /* get extra character literally */
- bool langmap_active = false; /* using :lmap mappings */
- int lang; /* getting a text character */
+ // Save count before an operator for next time
+ opcount = s->ca.opcount;
+}
- ++no_mapping;
- ++allow_keys; /* no mapping for nchar, but allow key codes */
- /* Don't generate a CursorHold event here, most commands can't handle
- * it, e.g., nv_replace(), nv_csearch(). */
- did_cursorhold = true;
- if (ca.cmdchar == 'g') {
- /*
- * For 'g' get the next character now, so that we can check for
- * "gr", "g'" and "g`".
- */
- ca.nchar = plain_vgetc();
- LANGMAP_ADJUST(ca.nchar, true);
- need_flushbuf |= add_to_showcmd(ca.nchar);
- if (ca.nchar == 'r' || ca.nchar == '\'' || ca.nchar == '`'
- || ca.nchar == Ctrl_BSL) {
- cp = &ca.extra_char; /* need to get a third character */
- if (ca.nchar != 'r')
- lit = true; /* get it literally */
- else
- repl = true; /* get it in replace mode */
- } else
- cp = NULL; /* no third character needed */
+static int normal_execute(VimState *state, int key)
+{
+ NormalState *s = (NormalState *)state;
+ s->command_finished = false;
+ s->ctrl_w = false; /* got CTRL-W command */
+ s->old_col = curwin->w_curswant;
+ s->c = key;
+
+ LANGMAP_ADJUST(s->c, true);
+
+ // If a mapping was started in Visual or Select mode, remember the length
+ // of the mapping. This is used below to not return to Insert mode for as
+ // long as the mapping is being executed.
+ if (restart_edit == 0) {
+ s->old_mapped_len = 0;
+ } else if (s->old_mapped_len || (VIsual_active && s->mapped_len == 0
+ && typebuf_maplen() > 0)) {
+ s->old_mapped_len = typebuf_maplen();
+ }
+
+ if (s->c == NUL) {
+ s->c = K_ZERO;
+ }
+
+ // In Select mode, typed text replaces the selection.
+ if (VIsual_active && VIsual_select && (vim_isprintc(s->c)
+ || s->c == NL || s->c == CAR || s->c == K_KENTER)) {
+ // Fake a "c"hange command. When "restart_edit" is set (e.g., because
+ // 'insertmode' is set) fake a "d"elete command, Insert mode will
+ // restart automatically.
+ // Insert the typed character in the typeahead buffer, so that it can
+ // be mapped in Insert mode. Required for ":lmap" to work.
+ ins_char_typebuf(s->c);
+ if (restart_edit != 0) {
+ s->c = 'd';
} else {
- if (ca.cmdchar == 'r') /* get it in replace mode */
- repl = true;
- cp = &ca.nchar;
+ s->c = 'c';
}
- lang = (repl || (nv_cmds[idx].cmd_flags & NV_LANG));
+ msg_nowait = true; // don't delay going to insert mode
+ s->old_mapped_len = 0; // do go to Insert mode
+ }
+
+ s->need_flushbuf = add_to_showcmd(s->c);
+
+ while (normal_get_command_count(s)) continue;
+
+ if (s->c == K_EVENT) {
+ // Save the count values so that ca.opcount and ca.count0 are exactly
+ // the same when coming back here after handling K_EVENT.
+ s->oa.prev_opcount = s->ca.opcount;
+ s->oa.prev_count0 = s->ca.count0;
+ } else if (s->ca.opcount != 0) {
+ // If we're in the middle of an operator (including after entering a
+ // yank buffer with '"') AND we had a count before the operator, then
+ // that count overrides the current value of ca.count0.
+ // What this means effectively, is that commands like "3dw" get turned
+ // into "d3w" which makes things fall into place pretty neatly.
+ // If you give a count before AND after the operator, they are
+ // multiplied.
+ if (s->ca.count0) {
+ s->ca.count0 *= s->ca.opcount;
+ } else {
+ s->ca.count0 = s->ca.opcount;
+ }
+ }
- /*
- * Get a second or third character.
- */
- if (cp != NULL) {
- if (repl) {
- State = REPLACE; /* pretend Replace mode */
- ui_cursor_shape(); /* show different cursor shape */
- }
- if (lang && curbuf->b_p_iminsert == B_IMODE_LMAP) {
- /* Allow mappings defined with ":lmap". */
- --no_mapping;
- --allow_keys;
- if (repl)
- State = LREPLACE;
- else
- State = LANGMAP;
- langmap_active = true;
- }
+ // Always remember the count. It will be set to zero (on the next call,
+ // above) when there is no pending operator.
+ // When called from main(), save the count for use by the "count" built-in
+ // variable.
+ s->ca.opcount = s->ca.count0;
+ s->ca.count1 = (s->ca.count0 == 0 ? 1 : s->ca.count0);
- *cp = plain_vgetc();
+ // Only set v:count when called from main() and not a stuffed command.
+ // Do set it for redo.
+ if (s->toplevel && readbuf1_empty()) {
+ set_vcount(s->ca.count0, s->ca.count1, s->set_prevcount);
+ }
- if (langmap_active) {
- /* Undo the decrement done above */
- ++no_mapping;
- ++allow_keys;
- State = NORMAL_BUSY;
- }
- State = NORMAL_BUSY;
- need_flushbuf |= add_to_showcmd(*cp);
-
- if (!lit) {
- /* Typing CTRL-K gets a digraph. */
- if (*cp == Ctrl_K
- && ((nv_cmds[idx].cmd_flags & NV_LANG)
- || cp == &ca.extra_char)
- && vim_strchr(p_cpo, CPO_DIGRAPH) == NULL) {
- c = get_digraph(false);
- if (c > 0) {
- *cp = c;
- /* Guessing how to update showcmd here... */
- del_from_showcmd(3);
- need_flushbuf |= add_to_showcmd(*cp);
- }
- }
+ // Find the command character in the table of commands.
+ // For CTRL-W we already got nchar when looking for a count.
+ if (s->ctrl_w) {
+ s->ca.nchar = s->c;
+ s->ca.cmdchar = Ctrl_W;
+ } else {
+ s->ca.cmdchar = s->c;
+ }
- /* adjust chars > 127, except after "tTfFr" commands */
- LANGMAP_ADJUST(*cp, !lang);
- /* adjust Hebrew mapped char */
- if (p_hkmap && lang && KeyTyped)
- *cp = hkmap(*cp);
- /* adjust Farsi mapped char */
- if (p_fkmap && lang && KeyTyped)
- *cp = fkmap(*cp);
- }
+ s->idx = find_command(s->ca.cmdchar);
- /*
- * When the next character is CTRL-\ a following CTRL-N means the
- * command is aborted and we go to Normal mode.
- */
- if (cp == &ca.extra_char
- && ca.nchar == Ctrl_BSL
- && (ca.extra_char == Ctrl_N || ca.extra_char == Ctrl_G)) {
- ca.cmdchar = Ctrl_BSL;
- ca.nchar = ca.extra_char;
- idx = find_command(ca.cmdchar);
- } else if ((ca.nchar == 'n' || ca.nchar == 'N') && ca.cmdchar == 'g')
- ca.oap->op_type = get_op_type(*cp, NUL);
- else if (*cp == Ctrl_BSL) {
- long towait = (p_ttm >= 0 ? p_ttm : p_tm);
-
- /* There is a busy wait here when typing "f<C-\>" and then
- * something different from CTRL-N. Can't be avoided. */
- while ((c = vpeekc()) <= 0 && towait > 0L) {
- do_sleep(towait > 50L ? 50L : towait);
- towait -= 50L;
- }
- if (c > 0) {
- c = plain_vgetc();
- if (c != Ctrl_N && c != Ctrl_G)
- vungetc(c);
- else {
- ca.cmdchar = Ctrl_BSL;
- ca.nchar = c;
- idx = find_command(ca.cmdchar);
- assert(idx >= 0);
- }
- }
- }
+ if (s->idx < 0) {
+ // Not a known command: beep.
+ clearopbeep(&s->oa);
+ s->command_finished = true;
+ goto finish;
+ }
- /* When getting a text character and the next character is a
- * multi-byte character, it could be a composing character.
- * However, don't wait for it to arrive. Also, do enable mapping,
- * because if it's put back with vungetc() it's too late to apply
- * mapping. */
- no_mapping--;
- while (enc_utf8 && lang && (c = vpeekc()) > 0
- && (c >= 0x100 || MB_BYTE2LEN(vpeekc()) > 1)) {
- c = plain_vgetc();
- if (!utf_iscomposing(c)) {
- vungetc(c); /* it wasn't, put it back */
- break;
- } else if (ca.ncharC1 == 0)
- ca.ncharC1 = c;
- else
- ca.ncharC2 = c;
- }
- no_mapping++;
- }
- --no_mapping;
- --allow_keys;
+ if (text_locked() && (nv_cmds[s->idx].cmd_flags & NV_NCW)) {
+ // This command is not allowed while editing a cmdline: beep.
+ clearopbeep(&s->oa);
+ text_locked_msg();
+ s->command_finished = true;
+ goto finish;
}
- /*
- * Flush the showcmd characters onto the screen so we can see them while
- * the command is being executed. Only do this when the shown command was
- * actually displayed, otherwise this will slow down a lot when executing
- * mappings.
- */
- if (need_flushbuf)
+ if ((nv_cmds[s->idx].cmd_flags & NV_NCW) && curbuf_locked()) {
+ s->command_finished = true;
+ goto finish;
+ }
+
+ // In Visual/Select mode, a few keys are handled in a special way.
+ if (VIsual_active && normal_handle_special_visual_command(s)) {
+ s->command_finished = true;
+ goto finish;
+ }
+
+ if (curwin->w_p_rl && KeyTyped && !KeyStuffed
+ && (nv_cmds[s->idx].cmd_flags & NV_RL)) {
+ // Invert horizontal movements and operations. Only when typed by the
+ // user directly, not when the result of a mapping or "x" translated
+ // to "dl".
+ normal_invert_horizontal(s);
+ }
+
+ // Get an additional character if we need one.
+ if (normal_need_aditional_char(s)) {
+ normal_get_additional_char(s);
+ }
+
+ // Flush the showcmd characters onto the screen so we can see them while
+ // the command is being executed. Only do this when the shown command was
+ // actually displayed, otherwise this will slow down a lot when executing
+ // mappings.
+ if (s->need_flushbuf) {
ui_flush();
- if (ca.cmdchar != K_IGNORE)
+ }
+ if (s->ca.cmdchar != K_IGNORE && s->ca.cmdchar != K_EVENT) {
did_cursorhold = false;
+ }
State = NORMAL;
- if (ca.nchar == ESC) {
- clearop(oap);
- if (restart_edit == 0 && goto_im())
+ if (s->ca.nchar == ESC) {
+ clearop(&s->oa);
+ if (restart_edit == 0 && goto_im()) {
restart_edit = 'a';
- goto normal_end;
+ }
+ s->command_finished = true;
+ goto finish;
}
- if (ca.cmdchar != K_IGNORE) {
- msg_didout = false; /* don't scroll screen up for normal command */
+ if (s->ca.cmdchar != K_IGNORE) {
+ msg_didout = false; // don't scroll screen up for normal command
msg_col = 0;
}
- old_pos = curwin->w_cursor; /* remember where cursor was */
+ s->old_pos = curwin->w_cursor; // remember where cursor was
- /* When 'keymodel' contains "startsel" some keys start Select/Visual
- * mode. */
+ // When 'keymodel' contains "startsel" some keys start Select/Visual
+ // mode.
if (!VIsual_active && km_startsel) {
- if (nv_cmds[idx].cmd_flags & NV_SS) {
+ if (nv_cmds[s->idx].cmd_flags & NV_SS) {
start_selection();
- unshift_special(&ca);
- idx = find_command(ca.cmdchar);
- } else if ((nv_cmds[idx].cmd_flags & NV_SSS)
+ unshift_special(&s->ca);
+ s->idx = find_command(s->ca.cmdchar);
+ } else if ((nv_cmds[s->idx].cmd_flags & NV_SSS)
&& (mod_mask & MOD_MASK_SHIFT)) {
start_selection();
mod_mask &= ~MOD_MASK_SHIFT;
}
}
- /*
- * Execute the command!
- * Call the command function found in the commands table.
- */
- ca.arg = nv_cmds[idx].cmd_arg;
- (nv_cmds[idx].cmd_func)(&ca);
+ // Execute the command!
+ // Call the command function found in the commands table.
+ s->ca.arg = nv_cmds[s->idx].cmd_arg;
+ (nv_cmds[s->idx].cmd_func)(&s->ca);
- /*
- * If we didn't start or finish an operator, reset oap->regname, unless we
- * need it later.
- */
- if (!finish_op
- && !oap->op_type
- && (idx < 0 || !(nv_cmds[idx].cmd_flags & NV_KEEPREG))) {
- clearop(oap);
- set_reg_var(get_default_register_name());
+finish:
+ normal_finish_command(s);
+ return 1;
+}
+
+static void normal_check_stuff_buffer(NormalState *s)
+{
+ if (stuff_empty()) {
+ did_check_timestamps = false;
+
+ if (need_check_timestamps) {
+ check_timestamps(false);
+ }
+
+ if (need_wait_return) {
+ // if wait_return still needed call it now
+ wait_return(false);
+ }
+
+ if (need_start_insertmode && goto_im() && !VIsual_active) {
+ need_start_insertmode = false;
+ stuffReadbuff((uint8_t *)"i"); // start insert mode next
+ // skip the fileinfo message now, because it would be shown
+ // after insert mode finishes!
+ need_fileinfo = false;
+ }
}
+}
- /* Get the length of mapped chars again after typing a count, second
- * character or "z333<cr>". */
- if (old_mapped_len > 0)
- old_mapped_len = typebuf_maplen();
+static void normal_check_interrupt(NormalState *s)
+{
+ // Reset "got_int" now that we got back to the main loop. Except when
+ // inside a ":g/pat/cmd" command, then the "got_int" needs to abort
+ // the ":g" command.
+ // For ":g/pat/vi" we reset "got_int" when used once. When used
+ // a second time we go back to Ex mode and abort the ":g" command.
+ if (got_int) {
+ if (s->noexmode && global_busy && !exmode_active
+ && s->previous_got_int) {
+ // Typed two CTRL-C in a row: go back to ex mode as if "Q" was
+ // used and keep "got_int" set, so that it aborts ":g".
+ exmode_active = EXMODE_NORMAL;
+ State = NORMAL;
+ } else if (!global_busy || !exmode_active) {
+ if (!quit_more) {
+ // flush all buffers
+ (void)vgetc();
+ }
+ got_int = false;
+ }
+ s->previous_got_int = true;
+ } else {
+ s->previous_got_int = false;
+ }
+}
- /*
- * If an operation is pending, handle it...
- */
- do_pending_operator(&ca, old_col, false);
+static void normal_check_cursor_moved(NormalState *s)
+{
+ // Trigger CursorMoved if the cursor moved.
+ if (!finish_op && (has_cursormoved() || curwin->w_p_cole > 0)
+ && !equalpos(last_cursormoved, curwin->w_cursor)) {
+ if (has_cursormoved()) {
+ apply_autocmds(EVENT_CURSORMOVED, NULL, NULL, false, curbuf);
+ }
- /*
- * Wait for a moment when a message is displayed that will be overwritten
- * by the mode message.
- * In Visual mode and with "^O" in Insert mode, a short message will be
- * overwritten by the mode message. Wait a bit, until a key is hit.
- * In Visual mode, it's more important to keep the Visual area updated
- * than keeping a message (e.g. from a /pat search).
- * Only do this if the command was typed, not from a mapping.
- * Don't wait when emsg_silent is non-zero.
- * Also wait a bit after an error message, e.g. for "^O:".
- * Don't redraw the screen, it would remove the message.
- */
- if ( ((p_smd
- && msg_silent == 0
- && (restart_edit != 0
- || (VIsual_active
- && old_pos.lnum == curwin->w_cursor.lnum
- && old_pos.col == curwin->w_cursor.col)
- )
- && (clear_cmdline
- || redraw_cmdline)
- && (msg_didout || (msg_didany && msg_scroll))
- && !msg_nowait
- && KeyTyped)
- || (restart_edit != 0
- && !VIsual_active
- && (msg_scroll
- || emsg_on_display)))
- && oap->regname == 0
- && !(ca.retval & CA_COMMAND_BUSY)
- && stuff_empty()
- && typebuf_typed()
- && emsg_silent == 0
- && !did_wait_return
- && oap->op_type == OP_NOP) {
- int save_State = State;
+ if (curwin->w_p_cole > 0) {
+ s->conceal_old_cursor_line = last_cursormoved.lnum;
+ s->conceal_new_cursor_line = curwin->w_cursor.lnum;
+ s->conceal_update_lines = true;
+ }
- /* Draw the cursor with the right shape here */
- if (restart_edit != 0)
- State = INSERT;
+ last_cursormoved = curwin->w_cursor;
+ }
+}
+
+static void normal_check_text_changed(NormalState *s)
+{
+ // Trigger TextChanged if b_changedtick differs.
+ if (!finish_op && has_textchanged()
+ && last_changedtick != curbuf->b_changedtick) {
+ if (last_changedtick_buf == curbuf) {
+ apply_autocmds(EVENT_TEXTCHANGED, NULL, NULL, false, curbuf);
+ }
- /* If need to redraw, and there is a "keep_msg", redraw before the
- * delay */
- if (must_redraw && keep_msg != NULL && !emsg_on_display) {
- char_u *kmsg;
+ last_changedtick_buf = curbuf;
+ last_changedtick = curbuf->b_changedtick;
+ }
+}
- kmsg = keep_msg;
- keep_msg = NULL;
- /* showmode() will clear keep_msg, but we want to use it anyway */
- update_screen(0);
- /* now reset it, otherwise it's put in the history again */
- keep_msg = kmsg;
- msg_attr(kmsg, keep_msg_attr);
- xfree(kmsg);
+static void normal_check_folds(NormalState *s)
+{
+ // Include a closed fold completely in the Visual area.
+ foldAdjustVisual();
+
+ // When 'foldclose' is set, apply 'foldlevel' to folds that don't
+ // contain the cursor.
+ // When 'foldopen' is "all", open the fold(s) under the cursor.
+ // This may mark the window for redrawing.
+ if (hasAnyFolding(curwin) && !char_avail()) {
+ foldCheckClose();
+
+ if (fdo_flags & FDO_ALL) {
+ foldOpenCursor();
}
- setcursor();
- ui_flush();
- if (msg_scroll || emsg_on_display)
- os_delay(1000L, true); /* wait at least one second */
- os_delay(3000L, false); /* wait up to three seconds */
- State = save_State;
+ }
+}
- msg_scroll = false;
- emsg_on_display = false;
+static void normal_redraw(NormalState *s)
+{
+ // Before redrawing, make sure w_topline is correct, and w_leftcol
+ // if lines don't wrap, and w_skipcol if lines wrap.
+ update_topline();
+ validate_cursor();
+
+ if (VIsual_active) {
+ update_curbuf(INVERTED); // update inverted part
+ } else if (must_redraw) {
+ update_screen(0);
+ } else if (redraw_cmdline || clear_cmdline) {
+ showmode();
}
- /*
- * Finish up after executing a Normal mode command.
- */
-normal_end:
+ redraw_statuslines();
- msg_nowait = false;
+ if (need_maketitle) {
+ maketitle();
+ }
- /* Reset finish_op, in case it was set */
- c = finish_op;
- finish_op = false;
- /* Redraw the cursor with another shape, if we were in Operator-pending
- * mode or did a replace command. */
- if (c || ca.cmdchar == 'r') {
- ui_cursor_shape(); /* may show different cursor shape */
+ // display message after redraw
+ if (keep_msg != NULL) {
+ // msg_attr_keep() will set keep_msg to NULL, must free the string here.
+ // Don't reset keep_msg, msg_attr_keep() uses it to check for duplicates.
+ char *p = (char *)keep_msg;
+ msg_attr((uint8_t *)p, keep_msg_attr);
+ xfree(p);
}
- if (oap->op_type == OP_NOP && oap->regname == 0
- && ca.cmdchar != K_CURSORHOLD
- )
- clear_showcmd();
+ if (need_fileinfo) { // show file info after redraw
+ fileinfo(false, true, false);
+ need_fileinfo = false;
+ }
- checkpcmark(); /* check if we moved since setting pcmark */
- xfree(ca.searchbuf);
+ emsg_on_display = false; // can delete error message now
+ did_emsg = false;
+ msg_didany = false; // reset lines_left in msg_start()
+ may_clear_sb_text(); // clear scroll-back text on next msg
+ showruler(false);
- if (has_mbyte)
- mb_adjust_cursor();
+ if (s->conceal_update_lines
+ && (s->conceal_old_cursor_line !=
+ s->conceal_new_cursor_line
+ || conceal_cursor_line(curwin)
+ || need_cursor_line_redraw)) {
+ if (s->conceal_old_cursor_line !=
+ s->conceal_new_cursor_line
+ && s->conceal_old_cursor_line <=
+ curbuf->b_ml.ml_line_count) {
+ update_single_line(curwin, s->conceal_old_cursor_line);
+ }
- if (curwin->w_p_scb && toplevel) {
- validate_cursor(); /* may need to update w_leftcol */
- do_check_scrollbind(true);
+ update_single_line(curwin, s->conceal_new_cursor_line);
+ curwin->w_valid &= ~VALID_CROW;
}
- if (curwin->w_p_crb && toplevel) {
- validate_cursor(); /* may need to update w_leftcol */
- do_check_cursorbind();
+ setcursor();
+}
+
+// Function executed before each iteration of normal mode.
+// Return:
+// 1 if the iteration should continue normally
+// -1 if the iteration should be skipped
+// 0 if the main loop must exit
+static int normal_check(VimState *state)
+{
+ NormalState *s = (NormalState *)state;
+ normal_check_stuff_buffer(s);
+ normal_check_interrupt(s);
+
+ if (!exmode_active) {
+ msg_scroll = false;
}
+ quit_more = false;
+
+ // If skip redraw is set (for ":" in wait_return()), don't redraw now.
+ // If there is nothing in the stuff_buffer or do_redraw is TRUE,
+ // update cursor and redraw.
+ if (skip_redraw || exmode_active) {
+ skip_redraw = false;
+ } else if (do_redraw || stuff_empty()) {
+ normal_check_cursor_moved(s);
+ normal_check_text_changed(s);
+
+ // Scroll-binding for diff mode may have been postponed until
+ // here. Avoids doing it for every change.
+ if (diff_need_scrollbind) {
+ check_scrollbind((linenr_T)0, 0L);
+ diff_need_scrollbind = false;
+ }
- /*
- * May restart edit(), if we got here with CTRL-O in Insert mode (but not
- * if still inside a mapping that started in Visual mode).
- * May switch from Visual to Select mode after CTRL-O command.
- */
- if ( oap->op_type == OP_NOP
- && ((restart_edit != 0 && !VIsual_active && old_mapped_len == 0)
- || restart_VIsual_select == 1)
- && !(ca.retval & CA_COMMAND_BUSY)
- && stuff_empty()
- && oap->regname == 0) {
- if (restart_VIsual_select == 1) {
- VIsual_select = true;
- showmode();
- restart_VIsual_select = 0;
+ normal_check_folds(s);
+ normal_redraw(s);
+ do_redraw = false;
+
+ // Now that we have drawn the first screen all the startup stuff
+ // has been done, close any file for startup messages.
+ if (time_fd != NULL) {
+ TIME_MSG("first screen update");
+ TIME_MSG("--- NVIM STARTED ---");
+ fclose(time_fd);
+ time_fd = NULL;
}
- if (restart_edit != 0
- && !VIsual_active && old_mapped_len == 0
- )
- (void)edit(restart_edit, false, 1L);
}
- if (restart_VIsual_select == 2)
- restart_VIsual_select = 1;
+ // May perform garbage collection when waiting for a character, but
+ // only at the very toplevel. Otherwise we may be using a List or
+ // Dict internally somewhere.
+ // "may_garbage_collect" is reset in vgetc() which is invoked through
+ // do_exmode() and normal_cmd().
+ may_garbage_collect = s->toplevel;
+
+ // Update w_curswant if w_set_curswant has been set.
+ // Postponed until here to avoid computing w_virtcol too often.
+ update_curswant();
- /* Save count before an operator for next time. */
- opcount = ca.opcount;
+ if (exmode_active) {
+ if (s->noexmode) {
+ return 0;
+ }
+ do_exmode(exmode_active == EXMODE_VIM);
+ return -1;
+ }
+
+ if (s->cmdwin && cmdwin_result != 0) {
+ // command-line window and cmdwin_result is set
+ return 0;
+ }
+
+ normal_prepare(s);
+ return 1;
}
/*
@@ -2937,7 +3260,7 @@ bool add_to_showcmd(int c)
K_RIGHTMOUSE, K_RIGHTDRAG, K_RIGHTRELEASE,
K_MOUSEDOWN, K_MOUSEUP, K_MOUSELEFT, K_MOUSERIGHT,
K_X1MOUSE, K_X1DRAG, K_X1RELEASE, K_X2MOUSE, K_X2DRAG, K_X2RELEASE,
- K_CURSORHOLD,
+ K_EVENT,
0
};
@@ -3924,8 +4247,13 @@ dozet:
break;
/* "zm": fold more */
- case 'm': if (curwin->w_p_fdl > 0)
- --curwin->w_p_fdl;
+ case 'm':
+ if (curwin->w_p_fdl > 0) {
+ curwin->w_p_fdl -= cap->count1;
+ if (curwin->w_p_fdl < 0) {
+ curwin->w_p_fdl = 0;
+ }
+ }
old_fdl = -1; /* force an update */
curwin->w_p_fen = true;
break;
@@ -3937,7 +4265,14 @@ dozet:
break;
/* "zr": reduce folding */
- case 'r': ++curwin->w_p_fdl;
+ case 'r':
+ curwin->w_p_fdl += cap->count1;
+ {
+ int d = getDeepestNesting();
+ if (curwin->w_p_fdl >= d) {
+ curwin->w_p_fdl = d;
+ }
+ }
break;
/* "zR": open all folds */
@@ -7131,6 +7466,13 @@ static void nv_object(cmdarg_T *cap)
flag = current_block(cap->oap, cap->count1, include, '<', '>');
break;
case 't': /* "at" = a tag block (xml and html) */
+ // Do not adjust oap->end in do_pending_operator()
+ // otherwise there are different results for 'dit'
+ // (note leading whitespace in last line):
+ // 1) <b> 2) <b>
+ // foobar foobar
+ // </b> </b>
+ cap->retval |= CA_NO_ADJ_OP_END;
flag = current_tagblock(cap->oap, cap->count1, include);
break;
case 'p': /* "ap" = a paragraph */
@@ -7357,16 +7699,33 @@ static void nv_open(cmdarg_T *cap)
n_opencmd(cap);
}
-/*
- * Trigger CursorHold event.
- * When waiting for a character for 'updatetime' K_CURSORHOLD is put in the
- * input buffer. "did_cursorhold" is set to avoid retriggering.
- */
-static void nv_cursorhold(cmdarg_T *cap)
+// Handle an arbitrary event in normal mode
+static void nv_event(cmdarg_T *cap)
{
- apply_autocmds(EVENT_CURSORHOLD, NULL, NULL, false, curbuf);
- did_cursorhold = true;
- cap->retval |= CA_COMMAND_BUSY; /* don't call edit() now */
+ // Garbage collection should have been executed before blocking for events in
+ // the `os_inchar` in `state_enter`, but we also disable it here in case the
+ // `os_inchar` branch was not executed(!queue_empty(loop.events), which could
+ // have `may_garbage_collect` set to true in `normal_check`).
+ //
+ // That is because here we may run code that calls `os_inchar`
+ // later(`f_confirm` or `get_keystroke` for example), but in these cases it is
+ // not safe to perform garbage collection because there could be unreferenced
+ // lists or dicts being used.
+ may_garbage_collect = false;
+ queue_process_events(loop.events);
+ cap->retval |= CA_COMMAND_BUSY; // don't call edit() now
+}
+
+/// Trigger FocusGained event.
+static void nv_focusgained(cmdarg_T *cap)
+{
+ apply_autocmds(EVENT_FOCUSGAINED, NULL, NULL, false, curbuf);
+}
+
+/// Trigger FocusLost event.
+static void nv_focuslost(cmdarg_T *cap)
+{
+ apply_autocmds(EVENT_FOCUSLOST, NULL, NULL, false, curbuf);
}
/*
@@ -7376,3 +7735,14 @@ static int mouse_model_popup(void)
{
return p_mousem[0] == 'p';
}
+
+void normal_cmd(oparg_T *oap, bool toplevel)
+{
+ NormalState s;
+ normal_state_init(&s);
+ s.toplevel = toplevel;
+ s.oa = *oap;
+ normal_prepare(&s);
+ (void)normal_execute(&s.state, safe_vgetc());
+ *oap = s.oa;
+}
diff --git a/src/nvim/normal.h b/src/nvim/normal.h
index b71487c30c..01259de6cd 100644
--- a/src/nvim/normal.h
+++ b/src/nvim/normal.h
@@ -36,8 +36,8 @@ typedef struct oparg_S {
bool block_mode; /* current operator is Visual block mode */
colnr_T start_vcol; /* start col for block mode operator */
colnr_T end_vcol; /* end col for block mode operator */
- long prev_opcount; /* ca.opcount saved for K_CURSORHOLD */
- long prev_count0; /* ca.count0 saved for K_CURSORHOLD */
+ long prev_opcount; // ca.opcount saved for K_EVENT
+ long prev_count0; // ca.count0 saved for K_EVENT
} oparg_T;
/*
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index 3fd2c0b773..bef0ebaeed 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -1,12 +1,4 @@
/*
- * VIM - Vi IMproved by Bram Moolenaar
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- * See README.txt for an overview of the Vim source code.
- */
-
-/*
* ops.c: implementation of various operators: op_shift, op_delete, op_tilde,
* op_change, op_yank, do_put, do_join
*/
@@ -4972,7 +4964,7 @@ void cursor_pos_info(void)
&char_count_cursor, len, eol_size);
if (lnum == curbuf->b_ml.ml_line_count
&& !curbuf->b_p_eol
- && curbuf->b_p_bin
+ && (curbuf->b_p_bin || !curbuf->b_p_fixeol)
&& (long)STRLEN(s) < len)
byte_count_cursor -= eol_size;
}
@@ -4993,7 +4985,7 @@ void cursor_pos_info(void)
}
/* Correction for when last line doesn't have an EOL. */
- if (!curbuf->b_p_eol && curbuf->b_p_bin)
+ if (!curbuf->b_p_eol && (curbuf->b_p_bin || !curbuf->b_p_fixeol))
byte_count -= eol_size;
if (l_VIsual_active) {
diff --git a/src/nvim/option.c b/src/nvim/option.c
index a578f2bb01..486f2083a6 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -1,12 +1,4 @@
/*
- * VIM - Vi IMproved by Bram Moolenaar
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- * See README.txt for an overview of the Vim source code.
- */
-
-/*
* Code to handle user-settable options. This is all pretty much table-
* driven. Checklist for adding a new option:
* - Put it in the options array below (copy an existing entry).
@@ -30,7 +22,6 @@
#define IN_OPTION_C
#include <assert.h>
-#include <errno.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdint.h>
@@ -131,6 +122,7 @@ static char_u *p_cpt;
static char_u *p_cfu;
static char_u *p_ofu;
static int p_eol;
+static int p_fixeol;
static int p_et;
static char_u *p_fenc;
static char_u *p_ff;
@@ -301,6 +293,243 @@ static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview",
# include "option.c.generated.h"
#endif
+/// Append string with escaped commas
+static char *strcpy_comma_escaped(char *dest, const char *src, const size_t len)
+ FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT
+{
+ size_t shift = 0;
+ for (size_t i = 0; i < len; i++) {
+ if (src[i] == ',') {
+ dest[i + shift++] = '\\';
+ }
+ dest[i + shift] = src[i];
+ }
+ return &dest[len + shift];
+}
+
+/// Compute length of a colon-separated value, doubled and with some suffixes
+///
+/// @param[in] val Colon-separated array value.
+/// @param[in] common_suf_len Length of the common suffix which is appended to
+/// each item in the array, twice.
+/// @param[in] single_suf_len Length of the suffix which is appended to each
+/// item in the array once.
+///
+/// @return Length of the comma-separated string array that contains each item
+/// in the original array twice with suffixes with given length
+/// (common_suf is present after each new item, single_suf is present
+/// after half of the new items) and with commas after each item, commas
+/// inside the values are escaped.
+static inline size_t compute_double_colon_len(const char *const val,
+ const size_t common_suf_len,
+ const size_t single_suf_len)
+ FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_PURE
+{
+ if (val == NULL || *val == NUL) {
+ return 0;
+ }
+ size_t ret = 0;
+ const void *iter = NULL;
+ do {
+ size_t dir_len;
+ const char *dir;
+ iter = vim_colon_env_iter(val, iter, &dir, &dir_len);
+ if (dir != NULL && dir_len > 0) {
+ ret += ((dir_len + memcnt(dir, ',', dir_len) + common_suf_len
+ + !after_pathsep(dir, dir + dir_len)) * 2
+ + single_suf_len);
+ }
+ } while (iter != NULL);
+ return ret;
+}
+
+#define NVIM_SIZE (sizeof("nvim") - 1)
+
+/// Add directories to a comma-separated array from a colon-separated one
+///
+/// Commas are escaped in process. To each item PATHSEP "nvim" is appended in
+/// addition to suf1 and suf2.
+///
+/// @param[in,out] dest Destination comma-separated array.
+/// @param[in] val Source colon-separated array.
+/// @param[in] suf1 If not NULL, suffix appended to destination. Prior to it
+/// directory separator is appended. Suffix must not contain
+/// commas.
+/// @param[in] len1 Length of the suf1.
+/// @param[in] suf2 If not NULL, another suffix appended to destination. Again
+/// with directory separator behind. Suffix must not contain
+/// commas.
+/// @param[in] len2 Length of the suf2.
+/// @param[in] forward If true, iterate over val in forward direction.
+/// Otherwise in reverse.
+///
+/// @return (dest + appended_characters_length)
+static inline char *add_colon_dirs(char *dest, const char *const val,
+ const char *const suf1, const size_t len1,
+ const char *const suf2, const size_t len2,
+ const bool forward)
+ FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_RET FUNC_ATTR_NONNULL_ARG(1)
+{
+ if (val == NULL || *val == NUL) {
+ return dest;
+ }
+ const void *iter = NULL;
+ do {
+ size_t dir_len;
+ const char *dir;
+ iter = (forward ? vim_colon_env_iter : vim_colon_env_iter_rev)(
+ val, iter, &dir, &dir_len);
+ if (dir != NULL && dir_len > 0) {
+ dest = strcpy_comma_escaped(dest, dir, dir_len);
+ if (!after_pathsep(dest - 1, dest)) {
+ *dest++ = PATHSEP;
+ }
+ memmove(dest, "nvim", NVIM_SIZE);
+ dest += NVIM_SIZE;
+ if (suf1 != NULL) {
+ *dest++ = PATHSEP;
+ memmove(dest, suf1, len1);
+ dest += len1;
+ if (suf2 != NULL) {
+ *dest++ = PATHSEP;
+ memmove(dest, suf2, len2);
+ dest += len2;
+ }
+ }
+ *dest++ = ',';
+ }
+ } while (iter != NULL);
+ return dest;
+}
+
+/// Add directory to a comma-separated list of directories
+///
+/// In the added directory comma is escaped.
+///
+/// @param[in,out] dest Destination comma-separated array.
+/// @param[in] dir Directory to append.
+/// @param[in] append_nvim If true, append "nvim" as the very first suffix.
+/// @param[in] suf1 If not NULL, suffix appended to destination. Prior to it
+/// directory separator is appended. Suffix must not contain
+/// commas.
+/// @param[in] len1 Length of the suf1.
+/// @param[in] suf2 If not NULL, another suffix appended to destination. Again
+/// with directory separator behind. Suffix must not contain
+/// commas.
+/// @param[in] len2 Length of the suf2.
+/// @param[in] forward If true, iterate over val in forward direction.
+/// Otherwise in reverse.
+///
+/// @return (dest + appended_characters_length)
+static inline char *add_dir(char *dest, const char *const dir,
+ const size_t dir_len, const bool append_nvim,
+ const char *const suf1, const size_t len1,
+ const char *const suf2, const size_t len2)
+ FUNC_ATTR_NONNULL_RET FUNC_ATTR_NONNULL_ARG(1) FUNC_ATTR_WARN_UNUSED_RESULT
+{
+ if (dir == NULL || dir_len == 0) {
+ return dest;
+ }
+ dest = strcpy_comma_escaped(dest, dir, dir_len);
+ if (append_nvim) {
+ if (!after_pathsep(dest - 1, dest)) {
+ *dest++ = PATHSEP;
+ }
+ memmove(dest, "nvim", NVIM_SIZE);
+ dest += NVIM_SIZE;
+ if (suf1 != NULL) {
+ *dest++ = PATHSEP;
+ memmove(dest, suf1, len1);
+ dest += len1;
+ if (suf2 != NULL) {
+ *dest++ = PATHSEP;
+ memmove(dest, suf2, len2);
+ dest += len2;
+ }
+ }
+ }
+ *dest++ = ',';
+ return dest;
+}
+
+/// Set &runtimepath to default value
+static void set_runtimepath_default(void)
+{
+ size_t rtp_size = 0;
+ char *const data_home = stdpaths_get_xdg_var(kXDGDataHome);
+ char *const config_home = stdpaths_get_xdg_var(kXDGConfigHome);
+ char *const vimruntime = vim_getenv("VIMRUNTIME");
+ char *const data_dirs = stdpaths_get_xdg_var(kXDGDataDirs);
+ char *const config_dirs = stdpaths_get_xdg_var(kXDGConfigDirs);
+#define SITE_SIZE (sizeof("site") - 1)
+#define AFTER_SIZE (sizeof("after") - 1)
+ size_t data_len = 0;
+ size_t config_len = 0;
+ size_t vimruntime_len = 0;
+ if (data_home != NULL) {
+ data_len = strlen(data_home);
+ if (data_len != 0) {
+ rtp_size += ((data_len + memcnt(data_home, ',', data_len)
+ + NVIM_SIZE + 1 + SITE_SIZE + 1
+ + !after_pathsep(data_home, data_home + data_len)) * 2
+ + AFTER_SIZE + 1);
+ }
+ }
+ if (config_home != NULL) {
+ config_len = strlen(config_home);
+ if (config_len != 0) {
+ rtp_size += ((config_len + memcnt(config_home, ',', config_len)
+ + NVIM_SIZE + 1
+ + !after_pathsep(config_home, config_home + config_len)) * 2
+ + AFTER_SIZE + 1);
+ }
+ }
+ if (vimruntime != NULL) {
+ vimruntime_len = strlen(vimruntime);
+ if (vimruntime_len != 0) {
+ rtp_size += vimruntime_len + memcnt(vimruntime, ',', vimruntime_len) + 1;
+ }
+ }
+ rtp_size += compute_double_colon_len(data_dirs, NVIM_SIZE + 1 + SITE_SIZE + 1,
+ AFTER_SIZE + 1);
+ rtp_size += compute_double_colon_len(config_dirs, NVIM_SIZE + 1,
+ AFTER_SIZE + 1);
+ if (rtp_size == 0) {
+ return;
+ }
+ char *const rtp = xmalloc(rtp_size);
+ char *rtp_cur = rtp;
+ rtp_cur = add_dir(rtp_cur, config_home, config_len, true, NULL, 0, NULL, 0);
+ rtp_cur = add_colon_dirs(rtp_cur, config_dirs, NULL, 0, NULL, 0, true);
+ rtp_cur = add_dir(rtp_cur, data_home, data_len, true, "site", SITE_SIZE,
+ NULL, 0);
+ rtp_cur = add_colon_dirs(rtp_cur, data_dirs, "site", SITE_SIZE, NULL, 0,
+ true);
+ rtp_cur = add_dir(rtp_cur, vimruntime, vimruntime_len, false, NULL, 0,
+ NULL, 0);
+ rtp_cur = add_colon_dirs(rtp_cur, data_dirs, "site", SITE_SIZE,
+ "after", AFTER_SIZE, false);
+ rtp_cur = add_dir(rtp_cur, data_home, data_len, true, "site", SITE_SIZE,
+ "after", AFTER_SIZE);
+ rtp_cur = add_colon_dirs(rtp_cur, config_dirs, "after", AFTER_SIZE, NULL, 0,
+ false);
+ rtp_cur = add_dir(rtp_cur, config_home, config_len, true,
+ "after", AFTER_SIZE, NULL, 0);
+ // Strip trailing comma.
+ rtp_cur[-1] = NUL;
+ assert((size_t) (rtp_cur - rtp) == rtp_size);
+#undef SITE_SIZE
+#undef AFTER_SIZE
+ set_string_default("runtimepath", rtp, true);
+ xfree(data_dirs);
+ xfree(config_dirs);
+ xfree(data_home);
+ xfree(config_home);
+ xfree(vimruntime);
+}
+
+#undef NVIM_SIZE
+
/*
* Initialize the options, first part.
*
@@ -308,7 +537,6 @@ static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview",
*/
void set_init_1(void)
{
- char_u *p;
int opt_idx;
langmap_init();
@@ -320,8 +548,12 @@ void set_init_1(void)
* Find default value for 'shell' option.
* Don't use it if it is empty.
*/
- if ((p = (char_u *)os_getenv("SHELL")) != NULL)
- set_string_default("sh", p);
+ {
+ const char *shell = os_getenv("SHELL");
+ if (shell != NULL) {
+ set_string_default("sh", (char *) shell, false);
+ }
+ }
/*
* Set the default for 'backupskip' to include environment variables for
@@ -339,17 +571,18 @@ void set_init_1(void)
ga_init(&ga, 1, 100);
for (size_t n = 0; n < ARRAY_SIZE(names); ++n) {
bool mustfree = true;
+ char *p;
# ifdef UNIX
if (*names[n] == NUL) {
- p = (char_u *)"/tmp";
+ p = "/tmp";
mustfree = false;
}
else
# endif
- p = (char_u *)vim_getenv(names[n]);
+ p = vim_getenv(names[n]);
if (p != NULL && *p != NUL) {
// First time count the NUL, otherwise count the ','.
- len = (int)STRLEN(p) + 3;
+ len = (int)strlen(p) + 3;
ga_grow(&ga, len);
if (!GA_EMPTY(&ga))
STRCAT(ga.ga_data, ",");
@@ -363,8 +596,7 @@ void set_init_1(void)
}
}
if (ga.ga_data != NULL) {
- set_string_default("bsk", ga.ga_data);
- xfree(ga.ga_data);
+ set_string_default("bsk", ga.ga_data, true);
}
}
@@ -425,17 +657,38 @@ void set_init_1(void)
#if defined(MSWIN) || defined(MAC)
/* Set print encoding on platforms that don't default to latin1 */
- set_string_default("penc",
- (char_u *)"hp-roman8"
- );
+ set_string_default("printencoding", "hp-roman8", false);
#endif
- /* 'printexpr' must be allocated to be able to evaluate it. */
- set_string_default(
- "pexpr",
- (char_u *)
- "system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error"
- );
+ // 'printexpr' must be allocated to be able to evaluate it.
+ set_string_default("printexpr",
+#ifdef UNIX
+ "system(['lpr'] "
+ "+ (empty(&printdevice)?[]:['-P', &printdevice]) "
+ "+ [v:fname_in])"
+ ". delete(v:fname_in)"
+ "+ v:shell_error",
+#elif defined(MSWIN)
+ "system(['copy', v:fname_in, "
+ "empty(&printdevice)?'LPT1':&printdevice])"
+ ". delete(v:fname_in)",
+#else
+ "",
+#endif
+ false);
+
+ char *backupdir = stdpaths_user_data_subpath("backup", 0);
+ const size_t backupdir_len = strlen(backupdir);
+ backupdir = xrealloc(backupdir, backupdir_len + 3);
+ memmove(backupdir + 2, backupdir, backupdir_len + 1);
+ memmove(backupdir, ".,", 2);
+ set_string_default("viewdir", stdpaths_user_data_subpath("view", 0), true);
+ set_string_default("backupdir", backupdir, true);
+ set_string_default("directory", stdpaths_user_data_subpath("swap", 2), true);
+ set_string_default("undodir", stdpaths_user_data_subpath("undo", 0), true);
+ // Set default for &runtimepath. All necessary expansions are performed in
+ // this function.
+ set_runtimepath_default();
/*
* Set all the options (except the terminal options) to their default
@@ -478,14 +731,16 @@ void set_init_1(void)
* default.
*/
for (opt_idx = 0; options[opt_idx].fullname; opt_idx++) {
+ char *p;
if ((options[opt_idx].flags & P_GETTEXT)
- && options[opt_idx].var != NULL)
- p = (char_u *)_(*(char **)options[opt_idx].var);
- else
- p = option_expand(opt_idx, NULL);
+ && options[opt_idx].var != NULL) {
+ p = _(*(char **)options[opt_idx].var);
+ } else {
+ p = (char *) option_expand(opt_idx, NULL);
+ }
if (p != NULL) {
- p = vim_strsave(p);
- *(char_u **)options[opt_idx].var = p;
+ p = xstrdup(p);
+ *(char **)options[opt_idx].var = p;
/* VIMEXP
* Defaults for all expanded options are currently the same for Vi
* and Vim. When this changes, add some code here! Also need to
@@ -493,7 +748,7 @@ void set_init_1(void)
*/
if (options[opt_idx].flags & P_DEF_ALLOCED)
xfree(options[opt_idx].def_val[VI_DEFAULT]);
- options[opt_idx].def_val[VI_DEFAULT] = p;
+ options[opt_idx].def_val[VI_DEFAULT] = (char_u *) p;
options[opt_idx].flags |= P_DEF_ALLOCED;
}
}
@@ -522,14 +777,14 @@ void set_init_1(void)
(void)set_chars_option(&p_lcs);
/* enc_locale() will try to find the encoding of the current locale. */
- p = enc_locale();
+ char_u *p = enc_locale();
if (p != NULL) {
char_u *save_enc;
/* Try setting 'encoding' and check if the value is valid.
* If not, go back to the default "utf-8". */
save_enc = p_enc;
- p_enc = p;
+ p_enc = (char_u *) p;
if (STRCMP(p_enc, "gb18030") == 0) {
/* We don't support "gb18030", but "cp936" is a good substitute
* for practical purposes, thus use that. It's not an alias to
@@ -674,7 +929,9 @@ set_options_default (
///
/// @param name The name of the option
/// @param val The value of the option
-void set_string_default(const char *name, const char_u *val)
+/// @param allocated If true, do not copy default as it was already allocated.
+static void set_string_default(const char *name, char *val, bool allocated)
+ FUNC_ATTR_NONNULL_ALL
{
int opt_idx = findoption((char_u *)name);
if (opt_idx >= 0) {
@@ -682,7 +939,10 @@ void set_string_default(const char *name, const char_u *val)
xfree(options[opt_idx].def_val[VI_DEFAULT]);
}
- options[opt_idx].def_val[VI_DEFAULT] = (char_u *) xstrdup((char *) val);
+ options[opt_idx].def_val[VI_DEFAULT] = (char_u *) (
+ allocated
+ ? (char_u *) val
+ : (char_u *) xstrdup(val));
options[opt_idx].flags |= P_DEF_ALLOCED;
}
}
@@ -759,12 +1019,9 @@ void set_init_2(void)
*/
void set_init_3(void)
{
-#if defined(UNIX) || defined(WIN3264)
- /*
- * Set 'shellpipe' and 'shellredir', depending on the 'shell' option.
- * This is done after other initializations, where 'shell' might have been
- * set, but only if they have not been set before.
- */
+ // Set 'shellpipe' and 'shellredir', depending on the 'shell' option.
+ // This is done after other initializations, where 'shell' might have been
+ // set, but only if they have not been set before.
int idx_srr;
int do_srr;
int idx_sp;
@@ -821,8 +1078,6 @@ void set_init_3(void)
}
xfree(p);
}
-#endif
-
set_title_defaults();
}
@@ -1244,9 +1499,10 @@ do_set (
} else if (opt_idx >= 0) { /* string */
char_u *save_arg = NULL;
char_u *s = NULL;
- char_u *oldval; /* previous value if *varp */
+ char_u *oldval = NULL; // previous value if *varp
char_u *newval;
- char_u *origval;
+ char_u *origval = NULL;
+ char_u *saved_origval = NULL;
unsigned newlen;
int comma;
int bs;
@@ -1513,14 +1769,37 @@ do_set (
/* Set the new value. */
*(char_u **)(varp) = newval;
+ if (!starting && origval != NULL) {
+ // origval may be freed by
+ // did_set_string_option(), make a copy.
+ saved_origval = vim_strsave(origval);
+ }
+
/* Handle side effects, and set the global value for
* ":set" on local options. */
errmsg = did_set_string_option(opt_idx, (char_u **)varp,
new_value_alloced, oldval, errbuf, opt_flags);
- /* If error detected, print the error message. */
- if (errmsg != NULL)
+ // If error detected, print the error message.
+ if (errmsg != NULL) {
+ xfree(saved_origval);
goto skip;
+ }
+
+ if (saved_origval != NULL) {
+ char_u buf_type[7];
+ vim_snprintf((char *)buf_type, ARRAY_SIZE(buf_type), "%s",
+ (opt_flags & OPT_LOCAL) ? "local" : "global");
+ set_vim_var_string(VV_OPTION_NEW,
+ *(char_u **)varp, -1);
+ set_vim_var_string(VV_OPTION_OLD, saved_origval, -1);
+ set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
+ apply_autocmds(EVENT_OPTIONSET,
+ (char_u *)options[opt_idx].fullname,
+ NULL, false, NULL);
+ reset_v_option_vars();
+ xfree(saved_origval);
+ }
} else {
// key code option(FIXME(tarruda): Show a warning or something
// similar)
@@ -2070,6 +2349,7 @@ set_string_option (
char_u *s;
char_u **varp;
char_u *oldval;
+ char_u *saved_oldval = NULL;
char_u *r = NULL;
if (options[opt_idx].var == NULL) /* don't set hidden option */
@@ -2083,10 +2363,30 @@ set_string_option (
: opt_flags);
oldval = *varp;
*varp = s;
- if ((r = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
+
+ if (!starting) {
+ saved_oldval = vim_strsave(oldval);
+ }
+
+ if ((r = did_set_string_option(opt_idx, varp, (int)true, oldval, NULL,
opt_flags)) == NULL)
did_set_option(opt_idx, opt_flags, TRUE);
+ // call autocommand after handling side effects
+ if (saved_oldval != NULL) {
+ char_u buf_type[7];
+ vim_snprintf((char *)buf_type, ARRAY_SIZE(buf_type), "%s",
+ (opt_flags & OPT_LOCAL) ? "local" : "global");
+ set_vim_var_string(VV_OPTION_NEW, *varp, -1);
+ set_vim_var_string(VV_OPTION_OLD, saved_oldval, -1);
+ set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
+ apply_autocmds(EVENT_OPTIONSET,
+ (char_u *)options[opt_idx].fullname,
+ NULL, false, NULL);
+ reset_v_option_vars();
+ xfree(saved_oldval);
+ }
+
return r;
}
@@ -3288,6 +3588,9 @@ set_bool_option (
/* when 'endofline' is changed, redraw the window title */
else if ((int *)varp == &curbuf->b_p_eol) {
redraw_titles();
+ } else if ((int *)varp == &curbuf->b_p_fixeol) {
+ // when 'fixeol' is changed, redraw the window title
+ redraw_titles();
}
/* when 'bomb' is changed, redraw the window title and tab page text */
else if ((int *)varp == &curbuf->b_p_bomb) {
@@ -3555,8 +3858,29 @@ set_bool_option (
* End of handling side effects for bool options.
*/
+ // after handling side effects, call autocommand
+
options[opt_idx].flags |= P_WAS_SET;
+ if (!starting) {
+ char_u buf_old[2];
+ char_u buf_new[2];
+ char_u buf_type[7];
+ vim_snprintf((char *)buf_old, ARRAY_SIZE(buf_old), "%d",
+ old_value ? true: false);
+ vim_snprintf((char *)buf_new, ARRAY_SIZE(buf_new), "%d",
+ value ? true: false);
+ vim_snprintf((char *)buf_type, ARRAY_SIZE(buf_type), "%s",
+ (opt_flags & OPT_LOCAL) ? "local" : "global");
+ set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
+ set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
+ set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
+ apply_autocmds(EVENT_OPTIONSET,
+ (char_u *) options[opt_idx].fullname,
+ NULL, false, NULL);
+ reset_v_option_vars();
+ }
+
comp_col(); /* in case 'ruler' or 'showcmd' changed */
if (curwin->w_curswant != MAXCOL
&& (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
@@ -3928,6 +4252,23 @@ set_num_option (
options[opt_idx].flags |= P_WAS_SET;
+ if (!starting && errmsg == NULL) {
+ char_u buf_old[NUMBUFLEN];
+ char_u buf_new[NUMBUFLEN];
+ char_u buf_type[7];
+ vim_snprintf((char *)buf_old, ARRAY_SIZE(buf_old), "%ld", old_value);
+ vim_snprintf((char *)buf_new, ARRAY_SIZE(buf_new), "%ld", value);
+ vim_snprintf((char *)buf_type, ARRAY_SIZE(buf_type), "%s",
+ (opt_flags & OPT_LOCAL) ? "local" : "global");
+ set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
+ set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
+ set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
+ apply_autocmds(EVENT_OPTIONSET,
+ (char_u *) options[opt_idx].fullname,
+ NULL, false, NULL);
+ reset_v_option_vars();
+ }
+
comp_col(); /* in case 'columns' or 'ls' changed */
if (curwin->w_curswant != MAXCOL
&& (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
@@ -4962,6 +5303,7 @@ static char_u *get_varp(vimoption_T *p)
case PV_CFU: return (char_u *)&(curbuf->b_p_cfu);
case PV_OFU: return (char_u *)&(curbuf->b_p_ofu);
case PV_EOL: return (char_u *)&(curbuf->b_p_eol);
+ case PV_FIXEOL: return (char_u *)&(curbuf->b_p_fixeol);
case PV_ET: return (char_u *)&(curbuf->b_p_et);
case PV_FENC: return (char_u *)&(curbuf->b_p_fenc);
case PV_FF: return (char_u *)&(curbuf->b_p_ff);
@@ -5206,6 +5548,7 @@ void buf_copy_options(buf_T *buf, int flags)
buf->b_p_bin = p_bin;
buf->b_p_bomb = p_bomb;
buf->b_p_et = p_et;
+ buf->b_p_fixeol = p_fixeol;
buf->b_p_et_nobin = p_et_nobin;
buf->b_p_ml = p_ml;
buf->b_p_ml_nobin = p_ml_nobin;
@@ -5948,7 +6291,7 @@ static void paste_option_changed(void)
old_p_paste = p_paste;
}
-/// vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found.
+/// vimrc_found() - Called when a vimrc or "VIMINIT" has been found.
///
/// Set the values for options that didn't get set yet to the Vim defaults.
/// When "fname" is not NULL, use it to set $"envname" when it wasn't set yet.
@@ -6141,6 +6484,7 @@ void save_file_ff(buf_T *buf)
* from when editing started (save_file_ff() called).
* Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was
* changed and 'binary' is not set.
+ * Also when 'endofline' was changed and 'fixeol' is not set.
* When "ignore_empty" is true don't consider a new, empty buffer to be
* changed.
*/
@@ -6155,9 +6499,9 @@ bool file_ff_differs(buf_T *buf, bool ignore_empty)
&& *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)
return FALSE;
if (buf->b_start_ffc != *buf->b_p_ff)
- return TRUE;
- if (buf->b_p_bin && buf->b_start_eol != buf->b_p_eol)
- return TRUE;
+ return true;
+ if ((buf->b_p_bin || !buf->b_p_fixeol) && buf->b_start_eol != buf->b_p_eol)
+ return true;
if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb)
return TRUE;
if (buf->b_start_fenc == NULL)
diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h
index d4d3410d5c..c72e1cf0bb 100644
--- a/src/nvim/option_defs.h
+++ b/src/nvim/option_defs.h
@@ -665,6 +665,7 @@ enum {
, BV_DEF
, BV_INC
, BV_EOL
+ , BV_FIXEOL
, BV_EP
, BV_ET
, BV_FENC
diff --git a/src/nvim/options.lua b/src/nvim/options.lua
index 842b0a7c82..5187340629 100644
--- a/src/nvim/options.lua
+++ b/src/nvim/options.lua
@@ -51,15 +51,6 @@ return {
defaults={if_true={vi=224}}
},
{
- full_name='antialias', abbreviation='anti',
- type='bool', scope={'global'},
- vi_def=true,
- vim=true,
- redraw={'everything'},
- enable_if=false,
- defaults={if_true={vi=false, vim=false}}
- },
- {
full_name='arabic', abbreviation='arab',
type='bool', scope={'window'},
vi_def=true,
@@ -176,7 +167,7 @@ return {
vi_def=true,
expand=true,
varname='p_bdir',
- defaults={if_true={vi=macros('DFLT_BDIR')}}
+ defaults={if_true={vi=''}}
},
{
full_name='backupext', abbreviation='bex',
@@ -627,7 +618,7 @@ return {
vi_def=true,
expand=true,
varname='p_dir',
- defaults={if_true={vi=macros('DFLT_DIR')}}
+ defaults={if_true={vi=''}}
},
{
full_name='display', abbreviation='dy',
@@ -808,6 +799,14 @@ return {
defaults={if_true={vi="vert:|,fold:-"}}
},
{
+ full_name='fixendofline', abbreviation='fixeol',
+ type='bool', scope={'buffer'},
+ vi_def=true,
+ redraw={'statuslines'},
+ varname='p_fixeol',
+ defaults={if_true={vi=true}}
+ },
+ {
full_name='fkmap', abbreviation='fk',
type='bool', scope={'global'},
vi_def=true,
@@ -1916,7 +1915,7 @@ return {
vi_def=true,
expand=true,
varname='p_rtp',
- defaults={if_true={vi=macros('DFLT_RUNTIMEPATH')}}
+ defaults={if_true={vi=''}}
},
{
full_name='scroll', abbreviation='scr',
@@ -2524,7 +2523,7 @@ return {
vi_def=true,
expand=true,
varname='p_udir',
- defaults={if_true={vi="."}}
+ defaults={if_true={vi=''}}
},
{
full_name='undofile', abbreviation='udf',
@@ -2585,7 +2584,7 @@ return {
vi_def=true,
expand=true,
varname='p_vdir',
- defaults={if_true={vi=macros('DFLT_VDIR')}}
+ defaults={if_true={vi=''}}
},
{
full_name='viewoptions', abbreviation='vop',
diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c
index 7be8a868bd..a791dca39c 100644
--- a/src/nvim/os/env.c
+++ b/src/nvim/os/env.c
@@ -46,7 +46,19 @@ bool os_env_exists(const char *name)
int os_setenv(const char *name, const char *value, int overwrite)
FUNC_ATTR_NONNULL_ALL
{
+#ifdef HAVE_SETENV
return setenv(name, value, overwrite);
+#elif defined(HAVE_PUTENV_S)
+ if (!overwrite && os_getenv(name) != NULL) {
+ return 0;
+ }
+ if (_putenv_s(name, value) == 0) {
+ return 0;
+ }
+ return -1;
+#else
+# error "This system has no implementation available for os_setenv()"
+#endif
}
/// Unset environment variable
@@ -141,6 +153,27 @@ void init_homedir(void)
char_u *var = (char_u *)os_getenv("HOME");
+#ifdef WIN32
+ // Typically, $HOME is not defined on Windows, unless the user has
+ // specifically defined it for Vim's sake. However, on Windows NT
+ // platforms, $HOMEDRIVE and $HOMEPATH are automatically defined for
+ // each user. Try constructing $HOME from these.
+ if (var == NULL) {
+ const char *homedrive = os_getenv("HOMEDRIVE");
+ const char *homepath = os_getenv("HOMEPATH");
+ if (homepath == NULL) {
+ homepath = "\\";
+ }
+ if (homedrive != NULL && strlen(homedrive) + strlen(homepath) < MAXPATHL) {
+ snprintf((char *)NameBuff, MAXPATHL, "%s%s", homedrive, homepath);
+ if (NameBuff[0] != NUL) {
+ var = NameBuff;
+ vim_setenv("HOME", (char *)NameBuff);
+ }
+ }
+ }
+#endif
+
if (var != NULL) {
#ifdef UNIX
/*
@@ -415,6 +448,74 @@ static char *remove_tail(char *p, char *pend, char *name)
return pend;
}
+/// Iterate over colon-separated list
+///
+/// @note Environment variables must not be modified during iteration.
+///
+/// @param[in] val Value of the environment variable to iterate over.
+/// @param[in] iter Pointer used for iteration. Must be NULL on first
+/// iteration.
+/// @param[out] dir Location where pointer to the start of the current
+/// directory name should be saved. May be set to NULL.
+/// @param[out] len Location where current directory length should be saved.
+///
+/// @return Next iter argument value or NULL when iteration should stop.
+const void *vim_colon_env_iter(const char *const val,
+ const void *const iter,
+ const char **const dir,
+ size_t *const len)
+ FUNC_ATTR_NONNULL_ARG(1, 3, 4) FUNC_ATTR_WARN_UNUSED_RESULT
+{
+ const char *varval = (const char *) iter;
+ if (varval == NULL) {
+ varval = val;
+ }
+ *dir = varval;
+ const char *const dirend = strchr(varval, ':');
+ if (dirend == NULL) {
+ *len = strlen(varval);
+ return NULL;
+ } else {
+ *len = (size_t) (dirend - varval);
+ return dirend + 1;
+ }
+}
+
+/// Iterate over colon-separated list in reverse order
+///
+/// @note Environment variables must not be modified during iteration.
+///
+/// @param[in] val Value of the environment variable to iterate over.
+/// @param[in] iter Pointer used for iteration. Must be NULL on first
+/// iteration.
+/// @param[out] dir Location where pointer to the start of the current
+/// directory name should be saved. May be set to NULL.
+/// @param[out] len Location where current directory length should be saved.
+///
+/// @return Next iter argument value or NULL when iteration should stop.
+const void *vim_colon_env_iter_rev(const char *const val,
+ const void *const iter,
+ const char **const dir,
+ size_t *const len)
+ FUNC_ATTR_NONNULL_ARG(1, 3, 4) FUNC_ATTR_WARN_UNUSED_RESULT
+{
+ const char *varend = (const char *) iter;
+ if (varend == NULL) {
+ varend = val + strlen(val) - 1;
+ }
+ const size_t varlen = (size_t) (varend - val) + 1;
+ const char *const colon = xmemrchr(val, ':', varlen);
+ if (colon == NULL) {
+ *len = varlen;
+ *dir = val;
+ return NULL;
+ } else {
+ *dir = colon + 1;
+ *len = (size_t) (varend - colon);
+ return colon - 1;
+ }
+}
+
/// Vim's version of getenv().
/// Special handling of $HOME, $VIM and $VIMRUNTIME, allowing the user to
/// override the vim runtime directory at runtime. Also does ACP to 'enc'
diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c
index 522e49950c..d59b66e773 100644
--- a/src/nvim/os/fs.c
+++ b/src/nvim/os/fs.c
@@ -140,9 +140,8 @@ static bool is_executable(const char_u *name)
static bool is_executable_in_path(const char_u *name, char_u **abspath)
FUNC_ATTR_NONNULL_ARG(1)
{
- const char *path = getenv("PATH");
- // PATH environment variable does not exist or is empty.
- if (path == NULL || *path == NUL) {
+ const char *path = os_getenv("PATH");
+ if (path == NULL) {
return false;
}
@@ -186,13 +185,13 @@ static bool is_executable_in_path(const char_u *name, char_u **abspath)
/// Opens or creates a file and returns a non-negative integer representing
/// the lowest-numbered unused file descriptor, for use in subsequent system
-/// calls (read, write, lseek, fcntl, etc.). If the operation fails, `-errno`
-/// is returned, and no file is created or modified.
+/// calls (read, write, lseek, fcntl, etc.). If the operation fails, a libuv
+/// error code is returned, and no file is created or modified.
///
/// @param flags Bitwise OR of flags defined in <fcntl.h>
/// @param mode Permissions for the newly-created file (IGNORED if 'flags' is
/// not `O_CREAT` or `O_TMPFILE`), subject to the current umask
-/// @return file descriptor, or negative `errno` on failure
+/// @return file descriptor, or libuv error code on failure
int os_open(const char* path, int flags, int mode)
FUNC_ATTR_NONNULL_ALL
{
@@ -205,28 +204,29 @@ int os_open(const char* path, int flags, int mode)
/// Get stat information for a file.
///
-/// @return OK on success, FAIL if a failure occurred.
-static bool os_stat(const char *name, uv_stat_t *statbuf)
+/// @return libuv return code.
+static int os_stat(const char *name, uv_stat_t *statbuf)
FUNC_ATTR_NONNULL_ALL
{
uv_fs_t request;
int result = uv_fs_stat(&fs_loop, &request, name, NULL);
*statbuf = request.statbuf;
uv_fs_req_cleanup(&request);
- return (result == kLibuvSuccess);
+ return result;
}
/// Get the file permissions for a given file.
///
-/// @return `-1` when `name` doesn't exist.
+/// @return libuv error code on error.
int32_t os_getperm(const char_u *name)
FUNC_ATTR_NONNULL_ALL
{
uv_stat_t statbuf;
- if (os_stat((char *)name, &statbuf)) {
+ int stat_result = os_stat((char *)name, &statbuf);
+ if (stat_result == kLibuvSuccess) {
return (int32_t)statbuf.st_mode;
} else {
- return -1;
+ return stat_result;
}
}
@@ -271,7 +271,7 @@ bool os_file_exists(const char_u *name)
FUNC_ATTR_NONNULL_ALL
{
uv_stat_t statbuf;
- return os_stat((char *)name, &statbuf);
+ return os_stat((char *)name, &statbuf) == kLibuvSuccess;
}
/// Check if a file is readable.
@@ -323,7 +323,7 @@ int os_rename(const char_u *path, const char_u *new_path)
/// Make a directory.
///
-/// @return `0` for success, -errno for failure.
+/// @return `0` for success, libuv error code for failure.
int os_mkdir(const char *path, int32_t mode)
FUNC_ATTR_NONNULL_ALL
{
@@ -343,7 +343,7 @@ int os_mkdir(const char *path, int32_t mode)
/// failed to create. I.e. it will contain dir or any
/// of the higher level directories.
///
-/// @return `0` for success, -errno for failure.
+/// @return `0` for success, libuv error code for failure.
int os_mkdir_recurse(const char *const dir, int32_t mode,
char **const failed_dir)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT
@@ -366,11 +366,17 @@ int os_mkdir_recurse(const char *const dir, int32_t mode,
}
while (e != real_end) {
if (e > past_head) {
- *e = '/';
+ *e = PATHSEP;
} else {
*past_head = past_head_save;
}
- e += strlen(e);
+ const size_t component_len = strlen(e);
+ e += component_len;
+ if (e == real_end
+ && memcnt(e - component_len, PATHSEP, component_len) == component_len) {
+ // Path ends with something like "////". Ignore this.
+ break;
+ }
int ret;
if ((ret = os_mkdir(curdir, mode)) != 0) {
*failed_dir = curdir;
@@ -465,7 +471,7 @@ int os_remove(const char *path)
bool os_fileinfo(const char *path, FileInfo *file_info)
FUNC_ATTR_NONNULL_ALL
{
- return os_stat(path, &(file_info->stat));
+ return os_stat(path, &(file_info->stat)) == kLibuvSuccess;
}
/// Get the file information for a given path without following links
@@ -567,7 +573,7 @@ bool os_fileid(const char *path, FileID *file_id)
FUNC_ATTR_NONNULL_ALL
{
uv_stat_t statbuf;
- if (os_stat(path, &statbuf)) {
+ if (os_stat(path, &statbuf) == kLibuvSuccess) {
file_id->inode = statbuf.st_ino;
file_id->device_id = statbuf.st_dev;
return true;
diff --git a/src/nvim/os/fs_defs.h b/src/nvim/os/fs_defs.h
index df1031b721..52b2841514 100644
--- a/src/nvim/os/fs_defs.h
+++ b/src/nvim/os/fs_defs.h
@@ -21,9 +21,9 @@ typedef struct {
uv_dirent_t ent; ///< @private The entry information.
} Directory;
-/// Function to convert -errno error to char * error description
+/// Function to convert libuv error to char * error description
///
-/// -errno errors are returned by a number of os functions.
+/// negative libuv error codes are returned by a number of os functions.
#define os_strerror uv_strerror
#endif // NVIM_OS_FS_DEFS_H
diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c
index e2cff2f9c0..ef6b5ff6f5 100644
--- a/src/nvim/os/input.c
+++ b/src/nvim/os/input.c
@@ -73,10 +73,27 @@ void input_stop(void)
stream_close(&read_stream, NULL);
}
+static void cursorhold_event(void **argv)
+{
+ event_T event = State & INSERT ? EVENT_CURSORHOLDI : EVENT_CURSORHOLD;
+ apply_autocmds(event, NULL, NULL, false, curbuf);
+ did_cursorhold = true;
+}
+
+static void create_cursorhold_event(void)
+{
+ // If events are enabled and the queue has any items, this function should not
+ // have been called(inbuf_poll would return kInputAvail)
+ // TODO(tarruda): Cursorhold should be implemented as a timer set during the
+ // `state_check` callback for the states where it can be triggered.
+ assert(!events_enabled || queue_empty(loop.events));
+ queue_put(loop.events, cursorhold_event, 0);
+}
+
// Low level input function
int os_inchar(uint8_t *buf, int maxlen, int ms, int tb_change_cnt)
{
- if (rbuffer_size(input_buffer)) {
+ if (maxlen && rbuffer_size(input_buffer)) {
return (int)rbuffer_read(input_buffer, (char *)buf, (size_t)maxlen);
}
@@ -87,16 +104,12 @@ int os_inchar(uint8_t *buf, int maxlen, int ms, int tb_change_cnt)
}
} else {
if ((result = inbuf_poll((int)p_ut)) == kInputNone) {
- if (trigger_cursorhold() && maxlen >= 3
- && !typebuf_changed(tb_change_cnt)) {
- buf[0] = K_SPECIAL;
- buf[1] = KS_EXTRA;
- buf[2] = KE_CURSORHOLD;
- return 3;
+ if (trigger_cursorhold() && !typebuf_changed(tb_change_cnt)) {
+ create_cursorhold_event();
+ } else {
+ before_blocking();
+ result = inbuf_poll(-1);
}
-
- before_blocking();
- result = inbuf_poll(-1);
}
}
@@ -105,14 +118,14 @@ int os_inchar(uint8_t *buf, int maxlen, int ms, int tb_change_cnt)
return 0;
}
- if (rbuffer_size(input_buffer)) {
+ if (maxlen && rbuffer_size(input_buffer)) {
// Safe to convert rbuffer_read to int, it will never overflow since we use
// relatively small buffers.
return (int)rbuffer_read(input_buffer, (char *)buf, (size_t)maxlen);
}
// If there are events, return the keys directly
- if (pending_events()) {
+ if (maxlen && pending_events()) {
return push_event_key(buf, maxlen);
}
@@ -313,6 +326,11 @@ void input_done(void)
input_eof = true;
}
+bool input_available(void)
+{
+ return rbuffer_size(input_buffer) != 0;
+}
+
// This is a replacement for the old `WaitForChar` function in os_unix.c
static InbufPollResult inbuf_poll(int ms)
{
diff --git a/src/nvim/os/os.h b/src/nvim/os/os.h
index 69bd1ff4fd..3e89e5a94a 100644
--- a/src/nvim/os/os.h
+++ b/src/nvim/os/os.h
@@ -5,6 +5,7 @@
#include <uv.h>
#include "nvim/os/fs_defs.h"
+#include "nvim/os/stdpaths_defs.h"
#include "nvim/vim.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
@@ -12,6 +13,7 @@
# include "os/mem.h.generated.h"
# include "os/env.h.generated.h"
# include "os/users.h.generated.h"
+# include "os/stdpaths.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 3d56115401..7d77899287 100644
--- a/src/nvim/os/os_defs.h
+++ b/src/nvim/os/os_defs.h
@@ -39,32 +39,6 @@
# define MAXPATHL 1024
#endif
-#ifndef FILETYPE_FILE
-# define FILETYPE_FILE "filetype.vim"
-#endif
-
-#ifndef FTPLUGIN_FILE
-# define FTPLUGIN_FILE "ftplugin.vim"
-#endif
-
-#ifndef INDENT_FILE
-# define INDENT_FILE "indent.vim"
-#endif
-
-#ifndef FTOFF_FILE
-# define FTOFF_FILE "ftoff.vim"
-#endif
-
-#ifndef FTPLUGOF_FILE
-# define FTPLUGOF_FILE "ftplugof.vim"
-#endif
-
-#ifndef INDOFF_FILE
-# define INDOFF_FILE "indoff.vim"
-#endif
-
-#define DFLT_ERRORFILE "errors.err"
-
// Command-processing buffer. Use large buffers for all platforms.
#define CMDBUFFSIZE 1024
@@ -103,9 +77,9 @@
# include <strings.h>
#endif
-/// Function to convert -errno error to char * error description
+/// Function to convert libuv error to char * error description
///
-/// -errno errors are returned by a number of os functions.
+/// negative libuv error codes are returned by a number of os functions.
#define os_strerror uv_strerror
#endif // NVIM_OS_OS_DEFS_H
diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c
index 57e25560de..3813c45726 100644
--- a/src/nvim/os/shell.c
+++ b/src/nvim/os/shell.c
@@ -418,7 +418,8 @@ static void read_input(DynamicBuffer *buf)
// Finished a line, add a NL, unless this line should not have one.
// FIXME need to make this more readable
if (lnum != curbuf->b_op_end.lnum
- || !curbuf->b_p_bin
+ || (!curbuf->b_p_bin
+ && curbuf->b_p_fixeol)
|| (lnum != curbuf->b_no_eol_lnum
&& (lnum !=
curbuf->b_ml.ml_line_count
diff --git a/src/nvim/os/signal.c b/src/nvim/os/signal.c
index 7158721433..0ff6016e32 100644
--- a/src/nvim/os/signal.c
+++ b/src/nvim/os/signal.c
@@ -32,9 +32,13 @@ void signal_init(void)
signal_watcher_init(&loop, &shup, NULL);
signal_watcher_init(&loop, &squit, NULL);
signal_watcher_init(&loop, &sterm, NULL);
+#ifdef SIGPIPE
signal_watcher_start(&spipe, on_signal, SIGPIPE);
+#endif
signal_watcher_start(&shup, on_signal, SIGHUP);
+#ifdef SIGQUIT
signal_watcher_start(&squit, on_signal, SIGQUIT);
+#endif
signal_watcher_start(&sterm, on_signal, SIGTERM);
#ifdef SIGPWR
signal_watcher_init(&loop, &spwr, NULL);
@@ -82,12 +86,16 @@ static char * signal_name(int signum)
case SIGPWR:
return "SIGPWR";
#endif
+#ifdef SIGPIPE
case SIGPIPE:
return "SIGPIPE";
+#endif
case SIGTERM:
return "SIGTERM";
+#ifdef SIGQUIT
case SIGQUIT:
return "SIGQUIT";
+#endif
case SIGHUP:
return "SIGHUP";
default:
@@ -123,11 +131,15 @@ static void on_signal(SignalWatcher *handle, int signum, void *data)
ml_sync_all(false, false);
break;
#endif
+#ifdef SIGPIPE
case SIGPIPE:
// Ignore
break;
+#endif
case SIGTERM:
+#ifdef SIGQUIT
case SIGQUIT:
+#endif
case SIGHUP:
if (!rejecting_deadly) {
deadly_signal(signum);
diff --git a/src/nvim/os/stdpaths.c b/src/nvim/os/stdpaths.c
new file mode 100644
index 0000000000..c9631a434c
--- /dev/null
+++ b/src/nvim/os/stdpaths.c
@@ -0,0 +1,108 @@
+#include <stdbool.h>
+
+#include "nvim/os/stdpaths_defs.h"
+#include "nvim/os/os.h"
+#include "nvim/path.h"
+#include "nvim/memory.h"
+#include "nvim/ascii.h"
+
+/// Names of the environment variables, mapped to XDGVarType values
+static const char *xdg_env_vars[] = {
+ [kXDGConfigHome] = "XDG_CONFIG_HOME",
+ [kXDGDataHome] = "XDG_DATA_HOME",
+ [kXDGCacheHome] = "XDG_CACHE_HOME",
+ [kXDGRuntimeDir] = "XDG_RUNTIME_DIR",
+ [kXDGConfigDirs] = "XDG_CONFIG_DIRS",
+ [kXDGDataDirs] = "XDG_DATA_DIRS",
+};
+
+/// Defaults for XDGVarType values
+///
+/// Used in case environment variables contain nothing. Need to be expanded.
+static const char *const xdg_defaults[] = {
+#ifdef WIN32
+ // Windows
+ [kXDGConfigHome] = "$LOCALAPPDATA\\nvim\\config",
+ [kXDGDataHome] = "$LOCALAPPDATA\\nvim\\data",
+ [kXDGCacheHome] = "$LOCALAPPDATA\\nvim\\cache",
+ [kXDGRuntimeDir] = NULL,
+ [kXDGConfigDirs] = NULL,
+ [kXDGDataDirs] = NULL,
+#else
+ // Linux, BSD, CYGWIN, Apple
+ [kXDGConfigHome] = "~/.config",
+ [kXDGDataHome] = "~/.local/share",
+ [kXDGCacheHome] = "~/.cache",
+ [kXDGRuntimeDir] = NULL,
+ [kXDGConfigDirs] = "/etc/xdg/",
+ [kXDGDataDirs] = "/usr/local/share/:/usr/share/",
+#endif
+};
+
+/// Return XDG variable value
+///
+/// @param[in] idx XDG variable to use.
+///
+/// @return [allocated] variable value.
+char *stdpaths_get_xdg_var(const XDGVarType idx)
+ FUNC_ATTR_WARN_UNUSED_RESULT
+{
+ const char *const env = xdg_env_vars[idx];
+ const char *const fallback = xdg_defaults[idx];
+
+ const char *const env_val = os_getenv(env);
+ char *ret = NULL;
+ if (env_val != NULL) {
+ ret = xstrdup(env_val);
+ } else if (fallback) {
+ ret = (char *) expand_env_save((char_u *)fallback);
+ }
+
+ return ret;
+}
+
+/// Return nvim-specific XDG directory subpath
+///
+/// @param[in] idx XDG directory to use.
+///
+/// @return [allocated] `{xdg_directory}/nvim`
+static char *get_xdg_home(const XDGVarType idx)
+ FUNC_ATTR_WARN_UNUSED_RESULT
+{
+ char *dir = stdpaths_get_xdg_var(idx);
+ if (dir) {
+ dir = concat_fnames_realloc(dir, "nvim", true);
+ }
+ return dir;
+}
+
+/// Return subpath of $XDG_CONFIG_HOME
+///
+/// @param[in] fname New component of the path.
+///
+/// @return [allocated] `$XDG_CONFIG_HOME/nvim/{fname}`
+char *stdpaths_user_conf_subpath(const char *fname)
+ FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET
+{
+ return concat_fnames_realloc(get_xdg_home(kXDGConfigHome), fname, true);
+}
+
+/// Return subpath of $XDG_DATA_HOME
+///
+/// @param[in] fname New component of the path.
+/// @param[in] trailing_pathseps Amount of trailing path separators to add.
+///
+/// @return [allocated] `$XDG_DATA_HOME/nvim/{fname}`
+char *stdpaths_user_data_subpath(const char *fname,
+ const size_t trailing_pathseps)
+ FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET
+{
+ char *ret = concat_fnames_realloc(get_xdg_home(kXDGDataHome), fname, true);
+ if (trailing_pathseps) {
+ const size_t len = strlen(ret);
+ ret = xrealloc(ret, len + trailing_pathseps + 1);
+ memset(ret + len, PATHSEP, trailing_pathseps);
+ ret[len + trailing_pathseps] = NUL;
+ }
+ return ret;
+}
diff --git a/src/nvim/os/stdpaths_defs.h b/src/nvim/os/stdpaths_defs.h
new file mode 100644
index 0000000000..1433e0bc62
--- /dev/null
+++ b/src/nvim/os/stdpaths_defs.h
@@ -0,0 +1,14 @@
+#ifndef NVIM_OS_STDPATHS_DEFS_H
+#define NVIM_OS_STDPATHS_DEFS_H
+
+/// List of possible XDG variables
+typedef enum {
+ kXDGConfigHome, ///< XDG_CONFIG_HOME
+ kXDGDataHome, ///< XDG_DATA_HOME
+ kXDGCacheHome, ///< XDG_CACHE_HOME
+ kXDGRuntimeDir, ///< XDG_RUNTIME_DIR
+ kXDGConfigDirs, ///< XDG_CONFIG_DIRS
+ kXDGDataDirs, ///< XDG_DATA_DIRS
+} XDGVarType;
+
+#endif // NVIM_OS_STDPATHS_DEFS_H
diff --git a/src/nvim/os/unix_defs.h b/src/nvim/os/unix_defs.h
index 949973bf40..e3ba3262f4 100644
--- a/src/nvim/os/unix_defs.h
+++ b/src/nvim/os/unix_defs.h
@@ -9,7 +9,6 @@
# include <sys/param.h>
#endif
-
#define TEMP_DIR_NAMES {"$TMPDIR", "/tmp", ".", "~"}
#define TEMP_FILE_PATH_MAXLEN 256
@@ -18,56 +17,4 @@
// Special wildcards that need to be handled by the shell.
#define SPECIAL_WILDCHAR "`'{"
-// Unix system-dependent file names
-#ifndef SYS_VIMRC_FILE
-# define SYS_VIMRC_FILE "$VIM/nvimrc"
-#endif
-#ifndef DFLT_HELPFILE
-# define DFLT_HELPFILE "$VIMRUNTIME/doc/help.txt"
-#endif
-#ifndef SYNTAX_FNAME
-# define SYNTAX_FNAME "$VIMRUNTIME/syntax/%s.vim"
-#endif
-#ifndef USR_EXRC_FILE
-# define USR_EXRC_FILE "~/.exrc"
-#endif
-#ifndef USR_VIMRC_FILE
-# define USR_VIMRC_FILE "~/.nvimrc"
-#endif
-#ifndef USR_VIMRC_FILE2
-# define USR_VIMRC_FILE2 "~/.nvim/nvimrc"
-#endif
-#ifndef EXRC_FILE
-# define EXRC_FILE ".exrc"
-#endif
-#ifndef VIMRC_FILE
-# define VIMRC_FILE ".nvimrc"
-#endif
-#ifndef SHADA_FILE
-# define SHADA_FILE "~/.nvim/shada/main.shada"
-#endif
-
-// Default for 'backupdir'.
-#ifndef DFLT_BDIR
-# define DFLT_BDIR ".,~/tmp,~/"
-#endif
-
-// Default for 'directory'.
-#ifndef DFLT_DIR
-# define DFLT_DIR ".,~/tmp,/var/tmp,/tmp"
-#endif
-
-// Default for 'viewdir'.
-#ifndef DFLT_VDIR
-# define DFLT_VDIR "~/.nvim/view"
-#endif
-
-#ifdef RUNTIME_GLOBAL
-# define DFLT_RUNTIMEPATH "~/.nvim," RUNTIME_GLOBAL ",$VIMRUNTIME," \
- RUNTIME_GLOBAL "/after,~/.nvim/after"
-#else
-# define DFLT_RUNTIMEPATH \
- "~/.nvim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,~/.nvim/after"
-#endif
-
#endif // NVIM_OS_UNIX_DEFS_H
diff --git a/src/nvim/os/win_defs.h b/src/nvim/os/win_defs.h
index b7ec50a109..32960dfbe9 100644
--- a/src/nvim/os/win_defs.h
+++ b/src/nvim/os/win_defs.h
@@ -6,21 +6,6 @@
#define TEMP_DIR_NAMES {"$TMP", "$TEMP", "$USERPROFILE", ""}
#define TEMP_FILE_PATH_MAXLEN _MAX_PATH
-// Defines needed to fix the build on Windows:
-// - USR_EXRC_FILE
-// - USR_VIMRC_FILE
-// - SHADA_FILE
-// - DFLT_DIR
-// - DFLT_BDIR
-// - DFLT_VDIR
-// - DFLT_RUNTIMEPATH
-// - EXRC_FILE
-// - VIMRC_FILE
-// - SYNTAX_FNAME
-// - DFLT_HELPFILE
-// - SYS_VIMRC_FILE
-// - SPECIAL_WILDCHAR
-
#define USE_CRNL
#ifdef _MSC_VER
@@ -32,7 +17,9 @@
# endif
#endif
+#ifdef _MSC_VER
typedef SSIZE_T ssize_t;
+#endif
#ifndef SSIZE_MAX
# ifdef _WIN64
diff --git a/src/nvim/os_unix.c b/src/nvim/os_unix.c
index 828ccd556d..62b264046c 100644
--- a/src/nvim/os_unix.c
+++ b/src/nvim/os_unix.c
@@ -1,12 +1,4 @@
/*
- * VIM - Vi IMproved by Bram Moolenaar
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- * See README.txt for an overview of the Vim source code.
- */
-
-/*
* os_unix.c -- code for all flavors of Unix (BSD, SYSV, SVR4, POSIX, ...)
*
* A lot of this file was originally written by Juergen Weigert and later
diff --git a/src/nvim/path.c b/src/nvim/path.c
index a9d1d052d4..253035ed99 100644
--- a/src/nvim/path.c
+++ b/src/nvim/path.c
@@ -1,6 +1,4 @@
-
#include <assert.h>
-#include <errno.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdlib.h>
@@ -329,6 +327,31 @@ int vim_fnamencmp(char_u *x, char_u *y, size_t len)
#endif
}
+/// Append fname2 to fname1
+///
+/// @param[in] fname1 First fname to append to.
+/// @param[in] len1 Length of fname1.
+/// @param[in] fname2 Secord part of the file name.
+/// @param[in] len2 Length of fname2.
+/// @param[in] sep If true and fname1 does not end with a path separator,
+/// add a path separator before fname2.
+///
+/// @return fname1
+static inline char *do_concat_fnames(char *fname1, const size_t len1,
+ const char *fname2, const size_t len2,
+ const bool sep)
+ FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET
+{
+ if (sep && *fname1 && !after_pathsep(fname1, fname1 + len1)) {
+ fname1[len1] = PATHSEP;
+ memmove(fname1 + len1 + 1, fname2, len2 + 1);
+ } else {
+ memmove(fname1 + len1, fname2, len2 + 1);
+ }
+
+ return fname1;
+}
+
/// Concatenate file names fname1 and fname2 into allocated memory.
///
/// Only add a '/' or '\\' when 'sep' is true and it is necessary.
@@ -339,17 +362,33 @@ int vim_fnamencmp(char_u *x, char_u *y, size_t len)
/// if necessary
/// @return [allocated] Concatenation of fname1 and fname2.
char *concat_fnames(const char *fname1, const char *fname2, bool sep)
- FUNC_ATTR_NONNULL_ARG(1, 2) FUNC_ATTR_NONNULL_RET
+ FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET
{
- char *dest = xmalloc(strlen(fname1) + strlen(fname2) + 3);
-
- strcpy(dest, fname1);
- if (sep) {
- add_pathsep(dest);
- }
- strcat(dest, fname2);
+ const size_t len1 = strlen(fname1);
+ const size_t len2 = strlen(fname2);
+ char *dest = xmalloc(len1 + len2 + 3);
+ memmove(dest, fname1, len1 + 1);
+ return do_concat_fnames(dest, len1, fname2, len2, sep);
+}
- return dest;
+/// Concatenate file names fname1 and fname2
+///
+/// Like concat_fnames(), but in place of allocating new memory it reallocates
+/// fname1. For this reason fname1 must be allocated with xmalloc, and can no
+/// longer be used after running concat_fnames_realloc.
+///
+/// @param fname1 is the first part of the path or filename
+/// @param fname2 is the second half of the path or filename
+/// @param sep is a flag to indicate a path separator should be added
+/// if necessary
+/// @return [allocated] Concatenation of fname1 and fname2.
+char *concat_fnames_realloc(char *fname1, const char *fname2, bool sep)
+ FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET
+{
+ const size_t len1 = strlen(fname1);
+ const size_t len2 = strlen(fname2);
+ return do_concat_fnames(xrealloc(fname1, len1 + len2 + 3), len1,
+ fname2, len2, sep);
}
/*
@@ -428,16 +467,13 @@ bool path_has_wildcard(const char_u *p)
return false;
}
-#if defined(UNIX)
/*
* Unix style wildcard expansion code.
- * It's here because it's used both for Unix and Mac.
*/
static int pstrcmp(const void *a, const void *b)
{
return pathcmp(*(char **)a, *(char **)b, -1);
}
-#endif
/// Checks if a path has a character path_expand can expand.
/// @param p The path to expand.
diff --git a/src/nvim/po/CMakeLists.txt b/src/nvim/po/CMakeLists.txt
index 243ac19b33..6687918df4 100644
--- a/src/nvim/po/CMakeLists.txt
+++ b/src/nvim/po/CMakeLists.txt
@@ -82,7 +82,7 @@ if(HAVE_WORKING_LIBINTL AND GETTEXT_FOUND AND XGETTEXT_PRG AND ICONV_PRG)
set(poFile ${CMAKE_CURRENT_SOURCE_DIR}/${name}.po)
add_custom_target(check-po-${name}
- COMMAND $<TARGET_FILE:nvim> -u NONE -n -e -X
+ COMMAND $<TARGET_FILE:nvim> -u NONE -n -e
-S ${CMAKE_CURRENT_SOURCE_DIR}/check.vim
-c "if error == 0 | q | endif" -c cq ${poFile} ||
${CMAKE_COMMAND} -E echo "${name}.po failed the check."
diff --git a/src/nvim/popupmnu.c b/src/nvim/popupmnu.c
index 10012a9775..001740943f 100644
--- a/src/nvim/popupmnu.c
+++ b/src/nvim/popupmnu.c
@@ -1,7 +1,7 @@
/// @file popupmnu.c
///
/// Popup menu (PUM)
-//
+
#include <assert.h>
#include <inttypes.h>
#include <stdbool.h>
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index 4d53238381..8e6ae46a3b 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -1,17 +1,8 @@
/*
- * VIM - Vi IMproved by Bram Moolenaar
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- * See README.txt for an overview of the Vim source code.
- */
-
-/*
* quickfix.c: functions for quickfix mode, using a file with error messages
*/
#include <assert.h>
-#include <errno.h>
#include <inttypes.h>
#include <stdbool.h>
#include <string.h>
diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c
index 4cd422400f..b96dcc66b3 100644
--- a/src/nvim/regexp_nfa.c
+++ b/src/nvim/regexp_nfa.c
@@ -1897,9 +1897,10 @@ static int nfa_regpiece(void)
return OK;
}
- // The engine is very inefficient (uses too many states) when the maximum is
- // much larger than the minimum. Bail out if we can use the other engine.
- if ((nfa_re_flags & RE_AUTO) && maxval > minval + 200) {
+ // The engine is very inefficient (uses too many states) when the maximum
+ // is much larger than the minimum and when the maximum is large. Bail out
+ // if we can use the other engine.
+ if ((nfa_re_flags & RE_AUTO) && (maxval > minval + 200 || maxval > 500)) {
return FAIL;
}
@@ -5761,7 +5762,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm
// Bail out quickly when there can't be a match, avoid the overhead of
// win_linetabsize() on long lines.
- if (op != 1 && col > t->state->val) {
+ if (op != 1 && col > t->state->val * (has_mbyte ? MB_MAXBYTES : 1)) {
break;
}
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index 0c4cf30602..9fdb476748 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -1,12 +1,4 @@
/*
- * VIM - Vi IMproved by Bram Moolenaar
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- * See README.txt for an overview of the Vim source code.
- */
-
-/*
* screen.c: code for displaying on the screen
*
* Output to the screen (console, terminal emulator or GUI window) is minimized
@@ -87,7 +79,6 @@
*/
#include <assert.h>
-#include <errno.h>
#include <inttypes.h>
#include <stdbool.h>
#include <string.h>
diff --git a/src/nvim/search.c b/src/nvim/search.c
index a44b0e00c7..fb7dfa350b 100644
--- a/src/nvim/search.c
+++ b/src/nvim/search.c
@@ -1,16 +1,8 @@
/*
- * VIM - Vi IMproved by Bram Moolenaar
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- * See README.txt for an overview of the Vim source code.
- */
-/*
* search.c: code for normal mode searching commands
*/
#include <assert.h>
-#include <errno.h>
#include <inttypes.h>
#include <stdbool.h>
#include <string.h>
@@ -926,7 +918,7 @@ static int first_submatch(regmmatch_T *rp)
* Careful: If spats[0].off.line == TRUE and spats[0].off.off == 0 this
* makes the movement linewise without moving the match position.
*
- * return 0 for failure, 1 for found, 2 for found and line offset added
+ * Return 0 for failure, 1 for found, 2 for found and line offset added.
*/
int do_search(
oparg_T *oap, /* can be NULL */
@@ -3201,6 +3193,7 @@ current_tagblock (
int do_include = include;
bool save_p_ws = p_ws;
int retval = FAIL;
+ int is_inclusive = true;
p_ws = false;
@@ -3295,9 +3288,16 @@ again:
if (inc_cursor() < 0)
break;
} else {
- /* Exclude the '<' of the end tag. */
- if (*get_cursor_pos_ptr() == '<')
+ char_u *c = get_cursor_pos_ptr();
+ // Exclude the '<' of the end tag.
+ // If the closing tag is on new line, do not decrement cursor, but make
+ // operation exclusive, so that the linefeed will be selected
+ if (*c == '<' && !VIsual_active && curwin->w_cursor.col == 0) {
+ // do not decrement cursor
+ is_inclusive = false;
+ } else if (*c == '<') {
dec_cursor();
+ }
}
end_pos = curwin->w_cursor;
@@ -3342,8 +3342,9 @@ again:
* on an empty area. */
curwin->w_cursor = start_pos;
oap->inclusive = false;
- } else
- oap->inclusive = true;
+ } else {
+ oap->inclusive = is_inclusive;
+ }
}
retval = OK;
@@ -4623,6 +4624,7 @@ void set_search_pattern(const SearchPattern pat)
{
free_spat(&spats[0]);
memcpy(&(spats[0]), &pat, sizeof(spats[0]));
+ set_vv_searchforward();
}
/// Set last substitute pattern
diff --git a/src/nvim/shada.c b/src/nvim/shada.c
index 523f8db6f0..340c14066a 100644
--- a/src/nvim/shada.c
+++ b/src/nvim/shada.c
@@ -10,7 +10,9 @@
#include <stdint.h>
#include <inttypes.h>
#include <errno.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <assert.h>
#include <msgpack.h>
@@ -43,6 +45,7 @@
#include "nvim/path.h"
#include "nvim/fileio.h"
#include "nvim/strings.h"
+#include "nvim/quickfix.h"
#include "nvim/lib/khash.h"
#include "nvim/lib/kvec.h"
@@ -98,6 +101,7 @@ KHASH_SET_INIT_STR(strset)
#define SEARCH_KEY_HIGHLIGHTED "sh"
#define SEARCH_KEY_OFFSET "so"
#define SEARCH_KEY_PAT "sp"
+#define SEARCH_KEY_BACKWARD "sb"
#define REG_KEY_TYPE "rt"
#define REG_KEY_WIDTH "rw"
@@ -201,11 +205,11 @@ enum SRNIFlags {
kSDReadHeader = (1 << kSDItemHeader), ///< Determines whether header should
///< be read (it is usually ignored).
kSDReadUndisableableData = (
- (1 << kSDItemSearchPattern)
- | (1 << kSDItemSubString)
- | (1 << kSDItemJump)), ///< Data reading which cannot be disabled by &shada
- ///< or other options except for disabling reading
- ///< ShaDa as a whole.
+ (1 << kSDItemSearchPattern)
+ | (1 << kSDItemSubString)
+ | (1 << kSDItemJump)), ///< Data reading which cannot be disabled by
+ ///< &shada or other options except for disabling
+ ///< reading ShaDa as a whole.
kSDReadRegisters = (1 << kSDItemRegister), ///< Determines whether registers
///< should be read (may only be
///< disabled when writing, but
@@ -263,6 +267,7 @@ typedef struct {
bool is_last_used;
bool is_substitute_pattern;
bool highlighted;
+ bool search_backward;
char *pat;
dict_T *additional_data;
} search_pattern;
@@ -441,7 +446,7 @@ typedef struct sd_write_def {
.attr = { __VA_ARGS__ } \
} \
}
-#define DEFAULT_POS {1, 0, 0}
+#define DEFAULT_POS { 1, 0, 0 }
static const pos_T default_pos = DEFAULT_POS;
static const ShadaEntry sd_default_values[] = {
[kSDItemMissing] = { .type = kSDItemMissing, .timestamp = 0 },
@@ -455,6 +460,7 @@ static const ShadaEntry sd_default_values[] = {
.is_last_used = true,
.is_substitute_pattern = false,
.highlighted = false,
+ .search_backward = false,
.pat = NULL,
.additional_data = NULL),
DEF_SDE(SubString, sub_string, .sub = NULL, .additional_elements = NULL),
@@ -527,11 +533,14 @@ static inline void hmll_init(HMLList *const hmll, const size_t size)
///
/// @param hmll Pointer to the list.
/// @param cur_entry Name of the variable to iterate over.
+/// @param code Code to execute on each iteration.
///
/// @return `for` cycle header (use `HMLL_FORALL(hmll, cur_entry) {body}`).
-#define HMLL_FORALL(hmll, cur_entry) \
+#define HMLL_FORALL(hmll, cur_entry, code) \
for (HMLListEntry *cur_entry = (hmll)->first; cur_entry != NULL; \
- cur_entry = cur_entry->next)
+ cur_entry = cur_entry->next) { \
+ code \
+ } \
/// Remove entry from the linked list
///
@@ -627,11 +636,14 @@ static inline void hmll_insert(HMLList *const hmll,
/// @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) \
+#define HMLL_ITER_BACK(hmll, cur_entry, code) \
for (cur_entry = (hmll)->last; cur_entry != NULL; \
- cur_entry = cur_entry->prev)
+ cur_entry = cur_entry->prev) { \
+ code \
+ }
/// Free linked list
///
@@ -812,7 +824,7 @@ static ShaDaReadResult sd_reader_skip(ShaDaReadDef *const sd_reader,
///
/// All arguments are passed to os_open().
///
-/// @return file descriptor or -errno on failure.
+/// @return file descriptor or libuv error on failure.
static int open_file(const char *const fname, const int flags, const int mode)
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
{
@@ -822,15 +834,15 @@ open_file_start:
fd = os_open(fname, flags, mode);
if (fd < 0) {
- if (-fd == ENOENT) {
+ if (fd == UV_ENOENT) {
return fd;
}
- if (-fd == ENOMEM && !did_try_to_free) {
+ if (fd == UV_ENOMEM && !did_try_to_free) {
try_to_free_memory();
did_try_to_free = true;
goto open_file_start;
}
- if (-fd != EEXIST) {
+ if (fd != UV_EEXIST) {
emsg3(_(SERR "System error while opening ShaDa file %s: %s"),
fname, os_strerror(fd));
}
@@ -844,7 +856,7 @@ open_file_start:
/// @param[in] fname File name to open.
/// @param[out] sd_reader Location where reader structure will be saved.
///
-/// @return -errno in case of error, 0 otherwise.
+/// @return libuv error in case of error, 0 otherwise.
static int open_shada_file_for_reading(const char *const fname,
ShaDaReadDef *sd_reader)
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
@@ -953,16 +965,16 @@ static int shada_read_file(const char *const file, const int flags)
if (p_verbose > 0) {
verbose_enter();
smsg(_("Reading ShaDa file \"%s\"%s%s%s"),
- fname,
- (flags & kShaDaWantInfo) ? _(" info") : "",
- (flags & kShaDaWantMarks) ? _(" marks") : "",
- (flags & kShaDaGetOldfiles) ? _(" oldfiles") : "",
- of_ret != 0 ? _(" FAILED") : "");
+ fname,
+ (flags & kShaDaWantInfo) ? _(" info") : "",
+ (flags & kShaDaWantMarks) ? _(" marks") : "",
+ (flags & kShaDaGetOldfiles) ? _(" oldfiles") : "",
+ of_ret != 0 ? _(" FAILED") : "");
verbose_leave();
}
if (of_ret != 0) {
- if (-of_ret == ENOENT && (flags & kShaDaMissingError)) {
+ if (of_ret == UV_ENOENT && (flags & kShaDaMissingError)) {
emsg3(_(SERR "System error while opening ShaDa file %s for reading: %s"),
fname, os_strerror(of_ret));
}
@@ -1005,8 +1017,8 @@ static const void *shada_hist_iter(const void *const iter,
.histtype = history_type,
.string = (char *) hist_he.hisstr,
.sep = (char) (history_type == HIST_SEARCH
- ? (char) hist_he.hisstr[STRLEN(hist_he.hisstr) + 1]
- : 0),
+ ? (char) hist_he.hisstr[STRLEN(hist_he.hisstr) + 1]
+ : 0),
.additional_elements = hist_he.additional_elements,
}
}
@@ -1068,11 +1080,11 @@ static void hms_insert(HistoryMergerState *const hms_p, const ShadaEntry entry,
}
}
HMLListEntry *insert_after;
- HMLL_ITER_BACK(hmll, insert_after) {
+ HMLL_ITER_BACK(hmll, insert_after, {
if (insert_after->data.timestamp <= entry.timestamp) {
break;
}
- }
+ })
hmll_insert(hmll, insert_after, entry, can_free_entry);
}
@@ -1130,14 +1142,14 @@ static inline void hms_to_he_array(const HistoryMergerState *const hms_p,
FUNC_ATTR_NONNULL_ALL
{
histentry_T *hist = hist_array;
- HMLL_FORALL(&hms_p->hmll, cur_entry) {
+ HMLL_FORALL(&hms_p->hmll, cur_entry, {
hist->timestamp = cur_entry->data.timestamp;
hist->hisnum = (int) (hist - hist_array) + 1;
hist->hisstr = (char_u *) cur_entry->data.data.history_item.string;
hist->additional_elements =
cur_entry->data.data.history_item.additional_elements;
hist++;
- }
+ })
*new_hisnum = (int) (hist - hist_array);
*new_hisidx = *new_hisnum - 1;
}
@@ -1155,10 +1167,11 @@ static inline void hms_dealloc(HistoryMergerState *const hms_p)
///
/// @param[in] hms_p Merger structure to iterate over.
/// @param[out] cur_entry Name of the iterator variable.
+/// @param code Code to execute on each iteration.
///
/// @return for cycle header. Use `HMS_ITER(hms_p, cur_entry) {body}`.
-#define HMS_ITER(hms_p, cur_entry) \
- HMLL_FORALL(&((hms_p)->hmll), cur_entry)
+#define HMS_ITER(hms_p, cur_entry, code) \
+ HMLL_FORALL(&((hms_p)->hmll), cur_entry, code)
/// Find buffer for given buffer name (cached)
///
@@ -1335,17 +1348,18 @@ static void shada_read(ShaDaReadDef *const sd_reader, const int flags)
(cur_entry.data.search_pattern.is_substitute_pattern
? &set_substitute_pattern
: &set_search_pattern)((SearchPattern) {
- .magic = cur_entry.data.search_pattern.magic,
- .no_scs = !cur_entry.data.search_pattern.smartcase,
- .off = {
- .line = cur_entry.data.search_pattern.has_line_offset,
- .end = cur_entry.data.search_pattern.place_cursor_at_end,
- .off = cur_entry.data.search_pattern.offset,
- },
- .pat = (char_u *) cur_entry.data.search_pattern.pat,
- .additional_data = cur_entry.data.search_pattern.additional_data,
- .timestamp = cur_entry.timestamp,
- });
+ .magic = cur_entry.data.search_pattern.magic,
+ .no_scs = !cur_entry.data.search_pattern.smartcase,
+ .off = {
+ .dir = cur_entry.data.search_pattern.search_backward ? '?' : '/',
+ .line = cur_entry.data.search_pattern.has_line_offset,
+ .end = cur_entry.data.search_pattern.place_cursor_at_end,
+ .off = cur_entry.data.search_pattern.offset,
+ },
+ .pat = (char_u *) cur_entry.data.search_pattern.pat,
+ .additional_data = cur_entry.data.search_pattern.additional_data,
+ .timestamp = cur_entry.timestamp,
+ });
if (cur_entry.data.search_pattern.is_last_used) {
set_last_used_pattern(
cur_entry.data.search_pattern.is_substitute_pattern);
@@ -1583,6 +1597,20 @@ shada_read_main_cycle_end:
kh_dealloc(strset, &oldfiles_set);
}
+/// Default shada file location: cached path
+static char *default_shada_file = NULL;
+
+/// Get the default ShaDa file
+static const char *shada_get_default_file(void)
+ FUNC_ATTR_WARN_UNUSED_RESULT
+{
+ if (default_shada_file == NULL) {
+ char *shada_dir = stdpaths_user_data_subpath("shada", 0);
+ default_shada_file = concat_fnames_realloc(shada_dir, "main.shada", true);
+ }
+ return default_shada_file;
+}
+
/// Get the ShaDa file name to use
///
/// If "file" is given and not empty, use it (has already been expanded by
@@ -1600,22 +1628,7 @@ static char *shada_filename(const char *file)
file = used_shada_file;
} else {
if ((file = find_shada_parameter('n')) == NULL || *file == NUL) {
-#ifdef SHADA_FILE2
- // don't use $HOME when not defined (turned into "c:/"!).
- if (os_getenv((char_u *)"HOME") == NULL) {
- // don't use $VIM when not available.
- expand_env((char_u *)"$VIM", NameBuff, MAXPATHL);
- if (STRCMP("$VIM", NameBuff) != 0) { // $VIM was expanded
- file = SHADA_FILE2;
- } else {
- file = SHADA_FILE;
- }
- } else {
-#endif
- file = SHADA_FILE;
-#ifdef SHADA_FILE2
- }
-#endif
+ file = shada_get_default_file();
}
// XXX It used to be one level lower, so that whatever is in
// `used_shada_file` was expanded. I intentionally moved it here
@@ -1755,6 +1768,7 @@ static bool shada_pack_entry(msgpack_packer *const packer,
+ ONE_IF_NOT_DEFAULT(entry, search_pattern.is_substitute_pattern)
+ ONE_IF_NOT_DEFAULT(entry, search_pattern.highlighted)
+ ONE_IF_NOT_DEFAULT(entry, search_pattern.offset)
+ + ONE_IF_NOT_DEFAULT(entry, search_pattern.search_backward)
// finally, additional data:
+ (size_t) (
entry.data.search_pattern.additional_data
@@ -1781,6 +1795,7 @@ static bool shada_pack_entry(msgpack_packer *const packer,
PACK_BOOL(entry, SEARCH_KEY_PLACE_CURSOR_AT_END, place_cursor_at_end);
PACK_BOOL(entry, SEARCH_KEY_IS_SUBSTITUTE_PATTERN, is_substitute_pattern);
PACK_BOOL(entry, SEARCH_KEY_HIGHLIGHTED, highlighted);
+ PACK_BOOL(entry, SEARCH_KEY_BACKWARD, search_backward);
if (!CHECK_DEFAULT(entry, search_pattern.offset)) {
PACK_STATIC_STR(SEARCH_KEY_OFFSET);
msgpack_pack_int64(spacker, entry.data.search_pattern.offset);
@@ -2422,17 +2437,26 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer,
}
const unsigned srni_flags = (unsigned) (
- kSDReadUndisableableData
- | kSDReadUnknown
- | (dump_history ? kSDReadHistory : 0)
- | (dump_registers ? kSDReadRegisters : 0)
- | (dump_global_vars ? kSDReadVariables : 0)
- | (dump_global_marks ? kSDReadGlobalMarks : 0)
- | (num_marked_files ? kSDReadLocalMarks | kSDReadChanges : 0));
+ kSDReadUndisableableData
+ | kSDReadUnknown
+ | (dump_history ? kSDReadHistory : 0)
+ | (dump_registers ? kSDReadRegisters : 0)
+ | (dump_global_vars ? kSDReadVariables : 0)
+ | (dump_global_marks ? kSDReadGlobalMarks : 0)
+ | (num_marked_files ? kSDReadLocalMarks | kSDReadChanges : 0));
msgpack_packer *const packer = msgpack_packer_new(sd_writer,
&msgpack_sd_writer_write);
+ // Set b_last_cursor for all the buffers that have a window.
+ //
+ // It is needed to correctly save '"' mark on exit. Has a side effect of
+ // setting '"' mark in all windows on :wshada to the current cursor
+ // position (basically what :wviminfo used to do).
+ FOR_ALL_TAB_WINDOWS(tp, wp) {
+ set_last_cursor(wp);
+ }
+
FOR_ALL_BUFFERS(buf) {
if (buf->b_ffname != NULL && shada_removable((char *) buf->b_ffname)) {
int kh_ret;
@@ -2470,8 +2494,11 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer,
// Write buffer list
if (find_shada_parameter('%') != NULL) {
size_t buf_count = 0;
+#define IGNORE_BUF(buf)\
+ (buf->b_ffname == NULL || !buf->b_p_bl || bt_quickfix(buf) \
+ || in_bufset(&removable_bufs, buf))
FOR_ALL_BUFFERS(buf) {
- if (buf->b_ffname != NULL && !in_bufset(&removable_bufs, buf)) {
+ if (!IGNORE_BUF(buf)) {
buf_count++;
}
}
@@ -2489,7 +2516,7 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer,
};
size_t i = 0;
FOR_ALL_BUFFERS(buf) {
- if (buf->b_ffname == NULL || in_bufset(&removable_bufs, buf)) {
+ if (IGNORE_BUF(buf)) {
continue;
}
buflist_entry.data.buffer_list.buffers[i] = (struct buffer_list_buffer) {
@@ -2505,6 +2532,7 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer,
goto shada_write_exit;
}
xfree(buflist_entry.data.buffer_list.buffers);
+#undef IGNORE_BUF
}
// Write some of the variables
@@ -2573,6 +2601,7 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer,
&& search_highlighted), \
.pat = (char *) pat.pat, \
.additional_data = pat.additional_data, \
+ .search_backward = (!is_sub && pat.off.dir == '?'), \
} \
} \
} \
@@ -2873,16 +2902,16 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer,
for (size_t i = 0; i < HIST_COUNT; i++) {
if (dump_one_history[i]) {
hms_insert_whole_neovim_history(&wms->hms[i]);
- HMS_ITER(&wms->hms[i], cur_entry) {
+ HMS_ITER(&wms->hms[i], cur_entry, {
if (!shada_pack_encoded_entry(
- packer, &sd_writer->sd_conv, (PossiblyFreedShadaEntry) {
- .data = cur_entry->data,
- .can_free_entry = cur_entry->can_free_entry,
- }, max_kbyte)) {
+ packer, &sd_writer->sd_conv, (PossiblyFreedShadaEntry) {
+ .data = cur_entry->data,
+ .can_free_entry = cur_entry->can_free_entry,
+ }, max_kbyte)) {
ret = kSDWriteFailed;
break;
}
- }
+ })
hms_dealloc(&wms->hms[i]);
if (ret == kSDWriteFailed) {
goto shada_write_exit;
@@ -2949,9 +2978,9 @@ shada_write_file_open:
fd = (intptr_t) open_file(tempname, O_CREAT|O_WRONLY|O_NOFOLLOW|O_EXCL,
perm);
if (fd < 0) {
- if (-fd == EEXIST
+ if (fd == UV_EEXIST
#ifdef ELOOP
- || -fd == ELOOP
+ || fd == UV_ELOOP
#endif
) {
// File already exists, try another name
@@ -3333,8 +3362,8 @@ static inline char *get_converted_string(const vimconv_T *const sd_conv,
entry_name " entry at position %" PRIu64 " " \
error_desc
#define CHECK_KEY(key, expected) ( \
- key.via.str.size == sizeof(expected) - 1 \
- && STRNCMP(key.via.str.ptr, expected, sizeof(expected) - 1) == 0)
+ key.via.str.size == sizeof(expected) - 1 \
+ && STRNCMP(key.via.str.ptr, expected, sizeof(expected) - 1) == 0)
#define CLEAR_GA_AND_ERROR_OUT(ga) \
do { \
ga_clear(&ga); \
@@ -3357,18 +3386,17 @@ static inline char *get_converted_string(const vimconv_T *const sd_conv,
tgt = proc(obj.via.attr); \
} while (0)
#define CHECK_KEY_IS_STR(entry_name) \
- do { \
- if (unpacked.data.via.map.ptr[i].key.type != MSGPACK_OBJECT_STR) { \
- emsgu(_(READERR(entry_name, "has key which is not a string")), \
- initial_fpos); \
- CLEAR_GA_AND_ERROR_OUT(ad_ga); \
- } else if (unpacked.data.via.map.ptr[i].key.via.str.size == 0) { \
- emsgu(_(READERR(entry_name, "has empty key")), initial_fpos); \
- CLEAR_GA_AND_ERROR_OUT(ad_ga); \
- } \
- } while (0)
+ if (unpacked.data.via.map.ptr[i].key.type != MSGPACK_OBJECT_STR) { \
+ emsgu(_(READERR(entry_name, "has key which is not a string")), \
+ initial_fpos); \
+ CLEAR_GA_AND_ERROR_OUT(ad_ga); \
+ } else if (unpacked.data.via.map.ptr[i].key.via.str.size == 0) { \
+ emsgu(_(READERR(entry_name, "has empty key")), initial_fpos); \
+ CLEAR_GA_AND_ERROR_OUT(ad_ga); \
+ }
#define CHECKED_KEY(entry_name, name, error_desc, tgt, condition, attr, proc) \
- if (CHECK_KEY(unpacked.data.via.map.ptr[i].key, name)) { \
+ else if (CHECK_KEY( /* NOLINT(readability/braces) */ \
+ unpacked.data.via.map.ptr[i].key, name)) { \
CHECKED_ENTRY( \
condition, "has " name " key value " error_desc, \
entry_name, unpacked.data.via.map.ptr[i].val, \
@@ -3388,17 +3416,17 @@ static inline char *get_converted_string(const vimconv_T *const sd_conv,
#define INT_KEY(entry_name, name, tgt, proc) \
CHECKED_KEY( \
entry_name, name, "which is not an integer", tgt, \
- (unpacked.data.via.map.ptr[i].val.type \
- == MSGPACK_OBJECT_POSITIVE_INTEGER \
- || unpacked.data.via.map.ptr[i].val.type \
- == MSGPACK_OBJECT_NEGATIVE_INTEGER), \
+ ((unpacked.data.via.map.ptr[i].val.type \
+ == MSGPACK_OBJECT_POSITIVE_INTEGER) \
+ || (unpacked.data.via.map.ptr[i].val.type \
+ == MSGPACK_OBJECT_NEGATIVE_INTEGER)), \
i64, proc)
#define INTEGER_KEY(entry_name, name, tgt) \
INT_KEY(entry_name, name, tgt, TOINT)
#define LONG_KEY(entry_name, name, tgt) \
INT_KEY(entry_name, name, tgt, TOLONG)
#define ADDITIONAL_KEY \
- { \
+ else { /* NOLINT(readability/braces) */ \
ga_grow(&ad_ga, 1); \
memcpy(((char *)ad_ga.ga_data) + ((size_t) ad_ga.ga_len \
* sizeof(*unpacked.data.via.map.ptr)), \
@@ -3407,9 +3435,9 @@ static inline char *get_converted_string(const vimconv_T *const sd_conv,
ad_ga.ga_len++; \
}
#define CONVERTED(str, len) ( \
- sd_reader->sd_conv.vc_type != CONV_NONE \
- ? get_converted_string(&sd_reader->sd_conv, (str), (len)) \
- : xmemdupz((str), (len)))
+ sd_reader->sd_conv.vc_type != CONV_NONE \
+ ? get_converted_string(&sd_reader->sd_conv, (str), (len)) \
+ : xmemdupz((str), (len)))
#define BIN_CONVERTED(b) CONVERTED(b.ptr, b.size)
#define SET_ADDITIONAL_DATA(tgt, name) \
do { \
@@ -3603,35 +3631,28 @@ shada_read_next_item_start:
garray_T ad_ga;
ga_init(&ad_ga, sizeof(*(unpacked.data.via.map.ptr)), 1);
for (size_t i = 0; i < unpacked.data.via.map.size; i++) {
- CHECK_KEY_IS_STR("search pattern");
+ CHECK_KEY_IS_STR("search pattern")
BOOLEAN_KEY("search pattern", SEARCH_KEY_MAGIC,
entry->data.search_pattern.magic)
- else
- BOOLEAN_KEY("search pattern", SEARCH_KEY_SMARTCASE,
- entry->data.search_pattern.smartcase)
- else
- BOOLEAN_KEY("search pattern", SEARCH_KEY_HAS_LINE_OFFSET,
- entry->data.search_pattern.has_line_offset)
- else
- BOOLEAN_KEY("search pattern", SEARCH_KEY_PLACE_CURSOR_AT_END,
- entry->data.search_pattern.place_cursor_at_end)
- else
- BOOLEAN_KEY("search pattern", SEARCH_KEY_IS_LAST_USED,
- entry->data.search_pattern.is_last_used)
- else
- BOOLEAN_KEY("search pattern", SEARCH_KEY_IS_SUBSTITUTE_PATTERN,
- entry->data.search_pattern.is_substitute_pattern)
- else
- BOOLEAN_KEY("search pattern", SEARCH_KEY_HIGHLIGHTED,
- entry->data.search_pattern.highlighted)
- else
- INTEGER_KEY("search pattern", SEARCH_KEY_OFFSET,
- entry->data.search_pattern.offset)
- else
- CONVERTED_STRING_KEY("search pattern", SEARCH_KEY_PAT,
- entry->data.search_pattern.pat)
- else
- ADDITIONAL_KEY
+ BOOLEAN_KEY("search pattern", SEARCH_KEY_SMARTCASE,
+ entry->data.search_pattern.smartcase)
+ BOOLEAN_KEY("search pattern", SEARCH_KEY_HAS_LINE_OFFSET,
+ entry->data.search_pattern.has_line_offset)
+ BOOLEAN_KEY("search pattern", SEARCH_KEY_PLACE_CURSOR_AT_END,
+ entry->data.search_pattern.place_cursor_at_end)
+ BOOLEAN_KEY("search pattern", SEARCH_KEY_IS_LAST_USED,
+ entry->data.search_pattern.is_last_used)
+ BOOLEAN_KEY("search pattern", SEARCH_KEY_IS_SUBSTITUTE_PATTERN,
+ entry->data.search_pattern.is_substitute_pattern)
+ BOOLEAN_KEY("search pattern", SEARCH_KEY_HIGHLIGHTED,
+ entry->data.search_pattern.highlighted)
+ BOOLEAN_KEY("search pattern", SEARCH_KEY_BACKWARD,
+ entry->data.search_pattern.search_backward)
+ INTEGER_KEY("search pattern", SEARCH_KEY_OFFSET,
+ entry->data.search_pattern.offset)
+ CONVERTED_STRING_KEY("search pattern", SEARCH_KEY_PAT,
+ entry->data.search_pattern.pat)
+ ADDITIONAL_KEY
}
if (entry->data.search_pattern.pat == NULL) {
emsgu(_(READERR("search pattern", "has no pattern")), initial_fpos);
@@ -3652,7 +3673,7 @@ shada_read_next_item_start:
garray_T ad_ga;
ga_init(&ad_ga, sizeof(*(unpacked.data.via.map.ptr)), 1);
for (size_t i = 0; i < unpacked.data.via.map.size; i++) {
- CHECK_KEY_IS_STR("mark");
+ CHECK_KEY_IS_STR("mark")
if (CHECK_KEY(unpacked.data.via.map.ptr[i].key, KEY_NAME_CHAR)) {
if (type_u64 == kSDItemJump || type_u64 == kSDItemChange) {
emsgu(_(READERR("mark", "has n key which is only valid for "
@@ -3665,15 +3686,11 @@ shada_read_next_item_start:
"has n key value which is not an unsigned integer",
"mark", unpacked.data.via.map.ptr[i].val,
entry->data.filemark.name, u64, TOCHAR);
- } else {
- LONG_KEY("mark", KEY_LNUM, entry->data.filemark.mark.lnum)
- else
- INTEGER_KEY("mark", KEY_COL, entry->data.filemark.mark.col)
- else
- STRING_KEY("mark", KEY_FILE, entry->data.filemark.fname)
- else
- ADDITIONAL_KEY
}
+ LONG_KEY("mark", KEY_LNUM, entry->data.filemark.mark.lnum)
+ INTEGER_KEY("mark", KEY_COL, entry->data.filemark.mark.col)
+ STRING_KEY("mark", KEY_FILE, entry->data.filemark.fname)
+ ADDITIONAL_KEY
}
if (entry->data.filemark.fname == NULL) {
emsgu(_(READERR("mark", "is missing file name")), initial_fpos);
@@ -3698,48 +3715,44 @@ shada_read_next_item_start:
garray_T ad_ga;
ga_init(&ad_ga, sizeof(*(unpacked.data.via.map.ptr)), 1);
for (size_t i = 0; i < unpacked.data.via.map.size; i++) {
- CHECK_KEY_IS_STR("register");
- TYPED_KEY("register", REG_KEY_TYPE, "an unsigned integer",
- entry->data.reg.type, POSITIVE_INTEGER, u64, TOU8)
- else
- TYPED_KEY("register", KEY_NAME_CHAR, "an unsigned integer",
- entry->data.reg.name, POSITIVE_INTEGER, u64, TOCHAR)
- else
- TYPED_KEY("register", REG_KEY_WIDTH, "an unsigned integer",
- entry->data.reg.width, POSITIVE_INTEGER, u64, TOSIZE)
- else
- if (CHECK_KEY(unpacked.data.via.map.ptr[i].key,
- REG_KEY_CONTENTS)) {
- if (unpacked.data.via.map.ptr[i].val.type != MSGPACK_OBJECT_ARRAY) {
- emsgu(_(READERR(
- "register",
- "has " REG_KEY_CONTENTS " key with non-array value")),
- initial_fpos);
- CLEAR_GA_AND_ERROR_OUT(ad_ga);
- }
- if (unpacked.data.via.map.ptr[i].val.via.array.size == 0) {
- emsgu(_(READERR("register",
- "has " REG_KEY_CONTENTS " key with empty array")),
- initial_fpos);
+ CHECK_KEY_IS_STR("register")
+ if (CHECK_KEY(unpacked.data.via.map.ptr[i].key,
+ REG_KEY_CONTENTS)) {
+ if (unpacked.data.via.map.ptr[i].val.type != MSGPACK_OBJECT_ARRAY) {
+ emsgu(_(READERR("register",
+ "has " REG_KEY_CONTENTS
+ " key with non-array value")),
+ initial_fpos);
+ CLEAR_GA_AND_ERROR_OUT(ad_ga);
+ }
+ if (unpacked.data.via.map.ptr[i].val.via.array.size == 0) {
+ emsgu(_(READERR("register",
+ "has " REG_KEY_CONTENTS " key with empty array")),
+ initial_fpos);
+ CLEAR_GA_AND_ERROR_OUT(ad_ga);
+ }
+ const msgpack_object_array arr =
+ unpacked.data.via.map.ptr[i].val.via.array;
+ for (size_t i = 0; i < arr.size; i++) {
+ if (arr.ptr[i].type != MSGPACK_OBJECT_BIN) {
+ emsgu(_(READERR("register", "has " REG_KEY_CONTENTS " array "
+ "with non-binary value")), initial_fpos);
CLEAR_GA_AND_ERROR_OUT(ad_ga);
}
- const msgpack_object_array arr =
- unpacked.data.via.map.ptr[i].val.via.array;
- for (size_t i = 0; i < arr.size; i++) {
- if (arr.ptr[i].type != MSGPACK_OBJECT_BIN) {
- emsgu(_(READERR("register", "has " REG_KEY_CONTENTS " array "
- "with non-binary value")), initial_fpos);
- CLEAR_GA_AND_ERROR_OUT(ad_ga);
- }
- }
- entry->data.reg.contents_size = arr.size;
- entry->data.reg.contents = xmalloc(arr.size * sizeof(char *));
- for (size_t i = 0; i < arr.size; i++) {
- entry->data.reg.contents[i] = BIN_CONVERTED(arr.ptr[i].via.bin);
- }
- } else {
- ADDITIONAL_KEY
}
+ entry->data.reg.contents_size = arr.size;
+ entry->data.reg.contents = xmalloc(arr.size * sizeof(char *));
+ for (size_t i = 0; i < arr.size; i++) {
+ entry->data.reg.contents[i] = BIN_CONVERTED(arr.ptr[i].via.bin);
+ }
+ }
+ TYPED_KEY("register", REG_KEY_TYPE, "an unsigned integer",
+ entry->data.reg.type, POSITIVE_INTEGER, u64, TOU8)
+ TYPED_KEY("register", KEY_NAME_CHAR, "an unsigned integer",
+ entry->data.reg.name, POSITIVE_INTEGER, u64, TOCHAR)
+ TYPED_KEY("register", REG_KEY_WIDTH, "an unsigned integer",
+ entry->data.reg.width, POSITIVE_INTEGER, u64, TOSIZE)
+ ADDITIONAL_KEY
}
if (entry->data.reg.contents == NULL) {
emsgu(_(READERR("register", "has missing " REG_KEY_CONTENTS " array")),
@@ -3807,8 +3820,8 @@ shada_read_next_item_hist_no_conv:
+ 1); // Separator character
entry->data.history_item.string = xmalloc(strsize);
memcpy(entry->data.history_item.string,
- unpacked.data.via.array.ptr[1].via.bin.ptr,
- unpacked.data.via.array.ptr[1].via.bin.size);
+ unpacked.data.via.array.ptr[1].via.bin.ptr,
+ unpacked.data.via.array.ptr[1].via.bin.size);
} else {
size_t len = unpacked.data.via.array.ptr[1].via.bin.size;
char *const converted = string_convert(
@@ -3928,17 +3941,14 @@ shada_read_next_item_hist_no_conv:
const size_t j = i;
{
for (size_t i = 0; i < unpacked.data.via.map.size; i++) {
- CHECK_KEY_IS_STR("buffer list entry");
+ CHECK_KEY_IS_STR("buffer list entry")
LONG_KEY("buffer list entry", KEY_LNUM,
- entry->data.buffer_list.buffers[j].pos.lnum)
- else
- INTEGER_KEY("buffer list entry", KEY_COL,
- entry->data.buffer_list.buffers[j].pos.col)
- else
- STRING_KEY("buffer list entry", KEY_FILE,
- entry->data.buffer_list.buffers[j].fname)
- else
- ADDITIONAL_KEY
+ entry->data.buffer_list.buffers[j].pos.lnum)
+ INTEGER_KEY("buffer list entry", KEY_COL,
+ entry->data.buffer_list.buffers[j].pos.col)
+ STRING_KEY("buffer list entry", KEY_FILE,
+ entry->data.buffer_list.buffers[j].fname)
+ ADDITIONAL_KEY
}
}
}
diff --git a/src/nvim/spell.c b/src/nvim/spell.c
index 7d9257141a..420e8e2b70 100644
--- a/src/nvim/spell.c
+++ b/src/nvim/spell.c
@@ -1,9 +1,3 @@
-// VIM - Vi IMproved by Bram Moolenaar
-//
-// Do ":help uganda" in Vim to read copying and usage conditions.
-// Do ":help credits" in Vim to see a list of people who contributed.
-// See README.txt for an overview of the Vim source code.
-
// spell.c: code for spell checking
//
// The spell checking mechanism uses a tree (aka trie). Each node in the tree
@@ -285,7 +279,6 @@
// few bytes as possible, see offset2bytes())
#include <assert.h>
-#include <errno.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
diff --git a/src/nvim/state.c b/src/nvim/state.c
new file mode 100644
index 0000000000..b2f3f0bebe
--- /dev/null
+++ b/src/nvim/state.c
@@ -0,0 +1,62 @@
+#include <assert.h>
+
+#include "nvim/lib/kvec.h"
+
+#include "nvim/state.h"
+#include "nvim/vim.h"
+#include "nvim/getchar.h"
+#include "nvim/ui.h"
+#include "nvim/os/input.h"
+
+#ifdef INCLUDE_GENERATED_DECLARATIONS
+# include "state.c.generated.h"
+#endif
+
+
+void state_enter(VimState *s)
+{
+ for (;;) {
+ int check_result = s->check ? s->check(s) : 1;
+
+ if (!check_result) {
+ break;
+ } else if (check_result == -1) {
+ continue;
+ }
+
+ int key;
+
+getkey:
+ if (char_avail() || using_script() || input_available()) {
+ // Don't block for events if there's a character already available for
+ // processing. Characters can come from mappings, scripts and other
+ // sources, so this scenario is very common.
+ key = safe_vgetc();
+ } else if (!queue_empty(loop.events)) {
+ // Event was made available after the last queue_process_events call
+ key = K_EVENT;
+ } else {
+ input_enable_events();
+ // Flush screen updates before blocking
+ ui_flush();
+ // Call `os_inchar` directly to block for events or user input without
+ // consuming anything from `input_buffer`(os/input.c) or calling the
+ // mapping engine. If an event was put into the queue, we send K_EVENT
+ // directly.
+ (void)os_inchar(NULL, 0, -1, 0);
+ input_disable_events();
+ key = !queue_empty(loop.events) ? K_EVENT : safe_vgetc();
+ }
+
+ if (key == K_EVENT) {
+ may_sync_undo();
+ }
+
+ int execute_result = s->execute(s, key);
+ if (!execute_result) {
+ break;
+ } else if (execute_result == -1) {
+ goto getkey;
+ }
+ }
+}
diff --git a/src/nvim/state.h b/src/nvim/state.h
new file mode 100644
index 0000000000..8027514148
--- /dev/null
+++ b/src/nvim/state.h
@@ -0,0 +1,20 @@
+#ifndef NVIM_STATE_H
+#define NVIM_STATE_H
+
+#include <stddef.h>
+
+typedef struct vim_state VimState;
+
+typedef int(*state_check_callback)(VimState *state);
+typedef int(*state_execute_callback)(VimState *state, int key);
+
+struct vim_state {
+ state_check_callback check;
+ state_execute_callback execute;
+};
+
+#ifdef INCLUDE_GENERATED_DECLARATIONS
+# include "state.h.generated.h"
+#endif
+
+#endif // NVIM_STATE_H
diff --git a/src/nvim/strings.c b/src/nvim/strings.c
index 9ffa5c6a76..00dcf3cf46 100644
--- a/src/nvim/strings.c
+++ b/src/nvim/strings.c
@@ -1,5 +1,3 @@
-
-#include <errno.h>
#include <inttypes.h>
#include <stdbool.h>
#include <string.h>
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index d0491ab42b..24422c71fb 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -1,18 +1,9 @@
/*
- * VIM - Vi IMproved by Bram Moolenaar
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- * See README.txt for an overview of the Vim source code.
- */
-
-/*
* syntax.c: code for syntax highlighting
*/
#include <assert.h>
#include <ctype.h>
-#include <errno.h>
#include <inttypes.h>
#include <stdbool.h>
#include <string.h>
diff --git a/src/nvim/tag.c b/src/nvim/tag.c
index b0d1a17c89..d832924efd 100644
--- a/src/nvim/tag.c
+++ b/src/nvim/tag.c
@@ -1,17 +1,8 @@
/*
- * VIM - Vi IMproved by Bram Moolenaar
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- * See README.txt for an overview of the Vim source code.
- */
-
-/*
* Code to handle tags and the tag stack
*/
#include <assert.h>
-#include <errno.h>
#include <inttypes.h>
#include <stdbool.h>
#include <string.h>
diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c
index 82b9599051..adf3f725a2 100644
--- a/src/nvim/terminal.c
+++ b/src/nvim/terminal.c
@@ -63,6 +63,7 @@
#include "nvim/map.h"
#include "nvim/misc1.h"
#include "nvim/move.h"
+#include "nvim/state.h"
#include "nvim/ex_docmd.h"
#include "nvim/ex_cmds.h"
#include "nvim/window.h"
@@ -73,6 +74,16 @@
#include "nvim/api/private/helpers.h"
#include "nvim/api/private/handle.h"
+typedef struct terminal_state {
+ VimState state;
+ Terminal *term;
+ int save_state; // saved value of State
+ int save_rd; // saved value of RedrawingDisabled
+ bool save_mapped_ctrl_c; // saved value of mapped_ctrl_c;
+ bool close;
+ bool got_bs; // if the last input was <C-\>
+} TerminalState;
+
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "terminal.c.generated.h"
#endif
@@ -341,105 +352,114 @@ void terminal_resize(Terminal *term, uint16_t width, uint16_t height)
void terminal_enter(void)
{
buf_T *buf = curbuf;
- Terminal *term = buf->terminal;
- assert(term && "should only be called when curbuf has a terminal");
+ TerminalState state, *s = &state;
+ memset(s, 0, sizeof(TerminalState));
+ s->term = buf->terminal;
+ assert(s->term && "should only be called when curbuf has a terminal");
// Ensure the terminal is properly sized.
- terminal_resize(term, 0, 0);
+ terminal_resize(s->term, 0, 0);
checkpcmark();
setpcmark();
- int save_state = State;
- int save_rd = RedrawingDisabled;
+ s->save_state = State;
+ s->save_rd = RedrawingDisabled;
State = TERM_FOCUS;
RedrawingDisabled = false;
- bool save_mapped_ctrl_c = mapped_ctrl_c;
+ s->save_mapped_ctrl_c = mapped_ctrl_c;
mapped_ctrl_c = true;
// go to the bottom when the terminal is focused
- adjust_topline(term, buf, false);
+ adjust_topline(s->term, buf, false);
// erase the unfocused cursor
- invalidate_terminal(term, term->cursor.row, term->cursor.row + 1);
+ invalidate_terminal(s->term, s->term->cursor.row, s->term->cursor.row + 1);
showmode();
ui_busy_start();
redraw(false);
- int c;
- bool close = false;
-
- bool got_bs = false; // True if the last input was <C-\>
-
- while (curbuf->handle == term->buf_handle) {
- input_enable_events();
- c = safe_vgetc();
- input_disable_events();
-
- switch (c) {
- case K_LEFTMOUSE:
- case K_LEFTDRAG:
- case K_LEFTRELEASE:
- case K_MIDDLEMOUSE:
- case K_MIDDLEDRAG:
- case K_MIDDLERELEASE:
- case K_RIGHTMOUSE:
- case K_RIGHTDRAG:
- case K_RIGHTRELEASE:
- case K_MOUSEDOWN:
- case K_MOUSEUP:
- if (send_mouse_event(term, c)) {
- goto end;
- }
- break;
-
- case K_EVENT:
- // We cannot let an event free the terminal yet. It is still needed.
- term->refcount++;
- queue_process_events(loop.events);
- term->refcount--;
- if (term->buf_handle == 0) {
- close = true;
- goto end;
- }
- break;
- case Ctrl_N:
- if (got_bs) {
- goto end;
- }
- // FALLTHROUGH
-
- default:
- if (c == Ctrl_BSL && !got_bs) {
- got_bs = true;
- break;
- }
- if (term->closed) {
- close = true;
- goto end;
- }
-
- got_bs = false;
- terminal_send_key(term, c);
- }
- }
+ s->state.execute = terminal_execute;
+ state_enter(&s->state);
-end:
restart_edit = 0;
- State = save_state;
- RedrawingDisabled = save_rd;
+ State = s->save_state;
+ RedrawingDisabled = s->save_rd;
// draw the unfocused cursor
- invalidate_terminal(term, term->cursor.row, term->cursor.row + 1);
- mapped_ctrl_c = save_mapped_ctrl_c;
+ invalidate_terminal(s->term, s->term->cursor.row, s->term->cursor.row + 1);
+ mapped_ctrl_c = s->save_mapped_ctrl_c;
unshowmode(true);
- redraw(buf != curbuf);
+ redraw(curbuf->handle != s->term->buf_handle);
ui_busy_stop();
- if (close) {
- bool wipe = term->buf_handle != 0;
- term->opts.close_cb(term->opts.data);
+ if (s->close) {
+ bool wipe = s->term->buf_handle != 0;
+ s->term->opts.close_cb(s->term->opts.data);
if (wipe) {
do_cmdline_cmd("bwipeout!");
}
}
}
+static int terminal_execute(VimState *state, int key)
+{
+ TerminalState *s = (TerminalState *)state;
+
+ switch (key) {
+ case K_FOCUSGAINED: // Neovim has been given focus
+ apply_autocmds(EVENT_FOCUSGAINED, NULL, NULL, false, curbuf);
+ break;
+
+ case K_FOCUSLOST: // Neovim has lost focus
+ apply_autocmds(EVENT_FOCUSLOST, NULL, NULL, false, curbuf);
+ break;
+
+ case K_LEFTMOUSE:
+ case K_LEFTDRAG:
+ case K_LEFTRELEASE:
+ case K_MIDDLEMOUSE:
+ case K_MIDDLEDRAG:
+ case K_MIDDLERELEASE:
+ case K_RIGHTMOUSE:
+ case K_RIGHTDRAG:
+ case K_RIGHTRELEASE:
+ case K_MOUSEDOWN:
+ case K_MOUSEUP:
+ if (send_mouse_event(s->term, key)) {
+ return 0;
+ }
+ break;
+
+ case K_EVENT:
+ // We cannot let an event free the terminal yet. It is still needed.
+ s->term->refcount++;
+ queue_process_events(loop.events);
+ s->term->refcount--;
+ if (s->term->buf_handle == 0) {
+ s->close = true;
+ return 0;
+ }
+ break;
+
+ case Ctrl_N:
+ if (s->got_bs) {
+ return 0;
+ }
+ // FALLTHROUGH
+
+ default:
+ if (key == Ctrl_BSL && !s->got_bs) {
+ s->got_bs = true;
+ break;
+ }
+ if (s->term->closed) {
+ s->close = true;
+ return 0;
+ }
+
+ s->got_bs = false;
+ terminal_send_key(s->term, key);
+ }
+
+ return curbuf->handle == s->term->buf_handle;
+}
+
void terminal_destroy(Terminal *term)
{
buf_T *buf = handle_get_buffer(term->buf_handle);
diff --git a/src/nvim/terminal.h b/src/nvim/terminal.h
index 6e0b062fbd..25e609fb68 100644
--- a/src/nvim/terminal.h
+++ b/src/nvim/terminal.h
@@ -18,15 +18,6 @@ typedef struct {
terminal_close_cb close_cb;
} TerminalOptions;
-#define TERMINAL_OPTIONS_INIT ((TerminalOptions) { \
- .data = NULL, \
- .width = 80, \
- .height = 24, \
- .write_cb = NULL, \
- .resize_cb = NULL, \
- .close_cb = NULL \
- })
-
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "terminal.h.generated.h"
#endif
diff --git a/src/nvim/testdir/test49.vim b/src/nvim/testdir/test49.vim
index 4cb500292d..afee9d882c 100644
--- a/src/nvim/testdir/test49.vim
+++ b/src/nvim/testdir/test49.vim
@@ -456,7 +456,7 @@ function! ExtraVim(...)
" messing up the user's viminfo file.
let redirect = a:0 ?
\ " -c 'au VimLeave * redir END' -c 'redir\\! >" . a:1 . "'" : ""
- exec "!echo '" . debug_quits . "q' | ../../../build/bin/nvim -u NONE -N -Xes" . redirect .
+ exec "!echo '" . debug_quits . "q' | ../../../build/bin/nvim -u NONE -N -es" . redirect .
\ " -c 'debuggreedy|set viminfo+=nviminfo'" .
\ " -c 'let ExtraVimBegin = " . extra_begin . "'" .
\ " -c 'let ExtraVimResult = \"" . resultfile . "\"'" . breakpoints .
diff --git a/src/nvim/testdir/test53.in b/src/nvim/testdir/test53.in
index 8ca9c9ed29..7c35b2e853 100644
--- a/src/nvim/testdir/test53.in
+++ b/src/nvim/testdir/test53.in
@@ -23,6 +23,7 @@ jfXdit
0fXdit
fXdat
0fXdat
+dit
:"
:put =matchstr(\"abcd\", \".\", 0, 2) " b
:put =matchstr(\"abcd\", \"..\", 0, 2) " bc
@@ -97,6 +98,9 @@ voo "nah" sdf " asdf" sdf " sdf" sd
-<b>asdX<i>a<i />sdf</i>asdf</b>-
-<b>asdf<i>Xasdf</i>asdf</b>-
-<b>asdX<i>as<b />df</i>asdf</b>-
+-<b>
+innertext object
+</b>
</begin>
SEARCH:
foobar
diff --git a/src/nvim/testdir/test53.ok b/src/nvim/testdir/test53.ok
index 0c0b9ded16..05206972a4 100644
--- a/src/nvim/testdir/test53.ok
+++ b/src/nvim/testdir/test53.ok
@@ -11,6 +11,7 @@ voo "zzzzzzzzzzzzzzzzzzzzzzzzzzzzsd
-<b></b>-
-<b>asdfasdf</b>-
--
+-<b></b>
</begin>
b
bc
diff --git a/src/nvim/testdir/unix.vim b/src/nvim/testdir/unix.vim
index aa1f6a92bc..a7daacf8cf 100644
--- a/src/nvim/testdir/unix.vim
+++ b/src/nvim/testdir/unix.vim
@@ -4,3 +4,6 @@ set shell=sh
" Don't depend on system locale, always use utf-8
set encoding=utf-8
+
+" Use safer defaults for various directories
+set backupdir=. directory=. undodir=. viewdir=.
diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c
index 654b857301..b41e4d2fba 100644
--- a/src/nvim/tui/input.c
+++ b/src/nvim/tui/input.c
@@ -10,6 +10,8 @@
#include "nvim/event/rstream.h"
#define PASTETOGGLE_KEY "<Paste>"
+#define FOCUSGAINED_KEY "<FocusGained>"
+#define FOCUSLOST_KEY "<FocusLost>"
#define KEY_BUFFER_SIZE 0xfff
#ifdef INCLUDE_GENERATED_DECLARATIONS
@@ -252,6 +254,32 @@ static void timer_cb(TimeWatcher *watcher, void *data)
flush_input(data, true);
}
+/// Handle focus events.
+///
+/// If the upcoming sequence of bytes in the input stream matches either the
+/// escape code for focus gained `<ESC>[I` or focus lost `<ESC>[O` then consume
+/// that sequence and push the appropriate event into the input queue
+///
+/// @param input the input stream
+/// @return true iff handle_focus_event consumed some input
+static bool handle_focus_event(TermInput *input)
+{
+ if (rbuffer_size(input->read_stream.buffer) > 2
+ && (!rbuffer_cmp(input->read_stream.buffer, "\x1b[I", 3)
+ || !rbuffer_cmp(input->read_stream.buffer, "\x1b[O", 3))) {
+ // Advance past the sequence
+ bool focus_gained = *rbuffer_get(input->read_stream.buffer, 2) == 'I';
+ rbuffer_consumed(input->read_stream.buffer, 3);
+ if (focus_gained) {
+ enqueue_input(input, FOCUSGAINED_KEY, sizeof(FOCUSGAINED_KEY) - 1);
+ } else {
+ enqueue_input(input, FOCUSLOST_KEY, sizeof(FOCUSLOST_KEY) - 1);
+ }
+ return true;
+ }
+ return false;
+}
+
static bool handle_bracketed_paste(TermInput *input)
{
if (rbuffer_size(input->read_stream.buffer) > 5 &&
@@ -314,7 +342,9 @@ static void read_cb(Stream *stream, RBuffer *buf, size_t c, void *data,
}
do {
- if (handle_bracketed_paste(input) || handle_forced_escape(input)) {
+ if (handle_focus_event(input)
+ || handle_bracketed_paste(input)
+ || handle_forced_escape(input)) {
continue;
}
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
index c87f6d331b..7f7d138358 100644
--- a/src/nvim/tui/tui.c
+++ b/src/nvim/tui/tui.c
@@ -43,7 +43,11 @@ typedef struct {
TermInput input;
uv_loop_t write_loop;
unibi_term *ut;
- uv_tty_t output_handle;
+ union {
+ uv_tty_t tty;
+ uv_pipe_t pipe;
+ } output_handle;
+ bool out_isatty;
SignalWatcher winch_handle, cont_handle;
bool cont_received;
// Event scheduled by the ui bridge. Since the main thread suspends until
@@ -62,6 +66,7 @@ typedef struct {
int enable_bracketed_paste, disable_bracketed_paste;
int enter_insert_mode, enter_replace_mode, exit_insert_mode;
int set_rgb_foreground, set_rgb_background;
+ int enable_focus_reporting, disable_focus_reporting;
} unibi_ext;
} TUIData;
@@ -116,8 +121,10 @@ static void terminfo_start(UI *ui)
data->unibi_ext.enter_insert_mode = -1;
data->unibi_ext.enter_replace_mode = -1;
data->unibi_ext.exit_insert_mode = -1;
- // write output to stderr if stdout is not a tty
- data->out_fd = os_isatty(1) ? 1 : (os_isatty(2) ? 2 : 1);
+ data->unibi_ext.enable_focus_reporting = -1;
+ data->unibi_ext.disable_focus_reporting = -1;
+ data->out_fd = 1;
+ data->out_isatty = os_isatty(data->out_fd);
// setup unibilium
data->ut = unibi_from_env();
if (!data->ut) {
@@ -131,9 +138,16 @@ static void terminfo_start(UI *ui)
unibi_out(ui, unibi_clear_screen);
// Enable bracketed paste
unibi_out(ui, data->unibi_ext.enable_bracketed_paste);
+ // Enable focus reporting
+ unibi_out(ui, data->unibi_ext.enable_focus_reporting);
uv_loop_init(&data->write_loop);
- uv_tty_init(&data->write_loop, &data->output_handle, data->out_fd, 0);
- uv_tty_set_mode(&data->output_handle, UV_TTY_MODE_RAW);
+ if (data->out_isatty) {
+ uv_tty_init(&data->write_loop, &data->output_handle.tty, data->out_fd, 0);
+ uv_tty_set_mode(&data->output_handle.tty, UV_TTY_MODE_RAW);
+ } else {
+ uv_pipe_init(&data->write_loop, &data->output_handle.pipe, 0);
+ uv_pipe_open(&data->output_handle.pipe, data->out_fd);
+ }
}
static void terminfo_stop(UI *ui)
@@ -148,6 +162,8 @@ static void terminfo_stop(UI *ui)
unibi_out(ui, unibi_exit_ca_mode);
// Disable bracketed paste
unibi_out(ui, data->unibi_ext.disable_bracketed_paste);
+ // Disable focus reporting
+ unibi_out(ui, data->unibi_ext.disable_focus_reporting);
flush_buf(ui);
uv_tty_reset_mode();
uv_close((uv_handle_t *)&data->output_handle, NULL);
@@ -210,6 +226,7 @@ static void tui_main(UIBridgeData *bridge, UI *ui)
loop_poll_events(&tui_loop, -1);
}
+ ui_bridge_stopped(bridge);
term_input_destroy(&data->input);
signal_watcher_stop(&data->cont_handle);
signal_watcher_close(&data->cont_handle, NULL);
@@ -677,7 +694,8 @@ static void update_size(UI *ui)
}
// 2 - try from a system call(ioctl/TIOCGWINSZ on unix)
- if (!uv_tty_get_winsize(&data->output_handle, &width, &height)) {
+ if (data->out_isatty &&
+ !uv_tty_get_winsize(&data->output_handle.tty, &width, &height)) {
goto end;
}
@@ -796,6 +814,11 @@ static void fix_terminfo(TUIData *data)
data->unibi_ext.disable_bracketed_paste = (int)unibi_add_ext_str(ut, NULL,
"\x1b[?2004l");
+ data->unibi_ext.enable_focus_reporting = (int)unibi_add_ext_str(ut, NULL,
+ "\x1b[?1004h");
+ data->unibi_ext.disable_focus_reporting = (int)unibi_add_ext_str(ut, NULL,
+ "\x1b[?1004l");
+
#define XTERM_SETAF \
"\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m"
#define XTERM_SETAB \
diff --git a/src/nvim/types.h b/src/nvim/types.h
index afd684925a..bfe8be2091 100644
--- a/src/nvim/types.h
+++ b/src/nvim/types.h
@@ -1,10 +1,3 @@
-/*
- * VIM - Vi IMproved by Bram Moolenaar
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- */
-
#ifndef NVIM_TYPES_H
#define NVIM_TYPES_H
diff --git a/src/nvim/ui_bridge.c b/src/nvim/ui_bridge.c
index 836339a887..359fffe3bf 100644
--- a/src/nvim/ui_bridge.c
+++ b/src/nvim/ui_bridge.c
@@ -74,6 +74,13 @@ UI *ui_bridge_attach(UI *ui, ui_main_fn ui_main, event_scheduler scheduler)
return &rv->bridge;
}
+void ui_bridge_stopped(UIBridgeData *bridge)
+{
+ uv_mutex_lock(&bridge->mutex);
+ bridge->stopped = true;
+ uv_mutex_unlock(&bridge->mutex);
+}
+
static void ui_thread_run(void *data)
{
UIBridgeData *bridge = data;
@@ -82,8 +89,18 @@ static void ui_thread_run(void *data)
static void ui_bridge_stop(UI *b)
{
- UI_CALL(b, stop, 1, b);
UIBridgeData *bridge = (UIBridgeData *)b;
+ bool stopped = bridge->stopped = false;
+ UI_CALL(b, stop, 1, b);
+ for (;;) {
+ uv_mutex_lock(&bridge->mutex);
+ stopped = bridge->stopped;
+ uv_mutex_unlock(&bridge->mutex);
+ if (stopped) {
+ break;
+ }
+ loop_poll_events(&loop, 10);
+ }
uv_thread_join(&bridge->ui_thread);
uv_mutex_destroy(&bridge->mutex);
uv_cond_destroy(&bridge->cond);
diff --git a/src/nvim/ui_bridge.h b/src/nvim/ui_bridge.h
index 76e9e27989..31b9a69216 100644
--- a/src/nvim/ui_bridge.h
+++ b/src/nvim/ui_bridge.h
@@ -22,6 +22,10 @@ struct ui_bridge_data {
// the call returns. This flag is used as a condition for the main
// thread to continue.
bool ready;
+ // When a stop request is sent from the main thread, it must wait until the UI
+ // thread finishes handling all events. This flag is set by the UI thread as a
+ // signal that it will no longer send messages to the main thread.
+ bool stopped;
};
#define CONTINUE(b) \
diff --git a/src/nvim/undo.c b/src/nvim/undo.c
index 2b0ffefa7e..69ac18ad54 100644
--- a/src/nvim/undo.c
+++ b/src/nvim/undo.c
@@ -1,12 +1,4 @@
/*
- * VIM - Vi IMproved by Bram Moolenaar
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- * See README.txt for an overview of the Vim source code.
- */
-
-/*
* undo.c: multi level undo facility
*
* The saved lines are stored in a list of lists (one for each buffer):
@@ -83,7 +75,6 @@
#include <assert.h>
#include <inttypes.h>
#include <limits.h>
-#include <errno.h>
#include <stdbool.h>
#include <string.h>
@@ -284,32 +275,32 @@ int u_savedel(linenr_T lnum, long nlines)
nlines == curbuf->b_ml.ml_line_count ? 2 : lnum, FALSE);
}
-/*
- * Return TRUE when undo is allowed. Otherwise give an error message and
- * return FALSE.
- */
-int undo_allowed(void)
+/// Return true when undo is allowed. Otherwise print an error message and
+/// return false.
+///
+/// @return true if undo is allowed.
+bool undo_allowed(void)
{
/* Don't allow changes when 'modifiable' is off. */
if (!MODIFIABLE(curbuf)) {
EMSG(_(e_modifiable));
- return FALSE;
+ return false;
}
// In the sandbox it's not allowed to change the text.
if (sandbox != 0) {
EMSG(_(e_sandbox));
- return FALSE;
+ return false;
}
/* Don't allow changes in the buffer while editing the cmdline. The
* caller of getcmdline() may get confused. */
if (textlock != 0) {
EMSG(_(e_secure));
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
/*
@@ -638,64 +629,89 @@ void u_compute_hash(char_u *hash)
sha256_finish(&ctx, hash);
}
-/*
- * Return an allocated string of the full path of the target undofile.
- * When "reading" is TRUE find the file to read, go over all directories in
- * 'undodir'.
- * When "reading" is FALSE use the first name where the directory exists.
- * Returns NULL when there is no place to write or no file to read.
- */
-char_u *u_get_undo_file_name(char_u *buf_ffname, int reading)
+/// Return an allocated string of the full path of the target undofile.
+///
+/// @param[in] buf_ffname Full file name for which undo file location should
+/// be found.
+/// @param[in] reading If true, find the file to read by traversing all of the
+/// directories in &undodir. If false use the first
+/// existing directory. If none of the directories in
+/// &undodir option exist then last directory in the list
+/// will be automatically created.
+///
+/// @return [allocated] File name to read from/write to or NULL.
+char *u_get_undo_file_name(const char *const buf_ffname, const bool reading)
+ FUNC_ATTR_WARN_UNUSED_RESULT
{
- char_u *dirp;
- char_u dir_name[IOSIZE + 1];
- char_u *munged_name = NULL;
- char_u *undo_file_name = NULL;
- char_u *p;
- char_u *ffname = buf_ffname;
+ char *dirp;
+ char dir_name[MAXPATHL + 1];
+ char *munged_name = NULL;
+ char *undo_file_name = NULL;
+ const char *ffname = buf_ffname;
#ifdef HAVE_READLINK
- char_u fname_buf[MAXPATHL];
+ char fname_buf[MAXPATHL];
#endif
- if (ffname == NULL)
+ if (ffname == NULL) {
return NULL;
+ }
#ifdef HAVE_READLINK
- /* Expand symlink in the file name, so that we put the undo file with the
- * actual file instead of with the symlink. */
- if (resolve_symlink(ffname, fname_buf) == OK)
+ // Expand symlink in the file name, so that we put the undo file with the
+ // actual file instead of with the symlink.
+ if (resolve_symlink((const char_u *)ffname, (char_u *)fname_buf) == OK) {
ffname = fname_buf;
+ }
#endif
- /* Loop over 'undodir'. When reading find the first file that exists.
- * When not reading use the first directory that exists or ".". */
- dirp = p_udir;
+ // Loop over 'undodir'. When reading find the first file that exists.
+ // When not reading use the first directory that exists or ".".
+ dirp = (char *) p_udir;
while (*dirp != NUL) {
- size_t dir_len = copy_option_part(&dirp, dir_name, IOSIZE, ",");
+ size_t dir_len = copy_option_part((char_u **)&dirp, (char_u *)dir_name,
+ MAXPATHL, ",");
if (dir_len == 1 && dir_name[0] == '.') {
- /* Use same directory as the ffname,
- * "dir/name" -> "dir/.name.un~" */
- undo_file_name = vim_strnsave(ffname, STRLEN(ffname) + 5);
- p = path_tail(undo_file_name);
- memmove(p + 1, p, STRLEN(p) + 1);
- *p = '.';
- STRCAT(p, ".un~");
+ // Use same directory as the ffname,
+ // "dir/name" -> "dir/.name.un~"
+ const size_t ffname_len = strlen(ffname);
+ undo_file_name = xmalloc(ffname_len + 6);
+ memmove(undo_file_name, ffname, ffname_len + 1);
+ char *const tail = (char *) path_tail((char_u *) undo_file_name);
+ const size_t tail_len = strlen(tail);
+ memmove(tail + 1, tail, tail_len + 1);
+ *tail = '.';
+ memmove(tail + tail_len + 1, ".un~", sizeof(".un~"));
} else {
dir_name[dir_len] = NUL;
- if (os_isdir(dir_name)) {
+ bool has_directory = os_isdir((char_u *)dir_name);
+ if (!has_directory && *dirp == NUL && !reading) {
+ // Last directory in the list does not exist, create it.
+ int ret;
+ char *failed_dir;
+ if ((ret = os_mkdir_recurse(dir_name, 0755, &failed_dir)) != 0) {
+ EMSG3(_("E926: Unable to create directory \"%s\" for undo file: %s"),
+ failed_dir, os_strerror(ret));
+ xfree(failed_dir);
+ } else {
+ has_directory = true;
+ }
+ }
+ if (has_directory) {
if (munged_name == NULL) {
- munged_name = vim_strsave(ffname);
- for (p = munged_name; *p != NUL; mb_ptr_adv(p))
- if (vim_ispathsep(*p))
+ munged_name = xstrdup(ffname);
+ for (char *p = munged_name; *p != NUL; mb_ptr_adv(p)) {
+ if (vim_ispathsep(*p)) {
*p = '%';
+ }
+ }
}
- undo_file_name = (char_u *)concat_fnames((char *)dir_name, (char *)munged_name, TRUE);
+ undo_file_name = concat_fnames(dir_name, munged_name, true);
}
}
// When reading check if the file exists.
- if (undo_file_name != NULL &&
- (!reading || os_file_exists(undo_file_name))) {
+ if (undo_file_name != NULL
+ && (!reading || os_file_exists((char_u *)undo_file_name))) {
break;
}
xfree(undo_file_name);
@@ -706,7 +722,13 @@ char_u *u_get_undo_file_name(char_u *buf_ffname, int reading)
return undo_file_name;
}
-static void corruption_error(char *mesg, char_u *file_name)
+/// Display an error for corrupted undo file
+///
+/// @param[in] mesg Identifier of the corruption kind.
+/// @param[in] file_name File in which error occurred.
+static void corruption_error(const char *const mesg,
+ const char *const file_name)
+ FUNC_ATTR_NONNULL_ALL
{
EMSG3(_("E825: Corrupted undo file (%s): %s"), mesg, file_name);
}
@@ -725,7 +747,11 @@ static void u_free_uhp(u_header_T *uhp)
xfree(uhp);
}
-/// Writes the header.
+/// Writes the undofile header.
+///
+/// @param bi The buffer information
+/// @param hash The hash of the buffer contents
+//
/// @returns false in case of an error.
static bool serialize_header(bufinfo_T *bi, char_u *hash)
FUNC_ATTR_NONNULL_ALL
@@ -779,6 +805,12 @@ static bool serialize_header(bufinfo_T *bi, char_u *hash)
return true;
}
+/// Writes an undo header.
+///
+/// @param bi The buffer information
+/// @param uhp The undo header to write
+//
+/// @returns false in case of an error.
static bool serialize_uhp(bufinfo_T *bi, u_header_T *uhp)
{
if (!undo_write_bytes(bi, (uintmax_t)UF_HEADER_MAGIC, 2)) {
@@ -821,7 +853,8 @@ static bool serialize_uhp(bufinfo_T *bi, u_header_T *uhp)
return true;
}
-static u_header_T *unserialize_uhp(bufinfo_T *bi, char_u *file_name)
+static u_header_T *unserialize_uhp(bufinfo_T *bi,
+ const char *file_name)
{
u_header_T *uhp = xmalloc(sizeof(u_header_T));
memset(uhp, 0, sizeof(u_header_T));
@@ -898,6 +931,9 @@ static u_header_T *unserialize_uhp(bufinfo_T *bi, char_u *file_name)
/// Serializes "uep".
///
+/// @param bi The buffer information
+/// @param uep The undo entry to write
+//
/// @returns false in case of an error.
static bool serialize_uep(bufinfo_T *bi, u_entry_T *uep)
{
@@ -918,7 +954,8 @@ static bool serialize_uep(bufinfo_T *bi, u_entry_T *uep)
return true;
}
-static u_entry_T *unserialize_uep(bufinfo_T * bi, bool *error, char_u *file_name)
+static u_entry_T *unserialize_uep(bufinfo_T * bi, bool *error,
+ const char *file_name)
{
u_entry_T *uep = xmalloc(sizeof(u_entry_T));
memset(uep, 0, sizeof(u_entry_T));
@@ -1000,19 +1037,20 @@ static void unserialize_visualinfo(bufinfo_T *bi, visualinfo_T *info)
info->vi_curswant = undo_read_4c(bi);
}
-/*
- * Write the undo tree in an undo file.
- * When "name" is not NULL, use it as the name of the undo file.
- * Otherwise use buf->b_ffname to generate the undo file name.
- * "buf" must never be null, buf->b_ffname is used to obtain the original file
- * permissions.
- * "forceit" is TRUE for ":wundo!", FALSE otherwise.
- * "hash[UNDO_HASH_SIZE]" must be the hash value of the buffer text.
- */
-void u_write_undo(char_u *name, int forceit, buf_T *buf, char_u *hash)
+/// Write the undo tree in an undo file.
+///
+/// @param[in] name Name of the undo file or NULL if this function needs to
+/// generate the undo file name based on buf->b_ffname.
+/// @param[in] forceit True for `:wundo!`, false otherwise.
+/// @param[in] buf Buffer for which undo file is written.
+/// @param[in] hash Hash value of the buffer text. Must have #UNDO_HASH_SIZE
+/// size.
+void u_write_undo(const char *const name, const bool forceit, buf_T *const buf,
+ char_u *const hash)
+ FUNC_ATTR_NONNULL_ARG(3, 4)
{
u_header_T *uhp;
- char_u *file_name;
+ char *file_name;
int mark;
#ifdef U_DEBUG
int headers_written = 0;
@@ -1024,7 +1062,7 @@ void u_write_undo(char_u *name, int forceit, buf_T *buf, char_u *hash)
bufinfo_T bi;
if (name == NULL) {
- file_name = u_get_undo_file_name(buf->b_ffname, FALSE);
+ file_name = u_get_undo_file_name((char *) buf->b_ffname, false);
if (file_name == NULL) {
if (p_verbose > 0) {
verbose_enter();
@@ -1033,8 +1071,9 @@ void u_write_undo(char_u *name, int forceit, buf_T *buf, char_u *hash)
}
return;
}
- } else
- file_name = name;
+ } else {
+ file_name = (char *) name;
+ }
/*
* Decide about the permission to use for the undo file. If the buffer
@@ -1054,10 +1093,10 @@ void u_write_undo(char_u *name, int forceit, buf_T *buf, char_u *hash)
/* If the undo file already exists, verify that it actually is an undo
* file, and delete it. */
- if (os_file_exists(file_name)) {
+ if (os_file_exists((char_u *)file_name)) {
if (name == NULL || !forceit) {
/* Check we can read it and it's an undo file. */
- fd = os_open((char *)file_name, O_RDONLY, 0);
+ fd = os_open(file_name, O_RDONLY, 0);
if (fd < 0) {
if (name != NULL || p_verbose > 0) {
if (name == NULL)
@@ -1086,7 +1125,7 @@ void u_write_undo(char_u *name, int forceit, buf_T *buf, char_u *hash)
}
}
}
- os_remove((char *)file_name);
+ os_remove(file_name);
}
/* If there is no undo information at all, quit here after deleting any
@@ -1097,13 +1136,12 @@ void u_write_undo(char_u *name, int forceit, buf_T *buf, char_u *hash)
goto theend;
}
- fd = os_open((char *)file_name,
- O_CREAT|O_WRONLY|O_EXCL|O_NOFOLLOW, perm);
+ fd = os_open(file_name, O_CREAT|O_WRONLY|O_EXCL|O_NOFOLLOW, perm);
if (fd < 0) {
EMSG2(_(e_not_open), file_name);
goto theend;
}
- (void)os_setperm(file_name, perm);
+ (void)os_setperm((char_u *)file_name, perm);
if (p_verbose > 0) {
verbose_enter();
smsg(_("Writing undo file: %s"), file_name);
@@ -1125,10 +1163,10 @@ void u_write_undo(char_u *name, int forceit, buf_T *buf, char_u *hash)
FileInfo file_info_new;
if (buf->b_ffname != NULL
&& os_fileinfo((char *)buf->b_ffname, &file_info_old)
- && os_fileinfo((char *)file_name, &file_info_new)
+ && os_fileinfo(file_name, &file_info_new)
&& file_info_old.stat.st_gid != file_info_new.stat.st_gid
&& os_fchown(fd, (uv_uid_t)-1, (uv_gid_t)file_info_old.stat.st_gid)) {
- os_setperm(file_name, (perm & 0707) | ((perm & 07) << 3));
+ os_setperm((char_u *)file_name, (perm & 0707) | ((perm & 07) << 3));
}
# ifdef HAVE_SELINUX
if (buf->b_ffname != NULL)
@@ -1140,7 +1178,7 @@ void u_write_undo(char_u *name, int forceit, buf_T *buf, char_u *hash)
if (fp == NULL) {
EMSG2(_(e_not_open), file_name);
close(fd);
- os_remove((char *)file_name);
+ os_remove(file_name);
goto theend;
}
@@ -1209,7 +1247,7 @@ write_error:
/* For systems that support ACL: get the ACL from the original file. */
acl = mch_get_acl(buf->b_ffname);
- mch_set_acl(file_name, acl);
+ mch_set_acl((char_u *)file_name, acl);
mch_free_acl(acl);
}
#endif
@@ -1224,15 +1262,15 @@ theend:
/// a bit more verbose.
/// Otherwise use curbuf->b_ffname to generate the undo file name.
/// "hash[UNDO_HASH_SIZE]" must be the hash value of the buffer text.
-void u_read_undo(char_u *name, char_u *hash, char_u *orig_name)
+void u_read_undo(char *name, char_u *hash, char_u *orig_name)
FUNC_ATTR_NONNULL_ARG(2)
{
u_header_T **uhp_table = NULL;
char_u *line_ptr = NULL;
- char_u *file_name;
+ char *file_name;
if (name == NULL) {
- file_name = u_get_undo_file_name(curbuf->b_ffname, TRUE);
+ file_name = u_get_undo_file_name((char *) curbuf->b_ffname, true);
if (file_name == NULL) {
return;
}
@@ -1256,7 +1294,7 @@ void u_read_undo(char_u *name, char_u *hash, char_u *orig_name)
}
#endif
} else {
- file_name = name;
+ file_name = (char *) name;
}
if (p_verbose > 0) {
@@ -1265,7 +1303,7 @@ void u_read_undo(char_u *name, char_u *hash, char_u *orig_name)
verbose_leave();
}
- FILE *fp = mch_fopen((char *)file_name, "r");
+ FILE *fp = mch_fopen(file_name, "r");
if (fp == NULL) {
if (name != NULL || p_verbose > 0) {
EMSG2(_("E822: Cannot open undo file for reading: %s"), file_name);
@@ -1520,6 +1558,10 @@ theend:
/// Writes a sequence of bytes to the undo file.
///
+/// @param bi The buffer info
+/// @param ptr The byte buffer to write
+/// @param len The number of bytes to write
+///
/// @returns false in case of an error.
static bool undo_write(bufinfo_T *bi, uint8_t *ptr, size_t len)
FUNC_ATTR_NONNULL_ARG(1)
@@ -1531,6 +1573,10 @@ static bool undo_write(bufinfo_T *bi, uint8_t *ptr, size_t len)
///
/// Must match with undo_read_?c() functions.
///
+/// @param bi The buffer info
+/// @param nr The number to write
+/// @param len The number of bytes to use when writing the number.
+///
/// @returns false in case of an error.
static bool undo_write_bytes(bufinfo_T *bi, uintmax_t nr, size_t len)
{
@@ -1575,6 +1621,10 @@ static time_t undo_read_time(bufinfo_T *bi)
/// Reads "buffer[size]" from the undo file.
///
+/// @param bi The buffer info
+/// @param buffer Character buffer to read data into
+/// @param size The size of the character buffer
+///
/// @returns false in case of an error.
static bool undo_read(bufinfo_T *bi, uint8_t *buffer, size_t size)
FUNC_ATTR_NONNULL_ARG(1)
@@ -2805,19 +2855,26 @@ static char_u *u_save_line(linenr_T lnum)
return vim_strsave(ml_get(lnum));
}
-/*
- * Check if the 'modified' flag is set, or 'ff' has changed (only need to
- * check the first character, because it can only be "dos", "unix" or "mac").
- * "nofile" and "scratch" type buffers are considered to always be unchanged.
- */
-int bufIsChanged(buf_T *buf)
+/// Check if the 'modified' flag is set, or 'ff' has changed (only need to
+/// check the first character, because it can only be "dos", "unix" or "mac").
+/// "nofile" and "scratch" type buffers are considered to always be unchanged.
+///
+/// @param buf The buffer to check
+///
+/// @return true if the buffer has changed
+bool bufIsChanged(buf_T *buf)
{
return
!bt_dontwrite(buf) &&
(buf->b_changed || file_ff_differs(buf, true));
}
-int curbufIsChanged(void)
+/// Check if the 'modified' flag is set, or 'ff' has changed (only need to
+/// check the first character, because it can only be "dos", "unix" or "mac").
+/// "nofile" and "scratch" type buffers are considered to always be unchanged.
+///
+/// @return true if the current buffer has changed
+bool curbufIsChanged(void)
{
return
!bt_dontwrite(curbuf) &&
diff --git a/src/nvim/version.c b/src/nvim/version.c
index 961c017bd5..e0f378b156 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -25,18 +25,21 @@
#define STR_(x) #x
#define STR(x) STR_(x)
-// for the startup-screen ( ":intro" command )
-#define NVIM_VERSION_MEDIUM STR(NVIM_VERSION_MAJOR) "." STR(NVIM_VERSION_MINOR)
-
-// for the ":version" command and "nvim --version"
-#define NVIM_VERSION_LONG "NVIM " NVIM_VERSION_MEDIUM "." STR(NVIM_VERSION_PATCH) NVIM_VERSION_PRERELEASE NVIM_VERSION_BUILD
+// for ":version", ":intro", and "nvim --version"
+#ifndef NVIM_VERSION_MEDIUM
+#define NVIM_VERSION_MEDIUM STR(NVIM_VERSION_MAJOR) "." STR(NVIM_VERSION_MINOR)\
+ "." STR(NVIM_VERSION_PATCH) NVIM_VERSION_PRERELEASE
+#endif
+#define NVIM_VERSION_LONG "NVIM " NVIM_VERSION_MEDIUM
char *Version = VIM_VERSION_SHORT;
char *longVersion = NVIM_VERSION_LONG;
-char *longVersionWithDate = NVIM_VERSION_LONG " (compiled " __DATE__ " " __TIME__ ")";
-char *mediumVersion = NVIM_VERSION_MEDIUM;
+char *longVersionWithDate = NVIM_VERSION_LONG \
+ " (compiled " __DATE__ " " __TIME__ ")";
+#ifdef NVIM_VERSION_COMMIT
char *version_commit = "Commit: " NVIM_VERSION_COMMIT;
+#endif
char *version_buildtype = "Build type: " NVIM_VERSION_BUILD_TYPE;
char *version_cflags = "Compilation: " NVIM_VERSION_CFLAGS;
@@ -71,20 +74,92 @@ static char *features[] = {
// clang-format off
static int included_patches[] = {
- // 850,
- // 849,
+ // 922,
+ // 921 NA
+ // 920 NA
+ // 919 NA
+ // 918 NA
+ // 917 NA
+ 916,
+ // 915,
+ // 914,
+ // 913 NA
+ // 912,
+ // 911 NA
+ // 910 NA
+ // 909,
+ // 908 NA
+ // 907 NA
+ // 906 NA
+ // 905,
+ // 904,
+ // 903,
+ // 902 NA
+ // 901,
+ // 900 NA
+ // 899 NA
+ 898,
+ // 897,
+ // 896,
+ // 895,
+ // 894 NA
+ // 893,
+ // 892,
+ // 891,
+ // 890 NA
+ // 889,
+ // 888,
+ // 887,
+ // 886 NA
+ // 885,
+ // 884 NA
+ // 883,
+ // 882,
+ // 881,
+ // 880 NA
+ // 879,
+ // 878,
+ // 877,
+ // 876 NA
+ // 875 NA
+ // 874 NA
+ // 873,
+ // 872 NA
+ // 871,
+ // 870,
+ // 869 NA
+ // 868,
+ // 867 NA
+ // 866,
+ // 865,
+ // 864,
+ // 863,
+ // 862 NA
+ // 861 NA
+ // 860,
+ // 859,
+ // 858,
+ // 857,
+ // 856,
+ // 855 NA
+ // 854,
+ // 853,
+ // 852 NA
+ // 851 NA
+ // 850 NA
+ 849,
// 848,
// 847,
- // 846,
+ // 846 NA
// 845,
// 844,
// 843,
// 842,
// 841,
- // 840,
+ // 840 NA
// 839,
// 838,
- // 837,
+ // 837 NA
836,
// 835,
// 834,
@@ -92,7 +167,7 @@ static int included_patches[] = {
// 832,
// 831,
// 830,
- // 829,
+ // 829 NA
// 828,
// 827,
826,
@@ -112,31 +187,31 @@ static int included_patches[] = {
// 812,
// 811,
// 810,
- // 809,
+ 809,
// 808,
// 807,
// 806,
// 805,
// 804,
// 803,
- // 802,
+ 802,
// 801,
// 800,
799,
// 798,
// 797,
// 796 NA
- // 795,
+ 795,
// 794 NA
793,
// 792,
- // 791,
- // 790,
- // 789,
+ 791,
+ 790,
+ 789,
// 788 NA
- // 787,
- // 786,
- // 785,
+ 787,
+ 786,
+ 785,
784,
// 783 NA
// 782,
@@ -149,35 +224,35 @@ static int included_patches[] = {
775,
774,
773,
- // 772,
+ // 772 NA
// 771,
- // 770,
+ // 770 NA
// 769,
// 768,
// 767,
- // 766,
+ // 766 NA
// 765,
// 764,
- // 763,
- // 762,
- // 761,
+ // 763 NA
+ // 762 NA
+ // 761 NA
// 760,
- // 759,
+ // 759 NA
// 758,
- // 757,
- // 756,
+ // 757 NA
+ // 756 NA
// 755,
// 754,
// 753,
// 752,
- // 751,
- // 750,
+ // 751 NA
+ // 750 NA
// 749,
// 748,
// 747,
// 746,
// 745,
- // 744,
+ // 744 NA
// 743,
// 742,
// 741,
@@ -235,7 +310,7 @@ static int included_patches[] = {
// 689,
// 688,
// 687 NA
- // 686,
+ 686,
// 685,
// 684,
// 683 NA
@@ -263,34 +338,34 @@ static int included_patches[] = {
// 661,
660,
659,
- // 658,
+ 658,
// 657 NA
// 656,
- // 655,
+ 655,
// 654,
653,
- // 652,
- // 651,
+ // 652 NA
+ 651,
// 650 NA
- // 649,
+ 649,
// 648 NA
// 647 NA
646,
- // 645,
+ 645,
// 644 NA
// 643,
// 642,
// 641,
- // 640,
+ 640,
// 639,
// 638 NA
637,
636,
- // 635,
+ 635,
// 634,
633,
// 632 NA
- // 631,
+ 631,
630,
629,
// 628,
@@ -298,13 +373,13 @@ static int included_patches[] = {
// 626 NA
// 625 NA
// 624,
- // 623,
+ 623,
// 622 NA
// 621 NA
// 620,
// 619 NA
// 618 NA
- // 617,
+ 617,
// 616,
615,
// 614,
@@ -1024,7 +1099,9 @@ void list_version(void)
// When adding features here, don't forget to update the list of
// internal variables in eval.c!
MSG(longVersionWithDate);
+#ifdef NVIM_VERSION_COMMIT
MSG(version_commit);
+#endif
MSG(version_buildtype);
MSG(version_cflags);
@@ -1067,31 +1144,6 @@ void list_version(void)
version_msg(SYS_VIMRC_FILE);
version_msg("\"\n");
#endif // ifdef SYS_VIMRC_FILE
-#ifdef USR_VIMRC_FILE
- version_msg(_(" user vimrc file: \""));
- version_msg(USR_VIMRC_FILE);
- version_msg("\"\n");
-#endif // ifdef USR_VIMRC_FILE
-#ifdef USR_VIMRC_FILE2
- version_msg(_(" 2nd user vimrc file: \""));
- version_msg(USR_VIMRC_FILE2);
- version_msg("\"\n");
-#endif // ifdef USR_VIMRC_FILE2
-#ifdef USR_VIMRC_FILE3
- version_msg(_(" 3rd user vimrc file: \""));
- version_msg(USR_VIMRC_FILE3);
- version_msg("\"\n");
-#endif // ifdef USR_VIMRC_FILE3
-#ifdef USR_EXRC_FILE
- version_msg(_(" user exrc file: \""));
- version_msg(USR_EXRC_FILE);
- version_msg("\"\n");
-#endif // ifdef USR_EXRC_FILE
-#ifdef USR_EXRC_FILE2
- version_msg(_(" 2nd user exrc file: \""));
- version_msg(USR_EXRC_FILE2);
- version_msg("\"\n");
-#endif // ifdef USR_EXRC_FILE2
#ifdef HAVE_PATHDEF
if (*default_vim_dir != NUL) {
diff --git a/src/nvim/version.h b/src/nvim/version.h
index c1881250f1..1de809e539 100644
--- a/src/nvim/version.h
+++ b/src/nvim/version.h
@@ -3,7 +3,6 @@
// defined in version.c
extern char* Version;
-extern char* mediumVersion;
extern char* longVersion;
//
diff --git a/src/nvim/vim.h b/src/nvim/vim.h
index 48d53369de..fa00d9efcf 100644
--- a/src/nvim/vim.h
+++ b/src/nvim/vim.h
@@ -1,10 +1,3 @@
-/*
- * VIM - Vi IMproved by Bram Moolenaar
- *
- * Do ":help uganda" in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- */
-
#ifndef NVIM_VIM_H
#define NVIM_VIM_H
diff --git a/src/nvim/window.c b/src/nvim/window.c
index b71b2cb603..16ff7dfb14 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -1,12 +1,3 @@
-/*
- * VIM - Vi IMproved by Bram Moolenaar
- *
- * Do ":help uganda" in Vim to read a list of people who contributed.
- * Do ":help credits" in Vim to see a list of people who contributed.
- * See README.txt for an overview of the Vim source code.
- */
-
-#include <errno.h>
#include <assert.h>
#include <inttypes.h>
#include <stdbool.h>
diff --git a/test/.luacheckrc b/test/.luacheckrc
new file mode 100644
index 0000000000..92e19d40e8
--- /dev/null
+++ b/test/.luacheckrc
@@ -0,0 +1,13 @@
+-- vim: ft=lua tw=80
+
+-- Don't report globals from luajit or busted (e.g. jit.os or describe).
+std = '+luajit +busted'
+
+-- One can't test these files properly; assume correctness.
+exclude_files = { '*/preload.lua' }
+
+-- Don't report unused self arguments of methods.
+self = false
+
+-- Rerun tests only if their modification time changed.
+cache = true
diff --git a/test/benchmark/bench_re_freeze_spec.lua b/test/benchmark/bench_re_freeze_spec.lua
index 7242f43c8e..d40d9f9ece 100644
--- a/test/benchmark/bench_re_freeze_spec.lua
+++ b/test/benchmark/bench_re_freeze_spec.lua
@@ -1,7 +1,7 @@
-- Test for benchmarking RE engine.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local insert, source = helpers.insert, helpers.source
local clear, execute, wait = helpers.clear, helpers.execute, helpers.wait
-- Temporary file for gathering benchmarking results for each regexp engine.
diff --git a/test/functional/api/menu_spec.lua b/test/functional/api/menu_spec.lua
index 34d23ca098..5b414fb559 100644
--- a/test/functional/api/menu_spec.lua
+++ b/test/functional/api/menu_spec.lua
@@ -19,7 +19,7 @@ describe("update_menu notification", function()
screen:detach()
end)
- function expect_sent(expected)
+ local function expect_sent(expected)
screen:wait(function()
if screen.update_menu ~= expected then
if expected then
diff --git a/test/functional/api/server_requests_spec.lua b/test/functional/api/server_requests_spec.lua
index 34bf4b5ace..a3ac864f79 100644
--- a/test/functional/api/server_requests_spec.lua
+++ b/test/functional/api/server_requests_spec.lua
@@ -95,13 +95,13 @@ describe('server -> client', function()
eq('notified!', eval('rpcrequest('..cid..', "notify")'))
end
- local function on_request(method, args)
+ local function on_request(method)
eq('notify', method)
eq(1, eval('rpcnotify('..cid..', "notification")'))
return 'notified!'
end
- local function on_notification(method, args)
+ local function on_notification(method)
eq('notification', method)
if notified == expected then
stop()
@@ -118,7 +118,7 @@ describe('server -> client', function()
describe('when the client is a recursive vim instance', function()
before_each(function()
- nvim('command', "let vim = rpcstart('"..nvim_prog.."', ['-u', 'NONE', '--embed'])")
+ nvim('command', "let vim = rpcstart('"..nvim_prog.."', ['-u', 'NONE', '-i', 'NONE', '--cmd', 'set noswapfile', '--embed'])")
neq(0, eval('vim'))
end)
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index 8d4e183653..cba0b7533b 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -180,6 +180,8 @@ describe('vim_* functions', function()
end)
describe('err_write', function()
+ local screen
+
before_each(function()
clear()
screen = Screen.new(40, 8)
@@ -247,33 +249,21 @@ describe('vim_* functions', function()
~ |
{1:very fail} |
]])
+ helpers.wait()
-- shows up to &cmdheight lines
- nvim_async('err_write', 'more fail\n')
- nvim_async('err_write', 'too fail\n')
+ nvim_async('err_write', 'more fail\ntoo fail\n')
screen:expect([[
~ |
~ |
~ |
~ |
~ |
- {1:very fail} |
- {1:more fail} |
- {2:Press ENTER or type command to continue}^ |
- ]])
-
- -- shows the rest after return
- feed('<cr>')
- screen:expect([[
- ~ |
- ~ |
- ~ |
- {1:very fail} |
{1:more fail} |
- {2:Press ENTER or type command to continue} |
{1:too fail} |
{2:Press ENTER or type command to continue}^ |
]])
+ feed('<cr>') -- exit the press ENTER screen
end)
end)
diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua
index 456252522d..17aacafe9b 100644
--- a/test/functional/api/window_spec.lua
+++ b/test/functional/api/window_spec.lua
@@ -1,9 +1,9 @@
-- Sanity checks for window_* API calls via msgpack-rpc
local helpers = require('test.functional.helpers')
-local clear, nvim, buffer, curbuf, curbuf_contents, window, curwin, eq, neq,
- ok, feed, rawfeed, insert, eval = helpers.clear, helpers.nvim, helpers.buffer, helpers.curbuf,
+local clear, nvim, curbuf, curbuf_contents, window, curwin, eq, neq,
+ ok, feed, insert, eval = helpers.clear, helpers.nvim, helpers.curbuf,
helpers.curbuf_contents, helpers.window, helpers.curwin, helpers.eq,
- helpers.neq, helpers.ok, helpers.feed, helpers.rawfeed, helpers.insert, helpers.eval
+ helpers.neq, helpers.ok, helpers.feed, helpers.insert, helpers.eval
local wait = helpers.wait
-- check if str is visible at the beginning of some line
@@ -54,7 +54,7 @@ describe('window_* functions', function()
insert("prologue")
feed('100o<esc>')
insert("epilogue")
- win = curwin()
+ local win = curwin()
feed('gg')
wait() -- let nvim process the 'gg' command
diff --git a/test/functional/autocmd/tabclose_spec.lua b/test/functional/autocmd/tabclose_spec.lua
index 847362e3de..bf609d1846 100644
--- a/test/functional/autocmd/tabclose_spec.lua
+++ b/test/functional/autocmd/tabclose_spec.lua
@@ -1,7 +1,5 @@
local helpers = require('test.functional.helpers')
-local clear, nvim, buffer, curbuf, curwin, eq, neq, ok =
- helpers.clear, helpers.nvim, helpers.buffer, helpers.curbuf, helpers.curwin,
- helpers.eq, helpers.neq, helpers.ok
+local clear, nvim, eq = helpers.clear, helpers.nvim, helpers.eq
describe('TabClosed', function()
describe('au TabClosed', function()
@@ -20,7 +18,6 @@ describe('TabClosed', function()
end)
describe('with NR as <afile>', function()
it('matches when closing a tab whose index is NR', function()
- tmp_path = nvim('eval', 'tempname()')
nvim('command', 'au! TabClosed 2 echom "tabclosed:match"')
repeat
nvim('command', 'tabnew')
diff --git a/test/functional/autocmd/tabnew_spec.lua b/test/functional/autocmd/tabnew_spec.lua
index d80644cd92..5ab504889b 100644
--- a/test/functional/autocmd/tabnew_spec.lua
+++ b/test/functional/autocmd/tabnew_spec.lua
@@ -1,7 +1,5 @@
local helpers = require('test.functional.helpers')
-local clear, nvim, buffer, curbuf, curwin, eq, neq, ok =
- helpers.clear, helpers.nvim, helpers.buffer, helpers.curbuf, helpers.curwin,
- helpers.eq, helpers.neq, helpers.ok
+local clear, nvim, eq = helpers.clear, helpers.nvim, helpers.eq
describe('TabNew', function()
setup(clear)
@@ -15,7 +13,7 @@ describe('TabNew', function()
end)
describe('with FILE as <afile>', function()
it('matches when opening a new tab for FILE', function()
- tmp_path = nvim('eval', 'tempname()')
+ local tmp_path = nvim('eval', 'tempname()')
nvim('command', 'au! TabNew '..tmp_path..' echom "tabnew:match"')
eq("\ntabnew:4:3\ntabnew:match\n\""..tmp_path.."\" [New File]", nvim('command_output', 'tabnew '..tmp_path))
end)
diff --git a/test/functional/autocmd/tabnewentered_spec.lua b/test/functional/autocmd/tabnewentered_spec.lua
index f220c15ef7..64b9a22f41 100644
--- a/test/functional/autocmd/tabnewentered_spec.lua
+++ b/test/functional/autocmd/tabnewentered_spec.lua
@@ -1,7 +1,5 @@
local helpers = require('test.functional.helpers')
-local clear, nvim, buffer, curbuf, curwin, eq, neq, ok =
- helpers.clear, helpers.nvim, helpers.buffer, helpers.curbuf, helpers.curwin,
- helpers.eq, helpers.neq, helpers.ok
+local clear, nvim, eq = helpers.clear, helpers.nvim, helpers.eq
describe('TabNewEntered', function()
describe('au TabNewEntered', function()
@@ -15,7 +13,7 @@ describe('TabNewEntered', function()
end)
describe('with FILE as <afile>', function()
it('matches when opening a new tab for FILE', function()
- tmp_path = nvim('eval', 'tempname()')
+ local tmp_path = nvim('eval', 'tempname()')
nvim('command', 'au! TabNewEntered '..tmp_path..' echom "tabnewentered:match"')
eq("\n\""..tmp_path.."\" [New File]\ntabnewentered:4:4\ntabnewentered:match", nvim('command_output', 'tabnew '..tmp_path))
end)
diff --git a/test/functional/autocmd/termclose_spec.lua b/test/functional/autocmd/termclose_spec.lua
new file mode 100644
index 0000000000..0961340e61
--- /dev/null
+++ b/test/functional/autocmd/termclose_spec.lua
@@ -0,0 +1,28 @@
+local helpers = require('test.functional.helpers')
+local Screen = require('test.functional.ui.screen')
+
+local clear, execute, feed, nvim, nvim_dir = helpers.clear,
+helpers.execute, helpers.feed, helpers.nvim, helpers.nvim_dir
+
+describe('TermClose event', function()
+ local screen
+ before_each(function()
+ clear()
+ nvim('set_option', 'shell', nvim_dir .. '/shell-test')
+ nvim('set_option', 'shellcmdflag', 'EXE')
+ screen = Screen.new(20, 4)
+ screen:attach(false)
+ end)
+
+ it('works as expected', function()
+ execute('autocmd TermClose * echomsg "TermClose works!"')
+ execute('terminal')
+ feed('<c-\\><c-n>')
+ screen:expect([[
+ ready $ |
+ [Process exited 0] |
+ ^ |
+ TermClose works! |
+ ]])
+ end)
+end)
diff --git a/test/functional/clipboard/clipboard_provider_spec.lua b/test/functional/clipboard/clipboard_provider_spec.lua
index 98b8d2dd45..898ec556a2 100644
--- a/test/functional/clipboard/clipboard_provider_spec.lua
+++ b/test/functional/clipboard/clipboard_provider_spec.lua
@@ -4,7 +4,6 @@ local helpers = require('test.functional.helpers')
local Screen = require('test.functional.ui.screen')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect, eq, eval = helpers.execute, helpers.expect, helpers.eq, helpers.eval
-local nvim, run, stop, restart = helpers.nvim, helpers.run, helpers.stop, helpers.restart
local function basic_register_test(noblock)
insert("some words")
diff --git a/test/functional/dict_notifications_spec.lua b/test/functional/dict_notifications_spec.lua
new file mode 100644
index 0000000000..2540929126
--- /dev/null
+++ b/test/functional/dict_notifications_spec.lua
@@ -0,0 +1,257 @@
+local helpers = require('test.functional.helpers')
+local clear, nvim, source = helpers.clear, helpers.nvim, helpers.source
+local eq, next_msg = helpers.eq, helpers.next_message
+local exc_exec = helpers.exc_exec
+
+
+describe('dictionary change notifications', function()
+ local channel
+
+ setup(function()
+ clear()
+ channel = nvim('get_api_info')[1]
+ nvim('set_var', 'channel', channel)
+ end)
+
+ -- the same set of tests are applied to top-level dictionaries(g:, b:, w: and
+ -- t:) and a dictionary variable, so we generate them in the following
+ -- function.
+ local function gentests(dict_expr, dict_expr_suffix, dict_init)
+ if not dict_expr_suffix then
+ dict_expr_suffix = ''
+ end
+
+ local function update(opval, key)
+ if not key then
+ key = 'watched'
+ end
+ if opval == '' then
+ nvim('command', "unlet "..dict_expr..dict_expr_suffix..key)
+ else
+ nvim('command', "let "..dict_expr..dict_expr_suffix..key.." "..opval)
+ end
+ end
+
+ local function verify_echo()
+ -- helper to verify that no notifications are sent after certain change
+ -- to a dict
+ nvim('command', "call rpcnotify(g:channel, 'echo')")
+ eq({'notification', 'echo', {}}, next_msg())
+ end
+
+ local function verify_value(vals, key)
+ if not key then
+ key = 'watched'
+ end
+ eq({'notification', 'values', {key, vals}}, next_msg())
+ end
+
+ describe('watcher', function()
+ if dict_init then
+ setup(function()
+ source(dict_init)
+ end)
+ end
+
+ before_each(function()
+ source([[
+ function! g:Changed(dict, key, value)
+ if a:dict != ]]..dict_expr..[[ |
+ throw 'invalid dict'
+ endif
+ call rpcnotify(g:channel, 'values', a:key, a:value)
+ endfunction
+ call dictwatcheradd(]]..dict_expr..[[, "watched", "g:Changed")
+ call dictwatcheradd(]]..dict_expr..[[, "watched2", "g:Changed")
+ ]])
+ end)
+
+ after_each(function()
+ source([[
+ call dictwatcherdel(]]..dict_expr..[[, "watched", "g:Changed")
+ call dictwatcherdel(]]..dict_expr..[[, "watched2", "g:Changed")
+ ]])
+ update('= "test"')
+ update('= "test2"', 'watched2')
+ update('', 'watched2')
+ update('')
+ verify_echo()
+ end)
+
+ it('is not triggered when unwatched keys are updated', function()
+ update('= "noop"', 'unwatched')
+ update('.= "noop2"', 'unwatched')
+ update('', 'unwatched')
+ verify_echo()
+ end)
+
+ it('is triggered by remove()', function()
+ update('= "test"')
+ verify_value({new = 'test'})
+ nvim('command', 'call remove('..dict_expr..', "watched")')
+ verify_value({old = 'test'})
+ end)
+
+ it('is triggered by extend()', function()
+ update('= "xtend"')
+ verify_value({new = 'xtend'})
+ nvim('command', [[
+ call extend(]]..dict_expr..[[, {'watched': 'xtend2', 'watched2': 5, 'watched3': 'a'})
+ ]])
+ verify_value({old = 'xtend', new = 'xtend2'})
+ verify_value({new = 5}, 'watched2')
+ update('')
+ verify_value({old = 'xtend2'})
+ update('', 'watched2')
+ verify_value({old = 5}, 'watched2')
+ update('', 'watched3')
+ verify_echo()
+ end)
+
+ it('is triggered with key patterns', function()
+ source([[
+ call dictwatcheradd(]]..dict_expr..[[, "wat*", "g:Changed")
+ ]])
+ update('= 1')
+ verify_value({new = 1})
+ verify_value({new = 1})
+ update('= 3', 'watched2')
+ verify_value({new = 3}, 'watched2')
+ verify_value({new = 3}, 'watched2')
+ verify_echo()
+ source([[
+ call dictwatcherdel(]]..dict_expr..[[, "wat*", "g:Changed")
+ ]])
+ -- watch every key pattern
+ source([[
+ call dictwatcheradd(]]..dict_expr..[[, "*", "g:Changed")
+ ]])
+ update('= 3', 'another_key')
+ update('= 4', 'another_key')
+ update('', 'another_key')
+ update('= 2')
+ verify_value({new = 3}, 'another_key')
+ verify_value({old = 3, new = 4}, 'another_key')
+ verify_value({old = 4}, 'another_key')
+ verify_value({old = 1, new = 2})
+ verify_value({old = 1, new = 2})
+ verify_echo()
+ source([[
+ call dictwatcherdel(]]..dict_expr..[[, "*", "g:Changed")
+ ]])
+ end)
+
+ -- test a sequence of updates of different types to ensure proper memory
+ -- management(with ASAN)
+ local function test_updates(tests)
+ it('test change sequence', function()
+ local input, output
+ for i = 1, #tests do
+ input, output = unpack(tests[i])
+ update(input)
+ verify_value(output)
+ end
+ end)
+ end
+
+ test_updates({
+ {'= 3', {new = 3}},
+ {'= 6', {old = 3, new = 6}},
+ {'+= 3', {old = 6, new = 9}},
+ {'', {old = 9}}
+ })
+
+ test_updates({
+ {'= "str"', {new = 'str'}},
+ {'= "str2"', {old = 'str', new = 'str2'}},
+ {'.= "2str"', {old = 'str2', new = 'str22str'}},
+ {'', {old = 'str22str'}}
+ })
+
+ test_updates({
+ {'= [1, 2]', {new = {1, 2}}},
+ {'= [1, 2, 3]', {old = {1, 2}, new = {1, 2, 3}}},
+ -- the += will update the list in place, so old and new are the same
+ {'+= [4, 5]', {old = {1, 2, 3, 4, 5}, new = {1, 2, 3, 4, 5}}},
+ {'', {old = {1, 2, 3, 4 ,5}}}
+ })
+
+ test_updates({
+ {'= {"k": "v"}', {new = {k = 'v'}}},
+ {'= {"k1": 2}', {old = {k = 'v'}, new = {k1 = 2}}},
+ {'', {old = {k1 = 2}}},
+ })
+ end)
+ end
+
+ gentests('g:')
+ gentests('b:')
+ gentests('w:')
+ gentests('t:')
+ gentests('g:dict_var', '.', 'let g:dict_var = {}')
+
+ describe('multiple watchers on the same dict/key', function()
+ setup(function()
+ source([[
+ function! g:Watcher1(dict, key, value)
+ call rpcnotify(g:channel, '1', a:key, a:value)
+ endfunction
+ function! g:Watcher2(dict, key, value)
+ call rpcnotify(g:channel, '2', a:key, a:value)
+ endfunction
+ call dictwatcheradd(g:, "key", "g:Watcher1")
+ call dictwatcheradd(g:, "key", "g:Watcher2")
+ ]])
+ end)
+
+ it('invokes all callbacks when the key is changed', function()
+ nvim('command', 'let g:key = "value"')
+ eq({'notification', '1', {'key', {new = 'value'}}}, next_msg())
+ eq({'notification', '2', {'key', {new = 'value'}}}, next_msg())
+ end)
+
+ it('only removes watchers that fully match dict, key and callback', function()
+ nvim('command', 'call dictwatcherdel(g:, "key", "g:Watcher1")')
+ nvim('command', 'let g:key = "v2"')
+ eq({'notification', '2', {'key', {old = 'value', new = 'v2'}}}, next_msg())
+ end)
+ end)
+
+ describe('errors', function()
+ -- WARNING: This suite depends on the above tests
+ it('fails to remove if no watcher with matching callback is found', function()
+ eq("Vim(call):Couldn't find a watcher matching key and callback",
+ exc_exec('call dictwatcherdel(g:, "key", "g:Watcher1")'))
+ end)
+
+ it('fails to remove if no watcher with matching key is found', function()
+ eq("Vim(call):Couldn't find a watcher matching key and callback",
+ exc_exec('call dictwatcherdel(g:, "invalid_key", "g:Watcher2")'))
+ end)
+
+ it("fails to add/remove if the callback doesn't exist", function()
+ eq("Vim(call):Function g:InvalidCb doesn't exist",
+ exc_exec('call dictwatcheradd(g:, "key", "g:InvalidCb")'))
+ eq("Vim(call):Function g:InvalidCb doesn't exist",
+ exc_exec('call dictwatcherdel(g:, "key", "g:InvalidCb")'))
+ end)
+
+ it('fails with empty keys', function()
+ eq("Vim(call):E713: Cannot use empty key for Dictionary",
+ exc_exec('call dictwatcheradd(g:, "", "g:Watcher1")'))
+ eq("Vim(call):E713: Cannot use empty key for Dictionary",
+ exc_exec('call dictwatcherdel(g:, "", "g:Watcher1")'))
+ end)
+
+ it('fails to replace a watcher function', function()
+ source([[
+ function! g:ReplaceWatcher2()
+ function! g:Watcher2()
+ endfunction
+ endfunction
+ ]])
+ eq("Vim(function):E127: Cannot redefine function Watcher2: It is in use",
+ exc_exec('call g:ReplaceWatcher2()'))
+ end)
+ end)
+end)
diff --git a/test/functional/eval/glob_spec.lua b/test/functional/eval/glob_spec.lua
index f99a9e7d0e..c6bba46424 100644
--- a/test/functional/eval/glob_spec.lua
+++ b/test/functional/eval/glob_spec.lua
@@ -1,3 +1,4 @@
+local lfs = require('lfs')
local helpers = require('test.functional.helpers')
local clear, execute, eval, eq = helpers.clear, helpers.execute, helpers.eval, helpers.eq
diff --git a/test/functional/eval/msgpack_functions_spec.lua b/test/functional/eval/msgpack_functions_spec.lua
index 9a7b630f64..da42fc9d26 100644
--- a/test/functional/eval/msgpack_functions_spec.lua
+++ b/test/functional/eval/msgpack_functions_spec.lua
@@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')
-local clear, feed, execute = helpers.clear, helpers.feed, helpers.execute
-local eval, eq, neq = helpers.eval, helpers.eq, helpers.neq
-local execute, source = helpers.execute, helpers.source
+local clear = helpers.clear
+local eval, eq = helpers.eval, helpers.eq
+local execute = helpers.execute
local nvim = helpers.nvim
local exc_exec = helpers.exc_exec
@@ -454,9 +454,9 @@ describe('msgpackparse() function', function()
it('msgpackparse(systemlist(...)) does not segfault. #3135', function()
local cmd = "sort(keys(msgpackparse(systemlist('"
..helpers.nvim_prog.." --api-info'))[0]))"
- local api_info = eval(cmd)
- api_info = eval(cmd) -- do it again (try to force segfault)
- api_info = eval(cmd) -- do it again
+ eval(cmd)
+ eval(cmd) -- do it again (try to force segfault)
+ local api_info = eval(cmd) -- do it again
eq({'error_types', 'functions', 'types'}, api_info)
end)
diff --git a/test/functional/ex_cmds/grep_spec.lua b/test/functional/ex_cmds/grep_spec.lua
index 9c792099c1..f3ff0a3817 100644
--- a/test/functional/ex_cmds/grep_spec.lua
+++ b/test/functional/ex_cmds/grep_spec.lua
@@ -1,7 +1,6 @@
local helpers = require('test.functional.helpers')
-local clear, execute, nvim, feed, eq, ok, eval =
- helpers.clear, helpers.execute, helpers.nvim, helpers.feed,
- helpers.eq, helpers.ok, helpers.eval
+local clear, execute, feed, ok, eval =
+ helpers.clear, helpers.execute, helpers.feed, helpers.ok, helpers.eval
describe(':grep', function()
before_each(clear)
diff --git a/test/functional/ex_cmds/oldfiles_spec.lua b/test/functional/ex_cmds/oldfiles_spec.lua
new file mode 100644
index 0000000000..dac6757a97
--- /dev/null
+++ b/test/functional/ex_cmds/oldfiles_spec.lua
@@ -0,0 +1,94 @@
+local Screen = require('test.functional.ui.screen')
+local helpers = require('test.functional.helpers')
+
+local buf, eq, execute = helpers.curbufmeths, helpers.eq, helpers.execute
+local feed, nvim_prog = helpers.feed, helpers.nvim_prog
+local ok, set_session, spawn = helpers.ok, helpers.set_session, helpers.spawn
+
+local shada_file = 'test.shada'
+
+--
+-- helpers.clear() uses "-i NONE", which is not useful for this test.
+--
+local function _clear()
+ set_session(spawn({nvim_prog,
+ '-u', 'NONE',
+ '--cmd', 'set noswapfile undodir=. directory=. viewdir=. backupdir=.',
+ '--embed'}))
+end
+
+describe(':oldfiles', function()
+ before_each(_clear)
+
+ after_each(function()
+ os.remove(shada_file)
+ end)
+
+ local function add_padding(s)
+ return s .. string.rep(' ', 96 - string.len(s))
+ end
+
+ it('shows most recently used files', function()
+ local screen = Screen.new(100, 5)
+ screen:attach()
+ execute('edit testfile1')
+ execute('edit testfile2')
+ execute('wshada ' .. shada_file)
+ execute('rshada! ' .. shada_file)
+ local oldfiles = helpers.meths.get_vvar('oldfiles')
+ execute('oldfiles')
+ screen:expect([[
+ testfile2 |
+ 1: ]].. add_padding(oldfiles[1]) ..[[ |
+ 2: ]].. add_padding(oldfiles[2]) ..[[ |
+ |
+ Press ENTER or type command to continue^ |
+ ]])
+ end)
+end)
+
+describe(':oldfiles!', function()
+ local filename
+ local filename2
+ local oldfiles
+
+ before_each(function()
+ _clear()
+ execute('edit testfile1')
+ filename = buf.get_name()
+ execute('edit testfile2')
+ filename2 = buf.get_name()
+ execute('wshada ' .. shada_file)
+ _clear()
+ execute('rshada! ' .. shada_file)
+
+ -- Ensure v:oldfiles isn't busted. Since things happen so fast,
+ -- the ordering of v:oldfiles is unstable (it uses qsort() under-the-hood).
+ -- Let's verify the contents and the length of v:oldfiles before moving on.
+ oldfiles = helpers.meths.get_vvar('oldfiles')
+ eq(2, #oldfiles)
+ ok(filename == oldfiles[1] or filename == oldfiles[2])
+ ok(filename2 == oldfiles[1] or filename2 == oldfiles[2])
+
+ execute('oldfiles!')
+ end)
+
+ after_each(function()
+ os.remove(shada_file)
+ end)
+
+ it('provides a prompt and edits the chosen file', function()
+ feed('2<cr>')
+ eq(oldfiles[2], buf.get_name())
+ end)
+
+ it('provides a prompt and does nothing on <cr>', function()
+ feed('<cr>')
+ eq('', buf.get_name())
+ end)
+
+ it('provides a prompt and does nothing if choice is out-of-bounds', function()
+ feed('3<cr>')
+ eq('', buf.get_name())
+ end)
+end)
diff --git a/test/functional/ex_cmds/profile_spec.lua b/test/functional/ex_cmds/profile_spec.lua
new file mode 100644
index 0000000000..744b22621f
--- /dev/null
+++ b/test/functional/ex_cmds/profile_spec.lua
@@ -0,0 +1,51 @@
+require('os')
+local lfs = require('lfs')
+
+local helpers = require('test.functional.helpers')
+local eval = helpers.eval
+local command = helpers.command
+local eq, neq = helpers.eq, helpers.neq
+local tempfile = os.tmpname()
+
+-- os.tmpname() also creates the file on POSIX systems. Remove it again.
+-- We just need the name, ignoring any race conditions.
+if lfs.attributes(tempfile, 'uid') then
+ os.remove(tempfile)
+end
+
+local function assert_file_exists(filepath)
+ -- Use 2-argument lfs.attributes() so no extra table gets created.
+ -- We don't really care for the uid.
+ neq(nil, lfs.attributes(filepath, 'uid'))
+end
+
+local function assert_file_exists_not(filepath)
+ eq(nil, lfs.attributes(filepath, 'uid'))
+end
+
+describe(':profile', function()
+ before_each(helpers.clear)
+
+ after_each(function()
+ if lfs.attributes(tempfile, 'uid') ~= nil then
+ os.remove(tempfile)
+ end
+ end)
+
+ it('dump', function()
+ eq(0, eval('v:profiling'))
+ command('profile start ' .. tempfile)
+ eq(1, eval('v:profiling'))
+ assert_file_exists_not(tempfile)
+ command('profile dump')
+ assert_file_exists(tempfile)
+ end)
+
+ it('stop', function()
+ command('profile start ' .. tempfile)
+ assert_file_exists_not(tempfile)
+ command('profile stop')
+ assert_file_exists(tempfile)
+ eq(0, eval('v:profiling'))
+ end)
+end)
diff --git a/test/functional/ex_cmds/quit_spec.lua b/test/functional/ex_cmds/quit_spec.lua
index 3cd8e19617..a8156228d3 100644
--- a/test/functional/ex_cmds/quit_spec.lua
+++ b/test/functional/ex_cmds/quit_spec.lua
@@ -1,5 +1,5 @@
local helpers = require('test.functional.helpers')
-local execute, eq, clear = helpers.execute, helpers.eq, helpers.clear
+local clear = helpers.clear
describe(':qa', function()
before_each(function()
diff --git a/test/functional/ex_cmds/recover_spec.lua b/test/functional/ex_cmds/recover_spec.lua
index a24a60af81..e1d01f6896 100644
--- a/test/functional/ex_cmds/recover_spec.lua
+++ b/test/functional/ex_cmds/recover_spec.lua
@@ -1,6 +1,7 @@
-- Tests for :recover
local helpers = require('test.functional.helpers')
+local lfs = require('lfs')
local execute, eq, clear, eval, feed, expect, source =
helpers.execute, helpers.eq, helpers.clear, helpers.eval, helpers.feed,
helpers.expect, helpers.source
@@ -29,9 +30,11 @@ describe(':preserve', function()
it("saves to custom 'directory' and (R)ecovers (issue #1836)", function()
local testfile = 'testfile_recover_spec'
+ -- Note: `set swapfile` *must* go after `set directory`: otherwise it may
+ -- attempt to create a swapfile in different directory.
local init = [[
- set swapfile fileformat=unix undolevels=-1
set directory^=]]..swapdir..[[//
+ set swapfile fileformat=unix undolevels=-1
]]
source(init)
@@ -47,7 +50,7 @@ describe(':preserve', function()
--TODO(justinmk): this is an ugly hack to force `helpers` to support
--multiple sessions.
- local nvim2 = helpers.spawn({helpers.nvim_prog, '-u', 'NONE', '--embed'},
+ local nvim2 = helpers.spawn({helpers.nvim_prog, '-u', 'NONE', '-i', 'NONE', '--embed'},
true)
helpers.set_session(nvim2)
diff --git a/test/functional/ex_cmds/sign_spec.lua b/test/functional/ex_cmds/sign_spec.lua
index be213cd0d9..c50704504d 100644
--- a/test/functional/ex_cmds/sign_spec.lua
+++ b/test/functional/ex_cmds/sign_spec.lua
@@ -1,7 +1,5 @@
local helpers = require('test.functional.helpers')
-local clear, nvim, buffer, curbuf, curwin, eq, ok =
- helpers.clear, helpers.nvim, helpers.buffer, helpers.curbuf, helpers.curwin,
- helpers.eq, helpers.ok
+local clear, nvim, eq = helpers.clear, helpers.nvim, helpers.eq
describe('sign', function()
before_each(clear)
diff --git a/test/functional/ex_cmds/wundo_spec.lua b/test/functional/ex_cmds/wundo_spec.lua
index d8bd8a7031..c3147e1c0f 100644
--- a/test/functional/ex_cmds/wundo_spec.lua
+++ b/test/functional/ex_cmds/wundo_spec.lua
@@ -1,9 +1,9 @@
--- Specs for
--- :wundo
+-- Specs for :wundo and underlying functions
local helpers = require('test.functional.helpers')
-local execute, eq, clear, eval, feed =
- helpers.execute, helpers.eq, helpers.clear, helpers.eval, helpers.feed
+local execute, clear, eval, feed, spawn, nvim_prog, set_session =
+ helpers.execute, helpers.clear, helpers.eval, helpers.feed, helpers.spawn,
+ helpers.nvim_prog, helpers.set_session
describe(':wundo', function()
@@ -16,5 +16,14 @@ describe(':wundo', function()
os.remove(eval('getcwd()') .. '/foo') --cleanup
end)
+end)
+describe('u_* functions', function()
+ it('safely fail on new, non-empty buffer', function()
+ local session = spawn({nvim_prog, '-u', 'NONE', '-i', 'NONE', '--embed',
+ '-c', 'set undodir=. undofile'})
+ set_session(session)
+ execute('echo "True"') -- Should not error out due to crashed Neovim
+ session:exit(0)
+ end)
end)
diff --git a/test/functional/ex_cmds/wviminfo_spec.lua b/test/functional/ex_cmds/wviminfo_spec.lua
index 0c85157a0f..207d94124f 100644
--- a/test/functional/ex_cmds/wviminfo_spec.lua
+++ b/test/functional/ex_cmds/wviminfo_spec.lua
@@ -1,6 +1,6 @@
local helpers, lfs = require('test.functional.helpers'), require('lfs')
-local clear, execute, eq, neq, spawn, nvim_prog, set_session, wait, write_file
- = helpers.clear, helpers.execute, helpers.eq, helpers.neq, helpers.spawn,
+local execute, eq, neq, spawn, nvim_prog, set_session, wait, write_file
+ = helpers.execute, helpers.eq, helpers.neq, helpers.spawn,
helpers.nvim_prog, helpers.set_session, helpers.wait, helpers.write_file
describe(':wshada', function()
@@ -13,7 +13,7 @@ describe(':wshada', function()
end
-- Override the default session because we need 'swapfile' for these tests.
- local session = spawn({nvim_prog, '-u', 'NONE', '--embed',
+ session = spawn({nvim_prog, '-u', 'NONE', '-i', '/dev/null', '--embed',
'--cmd', 'set swapfile'})
set_session(session)
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua
index a62f7a3d00..9562457c8e 100644
--- a/test/functional/helpers.lua
+++ b/test/functional/helpers.lua
@@ -1,4 +1,5 @@
require('coxpcall')
+local lfs = require('lfs')
local assert = require('luassert')
local Loop = require('nvim.loop')
local MsgpackStream = require('nvim.msgpack_stream')
@@ -7,7 +8,7 @@ local Session = require('nvim.session')
local nvim_prog = os.getenv('NVIM_PROG') or 'build/bin/nvim'
local nvim_argv = {nvim_prog, '-u', 'NONE', '-i', 'NONE', '-N',
- '--cmd', 'set shortmess+=I background=light noswapfile noautoindent laststatus=1 encoding=utf-8',
+ '--cmd', 'set shortmess+=I background=light noswapfile noautoindent laststatus=1 encoding=utf-8 undodir=. directory=. viewdir=. backupdir=.',
'--embed'}
-- Formulate a path to the directory containing nvim. We use this to
@@ -55,7 +56,7 @@ if prepend_argv then
nvim_argv = new_nvim_argv
end
-local session, loop_running, loop_stopped, last_error
+local session, loop_running, last_error
local function set_session(s)
session = s
@@ -79,7 +80,7 @@ local function next_message()
end
local function call_and_stop_on_error(...)
- local status, result = copcall(...)
+ local status, result = copcall(...) -- luacheck: ignore
if not status then
session:stop()
last_error = result
@@ -109,7 +110,6 @@ local function run(request_cb, notification_cb, setup_cb, timeout)
end
end
- loop_stopped = false
loop_running = true
session:run(on_request, on_notification, on_setup, timeout)
loop_running = false
@@ -121,7 +121,6 @@ local function run(request_cb, notification_cb, setup_cb, timeout)
end
local function stop()
- loop_stopped = true
session:stop()
end
@@ -197,9 +196,9 @@ local function spawn(argv, merge)
local loop = Loop.new()
local msgpack_stream = MsgpackStream.new(loop)
local async_session = AsyncSession.new(msgpack_stream)
- local session = Session.new(async_session)
+ local sess = Session.new(async_session)
loop:spawn(merge and merge_args(prepend_argv, argv) or argv)
- return session
+ return sess
end
local function clear(extra_cmd)
@@ -332,14 +331,14 @@ local function rmdir(path)
if file == '.' or file == '..' then
goto continue
end
- ret, err = os.remove(path..'/'..file)
+ local ret, err = os.remove(path..'/'..file)
if not ret then
error('os.remove: '..err)
return nil
end
::continue::
end
- ret, err = os.remove(path)
+ local ret, err = os.remove(path)
if not ret then
error('os.remove: '..err)
end
@@ -371,15 +370,15 @@ local function redir_exec(cmd)
end
local function create_callindex(func)
- local tbl = {}
- setmetatable(tbl, {
+ local table = {}
+ setmetatable(table, {
__index = function(tbl, arg1)
- ret = function(...) return func(arg1, ...) end
+ local ret = function(...) return func(arg1, ...) end
tbl[arg1] = ret
return ret
end,
})
- return tbl
+ return table
end
local funcs = create_callindex(nvim_call)
diff --git a/test/functional/job/job_spec.lua b/test/functional/job/job_spec.lua
index bdaf2a7ec6..0915ab0955 100644
--- a/test/functional/job/job_spec.lua
+++ b/test/functional/job/job_spec.lua
@@ -1,11 +1,11 @@
local helpers = require('test.functional.helpers')
-local clear, eq, eval, execute, expect, feed, insert, neq, next_msg, nvim,
- nvim_dir, ok, run, session, source, stop, wait, write_file = helpers.clear,
- helpers.eq, helpers.eval, helpers.execute, helpers.expect, helpers.feed,
+local clear, eq, eval, execute, feed, insert, neq, next_msg, nvim,
+ nvim_dir, ok, source, write_file = helpers.clear,
+ helpers.eq, helpers.eval, helpers.execute, helpers.feed,
helpers.insert, helpers.neq, helpers.next_message, helpers.nvim,
- helpers.nvim_dir, helpers.ok, helpers.run, helpers.session, helpers.source,
- helpers.stop, helpers.wait, helpers.write_file
+ helpers.nvim_dir, helpers.ok, helpers.source,
+ helpers.write_file
local Screen = require('test.functional.ui.screen')
@@ -370,7 +370,7 @@ describe('jobs', function()
describe('running tty-test program', function()
local function next_chunk()
- local rv = ''
+ local rv
while true do
local msg = next_msg()
local data = msg[3][2]
diff --git a/test/functional/legacy/003_cindent_spec.lua b/test/functional/legacy/003_cindent_spec.lua
index 1857721563..39de3e8280 100644
--- a/test/functional/legacy/003_cindent_spec.lua
+++ b/test/functional/legacy/003_cindent_spec.lua
@@ -4,7 +4,7 @@
-- in the original test. These have been converted to "it" test cases here.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local feed, insert = helpers.feed, helpers.insert
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
-- Inserts text as usual, and additionally positions the cursor on line 1 and
diff --git a/test/functional/legacy/009_bufleave_autocommand_spec.lua b/test/functional/legacy/009_bufleave_autocommand_spec.lua
index 0fc1b5b657..8c18639c8f 100644
--- a/test/functional/legacy/009_bufleave_autocommand_spec.lua
+++ b/test/functional/legacy/009_bufleave_autocommand_spec.lua
@@ -1,7 +1,7 @@
-- Test for Bufleave autocommand that deletes the buffer we are about to edit.
local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local clear, insert = helpers.clear, helpers.insert
local execute, expect = helpers.execute, helpers.expect
describe('BufLeave autocommand', function()
diff --git a/test/functional/legacy/015_alignment_spec.lua b/test/functional/legacy/015_alignment_spec.lua
index e71f9d1c90..3b19f4ff42 100644
--- a/test/functional/legacy/015_alignment_spec.lua
+++ b/test/functional/legacy/015_alignment_spec.lua
@@ -3,7 +3,7 @@
-- Also test undo after ":%s" and formatting.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local feed, insert = helpers.feed, helpers.insert
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
describe('alignment', function()
diff --git a/test/functional/legacy/022_line_ending_spec.lua b/test/functional/legacy/022_line_ending_spec.lua
index 4b897a7c95..a841378a82 100644
--- a/test/functional/legacy/022_line_ending_spec.lua
+++ b/test/functional/legacy/022_line_ending_spec.lua
@@ -1,7 +1,7 @@
-- Tests for file with some lines ending in CTRL-M, some not
local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local clear, feed = helpers.clear, helpers.feed
local execute, expect = helpers.execute, helpers.expect
describe('line ending', function()
diff --git a/test/functional/legacy/023_edit_arguments_spec.lua b/test/functional/legacy/023_edit_arguments_spec.lua
index e68af9758d..15b30bfa3a 100644
--- a/test/functional/legacy/023_edit_arguments_spec.lua
+++ b/test/functional/legacy/023_edit_arguments_spec.lua
@@ -1,7 +1,7 @@
-- Tests for complicated + argument to :edit command
local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local clear, insert = helpers.clear, helpers.insert
local execute, expect = helpers.execute, helpers.expect
describe(':edit', function()
diff --git a/test/functional/legacy/026_execute_while_if_spec.lua b/test/functional/legacy/026_execute_while_if_spec.lua
index ffe37819de..f17bb79702 100644
--- a/test/functional/legacy/026_execute_while_if_spec.lua
+++ b/test/functional/legacy/026_execute_while_if_spec.lua
@@ -1,7 +1,7 @@
-- Test for :execute, :while and :if
local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local clear = helpers.clear
local execute, expect = helpers.execute, helpers.expect
local source = helpers.source
diff --git a/test/functional/legacy/027_expand_file_names_spec.lua b/test/functional/legacy/027_expand_file_names_spec.lua
index d31f29d38a..4778d16d43 100644
--- a/test/functional/legacy/027_expand_file_names_spec.lua
+++ b/test/functional/legacy/027_expand_file_names_spec.lua
@@ -1,10 +1,10 @@
-- Test for expanding file names
local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
-local execute, expect = helpers.execute, helpers.expect
+local clear, feed = helpers.clear, helpers.feed
+local execute = helpers.execute
local curbuf_contents = helpers.curbuf_contents
-local eq, eval = helpers.eq, helpers.eval
+local eq = helpers.eq
describe('expand file name', function()
setup(clear)
diff --git a/test/functional/legacy/029_join_spec.lua b/test/functional/legacy/029_join_spec.lua
index eafa50d88c..25a072ad6e 100644
--- a/test/functional/legacy/029_join_spec.lua
+++ b/test/functional/legacy/029_join_spec.lua
@@ -1,7 +1,7 @@
-- Test for joining lines with marks in them (and with 'joinspaces' set/reset)
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local feed, insert = helpers.feed, helpers.insert
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
describe('joining lines', function()
diff --git a/test/functional/legacy/031_close_commands_spec.lua b/test/functional/legacy/031_close_commands_spec.lua
index 78e71b5fb1..3597cba12a 100644
--- a/test/functional/legacy/031_close_commands_spec.lua
+++ b/test/functional/legacy/031_close_commands_spec.lua
@@ -10,7 +10,7 @@
-- :edit
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local feed, insert = helpers.feed, helpers.insert
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
describe('Commands that close windows and/or buffers', function()
diff --git a/test/functional/legacy/038_virtual_replace_spec.lua b/test/functional/legacy/038_virtual_replace_spec.lua
index 94503bd42a..10d42f0cea 100644
--- a/test/functional/legacy/038_virtual_replace_spec.lua
+++ b/test/functional/legacy/038_virtual_replace_spec.lua
@@ -1,7 +1,7 @@
-- Test Virtual replace mode.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local feed = helpers.feed
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
describe('Virtual replace mode', function()
diff --git a/test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua b/test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua
index efe61aa354..1359b45228 100644
--- a/test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua
+++ b/test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua
@@ -4,7 +4,7 @@
-- This test contains both "test44" and "test99" from the old test suite.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local feed, insert = helpers.feed, helpers.insert
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
-- Runs the test protocol with the given 'regexpengine' setting. In the old test
diff --git a/test/functional/legacy/046_multi_line_regexps_spec.lua b/test/functional/legacy/046_multi_line_regexps_spec.lua
index f8a6143b18..b17ab42fe3 100644
--- a/test/functional/legacy/046_multi_line_regexps_spec.lua
+++ b/test/functional/legacy/046_multi_line_regexps_spec.lua
@@ -3,7 +3,7 @@
local helpers = require('test.functional.helpers')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
-local execute, expect = helpers.execute, helpers.expect
+local expect = helpers.expect
describe('multi-line regexp', function()
setup(clear)
diff --git a/test/functional/legacy/051_highlight_spec.lua b/test/functional/legacy/051_highlight_spec.lua
index 620df97aac..94c42b73e5 100644
--- a/test/functional/legacy/051_highlight_spec.lua
+++ b/test/functional/legacy/051_highlight_spec.lua
@@ -3,7 +3,7 @@
local Screen = require('test.functional.ui.screen')
local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local clear, feed = helpers.clear, helpers.feed
local execute, expect = helpers.execute, helpers.expect
local wait = helpers.wait
diff --git a/test/functional/legacy/056_script_local_function_spec.lua b/test/functional/legacy/056_script_local_function_spec.lua
index 147391ceb1..dec88e8001 100644
--- a/test/functional/legacy/056_script_local_function_spec.lua
+++ b/test/functional/legacy/056_script_local_function_spec.lua
@@ -3,7 +3,7 @@
local helpers = require('test.functional.helpers')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
-local execute, expect = helpers.execute, helpers.expect
+local expect = helpers.expect
describe('source function', function()
setup(clear)
diff --git a/test/functional/legacy/060_exists_and_has_functions_spec.lua b/test/functional/legacy/060_exists_and_has_functions_spec.lua
index e9b79b490d..7f44b35a4e 100644
--- a/test/functional/legacy/060_exists_and_has_functions_spec.lua
+++ b/test/functional/legacy/060_exists_and_has_functions_spec.lua
@@ -1,8 +1,8 @@
-- Tests for the exists() and has() functions.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
-local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+local source = helpers.source
+local clear, expect = helpers.clear, helpers.expect
local write_file = helpers.write_file
describe('exists() and has() functions', function()
diff --git a/test/functional/legacy/061_undo_tree_spec.lua b/test/functional/legacy/061_undo_tree_spec.lua
index 8cc2a371bb..ceb114b2a7 100644
--- a/test/functional/legacy/061_undo_tree_spec.lua
+++ b/test/functional/legacy/061_undo_tree_spec.lua
@@ -1,8 +1,8 @@
-- Tests for undo tree and :earlier and :later.
local helpers = require('test.functional.helpers')
-local feed, insert, source, eq, eval, clear, execute, expect, wait, write_file
- = helpers.feed, helpers.insert, helpers.source, helpers.eq, helpers.eval,
+local feed, source, eq, eval, clear, execute, expect, wait, write_file =
+ helpers.feed, helpers.source, helpers.eq, helpers.eval,
helpers.clear, helpers.execute, helpers.expect, helpers.wait,
helpers.write_file
@@ -97,9 +97,8 @@ describe('undo tree:', function()
-- Retry up to 3 times. pcall() is _not_ used for the final attempt, so
-- that failure messages can bubble up.
- local success, result = false, ''
- for i = 1, 2 do
- success, result = pcall(test_earlier_later)
+ for _ = 1, 2 do
+ local success = pcall(test_earlier_later)
if success then
return
end
diff --git a/test/functional/legacy/063_match_and_matchadd_spec.lua b/test/functional/legacy/063_match_and_matchadd_spec.lua
index d819db7812..a354d4d328 100644
--- a/test/functional/legacy/063_match_and_matchadd_spec.lua
+++ b/test/functional/legacy/063_match_and_matchadd_spec.lua
@@ -2,10 +2,9 @@
local helpers = require('test.functional.helpers')
local Screen = require('test.functional.ui.screen')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
-local eval, clear, execute, expect = helpers.eval, helpers.clear, helpers.execute
-local expect, eq, neq = helpers.expect, helpers.eq, helpers.neq
-local command = helpers.command
+local feed, insert = helpers.feed, helpers.insert
+local eval, clear, execute = helpers.eval, helpers.clear, helpers.execute
+local eq, neq = helpers.eq, helpers.neq
describe('063: Test for ":match", "matchadd()" and related functions', function()
setup(clear)
@@ -86,7 +85,7 @@ describe('063: Test for ":match", "matchadd()" and related functions', function(
execute("2match MyGroup2 /HUMPPA/")
execute("3match MyGroup3 /VIM/")
execute("let ml = getmatches()")
- ml = eval("ml")
+ local ml = eval("ml")
execute("call clearmatches()")
execute("call setmatches(ml)")
eq(ml, eval('getmatches()'))
diff --git a/test/functional/legacy/065_float_and_logic_operators_spec.lua b/test/functional/legacy/065_float_and_logic_operators_spec.lua
index 5cdb0b7f58..e78b230956 100644
--- a/test/functional/legacy/065_float_and_logic_operators_spec.lua
+++ b/test/functional/legacy/065_float_and_logic_operators_spec.lua
@@ -1,7 +1,7 @@
-- Test for floating point and logical operators.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local insert, source = helpers.insert, helpers.source
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
describe('floating point and logical operators', function()
diff --git a/test/functional/legacy/067_augroup_exists_spec.lua b/test/functional/legacy/067_augroup_exists_spec.lua
index 6d89ad6d55..dc4c9c7eeb 100644
--- a/test/functional/legacy/067_augroup_exists_spec.lua
+++ b/test/functional/legacy/067_augroup_exists_spec.lua
@@ -2,7 +2,7 @@
-- autocommands.
local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local clear = helpers.clear
local execute, expect = helpers.execute, helpers.expect
describe('augroup when calling exists()', function()
diff --git a/test/functional/legacy/072_undo_file_spec.lua b/test/functional/legacy/072_undo_file_spec.lua
index b7f7a65b30..efcc2f2cc3 100644
--- a/test/functional/legacy/072_undo_file_spec.lua
+++ b/test/functional/legacy/072_undo_file_spec.lua
@@ -3,7 +3,7 @@
-- undo-able pieces. Do that by setting 'undolevels'.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local feed, insert = helpers.feed, helpers.insert
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
describe('72', function()
@@ -18,7 +18,7 @@ describe('72', function()
-- Test 'undofile': first a simple one-line change.
execute('set visualbell')
- execute('set ul=100 undofile nomore')
+ execute('set ul=100 undofile undodir=. nomore')
execute('e! Xtestfile')
feed('ggdGithis is one line<esc>:set ul=100<cr>')
execute('s/one/ONE/')
diff --git a/test/functional/legacy/074_global_var_in_viminfo_spec.lua b/test/functional/legacy/074_global_var_in_viminfo_spec.lua
index 2428b7f74d..49c4827613 100644
--- a/test/functional/legacy/074_global_var_in_viminfo_spec.lua
+++ b/test/functional/legacy/074_global_var_in_viminfo_spec.lua
@@ -13,7 +13,7 @@ describe('storing global variables in ShaDa files', function()
end)
it('is working', function()
- local nvim2 = helpers.spawn({helpers.nvim_prog, '-u', 'NONE',
+ local nvim2 = spawn({helpers.nvim_prog, '-u', 'NONE',
'-i', 'Xviminfo', '--embed'})
helpers.set_session(nvim2)
diff --git a/test/functional/legacy/075_maparg_spec.lua b/test/functional/legacy/075_maparg_spec.lua
index 418abb14d4..82965f5cb2 100644
--- a/test/functional/legacy/075_maparg_spec.lua
+++ b/test/functional/legacy/075_maparg_spec.lua
@@ -2,7 +2,7 @@
-- Also test utf8 map with a 0x80 byte.
local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local clear, feed = helpers.clear, helpers.feed
local execute, expect = helpers.execute, helpers.expect
describe('maparg()', function()
diff --git a/test/functional/legacy/077_mf_hash_grow_spec.lua b/test/functional/legacy/077_mf_hash_grow_spec.lua
index 825f08e968..029fe98fe9 100644
--- a/test/functional/legacy/077_mf_hash_grow_spec.lua
+++ b/test/functional/legacy/077_mf_hash_grow_spec.lua
@@ -7,7 +7,7 @@
-- If it isn't available then the test will be skipped.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local feed = helpers.feed
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
describe('mf_hash_grow()', function()
diff --git a/test/functional/legacy/078_swapfile_recover_spec.lua b/test/functional/legacy/078_swapfile_recover_spec.lua
index e250c91441..e48fddaac1 100644
--- a/test/functional/legacy/078_swapfile_recover_spec.lua
+++ b/test/functional/legacy/078_swapfile_recover_spec.lua
@@ -4,9 +4,7 @@
-- pointer blocks.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
-local clear, execute, expect, source = helpers.clear, helpers.execute, helpers.expect, helpers.source
-local eval = helpers.eval
+local clear, expect, source = helpers.clear, helpers.expect, helpers.source
describe('78', function()
setup(clear)
@@ -17,7 +15,7 @@ describe('78', function()
it('is working', function()
source([=[
- set swapfile fileformat=unix undolevels=-1
+ set directory=. swapfile fileformat=unix undolevels=-1
e! Xtest
let text = "\tabcdefghijklmnoparstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnoparstuvwxyz0123456789"
let i = 1
diff --git a/test/functional/legacy/080_substitute_spec.lua b/test/functional/legacy/080_substitute_spec.lua
index 89ef7a713c..96082364e0 100644
--- a/test/functional/legacy/080_substitute_spec.lua
+++ b/test/functional/legacy/080_substitute_spec.lua
@@ -3,7 +3,7 @@
-- Test for *:s%* on :substitute.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local feed, insert = helpers.feed, helpers.insert
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
local eq, eval = helpers.eq, helpers.eval
diff --git a/test/functional/legacy/082_string_comparison_spec.lua b/test/functional/legacy/082_string_comparison_spec.lua
index 1615828ca0..933c6c8fa3 100644
--- a/test/functional/legacy/082_string_comparison_spec.lua
+++ b/test/functional/legacy/082_string_comparison_spec.lua
@@ -2,7 +2,7 @@
-- Also test "g~ap".
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local feed, source = helpers.feed, helpers.source
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
describe('case-insensitive string comparison in UTF-8', function()
diff --git a/test/functional/legacy/084_curswant_spec.lua b/test/functional/legacy/084_curswant_spec.lua
index 55df5d3e73..946dd5e501 100644
--- a/test/functional/legacy/084_curswant_spec.lua
+++ b/test/functional/legacy/084_curswant_spec.lua
@@ -1,8 +1,8 @@
-- Tests for curswant not changing when setting an option.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
-local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+local insert, source = helpers.insert, helpers.source
+local clear, expect = helpers.clear, helpers.expect
describe('curswant', function()
setup(clear)
diff --git a/test/functional/legacy/089_number_relnumber_findfile_spec.lua b/test/functional/legacy/089_number_relnumber_findfile_spec.lua
index 1f8e49cc81..f72ebf3f72 100644
--- a/test/functional/legacy/089_number_relnumber_findfile_spec.lua
+++ b/test/functional/legacy/089_number_relnumber_findfile_spec.lua
@@ -4,7 +4,7 @@
local helpers = require('test.functional.helpers')
local feed = helpers.feed
-local clear, execute, expect, source = helpers.clear, helpers.execute, helpers.expect, helpers.source
+local clear, expect, source = helpers.clear, helpers.expect, helpers.source
describe("setting 'number' and 'relativenumber'", function()
setup(clear)
diff --git a/test/functional/legacy/090_sha256_spec.lua b/test/functional/legacy/090_sha256_spec.lua
index 35fbd5752e..95e50063a1 100644
--- a/test/functional/legacy/090_sha256_spec.lua
+++ b/test/functional/legacy/090_sha256_spec.lua
@@ -1,8 +1,8 @@
-- Tests for sha256() function.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
-local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+local insert, source = helpers.insert, helpers.source
+local clear, expect = helpers.clear, helpers.expect
describe('sha256()', function()
setup(clear)
diff --git a/test/functional/legacy/091_context_variables_spec.lua b/test/functional/legacy/091_context_variables_spec.lua
index bb9c32b84f..ffeb0c657e 100644
--- a/test/functional/legacy/091_context_variables_spec.lua
+++ b/test/functional/legacy/091_context_variables_spec.lua
@@ -1,8 +1,8 @@
-- Tests for getbufvar(), getwinvar(), gettabvar() and gettabwinvar().
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
-local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+local insert, source = helpers.insert, helpers.source
+local clear, expect = helpers.clear, helpers.expect
describe('context variables', function()
setup(clear)
diff --git a/test/functional/legacy/092_mksession_cursor_cols_utf8_spec.lua b/test/functional/legacy/092_mksession_cursor_cols_utf8_spec.lua
index e0cc39dc40..f76ba25d7a 100644
--- a/test/functional/legacy/092_mksession_cursor_cols_utf8_spec.lua
+++ b/test/functional/legacy/092_mksession_cursor_cols_utf8_spec.lua
@@ -4,7 +4,7 @@
-- Same as legacy test 93 but using UTF-8 file encoding.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local feed, insert = helpers.feed, helpers.insert
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
describe('store cursor position in session file in UTF-8', function()
diff --git a/test/functional/legacy/093_mksession_cursor_cols_latin1_spec.lua b/test/functional/legacy/093_mksession_cursor_cols_latin1_spec.lua
index 659e716721..bf3af1a827 100644
--- a/test/functional/legacy/093_mksession_cursor_cols_latin1_spec.lua
+++ b/test/functional/legacy/093_mksession_cursor_cols_latin1_spec.lua
@@ -4,7 +4,7 @@
-- Same as legacy test 92 but using Latin-1 file encoding.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local feed, insert = helpers.feed, helpers.insert
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
describe('store cursor position in session file in Latin-1', function()
diff --git a/test/functional/legacy/095_regexp_multibyte_spec.lua b/test/functional/legacy/095_regexp_multibyte_spec.lua
index 559222e2ff..a80a247612 100644
--- a/test/functional/legacy/095_regexp_multibyte_spec.lua
+++ b/test/functional/legacy/095_regexp_multibyte_spec.lua
@@ -4,8 +4,8 @@
-- actually tried.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
-local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+local insert, source = helpers.insert, helpers.source
+local clear, expect = helpers.clear, helpers.expect
describe('regex with multi-byte', function()
setup(clear)
diff --git a/test/functional/legacy/096_location_list_spec.lua b/test/functional/legacy/096_location_list_spec.lua
index 2ccfd3530d..6e2f22ea33 100644
--- a/test/functional/legacy/096_location_list_spec.lua
+++ b/test/functional/legacy/096_location_list_spec.lua
@@ -7,7 +7,7 @@
-- it belongs to.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local source = helpers.source
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
describe('location list', function()
diff --git a/test/functional/legacy/097_glob_path_spec.lua b/test/functional/legacy/097_glob_path_spec.lua
index 84f26478ac..5c467fbb20 100644
--- a/test/functional/legacy/097_glob_path_spec.lua
+++ b/test/functional/legacy/097_glob_path_spec.lua
@@ -3,7 +3,7 @@
-- characters.
local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local clear = helpers.clear
local execute, expect = helpers.execute, helpers.expect
describe('glob() and globpath()', function()
diff --git a/test/functional/legacy/098_scrollbind_spec.lua b/test/functional/legacy/098_scrollbind_spec.lua
index 7b2059e38b..6850e373ab 100644
--- a/test/functional/legacy/098_scrollbind_spec.lua
+++ b/test/functional/legacy/098_scrollbind_spec.lua
@@ -1,8 +1,8 @@
-- Test for 'scrollbind' causing an unexpected scroll of one of the windows.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
-local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+local source = helpers.source
+local clear, expect = helpers.clear, helpers.expect
describe('scrollbind', function()
setup(clear)
diff --git a/test/functional/legacy/100_undo_level_spec.lua b/test/functional/legacy/100_undo_level_spec.lua
index 9143d9e540..3bf72341d6 100644
--- a/test/functional/legacy/100_undo_level_spec.lua
+++ b/test/functional/legacy/100_undo_level_spec.lua
@@ -1,8 +1,8 @@
-- Tests for 'undolevel' setting being global-local
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
-local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+local source = helpers.source
+local clear, expect = helpers.clear, helpers.expect
describe('undolevel', function()
setup(clear)
diff --git a/test/functional/legacy/101_hlsearch_spec.lua b/test/functional/legacy/101_hlsearch_spec.lua
index 4b8b1cef50..335d275c2a 100644
--- a/test/functional/legacy/101_hlsearch_spec.lua
+++ b/test/functional/legacy/101_hlsearch_spec.lua
@@ -1,9 +1,8 @@
-- Test for v:hlsearch
local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local clear, feed = helpers.clear, helpers.feed
local execute, expect = helpers.execute, helpers.expect
-local eval = helpers.eval
describe('v:hlsearch', function()
setup(clear)
diff --git a/test/functional/legacy/102_fnameescape_spec.lua b/test/functional/legacy/102_fnameescape_spec.lua
index 251ce68430..a3b0313d7a 100644
--- a/test/functional/legacy/102_fnameescape_spec.lua
+++ b/test/functional/legacy/102_fnameescape_spec.lua
@@ -1,7 +1,7 @@
-- Test if fnameescape is correct for special chars like!
local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local clear = helpers.clear
local execute, expect = helpers.execute, helpers.expect
describe('fnameescape', function()
diff --git a/test/functional/legacy/103_visual_mode_reset_spec.lua b/test/functional/legacy/103_visual_mode_reset_spec.lua
index 6b2f3bc1b6..c1407ef10a 100644
--- a/test/functional/legacy/103_visual_mode_reset_spec.lua
+++ b/test/functional/legacy/103_visual_mode_reset_spec.lua
@@ -1,8 +1,8 @@
-- Test for visual mode not being reset causing E315 error.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
-local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+local feed, source = helpers.feed, helpers.source
+local clear, expect = helpers.clear, helpers.expect
describe('E315 error', function()
setup(clear)
diff --git a/test/functional/legacy/105_filename_modifiers_spec.lua b/test/functional/legacy/105_filename_modifiers_spec.lua
index 3b417a88eb..3413667022 100644
--- a/test/functional/legacy/105_filename_modifiers_spec.lua
+++ b/test/functional/legacy/105_filename_modifiers_spec.lua
@@ -1,7 +1,7 @@
-- Test filename modifiers.
local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local clear = helpers.clear
local execute, expect = helpers.execute, helpers.expect
describe('filename modifiers', function()
diff --git a/test/functional/legacy/106_errorformat_spec.lua b/test/functional/legacy/106_errorformat_spec.lua
index 5b6037f928..5958f1aa7b 100644
--- a/test/functional/legacy/106_errorformat_spec.lua
+++ b/test/functional/legacy/106_errorformat_spec.lua
@@ -1,7 +1,7 @@
-- Tests for errorformat.
local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local clear = helpers.clear
local execute, expect = helpers.execute, helpers.expect
describe('errorformat', function()
diff --git a/test/functional/legacy/107_adjust_window_and_contents_spec.lua b/test/functional/legacy/107_adjust_window_and_contents_spec.lua
index f6ea7e5a6c..7a6de3d748 100644
--- a/test/functional/legacy/107_adjust_window_and_contents_spec.lua
+++ b/test/functional/legacy/107_adjust_window_and_contents_spec.lua
@@ -2,8 +2,8 @@
local helpers = require('test.functional.helpers')
local Screen = require('test.functional.ui.screen')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
-local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+local insert = helpers.insert
+local clear, execute = helpers.clear, helpers.execute
describe('107', function()
setup(clear)
diff --git a/test/functional/legacy/autocmd_option_spec.lua b/test/functional/legacy/autocmd_option_spec.lua
new file mode 100644
index 0000000000..855e9c6271
--- /dev/null
+++ b/test/functional/legacy/autocmd_option_spec.lua
@@ -0,0 +1,277 @@
+local helpers = require('test.functional.helpers')
+local nvim = helpers.meths
+local clear, eq, neq = helpers.clear, helpers.eq, helpers.neq
+local curbuf, buf = helpers.curbuf, helpers.bufmeths
+local source, execute = helpers.source, helpers.execute
+
+local function declare_hook_function()
+ source([[
+ fu! AutoCommand(match, bufnr, winnr)
+ let l:acc = {
+ \ 'option' : a:match,
+ \ 'oldval' : v:option_old,
+ \ 'newval' : v:option_new,
+ \ 'scope' : v:option_type,
+ \ 'attr' : {
+ \ 'bufnr' : a:bufnr,
+ \ 'winnr' : a:winnr,
+ \ }
+ \ }
+ call add(g:ret, l:acc)
+ endfu
+ ]])
+end
+
+local function set_hook(pattern)
+ execute(
+ 'au OptionSet '
+ .. pattern ..
+ ' :call AutoCommand(expand("<amatch>"), bufnr("%"), winnr())'
+ )
+end
+
+local function init_var()
+ execute('let g:ret = []')
+end
+
+local function get_result()
+ local ret = nvim.get_var('ret')
+ init_var()
+ return ret
+end
+
+local function expected_table(option, oldval, newval, scope, attr)
+ return {
+ option = option,
+ oldval = tostring(oldval),
+ newval = tostring(newval),
+ scope = scope,
+ attr = attr,
+ }
+end
+
+local function expected_combination(...)
+ local args = {...}
+ local ret = get_result()
+
+ if not (#args == #ret) then
+ local expecteds = {}
+ for _, v in pairs(args) do
+ table.insert(expecteds, expected_table(unpack(v)))
+ end
+ eq(expecteds, ret)
+ return
+ end
+
+ for i, v in ipairs(args) do
+ local attr = v[5]
+ if not attr then
+ -- remove attr entries
+ ret[i].attr = nil
+ else
+ -- remove attr entries which are not required
+ for k in pairs(ret[i].attr) do
+ if not attr[k] then
+ ret[i].attr[k] = nil
+ end
+ end
+ end
+ eq(expected_table(unpack(v)), ret[i])
+ end
+end
+
+local function expected_empty()
+ eq({}, get_result())
+end
+
+local function make_buffer()
+ local old_buf = curbuf()
+ execute('new')
+ local new_buf = curbuf()
+ execute('wincmd p') -- move previous window
+
+ neq(old_buf, new_buf)
+ eq(old_buf, curbuf())
+
+ return new_buf
+end
+
+describe('au OptionSet', function()
+ describe('with any opton (*)', function()
+
+ before_each(function()
+ clear()
+ declare_hook_function()
+ init_var()
+ set_hook('*')
+ end)
+
+ it('should be called in setting number option', function()
+ execute('set nu')
+ expected_combination({'number', 0, 1, 'global'})
+
+ execute('setlocal nonu')
+ expected_combination({'number', 1, 0, 'local'})
+
+ execute('setglobal nonu')
+ expected_combination({'number', 1, 0, 'global'})
+ end)
+
+ it('should be called in setting autoindent option',function()
+ execute('setlocal ai')
+ expected_combination({'autoindent', 0, 1, 'local'})
+
+ execute('setglobal ai')
+ expected_combination({'autoindent', 0, 1, 'global'})
+
+ execute('set noai')
+ expected_combination({'autoindent', 1, 0, 'global'})
+ end)
+
+ it('should be called in inverting global autoindent option',function()
+ execute('set ai!')
+ expected_combination({'autoindent', 0, 1, 'global'})
+ end)
+
+ it('should be called in being unset local autoindent option',function()
+ execute('setlocal ai')
+ expected_combination({'autoindent', 0, 1, 'local'})
+
+ execute('setlocal ai<')
+ expected_combination({'autoindent', 1, 0, 'local'})
+ end)
+
+ it('should be called in setting global list and number option at the same time',function()
+ execute('set list nu')
+ expected_combination(
+ {'list', 0, 1, 'global'},
+ {'number', 0, 1, 'global'}
+ )
+ end)
+
+ it('should not print anything, use :noa', function()
+ execute('noa set nolist nonu')
+ expected_empty()
+ end)
+
+ it('should be called in setting local acd', function()
+ execute('setlocal acd')
+ expected_combination({'autochdir', 0, 1, 'local'})
+ end)
+
+ it('should be called in setting autoread', function()
+ execute('set noar')
+ expected_combination({'autoread', 1, 0, 'global'})
+
+ execute('setlocal ar')
+ expected_combination({'autoread', 0, 1, 'local'})
+ end)
+
+ it('should be called in inverting global autoread', function()
+ execute('setglobal invar')
+ expected_combination({'autoread', 1, 0, 'global'})
+ end)
+
+ it('should be called in setting backspace option through :let', function()
+ execute('let &bs=""')
+ expected_combination({'backspace', 'indent,eol,start', '', 'global'})
+ end)
+
+ describe('being set by setbufvar()', function()
+ it('should not trigger because option name is invalid', function()
+ execute('call setbufvar(1, "&l:bk", 1)')
+ expected_empty()
+ end)
+
+ it('should trigger using correct option name', function()
+ execute('call setbufvar(1, "&backup", 1)')
+ expected_combination({'backup', 0, 1, 'local'})
+ end)
+
+ it('should trigger if the current buffer is different from the targetted buffer', function()
+ local new_buffer = make_buffer()
+ local new_bufnr = buf.get_number(new_buffer)
+
+ execute('call setbufvar(' .. new_bufnr .. ', "&buftype", "nofile")')
+ expected_combination({'buftype', '', 'nofile', 'local', {bufnr = new_bufnr}})
+ end)
+ end)
+ end)
+
+ describe('with specific option', function()
+
+ before_each(function()
+ clear()
+ declare_hook_function()
+ init_var()
+ end)
+
+ it('should be called iff setting readonly', function()
+ set_hook('readonly')
+
+ execute('set nu')
+ expected_empty()
+
+ execute('setlocal ro')
+ expected_combination({'readonly', 0, 1, 'local'})
+
+ execute('setglobal ro')
+ expected_combination({'readonly', 0, 1, 'global'})
+
+ execute('set noro')
+ expected_combination({'readonly', 1, 0, 'global'})
+ end)
+
+ describe('being set by setbufvar()', function()
+ it('should not trigger because option name does not match with backup', function()
+ set_hook('backup')
+
+ execute('call setbufvar(1, "&l:bk", 1)')
+ expected_empty()
+ end)
+
+ it('should trigger, use correct option name backup', function()
+ set_hook('backup')
+
+ execute('call setbufvar(1, "&backup", 1)')
+ expected_combination({'backup', 0, 1, 'local'})
+ end)
+
+ it('should trigger if the current buffer is different from the targetted buffer', function()
+ set_hook('buftype')
+
+ local new_buffer = make_buffer()
+ local new_bufnr = buf.get_number(new_buffer)
+
+ execute('call setbufvar(' .. new_bufnr .. ', "&buftype", "nofile")')
+ expected_combination({'buftype', '', 'nofile', 'local', {bufnr = new_bufnr}})
+ end)
+ end)
+
+ describe('being set by neovim api', function()
+ it('should trigger if a boolean option be set globally', function()
+ set_hook('autochdir')
+
+ nvim.set_option('autochdir', true)
+ eq(true, nvim.get_option('autochdir'))
+ expected_combination({'autochdir', '0', '1', 'global'})
+ end)
+
+ it('should trigger if a number option be set globally', function()
+ set_hook('cmdheight')
+
+ nvim.set_option('cmdheight', 5)
+ eq(5, nvim.get_option('cmdheight'))
+ expected_combination({'cmdheight', 1, 5, 'global'})
+ end)
+
+ it('should trigger if a string option be set globally', function()
+ set_hook('ambiwidth')
+
+ nvim.set_option('ambiwidth', 'double')
+ eq('double', nvim.get_option('ambiwidth'))
+ expected_combination({'ambiwidth', 'single', 'double', 'global'})
+ end)
+ end)
+ end)
+end)
diff --git a/test/functional/legacy/fixeol_spec.lua b/test/functional/legacy/fixeol_spec.lua
new file mode 100644
index 0000000000..578178d707
--- /dev/null
+++ b/test/functional/legacy/fixeol_spec.lua
@@ -0,0 +1,72 @@
+-- Tests for 'fixeol'
+
+local helpers = require('test.functional.helpers')
+local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+
+describe('fixeol', function()
+ local function rmtestfiles()
+ os.remove('test.out')
+ os.remove('XXEol')
+ os.remove('XXNoEol')
+ os.remove('XXTestEol')
+ os.remove('XXTestNoEol')
+ end
+ setup(function()
+ clear()
+ rmtestfiles()
+ end)
+ teardown(function()
+ rmtestfiles()
+ end)
+
+ it('is working', function()
+ -- First write two test files – with and without trailing EOL.
+ -- Use Unix fileformat for consistency.
+ execute('set ff=unix')
+ execute('enew!')
+ feed('awith eol<esc>:w! XXEol<cr>')
+ execute('enew!')
+ execute('set noeol nofixeol')
+ feed('awithout eol<esc>:w! XXNoEol<cr>')
+ execute('set eol fixeol')
+ execute('bwipe XXEol XXNoEol')
+
+ -- Try editing files with 'fixeol' disabled.
+ execute('e! XXEol')
+ feed('ostays eol<esc>:set nofixeol<cr>')
+ execute('w! XXTestEol')
+ execute('e! XXNoEol')
+ feed('ostays without<esc>:set nofixeol<cr>')
+ execute('w! XXTestNoEol')
+ execute('bwipe XXEol XXNoEol XXTestEol XXTestNoEol')
+ execute('set fixeol')
+
+ -- Append "END" to each file so that we can see what the last written char was.
+ feed('ggdGaEND<esc>:w >>XXEol<cr>')
+ execute('w >>XXNoEol')
+ execute('w >>XXTestEol')
+ execute('w >>XXTestNoEol')
+
+ -- Concatenate the results.
+ execute('e! test.out')
+ feed('a0<esc>:$r XXEol<cr>')
+ execute('$r XXNoEol')
+ feed('Go1<esc>:$r XXTestEol<cr>')
+ execute('$r XXTestNoEol')
+ execute('w')
+
+ -- Assert buffer contents.
+ expect([=[
+ 0
+ with eol
+ END
+ without eolEND
+ 1
+ with eol
+ stays eol
+ END
+ without eol
+ stays withoutEND]=])
+ end)
+end)
diff --git a/test/functional/legacy/listlbr_utf8_spec.lua b/test/functional/legacy/listlbr_utf8_spec.lua
index 15d12ac4af..69e7b87a21 100644
--- a/test/functional/legacy/listlbr_utf8_spec.lua
+++ b/test/functional/legacy/listlbr_utf8_spec.lua
@@ -1,8 +1,8 @@
-- Test for linebreak and list option in utf-8 mode
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
-local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+local source = helpers.source
+local clear, expect = helpers.clear, helpers.expect
describe('linebreak', function()
setup(clear)
diff --git a/test/functional/legacy/mapping_spec.lua b/test/functional/legacy/mapping_spec.lua
index 899f7423d0..4d377904f9 100644
--- a/test/functional/legacy/mapping_spec.lua
+++ b/test/functional/legacy/mapping_spec.lua
@@ -5,7 +5,7 @@ local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
describe('mapping', function()
- setup(clear)
+ before_each(clear)
it('is working', function()
insert([[
@@ -44,4 +44,30 @@ describe('mapping', function()
+
+]])
end)
+
+ it('i_CTRL-G_U', function()
+ -- <c-g>U<cursor> works only within a single line
+ execute('imapclear')
+ execute('imap ( ()<c-g>U<left>')
+ feed('G2o<esc>ki<cr>Test1: text with a (here some more text<esc>k.')
+ -- test undo
+ feed('G2o<esc>ki<cr>Test2: text wit a (here some more text [und undo]<c-g>u<esc>k.u')
+ execute('imapclear')
+ execute('set whichwrap=<,>,[,]')
+ feed('G3o<esc>2k')
+ execute([[:exe ":norm! iTest3: text with a (parenthesis here\<C-G>U\<Right>new line here\<esc>\<up>\<up>."]])
+
+ expect([[
+
+
+ Test1: text with a (here some more text)
+ Test1: text with a (here some more text)
+
+
+ Test2: text wit a (here some more text [und undo])
+ new line here
+ Test3: text with a (parenthesis here
+ new line here
+ ]])
+ end)
end)
diff --git a/test/functional/legacy/nested_function_spec.lua b/test/functional/legacy/nested_function_spec.lua
index 87371c8294..fac3b03191 100644
--- a/test/functional/legacy/nested_function_spec.lua
+++ b/test/functional/legacy/nested_function_spec.lua
@@ -1,7 +1,7 @@
-- Tests for nested function.
local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local clear, insert = helpers.clear, helpers.insert
local execute, expect, source = helpers.execute, helpers.expect, helpers.source
describe('test_nested_function', function()
diff --git a/test/functional/legacy/qf_title_spec.lua b/test/functional/legacy/qf_title_spec.lua
index aa005117be..01c781cc05 100644
--- a/test/functional/legacy/qf_title_spec.lua
+++ b/test/functional/legacy/qf_title_spec.lua
@@ -1,8 +1,8 @@
-- Tests for quickfix window's title
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
-local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+local insert, source = helpers.insert, helpers.source
+local clear, expect = helpers.clear, helpers.expect
describe('qf_title', function()
setup(clear)
diff --git a/test/functional/legacy/signs_spec.lua b/test/functional/legacy/signs_spec.lua
index 89b2bf3b73..5a834c39e3 100644
--- a/test/functional/legacy/signs_spec.lua
+++ b/test/functional/legacy/signs_spec.lua
@@ -1,7 +1,6 @@
-- Tests for signs
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
describe('signs', function()
diff --git a/test/functional/legacy/writefile_spec.lua b/test/functional/legacy/writefile_spec.lua
index e7a260bcd9..efdfc1d09f 100644
--- a/test/functional/legacy/writefile_spec.lua
+++ b/test/functional/legacy/writefile_spec.lua
@@ -1,7 +1,6 @@
-- Tests for writefile()
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
describe('writefile', function()
diff --git a/test/functional/normal/K_spec.lua b/test/functional/normal/K_spec.lua
index dbda6dcb93..df6b429f50 100644
--- a/test/functional/normal/K_spec.lua
+++ b/test/functional/normal/K_spec.lua
@@ -1,7 +1,6 @@
local helpers = require('test.functional.helpers')
-local execute, eq, clear, eval, feed, ok =
- helpers.execute, helpers.eq, helpers.clear, helpers.eval,
- helpers.feed, helpers.ok
+local eq, clear, eval, feed =
+ helpers.eq, helpers.clear, helpers.eval, helpers.feed
describe('K', function()
local test_file = 'K_spec_out'
diff --git a/test/functional/plugin/helpers.lua b/test/functional/plugin/helpers.lua
new file mode 100644
index 0000000000..cc76794267
--- /dev/null
+++ b/test/functional/plugin/helpers.lua
@@ -0,0 +1,41 @@
+local paths = require('test.config.paths')
+
+local helpers = require('test.functional.helpers')
+local spawn, set_session, nvim_prog, merge_args =
+ helpers.spawn, helpers.set_session, helpers.nvim_prog, helpers.merge_args
+
+local additional_cmd = ''
+
+local function nvim_argv(shada_file)
+ local rtp_value = ('\'%s/runtime\''):format(
+ paths.test_source_path:gsub('\'', '\'\''))
+ local nvim_args = {nvim_prog, '-u', 'NORC', '-i', shada_file or 'NONE', '-N',
+ '--cmd', 'set shortmess+=I background=light noswapfile',
+ '--cmd', 'let &runtimepath=' .. rtp_value,
+ '--cmd', additional_cmd,
+ '--embed'}
+ if helpers.prepend_argv then
+ return merge_args(helpers.prepend_argv, nvim_args)
+ else
+ return nvim_args
+ end
+end
+
+local session = nil
+
+local reset = function(...)
+ if session then
+ session:exit(0)
+ end
+ session = spawn(nvim_argv(...))
+ set_session(session)
+end
+
+local set_additional_cmd = function(s)
+ additional_cmd = s
+end
+
+return {
+ reset=reset,
+ set_additional_cmd=set_additional_cmd,
+}
diff --git a/test/functional/plugin/msgpack_spec.lua b/test/functional/plugin/msgpack_spec.lua
new file mode 100644
index 0000000000..18ff0f5156
--- /dev/null
+++ b/test/functional/plugin/msgpack_spec.lua
@@ -0,0 +1,699 @@
+local helpers = require('test.functional.helpers')
+local eq, nvim_eval, nvim_command, exc_exec =
+ helpers.eq, helpers.eval, helpers.command, helpers.exc_exec
+
+local plugin_helpers = require('test.functional.plugin.helpers')
+local reset = plugin_helpers.reset
+
+describe('In autoload/msgpack.vim', function()
+ before_each(reset)
+
+ local sp = function(typ, val)
+ return ('{"_TYPE": v:msgpack_types.%s, "_VAL": %s}'):format(typ, val)
+ end
+ local mapsp = function(...)
+ local val = ''
+ for i=1,(select('#', ...)/2) do
+ val = ('%s[%s,%s],'):format(val, select(i * 2 - 1, ...),
+ select(i * 2, ...))
+ end
+ return sp('map', '[' .. val .. ']')
+ end
+
+ local nan = -(1.0/0.0-1.0/0.0)
+ local minus_nan = 1.0/0.0-1.0/0.0
+ local inf = 1.0/0.0
+ local minus_inf = -(1.0/0.0)
+ local has_minus_nan = tostring(nan) ~= tostring(minus_nan)
+
+ describe('function msgpack#equal', function()
+ local msgpack_eq = function(expected, a, b)
+ eq(expected, nvim_eval(('msgpack#equal(%s, %s)'):format(a, b)))
+ if a ~= b then
+ eq(expected, nvim_eval(('msgpack#equal(%s, %s)'):format(b, a)))
+ end
+ end
+ it('compares raw integers correctly', function()
+ msgpack_eq(1, '1', '1')
+ msgpack_eq(0, '1', '0')
+ end)
+ it('compares integer specials correctly', function()
+ msgpack_eq(1, sp('integer', '[-1, 1, 0, 0]'),
+ sp('integer', '[-1, 1, 0, 0]'))
+ msgpack_eq(0, sp('integer', '[-1, 1, 0, 0]'),
+ sp('integer', '[ 1, 1, 0, 0]'))
+ end)
+ it('compares integer specials with raw integer correctly', function()
+ msgpack_eq(1, sp('integer', '[-1, 0, 0, 1]'), '-1')
+ msgpack_eq(0, sp('integer', '[-1, 0, 0, 1]'), '1')
+ msgpack_eq(0, sp('integer', '[ 1, 0, 0, 1]'), '-1')
+ msgpack_eq(1, sp('integer', '[ 1, 0, 0, 1]'), '1')
+ end)
+ it('compares integer with float correctly', function()
+ msgpack_eq(0, '0', '0.0')
+ end)
+ it('compares raw binaries correctly', function()
+ msgpack_eq(1, '"abc\\ndef"', '"abc\\ndef"')
+ msgpack_eq(0, '"abc\\ndef"', '"abc\\nghi"')
+ end)
+ it('compares binary specials correctly', function()
+ msgpack_eq(1, sp('binary', '["abc\\n", "def"]'),
+ sp('binary', '["abc\\n", "def"]'))
+ msgpack_eq(0, sp('binary', '["abc", "def"]'),
+ sp('binary', '["abc\\n", "def"]'))
+ end)
+ it('compares binary specials with raw binaries correctly', function()
+ msgpack_eq(1, sp('binary', '["abc", "def"]'), '"abc\\ndef"')
+ msgpack_eq(0, sp('binary', '["abc", "def"]'), '"abcdef"')
+ end)
+ it('compares string specials correctly', function()
+ msgpack_eq(1, sp('string', '["abc\\n", "def"]'),
+ sp('string', '["abc\\n", "def"]'))
+ msgpack_eq(0, sp('string', '["abc", "def"]'),
+ sp('string', '["abc\\n", "def"]'))
+ end)
+ it('compares string specials with binary correctly', function()
+ msgpack_eq(0, sp('string', '["abc\\n", "def"]'),
+ sp('binary', '["abc\\n", "def"]'))
+ msgpack_eq(0, sp('string', '["abc", "def"]'), '"abc\\ndef"')
+ msgpack_eq(0, sp('binary', '["abc\\n", "def"]'),
+ sp('string', '["abc\\n", "def"]'))
+ msgpack_eq(0, '"abc\\ndef"', sp('string', '["abc", "def"]'))
+ end)
+ it('compares ext specials correctly', function()
+ msgpack_eq(1, sp('ext', '[1, ["", "ac"]]'), sp('ext', '[1, ["", "ac"]]'))
+ msgpack_eq(0, sp('ext', '[2, ["", "ac"]]'), sp('ext', '[1, ["", "ac"]]'))
+ msgpack_eq(0, sp('ext', '[1, ["", "ac"]]'), sp('ext', '[1, ["", "abc"]]'))
+ end)
+ it('compares raw maps correctly', function()
+ msgpack_eq(1, '{"a": 1, "b": 2}', '{"b": 2, "a": 1}')
+ msgpack_eq(1, '{}', '{}')
+ msgpack_eq(0, '{}', '{"a": 1}')
+ msgpack_eq(0, '{"a": 2}', '{"a": 1}')
+ msgpack_eq(0, '{"a": 1}', '{"b": 1}')
+ msgpack_eq(0, '{"a": 1}', '{"a": 1, "b": 1}')
+ msgpack_eq(0, '{"a": 1, "b": 1}', '{"b": 1}')
+ end)
+ it('compares map specials correctly', function()
+ msgpack_eq(1, mapsp(), mapsp())
+ msgpack_eq(1, mapsp(sp('binary', '[""]'), '""'),
+ mapsp(sp('binary', '[""]'), '""'))
+ msgpack_eq(1, mapsp(mapsp('1', '1'), mapsp('1', '1')),
+ mapsp(mapsp('1', '1'), mapsp('1', '1')))
+ msgpack_eq(0, mapsp(), mapsp('1', '1'))
+ msgpack_eq(0, mapsp(sp('binary', '["a"]'), '""'),
+ mapsp(sp('binary', '[""]'), '""'))
+ msgpack_eq(0, mapsp(sp('binary', '[""]'), '"a"'),
+ mapsp(sp('binary', '[""]'), '""'))
+ msgpack_eq(0, mapsp(sp('binary', '["a"]'), '"a"'),
+ mapsp(sp('binary', '[""]'), '""'))
+ msgpack_eq(0, mapsp(mapsp('1', '1'), mapsp('1', '1')),
+ mapsp(sp('binary', '[""]'), mapsp('1', '1')))
+ msgpack_eq(0, mapsp(mapsp('1', '1'), mapsp('1', '1')),
+ mapsp(mapsp('2', '1'), mapsp('1', '1')))
+ msgpack_eq(0, mapsp(mapsp('1', '1'), mapsp('1', '1')),
+ mapsp(mapsp('1', '2'), mapsp('1', '1')))
+ msgpack_eq(0, mapsp(mapsp('1', '1'), mapsp('1', '1')),
+ mapsp(mapsp('1', '1'), mapsp('2', '1')))
+ msgpack_eq(0, mapsp(mapsp('1', '1'), mapsp('1', '1')),
+ mapsp(mapsp('1', '1'), mapsp('1', '2')))
+ msgpack_eq(1, mapsp(mapsp('2', '1'), mapsp('1', '1'),
+ mapsp('1', '1'), mapsp('1', '1')),
+ mapsp(mapsp('1', '1'), mapsp('1', '1'),
+ mapsp('2', '1'), mapsp('1', '1')))
+ end)
+ it('compares map specials with raw maps correctly', function()
+ msgpack_eq(1, mapsp(), '{}')
+ msgpack_eq(1, mapsp(sp('string', '["1"]'), '1'), '{"1": 1}')
+ msgpack_eq(1, mapsp(sp('string', '["1"]'), sp('integer', '[1, 0, 0, 1]')),
+ '{"1": 1}')
+ msgpack_eq(0, mapsp(sp('integer', '[1, 0, 0, 1]'), sp('string', '["1"]')),
+ '{1: "1"}')
+ msgpack_eq(0, mapsp('"1"', sp('integer', '[1, 0, 0, 1]')),
+ '{"1": 1}')
+ msgpack_eq(0,
+ mapsp(sp('string', '["1"]'), '1', sp('string', '["2"]'), '2'),
+ '{"1": 1}')
+ msgpack_eq(0, mapsp(sp('string', '["1"]'), '1'), '{"1": 1, "2": 2}')
+ end)
+ it('compares raw arrays correctly', function()
+ msgpack_eq(1, '[]', '[]')
+ msgpack_eq(0, '[]', '[1]')
+ msgpack_eq(1, '[1]', '[1]')
+ msgpack_eq(1, '[[[1]]]', '[[[1]]]')
+ msgpack_eq(0, '[[[2]]]', '[[[1]]]')
+ end)
+ it('compares array specials correctly', function()
+ msgpack_eq(1, sp('array', '[]'), sp('array', '[]'))
+ msgpack_eq(0, sp('array', '[]'), sp('array', '[1]'))
+ msgpack_eq(1, sp('array', '[1]'), sp('array', '[1]'))
+ msgpack_eq(1, sp('array', '[[[1]]]'), sp('array', '[[[1]]]'))
+ msgpack_eq(0, sp('array', '[[[1]]]'), sp('array', '[[[2]]]'))
+ end)
+ it('compares array specials with raw arrays correctly', function()
+ msgpack_eq(1, sp('array', '[]'), '[]')
+ msgpack_eq(0, sp('array', '[]'), '[1]')
+ msgpack_eq(1, sp('array', '[1]'), '[1]')
+ msgpack_eq(1, sp('array', '[[[1]]]'), '[[[1]]]')
+ msgpack_eq(0, sp('array', '[[[1]]]'), '[[[2]]]')
+ end)
+ it('compares raw floats correctly', function()
+ msgpack_eq(1, '0.0', '0.0')
+ msgpack_eq(1, '(1.0/0.0-1.0/0.0)', '(1.0/0.0-1.0/0.0)')
+ if has_minus_nan then
+ msgpack_eq(0, '(1.0/0.0-1.0/0.0)', '-(1.0/0.0-1.0/0.0)')
+ end
+ msgpack_eq(1, '-(1.0/0.0-1.0/0.0)', '-(1.0/0.0-1.0/0.0)')
+ msgpack_eq(1, '1.0/0.0', '1.0/0.0')
+ msgpack_eq(1, '-(1.0/0.0)', '-(1.0/0.0)')
+ msgpack_eq(1, '0.0', '0.0')
+ msgpack_eq(0, '0.0', '1.0')
+ msgpack_eq(0, '0.0', '(1.0/0.0-1.0/0.0)')
+ msgpack_eq(0, '0.0', '1.0/0.0')
+ msgpack_eq(0, '0.0', '-(1.0/0.0)')
+ msgpack_eq(0, '1.0/0.0', '-(1.0/0.0)')
+ msgpack_eq(0, '(1.0/0.0-1.0/0.0)', '-(1.0/0.0)')
+ msgpack_eq(0, '(1.0/0.0-1.0/0.0)', '1.0/0.0')
+ end)
+ it('compares float specials with raw floats correctly', function()
+ msgpack_eq(1, sp('float', '0.0'), '0.0')
+ msgpack_eq(1, sp('float', '(1.0/0.0-1.0/0.0)'), '(1.0/0.0-1.0/0.0)')
+ if has_minus_nan then
+ msgpack_eq(0, sp('float', '(1.0/0.0-1.0/0.0)'), '-(1.0/0.0-1.0/0.0)')
+ msgpack_eq(0, sp('float', '-(1.0/0.0-1.0/0.0)'), '(1.0/0.0-1.0/0.0)')
+ end
+ msgpack_eq(1, sp('float', '-(1.0/0.0-1.0/0.0)'), '-(1.0/0.0-1.0/0.0)')
+ msgpack_eq(1, sp('float', '1.0/0.0'), '1.0/0.0')
+ msgpack_eq(1, sp('float', '-(1.0/0.0)'), '-(1.0/0.0)')
+ msgpack_eq(1, sp('float', '0.0'), '0.0')
+ msgpack_eq(0, sp('float', '0.0'), '1.0')
+ msgpack_eq(0, sp('float', '0.0'), '(1.0/0.0-1.0/0.0)')
+ msgpack_eq(0, sp('float', '0.0'), '1.0/0.0')
+ msgpack_eq(0, sp('float', '0.0'), '-(1.0/0.0)')
+ msgpack_eq(0, sp('float', '1.0/0.0'), '-(1.0/0.0)')
+ msgpack_eq(0, sp('float', '(1.0/0.0-1.0/0.0)'), '-(1.0/0.0)')
+ msgpack_eq(0, sp('float', '(1.0/0.0-1.0/0.0)'), '1.0/0.0')
+ end)
+ it('compares float specials correctly', function()
+ msgpack_eq(1, sp('float', '0.0'), sp('float', '0.0'))
+ msgpack_eq(1, sp('float', '(1.0/0.0-1.0/0.0)'),
+ sp('float', '(1.0/0.0-1.0/0.0)'))
+ msgpack_eq(1, sp('float', '1.0/0.0'), sp('float', '1.0/0.0'))
+ msgpack_eq(1, sp('float', '-(1.0/0.0)'), sp('float', '-(1.0/0.0)'))
+ msgpack_eq(1, sp('float', '0.0'), sp('float', '0.0'))
+ msgpack_eq(0, sp('float', '0.0'), sp('float', '1.0'))
+ msgpack_eq(0, sp('float', '0.0'), sp('float', '(1.0/0.0-1.0/0.0)'))
+ msgpack_eq(0, sp('float', '0.0'), sp('float', '1.0/0.0'))
+ msgpack_eq(0, sp('float', '0.0'), sp('float', '-(1.0/0.0)'))
+ msgpack_eq(0, sp('float', '1.0/0.0'), sp('float', '-(1.0/0.0)'))
+ msgpack_eq(0, sp('float', '(1.0/0.0-1.0/0.0)'), sp('float', '-(1.0/0.0)'))
+ if has_minus_nan then
+ msgpack_eq(0, sp('float', '(1.0/0.0-1.0/0.0)'),
+ sp('float', '-(1.0/0.0-1.0/0.0)'))
+ end
+ msgpack_eq(1, sp('float', '-(1.0/0.0-1.0/0.0)'),
+ sp('float', '-(1.0/0.0-1.0/0.0)'))
+ msgpack_eq(0, sp('float', '(1.0/0.0-1.0/0.0)'), sp('float', '1.0/0.0'))
+ end)
+ it('compares boolean specials correctly', function()
+ msgpack_eq(1, sp('boolean', '1'), sp('boolean', '1'))
+ msgpack_eq(0, sp('boolean', '1'), sp('boolean', '0'))
+ end)
+ it('compares nil specials correctly', function()
+ msgpack_eq(1, sp('nil', '1'), sp('nil', '0'))
+ end)
+ it('compares nil, boolean and integer values with each other correctly',
+ function()
+ msgpack_eq(0, sp('boolean', '1'), '1')
+ msgpack_eq(0, sp('boolean', '1'), sp('nil', '0'))
+ msgpack_eq(0, sp('boolean', '1'), sp('nil', '1'))
+ msgpack_eq(0, sp('boolean', '0'), sp('nil', '0'))
+ msgpack_eq(0, sp('boolean', '0'), '0')
+ msgpack_eq(0, sp('boolean', '0'), sp('integer', '[1, 0, 0, 0]'))
+ msgpack_eq(0, sp('boolean', '0'), sp('integer', '[1, 0, 0, 1]'))
+ msgpack_eq(0, sp('boolean', '1'), sp('integer', '[1, 0, 0, 1]'))
+ msgpack_eq(0, sp('nil', '0'), sp('integer', '[1, 0, 0, 0]'))
+ msgpack_eq(0, sp('nil', '0'), '0')
+ end)
+ end)
+
+ describe('function msgpack#is_int', function()
+ it('works', function()
+ eq(1, nvim_eval('msgpack#is_int(1)'))
+ eq(1, nvim_eval('msgpack#is_int(-1)'))
+ eq(1, nvim_eval(('msgpack#is_int(%s)'):format(
+ sp('integer', '[1, 0, 0, 1]'))))
+ eq(1, nvim_eval(('msgpack#is_int(%s)'):format(
+ sp('integer', '[-1, 0, 0, 1]'))))
+ eq(0, nvim_eval(('msgpack#is_int(%s)'):format(
+ sp('float', '0.0'))))
+ eq(0, nvim_eval(('msgpack#is_int(%s)'):format(
+ sp('boolean', '0'))))
+ eq(0, nvim_eval(('msgpack#is_int(%s)'):format(
+ sp('nil', '0'))))
+ eq(0, nvim_eval('msgpack#is_int("")'))
+ end)
+ end)
+
+ describe('function msgpack#is_uint', function()
+ it('works', function()
+ eq(1, nvim_eval('msgpack#is_uint(1)'))
+ eq(0, nvim_eval('msgpack#is_uint(-1)'))
+ eq(1, nvim_eval(('msgpack#is_uint(%s)'):format(
+ sp('integer', '[1, 0, 0, 1]'))))
+ eq(0, nvim_eval(('msgpack#is_uint(%s)'):format(
+ sp('integer', '[-1, 0, 0, 1]'))))
+ eq(0, nvim_eval(('msgpack#is_uint(%s)'):format(
+ sp('float', '0.0'))))
+ eq(0, nvim_eval(('msgpack#is_uint(%s)'):format(
+ sp('boolean', '0'))))
+ eq(0, nvim_eval(('msgpack#is_uint(%s)'):format(
+ sp('nil', '0'))))
+ eq(0, nvim_eval('msgpack#is_uint("")'))
+ end)
+ end)
+
+ describe('function msgpack#strftime', function()
+ it('works', function()
+ local epoch = os.date('%Y-%m-%dT%H:%M:%S', 0)
+ eq(epoch, nvim_eval('msgpack#strftime("%Y-%m-%dT%H:%M:%S", 0)'))
+ eq(epoch, nvim_eval(
+ ('msgpack#strftime("%%Y-%%m-%%dT%%H:%%M:%%S", %s)'):format(sp(
+ 'integer', '[1, 0, 0, 0]'))))
+ end)
+ end)
+
+ describe('function msgpack#strptime', function()
+ it('works', function()
+ for _, v in ipairs({0, 10, 100000, 204, 1000000000}) do
+ local time = os.date('%Y-%m-%dT%H:%M:%S', v)
+ eq(v, nvim_eval('msgpack#strptime("%Y-%m-%dT%H:%M:%S", '
+ .. '"' .. time .. '")'))
+ end
+ end)
+ end)
+
+ describe('function msgpack#type', function()
+ local type_eq = function(expected, val)
+ eq(expected, nvim_eval(('msgpack#type(%s)'):format(val)))
+ end
+
+ it('works for special dictionaries', function()
+ type_eq('string', sp('string', '[""]'))
+ type_eq('binary', sp('binary', '[""]'))
+ type_eq('ext', sp('ext', '[1, [""]]'))
+ type_eq('array', sp('array', '[]'))
+ type_eq('map', sp('map', '[]'))
+ type_eq('integer', sp('integer', '[1, 0, 0, 0]'))
+ type_eq('float', sp('float', '0.0'))
+ type_eq('boolean', sp('boolean', '0'))
+ type_eq('nil', sp('nil', '0'))
+ end)
+
+ it('works for regular values', function()
+ type_eq('binary', '""')
+ type_eq('array', '[]')
+ type_eq('map', '{}')
+ type_eq('integer', '1')
+ type_eq('float', '0.0')
+ type_eq('float', '(1.0/0.0)')
+ type_eq('float', '-(1.0/0.0)')
+ type_eq('float', '(1.0/0.0-1.0/0.0)')
+ end)
+ end)
+
+ describe('function msgpack#special_type', function()
+ local sp_type_eq = function(expected, val)
+ eq(expected, nvim_eval(('msgpack#special_type(%s)'):format(val)))
+ end
+
+ it('works for special dictionaries', function()
+ sp_type_eq('string', sp('string', '[""]'))
+ sp_type_eq('binary', sp('binary', '[""]'))
+ sp_type_eq('ext', sp('ext', '[1, [""]]'))
+ sp_type_eq('array', sp('array', '[]'))
+ sp_type_eq('map', sp('map', '[]'))
+ sp_type_eq('integer', sp('integer', '[1, 0, 0, 0]'))
+ sp_type_eq('float', sp('float', '0.0'))
+ sp_type_eq('boolean', sp('boolean', '0'))
+ sp_type_eq('nil', sp('nil', '0'))
+ end)
+
+ it('works for regular values', function()
+ sp_type_eq(0, '""')
+ sp_type_eq(0, '[]')
+ sp_type_eq(0, '{}')
+ sp_type_eq(0, '1')
+ sp_type_eq(0, '0.0')
+ sp_type_eq(0, '(1.0/0.0)')
+ sp_type_eq(0, '-(1.0/0.0)')
+ sp_type_eq(0, '(1.0/0.0-1.0/0.0)')
+ end)
+ end)
+
+ describe('function msgpack#string', function()
+ local string_eq = function(expected, val)
+ eq(expected, nvim_eval(('msgpack#string(%s)'):format(val)))
+ end
+
+ it('works for special dictionaries', function()
+ string_eq('=""', sp('string', '[""]'))
+ string_eq('="\\n"', sp('string', '["", ""]'))
+ string_eq('="ab\\0c\\nde"', sp('string', '["ab\\nc", "de"]'))
+ string_eq('""', sp('binary', '[""]'))
+ string_eq('"\\n"', sp('binary', '["", ""]'))
+ string_eq('"ab\\0c\\nde"', sp('binary', '["ab\\nc", "de"]'))
+ string_eq('+(2)""', sp('ext', '[2, [""]]'))
+ string_eq('+(2)"\\n"', sp('ext', '[2, ["", ""]]'))
+ string_eq('+(2)"ab\\0c\\nde"', sp('ext', '[2, ["ab\\nc", "de"]]'))
+ string_eq('[]', sp('array', '[]'))
+ string_eq('[[[[{}]]]]', sp('array', '[[[[{}]]]]'))
+ string_eq('{}', sp('map', '[]'))
+ string_eq('{2: 10}', sp('map', '[[2, 10]]'))
+ string_eq('{{1: 1}: {1: 1}, {2: 1}: {1: 1}}',
+ mapsp(mapsp('2', '1'), mapsp('1', '1'),
+ mapsp('1', '1'), mapsp('1', '1')))
+ string_eq('{{1: 1}: {1: 1}, {2: 1}: {1: 1}}',
+ mapsp(mapsp('1', '1'), mapsp('1', '1'),
+ mapsp('2', '1'), mapsp('1', '1')))
+ string_eq('{[1, 2, {{1: 2}: 1}]: [1, 2, {{1: 2}: 1}]}',
+ mapsp(('[1, 2, %s]'):format(mapsp(mapsp('1', '2'), '1')),
+ ('[1, 2, %s]'):format(mapsp(mapsp('1', '2'), '1'))))
+ string_eq('0x0000000000000000', sp('integer', '[1, 0, 0, 0]'))
+ string_eq('-0x0000000100000000', sp('integer', '[-1, 0, 2, 0]'))
+ string_eq('0x123456789abcdef0',
+ sp('integer', '[ 1, 0, 610839793, 448585456]'))
+ string_eq('-0x123456789abcdef0',
+ sp('integer', '[-1, 0, 610839793, 448585456]'))
+ string_eq('0xf23456789abcdef0',
+ sp('integer', '[ 1, 3, 1684581617, 448585456]'))
+ string_eq('-0x723456789abcdef0',
+ sp('integer', '[-1, 1, 1684581617, 448585456]'))
+ string_eq('0.0', sp('float', '0.0'))
+ string_eq('inf', sp('float', '(1.0/0.0)'))
+ string_eq('-inf', sp('float', '-(1.0/0.0)'))
+ if has_minus_nan then
+ string_eq('-nan', sp('float', '(1.0/0.0-1.0/0.0)'))
+ end
+ string_eq('nan', sp('float', '-(1.0/0.0-1.0/0.0)'))
+ string_eq('FALSE', sp('boolean', '0'))
+ string_eq('TRUE', sp('boolean', '1'))
+ string_eq('NIL', sp('nil', '0'))
+ end)
+
+ it('works for regular values', function()
+ string_eq('""', '""')
+ string_eq('"\\n"', '"\\n"')
+ string_eq('[]', '[]')
+ string_eq('[[[{}]]]', '[[[{}]]]')
+ string_eq('{}', '{}')
+ string_eq('{="2": 10}', '{2: 10}')
+ string_eq('{="2": [{}]}', '{2: [{}]}')
+ string_eq('1', '1')
+ string_eq('0.0', '0.0')
+ string_eq('inf', '(1.0/0.0)')
+ string_eq('-inf', '-(1.0/0.0)')
+ if has_minus_nan then
+ string_eq('-nan', '(1.0/0.0-1.0/0.0)')
+ end
+ string_eq('nan', '-(1.0/0.0-1.0/0.0)')
+ end)
+ end)
+
+ describe('function msgpack#deepcopy', function()
+ it('works for special dictionaries', function()
+ nvim_command('let sparr = ' .. sp('array', '[[[]]]'))
+ nvim_command('let spmap = ' .. mapsp('"abc"', '[[]]'))
+ nvim_command('let spint = ' .. sp('integer', '[1, 0, 0, 0]'))
+ nvim_command('let spflt = ' .. sp('float', '1.0'))
+ nvim_command('let spext = ' .. sp('ext', '[2, ["abc", "def"]]'))
+ nvim_command('let spstr = ' .. sp('string', '["abc", "def"]'))
+ nvim_command('let spbin = ' .. sp('binary', '["abc", "def"]'))
+ nvim_command('let spbln = ' .. sp('boolean', '0'))
+ nvim_command('let spnil = ' .. sp('nil', '0'))
+
+ nvim_command('let sparr2 = msgpack#deepcopy(sparr)')
+ nvim_command('let spmap2 = msgpack#deepcopy(spmap)')
+ nvim_command('let spint2 = msgpack#deepcopy(spint)')
+ nvim_command('let spflt2 = msgpack#deepcopy(spflt)')
+ nvim_command('let spext2 = msgpack#deepcopy(spext)')
+ nvim_command('let spstr2 = msgpack#deepcopy(spstr)')
+ nvim_command('let spbin2 = msgpack#deepcopy(spbin)')
+ nvim_command('let spbln2 = msgpack#deepcopy(spbln)')
+ nvim_command('let spnil2 = msgpack#deepcopy(spnil)')
+
+ eq('array', nvim_eval('msgpack#type(sparr2)'))
+ eq('map', nvim_eval('msgpack#type(spmap2)'))
+ eq('integer', nvim_eval('msgpack#type(spint2)'))
+ eq('float', nvim_eval('msgpack#type(spflt2)'))
+ eq('ext', nvim_eval('msgpack#type(spext2)'))
+ eq('string', nvim_eval('msgpack#type(spstr2)'))
+ eq('binary', nvim_eval('msgpack#type(spbin2)'))
+ eq('boolean', nvim_eval('msgpack#type(spbln2)'))
+ eq('nil', nvim_eval('msgpack#type(spnil2)'))
+
+ nvim_command('call add(sparr._VAL, 0)')
+ nvim_command('call add(sparr._VAL[0], 0)')
+ nvim_command('call add(sparr._VAL[0][0], 0)')
+ nvim_command('call add(spmap._VAL, [0, 0])')
+ nvim_command('call add(spmap._VAL[0][1], 0)')
+ nvim_command('call add(spmap._VAL[0][1][0], 0)')
+ nvim_command('let spint._VAL[1] = 1')
+ nvim_command('let spflt._VAL = 0.0')
+ nvim_command('let spext._VAL[0] = 3')
+ nvim_command('let spext._VAL[1][0] = "gh"')
+ nvim_command('let spstr._VAL[0] = "gh"')
+ nvim_command('let spbin._VAL[0] = "gh"')
+ nvim_command('let spbln._VAL = 1')
+ nvim_command('let spnil._VAL = 1')
+
+ eq({_TYPE={}, _VAL={{{}}}}, nvim_eval('sparr2'))
+ eq({_TYPE={}, _VAL={{'abc', {{}}}}}, nvim_eval('spmap2'))
+ eq({_TYPE={}, _VAL={1, 0, 0, 0}}, nvim_eval('spint2'))
+ eq({_TYPE={}, _VAL=1.0}, nvim_eval('spflt2'))
+ eq({_TYPE={}, _VAL={2, {'abc', 'def'}}}, nvim_eval('spext2'))
+ eq({_TYPE={}, _VAL={'abc', 'def'}}, nvim_eval('spstr2'))
+ eq({_TYPE={}, _VAL={'abc', 'def'}}, nvim_eval('spbin2'))
+ eq({_TYPE={}, _VAL=0}, nvim_eval('spbln2'))
+ eq({_TYPE={}, _VAL=0}, nvim_eval('spnil2'))
+
+ nvim_command('let sparr._TYPE = []')
+ nvim_command('let spmap._TYPE = []')
+ nvim_command('let spint._TYPE = []')
+ nvim_command('let spflt._TYPE = []')
+ nvim_command('let spext._TYPE = []')
+ nvim_command('let spstr._TYPE = []')
+ nvim_command('let spbin._TYPE = []')
+ nvim_command('let spbln._TYPE = []')
+ nvim_command('let spnil._TYPE = []')
+
+ eq('array', nvim_eval('msgpack#special_type(sparr2)'))
+ eq('map', nvim_eval('msgpack#special_type(spmap2)'))
+ eq('integer', nvim_eval('msgpack#special_type(spint2)'))
+ eq('float', nvim_eval('msgpack#special_type(spflt2)'))
+ eq('ext', nvim_eval('msgpack#special_type(spext2)'))
+ eq('string', nvim_eval('msgpack#special_type(spstr2)'))
+ eq('binary', nvim_eval('msgpack#special_type(spbin2)'))
+ eq('boolean', nvim_eval('msgpack#special_type(spbln2)'))
+ eq('nil', nvim_eval('msgpack#special_type(spnil2)'))
+ end)
+
+ it('works for regular values', function()
+ nvim_command('let arr = [[[]]]')
+ nvim_command('let map = {1: {}}')
+ nvim_command('let int = 1')
+ nvim_command('let flt = 2.0')
+ nvim_command('let bin = "abc"')
+
+ nvim_command('let arr2 = msgpack#deepcopy(arr)')
+ nvim_command('let map2 = msgpack#deepcopy(map)')
+ nvim_command('let int2 = msgpack#deepcopy(int)')
+ nvim_command('let flt2 = msgpack#deepcopy(flt)')
+ nvim_command('let bin2 = msgpack#deepcopy(bin)')
+
+ eq('array', nvim_eval('msgpack#type(arr2)'))
+ eq('map', nvim_eval('msgpack#type(map2)'))
+ eq('integer', nvim_eval('msgpack#type(int2)'))
+ eq('float', nvim_eval('msgpack#type(flt2)'))
+ eq('binary', nvim_eval('msgpack#type(bin2)'))
+
+ nvim_command('call add(arr, 0)')
+ nvim_command('call add(arr[0], 0)')
+ nvim_command('call add(arr[0][0], 0)')
+ nvim_command('let map.a = 1')
+ nvim_command('let map.1.a = 1')
+ nvim_command('let int = 2')
+ nvim_command('let flt = 3.0')
+ nvim_command('let bin = ""')
+
+ eq({{{}}}, nvim_eval('arr2'))
+ eq({['1']={}}, nvim_eval('map2'))
+ eq(1, nvim_eval('int2'))
+ eq(2.0, nvim_eval('flt2'))
+ eq('abc', nvim_eval('bin2'))
+ end)
+ end)
+
+ describe('function msgpack#eval', function()
+ local eval_eq = function(expected_type, expected_val, str, ...)
+ nvim_command(('let g:__val = msgpack#eval(\'%s\', %s)'):format(str:gsub(
+ '\'', '\'\''), select(1, ...) or '{}'))
+ eq(expected_type, nvim_eval('msgpack#type(g:__val)'))
+ local expected_val_full = expected_val
+ if (not (({float=true, integer=true})[expected_type]
+ and type(expected_val) ~= 'table')
+ and expected_type ~= 'array') then
+ expected_val_full = {_TYPE={}, _VAL=expected_val_full}
+ end
+ if expected_val_full == expected_val_full then
+ eq(expected_val_full, nvim_eval('g:__val'))
+ else
+ eq(tostring(expected_val_full), tostring(nvim_eval('g:__val')))
+ end
+ nvim_command('unlet g:__val')
+ end
+
+ it('correctly loads binary strings', function()
+ eval_eq('binary', {'abcdef'}, '"abcdef"')
+ eval_eq('binary', {'abc', 'def'}, '"abc\\ndef"')
+ eval_eq('binary', {'abc\ndef'}, '"abc\\0def"')
+ eval_eq('binary', {'\nabc\ndef\n'}, '"\\0abc\\0def\\0"')
+ eval_eq('binary', {'abc\n\n\ndef'}, '"abc\\0\\0\\0def"')
+ eval_eq('binary', {'abc\n', '\ndef'}, '"abc\\0\\n\\0def"')
+ eval_eq('binary', {'abc', '', '', 'def'}, '"abc\\n\\n\\ndef"')
+ eval_eq('binary', {'abc', '', '', 'def', ''}, '"abc\\n\\n\\ndef\\n"')
+ eval_eq('binary', {'', 'abc', '', '', 'def'}, '"\\nabc\\n\\n\\ndef"')
+ eval_eq('binary', {''}, '""')
+ eval_eq('binary', {'"'}, '"\\""')
+ end)
+
+ it('correctly loads strings', function()
+ eval_eq('string', {'abcdef'}, '="abcdef"')
+ eval_eq('string', {'abc', 'def'}, '="abc\\ndef"')
+ eval_eq('string', {'abc\ndef'}, '="abc\\0def"')
+ eval_eq('string', {'\nabc\ndef\n'}, '="\\0abc\\0def\\0"')
+ eval_eq('string', {'abc\n\n\ndef'}, '="abc\\0\\0\\0def"')
+ eval_eq('string', {'abc\n', '\ndef'}, '="abc\\0\\n\\0def"')
+ eval_eq('string', {'abc', '', '', 'def'}, '="abc\\n\\n\\ndef"')
+ eval_eq('string', {'abc', '', '', 'def', ''}, '="abc\\n\\n\\ndef\\n"')
+ eval_eq('string', {'', 'abc', '', '', 'def'}, '="\\nabc\\n\\n\\ndef"')
+ eval_eq('string', {''}, '=""')
+ eval_eq('string', {'"'}, '="\\""')
+ end)
+
+ it('correctly loads ext values', function()
+ eval_eq('ext', {0, {'abcdef'}}, '+(0)"abcdef"')
+ eval_eq('ext', {0, {'abc', 'def'}}, '+(0)"abc\\ndef"')
+ eval_eq('ext', {0, {'abc\ndef'}}, '+(0)"abc\\0def"')
+ eval_eq('ext', {0, {'\nabc\ndef\n'}}, '+(0)"\\0abc\\0def\\0"')
+ eval_eq('ext', {0, {'abc\n\n\ndef'}}, '+(0)"abc\\0\\0\\0def"')
+ eval_eq('ext', {0, {'abc\n', '\ndef'}}, '+(0)"abc\\0\\n\\0def"')
+ eval_eq('ext', {0, {'abc', '', '', 'def'}}, '+(0)"abc\\n\\n\\ndef"')
+ eval_eq('ext', {0, {'abc', '', '', 'def', ''}},
+ '+(0)"abc\\n\\n\\ndef\\n"')
+ eval_eq('ext', {0, {'', 'abc', '', '', 'def'}},
+ '+(0)"\\nabc\\n\\n\\ndef"')
+ eval_eq('ext', {0, {''}}, '+(0)""')
+ eval_eq('ext', {0, {'"'}}, '+(0)"\\""')
+
+ eval_eq('ext', {-1, {'abcdef'}}, '+(-1)"abcdef"')
+ eval_eq('ext', {-1, {'abc', 'def'}}, '+(-1)"abc\\ndef"')
+ eval_eq('ext', {-1, {'abc\ndef'}}, '+(-1)"abc\\0def"')
+ eval_eq('ext', {-1, {'\nabc\ndef\n'}}, '+(-1)"\\0abc\\0def\\0"')
+ eval_eq('ext', {-1, {'abc\n\n\ndef'}}, '+(-1)"abc\\0\\0\\0def"')
+ eval_eq('ext', {-1, {'abc\n', '\ndef'}}, '+(-1)"abc\\0\\n\\0def"')
+ eval_eq('ext', {-1, {'abc', '', '', 'def'}}, '+(-1)"abc\\n\\n\\ndef"')
+ eval_eq('ext', {-1, {'abc', '', '', 'def', ''}},
+ '+(-1)"abc\\n\\n\\ndef\\n"')
+ eval_eq('ext', {-1, {'', 'abc', '', '', 'def'}},
+ '+(-1)"\\nabc\\n\\n\\ndef"')
+ eval_eq('ext', {-1, {''}}, '+(-1)""')
+ eval_eq('ext', {-1, {'"'}}, '+(-1)"\\""')
+ end)
+
+ it('correctly loads floats', function()
+ eval_eq('float', inf, 'inf')
+ eval_eq('float', minus_inf, '-inf')
+ eval_eq('float', nan, 'nan')
+ eval_eq('float', minus_nan, '-nan')
+ eval_eq('float', 1.0e10, '1.0e10')
+ eval_eq('float', 1.0e10, '1.0e+10')
+ eval_eq('float', -1.0e10, '-1.0e+10')
+ eval_eq('float', 1.0, '1.0')
+ eval_eq('float', -1.0, '-1.0')
+ eval_eq('float', 1.0e-10, '1.0e-10')
+ eval_eq('float', -1.0e-10, '-1.0e-10')
+ end)
+
+ it('correctly loads integers', function()
+ eval_eq('integer', 10, '10')
+ eval_eq('integer', -10, '-10')
+ eval_eq('integer', { 1, 0, 610839793, 448585456}, ' 0x123456789ABCDEF0')
+ eval_eq('integer', {-1, 0, 610839793, 448585456}, '-0x123456789ABCDEF0')
+ eval_eq('integer', { 1, 3, 1684581617, 448585456}, ' 0xF23456789ABCDEF0')
+ eval_eq('integer', {-1, 1, 1684581617, 448585456}, '-0x723456789ABCDEF0')
+ eval_eq('integer', { 1, 0, 0, 0x100}, '0x100')
+ eval_eq('integer', {-1, 0, 0, 0x100}, '-0x100')
+
+ eval_eq('integer', ('a'):byte(), '\'a\'')
+ eval_eq('integer', 0xAB, '\'«\'')
+ end)
+
+ it('correctly loads constants', function()
+ eval_eq('boolean', 1, 'TRUE')
+ eval_eq('boolean', 0, 'FALSE')
+ eval_eq('nil', 0, 'NIL')
+ eval_eq('nil', 0, 'NIL', '{"NIL": 1, "nan": 2, "T": 3}')
+ eval_eq('float', nan, 'nan',
+ '{"NIL": "1", "nan": "2", "T": "3"}')
+ eval_eq('integer', 3, 'T', '{"NIL": "1", "nan": "2", "T": "3"}')
+ eval_eq('integer', {1, 0, 0, 0}, 'T',
+ ('{"NIL": "1", "nan": "2", "T": \'%s\'}'):format(
+ sp('integer', '[1, 0, 0, 0]')))
+ end)
+
+ it('correctly loads maps', function()
+ eval_eq('map', {}, '{}')
+ eval_eq('map', {{{_TYPE={}, _VAL={{1, 2}}}, {_TYPE={}, _VAL={{3, 4}}}}},
+ '{{1: 2}: {3: 4}}')
+ eval_eq('map', {{{_TYPE={}, _VAL={{1, 2}}}, {_TYPE={}, _VAL={{3, 4}}}},
+ {1, 2}},
+ '{{1: 2}: {3: 4}, 1: 2}')
+ end)
+
+ it('correctly loads arrays', function()
+ eval_eq('array', {}, '[]')
+ eval_eq('array', {1}, '[1]')
+ eval_eq('array', {{_TYPE={}, _VAL=1}}, '[TRUE]')
+ eval_eq('array', {{{_TYPE={}, _VAL={{1, 2}}}}, {_TYPE={}, _VAL={{3, 4}}}},
+ '[[{1: 2}], {3: 4}]')
+ end)
+
+ it('errors out when needed', function()
+ eq('empty:Parsed string is empty',
+ exc_exec('call msgpack#eval("", {})'))
+ eq('unknown:Invalid non-space character: ^',
+ exc_exec('call msgpack#eval("^", {})'))
+ eq('char-invalid:Invalid integer character literal format: \'\'',
+ exc_exec('call msgpack#eval("\'\'", {})'))
+ eq('char-invalid:Invalid integer character literal format: \'ab\'',
+ exc_exec('call msgpack#eval("\'ab\'", {})'))
+ eq('char-invalid:Invalid integer character literal format: \'',
+ exc_exec('call msgpack#eval("\'", {})'))
+ eq('"-invalid:Invalid string: "',
+ exc_exec('call msgpack#eval("\\"", {})'))
+ eq('"-invalid:Invalid string: ="',
+ exc_exec('call msgpack#eval("=\\"", {})'))
+ eq('"-invalid:Invalid string: +(0)"',
+ exc_exec('call msgpack#eval("+(0)\\"", {})'))
+ eq('0.-nodigits:Decimal dot must be followed by digit(s): .e1',
+ exc_exec('call msgpack#eval("0.e1", {})'))
+ eq('0x-long:Must have at most 16 hex digits: FEDCBA98765432100',
+ exc_exec('call msgpack#eval("0xFEDCBA98765432100", {})'))
+ eq('0x-empty:Must have number after 0x: ',
+ exc_exec('call msgpack#eval("0x", {})'))
+ eq('name-unknown:Unknown name FOO: FOO',
+ exc_exec('call msgpack#eval("FOO", {})'))
+ end)
+ end)
+end)
diff --git a/test/functional/plugin/shada_spec.lua b/test/functional/plugin/shada_spec.lua
new file mode 100644
index 0000000000..4100a30452
--- /dev/null
+++ b/test/functional/plugin/shada_spec.lua
@@ -0,0 +1,2850 @@
+local helpers = require('test.functional.helpers')
+local eq, nvim_eval, nvim_command, nvim, exc_exec, funcs, nvim_feed, curbuf =
+ helpers.eq, helpers.eval, helpers.command, helpers.nvim, helpers.exc_exec,
+ helpers.funcs, helpers.feed, helpers.curbuf
+local neq = helpers.neq
+
+local msgpack = require('MessagePack')
+
+local plugin_helpers = require('test.functional.plugin.helpers')
+local reset = plugin_helpers.reset
+
+local shada_helpers = require('test.functional.shada.helpers')
+local get_shada_rw = shada_helpers.get_shada_rw
+
+local mpack_eq = function(expected, mpack_result)
+ local mpack_keys = {'type', 'timestamp', 'length', 'value'}
+
+ local unpacker = msgpack.unpacker(mpack_result)
+ local actual = {}
+ local cur
+ local i = 0
+ while true do
+ local off, val = unpacker()
+ if not off then break end
+ if i % 4 == 0 then
+ cur = {}
+ actual[#actual + 1] = cur
+ end
+ local key = mpack_keys[(i % 4) + 1]
+ if key ~= 'length' then
+ if key == 'timestamp' and math.abs(val - os.time()) < 2 then
+ val = 'current'
+ end
+ cur[key] = val
+ end
+ i = i + 1
+ end
+ eq(expected, actual)
+end
+
+local wshada, _, fname = get_shada_rw('Xtest-functional-plugin-shada.shada')
+
+local wshada_tmp, _, fname_tmp =
+ get_shada_rw('Xtest-functional-plugin-shada.shada.tmp.f')
+
+describe('In autoload/shada.vim', function()
+ local epoch = os.date('%Y-%m-%dT%H:%M:%S', 0)
+ before_each(function()
+ reset()
+ nvim_command([[
+ function ModifyVal(val)
+ if type(a:val) == type([])
+ if len(a:val) == 2 && type(a:val[0]) == type('') && a:val[0][0] is# '!' && has_key(v:msgpack_types, a:val[0][1:])
+ return {'_TYPE': v:msgpack_types[ a:val[0][1:] ], '_VAL': a:val[1]}
+ else
+ return map(copy(a:val), 'ModifyVal(v:val)')
+ endif
+ elseif type(a:val) == type({})
+ let keys = sort(keys(a:val))
+ let ret = {'_TYPE': v:msgpack_types.map, '_VAL': []}
+ for key in keys
+ let k = {'_TYPE': v:msgpack_types.string, '_VAL': split(key, "\n", 1)}
+ let v = ModifyVal(a:val[key])
+ call add(ret._VAL, [k, v])
+ unlet v
+ endfor
+ return ret
+ elseif type(a:val) == type('')
+ return {'_TYPE': v:msgpack_types.binary, '_VAL': split(a:val, "\n", 1)}
+ else
+ return a:val
+ endif
+ endfunction
+ ]])
+ end)
+
+ local sp = function(typ, val)
+ return ('{"_TYPE": v:msgpack_types.%s, "_VAL": %s}'):format(typ, val)
+ end
+
+ local st_meta = {
+ __pairs=function(table)
+ local ret = {}
+ local next_key = nil
+ local num_keys = 0
+ while true do
+ next_key = next(table, next_key)
+ if next_key == nil then
+ break
+ end
+ num_keys = num_keys + 1
+ ret[num_keys] = {next_key, table[next_key]}
+ end
+ table.sort(ret, function(a, b)
+ return a[1] < b[1]
+ end)
+ local state = {i=0}
+ return (function(state_, _)
+ state_.i = state_.i + 1
+ if ret[state_.i] then
+ return table.unpack(ret[state_.i])
+ end
+ end), state
+ end
+ }
+
+ local st = function(table)
+ return setmetatable(table, st_meta)
+ end
+
+ describe('function shada#mpack_to_sd', function()
+ local mpack2sd = function(arg)
+ return ('shada#mpack_to_sd(%s)'):format(arg)
+ end
+
+ it('works', function()
+ eq({}, nvim_eval(mpack2sd('[]')))
+ eq({{type=1, timestamp=5, length=1, data=7}},
+ nvim_eval(mpack2sd('[1, 5, 1, 7]')))
+ eq({{type=1, timestamp=5, length=1, data=7},
+ {type=1, timestamp=10, length=1, data=5}},
+ nvim_eval(mpack2sd('[1, 5, 1, 7, 1, 10, 1, 5]')))
+ eq('zero-uint:Entry 1 has type element which is zero',
+ exc_exec('call ' .. mpack2sd('[0, 5, 1, 7]')))
+ eq('zero-uint:Entry 1 has type element which is zero',
+ exc_exec('call ' .. mpack2sd(('[%s, 5, 1, 7]'):format(
+ sp('integer', '[1, 0, 0, 0]')))))
+ eq('not-uint:Entry 1 has timestamp element which is not an unsigned integer',
+ exc_exec('call ' .. mpack2sd('[1, -1, 1, 7]')))
+ eq('not-uint:Entry 1 has length element which is not an unsigned integer',
+ exc_exec('call ' .. mpack2sd('[1, 1, -1, 7]')))
+ eq('not-uint:Entry 1 has type element which is not an unsigned integer',
+ exc_exec('call ' .. mpack2sd('["", 1, -1, 7]')))
+ end)
+ end)
+
+ describe('function shada#sd_to_strings', function()
+ local sd2strings_eq = function(expected, arg)
+ if type(arg) == 'table' then
+ eq(expected, funcs['shada#sd_to_strings'](arg))
+ else
+ eq(expected, nvim_eval(('shada#sd_to_strings(%s)'):format(arg)))
+ end
+ end
+
+ it('works with empty input', function()
+ sd2strings_eq({}, '[]')
+ end)
+
+ it('works with unknown items', function()
+ sd2strings_eq({
+ 'Unknown (0x64) with timestamp ' .. epoch .. ':',
+ ' = 100'
+ }, {{type=100, timestamp=0, length=1, data=100}})
+
+ sd2strings_eq({
+ 'Unknown (0x4000001180000006) with timestamp ' .. epoch .. ':',
+ ' = 100'
+ }, ('[{"type": %s, "timestamp": 0, "length": 1, "data": 100}]'):format(
+ sp('integer', '[1, 1, 35, 6]')
+ ))
+ end)
+
+ it('works with multiple unknown items', function()
+ sd2strings_eq({
+ 'Unknown (0x64) with timestamp ' .. epoch .. ':',
+ ' = 100',
+ 'Unknown (0x65) with timestamp ' .. epoch .. ':',
+ ' = 500',
+ }, {{type=100, timestamp=0, length=1, data=100},
+ {type=101, timestamp=0, length=1, data=500}})
+ end)
+
+ it('works with header items', function()
+ sd2strings_eq({
+ 'Header with timestamp ' .. epoch .. ':',
+ ' % Key______ Value',
+ ' + generator "test"',
+ }, {{type=1, timestamp=0, data={generator='test'}}})
+ sd2strings_eq({
+ 'Header with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' + a 1',
+ ' + b 2',
+ ' + c column 3',
+ ' + d 4',
+ }, {{type=1, timestamp=0, data=st({a=1, b=2, c=3, d=4})}})
+ sd2strings_eq({
+ 'Header with timestamp ' .. epoch .. ':',
+ ' % Key Value',
+ ' + t "test"',
+ }, {{type=1, timestamp=0, data={t='test'}}})
+ sd2strings_eq({
+ 'Header with timestamp ' .. epoch .. ':',
+ ' # Unexpected type: array instead of map',
+ ' = [1, 2, 3]',
+ }, {{type=1, timestamp=0, data={1, 2, 3}}})
+ end)
+
+ it('processes standard keys correctly, even in header', function()
+ sd2strings_eq({
+ 'Header with timestamp ' .. epoch .. ':',
+ ' % Key Description________ Value',
+ ' + c column 0',
+ ' + f file name "/tmp/foo"',
+ ' + l line number 10',
+ ' + n name \'@\'',
+ ' + rc contents ["abc", "def"]',
+ ' + rt type CHARACTERWISE',
+ ' + rw block width 10',
+ ' + sb search backward TRUE',
+ ' + sc smartcase value FALSE',
+ ' + se place cursor at end TRUE',
+ ' + sh v:hlsearch value TRUE',
+ ' + sl has line offset FALSE',
+ ' + sm magic value TRUE',
+ ' + so offset value 10',
+ ' + sp pattern "100"',
+ ' + ss is :s pattern TRUE',
+ ' + su is last used FALSE',
+ }, ([[ [{'type': 1, 'timestamp': 0, 'data': {
+ 'sm': {'_TYPE': v:msgpack_types.boolean, '_VAL': 1},
+ 'sc': {'_TYPE': v:msgpack_types.boolean, '_VAL': 0},
+ 'sl': {'_TYPE': v:msgpack_types.boolean, '_VAL': 0},
+ 'se': {'_TYPE': v:msgpack_types.boolean, '_VAL': 1},
+ 'sb': {'_TYPE': v:msgpack_types.boolean, '_VAL': 1},
+ 'so': 10,
+ 'su': {'_TYPE': v:msgpack_types.boolean, '_VAL': 0},
+ 'ss': {'_TYPE': v:msgpack_types.boolean, '_VAL': 1},
+ 'sh': {'_TYPE': v:msgpack_types.boolean, '_VAL': 1},
+ 'sp': '100',
+ 'rt': 0,
+ 'rw': 10,
+ 'rc': ['abc', 'def'],
+ 'n': 0x40,
+ 'l': 10,
+ 'c': 0,
+ 'f': '/tmp/foo',
+ }}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Header with timestamp ' .. epoch .. ':',
+ ' % Key Description____ Value',
+ ' # Expected integer',
+ ' + c column "abc"',
+ ' # Expected no NUL bytes',
+ ' + f file name "abc\\0def"',
+ ' # Value is negative',
+ ' + l line number -10',
+ ' # Value is negative',
+ ' + n name -64',
+ ' # Expected array value',
+ ' + rc contents "10"',
+ ' # Unexpected enum value: expected one of '
+ .. '0 (CHARACTERWISE), 1 (LINEWISE), 2 (BLOCKWISE)',
+ ' + rt type 10',
+ ' # Expected boolean',
+ ' + sc smartcase value NIL',
+ ' # Expected boolean',
+ ' + sm magic value "TRUE"',
+ ' # Expected integer',
+ ' + so offset value "TRUE"',
+ ' # Expected binary string',
+ ' + sp pattern ="abc"',
+ }, ([[ [{'type': 1, 'timestamp': 0, 'data': {
+ 'sm': 'TRUE',
+ 'sc': {'_TYPE': v:msgpack_types.nil, '_VAL': 0},
+ 'so': 'TRUE',
+ 'sp': {'_TYPE': v:msgpack_types.string, '_VAL': ["abc"]},
+ 'rt': 10,
+ 'rc': '10',
+ 'n': -0x40,
+ 'l': -10,
+ 'c': 'abc',
+ 'f': {'_TYPE': v:msgpack_types.binary, '_VAL': ["abc\ndef"]},
+ }}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Header with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' # Expected no NUL bytes',
+ ' + f file name "abc\\0def"',
+ ' # Expected array of binary strings',
+ ' + rc contents ["abc", ="abc"]',
+ ' # Expected integer',
+ ' + rt type "ABC"',
+ }, ([[ [{'type': 1, 'timestamp': 0, 'data': {
+ 'rt': 'ABC',
+ 'rc': ["abc", {'_TYPE': v:msgpack_types.string, '_VAL': ["abc"]}],
+ 'f': {'_TYPE': v:msgpack_types.binary, '_VAL': ["abc\ndef"]},
+ }}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Header with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' # Expected no NUL bytes',
+ ' + rc contents ["abc", "a\\nd\\0"]',
+ }, ([[ [{'type': 1, 'timestamp': 0, 'data': {
+ 'rc': ["abc", {'_TYPE': v:msgpack_types.binary, '_VAL': ["a", "d\n"]}],
+ }}] ]]):gsub('\n', ''))
+ end)
+
+ it('works with search pattern items', function()
+ sd2strings_eq({
+ 'Search pattern with timestamp ' .. epoch .. ':',
+ ' # Unexpected type: array instead of map',
+ ' = [1, 2, 3]',
+ }, {{type=2, timestamp=0, data={1, 2, 3}}})
+ sd2strings_eq({
+ 'Search pattern with timestamp ' .. epoch .. ':',
+ ' % Key Description________ Value',
+ ' + sp pattern "abc"',
+ ' + sh v:hlsearch value FALSE',
+ ' + ss is :s pattern FALSE',
+ ' + sb search backward FALSE',
+ ' + sm magic value TRUE',
+ ' + sc smartcase value FALSE',
+ ' + sl has line offset FALSE',
+ ' + se place cursor at end FALSE',
+ ' + so offset value 0',
+ ' + su is last used TRUE',
+ }, ([[ [{'type': 2, 'timestamp': 0, 'data': {
+ 'sp': 'abc',
+ }}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Search pattern with timestamp ' .. epoch .. ':',
+ ' % Key Description________ Value',
+ ' + sp pattern "abc"',
+ ' + sh v:hlsearch value FALSE',
+ ' + ss is :s pattern FALSE',
+ ' + sb search backward FALSE',
+ ' + sm magic value TRUE',
+ ' + sc smartcase value FALSE',
+ ' + sl has line offset FALSE',
+ ' + se place cursor at end FALSE',
+ ' + so offset value 0',
+ ' + su is last used TRUE',
+ ' + sX NIL',
+ ' + sY NIL',
+ ' + sZ NIL',
+ }, ([[ [{'type': 2, 'timestamp': 0, 'data': {
+ 'sp': 'abc',
+ 'sZ': {'_TYPE': v:msgpack_types.nil, '_VAL': 0},
+ 'sY': {'_TYPE': v:msgpack_types.nil, '_VAL': 0},
+ 'sX': {'_TYPE': v:msgpack_types.nil, '_VAL': 0},
+ }}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Search pattern with timestamp ' .. epoch .. ':',
+ ' % Key Description________ Value',
+ ' + sp pattern "abc"',
+ ' + sh v:hlsearch value FALSE',
+ ' + ss is :s pattern FALSE',
+ ' + sb search backward FALSE',
+ ' + sm magic value TRUE',
+ ' + sc smartcase value FALSE',
+ ' + sl has line offset FALSE',
+ ' + se place cursor at end FALSE',
+ ' + so offset value 0',
+ ' + su is last used TRUE',
+ }, ([[ [{'type': 2, 'timestamp': 0, 'data': {
+ 'sp': 'abc',
+ 'sh': {'_TYPE': v:msgpack_types.boolean, '_VAL': 0},
+ 'ss': {'_TYPE': v:msgpack_types.boolean, '_VAL': 0},
+ 'sb': {'_TYPE': v:msgpack_types.boolean, '_VAL': 0},
+ 'sm': {'_TYPE': v:msgpack_types.boolean, '_VAL': 1},
+ 'sc': {'_TYPE': v:msgpack_types.boolean, '_VAL': 0},
+ 'sl': {'_TYPE': v:msgpack_types.boolean, '_VAL': 0},
+ 'se': {'_TYPE': v:msgpack_types.boolean, '_VAL': 0},
+ 'so': 0,
+ 'su': {'_TYPE': v:msgpack_types.boolean, '_VAL': 1},
+ }}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Search pattern with timestamp ' .. epoch .. ':',
+ ' % Key Description________ Value',
+ ' # Required key missing: sp',
+ ' + sh v:hlsearch value FALSE',
+ ' + ss is :s pattern FALSE',
+ ' + sb search backward FALSE',
+ ' + sm magic value TRUE',
+ ' + sc smartcase value FALSE',
+ ' + sl has line offset FALSE',
+ ' + se place cursor at end FALSE',
+ ' + so offset value 0',
+ ' + su is last used TRUE',
+ }, ([[ [{'type': 2, 'timestamp': 0, 'data': {
+ }}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Search pattern with timestamp ' .. epoch .. ':',
+ ' % Key Description________ Value',
+ ' + sp pattern ""',
+ ' + sh v:hlsearch value TRUE',
+ ' + ss is :s pattern TRUE',
+ ' + sb search backward TRUE',
+ ' + sm magic value FALSE',
+ ' + sc smartcase value TRUE',
+ ' + sl has line offset TRUE',
+ ' + se place cursor at end TRUE',
+ ' + so offset value -10',
+ ' + su is last used FALSE',
+ }, ([[ [{'type': 2, 'timestamp': 0, 'data': {
+ 'sp': '',
+ 'sh': {'_TYPE': v:msgpack_types.boolean, '_VAL': 1},
+ 'ss': {'_TYPE': v:msgpack_types.boolean, '_VAL': 1},
+ 'sb': {'_TYPE': v:msgpack_types.boolean, '_VAL': 1},
+ 'sm': {'_TYPE': v:msgpack_types.boolean, '_VAL': 0},
+ 'sc': {'_TYPE': v:msgpack_types.boolean, '_VAL': 1},
+ 'sl': {'_TYPE': v:msgpack_types.boolean, '_VAL': 1},
+ 'se': {'_TYPE': v:msgpack_types.boolean, '_VAL': 1},
+ 'so': -10,
+ 'su': {'_TYPE': v:msgpack_types.boolean, '_VAL': 0},
+ }}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Search pattern with timestamp ' .. epoch .. ':',
+ ' % Key Description________ Value',
+ ' # Expected binary string',
+ ' + sp pattern 0',
+ ' # Expected boolean',
+ ' + sh v:hlsearch value 0',
+ ' # Expected boolean',
+ ' + ss is :s pattern 0',
+ ' # Expected boolean',
+ ' + sb search backward 0',
+ ' # Expected boolean',
+ ' + sm magic value 0',
+ ' # Expected boolean',
+ ' + sc smartcase value 0',
+ ' # Expected boolean',
+ ' + sl has line offset 0',
+ ' # Expected boolean',
+ ' + se place cursor at end 0',
+ ' # Expected integer',
+ ' + so offset value ""',
+ ' # Expected boolean',
+ ' + su is last used 0',
+ }, ([[ [{'type': 2, 'timestamp': 0, 'data': {
+ 'sp': 0,
+ 'sh': 0,
+ 'ss': 0,
+ 'sb': 0,
+ 'sm': 0,
+ 'sc': 0,
+ 'sl': 0,
+ 'se': 0,
+ 'so': '',
+ 'su': 0,
+ }}] ]]):gsub('\n', ''))
+ end)
+
+ it('works with replacement string items', function()
+ sd2strings_eq({
+ 'Replacement string with timestamp ' .. epoch .. ':',
+ ' # Unexpected type: map instead of array',
+ ' = {="a": [10]}',
+ }, {{type=3, timestamp=0, data={a={10}}}})
+ sd2strings_eq({
+ 'Replacement string with timestamp ' .. epoch .. ':',
+ ' @ Description__________ Value',
+ ' # Expected more elements in list'
+ }, ([[ [{'type': 3, 'timestamp': 0, 'data': [
+ ]}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Replacement string with timestamp ' .. epoch .. ':',
+ ' @ Description__________ Value',
+ ' # Expected binary string',
+ ' - :s replacement string 0',
+ }, ([[ [{'type': 3, 'timestamp': 0, 'data': [
+ 0,
+ ]}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Replacement string with timestamp ' .. epoch .. ':',
+ ' @ Description__________ Value',
+ ' # Expected no NUL bytes',
+ ' - :s replacement string "abc\\0def"',
+ }, ([[ [{'type': 3, 'timestamp': 0, 'data': [
+ {'_TYPE': v:msgpack_types.binary, '_VAL': ["abc\ndef"]},
+ ]}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Replacement string with timestamp ' .. epoch .. ':',
+ ' @ Description__________ Value',
+ ' - :s replacement string "abc\\ndef"',
+ }, ([[ [{'type': 3, 'timestamp': 0, 'data': [
+ {'_TYPE': v:msgpack_types.binary, '_VAL': ["abc", "def"]},
+ ]}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Replacement string with timestamp ' .. epoch .. ':',
+ ' @ Description__________ Value',
+ ' - :s replacement string "abc\\ndef"',
+ ' - 0',
+ }, ([[ [{'type': 3, 'timestamp': 0, 'data': [
+ {'_TYPE': v:msgpack_types.binary, '_VAL': ["abc", "def"]},
+ 0,
+ ]}] ]]):gsub('\n', ''))
+ end)
+
+ it('works with history entry items', function()
+ sd2strings_eq({
+ 'History entry with timestamp ' .. epoch .. ':',
+ ' # Unexpected type: map instead of array',
+ ' = {="a": [10]}',
+ }, {{type=4, timestamp=0, data={a={10}}}})
+ sd2strings_eq({
+ 'History entry with timestamp ' .. epoch .. ':',
+ ' @ Description_ Value',
+ ' # Expected more elements in list'
+ }, ([[ [{'type': 4, 'timestamp': 0, 'data': [
+ ]}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'History entry with timestamp ' .. epoch .. ':',
+ ' @ Description_ Value',
+ ' # Expected integer',
+ ' - history type ""',
+ ' # Expected more elements in list'
+ }, ([[ [{'type': 4, 'timestamp': 0, 'data': [
+ '',
+ ]}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'History entry with timestamp ' .. epoch .. ':',
+ ' @ Description_ Value',
+ ' # Unexpected enum value: expected one of 0 (CMD), 1 (SEARCH), '
+ .. '2 (EXPR), 3 (INPUT), 4 (DEBUG)',
+ ' - history type 5',
+ ' - contents ""',
+ }, ([[ [{'type': 4, 'timestamp': 0, 'data': [
+ 5,
+ ''
+ ]}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'History entry with timestamp ' .. epoch .. ':',
+ ' @ Description_ Value',
+ ' # Unexpected enum value: expected one of 0 (CMD), 1 (SEARCH), '
+ .. '2 (EXPR), 3 (INPUT), 4 (DEBUG)',
+ ' - history type 5',
+ ' - contents ""',
+ ' - 32',
+ }, ([[ [{'type': 4, 'timestamp': 0, 'data': [
+ 5,
+ '',
+ 0x20
+ ]}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'History entry with timestamp ' .. epoch .. ':',
+ ' @ Description_ Value',
+ ' - history type CMD',
+ ' - contents ""',
+ ' - 32',
+ }, ([[ [{'type': 4, 'timestamp': 0, 'data': [
+ 0,
+ '',
+ 0x20
+ ]}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'History entry with timestamp ' .. epoch .. ':',
+ ' @ Description_ Value',
+ ' - history type SEARCH',
+ ' - contents ""',
+ ' - separator \' \'',
+ }, ([[ [{'type': 4, 'timestamp': 0, 'data': [
+ 1,
+ '',
+ 0x20
+ ]}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'History entry with timestamp ' .. epoch .. ':',
+ ' @ Description_ Value',
+ ' - history type SEARCH',
+ ' - contents ""',
+ ' # Expected more elements in list',
+ }, ([[ [{'type': 4, 'timestamp': 0, 'data': [
+ 1,
+ '',
+ ]}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'History entry with timestamp ' .. epoch .. ':',
+ ' @ Description_ Value',
+ ' - history type EXPR',
+ ' - contents ""',
+ }, ([[ [{'type': 4, 'timestamp': 0, 'data': [
+ 2,
+ '',
+ ]}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'History entry with timestamp ' .. epoch .. ':',
+ ' @ Description_ Value',
+ ' - history type INPUT',
+ ' - contents ""',
+ }, ([[ [{'type': 4, 'timestamp': 0, 'data': [
+ 3,
+ '',
+ ]}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'History entry with timestamp ' .. epoch .. ':',
+ ' @ Description_ Value',
+ ' - history type DEBUG',
+ ' - contents ""',
+ }, ([[ [{'type': 4, 'timestamp': 0, 'data': [
+ 4,
+ '',
+ ]}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'History entry with timestamp ' .. epoch .. ':',
+ ' @ Description_ Value',
+ ' - history type DEBUG',
+ ' # Expected binary string',
+ ' - contents 10',
+ }, ([[ [{'type': 4, 'timestamp': 0, 'data': [
+ 4,
+ 10,
+ ]}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'History entry with timestamp ' .. epoch .. ':',
+ ' @ Description_ Value',
+ ' - history type DEBUG',
+ ' # Expected no NUL bytes',
+ ' - contents "abc\\0def"',
+ }, ([[ [{'type': 4, 'timestamp': 0, 'data': [
+ 4,
+ {'_TYPE': v:msgpack_types.binary, '_VAL': ["abc\ndef"]},
+ ]}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'History entry with timestamp ' .. epoch .. ':',
+ ' @ Description_ Value',
+ ' - history type SEARCH',
+ ' - contents "abc"',
+ ' # Expected integer',
+ ' - separator ""',
+ }, ([[ [{'type': 4, 'timestamp': 0, 'data': [
+ 1,
+ 'abc',
+ '',
+ ]}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'History entry with timestamp ' .. epoch .. ':',
+ ' @ Description_ Value',
+ ' - history type SEARCH',
+ ' - contents "abc"',
+ ' # Value is negative',
+ ' - separator -1',
+ }, ([[ [{'type': 4, 'timestamp': 0, 'data': [
+ 1,
+ 'abc',
+ -1,
+ ]}] ]]):gsub('\n', ''))
+ end)
+
+ it('works with register items', function()
+ sd2strings_eq({
+ 'Register with timestamp ' .. epoch .. ':',
+ ' # Unexpected type: array instead of map',
+ ' = [1, 2, 3]',
+ }, {{type=5, timestamp=0, data={1, 2, 3}}})
+ sd2strings_eq({
+ 'Register with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' # Required key missing: n',
+ ' # Required key missing: rc',
+ ' + rw block width 0',
+ ' + rt type CHARACTERWISE',
+ }, ([[ [{'type': 5, 'timestamp': 0, 'data': {
+ }}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Register with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' + n name \' \'',
+ ' # Required key missing: rc',
+ ' + rw block width 0',
+ ' + rt type CHARACTERWISE',
+ }, ([[ [{'type': 5, 'timestamp': 0, 'data': {
+ 'n': 0x20,
+ }}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Register with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' + n name \' \'',
+ ' + rc contents ["abc", "def"]',
+ ' + rw block width 0',
+ ' + rt type CHARACTERWISE',
+ }, ([[ [{'type': 5, 'timestamp': 0, 'data': {
+ 'n': 0x20,
+ 'rc': ["abc", "def"],
+ }}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Register with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' + n name \' \'',
+ ' + rc contents @',
+ ' | - "abcdefghijklmnopqrstuvwxyz"',
+ ' | - "abcdefghijklmnopqrstuvwxyz"',
+ ' + rw block width 0',
+ ' + rt type CHARACTERWISE',
+ }, ([[ [{'type': 5, 'timestamp': 0, 'data': {
+ 'n': 0x20,
+ 'rc': ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz'],
+ }}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Register with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' + n name \' \'',
+ ' + rc contents @',
+ ' | - "abcdefghijklmnopqrstuvwxyz"',
+ ' | - "abcdefghijklmnopqrstuvwxyz"',
+ ' + rw block width 0',
+ ' + rt type CHARACTERWISE',
+ }, ([[ [{'type': 5, 'timestamp': 0, 'data': {
+ 'n': 0x20,
+ 'rc': ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz'],
+ 'rw': 0,
+ 'rt': 0,
+ }}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Register with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' + n name \' \'',
+ ' + rc contents @',
+ ' | - "abcdefghijklmnopqrstuvwxyz"',
+ ' | - "abcdefghijklmnopqrstuvwxyz"',
+ ' + rw block width 5',
+ ' + rt type LINEWISE',
+ }, ([[ [{'type': 5, 'timestamp': 0, 'data': {
+ 'n': 0x20,
+ 'rc': ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz'],
+ 'rw': 5,
+ 'rt': 1,
+ }}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Register with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' + n name \' \'',
+ ' + rc contents @',
+ ' | - "abcdefghijklmnopqrstuvwxyz"',
+ ' | - "abcdefghijklmnopqrstuvwxyz"',
+ ' # Expected integer',
+ ' + rw block width ""',
+ ' + rt type BLOCKWISE',
+ }, ([[ [{'type': 5, 'timestamp': 0, 'data': {
+ 'n': 0x20,
+ 'rc': ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz'],
+ 'rw': "",
+ 'rt': 2,
+ }}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Register with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' + n name \' \'',
+ ' # Expected array value',
+ ' + rc contents 0',
+ ' # Value is negative',
+ ' + rw block width -1',
+ ' # Unexpected enum value: expected one of 0 (CHARACTERWISE), '
+ .. '1 (LINEWISE), 2 (BLOCKWISE)',
+ ' + rt type 10',
+ }, ([[ [{'type': 5, 'timestamp': 0, 'data': {
+ 'n': 0x20,
+ 'rc': 0,
+ 'rw': -1,
+ 'rt': 10,
+ }}] ]]):gsub('\n', ''))
+ end)
+
+ it('works with variable items', function()
+ sd2strings_eq({
+ 'Variable with timestamp ' .. epoch .. ':',
+ ' # Unexpected type: map instead of array',
+ ' = {="a": [10]}',
+ }, {{type=6, timestamp=0, data={a={10}}}})
+ sd2strings_eq({
+ 'Variable with timestamp ' .. epoch .. ':',
+ ' @ Description Value',
+ ' # Expected more elements in list'
+ }, ([[ [{'type': 6, 'timestamp': 0, 'data': [
+ ]}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Variable with timestamp ' .. epoch .. ':',
+ ' @ Description Value',
+ ' # Expected binary string',
+ ' - name 1',
+ ' # Expected more elements in list',
+ }, ([[ [{'type': 6, 'timestamp': 0, 'data': [
+ 1
+ ]}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Variable with timestamp ' .. epoch .. ':',
+ ' @ Description Value',
+ ' # Expected no NUL bytes',
+ ' - name "\\0"',
+ ' # Expected more elements in list',
+ }, ([[ [{'type': 6, 'timestamp': 0, 'data': [
+ {'_TYPE': v:msgpack_types.binary, '_VAL': ["\n"]},
+ ]}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Variable with timestamp ' .. epoch .. ':',
+ ' @ Description Value',
+ ' - name "foo"',
+ ' # Expected more elements in list',
+ }, ([[ [{'type': 6, 'timestamp': 0, 'data': [
+ {'_TYPE': v:msgpack_types.binary, '_VAL': ["foo"]},
+ ]}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Variable with timestamp ' .. epoch .. ':',
+ ' @ Description Value',
+ ' - name "foo"',
+ ' - value NIL',
+ }, ([[ [{'type': 6, 'timestamp': 0, 'data': [
+ {'_TYPE': v:msgpack_types.binary, '_VAL': ["foo"]},
+ {'_TYPE': v:msgpack_types.nil, '_VAL': ["foo"]},
+ ]}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Variable with timestamp ' .. epoch .. ':',
+ ' @ Description Value',
+ ' - name "foo"',
+ ' - value NIL',
+ ' - NIL',
+ }, ([[ [{'type': 6, 'timestamp': 0, 'data': [
+ {'_TYPE': v:msgpack_types.binary, '_VAL': ["foo"]},
+ {'_TYPE': v:msgpack_types.nil, '_VAL': ["foo"]},
+ {'_TYPE': v:msgpack_types.nil, '_VAL': ["foo"]},
+ ]}] ]]):gsub('\n', ''))
+ end)
+
+ it('works with global mark items', function()
+ sd2strings_eq({
+ 'Global mark with timestamp ' .. epoch .. ':',
+ ' # Unexpected type: array instead of map',
+ ' = [1, 2, 3]',
+ }, {{type=7, timestamp=0, data={1, 2, 3}}})
+ sd2strings_eq({
+ 'Global mark with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' # Required key missing: n',
+ ' # Required key missing: f',
+ ' + l line number 1',
+ ' + c column 0',
+ }, ([[ [{'type': 7, 'timestamp': 0, 'data': {
+ }}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Global mark with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' # Expected integer',
+ ' + n name "foo"',
+ ' # Required key missing: f',
+ ' + l line number 1',
+ ' + c column 0',
+ }, ([[ [{'type': 7, 'timestamp': 0, 'data': {
+ 'n': 'foo',
+ }}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Global mark with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' # Required key missing: n',
+ ' + f file name "foo"',
+ ' + l line number 1',
+ ' + c column 0',
+ }, ([[ [{'type': 7, 'timestamp': 0, 'data': {
+ 'f': 'foo',
+ }}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Global mark with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' # Value is negative',
+ ' + n name -10',
+ ' # Expected no NUL bytes',
+ ' + f file name "\\0"',
+ ' + l line number 1',
+ ' + c column 0',
+ }, ([[ [{'type': 7, 'timestamp': 0, 'data': {
+ 'n': -10,
+ 'f': {'_TYPE': v:msgpack_types.binary, '_VAL': ["\n"]},
+ }}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Global mark with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' + n name 20',
+ ' + f file name "foo"',
+ ' # Value is negative',
+ ' + l line number -10',
+ ' # Value is negative',
+ ' + c column -10',
+ }, ([[ [{'type': 7, 'timestamp': 0, 'data': {
+ 'n': 20,
+ 'f': 'foo',
+ 'l': -10,
+ 'c': -10,
+ }}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Global mark with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' + n name 20',
+ ' + f file name "foo"',
+ ' # Expected integer',
+ ' + l line number "FOO"',
+ ' # Expected integer',
+ ' + c column "foo"',
+ ' + mX 10',
+ }, ([[ [{'type': 7, 'timestamp': 0, 'data': {
+ 'n': 20,
+ 'f': 'foo',
+ 'l': 'FOO',
+ 'c': 'foo',
+ 'mX': 10,
+ }}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Global mark with timestamp ' .. epoch .. ':',
+ ' % Key________ Description Value',
+ ' + n name \'A\'',
+ ' + f file name "foo"',
+ ' + l line number 2',
+ ' + c column 200',
+ ' + mX 10',
+ ' + mYYYYYYYYYY 10',
+ }, ([[ [{'type': 7, 'timestamp': 0, 'data': {
+ 'n': char2nr('A'),
+ 'f': 'foo',
+ 'l': 2,
+ 'c': 200,
+ 'mX': 10,
+ 'mYYYYYYYYYY': 10,
+ }}] ]]):gsub('\n', ''))
+ end)
+
+ it('works with jump items', function()
+ sd2strings_eq({
+ 'Jump with timestamp ' .. epoch .. ':',
+ ' # Unexpected type: array instead of map',
+ ' = [1, 2, 3]',
+ }, {{type=8, timestamp=0, data={1, 2, 3}}})
+ sd2strings_eq({
+ 'Jump with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' # Required key missing: f',
+ ' + l line number 1',
+ ' + c column 0',
+ }, ([[ [{'type': 8, 'timestamp': 0, 'data': {
+ }}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Jump with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' # Required key missing: f',
+ ' + l line number 1',
+ ' + c column 0',
+ ' # Expected integer',
+ ' + n name "foo"',
+ }, ([[ [{'type': 8, 'timestamp': 0, 'data': {
+ 'n': 'foo',
+ }}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Jump with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' + f file name "foo"',
+ ' + l line number 1',
+ ' + c column 0',
+ }, ([[ [{'type': 8, 'timestamp': 0, 'data': {
+ 'f': 'foo',
+ }}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Jump with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' # Expected no NUL bytes',
+ ' + f file name "\\0"',
+ ' + l line number 1',
+ ' + c column 0',
+ ' # Value is negative',
+ ' + n name -10',
+ }, ([[ [{'type': 8, 'timestamp': 0, 'data': {
+ 'n': -10,
+ 'f': {'_TYPE': v:msgpack_types.binary, '_VAL': ["\n"]},
+ }}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Jump with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' + f file name "foo"',
+ ' # Value is negative',
+ ' + l line number -10',
+ ' # Value is negative',
+ ' + c column -10',
+ }, ([[ [{'type': 8, 'timestamp': 0, 'data': {
+ 'f': 'foo',
+ 'l': -10,
+ 'c': -10,
+ }}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Jump with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' + f file name "foo"',
+ ' # Expected integer',
+ ' + l line number "FOO"',
+ ' # Expected integer',
+ ' + c column "foo"',
+ ' + mX 10',
+ }, ([[ [{'type': 8, 'timestamp': 0, 'data': {
+ 'f': 'foo',
+ 'l': 'FOO',
+ 'c': 'foo',
+ 'mX': 10,
+ }}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Jump with timestamp ' .. epoch .. ':',
+ ' % Key________ Description Value',
+ ' + f file name "foo"',
+ ' + l line number 2',
+ ' + c column 200',
+ ' + mX 10',
+ ' + mYYYYYYYYYY 10',
+ ' + n name \' \'',
+ }, ([[ [{'type': 8, 'timestamp': 0, 'data': {
+ 'n': 0x20,
+ 'f': 'foo',
+ 'l': 2,
+ 'c': 200,
+ 'mX': 10,
+ 'mYYYYYYYYYY': 10,
+ }}] ]]):gsub('\n', ''))
+ end)
+
+ it('works with buffer list items', function()
+ sd2strings_eq({
+ 'Buffer list with timestamp ' .. epoch .. ':',
+ ' # Unexpected type: map instead of array',
+ ' = {="a": [10]}',
+ }, {{type=9, timestamp=0, data={a={10}}}})
+ sd2strings_eq({
+ 'Buffer list with timestamp ' .. epoch .. ':',
+ ' # Expected array of maps',
+ ' = [[], []]',
+ }, {{type=9, timestamp=0, data={{}, {}}}})
+ sd2strings_eq({
+ 'Buffer list with timestamp ' .. epoch .. ':',
+ ' # Expected array of maps',
+ ' = [{="a": 10}, []]',
+ }, {{type=9, timestamp=0, data={{a=10}, {}}}})
+ sd2strings_eq({
+ 'Buffer list with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' # Required key missing: f',
+ ' + l line number 1',
+ ' + c column 0',
+ ' + a 10',
+ }, {{type=9, timestamp=0, data={{a=10}}}})
+ sd2strings_eq({
+ 'Buffer list with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' # Required key missing: f',
+ ' # Expected integer',
+ ' + l line number "10"',
+ ' # Expected integer',
+ ' + c column "10"',
+ ' + a 10',
+ }, {{type=9, timestamp=0, data={{l='10', c='10', a=10}}}})
+ sd2strings_eq({
+ 'Buffer list with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' # Required key missing: f',
+ ' + l line number 10',
+ ' + c column 10',
+ ' + a 10',
+ }, {{type=9, timestamp=0, data={{l=10, c=10, a=10}}}})
+ sd2strings_eq({
+ 'Buffer list with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' # Required key missing: f',
+ ' # Value is negative',
+ ' + l line number -10',
+ ' # Value is negative',
+ ' + c column -10',
+ }, {{type=9, timestamp=0, data={{l=-10, c=-10}}}})
+ sd2strings_eq({
+ 'Buffer list with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' + f file name "abc"',
+ ' + l line number 1',
+ ' + c column 0',
+ }, {{type=9, timestamp=0, data={{f='abc'}}}})
+ sd2strings_eq({
+ 'Buffer list with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' # Expected binary string',
+ ' + f file name 10',
+ ' + l line number 1',
+ ' + c column 0',
+ '',
+ ' % Key Description Value',
+ ' # Expected binary string',
+ ' + f file name 20',
+ ' + l line number 1',
+ ' + c column 0',
+ }, {{type=9, timestamp=0, data={{f=10}, {f=20}}}})
+ sd2strings_eq({
+ 'Buffer list with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' # Expected binary string',
+ ' + f file name 10',
+ ' + l line number 1',
+ ' + c column 0',
+ '',
+ ' % Key Description Value',
+ ' # Expected no NUL bytes',
+ ' + f file name "\\0"',
+ ' + l line number 1',
+ ' + c column 0',
+ }, ([[ [{'type': 9, 'timestamp': 0, 'data': [
+ {'f': 10},
+ {'f': {'_TYPE': v:msgpack_types.binary, '_VAL': ["\n"]}},
+ ]}] ]]):gsub('\n', ''))
+ end)
+
+ it('works with local mark items', function()
+ sd2strings_eq({
+ 'Local mark with timestamp ' .. epoch .. ':',
+ ' # Unexpected type: array instead of map',
+ ' = [1, 2, 3]',
+ }, {{type=10, timestamp=0, data={1, 2, 3}}})
+ sd2strings_eq({
+ 'Local mark with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' # Required key missing: f',
+ ' + n name \'"\'',
+ ' + l line number 1',
+ ' + c column 0',
+ }, ([[ [{'type': 10, 'timestamp': 0, 'data': {
+ }}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Local mark with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' # Required key missing: f',
+ ' # Expected integer',
+ ' + n name "foo"',
+ ' + l line number 1',
+ ' + c column 0',
+ }, ([[ [{'type': 10, 'timestamp': 0, 'data': {
+ 'n': 'foo',
+ }}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Local mark with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' + f file name "foo"',
+ ' + n name \'"\'',
+ ' + l line number 1',
+ ' + c column 0',
+ }, ([[ [{'type': 10, 'timestamp': 0, 'data': {
+ 'f': 'foo',
+ }}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Local mark with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' # Expected no NUL bytes',
+ ' + f file name "\\0"',
+ ' # Value is negative',
+ ' + n name -10',
+ ' + l line number 1',
+ ' + c column 0',
+ }, ([[ [{'type': 10, 'timestamp': 0, 'data': {
+ 'n': -10,
+ 'f': {'_TYPE': v:msgpack_types.binary, '_VAL': ["\n"]},
+ }}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Local mark with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' + f file name "foo"',
+ ' + n name 20',
+ ' # Value is negative',
+ ' + l line number -10',
+ ' # Value is negative',
+ ' + c column -10',
+ }, ([[ [{'type': 10, 'timestamp': 0, 'data': {
+ 'n': 20,
+ 'f': 'foo',
+ 'l': -10,
+ 'c': -10,
+ }}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Local mark with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' + f file name "foo"',
+ ' + n name 20',
+ ' # Expected integer',
+ ' + l line number "FOO"',
+ ' # Expected integer',
+ ' + c column "foo"',
+ ' + mX 10',
+ }, ([[ [{'type': 10, 'timestamp': 0, 'data': {
+ 'n': 20,
+ 'f': 'foo',
+ 'l': 'FOO',
+ 'c': 'foo',
+ 'mX': 10,
+ }}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Local mark with timestamp ' .. epoch .. ':',
+ ' % Key________ Description Value',
+ ' + f file name "foo"',
+ ' + n name \'a\'',
+ ' + l line number 2',
+ ' + c column 200',
+ ' + mX 10',
+ ' + mYYYYYYYYYY 10',
+ }, ([[ [{'type': 10, 'timestamp': 0, 'data': {
+ 'n': char2nr('a'),
+ 'f': 'foo',
+ 'l': 2,
+ 'c': 200,
+ 'mX': 10,
+ 'mYYYYYYYYYY': 10,
+ }}] ]]):gsub('\n', ''))
+ end)
+
+ it('works with change items', function()
+ sd2strings_eq({
+ 'Change with timestamp ' .. epoch .. ':',
+ ' # Unexpected type: array instead of map',
+ ' = [1, 2, 3]',
+ }, {{type=11, timestamp=0, data={1, 2, 3}}})
+ sd2strings_eq({
+ 'Change with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' # Required key missing: f',
+ ' + l line number 1',
+ ' + c column 0',
+ }, ([[ [{'type': 11, 'timestamp': 0, 'data': {
+ }}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Change with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' # Required key missing: f',
+ ' + l line number 1',
+ ' + c column 0',
+ ' # Expected integer',
+ ' + n name "foo"',
+ }, ([[ [{'type': 11, 'timestamp': 0, 'data': {
+ 'n': 'foo',
+ }}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Change with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' + f file name "foo"',
+ ' + l line number 1',
+ ' + c column 0',
+ }, ([[ [{'type': 11, 'timestamp': 0, 'data': {
+ 'f': 'foo',
+ }}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Change with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' # Expected no NUL bytes',
+ ' + f file name "\\0"',
+ ' + l line number 1',
+ ' + c column 0',
+ ' # Value is negative',
+ ' + n name -10',
+ }, ([[ [{'type': 11, 'timestamp': 0, 'data': {
+ 'n': -10,
+ 'f': {'_TYPE': v:msgpack_types.binary, '_VAL': ["\n"]},
+ }}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Change with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' + f file name "foo"',
+ ' # Value is negative',
+ ' + l line number -10',
+ ' # Value is negative',
+ ' + c column -10',
+ }, ([[ [{'type': 11, 'timestamp': 0, 'data': {
+ 'f': 'foo',
+ 'l': -10,
+ 'c': -10,
+ }}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Change with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' + f file name "foo"',
+ ' # Expected integer',
+ ' + l line number "FOO"',
+ ' # Expected integer',
+ ' + c column "foo"',
+ ' + mX 10',
+ }, ([[ [{'type': 11, 'timestamp': 0, 'data': {
+ 'f': 'foo',
+ 'l': 'FOO',
+ 'c': 'foo',
+ 'mX': 10,
+ }}] ]]):gsub('\n', ''))
+ sd2strings_eq({
+ 'Change with timestamp ' .. epoch .. ':',
+ ' % Key________ Description Value',
+ ' + f file name "foo"',
+ ' + l line number 2',
+ ' + c column 200',
+ ' + mX 10',
+ ' + mYYYYYYYYYY 10',
+ ' + n name \' \'',
+ }, ([[ [{'type': 11, 'timestamp': 0, 'data': {
+ 'n': 0x20,
+ 'f': 'foo',
+ 'l': 2,
+ 'c': 200,
+ 'mX': 10,
+ 'mYYYYYYYYYY': 10,
+ }}] ]]):gsub('\n', ''))
+ end)
+ end)
+
+ describe('function shada#get_strings', function()
+ it('works', function()
+ eq({
+ 'Header with timestamp ' .. epoch .. ':',
+ ' % Key Value',
+ }, nvim_eval('shada#get_strings(msgpackdump([1, 0, 0, {}]))'))
+ end)
+ end)
+
+ describe('function shada#strings_to_sd', function()
+
+ local strings2sd_eq = function(expected, input)
+ nvim('set_var', '__input', input)
+ nvim_command('let g:__actual = map(shada#strings_to_sd(g:__input), '
+ .. '"filter(v:val, \\"v:key[0] isnot# \'_\' '
+ .. '&& v:key isnot# \'length\'\\")")')
+ -- print()
+ if type(expected) == 'table' then
+ nvim('set_var', '__expected', expected)
+ nvim_command('let g:__expected = ModifyVal(g:__expected)')
+ expected = 'g:__expected'
+ -- print(nvim_eval('msgpack#string(g:__expected)'))
+ end
+ -- print(nvim_eval('msgpack#string(g:__actual)'))
+ eq(1, nvim_eval(('msgpack#equal(%s, g:__actual)'):format(expected)))
+ if type(expected) == 'table' then
+ nvim_command('unlet g:__expected')
+ end
+ nvim_command('unlet g:__input')
+ nvim_command('unlet g:__actual')
+ end
+
+ assert:set_parameter('TableFormatLevel', 100)
+
+ it('works with multiple items', function()
+ strings2sd_eq({{
+ type=11, timestamp=0, data={
+ f='foo',
+ l=2,
+ c=200,
+ mX=10,
+ mYYYYYYYYYY=10,
+ n=(' '):byte(),
+ }
+ }, {
+ type=1, timestamp=0, data={
+ c='abc',
+ f={'!binary', {'abc\ndef'}},
+ l=-10,
+ n=-64,
+ rc='10',
+ rt=10,
+ sc={'!nil', 0},
+ sm='TRUE',
+ so='TRUE',
+ sp={'!string', {'abc'}},
+ }
+ }}, {
+ 'Change with timestamp ' .. epoch .. ':',
+ ' % Key________ Description Value',
+ ' + f file name "foo"',
+ ' + l line number 2',
+ ' + c column 200',
+ ' + mX 10',
+ ' + mYYYYYYYYYY 10',
+ ' + n name \' \'',
+ 'Header with timestamp ' .. epoch .. ':',
+ ' % Key Description____ Value',
+ ' # Expected integer',
+ ' + c column "abc"',
+ ' # Expected no NUL bytes',
+ ' + f file name "abc\\0def"',
+ ' # Value is negative',
+ ' + l line number -10',
+ ' # Value is negative',
+ ' + n name -64',
+ ' # Expected array value',
+ ' + rc contents "10"',
+ ' # Unexpected enum value: expected one of '
+ .. '0 (CHARACTERWISE), 1 (LINEWISE), 2 (BLOCKWISE)',
+ ' + rt type 10',
+ ' # Expected boolean',
+ ' + sc smartcase value NIL',
+ ' # Expected boolean',
+ ' + sm magic value "TRUE"',
+ ' # Expected integer',
+ ' + so offset value "TRUE"',
+ ' # Expected binary string',
+ ' + sp pattern ="abc"',
+ })
+ end)
+
+ it('works with empty list', function()
+ strings2sd_eq({}, {})
+ end)
+
+ it('works with header items', function()
+ strings2sd_eq({{type=1, timestamp=0, data={
+ generator='test',
+ }}}, {
+ 'Header with timestamp ' .. epoch .. ':',
+ ' % Key______ Value',
+ ' + generator "test"',
+ })
+ strings2sd_eq({{type=1, timestamp=0, data={
+ 1, 2, 3,
+ }}}, {
+ 'Header with timestamp ' .. epoch .. ':',
+ ' # Unexpected type: array instead of map',
+ ' = [1, 2, 3]',
+ })
+ strings2sd_eq({{type=1, timestamp=0, data={
+ a=1, b=2, c=3, d=4,
+ }}}, {
+ 'Header with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' + a 1',
+ ' + b 2',
+ ' + c column 3',
+ ' + d 4',
+ })
+ strings2sd_eq({{type=1, timestamp=0, data={
+ c='abc',
+ f={'!binary', {'abc\ndef'}},
+ l=-10,
+ n=-64,
+ rc='10',
+ rt=10,
+ sc={'!nil', 0},
+ sm='TRUE',
+ so='TRUE',
+ sp={'!string', {'abc'}},
+ }}}, {
+ 'Header with timestamp ' .. epoch .. ':',
+ ' % Key Description____ Value',
+ ' # Expected integer',
+ ' + c column "abc"',
+ ' # Expected no NUL bytes',
+ ' + f file name "abc\\0def"',
+ ' # Value is negative',
+ ' + l line number -10',
+ ' # Value is negative',
+ ' + n name -64',
+ ' # Expected array value',
+ ' + rc contents "10"',
+ ' # Unexpected enum value: expected one of '
+ .. '0 (CHARACTERWISE), 1 (LINEWISE), 2 (BLOCKWISE)',
+ ' + rt type 10',
+ ' # Expected boolean',
+ ' + sc smartcase value NIL',
+ ' # Expected boolean',
+ ' + sm magic value "TRUE"',
+ ' # Expected integer',
+ ' + so offset value "TRUE"',
+ ' # Expected binary string',
+ ' + sp pattern ="abc"',
+ })
+ end)
+
+ it('works with search pattern items', function()
+ strings2sd_eq({{type=2, timestamp=0, data={
+ 1, 2, 3
+ }}}, {
+ 'Search pattern with timestamp ' .. epoch .. ':',
+ ' # Unexpected type: array instead of map',
+ ' = [1, 2, 3]',
+ })
+ strings2sd_eq({{type=2, timestamp=0, data={
+ sp='abc',
+ }}}, {
+ 'Search pattern with timestamp ' .. epoch .. ':',
+ ' % Key Description________ Value',
+ ' + sp pattern "abc"',
+ ' + sh v:hlsearch value FALSE',
+ ' + ss is :s pattern FALSE',
+ ' + sm magic value TRUE',
+ ' + sc smartcase value FALSE',
+ ' + sl has line offset FALSE',
+ ' + se place cursor at end FALSE',
+ ' + so offset value 0',
+ ' + su is last used TRUE',
+ })
+ strings2sd_eq({{type=2, timestamp=0, data={
+ sp='abc',
+ sX={'!nil', 0},
+ sY={'!nil', 0},
+ sZ={'!nil', 0},
+ }}}, {
+ 'Search pattern with timestamp ' .. epoch .. ':',
+ ' % Key Description________ Value',
+ ' + sp pattern "abc"',
+ ' + sh v:hlsearch value FALSE',
+ ' + ss is :s pattern FALSE',
+ ' + sm magic value TRUE',
+ ' + sc smartcase value FALSE',
+ ' + sl has line offset FALSE',
+ ' + se place cursor at end FALSE',
+ ' + so offset value 0',
+ ' + su is last used TRUE',
+ ' + sX NIL',
+ ' + sY NIL',
+ ' + sZ NIL',
+ })
+ strings2sd_eq({{type=2, timestamp=0, data={'!map', {
+ }}}}, {
+ 'Search pattern with timestamp ' .. epoch .. ':',
+ ' % Key Description________ Value',
+ ' # Required key missing: sp',
+ ' + sh v:hlsearch value FALSE',
+ ' + ss is :s pattern FALSE',
+ ' + sm magic value TRUE',
+ ' + sc smartcase value FALSE',
+ ' + sl has line offset FALSE',
+ ' + se place cursor at end FALSE',
+ ' + so offset value 0',
+ ' + su is last used TRUE',
+ })
+ strings2sd_eq({{type=2, timestamp=0, data={
+ sp='',
+ sh={'!boolean', 1},
+ ss={'!boolean', 1},
+ sc={'!boolean', 1},
+ sl={'!boolean', 1},
+ se={'!boolean', 1},
+ sm={'!boolean', 0},
+ su={'!boolean', 0},
+ so=-10,
+ }}}, {
+ 'Search pattern with timestamp ' .. epoch .. ':',
+ ' % Key Description________ Value',
+ ' + sp pattern ""',
+ ' + sh v:hlsearch value TRUE',
+ ' + ss is :s pattern TRUE',
+ ' + sm magic value FALSE',
+ ' + sc smartcase value TRUE',
+ ' + sl has line offset TRUE',
+ ' + se place cursor at end TRUE',
+ ' + so offset value -10',
+ ' + su is last used FALSE',
+ })
+ strings2sd_eq({{type=2, timestamp=0, data={
+ sp=0,
+ sh=0,
+ ss=0,
+ sc=0,
+ sl=0,
+ se=0,
+ sm=0,
+ su=0,
+ so='',
+ }}}, {
+ 'Search pattern with timestamp ' .. epoch .. ':',
+ ' % Key Description________ Value',
+ ' # Expected binary string',
+ ' + sp pattern 0',
+ ' # Expected boolean',
+ ' + sh v:hlsearch value 0',
+ ' # Expected boolean',
+ ' + ss is :s pattern 0',
+ ' # Expected boolean',
+ ' + sm magic value 0',
+ ' # Expected boolean',
+ ' + sc smartcase value 0',
+ ' # Expected boolean',
+ ' + sl has line offset 0',
+ ' # Expected boolean',
+ ' + se place cursor at end 0',
+ ' # Expected integer',
+ ' + so offset value ""',
+ ' # Expected boolean',
+ ' + su is last used 0',
+ })
+ end)
+
+ it('works with replacement string items', function()
+ strings2sd_eq({{type=3, timestamp=0, data={
+ a={10}
+ }}}, {
+ 'Replacement string with timestamp ' .. epoch .. ':',
+ ' # Unexpected type: map instead of array',
+ ' = {="a": [10]}',
+ })
+ strings2sd_eq({{type=3, timestamp=0, data={
+ }}}, {
+ 'Replacement string with timestamp ' .. epoch .. ':',
+ ' @ Description__________ Value',
+ ' # Expected more elements in list'
+ })
+ strings2sd_eq({{type=3, timestamp=0, data={
+ 0
+ }}}, {
+ 'Replacement string with timestamp ' .. epoch .. ':',
+ ' @ Description__________ Value',
+ ' # Expected binary string',
+ ' - :s replacement string 0',
+ })
+ strings2sd_eq({{type=3, timestamp=0, data={
+ 'abc\ndef', 0,
+ }}}, {
+ 'Replacement string with timestamp ' .. epoch .. ':',
+ ' @ Description__________ Value',
+ ' - :s replacement string "abc\\ndef"',
+ ' - 0',
+ })
+ strings2sd_eq({{type=3, timestamp=0, data={
+ 'abc\ndef',
+ }}}, {
+ 'Replacement string with timestamp ' .. epoch .. ':',
+ ' @ Description__________ Value',
+ ' - :s replacement string "abc\\ndef"',
+ })
+ end)
+
+ it('works with history entry items', function()
+ strings2sd_eq({{type=4, timestamp=0, data={
+ a={10},
+ }}}, {
+ 'History entry with timestamp ' .. epoch .. ':',
+ ' # Unexpected type: map instead of array',
+ ' = {="a": [10]}',
+ })
+ strings2sd_eq({{type=4, timestamp=0, data={
+ }}}, {
+ 'History entry with timestamp ' .. epoch .. ':',
+ ' @ Description_ Value',
+ ' # Expected more elements in list'
+ })
+ strings2sd_eq({{type=4, timestamp=0, data={
+ '',
+ }}}, {
+ 'History entry with timestamp ' .. epoch .. ':',
+ ' @ Description_ Value',
+ ' # Expected integer',
+ ' - history type ""',
+ ' # Expected more elements in list'
+ })
+ strings2sd_eq({{type=4, timestamp=0, data={
+ 5, '',
+ }}}, {
+ 'History entry with timestamp ' .. epoch .. ':',
+ ' @ Description_ Value',
+ ' # Unexpected enum value: expected one of 0 (CMD), 1 (SEARCH), '
+ .. '2 (EXPR), 3 (INPUT), 4 (DEBUG)',
+ ' - history type 5',
+ ' - contents ""',
+ })
+ strings2sd_eq({{type=4, timestamp=0, data={
+ 5, '', 32,
+ }}}, {
+ 'History entry with timestamp ' .. epoch .. ':',
+ ' @ Description_ Value',
+ ' # Unexpected enum value: expected one of 0 (CMD), 1 (SEARCH), '
+ .. '2 (EXPR), 3 (INPUT), 4 (DEBUG)',
+ ' - history type 5',
+ ' - contents ""',
+ ' - 32',
+ })
+ strings2sd_eq({{type=4, timestamp=0, data={
+ 0, '', 32,
+ }}}, {
+ 'History entry with timestamp ' .. epoch .. ':',
+ ' @ Description_ Value',
+ ' - history type CMD',
+ ' - contents ""',
+ ' - 32',
+ })
+ strings2sd_eq({{type=4, timestamp=0, data={
+ 1, '', 32,
+ }}}, {
+ 'History entry with timestamp ' .. epoch .. ':',
+ ' @ Description_ Value',
+ ' - history type SEARCH',
+ ' - contents ""',
+ ' - separator \' \'',
+ })
+ strings2sd_eq({{type=4, timestamp=0, data={
+ 1, '',
+ }}}, {
+ 'History entry with timestamp ' .. epoch .. ':',
+ ' @ Description_ Value',
+ ' - history type SEARCH',
+ ' - contents ""',
+ ' # Expected more elements in list',
+ })
+ strings2sd_eq({{type=4, timestamp=0, data={
+ 2, '',
+ }}}, {
+ 'History entry with timestamp ' .. epoch .. ':',
+ ' @ Description_ Value',
+ ' - history type EXPR',
+ ' - contents ""',
+ })
+ strings2sd_eq({{type=4, timestamp=0, data={
+ 3, ''
+ }}}, {
+ 'History entry with timestamp ' .. epoch .. ':',
+ ' @ Description_ Value',
+ ' - history type INPUT',
+ ' - contents ""',
+ })
+ strings2sd_eq({{type=4, timestamp=0, data={
+ 4, ''
+ }}}, {
+ 'History entry with timestamp ' .. epoch .. ':',
+ ' @ Description_ Value',
+ ' - history type DEBUG',
+ ' - contents ""',
+ })
+ end)
+
+ it('works with register items', function()
+ strings2sd_eq({{type=5, timestamp=0, data={
+ 1, 2, 3
+ }}}, {
+ 'Register with timestamp ' .. epoch .. ':',
+ ' # Unexpected type: array instead of map',
+ ' = [1, 2, 3]',
+ })
+ strings2sd_eq({{type=5, timestamp=0, data={'!map', {
+ }}}}, {
+ 'Register with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' # Required key missing: n',
+ ' # Required key missing: rc',
+ ' + rw block width 0',
+ ' + rt type CHARACTERWISE',
+ })
+ strings2sd_eq({{type=5, timestamp=0, data={
+ n=(' '):byte()
+ }}}, {
+ 'Register with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' + n name \' \'',
+ ' # Required key missing: rc',
+ ' + rw block width 0',
+ ' + rt type CHARACTERWISE',
+ })
+ strings2sd_eq({{type=5, timestamp=0, data={
+ n=(' '):byte(), rc={'abc', 'def'}
+ }}}, {
+ 'Register with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' + n name \' \'',
+ ' + rc contents ["abc", "def"]',
+ ' + rw block width 0',
+ ' + rt type CHARACTERWISE',
+ })
+ strings2sd_eq({{type=5, timestamp=0, data={
+ n=(' '):byte(),
+ rc={'abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz'},
+ }}}, {
+ 'Register with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' + n name \' \'',
+ ' + rc contents @',
+ ' | - "abcdefghijklmnopqrstuvwxyz"',
+ ' | - "abcdefghijklmnopqrstuvwxyz"',
+ ' + rw block width 0',
+ ' + rt type CHARACTERWISE',
+ })
+ strings2sd_eq({{type=5, timestamp=0, data={
+ n=(' '):byte(),
+ rc={'abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz'},
+ rw=5,
+ rt=1,
+ }}}, {
+ 'Register with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' + n name \' \'',
+ ' + rc contents @',
+ ' | - "abcdefghijklmnopqrstuvwxyz"',
+ ' | - "abcdefghijklmnopqrstuvwxyz"',
+ ' + rw block width 5',
+ ' + rt type LINEWISE',
+ })
+ strings2sd_eq({{type=5, timestamp=0, data={
+ n=(' '):byte(),
+ rc={'abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz'},
+ rw=5,
+ rt=2,
+ }}}, {
+ 'Register with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' + n name \' \'',
+ ' + rc contents @',
+ ' | - "abcdefghijklmnopqrstuvwxyz"',
+ ' | - "abcdefghijklmnopqrstuvwxyz"',
+ ' + rw block width 5',
+ ' + rt type BLOCKWISE',
+ })
+ strings2sd_eq({{type=5, timestamp=0, data={
+ n=(' '):byte(),
+ rc=0,
+ rw=-1,
+ rt=10,
+ }}}, {
+ 'Register with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' + n name \' \'',
+ ' # Expected array value',
+ ' + rc contents 0',
+ ' # Value is negative',
+ ' + rw block width -1',
+ ' # Unexpected enum value: expected one of 0 (CHARACTERWISE), '
+ .. '1 (LINEWISE), 2 (BLOCKWISE)',
+ ' + rt type 10',
+ })
+ end)
+
+ it('works with variable items', function()
+ strings2sd_eq({{type=6, timestamp=0, data={
+ a={10}
+ }}}, {
+ 'Variable with timestamp ' .. epoch .. ':',
+ ' # Unexpected type: map instead of array',
+ ' = {="a": [10]}',
+ })
+ strings2sd_eq({{type=6, timestamp=0, data={
+ }}}, {
+ 'Variable with timestamp ' .. epoch .. ':',
+ ' @ Description Value',
+ ' # Expected more elements in list'
+ })
+ strings2sd_eq({{type=6, timestamp=0, data={
+ 'foo',
+ }}}, {
+ 'Variable with timestamp ' .. epoch .. ':',
+ ' @ Description Value',
+ ' - name "foo"',
+ ' # Expected more elements in list',
+ })
+ strings2sd_eq({{type=6, timestamp=0, data={
+ 'foo', {'!nil', 0},
+ }}}, {
+ 'Variable with timestamp ' .. epoch .. ':',
+ ' @ Description Value',
+ ' - name "foo"',
+ ' - value NIL',
+ })
+ strings2sd_eq({{type=6, timestamp=0, data={
+ 'foo', {'!nil', 0}, {'!nil', 0}
+ }}}, {
+ 'Variable with timestamp ' .. epoch .. ':',
+ ' @ Description Value',
+ ' - name "foo"',
+ ' - value NIL',
+ ' - NIL',
+ })
+ end)
+
+ it('works with global mark items', function()
+ strings2sd_eq({{type=7, timestamp=0, data={
+ 1, 2, 3
+ }}}, {
+ 'Global mark with timestamp ' .. epoch .. ':',
+ ' # Unexpected type: array instead of map',
+ ' = [1, 2, 3]',
+ })
+ strings2sd_eq({{type=7, timestamp=0, data={
+ n=('A'):byte(), f='foo', l=2, c=200, mX=10, mYYYYYYYYYY=10,
+ }}}, {
+ 'Global mark with timestamp ' .. epoch .. ':',
+ ' % Key________ Description Value',
+ ' + n name \'A\'',
+ ' + f file name "foo"',
+ ' + l line number 2',
+ ' + c column 200',
+ ' + mX 10',
+ ' + mYYYYYYYYYY 10',
+ })
+ end)
+
+ it('works with jump items', function()
+ strings2sd_eq({{type=8, timestamp=0, data={
+ 1, 2, 3
+ }}}, {
+ 'Jump with timestamp ' .. epoch .. ':',
+ ' # Unexpected type: array instead of map',
+ ' = [1, 2, 3]',
+ })
+ strings2sd_eq({{type=8, timestamp=0, data={
+ n=('A'):byte(), f='foo', l=2, c=200, mX=10, mYYYYYYYYYY=10,
+ }}}, {
+ 'Jump with timestamp ' .. epoch .. ':',
+ ' % Key________ Description Value',
+ ' + n name \'A\'',
+ ' + f file name "foo"',
+ ' + l line number 2',
+ ' + c column 200',
+ ' + mX 10',
+ ' + mYYYYYYYYYY 10',
+ })
+ end)
+
+ it('works with buffer list items', function()
+ strings2sd_eq({{type=9, timestamp=0, data={
+ a={10}
+ }}}, {
+ 'Buffer list with timestamp ' .. epoch .. ':',
+ ' # Unexpected type: map instead of array',
+ ' = {="a": [10]}',
+ })
+ strings2sd_eq({{type=9, timestamp=0, data={
+ {a=10}, {}
+ }}}, {
+ 'Buffer list with timestamp ' .. epoch .. ':',
+ ' # Expected array of maps',
+ ' = [{="a": 10}, []]',
+ })
+ strings2sd_eq({{type=9, timestamp=0, data={
+ {a=10},
+ }}}, {
+ 'Buffer list with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' # Required key missing: f',
+ ' + l line number 1',
+ ' + c column 0',
+ ' + a 10',
+ })
+ strings2sd_eq({{type=9, timestamp=0, data={
+ {l='10', c='10', a=10},
+ }}}, {
+ 'Buffer list with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' # Required key missing: f',
+ ' # Expected integer',
+ ' + l line number "10"',
+ ' # Expected integer',
+ ' + c column "10"',
+ ' + a 10',
+ })
+ strings2sd_eq({{type=9, timestamp=0, data={
+ {l=10, c=10, a=10},
+ }}}, {
+ 'Buffer list with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' # Required key missing: f',
+ ' + l line number 10',
+ ' + c column 10',
+ ' + a 10',
+ })
+ strings2sd_eq({{type=9, timestamp=0, data={
+ {l=-10, c=-10},
+ }}}, {
+ 'Buffer list with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' # Required key missing: f',
+ ' # Value is negative',
+ ' + l line number -10',
+ ' # Value is negative',
+ ' + c column -10',
+ })
+ strings2sd_eq({{type=9, timestamp=0, data={
+ {f='abc'},
+ }}}, {
+ 'Buffer list with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' + f file name "abc"',
+ ' + l line number 1',
+ ' + c column 0',
+ })
+ strings2sd_eq({{type=9, timestamp=0, data={
+ {f=10}, {f=20},
+ }}}, {
+ 'Buffer list with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' # Expected binary string',
+ ' + f file name 10',
+ ' + l line number 1',
+ ' + c column 0',
+ '',
+ ' % Key Description Value',
+ ' # Expected binary string',
+ ' + f file name 20',
+ ' + l line number 1',
+ ' + c column 0',
+ })
+ strings2sd_eq({{type=9, timestamp=0, data={
+ {f=10}, {f={'!binary', {'\n'}}},
+ }}}, {
+ 'Buffer list with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' # Expected binary string',
+ ' + f file name 10',
+ ' + l line number 1',
+ ' + c column 0',
+ '',
+ ' % Key Description Value',
+ ' # Expected no NUL bytes',
+ ' + f file name "\\0"',
+ ' + l line number 1',
+ ' + c column 0',
+ })
+ end)
+
+ it('works with local mark items', function()
+ strings2sd_eq({{type=10, timestamp=0, data={
+ 1, 2, 3
+ }}}, {
+ 'Local mark with timestamp ' .. epoch .. ':',
+ ' # Unexpected type: array instead of map',
+ ' = [1, 2, 3]',
+ })
+ strings2sd_eq({{type=10, timestamp=0, data={
+ n=('A'):byte(), f='foo', l=2, c=200, mX=10, mYYYYYYYYYY=10,
+ }}}, {
+ 'Local mark with timestamp ' .. epoch .. ':',
+ ' % Key________ Description Value',
+ ' + n name \'A\'',
+ ' + f file name "foo"',
+ ' + l line number 2',
+ ' + c column 200',
+ ' + mX 10',
+ ' + mYYYYYYYYYY 10',
+ })
+ end)
+
+ it('works with change items', function()
+ strings2sd_eq({{type=11, timestamp=0, data={
+ 1, 2, 3
+ }}}, {
+ 'Change with timestamp ' .. epoch .. ':',
+ ' # Unexpected type: array instead of map',
+ ' = [1, 2, 3]',
+ })
+ strings2sd_eq({{type=11, timestamp=0, data={
+ n=('A'):byte(), f='foo', l=2, c=200, mX=10, mYYYYYYYYYY=10,
+ }}}, {
+ 'Change with timestamp ' .. epoch .. ':',
+ ' % Key________ Description Value',
+ ' + n name \'A\'',
+ ' + f file name "foo"',
+ ' + l line number 2',
+ ' + c column 200',
+ ' + mX 10',
+ ' + mYYYYYYYYYY 10',
+ })
+ end)
+ end)
+
+ describe('function shada#get_binstrings', function()
+ local getbstrings_eq = function(expected, input)
+ local result = funcs['shada#get_binstrings'](input)
+ for i, s in ipairs(result) do
+ result[i] = s:gsub('\n', '\0')
+ end
+ local mpack_result = table.concat(result, '\n')
+ return mpack_eq(expected, mpack_result)
+ end
+
+ it('works', function()
+ getbstrings_eq({{timestamp='current', type=1, value={
+ generator='shada.vim',
+ version=704,
+ }}}, {})
+ getbstrings_eq({
+ {timestamp='current', type=1, value={
+ generator='shada.vim', version=704
+ }},
+ {timestamp=0, type=1, value={generator='test'}}
+ }, {
+ 'Header with timestamp ' .. epoch .. ':',
+ ' % Key______ Value',
+ ' + generator "test"',
+ })
+ nvim('set_var', 'shada#add_own_header', 1)
+ getbstrings_eq({{timestamp='current', type=1, value={
+ generator='shada.vim',
+ version=704,
+ }}}, {})
+ getbstrings_eq({
+ {timestamp='current', type=1, value={
+ generator='shada.vim', version=704
+ }},
+ {timestamp=0, type=1, value={generator='test'}}
+ }, {
+ 'Header with timestamp ' .. epoch .. ':',
+ ' % Key______ Value',
+ ' + generator "test"',
+ })
+ nvim('set_var', 'shada#add_own_header', 0)
+ getbstrings_eq({}, {})
+ getbstrings_eq({{timestamp=0, type=1, value={generator='test'}}}, {
+ 'Header with timestamp ' .. epoch .. ':',
+ ' % Key______ Value',
+ ' + generator "test"',
+ })
+ nvim('set_var', 'shada#keep_old_header', 0)
+ getbstrings_eq({}, {
+ 'Header with timestamp ' .. epoch .. ':',
+ ' % Key______ Value',
+ ' + generator "test"',
+ })
+ getbstrings_eq({
+ {type=3, timestamp=0, value={'abc\ndef'}},
+ {type=3, timestamp=0, value={'abc\ndef'}},
+ {type=3, timestamp=0, value={'abc\ndef'}},
+ }, {
+ 'Replacement string with timestamp ' .. epoch .. ':',
+ ' @ Description__________ Value',
+ ' - :s replacement string "abc\\ndef"',
+ 'Replacement string with timestamp ' .. epoch .. ':',
+ ' @ Description__________ Value',
+ ' - :s replacement string "abc\\ndef"',
+ 'Replacement string with timestamp ' .. epoch .. ':',
+ ' @ Description__________ Value',
+ ' - :s replacement string "abc\\ndef"',
+ })
+ end)
+ end)
+end)
+
+describe('In plugin/shada.vim', function()
+ local epoch = os.date('%Y-%m-%dT%H:%M:%S', 0)
+ before_each(function()
+ reset()
+ os.remove(fname)
+ os.remove(fname .. '.tst')
+ os.remove(fname_tmp)
+ end)
+
+ teardown(function()
+ os.remove(fname)
+ os.remove(fname_tmp)
+ end)
+
+ local shada_eq = function(expected, fname_)
+ local fd = io.open(fname_)
+ local mpack_result = fd:read('*a')
+ fd:close()
+ mpack_eq(expected, mpack_result)
+ end
+
+ describe('event BufReadCmd', function()
+ it('works', function()
+ wshada('\004\000\009\147\000\196\002ab\196\001a')
+ wshada_tmp('\004\000\009\147\000\196\002ab\196\001b')
+ nvim_command('edit ' .. fname)
+ eq({
+ 'History entry with timestamp ' .. epoch .. ':',
+ ' @ Description_ Value',
+ ' - history type CMD',
+ ' - contents "ab"',
+ ' - "a"',
+ }, nvim_eval('getline(1, "$")'))
+ eq(false, curbuf('get_option', 'modified'))
+ eq('shada', curbuf('get_option', 'filetype'))
+ nvim_command('edit ' .. fname_tmp)
+ eq({
+ 'History entry with timestamp ' .. epoch .. ':',
+ ' @ Description_ Value',
+ ' - history type CMD',
+ ' - contents "ab"',
+ ' - "b"',
+ }, nvim_eval('getline(1, "$")'))
+ eq(false, curbuf('get_option', 'modified'))
+ eq('shada', curbuf('get_option', 'filetype'))
+ eq('++opt not supported', exc_exec('edit ++enc=latin1 ' .. fname))
+ neq({
+ 'History entry with timestamp ' .. epoch .. ':',
+ ' @ Description_ Value',
+ ' - history type CMD',
+ ' - contents "ab"',
+ ' - "a"',
+ }, nvim_eval('getline(1, "$")'))
+ neq(true, curbuf('get_option', 'modified'))
+ end)
+ end)
+
+ describe('event FileReadCmd', function()
+ it('works', function()
+ wshada('\004\000\009\147\000\196\002ab\196\001a')
+ wshada_tmp('\004\000\009\147\000\196\002ab\196\001b')
+ nvim_command('$read ' .. fname)
+ eq({
+ '',
+ 'History entry with timestamp ' .. epoch .. ':',
+ ' @ Description_ Value',
+ ' - history type CMD',
+ ' - contents "ab"',
+ ' - "a"',
+ }, nvim_eval('getline(1, "$")'))
+ eq(true, curbuf('get_option', 'modified'))
+ neq('shada', curbuf('get_option', 'filetype'))
+ nvim_command('1,$read ' .. fname_tmp)
+ eq({
+ '',
+ 'History entry with timestamp ' .. epoch .. ':',
+ ' @ Description_ Value',
+ ' - history type CMD',
+ ' - contents "ab"',
+ ' - "a"',
+ 'History entry with timestamp ' .. epoch .. ':',
+ ' @ Description_ Value',
+ ' - history type CMD',
+ ' - contents "ab"',
+ ' - "b"',
+ }, nvim_eval('getline(1, "$")'))
+ eq(true, curbuf('get_option', 'modified'))
+ neq('shada', curbuf('get_option', 'filetype'))
+ curbuf('set_option', 'modified', false)
+ eq('++opt not supported', exc_exec('$read ++enc=latin1 ' .. fname))
+ eq({
+ '',
+ 'History entry with timestamp ' .. epoch .. ':',
+ ' @ Description_ Value',
+ ' - history type CMD',
+ ' - contents "ab"',
+ ' - "a"',
+ 'History entry with timestamp ' .. epoch .. ':',
+ ' @ Description_ Value',
+ ' - history type CMD',
+ ' - contents "ab"',
+ ' - "b"',
+ }, nvim_eval('getline(1, "$")'))
+ neq(true, curbuf('get_option', 'modified'))
+ end)
+ end)
+
+ describe('event BufWriteCmd', function()
+ it('works', function()
+ nvim('set_var', 'shada#add_own_header', 0)
+ curbuf('set_line_slice', 0, 0, true, true, {
+ 'Jump with timestamp ' .. epoch .. ':',
+ ' % Key________ Description Value',
+ ' + n name \'A\'',
+ ' + f file name ["foo"]',
+ ' + l line number 2',
+ ' + c column -200',
+ 'Jump with timestamp ' .. epoch .. ':',
+ ' % Key________ Description Value',
+ ' + n name \'A\'',
+ ' + f file name ["foo"]',
+ ' + l line number 2',
+ ' + c column -200',
+ })
+ nvim_command('w ' .. fname .. '.tst')
+ nvim_command('w ' .. fname)
+ nvim_command('w ' .. fname_tmp)
+ eq('++opt not supported', exc_exec('w! ++enc=latin1 ' .. fname))
+ eq(table.concat({
+ 'Jump with timestamp ' .. epoch .. ':',
+ ' % Key________ Description Value',
+ ' + n name \'A\'',
+ ' + f file name ["foo"]',
+ ' + l line number 2',
+ ' + c column -200',
+ 'Jump with timestamp ' .. epoch .. ':',
+ ' % Key________ Description Value',
+ ' + n name \'A\'',
+ ' + f file name ["foo"]',
+ ' + l line number 2',
+ ' + c column -200',
+ }, '\n') .. '\n', io.open(fname .. '.tst'):read('*a'))
+ shada_eq({{
+ timestamp=0,
+ type=8,
+ value={c=-200, f={'foo'}, l=2, n=('A'):byte()},
+ }, {
+ timestamp=0,
+ type=8,
+ value={c=-200, f={'foo'}, l=2, n=('A'):byte()},
+ }}, fname)
+ shada_eq({{
+ timestamp=0,
+ type=8,
+ value={c=-200, f={'foo'}, l=2, n=('A'):byte()},
+ }, {
+ timestamp=0,
+ type=8,
+ value={c=-200, f={'foo'}, l=2, n=('A'):byte()},
+ }}, fname_tmp)
+ end)
+ end)
+
+ describe('event FileWriteCmd', function()
+ it('works', function()
+ nvim('set_var', 'shada#add_own_header', 0)
+ curbuf('set_line_slice', 0, 0, true, true, {
+ 'Jump with timestamp ' .. epoch .. ':',
+ ' % Key________ Description Value',
+ ' + n name \'A\'',
+ ' + f file name ["foo"]',
+ ' + l line number 2',
+ ' + c column -200',
+ 'Jump with timestamp ' .. epoch .. ':',
+ ' % Key________ Description Value',
+ ' + n name \'A\'',
+ ' + f file name ["foo"]',
+ ' + l line number 2',
+ ' + c column -200',
+ })
+ nvim_command('1,3w ' .. fname .. '.tst')
+ nvim_command('1,3w ' .. fname)
+ nvim_command('1,3w ' .. fname_tmp)
+ eq('++opt not supported', exc_exec('1,3w! ++enc=latin1 ' .. fname))
+ eq(table.concat({
+ 'Jump with timestamp ' .. epoch .. ':',
+ ' % Key________ Description Value',
+ ' + n name \'A\'',
+ }, '\n') .. '\n', io.open(fname .. '.tst'):read('*a'))
+ shada_eq({{
+ timestamp=0,
+ type=8,
+ value={n=('A'):byte()},
+ }}, fname)
+ shada_eq({{
+ timestamp=0,
+ type=8,
+ value={n=('A'):byte()},
+ }}, fname_tmp)
+ end)
+ end)
+
+ describe('event FileAppendCmd', function()
+ it('works', function()
+ nvim('set_var', 'shada#add_own_header', 0)
+ curbuf('set_line_slice', 0, 0, true, true, {
+ 'Jump with timestamp ' .. epoch .. ':',
+ ' % Key________ Description Value',
+ ' + n name \'A\'',
+ ' + f file name ["foo"]',
+ ' + l line number 2',
+ ' + c column -200',
+ 'Jump with timestamp ' .. epoch .. ':',
+ ' % Key________ Description Value',
+ ' + n name \'A\'',
+ ' + f file name ["foo"]',
+ ' + l line number 2',
+ ' + c column -200',
+ })
+ funcs.writefile({''}, fname .. '.tst', 'b')
+ funcs.writefile({''}, fname, 'b')
+ funcs.writefile({''}, fname_tmp, 'b')
+ nvim_command('1,3w >> ' .. fname .. '.tst')
+ nvim_command('1,3w >> ' .. fname)
+ nvim_command('1,3w >> ' .. fname_tmp)
+ nvim_command('w >> ' .. fname .. '.tst')
+ nvim_command('w >> ' .. fname)
+ nvim_command('w >> ' .. fname_tmp)
+ eq('++opt not supported', exc_exec('1,3w! ++enc=latin1 >> ' .. fname))
+ eq(table.concat({
+ 'Jump with timestamp ' .. epoch .. ':',
+ ' % Key________ Description Value',
+ ' + n name \'A\'',
+ 'Jump with timestamp ' .. epoch .. ':',
+ ' % Key________ Description Value',
+ ' + n name \'A\'',
+ ' + f file name ["foo"]',
+ ' + l line number 2',
+ ' + c column -200',
+ 'Jump with timestamp ' .. epoch .. ':',
+ ' % Key________ Description Value',
+ ' + n name \'A\'',
+ ' + f file name ["foo"]',
+ ' + l line number 2',
+ ' + c column -200',
+ }, '\n') .. '\n', io.open(fname .. '.tst'):read('*a'))
+ shada_eq({{
+ timestamp=0,
+ type=8,
+ value={n=('A'):byte()},
+ }, {
+ timestamp=0,
+ type=8,
+ value={c=-200, f={'foo'}, l=2, n=('A'):byte()},
+ }, {
+ timestamp=0,
+ type=8,
+ value={c=-200, f={'foo'}, l=2, n=('A'):byte()},
+ }}, fname)
+ shada_eq({{
+ timestamp=0,
+ type=8,
+ value={n=('A'):byte()},
+ }, {
+ timestamp=0,
+ type=8,
+ value={c=-200, f={'foo'}, l=2, n=('A'):byte()},
+ }, {
+ timestamp=0,
+ type=8,
+ value={c=-200, f={'foo'}, l=2, n=('A'):byte()},
+ }}, fname_tmp)
+ end)
+ end)
+
+ describe('event SourceCmd', function()
+ before_each(function()
+ reset(fname)
+ end)
+ it('works', function()
+ wshada('\004\000\006\146\000\196\002ab')
+ wshada_tmp('\004\001\006\146\000\196\002bc')
+ eq(0, exc_exec('source ' .. fname))
+ eq(0, exc_exec('source ' .. fname_tmp))
+ eq('bc', funcs.histget(':', -1))
+ eq('ab', funcs.histget(':', -2))
+ end)
+ end)
+end)
+
+describe('ftplugin/shada.vim', function()
+ local epoch = os.date('%Y-%m-%dT%H:%M:%S', 0)
+ before_each(reset)
+
+ it('sets indentexpr correctly', function()
+ nvim_command('filetype plugin indent on')
+ nvim_command('setlocal filetype=shada')
+ funcs.setline(1, {
+ 'Jump with timestamp ' .. epoch .. ':',
+ '% Key________ Description Value',
+ '+ n name \'A\'',
+ '+ f file name "foo"',
+ '+ l line number 2',
+ '+ c column 200',
+ '+ mX 10',
+ '+ mYYYYYYYYYY 10',
+ 'Register with timestamp ' .. epoch .. ':',
+ '% Key Description Value',
+ '+ n name \' \'',
+ '+ rc contents @',
+ '| - "abcdefghijklmnopqrstuvwxyz"',
+ '| - "abcdefghijklmnopqrstuvwxyz"',
+ '+ rw block width 0',
+ '+ rt type CHARACTERWISE',
+ 'Replacement string with timestamp ' .. epoch .. ':',
+ ' @ Description__________ Value',
+ ' - :s replacement string "abc\\ndef"',
+ ' Buffer list with timestamp ' .. epoch .. ':',
+ ' # Expected array of maps',
+ '= [{="a": 10}, []]',
+ ' Buffer list with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' # Expected binary string',
+ '+ f file name 10',
+ ' + l line number 1',
+ ' + c column 0',
+ '',
+ ' % Key Description Value',
+ ' # Expected binary string',
+ ' + f file name 20',
+ '+ l line number 1',
+ ' + c column 0',
+ })
+ nvim_command('normal! gg=G')
+ eq({
+ 'Jump with timestamp ' .. epoch .. ':',
+ ' % Key________ Description Value',
+ ' + n name \'A\'',
+ ' + f file name "foo"',
+ ' + l line number 2',
+ ' + c column 200',
+ ' + mX 10',
+ ' + mYYYYYYYYYY 10',
+ 'Register with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' + n name \' \'',
+ ' + rc contents @',
+ ' | - "abcdefghijklmnopqrstuvwxyz"',
+ ' | - "abcdefghijklmnopqrstuvwxyz"',
+ ' + rw block width 0',
+ ' + rt type CHARACTERWISE',
+ 'Replacement string with timestamp ' .. epoch .. ':',
+ ' @ Description__________ Value',
+ ' - :s replacement string "abc\\ndef"',
+ 'Buffer list with timestamp ' .. epoch .. ':',
+ ' # Expected array of maps',
+ ' = [{="a": 10}, []]',
+ 'Buffer list with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' # Expected binary string',
+ ' + f file name 10',
+ ' + l line number 1',
+ ' + c column 0',
+ '',
+ ' % Key Description Value',
+ ' # Expected binary string',
+ ' + f file name 20',
+ ' + l line number 1',
+ ' + c column 0',
+ }, funcs.getline(1, funcs.line('$')))
+ end)
+
+ it('sets options correctly', function()
+ nvim_command('filetype plugin indent on')
+ nvim_command('setlocal filetype=shada')
+ eq(true, curbuf('get_option', 'expandtab'))
+ eq(2, curbuf('get_option', 'tabstop'))
+ eq(2, curbuf('get_option', 'softtabstop'))
+ eq(2, curbuf('get_option', 'shiftwidth'))
+ end)
+
+ it('sets indentkeys correctly', function()
+ nvim_command('filetype plugin indent on')
+ nvim_command('setlocal filetype=shada')
+ funcs.setline(1, ' Replacement with timestamp ' .. epoch)
+ nvim_feed('ggA:\027')
+ eq('Replacement with timestamp ' .. epoch .. ':', curbuf('get_line', 0))
+ nvim_feed('o-\027')
+ eq(' -', curbuf('get_line', 1))
+ nvim_feed('ggO+\027')
+ eq('+', curbuf('get_line', 0))
+ nvim_feed('GO*\027')
+ eq(' *', curbuf('get_line', 2))
+ nvim_feed('ggO /\027')
+ eq(' /', curbuf('get_line', 0))
+ nvim_feed('ggOx\027')
+ eq('x', curbuf('get_line', 0))
+ end)
+end)
+
+describe('syntax/shada.vim', function()
+ local epoch = os.date('%Y-%m-%dT%H:%M:%S', 0)
+ before_each(reset)
+
+ it('works', function()
+ nvim_command('syntax on')
+ nvim_command('setlocal syntax=shada')
+ curbuf('set_line_slice', 0, 0, true, true, {
+ 'Header with timestamp ' .. epoch .. ':',
+ ' % Key Value',
+ ' + t "test"',
+ 'Jump with timestamp ' .. epoch .. ':',
+ ' % Key________ Description Value',
+ ' + n name \'A\'',
+ ' + f file name ["foo"]',
+ ' + l line number 2',
+ ' + c column -200',
+ 'Register with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ ' + rc contents @',
+ ' | - {"abcdefghijklmnopqrstuvwxyz": 1.0}',
+ ' + rt type CHARACTERWISE',
+ ' + rt type LINEWISE',
+ ' + rt type BLOCKWISE',
+ 'Replacement string with timestamp ' .. epoch .. ':',
+ ' @ Description__________ Value',
+ ' - :s replacement string CMD',
+ ' - :s replacement string SEARCH',
+ ' - :s replacement string EXPR',
+ ' - :s replacement string INPUT',
+ ' - :s replacement string DEBUG',
+ 'Buffer list with timestamp ' .. epoch .. ':',
+ ' # Expected array of maps',
+ ' = [{="a": +(10)"ac\\0df\\ngi\\"tt\\.", TRUE: FALSE}, [NIL, +(-10)""]]',
+ 'Buffer list with timestamp ' .. epoch .. ':',
+ ' % Key Description Value',
+ '',
+ ' % Key Description Value',
+ 'Header with timestamp ' .. epoch .. ':',
+ ' % Key Description________ Value',
+ ' + se place cursor at end TRUE',
+ })
+ nvim_command([[
+ function GetSyntax()
+ let lines = []
+ for l in range(1, line('$'))
+ let columns = []
+ let line = getline(l)
+ for c in range(1, col([l, '$']) - 1)
+ let synstack = map(synstack(l, c), 'synIDattr(v:val, "name")')
+ if !empty(columns) && columns[-1][0] ==# synstack
+ let columns[-1][1] .= line[c - 1]
+ else
+ call add(columns, [ synstack, line[c - 1] ])
+ endif
+ endfor
+ call add(lines, columns)
+ endfor
+ return lines
+ endfunction
+ ]])
+ local hname = function(s) return {{'ShaDaEntryHeader', 'ShaDaEntryName'},
+ s} end
+ local h = function(s) return {{'ShaDaEntryHeader'}, s} end
+ local htsnum = function(s) return {
+ {'ShaDaEntryHeader', 'ShaDaEntryTimestamp', 'ShaDaEntryTimestampNumber'},
+ s
+ } end
+ local synhtssep = function(s)
+ return {{'ShaDaEntryHeader', 'ShaDaEntryTimestamp'}, s}
+ end
+ local synepoch = {
+ year = htsnum(os.date('%Y', 0)),
+ month = htsnum(os.date('%m', 0)),
+ day = htsnum(os.date('%d', 0)),
+ hour = htsnum(os.date('%H', 0)),
+ minute = htsnum(os.date('%M', 0)),
+ second = htsnum(os.date('%S', 0)),
+ }
+ local msh = function(s) return {{'ShaDaEntryMapShort',
+ 'ShaDaEntryMapHeader'}, s} end
+ local mlh = function(s) return {{'ShaDaEntryMapLong',
+ 'ShaDaEntryMapHeader'}, s} end
+ local ah = function(s) return {{'ShaDaEntryArray',
+ 'ShaDaEntryArrayHeader'}, s} end
+ -- luacheck: ignore
+ local mses = function(s) return {{'ShaDaEntryMapShort',
+ 'ShaDaEntryMapShortEntryStart'}, s} end
+ local mles = function(s) return {{'ShaDaEntryMapLong',
+ 'ShaDaEntryMapLongEntryStart'}, s} end
+ local act = funcs.GetSyntax()
+ local ms = function(syn)
+ return {
+ {'ShaDaEntryMap' .. syn, 'ShaDaEntryMap' .. syn .. 'EntryStart'}, ' + '
+ }
+ end
+ local as = function()
+ return {{'ShaDaEntryArray', 'ShaDaEntryArrayEntryStart'}, ' - '}
+ end
+ local ad = function(s) return {{'ShaDaEntryArray',
+ 'ShaDaEntryArrayDescription'}, s} end
+ local mbas = function(syn)
+ return {
+ {'ShaDaEntryMap' .. syn, 'ShaDaEntryMapBinArrayStart'},
+ ' | - '
+ }
+ end
+ local msk = function(s) return {{'ShaDaEntryMapShort',
+ 'ShaDaEntryMapShortKey'}, s} end
+ local mlk = function(s) return {{'ShaDaEntryMapLong',
+ 'ShaDaEntryMapLongKey'}, s} end
+ local mld = function(s) return {{'ShaDaEntryMapLong',
+ 'ShaDaEntryMapLongDescription'}, s} end
+ local c = function(s) return {{'ShaDaComment'}, s} end
+ local exp = {
+ {
+ hname('Header'), h(' with timestamp '),
+ synepoch.year, synhtssep('-'), synepoch.month, synhtssep('-'),
+ synepoch.day, synhtssep('T'), synepoch.hour, synhtssep(':'),
+ synepoch.minute, synhtssep(':'), synepoch.second, h(':'),
+ },
+ {
+ msh(' % Key Value'),
+ },
+ {
+ ms('Short'), msk('t '),
+ {{'ShaDaEntryMapShort', 'ShaDaMsgpackBinaryString',
+ 'ShaDaMsgpackStringQuotes'}, '"'},
+ {{'ShaDaEntryMapShort', 'ShaDaMsgpackBinaryString'}, 'test'},
+ {{'ShaDaEntryMapShort', 'ShaDaMsgpackStringQuotes'}, '"'},
+ },
+ {
+ hname('Jump'), h(' with timestamp '),
+ synepoch.year, synhtssep('-'), synepoch.month, synhtssep('-'),
+ synepoch.day, synhtssep('T'), synepoch.hour, synhtssep(':'),
+ synepoch.minute, synhtssep(':'), synepoch.second, h(':'),
+ },
+ {
+ mlh(' % Key________ Description Value'),
+ },
+ {
+ ms('Long'), mlk('n '), mld('name '),
+ {{'ShaDaEntryMapLong', 'ShaDaMsgpackCharacter'}, '\'A\''},
+ },
+ {
+ ms('Long'), mlk('f '), mld('file name '),
+ {{'ShaDaEntryMapLong', 'ShaDaMsgpackArray',
+ 'ShaDaMsgpackArrayBraces'}, '['},
+ {{'ShaDaEntryMapLong', 'ShaDaMsgpackArray', 'ShaDaMsgpackBinaryString',
+ 'ShaDaMsgpackStringQuotes'}, '"'},
+ {{'ShaDaEntryMapLong', 'ShaDaMsgpackArray', 'ShaDaMsgpackBinaryString'},
+ 'foo'},
+ {{'ShaDaEntryMapLong', 'ShaDaMsgpackArray', 'ShaDaMsgpackStringQuotes'},
+ '"'},
+ {{'ShaDaEntryMapLong', 'ShaDaMsgpackArrayBraces'}, ']'},
+ },
+ {
+ ms('Long'), mlk('l '), mld('line number '),
+ {{'ShaDaEntryMapLong', 'ShaDaMsgpackInteger'}, '2'},
+ },
+ {
+ ms('Long'), mlk('c '), mld('column '),
+ {{'ShaDaEntryMapLong', 'ShaDaMsgpackInteger'}, '-200'},
+ },
+ {
+ hname('Register'), h(' with timestamp '),
+ synepoch.year, synhtssep('-'), synepoch.month, synhtssep('-'),
+ synepoch.day, synhtssep('T'), synepoch.hour, synhtssep(':'),
+ synepoch.minute, synhtssep(':'), synepoch.second, h(':'),
+ },
+ {
+ mlh(' % Key Description Value'),
+ },
+ {
+ ms('Long'), mlk('rc '), mld('contents '),
+ {{'ShaDaEntryMapLong', 'ShaDaMsgpackMultilineArray'}, '@'},
+ },
+ {
+ mbas('Long'),
+ {{'ShaDaEntryMapLong', 'ShaDaMsgpackMap', 'ShaDaMsgpackMapBraces'},
+ '{'},
+ {{'ShaDaEntryMapLong', 'ShaDaMsgpackMap', 'ShaDaMsgpackBinaryString',
+ 'ShaDaMsgpackStringQuotes'}, '"'},
+ {{'ShaDaEntryMapLong', 'ShaDaMsgpackMap', 'ShaDaMsgpackBinaryString'},
+ 'abcdefghijklmnopqrstuvwxyz'},
+ {{'ShaDaEntryMapLong', 'ShaDaMsgpackMap', 'ShaDaMsgpackStringQuotes'},
+ '"'},
+ {{'ShaDaEntryMapLong', 'ShaDaMsgpackMap', 'ShaDaMsgpackColon'}, ':'},
+ {{'ShaDaEntryMapLong', 'ShaDaMsgpackMap'}, ' '},
+ {{'ShaDaEntryMapLong', 'ShaDaMsgpackMap', 'ShaDaMsgpackFloat'}, '1.0'},
+ {{'ShaDaEntryMapLong', 'ShaDaMsgpackMapBraces'}, '}'},
+ },
+ {
+ ms('Long'), mlk('rt '), mld('type '),
+ {{'ShaDaEntryMapLong', 'ShaDaMsgpackShaDaKeyword'}, 'CHARACTERWISE'},
+ },
+ {
+ ms('Long'), mlk('rt '), mld('type '),
+ {{'ShaDaEntryMapLong', 'ShaDaMsgpackShaDaKeyword'}, 'LINEWISE'},
+ },
+ {
+ ms('Long'), mlk('rt '), mld('type '),
+ {{'ShaDaEntryMapLong', 'ShaDaMsgpackShaDaKeyword'}, 'BLOCKWISE'},
+ },
+ {
+ hname('Replacement string'), h(' with timestamp '),
+ synepoch.year, synhtssep('-'), synepoch.month, synhtssep('-'),
+ synepoch.day, synhtssep('T'), synepoch.hour, synhtssep(':'),
+ synepoch.minute, synhtssep(':'), synepoch.second, h(':'),
+ },
+ {
+ ah(' @ Description__________ Value'),
+ },
+ {
+ as(), ad(':s replacement string '),
+ {{'ShaDaEntryArray', 'ShaDaMsgpackShaDaKeyword'}, 'CMD'},
+ },
+ {
+ as(), ad(':s replacement string '),
+ {{'ShaDaEntryArray', 'ShaDaMsgpackShaDaKeyword'}, 'SEARCH'},
+ },
+ {
+ as(), ad(':s replacement string '),
+ {{'ShaDaEntryArray', 'ShaDaMsgpackShaDaKeyword'}, 'EXPR'},
+ },
+ {
+ as(), ad(':s replacement string '),
+ {{'ShaDaEntryArray', 'ShaDaMsgpackShaDaKeyword'}, 'INPUT'},
+ },
+ {
+ {{'ShaDaEntryArrayEntryStart'}, ' - '},
+ {{'ShaDaEntryArrayDescription'}, ':s replacement string '},
+ {{'ShaDaMsgpackShaDaKeyword'}, 'DEBUG'},
+ },
+ {
+ hname('Buffer list'), h(' with timestamp '),
+ synepoch.year, synhtssep('-'), synepoch.month, synhtssep('-'),
+ synepoch.day, synhtssep('T'), synepoch.hour, synhtssep(':'),
+ synepoch.minute, synhtssep(':'), synepoch.second, h(':'),
+ },
+ {
+ c(' # Expected array of maps'),
+ },
+ {
+ {{'ShaDaEntryRawMsgpack'}, ' = '},
+ {{'ShaDaMsgpackArray', 'ShaDaMsgpackArrayBraces'}, '['},
+ {{'ShaDaMsgpackArray', 'ShaDaMsgpackMap', 'ShaDaMsgpackMapBraces'},
+ '{'},
+ {{'ShaDaMsgpackArray', 'ShaDaMsgpackMap', 'ShaDaMsgpackString'}, '='},
+ {{'ShaDaMsgpackArray', 'ShaDaMsgpackMap', 'ShaDaMsgpackBinaryString',
+ 'ShaDaMsgpackStringQuotes'}, '"'},
+ {{'ShaDaMsgpackArray', 'ShaDaMsgpackMap', 'ShaDaMsgpackBinaryString'},
+ 'a'},
+ {{'ShaDaMsgpackArray', 'ShaDaMsgpackMap', 'ShaDaMsgpackStringQuotes'},
+ '"'},
+ {{'ShaDaMsgpackArray', 'ShaDaMsgpackMap', 'ShaDaMsgpackColon'}, ':'},
+ {{'ShaDaMsgpackArray', 'ShaDaMsgpackMap'}, ' '},
+ {{'ShaDaMsgpackArray', 'ShaDaMsgpackMap', 'ShaDaMsgpackExt'}, '+('},
+ {{'ShaDaMsgpackArray', 'ShaDaMsgpackMap', 'ShaDaMsgpackExt',
+ 'ShaDaMsgpackExtType'}, '10'},
+ {{'ShaDaMsgpackArray', 'ShaDaMsgpackMap', 'ShaDaMsgpackExt'}, ')'},
+ {{'ShaDaMsgpackArray', 'ShaDaMsgpackMap', 'ShaDaMsgpackBinaryString',
+ 'ShaDaMsgpackStringQuotes'}, '"'},
+ {{'ShaDaMsgpackArray', 'ShaDaMsgpackMap', 'ShaDaMsgpackBinaryString'},
+ 'ac'},
+ {{'ShaDaMsgpackArray', 'ShaDaMsgpackMap', 'ShaDaMsgpackBinaryString',
+ 'ShaDaMsgpackBinaryStringEscape'},
+ '\\0'},
+ {{'ShaDaMsgpackArray', 'ShaDaMsgpackMap', 'ShaDaMsgpackBinaryString'},
+ 'df'},
+ {{'ShaDaMsgpackArray', 'ShaDaMsgpackMap', 'ShaDaMsgpackBinaryString',
+ 'ShaDaMsgpackBinaryStringEscape'},
+ '\\n'},
+ {{'ShaDaMsgpackArray', 'ShaDaMsgpackMap', 'ShaDaMsgpackBinaryString'},
+ 'gi'},
+ {{'ShaDaMsgpackArray', 'ShaDaMsgpackMap', 'ShaDaMsgpackBinaryString',
+ 'ShaDaMsgpackBinaryStringEscape'},
+ '\\"'},
+ {{'ShaDaMsgpackArray', 'ShaDaMsgpackMap', 'ShaDaMsgpackBinaryString'},
+ 'tt\\.'},
+ {{'ShaDaMsgpackArray', 'ShaDaMsgpackMap', 'ShaDaMsgpackStringQuotes'},
+ '"'},
+ {{'ShaDaMsgpackArray', 'ShaDaMsgpackMap', 'ShaDaMsgpackComma'}, ','},
+ {{'ShaDaMsgpackArray', 'ShaDaMsgpackMap'}, ' '},
+ {{'ShaDaMsgpackArray', 'ShaDaMsgpackMap', 'ShaDaMsgpackKeyword'},
+ 'TRUE'},
+ {{'ShaDaMsgpackArray', 'ShaDaMsgpackMap', 'ShaDaMsgpackColon'}, ':'},
+ {{'ShaDaMsgpackArray', 'ShaDaMsgpackMap'}, ' '},
+ {{'ShaDaMsgpackArray', 'ShaDaMsgpackMap', 'ShaDaMsgpackKeyword'},
+ 'FALSE'},
+ {{'ShaDaMsgpackArray', 'ShaDaMsgpackMapBraces'}, '}'},
+ {{'ShaDaMsgpackArray', 'ShaDaMsgpackComma'}, ','},
+ {{'ShaDaMsgpackArray'}, ' '},
+ {{'ShaDaMsgpackArray', 'ShaDaMsgpackArray', 'ShaDaMsgpackArrayBraces'},
+ '['},
+ {{'ShaDaMsgpackArray', 'ShaDaMsgpackArray', 'ShaDaMsgpackKeyword'},
+ 'NIL'},
+ {{'ShaDaMsgpackArray', 'ShaDaMsgpackArray', 'ShaDaMsgpackComma'}, ','},
+ {{'ShaDaMsgpackArray', 'ShaDaMsgpackArray'}, ' '},
+ {{'ShaDaMsgpackArray', 'ShaDaMsgpackArray', 'ShaDaMsgpackExt'}, '+('},
+ {{'ShaDaMsgpackArray', 'ShaDaMsgpackArray', 'ShaDaMsgpackExt',
+ 'ShaDaMsgpackExtType'}, '-10'},
+ {{'ShaDaMsgpackArray', 'ShaDaMsgpackArray', 'ShaDaMsgpackExt'}, ')'},
+ {{'ShaDaMsgpackArray', 'ShaDaMsgpackArray', 'ShaDaMsgpackBinaryString',
+ 'ShaDaMsgpackStringQuotes'}, '"'},
+ {{'ShaDaMsgpackArray', 'ShaDaMsgpackArray', 'ShaDaMsgpackStringQuotes'},
+ '"'},
+ {{'ShaDaMsgpackArray', 'ShaDaMsgpackArrayBraces'}, ']'},
+ {{'ShaDaMsgpackArrayBraces'}, ']'},
+ },
+ {
+ hname('Buffer list'), h(' with timestamp '),
+ synepoch.year, synhtssep('-'), synepoch.month, synhtssep('-'),
+ synepoch.day, synhtssep('T'), synepoch.hour, synhtssep(':'),
+ synepoch.minute, synhtssep(':'), synepoch.second, h(':'),
+ },
+ {
+ mlh(' % Key Description Value'),
+ },
+ {
+ },
+ {
+ mlh(' % Key Description Value'),
+ },
+ {
+ hname('Header'), h(' with timestamp '),
+ synepoch.year, synhtssep('-'), synepoch.month, synhtssep('-'),
+ synepoch.day, synhtssep('T'), synepoch.hour, synhtssep(':'),
+ synepoch.minute, synhtssep(':'), synepoch.second, h(':'),
+ },
+ {
+ mlh(' % Key Description________ Value'),
+ },
+ {
+ {{'ShaDaEntryMapLongEntryStart'}, ' + '},
+ {{'ShaDaEntryMapLongKey'}, 'se '},
+ {{'ShaDaEntryMapLongDescription'}, 'place cursor at end '},
+ {{'ShaDaMsgpackKeyword'}, 'TRUE'},
+ },
+ }
+ eq(exp, act)
+ end)
+end)
diff --git a/test/functional/provider/define_spec.lua b/test/functional/provider/define_spec.lua
index 9b97ed84d9..6e8a3b89cd 100644
--- a/test/functional/provider/define_spec.lua
+++ b/test/functional/provider/define_spec.lua
@@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')
local eval, command, nvim = helpers.eval, helpers.command, helpers.nvim
local eq, run, stop = helpers.eq, helpers.run, helpers.stop
-local clear, feed = helpers.clear, helpers.feed
+local clear = helpers.clear
local function get_prefix(sync)
@@ -12,8 +12,8 @@ local function get_prefix(sync)
end
-local function call(fn, args)
- command('call '..fn..'('..args..')')
+local function call(fn, arguments)
+ command('call '..fn..'('..arguments..')')
end
@@ -87,9 +87,9 @@ local function command_specs_for(fn, sync, first_arg_factory, init)
command('RpcCommand arg1 arg2 arg3')
end
- local function handler(method, args)
+ local function handler(method, arguments)
eq('test-handler', method)
- eq({'arg1', 'arg2', 'arg3'}, args[1])
+ eq({'arg1', 'arg2', 'arg3'}, arguments[1])
return ''
end
@@ -104,9 +104,9 @@ local function command_specs_for(fn, sync, first_arg_factory, init)
command('1,1RpcCommand')
end
- local function handler(method, args)
+ local function handler(method, arguments)
eq('test-handler', method)
- eq({1, 1}, args[1])
+ eq({1, 1}, arguments[1])
return ''
end
@@ -121,10 +121,10 @@ local function command_specs_for(fn, sync, first_arg_factory, init)
command('1,1RpcCommand arg')
end
- local function handler(method, args)
+ local function handler(method, arguments)
eq('test-handler', method)
- eq({'arg'}, args[1])
- eq({1, 1}, args[2])
+ eq({'arg'}, arguments[1])
+ eq({1, 1}, arguments[2])
return ''
end
@@ -139,10 +139,10 @@ local function command_specs_for(fn, sync, first_arg_factory, init)
command('5RpcCommand arg')
end
- local function handler(method, args)
+ local function handler(method, arguments)
eq('test-handler', method)
- eq({'arg'}, args[1])
- eq(5, args[2])
+ eq({'arg'}, arguments[1])
+ eq(5, arguments[2])
return ''
end
@@ -157,11 +157,11 @@ local function command_specs_for(fn, sync, first_arg_factory, init)
command('5RpcCommand! arg')
end
- local function handler(method, args)
+ local function handler(method, arguments)
eq('test-handler', method)
- eq({'arg'}, args[1])
- eq(5, args[2])
- eq(1, args[3])
+ eq({'arg'}, arguments[1])
+ eq(5, arguments[2])
+ eq(1, arguments[3])
return ''
end
@@ -177,12 +177,12 @@ local function command_specs_for(fn, sync, first_arg_factory, init)
command('5RpcCommand! b arg')
end
- local function handler(method, args)
+ local function handler(method, arguments)
eq('test-handler', method)
- eq({'arg'}, args[1])
- eq(5, args[2])
- eq(1, args[3])
- eq('b', args[4])
+ eq({'arg'}, arguments[1])
+ eq(5, arguments[2])
+ eq(1, arguments[3])
+ eq('b', arguments[4])
return ''
end
@@ -199,13 +199,13 @@ local function command_specs_for(fn, sync, first_arg_factory, init)
command('5RpcCommand! b arg')
end
- local function handler(method, args)
+ local function handler(method, arguments)
eq('test-handler', method)
- eq({'arg'}, args[1])
- eq(5, args[2])
- eq(1, args[3])
- eq('b', args[4])
- eq('regb', args[5])
+ eq({'arg'}, arguments[1])
+ eq(5, arguments[2])
+ eq(1, arguments[3])
+ eq('b', arguments[4])
+ eq('regb', arguments[5])
return ''
end
@@ -243,7 +243,7 @@ local function autocmd_specs_for(fn, sync, first_arg_factory, init)
command('doautocmd BufEnter x.c')
end
- local function handler(method, args)
+ local function handler(method)
eq('test-handler', method)
return ''
end
@@ -259,9 +259,9 @@ local function autocmd_specs_for(fn, sync, first_arg_factory, init)
command('doautocmd BufEnter x.c')
end
- local function handler(method, args)
+ local function handler(method, arguments)
eq('test-handler', method)
- eq('x.c', args[1])
+ eq('x.c', arguments[1])
return ''
end
@@ -303,9 +303,9 @@ local function function_specs_for(fn, sync, first_arg_factory, init)
end
end
- local function handler(method, args)
+ local function handler(method, arguments)
eq('test-handler', method)
- eq({{1, 'a', {'b', 'c'}}}, args)
+ eq({{1, 'a', {'b', 'c'}}}, arguments)
return 'rv'
end
@@ -324,9 +324,9 @@ local function function_specs_for(fn, sync, first_arg_factory, init)
end
end
- local function handler(method, args)
+ local function handler(method, arguments)
eq('test-handler', method)
- eq({{1, 'a', {'b', 'c'}}, 4}, args)
+ eq({{1, 'a', {'b', 'c'}}, 4}, arguments)
return 'rv'
end
diff --git a/test/functional/provider/python3_spec.lua b/test/functional/provider/python3_spec.lua
index 5ecc1a0a91..a94880d4a2 100644
--- a/test/functional/provider/python3_spec.lua
+++ b/test/functional/provider/python3_spec.lua
@@ -4,6 +4,7 @@ local eq, clear, insert = helpers.eq, helpers.clear, helpers.insert
local expect, write_file = helpers.expect, helpers.write_file
do
+ clear()
command('let [g:interp, g:errors] = provider#pythonx#Detect(3)')
local errors = eval('g:errors')
if errors ~= '' then
diff --git a/test/functional/provider/python_spec.lua b/test/functional/provider/python_spec.lua
index f37c16a26a..da45d6aa00 100644
--- a/test/functional/provider/python_spec.lua
+++ b/test/functional/provider/python_spec.lua
@@ -4,6 +4,7 @@ local eq, clear, insert = helpers.eq, helpers.clear, helpers.insert
local expect, write_file = helpers.expect, helpers.write_file
do
+ clear()
command('let [g:interp, g:errors] = provider#pythonx#Detect(2)')
local errors = eval('g:errors')
if errors ~= '' then
diff --git a/test/functional/server/server_spec.lua b/test/functional/server/server_spec.lua
index 1cb3c879b9..d9ce96057e 100644
--- a/test/functional/server/server_spec.lua
+++ b/test/functional/server/server_spec.lua
@@ -1,7 +1,6 @@
local helpers = require('test.functional.helpers')
-local nvim, eq, neq, ok, eval
- = helpers.nvim, helpers.eq, helpers.neq, helpers.ok, helpers.eval
+local nvim, eq, neq, eval = helpers.nvim, helpers.eq, helpers.neq, helpers.eval
local clear = helpers.clear
describe('serverstart(), serverstop()', function()
diff --git a/test/functional/shada/buffers_spec.lua b/test/functional/shada/buffers_spec.lua
index 3666b718f0..fd4809e01a 100644
--- a/test/functional/shada/buffers_spec.lua
+++ b/test/functional/shada/buffers_spec.lua
@@ -1,7 +1,7 @@
-- ShaDa buffer list saving/reading support
local helpers = require('test.functional.helpers')
-local nvim_command, funcs, eq =
- helpers.command, helpers.funcs, helpers.eq
+local nvim_command, funcs, eq, curbufmeths =
+ helpers.command, helpers.funcs, helpers.eq, helpers.curbufmeths
local shada_helpers = require('test.functional.shada.helpers')
local reset, set_additional_cmd, clear =
@@ -9,8 +9,8 @@ local reset, set_additional_cmd, clear =
shada_helpers.clear
describe('ShaDa support code', function()
- testfilename = 'Xtestfile-functional-shada-buffers'
- testfilename_2 = 'Xtestfile-functional-shada-buffers-2'
+ local testfilename = 'Xtestfile-functional-shada-buffers'
+ local testfilename_2 = 'Xtestfile-functional-shada-buffers-2'
before_each(reset)
after_each(clear)
@@ -48,4 +48,43 @@ describe('ShaDa support code', function()
eq(1, funcs.bufnr('$'))
eq('', funcs.bufname(1))
end)
+
+ it('does not dump unlisted buffer', function()
+ set_additional_cmd('set shada+=%')
+ reset()
+ nvim_command('edit ' .. testfilename)
+ nvim_command('edit ' .. testfilename_2)
+ curbufmeths.set_option('buflisted', false)
+ nvim_command('qall')
+ reset()
+ eq(2, funcs.bufnr('$'))
+ eq('', funcs.bufname(1))
+ eq(testfilename, funcs.bufname(2))
+ end)
+
+ it('does not dump quickfix buffer', function()
+ set_additional_cmd('set shada+=%')
+ reset()
+ nvim_command('edit ' .. testfilename)
+ nvim_command('edit ' .. testfilename_2)
+ curbufmeths.set_option('buftype', 'quickfix')
+ nvim_command('qall')
+ reset()
+ eq(2, funcs.bufnr('$'))
+ eq('', funcs.bufname(1))
+ eq(testfilename, funcs.bufname(2))
+ end)
+
+ it('does not dump unnamed buffers', function()
+ set_additional_cmd('set shada+=% hidden')
+ reset()
+ curbufmeths.set_line(0, 'foo')
+ nvim_command('enew')
+ curbufmeths.set_line(0, 'bar')
+ eq(2, funcs.bufnr('$'))
+ nvim_command('qall!')
+ reset()
+ eq(1, funcs.bufnr('$'))
+ eq('', funcs.bufname(1))
+ end)
end)
diff --git a/test/functional/shada/compatibility_spec.lua b/test/functional/shada/compatibility_spec.lua
index 342dee377b..2ca0b16e75 100644
--- a/test/functional/shada/compatibility_spec.lua
+++ b/test/functional/shada/compatibility_spec.lua
@@ -4,9 +4,8 @@ local nvim_command, funcs, eq = helpers.command, helpers.funcs, helpers.eq
local exc_exec = helpers.exc_exec
local shada_helpers = require('test.functional.shada.helpers')
-local reset, set_additional_cmd, clear, get_shada_rw =
- shada_helpers.reset, shada_helpers.set_additional_cmd,
- shada_helpers.clear, shada_helpers.get_shada_rw
+local reset, clear, get_shada_rw = shada_helpers.reset, shada_helpers.clear,
+ shada_helpers.get_shada_rw
local read_shada_file = shada_helpers.read_shada_file
local wshada, sdrcmd, shada_fname = get_shada_rw('Xtest-functional-shada-compatibility.shada')
@@ -181,7 +180,7 @@ describe('ShaDa forward compatibility support code', function()
end
eq(3, found)
nvim_command('wshada! ' .. shada_fname)
- local found = 0
+ found = 0
for i, subv in ipairs(read_shada_file(shada_fname)) do
if i == 1 then
eq(1, subv.type)
@@ -249,7 +248,7 @@ describe('ShaDa forward compatibility support code', function()
end
eq(1, found)
nvim_command('wshada! ' .. shada_fname)
- local found = 0
+ found = 0
for i, v in ipairs(read_shada_file(shada_fname)) do
if i == 1 then
eq(1, v.type)
@@ -289,7 +288,7 @@ describe('ShaDa forward compatibility support code', function()
end
eq(1, found)
nvim_command('wshada! ' .. shada_fname)
- local found = 0
+ found = 0
for i, v in ipairs(read_shada_file(shada_fname)) do
if i == 1 then
eq(1, v.type)
@@ -395,7 +394,7 @@ describe('ShaDa forward compatibility support code', function()
end
eq(1, found)
nvim_command('wshada! ' .. shada_fname)
- local found = 0
+ found = 0
for i, v in ipairs(read_shada_file(shada_fname)) do
if i == 1 then
eq(1, v.type)
@@ -432,7 +431,7 @@ describe('ShaDa forward compatibility support code', function()
end
eq(1, found)
nvim_command('wshada! ' .. shada_fname)
- local found = 0
+ found = 0
for i, v in ipairs(read_shada_file(shada_fname)) do
if i == 1 then
eq(1, v.type)
diff --git a/test/functional/shada/errors_spec.lua b/test/functional/shada/errors_spec.lua
index 16ae77af02..62b9e6c84d 100644
--- a/test/functional/shada/errors_spec.lua
+++ b/test/functional/shada/errors_spec.lua
@@ -124,6 +124,11 @@ describe('ShaDa error handling', function()
eq('Vim(rshada):E575: Error while reading ShaDa file: search pattern entry at position 0 has sc key value which is not a boolean', exc_exec(sdrcmd()))
end)
+ it('fails on search pattern item with NIL search_backward key value', function()
+ wshada('\002\000\009\130\162sX\192\162sb\192')
+ eq('Vim(rshada):E575: Error while reading ShaDa file: search pattern entry at position 0 has sb key value which is not a boolean', exc_exec(sdrcmd()))
+ end)
+
it('fails on search pattern item with NIL has_line_offset key value', function()
wshada('\002\000\009\130\162sX\192\162sl\192')
eq('Vim(rshada):E575: Error while reading ShaDa file: search pattern entry at position 0 has sl key value which is not a boolean', exc_exec(sdrcmd()))
diff --git a/test/functional/shada/helpers.lua b/test/functional/shada/helpers.lua
index c2ff4cadd1..146ae8d51e 100644
--- a/test/functional/shada/helpers.lua
+++ b/test/functional/shada/helpers.lua
@@ -9,15 +9,14 @@ local tmpname = os.tmpname()
local additional_cmd = ''
local function nvim_argv()
- local ret
- local nvim_argv = {nvim_prog, '-u', 'NONE', '-i', tmpname, '-N',
- '--cmd', 'set shortmess+=I background=light noswapfile',
- '--cmd', additional_cmd,
- '--embed'}
+ local argv = {nvim_prog, '-u', 'NONE', '-i', tmpname, '-N',
+ '--cmd', 'set shortmess+=I background=light noswapfile',
+ '--cmd', additional_cmd,
+ '--embed'}
if helpers.prepend_argv then
- return merge_args(helpers.prepend_argv, nvim_argv)
+ return merge_args(helpers.prepend_argv, argv)
else
- return nvim_argv
+ return argv
end
end
@@ -88,7 +87,6 @@ return {
reset=reset,
set_additional_cmd=set_additional_cmd,
clear=clear,
- exc_exec=exc_exec,
get_shada_rw=get_shada_rw,
read_shada_file=read_shada_file,
}
diff --git a/test/functional/shada/history_spec.lua b/test/functional/shada/history_spec.lua
index 1123f829d2..94513945d0 100644
--- a/test/functional/shada/history_spec.lua
+++ b/test/functional/shada/history_spec.lua
@@ -107,14 +107,32 @@ describe('ShaDa support code', function()
end)
it('dumps and loads last search pattern with offset', function()
- funcs.setline('.', {'foo', 'bar'})
+ meths.set_option('wrapscan', false)
+ funcs.setline('.', {'foo', 'bar--'})
nvim_feed('gg0/a/e+1\n')
eq({0, 2, 3, 0}, funcs.getpos('.'))
nvim_command('wshada')
reset()
- funcs.setline('.', {'foo', 'bar'})
+ meths.set_option('wrapscan', false)
+ funcs.setline('.', {'foo', 'bar--'})
nvim_feed('gg0n')
eq({0, 2, 3, 0}, funcs.getpos('.'))
+ eq(1, meths.get_vvar('searchforward'))
+ end)
+
+ it('dumps and loads last search pattern with offset and backward direction',
+ function()
+ meths.set_option('wrapscan', false)
+ funcs.setline('.', {'foo', 'bar--'})
+ nvim_feed('G$?a?e+1\n')
+ eq({0, 2, 3, 0}, funcs.getpos('.'))
+ nvim_command('wshada')
+ reset()
+ meths.set_option('wrapscan', false)
+ funcs.setline('.', {'foo', 'bar--'})
+ nvim_feed('G$n')
+ eq({0, 2, 3, 0}, funcs.getpos('.'))
+ eq(0, meths.get_vvar('searchforward'))
end)
it('saves v:hlsearch=1', function()
diff --git a/test/functional/shada/marks_spec.lua b/test/functional/shada/marks_spec.lua
index b03af39662..955a6f382b 100644
--- a/test/functional/shada/marks_spec.lua
+++ b/test/functional/shada/marks_spec.lua
@@ -15,15 +15,15 @@ local nvim_current_line = function()
end
describe('ShaDa support code', function()
- testfilename = 'Xtestfile-functional-shada-marks'
- testfilename_2 = 'Xtestfile-functional-shada-marks-2'
+ local testfilename = 'Xtestfile-functional-shada-marks'
+ local testfilename_2 = 'Xtestfile-functional-shada-marks-2'
before_each(function()
reset()
local fd = io.open(testfilename, 'w')
fd:write('test\n')
fd:write('test2\n')
fd:close()
- local fd = io.open(testfilename_2, 'w')
+ fd = io.open(testfilename_2, 'w')
fd:write('test3\n')
fd:write('test4\n')
fd:close()
@@ -90,6 +90,16 @@ describe('ShaDa support code', function()
eq(2, nvim_current_line())
end)
+ it('is able to dump and read back mark "', function()
+ nvim_command('edit ' .. testfilename)
+ nvim_command('2')
+ nvim_command('qall')
+ reset()
+ nvim_command('edit ' .. testfilename)
+ nvim_command('normal! `"')
+ eq(2, nvim_current_line())
+ end)
+
it('is able to populate v:oldfiles', function()
nvim_command('edit ' .. testfilename)
local tf_full = curbufmeths.get_name()
@@ -98,13 +108,15 @@ describe('ShaDa support code', function()
nvim_command('qall')
reset()
local oldfiles = meths.get_vvar('oldfiles')
+ table.sort(oldfiles)
eq(2, #oldfiles)
eq(testfilename, oldfiles[1]:sub(-#testfilename))
eq(testfilename_2, oldfiles[2]:sub(-#testfilename_2))
eq(tf_full, oldfiles[1])
eq(tf_full_2, oldfiles[2])
nvim_command('rshada!')
- local oldfiles = meths.get_vvar('oldfiles')
+ oldfiles = meths.get_vvar('oldfiles')
+ table.sort(oldfiles)
eq(2, #oldfiles)
eq(testfilename, oldfiles[1]:sub(-#testfilename))
eq(testfilename_2, oldfiles[2]:sub(-#testfilename_2))
diff --git a/test/functional/shada/merging_spec.lua b/test/functional/shada/merging_spec.lua
index 7066ca9f54..221f989409 100644
--- a/test/functional/shada/merging_spec.lua
+++ b/test/functional/shada/merging_spec.lua
@@ -1,7 +1,7 @@
-- ShaDa merging data support
local helpers = require('test.functional.helpers')
-local nvim_command, meths, funcs, curbufmeths, eq =
- helpers.command, helpers.meths, helpers.funcs,
+local nvim_command, funcs, curbufmeths, eq =
+ helpers.command, helpers.funcs,
helpers.curbufmeths, helpers.eq
local exc_exec, redir_exec = helpers.exc_exec, helpers.redir_exec
@@ -870,7 +870,7 @@ describe('ShaDa jumps support code', function()
end
wshada(shada)
eq(0, exc_exec(sdrcmd()))
- local shada = ''
+ shada = ''
for i = 1,101 do
local t = i * 2
shada = shada .. (
@@ -964,7 +964,7 @@ describe('ShaDa changes support code', function()
end
wshada(shada)
eq(0, exc_exec(sdrcmd()))
- local shada = ''
+ shada = ''
for i = 1,101 do
local t = i * 2
shada = shada .. (
@@ -1001,7 +1001,7 @@ describe('ShaDa changes support code', function()
end
wshada(shada)
eq(0, exc_exec(sdrcmd()))
- local shada = ''
+ shada = ''
for i = 1,100 do
shada = shada .. ('\011%c\018\131\162mX\195\161f\196\006/a/b/c\161l%c'
):format(i, i)
diff --git a/test/functional/shell/viml_system_spec.lua b/test/functional/shell/viml_system_spec.lua
index 4985c24aec..00b16e9158 100644
--- a/test/functional/shell/viml_system_spec.lua
+++ b/test/functional/shell/viml_system_spec.lua
@@ -133,7 +133,7 @@ describe('system()', function()
-- write more than 1mb of data, which should be enough to overcome
-- the os buffer limit and force multiple event loop iterations to write
-- everything
- for i = 1, 0xffff do
+ for _ = 1, 0xffff do
input[#input + 1] = '01234567890ABCDEFabcdef'
end
input = table.concat(input, '\n')
@@ -299,7 +299,7 @@ describe('systemlist()', function()
describe('passing a lot of input', function()
it('returns the program output', function()
local input = {}
- for i = 1, 0xffff do
+ for _ = 1, 0xffff do
input[#input + 1] = '01234567890ABCDEFabcdef'
end
nvim('set_var', 'input', input)
diff --git a/test/functional/terminal/altscreen_spec.lua b/test/functional/terminal/altscreen_spec.lua
index 9ec0fc7c5a..d9d96b25f9 100644
--- a/test/functional/terminal/altscreen_spec.lua
+++ b/test/functional/terminal/altscreen_spec.lua
@@ -1,6 +1,5 @@
local helpers = require('test.functional.helpers')
local thelpers = require('test.functional.terminal.helpers')
-local Screen = require('test.functional.ui.screen')
local clear, eq, curbuf = helpers.clear, helpers.eq, helpers.curbuf
local feed = helpers.feed
local feed_data = thelpers.feed_data
diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua
index ffdfec4428..55ef254a63 100644
--- a/test/functional/terminal/buffer_spec.lua
+++ b/test/functional/terminal/buffer_spec.lua
@@ -1,5 +1,4 @@
local helpers = require('test.functional.helpers')
-local Screen = require('test.functional.ui.screen')
local thelpers = require('test.functional.terminal.helpers')
local feed, clear, nvim = helpers.feed, helpers.clear, helpers.nvim
local wait = helpers.wait
diff --git a/test/functional/terminal/cursor_spec.lua b/test/functional/terminal/cursor_spec.lua
index 7f07467fde..e9cb010003 100644
--- a/test/functional/terminal/cursor_spec.lua
+++ b/test/functional/terminal/cursor_spec.lua
@@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')
local Screen = require('test.functional.ui.screen')
local thelpers = require('test.functional.terminal.helpers')
local feed, clear, nvim = helpers.feed, helpers.clear, helpers.nvim
-local nvim_dir, execute, eq = helpers.nvim_dir, helpers.execute, helpers.eq
+local nvim_dir, execute = helpers.nvim_dir, helpers.execute
local hide_cursor = thelpers.hide_cursor
local show_cursor = thelpers.show_cursor
diff --git a/test/functional/terminal/ex_terminal_spec.lua b/test/functional/terminal/ex_terminal_spec.lua
index 3855cf4b65..493539b4d3 100644
--- a/test/functional/terminal/ex_terminal_spec.lua
+++ b/test/functional/terminal/ex_terminal_spec.lua
@@ -2,8 +2,7 @@ local helpers = require('test.functional.helpers')
local Screen = require('test.functional.ui.screen')
local clear, wait, nvim = helpers.clear, helpers.wait, helpers.nvim
local nvim_dir = helpers.nvim_dir
-local execute, source = helpers.execute, helpers.source
-local eq, neq = helpers.eq, helpers.neq
+local execute = helpers.execute
describe(':terminal', function()
local screen
@@ -22,7 +21,7 @@ describe(':terminal', function()
wait()
screen:expect([[
ready $ |
- [Program exited, press any key to close] |
+ [Process exited 0] |
|
|
|
@@ -37,7 +36,7 @@ describe(':terminal', function()
screen:expect([[
ready $ echo hi |
|
- [Program exited, press any key to close] |
+ [Process exited 0] |
|
|
|
@@ -51,7 +50,7 @@ describe(':terminal', function()
screen:expect([[
ready $ echo 'hello' \ "world" |
|
- [Program exited, press any key to close] |
+ [Process exited 0] |
|
|
|
diff --git a/test/functional/terminal/helpers.lua b/test/functional/terminal/helpers.lua
index ae13aab277..a32ae650d6 100644
--- a/test/functional/terminal/helpers.lua
+++ b/test/functional/terminal/helpers.lua
@@ -72,7 +72,7 @@ local function screen_setup(extra_height, command)
empty_line,
empty_line,
}
- for i = 1, extra_height do
+ for _ = 1, extra_height do
table.insert(expected, empty_line)
end
diff --git a/test/functional/terminal/highlight_spec.lua b/test/functional/terminal/highlight_spec.lua
index 1a96cb4dba..045f5aa42f 100644
--- a/test/functional/terminal/highlight_spec.lua
+++ b/test/functional/terminal/highlight_spec.lua
@@ -40,7 +40,7 @@ describe('terminal window highlighting', function()
]])
end)
- function descr(title, attr_num, set_attrs_fn)
+ local function descr(title, attr_num, set_attrs_fn)
local function sub(s)
return s:gsub('NUM', attr_num)
end
diff --git a/test/functional/terminal/mouse_spec.lua b/test/functional/terminal/mouse_spec.lua
index ac61abebcb..c4bd3c2663 100644
--- a/test/functional/terminal/mouse_spec.lua
+++ b/test/functional/terminal/mouse_spec.lua
@@ -1,8 +1,7 @@
-local Screen = require('test.functional.ui.screen')
local helpers = require('test.functional.helpers')
local thelpers = require('test.functional.terminal.helpers')
-local clear, eq, curbuf = helpers.clear, helpers.eq, helpers.curbuf
-local feed, execute, nvim = helpers.feed, helpers.execute, helpers.nvim
+local clear = helpers.clear
+local feed, nvim = helpers.feed, helpers.nvim
local feed_data = thelpers.feed_data
describe('terminal mouse', function()
diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua
index 87cc9a8266..4b56698520 100644
--- a/test/functional/terminal/scrollback_spec.lua
+++ b/test/functional/terminal/scrollback_spec.lua
@@ -340,7 +340,7 @@ describe('terminal prints more lines than the screen height and exits', function
line8 |
line9 |
|
- [Program exited, press any key to close] |
+ [Process exited 0] |
-- TERMINAL -- |
]])
feed('<cr>')
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua
index d604703fee..14700a2622 100644
--- a/test/functional/terminal/tui_spec.lua
+++ b/test/functional/terminal/tui_spec.lua
@@ -1,18 +1,20 @@
-- Some sanity checks for the TUI using the builtin terminal emulator
-- as a simple way to send keys and assert screen state.
-local Screen = require('test.functional.ui.screen')
local helpers = require('test.functional.helpers')
local thelpers = require('test.functional.terminal.helpers')
local feed = thelpers.feed_data
local execute = helpers.execute
+local nvim_dir = helpers.nvim_dir
describe('tui', function()
local screen
before_each(function()
helpers.clear()
- screen = thelpers.screen_setup(0, '["'..helpers.nvim_prog..'", "-u", "NONE", "--cmd", "set noswapfile"]')
- screen.timeout = 30000 -- pasting can be really slow in the TUI
+ screen = thelpers.screen_setup(0, '["'..helpers.nvim_prog..'", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile"]')
+ -- right now pasting can be really slow in the TUI, especially in ASAN.
+ -- this will be fixed later but for now we require a high timeout.
+ screen.timeout = 60000
screen:expect([[
{1: } |
~ |
@@ -51,6 +53,49 @@ describe('tui', function()
]])
end)
+ it('interprets leading esc byte as the alt modifier', function()
+ local keys = 'dfghjkl'
+ for c in keys:gmatch('.') do
+ execute('nnoremap <a-'..c..'> ialt-'..c..'<cr><esc>')
+ feed('\x1b'..c)
+ end
+ screen:expect([[
+ alt-j |
+ alt-k |
+ alt-l |
+ {1: } |
+ [No Name] [+] |
+ |
+ -- TERMINAL -- |
+ ]])
+ feed('gg')
+ screen:expect([[
+ {1:a}lt-d |
+ alt-f |
+ alt-g |
+ alt-h |
+ [No Name] [+] |
+ |
+ -- TERMINAL -- |
+ ]])
+ end)
+
+ it('accepts ascii control sequences', function()
+ feed('i')
+ feed('\x16\x07') -- ctrl+g
+ feed('\x16\x16') -- ctrl+v
+ feed('\x16\x0d') -- ctrl+m
+ screen:expect([[
+ {3:^G^V^M}{1: } |
+ ~ |
+ ~ |
+ ~ |
+ [No Name] [+] |
+ -- INSERT -- |
+ -- TERMINAL -- |
+ ]], {[1] = {reverse = true}, [2] = {background = 11}, [3] = {foreground = 4}})
+ end)
+
it('automatically sends <Paste> for bracketed paste sequences', function()
feed('i\x1b[200~')
screen:expect([[
@@ -104,3 +149,138 @@ describe('tui', function()
]])
end)
end)
+
+describe('tui with non-tty file descriptors', function()
+ before_each(helpers.clear)
+
+ after_each(function()
+ os.remove('testF') -- ensure test file is removed
+ end)
+
+ it('can handle pipes as stdout and stderr', function()
+ local screen = thelpers.screen_setup(0, '"'..helpers.nvim_prog..' -u NONE -i NONE --cmd \'set noswapfile\' --cmd \'normal iabc\' > /dev/null 2>&1 && cat testF && rm testF"')
+ screen:set_default_attr_ids({})
+ screen:set_default_attr_ignore(true)
+ feed(':w testF\n:q\n')
+ screen:expect([[
+ :w testF |
+ :q |
+ abc |
+ |
+ [Process exited 0] |
+ |
+ -- TERMINAL -- |
+ ]])
+ end)
+end)
+
+describe('tui focus event handling', function()
+ local screen
+
+ before_each(function()
+ helpers.clear()
+ screen = thelpers.screen_setup(0, '["'..helpers.nvim_prog..'", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile"]')
+ execute('autocmd FocusGained * echo "gained"')
+ execute('autocmd FocusLost * echo "lost"')
+ end)
+
+ it('can handle focus events in normal mode', function()
+ feed('\x1b[I')
+ screen:expect([[
+ {1: } |
+ ~ |
+ ~ |
+ ~ |
+ [No Name] |
+ gained |
+ -- TERMINAL -- |
+ ]])
+
+ feed('\x1b[O')
+ screen:expect([[
+ {1: } |
+ ~ |
+ ~ |
+ ~ |
+ [No Name] |
+ lost |
+ -- TERMINAL -- |
+ ]])
+ end)
+
+ it('can handle focus events in insert mode', function()
+ execute('set noshowmode')
+ feed('i')
+ feed('\x1b[I')
+ screen:expect([[
+ {1: } |
+ ~ |
+ ~ |
+ ~ |
+ [No Name] |
+ gained |
+ -- TERMINAL -- |
+ ]])
+ feed('\x1b[O')
+ screen:expect([[
+ {1: } |
+ ~ |
+ ~ |
+ ~ |
+ [No Name] |
+ lost |
+ -- TERMINAL -- |
+ ]])
+ end)
+
+ it('can handle focus events in cmdline mode', function()
+ feed(':')
+ feed('\x1b[I')
+ screen:expect([[
+ |
+ ~ |
+ ~ |
+ ~ |
+ [No Name] |
+ g{1:a}ined |
+ -- TERMINAL -- |
+ ]])
+ feed('\x1b[O')
+ screen:expect([[
+ |
+ ~ |
+ ~ |
+ ~ |
+ [No Name] |
+ l{1:o}st |
+ -- TERMINAL -- |
+ ]])
+ end)
+
+ it('can handle focus events in terminal mode', function()
+ execute('set shell='..nvim_dir..'/shell-test')
+ execute('set laststatus=0')
+ execute('set noshowmode')
+ execute('terminal')
+ feed('\x1b[I')
+ screen:expect([[
+ ready $ |
+ [Process exited 0]{1: } |
+ |
+ |
+ |
+ gained |
+ -- TERMINAL -- |
+ ]])
+ feed('\x1b[O')
+ screen:expect([[
+ ready $ |
+ [Process exited 0]{1: } |
+ |
+ |
+ |
+ lost |
+ -- TERMINAL -- |
+ ]])
+ end)
+end)
diff --git a/test/functional/terminal/window_spec.lua b/test/functional/terminal/window_spec.lua
index c2b9390a11..6c236ed868 100644
--- a/test/functional/terminal/window_spec.lua
+++ b/test/functional/terminal/window_spec.lua
@@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')
local thelpers = require('test.functional.terminal.helpers')
-local feed, clear, nvim = helpers.feed, helpers.clear, helpers.nvim
-local wait, eq = helpers.wait, helpers.eq
+local feed, clear = helpers.feed, helpers.clear
+local wait = helpers.wait
describe('terminal window', function()
diff --git a/test/functional/terminal/window_split_tab_spec.lua b/test/functional/terminal/window_split_tab_spec.lua
index c102b1f133..727eba2717 100644
--- a/test/functional/terminal/window_split_tab_spec.lua
+++ b/test/functional/terminal/window_split_tab_spec.lua
@@ -1,8 +1,7 @@
local helpers = require('test.functional.helpers')
local thelpers = require('test.functional.terminal.helpers')
-local clear, eq, curbuf = helpers.clear, helpers.eq, helpers.curbuf
+local clear = helpers.clear
local feed, nvim = helpers.feed, helpers.nvim
-local feed_data = thelpers.feed_data
describe('terminal', function()
local screen
diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua
index 33a53ef201..f9b112e464 100644
--- a/test/functional/ui/highlight_spec.lua
+++ b/test/functional/ui/highlight_spec.lua
@@ -1,6 +1,6 @@
local helpers = require('test.functional.helpers')
local Screen = require('test.functional.ui.screen')
-local clear, feed, nvim = helpers.clear, helpers.feed, helpers.nvim
+local clear, feed = helpers.clear, helpers.feed
local execute, request, eq = helpers.execute, helpers.request, helpers.eq
diff --git a/test/functional/ui/input_spec.lua b/test/functional/ui/input_spec.lua
index a7c8e02def..4818830940 100644
--- a/test/functional/ui/input_spec.lua
+++ b/test/functional/ui/input_spec.lua
@@ -8,7 +8,6 @@ describe('mappings', function()
local cid
local add_mapping = function(mapping, send)
- local str = 'mapped '..mapping
local cmd = "nnoremap "..mapping.." :call rpcnotify("..cid..", 'mapped', '"
..send:gsub('<', '<lt>').."')<cr>"
execute(cmd)
diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua
index 1be83d745e..e1c2d14759 100644
--- a/test/functional/ui/screen.lua
+++ b/test/functional/ui/screen.lua
@@ -106,8 +106,8 @@
-- use `screen:snapshot_util({},true)`
local helpers = require('test.functional.helpers')
-local request, run, stop = helpers.request, helpers.run, helpers.stop
-local eq, dedent = helpers.eq, helpers.dedent
+local request, run = helpers.request, helpers.run
+local dedent = helpers.dedent
local Screen = {}
Screen.__index = Screen
@@ -125,7 +125,7 @@ end
do
local spawn, nvim_prog = helpers.spawn, helpers.nvim_prog
- local session = spawn({nvim_prog, '-u', 'NONE', '-N', '--embed'})
+ local session = spawn({nvim_prog, '-u', 'NONE', '-i', 'NONE', '-N', '--embed'})
local status, rv = session:request('vim_get_color_map')
if not status then
print('failed to get color map')
@@ -241,7 +241,7 @@ function Screen:wait(check, timeout)
checked = true
if not err then
success_seen = true
- stop()
+ helpers.stop()
elseif success_seen and #args > 0 then
failure_after_success = true
--print(require('inspect')(args))
@@ -294,9 +294,9 @@ end
function Screen:_handle_resize(width, height)
local rows = {}
- for i = 1, height do
+ for _ = 1, height do
local cols = {}
- for j = 1, width do
+ for _ = 1, width do
table.insert(cols, {text = ' ', attrs = {}})
end
table.insert(rows, cols)
@@ -448,7 +448,7 @@ function Screen:_row_repr(row, attr_ids, attr_ignore)
local rv = {}
local current_attr_id
for i = 1, self._width do
- local attr_id = get_attr_id(attr_ids, attr_ignore, row[i].attrs)
+ local attr_id = self:_get_attr_id(attr_ids, attr_ignore, row[i].attrs)
if current_attr_id and attr_id ~= current_attr_id then
-- close current attribute bracket, add it before any whitespace
-- up to the current cell
@@ -524,8 +524,8 @@ function Screen:print_snapshot(attrs, ignore)
local row = self._rows[i]
for j = 1, self._width do
local attr = row[j].attrs
- if attr_index(attrs, attr) == nil and attr_index(ignore, attr) == nil then
- if not equal_attrs(attr, {}) then
+ if self:_attr_index(attrs, attr) == nil and self:_attr_index(ignore, attr) == nil then
+ if not self:_equal_attrs(attr, {}) then
table.insert(attrs, attr)
end
end
@@ -544,7 +544,7 @@ function Screen:print_snapshot(attrs, ignore)
if self._default_attr_ids == nil or self._default_attr_ids[i] ~= a then
alldefault = false
end
- local dict = "{"..pprint_attrs(a).."}"
+ local dict = "{"..self:_pprint_attrs(a).."}"
table.insert(attrstrs, "["..tostring(i).."] = "..dict)
end
local attrstr = "{"..table.concat(attrstrs, ", ").."}"
@@ -558,7 +558,7 @@ function Screen:print_snapshot(attrs, ignore)
io.stdout:flush()
end
-function pprint_attrs(attrs)
+function Screen:_pprint_attrs(attrs)
local items = {}
for f, v in pairs(attrs) do
local desc = tostring(v)
@@ -572,7 +572,7 @@ function pprint_attrs(attrs)
return table.concat(items, ", ")
end
-function backward_find_meaningful(tbl, from)
+function backward_find_meaningful(tbl, from) -- luacheck: ignore
for i = from or #tbl, 1, -1 do
if tbl[i] ~= ' ' then
return i + 1
@@ -581,24 +581,24 @@ function backward_find_meaningful(tbl, from)
return from
end
-function get_attr_id(attr_ids, ignore, attrs)
+function Screen:_get_attr_id(attr_ids, ignore, attrs)
if not attr_ids then
return
end
for id, a in pairs(attr_ids) do
- if equal_attrs(a, attrs) then
+ if self:_equal_attrs(a, attrs) then
return id
end
end
- if equal_attrs(attrs, {}) or
- ignore == true or attr_index(ignore, attrs) ~= nil then
+ if self:_equal_attrs(attrs, {}) or
+ ignore == true or self:_attr_index(ignore, attrs) ~= nil then
-- ignore this attrs
return nil
end
- return "UNEXPECTED "..pprint_attrs(attrs)
+ return "UNEXPECTED "..self:_pprint_attrs(attrs)
end
-function equal_attrs(a, b)
+function Screen:_equal_attrs(a, b)
return a.bold == b.bold and a.standout == b.standout and
a.underline == b.underline and a.undercurl == b.undercurl and
a.italic == b.italic and a.reverse == b.reverse and
@@ -606,12 +606,12 @@ function equal_attrs(a, b)
a.background == b.background
end
-function attr_index(attrs, attr)
+function Screen:_attr_index(attrs, attr)
if not attrs then
return nil
end
for i,a in pairs(attrs) do
- if equal_attrs(a, attr) then
+ if self:_equal_attrs(a, attr) then
return i
end
end
diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua
index 092cc8c126..a4545eeff0 100644
--- a/test/functional/ui/screen_basic_spec.lua
+++ b/test/functional/ui/screen_basic_spec.lua
@@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')
local Screen = require('test.functional.ui.screen')
local spawn, set_session, clear = helpers.spawn, helpers.set_session, helpers.clear
local feed, execute = helpers.feed, helpers.execute
-local insert, wait = helpers.insert, helpers.wait
+local insert = helpers.insert
describe('Initial screen', function()
local screen
@@ -11,9 +11,6 @@ describe('Initial screen', function()
'--embed'}
before_each(function()
- if session then
- session:exit(0)
- end
local screen_nvim = spawn(nvim_argv)
set_session(screen_nvim)
screen = Screen.new()
diff --git a/test/functional/ui/searchhl_spec.lua b/test/functional/ui/searchhl_spec.lua
index d04329e1e2..e4217abcfe 100644
--- a/test/functional/ui/searchhl_spec.lua
+++ b/test/functional/ui/searchhl_spec.lua
@@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')
local Screen = require('test.functional.ui.screen')
-local clear, feed, nvim, insert = helpers.clear, helpers.feed, helpers.nvim, helpers.insert
-local execute, request, eq = helpers.execute, helpers.request, helpers.eq
+local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local execute = helpers.execute
describe('search highlighting', function()
local screen
diff --git a/test/functional/viml/completion_spec.lua b/test/functional/viml/completion_spec.lua
index 5e3d4a6658..12f542de7f 100644
--- a/test/functional/viml/completion_spec.lua
+++ b/test/functional/viml/completion_spec.lua
@@ -1,6 +1,6 @@
local helpers = require('test.functional.helpers')
-local clear, feed, execute = helpers.clear, helpers.feed, helpers.execute
+local clear, feed = helpers.clear, helpers.feed
local eval, eq, neq = helpers.eval, helpers.eq, helpers.neq
local execute, source = helpers.execute, helpers.source
diff --git a/test/includes/CMakeLists.txt b/test/includes/CMakeLists.txt
index a139683b42..3d85197f19 100644
--- a/test/includes/CMakeLists.txt
+++ b/test/includes/CMakeLists.txt
@@ -8,6 +8,7 @@ foreach(hfile ${PRE_HEADERS})
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${post_hfile}
COMMAND ${CMAKE_C_COMPILER} -std=c99 -E -P
${CMAKE_CURRENT_SOURCE_DIR}/${hfile}
+ -I${LIBUV_INCLUDE_DIRS}
-o ${CMAKE_CURRENT_BINARY_DIR}/${post_hfile})
list(APPEND POST_HEADERS ${post_hfile})
endforeach()
diff --git a/test/includes/pre/sys/errno.h b/test/includes/pre/sys/errno.h
deleted file mode 100644
index 0b8934d33e..0000000000
--- a/test/includes/pre/sys/errno.h
+++ /dev/null
@@ -1,4 +0,0 @@
-#include <sys/errno.h>
-
-static const int kENOENT = ENOENT;
-static const int kEEXIST = EEXIST;
diff --git a/test/includes/pre/uv-errno.h b/test/includes/pre/uv-errno.h
new file mode 100644
index 0000000000..6b80f60e5c
--- /dev/null
+++ b/test/includes/pre/uv-errno.h
@@ -0,0 +1,4 @@
+#include <uv-errno.h>
+
+static const int kUV_ENOENT = UV_ENOENT;
+static const int kUV_EEXIST = UV_EEXIST;
diff --git a/test/unit/buffer_spec.lua b/test/unit/buffer_spec.lua
index e0e2b827e9..a2e7bd91af 100644
--- a/test/unit/buffer_spec.lua
+++ b/test/unit/buffer_spec.lua
@@ -1,11 +1,14 @@
+
+local assert = require("luassert")
local helpers = require("test.unit.helpers")
local to_cstr = helpers.to_cstr
local eq = helpers.eq
+local neq = helpers.neq
+local NULL = helpers.NULL
+local globals = helpers.cimport("./src/nvim/globals.h")
local buffer = helpers.cimport("./src/nvim/buffer.h")
-local window = helpers.cimport("./src/nvim/window.h")
-local option = helpers.cimport("./src/nvim/option.h")
describe('buffer functions', function()
@@ -206,4 +209,95 @@ describe('buffer functions', function()
close_buffer(NULL, buf2, buffer.DOBUF_WIPE, 0)
end)
end)
+
+ describe('build_stl_str_hl', function()
+
+ local output_buffer = to_cstr(string.rep(" ", 100))
+
+ local build_stl_str_hl = function(pat)
+ return buffer.build_stl_str_hl(globals.curwin,
+ output_buffer,
+ 100,
+ to_cstr(pat),
+ false,
+ 32,
+ 80,
+ NULL,
+ NULL)
+ end
+
+ it('should copy plain text', function()
+ local width = build_stl_str_hl("this is a test")
+
+ eq(14, width)
+ eq("this is a test", helpers.ffi.string(output_buffer, width))
+
+ end)
+
+ it('should print no file name', function()
+ local width = build_stl_str_hl("%f")
+
+ eq(9, width)
+ eq("[No Name]", helpers.ffi.string(output_buffer, width))
+
+ end)
+
+ it('should print the relative file name', function()
+ buffer.setfname(globals.curbuf, to_cstr("Makefile"), NULL, 1)
+ local width = build_stl_str_hl("%f")
+
+ eq(8, width)
+ eq("Makefile", helpers.ffi.string(output_buffer, width))
+
+ end)
+
+ it('should print the full file name', function()
+ buffer.setfname(globals.curbuf, to_cstr("Makefile"), NULL, 1)
+
+ local width = build_stl_str_hl("%F")
+
+ assert.is_true(8 < width)
+ neq(NULL, string.find(helpers.ffi.string(output_buffer, width), "Makefile"))
+
+ end)
+
+ it('should print the tail file name', function()
+ buffer.setfname(globals.curbuf, to_cstr("src/nvim/buffer.c"), NULL, 1)
+
+ local width = build_stl_str_hl("%t")
+
+ eq(8, width)
+ eq("buffer.c", helpers.ffi.string(output_buffer, width))
+
+ end)
+
+ it('should print the buffer number', function()
+ buffer.setfname(globals.curbuf, to_cstr("src/nvim/buffer.c"), NULL, 1)
+
+ local width = build_stl_str_hl("%n")
+
+ eq(1, width)
+ eq("1", helpers.ffi.string(output_buffer, width))
+ end)
+
+ it('should print the current line number in the buffer', function()
+ buffer.setfname(globals.curbuf, to_cstr("test/unit/buffer_spec.lua"), NULL, 1)
+
+ local width = build_stl_str_hl("%l")
+
+ eq(1, width)
+ eq("0", helpers.ffi.string(output_buffer, width))
+
+ end)
+
+ it('should print the number of lines in the buffer', function()
+ buffer.setfname(globals.curbuf, to_cstr("test/unit/buffer_spec.lua"), NULL, 1)
+
+ local width = build_stl_str_hl("%L")
+
+ eq(1, width)
+ eq("1", helpers.ffi.string(output_buffer, width))
+
+ end)
+ end)
end)
diff --git a/test/unit/fileio_spec.lua b/test/unit/fileio_spec.lua
index 180fc3c184..3e3c36617d 100644
--- a/test/unit/fileio_spec.lua
+++ b/test/unit/fileio_spec.lua
@@ -4,6 +4,7 @@ local helpers = require("test.unit.helpers")
local eq = helpers.eq
local ffi = helpers.ffi
local to_cstr = helpers.to_cstr
+local NULL = helpers.NULL
local fileio = helpers.cimport("./src/nvim/fileio.h")
diff --git a/test/unit/formatc.lua b/test/unit/formatc.lua
index f9397eaec6..3f86c5f1b1 100644
--- a/test/unit/formatc.lua
+++ b/test/unit/formatc.lua
@@ -124,13 +124,13 @@ end
local function set(t)
local s = {}
- for i, v in ipairs(t) do
+ for _, v in ipairs(t) do
s[v] = true
end
return s
end
-local C_keywords = set {
+local C_keywords = set { -- luacheck: ignore
"break", "case", "char", "const", "continue", "default", "do", "double",
"else", "enum", "extern", "float", "for", "goto", "if", "int", "long",
"register", "return", "short", "signed", "sizeof", "static", "struct",
@@ -154,13 +154,13 @@ local C_keywords = set {
-- The first one will have a lot of false positives (the line '{' for
-- example), the second one is more unique.
local function formatc(str)
- local tokens = TokeniseC(str)
+ local toks = TokeniseC(str)
local result = {}
local block_level = 0
local allow_one_nl = false
local end_at_brace = false
- for i, token in ipairs(tokens) do
+ for _, token in ipairs(toks) do
local typ = token[2]
if typ == '{' then
block_level = block_level + 1
@@ -213,8 +213,8 @@ local function formatc(str)
end
-- standalone operation (very handy for debugging)
-local function standalone(...)
- Preprocess = require("preprocess")
+local function standalone(...) -- luacheck: ignore
+ local Preprocess = require("preprocess")
Preprocess.add_to_include_path('./../../src')
Preprocess.add_to_include_path('./../../build/include')
Preprocess.add_to_include_path('./../../.deps/usr/include')
diff --git a/test/unit/garray_spec.lua b/test/unit/garray_spec.lua
index e779cab8a7..9694e3c427 100644
--- a/test/unit/garray_spec.lua
+++ b/test/unit/garray_spec.lua
@@ -5,8 +5,6 @@ local internalize = helpers.internalize
local eq = helpers.eq
local neq = helpers.neq
local ffi = helpers.ffi
-local lib = helpers.lib
-local cstr = helpers.cstr
local to_cstr = helpers.to_cstr
local NULL = helpers.NULL
@@ -48,7 +46,7 @@ local ga_size = function(garr)
return ga_len(garr) * ga_itemsize(garr)
end
-local ga_maxsize = function(garr)
+local ga_maxsize = function(garr) -- luacheck: ignore
return ga_maxlen(garr) * ga_itemsize(garr)
end
@@ -65,8 +63,8 @@ local ga_data_as_ints = function(garr)
end
-- garray manipulation
-local ga_init = function(garr, itemsize, growsize)
- return garray.ga_init(garr, itemsize, growsize)
+local ga_init = function(garr, itemsize_, growsize_)
+ return garray.ga_init(garr, itemsize_, growsize_)
end
local ga_clear = function(garr)
@@ -113,7 +111,7 @@ local ga_set_len = function(garr, len)
end
local ga_inc_len = function(garr, by)
- return ga_set_len(garr, ga_len(garr) + 1)
+ return ga_set_len(garr, ga_len(garr) + by)
end
-- custom append functions
@@ -197,10 +195,9 @@ describe('garray', function()
end)
describe('ga_grow', function()
- local new_and_grow
- function new_and_grow(itemsize, growsize, req)
+ local function new_and_grow(itemsize_, growsize_, req)
local garr = new_garray()
- ga_init(garr, itemsize, growsize)
+ ga_init(garr, itemsize_, growsize_)
eq(0, ga_size(garr)) -- should be 0 at first
eq(NULL, ga_data(garr)) -- should be NULL
ga_grow(garr, req) -- add space for `req` items
@@ -306,7 +303,7 @@ describe('garray', function()
ga_init(garr, ffi.sizeof("char"), 1)
local str = "ohwell●●"
local loop = 5
- for i = 1, loop do
+ for _ = 1, loop do
ga_concat(garr, str)
end
@@ -321,7 +318,7 @@ describe('garray', function()
end)
end)
- function test_concat_fn(input, fn, sep)
+ local function test_concat_fn(input, fn, sep)
local garr = new_string_garray()
ga_append_strings(garr, unpack(input))
if sep == nil then
diff --git a/test/unit/helpers.lua b/test/unit/helpers.lua
index 5bcc661226..7b43b2218c 100644
--- a/test/unit/helpers.lua
+++ b/test/unit/helpers.lua
@@ -18,17 +18,9 @@ local function trim(s)
end
-- a Set that keeps around the lines we've already seen
-if cdefs == nil then
- cdefs = Set:new()
-end
-
-if imported == nil then
- imported = Set:new()
-end
-
-if pragma_pack_id == nil then
- pragma_pack_id = 1
-end
+local cdefs = Set:new()
+local imported = Set:new()
+local pragma_pack_id = 1
-- some things are just too complex for the LuaJIT C parser to digest. We
-- usually don't need them anyway.
@@ -67,7 +59,7 @@ local function cimport(...)
end
local body = nil
- for i=1, 10 do
+ for _ = 1, 10 do
local stream = Preprocess.preprocess_stream(unpack(paths))
body = stream:read("*a")
stream:close()
diff --git a/test/unit/os/env_spec.lua b/test/unit/os/env_spec.lua
index 8e18c599d9..e0e12a24f2 100644
--- a/test/unit/os/env_spec.lua
+++ b/test/unit/os/env_spec.lua
@@ -1,11 +1,9 @@
local helpers = require('test.unit.helpers')
local cimport = helpers.cimport
-local internalize = helpers.internalize
local eq = helpers.eq
local neq = helpers.neq
local ffi = helpers.ffi
-local lib = helpers.lib
local cstr = helpers.cstr
local to_cstr = helpers.to_cstr
local NULL = helpers.NULL
@@ -15,15 +13,15 @@ require('lfs')
local env = cimport('./src/nvim/os/os.h')
describe('env function', function()
- function os_setenv(name, value, override)
+ local function os_setenv(name, value, override)
return env.os_setenv((to_cstr(name)), (to_cstr(value)), override)
end
- function os_unsetenv(name, value, override)
+ local function os_unsetenv(name, _, _)
return env.os_unsetenv((to_cstr(name)))
end
- function os_getenv(name)
+ local function os_getenv(name)
local rval = env.os_getenv((to_cstr(name)))
if rval ~= NULL then
return ffi.string(rval)
diff --git a/test/unit/os/fs_spec.lua b/test/unit/os/fs_spec.lua
index 28e831229f..95c98f18a1 100644
--- a/test/unit/os/fs_spec.lua
+++ b/test/unit/os/fs_spec.lua
@@ -1,3 +1,6 @@
+local lfs = require('lfs')
+local bit = require('bit')
+
local helpers = require('test.unit.helpers')
local cimport = helpers.cimport
@@ -6,16 +9,12 @@ local internalize = helpers.internalize
local eq = helpers.eq
local neq = helpers.neq
local ffi = helpers.ffi
-local lib = helpers.lib
local cstr = helpers.cstr
local to_cstr = helpers.to_cstr
local OK = helpers.OK
local FAIL = helpers.FAIL
local NULL = helpers.NULL
-require('lfs')
-require('bit')
-
cimport('unistd.h')
cimport('./src/nvim/os/shell.h')
cimport('./src/nvim/option_defs.h')
@@ -24,10 +23,9 @@ cimport('./src/nvim/fileio.h')
local fs = cimport('./src/nvim/os/os.h')
cppimport('sys/stat.h')
cppimport('sys/fcntl.h')
-cppimport('sys/errno.h')
+cppimport('uv-errno.h')
-local len = 0
-local buf = ""
+local buffer = ""
local directory = nil
local absolute_executable = nil
local executable_name = nil
@@ -85,24 +83,26 @@ describe('fs function', function()
end)
describe('os_dirname', function()
+ local length
+
local function os_dirname(buf, len)
return fs.os_dirname(buf, len)
end
before_each(function()
- len = (string.len(lfs.currentdir())) + 1
- buf = cstr(len, '')
+ length = (string.len(lfs.currentdir())) + 1
+ buffer = cstr(length, '')
end)
it('returns OK and writes current directory into the buffer if it is large\n enough', function()
- eq(OK, (os_dirname(buf, len)))
- eq(lfs.currentdir(), (ffi.string(buf)))
+ eq(OK, (os_dirname(buffer, length)))
+ eq(lfs.currentdir(), (ffi.string(buffer)))
end)
-- What kind of other failing cases are possible?
it('returns FAIL if the buffer is too small', function()
- local buf = cstr((len - 1), '')
- eq(FAIL, (os_dirname(buf, (len - 1))))
+ local buf = cstr((length - 1), '')
+ eq(FAIL, (os_dirname(buf, (length - 1))))
end)
end)
@@ -213,15 +213,6 @@ describe('fs function', function()
os_setperm('unit-test-directory/test.file', orig_test_file_perm)
end)
- local function os_getperm(filename)
- local perm = fs.os_getperm((to_cstr(filename)))
- return tonumber(perm)
- end
-
- local function os_setperm(filename, perm)
- return fs.os_setperm((to_cstr(filename)), perm)
- end
-
local function os_fchown(filename, user_id, group_id)
local fd = ffi.C.open(filename, 0)
local res = fs.os_fchown(fd, user_id, group_id)
@@ -242,8 +233,8 @@ describe('fs function', function()
end
describe('os_getperm', function()
- it('returns -1 when the given file does not exist', function()
- eq(-1, (os_getperm('non-existing-file')))
+ it('returns UV_ENOENT when the given file does not exist', function()
+ eq(ffi.C.UV_ENOENT, (os_getperm('non-existing-file')))
end)
it('returns a perm > 0 when given an existing file', function()
@@ -454,8 +445,8 @@ describe('fs function', function()
local new_file = 'test_new_file'
local existing_file = 'unit-test-directory/test_existing.file'
- it('returns -ENOENT for O_RDWR on a non-existing file', function()
- eq(-ffi.C.kENOENT, (os_open('non-existing-file', ffi.C.kO_RDWR, 0)))
+ it('returns UV_ENOENT for O_RDWR on a non-existing file', function()
+ eq(ffi.C.UV_ENOENT, (os_open('non-existing-file', ffi.C.kO_RDWR, 0)))
end)
it('returns non-negative for O_CREAT on a non-existing file', function()
@@ -468,9 +459,9 @@ describe('fs function', function()
assert.is_true(0 <= (os_open(existing_file, ffi.C.kO_CREAT, 0)))
end)
- it('returns -EEXIST for O_CREAT|O_EXCL on a existing file', function()
+ it('returns UV_EEXIST for O_CREAT|O_EXCL on a existing file', function()
assert_file_exists(existing_file)
- eq(-ffi.C.kEEXIST, (os_open(existing_file, (bit.bor(ffi.C.kO_CREAT, ffi.C.kO_EXCL)), 0)))
+ eq(ffi.C.kUV_EEXIST, (os_open(existing_file, (bit.bor(ffi.C.kO_CREAT, ffi.C.kO_EXCL)), 0)))
end)
it('sets `rwx` permissions for O_CREAT 700', function()
@@ -564,6 +555,28 @@ describe('fs function', function()
eq(false, os_isdir('unit-test-directory/new-dir-recurse'))
end)
+ it('succeeds to create a directory ending with ///', function()
+ local mode = ffi.C.kS_IRUSR + ffi.C.kS_IWUSR + ffi.C.kS_IXUSR
+ local ret, failed_str = os_mkdir_recurse(
+ 'unit-test-directory/new-dir-recurse///', mode)
+ eq(0, ret)
+ eq(nil, failed_str)
+ eq(true, os_isdir('unit-test-directory/new-dir-recurse'))
+ lfs.rmdir('unit-test-directory/new-dir-recurse')
+ eq(false, os_isdir('unit-test-directory/new-dir-recurse'))
+ end)
+
+ it('succeeds to create a directory ending with /', function()
+ local mode = ffi.C.kS_IRUSR + ffi.C.kS_IWUSR + ffi.C.kS_IXUSR
+ local ret, failed_str = os_mkdir_recurse(
+ 'unit-test-directory/new-dir-recurse/', mode)
+ eq(0, ret)
+ eq(nil, failed_str)
+ eq(true, os_isdir('unit-test-directory/new-dir-recurse'))
+ lfs.rmdir('unit-test-directory/new-dir-recurse')
+ eq(false, os_isdir('unit-test-directory/new-dir-recurse'))
+ end)
+
it('succeeds to create a directory tree', function()
local mode = ffi.C.kS_IRUSR + ffi.C.kS_IWUSR + ffi.C.kS_IXUSR
local ret, failed_str = os_mkdir_recurse(
@@ -589,7 +602,7 @@ describe('fs function', function()
it('removes the given directory and returns 0', function()
lfs.mkdir('unit-test-directory/new-dir')
- eq(0, (os_rmdir('unit-test-directory/new-dir', mode)))
+ eq(0, os_rmdir('unit-test-directory/new-dir'))
eq(false, (os_isdir('unit-test-directory/new-dir')))
end)
end)
diff --git a/test/unit/os/shell_spec.lua b/test/unit/os/shell_spec.lua
index 20cfc17950..01deefab0c 100644
--- a/test/unit/os/shell_spec.lua
+++ b/test/unit/os/shell_spec.lua
@@ -17,7 +17,7 @@ local shell = helpers.cimport(
'./src/nvim/main.h',
'./src/nvim/misc1.h'
)
-local ffi, eq, neq = helpers.ffi, helpers.eq, helpers.neq
+local ffi, eq = helpers.ffi, helpers.eq
local intern = helpers.internalize
local to_cstr = helpers.to_cstr
local NULL = ffi.cast('void *', 0)
@@ -70,7 +70,7 @@ describe('shell functions', function()
end)
it ('returns non-zero exit code', function()
- local status, output = os_system('exit 2')
+ local status = os_system('exit 2')
eq(2, status)
end)
end)
diff --git a/test/unit/os/users_spec.lua b/test/unit/os/users_spec.lua
index df5d2365c6..236481e9e7 100644
--- a/test/unit/os/users_spec.lua
+++ b/test/unit/os/users_spec.lua
@@ -1,26 +1,24 @@
local helpers = require('test.unit.helpers')
local cimport = helpers.cimport
-local internalize = helpers.internalize
local eq = helpers.eq
local ffi = helpers.ffi
local lib = helpers.lib
-local cstr = helpers.cstr
local NULL = helpers.NULL
local OK = helpers.OK
local FAIL = helpers.FAIL
local users = cimport('./src/nvim/os/os.h', 'unistd.h')
-function garray_new()
+local function garray_new()
return ffi.new('garray_T[1]')
end
-function garray_get_len(array)
+local function garray_get_len(array)
return array[0].ga_len
end
-function garray_get_item(array, index)
+local function garray_get_item(array, index)
return (ffi.cast('void **', array[0].ga_data))[index]
end
diff --git a/test/unit/path_spec.lua b/test/unit/path_spec.lua
index 239a255151..9b76834383 100644
--- a/test/unit/path_spec.lua
+++ b/test/unit/path_spec.lua
@@ -1,18 +1,16 @@
+local lfs = require('lfs')
local helpers = require('test.unit.helpers')
local cimport = helpers.cimport
-local internalize = helpers.internalize
local eq = helpers.eq
local neq = helpers.neq
local ffi = helpers.ffi
-local lib = helpers.lib
local cstr = helpers.cstr
local to_cstr = helpers.to_cstr
local NULL = helpers.NULL
local OK = helpers.OK
local FAIL = helpers.FAIL
-require('lfs')
cimport('string.h')
local path = cimport('./src/nvim/path.h')
@@ -23,7 +21,7 @@ local kBothFilesMissing = path.kBothFilesMissing
local kOneFileMissing = path.kOneFileMissing
local kEqualFileNames = path.kEqualFileNames
-local len = 0
+local length = 0
local buffer = nil
describe('path function', function()
@@ -36,19 +34,19 @@ describe('path function', function()
lfs.rmdir('unit-test-directory')
end)
- function path_full_dir_name(directory, buffer, len)
+ local function path_full_dir_name(directory, buf, len)
directory = to_cstr(directory)
- return path.path_full_dir_name(directory, buffer, len)
+ return path.path_full_dir_name(directory, buf, len)
end
before_each(function()
-- Create empty string buffer which will contain the resulting path.
- len = (string.len(lfs.currentdir())) + 22
- buffer = cstr(len, '')
+ length = string.len(lfs.currentdir()) + 22
+ buffer = cstr(length, '')
end)
it('returns the absolute directory name of a given relative one', function()
- local result = path_full_dir_name('..', buffer, len)
+ local result = path_full_dir_name('..', buffer, length)
eq(OK, result)
local old_dir = lfs.currentdir()
lfs.chdir('..')
@@ -58,23 +56,23 @@ describe('path function', function()
end)
it('returns the current directory name if the given string is empty', function()
- eq(OK, (path_full_dir_name('', buffer, len)))
+ eq(OK, (path_full_dir_name('', buffer, length)))
eq(lfs.currentdir(), (ffi.string(buffer)))
end)
it('fails if the given directory does not exist', function()
- eq(FAIL, path_full_dir_name('does_not_exist', buffer, len))
+ eq(FAIL, path_full_dir_name('does_not_exist', buffer, length))
end)
it('works with a normal relative dir', function()
- local result = path_full_dir_name('unit-test-directory', buffer, len)
+ local result = path_full_dir_name('unit-test-directory', buffer, length)
eq(lfs.currentdir() .. '/unit-test-directory', (ffi.string(buffer)))
eq(OK, result)
end)
end)
describe('path_full_compare', function()
- function path_full_compare(s1, s2, cn)
+ local function path_full_compare(s1, s2, cn)
s1 = to_cstr(s1)
s2 = to_cstr(s2)
return path.path_full_compare(s1, s2, cn or 0)
@@ -117,7 +115,7 @@ describe('path function', function()
end)
describe('path_tail', function()
- function path_tail(file)
+ local function path_tail(file)
local res = path.path_tail((to_cstr(file)))
neq(NULL, res)
return ffi.string(res)
@@ -133,7 +131,7 @@ describe('path function', function()
end)
describe('path_tail_with_sep', function()
- function path_tail_with_sep(file)
+ local function path_tail_with_sep(file)
local res = path.path_tail_with_sep((to_cstr(file)))
neq(NULL, res)
return ffi.string(res)
@@ -165,7 +163,7 @@ describe('path function', function()
-- Returns the path tail and length (out param) of the tail.
-- Does not convert the tail from C-pointer to lua string for use with
-- strcmp.
- function invocation_path_tail(invk)
+ local function invocation_path_tail(invk)
local plen = ffi.new('size_t[?]', 1)
local ptail = path.invocation_path_tail((to_cstr(invk)), plen)
neq(NULL, ptail)
@@ -178,7 +176,7 @@ describe('path function', function()
end
-- This test mimics the intended use in C.
- function compare(base, pinvk, len)
+ local function compare(base, pinvk, len)
return eq(0, (ffi.C.strncmp((to_cstr(base)), pinvk, len)))
end
@@ -207,7 +205,7 @@ describe('path function', function()
end)
it('only accepts whitespace as a terminator for the executable name', function()
- local invk, len = invocation_path_tail('exe-a+b_c[]()|#!@$%^&*')
+ local invk, _ = invocation_path_tail('exe-a+b_c[]()|#!@$%^&*')
eq('exe-a+b_c[]()|#!@$%^&*', (ffi.string(invk)))
end)
@@ -215,20 +213,20 @@ describe('path function', function()
local ptail = path.path_tail(to_cstr("a/b/c x y z"))
neq(NULL, ptail)
local tail = ffi.string(ptail)
- local invk, len = invocation_path_tail("a/b/c x y z")
+ local invk, _ = invocation_path_tail("a/b/c x y z")
eq(tail, ffi.string(invk))
end)
it('is not equivalent to path_tail when args contain a path separator', function()
local ptail = path.path_tail(to_cstr("a/b/c x y/z"))
neq(NULL, ptail)
- local invk, len = invocation_path_tail("a/b/c x y/z")
+ local invk, _ = invocation_path_tail("a/b/c x y/z")
neq((ffi.string(ptail)), (ffi.string(invk)))
end)
end)
describe('path_next_component', function()
- function path_next_component(file)
+ local function path_next_component(file)
local res = path.path_next_component((to_cstr(file)))
neq(NULL, res)
return ffi.string(res)
@@ -308,11 +306,11 @@ describe('more path function', function()
-- Since the tests are executed, they are called by an executable. We use
-- that executable for several asserts.
- absolute_executable = arg[0]
+ local absolute_executable = arg[0]
-- Split absolute_executable into a directory and the actual file name for
-- later usage.
- directory, executable_name = string.match(absolute_executable, '^(.*)/(.*)$')
+ local directory, executable_name = string.match(absolute_executable, '^(.*)/(.*)$') -- luacheck: ignore
end)
teardown(function()
@@ -321,27 +319,27 @@ describe('more path function', function()
end)
describe('vim_FullName', function()
- function vim_FullName(filename, buffer, length, force)
+ local function vim_FullName(filename, buf, len, force)
filename = to_cstr(filename)
- return path.vim_FullName(filename, buffer, length, force)
+ return path.vim_FullName(filename, buf, len, force)
end
before_each(function()
-- Create empty string buffer which will contain the resulting path.
- len = (string.len(lfs.currentdir())) + 33
- buffer = cstr(len, '')
+ length = (string.len(lfs.currentdir())) + 33
+ buffer = cstr(length, '')
end)
it('fails if given filename is NULL', function()
local force_expansion = 1
- local result = path.vim_FullName(NULL, buffer, len, force_expansion)
+ local result = path.vim_FullName(NULL, buffer, length, force_expansion)
eq(FAIL, result)
end)
it('uses the filename if the filename is a URL', function()
local force_expansion = 1
local filename = 'http://www.neovim.org'
- local result = vim_FullName(filename, buffer, len, force_expansion)
+ local result = vim_FullName(filename, buffer, length, force_expansion)
eq(filename, (ffi.string(buffer)))
eq(OK, result)
end)
@@ -349,14 +347,14 @@ describe('more path function', function()
it('fails and uses filename if given filename contains non-existing directory', function()
local force_expansion = 1
local filename = 'non_existing_dir/test.file'
- local result = vim_FullName(filename, buffer, len, force_expansion)
+ local result = vim_FullName(filename, buffer, length, force_expansion)
eq(filename, (ffi.string(buffer)))
eq(FAIL, result)
end)
it('concatenates given filename if it does not contain a slash', function()
local force_expansion = 1
- local result = vim_FullName('test.file', buffer, len, force_expansion)
+ local result = vim_FullName('test.file', buffer, length, force_expansion)
local expected = lfs.currentdir() .. '/test.file'
eq(expected, (ffi.string(buffer)))
eq(OK, result)
@@ -364,7 +362,7 @@ describe('more path function', function()
it('concatenates given filename if it is a directory but does not contain a\n slash', function()
local force_expansion = 1
- local result = vim_FullName('..', buffer, len, force_expansion)
+ local result = vim_FullName('..', buffer, length, force_expansion)
local expected = lfs.currentdir() .. '/..'
eq(expected, (ffi.string(buffer)))
eq(OK, result)
@@ -374,7 +372,7 @@ describe('more path function', function()
-- the unit tests? Which other directory would be better?
it('enters given directory (instead of just concatenating the strings) if possible and if path contains a slash', function()
local force_expansion = 1
- local result = vim_FullName('../test.file', buffer, len, force_expansion)
+ local result = vim_FullName('../test.file', buffer, length, force_expansion)
local old_dir = lfs.currentdir()
lfs.chdir('..')
local expected = lfs.currentdir() .. '/test.file'
@@ -386,7 +384,7 @@ describe('more path function', function()
it('just copies the path if it is already absolute and force=0', function()
local force_expansion = 0
local absolute_path = '/absolute/path'
- local result = vim_FullName(absolute_path, buffer, len, force_expansion)
+ local result = vim_FullName(absolute_path, buffer, length, force_expansion)
eq(absolute_path, (ffi.string(buffer)))
eq(OK, result)
end)
@@ -394,14 +392,14 @@ describe('more path function', function()
it('fails and uses filename when the path is relative to HOME', function()
local force_expansion = 1
local absolute_path = '~/home.file'
- local result = vim_FullName(absolute_path, buffer, len, force_expansion)
+ local result = vim_FullName(absolute_path, buffer, length, force_expansion)
eq(absolute_path, (ffi.string(buffer)))
eq(FAIL, result)
end)
it('works with some "normal" relative path with directories', function()
local force_expansion = 1
- local result = vim_FullName('unit-test-directory/test.file', buffer, len, force_expansion)
+ local result = vim_FullName('unit-test-directory/test.file', buffer, length, force_expansion)
eq(OK, result)
eq(lfs.currentdir() .. '/unit-test-directory/test.file', (ffi.string(buffer)))
end)
@@ -411,7 +409,7 @@ describe('more path function', function()
local filename = to_cstr('unit-test-directory/test.file')
-- Don't use the wrapper here but pass a cstring directly to the c
-- function.
- local result = path.vim_FullName(filename, buffer, len, force_expansion)
+ local result = path.vim_FullName(filename, buffer, length, force_expansion)
eq(lfs.currentdir() .. '/unit-test-directory/test.file', (ffi.string(buffer)))
eq('unit-test-directory/test.file', (ffi.string(filename)))
eq(OK, result)
@@ -420,15 +418,15 @@ describe('more path function', function()
it('works with directories that have one path component', function()
local force_expansion = 1
local filename = to_cstr('/tmp')
- local result = path.vim_FullName(filename, buffer, len, force_expansion)
+ local result = path.vim_FullName(filename, buffer, length, force_expansion)
eq('/tmp', ffi.string(buffer))
eq(OK, result)
end)
end)
describe('path_fix_case', function()
- function fix_case(file)
- c_file = to_cstr(file)
+ local function fix_case(file)
+ local c_file = to_cstr(file)
path.path_fix_case(c_file)
return ffi.string(c_file)
end
@@ -493,7 +491,7 @@ describe('more path function', function()
end)
describe('path_is_absolute_path', function()
- function path_is_absolute_path(filename)
+ local function path_is_absolute_path(filename)
filename = to_cstr(filename)
return path.path_is_absolute_path(filename)
end
diff --git a/test/unit/preprocess.lua b/test/unit/preprocess.lua
index d4c2e088a4..e5c838b13b 100644
--- a/test/unit/preprocess.lua
+++ b/test/unit/preprocess.lua
@@ -169,8 +169,8 @@ local type_to_class = {
-- find the best cc. If os.exec causes problems on windows (like popping up
-- a console window) we might consider using something like this:
-- http://scite-ru.googlecode.com/svn/trunk/pack/tools/LuaLib/shell.html#exec
-local function find_best_cc(ccs)
- for _, meta in pairs(ccs) do
+local function find_best_cc(compilers)
+ for _, meta in pairs(compilers) do
local version = io.popen(tostring(meta.path) .. " -v 2>&1")
version:close()
if version then
diff --git a/test/unit/profile_spec.lua b/test/unit/profile_spec.lua
index 2b006a0768..852475fe2c 100644
--- a/test/unit/profile_spec.lua
+++ b/test/unit/profile_spec.lua
@@ -36,20 +36,20 @@ local function cmp_assert(v1, v2, op, opstr)
assert.is_true(res)
end
-local function lt(v1, v2)
- cmp_assert(v1, v2, function(v1, v2) return v1 < v2 end, "<")
+local function lt(a, b) -- luacheck: ignore
+ cmp_assert(a, b, function(x, y) return x < y end, "<")
end
-local function lte(v1, v2)
- cmp_assert(v1, v2, function(v1, v2) return v1 <= v2 end, "<=")
+local function lte(a, b) -- luacheck: ignore
+ cmp_assert(a, b, function(x, y) return x <= y end, "<=")
end
-local function gt(v1, v2)
- cmp_assert(v1, v2, function(v1, v2) return v1 > v2 end, ">")
+local function gt(a, b) -- luacheck: ignore
+ cmp_assert(a, b, function(x, y) return x > y end, ">")
end
-local function gte(v1, v2)
- cmp_assert(v1, v2, function(v1, v2) return v1 >= v2 end, ">=")
+local function gte(a, b)
+ cmp_assert(a, b, function(x, y) return x >= y end, ">=")
end
-- missing functions:
@@ -70,7 +70,7 @@ describe('profiling related functions', function()
local function profile_equal(t1, t2) return prof.profile_equal(t1, t2) end
local function profile_msg(t) return ffi.string(prof.profile_msg(t)) end
- local function toseconds(t)
+ local function toseconds(t) -- luacheck: ignore
local str = trim(profile_msg(t))
local spl = split(str, ".")
local s, us = spl[1], spl[2]
@@ -122,7 +122,7 @@ describe('profiling related functions', function()
local divided = profile_divide(start, divisor)
local res = divided
- for i = 1, divisor - 1 do
+ for _ = 1, divisor - 1 do
res = profile_add(res, divided)
end
@@ -143,7 +143,7 @@ describe('profiling related functions', function()
describe('profile_start', function()
it('increases', function()
local last = profile_start()
- for i=1,100 do
+ for _ = 1, 100 do
local curr = profile_start()
gte(curr, last)
last = curr
@@ -157,7 +157,7 @@ describe('profiling related functions', function()
end)
it('outer elapsed >= inner elapsed', function()
- for i = 1, 100 do
+ for _ = 1, 100 do
local start_outer = profile_start()
local start_inner = profile_start()
local elapsed_inner = profile_end(start_inner)
@@ -238,7 +238,7 @@ describe('profiling related functions', function()
-- t2 >= t1 => profile_cmp(t1, t2) >= 0
assert.is_true(cmp >= 0)
- local cmp = profile_cmp(profile_sub(start3, start1), profile_sub(start2, start1))
+ cmp = profile_cmp(profile_sub(start3, start1), profile_sub(start2, start1))
-- t2 <= t1 => profile_cmp(t1, t2) <= 0
assert.is_true(cmp <= 0)
end)
diff --git a/test/unit/set.lua b/test/unit/set.lua
index bfb6b8c41c..4e66546f32 100644
--- a/test/unit/set.lua
+++ b/test/unit/set.lua
@@ -35,7 +35,7 @@ end
-- adds the argument table to this Set
function Set:union_table(t)
- for k, v in pairs(t) do
+ for _, v in pairs(t) do
self:add(v)
end
end
diff --git a/third-party/cmake/BuildLibuv.cmake b/third-party/cmake/BuildLibuv.cmake
index 2919d289cc..5debe5c071 100644
--- a/third-party/cmake/BuildLibuv.cmake
+++ b/third-party/cmake/BuildLibuv.cmake
@@ -43,18 +43,18 @@ set(UNIX_CFGCMD sh ${DEPS_BUILD_DIR}/src/libuv/autogen.sh &&
if(UNIX)
BuildLibUv(
CONFIGURE_COMMAND ${UNIX_CFGCMD}
- INSTALL_COMMAND ${MAKE_PRG} install)
+ INSTALL_COMMAND ${MAKE_PRG} V=1 install)
elseif(MINGW AND CMAKE_CROSSCOMPILING)
# Build libuv for the host
BuildLibUv(TARGET libuv_host
CONFIGURE_COMMAND sh ${DEPS_BUILD_DIR}/src/libuv_host/autogen.sh && ${DEPS_BUILD_DIR}/src/libuv_host/configure --with-pic --disable-shared --prefix=${HOSTDEPS_INSTALL_DIR} CC=${HOST_C_COMPILER}
- INSTALL_COMMAND ${MAKE_PRG} install)
+ INSTALL_COMMAND ${MAKE_PRG} V=1 install)
# Build libuv for the target
BuildLibUv(
CONFIGURE_COMMAND ${UNIX_CFGCMD} --host=${CROSS_TARGET}
- INSTALL_COMMAND ${MAKE_PRG} install)
+ INSTALL_COMMAND ${MAKE_PRG} V=1 install)
elseif(WIN32 AND MSVC)
diff --git a/third-party/cmake/BuildLuajit.cmake b/third-party/cmake/BuildLuajit.cmake
index 3598b00c04..83aceecb59 100644
--- a/third-party/cmake/BuildLuajit.cmake
+++ b/third-party/cmake/BuildLuajit.cmake
@@ -41,6 +41,7 @@ set(INSTALLCMD_UNIX ${MAKE_PRG} CFLAGS=-fPIC
CFLAGS+=-DLUA_USE_ASSERT
CCDEBUG+=-g
BUILDMODE=static
+ Q=
install)
if(UNIX)
@@ -67,6 +68,7 @@ elseif(MINGW AND CMAKE_CROSSCOMPILING)
HOST_CC=${HOST_C_COMPILER} HOST_CFLAGS=${HOST_C_FLAGS}
HOST_LDFLAGS=${HOST_EXE_LINKER_FLAGS}
FILE_T=luajit.exe
+ Q=
INSTALL_TSYMNAME=luajit.exe)
elseif(WIN32 AND MSVC)
diff --git a/third-party/cmake/BuildLuarocks.cmake b/third-party/cmake/BuildLuarocks.cmake
index 79d7e83ce7..a6126af789 100644
--- a/third-party/cmake/BuildLuarocks.cmake
+++ b/third-party/cmake/BuildLuarocks.cmake
@@ -116,17 +116,24 @@ list(APPEND THIRD_PARTY_DEPS lpeg)
if(USE_BUNDLED_BUSTED)
add_custom_command(OUTPUT ${HOSTDEPS_BIN_DIR}/busted
COMMAND ${LUAROCKS_BINARY}
- ARGS build https://raw.githubusercontent.com/Olivine-Labs/busted/v2.0.rc10-0/busted-2.0.rc10-0.rockspec ${LUAROCKS_BUILDARGS}
+ ARGS build https://raw.githubusercontent.com/Olivine-Labs/busted/v2.0.rc11-0/busted-2.0.rc11-0.rockspec ${LUAROCKS_BUILDARGS}
DEPENDS luarocks)
add_custom_target(busted
DEPENDS ${HOSTDEPS_BIN_DIR}/busted)
+ add_custom_command(OUTPUT ${HOSTDEPS_BIN_DIR}/luacheck
+ COMMAND ${LUAROCKS_BINARY}
+ ARGS build https://raw.githubusercontent.com/mpeterv/luacheck/3929eaa3528be2a8a50c593d687c8625205a2033/luacheck-scm-1.rockspec ${LUAROCKS_BUILDARGS}
+ DEPENDS busted)
+ add_custom_target(luacheck
+ DEPENDS ${HOSTDEPS_BIN_DIR}/luacheck)
+
add_custom_command(OUTPUT ${HOSTDEPS_LIB_DIR}/luarocks/rocks/nvim-client
COMMAND ${LUAROCKS_BINARY}
ARGS build https://raw.githubusercontent.com/neovim/lua-client/0.0.1-14/nvim-client-0.0.1-14.rockspec ${LUAROCKS_BUILDARGS} LIBUV_DIR=${HOSTDEPS_INSTALL_DIR}
- DEPENDS busted libuv)
+ DEPENDS luacheck libuv)
add_custom_target(nvim-client
DEPENDS ${HOSTDEPS_LIB_DIR}/luarocks/rocks/nvim-client)
- list(APPEND THIRD_PARTY_DEPS busted nvim-client)
+ list(APPEND THIRD_PARTY_DEPS busted luacheck nvim-client)
endif()