aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/autoload/health/provider.vim44
-rw-r--r--runtime/autoload/provider/clipboard.vim72
-rw-r--r--runtime/autoload/provider/node.vim19
-rw-r--r--runtime/autoload/provider/perl.vim28
-rw-r--r--runtime/autoload/provider/ruby.vim3
-rw-r--r--runtime/doc/api.txt96
-rw-r--r--runtime/doc/autocmd.txt174
-rw-r--r--runtime/doc/cmdline.txt1
-rw-r--r--runtime/doc/develop.txt6
-rw-r--r--runtime/doc/digraph.txt1
-rw-r--r--runtime/doc/eval.txt65
-rw-r--r--runtime/doc/help.txt4
-rw-r--r--runtime/doc/if_perl.txt268
-rw-r--r--runtime/doc/index.txt3
-rw-r--r--runtime/doc/intro.txt93
-rw-r--r--runtime/doc/lsp.txt73
-rw-r--r--runtime/doc/lua.txt193
-rw-r--r--runtime/doc/mbyte.txt208
-rw-r--r--runtime/doc/message.txt2
-rw-r--r--runtime/doc/mlang.txt3
-rw-r--r--runtime/doc/nvim_terminal_emulator.txt2
-rw-r--r--runtime/doc/options.txt44
-rw-r--r--runtime/doc/provider.txt14
-rw-r--r--runtime/doc/quickref.txt2
-rw-r--r--runtime/doc/starting.txt175
-rw-r--r--runtime/doc/ui.txt4
-rw-r--r--runtime/doc/usr_02.txt2
-rw-r--r--runtime/doc/vim_diff.txt19
-rw-r--r--runtime/filetype.vim6
-rw-r--r--runtime/lua/vim/highlight.lua2
-rw-r--r--runtime/lua/vim/lsp.lua10
-rw-r--r--runtime/lua/vim/lsp/rpc.lua1
-rw-r--r--runtime/lua/vim/lsp/util.lua10
-rw-r--r--runtime/lua/vim/shared.lua18
-rw-r--r--runtime/lua/vim/treesitter.lua39
-rw-r--r--runtime/lua/vim/treesitter/highlighter.lua28
-rw-r--r--runtime/lua/vim/treesitter/query.lua51
37 files changed, 866 insertions, 917 deletions
diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim
index 0482cb7f3c..e8e38f581f 100644
--- a/runtime/autoload/health/provider.vim
+++ b/runtime/autoload/health/provider.vim
@@ -573,7 +573,7 @@ function! s:check_ruby() abort
endif
call health#report_info('Ruby: '. s:system('ruby -v'))
- let host = provider#ruby#Detect()
+ let [host, err] = provider#ruby#Detect()
if empty(host)
call health#report_warn('`neovim-ruby-host` not found.',
\ ['Run `gem install neovim` to ensure the neovim RubyGem is installed.',
@@ -636,7 +636,7 @@ function! s:check_node() abort
call health#report_warn('node.js on this system does not support --inspect-brk so $NVIM_NODE_HOST_DEBUG is ignored.')
endif
- let host = provider#node#Detect()
+ let [host, err] = provider#node#Detect()
if empty(host)
call health#report_warn('Missing "neovim" npm (or yarn) package.',
\ ['Run in shell: npm install -g neovim',
@@ -689,29 +689,31 @@ function! s:check_perl() abort
return
endif
- if !executable('perl') || !executable('cpanm')
- call health#report_warn(
- \ '`perl` and `cpanm` must be in $PATH.',
- \ ['Install Perl and cpanminus and verify that `perl` and `cpanm` commands work.'])
- return
+ let [perl_exec, perl_errors] = provider#perl#Detect()
+ if empty(perl_exec)
+ if !empty(perl_errors)
+ call health#report_error('perl provider error:', perl_errors)
+ else
+ call health#report_warn('No usable perl executable found')
+ endif
+ return
endif
- let perl_v = get(split(s:system(['perl', '-W', '-e', 'print $^V']), "\n"), 0, '')
- call health#report_info('Perl: '. perl_v)
+
+ call health#report_info('perl executable: '. perl_exec)
+
+ " we cannot use cpanm that is on the path, as it may not be for the perl
+ " set with g:perl_host_prog
+ call s:system([perl_exec, '-W', '-MApp::cpanminus', '-e', ''])
if s:shell_error
- call health#report_warn('Nvim perl host does not support '.perl_v)
- " Skip further checks, they are nonsense if perl is too old.
- return
+ return [perl_exec, '"App::cpanminus" module is not installed']
endif
- let host = provider#perl#Detect()
- if empty(host)
- call health#report_warn('Missing "Neovim::Ext" cpan module.',
- \ ['Run in shell: cpanm Neovim::Ext'])
- return
- endif
- call health#report_info('Nvim perl host: '. host)
+ let latest_cpan_cmd = [perl_exec,
+ \ '-MApp::cpanminus::fatscript', '-e',
+ \ 'my $app = App::cpanminus::script->new;
+ \ $app->parse_options ("--info", "-q", "Neovim::Ext");
+ \ exit $app->doit']
- let latest_cpan_cmd = 'cpanm --info -q Neovim::Ext'
let latest_cpan = s:system(latest_cpan_cmd)
if s:shell_error || empty(latest_cpan)
call health#report_error('Failed to run: '. latest_cpan_cmd,
@@ -735,7 +737,7 @@ function! s:check_perl() abort
return
endif
- let current_cpan_cmd = [host, '-W', '-MNeovim::Ext', '-e', 'print $Neovim::Ext::VERSION']
+ let current_cpan_cmd = [perl_exec, '-W', '-MNeovim::Ext', '-e', 'print $Neovim::Ext::VERSION']
let current_cpan = s:system(current_cpan_cmd)
if s:shell_error
call health#report_error('Failed to run: '. string(current_cpan_cmd),
diff --git a/runtime/autoload/provider/clipboard.vim b/runtime/autoload/provider/clipboard.vim
index a96a0a61b7..275d18a5a9 100644
--- a/runtime/autoload/provider/clipboard.vim
+++ b/runtime/autoload/provider/clipboard.vim
@@ -35,8 +35,7 @@ endfunction
let s:selections = { '*': s:selection, '+': copy(s:selection) }
function! s:try_cmd(cmd, ...) abort
- let argv = split(a:cmd, " ")
- let out = systemlist(argv, (a:0 ? a:1 : ['']), 1)
+ let out = systemlist(a:cmd, (a:0 ? a:1 : ['']), 1)
if v:shell_error
if !exists('s:did_error_try_cmd')
echohl WarningMsg
@@ -55,6 +54,10 @@ function! s:cmd_ok(cmd) abort
return v:shell_error == 0
endfunction
+function! s:split_cmd(cmd) abort
+ return (type(a:cmd) == v:t_string) ? split(a:cmd, " ") : a:cmd
+endfunction
+
let s:cache_enabled = 1
let s:err = ''
@@ -71,44 +74,50 @@ function! provider#clipboard#Executable() abort
return ''
endif
- let s:copy = get(g:clipboard, 'copy', { '+': v:null, '*': v:null })
- let s:paste = get(g:clipboard, 'paste', { '+': v:null, '*': v:null })
+ let s:copy = {}
+ let s:copy['+'] = s:split_cmd(get(g:clipboard.copy, '+', v:null))
+ let s:copy['*'] = s:split_cmd(get(g:clipboard.copy, '*', v:null))
+
+ let s:paste = {}
+ let s:paste['+'] = s:split_cmd(get(g:clipboard.paste, '+', v:null))
+ let s:paste['*'] = s:split_cmd(get(g:clipboard.paste, '*', v:null))
+
let s:cache_enabled = get(g:clipboard, 'cache_enabled', 0)
return get(g:clipboard, 'name', 'g:clipboard')
elseif has('mac')
- let s:copy['+'] = 'pbcopy'
- let s:paste['+'] = 'pbpaste'
+ let s:copy['+'] = ['pbcopy']
+ let s:paste['+'] = ['pbpaste']
let s:copy['*'] = s:copy['+']
let s:paste['*'] = s:paste['+']
let s:cache_enabled = 0
return 'pbcopy'
elseif exists('$WAYLAND_DISPLAY') && executable('wl-copy') && executable('wl-paste')
- let s:copy['+'] = 'wl-copy --foreground --type text/plain'
- let s:paste['+'] = 'wl-paste --no-newline'
- let s:copy['*'] = 'wl-copy --foreground --primary --type text/plain'
- let s:paste['*'] = 'wl-paste --no-newline --primary'
+ let s:copy['+'] = ['wl-copy', '--foreground', '--type', 'text/plain']
+ let s:paste['+'] = ['wl-paste', '--no-newline']
+ let s:copy['*'] = ['wl-copy', '--foreground', '--primary', '--type', 'text/plain']
+ let s:paste['*'] = ['wl-paste', '--no-newline', '--primary']
return 'wl-copy'
elseif exists('$DISPLAY') && executable('xclip')
- let s:copy['+'] = 'xclip -quiet -i -selection clipboard'
- let s:paste['+'] = 'xclip -o -selection clipboard'
- let s:copy['*'] = 'xclip -quiet -i -selection primary'
- let s:paste['*'] = 'xclip -o -selection primary'
+ let s:copy['+'] = ['xclip', '-quiet', '-i', '-selection', 'clipboard']
+ let s:paste['+'] = ['xclip', '-o', '-selection', 'clipboard']
+ let s:copy['*'] = ['xclip', '-quiet', '-i', '-selection', 'primary']
+ let s:paste['*'] = ['xclip', '-o', '-selection', 'primary']
return 'xclip'
elseif exists('$DISPLAY') && executable('xsel') && s:cmd_ok('xsel -o -b')
- let s:copy['+'] = 'xsel --nodetach -i -b'
- let s:paste['+'] = 'xsel -o -b'
- let s:copy['*'] = 'xsel --nodetach -i -p'
- let s:paste['*'] = 'xsel -o -p'
+ let s:copy['+'] = ['xsel', '--nodetach', '-i', '-b']
+ let s:paste['+'] = ['xsel', '-o', '-b']
+ let s:copy['*'] = ['xsel', '--nodetach', '-i', '-p']
+ let s:paste['*'] = ['xsel', '-o', '-p']
return 'xsel'
elseif executable('lemonade')
- let s:copy['+'] = 'lemonade copy'
- let s:paste['+'] = 'lemonade paste'
- let s:copy['*'] = 'lemonade copy'
- let s:paste['*'] = 'lemonade paste'
+ let s:copy['+'] = ['lemonade', 'copy']
+ let s:paste['+'] = ['lemonade', 'paste']
+ let s:copy['*'] = ['lemonade', 'copy']
+ let s:paste['*'] = ['lemonade', 'paste']
return 'lemonade'
elseif executable('doitclient')
- let s:copy['+'] = 'doitclient wclip'
- let s:paste['+'] = 'doitclient wclip -r'
+ let s:copy['+'] = ['doitclient', 'wclip']
+ let s:paste['+'] = ['doitclient', 'wclip', '-r']
let s:copy['*'] = s:copy['+']
let s:paste['*'] = s:paste['+']
return 'doitclient'
@@ -118,14 +127,14 @@ function! provider#clipboard#Executable() abort
else
let win32yank = 'win32yank.exe'
endif
- let s:copy['+'] = win32yank.' -i --crlf'
- let s:paste['+'] = win32yank.' -o --lf'
+ let s:copy['+'] = [win32yank, '-i', '--crlf']
+ let s:paste['+'] = [win32yank, '-o', '--lf']
let s:copy['*'] = s:copy['+']
let s:paste['*'] = s:paste['+']
return 'win32yank'
elseif exists('$TMUX') && executable('tmux')
- let s:copy['+'] = 'tmux load-buffer -'
- let s:paste['+'] = 'tmux save-buffer -'
+ let s:copy['+'] = ['tmux', 'load-buffer', '-']
+ let s:paste['+'] = ['tmux', 'save-buffer', '-']
let s:copy['*'] = s:copy['+']
let s:paste['*'] = s:paste['+']
return 'tmux'
@@ -169,16 +178,15 @@ function! s:clipboard.set(lines, regtype, reg) abort
let s:selections[a:reg] = copy(s:selection)
let selection = s:selections[a:reg]
let selection.data = [a:lines, a:regtype]
- let argv = split(s:copy[a:reg], " ")
- let selection.argv = argv
+ let selection.argv = s:copy[a:reg]
let selection.detach = s:cache_enabled
let selection.cwd = "/"
- let jobid = jobstart(argv, selection)
+ let jobid = jobstart(selection.argv, selection)
if jobid > 0
call jobsend(jobid, a:lines)
call jobclose(jobid, 'stdin')
" xclip does not close stdout when receiving input via stdin
- if argv[0] ==# 'xclip'
+ if selection.argv[0] ==# 'xclip'
call jobclose(jobid, 'stdout')
endif
let selection.owner = jobid
diff --git a/runtime/autoload/provider/node.vim b/runtime/autoload/provider/node.vim
index c5d5e87729..17b6137816 100644
--- a/runtime/autoload/provider/node.vim
+++ b/runtime/autoload/provider/node.vim
@@ -48,14 +48,15 @@ function! provider#node#can_inspect() abort
endfunction
function! provider#node#Detect() abort
+ let minver = [6, 0]
if exists('g:node_host_prog')
- return expand(g:node_host_prog)
+ return [expand(g:node_host_prog), '']
endif
if !executable('node')
- return ''
+ return ['', 'node not found (or not executable)']
endif
- if !s:is_minimum_version(v:null, 6, 0)
- return ''
+ if !s:is_minimum_version(v:null, minver[0], minver[1])
+ return ['', printf('node version %s.%s not found', minver[0], minver[1])]
endif
let npm_opts = {}
@@ -75,7 +76,7 @@ function! provider#node#Detect() abort
if has('unix')
let yarn_default_path = $HOME . '/.config/yarn/global/' . yarn_opts.entry_point
if filereadable(yarn_default_path)
- return yarn_default_path
+ return [yarn_default_path, '']
endif
endif
let yarn_opts.job_id = jobstart('yarn global dir', yarn_opts)
@@ -85,18 +86,18 @@ function! provider#node#Detect() abort
if !empty(npm_opts)
let result = jobwait([npm_opts.job_id])
if result[0] == 0 && npm_opts.result != ''
- return npm_opts.result
+ return [npm_opts.result, '']
endif
endif
if !empty(yarn_opts)
let result = jobwait([yarn_opts.job_id])
if result[0] == 0 && yarn_opts.result != ''
- return yarn_opts.result
+ return [yarn_opts.result, '']
endif
endif
- return ''
+ return ['', 'failed to detect node']
endfunction
function! provider#node#Prog() abort
@@ -142,7 +143,7 @@ endfunction
let s:err = ''
-let s:prog = provider#node#Detect()
+let [s:prog, s:_] = provider#node#Detect()
let g:loaded_node_provider = empty(s:prog) ? 1 : 2
if g:loaded_node_provider != 2
diff --git a/runtime/autoload/provider/perl.vim b/runtime/autoload/provider/perl.vim
index 36ca2bbf14..24f2b018bb 100644
--- a/runtime/autoload/provider/perl.vim
+++ b/runtime/autoload/provider/perl.vim
@@ -5,15 +5,25 @@ endif
let s:loaded_perl_provider = 1
function! provider#perl#Detect() abort
- " use g:perl_host_prof if set or check if perl is on the path
+ " use g:perl_host_prog if set or check if perl is on the path
let prog = exepath(get(g:, 'perl_host_prog', 'perl'))
if empty(prog)
- return ''
+ return ['', '']
+ endif
+
+ " if perl is available, make sure we have 5.22+
+ call system([prog, '-e', 'use v5.22'])
+ if v:shell_error
+ return ['', 'Perl version is too old, 5.22+ required']
endif
" if perl is available, make sure the required module is available
call system([prog, '-W', '-MNeovim::Ext', '-e', ''])
- return v:shell_error ? '' : prog
+ if v:shell_error
+ return ['', '"Neovim::Ext" cpan module is not installed']
+ endif
+
+ return [prog, '']
endfunction
function! provider#perl#Prog() abort
@@ -46,7 +56,7 @@ function! provider#perl#Call(method, args) abort
if !exists('s:host')
try
- let s:host = remote#host#Require('perl')
+ let s:host = remote#host#Require('legacy-perl-provider')
catch
let s:err = v:exception
echohl WarningMsg
@@ -58,12 +68,16 @@ function! provider#perl#Call(method, args) abort
return call('rpcrequest', insert(insert(a:args, 'perl_'.a:method), s:host))
endfunction
-let s:err = ''
-let s:prog = provider#perl#Detect()
+let [s:prog, s:err] = provider#perl#Detect()
let g:loaded_perl_provider = empty(s:prog) ? 1 : 2
if g:loaded_perl_provider != 2
let s:err = 'Cannot find perl or the required perl module'
endif
-call remote#host#RegisterPlugin('perl-provider', 'perl', [])
+
+" The perl provider plugin will run in a separate instance of the perl
+" host.
+call remote#host#RegisterClone('legacy-perl-provider', 'perl')
+call remote#host#RegisterPlugin('legacy-perl-provider', 'ScriptHost.pm', [])
+
diff --git a/runtime/autoload/provider/ruby.vim b/runtime/autoload/provider/ruby.vim
index f843050df9..1f49c623ac 100644
--- a/runtime/autoload/provider/ruby.vim
+++ b/runtime/autoload/provider/ruby.vim
@@ -5,7 +5,8 @@ endif
let g:loaded_ruby_provider = 1
function! provider#ruby#Detect() abort
- return s:prog
+ let e = empty(s:prog) ? 'missing ruby or ruby-host' : ''
+ return [s:prog, e]
endfunction
function! provider#ruby#Prog() abort
diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt
index 7ac7f7d7ea..b80ca9edd7 100644
--- a/runtime/doc/api.txt
+++ b/runtime/doc/api.txt
@@ -70,7 +70,7 @@ Nvim instance:
nvim = MessagePack::RPC::Client.new(MessagePack::RPC::UNIXTransport.new, ENV['NVIM_LISTEN_ADDRESS'])
result = nvim.call(:nvim_command, 'echo "hello world!"')
<
-A better way is to use the Python REPL with the `neovim` package, where API
+A better way is to use the Python REPL with the "pynvim" package, where API
functions can be called interactively:
>
>>> from pynvim import attach
@@ -336,7 +336,7 @@ callbacks. These callbacks are called frequently in various contexts;
|textlock| prevents changing buffer contents and window layout (use
|vim.schedule| to defer such operations to the main loop instead).
-|nvim_buf_attach| will take keyword args for the callbacks. "on_lines" will
+|nvim_buf_attach()| will take keyword args for the callbacks. "on_lines" will
receive parameters ("lines", {buf}, {changedtick}, {firstline}, {lastline},
{new_lastline}, {old_byte_size}[, {old_utf32_size}, {old_utf16_size}]).
Unlike remote channel events the text contents are not passed. The new text can
@@ -355,7 +355,7 @@ was changed. The parameters recieved are ("changedtick", {buf}, {changedtick}).
*api-lua-detach*
In-process Lua callbacks can detach by returning `true`. This will detach all
-callbacks attached with the same |nvim_buf_attach| call.
+callbacks attached with the same |nvim_buf_attach()| call.
==============================================================================
@@ -537,6 +537,12 @@ nvim__put_attr({id}, {start_row}, {start_col}, {end_row}, {end_col})
should probably be derived from a reformed bufhl/virttext
interface with full support for multi-line ranges etc
+nvim__screenshot({path}) *nvim__screenshot()*
+ TODO: Documentation
+
+ Attributes: ~
+ {fast}
+
nvim__stats() *nvim__stats()*
Gets internal stats.
@@ -1565,12 +1571,6 @@ affected.
You can use |nvim_buf_is_loaded()| or |nvim_buf_line_count()|
to check whether a buffer is loaded.
- *nvim__buf_add_decoration()*
-nvim__buf_add_decoration({buffer}, {ns_id}, {hl_group}, {start_row},
- {start_col}, {end_row}, {end_col},
- {virt_text})
- TODO: Documentation
-
*nvim__buf_redraw_range()*
nvim__buf_redraw_range({buffer}, {first}, {last})
TODO: Documentation
@@ -1603,19 +1603,20 @@ nvim_buf_add_highlight({buffer}, {src_id}, {hl_group}, {line},
marks do.
Namespaces are used for batch deletion/updating of a set of
- highlights. To create a namespace, use |nvim_create_namespace|
- which returns a namespace id. Pass it in to this function as
- `ns_id` to add highlights to the namespace. All highlights in
- the same namespace can then be cleared with single call to
- |nvim_buf_clear_namespace|. If the highlight never will be
- deleted by an API call, pass `ns_id = -1` .
+ highlights. To create a namespace, use
+ |nvim_create_namespace()| which returns a namespace id. Pass
+ it in to this function as `ns_id` to add highlights to the
+ namespace. All highlights in the same namespace can then be
+ cleared with single call to |nvim_buf_clear_namespace()|. If
+ the highlight never will be deleted by an API call, pass
+ `ns_id = -1` .
As a shorthand, `ns_id = 0` can be used to create a new
namespace for the highlight, the allocated id is then
returned. If `hl_group` is the empty string no highlight is
added, but a new `ns_id` is still returned. This is supported
for backwards compatibility, new code should use
- |nvim_create_namespace| to create a new empty namespace.
+ |nvim_create_namespace()| to create a new empty namespace.
Parameters: ~
{buffer} Buffer handle, or 0 for current buffer
@@ -1766,13 +1767,16 @@ nvim_buf_get_commands({buffer}, {opts}) *nvim_buf_get_commands()*
Map of maps describing commands.
*nvim_buf_get_extmark_by_id()*
-nvim_buf_get_extmark_by_id({buffer}, {ns_id}, {id})
+nvim_buf_get_extmark_by_id({buffer}, {ns_id}, {id}, {opts})
Returns position for a given extmark id
Parameters: ~
{buffer} Buffer handle, or 0 for current buffer
{ns_id} Namespace id from |nvim_create_namespace()|
{id} Extmark id
+ {opts} Optional parameters. Keys:
+ • limit: Maximum number of marks to return
+ • details Whether to include the details dict
Return: ~
(row, col) tuple or empty list () if extmark id was absent
@@ -1821,6 +1825,7 @@ nvim_buf_get_extmarks({buffer}, {ns_id}, {start}, {end}, {opts})
extmark id (whose position defines the bound)
{opts} Optional parameters. Keys:
• limit: Maximum number of marks to return
+ • details Whether to include the details dict
Return: ~
List of [extmark_id, row, col] tuples in "traversal
@@ -1919,28 +1924,6 @@ nvim_buf_get_var({buffer}, {name}) *nvim_buf_get_var()*
Return: ~
Variable value
- *nvim_buf_get_virtual_text()*
-nvim_buf_get_virtual_text({buffer}, {line})
- Get the virtual text (annotation) for a buffer line.
-
- The virtual text is returned as list of lists, whereas the
- inner lists have either one or two elements. The first element
- is the actual text, the optional second element is the
- highlight group.
-
- The format is exactly the same as given to
- nvim_buf_set_virtual_text().
-
- If there is no virtual text associated with the given line, an
- empty list is returned.
-
- Parameters: ~
- {buffer} Buffer handle, or 0 for current buffer
- {line} Line to get the virtual text from (zero-indexed)
-
- Return: ~
- List of virtual text chunks
-
nvim_buf_is_loaded({buffer}) *nvim_buf_is_loaded()*
Checks if a buffer is valid and loaded. See |api-buffer| for
more info about unloaded buffers.
@@ -1974,22 +1957,35 @@ nvim_buf_line_count({buffer}) *nvim_buf_line_count()*
Line count, or 0 for unloaded buffer. |api-buffer|
*nvim_buf_set_extmark()*
-nvim_buf_set_extmark({buffer}, {ns_id}, {id}, {line}, {col}, {opts})
+nvim_buf_set_extmark({buffer}, {ns_id}, {line}, {col}, {opts})
Creates or updates an extmark.
To create a new extmark, pass id=0. The extmark id will be
- returned. It is also allowed to create a new mark by passing
- in a previously unused id, but the caller must then keep track
- of existing and unused ids itself. (Useful over RPC, to avoid
+ returned. To move an existing mark, pass its id.
+
+ It is also allowed to create a new mark by passing in a
+ previously unused id, but the caller must then keep track of
+ existing and unused ids itself. (Useful over RPC, to avoid
waiting for the return value.)
+ Using the optional arguments, it is possible to use this to
+ highlight a range of text, and also to associate virtual text
+ to the mark.
+
Parameters: ~
{buffer} Buffer handle, or 0 for current buffer
{ns_id} Namespace id from |nvim_create_namespace()|
- {id} Extmark id, or 0 to create new
{line} Line number where to place the mark
{col} Column where to place the mark
- {opts} Optional parameters. Currently not used.
+ {opts} Optional parameters.
+ • id : id of the extmark to edit.
+ • end_line : ending line of the mark, 0-based
+ inclusive.
+ • end_col : ending col of the mark, 0-based
+ inclusive.
+ • hl_group : name of the highlight group used to
+ highlight this mark.
+ • virt_text : virtual text to link to this mark.
Return: ~
Id of the created/updated extmark
@@ -2066,12 +2062,12 @@ nvim_buf_set_virtual_text({buffer}, {src_id}, {line}, {chunks},
Namespaces are used to support batch deletion/updating of
virtual text. To create a namespace, use
- |nvim_create_namespace|. Virtual text is cleared using
- |nvim_buf_clear_namespace|. The same `ns_id` can be used for
+ |nvim_create_namespace()|. Virtual text is cleared using
+ |nvim_buf_clear_namespace()|. The same `ns_id` can be used for
both virtual text and highlights added by
- |nvim_buf_add_highlight|, both can then be cleared with a
- single call to |nvim_buf_clear_namespace|. If the virtual text
- never will be cleared by an API call, pass `ns_id = -1` .
+ |nvim_buf_add_highlight()|, both can then be cleared with a
+ single call to |nvim_buf_clear_namespace()|. If the virtual
+ text never will be cleared by an API call, pass `ns_id = -1` .
As a shorthand, `ns_id = 0` can be used to create a new
namespace for the virtual text, the allocated id is then
diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt
index f1753b75cc..a6872d0af5 100644
--- a/runtime/doc/autocmd.txt
+++ b/runtime/doc/autocmd.txt
@@ -206,169 +206,9 @@ autocommands, this doesn't happen.
You can use the 'eventignore' option to ignore a number of events or all
events.
- *autocommand-events* *{event}*
-Vim recognizes the following events. Vim ignores the case of event names
-(e.g., you can use "BUFread" or "bufread" instead of "BufRead").
-
-First an overview by function with a short explanation. Then the list
-alphabetically with full explanations |autocmd-events-abc|.
-
-Name triggered by ~
-
- Reading
-|BufNewFile| starting to edit a file that doesn't exist
-|BufReadPre| starting to edit a new buffer, before reading the file
-|BufRead| starting to edit a new buffer, after reading the file
-|BufReadPost| starting to edit a new buffer, after reading the file
-|BufReadCmd| before starting to edit a new buffer |Cmd-event|
-
-|FileReadPre| before reading a file with a ":read" command
-|FileReadPost| after reading a file with a ":read" command
-|FileReadCmd| before reading a file with a ":read" command |Cmd-event|
-
-|FilterReadPre| before reading a file from a filter command
-|FilterReadPost| after reading a file from a filter command
-
-|StdinReadPre| before reading from stdin into the buffer
-|StdinReadPost| After reading from the stdin into the buffer
-
- Writing
-|BufWrite| starting to write the whole buffer to a file
-|BufWritePre| starting to write the whole buffer to a file
-|BufWritePost| after writing the whole buffer to a file
-|BufWriteCmd| before writing the whole buffer to a file |Cmd-event|
-
-|FileWritePre| starting to write part of a buffer to a file
-|FileWritePost| after writing part of a buffer to a file
-|FileWriteCmd| before writing part of a buffer to a file |Cmd-event|
-
-|FileAppendPre| starting to append to a file
-|FileAppendPost| after appending to a file
-|FileAppendCmd| before appending to a file |Cmd-event|
-
-|FilterWritePre| starting to write a file for a filter command or diff
-|FilterWritePost| after writing a file for a filter command or diff
-
- Buffers
-|BufAdd| just after adding a buffer to the buffer list
-|BufDelete| before deleting a buffer from the buffer list
-|BufWipeout| before completely deleting a buffer
-
-|BufFilePre| before changing the name of the current buffer
-|BufFilePost| after changing the name of the current buffer
-
-|BufEnter| after entering a buffer
-|BufLeave| before leaving to another buffer
-|BufWinEnter| after a buffer is displayed in a window
-|BufWinLeave| before a buffer is removed from a window
-
-|BufUnload| before unloading a buffer
-|BufHidden| just after a buffer has become hidden
-|BufNew| just after creating a new buffer
-
-|SwapExists| detected an existing swap file
-|TermOpen| starting a terminal job
-|TermEnter| entering Terminal-mode
-|TermLeave| leaving Terminal-mode
-|TermClose| stopping a terminal job
-|ChanOpen| after a channel opened
-|ChanInfo| after a channel has its state changed
-
- Options
-|FileType| when the 'filetype' option has been set
-|Syntax| when the 'syntax' option has been set
-|OptionSet| after setting any option
-
- Startup and exit
-|VimEnter| after doing all the startup stuff
-|UIEnter| after a UI attaches
-|UILeave| after a UI detaches
-|TermResponse| after the terminal response to t_RV is received
-|QuitPre| when using `:quit`, before deciding whether to exit
-|ExitPre| when using a command that may make Vim exit
-|VimLeavePre| before exiting Nvim, before writing the shada file
-|VimLeave| before exiting Nvim, after writing the shada file
-|VimResume| after Nvim is resumed
-|VimSuspend| before Nvim is suspended
-
- Various
-|DiffUpdated| after diffs have been updated
-|DirChanged| after the |current-directory| was changed
-
-|FileChangedShell| Vim notices that a file changed since editing started
-|FileChangedShellPost| after handling a file changed since editing started
-|FileChangedRO| before making the first change to a read-only file
-
-|ShellCmdPost| after executing a shell command
-|ShellFilterPost| after filtering with a shell command
-
-|CmdUndefined| a user command is used but it isn't defined
-|FuncUndefined| a user function is used but it isn't defined
-|SpellFileMissing| a spell file is used but it can't be found
-|SourcePre| before sourcing a Vim script
-|SourcePost| after sourcing a Vim script
-|SourceCmd| before sourcing a Vim script |Cmd-event|
-
-|VimResized| after the Vim window size changed
-|FocusGained| Nvim got focus
-|FocusLost| Nvim lost focus
-|CursorHold| the user doesn't press a key for a while
-|CursorHoldI| the user doesn't press a key for a while in Insert mode
-|CursorMoved| the cursor was moved in Normal mode
-|CursorMovedI| the cursor was moved in Insert mode
-
-|WinClosed| after closing a window
-|WinNew| after creating a new window
-|WinEnter| after entering another window
-|WinLeave| before leaving a window
-|TabEnter| after entering another tab page
-|TabLeave| before leaving a tab page
-|TabNew| when creating a new tab page
-|TabNewEntered| after entering a new tab page
-|TabClosed| after closing a tab page
-|CmdlineChanged| after a change was made to the command-line text
-|CmdlineEnter| after entering cmdline mode
-|CmdlineLeave| before leaving cmdline mode
-|CmdwinEnter| after entering the command-line window
-|CmdwinLeave| before leaving the command-line window
-
-|InsertEnter| starting Insert mode
-|InsertChange| when typing <Insert> while in Insert or Replace mode
-|InsertLeave| when leaving Insert mode
-|InsertCharPre| when a character was typed in Insert mode, before
- inserting it
-
-|TextYankPost| when some text is yanked or deleted
-
-|TextChanged| after a change was made to the text in Normal mode
-|TextChangedI| after a change was made to the text in Insert mode
- when popup menu is not visible
-|TextChangedP| after a change was made to the text in Insert mode
- when popup menu visible
-
-|ColorSchemePre| before loading a color scheme
-|ColorScheme| after loading a color scheme
-
-|RemoteReply| a reply from a server Vim was received
-
-|QuickFixCmdPre| before a quickfix command is run
-|QuickFixCmdPost| after a quickfix command is run
-
-|SessionLoadPost| after loading a session file
-
-|MenuPopup| just before showing the popup menu
-|CompleteChanged| after popup menu changed, not fired on popup menu hide
-|CompleteDonePre| after Insert mode completion is done, before clearing
- info
-|CompleteDone| after Insert mode completion is done, after clearing
- info
-
-|User| to be used in combination with ":doautocmd"
-|Signal| after Nvim receives a signal
-
-
-
-The alphabetical list of autocommand events: *autocmd-events-abc*
+
+ *events* *{event}*
+Nvim recognizes the following events. Names are case-insensitive.
*BufAdd*
BufAdd Just after creating a new buffer which is
@@ -642,7 +482,7 @@ CursorHold When the user doesn't press a key for the time
Hint: to force an update of the status lines
use: >
:let &ro = &ro
-
+<
*CursorHoldI*
CursorHoldI Like CursorHold, but in Insert mode. Not
triggered when waiting for another key, e.g.
@@ -1111,13 +951,13 @@ VimEnter After doing all the startup stuff, including
if v:vim_did_enter
call s:init()
else
- au VimEnter * call s:init()
+ au VimEnter * call s:init()
endif
< *VimLeave*
VimLeave Before exiting Vim, just after writing the
.shada file. Executed only once, like
VimLeavePre.
-< Use |v:dying| to detect an abnormal exit.
+ Use |v:dying| to detect an abnormal exit.
Use |v:exiting| to get the exit code.
Not triggered if |v:dying| is 2 or more.
*VimLeavePre*
@@ -1126,7 +966,7 @@ VimLeavePre Before exiting Vim, just before writing the
if there is a match with the name of what
happens to be the current buffer when exiting.
Mostly useful with a "*" pattern. >
- :autocmd VimLeavePre * call CleanupStuff()
+ :autocmd VimLeavePre * call CleanupStuff()
< Use |v:dying| to detect an abnormal exit.
Use |v:exiting| to get the exit code.
Not triggered if |v:dying| is 2 or more.
diff --git a/runtime/doc/cmdline.txt b/runtime/doc/cmdline.txt
index b31177ce0e..163dc81804 100644
--- a/runtime/doc/cmdline.txt
+++ b/runtime/doc/cmdline.txt
@@ -556,6 +556,7 @@ followed by another Vim command:
:lfdo
:make
:normal
+ :perlfile
:promptfind
:promptrepl
:pyfile
diff --git a/runtime/doc/develop.txt b/runtime/doc/develop.txt
index 09c5b7c4ad..aec0178da2 100644
--- a/runtime/doc/develop.txt
+++ b/runtime/doc/develop.txt
@@ -103,8 +103,10 @@ Examples:
The provider framework invokes VimL from C. It is composed of two functions
in eval.c:
-- eval_call_provider(name, method, arguments): calls provider#{name}#Call
- with the method and arguments.
+- eval_call_provider(name, method, arguments, discard): calls
+ provider#{name}#Call with the method and arguments. If discard is true, any
+ value returned by the provider will be discarded and and empty value be
+ returned.
- eval_has_provider(name): Checks the `g:loaded_{name}_provider` variable
which must be set to 2 by the provider script to indicate that it is
"enabled and working". Called by |has()| to check if features are available.
diff --git a/runtime/doc/digraph.txt b/runtime/doc/digraph.txt
index 7f807b5eee..271b8c2597 100644
--- a/runtime/doc/digraph.txt
+++ b/runtime/doc/digraph.txt
@@ -913,6 +913,7 @@ char digraph hex dec official name ~
‟ 9" 201F 8223 DOUBLE HIGH-REVERSED-9 QUOTATION MARK
† /- 2020 8224 DAGGER
‡ /= 2021 8225 DOUBLE DAGGER
+• oo 2022 8226 BULLET
‥ .. 2025 8229 TWO DOT LEADER
… ,. 2026 8230 HORIZONTAL ELLIPSIS
‰ %0 2030 8240 PER MILLE SIGN
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index ca03ee0374..5127a9f390 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -2288,6 +2288,7 @@ nr2char({expr}[, {utf8}]) String single char with ASCII/UTF8 value {expr}
nvim_...({args}...) any call nvim |api| functions
or({expr}, {expr}) Number bitwise OR
pathshorten({expr}) String shorten directory names in a path
+perleval({expr}) any evaluate |perl| expression
pow({x}, {y}) Float {x} to the power of {y}
prevnonblank({lnum}) Number line nr of non-blank line <= {lnum}
printf({fmt}, {expr1}...) String format text
@@ -6423,6 +6424,21 @@ pathshorten({expr}) *pathshorten()*
< ~/.c/n/a/file1.vim ~
It doesn't matter if the path exists or not.
+perleval({expr}) *perleval()*
+ Evaluate |perl| expression {expr} and return its result
+ converted to Vim data structures.
+ Numbers and strings are returned as they are (strings are
+ copied though).
+ Lists are represented as Vim |List| type.
+ Dictionaries are represented as Vim |Dictionary| type,
+ non-string keys result in error.
+
+ Note: If you want an array or hash, {expr} must return a
+ reference to it.
+ Example: >
+ :echo perleval('[1 .. 4]')
+< [1, 2, 3, 4]
+
pow({x}, {y}) *pow()*
Return the power of {x} to the exponent {y} as a |Float|.
{x} and {y} must evaluate to a |Float| or a |Number|.
@@ -7754,26 +7770,23 @@ sha256({string}) *sha256()*
shellescape({string} [, {special}]) *shellescape()*
Escape {string} for use as a shell command argument.
- On Windows when 'shellslash' is not set, it
- will enclose {string} in double quotes and double all double
- quotes within {string}.
- Otherwise, it will enclose {string} in single quotes and
- replace all "'" with "'\''".
-
- When the {special} argument is present and it's a non-zero
- Number or a non-empty String (|non-zero-arg|), then special
- items such as "!", "%", "#" and "<cword>" will be preceded by
- a backslash. This backslash will be removed again by the |:!|
- command.
- The "!" character will be escaped (again with a |non-zero-arg|
- {special}) when 'shell' contains "csh" in the tail. That is
- because for csh and tcsh "!" is used for history replacement
- even when inside single quotes.
+ On Windows when 'shellslash' is not set, encloses {string} in
+ double-quotes and doubles all double-quotes within {string}.
+ Otherwise encloses {string} in single-quotes and replaces all
+ "'" with "'\''".
+
+ If {special} is a ||non-zero-arg|:
+ - Special items such as "!", "%", "#" and "<cword>" will be
+ preceded by a backslash. The backslash will be removed again
+ by the |:!| command.
+ - The <NL> character is escaped.
- With a |non-zero-arg| {special} the <NL> character is also
- escaped. When 'shell' containing "csh" in the tail it's
- escaped a second time.
+ If 'shell' contains "csh" in the tail:
+ - The "!" character will be escaped. This is because csh and
+ tcsh use "!" for history replacement even in single-quotes.
+ - The <NL> character is escaped (twice if {special} is
+ a ||non-zero-arg|).
Example of use with a |:!| command: >
:exe '!dir ' . shellescape(expand('<cfile>'), 1)
@@ -8246,15 +8259,13 @@ sqrt({expr}) *sqrt()*
stdioopen({opts}) *stdioopen()*
- In a nvim launched with the |--headless| option, this opens
- stdin and stdout as a |channel|. This function can only be
- invoked once per instance. See |channel-stdio| for more
- information and examples. Note that stderr is not handled by
- this function, see |v:stderr|.
+ With |--headless| this opens stdin and stdout as a |channel|.
+ May be called only once. See |channel-stdio|. stderr is not
+ handled by this function, see |v:stderr|.
- Returns a |channel| ID. Close the stdio descriptors with |chanclose()|.
- Use |chansend()| to send data to stdout, and
- |rpcrequest()| and |rpcnotify()| to communicate over RPC.
+ Close the stdio handles with |chanclose()|. Use |chansend()|
+ to send data to stdout, and |rpcrequest()| and |rpcnotify()|
+ to communicate over RPC.
{opts} is a dictionary with these keys:
|on_stdin| : callback invoked when stdin is written to.
@@ -8262,7 +8273,7 @@ stdioopen({opts}) *stdioopen()*
rpc : If set, |msgpack-rpc| will be used to communicate
over stdio
Returns:
- - The channel ID on success (this is always 1)
+ - |channel-id| on success (value is always 1)
- 0 on invalid arguments
diff --git a/runtime/doc/help.txt b/runtime/doc/help.txt
index a384b5f876..203699435b 100644
--- a/runtime/doc/help.txt
+++ b/runtime/doc/help.txt
@@ -137,7 +137,7 @@ Special issues ~
Programming language support ~
|indent.txt| automatic indenting for C and other languages
-|lsp.txt| Language Server Protocol (LSP)
+|lsp.txt| Language Server Protocol (LSP)
|syntax.txt| syntax highlighting
|filetype.txt| settings done specifically for a type of file
|quickfix.txt| commands for a quick edit-compile-fix cycle
@@ -168,9 +168,9 @@ Versions ~
|vi_diff.txt| Main differences between Vim and Vi
*standard-plugin-list*
Standard plugins ~
+|matchit.txt| Extended |%| matching
|pi_gzip.txt| Reading and writing compressed files
|pi_health.txt| Healthcheck framework
-|pi_matchit.txt| Extended |%| matching
|pi_msgpack.txt| msgpack utilities
|pi_netrw.txt| Reading and writing files over a network
|pi_paren.txt| Highlight matching parens
diff --git a/runtime/doc/if_perl.txt b/runtime/doc/if_perl.txt
new file mode 100644
index 0000000000..f1d07ddb20
--- /dev/null
+++ b/runtime/doc/if_perl.txt
@@ -0,0 +1,268 @@
+*if_perl.txt* Nvim
+
+
+ VIM REFERENCE MANUAL by Jacques Germishuys
+
+The perl Interface to Vim *if_perl* *perl*
+
+See |provider-perl| for more information.
+
+ Type |gO| to see the table of contents.
+
+==============================================================================
+1. Commands *perl-commands*
+
+ *:perl*
+:[range]perl {stmt}
+ Execute perl statement {stmt}. The current package is
+ "main". A simple check if the `:perl` command is
+ working: >
+ :perl print "Hello"
+
+:[range]perl << [endmarker]
+{script}
+{endmarker}
+ Execute perl script {script}. Useful for including
+ perl code in Vim scripts. Requires perl, see
+ |script-here|.
+
+The {endmarker} below the {script} must NOT be preceded by any white space.
+
+If [endmarker] is omitted from after the "<<", a dot '.' must be used after
+{script}, like for the |:append| and |:insert| commands.
+
+Example: >
+ function! MyVimMethod()
+ perl << EOF
+ sub my_vim_method
+ {
+ print "Hello World!\n";
+ }
+ EOF
+ endfunction
+
+To see what version of perl you have: >
+
+ :perl print $^V
+<
+ *:perldo*
+:[range]perldo {cmd} Execute perl command {cmd} for each line in the[range],
+ with $_ being set to the test of each line in turn,
+ without a trailing <EOL>. In addition to $_, $line and
+ $linenr is also set to the line content and line number
+ respectively. Setting $_ will change the text, but note
+ that it is not possible to add or delete lines using
+ this command.
+ The default for [range] is the whole file: "1,$".
+
+Examples:
+>
+ :perldo $_ = reverse($_);
+ :perldo $_ = "".$linenr." => $line";
+
+One can use `:perldo` in conjunction with `:perl` to filter a range using
+perl. For example: >
+
+ :perl << EOF
+ sub perl_vim_string_replace
+ {
+ my $line = shift;
+ my $needle = $vim->eval('@a');
+ my $replacement = $vim->eval('@b');
+ $line =~ s/$needle/$replacement/g;
+ return $line;
+ }
+ EOF
+ :let @a='somevalue'
+ :let @b='newvalue'
+ :'<,'>perldo $_ = perl_vim_string_replace($_)
+<
+ *:perlfile*
+:[range]perlfile {file}
+ Execute the perl script in {file}. The whole
+ argument is used as a single file name.
+
+Both of these commands do essentially the same thing - they execute a piece of
+perl code, with the "current range" set to the given line range.
+
+In the case of :perl, the code to execute is in the command-line.
+In the case of :perlfile, the code to execute is the contents of the given file.
+
+perl commands cannot be used in the |sandbox|.
+
+To pass arguments you need to set @ARGV explicitly. Example: >
+
+ :perl @ARGV = ("foo", "bar");
+ :perlfile myscript.pl
+
+Here are some examples *perl-examples* >
+
+ :perl print "Hello"
+ :perl $current->line (uc ($current->line))
+ :perl my $str = $current->buffer->[42]; print "Set \$str to: $str"
+
+Note that changes (such as the "use" statements) persist from one command
+to the next.
+
+==============================================================================
+2. The VIM module *perl-vim*
+
+Perl code gets all of its access to Neovim via the "VIM" module.
+
+Overview >
+ print "Hello" # displays a message
+ VIM::Msg("Hello") # displays a message
+ VIM::SetOption("ai") # sets a vim option
+ $nbuf = VIM::Buffers() # returns the number of buffers
+ @buflist = VIM::Buffers() # returns array of all buffers
+ $mybuf = (VIM::Buffers('a.c'))[0] # returns buffer object for 'a.c'
+ @winlist = VIM::Windows() # returns array of all windows
+ $nwin = VIM::Windows() # returns the number of windows
+ ($success, $v) = VIM::Eval('&path') # $v: option 'path', $success: 1
+ ($success, $v) = VIM::Eval('&xyz') # $v: '' and $success: 0
+ $v = VIM::Eval('expand("<cfile>")') # expands <cfile>
+ $curwin->SetHeight(10) # sets the window height
+ @pos = $curwin->Cursor() # returns (row, col) array
+ @pos = (10, 10)
+ $curwin->Cursor(@pos) # sets cursor to @pos
+ $curwin->Cursor(10,10) # sets cursor to row 10 col 10
+ $mybuf = $curwin->Buffer() # returns the buffer object for window
+ $curbuf->Name() # returns buffer name
+ $curbuf->Number() # returns buffer number
+ $curbuf->Count() # returns the number of lines
+ $l = $curbuf->Get(10) # returns line 10
+ @l = $curbuf->Get(1 .. 5) # returns lines 1 through 5
+ $curbuf->Delete(10) # deletes line 10
+ $curbuf->Delete(10, 20) # delete lines 10 through 20
+ $curbuf->Append(10, "Line") # appends a line
+ $curbuf->Append(10, "L1", "L2", "L3") # appends 3 lines
+ @l = ("L1", "L2", "L3")
+ $curbuf->Append(10, @l) # appends L1, L2 and L3
+ $curbuf->Set(10, "Line") # replaces line 10
+ $curbuf->Set(10, "Line1", "Line2") # replaces lines 10 and 11
+ $curbuf->Set(10, @l) # replaces 3 lines
+
+Module Functions:
+
+ *perl-Msg*
+VIM::Msg({msg})
+ Displays the message {msg}.
+
+ *perl-SetOption*
+VIM::SetOption({arg}) Sets a vim option. {arg} can be any argument that the
+ ":set" command accepts. Note that this means that no
+ spaces are allowed in the argument! See |:set|.
+
+ *perl-Buffers*
+VIM::Buffers([{bn}...]) With no arguments, returns a list of all the buffers
+ in an array context or returns the number of buffers
+ in a scalar context. For a list of buffer names or
+ numbers {bn}, returns a list of the buffers matching
+ {bn}, using the same rules as Vim's internal
+ |bufname()| function.
+ WARNING: the list becomes invalid when |:bwipe| is
+ used.
+
+ *perl-Windows*
+VIM::Windows([{wn}...]) With no arguments, returns a list of all the windows
+ in an array context or returns the number of windows
+ in a scalar context. For a list of window numbers
+ {wn}, returns a list of the windows with those
+ numbers.
+ WARNING: the list becomes invalid when a window is
+ closed.
+
+ *perl-DoCommand*
+VIM::DoCommand({cmd}) Executes Ex command {cmd}.
+
+ *perl-Eval*
+VIM::Eval({expr}) Evaluates {expr} and returns (success, value) in list
+ context or just value in scalar context.
+ success=1 indicates that val contains the value of
+ {expr}; success=0 indicates a failure to evaluate
+ the expression. '@x' returns the contents of register
+ x, '&x' returns the value of option x, 'x' returns the
+ value of internal |variables| x, and '$x' is equivalent
+ to perl's $ENV{x}. All |functions| accessible from
+ the command-line are valid for {expr}.
+ A |List| is turned into a string by joining the items
+ and inserting line breaks.
+
+==============================================================================
+3. VIM::Buffer objects *perl-buffer*
+
+Methods:
+
+ *perl-Buffer-Name*
+Name() Returns the filename for the Buffer.
+
+ *perl-Buffer-Number*
+Number() Returns the number of the Buffer.
+
+ *perl-Buffer-Count*
+Count() Returns the number of lines in the Buffer.
+
+ *perl-Buffer-Get*
+Get({lnum}, {lnum}?, ...)
+ Returns a text string of line {lnum} in the Buffer
+ for each {lnum} specified. An array can be passed
+ with a list of {lnum}'s specified.
+
+ *perl-Buffer-Delete*
+Delete({lnum}, {lnum}?)
+ Deletes line {lnum} in the Buffer. With the second
+ {lnum}, deletes the range of lines from the first
+ {lnum} to the second {lnum}.
+
+ *perl-Buffer-Append*
+Append({lnum}, {line}, {line}?, ...)
+ Appends each {line} string after Buffer line {lnum}.
+ The list of {line}s can be an array.
+
+ *perl-Buffer-Set*
+Set({lnum}, {line}, {line}?, ...)
+ Replaces one or more Buffer lines with specified
+ {lines}s, starting at Buffer line {lnum}. The list of
+ {line}s can be an array. If the arguments are
+ invalid, replacement does not occur.
+
+==============================================================================
+4. VIM::Window objects *perl-window*
+
+Methods:
+ *perl-Window-SetHeight*
+SetHeight({height})
+ Sets the Window height to {height}, within screen
+ limits.
+
+ *perl-Window-GetCursor*
+Cursor({row}?, {col}?)
+ With no arguments, returns a (row, col) array for the
+ current cursor position in the Window. With {row} and
+ {col} arguments, sets the Window's cursor position to
+ {row} and {col}. Note that {col} is numbered from 0,
+ Perl-fashion, and thus is one less than the value in
+ Vim's ruler.
+
+Buffer() *perl-Window-Buffer*
+ Returns the Buffer object corresponding to the given
+ Window.
+
+==============================================================================
+5. Lexical variables *perl-globals*
+
+There are multiple lexical variables.
+
+$curwin The current Window object.
+$curbuf The current Buffer object.
+$vim A Neovim::Ext object.
+$nvim The same as $nvim.
+$current A Neovim::Ext::Current object.
+
+These are also available via the "main" package:
+
+$main::curwin The current Window object.
+$main::curbuf The current Buffer object.
+
+==============================================================================
+ vim:tw=78:ts=8:noet:ft=help:norl:
diff --git a/runtime/doc/index.txt b/runtime/doc/index.txt
index bdab10c0e4..afcacad460 100644
--- a/runtime/doc/index.txt
+++ b/runtime/doc/index.txt
@@ -1441,6 +1441,9 @@ tag command action ~
|:packloadall| :packl[oadall] load all packages under 'packpath'
|:pclose| :pc[lose] close preview window
|:pedit| :ped[it] edit file in the preview window
+|:perl| :perl execute perl command
+|:perldo| :perldo execute perl command for each line
+|:perfile| :perlfile execute perl script file
|:print| :p[rint] print lines
|:profdel| :profd[el] stop profiling a function or script
|:profile| :prof[ile] profiling functions and scripts
diff --git a/runtime/doc/intro.txt b/runtime/doc/intro.txt
index 3c3753df78..59b1f44e39 100644
--- a/runtime/doc/intro.txt
+++ b/runtime/doc/intro.txt
@@ -4,21 +4,15 @@
NVIM REFERENCE MANUAL
-Introduction to Vim *ref* *reference*
+Nvim *ref* *reference*
Type |gO| to see the table of contents.
==============================================================================
Introduction *intro*
-Vim stands for Vi IMproved. It used to be Vi IMitation, but there are so many
-improvements that a name change was appropriate. Vim is a text editor which
-includes almost all the commands from the Unix program "Vi" and a lot of new
-ones. It is very useful for editing programs and other plain text.
- All commands are given with the keyboard. This has the advantage that you
-can keep your fingers on the keyboard and your eyes on the screen. For those
-who want it, there is mouse support and a GUI version with scrollbars and
-menus (see |gui.txt|).
+Vim is a text editor which includes most commands from the Unix program "Vi"
+and many new ones.
An overview of this manual can be found in the file "help.txt", |help.txt|.
It can be accessed from within Vim with the <Help> or <F1> key and with the
@@ -28,16 +22,15 @@ is not located in the default place. You can jump to subjects like with tags:
Use CTRL-] to jump to a subject under the cursor, use CTRL-T to jump back.
*pronounce*
-Vim is pronounced as one word, like Jim. Nvim is pronounced as N-vim, or,
-continuing with the Jim simile, N-Jim, which sounds like Ninja.
+Vim is pronounced as one word, like Jim. So Nvim is N-Jim, which sounds like
+"Ninja". Starting Nvim is like performing a roundhouse kick.
-This manual is a reference for all the Vim commands and options. This is not
-an introduction to the use of Vi or Vim, it gets a bit complicated here and
-there. For beginners, there is a hands-on |tutor|. To learn using Vim, read
-the user manual |usr_toc.txt|.
+This manual is a reference for all Nvim editor and API features. It is not an
+introduction; instead for beginners, there is a hands-on |tutor| and a user
+manual |usr_toc.txt|.
*book*
-There are many books on Vi and Vim. We recommend these books:
+There are many books on Vi and Vim. We recommend:
"Practical Vim" by Drew Neil
"Modern Vim" by Drew Neil
@@ -48,7 +41,7 @@ tasks with Vim. "Modern Vim" explores new features in Nvim and Vim 8.
"Vim - Vi Improved" by Steve Oualline
-This is the first book dedicated to Vim. Parts of it were included in the
+This was the first book dedicated to Vim. Parts of it were included in the
user manual. |frombook| ISBN: 0735710015
For more information try one of these:
https://iccf-holland.org/click5.html
@@ -63,11 +56,9 @@ Nvim on the interwebs *internet*
Nvim FAQ: https://github.com/neovim/neovim/wiki/FAQ
Downloads: https://github.com/neovim/neovim/releases
Vim FAQ: https://vimhelp.appspot.com/vim_faq.txt.html
- Vim home page: https://www.vim.org/
- *bugs* *bug-report* *bugreport.vim* *feature-request*
-
+ *bugs* *bug-report*
Report bugs and request features here:
https://github.com/neovim/neovim/issues
@@ -97,7 +88,7 @@ Neovim development is funded separately from Vim:
https://neovim.io/#sponsor
==============================================================================
-Credits *credits* *author* *Bram* *Moolenaar*
+Credits *credits*
Most of Vim was written by Bram Moolenaar <Bram@vim.org>.
@@ -185,25 +176,21 @@ the ideas from all these people: They keep Vim alive!
*love* *peace* *friendship* *gross-national-happiness*
-In this documentation there are several references to other versions of Vi:
+Documentation may refer to other versions of Vi:
*Vi* *vi*
Vi "the original". Without further remarks this is the version
of Vi that appeared in Sun OS 4.x. ":version" returns
- "Version 3.7, 6/7/85". Sometimes other versions are referred
- to. Only runs under Unix. Source code only available with a
- license.
+ "Version 3.7, 6/7/85". Source code only available with a license.
*Nvi*
Nvi The "New" Vi. The version of Vi that comes with BSD 4.4 and FreeBSD.
Very good compatibility with the original Vi, with a few extensions.
The version used is 1.79. ":version" returns "Version 1.79
- (10/23/96)". There has been no release the last few years, although
- there is a development version 1.81.
- Source code is freely available.
+ (10/23/96)". Source code is freely available.
*Elvis*
Elvis Another Vi clone, made by Steve Kirkendall. Very compact but isn't
- as flexible as Vim.
- The version used is 2.1. It is still being developed. Source code is
- freely available.
+ as flexible as Vim. Source code is freely available.
+
+Vim Nvim is based on Vim. https://www.vim.org/
==============================================================================
Notation *notation*
@@ -387,37 +374,24 @@ notation meaning equivalent decimal value(s) ~
<D-…> command-key or "super" key *<D-*
-----------------------------------------------------------------------
-Note: The shifted cursor keys, the help key, and the undo key are only
-available on a few terminals.
-
-Note: There are two codes for the delete key. 127 is the decimal ASCII value
-for the delete key, which is always recognized. Some delete keys send another
-value, in which case this value is obtained from the |terminfo| entry "key_dc".
-Both values have the same effect.
+Note:
-Note: The keypad keys are used in the same way as the corresponding "normal"
-keys. For example, <kHome> has the same effect as <Home>. If a keypad key
-sends the same raw key code as its non-keypad equivalent, it will be
-recognized as the non-keypad code. For example, when <kHome> sends the same
-code as <Home>, when pressing <kHome> Vim will think <Home> was pressed.
-Mapping <kHome> will not work then.
-
-Note: If numlock is on, the |TUI| receives plain ASCII values, so
-mappings to <k0> - <k9> and <kPoint> will not work.
-
-Note: Nvim supports mapping multibyte chars with modifiers such as `<M-ä>`.
-Which combinations actually are usable depends on the terminal emulator or GUI.
+- Availability of some keys (<Help>, <S-Right>, …) depends on the UI or host
+ terminal.
+- If numlock is on the |TUI| receives plain ASCII values, so mapping <k0>,
+ <k1>, ..., <k9> and <kPoint> will not work.
+- Nvim supports mapping multibyte chars with modifiers such as `<M-ä>`. Which
+ combinations actually work depends on the the UI or host terminal.
*<>*
Examples are often given in the <> notation. Sometimes this is just to make
clear what you need to type, but often it can be typed literally, e.g., with
the ":map" command. The rules are:
- 1. Any printable characters are typed directly, except backslash and '<'
- 2. A backslash is represented with "\\", double backslash, or "<Bslash>".
- 3. A real '<' is represented with "\<" or "<lt>". When there is no
- confusion possible, a '<' can be used directly.
- 4. "<key>" means the special key typed. This is the notation explained in
- the table above. A few examples:
+ 1. Printable characters are typed directly, except backslash and "<"
+ 2. Backslash is represented with "\\", double backslash, or "<Bslash>".
+ 3. Literal "<" is represented with "\<" or "<lt>". When there is no
+ confusion possible, "<" can be used directly.
+ 4. "<key>" means the special key typed (see the table above). Examples:
<Esc> Escape key
<C-G> CTRL-G
<Up> cursor up key
@@ -437,11 +411,6 @@ one always works.
To get a literal "<lt>" in a mapping: >
:map <C-L> <lt>lt>
-For mapping, abbreviation and menu commands you can then copy-paste the
-examples and use them directly. Or type them literally, including the '<' and
-'>' characters. This does NOT work for other commands, like ":set" and
-":autocmd"!
-
==============================================================================
Modes, introduction *vim-modes-intro* *vim-modes*
@@ -599,7 +568,7 @@ Q or gQ Switch to Ex mode. This is like typing ":" commands
Use the ":vi" command |:visual| to exit this mode.
==============================================================================
-The window contents *window-contents*
+Window contents *window-contents*
In Normal mode and Insert/Replace mode the screen window will show the current
contents of the buffer: What You See Is What You Get. There are two
diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt
index 9db478ac41..0300ba55b3 100644
--- a/runtime/doc/lsp.txt
+++ b/runtime/doc/lsp.txt
@@ -4,7 +4,7 @@
NVIM REFERENCE MANUAL
-LSP client/framework *lsp*
+LSP client/framework *lsp* *LSP*
Nvim supports the Language Server Protocol (LSP), which means it acts as
a client to LSP servers and includes a Lua framework `vim.lsp` for building
@@ -419,7 +419,7 @@ client() *vim.lsp.client*
|vim.lsp.get_active_clients()|.
• Methods:
- • request(method, params, [callback], bufnr) Send a request
+ • request(method, params, [callback], bufnr) Sends a request
to the server. This is a thin wrapper around
{client.rpc.request} with some additional checking. If
{callback} is not specified, it will use
@@ -431,13 +431,13 @@ client() *vim.lsp.client*
If {status} is `true` , the function returns {request_id}
as the second result. You can use this with
`client.cancel_request(request_id)` to cancel the request.
- • notify(method, params) Send a notification to an LSP
+ • notify(method, params) Sends a notification to an LSP
server. Returns: a boolean to indicate if the notification
was successful. If it is false, then it will always be
false (the client has shutdown).
• cancel_request(id) Cancels a request with a given request
id. Returns: same as `notify()` .
- • stop([force]) Stop a client, optionally with force. By
+ • stop([force]) Stops a client, optionally with force. By
default, it will just ask the server to shutdown without
force. If you request to stop a client which has
previously been requested to shutdown, it will
@@ -647,7 +647,7 @@ stop_client({client_id}, {force}) *vim.lsp.stop_client()*
object. To stop all clients:
>
- vim.lsp.stop_client(lsp.get_active_clients())
+ vim.lsp.stop_client(vim.lsp.get_active_clients())
<
By default asks the server to shutdown, unless stop was
@@ -688,7 +688,7 @@ clear_references() *vim.lsp.buf.clear_references()*
Removes document highlights from current buffer.
code_action({context}) *vim.lsp.buf.code_action()*
- Select a code action from the input list that is available at
+ Selects a code action from the input list that is available at
the current cursor position.
Parameters: ~
@@ -733,7 +733,7 @@ document_symbol() *vim.lsp.buf.document_symbol()*
window.
execute_command({command}) *vim.lsp.buf.execute_command()*
- Execute an LSP server command.
+ Executes an LSP server command.
Parameters: ~
{command} A valid `ExecuteCommandParams` object
@@ -755,7 +755,7 @@ formatting({options}) *vim.lsp.buf.formatting()*
*vim.lsp.buf.formatting_sync()*
formatting_sync({options}, {timeout_ms})
- Perform |vim.lsp.buf.formatting()| synchronously.
+ Performs |vim.lsp.buf.formatting()| synchronously.
Useful for running on save, to make sure buffer is formatted
prior to being saved. {timeout_ms} is passed on to
@@ -790,15 +790,13 @@ outgoing_calls() *vim.lsp.buf.outgoing_calls()*
*vim.lsp.buf.range_formatting()*
range_formatting({options}, {start_pos}, {end_pos})
- Perform |vim.lsp.buf.formatting()| synchronously.
-
- Useful for running on save, to make sure buffer is formatted
- prior to being saved. {timeout_ms} is passed on to
- |vim.lsp.buf_request_sync()|.
+ Formats a given range.
Parameters: ~
- {options} Table with valid `FormattingOptions` entries
- {timeout_ms} (number) Request timeout
+ {options} Table with valid `FormattingOptions` entries.
+ {start_pos} ({number, number}, optional) mark-indexed
+ position. Defaults to the end of the last
+ visual selection.
references({context}) *vim.lsp.buf.references()*
Lists all the references to the symbol under the cursor in the
@@ -918,7 +916,7 @@ rpc_response_error({code}, {message}, {data})
*vim.lsp.rpc.start()*
start({cmd}, {cmd_args}, {handlers}, {extra_spawn_params})
- Start an LSP server process and create an LSP RPC client
+ Starts an LSP server process and create an LSP RPC client
object to interact with it.
Parameters: ~
@@ -959,9 +957,6 @@ Lua module: vim.lsp.util *lsp-util*
*vim.lsp.util.apply_text_document_edit()*
apply_text_document_edit({text_document_edit})
- Apply a `TextDocumentEdit` , which is a list of changes to a
- single document.
-
Parameters: ~
{text_document_edit} (table) a `TextDocumentEdit` object
@@ -984,7 +979,7 @@ apply_workspace_edit({workspace_edit})
{workspace_edit} (table) `WorkspaceEdit`
buf_clear_diagnostics({bufnr}) *vim.lsp.util.buf_clear_diagnostics()*
- Clear diagnostics for a buffer.
+ Clears diagnostics for a buffer.
Parameters: ~
{bufnr} (number) buffer id
@@ -1037,7 +1032,7 @@ buf_diagnostics_save_positions({bufnr}, {diagnostics})
*vim.lsp.util.buf_diagnostics_signs()*
buf_diagnostics_signs({bufnr}, {diagnostics})
- Place signs for each diagnostic in the sign column.
+ Places signs for each diagnostic in the sign column.
Sign characters can be customized with the following commands:
>
@@ -1058,7 +1053,7 @@ buf_diagnostics_underline({bufnr}, {diagnostics})
*vim.lsp.util.buf_diagnostics_virtual_text()*
buf_diagnostics_virtual_text({bufnr}, {diagnostics})
- Given a list of diagnostics, set the corresponding virtual
+ Given a list of diagnostics, sets the corresponding virtual
text for a buffer.
Parameters: ~
@@ -1067,7 +1062,7 @@ buf_diagnostics_virtual_text({bufnr}, {diagnostics})
*vim.lsp.util.buf_highlight_references()*
buf_highlight_references({bufnr}, {references})
- Show a list of document highlights for a certain buffer.
+ Shows a list of document highlights for a certain buffer.
Parameters: ~
{bufnr} buffer id
@@ -1089,7 +1084,7 @@ character_offset({buf}, {row}, {col}) *vim.lsp.util.character_offset()*
*vim.lsp.util.close_preview_autocmd()*
close_preview_autocmd({events}, {winnr})
- Create autocommands to close a preview window when events
+ Creates autocommands to close a preview window when events
happen.
Parameters: ~
@@ -1101,7 +1096,7 @@ close_preview_autocmd({events}, {winnr})
*vim.lsp.util.convert_input_to_markdown_lines()*
convert_input_to_markdown_lines({input}, {contents})
- Convert any of `MarkedString` | `MarkedString[]` |
+ Converts any of `MarkedString` | `MarkedString[]` |
`MarkupContent` into a list of lines containing valid
markdown. Useful to populate the hover window for
`textDocument/hover` , for parsing the result of
@@ -1121,7 +1116,7 @@ convert_input_to_markdown_lines({input}, {contents})
*vim.lsp.util.convert_signature_help_to_markdown_lines()*
convert_signature_help_to_markdown_lines({signature_help})
- Convert `textDocument/SignatureHelp` response to markdown
+ Converts `textDocument/SignatureHelp` response to markdown
lines.
Parameters: ~
@@ -1163,11 +1158,11 @@ extract_completion_items({result})
*vim.lsp.util.fancy_floating_markdown()*
fancy_floating_markdown({contents}, {opts})
- Convert markdown into syntax highlighted regions by stripping
+ Converts markdown into syntax highlighted regions by stripping
the code blocks and converting them into highlighted code.
This will by default insert a blank line separator after those
code block regions to improve readability. The result is shown
- in a floating preview
+ in a floating preview.
Parameters: ~
{contents} table of lines to show in window
@@ -1193,9 +1188,9 @@ focusable_float({unique_name}, {fn}) *vim.lsp.util.focusable_float()*
*vim.lsp.util.focusable_preview()*
focusable_preview({unique_name}, {fn})
- Focus/unfocus the floating preview window associated with the
- current buffer via the window variable `unique_name` . If no
- such preview window exists, make a new one.
+ Focuses/unfocuses the floating preview window associated with
+ the current buffer via the window variable `unique_name` . If
+ no such preview window exists, makes a new one.
Parameters: ~
{unique_name} (string) Window variable
@@ -1206,7 +1201,7 @@ focusable_preview({unique_name}, {fn})
be created
get_effective_tabstop({bufnr}) *vim.lsp.util.get_effective_tabstop()*
- Get visual width of tabstop.
+ Returns visual width of tabstop.
Parameters: ~
{bufnr} (optional, number): Buffer handle, defaults to
@@ -1219,7 +1214,7 @@ get_effective_tabstop({bufnr}) *vim.lsp.util.get_effective_tabstop()*
|softtabstop|
get_line_diagnostics() *vim.lsp.util.get_line_diagnostics()*
- Get list of diagnostics for the current line.
+ Gets list of diagnostics for the current line.
Return: ~
(table) list of `Diagnostic` tables
@@ -1229,7 +1224,7 @@ get_line_diagnostics() *vim.lsp.util.get_line_diagnostics()*
*vim.lsp.util.get_severity_highlight_name()*
get_severity_highlight_name({severity})
- Get the name of a severity's highlight group.
+ Gets the name of a severity's highlight group.
Parameters: ~
{severity} A member of
@@ -1319,7 +1314,7 @@ make_text_document_params() *vim.lsp.util.make_text_document_params()*
*vim.lsp.util.open_floating_preview()*
open_floating_preview({contents}, {filetype}, {opts})
- Show contents in a floating window
+ Shows contents in a floating window.
Parameters: ~
{contents} table of lines to show in window
@@ -1340,7 +1335,7 @@ parse_snippet({input}) *vim.lsp.util.parse_snippet()*
(string) parsed snippet
preview_location({location}) *vim.lsp.util.preview_location()*
- Preview a location in a floating window
+ Previews a location in a floating window
behavior depends on type of location:
• for Location, range is shown (e.g., function definition)
@@ -1355,7 +1350,7 @@ preview_location({location}) *vim.lsp.util.preview_location()*
or nil
set_lines({lines}, {A}, {B}, {new_lines}) *vim.lsp.util.set_lines()*
- Replace text in a range with new text.
+ Replaces text in a range with new text.
CAUTION: Changes in-place!
@@ -1389,7 +1384,7 @@ show_line_diagnostics() *vim.lsp.util.show_line_diagnostics()*
hover window.
symbols_to_items({symbols}, {bufnr}) *vim.lsp.util.symbols_to_items()*
- Convert symbols to quickfix list items
+ Converts symbols to quickfix list items.
Parameters: ~
{symbols} DocumentSymbol[] or SymbolInformation[]
@@ -1414,7 +1409,7 @@ text_document_completion_list_to_complete_items({result}, {prefix})
|complete-items|
trim_empty_lines({lines}) *vim.lsp.util.trim_empty_lines()*
- Remove empty lines from the beginning and end.
+ Removes empty lines from the beginning and end.
Parameters: ~
{lines} (table) list of lines to trim
diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt
index f336ba0c36..509ed7bf2c 100644
--- a/runtime/doc/lua.txt
+++ b/runtime/doc/lua.txt
@@ -9,7 +9,7 @@ Lua engine *lua* *Lua*
Type |gO| to see the table of contents.
==============================================================================
-Introduction *lua-intro*
+INTRODUCTION *lua-intro*
The Lua 5.1 language is builtin and always available. Try this command to get
an idea of what lurks beneath: >
@@ -30,7 +30,7 @@ finds and loads Lua modules. The conventions are similar to VimL plugins,
with some extra features. See |lua-require-example| for a walkthrough.
==============================================================================
-Importing Lua modules *lua-require*
+IMPORTING LUA MODULES *lua-require*
*lua-package-path*
Nvim automatically adjusts `package.path` and `package.cpath` according to
@@ -233,7 +233,7 @@ lua/charblob.lua: >
}
==============================================================================
-Commands *lua-commands*
+COMMANDS *lua-commands*
These commands execute a Lua chunk from either the command line (:lua, :luado)
or a file (:luafile) on the given line [range]. As always in Lua, each chunk
@@ -456,7 +456,7 @@ management. Try this command to see available functions: >
:lua print(vim.inspect(vim.loop))
-Reference: http://docs.libuv.org
+Reference: https://github.com/luvit/luv/blob/master/docs.md
Examples: https://github.com/luvit/luv/tree/master/examples
*E5560* *lua-loop-callbacks*
@@ -622,6 +622,15 @@ Node methods *lua-treesitter-node*
tsnode:parent() *tsnode:parent()*
Get the node's immediate parent.
+tsnode:iter_children() *tsnode:iter_children()*
+ Iterates over all the direct children of {tsnode}, regardless of
+ wether they are named or not.
+ Returns the child node plus the eventual field name corresponding to
+ this child node.
+
+tsnode:field({name}) *tsnode:field()*
+ Returns a table of the nodes corresponding to the {name} field.
+
tsnode:child_count() *tsnode:child_count()*
Get the node's number of children.
@@ -747,14 +756,15 @@ Here is a list of built-in predicates :
((node1) @left (node2) @right (#eq? @left @right))
<
`match?` *ts-predicate-match?*
- This will match if the provived lua regex matches the text
+ `vim-match?` *ts-predicate-vim-match?*
+ This will match if the provived vim regex matches the text
corresponding to a node : >
((idenfitier) @constant (#match? @constant "^[A-Z_]+$"))
< Note: the `^` and `$` anchors will respectively match the
start and end of the node's text.
- `vim-match?` *ts-predicate-vim-match?*
- This will match the same way than |match?| but using vim
+ `lua-match?` *ts-predicate-lua-match?*
+ This will match the same way than |match?| but using lua
regexes.
`contains?` *ts-predicate-contains?*
@@ -773,6 +783,11 @@ vim.treesitter.query.add_predicate({name}, {handler})
This adds a predicate with the name {name} to be used in queries.
{handler} should be a function whose signature will be : >
handler(match, pattern, bufnr, predicate)
+<
+ *vim.treesitter.query.list_predicates()*
+vim.treesitter.query.list_predicates()
+
+This lists the currently available predicates to use in queries.
Treesitter syntax highlighting (WIP) *lua-treesitter-highlight*
@@ -891,11 +906,6 @@ vim.api.{func}({...}) *vim.api*
Example: call the "nvim_get_current_line()" API function: >
print(tostring(vim.api.nvim_get_current_line()))
-vim.call({func}, {...}) *vim.call()*
- Invokes |vim-function| or |user-function| {func} with arguments {...}.
- See also |vim.fn|. Equivalent to: >
- vim.fn[func]({...})
-
vim.in_fast_event() *vim.in_fast_event()*
Returns true if the code is executing as part of a "fast" event
handler, where most of the API is disabled. These are low-level events
@@ -1055,22 +1065,6 @@ vim.wait({time}, {callback} [, {interval}]) *vim.wait()*
end
<
-vim.fn.{func}({...}) *vim.fn*
- Invokes |vim-function| or |user-function| {func} with arguments {...}.
- To call autoload functions, use the syntax: >
- vim.fn['some#function']({...})
-<
- Unlike vim.api.|nvim_call_function| this converts directly between Vim
- objects and Lua objects. If the Vim function returns a float, it will
- be represented directly as a Lua number. Empty lists and dictionaries
- both are represented by an empty table.
-
- Note: |v:null| values as part of the return value is represented as
- |vim.NIL| special value
-
- Note: vim.fn keys are generated lazily, thus `pairs(vim.fn)` only
- enumerates functions that were called at least once.
-
vim.type_idx *vim.type_idx*
Type index for use in |lua-special-tbl|. Specifying one of the
values from |vim.types| allows typing the empty table (it is
@@ -1106,64 +1100,103 @@ vim.types *vim.types*
`vim.types.dictionary` will not change or that `vim.types` table will
only contain values for these three types.
-==============================================================================
-Vim Internal Variables *lua-vim-internal-variables*
-
-Built-in Vim dictionaries can be accessed and set idiomatically in Lua by each
-of the following tables.
-
-To set a value: >
-
- vim.g.my_global_variable = 5
-<
+------------------------------------------------------------------------------
+LUA-VIMSCRIPT BRIDGE *lua-vimscript*
-To read a value: >
+Nvim Lua provides an interface to Vimscript variables and functions, and
+editor commands and options.
- print(vim.g.my_global_variable)
-<
+vim.call({func}, {...}) *vim.call()*
+ Invokes |vim-function| or |user-function| {func} with arguments {...}.
+ See also |vim.fn|.
+ Equivalent to: >
+ vim.fn[func]({...})
-To delete a value: >
+vim.cmd({cmd}) *vim.cmd()*
+ Invokes an Ex command (the ":" commands, Vimscript statements).
+ See also |ex-cmd-index|.
+ Example: >
+ vim.cmd('echo 42')
- vim.g.my_global_variable = nil
+vim.fn.{func}({...}) *vim.fn*
+ Invokes |vim-function| or |user-function| {func} with arguments {...}.
+ To call autoload functions, use the syntax: >
+ vim.fn['some#function']({...})
<
+ Unlike vim.api.|nvim_call_function| this converts directly between Vim
+ objects and Lua objects. If the Vim function returns a float, it will
+ be represented directly as a Lua number. Empty lists and dictionaries
+ both are represented by an empty table.
-vim.g *vim.g*
- Table with values from |g:|
- Keys with no values set will result in `nil`.
-
-vim.b *vim.b*
- Gets a buffer-scoped (b:) variable for the current buffer.
- Keys with no values set will result in `nil`.
-
-vim.w *vim.w*
- Gets a window-scoped (w:) variable for the current window.
- Keys with no values set will result in `nil`.
+ Note: |v:null| values as part of the return value is represented as
+ |vim.NIL| special value
-vim.t *vim.t*
- Gets a tabpage-scoped (t:) variable for the current table.
- Keys with no values set will result in `nil`.
+ Note: vim.fn keys are generated lazily, thus `pairs(vim.fn)` only
+ enumerates functions that were called at least once.
-vim.v *vim.v*
- Gets a v: variable.
- Keys with no values set will result in `nil`.
+ *lua-vim-variables*
+The Vim editor global dictionaries |g:| |w:| |b:| |t:| |v:| can be accessed
+from Lua conveniently and idiomatically by referencing the `vim.*` Lua tables
+described below. In this way you can easily read and modify global Vimscript
+variables from Lua.
-Vim Internal Options *lua-vim-internal-options*
+Example: >
-Read, set and clear vim |options| in Lua by each of the following tables.
+ vim.g.foo = 5 -- Set the g:foo Vimscript variable.
+ print(vim.g.foo) -- Get and print the g:foo Vimscript variable.
+ vim.g.foo = nil -- Delete (:unlet) the Vimscript variable.
+
+vim.g *vim.g*
+ Global (|g:|) editor variables.
+ Key with no value returns `nil`.
+
+vim.b *vim.b*
+ Buffer-scoped (|b:|) variables for the current buffer.
+ Invalid or unset key returns `nil`.
+
+vim.w *vim.w*
+ Window-scoped (|w:|) variables for the current window.
+ Invalid or unset key returns `nil`.
+
+vim.t *vim.t*
+ Tabpage-scoped (|t:|) variables for the current tabpage.
+ Invalid or unset key returns `nil`.
+
+vim.v *vim.v*
+ |v:| variables.
+ Invalid or unset key returns `nil`.
+
+vim.env *vim.env*
+ Environment variables defined in the editor session.
+ See |expand-env| and |:let-environment| for the Vimscript behavior.
+ Invalid or unset key returns `nil`.
+ Example: >
+ vim.env.FOO = 'bar'
+ print(vim.env.TERM)
+<
+ *lua-vim-options*
+From Lua you can work with editor |options| by reading and setting items in
+these Lua tables:
-vim.o *vim.o*
- Table with values from |options|
- Invalid keys will result in an error.
+vim.o *vim.o*
+ Get or set editor options, like |:set|. Invalid key is an error.
+ Example: >
+ vim.o.cmdheight = 4
+ print(vim.o.columns)
-vim.bo *vim.bo*
- Gets a buffer-scoped option for the current buffer.
- Invalid keys will result in an error.
+vim.bo *vim.bo*
+ Get or set buffer-scoped |local-options|. Invalid key is an error.
+ Example: >
+ vim.bo.buflisted = true
+ print(vim.bo.comments)
-vim.wo *vim.wo*
- Gets a window-scoped option for the current window.
- Invalid keys will result in an error.
+vim.wo *vim.wo*
+ Get or set window-scoped |local-options|. Invalid key is an error.
+ Example: >
+ vim.wo.cursorcolumn = true
+ print(vim.wo.foldmarker)
==============================================================================
@@ -1419,17 +1452,21 @@ tbl_flatten({t}) *vim.tbl_flatten()*
Fromhttps://github.com/premake/premake-core/blob/master/src/base/table.lua
tbl_isempty({t}) *vim.tbl_isempty()*
+ Checks if a table is empty.
+
+ Parameters: ~
+ {t} Table to check
+
See also: ~
- Fromhttps://github.com/premake/premake-core/blob/master/src/base/table.lua@paramt Table to check
+ https://github.com/premake/premake-core/blob/master/src/base/table.lua
tbl_islist({t}) *vim.tbl_islist()*
- Determine whether a Lua table can be treated as an array.
+ Tests if a Lua table can be treated as an array.
- An empty table `{}` will default to being treated as an array.
- Use `vim.emtpy_dict()` to create a table treated as an empty
- dict. Empty tables returned by `rpcrequest()` and `vim.fn`
- functions can be checked using this function whether they
- represent empty API arrays and vimL lists.
+ Empty table `{}` is assumed to be an array, unless it was
+ created by |vim.empty_dict()| or returned as a dict-like |API|
+ or Vimscript result, for example from |rpcrequest()| or
+ |vim.fn|.
Parameters: ~
{t} Table
diff --git a/runtime/doc/mbyte.txt b/runtime/doc/mbyte.txt
index 127c46c27d..a6410a09cb 100644
--- a/runtime/doc/mbyte.txt
+++ b/runtime/doc/mbyte.txt
@@ -71,24 +71,15 @@ If you are working in a terminal (emulator) you must make sure it accepts
UTF-8, the encoding which Vim is working with. Otherwise only ASCII can
be displayed and edited correctly.
-For the GUI you must select fonts that work with UTF-8. This
-is the difficult part. It depends on the system you are using, the locale and
-a few other things.
-
-For X11 you can set the 'guifontset' option to a list of fonts that together
-cover the characters that are used. Example for Korean: >
-
- :set guifontset=k12,r12
-
-Alternatively, you can set 'guifont' and 'guifontwide'. 'guifont' is used for
-the single-width characters, 'guifontwide' for the double-width characters.
-Thus the 'guifontwide' font must be exactly twice as wide as 'guifont'.
-Example for UTF-8: >
+For the GUI you must select fonts that work with UTF-8. You can set 'guifont'
+and 'guifontwide'. 'guifont' is used for the single-width characters,
+'guifontwide' for the double-width characters. Thus the 'guifontwide' font
+must be exactly twice as wide as 'guifont'. Example for UTF-8: >
:set guifont=-misc-fixed-medium-r-normal-*-18-120-100-100-c-90-iso10646-1
:set guifontwide=-misc-fixed-medium-r-normal-*-18-120-100-100-c-180-iso10646-1
-You can also set 'guifont' alone, Vim will try to find a matching
+You can also set 'guifont' alone, the Nvim GUI will try to find a matching
'guifontwide' for you.
@@ -267,16 +258,16 @@ Recognized 'fileencoding' values include: *encoding-values*
1 cp1258 Vietnamese
1 cp{number} MS-Windows: any installed single-byte codepage
2 cp932 Japanese (Windows only)
-2 euc-jp Japanese (Unix only)
-2 sjis Japanese (Unix only)
-2 cp949 Korean (Unix and Windows)
-2 euc-kr Korean (Unix only)
+2 euc-jp Japanese
+2 sjis Japanese
+2 cp949 Korean
+2 euc-kr Korean
2 cp936 simplified Chinese (Windows only)
-2 euc-cn simplified Chinese (Unix only)
-2 cp950 traditional Chinese (on Unix alias for big5)
-2 big5 traditional Chinese (on Windows alias for cp950)
-2 euc-tw traditional Chinese (Unix only)
-2 2byte-{name} Unix: any double-byte encoding (Vim specific name)
+2 euc-cn simplified Chinese
+2 cp950 traditional Chinese (alias for big5)
+2 big5 traditional Chinese (alias for cp950)
+2 euc-tw traditional Chinese
+2 2byte-{name} any double-byte encoding (Vim-specific name)
2 cp{number} MS-Windows: any installed double-byte codepage
u utf-8 32 bit UTF-8 encoded Unicode (ISO/IEC 10646-1)
u ucs-2 16 bit UCS-2 encoded Unicode (ISO/IEC 10646-1)
@@ -298,14 +289,14 @@ the same encoding is used and it's called latin1. 'isprint' can be used to
display the characters 0x80 - 0xA0 or not.
Several aliases can be used, they are translated to one of the names above.
-An incomplete list:
+Incomplete list:
1 ansi same as latin1 (obsolete, for backward compatibility)
-2 japan Japanese: on Unix "euc-jp", on MS-Windows cp932
-2 korea Korean: on Unix "euc-kr", on MS-Windows cp949
-2 prc simplified Chinese: on Unix "euc-cn", on MS-Windows cp936
+2 japan Japanese: "euc-jp"
+2 korea Korean: "euc-kr"
+2 prc simplified Chinese: "euc-cn"
2 chinese same as "prc"
-2 taiwan traditional Chinese: on Unix "euc-tw", on MS-Windows cp950
+2 taiwan traditional Chinese: "euc-tw"
u utf8 same as utf-8
u unicode same as ucs-2
u ucs2be same as ucs-2 (big endian)
@@ -394,148 +385,6 @@ conversion needs to be done. These conversions are supported:
request a very large buffer, more than Vim is willing to provide).
Try getting another iconv() implementation.
- *iconv-dynamic*
-On MS-Windows Vim can be compiled with the |+iconv/dyn| feature. This means
-Vim will search for the "iconv.dll" and "libiconv.dll" libraries. When
-neither of them can be found Vim will still work but some conversions won't be
-possible.
-
-==============================================================================
-Fonts on X11 *mbyte-fonts-X11*
-
-Unfortunately, using fonts in X11 is complicated. The name of a single-byte
-font is a long string. For multi-byte fonts we need several of these...
-
-First of all, Vim only accepts fixed-width fonts for displaying text. You
-cannot use proportionally spaced fonts. This excludes many of the available
-(and nicer looking) fonts. However, for menus and tooltips any font can be
-used.
-
-Note that Display and Input are independent. It is possible to see your
-language even though you have no input method for it.
-
-You should get a default font for menus and tooltips that works, but it might
-be ugly. Read the following to find out how to select a better font.
-
-
-X LOGICAL FONT DESCRIPTION (XLFD)
- *XLFD*
-XLFD is the X font name and contains the information about the font size,
-charset, etc. The name is in this format:
-
-FOUNDRY-FAMILY-WEIGHT-SLANT-WIDTH-STYLE-PIXEL-POINT-X-Y-SPACE-AVE-CR-CE
-
-Each field means:
-
-- FOUNDRY: FOUNDRY field. The company that created the font.
-- FAMILY: FAMILY_NAME field. Basic font family name. (helvetica, gothic,
- times, etc)
-- WEIGHT: WEIGHT_NAME field. How thick the letters are. (light, medium,
- bold, etc)
-- SLANT: SLANT field.
- r: Roman (no slant)
- i: Italic
- o: Oblique
- ri: Reverse Italic
- ro: Reverse Oblique
- ot: Other
- number: Scaled font
-- WIDTH: SETWIDTH_NAME field. Width of characters. (normal, condensed,
- narrow, double wide)
-- STYLE: ADD_STYLE_NAME field. Extra info to describe font. (Serif, Sans
- Serif, Informal, Decorated, etc)
-- PIXEL: PIXEL_SIZE field. Height, in pixels, of characters.
-- POINT: POINT_SIZE field. Ten times height of characters in points.
-- X: RESOLUTION_X field. X resolution (dots per inch).
-- Y: RESOLUTION_Y field. Y resolution (dots per inch).
-- SPACE: SPACING field.
- p: Proportional
- m: Monospaced
- c: CharCell
-- AVE: AVERAGE_WIDTH field. Ten times average width in pixels.
-- CR: CHARSET_REGISTRY field. The name of the charset group.
-- CE: CHARSET_ENCODING field. The rest of the charset name. For some
- charsets, such as JIS X 0208, if this field is 0, code points has
- the same value as GL, and GR if 1.
-
-For example, in case of a 16 dots font corresponding to JIS X 0208, it is
-written like:
- -misc-fixed-medium-r-normal--16-110-100-100-c-160-jisx0208.1990-0
-
-
-X FONTSET
- *fontset* *xfontset*
-A single-byte charset is typically associated with one font. For multi-byte
-charsets a combination of fonts is often used. This means that one group of
-characters are used from one font and another group from another font (which
-might be double wide). This collection of fonts is called a fontset.
-
-Which fonts are required in a fontset depends on the current locale. X
-windows maintains a table of which groups of characters are required for a
-locale. You have to specify all the fonts that a locale requires in the
-'guifontset' option.
-
-NOTE: The fontset always uses the current locale, even though 'encoding' may
-be set to use a different charset. In that situation you might want to use
-'guifont' and 'guifontwide' instead of 'guifontset'.
-
-Example:
- |charset| language "groups of characters" ~
- GB2312 Chinese (simplified) ISO-8859-1 and GB 2312
- Big5 Chinese (traditional) ISO-8859-1 and Big5
- CNS-11643 Chinese (traditional) ISO-8859-1, CNS 11643-1 and CNS 11643-2
- EUC-JP Japanese JIS X 0201 and JIS X 0208
- EUC-KR Korean ISO-8859-1 and KS C 5601 (KS X 1001)
-
-You can search for fonts using the xlsfonts command. For example, when you're
-searching for a font for KS C 5601: >
- xlsfonts | grep ksc5601
-
-This is complicated and confusing. You might want to consult the X-Windows
-documentation if there is something you don't understand.
-
- *base_font_name_list*
-When you have found the names of the fonts you want to use, you need to set
-the 'guifontset' option. You specify the list by concatenating the font names
-and putting a comma in between them.
-
-For example, when you use the ja_JP.eucJP locale, this requires JIS X 0201
-and JIS X 0208. You could supply a list of fonts that explicitly specifies
-the charsets, like: >
-
- :set guifontset=-misc-fixed-medium-r-normal--14-130-75-75-c-140-jisx0208.1983-0,
- \-misc-fixed-medium-r-normal--14-130-75-75-c-70-jisx0201.1976-0
-
-Alternatively, you can supply a base font name list that omits the charset
-name, letting X-Windows select font characters required for the locale. For
-example: >
-
- :set guifontset=-misc-fixed-medium-r-normal--14-130-75-75-c-140,
- \-misc-fixed-medium-r-normal--14-130-75-75-c-70
-
-Alternatively, you can supply a single base font name that allows X-Windows to
-select from all available fonts. For example: >
-
- :set guifontset=-misc-fixed-medium-r-normal--14-*
-
-Alternatively, you can specify alias names. See the fonts.alias file in the
-fonts directory (e.g., /usr/X11R6/lib/X11/fonts/). For example: >
-
- :set guifontset=k14,r14
-<
- *E253*
-Note that in East Asian fonts, the standard character cell is square. When
-mixing a Latin font and an East Asian font, the East Asian font width should
-be twice the Latin font width.
-
-If 'guifontset' is not empty, the "font" argument of the |:highlight| command
-is also interpreted as a fontset. For example, you should use for
-highlighting: >
- :hi Comment font=english_font,your_font
-If you use a wrong "font" argument you will get an error message.
-Also make sure that you set 'guifontset' before setting fonts for highlight
-groups.
-
==============================================================================
Input on X11 *mbyte-XIM*
@@ -647,10 +496,6 @@ Note that Display and Input are independent. It is possible to see your
language even though you have no input method for it. But when your Display
method doesn't match your Input method, the text will be displayed wrong.
- Note: You can not use IM unless you specify 'guifontset'.
- Therefore, Latin users, you have to also use 'guifontset'
- if you use IM.
-
To input your language you should run the |IM-server| which supports your
language and |conversion-server| if needed.
@@ -962,9 +807,9 @@ Vim has comprehensive UTF-8 support. It works well in:
- MS-Windows GUI
- several other platforms
-Double-width characters are supported. This works best with 'guifontwide' or
-'guifontset'. When using only 'guifont' the wide characters are drawn in the
-normal width and a space to fill the gap.
+Double-width characters are supported. Works best with 'guifontwide'. When
+using only 'guifont' the wide characters are drawn in the normal width and
+a space to fill the gap.
*bom-bytes*
When reading a file a BOM (Byte Order Mark) can be used to recognize the
@@ -1031,7 +876,6 @@ this:
1. Set 'guifont' and let Vim find a matching 'guifontwide'
2. Set 'guifont' and 'guifontwide'
-3. Set 'guifontset'
See the documentation for each option for details. Example: >
@@ -1077,10 +921,7 @@ not everybody is able to type a composing character.
==============================================================================
Overview of options *mbyte-options*
-These options are relevant for editing multi-byte files. Check the help in
-options.txt for detailed information.
-
-'encoding' Internal text encoding, always "utf-8".
+These options are relevant for editing multi-byte files.
'fileencoding' Encoding of a file. When it's different from "utf-8"
conversion is done when reading or writing the file.
@@ -1096,9 +937,6 @@ options.txt for detailed information.
languages where a sequence of characters can be broken
anywhere.
-'guifontset' The list of font names used for a multi-byte encoding. When
- this option is not empty, it replaces 'guifont'.
-
'keymap' Specify the name of a keyboard mapping.
==============================================================================
diff --git a/runtime/doc/message.txt b/runtime/doc/message.txt
index 43b1eb5e0c..745160da8a 100644
--- a/runtime/doc/message.txt
+++ b/runtime/doc/message.txt
@@ -359,7 +359,7 @@ the other way around. It should be used like this: {foo,bar}. This matches
ml_get: invalid lnum: {number}
This is an internal Vim error. Please try to find out how it can be
-reproduced, and submit a bug report |bugreport.vim|.
+reproduced, and submit a |bug-report|.
*E173* >
{number} more files to edit
diff --git a/runtime/doc/mlang.txt b/runtime/doc/mlang.txt
index 2a10a7051d..5217b2c160 100644
--- a/runtime/doc/mlang.txt
+++ b/runtime/doc/mlang.txt
@@ -124,8 +124,7 @@ maintainer of the translation and ask him to update it. You can find the
name and e-mail address of the translator in
"$VIMRUNTIME/lang/menu_<lang>.vim".
-To set the font (or fontset) to use for the menus, use the |:highlight|
-command. Example: >
+To set the font to use for the menus, use the |:highlight| command. Example: >
:highlight Menu font=k12,r12
diff --git a/runtime/doc/nvim_terminal_emulator.txt b/runtime/doc/nvim_terminal_emulator.txt
index a96d118667..bec2b362ea 100644
--- a/runtime/doc/nvim_terminal_emulator.txt
+++ b/runtime/doc/nvim_terminal_emulator.txt
@@ -92,7 +92,7 @@ Mouse input has the following behavior:
the terminal wont lose focus and the hovered window will be scrolled.
==============================================================================
-Configuration *terminal-configuration*
+Configuration *terminal-config*
Options: 'modified', 'scrollback'
Events: |TermOpen|, |TermEnter|, |TermLeave|, |TermClose|
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index 2cfc6e374b..190d6f9229 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -118,8 +118,7 @@ A few special texts:
Option was set with command line argument |-c|, +, |-S| or
|-q|.
Last set from environment variable ~
- Option was set from an environment variable, $VIMINIT,
- $GVIMINIT or $EXINIT.
+ Option was set from $VIMINIT.
Last set from error handler ~
Option was cleared when evaluating it resulted in an error.
@@ -2796,9 +2795,6 @@ A jump table for the options with a short description can be found at |Q_op|.
font names a list can be specified, font names separated with commas.
The first valid font is used.
- On systems where 'guifontset' is supported (X11) and 'guifontset' is
- not empty, then 'guifont' is not used.
-
Spaces after a comma are ignored. To include a comma in a font name
precede it with a backslash. Setting an option requires an extra
backslash before a space and a backslash. See also
@@ -2850,45 +2846,16 @@ A jump table for the options with a short description can be found at |Q_op|.
:set guifont=courier_new:h12:w5:b:cRUSSIAN
:set guifont=Andale_Mono:h7.5:w4.5
<
-
- *'guifontset'* *'gfs'*
- *E250* *E252* *E234* *E597* *E598*
-'guifontset' 'gfs' string (default "")
- global
- When not empty, specifies two (or more) fonts to be used. The first
- one for normal English, the second one for your special language. See
- |xfontset|.
- Setting this option also means that all font names will be handled as
- a fontset name. Also the ones used for the "font" argument of the
- |:highlight| command.
- The fonts must match with the current locale. If fonts for the
- character sets that the current locale uses are not included, setting
- 'guifontset' will fail.
- Note the difference between 'guifont' and 'guifontset': In 'guifont'
- the comma-separated names are alternative names, one of which will be
- used. In 'guifontset' the whole string is one fontset name,
- including the commas. It is not possible to specify alternative
- fontset names.
- This example works on many X11 systems: >
- :set guifontset=-*-*-medium-r-normal--16-*-*-*-c-*-*-*
-<
*'guifontwide'* *'gfw'* *E231* *E533* *E534*
'guifontwide' 'gfw' string (default "")
global
- When not empty, specifies a comma-separated list of fonts to be used
- for double-width characters. The first font that can be loaded is
- used.
+ Comma-separated list of fonts to be used for double-width characters.
+ The first font that can be loaded is used.
Note: The size of these fonts must be exactly twice as wide as the one
specified with 'guifont' and the same height.
- 'guifontwide' is only used when 'guifontset' is empty or invalid.
- When 'guifont' is set and a valid font is found in it and
- 'guifontwide' is empty Vim will attempt to find a matching
- double-width font and set 'guifontwide' to it.
-
- Windows +multibyte only: *guifontwide_win_mbyte*
-
- If set and valid, 'guifontwide' is used for IME instead of 'guifont'.
+ When 'guifont' has a valid font and 'guifontwide' is empty Vim will
+ attempt to set 'guifontwide' to a matching double-width font.
*'guioptions'* *'go'*
'guioptions' 'go' string (default "egmrLT" (MS-Windows))
@@ -4055,7 +4022,6 @@ A jump table for the options with a short description can be found at |Q_op|.
*'mousefocus'* *'mousef'* *'nomousefocus'* *'nomousef'*
'mousefocus' 'mousef' boolean (default off)
global
- {only works in the GUI}
The window that the mouse pointer is on is automatically activated.
When changing the window layout or window focus in another way, the
mouse pointer is moved to the window with keyboard focus. Off is the
diff --git a/runtime/doc/provider.txt b/runtime/doc/provider.txt
index 0a6cdc60e8..f944689d0b 100644
--- a/runtime/doc/provider.txt
+++ b/runtime/doc/provider.txt
@@ -129,9 +129,13 @@ To use the RVM "system" Ruby installation: >
==============================================================================
Perl integration *provider-perl*
-Nvim supports Perl |remote-plugin|s.
+Nvim supports Perl |remote-plugin|s on Unix platforms. Support for polling STDIN
+on MS-Windows is currently lacking from all known event loop implementations.
+The Vim legacy |perl-vim| interface is also supported (which is itself
+implemented as a Nvim remote-plugin).
https://github.com/jacquesg/p5-Neovim-Ext
+Note: Only perl versions from 5.22 onward are supported.
PERL QUICKSTART~
@@ -212,12 +216,12 @@ For example this configuration integrates the tmux clipboard: >
let g:clipboard = {
\ 'name': 'myClipboard',
\ 'copy': {
- \ '+': 'tmux load-buffer -',
- \ '*': 'tmux load-buffer -',
+ \ '+': ['tmux', 'load-buffer', '-'],
+ \ '*': ['tmux', 'load-buffer', '-'],
\ },
\ 'paste': {
- \ '+': 'tmux save-buffer -',
- \ '*': 'tmux save-buffer -',
+ \ '+': ['tmux', 'save-buffer', '-'],
+ \ '*': ['tmux', 'save-buffer', '-'],
\ },
\ 'cache_enabled': 1,
\ }
diff --git a/runtime/doc/quickref.txt b/runtime/doc/quickref.txt
index 224f14a18b..4a47fd4b57 100644
--- a/runtime/doc/quickref.txt
+++ b/runtime/doc/quickref.txt
@@ -711,7 +711,6 @@ Short explanation of each option: *option-list*
'grepprg' 'gp' program to use for ":grep"
'guicursor' 'gcr' GUI: settings for cursor shape and blinking
'guifont' 'gfn' GUI: Name(s) of font(s) to be used
-'guifontset' 'gfs' GUI: Names of multi-byte fonts to be used
'guifontwide' 'gfw' list of font names for double-wide characters
'guioptions' 'go' GUI: Which components and options are used
'guitablabel' 'gtl' GUI: custom label for a tab page
@@ -1106,7 +1105,6 @@ Context-sensitive completion on the command-line:
------------------------------------------------------------------------------
*Q_st* Starting Vim
-|-vim| vim [options] start editing with an empty buffer
|-file| vim [options] {file} .. start editing one or more files
|--| vim [options] - read file from stdin
|-tag| vim [options] -t {tag} edit the file associated with {tag}
diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt
index 0ded6a9060..d0faeb9cb7 100644
--- a/runtime/doc/starting.txt
+++ b/runtime/doc/starting.txt
@@ -9,20 +9,20 @@ Starting Vim *starting*
Type |gO| to see the table of contents.
==============================================================================
-1. Vim arguments *vim-arguments*
+Nvim arguments *vim-arguments*
-Most often, Vim is started to edit a single file with the command
+Most often, Nvim is started to edit a single file with the command: >
- nvim filename *-vim*
+ nvim filename
-More generally, Vim is started with:
+More generally, Nvim is started with: >
nvim [option | filename] ..
Option arguments and file name arguments can be mixed, and any number of them
can be given. However, watch out for options that take an argument.
-The following items may be used to choose how to start editing:
+The following items decide how to start editing:
*-file* *---*
filename One or more file names. The first one will be the current
@@ -231,9 +231,8 @@ argument.
-b Binary mode. File I/O will only recognize <NL> to separate
lines. The 'expandtab' option will be reset. The 'textwidth'
option is set to 0. 'modeline' is reset. The 'binary' option
- is set. This is done after reading the init.vim/exrc files
- but before reading any file in the arglist. See also
- |edit-binary|.
+ is set. This is done after reading the |vimrc| but before
+ reading any file in the arglist. See also |edit-binary|.
*-l*
-l Lisp mode. Sets the 'lisp' and 'showmatch' options on.
@@ -398,7 +397,7 @@ argument.
primary listen address |v:servername| to {addr}. |serverstart()|
==============================================================================
-2. Initialization *initialization* *startup*
+Initialization *initialization* *startup*
At startup, Vim checks environment variables and files and sets values
accordingly. Vim proceeds in this order:
@@ -414,45 +413,47 @@ accordingly. Vim proceeds in this order:
The |-V| argument can be used to display or log what happens next,
useful for debugging the initializations.
-3. Execute Ex commands, from environment variables and/or files
- An environment variable (e.g. $VIMINIT) is read as one Ex command
- line, where multiple commands must be separated with '|' or <NL>.
+3. Wait for UI to connect.
+ 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, …).
+ $VIMINIT environment variable is read as one Ex command line (separate
+ multiple commands with '|' or <NL>).
*config* *init.vim* *vimrc* *exrc*
- A file that contains initialization commands is generically called
- a "vimrc" or config file. Each line in a vimrc file is executed as an
- Ex command line. See also |vimrc-intro| and |base-directories|.
+ A file containing init commands is generically called a "vimrc" or
+ "config". Each line in such a file is executed as an Ex command.
+ |vimrc-intro| |base-directories|
- The Nvim config file is named "init.vim", located at:
+ The Nvim config file is "init.vim", located at:
Unix ~/.config/nvim/init.vim
Windows ~/AppData/Local/nvim/init.vim
- Or if |$XDG_CONFIG_HOME| is defined:
+ or if |$XDG_CONFIG_HOME| is defined:
$XDG_CONFIG_HOME/nvim/init.vim
- If Nvim was started with "-u filename", the file "filename" is used.
- All following initializations until 4. are skipped. $MYVIMRC is not
- set.
+ If Nvim was started with "-u {file}" then {file} is used as the config
+ and all initializations until 5. are skipped. $MYVIMRC is not set.
"nvim -u NORC" can be used to skip these initializations without
reading a file. "nvim -u NONE" also skips plugins and syntax
highlighting. |-u|
- If Nvim was started with |-es|, all following initializations until 4.
- are skipped.
+ If Nvim was started with |-es| all initializations until 5. are
+ skipped.
*system-vimrc* *sysinit.vim*
a. The system vimrc file is read for initializations. If
nvim/sysinit.vim file exists in one of $XDG_CONFIG_DIRS, it will be
- used. Otherwise, the system vimrc file is used. The path of this file
- is shown with the ":version" command. Mostly it's "$VIM/sysinit.vim".
+ used. Otherwise the system vimrc file is used. The path of this file
+ is given by the |:version| command. Usually it's "$VIM/sysinit.vim".
*VIMINIT* *EXINIT* *$MYVIMRC*
- b. Four places are searched for initializations. The first that exists
- is used, the others are ignored. The $MYVIMRC environment variable is
- set to the file that was first found, unless $MYVIMRC was already set
- and when using VIMINIT.
- - Environment variable $VIMINIT, used as an Ex command line.
- - User |config| file: $XDG_CONFIG_HOME/nvim/init.vim.
- - Other config file: {xdg_config_dir}/nvim/init.vim where
- {xdg_config_dir} is one of the directories in $XDG_CONFIG_DIRS.
- - Environment variable $EXINIT, used as an Ex command line.
+ b. Locations searched for initializations, in order of preference:
+ - $VIMINIT environment variable (Ex command line).
+ - User |config|: $XDG_CONFIG_HOME/nvim/init.vim.
+ - Other config: {dir}/nvim/init.vim where {dir} is any directory
+ in $XDG_CONFIG_DIRS.
+ - $EXINIT environment variable (Ex command line).
+ |$MYVIMRC| is set to the first valid location unless it was already
+ set or when using $VIMINIT.
c. If the 'exrc' option is on (which is NOT the default), the current
directory is searched for two files. The first that exists is used,
@@ -460,7 +461,7 @@ accordingly. Vim proceeds in this order:
- The file ".nvimrc"
- The file ".exrc"
-4. Enable filetype and indent plugins.
+5. Enable filetype and indent plugins.
This does the same as the commands: >
:runtime! filetype.vim
:runtime! ftplugin.vim
@@ -468,13 +469,13 @@ accordingly. Vim proceeds in this order:
< Skipped if ":filetype … off" was called or if the "-u NONE" command
line argument was given.
-5. Enable syntax highlighting.
+6. 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.
-6. Load the plugin scripts. *load-plugins*
+7. Load the plugin scripts. *load-plugins*
This does the same as the command: >
:runtime! plugin/**/*.vim
< The result is that all directories in the 'runtimepath' option will be
@@ -503,26 +504,26 @@ accordingly. Vim proceeds in this order:
if packages have been found, but that should not add a directory
ending in "after".
-7. Set 'shellpipe' and 'shellredir'
+8. 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
'shellredir' for you, unless you have set them yourself.
-8. Set 'updatecount' to zero, if "-n" command argument used
+9. Set 'updatecount' to zero, if "-n" command argument used
-9. Set binary options
+10. Set binary options
If the "-b" flag was given to Vim, the options for binary editing will
be set now. See |-b|.
-10. Read the ShaDa file
+11. Read the ShaDa file
See |shada-file|.
-11. Read the quickfix file
+12. Read the quickfix file
If the "-q" flag was given to Vim, the quickfix file is read. If this
fails, Vim exits.
-12. Open all windows
+13. 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
@@ -531,7 +532,7 @@ accordingly. Vim proceeds in this order:
If the "-q" flag was given to Vim, the first error is jumped to.
Buffers for all windows will be loaded.
-13. Execute startup commands
+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.
If the 'insertmode' option is set, Insert mode is entered.
@@ -540,29 +541,6 @@ accordingly. Vim proceeds in this order:
The |VimEnter| autocommands are executed.
-Some hints on using initializations ~
-
-Standard setup:
-Create a vimrc file to set the default settings and mappings for all your edit
-sessions. Put it in a place so that it will be found by 3b:
- ~/.config/nvim/init.vim (Unix)
- ~/AppData/Local/nvim/init.vim (Win32)
-
-Local setup:
-Put all commands that you need for editing a specific directory only into a
-vimrc file and place it in that directory under the name ".nvimrc" ("_nvimrc"
-for Windows). NOTE: To make Vim look for these special files you
-have to turn on the option 'exrc'. See |trojan-horse| too.
-
-System setup:
-This only applies if you are managing a Unix system with several users and
-want to set the defaults for all users. Create a vimrc file with commands
-for default settings and mappings and put it in the place that is given with
-the ":version" command. NOTE: System vimrc file needs specific compilation
-options (one needs to define SYS_VIMRC_FILE macros). If :version command does
-not show anything like this, consider contacting the nvim package maintainer.
-
-
Saving the current state of Vim to a file ~
Whenever you have changed values of options or when you have created a
@@ -570,20 +548,6 @@ mapping, then you may want to save them in a vimrc file for later use. See
|save-settings| about saving the current state of settings to a file.
-Avoiding setup problems for Vi users ~
-
-Vi uses the variable EXINIT and the file "~/.exrc". So if you do not want to
-interfere with Vi, then use the variable VIMINIT and the file init.vim
-instead.
-
-
-MS-DOS line separators: ~
-
-On Windows systems Vim assumes that all the vimrc files have <CR> <NL> pairs
-as line separators. This will give problems if you have a file with only
-<NL>s and have a line like ":map xx yy^M". The trailing ^M will be ignored.
-
-
Avoiding trojan horses ~
*trojan-horse*
While reading the "vimrc" or the "exrc" file in the current directory, some
@@ -606,7 +570,7 @@ it possible for another user to create a nasty vimrc and make you the owner.
Be careful!
When using tag search commands, executing the search command (the last
part of the line in the tags file) is always done in secure mode. This works
-just like executing a command from a vimrc/exrc in the current directory.
+just like executing a command from a vimrc in the current directory.
If Vim startup is slow ~
@@ -620,27 +584,29 @@ moment (use the Vim argument "-i NONE", |-i|). Try reducing the number of
lines stored in a register with ":set shada='20,<50,s10". |shada-file|.
-Intro message ~
- *:intro*
-When Vim starts without a file name, an introductory message is displayed (for
-those who don't know what Vim is). It is removed as soon as the display is
-redrawn in any way. To see the message again, use the ":intro" command (if
-there is not enough room, you will see only part of it).
- To avoid the intro message on startup, add the 'I' flag to 'shortmess'.
+Troubleshooting broken configurations ~
+ *bisect*
+The extreme flexibility of editors like Vim and Emacs means that any plugin or
+setting can affect the entire editor in ways that are not initially obvious.
- *info-message*
-The |--help| and |--version| arguments cause Nvim to print a message and then
-exit. Normally the message is sent to stdout, thus can be redirected to a
-file with: >
+To find the cause of a problem in your config, you must "bisect" it:
+1. Remove or disable half of your `init.vim`.
+2. Restart Nvim.
+3. If the problem still occurs, goto 1.
+4. If the problem is gone, restore half of the removed lines.
+5. Continue narrowing your config in this way, until you find the setting or
+ plugin causing the issue.
- nvim --help >file
-From inside Nvim: >
-
- :read !nvim --help
+Intro message ~
+ *:intro*
+When Vim starts without a file name, an introductory message is displayed. It
+is removed as soon as the display is redrawn. To see the message again, use
+the ":intro" command. To avoid the intro message on startup, add the "I" flag
+to 'shortmess'.
==============================================================================
-3. $VIM and $VIMRUNTIME
+$VIM and $VIMRUNTIME
*$VIM*
The environment variable "$VIM" is used to locate various user files for Nvim,
such as the user startup script |init.vim|. This depends on the system, see
@@ -683,9 +649,9 @@ greps in the help files) you might be able to use this: >
VIMRUNTIME="$(nvim --clean --headless --cmd 'echo $VIMRUNTIME|q')"
==============================================================================
-4. Suspending *suspend*
+Suspending *suspend*
- *iconize* *iconise* *CTRL-Z* *v_CTRL-Z*
+ *CTRL-Z* *v_CTRL-Z*
CTRL-Z Suspend Nvim, like ":stop".
Works in Normal and in Visual mode. In Insert and
Command-line mode, the CTRL-Z is inserted as a normal
@@ -706,7 +672,7 @@ CTRL-Z Suspend Nvim, like ":stop".
In the GUI, suspending is implementation-defined.
==============================================================================
-5. Exiting *exiting*
+Exiting *exiting*
There are several ways to exit Vim:
- Close the last window with `:quit`. Only when there are no changes.
@@ -719,7 +685,7 @@ When using `:cquit` or when there was an error message Vim exits with exit
code 1. Errors can be avoided by using `:silent!` or with `:catch`.
==============================================================================
-6. Saving settings *save-settings*
+Saving settings *save-settings*
Mostly you will edit your vimrc files manually. This gives you the greatest
flexibility. There are a few commands to generate a vimrc file automatically.
@@ -776,7 +742,7 @@ these steps:
You need to escape special characters, esp. spaces.
==============================================================================
-7. Views and Sessions *views-sessions*
+Views and Sessions *views-sessions*
This is introduced in sections |21.4| and |21.5| of the user manual.
@@ -920,7 +886,7 @@ To automatically save and restore views for *.c files: >
au BufWinEnter *.c silent! loadview
==============================================================================
-8. The ShaDa file *shada* *shada-file*
+Shada ("shared data") file *shada* *shada-file*
If you exit Vim and later start it again, you would normally lose a lot of
information. The ShaDa file can be used to remember that information, which
@@ -1358,7 +1324,7 @@ file when reading and include:
complete MessagePack object.
==============================================================================
-9. Standard Paths *standard-path*
+Standard Paths *standard-path*
Nvim stores configuration and data in standard locations. Plugins are strongly
encouraged to follow this pattern also. Use |stdpath()| to get the paths.
@@ -1389,4 +1355,5 @@ debugging, plugins and RPC clients. >
Usually the file is ~/.local/share/nvim/log unless that path is inaccessible
or if $NVIM_LOG_FILE was set before |startup|.
+
vim:noet:tw=78:ts=8:ft=help:norl:
diff --git a/runtime/doc/ui.txt b/runtime/doc/ui.txt
index 2817c1015b..e5c6b9b1b7 100644
--- a/runtime/doc/ui.txt
+++ b/runtime/doc/ui.txt
@@ -183,9 +183,9 @@ the editor.
'ambiwidth'
'emoji'
'guifont'
- 'guifontset'
'guifontwide'
'linespace'
+ 'mousefocus'
'pumblend'
'showtabline'
'termguicolors'
@@ -719,7 +719,7 @@ events, which the UI must handle.
kind
Name indicating the message kind:
- "" (empty) Unknown, report a |feature-request|
+ "" (empty) Unknown (consider a feature-request: |bugs|)
"confirm" |confirm()| or |:confirm| dialog
"confirm_sub" |:substitute| confirm dialog |:s_c|
"emsg" Error (|errors|, internal error, |:throw|, …)
diff --git a/runtime/doc/usr_02.txt b/runtime/doc/usr_02.txt
index 9ebbd11ac7..c8fd7c3e35 100644
--- a/runtime/doc/usr_02.txt
+++ b/runtime/doc/usr_02.txt
@@ -652,7 +652,7 @@ Summary: *help-summary* >
22) Autocommand events can be found by their name: >
:help BufWinLeave
< To see all possible events: >
- :help autocommand-events
+ :help events
23) Command-line switches always start with "-". So for the help of the -f
command switch of Vim use: >
diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt
index a7e040bc93..4bcea3e3fe 100644
--- a/runtime/doc/vim_diff.txt
+++ b/runtime/doc/vim_diff.txt
@@ -13,7 +13,7 @@ the differences.
Type |gO| to see the table of contents.
==============================================================================
-1. Configuration *nvim-configuration*
+1. Configuration *nvim-config*
- Use `$XDG_CONFIG_HOME/nvim/init.vim` instead of `.vimrc` for configuration.
- Use `$XDG_CONFIG_HOME/nvim` instead of `.vim` to store configuration files.
@@ -66,8 +66,8 @@ the differences.
- 'wildmenu' is enabled
- 'wildoptions' defaults to "pum,tagfile"
-- The |man.vim| plugin is enabled, to provide the |:Man| command.
-- The |matchit| plugin is enabled. To disable it in your config: >
+- |man.vim| plugin is enabled, so |:Man| is available by default.
+- |matchit| plugin is enabled. To disable it in your config: >
:let loaded_matchit = 1
==============================================================================
@@ -173,6 +173,7 @@ Functions:
|msgpackdump()|, |msgpackparse()| provide msgpack de/serialization
|stdpath()|
|system()|, |systemlist()| can run {cmd} directly (without 'shell')
+ |tabpagenr()| "#" argument
Highlight groups:
|highlight-blend| controls blend level for a highlight group
@@ -187,18 +188,18 @@ Highlight groups:
|hl-TermCursorNC|
|hl-Whitespace| highlights 'listchars' whitespace
-Input:
+Input/Mappings:
+ |<Cmd>| pseudokey
+
ALT (|META|) chords always work (even in the |TUI|). Map |<M-| with any key:
<M-1>, <M-BS>, <M-Del>, <M-Ins>, <M-/>, <M-\>, <M-Space>, <M-Enter>, etc.
Case-sensitive: <M-a> and <M-A> are two different keycodes.
ALT in insert-mode behaves like <Esc> if not mapped. |i_ALT|
-Mappings:
- |<Cmd>| pseudokey
-
Normal commands:
- "Outline": Type |gO| in |:Man| and |:help| pages to see a document outline.
+ |g<Tab>| goes to the last-accessed tabpage.
+ |gO| shows a filetype-defined "outline" of the current buffer.
Options:
'cpoptions' flags: |cpo-_|
@@ -407,7 +408,6 @@ Some legacy Vim features are not implemented:
- |if_lua|: Nvim Lua API is not compatible with Vim's "if_lua"
- *if_mzscheme*
-- *if_perl*
- |if_py|: *python-bindeval* *python-Function* are not supported
- *if_tcl*
@@ -472,6 +472,7 @@ Options:
'encoding' ("utf-8" is always used)
'esckeys'
'guioptions' "t" flag was removed
+ *'guifontset'* *'gfs'* (Use 'guifont' instead.)
*'guipty'* (Nvim uses pipes and PTYs consistently on all platforms.)
'highlight' (Names of builtin |highlight-groups| cannot be changed.)
*'imactivatefunc'* *'imaf'*
diff --git a/runtime/filetype.vim b/runtime/filetype.vim
index 41a9188905..32bd6daba0 100644
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -236,10 +236,10 @@ au BufNewFile,BufRead */etc/blkid.tab,*/etc/blkid.tab.old setf xml
au BufNewFile,BufRead *bsd,*.bsdl setf bsdl
" Bazel (http://bazel.io)
-autocmd BufRead,BufNewFile *.bzl,WORKSPACE,BUILD.bazel setf bzl
+autocmd BufRead,BufNewFile *.bzl,*.bazel,WORKSPACE setf bzl
if has("fname_case")
" There is another check for BUILD further below.
- autocmd BufRead,BufNewFile BUILD setf bzl
+ autocmd BufRead,BufNewFile *.BUILD,BUILD setf bzl
endif
" C or lpc
@@ -2041,7 +2041,7 @@ au BufNewFile,BufRead bzr_log.* setf bzr
" Bazel build file
if !has("fname_case")
- au BufNewFile,BufRead BUILD setf bzl
+ au BufNewFile,BufRead *.BUILD,BUILD setf bzl
endif
" BIND zone
diff --git a/runtime/lua/vim/highlight.lua b/runtime/lua/vim/highlight.lua
index ce0a3de520..705b34dc99 100644
--- a/runtime/lua/vim/highlight.lua
+++ b/runtime/lua/vim/highlight.lua
@@ -14,7 +14,7 @@ function highlight.range(bufnr, ns, higroup, start, finish, rtype, inclusive)
inclusive = inclusive or false
-- sanity check
- if start[2] < 0 or finish[2] < start[2] then return end
+ if start[2] < 0 or finish[1] < start[1] then return end
local region = vim.region(bufnr, start, finish, rtype, inclusive)
for linenr, cols in pairs(region) do
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua
index 47dca40208..585528dd5a 100644
--- a/runtime/lua/vim/lsp.lua
+++ b/runtime/lua/vim/lsp.lua
@@ -761,8 +761,12 @@ do
text_document_did_change_handler = function(_, bufnr, changedtick,
firstline, lastline, new_lastline, old_byte_size, old_utf32_size,
old_utf16_size)
- local _ = log.debug() and log.debug("on_lines", bufnr, changedtick, firstline,
- lastline, new_lastline, old_byte_size, old_utf32_size, old_utf16_size, nvim_buf_get_lines(bufnr, firstline, new_lastline, true))
+
+ local _ = log.debug() and log.debug(
+ string.format("on_lines bufnr: %s, changedtick: %s, firstline: %s, lastline: %s, new_lastline: %s, old_byte_size: %s, old_utf32_size: %s, old_utf16_size: %s",
+ bufnr, changedtick, firstline, lastline, new_lastline, old_byte_size, old_utf32_size, old_utf16_size),
+ nvim_buf_get_lines(bufnr, firstline, new_lastline, true)
+ )
-- Don't do anything if there are no clients attached.
if tbl_isempty(all_buffer_active_clients[bufnr] or {}) then
@@ -922,7 +926,7 @@ end
--- To stop all clients:
---
--- <pre>
---- vim.lsp.stop_client(lsp.get_active_clients())
+--- vim.lsp.stop_client(vim.lsp.get_active_clients())
--- </pre>
---
--- By default asks the server to shutdown, unless stop was requested
diff --git a/runtime/lua/vim/lsp/rpc.lua b/runtime/lua/vim/lsp/rpc.lua
index 680e1ba6ae..64080cf4f2 100644
--- a/runtime/lua/vim/lsp/rpc.lua
+++ b/runtime/lua/vim/lsp/rpc.lua
@@ -376,7 +376,6 @@ local function start(cmd, cmd_args, handlers, extra_spawn_params)
--@param params (table): Parameters for the invoked LSP method
--@returns (bool) `true` if notification could be sent, `false` if not
local function notify(method, params)
- local _ = log.debug() and log.debug("rpc.notify", method, params)
return encode_and_send {
jsonrpc = "2.0";
method = method;
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua
index 3ec7311d65..24cb454e5b 100644
--- a/runtime/lua/vim/lsp/util.lua
+++ b/runtime/lua/vim/lsp/util.lua
@@ -299,10 +299,9 @@ end
---
--@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_completion
local function sort_completion_items(items)
- if items[1] and items[1].sortText then
- table.sort(items, function(a, b) return a.sortText < b.sortText
- end)
- end
+ table.sort(items, function(a, b)
+ return (a.sortText or a.label) < (b.sortText or b.label)
+ end)
end
--@private
@@ -1438,6 +1437,9 @@ local function make_position_param()
local row, col = unpack(api.nvim_win_get_cursor(0))
row = row - 1
local line = api.nvim_buf_get_lines(0, row, row+1, true)[1]
+ if not line then
+ return { line = 0; character = 0; }
+ end
col = str_utfindex(line, col)
return { line = row; character = col; }
end
diff --git a/runtime/lua/vim/shared.lua b/runtime/lua/vim/shared.lua
index 6e427665f2..5c89c63f7b 100644
--- a/runtime/lua/vim/shared.lua
+++ b/runtime/lua/vim/shared.lua
@@ -190,10 +190,10 @@ function vim.tbl_contains(t, value)
return false
end
--- Returns true if the table is empty, and contains no indexed or keyed values.
---
---@see From https://github.com/premake/premake-core/blob/master/src/base/table.lua
---
+--- Checks if a table is empty.
+---
+--@see https://github.com/premake/premake-core/blob/master/src/base/table.lua
+---
--@param t Table to check
function vim.tbl_isempty(t)
assert(type(t) == 'table', string.format("Expected table, got %s", type(t)))
@@ -347,13 +347,11 @@ function vim.tbl_flatten(t)
return result
end
---- Determine whether a Lua table can be treated as an array.
+--- Tests if a Lua table can be treated as an array.
---
---- An empty table `{}` will default to being treated as an array.
---- Use `vim.emtpy_dict()` to create a table treated as an
---- empty dict. Empty tables returned by `rpcrequest()` and
---- `vim.fn` functions can be checked using this function
---- whether they represent empty API arrays and vimL lists.
+--- Empty table `{}` is assumed to be an array, unless it was created by
+--- |vim.empty_dict()| or returned as a dict-like |API| or Vimscript result,
+--- for example from |rpcrequest()| or |vim.fn|.
---
--@param t Table
--@returns `true` if array-like table, else `false`.
diff --git a/runtime/lua/vim/treesitter.lua b/runtime/lua/vim/treesitter.lua
index 550dee1e3f..3a475b8f98 100644
--- a/runtime/lua/vim/treesitter.lua
+++ b/runtime/lua/vim/treesitter.lua
@@ -33,16 +33,23 @@ function Parser:parse()
return self.tree, changes
end
-function Parser:_on_lines(bufnr, changed_tick, start_row, old_stop_row, stop_row, old_byte_size)
- local start_byte = a.nvim_buf_get_offset(bufnr,start_row)
- local stop_byte = a.nvim_buf_get_offset(bufnr,stop_row)
- local old_stop_byte = start_byte + old_byte_size
- self._parser:edit(start_byte,old_stop_byte,stop_byte,
- start_row,0,old_stop_row,0,stop_row,0)
+function Parser:_on_bytes(bufnr, changed_tick,
+ start_row, start_col, start_byte,
+ old_row, old_col, old_byte,
+ new_row, new_col, new_byte)
+ local old_end_col = old_col + ((old_row == 0) and start_col or 0)
+ local new_end_col = new_col + ((new_row == 0) and start_col or 0)
+ self._parser:edit(start_byte,start_byte+old_byte,start_byte+new_byte,
+ start_row, start_col,
+ start_row+old_row, old_end_col,
+ start_row+new_row, new_end_col)
self.valid = false
- for _, cb in ipairs(self.lines_cbs) do
- cb(bufnr, changed_tick, start_row, old_stop_row, stop_row, old_byte_size)
+ for _, cb in ipairs(self.bytes_cbs) do
+ cb(bufnr, changed_tick,
+ start_row, start_col, start_byte,
+ old_row, old_col, old_byte,
+ new_row, new_col, new_byte)
end
end
@@ -88,12 +95,12 @@ function M._create_parser(bufnr, lang, id)
local self = setmetatable({bufnr=bufnr, lang=lang, valid=false}, Parser)
self._parser = vim._create_ts_parser(lang)
self.changedtree_cbs = {}
- self.lines_cbs = {}
+ self.bytes_cbs = {}
self:parse()
- -- TODO(bfredl): use weakref to self, so that the parser is free'd is no plugin is
- -- using it.
- local function lines_cb(_, ...)
- return self:_on_lines(...)
+ -- TODO(bfredl): use weakref to self, so that the parser is free'd is no plugin is
+ -- using it.
+ local function bytes_cb(_, ...)
+ return self:_on_bytes(...)
end
local detach_cb = nil
if id ~= nil then
@@ -103,7 +110,7 @@ function M._create_parser(bufnr, lang, id)
end
end
end
- a.nvim_buf_attach(self.bufnr, false, {on_lines=lines_cb, on_detach=detach_cb})
+ a.nvim_buf_attach(self.bufnr, false, {on_bytes=bytes_cb, on_detach=detach_cb})
return self
end
@@ -138,8 +145,8 @@ function M.get_parser(bufnr, lang, buf_attach_cbs)
table.insert(parsers[id].changedtree_cbs, buf_attach_cbs.on_changedtree)
end
- if buf_attach_cbs and buf_attach_cbs.on_lines then
- table.insert(parsers[id].lines_cbs, buf_attach_cbs.on_lines)
+ if buf_attach_cbs and buf_attach_cbs.on_bytes then
+ table.insert(parsers[id].bytes_cbs, buf_attach_cbs.on_bytes)
end
return parsers[id]
diff --git a/runtime/lua/vim/treesitter/highlighter.lua b/runtime/lua/vim/treesitter/highlighter.lua
index 681d2c6324..718088e0ad 100644
--- a/runtime/lua/vim/treesitter/highlighter.lua
+++ b/runtime/lua/vim/treesitter/highlighter.lua
@@ -60,14 +60,11 @@ function TSHighlighter.new(query, bufnr, ft)
ft,
{
on_changedtree = function(...) self:on_changedtree(...) end,
- on_lines = function() self.root = self.parser:parse():root() end
+ on_bytes = function() self.parser:parse() end
}
)
self.buf = self.parser.bufnr
-
- local tree = self.parser:parse()
- self.root = tree:root()
self:set_query(query)
self.edit_count = 0
self.redraw_count = 0
@@ -98,7 +95,8 @@ function TSHighlighter:get_hl_from_capture(capture)
return vim.split(name, '.', true)[1]
else
-- Default to false to avoid recomputing
- return TSHighlighter.hl_map[name]
+ local hl = TSHighlighter.hl_map[name]
+ return hl and a.nvim_get_hl_id_by_name(hl) or 0
end
end
@@ -125,27 +123,25 @@ function TSHighlighter:set_query(query)
end
})
- self:on_changedtree({{self.root:range()}})
+ self:on_changedtree({{self.parser:parse():root():range()}})
end
function TSHighlighter:on_changedtree(changes)
-- Get a fresh root
- self.root = self.parser.tree:root()
+ local root = self.parser:parse():root()
for _, ch in ipairs(changes or {}) do
- -- Try to be as exact as possible
- local changed_node = self.root:descendant_for_range(ch[1], ch[2], ch[3], ch[4])
-
- a.nvim_buf_clear_namespace(self.buf, ts_hs_ns, ch[1], ch[3])
+ a.nvim_buf_clear_namespace(self.buf, ts_hs_ns, ch[1], ch[3]+1)
- for capture, node in self.query:iter_captures(changed_node, self.buf, ch[1], ch[3] + 1) do
+ for capture, node in self.query:iter_captures(root, self.buf, ch[1], ch[3] + 1) do
local start_row, start_col, end_row, end_col = node:range()
local hl = self.hl_cache[capture]
if hl then
- a.nvim__buf_add_decoration(self.buf, ts_hs_ns, hl,
- start_row, start_col,
- end_row, end_col,
- {})
+ a.nvim_buf_set_extmark(self.buf, ts_hs_ns, start_row, start_col, {
+ end_col = end_col,
+ end_line = end_row,
+ hl_group = hl
+ })
end
end
end
diff --git a/runtime/lua/vim/treesitter/query.lua b/runtime/lua/vim/treesitter/query.lua
index 17f61b24f1..ca27a50c6a 100644
--- a/runtime/lua/vim/treesitter/query.lua
+++ b/runtime/lua/vim/treesitter/query.lua
@@ -17,7 +17,7 @@ local M = {}
function M.parse_query(lang, query)
language.require_language(lang)
local self = setmetatable({}, Query)
- self.query = vim._ts_parse_query(lang, vim.fn.escape(query,'\\'))
+ self.query = vim._ts_parse_query(lang, query)
self.info = self.query:inspect()
self.captures = self.info.captures
return self
@@ -60,7 +60,7 @@ local predicate_handlers = {
return true
end,
- ["match?"] = function(match, _, bufnr, predicate)
+ ["lua-match?"] = function(match, _, bufnr, predicate)
local node = match[predicate[2]]
local regex = predicate[3]
local start_row, _, end_row, _ = node:range()
@@ -71,7 +71,7 @@ local predicate_handlers = {
return string.find(M.get_node_text(node, bufnr), regex)
end,
- ["vim-match?"] = (function()
+ ["match?"] = (function()
local magic_prefixes = {['\\v']=true, ['\\m']=true, ['\\M']=true, ['\\V']=true}
local function check_magic(str)
if string.len(str) < 2 or magic_prefixes[string.sub(str,1,2)] then
@@ -82,7 +82,7 @@ local predicate_handlers = {
local compiled_vim_regexes = setmetatable({}, {
__index = function(t, pattern)
- local res = vim.regex(check_magic(pattern))
+ local res = vim.regex(check_magic(vim.fn.escape(pattern, '\\')))
rawset(t, pattern, res)
return res
end
@@ -114,6 +114,9 @@ local predicate_handlers = {
end
}
+-- As we provide lua-match? also expose vim-match?
+predicate_handlers["vim-match?"] = predicate_handlers["match?"]
+
--- Adds a new predicates to be used in queries
--
-- @param name the name of the predicate, without leading #
@@ -127,25 +130,43 @@ function M.add_predicate(name, handler, force)
predicate_handlers[name] = handler
end
+--- Returns the list of currently supported predicates
+function M.list_predicates()
+ return vim.tbl_keys(predicate_handlers)
+end
+
+local function xor(x, y)
+ return (x or y) and not (x and y)
+end
+
function Query:match_preds(match, pattern, bufnr)
local preds = self.info.patterns[pattern]
- if not preds then
- return true
- end
- for _, pred in pairs(preds) do
+
+ for _, pred in pairs(preds or {}) do
-- Here we only want to return if a predicate DOES NOT match, and
-- continue on the other case. This way unknown predicates will not be considered,
-- which allows some testing and easier user extensibility (#12173).
-- Also, tree-sitter strips the leading # from predicates for us.
+ local pred_name
+ local is_not
if string.sub(pred[1], 1, 4) == "not-" then
- local pred_name = string.sub(pred[1], 5)
- if predicate_handlers[pred_name] and
- predicate_handlers[pred_name](match, pattern, bufnr, pred) then
- return false
- end
+ pred_name = string.sub(pred[1], 5)
+ is_not = true
+ else
+ pred_name = pred[1]
+ is_not = false
+ end
+
+ local handler = predicate_handlers[pred_name]
+
+ if not handler then
+ a.nvim_err_writeln(string.format("No handler for %s", pred[1]))
+ return false
+ end
+
+ local pred_matches = handler(match, pattern, bufnr, pred)
- elseif predicate_handlers[pred[1]] and
- not predicate_handlers[pred[1]](match, pattern, bufnr, pred) then
+ if not xor(is_not, pred_matches) then
return false
end
end