aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/autoload/zip.vim36
-rw-r--r--runtime/doc/api.txt975
-rw-r--r--runtime/doc/autocmd.txt5
-rw-r--r--runtime/doc/eval.txt13
-rw-r--r--runtime/doc/helphelp.txt20
-rw-r--r--runtime/doc/if_pyth.txt5
-rw-r--r--runtime/doc/lsp.txt146
-rw-r--r--runtime/doc/lua.txt44
-rw-r--r--runtime/doc/map.txt3
-rw-r--r--runtime/doc/options.txt7
-rw-r--r--runtime/doc/pi_zip.txt3
-rw-r--r--runtime/doc/treesitter.txt8
-rw-r--r--runtime/doc/usr_20.txt8
-rw-r--r--runtime/doc/vim_diff.txt1
-rw-r--r--runtime/filetype.vim2
-rw-r--r--runtime/ftplugin/aap.vim13
-rw-r--r--runtime/ftplugin/diff.vim11
-rw-r--r--runtime/ftplugin/lua.vim38
-rw-r--r--runtime/ftplugin/routeros.vim29
-rw-r--r--runtime/ftplugin/zimbu.vim61
-rw-r--r--runtime/lua/vim/diagnostic.lua234
-rw-r--r--runtime/lua/vim/lsp.lua97
-rw-r--r--runtime/lua/vim/lsp/diagnostic.lua2
-rw-r--r--runtime/lua/vim/lsp/handlers.lua5
-rw-r--r--runtime/lua/vim/lsp/sync.lua74
-rw-r--r--runtime/lua/vim/lsp/tagfunc.lua76
-rw-r--r--runtime/lua/vim/lsp/util.lua12
-rw-r--r--runtime/lua/vim/uri.lua28
-rw-r--r--runtime/pack/dist/opt/matchit/doc/matchit.txt4
-rw-r--r--runtime/pack/dist/opt/termdebug/plugin/termdebug.vim4
-rw-r--r--runtime/plugin/zipPlugin.vim2
-rw-r--r--runtime/syntax/autoit.vim3
-rw-r--r--runtime/syntax/gdb.vim13
-rw-r--r--runtime/syntax/gnuplot.vim41
-rw-r--r--runtime/syntax/lisp.vim26
-rw-r--r--runtime/syntax/routeros.vim91
-rw-r--r--runtime/syntax/tcl.vim20
-rw-r--r--runtime/syntax/vim.vim9
38 files changed, 1281 insertions, 888 deletions
diff --git a/runtime/autoload/zip.vim b/runtime/autoload/zip.vim
index 9588bbf4a2..bc9b62ddb0 100644
--- a/runtime/autoload/zip.vim
+++ b/runtime/autoload/zip.vim
@@ -1,7 +1,7 @@
" zip.vim: Handles browsing zipfiles
" AUTOLOAD PORTION
-" Date: Jan 07, 2020
-" Version: 31
+" Date: Nov 08, 2021
+" Version: 32
" Maintainer: Charles E Campbell <NcampObell@SdrPchip.AorgM-NOSPAM>
" License: Vim License (see vim's :help license)
" Copyright: Copyright (C) 2005-2019 Charles E. Campbell {{{1
@@ -20,7 +20,7 @@
if &cp || exists("g:loaded_zip")
finish
endif
-let g:loaded_zip= "v31"
+let g:loaded_zip= "v32"
if v:version < 702
echohl WarningMsg
echo "***warning*** this version of zip needs vim 7.2 or later"
@@ -115,7 +115,13 @@ fun! zip#Browse(zipfile)
setlocal bufhidden=hide
setlocal nobuflisted
setlocal nowrap
- set ft=tar
+
+ " Oct 12, 2021: need to re-use Bram's syntax/tar.vim.
+ " Setting the filetype to zip doesn't do anything (currently),
+ " but it is perhaps less confusing to curious perusers who do
+ " a :echo &ft
+ setf zip
+ run! syntax/tar.vim
" give header
call append(0, ['" zip.vim version '.g:loaded_zip,
@@ -187,8 +193,8 @@ fun! s:ZipBrowseSelect()
wincmd _
endif
let s:zipfile_{winnr()}= curfile
-" call Decho("exe e ".fnameescape("zipfile:".zipfile.'::'.fname))
- exe "noswapfile e ".fnameescape("zipfile:".zipfile.'::'.fname)
+" call Decho("exe e ".fnameescape("zipfile://".zipfile.'::'.fname))
+ exe "noswapfile e ".fnameescape("zipfile://".zipfile.'::'.fname)
filetype detect
let &report= repkeep
@@ -203,11 +209,11 @@ fun! zip#Read(fname,mode)
set report=10
if has("unix")
- let zipfile = substitute(a:fname,'zipfile:\(.\{-}\)::[^\\].*$','\1','')
- let fname = substitute(a:fname,'zipfile:.\{-}::\([^\\].*\)$','\1','')
+ let zipfile = substitute(a:fname,'zipfile://\(.\{-}\)::[^\\].*$','\1','')
+ let fname = substitute(a:fname,'zipfile://.\{-}::\([^\\].*\)$','\1','')
else
- let zipfile = substitute(a:fname,'^.\{-}zipfile:\(.\{-}\)::[^\\].*$','\1','')
- let fname = substitute(a:fname,'^.\{-}zipfile:.\{-}::\([^\\].*\)$','\1','')
+ let zipfile = substitute(a:fname,'^.\{-}zipfile://\(.\{-}\)::[^\\].*$','\1','')
+ let fname = substitute(a:fname,'^.\{-}zipfile://.\{-}::\([^\\].*\)$','\1','')
let fname = substitute(fname, '[', '[[]', 'g')
endif
" call Decho("zipfile<".zipfile.">")
@@ -224,7 +230,7 @@ fun! zip#Read(fname,mode)
" the following code does much the same thing as
" exe "keepj sil! r! ".g:zip_unzipcmd." -p -- ".s:Escape(zipfile,1)." ".s:Escape(fnameescape(fname),1)
- " but allows zipfile:... entries in quickfix lists
+ " but allows zipfile://... entries in quickfix lists
let temp = tempname()
" call Decho("using temp file<".temp.">")
let fn = expand('%:p')
@@ -296,11 +302,11 @@ fun! zip#Write(fname)
" call Decho("current directory now: ".getcwd())
if has("unix")
- let zipfile = substitute(a:fname,'zipfile:\(.\{-}\)::[^\\].*$','\1','')
- let fname = substitute(a:fname,'zipfile:.\{-}::\([^\\].*\)$','\1','')
+ let zipfile = substitute(a:fname,'zipfile://\(.\{-}\)::[^\\].*$','\1','')
+ let fname = substitute(a:fname,'zipfile://.\{-}::\([^\\].*\)$','\1','')
else
- let zipfile = substitute(a:fname,'^.\{-}zipfile:\(.\{-}\)::[^\\].*$','\1','')
- let fname = substitute(a:fname,'^.\{-}zipfile:.\{-}::\([^\\].*\)$','\1','')
+ let zipfile = substitute(a:fname,'^.\{-}zipfile://\(.\{-}\)::[^\\].*$','\1','')
+ let fname = substitute(a:fname,'^.\{-}zipfile://.\{-}::\([^\\].*\)$','\1','')
endif
" call Decho("zipfile<".zipfile.">")
" call Decho("fname <".fname.">")
diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt
index bb8e83f84a..166fef028d 100644
--- a/runtime/doc/api.txt
+++ b/runtime/doc/api.txt
@@ -652,35 +652,6 @@ nvim_call_atomic({calls}) *nvim_call_atomic()*
occurred, the values from all preceding calls will still
be returned.
- *nvim_call_dict_function()*
-nvim_call_dict_function({dict}, {fn}, {args})
- Calls a VimL |Dictionary-function| with the given arguments.
-
- On execution error: fails with VimL error, does not update
- v:errmsg.
-
- Parameters: ~
- {dict} Dictionary, or String evaluating to a VimL |self|
- dict
- {fn} Name of the function defined on the VimL dict
- {args} Function arguments packed in an Array
-
- Return: ~
- Result of the function call
-
-nvim_call_function({fn}, {args}) *nvim_call_function()*
- Calls a VimL function with the given arguments.
-
- On execution error: fails with VimL error, does not update
- v:errmsg.
-
- Parameters: ~
- {fn} Function to call
- {args} Function arguments packed in an Array
-
- Return: ~
- Result of the function call
-
nvim_chan_send({chan}, {data}) *nvim_chan_send()*
Send data to channel `id` . For a job, it writes it to the
stdin of the process. For the stdio channel |channel-stdio|,
@@ -697,18 +668,6 @@ nvim_chan_send({chan}, {data}) *nvim_chan_send()*
{chan} id of the channel
{data} data to write. 8-bit clean: can contain NUL bytes.
-nvim_command({command}) *nvim_command()*
- Executes an ex-command.
-
- On execution error: fails with VimL error, does not update
- v:errmsg.
-
- Parameters: ~
- {command} Ex-command string
-
- See also: ~
- |nvim_exec()|
-
nvim_create_buf({listed}, {scratch}) *nvim_create_buf()*
Creates a new, empty, unnamed buffer.
@@ -724,22 +683,6 @@ nvim_create_buf({listed}, {scratch}) *nvim_create_buf()*
See also: ~
buf_open_scratch
-nvim_create_namespace({name}) *nvim_create_namespace()*
- Creates a new *namespace* or gets an existing one.
-
- Namespaces are used for buffer highlights and virtual text,
- see |nvim_buf_add_highlight()| and |nvim_buf_set_extmark()|.
-
- Namespaces can be named or anonymous. If `name` matches an
- existing namespace, the associated id is returned. If `name`
- is an empty string a new, anonymous namespace is created.
-
- Parameters: ~
- {name} Namespace name or empty string
-
- Return: ~
- Namespace id
-
nvim_del_current_line() *nvim_del_current_line()*
Deletes the current line.
@@ -806,19 +749,6 @@ nvim_err_writeln({str}) *nvim_err_writeln()*
See also: ~
nvim_err_write()
-nvim_eval({expr}) *nvim_eval()*
- Evaluates a VimL |expression|. Dictionaries and Lists are
- recursively expanded.
-
- On execution error: fails with VimL error, does not update
- v:errmsg.
-
- Parameters: ~
- {expr} VimL expression string
-
- Return: ~
- Evaluation result or expanded object
-
nvim_eval_statusline({str}, {*opts}) *nvim_eval_statusline()*
Evaluates statusline string.
@@ -852,29 +782,6 @@ nvim_eval_statusline({str}, {*opts}) *nvim_eval_statusline()*
character that uses the highlight.
• group: (string) Name of highlight group.
-nvim_exec({src}, {output}) *nvim_exec()*
- Executes Vimscript (multiline block of Ex-commands), like
- anonymous |:source|.
-
- Unlike |nvim_command()| this function supports heredocs,
- script-scope (s:), etc.
-
- On execution error: fails with VimL error, does not update
- v:errmsg.
-
- Parameters: ~
- {src} Vimscript code
- {output} Capture and return all (non-error, non-shell
- |:!|) output
-
- Return: ~
- Output (non-error, non-shell |:!|) if `output` is true,
- else empty string.
-
- See also: ~
- |execute()|
- |nvim_command()|
-
nvim_exec_lua({code}, {args}) *nvim_exec_lua()*
Execute Lua code. Parameters (if any) are available as `...`
inside the chunk. The chunk can return a value.
@@ -1110,12 +1017,6 @@ nvim_get_mode() *nvim_get_mode()*
Attributes: ~
{fast}
-nvim_get_namespaces() *nvim_get_namespaces()*
- Gets existing, non-anonymous namespaces.
-
- Return: ~
- dict that maps from names to namespace ids.
-
nvim_get_option({name}) *nvim_get_option()*
Gets an option value string.
@@ -1344,7 +1245,15 @@ nvim_open_term({buffer}, {opts}) *nvim_open_term()*
Parameters: ~
{buffer} the buffer to use (expected to be empty)
- {opts} Optional parameters. Reserved for future use.
+ {opts} Optional parameters.
+ • on_input: lua callback for input sent, i e
+ keypresses in terminal mode. Note: keypresses
+ are sent raw as they would be to the pty
+ master end. For instance, a carriage return is
+ sent as a "\r", not as a "\n". |textlock|
+ applies. It is possible to call
+ |nvim_chan_send| directly in the callback
+ however. ["input", term, bufnr, data]
Return: ~
Channel id, or 0 on error
@@ -1357,104 +1266,6 @@ nvim_out_write({str}) *nvim_out_write()*
Parameters: ~
{str} Message
- *nvim_parse_expression()*
-nvim_parse_expression({expr}, {flags}, {highlight})
- Parse a VimL expression.
-
- Attributes: ~
- {fast}
-
- Parameters: ~
- {expr} Expression to parse. Always treated as a
- single line.
- {flags} Flags:
- • "m" if multiple expressions in a row are
- allowed (only the first one will be
- parsed),
- • "E" if EOC tokens are not allowed
- (determines whether they will stop parsing
- process or be recognized as an
- operator/space, though also yielding an
- error).
- • "l" when needing to start parsing with
- lvalues for ":let" or ":for". Common flag
- sets:
- • "m" to parse like for ":echo".
- • "E" to parse like for "<C-r>=".
- • empty string for ":call".
- • "lm" to parse for ":let".
- {highlight} If true, return value will also include
- "highlight" key containing array of 4-tuples
- (arrays) (Integer, Integer, Integer, String),
- where first three numbers define the
- highlighted region and represent line,
- starting column and ending column (latter
- exclusive: one should highlight region
- [start_col, end_col)).
-
- Return: ~
-
- • AST: top-level dictionary with these keys:
- • "error": Dictionary with error, present only if parser
- saw some error. Contains the following keys:
- • "message": String, error message in printf format,
- translated. Must contain exactly one "%.*s".
- • "arg": String, error message argument.
-
- • "len": Amount of bytes successfully parsed. With flags
- equal to "" that should be equal to the length of expr
- string. (“Successfully parsed” here means
- “participated in AST creation”, not “till the first
- error”.)
- • "ast": AST, either nil or a dictionary with these
- keys:
- • "type": node type, one of the value names from
- ExprASTNodeType stringified without "kExprNode"
- prefix.
- • "start": a pair [line, column] describing where node
- is "started" where "line" is always 0 (will not be 0
- if you will be using nvim_parse_viml() on e.g.
- ":let", but that is not present yet). Both elements
- are Integers.
- • "len": “length” of the node. This and "start" are
- there for debugging purposes primary (debugging
- parser and providing debug information).
- • "children": a list of nodes described in top/"ast".
- There always is zero, one or two children, key will
- not be present if node has no children. Maximum
- number of children may be found in node_maxchildren
- array.
-
- • Local values (present only for certain nodes):
- • "scope": a single Integer, specifies scope for
- "Option" and "PlainIdentifier" nodes. For "Option" it
- is one of ExprOptScope values, for "PlainIdentifier"
- it is one of ExprVarScope values.
- • "ident": identifier (without scope, if any), present
- for "Option", "PlainIdentifier", "PlainKey" and
- "Environment" nodes.
- • "name": Integer, register name (one character) or -1.
- Only present for "Register" nodes.
- • "cmp_type": String, comparison type, one of the value
- names from ExprComparisonType, stringified without
- "kExprCmp" prefix. Only present for "Comparison"
- nodes.
- • "ccs_strategy": String, case comparison strategy, one
- of the value names from ExprCaseCompareStrategy,
- stringified without "kCCStrategy" prefix. Only present
- for "Comparison" nodes.
- • "augmentation": String, augmentation type for
- "Assignment" nodes. Is either an empty string, "Add",
- "Subtract" or "Concat" for "=", "+=", "-=" or ".="
- respectively.
- • "invert": Boolean, true if result of comparison needs
- to be inverted. Only present for "Comparison" nodes.
- • "ivalue": Integer, integer value for "Integer" nodes.
- • "fvalue": Float, floating-point value for "Float"
- nodes.
- • "svalue": String, value for "SingleQuotedString" and
- "DoubleQuotedString" nodes.
-
nvim_paste({data}, {crlf}, {phase}) *nvim_paste()*
Pastes at cursor, in any mode.
@@ -1650,53 +1461,6 @@ nvim_set_current_win({window}) *nvim_set_current_win()*
Parameters: ~
{window} Window handle
- *nvim_set_decoration_provider()*
-nvim_set_decoration_provider({ns_id}, {opts})
- Set or change decoration provider for a namespace
-
- This is a very general purpose interface for having lua
- callbacks being triggered during the redraw code.
-
- The expected usage is to set extmarks for the currently
- redrawn buffer. |nvim_buf_set_extmark| can be called to add
- marks on a per-window or per-lines basis. Use the `ephemeral`
- key to only use the mark for the current screen redraw (the
- callback will be called again for the next redraw ).
-
- Note: this function should not be called often. Rather, the
- callbacks themselves can be used to throttle unneeded
- callbacks. the `on_start` callback can return `false` to
- disable the provider until the next redraw. Similarly, return
- `false` in `on_win` will skip the `on_lines` calls for that
- window (but any extmarks set in `on_win` will still be used).
- A plugin managing multiple sources of decoration should
- ideally only set one provider, and merge the sources
- internally. You can use multiple `ns_id` for the extmarks
- set/modified inside the callback anyway.
-
- Note: doing anything other than setting extmarks is considered
- experimental. Doing things like changing options are not
- expliticly forbidden, but is likely to have unexpected
- consequences (such as 100% CPU consumption). doing
- `vim.rpcnotify` should be OK, but `vim.rpcrequest` is quite
- dubious for the moment.
-
- Parameters: ~
- {ns_id} Namespace id from |nvim_create_namespace()|
- {opts} Callbacks invoked during redraw:
- • on_start: called first on each screen redraw
- ["start", tick]
- • on_buf: called for each buffer being redrawn
- (before window callbacks) ["buf", bufnr, tick]
- • on_win: called when starting to redraw a
- specific window. ["win", winid, bufnr, topline,
- botline_guess]
- • on_line: called for each buffer line being
- redrawn. (The interation with fold lines is
- subject to change) ["win", winid, bufnr, row]
- • on_end: called at the end of a redraw cycle
- ["end", tick]
-
nvim_set_hl({ns_id}, {name}, {val}) *nvim_set_hl()*
Set a highlight group.
@@ -1790,6 +1554,185 @@ nvim_unsubscribe({event}) *nvim_unsubscribe()*
==============================================================================
+Vimscript Functions *api-vimscript*
+
+ *nvim_call_dict_function()*
+nvim_call_dict_function({dict}, {fn}, {args})
+ Calls a VimL |Dictionary-function| with the given arguments.
+
+ On execution error: fails with VimL error, does not update
+ v:errmsg.
+
+ Parameters: ~
+ {dict} Dictionary, or String evaluating to a VimL |self|
+ dict
+ {fn} Name of the function defined on the VimL dict
+ {args} Function arguments packed in an Array
+
+ Return: ~
+ Result of the function call
+
+nvim_call_function({fn}, {args}) *nvim_call_function()*
+ Calls a VimL function with the given arguments.
+
+ On execution error: fails with VimL error, does not update
+ v:errmsg.
+
+ Parameters: ~
+ {fn} Function to call
+ {args} Function arguments packed in an Array
+
+ Return: ~
+ Result of the function call
+
+nvim_command({command}) *nvim_command()*
+ Executes an ex-command.
+
+ On execution error: fails with VimL error, does not update
+ v:errmsg.
+
+ Parameters: ~
+ {command} Ex-command string
+
+ See also: ~
+ |nvim_exec()|
+
+nvim_eval({expr}) *nvim_eval()*
+ Evaluates a VimL |expression|. Dictionaries and Lists are
+ recursively expanded.
+
+ On execution error: fails with VimL error, does not update
+ v:errmsg.
+
+ Parameters: ~
+ {expr} VimL expression string
+
+ Return: ~
+ Evaluation result or expanded object
+
+nvim_exec({src}, {output}) *nvim_exec()*
+ Executes Vimscript (multiline block of Ex-commands), like
+ anonymous |:source|.
+
+ Unlike |nvim_command()| this function supports heredocs,
+ script-scope (s:), etc.
+
+ On execution error: fails with VimL error, does not update
+ v:errmsg.
+
+ Parameters: ~
+ {src} Vimscript code
+ {output} Capture and return all (non-error, non-shell
+ |:!|) output
+
+ Return: ~
+ Output (non-error, non-shell |:!|) if `output` is true,
+ else empty string.
+
+ See also: ~
+ |execute()|
+ |nvim_command()|
+
+ *nvim_parse_expression()*
+nvim_parse_expression({expr}, {flags}, {highlight})
+ Parse a VimL expression.
+
+ Attributes: ~
+ {fast}
+
+ Parameters: ~
+ {expr} Expression to parse. Always treated as a
+ single line.
+ {flags} Flags:
+ • "m" if multiple expressions in a row are
+ allowed (only the first one will be
+ parsed),
+ • "E" if EOC tokens are not allowed
+ (determines whether they will stop parsing
+ process or be recognized as an
+ operator/space, though also yielding an
+ error).
+ • "l" when needing to start parsing with
+ lvalues for ":let" or ":for". Common flag
+ sets:
+ • "m" to parse like for ":echo".
+ • "E" to parse like for "<C-r>=".
+ • empty string for ":call".
+ • "lm" to parse for ":let".
+ {highlight} If true, return value will also include
+ "highlight" key containing array of 4-tuples
+ (arrays) (Integer, Integer, Integer, String),
+ where first three numbers define the
+ highlighted region and represent line,
+ starting column and ending column (latter
+ exclusive: one should highlight region
+ [start_col, end_col)).
+
+ Return: ~
+
+ • AST: top-level dictionary with these keys:
+ • "error": Dictionary with error, present only if parser
+ saw some error. Contains the following keys:
+ • "message": String, error message in printf format,
+ translated. Must contain exactly one "%.*s".
+ • "arg": String, error message argument.
+
+ • "len": Amount of bytes successfully parsed. With flags
+ equal to "" that should be equal to the length of expr
+ string. (“Successfully parsed” here means
+ “participated in AST creation”, not “till the first
+ error”.)
+ • "ast": AST, either nil or a dictionary with these
+ keys:
+ • "type": node type, one of the value names from
+ ExprASTNodeType stringified without "kExprNode"
+ prefix.
+ • "start": a pair [line, column] describing where node
+ is "started" where "line" is always 0 (will not be 0
+ if you will be using nvim_parse_viml() on e.g.
+ ":let", but that is not present yet). Both elements
+ are Integers.
+ • "len": “length” of the node. This and "start" are
+ there for debugging purposes primary (debugging
+ parser and providing debug information).
+ • "children": a list of nodes described in top/"ast".
+ There always is zero, one or two children, key will
+ not be present if node has no children. Maximum
+ number of children may be found in node_maxchildren
+ array.
+
+ • Local values (present only for certain nodes):
+ • "scope": a single Integer, specifies scope for
+ "Option" and "PlainIdentifier" nodes. For "Option" it
+ is one of ExprOptScope values, for "PlainIdentifier"
+ it is one of ExprVarScope values.
+ • "ident": identifier (without scope, if any), present
+ for "Option", "PlainIdentifier", "PlainKey" and
+ "Environment" nodes.
+ • "name": Integer, register name (one character) or -1.
+ Only present for "Register" nodes.
+ • "cmp_type": String, comparison type, one of the value
+ names from ExprComparisonType, stringified without
+ "kExprCmp" prefix. Only present for "Comparison"
+ nodes.
+ • "ccs_strategy": String, case comparison strategy, one
+ of the value names from ExprCaseCompareStrategy,
+ stringified without "kCCStrategy" prefix. Only present
+ for "Comparison" nodes.
+ • "augmentation": String, augmentation type for
+ "Assignment" nodes. Is either an empty string, "Add",
+ "Subtract" or "Concat" for "=", "+=", "-=" or ".="
+ respectively.
+ • "invert": Boolean, true if result of comparison needs
+ to be inverted. Only present for "Comparison" nodes.
+ • "ivalue": Integer, integer value for "Integer" nodes.
+ • "fvalue": Float, floating-point value for "Float"
+ nodes.
+ • "svalue": String, value for "SingleQuotedString" and
+ "DoubleQuotedString" nodes.
+
+
+==============================================================================
Buffer Functions *api-buffer*
@@ -1815,48 +1758,6 @@ nvim__buf_redraw_range({buffer}, {first}, {last})
nvim__buf_stats({buffer}) *nvim__buf_stats()*
TODO: Documentation
- *nvim_buf_add_highlight()*
-nvim_buf_add_highlight({buffer}, {ns_id}, {hl_group}, {line}, {col_start},
- {col_end})
- Adds a highlight to buffer.
-
- Useful for plugins that dynamically generate highlights to a
- buffer (like a semantic highlighter or linter). The function
- adds a single highlight to a buffer. Unlike |matchaddpos()|
- highlights follow changes to line numbering (as lines are
- inserted/removed above the highlighted line), like signs and
- 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` .
-
- 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.
-
- Parameters: ~
- {buffer} Buffer handle, or 0 for current buffer
- {ns_id} namespace to use or -1 for ungrouped
- highlight
- {hl_group} Name of the highlight group to use
- {line} Line to highlight (zero-indexed)
- {col_start} Start of (byte-indexed) column range to
- highlight
- {col_end} End of (byte-indexed) column range to
- highlight, or -1 to highlight to end of line
-
- Return: ~
- The ns_id that was used
-
nvim_buf_attach({buffer}, {send_buffer}, {opts}) *nvim_buf_attach()*
Activates buffer-update events on a channel, or as Lua
callbacks.
@@ -1965,33 +1866,6 @@ nvim_buf_call({buffer}, {fun}) *nvim_buf_call()*
Return value of function. NB: will deepcopy lua values
currently, use upvalues to send lua references in and out.
- *nvim_buf_clear_namespace()*
-nvim_buf_clear_namespace({buffer}, {ns_id}, {line_start}, {line_end})
- Clears namespaced objects (highlights, extmarks, virtual text)
- from a region.
-
- Lines are 0-indexed. |api-indexing| To clear the namespace in
- the entire buffer, specify line_start=0 and line_end=-1.
-
- Parameters: ~
- {buffer} Buffer handle, or 0 for current buffer
- {ns_id} Namespace to clear, or -1 to clear all
- namespaces.
- {line_start} Start of range of lines to clear
- {line_end} End of range of lines to clear (exclusive)
- or -1 to clear to end of buffer.
-
-nvim_buf_del_extmark({buffer}, {ns_id}, {id}) *nvim_buf_del_extmark()*
- Removes an extmark.
-
- Parameters: ~
- {buffer} Buffer handle, or 0 for current buffer
- {ns_id} Namespace id from |nvim_create_namespace()|
- {id} Extmark id
-
- Return: ~
- true if the extmark was found, else false
-
nvim_buf_del_keymap({buffer}, {mode}, {lhs}) *nvim_buf_del_keymap()*
Unmaps a buffer-local |mapping| for the given mode.
@@ -2073,73 +1947,6 @@ nvim_buf_get_commands({buffer}, {*opts}) *nvim_buf_get_commands()*
Return: ~
Map of maps describing commands.
- *nvim_buf_get_extmark_by_id()*
-nvim_buf_get_extmark_by_id({buffer}, {ns_id}, {id}, {opts})
- Gets the position (0-indexed) of an extmark.
-
- Parameters: ~
- {buffer} Buffer handle, or 0 for current buffer
- {ns_id} Namespace id from |nvim_create_namespace()|
- {id} Extmark id
- {opts} Optional parameters. Keys:
- • details: Whether to include the details dict
-
- Return: ~
- 0-indexed (row, col) tuple or empty list () if extmark id
- was absent
-
- *nvim_buf_get_extmarks()*
-nvim_buf_get_extmarks({buffer}, {ns_id}, {start}, {end}, {opts})
- Gets extmarks in "traversal order" from a |charwise| region
- defined by buffer positions (inclusive, 0-indexed
- |api-indexing|).
-
- Region can be given as (row,col) tuples, or valid extmark ids
- (whose positions define the bounds). 0 and -1 are understood
- as (0,0) and (-1,-1) respectively, thus the following are
- equivalent:
->
- nvim_buf_get_extmarks(0, my_ns, 0, -1, {})
- nvim_buf_get_extmarks(0, my_ns, [0,0], [-1,-1], {})
-<
-
- If `end` is less than `start` , traversal works backwards.
- (Useful with `limit` , to get the first marks prior to a given
- position.)
-
- Example:
->
- local a = vim.api
- local pos = a.nvim_win_get_cursor(0)
- local ns = a.nvim_create_namespace('my-plugin')
- -- Create new extmark at line 1, column 1.
- local m1 = a.nvim_buf_set_extmark(0, ns, 0, 0, 0, {})
- -- Create new extmark at line 3, column 1.
- local m2 = a.nvim_buf_set_extmark(0, ns, 0, 2, 0, {})
- -- Get extmarks only from line 3.
- local ms = a.nvim_buf_get_extmarks(0, ns, {2,0}, {2,0}, {})
- -- Get all marks in this buffer + namespace.
- local all = a.nvim_buf_get_extmarks(0, ns, 0, -1, {})
- print(vim.inspect(ms))
-<
-
- Parameters: ~
- {buffer} Buffer handle, or 0 for current buffer
- {ns_id} Namespace id from |nvim_create_namespace()|
- {start} Start of range: a 0-indexed (row, col) or valid
- extmark id (whose position defines the bound).
- |api-indexing|
- {end} End of range (inclusive): a 0-indexed (row, col)
- or valid extmark id (whose position defines the
- bound). |api-indexing|
- {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
- order".
-
nvim_buf_get_keymap({buffer}, {mode}) *nvim_buf_get_keymap()*
Gets a list of buffer-local |mapping| definitions.
@@ -2270,6 +2077,257 @@ nvim_buf_line_count({buffer}) *nvim_buf_line_count()*
Return: ~
Line count, or 0 for unloaded buffer. |api-buffer|
+ *nvim_buf_set_keymap()*
+nvim_buf_set_keymap({buffer}, {mode}, {lhs}, {rhs}, {*opts})
+ Sets a buffer-local |mapping| for the given mode.
+
+ Parameters: ~
+ {buffer} Buffer handle, or 0 for current buffer
+
+ See also: ~
+ |nvim_set_keymap()|
+
+ *nvim_buf_set_lines()*
+nvim_buf_set_lines({buffer}, {start}, {end}, {strict_indexing}, {replacement})
+ Sets (replaces) a line-range in the buffer.
+
+ Indexing is zero-based, end-exclusive. Negative indices are
+ interpreted as length+1+index: -1 refers to the index past the
+ end. So to change or delete the last element use start=-2 and
+ end=-1.
+
+ To insert lines at a given index, set `start` and `end` to the
+ same index. To delete a range of lines, set `replacement` to
+ an empty array.
+
+ Out-of-bounds indices are clamped to the nearest valid value,
+ unless `strict_indexing` is set.
+
+ Attributes: ~
+ not allowed when |textlock| is active
+
+ Parameters: ~
+ {buffer} Buffer handle, or 0 for current buffer
+ {start} First line index
+ {end} Last line index (exclusive)
+ {strict_indexing} Whether out-of-bounds should be an
+ error.
+ {replacement} Array of lines to use as replacement
+
+ *nvim_buf_set_mark()*
+nvim_buf_set_mark({buffer}, {name}, {line}, {col}, {opts})
+ Sets a named mark in the given buffer, all marks are allowed
+ file/uppercase, visual, last change, etc. See |mark-motions|.
+
+ Marks are (1,0)-indexed. |api-indexing|
+
+ Note:
+ Passing 0 as line deletes the mark
+
+ Parameters: ~
+ {buffer} Buffer to set the mark on
+ {name} Mark name
+ {line} Line number
+ {col} Column/row number
+ {opts} Optional parameters. Reserved for future use.
+
+ Return: ~
+ true if the mark was set, else false.
+
+ See also: ~
+ |nvim_buf_del_mark()|
+ |nvim_buf_get_mark()|
+
+nvim_buf_set_name({buffer}, {name}) *nvim_buf_set_name()*
+ Sets the full file name for a buffer
+
+ Parameters: ~
+ {buffer} Buffer handle, or 0 for current buffer
+ {name} Buffer name
+
+nvim_buf_set_option({buffer}, {name}, {value}) *nvim_buf_set_option()*
+ Sets a buffer option value. Passing 'nil' as value deletes the
+ option (only works if there's a global fallback)
+
+ Parameters: ~
+ {buffer} Buffer handle, or 0 for current buffer
+ {name} Option name
+ {value} Option value
+
+ *nvim_buf_set_text()*
+nvim_buf_set_text({buffer}, {start_row}, {start_col}, {end_row}, {end_col},
+ {replacement})
+ Sets (replaces) a range in the buffer
+
+ This is recommended over nvim_buf_set_lines when only
+ modifying parts of a line, as extmarks will be preserved on
+ non-modified parts of the touched lines.
+
+ Indexing is zero-based and end-exclusive.
+
+ To insert text at a given index, set `start` and `end` ranges
+ to the same index. To delete a range, set `replacement` to an
+ array containing an empty string, or simply an empty array.
+
+ Prefer nvim_buf_set_lines when adding or deleting entire lines
+ only.
+
+ Parameters: ~
+ {buffer} Buffer handle, or 0 for current buffer
+ {start_row} First line index
+ {start_column} Last column
+ {end_row} Last line index
+ {end_column} Last column
+ {replacement} Array of lines to use as replacement
+
+nvim_buf_set_var({buffer}, {name}, {value}) *nvim_buf_set_var()*
+ Sets a buffer-scoped (b:) variable
+
+ Parameters: ~
+ {buffer} Buffer handle, or 0 for current buffer
+ {name} Variable name
+ {value} Variable value
+
+
+==============================================================================
+Extmark Functions *api-extmark*
+
+ *nvim_buf_add_highlight()*
+nvim_buf_add_highlight({buffer}, {ns_id}, {hl_group}, {line}, {col_start},
+ {col_end})
+ Adds a highlight to buffer.
+
+ Useful for plugins that dynamically generate highlights to a
+ buffer (like a semantic highlighter or linter). The function
+ adds a single highlight to a buffer. Unlike |matchaddpos()|
+ highlights follow changes to line numbering (as lines are
+ inserted/removed above the highlighted line), like signs and
+ 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` .
+
+ 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.
+
+ Parameters: ~
+ {buffer} Buffer handle, or 0 for current buffer
+ {ns_id} namespace to use or -1 for ungrouped
+ highlight
+ {hl_group} Name of the highlight group to use
+ {line} Line to highlight (zero-indexed)
+ {col_start} Start of (byte-indexed) column range to
+ highlight
+ {col_end} End of (byte-indexed) column range to
+ highlight, or -1 to highlight to end of line
+
+ Return: ~
+ The ns_id that was used
+
+ *nvim_buf_clear_namespace()*
+nvim_buf_clear_namespace({buffer}, {ns_id}, {line_start}, {line_end})
+ Clears namespaced objects (highlights, extmarks, virtual text)
+ from a region.
+
+ Lines are 0-indexed. |api-indexing| To clear the namespace in
+ the entire buffer, specify line_start=0 and line_end=-1.
+
+ Parameters: ~
+ {buffer} Buffer handle, or 0 for current buffer
+ {ns_id} Namespace to clear, or -1 to clear all
+ namespaces.
+ {line_start} Start of range of lines to clear
+ {line_end} End of range of lines to clear (exclusive)
+ or -1 to clear to end of buffer.
+
+nvim_buf_del_extmark({buffer}, {ns_id}, {id}) *nvim_buf_del_extmark()*
+ Removes an extmark.
+
+ Parameters: ~
+ {buffer} Buffer handle, or 0 for current buffer
+ {ns_id} Namespace id from |nvim_create_namespace()|
+ {id} Extmark id
+
+ Return: ~
+ true if the extmark was found, else false
+
+ *nvim_buf_get_extmark_by_id()*
+nvim_buf_get_extmark_by_id({buffer}, {ns_id}, {id}, {opts})
+ Gets the position (0-indexed) of an extmark.
+
+ Parameters: ~
+ {buffer} Buffer handle, or 0 for current buffer
+ {ns_id} Namespace id from |nvim_create_namespace()|
+ {id} Extmark id
+ {opts} Optional parameters. Keys:
+ • details: Whether to include the details dict
+
+ Return: ~
+ 0-indexed (row, col) tuple or empty list () if extmark id
+ was absent
+
+ *nvim_buf_get_extmarks()*
+nvim_buf_get_extmarks({buffer}, {ns_id}, {start}, {end}, {opts})
+ Gets extmarks in "traversal order" from a |charwise| region
+ defined by buffer positions (inclusive, 0-indexed
+ |api-indexing|).
+
+ Region can be given as (row,col) tuples, or valid extmark ids
+ (whose positions define the bounds). 0 and -1 are understood
+ as (0,0) and (-1,-1) respectively, thus the following are
+ equivalent:
+>
+ nvim_buf_get_extmarks(0, my_ns, 0, -1, {})
+ nvim_buf_get_extmarks(0, my_ns, [0,0], [-1,-1], {})
+<
+
+ If `end` is less than `start` , traversal works backwards.
+ (Useful with `limit` , to get the first marks prior to a given
+ position.)
+
+ Example:
+>
+ local a = vim.api
+ local pos = a.nvim_win_get_cursor(0)
+ local ns = a.nvim_create_namespace('my-plugin')
+ -- Create new extmark at line 1, column 1.
+ local m1 = a.nvim_buf_set_extmark(0, ns, 0, 0, 0, {})
+ -- Create new extmark at line 3, column 1.
+ local m2 = a.nvim_buf_set_extmark(0, ns, 0, 2, 0, {})
+ -- Get extmarks only from line 3.
+ local ms = a.nvim_buf_get_extmarks(0, ns, {2,0}, {2,0}, {})
+ -- Get all marks in this buffer + namespace.
+ local all = a.nvim_buf_get_extmarks(0, ns, 0, -1, {})
+ print(vim.inspect(ms))
+<
+
+ Parameters: ~
+ {buffer} Buffer handle, or 0 for current buffer
+ {ns_id} Namespace id from |nvim_create_namespace()|
+ {start} Start of range: a 0-indexed (row, col) or valid
+ extmark id (whose position defines the bound).
+ |api-indexing|
+ {end} End of range (inclusive): a 0-indexed (row, col)
+ or valid extmark id (whose position defines the
+ bound). |api-indexing|
+ {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
+ order".
+
*nvim_buf_set_extmark()*
nvim_buf_set_extmark({buffer}, {ns_id}, {line}, {col}, {*opts})
Creates or updates an extmark.
@@ -2351,12 +2409,7 @@ nvim_buf_set_extmark({buffer}, {ns_id}, {line}, {col}, {*opts})
of the array. However the 'tabstop' buffer
option is still used for hard tabs. By default
lines are placed below the buffer line
- containing the mark. • Note: currently virtual lines are limited to
- one block per buffer. Thus setting a new mark
- disables any previous `virt_lines` decoration.
- However plugins should not rely on this
- behaviour, as this limitation is planned to be
- removed.
+ containing the mark.
• virt_lines_above: place virtual lines above
instead.
• virt_lines_leftcol: Place extmarks in the
@@ -2383,116 +2436,74 @@ nvim_buf_set_extmark({buffer}, {ns_id}, {line}, {col}, {*opts})
Return: ~
Id of the created/updated extmark
- *nvim_buf_set_keymap()*
-nvim_buf_set_keymap({buffer}, {mode}, {lhs}, {rhs}, {*opts})
- Sets a buffer-local |mapping| for the given mode.
-
- Parameters: ~
- {buffer} Buffer handle, or 0 for current buffer
-
- See also: ~
- |nvim_set_keymap()|
-
- *nvim_buf_set_lines()*
-nvim_buf_set_lines({buffer}, {start}, {end}, {strict_indexing}, {replacement})
- Sets (replaces) a line-range in the buffer.
-
- Indexing is zero-based, end-exclusive. Negative indices are
- interpreted as length+1+index: -1 refers to the index past the
- end. So to change or delete the last element use start=-2 and
- end=-1.
-
- To insert lines at a given index, set `start` and `end` to the
- same index. To delete a range of lines, set `replacement` to
- an empty array.
-
- Out-of-bounds indices are clamped to the nearest valid value,
- unless `strict_indexing` is set.
-
- Attributes: ~
- not allowed when |textlock| is active
-
- Parameters: ~
- {buffer} Buffer handle, or 0 for current buffer
- {start} First line index
- {end} Last line index (exclusive)
- {strict_indexing} Whether out-of-bounds should be an
- error.
- {replacement} Array of lines to use as replacement
-
- *nvim_buf_set_mark()*
-nvim_buf_set_mark({buffer}, {name}, {line}, {col}, {opts})
- Sets a named mark in the given buffer, all marks are allowed
- file/uppercase, visual, last change, etc. See |mark-motions|.
+nvim_create_namespace({name}) *nvim_create_namespace()*
+ Creates a new *namespace* or gets an existing one.
- Marks are (1,0)-indexed. |api-indexing|
+ Namespaces are used for buffer highlights and virtual text,
+ see |nvim_buf_add_highlight()| and |nvim_buf_set_extmark()|.
- Note:
- Passing 0 as line deletes the mark
+ Namespaces can be named or anonymous. If `name` matches an
+ existing namespace, the associated id is returned. If `name`
+ is an empty string a new, anonymous namespace is created.
Parameters: ~
- {buffer} Buffer to set the mark on
- {name} Mark name
- {line} Line number
- {col} Column/row number
- {opts} Optional parameters. Reserved for future use.
+ {name} Namespace name or empty string
Return: ~
- true if the mark was set, else false.
-
- See also: ~
- |nvim_buf_del_mark()|
- |nvim_buf_get_mark()|
-
-nvim_buf_set_name({buffer}, {name}) *nvim_buf_set_name()*
- Sets the full file name for a buffer
-
- Parameters: ~
- {buffer} Buffer handle, or 0 for current buffer
- {name} Buffer name
-
-nvim_buf_set_option({buffer}, {name}, {value}) *nvim_buf_set_option()*
- Sets a buffer option value. Passing 'nil' as value deletes the
- option (only works if there's a global fallback)
-
- Parameters: ~
- {buffer} Buffer handle, or 0 for current buffer
- {name} Option name
- {value} Option value
+ Namespace id
- *nvim_buf_set_text()*
-nvim_buf_set_text({buffer}, {start_row}, {start_col}, {end_row}, {end_col},
- {replacement})
- Sets (replaces) a range in the buffer
+nvim_get_namespaces() *nvim_get_namespaces()*
+ Gets existing, non-anonymous namespaces.
- This is recommended over nvim_buf_set_lines when only
- modifying parts of a line, as extmarks will be preserved on
- non-modified parts of the touched lines.
+ Return: ~
+ dict that maps from names to namespace ids.
- Indexing is zero-based and end-exclusive.
+ *nvim_set_decoration_provider()*
+nvim_set_decoration_provider({ns_id}, {opts})
+ Set or change decoration provider for a namespace
- To insert text at a given index, set `start` and `end` ranges
- to the same index. To delete a range, set `replacement` to an
- array containing an empty string, or simply an empty array.
+ This is a very general purpose interface for having lua
+ callbacks being triggered during the redraw code.
- Prefer nvim_buf_set_lines when adding or deleting entire lines
- only.
+ The expected usage is to set extmarks for the currently
+ redrawn buffer. |nvim_buf_set_extmark| can be called to add
+ marks on a per-window or per-lines basis. Use the `ephemeral`
+ key to only use the mark for the current screen redraw (the
+ callback will be called again for the next redraw ).
- Parameters: ~
- {buffer} Buffer handle, or 0 for current buffer
- {start_row} First line index
- {start_column} Last column
- {end_row} Last line index
- {end_column} Last column
- {replacement} Array of lines to use as replacement
+ Note: this function should not be called often. Rather, the
+ callbacks themselves can be used to throttle unneeded
+ callbacks. the `on_start` callback can return `false` to
+ disable the provider until the next redraw. Similarly, return
+ `false` in `on_win` will skip the `on_lines` calls for that
+ window (but any extmarks set in `on_win` will still be used).
+ A plugin managing multiple sources of decoration should
+ ideally only set one provider, and merge the sources
+ internally. You can use multiple `ns_id` for the extmarks
+ set/modified inside the callback anyway.
-nvim_buf_set_var({buffer}, {name}, {value}) *nvim_buf_set_var()*
- Sets a buffer-scoped (b:) variable
+ Note: doing anything other than setting extmarks is considered
+ experimental. Doing things like changing options are not
+ expliticly forbidden, but is likely to have unexpected
+ consequences (such as 100% CPU consumption). doing
+ `vim.rpcnotify` should be OK, but `vim.rpcrequest` is quite
+ dubious for the moment.
Parameters: ~
- {buffer} Buffer handle, or 0 for current buffer
- {name} Variable name
- {value} Variable value
+ {ns_id} Namespace id from |nvim_create_namespace()|
+ {opts} Callbacks invoked during redraw:
+ • on_start: called first on each screen redraw
+ ["start", tick]
+ • on_buf: called for each buffer being redrawn
+ (before window callbacks) ["buf", bufnr, tick]
+ • on_win: called when starting to redraw a
+ specific window. ["win", winid, bufnr, topline,
+ botline_guess]
+ • on_line: called for each buffer line being
+ redrawn. (The interation with fold lines is
+ subject to change) ["win", winid, bufnr, row]
+ • on_end: called at the end of a redraw cycle
+ ["end", tick]
==============================================================================
diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt
index 6c41dd3b10..2737ac9b9f 100644
--- a/runtime/doc/autocmd.txt
+++ b/runtime/doc/autocmd.txt
@@ -1002,8 +1002,9 @@ VimResume After Nvim resumes from |suspend| state.
*VimSuspend*
VimSuspend Before Nvim enters |suspend| state.
*WinClosed*
-WinClosed After closing a window. <afile> expands to the
- |window-ID|.
+WinClosed After closing a window. The pattern is
+ matched against the |window-ID|. Both
+ <amatch> and <afile> are set to the |window-ID|.
After WinLeave.
Non-recursive (event cannot trigger itself).
See also |ExitPre|, |QuitPre|.
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 1b949d749c..58d5d30146 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -5001,11 +5001,11 @@ getcurpos() Get the position of the cursor. This is like getpos('.'), but
getcwd([{winnr}[, {tabnr}]]) *getcwd()*
With no arguments, returns the name of the effective
|current-directory|. With {winnr} or {tabnr} the working
- directory of that scope is returned.
+ directory of that scope is returned, and 'autochdir' is
+ ignored.
Tabs and windows are identified by their respective numbers,
- 0 means current tab or window. Missing argument implies 0.
+ 0 means current tab or window. Missing tab number implies 0.
Thus the following are equivalent: >
- getcwd()
getcwd(0)
getcwd(0, 0)
< If {winnr} is -1 it is ignored, only the tab is resolved.
@@ -5562,6 +5562,9 @@ getwininfo([{winid}]) *getwininfo()*
otherwise
wincol leftmost screen column of the window;
"col" from |win_screenpos()|
+ textoff number of columns occupied by any
+ 'foldcolumn', 'signcolumn' and line
+ number in front of the text
winid |window-ID|
winnr window number
winrow topmost screen line of the window;
@@ -10291,7 +10294,9 @@ wildmenumode() *wildmenumode()*
win_execute({id}, {command} [, {silent}]) *win_execute()*
Like `execute()` but in the context of window {id}.
The window will temporarily be made the current window,
- without triggering autocommands.
+ without triggering autocommands or changing directory. When
+ executing {command} autocommands will be triggered, this may
+ have unexpected side effects. Use |:noautocmd| if needed.
Example: >
call win_execute(winid, 'syntax enable')
diff --git a/runtime/doc/helphelp.txt b/runtime/doc/helphelp.txt
index aaa2a35fe1..c884eea54f 100644
--- a/runtime/doc/helphelp.txt
+++ b/runtime/doc/helphelp.txt
@@ -319,21 +319,25 @@ Hints for translators:
3. Writing help files *help-writing*
For ease of use, a Vim help file for a plugin should follow the format of the
-standard Vim help files. If you are writing a new help file it's best to copy
-one of the existing files and use it as a template.
+standard Vim help files, except fot the fist line. If you are writing a new
+help file it's best to copy one of the existing files and use it as a
+template.
The first line in a help file should have the following format:
-*helpfile_name.txt* For Vim version 7.3 Last change: 2010 June 4
+*plugin_name.txt* {short description of the plugin}
-The first field is a link to the help file name. The second field describes
-the applicable Vim version. The last field specifies the last modification
-date of the file. Each field is separated by a tab.
+The first field is a help tag where ":help plugin_name" will jump to. The
+remainder of the line, after a Tab, describes the plugin purpose in a short
+way. This will show up in the "LOCAL ADDITIONS" section of the main help
+file. Check there that it shows up properly: |local-additions|.
+
+If you want to add a version number of last modification date, put it in the
+second line, right aligned.
At the bottom of the help file, place a Vim modeline to set the 'textwidth'
and 'tabstop' options and the 'filetype' to "help". Never set a global option
-in such a modeline, that can have consequences undesired by whoever reads that
-help.
+in such a modeline, that can have undesired consequences.
TAGS
diff --git a/runtime/doc/if_pyth.txt b/runtime/doc/if_pyth.txt
index dc46fa515a..fea47de220 100644
--- a/runtime/doc/if_pyth.txt
+++ b/runtime/doc/if_pyth.txt
@@ -45,6 +45,11 @@ To see what version of Python you have: >
There is no need to "import sys", it's done by default.
+ *python-environment*
+Environment variables set in Vim are not always available in Python. This
+depends on how Vim and Python were build. Also see
+https://docs.python.org/3/library/os.html#os.environ
+
Note: Python is very sensitive to indenting. Make sure the "class" line and
"EOF" do not have any indent.
diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt
index 83d201c23a..1e84402a9f 100644
--- a/runtime/doc/lsp.txt
+++ b/runtime/doc/lsp.txt
@@ -573,6 +573,9 @@ buf_request_sync({bufnr}, {method}, {params}, {timeout_ms})
error, returns `(nil, err)` where `err` is a string
describing the failure reason.
+check_clients_closed() *vim.lsp.check_clients_closed()*
+ TODO: Documentation
+
client() *vim.lsp.client*
LSP client object. You can get an active client object via
|vim.lsp.get_client_by_id()| or
@@ -628,11 +631,6 @@ client() *vim.lsp.client*
server.
• {handlers} (table): The handlers used by the client as
described in |lsp-handler|.
- • {requests} (table): The current pending requests in flight
- to the server. Entries are key-value pairs with the key
- being the request ID while the value is a table with `type`,
- `bufnr`, and `method` key-value pairs. `type` is either "pending"
- for an active request, or "cancel" for a cancel request.
• {config} (table): copy of the table that was passed by the
user to |vim.lsp.start_client()|.
• {server_capabilities} (table): Response from the server
@@ -657,6 +655,19 @@ flush({client}) *vim.lsp.flush()*
for_each_buffer_client({bufnr}, {fn})
TODO: Documentation
+formatexpr({opts}) *vim.lsp.formatexpr()*
+ Provides an interface between the built-in client and a
+ `formatexpr` function.
+
+ Currently only supports a single client. This can be set via `setlocal formatexpr=v:lua.vim.lsp.formatexpr()` but will typically or in `on_attach` via vim.api.nvim_buf_set_option(bufnr, 'formatexpr , 'v:lua.vim.lsp.formatexpr(#{timeout_ms:250})')`.
+
+ Parameters: ~
+ {opts} table options for customizing the formatting
+ expression which takes the following optional
+ keys:
+ • timeout_ms (default 500ms). The timeout period
+ for the formatting request.
+
get_active_clients() *vim.lsp.get_active_clients()*
Gets all active clients.
@@ -666,7 +677,7 @@ get_active_clients() *vim.lsp.get_active_clients()*
*vim.lsp.get_buffers_by_client_id()*
get_buffers_by_client_id({client_id})
Parameters: ~
- {client_id} client id
+ {client_id} number client id
Return: ~
list of buffer ids
@@ -676,7 +687,7 @@ get_client_by_id({client_id}) *vim.lsp.get_client_by_id()*
client may not yet be fully initialized.
Parameters: ~
- {client_id} client id number
+ {client_id} number client id
Return: ~
|vim.lsp.client| object, or nil
@@ -707,7 +718,7 @@ omnifunc({findstart}, {base}) *vim.lsp.omnifunc()*
|CompleteDone|
*vim.lsp.prepare()*
-prepare({bufnr}, {firstline}, {new_lastline}, {changedtick})
+prepare({bufnr}, {firstline}, {lastline}, {new_lastline}, {changedtick})
TODO: Documentation
reset({client_id}) *vim.lsp.reset()*
@@ -734,15 +745,12 @@ set_log_level({level}) *vim.lsp.set_log_level()*
start_client({config}) *vim.lsp.start_client()*
Starts and initializes a client with the given configuration.
- Parameters `cmd` and `root_dir` are required.
+ Parameter `cmd` is required.
The following parameters describe fields in the {config}
table.
Parameters: ~
- {root_dir} (string) Directory where the LSP
- server will base its rootUri on
- initialization.
{cmd} (required, string or list treated
like |jobstart()|) Base command that
initiates the LSP client.
@@ -757,6 +765,13 @@ start_client({config}) *vim.lsp.start_client()*
{ "PRODUCTION=true"; "TEST=123"; PORT = 8080; HOST = "0.0.0.0"; }
<
+ {workspace_folders} (table) List of workspace folders
+ passed to the language server. For
+ backwards compatibility rootUri and
+ rootPath will be derived from the
+ first workspace folder in this list.
+ See `workspaceFolders` in the LSP
+ spec.
{capabilities} Map overriding the default
capabilities defined by
|vim.lsp.protocol.make_client_capabilities()|,
@@ -776,15 +791,20 @@ start_client({config}) *vim.lsp.start_client()*
language server if requested via
`workspace/configuration` . Keys are
case-sensitive.
+ {commands} table Table that maps string of
+ clientside commands to user-defined
+ functions. Commands passed to
+ start_client take precedence over the
+ global command registry. Each key
+ must be a unique comand name, and the
+ value is a function which is called
+ if any LSP action (code action, code
+ lenses, ...) triggers the command.
{init_options} Values to pass in the initialization
request as `initializationOptions` .
See `initialize` in the LSP spec.
{name} (string, default=client-id) Name in
log messages.
- {workspace_folders} (table) List of workspace folders
- passed to the language server.
- Defaults to root_dir if not set. See
- `workspaceFolders` in the LSP spec
{get_language_id} function(bufnr, filetype) -> language
ID as string. Defaults to the
filetype.
@@ -851,6 +871,12 @@ start_client({config}) *vim.lsp.start_client()*
notifications to the server by the
given number in milliseconds. No
debounce occurs if nil
+ • exit_timeout (number, default 500):
+ Milliseconds to wait for server to
+ {root_dir} string Directory where the LSP server
+ will base its workspaceFolders,
+ rootUri, and rootPath on
+ initialization.
Return: ~
Client id. |vim.lsp.get_client_by_id()| Note: client may
@@ -876,6 +902,23 @@ stop_client({client_id}, {force}) *vim.lsp.stop_client()*
thereof
{force} boolean (optional) shutdown forcefully
+tagfunc({...}) *vim.lsp.tagfunc()*
+ Provides an interface between the built-in client and
+ 'tagfunc'.
+
+ When used with normal mode commands (e.g. |CTRL-]|) this will
+ invoke the "textDocument/definition" LSP method to find the
+ tag under the cursor. Otherwise, uses "workspace/symbol". If
+ no results are returned from any LSP servers, falls back to
+ using built-in tags.
+
+ Parameters: ~
+ {pattern} Pattern used to find a workspace symbol
+ {flags} See |tag-function|
+
+ Return: ~
+ A list of matching tags
+
with({handler}, {override_config}) *vim.lsp.with()*
Function to manage overriding defaults for LSP handlers.
@@ -1304,13 +1347,15 @@ buf_clear_references({bufnr}) *vim.lsp.util.buf_clear_references()*
{bufnr} buffer id
*vim.lsp.util.buf_highlight_references()*
-buf_highlight_references({bufnr}, {references})
+buf_highlight_references({bufnr}, {references}, {offset_encoding})
Shows a list of document highlights for a certain buffer.
Parameters: ~
- {bufnr} buffer id
- {references} List of `DocumentHighlight` objects to
- highlight
+ {bufnr} buffer id
+ {references} List of `DocumentHighlight` objects to
+ highlight
+ {offset_encoding} string utf-8|utf-16|utf-32|nil defaults
+ to utf-16
See also: ~
https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/#documentHighlight
@@ -1344,25 +1389,6 @@ close_preview_autocmd({events}, {winnr})
See also: ~
|autocmd-events|
- *vim.lsp.util.compute_diff()*
-compute_diff({old_lines}, {new_lines}, {start_line_idx}, {end_line_idx},
- {offset_encoding})
- Returns the range table for the difference between old and new
- lines
-
- Parameters: ~
- {old_lines} table list of lines
- {new_lines} table list of lines
- {start_line_idx} int line to begin search for first
- difference
- {end_line_idx} int line to begin search for last
- difference
- {offset_encoding} string encoding requested by language
- server
-
- Return: ~
- table start_line_idx and start_col_idx of range
-
*vim.lsp.util.convert_input_to_markdown_lines()*
convert_input_to_markdown_lines({input}, {contents})
Converts any of `MarkedString` | `MarkedString[]` |
@@ -1800,14 +1826,19 @@ notify({method}, {params}) *vim.lsp.rpc.notify()*
(bool) `true` if notification could be sent, `false` if
not
-request({method}, {params}, {callback}) *vim.lsp.rpc.request()*
+ *vim.lsp.rpc.request()*
+request({method}, {params}, {callback}, {notify_reply_callback})
Sends a request to the LSP server and runs {callback} upon
response.
Parameters: ~
- {method} (string) The invoked LSP method
- {params} (table) Parameters for the invoked LSP method
- {callback} (function) Callback to invoke
+ {method} (string) The invoked LSP method
+ {params} (table) Parameters for the
+ invoked LSP method
+ {callback} (function) Callback to invoke
+ {notify_reply_callback} (function) Callback to invoke as
+ soon as a request is no longer
+ pending
Return: ~
(bool, number) `(true, message_id)` if request could be
@@ -1862,6 +1893,35 @@ start({cmd}, {cmd_args}, {dispatchers}, {extra_spawn_params})
==============================================================================
+Lua module: vim.lsp.sync *lsp-sync*
+
+ *vim.lsp.sync.compute_diff()*
+compute_diff({prev_lines}, {curr_lines}, {firstline}, {lastline},
+ {new_lastline}, {offset_encoding}, {line_ending})
+ Returns the range table for the difference between prev and
+ curr lines
+
+ Parameters: ~
+ {prev_lines} table list of lines
+ {curr_lines} table list of lines
+ {firstline} number line to begin search for first
+ difference
+ {lastline} number line to begin search in
+ old_lines for last difference
+ {new_lastline} number line to begin search in
+ new_lines for last difference
+ {offset_encoding} string encoding requested by language
+ server
+
+ Return: ~
+ table TextDocumentContentChangeEvent see https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/#textDocumentContentChangeEvent
+
+ *vim.lsp.sync.compute_line_length()*
+compute_line_length({line}, {offset_encoding})
+ TODO: Documentation
+
+
+==============================================================================
Lua module: vim.lsp.protocol *lsp-protocol*
*vim.lsp.protocol.make_client_capabilities()*
diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt
index ef2d87949d..5e9189158a 100644
--- a/runtime/doc/lua.txt
+++ b/runtime/doc/lua.txt
@@ -1200,7 +1200,7 @@ inspect({object}, {options}) *vim.inspect()*
https://github.com/kikito/inspect.lua
https://github.com/mpeterv/vinspect
-make_dict_accessor({scope}) *vim.make_dict_accessor()*
+make_dict_accessor({scope}, {handle}) *vim.make_dict_accessor()*
TODO: Documentation
notify({msg}, {log_level}, {_opts}) *vim.notify()*
@@ -1617,14 +1617,12 @@ validate({opt}) *vim.validate()*
vim.validate{arg1={{'foo'}, 'table'}, arg2={'foo', 'string'}}
=> NOP (success)
-<
->
- vim.validate{arg1={1, 'table'}}
- => error('arg1: expected table, got number')
-<
->
- vim.validate{arg1={3, function(a) return (a % 2) == 0 end, 'even number'}}
- => error('arg1: expected even number, got 3')
+
+ vim.validate{arg1={1, 'table'}}
+ => error('arg1: expected table, got number')
+
+ vim.validate{arg1={3, function(a) return (a % 2) == 0 end, 'even number'}}
+ => error('arg1: expected even number, got 3')
<
Parameters: ~
@@ -1658,40 +1656,38 @@ uri_from_bufnr({bufnr}) *vim.uri_from_bufnr()*
Get a URI from a bufnr
Parameters: ~
- {bufnr} (number): Buffer number
+ {bufnr} number
Return: ~
- URI
+ string URI
uri_from_fname({path}) *vim.uri_from_fname()*
Get a URI from a file path.
Parameters: ~
- {path} (string): Path to file
+ {path} string Path to file
Return: ~
- URI
+ string URI
uri_to_bufnr({uri}) *vim.uri_to_bufnr()*
- Return or create a buffer for a uri.
+ Get the buffer for a uri. Creates a new unloaded buffer if no
+ buffer for the uri already exists.
Parameters: ~
- {uri} (string): The URI
+ {uri} string
Return: ~
- bufnr.
-
- Note:
- Creates buffer but does not load it
+ number bufnr
uri_to_fname({uri}) *vim.uri_to_fname()*
Get a filename from a URI
Parameters: ~
- {uri} (string): The URI
+ {uri} string
Return: ~
- Filename
+ string filename or unchanged URI for non-file URIs
==============================================================================
@@ -1731,6 +1727,12 @@ select({items}, {opts}, {on_choice}) *vim.ui.select()*
• format_item (function item -> text)
Function to format an individual item from
`items` . Defaults to `tostring` .
+ • kind (string|nil) Arbitrary hint string
+ indicating the item shape. Plugins
+ reimplementing `vim.ui.select` may wish to
+ use this to infer the structure or
+ semantics of `items` , or the context in
+ which select() was called.
{on_choice} function ((item|nil, idx|nil) -> ()) Called
once the user made a choice. `idx` is the
1-based index of `item` within `item` . `nil`
diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt
index 90d4c4de93..0b9ac42898 100644
--- a/runtime/doc/map.txt
+++ b/runtime/doc/map.txt
@@ -46,6 +46,8 @@ modes.
where the map command applies. The result, including
{rhs}, is then further scanned for mappings. This
allows for nested and recursive use of mappings.
+ Note: Trailing spaces are included in the {rhs},
+ because space is a valid Normal mode command.
*:nore* *:norem*
:no[remap] {lhs} {rhs} |mapmode-nvo| *:no* *:noremap* *:nor*
@@ -1419,6 +1421,7 @@ Possible values are (second column is the short name used in listing):
Special cases ~
*:command-bang* *:command-bar*
*:command-register* *:command-buffer*
+ *:command-keepscript*
There are some special cases as well:
-bang The command can take a ! modifier (like :q or :w)
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index 399a59251a..038808b760 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -3792,6 +3792,13 @@ A jump table for the options with a short description can be found at |Q_op|.
The characters ':' and ',' should not be used. UTF-8 characters can
be used. All characters must be single width.
+ Each character can be specified as hex: >
+ set listchars=eol:\\x24
+ set listchars=eol:\\u21b5
+ set listchars=eol:\\U000021b5
+< Note that a double backslash is used. The number of hex characters
+ must be exactly 2 for \\x, 4 for \\u and 8 for \\U.
+
Examples: >
:set lcs=tab:>-,trail:-
:set lcs=tab:>-,eol:<,nbsp:%
diff --git a/runtime/doc/pi_zip.txt b/runtime/doc/pi_zip.txt
index c715644847..2bbd6eea06 100644
--- a/runtime/doc/pi_zip.txt
+++ b/runtime/doc/pi_zip.txt
@@ -102,6 +102,9 @@ Copyright: Copyright (C) 2005-2015 Charles E Campbell *zip-copyright*
==============================================================================
4. History *zip-history* {{{1
+ v32 Oct 22, 2021 * to avoid an issue with a vim 8.2 patch, zipfile: has
+ been changed to zipfile:// . This often shows up
+ as zipfile:/// with zipped files that are root-based.
v29 Apr 02, 2017 * (Klartext) reported that an encrypted zip file could
opened but the swapfile held unencrypted contents.
The solution is to edit the contents of a zip file
diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt
index 441ae13df4..ac10aeec88 100644
--- a/runtime/doc/treesitter.txt
+++ b/runtime/doc/treesitter.txt
@@ -531,11 +531,9 @@ Query:iter_matches({self}, {node}, {source}, {start}, {stop})
for id, node in pairs(match) do
local name = query.captures[id]
-- `node` was captured by the `name` capture in the match
-<
->
- local node_data = metadata[id] -- Node level metadata
-<
->
+
+ local node_data = metadata[id] -- Node level metadata
+
... use the info here ...
end
end
diff --git a/runtime/doc/usr_20.txt b/runtime/doc/usr_20.txt
index 29252705d6..cff5c7d2f2 100644
--- a/runtime/doc/usr_20.txt
+++ b/runtime/doc/usr_20.txt
@@ -289,11 +289,11 @@ In chapter 3 we briefly mentioned the history. The basics are that you can
use the <Up> key to recall an older command line. <Down> then takes you back
to newer commands.
-There are actually four histories. The ones we will mention here are for ":"
+There are actually five histories. The ones we will mention here are for ":"
commands and for "/" and "?" search commands. The "/" and "?" commands share
-the same history, because they are both search commands. The two other
-histories are for expressions and input lines for the input() function.
-|cmdline-history|
+the same history, because they are both search commands. The three other
+histories are for expressions, debug more commands and input lines for the
+input() function. |cmdline-history|
Suppose you have done a ":set" command, typed ten more colon commands and then
want to repeat that ":set" command again. You could press ":" and then ten
diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt
index 77bf1d29eb..d88f4f42e8 100644
--- a/runtime/doc/vim_diff.txt
+++ b/runtime/doc/vim_diff.txt
@@ -186,7 +186,6 @@ Events:
|TermOpen|
|UIEnter|
|UILeave|
- |WinClosed|
Functions:
|dictwatcheradd()| notifies a callback whenever a |Dict| is modified
diff --git a/runtime/filetype.vim b/runtime/filetype.vim
index 13d8c72e76..1b48070128 100644
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -1,7 +1,7 @@
" Vim support file to detect file types
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
-" Last Change: 2021 Oct 03
+" Last Change: 2021 Nov 16
" Listen very carefully, I will say this only once
if exists("did_load_filetypes")
diff --git a/runtime/ftplugin/aap.vim b/runtime/ftplugin/aap.vim
index 9b20ec4766..b5065e5157 100644
--- a/runtime/ftplugin/aap.vim
+++ b/runtime/ftplugin/aap.vim
@@ -1,7 +1,7 @@
" Vim filetype plugin file
" Language: Aap recipe
" Maintainer: Bram Moolenaar <Bram@vim.org>
-" Last Change: 2013 Apr 05
+" Last Change: 2021 Nov 14
" Only do this when not done yet for this buffer
if exists("b:did_ftplugin")
@@ -11,8 +11,9 @@ endif
" Don't load another plugin for this buffer
let b:did_ftplugin = 1
-" Reset 'formatoptions', 'comments' and 'expandtab' to undo this plugin.
-let b:undo_ftplugin = "setl fo< com< et<"
+" Reset 'formatoptions', 'comments', 'commentstring' and 'expandtab' to undo
+" this plugin.
+let b:undo_ftplugin = "setl fo< com< cms< et<"
" Set 'formatoptions' to break comment lines but not other lines,
" and insert the comment leader when hitting <CR> or using "o".
@@ -20,6 +21,12 @@ setlocal fo-=t fo+=croql
" Set 'comments' to format dashed lists in comments.
setlocal comments=s:#\ -,m:#\ \ ,e:#,n:#,fb:-
+setlocal commentstring=#\ %s
" Expand tabs to spaces to avoid trouble.
setlocal expandtab
+
+if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
+ let b:browsefilter = "Aap Recipe Files (*.aap)\t*.aap\nAll Files (*.*)\t*.*\n"
+ let b:undo_ftplugin ..= " | unlet! b:browsefilter"
+endif
diff --git a/runtime/ftplugin/diff.vim b/runtime/ftplugin/diff.vim
index 0464290475..bf37d464c0 100644
--- a/runtime/ftplugin/diff.vim
+++ b/runtime/ftplugin/diff.vim
@@ -1,7 +1,7 @@
" Vim filetype plugin file
" Language: Diff
" Maintainer: Bram Moolenaar <Bram@vim.org>
-" Last Change: 2020 Jul 18
+" Last Change: 2021 Nov 14
" Only do this when not done yet for this buffer
if exists("b:did_ftplugin")
@@ -9,10 +9,15 @@ if exists("b:did_ftplugin")
endif
let b:did_ftplugin = 1
-let b:undo_ftplugin = "setl modeline<"
+let b:undo_ftplugin = "setl modeline< commentstring<"
" Don't use modelines in a diff, they apply to the diffed file
setlocal nomodeline
" If there are comments they start with #
-let &commentstring = "# %s"
+let &l:commentstring = "# %s"
+
+if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
+ let b:browsefilter = "Diff Files (*.diff)\t*.diff\nPatch Files (*.patch)\t*.h\nAll Files (*.*)\t*.*\n"
+ let b:undo_ftplugin ..= " | unlet! b:browsefilter"
+endif
diff --git a/runtime/ftplugin/lua.vim b/runtime/ftplugin/lua.vim
index 3454a4d694..2604257594 100644
--- a/runtime/ftplugin/lua.vim
+++ b/runtime/ftplugin/lua.vim
@@ -1,7 +1,8 @@
" Vim filetype plugin file.
-" Language: Lua 4.0+
-" Maintainer: Max Ischenko <mfi@ukr.net>
-" Last Change: 2012 Mar 07
+" Language: Lua
+" Maintainer: Doug Kearns <dougkearns@gmail.com>
+" Previous Maintainer: Max Ischenko <mfi@ukr.net>
+" Last Change: 2021 Nov 15
" Only do this when not done yet for this buffer
if exists("b:did_ftplugin")
@@ -16,27 +17,30 @@ set cpo&vim
" Set 'formatoptions' to break comment lines but not other lines, and insert
" the comment leader when hitting <CR> or using "o".
-setlocal fo-=t fo+=croql
+setlocal formatoptions-=t formatoptions+=croql
-setlocal com=:--
-setlocal cms=--%s
+setlocal comments=:--
+setlocal commentstring=--%s
setlocal suffixesadd=.lua
+let b:undo_ftplugin = "setlocal fo< com< cms< sua<"
-" The following lines enable the macros/matchit.vim plugin for
-" extended matching with the % key.
-if exists("loaded_matchit")
-
+if exists("loaded_matchit") && !exists("b:match_words")
let b:match_ignorecase = 0
let b:match_words =
- \ '\<\%(do\|function\|if\)\>:' .
- \ '\<\%(return\|else\|elseif\)\>:' .
- \ '\<end\>,' .
- \ '\<repeat\>:\<until\>'
+ \ '\<\%(do\|function\|if\)\>:' .
+ \ '\<\%(return\|else\|elseif\)\>:' .
+ \ '\<end\>,' .
+ \ '\<repeat\>:\<until\>,' .
+ \ '\%(--\)\=\[\(=*\)\[:]\1]'
+ let b:undo_ftplugin .= " | unlet! b:match_words b:match_ignorecase"
+endif
-endif " exists("loaded_matchit")
+if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
+ let b:browsefilter = "Lua Source Files (*.lua)\t*.lua\n" .
+ \ "All Files (*.*)\t*.*\n"
+ let b:undo_ftplugin .= " | unlet! b:browsefilter"
+endif
let &cpo = s:cpo_save
unlet s:cpo_save
-
-let b:undo_ftplugin = "setlocal fo< com< cms< suffixesadd<"
diff --git a/runtime/ftplugin/routeros.vim b/runtime/ftplugin/routeros.vim
new file mode 100644
index 0000000000..c6e4799aa2
--- /dev/null
+++ b/runtime/ftplugin/routeros.vim
@@ -0,0 +1,29 @@
+" Vim filetype plugin file
+" Language: MikroTik RouterOS Script
+" Maintainer: zainin <z@wintr.dev>
+" Last Change: 2021 Nov 14
+
+if exists("b:did_ftplugin")
+ finish
+endif
+let b:did_ftplugin = 1
+
+let s:save_cpo = &cpo
+set cpo-=C
+
+setlocal comments=:#
+setlocal commentstring=#\ %s
+setlocal formatoptions-=t formatoptions+=croql
+
+let b:undo_ftplugin = "setlocal com< cms< fo<"
+
+if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
+ let b:browsefilter = "RouterOS Script Files (*.rsc)\t*.rsc\n" ..
+ \ "All Files (*.*)\t*.*\n"
+ let b:undo_ftplugin ..= " | unlet! b:browsefilter"
+endif
+
+let &cpo = s:save_cpo
+unlet! s:save_cpo
+
+" vim: nowrap sw=2 sts=2 ts=8 noet:
diff --git a/runtime/ftplugin/zimbu.vim b/runtime/ftplugin/zimbu.vim
index 24674776cb..e365ccf07e 100644
--- a/runtime/ftplugin/zimbu.vim
+++ b/runtime/ftplugin/zimbu.vim
@@ -1,7 +1,7 @@
" Vim filetype plugin file
" Language: Zimbu
" Maintainer: Bram Moolenaar <Bram@vim.org>
-" Last Change: 2017 Dec 05
+" Last Change: 2021 Nov 12
" Only do this when not done yet for this buffer
if exists("b:did_ftplugin")
@@ -34,9 +34,11 @@ setlocal errorformat^=%f\ line\ %l\ col\ %c:\ %m,ERROR:\ %m
" When the matchit plugin is loaded, this makes the % command skip parens and
" braces in comments.
-let b:match_words = '\(^\s*\)\@<=\(MODULE\|CLASS\|INTERFACE\|BITS\|ENUM\|SHARED\|FUNC\|REPLACE\|DEFINE\|PROC\|EQUAL\|MAIN\|IF\|GENERATE_IF\|WHILE\|REPEAT\|WITH\|DO\|FOR\|SWITCH\|TRY\)\>\|{\s*$:\(^\s*\)\@<=\(ELSE\|ELSEIF\|GENERATE_ELSE\|GENERATE_ELSEIF\|CATCH\|FINALLY\)\>:\(^\s*\)\@<=\(}\|\<UNTIL\>\)'
-
-let b:match_skip = 's:comment\|string\|zimbuchar'
+if exists("loaded_matchit") && !exists("b:match_words")
+ let b:match_words = '\(^\s*\)\@<=\(MODULE\|CLASS\|INTERFACE\|BITS\|ENUM\|SHARED\|FUNC\|REPLACE\|DEFINE\|PROC\|EQUAL\|MAIN\|IF\|GENERATE_IF\|WHILE\|REPEAT\|WITH\|DO\|FOR\|SWITCH\|TRY\)\>\|{\s*$:\(^\s*\)\@<=\(ELSE\|ELSEIF\|GENERATE_ELSE\|GENERATE_ELSEIF\|CATCH\|FINALLY\)\>:\(^\s*\)\@<=\(}\|\<UNTIL\>\)'
+ let b:match_skip = 's:comment\|string\|zimbuchar'
+ let b:undo_ftplugin ..= " | unlet! b:match_words b:match_skip"
+endif
setlocal tw=78
setlocal et sts=2 sw=2
@@ -135,9 +137,60 @@ iabbr <buffer> <expr> until GCUpperSpace("until")
iabbr <buffer> <expr> while GCUpperSpace("while")
iabbr <buffer> <expr> repeat GCUpper("repeat")
+let b:undo_ftplugin ..=
+ \ " | iunabbr <buffer> alias" ..
+ \ " | iunabbr <buffer> arg" ..
+ \ " | iunabbr <buffer> break" ..
+ \ " | iunabbr <buffer> case" ..
+ \ " | iunabbr <buffer> catch" ..
+ \ " | iunabbr <buffer> check" ..
+ \ " | iunabbr <buffer> class" ..
+ \ " | iunabbr <buffer> interface" ..
+ \ " | iunabbr <buffer> implements" ..
+ \ " | iunabbr <buffer> shared" ..
+ \ " | iunabbr <buffer> continue" ..
+ \ " | iunabbr <buffer> default" ..
+ \ " | iunabbr <buffer> extends" ..
+ \ " | iunabbr <buffer> do" ..
+ \ " | iunabbr <buffer> else" ..
+ \ " | iunabbr <buffer> elseif" ..
+ \ " | iunabbr <buffer> enum" ..
+ \ " | iunabbr <buffer> exit" ..
+ \ " | iunabbr <buffer> false" ..
+ \ " | iunabbr <buffer> fail" ..
+ \ " | iunabbr <buffer> finally" ..
+ \ " | iunabbr <buffer> for" ..
+ \ " | iunabbr <buffer> func" ..
+ \ " | iunabbr <buffer> if" ..
+ \ " | iunabbr <buffer> import" ..
+ \ " | iunabbr <buffer> in" ..
+ \ " | iunabbr <buffer> io" ..
+ \ " | iunabbr <buffer> main" ..
+ \ " | iunabbr <buffer> module" ..
+ \ " | iunabbr <buffer> new" ..
+ \ " | iunabbr <buffer> nil" ..
+ \ " | iunabbr <buffer> ok" ..
+ \ " | iunabbr <buffer> proc" ..
+ \ " | iunabbr <buffer> proceed" ..
+ \ " | iunabbr <buffer> return" ..
+ \ " | iunabbr <buffer> step" ..
+ \ " | iunabbr <buffer> switch" ..
+ \ " | iunabbr <buffer> sys" ..
+ \ " | iunabbr <buffer> this" ..
+ \ " | iunabbr <buffer> throw" ..
+ \ " | iunabbr <buffer> try" ..
+ \ " | iunabbr <buffer> to" ..
+ \ " | iunabbr <buffer> true" ..
+ \ " | iunabbr <buffer> until" ..
+ \ " | iunabbr <buffer> while" ..
+ \ " | iunabbr <buffer> repeat"
+
if !exists("no_plugin_maps") && !exists("no_zimbu_maps")
nnoremap <silent> <buffer> [[ m`:call ZimbuGoStartBlock()<CR>
nnoremap <silent> <buffer> ]] m`:call ZimbuGoEndBlock()<CR>
+ let b:undo_ftplugin ..=
+ \ " | silent! exe 'nunmap <buffer> [['" ..
+ \ " | silent! exe 'nunmap <buffer> ]]'"
endif
" Using a function makes sure the search pattern is restored
diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua
index 191b9b9145..9b57467a52 100644
--- a/runtime/lua/vim/diagnostic.lua
+++ b/runtime/lua/vim/diagnostic.lua
@@ -36,7 +36,51 @@ M.handlers = setmetatable({}, {
end,
})
--- Local functions {{{
+-- Metatable that automatically creates an empty table when assigning to a missing key
+local bufnr_and_namespace_cacher_mt = {
+ __index = function(t, bufnr)
+ if not bufnr or bufnr == 0 then
+ bufnr = vim.api.nvim_get_current_buf()
+ end
+
+ rawset(t, bufnr, {})
+
+ return rawget(t, bufnr)
+ end,
+
+ __newindex = function(t, bufnr, v)
+ if not bufnr or bufnr == 0 then
+ bufnr = vim.api.nvim_get_current_buf()
+ end
+
+ rawset(t, bufnr, v)
+ end,
+}
+
+local diagnostic_cache = setmetatable({}, {
+ __index = function(t, bufnr)
+ if not bufnr or bufnr == 0 then
+ bufnr = vim.api.nvim_get_current_buf()
+ end
+
+ vim.api.nvim_buf_attach(bufnr, false, {
+ on_detach = function()
+ rawset(t, bufnr, nil) -- clear cache
+ end
+ })
+
+ rawset(t, bufnr, {})
+
+ return rawget(t, bufnr)
+ end,
+})
+
+local diagnostic_cache_extmarks = setmetatable({}, bufnr_and_namespace_cacher_mt)
+local diagnostic_attached_buffers = {}
+local diagnostic_disabled = {}
+local bufs_waiting_to_update = setmetatable({}, bufnr_and_namespace_cacher_mt)
+
+local all_namespaces = {}
---@private
local function to_severity(severity)
@@ -106,8 +150,6 @@ local function reformat_diagnostics(format, diagnostics)
return formatted
end
-local all_namespaces = {}
-
---@private
local function enabled_value(option, namespace)
local ns = namespace and M.get_namespace(namespace) or {}
@@ -213,36 +255,6 @@ local function get_bufnr(bufnr)
return bufnr
end
--- Metatable that automatically creates an empty table when assigning to a missing key
-local bufnr_and_namespace_cacher_mt = {
- __index = function(t, bufnr)
- if not bufnr or bufnr == 0 then
- bufnr = vim.api.nvim_get_current_buf()
- end
-
- if rawget(t, bufnr) == nil then
- rawset(t, bufnr, {})
- end
-
- return rawget(t, bufnr)
- end,
-
- __newindex = function(t, bufnr, v)
- if not bufnr or bufnr == 0 then
- bufnr = vim.api.nvim_get_current_buf()
- end
-
- rawset(t, bufnr, v)
- end,
-}
-
-local diagnostic_cleanup = setmetatable({}, bufnr_and_namespace_cacher_mt)
-local diagnostic_cache = setmetatable({}, bufnr_and_namespace_cacher_mt)
-local diagnostic_cache_extmarks = setmetatable({}, bufnr_and_namespace_cacher_mt)
-local diagnostic_attached_buffers = {}
-local diagnostic_disabled = {}
-local bufs_waiting_to_update = setmetatable({}, bufnr_and_namespace_cacher_mt)
-
---@private
local function is_disabled(namespace, bufnr)
local ns = M.get_namespace(namespace)
@@ -287,11 +299,6 @@ local function set_diagnostic_cache(namespace, bufnr, diagnostics)
end
---@private
-local function clear_diagnostic_cache(namespace, bufnr)
- diagnostic_cache[bufnr][namespace] = nil
-end
-
----@private
local function restore_extmarks(bufnr, last)
for ns, extmarks in pairs(diagnostic_cache_extmarks[bufnr]) do
local extmarks_current = vim.api.nvim_buf_get_extmarks(bufnr, ns, 0, -1, {details = true})
@@ -377,6 +384,59 @@ local function clear_scheduled_display(namespace, bufnr)
end
---@private
+local function get_diagnostics(bufnr, opts, clamp)
+ opts = opts or {}
+
+ local namespace = opts.namespace
+ local diagnostics = {}
+ local buf_line_count = clamp and vim.api.nvim_buf_line_count(bufnr) or math.huge
+
+ ---@private
+ local function add(d)
+ if not opts.lnum or d.lnum == opts.lnum then
+ if clamp and (d.lnum >= buf_line_count or d.end_lnum >= buf_line_count) then
+ d = vim.deepcopy(d)
+ d.lnum = math.max(math.min(d.lnum, buf_line_count - 1), 0)
+ d.end_lnum = math.max(math.min(d.end_lnum, buf_line_count - 1), 0)
+ end
+ table.insert(diagnostics, d)
+ end
+ end
+
+ if namespace == nil and bufnr == nil then
+ for _, t in pairs(diagnostic_cache) do
+ for _, v in pairs(t) do
+ for _, diagnostic in pairs(v) do
+ add(diagnostic)
+ end
+ end
+ end
+ elseif namespace == nil then
+ for iter_namespace in pairs(diagnostic_cache[bufnr]) do
+ for _, diagnostic in pairs(diagnostic_cache[bufnr][iter_namespace]) do
+ add(diagnostic)
+ end
+ end
+ elseif bufnr == nil then
+ for _, t in pairs(diagnostic_cache) do
+ for _, diagnostic in pairs(t[namespace] or {}) do
+ add(diagnostic)
+ end
+ end
+ else
+ for _, diagnostic in pairs(diagnostic_cache[bufnr][namespace] or {}) do
+ add(diagnostic)
+ end
+ end
+
+ if opts.severity then
+ diagnostics = filter_by_severity(opts.severity, diagnostics)
+ end
+
+ return diagnostics
+end
+
+---@private
local function set_list(loclist, opts)
opts = opts or {}
local open = vim.F.if_nil(opts.open, true)
@@ -386,7 +446,7 @@ local function set_list(loclist, opts)
if loclist then
bufnr = vim.api.nvim_win_get_buf(winnr)
end
- local diagnostics = M.get(bufnr, opts)
+ local diagnostics = get_diagnostics(bufnr, opts, true)
local items = M.toqflist(diagnostics)
if loclist then
vim.fn.setloclist(winnr, {}, ' ', { title = title, items = items })
@@ -399,27 +459,12 @@ local function set_list(loclist, opts)
end
---@private
---- To (slightly) improve performance, modifies diagnostics in place.
-local function clamp_line_numbers(bufnr, diagnostics)
- local buf_line_count = vim.api.nvim_buf_line_count(bufnr)
- if buf_line_count == 0 then
- return
- end
-
- for _, diagnostic in ipairs(diagnostics) do
- diagnostic.lnum = math.max(math.min(diagnostic.lnum, buf_line_count - 1), 0)
- diagnostic.end_lnum = math.max(math.min(diagnostic.end_lnum, buf_line_count - 1), 0)
- end
-end
-
----@private
local function next_diagnostic(position, search_forward, bufnr, opts, namespace)
position[1] = position[1] - 1
bufnr = get_bufnr(bufnr)
local wrap = vim.F.if_nil(opts.wrap, true)
local line_count = vim.api.nvim_buf_line_count(bufnr)
- local diagnostics = M.get(bufnr, vim.tbl_extend("keep", opts, {namespace = namespace}))
- clamp_line_numbers(bufnr, diagnostics)
+ local diagnostics = get_diagnostics(bufnr, vim.tbl_extend("keep", opts, {namespace = namespace}), true)
local line_diagnostics = diagnostic_lines(diagnostics)
for i = 0, line_count do
local offset = i * (search_forward and 1 or -1)
@@ -431,13 +476,14 @@ local function next_diagnostic(position, search_forward, bufnr, opts, namespace)
lnum = (lnum + line_count) % line_count
end
if line_diagnostics[lnum] and not vim.tbl_isempty(line_diagnostics[lnum]) then
+ local line_length = #vim.api.nvim_buf_get_lines(bufnr, lnum, lnum + 1, true)[1]
local sort_diagnostics, is_next
if search_forward then
sort_diagnostics = function(a, b) return a.col < b.col end
- is_next = function(diagnostic) return diagnostic.col > position[2] end
+ is_next = function(d) return math.min(d.col, line_length - 1) > position[2] end
else
sort_diagnostics = function(a, b) return a.col > b.col end
- is_next = function(diagnostic) return diagnostic.col < position[2] end
+ is_next = function(d) return math.min(d.col, line_length - 1) < position[2] end
end
table.sort(line_diagnostics[lnum], sort_diagnostics)
if i == 0 then
@@ -481,10 +527,6 @@ local function diagnostic_move_pos(opts, pos)
end
end
--- }}}
-
--- Public API {{{
-
--- Configure diagnostic options globally or for a specific diagnostic
--- namespace.
---
@@ -618,19 +660,8 @@ function M.set(namespace, bufnr, diagnostics, opts)
}
if vim.tbl_isempty(diagnostics) then
- clear_diagnostic_cache(namespace, bufnr)
+ diagnostic_cache[bufnr][namespace] = nil
else
- if not diagnostic_cleanup[bufnr][namespace] then
- diagnostic_cleanup[bufnr][namespace] = true
-
- -- Clean up our data when the buffer unloads.
- vim.api.nvim_buf_attach(bufnr, false, {
- on_detach = function(_, b)
- clear_diagnostic_cache(namespace, b)
- diagnostic_cleanup[b][namespace] = nil
- end
- })
- end
set_diagnostic_cache(namespace, bufnr, diagnostics)
end
@@ -689,49 +720,7 @@ function M.get(bufnr, opts)
opts = { opts, 't', true },
}
- opts = opts or {}
-
- local namespace = opts.namespace
- local diagnostics = {}
-
- ---@private
- local function add(d)
- if not opts.lnum or d.lnum == opts.lnum then
- table.insert(diagnostics, d)
- end
- end
-
- if namespace == nil and bufnr == nil then
- for _, t in pairs(diagnostic_cache) do
- for _, v in pairs(t) do
- for _, diagnostic in pairs(v) do
- add(diagnostic)
- end
- end
- end
- elseif namespace == nil then
- for iter_namespace in pairs(diagnostic_cache[bufnr]) do
- for _, diagnostic in pairs(diagnostic_cache[bufnr][iter_namespace]) do
- add(diagnostic)
- end
- end
- elseif bufnr == nil then
- for _, t in pairs(diagnostic_cache) do
- for _, diagnostic in pairs(t[namespace] or {}) do
- add(diagnostic)
- end
- end
- else
- for _, diagnostic in pairs(diagnostic_cache[bufnr][namespace] or {}) do
- add(diagnostic)
- end
- end
-
- if opts.severity then
- diagnostics = filter_by_severity(opts.severity, diagnostics)
- end
-
- return diagnostics
+ return get_diagnostics(bufnr, opts, false)
end
--- Get the previous diagnostic closest to the cursor position.
@@ -1115,7 +1104,7 @@ function M.show(namespace, bufnr, diagnostics, opts)
M.hide(namespace, bufnr)
- diagnostics = diagnostics or M.get(bufnr, {namespace=namespace})
+ diagnostics = diagnostics or get_diagnostics(bufnr, {namespace=namespace}, true)
if not diagnostics or vim.tbl_isempty(diagnostics) then
return
@@ -1141,8 +1130,6 @@ function M.show(namespace, bufnr, diagnostics, opts)
end
end
- clamp_line_numbers(bufnr, diagnostics)
-
for handler_name, handler in pairs(M.handlers) do
if handler.show and opts[handler_name] then
handler.show(namespace, bufnr, diagnostics, opts)
@@ -1213,8 +1200,7 @@ function M.open_float(bufnr, opts)
opts = get_resolved_options({ float = float_opts }, nil, bufnr).float
end
- local diagnostics = M.get(bufnr, opts)
- clamp_line_numbers(bufnr, diagnostics)
+ local diagnostics = get_diagnostics(bufnr, opts, true)
if scope == "line" then
diagnostics = vim.tbl_filter(function(d)
@@ -1338,7 +1324,7 @@ function M.reset(namespace, bufnr)
for _, iter_bufnr in ipairs(buffers) do
local namespaces = namespace and {namespace} or vim.tbl_keys(diagnostic_cache[iter_bufnr])
for _, iter_namespace in ipairs(namespaces) do
- clear_diagnostic_cache(iter_namespace, iter_bufnr)
+ diagnostic_cache[iter_bufnr][iter_namespace] = nil
M.hide(iter_namespace, iter_bufnr)
end
end
@@ -1545,7 +1531,7 @@ function M.fromqflist(list)
for _, item in ipairs(list) do
if item.valid == 1 then
local lnum = math.max(0, item.lnum - 1)
- local col = item.col > 0 and (item.col - 1) or nil
+ local col = math.max(0, item.col - 1)
local end_lnum = item.end_lnum > 0 and (item.end_lnum - 1) or lnum
local end_col = item.end_col > 0 and (item.end_col - 1) or col
local severity = item.type ~= "" and M.severity[item.type] or M.severity.ERROR
@@ -1563,6 +1549,4 @@ function M.fromqflist(list)
return diagnostics
end
--- }}}
-
return M
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua
index 0fc0a7a7aa..7433e7c04d 100644
--- a/runtime/lua/vim/lsp.lua
+++ b/runtime/lua/vim/lsp.lua
@@ -115,6 +115,13 @@ local format_line_ending = {
["mac"] = '\r',
}
+---@private
+---@param bufnr (number)
+---@returns (string)
+local function buf_get_line_ending(bufnr)
+ return format_line_ending[nvim_buf_get_option(bufnr, 'fileformat')] or '\n'
+end
+
local client_index = 0
---@private
--- Returns a new, unused client id.
@@ -236,7 +243,6 @@ local function validate_client_config(config)
config = { config, 't' };
}
validate {
- root_dir = { config.root_dir, optional_validator(is_dir), "directory" };
handlers = { config.handlers, "t", true };
capabilities = { config.capabilities, "t", true };
cmd_cwd = { config.cmd_cwd, optional_validator(is_dir), "directory" };
@@ -278,9 +284,10 @@ end
---@param bufnr (number) Buffer handle, or 0 for current.
---@returns Buffer text as string.
local function buf_get_full_text(bufnr)
- local text = table.concat(nvim_buf_get_lines(bufnr, 0, -1, true), '\n')
+ local line_ending = buf_get_line_ending(bufnr)
+ local text = table.concat(nvim_buf_get_lines(bufnr, 0, -1, true), line_ending)
if nvim_buf_get_option(bufnr, 'eol') then
- text = text .. '\n'
+ text = text .. line_ending
end
return text
end
@@ -362,9 +369,9 @@ do
local incremental_changes = function(client)
local cached_buffers = state_by_client[client.id].buffers
local curr_lines = nvim_buf_get_lines(bufnr, 0, -1, true)
- local line_ending = format_line_ending[vim.api.nvim_buf_get_option(0, 'fileformat')]
+ local line_ending = buf_get_line_ending(bufnr)
local incremental_change = sync.compute_diff(
- cached_buffers[bufnr], curr_lines, firstline, lastline, new_lastline, client.offset_encoding or 'utf-16', line_ending or '\n')
+ cached_buffers[bufnr], curr_lines, firstline, lastline, new_lastline, client.offset_encoding or 'utf-16', line_ending)
cached_buffers[bufnr] = curr_lines
return incremental_change
end
@@ -566,12 +573,10 @@ end
--
--- Starts and initializes a client with the given configuration.
---
---- Parameters `cmd` and `root_dir` are required.
+--- Parameter `cmd` is required.
---
--- The following parameters describe fields in the {config} table.
---
----@param root_dir: (string) Directory where the LSP server will base
---- its rootUri on initialization.
---
---@param cmd: (required, string or list treated like |jobstart()|) Base command
--- that initiates the LSP client.
@@ -587,6 +592,11 @@ end
--- { "PRODUCTION=true"; "TEST=123"; PORT = 8080; HOST = "0.0.0.0"; }
--- </pre>
---
+---@param workspace_folders (table) List of workspace folders passed to the
+--- language server. For backwards compatibility rootUri and rootPath will be
+--- derived from the first workspace folder in this list. See `workspaceFolders` in
+--- the LSP spec.
+---
---@param capabilities Map overriding the default capabilities defined by
--- |vim.lsp.protocol.make_client_capabilities()|, passed to the language
--- server on initialization. Hint: use make_client_capabilities() and modify
@@ -610,10 +620,6 @@ end
--- as `initializationOptions`. See `initialize` in the LSP spec.
---
---@param name (string, default=client-id) Name in log messages.
---
----@param workspace_folders (table) List of workspace folders passed to the
---- language server. Defaults to root_dir if not set. See `workspaceFolders` in
---- the LSP spec
---
---@param get_language_id function(bufnr, filetype) -> language ID as string.
--- Defaults to the filetype.
@@ -663,6 +669,11 @@ end
--- - exit_timeout (number, default 500): Milliseconds to wait for server to
-- exit cleanly after sending the 'shutdown' request before sending kill -15.
-- If set to false, nvim exits immediately after sending the 'shutdown' request to the server.
+---
+---@param root_dir string Directory where the LSP
+--- server will base its workspaceFolders, rootUri, and rootPath
+--- on initialization.
+---
---@returns Client id. |vim.lsp.get_client_by_id()| Note: client may not be
--- fully initialized. Use `on_init` to do any actions once
--- the client has been initialized.
@@ -805,11 +816,24 @@ function lsp.start_client(config)
}
local version = vim.version()
- if config.root_dir and not config.workspace_folders then
- config.workspace_folders = {{
- uri = vim.uri_from_fname(config.root_dir);
- name = string.format("%s", config.root_dir);
- }};
+ local workspace_folders
+ local root_uri
+ local root_path
+ if config.workspace_folders or config.root_dir then
+ if config.root_dir and not config.workspace_folders then
+ workspace_folders = {{
+ uri = vim.uri_from_fname(config.root_dir);
+ name = string.format("%s", config.root_dir);
+ }};
+ else
+ workspace_folders = config.workspace_folders
+ end
+ root_uri = workspace_folders[1].uri
+ root_path = vim.uri_to_fname(root_uri)
+ else
+ workspace_folders = vim.NIL
+ root_uri = vim.NIL
+ root_path = vim.NIL
end
local initialize_params = {
@@ -827,10 +851,15 @@ function lsp.start_client(config)
-- The rootPath of the workspace. Is null if no folder is open.
--
-- @deprecated in favour of rootUri.
- rootPath = config.root_dir;
+ rootPath = root_path;
-- The rootUri of the workspace. Is null if no folder is open. If both
-- `rootPath` and `rootUri` are set `rootUri` wins.
- rootUri = config.root_dir and vim.uri_from_fname(config.root_dir);
+ rootUri = root_uri;
+ -- The workspace folders configured in the client when the server starts.
+ -- This property is only available if the client supports workspace folders.
+ -- It can be `null` if the client supports workspace folders but none are
+ -- configured.
+ workspaceFolders = workspace_folders;
-- User provided initialization options.
initializationOptions = config.init_options;
-- The capabilities provided by the client (editor or tool)
@@ -838,21 +867,6 @@ function lsp.start_client(config)
-- The initial trace setting. If omitted trace is disabled ("off").
-- trace = "off" | "messages" | "verbose";
trace = valid_traces[config.trace] or 'off';
- -- The workspace folders configured in the client when the server starts.
- -- This property is only available if the client supports workspace folders.
- -- It can be `null` if the client supports workspace folders but none are
- -- configured.
- --
- -- Since 3.6.0
- -- workspaceFolders?: WorkspaceFolder[] | null;
- -- export interface WorkspaceFolder {
- -- -- The associated URI for this workspace folder.
- -- uri
- -- -- The name of the workspace folder. Used to refer to this
- -- -- workspace folder in the user interface.
- -- name
- -- }
- workspaceFolders = config.workspace_folders,
}
if config.before_init then
-- TODO(ashkan) handle errors here.
@@ -1587,6 +1601,21 @@ function lsp.formatexpr(opts)
return 0
end
+--- Provides an interface between the built-in client and 'tagfunc'.
+---
+--- When used with normal mode commands (e.g. |CTRL-]|) this will invoke
+--- the "textDocument/definition" LSP method to find the tag under the cursor.
+--- Otherwise, uses "workspace/symbol". If no results are returned from
+--- any LSP servers, falls back to using built-in tags.
+---
+---@param pattern Pattern used to find a workspace symbol
+---@param flags See |tag-function|
+---
+---@returns A list of matching tags
+function lsp.tagfunc(...)
+ return require('vim.lsp.tagfunc')(...)
+end
+
---Checks whether a client is stopped.
---
---@param client_id (Number)
diff --git a/runtime/lua/vim/lsp/diagnostic.lua b/runtime/lua/vim/lsp/diagnostic.lua
index 1e6f83c1ba..76a4dc30b7 100644
--- a/runtime/lua/vim/lsp/diagnostic.lua
+++ b/runtime/lua/vim/lsp/diagnostic.lua
@@ -717,5 +717,3 @@ end
-- }}}
return M
-
--- vim: fdm=marker
diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua
index a561630c2b..fa4f2b22a5 100644
--- a/runtime/lua/vim/lsp/handlers.lua
+++ b/runtime/lua/vim/lsp/handlers.lua
@@ -350,7 +350,10 @@ M['textDocument/signatureHelp'] = M.signature_help
--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_documentHighlight
M['textDocument/documentHighlight'] = function(_, result, ctx, _)
if not result then return end
- util.buf_highlight_references(ctx.bufnr, result, ctx.client_id)
+ local client_id = ctx.client_id
+ local client = vim.lsp.get_client_by_id(client_id)
+ if not client then return end
+ util.buf_highlight_references(ctx.bufnr, result, client.offset_encoding)
end
---@private
diff --git a/runtime/lua/vim/lsp/sync.lua b/runtime/lua/vim/lsp/sync.lua
index 585c14a00f..f185e3973f 100644
--- a/runtime/lua/vim/lsp/sync.lua
+++ b/runtime/lua/vim/lsp/sync.lua
@@ -74,43 +74,45 @@ local function byte_to_utf(line, byte, offset_encoding)
return utf_idx + 1
end
+local function compute_line_length(line, offset_encoding)
+ local length
+ local _
+ if offset_encoding == 'utf-16' then
+ _, length = str_utfindex(line)
+ elseif offset_encoding == 'utf-32' then
+ length, _ = str_utfindex(line)
+ else
+ length = #line
+ end
+ return length
+end
+
---@private
-- Given a line, byte idx, alignment, and offset_encoding convert to the aligned
-- utf-8 index and either the utf-16, or utf-32 index.
---@param line string the line to index into
---@param byte integer the byte idx
----@param align string when dealing with multibyte characters,
--- to choose the start of the current character or the beginning of the next.
--- Used for incremental sync for start/end range respectively
---@param offset_encoding string utf-8|utf-16|utf-32|nil (default: utf-8)
---@returns table<string, int> byte_idx and char_idx of first change position
-local function align_position(line, byte, align, offset_encoding)
+local function align_end_position(line, byte, offset_encoding)
local char
-- If on the first byte, or an empty string: the trivial case
if byte == 1 or #line == 0 then
char = byte
-- Called in the case of extending an empty line "" -> "a"
elseif byte == #line + 1 then
- byte = byte + str_utf_end(line, #line)
- char = byte_to_utf(line, byte, offset_encoding)
+ char = compute_line_length(line, offset_encoding) + 1
else
-- Modifying line, find the nearest utf codepoint
- if align == 'start' then
- byte = byte + str_utf_start(line, byte)
- char = byte_to_utf(line, byte, offset_encoding)
- elseif align == 'end' then
- local offset = str_utf_end(line, byte)
- -- If the byte does not fall on the start of the character, then
- -- align to the start of the next character.
- if offset > 0 then
- char = byte_to_utf(line, byte, offset_encoding) + 1
- byte = byte + offset
- else
- char = byte_to_utf(line, byte, offset_encoding)
- byte = byte + offset
- end
+ local offset = str_utf_end(line, byte)
+ -- If the byte does not fall on the start of the character, then
+ -- align to the start of the next character.
+ if offset > 0 then
+ char = byte_to_utf(line, byte, offset_encoding) + 1
+ byte = byte + offset
else
- error('`align` must be start or end.')
+ char = byte_to_utf(line, byte, offset_encoding)
+ byte = byte + offset
end
-- Extending line, find the nearest utf codepoint for the last valid character
end
@@ -154,7 +156,18 @@ local function compute_start_range(prev_lines, curr_lines, firstline, lastline,
end
-- Convert byte to codepoint if applicable
- local byte_idx, char_idx = align_position(prev_line, start_byte_idx, 'start', offset_encoding)
+ local char_idx
+ local byte_idx
+ if start_byte_idx == 1 or (#prev_line == 0 and start_byte_idx == 1)then
+ byte_idx = start_byte_idx
+ char_idx = 1
+ elseif start_byte_idx == #prev_line + 1 then
+ byte_idx = start_byte_idx
+ char_idx = compute_line_length(prev_line, offset_encoding) + 1
+ else
+ byte_idx = start_byte_idx + str_utf_start(prev_line, start_byte_idx)
+ char_idx = byte_to_utf(prev_line, start_byte_idx, offset_encoding)
+ end
-- Return the start difference (shared for new and prev lines)
return { line_idx = firstline, byte_idx = byte_idx, char_idx = char_idx }
@@ -219,11 +232,12 @@ local function compute_end_range(prev_lines, curr_lines, start_range, firstline,
-- Iterate from end to beginning of shortest line
local prev_end_byte_idx = prev_line_length - byte_offset + 1
+
-- Handle case where lines match
if prev_end_byte_idx == 0 then
prev_end_byte_idx = 1
end
- local prev_byte_idx, prev_char_idx = align_position(prev_line, prev_end_byte_idx, 'start', offset_encoding)
+ local prev_byte_idx, prev_char_idx = align_end_position(prev_line, prev_end_byte_idx, offset_encoding)
local prev_end_range = { line_idx = prev_line_idx, byte_idx = prev_byte_idx, char_idx = prev_char_idx }
local curr_end_range
@@ -236,7 +250,7 @@ local function compute_end_range(prev_lines, curr_lines, start_range, firstline,
if curr_end_byte_idx == 0 then
curr_end_byte_idx = 1
end
- local curr_byte_idx, curr_char_idx = align_position(curr_line, curr_end_byte_idx, 'start', offset_encoding)
+ local curr_byte_idx, curr_char_idx = align_end_position(curr_line, curr_end_byte_idx, offset_encoding)
curr_end_range = { line_idx = curr_line_idx, byte_idx = curr_byte_idx, char_idx = curr_char_idx }
end
@@ -280,18 +294,6 @@ local function extract_text(lines, start_range, end_range, line_ending)
end
end
-local function compute_line_length(line, offset_encoding)
- local length
- local _
- if offset_encoding == 'utf-16' then
- _, length = str_utfindex(line)
- elseif offset_encoding == 'utf-32' then
- length, _ = str_utfindex(line)
- else
- length = #line
- end
- return length
-end
---@private
-- rangelength depends on the offset encoding
-- bytes for utf-8 (clangd with extenion)
diff --git a/runtime/lua/vim/lsp/tagfunc.lua b/runtime/lua/vim/lsp/tagfunc.lua
new file mode 100644
index 0000000000..5c55e8559f
--- /dev/null
+++ b/runtime/lua/vim/lsp/tagfunc.lua
@@ -0,0 +1,76 @@
+local lsp = vim.lsp
+local util = vim.lsp.util
+
+---@private
+local function mk_tag_item(name, range, uri, offset_encoding)
+ local bufnr = vim.uri_to_bufnr(uri)
+ -- This is get_line_byte_from_position is 0-indexed, call cursor expects a 1-indexed position
+ local byte = util._get_line_byte_from_position(bufnr, range.start, offset_encoding) + 1
+ return {
+ name = name,
+ filename = vim.uri_to_fname(uri),
+ cmd = string.format('call cursor(%d, %d)|', range.start.line + 1, byte),
+ }
+end
+
+---@private
+local function query_definition(pattern)
+ local params = lsp.util.make_position_params()
+ local results_by_client, err = lsp.buf_request_sync(0, 'textDocument/definition', params, 1000)
+ if err then
+ return {}
+ end
+ local results = {}
+ local add = function(range, uri, offset_encoding)
+ table.insert(results, mk_tag_item(pattern, range, uri, offset_encoding))
+ end
+ for client_id, lsp_results in pairs(results_by_client) do
+ local client = lsp.get_client_by_id(client_id)
+ local result = lsp_results.result or {}
+ if result.range then -- Location
+ add(result.range, result.uri)
+ else -- Location[] or LocationLink[]
+ for _, item in pairs(result) do
+ if item.range then -- Location
+ add(item.range, item.uri, client.offset_encoding)
+ else -- LocationLink
+ add(item.targetSelectionRange, item.targetUri, client.offset_encoding)
+ end
+ end
+ end
+ end
+ return results
+end
+
+---@private
+local function query_workspace_symbols(pattern)
+ local results_by_client, err = lsp.buf_request_sync(0, 'workspace/symbol', { query = pattern }, 1000)
+ if err then
+ return {}
+ end
+ local results = {}
+ for client_id, symbols in pairs(results_by_client) do
+ local client = lsp.get_client_by_id(client_id)
+ for _, symbol in pairs(symbols.result or {}) do
+ local loc = symbol.location
+ local item = mk_tag_item(symbol.name, loc.range, loc.uri, client.offset_encoding)
+ item.kind = lsp.protocol.SymbolKind[symbol.kind] or 'Unknown'
+ table.insert(results, item)
+ end
+ end
+ return results
+end
+
+---@private
+local function tagfunc(pattern, flags)
+ local matches
+ if string.match(flags, 'c') then
+ matches = query_definition(pattern)
+ else
+ matches = query_workspace_symbols(pattern)
+ end
+ -- fall back to tags if no matches
+ return #matches > 0 and matches or vim.NIL
+end
+
+return tagfunc
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua
index a4b7b9922b..ba5c20ef9f 100644
--- a/runtime/lua/vim/lsp/util.lua
+++ b/runtime/lua/vim/lsp/util.lua
@@ -1341,19 +1341,17 @@ do --[[ References ]]
---
---@param bufnr buffer id
---@param references List of `DocumentHighlight` objects to highlight
+ ---@param offset_encoding string utf-8|utf-16|utf-32|nil defaults to utf-16
---@see https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/#documentHighlight
- function M.buf_highlight_references(bufnr, references, client_id)
+ function M.buf_highlight_references(bufnr, references, offset_encoding)
validate { bufnr = {bufnr, 'n', true} }
- local client = vim.lsp.get_client_by_id(client_id)
- if not client then
- return
- end
+ offset_encoding = offset_encoding or 'utf-16'
for _, reference in ipairs(references) do
local start_line, start_char = reference["range"]["start"]["line"], reference["range"]["start"]["character"]
local end_line, end_char = reference["range"]["end"]["line"], reference["range"]["end"]["character"]
- local start_idx = get_line_byte_from_position(bufnr, { line = start_line, character = start_char }, client.offset_encoding)
- local end_idx = get_line_byte_from_position(bufnr, { line = start_line, character = end_char }, client.offset_encoding)
+ local start_idx = get_line_byte_from_position(bufnr, { line = start_line, character = start_char }, offset_encoding)
+ local end_idx = get_line_byte_from_position(bufnr, { line = start_line, character = end_char }, offset_encoding)
local document_highlight_kind = {
[protocol.DocumentHighlightKind.Text] = "LspReferenceText";
diff --git a/runtime/lua/vim/uri.lua b/runtime/lua/vim/uri.lua
index 5d8d4fa169..d08d2a3ee3 100644
--- a/runtime/lua/vim/uri.lua
+++ b/runtime/lua/vim/uri.lua
@@ -56,8 +56,8 @@ local function is_windows_file_uri(uri)
end
--- Get a URI from a file path.
----@param path (string): Path to file
----@return URI
+---@param path string Path to file
+---@return string URI
local function uri_from_fname(path)
local volume_path, fname = path:match("^([a-zA-Z]:)(.*)")
local is_windows = volume_path ~= nil
@@ -78,8 +78,8 @@ local URI_SCHEME_PATTERN = '^([a-zA-Z]+[a-zA-Z0-9+-.]*):.*'
local WINDOWS_URI_SCHEME_PATTERN = '^([a-zA-Z]+[a-zA-Z0-9+-.]*):[a-zA-Z]:.*'
--- Get a URI from a bufnr
----@param bufnr (number): Buffer number
----@return URI
+---@param bufnr number
+---@return string URI
local function uri_from_bufnr(bufnr)
local fname = vim.api.nvim_buf_get_name(bufnr)
local volume_path = fname:match("^([a-zA-Z]:).*")
@@ -99,8 +99,8 @@ local function uri_from_bufnr(bufnr)
end
--- Get a filename from a URI
----@param uri (string): The URI
----@return Filename
+---@param uri string
+---@return string filename or unchanged URI for non-file URIs
local function uri_to_fname(uri)
local scheme = assert(uri:match(URI_SCHEME_PATTERN), 'URI must contain a scheme: ' .. uri)
if scheme ~= 'file' then
@@ -117,17 +117,13 @@ local function uri_to_fname(uri)
return uri
end
---- Return or create a buffer for a uri.
----@param uri (string): The URI
----@return bufnr.
----@note Creates buffer but does not load it
+--- Get the buffer for a uri.
+--- Creates a new unloaded buffer if no buffer for the uri already exists.
+--
+---@param uri string
+---@return number bufnr
local function uri_to_bufnr(uri)
- local scheme = assert(uri:match(URI_SCHEME_PATTERN), 'URI must contain a scheme: ' .. uri)
- if scheme == 'file' then
- return vim.fn.bufadd(uri_to_fname(uri))
- else
- return vim.fn.bufadd(uri)
- end
+ return vim.fn.bufadd(uri_to_fname(uri))
end
return {
diff --git a/runtime/pack/dist/opt/matchit/doc/matchit.txt b/runtime/pack/dist/opt/matchit/doc/matchit.txt
index 58a47780ef..b719fae730 100644
--- a/runtime/pack/dist/opt/matchit/doc/matchit.txt
+++ b/runtime/pack/dist/opt/matchit/doc/matchit.txt
@@ -1,10 +1,10 @@
-*matchit.txt* Extended "%" matching
+*matchit.txt* Extended "%" matching
For instructions on installing this file, type
`:help matchit-install`
inside Vim.
-For Vim version 8.1. Last change: 2021 May 17
+For Vim version 8.1. Last change: 2021 Nov 13
VIM REFERENCE MANUAL by Benji Fisher et al
diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
index 8de03dfab7..ae0242a312 100644
--- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
+++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
@@ -2,7 +2,7 @@
"
" Author: Bram Moolenaar
" Copyright: Vim license applies, see ":help license"
-" Last Change: 2021 Oct 26
+" Last Change: 2021 Nov 14
"
" WORK IN PROGRESS - Only the basics work
" Note: On MS-Windows you need a recent version of gdb. The one included with
@@ -1191,6 +1191,7 @@ func s:GotoAsmwinOrCreateIt()
setlocal number
setlocal noswapfile
setlocal buftype=nofile
+ setlocal modifiable
let asmbuf = bufnr('Termdebug-asm-listing')
if asmbuf > 0
@@ -1273,6 +1274,7 @@ func s:HandleCursor(msg)
endif
endif
exe lnum
+ normal! zv
exe 'sign unplace ' . s:pc_id
exe 'sign place ' . s:pc_id . ' line=' . lnum . ' name=debugPC file=' . fname
if !exists('b:save_signcolumn')
diff --git a/runtime/plugin/zipPlugin.vim b/runtime/plugin/zipPlugin.vim
index b9e334fb98..edc52713a8 100644
--- a/runtime/plugin/zipPlugin.vim
+++ b/runtime/plugin/zipPlugin.vim
@@ -20,7 +20,7 @@
if &cp || exists("g:loaded_zipPlugin")
finish
endif
-let g:loaded_zipPlugin = "v31"
+let g:loaded_zipPlugin = "v32"
let s:keepcpo = &cpo
set cpo&vim
diff --git a/runtime/syntax/autoit.vim b/runtime/syntax/autoit.vim
index 1b9ab7458e..6b6048aadc 100644
--- a/runtime/syntax/autoit.vim
+++ b/runtime/syntax/autoit.vim
@@ -5,6 +5,7 @@
" Authored By: Riccardo Casini <ric@libero.it>
" Script URL: http://www.vim.org/scripts/script.php?script_id=1239
" ChangeLog: Please visit the script URL for detailed change information
+" Included change from #970.
" Quit when a syntax file was already loaded.
if exists("b:current_syntax")
@@ -932,7 +933,7 @@ syn match autoitConst "\$SD_POWERDOWN"
" constants - string
syn match autoitConst "\$STR_NOCASESENSE"
syn match autoitConst "\$STR_CASESENSE"
-syn match autoitConst "\STR_STRIPLEADING"
+syn match autoitConst "\$STR_STRIPLEADING"
syn match autoitConst "\$STR_STRIPTRAILING"
syn match autoitConst "\$STR_STRIPSPACES"
syn match autoitConst "\$STR_STRIPALL"
diff --git a/runtime/syntax/gdb.vim b/runtime/syntax/gdb.vim
index 25a21d184e..c820ba40a9 100644
--- a/runtime/syntax/gdb.vim
+++ b/runtime/syntax/gdb.vim
@@ -2,7 +2,8 @@
" Language: GDB command files
" Maintainer: Claudio Fleiner <claudio@fleiner.com>
" URL: http://www.fleiner.com/vim/syntax/gdb.vim
-" Last Change: 2012 Oct 05
+" Last Change: 2021 Nov 15
+" Additional changes by Simon Sobisch
" quit when a syntax file was already loaded
if exists("b:current_syntax")
@@ -21,19 +22,19 @@ syn match gdbInfo contained "all-registers"
syn keyword gdbStatement contained actions apply attach awatch backtrace break bt call catch cd clear collect commands
-syn keyword gdbStatement contained complete condition continue delete detach directory disable disassemble display down
+syn keyword gdbStatement contained complete condition continue delete detach directory disable disas[semble] disp[lay] down
syn keyword gdbStatement contained echo else enable end file finish frame handle hbreak help if ignore
syn keyword gdbStatement contained inspect jump kill list load maintenance make next nexti ni output overlay
-syn keyword gdbStatement contained passcount path print printf ptype pwd quit rbreak remote return run rwatch
-syn keyword gdbStatement contained search section set sharedlibrary shell show si signal source step stepi stepping
+syn keyword gdbStatement contained passcount path print printf ptype python pwd quit rbreak remote return run rwatch
+syn keyword gdbStatement contained search section set sharedlibrary shell show si signal skip source step stepi stepping
syn keyword gdbStatement contained stop target tbreak tdump tfind thbreak thread tp trace tstart tstatus tstop
-syn keyword gdbStatement contained tty undisplay unset until up watch whatis where while ws x
+syn keyword gdbStatement contained tty und[isplay] unset until up watch whatis where while ws x
syn match gdbFuncDef "\<define\>.*"
syn match gdbStatmentContainer "^\s*\S\+" contains=gdbStatement,gdbFuncDef
syn match gdbStatement "^\s*info" nextgroup=gdbInfo skipwhite skipempty
" some commonly used abbreviations
-syn keyword gdbStatement c disp undisp disas p
+syn keyword gdbStatement c cont p py
syn region gdbDocument matchgroup=gdbFuncDef start="\<document\>.*$" matchgroup=gdbFuncDef end="^end\s*$"
diff --git a/runtime/syntax/gnuplot.vim b/runtime/syntax/gnuplot.vim
index 9c98e67e58..b5092d7555 100644
--- a/runtime/syntax/gnuplot.vim
+++ b/runtime/syntax/gnuplot.vim
@@ -3,7 +3,8 @@
" Maintainer: Josh Wainwright <wainwright DOT ja AT gmail DOT com>
" Last Maintainer: Andrew Rasmussen andyras@users.sourceforge.net
" Original Maintainer: John Hoelzel johnh51@users.sourceforge.net
-" Last Change: 2020 May 12
+" Last Change: 2021 Nov 16
+" additional changes from PR #8949
" Filenames: *.gnu *.plt *.gpi *.gih *.gp *.gnuplot scripts: #!*gnuplot
" URL: http://www.vim.org/scripts/script.php?script_id=4873
" Original URL: http://johnh51.get.to/vim/syntax/gnuplot.vim
@@ -32,22 +33,22 @@ syn match gnuplotSpecial "\\." contained
" syn match gnuplotSpecial "\\\o\o\o\|\\x\x\x\|\\c[^"]\|\\[a-z\\]" contained
" measurements in the units in, cm and pt are special
-syn match gnuplotUnit "[0-9]+in"
-syn match gnuplotUnit "[0-9]+cm"
-syn match gnuplotUnit "[0-9]+pt"
+syn match gnuplotUnit "\d+in"
+syn match gnuplotUnit "\d+cm"
+syn match gnuplotUnit "\d+pt"
" external (shell) commands are special
-syn region gnuplotExternal start="!" end="$"
+syn region gnuplotExternal start="^\s*!" end="$"
" ---- Comments ---- "
-syn region gnuplotComment start="#" end="$" contains=gnuplotTodo
+syn region gnuplotComment start="#" end="$" contains=gnuplotTodo,@Spell
" ---- Constants ---- "
" strings
-syn region gnuplotString start=+"+ skip=+\\"+ end=+"+ contains=gnuplotSpecial
-syn region gnuplotString start="'" end="'"
+syn region gnuplotString start=+"+ skip=+\\"+ end=+"+ contains=gnuplotSpecial,@Spell
+syn region gnuplotString start="'" end="'" contains=@Spell
" built-in variables
syn keyword gnuplotNumber GNUTERM GPVAL_TERM GPVAL_TERMOPTIONS GPVAL_SPLOT
@@ -76,7 +77,7 @@ syn keyword gnuplotNumber GPVAL_TERM_YSIZE GPVAL_VIEW_MAP GPVAL_VIEW_ROT_X
syn keyword gnuplotNumber GPVAL_VIEW_ROT_Z GPVAL_VIEW_SCALE
" function name variables
-syn match gnuplotNumber "GPFUN_[a-zA-Z_]*"
+syn match gnuplotNumber "GPFUN_\h*"
" stats variables
syn keyword gnuplotNumber STATS_records STATS_outofrange STATS_invalid
@@ -104,23 +105,23 @@ syn keyword gnuplotError FIT_LAMBDA_FACTOR FIT_LOG FIT_SCRIPT
" integer number, or floating point number without a dot and with "f".
syn case ignore
-syn match gnuplotNumber "\<[0-9]\+\(u\=l\=\|lu\|f\)\>"
+syn match gnuplotNumber "\<\d\+\(u\=l\=\|lu\|f\)\>"
" floating point number, with dot, optional exponent
-syn match gnuplotFloat "\<[0-9]\+\.[0-9]*\(e[-+]\=[0-9]\+\)\=[fl]\=\>"
+syn match gnuplotFloat "\<\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\=\>"
" floating point number, starting with a dot, optional exponent
-syn match gnuplotFloat "\.[0-9]\+\(e[-+]\=[0-9]\+\)\=[fl]\=\>"
+syn match gnuplotFloat "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>"
" floating point number, without dot, with exponent
-syn match gnuplotFloat "\<[0-9]\+e[-+]\=[0-9]\+[fl]\=\>"
+syn match gnuplotFloat "\<\d\+e[-+]\=\d\+[fl]\=\>"
" hex number
-syn match gnuplotNumber "\<0x[0-9a-f]\+\(u\=l\=\|lu\)\>"
+syn match gnuplotNumber "\<0x\x\+\(u\=l\=\|lu\)\>"
syn case match
" flag an octal number with wrong digits by not highlighting
-syn match gnuplotOctalError "\<0[0-7]*[89]"
+syn match gnuplotOctalError "\<0\o*[89]"
" ---- Identifiers: Functions ---- "
@@ -374,8 +375,8 @@ syn keyword gnuplotKeyword nohead nooutliers nowedge off opaque outliers
syn keyword gnuplotKeyword palette pattern pi pointinterval pointsize
syn keyword gnuplotKeyword pointtype ps pt radius range rectangle
syn keyword gnuplotKeyword rowstacked screen separation size solid sorted
-syn keyword gnuplotKeyword textbox transparent units unsorted userstyles
-syn keyword gnuplotKeyword wedge x x2 xx xy yy
+syn keyword gnuplotKeyword textbox units unsorted userstyles wedge
+syn keyword gnuplotKeyword x x2 xx xy yy
" set surface
syn keyword gnuplotKeyword surface implicit explicit
" set table
@@ -477,9 +478,13 @@ syn keyword gnuplotKeyword nooutput
" keywords for 'test' command
syn keyword gnuplotKeyword terminal palette rgb rbg grb gbr brg bgr
+" The transparent gnuplot keyword cannot use 'syn keyword' as transparent
+" has a special meaning in :syntax commands.
+syn match gnuplotKeyword "\<transparent\>"
+
" ---- Macros ---- "
-syn match gnuplotMacro "@[a-zA-Z0-9_]*"
+syn match gnuplotMacro "@\w*"
" ---- Todos ---- "
diff --git a/runtime/syntax/lisp.vim b/runtime/syntax/lisp.vim
index 434150ab26..90513e3a00 100644
--- a/runtime/syntax/lisp.vim
+++ b/runtime/syntax/lisp.vim
@@ -1,8 +1,8 @@
" Vim syntax file
" Language: Lisp
" Maintainer: Charles E. Campbell <NcampObell@SdrPchip.AorgM-NOSPAM>
-" Last Change: Jul 11, 2019
-" Version: 30
+" Last Change: Nov 10, 2021
+" Version: 31
" URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_LISP
"
" Thanks to F Xavier Noria for a list of 978 Common Lisp symbols taken from HyperSpec
@@ -54,20 +54,20 @@ if exists("g:lisp_rainbow") && g:lisp_rainbow != 0
syn region lispParen8 contained matchgroup=hlLevel8 start="`\=(" end=")" skip="|.\{-}|" contains=@lispListCluster,lispParen9
syn region lispParen9 contained matchgroup=hlLevel9 start="`\=(" end=")" skip="|.\{-}|" contains=@lispListCluster,lispParen0
else
- syn region lispList matchgroup=lispParen start="(" skip="|.\{-}|" matchgroup=lispParen end=")" contains=@lispListCluster
- syn region lispBQList matchgroup=PreProc start="`(" skip="|.\{-}|" matchgroup=PreProc end=")" contains=@lispListCluster
+ syn region lispList matchgroup=lispParen start="(" skip="|.\{-}|" matchgroup=lispParen end=")" contains=@lispListCluster
+ syn region lispBQList matchgroup=PreProc start="`(" skip="|.\{-}|" matchgroup=PreProc end=")" contains=@lispListCluster
endif
" ---------------------------------------------------------------------
" Atoms: {{{1
-syn match lispAtomMark "'"
-syn match lispAtom "'("me=e-1 contains=lispAtomMark nextgroup=lispAtomList
-syn match lispAtom "'[^ \t()]\+" contains=lispAtomMark
-syn match lispAtomBarSymbol !'|..\{-}|! contains=lispAtomMark
-syn region lispAtom start=+'"+ skip=+\\"+ end=+"+
-syn region lispAtomList contained matchgroup=Special start="(" skip="|.\{-}|" matchgroup=Special end=")" contains=@lispAtomCluster,lispString,lispEscapeSpecial
-syn match lispAtomNmbr contained "\<\d\+"
-syn match lispLeadWhite contained "^\s\+"
+syn match lispAtomMark "'"
+syn match lispAtom "'("me=e-1 contains=lispAtomMark nextgroup=lispAtomList
+syn match lispAtom "'[^ \t()]\+" contains=lispAtomMark
+syn match lispAtomBarSymbol !'|..\{-}|! contains=lispAtomMark
+syn region lispAtom start=+'"+ skip=+\\"+ end=+"+
+syn region lispAtomList contained matchgroup=Special start="(" skip="|.\{-}|" matchgroup=Special end=")" contains=@lispAtomCluster,lispString,lispEscapeSpecial
+syn match lispAtomNmbr contained "\<\d\+"
+syn match lispLeadWhite contained "^\s\+"
" ---------------------------------------------------------------------
" Standard Lisp Functions and Macros: {{{1
@@ -553,6 +553,8 @@ syn match lispParenError ")"
syn cluster lispCommentGroup contains=lispTodo,@Spell
syn match lispComment ";.*$" contains=@lispCommentGroup
syn region lispCommentRegion start="#|" end="|#" contains=lispCommentRegion,@lispCommentGroup
+syn region lispComment start="#+nil" end="\ze)" contains=@lispCommentGroup
+syn match lispComment '^\s*#+nil.*$' contains=@lispCommentGroup
syn keyword lispTodo contained combak combak: todo todo:
" ---------------------------------------------------------------------
diff --git a/runtime/syntax/routeros.vim b/runtime/syntax/routeros.vim
new file mode 100644
index 0000000000..b6effc9b62
--- /dev/null
+++ b/runtime/syntax/routeros.vim
@@ -0,0 +1,91 @@
+" Vim syntax file
+" Language: MikroTik RouterOS Script
+" Maintainer: zainin <z@wintr.dev>
+" Original Author: ndbjorne @ MikroTik forums
+" Last Change: 2021 Nov 14
+
+" quit when a syntax file was already loaded
+if exists("b:current_syntax")
+ finish
+endif
+
+syn case ignore
+
+syn iskeyword @,48-57,-
+
+" comments
+syn match routerosComment /^\s*\zs#.*/
+
+" options submenus: /interface ether1 etc
+syn match routerosSubMenu "\([a-z]\)\@<!/[a-zA-Z0-9-]*"
+
+" variables are matched by looking at strings ending with "=", e.g. var=
+syn match routerosVariable "[a-zA-Z0-9-/]*\(=\)\@="
+syn match routerosVariable "$[a-zA-Z0-9-]*"
+
+" colored for clarity
+syn match routerosDelimiter "[,=]"
+" match slash in CIDR notation (1.2.3.4/24, 2001:db8::/48, ::1/128)
+syn match routerosDelimiter "\(\x\|:\)\@<=\/\(\d\)\@="
+" dash in IP ranges
+syn match routerosDelimiter "\(\x\|:\)\@<=-\(\x\|:\)\@="
+
+" match service names after "set", like in original routeros syntax
+syn match routerosService "\(set\)\@<=\s\(api-ssl\|api\|dns\|ftp\|http\|https\|pim\|ntp\|smb\|ssh\|telnet\|winbox\|www\|www-ssl\)"
+
+" colors various interfaces
+syn match routerosInterface "bridge\d\+\|ether\d\+\|wlan\d\+\|pppoe-\(out\|in\)\d\+"
+
+syn keyword routerosBoolean yes no true false
+
+syn keyword routerosConditional if
+
+" operators
+syn match routerosOperator " \zs[-+*<>=!~^&.,]\ze "
+syn match routerosOperator "[<>!]="
+syn match routerosOperator "<<\|>>"
+syn match routerosOperator "[+-]\d\@="
+
+syn keyword routerosOperator and or in
+
+" commands
+syn keyword routerosCommands beep delay put len typeof pick log time set find environment
+syn keyword routerosCommands terminal error parse resolve toarray tobool toid toip toip6
+syn keyword routerosCommands tonum tostr totime add remove enable disable where get print
+syn keyword routerosCommands export edit find append as-value brief detail count-only file
+syn keyword routerosCommands follow follow-only from interval terse value-list without-paging
+syn keyword routerosCommands return
+
+" variable types
+syn keyword routerosType global local
+
+" loop keywords
+syn keyword routerosRepeat do while for foreach
+
+syn match routerosSpecial "[():[\]{|}]"
+
+syn match routerosLineContinuation "\\$"
+
+syn match routerosEscape "\\["\\nrt$?_abfv]" contained display
+syn match routerosEscape "\\\x\x" contained display
+
+syn region routerosString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=routerosEscape,routerosLineContinuation
+
+hi link routerosComment Comment
+hi link routerosSubMenu Function
+hi link routerosVariable Identifier
+hi link routerosDelimiter Operator
+hi link routerosEscape Special
+hi link routerosService Type
+hi link routerosInterface Type
+hi link routerosBoolean Boolean
+hi link routerosConditional Conditional
+hi link routerosOperator Operator
+hi link routerosCommands Operator
+hi link routerosType Type
+hi link routerosRepeat Repeat
+hi link routerosSpecial Delimiter
+hi link routerosString String
+hi link routerosLineContinuation Special
+
+let b:current_syntax = "routeros"
diff --git a/runtime/syntax/tcl.vim b/runtime/syntax/tcl.vim
index 73b2b3fa11..59cb04f70f 100644
--- a/runtime/syntax/tcl.vim
+++ b/runtime/syntax/tcl.vim
@@ -6,8 +6,8 @@
" (previously Matt Neumann <mattneu@purpleturtle.com>)
" (previously Allan Kelly <allan@fruitloaf.co.uk>)
" Original: Robin Becker <robin@jessikat.demon.co.uk>
-" Last Change: 2021 Oct 03
-" Version: 1.14
+" Last Change: 2021 Nov 16
+" Version: 1.14 plus improvements from PR #8948
" URL: (removed, no longer worked)
" quit when a syntax file was already loaded
@@ -192,18 +192,18 @@ syn region tcltkCommand matchgroup=tcltkCommandColor start="\<lsort\>" matchgrou
syn keyword tclTodo contained TODO
" Sequences which are backslash-escaped: http://www.tcl.tk/man/tcl8.5/TclCmd/Tcl.htm#M16
-" Octal, hexadecimal, unicode codepoints, and the classics.
+" Octal, hexadecimal, Unicode codepoints, and the classics.
" Tcl takes as many valid characters in a row as it can, so \xAZ in a string is newline followed by 'Z'.
-syn match tclSpecial contained '\\\([0-7]\{1,3}\|x\x\{1,2}\|u\x\{1,4}\|[abfnrtv]\)'
+syn match tclSpecial contained '\\\(\o\{1,3}\|x\x\{1,2}\|u\x\{1,4}\|[abfnrtv]\)'
syn match tclSpecial contained '\\[\[\]\{\}\"\$]'
" Command appearing inside another command or inside a string.
syn region tclEmbeddedStatement start='\[' end='\]' contained contains=tclCommand,tclNumber,tclLineContinue,tclString,tclVarRef,tclEmbeddedStatement
" A string needs the skip argument as it may legitimately contain \".
" Match at start of line
-syn region tclString start=+^"+ end=+"+ contains=@tclSpecialC skip=+\\\\\|\\"+
+syn region tclString start=+^"+ end=+"+ contains=@tclSpecialC,@Spell skip=+\\\\\|\\"+
"Match all other legal strings.
-syn region tclString start=+[^\\]"+ms=s+1 end=+"+ contains=@tclSpecialC,@tclVarRefC,tclEmbeddedStatement skip=+\\\\\|\\"+
+syn region tclString start=+[^\\]"+ms=s+1 end=+"+ contains=@tclSpecialC,@tclVarRefC,tclEmbeddedStatement,@Spell skip=+\\\\\|\\"+
" Line continuation is backslash immediately followed by newline.
syn match tclLineContinue '\\$'
@@ -222,12 +222,12 @@ syn match tclNumber "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>"
"floating point number, without dot, with exponent
syn match tclNumber "\<\d\+e[-+]\=\d\+[fl]\=\>"
"hex number
-syn match tclNumber "0x[0-9a-f]\+\(u\=l\=\|lu\)\>"
-"syn match tclIdentifier "\<[a-z_][a-z0-9_]*\>"
+syn match tclNumber "0x\x\+\(u\=l\=\|lu\)\>"
+"syn match tclIdentifier "\<\h\w*\>"
syn case match
-syn region tclComment start="^\s*\#" skip="\\$" end="$" contains=tclTodo
-syn region tclComment start=/;\s*\#/hs=s+1 skip="\\$" end="$" contains=tclTodo
+syn region tclComment start="^\s*\#" skip="\\$" end="$" contains=tclTodo,@Spell
+syn region tclComment start=/;\s*\#/hs=s+1 skip="\\$" end="$" contains=tclTodo,@Spell
"syn match tclComment /^\s*\#.*$/
"syn match tclComment /;\s*\#.*$/hs=s+1
diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim
index 67756fa320..f7b5ce0f63 100644
--- a/runtime/syntax/vim.vim
+++ b/runtime/syntax/vim.vim
@@ -161,10 +161,13 @@ syn match vimFBVar contained "\<[bwglstav]:\h[a-zA-Z0-9#_]*\>"
syn keyword vimCommand contained in
" Insertions And Appends: insert append {{{2
+" (buftype != nofile test avoids having append, change, insert show up in the command window)
" =======================
-syn region vimInsert matchgroup=vimCommand start="^[: \t]*\(\d\+\(,\d\+\)\=\)\=a\%[ppend]$" matchgroup=vimCommand end="^\.$""
-syn region vimInsert matchgroup=vimCommand start="^[: \t]*\(\d\+\(,\d\+\)\=\)\=c\%[hange]$" matchgroup=vimCommand end="^\.$""
-syn region vimInsert matchgroup=vimCommand start="^[: \t]*\(\d\+\(,\d\+\)\=\)\=i\%[nsert]$" matchgroup=vimCommand end="^\.$""
+if &buftype != 'nofile'
+ syn region vimInsert matchgroup=vimCommand start="^[: \t]*\(\d\+\(,\d\+\)\=\)\=a\%[ppend]$" matchgroup=vimCommand end="^\.$""
+ syn region vimInsert matchgroup=vimCommand start="^[: \t]*\(\d\+\(,\d\+\)\=\)\=c\%[hange]$" matchgroup=vimCommand end="^\.$""
+ syn region vimInsert matchgroup=vimCommand start="^[: \t]*\(\d\+\(,\d\+\)\=\)\=i\%[nsert]$" matchgroup=vimCommand end="^\.$""
+endif
" Behave! {{{2
" =======