aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/autoload/man.vim18
-rw-r--r--runtime/doc/cmdline.txt5
-rw-r--r--runtime/doc/eval.txt341
-rw-r--r--runtime/doc/lsp.txt65
-rw-r--r--runtime/doc/lua.txt4
-rw-r--r--runtime/doc/nvim_terminal_emulator.txt2
-rw-r--r--runtime/doc/options.txt20
-rw-r--r--runtime/doc/starting.txt41
-rw-r--r--runtime/doc/syntax.txt11
-rw-r--r--runtime/doc/testing.txt36
-rw-r--r--runtime/doc/vim_diff.txt26
-rw-r--r--runtime/ftplugin/jsonc.vim27
-rw-r--r--runtime/ftplugin/man.vim14
-rw-r--r--runtime/indent/jsonc.vim189
-rw-r--r--runtime/lua/vim/F.lua9
-rw-r--r--runtime/lua/vim/highlight.lua6
-rw-r--r--runtime/lua/vim/lsp.lua4
-rw-r--r--runtime/lua/vim/lsp/codelens.lua3
-rw-r--r--runtime/lua/vim/lsp/diagnostic.lua9
-rw-r--r--runtime/lua/vim/lsp/util.lua18
-rw-r--r--runtime/lua/vim/treesitter.lua3
-rw-r--r--runtime/plugin/man.vim4
-rw-r--r--runtime/syntax/jsonc.vim44
-rw-r--r--runtime/syntax/man.vim8
-rw-r--r--runtime/tutor/en/vim-01-beginner.tutor222
-rw-r--r--runtime/tutor/en/vim-01-beginner.tutor.json70
26 files changed, 889 insertions, 310 deletions
diff --git a/runtime/autoload/man.vim b/runtime/autoload/man.vim
index 4f556e6e87..8bf95651b7 100644
--- a/runtime/autoload/man.vim
+++ b/runtime/autoload/man.vim
@@ -65,6 +65,7 @@ function! man#open_page(count, mods, ...) abort
let b:man_sect = sect
endfunction
+" Called when a man:// buffer is opened.
function! man#read_page(ref) abort
try
let [sect, name] = s:extract_sect_and_name_ref(a:ref)
@@ -121,6 +122,15 @@ function! s:system(cmd, ...) abort
return opts.stdout
endfunction
+function! s:set_options(pager) abort
+ setlocal filetype=man
+ setlocal noswapfile buftype=nofile bufhidden=hide
+ setlocal nomodified readonly nomodifiable
+ if a:pager
+ nnoremap <silent> <buffer> <nowait> q :lclose<CR>:q<CR>
+ endif
+endfunction
+
function! s:get_page(path) abort
" Disable hard-wrap by using a big $MANWIDTH (max 1000 on some systems #9065).
" Soft-wrap: ftplugin/man.vim sets wrap/breakindent/….
@@ -134,9 +144,7 @@ function! s:get_page(path) abort
endfunction
function! s:put_page(page) abort
- setlocal modifiable
- setlocal noreadonly
- setlocal noswapfile
+ setlocal modifiable noreadonly noswapfile
silent keepjumps %delete _
silent put =a:page
while getline(1) =~# '^\s*$'
@@ -148,7 +156,7 @@ function! s:put_page(page) abort
silent! keeppatterns keepjumps %s/\s\{199,}/\=repeat(' ', 10)/g
1
lua require("man").highlight_man_page()
- setlocal filetype=man
+ call s:set_options(v:false)
endfunction
function! man#show_toc() abort
@@ -397,6 +405,7 @@ function! s:format_candidate(path, psect) abort
endif
endfunction
+" Called when Nvim is invoked as $MANPAGER.
function! man#init_pager() abort
" https://github.com/neovim/neovim/issues/6828
let og_modifiable = &modifiable
@@ -420,6 +429,7 @@ function! man#init_pager() abort
execute 'silent file man://'.tolower(fnameescape(ref))
endif
+ call s:set_options(v:true)
let &l:modifiable = og_modifiable
endfunction
diff --git a/runtime/doc/cmdline.txt b/runtime/doc/cmdline.txt
index 2db694cf07..689fb1ecd2 100644
--- a/runtime/doc/cmdline.txt
+++ b/runtime/doc/cmdline.txt
@@ -1140,6 +1140,11 @@ Thus you can resize the command-line window, but not others.
The |getcmdwintype()| function returns the type of the command-line being
edited as described in |cmdwin-char|.
+Nvim defines this default CmdWinEnter autocmd in the "nvim_cmdwin" group: >
+ autocmd CmdWinEnter [:>] syntax sync minlines=1 maxlines=1
+<
+You can disable this in your config with "autocmd! nvim_cmdwin". |default-autocmds|
+
AUTOCOMMANDS
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index e02d80252f..87240831a2 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -669,12 +669,14 @@ Expression syntax summary, from least to most significant:
expr8[expr1 : expr1] substring of a String or sublist of a |List|
expr8.name entry in a |Dictionary|
expr8(expr1, ...) function call with |Funcref| variable
+ expr8->name(expr1, ...) |method| call
|expr9| number number constant
"string" string constant, backslash is special
'string' string constant, ' is doubled
[expr1, ...] |List|
{expr1: expr1, ...} |Dictionary|
+ #{key: expr1, ...} |Dictionary|
&option option value
(expr1) nested expression
variable internal variable
@@ -939,9 +941,11 @@ expr8 *expr8*
-----
This expression is either |expr9| or a sequence of the alternatives below,
in any order. E.g., these are all possible:
- expr9[expr1].name
- expr9.name[expr1]
- expr9(expr1, ...)[expr1].name
+ expr8[expr1].name
+ expr8.name[expr1]
+ expr8(expr1, ...)[expr1].name
+ expr8->(expr1, ...)[expr1]
+Evaluation is always from left to right.
expr8[expr1] item of String or |List| *expr-[]* *E111*
@@ -1043,6 +1047,36 @@ expr8(expr1, ...) |Funcref| function call
When expr8 is a |Funcref| type variable, invoke the function it refers to.
+expr8->name([args]) method call *method* *->*
+expr8->{lambda}([args])
+
+For methods that are also available as global functions this is the same as: >
+ name(expr8 [, args])
+There can also be methods specifically for the type of "expr8".
+
+This allows for chaining, passing the value that one method returns to the
+next method: >
+ mylist->filter(filterexpr)->map(mapexpr)->sort()->join()
+<
+Example of using a lambda: >
+ GetPercentage->{x -> x * 100}()->printf('%d%%')
+<
+When using -> the |expr7| operators will be applied first, thus: >
+ -1.234->string()
+Is equivalent to: >
+ (-1.234)->string()
+And NOT: >
+ -(1.234->string())
+<
+ *E274*
+"->name(" must not contain white space. There can be white space before the
+"->" and after the "(", thus you can split the lines like this: >
+ mylist
+ \ ->filter(filterexpr)
+ \ ->map(mapexpr)
+ \ ->sort()
+ \ ->join()
+<
*expr9*
number
@@ -2583,6 +2617,8 @@ abs({expr}) *abs()*
echo abs(-4)
< 4
+ Can also be used as a |method|: >
+ Compute()->abs()
acos({expr}) *acos()*
Return the arc cosine of {expr} measured in radians, as a
@@ -2595,6 +2631,8 @@ acos({expr}) *acos()*
:echo acos(-0.5)
< 2.094395
+ Can also be used as a |method|: >
+ Compute()->acos()
add({list}, {expr}) *add()*
Append the item {expr} to |List| {list}. Returns the
@@ -2605,12 +2643,16 @@ add({list}, {expr}) *add()*
item. Use |extend()| to concatenate |Lists|.
Use |insert()| to add an item at another position.
+ Can also be used as a |method|: >
+ mylist->add(val1)->add(val2)
and({expr}, {expr}) *and()*
Bitwise AND on the two arguments. The arguments are converted
to a number. A List, Dict or Float argument causes an error.
Example: >
:let flag = and(bits, 0x80)
+< Can also be used as a |method|: >
+ :let flag = bits->and(0x80)
api_info() *api_info()*
Returns Dictionary of |api-metadata|.
@@ -2629,6 +2671,9 @@ append({lnum}, {text}) *append()*
:let failed = append(line('$'), "# THE END")
:let failed = append(0, ["Chapter 1", "the beginning"])
+< Can also be used as a |method| after a List: >
+ mylist->append(lnum)
+
appendbufline({expr}, {lnum}, {text}) *appendbufline()*
Like |append()| but append the text in buffer {expr}.
@@ -2647,8 +2692,10 @@ appendbufline({expr}, {lnum}, {text}) *appendbufline()*
error message is given. Example: >
:let failed = appendbufline(13, 0, "# THE START")
<
- *argc()*
-argc([{winid}])
+ Can also be used as a |method| after a List: >
+ mylist->appendbufline(buf, lnum)
+
+argc([{winid}]) *argc()*
The result is the number of files in the argument list. See
|arglist|.
If {winid} is not supplied, the argument list of the current
@@ -2702,6 +2749,9 @@ asin({expr}) *asin()*
:echo asin(-0.5)
< -0.523599
+ Can also be used as a |method|: >
+ Compute()->asin()
+
assert_ functions are documented here: |assert-functions-details|
@@ -2716,6 +2766,8 @@ atan({expr}) *atan()*
:echo atan(-4.01)
< -1.326405
+ Can also be used as a |method|: >
+ Compute()->atan()
atan2({expr1}, {expr2}) *atan2()*
Return the arc tangent of {expr1} / {expr2}, measured in
@@ -2727,6 +2779,8 @@ atan2({expr1}, {expr2}) *atan2()*
:echo atan2(1, -1)
< 2.356194
+ Can also be used as a |method|: >
+ Compute()->atan2(1)
*browse()*
browse({save}, {title}, {initdir}, {default})
@@ -2737,8 +2791,8 @@ browse({save}, {title}, {initdir}, {default})
{title} title for the requester
{initdir} directory to start browsing in
{default} default file name
- When the "Cancel" button is hit, something went wrong, or
- browsing is not possible, an empty string is returned.
+ An empty string is returned when the "Cancel" button is hit,
+ something went wrong, or browsing is not possible.
*browsedir()*
browsedir({title}, {initdir})
@@ -2760,6 +2814,8 @@ bufadd({name}) *bufadd()*
created buffer. When {name} is an empty string then a new
buffer is always created.
The buffer will not have' 'buflisted' set.
+< Can also be used as a |method|: >
+ let bufnr = 'somename'->bufadd()
bufexists({expr}) *bufexists()*
The result is a Number, which is |TRUE| if a buffer called
@@ -2783,11 +2839,17 @@ bufexists({expr}) *bufexists()*
Use "bufexists(0)" to test for the existence of an alternate
file name.
+ Can also be used as a |method|: >
+ let exists = 'somename'->bufexists()
+
buflisted({expr}) *buflisted()*
The result is a Number, which is |TRUE| if a buffer called
{expr} exists and is listed (has the 'buflisted' option set).
The {expr} argument is used like with |bufexists()|.
+ Can also be used as a |method|: >
+ let listed = 'somename'->buflisted()
+
bufload({expr}) *bufload()*
Ensure the buffer {expr} is loaded. When the buffer name
refers to an existing file then the file is read. Otherwise
@@ -2797,15 +2859,21 @@ bufload({expr}) *bufload()*
there will be no dialog, the buffer will be loaded anyway.
The {expr} argument is used like with |bufexists()|.
+ Can also be used as a |method|: >
+ eval 'somename'->bufload()
+
bufloaded({expr}) *bufloaded()*
The result is a Number, which is |TRUE| if a buffer called
{expr} exists and is loaded (shown in a window or hidden).
The {expr} argument is used like with |bufexists()|.
+ Can also be used as a |method|: >
+ let loaded = 'somename'->bufloaded()
+
bufname([{expr}]) *bufname()*
The result is the name of a buffer, as it is displayed by the
":ls" command.
-+ If {expr} is omitted the current buffer is used.
+ If {expr} is omitted the current buffer is used.
If {expr} is a Number, that buffer number's name is given.
Number zero is the alternate buffer for the current window.
If {expr} is a String, it is used as a |file-pattern| to match
@@ -2824,6 +2892,9 @@ bufname([{expr}]) *bufname()*
If the {expr} is a String, but you want to use it as a buffer
number, force it to be a Number by adding zero to it: >
:echo bufname("3" + 0)
+< Can also be used as a |method|: >
+ echo bufnr->bufname()
+
< If the buffer doesn't exist, or doesn't have a name, an empty
string is returned. >
bufname("#") alternate buffer name
@@ -2846,6 +2917,9 @@ bufnr([{expr} [, {create}]])
number necessarily exist, because ":bwipeout" may have removed
them. Use bufexists() to test for the existence of a buffer.
+ Can also be used as a |method|: >
+ echo bufref->bufnr()
+
bufwinid({expr}) *bufwinid()*
The result is a Number, which is the |window-ID| of the first
window associated with buffer {expr}. For the use of {expr},
@@ -2856,18 +2930,22 @@ bufwinid({expr}) *bufwinid()*
<
Only deals with the current tab page.
+ Can also be used as a |method|: >
+ FindBuffer()->bufwinid()
+
bufwinnr({expr}) *bufwinnr()*
- The result is a Number, which is the number of the first
- window associated with buffer {expr}. For the use of {expr},
- see |bufname()| above. If buffer {expr} doesn't exist or
- there is no such window, -1 is returned. Example: >
+ Like |bufwinid()| but return the window number instead of the
+ |window-ID|.
+ If buffer {expr} doesn't exist or there is no such window, -1
+ is returned. Example: >
echo "A window containing buffer 1 is " . (bufwinnr(1))
< The number can be used with |CTRL-W_w| and ":wincmd w"
|:wincmd|.
- Only deals with the current tab page.
+ Can also be used as a |method|: >
+ FindBuffer()->bufwinnr()
byte2line({byte}) *byte2line()*
Return the line number that contains the character at byte
@@ -2877,6 +2955,9 @@ byte2line({byte}) *byte2line()*
one.
Also see |line2byte()|, |go| and |:goto|.
+ Can also be used as a |method|: >
+ GetOffset()->byte2line()
+
byteidx({expr}, {nr}) *byteidx()*
Return byte index of the {nr}'th character in the string
{expr}. Use zero for the first character, it then returns
@@ -2899,6 +2980,9 @@ byteidx({expr}, {nr}) *byteidx()*
If there are exactly {nr} characters the length of the string
in bytes is returned.
+ Can also be used as a |method|: >
+ GetName()->byteidx(idx)
+
byteidxcomp({expr}, {nr}) *byteidxcomp()*
Like byteidx(), except that a composing character is counted
as a separate character. Example: >
@@ -2912,6 +2996,9 @@ byteidxcomp({expr}, {nr}) *byteidxcomp()*
Only works differently from byteidx() when 'encoding' is set to
a Unicode encoding.
+ Can also be used as a |method|: >
+ GetName()->byteidxcomp(idx)
+
call({func}, {arglist} [, {dict}]) *call()* *E699*
Call function {func} with the items in |List| {arglist} as
arguments.
@@ -2921,6 +3008,9 @@ call({func}, {arglist} [, {dict}]) *call()* *E699*
{dict} is for functions with the "dict" attribute. It will be
used to set the local variable "self". |Dictionary-function|
+ Can also be used as a |method|: >
+ GetFunc()->call([arg, arg], dict)
+
ceil({expr}) *ceil()*
Return the smallest integral value greater than or equal to
{expr} as a |Float| (round up).
@@ -2933,6 +3023,9 @@ ceil({expr}) *ceil()*
echo ceil(4.0)
< 4.0
+ Can also be used as a |method|: >
+ Compute()->ceil()
+
changenr() *changenr()*
Return the number of the most recent change. This is the same
number as what is displayed with |:undolist| and can be used
@@ -2982,6 +3075,9 @@ char2nr({expr} [, {utf8}]) *char2nr()*
A combining character is a separate character.
|nr2char()| does the opposite.
+ Can also be used as a |method|: >
+ GetChar()->char2nr()
+
*charidx()*
charidx({string}, {idx} [, {countcc}])
Return the character index of the byte at {idx} in {string}.
@@ -3013,12 +3109,18 @@ cindent({lnum}) *cindent()*
When {lnum} is invalid -1 is returned.
See |C-indenting|.
+ Can also be used as a |method|: >
+ GetLnum()->cindent()
+
clearmatches([{win}]) *clearmatches()*
Clears all matches previously defined for the current window
by |matchadd()| and the |:match| commands.
If {win} is specified, use the window with this number or
window ID instead of the current window.
+ Can also be used as a |method|: >
+ GetWin()->clearmatches()
+<
*col()*
col({expr}) The result is a Number, which is the byte index of the column
position given with {expr}. The accepted positions are:
@@ -3054,6 +3156,9 @@ col({expr}) The result is a Number, which is the byte index of the column
\<C-O>:set ve=all<CR>
\<C-O>:echo col(".") . "\n" <Bar>
\let &ve = save_ve<CR>
+
+< Can also be used as a |method|: >
+ GetPos()->col()
<
complete({startcol}, {matches}) *complete()* *E785*
@@ -3085,6 +3190,10 @@ complete({startcol}, {matches}) *complete()* *E785*
< This isn't very useful, but it shows how it works. Note that
an empty string is returned to avoid a zero being inserted.
+ Can also be used as a |method|, the second argument is passed
+ in: >
+ GetMatches()->complete(col('.'))
+
complete_add({expr}) *complete_add()*
Add {expr} to the list of matches. Only to be used by the
function specified with the 'completefunc' option.
@@ -3094,6 +3203,9 @@ complete_add({expr}) *complete_add()*
See |complete-functions| for an explanation of {expr}. It is
the same as one item in the list that 'omnifunc' would return.
+ Can also be used as a |method|: >
+ GetMoreMatches()->complete_add()
+
complete_check() *complete_check()*
Check for a key typed while looking for completion matches.
This is to be used when looking for matches takes some time.
@@ -3154,6 +3266,9 @@ complete_info([{what}])
call complete_info(['mode'])
" Get only 'mode' and 'pum_visible'
call complete_info(['mode', 'pum_visible'])
+
+< Can also be used as a |method|: >
+ GetItems()->complete_info()
<
*confirm()*
confirm({msg} [, {choices} [, {default} [, {type}]]])
@@ -3207,6 +3322,9 @@ confirm({msg} [, {choices} [, {default} [, {type}]]])
don't fit, a vertical layout is used anyway. For some systems
the horizontal layout is always used.
+ Can also be used as a |method|in: >
+ BuildMessage()->confirm("&Yes\n&No")
+
*copy()*
copy({expr}) Make a copy of {expr}. For Numbers and Strings this isn't
different from using {expr} directly.
@@ -3216,6 +3334,8 @@ copy({expr}) Make a copy of {expr}. For Numbers and Strings this isn't
changing an item changes the contents of both |Lists|.
A |Dictionary| is copied in a similar way as a |List|.
Also see |deepcopy()|.
+ Can also be used as a |method|: >
+ mylist->copy()
cos({expr}) *cos()*
Return the cosine of {expr}, measured in radians, as a |Float|.
@@ -3226,6 +3346,8 @@ cos({expr}) *cos()*
:echo cos(-4.01)
< -0.646043
+ Can also be used as a |method|: >
+ Compute()->cos()
cosh({expr}) *cosh()*
Return the hyperbolic cosine of {expr} as a |Float| in the range
@@ -3237,6 +3359,8 @@ cosh({expr}) *cosh()*
:echo cosh(-0.5)
< -1.127626
+ Can also be used as a |method|: >
+ Compute()->cosh()
count({comp}, {expr} [, {ic} [, {start}]]) *count()*
Return the number of times an item with value {expr} appears
@@ -3251,6 +3375,9 @@ count({comp}, {expr} [, {ic} [, {start}]]) *count()*
occurrences of {expr} is returned. Zero is returned when
{expr} is an empty string.
+ Can also be used as a |method|: >
+ mylist->count(val)
+
*cscope_connection()*
cscope_connection([{num} , {dbpath} [, {prepend}]])
Checks for the existence of a |cscope| connection. If no
@@ -3346,6 +3473,8 @@ cursor({list})
position within a <Tab> or after the last character.
Returns 0 when the position could be set, -1 otherwise.
+ Can also be used as a |method|: >
+ GetCursorPos()->cursor()
deepcopy({expr}[, {noref}]) *deepcopy()* *E698*
Make a copy of {expr}. For Numbers and Strings this isn't
@@ -3367,6 +3496,9 @@ deepcopy({expr}[, {noref}]) *deepcopy()* *E698*
{noref} set to 1 will fail.
Also see |copy()|.
+ Can also be used as a |method|: >
+ GetObject()->deepcopy()
+
delete({fname} [, {flags}]) *delete()*
Without {flags} or with {flags} empty: Deletes the file by the
name {fname}. This also works when {fname} is a symbolic link.
@@ -3384,6 +3516,9 @@ delete({fname} [, {flags}]) *delete()*
operation was successful and -1/true when the deletion failed
or partly failed.
+ Can also be used as a |method|: >
+ GetName()->delete()
+
deletebufline({expr}, {first}[, {last}]) *deletebufline()*
Delete lines {first} to {last} (inclusive) from buffer {expr}.
If {last} is omitted then delete line {first} only.
@@ -3398,6 +3533,9 @@ deletebufline({expr}, {first}[, {last}]) *deletebufline()*
when using |line()| this refers to the current buffer. Use "$"
to refer to the last line in buffer {expr}.
+ Can also be used as a |method|: >
+ GetBuffer()->deletebufline(1)
+
dictwatcheradd({dict}, {pattern}, {callback}) *dictwatcheradd()*
Adds a watcher to a dictionary. A dictionary watcher is
identified by three components:
@@ -3464,6 +3602,9 @@ diff_filler({lnum}) *diff_filler()*
line, "'m" mark m, etc.
Returns 0 if the current window is not in diff mode.
+ Can also be used as a |method|: >
+ GetLnum()->diff_filler()
+
diff_hlID({lnum}, {col}) *diff_hlID()*
Returns the highlight ID for diff mode at line {lnum} column
{col} (byte index). When the current line does not have a
@@ -3475,11 +3616,16 @@ diff_hlID({lnum}, {col}) *diff_hlID()*
The highlight ID can be used with |synIDattr()| to obtain
syntax information about the highlighting.
+ Can also be used as a |method|: >
+ GetLnum()->diff_hlID(col)
+
empty({expr}) *empty()*
Return the Number 1 if {expr} is empty, zero otherwise.
A |List| or |Dictionary| is empty when it does not have any
items. A Number is empty when its value is zero. Special
variable is empty when it is |v:false| or |v:null|.
+ Can also be used as a |method|: >
+ mylist->empty()
environ() *environ()*
Return all of environment variables as dictionary. You can
@@ -3504,6 +3650,9 @@ eval({string}) Evaluate {string} and return the result. Especially useful to
them. Also works for |Funcref|s that refer to existing
functions.
+ Can also be used as a |method|: >
+ argv->join()->eval()
+
eventhandler() *eventhandler()*
Returns 1 when inside an event handler. That is that Vim got
interrupted while waiting for the user to type a character,
@@ -3661,12 +3810,18 @@ exp({expr}) *exp()*
:echo exp(-1)
< 0.367879
+ Can also be used as a |method|: >
+ Compute()->exp()
+
debugbreak({pid}) *debugbreak()*
Specifically used to interrupt a program being debugged. It
will cause process {pid} to get a SIGTRAP. Behavior for other
processes is undefined. See |terminal-debugger|.
{Sends a SIGINT to a process {pid} other than MS-Windows}
+ Can also be used as a |method|: >
+ GetPid()->debugbreak()
+
expand({expr} [, {nosuf} [, {list}]]) *expand()*
Expand wildcards and the following special keywords in {expr}.
'wildignorecase' applies.
@@ -3795,6 +3950,8 @@ extend({expr1}, {expr2} [, {expr3}]) *extend()*
fails.
Returns {expr1}.
+ Can also be used as a |method|: >
+ mylist->extend(otherlist)
feedkeys({string} [, {mode}]) *feedkeys()*
Characters in {string} are queued for processing as if they
@@ -3848,7 +4005,11 @@ filereadable({file}) *filereadable()*
expression, which is used as a String.
If you don't care about the file being readable you can use
|glob()|.
-
+ {file} is used as-is, you may want to expand wildcards first: >
+ echo filereadable('~/.vimrc')
+ 0
+ echo filereadable(expand('~/.vimrc'))
+ 1
filewritable({file}) *filewritable()*
The result is a Number, which is 1 when a file with the
@@ -3904,6 +4065,8 @@ filter({expr1}, {expr2}) *filter()*
Funcref errors inside a function are ignored, unless it was
defined with the "abort" flag.
+ Can also be used as a |method|: >
+ mylist->filter(expr2)
finddir({name} [, {path} [, {count}]]) *finddir()*
Find directory {name} in {path}. Supports both downwards and
@@ -3966,6 +4129,8 @@ float2nr({expr}) *float2nr()*
echo float2nr(1.0e-100)
< 0
+ Can also be used as a |method|: >
+ Compute()->float2nr()
floor({expr}) *floor()*
Return the largest integral value less than or equal to
@@ -3979,6 +4144,8 @@ floor({expr}) *floor()*
echo floor(4.0)
< 4.0
+ Can also be used as a |method|: >
+ Compute()->floor()
fmod({expr1}, {expr2}) *fmod()*
Return the remainder of {expr1} / {expr2}, even if the
@@ -3994,6 +4161,8 @@ fmod({expr1}, {expr2}) *fmod()*
:echo fmod(-12.33, 1.22)
< -0.13
+ Can also be used as a |method|: >
+ Compute()->fmod(1.22)
fnameescape({string}) *fnameescape()*
Escape {string} for use as file name command argument. All
@@ -4160,6 +4329,8 @@ get({list}, {idx} [, {default}]) *get()*
Get item {idx} from |List| {list}. When this item is not
available return {default}. Return zero when {default} is
omitted.
+ Can also be used as a |method|: >
+ mylist->get(idx)
get({dict}, {key} [, {default}])
Get item with key {key} from |Dictionary| {dict}. When this
item is not available return {default}. Return zero when
@@ -5171,6 +5342,9 @@ has_key({dict}, {key}) *has_key()*
The result is a Number, which is TRUE if |Dictionary| {dict}
has an entry with key {key}. FALSE otherwise.
+ Can also be used as a |method|: >
+ mydict->has_key(key)
+
haslocaldir([{winnr}[, {tabnr}]]) *haslocaldir()*
The result is a Number, which is 1 when the tabpage or window
has set a local path via |:tcd| or |:lcd|, otherwise 0.
@@ -5514,6 +5688,9 @@ insert({list}, {item} [, {idx}]) *insert()*
Note that when {item} is a |List| it is inserted as a single
item. Use |extend()| to concatenate |Lists|.
+ Can also be used as a |method|: >
+ mylist->insert(item)
+
interrupt() *interrupt()*
Interrupt script execution. It works more or less like the
user typing CTRL-C, most commands won't execute and control
@@ -5531,6 +5708,8 @@ invert({expr}) *invert()*
Bitwise invert. The argument is converted to a number. A
List, Dict or Float argument causes an error. Example: >
:let bits = invert(bits)
+< Can also be used as a |method|: >
+ :let bits = bits->invert()
isdirectory({directory}) *isdirectory()*
The result is a Number, which is |TRUE| when a directory
@@ -5546,6 +5725,9 @@ isinf({expr}) *isinf()*
:echo isinf(-1.0 / 0.0)
< -1
+ Can also be used as a |method|: >
+ Compute()->isinf()
+
islocked({expr}) *islocked()* *E786*
The result is a Number, which is |TRUE| when {expr} is the
name of a locked variable.
@@ -5581,12 +5763,17 @@ items({dict}) *items()*
|List| item is a list with two items: the key of a {dict}
entry and the value of this entry. The |List| is in arbitrary
order.
+ Can also be used as a |method|: >
+ mydict->items()
isnan({expr}) *isnan()*
Return |TRUE| if {expr} is a float with value NaN. >
echo isnan(0.0 / 0.0)
< 1
+ Can also be used as a |method|: >
+ Compute()->isnan()
+
jobpid({job}) *jobpid()*
Return the PID (process id) of |job-id| {job}.
@@ -5714,6 +5901,9 @@ join({list} [, {sep}]) *join()*
converted into a string like with |string()|.
The opposite function is |split()|.
+ Can also be used as a |method|: >
+ mylist->join()
+
json_decode({expr}) *json_decode()*
Convert {expr} from JSON object. Accepts |readfile()|-style
list as the input, as well as regular string. May output any
@@ -5744,8 +5934,10 @@ json_encode({expr}) *json_encode()*
keys({dict}) *keys()*
Return a |List| with all the keys of {dict}. The |List| is in
arbitrary order.
+ Can also be used as a |method|: >
+ mydict->keys()
- *len()* *E701*
+< *len()* *E701*
len({expr}) The result is a Number, which is the length of the argument.
When {expr} is a String or a Number the length in bytes is
used, as with |strlen()|.
@@ -5756,7 +5948,10 @@ len({expr}) The result is a Number, which is the length of the argument.
|Dictionary| is returned.
Otherwise an error is given.
- *libcall()* *E364* *E368*
+ Can also be used as a |method|: >
+ mylist->len()
+
+< *libcall()* *E364* *E368*
libcall({libname}, {funcname}, {argument})
Call function {funcname} in the run-time library {libname}
with single argument {argument}.
@@ -5881,6 +6076,8 @@ log({expr}) *log()*
:echo log(exp(5))
< 5.0
+ Can also be used as a |method|: >
+ Compute()->log()
log10({expr}) *log10()*
Return the logarithm of Float {expr} to base 10 as a |Float|.
@@ -5891,6 +6088,9 @@ log10({expr}) *log10()*
:echo log10(0.01)
< -2.0
+ Can also be used as a |method|: >
+ Compute()->log10()
+
luaeval({expr}[, {expr}])
Evaluate Lua expression {expr} and return its result converted
to Vim data structures. See |lua-eval| for more details.
@@ -5939,6 +6139,8 @@ map({expr1}, {expr2}) *map()*
Funcref errors inside a function are ignored, unless it was
defined with the "abort" flag.
+ Can also be used as a |method|: >
+ mylist->map(expr2)
maparg({name} [, {mode} [, {abbr} [, {dict}]]]) *maparg()*
When {dict} is omitted or zero: Return the rhs of mapping
@@ -6274,6 +6476,9 @@ max({expr}) Return the maximum value of all items in {expr}.
items in {expr} cannot be used as a Number this results in
an error. An empty |List| or |Dictionary| results in zero.
+ Can also be used as a |method|: >
+ mylist->max()
+
menu_get({path}, {modes}) *menu_get()*
Returns a |List| of |Dictionaries| describing |menus| (defined
by |:menu|, |:amenu|, …), including |hidden-menus|.
@@ -6328,7 +6533,10 @@ min({expr}) Return the minimum value of all items in {expr}.
items in {expr} cannot be used as a Number this results in
an error. An empty |List| or |Dictionary| results in zero.
- *mkdir()* *E739*
+ Can also be used as a |method|: >
+ mylist->min()
+
+< *mkdir()* *E739*
mkdir({name} [, {path} [, {prot}]])
Create directory {name}.
If {path} is "p" then intermediate directories are created as
@@ -6523,7 +6731,8 @@ or({expr}, {expr}) *or()*
to a number. A List, Dict or Float argument causes an error.
Example: >
:let bits = or(bits, 0x80)
-
+< Can also be used as a |method|: >
+ :let bits = bits->or(0x80)
pathshorten({expr}) *pathshorten()*
Shorten directory names in the path {expr} and return the
@@ -6560,6 +6769,9 @@ pow({x}, {y}) *pow()*
:echo pow(32, 0.20)
< 2.0
+ Can also be used as a |method|: >
+ Compute()->pow(3)
+
prevnonblank({lnum}) *prevnonblank()*
Return the line number of the first line at or above {lnum}
that is not blank. Example: >
@@ -6576,7 +6788,11 @@ printf({fmt}, {expr1} ...) *printf()*
< May result in:
" 99: E42 asdfasdfasdfasdfasdfasdfasdfas" ~
- Often used items are:
+ When used as a |method| the base is passed as the second
+ argument: >
+ Compute()->printf("result: %d")
+
+< Often used items are:
%s string
%6S string right-aligned in 6 display cells
%6s string right-aligned in 6 bytes
@@ -7086,6 +7302,10 @@ remove({list}, {idx} [, {end}]) *remove()*
Example: >
:echo "last item: " . remove(mylist, -1)
:call remove(mylist, 0, 9)
+
+< Can also be used as a |method|: >
+ mylist->remove(idx)
+
remove({dict}, {key})
Remove the entry from {dict} with key {key} and return it.
Example: >
@@ -7112,6 +7332,8 @@ repeat({expr}, {count}) *repeat()*
:let longlist = repeat(['a', 'b'], 3)
< Results in ['a', 'b', 'a', 'b', 'a', 'b'].
+ Can also be used as a |method|: >
+ mylist->repeat(count)
resolve({filename}) *resolve()* *E655*
On MS-Windows, when {filename} is a shortcut (a .lnk file),
@@ -7131,6 +7353,8 @@ reverse({list}) Reverse the order of items in {list} in-place. Returns
{list}.
If you want a list to remain unmodified make a copy first: >
:let revlist = reverse(copy(mylist))
+< Can also be used as a |method|: >
+ mylist->reverse()
round({expr}) *round()*
Round off {expr} to the nearest integral value and return it
@@ -7145,6 +7369,9 @@ round({expr}) *round()*
echo round(-4.5)
< -5.0
+ Can also be used as a |method|: >
+ Compute()->round()
+
rpcnotify({channel}, {event}[, {args}...]) *rpcnotify()*
Sends {event} to {channel} via |RPC| and returns immediately.
If {channel} is 0, the event is broadcast to all channels.
@@ -8121,6 +8348,8 @@ sin({expr}) *sin()*
:echo sin(-4.01)
< 0.763301
+ Can also be used as a |method|: >
+ Compute()->sin()
sinh({expr}) *sinh()*
Return the hyperbolic sine of {expr} as a |Float| in the range
@@ -8132,6 +8361,9 @@ sinh({expr}) *sinh()*
:echo sinh(-0.9)
< -1.026517
+ Can also be used as a |method|: >
+ Compute()->sinh()
+
sockconnect({mode}, {address}, {opts}) *sockconnect()*
Connect a socket to an address. If {mode} is "pipe" then
{address} should be the path of a named pipe. If {mode} is
@@ -8210,7 +8442,10 @@ sort({list} [, {func} [, {dict}]]) *sort()* *E702*
on numbers, text strings will sort next to each other, in the
same order as they were originally.
- Also see |uniq()|.
+ Can also be used as a |method|: >
+ mylist->sort()
+
+< Also see |uniq()|.
Example: >
func MyCompare(i1, i2)
@@ -8303,6 +8538,8 @@ split({expr} [, {pattern} [, {keepempty}]]) *split()*
:let items = split(line, ':', 1)
< The opposite function is |join()|.
+ Can also be used as a |method|: >
+ GetString()->split()
sqrt({expr}) *sqrt()*
Return the non-negative square root of Float {expr} as a
@@ -8316,6 +8553,8 @@ sqrt({expr}) *sqrt()*
< nan
"nan" may be different, it depends on system libraries.
+ Can also be used as a |method|: >
+ Compute()->sqrt()
stdioopen({opts}) *stdioopen()*
With |--headless| this opens stdin and stdout as a |channel|.
@@ -8367,6 +8606,9 @@ str2float({expr}) *str2float()*
12.0. You can strip out thousands separators with
|substitute()|: >
let f = str2float(substitute(text, ',', '', 'g'))
+<
+ Can also be used as a |method|: >
+ let f = text->substitute(',', '', 'g')->str2float()
str2list({expr} [, {utf8}]) *str2list()*
Return a list containing the number values which represent
@@ -8381,12 +8623,18 @@ str2list({expr} [, {utf8}]) *str2list()*
properly: >
str2list("á") returns [97, 769]
+< Can also be used as a |method|: >
+ GetString()->str2list()
+
str2nr({expr} [, {base}]) *str2nr()*
Convert string {expr} to a number.
{base} is the conversion base, it can be 2, 8, 10 or 16.
+
When {base} is omitted base 10 is used. This also means that
a leading zero doesn't cause octal conversion to be used, as
- with the default String to Number conversion.
+ with the default String to Number conversion. Example: >
+ let nr = str2nr('123')
+<
When {base} is 16 a leading "0x" or "0X" is ignored. With a
different base the result will be zero. Similarly, when {base}
is 8 a leading "0" is ignored, and when {base} is 2 a leading
@@ -8505,6 +8753,9 @@ string({expr}) Return {expr} converted to a String. If {expr} is a Number,
method, use |msgpackdump()| or |json_encode()| if you need to
share data with other application.
+ Can also be used as a |method|: >
+ mylist->string()
+
*strlen()*
strlen({expr}) The result is a Number, which is the length of the String
{expr} in bytes.
@@ -8514,6 +8765,9 @@ strlen({expr}) The result is a Number, which is the length of the String
|strchars()|.
Also see |len()|, |strdisplaywidth()| and |strwidth()|.
+ Can also be used as a |method|: >
+ GetString()->strlen()
+
strpart({src}, {start} [, {len} [, {chars}]]) *strpart()*
The result is a String, which is part of {src}, starting from
byte {start}, with the byte length {len}.
@@ -8588,6 +8842,9 @@ strtrans({expr}) *strtrans()*
< This displays a newline in register a as "^@" instead of
starting a new line.
+ Can also be used as a |method|: >
+ GetString()->strtrans()
+
strwidth({expr}) *strwidth()*
The result is a Number, which is the number of display cells
String {expr} occupies. A Tab character is counted as one
@@ -8596,6 +8853,9 @@ strwidth({expr}) *strwidth()*
Ambiguous, this function's return value depends on 'ambiwidth'.
Also see |strlen()|, |strdisplaywidth()| and |strchars()|.
+ Can also be used as a |method|: >
+ GetString()->strwidth()
+
submatch({nr} [, {list}]) *submatch()* *E935*
Only for an expression in a |:substitute| command or
substitute() function.
@@ -8663,6 +8923,9 @@ substitute({expr}, {pat}, {sub}, {flags}) *substitute()*
|submatch()| returns. Example: >
:echo substitute(s, '%\(\x\x\)', {m -> '0x' . m[1]}, 'g')
+< Can also be used as a |method|: >
+ GetString()->substitute(pat, sub, flags)
+
swapinfo({fname}) *swapinfo()*
The result is a dictionary, which holds information about the
swapfile {fname}. The available fields are:
@@ -8747,12 +9010,18 @@ synIDattr({synID}, {what} [, {mode}]) *synIDattr()*
cursor): >
:echo synIDattr(synIDtrans(synID(line("."), col("."), 1)), "fg")
<
+ Can also be used as a |method|: >
+ :echo synID(line("."), col("."), 1)->synIDtrans()->synIDattr("fg")
+
synIDtrans({synID}) *synIDtrans()*
The result is a Number, which is the translated syntax ID of
{synID}. This is the syntax group ID of what is being used to
highlight the character. Highlight links given with
":highlight link" are followed.
+ Can also be used as a |method|: >
+ :echo synID(line("."), col("."), 1)->synIDtrans()->synIDattr("fg")
+
synconcealed({lnum}, {col}) *synconcealed()*
The result is a |List| with currently three items:
1. The first item in the list is 0 if the character at the
@@ -8849,6 +9118,8 @@ system({cmd} [, {input}]) *system()* *E677*
Unlike ":!cmd" there is no automatic check for changed files.
Use |:checktime| to force a check.
+ Can also be used as a |method|: >
+ :echo GetCmd()->system()
systemlist({cmd} [, {input} [, {keepempty}]]) *systemlist()*
Same as |system()|, but returns a |List| with lines (parts of
@@ -8864,6 +9135,8 @@ systemlist({cmd} [, {input} [, {keepempty}]]) *systemlist()*
<
Returns an empty string on error.
+ Can also be used as a |method|: >
+ :echo GetCmd()->systemlist()
tabpagebuflist([{arg}]) *tabpagebuflist()*
The result is a |List|, where each item is the number of the
@@ -8987,6 +9260,8 @@ tan({expr}) *tan()*
:echo tan(-4.01)
< -1.181502
+ Can also be used as a |method|: >
+ Compute()->tan()
tanh({expr}) *tanh()*
Return the hyperbolic tangent of {expr} as a |Float| in the
@@ -8998,6 +9273,8 @@ tanh({expr}) *tanh()*
:echo tanh(-1)
< -0.761594
+ Can also be used as a |method|: >
+ Compute()->tanh()
*timer_info()*
timer_info([{id}])
@@ -9124,6 +9401,9 @@ trunc({expr}) *trunc()*
echo trunc(4.0)
< 4.0
+ Can also be used as a |method|: >
+ Compute()->trunc()
+
type({expr}) *type()*
The result is a Number representing the type of {expr}.
Instead of using the number directly, it is better to use the
@@ -9150,6 +9430,9 @@ type({expr}) *type()*
< To check if the v:t_ variables exist use this: >
:if exists('v:t_number')
+< Can also be used as a |method|: >
+ mylist->type()
+
undofile({name}) *undofile()*
Return the name of the undo file that would be used for a file
with name {name} when writing. This uses the 'undodir'
@@ -9212,10 +9495,15 @@ uniq({list} [, {func} [, {dict}]]) *uniq()* *E882*
< The default compare function uses the string representation of
each item. For the use of {func} and {dict} see |sort()|.
+ Can also be used as a |method|: >
+ mylist->uniq()
+
values({dict}) *values()*
Return a |List| with all the values of {dict}. The |List| is
in arbitrary order.
+ Can also be used as a |method|: >
+ mydict->values()
virtcol({expr}) *virtcol()*
The result is a Number, which is the screen column of the file
@@ -9393,6 +9681,9 @@ winbufnr({nr}) The result is a Number, which is the number of the buffer
Example: >
:echo "The file in the current window is " . bufname(winbufnr(0))
<
+ Can also be used as a |method|: >
+ FindWindow()->winbufnr()->bufname()
+<
*wincol()*
wincol() The result is a Number, which is the virtual column of the
cursor in the window. This is counting screen cells from the
@@ -9606,6 +9897,8 @@ xor({expr}, {expr}) *xor()*
to a number. A List, Dict or Float argument causes an error.
Example: >
:let bits = xor(bits, 0x80)
+< Can also be used as a |method|: >
+ :let bits = bits->xor(0x80)
<
@@ -9943,7 +10236,9 @@ This function can then be called with: >
The recursiveness of user functions is restricted with the |'maxfuncdepth'|
option.
-It is also possible to use `:eval`. It does not support a range.
+It is also possible to use `:eval`. It does not support a range, but does
+allow for method chaining, e.g.: >
+ eval GetList()->Filter()->append('$')
AUTOMATICALLY LOADING FUNCTIONS ~
@@ -10686,7 +10981,7 @@ text...
<
*:eval*
:eval {expr} Evaluate {expr} and discard the result. Example: >
- :eval append(Filter(Getlist()), '$')
+ :eval Getlist()->Filter()->append('$')
< The expression is supposed to have a side effect,
since the resulting value is not used. In the example
diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt
index 688e906063..e76e224596 100644
--- a/runtime/doc/lsp.txt
+++ b/runtime/doc/lsp.txt
@@ -1207,34 +1207,6 @@ workspace_symbol({query}) *vim.lsp.buf.workspace_symbol()*
==============================================================================
Lua module: vim.lsp.diagnostic *lsp-diagnostic*
- *vim.lsp.diagnostic.apply_to_diagnostic_items()*
-apply_to_diagnostic_items({item_handler}, {command}, {opts})
- Gets diagnostics, converts them to quickfix/location list
- items, and applies the item_handler callback to the items.
-
- Parameters: ~
- {item_handler} function Callback to apply to the
- diagnostic items
- {command} string|nil Command to execute after
- applying the item_handler
- {opts} table|nil Configuration table. Keys:
- • {client_id}: (number)
- • If nil, will consider all clients
- attached to buffer.
-
- • {severity}: (DiagnosticSeverity)
- • Exclusive severity to consider.
- Overrides {severity_limit}
-
- • {severity_limit}: (DiagnosticSeverity)
- • Limit severity of diagnostics found.
- E.g. "Warning" means { "Error",
- "Warning" } will be valid.
-
- • {workspace}: (boolean, default false)
- • Set the list with workspace
- diagnostics
-
*vim.lsp.diagnostic.clear()*
clear({bufnr}, {client_id}, {diagnostic_ns}, {sign_ns})
Clears the currently displayed diagnostics
@@ -1657,31 +1629,6 @@ set_virtual_text({diagnostics}, {bufnr}, {client_id}, {diagnostic_ns}, {opts})
E.g. "Warning" means { "Error",
"Warning" } will be valid.
- *vim.lsp.diagnostic.show_diagnostics()*
-show_diagnostics({opts}, {diagnostics})
- Open a floating window with the provided diagnostics
-
- The floating window can be customized with the following
- highlight groups: >
-
- LspDiagnosticsFloatingError
- LspDiagnosticsFloatingWarning
- LspDiagnosticsFloatingInformation
- LspDiagnosticsFloatingHint
-<
-
- Parameters: ~
- {opts} table Configuration table
- • show_header (boolean, default true): Show
- "Diagnostics:" header
- • all opts for
- |vim.lsp.util.open_floating_preview()|
- can be used here
- {diagnostics} table: The diagnostics to display
-
- Return: ~
- table {popup_bufnr, win_id}
-
*vim.lsp.diagnostic.show_line_diagnostics()*
show_line_diagnostics({opts}, {buf_nr}, {line_nr}, {client_id})
Parameters: ~
@@ -1698,6 +1645,8 @@ show_line_diagnostics({opts}, {buf_nr}, {line_nr}, {client_id})
*vim.lsp.diagnostic.show_position_diagnostics()*
show_position_diagnostics({opts}, {buf_nr}, {position})
+ Open a floating window with the diagnostics from {position}
+
Parameters: ~
{opts} table|nil Configuration keys
• severity: (DiagnosticSeverity, default nil)
@@ -1733,6 +1682,10 @@ display({lenses}, {bufnr}, {client_id}) *vim.lsp.codelens.display()*
get({bufnr}) *vim.lsp.codelens.get()*
Return all lenses for the given buffer
+ Parameters: ~
+ {bufnr} number Buffer number. 0 can be used for the
+ current buffer.
+
Return: ~
table ( `CodeLens[]` )
@@ -1838,12 +1791,6 @@ apply_workspace_edit({workspace_edit})
Parameters: ~
{workspace_edit} (table) `WorkspaceEdit`
-border_height({id}) *vim.lsp.util.border_height()*
- TODO: Documentation
-
-border_width({id}) *vim.lsp.util.border_width()*
- TODO: Documentation
-
buf_clear_references({bufnr}) *vim.lsp.util.buf_clear_references()*
Removes document highlights from a buffer.
diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt
index d4c6e55d0e..a44b2e42f5 100644
--- a/runtime/doc/lua.txt
+++ b/runtime/doc/lua.txt
@@ -391,6 +391,10 @@ where the args are converted to Lua values. The expression >
is equivalent to the Lua chunk >
return somemod.func(...)
+The `v:lua` prefix may be used to call Lua functions as |method|s. For
+example: >
+ arg1->v:lua.somemod.func(arg2)
+
You can use `v:lua` in "func" options like 'tagfunc', 'omnifunc', etc.
For example consider the following Lua omnifunc handler: >
diff --git a/runtime/doc/nvim_terminal_emulator.txt b/runtime/doc/nvim_terminal_emulator.txt
index e0589ba7b8..0bf58f85fc 100644
--- a/runtime/doc/nvim_terminal_emulator.txt
+++ b/runtime/doc/nvim_terminal_emulator.txt
@@ -13,7 +13,7 @@ from the connected program.
Terminal buffers behave like normal buffers, except:
- With 'modifiable', lines can be edited but not deleted.
- 'scrollback' controls how many lines are kept.
-- Output is followed if the cursor is on the last line.
+- Output is followed ("tailed") if cursor is on the last line.
- 'modified' is the default. You can set 'nomodified' to avoid a warning when
closing the terminal buffer.
- 'bufhidden' defaults to "hide".
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index 364d4c5167..475ccb66b3 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -824,12 +824,12 @@ 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 ".,$XDG_DATA_HOME/nvim/backup")
+'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
- where this is possible. The directory must exist, Vim will not
- create it for you.
+ where this is possible. If none of the directories exist Nvim will
+ attempt to create the last directory in the list.
- Empty means that no backup file will be created ('patchmode' is
impossible!). Writing may fail because of this.
- A directory "." means to put the backup file in the same directory
@@ -6533,17 +6533,17 @@ A jump table for the options with a short description can be found at |Q_op|.
'ttyfast' 'tf' Removed. |vim-differences|
*'undodir'* *'udir'* *E5003*
-'undodir' 'udir' string (default "$XDG_DATA_HOME/nvim/undo")
+'undodir' 'udir' string (default "$XDG_DATA_HOME/nvim/undo//")
global
List of directory names for undo files, separated with commas.
- See |'backupdir'| for details of the format.
+ See 'backupdir' for details of the format.
"." means using the directory of the file. The undo file name for
"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. If none of
- the directories exist Neovim will attempt to create last directory in
+ works, no directories after "." will be used for writing. If none of
+ the directories exist Nvim will attempt to create the 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
@@ -6552,6 +6552,10 @@ A jump table for the options with a short description can be found at |Q_op|.
This option cannot be set from a |modeline| or in the |sandbox|, for
security reasons.
+ Note that unlike 'directory' and 'backupdir', 'undodir' always acts as
+ though the trailing slashes are present (see 'backupdir' for what this
+ means).
+
*'undofile'* *'noundofile'* *'udf'* *'noudf'*
'undofile' 'udf' boolean (default off)
local to buffer
@@ -6692,7 +6696,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: "$XDG_DATA_HOME/nvim/view")
+'viewdir' 'vdir' string (default: "$XDG_DATA_HOME/nvim/view//")
global
Name of the directory where to store files for |:mkview|.
This option cannot be set from a |modeline| or in the |sandbox|, for
diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt
index 80b8dd52ea..d6b54fbd01 100644
--- a/runtime/doc/starting.txt
+++ b/runtime/doc/starting.txt
@@ -388,8 +388,8 @@ argument.
==============================================================================
Initialization *initialization* *startup*
-At startup, Vim checks environment variables and files and sets values
-accordingly. Vim proceeds in this order:
+At startup, Nvim checks environment variables and files and sets values
+accordingly, proceeding as follows:
1. Set the 'shell' option *SHELL* *COMSPEC*
The environment variable SHELL, if it exists, is used to set the
@@ -406,7 +406,9 @@ accordingly. Vim proceeds in this order:
Nvim started with |--embed| waits for the UI to connect before
proceeding to load user configuration.
-4. Load user config (execute Ex commands from files, environment, …).
+4. Setup |default-mappings| and |default-autocmds|.
+
+5. Load user config (execute Ex commands from files, environment, …).
$VIMINIT environment variable is read as one Ex command line (separate
multiple commands with '|' or <NL>).
*config* *init.vim* *init.lua* *vimrc* *exrc*
@@ -450,7 +452,7 @@ accordingly. Vim proceeds in this order:
- The file ".nvimrc"
- The file ".exrc"
-5. Enable filetype and indent plugins.
+6. Enable filetype and indent plugins.
This does the same as the commands: >
:runtime! filetype.vim
:runtime! ftplugin.vim
@@ -458,13 +460,13 @@ accordingly. Vim proceeds in this order:
< Skipped if ":filetype … off" was called or if the "-u NONE" command
line argument was given.
-6. Enable syntax highlighting.
+7. Enable syntax highlighting.
This does the same as the command: >
:runtime! syntax/syntax.vim
< Skipped if ":syntax off" was called or if the "-u NONE" command
line argument was given.
-7. Load the plugin scripts. *load-plugins*
+8. Load the plugin scripts. *load-plugins*
This does the same as the command: >
:runtime! plugin/**/*.vim
:runtime! plugin/**/*.lua
@@ -494,38 +496,33 @@ accordingly. Vim proceeds in this order:
if packages have been found, but that should not add a directory
ending in "after".
-8. Set 'shellpipe' and 'shellredir'
+9. Set 'shellpipe' and 'shellredir'
The 'shellpipe' and 'shellredir' options are set according to the
value of the 'shell' option, unless they have been set before.
- This means that Vim will figure out the values of 'shellpipe' and
+ This means that Nvim will figure out the values of 'shellpipe' and
'shellredir' for you, unless you have set them yourself.
-9. Set 'updatecount' to zero, if "-n" command argument used
+10. Set 'updatecount' to zero, if "-n" command argument used
-10. Set binary options
- If the "-b" flag was given to Vim, the options for binary editing will
- be set now. See |-b|.
+11. Set binary options if the |-b| flag was given.
-11. Read the ShaDa file
- See |shada-file|.
+12. Read the |shada-file|.
-12. Read the quickfix file
- If the "-q" flag was given to Vim, the quickfix file is read. If this
- fails, Vim exits.
+13. Read the quickfix file if the |-q| flag was given, or exit on failure.
-13. Open all windows
+14. Open all windows
When the |-o| flag was given, windows will be opened (but not
displayed yet).
When the |-p| flag was given, tab pages will be created (but not
displayed yet).
When switching screens, it happens now. Redrawing starts.
- If the "-q" flag was given to Vim, the first error is jumped to.
+ If the |-q| flag was given, the first error is jumped to.
Buffers for all windows will be loaded, without triggering |BufAdd|
autocommands.
-14. Execute startup commands
- If a "-t" flag was given to Vim, the tag is jumped to.
- The commands given with the |-c| and |+cmd| arguments are executed.
+15. Execute startup commands
+ If a |-t| flag was given, the tag is jumped to.
+ Commands given with |-c| and |+cmd| are executed.
If the 'insertmode' option is set, Insert mode is entered.
The starting flag is reset, has("vim_starting") will now return zero.
The |v:vim_did_enter| variable is set to 1.
diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt
index 0cd3aed7a2..161b4f0d04 100644
--- a/runtime/doc/syntax.txt
+++ b/runtime/doc/syntax.txt
@@ -5064,10 +5064,15 @@ Substitute |:substitute| replacement text highlighting
*hl-LineNr*
LineNr Line number for ":number" and ":#" commands, and when 'number'
or 'relativenumber' option is set.
+ *hl-LineNrAbove*
+LineNrAbove Line number for when the 'relativenumber'
+ option is set, above the cursor line.
+ *hl-LineNrBelow*
+LineNrBelow Line number for when the 'relativenumber'
+ option is set, below the cursor line.
*hl-CursorLineNr*
-CursorLineNr Like LineNr when 'cursorline' is set and 'cursorlineopt' is
- set to "number" or "both", or 'relativenumber' is set, for
- the cursor line.
+CursorLineNr Like LineNr when 'cursorline' is set and 'cursorlineopt'
+ contains "number" or is "both", for the cursor line.
*hl-MatchParen*
MatchParen The character under the cursor or just before it, if it
is a paired bracket, and its match. |pi_paren.txt|
diff --git a/runtime/doc/testing.txt b/runtime/doc/testing.txt
index ef8d6b5ea9..3b59dfa908 100644
--- a/runtime/doc/testing.txt
+++ b/runtime/doc/testing.txt
@@ -53,6 +53,9 @@ assert_beeps({cmd}) *assert_beeps()*
Also see |assert_fails()|, |assert_nobeep()| and
|assert-return|.
+ Can also be used as a |method|: >
+ GetCmd()->assert_beeps()
+<
*assert_equal()*
assert_equal({expected}, {actual} [, {msg}])
When {expected} and {actual} are not equal an error message is
@@ -69,7 +72,10 @@ assert_equal({expected}, {actual} [, {msg}])
< Will result in a string to be added to |v:errors|:
test.vim line 12: Expected 'foo' but got 'bar' ~
- *assert_equalfile()*
+ Can also be used as a |method|: >
+ mylist->assert_equal([1, 2, 3])
+
+< *assert_equalfile()*
assert_equalfile({fname-one}, {fname-two})
When the files {fname-one} and {fname-two} do not contain
exactly the same text an error message is added to |v:errors|.
@@ -77,6 +83,9 @@ assert_equalfile({fname-one}, {fname-two})
When {fname-one} or {fname-two} does not exist the error will
mention that.
+ Can also be used as a |method|: >
+ GetLog()->assert_equalfile('expected.log')
+
assert_exception({error} [, {msg}]) *assert_exception()*
When v:exception does not contain the string {error} an error
message is added to |v:errors|. Also see |assert-return|.
@@ -97,6 +106,9 @@ assert_fails({cmd} [, {error} [, {msg}]]) *assert_fails()*
Note that beeping is not considered an error, and some failing
commands only beep. Use |assert_beeps()| for those.
+ Can also be used as a |method|: >
+ GetCmd()->assert_fails('E99:')
+
assert_false({actual} [, {msg}]) *assert_false()*
When {actual} is not false an error message is added to
|v:errors|, like with |assert_equal()|.
@@ -106,6 +118,9 @@ assert_false({actual} [, {msg}]) *assert_false()*
When {msg} is omitted an error in the form
"Expected False but got {actual}" is produced.
+ Can also be used as a |method|: >
+ GetResult()->assert_false()
+
assert_inrange({lower}, {upper}, {actual} [, {msg}]) *assert_inrange()*
This asserts number and |Float| values. When {actual} is lower
than {lower} or higher than {upper} an error message is added
@@ -134,6 +149,9 @@ assert_match({pattern}, {actual} [, {msg}])
< Will result in a string to be added to |v:errors|:
test.vim line 12: Pattern '^f.*o$' does not match 'foobar' ~
+ Can also be used as a |method|: >
+ getFile()->assert_match('foo.*')
+<
assert_nobeep({cmd}) *assert_nobeep()*
Run {cmd} and add an error message to |v:errors| if it
produces a beep or visual bell.
@@ -145,16 +163,27 @@ assert_notequal({expected}, {actual} [, {msg}])
|v:errors| when {expected} and {actual} are equal.
Also see |assert-return|.
- *assert_notmatch()*
+ Can also be used as a |method|: >
+ mylist->assert_notequal([1, 2, 3])
+
+< *assert_notmatch()*
assert_notmatch({pattern}, {actual} [, {msg}])
The opposite of `assert_match()`: add an error message to
|v:errors| when {pattern} matches {actual}.
Also see |assert-return|.
+ Can also be used as a |method|: >
+ getFile()->assert_notmatch('bar.*')
+
+
assert_report({msg}) *assert_report()*
Report a test failure directly, using {msg}.
Always returns one.
+ Can also be used as a |method|: >
+ GetMessage()->assert_report()
+
+
assert_true({actual} [, {msg}]) *assert_true()*
When {actual} is not true an error message is added to
|v:errors|, like with |assert_equal()|.
@@ -164,5 +193,8 @@ assert_true({actual} [, {msg}]) *assert_true()*
When {msg} is omitted an error in the form "Expected True but
got {actual}" is produced.
+ Can also be used as a |method|: >
+ GetResult()->assert_true()
+<
vim:tw=78:ts=8:noet:ft=help:norl:
diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt
index 166c0c17aa..4b134926a2 100644
--- a/runtime/doc/vim_diff.txt
+++ b/runtime/doc/vim_diff.txt
@@ -30,7 +30,7 @@ the differences.
- 'autoread' is enabled
- 'background' defaults to "dark" (unless set automatically by the terminal/UI)
- 'backspace' defaults to "indent,eol,start"
-- 'backupdir' defaults to .,~/.local/share/nvim/backup (|xdg|)
+- 'backupdir' defaults to .,~/.local/share/nvim/backup// (|xdg|), auto-created
- 'belloff' defaults to "all"
- 'compatible' is always disabled
- 'complete' excludes "i"
@@ -63,7 +63,7 @@ the differences.
- 'tags' defaults to "./tags;,tags"
- 'ttimeoutlen' defaults to 50
- 'ttyfast' is always set
-- 'undodir' defaults to ~/.local/share/nvim/undo (|xdg|), auto-created
+- 'undodir' defaults to ~/.local/share/nvim/undo// (|xdg|), auto-created
- 'viewoptions' includes "unix,slash", excludes "options"
- 'viminfo' includes "!"
- 'wildmenu' is enabled
@@ -76,12 +76,24 @@ the differences.
- |g:vimsyn_embed| defaults to "l" to enable Lua highlighting
-Default Mappings: *default-mappings*
+Default Mappings ~
+ *default-mappings*
+>
+ nnoremap Y y$
+ nnoremap <C-L> <Cmd>nohlsearch<Bar>diffupdate<CR><C-L>
+ inoremap <C-U> <C-G>u<C-U>
+ inoremap <C-W> <C-G>u<C-W>
+<
+Default Autocommands ~
+ *default-autocmds*
+Default autocommands exist in the following groups. Use ":autocmd! {group}" to
+remove them and ":autocmd {group}" to see how they're defined.
+
+nvim_terminal:
+- BufReadCmd: Treats "term://" buffers as |terminal| buffers. |terminal-start|
-nnoremap Y y$
-nnoremap <C-L> <Cmd>nohlsearch<Bar>diffupdate<CR><C-L>
-inoremap <C-U> <C-G>u<C-U>
-inoremap <C-W> <C-G>u<C-W>
+nvim_cmdwin:
+- CmdwinEnter: Limits syntax sync to maxlines=1 in the |cmdwin|.
==============================================================================
3. New Features *nvim-features*
diff --git a/runtime/ftplugin/jsonc.vim b/runtime/ftplugin/jsonc.vim
new file mode 100644
index 0000000000..90d52cd0d3
--- /dev/null
+++ b/runtime/ftplugin/jsonc.vim
@@ -0,0 +1,27 @@
+" Vim filetype plugin
+" Language: JSONC (JSON with Comments)
+" Original Author: Izhak Jakov <izhak724@gmail.com>
+" Acknowledgement: Based off of vim-jsonc maintained by Kevin Locke <kevin@kevinlocke.name>
+" https://github.com/kevinoid/vim-jsonc
+" License: MIT
+" Last Change: 2021-07-01
+
+runtime! ftplugin/json.vim
+
+if exists('b:did_ftplugin_jsonc')
+ finish
+else
+ let b:did_ftplugin_jsonc = 1
+endif
+
+" A list of commands that undo buffer local changes made below.
+let s:undo_ftplugin = []
+
+" Set comment (formatting) related options. {{{1
+setlocal commentstring=//%s comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,://
+call add(s:undo_ftplugin, 'commentstring< comments<')
+
+" Let Vim know how to disable the plug-in.
+call map(s:undo_ftplugin, "'execute ' . string(v:val)")
+let b:undo_ftplugin = join(s:undo_ftplugin, ' | ')
+unlet s:undo_ftplugin
diff --git a/runtime/ftplugin/man.vim b/runtime/ftplugin/man.vim
index 5d3e00d033..fce12012b5 100644
--- a/runtime/ftplugin/man.vim
+++ b/runtime/ftplugin/man.vim
@@ -6,14 +6,6 @@ if exists('b:did_ftplugin') || &filetype !=# 'man'
endif
let b:did_ftplugin = 1
-let s:pager = !exists('b:man_sect')
-
-if s:pager
- call man#init_pager()
-endif
-
-setlocal noswapfile buftype=nofile bufhidden=hide
-setlocal nomodified readonly nomodifiable
setlocal noexpandtab tabstop=8 softtabstop=8 shiftwidth=8
setlocal wrap breakindent linebreak
@@ -32,11 +24,7 @@ if !exists('g:no_plugin_maps') && !exists('g:no_man_maps')
nnoremap <silent> <buffer> k gk
nnoremap <silent> <buffer> gO :call man#show_toc()<CR>
nnoremap <silent> <buffer> <2-LeftMouse> :Man<CR>
- if s:pager
- nnoremap <silent> <buffer> <nowait> q :lclose<CR>:q<CR>
- else
- nnoremap <silent> <buffer> <nowait> q :lclose<CR><C-W>c
- endif
+ nnoremap <silent> <buffer> <nowait> q :lclose<CR><C-W>c
endif
if get(g:, 'ft_man_folding_enable', 0)
diff --git a/runtime/indent/jsonc.vim b/runtime/indent/jsonc.vim
new file mode 100644
index 0000000000..bf8e501dd5
--- /dev/null
+++ b/runtime/indent/jsonc.vim
@@ -0,0 +1,189 @@
+" Vim indent file
+" Language: JSONC (JSON with Comments)
+" Original Author: Izhak Jakov <izhak724@gmail.com>
+" Acknowledgement: Based off of vim-json maintained by Eli Parra <eli@elzr.com>
+" https://github.com/elzr/vim-json
+" Last Change: 2021-07-01
+
+" 0. Initialization {{{1
+" =================
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+setlocal nosmartindent
+
+" Now, set up our indentation expression and keys that trigger it.
+setlocal indentexpr=GetJSONCIndent()
+setlocal indentkeys=0{,0},0),0[,0],!^F,o,O,e
+
+" Only define the function once.
+if exists("*GetJSONCIndent")
+ finish
+endif
+
+let s:cpo_save = &cpo
+set cpo&vim
+
+" 1. Variables {{{1
+" ============
+
+let s:line_term = '\s*\%(\%(\/\/\).*\)\=$'
+" Regex that defines blocks.
+let s:block_regex = '\%({\)\s*\%(|\%([*@]\=\h\w*,\=\s*\)\%(,\s*[*@]\=\h\w*\)*|\)\=' . s:line_term
+
+" 2. Auxiliary Functions {{{1
+" ======================
+
+" Check if the character at lnum:col is inside a string.
+function s:IsInString(lnum, col)
+ return synIDattr(synID(a:lnum, a:col, 1), 'name') == 'jsonString'
+endfunction
+
+" Find line above 'lnum' that isn't empty, or in a string.
+function s:PrevNonBlankNonString(lnum)
+ let lnum = prevnonblank(a:lnum)
+ while lnum > 0
+ " If the line isn't empty or in a string, end search.
+ let line = getline(lnum)
+ if !(s:IsInString(lnum, 1) && s:IsInString(lnum, strlen(line)))
+ break
+ endif
+ let lnum = prevnonblank(lnum - 1)
+ endwhile
+ return lnum
+endfunction
+
+" Check if line 'lnum' has more opening brackets than closing ones.
+function s:LineHasOpeningBrackets(lnum)
+ let open_0 = 0
+ let open_2 = 0
+ let open_4 = 0
+ let line = getline(a:lnum)
+ let pos = match(line, '[][(){}]', 0)
+ while pos != -1
+ let idx = stridx('(){}[]', line[pos])
+ if idx % 2 == 0
+ let open_{idx} = open_{idx} + 1
+ else
+ let open_{idx - 1} = open_{idx - 1} - 1
+ endif
+ let pos = match(line, '[][(){}]', pos + 1)
+ endwhile
+ return (open_0 > 0) . (open_2 > 0) . (open_4 > 0)
+endfunction
+
+function s:Match(lnum, regex)
+ let col = match(getline(a:lnum), a:regex) + 1
+ return col > 0 && !s:IsInString(a:lnum, col) ? col : 0
+endfunction
+
+" 3. GetJSONCIndent Function {{{1
+" =========================
+
+function GetJSONCIndent()
+ if !exists("s:inside_comment")
+ let s:inside_comment = 0
+ endif
+
+ " 3.1. Setup {{{2
+ " ----------
+
+ " Set up variables for restoring position in file. Could use v:lnum here.
+ let vcol = col('.')
+
+ " 3.2. Work on the current line {{{2
+ " -----------------------------
+
+
+ " Get the current line.
+ let line = getline(v:lnum)
+ let ind = -1
+ if s:inside_comment == 0
+ " TODO iterate through all the matches in a line
+ let col = matchend(line, '\/\*')
+ if col > 0 && !s:IsInString(v:lnum, col)
+ let s:inside_comment = 1
+ endif
+ endif
+ " If we're in the middle of a comment
+ if s:inside_comment == 1
+ let col = matchend(line, '\*\/')
+ if col > 0 && !s:IsInString(v:lnum, col)
+ let s:inside_comment = 0
+ endif
+ return ind
+ endif
+ if line =~ '^\s*//'
+ return ind
+ endif
+
+ " If we got a closing bracket on an empty line, find its match and indent
+ " according to it.
+ let col = matchend(line, '^\s*[]}]')
+
+ if col > 0 && !s:IsInString(v:lnum, col)
+ call cursor(v:lnum, col)
+ let bs = strpart('{}[]', stridx('}]', line[col - 1]) * 2, 2)
+
+ let pairstart = escape(bs[0], '[')
+ let pairend = escape(bs[1], ']')
+ let pairline = searchpair(pairstart, '', pairend, 'bW')
+
+ if pairline > 0
+ let ind = indent(pairline)
+ else
+ let ind = virtcol('.') - 1
+ endif
+
+ return ind
+ endif
+
+ " If we are in a multi-line string, don't do anything to it.
+ if s:IsInString(v:lnum, matchend(line, '^\s*') + 1)
+ return indent('.')
+ endif
+
+ " 3.3. Work on the previous line. {{{2
+ " -------------------------------
+
+ let lnum = prevnonblank(v:lnum - 1)
+
+ if lnum == 0
+ return 0
+ endif
+
+ " Set up variables for current line.
+ let line = getline(lnum)
+ let ind = indent(lnum)
+
+ " If the previous line ended with a block opening, add a level of indent.
+ " if s:Match(lnum, s:block_regex)
+ " return indent(lnum) + shiftwidth()
+ " endif
+
+ " If the previous line contained an opening bracket, and we are still in it,
+ " add indent depending on the bracket type.
+ if line =~ '[[({]'
+ let counts = s:LineHasOpeningBrackets(lnum)
+ if counts[0] == '1' || counts[1] == '1' || counts[2] == '1'
+ return ind + shiftwidth()
+ else
+ call cursor(v:lnum, vcol)
+ end
+ endif
+
+ " }}}2
+
+ return ind
+endfunction
+
+" }}}1
+
+let &cpo = s:cpo_save
+unlet s:cpo_save
+
+" vim:set sw=2 sts=2 ts=8 noet:
diff --git a/runtime/lua/vim/F.lua b/runtime/lua/vim/F.lua
index 09467eb8c6..1a258546a5 100644
--- a/runtime/lua/vim/F.lua
+++ b/runtime/lua/vim/F.lua
@@ -27,5 +27,14 @@ function F.nil_wrap(fn)
end
end
+--- like {...} except preserve the lenght explicitly
+function F.pack_len(...)
+ return {n=select('#', ...), ...}
+end
+
+--- like unpack() but use the length set by F.pack_len if present
+function F.unpack_len(t)
+ return unpack(t, 1, t.n)
+end
return F
diff --git a/runtime/lua/vim/highlight.lua b/runtime/lua/vim/highlight.lua
index 4cb1994419..236f3165f2 100644
--- a/runtime/lua/vim/highlight.lua
+++ b/runtime/lua/vim/highlight.lua
@@ -85,7 +85,11 @@ function highlight.on_yank(opts)
highlight.range(bufnr, yank_ns, higroup, pos1, pos2, event.regtype, event.inclusive)
vim.defer_fn(
- function() api.nvim_buf_clear_namespace(bufnr, yank_ns, 0, -1) end,
+ function()
+ if api.nvim_buf_is_valid(bufnr) then
+ api.nvim_buf_clear_namespace(bufnr, yank_ns, 0, -1)
+ end
+ end,
timeout
)
end
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua
index 8821bd53e7..0fdd43e210 100644
--- a/runtime/lua/vim/lsp.lua
+++ b/runtime/lua/vim/lsp.lua
@@ -381,7 +381,7 @@ do
end
state.pending_change = function()
state.pending_change = nil
- if client.is_stopped() then
+ if client.is_stopped() or not vim.api.nvim_buf_is_valid(bufnr) then
return
end
local contentChanges
@@ -1152,7 +1152,7 @@ end
---@param bufnr (number) Buffer handle, or 0 for current
---@param client_id (number) the client id
function lsp.buf_is_attached(bufnr, client_id)
- return (all_buffer_active_clients[bufnr] or {})[client_id] == true
+ return (all_buffer_active_clients[resolve_bufnr(bufnr)] or {})[client_id] == true
end
--- Gets a client by id, or nil if the id is invalid.
diff --git a/runtime/lua/vim/lsp/codelens.lua b/runtime/lua/vim/lsp/codelens.lua
index 3af1d836c7..7e706823f0 100644
--- a/runtime/lua/vim/lsp/codelens.lua
+++ b/runtime/lua/vim/lsp/codelens.lua
@@ -44,9 +44,10 @@ end
--- Return all lenses for the given buffer
---
+---@param bufnr number Buffer number. 0 can be used for the current buffer.
---@return table (`CodeLens[]`)
function M.get(bufnr)
- local lenses_by_client = lens_cache_by_buf[bufnr]
+ local lenses_by_client = lens_cache_by_buf[bufnr or 0]
if not lenses_by_client then return {} end
local lenses = {}
for _, client_lenses in pairs(lenses_by_client) do
diff --git a/runtime/lua/vim/lsp/diagnostic.lua b/runtime/lua/vim/lsp/diagnostic.lua
index 11bfa41097..41a62da522 100644
--- a/runtime/lua/vim/lsp/diagnostic.lua
+++ b/runtime/lua/vim/lsp/diagnostic.lua
@@ -1217,9 +1217,8 @@ function M.redraw(bufnr, client_id)
)
end
--- }}}
--- Diagnostic User Functions {{{
+---@private
--- Open a floating window with the provided diagnostics
---
--- The floating window can be customized with the following highlight groups:
@@ -1268,8 +1267,11 @@ local function show_diagnostics(opts, diagnostics)
return popup_bufnr, winnr
end
---- Open a floating window with the diagnostics from {position}
+-- }}}
+-- Diagnostic User Functions {{{
+
+--- Open a floating window with the diagnostics from {position}
---@param opts table|nil Configuration keys
--- - severity: (DiagnosticSeverity, default nil)
--- - Only return diagnostics with this severity. Overrides severity_limit
@@ -1337,6 +1339,7 @@ function M.reset(client_id, buffer_client_map)
end)
end
+---@private
--- Gets diagnostics, converts them to quickfix/location list items, and applies the item_handler callback to the items.
---@param item_handler function Callback to apply to the diagnostic items
---@param command string|nil Command to execute after applying the item_handler
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua
index a4b3298fd8..a4c8b69f6c 100644
--- a/runtime/lua/vim/lsp/util.lua
+++ b/runtime/lua/vim/lsp/util.lua
@@ -43,7 +43,9 @@ local loclist_type_map = {
---@private
--- Check the border given by opts or the default border for the additional
--- size it adds to a float.
----@returns size of border in height and width
+---@param opts (table, optional) options for the floating window
+--- - border (string or table) the border
+---@returns (table) size of border in the form of { height = height, width = width }
local function get_border_size(opts)
local border = opts and opts.border or default_border
local height = 0
@@ -52,12 +54,16 @@ local function get_border_size(opts)
if type(border) == 'string' then
local border_size = {none = {0, 0}, single = {2, 2}, double = {2, 2}, rounded = {2, 2}, solid = {2, 2}, shadow = {1, 1}}
if border_size[border] == nil then
- error("floating preview border is not correct. Please refer to the docs |vim.api.nvim_open_win()|"
- .. vim.inspect(border))
+ error(string.format("invalid floating preview border: %s. :help vim.api.nvim_open_win()", vim.inspect(border)))
end
height, width = unpack(border_size[border])
else
+ if 8 % #border ~= 0 then
+ error(string.format("invalid floating preview border: %s. :help vim.api.nvim_open_win()", vim.inspect(border)))
+ end
+ ---@private
local function border_width(id)
+ id = (id - 1) % #border + 1
if type(border[id]) == "table" then
-- border specified as a table of <character, highlight group>
return vim.fn.strdisplaywidth(border[id][1])
@@ -65,9 +71,11 @@ local function get_border_size(opts)
-- border specified as a list of border characters
return vim.fn.strdisplaywidth(border[id])
end
- error("floating preview border is not correct. Please refer to the docs |vim.api.nvim_open_win()|" .. vim.inspect(border))
+ error(string.format("invalid floating preview border: %s. :help vim.api.nvim_open_win()", vim.inspect(border)))
end
+ ---@private
local function border_height(id)
+ id = (id - 1) % #border + 1
if type(border[id]) == "table" then
-- border specified as a table of <character, highlight group>
return #border[id][1] > 0 and 1 or 0
@@ -75,7 +83,7 @@ local function get_border_size(opts)
-- border specified as a list of border characters
return #border[id] > 0 and 1 or 0
end
- error("floating preview border is not correct. Please refer to the docs |vim.api.nvim_open_win()|" .. vim.inspect(border))
+ error(string.format("invalid floating preview border: %s. :help vim.api.nvim_open_win()", vim.inspect(border)))
end
height = height + border_height(2) -- top
height = height + border_height(6) -- bottom
diff --git a/runtime/lua/vim/treesitter.lua b/runtime/lua/vim/treesitter.lua
index a09e0a9cf7..66999c5f7f 100644
--- a/runtime/lua/vim/treesitter.lua
+++ b/runtime/lua/vim/treesitter.lua
@@ -20,6 +20,9 @@ setmetatable(M, {
elseif k == "language" then
t[k] = require"vim.treesitter.language"
return t[k]
+ elseif k == "query" then
+ t[k] = require"vim.treesitter.query"
+ return t[k]
end
end
})
diff --git a/runtime/plugin/man.vim b/runtime/plugin/man.vim
index 689aa32ef3..b10677593f 100644
--- a/runtime/plugin/man.vim
+++ b/runtime/plugin/man.vim
@@ -5,8 +5,8 @@ if exists('g:loaded_man')
endif
let g:loaded_man = 1
-command! -bang -bar -range=-1 -complete=customlist,man#complete -nargs=* Man
- \ if <bang>0 | set ft=man |
+command! -bang -bar -addr=other -complete=customlist,man#complete -nargs=* Man
+ \ if <bang>0 | call man#init_pager() |
\ else | call man#open_page(<count>, <q-mods>, <f-args>) | endif
augroup man
diff --git a/runtime/syntax/jsonc.vim b/runtime/syntax/jsonc.vim
new file mode 100644
index 0000000000..d0df16bbf1
--- /dev/null
+++ b/runtime/syntax/jsonc.vim
@@ -0,0 +1,44 @@
+" Vim syntax file
+" Language: JSONC (JSON with Comments)
+" Original Author: Izhak Jakov <izhak724@gmail.com>
+" Acknowledgement: Based off of vim-jsonc maintained by Kevin Locke <kevin@kevinlocke.name>
+" https://github.com/kevinoid/vim-jsonc
+" License: MIT
+" Last Change: 2021-07-01
+
+" Ensure syntax is loaded once, unless nested inside another (main) syntax
+" For description of main_syntax, see https://stackoverflow.com/q/16164549
+if !exists('g:main_syntax')
+ if exists('b:current_syntax') && b:current_syntax ==# 'jsonc'
+ finish
+ endif
+ let g:main_syntax = 'jsonc'
+endif
+
+" Based on vim-json syntax
+runtime! syntax/json.vim
+
+" Remove syntax group for comments treated as errors
+if !exists("g:vim_json_warnings") || g:vim_json_warnings
+ syn clear jsonCommentError
+endif
+
+syn match jsonStringMatch /"\([^"]\|\\\"\)\+"\ze\(\_s*\/\/.*\_s*\)*[}\]]/ contains=jsonString
+syn match jsonStringMatch /"\([^"]\|\\\"\)\+"\ze\_s*\/\*\_.*\*\/\_s*[}\]]/ contains=jsonString
+syn match jsonTrailingCommaError /\(,\)\+\ze\(\_s*\/\/.*\_s*\)*[}\]]/
+syn match jsonTrailingCommaError /\(,\)\+\ze\_s*\/\*\_.*\*\/\_s*[}\]]/
+
+" Define syntax matching comments and their contents
+syn keyword jsonCommentTodo FIXME NOTE TBD TODO XXX
+syn region jsonLineComment start=+\/\/+ end=+$+ contains=@Spell,jsonCommentTodo keepend
+syn region jsonComment start='/\*' end='\*/' contains=@Spell,jsonCommentTodo fold
+
+" Link comment syntax comment to highlighting
+hi! def link jsonLineComment Comment
+hi! def link jsonComment Comment
+
+" Set/Unset syntax to avoid duplicate inclusion and correctly handle nesting
+let b:current_syntax = 'jsonc'
+if g:main_syntax ==# 'jsonc'
+ unlet g:main_syntax
+endif
diff --git a/runtime/syntax/man.vim b/runtime/syntax/man.vim
index a01bd1c0e7..55b0e16de9 100644
--- a/runtime/syntax/man.vim
+++ b/runtime/syntax/man.vim
@@ -6,7 +6,7 @@ if exists('b:current_syntax')
endif
syntax case ignore
-syntax match manReference display '[^()[:space:]]\+([0-9nx][a-z]*)'
+syntax match manReference display '[^()[:space:]]\+(\%([0-9][a-z]*\|[nlpox]\))'
syntax match manSectionHeading display '^\S.*$'
syntax match manHeader display '^\%1l.*$'
syntax match manSubHeading display '^ \{3\}\S.*$'
@@ -27,11 +27,7 @@ if &filetype != 'man'
finish
endif
-if !exists('b:man_sect')
- call man#init_pager()
-endif
-
-if b:man_sect =~# '^[023]'
+if get(b:, 'man_sect', '') =~# '^[023]'
syntax case match
syntax include @c $VIMRUNTIME/syntax/c.vim
syntax match manCFuncDefinition display '\<\h\w*\>\ze\(\s\|\n\)*(' contained
diff --git a/runtime/tutor/en/vim-01-beginner.tutor b/runtime/tutor/en/vim-01-beginner.tutor
index 5ae0fde0da..7c0c357e80 100644
--- a/runtime/tutor/en/vim-01-beginner.tutor
+++ b/runtime/tutor/en/vim-01-beginner.tutor
@@ -1,4 +1,4 @@
-# Welcome to the VIM Tutor
+# Welcome to the VIM Tutor
Vim is a very powerful editor that has many commands, too many to explain in
a tutor such as this. This tutor is designed to describe enough of the
@@ -21,7 +21,9 @@ This tutorial is interactive, and there are a few things you should know.
- Type [<Enter>](<Enter>) on links [like this](holy-grail ) to open the linked help section.
- Or simply type [K](K) on any word to find its documentation!
- Sometimes you will be required to modify text like
-this here
+
+ this here
+
Once you have done the changes correctly, the ✗ sign at the left will change
to ✓. I imagine you can already see how neat Vim can be. ;)
Other times, you'll be prompted to run a command (I'll explain this later):
@@ -32,7 +34,6 @@ or press a sequence of keys
~~~ normal
<Esc>0f<Space>d3wP$P
~~~
-
Text within <'s and >'s (like `<Enter>`{normal}) describes a key to press
instead of text to type.
@@ -48,12 +49,12 @@ Now, move to the next lesson (use the `j`{normal} key to scroll down).
j The `j`{normal} key looks like a down arrow.
- 1. Move the cursor around the screen until you are comfortable.
+ 1. Move the cursor around the screen until you are comfortable.
- 2. Hold down the down key (`j`{normal}) until it repeats.
- Now you know how to move to the next lesson.
+ 2. Hold down the down key (`j`{normal}) until it repeats.
+ Now you know how to move to the next lesson.
- 3. Using the down key, move to Lesson 1.2.
+ 3. Using the down key, move to Lesson 1.2.
NOTE: If you are ever unsure about something you typed, press <Esc> to place
you in Normal mode. Then retype the command you wanted.
@@ -63,8 +64,7 @@ NOTE: The cursor keys should also work. But using hjkl you will be able to
# Lesson 1.2: EXITING VIM
-!! NOTE: Before executing any of the steps below,
-read this entire lesson !!
+!! NOTE: Before executing any of the steps below, read this entire lesson !!
1. Press the <Esc> key (to make sure you are in Normal mode).
@@ -72,18 +72,18 @@ read this entire lesson !!
`:q!`{vim} `<Enter>`{normal}.
- This exits the editor, DISCARDING any changes you have made.
+ This exits the editor, DISCARDING any changes you have made.
3. Open vim and get back here by executing the command that got you into
- this tutor. That might be:
+ this tutor. That might be:
- :Tutor <Enter>
+ :Tutor <Enter>
4. If you have these steps memorized and are confident, execute steps
- 1 through 3 to exit and re-enter the editor.
+ 1 through 3 to exit and re-enter the editor.
NOTE: [:q!](:q) <Enter> discards any changes you made. In a few lessons you
- will learn how to save the changes to a file.
+ will learn how to save the changes to a file.
5. Move the cursor down to Lesson 1.3.
@@ -94,7 +94,7 @@ NOTE: [:q!](:q) <Enter> discards any changes you made. In a few lessons you
1. Move the cursor to the line below marked ✗.
2. To fix the errors, move the cursor until it is on top of the
- character to be deleted.
+ character to be deleted.
3. Press [the x key](x) to delete the unwanted character.
@@ -104,8 +104,9 @@ The ccow jumpedd ovverr thhe mooon.
5. Now that the line is correct, go on to Lesson 1.4.
-NOTE: As you go through this tutor, do not try to memorize, learn by
- usage.
+NOTE: As you go through this tutor, do not try to memorize everything,
+ your Vim vocabulary will expand with usage. Consider returning to
+ this tutor periodically for a refresher.
# Lesson 1.4: TEXT EDITING: INSERTION
@@ -114,12 +115,12 @@ NOTE: As you go through this tutor, do not try to memorize, learn by
1. Move the cursor to the first line below marked ✗.
2. To make the first line the same as the second, move the cursor on top
- of the first character AFTER where the text is to be inserted.
+ of the first character AFTER where the text is to be inserted.
3. Press `i`{normal} and type in the necessary additions.
4. As each error is fixed press `<Esc>`{normal} to return to Normal mode.
- Repeat steps 2 through 4 to correct the sentence.
+ Repeat steps 2 through 4 to correct the sentence.
There is text misng this .
There is some text missing from this line.
@@ -136,7 +137,7 @@ There is some text missing from this line.
2. Press [A](A) and type in the necessary additions.
3. As the text has been appended press `<Esc>`{normal} to return to Normal
- mode.
+ mode.
4. Move the cursor to the second line marked ✗ and repeat
steps 2 and 3 to correct this sentence.
@@ -159,7 +160,7 @@ There is also some text missing here.
2. At the shell prompt type this command:
~~~ sh
- $ nvim tutor
+ $ nvim tutor
~~~
'nvim' is the command to start the Nvim editor, 'tutor' is the name of
the file you wish to edit. Use a file that may be changed.
@@ -168,13 +169,12 @@ There is also some text missing here.
4. Save the file with changes and exit Vim with:
~~~ cmd
- :wq
+ :wq
~~~
-
Note you'll need to press `<Enter>` to execute the command.
5. If you have quit vimtutor in step 1 restart the vimtutor and move down
- to the following summary.
+ to the following summary.
6. After reading the above steps and understanding them: do it.
@@ -184,15 +184,11 @@ There is also some text missing here.
h (left) j (down) k (up) l (right)
2. To start Vim from the shell prompt type:
-
~~~ sh
$ nvim FILENAME
~~~
-
- 3. To exit Vim type: `<Esc>`{normal} `:q!`{vim} `<Enter>`{normal} to trash
- all changes.
- OR type: `<Esc>`{normal} `:wq`{vim} `<Enter>`{normal} to save
- the changes.
+ 3. To exit Vim type: `<Esc>`{normal} `:q!`{vim} `<Enter>`{normal} to trash all changes.
+ OR type: `<Esc>`{normal} `:wq`{vim} `<Enter>`{normal} to save the changes.
4. To delete the character at the cursor type: `x`{normal}
@@ -239,8 +235,7 @@ Somebody typed the end of this line twice. end of this line twice.
# Lesson 2.3: ON OPERATORS AND MOTIONS
-Many commands that change text are made from an [operator](operator) and
-a [motion](navigation).
+Many commands that change text are made from an [operator](operator) and a [motion](navigation).
The format for a delete command with the [d](d) delete operator is as follows:
d motion
@@ -318,16 +313,13 @@ it would be easier to simply type two d's to delete a line.
** Press `u`{normal} to undo the last commands, `U`{normal} to fix a whole line. **
- 1. Move the cursor to the line below marked ✗ and place it on the
- first error.
+ 1. Move the cursor to the line below marked ✗ and place it on the first error.
2. Type `x`{normal} to delete the first unwanted character.
3. Now type `u`{normal} to undo the last command executed.
4. This time fix all the errors on the line using the `x`{normal} command.
5. Now type a capital `U`{normal} to return the line to its original state.
- 6. Now type `u`{normal} a few times to undo the `U`{normal} and preceding
- commands.
- 7. Now type `<C-r>`{normal} (Control + R) a few times to redo the commands
- (undo the undos).
+ 6. Now type `u`{normal} a few times to undo the `U`{normal} and preceding commands.
+ 7. Now type `<C-r>`{normal} (Control + R) a few times to redo the commands.
Fiix the errors oon thhis line and reeplace them witth undo.
@@ -341,11 +333,14 @@ Fiix the errors oon thhis line and reeplace them witth undo.
4. To repeat a motion prepend it with a number: `2w`{normal}
5. The format for a change command is:
- operator [number] motion
+
+ operator [number] motion
+
where:
- operator - is what to do, such as [d](d) for delete
- [number] - is an optional count to repeat the motion
- motion - moves over the text to operate on, such as:
+
+ operator - is what to do, such as [d](d) for delete
+ [number] - is an optional count to repeat the motion
+ motion - moves over the text to operate on, such as:
[w](w) (word),
[$]($) (to the end of line), etc.
@@ -403,8 +398,7 @@ NOTE: Remember that you should be learning by doing, not memorization.
3. Type `ce`{normal} and the correct word (in this case, type "ine" ).
- 4. Press `<Esc>`{normal} and move to the next character that needs to be
- changed.
+ 4. Press `<Esc>`{normal} and move to the next character that needs to be changed.
5. Repeat steps 3 and 4 until the first sentence is the same as the second.
@@ -419,7 +413,7 @@ Notice that [c](c)e deletes the word and places you in Insert mode.
1. The change operator works in the same way as delete. The format is:
- c [number] motion
+ c [number] motion
2. The motions are the same, such as `w`{normal} (word) and `$`{normal} (end of line).
@@ -449,7 +443,7 @@ NOTE: You can use the Backspace key to correct mistakes while typing.
4. The format for change is:
- c [number] motion
+ c [number] motion
Now go on to the next lesson.
@@ -460,13 +454,13 @@ Now go on to the next lesson.
NOTE: Read this entire lesson before executing any of the steps!!
- 1. Hold down the `<Ctrl>`{normal} key and press `g`{normal}. We call this
- `<C-g>`{normal}. A message will appear at the bottom of the page with the
- filename and the position in the file. Remember the line number for
- Step 3.
+ 1. Hold down the `<Ctrl>`{normal} key and press `g`{normal}. We call this `<C-g>`{normal}.
+ A message will appear at the bottom of the page with the filename and
+ the position in the file. Remember the line number for Step 3.
NOTE: You may see the cursor position in the lower right corner of the
screen. This happens when the ['ruler']('ruler') option is set.
+
2. Press [G](G) to move you to the bottom of the file.
Type [gg](gg) to move you to the start of the file.
@@ -482,17 +476,16 @@ NOTE: You may see the cursor position in the lower right corner of the
1. In Normal mode type the `/`{normal} character. Notice that it and the
cursor appear at the bottom of the screen as with the `:`{normal} command.
- 2. Now type 'errroor' `<Enter>`{normal}. This is the word you want to search
- for.
+ 2. Now type 'errroor' `<Enter>`{normal}. This is the word you want to search for.
3. To search for the same phrase again, simply type [n](n).
To search for the same phrase in the opposite direction, type [N](N).
- 4. To search for a phrase in the backward direction, use [?](?) instead
- of `/`{normal}.
+ 4. To search for a phrase in the backward direction, use [?](?) instead of `/`{normal}.
- 5. To go back to where you came from press `<C-o>`{normal} (keep `<Ctrl>`{normal} pressed down while pressing the letter `o`{normal}). Repeat to go back
- further. `<C-i>`{normal} goes forward.
+ 5. To go back to where you came from press `<C-o>`{normal}.
+ (keep `<Ctrl>`{normal} pressed down while pressing the letter `o`{normal}).
+ Repeat to go back further. `<C-i>`{normal} goes forward.
"errroor" is not the way to spell error; errroor is an error.
@@ -525,16 +518,14 @@ NOTE: This is very useful in debugging a program with unmatched parentheses!
2. Type
~~~ cmd
- :s/thee/the/
+ :s/thee/the/
~~~
-
- NOTE that the [:s](:s) command only changed the first occurrence of "thee" in the line.
+ NOTE: the [:s](:s) command only changed the first match of "thee" in the line.
3. Now type
~~~ cmd
- :s/thee/the/g
+ :s/thee/the/g
~~~
-
Adding the g [flag](:s_flags) means to substitute globally in the line,
change all occurrences of "thee" in the line.
@@ -542,20 +533,20 @@ Usually thee best time to see thee flowers is in thee spring.
4. To change every occurrence of a character string between two lines, type
~~~ cmd
- :#,#s/old/new/g
+ :#,#s/old/new/g
~~~
where #,# are the line numbers of the range of lines where the
substitution is to be done.
Type
~~~ cmd
- :%s/old/new/g
+ :%s/old/new/g
~~~
to change every occurrence in the whole file.
Type
~~~ cmd
- :%s/old/new/gc
+ :%s/old/new/gc
~~~
to find every occurrence in the whole file, with a prompt whether to
substitute or not.
@@ -564,7 +555,7 @@ Usually thee best time to see thee flowers is in thee spring.
1. `<C-g>`{normal} displays your location and the file status.
`G`{normal} moves to the end of the file.
- number `G`{normal} moves to that line number.
+ number `G`{normal} moves to that line number.
`gg`{normal} moves to the first line.
2. Typing `/`{normal} followed by a phrase searches FORWARD for the phrase.
@@ -643,7 +634,6 @@ NOTE: If you were to exit Vim and start it again with `nvim TEST`, the file
~~~ cmd
:!rm TEST
~~~
-
# Lesson 5.3: SELECTING TEXT TO WRITE
** To save part of the file, type `v`{normal} motion `:w FILENAME`{vim}. **
@@ -655,7 +645,7 @@ NOTE: If you were to exit Vim and start it again with `nvim TEST`, the file
3. Press the `:`{normal} character. At the bottom of the screen
- :'<,'>
+ `:'<,'>`{vim}
will appear.
@@ -669,12 +659,12 @@ NOTE: If you were to exit Vim and start it again with `nvim TEST`, the file
before you press `<Enter>`{normal}.
- 5. Vim will write the selected lines to the file TEST. Use `:!ls`{vim} to see it. Do not remove it yet! We will use it in the next lesson.
+ 5. Vim will write the selected lines to the file TEST. Use `:!ls`{vim} to see it.
+ Do not remove it yet! We will use it in the next lesson.
-NOTE: Pressing [v](v) starts [Visual selection](visual-mode). You can move
- the cursor around to make the selection bigger or smaller. Then you can
- use an operator to do something with the text. For example, `d`{normal}
- deletes the text.
+NOTE: Pressing [v](v) starts [Visual selection](visual-mode). You can move the cursor around to
+ make the selection bigger or smaller. Then you can use an operator to
+ do something with the text. For example, `d`{normal} deletes the text.
# Lesson 5.4: RETRIEVING AND MERGING FILES
@@ -689,8 +679,8 @@ NOTE: After executing Step 2 you will see text from Lesson 5.3. Then move
`:r TEST`{vim}
- where TEST is the name of the file you used.
- The file you retrieve is placed below the cursor line.
+ where TEST is the name of the file you used.
+ The file you retrieve is placed below the cursor line.
3. To verify that a file was retrieved, cursor back and notice that there
are now two copies of Lesson 5.3, the original and the file version.
@@ -706,20 +696,20 @@ NOTE: You can also read the output of an external command. For example,
1. [:!command](:!cmd) executes an external command.
Some useful examples are:
- `:!ls`{vim} - shows a directory listing
- `:!rm FILENAME`{vim} - removes file FILENAME
+ `:!ls`{vim} - shows a directory listing
+ `:!rm FILENAME`{vim} - removes file FILENAME
- 2. [:w](:w) FILENAME writes the current Vim file to disk with
- name FILENAME.
+ 2. [:w](:w) FILENAME writes the current Vim file to disk with
+ name FILENAME.
3. [v](v) motion :w FILENAME saves the Visually selected lines in file
FILENAME.
- 4. [:r](:r) FILENAME retrieves disk file FILENAME and puts it
- below the cursor position.
+ 4. [:r](:r) FILENAME retrieves disk file FILENAME and puts it
+ below the cursor position.
- 5. [:r !dir](:r!) reads the output of the dir command and
- puts it below the cursor position.
+ 5. [:r !dir](:r!) reads the output of the dir command and
+ puts it below the cursor position.
# Lesson 6.1: THE OPEN COMMAND
@@ -747,14 +737,11 @@ Open up a line above this by typing O while the cursor is on this line.
2. Press `e`{normal} until the cursor is on the end of "li".
- 3. Type the lowercase letter `a`{normal} to [append](a) text AFTER the
- cursor.
+ 3. Type the lowercase letter `a`{normal} to [append](a) text AFTER the cursor.
- 4. Complete the word like the line below it. Press `<Esc>`{normal} to exit
- Insert mode.
+ 4. Complete the word like the line below it. Press `<Esc>`{normal} to exit Insert mode.
- 5. Use `e`{normal} to move to the next incomplete word and repeat steps 3
- and 4.
+ 5. Use `e`{normal} to move to the next incomplete word and repeat steps 3 and 4.
This li will allow you to pract appendi text to a line.
This line will allow you to practice appending text to a line.
@@ -767,21 +754,21 @@ NOTE: [a](a), [i](i) and [A](A) all go to the same Insert mode, the only
** Type a capital `R`{normal} to replace more than one character. **
1. Move the cursor to the first line below marked ✗. Move the cursor to
- the beginning of the first "xxx".
+ the beginning of the first "xxx".
2. Now press `R`{normal} ([capital R](R)) and type the number below it in the
- second line, so that it replaces the "xxx".
+ second line, so that it replaces the "xxx".
3. Press `<Esc>`{normal} to leave [Replace mode](mode-replace). Notice that
- the rest of the line remains unmodified.
+ the rest of the line remains unmodified.
4. Repeat the steps to replace the remaining "xxx".
Adding 123 to xxx gives you xxx.
Adding 123 to 456 gives you 579.
-NOTE: Replace mode is like Insert mode, but every typed character deletes an
- existing character.
+NOTE: Replace mode is like Insert mode, but every typed character
+ deletes an existing character.
# Lesson 6.4: COPY AND PASTE TEXT
@@ -875,17 +862,17 @@ NOTE: If you want to ignore case for just one search command, use [\c](/\c)
~~~ cmd
:set invic
~~~
-
# Lesson 7.1: GETTING HELP
** Use the on-line help system. **
-Vim has a comprehensive on-line help system. To get started, try one of
-these three:
- - press the `<HELP>`{normal} key (if you have one)
- - press the `<F1>`{normal} key (if you have one)
- - type
- `:help`{vim}
+Vim has a comprehensive on-line help system.
+
+To get started, try one of these three:
+
+ - press the `<HELP>`{normal} key (if you have one)
+ - press the `<F1>`{normal} key (if you have one)
+ - type `:help`{vim}
Read the text in the help window to find out how the help works.
Type `<C-w><C-w>`{normal} to jump from one window to another.
@@ -907,10 +894,12 @@ 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.
+
`:call mkdir(stdpath('config'),'p')`{vim}
`:exe 'edit' stdpath('config').'/init.vim'`{vim}
2. Write the file with:
+
`:w`{vim}
You can add all your preferred settings to this "vimrc" file.
@@ -924,17 +913,15 @@ default. To start using more features you have to create a "vimrc" file.
2. Type the start of a command: `:e`{vim}
- 3. Press `<C-d>`{normal} and Vim will show a list of commands that start
- with "e".
+ 3. Press `<C-d>`{normal} and Vim will show a list of commands beginning with "e".
4. Press `<Tab>`{normal} and Vim will complete the command name to ":edit".
5. Now add a space and the start of an existing file name: `:edit FIL`{vim}
- 6. Press `<Tab>`{normal}. Vim will complete the name (if it is unique).
+ 6. Press `<Tab>`{normal}. Vim will complete the name ("FIL" -> "FILE", if it is unique).
-NOTE: Completion works for many commands. It is especially useful for
- `:help`{vim}.
+NOTE: Completion works for many commands. It is especially useful for `:help`{vim}.
# Lesson 7 SUMMARY
@@ -950,7 +937,7 @@ NOTE: Completion works for many commands. It is especially useful for
5. Create a vimrc startup script to keep your preferred settings.
6. While in command mode, press `<C-d>`{normal} to see possible completions.
- Press `<Tab>`{normal} to use one completion.
+ Press `<Tab>`{normal} to use one completion.
# CONCLUSION
@@ -961,13 +948,20 @@ many many more commands. Consult the help often.
There are many resources online to learn more about vim. Here's a bunch of
them:
-- *Learn Vim Progressively*: http://yannesposito.com/Scratch/en/blog/Learn-Vim-Progressively/
-- *Learning Vim in 2014*: http://benmccormick.org/learning-vim-in-2014/
-- *Vimcasts*: http://vimcasts.org/
-- *Vim Video-Tutorials by Derek Wyatt*: http://derekwyatt.org/vim/tutorials/
-- *Learn Vimscript the Hard Way*: http://learnvimscriptthehardway.stevelosh.com/
-- *7 Habits of Effective Text Editing*: http://www.moolenaar.net/habits.html
-- *vim-galore*: https://github.com/mhinz/vim-galore
+- *Learn Vim Progressively*:
+ http://yannesposito.com/Scratch/en/blog/Learn-Vim-Progressively/
+- *Learning Vim in 2013*:
+ http://benmccormick.org/learning-vim-in-2014/
+- *Vimcasts*:
+ http://vimcasts.org/
+- *Vim Video-Tutorials by Derek Wyatt*:
+ http://derekwyatt.org/vim/tutorials/
+- *Learn Vimscript the Hard Way*:
+ http://learnvimscriptthehardway.stevelosh.com/
+- *7 Habits of Effective Text Editing*:
+ http://www.moolenaar.net/habits.html
+- *vim-galore*:
+ https://github.com/mhinz/vim-galore
If you prefer a book, *Practical Vim* by Drew Neil is recommended often
(the sequel, *Modern Vim*, includes material specific to nvim).
@@ -978,3 +972,5 @@ University. E-mail: bware@mines.colorado.edu.
Modified for Vim by Bram Moolenaar.
Modified for vim-tutor-mode by Felipe Morales.
+
+// vim: nowrap
diff --git a/runtime/tutor/en/vim-01-beginner.tutor.json b/runtime/tutor/en/vim-01-beginner.tutor.json
index af22cf2aca..e71ead976d 100644
--- a/runtime/tutor/en/vim-01-beginner.tutor.json
+++ b/runtime/tutor/en/vim-01-beginner.tutor.json
@@ -1,45 +1,45 @@
{
"expect": {
- "24": -1,
+ "25": -1,
"103": "The cow jumped over the moon.",
- "124": "There is some text missing from this line.",
"125": "There is some text missing from this line.",
- "144": "There is some text missing from this line.",
+ "126": "There is some text missing from this line.",
"145": "There is some text missing from this line.",
- "146": "There is also some text missing here.",
+ "146": "There is some text missing from this line.",
"147": "There is also some text missing here.",
- "220": "There are some words that don't belong in this sentence.",
- "236": "Somebody typed the end of this line twice.",
- "276": -1,
- "295": "This line of words is cleaned up.",
+ "148": "There is also some text missing here.",
+ "216": "There are some words that don't belong in this sentence.",
+ "232": "Somebody typed the end of this line twice.",
+ "271": -1,
+ "290": "This line of words is cleaned up.",
+ "304": -1,
+ "305": -1,
+ "306": -1,
+ "307": -1,
+ "308": -1,
"309": -1,
"310": -1,
- "311": -1,
- "312": -1,
- "313": -1,
- "314": -1,
- "315": -1,
- "332": "Fix the errors on this line and replace them with undo.",
- "372": -1,
- "373": -1,
- "374": -1,
- "375": -1,
- "389": "When this line was typed in, someone pressed some wrong keys!",
- "390": "When this line was typed in, someone pressed some wrong keys!",
- "411": "This line has a few words that need changing using the change operator.",
- "412": "This line has a few words that need changing using the change operator.",
- "432": "The end of this line needs to be corrected using the `c$` command.",
- "433": "The end of this line needs to be corrected using the `c$` command.",
- "497": -1,
- "516": -1,
- "541": "Usually the best time to see the flowers is in the spring.",
- "735": -1,
- "740": -1,
- "759": "This line will allow you to practice appending text to a line.",
- "760": "This line will allow you to practice appending text to a line.",
- "780": "Adding 123 to 456 gives you 579.",
- "781": "Adding 123 to 456 gives you 579.",
- "807": "a) This is the first item.",
- "808": "b) This is the second item."
+ "324": "Fix the errors on this line and replace them with undo.",
+ "367": -1,
+ "368": -1,
+ "369": -1,
+ "370": -1,
+ "384": "When this line was typed in, someone pressed some wrong keys!",
+ "385": "When this line was typed in, someone pressed some wrong keys!",
+ "405": "This line has a few words that need changing using the change operator.",
+ "406": "This line has a few words that need changing using the change operator.",
+ "426": "The end of this line needs to be corrected using the `c$` command.",
+ "427": "The end of this line needs to be corrected using the `c$` command.",
+ "490": -1,
+ "509": -1,
+ "532": "Usually the best time to see the flowers is in the spring.",
+ "725": -1,
+ "730": -1,
+ "746": "This line will allow you to practice appending text to a line.",
+ "747": "This line will allow you to practice appending text to a line.",
+ "767": "Adding 123 to 456 gives you 579.",
+ "768": "Adding 123 to 456 gives you 579.",
+ "794": "a) This is the first item.",
+ "795": "b) This is the second item."
}
}