diff options
-rw-r--r-- | runtime/doc/eval.txt | 44 | ||||
-rw-r--r-- | runtime/doc/gui.txt | 4 | ||||
-rw-r--r-- | runtime/doc/map.txt | 12 | ||||
-rw-r--r-- | runtime/macros/shellmenu.vim | 97 | ||||
-rw-r--r-- | runtime/macros/swapmous.vim | 25 | ||||
-rw-r--r-- | runtime/pack/dist/opt/shellmenu/plugin/shellmenu.vim | 94 | ||||
-rw-r--r-- | runtime/pack/dist/opt/swapmouse/plugin/swapmouse.vim | 22 | ||||
-rw-r--r-- | src/nvim/edit.c | 2 | ||||
-rw-r--r-- | src/nvim/eval.c | 45 | ||||
-rw-r--r-- | src/nvim/ex_docmd.c | 11 | ||||
-rw-r--r-- | src/nvim/memline.c | 7 | ||||
-rw-r--r-- | src/nvim/regexp.c | 26 | ||||
-rw-r--r-- | src/nvim/regexp_nfa.c | 23 | ||||
-rw-r--r-- | src/nvim/testdir/test_alot.vim | 2 | ||||
-rw-r--r-- | src/nvim/testdir/test_cmdline.vim | 120 | ||||
-rw-r--r-- | src/nvim/testdir/test_popup.vim | 30 | ||||
-rw-r--r-- | src/nvim/version.c | 601 | ||||
-rw-r--r-- | test/functional/legacy/036_regexp_character_classes_spec.lua | 11 |
18 files changed, 1021 insertions, 155 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 9ff97436bb..de1ced160c 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1887,6 +1887,7 @@ getcmdline() String return the current command-line getcmdpos() Number return cursor position in command-line getcmdtype() String return current command-line type getcmdwintype() String return current command-line window type +getcompletion({pat}, {type}) List list of cmdline completion matches getcurpos() List position of the cursor getcwd([{winnr} [, {tabnr}]]) String the current working directory getfontname([{name}]) String name of font being used @@ -3647,6 +3648,49 @@ getcmdwintype() *getcmdwintype()* values are the same as |getcmdtype()|. Returns an empty string when not in the command-line window. +getcompletion({pat}, {type}) *getcompletion()* + Return a list of command-line completion matches. {type} + specifies what for. The following completion types are + supported: + + augroup autocmd groups + buffer buffer names + behave :behave suboptions + color color schemes + command Ex command (and arguments) + compiler compilers + cscope |:cscope| suboptions + dir directory names + environment environment variable names + event autocommand events + expression Vim expression + file file and directory names + file_in_path file and directory names in |'path'| + filetype filetype names |'filetype'| + function function name + help help subjects + highlight highlight groups + history :history suboptions + locale locale names (as output of locale -a) + mapping mapping name + menu menus + option options + shellcmd Shell command + sign |:sign| suboptions + syntax syntax file names |'syntax'| + syntime |:syntime| suboptions + tag tags + tag_listfiles tags, file names + user user names + var user variables + + If {pat} is an empty string, then all the matches are returned. + Otherwise only items matching {pat} are returned. See + |wildcards| for the use of special characters in {pat}. + + If there are no matches, an empty list is returned. An + invalid value for {type} produces an error. + *getcurpos()* getcurpos() Get the position of the cursor. This is like getpos('.'), but includes an extra item in the list: diff --git a/runtime/doc/gui.txt b/runtime/doc/gui.txt index e2fb501ac5..1e8bb408d9 100644 --- a/runtime/doc/gui.txt +++ b/runtime/doc/gui.txt @@ -825,13 +825,13 @@ the <CR> key. |<>|) See section |42.4| in the user manual. - *:tmenu* *:tm* + *:tmenu* :tm[enu] {menupath} {rhs} Define a tip for a menu or tool. {only in X11 and Win32 GUI} :tm[enu] [menupath] List menu tips. {only in X11 and Win32 GUI} - *:tunmenu* *:tu* + *:tunmenu* :tu[nmenu] {menupath} Remove a tip for a menu or tool. {only in X11 and Win32 GUI} diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt index 31c3198f72..c1eef398e2 100644 --- a/runtime/doc/map.txt +++ b/runtime/doc/map.txt @@ -55,6 +55,7 @@ modes. :im[ap] {lhs} {rhs} |mapmode-i| *:im* *:imap* :lm[ap] {lhs} {rhs} |mapmode-l| *:lm* *:lmap* :cm[ap] {lhs} {rhs} |mapmode-c| *:cm* *:cmap* +:tm[ap] {lhs} {rhs} |mapmode-t| *:tm* *:tmap* Map the key sequence {lhs} to {rhs} for the modes where the map command applies. The result, including {rhs}, is then further scanned for mappings. This @@ -71,6 +72,7 @@ modes. :ino[remap] {lhs} {rhs} |mapmode-i| *:ino* *:inoremap* :ln[oremap] {lhs} {rhs} |mapmode-l| *:ln* *:lnoremap* :cno[remap] {lhs} {rhs} |mapmode-c| *:cno* *:cnoremap* +:tno[remap] {lhs} {rhs} |mapmode-t| *:tno* *:tnoremap* Map the key sequence {lhs} to {rhs} for the modes where the map command applies. Disallow mapping of {rhs}, to avoid nested and recursive mappings. Often @@ -87,6 +89,7 @@ modes. :iu[nmap] {lhs} |mapmode-i| *:iu* *:iunmap* :lu[nmap] {lhs} |mapmode-l| *:lu* *:lunmap* :cu[nmap] {lhs} |mapmode-c| *:cu* *:cunmap* +:tu[nmap] {lhs} |mapmode-t| *:tu* *:tunmap* Remove the mapping of {lhs} for the modes where the map command applies. The mapping may remain defined for other modes where it applies. @@ -105,6 +108,7 @@ modes. :imapc[lear] |mapmode-i| *:imapc* *:imapclear* :lmapc[lear] |mapmode-l| *:lmapc* *:lmapclear* :cmapc[lear] |mapmode-c| *:cmapc* *:cmapclear* +:tmapc[lear] |mapmode-t| *:tmapc* *:tmapclear* Remove ALL mappings for the modes where the map command applies. Use the <buffer> argument to remove buffer-local @@ -121,6 +125,7 @@ modes. :im[ap] |mapmode-i| :lm[ap] |mapmode-l| :cm[ap] |mapmode-c| +:tm[ap] |mapmode-t| List all key mappings for the modes where the map command applies. Note that ":map" and ":map!" are used most often, because they include the other modes. @@ -135,6 +140,7 @@ modes. :im[ap] {lhs} |mapmode-i| *:imap_l* :lm[ap] {lhs} |mapmode-l| *:lmap_l* :cm[ap] {lhs} |mapmode-c| *:cmap_l* +:tm[ap] {lhs} |mapmode-t| *:tmap_l* List the key mappings for the key sequences starting with {lhs} in the modes where the map command applies. @@ -288,9 +294,9 @@ as a special key. 1.3 MAPPING AND MODES *:map-modes* - *mapmode-nvo* *mapmode-n* *mapmode-v* *mapmode-o* + *mapmode-nvo* *mapmode-n* *mapmode-v* *mapmode-o* *mapmode-t* -There are six sets of mappings +There are seven sets of mappings - For Normal mode: When typing commands. - For Visual mode: When typing commands while the Visual area is highlighted. - For Select mode: like Visual mode but typing text replaces the selection. @@ -298,6 +304,7 @@ There are six sets of mappings etc.). See below: |omap-info|. - For Insert mode. These are also used in Replace mode. - For Command-line mode: When entering a ":" or "/" command. +- For Terminal mode: When typing in a |:terminal| buffer. Special case: While typing a count for a command in Normal mode, mapping zero is disabled. This makes it possible to map zero without making it impossible @@ -316,6 +323,7 @@ Overview of which map command works in which mode. More details below. :imap :inoremap :iunmap Insert :lmap :lnoremap :lunmap Insert, Command-line, Lang-Arg :cmap :cnoremap :cunmap Command-line +:tmap :tnoremap :tunmap Terminal COMMANDS MODES ~ diff --git a/runtime/macros/shellmenu.vim b/runtime/macros/shellmenu.vim index 6175d1d9a6..4eb72a556a 100644 --- a/runtime/macros/shellmenu.vim +++ b/runtime/macros/shellmenu.vim @@ -1,94 +1,3 @@ -" When you're writing shell scripts and you are in doubt which test to use, -" which shell environment variables are defined, what the syntax of the case -" statement is, and you need to invoke 'man sh'? -" -" Your problems are over now! -" -" Attached is a Vim script file for turning gvim into a shell script editor. -" It may also be used as an example how to use menus in Vim. -" -" Written by: Lennart Schultz <les@dmi.min.dk> - -imenu Stmts.for for in
do
doneki kk0elli -imenu Stmts.case case in
) ;;
esacbki k0elli -imenu Stmts.if if
then
fiki kk0elli -imenu Stmts.if-else if
then
else
fiki kki kk0elli -imenu Stmts.elif elif
then
ki kk0elli -imenu Stmts.while while
do
doneki kk0elli -imenu Stmts.break break -imenu Stmts.continue continue -imenu Stmts.function () {
}ki k0i -imenu Stmts.return return -imenu Stmts.return-true return 0 -imenu Stmts.return-false return 1 -imenu Stmts.exit exit -imenu Stmts.shift shift -imenu Stmts.trap trap -imenu Test.existence [ -e ]hi -imenu Test.existence - file [ -f ]hi -imenu Test.existence - file (not empty) [ -s ]hi -imenu Test.existence - directory [ -d ]hi -imenu Test.existence - executable [ -x ]hi -imenu Test.existence - readable [ -r ]hi -imenu Test.existence - writable [ -w ]hi -imenu Test.String is empty [ x = "x$" ]hhi -imenu Test.String is not empty [ x != "x$" ]hhi -imenu Test.Strings is equal [ "" = "" ]hhhhhhhi -imenu Test.Strings is not equal [ "" != "" ]hhhhhhhhi -imenu Test.Values is greater than [ -gt ]hhhhhhi -imenu Test.Values is greater equal [ -ge ]hhhhhhi -imenu Test.Values is equal [ -eq ]hhhhhhi -imenu Test.Values is not equal [ -ne ]hhhhhhi -imenu Test.Values is less than [ -lt ]hhhhhhi -imenu Test.Values is less equal [ -le ]hhhhhhi -imenu ParmSub.Substitute word if parm not set ${:-}hhi -imenu ParmSub.Set parm to word if not set ${:=}hhi -imenu ParmSub.Substitute word if parm set else nothing ${:+}hhi -imenu ParmSub.If parm not set print word and exit ${:?}hhi -imenu SpShVars.Number of positional parameters ${#} -imenu SpShVars.All positional parameters (quoted spaces) ${*} -imenu SpShVars.All positional parameters (unquoted spaces) ${@} -imenu SpShVars.Flags set ${-} -imenu SpShVars.Return code of last command ${?} -imenu SpShVars.Process number of this shell ${$} -imenu SpShVars.Process number of last background command ${!} -imenu Environ.HOME ${HOME} -imenu Environ.PATH ${PATH} -imenu Environ.CDPATH ${CDPATH} -imenu Environ.MAIL ${MAIL} -imenu Environ.MAILCHECK ${MAILCHECK} -imenu Environ.PS1 ${PS1} -imenu Environ.PS2 ${PS2} -imenu Environ.IFS ${IFS} -imenu Environ.SHACCT ${SHACCT} -imenu Environ.SHELL ${SHELL} -imenu Environ.LC_CTYPE ${LC_CTYPE} -imenu Environ.LC_MESSAGES ${LC_MESSAGES} -imenu Builtins.cd cd -imenu Builtins.echo echo -imenu Builtins.eval eval -imenu Builtins.exec exec -imenu Builtins.export export -imenu Builtins.getopts getopts -imenu Builtins.hash hash -imenu Builtins.newgrp newgrp -imenu Builtins.pwd pwd -imenu Builtins.read read -imenu Builtins.readonly readonly -imenu Builtins.return return -imenu Builtins.times times -imenu Builtins.type type -imenu Builtins.umask umask -imenu Builtins.wait wait -imenu Set.set set -imenu Set.unset unset -imenu Set.mark modified or modified variables set -a -imenu Set.exit when command returns non-zero exit code set -e -imenu Set.Disable file name generation set -f -imenu Set.remember function commands set -h -imenu Set.All keyword arguments are placed in the environment set -k -imenu Set.Read commands but do not execute them set -n -imenu Set.Exit after reading and executing one command set -t -imenu Set.Treat unset variables as an error when substituting set -u -imenu Set.Print shell input lines as they are read set -v -imenu Set.Print commands and their arguments as they are executed set -x +" Load the shellmenu package. +" For those users who were loading the shellmenu plugin from here. +packadd shellmenu diff --git a/runtime/macros/swapmous.vim b/runtime/macros/swapmous.vim index 8b85be050b..5884d83473 100644 --- a/runtime/macros/swapmous.vim +++ b/runtime/macros/swapmous.vim @@ -1,22 +1,3 @@ -" These macros swap the left and right mouse buttons (for left handed) -" Don't forget to do ":set mouse=a" or the mouse won't work at all -noremap <LeftMouse> <RightMouse> -noremap <2-LeftMouse> <2-RightMouse> -noremap <3-LeftMouse> <3-RightMouse> -noremap <4-LeftMouse> <4-RightMouse> -noremap <LeftDrag> <RightDrag> -noremap <LeftRelease> <RightRelease> -noremap <RightMouse> <LeftMouse> -noremap <2-RightMouse> <2-LeftMouse> -noremap <3-RightMouse> <3-LeftMouse> -noremap <4-RightMouse> <4-LeftMouse> -noremap <RightDrag> <LeftDrag> -noremap <RightRelease> <LeftRelease> -noremap g<LeftMouse> <C-RightMouse> -noremap g<RightMouse> <C-LeftMouse> -noremap! <LeftMouse> <RightMouse> -noremap! <LeftDrag> <RightDrag> -noremap! <LeftRelease> <RightRelease> -noremap! <RightMouse> <LeftMouse> -noremap! <RightDrag> <LeftDrag> -noremap! <RightRelease> <LeftRelease> +" Load the swapmouse package. +" For those users who were loading the swapmous plugin from here. +packadd swapmouse diff --git a/runtime/pack/dist/opt/shellmenu/plugin/shellmenu.vim b/runtime/pack/dist/opt/shellmenu/plugin/shellmenu.vim new file mode 100644 index 0000000000..6175d1d9a6 --- /dev/null +++ b/runtime/pack/dist/opt/shellmenu/plugin/shellmenu.vim @@ -0,0 +1,94 @@ +" When you're writing shell scripts and you are in doubt which test to use, +" which shell environment variables are defined, what the syntax of the case +" statement is, and you need to invoke 'man sh'? +" +" Your problems are over now! +" +" Attached is a Vim script file for turning gvim into a shell script editor. +" It may also be used as an example how to use menus in Vim. +" +" Written by: Lennart Schultz <les@dmi.min.dk> + +imenu Stmts.for for in
do
doneki kk0elli +imenu Stmts.case case in
) ;;
esacbki k0elli +imenu Stmts.if if
then
fiki kk0elli +imenu Stmts.if-else if
then
else
fiki kki kk0elli +imenu Stmts.elif elif
then
ki kk0elli +imenu Stmts.while while
do
doneki kk0elli +imenu Stmts.break break +imenu Stmts.continue continue +imenu Stmts.function () {
}ki k0i +imenu Stmts.return return +imenu Stmts.return-true return 0 +imenu Stmts.return-false return 1 +imenu Stmts.exit exit +imenu Stmts.shift shift +imenu Stmts.trap trap +imenu Test.existence [ -e ]hi +imenu Test.existence - file [ -f ]hi +imenu Test.existence - file (not empty) [ -s ]hi +imenu Test.existence - directory [ -d ]hi +imenu Test.existence - executable [ -x ]hi +imenu Test.existence - readable [ -r ]hi +imenu Test.existence - writable [ -w ]hi +imenu Test.String is empty [ x = "x$" ]hhi +imenu Test.String is not empty [ x != "x$" ]hhi +imenu Test.Strings is equal [ "" = "" ]hhhhhhhi +imenu Test.Strings is not equal [ "" != "" ]hhhhhhhhi +imenu Test.Values is greater than [ -gt ]hhhhhhi +imenu Test.Values is greater equal [ -ge ]hhhhhhi +imenu Test.Values is equal [ -eq ]hhhhhhi +imenu Test.Values is not equal [ -ne ]hhhhhhi +imenu Test.Values is less than [ -lt ]hhhhhhi +imenu Test.Values is less equal [ -le ]hhhhhhi +imenu ParmSub.Substitute word if parm not set ${:-}hhi +imenu ParmSub.Set parm to word if not set ${:=}hhi +imenu ParmSub.Substitute word if parm set else nothing ${:+}hhi +imenu ParmSub.If parm not set print word and exit ${:?}hhi +imenu SpShVars.Number of positional parameters ${#} +imenu SpShVars.All positional parameters (quoted spaces) ${*} +imenu SpShVars.All positional parameters (unquoted spaces) ${@} +imenu SpShVars.Flags set ${-} +imenu SpShVars.Return code of last command ${?} +imenu SpShVars.Process number of this shell ${$} +imenu SpShVars.Process number of last background command ${!} +imenu Environ.HOME ${HOME} +imenu Environ.PATH ${PATH} +imenu Environ.CDPATH ${CDPATH} +imenu Environ.MAIL ${MAIL} +imenu Environ.MAILCHECK ${MAILCHECK} +imenu Environ.PS1 ${PS1} +imenu Environ.PS2 ${PS2} +imenu Environ.IFS ${IFS} +imenu Environ.SHACCT ${SHACCT} +imenu Environ.SHELL ${SHELL} +imenu Environ.LC_CTYPE ${LC_CTYPE} +imenu Environ.LC_MESSAGES ${LC_MESSAGES} +imenu Builtins.cd cd +imenu Builtins.echo echo +imenu Builtins.eval eval +imenu Builtins.exec exec +imenu Builtins.export export +imenu Builtins.getopts getopts +imenu Builtins.hash hash +imenu Builtins.newgrp newgrp +imenu Builtins.pwd pwd +imenu Builtins.read read +imenu Builtins.readonly readonly +imenu Builtins.return return +imenu Builtins.times times +imenu Builtins.type type +imenu Builtins.umask umask +imenu Builtins.wait wait +imenu Set.set set +imenu Set.unset unset +imenu Set.mark modified or modified variables set -a +imenu Set.exit when command returns non-zero exit code set -e +imenu Set.Disable file name generation set -f +imenu Set.remember function commands set -h +imenu Set.All keyword arguments are placed in the environment set -k +imenu Set.Read commands but do not execute them set -n +imenu Set.Exit after reading and executing one command set -t +imenu Set.Treat unset variables as an error when substituting set -u +imenu Set.Print shell input lines as they are read set -v +imenu Set.Print commands and their arguments as they are executed set -x diff --git a/runtime/pack/dist/opt/swapmouse/plugin/swapmouse.vim b/runtime/pack/dist/opt/swapmouse/plugin/swapmouse.vim new file mode 100644 index 0000000000..8b85be050b --- /dev/null +++ b/runtime/pack/dist/opt/swapmouse/plugin/swapmouse.vim @@ -0,0 +1,22 @@ +" These macros swap the left and right mouse buttons (for left handed) +" Don't forget to do ":set mouse=a" or the mouse won't work at all +noremap <LeftMouse> <RightMouse> +noremap <2-LeftMouse> <2-RightMouse> +noremap <3-LeftMouse> <3-RightMouse> +noremap <4-LeftMouse> <4-RightMouse> +noremap <LeftDrag> <RightDrag> +noremap <LeftRelease> <RightRelease> +noremap <RightMouse> <LeftMouse> +noremap <2-RightMouse> <2-LeftMouse> +noremap <3-RightMouse> <3-LeftMouse> +noremap <4-RightMouse> <4-LeftMouse> +noremap <RightDrag> <LeftDrag> +noremap <RightRelease> <LeftRelease> +noremap g<LeftMouse> <C-RightMouse> +noremap g<RightMouse> <C-LeftMouse> +noremap! <LeftMouse> <RightMouse> +noremap! <LeftDrag> <RightDrag> +noremap! <LeftRelease> <RightRelease> +noremap! <RightMouse> <LeftMouse> +noremap! <RightDrag> <LeftDrag> +noremap! <RightRelease> <LeftRelease> diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 03ef41f849..98ec9ae280 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -2385,6 +2385,7 @@ void set_completion(colnr_T startcol, list_T *list) } else { ins_complete(Ctrl_N, false); } + compl_enter_selects = compl_no_insert; // Lazily show the popup menu, unless we got interrupted. if (!compl_interrupted) { @@ -3989,6 +3990,7 @@ static void ins_compl_insert(void) dict_add_nr_str(dict, "info", 0L, EMPTY_IF_NULL(compl_shown_match->cp_text[CPT_INFO])); set_vim_var_dict(VV_COMPLETED_ITEM, dict); + compl_curr_match = compl_shown_match; } /* diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 7deb1c1bbb..a5333d74be 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -6791,6 +6791,7 @@ static struct fst { { "getcmdpos", 0, 0, f_getcmdpos }, { "getcmdtype", 0, 0, f_getcmdtype }, { "getcmdwintype", 0, 0, f_getcmdwintype }, + { "getcompletion", 2, 2, f_getcompletion }, { "getcurpos", 0, 0, f_getcurpos }, { "getcwd", 0, 2, f_getcwd }, { "getfontname", 0, 1, f_getfontname }, @@ -9983,6 +9984,50 @@ static void f_getcmdwintype(typval_T *argvars, typval_T *rettv) rettv->vval.v_string[0] = cmdwin_type; } +// "getcompletion()" function +static void f_getcompletion(typval_T *argvars, typval_T *rettv) +{ + char_u *pat; + expand_T xpc; + int options = WILD_KEEP_ALL | WILD_SILENT | WILD_USE_NL + | WILD_LIST_NOTFOUND | WILD_NO_BEEP; + + if (p_wic) { + options |= WILD_ICASE; + } + + ExpandInit(&xpc); + xpc.xp_pattern = get_tv_string(&argvars[0]); + xpc.xp_pattern_len = STRLEN(xpc.xp_pattern); + xpc.xp_context = cmdcomplete_str_to_type(get_tv_string(&argvars[1])); + if (xpc.xp_context == EXPAND_NOTHING) { + if (argvars[1].v_type == VAR_STRING) { + EMSG2(_(e_invarg2), argvars[1].vval.v_string); + } else { + EMSG(_(e_invarg)); + } + return; + } + + if (xpc.xp_context == EXPAND_MENUS) { + set_context_in_menu_cmd(&xpc, (char_u *)"menu", xpc.xp_pattern, false); + xpc.xp_pattern_len = STRLEN(xpc.xp_pattern); + } + + pat = addstar(xpc.xp_pattern, xpc.xp_pattern_len, xpc.xp_context); + if ((rettv_list_alloc(rettv) != FAIL) && (pat != NULL)) { + int i; + + ExpandOne(&xpc, pat, NULL, options, WILD_ALL_KEEP); + + for (i = 0; i < xpc.xp_numfiles; i++) { + list_append_string(rettv->vval.v_list, xpc.xp_files[i], -1); + } + } + xfree(pat); + ExpandCleanup(&xpc); +} + /// `getcwd([{win}[, {tab}]])` function /// /// Every scope not specified implies the currently selected scope object. diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 9bc7ec39da..8bae817211 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -5597,6 +5597,17 @@ int parse_compl_arg(char_u *value, int vallen, int *complp, return OK; } +int cmdcomplete_str_to_type(char_u *complete_str) +{ + for (int i = 0; command_complete[i].expand != 0; i++) { + if (STRCMP(complete_str, command_complete[i].name) == 0) { + return command_complete[i].expand; + } + } + + return EXPAND_NOTHING; +} + static void ex_colorscheme(exarg_T *eap) { if (*eap->arg == NUL) { diff --git a/src/nvim/memline.c b/src/nvim/memline.c index 673205f08f..08e82071d7 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -3165,9 +3165,10 @@ attention_message ( } /* Some of these messages are long to allow translation to * other languages. */ - MSG_PUTS(_( - "\n(1) Another program may be editing the same file. If this is the case,\n be careful not to end up with two different instances of the same\n file when making changes.")); - MSG_PUTS(_(" Quit, or continue with caution.\n")); + MSG_PUTS(_("\n(1) Another program may be editing the same file. If this is" + " the case,\n be careful not to end up with two different" + " instances of the same\n file when making changes." + " Quit, or continue with caution.\n")); MSG_PUTS(_("(2) An edit session for this file crashed.\n")); MSG_PUTS(_(" If this is the case, use \":recover\" or \"vim -r ")); msg_outtrans(buf->b_fname); diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index 886a48e7c5..f8fd7d4ef8 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -1389,6 +1389,10 @@ int vim_regcomp_had_eol(void) return had_eol; } +// variables for parsing reginput +static int at_start; // True when on the first character +static int prev_at_start; // True when on the second character + /* * Parse regular expression, i.e. main body or parenthesized thing. * @@ -1768,6 +1772,7 @@ static char_u *regatom(int *flagp) int c; char_u *p; int extra = 0; + int save_prev_at_start = prev_at_start; *flagp = WORST; /* Tentatively. */ @@ -2143,17 +2148,21 @@ static char_u *regatom(int *flagp) } break; } else if (c == 'l' || c == 'c' || c == 'v') { - if (c == 'l') + if (c == 'l') { ret = regnode(RE_LNUM); - else if (c == 'c') + if (save_prev_at_start) { + at_start = true; + } + } else if (c == 'c') { ret = regnode(RE_COL); - else + } else { ret = regnode(RE_VCOL); - if (ret == JUST_CALC_SIZE) + } + if (ret == JUST_CALC_SIZE) { regsize += 5; - else { - /* put the number and the optional - * comparator after the opcode */ + } else { + // put the number and the optional + // comparator after the opcode regcode = re_put_uint32(regcode, n); *regcode++ = cmp; } @@ -2679,9 +2688,6 @@ static void regoptail(char_u *p, char_u *val) * Functions for getting characters from the regexp input. */ -static int at_start; /* True when on the first character */ -static int prev_at_start; /* True when on the second character */ - /* * Start parsing at "str". */ diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c index f97dce9e0d..92dbd693ea 100644 --- a/src/nvim/regexp_nfa.c +++ b/src/nvim/regexp_nfa.c @@ -1096,6 +1096,7 @@ static int nfa_regatom(void) int startc = -1; int endc = -1; int oldstartc = -1; + int save_prev_at_start = prev_at_start; c = getchr(); switch (c) { @@ -1412,18 +1413,22 @@ static int nfa_regatom(void) c = getchr(); } if (c == 'l' || c == 'c' || c == 'v') { - if (c == 'l') - /* \%{n}l \%{n}<l \%{n}>l */ + if (c == 'l') { + // \%{n}l \%{n}<l \%{n}>l EMIT(cmp == '<' ? NFA_LNUM_LT : - cmp == '>' ? NFA_LNUM_GT : NFA_LNUM); - else if (c == 'c') - /* \%{n}c \%{n}<c \%{n}>c */ + cmp == '>' ? NFA_LNUM_GT : NFA_LNUM); + if (save_prev_at_start) { + at_start = true; + } + } else if (c == 'c') { + // \%{n}c \%{n}<c \%{n}>c EMIT(cmp == '<' ? NFA_COL_LT : - cmp == '>' ? NFA_COL_GT : NFA_COL); - else - /* \%{n}v \%{n}<v \%{n}>v */ + cmp == '>' ? NFA_COL_GT : NFA_COL); + } else { + // \%{n}v \%{n}<v \%{n}>v EMIT(cmp == '<' ? NFA_VCOL_LT : - cmp == '>' ? NFA_VCOL_GT : NFA_VCOL); + cmp == '>' ? NFA_VCOL_GT : NFA_VCOL); + } EMIT(n); break; } else if (c == '\'' && n == 0) { diff --git a/src/nvim/testdir/test_alot.vim b/src/nvim/testdir/test_alot.vim index ad9b2cce8b..30b8a9ceb8 100644 --- a/src/nvim/testdir/test_alot.vim +++ b/src/nvim/testdir/test_alot.vim @@ -3,5 +3,7 @@ source test_assign.vim source test_cursor_func.vim +source test_cmdline.vim source test_menu.vim +source test_popup.vim source test_unlet.vim diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim new file mode 100644 index 0000000000..438b20cc5e --- /dev/null +++ b/src/nvim/testdir/test_cmdline.vim @@ -0,0 +1,120 @@ +" Tests for editing the command line. + +func Test_complete_tab() + call writefile(['testfile'], 'Xtestfile') + call feedkeys(":e Xtest\t\r", "tx") + call assert_equal('testfile', getline(1)) + call delete('Xtestfile') +endfunc + +func Test_complete_list() + " We can't see the output, but at least we check the code runs properly. + call feedkeys(":e test\<C-D>\r", "tx") + call assert_equal('test', expand('%:t')) +endfunc + +func Test_complete_wildmenu() + call writefile(['testfile1'], 'Xtestfile1') + call writefile(['testfile2'], 'Xtestfile2') + set wildmenu + call feedkeys(":e Xtest\t\t\r", "tx") + call assert_equal('testfile2', getline(1)) + + call delete('Xtestfile1') + call delete('Xtestfile2') + set nowildmenu +endfunc + +func Test_getcompletion() + if !has('cmdline_compl') + return + endif + let groupcount = len(getcompletion('', 'event')) + call assert_true(groupcount > 0) + let matchcount = len(getcompletion('File', 'event')) + call assert_true(matchcount > 0) + call assert_true(groupcount > matchcount) + + if has('menu') + source $VIMRUNTIME/menu.vim + let matchcount = len(getcompletion('', 'menu')) + call assert_true(matchcount > 0) + call assert_equal(['File.'], getcompletion('File', 'menu')) + call assert_true(matchcount > 0) + let matchcount = len(getcompletion('File.', 'menu')) + call assert_true(matchcount > 0) + endif + + let l = getcompletion('v:n', 'var') + call assert_true(index(l, 'v:null') >= 0) + + let l = getcompletion('', 'augroup') + call assert_true(index(l, 'END') >= 0) + + let l = getcompletion('', 'behave') + call assert_true(index(l, 'mswin') >= 0) + + let l = getcompletion('', 'color') + call assert_true(index(l, 'default') >= 0) + + let l = getcompletion('', 'command') + call assert_true(index(l, 'sleep') >= 0) + + let l = getcompletion('', 'dir') + call assert_true(index(l, 'sautest') >= 0) + + let l = getcompletion('exe', 'expression') + call assert_true(index(l, 'executable(') >= 0) + + let l = getcompletion('tag', 'function') + call assert_true(index(l, 'taglist(') >= 0) + + let l = getcompletion('run', 'file') + call assert_true(index(l, 'runtest.vim') >= 0) + + let l = getcompletion('ha', 'filetype') + call assert_true(index(l, 'hamster') >= 0) + + let l = getcompletion('z', 'syntax') + call assert_true(index(l, 'zimbu') >= 0) + + let l = getcompletion('jikes', 'compiler') + call assert_true(index(l, 'jikes') >= 0) + + let l = getcompletion('time', 'option') + call assert_true(index(l, 'timeoutlen') >= 0) + + let l = getcompletion('er', 'highlight') + call assert_true(index(l, 'ErrorMsg') >= 0) + + " For others test if the name is recognized. + let names = ['buffer', 'environment', 'file_in_path', + \ 'mapping', 'shellcmd', 'tag', 'tag_listfiles', 'user'] + if has('cscope') + call add(names, 'cscope') + endif + if has('cmdline_hist') + call add(names, 'history') + endif + if has('gettext') + call add(names, 'locale') + endif + if has('profile') + call add(names, 'syntime') + endif + if has('signs') + call add(names, 'sign') + endif + + set tags=Xtags + call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", "word\tfile\tcmd"], 'Xtags') + + for name in names + let matchcount = len(getcompletion('', name)) + call assert_true(matchcount >= 0, 'No matches for ' . name) + endfor + + call delete('Xtags') + + call assert_fails('call getcompletion("", "burp")', 'E475:') +endfunc diff --git a/src/nvim/testdir/test_popup.vim b/src/nvim/testdir/test_popup.vim new file mode 100644 index 0000000000..78fc81e3d2 --- /dev/null +++ b/src/nvim/testdir/test_popup.vim @@ -0,0 +1,30 @@ +" Test for completion menu + +function! ComplTest() abort + call complete(1, ['source', 'soundfold']) + return '' +endfunction + +function! Test() abort + call complete(1, ['source', 'soundfold']) + return '' +endfunction + +func Test_noinsert_complete() + new + set completeopt+=noinsert + inoremap <F5> <C-R>=ComplTest()<CR> + call feedkeys("i\<F5>soun\<CR>\<CR>\<ESC>.", 'tx') + call assert_equal('soundfold', getline(1)) + call assert_equal('soundfold', getline(2)) + bwipe! + + new + inoremap <F5> <C-R>=Test()<CR> + call feedkeys("i\<F5>\<CR>\<ESC>", 'tx') + call assert_equal('source', getline(1)) + bwipe! + + set completeopt-=noinsert + iunmap <F5> +endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index 4a17660cd5..d6b051a511 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -75,32 +75,608 @@ static char *features[] = { // clang-format off static int included_patches[] = { + // 2200, + // 2199, + // 2198, + // 2197, + // 2196, + // 2195, + // 2194, + // 2193, + // 2192, + // 2191, + // 2190, + // 2189, + // 2188, + // 2187, + // 2186, + // 2185, + // 2184, + // 2183, + // 2182, + // 2181, + // 2180, + // 2179, + // 2178, + // 2177, + // 2176, + // 2175, + // 2174, + // 2173, + // 2172, + // 2171, + // 2170, + // 2169, + // 2168, + // 2167, + // 2166, + // 2165, + // 2164, + // 2163, + // 2162, + // 2161, + // 2160, + // 2159, + // 2158, + // 2157, + // 2156, + // 2155, + // 2154, + // 2153, + // 2152, + // 2151, + // 2150, + // 2149, + // 2148, + // 2147, + // 2146, + // 2145, + // 2144, + // 2143, + // 2142, + // 2141, + // 2140, + // 2139, + // 2138, + // 2137, + // 2136, + // 2135, + // 2134, + // 2133, + // 2132, + // 2131, + // 2130, + // 2129, + // 2128, + // 2127, + // 2126, + // 2125, + // 2124, + // 2123, + // 2122, + // 2121, + // 2120, + // 2119, + // 2118, + // 2117, + // 2116, + // 2115, + // 2114, + // 2113, + // 2112, + // 2111, + // 2110, + // 2109, + // 2108, + // 2107, + // 2106, + // 2105 NA + // 2104, + // 2103, + // 2102 NA + // 2101, + // 2100, + // 2099, + // 2098, + // 2097, + // 2096, + // 2095, + // 2094, + // 2093, + // 2092 NA + // 2091 NA + // 2090, + // 2089 NA + // 2088, + // 2087, + // 2086, + // 2085, + // 2084, + // 2083, + // 2082, + // 2081, + // 2080, + // 2079 NA + // 2078 NA + // 2077, + // 2076, + // 2075, + // 2074, + // 2073, + // 2072, + // 2071, + // 2070 NA + // 2069, + // 2068, + // 2067, + 2066, + // 2065, + // 2064, + // 2063 NA + // 2062, + // 2061, + // 2060 NA + // 2059 NA + // 2058, + // 2057 NA + // 2056 NA + // 2055 NA + // 2054 NA + // 2053 NA + // 2052 NA + // 2051, + // 2050, + // 2049, + // 2048 NA + // 2047, + // 2046, + // 2045 NA + // 2044, + // 2043, + // 2042 NA + // 2041 NA + // 2040 NA + // 2039 NA + // 2038 NA + // 2037 NA + // 2036, + // 2035 NA + // 2034 NA + // 2033, + // 2032 NA + // 2031, + // 2030 NA + // 2029, + // 2028, + // 2027 NA + // 2026 NA + // 2025 NA + // 2024, + // 2023, + // 2022, + // 2021, + // 2020 NA + // 2019, + // 2018, + // 2017, + // 2016 NA + // 2015, + 2014, + 2013, + 2012, + 2011, + // 2010, + // 2009, + // 2008, + // 2007, + // 2006, + // 2005, + // 2004 NA + // 2003 NA + // 2002, + // 2001 NA + // 2000, + // 1999, + // 1998 NA + // 1997, + // 1996, + // 1995 NA + // 1994, + // 1993, + // 1992, + // 1991, + // 1990, + // 1989, + // 1988 NA + // 1987 NA + // 1986, + // 1985 NA + // 1984, + // 1983 NA + // 1982 NA + // 1981, + // 1980, + // 1979, + // 1978, + // 1977, + // 1976, + // 1975, + // 1974 NA 1973, + // 1972, + // 1971, + // 1970, + // 1969 NA + // 1968, + // 1967, + // 1966, + // 1965 NA + // 1964, + // 1963 NA + // 1962, + // 1961, 1960, + // 1959 NA + // 1958 NA + // 1957 NA + // 1956, + // 1955, + // 1954, + // 1953, + // 1952, + // 1951 NA + // 1950, + // 1949, + // 1948, + // 1947 NA + // 1946 NA + // 1945, + // 1944 NA + // 1943 NA + // 1942 NA + // 1941, + // 1940, + // 1939 NA + // 1938 NA + // 1937, + // 1936, + // 1935 NA + // 1934 NA + // 1933 NA + // 1932 NA + // 1931 NA + // 1930 NA + // 1929 NA + // 1928, + // 1927 NA + // 1926 NA + // 1925 NA + // 1924 NA + // 1923, + // 1922 NA + // 1921 NA + // 1920 NA + // 1919 NA + // 1918 NA + // 1917 NA + // 1916 NA + // 1915 NA + // 1914, + // 1913, + // 1912, + // 1911, + // 1910, + // 1909, + // 1908 NA + // 1907, + // 1906 NA + // 1905, + // 1904, + // 1903, + // 1902 NA + // 1901 NA + // 1900, + // 1899 NA + // 1898, + // 1897, + // 1896, + // 1895, + // 1894 NA + // 1893, + // 1892 NA + // 1891 NA + // 1890 NA + // 1889, + // 1888, + // 1887 NA + // 1886 NA + // 1885 NA + // 1884, + // 1883 NA + // 1882, + // 1881, + // 1880 NA + // 1879 NA + // 1878 NA + // 1877 NA + // 1876, + // 1875, + // 1874 NA + // 1873 NA + // 1872 NA + // 1871, + // 1870 NA + // 1869 NA + // 1868, + // 1867, + // 1866, + // 1865 NA + // 1864 NA + // 1863 NA + // 1862, + // 1861, + // 1860 NA + // 1859 NA + // 1858 NA + // 1857 NA + // 1856 NA + // 1855 NA + // 1854 NA + // 1853 NA + // 1852 NA + // 1851, + // 1850 NA + // 1849 NA + // 1848 NA + // 1847, + // 1846 NA + // 1845 NA + // 1844, + // 1843 NA + // 1842, + // 1841, 1840, + // 1839, + // 1838, + // 1837, + // 1836, + // 1835, + // 1834, + // 1833, 1832, 1831, + // 1830 NA + // 1829 NA + // 1828 NA + // 1827 NA + // 1826 NA + // 1825 NA + // 1824 NA + // 1823, + // 1822 NA + // 1821, + // 1820, + // 1819 NA + // 1818, + // 1817 NA + // 1816, + // 1815, + // 1814 NA + // 1813, + // 1812, + // 1811, + // 1810 NA 1809, 1808, + // 1807 NA 1806, + // 1805, + // 1804, + // 1803 NA + // 1802, + // 1801 NA + // 1800 NA 1799, + // 1798 NA + // 1797 NA + // 1796 NA + // 1795 NA + // 1794, + // 1793, + // 1792 NA + // 1791 NA + // 1790 NA + // 1789 NA + // 1789 NA + // 1788 NA + // 1787 NA + // 1786 NA + // 1785, + // 1784 NA + // 1783, + // 1782, + // 1781, + // 1780, + // 1779, + // 1778 NA + // 1777 NA + // 1776 NA + // 1775 NA + // 1774 NA + // 1773 NA + // 1772 NA + // 1771 NA + // 1770, + // 1769, + // 1768, + // 1767 NA + // 1766 NA + // 1765, + // 1764 NA + // 1763, + // 1762, + // 1761, + // 1760 NA + // 1759, + // 1758, 1757, + // 1756 NA 1755, + // 1754, 1753, + // 1753, + // 1752, + // 1751, + // 1750, + // 1749 NA + // 1748, + // 1747 NA + // 1746 NA + // 1745 NA + // 1744 NA + // 1743 NA + // 1742, + // 1741, + // 1740, + // 1739, + // 1738, + // 1737 NA + // 1736 NA + // 1735, + // 1734, + // 1733 NA + 1732, + // 1731, + // 1730, + // 1729 NA 1728, + // 1727, + // 1726 NA + // 1725 NA + // 1724 NA + // 1723, + // 1722 NA + // 1721 NA + // 1720, + // 1719, + // 1718, + // 1717 NA 1716, + // 1715, + // 1714, + // 1713 NA 1712, + // 1711, + // 1710, + // 1709 NA + // 1708, + // 1707, + // 1706 NA + // 1705 NA + // 1704, 1703, + // 1702, + // 1701, + // 1700, + // 1699, + // 1698 NA + // 1697, + // 1696, 1695, + // 1694 NA + // 1693 NA + // 1692, + // 1691, + // 1690 NA + // 1689 NA + // 1688 NA + // 1687 NA + // 1686, + // 1685, + // 1684 NA + // 1683 NA 1682, + // 1681, + // 1680 NA + // 1679, + // 1678 NA + // 1677 NA + 1676, + 1675, + // 1674 NA + // 1673, + // 1672 NA + // 1671, + // 1670, + // 1669 NA + // 1668 NA + // 1667 NA + // 1666 NA + // 1665 NA + // 1664, 1663, + // 1662 NA + // 1661 NA + // 1660, + // 1659 NA + // 1658, + // 1657 NA + // 1656, + // 1655 NA 1654, + // 1653, 1652, + // 1651 NA + // 1650, 1649, + // 1648, + // 1647, + // 1646 NA + // 1645, + // 1644, 1643, + // 1642, 1641, + // 1640, + // 1639, + // 1638, + // 1637 NA + // 1636 NA + // 1635 NA + // 1634, + // 1633 NA + // 1632 NA + // 1631 NA + // 1630, + // 1629, + // 1628 NA + // 1627 NA + // 1626 NA + // 1625 NA // 1624 NA - + // 1623 NA + // 1622 NA + // 1621 NA + // 1620, + // 1619, + // 1618 NA + // 1617 NA + // 1616 NA + // 1615 NA + // 1614, + // 1613 NA + // 1612 NA + // 1611 NA + // 1610 NA + // 1609 NA + // 1608, + // 1607, + // 1606, + // 1605, + // 1604, + // 1603, + // 1602 NA + // 1601 NA // 1600 NA // 1599 NA // 1598 NA @@ -120,7 +696,6 @@ static int included_patches[] = { // 1584 NA // 1583 NA // 1582, - // 1581, // 1580, // 1579 NA @@ -246,7 +821,7 @@ static int included_patches[] = { // 1459 NA // 1458 NA // 1457 NA - // 1456, + // 1456 NA // 1455 NA // 1454 NA // 1453 NA @@ -397,7 +972,7 @@ static int included_patches[] = { // 1308 NA // 1307 NA // 1306 NA - // 1305, + 1305, 1304, // 1303 NA // 1302 NA @@ -429,7 +1004,7 @@ static int included_patches[] = { 1276, // 1275 NA // 1274 NA - // 1273, + // 1273 NA // 1272 NA 1271, // 1270 NA @@ -465,7 +1040,7 @@ static int included_patches[] = { // 1240 NA // 1239 NA // 1238 NA - // 1237, + 1237, 1236, // 1235 NA // 1234 NA @@ -628,7 +1203,7 @@ static int included_patches[] = { // 1077 NA 1076, 1075, - // 1074 NA, + // 1074 NA // 1073 NA 1072, 1071, @@ -671,7 +1246,7 @@ static int included_patches[] = { 1034, // 1033 NA 1032, - // 1031 NA, + // 1031 NA 1030, 1029, // 1028 NA @@ -692,15 +1267,15 @@ static int included_patches[] = { 1013, // 1012 NA // 1011 NA - // 1010 NA, + // 1010 NA // 1009 NA // 1008 NA 1007, 1006, - // 1005 NA, - // 1004 NA, - // 1003 NA, - // 1002 NA, + // 1005 NA + // 1004 NA + // 1003 NA + // 1002 NA 1001, 1000, // 999 NA diff --git a/test/functional/legacy/036_regexp_character_classes_spec.lua b/test/functional/legacy/036_regexp_character_classes_spec.lua index 3d5e69d1e5..9e67bb9429 100644 --- a/test/functional/legacy/036_regexp_character_classes_spec.lua +++ b/test/functional/legacy/036_regexp_character_classes_spec.lua @@ -268,4 +268,15 @@ describe('character classes in regexp', function() ABCDEFGHIXYZ ABCDEFGHIXYZ]]) end) + it([["\%1l^#.*" does not match on a line starting with "#". (vim-patch:7.4.1305)]], function() + source([[ + 1 s/\%#=0\%1l^\t...//g + 2 s/\%#=1\%2l^\t...//g + 3 s/\%#=2\%3l^\t...//g + 4 s/\%#=0\%4l^\t...//g + 5 s/\%#=1\%5l^\t...//g + 6 s/\%#=2\%6l^\t...//g]]) + diff(sixlines(string.sub(punct1, 1)..digits..punct2..upper..punct3.. + lower..punct4..ctrl2..iso_text)) + end) end) |