aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt4
-rwxr-xr-xci/snap/deploy.sh2
-rw-r--r--config/CMakeLists.txt2
-rw-r--r--contrib/local.mk.example2
-rw-r--r--runtime/CMakeLists.txt2
-rw-r--r--runtime/autoload/dist/ft.vim21
-rw-r--r--runtime/doc/api.txt6
-rw-r--r--runtime/doc/autocmd.txt2
-rw-r--r--runtime/doc/diagnostic.txt67
-rw-r--r--runtime/doc/eval.txt13
-rw-r--r--runtime/doc/filetype.txt12
-rw-r--r--runtime/doc/lsp.txt158
-rw-r--r--runtime/doc/lua.txt28
-rw-r--r--runtime/doc/pi_msgpack.txt2
-rw-r--r--runtime/doc/syntax.txt8
-rw-r--r--runtime/doc/treesitter.txt19
-rw-r--r--runtime/doc/vim_diff.txt2
-rw-r--r--runtime/filetype.vim23
-rw-r--r--runtime/ftplugin/jsonc.vim10
-rw-r--r--runtime/lua/vim/F.lua2
-rw-r--r--runtime/lua/vim/_meta.lua2
-rw-r--r--runtime/lua/vim/diagnostic.lua97
-rw-r--r--runtime/lua/vim/lsp.lua104
-rw-r--r--runtime/lua/vim/lsp/buf.lua17
-rw-r--r--runtime/lua/vim/lsp/diagnostic.lua25
-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.lua13
-rw-r--r--runtime/lua/vim/lsp/sync.lua5
-rw-r--r--runtime/lua/vim/lsp/util.lua258
-rw-r--r--runtime/lua/vim/shared.lua20
-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.vim175
-rw-r--r--runtime/rgb.txt753
-rw-r--r--runtime/scripts.vim4
-rw-r--r--runtime/syntax/vim.vim8
-rw-r--r--runtime/tools/check_colors.vim14
-rw-r--r--scripts/lintcommit.lua2
-rw-r--r--src/mpack/object.h2
-rw-r--r--src/nvim/api/buffer.c4
-rw-r--r--src/nvim/api/extmark.c2
-rw-r--r--src/nvim/auevents.lua2
-rw-r--r--src/nvim/change.c2
-rw-r--r--src/nvim/ex_docmd.c4
-rw-r--r--src/nvim/fileio.c8
-rw-r--r--src/nvim/lib/khash.h2
-rw-r--r--src/nvim/lua/stdlib.c6
-rw-r--r--src/nvim/lua/vim.lua13
-rw-r--r--src/nvim/ops.c56
-rw-r--r--src/nvim/sign.c2
-rw-r--r--src/nvim/syntax.c2
-rw-r--r--src/nvim/testdir/test_blockedit.vim52
-rw-r--r--src/nvim/testdir/test_filetype.vim73
-rw-r--r--src/nvim/testdir/test_put.vim13
-rw-r--r--test/functional/core/fileio_spec.lua9
-rw-r--r--test/functional/core/startup_spec.lua2
-rw-r--r--test/functional/fixtures/api_level_8.mpackbin0 -> 28544 bytes
-rw-r--r--test/functional/lua/diagnostic_spec.lua22
-rw-r--r--test/functional/lua/vim_spec.lua14
-rw-r--r--third-party/CMakeLists.txt2
64 files changed, 846 insertions, 1347 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f44937b5ae..87223b9d4e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -136,14 +136,14 @@ set_property(CACHE CMAKE_BUILD_TYPE PROPERTY
# If not in a git repo (e.g., a tarball) these tokens define the complete
# version string, else they are combined with the result of `git describe`.
set(NVIM_VERSION_MAJOR 0)
-set(NVIM_VERSION_MINOR 6)
+set(NVIM_VERSION_MINOR 7)
set(NVIM_VERSION_PATCH 0)
set(NVIM_VERSION_PRERELEASE "-dev") # for package maintainers
# API level
set(NVIM_API_LEVEL 8) # Bump this after any API change.
set(NVIM_API_LEVEL_COMPAT 0) # Adjust this after a _breaking_ API change.
-set(NVIM_API_PRERELEASE true)
+set(NVIM_API_PRERELEASE false)
set(NVIM_VERSION_BUILD_TYPE "${CMAKE_BUILD_TYPE}")
# NVIM_VERSION_CFLAGS set further below.
diff --git a/ci/snap/deploy.sh b/ci/snap/deploy.sh
index 579c48e933..8429059e22 100755
--- a/ci/snap/deploy.sh
+++ b/ci/snap/deploy.sh
@@ -24,7 +24,7 @@ snap_realease_needed() {
trigger_snapcraft_webhook() {
[[ -n "${PAYLOAD_SIG}" ]] || exit
- echo "Triggering new snap relase via webhook..."
+ echo "Triggering new snap release via webhook..."
curl -X POST \
-H "Content-Type: application/json" \
-H "X-Hub-Signature: sha1=${PAYLOAD_SIG}" \
diff --git a/config/CMakeLists.txt b/config/CMakeLists.txt
index 581f25857b..613475b00d 100644
--- a/config/CMakeLists.txt
+++ b/config/CMakeLists.txt
@@ -92,7 +92,7 @@ if (NOT "${HAVE_BE64TOH}")
# any case and ORDER_BIG_ENDIAN will not be examined.
# - CMAKE_CROSSCOMPILING *and* HAVE_BE64TOH are both false. In this case
# be64toh function which uses cycle and arithmetic operations is used which
- # will work regardless of endianess. Function is sub-optimal though.
+ # will work regardless of endianness. Function is sub-optimal though.
check_c_source_runs("
${SI}
${MS}
diff --git a/contrib/local.mk.example b/contrib/local.mk.example
index 778e848d60..20396e86ae 100644
--- a/contrib/local.mk.example
+++ b/contrib/local.mk.example
@@ -27,7 +27,7 @@
# With non-Debug builds interprocedural optimization (IPO) (which includes
# link-time optimization (LTO)) is enabled by default, which causes the link
-# step to take a significant amout of time, which is relevant when building
+# step to take a significant amount of time, which is relevant when building
# often. You can disable it explicitly:
# CMAKE_EXTRA_FLAGS += -DENABLE_LTO=OFF
diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt
index 37029874f2..f656f1cbc3 100644
--- a/runtime/CMakeLists.txt
+++ b/runtime/CMakeLists.txt
@@ -123,7 +123,7 @@ foreach(PROG ${RUNTIME_PROGRAMS})
endforeach()
globrecurse_wrapper(RUNTIME_FILES ${CMAKE_CURRENT_SOURCE_DIR}
- rgb.txt *.vim *.lua *.dict *.py *.rb *.ps *.spl *.tutor *.tutor.json)
+ *.vim *.lua *.dict *.py *.rb *.ps *.spl *.tutor *.tutor.json)
foreach(F ${RUNTIME_FILES})
get_filename_component(BASEDIR ${F} PATH)
diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim
index 7484149a26..74df871544 100644
--- a/runtime/autoload/dist/ft.vim
+++ b/runtime/autoload/dist/ft.vim
@@ -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
@@ -272,6 +289,8 @@ func dist#ft#FTm()
" excluding end(for|function|if|switch|while) common to Murphi
let octave_block_terminators = '\<end\%(_try_catch\|classdef\|enumeration\|events\|methods\|parfor\|properties\)\>'
+ let objc_preprocessor = '^\s*#\s*\%(import\|include\|define\|if\|ifn\=def\|undef\|line\|error\|pragma\)\>'
+
let n = 1
let saw_comment = 0 " Whether we've seen a multiline comment leader.
while n < 100
@@ -282,7 +301,7 @@ func dist#ft#FTm()
" anything more definitive.
let saw_comment = 1
endif
- if line =~ '^\s*\(#\s*\(include\|import\)\>\|@import\>\|//\)'
+ if line =~ '^\s*//' || line =~ '^\s*@import\>' || line =~ objc_preprocessor
setf objc
return
endif
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..5d9f9590e2 100644
--- a/runtime/doc/autocmd.txt
+++ b/runtime/doc/autocmd.txt
@@ -793,7 +793,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/diagnostic.txt b/runtime/doc/diagnostic.txt
index 1dd9c4f301..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
@@ -289,11 +289,11 @@ option in the "signs" table of |vim.diagnostic.config()| or 10 if unset).
==============================================================================
EVENTS *diagnostic-events*
- *DiagnosticsChanged*
-DiagnosticsChanged After diagnostics have changed.
+ *DiagnosticChanged*
+DiagnosticChanged After diagnostics have changed.
Example: >
- autocmd User DiagnosticsChanged lua vim.diagnostic.setqflist({open = false })
+ autocmd DiagnosticChanged * lua vim.diagnostic.setqflist({open = false })
<
==============================================================================
==============================================================================
@@ -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 02ff9fc591..4d4e011c08 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -3081,7 +3081,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
@@ -3584,7 +3584,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
@@ -3937,7 +3937,7 @@ exepath({expr}) *exepath()*
Can also be used as a |method|: >
GetCommand()->exepath()
-
+<
*exists()*
exists({expr}) The result is a Number, which is |TRUE| if {expr} is
defined, zero otherwise.
@@ -4483,7 +4483,7 @@ foldlevel({lnum}) *foldlevel()*
Can also be used as a |method|: >
GetLnum()->foldlevel()
-
+<
*foldtext()*
foldtext() Returns a String, to be displayed for a closed fold. This is
the default function used for the 'foldtext' option and should
@@ -8552,6 +8552,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.
@@ -8976,7 +8977,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.
@@ -8986,7 +8987,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 1e84402a9f..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,29 +1456,6 @@ get_effective_tabstop({bufnr}) *vim.lsp.util.get_effective_tabstop()*
See also: ~
|softtabstop|
-get_line({uri}, {row}) *vim.lsp.util.get_line()*
- Gets the zero-indexed line from the given uri.
-
- Parameters: ~
- {uri} string uri of the resource to get the line from
- {row} number zero-indexed line number
-
- Return: ~
- string the line at row in filename
-
-get_lines({uri}, {rows}) *vim.lsp.util.get_lines()*
- Gets the zero-indexed lines from the given uri.
-
- Parameters: ~
- {uri} string uri of the resource to get the lines from
- {rows} number[] zero-indexed line numbers
-
- Return: ~
- table<number string> a table mapping rows to lines
-
-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.
@@ -1619,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
- • focusable (boolean, default true): Make
+ • 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}
Return: ~
bufnr,winnr buffer and window number of the newly created
@@ -1778,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
@@ -1857,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
@@ -1916,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 5e9189158a..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.
@@ -1200,20 +1197,16 @@ inspect({object}, {options}) *vim.inspect()*
https://github.com/kikito/inspect.lua
https://github.com/mpeterv/vinspect
-make_dict_accessor({scope}, {handle}) *vim.make_dict_accessor()*
- TODO: Documentation
-
-notify({msg}, {log_level}, {_opts}) *vim.notify()*
+notify({msg}, {log_level}, {opts}) *vim.notify()*
Notification provider
Without a runtime, writes to :Messages
Parameters: ~
- {msg} Content of the notification to show to the
- user
- {log_level} Optional log level
- {opts} Dictionary with optional options (timeout,
- etc)
+ {msg} string Content of the notification to show to
+ the user
+ {log_level} number|nil enum from vim.log.levels
+ {opts} table|nil additional options (timeout, etc)
See also: ~
:help nvim_notify
@@ -1239,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
@@ -1328,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.
@@ -1369,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/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/syntax.txt b/runtime/doc/syntax.txt
index e423c59efe..72f08c37ca 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 ~
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..cc28dba1d0 100644
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -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
@@ -2055,9 +2064,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
@@ -2155,7 +2170,7 @@ 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')
" Asterisk config file
au BufNewFile,BufRead *asterisk/*.conf* call s:StarSetf('asterisk')
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/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..a3d5f64630 100644
--- a/runtime/lua/vim/_meta.lua
+++ b/runtime/lua/vim/_meta.lua
@@ -398,7 +398,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,
diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua
index 74996faf3c..5c5631af98 100644
--- a/runtime/lua/vim/diagnostic.lua
+++ b/runtime/lua/vim/diagnostic.lua
@@ -372,25 +372,35 @@ local function get_diagnostics(bufnr, opts, clamp)
local namespace = opts.namespace
local diagnostics = {}
- local buf_line_count = clamp and vim.api.nvim_buf_line_count(bufnr) or math.huge
+
+ -- Memoized results of buf_line_count per bufnr
+ local buf_line_count = setmetatable({}, {
+ __index = function(t, k)
+ t[k] = vim.api.nvim_buf_line_count(k)
+ return rawget(t, k)
+ end,
+ })
---@private
- local function add(d)
+ local function add(b, d)
if not opts.lnum or d.lnum == opts.lnum then
- if clamp and (d.lnum >= buf_line_count or d.end_lnum >= buf_line_count) then
- d = vim.deepcopy(d)
- d.lnum = math.max(math.min(d.lnum, buf_line_count - 1), 0)
- d.end_lnum = math.max(math.min(d.end_lnum, buf_line_count - 1), 0)
+ 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
+ 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)
+ end
end
table.insert(diagnostics, d)
end
end
if namespace == nil and bufnr == nil then
- for _, t in pairs(diagnostic_cache) do
+ for b, t in pairs(diagnostic_cache) do
for _, v in pairs(t) do
for _, diagnostic in pairs(v) do
- add(diagnostic)
+ add(b, diagnostic)
end
end
end
@@ -398,19 +408,19 @@ local function get_diagnostics(bufnr, opts, clamp)
bufnr = get_bufnr(bufnr)
for iter_namespace in pairs(diagnostic_cache[bufnr]) do
for _, diagnostic in pairs(diagnostic_cache[bufnr][iter_namespace]) do
- add(diagnostic)
+ add(bufnr, diagnostic)
end
end
elseif bufnr == nil then
- for _, t in pairs(diagnostic_cache) do
+ for b, t in pairs(diagnostic_cache) do
for _, diagnostic in pairs(t[namespace] or {}) do
- add(diagnostic)
+ add(b, diagnostic)
end
end
else
bufnr = get_bufnr(bufnr)
for _, diagnostic in pairs(diagnostic_cache[bufnr][namespace] or {}) do
- add(diagnostic)
+ add(bufnr, diagnostic)
end
end
@@ -431,7 +441,9 @@ local function set_list(loclist, opts)
if loclist then
bufnr = vim.api.nvim_win_get_buf(winnr)
end
- local diagnostics = get_diagnostics(bufnr, opts, true)
+ -- Don't clamp line numbers since the quickfix list can already handle line
+ -- numbers beyond the end of the buffer
+ local diagnostics = get_diagnostics(bufnr, opts, false)
local items = M.toqflist(diagnostics)
if loclist then
vim.fn.setloclist(winnr, {}, ' ', { title = title, items = items })
@@ -506,7 +518,10 @@ local function diagnostic_move_pos(opts, pos)
vim.schedule(function()
M.open_float(
vim.api.nvim_win_get_buf(win_id),
- vim.tbl_extend("keep", float_opts, {scope="cursor"})
+ vim.tbl_extend("keep", float_opts, {
+ scope = "cursor",
+ focus = false,
+ })
)
end)
end
@@ -564,26 +579,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
@@ -591,6 +587,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)
@@ -653,15 +650,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("doautocmd <nomodeline> User DiagnosticsChanged")
+ vim.api.nvim_command(
+ string.format("doautocmd <nomodeline> DiagnosticChanged %s", vim.api.nvim_buf_get_name(bufnr))
+ )
end
--- Get namespace metadata.
---
----@param ns number Diagnostic namespace
+---@param namespace number Diagnostic namespace
---@return table Namespace metadata
function M.get_namespace(namespace)
vim.validate { namespace = { namespace, 'n' } }
@@ -783,7 +782,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(
@@ -1130,7 +1131,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;
@@ -1147,7 +1148,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)
@@ -1158,7 +1169,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
@@ -1316,7 +1327,9 @@ function M.reset(namespace, bufnr)
end
end
- vim.api.nvim_command("doautocmd <nomodeline> User DiagnosticsChanged")
+ vim.api.nvim_command(
+ string.format("doautocmd <nomodeline> DiagnosticChanged %s", vim.api.nvim_buf_get_name(bufnr))
+ )
end
--- Add all diagnostics to the quickfix list.
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua
index a380164a51..61a700bd15 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' };
@@ -320,12 +314,14 @@ do
---
--- state
--- pending_change?: function that the timer starts to trigger didChange
- --- pending_changes: list of tables with the pending changesets; for incremental_sync only
+ --- pending_changes: table (uri -> list of pending changeset tables));
+ -- Only set if incremental_sync is used
--- use_incremental_sync: bool
--- buffers?: table (bufnr → lines); for incremental sync only
--- timer?: uv_timer
local state_by_client = {}
+ ---@private
function changetracking.init(client, bufnr)
local state = state_by_client[client.id]
if not state then
@@ -347,16 +343,16 @@ 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]
- if state then
- changetracking._reset_timer(state)
- if state.buffers then
- state.buffers[bufnr] = nil
- end
+ if state and state.buffers then
+ state.buffers[bufnr] = nil
end
end
+ ---@private
function changetracking.reset(client_id)
local state = state_by_client[client_id]
if state then
@@ -365,7 +361,8 @@ do
end
end
- function changetracking.prepare(bufnr, firstline, lastline, new_lastline, changedtick)
+ ---@private
+ function changetracking.prepare(bufnr, firstline, lastline, new_lastline)
local incremental_changes = function(client)
local cached_buffers = state_by_client[client.id].buffers
local curr_lines = nvim_buf_get_lines(bufnr, 0, -1, true)
@@ -392,7 +389,7 @@ do
client.notify("textDocument/didChange", {
textDocument = {
uri = uri;
- version = changedtick;
+ version = util.buf_versions[bufnr];
};
contentChanges = { changes, }
})
@@ -402,27 +399,36 @@ do
if state.use_incremental_sync then
-- This must be done immediately and cannot be delayed
-- The contents would further change and startline/endline may no longer fit
- table.insert(state.pending_changes, incremental_changes(client))
+ if not state.pending_changes[uri] then
+ state.pending_changes[uri] = {}
+ end
+ table.insert(state.pending_changes[uri], incremental_changes(client))
end
state.pending_change = function()
state.pending_change = nil
if client.is_stopped() or not vim.api.nvim_buf_is_valid(bufnr) then
return
end
- local contentChanges
if state.use_incremental_sync then
- contentChanges = state.pending_changes
+ for change_uri, content_changes in pairs(state.pending_changes) do
+ client.notify("textDocument/didChange", {
+ textDocument = {
+ uri = change_uri;
+ version = util.buf_versions[vim.uri_to_bufnr(change_uri)];
+ };
+ contentChanges = content_changes,
+ })
+ end
state.pending_changes = {}
else
- contentChanges = { full_changes(), }
+ client.notify("textDocument/didChange", {
+ textDocument = {
+ uri = uri;
+ version = util.buf_versions[bufnr];
+ };
+ contentChanges = { full_changes() },
+ })
end
- client.notify("textDocument/didChange", {
- textDocument = {
- uri = uri;
- version = changedtick;
- };
- contentChanges = contentChanges
- })
end
state.timer = vim.loop.new_timer()
-- Must use schedule_wrap because `full_changes()` calls nvim_buf_get_lines
@@ -439,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
@@ -613,7 +620,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
@@ -667,8 +674,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
@@ -790,6 +797,9 @@ function lsp.start_client(config)
env = config.cmd_env;
})
+ -- Return nil if client fails to start
+ if not rpc then return end
+
local client = {
id = client_id;
name = name;
@@ -1023,7 +1033,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
@@ -1100,7 +1110,7 @@ do
return
end
util.buf_versions[bufnr] = changedtick
- local compute_change_and_notify = changetracking.prepare(bufnr, firstline, lastline, new_lastline, changedtick)
+ local compute_change_and_notify = changetracking.prepare(bufnr, firstline, lastline, new_lastline)
for_each_buffer_client(bufnr, compute_change_and_notify)
end
end
@@ -1159,6 +1169,7 @@ function lsp.buf_attach_client(bufnr, client_id)
on_reload = function()
local params = { textDocument = { uri = uri; } }
for_each_buffer_client(bufnr, function(client, _)
+ changetracking.reset_buf(client, bufnr)
if client.resolved_capabilities.text_document_open_close then
client.notify('textDocument/didClose', params)
end
@@ -1168,10 +1179,10 @@ function lsp.buf_attach_client(bufnr, client_id)
on_detach = function()
local params = { textDocument = { uri = uri; } }
for_each_buffer_client(bufnr, function(client, _)
+ changetracking.reset_buf(client, bufnr)
if client.resolved_capabilities.text_document_open_close then
client.notify('textDocument/didClose', params)
end
- changetracking.reset_buf(client, bufnr)
end)
util.buf_versions[bufnr] = nil
all_buffer_active_clients[bufnr] = nil
@@ -1206,7 +1217,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
@@ -1215,7 +1226,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)
@@ -1285,6 +1296,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
@@ -1319,8 +1331,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
@@ -1671,7 +1683,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
@@ -1730,11 +1752,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 d3ba766d89..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
@@ -176,9 +176,10 @@ function M.formatting_sync(options, timeout_ms)
if client == nil then return end
local params = util.make_formatting_params(options)
- local result, err = client.request_sync("textDocument/formatting", params, timeout_ms, vim.api.nvim_get_current_buf())
+ local bufnr = vim.api.nvim_get_current_buf()
+ local result, err = client.request_sync("textDocument/formatting", params, timeout_ms, bufnr)
if result and result.result then
- util.apply_text_edits(result.result)
+ util.apply_text_edits(result.result, bufnr)
elseif err then
vim.notify("vim.lsp.buf.formatting_sync: " .. err, vim.log.levels.WARN)
end
@@ -202,6 +203,7 @@ end
---the remaining clients in the order as they occur in the `order` list.
function M.formatting_seq_sync(options, timeout_ms, order)
local clients = vim.tbl_values(vim.lsp.buf_get_clients());
+ local bufnr = vim.api.nvim_get_current_buf()
-- sort the clients according to `order`
for _, client_name in pairs(order or {}) do
@@ -220,7 +222,7 @@ function M.formatting_seq_sync(options, timeout_ms, order)
local params = util.make_formatting_params(options)
local result, err = client.request_sync("textDocument/formatting", params, timeout_ms, vim.api.nvim_get_current_buf())
if result and result.result then
- util.apply_text_edits(result.result)
+ util.apply_text_edits(result.result, bufnr)
elseif err then
vim.notify(string.format("vim.lsp.buf.formatting_seq_sync: (%s) %s", client.name, err), vim.log.levels.WARN)
end
@@ -261,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)
@@ -444,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 76a4dc30b7..075da41b23 100644
--- a/runtime/lua/vim/lsp/diagnostic.lua
+++ b/runtime/lua/vim/lsp/diagnostic.lua
@@ -220,12 +220,9 @@ function M.on_publish_diagnostics(_, result, ctx, config)
end
vim.diagnostic.set(namespace, bufnr, diagnostic_lsp_to_vim(diagnostics, bufnr, client_id))
-
- -- Keep old autocmd for back compat. This should eventually be removed.
- vim.api.nvim_command("doautocmd <nomodeline> User LspDiagnosticsChanged")
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
@@ -434,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
@@ -565,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 bce1e9f35d..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}.
@@ -264,8 +264,6 @@ local function start(cmd, cmd_args, dispatchers, extra_spawn_params)
if extra_spawn_params and extra_spawn_params.cwd then
assert(is_dir(extra_spawn_params.cwd), "cwd must be a directory")
- elseif not (vim.fn.executable(cmd) == 1) then
- error(string.format("The given command %q is not executable.", cmd))
end
if dispatchers then
local user_dispatchers = dispatchers
@@ -325,7 +323,14 @@ local function start(cmd, cmd_args, dispatchers, extra_spawn_params)
end
handle, pid = uv.spawn(cmd, spawn_params, onexit)
if handle == nil then
- error(string.format("start `%s` failed: %s", cmd, pid))
+ local msg = string.format("Spawning language server with cmd: `%s` failed", cmd)
+ if string.match(pid, "ENOENT") then
+ msg = msg .. ". The language server is either not installed, missing from PATH, or not executable."
+ else
+ msg = msg .. string.format(" with error message: %s", pid)
+ end
+ 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 ba5c20ef9f..fad2b962b5 100644
--- a/runtime/lua/vim/lsp/util.lua
+++ b/runtime/lua/vim/lsp/util.lua
@@ -148,6 +148,93 @@ local function sort_by_key(fn)
end
---@private
+--- Gets the zero-indexed lines from the given buffer.
+--- Works on unloaded buffers by reading the file using libuv to bypass buf reading events.
+--- Falls back to loading the buffer and nvim_buf_get_lines for buffers with non-file URI.
+---
+---@param bufnr number bufnr to get the lines from
+---@param rows number[] zero-indexed line numbers
+---@return table<number string> a table mapping rows to lines
+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
+ lines[row] = (vim.api.nvim_buf_get_lines(bufnr, row, row + 1, false) or { "" })[1]
+ end
+ return lines
+ end
+
+ local uri = vim.uri_from_bufnr(bufnr)
+
+ -- load the buffer if this is not a file uri
+ -- Custom language server protocol extensions can result in servers sending URIs with custom schemes. Plugins are able to load these via `BufReadCmd` autocmds.
+ if uri:sub(1, 4) ~= "file" then
+ vim.fn.bufload(bufnr)
+ return buf_lines()
+ end
+
+ -- use loaded buffers if available
+ if vim.fn.bufloaded(bufnr) == 1 then
+ return buf_lines()
+ end
+
+ local filename = api.nvim_buf_get_name(bufnr)
+
+ -- get the data from the file
+ local fd = uv.fs_open(filename, "r", 438)
+ if not fd then return "" end
+ local stat = uv.fs_fstat(fd)
+ local data = uv.fs_read(fd, stat.size, 0)
+ uv.fs_close(fd)
+
+ local lines = {} -- rows we need to retrieve
+ local need = 0 -- keep track of how many unique rows we need
+ for _, row in pairs(rows) do
+ if not lines[row] then
+ need = need + 1
+ end
+ lines[row] = true
+ end
+
+ local found = 0
+ local lnum = 0
+
+ for line in string.gmatch(data, "([^\n]*)\n?") do
+ if lines[lnum] == true then
+ lines[lnum] = line
+ found = found + 1
+ if found == need then break end
+ end
+ lnum = lnum + 1
+ end
+
+ -- change any lines we didn't find to the empty string
+ for i, line in pairs(lines) do
+ if line == true then
+ lines[i] = ""
+ end
+ end
+ return lines
+end
+
+
+---@private
+--- Gets the zero-indexed line from the given buffer.
+--- Works on unloaded buffers by reading the file using libuv to bypass buf reading events.
+--- Falls back to loading the buffer and nvim_buf_get_lines for buffers with non-file URI.
+---
+---@param bufnr number
+---@param row number zero-indexed line number
+---@return string the line at row in filename
+local function get_line(bufnr, row)
+ return get_lines(bufnr, { row })[row]
+end
+
+
+---@private
--- Position is a https://microsoft.github.io/language-server-protocol/specifications/specification-current/#position
--- Returns a zero-indexed column, since set_lines() does the conversion to
--- 1-indexed
@@ -158,31 +245,25 @@ local function get_line_byte_from_position(bufnr, position, offset_encoding)
-- When on the first character, we can ignore the difference between byte and
-- character
if col > 0 then
- if not api.nvim_buf_is_loaded(bufnr) then
- vim.fn.bufload(bufnr)
- end
+ local line = get_line(bufnr, position.line)
+ local ok, result
- local line = position.line
- local lines = api.nvim_buf_get_lines(bufnr, line, line + 1, false)
- if #lines > 0 then
- local ok, result
-
- if offset_encoding == "utf-16" or not offset_encoding then
- ok, result = pcall(vim.str_byteindex, lines[1], col, true)
- elseif offset_encoding == "utf-32" then
- ok, result = pcall(vim.str_byteindex, lines[1], col, false)
- end
+ if offset_encoding == "utf-16" or not offset_encoding then
+ ok, result = pcall(vim.str_byteindex, line, col, true)
+ elseif offset_encoding == "utf-32" then
+ ok, result = pcall(vim.str_byteindex, line, col, false)
+ end
- if ok then
- return result
- end
- return math.min(#lines[1], col)
+ if ok then
+ return result
end
+ return math.min(#line, col)
end
return col
end
--- Process and return progress reports from lsp server
+---@private
function M.get_progress_messages()
local new_messages = {}
@@ -246,6 +327,10 @@ end
---@param bufnr number Buffer id
---@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textEdit
function M.apply_text_edits(text_edits, bufnr)
+ validate {
+ text_edits = { text_edits, 't', false };
+ bufnr = { bufnr, 'number', false };
+ }
if not next(text_edits) then return end
if not api.nvim_buf_is_loaded(bufnr) then
vim.fn.bufload(bufnr)
@@ -474,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.
---
@@ -574,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`
@@ -586,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)
@@ -1054,7 +1139,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
@@ -1087,7 +1172,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()
@@ -1223,18 +1308,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)
@@ -1246,12 +1334,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
@@ -1314,7 +1403,7 @@ function M.open_floating_preview(contents, syntax, opts)
api.nvim_buf_set_option(floating_bufnr, 'modifiable', false)
api.nvim_buf_set_option(floating_bufnr, 'bufhidden', 'wipe')
- api.nvim_buf_set_keymap(floating_bufnr, "n", "q", "<cmd>bdelete<cr>", {silent = true, noremap = true})
+ api.nvim_buf_set_keymap(floating_bufnr, "n", "q", "<cmd>bdelete<cr>", {silent = true, noremap = true, nowait = true})
M.close_preview_autocmd(opts.close_events, floating_winnr)
-- save focus_id
@@ -1331,7 +1420,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)
@@ -1339,9 +1428,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} }
@@ -1372,88 +1461,6 @@ local position_sort = sort_by_key(function(v)
return {v.start.line, v.start.character}
end)
---- Gets the zero-indexed line from the given uri.
----@param uri string uri of the resource to get the line from
----@param row number zero-indexed line number
----@return string the line at row in filename
--- For non-file uris, we load the buffer and get the line.
--- If a loaded buffer exists, then that is used.
--- Otherwise we get the line using libuv which is a lot faster than loading the buffer.
-function M.get_line(uri, row)
- return M.get_lines(uri, { row })[row]
-end
-
---- Gets the zero-indexed lines from the given uri.
----@param uri string uri of the resource to get the lines from
----@param rows number[] zero-indexed line numbers
----@return table<number string> a table mapping rows to lines
--- For non-file uris, we load the buffer and get the lines.
--- If a loaded buffer exists, then that is used.
--- Otherwise we get the lines using libuv which is a lot faster than loading the buffer.
-function M.get_lines(uri, rows)
- rows = type(rows) == "table" and rows or { rows }
-
- local function buf_lines(bufnr)
- local lines = {}
- for _, row in pairs(rows) do
- lines[row] = (vim.api.nvim_buf_get_lines(bufnr, row, row + 1, false) or { "" })[1]
- end
- return lines
- end
-
- -- load the buffer if this is not a file uri
- -- Custom language server protocol extensions can result in servers sending URIs with custom schemes. Plugins are able to load these via `BufReadCmd` autocmds.
- if uri:sub(1, 4) ~= "file" then
- local bufnr = vim.uri_to_bufnr(uri)
- vim.fn.bufload(bufnr)
- return buf_lines(bufnr)
- end
-
- local filename = vim.uri_to_fname(uri)
-
- -- use loaded buffers if available
- if vim.fn.bufloaded(filename) == 1 then
- local bufnr = vim.fn.bufnr(filename, false)
- return buf_lines(bufnr)
- end
-
- -- get the data from the file
- local fd = uv.fs_open(filename, "r", 438)
- if not fd then return "" end
- local stat = uv.fs_fstat(fd)
- local data = uv.fs_read(fd, stat.size, 0)
- uv.fs_close(fd)
-
- local lines = {} -- rows we need to retrieve
- local need = 0 -- keep track of how many unique rows we need
- for _, row in pairs(rows) do
- if not lines[row] then
- need = need + 1
- end
- lines[row] = true
- end
-
- local found = 0
- local lnum = 0
-
- for line in string.gmatch(data, "([^\n]*)\n?") do
- if lines[lnum] == true then
- lines[lnum] = line
- found = found + 1
- if found == need then break end
- end
- lnum = lnum + 1
- end
-
- -- change any lines we didn't find to the empty string
- for i, line in pairs(lines) do
- if line == true then
- lines[i] = ""
- end
- end
- return lines
-end
-
--- Returns the items with the byte position calculated correctly and in sorted
--- order, for display in quickfix and location lists.
---
@@ -1496,7 +1503,7 @@ function M.locations_to_items(locations)
end
-- get all the lines for this uri
- local lines = M.get_lines(uri, uri_rows)
+ local lines = get_lines(vim.uri_to_bufnr(uri), uri_rows)
for _, temp in ipairs(rows) do
local pos = temp.start
@@ -1541,7 +1548,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)
@@ -1773,8 +1780,7 @@ end
---@param col 0-indexed byte offset in line
---@returns (number, number) UTF-32 and UTF-16 index of the character in line {row} column {col} in buffer {buf}
function M.character_offset(bufnr, row, col)
- local uri = vim.uri_from_bufnr(bufnr)
- local line = M.get_line(uri, row)
+ local line = get_line(bufnr, row)
-- If the col is past the EOL, use the line length.
if col > #line then
return str_utfindex(line)
diff --git a/runtime/lua/vim/shared.lua b/runtime/lua/vim/shared.lua
index 6e40b6ca52..1cf618725d 100644
--- a/runtime/lua/vim/shared.lua
+++ b/runtime/lua/vim/shared.lua
@@ -12,7 +12,7 @@ local vim = vim or {}
--- same functions as those in the input table. Userdata and threads are not
--- copied and will throw an error.
---
----@param orig Table to copy
+---@param orig table Table to copy
---@returns New table of copied keys and (nested) values.
function vim.deepcopy(orig) end -- luacheck: no unused
vim.deepcopy = (function()
@@ -21,17 +21,16 @@ vim.deepcopy = (function()
end
local deepcopy_funcs = {
- table = function(orig)
+ table = function(orig, cache)
+ if cache[orig] then return cache[orig] end
local copy = {}
- if vim._empty_dict_mt ~= nil and getmetatable(orig) == vim._empty_dict_mt then
- copy = vim.empty_dict()
- end
-
+ cache[orig] = copy
+ local mt = getmetatable(orig)
for k, v in pairs(orig) do
- copy[vim.deepcopy(k)] = vim.deepcopy(v)
+ copy[vim.deepcopy(k, cache)] = vim.deepcopy(v, cache)
end
- return copy
+ return setmetatable(copy, mt)
end,
number = _id,
string = _id,
@@ -40,10 +39,10 @@ vim.deepcopy = (function()
['function'] = _id,
}
- return function(orig)
+ return function(orig, cache)
local f = deepcopy_funcs[type(orig)]
if f then
- return f(orig)
+ return f(orig, cache or {})
else
error("Cannot deepcopy object of type "..type(orig))
end
@@ -560,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..4a58bee8ce 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 27
"
" 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)
@@ -516,6 +524,15 @@ func TermDebugSendCommand(cmd)
endif
endfunc
+" Send a command only when stopped. Used for :Next and :Step.
+func s:SendCommandIfStopped(cmd)
+ if s:stopped
+ 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 +601,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 +778,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,9 +815,9 @@ 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:SendCommandIfStopped('-exec-step')
+ command Over call s:SendCommandIfStopped('-exec-next')
+ command Finish call s:SendCommandIfStopped('-exec-finish')
command -nargs=* Run call s:Run(<q-args>)
command -nargs=* Arguments call s:SendCommand('-exec-arguments ' . <q-args>)
@@ -1024,21 +1034,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 +1063,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 +1344,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 +1363,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 +1386,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 +1414,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/rgb.txt b/runtime/rgb.txt
deleted file mode 100644
index 5bc2baa3d6..0000000000
--- a/runtime/rgb.txt
+++ /dev/null
@@ -1,753 +0,0 @@
-! $XConsortium: rgb.txt,v 10.41 94/02/20 18:39:36 rws Exp $
-255 250 250 snow
-248 248 255 ghost white
-248 248 255 GhostWhite
-245 245 245 white smoke
-245 245 245 WhiteSmoke
-220 220 220 gainsboro
-255 250 240 floral white
-255 250 240 FloralWhite
-253 245 230 old lace
-253 245 230 OldLace
-250 240 230 linen
-250 235 215 antique white
-250 235 215 AntiqueWhite
-255 239 213 papaya whip
-255 239 213 PapayaWhip
-255 235 205 blanched almond
-255 235 205 BlanchedAlmond
-255 228 196 bisque
-255 218 185 peach puff
-255 218 185 PeachPuff
-255 222 173 navajo white
-255 222 173 NavajoWhite
-255 228 181 moccasin
-255 248 220 cornsilk
-255 255 240 ivory
-255 250 205 lemon chiffon
-255 250 205 LemonChiffon
-255 245 238 seashell
-240 255 240 honeydew
-245 255 250 mint cream
-245 255 250 MintCream
-240 255 255 azure
-240 248 255 alice blue
-240 248 255 AliceBlue
-230 230 250 lavender
-255 240 245 lavender blush
-255 240 245 LavenderBlush
-255 228 225 misty rose
-255 228 225 MistyRose
-255 255 255 white
- 0 0 0 black
- 47 79 79 dark slate gray
- 47 79 79 DarkSlateGray
- 47 79 79 dark slate grey
- 47 79 79 DarkSlateGrey
-105 105 105 dim gray
-105 105 105 DimGray
-105 105 105 dim grey
-105 105 105 DimGrey
-112 128 144 slate gray
-112 128 144 SlateGray
-112 128 144 slate grey
-112 128 144 SlateGrey
-119 136 153 light slate gray
-119 136 153 LightSlateGray
-119 136 153 light slate grey
-119 136 153 LightSlateGrey
-190 190 190 gray
-190 190 190 grey
-211 211 211 light grey
-211 211 211 LightGrey
-211 211 211 light gray
-211 211 211 LightGray
- 25 25 112 midnight blue
- 25 25 112 MidnightBlue
- 0 0 128 navy
- 0 0 128 navy blue
- 0 0 128 NavyBlue
-100 149 237 cornflower blue
-100 149 237 CornflowerBlue
- 72 61 139 dark slate blue
- 72 61 139 DarkSlateBlue
-106 90 205 slate blue
-106 90 205 SlateBlue
-123 104 238 medium slate blue
-123 104 238 MediumSlateBlue
-132 112 255 light slate blue
-132 112 255 LightSlateBlue
- 0 0 205 medium blue
- 0 0 205 MediumBlue
- 65 105 225 royal blue
- 65 105 225 RoyalBlue
- 0 0 255 blue
- 30 144 255 dodger blue
- 30 144 255 DodgerBlue
- 0 191 255 deep sky blue
- 0 191 255 DeepSkyBlue
-135 206 235 sky blue
-135 206 235 SkyBlue
-135 206 250 light sky blue
-135 206 250 LightSkyBlue
- 70 130 180 steel blue
- 70 130 180 SteelBlue
-176 196 222 light steel blue
-176 196 222 LightSteelBlue
-173 216 230 light blue
-173 216 230 LightBlue
-176 224 230 powder blue
-176 224 230 PowderBlue
-175 238 238 pale turquoise
-175 238 238 PaleTurquoise
- 0 206 209 dark turquoise
- 0 206 209 DarkTurquoise
- 72 209 204 medium turquoise
- 72 209 204 MediumTurquoise
- 64 224 208 turquoise
- 0 255 255 cyan
-224 255 255 light cyan
-224 255 255 LightCyan
- 95 158 160 cadet blue
- 95 158 160 CadetBlue
-102 205 170 medium aquamarine
-102 205 170 MediumAquamarine
-127 255 212 aquamarine
- 0 100 0 dark green
- 0 100 0 DarkGreen
- 85 107 47 dark olive green
- 85 107 47 DarkOliveGreen
-143 188 143 dark sea green
-143 188 143 DarkSeaGreen
- 46 139 87 sea green
- 46 139 87 SeaGreen
- 60 179 113 medium sea green
- 60 179 113 MediumSeaGreen
- 32 178 170 light sea green
- 32 178 170 LightSeaGreen
-152 251 152 pale green
-152 251 152 PaleGreen
- 0 255 127 spring green
- 0 255 127 SpringGreen
-124 252 0 lawn green
-124 252 0 LawnGreen
- 0 255 0 green
-127 255 0 chartreuse
- 0 250 154 medium spring green
- 0 250 154 MediumSpringGreen
-173 255 47 green yellow
-173 255 47 GreenYellow
- 50 205 50 lime green
- 50 205 50 LimeGreen
-154 205 50 yellow green
-154 205 50 YellowGreen
- 34 139 34 forest green
- 34 139 34 ForestGreen
-107 142 35 olive drab
-107 142 35 OliveDrab
-189 183 107 dark khaki
-189 183 107 DarkKhaki
-240 230 140 khaki
-238 232 170 pale goldenrod
-238 232 170 PaleGoldenrod
-250 250 210 light goldenrod yellow
-250 250 210 LightGoldenrodYellow
-255 255 224 light yellow
-255 255 224 LightYellow
-255 255 0 yellow
-255 215 0 gold
-238 221 130 light goldenrod
-238 221 130 LightGoldenrod
-218 165 32 goldenrod
-184 134 11 dark goldenrod
-184 134 11 DarkGoldenrod
-188 143 143 rosy brown
-188 143 143 RosyBrown
-205 92 92 indian red
-205 92 92 IndianRed
-139 69 19 saddle brown
-139 69 19 SaddleBrown
-160 82 45 sienna
-205 133 63 peru
-222 184 135 burlywood
-245 245 220 beige
-245 222 179 wheat
-244 164 96 sandy brown
-244 164 96 SandyBrown
-210 180 140 tan
-210 105 30 chocolate
-178 34 34 firebrick
-165 42 42 brown
-233 150 122 dark salmon
-233 150 122 DarkSalmon
-250 128 114 salmon
-255 160 122 light salmon
-255 160 122 LightSalmon
-255 165 0 orange
-255 140 0 dark orange
-255 140 0 DarkOrange
-255 127 80 coral
-240 128 128 light coral
-240 128 128 LightCoral
-255 99 71 tomato
-255 69 0 orange red
-255 69 0 OrangeRed
-255 0 0 red
-255 105 180 hot pink
-255 105 180 HotPink
-255 20 147 deep pink
-255 20 147 DeepPink
-255 192 203 pink
-255 182 193 light pink
-255 182 193 LightPink
-219 112 147 pale violet red
-219 112 147 PaleVioletRed
-176 48 96 maroon
-199 21 133 medium violet red
-199 21 133 MediumVioletRed
-208 32 144 violet red
-208 32 144 VioletRed
-255 0 255 magenta
-238 130 238 violet
-221 160 221 plum
-218 112 214 orchid
-186 85 211 medium orchid
-186 85 211 MediumOrchid
-153 50 204 dark orchid
-153 50 204 DarkOrchid
-148 0 211 dark violet
-148 0 211 DarkViolet
-138 43 226 blue violet
-138 43 226 BlueViolet
-160 32 240 purple
-147 112 219 medium purple
-147 112 219 MediumPurple
-216 191 216 thistle
-255 250 250 snow1
-238 233 233 snow2
-205 201 201 snow3
-139 137 137 snow4
-255 245 238 seashell1
-238 229 222 seashell2
-205 197 191 seashell3
-139 134 130 seashell4
-255 239 219 AntiqueWhite1
-238 223 204 AntiqueWhite2
-205 192 176 AntiqueWhite3
-139 131 120 AntiqueWhite4
-255 228 196 bisque1
-238 213 183 bisque2
-205 183 158 bisque3
-139 125 107 bisque4
-255 218 185 PeachPuff1
-238 203 173 PeachPuff2
-205 175 149 PeachPuff3
-139 119 101 PeachPuff4
-255 222 173 NavajoWhite1
-238 207 161 NavajoWhite2
-205 179 139 NavajoWhite3
-139 121 94 NavajoWhite4
-255 250 205 LemonChiffon1
-238 233 191 LemonChiffon2
-205 201 165 LemonChiffon3
-139 137 112 LemonChiffon4
-255 248 220 cornsilk1
-238 232 205 cornsilk2
-205 200 177 cornsilk3
-139 136 120 cornsilk4
-255 255 240 ivory1
-238 238 224 ivory2
-205 205 193 ivory3
-139 139 131 ivory4
-240 255 240 honeydew1
-224 238 224 honeydew2
-193 205 193 honeydew3
-131 139 131 honeydew4
-255 240 245 LavenderBlush1
-238 224 229 LavenderBlush2
-205 193 197 LavenderBlush3
-139 131 134 LavenderBlush4
-255 228 225 MistyRose1
-238 213 210 MistyRose2
-205 183 181 MistyRose3
-139 125 123 MistyRose4
-240 255 255 azure1
-224 238 238 azure2
-193 205 205 azure3
-131 139 139 azure4
-131 111 255 SlateBlue1
-122 103 238 SlateBlue2
-105 89 205 SlateBlue3
- 71 60 139 SlateBlue4
- 72 118 255 RoyalBlue1
- 67 110 238 RoyalBlue2
- 58 95 205 RoyalBlue3
- 39 64 139 RoyalBlue4
- 0 0 255 blue1
- 0 0 238 blue2
- 0 0 205 blue3
- 0 0 139 blue4
- 30 144 255 DodgerBlue1
- 28 134 238 DodgerBlue2
- 24 116 205 DodgerBlue3
- 16 78 139 DodgerBlue4
- 99 184 255 SteelBlue1
- 92 172 238 SteelBlue2
- 79 148 205 SteelBlue3
- 54 100 139 SteelBlue4
- 0 191 255 DeepSkyBlue1
- 0 178 238 DeepSkyBlue2
- 0 154 205 DeepSkyBlue3
- 0 104 139 DeepSkyBlue4
-135 206 255 SkyBlue1
-126 192 238 SkyBlue2
-108 166 205 SkyBlue3
- 74 112 139 SkyBlue4
-176 226 255 LightSkyBlue1
-164 211 238 LightSkyBlue2
-141 182 205 LightSkyBlue3
- 96 123 139 LightSkyBlue4
-198 226 255 SlateGray1
-185 211 238 SlateGray2
-159 182 205 SlateGray3
-108 123 139 SlateGray4
-202 225 255 LightSteelBlue1
-188 210 238 LightSteelBlue2
-162 181 205 LightSteelBlue3
-110 123 139 LightSteelBlue4
-191 239 255 LightBlue1
-178 223 238 LightBlue2
-154 192 205 LightBlue3
-104 131 139 LightBlue4
-224 255 255 LightCyan1
-209 238 238 LightCyan2
-180 205 205 LightCyan3
-122 139 139 LightCyan4
-187 255 255 PaleTurquoise1
-174 238 238 PaleTurquoise2
-150 205 205 PaleTurquoise3
-102 139 139 PaleTurquoise4
-152 245 255 CadetBlue1
-142 229 238 CadetBlue2
-122 197 205 CadetBlue3
- 83 134 139 CadetBlue4
- 0 245 255 turquoise1
- 0 229 238 turquoise2
- 0 197 205 turquoise3
- 0 134 139 turquoise4
- 0 255 255 cyan1
- 0 238 238 cyan2
- 0 205 205 cyan3
- 0 139 139 cyan4
-151 255 255 DarkSlateGray1
-141 238 238 DarkSlateGray2
-121 205 205 DarkSlateGray3
- 82 139 139 DarkSlateGray4
-127 255 212 aquamarine1
-118 238 198 aquamarine2
-102 205 170 aquamarine3
- 69 139 116 aquamarine4
-193 255 193 DarkSeaGreen1
-180 238 180 DarkSeaGreen2
-155 205 155 DarkSeaGreen3
-105 139 105 DarkSeaGreen4
- 84 255 159 SeaGreen1
- 78 238 148 SeaGreen2
- 67 205 128 SeaGreen3
- 46 139 87 SeaGreen4
-154 255 154 PaleGreen1
-144 238 144 PaleGreen2
-124 205 124 PaleGreen3
- 84 139 84 PaleGreen4
- 0 255 127 SpringGreen1
- 0 238 118 SpringGreen2
- 0 205 102 SpringGreen3
- 0 139 69 SpringGreen4
- 0 255 0 green1
- 0 238 0 green2
- 0 205 0 green3
- 0 139 0 green4
-127 255 0 chartreuse1
-118 238 0 chartreuse2
-102 205 0 chartreuse3
- 69 139 0 chartreuse4
-192 255 62 OliveDrab1
-179 238 58 OliveDrab2
-154 205 50 OliveDrab3
-105 139 34 OliveDrab4
-202 255 112 DarkOliveGreen1
-188 238 104 DarkOliveGreen2
-162 205 90 DarkOliveGreen3
-110 139 61 DarkOliveGreen4
-255 246 143 khaki1
-238 230 133 khaki2
-205 198 115 khaki3
-139 134 78 khaki4
-255 236 139 LightGoldenrod1
-238 220 130 LightGoldenrod2
-205 190 112 LightGoldenrod3
-139 129 76 LightGoldenrod4
-255 255 224 LightYellow1
-238 238 209 LightYellow2
-205 205 180 LightYellow3
-139 139 122 LightYellow4
-255 255 0 yellow1
-238 238 0 yellow2
-205 205 0 yellow3
-139 139 0 yellow4
-255 215 0 gold1
-238 201 0 gold2
-205 173 0 gold3
-139 117 0 gold4
-255 193 37 goldenrod1
-238 180 34 goldenrod2
-205 155 29 goldenrod3
-139 105 20 goldenrod4
-255 185 15 DarkGoldenrod1
-238 173 14 DarkGoldenrod2
-205 149 12 DarkGoldenrod3
-139 101 8 DarkGoldenrod4
-255 193 193 RosyBrown1
-238 180 180 RosyBrown2
-205 155 155 RosyBrown3
-139 105 105 RosyBrown4
-255 106 106 IndianRed1
-238 99 99 IndianRed2
-205 85 85 IndianRed3
-139 58 58 IndianRed4
-255 130 71 sienna1
-238 121 66 sienna2
-205 104 57 sienna3
-139 71 38 sienna4
-255 211 155 burlywood1
-238 197 145 burlywood2
-205 170 125 burlywood3
-139 115 85 burlywood4
-255 231 186 wheat1
-238 216 174 wheat2
-205 186 150 wheat3
-139 126 102 wheat4
-255 165 79 tan1
-238 154 73 tan2
-205 133 63 tan3
-139 90 43 tan4
-255 127 36 chocolate1
-238 118 33 chocolate2
-205 102 29 chocolate3
-139 69 19 chocolate4
-255 48 48 firebrick1
-238 44 44 firebrick2
-205 38 38 firebrick3
-139 26 26 firebrick4
-255 64 64 brown1
-238 59 59 brown2
-205 51 51 brown3
-139 35 35 brown4
-255 140 105 salmon1
-238 130 98 salmon2
-205 112 84 salmon3
-139 76 57 salmon4
-255 160 122 LightSalmon1
-238 149 114 LightSalmon2
-205 129 98 LightSalmon3
-139 87 66 LightSalmon4
-255 165 0 orange1
-238 154 0 orange2
-205 133 0 orange3
-139 90 0 orange4
-255 127 0 DarkOrange1
-238 118 0 DarkOrange2
-205 102 0 DarkOrange3
-139 69 0 DarkOrange4
-255 114 86 coral1
-238 106 80 coral2
-205 91 69 coral3
-139 62 47 coral4
-255 99 71 tomato1
-238 92 66 tomato2
-205 79 57 tomato3
-139 54 38 tomato4
-255 69 0 OrangeRed1
-238 64 0 OrangeRed2
-205 55 0 OrangeRed3
-139 37 0 OrangeRed4
-255 0 0 red1
-238 0 0 red2
-205 0 0 red3
-139 0 0 red4
-255 20 147 DeepPink1
-238 18 137 DeepPink2
-205 16 118 DeepPink3
-139 10 80 DeepPink4
-255 110 180 HotPink1
-238 106 167 HotPink2
-205 96 144 HotPink3
-139 58 98 HotPink4
-255 181 197 pink1
-238 169 184 pink2
-205 145 158 pink3
-139 99 108 pink4
-255 174 185 LightPink1
-238 162 173 LightPink2
-205 140 149 LightPink3
-139 95 101 LightPink4
-255 130 171 PaleVioletRed1
-238 121 159 PaleVioletRed2
-205 104 137 PaleVioletRed3
-139 71 93 PaleVioletRed4
-255 52 179 maroon1
-238 48 167 maroon2
-205 41 144 maroon3
-139 28 98 maroon4
-255 62 150 VioletRed1
-238 58 140 VioletRed2
-205 50 120 VioletRed3
-139 34 82 VioletRed4
-255 0 255 magenta1
-238 0 238 magenta2
-205 0 205 magenta3
-139 0 139 magenta4
-255 131 250 orchid1
-238 122 233 orchid2
-205 105 201 orchid3
-139 71 137 orchid4
-255 187 255 plum1
-238 174 238 plum2
-205 150 205 plum3
-139 102 139 plum4
-224 102 255 MediumOrchid1
-209 95 238 MediumOrchid2
-180 82 205 MediumOrchid3
-122 55 139 MediumOrchid4
-191 62 255 DarkOrchid1
-178 58 238 DarkOrchid2
-154 50 205 DarkOrchid3
-104 34 139 DarkOrchid4
-155 48 255 purple1
-145 44 238 purple2
-125 38 205 purple3
- 85 26 139 purple4
-171 130 255 MediumPurple1
-159 121 238 MediumPurple2
-137 104 205 MediumPurple3
- 93 71 139 MediumPurple4
-255 225 255 thistle1
-238 210 238 thistle2
-205 181 205 thistle3
-139 123 139 thistle4
- 0 0 0 gray0
- 0 0 0 grey0
- 3 3 3 gray1
- 3 3 3 grey1
- 5 5 5 gray2
- 5 5 5 grey2
- 8 8 8 gray3
- 8 8 8 grey3
- 10 10 10 gray4
- 10 10 10 grey4
- 13 13 13 gray5
- 13 13 13 grey5
- 15 15 15 gray6
- 15 15 15 grey6
- 18 18 18 gray7
- 18 18 18 grey7
- 20 20 20 gray8
- 20 20 20 grey8
- 23 23 23 gray9
- 23 23 23 grey9
- 26 26 26 gray10
- 26 26 26 grey10
- 28 28 28 gray11
- 28 28 28 grey11
- 31 31 31 gray12
- 31 31 31 grey12
- 33 33 33 gray13
- 33 33 33 grey13
- 36 36 36 gray14
- 36 36 36 grey14
- 38 38 38 gray15
- 38 38 38 grey15
- 41 41 41 gray16
- 41 41 41 grey16
- 43 43 43 gray17
- 43 43 43 grey17
- 46 46 46 gray18
- 46 46 46 grey18
- 48 48 48 gray19
- 48 48 48 grey19
- 51 51 51 gray20
- 51 51 51 grey20
- 54 54 54 gray21
- 54 54 54 grey21
- 56 56 56 gray22
- 56 56 56 grey22
- 59 59 59 gray23
- 59 59 59 grey23
- 61 61 61 gray24
- 61 61 61 grey24
- 64 64 64 gray25
- 64 64 64 grey25
- 66 66 66 gray26
- 66 66 66 grey26
- 69 69 69 gray27
- 69 69 69 grey27
- 71 71 71 gray28
- 71 71 71 grey28
- 74 74 74 gray29
- 74 74 74 grey29
- 77 77 77 gray30
- 77 77 77 grey30
- 79 79 79 gray31
- 79 79 79 grey31
- 82 82 82 gray32
- 82 82 82 grey32
- 84 84 84 gray33
- 84 84 84 grey33
- 87 87 87 gray34
- 87 87 87 grey34
- 89 89 89 gray35
- 89 89 89 grey35
- 92 92 92 gray36
- 92 92 92 grey36
- 94 94 94 gray37
- 94 94 94 grey37
- 97 97 97 gray38
- 97 97 97 grey38
- 99 99 99 gray39
- 99 99 99 grey39
-102 102 102 gray40
-102 102 102 grey40
-105 105 105 gray41
-105 105 105 grey41
-107 107 107 gray42
-107 107 107 grey42
-110 110 110 gray43
-110 110 110 grey43
-112 112 112 gray44
-112 112 112 grey44
-115 115 115 gray45
-115 115 115 grey45
-117 117 117 gray46
-117 117 117 grey46
-120 120 120 gray47
-120 120 120 grey47
-122 122 122 gray48
-122 122 122 grey48
-125 125 125 gray49
-125 125 125 grey49
-127 127 127 gray50
-127 127 127 grey50
-130 130 130 gray51
-130 130 130 grey51
-133 133 133 gray52
-133 133 133 grey52
-135 135 135 gray53
-135 135 135 grey53
-138 138 138 gray54
-138 138 138 grey54
-140 140 140 gray55
-140 140 140 grey55
-143 143 143 gray56
-143 143 143 grey56
-145 145 145 gray57
-145 145 145 grey57
-148 148 148 gray58
-148 148 148 grey58
-150 150 150 gray59
-150 150 150 grey59
-153 153 153 gray60
-153 153 153 grey60
-156 156 156 gray61
-156 156 156 grey61
-158 158 158 gray62
-158 158 158 grey62
-161 161 161 gray63
-161 161 161 grey63
-163 163 163 gray64
-163 163 163 grey64
-166 166 166 gray65
-166 166 166 grey65
-168 168 168 gray66
-168 168 168 grey66
-171 171 171 gray67
-171 171 171 grey67
-173 173 173 gray68
-173 173 173 grey68
-176 176 176 gray69
-176 176 176 grey69
-179 179 179 gray70
-179 179 179 grey70
-181 181 181 gray71
-181 181 181 grey71
-184 184 184 gray72
-184 184 184 grey72
-186 186 186 gray73
-186 186 186 grey73
-189 189 189 gray74
-189 189 189 grey74
-191 191 191 gray75
-191 191 191 grey75
-194 194 194 gray76
-194 194 194 grey76
-196 196 196 gray77
-196 196 196 grey77
-199 199 199 gray78
-199 199 199 grey78
-201 201 201 gray79
-201 201 201 grey79
-204 204 204 gray80
-204 204 204 grey80
-207 207 207 gray81
-207 207 207 grey81
-209 209 209 gray82
-209 209 209 grey82
-212 212 212 gray83
-212 212 212 grey83
-214 214 214 gray84
-214 214 214 grey84
-217 217 217 gray85
-217 217 217 grey85
-219 219 219 gray86
-219 219 219 grey86
-222 222 222 gray87
-222 222 222 grey87
-224 224 224 gray88
-224 224 224 grey88
-227 227 227 gray89
-227 227 227 grey89
-229 229 229 gray90
-229 229 229 grey90
-232 232 232 gray91
-232 232 232 grey91
-235 235 235 gray92
-235 235 235 grey92
-237 237 237 gray93
-237 237 237 grey93
-240 240 240 gray94
-240 240 240 grey94
-242 242 242 gray95
-242 242 242 grey95
-245 245 245 gray96
-245 245 245 grey96
-247 247 247 gray97
-247 247 247 grey97
-250 250 250 gray98
-250 250 250 grey98
-252 252 252 gray99
-252 252 252 grey99
-255 255 255 gray100
-255 255 255 grey100
-169 169 169 dark grey
-169 169 169 DarkGrey
-169 169 169 dark gray
-169 169 169 DarkGray
-0 0 139 dark blue
-0 0 139 DarkBlue
-0 139 139 dark cyan
-0 139 139 DarkCyan
-139 0 139 dark magenta
-139 0 139 DarkMagenta
-139 0 0 dark red
-139 0 0 DarkRed
-144 238 144 light green
-144 238 144 LightGreen
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/vim.vim b/runtime/syntax/vim.vim
index f7b5ce0f63..d0272916b9 100644
--- a/runtime/syntax/vim.vim
+++ b/runtime/syntax/vim.vim
@@ -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
diff --git a/scripts/lintcommit.lua b/scripts/lintcommit.lua
index c30a1b10da..0a7da4d4ef 100644
--- a/scripts/lintcommit.lua
+++ b/scripts/lintcommit.lua
@@ -47,7 +47,7 @@ end
local function validate_commit(commit_message)
local commit_split = vim.split(commit_message, ":")
- -- Return true if the type is vim-patch since most of the normal rules don't
+ -- Return nil if the type is vim-patch since most of the normal rules don't
-- apply.
if commit_split[1] == "vim-patch" then
return nil
diff --git a/src/mpack/object.h b/src/mpack/object.h
index 5327e56e18..e69821f9de 100644
--- a/src/mpack/object.h
+++ b/src/mpack/object.h
@@ -22,7 +22,7 @@ enum {
};
/* Storing integer in pointers in undefined behavior according to the C
- * standard. Define a union type to accomodate arbitrary user data associated
+ * standard. Define a union type to accommodate arbitrary user data associated
* with nodes(and with requests in rpc.h). */
typedef union {
void *p;
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c
index 4076a0d220..718743ed9c 100644
--- a/src/nvim/api/buffer.c
+++ b/src/nvim/api/buffer.c
@@ -535,7 +535,7 @@ end:
/// @param channel_id
/// @param buffer Buffer handle, or 0 for current buffer
/// @param start_row First line index
-/// @param start_column Last column
+/// @param start_column First column
/// @param end_row Last line index
/// @param end_column Last column
/// @param replacement Array of lines to use as replacement
@@ -1246,7 +1246,7 @@ ArrayOf(Integer, 2) nvim_buf_get_mark(Buffer buffer, String name, Error *err)
/// If the current window already shows "buffer", the window is not 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
+/// Otherwise a temporary 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 the current
diff --git a/src/nvim/api/extmark.c b/src/nvim/api/extmark.c
index 6f1fb15dac..6e25e627b9 100644
--- a/src/nvim/api/extmark.c
+++ b/src/nvim/api/extmark.c
@@ -839,7 +839,7 @@ void nvim_buf_clear_namespace(Buffer buffer, Integer ns_id, Integer line_start,
/// - on_win: called when starting to redraw a specific window.
/// ["win", winid, bufnr, topline, botline_guess]
/// - on_line: called for each buffer line being redrawn. (The
-/// interation with fold lines is subject to change)
+/// 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/src/nvim/auevents.lua b/src/nvim/auevents.lua
index 6be51c504c..7e7114b291 100644
--- a/src/nvim/auevents.lua
+++ b/src/nvim/auevents.lua
@@ -37,6 +37,7 @@ return {
'CursorHoldI', -- idem, in Insert mode
'CursorMoved', -- cursor was moved
'CursorMovedI', -- cursor was moved in Insert mode
+ 'DiagnosticChanged', -- diagnostics in a buffer were modified
'DiffUpdated', -- diffs have been updated
'DirChanged', -- directory changed
'EncodingChanged', -- after changing the 'encoding' option
@@ -126,6 +127,7 @@ return {
-- syntax file
nvim_specific = {
BufModifiedSet=true,
+ DiagnosticChanged=true,
DirChanged=true,
Signal=true,
TabClosed=true,
diff --git a/src/nvim/change.c b/src/nvim/change.c
index c52d992fbe..ef771125f1 100644
--- a/src/nvim/change.c
+++ b/src/nvim/change.c
@@ -625,7 +625,7 @@ void ins_char_bytes(char_u *buf, size_t charlen)
}
}
- char_u *newp = xmalloc((size_t)(linelen + newlen - oldlen));
+ char_u *newp = xmalloc(linelen + newlen - oldlen);
// Copy bytes before the cursor.
if (col > 0) {
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 62919c98f7..284f8a9ab5 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -818,7 +818,7 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline, void *cookie, int flags)
// of interrupts or errors to exceptions, and ensure that no more
// commands are executed.
if (current_exception) {
- void *p = NULL;
+ char *p = NULL;
char_u *saved_sourcing_name;
int saved_sourcing_lnum;
struct msglist *messages = NULL;
@@ -835,7 +835,7 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline, void *cookie, int flags)
vim_snprintf((char *)IObuff, IOSIZE,
_("E605: Exception not caught: %s"),
current_exception->value);
- p = vim_strsave(IObuff);
+ p = (char *)vim_strsave(IObuff);
break;
case ET_ERROR:
messages = current_exception->messages;
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index 7573064fa9..c90115d796 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -100,8 +100,8 @@ struct bw_info {
char_u bw_rest[CONV_RESTLEN]; // not converted bytes
int bw_restlen; // nr of bytes in bw_rest[]
int bw_first; // first write call
- char_u *bw_conv_buf; // buffer for writing converted chars
- int bw_conv_buflen; // size of bw_conv_buf
+ char_u *bw_conv_buf; // buffer for writing converted chars
+ size_t bw_conv_buflen; // size of bw_conv_buf
int bw_conv_error; // set for conversion error
linenr_T bw_conv_error_lnum; // first line with error or zero
linenr_T bw_start_lnum; // line number at start of buffer
@@ -1360,6 +1360,10 @@ retry:
u8c += (unsigned)(*--p) << 16;
u8c += (unsigned)(*--p) << 24;
}
+ // Replace characters over INT_MAX with Unicode replacement character
+ if (u8c > INT_MAX) {
+ u8c = 0xfffd;
+ }
} else { // UTF-8
if (*--p < 0x80) {
u8c = *p;
diff --git a/src/nvim/lib/khash.h b/src/nvim/lib/khash.h
index 8cfeb03cc4..e81db43038 100644
--- a/src/nvim/lib/khash.h
+++ b/src/nvim/lib/khash.h
@@ -666,7 +666,7 @@ static kh_inline khint_t __ac_Wang_hash(khint_t key)
} \
}
-// More conenient interfaces
+// More convenient interfaces
/*! @function
@abstract Instantiate a hash set containing integer keys
diff --git a/src/nvim/lua/stdlib.c b/src/nvim/lua/stdlib.c
index db79e9e7e9..b5553060a1 100644
--- a/src/nvim/lua/stdlib.c
+++ b/src/nvim/lua/stdlib.c
@@ -175,13 +175,13 @@ int nlua_str_utfindex(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL
size_t s1_len;
const char *s1 = luaL_checklstring(lstate, 1, &s1_len);
intptr_t idx;
- if (lua_gettop(lstate) >= 2) {
+ if (lua_isnoneornil(lstate, 2)) {
+ idx = (intptr_t)s1_len;
+ } else {
idx = luaL_checkinteger(lstate, 2);
if (idx < 0 || idx > (intptr_t)s1_len) {
return luaL_error(lstate, "index out of range");
}
- } else {
- idx = (intptr_t)s1_len;
}
size_t codepoints = 0, codeunits = 0;
diff --git a/src/nvim/lua/vim.lua b/src/nvim/lua/vim.lua
index 30c7034209..c1a1e7f162 100644
--- a/src/nvim/lua/vim.lua
+++ b/src/nvim/lua/vim.lua
@@ -323,6 +323,7 @@ end
do
local validate = vim.validate
+ --@private
local function make_dict_accessor(scope, handle)
validate {
scope = {scope, 's'};
@@ -422,11 +423,10 @@ end
---
--- Without a runtime, writes to :Messages
---@see :help nvim_notify
----@param msg Content of the notification to show to the user
----@param log_level Optional log level
----@param opts Dictionary with optional options (timeout, etc)
-function vim.notify(msg, log_level, _opts)
-
+---@param msg string Content of the notification to show to the user
+---@param log_level number|nil enum from vim.log.levels
+---@param opts table|nil additional options (timeout, etc)
+function vim.notify(msg, log_level, opts) -- luacheck: no unused
if log_level == vim.log.levels.ERROR then
vim.api.nvim_err_writeln(msg)
elseif log_level == vim.log.levels.WARN then
@@ -454,7 +454,7 @@ local on_key_cbs = {}
--- On each key press, Nvim passes the key char to fn(). |i_CTRL-V|
--- If {fn} is nil, it removes the callback for the associated {ns_id}
---@param ns_id number? Namespace ID. If nil or 0, generates and returns a new
---- |nvim_create_namesapce()| id.
+--- |nvim_create_namespace()| id.
---
---@return number Namespace id associated with {fn}. Or count of all callbacks
---if on_key() is called without arguments.
@@ -580,6 +580,7 @@ function vim._expand_pat(pat, env)
end
local keys = {}
+ ---@private
local function insert_keys(obj)
for k,_ in pairs(obj) do
if type(k) == "string" and string.sub(k,1,string.len(match_part)) == match_part then
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index b4b9545daf..09979c4ef5 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -2162,7 +2162,8 @@ void op_insert(oparg_T *oap, long count1)
{
long ins_len, pre_textlen = 0;
char_u *firstline, *ins_text;
- colnr_T ind_pre = 0;
+ colnr_T ind_pre_col = 0, ind_post_col;
+ int ind_pre_vcol = 0, ind_post_vcol = 0;
struct block_def bd;
int i;
pos_T t1;
@@ -2196,7 +2197,8 @@ void op_insert(oparg_T *oap, long count1)
// Get the info about the block before entering the text
block_prep(oap, &bd, oap->start.lnum, true);
// Get indent information
- ind_pre = (colnr_T)getwhitecols_curline();
+ ind_pre_col = (colnr_T)getwhitecols_curline();
+ ind_pre_vcol = get_indent();
firstline = ml_get(oap->start.lnum) + bd.textcol;
if (oap->op_type == OP_APPEND) {
@@ -2261,10 +2263,11 @@ void op_insert(oparg_T *oap, long count1)
// if indent kicked in, the firstline might have changed
// but only do that, if the indent actually increased
- const colnr_T ind_post = (colnr_T)getwhitecols_curline();
- if (curbuf->b_op_start.col > ind_pre && ind_post > ind_pre) {
- bd.textcol += ind_post - ind_pre;
- bd.start_vcol += ind_post - ind_pre;
+ ind_post_col = (colnr_T)getwhitecols_curline();
+ if (curbuf->b_op_start.col > ind_pre_col && ind_post_col > ind_pre_col) {
+ bd.textcol += ind_post_col - ind_pre_col;
+ ind_post_vcol = get_indent();
+ bd.start_vcol += ind_post_vcol - ind_pre_vcol;
did_indent = true;
}
@@ -2297,12 +2300,26 @@ void op_insert(oparg_T *oap, long count1)
}
}
- /*
- * Spaces and tabs in the indent may have changed to other spaces and
- * tabs. Get the starting column again and correct the length.
- * Don't do this when "$" used, end-of-line will have changed.
- */
+ // Spaces and tabs in the indent may have changed to other spaces and
+ // tabs. Get the starting column again and correct the length.
+ // Don't do this when "$" used, end-of-line will have changed.
+ //
+ // if indent was added and the inserted text was after the indent,
+ // correct the selection for the new indent.
+ if (did_indent && bd.textcol - ind_post_col > 0) {
+ oap->start.col += ind_post_col - ind_pre_col;
+ oap->start_vcol += ind_post_vcol - ind_pre_vcol;
+ oap->end.col += ind_post_col - ind_pre_col;
+ oap->end_vcol += ind_post_vcol - ind_pre_vcol;
+ }
block_prep(oap, &bd2, oap->start.lnum, true);
+ if (did_indent && bd.textcol - ind_post_col > 0) {
+ // undo for where "oap" is used below
+ oap->start.col -= ind_post_col - ind_pre_col;
+ oap->start_vcol -= ind_post_vcol - ind_pre_vcol;
+ oap->end.col -= ind_post_col - ind_pre_col;
+ oap->end_vcol -= ind_post_vcol - ind_pre_vcol;
+ }
if (!bd.is_MAX || bd2.textlen < bd.textlen) {
if (oap->op_type == OP_APPEND) {
pre_textlen += bd2.textlen - bd.textlen;
@@ -3340,6 +3357,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
if (y_type == kMTCharWise && y_size == 1) {
linenr_T end_lnum = 0; // init for gcc
linenr_T start_lnum = lnum;
+ int first_byte_off = 0;
if (VIsual_active) {
end_lnum = curbuf->b_visual.vi_end.lnum;
@@ -3386,6 +3404,10 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
}
STRMOVE(ptr, oldp + col);
ml_replace(lnum, newp, false);
+
+ // compute the byte offset for the last character
+ first_byte_off = utf_head_off(newp, ptr - 1);
+
// Place cursor on last putted char.
if (lnum == curwin->w_cursor.lnum) {
// make sure curwin->w_virtcol is updated
@@ -3405,10 +3427,15 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
lnum--;
}
+ // put '] at the first byte of the last character
curbuf->b_op_end = curwin->w_cursor;
+ curbuf->b_op_end.col -= first_byte_off;
+
// For "CTRL-O p" in Insert mode, put cursor after last char
if (totlen && (restart_edit != 0 || (flags & PUT_CURSEND))) {
curwin->w_cursor.col++;
+ } else {
+ curwin->w_cursor.col -= first_byte_off;
}
} else {
// Insert at least one line. When y_type is kMTCharWise, break the first
@@ -3520,12 +3547,13 @@ error:
curbuf->b_op_start.lnum, nr_lines, true);
}
- // put '] mark at last inserted character
+ // Put the '] mark on the first byte of the last inserted character.
+ // Correct the length for change in indent.
curbuf->b_op_end.lnum = lnum;
- // correct length for change in indent
col = (colnr_T)STRLEN(y_array[y_size - 1]) - lendiff;
if (col > 1) {
- curbuf->b_op_end.col = col - 1;
+ curbuf->b_op_end.col = col - 1 - utf_head_off(y_array[y_size - 1],
+ y_array[y_size - 1] + col - 1);
} else {
curbuf->b_op_end.col = 0;
}
diff --git a/src/nvim/sign.c b/src/nvim/sign.c
index d8eea7f942..fca73dc9f2 100644
--- a/src/nvim/sign.c
+++ b/src/nvim/sign.c
@@ -80,7 +80,7 @@ static signgroup_T *sign_group_ref(const char_u *groupname)
hi = hash_lookup(&sg_table, (char *)groupname, STRLEN(groupname), hash);
if (HASHITEM_EMPTY(hi)) {
// new group
- group = xmalloc((unsigned)(sizeof(signgroup_T) + STRLEN(groupname)));
+ group = xmalloc(sizeof(signgroup_T) + STRLEN(groupname));
STRCPY(group->sg_name, groupname);
group->sg_refcount = 1;
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index dd3f1b4dc9..49f8bbab37 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -5401,7 +5401,7 @@ static int get_id_list(char_u **const arg, const int keylen, int16_t **const lis
do {
for (end = p; *end && !ascii_iswhite(*end) && *end != ','; end++) {
}
- char_u *const name = xmalloc((int)(end - p + 3)); // leave room for "^$"
+ char_u *const name = xmalloc(end - p + 3); // leave room for "^$"
STRLCPY(name + 1, p, end - p + 1);
if (STRCMP(name + 1, "ALLBUT") == 0
|| STRCMP(name + 1, "ALL") == 0
diff --git a/src/nvim/testdir/test_blockedit.vim b/src/nvim/testdir/test_blockedit.vim
index 180524cd73..38978ef689 100644
--- a/src/nvim/testdir/test_blockedit.vim
+++ b/src/nvim/testdir/test_blockedit.vim
@@ -15,6 +15,58 @@ func Test_blockinsert_indent()
bwipe!
endfunc
+func Test_blockinsert_autoindent()
+ new
+ let lines =<< trim END
+ var d = {
+ a: () => 0,
+ b: () => 0,
+ c: () => 0,
+ }
+ END
+ call setline(1, lines)
+ filetype plugin indent on
+ setlocal sw=2 et ft=vim
+ setlocal indentkeys+=:
+ exe "norm! 2Gf)\<c-v>2jA: asdf\<esc>"
+ let expected =<< trim END
+ var d = {
+ a: (): asdf => 0,
+ b: (): asdf => 0,
+ c: (): asdf => 0,
+ }
+ END
+ call assert_equal(expected, getline(1, 5))
+
+ " insert on the next column should do exactly the same
+ :%dele
+ call setline(1, lines)
+ exe "norm! 2Gf)l\<c-v>2jI: asdf\<esc>"
+ call assert_equal(expected, getline(1, 5))
+
+ :%dele
+ call setline(1, lines)
+ setlocal sw=8 noet
+ exe "norm! 2Gf)\<c-v>2jA: asdf\<esc>"
+ let expected =<< trim END
+ var d = {
+ a: (): asdf => 0,
+ b: (): asdf => 0,
+ c: (): asdf => 0,
+ }
+ END
+ call assert_equal(expected, getline(1, 5))
+
+ " insert on the next column should do exactly the same
+ :%dele
+ call setline(1, lines)
+ exe "norm! 2Gf)l\<c-v>2jI: asdf\<esc>"
+ call assert_equal(expected, getline(1, 5))
+
+ filetype off
+ bwipe!
+endfunc
+
func Test_blockinsert_delete()
new
let _bs = &bs
diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim
index 9651b8dce0..48b434b9fd 100644
--- a/src/nvim/testdir/test_filetype.vim
+++ b/src/nvim/testdir/test_filetype.vim
@@ -59,7 +59,7 @@ let s:filename_checks = {
\ 'aml': ['file.aml'],
\ 'ampl': ['file.run'],
\ 'ant': ['build.xml'],
- \ 'apache': ['.htaccess', '/etc/httpd/file.conf', '/etc/apache2/sites-2/file.com', '/etc/apache2/some.config', '/etc/apache2/conf.file/conf', '/etc/apache2/mods-some/file', '/etc/apache2/sites-some/file', '/etc/httpd/conf.d/file.config', '/etc/apache2/conf.file/file', '/etc/apache2/file.conf', '/etc/apache2/file.conf-file', '/etc/apache2/mods-file/file', '/etc/apache2/sites-file/file', '/etc/apache2/sites-file/file.com', '/etc/httpd/conf.d/file.conf', '/etc/httpd/conf.d/file.conf-file', 'access.conf', 'access.conf-file', 'any/etc/apache2/conf.file/file', 'any/etc/apache2/file.conf', 'any/etc/apache2/file.conf-file', 'any/etc/apache2/mods-file/file', 'any/etc/apache2/sites-file/file', 'any/etc/apache2/sites-file/file.com', 'any/etc/httpd/conf.d/file.conf', 'any/etc/httpd/conf.d/file.conf-file', 'any/etc/httpd/file.conf', 'apache.conf', 'apache.conf-file', 'apache2.conf', 'apache2.conf-file', 'httpd.conf', 'httpd.conf-file', 'srm.conf', 'srm.conf-file'],
+ \ 'apache': ['.htaccess', '/etc/httpd/file.conf', '/etc/apache2/sites-2/file.com', '/etc/apache2/some.config', '/etc/apache2/conf.file/conf', '/etc/apache2/mods-some/file', '/etc/apache2/sites-some/file', '/etc/httpd/conf.d/file.config', '/etc/apache2/conf.file/file', '/etc/apache2/file.conf', '/etc/apache2/file.conf-file', '/etc/apache2/mods-file/file', '/etc/apache2/sites-file/file', '/etc/apache2/sites-file/file.com', '/etc/httpd/conf.d/file.conf', '/etc/httpd/conf.d/file.conf-file', 'access.conf', 'access.conf-file', 'any/etc/apache2/conf.file/file', 'any/etc/apache2/file.conf', 'any/etc/apache2/file.conf-file', 'any/etc/apache2/mods-file/file', 'any/etc/apache2/sites-file/file', 'any/etc/apache2/sites-file/file.com', 'any/etc/httpd/conf.d/file.conf', 'any/etc/httpd/conf.d/file.conf-file', 'any/etc/httpd/file.conf', 'apache.conf', 'apache.conf-file', 'apache2.conf', 'apache2.conf-file', 'httpd.conf', 'httpd.conf-file', 'srm.conf', 'srm.conf-file', '/etc/httpd/mods-some/file', '/etc/httpd/sites-some/file', '/etc/httpd/conf.file/conf'],
\ 'apachestyle': ['/etc/proftpd/file.config,/etc/proftpd/conf.file/file', '/etc/proftpd/conf.file/file', '/etc/proftpd/file.conf', '/etc/proftpd/file.conf-file', 'any/etc/proftpd/conf.file/file', 'any/etc/proftpd/file.conf', 'any/etc/proftpd/file.conf-file', 'proftpd.conf', 'proftpd.conf-file'],
\ 'applescript': ['file.scpt'],
\ 'aptconf': ['apt.conf', '/.aptitude/config', 'any/.aptitude/config'],
@@ -142,7 +142,7 @@ let s:filename_checks = {
\ 'desc': ['file.desc'],
\ 'desktop': ['file.desktop', '.directory', 'file.directory'],
\ 'dictconf': ['dict.conf', '.dictrc'],
- \ 'dictdconf': ['dictd.conf'],
+ \ 'dictdconf': ['dictd.conf', 'dictdfile.conf', 'dictd-file.conf'],
\ 'diff': ['file.diff', 'file.rej'],
\ 'dircolors': ['.dir_colors', '.dircolors', '/etc/DIR_COLORS', 'any/etc/DIR_COLORS'],
\ 'dnsmasq': ['/etc/dnsmasq.conf', '/etc/dnsmasq.d/file', 'any/etc/dnsmasq.conf', 'any/etc/dnsmasq.d/file'],
@@ -182,11 +182,12 @@ let s:filename_checks = {
\ 'fgl': ['file.4gl', 'file.4gh', 'file.m4gl'],
\ 'fish': ['file.fish'],
\ 'focexec': ['file.fex', 'file.focexec'],
- \ 'forth': ['file.fs', 'file.ft', 'file.fth'],
+ \ 'forth': ['file.ft', 'file.fth'],
\ 'fortran': ['file.f', 'file.for', 'file.fortran', 'file.fpp', 'file.ftn', 'file.f77', 'file.f90', 'file.f95', 'file.f03', 'file.f08'],
\ 'fpcmake': ['file.fpc'],
\ 'framescript': ['file.fsl'],
\ 'freebasic': ['file.fb', 'file.bi'],
+ \ 'fsharp': ['file.fs', 'file.fsi', 'file.fsx'],
\ 'fstab': ['fstab', 'mtab'],
\ 'fvwm': ['/.fvwm/file', 'any/.fvwm/file'],
\ 'gdb': ['.gdbinit', 'gdbinit'],
@@ -553,7 +554,7 @@ let s:filename_checks = {
\ 'xhtml': ['file.xhtml', 'file.xht'],
\ 'xinetd': ['/etc/xinetd.conf', '/etc/xinetd.d/file', 'any/etc/xinetd.conf', 'any/etc/xinetd.d/file'],
\ 'xmath': ['file.msc', 'file.msf'],
- \ 'xml': ['/etc/blkid.tab', '/etc/blkid.tab.old', 'file.xmi', 'file.csproj', 'file.csproj.user', 'file.ui', 'file.tpm', '/etc/xdg/menus/file.menu', 'fglrxrc', 'file.xlf', 'file.xliff', 'file.xul', 'file.wsdl', 'file.wpl', 'any/etc/blkid.tab', 'any/etc/blkid.tab.old', 'any/etc/xdg/menus/file.menu'],
+ \ 'xml': ['/etc/blkid.tab', '/etc/blkid.tab.old', 'file.xmi', 'file.csproj', 'file.csproj.user', 'file.fsproj', 'file.fsproj.user', 'file.vbproj', 'file.vbproj.user', 'file.ui', 'file.tpm', '/etc/xdg/menus/file.menu', 'fglrxrc', 'file.xlf', 'file.xliff', 'file.xul', 'file.wsdl', 'file.wpl', 'any/etc/blkid.tab', 'any/etc/blkid.tab.old', 'any/etc/xdg/menus/file.menu', 'file.atom', 'file.rss', 'file.cdxml', 'file.psc1', 'file.mpd'],
\ 'xmodmap': ['anyXmodmap', 'Xmodmap', 'some-Xmodmap', 'some-xmodmap', 'some-xmodmap-file', 'xmodmap', 'xmodmap-file'],
\ 'xf86conf': ['xorg.conf', 'xorg.conf-4'],
\ 'xpm': ['file.xpm'],
@@ -663,6 +664,7 @@ let s:script_checks = {
\ 'fennel': [['#!/path/fennel']],
\ 'routeros': [['#!/path/rsc']],
\ 'fish': [['#!/path/fish']],
+ \ 'forth': [['#!/path/gforth']],
\ }
" Various forms of "env" optional arguments.
@@ -866,6 +868,16 @@ func Test_m_file()
call assert_equal('objc', &filetype)
bwipe!
+ call writefile(['#include <header.h>'], 'Xfile.m')
+ split Xfile.m
+ call assert_equal('objc', &filetype)
+ bwipe!
+
+ call writefile(['#define FORTY_TWO'], 'Xfile.m')
+ split Xfile.m
+ call assert_equal('objc', &filetype)
+ bwipe!
+
" Octave
call writefile(['# Octave line comment'], 'Xfile.m')
@@ -935,4 +947,57 @@ func Test_xpm_file()
filetype off
endfunc
+func Test_fs_file()
+ filetype on
+
+ call writefile(['looks like F#'], 'Xfile.fs')
+ split Xfile.fs
+ call assert_equal('fsharp', &filetype)
+ bwipe!
+
+ let g:filetype_fs = 'forth'
+ split Xfile.fs
+ call assert_equal('forth', &filetype)
+ bwipe!
+ unlet g:filetype_fs
+
+ " Test dist#ft#FTfs()
+
+ " Forth (Gforth)
+
+ call writefile(['( Forth inline comment )'], 'Xfile.fs')
+ split Xfile.fs
+ call assert_equal('forth', &filetype)
+ bwipe!
+
+ call writefile(['.( Forth displayed inline comment )'], 'Xfile.fs')
+ split Xfile.fs
+ call assert_equal('forth', &filetype)
+ bwipe!
+
+ call writefile(['\ Forth line comment'], 'Xfile.fs')
+ split Xfile.fs
+ call assert_equal('forth', &filetype)
+ bwipe!
+
+ " empty line comment - no space required
+ call writefile(['\'], 'Xfile.fs')
+ split Xfile.fs
+ call assert_equal('forth', &filetype)
+ bwipe!
+
+ call writefile(['\G Forth documentation comment '], 'Xfile.fs')
+ split Xfile.fs
+ call assert_equal('forth', &filetype)
+ bwipe!
+
+ call writefile([': squared ( n -- n^2 )', 'dup * ;'], 'Xfile.fs')
+ split Xfile.fs
+ call assert_equal('forth', &filetype)
+ bwipe!
+
+ call delete('Xfile.fs')
+ filetype off
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_put.vim b/src/nvim/testdir/test_put.vim
index 15745d5619..8d8cc77025 100644
--- a/src/nvim/testdir/test_put.vim
+++ b/src/nvim/testdir/test_put.vim
@@ -111,3 +111,16 @@ func Test_put_p_indent_visual()
call assert_equal('select that text', getline(2))
bwipe!
endfunc
+
+func Test_multibyte_op_end_mark()
+ new
+ call setline(1, 'тест')
+ normal viwdp
+ call assert_equal([0, 1, 7, 0], getpos("'>"))
+ call assert_equal([0, 1, 7, 0], getpos("']"))
+
+ normal Vyp
+ call assert_equal([0, 1, 2147483647, 0], getpos("'>"))
+ call assert_equal([0, 2, 7, 0], getpos("']"))
+ bwipe!
+ endfunc
diff --git a/test/functional/core/fileio_spec.lua b/test/functional/core/fileio_spec.lua
index f4c476560d..c68bc18eed 100644
--- a/test/functional/core/fileio_spec.lua
+++ b/test/functional/core/fileio_spec.lua
@@ -15,6 +15,7 @@ local read_file = helpers.read_file
local trim = helpers.trim
local currentdir = helpers.funcs.getcwd
local iswin = helpers.iswin
+local assert_alive = helpers.assert_alive
describe('fileio', function()
before_each(function()
@@ -26,6 +27,7 @@ describe('fileio', function()
os.remove('Xtest_startup_file1~')
os.remove('Xtest_startup_file2')
os.remove('Xtest_тест.md')
+ os.remove('Xtest-u8-int-max')
rmdir('Xtest_startup_swapdir')
rmdir('Xtest_backupdir')
end)
@@ -128,5 +130,12 @@ describe('fileio', function()
table.insert(text, '')
eq(text, funcs.readfile(fname, 'b'))
end)
+ it('read invalid u8 over INT_MAX doesn\'t segfault', function()
+ clear()
+ command('call writefile(0zFFFFFFFF, "Xtest-u8-int-max")')
+ -- This should not segfault
+ command('edit ++enc=utf32 Xtest-u8-int-max')
+ assert_alive()
+ end)
end)
diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua
index d1dce0f8da..4220d68ee1 100644
--- a/test/functional/core/startup_spec.lua
+++ b/test/functional/core/startup_spec.lua
@@ -560,7 +560,7 @@ describe('user config init', function()
it('loads default lua config, but shows an error', function()
clear{ args_rm={'-u'}, env=xenv }
- feed('<cr>') -- TODO check this, test execution is blocked without it
+ feed('<cr>') -- confirm "Conflicting config ..." message
eq(1, eval('g:lua_rc'))
matches('^E5422: Conflicting configs', meths.exec('messages', true))
end)
diff --git a/test/functional/fixtures/api_level_8.mpack b/test/functional/fixtures/api_level_8.mpack
new file mode 100644
index 0000000000..0447fce3ed
--- /dev/null
+++ b/test/functional/fixtures/api_level_8.mpack
Binary files differ
diff --git a/test/functional/lua/diagnostic_spec.lua b/test/functional/lua/diagnostic_spec.lua
index aacb8cf3ae..927ee8060d 100644
--- a/test/functional/lua/diagnostic_spec.lua
+++ b/test/functional/lua/diagnostic_spec.lua
@@ -357,7 +357,7 @@ describe('vim.diagnostic', function()
it("doesn't error after bwipeout on buffer", function()
exec_lua [[
- vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, { lnum = 0, end_lnum = 0, col = 0, end_col = 0 })
+ vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, {{ lnum = 0, end_lnum = 0, col = 0, end_col = 0 }})
vim.cmd("bwipeout! " .. diagnostic_bufnr)
vim.diagnostic.show(diagnostic_ns)
@@ -653,7 +653,7 @@ describe('vim.diagnostic', function()
it("doesn't error after bwipeout called on buffer", function()
exec_lua [[
- vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, { lnum = 0, end_lnum = 0, col = 0, end_col = 0 })
+ vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, {{ lnum = 0, end_lnum = 0, col = 0, end_col = 0 }})
vim.cmd("bwipeout! " .. diagnostic_bufnr)
vim.diagnostic.reset(diagnostic_ns)
@@ -925,7 +925,7 @@ describe('vim.diagnostic', function()
]]
eq(1, exec_lua [[return count_diagnostics(diagnostic_bufnr, vim.diagnostic.severity.ERROR, diagnostic_ns)]])
- -- eq(1, exec_lua [[return count_extmarks(diagnostic_bufnr, diagnostic_ns)]])
+ eq(1, exec_lua [[return count_extmarks(diagnostic_bufnr, diagnostic_ns)]])
end)
it('allows filtering by severity', function()
@@ -1370,7 +1370,7 @@ describe('vim.diagnostic', function()
}
vim.api.nvim_win_set_buf(0, diagnostic_bufnr)
vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, diagnostics)
- local float_bufnr, winnr = vim.diagnostic.open_float(0, {header = false})
+ local float_bufnr, winnr = vim.diagnostic.open_float(0, {header = false, scope="buffer"})
local lines = vim.api.nvim_buf_get_lines(float_bufnr, 0, -1, false)
vim.api.nvim_win_close(winnr, true)
return lines
@@ -1387,7 +1387,7 @@ describe('vim.diagnostic', function()
vim.api.nvim_win_set_buf(0, diagnostic_bufnr)
vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, diagnostics)
vim.api.nvim_win_set_cursor(0, {2, 1})
- local float_bufnr, winnr = vim.diagnostic.open_float(0, {header=false, scope="line"})
+ local float_bufnr, winnr = vim.diagnostic.open_float(0, {header=false})
local lines = vim.api.nvim_buf_get_lines(float_bufnr, 0, -1, false)
vim.api.nvim_win_close(winnr, true)
return lines
@@ -1402,7 +1402,7 @@ describe('vim.diagnostic', function()
vim.api.nvim_win_set_buf(0, diagnostic_bufnr)
vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, diagnostics)
vim.api.nvim_win_set_cursor(0, {1, 1})
- local float_bufnr, winnr = vim.diagnostic.open_float(0, {header=false, scope="line", pos=1})
+ local float_bufnr, winnr = vim.diagnostic.open_float(0, {header=false, pos=1})
local lines = vim.api.nvim_buf_get_lines(float_bufnr, 0, -1, false)
vim.api.nvim_win_close(winnr, true)
return lines
@@ -1466,7 +1466,7 @@ describe('vim.diagnostic', function()
}
vim.api.nvim_win_set_buf(0, diagnostic_bufnr)
vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, diagnostics)
- local float_bufnr, winnr = vim.diagnostic.open_float(diagnostic_bufnr, {scope="line"})
+ local float_bufnr, winnr = vim.diagnostic.open_float(diagnostic_bufnr)
local lines = vim.api.nvim_buf_get_lines(float_bufnr, 0, -1, false)
vim.api.nvim_win_close(winnr, true)
return #lines
@@ -1533,7 +1533,7 @@ describe('vim.diagnostic', function()
}
vim.api.nvim_win_set_buf(0, diagnostic_bufnr)
vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, diagnostics)
- local float_bufnr, winnr = vim.diagnostic.open_float(diagnostic_bufnr, {header = false, scope = "line", pos = 5})
+ local float_bufnr, winnr = vim.diagnostic.open_float(diagnostic_bufnr, {header = false, pos = 5})
local lines = vim.api.nvim_buf_get_lines(float_bufnr, 0, -1, false)
vim.api.nvim_win_close(winnr, true)
return #lines
@@ -1665,7 +1665,7 @@ describe('vim.diagnostic', function()
}
vim.api.nvim_win_set_buf(0, diagnostic_bufnr)
vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, diagnostics)
- local float_bufnr, winnr = vim.diagnostic.open_float(0, {header = false})
+ local float_bufnr, winnr = vim.diagnostic.open_float(0, {header = false, scope = "buffer"})
local lines = vim.api.nvim_buf_get_lines(float_bufnr, 0, -1, false)
vim.api.nvim_win_close(winnr, true)
return lines
@@ -1678,7 +1678,7 @@ describe('vim.diagnostic', function()
}
vim.api.nvim_win_set_buf(0, diagnostic_bufnr)
vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, diagnostics)
- local float_bufnr, winnr = vim.diagnostic.open_float(0, {header = false, prefix = ""})
+ local float_bufnr, winnr = vim.diagnostic.open_float(0, {header = false, scope = "buffer", prefix = ""})
local lines = vim.api.nvim_buf_get_lines(float_bufnr, 0, -1, false)
vim.api.nvim_win_close(winnr, true)
return lines
@@ -1687,7 +1687,7 @@ describe('vim.diagnostic', function()
eq({'1. Syntax error', '2. Some warning'}, exec_lua [[
local diagnostics = {
make_error("Syntax error", 0, 1, 0, 3),
- make_warning("Some warning", 1, 1, 1, 3),
+ make_warning("Some warning", 0, 1, 0, 3),
}
vim.api.nvim_win_set_buf(0, diagnostic_bufnr)
vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, diagnostics)
diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua
index 3832d27a22..28471bdd46 100644
--- a/test/functional/lua/vim_spec.lua
+++ b/test/functional/lua/vim_spec.lua
@@ -396,6 +396,20 @@ describe('lua stdlib', function()
return t1.f() ~= t2.f()
]]))
+ ok(exec_lua([[
+ local t1 = {a = 5}
+ t1.self = t1
+ local t2 = vim.deepcopy(t1)
+ return t2.self == t2 and t2.self ~= t1
+ ]]))
+
+ ok(exec_lua([[
+ local mt = {mt=true}
+ local t1 = setmetatable({a = 5}, mt)
+ local t2 = vim.deepcopy(t1)
+ return getmetatable(t2) == mt
+ ]]))
+
eq('Error executing lua: vim/shared.lua:0: Cannot deepcopy object of type thread',
pcall_err(exec_lua, [[
local thread = coroutine.create(function () return 0 end)
diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt
index cfbcbdd0f2..52839d8efa 100644
--- a/third-party/CMakeLists.txt
+++ b/third-party/CMakeLists.txt
@@ -97,7 +97,7 @@ endif()
if(MINGW AND CMAKE_GENERATOR MATCHES "Ninja")
find_program(MAKE_PRG NAMES mingw32-make)
if(NOT MAKE_PRG)
- message(FATAL_ERROR "GNU Make for mingw32 is required to build the dependecies.")
+ message(FATAL_ERROR "GNU Make for mingw32 is required to build the dependencies.")
else()
message(STATUS "Found GNU Make for mingw32: ${MAKE_PRG}")
endif()