aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/autoload/dist/ft.vim19
-rw-r--r--runtime/doc/api.txt6
-rw-r--r--runtime/doc/autocmd.txt24
-rw-r--r--runtime/doc/cmdline.txt6
-rw-r--r--runtime/doc/diagnostic.txt61
-rw-r--r--runtime/doc/eval.txt30
-rw-r--r--runtime/doc/filetype.txt12
-rw-r--r--runtime/doc/lsp.txt138
-rw-r--r--runtime/doc/lua.txt14
-rw-r--r--runtime/doc/options.txt9
-rw-r--r--runtime/doc/pi_msgpack.txt2
-rw-r--r--runtime/doc/quickfix.txt6
-rw-r--r--runtime/doc/sign.txt5
-rw-r--r--runtime/doc/syntax.txt16
-rw-r--r--runtime/doc/treesitter.txt19
-rw-r--r--runtime/doc/vim_diff.txt2
-rw-r--r--runtime/filetype.vim55
-rw-r--r--runtime/ftplugin/jsonc.vim10
-rw-r--r--runtime/indent/vim.vim3
-rw-r--r--runtime/lua/vim/F.lua2
-rw-r--r--runtime/lua/vim/_meta.lua123
-rw-r--r--runtime/lua/vim/diagnostic.lua75
-rw-r--r--runtime/lua/vim/lsp.lua56
-rw-r--r--runtime/lua/vim/lsp/buf.lua9
-rw-r--r--runtime/lua/vim/lsp/diagnostic.lua22
-rw-r--r--runtime/lua/vim/lsp/handlers.lua3
-rw-r--r--runtime/lua/vim/lsp/log.lua1
-rw-r--r--runtime/lua/vim/lsp/rpc.lua4
-rw-r--r--runtime/lua/vim/lsp/sync.lua5
-rw-r--r--runtime/lua/vim/lsp/util.lua54
-rw-r--r--runtime/lua/vim/shared.lua1
-rw-r--r--runtime/lua/vim/treesitter.lua2
-rw-r--r--runtime/lua/vim/treesitter/language.lua2
-rw-r--r--runtime/lua/vim/treesitter/languagetree.lua4
-rw-r--r--runtime/lua/vim/treesitter/query.lua6
-rw-r--r--runtime/nvim.appdata.xml1
-rw-r--r--runtime/pack/dist/opt/termdebug/plugin/termdebug.vim188
-rw-r--r--runtime/scripts.vim4
-rw-r--r--runtime/syntax/django.vim3
-rw-r--r--runtime/syntax/squirrel.vim50
-rw-r--r--runtime/syntax/vb.vim84
-rw-r--r--runtime/syntax/vim.vim10
-rw-r--r--runtime/tools/check_colors.vim14
43 files changed, 639 insertions, 521 deletions
diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim
index 344889249b..a3db4ae87a 100644
--- a/runtime/autoload/dist/ft.vim
+++ b/runtime/autoload/dist/ft.vim
@@ -1,7 +1,7 @@
" Vim functions for file type detection
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
-" Last Change: 2020 Aug 17
+" Last Change: 2021 Nov 27
" These functions are moved here from runtime/filetype.vim to make startup
" faster.
@@ -219,6 +219,23 @@ func dist#ft#FTe()
endif
endfunc
+" Distinguish between Forth and F#.
+" Provided by Doug Kearns.
+func dist#ft#FTfs()
+ if exists("g:filetype_fs")
+ exe "setf " . g:filetype_fs
+ else
+ let line = getline(nextnonblank(1))
+ " comments and colon definitions
+ if line =~ '^\s*\.\=( ' || line =~ '^\s*\\G\= ' || line =~ '^\\$'
+ \ || line =~ '^\s*: \S'
+ setf forth
+ else
+ setf fsharp
+ endif
+ endif
+endfunc
+
" Distinguish between HTML, XHTML and Django
func dist#ft#FThtml()
let n = 1
diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt
index 166fef028d..482d8c198d 100644
--- a/runtime/doc/api.txt
+++ b/runtime/doc/api.txt
@@ -1851,7 +1851,7 @@ nvim_buf_call({buffer}, {fun}) *nvim_buf_call()*
switched If a window inside the current tabpage (including a
float) already shows the buffer One of these windows will be
set as current window temporarily. Otherwise a temporary
- scratch window (calleed the "autocmd window" for historical
+ scratch window (called the "autocmd window" for historical
reasons) will be used.
This is useful e.g. to call vimL functions that only work with
@@ -2175,7 +2175,7 @@ nvim_buf_set_text({buffer}, {start_row}, {start_col}, {end_row}, {end_col},
Parameters: ~
{buffer} Buffer handle, or 0 for current buffer
{start_row} First line index
- {start_column} Last column
+ {start_column} First column
{end_row} Last line index
{end_column} Last column
{replacement} Array of lines to use as replacement
@@ -2500,7 +2500,7 @@ nvim_set_decoration_provider({ns_id}, {opts})
specific window. ["win", winid, bufnr, topline,
botline_guess]
• on_line: called for each buffer line being
- redrawn. (The interation with fold lines is
+ redrawn. (The interaction 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 7ca6b3cd8e..879a34bcaa 100644
--- a/runtime/doc/autocmd.txt
+++ b/runtime/doc/autocmd.txt
@@ -718,7 +718,27 @@ MenuPopup Just before showing the popup menu (under the
o Operator-pending
i Insert
c Command line
- *OptionSet*
+ *ModeChanged*
+ModeChanged After changing the mode. The pattern is
+ matched against `'old_mode:new_mode'`, for
+ example match against `*:c` to simulate
+ |CmdlineEnter|.
+ The following values of |v:event| are set:
+ old_mode The mode before it changed.
+ new_mode The new mode as also returned
+ by |mode()| called with a
+ non-zero argument.
+ When ModeChanged is triggered, old_mode will
+ have the value of new_mode when the event was
+ last triggered.
+ This will be triggered on every minor mode
+ change.
+ Usage example to use relative line numbers
+ when entering visual mode: >
+ :au ModeChanged [vV\x16]*:* let &l:rnu = mode() =~# '^[vV\x16]'
+ :au ModeChanged *:[vV\x16]* let &l:rnu = mode() =~# '^[vV\x16]'
+ :au WinEnter,WinLeave * let &l:rnu = mode() =~# '^[vV\x16]'
+< *OptionSet*
OptionSet After setting an option (except during
|startup|). The |autocmd-pattern| is matched
against the long option name. |<amatch>|
@@ -793,7 +813,7 @@ QuitPre When using `:quit`, `:wq` or `:qall`, before
before QuitPre is triggered. Can be used to
close any non-essential window if the current
window is the last ordinary window.
- See also |ExitPre|, ||WinClosed|.
+ See also |ExitPre|, |WinClosed|.
*RemoteReply*
RemoteReply When a reply from a Vim that functions as
server was received |server2client()|. The
diff --git a/runtime/doc/cmdline.txt b/runtime/doc/cmdline.txt
index 6b46ac9cf2..7716af25bd 100644
--- a/runtime/doc/cmdline.txt
+++ b/runtime/doc/cmdline.txt
@@ -863,9 +863,11 @@ Note: these are typed literally, they are not special keys!
*:<amatch>* *<amatch>*
<amatch> When executing autocommands, is replaced with the match for
which this autocommand was executed. *E497*
- It differs from <afile> only when the file name isn't used
- to match with (for FileType, Syntax and SpellFileMissing
+ It differs from <afile> when the file name isn't used to
+ match with (for FileType, Syntax and SpellFileMissing
events).
+ When the match is with a file name, it is expanded to the
+ full path.
*:<sfile>* *<sfile>*
<sfile> When executing a ":source" command, is replaced with the
file name of the sourced file. *E498*
diff --git a/runtime/doc/diagnostic.txt b/runtime/doc/diagnostic.txt
index d41cee3cdd..9a65737dae 100644
--- a/runtime/doc/diagnostic.txt
+++ b/runtime/doc/diagnostic.txt
@@ -239,7 +239,7 @@ DiagnosticUnderlineHint
*hl-DiagnosticFloatingError*
DiagnosticFloatingError
Used to color "Error" diagnostic messages in diagnostics float.
- See |vim.diagnostic.show_line_diagnostics()|
+ See |vim.diagnostic.open_float()|
*hl-DiagnosticFloatingWarn*
DiagnosticFloatingWarn
@@ -373,39 +373,8 @@ config({opts}, {namespace}) *vim.diagnostic.config()*
Otherwise, all signs use the same
priority.
- • float: Options for floating windows:
- • severity: See |diagnostic-severity|.
- • header: (string or table) String to use
- as the header for the floating window. If
- a table, it is interpreted as a [text,
- hl_group] tuple. Defaults to
- "Diagnostics:".
- • source: (string) Include the diagnostic
- source in the message. One of "always" or
- "if_many".
- • format: (function) A function that takes
- a diagnostic as input and returns a
- string. The return value is the text used
- to display the diagnostic.
- • prefix: (function, string, or table)
- Prefix each diagnostic in the floating
- window. If a function, it must have the
- signature (diagnostic, i, total) ->
- (string, string), where {i} is the index
- of the diagnostic being evaluated and
- {total} is the total number of
- diagnostics displayed in the window. The
- function should return a string which is
- prepended to each diagnostic in the
- window as well as an (optional) highlight
- group which will be used to highlight the
- prefix. If {prefix} is a table, it is
- interpreted as a [text, hl_group] tuple
- as in |nvim_echo()|; otherwise, if
- {prefix} is a string, it is prepended to
- each diagnostic in the window with no
- highlight.
-
+ • float: Options for floating windows. See
+ |vim.diagnostic.open_float()|.
• update_in_insert: (default false) Update
diagnostics in Insert mode (if false,
diagnostics are updated on InsertLeave)
@@ -470,7 +439,7 @@ get_namespace({namespace}) *vim.diagnostic.get_namespace()*
Get namespace metadata.
Parameters: ~
- {ns} number Diagnostic namespace
+ {namespace} number Diagnostic namespace
Return: ~
table Namespace metadata
@@ -539,6 +508,9 @@ goto_next({opts}) *vim.diagnostic.goto_next()*
"true", call |vim.diagnostic.open_float()| after
moving. If a table, pass the table as the {opts}
parameter to |vim.diagnostic.open_float()|.
+ Unless overridden, the float will show
+ diagnostics at the new cursor position (as if
+ "cursor" were passed to the "scope" option).
• win_id: (number, default 0) Window ID
goto_prev({opts}) *vim.diagnostic.goto_prev()*
@@ -613,7 +585,7 @@ open_float({bufnr}, {opts}) *vim.diagnostic.open_float()*
addition to the following:
• namespace: (number) Limit diagnostics to the
given namespace
- • scope: (string, default "buffer") Show
+ • scope: (string, default "line") Show
diagnostics from the whole buffer ("buffer"),
the current cursor line ("line"), or the
current cursor position ("cursor").
@@ -641,8 +613,21 @@ open_float({bufnr}, {opts}) *vim.diagnostic.open_float()*
diagnostic. Overrides the setting from
|vim.diagnostic.config()|.
• prefix: (function, string, or table) Prefix
- each diagnostic in the floating window.
- Overrides the setting from
+ each diagnostic in the floating window. If a
+ function, it must have the signature
+ (diagnostic, i, total) -> (string, string),
+ where {i} is the index of the diagnostic being
+ evaluated and {total} is the total number of
+ diagnostics displayed in the window. The
+ function should return a string which is
+ prepended to each diagnostic in the window as
+ well as an (optional) highlight group which
+ will be used to highlight the prefix. If
+ {prefix} is a table, it is interpreted as a
+ [text, hl_group] tuple as in |nvim_echo()|;
+ otherwise, if {prefix} is a string, it is
+ prepended to each diagnostic in the window with
+ no highlight. Overrides the setting from
|vim.diagnostic.config()|.
Return: ~
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index d1af4c4d72..75b782fbff 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -2042,10 +2042,29 @@ v:option_new New value of the option. Valid while executing an |OptionSet|
autocommand.
*v:option_old*
v:option_old Old value of the option. Valid while executing an |OptionSet|
- autocommand.
+ autocommand. Depending on the command used for setting and the
+ kind of option this is either the local old value or the
+ global old value.
+ *v:option_oldlocal*
+v:option_oldlocal
+ Old local value of the option. Valid while executing an
+ |OptionSet| autocommand.
+ *v:option_oldglobal*
+v:option_oldglobal
+ Old global value of the option. Valid while executing an
+ |OptionSet| autocommand.
*v:option_type*
v:option_type Scope of the set command. Valid while executing an
|OptionSet| autocommand. Can be either "global" or "local"
+ *v:option_command*
+v:option_command
+ Command used to set the option. Valid while executing an
+ |OptionSet| autocommand.
+ value option was set via ~
+ "setlocal" |:setlocal| or ":let l:xxx"
+ "setglobal" |:setglobal| or ":let g:xxx"
+ "set" |:set| or |:let|
+ "modeline" |modeline|
*v:operator* *operator-variable*
v:operator The last operator given in Normal mode. This is a single
character except for commands starting with <g> or <z>,
@@ -3085,7 +3104,7 @@ bufname([{buf}]) *bufname()*
bufname(3) name of buffer 3
bufname("%") name of current buffer
bufname("file2") name of buffer where "file2" matches.
-
+<
*bufnr()*
bufnr([{buf} [, {create}]])
The result is the number of a buffer, as it is displayed by
@@ -3591,7 +3610,7 @@ count({comp}, {expr} [, {ic} [, {start}]]) *count()*
Can also be used as a |method|: >
mylist->count(val)
-
+<
*cscope_connection()*
cscope_connection([{num} , {dbpath} [, {prepend}]])
Checks for the existence of a |cscope| connection. If no
@@ -8598,6 +8617,7 @@ setbufline({buf}, {lnum}, {text}) *setbufline()*
For the use of {buf}, see |bufname()| above.
{lnum} is used like with |setline()|.
+ Use "$" to refer to the last line in buffer {buf}.
When {lnum} is just below the last line the {text} will be
added below the last line.
On success 0 is returned, on failure 1 is returned.
@@ -9078,7 +9098,7 @@ shellescape({string} [, {special}]) *shellescape()*
Otherwise encloses {string} in single-quotes and replaces all
"'" with "'\''".
- If {special} is a ||non-zero-arg|:
+ If {special} is a |non-zero-arg|:
- Special items such as "!", "%", "#" and "<cword>" will be
preceded by a backslash. The backslash will be removed again
by the |:!| command.
@@ -9088,7 +9108,7 @@ shellescape({string} [, {special}]) *shellescape()*
- The "!" character will be escaped. This is because csh and
tcsh use "!" for history replacement even in single-quotes.
- The <NL> character is escaped (twice if {special} is
- a ||non-zero-arg|).
+ a |non-zero-arg|).
If 'shell' contains "fish" in the tail, the "\" character will
be escaped because in fish it is used as an escape character
diff --git a/runtime/doc/filetype.txt b/runtime/doc/filetype.txt
index 42a9993c8c..bbbe71ec3a 100644
--- a/runtime/doc/filetype.txt
+++ b/runtime/doc/filetype.txt
@@ -128,18 +128,19 @@ can be used to overrule the filetype used for certain extensions:
file name variable ~
*.asa g:filetype_asa |ft-aspvbs-syntax| |ft-aspperl-syntax|
- *.asp g:filetype_asp |ft-aspvbs-syntax| |ft-aspperl-syntax|
*.asm g:asmsyntax |ft-asm-syntax|
- *.prg g:filetype_prg
- *.pl g:filetype_pl
- *.inc g:filetype_inc
- *.w g:filetype_w |ft-cweb-syntax|
+ *.asp g:filetype_asp |ft-aspvbs-syntax| |ft-aspperl-syntax|
+ *.fs g:filetype_fs |ft-forth-syntax|
*.i g:filetype_i |ft-progress-syntax|
+ *.inc g:filetype_inc
*.m g:filetype_m |ft-mathematica-syntax|
*.p g:filetype_p |ft-pascal-syntax|
+ *.pl g:filetype_pl
*.pp g:filetype_pp |ft-pascal-syntax|
+ *.prg g:filetype_prg
*.sh g:bash_is_sh |ft-sh-syntax|
*.tex g:tex_flavor |ft-tex-plugin|
+ *.w g:filetype_w |ft-cweb-syntax|
*filetype-ignore*
To avoid that certain files are being inspected, the g:ft_ignore_pat variable
@@ -494,7 +495,6 @@ Options:
For further discussion of fortran_have_tabs and the method used for the
detection of source format see |ft-fortran-syntax|.
-
GIT COMMIT *ft-gitcommit-plugin*
One command, :DiffGitCached, is provided to show a diff of the current commit
diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt
index 1a54ca227f..9bd304cbb4 100644
--- a/runtime/doc/lsp.txt
+++ b/runtime/doc/lsp.txt
@@ -521,7 +521,9 @@ buf_request({bufnr}, {method}, {params}, {handler})
{method} (string) LSP method name
{params} (optional, table) Parameters to send to the
server
- {handler} (optional, function) See |lsp-handler|
+ {handler} (optional, function) See |lsp-handler| If nil,
+ follows resolution strategy defined in
+ |lsp-handler-configuration|
Return: ~
2-tuple:
@@ -573,9 +575,6 @@ 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
@@ -648,12 +647,21 @@ client_is_stopped({client_id}) *vim.lsp.client_is_stopped()*
Return: ~
true if client is stopped, false otherwise.
-flush({client}) *vim.lsp.flush()*
- TODO: Documentation
-
*vim.lsp.for_each_buffer_client()*
for_each_buffer_client({bufnr}, {fn})
- TODO: Documentation
+ Invokes a function for each LSP client attached to a buffer.
+
+ Parameters: ~
+ {bufnr} number Buffer number
+ {fn} function Function to run on each client attached
+ to buffer {bufnr}. The function takes the client,
+ client ID, and buffer number as arguments.
+ Example: >
+
+ vim.lsp.for_each_buffer_client(0, function(client, client_id, bufnr)
+ print(vim.inspect(client))
+ end)
+<
formatexpr({opts}) *vim.lsp.formatexpr()*
Provides an interface between the built-in client and a
@@ -676,6 +684,8 @@ get_active_clients() *vim.lsp.get_active_clients()*
*vim.lsp.get_buffers_by_client_id()*
get_buffers_by_client_id({client_id})
+ Returns list of buffers attached to client_id.
+
Parameters: ~
{client_id} number client id
@@ -717,16 +727,6 @@ omnifunc({findstart}, {base}) *vim.lsp.omnifunc()*
|complete-items|
|CompleteDone|
- *vim.lsp.prepare()*
-prepare({bufnr}, {firstline}, {lastline}, {new_lastline}, {changedtick})
- TODO: Documentation
-
-reset({client_id}) *vim.lsp.reset()*
- TODO: Documentation
-
-reset_buf({client}, {bufnr}) *vim.lsp.reset_buf()*
- TODO: Documentation
-
set_log_level({level}) *vim.lsp.set_log_level()*
Sets the global log level for LSP logging.
@@ -796,10 +796,11 @@ start_client({config}) *vim.lsp.start_client()*
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.
+ must be a unique command 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.
@@ -873,6 +874,11 @@ start_client({config}) *vim.lsp.start_client()*
debounce occurs if nil
• 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.
{root_dir} string Directory where the LSP server
will base its workspaceFolders,
rootUri, and rootPath on
@@ -985,9 +991,9 @@ document_highlight() *vim.lsp.buf.document_highlight()*
triggered by a key mapping or by events such as `CursorHold` ,
eg:
>
- vim.api.nvim_command [[autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()]]
- vim.api.nvim_command [[autocmd CursorHoldI <buffer> lua vim.lsp.buf.document_highlight()]]
- vim.api.nvim_command [[autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()]]
+ autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
+ autocmd CursorHoldI <buffer> lua vim.lsp.buf.document_highlight()
+ autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
<
Note: Usage of |vim.lsp.buf.document_highlight()| requires the
@@ -1055,7 +1061,7 @@ formatting_sync({options}, {timeout_ms})
|vim.lsp.buf_request_sync()|. Example:
>
- vim.api.nvim_command[[autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync()]]
+ autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync()
<
Parameters: ~
@@ -1087,9 +1093,6 @@ outgoing_calls() *vim.lsp.buf.outgoing_calls()*
cursor in the |quickfix| window. If the symbol can resolve to
multiple items, the user can pick one in the |inputlist|.
-prepare_rename({err}, {result}) *vim.lsp.buf.prepare_rename()*
- TODO: Documentation
-
*vim.lsp.buf.range_code_action()*
range_code_action({context}, {start_pos}, {end_pos})
Performs |vim.lsp.buf.code_action()| for a given range.
@@ -1344,25 +1347,22 @@ buf_clear_references({bufnr}) *vim.lsp.util.buf_clear_references()*
Removes document highlights from a buffer.
Parameters: ~
- {bufnr} buffer id
+ {bufnr} number Buffer id
*vim.lsp.util.buf_highlight_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
- {offset_encoding} string utf-8|utf-16|utf-32|nil defaults
- to utf-16
+ {bufnr} number Buffer id
+ {references} table List of `DocumentHighlight`
+ objects to highlight
+ {offset_encoding} string One of "utf-8", "utf-16",
+ "utf-32", or nil. Defaults to utf-16
See also: ~
https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/#documentHighlight
-buf_lines({bufnr}) *vim.lsp.util.buf_lines()*
- TODO: Documentation
-
*vim.lsp.util.character_offset()*
character_offset({bufnr}, {row}, {col})
Returns the UTF-32 and UTF-16 offsets for a position in a
@@ -1429,12 +1429,6 @@ convert_signature_help_to_markdown_lines({signature_help}, {ft}, {triggers})
See also: ~
https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_signatureHelp
-create_file({change}) *vim.lsp.util.create_file()*
- TODO: Documentation
-
-delete_file({change}) *vim.lsp.util.delete_file()*
- TODO: Documentation
-
*vim.lsp.util.extract_completion_items()*
extract_completion_items({result})
Can be used to extract the completion items from a `textDocument/completion` request, which may return one of `CompletionItem[]` , `CompletionList` or null.
@@ -1462,9 +1456,6 @@ get_effective_tabstop({bufnr}) *vim.lsp.util.get_effective_tabstop()*
See also: ~
|softtabstop|
-get_progress_messages() *vim.lsp.util.get_progress_messages()*
- TODO: Documentation
-
jump_to_location({location}) *vim.lsp.util.jump_to_location()*
Jumps to a location.
@@ -1599,25 +1590,32 @@ open_floating_preview({contents}, {syntax}, {opts})
Parameters: ~
{contents} table of lines to show in window
{syntax} string of syntax to set for opened buffer
- {opts} dictionary with optional fields
- • height of floating window
- • width of floating window
- • wrap boolean enable wrapping of long lines
- (defaults to true)
- • wrap_at character to wrap at for computing
- height when wrap is enabled
- • max_width maximal width of floating window
- • max_height maximal height of floating window
- • pad_top number of lines to pad contents at
- top
- • pad_bottom number of lines to pad contents
- at bottom
- • focus_id if a popup with this id is opened,
- then focus it
- • close_events list of events that closes the
+ {opts} table with optional fields (additional keys
+ are passed on to |vim.api.nvim_open_win()|)
+ • height: (number) height of floating window
+ • width: (number) width of floating window
+ • wrap: (boolean, default true) wrap long
+ lines
+ • wrap_at: (string) character to wrap at for
+ computing height when wrap is enabled
+ • max_width: (number) maximal width of
+ floating window
+ • max_height: (number) maximal height of
floating window
- • focusable (boolean, default true): Make
+ • pad_top: (number) number of lines to pad
+ contents at top
+ • pad_bottom: (number) number of lines to pad
+ contents at bottom
+ • focus_id: (string) if a popup with this id
+ is opened, then focus it
+ • close_events: (table) list of events that
+ closes the floating window
+ • focusable: (boolean, default true) Make
float focusable
+ • focus: (boolean, default true) If `true` ,
+ and if {focusable} is also `true` , focus an
+ existing floating window with the same
+ {focus_id}
Return: ~
bufnr,winnr buffer and window number of the newly created
@@ -1758,7 +1756,10 @@ get_filename() *vim.lsp.log.get_filename()*
(string) log filename
get_level() *vim.lsp.log.get_level()*
- TODO: Documentation
+ Gets the current log level.
+
+ Return: ~
+ string current log level
set_format_func({handle}) *vim.lsp.log.set_format_func()*
Sets formatting function used to format logs
@@ -1837,7 +1838,8 @@ rpc_response_error({code}, {message}, {data})
*vim.lsp.rpc.start()*
start({cmd}, {cmd_args}, {dispatchers}, {extra_spawn_params})
Starts an LSP server process and create an LSP RPC client
- object to interact with it.
+ object to interact with it. Communication with the server is
+ currently limited to stdio.
Parameters: ~
{cmd} (string) Command to start the LSP
@@ -1896,10 +1898,6 @@ compute_diff({prev_lines}, {curr_lines}, {firstline}, {lastline},
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*
diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt
index 2db1974966..630df16e79 100644
--- a/runtime/doc/lua.txt
+++ b/runtime/doc/lua.txt
@@ -362,8 +362,8 @@ cases there is the following agreement:
converted to a dictionary `{'a': 42}`: non-string keys are ignored.
Without `vim.type_idx` key tables with keys not fitting in 1., 2. or 3.
are errors.
- - `{[vim.type_idx]=vim.types.list}` is converted to an empty list. As well
- as `{[vim.type_idx]=vim.types.list, [42]=1}`: integral keys that do not
+ - `{[vim.type_idx]=vim.types.array}` is converted to an empty list. As well
+ as `{[vim.type_idx]=vim.types.array, [42]=1}`: integral keys that do not
form a 1-step sequence from 1 to N are ignored, as well as all
non-integral keys.
@@ -1190,9 +1190,6 @@ defer_fn({fn}, {timeout}) *vim.defer_fn()*
Return: ~
timer luv timer object
-insert_keys({obj}) *vim.insert_keys()*
- TODO: Documentation
-
inspect({object}, {options}) *vim.inspect()*
Return a human-readable representation of the given object.
@@ -1235,7 +1232,7 @@ on_key({fn}, {ns_id}) *vim.on_key()*
it removes the callback for the associated
{ns_id}
{ns_id} number? Namespace ID. If nil or 0, generates and
- returns a new |nvim_create_namesapce()| id.
+ returns a new |nvim_create_namespace()| id.
Return: ~
number Namespace id associated with {fn}. Or count of all
@@ -1324,7 +1321,7 @@ deepcopy({orig}) *vim.deepcopy()*
and will throw an error.
Parameters: ~
- {orig} Table to copy
+ {orig} table Table to copy
Return: ~
New table of copied keys and (nested) values.
@@ -1365,9 +1362,6 @@ is_callable({f}) *vim.is_callable()*
Return: ~
true if `f` is callable, else false
-is_valid({opt}) *vim.is_valid()*
- TODO: Documentation
-
list_extend({dst}, {src}, {start}, {finish}) *vim.list_extend()*
Extends a list-like table with the values of another list-like
table.
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index 038808b760..47633c750c 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -684,9 +684,12 @@ A jump table for the options with a short description can be found at |Q_op|.
'autowrite' 'aw' boolean (default off)
global
Write the contents of the file, if it has been modified, on each
- :next, :rewind, :last, :first, :previous, :stop, :suspend, :tag, :!,
- :make, CTRL-] and CTRL-^ command; and when a :buffer, CTRL-O, CTRL-I,
- '{A-Z0-9}, or `{A-Z0-9} command takes one to another file.
+ `:next`, `:rewind`, `:last`, `:first`, `:previous`, `:stop`,
+ `:suspend`, `:tag`, `:!`, `:make`, CTRL-] and CTRL-^ command; and when
+ a :buffer, CTRL-O, CTRL-I, '{A-Z0-9}, or `{A-Z0-9} command takes one
+ to another file.
+ A buffer is not written if it becomes hidden, e.g. when 'bufhidden' is
+ set to "hide" and `:next` is used
Note that for some commands the 'autowrite' option is not used, see
'autowriteall' for that.
Some buffers will not be written, specifically when 'buftype' is
diff --git a/runtime/doc/pi_msgpack.txt b/runtime/doc/pi_msgpack.txt
index 951b897f55..1dbd268038 100644
--- a/runtime/doc/pi_msgpack.txt
+++ b/runtime/doc/pi_msgpack.txt
@@ -68,7 +68,7 @@ msgpack#strftime({format}, {msgpack-integer}) *msgpack#strftime()*
*msgpack#strptime*
msgpack#strptime({format}, {time}) *msgpack#strptime()*
- Reverse of |msgpack#strptime()|: for any time and format
+ Reverse of |msgpack#strftime()|: for any time and format
|msgpack#equal|( |msgpack#strptime|(format, |msgpack#strftime|(format,
time)), time) be true. Requires |+python| or |+python3|, without it
only supports non-|msgpack-special-dict| nonnegative times and format
diff --git a/runtime/doc/quickfix.txt b/runtime/doc/quickfix.txt
index 9c1f584415..ba1da209f7 100644
--- a/runtime/doc/quickfix.txt
+++ b/runtime/doc/quickfix.txt
@@ -837,9 +837,9 @@ lists. They set one of the existing error lists as the current one.
*:chistory* *:chi*
:[count]chi[story] Show the list of error lists. The current list is
marked with ">". The output looks like:
- error list 1 of 3; 43 errors ~
- > error list 2 of 3; 0 errors ~
- error list 3 of 3; 15 errors ~
+ error list 1 of 3; 43 errors :make ~
+ > error list 2 of 3; 0 errors :helpgrep tag ~
+ error list 3 of 3; 15 errors :grep ex_help *.c ~
When [count] is given, then the count'th quickfix
list is made the current list. Example: >
diff --git a/runtime/doc/sign.txt b/runtime/doc/sign.txt
index 9181684945..895ee5ebef 100644
--- a/runtime/doc/sign.txt
+++ b/runtime/doc/sign.txt
@@ -419,11 +419,12 @@ sign_getdefined([{name}]) *sign_getdefined()*
following entries:
icon full path to the bitmap file of the sign
linehl highlight group used for the whole line the
- sign is placed in.
+ sign is placed in; not present if not set.
name name of the sign
text text that is displayed when there is no icon
or the GUI is not being used.
- texthl highlight group used for the text item
+ texthl highlight group used for the text item; not
+ present if not set.
numhl highlight group used for 'number' column at the
associated line. Overrides |hl-LineNr|,
|hl-CursorLineNr|.
diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt
index e423c59efe..b57b8bfd5c 100644
--- a/runtime/doc/syntax.txt
+++ b/runtime/doc/syntax.txt
@@ -1497,6 +1497,14 @@ gvim display. Here, statements are colored LightYellow instead of Yellow, and
conditionals are LightBlue for better distinction.
+FORTH *forth.vim* *ft-forth-syntax*
+
+Files matching "*.fs" could be F# or Forth. If the automatic detection
+doesn't work for you, or you don't edit F# at all, use this in your
+startup vimrc: >
+ :let filetype_fs = "forth"
+
+
FORTRAN *fortran.vim* *ft-fortran-syntax*
Default highlighting and dialect ~
@@ -3153,6 +3161,14 @@ buffer by buffer basis.
For more detailed instructions see |ft_sql.txt|.
+SQUIRREL *squirrel.vim* *ft-squirrel-syntax*
+
+Squirrel is a high level imperative, object-oriented programming language,
+designed to be a light-weight scripting language that fits in the size, memory
+bandwidth, and real-time requirements of applications like video games. Files
+with the following extensions are recognized as squirrel files: .nut.
+
+
TCSH *tcsh.vim* *ft-tcsh-syntax*
This covers the shell named "tcsh". It is a superset of csh. See |csh.vim|
diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt
index ac10aeec88..08dc0583ac 100644
--- a/runtime/doc/treesitter.txt
+++ b/runtime/doc/treesitter.txt
@@ -353,7 +353,7 @@ Lua module: vim.treesitter *lua-treesitter-core*
get_parser({bufnr}, {lang}, {opts}) *get_parser()*
Gets the parser for this bufnr / ft combination.
- If needed this will create the parser. Unconditionnally attach
+ If needed this will create the parser. Unconditionally attach
the provided callback
Parameters: ~
@@ -380,7 +380,7 @@ Lua module: vim.treesitter.language *treesitter-language*
inspect_language({lang}) *inspect_language()*
Inspects the provided language.
- Inspecting provides some useful informations on the language
+ Inspecting provides some useful information on the language
like node names, ...
Parameters: ~
@@ -479,7 +479,7 @@ Query:iter_captures({self}, {node}, {source}, {start}, {stop})
{source} is needed if the query contains predicates, then the
caller must ensure to use a freshly parsed tree consistent
- with the current text of the buffer (if relevent). {start_row}
+ with the current text of the buffer (if relevant). {start_row}
and {end_row} can be used to limit matches inside a row range
(this is typically used with root node as the node, i e to get
syntax highlight matches in the current viewport). When
@@ -503,8 +503,7 @@ Query:iter_captures({self}, {node}, {source}, {start}, {stop})
Parameters: ~
{node} The node under which the search will occur
- {source} The source buffer or string to exctract text
- from
+ {source} The source buffer or string to extract text from
{start} The starting line of the search
{stop} The stopping line of the search (end-exclusive)
{self}
@@ -531,9 +530,11 @@ 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
@@ -609,7 +610,7 @@ LanguageTree:children({self}) *LanguageTree:children()*
{self}
LanguageTree:contains({self}, {range}) *LanguageTree:contains()*
- Determines wether This goes down the tree to recursively check childs.
+ Determines whether This goes down the tree to recursively check children.
Parameters: ~
{range} is contained in this language tree
diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt
index d88f4f42e8..956cb3e624 100644
--- a/runtime/doc/vim_diff.txt
+++ b/runtime/doc/vim_diff.txt
@@ -428,7 +428,7 @@ Working directory (Vim implemented some of these later than Nvim):
- |DirChanged| can be triggered when switching to another window.
- |getcwd()| and |haslocaldir()| may throw errors if the tab page or window
cannot be found. *E5000* *E5001* *E5002*
-- |haslocaldir()| only checks for tab-local directory when -1 is passed as
+- |haslocaldir()| checks for tab-local directory if and only if -1 is passed as
window number, and its only possible returns values are 0 and 1.
- `getcwd(-1)` is equivalent to `getcwd(-1, 0)` instead of returning the global
working directory. Use `getcwd(-1, -1)` to get the global working directory.
diff --git a/runtime/filetype.vim b/runtime/filetype.vim
index 1b48070128..e1c917ac64 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 Nov 16
+" Last Change: 2021 Dec 03
" Listen very carefully, I will say this only once
if exists("did_load_filetypes")
@@ -119,7 +119,7 @@ au BufNewFile,BufRead *.aml setf aml
" APT config file
au BufNewFile,BufRead apt.conf setf aptconf
au BufNewFile,BufRead */.aptitude/config setf aptconf
-au BufNewFile,BufRead */etc/apt/apt.conf.d/{[-_[:alnum:]]\+,[-_.[:alnum:]]\+.conf} setf aptconf
+" more generic pattern far down
" Arch Inventory file
au BufNewFile,BufRead .arch-inventory,=tagging-method setf arch
@@ -484,7 +484,7 @@ au BufNewFile,BufRead *.desktop,*.directory setf desktop
au BufNewFile,BufRead dict.conf,.dictrc setf dictconf
" Dictd config
-au BufNewFile,BufRead dictd.conf setf dictdconf
+au BufNewFile,BufRead dictd*.conf setf dictdconf
" Diff files
au BufNewFile,BufRead *.diff,*.rej setf diff
@@ -628,7 +628,7 @@ au BufNewFile,BufRead auto.master setf conf
au BufNewFile,BufRead *.mas,*.master setf master
" Forth
-au BufNewFile,BufRead *.fs,*.ft,*.fth setf forth
+au BufNewFile,BufRead *.ft,*.fth setf forth
" Reva Forth
au BufNewFile,BufRead *.frt setf reva
@@ -645,6 +645,12 @@ au BufNewFile,BufRead *.fsl setf framescript
" FStab
au BufNewFile,BufRead fstab,mtab setf fstab
+" F# or Forth
+au BufNewFile,BufRead *.fs call dist#ft#FTfs()
+
+" F#
+au BufNewFile,BufRead *.fsi,*.fsx setf fsharp
+
" GDB command files
au BufNewFile,BufRead .gdbinit,gdbinit setf gdb
@@ -1095,6 +1101,9 @@ au BufNewFile,BufRead *.moo setf moo
" Modconf
au BufNewFile,BufRead */etc/modules.conf,*/etc/modules,*/etc/conf.modules setf modconf
+" MPD is based on XML
+au BufNewFile,BufRead *.mpd setf xml
+
" Mplayer config
au BufNewFile,BufRead mplayer.conf,*/.mplayer/config setf mplayerconf
@@ -1110,14 +1119,15 @@ au BufNewFile,BufRead *.msql setf msql
" Mysql
au BufNewFile,BufRead *.mysql setf mysql
-" Mutt setup files (must be before catch *.rc)
-au BufNewFile,BufRead */etc/Muttrc.d/* call s:StarSetf('muttrc')
-
" Tcl Shell RC file
au BufNewFile,BufRead tclsh.rc setf tcl
" M$ Resource files
-au BufNewFile,BufRead *.rc,*.rch setf rc
+" /etc/Muttrc.d/file.rc is muttrc
+au BufNewFile,BufRead *.rc,*.rch
+ \ if expand("<afile>") !~ "/etc/Muttrc.d/" |
+ \ setf rc |
+ \ endif
" MuPAD source
au BufRead,BufNewFile *.mu setf mupad
@@ -1743,6 +1753,9 @@ au BufNewFile,BufRead *.sqlj setf sqlj
" SQR
au BufNewFile,BufRead *.sqr,*.sqi setf sqr
+" Squirrel
+au BufNewFile,BufRead *.nut setf squirrel
+
" OpenSSH configuration
au BufNewFile,BufRead ssh_config,*/.ssh/config setf sshconfig
au BufNewFile,BufRead */etc/ssh/ssh_config.d/*.conf setf sshconfig
@@ -2055,9 +2068,15 @@ au BufNewFile,BufRead *.xml call dist#ft#FTxml()
" XMI (holding UML models) is also XML
au BufNewFile,BufRead *.xmi setf xml
-" CSPROJ files are Visual Studio.NET's XML-based project config files
+" CSPROJ files are Visual Studio.NET's XML-based C# project config files
au BufNewFile,BufRead *.csproj,*.csproj.user setf xml
+" FSPROJ files are Visual Studio.NET's XML-based F# project config files
+au BufNewFile,BufRead *.fsproj,*.fsproj.user setf xml
+
+" VBPROJ files are Visual Studio.NET's XML-based Visual Basic project config files
+au BufNewFile,BufRead *.vbproj,*.vbproj.user setf xml
+
" Qt Linguist translation source and Qt User Interface Files are XML
" However, for .ts Typescript is more common.
au BufNewFile,BufRead *.ui setf xml
@@ -2143,6 +2162,12 @@ au BufNewFile,BufRead *
au StdinReadPost * if !did_filetype() | runtime! scripts.vim | endif
+" Plain text files, needs to be far down to not override others. This avoids
+" the "conf" type being used if there is a line starting with '#'.
+" But before patterns matching everything in a directory.
+au BufNewFile,BufRead *.text,README,LICENSE,COPYING,AUTHORS setf text
+
+
" Extra checks for when no filetype has been detected now. Mostly used for
" patterns that end in "*". E.g., "zsh*" matches "zsh.vim", but that's a Vim
" script file.
@@ -2155,7 +2180,10 @@ au BufNewFile,BufRead proftpd.conf* call s:StarSetf('apachestyle')
" More Apache config files
au BufNewFile,BufRead access.conf*,apache.conf*,apache2.conf*,httpd.conf*,srm.conf* call s:StarSetf('apache')
-au BufNewFile,BufRead */etc/apache2/*.conf*,*/etc/apache2/conf.*/*,*/etc/apache2/mods-*/*,*/etc/apache2/sites-*/*,*/etc/httpd/conf.d/*.conf* call s:StarSetf('apache')
+au BufNewFile,BufRead */etc/apache2/*.conf*,*/etc/apache2/conf.*/*,*/etc/apache2/mods-*/*,*/etc/apache2/sites-*/*,*/etc/httpd/conf.*/*,*/etc/httpd/mods-*/*,*/etc/httpd/sites-*/*,*/etc/httpd/conf.d/*.conf* call s:StarSetf('apache')
+
+" APT config file
+au BufNewFile,BufRead */etc/apt/apt.conf.d/{[-_[:alnum:]]\+,[-_.[:alnum:]]\+.conf} call s:StarSetf('aptconf')
" Asterisk config file
au BufNewFile,BufRead *asterisk/*.conf* call s:StarSetf('asterisk')
@@ -2258,6 +2286,9 @@ au BufNewFile,BufRead */etc/modutils/*
\|endif
au BufNewFile,BufRead */etc/modprobe.* call s:StarSetf('modconf')
+" Mutt setup files (must be before catch *.rc)
+au BufNewFile,BufRead */etc/Muttrc.d/* call s:StarSetf('muttrc')
+
" Mutt setup file
au BufNewFile,BufRead .mutt{ng,}rc*,*/.mutt{ng,}/mutt{ng,}rc* call s:StarSetf('muttrc')
au BufNewFile,BufRead mutt{ng,}rc*,Mutt{ng,}rc* call s:StarSetf('muttrc')
@@ -2350,10 +2381,6 @@ au BufNewFile,BufRead .zsh*,.zlog*,.zcompdump* call s:StarSetf('zsh')
au BufNewFile,BufRead zsh*,zlog* call s:StarSetf('zsh')
-" Plain text files, needs to be far down to not override others. This avoids
-" the "conf" type being used if there is a line starting with '#'.
-au BufNewFile,BufRead *.text,README setf text
-
" Help files match *.txt but should have a last line that is a modeline.
au BufNewFile,BufRead *.txt
\ if getline('$') !~ 'vim:.*ft=help'
diff --git a/runtime/ftplugin/jsonc.vim b/runtime/ftplugin/jsonc.vim
index 90d52cd0d3..e47a75f574 100644
--- a/runtime/ftplugin/jsonc.vim
+++ b/runtime/ftplugin/jsonc.vim
@@ -4,7 +4,7 @@
" Acknowledgement: Based off of vim-jsonc maintained by Kevin Locke <kevin@kevinlocke.name>
" https://github.com/kevinoid/vim-jsonc
" License: MIT
-" Last Change: 2021-07-01
+" Last Change: 2021 Nov 22
runtime! ftplugin/json.vim
@@ -14,14 +14,8 @@ else
let b:did_ftplugin_jsonc = 1
endif
-" A list of commands that undo buffer local changes made below.
-let s:undo_ftplugin = []
-
" Set comment (formatting) related options. {{{1
setlocal commentstring=//%s comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,://
-call add(s:undo_ftplugin, 'commentstring< comments<')
" Let Vim know how to disable the plug-in.
-call map(s:undo_ftplugin, "'execute ' . string(v:val)")
-let b:undo_ftplugin = join(s:undo_ftplugin, ' | ')
-unlet s:undo_ftplugin
+let b:undo_ftplugin = 'setlocal commentstring< comments<'
diff --git a/runtime/indent/vim.vim b/runtime/indent/vim.vim
index a98c75e541..7c03ff2873 100644
--- a/runtime/indent/vim.vim
+++ b/runtime/indent/vim.vim
@@ -1,7 +1,7 @@
" Vim indent file
" Language: Vim script
" Maintainer: Bram Moolenaar <Bram@vim.org>
-" Last Change: 2021 Nov 03
+" Last Change: 2021 Nov 27
" Only load this indent file when no other was loaded.
if exists("b:did_indent")
@@ -12,6 +12,7 @@ let b:did_indent = 1
setlocal indentexpr=GetVimIndent()
setlocal indentkeys+==end,=},=else,=cat,=finall,=END,0\\,0=\"\\\
setlocal indentkeys-=0#
+setlocal indentkeys-=:
let b:undo_indent = "setl indentkeys< indentexpr<"
diff --git a/runtime/lua/vim/F.lua b/runtime/lua/vim/F.lua
index 1a258546a5..9327c652db 100644
--- a/runtime/lua/vim/F.lua
+++ b/runtime/lua/vim/F.lua
@@ -27,7 +27,7 @@ function F.nil_wrap(fn)
end
end
---- like {...} except preserve the lenght explicitly
+--- like {...} except preserve the length explicitly
function F.pack_len(...)
return {n=select('#', ...), ...}
end
diff --git a/runtime/lua/vim/_meta.lua b/runtime/lua/vim/_meta.lua
index f7d47c1030..522e26caa7 100644
--- a/runtime/lua/vim/_meta.lua
+++ b/runtime/lua/vim/_meta.lua
@@ -16,10 +16,6 @@ for _, v in pairs(a.nvim_get_all_options_info()) do
if v.shortname ~= "" then options_info[v.shortname] = v end
end
-local is_global_option = function(info) return info.scope == "global" end
-local is_buffer_option = function(info) return info.scope == "buf" end
-local is_window_option = function(info) return info.scope == "win" end
-
local get_scoped_options = function(scope)
local result = {}
for name, option_info in pairs(options_info) do
@@ -133,107 +129,18 @@ do -- window option accessor
vim.wo = new_win_opt_accessor(nil)
end
---[[
-Local window setter
-
-buffer options: does not get copied when split
- nvim_set_option(buf_opt, value) -> sets the default for NEW buffers
- this sets the hidden global default for buffer options
-
- nvim_buf_set_option(...) -> sets the local value for the buffer
-
- set opt=value, does BOTH global default AND buffer local value
- setlocal opt=value, does ONLY buffer local value
-
-window options: gets copied
- does not need to call nvim_set_option because nobody knows what the heck this does⸮
- We call it anyway for more readable code.
-
-
- Command global value local value
- :set option=value set set
- :setlocal option=value - set
-:setglobal option=value set -
---]]
-local function set_scoped_option(k, v, set_type)
- local info = options_info[k]
-
- -- Don't let people do setlocal with global options.
- -- That is a feature that doesn't make sense.
- if set_type == SET_TYPES.LOCAL and is_global_option(info) then
- error(string.format("Unable to setlocal option: '%s', which is a global option.", k))
- end
-
- -- Only `setlocal` skips setting the default/global value
- -- This will more-or-less noop for window options, but that's OK
- if set_type ~= SET_TYPES.LOCAL then
- a.nvim_set_option(k, v)
- end
-
- if is_window_option(info) then
- if set_type ~= SET_TYPES.GLOBAL then
- a.nvim_win_set_option(0, k, v)
- end
- elseif is_buffer_option(info) then
- if set_type == SET_TYPES.LOCAL
- or (set_type == SET_TYPES.SET and not info.global_local) then
- a.nvim_buf_set_option(0, k, v)
- end
- end
-end
-
---[[
-Local window getter
-
- Command global value local value
- :set option? - display
- :setlocal option? - display
-:setglobal option? display -
---]]
-local function get_scoped_option(k, set_type)
- local info = assert(options_info[k], "Must be a valid option: " .. tostring(k))
-
- if set_type == SET_TYPES.GLOBAL or is_global_option(info) then
- return a.nvim_get_option(k)
- end
-
- if is_buffer_option(info) then
- local was_set, value = pcall(a.nvim_buf_get_option, 0, k)
- if was_set then return value end
-
- if info.global_local then
- return a.nvim_get_option(k)
- end
-
- error("buf_get: This should not be able to happen, given my understanding of options // " .. k)
- end
-
- if is_window_option(info) then
- local ok, value = pcall(a.nvim_win_get_option, 0, k)
- if ok then
- return value
- end
-
- local global_ok, global_val = pcall(a.nvim_get_option, k)
- if global_ok then
- return global_val
- end
-
- error("win_get: This should never happen. File an issue and tag @tjdevries")
- end
-
- error("This fallback case should not be possible. " .. k)
-end
-
-- vim global option
-- this ONLY sets the global option. like `setglobal`
-vim.go = make_meta_accessor(a.nvim_get_option, a.nvim_set_option)
+vim.go = make_meta_accessor(
+ function(k) return a.nvim_get_option_value(k, {scope = "global"}) end,
+ function(k, v) return a.nvim_set_option_value(k, v, {scope = "global"}) end
+)
-- vim `set` style options.
-- it has no additional metamethod magic.
vim.o = make_meta_accessor(
- function(k) return get_scoped_option(k, SET_TYPES.SET) end,
- function(k, v) return set_scoped_option(k, v, SET_TYPES.SET) end
+ function(k) return a.nvim_get_option_value(k, {}) end,
+ function(k, v) return a.nvim_set_option_value(k, v, {}) end
)
---@brief [[
@@ -389,6 +296,10 @@ local convert_value_to_vim = (function()
}
return function(name, info, value)
+ if value == nil then
+ return vim.NIL
+ end
+
local option_type = get_option_type(name, info)
assert_valid_value(name, value, valid_types[option_type])
@@ -398,7 +309,7 @@ end)()
--- Converts a vimoption_T style value to a Lua value
local convert_value_to_lua = (function()
- -- Map of OptionType to functions that take vimoption_T values and conver to lua values.
+ -- Map of OptionType to functions that take vimoption_T values and convert to lua values.
-- Each function takes (info, vim_value) -> lua_value
local to_lua_value = {
[OptionTypes.BOOLEAN] = function(_, value) return value end,
@@ -671,15 +582,19 @@ local create_option_metatable = function(set_type)
}, option_mt)
end
- -- TODO(tjdevries): consider supporting `nil` for set to remove the local option.
- -- vim.cmd [[set option<]]
+ local scope
+ if set_type == SET_TYPES.GLOBAL then
+ scope = "global"
+ elseif set_type == SET_TYPES.LOCAL then
+ scope = "local"
+ end
option_mt = {
-- To set a value, instead use:
-- opt[my_option] = value
_set = function(self)
local value = convert_value_to_vim(self._name, self._info, self._value)
- set_scoped_option(self._name, value, set_type)
+ a.nvim_set_option_value(self._name, value, {scope = scope})
return self
end,
@@ -716,7 +631,7 @@ local create_option_metatable = function(set_type)
set_mt = {
__index = function(_, k)
- return make_option(k, get_scoped_option(k, set_type))
+ return make_option(k, a.nvim_get_option_value(k, {scope = scope}))
end,
__newindex = function(_, k, v)
diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua
index 015db54d34..ac4081bb54 100644
--- a/runtime/lua/vim/diagnostic.lua
+++ b/runtime/lua/vim/diagnostic.lua
@@ -386,7 +386,7 @@ local function get_diagnostics(bufnr, opts, clamp)
if not opts.lnum or d.lnum == opts.lnum then
if clamp and vim.api.nvim_buf_is_loaded(b) then
local line_count = buf_line_count[b] - 1
- if (d.lnum > line_count or d.end_lnum > line_count) then
+ if (d.lnum > line_count or d.end_lnum > line_count or d.lnum < 0 or d.end_lnum < 0) then
d = vim.deepcopy(d)
d.lnum = math.max(math.min(d.lnum, line_count), 0)
d.end_lnum = math.max(math.min(d.end_lnum, line_count), 0)
@@ -508,10 +508,13 @@ local function diagnostic_move_pos(opts, pos)
return
end
- -- Save position in the window's jumplist
- vim.api.nvim_win_call(win_id, function() vim.cmd("normal! m'") end)
-
- vim.api.nvim_win_set_cursor(win_id, {pos[1] + 1, pos[2]})
+ vim.api.nvim_win_call(win_id, function()
+ -- Save position in the window's jumplist
+ vim.cmd("normal! m'")
+ vim.api.nvim_win_set_cursor(win_id, {pos[1] + 1, pos[2]})
+ -- Open folds under the cursor
+ vim.cmd("normal! zv")
+ end)
if float then
local float_opts = type(float) == "table" and float or {}
@@ -520,7 +523,7 @@ local function diagnostic_move_pos(opts, pos)
vim.api.nvim_win_get_buf(win_id),
vim.tbl_extend("keep", float_opts, {
scope = "cursor",
- focusable = false,
+ focus = false,
})
)
end)
@@ -579,26 +582,7 @@ end
--- * priority: (number, default 10) Base priority to use for signs. When
--- {severity_sort} is used, the priority of a sign is adjusted based on
--- its severity. Otherwise, all signs use the same priority.
---- - float: Options for floating windows:
---- * severity: See |diagnostic-severity|.
---- * header: (string or table) String to use as the header for the floating
---- window. If a table, it is interpreted as a [text, hl_group] tuple.
---- Defaults to "Diagnostics:".
---- * source: (string) Include the diagnostic source in
---- the message. One of "always" or "if_many".
---- * format: (function) A function that takes a diagnostic as input and returns a
---- string. The return value is the text used to display the diagnostic.
---- * prefix: (function, string, or table) Prefix each diagnostic in the floating
---- window. If a function, it must have the signature (diagnostic, i,
---- total) -> (string, string), where {i} is the index of the diagnostic
---- being evaluated and {total} is the total number of diagnostics
---- displayed in the window. The function should return a string which
---- is prepended to each diagnostic in the window as well as an
---- (optional) highlight group which will be used to highlight the
---- prefix. If {prefix} is a table, it is interpreted as a [text,
---- hl_group] tuple as in |nvim_echo()|; otherwise, if {prefix} is a
---- string, it is prepended to each diagnostic in the window with no
---- highlight.
+--- - float: Options for floating windows. See |vim.diagnostic.open_float()|.
--- - update_in_insert: (default false) Update diagnostics in Insert mode (if false,
--- diagnostics are updated on InsertLeave)
--- - severity_sort: (default false) Sort diagnostics by severity. This affects the order in
@@ -606,6 +590,7 @@ end
--- are displayed before lower severities (e.g. ERROR is displayed before WARN).
--- Options:
--- * reverse: (boolean) Reverse sort order
+---
---@param namespace number|nil Update the options for the given namespace. When omitted, update the
--- global diagnostic options.
function M.config(opts, namespace)
@@ -668,12 +653,17 @@ function M.set(namespace, bufnr, diagnostics, opts)
end
if vim.api.nvim_buf_is_loaded(bufnr) then
- M.show(namespace, bufnr, diagnostics, opts)
+ M.show(namespace, bufnr, nil, opts)
end
- vim.api.nvim_command(
- string.format("doautocmd <nomodeline> DiagnosticChanged %s", vim.api.nvim_buf_get_name(bufnr))
- )
+ vim.api.nvim_buf_call(bufnr, function()
+ vim.api.nvim_command(
+ string.format(
+ "doautocmd <nomodeline> DiagnosticChanged %s",
+ vim.fn.fnameescape(vim.api.nvim_buf_get_name(bufnr))
+ )
+ )
+ end)
end
--- Get namespace metadata.
@@ -800,7 +790,9 @@ end
--- - severity: See |diagnostic-severity|.
--- - float: (boolean or table, default true) If "true", call |vim.diagnostic.open_float()|
--- after moving. If a table, pass the table as the {opts} parameter to
---- |vim.diagnostic.open_float()|.
+--- |vim.diagnostic.open_float()|. Unless overridden, the float will show
+--- diagnostics at the new cursor position (as if "cursor" were passed to
+--- the "scope" option).
--- - win_id: (number, default 0) Window ID
function M.goto_next(opts)
return diagnostic_move_pos(
@@ -1147,7 +1139,7 @@ end
---@param opts table|nil Configuration table with the same keys as
--- |vim.lsp.util.open_floating_preview()| in addition to the following:
--- - namespace: (number) Limit diagnostics to the given namespace
---- - scope: (string, default "buffer") Show diagnostics from the whole buffer ("buffer"),
+--- - scope: (string, default "line") Show diagnostics from the whole buffer ("buffer"),
--- the current cursor line ("line"), or the current cursor position ("cursor").
--- - pos: (number or table) If {scope} is "line" or "cursor", use this position rather
--- than the cursor position. If a number, interpreted as a line number;
@@ -1164,7 +1156,17 @@ end
--- - format: (function) A function that takes a diagnostic as input and returns a
--- string. The return value is the text used to display the diagnostic.
--- Overrides the setting from |vim.diagnostic.config()|.
---- - prefix: (function, string, or table) Prefix each diagnostic in the floating window.
+--- - prefix: (function, string, or table) Prefix each diagnostic in the floating
+--- window. If a function, it must have the signature (diagnostic, i,
+--- total) -> (string, string), where {i} is the index of the diagnostic
+--- being evaluated and {total} is the total number of diagnostics
+--- displayed in the window. The function should return a string which
+--- is prepended to each diagnostic in the window as well as an
+--- (optional) highlight group which will be used to highlight the
+--- prefix. If {prefix} is a table, it is interpreted as a [text,
+--- hl_group] tuple as in |nvim_echo()|; otherwise, if {prefix} is a
+--- string, it is prepended to each diagnostic in the window with no
+--- highlight.
--- Overrides the setting from |vim.diagnostic.config()|.
---@return tuple ({float_bufnr}, {win_id})
function M.open_float(bufnr, opts)
@@ -1175,7 +1177,7 @@ function M.open_float(bufnr, opts)
opts = opts or {}
bufnr = get_bufnr(bufnr)
- local scope = opts.scope or "buffer"
+ local scope = opts.scope or "line"
local lnum, col
if scope == "line" or scope == "cursor" then
if not opts.pos then
@@ -1334,7 +1336,10 @@ function M.reset(namespace, bufnr)
end
vim.api.nvim_command(
- string.format("doautocmd <nomodeline> DiagnosticChanged %s", vim.api.nvim_buf_get_name(bufnr))
+ string.format(
+ "doautocmd <nomodeline> DiagnosticChanged %s",
+ vim.fn.fnameescape(vim.api.nvim_buf_get_name(bufnr))
+ )
)
end
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua
index 6abb81d144..dbbfd7d1d8 100644
--- a/runtime/lua/vim/lsp.lua
+++ b/runtime/lua/vim/lsp.lua
@@ -137,12 +137,6 @@ local all_buffer_active_clients = {}
local uninitialized_clients = {}
---@private
---- Invokes a function for each LSP client attached to the buffer {bufnr}.
----
----@param bufnr (Number) of buffer
----@param fn (function({client}, {client_id}, {bufnr}) Function to run on
----each client attached to that buffer.
----@param restrict_client_ids table list of client ids on which to restrict function application.
local function for_each_buffer_client(bufnr, fn, restrict_client_ids)
validate {
fn = { fn, 'f' };
@@ -327,6 +321,7 @@ do
--- timer?: uv_timer
local state_by_client = {}
+ ---@private
function changetracking.init(client, bufnr)
local state = state_by_client[client.id]
if not state then
@@ -348,6 +343,7 @@ do
state.buffers[bufnr] = nvim_buf_get_lines(bufnr, 0, -1, true)
end
+ ---@private
function changetracking.reset_buf(client, bufnr)
changetracking.flush(client)
local state = state_by_client[client.id]
@@ -356,6 +352,7 @@ do
end
end
+ ---@private
function changetracking.reset(client_id)
local state = state_by_client[client_id]
if state then
@@ -364,6 +361,7 @@ do
end
end
+ ---@private
function changetracking.prepare(bufnr, firstline, lastline, new_lastline)
local incremental_changes = function(client)
local cached_buffers = state_by_client[client.id].buffers
@@ -447,6 +445,7 @@ do
end
--- Flushes any outstanding change notification.
+ ---@private
function changetracking.flush(client)
local state = state_by_client[client.id]
if state then
@@ -560,6 +559,12 @@ end
---
--- - {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()|.
---
@@ -621,7 +626,7 @@ end
---
---@param 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
+--- must be a unique command name, and the value is a function which is called if any LSP action
--- (code action, code lenses, ...) triggers the command.
---
---@param init_options Values to pass in the initialization request
@@ -675,8 +680,8 @@ end
--- 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
--- 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.
+--- 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
@@ -1034,7 +1039,7 @@ function lsp.start_client(config)
return rpc.notify("$/cancelRequest", { id = id })
end
- -- Track this so that we can escalate automatically if we've alredy tried a
+ -- Track this so that we can escalate automatically if we've already tried a
-- graceful shutdown
local graceful_shutdown_failed = false
---@private
@@ -1218,7 +1223,7 @@ end
--- Gets a client by id, or nil if the id is invalid.
--- The returned client may not yet be fully initialized.
---
+---
---@param client_id number client id
---
---@returns |vim.lsp.client| object, or nil
@@ -1227,7 +1232,7 @@ function lsp.get_client_by_id(client_id)
end
--- Returns list of buffers attached to client_id.
---
+---
---@param client_id number client id
---@returns list of buffer ids
function lsp.get_buffers_by_client_id(client_id)
@@ -1297,6 +1302,7 @@ function lsp._vim_exit_handler()
local poll_time = 50
+ ---@private
local function check_clients_closed()
for client_id, timeout in pairs(timeouts) do
timeouts[client_id] = timeout - poll_time
@@ -1331,8 +1337,8 @@ nvim_command("autocmd VimLeavePre * lua vim.lsp._vim_exit_handler()")
---@param method (string) LSP method name
---@param params (optional, table) Parameters to send to the server
---@param handler (optional, function) See |lsp-handler|
--- If nil, follows resolution strategy defined in |lsp-handler-configuration|
---
+--- If nil, follows resolution strategy defined in |lsp-handler-configuration|
+---
---@returns 2-tuple:
--- - Map of client-id:request-id pairs for all successful requests.
--- - Function which can be used to cancel all the requests. You could instead
@@ -1683,7 +1689,17 @@ function lsp.get_log_path()
return log.get_filename()
end
---- Call {fn} for every client attached to {bufnr}
+--- Invokes a function for each LSP client attached to a buffer.
+---
+---@param bufnr number Buffer number
+---@param fn function Function to run on each client attached to buffer
+--- {bufnr}. The function takes the client, client ID, and
+--- buffer number as arguments. Example:
+--- <pre>
+--- vim.lsp.for_each_buffer_client(0, function(client, client_id, bufnr)
+--- print(vim.inspect(client))
+--- end)
+--- </pre>
function lsp.for_each_buffer_client(bufnr, fn)
return for_each_buffer_client(bufnr, fn)
end
@@ -1742,11 +1758,11 @@ end
--- using `workspace/executeCommand`.
---
--- The first argument to the function will be the `Command`:
--- Command
--- title: String
--- command: String
--- arguments?: any[]
---
+--- Command
+--- title: String
+--- command: String
+--- arguments?: any[]
+---
--- The second argument is the `ctx` of |lsp-handler|
lsp.commands = setmetatable({}, {
__newindex = function(tbl, key, value)
diff --git a/runtime/lua/vim/lsp/buf.lua b/runtime/lua/vim/lsp/buf.lua
index be9bd9d223..f02ebfb9dc 100644
--- a/runtime/lua/vim/lsp/buf.lua
+++ b/runtime/lua/vim/lsp/buf.lua
@@ -165,7 +165,7 @@ end
--- saved. {timeout_ms} is passed on to |vim.lsp.buf_request_sync()|. Example:
---
--- <pre>
---- vim.api.nvim_command[[autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync()]]
+--- autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync()
--- </pre>
---
---@param options Table with valid `FormattingOptions` entries
@@ -263,6 +263,7 @@ function M.rename(new_name)
request('textDocument/rename', params)
end
+ ---@private
local function prepare_rename(err, result)
if err == nil and result == nil then
vim.notify('nothing to rename', vim.log.levels.INFO)
@@ -446,9 +447,9 @@ end
--- by events such as `CursorHold`, eg:
---
--- <pre>
---- vim.api.nvim_command [[autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()]]
---- vim.api.nvim_command [[autocmd CursorHoldI <buffer> lua vim.lsp.buf.document_highlight()]]
---- vim.api.nvim_command [[autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()]]
+--- autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
+--- autocmd CursorHoldI <buffer> lua vim.lsp.buf.document_highlight()
+--- autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
--- </pre>
---
--- Note: Usage of |vim.lsp.buf.document_highlight()| requires the following highlight groups
diff --git a/runtime/lua/vim/lsp/diagnostic.lua b/runtime/lua/vim/lsp/diagnostic.lua
index 3b214c49f9..075da41b23 100644
--- a/runtime/lua/vim/lsp/diagnostic.lua
+++ b/runtime/lua/vim/lsp/diagnostic.lua
@@ -222,7 +222,7 @@ function M.on_publish_diagnostics(_, result, ctx, config)
vim.diagnostic.set(namespace, bufnr, diagnostic_lsp_to_vim(diagnostics, bufnr, client_id))
end
---- Clear diagnotics and diagnostic cache.
+--- Clear diagnostics and diagnostic cache.
---
--- Diagnostic producers should prefer |vim.diagnostic.reset()|. However,
--- this method signature is still used internally in some parts of the LSP
@@ -431,24 +431,6 @@ end
--- Move to the next diagnostic
---
---@deprecated Prefer |vim.diagnostic.goto_next()|
----
----@param opts table|nil Configuration table. Keys:
---- - {client_id}: (number)
---- - If nil, will consider all clients attached to buffer.
---- - {cursor_position}: (Position, default current position)
---- - See |nvim_win_get_cursor()|
---- - {wrap}: (boolean, default true)
---- - Whether to loop around file or not. Similar to 'wrapscan'
---- - {severity}: (DiagnosticSeverity)
---- - Exclusive severity to consider. Overrides {severity_limit}
---- - {severity_limit}: (DiagnosticSeverity)
---- - Limit severity of diagnostics found. E.g. "Warning" means { "Error", "Warning" } will be valid.
---- - {enable_popup}: (boolean, default true)
---- - Call |vim.lsp.diagnostic.show_line_diagnostics()| on jump
---- - {popup_opts}: (table)
---- - Table to pass as {opts} parameter to |vim.lsp.diagnostic.show_line_diagnostics()|
---- - {win_id}: (number, default 0)
---- - Window ID
function M.goto_next(opts)
if opts then
if opts.severity then
@@ -562,7 +544,7 @@ end
--- Open a floating window with the diagnostics from {line_nr}
---
----@deprecated Prefer |vim.diagnostic.show_line_diagnostics()|
+---@deprecated Prefer |vim.diagnostic.open_float()|
---
---@param opts table Configuration table
--- - all opts for |vim.lsp.diagnostic.get_line_diagnostics()| and
diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua
index fa4f2b22a5..22089aaaa6 100644
--- a/runtime/lua/vim/lsp/handlers.lua
+++ b/runtime/lua/vim/lsp/handlers.lua
@@ -28,7 +28,7 @@ local function progress_handler(_, result, ctx, _)
local client_name = client and client.name or string.format("id=%d", client_id)
if not client then
err_message("LSP[", client_name, "] client has shut down after sending the message")
- return
+ return vim.NIL
end
local val = result.value -- unspecified yet
local token = result.token -- string or number
@@ -70,6 +70,7 @@ M['window/workDoneProgress/create'] = function(_, result, ctx)
local client_name = client and client.name or string.format("id=%d", client_id)
if not client then
err_message("LSP[", client_name, "] client has shut down after sending the message")
+ return vim.NIL
end
client.messages.progress[token] = {}
return vim.NIL
diff --git a/runtime/lua/vim/lsp/log.lua b/runtime/lua/vim/lsp/log.lua
index 4597f1919a..dbc473b52c 100644
--- a/runtime/lua/vim/lsp/log.lua
+++ b/runtime/lua/vim/lsp/log.lua
@@ -101,6 +101,7 @@ function log.set_level(level)
end
--- Gets the current log level.
+---@return string current log level
function log.get_level()
return current_log_level
end
diff --git a/runtime/lua/vim/lsp/rpc.lua b/runtime/lua/vim/lsp/rpc.lua
index ff8d7e0338..1fb75ddeb7 100644
--- a/runtime/lua/vim/lsp/rpc.lua
+++ b/runtime/lua/vim/lsp/rpc.lua
@@ -230,7 +230,7 @@ function default_dispatchers.on_error(code, err)
end
--- Starts an LSP server process and create an LSP RPC client object to
---- interact with it.
+--- interact with it. Communication with the server is currently limited to stdio.
---
---@param cmd (string) Command to start the LSP server.
---@param cmd_args (table) List of additional string arguments to pass to {cmd}.
@@ -329,7 +329,7 @@ local function start(cmd, cmd_args, dispatchers, extra_spawn_params)
else
msg = msg .. string.format(" with error message: %s", pid)
end
- vim.notify(msg, vim.log.levels.ERROR)
+ vim.notify(msg, vim.log.levels.WARN)
return
end
end
diff --git a/runtime/lua/vim/lsp/sync.lua b/runtime/lua/vim/lsp/sync.lua
index f185e3973f..5df2a4d144 100644
--- a/runtime/lua/vim/lsp/sync.lua
+++ b/runtime/lua/vim/lsp/sync.lua
@@ -74,6 +74,7 @@ local function byte_to_utf(line, byte, offset_encoding)
return utf_idx + 1
end
+---@private
local function compute_line_length(line, offset_encoding)
local length
local _
@@ -133,7 +134,7 @@ local function compute_start_range(prev_lines, curr_lines, firstline, lastline,
-- occur on a new line pointed to by lastline. This occurs during insertion of
-- new lines(O), the new newline is inserted at the line indicated by
-- new_lastline.
- -- If firstline == new_lastline, the first change occured on a line that was deleted.
+ -- If firstline == new_lastline, the first change occurred on a line that was deleted.
-- In this case, the first byte change is also at the first byte of firstline
if firstline == new_lastline or firstline == lastline then
return { line_idx = firstline, byte_idx = 1, char_idx = 1 }
@@ -187,7 +188,7 @@ end
---@param offset_encoding string
---@returns (int, int) end_line_idx and end_col_idx of range
local function compute_end_range(prev_lines, curr_lines, start_range, firstline, lastline, new_lastline, offset_encoding)
- -- If firstline == new_lastline, the first change occured on a line that was deleted.
+ -- If firstline == new_lastline, the first change occurred on a line that was deleted.
-- In this case, the last_byte...
if firstline == new_lastline then
return { line_idx = (lastline - new_lastline + firstline), byte_idx = 1, char_idx = 1 }, { line_idx = firstline, byte_idx = 1, char_idx = 1 }
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua
index b88ddcd207..059e66c53a 100644
--- a/runtime/lua/vim/lsp/util.lua
+++ b/runtime/lua/vim/lsp/util.lua
@@ -158,6 +158,7 @@ end
local function get_lines(bufnr, rows)
rows = type(rows) == "table" and rows or { rows }
+ ---@private
local function buf_lines()
local lines = {}
for _, row in pairs(rows) do
@@ -262,6 +263,7 @@ local function get_line_byte_from_position(bufnr, position, offset_encoding)
end
--- Process and return progress reports from lsp server
+---@private
function M.get_progress_messages()
local new_messages = {}
@@ -557,7 +559,7 @@ local function remove_unmatch_completion_items(items, prefix)
end, items)
end
---- Acording to LSP spec, if the client set `completionItemKind.valueSet`,
+--- According to LSP spec, if the client set `completionItemKind.valueSet`,
--- the client must handle it properly even if it receives a value outside the
--- specification.
---
@@ -657,7 +659,7 @@ function M.rename(old_fname, new_fname, opts)
api.nvim_buf_delete(oldbuf, { force = true })
end
-
+---@private
local function create_file(change)
local opts = change.options or {}
-- from spec: Overwrite wins over `ignoreIfExists`
@@ -669,7 +671,7 @@ local function create_file(change)
vim.fn.bufadd(fname)
end
-
+---@private
local function delete_file(change)
local opts = change.options or {}
local fname = vim.uri_to_fname(change.uri)
@@ -963,6 +965,8 @@ function M.jump_to_location(location)
local row = range.start.line
local col = get_line_byte_from_position(0, range.start)
api.nvim_win_set_cursor(0, {row + 1, col})
+ -- Open folds under the cursor
+ vim.cmd("normal! zv")
return true
end
@@ -1137,7 +1141,7 @@ function M.stylize_markdown(bufnr, contents, opts)
markdown_lines[#stripped] = true
end
else
- -- strip any emty lines or separators prior to this separator in actual markdown
+ -- strip any empty lines or separators prior to this separator in actual markdown
if line:match("^---+$") then
while markdown_lines[#stripped] and (stripped[#stripped]:match("^%s*$") or stripped[#stripped]:match("^---+$")) do
markdown_lines[#stripped] = false
@@ -1170,7 +1174,7 @@ function M.stylize_markdown(bufnr, contents, opts)
local idx = 1
---@private
- -- keep track of syntaxes we already inlcuded.
+ -- keep track of syntaxes we already included.
-- no need to include the same syntax more than once
local langs = {}
local fences = get_markdown_fences()
@@ -1306,18 +1310,21 @@ end
---
---@param contents table of lines to show in window
---@param syntax string of syntax to set for opened buffer
----@param opts dictionary with optional fields
---- - height of floating window
---- - width of floating window
---- - wrap boolean enable wrapping of long lines (defaults to true)
---- - wrap_at character to wrap at for computing height when wrap is enabled
---- - max_width maximal width of floating window
---- - max_height maximal height of floating window
---- - pad_top number of lines to pad contents at top
---- - pad_bottom number of lines to pad contents at bottom
---- - focus_id if a popup with this id is opened, then focus it
---- - close_events list of events that closes the floating window
---- - focusable (boolean, default true): Make float focusable
+---@param opts table with optional fields (additional keys are passed on to |vim.api.nvim_open_win()|)
+--- - height: (number) height of floating window
+--- - width: (number) width of floating window
+--- - wrap: (boolean, default true) wrap long lines
+--- - wrap_at: (string) character to wrap at for computing height when wrap is enabled
+--- - max_width: (number) maximal width of floating window
+--- - max_height: (number) maximal height of floating window
+--- - pad_top: (number) number of lines to pad contents at top
+--- - pad_bottom: (number) number of lines to pad contents at bottom
+--- - focus_id: (string) if a popup with this id is opened, then focus it
+--- - close_events: (table) list of events that closes the floating window
+--- - focusable: (boolean, default true) Make float focusable
+--- - focus: (boolean, default true) If `true`, and if {focusable}
+--- is also `true`, focus an existing floating window with the same
+--- {focus_id}
---@returns bufnr,winnr buffer and window number of the newly created floating
---preview window
function M.open_floating_preview(contents, syntax, opts)
@@ -1329,12 +1336,13 @@ function M.open_floating_preview(contents, syntax, opts)
opts = opts or {}
opts.wrap = opts.wrap ~= false -- wrapping by default
opts.stylize_markdown = opts.stylize_markdown ~= false
+ opts.focus = opts.focus ~= false
opts.close_events = opts.close_events or {"CursorMoved", "CursorMovedI", "BufHidden", "InsertCharPre"}
local bufnr = api.nvim_get_current_buf()
-- check if this popup is focusable and we need to focus
- if opts.focus_id and opts.focusable ~= false then
+ if opts.focus_id and opts.focusable ~= false and opts.focus then
-- Go back to previous window if we are in a focusable one
local current_winnr = api.nvim_get_current_win()
if npcall(api.nvim_win_get_var, current_winnr, opts.focus_id) then
@@ -1414,7 +1422,7 @@ do --[[ References ]]
--- Removes document highlights from a buffer.
---
- ---@param bufnr buffer id
+ ---@param bufnr number Buffer id
function M.buf_clear_references(bufnr)
validate { bufnr = {bufnr, 'n', true} }
api.nvim_buf_clear_namespace(bufnr, reference_ns, 0, -1)
@@ -1422,9 +1430,9 @@ do --[[ References ]]
--- Shows a list of document highlights for a certain buffer.
---
- ---@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
+ ---@param bufnr number Buffer id
+ ---@param references table List of `DocumentHighlight` objects to highlight
+ ---@param offset_encoding string One of "utf-8", "utf-16", "utf-32", or 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, offset_encoding)
validate { bufnr = {bufnr, 'n', true} }
@@ -1542,7 +1550,7 @@ function M.set_qflist(items)
})
end
--- Acording to LSP spec, if the client set "symbolKind.valueSet",
+-- According to LSP spec, if the client set "symbolKind.valueSet",
-- the client must handle it properly even if it receives a value outside the specification.
-- https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_documentSymbol
function M._get_symbol_kind_name(symbol_kind)
diff --git a/runtime/lua/vim/shared.lua b/runtime/lua/vim/shared.lua
index bf77f0c776..1cf618725d 100644
--- a/runtime/lua/vim/shared.lua
+++ b/runtime/lua/vim/shared.lua
@@ -559,6 +559,7 @@ do
return type(val) == t or (t == 'callable' and vim.is_callable(val))
end
+ ---@private
local function is_valid(opt)
if type(opt) ~= 'table' then
return false, string.format('opt: expected table, got %s', type(opt))
diff --git a/runtime/lua/vim/treesitter.lua b/runtime/lua/vim/treesitter.lua
index 66999c5f7f..07f6418c0c 100644
--- a/runtime/lua/vim/treesitter.lua
+++ b/runtime/lua/vim/treesitter.lua
@@ -72,7 +72,7 @@ end
--- Gets the parser for this bufnr / ft combination.
---
--- If needed this will create the parser.
---- Unconditionnally attach the provided callback
+--- Unconditionally attach the provided callback
---
---@param bufnr The buffer the parser should be tied to
---@param lang The filetype of this parser
diff --git a/runtime/lua/vim/treesitter/language.lua b/runtime/lua/vim/treesitter/language.lua
index 89ddd6cd5a..6f347ff25f 100644
--- a/runtime/lua/vim/treesitter/language.lua
+++ b/runtime/lua/vim/treesitter/language.lua
@@ -38,7 +38,7 @@ end
--- Inspects the provided language.
---
---- Inspecting provides some useful informations on the language like node names, ...
+--- Inspecting provides some useful information on the language like node names, ...
---
---@param lang The language.
function M.inspect_language(lang)
diff --git a/runtime/lua/vim/treesitter/languagetree.lua b/runtime/lua/vim/treesitter/languagetree.lua
index 7e392f72a4..594765761d 100644
--- a/runtime/lua/vim/treesitter/languagetree.lua
+++ b/runtime/lua/vim/treesitter/languagetree.lua
@@ -493,9 +493,9 @@ local function tree_contains(tree, range)
return false
end
---- Determines wether @param range is contained in this language tree
+--- Determines whether @param range is contained in this language tree
---
---- This goes down the tree to recursively check childs.
+--- This goes down the tree to recursively check children.
---
---@param range A range, that is a `{ start_line, start_col, end_line, end_col }` table.
function LanguageTree:contains(range)
diff --git a/runtime/lua/vim/treesitter/query.lua b/runtime/lua/vim/treesitter/query.lua
index 66da179ea3..b8255e61ed 100644
--- a/runtime/lua/vim/treesitter/query.lua
+++ b/runtime/lua/vim/treesitter/query.lua
@@ -48,7 +48,7 @@ function M.get_query_files(lang, query_name, is_included)
local base_langs = {}
-- Now get the base languages by looking at the first line of every file
- -- The syntax is the folowing :
+ -- The syntax is the following :
-- ;+ inherits: ({language},)*{language}
--
-- {language} ::= {lang} | ({lang})
@@ -446,7 +446,7 @@ end
---
--- {source} is needed if the query contains predicates, then the caller
--- must ensure to use a freshly parsed tree consistent with the current
---- text of the buffer (if relevent). {start_row} and {end_row} can be used to limit
+--- text of the buffer (if relevant). {start_row} and {end_row} can be used to limit
--- matches inside a row range (this is typically used with root node
--- as the node, i e to get syntax highlight matches in the current
--- viewport). When omitted the start and end row values are used from the given node.
@@ -466,7 +466,7 @@ end
--- </pre>
---
---@param node The node under which the search will occur
----@param source The source buffer or string to exctract text from
+---@param source The source buffer or string to extract text from
---@param start The starting line of the search
---@param stop The stopping line of the search (end-exclusive)
---
diff --git a/runtime/nvim.appdata.xml b/runtime/nvim.appdata.xml
index 099c9a57c0..225dd79878 100644
--- a/runtime/nvim.appdata.xml
+++ b/runtime/nvim.appdata.xml
@@ -26,6 +26,7 @@
</screenshots>
<releases>
+ <release date="2021-11-30" version="0.6.0"/>
<release date="2021-07-02" version="0.5.0"/>
<release date="2020-08-04" version="0.4.4"/>
<release date="2019-11-06" version="0.4.3"/>
diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
index c5a9f503d5..67d91360d8 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 Nov 21
+" Last Change: 2021 Nov 29
"
" WORK IN PROGRESS - Only the basics work
" Note: On MS-Windows you need a recent version of gdb. The one included with
@@ -102,6 +102,7 @@ endfunc
call s:Highlight(1, '', &background)
hi default debugBreakpoint term=reverse ctermbg=red guibg=red
+hi default debugBreakpointDisabled term=reverse ctermbg=gray guibg=gray
func s:StartDebug(bang, ...)
" First argument is the command to debug, second core file or process ID.
@@ -241,15 +242,29 @@ func s:StartDebug_term(dict)
let comm_job_info = nvim_get_chan_info(s:comm_job_id)
let commpty = comm_job_info['pty']
- " Open a terminal window to run the debugger.
- " Add -quiet to avoid the intro message causing a hit-enter prompt.
let gdb_args = get(a:dict, 'gdb_args', [])
let proc_args = get(a:dict, 'proc_args', [])
- let cmd = [g:termdebugger, '-quiet', '-tty', pty, '--eval-command', 'echo startupdone\n'] + gdb_args
- "call ch_log('executing "' . join(cmd) . '"')
+ let gdb_cmd = [g:termdebugger]
+ " Add -quiet to avoid the intro message causing a hit-enter prompt.
+ let gdb_cmd += ['-quiet']
+ " Disable pagination, it causes everything to stop at the gdb
+ let gdb_cmd += ['-iex', 'set pagination off']
+ " Interpret commands while the target is running. This should usually only
+ " be exec-interrupt, since many commands don't work properly while the
+ " target is running (so execute during startup).
+ let gdb_cmd += ['-iex', 'set mi-async on']
+ " Open a terminal window to run the debugger.
+ let gdb_cmd += ['-tty', pty]
+ " Command executed _after_ startup is done, provides us with the necessary feedback
+ let gdb_cmd += ['-ex', 'echo startupdone\n']
+
+ " Adding arguments requested by the user
+ let gdb_cmd += gdb_args
+
execute 'new'
- let s:gdb_job_id = termopen(cmd, {'on_exit': function('s:EndTermDebug')})
+ " call ch_log('executing "' . join(gdb_cmd) . '"')
+ let s:gdb_job_id = termopen(gdb_cmd, {'on_exit': function('s:EndTermDebug')})
if s:gdb_job_id == 0
echoerr 'invalid argument (or job table is full) while opening gdb terminal window'
exe 'bwipe! ' . s:ptybuf
@@ -272,8 +287,8 @@ func s:StartDebug_term(dict)
for lnum in range(1, 200)
if get(getbufline(s:gdbbuf, lnum), 0, '') =~ 'startupdone'
- let try_count = 9999
- break
+ let try_count = 9999
+ break
endif
endfor
let try_count += 1
@@ -286,7 +301,7 @@ func s:StartDebug_term(dict)
" Set arguments to be run.
if len(proc_args)
- call chansend(s:gdb_job_id, 'set args ' . join(proc_args) . "\r")
+ call chansend(s:gdb_job_id, 'server set args ' . join(proc_args) . "\r")
endif
" Connect gdb to the communication pty, using the GDB/MI interface.
@@ -310,6 +325,7 @@ func s:StartDebug_term(dict)
let response = line1 . line2
if response =~ 'Undefined command'
echoerr 'Sorry, your gdb is too old, gdb 7.12 is required'
+ " CHECKME: possibly send a "server show version" here
call s:CloseBuffers()
return
endif
@@ -333,17 +349,6 @@ func s:StartDebug_term(dict)
sleep 10m
endwhile
- " Interpret commands while the target is running. This should usually only be
- " exec-interrupt, since many commands don't work properly while the target is
- " running.
- call s:SendCommand('-gdb-set mi-async on')
- " Older gdb uses a different command.
- call s:SendCommand('-gdb-set target-async on')
-
- " Disable pagination, it causes everything to stop at the gdb
- " "Type <return> to continue" prompt.
- call s:SendCommand('set pagination off')
-
" Set the filetype, this can be used to add mappings.
set filetype=termdebug
@@ -371,14 +376,26 @@ func s:StartDebug_prompt(dict)
exe (&columns / 2 - 1) . "wincmd |"
endif
- " Add -quiet to avoid the intro message causing a hit-enter prompt.
let gdb_args = get(a:dict, 'gdb_args', [])
let proc_args = get(a:dict, 'proc_args', [])
- let cmd = [g:termdebugger, '-quiet', '--interpreter=mi2'] + gdb_args
- "call ch_log('executing "' . join(cmd) . '"')
+ let gdb_cmd = [g:termdebugger]
+ " Add -quiet to avoid the intro message causing a hit-enter prompt.
+ let gdb_cmd += ['-quiet']
+ " Disable pagination, it causes everything to stop at the gdb, needs to be run early
+ let gdb_cmd += ['-iex', 'set pagination off']
+ " Interpret commands while the target is running. This should usually only
+ " be exec-interrupt, since many commands don't work properly while the
+ " target is running (so execute during startup).
+ let gdb_cmd += ['-iex', 'set mi-async on']
+ " directly communicate via mi2
+ let gdb_cmd += ['--interpreter=mi2']
+
+ " Adding arguments requested by the user
+ let gdb_cmd += gdb_args
- let s:gdbjob = jobstart(cmd, {
+ " call ch_log('executing "' . join(gdb_cmd) . '"')
+ let s:gdbjob = jobstart(gdb_cmd, {
\ 'on_exit': function('s:EndPromptDebug'),
\ 'on_stdout': function('s:GdbOutCallback'),
\ })
@@ -392,13 +409,6 @@ func s:StartDebug_prompt(dict)
return
endif
- " Interpret commands while the target is running. This should usually only
- " be exec-interrupt, since many commands don't work properly while the
- " target is running.
- call s:SendCommand('-gdb-set mi-async on')
- " Older gdb uses a different command.
- call s:SendCommand('-gdb-set target-async on')
-
let s:ptybuf = 0
if has('win32')
" MS-Windows: run in a new console window for maximum compatibility
@@ -433,8 +443,6 @@ func s:StartDebug_prompt(dict)
endif
call s:SendCommand('set print pretty on')
call s:SendCommand('set breakpoint pending on')
- " Disable pagination, it causes everything to stop at the gdb
- call s:SendCommand('set pagination off')
" Set arguments to be run
if len(proc_args)
@@ -477,7 +485,7 @@ func s:StartDebugCommon(dict)
" Run the command if the bang attribute was given and got to the debug
" window.
if get(a:dict, 'bang', 0)
- call s:SendCommand('-exec-run')
+ call s:SendResumingCommand('-exec-run')
call win_gotoid(s:ptywin)
endif
endfunc
@@ -516,6 +524,20 @@ func TermDebugSendCommand(cmd)
endif
endfunc
+" Send a command that resumes the program. If the program isn't stopped the
+" command is not sent (to avoid a repeated command to cause trouble).
+" If the command is sent then reset s:stopped.
+func s:SendResumingCommand(cmd)
+ if s:stopped
+ " reset s:stopped here, it may take a bit of time before we get a response
+ let s:stopped = 0
+ " call ch_log('assume that program is running after this command')
+ call s:SendCommand(a:cmd)
+ " else
+ " call ch_log('dropping command, program is running: ' . a:cmd)
+ endif
+endfunc
+
" Function called when entering a line in the prompt buffer.
func s:PromptCallback(text)
call s:SendCommand(a:text)
@@ -584,32 +606,23 @@ func s:GdbOutCallback(job_id, msgs, event)
endfunc
" Decode a message from gdb. quotedText starts with a ", return the text up
-" to the next ", unescaping characters.
+" to the next ", unescaping characters:
+" - remove line breaks
+" - change \\t to \t
+" - change \0xhh to \xhh
+" - change \ooo to octal
+" - change \\ to \
func s:DecodeMessage(quotedText)
if a:quotedText[0] != '"'
echoerr 'DecodeMessage(): missing quote in ' . a:quotedText
return
endif
- let result = ''
- let i = 1
- while a:quotedText[i] != '"' && i < len(a:quotedText)
- if a:quotedText[i] == '\'
- let i += 1
- if a:quotedText[i] == 'n'
- " drop \n
- let i += 1
- continue
- elseif a:quotedText[i] == 't'
- " append \t
- let i += 1
- let result .= "\t"
- continue
- endif
- endif
- let result .= a:quotedText[i]
- let i += 1
- endwhile
- return result
+ return a:quotedText
+ \->substitute('^"\|".*\|\\n', '', 'g')
+ \->substitute('\\t', "\t", 'g')
+ \->substitute('\\0x\(\x\x\)', {-> eval('"\x' .. submatch(1) .. '"')}, 'g')
+ \->substitute('\\\o\o\o', {-> eval('"' .. submatch(0) .. '"')}, 'g')
+ \->substitute('\\\\', '\', 'g')
endfunc
" Extract the "name" value from a gdb message with fullname="name".
@@ -770,8 +783,10 @@ func s:CommOutput(job_id, msgs, event)
elseif msg != ''
if msg =~ '^\(\*stopped\|\*running\|=thread-selected\)'
call s:HandleCursor(msg)
- elseif msg =~ '^\^done,bkpt=' || msg =~ '^=breakpoint-created,' || msg =~ '^=breakpoint-modified,'
- call s:HandleNewBreakpoint(msg)
+ elseif msg =~ '^\^done,bkpt=' || msg =~ '^=breakpoint-created,'
+ call s:HandleNewBreakpoint(msg, 0)
+ elseif msg =~ '^=breakpoint-modified,'
+ call s:HandleNewBreakpoint(msg, 1)
elseif msg =~ '^=breakpoint-deleted,'
call s:HandleBreakpointDelete(msg)
elseif msg =~ '^=thread-group-started'
@@ -805,11 +820,11 @@ func s:InstallCommands()
command -nargs=? Break call s:SetBreakpoint(<q-args>)
command Clear call s:ClearBreakpoint()
- command Step call s:SendCommand('-exec-step')
- command Over call s:SendCommand('-exec-next')
- command Finish call s:SendCommand('-exec-finish')
+ command Step call s:SendResumingCommand('-exec-step')
+ command Over call s:SendResumingCommand('-exec-next')
+ command Finish call s:SendResumingCommand('-exec-finish')
command -nargs=* Run call s:Run(<q-args>)
- command -nargs=* Arguments call s:SendCommand('-exec-arguments ' . <q-args>)
+ command -nargs=* Arguments call s:SendResumingCommand('-exec-arguments ' . <q-args>)
if s:way == 'prompt'
command Stop call s:PromptInterrupt()
@@ -968,9 +983,9 @@ endfunc
func s:Run(args)
if a:args != ''
- call s:SendCommand('-exec-arguments ' . a:args)
+ call s:SendResumingCommand('-exec-arguments ' . a:args)
endif
- call s:SendCommand('-exec-run')
+ call s:SendResumingCommand('-exec-run')
endfunc
func s:SendEval(expr)
@@ -1024,21 +1039,24 @@ endfunc
" clean up expression that may got in because of range
" (newlines and surrounding whitespace)
+" As it can also be specified via ex-command for assignments this function
+" may not change the "content" parts (like replacing contained spaces
func s:CleanupExpr(expr)
" replace all embedded newlines/tabs/...
- let expr = substitute( a:expr, '\s', ' ', 'g')
+ let expr = substitute(a:expr, '\_s', ' ', 'g')
if &filetype ==# 'cobol'
- " extra cleanup for COBOL: _every: expression ends with a period,
- " a semicolon nmay be used instead of a space
- " a trailing comma is ignored as it commonly separates multiple expr
- let expr = substitute(expr, '\..*', '', '')
+ " extra cleanup for COBOL:
+ " - a semicolon nmay be used instead of a space
+ " - a trailing comma or period is ignored as it commonly separates/ends
+ " multiple expr
let expr = substitute(expr, ';', ' ', 'g')
- let expr = substitute(expr, ',*$', '', '')
+ let expr = substitute(expr, '[,.]\+ *$', '', '')
endif
- " get rid of surrounding spaces
- let expr = substitute(expr, '^ *\(.*\) *', '\1', '')
+ " get rid of leading and trailing spaces
+ let expr = substitute(expr, '^ *', '', '')
+ let expr = substitute(expr, ' *$', '', '')
return expr
endfunc
@@ -1050,6 +1068,8 @@ let s:evalFromBalloonExprResult = ''
func s:HandleEvaluate(msg)
let value = substitute(a:msg, '.*value="\(.*\)"', '\1', '')
let value = substitute(value, '\\"', '"', 'g')
+ " multi-byte characters arrive in octal form
+ let value = substitute(value, '\\\o\o\o', {-> eval('"' .. submatch(0) .. '"')}, 'g')
let value = substitute(value, ' ', '\1', '')
if s:evalFromBalloonExpr
if s:evalFromBalloonExprResult == ''
@@ -1329,11 +1349,16 @@ endfunc
let s:BreakpointSigns = []
-func s:CreateBreakpoint(id, subid)
+func s:CreateBreakpoint(id, subid, enabled)
let nr = printf('%d.%d', a:id, a:subid)
if index(s:BreakpointSigns, nr) == -1
call add(s:BreakpointSigns, nr)
- exe "sign define debugBreakpoint" . nr . " text=" . substitute(nr, '\..*', '', '') . " texthl=debugBreakpoint"
+ if a:enabled == "n"
+ let hiName = "debugBreakpointDisabled"
+ else
+ let hiName = "debugBreakpoint"
+ endif
+ exe "sign define debugBreakpoint" . nr . " text=" . substitute(nr, '\..*', '', '') . " texthl=" . hiName
endif
endfunc
@@ -1343,7 +1368,7 @@ endfunction
" Handle setting a breakpoint
" Will update the sign that shows the breakpoint
-func s:HandleNewBreakpoint(msg)
+func s:HandleNewBreakpoint(msg, modifiedFlag)
if a:msg !~ 'fullname='
" a watch or a pending breakpoint does not have a file name
if a:msg =~ 'pending='
@@ -1366,7 +1391,8 @@ func s:HandleNewBreakpoint(msg)
" If "nr" is 123 it becomes "123.0" and subid is "0".
" If "nr" is 123.4 it becomes "123.4.0" and subid is "4"; "0" is discarded.
let [id, subid; _] = map(split(nr . '.0', '\.'), 'v:val + 0')
- call s:CreateBreakpoint(id, subid)
+ let enabled = substitute(msg, '.*enabled="\([yn]\)".*', '\1', '')
+ call s:CreateBreakpoint(id, subid, enabled)
if has_key(s:breakpoints, id)
let entries = s:breakpoints[id]
@@ -1393,8 +1419,18 @@ func s:HandleNewBreakpoint(msg)
if bufloaded(fname)
call s:PlaceSign(id, subid, entry)
+ let posMsg = ' at line ' . lnum . '.'
+ else
+ let posMsg = ' in ' . fname . ' at line ' . lnum . '.'
+ endif
+ if !a:modifiedFlag
+ let actionTaken = 'created'
+ elseif enabled == 'n'
+ let actionTaken = 'disabled'
+ else
+ let actionTaken = 'enabled'
endif
- echomsg 'Breakpoint ' . nr . ' created at line ' . lnum . '.'
+ echomsg 'Breakpoint ' . nr . ' ' . actionTaken . posMsg
endfor
endfunc
diff --git a/runtime/scripts.vim b/runtime/scripts.vim
index 0ff8e49088..3790b1c10f 100644
--- a/runtime/scripts.vim
+++ b/runtime/scripts.vim
@@ -198,6 +198,10 @@ if s:line1 =~# "^#!"
elseif s:name =~# 'fish\>'
set ft=fish
+ " Gforth
+ elseif s:name =~# 'gforth\>'
+ set ft=forth
+
endif
unlet s:name
diff --git a/runtime/syntax/django.vim b/runtime/syntax/django.vim
index d3ca4de0e2..76b47d2e59 100644
--- a/runtime/syntax/django.vim
+++ b/runtime/syntax/django.vim
@@ -1,7 +1,7 @@
" Vim syntax file
" Language: Django template
" Maintainer: Dave Hodder <dmh@dmh.org.uk>
-" Last Change: 2014 Jul 13
+" Last Change: 2021 Nov 29
" quit when a syntax file was already loaded
if exists("b:current_syntax")
@@ -31,6 +31,7 @@ syn keyword djangoStatement contained closecomment widthratio url with endwith
syn keyword djangoStatement contained get_current_language trans noop blocktrans
syn keyword djangoStatement contained endblocktrans get_available_languages
syn keyword djangoStatement contained get_current_language_bidi plural
+syn keyword djangoStatement contained translate blocktranslate endblocktranslate
" Django templete built-in filters
syn keyword djangoFilter contained add addslashes capfirst center cut date
diff --git a/runtime/syntax/squirrel.vim b/runtime/syntax/squirrel.vim
new file mode 100644
index 0000000000..81d59cc986
--- /dev/null
+++ b/runtime/syntax/squirrel.vim
@@ -0,0 +1,50 @@
+" Vim syntax file
+" Language: squirrel
+" Current Maintainer: Matt Dunford (zenmatic@gmail.com)
+" URL: https://github.com/zenmatic/vim-syntax-squirrel
+" Last Change: 2021 Nov 28
+
+" http://squirrel-lang.org/
+
+" quit when a syntax file was already loaded
+if exists("b:current_syntax")
+ finish
+endif
+
+" inform C syntax that the file was included from cpp.vim
+let b:filetype_in_cpp_family = 1
+
+" Read the C syntax to start with
+runtime! syntax/c.vim
+unlet b:current_syntax
+
+" squirrel extensions
+syn keyword squirrelStatement delete this in yield resume base clone
+syn keyword squirrelAccess local
+syn keyword cConstant null
+syn keyword squirrelModifier static
+syn keyword squirrelType bool instanceof typeof
+syn keyword squirrelExceptions throw try catch
+syn keyword squirrelStructure class function extends constructor
+syn keyword squirrelBoolean true false
+syn keyword squirrelRepeat foreach
+
+syn region squirrelMultiString start='@"' end='"$' end='";$'me=e-1
+
+syn match squirrelShComment "^\s*#.*$"
+
+" Default highlighting
+hi def link squirrelAccess squirrelStatement
+hi def link squirrelExceptions Exception
+hi def link squirrelStatement Statement
+hi def link squirrelModifier Type
+hi def link squirrelType Type
+hi def link squirrelStructure Structure
+hi def link squirrelBoolean Boolean
+hi def link squirrelMultiString String
+hi def link squirrelRepeat cRepeat
+hi def link squirrelShComment Comment
+
+let b:current_syntax = "squirrel"
+
+" vim: ts=8
diff --git a/runtime/syntax/vb.vim b/runtime/syntax/vb.vim
index 8ddb1efac3..607f6130ba 100644
--- a/runtime/syntax/vb.vim
+++ b/runtime/syntax/vb.vim
@@ -1,9 +1,11 @@
" Vim syntax file
-" Language: Visual Basic
-" Maintainer: Tim Chase <vb.vim@tim.thechases.com>
-" Former Maintainer: Robert M. Cortopassi <cortopar@mindspring.com>
-" (tried multiple times to contact, but email bounced)
+" Language: Visual Basic
+" Maintainer: Doug Kearns <dougkearns@gmail.com>
+" Former Maintainer: Tim Chase <vb.vim@tim.thechases.com>
+" Former Maintainer: Robert M. Cortopassi <cortopar@mindspring.com>
+" (tried multiple times to contact, but email bounced)
" Last Change:
+" 2021 Nov 26 Incorporated additions from Doug Kearns
" 2005 May 25 Synched with work by Thomas Barthel
" 2004 May 30 Added a few keywords
@@ -13,7 +15,7 @@
" quit when a syntax file was already loaded
if exists("b:current_syntax")
- finish
+ finish
endif
" VB is case insensitive
@@ -233,7 +235,7 @@ syn keyword vbKeyword Public PublicNotCreateable OnNewProcessSingleUse
syn keyword vbKeyword InSameProcessMultiUse GlobalMultiUse Resume Seek
syn keyword vbKeyword Set Static Step String Time WithEvents
-syn keyword vbTodo contained TODO
+syn keyword vbTodo contained TODO
"Datatypes
syn keyword vbTypes Boolean Byte Currency Date Decimal Double Empty
@@ -319,46 +321,54 @@ syn match vbNumber "\<\d\+\>"
syn match vbNumber "\<\d\+\.\d*\>"
"floating point number, starting with a dot
syn match vbNumber "\.\d\+\>"
-"syn match vbNumber "{[[:xdigit:]-]\+}\|&[hH][[:xdigit:]]\+&"
-"syn match vbNumber ":[[:xdigit:]]\+"
-"syn match vbNumber "[-+]\=\<\d\+\>"
-syn match vbFloat "[-+]\=\<\d\+[eE][\-+]\=\d\+"
-syn match vbFloat "[-+]\=\<\d\+\.\d*\([eE][\-+]\=\d\+\)\="
-syn match vbFloat "[-+]\=\<\.\d\+\([eE][\-+]\=\d\+\)\="
+"syn match vbNumber "{[[:xdigit:]-]\+}\|&[hH][[:xdigit:]]\+&"
+"syn match vbNumber ":[[:xdigit:]]\+"
+"syn match vbNumber "[-+]\=\<\d\+\>"
+syn match vbFloat "[-+]\=\<\d\+[eE][\-+]\=\d\+"
+syn match vbFloat "[-+]\=\<\d\+\.\d*\([eE][\-+]\=\d\+\)\="
+syn match vbFloat "[-+]\=\<\.\d\+\([eE][\-+]\=\d\+\)\="
-" String and Character contstants
+" String and Character constants
syn region vbString start=+"+ end=+"\|$+
syn region vbComment start="\(^\|\s\)REM\s" end="$" contains=vbTodo
syn region vbComment start="\(^\|\s\)\'" end="$" contains=vbTodo
-syn match vbLineNumber "^\d\+\(\s\|$\)"
-syn match vbTypeSpecifier "[a-zA-Z0-9][\$%&!#]"ms=s+1
+syn match vbLineLabel "^\h\w\+:"
+syn match vbLineNumber "^\d\+\(:\|\s\|$\)"
+syn match vbTypeSpecifier "\<\a\w*[@\$%&!#]"ms=s+1
syn match vbTypeSpecifier "#[a-zA-Z0-9]"me=e-1
+" Conditional Compilation
+syn match vbPreProc "^#const\>"
+syn region vbPreProc matchgroup=PreProc start="^#if\>" end="\<then\>" transparent contains=TOP
+syn region vbPreProc matchgroup=PreProc start="^#elseif\>" end="\<then\>" transparent contains=TOP
+syn match vbPreProc "^#else\>"
+syn match vbPreProc "^#end\s*if\>"
" Define the default highlighting.
" Only when an item doesn't have highlighting yet
-hi def link vbBoolean Boolean
-hi def link vbLineNumber Comment
-hi def link vbComment Comment
-hi def link vbConditional Conditional
-hi def link vbConst Constant
-hi def link vbDefine Constant
-hi def link vbError Error
-hi def link vbFunction Identifier
-hi def link vbIdentifier Identifier
-hi def link vbNumber Number
-hi def link vbFloat Float
-hi def link vbMethods PreProc
-hi def link vbOperator Operator
-hi def link vbRepeat Repeat
-hi def link vbString String
-hi def link vbStatement Statement
-hi def link vbKeyword Statement
-hi def link vbEvents Special
-hi def link vbTodo Todo
-hi def link vbTypes Type
-hi def link vbTypeSpecifier Type
-
+hi def link vbBoolean Boolean
+hi def link vbLineNumber Comment
+hi def link vbLineLabel Comment
+hi def link vbComment Comment
+hi def link vbConditional Conditional
+hi def link vbConst Constant
+hi def link vbDefine Constant
+hi def link vbError Error
+hi def link vbFunction Identifier
+hi def link vbIdentifier Identifier
+hi def link vbNumber Number
+hi def link vbFloat Float
+hi def link vbMethods PreProc
+hi def link vbOperator Operator
+hi def link vbRepeat Repeat
+hi def link vbString String
+hi def link vbStatement Statement
+hi def link vbKeyword Statement
+hi def link vbEvents Special
+hi def link vbTodo Todo
+hi def link vbTypes Type
+hi def link vbTypeSpecifier Type
+hi def link vbPreProc PreProc
let b:current_syntax = "vb"
diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim
index f7b5ce0f63..41993b65b0 100644
--- a/runtime/syntax/vim.vim
+++ b/runtime/syntax/vim.vim
@@ -53,7 +53,7 @@ syn case ignore
syn keyword vimGroup contained Comment Constant String Character Number Boolean Float Identifier Function Statement Conditional Repeat Label Operator Keyword Exception PreProc Include Define Macro PreCondit Type StorageClass Structure Typedef Special SpecialChar Tag Delimiter SpecialComment Debug Underlined Ignore Error Todo
" Default highlighting groups {{{2
-syn keyword vimHLGroup contained ColorColumn Cursor CursorColumn CursorIM CursorLine CursorLineNr DiffAdd DiffChange DiffDelete DiffText Directory EndOfBuffer ErrorMsg FoldColumn Folded IncSearch LineNr MatchParen Menu ModeMsg MoreMsg NonText Normal Pmenu PmenuSbar PmenuSel PmenuThumb Question QuickFixLine Scrollbar Search SignColumn SpecialKey SpellBad SpellCap SpellLocal SpellRare StatusLine StatusLineNC TabLine TabLineFill TabLineSel Title Tooltip VertSplit Visual WarningMsg WildMenu
+syn keyword vimHLGroup contained ColorColumn Cursor CursorColumn CursorIM CursorLine CursorLineFold CursorLineNr CursorLineSign DiffAdd DiffChange DiffDelete DiffText Directory EndOfBuffer ErrorMsg FoldColumn Folded IncSearch LineNr MatchParen Menu ModeMsg MoreMsg NonText Normal Pmenu PmenuSbar PmenuSel PmenuThumb Question QuickFixLine Scrollbar Search SignColumn SpecialKey SpellBad SpellCap SpellLocal SpellRare StatusLine StatusLineNC TabLine TabLineFill TabLineSel Title Tooltip VertSplit Visual WarningMsg WildMenu
syn match vimHLGroup contained "Conceal"
syn keyword vimOnlyHLGroup contained LineNrAbove LineNrBelow StatusLineTerm Terminal VisualNOS
syn keyword nvimHLGroup contained Substitute TermCursor TermCursorNC
@@ -741,10 +741,10 @@ if g:vimsyn_embed =~# 'P' && filereadable(s:pythonpath)
unlet! b:current_syntax
syn cluster vimFuncBodyList add=vimPythonRegion
exe "syn include @vimPythonScript ".s:pythonpath
- VimFoldP syn region vimPythonRegion matchgroup=vimScriptDelim start=+py\%[thon][3x]\=\s*<<\s*\z(\S*\)\ze\(\s*#.*\)\=$+ end=+^\z1\ze\(\s*".*\)\=$+ contains=@vimPythonScript
- VimFoldP syn region vimPythonRegion matchgroup=vimScriptDelim start=+py\%[thon][3x]\=\s*<<\s*$+ end=+\.$+ contains=@vimPythonScript
- VimFoldP syn region vimPythonRegion matchgroup=vimScriptDelim start=+Py\%[thon]2or3\s*<<\s*\z(\S*\)\ze\(\s*#.*\)\=$+ end=+^\z1\ze\(\s*".*\)\=$+ contains=@vimPythonScript
- VimFoldP syn region vimPythonRegion matchgroup=vimScriptDelim start=+Py\%[thon]2or3\=\s*<<\s*$+ end=+\.$+ contains=@vimPythonScript
+ VimFoldP syn region vimPythonRegion matchgroup=vimScriptDelim start=+py\%[thon][3x]\=\s*<<\s*\%(trim\s*\)\=\z(\S*\)\ze\(\s*#.*\)\=$+ end=+^\z1\ze\(\s*".*\)\=$+ contains=@vimPythonScript
+ VimFoldP syn region vimPythonRegion matchgroup=vimScriptDelim start=+py\%[thon][3x]\=\s*<<\s*\%(trim\s*\)\=$+ end=+\.$+ contains=@vimPythonScript
+ VimFoldP syn region vimPythonRegion matchgroup=vimScriptDelim start=+Py\%[thon]2or3\s*<<\s*\%(trim\s*\)\=\z(\S*\)\ze\(\s*#.*\)\=$+ end=+^\z1\ze\(\s*".*\)\=$+ contains=@vimPythonScript
+ VimFoldP syn region vimPythonRegion matchgroup=vimScriptDelim start=+Py\%[thon]2or3\=\s*<<\s*\%(trim\s*\)\=$+ end=+\.$+ contains=@vimPythonScript
syn cluster vimFuncBodyList add=vimPythonRegion
else
syn region vimEmbedError start=+py\%[thon]3\=\s*<<\s*\z(.*\)$+ end=+^\z1$+
diff --git a/runtime/tools/check_colors.vim b/runtime/tools/check_colors.vim
index 966072c706..85df882d1e 100644
--- a/runtime/tools/check_colors.vim
+++ b/runtime/tools/check_colors.vim
@@ -226,7 +226,13 @@ fu! Result(err)
endif
endfu
-call Test_check_colors()
-
-let &cpo = s:save_cpo
-unlet s:save_cpo
+try
+ call Test_check_colors()
+catch
+ echohl ErrorMsg
+ echomsg v:exception
+ echohl NONE
+finally
+ let &cpo = s:save_cpo
+ unlet s:save_cpo
+endtry