From 0d32e5ba3087d7fca48b9d01e533010588625558 Mon Sep 17 00:00:00 2001 From: Diomendius <42310725+Diomendius@users.noreply.github.com> Date: Thu, 26 Aug 2021 21:39:29 +1200 Subject: docs(lua): fix, clarify Lua require() docs Corrects lua.txt help file to say that require() searches runtimepath and loads the first module found, not the last. Also adds additional clarification on require() and module search order. Closes #15480 --- runtime/doc/lua.txt | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index cc70c7b2fd..5b054b8261 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -21,19 +21,35 @@ Nvim includes a "standard library" |lua-stdlib| for Lua. It complements the be used from Lua code. A good overview of using Lua in neovim is given by https://github.com/nanotee/nvim-lua-guide. -Module conflicts are resolved by "last wins". For example if both of these -are on 'runtimepath': - runtime/lua/foo.lua - ~/.config/nvim/lua/foo.lua -then `require('foo')` loads "~/.config/nvim/lua/foo.lua", and -"runtime/lua/foo.lua" is not used. See |lua-require| to understand how Nvim -finds and loads Lua modules. The conventions are similar to those of -Vimscript |plugin|s, with some extra features. See |lua-require-example| for -a walkthrough. +The |:source| and |:runtime| commands can run Lua scripts as well as Vim +scripts. Lua modules can be loaded with `require('name')`, which +conventionally returns a table but can return any value. + +See |lua-require| for details on how Nvim finds and loads Lua modules. +See |lua-require-example| for an example of how to write and use a module. ============================================================================== IMPORTING LUA MODULES *lua-require* +Modules are searched for under the directories specified in 'runtimepath', in +the order they appear. For a module `foo`, each directory is searched for +`lua/foo.lua`, then the entire list is searched again for `lua/foo/init.lua`, +then paths specified by `package.path` and `package.cpath`. The first script +found is run and `require()` returns the value returned by the script if any, +else `true`. + +The return value is cached after the first call to `require()` for each +module, with subsequent calls returning the cached value without searching for +or executing any script. For further details on `require()`, see the Lua +documentation at https://www.lua.org/manual/5.1/manual.html#pdf-require. + +For example, if 'runtimepath' is "foo,bar", `require('mod')` searches these +paths in order and the first script found is used: + foo/lua/mod.lua + bar/lua/mod.lua + foo/lua/mod/init.lua + bar/lua/mod/init.lua + *lua-package-path* Nvim automatically adjusts `package.path` and `package.cpath` according to effective 'runtimepath' value. Adjustment happens whenever 'runtimepath' is -- cgit From 89270346f986a47ee73a8edae51e3269de608668 Mon Sep 17 00:00:00 2001 From: Diomendius <42310725+Diomendius@users.noreply.github.com> Date: Mon, 22 Nov 2021 00:11:32 +1300 Subject: docs(lua): further improve Lua require() docs Change docs to reflect recent changes to require() search order and add info on `.` in module names and search order for shared library modules. --- runtime/doc/lua.txt | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index 5b054b8261..d9a820913d 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -32,9 +32,13 @@ See |lua-require-example| for an example of how to write and use a module. IMPORTING LUA MODULES *lua-require* Modules are searched for under the directories specified in 'runtimepath', in -the order they appear. For a module `foo`, each directory is searched for -`lua/foo.lua`, then the entire list is searched again for `lua/foo/init.lua`, -then paths specified by `package.path` and `package.cpath`. The first script +the order they appear. Any `.` in the module name is treated as a directory +separator when searching. For a module `foo.bar`, each directory is searched +for `lua/foo/bar.lua`, then `lua/foo/bar/init.lua`. If no files are found, +the directories are searched again for a shared library with a name matching +`lua/foo/bar.?`, where `?` is a list of suffixes (such as `so` or `dll`) +derived from the initial value of `package.cpath`. If still no files are +found, Nvim falls back to Lua's default search mechanism. The first script found is run and `require()` returns the value returned by the script if any, else `true`. @@ -43,12 +47,17 @@ module, with subsequent calls returning the cached value without searching for or executing any script. For further details on `require()`, see the Lua documentation at https://www.lua.org/manual/5.1/manual.html#pdf-require. -For example, if 'runtimepath' is "foo,bar", `require('mod')` searches these -paths in order and the first script found is used: +For example, if 'runtimepath' is `foo,bar` and `package.cpath` was +`./?.so;./?.dll` at startup, `require('mod')` searches these paths in order +and loads the first module found: foo/lua/mod.lua - bar/lua/mod.lua foo/lua/mod/init.lua + bar/lua/mod.lua bar/lua/mod/init.lua + foo/lua/mod.so + foo/lua/mod.dll + bar/lua/mod.so + bar/lua/mod.dll *lua-package-path* Nvim automatically adjusts `package.path` and `package.cpath` according to -- cgit From f6df44232c6780eb780143ef05e8f8e6951a17cb Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 27 Dec 2021 17:31:32 +0800 Subject: docs: clarify UIEnter and UILeave docs --- runtime/doc/autocmd.txt | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt index 3df8d5ced4..0cd0d1ce0e 100644 --- a/runtime/doc/autocmd.txt +++ b/runtime/doc/autocmd.txt @@ -663,15 +663,19 @@ FuncUndefined When a user function is used but it isn't alternative is to use an autoloaded function. See |autoload-functions|. *UIEnter* -UIEnter After a UI connects via |nvim_ui_attach()|, - after VimEnter. Can be used for GUI-specific - configuration. +UIEnter After a UI connects via |nvim_ui_attach()|, or + after builtin TUI is started, after |VimEnter|. Sets these |v:event| keys: - chan + chan: 0 for builtin TUI + 1 for |--embed| + |channel-id| of the UI otherwise *UILeave* -UILeave After a UI disconnects from Nvim. +UILeave After a UI disconnects from Nvim, or after + builtin TUI is stopped, after |VimLeave|. Sets these |v:event| keys: - chan + chan: 0 for builtin TUI + 1 for |--embed| + |channel-id| of the UI otherwise *InsertChange* InsertChange When typing while in Insert or Replace mode. The |v:insertmode| variable -- cgit From 9c26939f75be8057d8880689292a729e8d8c9306 Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Wed, 5 Jan 2022 19:23:00 +0100 Subject: perf(treesitter): cache query parsing --- runtime/lua/vim/treesitter/query.lua | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'runtime') diff --git a/runtime/lua/vim/treesitter/query.lua b/runtime/lua/vim/treesitter/query.lua index ebed502c92..b3036ea679 100644 --- a/runtime/lua/vim/treesitter/query.lua +++ b/runtime/lua/vim/treesitter/query.lua @@ -138,6 +138,13 @@ function M.get_query(lang, query_name) end end +local query_cache = setmetatable({}, { + __index = function(tbl, key) + rawset(tbl, key, {}) + return rawget(tbl, key) + end +}) + --- Parse {query} as a string. (If the query is in a file, the caller --- should read the contents into a string before calling). --- @@ -151,17 +158,23 @@ end --- -` info.captures` also points to `captures`. --- - `info.patterns` contains information about predicates. --- ----@param lang The language ----@param query A string containing the query (s-expr syntax) +---@param lang string The language +---@param query string A string containing the query (s-expr syntax) --- ---@returns The query function M.parse_query(lang, query) language.require_language(lang) - local self = setmetatable({}, Query) - self.query = vim._ts_parse_query(lang, query) - self.info = self.query:inspect() - self.captures = self.info.captures - return self + local cached = query_cache[lang][query] + if cached then + return cached + else + local self = setmetatable({}, Query) + self.query = vim._ts_parse_query(lang, query) + self.info = self.query:inspect() + self.captures = self.info.captures + query_cache[lang][query] = self + return self + end end --- Gets the text corresponding to a given node -- cgit From fc8af96888f746aeae84660502d2f529a5c2cfc1 Mon Sep 17 00:00:00 2001 From: Gregory Anders Date: Tue, 11 Jan 2022 16:39:15 -0700 Subject: fix(diagnostic): resolve nil opts tables In functions which allow opts to be optional, ensure that the value actually resolves to a non-nil value. --- runtime/lua/vim/diagnostic.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'runtime') diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua index 417b661155..76e19b2de2 100644 --- a/runtime/lua/vim/diagnostic.lua +++ b/runtime/lua/vim/diagnostic.lua @@ -823,6 +823,7 @@ M.handlers.signs = { } bufnr = get_bufnr(bufnr) + opts = opts or {} if opts.signs and opts.signs.severity then diagnostics = filter_by_severity(opts.signs.severity, diagnostics) @@ -890,6 +891,7 @@ M.handlers.underline = { } bufnr = get_bufnr(bufnr) + opts = opts or {} if opts.underline and opts.underline.severity then diagnostics = filter_by_severity(opts.underline.severity, diagnostics) @@ -942,6 +944,7 @@ M.handlers.virtual_text = { } bufnr = get_bufnr(bufnr) + opts = opts or {} local severity if opts.virtual_text then -- cgit From 984270c09f628415f99e576c64e93041731a8ba6 Mon Sep 17 00:00:00 2001 From: Gregory Anders Date: Tue, 11 Jan 2022 16:43:47 -0700 Subject: fix(diagnostic): allow setting arbitrary config values --- runtime/lua/vim/diagnostic.lua | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'runtime') diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua index 76e19b2de2..1425de854a 100644 --- a/runtime/lua/vim/diagnostic.lua +++ b/runtime/lua/vim/diagnostic.lua @@ -611,10 +611,8 @@ function M.config(opts, namespace) t = global_diagnostic_options end - for opt in pairs(global_diagnostic_options) do - if opts[opt] ~= nil then - t[opt] = opts[opt] - end + for k, v in pairs(opts) do + t[k] = v end if namespace then -- cgit From 8a27205d09405b9b040f0122e2adbd22fc29d498 Mon Sep 17 00:00:00 2001 From: Gregory Anders Date: Tue, 11 Jan 2022 16:44:07 -0700 Subject: fix(diagnostic): only set default handler config if unset --- runtime/lua/vim/diagnostic.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua index 1425de854a..4bf69a2d39 100644 --- a/runtime/lua/vim/diagnostic.lua +++ b/runtime/lua/vim/diagnostic.lua @@ -30,7 +30,7 @@ M.handlers = setmetatable({}, { __newindex = function(t, name, handler) vim.validate { handler = {handler, "t" } } rawset(t, name, handler) - if not global_diagnostic_options[name] then + if global_diagnostic_options[name] == nil then global_diagnostic_options[name] = true end end, -- cgit From c915571b99d7e1ea99e29b103ca2ad37b5974027 Mon Sep 17 00:00:00 2001 From: Gregory Anders Date: Tue, 11 Jan 2022 16:44:31 -0700 Subject: feat(diagnostic): allow retrieving current diagnostic config --- runtime/doc/diagnostic.txt | 5 +++-- runtime/lua/vim/diagnostic.lua | 10 ++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/diagnostic.txt b/runtime/doc/diagnostic.txt index bb36fa46f6..19db3158be 100644 --- a/runtime/doc/diagnostic.txt +++ b/runtime/doc/diagnostic.txt @@ -334,8 +334,9 @@ config({opts}, {namespace}) *vim.diagnostic.config()* that returns any of the above. Parameters: ~ - {opts} table Configuration table with the following - keys: + {opts} table|nil When omitted or "nil", retrieve the + current configuration. Otherwise, a + configuration table with the following keys: • underline: (default true) Use underline for diagnostics. Options: • severity: Only underline diagnostics diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua index 4bf69a2d39..b4537c2882 100644 --- a/runtime/lua/vim/diagnostic.lua +++ b/runtime/lua/vim/diagnostic.lua @@ -552,7 +552,8 @@ end --- - `table`: Enable this feature with overrides. Use an empty table to use default values. --- - `function`: Function with signature (namespace, bufnr) that returns any of the above. --- ----@param opts table Configuration table with the following keys: +---@param opts table|nil When omitted or "nil", retrieve the current configuration. Otherwise, a +--- configuration table with the following keys: --- - underline: (default true) Use underline for diagnostics. Options: --- * severity: Only underline diagnostics matching the given severity --- |diagnostic-severity| @@ -599,7 +600,7 @@ end --- global diagnostic options. function M.config(opts, namespace) vim.validate { - opts = { opts, 't' }, + opts = { opts, 't', true }, namespace = { namespace, 'n', true }, } @@ -611,6 +612,11 @@ function M.config(opts, namespace) t = global_diagnostic_options end + if not opts then + -- Return current config + return vim.deepcopy(t) + end + for k, v in pairs(opts) do t[k] = v end -- cgit From 43ef7df22d58a72e8b155265620f6c030900812e Mon Sep 17 00:00:00 2001 From: hrsh7th Date: Thu, 13 Jan 2022 18:28:13 +0900 Subject: fix(lsp): fix applying multiple out-of-range TextEdits (#17037) --- runtime/lua/vim/lsp/util.lua | 53 +++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 25 deletions(-) (limited to 'runtime') diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index 89c5ebe8f7..4f893425ef 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -286,7 +286,7 @@ 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 - local line = get_line(bufnr, position.line) + local line = get_line(bufnr, position.line) or '' local ok, result ok, result = pcall(_str_byteindex_enc, line, col, offset_encoding) if ok then @@ -402,25 +402,6 @@ function M.apply_text_edits(text_edits, bufnr, offset_encoding) end end) - -- Some LSP servers may return +1 range of the buffer content but nvim_buf_set_text can't accept it so we should fix it here. - local has_eol_text_edit = false - local max = vim.api.nvim_buf_line_count(bufnr) - local len = _str_utfindex_enc(vim.api.nvim_buf_get_lines(bufnr, -2, -1, false)[1] or '', nil, offset_encoding) - text_edits = vim.tbl_map(function(text_edit) - if max <= text_edit.range.start.line then - text_edit.range.start.line = max - 1 - text_edit.range.start.character = len - text_edit.newText = '\n' .. text_edit.newText - has_eol_text_edit = true - end - if max <= text_edit.range['end'].line then - text_edit.range['end'].line = max - 1 - text_edit.range['end'].character = len - has_eol_text_edit = true - end - return text_edit - end, text_edits) - -- Some LSP servers are depending on the VSCode behavior. -- The VSCode will re-locate the cursor position after applying TextEdit so we also do it. local is_current_buf = vim.api.nvim_get_current_buf() == bufnr @@ -440,16 +421,35 @@ function M.apply_text_edits(text_edits, bufnr, offset_encoding) -- Apply text edits. local is_cursor_fixed = false + local has_eol_text_edit = false for _, text_edit in ipairs(text_edits) do + -- Convert from LSP style ranges to Neovim style ranges. local e = { start_row = text_edit.range.start.line, - start_col = get_line_byte_from_position(bufnr, text_edit.range.start), + start_col = get_line_byte_from_position(bufnr, text_edit.range.start, offset_encoding), end_row = text_edit.range['end'].line, - end_col = get_line_byte_from_position(bufnr, text_edit.range['end']), + end_col = get_line_byte_from_position(bufnr, text_edit.range['end'], offset_encoding), text = vim.split(text_edit.newText, '\n', true), } + + -- Some LSP servers may return +1 range of the buffer content but nvim_buf_set_text can't accept it so we should fix it here. + local max = vim.api.nvim_buf_line_count(bufnr) + if max <= e.start_row or max <= e.end_row then + local len = #(get_line(bufnr, max - 1) or '') + if max <= e.start_row then + e.start_row = max - 1 + e.start_col = len + table.insert(e.text, 1, '') + end + if max <= e.end_row then + e.end_row = max - 1 + e.end_col = len + end + has_eol_text_edit = true + end vim.api.nvim_buf_set_text(bufnr, e.start_row, e.start_col, e.end_row, e.end_col, e.text) + -- Fix cursor position. local row_count = (e.end_row - e.start_row) + 1 if e.end_row < cursor.row then cursor.row = cursor.row + (#e.text - row_count) @@ -464,10 +464,13 @@ function M.apply_text_edits(text_edits, bufnr, offset_encoding) end end + local max = vim.api.nvim_buf_line_count(bufnr) + + -- Apply fixed cursor position. if is_cursor_fixed then local is_valid_cursor = true - is_valid_cursor = is_valid_cursor and cursor.row < vim.api.nvim_buf_line_count(bufnr) - is_valid_cursor = is_valid_cursor and cursor.col <= #(vim.api.nvim_buf_get_lines(bufnr, cursor.row, cursor.row + 1, false)[1] or '') + is_valid_cursor = is_valid_cursor and cursor.row < max + is_valid_cursor = is_valid_cursor and cursor.col <= #(get_line(bufnr, max - 1) or '') if is_valid_cursor then vim.api.nvim_win_set_cursor(0, { cursor.row + 1, cursor.col }) end @@ -476,7 +479,7 @@ function M.apply_text_edits(text_edits, bufnr, offset_encoding) -- Remove final line if needed local fix_eol = has_eol_text_edit fix_eol = fix_eol and api.nvim_buf_get_option(bufnr, 'fixeol') - fix_eol = fix_eol and (vim.api.nvim_buf_get_lines(bufnr, -2, -1, false)[1] or '') == '' + fix_eol = fix_eol and get_line(bufnr, max - 1) == '' if fix_eol then vim.api.nvim_buf_set_lines(bufnr, -2, -1, false, {}) end -- cgit From e7cd81156755c2f588752d469bceee9e48377b4e Mon Sep 17 00:00:00 2001 From: Mathias Fußenegger Date: Thu, 13 Jan 2022 10:47:36 +0100 Subject: fix(lsp): handle negative activeSignature in signatureHelp (#17064) omnisharp-roslyn can send negative values: { activeParameter = 0, activeSignature = -1, signatures = { { documentation = "", label = "TestEntity.TestEntity()", parameters = {} } } } In 3.16 of the specification `activeSignature` is defined as `uinteger` and therefore negative values shouldn't be allowed, but within 3.15 it was defined as `number` which makes me think we can be a bit lenient in this case and handle them. The expected behavior is quite clear: The active signature. If omitted or the value lies outside the range of `signatures` the value defaults to zero or is ignored if the `SignatureHelp` has no signatures. Fixes an error: util.lua:1685: attempt to get length of local 'lines' (a nil value) util.lua:1685: in function 'trim_empty_lines' handlers.lua:334: in function 'textDocument/signatureHelp' --- runtime/lua/vim/lsp/util.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index 4f893425ef..a00f7f3673 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -842,7 +842,8 @@ function M.convert_signature_help_to_markdown_lines(signature_help, ft, triggers local active_hl local active_signature = signature_help.activeSignature or 0 -- If the activeSignature is not inside the valid range, then clip it. - if active_signature >= #signature_help.signatures then + -- In 3.15 of the protocol, activeSignature was allowed to be negative + if active_signature >= #signature_help.signatures or active_signature < 0 then active_signature = 0 end local signature = signature_help.signatures[active_signature + 1] -- cgit From bc722c8a74766e14aff3a8e2fc46db72ed864053 Mon Sep 17 00:00:00 2001 From: Michael Lingelbach Date: Thu, 13 Jan 2022 02:34:04 -0800 Subject: fix(lsp): strictly enforce passing offset encoding (#17049) This removes the "fallback" to utf-16 in many of our helper functions. We should always explicitly pass these around when possible except in two locations: * generating params with help utilities called by buf.lua functions * the buf.lua functions themselves Anything that is called by the handler should be passed the offset encoding. --- runtime/lua/vim/lsp/buf.lua | 2 +- runtime/lua/vim/lsp/handlers.lua | 41 ++++++++++++++++++++------ runtime/lua/vim/lsp/util.lua | 62 ++++++++++++++++++++++++++++------------ 3 files changed, 77 insertions(+), 28 deletions(-) (limited to 'runtime') diff --git a/runtime/lua/vim/lsp/buf.lua b/runtime/lua/vim/lsp/buf.lua index c1d777ae6c..e8633f5924 100644 --- a/runtime/lua/vim/lsp/buf.lua +++ b/runtime/lua/vim/lsp/buf.lua @@ -503,7 +503,7 @@ local function on_code_action_results(results, ctx) ---@private local function apply_action(action, client) if action.edit then - util.apply_workspace_edit(action.edit) + util.apply_workspace_edit(action.edit, client.offset_encoding) end if action.command then local command = type(action.command) == 'table' and action.command or action diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua index a48302cc4b..6378ed0749 100644 --- a/runtime/lua/vim/lsp/handlers.lua +++ b/runtime/lua/vim/lsp/handlers.lua @@ -111,13 +111,15 @@ M['client/registerCapability'] = function(_, _, ctx) end --see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_applyEdit -M['workspace/applyEdit'] = function(_, workspace_edit) +M['workspace/applyEdit'] = function(_, workspace_edit, ctx) if not workspace_edit then return end -- TODO(ashkan) Do something more with label? + local client_id = ctx.client_id + local client = vim.lsp.get_client_by_id(client_id) if workspace_edit.label then print("Workspace edit", workspace_edit.label) end - local status, result = pcall(util.apply_workspace_edit, workspace_edit.edit) + local status, result = pcall(util.apply_workspace_edit, workspace_edit.edit, client.offset_encoding) return { applied = status; failureReason = result; @@ -159,6 +161,28 @@ M['textDocument/codeLens'] = function(...) end +--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_references +M['textDocument/references'] =function(_, result, ctx, config) + if not result or vim.tbl_isempty(result) then + vim.notify('No references found') + else + config = config or {} + if config.loclist then + vim.fn.setloclist(0, {}, ' ', { + title = 'Language Server'; + items = util.locations_to_items(result, ctx.offset_encoding); + }) + api.nvim_command("lopen") + else + vim.fn.setqflist({}, ' ', { + title = 'Language Server'; + items = util.locations_to_items(result, ctx.offset_encoding); + }) + api.nvim_command("botright copen") + end + end +end + ---@private --- Return a function that converts LSP responses to list items and opens the list @@ -194,9 +218,6 @@ local function response_to_list(map_result, entity) end ---see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_references -M['textDocument/references'] = response_to_list(util.locations_to_items, 'references') - --see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_documentSymbol M['textDocument/documentSymbol'] = response_to_list(util.symbols_to_items, 'document symbols') @@ -277,19 +298,23 @@ local function location_handler(_, result, ctx, _) local _ = log.info() and log.info(ctx.method, 'No location found') return nil end + local client = vim.lsp.get_client_by_id(ctx.client_id) -- textDocument/definition can return Location or Location[] -- https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_definition if vim.tbl_islist(result) then - util.jump_to_location(result[1]) + util.jump_to_location(result[1], client.offset_encoding) if #result > 1 then - vim.fn.setqflist({}, ' ', {title = 'LSP locations', items = util.locations_to_items(result)}) + vim.fn.setqflist({}, ' ', { + title = 'LSP locations', + items = util.locations_to_items(result, client.offset_encoding) + }) api.nvim_command("copen") end else - util.jump_to_location(result) + util.jump_to_location(result, client.offset_encoding) end end diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index a00f7f3673..d09865be89 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -277,7 +277,7 @@ 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 ----@param offset_encoding string utf-8|utf-16|utf-32|nil defaults to utf-16 +---@param offset_encoding string utf-8|utf-16|utf-32 --- 1-indexed local function get_line_byte_from_position(bufnr, position, offset_encoding) -- LSP's line and characters are 0-indexed @@ -360,15 +360,14 @@ end --- Applies a list of text edits to a buffer. ---@param text_edits table list of `TextEdit` objects ---@param bufnr number Buffer id ----@param offset_encoding string utf-8|utf-16|utf-32|nil defaults to encoding of first client of `bufnr` +---@param offset_encoding string utf-8|utf-16|utf-32 defaults to encoding of first client of `bufnr` ---@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textEdit function M.apply_text_edits(text_edits, bufnr, offset_encoding) validate { text_edits = { text_edits, 't', false }; bufnr = { bufnr, 'number', false }; - offset_encoding = { offset_encoding, 'string', true }; + offset_encoding = { offset_encoding, 'string', false }; } - offset_encoding = offset_encoding or M._get_offset_encoding(bufnr) if not next(text_edits) then return end if not api.nvim_buf_is_loaded(bufnr) then vim.fn.bufload(bufnr) @@ -517,9 +516,12 @@ end ---@param text_document_edit table: a `TextDocumentEdit` object ---@param index number: Optional index of the edit, if from a list of edits (or nil, if not from a list) ---@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocumentEdit -function M.apply_text_document_edit(text_document_edit, index) +function M.apply_text_document_edit(text_document_edit, index, offset_encoding) local text_document = text_document_edit.textDocument local bufnr = vim.uri_to_bufnr(text_document.uri) + if offset_encoding == nil then + vim.notify_once("apply_text_document_edit must be called with valid offset encoding", vim.log.levels.WARN) + end -- For lists of text document edits, -- do not check the version after the first edit. @@ -538,7 +540,7 @@ function M.apply_text_document_edit(text_document_edit, index) return end - M.apply_text_edits(text_document_edit.edits, bufnr) + M.apply_text_edits(text_document_edit.edits, bufnr, offset_encoding) end --- Parses snippets in a completion entry. @@ -737,7 +739,10 @@ end --- ---@param workspace_edit (table) `WorkspaceEdit` --see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_applyEdit -function M.apply_workspace_edit(workspace_edit) +function M.apply_workspace_edit(workspace_edit, offset_encoding) + if offset_encoding == nil then + vim.notify_once("apply_workspace_edit must be called with valid offset encoding", vim.log.levels.WARN) + end if workspace_edit.documentChanges then for idx, change in ipairs(workspace_edit.documentChanges) do if change.kind == "rename" then @@ -753,7 +758,7 @@ function M.apply_workspace_edit(workspace_edit) elseif change.kind then error(string.format("Unsupported change: %q", vim.inspect(change))) else - M.apply_text_document_edit(change, idx) + M.apply_text_document_edit(change, idx, offset_encoding) end end return @@ -984,12 +989,16 @@ end --- Jumps to a location. --- ----@param location (`Location`|`LocationLink`) +---@param location table (`Location`|`LocationLink`) +---@param offset_encoding string utf-8|utf-16|utf-32 (required) ---@returns `true` if the jump succeeded -function M.jump_to_location(location) +function M.jump_to_location(location, offset_encoding) -- location may be Location or LocationLink local uri = location.uri or location.targetUri if uri == nil then return end + if offset_encoding == nil then + vim.notify_once("jump_to_location must be called with valid offset encoding", vim.log.levels.WARN) + end local bufnr = vim.uri_to_bufnr(uri) -- Save position in jumplist vim.cmd "normal! m'" @@ -1004,7 +1013,7 @@ function M.jump_to_location(location) api.nvim_buf_set_option(bufnr, 'buflisted', true) local range = location.range or location.targetSelectionRange local row = range.start.line - local col = get_line_byte_from_position(bufnr, range.start) + local col = get_line_byte_from_position(bufnr, range.start, offset_encoding) api.nvim_win_set_cursor(0, {row + 1, col}) -- Open folds under the cursor vim.cmd("normal! zv") @@ -1513,11 +1522,13 @@ do --[[ References ]] --- ---@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 `offset_encoding` of first client of `bufnr` + ---@param offset_encoding string One of "utf-8", "utf-16", "utf-32". ---@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} } - offset_encoding = offset_encoding or M._get_offset_encoding(bufnr) + validate { + bufnr = {bufnr, 'n', true}, + offset_encoding = { offset_encoding, 'string', false }; + } for _, reference in ipairs(references) do local start_line, start_char = reference["range"]["start"]["line"], reference["range"]["start"]["character"] local end_line, end_char = reference["range"]["end"]["line"], reference["range"]["end"]["character"] @@ -1550,9 +1561,14 @@ end) --- The result can be passed to the {list} argument of |setqflist()| or --- |setloclist()|. --- ----@param locations (table) list of `Location`s or `LocationLink`s +---@param locations table list of `Location`s or `LocationLink`s +---@param offset_encoding string offset_encoding for locations utf-8|utf-16|utf-32 ---@returns (table) list of items -function M.locations_to_items(locations) +function M.locations_to_items(locations, offset_encoding) + if offset_encoding == nil then + vim.notify_once("locations_to_items must be called with valid offset encoding", vim.log.levels.WARN) + end + local items = {} local grouped = setmetatable({}, { __index = function(t, k) @@ -1592,7 +1608,7 @@ function M.locations_to_items(locations) local pos = temp.start local row = pos.line local line = lines[row] or "" - local col = pos.character + local col = M._str_byteindex_enc(line, pos.character, offset_encoding) table.insert(items, { filename = filename, lnum = row + 1, @@ -1776,7 +1792,13 @@ function M._get_offset_encoding(bufnr) local offset_encoding for _, client in pairs(vim.lsp.buf_get_clients(bufnr)) do - local this_offset_encoding = client.offset_encoding or "utf-16" + if client.offset_encoding == nil then + vim.notify_once( + string.format("Client (id: %s) offset_encoding is nil. Do not unset offset_encoding.", client.id), + vim.log.levels.ERROR + ) + end + local this_offset_encoding = client.offset_encoding if not offset_encoding then offset_encoding = this_offset_encoding elseif offset_encoding ~= this_offset_encoding then @@ -1905,7 +1927,9 @@ end ---@returns (number, number) `offset_encoding` index of the character in line {row} column {col} in buffer {buf} function M.character_offset(buf, row, col, offset_encoding) local line = get_line(buf, row) - offset_encoding = offset_encoding or M._get_offset_encoding(buf) + if offset_encoding == nil then + vim.notify_once("character_offset must be called with valid offset encoding", vim.log.levels.WARN) + end -- If the col is past the EOL, use the line length. if col > #line then return _str_utfindex_enc(line, nil, offset_encoding) -- cgit From 9304ee3874fc1e0608a9902cf5b1b0ac6645ef0a Mon Sep 17 00:00:00 2001 From: Michael Lingelbach Date: Thu, 13 Jan 2022 06:47:35 -0800 Subject: fix(lsp): forward offset_encoding to apply_text_edits (#17075) --- runtime/lua/vim/lsp/buf.lua | 4 ++-- runtime/lua/vim/lsp/handlers.lua | 6 ++++-- runtime/lua/vim/lsp/util.lua | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) (limited to 'runtime') diff --git a/runtime/lua/vim/lsp/buf.lua b/runtime/lua/vim/lsp/buf.lua index e8633f5924..c9b73e4b70 100644 --- a/runtime/lua/vim/lsp/buf.lua +++ b/runtime/lua/vim/lsp/buf.lua @@ -184,7 +184,7 @@ function M.formatting_sync(options, timeout_ms) local result, err = client.request_sync('textDocument/formatting', params, timeout_ms, bufnr) if result and result.result then - util.apply_text_edits(result.result, bufnr) + util.apply_text_edits(result.result, bufnr, client.offset_encoding) elseif err then vim.notify('vim.lsp.buf.formatting_sync: ' .. err, vim.log.levels.WARN) end @@ -228,7 +228,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, bufnr) + util.apply_text_edits(result.result, bufnr, client.offset_encoding) elseif err then vim.notify(string.format("vim.lsp.buf.formatting_seq_sync: (%s) %s", client.name, err), vim.log.levels.WARN) end diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua index 6378ed0749..4c0ca28bb9 100644 --- a/runtime/lua/vim/lsp/handlers.lua +++ b/runtime/lua/vim/lsp/handlers.lua @@ -233,13 +233,15 @@ end --see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_rangeFormatting M['textDocument/rangeFormatting'] = function(_, result, ctx, _) if not result then return end - util.apply_text_edits(result, ctx.bufnr) + local client = vim.lsp.get_client_by_id(ctx.client_id) + util.apply_text_edits(result, ctx.bufnr, client.offset_encoding) end --see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_formatting M['textDocument/formatting'] = function(_, result, ctx, _) if not result then return end - util.apply_text_edits(result, ctx.bufnr) + local client = vim.lsp.get_client_by_id(ctx.client_id) + util.apply_text_edits(result, ctx.bufnr, client.offset_encoding) end --see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_completion diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index d09865be89..edb9f50d20 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -771,7 +771,7 @@ function M.apply_workspace_edit(workspace_edit, offset_encoding) for uri, changes in pairs(all_changes) do local bufnr = vim.uri_to_bufnr(uri) - M.apply_text_edits(changes, bufnr) + M.apply_text_edits(changes, bufnr, offset_encoding) end end -- cgit From 8066abcd65a672010e7159bcb9601f6eb5481e81 Mon Sep 17 00:00:00 2001 From: Michael Lingelbach Date: Thu, 13 Jan 2022 09:28:27 -0800 Subject: fix(lsp): forward offset_encoding in rename handler (#17079) --- runtime/lua/vim/lsp/handlers.lua | 5 +++-- runtime/lua/vim/lsp/util.lua | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'runtime') diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua index 4c0ca28bb9..ddfcbf5f75 100644 --- a/runtime/lua/vim/lsp/handlers.lua +++ b/runtime/lua/vim/lsp/handlers.lua @@ -225,9 +225,10 @@ M['textDocument/documentSymbol'] = response_to_list(util.symbols_to_items, 'docu M['workspace/symbol'] = response_to_list(util.symbols_to_items, 'symbols') --see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_rename -M['textDocument/rename'] = function(_, result, _) +M['textDocument/rename'] = function(_, result, ctx, _) if not result then return end - util.apply_workspace_edit(result) + local client = vim.lsp.get_client_by_id(ctx.client_id) + util.apply_workspace_edit(result, client.offset_encoding) end --see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_rangeFormatting diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index edb9f50d20..4cbd8c9554 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -737,7 +737,8 @@ end --- Applies a `WorkspaceEdit`. --- ----@param workspace_edit (table) `WorkspaceEdit` +---@param workspace_edit table `WorkspaceEdit` +---@param offset_encoding string utf-8|utf-16|utf-32 (required) --see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_applyEdit function M.apply_workspace_edit(workspace_edit, offset_encoding) if offset_encoding == nil then -- cgit From 596c55756a6a25e8a6d587610292f3e2ca0940b7 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Thu, 13 Jan 2022 18:31:15 +0100 Subject: vim-patch:8.2.4077: not all Libsensors files are recognized (#17080) Problem: Not all Libsensors files are recognized. Solution: Add "sensors.d/*" pattern. (Doug Kearns) https://github.com/vim/vim/commit/8d9e470aa91a93da7d6bda62521aef69a79e956d --- runtime/filetype.vim | 3 +++ runtime/lua/vim/filetype.lua | 1 + 2 files changed, 4 insertions(+) (limited to 'runtime') diff --git a/runtime/filetype.vim b/runtime/filetype.vim index aa12a5f8dd..900bbf778d 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -2285,6 +2285,9 @@ au BufNewFile,BufRead Kconfig.* call s:StarSetf('kconfig') " Lilo: Linux loader au BufNewFile,BufRead lilo.conf* call s:StarSetf('lilo') +" Libsensors +au BufNewFile,BufRead */etc/sensors.d/[^.]* call s:StarSetf('sensors') + " Logcheck au BufNewFile,BufRead */etc/logcheck/*.d*/* call s:StarSetf('logcheck') diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index 3d91abc406..6ba6b3981d 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -1346,6 +1346,7 @@ local pattern = { [".*/constant/g"] = function() vim.fn["dist#ft#FTfoam"]() end, [".*/0/.*"] = function() vim.fn["dist#ft#FTfoam"]() end, [".*/0%.orig/.*"] = function() vim.fn["dist#ft#FTfoam"]() end, + [".*/etc/sensors%.d/[^.].*"] = starsetf('sensors'), -- END PATTERN } -- luacheck: pop -- cgit From 19864bd99529334909922e8d2a61a600fea7b29a Mon Sep 17 00:00:00 2001 From: Gary Sentosa Date: Thu, 6 Jan 2022 21:43:36 +0900 Subject: feat(filetype.lua): fix .env file not detected --- runtime/lua/vim/filetype.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'runtime') diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index 6ba6b3981d..bf3e060ca6 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -1075,6 +1075,7 @@ local filename = { [".alias"] = function() vim.fn["dist#ft#CSH"]() end, [".bashrc"] = function() vim.fn["dist#ft#SetFileTypeSH"]("bash") end, [".cshrc"] = function() vim.fn["dist#ft#CSH"]() end, + [".env"] = function() vim.fn["dist#ft#SetFileTypeSH"](vim.fn.getline(1)) end, [".kshrc"] = function() vim.fn["dist#ft#SetFileTypeSH"]("ksh") end, [".login"] = function() vim.fn["dist#ft#CSH"]() end, [".profile"] = function() vim.fn["dist#ft#SetFileTypeSH"](vim.fn.getline(1)) end, -- cgit From 94d53589221567444bac2cf6a3692906259fe4c6 Mon Sep 17 00:00:00 2001 From: Gary Sentosa Date: Thu, 6 Jan 2022 16:27:16 +0900 Subject: feat(filetype.lua): add support for tmux.conf files --- runtime/lua/vim/filetype.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'runtime') diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index bf3e060ca6..87846f5eed 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -1038,6 +1038,7 @@ local filename = { ["tidy.conf"] = "tidy", tidyrc = "tidy", [".tidyrc"] = "tidy", + [".tmux.conf"] = "tmux", ["/.cargo/config"] = "toml", Pipfile = "toml", ["Gopkg.lock"] = "toml", @@ -1233,6 +1234,8 @@ local pattern = { [".*/%.config/systemd/user/.*%.d/.*%.conf"] = "systemd", [".*/etc/systemd/system/.*%.d/.*%.conf"] = "systemd", [".*%.t%.html"] = "tilde", + ["%.?tmux.*%.conf"] = "tmux", + ["%.?tmux.*%.conf.*"] = { "tmux", { priority = -1 } }, [".*/%.cargo/config"] = "toml", [".*/%.cargo/credentials"] = "toml", [".*/etc/udev/udev%.conf"] = "udevconf", -- cgit From 27b664a2de08301ca847c3b06a34df2be71e0caf Mon Sep 17 00:00:00 2001 From: Sanchayan Maity Date: Thu, 6 Jan 2022 21:28:24 +0530 Subject: feat(filetype.lua): add support for patch files --- runtime/lua/vim/filetype.lua | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'runtime') diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index 87846f5eed..ea7e57c408 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -770,6 +770,14 @@ local extension = { mm = function() vim.fn["dist#ft#FTmm"]() end, mms = function() vim.fn["dist#ft#FTmms"]() end, p = function() vim.fn["dist#ft#FTprogress_pascal"]() end, + patch = function(path, bufnr) + local firstline = getline(bufnr, 1) + if string.find(firstline, "^From " .. string.rep("%x", 40) .. "+ Mon Sep 17 00:00:00 2001$") then + return "gitsendemail" + else + return "diff" + end + end, pl = function() vim.fn["dist#ft#FTpl"]() end, pp = function() vim.fn["dist#ft#FTpp"]() end, pro = function() vim.fn["dist#ft#ProtoCheck"]('idlang') end, -- cgit From 7a574e54f2309eb9d267282619f9383413b85d08 Mon Sep 17 00:00:00 2001 From: Sanchayan Maity Date: Fri, 7 Jan 2022 15:19:49 +0530 Subject: feat(filetype.lua): add support for files under .git --- runtime/lua/vim/filetype.lua | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'runtime') diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index ea7e57c408..83e4a20ef7 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -1359,6 +1359,12 @@ local pattern = { [".*/0/.*"] = function() vim.fn["dist#ft#FTfoam"]() end, [".*/0%.orig/.*"] = function() vim.fn["dist#ft#FTfoam"]() end, [".*/etc/sensors%.d/[^.].*"] = starsetf('sensors'), + [".*%.git/.*"] = function(path, bufnr) + local firstline = getline(bufnr, 1) + if firstline:find("^" .. string.rep("%x", 40) .. "+ ") or firstline:sub(1, 5) == "ref: " then + return "git" + end + end, -- END PATTERN } -- luacheck: pop -- cgit From c38d602b888a95a4b3b7a3b4241ce5b3e434eb35 Mon Sep 17 00:00:00 2001 From: rhcher <2032877541@qq.com> Date: Sun, 9 Jan 2022 16:49:37 +0800 Subject: feat(filetype.lua): fix .cc file not detected --- runtime/lua/vim/filetype.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index 83e4a20ef7..3423be40f9 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -119,7 +119,13 @@ local extension = { tcc = "cpp", hxx = "cpp", hpp = "cpp", - cpp = function() + cpp = function(path, bufnr) + if vim.g.cynlib_syntax_for_cc then + return "cynlib" + end + return "cpp" + end, + cc = function(path, bufnr) if vim.g.cynlib_syntax_for_cc then return "cynlib" end -- cgit From 6e04c8653cf3a5d8d4e9d81645fb65834877349c Mon Sep 17 00:00:00 2001 From: Gregory Anders Date: Tue, 11 Jan 2022 13:50:47 -0700 Subject: fix(filetype): fix foam pattern detection --- runtime/lua/vim/filetype.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'runtime') diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index 3423be40f9..13da5286c8 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -1356,10 +1356,10 @@ local pattern = { ["zlog.*"] = starsetf('zsh'), ["zsh.*"] = starsetf('zsh'), ["ae%d+%.txt"] = 'mail', - ["[a-zA-Z0-9]*Dict"] = function() vim.fn["dist#ft#FTfoam"]() end, - ["[a-zA-Z0-9]*Dict%..*"] = function() vim.fn["dist#ft#FTfoam"]() end, - ["[a-zA-Z]*Properties"] = function() vim.fn["dist#ft#FTfoam"]() end, - ["[a-zA-Z]*Properties%..*"] = function() vim.fn["dist#ft#FTfoam"]() end, + ["[a-zA-Z0-9].*Dict"] = function() vim.fn["dist#ft#FTfoam"]() end, + ["[a-zA-Z0-9].*Dict%..*"] = function() vim.fn["dist#ft#FTfoam"]() end, + ["[a-zA-Z].*Properties"] = function() vim.fn["dist#ft#FTfoam"]() end, + ["[a-zA-Z].*Properties%..*"] = function() vim.fn["dist#ft#FTfoam"]() end, [".*Transport%..*"] = function() vim.fn["dist#ft#FTfoam"]() end, [".*/constant/g"] = function() vim.fn["dist#ft#FTfoam"]() end, [".*/0/.*"] = function() vim.fn["dist#ft#FTfoam"]() end, -- cgit From b72aae85fd980b55a695543c1c34e8f0bf584cc4 Mon Sep 17 00:00:00 2001 From: Michael Lingelbach Date: Fri, 14 Jan 2022 08:02:44 -0800 Subject: fix(lsp): always split text edits on \r, \r\n, and \n (#17087) Closes: https://github.com/neovim/neovim/issues/17053 Servers can return a mix of line endings per the language server protocol. See: https://microsoft.github.io/language-server-protocol/specification.html#textDocuments All should be equally treated as line endings. --- runtime/lua/vim/lsp/util.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'runtime') diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index 4cbd8c9554..8be1683d86 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -422,6 +422,9 @@ function M.apply_text_edits(text_edits, bufnr, offset_encoding) local is_cursor_fixed = false local has_eol_text_edit = false for _, text_edit in ipairs(text_edits) do + -- Normalize line ending + text_edit.newText, _ = string.gsub(text_edit.newText, '\r\n?', '\n') + -- Convert from LSP style ranges to Neovim style ranges. local e = { start_row = text_edit.range.start.line, -- cgit From 59ea8fa322c946183631233ae546e3e8b0c37e30 Mon Sep 17 00:00:00 2001 From: Gregory Anders <8965202+gpanders@users.noreply.github.com> Date: Fri, 14 Jan 2022 14:20:17 -0700 Subject: fix(filetype): expand tildes in filetype patterns (#17091) This allows patterns like ["~/.config/foo"] = "fooscript" to work. --- runtime/lua/vim/filetype.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index 13da5286c8..819587bb3e 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -1398,7 +1398,7 @@ local pattern_sorted = sort_by_priority(pattern) ---@private local function normalize_path(path) - return (path:gsub("\\", "/")) + return (path:gsub("\\", "/"):gsub("^~", vim.env.HOME)) end --- Add new filetype mappings. -- cgit From 574a5822023939d534d922eaa345bb7e0633d2b8 Mon Sep 17 00:00:00 2001 From: Gregory Anders <8965202+gpanders@users.noreply.github.com> Date: Fri, 14 Jan 2022 14:20:50 -0700 Subject: feat(lsp): dynamically generate list title in response_to_list (#17081) This gives quickfix/location lists created by handlers which use 'response_to_list' (textDocument/documentSymbols and workspace/symbol by default) the ability to set a more useful list title. This commit gives lists created for documentSymbols a title of the form: Symbols in and lists for workspace/symbol a title of the form: Symbols matching '' These are more informative than a standard "Language Server" list title and can help disambiguate results when users have multiple quickfix lists that they cycle through with `:colder` and `:cnewer`. --- runtime/lua/vim/lsp/handlers.lua | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'runtime') diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua index ddfcbf5f75..c0843e1577 100644 --- a/runtime/lua/vim/lsp/handlers.lua +++ b/runtime/lua/vim/lsp/handlers.lua @@ -162,21 +162,23 @@ end --see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_references -M['textDocument/references'] =function(_, result, ctx, config) +M['textDocument/references'] = function(_, result, ctx, config) if not result or vim.tbl_isempty(result) then vim.notify('No references found') else config = config or {} if config.loclist then vim.fn.setloclist(0, {}, ' ', { - title = 'Language Server'; + title = 'References'; items = util.locations_to_items(result, ctx.offset_encoding); + context = ctx; }) api.nvim_command("lopen") else vim.fn.setqflist({}, ' ', { - title = 'Language Server'; + title = 'References'; items = util.locations_to_items(result, ctx.offset_encoding); + context = ctx; }) api.nvim_command("botright copen") end @@ -193,23 +195,26 @@ end --- loclist: (boolean) use the location list (default is to use the quickfix list) --- ---@param map_result function `((resp, bufnr) -> list)` to convert the response ----@param entity name of the resource used in a `not found` error message -local function response_to_list(map_result, entity) - return function(_,result, ctx, config) +---@param entity string name of the resource used in a `not found` error message +---@param title_fn function Function to call to generate list title +local function response_to_list(map_result, entity, title_fn) + return function(_, result, ctx, config) if not result or vim.tbl_isempty(result) then vim.notify('No ' .. entity .. ' found') else config = config or {} if config.loclist then vim.fn.setloclist(0, {}, ' ', { - title = 'Language Server'; + title = title_fn(ctx); items = map_result(result, ctx.bufnr); + context = ctx; }) api.nvim_command("lopen") else vim.fn.setqflist({}, ' ', { - title = 'Language Server'; + title = title_fn(ctx); items = map_result(result, ctx.bufnr); + context = ctx; }) api.nvim_command("botright copen") end @@ -219,10 +224,15 @@ end --see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_documentSymbol -M['textDocument/documentSymbol'] = response_to_list(util.symbols_to_items, 'document symbols') +M['textDocument/documentSymbol'] = response_to_list(util.symbols_to_items, 'document symbols', function(ctx) + local fname = vim.fn.fnamemodify(vim.uri_to_fname(ctx.params.textDocument.uri), ":.") + return string.format('Symbols in %s', fname) +end) --see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_symbol -M['workspace/symbol'] = response_to_list(util.symbols_to_items, 'symbols') +M['workspace/symbol'] = response_to_list(util.symbols_to_items, 'symbols', function(ctx) + return string.format("Symbols matching '%s'", ctx.params.query) +end) --see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_rename M['textDocument/rename'] = function(_, result, ctx, _) -- cgit From d391940b9a074bca7ee82460ccaaabf46b5f2ba9 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 15 Jan 2022 19:21:17 +0800 Subject: vim-patch:8.2.3227: 'virtualedit' can only be set globally Problem: 'virtualedit' can only be set globally. Solution: Make 'virtualedit' global-local. (Gary Johnson, closes vim/vim#8638) https://github.com/vim/vim/commit/53ba05b09075f14227f9be831a22ed16f7cc26b2 I changed some macros to unsigned integer literals to avoid compiler warnings. --- runtime/doc/options.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 06236741c2..08f719f16c 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -6782,12 +6782,16 @@ A jump table for the options with a short description can be found at |Q_op|. *'virtualedit'* *'ve'* 'virtualedit' 've' string (default "") - global + global or local to buffer |global-local| A comma separated list of these words: block Allow virtual editing in Visual block mode. insert Allow virtual editing in Insert mode. all Allow virtual editing in all modes. onemore Allow the cursor to move just past the end of the line + none When used as the local value, do not allow virtual + editing even when the global value is set. When used + as the global value, "none" is the same as "". + NONE Alternative spelling of "none". Virtual editing means that the cursor can be positioned where there is no actual character. This can be halfway into a tab or beyond the end -- cgit From 87e54f123aa1c9c769d3ff35bdd1b5a980ba701c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 15 Jan 2022 19:21:17 +0800 Subject: vim-patch:8.2.3280: 'virtualedit' local to buffer is not the best solution Problem: 'virtualedit' local to buffer is not the best solution. Solution: Make it window-local. (Gary Johnson, closes vim/vim#8685) https://github.com/vim/vim/commit/51ad850f5fbafa7aa3f60affa74ec9c9f992c6cc --- runtime/doc/options.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 08f719f16c..4536079cea 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -6782,7 +6782,7 @@ A jump table for the options with a short description can be found at |Q_op|. *'virtualedit'* *'ve'* 'virtualedit' 've' string (default "") - global or local to buffer |global-local| + global or local to window |global-local| A comma separated list of these words: block Allow virtual editing in Visual block mode. insert Allow virtual editing in Insert mode. -- cgit From c09147aad99a88dc39c47c276b431ade4c83ac9d Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sat, 15 Jan 2022 14:47:25 +0100 Subject: vim-patch:8.2.4095: sed script not recognized by the first line (#17101) Problem: Sed script not recognized by the first line. Solution: Recognize a sed script starting with "#n". (Doug Kearns) https://github.com/vim/vim/commit/e3ce17a3ca838954728df21ccb6c2a724490203d --- runtime/scripts.vim | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'runtime') diff --git a/runtime/scripts.vim b/runtime/scripts.vim index e41405a6c5..dd47f65ba0 100644 --- a/runtime/scripts.vim +++ b/runtime/scripts.vim @@ -406,6 +406,12 @@ else elseif s:line1 =~# '^#.*by RouterOS.*$' set ft=routeros + " Sed scripts + " #ncomment is allowed but most likely a false positive so require a space + " before any trailing comment text + elseif s:line1 =~# '^#n\%($\|\s\)' + set ft=sed + " CVS diff else let s:lnum = 1 -- cgit From b455e0179b4288c69e6231bfcf8d1c132b78f2fc Mon Sep 17 00:00:00 2001 From: Michael Lingelbach Date: Sat, 15 Jan 2022 14:19:20 -0800 Subject: feat: use nvim_buf_set_extmark for vim.highlight (#16963) Closes https://github.com/neovim/neovim/issues/13647 This allows customizing the priority of the highlights. * Add default priority of 50 * Use priority of 200 for highlight on yank * use priority of 40 for highlight references (LSP) --- runtime/lua/vim/highlight.lua | 19 ++++++++++++++++--- runtime/lua/vim/lsp/util.lua | 5 ++++- 2 files changed, 20 insertions(+), 4 deletions(-) (limited to 'runtime') diff --git a/runtime/lua/vim/highlight.lua b/runtime/lua/vim/highlight.lua index 236f3165f2..12faa0a6e1 100644 --- a/runtime/lua/vim/highlight.lua +++ b/runtime/lua/vim/highlight.lua @@ -25,16 +25,29 @@ end ---@param higroup highlight group to use for highlighting ---@param rtype type of range (:help setreg, default charwise) ---@param inclusive boolean indicating whether the range is end-inclusive (default false) -function highlight.range(bufnr, ns, higroup, start, finish, rtype, inclusive) +---@param priority number indicating priority of highlight (default 50) +function highlight.range(bufnr, ns, higroup, start, finish, rtype, inclusive, priority) rtype = rtype or 'v' inclusive = inclusive or false + priority = priority or 50 -- sanity check if start[2] < 0 or finish[1] < start[1] then return end local region = vim.region(bufnr, start, finish, rtype, inclusive) for linenr, cols in pairs(region) do - api.nvim_buf_add_highlight(bufnr, ns, higroup, linenr, cols[1], cols[2]) + local end_row + if cols[2] == -1 then + end_row = linenr + 1 + cols[2] = 0 + end + api.nvim_buf_set_extmark(bufnr, ns, linenr, cols[1], { + hl_group = higroup, + end_row = end_row, + end_col = cols[2], + priority = priority, + strict = false + }) end end @@ -82,7 +95,7 @@ function highlight.on_yank(opts) pos1 = {pos1[2] - 1, pos1[3] - 1 + pos1[4]} pos2 = {pos2[2] - 1, pos2[3] - 1 + pos2[4]} - highlight.range(bufnr, yank_ns, higroup, pos1, pos2, event.regtype, event.inclusive) + highlight.range(bufnr, yank_ns, higroup, pos1, pos2, event.regtype, event.inclusive, 200) vim.defer_fn( function() diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index 8be1683d86..d22c00ae76 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -1550,7 +1550,10 @@ do --[[ References ]] reference_ns, document_highlight_kind[kind], { start_line, start_idx }, - { end_line, end_idx }) + { end_line, end_idx }, + nil, + false, + 40) end end end -- cgit From a0201b6ed37bae594bd0db2804c8ecff09a29e0e Mon Sep 17 00:00:00 2001 From: Michael Lingelbach Date: Sat, 15 Jan 2022 15:49:29 -0800 Subject: fix(lsp): fetch offset_encoding from client in references (#17104) --- runtime/lua/vim/lsp/handlers.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua index c0843e1577..36ab6d59dd 100644 --- a/runtime/lua/vim/lsp/handlers.lua +++ b/runtime/lua/vim/lsp/handlers.lua @@ -166,18 +166,19 @@ M['textDocument/references'] = function(_, result, ctx, config) if not result or vim.tbl_isempty(result) then vim.notify('No references found') else + local client = vim.lsp.get_client_by_id(ctx.client_id) config = config or {} if config.loclist then vim.fn.setloclist(0, {}, ' ', { title = 'References'; - items = util.locations_to_items(result, ctx.offset_encoding); + items = util.locations_to_items(result, client.offset_encoding); context = ctx; }) api.nvim_command("lopen") else vim.fn.setqflist({}, ' ', { title = 'References'; - items = util.locations_to_items(result, ctx.offset_encoding); + items = util.locations_to_items(result, client.offset_encoding); context = ctx; }) api.nvim_command("botright copen") -- cgit From 7085e5b0c8588618e643c87802afc515f67812d9 Mon Sep 17 00:00:00 2001 From: Daniel Steinberg Date: Sun, 16 Jan 2022 02:08:35 -0500 Subject: fix(lsp): avoid nil workspace/symbol query (#17107) --- runtime/lua/vim/lsp/buf.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'runtime') diff --git a/runtime/lua/vim/lsp/buf.lua b/runtime/lua/vim/lsp/buf.lua index c9b73e4b70..eb7ec579f1 100644 --- a/runtime/lua/vim/lsp/buf.lua +++ b/runtime/lua/vim/lsp/buf.lua @@ -447,6 +447,9 @@ end ---@param query (string, optional) function M.workspace_symbol(query) query = query or npcall(vfn.input, "Query: ") + if query == nil then + return + end local params = {query = query} request('workspace/symbol', params) end -- cgit From be15ac06badbea6b11390ad7d9c2ddd4aea73480 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 16 Jan 2022 18:44:28 +0800 Subject: feat(statusline): support multibyte fillchar This includes a partial port of Vim patch 8.2.2569 and some changes to nvim_eval_statusline() to allow a multibyte fillchar. Literally every line of C code touched by that patch has been refactored in Nvim, and that patch contains some irrelevant foldcolumn tests I'm not sure how to port (as Nvim's foldcolumn behavior has diverged from Vim's). --- runtime/doc/options.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 06236741c2..cd374a0b05 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -2458,7 +2458,8 @@ A jump table for the options with a short description can be found at |Q_op|. < This is similar to the default, except that these characters will also be used when there is highlighting. - for "stl" and "stlnc" only single-byte values are supported. + For "stl" and "stlnc" single-byte and multibyte characters are + supported. But double-width characters are not supported. The highlighting used for these items: item highlight group ~ -- cgit From 3906b2d4fc617c6b03f7c9a615d18b70d7250e80 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Mon, 17 Jan 2022 11:58:36 +0100 Subject: vim-patch:fd31be29b822 (#17114) Update runtime files https://github.com/vim/vim/commit/fd31be29b8220ee1cb0b3460c82f2634ae3cc370 --- runtime/autoload/dist/ft.vim | 2 +- runtime/doc/autocmd.txt | 34 +++++++++++----------- runtime/doc/editing.txt | 1 + runtime/doc/map.txt | 2 +- runtime/doc/various.txt | 16 +++++----- runtime/filetype.vim | 2 +- .../pack/dist/opt/termdebug/plugin/termdebug.vim | 14 ++++++++- runtime/syntax/i3config.vim | 4 +-- 8 files changed, 44 insertions(+), 31 deletions(-) (limited to 'runtime') diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim index 342731b272..0d6841a35b 100644 --- a/runtime/autoload/dist/ft.vim +++ b/runtime/autoload/dist/ft.vim @@ -1,7 +1,7 @@ " Vim functions for file type detection " " Maintainer: Bram Moolenaar -" Last Change: 2021 Dec 17 +" Last Change: 2022 Jan 11 " These functions are moved here from runtime/filetype.vim to make startup " faster. diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt index 46d9a3b57a..5e50f9c1f8 100644 --- a/runtime/doc/autocmd.txt +++ b/runtime/doc/autocmd.txt @@ -40,10 +40,10 @@ effects. Be careful not to destroy your text. 2. Defining autocommands *autocmd-define* *:au* *:autocmd* -:au[tocmd] [group] {event} {pat} [++once] [++nested] {cmd} +:au[tocmd] [group] {event} {aupat} [++once] [++nested] {cmd} Add {cmd} to the list of commands that Vim will execute automatically on {event} for a file matching - {pat} |autocmd-pattern|. + {aupat} |autocmd-pattern|. Note: A quote character is seen as argument to the :autocmd and won't start a comment. Nvim always adds {cmd} after existing autocommands so @@ -119,19 +119,19 @@ prompt. When one command outputs two messages this can happen anyway. ============================================================================== 3. Removing autocommands *autocmd-remove* -:au[tocmd]! [group] {event} {pat} [++once] [++nested] {cmd} +:au[tocmd]! [group] {event} {aupat} [++once] [++nested] {cmd} Remove all autocommands associated with {event} and - {pat}, and add the command {cmd}. + {aupat}, and add the command {cmd}. See |autocmd-once| for [++once]. See |autocmd-nested| for [++nested]. -:au[tocmd]! [group] {event} {pat} +:au[tocmd]! [group] {event} {aupat} Remove all autocommands associated with {event} and - {pat}. + {aupat}. -:au[tocmd]! [group] * {pat} - Remove all autocommands associated with {pat} for all - events. +:au[tocmd]! [group] * {aupat} + Remove all autocommands associated with {aupat} for + all events. :au[tocmd]! [group] {event} Remove ALL autocommands for {event}. @@ -151,12 +151,12 @@ with ":augroup"); otherwise, Vim uses the group defined with [group]. ============================================================================== 4. Listing autocommands *autocmd-list* -:au[tocmd] [group] {event} {pat} +:au[tocmd] [group] {event} {aupat} Show the autocommands associated with {event} and - {pat}. + {aupat}. -:au[tocmd] [group] * {pat} - Show the autocommands associated with {pat} for all +:au[tocmd] [group] * {aupat} + Show the autocommands associated with {aupat} for all events. :au[tocmd] [group] {event} @@ -1075,16 +1075,16 @@ WinScrolled After scrolling the viewport of the current ============================================================================== -6. Patterns *autocmd-pattern* *{pat}* +6. Patterns *autocmd-pattern* *{aupat}* -The {pat} argument can be a comma separated list. This works as if the -command was given with each pattern separately. Thus this command: > +The {aupat} argument of `:autocmd` can be a comma separated list. This works +as if the command was given with each pattern separately. Thus this command: > :autocmd BufRead *.txt,*.info set et Is equivalent to: > :autocmd BufRead *.txt set et :autocmd BufRead *.info set et -The file pattern {pat} is tested for a match against the file name in one of +The file pattern {aupat} is tested for a match against the file name in one of two ways: 1. When there is no '/' in the pattern, Vim checks for a match against only the tail part of the file name (without its leading directory path). diff --git a/runtime/doc/editing.txt b/runtime/doc/editing.txt index 14df41e6c8..b5a7a193a5 100644 --- a/runtime/doc/editing.txt +++ b/runtime/doc/editing.txt @@ -1331,6 +1331,7 @@ current directory for that window. Windows where the |:lcd| command has not been used stick to the global or tab-local directory. When jumping to another window the current directory is changed to the last specified local current directory. If none was specified, the global or tab-local directory is used. +When creating a new window it inherits the local directory of the current window. When changing tabs the same behaviour applies. If the current tab has no local working directory the global working directory is used. diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt index e2c274e040..d83682b02b 100644 --- a/runtime/doc/map.txt +++ b/runtime/doc/map.txt @@ -244,7 +244,7 @@ go through the main loop (e.g. to update the display), return "\". This is similar to "nothing" but makes Vim return from the loop that waits for input. -Also, keep in mind that the expression may be evaluated when looking for +Keep in mind that the expression may be evaluated when looking for typeahead, before the previous command has been executed. For example: > func StoreColumn() let g:column = col('.') diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt index 05bffc3038..fc0230c62d 100644 --- a/runtime/doc/various.txt +++ b/runtime/doc/various.txt @@ -358,19 +358,19 @@ g8 Print the hex values of the bytes used in the :redi[r] END End redirecting messages. *:filt* *:filter* -:filt[er][!] {pat} {command} -:filt[er][!] /{pat}/ {command} +:filt[er][!] {pattern} {command} +:filt[er][!] /{pattern}/ {command} Restrict the output of {command} to lines matching - with {pat}. For example, to list only xml files: > + with {pattern}. For example, to list only xml files: > :filter /\.xml$/ oldfiles < If the [!] is given, restrict the output of {command} - to lines that do NOT match {pat}. + to lines that do NOT match {pattern}. - {pat} is a Vim search pattern. Instead of enclosing + {pattern} is a Vim search pattern. Instead of enclosing it in / any non-ID character (see |'isident'|) can be - used, so long as it does not appear in {pat}. Without - the enclosing character the pattern cannot include the - bar character. 'ignorecase' is not used. + used, so long as it does not appear in {pattern}. + Without the enclosing character the pattern cannot + include the bar character. 'ignorecase' is not used. The pattern is matched against the relevant part of the output, not necessarily the whole line. Only some diff --git a/runtime/filetype.vim b/runtime/filetype.vim index 900bbf778d..73237437dc 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -1,7 +1,7 @@ " Vim support file to detect file types " " Maintainer: Bram Moolenaar -" Last Change: 2022 Jan 05 +" Last Change: 2022 Jan 13 " Listen very carefully, I will say this only once if exists("did_load_filetypes") diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index c881133b72..829e41001b 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 Dec 16 +" Last Change: 2022 Jan 13 " " WORK IN PROGRESS - Only the basics work " Note: On MS-Windows you need a recent version of gdb. The one included with @@ -1344,6 +1344,15 @@ func s:HandleCursor(msg) if lnum =~ '^[0-9]*$' call s:GotoSourcewinOrCreateIt() if expand('%:p') != fnamemodify(fname, ':p') + augroup Termdebug + " Always open a file read-only instead of showing the ATTENTION + " prompt, since we are unlikely to want to edit the file. + " The file may be changed but not saved, warn for that. + au SwapExists * echohl WarningMsg + \ | echo 'Warning: file is being edited elsewhere' + \ | echohl None + \ | let v:swapchoice = 'o' + augroup END if &modified " TODO: find existing window exe 'split ' . fnameescape(fname) @@ -1352,6 +1361,9 @@ func s:HandleCursor(msg) else exe 'edit ' . fnameescape(fname) endif + augroup Termdebug + au! SwapExists + augroup END endif exe lnum normal! zv diff --git a/runtime/syntax/i3config.vim b/runtime/syntax/i3config.vim index f9e15d57e5..a2f50e50b8 100644 --- a/runtime/syntax/i3config.vim +++ b/runtime/syntax/i3config.vim @@ -3,7 +3,7 @@ " Original Author: Mohamed Boughaba " Maintainer: Quentin Hibon (github user hiqua) " Version: 0.4 -" Last Change: 2022 Jan 04 +" Last Change: 2022 Jan 15 " References: " http://i3wm.org/docs/userguide.html#configuring @@ -175,7 +175,7 @@ syn keyword i3ConfigDrawingMarksKeyword show_marks contained syn match i3ConfigDrawingMarks /^\s*show_marks\s\+\(yes\|no\)\s\?$/ contains=i3ConfigFocusWrappingType,i3ConfigDrawingMarksKeyword " Group mode/bar -syn keyword i3ConfigBlockKeyword mode bar colors i3bar_command status_command position exec mode hidden_state modifier id position output background statusline tray_output tray_padding separator separator_symbol workspace_buttons strip_workspace_numbers binding_mode_indicator focused_workspace active_workspace inactive_workspace urgent_workspace binding_mode contained +syn keyword i3ConfigBlockKeyword mode bar colors i3bar_command status_command position exec mode hidden_state modifier id position output background statusline tray_output tray_padding separator separator_symbol workspace_min_width workspace_buttons strip_workspace_numbers binding_mode_indicator focused_workspace active_workspace inactive_workspace urgent_workspace binding_mode contained syn region i3ConfigBlock start=+.*s\?{$+ end=+^}$+ contains=i3ConfigBlockKeyword,i3ConfigString,i3ConfigBind,i3ConfigComment,i3ConfigFont,i3ConfigFocusWrappingType,i3ConfigColor,i3ConfigVariable transparent keepend extend " Line continuation -- cgit From 9055ec5792d29eb8ad5e5c20708ffcb980ad8609 Mon Sep 17 00:00:00 2001 From: Michael Lingelbach Date: Mon, 17 Jan 2022 08:19:33 -0800 Subject: perf(lsp): request only changed portions of the buffer in changetracking (#17118) This commits introduces two performance improvements in incremental sync: * avoiding expensive lua string reallocations on each on_lines call by requesting only the changed chunk of the buffer as reported by firstline and new_lastline parameters of on_lines * re-using already allocated tables for storing the resulting lines to reduce the load on the garbage collector The majority of the performance improvement is from requesting only changed chunks of the buffer. Benchmark: The following code measures the time required to perform a buffer edit to that operates individually on each line, common to plugins such as vim-commentary. set rtp+=~/.config/nvim/plugged/nvim-lspconfig set rtp+=~/.config/nvim/plugged/vim-commentary lua require('lspconfig')['ccls'].setup({}) function! Benchmark(tries) abort let results_comment = [] let results_undo = [] for i in range(a:tries) echo printf('run %d', i+1) let begin = reltime() normal gggcG call add(results_comment, reltimefloat(reltime(begin))) let begin = reltime() silent! undo call add(results_undo, reltimefloat(reltime(begin))) redraw endfor let avg_comment = 0.0 let avg_undo = 0.0 for i in range(a:tries) echomsg printf('run %3d: comment=%fs undo=%fs', i+1, results_comment[i], results_undo[i]) let avg_comment += results_comment[i] let avg_undo += results_undo[i] endfor echomsg printf('average: comment=%fs undo=%fs', avg_comment / a:tries, avg_undo / a:tries) endfunction command! -bar Benchmark call Benchmark(10) All text changes will be recorded within a single undo operation. Both the comment operation itself and the undo operation will generate an on_lines event for each changed line. Formatter plugins using setline() have also been found to exhibit the same problem (neoformat, :RustFmt in rust.vim), as this function too generates an on_lines event for every line it changes. Using the neovim codebase as an example (commit 2ecf0a4) with neovim itself built at 2ecf0a4 with CMAKE_BUILD_TYPE=Release shows the following performance improvement: src/nvim/lua/executor.c, 1432 lines: - baseline, no optimizations: comment=0.540587s undo=0.440249s - without double-buffering optimization: comment=0.183314s undo=0.060663s - all optimizations in this commit: comment=0.174850s undo=0.052789s src/nvim/search.c, 5467 lines: - baseline, no optimizations: comment=7.420446s undo=7.656624s - without double-buffering optimization: comment=0.889048s undo=0.486026s - all optimizations in this commit: comment=0.662899s undo=0.243628s src/nvim/eval.c, 11355 lines: - baseline, no optimizations: comment=41.775695s undo=44.583374s - without double-buffering optimization: comment=3.643933s undo=2.817158s - all optimizations in this commit: comment=1.510886s undo=0.707928s Co-authored-by: Dmytro Meleshko --- runtime/lua/vim/lsp.lua | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua index 8b7eb4ac90..37e222a5ce 100644 --- a/runtime/lua/vim/lsp.lua +++ b/runtime/lua/vim/lsp.lua @@ -344,6 +344,7 @@ do state.buffers[bufnr] = buf_state if use_incremental_sync then buf_state.lines = nvim_buf_get_lines(bufnr, 0, -1, true) + buf_state.lines_tmp = {} buf_state.pending_changes = {} end end @@ -403,11 +404,40 @@ do ---@private function changetracking.prepare(bufnr, firstline, lastline, new_lastline) local incremental_changes = function(client, buf_state) - local curr_lines = nvim_buf_get_lines(bufnr, 0, -1, true) + + local prev_lines = buf_state.lines + local curr_lines = buf_state.lines_tmp + + local changed_lines = nvim_buf_get_lines(bufnr, firstline, new_lastline, true) + for i = 1, firstline do + curr_lines[i] = prev_lines[i] + end + for i = firstline + 1, new_lastline do + curr_lines[i] = changed_lines[i - firstline] + end + for i = lastline + 1, #prev_lines do + curr_lines[i - lastline + new_lastline] = prev_lines[i] + end + if tbl_isempty(curr_lines) then + -- Can happen when deleting the entire contents of a buffer, see https://github.com/neovim/neovim/issues/16259. + curr_lines[1] = '' + end + local line_ending = buf_get_line_ending(bufnr) local incremental_change = sync.compute_diff( buf_state.lines, curr_lines, firstline, lastline, new_lastline, client.offset_encoding or 'utf-16', line_ending) + + -- Double-buffering of lines tables is used to reduce the load on the garbage collector. + -- At this point the prev_lines table is useless, but its internal storage has already been allocated, + -- so let's keep it around for the next didChange event, in which it will become the next + -- curr_lines table. Note that setting elements to nil doesn't actually deallocate slots in the + -- internal storage - it merely marks them as free, for the GC to deallocate them. + for i in ipairs(prev_lines) do + prev_lines[i] = nil + end buf_state.lines = curr_lines + buf_state.lines_tmp = prev_lines + return incremental_change end local full_changes = once(function() -- cgit From 2c94b75eac07a3b7fc5e1ee536c9f7f0b3fd31f6 Mon Sep 17 00:00:00 2001 From: marvim Date: Mon, 17 Jan 2022 18:28:23 +0000 Subject: docs: regenerate [skip ci] --- runtime/doc/api.txt | 10 +++++++--- runtime/doc/lsp.txt | 45 +++++++++++++++++++++++++-------------------- runtime/doc/lua.txt | 9 +++++++++ runtime/doc/treesitter.txt | 7 ++++--- 4 files changed, 45 insertions(+), 26 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index 0daca0de53..2da1f5e40d 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -709,8 +709,8 @@ nvim_chan_send({chan}, {data}) *nvim_chan_send()* Send data to channel `id` . For a job, it writes it to the stdin of the process. For the stdio channel |channel-stdio|, it writes to Nvim's stdout. For an internal terminal instance - (|nvim_open_term()|) it writes directly to terimal output. See - |channel-bytes| for more information. + (|nvim_open_term()|) it writes directly to terminal output. + See |channel-bytes| for more information. This function writes raw data, not RPC messages. If the channel was created with `rpc=true` then the channel expects @@ -1405,7 +1405,7 @@ nvim_replace_termcodes({str}, {from_part}, {do_lt}, {special}) {from_part} Legacy Vim parameter. Usually true. {do_lt} Also translate . Ignored if `special` is false. - {special} Replace |keycodes|, e.g. becomes a "\n" + {special} Replace |keycodes|, e.g. becomes a "\r" char. See also: ~ @@ -2548,6 +2548,10 @@ nvim_buf_set_extmark({buffer}, {ns_id}, {line}, {col}, {*opts}) • priority: a priority value for the highlight group. For example treesitter highlighting uses a value of 100. + • strict: boolean that indicates extmark should + not be placed if the line or column value is + past the end of the buffer or end of the line + respectively. Defaults to true. Return: ~ Id of the created/updated extmark diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt index bb42a87034..f6fcbe8fb9 100644 --- a/runtime/doc/lsp.txt +++ b/runtime/doc/lsp.txt @@ -749,8 +749,8 @@ omnifunc({findstart}, {base}) *vim.lsp.omnifunc()* set_log_level({level}) *vim.lsp.set_log_level()* Sets the global log level for LSP logging. - Levels by name: "trace", "debug", "info", "warn", "error" - Level numbers begin with "trace" at 0 + Levels by name: "TRACE", "DEBUG", "INFO", "WARN", "ERROR" + Level numbers begin with "TRACE" at 0 Use `lsp.log_levels` for reverse lookup. @@ -887,10 +887,10 @@ start_client({config}) *vim.lsp.start_client()* default true): Allow using incremental sync for buffer edits • debounce_text_changes (number, - default 150): Debounce didChange + default nil): Debounce didChange notifications to the server by the given number in milliseconds. No - debounce occurs if set to 0. + debounce occurs if nil • exit_timeout (number, default 500): Milliseconds to wait for server to exit cleanly after sending the @@ -1008,7 +1008,7 @@ document_highlight() *vim.lsp.buf.document_highlight()* Send request to the server to resolve document highlights for the current text document position. This request can be triggered by a key mapping or by events such as `CursorHold` , - eg: + e.g.: > autocmd CursorHold lua vim.lsp.buf.document_highlight() autocmd CursorHoldI lua vim.lsp.buf.document_highlight() @@ -1024,11 +1024,12 @@ document_symbol() *vim.lsp.buf.document_symbol()* Lists all symbols in the current buffer in the quickfix window. -execute_command({command}) *vim.lsp.buf.execute_command()* +execute_command({command_params}) *vim.lsp.buf.execute_command()* Executes an LSP server command. Parameters: ~ - {command} A valid `ExecuteCommandParams` object + {command_params} table A valid `ExecuteCommandParams` + object See also: ~ https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_executeCommand @@ -1331,7 +1332,7 @@ signature_help({_}, {result}, {ctx}, {config}) Lua module: vim.lsp.util *lsp-util* *vim.lsp.util.apply_text_document_edit()* -apply_text_document_edit({text_document_edit}, {index}) +apply_text_document_edit({text_document_edit}, {index}, {offset_encoding}) Applies a `TextDocumentEdit` , which is a list of changes to a single document. @@ -1351,18 +1352,19 @@ apply_text_edits({text_edits}, {bufnr}, {offset_encoding}) Parameters: ~ {text_edits} table list of `TextEdit` objects {bufnr} number Buffer id - {offset_encoding} string utf-8|utf-16|utf-32|nil defaults - to encoding of first client of `bufnr` + {offset_encoding} string utf-8|utf-16|utf-32 defaults to + encoding of first client of `bufnr` See also: ~ https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textEdit *vim.lsp.util.apply_workspace_edit()* -apply_workspace_edit({workspace_edit}) +apply_workspace_edit({workspace_edit}, {offset_encoding}) Applies a `WorkspaceEdit` . Parameters: ~ - {workspace_edit} (table) `WorkspaceEdit` + {workspace_edit} table `WorkspaceEdit` + {offset_encoding} string utf-8|utf-16|utf-32 (required) buf_clear_references({bufnr}) *vim.lsp.util.buf_clear_references()* Removes document highlights from a buffer. @@ -1379,9 +1381,7 @@ buf_highlight_references({bufnr}, {references}, {offset_encoding}) {references} table List of `DocumentHighlight` objects to highlight {offset_encoding} string One of "utf-8", "utf-16", - "utf-32", or nil. Defaults to - `offset_encoding` of first client of - `bufnr` + "utf-32". See also: ~ https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/#documentHighlight @@ -1470,16 +1470,19 @@ get_effective_tabstop({bufnr}) *vim.lsp.util.get_effective_tabstop()* See also: ~ |softtabstop| -jump_to_location({location}) *vim.lsp.util.jump_to_location()* + *vim.lsp.util.jump_to_location()* +jump_to_location({location}, {offset_encoding}) Jumps to a location. Parameters: ~ - {location} ( `Location` | `LocationLink` ) + {location} table ( `Location` | `LocationLink` ) + {offset_encoding} string utf-8|utf-16|utf-32 (required) Return: ~ `true` if the jump succeeded -locations_to_items({locations}) *vim.lsp.util.locations_to_items()* + *vim.lsp.util.locations_to_items()* +locations_to_items({locations}, {offset_encoding}) Returns the items with the byte position calculated correctly and in sorted order, for display in quickfix and location lists. @@ -1488,8 +1491,10 @@ locations_to_items({locations}) *vim.lsp.util.locations_to_items()* |setqflist()| or |setloclist()|. Parameters: ~ - {locations} (table) list of `Location` s or - `LocationLink` s + {locations} table list of `Location` s or + `LocationLink` s + {offset_encoding} string offset_encoding for locations + utf-8|utf-16|utf-32 Return: ~ (table) list of items diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index 80c1f58323..3d4abed550 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -1872,6 +1872,15 @@ add({filetypes}) *vim.filetype.add()* {filetypes} table A table containing new filetype maps (see example). +match({name}, {bufnr}) *vim.filetype.match()* + Set the filetype for the given buffer from a file name. + + Parameters: ~ + {name} string File name (can be an absolute or relative + path) + {bufnr} number|nil The buffer to set the filetype for. + Defaults to the current buffer. + ============================================================================== Lua module: keymap *lua-keymap* diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt index 7de6a0f890..5829dbdd6b 100644 --- a/runtime/doc/treesitter.txt +++ b/runtime/doc/treesitter.txt @@ -467,8 +467,9 @@ parse_query({lang}, {query}) *parse_query()* • `info.patterns` contains information about predicates. Parameters: ~ - {lang} The language - {query} A string containing the query (s-expr syntax) + {lang} string The language + {query} string A string containing the query (s-expr + syntax) Return: ~ The query @@ -665,7 +666,7 @@ LanguageTree:invalidate({self}, {reload}) *LanguageTree:invalidate()* {self} LanguageTree:is_valid({self}) *LanguageTree:is_valid()* - Determines whether this tree is valid. If the tree is invalid, `parse()` must be called to get the an updated tree. + Determines whether this tree is valid. If the tree is invalid, `parse()` must be called to get the updated tree. Parameters: ~ {self} -- cgit From ad2dbd4b5f2cfa740e373fff0e021e2163909cfb Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 18 Jan 2022 02:45:46 +0800 Subject: fix(man.vim): support calling :Man without a section again (#17119) When `man -w` is called with an empty string as section name, it may fail with an error code, which causes :Man to no longer work without a section. Just remove that argument when no section is specified. --- runtime/autoload/man.vim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/autoload/man.vim b/runtime/autoload/man.vim index a954e1b1a3..b28170b7a1 100644 --- a/runtime/autoload/man.vim +++ b/runtime/autoload/man.vim @@ -232,7 +232,11 @@ function! s:get_path(sect, name) abort " " Finally, we can avoid relying on -S or -s here since they are very " inconsistently supported. Instead, call -w with a section and a name. - let results = split(s:system(['man', s:find_arg, a:sect, a:name])) + if empty(a:sect) + let results = split(s:system(['man', s:find_arg, a:name])) + else + let results = split(s:system(['man', s:find_arg, a:sect, a:name])) + endif if empty(results) return '' -- cgit From fcf5dd34fdfde3a6632b96a88f66c1053cba08d1 Mon Sep 17 00:00:00 2001 From: Gregory Anders <8965202+gpanders@users.noreply.github.com> Date: Mon, 17 Jan 2022 14:11:59 -0700 Subject: refactor: enable filetype detection before user startup scripts (#17040) --- runtime/doc/starting.txt | 20 +++++++++++--------- runtime/doc/vim_diff.txt | 8 ++++++-- 2 files changed, 17 insertions(+), 11 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index bb775ec884..7c4b684ca4 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -409,7 +409,17 @@ accordingly, proceeding as follows: 4. Setup |default-mappings| and |default-autocmds|. -5. Load user config (execute Ex commands from files, environment, …). +5. Enable filetype and indent plugins. + This does the same as the command: > + :filetype plugin indent on +< which in turn is equivalent to: > + :runtime! filetype.lua + :runtime! filetype.vim + :runtime! ftplugin.vim + :runtime! indent.vim +< Skipped if the "-u NONE" command line argument was given. + +6. Load user config (execute Ex commands from files, environment, …). $VIMINIT environment variable is read as one Ex command line (separate multiple commands with '|' or ). *config* *init.vim* *init.lua* *vimrc* *exrc* @@ -453,14 +463,6 @@ accordingly, proceeding as follows: - The file ".nvimrc" - The file ".exrc" -6. Enable filetype and indent plugins. - This does the same as the commands: > - :runtime! filetype.vim - :runtime! ftplugin.vim - :runtime! indent.vim -< Skipped if ":filetype … off" was called or if the "-u NONE" command - line argument was given. - 7. Enable syntax highlighting. This does the same as the command: > :runtime! syntax/syntax.vim diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index 4fcaf15717..32a97779e0 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -23,8 +23,12 @@ centralized reference of the differences. ============================================================================== 2. Defaults *nvim-defaults* -- Syntax highlighting is enabled by default -- ":filetype plugin indent on" is enabled by default +- ":filetype plugin indent on" is enabled by default. This runs before + init.vim is sourced so that FileType autocommands in init.vim run after + those in filetype.vim. +- Syntax highlighting is enabled by default. This runs after init.vim is + sourced so that users can optionally disable syntax highlighting with + ":syntax off". - 'autoindent' is enabled - 'autoread' is enabled -- cgit From de6f9233eee937139f607d3a59fd5b1f479d8a13 Mon Sep 17 00:00:00 2001 From: Gregory Anders <8965202+gpanders@users.noreply.github.com> Date: Tue, 18 Jan 2022 12:46:41 -0700 Subject: refactor: source ftplugin.vim separately from filetype.vim (#17129) This is a follow-on to #17040. The real benefit of #17040 was ensuring that the ftplugin FileType autocommand was defined first and thus always fired first. A side effect of the implementation in #17040 was that setting variables that modified the state of filetype detection (such as g:did_load_filetypes or g:do_filetype_lua) could no longer be set in the user's init file. Filetype detection can also no longer be prevented from loading by using `:filetype off`. This PR addresses both of those side effects by unconditionally sourcing ftplugin.vim and indent.vim before the user's init file (which ensures that these autocommands run first) and sourcing filetype.vim *after* the user's init file (thus allowing it to be blocked or modified). --- runtime/doc/starting.txt | 31 ++++++++++++++++--------------- runtime/doc/vim_diff.txt | 10 ++++------ 2 files changed, 20 insertions(+), 21 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index 7c4b684ca4..8e5b834088 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -411,12 +411,7 @@ accordingly, proceeding as follows: 5. Enable filetype and indent plugins. This does the same as the command: > - :filetype plugin indent on -< which in turn is equivalent to: > - :runtime! filetype.lua - :runtime! filetype.vim - :runtime! ftplugin.vim - :runtime! indent.vim + :runtime! ftplugin.vim indent.vim < Skipped if the "-u NONE" command line argument was given. 6. Load user config (execute Ex commands from files, environment, …). @@ -463,13 +458,19 @@ accordingly, proceeding as follows: - The file ".nvimrc" - The file ".exrc" -7. Enable syntax highlighting. +7. Enable filetype detection. + This does the same as the command: > + :runtime! filetype.lua filetype.vim +< Skipped if ":filetype off" was called or if the "-u NONE" command line + argument was given. + +8. Enable syntax highlighting. This does the same as the command: > :runtime! syntax/syntax.vim < Skipped if ":syntax off" was called or if the "-u NONE" command line argument was given. -8. Load the plugin scripts. *load-plugins* +9. Load the plugin scripts. *load-plugins* This does the same as the command: > :runtime! plugin/**/*.vim :runtime! plugin/**/*.lua @@ -499,21 +500,21 @@ accordingly, proceeding as follows: if packages have been found, but that should not add a directory ending in "after". -9. Set 'shellpipe' and 'shellredir' +10. Set 'shellpipe' and 'shellredir' The 'shellpipe' and 'shellredir' options are set according to the value of the 'shell' option, unless they have been set before. This means that Nvim will figure out the values of 'shellpipe' and 'shellredir' for you, unless you have set them yourself. -10. Set 'updatecount' to zero, if "-n" command argument used +11. Set 'updatecount' to zero, if "-n" command argument used -11. Set binary options if the |-b| flag was given. +12. Set binary options if the |-b| flag was given. -12. Read the |shada-file|. +13. Read the |shada-file|. -13. Read the quickfix file if the |-q| flag was given, or exit on failure. +14. Read the quickfix file if the |-q| flag was given, or exit on failure. -14. Open all windows +15. Open all windows When the |-o| flag was given, windows will be opened (but not displayed yet). When the |-p| flag was given, tab pages will be created (but not @@ -523,7 +524,7 @@ accordingly, proceeding as follows: Buffers for all windows will be loaded, without triggering |BufAdd| autocommands. -15. Execute startup commands +16. Execute startup commands If a |-t| flag was given, the tag is jumped to. Commands given with |-c| and |+cmd| are executed. If the 'insertmode' option is set, Insert mode is entered. diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index 32a97779e0..7e61eac404 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -23,12 +23,10 @@ centralized reference of the differences. ============================================================================== 2. Defaults *nvim-defaults* -- ":filetype plugin indent on" is enabled by default. This runs before - init.vim is sourced so that FileType autocommands in init.vim run after - those in filetype.vim. -- Syntax highlighting is enabled by default. This runs after init.vim is - sourced so that users can optionally disable syntax highlighting with - ":syntax off". +- Filetype detection is enabled by default. This can be disabled by adding + ":filetype off" to |init.vim|. +- Syntax highlighting is enabled by default. This can be disabled by adding + ":syntax off" to |init.vim|. - 'autoindent' is enabled - 'autoread' is enabled -- cgit From aa4eadd2bee7d389edc6284078bb43c700de5b0f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 20 Jan 2022 14:34:24 +0800 Subject: vim-patch:8.2.0128: cannot list options one per line Problem: Cannot list options one per line. Solution: Use ":set!" to list one option per line. https://github.com/vim/vim/commit/6b915c0c0ee7ef82f8d3d310a4345e098cb929b0 --- runtime/doc/options.txt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 06236741c2..dbd012ff9a 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -20,9 +20,13 @@ achieve special effects. These options come in three forms: 1. Setting options *set-option* *E764* *:se* *:set* -:se[t] Show all options that differ from their default value. +:se[t][!] Show all options that differ from their default value. + When [!] is present every option is on a separate + line. -:se[t] all Show all options. +:se[t][!] all Show all options. + When [!] is present every option is on a separate + line. *E518* *E519* :se[t] {option}? Show value of {option}. @@ -235,7 +239,7 @@ happens when the buffer is not loaded, but they are lost when the buffer is wiped out |:bwipe|. *:setl* *:setlocal* -:setl[ocal] ... Like ":set" but set only the value local to the +:setl[ocal][!] ... Like ":set" but set only the value local to the current buffer or window. Not all options have a local value. If the option does not have a local value the global value is set. @@ -257,7 +261,7 @@ wiped out |:bwipe|. {option}, so that the global value will be used. *:setg* *:setglobal* -:setg[lobal] ... Like ":set" but set only the global value for a local +:setg[lobal][!] ... Like ":set" but set only the global value for a local option without changing the local value. When displaying an option, the global value is shown. With the "all" argument: display global values for all -- cgit From 8e702c14ac5fc481bc4a3c709e75e3c165326128 Mon Sep 17 00:00:00 2001 From: Michael Lingelbach Date: Thu, 20 Jan 2022 22:51:34 -0800 Subject: feat(lsp): add handler for workspace/workspaceFolders (#17149) --- runtime/lua/vim/lsp/handlers.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'runtime') diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua index 36ab6d59dd..a997b887d9 100644 --- a/runtime/lua/vim/lsp/handlers.lua +++ b/runtime/lua/vim/lsp/handlers.lua @@ -152,6 +152,17 @@ M['workspace/configuration'] = function(_, result, ctx) return response end +--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_workspaceFolders +M['workspace/workspaceFolders'] = function(_, _, ctx) + local client_id = ctx.client_id + local client = vim.lsp.get_client_by_id(client_id) + if not client then + err_message("LSP[id=", client_id, "] client has shut down after sending the message") + return + end + return client.workspace_folders or vim.NIL +end + M['textDocument/publishDiagnostics'] = function(...) return require('vim.lsp.diagnostic').on_publish_diagnostics(...) end -- cgit From c977d8b43cd6ecf7ad756f9b064eadea79fbd604 Mon Sep 17 00:00:00 2001 From: xnmet <72987524+xnmet@users.noreply.github.com> Date: Fri, 21 Jan 2022 04:40:48 -0300 Subject: docs(lsp): fix on_publish_diagnostics example (#17146) --- runtime/lua/vim/lsp/diagnostic.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/lua/vim/lsp/diagnostic.lua b/runtime/lua/vim/lsp/diagnostic.lua index f38b469f3c..68942ae11a 100644 --- a/runtime/lua/vim/lsp/diagnostic.lua +++ b/runtime/lua/vim/lsp/diagnostic.lua @@ -168,8 +168,8 @@ end --- }, --- -- Use a function to dynamically turn signs off --- -- and on, using buffer local variables ---- signs = function(bufnr, client_id) ---- return vim.bo[bufnr].show_signs == false +--- signs = function(namespace, bufnr) +--- return vim.b[bufnr].show_signs == true --- end, --- -- Disable a feature --- update_in_insert = false, -- cgit From 8300d337c89dc3ef943694bc1d44f32145a74f0d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 21 Jan 2022 18:08:56 +0800 Subject: refactor: remove the key CSI typed directly is now just . The key is obsolete. --- runtime/doc/intro.txt | 1 - 1 file changed, 1 deletion(-) (limited to 'runtime') diff --git a/runtime/doc/intro.txt b/runtime/doc/intro.txt index 0e0156ac6b..54999fa163 100644 --- a/runtime/doc/intro.txt +++ b/runtime/doc/intro.txt @@ -322,7 +322,6 @@ notation meaning equivalent decimal value(s) ~ vertical bar | 124 ** delete 127 command sequence intro ALT-Esc 155 ** - CSI when typed in the GUI ** end-of-line (can be , or , depends on system and 'fileformat') ** -- cgit From 8e84d1b93043f33d997627f99a181159aa66434d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 21 Jan 2022 18:18:18 +0800 Subject: vim-patch:8.2.3584: "verbose set efm" reports location of the :compiler command Problem: "verbose set efm" reports the location of the :compiler command. (Gary Johnson) Solution: Add the "-keepscript" argument to :command and use it when defining CompilerSet. https://github.com/vim/vim/commit/58ef8a31d7087d495ab1582be5b7a22796ac2451 --- runtime/doc/map.txt | 3 +++ 1 file changed, 3 insertions(+) (limited to 'runtime') diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt index d83682b02b..1787fb0fe6 100644 --- a/runtime/doc/map.txt +++ b/runtime/doc/map.txt @@ -1434,6 +1434,9 @@ There are some special cases as well: -register The first argument to the command can be an optional register name (like :del, :put, :yank). -buffer The command will only be available in the current buffer. + -keepscript Do not use the location of where the user command was + defined for verbose messages, use the location of where + the user command was invoked. In the cases of the -count and -register attributes, if the optional argument is supplied, it is removed from the argument list and is available to the -- cgit From 9d02fc4c00f61724610224f91950c51bd2700c97 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Fri, 21 Jan 2022 16:45:32 +0100 Subject: vim-patch:8.2.4172: filetype detection for BASIC is not optimal (#17161) Problem: Filetype detection for BASIC is not optimal. Solution: Improve BASIC filetype detection. (Doug Kearns) https://github.com/vim/vim/commit/6517f14165cdebf83a07ab9d4aeeb102b4e16e92 --- runtime/autoload/dist/ft.vim | 26 +++++++++++++++++++++----- runtime/filetype.vim | 5 +++-- runtime/lua/vim/filetype.lua | 5 +++-- 3 files changed, 27 insertions(+), 9 deletions(-) (limited to 'runtime') diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim index 0d6841a35b..69712046a5 100644 --- a/runtime/autoload/dist/ft.vim +++ b/runtime/autoload/dist/ft.vim @@ -67,13 +67,29 @@ func dist#ft#FTasmsyntax() endif endfunc -" Check if one of the first five lines contains "VB_Name". In that case it is -" probably a Visual Basic file. Otherwise it's assumed to be "alt" filetype. -func dist#ft#FTVB(alt) - if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'VB_Name\|Begin VB\.\(Form\|MDIForm\|UserControl\)' +func dist#ft#FTbas() + if exists("g:filetype_bas") + exe "setf " . g:filetype_bas + return + endif + + " most frequent FreeBASIC-specific keywords in distro files + let fb_keywords = '\c^\s*\%(extern\|var\|enum\|private\|scope\|union\|byref\|operator\|constructor\|delete\|namespace\|public\|property\|with\|destructor\|using\)\>\%(\s*[:=(]\)\@!' + let fb_preproc = '\c^\s*\%(#\a\+\|option\s\+\%(byval\|dynamic\|escape\|\%(no\)\=gosub\|nokeyword\|private\|static\)\>\)' + let fb_comment = "^\\s*/'" + " OPTION EXPLICIT, without the leading underscore, is common to many dialects + let qb64_preproc = '\c^\s*\%($\a\+\|option\s\+\%(_explicit\|_\=explicitarray\)\>\)' + + let lines = getline(1, min([line("$"), 100])) + + if match(lines, fb_preproc) > -1 || match(lines, fb_comment) > -1 || match(lines, fb_keywords) > -1 + setf freebasic + elseif match(lines, qb64_preproc) > -1 + setf qb64 + elseif match(lines, '\cVB_Name\|Begin VB\.\(Form\|MDIForm\|UserControl\)') > -1 setf vb else - exe "setf " . a:alt + setf basic endif endfunc diff --git a/runtime/filetype.vim b/runtime/filetype.vim index 73237437dc..f809a47b3f 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -189,7 +189,8 @@ au BufNewFile,BufRead *.awk,*.gawk setf awk au BufNewFile,BufRead *.mch,*.ref,*.imp setf b " BASIC or Visual Basic -au BufNewFile,BufRead *.bas call dist#ft#FTVB("basic") +au BufNewFile,BufRead *.bas call dist#ft#FTbas() +au BufNewFile,BufRead *.bi,*.bm call dist#ft#FTbas() " Visual Basic Script (close to Visual Basic) or Visual Basic .NET au BufNewFile,BufRead *.vb,*.vbs,*.dsm,*.ctl setf vb @@ -198,7 +199,7 @@ au BufNewFile,BufRead *.vb,*.vbs,*.dsm,*.ctl setf vb au BufNewFile,BufRead *.iba,*.ibi setf ibasic " FreeBasic file (similar to QBasic) -au BufNewFile,BufRead *.fb,*.bi setf freebasic +au BufNewFile,BufRead *.fb setf freebasic " Batch file for MSDOS. au BufNewFile,BufRead *.bat,*.sys setf dosbatch diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index 819587bb3e..c7e18bf186 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -220,7 +220,6 @@ local extension = { ["f08"] = "fortran", fpc = "fpcmake", fsl = "framescript", - bi = "freebasic", fb = "freebasic", fsi = "fsharp", fsx = "fsharp", @@ -738,7 +737,9 @@ local extension = { PL = function() vim.fn["dist#ft#FTpl"]() end, R = function() vim.fn["dist#ft#FTr"]() end, asm = function() vim.fn["dist#ft#FTasm"]() end, - bas = function() vim.fn["dist#ft#FTVB"]("basic") end, + bas = function() vim.fn["dist#ft#FTbas"]() end, + bi = function() vim.fn["dist#ft#FTbas"]() end, + bm = function() vim.fn["dist#ft#FTbas"]() end, bash = function() vim.fn["dist#ft#SetFileTypeSH"]("bash") end, btm = function() vim.fn["dist#ft#FTbtm"]() end, c = function() vim.fn["dist#ft#FTlpc"]() end, -- cgit From d7ab4e819a89c12b74772217e725c640858a18c6 Mon Sep 17 00:00:00 2001 From: Shougo Matsushita Date: Fri, 21 Jan 2022 09:36:26 +0900 Subject: vim-patch:8.2.4160: cannot change the register used for Select mode delete Problem: Cannot change the register used for Select mode delete. Solution: Make CTRL-R set the register to be used when deleting text for Select mode. (Shougo Matsushita, closes vim/vim#9531) https://github.com/vim/vim/commit/4ede01f18884961f2e008880b4964e5d61ea5c36 --- runtime/doc/visual.txt | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'runtime') diff --git a/runtime/doc/visual.txt b/runtime/doc/visual.txt index 4a69fc989b..5563a56216 100644 --- a/runtime/doc/visual.txt +++ b/runtime/doc/visual.txt @@ -478,6 +478,10 @@ Commands in Select mode: - ESC stops Select mode. - CTRL-O switches to Visual mode for the duration of one command. *v_CTRL-O* - CTRL-G switches to Visual mode. +- CTRL-R {register} selects the register to be used for the text that is + deleted when typing text. *v_CTRL-R* + Unless you specify the "_" (black hole) register, the unnamed register is + also overwritten. Otherwise, typed characters are handled as in Visual mode. -- cgit From 3d62dd207733bbdc46fd5b6807e5d7dcf95681e2 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sun, 23 Jan 2022 13:52:37 +0100 Subject: vim-patch:8.2.4187: gnuplot file not recognized (#17177) Problem: Gnuplot file not recognized. Solution: Recognize ".gnuplot". (closes vim/vim#9588) https://github.com/vim/vim/commit/ff5cbe8133c6eb5dd86b9e042f32f589627e9bf9 --- runtime/filetype.vim | 2 +- runtime/lua/vim/filetype.lua | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/filetype.vim b/runtime/filetype.vim index f809a47b3f..803de5e0c7 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -710,7 +710,7 @@ au BufNewFile,BufRead gitolite.conf setf gitolite au BufNewFile,BufRead {,.}gitolite.rc,example.gitolite.rc setf perl " Gnuplot scripts -au BufNewFile,BufRead *.gpi setf gnuplot +au BufNewFile,BufRead *.gpi,.gnuplot setf gnuplot " Go (Google) au BufNewFile,BufRead *.go setf go diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index c7e18bf186..e5168403b2 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -230,6 +230,7 @@ local extension = { gemini = "gemtext", gift = "gift", gpi = "gnuplot", + gnuplot = "gnuplot", go = "go", gp = "gp", gs = "grads", -- cgit From ffd9551aa210ecd652044ad3c43eb480858f191a Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Sun, 23 Jan 2022 16:19:48 +0100 Subject: vim-patch:8.2.4191: json5 files are not recognized (#17180) Problem: json5 files are not recognized. Solution: Add a pattern for json5 files. (closes vim/vim#9601) https://github.com/vim/vim/commit/e15ebeffb35da4bb7d9054358671735ce6988c28 --- runtime/filetype.vim | 3 +++ runtime/lua/vim/filetype.lua | 1 + 2 files changed, 4 insertions(+) (limited to 'runtime') diff --git a/runtime/filetype.vim b/runtime/filetype.vim index 803de5e0c7..cd80f9786c 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -882,6 +882,9 @@ au BufNewFile,BufRead *.jov,*.j73,*.jovial setf jovial " JSON au BufNewFile,BufRead *.json,*.jsonp,*.webmanifest setf json +" JSON5 +au BufNewFile,BufRead *.json5 setf json5 + " JSON Patch (RFC 6902) au BufNewFile,BufRead *.json-patch setf json diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index e5168403b2..060022bce1 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -293,6 +293,7 @@ local extension = { webmanifest = "json", ipynb = "json", ["json-patch"] = "json", + json5 = "json5", jsonc = "jsonc", jsp = "jsp", jl = "julia", -- cgit From 28352dc6e50b9559f32f054c56dc950a79ae45bc Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sun, 23 Jan 2022 17:50:45 +0100 Subject: vim-patch:8.2.4188: not all gitconfig files are recognized (#17178) Problem: Not all gitconfig files are recognized. Solution: Add a few more patterns. (Tim Pope, closes vim/vim#9597) https://github.com/vim/vim/commit/bcfa11b7dfdfbb4d412dd843a6da3fce68ba2e39 --- runtime/filetype.vim | 4 +++- runtime/lua/vim/filetype.lua | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'runtime') diff --git a/runtime/filetype.vim b/runtime/filetype.vim index cd80f9786c..5f96e30aa6 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -674,8 +674,10 @@ autocmd BufRead,BufNewFile *.gift setf gift " Git au BufNewFile,BufRead COMMIT_EDITMSG,MERGE_MSG,TAG_EDITMSG setf gitcommit au BufNewFile,BufRead NOTES_EDITMSG,EDIT_DESCRIPTION setf gitcommit -au BufNewFile,BufRead *.git/config,.gitconfig,/etc/gitconfig setf gitconfig +au BufNewFile,BufRead *.git/config,.gitconfig,*/etc/gitconfig setf gitconfig au BufNewFile,BufRead */.config/git/config setf gitconfig +au BufNewFile,BufRead *.git/config.worktree setf gitconfig +au BufNewFile,BufRead *.git/worktrees/*/config.worktree setf gitconfig au BufNewFile,BufRead .gitmodules,*.git/modules/*/config setf gitconfig if !empty($XDG_CONFIG_HOME) au BufNewFile,BufRead $XDG_CONFIG_HOME/git/config setf gitconfig diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index 060022bce1..736ecc1ff7 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -893,8 +893,6 @@ local filename = { ["EDIT_DESCRIPTION"] = "gitcommit", [".gitconfig"] = "gitconfig", [".gitmodules"] = "gitconfig", - ["/.config/git/config"] = "gitconfig", - ["/etc/gitconfig"] = "gitconfig", ["gitolite.conf"] = "gitolite", ["git-rebase-todo"] = "gitrebase", gkrellmrc = "gkrellmrc", @@ -1149,7 +1147,10 @@ local pattern = { [".*Eterm/.*%.cfg"] = "eterm", [".*%.git/modules/.*/config"] = "gitconfig", [".*%.git/config"] = "gitconfig", + [".*/etc/gitconfig"] = "gitconfig", [".*/%.config/git/config"] = "gitconfig", + [".*%.git/config%.worktree"] = "gitconfig", + [".*%.git/worktrees/.*/config%.worktree"] = "gitconfig", ["%.gitsendemail%.msg%......."] = "gitsendemail", ["gkrellmrc_."] = "gkrellmrc", [".*/usr/.*/gnupg/options%.skel"] = "gpg", -- cgit From 4ba7fa1700ead8a53d73fea7fc17a545f9b4588d Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sun, 23 Jan 2022 18:38:41 +0100 Subject: vim-patch:6f4754b9f725 (#17179) Update runtime files https://github.com/vim/vim/commit/6f4754b9f7253d7e4ba527064a24aff1acdb1e8f --- runtime/doc/diff.txt | 7 +- runtime/doc/editing.txt | 2 +- runtime/doc/filetype.txt | 7 +- runtime/doc/fold.txt | 4 +- runtime/doc/map.txt | 4 +- runtime/doc/nvim_terminal_emulator.txt | 5 +- runtime/doc/starting.txt | 2 +- runtime/doc/syntax.txt | 6 +- runtime/filetype.vim | 2 +- .../pack/dist/opt/termdebug/plugin/termdebug.vim | 3 +- runtime/syntax/rc.vim | 21 ++-- runtime/syntax/scala.vim | 110 ++++++++++----------- 12 files changed, 92 insertions(+), 81 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/diff.txt b/runtime/doc/diff.txt index 6115a5d235..abe99102ee 100644 --- a/runtime/doc/diff.txt +++ b/runtime/doc/diff.txt @@ -324,8 +324,9 @@ After setting this variable, reload the syntax script: > FINDING THE DIFFERENCES *diff-diffexpr* -The 'diffexpr' option can be set to use something else than the standard -"diff" program to compare two files and find the differences. *E959* +The 'diffexpr' option can be set to use something else than the internal diff +support or the standard "diff" program to compare two files and find the +differences. When 'diffexpr' is empty, Vim uses this command to find the differences between file1 and file2: > @@ -358,7 +359,7 @@ format mentioned. These variables are set to the file names used: v:fname_in original file v:fname_new new version of the same file - v:fname_out resulting diff file + v:fname_out where to write the resulting diff file Additionally, 'diffexpr' should take care of "icase" and "iwhite" in the 'diffopt' option. 'diffexpr' cannot change the value of 'lines' and diff --git a/runtime/doc/editing.txt b/runtime/doc/editing.txt index b5a7a193a5..44987f3b7b 100644 --- a/runtime/doc/editing.txt +++ b/runtime/doc/editing.txt @@ -845,7 +845,7 @@ Note: When the 'write' option is off, you are not able to write any file. *:w* *:write* *E502* *E503* *E504* *E505* - *E512* *E514* *E667* *E796* *E949* + *E512* *E514* *E667* *E949* :w[rite] [++opt] Write the whole buffer to the current file. This is the normal way to save changes to a file. It fails when the 'readonly' option is set or when there is diff --git a/runtime/doc/filetype.txt b/runtime/doc/filetype.txt index fdd9c8c12e..5486c87af9 100644 --- a/runtime/doc/filetype.txt +++ b/runtime/doc/filetype.txt @@ -131,14 +131,15 @@ shell script: "#!/bin/csh". argument was used. *filetype-overrule* -When the same extension is used for two filetypes, Vim tries to guess what -kind of file it is. This doesn't always work. A number of global variables -can be used to overrule the filetype used for certain extensions: +When the same extension is used for multiple filetypes, Vim tries to guess +what kind of file it is. This doesn't always work. A number of global +variables can be used to overrule the filetype used for certain extensions: file name variable ~ *.asa g:filetype_asa |ft-aspvbs-syntax| |ft-aspperl-syntax| *.asm g:asmsyntax |ft-asm-syntax| *.asp g:filetype_asp |ft-aspvbs-syntax| |ft-aspperl-syntax| + *.bas g:filetype_bas |ft-basic-syntax| *.fs g:filetype_fs |ft-forth-syntax| *.i g:filetype_i |ft-progress-syntax| *.inc g:filetype_inc diff --git a/runtime/doc/fold.txt b/runtime/doc/fold.txt index 80c934d13b..8bc47a3b10 100644 --- a/runtime/doc/fold.txt +++ b/runtime/doc/fold.txt @@ -501,7 +501,9 @@ Note the use of backslashes to avoid some characters to be interpreted by the :endfunction Evaluating 'foldtext' is done in the |sandbox|. The current window is set to -the window that displays the line. Errors are ignored. +the window that displays the line. + +Errors are ignored. For debugging set the 'debug' option to "throw". The default value is |foldtext()|. This returns a reasonable text for most types of folding. If you don't like it, you can specify your own 'foldtext' diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt index d83682b02b..248a5c1ec2 100644 --- a/runtime/doc/map.txt +++ b/runtime/doc/map.txt @@ -1217,7 +1217,7 @@ scripts. *:command-verbose* When 'verbose' is non-zero, listing a command will also display where it was -last defined. Example: > +last defined and any completion argument. Example: > :verbose command TOhtml < Name Args Range Complete Definition ~ @@ -1332,6 +1332,8 @@ completion can be enabled: -complete=custom,{func} custom completion, defined via {func} -complete=customlist,{func} custom completion, defined via {func} +If you specify completion while there is nothing to complete (-nargs=0, the +default) then you get error *E1208* . Note: That some completion methods might expand environment variables. diff --git a/runtime/doc/nvim_terminal_emulator.txt b/runtime/doc/nvim_terminal_emulator.txt index bfacbe19f5..f322764ecf 100644 --- a/runtime/doc/nvim_terminal_emulator.txt +++ b/runtime/doc/nvim_terminal_emulator.txt @@ -162,12 +162,11 @@ command name, for example: > This opens two windows: gdb window A terminal window in which "gdb vim" is executed. Here you - can directly interact with gdb. The buffer name is "!gdb". + can directly interact with gdb. program window A terminal window for the executed program. When "run" is used in gdb the program I/O will happen in this window, so - that it does not interfere with controlling gdb. The buffer - name is "gdb program". + that it does not interfere with controlling gdb. The current window is used to show the source code. When gdb pauses the source file location will be displayed, if possible. A sign is used to diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index 8e5b834088..978142a1e0 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -188,7 +188,7 @@ argument. changes and writing. -e *-e* *-E* --E Start Nvim in Ex mode |gQ|. +-E Start Nvim in Ex mode |gQ|, see |Ex-mode|. If stdin is not a TTY: -e reads/executes stdin as Ex commands. diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt index 2c5531411d..be1586ab41 100644 --- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -920,12 +920,16 @@ in .../after/syntax/baan.vim (see |after-directory|). Eg: > BASIC *basic.vim* *vb.vim* *ft-basic-syntax* *ft-vb-syntax* -Both Visual Basic and "normal" basic use the extension ".bas". To detect +Both Visual Basic and "normal" BASIC use the extension ".bas". To detect which one should be used, Vim checks for the string "VB_Name" in the first five lines of the file. If it is not found, filetype will be "basic", otherwise "vb". Files with the ".frm" extension will always be seen as Visual Basic. +If the automatic detection doesn't work for you or you only edit, for +example, FreeBASIC files, use this in your startup vimrc: > + :let filetype_bas = "freebasic" + C *c.vim* *ft-c-syntax* diff --git a/runtime/filetype.vim b/runtime/filetype.vim index 5f96e30aa6..f58658a73b 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -1,7 +1,7 @@ " Vim support file to detect file types " " Maintainer: Bram Moolenaar -" Last Change: 2022 Jan 13 +" Last Change: 2022 Jan 23 " Listen very carefully, I will say this only once if exists("did_load_filetypes") diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index 829e41001b..49d9389773 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: 2022 Jan 13 +" Last Change: 2022 Jan 17 " " WORK IN PROGRESS - Only the basics work " Note: On MS-Windows you need a recent version of gdb. The one included with @@ -1344,6 +1344,7 @@ func s:HandleCursor(msg) if lnum =~ '^[0-9]*$' call s:GotoSourcewinOrCreateIt() if expand('%:p') != fnamemodify(fname, ':p') + echomsg 'different fname: "' .. expand('%:p') .. '" vs "' .. fnamemodify(fname, ':p') .. '"' augroup Termdebug " Always open a file read-only instead of showing the ATTENTION " prompt, since we are unlikely to want to edit the file. diff --git a/runtime/syntax/rc.vim b/runtime/syntax/rc.vim index 4c6856bc83..d69edd00fd 100644 --- a/runtime/syntax/rc.vim +++ b/runtime/syntax/rc.vim @@ -1,7 +1,7 @@ " Vim syntax file " Language: M$ Resource files (*.rc) " Maintainer: Christian Brabandt -" Last Change: 2015-05-29 +" Last Change: 20220116 " Repository: https://github.com/chrisbra/vim-rc-syntax " License: Vim (see :h license) " Previous Maintainer: Heiko Erhardt @@ -173,16 +173,17 @@ hi def link rcAttribute rcCommonAttribute hi def link rcStdId rcStatement hi def link rcStatement Statement -" Default color overrides -hi def rcLanguage term=reverse ctermbg=Red ctermfg=Yellow guibg=Red guifg=Yellow -hi def rcMainObject term=underline ctermfg=Blue guifg=Blue -hi def rcSubObject ctermfg=Green guifg=Green -hi def rcCaptionParam term=underline ctermfg=DarkGreen guifg=Green -hi def rcParam ctermfg=DarkGreen guifg=DarkGreen -hi def rcStatement ctermfg=DarkGreen guifg=DarkGreen -hi def rcCommonAttribute ctermfg=Brown guifg=Brown +hi def link rcLanguage Constant +hi def link rcCaptionParam Constant +hi def link rcCommonAttribute Constant + +hi def link rcMainObject Identifier +hi def link rcSubObject Define +hi def link rcParam Constant +hi def link rcStatement Statement +" +"hi def link rcIdentifier Identifier -"hi def link rcIdentifier Identifier let b:current_syntax = "rc" diff --git a/runtime/syntax/scala.vim b/runtime/syntax/scala.vim index 16e114778d..c08e60e55a 100644 --- a/runtime/syntax/scala.vim +++ b/runtime/syntax/scala.vim @@ -3,7 +3,7 @@ " Maintainer: Derek Wyatt " URL: https://github.com/derekwyatt/vim-scala " License: Same as Vim -" Last Change: 23 August 2021 +" Last Change: 23 January 2022 " ---------------------------------------------------------------------------- if !exists('main_syntax') @@ -43,55 +43,55 @@ syn keyword scalaKeyword class trait object extends with nextgroup=scalaInstance syn keyword scalaKeyword case nextgroup=scalaKeyword,scalaCaseFollowing skipwhite syn keyword scalaKeyword val nextgroup=scalaNameDefinition,scalaQuasiQuotes skipwhite syn keyword scalaKeyword def var nextgroup=scalaNameDefinition skipwhite -hi link scalaKeyword Keyword +hi def link scalaKeyword Keyword exe 'syn region scalaBlock start=/{/ end=/}/ contains=' . s:ContainedGroup() . ' fold' syn keyword scalaAkkaSpecialWord when goto using startWith initialize onTransition stay become unbecome -hi link scalaAkkaSpecialWord PreProc +hi def link scalaAkkaSpecialWord PreProc syn keyword scalatestSpecialWord shouldBe syn match scalatestShouldDSLA /^\s\+\zsit should/ syn match scalatestShouldDSLB /\/ -hi link scalatestSpecialWord PreProc -hi link scalatestShouldDSLA PreProc -hi link scalatestShouldDSLB PreProc +hi def link scalatestSpecialWord PreProc +hi def link scalatestShouldDSLA PreProc +hi def link scalatestShouldDSLB PreProc syn match scalaSymbol /'[_A-Za-z0-9$]\+/ -hi link scalaSymbol Number +hi def link scalaSymbol Number syn match scalaChar /'.'/ syn match scalaChar /'\\[\\"'ntbrf]'/ contains=scalaEscapedChar syn match scalaChar /'\\u[A-Fa-f0-9]\{4}'/ contains=scalaUnicodeChar syn match scalaEscapedChar /\\[\\"'ntbrf]/ syn match scalaUnicodeChar /\\u[A-Fa-f0-9]\{4}/ -hi link scalaChar Character -hi link scalaEscapedChar Special -hi link scalaUnicodeChar Special +hi def link scalaChar Character +hi def link scalaEscapedChar Special +hi def link scalaUnicodeChar Special syn match scalaOperator "||" syn match scalaOperator "&&" syn match scalaOperator "|" syn match scalaOperator "&" -hi link scalaOperator Special +hi def link scalaOperator Special syn match scalaNameDefinition /\<[_A-Za-z0-9$]\+\>/ contained nextgroup=scalaPostNameDefinition,scalaVariableDeclarationList syn match scalaNameDefinition /`[^`]\+`/ contained nextgroup=scalaPostNameDefinition syn match scalaVariableDeclarationList /\s*,\s*/ contained nextgroup=scalaNameDefinition syn match scalaPostNameDefinition /\_s*:\_s*/ contained nextgroup=scalaTypeDeclaration -hi link scalaNameDefinition Function +hi def link scalaNameDefinition Function syn match scalaInstanceDeclaration /\<[_\.A-Za-z0-9$]\+\>/ contained nextgroup=scalaInstanceHash syn match scalaInstanceDeclaration /`[^`]\+`/ contained syn match scalaInstanceHash /#/ contained nextgroup=scalaInstanceDeclaration -hi link scalaInstanceDeclaration Special -hi link scalaInstanceHash Type +hi def link scalaInstanceDeclaration Special +hi def link scalaInstanceHash Type syn match scalaUnimplemented /???/ -hi link scalaUnimplemented ERROR +hi def link scalaUnimplemented ERROR syn match scalaCapitalWord /\<[A-Z][A-Za-z0-9$]*\>/ -hi link scalaCapitalWord Special +hi def link scalaCapitalWord Special " Handle type declarations specially syn region scalaTypeStatement matchgroup=Keyword start=/\]/ contained nextgroup=scalaTypeTypePostDe syn match scalaTypeTypeExtension /)\?\_s*\zs\%(⇒\|=>\|<:\|:>\|=:=\|::\|#\)/ contained contains=scalaTypeOperator nextgroup=scalaTypeTypeDeclaration skipwhite syn match scalaTypeTypePostDeclaration /\<[_\.A-Za-z0-9$]\+\>/ contained nextgroup=scalaTypeTypePostExtension skipwhite syn match scalaTypeTypePostExtension /\%(⇒\|=>\|<:\|:>\|=:=\|::\)/ contained contains=scalaTypeOperator nextgroup=scalaTypeTypePostDeclaration skipwhite -hi link scalaTypeTypeDeclaration Type -hi link scalaTypeTypeExtension Keyword -hi link scalaTypeTypePostDeclaration Special -hi link scalaTypeTypePostExtension Keyword +hi def link scalaTypeTypeDeclaration Type +hi def link scalaTypeTypeExtension Keyword +hi def link scalaTypeTypePostDeclaration Special +hi def link scalaTypeTypePostExtension Keyword syn match scalaTypeDeclaration /(/ contained nextgroup=scalaTypeExtension contains=scalaRoundBrackets skipwhite syn match scalaTypeDeclaration /\%(⇒\|=>\)\ze/ contained nextgroup=scalaTypeDeclaration contains=scalaTypeExtension skipwhite syn match scalaTypeDeclaration /\<[_\.A-Za-z0-9$]\+\>/ contained nextgroup=scalaTypeExtension skipwhite syn match scalaTypeExtension /)\?\_s*\zs\%(⇒\|=>\|<:\|:>\|=:=\|::\|#\)/ contained contains=scalaTypeOperator nextgroup=scalaTypeDeclaration skipwhite -hi link scalaTypeDeclaration Type -hi link scalaTypeExtension Keyword -hi link scalaTypePostExtension Keyword +hi def link scalaTypeDeclaration Type +hi def link scalaTypeExtension Keyword +hi def link scalaTypePostExtension Keyword syn match scalaTypeAnnotation /\%([_a-zA-Z0-9$\s]:\_s*\)\ze[_=(\.A-Za-z0-9$]\+/ skipwhite nextgroup=scalaTypeDeclaration contains=scalaRoundBrackets syn match scalaTypeAnnotation /)\_s*:\_s*\ze[_=(\.A-Za-z0-9$]\+/ skipwhite nextgroup=scalaTypeDeclaration @@ -124,51 +124,51 @@ hi clear scalaTypeAnnotation syn match scalaCaseFollowing /\<[_\.A-Za-z0-9$]\+\>/ contained contains=scalaCapitalWord syn match scalaCaseFollowing /`[^`]\+`/ contained contains=scalaCapitalWord -hi link scalaCaseFollowing Special +hi def link scalaCaseFollowing Special syn keyword scalaKeywordModifier abstract override final lazy implicit private protected sealed null super syn keyword scalaSpecialFunction implicitly require -hi link scalaKeywordModifier Function -hi link scalaSpecialFunction Function +hi def link scalaKeywordModifier Function +hi def link scalaSpecialFunction Function syn keyword scalaSpecial this true false ne eq syn keyword scalaSpecial new nextgroup=scalaInstanceDeclaration skipwhite syn match scalaSpecial "\%(=>\|⇒\|<-\|←\|->\|→\)" syn match scalaSpecial /`[^`]\+`/ " Backtick literals -hi link scalaSpecial PreProc +hi def link scalaSpecial PreProc syn keyword scalaExternal package import -hi link scalaExternal Include +hi def link scalaExternal Include syn match scalaStringEmbeddedQuote /\\"/ contained syn region scalaString start=/"/ end=/"/ contains=scalaStringEmbeddedQuote,scalaEscapedChar,scalaUnicodeChar -hi link scalaString String -hi link scalaStringEmbeddedQuote String +hi def link scalaString String +hi def link scalaStringEmbeddedQuote String syn region scalaIString matchgroup=scalaInterpolationBrackets start=/\<[a-zA-Z][a-zA-Z0-9_]*"/ skip=/\\"/ end=/"/ contains=scalaInterpolation,scalaInterpolationB,scalaEscapedChar,scalaUnicodeChar syn region scalaTripleIString matchgroup=scalaInterpolationBrackets start=/\<[a-zA-Z][a-zA-Z0-9_]*"""/ end=/"""\ze\%([^"]\|$\)/ contains=scalaInterpolation,scalaInterpolationB,scalaEscapedChar,scalaUnicodeChar -hi link scalaIString String -hi link scalaTripleIString String +hi def link scalaIString String +hi def link scalaTripleIString String syn match scalaInterpolation /\$[a-zA-Z0-9_$]\+/ contained exe 'syn region scalaInterpolationB matchgroup=scalaInterpolationBoundary start=/\${/ end=/}/ contained contains=' . s:ContainedGroup() -hi link scalaInterpolation Function +hi def link scalaInterpolation Function hi clear scalaInterpolationB syn region scalaFString matchgroup=scalaInterpolationBrackets start=/f"/ skip=/\\"/ end=/"/ contains=scalaFInterpolation,scalaFInterpolationB,scalaEscapedChar,scalaUnicodeChar syn match scalaFInterpolation /\$[a-zA-Z0-9_$]\+\(%[-A-Za-z0-9\.]\+\)\?/ contained exe 'syn region scalaFInterpolationB matchgroup=scalaInterpolationBoundary start=/${/ end=/}\(%[-A-Za-z0-9\.]\+\)\?/ contained contains=' . s:ContainedGroup() -hi link scalaFString String -hi link scalaFInterpolation Function +hi def link scalaFString String +hi def link scalaFInterpolation Function hi clear scalaFInterpolationB syn region scalaTripleString start=/"""/ end=/"""\%([^"]\|$\)/ contains=scalaEscapedChar,scalaUnicodeChar syn region scalaTripleFString matchgroup=scalaInterpolationBrackets start=/f"""/ end=/"""\%([^"]\|$\)/ contains=scalaFInterpolation,scalaFInterpolationB,scalaEscapedChar,scalaUnicodeChar -hi link scalaTripleString String -hi link scalaTripleFString String +hi def link scalaTripleString String +hi def link scalaTripleFString String -hi link scalaInterpolationBrackets Special -hi link scalaInterpolationBoundary Function +hi def link scalaInterpolationBrackets Special +hi def link scalaInterpolationBoundary Function syn match scalaNumber /\<0[dDfFlL]\?\>/ " Just a bare 0 syn match scalaNumber /\<[1-9]\d*[dDfFlL]\?\>/ " A multi-digit number - octal numbers with leading 0's are deprecated in Scala @@ -176,16 +176,16 @@ syn match scalaNumber /\<0[xX][0-9a-fA-F]\+[dDfFlL]\?\>/ " Hex number syn match scalaNumber /\%(\<\d\+\.\d*\|\.\d\+\)\%([eE][-+]\=\d\+\)\=[fFdD]\=/ " exponential notation 1 syn match scalaNumber /\<\d\+[eE][-+]\=\d\+[fFdD]\=\>/ " exponential notation 2 syn match scalaNumber /\<\d\+\%([eE][-+]\=\d\+\)\=[fFdD]\>/ " exponential notation 3 -hi link scalaNumber Number +hi def link scalaNumber Number syn region scalaRoundBrackets start="(" end=")" skipwhite contained contains=scalaTypeDeclaration,scalaSquareBrackets,scalaRoundBrackets syn region scalaSquareBrackets matchgroup=scalaSquareBracketsBrackets start="\[" end="\]" skipwhite nextgroup=scalaTypeExtension contains=scalaTypeDeclaration,scalaSquareBrackets,scalaTypeOperator,scalaTypeAnnotationParameter syn match scalaTypeOperator /[-+=:<>]\+/ contained syn match scalaTypeAnnotationParameter /@\<[`_A-Za-z0-9$]\+\>/ contained -hi link scalaSquareBracketsBrackets Type -hi link scalaTypeOperator Keyword -hi link scalaTypeAnnotationParameter Function +hi def link scalaSquareBracketsBrackets Type +hi def link scalaTypeOperator Keyword +hi def link scalaTypeAnnotationParameter Function syn match scalaShebang "\%^#!.*" display syn region scalaMultilineComment start="/\*" end="\*/" contains=scalaMultilineComment,scalaDocLinks,scalaParameterAnnotation,scalaCommentAnnotation,scalaTodo,scalaCommentCodeBlock,@Spell keepend fold @@ -195,20 +195,20 @@ syn match scalaParamAnnotationValue /[.`_A-Za-z0-9$]\+/ contained syn region scalaDocLinks start="\[\[" end="\]\]" contained syn region scalaCommentCodeBlock matchgroup=Keyword start="{{{" end="}}}" contained syn match scalaTodo "\vTODO|FIXME|XXX" contained -hi link scalaShebang Comment -hi link scalaMultilineComment Comment -hi link scalaDocLinks Function -hi link scalaParameterAnnotation Function -hi link scalaParamAnnotationValue Keyword -hi link scalaCommentAnnotation Function -hi link scalaCommentCodeBlock String -hi link scalaTodo Todo +hi def link scalaShebang Comment +hi def link scalaMultilineComment Comment +hi def link scalaDocLinks Function +hi def link scalaParameterAnnotation Function +hi def link scalaParamAnnotationValue Keyword +hi def link scalaCommentAnnotation Function +hi def link scalaCommentCodeBlock String +hi def link scalaTodo Todo syn match scalaAnnotation /@\<[`_A-Za-z0-9$]\+\>/ -hi link scalaAnnotation PreProc +hi def link scalaAnnotation PreProc syn match scalaTrailingComment "//.*$" contains=scalaTodo,@Spell -hi link scalaTrailingComment Comment +hi def link scalaTrailingComment Comment syn match scalaAkkaFSM /goto([^)]*)\_s\+\/ contains=scalaAkkaFSMGotoUsing syn match scalaAkkaFSM /stay\_s\+using/ @@ -221,8 +221,8 @@ syn match scalaAkkaFSM /onTermination/ syn match scalaAkkaFSM /whenUnhandled/ syn match scalaAkkaFSMGotoUsing /\/ syn match scalaAkkaFSMGotoUsing /\/ -hi link scalaAkkaFSM PreProc -hi link scalaAkkaFSMGotoUsing PreProc +hi def link scalaAkkaFSM PreProc +hi def link scalaAkkaFSMGotoUsing PreProc let b:current_syntax = 'scala' -- cgit From ecec957125ca95ef5fbc4534d62ed16cfedb0c44 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Tue, 25 Jan 2022 08:22:15 +0100 Subject: vim-patch:8.2.4196: various file types not recognized (#17182) Problem: Various file types not recognized. Solution: Add patterns to recognize more file types (closes vim/vim#9607) https://github.com/vim/vim/commit/428058ab3213e81531cbd7989f4267870f35d52e --- runtime/filetype.vim | 61 ++++++++++++++++++++++++++++++++++++++++++++ runtime/lua/vim/filetype.lua | 28 ++++++++++++++++++++ 2 files changed, 89 insertions(+) (limited to 'runtime') diff --git a/runtime/filetype.vim b/runtime/filetype.vim index f58658a73b..2a0a5110f2 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -650,6 +650,9 @@ au BufNewFile,BufRead *.fsl setf framescript " FStab au BufNewFile,BufRead fstab,mtab setf fstab +" Fusion +au BufRead,BufNewFile *.fusion setf fusion + " F# or Forth au BufNewFile,BufRead *.fs call dist#ft#FTfs() @@ -662,6 +665,12 @@ au BufNewFile,BufRead .gdbinit,gdbinit setf gdb " GDMO au BufNewFile,BufRead *.mo,*.gdmo setf gdmo +" GDscript +au BufNewFile,BufRead *.gd setf gdscript + +" Godot resource +au BufRead,BufNewFile *.tscn,*.tres setf gdresource + " Gedcom au BufNewFile,BufRead *.ged,lltxxxxx.txt setf gedcom @@ -692,6 +701,9 @@ au BufNewFile,BufRead *.git/* " Gkrellmrc au BufNewFile,BufRead gkrellmrc,gkrellmrc_? setf gkrellmrc +" GLSL +au BufNewFile,BufRead *.glsl setf glsl + " GP scripts (2.0 and onward) au BufNewFile,BufRead *.gp,.gprc setf gp @@ -717,10 +729,14 @@ au BufNewFile,BufRead *.gpi,.gnuplot setf gnuplot " Go (Google) au BufNewFile,BufRead *.go setf go au BufNewFile,BufRead Gopkg.lock setf toml +au BufRead,BufNewFile go.work setf gowork " GrADS scripts au BufNewFile,BufRead *.gs setf grads +" GraphQL +au BufNewFile,BufRead *.graphql,*.graphqls,*.gql setf graphql + " Gretl au BufNewFile,BufRead *.gretl setf gretl @@ -736,12 +752,18 @@ au BufNewFile,BufRead */etc/group,*/etc/group-,*/etc/group.edit,*/etc/gshadow,*/ " GTK RC au BufNewFile,BufRead .gtkrc,gtkrc setf gtkrc +" Hack +au BufRead,BufNewFile *.hack,*.hackpartial setf hack + " Haml au BufNewFile,BufRead *.haml setf haml " Hamster Classic | Playground files au BufNewFile,BufRead *.hsm setf hamster +" Handlebars +au BufNewFile,BufRead *.hbs setf handlebars + " Haskell au BufNewFile,BufRead *.hs,*.hsc,*.hs-boot,*.hsig setf haskell au BufNewFile,BufRead *.lhs setf lhaskell @@ -754,12 +776,21 @@ au BufNewFile,BufRead cabal.config setf cabalconfig au BufNewFile,BufRead *.ht setf haste au BufNewFile,BufRead *.htpp setf hastepreproc +" HCL +au BufRead,BufNewFile *.hcl setf hcl + " Hercules au BufNewFile,BufRead *.vc,*.ev,*.sum,*.errsum setf hercules +" HEEx +au BufRead,BufNewFile *.heex setf heex + " HEX (Intel) au BufNewFile,BufRead *.hex,*.h32 setf hex +" Hjson +au BufNewFile,BufRead *.hjson setf hjson + " Hollywood au BufRead,BufNewFile *.hws setf hollywood @@ -938,6 +969,9 @@ au BufNewFile,BufRead *.ldif setf ldif " Ld loader au BufNewFile,BufRead *.ld setf ld +" Ledger +au BufRead,BufNewFile *.ldg,*.ledger,*.journal setf ledger + " Less au BufNewFile,BufRead *.less setf less @@ -1175,6 +1209,9 @@ au BufNewFile,BufRead *.nginx,nginx*.conf,*nginx.conf,*/etc/nginx/*,*/usr/local/ " Ninja file au BufNewFile,BufRead *.ninja setf ninja +" Nix +au BufRead,BufNewFile *.nix setf nix + " NPM RC file au BufNewFile,BufRead npmrc,.npmrc setf dosini @@ -1360,6 +1397,9 @@ au BufNewFile,BufRead *printcap au BufNewFile,BufRead *termcap \ let b:ptcap_type = "term" | setf ptcap +" Prisma +au BufRead,BufNewFile *.prisma setf prisma + " PCCTS / ANTLR "au BufNewFile,BufRead *.g setf antlr au BufNewFile,BufRead *.g setf pccts @@ -1367,6 +1407,9 @@ au BufNewFile,BufRead *.g setf pccts " PPWizard au BufNewFile,BufRead *.it,*.ih setf ppwiz +" Pug +au BufRead,BufNewFile *.pug setf pug + " Puppet au BufNewFile,BufRead Puppetfile setf ruby @@ -1432,6 +1475,9 @@ au BufNewFile,BufRead *.pyx,*.pxd setf pyrex au BufNewFile,BufRead *.py,*.pyw,.pythonstartup,.pythonrc setf python au BufNewFile,BufRead *.ptl,*.pyi,SConstruct setf python +" QL +au BufRead,BufNewFile *.ql,*.qll setf ql + " Radiance au BufNewFile,BufRead *.rad,*.mat setf radiance @@ -1836,6 +1882,9 @@ au BufNewFile,BufRead */etc/sudoers,sudoers.tmp setf sudoers " SVG (Scalable Vector Graphics) au BufNewFile,BufRead *.svg setf svg +" Surface +au BufRead,BufNewFile *.sface setf surface + " Tads (or Nroff or Perl test file) au BufNewFile,BufRead *.t \ if !dist#ft#FTnroff() && !dist#ft#FTperl() | setf tads | endif @@ -1853,6 +1902,9 @@ au BufRead,BufNewFile *.task setf taskedit " Tcl (JACL too) au BufNewFile,BufRead *.tcl,*.tm,*.tk,*.itcl,*.itk,*.jacl,.tclshrc,.wishrc setf tcl +" Teal +au BufRead,BufNewFile *.tl setf teal + " TealInfo au BufNewFile,BufRead *.tli setf tli @@ -1870,6 +1922,9 @@ au BufRead,BufNewFile *.ttl " Terminfo au BufNewFile,BufRead *.ti setf terminfo +" Terraform +au BufRead,BufNewFile *.tfvars setf terraform + " TeX au BufNewFile,BufRead *.latex,*.sty,*.dtx,*.ltx,*.bbl setf tex au BufNewFile,BufRead *.tex call dist#ft#FTtex() @@ -1889,6 +1944,9 @@ au BufNewFile,BufRead .tidyrc,tidyrc,tidy.conf setf tidy " TF mud client au BufNewFile,BufRead *.tf,.tfrc,tfrc setf tf +" TLA+ +au BufRead,BufNewFile *.tla setf tla + " tmux configuration au BufNewFile,BufRead {.,}tmux*.conf setf tmux @@ -2150,6 +2208,9 @@ au BufNewFile,BufRead *.raml setf raml " yum conf (close enough to dosini) au BufNewFile,BufRead */etc/yum.conf setf dosini +" YANG +au BufRead,BufNewFile *.yang setf yang + " Zimbu au BufNewFile,BufRead *.zu setf zimbu " Zimbu Templates diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index 736ecc1ff7..bd3b44e95b 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -223,23 +223,34 @@ local extension = { fb = "freebasic", fsi = "fsharp", fsx = "fsharp", + fusion = "fusion", gdmo = "gdmo", mo = "gdmo", + tres = "gdresource", + tscn = "gdresource", + gd = "gdscript", ged = "gedcom", gmi = "gemtext", gemini = "gemtext", gift = "gift", + glsl = "glsl", gpi = "gnuplot", gnuplot = "gnuplot", go = "go", gp = "gp", gs = "grads", + gql = "graphql", + graphql = "graphql", + graphqls = "graphql", gretl = "gretl", gradle = "groovy", groovy = "groovy", gsp = "gsp", + hack = "hack", + hackpartial = "hack", haml = "haml", hsm = "hamster", + hbs = "handlebars", ["hs-boot"] = "haskell", hsig = "haskell", hsc = "haskell", @@ -251,8 +262,11 @@ local extension = { errsum = "hercules", ev = "hercules", vc = "hercules", + hcl = "hcl", + heex = "heex", hex = "hex", ["h32"] = "hex", + hjson = "hjson", hog = "hog", hws = "hollywood", htt = "httest", @@ -310,6 +324,9 @@ local extension = { lte = "latte", ld = "ld", ldif = "ldif", + journal = "ledger", + ldg = "ledger", + ledger = "ledger", less = "less", lex = "lex", lxx = "lex", @@ -393,6 +410,7 @@ local extension = { ncf = "ncf", nginx = "nginx", ninja = "ninja", + nix = "nix", nqc = "nqc", roff = "nroff", tmac = "nroff", @@ -427,6 +445,7 @@ local extension = { pcmk = "pcmk", pdf = "pdf", plx = "perl", + prisma = "prisma", psgi = "perl", al = "perl", ctp = "php", @@ -470,6 +489,7 @@ local extension = { ["ps1xml"] = "ps1xml", psf = "psf", psl = "psl", + pug = "pug", arr = "pyret", pxd = "pyrex", pyx = "pyrex", @@ -477,6 +497,8 @@ local extension = { py = "python", pyi = "python", ptl = "python", + ql = "ql", + qll = "ql", rad = "radiance", mat = "radiance", ["pod6"] = "raku", @@ -613,6 +635,7 @@ local extension = { mata = "stata", ado = "stata", stp = "stp", + sface = "surface", svelte = "svelte", svg = "svg", swift = "swift", @@ -626,6 +649,7 @@ local extension = { itcl = "tcl", tk = "tcl", jacl = "tcl", + tl = "teal", tmpl = "template", ti = "terminfo", dtx = "tex", @@ -638,6 +662,8 @@ local extension = { texinfo = "texinfo", text = "text", tf = "tf", + tfvars = "terraform", + tla = "tla", tli = "tli", toml = "toml", tpp = "tpp", @@ -725,6 +751,7 @@ local extension = { yxx = "yacc", yml = "yaml", yaml = "yaml", + yang = "yang", ["z8a"] = "z8a", zig = "zig", zu = "zimbu", @@ -900,6 +927,7 @@ local filename = { [".gnashpluginrc"] = "gnash", gnashpluginrc = "gnash", gnashrc = "gnash", + ["go.work"] = "gowork", [".gprc"] = "gp", ["/.gnupg/gpg.conf"] = "gpg", ["/.gnupg/options"] = "gpg", -- cgit From f9080b24c4f60c3772db2b6e713ea5a6a3b52f1e Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Thu, 27 Jan 2022 09:42:59 +0000 Subject: fix(ts): escape lang when loading parsers (#16668) When trying to load a language parser, escape the value of the language. With language injection, the language might be picked up from the buffer. If this value is erroneous it can cause `nvim_get_runtime_file` to hard error. E.g., the markdown expression `~~~{` will extract '{' as a language and then try to get the parser using `parser/{*` as the pattern. --- runtime/lua/vim/treesitter/language.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/lua/vim/treesitter/language.lua b/runtime/lua/vim/treesitter/language.lua index 6f347ff25f..8b106108df 100644 --- a/runtime/lua/vim/treesitter/language.lua +++ b/runtime/lua/vim/treesitter/language.lua @@ -14,7 +14,7 @@ function M.require_language(lang, path, silent) return true end if path == nil then - local fname = 'parser/' .. lang .. '.*' + local fname = 'parser/' .. vim.fn.fnameescape(lang) .. '.*' local paths = a.nvim_get_runtime_file(fname, false) if #paths == 0 then if silent then -- cgit From 8c140be31f0d203b63e7052e698fdfe253e0b5d4 Mon Sep 17 00:00:00 2001 From: Thomas Vigouroux Date: Thu, 27 Jan 2022 12:46:56 +0100 Subject: feat(ts): expose minimum language version to lua (#17186) --- runtime/lua/vim/treesitter.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'runtime') diff --git a/runtime/lua/vim/treesitter.lua b/runtime/lua/vim/treesitter.lua index 07f6418c0c..f9d539f028 100644 --- a/runtime/lua/vim/treesitter.lua +++ b/runtime/lua/vim/treesitter.lua @@ -11,6 +11,7 @@ local parsers = {} local M = vim.tbl_extend("error", query, language) M.language_version = vim._ts_get_language_version() +M.minimum_language_version = vim._ts_get_minimum_language_version() setmetatable(M, { __index = function (t, k) -- cgit From 39d6db3899759b27c69d2b3444b0cd0e0161793d Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Thu, 27 Jan 2022 14:56:18 +0100 Subject: docs(helphelp): remove extra backtick interference (#17201) An extra backtick was explicitly written to show what a backtick looked like, but it interferes with the syntax highlighting which thinks that it's a part of a concealed group and couples it with the wrong backtick. --- runtime/doc/helphelp.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/doc/helphelp.txt b/runtime/doc/helphelp.txt index 03ec8966d4..569995d319 100644 --- a/runtime/doc/helphelp.txt +++ b/runtime/doc/helphelp.txt @@ -358,7 +358,7 @@ When referring to a Vim option in the help file, place the option name between two single quotes, eg. 'statusline' When referring to any other technical term, such as a filename or function -parameter, surround it in backticks (`), eg. `~/.path/to/init.vim`. +parameter, surround it in backticks, eg. `~/.path/to/init.vim`. HIGHLIGHTING -- cgit From 5b9980f01eb021b0d84f540a6618f94ad2727153 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Fri, 28 Jan 2022 16:59:17 +0100 Subject: vim-patch:8.2.4238: *.tf file could be fileytpe "tf" or "terraform" Problem: *.tf file could be fileytpe "tf" or "terraform". Solution: Detect the type from the file contents. (closes vim/vim#9642) https://github.com/vim/vim/commit/bd8168c7705e315827642f2976ec59e26b7fe009 --- runtime/autoload/dist/ft.vim | 15 +++++++++++++++ runtime/filetype.vim | 9 ++++++--- runtime/lua/vim/filetype.lua | 2 +- 3 files changed, 22 insertions(+), 4 deletions(-) (limited to 'runtime') diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim index 69712046a5..86c71fa52d 100644 --- a/runtime/autoload/dist/ft.vim +++ b/runtime/autoload/dist/ft.vim @@ -862,6 +862,21 @@ func dist#ft#FTfoam() endwhile endfunc +" Determine if a *.tf file is TF mud client or terraform +func dist#ft#FTtf() + let numberOfLines = line('$') + for i in range(1, numberOfLines) + let currentLine = trim(getline(i)) + let firstCharacter = currentLine[0] + if firstCharacter !=? ";" && firstCharacter !=? "/" && firstCharacter !=? "" + setf terraform + return + endif + endfor + setf tf +endfunc + + " Restore 'cpoptions' let &cpo = s:cpo_save unlet s:cpo_save diff --git a/runtime/filetype.vim b/runtime/filetype.vim index 2a0a5110f2..6a27998cf4 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -1942,10 +1942,13 @@ au BufNewFile,BufRead texmf.cnf setf texmf au BufNewFile,BufRead .tidyrc,tidyrc,tidy.conf setf tidy " TF mud client -au BufNewFile,BufRead *.tf,.tfrc,tfrc setf tf +au BufNewFile,BufRead .tfrc,tfrc setf tf + +" TF mud client or terraform +au BufNewFile,BufRead *.tf call dist#ft#FTtf() " TLA+ -au BufRead,BufNewFile *.tla setf tla +au BufNewFile,BufRead *.tla setf tla " tmux configuration au BufNewFile,BufRead {.,}tmux*.conf setf tmux @@ -1954,7 +1957,7 @@ au BufNewFile,BufRead {.,}tmux*.conf setf tmux au BufNewFile,BufRead *.toml setf toml " TPP - Text Presentation Program -au BufNewFile,BufReadPost *.tpp setf tpp +au BufNewFile,BufRead *.tpp setf tpp " Treetop au BufRead,BufNewFile *.treetop setf treetop diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index bd3b44e95b..7fa2fbe001 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -661,7 +661,6 @@ local extension = { txi = "texinfo", texinfo = "texinfo", text = "text", - tf = "tf", tfvars = "terraform", tla = "tla", tli = "tli", @@ -827,6 +826,7 @@ local extension = { stm = function() vim.fn["dist#ft#FThtml"]() end, tcsh = function() vim.fn["dist#ft#SetFileTypeShell"]("tcsh") end, tex = function() vim.fn["dist#ft#FTtex"]() end, + tf = function() vim.fn["dist#ft#FTtf"]() end, w = function() vim.fn["dist#ft#FTprogress_cweb"]() end, xml = function() vim.fn["dist#ft#FTxml"]() end, y = function() vim.fn["dist#ft#FTy"]() end, -- cgit From 6dcdec8042e69c151f40974486b0e3d254596e6c Mon Sep 17 00:00:00 2001 From: Daniel Steinberg Date: Sat, 29 Jan 2022 07:37:07 -0500 Subject: vim-patch:8.2.4052: not easy to resize a window from a plugin (#17028) --- runtime/doc/eval.txt | 31 +++++++++++++++++++++++++++++++ runtime/doc/usr_41.txt | 2 ++ 2 files changed, 33 insertions(+) (limited to 'runtime') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index fa75ead9a3..4a307c0d13 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -2783,6 +2783,8 @@ win_gettype([{nr}]) String type of window {nr} win_gotoid({expr}) Number go to |window-ID| {expr} win_id2tabwin({expr}) List get tab and window nr from |window-ID| win_id2win({expr}) Number get window nr from |window-ID| +win_move_separator({nr}) Number move window vertical separator +win_move_statusline({nr}) Number move window status line win_screenpos({nr}) List get screen position of window {nr} win_splitmove({nr}, {target} [, {options}]) Number move window {nr} to split of {target} @@ -10612,6 +10614,35 @@ win_id2win({expr}) *win_id2win()* Can also be used as a |method|: > GetWinid()->win_id2win() +win_move_separator({nr}, {offset}) *win_move_separator()* + Move window {nr}'s vertical separator (i.e., the right border) + by {offset} columns, as if being dragged by the mouse. {nr} + can be a window number or |window-ID|. A positive {offset} + moves right and a negative {offset} moves left. Moving a + window's vertical separator will change the width of the + window and the width of other windows adjacent to the vertical + separator. The magnitude of movement may be smaller than + specified (e.g., as a consequence of maintaining + 'winminwidth'). Returns TRUE if the window can be found and + FALSE otherwise. + + Can also be used as a |method|: > + GetWinnr()->win_move_separator(offset) + +win_move_statusline({nr}, {offset}) *win_move_statusline()* + Move window {nr}'s status line (i.e., the bottom border) by + {offset} rows, as if being dragged by the mouse. {nr} can be a + window number or |window-ID|. A positive {offset} moves down + and a negative {offset} moves up. Moving a window's status + line will change the height of the window and the height of + other windows adjacent to the status line. The magnitude of + movement may be smaller than specified (e.g., as a consequence + of maintaining 'winminheight'). Returns TRUE if the window can + be found and FALSE otherwise. + + Can also be used as a |method|: > + GetWinnr()->win_move_statusline(offset) + win_screenpos({nr}) *win_screenpos()* Return the screen position of window {nr} as a list with two numbers: [row, col]. The first window always has position diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt index 7e611a47f3..66030eef0d 100644 --- a/runtime/doc/usr_41.txt +++ b/runtime/doc/usr_41.txt @@ -837,6 +837,8 @@ Buffers, windows and the argument list: win_gotoid() go to window with ID win_id2tabwin() get tab and window nr from window ID win_id2win() get window nr from window ID + win_move_separator() move window vertical separator + win_move_statusline() move window status line getbufinfo() get a list with buffer information gettabinfo() get a list with tab page information getwininfo() get a list with window information -- cgit From b2f77c354a289ac99de4c28425dc39d7d057cf90 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sat, 29 Jan 2022 15:40:29 +0100 Subject: vim-patch:8.2.4251: vala files are not recognized (#17235) Problem: Vala files are not recognized. Solution: Add the *.vala pattern. (closes vim/vim#9654) https://github.com/vim/vim/commit/97c554d5149c2aa4a43d689c59563e77277265d4 --- runtime/filetype.vim | 3 +++ runtime/lua/vim/filetype.lua | 1 + 2 files changed, 4 insertions(+) (limited to 'runtime') diff --git a/runtime/filetype.vim b/runtime/filetype.vim index 6a27998cf4..28ecf8844e 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -2017,6 +2017,9 @@ au BufNewFile,BufRead */.init/*.conf,*/.init/*.override setf upstart au BufNewFile,BufRead */.config/upstart/*.conf setf upstart au BufNewFile,BufRead */.config/upstart/*.override setf upstart +" Vala +au BufNewFile,BufRead *.vala setf vala + " Vera au BufNewFile,BufRead *.vr,*.vri,*.vrh setf vera diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index 7fa2fbe001..82ef2f6263 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -756,6 +756,7 @@ local extension = { zu = "zimbu", zut = "zimbutempl", zsh = "zsh", + vala = "vala", E = function() vim.fn["dist#ft#FTe"]() end, EU = function() vim.fn["dist#ft#EuphoriaCheck"]() end, EW = function() vim.fn["dist#ft#EuphoriaCheck"]() end, -- cgit From baec0d3152afeab3007ebb505f3fc274511db434 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Fri, 28 Jan 2022 15:42:19 +0100 Subject: feat(provider)!: remove support for python2 and python3.[3-5] These versions of python has reached End-of-life. getting rid of python2 support removes a lot of logic to support two incompatible python versions in the same version. --- runtime/autoload/health/nvim.vim | 4 +- runtime/autoload/health/provider.vim | 19 +++++----- runtime/autoload/provider/python.vim | 45 ----------------------- runtime/autoload/provider/pythonx.vim | 12 ++---- runtime/doc/eval.txt | 1 - runtime/doc/if_pyth.txt | 69 +++++++++++++---------------------- runtime/doc/options.txt | 21 ++--------- runtime/doc/provider.txt | 26 +++---------- runtime/doc/quickfix.txt | 2 +- 9 files changed, 50 insertions(+), 149 deletions(-) delete mode 100644 runtime/autoload/provider/python.vim (limited to 'runtime') diff --git a/runtime/autoload/health/nvim.vim b/runtime/autoload/health/nvim.vim index 0bb343e198..ef680097d5 100644 --- a/runtime/autoload/health/nvim.vim +++ b/runtime/autoload/health/nvim.vim @@ -104,8 +104,8 @@ function! s:check_rplugin_manifest() abort if !has_key(existing_rplugins, script) let msg = printf('"%s" is not registered.', fnamemodify(path, ':t')) if python_version ==# 'pythonx' - if !has('python2') && !has('python3') - let msg .= ' (python2 and python3 not available)' + if !has('python3') + let msg .= ' (python3 not available)' endif elseif !has(python_version) let msg .= printf(' (%s not available)', python_version) diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index e6523aa215..8f0dbbab39 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -282,10 +282,10 @@ function! s:disabled_via_loaded_var(provider) abort return 0 endfunction -function! s:check_python(version) abort - call health#report_start('Python ' . a:version . ' provider (optional)') +function! s:check_python() abort + call health#report_start('Python 3 provider (optional)') - let pyname = 'python'.(a:version == 2 ? '' : '3') + let pyname = 'python3' let python_exe = '' let venv = exists('$VIRTUAL_ENV') ? resolve($VIRTUAL_ENV) : '' let host_prog_var = pyname.'_host_prog' @@ -301,7 +301,7 @@ function! s:check_python(version) abort call health#report_info(printf('Using: g:%s = "%s"', host_prog_var, get(g:, host_prog_var))) endif - let [pyname, pythonx_errors] = provider#pythonx#Detect(a:version) + let [pyname, pythonx_errors] = provider#pythonx#Detect(3) if empty(pyname) call health#report_warn('No Python executable found that can `import neovim`. ' @@ -405,7 +405,7 @@ function! s:check_python(version) abort " can import 'pynvim'. If so, that Python failed to import 'neovim' as " well, which is most probably due to a failed pip upgrade: " https://github.com/neovim/neovim/wiki/Following-HEAD#20181118 - let [pynvim_exe, errors] = provider#pythonx#DetectByModule('pynvim', a:version) + let [pynvim_exe, errors] = provider#pythonx#DetectByModule('pynvim', 3) if !empty(pynvim_exe) call health#report_error( \ 'Detected pip upgrade failure: Python executable can import "pynvim" but ' @@ -416,14 +416,14 @@ function! s:check_python(version) abort \ . pynvim_exe ." -m pip install neovim # only if needed by third-party software") endif else - let [pyversion, current, latest, status] = s:version_info(python_exe) + let [majorpyversion, current, latest, status] = s:version_info(python_exe) - if a:version != str2nr(pyversion) + if 3 != str2nr(majorpyversion) call health#report_warn('Unexpected Python version.' . \ ' This could lead to confusing error messages.') endif - call health#report_info('Python version: ' . pyversion) + call health#report_info('Python version: ' . majorpyversion) if s:is_bad_response(status) call health#report_info(printf('pynvim version: %s (%s)', current, status)) @@ -751,8 +751,7 @@ endfunction function! health#provider#check() abort call s:check_clipboard() - call s:check_python(2) - call s:check_python(3) + call s:check_python() call s:check_virtualenv() call s:check_ruby() call s:check_node() diff --git a/runtime/autoload/provider/python.vim b/runtime/autoload/provider/python.vim deleted file mode 100644 index 8a1d162784..0000000000 --- a/runtime/autoload/provider/python.vim +++ /dev/null @@ -1,45 +0,0 @@ -" The Python provider uses a Python host to emulate an environment for running -" python-vim plugins. :help provider -" -" Associating the plugin with the Python host is the first step because plugins -" will be passed as command-line arguments - -if exists('g:loaded_python_provider') - finish -endif -let [s:prog, s:err] = provider#pythonx#Detect(2) -let g:loaded_python_provider = empty(s:prog) ? 1 : 2 - -function! provider#python#Prog() abort - return s:prog -endfunction - -function! provider#python#Error() abort - return s:err -endfunction - -" The Python provider plugin will run in a separate instance of the Python -" host. -call remote#host#RegisterClone('legacy-python-provider', 'python') -call remote#host#RegisterPlugin('legacy-python-provider', 'script_host.py', []) - -function! provider#python#Call(method, args) abort - if s:err != '' - return - endif - if !exists('s:host') - let s:rpcrequest = function('rpcrequest') - - " Ensure that we can load the Python host before bootstrapping - try - let s:host = remote#host#Require('legacy-python-provider') - catch - let s:err = v:exception - echohl WarningMsg - echomsg v:exception - echohl None - return - endtry - endif - return call(s:rpcrequest, insert(insert(a:args, 'python_'.a:method), s:host)) -endfunction diff --git a/runtime/autoload/provider/pythonx.vim b/runtime/autoload/provider/pythonx.vim index 0eeb35cba8..5b299b322c 100644 --- a/runtime/autoload/provider/pythonx.vim +++ b/runtime/autoload/provider/pythonx.vim @@ -6,10 +6,8 @@ endif let s:loaded_pythonx_provider = 1 function! provider#pythonx#Require(host) abort - let ver = (a:host.orig_name ==# 'python') ? 2 : 3 - " Python host arguments - let prog = (ver == '2' ? provider#python#Prog() : provider#python3#Prog()) + let prog = provider#python3#Prog() let args = [prog, '-c', 'import sys; sys.path = list(filter(lambda x: x != "", sys.path)); import neovim; neovim.start_host()'] @@ -23,14 +21,12 @@ function! provider#pythonx#Require(host) abort endfunction function! s:get_python_executable_from_host_var(major_version) abort - return expand(get(g:, 'python'.(a:major_version == 3 ? '3' : '').'_host_prog', ''), v:true) + return expand(get(g:, 'python'.(a:major_version == 3 ? '3' : execute("throw 'unsupported'")).'_host_prog', ''), v:true) endfunction function! s:get_python_candidates(major_version) abort return { - \ 2: ['python2', 'python2.7', 'python2.6', 'python'], - \ 3: ['python3', 'python3.10', 'python3.9', 'python3.8', 'python3.7', - \ 'python3.6', 'python'] + \ 3: ['python3', 'python3.10', 'python3.9', 'python3.8', 'python3.7', 'python'] \ }[a:major_version] endfunction @@ -82,7 +78,7 @@ function! provider#pythonx#CheckForModule(prog, module, major_version) abort return [0, a:prog . ' not found in search path or not executable.'] endif - let min_version = (a:major_version == 2) ? '2.6' : '3.3' + let min_version = '3.7' " Try to load module, and output Python version. " Exit codes: diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 4a307c0d13..800604b506 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -5806,7 +5806,6 @@ has({feature}) Returns 1 if {feature} is supported, 0 otherwise. The this is not present). mac MacOS system. nvim This is Nvim. - python2 Legacy Vim |python2| interface. |has-python| python3 Legacy Vim |python3| interface. |has-python| pythonx Legacy Vim |python_x| interface. |has-pythonx| ttyin input is a terminal (tty) diff --git a/runtime/doc/if_pyth.txt b/runtime/doc/if_pyth.txt index fea47de220..afdf039aa8 100644 --- a/runtime/doc/if_pyth.txt +++ b/runtime/doc/if_pyth.txt @@ -1,10 +1,10 @@ *if_pyth.txt* Nvim - VIM REFERENCE MANUAL by Paul Moore + NVIM REFERENCE MANUAL -The Python Interface to Vim *if_pyth* *python* *Python* +The Python Interface to NVim *if_pyth* *python* *Python* See |provider-python| for more information. @@ -134,7 +134,7 @@ Instead, put the Python command in a function and call that function: Note that "EOF" must be at the start of the line. ============================================================================== -The vim module *python-vim* *python2* +The vim module *python-vim* Python code gets all of its access to vim (with one exception - see |python-output| below) via the "vim" module. The vim module implements two @@ -322,14 +322,13 @@ Output from Python *python-output* supported, and may cause the program to crash. This should probably be fixed. - *python2-directory* *python3-directory* *pythonx-directory* + *python3-directory* *pythonx-directory* Python 'runtimepath' handling *python-special-path* In python vim.VIM_SPECIAL_PATH special directory is used as a replacement for the list of paths found in 'runtimepath': with this directory in sys.path and vim.path_hooks in sys.path_hooks python will try to load module from -{rtp}/python2 (or python3) and {rtp}/pythonx (for both python versions) for -each {rtp} found in 'runtimepath'. +{rtp}/python3 and {rtp}/pythonx for each {rtp} found in 'runtimepath'. Implementation is similar to the following, but written in C: > @@ -401,8 +400,8 @@ vim._get_paths *python-_get_paths* hook. You should not rely on this method being present in future versions, but can use it for debugging. - It returns a list of {rtp}/python2 (or {rtp}/python3) and - {rtp}/pythonx directories for each {rtp} in 'runtimepath'. + It returns a list of {rtp}/python3 and {rtp}/pythonx + directories for each {rtp} in 'runtimepath'. ============================================================================== Buffer objects *python-buffer* @@ -590,6 +589,11 @@ functions to evaluate Python expressions and pass their values to Vim script. ============================================================================== Python 3 *python3* +As Python 3 is the only supported version in Nvim, "python" is synonymous +with "python3" in the current version. However, code that aims to support older +versions of Neovim, as well as Vim, should prefer to use "python3" +variants explicitly if Python 3 is required. + *:py3* *:python3* :[range]py3 {stmt} :[range]py3 << [endmarker] @@ -619,31 +623,26 @@ Raising SystemExit exception in python isn't endorsed way to quit vim, use: > :py vim.command("qall!") < *has-python* -You can test what Python version is available with: > - if has('python') - echo 'there is Python 2.x' +You can test if Python is available with: > + if has('pythonx') + echo 'there is Python' endif if has('python3') echo 'there is Python 3.x' endif +Python 2 is no longer supported. Thus `has('python')` always returns +zero for backwards compatibility reasons. + ============================================================================== Python X *python_x* *pythonx* -Because most python code can be written so that it works with Python 2.6+ and -Python 3, the pyx* functions and commands have been written. They work the -same as the Python 2 and 3 variants, but select the Python version using the -'pyxversion' setting. - -Set 'pyxversion' in your |vimrc| to prefer Python 2 or Python 3 for Python -commands. Changing this setting at runtime risks losing the state of plugins -(such as initialization). - -If you want to use a module, you can put it in the {rtp}/pythonx directory. -See |pythonx-directory|. +The "pythonx" and "pyx" prefixes were introduced for python code which +works with Python 2.6+ and Python 3. As Nvim only supports Python 3, +all these commands are now synonymous to their "python3" equivalents. *:pyx* *:pythonx* -`:pyx` and `:pythonx` work similar to `:python`. To check if `:pyx` works: > +`:pyx` and `:pythonx` work the same as `:python3`. To check if `:pyx` works: > :pyx print("Hello") To see what version of Python is being used: > @@ -651,34 +650,16 @@ To see what version of Python is being used: > :pyx print(sys.version) < *:pyxfile* *python_x-special-comments* -`:pyxfile` works similar to `:pyfile`. But you can add a "shebang" comment to -force Vim to use `:pyfile` or `:py3file`: > - #!/any string/python2 " Shebang. Must be the first line of the file. - #!/any string/python3 " Shebang. Must be the first line of the file. - # requires python 2.x " Maximum lines depend on 'modelines'. - # requires python 3.x " Maximum lines depend on 'modelines'. -Unlike normal modelines, the bottom of the file is not checked. -If none of them are found, the 'pyxversion' option is used. - *W20* *W21* -If Vim does not support the selected Python version a silent message will be -printed. Use `:messages` to read them. +`:pyxfile` works the same as `:py3file`. *:pyxdo* -`:pyxdo` works similar to `:pydo`. +`:pyxdo` works the same as `:py3do`. *has-pythonx* -To check if pyx* functions and commands are available: > +To check if `pyx*` functions and commands are available: > if has('pythonx') echo 'pyx* commands are available. (Python ' . &pyx . ')' endif -If you prefer Python 2 and want to fallback to Python 3, set 'pyxversion' -explicitly in your |.vimrc|. Example: > - if has('python') - set pyx=2 - elseif has('python3') - set pyx=3 - endif - ============================================================================== vim:tw=78:ts=8:noet:ft=help:norl: diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 13a19d8991..5e7d709584 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -4637,26 +4637,11 @@ A jump table for the options with a short description can be found at |Q_op|. nudged to fit on the screen. *'pyxversion'* *'pyx'* -'pyxversion' 'pyx' number (default depends on the build) +'pyxversion' 'pyx' number (default 3) global Specifies the python version used for pyx* functions and commands - |python_x|. The default value is as follows: - - |provider| installed Default ~ - |+python| and |+python3| 0 - only |+python| 2 - only |+python3| 3 - - Available values are 0, 2 and 3. - If 'pyxversion' is 0, it is set to 2 or 3 after the first execution of - any python2/3 commands or functions. E.g. `:py` sets to 2, and `:py3` - sets to 3. `:pyx` sets it to 3 if Python 3 is available, otherwise sets - to 2 if Python 2 is available. - See also: |has-pythonx| - - If only |+python| or |+python3| are available, - 'pyxversion' has no effect. The pyx* functions and commands are - always the same as the installed version. + |python_x|. As only Python 3 is supported, this always has the value + `3`. Setting any other value is an error. This option cannot be set from a |modeline| or in the |sandbox|, for security reasons. diff --git a/runtime/doc/provider.txt b/runtime/doc/provider.txt index b785010699..9fd35f19c5 100644 --- a/runtime/doc/provider.txt +++ b/runtime/doc/provider.txt @@ -20,11 +20,12 @@ Run the |:checkhealth| command, and review the sections below. ============================================================================== Python integration *provider-python* -Nvim supports Python |remote-plugin|s and the Vim legacy |python2| and -|python3| interfaces (which are implemented as remote-plugins). +Nvim supports Python |remote-plugin|s and the Vim legacy |python3| and +|pythonx| interfaces (which are implemented as remote-plugins). Note: Only the Vim 7.3 legacy interface is supported, not later features such -as |python-bindeval| (Vim 7.4); use the Nvim API instead. +as |python-bindeval| (Vim 7.4); use the Nvim API instead. Python 2 is not +supported. PYTHON QUICKSTART ~ @@ -38,11 +39,6 @@ For Python 3 plugins: 2. Install the module (try "python" if "python3" is missing): > python3 -m pip install --user --upgrade pynvim -For Python 2 plugins: -1. Make sure Python 2.7 is available in your $PATH. -2. Install the module (try "python" if "python2" is missing): > - python2 -m pip install --user --upgrade pynvim - The pip `--upgrade` flag ensures that you get the latest version even if a previous version was already installed. @@ -56,21 +52,11 @@ If you run into problems, uninstall _both_ then install "pynvim" again: > PYTHON PROVIDER CONFIGURATION ~ - *g:python_host_prog* -Command to start Python 2 (executable, not directory). Setting this makes -startup faster. Useful for working with virtualenvs. Must be set before any -check for has("python2"). > - let g:python_host_prog = '/path/to/python' -< *g:python3_host_prog* Command to start Python 3 (executable, not directory). Setting this makes startup faster. Useful for working with virtualenvs. Must be set before any check for has("python3"). > let g:python3_host_prog = '/path/to/python3' -< - *g:loaded_python_provider* -To disable Python 2 support: > - let g:loaded_python_provider = 0 < *g:loaded_python3_provider* To disable Python 3 support: > @@ -81,8 +67,8 @@ PYTHON VIRTUALENVS ~ *python-virtualenv* If you plan to use per-project virtualenvs often, you should assign one virtualenv for Neovim and hard-code the interpreter path via -|g:python3_host_prog| (or |g:python_host_prog|) so that the "pynvim" package -is not required for each virtualenv. +|g:python3_host_prog| so that the "pynvim" package is not required +for each virtualenv. Example using pyenv: > pyenv install 3.4.4 diff --git a/runtime/doc/quickfix.txt b/runtime/doc/quickfix.txt index 873fbd8971..bb4d807413 100644 --- a/runtime/doc/quickfix.txt +++ b/runtime/doc/quickfix.txt @@ -1446,7 +1446,7 @@ error message (line numbers are not part of the actual output): 4 Traceback (most recent call last): 5 File "unittests/dbfacadeTest.py", line 89, in testFoo 6 self.assertEquals(34, dtid) - 7 File "/usr/lib/python2.2/unittest.py", line 286, in + 7 File "/usr/lib/python3.8/unittest.py", line 286, in 8 failUnlessEqual 9 raise self.failureException, \ 10 AssertionError: 34 != 33 -- cgit From 4458413bc02a1308bd722611227664033916d6f7 Mon Sep 17 00:00:00 2001 From: Gregory Anders <8965202+gpanders@users.noreply.github.com> Date: Sat, 29 Jan 2022 13:43:06 -0600 Subject: feat(filetype): convert patterns for mail buffers (#17238) --- runtime/lua/vim/filetype.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'runtime') diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index 82ef2f6263..adc838578d 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -1389,6 +1389,16 @@ local pattern = { ["zlog.*"] = starsetf('zsh'), ["zsh.*"] = starsetf('zsh'), ["ae%d+%.txt"] = 'mail', + ["snd%.%d+"] = "mail", + ["%.letter%.%d+"] = "mail", + ["%.article%.%d+"] = "mail", + ["pico%.%d+"] = "mail", + ["mutt%-.*%-%w+"] = "mail", + ["neomutt%-.*%-%w+"] = "mail", + ["muttng%-.*%-%w+"] = "mail", + ["mutt" .. string.rep("[%w_-]", 6)] = "mail", + ["neomutt" .. string.rep("[%w_-]", 6)] = "mail", + ["/tmp/SLRN[0-9A-Z.]+"] = "mail", ["[a-zA-Z0-9].*Dict"] = function() vim.fn["dist#ft#FTfoam"]() end, ["[a-zA-Z0-9].*Dict%..*"] = function() vim.fn["dist#ft#FTfoam"]() end, ["[a-zA-Z].*Properties"] = function() vim.fn["dist#ft#FTfoam"]() end, -- cgit From a94632d2126823bcd593f4cdd5a41aaff197b291 Mon Sep 17 00:00:00 2001 From: Daniel Steinberg Date: Fri, 7 Jan 2022 12:28:17 -0500 Subject: vim-patch:8.2.3917: the eval.txt help file is way too big Problem: The eval.txt help file is way too big. Solution: Move the builtin function details to a separate file. https://github.com/vim/vim/commit/1cae5a0a034d0545360387407a7a409310f1efe2 Note: Neovim-specific references to |functions| were changed to |builtin-functions|. This included updates to: 1. test/functional/vimscript/functions_spec.lua 2. test/functional/vimscript/eval_spec.lua 3. runtime/doc/lua.txt --- runtime/doc/builtin.txt | 8697 +++++++++++++++++++++++++++++++++++++++++++++++ runtime/doc/eval.txt | 8681 +--------------------------------------------- runtime/doc/help.txt | 1 + runtime/doc/lua.txt | 6 +- 4 files changed, 8705 insertions(+), 8680 deletions(-) create mode 100644 runtime/doc/builtin.txt (limited to 'runtime') diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt new file mode 100644 index 0000000000..ae15dca3f1 --- /dev/null +++ b/runtime/doc/builtin.txt @@ -0,0 +1,8697 @@ +*builtin.txt* Nvim + + + VIM REFERENCE MANUAL by Bram Moolenaar + + +Builtin functions *builtin-functions* + +1. Overview |builtin-function-list| +2. Details |builtin-function-details| +3. Matching a pattern in a String |string-match| + +============================================================================== +1. Overview *builtin-function-list* + +Use CTRL-] on the function name to jump to the full explanation. + +USAGE RESULT DESCRIPTION ~ + +abs({expr}) Float or Number absolute value of {expr} +acos({expr}) Float arc cosine of {expr} +add({object}, {item}) List/Blob append {item} to {object} +and({expr}, {expr}) Number bitwise AND +api_info() Dict api metadata +append({lnum}, {string}) Number append {string} below line {lnum} +append({lnum}, {list}) Number append lines {list} below line {lnum} +argc([{winid}]) Number number of files in the argument list +argidx() Number current index in the argument list +arglistid([{winnr} [, {tabnr}]]) Number argument list id +argv({nr} [, {winid}]) String {nr} entry of the argument list +argv([-1, {winid}]) List the argument list +asin({expr}) Float arc sine of {expr} +assert_beeps({cmd}) Number assert {cmd} causes a beep +assert_equal({exp}, {act} [, {msg}]) + Number assert {exp} is equal to {act} +assert_equalfile({fname-one}, {fname-two} [, {msg}]) + Number assert file contents are equal +assert_exception({error} [, {msg}]) + Number assert {error} is in v:exception +assert_fails({cmd} [, {error}]) Number assert {cmd} fails +assert_false({actual} [, {msg}]) + Number assert {actual} is false +assert_inrange({lower}, {upper}, {actual} [, {msg}]) + Number assert {actual} is inside the range +assert_match({pat}, {text} [, {msg}]) + Number assert {pat} matches {text} +assert_nobeep({cmd}) Number assert {cmd} does not cause a beep +assert_notequal({exp}, {act} [, {msg}]) + Number assert {exp} is not equal {act} +assert_notmatch({pat}, {text} [, {msg}]) + Number assert {pat} not matches {text} +assert_report({msg}) Number report a test failure +assert_true({actual} [, {msg}]) Number assert {actual} is true +atan({expr}) Float arc tangent of {expr} +atan2({expr}, {expr}) Float arc tangent of {expr1} / {expr2} +browse({save}, {title}, {initdir}, {default}) + String put up a file requester +browsedir({title}, {initdir}) String put up a directory requester +bufadd({name}) Number add a buffer to the buffer list +bufexists({expr}) Number |TRUE| if buffer {expr} exists +buflisted({expr}) Number |TRUE| if buffer {expr} is listed +bufload({expr}) Number load buffer {expr} if not loaded yet +bufloaded({expr}) Number |TRUE| if buffer {expr} is loaded +bufname([{expr}]) String Name of the buffer {expr} +bufnr([{expr} [, {create}]]) Number Number of the buffer {expr} +bufwinid({expr}) Number |window-ID| of buffer {expr} +bufwinnr({expr}) Number window number of buffer {expr} +byte2line({byte}) Number line number at byte count {byte} +byteidx({expr}, {nr}) Number byte index of {nr}'th char in {expr} +byteidxcomp({expr}, {nr}) Number byte index of {nr}'th char in {expr} +call({func}, {arglist} [, {dict}]) + any call {func} with arguments {arglist} +ceil({expr}) Float round {expr} up +changenr() Number current change number +chanclose({id}[, {stream}]) Number Closes a channel or one of its streams +chansend({id}, {data}) Number Writes {data} to channel +char2nr({expr}[, {utf8}]) Number ASCII/UTF-8 value of first char in {expr} +charidx({string}, {idx} [, {countcc}]) + Number char index of byte {idx} in {string} +chdir({dir}) String change current working directory +cindent({lnum}) Number C indent for line {lnum} +clearmatches([{win}]) none clear all matches +col({expr}) Number column nr of cursor or mark +complete({startcol}, {matches}) none set Insert mode completion +complete_add({expr}) Number add completion match +complete_check() Number check for key typed during completion +complete_info([{what}]) Dict get current completion information +confirm({msg} [, {choices} [, {default} [, {type}]]]) + Number number of choice picked by user +copy({expr}) any make a shallow copy of {expr} +cos({expr}) Float cosine of {expr} +cosh({expr}) Float hyperbolic cosine of {expr} +count({list}, {expr} [, {ic} [, {start}]]) + Number count how many {expr} are in {list} +cscope_connection([{num}, {dbpath} [, {prepend}]]) + Number checks existence of cscope connection +ctxget([{index}]) Dict return the |context| dict at {index} +ctxpop() none pop and restore |context| from the + |context-stack| +ctxpush([{types}]) none push the current |context| to the + |context-stack| +ctxset({context}[, {index}]) none set |context| at {index} +ctxsize() Number return |context-stack| size +cursor({lnum}, {col} [, {off}]) + Number move cursor to {lnum}, {col}, {off} +cursor({list}) Number move cursor to position in {list} +debugbreak({pid}) Number interrupt process being debugged +deepcopy({expr} [, {noref}]) any make a full copy of {expr} +delete({fname} [, {flags}]) Number delete the file or directory {fname} +deletebufline({buf}, {first}[, {last}]) + Number delete lines from buffer {buf} +dictwatcheradd({dict}, {pattern}, {callback}) + Start watching a dictionary +dictwatcherdel({dict}, {pattern}, {callback}) + Stop watching a dictionary +did_filetype() Number |TRUE| if FileType autocommand event used +diff_filler({lnum}) Number diff filler lines about {lnum} +diff_hlID({lnum}, {col}) Number diff highlighting at {lnum}/{col} +empty({expr}) Number |TRUE| if {expr} is empty +environ() Dict return environment variables +escape({string}, {chars}) String escape {chars} in {string} with '\' +eval({string}) any evaluate {string} into its value +eventhandler() Number |TRUE| if inside an event handler +executable({expr}) Number 1 if executable {expr} exists +execute({command}) String execute and capture output of {command} +exepath({expr}) String full path of the command {expr} +exists({expr}) Number |TRUE| if {expr} exists +extend({expr1}, {expr2} [, {expr3}]) + List/Dict insert items of {expr2} into {expr1} +exp({expr}) Float exponential of {expr} +expand({expr} [, {nosuf} [, {list}]]) + any expand special keywords in {expr} +expandcmd({expr}) String expand {expr} like with `:edit` +feedkeys({string} [, {mode}]) Number add key sequence to typeahead buffer +filereadable({file}) Number |TRUE| if {file} is a readable file +filewritable({file}) Number |TRUE| if {file} is a writable file +filter({expr1}, {expr2}) List/Dict remove items from {expr1} where + {expr2} is 0 +finddir({name} [, {path} [, {count}]]) + String find directory {name} in {path} +findfile({name} [, {path} [, {count}]]) + String find file {name} in {path} +flatten({list} [, {maxdepth}]) List flatten {list} up to {maxdepth} levels +float2nr({expr}) Number convert Float {expr} to a Number +floor({expr}) Float round {expr} down +fmod({expr1}, {expr2}) Float remainder of {expr1} / {expr2} +fnameescape({fname}) String escape special characters in {fname} +fnamemodify({fname}, {mods}) String modify file name +foldclosed({lnum}) Number first line of fold at {lnum} if closed +foldclosedend({lnum}) Number last line of fold at {lnum} if closed +foldlevel({lnum}) Number fold level at {lnum} +foldtext() String line displayed for closed fold +foldtextresult({lnum}) String text for closed fold at {lnum} +foreground() Number bring the Vim window to the foreground +fullcommand({name}) String get full command from {name} +funcref({name} [, {arglist}] [, {dict}]) + Funcref reference to function {name} +function({name} [, {arglist}] [, {dict}]) + Funcref named reference to function {name} +garbagecollect([{atexit}]) none free memory, breaking cyclic references +get({list}, {idx} [, {def}]) any get item {idx} from {list} or {def} +get({dict}, {key} [, {def}]) any get item {key} from {dict} or {def} +get({func}, {what}) any get property of funcref/partial {func} +getbufinfo([{buf}]) List information about buffers +getbufline({buf}, {lnum} [, {end}]) + List lines {lnum} to {end} of buffer {buf} +getbufvar({buf}, {varname} [, {def}]) + any variable {varname} in buffer {buf} +getchangelist([{buf}]) List list of change list items +getchar([expr]) Number or String + get one character from the user +getcharmod() Number modifiers for the last typed character +getcharsearch() Dict last character search +getcharstr([expr]) String get one character from the user +getcmdline() String return the current command-line +getcmdpos() Number return cursor position in command-line +getcmdtype() String return current command-line type +getcmdwintype() String return current command-line window type +getcompletion({pat}, {type} [, {filtered}]) + List list of cmdline completion matches +getcurpos() List position of the cursor +getcwd([{winnr} [, {tabnr}]]) String get the current working directory +getenv({name}) String return environment variable +getfontname([{name}]) String name of font being used +getfperm({fname}) String file permissions of file {fname} +getfsize({fname}) Number size in bytes of file {fname} +getftime({fname}) Number last modification time of file +getftype({fname}) String description of type of file {fname} +getjumplist([{winnr} [, {tabnr}]]) + List list of jump list items +getline({lnum}) String line {lnum} of current buffer +getline({lnum}, {end}) List lines {lnum} to {end} of current buffer +getloclist({nr}) List list of location list items +getloclist({nr}, {what}) Dict get specific location list properties +getmarklist([{buf}]) List list of global/local marks +getmatches([{win}]) List list of current matches +getmousepos() Dict last known mouse position +getpid() Number process ID of Vim +getpos({expr}) List position of cursor, mark, etc. +getqflist() List list of quickfix items +getqflist({what}) Dict get specific quickfix list properties +getreg([{regname} [, 1 [, {list}]]]) + String or List contents of a register +getreginfo([{regname}]) Dict information about a register +getregtype([{regname}]) String type of a register +gettabinfo([{expr}]) List list of tab pages +gettabvar({nr}, {varname} [, {def}]) + any variable {varname} in tab {nr} or {def} +gettabwinvar({tabnr}, {winnr}, {name} [, {def}]) + any {name} in {winnr} in tab page {tabnr} +gettagstack([{nr}]) Dict get the tag stack of window {nr} +getwininfo([{winid}]) List list of windows +getwinpos([{timeout}]) List X and Y coord in pixels of the Vim window +getwinposx() Number X coord in pixels of Vim window +getwinposy() Number Y coord in pixels of Vim window +getwinvar({nr}, {varname} [, {def}]) + any variable {varname} in window {nr} +glob({expr} [, {nosuf} [, {list} [, {alllinks}]]]) + any expand file wildcards in {expr} +glob2regpat({expr}) String convert a glob pat into a search pat +globpath({path}, {expr} [, {nosuf} [, {list} [, {alllinks}]]]) + String do glob({expr}) for all dirs in {path} +has({feature}) Number |TRUE| if feature {feature} supported +has_key({dict}, {key}) Number |TRUE| if {dict} has entry {key} +haslocaldir([{winnr} [, {tabnr}]]) + Number |TRUE| if the window executed |:lcd| or + the tab executed |:tcd| +hasmapto({what} [, {mode} [, {abbr}]]) + Number |TRUE| if mapping to {what} exists +histadd({history}, {item}) String add an item to a history +histdel({history} [, {item}]) String remove an item from a history +histget({history} [, {index}]) String get the item {index} from a history +histnr({history}) Number highest index of a history +hlexists({name}) Number |TRUE| if highlight group {name} exists +hlID({name}) Number syntax ID of highlight group {name} +hostname() String name of the machine Vim is running on +iconv({expr}, {from}, {to}) String convert encoding of {expr} +indent({lnum}) Number indent of line {lnum} +index({object}, {expr} [, {start} [, {ic}]]) + Number index in {object} where {expr} appears +input({prompt} [, {text} [, {completion}]]) + String get input from the user +inputlist({textlist}) Number let the user pick from a choice list +inputrestore() Number restore typeahead +inputsave() Number save and clear typeahead +inputsecret({prompt} [, {text}]) + String like input() but hiding the text +insert({object}, {item} [, {idx}]) + List insert {item} in {object} [before {idx}] +interrupt() none interrupt script execution +invert({expr}) Number bitwise invert +isdirectory({directory}) Number |TRUE| if {directory} is a directory +isinf({expr}) Number determine if {expr} is infinity value + (positive or negative) +islocked({expr}) Number |TRUE| if {expr} is locked +isnan({expr}) Number |TRUE| if {expr} is NaN +id({expr}) String identifier of the container +items({dict}) List key-value pairs in {dict} +jobpid({id}) Number Returns pid of a job. +jobresize({id}, {width}, {height}) + Number Resize pseudo terminal window of a job +jobstart({cmd}[, {opts}]) Number Spawns {cmd} as a job +jobstop({id}) Number Stops a job +jobwait({ids}[, {timeout}]) Number Wait for a set of jobs +join({list} [, {sep}]) String join {list} items into one String +json_decode({expr}) any Convert {expr} from JSON +json_encode({expr}) String Convert {expr} to JSON +keys({dict}) List keys in {dict} +len({expr}) Number the length of {expr} +libcall({lib}, {func}, {arg}) String call {func} in library {lib} with {arg} +libcallnr({lib}, {func}, {arg}) Number idem, but return a Number +line({expr} [, {winid}]) Number line nr of cursor, last line or mark +line2byte({lnum}) Number byte count of line {lnum} +lispindent({lnum}) Number Lisp indent for line {lnum} +list2str({list} [, {utf8}]) String turn numbers in {list} into a String +localtime() Number current time +log({expr}) Float natural logarithm (base e) of {expr} +log10({expr}) Float logarithm of Float {expr} to base 10 +luaeval({expr}[, {expr}]) any evaluate Lua expression +map({expr1}, {expr2}) List/Dict change each item in {expr1} to {expr} +maparg({name}[, {mode} [, {abbr} [, {dict}]]]) + String or Dict + rhs of mapping {name} in mode {mode} +mapcheck({name}[, {mode} [, {abbr}]]) + String check for mappings matching {name} +match({expr}, {pat}[, {start}[, {count}]]) + Number position where {pat} matches in {expr} +matchadd({group}, {pattern}[, {priority}[, {id}]]) + Number highlight {pattern} with {group} +matchaddpos({group}, {list}[, {priority}[, {id}]]) + Number highlight positions with {group} +matcharg({nr}) List arguments of |:match| +matchdelete({id} [, {win}]) Number delete match identified by {id} +matchend({expr}, {pat}[, {start}[, {count}]]) + Number position where {pat} ends in {expr} +matchlist({expr}, {pat}[, {start}[, {count}]]) + List match and submatches of {pat} in {expr} +matchstr({expr}, {pat}[, {start}[, {count}]]) + String {count}'th match of {pat} in {expr} +matchstrpos({expr}, {pat}[, {start}[, {count}]]) + List {count}'th match of {pat} in {expr} +max({expr}) Number maximum value of items in {expr} +menu_get({path} [, {modes}]) List description of |menus| matched by {path} +min({expr}) Number minimum value of items in {expr} +mkdir({name} [, {path} [, {prot}]]) + Number create directory {name} +mode([expr]) String current editing mode +msgpackdump({list} [, {type}]) List/Blob dump objects to msgpack +msgpackparse({data}) List parse msgpack to a list of objects +nextnonblank({lnum}) Number line nr of non-blank line >= {lnum} +nr2char({expr}[, {utf8}]) String single char with ASCII/UTF-8 value {expr} +nvim_...({args}...) any call nvim |api| functions +or({expr}, {expr}) Number bitwise OR +pathshorten({expr}) String shorten directory names in a path +perleval({expr}) any evaluate |perl| expression +pow({x}, {y}) Float {x} to the power of {y} +prevnonblank({lnum}) Number line nr of non-blank line <= {lnum} +printf({fmt}, {expr1}...) String format text +prompt_getprompt({buf}) String get prompt text +prompt_setcallback({buf}, {expr}) none set prompt callback function +prompt_setinterrupt({buf}, {text}) none set prompt interrupt function +prompt_setprompt({buf}, {text}) none set prompt text +pum_getpos() Dict position and size of pum if visible +pumvisible() Number whether popup menu is visible +pyeval({expr}) any evaluate |Python| expression +py3eval({expr}) any evaluate |python3| expression +pyxeval({expr}) any evaluate |python_x| expression +range({expr} [, {max} [, {stride}]]) + List items from {expr} to {max} +readdir({dir} [, {expr}]) List file names in {dir} selected by {expr} +readfile({fname} [, {type} [, {max}]]) + List get list of lines from file {fname} +reg_executing() String get the executing register name +reg_recorded() String get the last recorded register name +reg_recording() String get the recording register name +reltime([{start} [, {end}]]) List get time value +reltimefloat({time}) Float turn the time value into a Float +reltimestr({time}) String turn time value into a String +remote_expr({server}, {string} [, {idvar} [, {timeout}]]) + String send expression +remote_foreground({server}) Number bring Vim server to the foreground +remote_peek({serverid} [, {retvar}]) + Number check for reply string +remote_read({serverid} [, {timeout}]) + String read reply string +remote_send({server}, {string} [, {idvar}]) + String send key sequence +remote_startserver({name}) none become server {name} +remove({list}, {idx} [, {end}]) any/List + remove items {idx}-{end} from {list} +remove({blob}, {idx} [, {end}]) Number/Blob + remove bytes {idx}-{end} from {blob} +remove({dict}, {key}) any remove entry {key} from {dict} +rename({from}, {to}) Number rename (move) file from {from} to {to} +repeat({expr}, {count}) String repeat {expr} {count} times +resolve({filename}) String get filename a shortcut points to +reverse({list}) List reverse {list} in-place +round({expr}) Float round off {expr} +rubyeval({expr}) any evaluate |Ruby| expression +rpcnotify({channel}, {event}[, {args}...]) + Sends an |RPC| notification to {channel} +rpcrequest({channel}, {method}[, {args}...]) + Sends an |RPC| request to {channel} +screenattr({row}, {col}) Number attribute at screen position +screenchar({row}, {col}) Number character at screen position +screenchars({row}, {col}) List List of characters at screen position +screencol() Number current cursor column +screenpos({winid}, {lnum}, {col}) Dict screen row and col of a text character +screenrow() Number current cursor row +screenstring({row}, {col}) String characters at screen position +search({pattern} [, {flags} [, {stopline} [, {timeout}]]]) + Number search for {pattern} +searchcount([{options}]) Dict Get or update the last search count +searchdecl({name} [, {global} [, {thisblock}]]) + Number search for variable declaration +searchpair({start}, {middle}, {end} [, {flags} [, {skip} [...]]]) + Number search for other end of start/end pair +searchpairpos({start}, {middle}, {end} [, {flags} [, {skip} [...]]]) + List search for other end of start/end pair +searchpos({pattern} [, {flags} [, {stopline} [, {timeout}]]]) + List search for {pattern} +server2client({clientid}, {string}) + Number send reply string +serverlist() String get a list of available servers +setbufline( {expr}, {lnum}, {line}) + Number set line {lnum} to {line} in buffer + {expr} +setbufvar({buf}, {varname}, {val}) set {varname} in buffer {buf} to {val} +setcharsearch({dict}) Dict set character search from {dict} +setcmdpos({pos}) Number set cursor position in command-line +setenv({name}, {val}) none set environment variable +setfperm({fname}, {mode} Number set {fname} file permissions to {mode} +setline({lnum}, {line}) Number set line {lnum} to {line} +setloclist({nr}, {list} [, {action}]) + Number modify location list using {list} +setloclist({nr}, {list}, {action}, {what}) + Number modify specific location list props +setmatches({list} [, {win}]) Number restore a list of matches +setpos({expr}, {list}) Number set the {expr} position to {list} +setqflist({list} [, {action}]) Number modify quickfix list using {list} +setqflist({list}, {action}, {what}) + Number modify specific quickfix list props +setreg({n}, {v}[, {opt}]) Number set register to value and type +settabvar({nr}, {varname}, {val}) set {varname} in tab page {nr} to {val} +settabwinvar({tabnr}, {winnr}, {varname}, {val}) set {varname} in window + {winnr} in tab page {tabnr} to {val} +settagstack({nr}, {dict} [, {action}]) + Number modify tag stack using {dict} +setwinvar({nr}, {varname}, {val}) set {varname} in window {nr} to {val} +sha256({string}) String SHA256 checksum of {string} +shellescape({string} [, {special}]) + String escape {string} for use as shell + command argument +shiftwidth([{col}]) Number effective value of 'shiftwidth' +sign_define({name} [, {dict}]) Number define or update a sign +sign_define({list}) List define or update a list of signs +sign_getdefined([{name}]) List get a list of defined signs +sign_getplaced([{buf} [, {dict}]]) + List get a list of placed signs +sign_jump({id}, {group}, {buf}) + Number jump to a sign +sign_place({id}, {group}, {name}, {buf} [, {dict}]) + Number place a sign +sign_placelist({list}) List place a list of signs +sign_undefine([{name}]) Number undefine a sign +sign_undefine({list}) List undefine a list of signs +sign_unplace({group} [, {dict}]) + Number unplace a sign +sign_unplacelist({list}) List unplace a list of signs +simplify({filename}) String simplify filename as much as possible +sin({expr}) Float sine of {expr} +sinh({expr}) Float hyperbolic sine of {expr} +sockconnect({mode}, {address} [, {opts}]) + Number Connects to socket +sort({list} [, {func} [, {dict}]]) + List sort {list}, using {func} to compare +soundfold({word}) String sound-fold {word} +spellbadword() String badly spelled word at cursor +spellsuggest({word} [, {max} [, {capital}]]) + List spelling suggestions +split({expr} [, {pat} [, {keepempty}]]) + List make |List| from {pat} separated {expr} +sqrt({expr}) Float square root of {expr} +stdioopen({dict}) Number open stdio in a headless instance. +stdpath({what}) String/List returns the standard path(s) for {what} +str2float({expr} [, {quoted}]) Float convert String to Float +str2list({expr} [, {utf8}]) List convert each character of {expr} to + ASCII/UTF-8 value +str2nr({expr} [, {base} [, {quoted}]]) + Number convert String to Number +strchars({expr} [, {skipcc}]) Number character length of the String {expr} +strcharpart({str}, {start} [, {len}]) + String {len} characters of {str} at + character {start} +strdisplaywidth({expr} [, {col}]) Number display length of the String {expr} +strftime({format} [, {time}]) String format time with a specified format +strgetchar({str}, {index}) Number get char {index} from {str} +stridx({haystack}, {needle} [, {start}]) + Number index of {needle} in {haystack} +string({expr}) String String representation of {expr} value +strlen({expr}) Number length of the String {expr} +strpart({str}, {start} [, {len} [, {chars}]]) + String {len} bytes/chars of {str} at + byte {start} +strptime({format}, {timestring}) + Number Convert {timestring} to unix timestamp +strridx({haystack}, {needle} [, {start}]) + Number last index of {needle} in {haystack} +strtrans({expr}) String translate string to make it printable +strwidth({expr}) Number display cell length of the String {expr} +submatch({nr} [, {list}]) String or List + specific match in ":s" or substitute() +substitute({expr}, {pat}, {sub}, {flags}) + String all {pat} in {expr} replaced with {sub} +swapinfo({fname}) Dict information about swap file {fname} +swapname({buf}) String swap file of buffer {buf} +synID({lnum}, {col}, {trans}) Number syntax ID at {lnum} and {col} +synIDattr({synID}, {what} [, {mode}]) + String attribute {what} of syntax ID {synID} +synIDtrans({synID}) Number translated syntax ID of {synID} +synconcealed({lnum}, {col}) List info about concealing +synstack({lnum}, {col}) List stack of syntax IDs at {lnum} and {col} +system({cmd} [, {input}]) String output of shell command/filter {cmd} +systemlist({cmd} [, {input}]) List output of shell command/filter {cmd} +tabpagebuflist([{arg}]) List list of buffer numbers in tab page +tabpagenr([{arg}]) Number number of current or last tab page +tabpagewinnr({tabarg}[, {arg}]) + Number number of current window in tab page +taglist({expr}[, {filename}]) List list of tags matching {expr} +tagfiles() List tags files used +tan({expr}) Float tangent of {expr} +tanh({expr}) Float hyperbolic tangent of {expr} +tempname() String name for a temporary file +test_garbagecollect_now() none free memory right now for testing +timer_info([{id}]) List information about timers +timer_pause({id}, {pause}) none pause or unpause a timer +timer_start({time}, {callback} [, {options}]) + Number create a timer +timer_stop({timer}) none stop a timer +timer_stopall() none stop all timers +tolower({expr}) String the String {expr} switched to lowercase +toupper({expr}) String the String {expr} switched to uppercase +tr({src}, {fromstr}, {tostr}) String translate chars of {src} in {fromstr} + to chars in {tostr} +trim({text} [, {mask} [, {dir}]]) + String trim characters in {mask} from {text} +trunc({expr}) Float truncate Float {expr} +type({name}) Number type of variable {name} +undofile({name}) String undo file name for {name} +undotree() List undo file tree +uniq({list} [, {func} [, {dict}]]) + List remove adjacent duplicates from a list +values({dict}) List values in {dict} +virtcol({expr}) Number screen column of cursor or mark +visualmode([expr]) String last visual mode used +wait({timeout}, {condition}[, {interval}]) + Number Wait until {condition} is satisfied +wildmenumode() Number whether 'wildmenu' mode is active +win_execute({id}, {command} [, {silent}]) + String execute {command} in window {id} +win_findbuf({bufnr}) List find windows containing {bufnr} +win_getid([{win} [, {tab}]]) Number get |window-ID| for {win} in {tab} +win_gettype([{nr}]) String type of window {nr} +win_gotoid({expr}) Number go to |window-ID| {expr} +win_id2tabwin({expr}) List get tab and window nr from |window-ID| +win_id2win({expr}) Number get window nr from |window-ID| +win_move_separator({nr}) Number move window vertical separator +win_move_statusline({nr}) Number move window status line +win_screenpos({nr}) List get screen position of window {nr} +win_splitmove({nr}, {target} [, {options}]) + Number move window {nr} to split of {target} +winbufnr({nr}) Number buffer number of window {nr} +wincol() Number window column of the cursor +windowsversion() String MS-Windows OS version +winheight({nr}) Number height of window {nr} +winlayout([{tabnr}]) List layout of windows in tab {tabnr} +winline() Number window line of the cursor +winnr([{expr}]) Number number of current window +winrestcmd() String returns command to restore window sizes +winrestview({dict}) none restore view of current window +winsaveview() Dict save view of current window +winwidth({nr}) Number width of window {nr} +wordcount() Dict get byte/char/word statistics +writefile({object}, {fname} [, {flags}]) + Number write |Blob| or |List| of lines to file +xor({expr}, {expr}) Number bitwise XOR + +============================================================================== +2. Details *builtin-function-details* + +Not all functions are here, some have been moved to a help file covering the +specific functionality. + +abs({expr}) *abs()* + Return the absolute value of {expr}. When {expr} evaluates to + a |Float| abs() returns a |Float|. When {expr} can be + converted to a |Number| abs() returns a |Number|. Otherwise + abs() gives an error message and returns -1. + Examples: > + echo abs(1.456) +< 1.456 > + echo abs(-5.456) +< 5.456 > + echo abs(-4) +< 4 + + Can also be used as a |method|: > + Compute()->abs() + +acos({expr}) *acos()* + Return the arc cosine of {expr} measured in radians, as a + |Float| in the range of [0, pi]. + {expr} must evaluate to a |Float| or a |Number| in the range + [-1, 1]. + Examples: > + :echo acos(0) +< 1.570796 > + :echo acos(-0.5) +< 2.094395 + + Can also be used as a |method|: > + Compute()->acos() + +add({object}, {expr}) *add()* + Append the item {expr} to |List| or |Blob| {object}. Returns + the resulting |List| or |Blob|. Examples: > + :let alist = add([1, 2, 3], item) + :call add(mylist, "woodstock") +< Note that when {expr} is a |List| it is appended as a single + item. Use |extend()| to concatenate |Lists|. + When {object} is a |Blob| then {expr} must be a number. + Use |insert()| to add an item at another position. + + Can also be used as a |method|: > + mylist->add(val1)->add(val2) + +and({expr}, {expr}) *and()* + Bitwise AND on the two arguments. The arguments are converted + to a number. A List, Dict or Float argument causes an error. + Example: > + :let flag = and(bits, 0x80) +< Can also be used as a |method|: > + :let flag = bits->and(0x80) + +api_info() *api_info()* + Returns Dictionary of |api-metadata|. + + View it in a nice human-readable format: > + :lua print(vim.inspect(vim.fn.api_info())) + +append({lnum}, {text}) *append()* + When {text} is a |List|: Append each item of the |List| as a + text line below line {lnum} in the current buffer. + Otherwise append {text} as one text line below line {lnum} in + the current buffer. + {lnum} can be zero to insert a line before the first one. + {lnum} is used like with |getline()|. + Returns 1 for failure ({lnum} out of range or out of memory), + 0 for success. Example: > + :let failed = append(line('$'), "# THE END") + :let failed = append(0, ["Chapter 1", "the beginning"]) + +< Can also be used as a |method| after a List: > + mylist->append(lnum) + +appendbufline({buf}, {lnum}, {text}) *appendbufline()* + Like |append()| but append the text in buffer {expr}. + + This function works only for loaded buffers. First call + |bufload()| if needed. + + For the use of {buf}, see |bufname()|. + + {lnum} is used like with |append()|. Note that using |line()| + would use the current buffer, not the one appending to. + Use "$" to append at the end of the buffer. + + On success 0 is returned, on failure 1 is returned. + + If {buf} is not a valid buffer or {lnum} is not valid, an + error message is given. Example: > + :let failed = appendbufline(13, 0, "# THE START") +< + Can also be used as a |method| after a List: > + mylist->appendbufline(buf, lnum) + +argc([{winid}]) *argc()* + The result is the number of files in the argument list. See + |arglist|. + If {winid} is not supplied, the argument list of the current + window is used. + If {winid} is -1, the global argument list is used. + Otherwise {winid} specifies the window of which the argument + list is used: either the window number or the window ID. + Returns -1 if the {winid} argument is invalid. + + *argidx()* +argidx() The result is the current index in the argument list. 0 is + the first file. argc() - 1 is the last one. See |arglist|. + + *arglistid()* +arglistid([{winnr} [, {tabnr}]]) + Return the argument list ID. This is a number which + identifies the argument list being used. Zero is used for the + global argument list. See |arglist|. + Returns -1 if the arguments are invalid. + + Without arguments use the current window. + With {winnr} only use this window in the current tab page. + With {winnr} and {tabnr} use the window in the specified tab + page. + {winnr} can be the window number or the |window-ID|. + + *argv()* +argv([{nr} [, {winid}]]) + The result is the {nr}th file in the argument list. See + |arglist|. "argv(0)" is the first one. Example: > + :let i = 0 + :while i < argc() + : let f = escape(fnameescape(argv(i)), '.') + : exe 'amenu Arg.' . f . ' :e ' . f . '' + : let i = i + 1 + :endwhile +< Without the {nr} argument, or when {nr} is -1, a |List| with + the whole |arglist| is returned. + + The {winid} argument specifies the window ID, see |argc()|. + For the Vim command line arguments see |v:argv|. + +asin({expr}) *asin()* + Return the arc sine of {expr} measured in radians, as a |Float| + in the range of [-pi/2, pi/2]. + {expr} must evaluate to a |Float| or a |Number| in the range + [-1, 1]. + Examples: > + :echo asin(0.8) +< 0.927295 > + :echo asin(-0.5) +< -0.523599 + + Can also be used as a |method|: > + Compute()->asin() + + +assert_ functions are documented here: |assert-functions-details| + + +atan({expr}) *atan()* + Return the principal value of the arc tangent of {expr}, in + the range [-pi/2, +pi/2] radians, as a |Float|. + {expr} must evaluate to a |Float| or a |Number|. + Examples: > + :echo atan(100) +< 1.560797 > + :echo atan(-4.01) +< -1.326405 + + Can also be used as a |method|: > + Compute()->atan() + +atan2({expr1}, {expr2}) *atan2()* + Return the arc tangent of {expr1} / {expr2}, measured in + radians, as a |Float| in the range [-pi, pi]. + {expr1} and {expr2} must evaluate to a |Float| or a |Number|. + Examples: > + :echo atan2(-1, 1) +< -0.785398 > + :echo atan2(1, -1) +< 2.356194 + + Can also be used as a |method|: > + Compute()->atan2(1) + + *browse()* +browse({save}, {title}, {initdir}, {default}) + Put up a file requester. This only works when "has("browse")" + returns |TRUE| (only in some GUI versions). + The input fields are: + {save} when |TRUE|, select file to write + {title} title for the requester + {initdir} directory to start browsing in + {default} default file name + An empty string is returned when the "Cancel" button is hit, + something went wrong, or browsing is not possible. + + *browsedir()* +browsedir({title}, {initdir}) + Put up a directory requester. This only works when + "has("browse")" returns |TRUE| (only in some GUI versions). + On systems where a directory browser is not supported a file + browser is used. In that case: select a file in the directory + to be used. + The input fields are: + {title} title for the requester + {initdir} directory to start browsing in + When the "Cancel" button is hit, something went wrong, or + browsing is not possible, an empty string is returned. + +bufadd({name}) *bufadd()* + Add a buffer to the buffer list with String {name}. + If a buffer for file {name} already exists, return that buffer + number. Otherwise return the buffer number of the newly + created buffer. When {name} is an empty string then a new + buffer is always created. + The buffer will not have 'buflisted' set and not be loaded + yet. To add some text to the buffer use this: > + let bufnr = bufadd('someName') + call bufload(bufnr) + call setbufline(bufnr, 1, ['some', 'text']) +< Can also be used as a |method|: > + let bufnr = 'somename'->bufadd() + +bufexists({buf}) *bufexists()* + The result is a Number, which is |TRUE| if a buffer called + {buf} exists. + If the {buf} argument is a number, buffer numbers are used. + Number zero is the alternate buffer for the current window. + + If the {buf} argument is a string it must match a buffer name + exactly. The name can be: + - Relative to the current directory. + - A full path. + - The name of a buffer with 'buftype' set to "nofile". + - A URL name. + Unlisted buffers will be found. + Note that help files are listed by their short name in the + output of |:buffers|, but bufexists() requires using their + long name to be able to find them. + bufexists() may report a buffer exists, but to use the name + with a |:buffer| command you may need to use |expand()|. Esp + for MS-Windows 8.3 names in the form "c:\DOCUME~1" + Use "bufexists(0)" to test for the existence of an alternate + file name. + + Can also be used as a |method|: > + let exists = 'somename'->bufexists() + +buflisted({buf}) *buflisted()* + The result is a Number, which is |TRUE| if a buffer called + {buf} exists and is listed (has the 'buflisted' option set). + The {buf} argument is used like with |bufexists()|. + + Can also be used as a |method|: > + let listed = 'somename'->buflisted() + +bufload({buf}) *bufload()* + Ensure the buffer {buf} is loaded. When the buffer name + refers to an existing file then the file is read. Otherwise + the buffer will be empty. If the buffer was already loaded + then there is no change. + If there is an existing swap file for the file of the buffer, + there will be no dialog, the buffer will be loaded anyway. + The {buf} argument is used like with |bufexists()|. + + Can also be used as a |method|: > + eval 'somename'->bufload() + +bufloaded({buf}) *bufloaded()* + The result is a Number, which is |TRUE| if a buffer called + {buf} exists and is loaded (shown in a window or hidden). + The {buf} argument is used like with |bufexists()|. + + Can also be used as a |method|: > + let loaded = 'somename'->bufloaded() + +bufname([{buf}]) *bufname()* + The result is the name of a buffer. Mostly as it is displayed + by the `:ls` command, but not using special names such as + "[No Name]". + If {buf} is omitted the current buffer is used. + If {buf} is a Number, that buffer number's name is given. + Number zero is the alternate buffer for the current window. + If {buf} is a String, it is used as a |file-pattern| to match + with the buffer names. This is always done like 'magic' is + set and 'cpoptions' is empty. When there is more than one + match an empty string is returned. + "" or "%" can be used for the current buffer, "#" for the + alternate buffer. + A full match is preferred, otherwise a match at the start, end + or middle of the buffer name is accepted. If you only want a + full match then put "^" at the start and "$" at the end of the + pattern. + Listed buffers are found first. If there is a single match + with a listed buffer, that one is returned. Next unlisted + buffers are searched for. + If the {buf} is a String, but you want to use it as a buffer + number, force it to be a Number by adding zero to it: > + :echo bufname("3" + 0) +< Can also be used as a |method|: > + echo bufnr->bufname() + +< If the buffer doesn't exist, or doesn't have a name, an empty + string is returned. > + bufname("#") alternate buffer name + 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 + the `:ls` command. For the use of {buf}, see |bufname()| + above. + If the buffer doesn't exist, -1 is returned. Or, if the + {create} argument is present and TRUE, a new, unlisted, + buffer is created and its number is returned. + bufnr("$") is the last buffer: > + :let last_buffer = bufnr("$") +< The result is a Number, which is the highest buffer number + of existing buffers. Note that not all buffers with a smaller + number necessarily exist, because ":bwipeout" may have removed + them. Use bufexists() to test for the existence of a buffer. + + Can also be used as a |method|: > + echo bufref->bufnr() + +bufwinid({buf}) *bufwinid()* + The result is a Number, which is the |window-ID| of the first + window associated with buffer {buf}. For the use of {buf}, + see |bufname()| above. If buffer {buf} doesn't exist or + there is no such window, -1 is returned. Example: > + + echo "A window containing buffer 1 is " . (bufwinid(1)) +< + Only deals with the current tab page. + + Can also be used as a |method|: > + FindBuffer()->bufwinid() + +bufwinnr({buf}) *bufwinnr()* + Like |bufwinid()| but return the window number instead of the + |window-ID|. + If buffer {buf} doesn't exist or there is no such window, -1 + is returned. Example: > + + echo "A window containing buffer 1 is " . (bufwinnr(1)) + +< The number can be used with |CTRL-W_w| and ":wincmd w" + |:wincmd|. + + Can also be used as a |method|: > + FindBuffer()->bufwinnr() + +byte2line({byte}) *byte2line()* + Return the line number that contains the character at byte + count {byte} in the current buffer. This includes the + end-of-line character, depending on the 'fileformat' option + for the current buffer. The first character has byte count + one. + Also see |line2byte()|, |go| and |:goto|. + + Can also be used as a |method|: > + GetOffset()->byte2line() + +byteidx({expr}, {nr}) *byteidx()* + Return byte index of the {nr}'th character in the String + {expr}. Use zero for the first character, it then returns + zero. + If there are no multibyte characters the returned value is + equal to {nr}. + Composing characters are not counted separately, their byte + length is added to the preceding base character. See + |byteidxcomp()| below for counting composing characters + separately. + Example : > + echo matchstr(str, ".", byteidx(str, 3)) +< will display the fourth character. Another way to do the + same: > + let s = strpart(str, byteidx(str, 3)) + echo strpart(s, 0, byteidx(s, 1)) +< Also see |strgetchar()| and |strcharpart()|. + + If there are less than {nr} characters -1 is returned. + If there are exactly {nr} characters the length of the string + in bytes is returned. + + Can also be used as a |method|: > + GetName()->byteidx(idx) + +byteidxcomp({expr}, {nr}) *byteidxcomp()* + Like byteidx(), except that a composing character is counted + as a separate character. Example: > + let s = 'e' . nr2char(0x301) + echo byteidx(s, 1) + echo byteidxcomp(s, 1) + echo byteidxcomp(s, 2) +< The first and third echo result in 3 ('e' plus composing + character is 3 bytes), the second echo results in 1 ('e' is + one byte). + Only works differently from byteidx() when 'encoding' is set to + a Unicode encoding. + + Can also be used as a |method|: > + GetName()->byteidxcomp(idx) + +call({func}, {arglist} [, {dict}]) *call()* *E699* + Call function {func} with the items in |List| {arglist} as + arguments. + {func} can either be a |Funcref| or the name of a function. + a:firstline and a:lastline are set to the cursor line. + Returns the return value of the called function. + {dict} is for functions with the "dict" attribute. It will be + used to set the local variable "self". |Dictionary-function| + + Can also be used as a |method|: > + GetFunc()->call([arg, arg], dict) + +ceil({expr}) *ceil()* + Return the smallest integral value greater than or equal to + {expr} as a |Float| (round up). + {expr} must evaluate to a |Float| or a |Number|. + Examples: > + echo ceil(1.456) +< 2.0 > + echo ceil(-5.456) +< -5.0 > + echo ceil(4.0) +< 4.0 + + Can also be used as a |method|: > + Compute()->ceil() + +changenr() *changenr()* + Return the number of the most recent change. This is the same + number as what is displayed with |:undolist| and can be used + with the |:undo| command. + When a change was made it is the number of that change. After + redo it is the number of the redone change. After undo it is + one less than the number of the undone change. + +chanclose({id}[, {stream}]) *chanclose()* + Close a channel or a specific stream associated with it. + For a job, {stream} can be one of "stdin", "stdout", + "stderr" or "rpc" (closes stdin/stdout for a job started + with `"rpc":v:true`) If {stream} is omitted, all streams + are closed. If the channel is a pty, this will then close the + pty master, sending SIGHUP to the job process. + For a socket, there is only one stream, and {stream} should be + ommited. + +chansend({id}, {data}) *chansend()* + Send data to channel {id}. For a job, it writes it to the + stdin of the process. For the stdio channel |channel-stdio|, + it writes to Nvim's stdout. Returns the number of bytes + written if the write succeeded, 0 otherwise. + See |channel-bytes| for more information. + + {data} may be a string, string convertible, |Blob|, or a list. + If {data} is a list, the items will be joined by newlines; any + newlines in an item will be sent as NUL. To send a final + newline, include a final empty string. Example: > + :call chansend(id, ["abc", "123\n456", ""]) +< will send "abc123456". + + chansend() writes raw data, not RPC messages. If the channel + was created with `"rpc":v:true` then the channel expects RPC + messages, use |rpcnotify()| and |rpcrequest()| instead. + + +char2nr({string} [, {utf8}]) *char2nr()* + Return number value of the first char in {string}. + Examples: > + char2nr(" ") returns 32 + char2nr("ABC") returns 65 + char2nr("á") returns 225 + char2nr("á"[0]) returns 195 + char2nr("\") returns 128 +< Non-ASCII characters are always treated as UTF-8 characters. + {utf8} is ignored, it exists only for backwards-compatibility. + A combining character is a separate character. + |nr2char()| does the opposite. + + Can also be used as a |method|: > + GetChar()->char2nr() +< + *charidx()* +charidx({string}, {idx} [, {countcc}]) + Return the character index of the byte at {idx} in {string}. + The index of the first character is zero. + If there are no multibyte characters the returned value is + equal to {idx}. + When {countcc} is omitted or |FALSE|, then composing characters + are not counted separately, their byte length is + added to the preceding base character. + When {countcc} is |TRUE|, then composing characters are + counted as separate characters. + Returns -1 if the arguments are invalid or if {idx} is greater + than the index of the last byte in {string}. An error is + given if the first argument is not a string, the second + argument is not a number or when the third argument is present + and is not zero or one. + See |byteidx()| and |byteidxcomp()| for getting the byte index + from the character index. + Examples: > + echo charidx('áb́ć', 3) returns 1 + echo charidx('áb́ć', 6, 1) returns 4 + echo charidx('áb́ć', 16) returns -1 +< + Can also be used as a |method|: > + GetName()->charidx(idx) + +chdir({dir}) *chdir()* + Change the current working directory to {dir}. The scope of + the directory change depends on the directory of the current + window: + - If the current window has a window-local directory + (|:lcd|), then changes the window local directory. + - Otherwise, if the current tabpage has a local + directory (|:tcd|) then changes the tabpage local + directory. + - Otherwise, changes the global directory. + If successful, returns the previous working directory. Pass + this to another chdir() to restore the directory. + On failure, returns an empty string. + + Example: > + let save_dir = chdir(newdir) + if save_dir + " ... do some work + call chdir(save_dir) + endif +< +cindent({lnum}) *cindent()* + Get the amount of indent for line {lnum} according the C + indenting rules, as with 'cindent'. + The indent is counted in spaces, the value of 'tabstop' is + relevant. {lnum} is used just like in |getline()|. + When {lnum} is invalid -1 is returned. + See |C-indenting|. + + Can also be used as a |method|: > + GetLnum()->cindent() + +clearmatches([{win}]) *clearmatches()* + Clears all matches previously defined for the current window + by |matchadd()| and the |:match| commands. + If {win} is specified, use the window with this number or + window ID instead of the current window. + + Can also be used as a |method|: > + GetWin()->clearmatches() +< + *col()* +col({expr}) The result is a Number, which is the byte index of the column + position given with {expr}. The accepted positions are: + . the cursor position + $ the end of the cursor line (the result is the + number of bytes in the cursor line plus one) + 'x position of mark x (if the mark is not set, 0 is + returned) + v In Visual mode: the start of the Visual area (the + cursor is the end). When not in Visual mode + returns the cursor position. Differs from |'<| in + that it's updated right away. + Additionally {expr} can be [lnum, col]: a |List| with the line + and column number. Most useful when the column is "$", to get + the last column of a specific line. When "lnum" or "col" is + out of range then col() returns zero. + To get the line number use |line()|. To get both use + |getpos()|. + For the screen column position use |virtcol()|. + Note that only marks in the current file can be used. + Examples: > + col(".") column of cursor + col("$") length of cursor line plus one + col("'t") column of mark t + col("'" . markname) column of mark markname +< The first column is 1. 0 is returned for an error. + For an uppercase mark the column may actually be in another + buffer. + For the cursor position, when 'virtualedit' is active, the + column is one higher if the cursor is after the end of the + line. This can be used to obtain the column in Insert mode: > + :imap :let save_ve = &ve + \:set ve=all + \:echo col(".") . "\n" + \let &ve = save_ve + +< Can also be used as a |method|: > + GetPos()->col() +< + +complete({startcol}, {matches}) *complete()* *E785* + Set the matches for Insert mode completion. + Can only be used in Insert mode. You need to use a mapping + with CTRL-R = (see |i_CTRL-R|). It does not work after CTRL-O + or with an expression mapping. + {startcol} is the byte offset in the line where the completed + text start. The text up to the cursor is the original text + that will be replaced by the matches. Use col('.') for an + empty string. "col('.') - 1" will replace one character by a + match. + {matches} must be a |List|. Each |List| item is one match. + See |complete-items| for the kind of items that are possible. + "longest" in 'completeopt' is ignored. + Note that the after calling this function you need to avoid + inserting anything that would cause completion to stop. + The match can be selected with CTRL-N and CTRL-P as usual with + Insert mode completion. The popup menu will appear if + specified, see |ins-completion-menu|. + Example: > + inoremap =ListMonths() + + func! ListMonths() + call complete(col('.'), ['January', 'February', 'March', + \ 'April', 'May', 'June', 'July', 'August', 'September', + \ 'October', 'November', 'December']) + return '' + endfunc +< This isn't very useful, but it shows how it works. Note that + an empty string is returned to avoid a zero being inserted. + + Can also be used as a |method|, the base is passed as the + second argument: > + GetMatches()->complete(col('.')) + +complete_add({expr}) *complete_add()* + Add {expr} to the list of matches. Only to be used by the + function specified with the 'completefunc' option. + Returns 0 for failure (empty string or out of memory), + 1 when the match was added, 2 when the match was already in + the list. + See |complete-functions| for an explanation of {expr}. It is + the same as one item in the list that 'omnifunc' would return. + + Can also be used as a |method|: > + GetMoreMatches()->complete_add() + +complete_check() *complete_check()* + Check for a key typed while looking for completion matches. + This is to be used when looking for matches takes some time. + Returns |TRUE| when searching for matches is to be aborted, + zero otherwise. + Only to be used by the function specified with the + 'completefunc' option. + + +complete_info([{what}]) *complete_info()* + Returns a |Dictionary| with information about Insert mode + completion. See |ins-completion|. + The items are: + mode Current completion mode name string. + See |complete_info_mode| for the values. + pum_visible |TRUE| if popup menu is visible. + See |pumvisible()|. + items List of completion matches. Each item is a + dictionary containing the entries "word", + "abbr", "menu", "kind", "info" and "user_data". + See |complete-items|. + selected Selected item index. First index is zero. + Index is -1 if no item is selected (showing + typed text only, or the last completion after + no item is selected when using the or + keys) + inserted Inserted string. [NOT IMPLEMENT YET] + + *complete_info_mode* + mode values are: + "" Not in completion mode + "keyword" Keyword completion |i_CTRL-X_CTRL-N| + "ctrl_x" Just pressed CTRL-X |i_CTRL-X| + "scroll" Scrolling with |i_CTRL-X_CTRL-E| or + |i_CTRL-X_CTRL-Y| + "whole_line" Whole lines |i_CTRL-X_CTRL-L| + "files" File names |i_CTRL-X_CTRL-F| + "tags" Tags |i_CTRL-X_CTRL-]| + "path_defines" Definition completion |i_CTRL-X_CTRL-D| + "path_patterns" Include completion |i_CTRL-X_CTRL-I| + "dictionary" Dictionary |i_CTRL-X_CTRL-K| + "thesaurus" Thesaurus |i_CTRL-X_CTRL-T| + "cmdline" Vim Command line |i_CTRL-X_CTRL-V| + "function" User defined completion |i_CTRL-X_CTRL-U| + "omni" Omni completion |i_CTRL-X_CTRL-O| + "spell" Spelling suggestions |i_CTRL-X_s| + "eval" |complete()| completion + "unknown" Other internal modes + + If the optional {what} list argument is supplied, then only + the items listed in {what} are returned. Unsupported items in + {what} are silently ignored. + + To get the position and size of the popup menu, see + |pum_getpos()|. It's also available in |v:event| during the + |CompleteChanged| event. + + Examples: > + " Get all items + call complete_info() + " Get only 'mode' + call complete_info(['mode']) + " Get only 'mode' and 'pum_visible' + call complete_info(['mode', 'pum_visible']) + +< Can also be used as a |method|: > + GetItems()->complete_info() +< + *confirm()* +confirm({msg} [, {choices} [, {default} [, {type}]]]) + Confirm() offers the user a dialog, from which a choice can be + made. It returns the number of the choice. For the first + choice this is 1. + + {msg} is displayed in a dialog with {choices} as the + alternatives. When {choices} is missing or empty, "&OK" is + used (and translated). + {msg} is a String, use '\n' to include a newline. Only on + some systems the string is wrapped when it doesn't fit. + + {choices} is a String, with the individual choices separated + by '\n', e.g. > + confirm("Save changes?", "&Yes\n&No\n&Cancel") +< The letter after the '&' is the shortcut key for that choice. + Thus you can type 'c' to select "Cancel". The shortcut does + not need to be the first letter: > + confirm("file has been modified", "&Save\nSave &All") +< For the console, the first letter of each choice is used as + the default shortcut key. Case is ignored. + + The optional {type} String argument gives the type of dialog. + It can be one of these values: "Error", "Question", "Info", + "Warning" or "Generic". Only the first character is relevant. + When {type} is omitted, "Generic" is used. + + The optional {type} argument gives the type of dialog. This + is only used for the icon of the Win32 GUI. It can be one of + these values: "Error", "Question", "Info", "Warning" or + "Generic". Only the first character is relevant. + When {type} is omitted, "Generic" is used. + + If the user aborts the dialog by pressing , CTRL-C, + or another valid interrupt key, confirm() returns 0. + + An example: > + :let choice = confirm("What do you want?", "&Apples\n&Oranges\n&Bananas", 2) + :if choice == 0 + : echo "make up your mind!" + :elseif choice == 3 + : echo "tasteful" + :else + : echo "I prefer bananas myself." + :endif +< In a GUI dialog, buttons are used. The layout of the buttons + depends on the 'v' flag in 'guioptions'. If it is included, + the buttons are always put vertically. Otherwise, confirm() + tries to put the buttons in one horizontal line. If they + don't fit, a vertical layout is used anyway. For some systems + the horizontal layout is always used. + + Can also be used as a |method|in: > + BuildMessage()->confirm("&Yes\n&No") +< + *copy()* +copy({expr}) Make a copy of {expr}. For Numbers and Strings this isn't + different from using {expr} directly. + When {expr} is a |List| a shallow copy is created. This means + that the original |List| can be changed without changing the + copy, and vice versa. But the items are identical, thus + changing an item changes the contents of both |Lists|. + A |Dictionary| is copied in a similar way as a |List|. + Also see |deepcopy()|. + Can also be used as a |method|: > + mylist->copy() + +cos({expr}) *cos()* + Return the cosine of {expr}, measured in radians, as a |Float|. + {expr} must evaluate to a |Float| or a |Number|. + Examples: > + :echo cos(100) +< 0.862319 > + :echo cos(-4.01) +< -0.646043 + + Can also be used as a |method|: > + Compute()->cos() + +cosh({expr}) *cosh()* + Return the hyperbolic cosine of {expr} as a |Float| in the range + [1, inf]. + {expr} must evaluate to a |Float| or a |Number|. + Examples: > + :echo cosh(0.5) +< 1.127626 > + :echo cosh(-0.5) +< -1.127626 + + Can also be used as a |method|: > + Compute()->cosh() + +count({comp}, {expr} [, {ic} [, {start}]]) *count()* + Return the number of times an item with value {expr} appears + in |String|, |List| or |Dictionary| {comp}. + + If {start} is given then start with the item with this index. + {start} can only be used with a |List|. + + When {ic} is given and it's |TRUE| then case is ignored. + + When {comp} is a string then the number of not overlapping + occurrences of {expr} is returned. Zero is returned when + {expr} is an empty string. + + Can also be used as a |method|: > + mylist->count(val) +< + *cscope_connection()* +cscope_connection([{num} , {dbpath} [, {prepend}]]) + Checks for the existence of a |cscope| connection. If no + parameters are specified, then the function returns: + 0, if there are no cscope connections; + 1, if there is at least one cscope connection. + + If parameters are specified, then the value of {num} + determines how existence of a cscope connection is checked: + + {num} Description of existence check + ----- ------------------------------ + 0 Same as no parameters (e.g., "cscope_connection()"). + 1 Ignore {prepend}, and use partial string matches for + {dbpath}. + 2 Ignore {prepend}, and use exact string matches for + {dbpath}. + 3 Use {prepend}, use partial string matches for both + {dbpath} and {prepend}. + 4 Use {prepend}, use exact string matches for both + {dbpath} and {prepend}. + + Note: All string comparisons are case sensitive! + + Examples. Suppose we had the following (from ":cs show"): > + + # pid database name prepend path + 0 27664 cscope.out /usr/local +< + Invocation Return Val ~ + ---------- ---------- > + cscope_connection() 1 + cscope_connection(1, "out") 1 + cscope_connection(2, "out") 0 + cscope_connection(3, "out") 0 + cscope_connection(3, "out", "local") 1 + cscope_connection(4, "out") 0 + cscope_connection(4, "out", "local") 0 + cscope_connection(4, "cscope.out", "/usr/local") 1 +< + +ctxget([{index}]) *ctxget()* + Returns a |Dictionary| representing the |context| at {index} + from the top of the |context-stack| (see |context-dict|). + If {index} is not given, it is assumed to be 0 (i.e.: top). + +ctxpop() *ctxpop()* + Pops and restores the |context| at the top of the + |context-stack|. + +ctxpush([{types}]) *ctxpush()* + Pushes the current editor state (|context|) on the + |context-stack|. + If {types} is given and is a |List| of |String|s, it specifies + which |context-types| to include in the pushed context. + Otherwise, all context types are included. + +ctxset({context}[, {index}]) *ctxset()* + Sets the |context| at {index} from the top of the + |context-stack| to that represented by {context}. + {context} is a Dictionary with context data (|context-dict|). + If {index} is not given, it is assumed to be 0 (i.e.: top). + +ctxsize() *ctxsize()* + Returns the size of the |context-stack|. + +cursor({lnum}, {col} [, {off}]) *cursor()* +cursor({list}) + Positions the cursor at the column (byte count) {col} in the + line {lnum}. The first column is one. + + When there is one argument {list} this is used as a |List| + with two, three or four item: + [{lnum}, {col}] + [{lnum}, {col}, {off}] + [{lnum}, {col}, {off}, {curswant}] + This is like the return value of |getpos()| or |getcurpos()|, + but without the first item. + + Does not change the jumplist. + If {lnum} is greater than the number of lines in the buffer, + the cursor will be positioned at the last line in the buffer. + If {lnum} is zero, the cursor will stay in the current line. + If {col} is greater than the number of bytes in the line, + the cursor will be positioned at the last character in the + line. + If {col} is zero, the cursor will stay in the current column. + If {curswant} is given it is used to set the preferred column + for vertical movement. Otherwise {col} is used. + + When 'virtualedit' is used {off} specifies the offset in + screen columns from the start of the character. E.g., a + position within a or after the last character. + Returns 0 when the position could be set, -1 otherwise. + + Can also be used as a |method|: > + GetCursorPos()->cursor() + +deepcopy({expr}[, {noref}]) *deepcopy()* *E698* + Make a copy of {expr}. For Numbers and Strings this isn't + different from using {expr} directly. + When {expr} is a |List| a full copy is created. This means + that the original |List| can be changed without changing the + copy, and vice versa. When an item is a |List|, a copy for it + is made, recursively. Thus changing an item in the copy does + not change the contents of the original |List|. + + When {noref} is omitted or zero a contained |List| or + |Dictionary| is only copied once. All references point to + this single copy. With {noref} set to 1 every occurrence of a + |List| or |Dictionary| results in a new copy. This also means + that a cyclic reference causes deepcopy() to fail. + *E724* + Nesting is possible up to 100 levels. When there is an item + that refers back to a higher level making a deep copy with + {noref} set to 1 will fail. + Also see |copy()|. + + Can also be used as a |method|: > + GetObject()->deepcopy() + +delete({fname} [, {flags}]) *delete()* + Without {flags} or with {flags} empty: Deletes the file by the + name {fname}. This also works when {fname} is a symbolic link. + A symbolic link itself is deleted, not what it points to. + + When {flags} is "d": Deletes the directory by the name + {fname}. This fails when directory {fname} is not empty. + + When {flags} is "rf": Deletes the directory by the name + {fname} and everything in it, recursively. BE CAREFUL! + Note: on MS-Windows it is not possible to delete a directory + that is being used. + + The result is a Number, which is 0/false if the delete + operation was successful and -1/true when the deletion failed + or partly failed. + + Can also be used as a |method|: > + GetName()->delete() + +deletebufline({buf}, {first}[, {last}]) *deletebufline()* + Delete lines {first} to {last} (inclusive) from buffer {buf}. + If {last} is omitted then delete line {first} only. + On success 0 is returned, on failure 1 is returned. + + This function works only for loaded buffers. First call + |bufload()| if needed. + + For the use of {buf}, see |bufname()| above. + + {first} and {last} are used like with |setline()|. Note that + when using |line()| this refers to the current buffer. Use "$" + to refer to the last line in buffer {buf}. + + Can also be used as a |method|: > + GetBuffer()->deletebufline(1) +< +dictwatcheradd({dict}, {pattern}, {callback}) *dictwatcheradd()* + Adds a watcher to a dictionary. A dictionary watcher is + identified by three components: + + - A dictionary({dict}); + - A key pattern({pattern}). + - A function({callback}). + + After this is called, every change on {dict} and on keys + matching {pattern} will result in {callback} being invoked. + + For example, to watch all global variables: > + silent! call dictwatcherdel(g:, '*', 'OnDictChanged') + function! OnDictChanged(d,k,z) + echomsg string(a:k) string(a:z) + endfunction + call dictwatcheradd(g:, '*', 'OnDictChanged') +< + For now {pattern} only accepts very simple patterns that can + contain a '*' at the end of the string, in which case it will + match every key that begins with the substring before the '*'. + That means if '*' is not the last character of {pattern}, only + keys that are exactly equal as {pattern} will be matched. + + The {callback} receives three arguments: + + - The dictionary being watched. + - The key which changed. + - A dictionary containing the new and old values for the key. + + The type of change can be determined by examining the keys + present on the third argument: + + - If contains both `old` and `new`, the key was updated. + - If it contains only `new`, the key was added. + - If it contains only `old`, the key was deleted. + + This function can be used by plugins to implement options with + validation and parsing logic. + +dictwatcherdel({dict}, {pattern}, {callback}) *dictwatcherdel()* + Removes a watcher added with |dictwatcheradd()|. All three + arguments must match the ones passed to |dictwatcheradd()| in + order for the watcher to be successfully deleted. + + *did_filetype()* +did_filetype() Returns |TRUE| when autocommands are being executed and the + FileType event has been triggered at least once. Can be used + to avoid triggering the FileType event again in the scripts + that detect the file type. |FileType| + Returns |FALSE| when `:setf FALLBACK` was used. + When editing another file, the counter is reset, thus this + really checks if the FileType event has been triggered for the + current buffer. This allows an autocommand that starts + editing another buffer to set 'filetype' and load a syntax + file. + +diff_filler({lnum}) *diff_filler()* + Returns the number of filler lines above line {lnum}. + These are the lines that were inserted at this point in + another diff'ed window. These filler lines are shown in the + display but don't exist in the buffer. + {lnum} is used like with |getline()|. Thus "." is the current + line, "'m" mark m, etc. + Returns 0 if the current window is not in diff mode. + + Can also be used as a |method|: > + GetLnum()->diff_filler() + +diff_hlID({lnum}, {col}) *diff_hlID()* + Returns the highlight ID for diff mode at line {lnum} column + {col} (byte index). When the current line does not have a + diff change zero is returned. + {lnum} is used like with |getline()|. Thus "." is the current + line, "'m" mark m, etc. + {col} is 1 for the leftmost column, {lnum} is 1 for the first + line. + The highlight ID can be used with |synIDattr()| to obtain + syntax information about the highlighting. + + Can also be used as a |method|: > + GetLnum()->diff_hlID(col) + +empty({expr}) *empty()* + Return the Number 1 if {expr} is empty, zero otherwise. + - A |List| or |Dictionary| is empty when it does not have any + items. + - A |String| is empty when its length is zero. + - A |Number| and |Float| are empty when their value is zero. + - |v:false| and |v:null| are empty, |v:true| is not. + - A |Blob| is empty when its length is zero. + + Can also be used as a |method|: > + mylist->empty() + +environ() *environ()* + Return all of environment variables as dictionary. You can + check if an environment variable exists like this: > + :echo has_key(environ(), 'HOME') +< Note that the variable name may be CamelCase; to ignore case + use this: > + :echo index(keys(environ()), 'HOME', 0, 1) != -1 + +escape({string}, {chars}) *escape()* + Escape the characters in {chars} that occur in {string} with a + backslash. Example: > + :echo escape('c:\program files\vim', ' \') +< results in: > + c:\\program\ files\\vim +< Also see |shellescape()| and |fnameescape()|. + + Can also be used as a |method|: > + GetText()->escape(' \') +< + *eval()* +eval({string}) Evaluate {string} and return the result. Especially useful to + turn the result of |string()| back into the original value. + This works for Numbers, Floats, Strings, Blobs and composites + of them. Also works for |Funcref|s that refer to existing + functions. + + Can also be used as a |method|: > + argv->join()->eval() + +eventhandler() *eventhandler()* + Returns 1 when inside an event handler. That is that Vim got + interrupted while waiting for the user to type a character, + e.g., when dropping a file on Vim. This means interactive + commands cannot be used. Otherwise zero is returned. + +executable({expr}) *executable()* + This function checks if an executable with the name {expr} + exists. {expr} must be the name of the program without any + arguments. + executable() uses the value of $PATH and/or the normal + searchpath for programs. *PATHEXT* + On MS-Windows the ".exe", ".bat", etc. can optionally be + included. Then the extensions in $PATHEXT are tried. Thus if + "foo.exe" does not exist, "foo.exe.bat" can be found. If + $PATHEXT is not set then ".exe;.com;.bat;.cmd" is used. A dot + by itself can be used in $PATHEXT to try using the name + without an extension. When 'shell' looks like a Unix shell, + then the name is also tried without adding an extension. + On MS-Windows it only checks if the file exists and is not a + directory, not if it's really executable. + On Windows an executable in the same directory as Vim is + always found (it is added to $PATH at |startup|). + The result is a Number: + 1 exists + 0 does not exist + -1 not implemented on this system + |exepath()| can be used to get the full path of an executable. + + Can also be used as a |method|: > + GetCommand()->executable() + +execute({command} [, {silent}]) *execute()* + Execute {command} and capture its output. + If {command} is a |String|, returns {command} output. + If {command} is a |List|, returns concatenated outputs. + Examples: > + echo execute('echon "foo"') +< foo > + echo execute(['echon "foo"', 'echon "bar"']) +< foobar + + The optional {silent} argument can have these values: + "" no `:silent` used + "silent" `:silent` used + "silent!" `:silent!` used + The default is "silent". Note that with "silent!", unlike + `:redir`, error messages are dropped. + + To get a list of lines use |split()| on the result: > + split(execute('args'), "\n") + +< This function is not available in the |sandbox|. + Note: If nested, an outer execute() will not observe output of + the inner calls. + Note: Text attributes (highlights) are not captured. + To execute a command in another window than the current one + use `win_execute()`. + + Can also be used as a |method|: > + GetCommand()->execute() + +exepath({expr}) *exepath()* + Returns the full path of {expr} if it is an executable and + given as a (partial or full) path or is found in $PATH. + Returns empty string otherwise. + If {expr} starts with "./" the |current-directory| is used. + + 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. + + For checking for a supported feature use |has()|. + For checking if a file exists use |filereadable()|. + + The {expr} argument is a string, which contains one of these: + &option-name Vim option (only checks if it exists, + not if it really works) + +option-name Vim option that works. + $ENVNAME environment variable (could also be + done by comparing with an empty + string) + *funcname built-in function (see |functions|) + or user defined function (see + |user-function|). Also works for a + variable that is a Funcref. + varname internal variable (see + |internal-variables|). Also works + for |curly-braces-names|, |Dictionary| + entries, |List| items, etc. Beware + that evaluating an index may cause an + error message for an invalid + expression. E.g.: > + :let l = [1, 2, 3] + :echo exists("l[5]") +< 0 > + :echo exists("l[xx]") +< E121: Undefined variable: xx + 0 + :cmdname Ex command: built-in command, user + command or command modifier |:command|. + Returns: + 1 for match with start of a command + 2 full match with a command + 3 matches several user commands + To check for a supported command + always check the return value to be 2. + :2match The |:2match| command. + :3match The |:3match| command. + #event autocommand defined for this event + #event#pattern autocommand defined for this event and + pattern (the pattern is taken + literally and compared to the + autocommand patterns character by + character) + #group autocommand group exists + #group#event autocommand defined for this group and + event. + #group#event#pattern + autocommand defined for this group, + event and pattern. + ##event autocommand for this event is + supported. + + Examples: > + exists("&mouse") + exists("$HOSTNAME") + exists("*strftime") + exists("*s:MyFunc") + exists("bufcount") + exists(":Make") + exists("#CursorHold") + exists("#BufReadPre#*.gz") + exists("#filetypeindent") + exists("#filetypeindent#FileType") + exists("#filetypeindent#FileType#*") + exists("##ColorScheme") +< There must be no space between the symbol (&/$/*/#) and the + name. + There must be no extra characters after the name, although in + a few cases this is ignored. That may become more strict in + the future, thus don't count on it! + Working example: > + exists(":make") +< NOT working example: > + exists(":make install") + +< Note that the argument must be a string, not the name of the + variable itself. For example: > + exists(bufcount) +< This doesn't check for existence of the "bufcount" variable, + but gets the value of "bufcount", and checks if that exists. + + Can also be used as a |method|: > + Varname()->exists() + +exp({expr}) *exp()* + Return the exponential of {expr} as a |Float| in the range + [0, inf]. + {expr} must evaluate to a |Float| or a |Number|. + Examples: > + :echo exp(2) +< 7.389056 > + :echo exp(-1) +< 0.367879 + + Can also be used as a |method|: > + Compute()->exp() + +debugbreak({pid}) *debugbreak()* + Specifically used to interrupt a program being debugged. It + will cause process {pid} to get a SIGTRAP. Behavior for other + processes is undefined. See |terminal-debugger|. + {Sends a SIGINT to a process {pid} other than MS-Windows} + + Can also be used as a |method|: > + GetPid()->debugbreak() + +expand({string} [, {nosuf} [, {list}]]) *expand()* + Expand wildcards and the following special keywords in + {string}. 'wildignorecase' applies. + + If {list} is given and it is |TRUE|, a List will be returned. + Otherwise the result is a String and when there are several + matches, they are separated by characters. + + If the expansion fails, the result is an empty string. A name + for a non-existing file is not included, unless {string} does + not start with '%', '#' or '<', see below. + + When {string} starts with '%', '#' or '<', the expansion is + done like for the |cmdline-special| variables with their + associated modifiers. Here is a short overview: + + % current file name + # alternate file name + #n alternate file name n + file name under the cursor + autocmd file name + autocmd buffer number (as a String!) + autocmd matched name + sourced script file or function name + sourced script line number or function + line number + script file line number, also when in + a function + "123_" where "123" is the + current script ID || + word under the cursor + WORD under the cursor + the {clientid} of the last received + message |server2client()| + Modifiers: + :p expand to full path + :h head (last path component removed) + :t tail (last path component only) + :r root (one extension removed) + :e extension only + + Example: > + :let &tags = expand("%:p:h") . "/tags" +< Note that when expanding a string that starts with '%', '#' or + '<', any following text is ignored. This does NOT work: > + :let doesntwork = expand("%:h.bak") +< Use this: > + :let doeswork = expand("%:h") . ".bak" +< Also note that expanding "" and others only returns the + referenced file name without further expansion. If "" + is "~/.cshrc", you need to do another expand() to have the + "~/" expanded into the path of the home directory: > + :echo expand(expand("")) +< + There cannot be white space between the variables and the + following modifier. The |fnamemodify()| function can be used + to modify normal file names. + + When using '%' or '#', and the current or alternate file name + is not defined, an empty string is used. Using "%:p" in a + buffer with no name, results in the current directory, with a + '/' added. + + When {string} does not start with '%', '#' or '<', it is + expanded like a file name is expanded on the command line. + 'suffixes' and 'wildignore' are used, unless the optional + {nosuf} argument is given and it is |TRUE|. + Names for non-existing files are included. The "**" item can + be used to search in a directory tree. For example, to find + all "README" files in the current directory and below: > + :echo expand("**/README") +< + expand() can also be used to expand variables and environment + variables that are only known in a shell. But this can be + slow, because a shell may be used to do the expansion. See + |expr-env-expand|. + The expanded variable is still handled like a list of file + names. When an environment variable cannot be expanded, it is + left unchanged. Thus ":echo expand('$FOOBAR')" results in + "$FOOBAR". + + See |glob()| for finding existing files. See |system()| for + getting the raw output of an external command. + + Can also be used as a |method|: > + Getpattern()->expand() + +expandcmd({string}) *expandcmd()* + Expand special items in String {string} like what is done for + an Ex command such as `:edit`. This expands special keywords, + like with |expand()|, and environment variables, anywhere in + {string}. "~user" and "~/path" are only expanded at the + start. + Returns the expanded string. Example: > + :echo expandcmd('make %<.o') + +< Can also be used as a |method|: > + GetCommand()->expandcmd() +< +extend({expr1}, {expr2} [, {expr3}]) *extend()* + {expr1} and {expr2} must be both |Lists| or both + |Dictionaries|. + + If they are |Lists|: Append {expr2} to {expr1}. + If {expr3} is given insert the items of {expr2} before the + item with index {expr3} in {expr1}. When {expr3} is zero + insert before the first item. When {expr3} is equal to + len({expr1}) then {expr2} is appended. + Examples: > + :echo sort(extend(mylist, [7, 5])) + :call extend(mylist, [2, 3], 1) +< When {expr1} is the same List as {expr2} then the number of + items copied is equal to the original length of the List. + E.g., when {expr3} is 1 you get N new copies of the first item + (where N is the original length of the List). + Use |add()| to concatenate one item to a list. To concatenate + two lists into a new list use the + operator: > + :let newlist = [1, 2, 3] + [4, 5] +< + If they are |Dictionaries|: + Add all entries from {expr2} to {expr1}. + If a key exists in both {expr1} and {expr2} then {expr3} is + used to decide what to do: + {expr3} = "keep": keep the value of {expr1} + {expr3} = "force": use the value of {expr2} + {expr3} = "error": give an error message *E737* + When {expr3} is omitted then "force" is assumed. + + {expr1} is changed when {expr2} is not empty. If necessary + make a copy of {expr1} first. + {expr2} remains unchanged. + When {expr1} is locked and {expr2} is not empty the operation + fails. + Returns {expr1}. + + Can also be used as a |method|: > + mylist->extend(otherlist) + +feedkeys({string} [, {mode}]) *feedkeys()* + Characters in {string} are queued for processing as if they + come from a mapping or were typed by the user. + + By default the string is added to the end of the typeahead + buffer, thus if a mapping is still being executed the + characters come after them. Use the 'i' flag to insert before + other characters, they will be executed next, before any + characters from a mapping. + + The function does not wait for processing of keys contained in + {string}. + + To include special keys into {string}, use double-quotes + and "\..." notation |expr-quote|. For example, + feedkeys("\") simulates pressing of the key. But + feedkeys('\') pushes 5 characters. + The || keycode may be used to exit the + wait-for-character without doing anything. + + {mode} is a String, which can contain these character flags: + 'm' Remap keys. This is default. If {mode} is absent, + keys are remapped. + 'n' Do not remap keys. + 't' Handle keys as if typed; otherwise they are handled as + if coming from a mapping. This matters for undo, + opening folds, etc. + 'i' Insert the string instead of appending (see above). + 'x' Execute commands until typeahead is empty. This is + similar to using ":normal!". You can call feedkeys() + several times without 'x' and then one time with 'x' + (possibly with an empty {string}) to execute all the + typeahead. Note that when Vim ends in Insert mode it + will behave as if is typed, to avoid getting + stuck, waiting for a character to be typed before the + script continues. + Note that if you manage to call feedkeys() while + executing commands, thus calling it recursively, then + all typehead will be consumed by the last call. + '!' When used with 'x' will not end Insert mode. Can be + used in a test when a timer is set to exit Insert mode + a little later. Useful for testing CursorHoldI. + + Return value is always 0. + + Can also be used as a |method|: > + GetInput()->feedkeys() + +filereadable({file}) *filereadable()* + The result is a Number, which is |TRUE| when a file with the + name {file} exists, and can be read. If {file} doesn't exist, + or is a directory, the result is |FALSE|. {file} is any + expression, which is used as a String. + If you don't care about the file being readable you can use + |glob()|. + {file} is used as-is, you may want to expand wildcards first: > + echo filereadable('~/.vimrc') + 0 + echo filereadable(expand('~/.vimrc')) + 1 + +< Can also be used as a |method|: > + GetName()->filereadable() + +filewritable({file}) *filewritable()* + The result is a Number, which is 1 when a file with the + name {file} exists, and can be written. If {file} doesn't + exist, or is not writable, the result is 0. If {file} is a + directory, and we can write to it, the result is 2. + + Can also be used as a |method|: > + GetName()->filewriteable() + +filter({expr1}, {expr2}) *filter()* + {expr1} must be a |List|, |Blob|, or a |Dictionary|. + For each item in {expr1} evaluate {expr2} and when the result + is zero remove the item from the |List| or |Dictionary|. For a + |Blob| each byte is removed. + + {expr2} must be a |string| or |Funcref|. + + If {expr2} is a |string|, inside {expr2} |v:val| has the value + of the current item. For a |Dictionary| |v:key| has the key + of the current item and for a |List| |v:key| has the index of + the current item. For a |Blob| |v:key| has the index of the + current byte. + + Examples: > + call filter(mylist, 'v:val !~ "OLD"') +< Removes the items where "OLD" appears. > + call filter(mydict, 'v:key >= 8') +< Removes the items with a key below 8. > + call filter(var, 0) +< Removes all the items, thus clears the |List| or |Dictionary|. + + Note that {expr2} is the result of expression and is then + used as an expression again. Often it is good to use a + |literal-string| to avoid having to double backslashes. + + If {expr2} is a |Funcref| it must take two arguments: + 1. the key or the index of the current item. + 2. the value of the current item. + The function must return |TRUE| if the item should be kept. + Example that keeps the odd items of a list: > + func Odd(idx, val) + return a:idx % 2 == 1 + endfunc + call filter(mylist, function('Odd')) +< It is shorter when using a |lambda|: > + call filter(myList, {idx, val -> idx * val <= 42}) +< If you do not use "val" you can leave it out: > + call filter(myList, {idx -> idx % 2 == 1}) +< + The operation is done in-place. If you want a |List| or + |Dictionary| to remain unmodified make a copy first: > + :let l = filter(copy(mylist), 'v:val =~ "KEEP"') + +< Returns {expr1}, the |List|, |Blob| or |Dictionary| that was + filtered. When an error is encountered while evaluating + {expr2} no further items in {expr1} are processed. When + {expr2} is a Funcref errors inside a function are ignored, + unless it was defined with the "abort" flag. + + Can also be used as a |method|: > + mylist->filter(expr2) + +finddir({name} [, {path} [, {count}]]) *finddir()* + Find directory {name} in {path}. Supports both downwards and + upwards recursive directory searches. See |file-searching| + for the syntax of {path}. + + Returns the path of the first found match. When the found + directory is below the current directory a relative path is + returned. Otherwise a full path is returned. + If {path} is omitted or empty then 'path' is used. + + If the optional {count} is given, find {count}'s occurrence of + {name} in {path} instead of the first one. + When {count} is negative return all the matches in a |List|. + + This is quite similar to the ex-command `:find`. + + Can also be used as a |method|: > + GetName()->finddir() + +findfile({name} [, {path} [, {count}]]) *findfile()* + Just like |finddir()|, but find a file instead of a directory. + Uses 'suffixesadd'. + Example: > + :echo findfile("tags.vim", ".;") +< Searches from the directory of the current file upwards until + it finds the file "tags.vim". + + Can also be used as a |method|: > + GetName()->findfile() + +flatten({list} [, {maxdepth}]) *flatten()* + Flatten {list} up to {maxdepth} levels. Without {maxdepth} + the result is a |List| without nesting, as if {maxdepth} is + a very large number. + The {list} is changed in place, make a copy first if you do + not want that. + *E900* + {maxdepth} means how deep in nested lists changes are made. + {list} is not modified when {maxdepth} is 0. + {maxdepth} must be positive number. + + If there is an error the number zero is returned. + + Example: > + :echo flatten([1, [2, [3, 4]], 5]) +< [1, 2, 3, 4, 5] > + :echo flatten([1, [2, [3, 4]], 5], 1) +< [1, 2, [3, 4], 5] + + Can also be used as a |method|: > + mylist->flatten() +< +float2nr({expr}) *float2nr()* + Convert {expr} to a Number by omitting the part after the + decimal point. + {expr} must evaluate to a |Float| or a Number. + When the value of {expr} is out of range for a |Number| the + result is truncated to 0x7fffffff or -0x7fffffff (or when + 64-bit Number support is enabled, 0x7fffffffffffffff or + -0x7fffffffffffffff). NaN results in -0x80000000 (or when + 64-bit Number support is enabled, -0x8000000000000000). + Examples: > + echo float2nr(3.95) +< 3 > + echo float2nr(-23.45) +< -23 > + echo float2nr(1.0e100) +< 2147483647 (or 9223372036854775807) > + echo float2nr(-1.0e150) +< -2147483647 (or -9223372036854775807) > + echo float2nr(1.0e-100) +< 0 + + Can also be used as a |method|: > + Compute()->float2nr() + +floor({expr}) *floor()* + Return the largest integral value less than or equal to + {expr} as a |Float| (round down). + {expr} must evaluate to a |Float| or a |Number|. + Examples: > + echo floor(1.856) +< 1.0 > + echo floor(-5.456) +< -6.0 > + echo floor(4.0) +< 4.0 + + Can also be used as a |method|: > + Compute()->floor() + +fmod({expr1}, {expr2}) *fmod()* + Return the remainder of {expr1} / {expr2}, even if the + division is not representable. Returns {expr1} - i * {expr2} + for some integer i such that if {expr2} is non-zero, the + result has the same sign as {expr1} and magnitude less than + the magnitude of {expr2}. If {expr2} is zero, the value + returned is zero. The value returned is a |Float|. + {expr1} and {expr2} must evaluate to a |Float| or a |Number|. + Examples: > + :echo fmod(12.33, 1.22) +< 0.13 > + :echo fmod(-12.33, 1.22) +< -0.13 + + Can also be used as a |method|: > + Compute()->fmod(1.22) + +fnameescape({string}) *fnameescape()* + Escape {string} for use as file name command argument. All + characters that have a special meaning, such as '%' and '|' + are escaped with a backslash. + For most systems the characters escaped are + " \t\n*?[{`$\\%#'\"|!<". For systems where a backslash + appears in a filename, it depends on the value of 'isfname'. + A leading '+' and '>' is also escaped (special after |:edit| + and |:write|). And a "-" by itself (special after |:cd|). + Example: > + :let fname = '+some str%nge|name' + :exe "edit " . fnameescape(fname) +< results in executing: > + edit \+some\ str\%nge\|name +< + Can also be used as a |method|: > + GetName()->fnameescape() + +fnamemodify({fname}, {mods}) *fnamemodify()* + Modify file name {fname} according to {mods}. {mods} is a + string of characters like it is used for file names on the + command line. See |filename-modifiers|. + Example: > + :echo fnamemodify("main.c", ":p:h") +< results in: > + /home/mool/vim/vim/src +< If {mods} is empty then {fname} is returned. + Note: Environment variables don't work in {fname}, use + |expand()| first then. + + Can also be used as a |method|: > + GetName()->fnamemodify(':p:h') + +foldclosed({lnum}) *foldclosed()* + The result is a Number. If the line {lnum} is in a closed + fold, the result is the number of the first line in that fold. + If the line {lnum} is not in a closed fold, -1 is returned. + {lnum} is used like with |getline()|. Thus "." is the current + line, "'m" mark m, etc. + + Can also be used as a |method|: > + GetLnum()->foldclosed() + +foldclosedend({lnum}) *foldclosedend()* + The result is a Number. If the line {lnum} is in a closed + fold, the result is the number of the last line in that fold. + If the line {lnum} is not in a closed fold, -1 is returned. + {lnum} is used like with |getline()|. Thus "." is the current + line, "'m" mark m, etc. + + Can also be used as a |method|: > + GetLnum()->foldclosedend() + +foldlevel({lnum}) *foldlevel()* + The result is a Number, which is the foldlevel of line {lnum} + in the current buffer. For nested folds the deepest level is + returned. If there is no fold at line {lnum}, zero is + returned. It doesn't matter if the folds are open or closed. + When used while updating folds (from 'foldexpr') -1 is + returned for lines where folds are still to be updated and the + foldlevel is unknown. As a special case the level of the + previous line is usually available. + {lnum} is used like with |getline()|. Thus "." is the current + line, "'m" mark m, etc. + + 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 + only be called from evaluating 'foldtext'. It uses the + |v:foldstart|, |v:foldend| and |v:folddashes| variables. + The returned string looks like this: > + +-- 45 lines: abcdef +< The number of leading dashes depends on the foldlevel. The + "45" is the number of lines in the fold. "abcdef" is the text + in the first non-blank line of the fold. Leading white space, + "//" or "/*" and the text from the 'foldmarker' and + 'commentstring' options is removed. + When used to draw the actual foldtext, the rest of the line + will be filled with the fold char from the 'fillchars' + setting. + +foldtextresult({lnum}) *foldtextresult()* + Returns the text that is displayed for the closed fold at line + {lnum}. Evaluates 'foldtext' in the appropriate context. + When there is no closed fold at {lnum} an empty string is + returned. + {lnum} is used like with |getline()|. Thus "." is the current + line, "'m" mark m, etc. + Useful when exporting folded text, e.g., to HTML. + + Can also be used as a |method|: > + GetLnum()->foldtextresult() +< + *foreground()* +foreground() Move the Vim window to the foreground. Useful when sent from + a client to a Vim server. |remote_send()| + On Win32 systems this might not work, the OS does not always + allow a window to bring itself to the foreground. Use + |remote_foreground()| instead. + {only in the Win32 GUI and console version} + +fullcommand({name}) *fullcommand()* + Get the full command name from a short abbreviated command + name; see |20.2| for details on command abbreviations. + + The string argument {name} may start with a `:` and can + include a [range], these are skipped and not returned. + Returns an empty string if a command doesn't exist or if it's + ambiguous (for user-defined commands). + + For example `fullcommand('s')`, `fullcommand('sub')`, + `fullcommand(':%substitute')` all return "substitute". + + Can also be used as a |method|: > + GetName()->fullcommand() +< + *funcref()* +funcref({name} [, {arglist}] [, {dict}]) + Just like |function()|, but the returned Funcref will lookup + the function by reference, not by name. This matters when the + function {name} is redefined later. + + Unlike |function()|, {name} must be an existing user function. + It only works for an autoloaded function if it has already + been loaded (to avoid mistakenly loading the autoload script + when only intending to use the function name, use |function()| + instead). {name} cannot be a builtin function. + + Can also be used as a |method|: > + GetFuncname()->funcref([arg]) +< + *function()* *E700* *E922* *E923* +function({name} [, {arglist}] [, {dict}]) + Return a |Funcref| variable that refers to function {name}. + {name} can be a user defined function or an internal function. + + {name} can also be a Funcref or a partial. When it is a + partial the dict stored in it will be used and the {dict} + argument is not allowed. E.g.: > + let FuncWithArg = function(dict.Func, [arg]) + let Broken = function(dict.Func, [arg], dict) +< + When using the Funcref the function will be found by {name}, + also when it was redefined later. Use |funcref()| to keep the + same function. + + When {arglist} or {dict} is present this creates a partial. + That means the argument list and/or the dictionary is stored in + the Funcref and will be used when the Funcref is called. + + The arguments are passed to the function in front of other + arguments, but after any argument from |method|. Example: > + func Callback(arg1, arg2, name) + ... + let Partial = function('Callback', ['one', 'two']) + ... + call Partial('name') +< Invokes the function as with: > + call Callback('one', 'two', 'name') + +< The Dictionary is only useful when calling a "dict" function. + In that case the {dict} is passed in as "self". Example: > + function Callback() dict + echo "called for " . self.name + endfunction + ... + let context = {"name": "example"} + let Func = function('Callback', context) + ... + call Func() " will echo: called for example + +< The argument list and the Dictionary can be combined: > + function Callback(arg1, count) dict + ... + let context = {"name": "example"} + let Func = function('Callback', ['one'], context) + ... + call Func(500) +< Invokes the function as with: > + call context.Callback('one', 500) +< + Can also be used as a |method|: > + GetFuncname()->function([arg]) + +garbagecollect([{atexit}]) *garbagecollect()* + Cleanup unused |Lists| and |Dictionaries| that have circular + references. + + There is hardly ever a need to invoke this function, as it is + automatically done when Vim runs out of memory or is waiting + for the user to press a key after 'updatetime'. Items without + circular references are always freed when they become unused. + This is useful if you have deleted a very big |List| and/or + |Dictionary| with circular references in a script that runs + for a long time. + + When the optional {atexit} argument is one, garbage + collection will also be done when exiting Vim, if it wasn't + done before. This is useful when checking for memory leaks. + + The garbage collection is not done immediately but only when + it's safe to perform. This is when waiting for the user to + type a character. + +get({list}, {idx} [, {default}]) *get()* + Get item {idx} from |List| {list}. When this item is not + available return {default}. Return zero when {default} is + omitted. + Can also be used as a |method|: > + mylist->get(idx) +get({blob}, {idx} [, {default}]) + Get byte {idx} from |Blob| {blob}. When this byte is not + available return {default}. Return -1 when {default} is + omitted. +get({dict}, {key} [, {default}]) + Get item with key {key} from |Dictionary| {dict}. When this + item is not available return {default}. Return zero when + {default} is omitted. Useful example: > + let val = get(g:, 'var_name', 'default') +< This gets the value of g:var_name if it exists, and uses + 'default' when it does not exist. +get({func}, {what}) + Get item {what} from Funcref {func}. Possible values for + {what} are: + "name" The function name + "func" The function + "dict" The dictionary + "args" The list with arguments + + *getbufinfo()* +getbufinfo([{buf}]) +getbufinfo([{dict}]) + Get information about buffers as a List of Dictionaries. + + Without an argument information about all the buffers is + returned. + + When the argument is a |Dictionary| only the buffers matching + the specified criteria are returned. The following keys can + be specified in {dict}: + buflisted include only listed buffers. + bufloaded include only loaded buffers. + bufmodified include only modified buffers. + + Otherwise, {buf} specifies a particular buffer to return + information for. For the use of {buf}, see |bufname()| + above. If the buffer is found the returned List has one item. + Otherwise the result is an empty list. + + Each returned List item is a dictionary with the following + entries: + bufnr Buffer number. + changed TRUE if the buffer is modified. + changedtick Number of changes made to the buffer. + hidden TRUE if the buffer is hidden. + lastused Timestamp in seconds, like + |localtime()|, when the buffer was + last used. + listed TRUE if the buffer is listed. + lnum Line number used for the buffer when + opened in the current window. + Only valid if the buffer has been + displayed in the window in the past. + If you want the line number of the + last known cursor position in a given + window, use |line()|: > + :echo line('.', {winid}) +< + linecount Number of lines in the buffer (only + valid when loaded) + loaded TRUE if the buffer is loaded. + name Full path to the file in the buffer. + signs List of signs placed in the buffer. + Each list item is a dictionary with + the following fields: + id sign identifier + lnum line number + name sign name + variables A reference to the dictionary with + buffer-local variables. + windows List of |window-ID|s that display this + buffer + + Examples: > + for buf in getbufinfo() + echo buf.name + endfor + for buf in getbufinfo({'buflisted':1}) + if buf.changed + .... + endif + endfor +< + To get buffer-local options use: > + getbufvar({bufnr}, '&option_name') +< + Can also be used as a |method|: > + GetBufnr()->getbufinfo() +< + *getbufline()* +getbufline({buf}, {lnum} [, {end}]) + Return a |List| with the lines starting from {lnum} to {end} + (inclusive) in the buffer {buf}. If {end} is omitted, a + |List| with only the line {lnum} is returned. + + For the use of {buf}, see |bufname()| above. + + For {lnum} and {end} "$" can be used for the last line of the + buffer. Otherwise a number must be used. + + When {lnum} is smaller than 1 or bigger than the number of + lines in the buffer, an empty |List| is returned. + + When {end} is greater than the number of lines in the buffer, + it is treated as {end} is set to the number of lines in the + buffer. When {end} is before {lnum} an empty |List| is + returned. + + This function works only for loaded buffers. For unloaded and + non-existing buffers, an empty |List| is returned. + + Example: > + :let lines = getbufline(bufnr("myfile"), 1, "$") + +< Can also be used as a |method|: > + GetBufnr()->getbufline(lnum) + +getbufvar({buf}, {varname} [, {def}]) *getbufvar()* + The result is the value of option or local buffer variable + {varname} in buffer {buf}. Note that the name without "b:" + must be used. + The {varname} argument is a string. + When {varname} is empty returns a |Dictionary| with all the + buffer-local variables. + When {varname} is equal to "&" returns a |Dictionary| with all + the buffer-local options. + Otherwise, when {varname} starts with "&" returns the value of + a buffer-local option. + This also works for a global or buffer-local option, but it + doesn't work for a global variable, window-local variable or + window-local option. + For the use of {buf}, see |bufname()| above. + When the buffer or variable doesn't exist {def} or an empty + string is returned, there is no error message. + Examples: > + :let bufmodified = getbufvar(1, "&mod") + :echo "todo myvar = " . getbufvar("todo", "myvar") + +< Can also be used as a |method|: > + GetBufnr()->getbufvar(varname) +< +getchangelist([{buf}]) *getchangelist()* + Returns the |changelist| for the buffer {buf}. For the use + of {buf}, see |bufname()| above. If buffer {buf} doesn't + exist, an empty list is returned. + + The returned list contains two entries: a list with the change + locations and the current position in the list. Each + entry in the change list is a dictionary with the following + entries: + col column number + coladd column offset for 'virtualedit' + lnum line number + If buffer {buf} is the current buffer, then the current + position refers to the position in the list. For other + buffers, it is set to the length of the list. + + Can also be used as a |method|: > + GetBufnr()->getchangelist() + +getchar([expr]) *getchar()* + Get a single character from the user or input stream. + If [expr] is omitted, wait until a character is available. + If [expr] is 0, only get a character when one is available. + Return zero otherwise. + If [expr] is 1, only check if a character is available, it is + not consumed. Return zero if no character available. + If you prefer always getting a string use |getcharstr()|. + + Without [expr] and when [expr] is 0 a whole character or + special key is returned. If it is a single character, the + result is a number. Use nr2char() to convert it to a String. + Otherwise a String is returned with the encoded character. + For a special key it's a String with a sequence of bytes + starting with 0x80 (decimal: 128). This is the same value as + the String "\", e.g., "\". The returned value is + also a String when a modifier (shift, control, alt) was used + that is not included in the character. + + When [expr] is 0 and Esc is typed, there will be a short delay + while Vim waits to see if this is the start of an escape + sequence. + + When [expr] is 1 only the first byte is returned. For a + one-byte character it is the character itself as a number. + Use nr2char() to convert it to a String. + + Use getcharmod() to obtain any additional modifiers. + + When the user clicks a mouse button, the mouse event will be + returned. The position can then be found in |v:mouse_col|, + |v:mouse_lnum|, |v:mouse_winid| and |v:mouse_win|. + |getmousepos()| can also be used. Mouse move events will be + ignored. + This example positions the mouse as it would normally happen: > + let c = getchar() + if c == "\" && v:mouse_win > 0 + exe v:mouse_win . "wincmd w" + exe v:mouse_lnum + exe "normal " . v:mouse_col . "|" + endif +< + There is no prompt, you will somehow have to make clear to the + user that a character has to be typed. The screen is not + redrawn, e.g. when resizing the window. + + There is no mapping for the character. + Key codes are replaced, thus when the user presses the + key you get the code for the key, not the raw character + sequence. Examples: > + getchar() == "\" + getchar() == "\" +< This example redefines "f" to ignore case: > + :nmap f :call FindChar() + :function FindChar() + : let c = nr2char(getchar()) + : while col('.') < col('$') - 1 + : normal l + : if getline('.')[col('.') - 1] ==? c + : break + : endif + : endwhile + :endfunction +< +getcharmod() *getcharmod()* + The result is a Number which is the state of the modifiers for + the last obtained character with getchar() or in another way. + These values are added together: + 2 shift + 4 control + 8 alt (meta) + 16 meta (when it's different from ALT) + 32 mouse double click + 64 mouse triple click + 96 mouse quadruple click (== 32 + 64) + 128 command (Macintosh only) + Only the modifiers that have not been included in the + character itself are obtained. Thus Shift-a results in "A" + without a modifier. + +getcharsearch() *getcharsearch()* + Return the current character search information as a {dict} + with the following entries: + + char character previously used for a character + search (|t|, |f|, |T|, or |F|); empty string + if no character search has been performed + forward direction of character search; 1 for forward, + 0 for backward + until type of character search; 1 for a |t| or |T| + character search, 0 for an |f| or |F| + character search + + This can be useful to always have |;| and |,| search + forward/backward regardless of the direction of the previous + character search: > + :nnoremap ; getcharsearch().forward ? ';' : ',' + :nnoremap , getcharsearch().forward ? ',' : ';' +< Also see |setcharsearch()|. + + +getcharstr([expr]) *getcharstr()* + Get a single character from the user or input stream as a + string. + If [expr] is omitted, wait until a character is available. + If [expr] is 0 or false, only get a character when one is + available. Return an empty string otherwise. + If [expr] is 1 or true, only check if a character is + available, it is not consumed. Return an empty string + if no character is available. + Otherwise this works like |getchar()|, except that a number + result is converted to a string. + + +getcmdline() *getcmdline()* + Return the current command-line. Only works when the command + line is being edited, thus requires use of |c_CTRL-\_e| or + |c_CTRL-R_=|. + Example: > + :cmap eescape(getcmdline(), ' \') +< Also see |getcmdtype()|, |getcmdpos()| and |setcmdpos()|. + Returns an empty string when entering a password or using + |inputsecret()|. + +getcmdpos() *getcmdpos()* + Return the position of the cursor in the command line as a + byte count. The first column is 1. + Only works when editing the command line, thus requires use of + |c_CTRL-\_e| or |c_CTRL-R_=| or an expression mapping. + Returns 0 otherwise. + Also see |getcmdtype()|, |setcmdpos()| and |getcmdline()|. + +getcmdtype() *getcmdtype()* + Return the current command-line type. Possible return values + are: + : normal Ex command + > debug mode command |debug-mode| + / forward search command + ? backward search command + @ |input()| command + - |:insert| or |:append| command + = |i_CTRL-R_=| + Only works when editing the command line, thus requires use of + |c_CTRL-\_e| or |c_CTRL-R_=| or an expression mapping. + Returns an empty string otherwise. + Also see |getcmdpos()|, |setcmdpos()| and |getcmdline()|. + +getcmdwintype() *getcmdwintype()* + Return the current |command-line-window| type. Possible return + values are the same as |getcmdtype()|. Returns an empty string + when not in the command-line window. + +getcompletion({pat}, {type} [, {filtered}]) *getcompletion()* + Return a list of command-line completion matches. The String + {type} argument specifies what for. The following completion + types are supported: + + arglist file names in argument list + augroup autocmd groups + buffer buffer names + behave :behave suboptions + cmdline |cmdline-completion| result + color color schemes + command Ex command + compiler compilers + cscope |:cscope| suboptions + diff_buffer |:diffget| and |:diffput| completion + dir directory names + environment environment variable names + event autocommand events + expression Vim expression + file file and directory names + file_in_path file and directory names in |'path'| + filetype filetype names |'filetype'| + function function name + help help subjects + highlight highlight groups + history :history suboptions + locale locale names (as output of locale -a) + mapclear buffer argument + mapping mapping name + menu menus + messages |:messages| suboptions + option options + packadd optional package |pack-add| names + shellcmd Shell command + sign |:sign| suboptions + syntax syntax file names |'syntax'| + syntime |:syntime| suboptions + tag tags + tag_listfiles tags, file names + user user names + var user variables + + If {pat} is an empty string, then all the matches are + returned. Otherwise only items matching {pat} are returned. + See |wildcards| for the use of special characters in {pat}. + + If the optional {filtered} flag is set to 1, then 'wildignore' + is applied to filter the results. Otherwise all the matches + are returned. The 'wildignorecase' option always applies. + + If {type} is "cmdline", then the |cmdline-completion| result is + returned. For example, to complete the possible values after + a ":call" command: > + echo getcompletion('call ', 'cmdline') +< + If there are no matches, an empty list is returned. An + invalid value for {type} produces an error. + + Can also be used as a |method|: > + GetPattern()->getcompletion('color') +< + *getcurpos()* +getcurpos() Get the position of the cursor. This is like getpos('.'), but + includes an extra "curswant" in the list: + [0, lnum, col, off, curswant] ~ + The "curswant" number is the preferred column when moving the + cursor vertically. Also see |getpos()|. + The first "bufnum" item is always zero. + + This can be used to save and restore the cursor position: > + let save_cursor = getcurpos() + MoveTheCursorAround + call setpos('.', save_cursor) +< Note that this only works within the window. See + |winrestview()| for restoring more state. + +getcwd([{winnr}[, {tabnr}]]) *getcwd()* + With no arguments, returns the name of the effective + |current-directory|. With {winnr} or {tabnr} the working + directory of that scope is returned, and 'autochdir' is + ignored. + Tabs and windows are identified by their respective numbers, + 0 means current tab or window. Missing tab number implies 0. + Thus the following are equivalent: > + getcwd(0) + getcwd(0, 0) +< If {winnr} is -1 it is ignored, only the tab is resolved. + {winnr} can be the window number or the |window-ID|. + If both {winnr} and {tabnr} are -1 the global working + directory is returned. + Throw error if the arguments are invalid. |E5000| |E5001| |E5002| + + Can also be used as a |method|: > + GetWinnr()->getcwd() + +getenv({name}) *getenv()* + Return the value of environment variable {name}. The {name} + argument is a string, without a leading '$'. Example: > + myHome = getenv('HOME') + +< When the variable does not exist |v:null| is returned. That + is different from a variable set to an empty string. + See also |expr-env|. + + Can also be used as a |method|: > + GetVarname()->getenv() + +getfontname([{name}]) *getfontname()* + Without an argument returns the name of the normal font being + used. Like what is used for the Normal highlight group + |hl-Normal|. + With an argument a check is done whether String {name} is a + valid font name. If not then an empty string is returned. + Otherwise the actual font name is returned, or {name} if the + GUI does not support obtaining the real name. + Only works when the GUI is running, thus not in your vimrc or + gvimrc file. Use the |GUIEnter| autocommand to use this + function just after the GUI has started. + +getfperm({fname}) *getfperm()* + The result is a String, which is the read, write, and execute + permissions of the given file {fname}. + If {fname} does not exist or its directory cannot be read, an + empty string is returned. + The result is of the form "rwxrwxrwx", where each group of + "rwx" flags represent, in turn, the permissions of the owner + of the file, the group the file belongs to, and other users. + If a user does not have a given permission the flag for this + is replaced with the string "-". Examples: > + :echo getfperm("/etc/passwd") + :echo getfperm(expand("~/.config/nvim/init.vim")) +< This will hopefully (from a security point of view) display + the string "rw-r--r--" or even "rw-------". + + Can also be used as a |method|: > + GetFilename()->getfperm() +< + For setting permissions use |setfperm()|. + +getfsize({fname}) *getfsize()* + The result is a Number, which is the size in bytes of the + given file {fname}. + If {fname} is a directory, 0 is returned. + If the file {fname} can't be found, -1 is returned. + If the size of {fname} is too big to fit in a Number then -2 + is returned. + + Can also be used as a |method|: > + GetFilename()->getfsize() + +getftime({fname}) *getftime()* + The result is a Number, which is the last modification time of + the given file {fname}. The value is measured as seconds + since 1st Jan 1970, and may be passed to strftime(). See also + |localtime()| and |strftime()|. + If the file {fname} can't be found -1 is returned. + + Can also be used as a |method|: > + GetFilename()->getftime() + +getftype({fname}) *getftype()* + The result is a String, which is a description of the kind of + file of the given file {fname}. + If {fname} does not exist an empty string is returned. + Here is a table over different kinds of files and their + results: + Normal file "file" + Directory "dir" + Symbolic link "link" + Block device "bdev" + Character device "cdev" + Socket "socket" + FIFO "fifo" + All other "other" + Example: > + getftype("/home") +< Note that a type such as "link" will only be returned on + systems that support it. On some systems only "dir" and + "file" are returned. + + Can also be used as a |method|: > + GetFilename()->getftype() + +getjumplist([{winnr} [, {tabnr}]]) *getjumplist()* + Returns the |jumplist| for the specified window. + + Without arguments use the current window. + With {winnr} only use this window in the current tab page. + {winnr} can also be a |window-ID|. + With {winnr} and {tabnr} use the window in the specified tab + page. + + The returned list contains two entries: a list with the jump + locations and the last used jump position number in the list. + Each entry in the jump location list is a dictionary with + the following entries: + bufnr buffer number + col column number + coladd column offset for 'virtualedit' + filename filename if available + lnum line number + + Can also be used as a |method|: > + GetWinnr()->getjumplist() + +< *getline()* +getline({lnum} [, {end}]) + Without {end} the result is a String, which is line {lnum} + from the current buffer. Example: > + getline(1) +< When {lnum} is a String that doesn't start with a + digit, |line()| is called to translate the String into a Number. + To get the line under the cursor: > + getline(".") +< When {lnum} is a number smaller than 1 or bigger than the + number of lines in the buffer, an empty string is returned. + + When {end} is given the result is a |List| where each item is + a line from the current buffer in the range {lnum} to {end}, + including line {end}. + {end} is used in the same way as {lnum}. + Non-existing lines are silently omitted. + When {end} is before {lnum} an empty |List| is returned. + Example: > + :let start = line('.') + :let end = search("^$") - 1 + :let lines = getline(start, end) + +< Can also be used as a |method|: > + ComputeLnum()->getline() + +< To get lines from another buffer see |getbufline()| + +getloclist({nr},[, {what}]) *getloclist()* + Returns a |List| with all the entries in the location list for + window {nr}. {nr} can be the window number or the |window-ID|. + When {nr} is zero the current window is used. + + For a location list window, the displayed location list is + returned. For an invalid window number {nr}, an empty list is + returned. Otherwise, same as |getqflist()|. + + If the optional {what} dictionary argument is supplied, then + returns the items listed in {what} as a dictionary. Refer to + |getqflist()| for the supported items in {what}. + If {what} contains 'filewinid', then returns the id of the + window used to display files from the location list. This + field is applicable only when called from a location list + window. See |location-list-file-window| for more details. + + Returns a |Dictionary| with default values if there is no + location list for the window {nr}. + Returns an empty Dictionary if window {nr} does not exist. + + Examples (See also |getqflist-examples|): > + :echo getloclist(3, {'all': 0}) + :echo getloclist(5, {'filewinid': 0}) + + +getmarklist([{buf}]) *getmarklist()* + Without the {buf} argument returns a |List| with information + about all the global marks. |mark| + + If the optional {buf} argument is specified, returns the + local marks defined in buffer {buf}. For the use of {buf}, + see |bufname()|. + + Each item in the returned List is a |Dict| with the following: + mark name of the mark prefixed by "'" + pos a |List| with the position of the mark: + [bufnum, lnum, col, off] + Refer to |getpos()| for more information. + file file name + + Refer to |getpos()| for getting information about a specific + mark. + + Can also be used as a |method|: > + GetBufnr()->getmarklist() + +getmatches([{win}]) *getmatches()* + Returns a |List| with all matches previously defined for the + current window by |matchadd()| and the |:match| commands. + |getmatches()| is useful in combination with |setmatches()|, + as |setmatches()| can restore a list of matches saved by + |getmatches()|. + If {win} is specified, use the window with this number or + window ID instead of the current window. + Example: > + :echo getmatches() +< [{'group': 'MyGroup1', 'pattern': 'TODO', + 'priority': 10, 'id': 1}, {'group': 'MyGroup2', + 'pattern': 'FIXME', 'priority': 10, 'id': 2}] > + :let m = getmatches() + :call clearmatches() + :echo getmatches() +< [] > + :call setmatches(m) + :echo getmatches() +< [{'group': 'MyGroup1', 'pattern': 'TODO', + 'priority': 10, 'id': 1}, {'group': 'MyGroup2', + 'pattern': 'FIXME', 'priority': 10, 'id': 2}] > + :unlet m +< +getmousepos() *getmousepos()* + Returns a Dictionary with the last known position of the + mouse. This can be used in a mapping for a mouse click. The + items are: + screenrow screen row + screencol screen column + winid Window ID of the click + winrow row inside "winid" + wincol column inside "winid" + line text line inside "winid" + column text column inside "winid" + All numbers are 1-based. + + If not over a window, e.g. when in the command line, then only + "screenrow" and "screencol" are valid, the others are zero. + + When on the status line below a window or the vertical + separater right of a window, the "line" and "column" values + are zero. + + When the position is after the text then "column" is the + length of the text in bytes plus one. + + If the mouse is over a focusable floating window then that + window is used. + + When using |getchar()| the Vim variables |v:mouse_lnum|, + |v:mouse_col| and |v:mouse_winid| also provide these values. + + *getpid()* +getpid() Return a Number which is the process ID of the Vim process. + This is a unique number, until Vim exits. + + *getpos()* +getpos({expr}) Get the position for String {expr}. For possible values of + {expr} see |line()|. For getting the cursor position see + |getcurpos()|. + The result is a |List| with four numbers: + [bufnum, lnum, col, off] + "bufnum" is zero, unless a mark like '0 or 'A is used, then it + is the buffer number of the mark. + "lnum" and "col" are the position in the buffer. The first + column is 1. + The "off" number is zero, unless 'virtualedit' is used. Then + it is the offset in screen columns from the start of the + character. E.g., a position within a or after the last + character. + Note that for '< and '> Visual mode matters: when it is "V" + (visual line mode) the column of '< is zero and the column of + '> is a large number. + The column number in the returned List is the byte position + within the line. + The column number can be very large, e.g. 2147483647, in which + case it means "after the end of the line". + This can be used to save and restore the position of a mark: > + let save_a_mark = getpos("'a") + ... + call setpos("'a", save_a_mark) +< Also see |getcurpos()| and |setpos()|. + + Can also be used as a |method|: > + GetMark()->getpos() + +getqflist([{what}]) *getqflist()* + Returns a |List| with all the current quickfix errors. Each + list item is a dictionary with these entries: + bufnr number of buffer that has the file name, use + bufname() to get the name + module module name + lnum line number in the buffer (first line is 1) + end_lnum + end of line number if the item is multiline + col column number (first column is 1) + end_col end of column number if the item has range + vcol |TRUE|: "col" is visual column + |FALSE|: "col" is byte index + nr error number + pattern search pattern used to locate the error + text description of the error + type type of the error, 'E', '1', etc. + valid |TRUE|: recognized error message + + When there is no error list or it's empty, an empty list is + returned. Quickfix list entries with a non-existing buffer + number are returned with "bufnr" set to zero (Note: some + functions accept buffer number zero for the alternate buffer, + you may need to explicitly check for zero). + + Useful application: Find pattern matches in multiple files and + do something with them: > + :vimgrep /theword/jg *.c + :for d in getqflist() + : echo bufname(d.bufnr) ':' d.lnum '=' d.text + :endfor +< + If the optional {what} dictionary argument is supplied, then + returns only the items listed in {what} as a dictionary. The + following string items are supported in {what}: + changedtick get the total number of changes made + to the list |quickfix-changedtick| + context get the |quickfix-context| + efm errorformat to use when parsing "lines". If + not present, then the 'errorformat' option + value is used. + id get information for the quickfix list with + |quickfix-ID|; zero means the id for the + current list or the list specified by "nr" + idx get information for the quickfix entry at this + index in the list specified by 'id' or 'nr'. + If set to zero, then uses the current entry. + See |quickfix-index| + items quickfix list entries + lines parse a list of lines using 'efm' and return + the resulting entries. Only a |List| type is + accepted. The current quickfix list is not + modified. See |quickfix-parse|. + nr get information for this quickfix list; zero + means the current quickfix list and "$" means + the last quickfix list + size number of entries in the quickfix list + title get the list title |quickfix-title| + winid get the quickfix |window-ID| + all all of the above quickfix properties + Non-string items in {what} are ignored. To get the value of a + particular item, set it to zero. + If "nr" is not present then the current quickfix list is used. + If both "nr" and a non-zero "id" are specified, then the list + specified by "id" is used. + To get the number of lists in the quickfix stack, set "nr" to + "$" in {what}. The "nr" value in the returned dictionary + contains the quickfix stack size. + When "lines" is specified, all the other items except "efm" + are ignored. The returned dictionary contains the entry + "items" with the list of entries. + + The returned dictionary contains the following entries: + changedtick total number of changes made to the + list |quickfix-changedtick| + context quickfix list context. See |quickfix-context| + If not present, set to "". + id quickfix list ID |quickfix-ID|. If not + present, set to 0. + idx index of the quickfix entry in the list. If not + present, set to 0. + items quickfix list entries. If not present, set to + an empty list. + nr quickfix list number. If not present, set to 0 + size number of entries in the quickfix list. If not + present, set to 0. + title quickfix list title text. If not present, set + to "". + winid quickfix |window-ID|. If not present, set to 0 + + Examples (See also |getqflist-examples|): > + :echo getqflist({'all': 1}) + :echo getqflist({'nr': 2, 'title': 1}) + :echo getqflist({'lines' : ["F1:10:L10"]}) +< +getreg([{regname} [, 1 [, {list}]]]) *getreg()* + The result is a String, which is the contents of register + {regname}. Example: > + :let cliptext = getreg('*') +< When register {regname} was not set the result is an empty + string. + The {regname} argument must be a string. + + getreg('=') returns the last evaluated value of the expression + register. (For use in maps.) + getreg('=', 1) returns the expression itself, so that it can + be restored with |setreg()|. For other registers the extra + argument is ignored, thus you can always give it. + + If {list} is present and |TRUE|, the result type is changed + to |List|. Each list item is one text line. Use it if you care + about zero bytes possibly present inside register: without + third argument both NLs and zero bytes are represented as NLs + (see |NL-used-for-Nul|). + When the register was not set an empty list is returned. + + If {regname} is not specified, |v:register| is used. + + Can also be used as a |method|: > + GetRegname()->getreg() + +getreginfo([{regname}]) *getreginfo()* + Returns detailed information about register {regname} as a + Dictionary with the following entries: + regcontents List of lines contained in register + {regname}, like + |getreg|({regname}, 1, 1). + regtype the type of register {regname}, as in + |getregtype()|. + isunnamed Boolean flag, v:true if this register + is currently pointed to by the unnamed + register. + points_to for the unnamed register, gives the + single letter name of the register + currently pointed to (see |quotequote|). + For example, after deleting a line + with `dd`, this field will be "1", + which is the register that got the + deleted text. + + The {regname} argument is a string. If {regname} is invalid + or not set, an empty Dictionary will be returned. + If {regname} is not specified, |v:register| is used. + The returned Dictionary can be passed to |setreg()|. + + Can also be used as a |method|: > + GetRegname()->getreginfo() + +getregtype([{regname}]) *getregtype()* + The result is a String, which is type of register {regname}. + The value will be one of: + "v" for |charwise| text + "V" for |linewise| text + "{width}" for |blockwise-visual| text + "" for an empty or unknown register + is one character with value 0x16. + The {regname} argument is a string. If {regname} is not + specified, |v:register| is used. + + Can also be used as a |method|: > + GetRegname()->getregtype() + +gettabinfo([{tabnr}]) *gettabinfo()* + If {tabnr} is not specified, then information about all the + tab pages is returned as a |List|. Each List item is a + |Dictionary|. Otherwise, {tabnr} specifies the tab page + number and information about that one is returned. If the tab + page does not exist an empty List is returned. + + Each List item is a |Dictionary| with the following entries: + tabnr tab page number. + variables a reference to the dictionary with + tabpage-local variables + windows List of |window-ID|s in the tab page. + + Can also be used as a |method|: > + GetTabnr()->gettabinfo() + +gettabvar({tabnr}, {varname} [, {def}]) *gettabvar()* + Get the value of a tab-local variable {varname} in tab page + {tabnr}. |t:var| + Tabs are numbered starting with one. + The {varname} argument is a string. When {varname} is empty a + dictionary with all tab-local variables is returned. + Note that the name without "t:" must be used. + When the tab or variable doesn't exist {def} or an empty + string is returned, there is no error message. + + Can also be used as a |method|: > + GetTabnr()->gettabvar(varname) + +gettabwinvar({tabnr}, {winnr}, {varname} [, {def}]) *gettabwinvar()* + Get the value of window-local variable {varname} in window + {winnr} in tab page {tabnr}. + The {varname} argument is a string. When {varname} is empty a + dictionary with all window-local variables is returned. + When {varname} is equal to "&" get the values of all + window-local options in a |Dictionary|. + Otherwise, when {varname} starts with "&" get the value of a + window-local option. + Note that {varname} must be the name without "w:". + Tabs are numbered starting with one. For the current tabpage + use |getwinvar()|. + {winnr} can be the window number or the |window-ID|. + When {winnr} is zero the current window is used. + This also works for a global option, buffer-local option and + window-local option, but it doesn't work for a global variable + or buffer-local variable. + When the tab, window or variable doesn't exist {def} or an + empty string is returned, there is no error message. + Examples: > + :let list_is_on = gettabwinvar(1, 2, '&list') + :echo "myvar = " . gettabwinvar(3, 1, 'myvar') +< + To obtain all window-local variables use: > + gettabwinvar({tabnr}, {winnr}, '&') + +< Can also be used as a |method|: > + GetTabnr()->gettabwinvar(winnr, varname) + +gettagstack([{winnr}]) *gettagstack()* + The result is a Dict, which is the tag stack of window {winnr}. + {winnr} can be the window number or the |window-ID|. + When {winnr} is not specified, the current window is used. + When window {winnr} doesn't exist, an empty Dict is returned. + + The returned dictionary contains the following entries: + curidx Current index in the stack. When at + top of the stack, set to (length + 1). + Index of bottom of the stack is 1. + items List of items in the stack. Each item + is a dictionary containing the + entries described below. + length Number of entries in the stack. + + Each item in the stack is a dictionary with the following + entries: + bufnr buffer number of the current jump + from cursor position before the tag jump. + See |getpos()| for the format of the + returned list. + matchnr current matching tag number. Used when + multiple matching tags are found for a + name. + tagname name of the tag + + See |tagstack| for more information about the tag stack. + + Can also be used as a |method|: > + GetWinnr()->gettagstack() + +getwininfo([{winid}]) *getwininfo()* + Returns information about windows as a |List| with Dictionaries. + + If {winid} is given Information about the window with that ID + is returned, as a |List| with one item. If the window does not + exist the result is an empty list. + + Without {winid} information about all the windows in all the + tab pages is returned. + + Each List item is a |Dictionary| with the following entries: + botline last complete displayed buffer line + bufnr number of buffer in the window + height window height (excluding winbar) + loclist 1 if showing a location list + quickfix 1 if quickfix or location list window + terminal 1 if a terminal window + tabnr tab page number + topline first displayed buffer line + variables a reference to the dictionary with + window-local variables + width window width + winbar 1 if the window has a toolbar, 0 + otherwise + wincol leftmost screen column of the window; + "col" from |win_screenpos()| + textoff number of columns occupied by any + 'foldcolumn', 'signcolumn' and line + number in front of the text + winid |window-ID| + winnr window number + winrow topmost screen line of the window; + "row" from |win_screenpos()| + + Can also be used as a |method|: > + GetWinnr()->getwininfo() + +getwinpos([{timeout}]) *getwinpos()* + The result is a |List| with two numbers, the result of + |getwinposx()| and |getwinposy()| combined: + [x-pos, y-pos] + {timeout} can be used to specify how long to wait in msec for + a response from the terminal. When omitted 100 msec is used. + + Use a longer time for a remote terminal. + When using a value less than 10 and no response is received + within that time, a previously reported position is returned, + if available. This can be used to poll for the position and + do some work in the meantime: > + while 1 + let res = getwinpos(1) + if res[0] >= 0 + break + endif + " Do some work here + endwhile +< + Can also be used as a |method|: > + GetTimeout()->getwinpos() +< + *getwinposx()* +getwinposx() The result is a Number, which is the X coordinate in pixels of + the left hand side of the GUI Vim window. The result will be + -1 if the information is not available. + The value can be used with `:winpos`. + + *getwinposy()* +getwinposy() The result is a Number, which is the Y coordinate in pixels of + the top of the GUI Vim window. The result will be -1 if the + information is not available. + The value can be used with `:winpos`. + +getwinvar({winnr}, {varname} [, {def}]) *getwinvar()* + Like |gettabwinvar()| for the current tabpage. + Examples: > + :let list_is_on = getwinvar(2, '&list') + :echo "myvar = " . getwinvar(1, 'myvar') + +< Can also be used as a |method|: > + GetWinnr()->getwinvar(varname) +< +glob({expr} [, {nosuf} [, {list} [, {alllinks}]]]) *glob()* + Expand the file wildcards in {expr}. See |wildcards| for the + use of special characters. + + Unless the optional {nosuf} argument is given and is |TRUE|, + the 'suffixes' and 'wildignore' options apply: Names matching + one of the patterns in 'wildignore' will be skipped and + 'suffixes' affect the ordering of matches. + 'wildignorecase' always applies. + + When {list} is present and it is |TRUE| the result is a |List| + with all matching files. The advantage of using a List is, + you also get filenames containing newlines correctly. + Otherwise the result is a String and when there are several + matches, they are separated by characters. + + If the expansion fails, the result is an empty String or List. + + You can also use |readdir()| if you need to do complicated + things, such as limiting the number of matches. + + A name for a non-existing file is not included. A symbolic + link is only included if it points to an existing file. + However, when the {alllinks} argument is present and it is + |TRUE| then all symbolic links are included. + + For most systems backticks can be used to get files names from + any external command. Example: > + :let tagfiles = glob("`find . -name tags -print`") + :let &tags = substitute(tagfiles, "\n", ",", "g") +< The result of the program inside the backticks should be one + item per line. Spaces inside an item are allowed. + + See |expand()| for expanding special Vim variables. See + |system()| for getting the raw output of an external command. + + Can also be used as a |method|: > + GetExpr()->glob() + +glob2regpat({string}) *glob2regpat()* + Convert a file pattern, as used by glob(), into a search + pattern. The result can be used to match with a string that + is a file name. E.g. > + if filename =~ glob2regpat('Make*.mak') +< This is equivalent to: > + if filename =~ '^Make.*\.mak$' +< When {string} is an empty string the result is "^$", match an + empty string. + Note that the result depends on the system. On MS-Windows + a backslash usually means a path separator. + + Can also be used as a |method|: > + GetExpr()->glob2regpat() +< *globpath()* +globpath({path}, {expr} [, {nosuf} [, {list} [, {allinks}]]]) + Perform glob() for String {expr} on all directories in {path} + and concatenate the results. Example: > + :echo globpath(&rtp, "syntax/c.vim") +< + {path} is a comma-separated list of directory names. Each + directory name is prepended to {expr} and expanded like with + |glob()|. A path separator is inserted when needed. + To add a comma inside a directory name escape it with a + backslash. Note that on MS-Windows a directory may have a + trailing backslash, remove it if you put a comma after it. + If the expansion fails for one of the directories, there is no + error message. + + Unless the optional {nosuf} argument is given and is |TRUE|, + the 'suffixes' and 'wildignore' options apply: Names matching + one of the patterns in 'wildignore' will be skipped and + 'suffixes' affect the ordering of matches. + + When {list} is present and it is |TRUE| the result is a |List| + with all matching files. The advantage of using a List is, you + also get filenames containing newlines correctly. Otherwise + the result is a String and when there are several matches, + they are separated by characters. Example: > + :echo globpath(&rtp, "syntax/c.vim", 0, 1) +< + {allinks} is used as with |glob()|. + + The "**" item can be used to search in a directory tree. + For example, to find all "README.txt" files in the directories + in 'runtimepath' and below: > + :echo globpath(&rtp, "**/README.txt") +< Upwards search and limiting the depth of "**" is not + supported, thus using 'path' will not always work properly. + + Can also be used as a |method|, the base is passed as the + second argument: > + GetExpr()->globpath(&rtp) +< + *has()* +has({feature}) Returns 1 if {feature} is supported, 0 otherwise. The + {feature} argument is a feature name like "nvim-0.2.1" or + "win32", see below. See also |exists()|. + + If the code has a syntax error, then Nvim may skip the rest + of the line and miss |:endif|. > + if has('feature') | let x = this->breaks->without->the->feature | endif +< + Put |:if| and |:endif| on separate lines to avoid the + syntax error. > + if has('feature') + let x = this->breaks->without->the->feature + endif +< + Vim's compile-time feature-names (prefixed with "+") are not + recognized because Nvim is always compiled with all possible + features. |feature-compile| + + Feature names can be: + 1. Nvim version. For example the "nvim-0.2.1" feature means + that Nvim is version 0.2.1 or later: > + :if has("nvim-0.2.1") + +< 2. Runtime condition or other pseudo-feature. For example the + "win32" feature checks if the current system is Windows: > + :if has("win32") +< *feature-list* + List of supported pseudo-feature names: + acl |ACL| support + bsd BSD system (not macOS, use "mac" for that). + iconv Can use |iconv()| for conversion. + +shellslash Can use backslashes in filenames (Windows) + clipboard |clipboard| provider is available. + fname_case Case in file names matters (for Darwin and MS-Windows + this is not present). + mac MacOS system. + nvim This is Nvim. + python3 Legacy Vim |python3| interface. |has-python| + pythonx Legacy Vim |python_x| interface. |has-pythonx| + ttyin input is a terminal (tty) + ttyout output is a terminal (tty) + unix Unix system. + *vim_starting* True during |startup|. + win32 Windows system (32 or 64 bit). + win64 Windows system (64 bit). + wsl WSL (Windows Subsystem for Linux) system + + *has-patch* + 3. Vim patch. For example the "patch123" feature means that + Vim patch 123 at the current |v:version| was included: > + :if v:version > 602 || v:version == 602 && has("patch148") + +< 4. Vim version. For example the "patch-7.4.237" feature means + that Nvim is Vim-compatible to version 7.4.237 or later. > + :if has("patch-7.4.237") + + +has_key({dict}, {key}) *has_key()* + The result is a Number, which is TRUE if |Dictionary| {dict} + has an entry with key {key}. FALSE otherwise. The {key} + argument is a string. + + Can also be used as a |method|: > + mydict->has_key(key) + +haslocaldir([{winnr}[, {tabnr}]]) *haslocaldir()* + The result is a Number, which is 1 when the window has set a + local path via |:lcd| or when {winnr} is -1 and the tabpage + has set a local path via |:tcd|, otherwise 0. + + Tabs and windows are identified by their respective numbers, + 0 means current tab or window. Missing argument implies 0. + Thus the following are equivalent: > + haslocaldir() + haslocaldir(0) + haslocaldir(0, 0) +< With {winnr} use that window in the current tabpage. + With {winnr} and {tabnr} use the window in that tabpage. + {winnr} can be the window number or the |window-ID|. + If {winnr} is -1 it is ignored, only the tab is resolved. + Throw error if the arguments are invalid. |E5000| |E5001| |E5002| + + Can also be used as a |method|: > + GetWinnr()->haslocaldir() + +hasmapto({what} [, {mode} [, {abbr}]]) *hasmapto()* + The result is a Number, which is TRUE if there is a mapping + that contains {what} in somewhere in the rhs (what it is + mapped to) and this mapping exists in one of the modes + indicated by {mode}. + The arguments {what} and {mode} are strings. + When {abbr} is there and it is |TRUE| use abbreviations + instead of mappings. Don't forget to specify Insert and/or + Command-line mode. + Both the global mappings and the mappings local to the current + buffer are checked for a match. + If no matching mapping is found FALSE is returned. + The following characters are recognized in {mode}: + n Normal mode + v Visual and Select mode + x Visual mode + s Select mode + o Operator-pending mode + i Insert mode + l Language-Argument ("r", "f", "t", etc.) + c Command-line mode + When {mode} is omitted, "nvo" is used. + + This function is useful to check if a mapping already exists + to a function in a Vim script. Example: > + :if !hasmapto('\ABCdoit') + : map d \ABCdoit + :endif +< This installs the mapping to "\ABCdoit" only if there isn't + already a mapping to "\ABCdoit". + + Can also be used as a |method|: > + GetRHS()->hasmapto() + +histadd({history}, {item}) *histadd()* + Add the String {item} to the history {history} which can be + one of: *hist-names* + "cmd" or ":" command line history + "search" or "/" search pattern history + "expr" or "=" typed expression history + "input" or "@" input line history + "debug" or ">" debug command history + empty the current or last used history + The {history} string does not need to be the whole name, one + character is sufficient. + If {item} does already exist in the history, it will be + shifted to become the newest entry. + The result is a Number: TRUE if the operation was successful, + otherwise FALSE is returned. + + Example: > + :call histadd("input", strftime("%Y %b %d")) + :let date=input("Enter date: ") +< This function is not available in the |sandbox|. + + Can also be used as a |method|, the base is passed as the + second argument: > + GetHistory()->histadd('search') + +histdel({history} [, {item}]) *histdel()* + Clear {history}, i.e. delete all its entries. See |hist-names| + for the possible values of {history}. + + If the parameter {item} evaluates to a String, it is used as a + regular expression. All entries matching that expression will + be removed from the history (if there are any). + Upper/lowercase must match, unless "\c" is used |/\c|. + If {item} evaluates to a Number, it will be interpreted as + an index, see |:history-indexing|. The respective entry will + be removed if it exists. + + The result is TRUE for a successful operation, otherwise FALSE + is returned. + + Examples: + Clear expression register history: > + :call histdel("expr") +< + Remove all entries starting with "*" from the search history: > + :call histdel("/", '^\*') +< + The following three are equivalent: > + :call histdel("search", histnr("search")) + :call histdel("search", -1) + :call histdel("search", '^'.histget("search", -1).'$') +< + To delete the last search pattern and use the last-but-one for + the "n" command and 'hlsearch': > + :call histdel("search", -1) + :let @/ = histget("search", -1) +< + Can also be used as a |method|: > + GetHistory()->histdel() + +histget({history} [, {index}]) *histget()* + The result is a String, the entry with Number {index} from + {history}. See |hist-names| for the possible values of + {history}, and |:history-indexing| for {index}. If there is + no such entry, an empty String is returned. When {index} is + omitted, the most recent item from the history is used. + + Examples: + Redo the second last search from history. > + :execute '/' . histget("search", -2) + +< Define an Ex command ":H {num}" that supports re-execution of + the {num}th entry from the output of |:history|. > + :command -nargs=1 H execute histget("cmd", 0+) +< + Can also be used as a |method|: > + GetHistory()->histget() + +histnr({history}) *histnr()* + The result is the Number of the current entry in {history}. + See |hist-names| for the possible values of {history}. + If an error occurred, -1 is returned. + + Example: > + :let inp_index = histnr("expr") + +< Can also be used as a |method|: > + GetHistory()->histnr() +< +hlexists({name}) *hlexists()* + The result is a Number, which is TRUE if a highlight group + called {name} exists. This is when the group has been + defined in some way. Not necessarily when highlighting has + been defined for it, it may also have been used for a syntax + item. + + Can also be used as a |method|: > + GetName()->hlexists() +< + *hlID()* +hlID({name}) The result is a Number, which is the ID of the highlight group + with name {name}. When the highlight group doesn't exist, + zero is returned. + This can be used to retrieve information about the highlight + group. For example, to get the background color of the + "Comment" group: > + :echo synIDattr(synIDtrans(hlID("Comment")), "bg") +< + Can also be used as a |method|: > + GetName()->hlID() + +hostname() *hostname()* + The result is a String, which is the name of the machine on + which Vim is currently running. Machine names greater than + 256 characters long are truncated. + +iconv({string}, {from}, {to}) *iconv()* + The result is a String, which is the text {string} converted + from encoding {from} to encoding {to}. + When the conversion completely fails an empty string is + returned. When some characters could not be converted they + are replaced with "?". + The encoding names are whatever the iconv() library function + can accept, see ":!man 3 iconv". + Note that Vim uses UTF-8 for all Unicode encodings, conversion + from/to UCS-2 is automatically changed to use UTF-8. You + cannot use UCS-2 in a string anyway, because of the NUL bytes. + + Can also be used as a |method|: > + GetText()->iconv('latin1', 'utf-8') +< + *indent()* +indent({lnum}) The result is a Number, which is indent of line {lnum} in the + current buffer. The indent is counted in spaces, the value + of 'tabstop' is relevant. {lnum} is used just like in + |getline()|. + When {lnum} is invalid -1 is returned. + + Can also be used as a |method|: > + GetLnum()->indent() + +index({object}, {expr} [, {start} [, {ic}]]) *index()* + If {object} is a |List| return the lowest index where the item + has a value equal to {expr}. There is no automatic + conversion, so the String "4" is different from the Number 4. + And the Number 4 is different from the Float 4.0. The value + of 'ignorecase' is not used here, case always matters. + + If {object} is a |Blob| return the lowest index where the byte + value is equal to {expr}. + + If {start} is given then start looking at the item with index + {start} (may be negative for an item relative to the end). + When {ic} is given and it is |TRUE|, ignore case. Otherwise + case must match. + -1 is returned when {expr} is not found in {object}. + Example: > + :let idx = index(words, "the") + :if index(numbers, 123) >= 0 + +< Can also be used as a |method|: > + GetObject()->index(what) + +input({prompt} [, {text} [, {completion}]]) *input()* +input({opts}) + The result is a String, which is whatever the user typed on + the command-line. The {prompt} argument is either a prompt + string, or a blank string (for no prompt). A '\n' can be used + in the prompt to start a new line. + + In the second form it accepts a single dictionary with the + following keys, any of which may be omitted: + + Key Default Description ~ + prompt "" Same as {prompt} in the first form. + default "" Same as {text} in the first form. + completion nothing Same as {completion} in the first form. + cancelreturn "" The value returned when the dialog is + cancelled. + highlight nothing Highlight handler: |Funcref|. + + The highlighting set with |:echohl| is used for the prompt. + The input is entered just like a command-line, with the same + editing commands and mappings. There is a separate history + for lines typed for input(). + Example: > + :if input("Coffee or beer? ") == "beer" + : echo "Cheers!" + :endif +< + If the optional {text} argument is present and not empty, this + is used for the default reply, as if the user typed this. + Example: > + :let color = input("Color? ", "white") + +< The optional {completion} argument specifies the type of + completion supported for the input. Without it completion is + not performed. The supported completion types are the same as + that can be supplied to a user-defined command using the + "-complete=" argument. Refer to |:command-completion| for + more information. Example: > + let fname = input("File: ", "", "file") + +< *input()-highlight* *E5400* *E5402* + The optional `highlight` key allows specifying function which + will be used for highlighting user input. This function + receives user input as its only argument and must return + a list of 3-tuples [hl_start_col, hl_end_col + 1, hl_group] + where + hl_start_col is the first highlighted column, + hl_end_col is the last highlighted column (+ 1!), + hl_group is |:hi| group used for highlighting. + *E5403* *E5404* *E5405* *E5406* + Both hl_start_col and hl_end_col + 1 must point to the start + of the multibyte character (highlighting must not break + multibyte characters), hl_end_col + 1 may be equal to the + input length. Start column must be in range [0, len(input)), + end column must be in range (hl_start_col, len(input)], + sections must be ordered so that next hl_start_col is greater + then or equal to previous hl_end_col. + + Example (try some input with parentheses): > + highlight RBP1 guibg=Red ctermbg=red + highlight RBP2 guibg=Yellow ctermbg=yellow + highlight RBP3 guibg=Green ctermbg=green + highlight RBP4 guibg=Blue ctermbg=blue + let g:rainbow_levels = 4 + function! RainbowParens(cmdline) + let ret = [] + let i = 0 + let lvl = 0 + while i < len(a:cmdline) + if a:cmdline[i] is# '(' + call add(ret, [i, i + 1, 'RBP' . ((lvl % g:rainbow_levels) + 1)]) + let lvl += 1 + elseif a:cmdline[i] is# ')' + let lvl -= 1 + call add(ret, [i, i + 1, 'RBP' . ((lvl % g:rainbow_levels) + 1)]) + endif + let i += 1 + endwhile + return ret + endfunction + call input({'prompt':'>','highlight':'RainbowParens'}) +< + Highlight function is called at least once for each new + displayed input string, before command-line is redrawn. It is + expected that function is pure for the duration of one input() + call, i.e. it produces the same output for the same input, so + output may be memoized. Function is run like under |:silent| + modifier. If the function causes any errors, it will be + skipped for the duration of the current input() call. + + Highlighting is disabled if command-line contains arabic + characters. + + NOTE: This function must not be used in a startup file, for + the versions that only run in GUI mode (e.g., the Win32 GUI). + Note: When input() is called from within a mapping it will + consume remaining characters from that mapping, because a + mapping is handled like the characters were typed. + Use |inputsave()| before input() and |inputrestore()| + after input() to avoid that. Another solution is to avoid + that further characters follow in the mapping, e.g., by using + |:execute| or |:normal|. + + Example with a mapping: > + :nmap \x :call GetFoo():exe "/" . Foo + :function GetFoo() + : call inputsave() + : let g:Foo = input("enter search pattern: ") + : call inputrestore() + :endfunction + +< Can also be used as a |method|: > + GetPrompt()->input() + +inputlist({textlist}) *inputlist()* + {textlist} must be a |List| of strings. This |List| is + displayed, one string per line. The user will be prompted to + enter a number, which is returned. + The user can also select an item by clicking on it with the + mouse, if the mouse is enabled in the command line ('mouse' is + "a" or includes "c"). For the first string 0 is returned. + When clicking above the first item a negative number is + returned. When clicking on the prompt one more than the + length of {textlist} is returned. + Make sure {textlist} has less than 'lines' entries, otherwise + it won't work. It's a good idea to put the entry number at + the start of the string. And put a prompt in the first item. + Example: > + let color = inputlist(['Select color:', '1. red', + \ '2. green', '3. blue']) + +< Can also be used as a |method|: > + GetChoices()->inputlist() + +inputrestore() *inputrestore()* + Restore typeahead that was saved with a previous |inputsave()|. + Should be called the same number of times inputsave() is + called. Calling it more often is harmless though. + Returns TRUE when there is nothing to restore, FALSE otherwise. + +inputsave() *inputsave()* + Preserve typeahead (also from mappings) and clear it, so that + a following prompt gets input from the user. Should be + followed by a matching inputrestore() after the prompt. Can + be used several times, in which case there must be just as + many inputrestore() calls. + Returns TRUE when out of memory, FALSE otherwise. + +inputsecret({prompt} [, {text}]) *inputsecret()* + This function acts much like the |input()| function with but + two exceptions: + a) the user's response will be displayed as a sequence of + asterisks ("*") thereby keeping the entry secret, and + b) the user's response will not be recorded on the input + |history| stack. + The result is a String, which is whatever the user actually + typed on the command-line in response to the issued prompt. + NOTE: Command-line completion is not supported. + + Can also be used as a |method|: > + GetPrompt()->inputsecret() + +insert({object}, {item} [, {idx}]) *insert()* + When {object} is a |List| or a |Blob| insert {item} at the start + of it. + + If {idx} is specified insert {item} before the item with index + {idx}. If {idx} is zero it goes before the first item, just + like omitting {idx}. A negative {idx} is also possible, see + |list-index|. -1 inserts just before the last item. + + Returns the resulting |List| or |Blob|. Examples: > + :let mylist = insert([2, 3, 5], 1) + :call insert(mylist, 4, -1) + :call insert(mylist, 6, len(mylist)) +< The last example can be done simpler with |add()|. + Note that when {item} is a |List| it is inserted as a single + item. Use |extend()| to concatenate |Lists|. + + Can also be used as a |method|: > + mylist->insert(item) + +interrupt() *interrupt()* + Interrupt script execution. It works more or less like the + user typing CTRL-C, most commands won't execute and control + returns to the user. This is useful to abort execution + from lower down, e.g. in an autocommand. Example: > + :function s:check_typoname(file) + : if fnamemodify(a:file, ':t') == '[' + : echomsg 'Maybe typo' + : call interrupt() + : endif + :endfunction + :au BufWritePre * call s:check_typoname(expand('')) + +invert({expr}) *invert()* + Bitwise invert. The argument is converted to a number. A + List, Dict or Float argument causes an error. Example: > + :let bits = invert(bits) +< Can also be used as a |method|: > + :let bits = bits->invert() + +isdirectory({directory}) *isdirectory()* + The result is a Number, which is |TRUE| when a directory + with the name {directory} exists. If {directory} doesn't + exist, or isn't a directory, the result is |FALSE|. {directory} + is any expression, which is used as a String. + + Can also be used as a |method|: > + GetName()->isdirectory() + +isinf({expr}) *isinf()* + Return 1 if {expr} is a positive infinity, or -1 a negative + infinity, otherwise 0. > + :echo isinf(1.0 / 0.0) +< 1 > + :echo isinf(-1.0 / 0.0) +< -1 + + Can also be used as a |method|: > + Compute()->isinf() + +islocked({expr}) *islocked()* *E786* + The result is a Number, which is |TRUE| when {expr} is the + name of a locked variable. + The string argument {expr} must be the name of a variable, + |List| item or |Dictionary| entry, not the variable itself! + Example: > + :let alist = [0, ['a', 'b'], 2, 3] + :lockvar 1 alist + :echo islocked('alist') " 1 + :echo islocked('alist[1]') " 0 + +< When {expr} is a variable that does not exist you get an error + message. Use |exists()| to check for existence. + + Can also be used as a |method|: > + GetName()->islocked() + +id({expr}) *id()* + Returns a |String| which is a unique identifier of the + container type (|List|, |Dict|, |Blob| and |Partial|). It is + guaranteed that for the mentioned types `id(v1) ==# id(v2)` + returns true iff `type(v1) == type(v2) && v1 is v2`. + Note that |v:_null_string|, |v:_null_list|, |v:_null_dict| and + |v:_null_blob| have the same `id()` with different types + because they are internally represented as NULL pointers. + `id()` returns a hexadecimal representanion of the pointers to + the containers (i.e. like `0x994a40`), same as `printf("%p", + {expr})`, but it is advised against counting on the exact + format of the return value. + + It is not guaranteed that `id(no_longer_existing_container)` + will not be equal to some other `id()`: new containers may + reuse identifiers of the garbage-collected ones. + +items({dict}) *items()* + Return a |List| with all the key-value pairs of {dict}. Each + |List| item is a list with two items: the key of a {dict} + entry and the value of this entry. The |List| is in arbitrary + order. Also see |keys()| and |values()|. + Example: > + for [key, value] in items(mydict) + echo key . ': ' . value + endfor + +< Can also be used as a |method|: > + mydict->items() + +isnan({expr}) *isnan()* + Return |TRUE| if {expr} is a float with value NaN. > + echo isnan(0.0 / 0.0) +< 1 + + Can also be used as a |method|: > + Compute()->isnan() + +jobpid({job}) *jobpid()* + Return the PID (process id) of |job-id| {job}. + +jobresize({job}, {width}, {height}) *jobresize()* + Resize the pseudo terminal window of |job-id| {job} to {width} + columns and {height} rows. + Fails if the job was not started with `"pty":v:true`. + +jobstart({cmd}[, {opts}]) *jobstart()* + Spawns {cmd} as a job. + If {cmd} is a List it runs directly (no 'shell'). + If {cmd} is a String it runs in the 'shell', like this: > + :call jobstart(split(&shell) + split(&shellcmdflag) + ['{cmd}']) +< (See |shell-unquoting| for details.) + + Example: > + :call jobstart('nvim -h', {'on_stdout':{j,d,e->append(line('.'),d)}}) +< + Returns |job-id| on success, 0 on invalid arguments (or job + table is full), -1 if {cmd}[0] or 'shell' is not executable. + The returned job-id is a valid |channel-id| representing the + job's stdio streams. Use |chansend()| (or |rpcnotify()| and + |rpcrequest()| if "rpc" was enabled) to send data to stdin and + |chanclose()| to close the streams without stopping the job. + + See |job-control| and |RPC|. + + NOTE: on Windows if {cmd} is a List: + - cmd[0] must be an executable (not a "built-in"). If it is + in $PATH it can be called by name, without an extension: > + :call jobstart(['ping', 'neovim.io']) +< If it is a full or partial path, extension is required: > + :call jobstart(['System32\ping.exe', 'neovim.io']) +< - {cmd} is collapsed to a string of quoted args as expected + by CommandLineToArgvW https://msdn.microsoft.com/bb776391 + unless cmd[0] is some form of "cmd.exe". + + *jobstart-options* + {opts} is a dictionary with these keys: + clear_env: (boolean) `env` defines the job environment + exactly, instead of merging current environment. + cwd: (string, default=|current-directory|) Working + directory of the job. + detach: (boolean) Detach the job process: it will not be + killed when Nvim exits. If the process exits + before Nvim, `on_exit` will be invoked. + env: (dict) Map of environment variable name:value + pairs extending (or replacing if |clear_env|) + the current environment. + height: (number) Height of the `pty` terminal. + |on_exit|: (function) Callback invoked when the job exits. + |on_stdout|: (function) Callback invoked when the job emits + stdout data. + |on_stderr|: (function) Callback invoked when the job emits + stderr data. + overlapped: (boolean) Set FILE_FLAG_OVERLAPPED for the + standard input/output passed to the child process. + Normally you do not need to set this. + (Only available on MS-Windows, On other + platforms, this option is silently ignored.) + pty: (boolean) Connect the job to a new pseudo + terminal, and its streams to the master file + descriptor. Then `on_stderr` is ignored, + `on_stdout` receives all output. + rpc: (boolean) Use |msgpack-rpc| to communicate with + the job over stdio. Then `on_stdout` is ignored, + but `on_stderr` can still be used. + stderr_buffered: (boolean) Collect data until EOF (stream closed) + before invoking `on_stderr`. |channel-buffered| + stdout_buffered: (boolean) Collect data until EOF (stream + closed) before invoking `on_stdout`. |channel-buffered| + stdin: (string) Either "pipe" (default) to connect the + job's stdin to a channel or "null" to disconnect + stdin. + width: (number) Width of the `pty` terminal. + + {opts} is passed as |self| dictionary to the callback; the + caller may set other keys to pass application-specific data. + + Returns: + - |channel-id| on success + - 0 on invalid arguments + - -1 if {cmd}[0] is not executable. + See also |job-control|, |channel|, |msgpack-rpc|. + +jobstop({id}) *jobstop()* + Stop |job-id| {id} by sending SIGTERM to the job process. If + the process does not terminate after a timeout then SIGKILL + will be sent. When the job terminates its |on_exit| handler + (if any) will be invoked. + See |job-control|. + + Returns 1 for valid job id, 0 for invalid id, including jobs have + exited or stopped. + +jobwait({jobs}[, {timeout}]) *jobwait()* + Waits for jobs and their |on_exit| handlers to complete. + + {jobs} is a List of |job-id|s to wait for. + {timeout} is the maximum waiting time in milliseconds. If + omitted or -1, wait forever. + + Timeout of 0 can be used to check the status of a job: > + let running = jobwait([{job-id}], 0)[0] == -1 +< + During jobwait() callbacks for jobs not in the {jobs} list may + be invoked. The screen will not redraw unless |:redraw| is + invoked by a callback. + + Returns a list of len({jobs}) integers, where each integer is + the status of the corresponding job: + Exit-code, if the job exited + -1 if the timeout was exceeded + -2 if the job was interrupted (by |CTRL-C|) + -3 if the job-id is invalid + +join({list} [, {sep}]) *join()* + Join the items in {list} together into one String. + When {sep} is specified it is put in between the items. If + {sep} is omitted a single space is used. + Note that {sep} is not added at the end. You might want to + add it there too: > + let lines = join(mylist, "\n") . "\n" +< String items are used as-is. |Lists| and |Dictionaries| are + converted into a string like with |string()|. + The opposite function is |split()|. + + Can also be used as a |method|: > + mylist->join() + +json_decode({expr}) *json_decode()* + Convert {expr} from JSON object. Accepts |readfile()|-style + list as the input, as well as regular string. May output any + Vim value. In the following cases it will output + |msgpack-special-dict|: + 1. Dictionary contains duplicate key. + 2. Dictionary contains empty key. + 3. String contains NUL byte. Two special dictionaries: for + dictionary and for string will be emitted in case string + with NUL byte was a dictionary key. + + Note: function treats its input as UTF-8 always. The JSON + standard allows only a few encodings, of which UTF-8 is + recommended and the only one required to be supported. + Non-UTF-8 characters are an error. + + Can also be used as a |method|: > + ReadObject()->json_decode() + +json_encode({expr}) *json_encode()* + Convert {expr} into a JSON string. Accepts + |msgpack-special-dict| as the input. Will not convert + |Funcref|s, mappings with non-string keys (can be created as + |msgpack-special-dict|), values with self-referencing + containers, strings which contain non-UTF-8 characters, + pseudo-UTF-8 strings which contain codepoints reserved for + surrogate pairs (such strings are not valid UTF-8 strings). + Non-printable characters are converted into "\u1234" escapes + or special escapes like "\t", other are dumped as-is. + |Blob|s are converted to arrays of the individual bytes. + + Can also be used as a |method|: > + GetObject()->json_encode() + +keys({dict}) *keys()* + Return a |List| with all the keys of {dict}. The |List| is in + arbitrary order. Also see |items()| and |values()|. + + Can also be used as a |method|: > + mydict->keys() + +< *len()* *E701* +len({expr}) The result is a Number, which is the length of the argument. + When {expr} is a String or a Number the length in bytes is + used, as with |strlen()|. + When {expr} is a |List| the number of items in the |List| is + returned. + When {expr} is a |Blob| the number of bytes is returned. + When {expr} is a |Dictionary| the number of entries in the + |Dictionary| is returned. + Otherwise an error is given. + + Can also be used as a |method|: > + mylist->len() + +< *libcall()* *E364* *E368* +libcall({libname}, {funcname}, {argument}) + Call function {funcname} in the run-time library {libname} + with single argument {argument}. + This is useful to call functions in a library that you + especially made to be used with Vim. Since only one argument + is possible, calling standard library functions is rather + limited. + The result is the String returned by the function. If the + function returns NULL, this will appear as an empty string "" + to Vim. + If the function returns a number, use libcallnr()! + If {argument} is a number, it is passed to the function as an + int; if {argument} is a string, it is passed as a + null-terminated string. + + libcall() allows you to write your own 'plug-in' extensions to + Vim without having to recompile the program. It is NOT a + means to call system functions! If you try to do so Vim will + very probably crash. + + For Win32, the functions you write must be placed in a DLL + and use the normal C calling convention (NOT Pascal which is + used in Windows System DLLs). The function must take exactly + one parameter, either a character pointer or a long integer, + and must return a character pointer or NULL. The character + pointer returned must point to memory that will remain valid + after the function has returned (e.g. in static data in the + DLL). If it points to allocated memory, that memory will + leak away. Using a static buffer in the function should work, + it's then freed when the DLL is unloaded. + + WARNING: If the function returns a non-valid pointer, Vim may + crash! This also happens if the function returns a number, + because Vim thinks it's a pointer. + For Win32 systems, {libname} should be the filename of the DLL + without the ".DLL" suffix. A full path is only required if + the DLL is not in the usual places. + For Unix: When compiling your own plugins, remember that the + object code must be compiled as position-independent ('PIC'). + Examples: > + :echo libcall("libc.so", "getenv", "HOME") + +< Can also be used as a |method|, the base is passed as the + third argument: > + GetValue()->libcall("libc.so", "getenv") +< + *libcallnr()* +libcallnr({libname}, {funcname}, {argument}) + Just like |libcall()|, but used for a function that returns an + int instead of a string. + Examples: > + :echo libcallnr("/usr/lib/libc.so", "getpid", "") + :call libcallnr("libc.so", "printf", "Hello World!\n") + :call libcallnr("libc.so", "sleep", 10) +< + Can also be used as a |method|, the base is passed as the + third argument: > + GetValue()->libcallnr("libc.so", "printf") +< +line({expr} [, {winid}]) *line()* + The result is a Number, which is the line number of the file + position given with {expr}. The {expr} argument is a string. + The accepted positions are: + . the cursor position + $ the last line in the current buffer + 'x position of mark x (if the mark is not set, 0 is + returned) + w0 first line visible in current window (one if the + display isn't updated, e.g. in silent Ex mode) + w$ last line visible in current window (this is one + less than "w0" if no lines are visible) + v In Visual mode: the start of the Visual area (the + cursor is the end). When not in Visual mode + returns the cursor position. Differs from |'<| in + that it's updated right away. + Note that a mark in another file can be used. The line number + then applies to another buffer. + To get the column number use |col()|. To get both use + |getpos()|. + With the optional {winid} argument the values are obtained for + that window instead of the current window. + Examples: > + line(".") line number of the cursor + line(".", winid) idem, in window "winid" + line("'t") line number of mark t + line("'" . marker) line number of mark marker +< + Can also be used as a |method|: > + GetValue()->line() + +line2byte({lnum}) *line2byte()* + Return the byte count from the start of the buffer for line + {lnum}. This includes the end-of-line character, depending on + the 'fileformat' option for the current buffer. The first + line returns 1. UTF-8 encoding is used, 'fileencoding' is + ignored. This can also be used to get the byte count for the + line just below the last line: > + line2byte(line("$") + 1) +< This is the buffer size plus one. If 'fileencoding' is empty + it is the file size plus one. {lnum} is used like with + |getline()|. When {lnum} is invalid -1 is returned. + Also see |byte2line()|, |go| and |:goto|. + + Can also be used as a |method|: > + GetLnum()->line2byte() + +lispindent({lnum}) *lispindent()* + Get the amount of indent for line {lnum} according the lisp + indenting rules, as with 'lisp'. + The indent is counted in spaces, the value of 'tabstop' is + relevant. {lnum} is used just like in |getline()|. + When {lnum} is invalid, -1 is returned. + + Can also be used as a |method|: > + GetLnum()->lispindent() + +list2str({list} [, {utf8}]) *list2str()* + Convert each number in {list} to a character string can + concatenate them all. Examples: > + list2str([32]) returns " " + list2str([65, 66, 67]) returns "ABC" +< The same can be done (slowly) with: > + join(map(list, {nr, val -> nr2char(val)}), '') +< |str2list()| does the opposite. + + UTF-8 encoding is always used, {utf8} option has no effect, + and exists only for backwards-compatibility. + With UTF-8 composing characters work as expected: > + list2str([97, 769]) returns "á" +< + Can also be used as a |method|: > + GetList()->list2str() + +localtime() *localtime()* + Return the current time, measured as seconds since 1st Jan + 1970. See also |strftime()|, |strptime()| and |getftime()|. + + +log({expr}) *log()* + Return the natural logarithm (base e) of {expr} as a |Float|. + {expr} must evaluate to a |Float| or a |Number| in the range + (0, inf]. + Examples: > + :echo log(10) +< 2.302585 > + :echo log(exp(5)) +< 5.0 + + Can also be used as a |method|: > + Compute()->log() + +log10({expr}) *log10()* + Return the logarithm of Float {expr} to base 10 as a |Float|. + {expr} must evaluate to a |Float| or a |Number|. + Examples: > + :echo log10(1000) +< 3.0 > + :echo log10(0.01) +< -2.0 + + Can also be used as a |method|: > + Compute()->log10() + +luaeval({expr}[, {expr}]) + Evaluate Lua expression {expr} and return its result converted + to Vim data structures. See |lua-eval| for more details. + + Can also be used as a |method|: > + GetExpr()->luaeval() + +map({expr1}, {expr2}) *map()* + {expr1} must be a |List|, |Blob| or |Dictionary|. + Replace each item in {expr1} with the result of evaluating + {expr2}. For a |Blob| each byte is replaced. + + {expr2} must be a |string| or |Funcref|. + + If {expr2} is a |string|, inside {expr2} |v:val| has the value + of the current item. For a |Dictionary| |v:key| has the key + of the current item and for a |List| |v:key| has the index of + the current item. For a |Blob| |v:key| has the index of the + current byte. + Example: > + :call map(mylist, '"> " . v:val . " <"') +< This puts "> " before and " <" after each item in "mylist". + + Note that {expr2} is the result of an expression and is then + used as an expression again. Often it is good to use a + |literal-string| to avoid having to double backslashes. You + still have to double ' quotes + + If {expr2} is a |Funcref| it is called with two arguments: + 1. The key or the index of the current item. + 2. the value of the current item. + The function must return the new value of the item. Example + that changes each value by "key-value": > + func KeyValue(key, val) + return a:key . '-' . a:val + endfunc + call map(myDict, function('KeyValue')) +< It is shorter when using a |lambda|: > + call map(myDict, {key, val -> key . '-' . val}) +< If you do not use "val" you can leave it out: > + call map(myDict, {key -> 'item: ' . key}) +< If you do not use "key" you can use a short name: > + call map(myDict, {_, val -> 'item: ' . val}) +< + The operation is done in-place. If you want a |List| or + |Dictionary| to remain unmodified make a copy first: > + :let tlist = map(copy(mylist), ' v:val . "\t"') + +< Returns {expr1}, the |List|, |Blob| or |Dictionary| that was + filtered. When an error is encountered while evaluating + {expr2} no further items in {expr1} are processed. When + {expr2} is a Funcref errors inside a function are ignored, + unless it was defined with the "abort" flag. + + Can also be used as a |method|: > + mylist->map(expr2) + +maparg({name} [, {mode} [, {abbr} [, {dict}]]]) *maparg()* + When {dict} is omitted or zero: Return the rhs of mapping + {name} in mode {mode}. The returned String has special + characters translated like in the output of the ":map" command + listing. + + When there is no mapping for {name}, an empty String is + returned. When the mapping for {name} is empty, then "" + is returned. + + The {name} can have special key names, like in the ":map" + command. + + {mode} can be one of these strings: + "n" Normal + "v" Visual (including Select) + "o" Operator-pending + "i" Insert + "c" Cmd-line + "s" Select + "x" Visual + "l" langmap |language-mapping| + "t" Terminal + "" Normal, Visual and Operator-pending + When {mode} is omitted, the modes for "" are used. + + When {abbr} is there and it is |TRUE| use abbreviations + instead of mappings. + + When {dict} is there and it is |TRUE| return a dictionary + containing all the information of the mapping with the + following items: + "lhs" The {lhs} of the mapping. + "rhs" The {rhs} of the mapping as typed. + "silent" 1 for a |:map-silent| mapping, else 0. + "noremap" 1 if the {rhs} of the mapping is not remappable. + "script" 1 if mapping was defined with +
+text +
% END_INDENT diff --git a/runtime/indent/testdir/html.ok b/runtime/indent/testdir/html.ok index c0dfc9dc72..938e965d8c 100644 --- a/runtime/indent/testdir/html.ok +++ b/runtime/indent/testdir/html.ok @@ -1,4 +1,4 @@ -" vim: set ft=html sw=4 : +" vim: set ft=html sw=4 ts=8 : " START_INDENT @@ -41,6 +41,11 @@ div#d2 { color: green; } dt text +
+ text +
@@ -50,6 +55,7 @@ div#d2 { color: green; } % START_INDENT % INDENT_EXE let g:html_indent_style1 = "inc" % INDENT_EXE let g:html_indent_script1 = "zero" +% INDENT_EXE let g:html_indent_attribute = 1 % INDENT_EXE call HtmlIndent_CheckUserSettings() @@ -61,6 +67,11 @@ div#d2 { color: green; } var v1 = "v1"; var v2 = "v2"; +
+ text +
% END_INDENT diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index adc838578d..ff44f48195 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -789,7 +789,7 @@ local extension = { ex = function() vim.fn["dist#ft#ExCheck"]() end, exu = function() vim.fn["dist#ft#EuphoriaCheck"]() end, exw = function() vim.fn["dist#ft#EuphoriaCheck"]() end, - frm = function() vim.fn["dist#ft#FTVB"]("form") end, + frm = function() vim.fn["dist#ft#FTbas"]("form") end, fs = function() vim.fn["dist#ft#FTfs"]() end, h = function() vim.fn["dist#ft#FTheader"]() end, htm = function() vim.fn["dist#ft#FThtml"]() end, -- cgit From a562b5771ea91becd0a469378ec852feaf50d2d0 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Tue, 1 Feb 2022 08:35:28 +0100 Subject: vim-patch:8.2.4274: Basic and form filetype detection is incomplete (#17259) Problem: Basic and form filetype detection is incomplete. Solution: Add a separate function for .frm files. (Doug Kearns, closes vim/vim#9675) https://github.com/vim/vim/commit/c570e9cf68c0fe30366e82c96be460047dd659b9 --- runtime/autoload/dist/ft.vim | 24 ++++++++++++++++++++---- runtime/filetype.vim | 2 +- runtime/lua/vim/filetype.lua | 2 +- 3 files changed, 22 insertions(+), 6 deletions(-) (limited to 'runtime') diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim index f513a2ac8f..5d8734a625 100644 --- a/runtime/autoload/dist/ft.vim +++ b/runtime/autoload/dist/ft.vim @@ -67,7 +67,10 @@ func dist#ft#FTasmsyntax() endif endfunc -func dist#ft#FTbas(alt = '') +let s:ft_visual_basic_content = '\cVB_Name\|Begin VB\.\(Form\|MDIForm\|UserControl\)' + +" See FTfrm() for Visual Basic form file detection +func dist#ft#FTbas() if exists("g:filetype_bas") exe "setf " . g:filetype_bas return @@ -86,10 +89,8 @@ func dist#ft#FTbas(alt = '') setf freebasic elseif match(lines, qb64_preproc) > -1 setf qb64 - elseif match(lines, '\cVB_Name\|Begin VB\.\(Form\|MDIForm\|UserControl\)') > -1 + elseif match(lines, s:ft_visual_basic_content) > -1 setf vb - elseif a:alt != '' - exe 'setf ' .. a:alt else setf basic endif @@ -237,6 +238,21 @@ func dist#ft#FTe() endif endfunc +func dist#ft#FTfrm() + if exists("g:filetype_frm") + exe "setf " . g:filetype_frm + return + endif + + let lines = getline(1, min([line("$"), 5])) + + if match(lines, s:ft_visual_basic_content) > -1 + setf vb + else + setf form + endif +endfunc + " Distinguish between Forth and F#. " Provided by Doug Kearns. func dist#ft#FTfs() diff --git a/runtime/filetype.vim b/runtime/filetype.vim index 7c86809cb8..8b40b43a04 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -2050,7 +2050,7 @@ au BufRead,BufNewFile *.hw,*.module,*.pkg \ endif " Visual Basic (also uses *.bas) or FORM -au BufNewFile,BufRead *.frm call dist#ft#FTbas('form') +au BufNewFile,BufRead *.frm call dist#ft#FTfrm() " SaxBasic is close to Visual Basic au BufNewFile,BufRead *.sba setf vb diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index ff44f48195..e2cf408f3b 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -789,7 +789,7 @@ local extension = { ex = function() vim.fn["dist#ft#ExCheck"]() end, exu = function() vim.fn["dist#ft#EuphoriaCheck"]() end, exw = function() vim.fn["dist#ft#EuphoriaCheck"]() end, - frm = function() vim.fn["dist#ft#FTbas"]("form") end, + frm = function() vim.fn["dist#ft#FTfrm"]() end, fs = function() vim.fn["dist#ft#FTfs"]() end, h = function() vim.fn["dist#ft#FTheader"]() end, htm = function() vim.fn["dist#ft#FThtml"]() end, -- cgit From 7d72076a6f3bd3cb85100c94bfeb7a70de345c3b Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 30 Jan 2022 14:53:56 +0800 Subject: vim-patch:8.2.3219: :find searches non-existing directories Problem: :find searches non-existing directories. Solution: Check the path is not "..". Update help. (Christian Brabandt, closes vim/vim#8612, closes vim/vim#8533) https://github.com/vim/vim/commit/7a4ca32175bef0f9a177052796bd9addd10dc218 Change STRNCAT to STRLCAT as clint doesn't like the former. Include a typo fix from https://github.com/vim/vim/commit/2f0936cb9a2eb026acac03e6a8fd0b2a5d97508b#diff-7e9292cae1f2ba70dd5b17d2d162693a91044ada6ac99e9c3e8917f32878c097 --- runtime/doc/editing.txt | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'runtime') diff --git a/runtime/doc/editing.txt b/runtime/doc/editing.txt index 44987f3b7b..3d0287b0cd 100644 --- a/runtime/doc/editing.txt +++ b/runtime/doc/editing.txt @@ -1569,6 +1569,12 @@ There are three different types of searching: /u/user_x/work/include /u/user_x/include +< Note: If your 'path' setting includes a non-existing directory, Vim will + skip the non-existing directory, but continues searching in the parent of + the non-existing directory if upwards searching is used. E.g. when + searching "../include" and that doesn't exist, and upward searching is + used, also searches in "..". + 3) Combined up/downward search: If Vim's current path is /u/user_x/work/release and you do > set path=**;/u/user_x -- cgit From a87ecf5d086c9a93be4c5f331a684301b2c1bc12 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 3 Feb 2022 17:19:51 +0800 Subject: fix(health): do not run external processes in a shell --- runtime/autoload/health/nvim.vim | 12 ++++++------ runtime/autoload/health/provider.vim | 18 +++++++++--------- 2 files changed, 15 insertions(+), 15 deletions(-) (limited to 'runtime') diff --git a/runtime/autoload/health/nvim.vim b/runtime/autoload/health/nvim.vim index ef680097d5..961f83d926 100644 --- a/runtime/autoload/health/nvim.vim +++ b/runtime/autoload/health/nvim.vim @@ -148,14 +148,14 @@ endfunction function! s:get_tmux_option(option) abort let cmd = 'tmux show-option -qvg '.a:option " try global scope - let out = system(cmd) + let out = system(split(cmd)) let val = substitute(out, '\v(\s|\r|\n)', '', 'g') if v:shell_error call health#report_error('command failed: '.cmd."\n".out) return 'error' elseif empty(val) let cmd = 'tmux show-option -qvgs '.a:option " try session scope - let out = system(cmd) + let out = system(split(cmd)) let val = substitute(out, '\v(\s|\r|\n)', '', 'g') if v:shell_error call health#report_error('command failed: '.cmd."\n".out) @@ -202,11 +202,11 @@ function! s:check_tmux() abort " check default-terminal and $TERM call health#report_info('$TERM: '.$TERM) let cmd = 'tmux show-option -qvg default-terminal' - let out = system(cmd) + let out = system(split(cmd)) let tmux_default_term = substitute(out, '\v(\s|\r|\n)', '', 'g') if empty(tmux_default_term) let cmd = 'tmux show-option -qvgs default-terminal' - let out = system(cmd) + let out = system(split(cmd)) let tmux_default_term = substitute(out, '\v(\s|\r|\n)', '', 'g') endif @@ -225,7 +225,7 @@ function! s:check_tmux() abort endif " check for RGB capabilities - let info = system('tmux server-info') + let info = system(['tmux', 'server-info']) let has_tc = stridx(info, " Tc: (flag) true") != -1 let has_rgb = stridx(info, " RGB: (flag) true") != -1 if !has_tc && !has_rgb @@ -242,7 +242,7 @@ function! s:check_terminal() abort endif call health#report_start('terminal') let cmd = 'infocmp -L' - let out = system(cmd) + let out = system(split(cmd)) let kbs_entry = matchstr(out, 'key_backspace=[^,[:space:]]*') let kdch1_entry = matchstr(out, 'key_dc=[^,[:space:]]*') diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index 8f0dbbab39..2f35179338 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -565,7 +565,7 @@ function! s:check_ruby() abort \ ['Install Ruby and verify that `ruby` and `gem` commands work.']) return endif - call health#report_info('Ruby: '. s:system('ruby -v')) + call health#report_info('Ruby: '. s:system(['ruby', '-v'])) let [host, err] = provider#ruby#Detect() if empty(host) @@ -588,11 +588,11 @@ function! s:check_ruby() abort endif let latest_gem = get(split(latest_gem, 'neovim (\|, \|)$' ), 0, 'not found') - let current_gem_cmd = host .' --version' + let current_gem_cmd = [host, '--version'] let current_gem = s:system(current_gem_cmd) if s:shell_error - call health#report_error('Failed to run: '. current_gem_cmd, - \ ['Report this issue with the output of: ', current_gem_cmd]) + call health#report_error('Failed to run: '. join(current_gem_cmd), + \ ['Report this issue with the output of: ', join(current_gem_cmd)]) return endif @@ -619,7 +619,7 @@ function! s:check_node() abort \ ['Install Node.js and verify that `node` and `npm` (or `yarn`) commands work.']) return endif - let node_v = get(split(s:system('node -v'), "\n"), 0, '') + let node_v = get(split(s:system(['node', '-v']), "\n"), 0, '') call health#report_info('Node.js: '. node_v) if s:shell_error || s:version_cmp(node_v[1:], '6.0.0') < 0 call health#report_warn('Nvim node.js host does not support '.node_v) @@ -660,8 +660,8 @@ function! s:check_node() abort let current_npm_cmd = ['node', host, '--version'] let current_npm = s:system(current_npm_cmd) if s:shell_error - call health#report_error('Failed to run: '. string(current_npm_cmd), - \ ['Report this issue with the output of: ', string(current_npm_cmd)]) + call health#report_error('Failed to run: '. join(current_npm_cmd), + \ ['Report this issue with the output of: ', join(current_npm_cmd)]) return endif @@ -734,8 +734,8 @@ function! s:check_perl() abort let current_cpan_cmd = [perl_exec, '-W', '-MNeovim::Ext', '-e', 'print $Neovim::Ext::VERSION'] let current_cpan = s:system(current_cpan_cmd) if s:shell_error - call health#report_error('Failed to run: '. string(current_cpan_cmd), - \ ['Report this issue with the output of: ', string(current_cpan_cmd)]) + call health#report_error('Failed to run: '. join(current_cpan_cmd), + \ ['Report this issue with the output of: ', join(current_cpan_cmd)]) return endif -- cgit From f25ab39faaf9e5e161d3c285a4af645383c5498b Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 4 Feb 2022 09:23:54 +0800 Subject: vim-patch:8.1.0846: not easy to recognize the system Vim runs on Problem: Not easy to recognize the system Vim runs on. Solution: Add more items to the features list. (Ozaki Kiichi, closes vim/vim#3855) https://github.com/vim/vim/commit/39536dd557e847e80572044c2be319db5886abe3 Some doc changes have already been applied. Some others are N/A. "moon" was removed in patch 8.2.0427 so I did not add it. --- runtime/doc/builtin.txt | 12 +++++++++--- runtime/doc/eval.txt | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index bb04376f57..b0ce848de2 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -4347,6 +4347,9 @@ line({expr} [, {winid}]) *line()* line("'t") line number of mark t line("'" . marker) line number of mark marker < + To jump to the last known position when opening a file see + |last-position-jump|. + Can also be used as a |method|: > GetValue()->line() @@ -4912,8 +4915,10 @@ min({expr}) Return the minimum value of all items in {expr}. < *mkdir()* *E739* mkdir({name} [, {path} [, {prot}]]) Create directory {name}. + If {path} is "p" then intermediate directories are created as necessary. Otherwise it must be "". + If {prot} is given it is used to set the protection bits of the new directory. The default is 0o755 (rwxr-xr-x: r/w for the user, readable for others). Use 0o700 to make it @@ -4922,6 +4927,7 @@ mkdir({name} [, {path} [, {prot}]]) {prot} is applied for all parts of {name}. Thus if you create /tmp/foo/bar then /tmp/foo will be created with 0o700. Example: > :call mkdir($HOME . "/tmp/foo/bar", "p", 0o700) + < This function is not available in the |sandbox|. If you try to create an existing directory with {path} set to @@ -5758,8 +5764,10 @@ remove({list}, {idx} [, {end}]) *remove()* Example: > :echo "last item: " . remove(mylist, -1) :call remove(mylist, 0, 9) +< + Use |delete()| to remove a file. -< Can also be used as a |method|: > + Can also be used as a |method|: > mylist->remove(idx) remove({blob}, {idx} [, {end}]) @@ -5779,8 +5787,6 @@ remove({dict}, {key}) :echo "removed " . remove(dict, "one") < If there is no {key} in {dict} this is an error. - Use |delete()| to remove a file. - rename({from}, {to}) *rename()* Rename the file by the name {from} to the name {to}. This should also work to move files across file systems. The diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index f2b014dde6..d6486073cf 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -676,7 +676,7 @@ similar to -1. > :let otherblob = myblob[:] " make a copy of the Blob If the first index is beyond the last byte of the Blob or the second byte is -before the first byte, the result is an empty Blob. There is no error +before the first index, the result is an empty Blob. There is no error message. If the second index is equal to or greater than the length of the Blob the -- cgit From 4c4a80950e98be2529c4ed51f5563ebe3ece8064 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 4 Feb 2022 09:23:54 +0800 Subject: docs: update feature-list Add "linux", "sun". Remove "+shellslash" as it should be passed to exists(). Sort alphabetically and consistently use Tabs for indent. --- runtime/doc/builtin.txt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index b0ce848de2..4153c1c9d8 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -3543,24 +3543,25 @@ has({feature}) Returns 1 if {feature} is supported, 0 otherwise. The :if has("win32") < *feature-list* List of supported pseudo-feature names: - acl |ACL| support + acl |ACL| support. bsd BSD system (not macOS, use "mac" for that). - iconv Can use |iconv()| for conversion. - +shellslash Can use backslashes in filenames (Windows) clipboard |clipboard| provider is available. fname_case Case in file names matters (for Darwin and MS-Windows this is not present). + iconv Can use |iconv()| for conversion. + linux Linux system. mac MacOS system. nvim This is Nvim. python3 Legacy Vim |python3| interface. |has-python| pythonx Legacy Vim |python_x| interface. |has-pythonx| - ttyin input is a terminal (tty) - ttyout output is a terminal (tty) + sun SunOS system. + ttyin input is a terminal (tty). + ttyout output is a terminal (tty). unix Unix system. *vim_starting* True during |startup|. win32 Windows system (32 or 64 bit). win64 Windows system (64 bit). - wsl WSL (Windows Subsystem for Linux) system + wsl WSL (Windows Subsystem for Linux) system. *has-patch* 3. Vim patch. For example the "patch123" feature means that -- cgit From 6775a7d98f580b2024fde962dbda984eb5d583fe Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 4 Feb 2022 09:23:54 +0800 Subject: vim-patch:8.2.3797: no good reason to limit the message history in tiny version Problem: No good reason to limit the message history in the tiny version. Solution: Always use 200. https://github.com/vim/vim/commit/1e78deb0779bc403a914712f0842a65d2949dfdf --- runtime/doc/message.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/message.txt b/runtime/doc/message.txt index 950028d9cc..fa1bc6f7da 100644 --- a/runtime/doc/message.txt +++ b/runtime/doc/message.txt @@ -27,8 +27,7 @@ depends on the 'shortmess' option. Clear messages, keeping only the {count} most recent ones. -The number of remembered messages is fixed at 20 for the tiny version and 200 -for other versions. +The number of remembered messages is fixed at 200. *g<* The "g<" command can be used to see the last page of previous command output. -- cgit From 9b0363d365f92b1a31bcf0fc32969a4667c11e95 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 4 Feb 2022 22:17:25 +0800 Subject: vim-patch:8.2.1128: the write message mentions characters, but it's bytes Problem: The write message mentions characters, but it's actually bytes. Solution: Change "C" to "B" and "characters" to "bytes". https://github.com/vim/vim/commit/3f40ce78f5c178d15871bd784ed878c78f0b8a44 --- runtime/doc/options.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 2984a68ea2..6e2bc228d0 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -5462,7 +5462,7 @@ A jump table for the options with a short description can be found at |Q_op|. flag meaning when present ~ f use "(3 of 5)" instead of "(file 3 of 5)" i use "[noeol]" instead of "[Incomplete last line]" - l use "999L, 888C" instead of "999 lines, 888 characters" + l use "999L, 888B" instead of "999 lines, 888 bytes" m use "[+]" instead of "[Modified]" n use "[New]" instead of "[New File]" r use "[RO]" instead of "[readonly]" -- cgit From 22f0725aac300ed9b249f995df7889f6c203d1e0 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Sun, 9 Jan 2022 22:48:29 +0000 Subject: vim-patch:8.1.2342: random number generator in Vim script is slow Problem: Random number generator in Vim script is slow. Solution: Add rand() and srand(). (Yasuhiro Matsumoto, closes vim/vim#1277) https://github.com/vim/vim/commit/06b0b4bc27077013e9b4b48fd1d9b33e543ccf99 Add missing method call usage to builtin.txt. vim_time and test_settime is N/A. Add a modeline to test_random.vim. Use typval_T* over listitem_T* vars so we don't need to use TV_LIST_ITEM_TV all over the place... Remove NULL list checks (tv_list_len covers this). --- runtime/doc/builtin.txt | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'runtime') diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 4153c1c9d8..35beb97518 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -325,6 +325,7 @@ pumvisible() Number whether popup menu is visible pyeval({expr}) any evaluate |Python| expression py3eval({expr}) any evaluate |python3| expression pyxeval({expr}) any evaluate |python_x| expression +rand([{expr}]) Number get pseudo-random number range({expr} [, {max} [, {stride}]]) List items from {expr} to {max} readdir({dir} [, {expr}]) List file names in {dir} selected by {expr} @@ -441,6 +442,7 @@ spellsuggest({word} [, {max} [, {capital}]]) split({expr} [, {pat} [, {keepempty}]]) List make |List| from {pat} separated {expr} sqrt({expr}) Float square root of {expr} +srand([{expr}]) List get seed for |rand()| stdioopen({dict}) Number open stdio in a headless instance. stdpath({what}) String/List returns the standard path(s) for {what} str2float({expr} [, {quoted}]) Float convert String to Float @@ -5529,6 +5531,22 @@ range({expr} [, {max} [, {stride}]]) *range()* < Can also be used as a |method|: > GetExpr()->range() +< +rand([{expr}]) *rand()* + Return a pseudo-random Number generated with an xorshift + algorithm using seed {expr}. {expr} can be initialized by + |srand()| and will be updated by rand(). + If {expr} is omitted, an internal seed value is used and + updated. + + Examples: > + :echo rand() + :let seed = srand() + :echo rand(seed) + :echo rand(seed) +< + Can also be used as a |method|: > + seed->rand() < *readdir()* readdir({directory} [, {expr}]) @@ -7178,6 +7196,22 @@ sqrt({expr}) *sqrt()* Can also be used as a |method|: > Compute()->sqrt() +srand([{expr}]) *srand()* + Initialize seed used by |rand()|: + - If {expr} is not given, seed values are initialized by + time(NULL) a.k.a. epoch time. + - If {expr} is given, return seed values which x element is + {expr}. This is useful for testing or when a predictable + sequence is expected. + + Examples: > + :let seed = srand() + :let seed = srand(userinput) + :echo rand(seed) +< + Can also be used as a |method|: > + userinput->srand() + stdioopen({opts}) *stdioopen()* With |--headless| this opens stdin and stdout as a |channel|. May be called only once. See |channel-stdio|. stderr is not -- cgit From 061b06a8ae2e49e7921080ea4a1cc157e704bb28 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Sun, 9 Jan 2022 23:31:48 +0000 Subject: docs(rand): cherry-pick changes from rt update 0c0734d https://github.com/vim/vim/commit/0c0734d527a132edfb4089be48486586424b3f41 --- runtime/doc/builtin.txt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 35beb97518..8d88c533f0 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -5534,16 +5534,17 @@ range({expr} [, {max} [, {stride}]]) *range()* < rand([{expr}]) *rand()* Return a pseudo-random Number generated with an xorshift - algorithm using seed {expr}. {expr} can be initialized by - |srand()| and will be updated by rand(). - If {expr} is omitted, an internal seed value is used and - updated. + algorithm using seed {expr}. The returned number is 32 bits, + also on 64 bits systems, for consistency. + {expr} can be initialized by |srand()| and will be updated by + rand(). If {expr} is omitted, an internal seed value is used + and updated. Examples: > :echo rand() :let seed = srand() :echo rand(seed) - :echo rand(seed) + :echo rand(seed) % 16 " random number 0 - 15 < Can also be used as a |method|: > seed->rand() @@ -7199,7 +7200,8 @@ sqrt({expr}) *sqrt()* srand([{expr}]) *srand()* Initialize seed used by |rand()|: - If {expr} is not given, seed values are initialized by - time(NULL) a.k.a. epoch time. + time(NULL) a.k.a. epoch time. This only has second + accuracy. - If {expr} is given, return seed values which x element is {expr}. This is useful for testing or when a predictable sequence is expected. -- cgit From c97614d98fc7ab040851b7fe1bc4cb575ce8c627 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Sun, 9 Jan 2022 23:26:03 +0000 Subject: vim-patch:8.1.2356: rand() does not use the best algorithm Problem: rand() does not use the best algorithm. Solution: use xoshiro128** instead of xorshift. (Kaito Udagawa, closes vim/vim#5279) https://github.com/vim/vim/commit/f8c1f9200c4b50969a8191a4fe0b0d09edb38979 --- runtime/doc/builtin.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 8d88c533f0..327b8dc4d9 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -5533,7 +5533,7 @@ range({expr} [, {max} [, {stride}]]) *range()* GetExpr()->range() < rand([{expr}]) *rand()* - Return a pseudo-random Number generated with an xorshift + Return a pseudo-random Number generated with an xoshiro128** algorithm using seed {expr}. The returned number is 32 bits, also on 64 bits systems, for consistency. {expr} can be initialized by |srand()| and will be updated by @@ -7200,11 +7200,11 @@ sqrt({expr}) *sqrt()* srand([{expr}]) *srand()* Initialize seed used by |rand()|: - If {expr} is not given, seed values are initialized by - time(NULL) a.k.a. epoch time. This only has second - accuracy. - - If {expr} is given, return seed values which x element is - {expr}. This is useful for testing or when a predictable - sequence is expected. + reading from /dev/urandom, if possible, or using time(NULL) + a.k.a. epoch time otherwise; this only has second accuracy. + - If {expr} is given it must be a Number. It is used to + initialize the seed values. This is useful for testing or + when a predictable sequence is intended. Examples: > :let seed = srand() -- cgit From 4f7a8991a93ddb1b6ab7cd8a8f21b5197c4612bb Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Mon, 10 Jan 2022 10:31:16 +0000 Subject: vim-patch:8.2.0233: crash when using garbagecollect() in between rand() Problem: Crash when using garbagecollect() in between rand(). Solution: Redesign the rand() and srand() implementation. (Yasuhiro Matsumoto, closes vim/vim#5587, closes vim/vim#5588) https://github.com/vim/vim/commit/4f645c54efe33d7a11e314676e503118761f08a7 Omit test_srand_seed. Unmacroify SHUFFLE_XOSHIRO128STARSTAR and SPLITMIX32 while we're at it (leave ROTL alone as it's fairly innocent). --- runtime/doc/vim_diff.txt | 1 + 1 file changed, 1 insertion(+) (limited to 'runtime') diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index 7e61eac404..11849632c5 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -574,6 +574,7 @@ Test functions: test_scrollbar() test_setmouse() test_settime() + test_srand_seed() TUI: *t_xx* *termcap-options* *t_AB* *t_Sb* *t_vb* *t_SI* -- cgit From 7002a3433bed7600ec02d64927ae0e77d077f34e Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Sat, 1 Jan 2022 07:27:46 +0000 Subject: vim-patch:8.2.2658: :for cannot loop over a string Problem: :for cannot loop over a string. Solution: Accept a string argument and iterate over its characters. https://github.com/vim/vim/commit/74e54fcb447e5db32f9c2df34c0554bbecdccca2 v8.2.2659 is already ported. N/A patches for version.c: vim-patch:8.2.2736: Vim9: for loop over string is a bit slow Problem: Vim9: for loop over string is a bit slow. Solution: Avoid using strlen(). https://github.com/vim/vim/commit/175a41c13f3e27e30c662f2f418c5a347dbc645d --- runtime/doc/eval.txt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index d6486073cf..aa6d994857 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -372,8 +372,8 @@ Changing the order of items in a list: > For loop ~ -The |:for| loop executes commands for each item in a |List| or |Blob|. -A variable is set to each item in the sequence. Example with a List: > +The |:for| loop executes commands for each item in a |List|, |String| or |Blob|. +A variable is set to each item in sequence. Example with a List: > :for item in mylist : call Doit(item) :endfor @@ -390,7 +390,7 @@ If all you want to do is modify each item in the list then the |map()| function will be a simpler method than a for loop. Just like the |:let| command, |:for| also accepts a list of variables. This -requires the argument to be a list of lists. > +requires the argument to be a List of Lists. > :for [lnum, col] in [[1, 3], [2, 8], [3, 0]] : call Doit(lnum, col) :endfor @@ -408,6 +408,12 @@ It is also possible to put remaining items in a List variable: > For a Blob one byte at a time is used. +For a String one character, including any composing characters, is used as a +String. Example: > + for c in text + echo 'This character is ' .. c + endfor + List functions ~ *E714* -- cgit From 8ba9f19961d8573dc851d3d5f2ec217ad2fb7b28 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 6 Feb 2022 04:46:16 +0800 Subject: vim-patch:8.2.1727: a popup created with "cursorline" will ignore "firstline" Problem: A popup created with "cursorline" will ignore "firstline". Solution: When both "cursorline" and "firstline" are present put the cursor on "firstline". (closes vim/vim#7000) Add the "winid" argument to getcurpos(). https://github.com/vim/vim/commit/99ca9c4868bb1669706b9e3de9a9218bd11cc459 Skip popup window related code. Cherry-pick all of Test_getcurpos_setpos() from patch 8.2.0610. --- runtime/doc/builtin.txt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 327b8dc4d9..4f6104c602 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -178,7 +178,7 @@ getcmdtype() String return current command-line type getcmdwintype() String return current command-line window type getcompletion({pat}, {type} [, {filtered}]) List list of cmdline completion matches -getcurpos() List position of the cursor +getcurpos([{winnr}]) List position of the cursor getcwd([{winnr} [, {tabnr}]]) String get the current working directory getenv({name}) String return environment variable getfontname([{name}]) String name of font being used @@ -2786,13 +2786,20 @@ getcompletion({pat}, {type} [, {filtered}]) *getcompletion()* GetPattern()->getcompletion('color') < *getcurpos()* -getcurpos() Get the position of the cursor. This is like getpos('.'), but +getcurpos([{winid}]) + Get the position of the cursor. This is like getpos('.'), but includes an extra "curswant" in the list: [0, lnum, col, off, curswant] ~ The "curswant" number is the preferred column when moving the cursor vertically. Also see |getpos()|. The first "bufnum" item is always zero. + The optional {winid} argument can specify the window. It can + be the window number or the |window-ID|. The last known + cursor position is returned, this may be invalid for the + current value of the buffer if it is not the current window. + If {winid} is invalid a list with zeroes is returned. + This can be used to save and restore the cursor position: > let save_cursor = getcurpos() MoveTheCursorAround -- cgit From 6ab71683d14a408e79f7cbda3a07ab65f76c6b35 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 6 Feb 2022 04:46:16 +0800 Subject: vim-patch:8.2.2324: not easy to get mark en cursor posotion by character count Problem: Not easy to get mark en cursor posotion by character count. Solution: Add functions that use character index. (Yegappan Lakshmanan, closes vim/vim#7648) https://github.com/vim/vim/commit/6f02b00bb0958f70bc15534e115b4c6dadff0e06 --- runtime/doc/builtin.txt | 117 ++++++++++++++++++++++++++++++++++++++++++------ runtime/doc/eval.txt | 6 +-- runtime/doc/usr_41.txt | 5 +++ 3 files changed, 111 insertions(+), 17 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 4f6104c602..7738324b49 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -75,12 +75,13 @@ changenr() Number current change number chanclose({id}[, {stream}]) Number Closes a channel or one of its streams chansend({id}, {data}) Number Writes {data} to channel char2nr({expr}[, {utf8}]) Number ASCII/UTF-8 value of first char in {expr} +charcol({expr}) Number column number of cursor or mark charidx({string}, {idx} [, {countcc}]) Number char index of byte {idx} in {string} chdir({dir}) String change current working directory cindent({lnum}) Number C indent for line {lnum} clearmatches([{win}]) none clear all matches -col({expr}) Number column nr of cursor or mark +col({expr}) Number column byte index of cursor or mark complete({startcol}, {matches}) none set Insert mode completion complete_add({expr}) Number add completion match complete_check() Number check for key typed during completion @@ -170,6 +171,7 @@ getchangelist([{buf}]) List list of change list items getchar([expr]) Number or String get one character from the user getcharmod() Number modifiers for the last typed character +getcharpos({expr}) List position of cursor, mark, etc. getcharsearch() Dict last character search getcharstr([expr]) String get one character from the user getcmdline() String return the current command-line @@ -179,6 +181,7 @@ getcmdwintype() String return current command-line window type getcompletion({pat}, {type} [, {filtered}]) List list of cmdline completion matches getcurpos([{winnr}]) List position of the cursor +getcursorcharpos([{winnr}]) List character position of the cursor getcwd([{winnr} [, {tabnr}]]) String get the current working directory getenv({name}) String return environment variable getfontname([{name}]) String name of font being used @@ -387,8 +390,10 @@ setbufline( {expr}, {lnum}, {line}) Number set line {lnum} to {line} in buffer {expr} setbufvar({buf}, {varname}, {val}) set {varname} in buffer {buf} to {val} +setcharpos({expr}, {list}) Number set the {expr} position to {list} setcharsearch({dict}) Dict set character search from {dict} setcmdpos({pos}) Number set cursor position in command-line +setcursorcharpos({list}) Number move cursor to position in {list} setenv({name}, {val}) none set environment variable setfperm({fname}, {mode} Number set {fname} file permissions to {mode} setline({lnum}, {line}) Number set line {lnum} to {line} @@ -949,8 +954,8 @@ byteidxcomp({expr}, {nr}) *byteidxcomp()* < The first and third echo result in 3 ('e' plus composing character is 3 bytes), the second echo results in 1 ('e' is one byte). - Only works differently from byteidx() when 'encoding' is set to - a Unicode encoding. + Only works differently from byteidx() when 'encoding' is set + to a Unicode encoding. Can also be used as a |method|: > GetName()->byteidxcomp(idx) @@ -1034,6 +1039,18 @@ char2nr({string} [, {utf8}]) *char2nr()* Can also be used as a |method|: > GetChar()->char2nr() +< + *charcol()* +charcol({expr}) Same as |col()| but returns the character index of the column + position given with {expr} instead of the byte position. + + Example: + With the cursor on '세' in line 5 with text "여보세요": > + charcol('.') returns 3 + col('.') returns 7 + +< Can also be used as a |method|: > + GetPos()->col() < *charidx()* charidx({string}, {idx} [, {countcc}]) @@ -1120,7 +1137,8 @@ col({expr}) The result is a Number, which is the byte index of the column out of range then col() returns zero. To get the line number use |line()|. To get both use |getpos()|. - For the screen column position use |virtcol()|. + For the screen column position use |virtcol()|. For the + character position use |charcol()|. Note that only marks in the current file can be used. Examples: > col(".") column of cursor @@ -1443,6 +1461,9 @@ cursor({list}) This is like the return value of |getpos()| or |getcurpos()|, but without the first item. + To position the cursor using the character count, use + |setcursorcharpos()|. + Does not change the jumplist. If {lnum} is greater than the number of lines in the buffer, the cursor will be positioned at the last line in the buffer. @@ -2652,6 +2673,20 @@ getcharmod() *getcharmod()* character itself are obtained. Thus Shift-a results in "A" without a modifier. + *getcharpos()* +getcharpos({expr}) + Get the position for {expr}. Same as |getpos()| but the column + number in the returned List is a character index instead of + a byte index. + + Example: + With the cursor on '세' in line 5 with text "여보세요": > + getcharpos('.') returns [0, 5, 3, 0] + getpos('.') returns [0, 5, 7, 0] +< + Can also be used as a |method|: > + GetMark()->getcharpos() + getcharsearch() *getcharsearch()* Return the current character search information as a {dict} with the following entries: @@ -2791,8 +2826,11 @@ getcurpos([{winid}]) includes an extra "curswant" in the list: [0, lnum, col, off, curswant] ~ The "curswant" number is the preferred column when moving the - cursor vertically. Also see |getpos()|. - The first "bufnum" item is always zero. + cursor vertically. Also see |getcursorcharpos()| and + |getpos()|. + The first "bufnum" item is always zero. The byte position of + the cursor is returned in 'col'. To get the character + position, use |getcursorcharpos()|. The optional {winid} argument can specify the window. It can be the window number or the |window-ID|. The last known @@ -2807,6 +2845,22 @@ getcurpos([{winid}]) < Note that this only works within the window. See |winrestview()| for restoring more state. + Can also be used as a |method|: > + GetWinid()->getcurpos() + +< *getcursorcharpos()* +getcursorcharpos([{winid}]) + Same as |getcurpos()| but the column number in the returned + List is a character index instead of a byte index. + + Example: + With the cursor on '보' in line 3 with text "여보세요": > + getcursorcharpos() returns [0, 3, 2, 0, 3] + getcurpos() returns [0, 3, 4, 0, 3] + +< Can also be used as a |method|: > + GetWinid()->getcursorcharpos() + getcwd([{winnr}[, {tabnr}]]) *getcwd()* With no arguments, returns the name of the effective |current-directory|. With {winnr} or {tabnr} the working @@ -3086,14 +3140,15 @@ getpos({expr}) Get the position for String {expr}. For possible values of (visual line mode) the column of '< is zero and the column of '> is a large number. The column number in the returned List is the byte position - within the line. + within the line. To get the character position in the line, + use |getcharpos()| The column number can be very large, e.g. 2147483647, in which case it means "after the end of the line". This can be used to save and restore the position of a mark: > let save_a_mark = getpos("'a") ... call setpos("'a", save_a_mark) -< Also see |getcurpos()| and |setpos()|. +< Also see |getcharpos()|, |getcurpos()| and |setpos()|. Can also be used as a |method|: > GetMark()->getpos() @@ -4855,8 +4910,10 @@ matchstrpos({expr}, {pat} [, {start} [, {count}]]) *matchstrpos()* GetText()->matchstrpos('word') < *max()* -max({expr}) Return the maximum value of all items in {expr}. - {expr} can be a |List| or a |Dictionary|. For a Dictionary, +max({expr}) Return the maximum value of all items in {expr}. Example: > + echo max([apples, pears, oranges]) + +< {expr} can be a |List| or a |Dictionary|. For a Dictionary, it returns the maximum of all values in the Dictionary. If {expr} is neither a List nor a Dictionary, or one of the items in {expr} cannot be used as a Number this results in @@ -4912,8 +4969,10 @@ menu_get({path} [, {modes}]) *menu_get()* < *min()* -min({expr}) Return the minimum value of all items in {expr}. - {expr} can be a |List| or a |Dictionary|. For a Dictionary, +min({expr}) Return the minimum value of all items in {expr}. Example: > + echo min([apples, pears, oranges]) + +< {expr} can be a |List| or a |Dictionary|. For a Dictionary, it returns the minimum of all values in the Dictionary. If {expr} is neither a List nor a Dictionary, or one of the items in {expr} cannot be used as a Number this results in @@ -6454,6 +6513,20 @@ setbufvar({buf}, {varname}, {val}) *setbufvar()* third argument: > GetValue()->setbufvar(buf, varname) +setcharpos({expr}, {list}) *setcharpos()* + Same as |setpos()| but uses the specified column number as the + character index instead of the byte index in the line. + + Example: + With the text "여보세요" in line 8: > + call setcharpos('.', [0, 8, 4, 0]) +< positions the cursor on the fourth character '요'. > + call setpos('.', [0, 8, 4, 0]) +< positions the cursor on the second character '보'. + + Can also be used as a |method|: > + GetPosition()->setcharpos('.') + setcharsearch({dict}) *setcharsearch()* Set the current character search information to {dict}, which contains one or more of the following entries: @@ -6495,6 +6568,21 @@ setcmdpos({pos}) *setcmdpos()* Can also be used as a |method|: > GetPos()->setcmdpos() +setcursorcharpos({lnum}, {col} [, {off}]) *setcursorcharpos()* +setcursorcharpos({list}) + Same as |cursor()| but uses the specified column number as the + character index instead of the byte index in the line. + + Example: + With the text "여보세요" in line 4: > + call setcursorcharpos(4, 3) +< positions the cursor on the third character '세'. > + call cursor(4, 3) +< positions the cursor on the first character '여'. + + Can also be used as a |method|: > + GetCursorPos()->setcursorcharpos() + setenv({name}, {val}) *setenv()* Set environment variable {name} to {val}. Example: > call setenv('HOME', '/home/myhome') @@ -6607,7 +6695,8 @@ setpos({expr}, {list}) "lnum" and "col" are the position in the buffer. The first column is 1. Use a zero "lnum" to delete a mark. If "col" is - smaller than 1 then 1 is used. + smaller than 1 then 1 is used. To use the character count + instead of the byte count, use |setcharpos()|. The "off" number is only used when 'virtualedit' is set. Then it is the offset in screen columns from the start of the @@ -6627,7 +6716,7 @@ setpos({expr}, {list}) Returns 0 when the position could be set, -1 otherwise. An error message is given if {expr} is invalid. - Also see |getpos()| and |getcurpos()|. + Also see |setcharpos()|, |getpos()| and |getcurpos()|. This does not restore the preferred column for moving vertically; if you set the cursor position with this, |j| and diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index d6486073cf..2b79b0280f 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1066,7 +1066,7 @@ expr7 *expr7* For '!' |TRUE| becomes |FALSE|, |FALSE| becomes |TRUE| (one). For '-' the sign of the number is changed. -For '+' the number is unchanged. +For '+' the number is unchanged. Note: "++" has no effect. A String will be converted to a Number first. @@ -1228,8 +1228,8 @@ And NOT: > number ------ number number constant *expr-number* - *hex-number* *octal-number* *binary-number* + *0x* *hex-number* *0o* *octal-number* *binary-number* Decimal, Hexadecimal (starting with 0x or 0X), Binary (starting with 0b or 0B) and Octal (starting with 0, 0o or 0O). @@ -1486,7 +1486,7 @@ Notice how execute() is used to execute an Ex command. That's ugly though. Lambda expressions have internal names like '42'. If you get an error for a lambda expression, you can find what it is with the following command: > - :function {'42'} + :function 42 See also: |numbered-function| ============================================================================== diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt index 5dde170a12..bf29c94d51 100644 --- a/runtime/doc/usr_41.txt +++ b/runtime/doc/usr_41.txt @@ -746,6 +746,11 @@ Cursor and mark position: *cursor-functions* *mark-functions* screenchar() get character code at a screen line/row screenchars() get character codes at a screen line/row screenstring() get string of characters at a screen line/row + charcol() character number of the cursor or a mark + getcharpos() get character position of cursor, mark, etc. + setcharpos() set character position of cursor, mark, etc. + getcursorcharpos() get character position of the cursor + setcursorcharpos() set character position of the cursor Working with text in the current buffer: *text-functions* getline() get a line or list of lines from the buffer -- cgit From 46d1b8ed1fd8ae4d39007c698e3981e87f2fb956 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 6 Feb 2022 04:46:16 +0800 Subject: vim-patch:partial:2346a6378483 Update runtime files https://github.com/vim/vim/commit/2346a6378483c9871016f9fc821ec5cbea638f13 --- runtime/doc/builtin.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 7738324b49..cc1067e14a 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -2847,8 +2847,8 @@ getcurpos([{winid}]) Can also be used as a |method|: > GetWinid()->getcurpos() - -< *getcursorcharpos()* +< + *getcursorcharpos()* getcursorcharpos([{winid}]) Same as |getcurpos()| but the column number in the returned List is a character index instead of a byte index. @@ -2857,8 +2857,8 @@ getcursorcharpos([{winid}]) With the cursor on '보' in line 3 with text "여보세요": > getcursorcharpos() returns [0, 3, 2, 0, 3] getcurpos() returns [0, 3, 4, 0, 3] - -< Can also be used as a |method|: > +< + Can also be used as a |method|: > GetWinid()->getcursorcharpos() getcwd([{winnr}[, {tabnr}]]) *getcwd()* @@ -3141,7 +3141,7 @@ getpos({expr}) Get the position for String {expr}. For possible values of '> is a large number. The column number in the returned List is the byte position within the line. To get the character position in the line, - use |getcharpos()| + use |getcharpos()|. The column number can be very large, e.g. 2147483647, in which case it means "after the end of the line". This can be used to save and restore the position of a mark: > -- cgit From be9dbc925ce66a8880ac9ccc68e3ac902b322de0 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 6 Feb 2022 04:46:16 +0800 Subject: vim-patch:partial:6aa57295cfbe Update runtime files https://github.com/vim/vim/commit/6aa57295cfbe8f21c15f0671e45fd53cf990d404 --- runtime/doc/builtin.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index cc1067e14a..c68e86462d 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -2675,9 +2675,9 @@ getcharmod() *getcharmod()* *getcharpos()* getcharpos({expr}) - Get the position for {expr}. Same as |getpos()| but the column - number in the returned List is a character index instead of - a byte index. + Get the position for String {expr}. Same as |getpos()| but the + column number in the returned List is a character index + instead of a byte index. Example: With the cursor on '세' in line 5 with text "여보세요": > -- cgit From d65ee129143fedd43178c9be52095b5d2d06b5c2 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 6 Feb 2022 16:29:12 +0800 Subject: vim-patch:8.2.1741: pathshorten() only supports using one character Problem: pathshorten() only supports using one character. Solution: Add an argument to control the length. (closes vim/vim#7006) https://github.com/vim/vim/commit/6a33ef0deb5c75c003a9f3bd1c57f3ca5e77327e Cherry-pick a line in test from patch 8.2.0634. Use Nvim's config paths in docs. shorten_dir() returning a pointer looks a bit confusing here, as it is actually the same pointer passed to it, and it doesn't really reduce much code, so change it back to void. Assigning rettv->vval.v_string = NULL is not needed if a pointer is within 64 bits. While this is usually the case, I'm not sure if it can be taken for granted. --- runtime/doc/builtin.txt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index c68e86462d..56bc8bfb3e 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -314,7 +314,7 @@ nextnonblank({lnum}) Number line nr of non-blank line >= {lnum} nr2char({expr}[, {utf8}]) String single char with ASCII/UTF-8 value {expr} nvim_...({args}...) any call nvim |api| functions or({expr}, {expr}) Number bitwise OR -pathshorten({expr}) String shorten directory names in a path +pathshorten({expr} [, {len}]) String shorten directory names in a path perleval({expr}) any evaluate |perl| expression pow({x}, {y}) Float {x} to the power of {y} prevnonblank({lnum}) Number line nr of non-blank line <= {lnum} @@ -5204,13 +5204,17 @@ or({expr}, {expr}) *or()* < Can also be used as a |method|: > :let bits = bits->or(0x80) -pathshorten({path}) *pathshorten()* +pathshorten({expr} [, {len}]) *pathshorten()* Shorten directory names in the path {path} and return the result. The tail, the file name, is kept as-is. The other - components in the path are reduced to single letters. Leading - '~' and '.' characters are kept. Example: > + components in the path are reduced to {len} letters in length. + If {len} is omitted or smaller than 1 then 1 is used (single + letters). Leading '~' and '.' characters are kept. Examples: > :echo pathshorten('~/.config/nvim/autoload/file1.vim') < ~/.c/n/a/file1.vim ~ +> + :echo pathshorten('~/.config/nvim/autoload/file2.vim', 2) +< ~/.co/nv/au/file2.vim ~ It doesn't matter if the path exists or not. Can also be used as a |method|: > -- cgit From 05f38bbede99ea0223550554bcfb9ab43d036d1f Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sun, 6 Feb 2022 12:09:16 +0100 Subject: vim-patch:8.2.4305: tex filetype detection fails Problem: Tex filetype detection fails. Solution: Check value to be positive. (closes vim/vim#9704) https://github.com/vim/vim/commit/e5b7897585eccec84431d8b23df5cde2e283828c --- runtime/autoload/dist/ft.vim | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim index 5d8734a625..aacecc521e 100644 --- a/runtime/autoload/dist/ft.vim +++ b/runtime/autoload/dist/ft.vim @@ -726,7 +726,7 @@ func dist#ft#FTperl() endif let save_cursor = getpos('.') call cursor(1,1) - let has_use = search('^use\s\s*\k', 'c', 30) + let has_use = search('^use\s\s*\k', 'c', 30) > 0 call setpos('.', save_cursor) if has_use setf perl @@ -758,7 +758,8 @@ func dist#ft#FTtex() let save_cursor = getpos('.') call cursor(1,1) let firstNC = search('^\s*[^[:space:]%]', 'c', 1000) - if firstNC " Check the next thousand lines for a LaTeX or ConTeXt keyword. + if firstNC > 0 + " Check the next thousand lines for a LaTeX or ConTeXt keyword. let lpat = 'documentclass\>\|usepackage\>\|begin{\|newcommand\>\|renewcommand\>' let cpat = 'start\a\+\|setup\a\+\|usemodule\|enablemode\|enableregime\|setvariables\|useencoding\|usesymbols\|stelle\a\+\|verwende\a\+\|stel\a\+\|gebruik\a\+\|usa\a\+\|imposta\a\+\|regle\a\+\|utilisemodule\>' let kwline = search('^\s*\\\%(' . lpat . '\)\|^\s*\\\(' . cpat . '\)', -- cgit From d457168e3b6078ae018a2b1fe59ff54f82d3ba14 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 7 Feb 2022 06:48:10 +0800 Subject: vim-patch:8.2.0208: fnamemodify() does not apply ":~" when followed by ":." Problem: Fnamemodify() does not apply ":~" when followed by ":.". Solution: Don't let a failing ":." cause the ":~" to be skipped. (Yasuhiro Matsumoto, closes vim/vim#5577) https://github.com/vim/vim/commit/d816cd94d87afb73c505bf1e5cd5e07522482113 --- runtime/doc/cmdline.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/cmdline.txt b/runtime/doc/cmdline.txt index 641cd93386..f2f6ebb2c9 100644 --- a/runtime/doc/cmdline.txt +++ b/runtime/doc/cmdline.txt @@ -908,8 +908,7 @@ These modifiers can be given, in this order: directory. :. Reduce file name to be relative to current directory, if possible. File name is unmodified if it is not below the - current directory, but on MS-Windows the drive is removed if - it is the current drive. + current directory. For maximum shortness, use ":~:.". :h Head of the file name (the last component and any separators removed). Cannot be used with :e, :r or :t. -- cgit From fba00b5e7ef2b6903a4588a2c080d8b33a8a2b68 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Sat, 1 Jan 2022 14:58:32 +0000 Subject: vim-patch:8.2.1665: cannot do fuzzy string matching Problem: Cannot do fuzzy string matching. Solution: Add matchfuzzy(). (Yegappan Lakshmanan, closes vim/vim#6932) https://github.com/vim/vim/commit/635414dd2f3ae7d4d972d79b806348a6516cb91a Adjust Test_matchfuzzy's 2nd assert to expect the last error thrown, as v8.2.1183 hasn't been ported yet (to be honest, the error message is kinda weird if the 2nd argument is not convertible to string). We can still port this fully as porting v8.2.1183 would require removing this change to pass CI. --- runtime/doc/builtin.txt | 22 ++++++++++++++++++++++ runtime/doc/usr_41.txt | 1 + 2 files changed, 23 insertions(+) (limited to 'runtime') diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 56bc8bfb3e..198ef25ed9 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -296,6 +296,7 @@ matcharg({nr}) List arguments of |:match| matchdelete({id} [, {win}]) Number delete match identified by {id} matchend({expr}, {pat}[, {start}[, {count}]]) Number position where {pat} ends in {expr} +matchfuzzy({list}, {str}) List fuzzy match {str} in {list} matchlist({expr}, {pat}[, {start}[, {count}]]) List match and submatches of {pat} in {expr} matchstr({expr}, {pat}[, {start}[, {count}]]) @@ -4857,6 +4858,27 @@ matchend({expr}, {pat} [, {start} [, {count}]]) *matchend()* Can also be used as a |method|: > GetText()->matchend('word') +matchfuzzy({list}, {str}) *matchfuzzy()* + Returns a list with all the strings in {list} that fuzzy + match {str}. The strings in the returned list are sorted + based on the matching score. {str} is treated as a literal + string and regular expression matching is NOT supported. + The maximum supported {str} length is 256. + + If there are no matching strings or there is an error, then an + empty list is returned. If length of {str} is greater than + 256, then returns an empty list. + + Example: > + :echo matchfuzzy(["clay", "crow"], "cay") +< results in ["clay"]. > + :echo getbufinfo()->map({_, v -> v.name})->matchfuzzy("ndl") +< results in a list of buffer names fuzzy matching "ndl". > + :echo v:oldfiles->matchfuzzy("test") +< results in a list of file names fuzzy matching "test". > + :let l = readfile("buffer.c")->matchfuzzy("str") +< results in a list of lines in "buffer.c" fuzzy matching "str". + matchlist({expr}, {pat} [, {start} [, {count}]]) *matchlist()* Same as |match()|, but return a |List|. The first item in the list is the matched string, same as what matchstr() would diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt index bf29c94d51..19f58cddd6 100644 --- a/runtime/doc/usr_41.txt +++ b/runtime/doc/usr_41.txt @@ -608,6 +608,7 @@ String manipulation: *string-functions* toupper() turn a string to uppercase match() position where a pattern matches in a string matchend() position where a pattern match ends in a string + matchfuzzy() fuzzy matches a string in a list of strings matchstr() match of a pattern in a string matchstrpos() match and positions of a pattern in a string matchlist() like matchstr() and also return submatches -- cgit From 960ea01972ad5fd291a846dce67f96a95222c310 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Sat, 1 Jan 2022 16:40:28 +0000 Subject: vim-patch:8.2.1726: fuzzy matching only works on strings Problem: Fuzzy matching only works on strings. Solution: Support passing a dict. Add matchfuzzypos() to also get the match positions. (Yegappan Lakshmanan, closes vim/vim#6947) https://github.com/vim/vim/commit/4f73b8e9cc83f647b34002554a8bdf9abec0a82f Also remove some N/A and seemingly useless NULL checks -- Nvim allocs can't return NULL. I'm not sure why the retmatchpos stuff in match_fuzzy checks for NULL too, given that Vim checks for NULL alloc in do_fuzzymatch; assert that the li stuff is not NULL as that's the one check I'm ever-so-slightly unsure about. Adjust tests. Note that the text_cb tests actually throw E6000 in Nvim, but we also can't assert that error due to v8.2.1183 not being ported yet. --- runtime/doc/builtin.txt | 57 +++++++++++++++++++++++++++++++++++++++++++------ runtime/doc/usr_41.txt | 1 + 2 files changed, 51 insertions(+), 7 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 198ef25ed9..14cf9f09fc 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -296,7 +296,10 @@ matcharg({nr}) List arguments of |:match| matchdelete({id} [, {win}]) Number delete match identified by {id} matchend({expr}, {pat}[, {start}[, {count}]]) Number position where {pat} ends in {expr} -matchfuzzy({list}, {str}) List fuzzy match {str} in {list} +matchfuzzy({list}, {str} [, {dict}]) + List fuzzy match {str} in {list} +matchfuzzypos({list}, {str} [, {dict}]) + List fuzzy match {str} in {list} matchlist({expr}, {pat}[, {start}[, {count}]]) List match and submatches of {pat} in {expr} matchstr({expr}, {pat}[, {start}[, {count}]]) @@ -4858,12 +4861,25 @@ matchend({expr}, {pat} [, {start} [, {count}]]) *matchend()* Can also be used as a |method|: > GetText()->matchend('word') -matchfuzzy({list}, {str}) *matchfuzzy()* - Returns a list with all the strings in {list} that fuzzy - match {str}. The strings in the returned list are sorted - based on the matching score. {str} is treated as a literal - string and regular expression matching is NOT supported. - The maximum supported {str} length is 256. +matchfuzzy({list}, {str} [, {dict}]) *matchfuzzy()* + If {list} is a list of strings, then returns a list with all + the strings in {list} that fuzzy match {str}. The strings in + the returned list are sorted based on the matching score. + + If {list} is a list of dictionaries, then the optional {dict} + argument supports the following items: + key key of the item which is fuzzy matched against + {str}. The value of this item should be a + string. + text_cb |Funcref| that will be called for every item + in {list} to get the text for fuzzy matching. + This should accept a dictionary item as the + argument and return the text for that item to + use for fuzzy matching. + + {str} is treated as a literal string and regular expression + matching is NOT supported. The maximum supported {str} length + is 256. If there are no matching strings or there is an error, then an empty list is returned. If length of {str} is greater than @@ -4874,11 +4890,38 @@ matchfuzzy({list}, {str}) *matchfuzzy()* < results in ["clay"]. > :echo getbufinfo()->map({_, v -> v.name})->matchfuzzy("ndl") < results in a list of buffer names fuzzy matching "ndl". > + :echo getbufinfo()->matchfuzzy("ndl", {'key' : 'name'}) +< results in a list of buffer information dicts with buffer + names fuzzy matching "ndl". > + :echo getbufinfo()->matchfuzzy("spl", + \ {'text_cb' : {v -> v.name}}) +< results in a list of buffer information dicts with buffer + names fuzzy matching "spl". > :echo v:oldfiles->matchfuzzy("test") < results in a list of file names fuzzy matching "test". > :let l = readfile("buffer.c")->matchfuzzy("str") < results in a list of lines in "buffer.c" fuzzy matching "str". +matchfuzzypos({list}, {str} [, {dict}]) *matchfuzzypos()* + Same as |matchfuzzy()|, but returns the list of matched + strings and the list of character positions where characters + in {str} matches. + + If {str} matches multiple times in a string, then only the + positions for the best match is returned. + + If there are no matching strings or there is an error, then a + list with two empty list items is returned. + + Example: > + :echo matchfuzzypos(['testing'], 'tsg') +< results in [['testing'], [[0, 2, 6]]] > + :echo matchfuzzypos(['clay', 'lacy'], 'la') +< results in [['lacy', 'clay'], [[0, 1], [1, 2]]] > + :echo [{'text': 'hello', 'id' : 10}] + \ ->matchfuzzypos('ll', {'key' : 'text'}) +< results in [{'id': 10, 'text': 'hello'}] [[2, 3]] + matchlist({expr}, {pat} [, {start} [, {count}]]) *matchlist()* Same as |match()|, but return a |List|. The first item in the list is the matched string, same as what matchstr() would diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt index 19f58cddd6..bf024315f6 100644 --- a/runtime/doc/usr_41.txt +++ b/runtime/doc/usr_41.txt @@ -609,6 +609,7 @@ String manipulation: *string-functions* match() position where a pattern matches in a string matchend() position where a pattern match ends in a string matchfuzzy() fuzzy matches a string in a list of strings + matchfuzzypos() fuzzy matches a string in a list of strings matchstr() match of a pattern in a string matchstrpos() match and positions of a pattern in a string matchlist() like matchstr() and also return submatches -- cgit From 30deb14f397e576aedfa54600ed7408b3e03459d Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Sat, 1 Jan 2022 21:25:41 +0000 Subject: vim-patch:8.2.1893: fuzzy matching does not support multiple words Problem: Fuzzy matching does not support multiple words. Solution: Add support for matching white space separated words. (Yegappan Lakshmanan, closes vim/vim#7163) https://github.com/vim/vim/commit/8ded5b647aa4b3338da721b343e0bce0f86655f6 --- runtime/doc/builtin.txt | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 14cf9f09fc..745f1d9116 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -4866,8 +4866,15 @@ matchfuzzy({list}, {str} [, {dict}]) *matchfuzzy()* the strings in {list} that fuzzy match {str}. The strings in the returned list are sorted based on the matching score. + The optional {dict} argument always supports the following + items: + matchseq When this item is present and {str} contains + multiple words separated by white space, then + returns only matches that contain the words in + the given sequence. + If {list} is a list of dictionaries, then the optional {dict} - argument supports the following items: + argument supports the following additional items: key key of the item which is fuzzy matched against {str}. The value of this item should be a string. @@ -4881,6 +4888,9 @@ matchfuzzy({list}, {str} [, {dict}]) *matchfuzzy()* matching is NOT supported. The maximum supported {str} length is 256. + When {str} has multiple words each separated by white space, + then the list of strings that have all the words is returned. + If there are no matching strings or there is an error, then an empty list is returned. If length of {str} is greater than 256, then returns an empty list. @@ -4900,7 +4910,12 @@ matchfuzzy({list}, {str} [, {dict}]) *matchfuzzy()* :echo v:oldfiles->matchfuzzy("test") < results in a list of file names fuzzy matching "test". > :let l = readfile("buffer.c")->matchfuzzy("str") -< results in a list of lines in "buffer.c" fuzzy matching "str". +< results in a list of lines in "buffer.c" fuzzy matching "str". > + :echo ['one two', 'two one']->matchfuzzy('two one') +< results in ['two one', 'one two']. > + :echo ['one two', 'two one']->matchfuzzy('two one', + \ {'matchseq': 1}) +< results in ['two one']. matchfuzzypos({list}, {str} [, {dict}]) *matchfuzzypos()* Same as |matchfuzzy()|, but returns the list of matched -- cgit From 715fbcbb8c6ec4385d1168b1260fdb991d4e6fc5 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Sat, 1 Jan 2022 22:40:42 +0000 Subject: vim-patch:8.2.2280: fuzzy matching doesn't give access to the scores Problem: Fuzzy matching doesn't give access to the scores. Solution: Return the scores with a third list. (Yegappan Lakshmanan, closes vim/vim#7596) https://github.com/vim/vim/commit/9d19e4f4ba55f8bef18d4991abdf740ff6472dba Remove seemingly useless NULL checks. assert that removing the li one wasn't dumb. --- runtime/doc/builtin.txt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 745f1d9116..45c03fc447 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -4919,23 +4919,25 @@ matchfuzzy({list}, {str} [, {dict}]) *matchfuzzy()* matchfuzzypos({list}, {str} [, {dict}]) *matchfuzzypos()* Same as |matchfuzzy()|, but returns the list of matched - strings and the list of character positions where characters - in {str} matches. + strings, the list of character positions where characters + in {str} matches and a list of matching scores. You can + use |byteidx()| to convert a character position to a byte + position. If {str} matches multiple times in a string, then only the positions for the best match is returned. If there are no matching strings or there is an error, then a - list with two empty list items is returned. + list with three empty list items is returned. Example: > :echo matchfuzzypos(['testing'], 'tsg') -< results in [['testing'], [[0, 2, 6]]] > +< results in [['testing'], [[0, 2, 6]], [99]] > :echo matchfuzzypos(['clay', 'lacy'], 'la') -< results in [['lacy', 'clay'], [[0, 1], [1, 2]]] > +< results in [['lacy', 'clay'], [[0, 1], [1, 2]], [153, 133]] > :echo [{'text': 'hello', 'id' : 10}] \ ->matchfuzzypos('ll', {'key' : 'text'}) -< results in [{'id': 10, 'text': 'hello'}] [[2, 3]] +< results in [[{'id': 10, 'text': 'hello'}], [[2, 3]], [127]] matchlist({expr}, {pat} [, {start} [, {count}]]) *matchlist()* Same as |match()|, but return a |List|. The first item in the -- cgit From ce797e08f539dc24d16ea8c02591296bbbc83772 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Sat, 1 Jan 2022 23:06:09 +0000 Subject: vim-patch:8.2.2813: cannot grep using fuzzy matching Problem: Cannot grep using fuzzy matching. Solution: Add the "f" flag to :vimgrep. (Yegappan Lakshmanan, closes vim/vim#8152) https://github.com/vim/vim/commit/bb01a1ef3a093cdb36877ba73474719c531dc8cb --- runtime/doc/quickfix.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/quickfix.txt b/runtime/doc/quickfix.txt index bb4d807413..c7289cfca6 100644 --- a/runtime/doc/quickfix.txt +++ b/runtime/doc/quickfix.txt @@ -989,7 +989,7 @@ commands can be combined to create a NewGrep command: > 5.1 using Vim's internal grep *:vim* *:vimgrep* *E682* *E683* -:vim[grep][!] /{pattern}/[g][j] {file} ... +:vim[grep][!] /{pattern}/[g][j][f] {file} ... Search for {pattern} in the files {file} ... and set the error list to the matches. Files matching 'wildignore' are ignored; files in 'suffixes' are @@ -1042,20 +1042,20 @@ commands can be combined to create a NewGrep command: > :vimgrep Error *.c < *:lv* *:lvimgrep* -:lv[imgrep][!] /{pattern}/[g][j] {file} ... +:lv[imgrep][!] /{pattern}/[g][j][f] {file} ... :lv[imgrep][!] {pattern} {file} ... Same as ":vimgrep", except the location list for the current window is used instead of the quickfix list. *:vimgrepa* *:vimgrepadd* -:vimgrepa[dd][!] /{pattern}/[g][j] {file} ... +:vimgrepa[dd][!] /{pattern}/[g][j][f] {file} ... :vimgrepa[dd][!] {pattern} {file} ... Just like ":vimgrep", but instead of making a new list of errors the matches are appended to the current list. *:lvimgrepa* *:lvimgrepadd* -:lvimgrepa[dd][!] /{pattern}/[g][j] {file} ... +:lvimgrepa[dd][!] /{pattern}/[g][j][f] {file} ... :lvimgrepa[dd][!] {pattern} {file} ... Same as ":vimgrepadd", except the location list for the current window is used instead of the quickfix -- cgit From 02e74314459621bfd18b3b3a1e3ac261658dc096 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Sun, 2 Jan 2022 00:42:09 +0000 Subject: docs(fuzzy-match): cherry-pick latest changes https://github.com/vim/vim/commit/53f7fccc9413c9f770694b56f40f242d383b2d5f https://github.com/vim/vim/commit/1b884a0053982335f644eec6c71027706bf3c522 https://github.com/vim/vim/commit/4c295027a426986566cd7a76c47a6d3a529727e7 https://github.com/vim/vim/commit/3ec3217f0491e9ba8aa8ea02f7e454cd19a287ef --- runtime/doc/builtin.txt | 5 ++++- runtime/doc/pattern.txt | 33 +++++++++++++++++++++++++++++++++ runtime/doc/quickfix.txt | 7 +++++++ 3 files changed, 44 insertions(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 45c03fc447..b7a9a06b3c 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -4862,7 +4862,7 @@ matchend({expr}, {pat} [, {start} [, {count}]]) *matchend()* GetText()->matchend('word') matchfuzzy({list}, {str} [, {dict}]) *matchfuzzy()* - If {list} is a list of strings, then returns a list with all + If {list} is a list of strings, then returns a |List| with all the strings in {list} that fuzzy match {str}. The strings in the returned list are sorted based on the matching score. @@ -4895,6 +4895,9 @@ matchfuzzy({list}, {str} [, {dict}]) *matchfuzzy()* empty list is returned. If length of {str} is greater than 256, then returns an empty list. + Refer to |fuzzy-match| for more information about fuzzy + matching strings. + Example: > :echo matchfuzzy(["clay", "crow"], "cay") < results in ["clay"]. > diff --git a/runtime/doc/pattern.txt b/runtime/doc/pattern.txt index 634145da3e..42005b0d78 100644 --- a/runtime/doc/pattern.txt +++ b/runtime/doc/pattern.txt @@ -1421,5 +1421,38 @@ Finally, these constructs are unique to Perl: are suggested to use ":match" for manual matching and ":2match" for another plugin. +============================================================================== +11. Fuzzy matching *fuzzy-match* + +Fuzzy matching refers to matching strings using a non-exact search string. +Fuzzy matching will match a string, if all the characters in the search string +are present anywhere in the string in the same order. Case is ignored. In a +matched string, other characters can be present between two consecutive +characters in the search string. If the search string has multiple words, then +each word is matched separately. So the words in the search string can be +present in any order in a string. + +Fuzzy matching assigns a score for each matched string based on the following +criteria: + - The number of sequentially matching characters. + - The number of characters (distance) between two consecutive matching + characters. + - Matches at the beginning of a word + - Matches at a camel case character (e.g. Case in CamelCase) + - Matches after a path separator or a hyphen. + - The number of unmatched characters in a string. +The matching string with the highest score is returned first. + +For example, when you search for the "get pat" string using fuzzy matching, it +will match the strings "GetPattern", "PatternGet", "getPattern", "patGetter", +"getSomePattern", "MatchpatternGet" etc. + +The functions |matchfuzzy()| and |matchfuzzypos()| can be used to fuzzy search +a string in a List of strings. The matchfuzzy() function returns a List of +matching strings. The matchfuzzypos() functions returns the List of matches, +the matching positions and the fuzzy match scores. + +The "f" flag of `:vimgrep` enables fuzzy matching. + vim:tw=78:ts=8:noet:ft=help:norl: diff --git a/runtime/doc/quickfix.txt b/runtime/doc/quickfix.txt index c7289cfca6..ed736ad4eb 100644 --- a/runtime/doc/quickfix.txt +++ b/runtime/doc/quickfix.txt @@ -1014,6 +1014,13 @@ commands can be combined to create a NewGrep command: > updated. With the [!] any changes in the current buffer are abandoned. + 'f' When the 'f' flag is specified, fuzzy string + matching is used to find matching lines. In this + case, {pattern} is treated as a literal string + instead of a regular expression. See + |fuzzy-match| for more information about fuzzy + matching strings. + |QuickFixCmdPre| and |QuickFixCmdPost| are triggered. A file that is opened for matching may use a buffer number, but it is reused if possible to avoid -- cgit From 64116d78502e0ca611e13adf9323ef2d3fe708c2 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Tue, 8 Feb 2022 01:19:06 +0100 Subject: chore: fix typos (#17250) Co-authored-by: zeertzjq Co-authored-by: Dani Dickstein Co-authored-by: Axel Dahlberg --- runtime/doc/api.txt | 2 +- runtime/doc/autocmd.txt | 2 +- runtime/doc/builtin.txt | 102 ++++++++++++++++++++++++----------------------- runtime/doc/repeat.txt | 4 +- runtime/doc/vim_diff.txt | 3 +- runtime/lua/vim/ui.lua | 2 +- 6 files changed, 59 insertions(+), 56 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index 2da1f5e40d..7bae5bb94b 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -186,7 +186,7 @@ About the `functions` map: a type name, e.g. `nvim_buf_get_lines` is the `get_lines` method of a Buffer instance. |dev-api| - Global functions have the "method=false" flag and are prefixed with just - `nvim_`, e.g. `nvim_get_buffers`. + `nvim_`, e.g. `nvim_list_bufs`. *api-mapping* External programs (clients) can use the metadata to discover the API, using diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt index 5e50f9c1f8..ed75acf36e 100644 --- a/runtime/doc/autocmd.txt +++ b/runtime/doc/autocmd.txt @@ -526,7 +526,7 @@ DirChanged After the |current-directory| was changed. "auto" to trigger on 'autochdir'. Sets these |v:event| keys: cwd: current working directory - scope: "global", "tab", "window" + scope: "global", "tabpage", "window" changed_window: v:true if we fired the event switching window (or tab) is set to the new directory name. diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index b7a9a06b3c..9bf37a3759 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -22,8 +22,10 @@ acos({expr}) Float arc cosine of {expr} add({object}, {item}) List/Blob append {item} to {object} and({expr}, {expr}) Number bitwise AND api_info() Dict api metadata -append({lnum}, {string}) Number append {string} below line {lnum} -append({lnum}, {list}) Number append lines {list} below line {lnum} +append({lnum}, {text}) Number append {text} below line {lnum} +appendbufline({expr}, {lnum}, {text}) + Number append {text} below line {lnum} + in buffer {expr} argc([{winid}]) Number number of files in the argument list argidx() Number current index in the argument list arglistid([{winnr} [, {tabnr}]]) Number argument list id @@ -52,7 +54,7 @@ assert_notmatch({pat}, {text} [, {msg}]) assert_report({msg}) Number report a test failure assert_true({actual} [, {msg}]) Number assert {actual} is true atan({expr}) Float arc tangent of {expr} -atan2({expr}, {expr}) Float arc tangent of {expr1} / {expr2} +atan2({expr1}, {expr2}) Float arc tangent of {expr1} / {expr2} browse({save}, {title}, {initdir}, {default}) String put up a file requester browsedir({title}, {initdir}) String put up a directory requester @@ -72,9 +74,9 @@ call({func}, {arglist} [, {dict}]) any call {func} with arguments {arglist} ceil({expr}) Float round {expr} up changenr() Number current change number -chanclose({id}[, {stream}]) Number Closes a channel or one of its streams +chanclose({id} [, {stream}]) Number Closes a channel or one of its streams chansend({id}, {data}) Number Writes {data} to channel -char2nr({expr}[, {utf8}]) Number ASCII/UTF-8 value of first char in {expr} +char2nr({expr} [, {utf8}]) Number ASCII/UTF-8 value of first char in {expr} charcol({expr}) Number column number of cursor or mark charidx({string}, {idx} [, {countcc}]) Number char index of byte {idx} in {string} @@ -91,8 +93,8 @@ confirm({msg} [, {choices} [, {default} [, {type}]]]) copy({expr}) any make a shallow copy of {expr} cos({expr}) Float cosine of {expr} cosh({expr}) Float hyperbolic cosine of {expr} -count({list}, {expr} [, {ic} [, {start}]]) - Number count how many {expr} are in {list} +count({comp}, {expr} [, {ic} [, {start}]]) + Number count how many {expr} are in {comp} cscope_connection([{num}, {dbpath} [, {prepend}]]) Number checks existence of cscope connection ctxget([{index}]) Dict return the |context| dict at {index} @@ -100,7 +102,7 @@ ctxpop() none pop and restore |context| from the |context-stack| ctxpush([{types}]) none push the current |context| to the |context-stack| -ctxset({context}[, {index}]) none set |context| at {index} +ctxset({context} [, {index}]) none set |context| at {index} ctxsize() Number return |context-stack| size cursor({lnum}, {col} [, {off}]) Number move cursor to {lnum}, {col}, {off} @@ -108,7 +110,7 @@ cursor({list}) Number move cursor to position in {list} debugbreak({pid}) Number interrupt process being debugged deepcopy({expr} [, {noref}]) any make a full copy of {expr} delete({fname} [, {flags}]) Number delete the file or directory {fname} -deletebufline({buf}, {first}[, {last}]) +deletebufline({buf}, {first} [, {last}]) Number delete lines from buffer {buf} dictwatcheradd({dict}, {pattern}, {callback}) Start watching a dictionary @@ -212,7 +214,7 @@ gettabvar({nr}, {varname} [, {def}]) gettabwinvar({tabnr}, {winnr}, {name} [, {def}]) any {name} in {winnr} in tab page {tabnr} gettagstack([{nr}]) Dict get the tag stack of window {nr} -getwininfo([{winid}]) List list of windows +getwininfo([{winid}]) List list of info about each window getwinpos([{timeout}]) List X and Y coord in pixels of the Vim window getwinposx() Number X coord in pixels of Vim window getwinposy() Number Y coord in pixels of Vim window @@ -262,9 +264,9 @@ items({dict}) List key-value pairs in {dict} jobpid({id}) Number Returns pid of a job. jobresize({id}, {width}, {height}) Number Resize pseudo terminal window of a job -jobstart({cmd}[, {opts}]) Number Spawns {cmd} as a job +jobstart({cmd} [, {opts}]) Number Spawns {cmd} as a job jobstop({id}) Number Stops a job -jobwait({ids}[, {timeout}]) Number Wait for a set of jobs +jobwait({ids} [, {timeout}]) Number Wait for a set of jobs join({list} [, {sep}]) String join {list} items into one String json_decode({expr}) any Convert {expr} from JSON json_encode({expr}) String Convert {expr} to JSON @@ -279,32 +281,32 @@ list2str({list} [, {utf8}]) String turn numbers in {list} into a String localtime() Number current time log({expr}) Float natural logarithm (base e) of {expr} log10({expr}) Float logarithm of Float {expr} to base 10 -luaeval({expr}[, {expr}]) any evaluate Lua expression +luaeval({expr} [, {expr}]) any evaluate |Lua| expression map({expr1}, {expr2}) List/Dict change each item in {expr1} to {expr} -maparg({name}[, {mode} [, {abbr} [, {dict}]]]) +maparg({name} [, {mode} [, {abbr} [, {dict}]]]) String or Dict rhs of mapping {name} in mode {mode} -mapcheck({name}[, {mode} [, {abbr}]]) +mapcheck({name} [, {mode} [, {abbr}]]) String check for mappings matching {name} -match({expr}, {pat}[, {start}[, {count}]]) +match({expr}, {pat} [, {start} [, {count}]]) Number position where {pat} matches in {expr} -matchadd({group}, {pattern}[, {priority}[, {id}]]) +matchadd({group}, {pattern} [, {priority} [, {id} [, {dict}]]]) Number highlight {pattern} with {group} -matchaddpos({group}, {list}[, {priority}[, {id}]]) +matchaddpos({group}, {pos} [, {priority} [, {id} [, {dict}]]]) Number highlight positions with {group} matcharg({nr}) List arguments of |:match| matchdelete({id} [, {win}]) Number delete match identified by {id} -matchend({expr}, {pat}[, {start}[, {count}]]) +matchend({expr}, {pat} [, {start} [, {count}]]) Number position where {pat} ends in {expr} matchfuzzy({list}, {str} [, {dict}]) List fuzzy match {str} in {list} matchfuzzypos({list}, {str} [, {dict}]) List fuzzy match {str} in {list} -matchlist({expr}, {pat}[, {start}[, {count}]]) +matchlist({expr}, {pat} [, {start} [, {count}]]) List match and submatches of {pat} in {expr} -matchstr({expr}, {pat}[, {start}[, {count}]]) +matchstr({expr}, {pat} [, {start} [, {count}]]) String {count}'th match of {pat} in {expr} -matchstrpos({expr}, {pat}[, {start}[, {count}]]) +matchstrpos({expr}, {pat} [, {start} [, {count}]]) List {count}'th match of {pat} in {expr} max({expr}) Number maximum value of items in {expr} menu_get({path} [, {modes}]) List description of |menus| matched by {path} @@ -315,7 +317,7 @@ mode([expr]) String current editing mode msgpackdump({list} [, {type}]) List/Blob dump objects to msgpack msgpackparse({data}) List parse msgpack to a list of objects nextnonblank({lnum}) Number line nr of non-blank line >= {lnum} -nr2char({expr}[, {utf8}]) String single char with ASCII/UTF-8 value {expr} +nr2char({expr} [, {utf8}]) String single char with ASCII/UTF-8 value {expr} nvim_...({args}...) any call nvim |api| functions or({expr}, {expr}) Number bitwise OR pathshorten({expr} [, {len}]) String shorten directory names in a path @@ -365,9 +367,9 @@ resolve({filename}) String get filename a shortcut points to reverse({list}) List reverse {list} in-place round({expr}) Float round off {expr} rubyeval({expr}) any evaluate |Ruby| expression -rpcnotify({channel}, {event}[, {args}...]) +rpcnotify({channel}, {event} [, {args}...]) Sends an |RPC| notification to {channel} -rpcrequest({channel}, {method}[, {args}...]) +rpcrequest({channel}, {method} [, {args}...]) Sends an |RPC| request to {channel} screenattr({row}, {col}) Number attribute at screen position screenchar({row}, {col}) Number character at screen position @@ -390,8 +392,8 @@ searchpos({pattern} [, {flags} [, {stopline} [, {timeout}]]]) server2client({clientid}, {string}) Number send reply string serverlist() String get a list of available servers -setbufline( {expr}, {lnum}, {line}) - Number set line {lnum} to {line} in buffer +setbufline({expr}, {lnum}, {text}) + Number set line {lnum} to {text} in buffer {expr} setbufvar({buf}, {varname}, {val}) set {varname} in buffer {buf} to {val} setcharpos({expr}, {list}) Number set the {expr} position to {list} @@ -410,7 +412,7 @@ setpos({expr}, {list}) Number set the {expr} position to {list} setqflist({list} [, {action}]) Number modify quickfix list using {list} setqflist({list}, {action}, {what}) Number modify specific quickfix list props -setreg({n}, {v}[, {opt}]) Number set register to value and type +setreg({n}, {v} [, {opt}]) Number set register to value and type settabvar({nr}, {varname}, {val}) set {varname} in tab page {nr} to {val} settabwinvar({tabnr}, {winnr}, {varname}, {val}) set {varname} in window {winnr} in tab page {tabnr} to {val} @@ -495,9 +497,9 @@ system({cmd} [, {input}]) String output of shell command/filter {cmd} systemlist({cmd} [, {input}]) List output of shell command/filter {cmd} tabpagebuflist([{arg}]) List list of buffer numbers in tab page tabpagenr([{arg}]) Number number of current or last tab page -tabpagewinnr({tabarg}[, {arg}]) +tabpagewinnr({tabarg} [, {arg}]) Number number of current window in tab page -taglist({expr}[, {filename}]) List list of tags matching {expr} +taglist({expr} [, {filename}]) List list of tags matching {expr} tagfiles() List tags files used tan({expr}) Float tangent of {expr} tanh({expr}) Float hyperbolic tangent of {expr} @@ -524,7 +526,7 @@ uniq({list} [, {func} [, {dict}]]) values({dict}) List values in {dict} virtcol({expr}) Number screen column of cursor or mark visualmode([expr]) String last visual mode used -wait({timeout}, {condition}[, {interval}]) +wait({timeout}, {condition} [, {interval}]) Number Wait until {condition} is satisfied wildmenumode() Number whether 'wildmenu' mode is active win_execute({id}, {command} [, {silent}]) @@ -999,7 +1001,7 @@ changenr() *changenr()* redo it is the number of the redone change. After undo it is one less than the number of the undone change. -chanclose({id}[, {stream}]) *chanclose()* +chanclose({id} [, {stream}]) *chanclose()* Close a channel or a specific stream associated with it. For a job, {stream} can be one of "stdin", "stdout", "stderr" or "rpc" (closes stdin/stdout for a job started @@ -1443,7 +1445,7 @@ ctxpush([{types}]) *ctxpush()* which |context-types| to include in the pushed context. Otherwise, all context types are included. -ctxset({context}[, {index}]) *ctxset()* +ctxset({context} [, {index}]) *ctxset()* Sets the |context| at {index} from the top of the |context-stack| to that represented by {context}. {context} is a Dictionary with context data (|context-dict|). @@ -1487,7 +1489,7 @@ cursor({list}) Can also be used as a |method|: > GetCursorPos()->cursor() -deepcopy({expr}[, {noref}]) *deepcopy()* *E698* +deepcopy({expr} [, {noref}]) *deepcopy()* *E698* Make a copy of {expr}. For Numbers and Strings this isn't different from using {expr} directly. When {expr} is a |List| a full copy is created. This means @@ -1530,7 +1532,7 @@ delete({fname} [, {flags}]) *delete()* Can also be used as a |method|: > GetName()->delete() -deletebufline({buf}, {first}[, {last}]) *deletebufline()* +deletebufline({buf}, {first} [, {last}]) *deletebufline()* Delete lines {first} to {last} (inclusive) from buffer {buf}. If {last} is omitted then delete line {first} only. On success 0 is returned, on failure 1 is returned. @@ -1540,7 +1542,7 @@ deletebufline({buf}, {first}[, {last}]) *deletebufline()* For the use of {buf}, see |bufname()| above. - {first} and {last} are used like with |setline()|. Note that + {first} and {last} are used like with |getline()|. Note that when using |line()| this refers to the current buffer. Use "$" to refer to the last line in buffer {buf}. @@ -2865,7 +2867,7 @@ getcursorcharpos([{winid}]) Can also be used as a |method|: > GetWinid()->getcursorcharpos() -getcwd([{winnr}[, {tabnr}]]) *getcwd()* +getcwd([{winnr} [, {tabnr}]]) *getcwd()* With no arguments, returns the name of the effective |current-directory|. With {winnr} or {tabnr} the working directory of that scope is returned, and 'autochdir' is @@ -3022,7 +3024,7 @@ getline({lnum} [, {end}]) < To get lines from another buffer see |getbufline()| -getloclist({nr},[, {what}]) *getloclist()* +getloclist({nr} [, {what}]) *getloclist()* Returns a |List| with all the entries in the location list for window {nr}. {nr} can be the window number or the |window-ID|. When {nr} is zero the current window is used. @@ -3649,7 +3651,7 @@ has_key({dict}, {key}) *has_key()* Can also be used as a |method|: > mydict->has_key(key) -haslocaldir([{winnr}[, {tabnr}]]) *haslocaldir()* +haslocaldir([{winnr} [, {tabnr}]]) *haslocaldir()* The result is a Number, which is 1 when the window has set a local path via |:lcd| or when {winnr} is -1 and the tabpage has set a local path via |:tcd|, otherwise 0. @@ -4151,7 +4153,7 @@ jobresize({job}, {width}, {height}) *jobresize()* columns and {height} rows. Fails if the job was not started with `"pty":v:true`. -jobstart({cmd}[, {opts}]) *jobstart()* +jobstart({cmd} [, {opts}]) *jobstart()* Spawns {cmd} as a job. If {cmd} is a List it runs directly (no 'shell'). If {cmd} is a String it runs in the 'shell', like this: > @@ -4238,7 +4240,7 @@ jobstop({id}) *jobstop()* Returns 1 for valid job id, 0 for invalid id, including jobs have exited or stopped. -jobwait({jobs}[, {timeout}]) *jobwait()* +jobwait({jobs} [, {timeout}]) *jobwait()* Waits for jobs and their |on_exit| handlers to complete. {jobs} is a List of |job-id|s to wait for. @@ -4495,7 +4497,7 @@ log10({expr}) *log10()* Can also be used as a |method|: > Compute()->log10() -luaeval({expr}[, {expr}]) +luaeval({expr} [, {expr}]) Evaluate Lua expression {expr} and return its result converted to Vim data structures. See |lua-eval| for more details. @@ -4715,7 +4717,7 @@ match({expr}, {pat} [, {start} [, {count}]]) *match()* GetList()->match('word') < *matchadd()* *E798* *E799* *E801* *E957* -matchadd({group}, {pattern}[, {priority}[, {id} [, {dict}]]]) +matchadd({group}, {pattern} [, {priority} [, {id} [, {dict}]]]) Defines a pattern to be highlighted in the current window (a "match"). It will be highlighted with {group}. Returns an identification number (ID), which can be used to delete the @@ -6028,19 +6030,19 @@ round({expr}) *round()* Can also be used as a |method|: > Compute()->round() -rpcnotify({channel}, {event}[, {args}...]) *rpcnotify()* +rpcnotify({channel}, {event} [, {args}...]) *rpcnotify()* Sends {event} to {channel} via |RPC| and returns immediately. If {channel} is 0, the event is broadcast to all channels. Example: > :au VimLeave call rpcnotify(0, "leaving") -rpcrequest({channel}, {method}[, {args}...]) *rpcrequest()* +rpcrequest({channel}, {method} [, {args}...]) *rpcrequest()* Sends a request to {channel} to invoke {method} via |RPC| and blocks until a response is received. Example: > :let result = rpcrequest(rpc_chan, "func", 1, 2, 3) -rpcstart({prog}[, {argv}]) *rpcstart()* +rpcstart({prog} [, {argv}]) *rpcstart()* Deprecated. Replace > :let id = rpcstart('prog', ['arg1', 'arg2']) < with > @@ -7808,11 +7810,11 @@ substitute({string}, {pat}, {sub}, {flags}) *substitute()* swapinfo({fname}) *swapinfo()* The result is a dictionary, which holds information about the swapfile {fname}. The available fields are: - version VIM version + version Vim version user user name host host name fname original file name - pid PID of the VIM process that created the swap + pid PID of the Vim process that created the swap file mtime last modification time in seconds inode Optional: INODE number of the file @@ -8123,7 +8125,7 @@ tempname() *tempname()* *temp-file-name* For MS-Windows forward slashes are used when the 'shellslash' option is set or when 'shellcmdflag' starts with '-'. -termopen({cmd}[, {opts}]) *termopen()* +termopen({cmd} [, {opts}]) *termopen()* Spawns {cmd} in a new pseudo-terminal session connected to the current buffer. {cmd} is the same as the one passed to |jobstart()|. This function fails if the current buffer is @@ -8482,7 +8484,7 @@ visualmode([{expr}]) *visualmode()* a non-empty String, then the Visual mode will be cleared and the old value is returned. See |non-zero-arg|. -wait({timeout}, {condition}[, {interval}]) *wait()* +wait({timeout}, {condition} [, {interval}]) *wait()* Waits until {condition} evaluates to |TRUE|, where {condition} is a |Funcref| or |string| containing an expression. diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt index c7481ad290..a022049766 100644 --- a/runtime/doc/repeat.txt +++ b/runtime/doc/repeat.txt @@ -465,8 +465,8 @@ flag when defining the function, it is not relevant when executing it. > :set cpo-=C < *line-continuation-comment* -To add a comment in between the lines start with '\" '. Notice the space -after the double quote. Example: > +To add a comment in between the lines start with '"\ '. Notice the space +after the backslash. Example: > let array = [ "\ first entry comment \ 'first', diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index 11849632c5..7892b82137 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -322,6 +322,8 @@ coerced to strings. See |id()| for more details, currently it uses |c_CTRL-R| pasting a non-special register into |cmdline| omits the last . +|CursorMoved| always triggers when moving between windows. + Lua interface (|lua.txt|): - `:lua print("a\0b")` will print `a^@b`, like with `:echomsg "a\nb"` . In Vim @@ -483,7 +485,6 @@ Commands: :tearoff Compile-time features: - EBCDIC Emacs tags support X11 integration (see |x11-selection|) diff --git a/runtime/lua/vim/ui.lua b/runtime/lua/vim/ui.lua index 0f2de6ce5c..9d4b38f08a 100644 --- a/runtime/lua/vim/ui.lua +++ b/runtime/lua/vim/ui.lua @@ -78,7 +78,7 @@ end --- --- Example: ---
---- vim.ui.input({ prompt = 'Select value for shiftwidth: ' }, function(input)
+--- vim.ui.input({ prompt = 'Enter value for shiftwidth: ' }, function(input)
 ---     vim.o.shiftwidth = tonumber(input)
 --- end)
 --- 
-- cgit From 300b009f47bc617faa1c445966e2085c455e0c45 Mon Sep 17 00:00:00 2001 From: Edmund Cape Date: Wed, 19 Jan 2022 13:30:20 -0500 Subject: fix(healthcheck): handle empty reports --- runtime/autoload/health.vim | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/autoload/health.vim b/runtime/autoload/health.vim index 1d462ad02c..ec030adf04 100644 --- a/runtime/autoload/health.vim +++ b/runtime/autoload/health.vim @@ -21,10 +21,17 @@ function! health#check(plugin_names) abort throw 'healthcheck_not_found' endif eval type == 'v' ? call(func, []) : luaeval(func) + " in the event the healthcheck doesn't return anything + " (the plugin author should avoid this possibility) + if len(s:output) == 0 + throw 'healthcheck_no_return_value' + endif catch let s:output = [] " Clear the output if v:exception =~# 'healthcheck_not_found' call health#report_error('No healthcheck found for "'.name.'" plugin.') + elseif v:exception =~# 'healthcheck_no_return_value' + call health#report_error('The healthcheck report for "'.name.'" plugin is empty.') else call health#report_error(printf( \ "Failed to run healthcheck for \"%s\" plugin. Exception:\n%s\n%s", @@ -127,7 +134,7 @@ endfunction " }}} " From a path return a list [{name}, {func}, {type}] representing a healthcheck function! s:filepath_to_healthcheck(path) abort - if a:path =~# 'vim$' + if a:path =~# 'vim$' let name = matchstr(a:path, '\zs[^\/]*\ze\.vim$') let func = 'health#'.name.'#check' let type = 'v' -- cgit From b9732e555b116e8b6b037d107722ce39add4952f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 9 Feb 2022 13:18:37 +0800 Subject: vim-patch:8.2.4329: no support for end line number and column in 'errorformat' Problem: No support for end line number and column in 'errorformat'. Solution: Add %e and %k. (closes vim/vim#9624) https://github.com/vim/vim/commit/e023d499378942a6c3a3855cbe461ec2cb570f63 Use "\t" to represent a Tab as it looks better. --- runtime/doc/quickfix.txt | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'runtime') diff --git a/runtime/doc/quickfix.txt b/runtime/doc/quickfix.txt index ed736ad4eb..5b68da8be9 100644 --- a/runtime/doc/quickfix.txt +++ b/runtime/doc/quickfix.txt @@ -1339,12 +1339,17 @@ Basic items %f file name (finds a string) %o module name (finds a string) %l line number (finds a number) + %e end line number (finds a number) %c column number (finds a number representing character column of the error, byte index, a is 1 character column) %v virtual column number (finds a number representing screen column of the error (1 == 8 screen columns)) + %k end column number (finds a number representing + the character column of the error, byte index, or a + number representing screen end column of the error if + it's used with %v) %t error type (finds a single character): e - error message w - warning message -- cgit From d9cb3fba9228aed5109a8e6069c50e4f265be9f3 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 9 Feb 2022 14:21:04 +0800 Subject: vim-patch:8.2.4242: put in Visual mode cannot be repeated Problem: Put in Visual mode cannot be repeated. Solution: Use "P" to put without yanking the deleted text into the unnamed register. (Shougo Matsushita, closes vim/vim#9591) https://github.com/vim/vim/commit/fb55207ed17918c8a2a6cadf5ad9d5fcf686a7ab Cherry-pick get_y_previous() and set_y_previous() from patch 8.1.1736. Nvim has removed y_current, so code related to it is N/A. --- runtime/doc/visual.txt | 1 + 1 file changed, 1 insertion(+) (limited to 'runtime') diff --git a/runtime/doc/visual.txt b/runtime/doc/visual.txt index 5563a56216..4d5366a41a 100644 --- a/runtime/doc/visual.txt +++ b/runtime/doc/visual.txt @@ -255,6 +255,7 @@ Additionally the following commands can be used: X delete (2) |v_X| Y yank (2) |v_Y| p put |v_p| + P put without unnamed register overwrite |v_P| J join (1) |v_J| U make uppercase |v_U| u make lowercase |v_u| -- cgit From 196160b1838a462a819bcecb5921b96c2089cb20 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 9 Feb 2022 14:21:04 +0800 Subject: vim-patch:partial:f10911e5db16 Update runtime files https://github.com/vim/vim/commit/f10911e5db16f1fe6ab519c5d091ad0c1df0d063 --- runtime/doc/change.txt | 7 +++++-- runtime/doc/index.txt | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/change.txt b/runtime/doc/change.txt index e26a84f80f..b4d3304880 100644 --- a/runtime/doc/change.txt +++ b/runtime/doc/change.txt @@ -1118,8 +1118,11 @@ register. With blockwise selection it also depends on the size of the block and whether the corners are on an existing character. (Implementation detail: it actually works by first putting the register after the selection and then deleting the selection.) -The previously selected text is put in the unnamed register. If you want to -put the same text into a Visual selection several times you need to use +With 'p' the previously selected text is put in the unnamed register. This is +useful if you want to put that text somewhere else. But you cannot repeat the +same change. +With 'P' the unnamed register is not changed, you can repeat the same change. +But the deleted text cannot be used. If you do need it you can use 'p' with another register. E.g., yank the text to copy, Visually select the text to replace and use "0p . You can repeat this as many times as you like, and the unnamed register will be changed each time. diff --git a/runtime/doc/index.txt b/runtime/doc/index.txt index f02f9f8032..e3bc3d5437 100644 --- a/runtime/doc/index.txt +++ b/runtime/doc/index.txt @@ -923,7 +923,9 @@ tag command note action in Visual mode ~ before the highlighted area |v_J| J 2 join the highlighted lines |v_K| K run 'keywordprg' on the highlighted area -|v_O| O move horizontally to other corner of area. +|v_O| O move horizontally to other corner of area +|v_P| P replace highlighted area with register + contents; unnamed register is unchanged Q does not start Ex mode |v_R| R 2 delete the highlighted lines and start insert -- cgit From aea889fc06f0efb691cab92ebe2e46c52fe259b1 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 10 Feb 2022 07:28:54 +0800 Subject: vim-patch:8.1.2221: cannot filter :disp output Problem: Cannot filter :disp output. Solution: Support filtereing :disp output. (Andi Massimino, closes vim/vim#5117) https://github.com/vim/vim/commit/8fc42964363087025a27e8c80276c706536fc4e3 --- runtime/doc/various.txt | 2 ++ 1 file changed, 2 insertions(+) (limited to 'runtime') diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt index fc0230c62d..38869f8e94 100644 --- a/runtime/doc/various.txt +++ b/runtime/doc/various.txt @@ -388,6 +388,8 @@ g8 Print the hex values of the bytes used in the |:marks| - filter by text in the current file, or file name for other files |:oldfiles| - filter by file name + |:registers| - filter by register contents + (does not work multi-line) |:set| - filter by option name Only normal messages are filtered, error messages are -- cgit From 059d36e326e31fc9bc6055d7c999f86d94fa9bd5 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 11 Feb 2022 12:44:47 +0800 Subject: feat(events): add DirChangedPre In Nvim, like DirChanged, this also triggers when switching windows. This marks Vim patch 8.2.4335 as ported. vim-patch:8.2.4335: no autocommand event triggered before changing directory Problem: No autocommand event triggered before changing directory. (Ronnie Magatti) Solution: Add DirChangedPre. (closes vim/vim#9721) https://github.com/vim/vim/commit/28e8f73ae2d90009fd62cd60f97c2643ba44de68 --- runtime/doc/autocmd.txt | 15 +++++++++++++-- runtime/doc/vim_diff.txt | 3 ++- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt index ed75acf36e..dbe70b84cf 100644 --- a/runtime/doc/autocmd.txt +++ b/runtime/doc/autocmd.txt @@ -525,8 +525,19 @@ DirChanged After the |current-directory| was changed. "global" to trigger on `:cd` "auto" to trigger on 'autochdir'. Sets these |v:event| keys: - cwd: current working directory - scope: "global", "tabpage", "window" + cwd: current working directory + scope: "global", "tabpage", "window" + changed_window: v:true if we fired the event + switching window (or tab) + is set to the new directory name. + Non-recursive (event cannot trigger itself). + *DirChangedPre* +DirChangedPre When the |current-directory| is going to be + changed, as with |DirChanged|. + The pattern is like with |DirChanged|. + Sets these |v:event| keys: + directory: new working directory + scope: "global", "tabpage", "window" changed_window: v:true if we fired the event switching window (or tab) is set to the new directory name. diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index 7892b82137..385ce34d70 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -433,7 +433,8 @@ Vimscript compatibility: `this_session` does not alias to |v:this_session| Working directory (Vim implemented some of these later than Nvim): -- |DirChanged| can be triggered when switching to another window. +- |DirChanged| and |DirChangedPre| can be triggered when switching to another + window or tab. - |getcwd()| and |haslocaldir()| may throw errors if the tab page or window cannot be found. *E5000* *E5001* *E5002* - |haslocaldir()| checks for tab-local directory if and only if -1 is passed as -- cgit From afcf64479c1aa5ea53286853370082507f2721f7 Mon Sep 17 00:00:00 2001 From: kevinhwang91 Date: Fri, 11 Feb 2022 14:42:23 +0800 Subject: fix(query.lua): check empty table for lines The range of node may make `nvim_buf_get_lines` return an empty table. --- runtime/lua/vim/treesitter/query.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'runtime') diff --git a/runtime/lua/vim/treesitter/query.lua b/runtime/lua/vim/treesitter/query.lua index b3036ea679..14940332d6 100644 --- a/runtime/lua/vim/treesitter/query.lua +++ b/runtime/lua/vim/treesitter/query.lua @@ -199,11 +199,13 @@ function M.get_node_text(node, source) lines = a.nvim_buf_get_lines(source, start_row, end_row + 1, true) end - if #lines == 1 then - lines[1] = string.sub(lines[1], start_col+1, end_col) - else - lines[1] = string.sub(lines[1], start_col+1) - lines[#lines] = string.sub(lines[#lines], 1, end_col) + if #lines > 0 then + if #lines == 1 then + lines[1] = string.sub(lines[1], start_col+1, end_col) + else + lines[1] = string.sub(lines[1], start_col+1) + lines[#lines] = string.sub(lines[#lines], 1, end_col) + end end return table.concat(lines, "\n") -- cgit From f6329ea137730e571671ee31309ec1b7dc6ec85e Mon Sep 17 00:00:00 2001 From: Lajos Koszti Date: Fri, 11 Feb 2022 14:04:15 +0100 Subject: fix(lsp): correct prefix when filterText is present (#17051) LSP server might return an item which would replace a token to another. For example in typescript for a `jest.Mock` object `getProductsMock.` text I get the following response: ``` { commitCharacters = { ".", ",", "(" }, data = { entryNames = { "Symbol" }, file = "/foo/bar/baz.service.spec.ts", line = 268, offset = 17 }, filterText = ".Symbol", kind = 6, label = "Symbol", sortText = "11", textEdit = { newText = "[Symbol]", range = { end = { character = 16, line = 267 }, start = { character = 15, line = 267 } } } }, ``` In `lsp.omnifunc` to get a `prefix` we call the `adjust_start_col` which then returns the `textEdit.range.start.character`. Th `prefix` then be the `.` character. Then when filter the items with `remove_unmatch_completion_items`, every item will be filtered out, since no completion word starts `.`. To fix we return the `end.character`, which in that particular case will be the position after the `.`. --- runtime/lua/vim/lsp.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua index 37e222a5ce..8d11b4621c 100644 --- a/runtime/lua/vim/lsp.lua +++ b/runtime/lua/vim/lsp.lua @@ -1598,7 +1598,7 @@ end local function adjust_start_col(lnum, line, items, encoding) local min_start_char = nil for _, item in pairs(items) do - if item.textEdit and item.textEdit.range.start.line == lnum - 1 then + if item.filterText == nil and item.textEdit and item.textEdit.range.start.line == lnum - 1 then if min_start_char and min_start_char ~= item.textEdit.range.start.character then return nil end -- cgit From 8090753880697451a4d18777d9f258d234811747 Mon Sep 17 00:00:00 2001 From: glacambre Date: Tue, 8 Feb 2022 06:08:25 +0100 Subject: docs(stdioopen): add missing documentation for on_print param This commit adds documentation for the feature introduced in #15910. --- runtime/doc/builtin.txt | 3 +++ 1 file changed, 3 insertions(+) (limited to 'runtime') diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 9bf37a3759..0fcf01aadc 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -7412,6 +7412,9 @@ stdioopen({opts}) *stdioopen()* {opts} is a dictionary with these keys: |on_stdin| : callback invoked when stdin is written to. + on_print : callback invoked when Nvim needs to print a + message, with the message (whose type is string) + as sole argument. stdin_buffered : read stdin in |channel-buffered| mode. rpc : If set, |msgpack-rpc| will be used to communicate over stdio -- cgit From 3b13c7fc8b15d2ab90c070131c0268711fcf4f10 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sat, 12 Feb 2022 12:03:02 +0100 Subject: vim-patch:8.2.4352: ReScript files are not recognized Problem: ReScript files are not recognized. Solution: Add the *.res and *.resi patterns. (Ananda Umamil, closes vim/vim#9752) https://github.com/vim/vim/commit/0c3cc2fec31521b0697edc406f85b7a43e979860 --- runtime/filetype.vim | 3 +++ runtime/lua/vim/filetype.lua | 2 ++ 2 files changed, 5 insertions(+) (limited to 'runtime') diff --git a/runtime/filetype.vim b/runtime/filetype.vim index 8b40b43a04..35f4b25120 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -1543,6 +1543,9 @@ au BufNewFile,BufRead *.r,*.R call dist#ft#FTr() " Remind au BufNewFile,BufRead .reminders,*.remind,*.rem setf remind +" ReScript +au BufNewFile,BufRead *.res,*.resi setf rescript + " Resolv.conf au BufNewFile,BufRead resolv.conf setf resolv diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index e2cf408f3b..2fe4aa3d32 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -514,6 +514,8 @@ local extension = { rego = "rego", rem = "remind", remind = "remind", + res = "rescript", + resi = "rescript", frt = "reva", testUnit = "rexx", rex = "rexx", -- cgit From cdb2c100118ab788772a6a0a1d60f555370fd201 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Tue, 1 Feb 2022 12:44:14 +0000 Subject: vim-patch:8.2.0915: search() cannot skip over matches like searchpair() can Problem: Search() cannot skip over matches like searchpair() can. Solution: Add an optional "skip" argument. (Christian Brabandt, closes vim/vim#861) https://github.com/vim/vim/commit/adc17a5f9d207fd1623fd923457a46efc9214777 Enable skip arg usage in autoload/freebasic.vim evalarg_T doesn't really matter because it's deleted in v8.2.0918 (and reincarnated for Vim9 script in v8.2.1047), but I found out too late :P Anyway: - Port evalarg_T into eval.h and use const char * and Callback fields - Use EVALARG_INIT to initialize - Return bool over OK/FAIL from evalarg functions - Remove check from evalarg_clean as callback_free ignores None callbacks anyway - Move eva_buf field into evalarg_get as a local (not sure what reason it has being in the struct) N/A patches for version.c: vim-patch:8.2.4355: unnecessary call to check_colorcolumn() Problem: Unnecessary call to check_colorcolumn(). Solution: Remove the call. (Sean Dewar, closes vim/vim#9748) https://github.com/vim/vim/commit/0f7ff851cb721bb3c07261adbf82b591229f530d --- runtime/autoload/freebasic.vim | 3 +-- runtime/doc/builtin.txt | 21 ++++++++++++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) (limited to 'runtime') diff --git a/runtime/autoload/freebasic.vim b/runtime/autoload/freebasic.vim index fe6d2745be..428cf1382b 100644 --- a/runtime/autoload/freebasic.vim +++ b/runtime/autoload/freebasic.vim @@ -23,8 +23,7 @@ function! freebasic#GetDialect() abort let save_cursor = getcurpos() call cursor(1, 1) - " let lnum = search(pat, 'n', '', '', skip) " 'skip' needs 8.2.0915 - let lnum = search(pat, 'n', '', '') + let lnum = search(pat, 'n', '', '', skip) call setpos('.', save_cursor) if lnum diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index f371ad92cc..35a232c0c2 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -380,7 +380,7 @@ screencol() Number current cursor column screenpos({winid}, {lnum}, {col}) Dict screen row and col of a text character screenrow() Number current cursor row screenstring({row}, {col}) String characters at screen position -search({pattern} [, {flags} [, {stopline} [, {timeout}]]]) +search({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]]) Number search for {pattern} searchcount([{options}]) Dict Get or update the last search count searchdecl({name} [, {global} [, {thisblock}]]) @@ -389,7 +389,7 @@ searchpair({start}, {middle}, {end} [, {flags} [, {skip} [...]]]) Number search for other end of start/end pair searchpairpos({start}, {middle}, {end} [, {flags} [, {skip} [...]]]) List search for other end of start/end pair -searchpos({pattern} [, {flags} [, {stopline} [, {timeout}]]]) +searchpos({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]]) List search for {pattern} server2client({clientid}, {string}) Number send reply string @@ -6169,8 +6169,9 @@ screenstring({row}, {col}) *screenstring()* Can also be used as a |method|: > GetRow()->screenstring(col) - -search({pattern} [, {flags} [, {stopline} [, {timeout}]]]) *search()* +< + *search()* +search({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]]) Search for regexp pattern {pattern}. The search starts at the cursor position (you can use |cursor()| to set it). @@ -6222,6 +6223,15 @@ search({pattern} [, {flags} [, {stopline} [, {timeout}]]]) *search()* The value must not be negative. A zero value is like not giving the argument. + If the {skip} expression is given it is evaluated with the + cursor positioned on the start of a match. If it evaluates to + non-zero this match is skipped. This can be used, for + example, to skip a match in a comment or a string. + {skip} can be a string, which is evaluated as an expression, a + function reference or a lambda. + When {skip} is omitted or empty, every match is accepted. + When evaluating {skip} causes an error the search is aborted + and -1 returned. *search()-sub-match* With the 'p' flag the returned value is one more than the first sub-match in \(\). One if none of them matched but the @@ -6505,7 +6515,8 @@ searchpairpos({start}, {middle}, {end} [, {flags} [, {skip} < See |match-parens| for a bigger and more useful example. -searchpos({pattern} [, {flags} [, {stopline} [, {timeout}]]]) *searchpos()* + *searchpos()* +searchpos({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]]) Same as |search()|, but returns a |List| with the line and column position of the match. The first element of the |List| is the line number and the second element is the byte index of -- cgit From e4819017480c801c07619bfe740cc934e2f4c85b Mon Sep 17 00:00:00 2001 From: Chinmay Dalal Date: Sun, 13 Feb 2022 19:13:25 +0530 Subject: docs: treesitter.txt - fix overflowing lines, document minimum_language_version (#17286) --- runtime/doc/treesitter.txt | 132 +++++++++++++++------------- runtime/lua/vim/treesitter/languagetree.lua | 28 +++--- runtime/lua/vim/treesitter/query.lua | 4 +- 3 files changed, 90 insertions(+), 74 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt index 5829dbdd6b..dbd8ec6fef 100644 --- a/runtime/doc/treesitter.txt +++ b/runtime/doc/treesitter.txt @@ -14,10 +14,12 @@ VIM.TREESITTER *lua-treesitter* Nvim integrates the tree-sitter library for incremental parsing of buffers. *vim.treesitter.language_version* -To check which language version is compiled with neovim, the number is stored -within `vim.treesitter.language_version`. This number is not too helpful -unless you are wondering about compatibility between different versions of -compiled grammars. +The latest parser ABI version that is supported by the bundled tree-sitter +library. + + *vim.treesitter.minimum_language_version* +The earliest parser ABI version that is supported by the bundled tree-sitter +library. Parser files *treesitter-parsers* @@ -49,10 +51,10 @@ Whenever you need to access the current syntax tree, parse the buffer: > tstree = parser:parse() - + language injection. {region_list} should be of the form + (all zero-based): > { {node1, node2}, ... @@ -92,13 +95,13 @@ tsnode:next_sibling() *tsnode:next_sibling()* tsnode:prev_sibling() *tsnode:prev_sibling()* Get the node's previous sibling. -tsnode:next_named_sibling() *tsnode:next_named_sibling()* +tsnode:next_named_sibling() *tsnode:next_named_sibling()* Get the node's next named sibling. -tsnode:prev_named_sibling() *tsnode:prev_named_sibling()* +tsnode:prev_named_sibling() *tsnode:prev_named_sibling()* Get the node's previous named sibling. -tsnode:iter_children() *tsnode:iter_children()* +tsnode:iter_children() *tsnode:iter_children()* Iterates over all the direct children of {tsnode}, regardless of whether they are named or not. Returns the child node plus the eventual field name corresponding to @@ -114,10 +117,10 @@ tsnode:child({index}) *tsnode:child()* Get the node's child at the given {index}, where zero represents the first child. -tsnode:named_child_count() *tsnode:named_child_count()* +tsnode:named_child_count() *tsnode:named_child_count()* Get the node's number of named children. -tsnode:named_child({index}) *tsnode:named_child()* +tsnode:named_child({index}) *tsnode:named_child()* Get the node's named child at the given {index}, where zero represents the first named child. @@ -157,20 +160,20 @@ tsnode:sexpr() *tsnode:sexpr()* tsnode:id() *tsnode:id()* Get an unique identifier for the node inside its own tree. - No guarantees are made about this identifier's internal representation, - except for being a primitive lua type with value equality (so not a table). - Presently it is a (non-printable) string. + No guarantees are made about this identifier's internal + representation, except for being a primitive lua type with value + equality (so not a table). Presently it is a (non-printable) string. Note: the id is not guaranteed to be unique for nodes from different trees. + *tsnode:descendant_for_range()* tsnode:descendant_for_range({start_row}, {start_col}, {end_row}, {end_col}) - *tsnode:descendant_for_range()* Get the smallest node within this node that spans the given range of (row, column) positions + *tsnode:named_descendant_for_range()* tsnode:named_descendant_for_range({start_row}, {start_col}, {end_row}, {end_col}) - *tsnode:named_descendant_for_range()* Get the smallest named node within this node that spans the given range of (row, column) positions @@ -192,11 +195,11 @@ and predicates. A `capture` allows you to associate names with a specific node in a pattern. A `predicate` adds arbitrary metadata and conditional data to a match. -Treesitter Query Predicates *lua-treesitter-predicates* +Treesitter Query Predicates *lua-treesitter-predicates* When writing queries for treesitter, one might use `predicates`, that is, -special scheme nodes that are evaluated to verify things on a captured node for -example, the |eq?| predicate : > +special scheme nodes that are evaluated to verify things on a captured node +for example, the |eq?| predicate : > ((identifier) @foo (#eq? @foo "foo")) This will only match identifier corresponding to the `"foo"` text. @@ -209,24 +212,24 @@ Here is a list of built-in predicates : ((node1) @left (node2) @right (#eq? @left @right)) < `match?` *ts-predicate-match?* - `vim-match?` *ts-predicate-vim-match?* + `vim-match?` *ts-predicate-vim-match?* This will match if the provided vim regex matches the text corresponding to a node : > ((identifier) @constant (#match? @constant "^[A-Z_]+$")) < Note: the `^` and `$` anchors will respectively match the start and end of the node's text. - `lua-match?` *ts-predicate-lua-match?* + `lua-match?` *ts-predicate-lua-match?* This will match the same way than |match?| but using lua regexes. - `contains?` *ts-predicate-contains?* + `contains?` *ts-predicate-contains?* Will check if any of the following arguments appears in the text corresponding to the node : > ((identifier) @foo (#contains? @foo "foo")) ((identifier) @foo-bar (#contains @foo-bar "foo" "bar")) < - `any-of?` *ts-predicate-any-of?* + `any-of?` *ts-predicate-any-of?* Will check if the text is the same as any of the following. This is the recommended way to check if the node matches one of many keywords for example, as it has been optimized for @@ -234,27 +237,27 @@ Here is a list of built-in predicates : arguments : > ((identifier) @foo (#any-of? @foo "foo" "bar")) < - *lua-treesitter-not-predicate* + *lua-treesitter-not-predicate* Each predicate has a `not-` prefixed predicate that is just the negation of the predicate. - *vim.treesitter.query.add_predicate()* + *vim.treesitter.query.add_predicate()* vim.treesitter.query.add_predicate({name}, {handler}) This adds a predicate with the name {name} to be used in queries. {handler} should be a function whose signature will be : > handler(match, pattern, bufnr, predicate) < - *vim.treesitter.query.list_predicates()* + *vim.treesitter.query.list_predicates()* vim.treesitter.query.list_predicates() This lists the currently available predicates to use in queries. -Treesitter Query Directive *lua-treesitter-directives* +Treesitter Query Directive *lua-treesitter-directives* -Treesitter queries can also contain `directives`. Directives store metadata for a node -or match and perform side effects. For example, the |set!| predicate sets metadata on -the match or node : > +Treesitter queries can also contain `directives`. Directives store metadata +for a node or match and perform side effects. For example, the |set!| +predicate sets metadata on the match or node : > ((identifier) @foo (#set! "type" "parameter")) Here is a list of built-in directives: @@ -268,8 +271,8 @@ Here is a list of built-in directives: Takes the range of the captured node and applies the offsets to it's range : > ((identifier) @constant (#offset! @constant 0 1 0 -1)) -< This will generate a range object for the captured node with the - offsets applied. The arguments are +< This will generate a range object for the captured node with + the offsets applied. The arguments are `({capture_id}, {start_row}, {start_col}, {end_row}, {end_col}, {key?})` The default key is "offset". @@ -279,25 +282,25 @@ vim.treesitter.query.add_directive({name}, {handler}) This adds a directive with the name {name} to be used in queries. {handler} should be a function whose signature will be : > handler(match, pattern, bufnr, predicate, metadata) -Handlers can set match level data by setting directly on the metadata object `metadata.key = value` -Handlers can set node level data by using the capture id on the metadata table -`metadata[capture_id].key = value` +Handlers can set match level data by setting directly on the metadata object +`metadata.key = value` Handlers can set node level data by using the capture +id on the metadata table `metadata[capture_id].key = value` *vim.treesitter.query.list_directives()* vim.treesitter.query.list_directives() This lists the currently available directives to use in queries. -Treesitter syntax highlighting (WIP) *lua-treesitter-highlight* +Treesitter syntax highlighting (WIP) *lua-treesitter-highlight* NOTE: This is a partially implemented feature, and not usable as a default solution yet. What is documented here is a temporary interface intended for those who want to experiment with this feature and contribute to its development. -Highlights are defined in the same query format as in the tree-sitter highlight -crate, with some limitations and additions. Set a highlight query for a -buffer with this code: > +Highlights are defined in the same query format as in the tree-sitter +highlight crate, with some limitations and additions. Set a highlight query +for a buffer with this code: > local query = [[ "for" @keyword @@ -338,7 +341,8 @@ Treesitter Highlighting Priority *lua-treesitter-highlight-priority* Tree-sitter uses |nvim_buf_set_extmark()| to set highlights with a default priority of 100. This enables plugins to set a highlighting priority lower or higher than tree-sitter. It is also possible to change the priority of an -individual query pattern manually by setting its `"priority"` metadata attribute: > +individual query pattern manually by setting its `"priority"` metadata +attribute: > ( (super_important_node) @ImportantHighlight @@ -461,7 +465,7 @@ parse_query({lang}, {query}) *parse_query()* can be used to search nodes in the syntax tree for the patterns defined in {query} using `iter_*` methods below. - Exposes `info` and `captures` with additional information about the {query}. + Exposes `info` and `captures` with additional context about {query}. • `captures` contains the list of unique capture names defined in {query}. - `info.captures` also points to `captures` . • `info.patterns` contains information about predicates. @@ -609,10 +613,9 @@ LanguageTree:children({self}) *LanguageTree:children()* {self} LanguageTree:contains({self}, {range}) *LanguageTree:contains()* - Determines whether This goes down the tree to recursively check children. + Determines whether {range} is contained in this language tree - Parameters: ~ - {range} is contained in this language tree + This goes down the tree to recursively check children. Parameters: ~ {range} A range, that is a `{ start_line, start_col, @@ -622,8 +625,9 @@ LanguageTree:contains({self}, {range}) *LanguageTree:contains()* LanguageTree:destroy({self}) *LanguageTree:destroy()* Destroys this language tree and all its children. - Any cleanup logic should be performed here. Note, this DOES - NOT remove this tree from a parent. `remove_child` must be called on the parent to remove it. + Any cleanup logic should be performed here. + + Note: This DOES NOT remove this tree from a parent. Instead, `remove_child` must be called on the parent to remove it. Parameters: ~ {self} @@ -666,7 +670,8 @@ LanguageTree:invalidate({self}, {reload}) *LanguageTree:invalidate()* {self} LanguageTree:is_valid({self}) *LanguageTree:is_valid()* - Determines whether this tree is valid. If the tree is invalid, `parse()` must be called to get the updated tree. + Determines whether this tree is valid. If the tree is invalid, + call `parse()` . This will return the updated tree. Parameters: ~ {self} @@ -679,7 +684,7 @@ LanguageTree:lang({self}) *LanguageTree:lang()* *LanguageTree:language_for_range()* LanguageTree:language_for_range({self}, {range}) - Gets the appropriate language that contains + Gets the appropriate language that contains {range} Parameters: ~ {range} A text range, see |LanguageTree:contains| @@ -695,13 +700,22 @@ LanguageTree:parse({self}) *LanguageTree:parse()* {self} LanguageTree:register_cbs({self}, {cbs}) *LanguageTree:register_cbs()* - Registers callbacks for the parser - - Parameters: ~ - {cbs} An `nvim_buf_attach` -like table argument with the following keys : `on_bytes` : see `nvim_buf_attach` , but this will be called after the parsers callback. `on_changedtree` : a callback that will be called every time the - tree has syntactical changes. it will only be - passed one argument, that is a table of the ranges - (as node ranges) that changed. `on_child_added` : emitted when a child is added to the tree. `on_child_removed` : emitted when a child is removed from the tree. + Registers callbacks for the parser. + + Parameters: ~ + {cbs} table An |nvim_buf_attach()|-like table argument + with the following keys : + • `on_bytes` : see |nvim_buf_attach()|, but this will be + called after the parsers callback. + • `on_changedtree` : a callback that will be + called every time the tree has syntactical + changes. It will only be passed one argument, + which is a table of the ranges (as node ranges) + that changed. + • `on_child_added` : emitted when a child is added + to the tree. + • `on_child_removed` : emitted when a child is + removed from the tree. {self} LanguageTree:remove_child({self}, {lang}) *LanguageTree:remove_child()* diff --git a/runtime/lua/vim/treesitter/languagetree.lua b/runtime/lua/vim/treesitter/languagetree.lua index 85fd5cd8e0..b83df65151 100644 --- a/runtime/lua/vim/treesitter/languagetree.lua +++ b/runtime/lua/vim/treesitter/languagetree.lua @@ -76,8 +76,8 @@ function LanguageTree:lang() end --- Determines whether this tree is valid. ---- If the tree is invalid, `parse()` must be called ---- to get the updated tree. +--- If the tree is invalid, call `parse()`. +--- This will return the updated tree. function LanguageTree:is_valid() return self._valid end @@ -234,7 +234,9 @@ end --- Destroys this language tree and all its children. --- --- Any cleanup logic should be performed here. ---- Note, this DOES NOT remove this tree from a parent. +--- +--- Note: +--- This DOES NOT remove this tree from a parent. Instead, --- `remove_child` must be called on the parent to remove it. function LanguageTree:destroy() -- Cleanup here @@ -448,14 +450,14 @@ function LanguageTree:_on_detach(...) self:_do_callback('detach', ...) end ---- Registers callbacks for the parser ----@param cbs An `nvim_buf_attach`-like table argument with the following keys : ---- `on_bytes` : see `nvim_buf_attach`, but this will be called _after_ the parsers callback. ---- `on_changedtree` : a callback that will be called every time the tree has syntactical changes. ---- it will only be passed one argument, that is a table of the ranges (as node ranges) that ---- changed. ---- `on_child_added` : emitted when a child is added to the tree. ---- `on_child_removed` : emitted when a child is removed from the tree. +--- Registers callbacks for the parser. +---@param cbs table An |nvim_buf_attach()|-like table argument with the following keys : +--- - `on_bytes` : see |nvim_buf_attach()|, but this will be called _after_ the parsers callback. +--- - `on_changedtree` : a callback that will be called every time the tree has syntactical changes. +--- It will only be passed one argument, which is a table of the ranges (as node ranges) that +--- changed. +--- - `on_child_added` : emitted when a child is added to the tree. +--- - `on_child_removed` : emitted when a child is removed from the tree. function LanguageTree:register_cbs(cbs) if not cbs then return end @@ -493,7 +495,7 @@ local function tree_contains(tree, range) return false end ---- Determines whether @param range is contained in this language tree +--- Determines whether {range} is contained in this language tree --- --- This goes down the tree to recursively check children. --- @@ -508,7 +510,7 @@ function LanguageTree:contains(range) return false end ---- Gets the appropriate language that contains @param range +--- Gets the appropriate language that contains {range} --- ---@param range A text range, see |LanguageTree:contains| function LanguageTree:language_for_range(range) diff --git a/runtime/lua/vim/treesitter/query.lua b/runtime/lua/vim/treesitter/query.lua index 14940332d6..8383551b5f 100644 --- a/runtime/lua/vim/treesitter/query.lua +++ b/runtime/lua/vim/treesitter/query.lua @@ -146,13 +146,13 @@ local query_cache = setmetatable({}, { }) --- Parse {query} as a string. (If the query is in a file, the caller ---- should read the contents into a string before calling). +--- should read the contents into a string before calling). --- --- Returns a `Query` (see |lua-treesitter-query|) object which can be used to --- search nodes in the syntax tree for the patterns defined in {query} --- using `iter_*` methods below. --- ---- Exposes `info` and `captures` with additional information about the {query}. +--- Exposes `info` and `captures` with additional context about {query}. --- - `captures` contains the list of unique capture names defined in --- {query}. --- -` info.captures` also points to `captures`. -- cgit From 45e666fb92222c0cdd1892e1853f209a4b847d06 Mon Sep 17 00:00:00 2001 From: marvim Date: Sun, 13 Feb 2022 13:44:51 +0000 Subject: docs: regenerate [skip ci] --- runtime/doc/api.txt | 27 ++++++++++++++------------- runtime/doc/lsp.txt | 4 ++-- runtime/doc/lua.txt | 23 +++++++++++++++++++++++ 3 files changed, 39 insertions(+), 15 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index 7bae5bb94b..7a5aeee603 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -855,7 +855,7 @@ nvim_exec_lua({code}, {args}) *nvim_exec_lua()* Return: ~ Return value of Lua code if present or NIL. -nvim_feedkeys({keys}, {mode}, {escape_csi}) *nvim_feedkeys()* +nvim_feedkeys({keys}, {mode}, {escape_ks}) *nvim_feedkeys()* Sends input-keys to Nvim, subject to various quirks controlled by `mode` flags. This is a blocking call, unlike |nvim_input()|. @@ -863,23 +863,25 @@ nvim_feedkeys({keys}, {mode}, {escape_csi}) *nvim_feedkeys()* On execution error: does not fail, but updates v:errmsg. To input sequences like use |nvim_replace_termcodes()| - (typically with escape_csi=true) to replace |keycodes|, then + (typically with escape_ks=false) to replace |keycodes|, then pass the result to nvim_feedkeys(). Example: > :let key = nvim_replace_termcodes("", v:true, v:false, v:true) - :call nvim_feedkeys(key, 'n', v:true) + :call nvim_feedkeys(key, 'n', v:false) < Parameters: ~ - {keys} to be typed - {mode} behavior flags, see |feedkeys()| - {escape_csi} If true, escape K_SPECIAL/CSI bytes in - `keys` + {keys} to be typed + {mode} behavior flags, see |feedkeys()| + {escape_ks} If true, escape K_SPECIAL bytes in `keys` + This should be false if you already used + |nvim_replace_termcodes()|, and true + otherwise. See also: ~ feedkeys() - vim_strsave_escape_csi + vim_strsave_escape_ks nvim_get_all_options_info() *nvim_get_all_options_info()* Gets the option information for all options. @@ -1538,14 +1540,13 @@ nvim_set_current_win({window}) *nvim_set_current_win()* Parameters: ~ {window} Window handle -nvim_set_hl({ns_id}, {name}, {val}) *nvim_set_hl()* +nvim_set_hl({ns_id}, {name}, {*val}) *nvim_set_hl()* Set a highlight group. - TODO: ns_id = 0, should modify :highlight namespace TODO val - should take update vs reset flag - Parameters: ~ - {ns_id} number of namespace for this highlight + {ns_id} number of namespace for this highlight. Use value + 0 to set a highlight group in the global ( + `:highlight` ) namespace. {name} highlight group name, like ErrorMsg {val} highlight definition map, like |nvim_get_hl_by_name|. in addition the following diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt index f6fcbe8fb9..d717759444 100644 --- a/runtime/doc/lsp.txt +++ b/runtime/doc/lsp.txt @@ -1225,8 +1225,8 @@ on_publish_diagnostics({_}, {result}, {ctx}, {config}) }, -- Use a function to dynamically turn signs off -- and on, using buffer local variables - signs = function(bufnr, client_id) - return vim.bo[bufnr].show_signs == false + signs = function(namespace, bufnr) + return vim.b[bufnr].show_signs == true end, -- Disable a feature update_in_insert = false, diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index 77f1dad6c7..1a2d845281 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -1763,6 +1763,13 @@ Lua module: ui *lua-ui* input({opts}, {on_confirm}) *vim.ui.input()* Prompts the user for input + Example: > + + vim.ui.input({ prompt = 'Enter value for shiftwidth: ' }, function(input) + vim.o.shiftwidth = tonumber(input) + end) +< + Parameters: ~ {opts} table Additional options. See |input()| • prompt (string|nil) Text of the prompt. @@ -1786,6 +1793,22 @@ select({items}, {opts}, {on_choice}) *vim.ui.select()* Prompts the user to pick a single item from a collection of entries + Example: > + + vim.ui.select({ 'tabs', 'spaces' }, { + prompt = 'Select tabs or spaces:', + format_item = function(item) + return "I'd like to choose " .. item + end, + }, function(choice) + if choice == 'spaces' then + vim.o.expandtab = true + else + vim.o.expandtab = false + end + end) +< + Parameters: ~ {items} table Arbitrary items {opts} table Additional options -- cgit From 5220891571a799fd630cbcbe836d1f9e3d2dc1fa Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 14 Feb 2022 11:35:25 +0800 Subject: vim-patch:8.2.4343: when reloading not all properties are detected Problem: When reloading not all properties are detected. Solution: Add the "edit" value to v:fcs_choice. (Rob Pilling, closes vim/vim#9579) https://github.com/vim/vim/commit/8196e94a8b72ed8618605cb66615571313097d78 Cherry-pick some test changes from patch 8.1.1826. --- runtime/doc/editing.txt | 5 +++++ runtime/doc/eval.txt | 5 +++++ 2 files changed, 10 insertions(+) (limited to 'runtime') diff --git a/runtime/doc/editing.txt b/runtime/doc/editing.txt index 3d0287b0cd..8ddc661c0e 100644 --- a/runtime/doc/editing.txt +++ b/runtime/doc/editing.txt @@ -1450,6 +1450,11 @@ If you don't get warned often enough you can use the following command. if it exists now. Once a file has been checked the timestamp is reset, you will not be warned again. + Syntax highlighting, marks, diff status, + 'fileencoding', 'fileformat' and 'binary' options + are not changed. See |v:fcs_choice| to reload these + too (for example, if a code formatting tools has + changed the file). :[N]checkt[ime] {filename} :[N]checkt[ime] [N] diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index fc788fba59..fc422f13e5 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1882,6 +1882,11 @@ v:fcs_choice What should happen after a |FileChangedShell| event was do with the affected buffer: reload Reload the buffer (does not work if the file was deleted). + edit Reload the buffer and detect the + values for options such as + 'fileformat', 'fileencoding', 'binary' + (does not work if the file was + deleted). ask Ask the user what to do, as if there was no autocommand. Except that when only the timestamp changed nothing -- cgit From 9a74c2b04ac8f54a17925a437b5a2f03b18f6281 Mon Sep 17 00:00:00 2001 From: Shadman <13149513+shadmansaleh@users.noreply.github.com> Date: Wed, 16 Feb 2022 14:39:50 +0600 Subject: feat(mappings): considering map description when filtering (#17423) --- runtime/doc/map.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt index 2d2795b1ca..89df42600c 100644 --- a/runtime/doc/map.txt +++ b/runtime/doc/map.txt @@ -502,7 +502,7 @@ Note: When using mappings for Visual mode, you can use the "'<" mark, which is the start of the last selected Visual area in the current buffer |'<|. The |:filter| command can be used to select what mappings to list. The -pattern is matched against the {lhs} and {rhs} in the raw form. +pattern is matched against the {lhs}, {rhs} and {desc} in the raw form. *:map-verbose* When 'verbose' is non-zero, listing a key map will also display where it was -- cgit From cc81a8253be032aa12f05730e8a2f1b5d94fd08c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 16 Feb 2022 16:58:32 +0800 Subject: docs: minor changes related to mapping description --- runtime/doc/api.txt | 2 +- runtime/doc/map.txt | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index 7a5aeee603..1e1534c31f 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -1584,7 +1584,7 @@ nvim_set_keymap({mode}, {lhs}, {rhs}, {*opts}) *nvim_set_keymap()* {rhs} Right-hand-side |{rhs}| of the mapping. {opts} Optional parameters map. Accepts all |:map-arguments| as keys excluding || but - including |noremap| and "desc". |desc| can be used + including |noremap| and "desc". "desc" can be used to give a description to keymap. When called from Lua, also accepts a "callback" key that takes a Lua function to call when the mapping is executed. diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt index 89df42600c..358e944261 100644 --- a/runtime/doc/map.txt +++ b/runtime/doc/map.txt @@ -502,7 +502,9 @@ Note: When using mappings for Visual mode, you can use the "'<" mark, which is the start of the last selected Visual area in the current buffer |'<|. The |:filter| command can be used to select what mappings to list. The -pattern is matched against the {lhs}, {rhs} and {desc} in the raw form. +pattern is matched against the {lhs} and {rhs} in the raw form. If a +description was added using |nvim_set_keymap()| or |nvim_buf_set_keymap()| +then the pattern is also matched against it. *:map-verbose* When 'verbose' is non-zero, listing a key map will also display where it was -- cgit From 8ab5ec4aaaeed27b1d8086d395171a52568378c2 Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Wed, 16 Feb 2022 19:38:19 +0100 Subject: feat(tree-sitter): allow Atom-style capture fallbacks (#14196) This allows falling back to `@definition` when we have no mapping `@definition.fancy-specialization`. This behavior is described in tree-sitter's documentation (https://tree-sitter.github.io/tree-sitter/syntax-highlighting#theme). Fixes https://github.com/nvim-treesitter/nvim-treesitter/issues/738 --- runtime/lua/vim/treesitter/highlighter.lua | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/lua/vim/treesitter/highlighter.lua b/runtime/lua/vim/treesitter/highlighter.lua index 22b528838c..b6f61cfb2e 100644 --- a/runtime/lua/vim/treesitter/highlighter.lua +++ b/runtime/lua/vim/treesitter/highlighter.lua @@ -22,7 +22,21 @@ local _link_default_highlight_once = function(from, to) return from end -TSHighlighter.hl_map = { +-- If @definition.special does not exist use @definition instead +local subcapture_fallback = { + __index = function(self, capture) + local rtn + local shortened = capture + while not rtn and shortened do + shortened = shortened:match('(.*)%.') + rtn = shortened and rawget(self, shortened) + end + rawset(self, capture, rtn or "__notfound") + return rtn + end +} + +TSHighlighter.hl_map = setmetatable({ ["error"] = "Error", -- Miscs @@ -66,7 +80,7 @@ TSHighlighter.hl_map = { ["type.builtin"] = "Type", ["structure"] = "Structure", ["include"] = "Include", -} +}, subcapture_fallback) ---@private local function is_highlight_name(capture_name) -- cgit From b149665689f84ee7297ab5ce8a8eb59b12611af1 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Wed, 16 Feb 2022 21:23:08 +0000 Subject: vim-patch:8.2.3573: cannot decide whether to skip test that fails with 64 bit Problem: Cannot decide whether to skip test that fails with 64 bit ints. (closes vim/vim#9072) Solution: Add v:sizeofint, v:sizeoflong and v:sizeofpointer. Improve the check for multiply overflow. https://github.com/vim/vim/commit/69b3072d984480935ec412b32b97fea974d2b689 Omit v:sizeof{int,long,pointer} as they're only really used for tests. --- runtime/doc/vim_diff.txt | 3 +++ 1 file changed, 3 insertions(+) (limited to 'runtime') diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index 385ce34d70..5ea6a9c5dd 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -494,6 +494,9 @@ Eval: *js_encode()* *js_decode()* *v:none* (used by Vim to represent JavaScript "undefined"); use |v:null| instead. + *v:sizeofint* + *v:sizeoflong* + *v:sizeofpointer* Events: *SigUSR1* Use |Signal| to detect `SIGUSR1` signal instead. -- cgit From 1fd106ca88a606241e1e1fb8c73645dcea5ea5c8 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Thu, 17 Feb 2022 23:05:48 +0100 Subject: vim-patch:8.2.4411: bicep files are not recognized (#17447) Problem: Bicep files are not recognized. Solution: Match *.bicep files. (Dundar Goc, closes vim/vim#9791) https://github.com/vim/vim/commit/8e5ba693ad9377fbf4b047093624248b81eac854 --- runtime/filetype.vim | 7 +++++-- runtime/lua/vim/filetype.lua | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/filetype.vim b/runtime/filetype.vim index 35f4b25120..60be03d708 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -44,7 +44,7 @@ endif " file name matches ft_ignore_pat. " When using this, the entry should probably be further down below with the " other StarSetf() calls. -func! s:StarSetf(ft) +func s:StarSetf(ft) if expand("") !~ g:ft_ignore_pat exe 'setf ' . a:ft endif @@ -225,6 +225,9 @@ au BufNewFile,BufRead *.bib setf bib " BibTeX Bibliography Style au BufNewFile,BufRead *.bst setf bst +" Bicep +au BufNewFile,BufRead *.bicep setf bicep + " BIND configuration " sudoedit uses namedXXXX.conf au BufNewFile,BufRead named*.conf,rndc*.conf,rndc*.key setf named @@ -2517,7 +2520,7 @@ endif " Function called for testing all functions defined here. These are " script-local, thus need to be executed here. " Returns a string with error messages (hopefully empty). -func! TestFiletypeFuncs(testlist) +func TestFiletypeFuncs(testlist) let output = '' for f in a:testlist try diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index 2fe4aa3d32..399e1c7f60 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -65,6 +65,7 @@ local extension = { bdf = "bdf", beancount = "beancount", bib = "bib", + bicep = "bicep", bl = "blank", bsdl = "bsdl", bst = "bst", -- cgit From 36362ef0aed92e726d967d30e3c6cd87c65642b3 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Fri, 18 Feb 2022 17:08:43 +0100 Subject: vim-patch:8.2.4414: solidity files are not recognized (#17451) Problem: Solidity files are not recognized. Solution: Add the *.sol pattern. (Dundar Goc, closes vim/vim#9792) https://github.com/vim/vim/commit/97b231541d4e82fbc85e51121448d95bd43c50ad --- runtime/filetype.vim | 3 +++ runtime/lua/vim/filetype.lua | 1 + 2 files changed, 4 insertions(+) (limited to 'runtime') diff --git a/runtime/filetype.vim b/runtime/filetype.vim index 60be03d708..c7955d74ee 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -1791,6 +1791,9 @@ au BufNewFile,BufRead *.mib,*.my setf mib au BufNewFile,BufRead *.hog,snort.conf,vision.conf setf hog au BufNewFile,BufRead *.rules call dist#ft#FTRules() +" Solidity +au BufRead,BufNewFile *.sol setf solidity + " SPARQL queries au BufNewFile,BufRead *.rq,*.sparql setf sparql diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index 399e1c7f60..c6bcdd965c 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -598,6 +598,7 @@ local extension = { sl = "slang", ice = "slice", score = "slrnsc", + sol = "solidity", tpl = "smarty", ihlp = "smcl", smcl = "smcl", -- cgit From 791e400858ae8d32f974b40c4e1c0d54b66f610f Mon Sep 17 00:00:00 2001 From: Michael Lingelbach Date: Sat, 19 Feb 2022 08:38:14 -0800 Subject: fix: lsp and diagnostic highlight priority (#17461) Closes https://github.com/neovim/neovim/issues/17456 * treesitter uses the default highlight priority of 50 * diagnostic highlights have a priority of 150 * lsp reference highlights have a priority of 200 This ensures proper ordering. --- runtime/lua/vim/diagnostic.lua | 5 ++++- runtime/lua/vim/lsp/util.lua | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'runtime') diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua index b4537c2882..fda70b4e95 100644 --- a/runtime/lua/vim/diagnostic.lua +++ b/runtime/lua/vim/diagnostic.lua @@ -920,7 +920,10 @@ M.handlers.underline = { underline_ns, higroup, { diagnostic.lnum, diagnostic.col }, - { diagnostic.end_lnum, diagnostic.end_col } + { diagnostic.end_lnum, diagnostic.end_col }, + 'v', + false, + 150 ) end save_extmarks(underline_ns, bufnr) diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index d22c00ae76..d93331c12f 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -1551,9 +1551,9 @@ do --[[ References ]] document_highlight_kind[kind], { start_line, start_idx }, { end_line, end_idx }, - nil, + 'v', false, - 40) + 200) end end end -- cgit From 439a843b80339d80e788e8382ae91414c3db6dd5 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sat, 19 Feb 2022 23:41:11 +0100 Subject: vim-patch:8.2.4424: ".gts" and ".gjs" files are not recognized (#17464) Problem: ".gts" and ".gjs" files are not recognized. Solution: Recognize Glimmer flavored typescript and javascript. (closes vim/vim#9799) https://github.com/vim/vim/commit/cdf717283ca70b18f20b8a2cefe7957083280c6f --- runtime/filetype.vim | 4 ++++ runtime/lua/vim/filetype.lua | 2 ++ 2 files changed, 6 insertions(+) (limited to 'runtime') diff --git a/runtime/filetype.vim b/runtime/filetype.vim index c7955d74ee..f47b3ee0d4 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -726,6 +726,10 @@ au BufNewFile,BufRead gnashrc,.gnashrc,gnashpluginrc,.gnashpluginrc setf gnash au BufNewFile,BufRead gitolite.conf setf gitolite au BufNewFile,BufRead {,.}gitolite.rc,example.gitolite.rc setf perl +" Glimmer-flavored TypeScript and JavaScript +au BufNewFile,BufRead *.gts setf typescript.glimmer +au BufNewFile,BufRead *.gjs setf javascript.glimmer + " Gnuplot scripts au BufNewFile,BufRead *.gpi,.gnuplot setf gnuplot diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index c6bcdd965c..0555b87651 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -247,6 +247,8 @@ local extension = { gradle = "groovy", groovy = "groovy", gsp = "gsp", + gjs = "javascript.glimmer", + gts = "typescript.glimmer", hack = "hack", hackpartial = "hack", haml = "haml", -- cgit From 6a3acccd8be1c3796c0d1630383046b54b9f994c Mon Sep 17 00:00:00 2001 From: Michael Lingelbach Date: Sun, 20 Feb 2022 11:09:01 -0800 Subject: fix(lsp): use botright copen for all handlers (#17471) --- runtime/lua/vim/lsp/handlers.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua index a997b887d9..f5aefd4402 100644 --- a/runtime/lua/vim/lsp/handlers.lua +++ b/runtime/lua/vim/lsp/handlers.lua @@ -336,7 +336,7 @@ local function location_handler(_, result, ctx, _) title = 'LSP locations', items = util.locations_to_items(result, client.offset_encoding) }) - api.nvim_command("copen") + api.nvim_command("botright copen") end else util.jump_to_location(result, client.offset_encoding) @@ -430,7 +430,7 @@ local make_call_hierarchy_handler = function(direction) end end vim.fn.setqflist({}, ' ', {title = 'LSP call hierarchy', items = items}) - api.nvim_command("copen") + api.nvim_command("botright copen") end end -- cgit From d80c9b925973be87d1d5a2e948d65907234b2134 Mon Sep 17 00:00:00 2001 From: Michael Lingelbach Date: Sun, 20 Feb 2022 13:44:14 -0800 Subject: fix(diagnostic): use botright copen for qflist (#17475) This matches the LSP handlers, and forces the qflist for diagnostics to span across the horizontal space, below all open windows. --- runtime/lua/vim/diagnostic.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua index fda70b4e95..8879e2debd 100644 --- a/runtime/lua/vim/diagnostic.lua +++ b/runtime/lua/vim/diagnostic.lua @@ -447,7 +447,7 @@ local function set_list(loclist, opts) vim.fn.setqflist({}, ' ', { title = title, items = items }) end if open then - vim.api.nvim_command(loclist and "lopen" or "copen") + vim.api.nvim_command(loclist and "lopen" or "botright copen") end end -- cgit From aeb390e28f6346009c5a67a9ea79161bc1e62dda Mon Sep 17 00:00:00 2001 From: Aetf <7437103@gmail.com> Date: Sun, 20 Feb 2022 17:58:31 -0500 Subject: docs: clarify ftdetect scripts loading during packadd (#17465) The old description doesn't match the current behavior anymore. --- runtime/doc/repeat.txt | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt index a022049766..05529dc90a 100644 --- a/runtime/doc/repeat.txt +++ b/runtime/doc/repeat.txt @@ -253,21 +253,22 @@ For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|. below "plugin", just like with plugins in 'runtimepath'. - If the filetype detection was not enabled yet (this + If the filetype detection was already enabled (this is usually done with a "syntax enable" or "filetype - on" command in your .vimrc file), this will also look + on" command in your |init.vim|, or automatically during + |initialization|), and the package was found in + "pack/*/opt/{name}", this command will also look for "{name}/ftdetect/*.vim" files. When the optional ! is added no plugin files or ftdetect scripts are loaded, only the matching directories are added to 'runtimepath'. This is - useful in your .vimrc. The plugins will then be - loaded during initialization, see |load-plugins| (note + useful in your |init.vim|. The plugins will then be + loaded during |initialization|, see |load-plugins| (note that the loading order will be reversed, because each - directory is inserted before others). - Note that for ftdetect scripts to be loaded - you will need to write `filetype plugin indent on` - AFTER all `packadd!` commands. + directory is inserted before others). In this case, the + ftdetect scripts will be loaded during |initialization|, + before the |load-plugins| step. Also see |pack-add|. -- cgit From 10a46a20ce78efa80c1d1f7ac43b2a95ef92ea76 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Mon, 21 Feb 2022 21:21:42 +0100 Subject: refactor(highlight)!: optional arguments for highlight.range as table (#17462) also update documentation BREAKING CHANGE: signature of highlight.range is now vim.highlight.range(bufnr, ns, hlgroup, start, finish, { regtype = regtype, inclusive = inclusive, priority = priority }) Co-authored-by: Gregory Anders <8965202+gpanders@users.noreply.github.com> --- runtime/doc/lua.txt | 32 ++++++++++--- runtime/lua/vim/diagnostic.lua | 4 +- runtime/lua/vim/highlight.lua | 105 ++++++++++++++++++++++++++--------------- runtime/lua/vim/lsp/util.lua | 4 +- 4 files changed, 95 insertions(+), 50 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index 1a2d845281..355c31090e 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -595,13 +595,33 @@ vim.highlight.on_yank({opts}) *vim.highlight.on_yank()* - {on_visual} highlight when yanking visual selection (default `true`) - {event} event structure (default |v:event|) -vim.highlight.range({bufnr}, {ns}, {higroup}, {start}, {finish}, {rtype}, {inclusive}) +vim.highlight.range({bufnr}, {ns}, {hlgroup}, {start}, {finish}, {opts}) *vim.highlight.range()* - Highlights the range between {start} and {finish} (tuples of {line,col}) - in buffer {bufnr} with the highlight group {higroup} using the namespace - {ns}. Optional arguments are the type of range (characterwise, linewise, - or blockwise, see |setreg|; default to characterwise) and whether the - range is inclusive (default false). + + Apply highlight group to range of text. + + Parameters: ~ + {bufnr} buffer number + {ns} namespace for highlights + {hlgroup} highlight group name + {start} starting position (tuple {line,col}) + {finish} finish position (tuple {line,col}) + {opts} optional parameters: + • `regtype`: type of range (characterwise, linewise, + or blockwise, see |setreg|), default `'v'` + • `inclusive`: range includes end position, default + `false` + • `priority`: priority of highlight, default + `vim.highlight.user` (see below) + +vim.highlight.priorities *vim.highlight.priorities* + + Table with default priorities used for highlighting: + • `syntax`: `50`, used for standard syntax highlighting + • `treesitter`: `100`, used for tree-sitter-based highlighting + • `diagnostics`: `150`, used for code analysis such as diagnostics + • `user`: `200`, used for user-triggered highlights such as LSP + document symbols or `on_yank` autocommands ------------------------------------------------------------------------------ VIM.REGEX *lua-regex* diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua index 8879e2debd..fcb1e61764 100644 --- a/runtime/lua/vim/diagnostic.lua +++ b/runtime/lua/vim/diagnostic.lua @@ -921,9 +921,7 @@ M.handlers.underline = { higroup, { diagnostic.lnum, diagnostic.col }, { diagnostic.end_lnum, diagnostic.end_col }, - 'v', - false, - 150 + { priority = vim.highlight.priorities.diagnostics } ) end save_extmarks(underline_ns, bufnr) diff --git a/runtime/lua/vim/highlight.lua b/runtime/lua/vim/highlight.lua index 12faa0a6e1..4105ef0675 100644 --- a/runtime/lua/vim/highlight.lua +++ b/runtime/lua/vim/highlight.lua @@ -1,9 +1,16 @@ local api = vim.api -local highlight = {} +local M = {} + +M.priorities = { + syntax = 50, + treesitter = 100, + diagnostics = 150, + user = 200, +} ---@private -function highlight.create(higroup, hi_info, default) +function M.create(higroup, hi_info, default) local options = {} -- TODO: Add validation for k, v in pairs(hi_info) do @@ -13,28 +20,33 @@ function highlight.create(higroup, hi_info, default) end ---@private -function highlight.link(higroup, link_to, force) +function M.link(higroup, link_to, force) vim.cmd(string.format([[highlight%s link %s %s]], force and "!" or " default", higroup, link_to)) end - --- Highlight range between two positions --- ---@param bufnr number of buffer to apply highlighting to ---@param ns namespace to add highlight to ---@param higroup highlight group to use for highlighting ----@param rtype type of range (:help setreg, default charwise) ----@param inclusive boolean indicating whether the range is end-inclusive (default false) ----@param priority number indicating priority of highlight (default 50) -function highlight.range(bufnr, ns, higroup, start, finish, rtype, inclusive, priority) - rtype = rtype or 'v' - inclusive = inclusive or false - priority = priority or 50 +---@param start first position (tuple {line,col}) +---@param finish second position (tuple {line,col}) +---@param opts table with options: +-- - regtype type of range (:help setreg, default charwise) +-- - inclusive boolean indicating whether the range is end-inclusive (default false) +-- - priority number indicating priority of highlight (default priorities.user) +function M.range(bufnr, ns, higroup, start, finish, opts) + opts = opts or {} + local regtype = opts.regtype or "v" + local inclusive = opts.inclusive or false + local priority = opts.priority or M.priorities.user -- sanity check - if start[2] < 0 or finish[1] < start[1] then return end + if start[2] < 0 or finish[1] < start[1] then + return + end - local region = vim.region(bufnr, start, finish, rtype, inclusive) + local region = vim.region(bufnr, start, finish, regtype, inclusive) for linenr, cols in pairs(region) do local end_row if cols[2] == -1 then @@ -46,13 +58,12 @@ function highlight.range(bufnr, ns, higroup, start, finish, rtype, inclusive, pr end_row = end_row, end_col = cols[2], priority = priority, - strict = false + strict = false, }) end - end -local yank_ns = api.nvim_create_namespace('hlyank') +local yank_ns = api.nvim_create_namespace("hlyank") --- Highlight the yanked region --- --- use from init.vim via @@ -62,26 +73,40 @@ local yank_ns = api.nvim_create_namespace('hlyank') --- customize conditions (here: do not highlight a visual selection) via --- au TextYankPost * lua vim.highlight.on_yank {on_visual=false} --- --- @param opts dictionary with options controlling the highlight: +-- @param opts table with options controlling the highlight: -- - higroup highlight group for yanked region (default "IncSearch") -- - timeout time in ms before highlight is cleared (default 150) -- - on_macro highlight when executing macro (default false) -- - on_visual highlight when yanking visual selection (default true) -- - event event structure (default vim.v.event) -function highlight.on_yank(opts) - vim.validate { - opts = { opts, - function(t) if t == nil then return true else return type(t) == 'table' end end, - 'a table or nil to configure options (see `:h highlight.on_yank`)', - }} +function M.on_yank(opts) + vim.validate({ + opts = { + opts, + function(t) + if t == nil then + return true + else + return type(t) == "table" + end + end, + "a table or nil to configure options (see `:h highlight.on_yank`)", + }, + }) opts = opts or {} local event = opts.event or vim.v.event local on_macro = opts.on_macro or false local on_visual = (opts.on_visual ~= false) - if (not on_macro) and vim.fn.reg_executing() ~= '' then return end - if event.operator ~= 'y' or event.regtype == '' then return end - if (not on_visual) and event.visual then return end + if not on_macro and vim.fn.reg_executing() ~= "" then + return + end + if event.operator ~= "y" or event.regtype == "" then + return + end + if not on_visual and event.visual then + return + end local higroup = opts.higroup or "IncSearch" local timeout = opts.timeout or 150 @@ -92,19 +117,23 @@ function highlight.on_yank(opts) local pos1 = vim.fn.getpos("'[") local pos2 = vim.fn.getpos("']") - pos1 = {pos1[2] - 1, pos1[3] - 1 + pos1[4]} - pos2 = {pos2[2] - 1, pos2[3] - 1 + pos2[4]} - - highlight.range(bufnr, yank_ns, higroup, pos1, pos2, event.regtype, event.inclusive, 200) + pos1 = { pos1[2] - 1, pos1[3] - 1 + pos1[4] } + pos2 = { pos2[2] - 1, pos2[3] - 1 + pos2[4] } - vim.defer_fn( - function() - if api.nvim_buf_is_valid(bufnr) then - api.nvim_buf_clear_namespace(bufnr, yank_ns, 0, -1) - end - end, - timeout + M.range( + bufnr, + yank_ns, + higroup, + pos1, + pos2, + { regtype = event.regtype, inclusive = event.inclusive, priority = M.priorities.user } ) + + vim.defer_fn(function() + if api.nvim_buf_is_valid(bufnr) then + api.nvim_buf_clear_namespace(bufnr, yank_ns, 0, -1) + end + end, timeout) end -return highlight +return M diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index d93331c12f..655c3a4679 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -1551,9 +1551,7 @@ do --[[ References ]] document_highlight_kind[kind], { start_line, start_idx }, { end_line, end_idx }, - 'v', - false, - 200) + { priority = vim.highlight.priorities.user }) end end end -- cgit From 30c9c8815b531e0130ebeb9358bc6d3947a6128a Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Mon, 21 Feb 2022 23:01:22 +0100 Subject: vim-patch:partial 944697ae1968 (#17490) Update runtime files https://github.com/vim/vim/commit/944697ae19683441981539cd4d2469df89d6ec82 skip: docs skip: translations --- runtime/syntax/structurizr.vim | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/syntax/structurizr.vim b/runtime/syntax/structurizr.vim index 73629b1495..ab9e4ee609 100644 --- a/runtime/syntax/structurizr.vim +++ b/runtime/syntax/structurizr.vim @@ -1,7 +1,7 @@ " Vim syntax file " Language: Structurizr DSL " Maintainer: Bastian Venthur -" Last Change: 2021-08-16 +" Last Change: 2022-02-15 " Remark: For a language reference, see " https://github.com/structurizr/dsl @@ -30,6 +30,7 @@ syn keyword skeyword deployment syn keyword skeyword deploymentenvironment syn keyword skeyword deploymentgroup syn keyword skeyword deploymentnode +syn keyword skeyword description syn keyword skeyword dynamic syn keyword skeyword element syn keyword skeyword enterprise @@ -37,7 +38,6 @@ syn keyword skeyword exclude syn keyword skeyword filtered syn keyword skeyword group syn keyword skeyword healthcheck -syn keyword skeyword impliedrelationships syn keyword skeyword include syn keyword skeyword infrastructurenode syn keyword skeyword model @@ -51,6 +51,7 @@ syn keyword skeyword styles syn keyword skeyword systemcontext syn keyword skeyword systemlandscape syn keyword skeyword tags +syn keyword skeyword technology syn keyword skeyword terminology syn keyword skeyword theme syn keyword skeyword title @@ -63,7 +64,11 @@ syn match skeyword "\!adrs\s\+" syn match skeyword "\!constant\s\+" syn match skeyword "\!docs\s\+" syn match skeyword "\!identifiers\s\+" +syn match skeyword "\!impliedrelationships\s\+" syn match skeyword "\!include\s\+" +syn match skeyword "\!plugin\s\+" +syn match skeyword "\!ref\s\+" +syn match skeyword "\!script\s\+" syn region sstring oneline start='"' end='"' -- cgit From 11f7aeed7aa83d342d19897d9a69ba9f32ece7f7 Mon Sep 17 00:00:00 2001 From: Gregory Anders <8965202+gpanders@users.noreply.github.com> Date: Tue, 22 Feb 2022 13:19:21 -0700 Subject: feat(api): implement nvim_buf_get_text (#15181) nvim_buf_get_text is the mirror of nvim_buf_set_text. It differs from nvim_buf_get_lines in that it allows retrieving only portions of lines. While this can typically be done easily enough by API clients, implementing this function provides symmetry between the get/set text/lines APIs, and also provides a nice convenience that saves API clients the work of having to slice the result of nvim_buf_get_lines themselves. --- runtime/doc/api.txt | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'runtime') diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index 1e1534c31f..de7db3b0b7 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -2152,6 +2152,29 @@ nvim_buf_get_option({buffer}, {name}) *nvim_buf_get_option()* Return: ~ Option value + *nvim_buf_get_text()* +nvim_buf_get_text({buffer}, {start_row}, {start_col}, {end_row}, {end_col}, + {opts}) + Gets a range from the buffer. + + This differs from |nvim_buf_get_lines()| in that it allows + retrieving only portions of a line. + + Indexing is zero-based. Column indices are end-exclusive. + + Prefer |nvim_buf_get_lines()| when retrieving entire lines. + + Parameters: ~ + {buffer} Buffer handle, or 0 for current buffer + {start_row} First line index + {start_col} Starting byte offset of first line + {end_row} Last line index + {end_col} Ending byte offset of last line (exclusive) + {opts} Optional parameters. Currently unused. + + Return: ~ + Array of lines, or empty array for unloaded buffer. + nvim_buf_get_var({buffer}, {name}) *nvim_buf_get_var()* Gets a buffer-scoped (b:) variable. -- cgit From c07b5b5de6af5c85dd903c2cbb617d2a54153b44 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Wed, 23 Feb 2022 12:22:18 +0000 Subject: vim-patch:partial 944697ae196 (#17493) Update runtime files https://github.com/vim/vim/commit/944697ae19683441981539cd4d2469df89d6ec82 Doc changes: Include remote_*() (even though +clientserver and remote.txt isn't ported yet) Omit screenpos() (need v8.2.4389) Other changes are N/A or cannot be directly applied --- runtime/doc/builtin.txt | 30 +++++++++++++++++++++--------- runtime/doc/editing.txt | 6 +++--- runtime/doc/options.txt | 8 ++++---- 3 files changed, 28 insertions(+), 16 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 35a232c0c2..833da2622c 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -1807,6 +1807,7 @@ exists({expr}) The result is a Number, which is |TRUE| if {expr} is exists("$HOSTNAME") exists("*strftime") exists("*s:MyFunc") + exists("*MyFunc") exists("bufcount") exists(":Make") exists("#CursorHold") @@ -5863,16 +5864,22 @@ reltimestr({time}) *reltimestr()* < *remote_expr()* *E449* remote_expr({server}, {string} [, {idvar} [, {timeout}]]) - Send the {string} to {server}. The string is sent as an - expression and the result is returned after evaluation. - The result must be a String or a |List|. A |List| is turned - into a String by joining the items with a line break in - between (not at the end), like with join(expr, "\n"). + Send the {string} to {server}. The {server} argument is a + string, also see |{server}|. + + The string is sent as an expression and the result is returned + after evaluation. The result must be a String or a |List|. A + |List| is turned into a String by joining the items with a + line break in between (not at the end), like with join(expr, + "\n"). + If {idvar} is present and not empty, it is taken as the name of a variable and a {serverid} for later use with |remote_read()| is stored there. + If {timeout} is given the read times out after this many seconds. Otherwise a timeout of 600 seconds is used. + See also |clientserver| |RemoteReply|. This function is not available in the |sandbox|. Note: Any errors will cause a local error message to be issued @@ -5890,7 +5897,7 @@ remote_expr({server}, {string} [, {idvar} [, {timeout}]]) remote_foreground({server}) *remote_foreground()* Move the Vim server with the name {server} to the foreground. - The {server} argument is a string. + The {server} argument is a string, also see |{server}|. This works like: > remote_expr({server}, "foreground()") < Except that on Win32 systems the client does the work, to work @@ -5926,12 +5933,17 @@ remote_read({serverid}, [{timeout}]) *remote_read()* < *remote_send()* *E241* remote_send({server}, {string} [, {idvar}]) - Send the {string} to {server}. The string is sent as input - keys and the function returns immediately. At the Vim server - the keys are not mapped |:map|. + Send the {string} to {server}. The {server} argument is a + string, also see |{server}|. + + The string is sent as input keys and the function returns + immediately. At the Vim server the keys are not mapped + |:map|. + If {idvar} is present, it is taken as the name of a variable and a {serverid} for later use with remote_read() is stored there. + See also |clientserver| |RemoteReply|. This function is not available in the |sandbox|. diff --git a/runtime/doc/editing.txt b/runtime/doc/editing.txt index 8ddc661c0e..4ccf3f145c 100644 --- a/runtime/doc/editing.txt +++ b/runtime/doc/editing.txt @@ -196,7 +196,7 @@ If you want to keep the changed buffer without saving it, switch on the Edit {file} always. Discard any changes to the current buffer. Also see |++opt| and |+cmd|. - + *:edit_#* *:e#* :e[dit] [++opt] [+cmd] #[count] Edit the [count]th buffer (as shown by |:files|). This command does the same as [count] CTRL-^. But ":e @@ -356,7 +356,7 @@ as a wildcard when "[" is in the 'isfname' option. A simple way to avoid this is to use "path\[[]abc]", this matches the file "path\[abc]". *starstar-wildcard* -Expanding "**" is possible on Unix, Win32, Mac OS/X and a few other systems. +Expanding "**" is possible on Unix, Win32, macOS and a few other systems. This allows searching a directory tree. This goes up to 100 directories deep. Note there are some commands where this works slightly differently, see |file-searching|. @@ -1495,7 +1495,7 @@ which version of the file you want to keep. The accuracy of the time check depends on the filesystem. On Unix it is usually sub-second. With old file sytems and on MS-Windows it is normally one -second. Use has('nanotime') check if sub-second time stamp checks are +second. Use `has('nanotime')` to check if sub-second time stamp checks are available. There is one situation where you get the message while there is nothing wrong: diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 6e2bc228d0..2f76cc018c 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -3040,7 +3040,7 @@ A jump table for the options with a short description can be found at |Q_op|. *'guitablabel'* *'gtl'* 'guitablabel' 'gtl' string (default empty) global - When nonempty describes the text to use in a label of the GUI tab + When non-empty describes the text to use in a label of the GUI tab pages line. When empty and when the result is empty Vim will use a default label. See |setting-guitablabel| for more info. @@ -3057,7 +3057,7 @@ A jump table for the options with a short description can be found at |Q_op|. *'guitabtooltip'* *'gtt'* 'guitabtooltip' 'gtt' string (default empty) global - When nonempty describes the text to use in a tooltip for the GUI tab + When non-empty describes the text to use in a tooltip for the GUI tab pages line. When empty Vim will use a default tooltip. This option is otherwise just like 'guitablabel' above. You can include a line break. Simplest method is to use |:let|: > @@ -5906,7 +5906,7 @@ A jump table for the options with a short description can be found at |Q_op|. *'statusline'* *'stl'* *E540* *E542* 'statusline' 'stl' string (default empty) global or local to window |global-local| - When nonempty, this option determines the content of the status line. + When non-empty, this option determines the content of the status line. Also see |status-line|. The option consists of printf style '%' items interspersed with @@ -6222,7 +6222,7 @@ A jump table for the options with a short description can be found at |Q_op|. *'tabline'* *'tal'* 'tabline' 'tal' string (default empty) global - When nonempty, this option determines the content of the tab pages + When non-empty, this option determines the content of the tab pages line at the top of the Vim window. When empty Vim will use a default tab pages line. See |setting-tabline| for more info. -- cgit From 1630ec742dce02c2f56cc5520de0ca2616ea1241 Mon Sep 17 00:00:00 2001 From: Dundar Göc Date: Sun, 20 Feb 2022 22:45:32 +0100 Subject: docs: update explanation of Y to reflect new defaults Closes https://github.com/neovim/neovim/issues/17435 --- runtime/doc/index.txt | 1 + runtime/doc/quickref.txt | 1 + runtime/doc/usr_04.txt | 8 +++++--- runtime/doc/usr_07.txt | 4 ++-- runtime/doc/usr_10.txt | 4 ++-- 5 files changed, 11 insertions(+), 7 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/index.txt b/runtime/doc/index.txt index e3bc3d5437..d02ab1b759 100644 --- a/runtime/doc/index.txt +++ b/runtime/doc/index.txt @@ -353,6 +353,7 @@ tag char note action in Normal mode ~ register x] |Y| ["x]Y yank N lines [into register x]; synonym for "yy" + Note: Mapped to "y$" by default. |default-mappings| |ZZ| ZZ write if buffer changed and close window |ZQ| ZQ close window without writing |[| [{char} square bracket command (see |[| below) diff --git a/runtime/doc/quickref.txt b/runtime/doc/quickref.txt index af8301f1a0..e36eb2359f 100644 --- a/runtime/doc/quickref.txt +++ b/runtime/doc/quickref.txt @@ -356,6 +356,7 @@ In Insert or Command-line mode: |v_y| {visual}y yank the highlighted text into a register |yy| N yy yank N lines into a register |Y| N Y yank N lines into a register + Note: Mapped to "y$" by default. |default-mappings| |p| N p put a register after the cursor position (N times) |P| N P put a register before the cursor position (N times) |]p| N ]p like p, but adjust indent to current line diff --git a/runtime/doc/usr_04.txt b/runtime/doc/usr_04.txt index b2dd617542..c7c900274b 100644 --- a/runtime/doc/usr_04.txt +++ b/runtime/doc/usr_04.txt @@ -349,15 +349,17 @@ Notice that "yw" includes the white space after a word. If you don't want this, use "ye". The "yy" command yanks a whole line, just like "dd" deletes a whole line. -Unexpectedly, while "D" deletes from the cursor to the end of the line, "Y" -works like "yy", it yanks the whole line. Watch out for this inconsistency! -Use "y$" to yank to the end of the line. a text line yy a text line a text line line 2 line 2 p line 2 last line last line a text line last line +"Y" was originally equivalent to "yank the entire line", as opposed to "D" +which is "delete to end of the line". "Y" has thus been remapped to mean +"yank to end of the line" to make it consistent with the behavior of "D". +Mappings will be covered in later chapters. + ============================================================================== *04.7* Using the clipboard diff --git a/runtime/doc/usr_07.txt b/runtime/doc/usr_07.txt index 649be8d7ce..ebf5c3d7b8 100644 --- a/runtime/doc/usr_07.txt +++ b/runtime/doc/usr_07.txt @@ -336,7 +336,7 @@ there. > Of course you can use many other commands to yank the text. For example, to select whole lines start Visual mode with "V". Or use CTRL-V to select a -rectangular block. Or use "Y" to yank a single line, "yaw" to yank-a-word, +rectangular block. Or use "yy" to yank a single line, "yaw" to yank-a-word, etc. The "p" command puts the text after the cursor. Use "P" to put the text before the cursor. Notice that Vim remembers if you yanked a whole line or a @@ -359,7 +359,7 @@ the text should be placed in the f register. This must come just before the yank command. Now yank three whole lines to the l register (l for line): > - "l3Y + "l3yy The count could be before the "l just as well. To yank a block of text to the b (for block) register: > diff --git a/runtime/doc/usr_10.txt b/runtime/doc/usr_10.txt index 5365f90314..8844671e01 100644 --- a/runtime/doc/usr_10.txt +++ b/runtime/doc/usr_10.txt @@ -132,11 +132,11 @@ This works both with recording and with yank and delete commands. For example, you want to collect a sequence of lines into the a register. Yank the first line with: > - "aY + "ayy Now move to the second line, and type: > - "AY + "Ayy Repeat this command for all lines. The a register now contains all those lines, in the order you yanked them. -- cgit From fdea15723fab6a3ee96218f13669d9f2e0a6d6d7 Mon Sep 17 00:00:00 2001 From: Gregory Anders <8965202+gpanders@users.noreply.github.com> Date: Thu, 24 Feb 2022 10:02:17 -0700 Subject: feat(filetype): support scripts.vim with filetype.lua (#17517) When filetype.vim is disabled, create the autocommand that runs scripts.vim in filetype.lua. --- runtime/filetype.lua | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'runtime') diff --git a/runtime/filetype.lua b/runtime/filetype.lua index fcfc5701f0..74e427c358 100644 --- a/runtime/filetype.lua +++ b/runtime/filetype.lua @@ -7,6 +7,7 @@ if vim.g.do_filetype_lua ~= 1 then return end +-- TODO: Remove vim.cmd once Lua autocommands land vim.cmd [[ augroup filetypedetect au BufRead,BufNewFile * call v:lua.vim.filetype.match(expand('')) @@ -18,6 +19,12 @@ runtime! ftdetect/*.lua " Set a marker so that the ftdetect scripts are not sourced a second time by filetype.vim let g:did_load_ftdetect = 1 +" If filetype.vim is disabled, set up the autocmd to use scripts.vim +if exists('did_load_filetypes') + au BufRead,BufNewFile * if !did_filetype() && expand('') !~ g:ft_ignore_pat | runtime! scripts.vim | endif + au StdinReadPost * if !did_filetype() | runtime! scripts.vim | endif +endif + augroup END ]] -- cgit From d0f8f76224f501d919ba6c8a5cd717de76903b34 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sat, 26 Feb 2022 14:01:37 +0100 Subject: vim-patch:8.2.4464: Dtrace files are recognized as filetype D (#17518) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: Dtrace files are recognized as filetype D. Solution: Add a pattern for Dtrace files. (Teubel György, closes vim/vim#9841) Add some more testing. https://github.com/vim/vim/commit/4d56b971cbae01cc454eb09713326224993e38ed --- runtime/autoload/dist/ft.vim | 4 ++++ runtime/filetype.vim | 1 + runtime/lua/vim/filetype.lua | 1 + 3 files changed, 6 insertions(+) (limited to 'runtime') diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim index aacecc521e..bcb1431b5f 100644 --- a/runtime/autoload/dist/ft.vim +++ b/runtime/autoload/dist/ft.vim @@ -211,6 +211,10 @@ func dist#ft#EuphoriaCheck() endfunc func dist#ft#DtraceCheck() + if did_filetype() + " Filetype was already detected + return + endif let lines = getline(1, min([line("$"), 100])) if match(lines, '^module\>\|^import\>') > -1 " D files often start with a module and/or import statement. diff --git a/runtime/filetype.vim b/runtime/filetype.vim index f47b3ee0d4..8114ad4092 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -480,6 +480,7 @@ au BufNewFile,BufRead */etc/dnsmasq.conf setf dnsmasq au BufNewFile,BufRead *.desc setf desc " the D language or dtrace +au BufNewFile,BufRead */dtrace/*.d setf dtrace au BufNewFile,BufRead *.d call dist#ft#DtraceCheck() " Desktop files diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index 0555b87651..f5e4dabfb6 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -1178,6 +1178,7 @@ local pattern = { [".*/etc/yum%.conf"] = "dosini", [".*lvs"] = "dracula", [".*lpe"] = "dracula", + [".*/dtrace/.*%.d"] = "dtrace", [".*esmtprc"] = "esmtprc", [".*Eterm/.*%.cfg"] = "eterm", [".*%.git/modules/.*/config"] = "gitconfig", -- cgit From b87867e69e94d9784468a126f21c721446f080de Mon Sep 17 00:00:00 2001 From: erw7 Date: Sat, 11 Sep 2021 11:48:58 +0900 Subject: feat(lua): add proper support of luv threads --- runtime/lua/vim/_load_package.lua | 48 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 runtime/lua/vim/_load_package.lua (limited to 'runtime') diff --git a/runtime/lua/vim/_load_package.lua b/runtime/lua/vim/_load_package.lua new file mode 100644 index 0000000000..3e346fb3f6 --- /dev/null +++ b/runtime/lua/vim/_load_package.lua @@ -0,0 +1,48 @@ +-- prevents luacheck from making lints for setting things on vim +local vim = assert(vim) + +local pathtrails = {} +vim._so_trails = {} +for s in (package.cpath..';'):gmatch('[^;]*;') do + s = s:sub(1, -2) -- Strip trailing semicolon + -- Find out path patterns. pathtrail should contain something like + -- /?.so, \?.dll. This allows not to bother determining what correct + -- suffixes are. + local pathtrail = s:match('[/\\][^/\\]*%?.*$') + if pathtrail and not pathtrails[pathtrail] then + pathtrails[pathtrail] = true + table.insert(vim._so_trails, pathtrail) + end +end + +function vim._load_package(name) + local basename = name:gsub('%.', '/') + local paths = {"lua/"..basename..".lua", "lua/"..basename.."/init.lua"} + local found = vim.api.nvim__get_runtime(paths, false, {is_lua=true}) + if #found > 0 then + local f, err = loadfile(found[1]) + return f or error(err) + end + + local so_paths = {} + for _,trail in ipairs(vim._so_trails) do + local path = "lua"..trail:gsub('?', basename) -- so_trails contains a leading slash + table.insert(so_paths, path) + end + + found = vim.api.nvim__get_runtime(so_paths, false, {is_lua=true}) + if #found > 0 then + -- Making function name in Lua 5.1 (see src/loadlib.c:mkfuncname) is + -- a) strip prefix up to and including the first dash, if any + -- b) replace all dots by underscores + -- c) prepend "luaopen_" + -- So "foo-bar.baz" should result in "luaopen_bar_baz" + local dash = name:find("-", 1, true) + local modname = dash and name:sub(dash + 1) or name + local f, err = package.loadlib(found[1], "luaopen_"..modname:gsub("%.", "_")) + return f or error(err) + end + return nil +end + +table.insert(package.loaders, 1, vim._load_package) -- cgit From 850b3e19c9fc8d84d960e6932a9ad4f0bcad2a8e Mon Sep 17 00:00:00 2001 From: bfredl Date: Sat, 26 Feb 2022 11:03:39 +0100 Subject: refactor(lua): cleanup and docs for threads --- runtime/doc/lua.txt | 20 ++++++++++++++++++++ runtime/lua/vim/_load_package.lua | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index 355c31090e..4ea78c2426 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -568,6 +568,26 @@ Example: TCP echo-server *tcp-server* end) print('TCP echo-server listening on port: '..server:getsockname().port) + +Multithreading *lua-loop-threading* + +Plugins can perform work in separate (os-level) threads using the threading +APIs in luv, for instance `vim.loop.new_thread`. Note that every thread +gets its own separate lua interpreter state, with no access to lua globals +in the main thread. Neither can the state of the editor (buffers, windows, +etc) be directly accessed from threads. + +A subset of the `vim.*` API is available in threads. This includes: + +- `vim.loop` with a separate event loop per thread. +- `vim.mpack` and `vim.json` (useful for serializing messages between threads) +- `require` in threads can use lua packages from the global |lua-package-path| +- `print()` and `vim.inspect` +- `vim.diff` +- most utility functions in `vim.*` for working with pure lua values + like `vim.split`, `vim.tbl_*`, `vim.list_*`, and so on. +- `vim.is_thread()` returns true from a non-main thread. + ------------------------------------------------------------------------------ VIM.HIGHLIGHT *lua-highlight* diff --git a/runtime/lua/vim/_load_package.lua b/runtime/lua/vim/_load_package.lua index 3e346fb3f6..525f603438 100644 --- a/runtime/lua/vim/_load_package.lua +++ b/runtime/lua/vim/_load_package.lua @@ -45,4 +45,5 @@ function vim._load_package(name) return nil end -table.insert(package.loaders, 1, vim._load_package) +-- Insert vim._load_package after the preloader at position 2 +table.insert(package.loaders, 2, vim._load_package) -- cgit From 0347875a5c11258ebb6377a1ab79b04fe9c55bc9 Mon Sep 17 00:00:00 2001 From: shadmansaleh <13149513+shadmansaleh@users.noreply.github.com> Date: Fri, 7 Jan 2022 17:28:14 +0600 Subject: feat: ignore nore on maps --- runtime/doc/map.txt | 3 +++ runtime/doc/vim_diff.txt | 3 +++ 2 files changed, 6 insertions(+) (limited to 'runtime') diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt index 358e944261..e73bf3c453 100644 --- a/runtime/doc/map.txt +++ b/runtime/doc/map.txt @@ -65,6 +65,9 @@ modes. where the map command applies. Disallow mapping of {rhs}, to avoid nested and recursive mappings. Often used to redefine a command. + Note: "nore" is ignored for a mapping whose result + starts with . is always remapped even if + "nore" is used. :unm[ap] {lhs} |mapmode-nvo| *:unm* *:unmap* diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index 5ea6a9c5dd..d7a65756bf 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -442,6 +442,9 @@ Working directory (Vim implemented some of these later than Nvim): - `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. +Mappings: +- |nore| is ignored for rhs mappings. mappings are always remapped. + ============================================================================== 5. Missing legacy features *nvim-features-missing* -- cgit From c031e038df8429e14b0aa608aaa77068daa680f0 Mon Sep 17 00:00:00 2001 From: shadmansaleh <13149513+shadmansaleh@users.noreply.github.com> Date: Fri, 7 Jan 2022 18:17:19 +0600 Subject: chore: remove detection from vim.keymap --- runtime/doc/lua.txt | 4 +--- runtime/lua/vim/keymap.lua | 6 +++--- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index 355c31090e..c91bd1b2ae 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -1994,9 +1994,7 @@ set({mode}, {lhs}, {rhs}, {opts}) *vim.keymap.set()* result of Lua expr maps. • remap: (boolean) Make the mapping recursive. This is the inverse of the "noremap" option from - |nvim_set_keymap()|. Default `true` if `lhs` is - a string starting with `` - (case-insensitive), `false` otherwise. + |nvim_set_keymap()|. Default `false` . See also: ~ |nvim_set_keymap()| diff --git a/runtime/lua/vim/keymap.lua b/runtime/lua/vim/keymap.lua index d53b790746..df49eff4b6 100644 --- a/runtime/lua/vim/keymap.lua +++ b/runtime/lua/vim/keymap.lua @@ -42,7 +42,7 @@ local keymap = {} --- |nvim_replace_termcodes()| is applied to the result of Lua expr maps. --- - remap: (boolean) Make the mapping recursive. This is the --- inverse of the "noremap" option from |nvim_set_keymap()|. ---- Default `true` if `lhs` is a string starting with `` (case-insensitive), `false` otherwise. +--- Default `false`. ---@see |nvim_set_keymap()| function keymap.set(mode, lhs, rhs, opts) vim.validate { @@ -66,8 +66,8 @@ function keymap.set(mode, lhs, rhs, opts) opts.replace_keycodes = nil if opts.remap == nil then - -- remap by default on mappings and don't otherwise. - opts.noremap = is_rhs_luaref or rhs:lower():match("^") == nil + -- default remap value is false + opts.noremap = true else -- remaps behavior is opposite of noremap option. opts.noremap = not opts.remap -- cgit From 9d3370a14429587303d3abe6d4ece71342f5e4b5 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sun, 27 Feb 2022 11:56:30 +0100 Subject: vim-patch:c51cf0329809 (#17530) Update runtime files. https://github.com/vim/vim/commit/c51cf0329809c7ae946c59d6f56699227efc9d1b --- runtime/autoload/dist/ft.vim | 2 +- runtime/doc/autocmd.txt | 4 +- runtime/doc/builtin.txt | 106 +++++++++++++++++++++---------------------- runtime/doc/change.txt | 4 +- runtime/doc/cmdline.txt | 2 +- runtime/doc/diff.txt | 12 ++--- runtime/doc/editing.txt | 4 +- runtime/doc/eval.txt | 56 ++++++++++++----------- runtime/doc/fold.txt | 2 +- runtime/doc/ft_raku.txt | 24 +++++----- runtime/doc/ft_rust.txt | 4 +- runtime/doc/ft_sql.txt | 12 ++--- runtime/doc/if_pyth.txt | 2 +- runtime/doc/insert.txt | 6 +-- runtime/doc/map.txt | 8 ++-- runtime/doc/motion.txt | 2 +- runtime/doc/options.txt | 16 +++---- runtime/doc/pattern.txt | 4 +- runtime/doc/pi_netrw.txt | 6 +-- runtime/doc/print.txt | 6 +-- runtime/doc/quickfix.txt | 22 ++++++++- runtime/doc/sign.txt | 2 +- runtime/doc/spell.txt | 4 +- runtime/doc/starting.txt | 2 +- runtime/doc/syntax.txt | 10 ++-- runtime/doc/tabpage.txt | 18 ++++---- runtime/doc/tagsrch.txt | 2 +- runtime/doc/term.txt | 2 +- runtime/doc/tips.txt | 28 ++++++------ runtime/doc/undo.txt | 4 +- runtime/doc/usr_05.txt | 2 +- runtime/doc/various.txt | 4 +- runtime/doc/windows.txt | 14 +++--- runtime/indent/vim.vim | 20 +++++--- 34 files changed, 221 insertions(+), 195 deletions(-) (limited to 'runtime') diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim index bcb1431b5f..54cb6ce70f 100644 --- a/runtime/autoload/dist/ft.vim +++ b/runtime/autoload/dist/ft.vim @@ -1,7 +1,7 @@ " Vim functions for file type detection " " Maintainer: Bram Moolenaar -" Last Change: 2022 Jan 31 +" Last Change: 2022 Feb 22 " These functions are moved here from runtime/filetype.vim to make startup " faster. diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt index dbe70b84cf..9054bedc8d 100644 --- a/runtime/doc/autocmd.txt +++ b/runtime/doc/autocmd.txt @@ -1406,7 +1406,7 @@ Examples for reading and writing compressed files: > : autocmd BufReadPre,FileReadPre *.gz set bin : autocmd BufReadPost,FileReadPost *.gz '[,']!gunzip : autocmd BufReadPost,FileReadPost *.gz set nobin - : autocmd BufReadPost,FileReadPost *.gz execute ":doautocmd BufReadPost " . expand("%:r") + : autocmd BufReadPost,FileReadPost *.gz execute ":doautocmd BufReadPost " .. expand("%:r") : autocmd BufWritePost,FileWritePost *.gz !mv :r : autocmd BufWritePost,FileWritePost *.gz !gzip :r @@ -1505,7 +1505,7 @@ To insert the current date and time in a *.html file when writing it: > : else : let l = line("$") : endif - : exe "1," . l . "g/Last modified: /s/Last modified: .*/Last modified: " . + : exe "1," .. l .. "g/Last modified: /s/Last modified: .*/Last modified: " .. : \ strftime("%Y %b %d") :endfun diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 833da2622c..03a5f98c6d 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -693,7 +693,7 @@ argv([{nr} [, {winid}]]) :let i = 0 :while i < argc() : let f = escape(fnameescape(argv(i)), '.') - : exe 'amenu Arg.' . f . ' :e ' . f . '' + : exe 'amenu Arg.' .. f .. ' :e ' .. f .. '' : let i = i + 1 :endwhile < Without the {nr} argument, or when {nr} is -1, a |List| with @@ -895,7 +895,7 @@ bufwinid({buf}) *bufwinid()* see |bufname()| above. If buffer {buf} doesn't exist or there is no such window, -1 is returned. Example: > - echo "A window containing buffer 1 is " . (bufwinid(1)) + echo "A window containing buffer 1 is " .. (bufwinid(1)) < Only deals with the current tab page. @@ -908,7 +908,7 @@ bufwinnr({buf}) *bufwinnr()* If buffer {buf} doesn't exist or there is no such window, -1 is returned. Example: > - echo "A window containing buffer 1 is " . (bufwinnr(1)) + echo "A window containing buffer 1 is " .. (bufwinnr(1)) < The number can be used with |CTRL-W_w| and ":wincmd w" |:wincmd|. @@ -955,7 +955,7 @@ byteidx({expr}, {nr}) *byteidx()* byteidxcomp({expr}, {nr}) *byteidxcomp()* Like byteidx(), except that a composing character is counted as a separate character. Example: > - let s = 'e' . nr2char(0x301) + let s = 'e' .. nr2char(0x301) echo byteidx(s, 1) echo byteidxcomp(s, 1) echo byteidxcomp(s, 2) @@ -1152,7 +1152,7 @@ col({expr}) The result is a Number, which is the byte index of the column col(".") column of cursor col("$") length of cursor line plus one col("'t") column of mark t - col("'" . markname) column of mark markname + col("'" .. markname) column of mark markname < The first column is 1. 0 is returned for an error. For an uppercase mark the column may actually be in another buffer. @@ -1161,7 +1161,7 @@ col({expr}) The result is a Number, which is the byte index of the column line. This can be used to obtain the column in Insert mode: > :imap :let save_ve = &ve \:set ve=all - \:echo col(".") . "\n" + \:echo col(".") .. "\n" \let &ve = save_ve < Can also be used as a |method|: > @@ -1899,12 +1899,12 @@ expand({string} [, {nosuf} [, {list}]]) *expand()* :e extension only Example: > - :let &tags = expand("%:p:h") . "/tags" + :let &tags = expand("%:p:h") .. "/tags" < Note that when expanding a string that starts with '%', '#' or '<', any following text is ignored. This does NOT work: > :let doesntwork = expand("%:h.bak") < Use this: > - :let doeswork = expand("%:h") . ".bak" + :let doeswork = expand("%:h") .. ".bak" < Also note that expanding "" and others only returns the referenced file name without further expansion. If "" is "~/.cshrc", you need to do another expand() to have the @@ -2240,7 +2240,7 @@ fnameescape({string}) *fnameescape()* and |:write|). And a "-" by itself (special after |:cd|). Example: > :let fname = '+some str%nge|name' - :exe "edit " . fnameescape(fname) + :exe "edit " .. fnameescape(fname) < results in executing: > edit \+some\ str\%nge\|name < @@ -2395,7 +2395,7 @@ function({name} [, {arglist}] [, {dict}]) < The Dictionary is only useful when calling a "dict" function. In that case the {dict} is passed in as "self". Example: > function Callback() dict - echo "called for " . self.name + echo "called for " .. self.name endfunction ... let context = {"name": "example"} @@ -2578,7 +2578,7 @@ getbufvar({buf}, {varname} [, {def}]) *getbufvar()* string is returned, there is no error message. Examples: > :let bufmodified = getbufvar(1, "&mod") - :echo "todo myvar = " . getbufvar("todo", "myvar") + :echo "todo myvar = " .. getbufvar("todo", "myvar") < Can also be used as a |method|: > GetBufnr()->getbufvar(varname) @@ -2639,9 +2639,9 @@ getchar([expr]) *getchar()* This example positions the mouse as it would normally happen: > let c = getchar() if c == "\" && v:mouse_win > 0 - exe v:mouse_win . "wincmd w" + exe v:mouse_win .. "wincmd w" exe v:mouse_lnum - exe "normal " . v:mouse_col . "|" + exe "normal " .. v:mouse_col .. "|" endif < There is no prompt, you will somehow have to make clear to the @@ -3374,7 +3374,7 @@ gettabwinvar({tabnr}, {winnr}, {varname} [, {def}]) *gettabwinvar()* empty string is returned, there is no error message. Examples: > :let list_is_on = gettabwinvar(1, 2, '&list') - :echo "myvar = " . gettabwinvar(3, 1, 'myvar') + :echo "myvar = " .. gettabwinvar(3, 1, 'myvar') < To obtain all window-local variables use: > gettabwinvar({tabnr}, {winnr}, '&') @@ -3489,7 +3489,7 @@ getwinvar({winnr}, {varname} [, {def}]) *getwinvar()* Like |gettabwinvar()| for the current tabpage. Examples: > :let list_is_on = getwinvar(2, '&list') - :echo "myvar = " . getwinvar(1, 'myvar') + :echo "myvar = " .. getwinvar(1, 'myvar') < Can also be used as a |method|: > GetWinnr()->getwinvar(varname) @@ -3758,7 +3758,7 @@ histdel({history} [, {item}]) *histdel()* The following three are equivalent: > :call histdel("search", histnr("search")) :call histdel("search", -1) - :call histdel("search", '^'.histget("search", -1).'$') + :call histdel("search", '^' .. histget("search", -1) .. '$') < To delete the last search pattern and use the last-but-one for the "n" command and 'hlsearch': > @@ -3777,7 +3777,7 @@ histget({history} [, {index}]) *histget()* Examples: Redo the second last search from history. > - :execute '/' . histget("search", -2) + :execute '/' .. histget("search", -2) < Define an Ex command ":H {num}" that supports re-execution of the {num}th entry from the output of |:history|. > @@ -3941,11 +3941,11 @@ input({opts}) let lvl = 0 while i < len(a:cmdline) if a:cmdline[i] is# '(' - call add(ret, [i, i + 1, 'RBP' . ((lvl % g:rainbow_levels) + 1)]) + call add(ret, [i, i + 1, 'RBP' .. ((lvl % g:rainbow_levels) + 1)]) let lvl += 1 elseif a:cmdline[i] is# ')' let lvl -= 1 - call add(ret, [i, i + 1, 'RBP' . ((lvl % g:rainbow_levels) + 1)]) + call add(ret, [i, i + 1, 'RBP' .. ((lvl % g:rainbow_levels) + 1)]) endif let i += 1 endwhile @@ -3975,7 +3975,7 @@ input({opts}) |:execute| or |:normal|. Example with a mapping: > - :nmap \x :call GetFoo():exe "/" . Foo + :nmap \x :call GetFoo():exe "/" .. Foo :function GetFoo() : call inputsave() : let g:Foo = input("enter search pattern: ") @@ -4134,7 +4134,7 @@ items({dict}) *items()* order. Also see |keys()| and |values()|. Example: > for [key, value] in items(mydict) - echo key . ': ' . value + echo key .. ': ' .. value endfor < Can also be used as a |method|: > @@ -4270,7 +4270,7 @@ join({list} [, {sep}]) *join()* {sep} is omitted a single space is used. Note that {sep} is not added at the end. You might want to add it there too: > - let lines = join(mylist, "\n") . "\n" + let lines = join(mylist, "\n") .. "\n" < String items are used as-is. |Lists| and |Dictionaries| are converted into a string like with |string()|. The opposite function is |split()|. @@ -4419,7 +4419,7 @@ line({expr} [, {winid}]) *line()* line(".") line number of the cursor line(".", winid) idem, in window "winid" line("'t") line number of mark t - line("'" . marker) line number of mark marker + line("'" .. marker) line number of mark marker < To jump to the last known position when opening a file see |last-position-jump|. @@ -4520,7 +4520,7 @@ map({expr1}, {expr2}) *map()* the current item. For a |Blob| |v:key| has the index of the current byte. Example: > - :call map(mylist, '"> " . v:val . " <"') + :call map(mylist, '"> " .. v:val .. " <"') < This puts "> " before and " <" after each item in "mylist". Note that {expr2} is the result of an expression and is then @@ -4534,19 +4534,19 @@ map({expr1}, {expr2}) *map()* The function must return the new value of the item. Example that changes each value by "key-value": > func KeyValue(key, val) - return a:key . '-' . a:val + return a:key .. '-' .. a:val endfunc call map(myDict, function('KeyValue')) < It is shorter when using a |lambda|: > - call map(myDict, {key, val -> key . '-' . val}) + call map(myDict, {key, val -> key .. '-' .. val}) < If you do not use "val" you can leave it out: > - call map(myDict, {key -> 'item: ' . key}) + call map(myDict, {key -> 'item: ' .. key}) < If you do not use "key" you can use a short name: > - call map(myDict, {_, val -> 'item: ' . val}) + call map(myDict, {_, val -> 'item: ' .. val}) < The operation is done in-place. If you want a |List| or |Dictionary| to remain unmodified make a copy first: > - :let tlist = map(copy(mylist), ' v:val . "\t"') + :let tlist = map(copy(mylist), ' v:val .. "\t"') < Returns {expr1}, the |List|, |Blob| or |Dictionary| that was filtered. When an error is encountered while evaluating @@ -4612,7 +4612,7 @@ maparg({name} [, {mode} [, {abbr} [, {dict}]]]) *maparg()* then the global mappings. This function can be used to map a key even when it's already mapped, and have it do the original mapping too. Sketch: > - exe 'nnoremap ==' . maparg('', 'n') + exe 'nnoremap ==' .. maparg('', 'n') < Can also be used as a |method|: > GetKey()->maparg('n') @@ -5085,7 +5085,7 @@ mkdir({name} [, {path} [, {prot}]]) {prot} is applied for all parts of {name}. Thus if you create /tmp/foo/bar then /tmp/foo will be created with 0o700. Example: > - :call mkdir($HOME . "/tmp/foo/bar", "p", 0o700) + :call mkdir($HOME .. "/tmp/foo/bar", "p", 0o700) < This function is not available in the |sandbox|. @@ -5585,7 +5585,7 @@ prompt_setcallback({buf}, {expr}) *prompt_setcallback()* stopinsert close else - call append(line('$') - 1, 'Entered: "' . a:text . '"') + call append(line('$') - 1, 'Entered: "' .. a:text .. '"') " Reset 'modified' to allow the buffer to be closed. set nomodified endif @@ -5732,7 +5732,7 @@ readdir({directory} [, {expr}]) function! s:tree(dir) return {a:dir : map(readdir(a:dir), \ {_, x -> isdirectory(x) ? - \ {x : s:tree(a:dir . '/' . x)} : x})} + \ {x : s:tree(a:dir .. '/' .. x)} : x})} endfunction echo s:tree(".") < @@ -5920,7 +5920,7 @@ remote_peek({serverid} [, {retvar}]) *remote_peek()* This function is not available in the |sandbox|. Examples: > :let repl = "" - :echo "PEEK: ".remote_peek(id, "repl").": ".repl + :echo "PEEK: " .. remote_peek(id, "repl") .. ": " .. repl remote_read({serverid}, [{timeout}]) *remote_read()* Return the oldest available reply from {serverid} and consume @@ -5950,12 +5950,12 @@ remote_send({server}, {string} [, {idvar}]) Note: Any errors will be reported in the server and may mess up the display. Examples: > - :echo remote_send("gvim", ":DropAndReply ".file, "serverid"). + :echo remote_send("gvim", ":DropAndReply " .. file, "serverid") .. \ remote_read(serverid) :autocmd NONE RemoteReply * \ echo remote_read(expand("")) - :echo remote_send("gvim", ":sleep 10 | echo ". + :echo remote_send("gvim", ":sleep 10 | echo " .. \ 'server2client(expand(""), "HELLO")') < *remote_startserver()* *E941* *E942* @@ -5972,7 +5972,7 @@ remove({list}, {idx} [, {end}]) *remove()* points to an item before {idx} this is an error. See |list-index| for possible values of {idx} and {end}. Example: > - :echo "last item: " . remove(mylist, -1) + :echo "last item: " .. remove(mylist, -1) :call remove(mylist, 0, 9) < Use |delete()| to remove a file. @@ -5988,13 +5988,13 @@ remove({blob}, {idx} [, {end}]) byte as {end} a |Blob| with one byte is returned. When {end} points to a byte before {idx} this is an error. Example: > - :echo "last byte: " . remove(myblob, -1) + :echo "last byte: " .. remove(myblob, -1) :call remove(mylist, 0, 9) remove({dict}, {key}) Remove the entry from {dict} with key {key} and return it. Example: > - :echo "removed " . remove(dict, "one") + :echo "removed " .. remove(dict, "one") < If there is no {key} in {dict} this is an error. rename({from}, {to}) *rename()* @@ -6135,7 +6135,7 @@ screencol() *screencol()* column inside the command line, which is 1 when the command is executed. To get the cursor position in the file use one of the following mappings: > - nnoremap GG ":echom ".screencol()."\n" + nnoremap GG ":echom " .. screencol() .. "\n" nnoremap GG :echom screencol() noremap GG echom screencol() < @@ -6256,7 +6256,7 @@ search({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]]) Example (goes over all files in the argument list): > :let n = 1 :while n <= argc() " loop over all files in arglist - : exe "argument " . n + : exe "argument " .. n : " start at the last char in the file and wrap for the : " first search to find match at start of file : normal G$ @@ -6340,11 +6340,11 @@ searchcount([{options}]) *searchcount()* return printf(' /%s [%d/%d]', @/, \ result.current, result.total) endfunction - let &statusline .= '%{LastSearchCount()}' + let &statusline ..= '%{LastSearchCount()}' " Or if you want to show the count only when " 'hlsearch' was on - " let &statusline .= + " let &statusline ..= " \ '%{v:hlsearch ? LastSearchCount() : ""}' < You can also update the search count, which can be useful in a @@ -7146,10 +7146,10 @@ shellescape({string} [, {special}]) *shellescape()* inside single quotes. Example of use with a |:!| command: > - :exe '!dir ' . shellescape(expand(''), 1) + :exe '!dir ' .. shellescape(expand(''), 1) < This results in a directory listing for the file under the cursor. Example of use with |system()|: > - :call system("chmod +w -- " . shellescape(expand("%"))) + :call system("chmod +w -- " .. shellescape(expand("%"))) < See also |::S|. Can also be used as a |method|: > @@ -7841,7 +7841,7 @@ substitute({string}, {pat}, {sub}, {flags}) *substitute()* When {sub} starts with "\=", the remainder is interpreted as an expression. See |sub-replace-expression|. Example: > :echo substitute(s, '%\(\x\x\)', - \ '\=nr2char("0x" . submatch(1))', 'g') + \ '\=nr2char("0x" .. submatch(1))', 'g') < When {sub} is a Funcref that function is called, with one optional argument. Example: > @@ -7849,7 +7849,7 @@ substitute({string}, {pat}, {sub}, {flags}) *substitute()* < The optional argument is a list which contains the whole matched string and up to nine submatches, like what |submatch()| returns. Example: > - :echo substitute(s, '%\(\x\x\)', {m -> '0x' . m[1]}, 'g') + :echo substitute(s, '%\(\x\x\)', {m -> '0x' .. m[1]}, 'g') < Can also be used as a |method|: > GetString()->substitute(pat, sub, flags) @@ -8167,7 +8167,7 @@ tempname() *tempname()* *temp-file-name* The result is a String, which is the name of a file that doesn't exist. It can be used for a temporary file. Example: > :let tmpfile = tempname() - :exe "redir > " . tmpfile + :exe "redir > " .. tmpfile < For Unix, the file will be in a private directory |tempfile|. For MS-Windows forward slashes are used when the 'shellslash' option is set or when 'shellcmdflag' starts with '-'. @@ -8343,7 +8343,7 @@ trim({text} [, {mask} [, {dir}]]) *trim()* Examples: > echo trim(" some text ") < returns "some text" > - echo trim(" \r\t\t\r RESERVE \t\n\x0B\xA0") . "_TAIL" + echo trim(" \r\t\t\r RESERVE \t\n\x0B\xA0") .. "_TAIL" < returns "RESERVE_TAIL" > echo trim("rmX>rrm", "rm<>") < returns "Xrm<>X" (characters in the middle are not removed) > @@ -8521,7 +8521,7 @@ visualmode([{expr}]) *visualmode()* character-wise, line-wise, or block-wise Visual mode respectively. Example: > - :exe "normal " . visualmode() + :exe "normal " .. visualmode() < This enters the same Visual mode as before. It is also useful in scripts if you wish to act differently depending on the Visual mode that was used. @@ -8708,7 +8708,7 @@ winbufnr({nr}) The result is a Number, which is the number of the buffer window is returned. When window {nr} doesn't exist, -1 is returned. Example: > - :echo "The file in the current window is " . bufname(winbufnr(0)) + :echo "The file in the current window is " .. bufname(winbufnr(0)) < Can also be used as a |method|: > FindWindow()->winbufnr()->bufname() @@ -8733,7 +8733,7 @@ winheight({nr}) *winheight()* An existing window always has a height of zero or more. This excludes any window toolbar line. Examples: > - :echo "The current window has " . winheight(0) . " lines." + :echo "The current window has " .. winheight(0) .. " lines." < Can also be used as a |method|: > GetWinid()->winheight() @@ -8870,7 +8870,7 @@ winwidth({nr}) *winwidth()* returned. When window {nr} doesn't exist, -1 is returned. An existing window always has a width of zero or more. Examples: > - :echo "The current window has " . winwidth(0) . " columns." + :echo "The current window has " .. winwidth(0) .. " columns." :if winwidth(0) <= 50 : 50 wincmd | :endif diff --git a/runtime/doc/change.txt b/runtime/doc/change.txt index b4d3304880..b170f7cf65 100644 --- a/runtime/doc/change.txt +++ b/runtime/doc/change.txt @@ -906,7 +906,7 @@ Consider using a character like "@" or ":". There is no problem if the result of the expression contains the separation character. Examples: > - :s@\n@\="\r" . expand("$HOME") . "\r"@ + :s@\n@\="\r" .. expand("$HOME") .. "\r"@ This replaces an end-of-line with a new line containing the value of $HOME. > s/E/\="\"/g @@ -1065,7 +1065,7 @@ inside of strings can change! Also see 'softtabstop' option. > the command. You need to escape the '|' and '"' characters to prevent them from terminating the command. Example: > - :put ='path' . \",/test\" + :put ='path' .. \",/test\" < If there is no expression after '=', Vim uses the previous expression. You can see it with ":dis =". diff --git a/runtime/doc/cmdline.txt b/runtime/doc/cmdline.txt index f2f6ebb2c9..c6e4bf003f 100644 --- a/runtime/doc/cmdline.txt +++ b/runtime/doc/cmdline.txt @@ -207,7 +207,7 @@ CTRL-\ e {expr} *c_CTRL-\_e* Example: > :cmap eAppendSome() :func AppendSome() - :let cmd = getcmdline() . " Some()" + :let cmd = getcmdline() .. " Some()" :" place the cursor on the ) :call setcmdpos(strlen(cmd)) :return cmd diff --git a/runtime/doc/diff.txt b/runtime/doc/diff.txt index abe99102ee..9c5792dd43 100644 --- a/runtime/doc/diff.txt +++ b/runtime/doc/diff.txt @@ -371,13 +371,13 @@ Example (this does almost the same as 'diffexpr' being empty): > function MyDiff() let opt = "" if &diffopt =~ "icase" - let opt = opt . "-i " + let opt = opt .. "-i " endif if &diffopt =~ "iwhite" - let opt = opt . "-b " + let opt = opt .. "-b " endif - silent execute "!diff -a --binary " . opt . v:fname_in . " " . v:fname_new . - \ " > " . v:fname_out + silent execute "!diff -a --binary " .. opt .. v:fname_in .. " " .. v:fname_new .. + \ " > " .. v:fname_out redraw! endfunction @@ -427,8 +427,8 @@ Example (this does the same as 'patchexpr' being empty): > set patchexpr=MyPatch() function MyPatch() - :call system("patch -o " . v:fname_out . " " . v:fname_in . - \ " < " . v:fname_diff) + :call system("patch -o " .. v:fname_out .. " " .. v:fname_in .. + \ " < " .. v:fname_diff) endfunction Make sure that using the "patch" program doesn't have unwanted side effects. diff --git a/runtime/doc/editing.txt b/runtime/doc/editing.txt index 4ccf3f145c..bfa01f45a7 100644 --- a/runtime/doc/editing.txt +++ b/runtime/doc/editing.txt @@ -411,9 +411,9 @@ does apply like to other wildcards. Environment variables in the expression are expanded when evaluating the expression, thus this works: > - :e `=$HOME . '/.vimrc'` + :e `=$HOME .. '/.vimrc'` This does not work, $HOME is inside a string and used literally: > - :e `='$HOME' . '/.vimrc'` + :e `='$HOME' .. '/.vimrc'` If the expression returns a string then names are to be separated with line breaks. When the result is a |List| then each item is used as a name. Line diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index fc422f13e5..3015e232a7 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -402,7 +402,7 @@ It is also possible to put remaining items in a List variable: > :for [i, j; rest] in listlist : call Doit(i, j) : if !empty(rest) - : echo "remainder: " . string(rest) + : echo "remainder: " .. string(rest) : endif :endfor @@ -430,11 +430,11 @@ Functions that are useful with a List: > :let list = split("a b c") " create list from items in a string :let string = join(list, ', ') " create string from list items :let s = string(list) " String representation of list - :call map(list, '">> " . v:val') " prepend ">> " to each item + :call map(list, '">> " .. v:val') " prepend ">> " to each item Don't forget that a combination of features can make things simple. For example, to add up all the numbers in a list: > - :exe 'let sum = ' . join(nrlist, '+') + :exe 'let sum = ' .. join(nrlist, '+') 1.4 Dictionaries ~ @@ -496,7 +496,7 @@ turn the Dictionary into a List and pass it to |:for|. Most often you want to loop over the keys, using the |keys()| function: > :for key in keys(mydict) - : echo key . ': ' . mydict[key] + : echo key .. ': ' .. mydict[key] :endfor The List of keys is unsorted. You may want to sort them first: > @@ -504,13 +504,13 @@ The List of keys is unsorted. You may want to sort them first: > To loop over the values use the |values()| function: > :for v in values(mydict) - : echo "value: " . v + : echo "value: " .. v :endfor If you want both the key and the value use the |items()| function. It returns a List in which each item is a List with two items, the key and the value: > :for [key, value] in items(mydict) - : echo key . ': ' . value + : echo key .. ': ' .. value :endfor @@ -605,7 +605,7 @@ Functions that can be used with a Dictionary: > :let small = min(dict) " minimum value in dict :let xs = count(dict, 'x') " count nr of times 'x' appears in dict :let s = string(dict) " String representation of dict - :call map(dict, '">> " . v:val') " prepend ">> " to each item + :call map(dict, '">> " .. v:val') " prepend ">> " to each item 1.5 Blobs ~ @@ -840,7 +840,7 @@ Example: > All expressions within one level are parsed from left to right. -expr1 *expr1* *trinary* *E109* +expr1 *expr1* *ternary* *E109* ----- expr2 ? expr1 : expr1 @@ -1362,7 +1362,7 @@ option *expr-option* *E112* *E113* &l:option local option value Examples: > - echo "tabstop is " . &tabstop + echo "tabstop is " .. &tabstop if &insertmode Any option name can be used here. See |options|. When using the local value @@ -1637,7 +1637,7 @@ maintain a counter: > echo "script executed for the first time" else let s:counter = s:counter + 1 - echo "script executed " . s:counter . " times now" + echo "script executed " .. s:counter .. " times now" endif Note that this means that filetype plugins don't get a different set of script @@ -1736,7 +1736,7 @@ v:completed_item *v:count* *count-variable* v:count The count given for the last Normal mode command. Can be used to get the count before a mapping. Read-only. Example: > - :map _x :echo "the count is " . v:count + :map _x :echo "the count is " .. v:count < Note: The is required to remove the line range that you get when typing ':' after a count. When there are two counts, as in "3d2w", they are multiplied, @@ -2531,9 +2531,9 @@ Example: > : echohl Title : echo a:title : echohl None - : echo a:0 . " items:" + : echo a:0 .. " items:" : for s in a:000 - : echon ' ' . s + : echon ' ' .. s : endfor :endfunction @@ -2572,7 +2572,7 @@ This function can then be called with: > this works: *function-range-example* > :function Mynumber(arg) - : echo line(".") . " " . a:arg + : echo line(".") .. " " .. a:arg :endfunction :1,5call Mynumber(getline(".")) < @@ -2583,7 +2583,7 @@ This function can then be called with: > Example of a function that handles the range itself: > :function Cont() range - : execute (a:firstline + 1) . "," . a:lastline . 's/^/\t\\ ' + : execute (a:firstline + 1) .. "," .. a:lastline .. 's/^/\t\\ ' :endfunction :4,8call Cont() < @@ -2745,7 +2745,7 @@ This does NOT work: > This cannot be used to add an item to a |List|. This cannot be used to set a byte in a String. You can do that like this: > - :let var = var[0:2] . 'X' . var[4:] + :let var = var[0:2] .. 'X' .. var[4:] < When {var-name} is a |Blob| then {idx} can be the length of the blob, in which case one byte is appended. @@ -2807,7 +2807,7 @@ This does NOT work: > is just like using the |:set| command: both the local value and the global value are changed. Example: > - :let &path = &path . ',/usr/local/include' + :let &path = &path .. ',/usr/local/include' :let &{option-name} .= {expr1} For a string option: Append {expr1} to the value. @@ -3064,6 +3064,8 @@ text... :if {expr1} *:if* *:end* *:endif* *:en* *E171* *E579* *E580* :en[dif] Execute the commands until the next matching ":else" or ":endif" if {expr1} evaluates to non-zero. + Although the short forms work, it is recommended to + always use `:endif` to avoid confusion. From Vim version 4.5 until 5.0, every Ex command in between the ":if" and ":endif" is ignored. These two @@ -3661,7 +3663,7 @@ exception most recently caught as long it is not finished. :function! Caught() : if v:exception != "" - : echo 'Caught "' . v:exception . '" in ' . v:throwpoint + : echo 'Caught "' .. v:exception .. '" in ' .. v:throwpoint : else : echo 'Nothing caught' : endif @@ -4064,8 +4066,8 @@ a script in order to catch unexpected things. :catch /^Vim:Interrupt$/ : echo "Script interrupted" :catch /.*/ - : echo "Internal error (" . v:exception . ")" - : echo " - occurred at " . v:throwpoint + : echo "Internal error (" .. v:exception .. ")" + : echo " - occurred at " .. v:throwpoint :endtry :" end of script @@ -4261,7 +4263,7 @@ parentheses can be cut out from |v:exception| with the ":substitute" command. :function! CheckRange(a, func) : if a:a < 0 - : throw "EXCEPT:MATHERR:RANGE(" . a:func . ")" + : throw "EXCEPT:MATHERR:RANGE(" .. a:func .. ")" : endif :endfunction : @@ -4288,7 +4290,7 @@ parentheses can be cut out from |v:exception| with the ":substitute" command. : try : execute "write" fnameescape(a:file) : catch /^Vim(write):/ - : throw "EXCEPT:IO(" . getcwd() . ", " . a:file . "):WRITEERR" + : throw "EXCEPT:IO(" .. getcwd() .. ", " .. a:file .. "):WRITEERR" : endtry :endfunction : @@ -4307,9 +4309,9 @@ parentheses can be cut out from |v:exception| with the ":substitute" command. : let dir = substitute(v:exception, '.*(\(.\+\),\s*.\+).*', '\1', "") : let file = substitute(v:exception, '.*(.\+,\s*\(.\+\)).*', '\1', "") : if file !~ '^/' - : let file = dir . "/" . file + : let file = dir .. "/" .. file : endif - : echo 'I/O error for "' . file . '"' + : echo 'I/O error for "' .. file .. '"' : :catch /^EXCEPT/ : echo "Unspecified error" @@ -4377,7 +4379,7 @@ clauses, however, is executed. : echo "inner finally" : endtry :catch - : echo 'outer catch-all caught "' . v:exception . '"' + : echo 'outer catch-all caught "' .. v:exception .. '"' : finally : echo "outer finally" :endtry @@ -4439,7 +4441,7 @@ Printing in Binary ~ : let n = a:nr : let r = "" : while n - : let r = '01'[n % 2] . r + : let r = '01'[n % 2] .. r : let n = n / 2 : endwhile : return r @@ -4450,7 +4452,7 @@ Printing in Binary ~ :func String2Bin(str) : let out = '' : for ix in range(strlen(a:str)) - : let out = out . '-' . Nr2Bin(char2nr(a:str[ix])) + : let out = out .. '-' .. Nr2Bin(char2nr(a:str[ix])) : endfor : return out[1:] :endfunc diff --git a/runtime/doc/fold.txt b/runtime/doc/fold.txt index 8bc47a3b10..9e3d78faff 100644 --- a/runtime/doc/fold.txt +++ b/runtime/doc/fold.txt @@ -497,7 +497,7 @@ Note the use of backslashes to avoid some characters to be interpreted by the :function MyFoldText() : let line = getline(v:foldstart) : let sub = substitute(line, '/\*\|\*/\|{{{\d\=', '', 'g') - : return v:folddashes . sub + : return v:folddashes .. sub :endfunction Evaluating 'foldtext' is done in the |sandbox|. The current window is set to diff --git a/runtime/doc/ft_raku.txt b/runtime/doc/ft_raku.txt index 00b140ee9c..3d1179ed4e 100644 --- a/runtime/doc/ft_raku.txt +++ b/runtime/doc/ft_raku.txt @@ -47,20 +47,20 @@ Numbers, subscripts and superscripts are available with 's' and 'S': But some don't come defined by default. Those are digraph definitions you can add in your ~/.vimrc file. > - exec 'digraph \\ '.char2nr('∖') - exec 'digraph \< '.char2nr('≼') - exec 'digraph \> '.char2nr('≽') - exec 'digraph (L '.char2nr('⊈') - exec 'digraph )L '.char2nr('⊉') - exec 'digraph (/ '.char2nr('⊄') - exec 'digraph )/ '.char2nr('⊅') - exec 'digraph )/ '.char2nr('⊅') - exec 'digraph U+ '.char2nr('⊎') - exec 'digraph 0- '.char2nr('⊖') + exec 'digraph \\ ' .. char2nr('∖') + exec 'digraph \< ' .. char2nr('≼') + exec 'digraph \> ' .. char2nr('≽') + exec 'digraph (L ' .. char2nr('⊈') + exec 'digraph )L ' .. char2nr('⊉') + exec 'digraph (/ ' .. char2nr('⊄') + exec 'digraph )/ ' .. char2nr('⊅') + exec 'digraph )/ ' .. char2nr('⊅') + exec 'digraph U+ ' .. char2nr('⊎') + exec 'digraph 0- ' .. char2nr('⊖') " Euler's constant - exec 'digraph ne '.char2nr('𝑒') + exec 'digraph ne ' .. char2nr('𝑒') " Raku's atomic operations marker - exec 'digraph @@ '.char2nr('⚛') + exec 'digraph @@ ' .. char2nr('⚛') Alternatively, you can write Insert mode abbreviations that convert ASCII- based operators into their single-character Unicode equivalent. > diff --git a/runtime/doc/ft_rust.txt b/runtime/doc/ft_rust.txt index ff2e0ca56f..5c8782ec7a 100644 --- a/runtime/doc/ft_rust.txt +++ b/runtime/doc/ft_rust.txt @@ -26,7 +26,7 @@ behavior of the plugin. g:rustc_path~ Set this option to the path to rustc for use in the |:RustRun| and |:RustExpand| commands. If unset, "rustc" will be located in $PATH: > - let g:rustc_path = $HOME."/bin/rustc" + let g:rustc_path = $HOME .. "/bin/rustc" < *g:rustc_makeprg_no_percent* @@ -87,7 +87,7 @@ g:rust_bang_comment_leader~ g:ftplugin_rust_source_path~ Set this option to a path that should be prepended to 'path' for Rust source files: > - let g:ftplugin_rust_source_path = $HOME.'/dev/rust' + let g:ftplugin_rust_source_path = $HOME .. '/dev/rust' < *g:rustfmt_command* diff --git a/runtime/doc/ft_sql.txt b/runtime/doc/ft_sql.txt index 53a99a9e1d..fccbbce17f 100644 --- a/runtime/doc/ft_sql.txt +++ b/runtime/doc/ft_sql.txt @@ -109,8 +109,8 @@ must be configurable. The filetype plugin attempts to define many of the standard objects, plus many additional ones. In order to make this as flexible as possible, you can override the list of objects from within your |vimrc| with the following: > - let g:ftplugin_sql_objects = 'function,procedure,event,table,trigger' . - \ ',schema,service,publication,database,datatype,domain' . + let g:ftplugin_sql_objects = 'function,procedure,event,table,trigger' .. + \ ',schema,service,publication,database,datatype,domain' .. \ ',index,subscription,synchronization,view,variable' The following |Normal| mode and |Visual| mode maps have been created which use @@ -131,10 +131,10 @@ Repeatedly pressing ]} will cycle through each of these create statements: > create index i1 on t1 (c1); The default setting for g:ftplugin_sql_objects is: > - let g:ftplugin_sql_objects = 'function,procedure,event,' . - \ '\\(existing\\\\|global\\s\\+temporary\\s\\+\\)\\\{,1}' . - \ 'table,trigger' . - \ ',schema,service,publication,database,datatype,domain' . + let g:ftplugin_sql_objects = 'function,procedure,event,' .. + \ '\\(existing\\\\|global\\s\\+temporary\\s\\+\\)\\\{,1}' .. + \ 'table,trigger' .. + \ ',schema,service,publication,database,datatype,domain' .. \ ',index,subscription,synchronization,view,variable' The above will also handle these cases: > diff --git a/runtime/doc/if_pyth.txt b/runtime/doc/if_pyth.txt index afdf039aa8..9b434e61d7 100644 --- a/runtime/doc/if_pyth.txt +++ b/runtime/doc/if_pyth.txt @@ -658,7 +658,7 @@ To see what version of Python is being used: > *has-pythonx* To check if `pyx*` functions and commands are available: > if has('pythonx') - echo 'pyx* commands are available. (Python ' . &pyx . ')' + echo 'pyx* commands are available. (Python ' .. &pyx .. ')' endif ============================================================================== diff --git a/runtime/doc/insert.txt b/runtime/doc/insert.txt index ae2b9c4418..39682a2ab2 100644 --- a/runtime/doc/insert.txt +++ b/runtime/doc/insert.txt @@ -864,7 +864,7 @@ Groß): > else let res = [] let h = '' - for l in split(system('aiksaurus '.shellescape(a:base)), '\n') + for l in split(system('aiksaurus ' .. shellescape(a:base)), '\n') if l[:3] == '=== ' let h = substitute(l[4:], ' =*$', '', '') elseif l[0] =~ '\a' @@ -1199,7 +1199,7 @@ An example that completes the names of the months: > " find months matching with "a:base" let res = [] for m in split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec") - if m =~ '^' . a:base + if m =~ '^' .. a:base call add(res, m) endif endfor @@ -1221,7 +1221,7 @@ The same, but now pretending searching for matches is slow: > else " find months matching with "a:base" for m in split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec") - if m =~ '^' . a:base + if m =~ '^' .. a:base call complete_add(m) endif sleep 300m " simulate searching for next match diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt index 358e944261..0a44ee2418 100644 --- a/runtime/doc/map.txt +++ b/runtime/doc/map.txt @@ -285,7 +285,7 @@ Here is an example that inserts a list number that increases: > func ListItem() let g:counter += 1 - return g:counter . '. ' + return g:counter .. '. ' endfunc func ListReset() @@ -1489,12 +1489,12 @@ The valid escape sequences are Examples: > command! -nargs=+ -complete=file MyEdit \ for f in expand(, 0, 1) | - \ exe ' split ' . f | + \ exe ' split ' .. f | \ endfor function! SpecialEdit(files, mods) for f in expand(a:files, 0, 1) - exe a:mods . ' split ' . f + exe a:mods .. ' split ' .. f endfor endfunction command! -nargs=+ -complete=file Sedit @@ -1570,7 +1570,7 @@ This will invoke: > : let i = 0 : while i < argc() : if filereadable(argv(i)) - : execute "e " . argv(i) + : execute "e " .. argv(i) : execute a:command : endif : let i = i + 1 diff --git a/runtime/doc/motion.txt b/runtime/doc/motion.txt index c473244827..20033bd76a 100644 --- a/runtime/doc/motion.txt +++ b/runtime/doc/motion.txt @@ -993,7 +993,7 @@ These commands are not marks themselves, but jump to a mark: :let lnum = line(".") :keepjumps normal gg :call SetLastChange() - :keepjumps exe "normal " . lnum . "G" + :keepjumps exe "normal " .. lnum .. "G" < Note that ":keepjumps" must be used for every command. When invoking a function the commands in that function diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 2f76cc018c..56c65394f3 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -897,7 +897,7 @@ A jump table for the options with a short description can be found at |Q_op|. If you like to keep a lot of backups, you could use a BufWritePre autocommand to change 'backupext' just before writing the file to include a timestamp. > - :au BufWritePre * let &bex = '-' . strftime("%Y%b%d%X") . '~' + :au BufWritePre * let &bex = '-' .. strftime("%Y%b%d%X") .. '~' < Use 'backupdir' to put the backup in a different directory. *'backupskip'* *'bsk'* @@ -920,7 +920,7 @@ A jump table for the options with a short description can be found at |Q_op|. Note that environment variables are not expanded. If you want to use $HOME you must expand it explicitly, e.g.: > - :let backupskip = escape(expand('$HOME'), '\') . '/tmp/*' + :let backupskip = escape(expand('$HOME'), '\') .. '/tmp/*' < Note that the default also makes sure that "crontab -e" works (when a backup would be made by renaming the original file crontab won't see @@ -1185,7 +1185,7 @@ A jump table for the options with a short description can be found at |Q_op|. If the default value taken from $CDPATH is not what you want, include a modified version of the following command in your vimrc file to override it: > - :let &cdpath = ',' . substitute(substitute($CDPATH, '[, ]', '\\\0', 'g'), ':', ',', 'g') + :let &cdpath = ',' .. substitute(substitute($CDPATH, '[, ]', '\\\0', 'g'), ':', ',', 'g') < This option cannot be set from a |modeline| or in the |sandbox|, for security reasons. (parts of 'cdpath' can be passed to the shell to expand file names). @@ -1232,8 +1232,8 @@ A jump table for the options with a short description can be found at |Q_op|. set charconvert=CharConvert() fun CharConvert() system("recode " - \ . v:charconvert_from . ".." . v:charconvert_to - \ . " <" . v:fname_in . " >" v:fname_out) + \ .. v:charconvert_from .. ".." .. v:charconvert_to + \ .. " <" .. v:fname_in .. " >" .. v:fname_out) return v:shell_error endfun < The related Vim variables are: @@ -3620,7 +3620,7 @@ A jump table for the options with a short description can be found at |Q_op|. global Language to use for menu translation. Tells which file is loaded from the "lang" directory in 'runtimepath': > - "lang/menu_" . &langmenu . ".vim" + "lang/menu_" .. &langmenu .. ".vim" < (without the spaces). For example, to always use the Dutch menus, no matter what $LANG is set to: > :set langmenu=nl_NL.ISO_8859-1 @@ -4522,7 +4522,7 @@ A jump table for the options with a short description can be found at |Q_op|. < To use an environment variable, you probably need to replace the separator. Here is an example to append $INCL, in which directory names are separated with a semi-colon: > - :let &path = &path . "," . substitute($INCL, ';', ',', 'g') + :let &path = &path .. "," .. substitute($INCL, ';', ',', 'g') < Replace the ';' with a ':' or whatever separator is used. Note that this doesn't work when $INCL contains a comma or white space. @@ -6570,7 +6570,7 @@ A jump table for the options with a short description can be found at |Q_op|. This option cannot be set in a modeline when 'modelineexpr' is off. Example: > - :auto BufEnter * let &titlestring = hostname() . "/" . expand("%:p") + :auto BufEnter * let &titlestring = hostname() .. "/" .. expand("%:p") :set title titlestring=%<%F%=%l/%L-%P titlelen=70 < The value of 'titlelen' is used to align items in the middle or right of the available space. diff --git a/runtime/doc/pattern.txt b/runtime/doc/pattern.txt index 42005b0d78..c3bd5baff2 100644 --- a/runtime/doc/pattern.txt +++ b/runtime/doc/pattern.txt @@ -923,7 +923,7 @@ $ At end of pattern or in front of "\|", "\)" or "\n" ('magic' on): update the matches. This means Syntax highlighting quickly becomes wrong. Example, to highlight the line where the cursor currently is: > - :exe '/\%' . line(".") . 'l.*' + :exe '/\%' .. line(".") .. 'l.*' < When 'hlsearch' is set and you move the cursor around and make changes this will clearly show when the match is updated or not. @@ -939,7 +939,7 @@ $ At end of pattern or in front of "\|", "\)" or "\n" ('magic' on): update the matches. This means Syntax highlighting quickly becomes wrong. Example, to highlight the column where the cursor currently is: > - :exe '/\%' . col(".") . 'c' + :exe '/\%' .. col(".") .. 'c' < When 'hlsearch' is set and you move the cursor around and make changes this will clearly show when the match is updated or not. Example for matching a single byte in column 44: > diff --git a/runtime/doc/pi_netrw.txt b/runtime/doc/pi_netrw.txt index 3ac61be6f2..8257152b11 100644 --- a/runtime/doc/pi_netrw.txt +++ b/runtime/doc/pi_netrw.txt @@ -968,7 +968,7 @@ itself: fun! NetReadFixup(method, line1, line2) if method == 3 " ftp (no <.netrc>) let fourblanklines= line2 - 3 - silent fourblanklines.",".line2."g/^\s*/d" + silent fourblanklines .. "," .. line2 .. "g/^\s*/d" endif endfunction endif @@ -1975,7 +1975,7 @@ To use this function, simply assign its output to |g:netrw_list_hide| option. > Example: let g:netrw_list_hide= netrw_gitignore#Hide('my_gitignore_file') Function can take additional files with git-ignore patterns. - Example: g:netrw_list_hide= netrw_gitignore#Hide() . '.*\.swp$' + Example: let g:netrw_list_hide= netrw_gitignore#Hide() .. '.*\.swp$' Combining 'netrw_gitignore#Hide' with custom patterns. < @@ -2824,7 +2824,7 @@ your browsing preferences. (see also: |netrw-settings|) Examples: let g:netrw_list_hide= '.*\.swp$' - let g:netrw_list_hide= netrw_gitignore#Hide().'.*\.swp$' + let g:netrw_list_hide= netrw_gitignore#Hide() .. '.*\.swp$' default: "" *g:netrw_localcopycmd* ="cp" Linux/Unix/MacOS/Cygwin diff --git a/runtime/doc/print.txt b/runtime/doc/print.txt index f54d0429a6..924fab175e 100644 --- a/runtime/doc/print.txt +++ b/runtime/doc/print.txt @@ -127,21 +127,21 @@ file: > system(['lpr'] + (empty(&printdevice)?[]:['-P', &printdevice]) + [v:fname_in]) - . delete(v:fname_in) + .. delete(v:fname_in) + v:shell_error On MS-Dos and MS-Windows machines the default is to copy the file to the currently specified printdevice: > system(['copy', v:fname_in, empty(&printdevice)?'LPT1':&printdevice]) - . delete(v:fname_in) + .. delete(v:fname_in) If you change this option, using a function is an easy way to avoid having to escape all the spaces. Example: > :set printexpr=PrintFile(v:fname_in) :function PrintFile(fname) - : call system("ghostview " . a:fname) + : call system("ghostview " .. a:fname) : call delete(a:fname) : return v:shell_error :endfunc diff --git a/runtime/doc/quickfix.txt b/runtime/doc/quickfix.txt index 5b68da8be9..601384a71f 100644 --- a/runtime/doc/quickfix.txt +++ b/runtime/doc/quickfix.txt @@ -341,7 +341,7 @@ processing a quickfix or location list command, it will be aborted. cursor position will not be changed. See |:cexpr| for more information. Example: > - :g/mypattern/caddexpr expand("%") . ":" . line(".") . ":" . getline(".") + :g/mypattern/caddexpr expand("%") .. ":" .. line(".") .. ":" .. getline(".") < *:lad* *:addd* *:laddexpr* :lad[dexpr] {expr} Same as ":caddexpr", except the location list for the @@ -641,6 +641,24 @@ quickfix window. If there already is a window for that file, it is used instead. If the buffer in the used window has changed, and the error is in another file, jumping to the error will fail. You will first have to make sure the window contains a buffer which can be abandoned. + +The following steps are used to find a window to open the file selected from +the quickfix window: +1. If 'switchbuf' contains "usetab", then find a window in any tabpage + (starting with the first tabpage) that has the selected file and jump to + it. +2. Otherwise find a window displaying the selected file in the current tab + page (starting with the window before the quickfix window) and use it. +3. Otherwise find a window displaying a normal buffer ('buftype' is empty) + starting with the window before the quickfix window. If a window is found, + open the file in that window. +4. If a usable window is not found and 'switchbuf' contains "uselast", then + open the file in the last used window. +5. Otherwise open the file in the window before the quickfix window. If there + is no previous window, then open the file in the next window. +6. If a usable window is not found in the above steps, then create a new + horizontally split window above the quickfix window and open the file. + *CTRL-W_* *CTRL-W_* You can use CTRL-W to open a new window and jump to the error there. @@ -650,7 +668,7 @@ FileType event (also see |qf.vim|). Then the BufReadPost event is triggered, using "quickfix" for the buffer name. This can be used to perform some action on the listed errors. Example: > au BufReadPost quickfix setlocal modifiable - \ | silent exe 'g/^/s//\=line(".")." "/' + \ | silent exe 'g/^/s//\=line(".") .. " "/' \ | setlocal nomodifiable This prepends the line number to each line. Note the use of "\=" in the substitute string of the ":s" command, which is used to evaluate an diff --git a/runtime/doc/sign.txt b/runtime/doc/sign.txt index 5cfa06c33c..a2a5645baa 100644 --- a/runtime/doc/sign.txt +++ b/runtime/doc/sign.txt @@ -87,7 +87,7 @@ the delete is undone the sign does not move back. Here is an example that places a sign "piet", displayed with the text ">>", in line 23 of the current file: > :sign define piet text=>> texthl=Search - :exe ":sign place 2 line=23 name=piet file=" . expand("%:p") + :exe ":sign place 2 line=23 name=piet file=" .. expand("%:p") And here is the command to delete it again: > :sign unplace 2 diff --git a/runtime/doc/spell.txt b/runtime/doc/spell.txt index 03c00c8495..bc45b0e511 100644 --- a/runtime/doc/spell.txt +++ b/runtime/doc/spell.txt @@ -120,8 +120,8 @@ zuG Undo |zW| and |zG|, remove the word from the internal rare as this is a fairly uncommon command and all intuitive commands for this are already taken. If you want you can add mappings with e.g.: > - nnoremap z? :exe ':spellrare ' . expand('') - nnoremap z/ :exe ':spellrare! ' . expand('') + nnoremap z? :exe ':spellrare ' .. expand('') + nnoremap z/ :exe ':spellrare! ' .. expand('') < |:spellundo|, |zuw|, or |zuW| can be used to undo this. :spellr[rare]! {word} Add {word} as a rare word to the internal word diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index 978142a1e0..1d3fa6c2ca 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -800,7 +800,7 @@ resulting file, when executed with a ":source" command: After restoring the Session, the full filename of your current Session is available in the internal variable |v:this_session|. An example mapping: > - :nmap :waexe "mksession! " . v:this_session:so ~/sessions/ + :nmap :waexe "mksession! " .. v:this_session:so ~/sessions/ This saves the current Session, and starts off the command to load another. A session includes all tab pages, unless "tabpages" was removed from diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt index 319a715e40..778f829a4e 100644 --- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -616,7 +616,7 @@ evaluate to get a unique string to append to each ID used in a given document, so that the full IDs will be unique even when combined with other content in a larger HTML document. Example, to append _ and the buffer number to each ID: > - :let g:html_id_expr = '"_".bufnr("%")' + :let g:html_id_expr = '"_" .. bufnr("%")' < To append a string "_mystring" to the end of each ID: > @@ -3550,8 +3550,8 @@ Do you want to draw with the mouse? Try the following: > :function! GetPixel() : let c = getline(".")[col(".") - 1] : echo c - : exe "noremap r".c - : exe "noremap r".c + : exe "noremap r" .. c + : exe "noremap r" .. c :endfunction :noremap :call GetPixel() :set guicursor=n:hor20 " to see the color beneath the cursor @@ -5363,9 +5363,9 @@ types.vim: *.[ch] And put these lines in your vimrc: > " load the types.vim highlighting file, if it exists - autocmd BufRead,BufNewFile *.[ch] let fname = expand(':p:h') . '/types.vim' + autocmd BufRead,BufNewFile *.[ch] let fname = expand(':p:h') .. '/types.vim' autocmd BufRead,BufNewFile *.[ch] if filereadable(fname) - autocmd BufRead,BufNewFile *.[ch] exe 'so ' . fname + autocmd BufRead,BufNewFile *.[ch] exe 'so ' .. fname autocmd BufRead,BufNewFile *.[ch] endif ============================================================================== diff --git a/runtime/doc/tabpage.txt b/runtime/doc/tabpage.txt index 7f91fda9f4..c5b61e3a35 100644 --- a/runtime/doc/tabpage.txt +++ b/runtime/doc/tabpage.txt @@ -366,24 +366,24 @@ pages and define labels for them. Then get the label for each tab page. > for i in range(tabpagenr('$')) " select the highlighting if i + 1 == tabpagenr() - let s .= '%#TabLineSel#' + let s ..= '%#TabLineSel#' else - let s .= '%#TabLine#' + let s ..= '%#TabLine#' endif " set the tab page number (for mouse clicks) - let s .= '%' . (i + 1) . 'T' + let s ..= '%' .. (i + 1) .. 'T' " the label is made by MyTabLabel() - let s .= ' %{MyTabLabel(' . (i + 1) . ')} ' + let s ..= ' %{MyTabLabel(' .. (i + 1) .. ')} ' endfor " after the last tab fill with TabLineFill and reset tab page nr - let s .= '%#TabLineFill#%T' + let s ..= '%#TabLineFill#%T' " right-align the label to close the current tab page if tabpagenr('$') > 1 - let s .= '%=%#TabLine#%999Xclose' + let s ..= '%=%#TabLine#%999Xclose' endif return s @@ -446,14 +446,14 @@ windows in the tab page and a '+' if there is a modified buffer: > " Append the number of windows in the tab page if more than one let wincount = tabpagewinnr(v:lnum, '$') if wincount > 1 - let label .= wincount + let label ..= wincount endif if label != '' - let label .= ' ' + let label ..= ' ' endif " Append the buffer name - return label . bufname(bufnrlist[tabpagewinnr(v:lnum) - 1]) + return label .. bufname(bufnrlist[tabpagewinnr(v:lnum) - 1]) endfunction set guitablabel=%{GuiTabLabel()} diff --git a/runtime/doc/tagsrch.txt b/runtime/doc/tagsrch.txt index 4d938c4a23..5a0d16d6b8 100644 --- a/runtime/doc/tagsrch.txt +++ b/runtime/doc/tagsrch.txt @@ -705,7 +705,7 @@ matches the pattern "^# *define" it is not considered to be a comment. If you want to list matches, and then select one to jump to, you could use a mapping to do that for you. Here is an example: > - :map [I:let nr = input("Which one: ")exe "normal " . nr ."[\t" + :map [I:let nr = input("Which one: ")exe "normal " .. nr .. "[\t" < *[i* [i Display the first line that contains the keyword diff --git a/runtime/doc/term.txt b/runtime/doc/term.txt index 62e13285f5..f9b2271756 100644 --- a/runtime/doc/term.txt +++ b/runtime/doc/term.txt @@ -321,7 +321,7 @@ an #if/#else/#endif block, the selection becomes linewise. For MS-Windows and xterm the time for double clicking can be set with the 'mousetime' option. For the other systems this time is defined outside of Vim. An example, for using a double click to jump to the tag under the cursor: > - :map <2-LeftMouse> :exe "tag ". expand("") + :map <2-LeftMouse> :exe "tag " .. expand("") Dragging the mouse with a double click (button-down, button-up, button-down and then drag) will result in whole words to be selected. This continues diff --git a/runtime/doc/tips.txt b/runtime/doc/tips.txt index b77c7d9a6d..d913b53c6b 100644 --- a/runtime/doc/tips.txt +++ b/runtime/doc/tips.txt @@ -84,14 +84,14 @@ What you need: create it with the shell command "mkid file1 file2 ..". Put this in your |init.vim|: > - map _u :call ID_search()execute "/\\<" . g:word . "\\>" - map _n :nexecute "/\\<" . g:word . "\\>" + map _u :call ID_search()execute "/\\<" .. g:word .. "\\>" + map _n :nexecute "/\\<" .. g:word .. "\\>" function! ID_search() let g:word = expand("") - let x = system("lid --key=none ". g:word) + let x = system("lid --key=none " .. g:word) let x = substitute(x, "\n", " ", "g") - execute "next " . x + execute "next " .. x endfun To use it, place the cursor on a word, type "_u" and vim will load the file @@ -285,13 +285,13 @@ This mapping will format any bullet list. It requires that there is an empty line above and below each list entry. The expression commands are used to be able to give comments to the parts of the mapping. > - :let m = ":map _f :set ai" " need 'autoindent' set - :let m = m . "{O" " add empty line above item - :let m = m . "}{)^W" " move to text after bullet - :let m = m . "i " " add space for indent - :let m = m . "gq}" " format text after the bullet - :let m = m . "{dd" " remove the empty line - :let m = m . "5lDJ" " put text after bullet + :let m = ":map _f :set ai" " need 'autoindent' set + :let m ..= "{O" " add empty line above item + :let m ..= "}{)^W" " move to text after bullet + :let m ..= "i " " add space for indent + :let m ..= "gq}" " format text after the bullet + :let m ..= "{dd" " remove the empty line + :let m ..= "5lDJ" " put text after bullet :execute m |" define the mapping (<> notation |<>|. Note that this is all typed literally. ^W is "^" "W", not @@ -429,15 +429,15 @@ A slightly more advanced version is used in the |matchparen| plugin. let c = '\[' let c2 = '\]' endif - let s_skip ='synIDattr(synID(line("."), col("."), 0), "name") ' . + let s_skip ='synIDattr(synID(line("."), col("."), 0), "name") ' .. \ '=~? "string\\|comment"' execute 'if' s_skip '| let s_skip = 0 | endif' let [m_lnum, m_col] = searchpairpos(c, '', c2, s_flags, s_skip) if m_lnum > 0 && m_lnum >= line('w0') && m_lnum <= line('w$') - exe 'match Search /\(\%' . c_lnum . 'l\%' . c_col . - \ 'c\)\|\(\%' . m_lnum . 'l\%' . m_col . 'c\)/' + exe 'match Search /\(\%' .. c_lnum .. 'l\%' .. c_col .. + \ 'c\)\|\(\%' .. m_lnum .. 'l\%' .. m_col .. 'c\)/' let s:paren_hl_on = 1 endif endfunction diff --git a/runtime/doc/undo.txt b/runtime/doc/undo.txt index b11d7581ed..a853aea995 100644 --- a/runtime/doc/undo.txt +++ b/runtime/doc/undo.txt @@ -272,12 +272,12 @@ history file. E.g.: > au BufReadPost * call ReadUndo() au BufWritePost * call WriteUndo() func ReadUndo() - if filereadable(expand('%:h'). '/UNDO/' . expand('%:t')) + if filereadable(expand('%:h') .. '/UNDO/' .. expand('%:t')) rundo %:h/UNDO/%:t endif endfunc func WriteUndo() - let dirname = expand('%:h') . '/UNDO' + let dirname = expand('%:h') .. '/UNDO' if !isdirectory(dirname) call mkdir(dirname) endif diff --git a/runtime/doc/usr_05.txt b/runtime/doc/usr_05.txt index f93a221e43..b1ef563e43 100644 --- a/runtime/doc/usr_05.txt +++ b/runtime/doc/usr_05.txt @@ -131,7 +131,7 @@ it worked before Vim 5.0. Otherwise the "Q" command starts Ex mode, but you will not need it. > - vnoremap _g y:exe "grep /" . escape(@", '\\/') . "/ *.c *.h" + vnoremap _g y:exe "grep /" .. escape(@", '\\/') .. "/ *.c *.h" This mapping yanks the visually selected text and searches for it in C files. This is a complicated mapping. You can see that mappings can be used to do diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt index 38869f8e94..e1b87f60ad 100644 --- a/runtime/doc/various.txt +++ b/runtime/doc/various.txt @@ -275,7 +275,7 @@ g8 Print the hex values of the bytes used in the Special characters are not escaped, use quotes or |shellescape()|: > :!ls "%" - :exe "!ls " . shellescape(expand("%")) + :exe "!ls " .. shellescape(expand("%")) < Newline character ends {cmd} unless a backslash precedes the newline. What follows is interpreted as @@ -432,7 +432,7 @@ g8 Print the hex values of the bytes used in the used. In this example |:silent| is used to avoid the message about reading the file and |:unsilent| to be able to list the first line of each file. > - :silent argdo unsilent echo expand('%') . ": " . getline(1) + :silent argdo unsilent echo expand('%') .. ": " .. getline(1) < *:verb* *:verbose* diff --git a/runtime/doc/windows.txt b/runtime/doc/windows.txt index 5b91321c40..bd29cd1d7a 100644 --- a/runtime/doc/windows.txt +++ b/runtime/doc/windows.txt @@ -447,7 +447,7 @@ These commands can also be executed with ":wincmd": the |CursorHold| autocommand event). Or when a Normal mode command is inconvenient. The count can also be a window number. Example: > - :exe nr . "wincmd w" + :exe nr .. "wincmd w" < This goes to window "nr". ============================================================================== @@ -909,12 +909,12 @@ CTRL-W g } *CTRL-W_g}* cursor. This is less clever than using |:ptag|, but you don't need a tags file and it will also find matches in system include files. Example: > - :au! CursorHold *.[ch] ++nested exe "silent! psearch " . expand("") + :au! CursorHold *.[ch] ++nested exe "silent! psearch " .. expand("") < Warning: This can be slow. Example *CursorHold-example* > - :au! CursorHold *.[ch] ++nested exe "silent! ptag " . expand("") + :au! CursorHold *.[ch] ++nested exe "silent! ptag " .. expand("") This will cause a ":ptag" to be executed for the keyword under the cursor, when the cursor hasn't moved for the time set with 'updatetime'. "++nested" @@ -937,14 +937,14 @@ is no word under the cursor, and a few other things: > : : " Delete any existing highlight before showing another tag : silent! wincmd P " jump to preview window - : if &previewwindow " if we really get there... + : if &previewwindow " if we really get there... : match none " delete existing highlight : wincmd p " back to old window : endif : : " Try displaying a matching tag for the word under the cursor : try - : exe "ptag " . w + : exe "ptag " .. w : catch : return : endtry @@ -956,10 +956,10 @@ is no word under the cursor, and a few other things: > : endif : call search("$", "b") " to end of previous line : let w = substitute(w, '\\', '\\\\', "") - : call search('\<\V' . w . '\>') " position cursor on match + : call search('\<\V' .. w .. '\>') " position cursor on match : " Add a match highlight to the word at this position : hi previewWord term=bold ctermbg=green guibg=green - : exe 'match previewWord "\%' . line(".") . 'l\%' . col(".") . 'c\k*"' + : exe 'match previewWord "\%' .. line(".") .. 'l\%' .. col(".") .. 'c\k*"' : wincmd p " back to old window : endif : endif diff --git a/runtime/indent/vim.vim b/runtime/indent/vim.vim index 7c03ff2873..f5a94940bd 100644 --- a/runtime/indent/vim.vim +++ b/runtime/indent/vim.vim @@ -1,7 +1,7 @@ " Vim indent file " Language: Vim script " Maintainer: Bram Moolenaar -" Last Change: 2021 Nov 27 +" Last Change: 2022 Feb 23 " Only load this indent file when no other was loaded. if exists("b:did_indent") @@ -10,7 +10,7 @@ endif let b:did_indent = 1 setlocal indentexpr=GetVimIndent() -setlocal indentkeys+==end,=},=else,=cat,=finall,=END,0\\,0=\"\\\ +setlocal indentkeys+==endif,=enddef,=endfu,=endfor,=endwh,=endtry,=},=else,=cat,=finall,=END,0\\,0=\"\\\ setlocal indentkeys-=0# setlocal indentkeys-=: @@ -103,10 +103,11 @@ function GetVimIndentIntern() " A line starting with :au does not increment/decrement indent. " A { may start a block or a dict. Assume that when a } follows it's a " terminated dict. + " ":function" starts a block but "function(" doesn't. if prev_text !~ '^\s*au\%[tocmd]' && prev_text !~ '^\s*{.*}' - let i = match(prev_text, '\(^\||\)\s*\(export\s\+\)\?\({\|\(if\|wh\%[ile]\|for\|try\|cat\%[ch]\|fina\|finall\%[y]\|fu\%[nction]\|def\|el\%[seif]\)\>\)') + let i = match(prev_text, '\(^\||\)\s*\(export\s\+\)\?\({\|\(if\|wh\%[ile]\|for\|try\|cat\%[ch]\|fina\|finall\%[y]\|def\|el\%[seif]\)\>\|fu\%[nction]\s\)') if i >= 0 - let ind += shiftwidth() + let ind += shiftwidth() if strpart(prev_text, i, 1) == '|' && has('syntax_items') \ && synIDattr(synID(lnum, i, 1), "name") =~ '\(Comment\|String\|PatSep\)$' let ind -= shiftwidth() @@ -170,10 +171,15 @@ function GetVimIndentIntern() let ind = ind + shiftwidth() endif - " Subtract a 'shiftwidth' on a :endif, :endwhile, :catch, :finally, :endtry, - " :endfun, :else and :augroup END. - if cur_text =~ '^\s*\(ene\@!\|cat\|finall\|el\|aug\%[roup]\s\+[eE][nN][dD]\)' + " Subtract a 'shiftwidth' on a :endif, :endwhile, :endfor, :catch, :finally, + " :endtry, :endfun, :enddef, :else and :augroup END. + " Although ":en" would be enough only match short command names as in + " 'indentkeys'. + if cur_text =~ '^\s*\(endif\|endwh\|endfor\|endtry\|endfu\|enddef\|cat\|finall\|else\|aug\%[roup]\s\+[eE][nN][dD]\)' let ind = ind - shiftwidth() + if ind < 0 + let ind = 0 + endif endif return ind -- cgit From 1b5767aa3480c0cdc43f7a4b78f36a14e85a182f Mon Sep 17 00:00:00 2001 From: Javier Lopez Date: Sun, 27 Feb 2022 14:35:06 -0500 Subject: feat(lua): add to user commands callback (#17522) Works similar to ex . It only splits the arguments if the command has more than one posible argument. In cases were the command can only have 1 argument opts.fargs = { opts.args } --- runtime/doc/api.txt | 3 +++ 1 file changed, 3 insertions(+) (limited to 'runtime') diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index de7db3b0b7..cff616cf59 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -651,6 +651,9 @@ nvim_add_user_command({name}, {command}, {*opts}) that contains the following keys: • args: (string) The args passed to the command, if any || + • fargs: (table) The args split by unescaped + whitespace (when more than one argument is + allowed), if any || • bang: (boolean) "true" if the command was executed with a ! modifier || • line1: (number) The starting line of the -- cgit From ebfe083337701534887ac3ea3d8e7ad47f7a206a Mon Sep 17 00:00:00 2001 From: shadmansaleh <13149513+shadmansaleh@users.noreply.github.com> Date: Sat, 8 Jan 2022 00:39:44 +0600 Subject: feat(lua): show proper verbose output for lua configuration `:verbose` didn't work properly with lua configs (For example: options or keymaps are set from lua, just say that they were set from lua, doesn't say where they were set at. This fixes that issue. Now `:verbose` will provide filename and line no when option/keymap is set from lua. Changes: - compiles lua/vim/keymap.lua as vim/keymap.lua - When souring a lua file current_sctx.sc_sid is set to SID_LUA - Moved finding scripts SID out of `do_source()` to `get_current_script_id()`. So it can be reused for lua files. - Added new function `nlua_get_sctx` that extracts current lua scripts name and line no with debug library. And creates a sctx for it. NOTE: This function ignores C functions and blacklist which currently contains only vim/_meta.lua so vim.o/opt wrappers aren't targeted. - Added function `nlua_set_sctx` that changes provided sctx to current lua scripts sctx if a lua file is being executed. - Added tests in tests/functional/lua/verbose_spec.lua - add primary support for additional types (:autocmd, :function, :syntax) to lua verbose Note: These can't yet be directly set from lua but once that's possible :verbose should work for them hopefully :D - add :verbose support for nvim_exec & nvim_command within lua Currently auto commands/commands/functions ... can only be defined by nvim_exec/nvim_command this adds support for them. Means if those Are defined within lua with vim.cmd/nvim_exec :verbose will show their location . Though note it'll show the line no on which nvim_exec call was made. --- runtime/doc/options.txt | 4 ++-- runtime/doc/various.txt | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 56c65394f3..82214a2527 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -6716,8 +6716,8 @@ A jump table for the options with a short description can be found at |Q_op|. global When bigger than zero, Vim will give messages about what it is doing. Currently, these messages are given: - >= 1 When the shada file is read or written. - >= 2 When a file is ":source"'ed. + >= 1 Lua assignments to options,keymaps etc. + >= 2 When a file is ":source"'ed and when the shada file is read or written.. >= 3 UI info, terminal capabilities >= 4 Shell commands. >= 5 Every searched tags file and include file. diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt index e1b87f60ad..19e429fde2 100644 --- a/runtime/doc/various.txt +++ b/runtime/doc/various.txt @@ -461,10 +461,11 @@ g8 Print the hex values of the bytes used in the *:verbose-cmd* When 'verbose' is non-zero, listing the value of a Vim option or a key map or an abbreviation or a user-defined function or a command or a highlight group -or an autocommand will also display where it was last defined. If it was -defined manually then there will be no "Last set" message. When it was -defined while executing a function, user command or autocommand, the script in -which it was defined is reported. +or an autocommand will also display where it was last defined. If they were +defined in Lua they will only be located if 'verbose' is set. So Start +nvim with -V1 arg to see them. If it was defined manually then there +will be no "Last set" message. When it was defined while executing a function, +user command or autocommand, the script in which it was defined is reported. *K* [count]K Runs the program given by 'keywordprg' to lookup the -- cgit From 0f613482b389ad259dd53d893907b024a115352e Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Fri, 28 May 2021 15:45:34 -0400 Subject: feat(lua): add missing changes to autocmds lost in the rebase Note: some of these changes are breaking, like change of API signatures --- runtime/doc/api.txt | 124 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) (limited to 'runtime') diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index cff616cf59..fe5f9eaf35 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -3108,6 +3108,130 @@ nvim_tabpage_set_var({tabpage}, {name}, {value}) {value} Variable value +============================================================================== +Autocmd Functions *api-autocmd* + +nvim_create_augroup({name}, {*opts}) *nvim_create_augroup()* + Create or get an augroup. + + To get an existing augroup ID, do: > + local id = vim.api.nvim_create_augroup(name, { + clear = false + }) +< + + Parameters: ~ + {name} String: The name of the augroup to create + {opts} Parameters + • clear (bool): Whether to clear existing commands + or not. Defaults to true. See |autocmd-groups| + + Return: ~ + opaque value to use with nvim_del_augroup_by_id + +nvim_create_autocmd({event}, {*opts}) *nvim_create_autocmd()* + Create an autocmd. + + Examples: + • event: "pat1,pat2,pat3", + • event: "pat1" + • event: { "pat1" } + • event: { "pat1", "pat2", "pat3" } + + Parameters: ~ + {event} The event or events to register this autocmd + Required keys: event: string | ArrayOf(string) + + Parameters: ~ + {opts} Optional Parameters: + • callback: (string|function) + • (string): The name of the viml function to + execute when triggering this autocmd + • (function): The lua function to execute when + triggering this autocmd + • NOTE: Cannot be used with {command} + + • command: (string) command + • vimscript command + • NOTE: Cannot be used with {callback} Eg. + command = "let g:value_set = v:true" + + • pattern: (string|table) + • pattern or patterns to match against + • defaults to "*". + • NOTE: Cannot be used with {buffer} + + • buffer: (bufnr) + • create a |autocmd-buflocal| autocmd. + • NOTE: Cannot be used with {pattern} + + • group: (string) The augroup name + • once: (boolean) - See |autocmd-once| + • nested: (boolean) - See |autocmd-nested| + • desc: (string) - Description of the autocmd + + Return: ~ + opaque value to use with nvim_del_autocmd + +nvim_del_augroup_by_id({id}) *nvim_del_augroup_by_id()* + Delete an augroup by {id}. {id} can only be returned when + augroup was created with |nvim_create_augroup|. + + NOTE: behavior differs from augroup-delete. + + When deleting an augroup, autocmds contained by this augroup + will also be deleted and cleared. This augroup will no longer + exist + +nvim_del_augroup_by_name({name}) *nvim_del_augroup_by_name()* + Delete an augroup by {name}. + + NOTE: behavior differs from augroup-delete. + + When deleting an augroup, autocmds contained by this augroup + will also be deleted and cleared. This augroup will no longer + exist + +nvim_del_autocmd({id}) *nvim_del_autocmd()* + Delete an autocmd by {id}. Autocmds only return IDs when + created via the API. Will not error if called and no autocmds + match the {id}. + + Parameters: ~ + {id} Integer The ID returned by nvim_create_autocmd + +nvim_do_autocmd({event}, {*opts}) *nvim_do_autocmd()* + Do one autocmd. + + Parameters: ~ + {event} The event or events to execute + {opts} Optional Parameters: + • buffer (number) - buffer number + • NOTE: Cannot be used with {pattern} + + • pattern (string|table) - optional, defaults to + "*". + • NOTE: Cannot be used with {buffer} + + • group (string) - autocmd group name + • modeline (boolean) - Default true, see + || + +nvim_get_autocmds({*opts}) *nvim_get_autocmds()* + Get autocmds that match the requirements passed to {opts}. + + Parameters: ~ + {opts} Optional Parameters: + • event : Name or list of name of events to match + against + • group (string): Name of group to match against + • pattern: Pattern or list of patterns to match + against + + Return: ~ + A list of autocmds that match + + ============================================================================== UI Functions *api-ui* -- cgit From 0cb9a577edf04c9be25c6bd97a567e75283b4530 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 1 Mar 2022 09:27:36 +0800 Subject: docs: clarify actual behavior of --- runtime/doc/map.txt | 5 ++--- runtime/doc/vim_diff.txt | 7 ++++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt index 8d5449da0b..8715c3231c 100644 --- a/runtime/doc/map.txt +++ b/runtime/doc/map.txt @@ -65,9 +65,8 @@ modes. where the map command applies. Disallow mapping of {rhs}, to avoid nested and recursive mappings. Often used to redefine a command. - Note: "nore" is ignored for a mapping whose result - starts with . is always remapped even if - "nore" is used. + Note: A mapping whose {lhs} starts with is + always applied even if mapping is disallowed. :unm[ap] {lhs} |mapmode-nvo| *:unm* *:unmap* diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index d7a65756bf..90f56e2566 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -358,6 +358,10 @@ Macro/|recording| behavior macros and 'keymap' at the same time. This also means you can use |:imap| on the results of keys from 'keymap'. +Mappings: +- A mapping whose {lhs} starts with is always applied even if mapping + is disallowed by |nore|. + Motion: The |jumplist| avoids useless/phantom jumps. @@ -442,9 +446,6 @@ Working directory (Vim implemented some of these later than Nvim): - `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. -Mappings: -- |nore| is ignored for rhs mappings. mappings are always remapped. - ============================================================================== 5. Missing legacy features *nvim-features-missing* -- cgit From d477788cd5bfd36b6be88e4ea736e5053369252b Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Wed, 2 Mar 2022 14:33:02 -0500 Subject: fix(lsp): respect all of 'fixeol', 'eol', and 'binary' applying edits (#17574) --- runtime/lua/vim/lsp/util.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index 655c3a4679..59ab3d7e1f 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -480,7 +480,7 @@ function M.apply_text_edits(text_edits, bufnr, offset_encoding) -- Remove final line if needed local fix_eol = has_eol_text_edit - fix_eol = fix_eol and api.nvim_buf_get_option(bufnr, 'fixeol') + fix_eol = fix_eol and (api.nvim_buf_get_option(bufnr, 'eol') or (api.nvim_buf_get_option(bufnr, 'fixeol') and not api.nvim_buf_get_option('binary'))) fix_eol = fix_eol and get_line(bufnr, max - 1) == '' if fix_eol then vim.api.nvim_buf_set_lines(bufnr, -2, -1, false, {}) -- cgit From 5d6006f9bfc2f1f064adbcfa974da6976e867450 Mon Sep 17 00:00:00 2001 From: David Shen <17462095+mxteries@users.noreply.github.com> Date: Wed, 2 Mar 2022 20:42:27 -0500 Subject: feat(diagnostic): add "code" to the diagnostic structure (#17510) --- runtime/doc/diagnostic.txt | 10 ++++++---- runtime/lua/vim/lsp/diagnostic.lua | 6 +++++- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/diagnostic.txt b/runtime/doc/diagnostic.txt index 19db3158be..781539cfb6 100644 --- a/runtime/doc/diagnostic.txt +++ b/runtime/doc/diagnostic.txt @@ -39,16 +39,18 @@ modify the diagnostics for a buffer (e.g. |vim.diagnostic.set()|) then it requires a namespace. *diagnostic-structure* -A diagnostic is a Lua table with the following keys: +A diagnostic is a Lua table with the following keys. Required keys are +indicated with (*): bufnr: Buffer number - lnum: The starting line of the diagnostic + lnum(*): The starting line of the diagnostic end_lnum: The final line of the diagnostic - col: The starting column of the diagnostic + col(*): The starting column of the diagnostic end_col: The final column of the diagnostic severity: The severity of the diagnostic |vim.diagnostic.severity| - message: The diagnostic text + message(*): The diagnostic text source: The source of the diagnostic + code: The diagnostic code user_data: Arbitrary data plugins or users can add Diagnostics use the same indexing as the rest of the Nvim API (i.e. 0-based diff --git a/runtime/lua/vim/lsp/diagnostic.lua b/runtime/lua/vim/lsp/diagnostic.lua index 68942ae11a..614d83f565 100644 --- a/runtime/lua/vim/lsp/diagnostic.lua +++ b/runtime/lua/vim/lsp/diagnostic.lua @@ -104,8 +104,10 @@ local function diagnostic_lsp_to_vim(diagnostics, bufnr, client_id) severity = severity_lsp_to_vim(diagnostic.severity), message = diagnostic.message, source = diagnostic.source, + code = diagnostic.code, user_data = { lsp = { + -- usage of user_data.lsp.code is deprecated in favor of the top-level code field code = diagnostic.code, codeDescription = diagnostic.codeDescription, tags = diagnostic.tags, @@ -120,7 +122,8 @@ end ---@private local function diagnostic_vim_to_lsp(diagnostics) return vim.tbl_map(function(diagnostic) - return vim.tbl_extend("error", { + return vim.tbl_extend("keep", { + -- "keep" the below fields over any duplicate fields in diagnostic.user_data.lsp range = { start = { line = diagnostic.lnum, @@ -134,6 +137,7 @@ local function diagnostic_vim_to_lsp(diagnostics) severity = severity_vim_to_lsp(diagnostic.severity), message = diagnostic.message, source = diagnostic.source, + code = diagnostic.code, }, diagnostic.user_data and (diagnostic.user_data.lsp or {}) or {}) end, diagnostics) end -- cgit From e8107f07486ce9dffdc020baf12836e55bf90ce5 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 3 Mar 2022 21:59:28 +0800 Subject: vim-patch:8.2.4498: using with "noremap" does not work Problem: Using with "noremap" does not work. Solution: Always remap . (closes vim/vim#9879, closes vim/vim#9789) https://github.com/vim/vim/commit/1fc34225acbee5ddca2b9ec3f82b3014d385b7f8 --- runtime/doc/map.txt | 4 ++-- runtime/doc/vim_diff.txt | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt index 8715c3231c..b874d6dc61 100644 --- a/runtime/doc/map.txt +++ b/runtime/doc/map.txt @@ -65,8 +65,8 @@ modes. where the map command applies. Disallow mapping of {rhs}, to avoid nested and recursive mappings. Often used to redefine a command. - Note: A mapping whose {lhs} starts with is - always applied even if mapping is disallowed. + Note: When appears in the {rhs} this part is + always applied even if remapping is disallowed. :unm[ap] {lhs} |mapmode-nvo| *:unm* *:unmap* diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index 90f56e2566..5ea6a9c5dd 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -358,10 +358,6 @@ Macro/|recording| behavior macros and 'keymap' at the same time. This also means you can use |:imap| on the results of keys from 'keymap'. -Mappings: -- A mapping whose {lhs} starts with is always applied even if mapping - is disallowed by |nore|. - Motion: The |jumplist| avoids useless/phantom jumps. -- cgit From f9faba88fdc46b2dd1a979a37ba61b000830ff3a Mon Sep 17 00:00:00 2001 From: bfredl Date: Tue, 1 Mar 2022 14:27:19 +0100 Subject: refactor(lua): reorganize builtin modules, phase 1 --- runtime/lua/vim/_load_package.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'runtime') diff --git a/runtime/lua/vim/_load_package.lua b/runtime/lua/vim/_load_package.lua index 525f603438..59bca9b148 100644 --- a/runtime/lua/vim/_load_package.lua +++ b/runtime/lua/vim/_load_package.lua @@ -47,3 +47,6 @@ end -- Insert vim._load_package after the preloader at position 2 table.insert(package.loaders, 2, vim._load_package) + +-- should always be available +vim.inspect = require'vim.inspect' -- cgit From f89fb41a7a8b499159bfa44afa26dd17a845af45 Mon Sep 17 00:00:00 2001 From: Kirill Chibisov Date: Wed, 2 Mar 2022 00:48:11 +0300 Subject: feat(tui): add support for `CSI 4 : [2,4,5] m` This commit finishes support for colored and styled underlines adding `CSI 4 : [2,4,5] m` support providing double, dashed, and dotted underlines Fixes #17362. --- runtime/doc/builtin.txt | 5 ++++- runtime/doc/syntax.txt | 15 ++++++++++----- runtime/doc/ui.txt | 36 ++++++++++++++++++++++-------------- runtime/syntax/vim.vim | 2 +- 4 files changed, 37 insertions(+), 21 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 03a5f98c6d..b0859d1cea 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -7937,8 +7937,11 @@ synIDattr({synID}, {what} [, {mode}]) *synIDattr()* "inverse" "1" if inverse (= reverse) "standout" "1" if standout "underline" "1" if underlined + "underlineline" "1" if double underlined "undercurl" "1" if undercurled - "strikethrough" "1" if struckthrough + "underdot" "1" if dotted underlined + "underdash" "1" if dashed underlined + "strikethrough" "1" if struckthrough Example (echoes the color of the syntax item under the cursor): > diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt index 778f829a4e..7383848b04 100644 --- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -4875,7 +4875,8 @@ the same syntax file on all UIs. 1. TUI highlight arguments - *bold* *underline* *undercurl* + *bold* *underline* *underlineline* + *undercurl* *underdot* *underdash* *inverse* *italic* *standout* *nocombine* *strikethrough* cterm={attr-list} *attr-list* *highlight-cterm* *E418* @@ -4883,7 +4884,10 @@ cterm={attr-list} *attr-list* *highlight-cterm* *E418* following items (in any order): bold underline + underlineline double underline undercurl curly underline + underdot dotted underline + underdash dashed underline strikethrough reverse inverse same as reverse @@ -4894,8 +4898,9 @@ cterm={attr-list} *attr-list* *highlight-cterm* *E418* Note that "bold" can be used here and by using a bold font. They have the same effect. - "undercurl" falls back to "underline" in a terminal that does not - support it. The color is set using |highlight-guisp|. + "underlineline", "undercurl", "underdot", and "underdash" falls back + to "underline" in a terminal that does not support it. The color is set + using |highlight-guisp|. start={term-list} *highlight-start* *E422* stop={term-list} *term-list* *highlight-stop* @@ -5028,8 +5033,8 @@ guifg={color-name} *highlight-guifg* guibg={color-name} *highlight-guibg* guisp={color-name} *highlight-guisp* These give the foreground (guifg), background (guibg) and special - (guisp) color to use in the GUI. "guisp" is used for undercurl - and underline. + (guisp) color to use in the GUI. "guisp" is used for various + underlines. There are a few special names: NONE no color (transparent) bg use normal background color diff --git a/runtime/doc/ui.txt b/runtime/doc/ui.txt index e7be14e732..7c394a66c2 100644 --- a/runtime/doc/ui.txt +++ b/runtime/doc/ui.txt @@ -283,19 +283,24 @@ numerical highlight ids to the actual attributes. attributes specified by the `rgb_attr` and `cterm_attr` dicts, with the following (all optional) keys. - `foreground`: foreground color. - `background`: background color. - `special`: color to use for underline and undercurl, when present. - `reverse`: reverse video. Foreground and background colors are - switched. - `italic`: italic text. - `bold`: bold text. - `strikethrough`: struckthrough text. - `underline`: underlined text. The line has `special` color. - `undercurl`: undercurled text. The curl has `special` color. - `blend`: Blend level (0-100). Could be used by UIs to support - blending floating windows to the background or to - signal a transparent cursor. + `foreground`: foreground color. + `background`: background color. + `special`: color to use for various underlines, when + present. + `reverse`: reverse video. Foreground and background colors + are switched. + `italic`: italic text. + `bold`: bold text. + `strikethrough`: struckthrough text. + `underline`: underlined text. The line has `special` color. + `underlineline`: double underlined text. The lines has `special` + color. + `undercurl`: undercurled text. The curl has `special` color. + `underdot`: underdotted text. The dots has `special` color. + `underdash`: underdashed text. The dashes has `special` color. + `blend`: Blend level (0-100). Could be used by UIs to + support blending floating windows to the + background or to signal a transparent cursor. For absent color keys the default color should be used. Don't store the default value in the table, rather a sentinel value, so that @@ -444,14 +449,17 @@ is not active. New UIs should implement |ui-linegrid| instead. `foreground`: foreground color. `background`: background color. - `special`: color to use for underline and undercurl, when present. + `special`: color to use for various underlines, when present. `reverse`: reverse video. Foreground and background colors are switched. `italic`: italic text. `bold`: bold text. `strikethrough`: struckthrough text. `underline`: underlined text. The line has `special` color. + `underlineline`: double underlined text. The lines has `special` color. `undercurl`: undercurled text. The curl has `special` color. + `underdot`: underdotted text. The dots has `special` color. + `underdash`: underdashed text. The dashes has `special` color. ["put", text] The (utf-8 encoded) string `text` is put at the cursor position diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim index 41993b65b0..d8b8bce657 100644 --- a/runtime/syntax/vim.vim +++ b/runtime/syntax/vim.vim @@ -574,7 +574,7 @@ syn match vimHiBang contained "!" skipwhite nextgroup=@vimHighlightCluster syn match vimHiGroup contained "\i\+" syn case ignore -syn keyword vimHiAttrib contained none bold inverse italic nocombine reverse standout strikethrough underline undercurl +syn keyword vimHiAttrib contained none bold inverse italic nocombine reverse standout strikethrough underline underlineline undercurl underdot underdash syn keyword vimFgBgAttrib contained none bg background fg foreground syn case match syn match vimHiAttribList contained "\i\+" contains=vimHiAttrib -- cgit From 44728201820470324e70a93cf48210f0a68f56a2 Mon Sep 17 00:00:00 2001 From: Kirill Chibisov Date: Fri, 4 Mar 2022 00:35:03 +0300 Subject: fix(docs): spelling in new underlines docs --- runtime/doc/syntax.txt | 6 +++--- runtime/doc/ui.txt | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt index 7383848b04..9084c5315a 100644 --- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -4898,9 +4898,9 @@ cterm={attr-list} *attr-list* *highlight-cterm* *E418* Note that "bold" can be used here and by using a bold font. They have the same effect. - "underlineline", "undercurl", "underdot", and "underdash" falls back - to "underline" in a terminal that does not support it. The color is set - using |highlight-guisp|. + "underlineline", "undercurl", "underdot", and "underdash" fall back + to "underline" in a terminal that does not support them. The color is + set using |highlight-guisp|. start={term-list} *highlight-start* *E422* stop={term-list} *term-list* *highlight-stop* diff --git a/runtime/doc/ui.txt b/runtime/doc/ui.txt index 7c394a66c2..c5e3b60079 100644 --- a/runtime/doc/ui.txt +++ b/runtime/doc/ui.txt @@ -293,11 +293,11 @@ numerical highlight ids to the actual attributes. `bold`: bold text. `strikethrough`: struckthrough text. `underline`: underlined text. The line has `special` color. - `underlineline`: double underlined text. The lines has `special` + `underlineline`: double underlined text. The lines have `special` color. `undercurl`: undercurled text. The curl has `special` color. - `underdot`: underdotted text. The dots has `special` color. - `underdash`: underdashed text. The dashes has `special` color. + `underdot`: underdotted text. The dots have `special` color. + `underdash`: underdashed text. The dashes have `special` color. `blend`: Blend level (0-100). Could be used by UIs to support blending floating windows to the background or to signal a transparent cursor. @@ -456,10 +456,10 @@ is not active. New UIs should implement |ui-linegrid| instead. `bold`: bold text. `strikethrough`: struckthrough text. `underline`: underlined text. The line has `special` color. - `underlineline`: double underlined text. The lines has `special` color. + `underlineline`: double underlined text. The lines have `special` color. `undercurl`: undercurled text. The curl has `special` color. - `underdot`: underdotted text. The dots has `special` color. - `underdash`: underdashed text. The dashes has `special` color. + `underdot`: underdotted text. The dots have `special` color. + `underdash`: underdashed text. The dashes have `special` color. ["put", text] The (utf-8 encoded) string `text` is put at the cursor position -- cgit From 6795c9772b07a7eeb154bf9cc132bf50fa4ddcaa Mon Sep 17 00:00:00 2001 From: Kirill Chibisov Date: Fri, 4 Mar 2022 15:35:44 +0300 Subject: fix(syntax): remove trailing spaces in vim.vim --- runtime/syntax/vim.vim | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'runtime') diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim index d8b8bce657..0bc233fc2a 100644 --- a/runtime/syntax/vim.vim +++ b/runtime/syntax/vim.vim @@ -46,14 +46,14 @@ syn match vimTermOption contained "t_%i" syn match vimTermOption contained "t_k;" " unsupported settings: these are supported by vi but don't do anything in vim {{{2 -syn keyword vimErrSetting contained hardtabs ht w1200 w300 w9600 +syn keyword vimErrSetting contained hardtabs ht w1200 w300 w9600 "}}}2 syn case ignore " Highlight commonly used Groupnames {{{2 -syn keyword vimGroup contained Comment Constant String Character Number Boolean Float Identifier Function Statement Conditional Repeat Label Operator Keyword Exception PreProc Include Define Macro PreCondit Type StorageClass Structure Typedef Special SpecialChar Tag Delimiter SpecialComment Debug Underlined Ignore Error Todo +syn keyword vimGroup contained Comment Constant String Character Number Boolean Float Identifier Function Statement Conditional Repeat Label Operator Keyword Exception PreProc Include Define Macro PreCondit Type StorageClass Structure Typedef Special SpecialChar Tag Delimiter SpecialComment Debug Underlined Ignore Error Todo " Default highlighting groups {{{2 -syn keyword vimHLGroup contained ColorColumn Cursor CursorColumn CursorIM CursorLine CursorLineFold CursorLineNr CursorLineSign DiffAdd DiffChange DiffDelete DiffText Directory EndOfBuffer ErrorMsg FoldColumn Folded IncSearch LineNr MatchParen Menu ModeMsg MoreMsg NonText Normal Pmenu PmenuSbar PmenuSel PmenuThumb Question QuickFixLine Scrollbar Search SignColumn SpecialKey SpellBad SpellCap SpellLocal SpellRare StatusLine StatusLineNC TabLine TabLineFill TabLineSel Title Tooltip VertSplit Visual WarningMsg WildMenu +syn keyword vimHLGroup contained ColorColumn Cursor CursorColumn CursorIM CursorLine CursorLineFold CursorLineNr CursorLineSign DiffAdd DiffChange DiffDelete DiffText Directory EndOfBuffer ErrorMsg FoldColumn Folded IncSearch LineNr MatchParen Menu ModeMsg MoreMsg NonText Normal Pmenu PmenuSbar PmenuSel PmenuThumb Question QuickFixLine Scrollbar Search SignColumn SpecialKey SpellBad SpellCap SpellLocal SpellRare StatusLine StatusLineNC TabLine TabLineFill TabLineSel Title Tooltip VertSplit Visual WarningMsg WildMenu syn match vimHLGroup contained "Conceal" syn keyword vimOnlyHLGroup contained LineNrAbove LineNrBelow StatusLineTerm Terminal VisualNOS syn keyword nvimHLGroup contained Substitute TermCursor TermCursorNC @@ -88,10 +88,10 @@ if exists("g:vimsyn_folding") && g:vimsyn_folding =~# '[afhlmpPrt]' else com! -nargs=* VimFoldm endif - if g:vimsyn_folding =~# 'p' - com! -nargs=* VimFoldp fold - else - com! -nargs=* VimFoldp + if g:vimsyn_folding =~# 'p' + com! -nargs=* VimFoldp fold + else + com! -nargs=* VimFoldp endif if g:vimsyn_folding =~# 'P' com! -nargs=* VimFoldP fold @@ -148,8 +148,8 @@ syn match vimNumber '-\d\+\%(\.\d\+\%([eE][+-]\=\d\+\)\=\)\=' skipwhite nextgro syn match vimNumber '\<0[xX]\x\+' skipwhite nextgroup=vimGlobal,vimSubst,vimCommand,vimComment,vim9Comment syn match vimNumber '\%(^\|\A\)\zs#\x\{6}' skipwhite nextgroup=vimGlobal,vimSubst,vimCommand,vimComment,vim9Comment syn match vimNumber '\<0[zZ][a-zA-Z0-9.]\+' skipwhite nextgroup=vimGlobal,vimSubst,vimCommand,vimComment,vim9Comment -syn match vimNumber '0[0-7]\+' skipwhite nextgroup=vimGlobal,vimSubst,vimCommand,vimComment,vim9Comment -syn match vimNumber '0[bB][01]\+' skipwhite nextgroup=vimGlobal,vimSubst,vimCommand,vimComment,vim9Comment +syn match vimNumber '0[0-7]\+' skipwhite nextgroup=vimGlobal,vimSubst,vimCommand,vimComment,vim9Comment +syn match vimNumber '0[bB][01]\+' skipwhite nextgroup=vimGlobal,vimSubst,vimCommand,vimComment,vim9Comment " All vimCommands are contained by vimIsCommand. {{{2 syn match vimCmdSep "[:|]\+" skipwhite nextgroup=vimAddress,vimAutoCmd,vimEcho,vimIsCommand,vimExtCmd,vimFilter,vimLet,vimMap,vimMark,vimSet,vimSyntax,vimUserCmd @@ -574,7 +574,7 @@ syn match vimHiBang contained "!" skipwhite nextgroup=@vimHighlightCluster syn match vimHiGroup contained "\i\+" syn case ignore -syn keyword vimHiAttrib contained none bold inverse italic nocombine reverse standout strikethrough underline underlineline undercurl underdot underdash +syn keyword vimHiAttrib contained none bold inverse italic nocombine reverse standout strikethrough underline underlineline undercurl underdot underdash syn keyword vimFgBgAttrib contained none bg background fg foreground syn case match syn match vimHiAttribList contained "\i\+" contains=vimHiAttrib -- cgit From 186a559818f7a709dbdd4590fe7440ebd619a208 Mon Sep 17 00:00:00 2001 From: bfredl Date: Fri, 4 Mar 2022 16:18:58 +0100 Subject: refactor(lua): move only runtime lua file in src/ to runtime/lua reorganize so that initialization is done in lua --- runtime/lua/vim/_editor.lua | 659 +++++++++++++++++++++++++++++++++++++ runtime/lua/vim/_init_packages.lua | 65 ++++ runtime/lua/vim/_load_package.lua | 52 --- 3 files changed, 724 insertions(+), 52 deletions(-) create mode 100644 runtime/lua/vim/_editor.lua create mode 100644 runtime/lua/vim/_init_packages.lua delete mode 100644 runtime/lua/vim/_load_package.lua (limited to 'runtime') diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua new file mode 100644 index 0000000000..5f3329ef42 --- /dev/null +++ b/runtime/lua/vim/_editor.lua @@ -0,0 +1,659 @@ +-- Nvim-Lua stdlib: the `vim` module (:help lua-stdlib) +-- +-- Lua code lives in one of three places: +-- 1. runtime/lua/vim/ (the runtime): For "nice to have" features, e.g. the +-- `inspect` and `lpeg` modules. +-- 2. runtime/lua/vim/shared.lua: Code shared between Nvim and tests. +-- (This will go away if we migrate to nvim as the test-runner.) +-- 3. src/nvim/lua/: Compiled-into Nvim itself. +-- +-- Guideline: "If in doubt, put it in the runtime". +-- +-- Most functions should live directly in `vim.`, not in submodules. +-- The only "forbidden" names are those claimed by legacy `if_lua`: +-- $ vim +-- :lua for k,v in pairs(vim) do print(k) end +-- buffer +-- open +-- window +-- lastline +-- firstline +-- type +-- line +-- eval +-- dict +-- beep +-- list +-- command +-- +-- Reference (#6580): +-- - https://github.com/luafun/luafun +-- - https://github.com/rxi/lume +-- - http://leafo.net/lapis/reference/utilities.html +-- - https://github.com/torch/paths +-- - https://github.com/bakpakin/Fennel (pretty print, repl) +-- - https://github.com/howl-editor/howl/tree/master/lib/howl/util + +local vim = assert(vim) +assert(vim.inspect) + +-- These are for loading runtime modules lazily since they aren't available in +-- the nvim binary as specified in executor.c +setmetatable(vim, { + __index = function(t, key) + if key == 'treesitter' then + t.treesitter = require('vim.treesitter') + return t.treesitter + elseif key == 'filetype' then + t.filetype = require('vim.filetype') + return t.filetype + elseif key == 'F' then + t.F = require('vim.F') + return t.F + elseif require('vim.uri')[key] ~= nil then + -- Expose all `vim.uri` functions on the `vim` module. + t[key] = require('vim.uri')[key] + return t[key] + elseif key == 'lsp' then + t.lsp = require('vim.lsp') + return t.lsp + elseif key == 'highlight' then + t.highlight = require('vim.highlight') + return t.highlight + elseif key == 'diagnostic' then + t.diagnostic = require('vim.diagnostic') + return t.diagnostic + elseif key == 'keymap' then + t.keymap = require('vim.keymap') + return t.keymap + elseif key == 'ui' then + t.ui = require('vim.ui') + return t.ui + end + end +}) + +vim.log = { + levels = { + TRACE = 0; + DEBUG = 1; + INFO = 2; + WARN = 3; + ERROR = 4; + } +} + +-- Internal-only until comments in #8107 are addressed. +-- Returns: +-- {errcode}, {output} +function vim._system(cmd) + local out = vim.fn.system(cmd) + local err = vim.v.shell_error + return err, out +end + +-- Gets process info from the `ps` command. +-- Used by nvim_get_proc() as a fallback. +function vim._os_proc_info(pid) + if pid == nil or pid <= 0 or type(pid) ~= 'number' then + error('invalid pid') + end + local cmd = { 'ps', '-p', pid, '-o', 'comm=', } + local err, name = vim._system(cmd) + if 1 == err and vim.trim(name) == '' then + return {} -- Process not found. + elseif 0 ~= err then + error('command failed: '..vim.fn.string(cmd)) + end + local _, ppid = vim._system({ 'ps', '-p', pid, '-o', 'ppid=', }) + -- Remove trailing whitespace. + name = vim.trim(name):gsub('^.*/', '') + ppid = tonumber(ppid) or -1 + return { + name = name, + pid = pid, + ppid = ppid, + } +end + +-- Gets process children from the `pgrep` command. +-- Used by nvim_get_proc_children() as a fallback. +function vim._os_proc_children(ppid) + if ppid == nil or ppid <= 0 or type(ppid) ~= 'number' then + error('invalid ppid') + end + local cmd = { 'pgrep', '-P', ppid, } + local err, rv = vim._system(cmd) + if 1 == err and vim.trim(rv) == '' then + return {} -- Process not found. + elseif 0 ~= err then + error('command failed: '..vim.fn.string(cmd)) + end + local children = {} + for s in rv:gmatch('%S+') do + local i = tonumber(s) + if i ~= nil then + table.insert(children, i) + end + end + return children +end + +-- TODO(ZyX-I): Create compatibility layer. + +--- Return a human-readable representation of the given object. +--- +---@see https://github.com/kikito/inspect.lua +---@see https://github.com/mpeterv/vinspect +local function inspect(object, options) -- luacheck: no unused + error(object, options) -- Stub for gen_vimdoc.py +end + +do + local tdots, tick, got_line1 = 0, 0, false + + --- Paste handler, invoked by |nvim_paste()| when a conforming UI + --- (such as the |TUI|) pastes text into the editor. + --- + --- Example: To remove ANSI color codes when pasting: + ---
+  --- vim.paste = (function(overridden)
+  ---   return function(lines, phase)
+  ---     for i,line in ipairs(lines) do
+  ---       -- Scrub ANSI color codes from paste input.
+  ---       lines[i] = line:gsub('\27%[[0-9;mK]+', '')
+  ---     end
+  ---     overridden(lines, phase)
+  ---   end
+  --- end)(vim.paste)
+  --- 
+ --- + ---@see |paste| + --- + ---@param lines |readfile()|-style list of lines to paste. |channel-lines| + ---@param phase -1: "non-streaming" paste: the call contains all lines. + --- If paste is "streamed", `phase` indicates the stream state: + --- - 1: starts the paste (exactly once) + --- - 2: continues the paste (zero or more times) + --- - 3: ends the paste (exactly once) + ---@returns false if client should cancel the paste. + function vim.paste(lines, phase) + local call = vim.api.nvim_call_function + local now = vim.loop.now() + local mode = call('mode', {}):sub(1,1) + if phase < 2 then -- Reset flags. + tdots, tick, got_line1 = now, 0, false + elseif mode ~= 'c' then + vim.api.nvim_command('undojoin') + end + if mode == 'c' and not got_line1 then -- cmdline-mode: paste only 1 line. + got_line1 = (#lines > 1) + vim.api.nvim_set_option('paste', true) -- For nvim_input(). + local line1 = lines[1]:gsub('<', ''):gsub('[\r\n\012\027]', ' ') -- Scrub. + vim.api.nvim_input(line1) + vim.api.nvim_set_option('paste', false) + elseif mode ~= 'c' then + if phase < 2 and mode:find('^[vV\22sS\19]') then + vim.api.nvim_command([[exe "normal! \"]]) + vim.api.nvim_put(lines, 'c', false, true) + elseif phase < 2 and not mode:find('^[iRt]') then + vim.api.nvim_put(lines, 'c', true, true) + -- XXX: Normal-mode: workaround bad cursor-placement after first chunk. + vim.api.nvim_command('normal! a') + elseif phase < 2 and mode == 'R' then + local nchars = 0 + for _, line in ipairs(lines) do + nchars = nchars + line:len() + end + local row, col = unpack(vim.api.nvim_win_get_cursor(0)) + local bufline = vim.api.nvim_buf_get_lines(0, row-1, row, true)[1] + local firstline = lines[1] + firstline = bufline:sub(1, col)..firstline + lines[1] = firstline + lines[#lines] = lines[#lines]..bufline:sub(col + nchars + 1, bufline:len()) + vim.api.nvim_buf_set_lines(0, row-1, row, false, lines) + else + vim.api.nvim_put(lines, 'c', false, true) + end + end + if phase ~= -1 and (now - tdots >= 100) then + local dots = ('.'):rep(tick % 4) + tdots = now + tick = tick + 1 + -- Use :echo because Lua print('') is a no-op, and we want to clear the + -- message when there are zero dots. + vim.api.nvim_command(('echo "%s"'):format(dots)) + end + if phase == -1 or phase == 3 then + vim.api.nvim_command('redraw'..(tick > 1 and '|echo ""' or '')) + end + return true -- Paste will not continue if not returning `true`. + end +end + +--- Defers callback `cb` until the Nvim API is safe to call. +--- +---@see |lua-loop-callbacks| +---@see |vim.schedule()| +---@see |vim.in_fast_event()| +function vim.schedule_wrap(cb) + return (function (...) + local args = vim.F.pack_len(...) + vim.schedule(function() cb(vim.F.unpack_len(args)) end) + end) +end + +-- vim.fn.{func}(...) +vim.fn = setmetatable({}, { + __index = function(t, key) + local _fn + if vim.api[key] ~= nil then + _fn = function() + error(string.format("Tried to call API function with vim.fn: use vim.api.%s instead", key)) + end + else + _fn = function(...) + return vim.call(key, ...) + end + end + t[key] = _fn + return _fn + end +}) + +vim.funcref = function(viml_func_name) + return vim.fn[viml_func_name] +end + +-- An easier alias for commands. +vim.cmd = function(command) + return vim.api.nvim_exec(command, false) +end + +-- These are the vim.env/v/g/o/bo/wo variable magic accessors. +do + local validate = vim.validate + + --@private + local function make_dict_accessor(scope, handle) + validate { + scope = {scope, 's'}; + } + local mt = {} + function mt:__newindex(k, v) + return vim._setvar(scope, handle or 0, k, v) + end + function mt:__index(k) + if handle == nil and type(k) == 'number' then + return make_dict_accessor(scope, k) + end + return vim._getvar(scope, handle or 0, k) + end + return setmetatable({}, mt) + end + + vim.g = make_dict_accessor('g', false) + vim.v = make_dict_accessor('v', false) + vim.b = make_dict_accessor('b') + vim.w = make_dict_accessor('w') + vim.t = make_dict_accessor('t') +end + +--- Get a table of lines with start, end columns for a region marked by two points +--- +---@param bufnr number of buffer +---@param pos1 (line, column) tuple marking beginning of region +---@param pos2 (line, column) tuple marking end of region +---@param regtype type of selection (:help setreg) +---@param inclusive boolean indicating whether the selection is end-inclusive +---@return region lua table of the form {linenr = {startcol,endcol}} +function vim.region(bufnr, pos1, pos2, regtype, inclusive) + if not vim.api.nvim_buf_is_loaded(bufnr) then + vim.fn.bufload(bufnr) + end + + -- check that region falls within current buffer + local buf_line_count = vim.api.nvim_buf_line_count(bufnr) + pos1[1] = math.min(pos1[1], buf_line_count - 1) + pos2[1] = math.min(pos2[1], buf_line_count - 1) + + -- in case of block selection, columns need to be adjusted for non-ASCII characters + -- TODO: handle double-width characters + local bufline + if regtype:byte() == 22 then + bufline = vim.api.nvim_buf_get_lines(bufnr, pos1[1], pos1[1] + 1, true)[1] + pos1[2] = vim.str_utfindex(bufline, pos1[2]) + end + + local region = {} + for l = pos1[1], pos2[1] do + local c1, c2 + if regtype:byte() == 22 then -- block selection: take width from regtype + c1 = pos1[2] + c2 = c1 + regtype:sub(2) + -- and adjust for non-ASCII characters + bufline = vim.api.nvim_buf_get_lines(bufnr, l, l + 1, true)[1] + if c1 < #bufline then + c1 = vim.str_byteindex(bufline, c1) + end + if c2 < #bufline then + c2 = vim.str_byteindex(bufline, c2) + end + else + c1 = (l == pos1[1]) and (pos1[2]) or 0 + c2 = (l == pos2[1]) and (pos2[2] + (inclusive and 1 or 0)) or -1 + end + table.insert(region, l, {c1, c2}) + end + return region +end + +--- Defers calling `fn` until `timeout` ms passes. +--- +--- Use to do a one-shot timer that calls `fn` +--- Note: The {fn} is |schedule_wrap|ped automatically, so API functions are +--- safe to call. +---@param fn Callback to call once `timeout` expires +---@param timeout Number of milliseconds to wait before calling `fn` +---@return timer luv timer object +function vim.defer_fn(fn, timeout) + vim.validate { fn = { fn, 'c', true}; } + local timer = vim.loop.new_timer() + timer:start(timeout, 0, vim.schedule_wrap(function() + timer:stop() + timer:close() + + fn() + end)) + + return timer +end + + +--- Display a notification to the user. +--- +--- This function can be overridden by plugins to display notifications using a +--- custom provider (such as the system notification provider). By default, +--- writes to |:messages|. +--- +---@param msg string Content of the notification to show to the user. +---@param level number|nil One of the values from |vim.log.levels|. +---@param opts table|nil Optional parameters. Unused by default. +function vim.notify(msg, level, opts) -- luacheck: no unused args + if level == vim.log.levels.ERROR then + vim.api.nvim_err_writeln(msg) + elseif level == vim.log.levels.WARN then + vim.api.nvim_echo({{msg, 'WarningMsg'}}, true, {}) + else + vim.api.nvim_echo({{msg}}, true, {}) + end +end + +do + local notified = {} + + --- Display a notification only one time. + --- + --- Like |vim.notify()|, but subsequent calls with the same message will not + --- display a notification. + --- + ---@param msg string Content of the notification to show to the user. + ---@param level number|nil One of the values from |vim.log.levels|. + ---@param opts table|nil Optional parameters. Unused by default. + function vim.notify_once(msg, level, opts) -- luacheck: no unused args + if not notified[msg] then + vim.notify(msg, level, opts) + notified[msg] = true + end + end +end + +---@private +function vim.register_keystroke_callback() + error('vim.register_keystroke_callback is deprecated, instead use: vim.on_key') +end + +local on_key_cbs = {} + +--- Adds Lua function {fn} with namespace id {ns_id} as a listener to every, +--- yes every, input key. +--- +--- The Nvim command-line option |-w| is related but does not support callbacks +--- and cannot be toggled dynamically. +--- +---@param fn function: Callback function. It should take one string argument. +--- 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_namespace()| id. +--- +---@return number Namespace id associated with {fn}. Or count of all callbacks +---if on_key() is called without arguments. +--- +---@note {fn} will be removed if an error occurs while calling. +---@note {fn} will not be cleared by |nvim_buf_clear_namespace()| +---@note {fn} will receive the keys after mappings have been evaluated +function vim.on_key(fn, ns_id) + if fn == nil and ns_id == nil then + return #on_key_cbs + end + + vim.validate { + fn = { fn, 'c', true}, + ns_id = { ns_id, 'n', true } + } + + if ns_id == nil or ns_id == 0 then + ns_id = vim.api.nvim_create_namespace('') + end + + on_key_cbs[ns_id] = fn + return ns_id +end + +--- Executes the on_key callbacks. +---@private +function vim._on_key(char) + local failed_ns_ids = {} + local failed_messages = {} + for k, v in pairs(on_key_cbs) do + local ok, err_msg = pcall(v, char) + if not ok then + vim.on_key(nil, k) + table.insert(failed_ns_ids, k) + table.insert(failed_messages, err_msg) + end + end + + if failed_ns_ids[1] then + error(string.format( + "Error executing 'on_key' with ns_ids '%s'\n Messages: %s", + table.concat(failed_ns_ids, ", "), + table.concat(failed_messages, "\n"))) + end +end + +--- Generate a list of possible completions for the string. +--- String starts with ^ and then has the pattern. +--- +--- 1. Can we get it to just return things in the global namespace with that name prefix +--- 2. Can we get it to return things from global namespace even with `print(` in front. +function vim._expand_pat(pat, env) + env = env or _G + + pat = string.sub(pat, 2, #pat) + + if pat == '' then + local result = vim.tbl_keys(env) + table.sort(result) + return result, 0 + end + + -- TODO: We can handle spaces in [] ONLY. + -- We should probably do that at some point, just for cooler completion. + -- TODO: We can suggest the variable names to go in [] + -- This would be difficult as well. + -- Probably just need to do a smarter match than just `:match` + + -- Get the last part of the pattern + local last_part = pat:match("[%w.:_%[%]'\"]+$") + if not last_part then return {}, 0 end + + local parts, search_index = vim._expand_pat_get_parts(last_part) + + local match_part = string.sub(last_part, search_index, #last_part) + local prefix_match_pat = string.sub(pat, 1, #pat - #match_part) or '' + + local final_env = env + + for _, part in ipairs(parts) do + if type(final_env) ~= 'table' then + return {}, 0 + end + local key + + -- Normally, we just have a string + -- Just attempt to get the string directly from the environment + if type(part) == "string" then + key = part + else + -- However, sometimes you want to use a variable, and complete on it + -- With this, you have the power. + + -- MY_VAR = "api" + -- vim[MY_VAR] + -- -> _G[MY_VAR] -> "api" + local result_key = part[1] + if not result_key then + return {}, 0 + end + + local result = rawget(env, result_key) + + if result == nil then + return {}, 0 + end + + key = result + end + local field = rawget(final_env, key) + if field == nil then + local mt = getmetatable(final_env) + if mt and type(mt.__index) == "table" then + field = rawget(mt.__index, key) + end + end + final_env = field + + if not final_env then + return {}, 0 + end + 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 + table.insert(keys,k) + end + end + end + + if type(final_env) == "table" then + insert_keys(final_env) + end + local mt = getmetatable(final_env) + if mt and type(mt.__index) == "table" then + insert_keys(mt.__index) + end + + table.sort(keys) + + return keys, #prefix_match_pat +end + +vim._expand_pat_get_parts = function(lua_string) + local parts = {} + + local accumulator, search_index = '', 1 + local in_brackets, bracket_end = false, -1 + local string_char = nil + for idx = 1, #lua_string do + local s = lua_string:sub(idx, idx) + + if not in_brackets and (s == "." or s == ":") then + table.insert(parts, accumulator) + accumulator = '' + + search_index = idx + 1 + elseif s == "[" then + in_brackets = true + + table.insert(parts, accumulator) + accumulator = '' + + search_index = idx + 1 + elseif in_brackets then + if idx == bracket_end then + in_brackets = false + search_index = idx + 1 + + if string_char == "VAR" then + table.insert(parts, { accumulator }) + accumulator = '' + + string_char = nil + end + elseif not string_char then + bracket_end = string.find(lua_string, ']', idx, true) + + if s == '"' or s == "'" then + string_char = s + elseif s ~= ' ' then + string_char = "VAR" + accumulator = s + end + elseif string_char then + if string_char ~= s then + accumulator = accumulator .. s + else + table.insert(parts, accumulator) + accumulator = '' + + string_char = nil + end + end + else + accumulator = accumulator .. s + end + end + + parts = vim.tbl_filter(function(val) return #val > 0 end, parts) + + return parts, search_index +end + +---Prints given arguments in human-readable format. +---Example: +---
+---  -- Print highlight group Normal and store it's contents in a variable.
+---  local hl_normal = vim.pretty_print(vim.api.nvim_get_hl_by_name("Normal", true))
+---
+---@see |vim.inspect()| +---@return given arguments. +function vim.pretty_print(...) + local objects = {} + for i = 1, select('#', ...) do + local v = select(i, ...) + table.insert(objects, vim.inspect(v)) + end + + print(table.concat(objects, ' ')) + return ... +end + + +require('vim._meta') + +return vim diff --git a/runtime/lua/vim/_init_packages.lua b/runtime/lua/vim/_init_packages.lua new file mode 100644 index 0000000000..dcb402287c --- /dev/null +++ b/runtime/lua/vim/_init_packages.lua @@ -0,0 +1,65 @@ +-- prevents luacheck from making lints for setting things on vim +local vim = assert(vim) + +local pathtrails = {} +vim._so_trails = {} +for s in (package.cpath..';'):gmatch('[^;]*;') do + s = s:sub(1, -2) -- Strip trailing semicolon + -- Find out path patterns. pathtrail should contain something like + -- /?.so, \?.dll. This allows not to bother determining what correct + -- suffixes are. + local pathtrail = s:match('[/\\][^/\\]*%?.*$') + if pathtrail and not pathtrails[pathtrail] then + pathtrails[pathtrail] = true + table.insert(vim._so_trails, pathtrail) + end +end + +function vim._load_package(name) + local basename = name:gsub('%.', '/') + local paths = {"lua/"..basename..".lua", "lua/"..basename.."/init.lua"} + local found = vim.api.nvim__get_runtime(paths, false, {is_lua=true}) + if #found > 0 then + local f, err = loadfile(found[1]) + return f or error(err) + end + + local so_paths = {} + for _,trail in ipairs(vim._so_trails) do + local path = "lua"..trail:gsub('?', basename) -- so_trails contains a leading slash + table.insert(so_paths, path) + end + + found = vim.api.nvim__get_runtime(so_paths, false, {is_lua=true}) + if #found > 0 then + -- Making function name in Lua 5.1 (see src/loadlib.c:mkfuncname) is + -- a) strip prefix up to and including the first dash, if any + -- b) replace all dots by underscores + -- c) prepend "luaopen_" + -- So "foo-bar.baz" should result in "luaopen_bar_baz" + local dash = name:find("-", 1, true) + local modname = dash and name:sub(dash + 1) or name + local f, err = package.loadlib(found[1], "luaopen_"..modname:gsub("%.", "_")) + return f or error(err) + end + return nil +end + +-- Insert vim._load_package after the preloader at position 2 +table.insert(package.loaders, 2, vim._load_package) + +-- builtin functions which always should be available +require'vim.shared' +vim.inspect = require'vim.inspect' + +--- +---@private +--- TODO: should be in vim.shared when vim.shared always uses nvim-lua +function vim.empty_dict() + return setmetatable({}, vim._empty_dict_mt) +end + +-- only on main thread: functions for interacting with editor state +if not vim.is_thread() then + require'vim._editor' +end diff --git a/runtime/lua/vim/_load_package.lua b/runtime/lua/vim/_load_package.lua deleted file mode 100644 index 59bca9b148..0000000000 --- a/runtime/lua/vim/_load_package.lua +++ /dev/null @@ -1,52 +0,0 @@ --- prevents luacheck from making lints for setting things on vim -local vim = assert(vim) - -local pathtrails = {} -vim._so_trails = {} -for s in (package.cpath..';'):gmatch('[^;]*;') do - s = s:sub(1, -2) -- Strip trailing semicolon - -- Find out path patterns. pathtrail should contain something like - -- /?.so, \?.dll. This allows not to bother determining what correct - -- suffixes are. - local pathtrail = s:match('[/\\][^/\\]*%?.*$') - if pathtrail and not pathtrails[pathtrail] then - pathtrails[pathtrail] = true - table.insert(vim._so_trails, pathtrail) - end -end - -function vim._load_package(name) - local basename = name:gsub('%.', '/') - local paths = {"lua/"..basename..".lua", "lua/"..basename.."/init.lua"} - local found = vim.api.nvim__get_runtime(paths, false, {is_lua=true}) - if #found > 0 then - local f, err = loadfile(found[1]) - return f or error(err) - end - - local so_paths = {} - for _,trail in ipairs(vim._so_trails) do - local path = "lua"..trail:gsub('?', basename) -- so_trails contains a leading slash - table.insert(so_paths, path) - end - - found = vim.api.nvim__get_runtime(so_paths, false, {is_lua=true}) - if #found > 0 then - -- Making function name in Lua 5.1 (see src/loadlib.c:mkfuncname) is - -- a) strip prefix up to and including the first dash, if any - -- b) replace all dots by underscores - -- c) prepend "luaopen_" - -- So "foo-bar.baz" should result in "luaopen_bar_baz" - local dash = name:find("-", 1, true) - local modname = dash and name:sub(dash + 1) or name - local f, err = package.loadlib(found[1], "luaopen_"..modname:gsub("%.", "_")) - return f or error(err) - end - return nil -end - --- Insert vim._load_package after the preloader at position 2 -table.insert(package.loaders, 2, vim._load_package) - --- should always be available -vim.inspect = require'vim.inspect' -- cgit From a5e475fcc269b32a8a487f787af20802cbfabe28 Mon Sep 17 00:00:00 2001 From: Michael Lingelbach Date: Sat, 5 Mar 2022 09:17:56 -0800 Subject: fix(lsp): start incremental sync range at previous newline character (#17610) This change forces the start of an incremental sync range to begin always on an existing line. --- runtime/lua/vim/lsp/sync.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'runtime') diff --git a/runtime/lua/vim/lsp/sync.lua b/runtime/lua/vim/lsp/sync.lua index 0f4e5b572b..e500be46c2 100644 --- a/runtime/lua/vim/lsp/sync.lua +++ b/runtime/lua/vim/lsp/sync.lua @@ -131,13 +131,22 @@ end ---@param offset_encoding string utf-8|utf-16|utf-32|nil (fallback to utf-8) ---@returns table line_idx, byte_idx, and char_idx of first change position local function compute_start_range(prev_lines, curr_lines, firstline, lastline, new_lastline, offset_encoding) + local char_idx + local byte_idx -- If firstline == lastline, no existing text is changed. All edit operations -- 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 == lastline then + local line = prev_lines[firstline - 1] + byte_idx = #line + 1 + char_idx = compute_line_length(line, offset_encoding) + 1 + return { line_idx = firstline - 1, byte_idx = byte_idx, char_idx = char_idx } + end + -- 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 + if firstline == new_lastline then return { line_idx = firstline, byte_idx = 1, char_idx = 1 } end @@ -158,8 +167,6 @@ local function compute_start_range(prev_lines, curr_lines, firstline, lastline, end -- Convert byte to codepoint if applicable - local char_idx - local byte_idx if start_byte_idx == 1 or (#prev_line == 0 and start_byte_idx == 1)then byte_idx = start_byte_idx char_idx = 1 -- cgit From 80e6f81862d943b2d31639a0e437b6abdff3373c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 6 Mar 2022 21:16:21 +0800 Subject: docs(lua): reference runtime/lua/vim/_editor.lua --- runtime/doc/develop.txt | 2 +- runtime/lua/vim/_editor.lua | 2 +- runtime/lua/vim/shared.lua | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/develop.txt b/runtime/doc/develop.txt index 178b0dc62b..cc146fcf6e 100644 --- a/runtime/doc/develop.txt +++ b/runtime/doc/develop.txt @@ -204,7 +204,7 @@ Docstring format: - Use `
`  for code samples.
 
 Example: the help for |vim.paste()| is generated from a docstring decorating
-vim.paste in src/nvim/lua/vim.lua like this: >
+vim.paste in runtime/lua/vim/_editor.lua like this: >
 
     --- Paste handler, invoked by |nvim_paste()| when a conforming UI
     --- (such as the |TUI|) pastes text into the editor.
diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua
index 5f3329ef42..ddd1147468 100644
--- a/runtime/lua/vim/_editor.lua
+++ b/runtime/lua/vim/_editor.lua
@@ -5,7 +5,7 @@
 --       `inspect` and `lpeg` modules.
 --    2. runtime/lua/vim/shared.lua: Code shared between Nvim and tests.
 --       (This will go away if we migrate to nvim as the test-runner.)
---    3. src/nvim/lua/: Compiled-into Nvim itself.
+--    3. runtime/lua/vim/_editor.lua: Compiled-into Nvim itself.
 --
 -- Guideline: "If in doubt, put it in the runtime".
 --
diff --git a/runtime/lua/vim/shared.lua b/runtime/lua/vim/shared.lua
index e170befa4c..48d0bd3672 100644
--- a/runtime/lua/vim/shared.lua
+++ b/runtime/lua/vim/shared.lua
@@ -2,7 +2,7 @@
 --
 -- The singular purpose of this module is to share code with the Nvim
 -- test-suite. If, in the future, Nvim itself is used to run the test-suite
--- instead of "vanilla Lua", these functions could move to src/nvim/lua/vim.lua
+-- instead of "vanilla Lua", these functions could move to runtime/lua/vim/_editor.lua
 
 local vim = vim or {}
 
-- 
cgit 


From 3800615da9eaf9e8b26d9040c882c74084d688e4 Mon Sep 17 00:00:00 2001
From: Michael Lingelbach 
Date: Sun, 6 Mar 2022 07:52:11 -0800
Subject: fix(lsp): handle insertion of previous line (#17618)

---
 runtime/lua/vim/lsp/sync.lua | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

(limited to 'runtime')

diff --git a/runtime/lua/vim/lsp/sync.lua b/runtime/lua/vim/lsp/sync.lua
index e500be46c2..9955fff3e2 100644
--- a/runtime/lua/vim/lsp/sync.lua
+++ b/runtime/lua/vim/lsp/sync.lua
@@ -138,10 +138,18 @@ local function compute_start_range(prev_lines, curr_lines, firstline, lastline,
   -- new lines(O), the new newline is inserted at the line indicated by
   -- new_lastline.
   if firstline == lastline then
+    local line_idx
     local line = prev_lines[firstline - 1]
-    byte_idx = #line + 1
-    char_idx = compute_line_length(line, offset_encoding) + 1
-    return { line_idx = firstline - 1, byte_idx = byte_idx, char_idx = char_idx }
+    if line then
+      line_idx = firstline - 1
+      byte_idx = #line + 1
+      char_idx = compute_line_length(line, offset_encoding) + 1
+    else
+      line_idx = firstline
+      byte_idx = 1
+      char_idx = 1
+    end
+    return { line_idx = line_idx, byte_idx = byte_idx, char_idx = char_idx }
   end
 
   -- If firstline == new_lastline, the first change occurred on a line that was deleted.
-- 
cgit 


From 92349b1db0039aac3a43089d0aade2437164505c Mon Sep 17 00:00:00 2001
From: Gregory Anders <8965202+gpanders@users.noreply.github.com>
Date: Sun, 6 Mar 2022 12:35:14 -0700
Subject: feat(api): add 'buffer' argument to nvim_get_autocmds (#17594)

This enables retrieving autocommands defined in the given buffers. Under
the hood this simply translates the buffer numbers into ''
patterns.
---
 runtime/doc/api.txt | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

(limited to 'runtime')

diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt
index fe5f9eaf35..73536d174a 100644
--- a/runtime/doc/api.txt
+++ b/runtime/doc/api.txt
@@ -3226,7 +3226,11 @@ nvim_get_autocmds({*opts})                               *nvim_get_autocmds()*
                               against
                             • group (string): Name of group to match against
                             • pattern: Pattern or list of patterns to match
-                              against
+                              against. Cannot be used with {buffer}
+                            • buffer: Buffer number or list of buffer numbers
+                              for buffer local autocommands
+                              |autocmd-buflocal|. Cannot be used with
+                              {pattern}
 
                 Return: ~
                     A list of autocmds that match
-- 
cgit 


From f39a12d629500bdbacb389ed593adac34d058fcb Mon Sep 17 00:00:00 2001
From: bfredl 
Date: Sun, 6 Mar 2022 13:13:10 +0100
Subject: refactor(lua): make vim submodule lazy loading declarative

This will allow us to also use the same logic for lua threads and
processes, later.
---
 runtime/lua/vim/_editor.lua        | 52 +++++++++++---------------------------
 runtime/lua/vim/_init_packages.lua | 20 ++++++++++++++-
 runtime/lua/vim/shared.lua         |  8 +++---
 3 files changed, 39 insertions(+), 41 deletions(-)

(limited to 'runtime')

diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua
index ddd1147468..2251aca004 100644
--- a/runtime/lua/vim/_editor.lua
+++ b/runtime/lua/vim/_editor.lua
@@ -3,9 +3,11 @@
 -- Lua code lives in one of three places:
 --    1. runtime/lua/vim/ (the runtime): For "nice to have" features, e.g. the
 --       `inspect` and `lpeg` modules.
---    2. runtime/lua/vim/shared.lua: Code shared between Nvim and tests.
---       (This will go away if we migrate to nvim as the test-runner.)
---    3. runtime/lua/vim/_editor.lua: Compiled-into Nvim itself.
+--    2. runtime/lua/vim/shared.lua: pure lua functions which always
+--       are available. Used in the test runner, as well as worker threads
+--       and processes launched from Nvim.
+--    3. runtime/lua/vim/_editor.lua: Code which directly interacts with
+--       the Nvim editor state. Only available in the main thread.
 --
 -- Guideline: "If in doubt, put it in the runtime".
 --
@@ -35,43 +37,19 @@
 --    - https://github.com/howl-editor/howl/tree/master/lib/howl/util
 
 local vim = assert(vim)
-assert(vim.inspect)
 
 -- These are for loading runtime modules lazily since they aren't available in
 -- the nvim binary as specified in executor.c
-setmetatable(vim, {
-  __index = function(t, key)
-    if key == 'treesitter' then
-      t.treesitter = require('vim.treesitter')
-      return t.treesitter
-    elseif key == 'filetype' then
-      t.filetype = require('vim.filetype')
-      return t.filetype
-    elseif key == 'F' then
-      t.F = require('vim.F')
-      return t.F
-    elseif require('vim.uri')[key] ~= nil then
-      -- Expose all `vim.uri` functions on the `vim` module.
-      t[key] = require('vim.uri')[key]
-      return t[key]
-    elseif key == 'lsp' then
-      t.lsp = require('vim.lsp')
-      return t.lsp
-    elseif key == 'highlight' then
-      t.highlight = require('vim.highlight')
-      return t.highlight
-    elseif key == 'diagnostic' then
-      t.diagnostic = require('vim.diagnostic')
-      return t.diagnostic
-    elseif key == 'keymap' then
-      t.keymap = require('vim.keymap')
-      return t.keymap
-    elseif key == 'ui' then
-      t.ui = require('vim.ui')
-      return t.ui
-    end
-  end
-})
+for k,v in pairs {
+  treesitter=true;
+  filetype = true;
+  F=true;
+  lsp=true;
+  highlight=true;
+  diagnostic=true;
+  keymap=true;
+  ui=true;
+} do vim._submodules[k] = v end
 
 vim.log = {
   levels = {
diff --git a/runtime/lua/vim/_init_packages.lua b/runtime/lua/vim/_init_packages.lua
index dcb402287c..7d27741f1b 100644
--- a/runtime/lua/vim/_init_packages.lua
+++ b/runtime/lua/vim/_init_packages.lua
@@ -50,7 +50,25 @@ table.insert(package.loaders, 2, vim._load_package)
 
 -- builtin functions which always should be available
 require'vim.shared'
-vim.inspect = require'vim.inspect'
+
+vim._submodules = {inspect=true}
+
+-- These are for loading runtime modules in the vim namespace lazily.
+setmetatable(vim, {
+  __index = function(t, key)
+    if vim._submodules[key] then
+      t[key] = require('vim.'..key)
+      return t[key]
+    elseif vim.startswith(key, 'uri_') then
+      local val = require('vim.uri')[key]
+      if val ~= nil then
+        -- Expose all `vim.uri` functions on the `vim` module.
+        t[key] = val
+        return t[key]
+      end
+    end
+  end
+})
 
 --- 
 ---@private
diff --git a/runtime/lua/vim/shared.lua b/runtime/lua/vim/shared.lua
index 48d0bd3672..8124b23eb1 100644
--- a/runtime/lua/vim/shared.lua
+++ b/runtime/lua/vim/shared.lua
@@ -1,8 +1,10 @@
 -- Functions shared by Nvim and its test-suite.
 --
--- The singular purpose of this module is to share code with the Nvim
--- test-suite. If, in the future, Nvim itself is used to run the test-suite
--- instead of "vanilla Lua", these functions could move to runtime/lua/vim/_editor.lua
+-- These are "pure" lua functions not depending of the state of the editor.
+-- Thus they should always be available whenever nvim-related lua code is run,
+-- regardless if it is code in the editor itself, or in worker threads/processes,
+-- or the test suite. (Eventually the test suite will be run in a worker process,
+-- so this wouldn't be a separate case to consider)
 
 local vim = vim or {}
 
-- 
cgit 


From 2783f4cc4a410cd3b73e8cdfbdf8c859c426c6c6 Mon Sep 17 00:00:00 2001
From: Dhruv Manilawala 
Date: Tue, 8 Mar 2022 09:45:43 +0530
Subject: feat(api): autocmd `group` can be either name or id (#17559)

* feat(api): `group` can be either string or int

This affects the following API functions:
- `vim.api.nvim_create_autocmd`
- `vim.api.nvim_get_autocmds`
- `vim.api.nvim_do_autocmd`

closes #17552

* refactor: add two maps for fast lookups

* fix: delete augroup info from id->name map

When in "stupid_legacy_mode", the value in name->id map would be updated
to `AUGROUP_DELETED`, but the entry would still remain in id->name. This
would create a problem in `augroup_name` function which would return the
name of the augroup instead of `--DELETED--`.

The id->name map is only used for fast loopup in `augroup_name` function
so there's no point in keeping the entry of deleted augroup in it.

Co-authored-by: TJ DeVries 
---
 runtime/doc/api.txt | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

(limited to 'runtime')

diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt
index 73536d174a..eefe6e5a47 100644
--- a/runtime/doc/api.txt
+++ b/runtime/doc/api.txt
@@ -3165,7 +3165,7 @@ nvim_create_autocmd({event}, {*opts})                  *nvim_create_autocmd()*
                               • create a |autocmd-buflocal| autocmd.
                               • NOTE: Cannot be used with {pattern}
 
-                            • group: (string) The augroup name
+                            • group: (string|int) The augroup name or id
                             • once: (boolean) - See |autocmd-once|
                             • nested: (boolean) - See |autocmd-nested|
                             • desc: (string) - Description of the autocmd
@@ -3213,7 +3213,7 @@ nvim_do_autocmd({event}, {*opts})                          *nvim_do_autocmd()*
                                "*".
                                • NOTE: Cannot be used with {buffer}
 
-                             • group (string) - autocmd group name
+                             • group (string|int) - autocmd group name or id
                              • modeline (boolean) - Default true, see
                                ||
 
@@ -3224,7 +3224,8 @@ nvim_get_autocmds({*opts})                               *nvim_get_autocmds()*
                     {opts}  Optional Parameters:
                             • event : Name or list of name of events to match
                               against
-                            • group (string): Name of group to match against
+                            • group (string|int): Name or id of group to match
+                              against
                             • pattern: Pattern or list of patterns to match
                               against. Cannot be used with {buffer}
                             • buffer: Buffer number or list of buffer numbers
-- 
cgit 


From 165cf1b48e4505b2b8aa9ff0522c9176a073b7ea Mon Sep 17 00:00:00 2001
From: zeertzjq 
Date: Wed, 23 Feb 2022 15:56:37 +0800
Subject: vim-patch:8.2.0997: cannot execute a register containing line
 continuation

Problem:    Cannot execute a register containing line continuation.
Solution:   Concatenate lines where needed. (Yegappan Lakshmanan,
            closes vim/vim#6272)
https://github.com/vim/vim/commit/856c1110c1cf0d6e44e387b70732ca4b4c8ef0f2

According to #2542 the "Future:" part was removed intentionally.
Use size_t in more places to reduce type casts.
---
 runtime/doc/repeat.txt | 5 +++++
 1 file changed, 5 insertions(+)

(limited to 'runtime')

diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt
index 05529dc90a..994f97bba0 100644
--- a/runtime/doc/repeat.txt
+++ b/runtime/doc/repeat.txt
@@ -161,6 +161,11 @@ Q			Repeat the last recorded register [count] times.
 			result of evaluating the expression is executed as an
 			Ex command.
 			Mappings are not recognized in these commands.
+			When the |line-continuation| character (\) is present
+			at the beginning of a line in a linewise register,
+			then it is combined with the previous line. This is
+			useful for yanking and executing parts of a Vim
+			script.
 
 							*:@:*
 :[addr]@:		Repeat last command-line.  First set cursor at line
-- 
cgit 


From a681b5eaca215448522973c95e8f751f1b586ea2 Mon Sep 17 00:00:00 2001
From: Christian Clason 
Date: Wed, 9 Mar 2022 08:40:16 +0100
Subject: vim-patch:partial 1588bc8ebee2 (#17656)

Update runtime files
https://github.com/vim/vim/commit/1588bc8ebee22f2855f27273fc2234fff370f86c

omit: doc updates
---
 runtime/autoload/dist/ft.vim | 2 +-
 runtime/compiler/jest.vim    | 8 +++++---
 runtime/compiler/sml.vim     | 8 ++++----
 runtime/ftplugin/ant.vim     | 6 ++++--
 runtime/ftplugin/aspvbs.vim  | 6 ++++--
 runtime/ftplugin/config.vim  | 6 ++++--
 runtime/ftplugin/csc.vim     | 6 ++++--
 runtime/ftplugin/csh.vim     | 2 +-
 runtime/ftplugin/dtd.vim     | 6 ++++--
 runtime/ftplugin/html.vim    | 6 ++++--
 runtime/ftplugin/java.vim    | 6 ++++--
 runtime/ftplugin/jsp.vim     | 6 ++++--
 runtime/ftplugin/pascal.vim  | 2 +-
 runtime/ftplugin/php.vim     | 6 ++++--
 runtime/ftplugin/sgml.vim    | 6 ++++--
 runtime/ftplugin/sh.vim      | 6 ++++--
 runtime/ftplugin/svg.vim     | 6 ++++--
 runtime/ftplugin/tcsh.vim    | 2 +-
 runtime/ftplugin/xhtml.vim   | 6 ++++--
 runtime/ftplugin/xml.vim     | 2 +-
 runtime/ftplugin/xsd.vim     | 6 ++++--
 runtime/ftplugin/xslt.vim    | 6 ++++--
 runtime/indent/vim.vim       | 4 ++--
 runtime/menu.vim             | 6 +++---
 24 files changed, 79 insertions(+), 47 deletions(-)

(limited to 'runtime')

diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim
index 54cb6ce70f..c52def1051 100644
--- a/runtime/autoload/dist/ft.vim
+++ b/runtime/autoload/dist/ft.vim
@@ -1,7 +1,7 @@
 " Vim functions for file type detection
 "
 " Maintainer:	Bram Moolenaar 
-" Last Change:	2022 Feb 22
+" Last Change:	2022 Mar 05
 
 " These functions are moved here from runtime/filetype.vim to make startup
 " faster.
diff --git a/runtime/compiler/jest.vim b/runtime/compiler/jest.vim
index fee70b7c55..a4bb549de1 100644
--- a/runtime/compiler/jest.vim
+++ b/runtime/compiler/jest.vim
@@ -1,7 +1,7 @@
 " Vim compiler file
 " Compiler:	Jest
 " Maintainer:	Doug Kearns 
-" Last Change:	2018 May 15
+" Last Change:	2021 Nov 20
 
 if exists("current_compiler")
   finish
@@ -15,12 +15,14 @@ endif
 let s:cpo_save = &cpo
 set cpo&vim
 
-" CompilerSet makeprg=npx\ jest\ --no-colors
+" CompilerSet makeprg=npx\ --no-install\ jest\ --no-colors
 
 CompilerSet makeprg=jest\ --no-colors
-CompilerSet errorformat=%E\ \ ●\ %m,
+CompilerSet errorformat=%-A\ \ ●\ Console,
+		       \%E\ \ ●\ %m,
 		       \%Z\ %\\{4}%.%#Error:\ %f:\ %m\ (%l:%c):%\\=,
 		       \%Z\ %\\{6}at\ %\\S%#\ (%f:%l:%c),
+		       \%Z\ %\\{6}at\ %\\S%#\ %f:%l:%c,
 		       \%+C\ %\\{4}%\\w%.%#,
 		       \%+C\ %\\{4}%[-+]%.%#,
 		       \%-C%.%#,
diff --git a/runtime/compiler/sml.vim b/runtime/compiler/sml.vim
index c7e1b1bf16..a0b13b6c8a 100644
--- a/runtime/compiler/sml.vim
+++ b/runtime/compiler/sml.vim
@@ -1,7 +1,7 @@
 " Vim compiler file
 " Compiler:	SML/NJ Compiler
 " Maintainer:	Doug Kearns 
-" Last Change:	2020 Feb 10
+" Last Change:	2022 Feb 09
 
 if exists("current_compiler")
   finish
@@ -16,10 +16,10 @@ let s:cpo_save = &cpo
 set cpo&vim
 
 CompilerSet makeprg=sml
-CompilerSet errorformat=%f:%l.%c-%\\d%\\+.%\\d%\\+\ %trror:\ %m,
+CompilerSet errorformat=%f:%l.%c-%e.%k\ %trror:\ %m,
 		       \%f:%l.%c\ %trror:\ %m,
-		       \%trror:\ %m
-		       \%f:%l.%c-%\\d%\\+.%\\d%\\+\ %tarning:\ %m,
+		       \%trror:\ %m,
+		       \%f:%l.%c-%e.%k\ %tarning:\ %m,
 		       \%f:%l.%c\ %tarning:\ %m,
 		       \%tarning:\ %m,
 		       \%-G%.%#
diff --git a/runtime/ftplugin/ant.vim b/runtime/ftplugin/ant.vim
index 5905858896..aee07ca4b9 100644
--- a/runtime/ftplugin/ant.vim
+++ b/runtime/ftplugin/ant.vim
@@ -1,8 +1,10 @@
 " Vim filetype plugin file
 " Language:	ant
-" Maintainer:	Dan Sharp 
+"
+" This runtime file is looking for a new maintainer.
+"
+" Former maintainer:	Dan Sharp
 " Last Changed: 20 Jan 2009
-" URL:		http://dwsharp.users.sourceforge.net/vim/ftplugin
 
 if exists("b:did_ftplugin") | finish | endif
 
diff --git a/runtime/ftplugin/aspvbs.vim b/runtime/ftplugin/aspvbs.vim
index 660dab4685..70a130d287 100644
--- a/runtime/ftplugin/aspvbs.vim
+++ b/runtime/ftplugin/aspvbs.vim
@@ -1,8 +1,10 @@
 " Vim filetype plugin file
 " Language:	aspvbs
-" Maintainer:	Dan Sharp 
+"
+" This runtime file is looking for a new maintainer.
+"
+" Former maintainer:	Dan Sharp
 " Last Changed: 20 Jan 2009
-" URL:		http://dwsharp.users.sourceforge.net/vim/ftplugin
 
 if exists("b:did_ftplugin") | finish | endif
 
diff --git a/runtime/ftplugin/config.vim b/runtime/ftplugin/config.vim
index 7fde42ebf5..73136cbc66 100644
--- a/runtime/ftplugin/config.vim
+++ b/runtime/ftplugin/config.vim
@@ -1,8 +1,10 @@
 " Vim filetype plugin file
 " Language:	config
-" Maintainer:	Dan Sharp 
+"
+" This runtime file is looking for a new maintainer.
+"
+" Former maintainer:	Dan Sharp
 " Last Changed: 20 Jan 2009
-" URL:		http://dwsharp.users.sourceforge.net/vim/ftplugin
 
 if exists("b:did_ftplugin") | finish | endif
 
diff --git a/runtime/ftplugin/csc.vim b/runtime/ftplugin/csc.vim
index 3a09c3bf8b..7b4126a503 100644
--- a/runtime/ftplugin/csc.vim
+++ b/runtime/ftplugin/csc.vim
@@ -1,8 +1,10 @@
 " Vim filetype plugin file
 " Language:	csc
-" Maintainer:	Dan Sharp 
+"
+" This runtime file is looking for a new maintainer.
+"
+" Former maintainer:	Dan Sharp
 " Last Changed: 20 Jan 2009
-" URL:		http://dwsharp.users.sourceforge.net/vim/ftplugin
 
 if exists("b:did_ftplugin") | finish | endif
 let b:did_ftplugin = 1
diff --git a/runtime/ftplugin/csh.vim b/runtime/ftplugin/csh.vim
index 929823219c..ca5da5a8b9 100644
--- a/runtime/ftplugin/csh.vim
+++ b/runtime/ftplugin/csh.vim
@@ -1,7 +1,7 @@
 " Vim filetype plugin file
 " Language:		csh
 " Maintainer:		Doug Kearns 
-" Previous Maintainer:	Dan Sharp 
+" Previous Maintainer:	Dan Sharp
 " Contributor:		Johannes Zellner 
 " Last Change:		2021 Oct 15
 
diff --git a/runtime/ftplugin/dtd.vim b/runtime/ftplugin/dtd.vim
index 6c08f6691d..a046118c70 100644
--- a/runtime/ftplugin/dtd.vim
+++ b/runtime/ftplugin/dtd.vim
@@ -1,8 +1,10 @@
 " Vim filetype plugin file
 " Language:	dtd
-" Maintainer:	Dan Sharp 
+"
+" This runtime file is looking for a new maintainer.
+"
+" Former maintainer:	Dan Sharp
 " Last Changed: 20 Jan 2009
-" URL:		http://dwsharp.users.sourceforge.net/vim/ftplugin
 
 if exists("b:did_ftplugin") | finish | endif
 let b:did_ftplugin = 1
diff --git a/runtime/ftplugin/html.vim b/runtime/ftplugin/html.vim
index 7579080ea5..3179aa2e88 100644
--- a/runtime/ftplugin/html.vim
+++ b/runtime/ftplugin/html.vim
@@ -1,8 +1,10 @@
 " Vim filetype plugin file
 " Language:	html
-" Maintainer:	Dan Sharp 
+"
+" This runtime file is looking for a new maintainer.
+"
+" Former maintainer:	Dan Sharp
 " Last Changed: 20 Jan 2009
-" URL:		http://dwsharp.users.sourceforge.net/vim/ftplugin
 
 if exists("b:did_ftplugin") | finish | endif
 let b:did_ftplugin = 1
diff --git a/runtime/ftplugin/java.vim b/runtime/ftplugin/java.vim
index 292cb6b166..74c8e8d1c1 100644
--- a/runtime/ftplugin/java.vim
+++ b/runtime/ftplugin/java.vim
@@ -1,8 +1,10 @@
 " Vim filetype plugin file
 " Language:	Java
-" Maintainer:	Dan Sharp 
+"
+" This runtime file is looking for a new maintainer.
+"
+" Former maintainer:	Dan Sharp
 " Last Change:  2012 Mar 11
-" URL:		http://dwsharp.users.sourceforge.net/vim/ftplugin
 
 if exists("b:did_ftplugin") | finish | endif
 let b:did_ftplugin = 1
diff --git a/runtime/ftplugin/jsp.vim b/runtime/ftplugin/jsp.vim
index fbba863b32..18136ccc24 100644
--- a/runtime/ftplugin/jsp.vim
+++ b/runtime/ftplugin/jsp.vim
@@ -1,8 +1,10 @@
 " Vim filetype plugin file
 " Language:	jsp
-" Maintainer:	Dan Sharp 
+"
+" This runtime file is looking for a new maintainer.
+"
+" Former maintainer:	Dan Sharp
 " Last Changed: 20 Jan 2009
-" URL:		http://dwsharp.users.sourceforge.net/vim/ftplugin
 
 if exists("b:did_ftplugin") | finish | endif
 
diff --git a/runtime/ftplugin/pascal.vim b/runtime/ftplugin/pascal.vim
index 2de92563ae..aba1e54f27 100644
--- a/runtime/ftplugin/pascal.vim
+++ b/runtime/ftplugin/pascal.vim
@@ -1,7 +1,7 @@
 " Vim filetype plugin file
 " Language:		Pascal
 " Maintainer:		Doug Kearns 
-" Previous Maintainer:	Dan Sharp 
+" Previous Maintainer:	Dan Sharp
 " Last Change:		2021 Apr 23
 
 if exists("b:did_ftplugin") | finish | endif
diff --git a/runtime/ftplugin/php.vim b/runtime/ftplugin/php.vim
index a2f8b4d8d3..3ff0828ffe 100644
--- a/runtime/ftplugin/php.vim
+++ b/runtime/ftplugin/php.vim
@@ -1,8 +1,10 @@
 " Vim filetype plugin file
 " Language:	php
-" Maintainer:	Dan Sharp 
+"
+" This runtime file is looking for a new maintainer.
+"
+" Former maintainer:	Dan Sharp
 " Last Changed: 20 Jan 2009
-" URL:		http://dwsharp.users.sourceforge.net/vim/ftplugin
 
 if exists("b:did_ftplugin") | finish | endif
 
diff --git a/runtime/ftplugin/sgml.vim b/runtime/ftplugin/sgml.vim
index bf63efbf1f..ef52125c68 100644
--- a/runtime/ftplugin/sgml.vim
+++ b/runtime/ftplugin/sgml.vim
@@ -1,8 +1,10 @@
 " Vim filetype plugin file
 " Language:	sgml
-" Maintainer:	Dan Sharp 
+"
+" This runtime file is looking for a new maintainer.
+"
+" Former maintainer:	Dan Sharp
 " Last Changed: 20 Jan 2009
-" URL:		http://dwsharp.users.sourceforge.net/vim/ftplugin
 
 if exists("b:did_ftplugin") | finish | endif
 
diff --git a/runtime/ftplugin/sh.vim b/runtime/ftplugin/sh.vim
index 593fcec927..93a46f63e2 100644
--- a/runtime/ftplugin/sh.vim
+++ b/runtime/ftplugin/sh.vim
@@ -1,8 +1,10 @@
 " Vim filetype plugin file
 " Language:	sh
-" Maintainer:	Dan Sharp 
+"
+" This runtime file is looking for a new maintainer.
+"
+" Former maintainer:	Dan Sharp
 " Last Changed: 20 Jan 2009
-" URL:		http://dwsharp.users.sourceforge.net/vim/ftplugin
 
 if exists("b:did_ftplugin") | finish | endif
 let b:did_ftplugin = 1
diff --git a/runtime/ftplugin/svg.vim b/runtime/ftplugin/svg.vim
index 8fff6ea32c..6f16b1a0f4 100644
--- a/runtime/ftplugin/svg.vim
+++ b/runtime/ftplugin/svg.vim
@@ -1,8 +1,10 @@
 " Vim filetype plugin file
 " Language:	svg
-" Maintainer:	Dan Sharp 
+"
+" This runtime file is looking for a new maintainer.
+"
+" Former maintainer:	Dan Sharp
 " Last Changed: 20 Jan 2009
-" URL:		http://dwsharp.users.sourceforge.net/vim/ftplugin
 
 if exists("b:did_ftplugin") | finish | endif
 
diff --git a/runtime/ftplugin/tcsh.vim b/runtime/ftplugin/tcsh.vim
index 33f1aabf68..85d3873b33 100644
--- a/runtime/ftplugin/tcsh.vim
+++ b/runtime/ftplugin/tcsh.vim
@@ -1,7 +1,7 @@
 " Vim filetype plugin file
 " Language:		tcsh
 " Maintainer:		Doug Kearns 
-" Previous Maintainer:	Dan Sharp 
+" Previous Maintainer:	Dan Sharp
 " Last Change:		2021 Oct 15
 
 if exists("b:did_ftplugin") | finish | endif
diff --git a/runtime/ftplugin/xhtml.vim b/runtime/ftplugin/xhtml.vim
index 21ed3e1100..d2a1c0b566 100644
--- a/runtime/ftplugin/xhtml.vim
+++ b/runtime/ftplugin/xhtml.vim
@@ -1,8 +1,10 @@
 " Vim filetype plugin file
 " Language:	xhtml
-" Maintainer:	Dan Sharp 
+"
+" This runtime file is looking for a new maintainer.
+"
+" Former maintainer:	Dan Sharp
 " Last Changed: 20 Jan 2009
-" URL:		http://dwsharp.users.sourceforge.net/vim/ftplugin
 
 if exists("b:did_ftplugin") | finish | endif
 
diff --git a/runtime/ftplugin/xml.vim b/runtime/ftplugin/xml.vim
index 1d43521155..9aa188cecc 100644
--- a/runtime/ftplugin/xml.vim
+++ b/runtime/ftplugin/xml.vim
@@ -3,7 +3,7 @@
 "   Maintainer:	Christian Brabandt 
 " Last Changed: Dec 07th, 2018
 "   Repository: https://github.com/chrisbra/vim-xml-ftplugin
-" Previous Maintainer:	Dan Sharp 
+" Previous Maintainer:	Dan Sharp
 "          URL:		      http://dwsharp.users.sourceforge.net/vim/ftplugin
 
 if exists("b:did_ftplugin") | finish | endif
diff --git a/runtime/ftplugin/xsd.vim b/runtime/ftplugin/xsd.vim
index 6a4a193656..7d3efbb390 100644
--- a/runtime/ftplugin/xsd.vim
+++ b/runtime/ftplugin/xsd.vim
@@ -1,8 +1,10 @@
 " Vim filetype plugin file
 " Language:	xsd
-" Maintainer:	Dan Sharp 
+"
+" This runtime file is looking for a new maintainer.
+"
+" Former maintainer:	Dan Sharp
 " Last Changed: 20 Jan 2009
-" URL:		http://dwsharp.users.sourceforge.net/vim/ftplugin
 
 if exists("b:did_ftplugin") | finish | endif
 
diff --git a/runtime/ftplugin/xslt.vim b/runtime/ftplugin/xslt.vim
index 1a5ee62865..9d2def107b 100644
--- a/runtime/ftplugin/xslt.vim
+++ b/runtime/ftplugin/xslt.vim
@@ -1,8 +1,10 @@
 " Vim filetype plugin file
 " Language:	xslt
-" Maintainer:	Dan Sharp 
+"
+" This runtime file is looking for a new maintainer.
+"
+" Former maintainer:	Dan Sharp
 " Last Changed: 20 Jan 2009
-" URL:		http://dwsharp.users.sourceforge.net/vim/ftplugin
 
 if exists("b:did_ftplugin") | finish | endif
 
diff --git a/runtime/indent/vim.vim b/runtime/indent/vim.vim
index f5a94940bd..cd2d4982d8 100644
--- a/runtime/indent/vim.vim
+++ b/runtime/indent/vim.vim
@@ -1,7 +1,7 @@
 " Vim indent file
 " Language:	Vim script
 " Maintainer:	Bram Moolenaar 
-" Last Change:	2022 Feb 23
+" Last Change:	2022 Mar 01
 
 " Only load this indent file when no other was loaded.
 if exists("b:did_indent")
@@ -105,7 +105,7 @@ function GetVimIndentIntern()
     " terminated dict.
     " ":function" starts a block but "function(" doesn't.
     if prev_text !~ '^\s*au\%[tocmd]' && prev_text !~ '^\s*{.*}'
-      let i = match(prev_text, '\(^\||\)\s*\(export\s\+\)\?\({\|\(if\|wh\%[ile]\|for\|try\|cat\%[ch]\|fina\|finall\%[y]\|def\|el\%[seif]\)\>\|fu\%[nction]\s\)')
+      let i = match(prev_text, '\(^\||\)\s*\(export\s\+\)\?\({\|\(if\|wh\%[ile]\|for\|try\|cat\%[ch]\|fina\|finall\%[y]\|def\|el\%[seif]\)\>\|fu\%[nction][! ]\)')
       if i >= 0
         let ind += shiftwidth()
 	if strpart(prev_text, i, 1) == '|' && has('syntax_items')
diff --git a/runtime/menu.vim b/runtime/menu.vim
index 701dd33cdd..956b941971 100644
--- a/runtime/menu.vim
+++ b/runtime/menu.vim
@@ -569,9 +569,9 @@ func! s:XxdConv()
     %!mc vim:xxd
   else
     call s:XxdFind()
-    exe '%!' . g:xxdprogram
+    exe ':%!' . g:xxdprogram
   endif
-  if getline(1) =~ "^0000000:"		" only if it worked
+  if getline(1) =~ "^00000000:"		" only if it worked
     set ft=xxd
   endif
   let &mod = mod
@@ -583,7 +583,7 @@ func! s:XxdBack()
     %!mc vim:xxd -r
   else
     call s:XxdFind()
-    exe '%!' . g:xxdprogram . ' -r'
+    exe ':%!' . g:xxdprogram . ' -r'
   endif
   set ft=
   doautocmd filetypedetect BufReadPost
-- 
cgit 


From b743e415fe0075212f072f9f4e2fa7aed7f8a28f Mon Sep 17 00:00:00 2001
From: Sean Dewar 
Date: Wed, 9 Mar 2022 07:44:28 +0000
Subject: vim-patch:partial 1588bc8ebee2 (#17657)

Update runtime files
https://github.com/vim/vim/commit/1588bc8ebee22f2855f27273fc2234fff370f86c

docs only

skip :argdedupe changes (need v8.2.3888)
skip sound_playfile changes (need +sound)
skip fuzzy-matching changes in *command-attributes* (need #17536)
---
 runtime/doc/builtin.txt  |   2 +-
 runtime/doc/channel.txt  |   4 +-
 runtime/doc/eval.txt     | 168 ++++++++++++++++++++++++-----------------------
 runtime/doc/insert.txt   |   5 +-
 runtime/doc/pattern.txt  |   9 +--
 runtime/doc/quickfix.txt |  53 ++++++++-------
 runtime/doc/syntax.txt   |   2 +-
 runtime/doc/uganda.txt   |  11 ++--
 8 files changed, 134 insertions(+), 120 deletions(-)

(limited to 'runtime')

diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt
index b0859d1cea..5b0c7918e0 100644
--- a/runtime/doc/builtin.txt
+++ b/runtime/doc/builtin.txt
@@ -4900,7 +4900,7 @@ matchfuzzy({list}, {str} [, {dict}])			*matchfuzzy()*
 		empty list is returned. If length of {str} is greater than
 		256, then returns an empty list.
 
-		Refer to |fuzzy-match| for more information about fuzzy
+		Refer to |fuzzy-matching| for more information about fuzzy
 		matching strings.
 
 		Example: >
diff --git a/runtime/doc/channel.txt b/runtime/doc/channel.txt
index e14427494d..d4bed7a5f2 100644
--- a/runtime/doc/channel.txt
+++ b/runtime/doc/channel.txt
@@ -229,12 +229,12 @@ prompt. >
 	  call chansend(g:shell_job, [a:text, ''])
 	endfunc
 
-	" Function handling output from the shell: Added above the prompt.
+	" Function handling output from the shell: Add it above the prompt.
 	func GotOutput(channel, msg, name)
 	  call append(line("$") - 1, a:msg)
 	endfunc
 
-	" Function handling the shell exit: close the window.
+	" Function handling the shell exits: close the window.
 	func JobExit(job, status, event)
 	  quit!
 	endfunc
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 3015e232a7..9fcdbe4cc3 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -1651,6 +1651,7 @@ Some variables can be set by the user, but the type cannot be changed.
 					*v:argv* *argv-variable*
 v:argv		The command line arguments Vim was invoked with.  This is a
 		list of strings.  The first item is the Vim command.
+		See |v:progpath| for the command with full path.
 
 					*v:beval_col* *beval_col-variable*
 v:beval_col	The number of the column, over which the mouse pointer is.
@@ -2027,6 +2028,9 @@ v:null		Special value used to put "null" in JSON and NIL in msgpack.
 		used as a String (e.g. in |expr5| with string concatenation
 		operator) and to zero when used as a Number (e.g. in |expr5|
 		or |expr7| when used with numeric operators). Read-only.
+		In some places `v:null` can be used for a List, Dict, etc.
+		that is not set.  That is slightly different than an empty
+		List, Dict, etc.
 
 					*v:numbermax* *numbermax-variable*
 v:numbermax	Maximum value of a number.
@@ -3062,16 +3066,17 @@ text...
 			opposite of |:lockvar|.
 
 :if {expr1}			*:if* *:end* *:endif* *:en* *E171* *E579* *E580*
-:en[dif]		Execute the commands until the next matching ":else"
-			or ":endif" if {expr1} evaluates to non-zero.
+:en[dif]		Execute the commands until the next matching `:else`
+			or `:endif` if {expr1} evaluates to non-zero.
 			Although the short forms work, it is recommended to
-			always use `:endif` to avoid confusion.
+			always use `:endif` to avoid confusion and to make
+			auto-indenting work properly.
 
 			From Vim version 4.5 until 5.0, every Ex command in
-			between the ":if" and ":endif" is ignored.  These two
+			between the `:if` and `:endif` is ignored.  These two
 			commands were just to allow for future expansions in a
 			backward compatible way.  Nesting was allowed.  Note
-			that any ":else" or ":elseif" was ignored, the "else"
+			that any `:else` or `:elseif` was ignored, the `else`
 			part was not executed either.
 
 			You can use this to remain compatible with older
@@ -3080,32 +3085,32 @@ text...
 				:  version-5-specific-commands
 				:endif
 <			The commands still need to be parsed to find the
-			"endif".  Sometimes an older Vim has a problem with a
-			new command.  For example, ":silent" is recognized as
-			a ":substitute" command.  In that case ":execute" can
+			`endif`.  Sometimes an older Vim has a problem with a
+			new command.  For example, `:silent` is recognized as
+			a `:substitute` command.  In that case `:execute` can
 			avoid problems: >
 				:if version >= 600
 				:  execute "silent 1,$delete"
 				:endif
 <
-			NOTE: The ":append" and ":insert" commands don't work
-			properly in between ":if" and ":endif".
+			NOTE: The `:append` and `:insert` commands don't work
+			properly in between `:if` and `:endif`.
 
 						*:else* *:el* *E581* *E583*
-:el[se]			Execute the commands until the next matching ":else"
-			or ":endif" if they previously were not being
+:el[se]			Execute the commands until the next matching `:else`
+			or `:endif` if they previously were not being
 			executed.
 
 					*:elseif* *:elsei* *E582* *E584*
-:elsei[f] {expr1}	Short for ":else" ":if", with the addition that there
-			is no extra ":endif".
+:elsei[f] {expr1}	Short for `:else` `:if`, with the addition that there
+			is no extra `:endif`.
 
 :wh[ile] {expr1}			*:while* *:endwhile* *:wh* *:endw*
 						*E170* *E585* *E588* *E733*
-:endw[hile]		Repeat the commands between ":while" and ":endwhile",
+:endw[hile]		Repeat the commands between `:while` and `:endwhile`,
 			as long as {expr1} evaluates to non-zero.
 			When an error is detected from a command inside the
-			loop, execution continues after the "endwhile".
+			loop, execution continues after the `endwhile`.
 			Example: >
 				:let lnum = 1
 				:while lnum <= line("$")
@@ -3113,16 +3118,16 @@ text...
 				   :let lnum = lnum + 1
 				:endwhile
 <
-			NOTE: The ":append" and ":insert" commands don't work
-			properly inside a ":while" and ":for" loop.
+			NOTE: The `:append` and `:insert` commands don't work
+			properly inside a `:while` and `:for` loop.
 
 :for {var} in {object}					*:for* *E690* *E732*
 :endfo[r]						*:endfo* *:endfor*
-			Repeat the commands between ":for" and ":endfor" for
+			Repeat the commands between `:for` and `:endfor` for
 			each item in {object}.  {object} can be a |List| or
 			a |Blob|.  Variable {var} is set to the value of each
 			item.  When an error is detected for a command inside
-			the loop, execution continues after the "endfor".
+			the loop, execution continues after the `endfor`.
 			Changing {object} inside the loop affects what items
 			are used.  Make a copy if this is unwanted: >
 				:for item in copy(mylist)
@@ -3146,7 +3151,7 @@ text...
 
 :for [{var1}, {var2}, ...] in {listlist}
 :endfo[r]
-			Like ":for" above, but each item in {listlist} must be
+			Like `:for` above, but each item in {listlist} must be
 			a list, of which each item is assigned to {var1},
 			{var2}, etc.  Example: >
 				:for [lnum, col] in [[1, 3], [2, 5], [3, 8]]
@@ -3154,38 +3159,39 @@ text...
 				:endfor
 <
 						*:continue* *:con* *E586*
-:con[tinue]		When used inside a ":while" or ":for" loop, jumps back
+:con[tinue]		When used inside a `:while` or `:for` loop, jumps back
 			to the start of the loop.
-			If it is used after a |:try| inside the loop but
-			before the matching |:finally| (if present), the
-			commands following the ":finally" up to the matching
-			|:endtry| are executed first.  This process applies to
-			all nested ":try"s inside the loop.  The outermost
-			":endtry" then jumps back to the start of the loop.
+
+			If it is used after a `:try` inside the loop but
+			before the matching `:finally` (if present), the
+			commands following the `:finally` up to the matching
+			`:endtry` are executed first.  This process applies to
+			all nested `:try`s inside the loop.  The outermost
+			`:endtry` then jumps back to the start of the loop.
 
 						*:break* *:brea* *E587*
-:brea[k]		When used inside a ":while" or ":for" loop, skips to
-			the command after the matching ":endwhile" or
-			":endfor".
-			If it is used after a |:try| inside the loop but
-			before the matching |:finally| (if present), the
-			commands following the ":finally" up to the matching
-			|:endtry| are executed first.  This process applies to
-			all nested ":try"s inside the loop.  The outermost
-			":endtry" then jumps to the command after the loop.
+:brea[k]		When used inside a `:while` or `:for` loop, skips to
+			the command after the matching `:endwhile` or
+			`:endfor`.
+			If it is used after a `:try` inside the loop but
+			before the matching `:finally` (if present), the
+			commands following the `:finally` up to the matching
+			`:endtry` are executed first.  This process applies to
+			all nested `:try`s inside the loop.  The outermost
+			`:endtry` then jumps to the command after the loop.
 
 :try				*:try* *:endt* *:endtry* *E600* *E601* *E602*
 :endt[ry]		Change the error handling for the commands between
-			":try" and ":endtry" including everything being
-			executed across ":source" commands, function calls,
+			`:try` and `:endtry` including everything being
+			executed across `:source` commands, function calls,
 			or autocommand invocations.
 
 			When an error or interrupt is detected and there is
-			a |:finally| command following, execution continues
-			after the ":finally".  Otherwise, or when the
-			":endtry" is reached thereafter, the next
-			(dynamically) surrounding ":try" is checked for
-			a corresponding ":finally" etc.  Then the script
+			a `:finally` command following, execution continues
+			after the `:finally`.  Otherwise, or when the
+			`:endtry` is reached thereafter, the next
+			(dynamically) surrounding `:try` is checked for
+			a corresponding `:finally` etc.  Then the script
 			processing is terminated.  Whether a function
 			definition has an "abort" argument does not matter.
 			Example: >
@@ -3193,9 +3199,9 @@ text...
 		echomsg "not reached"
 <
 			Moreover, an error or interrupt (dynamically) inside
-			":try" and ":endtry" is converted to an exception.  It
-			can be caught as if it were thrown by a |:throw|
-			command (see |:catch|).  In this case, the script
+			`:try` and `:endtry` is converted to an exception.  It
+			can be caught as if it were thrown by a `:throw`
+			command (see `:catch`).  In this case, the script
 			processing is not terminated.
 
 			The value "Vim:Interrupt" is used for an interrupt
@@ -3211,11 +3217,11 @@ text...
 		try | edit | catch /^Vim(edit):E\d\+/ | echo "error" | endtry
 <
 					*:cat* *:catch* *E603* *E604* *E605*
-:cat[ch] /{pattern}/	The following commands until the next |:catch|,
-			|:finally|, or |:endtry| that belongs to the same
-			|:try| as the ":catch" are executed when an exception
+:cat[ch] /{pattern}/	The following commands until the next `:catch`,
+			`:finally`, or `:endtry` that belongs to the same
+			`:try` as the `:catch` are executed when an exception
 			matching {pattern} is being thrown and has not yet
-			been caught by a previous ":catch".  Otherwise, these
+			been caught by a previous `:catch`.  Otherwise, these
 			commands are skipped.
 			When {pattern} is omitted all errors are caught.
 			Examples: >
@@ -3239,27 +3245,27 @@ text...
 			locales.
 
 					*:fina* *:finally* *E606* *E607*
-:fina[lly]		The following commands until the matching |:endtry|
+:fina[lly]		The following commands until the matching `:endtry`
 			are executed whenever the part between the matching
-			|:try| and the ":finally" is left:  either by falling
-			through to the ":finally" or by a |:continue|,
-			|:break|, |:finish|, or |:return|, or by an error or
-			interrupt or exception (see |:throw|).
+			`:try` and the `:finally` is left:  either by falling
+			through to the `:finally` or by a `:continue`,
+			`:break`, `:finish`, or `:return`, or by an error or
+			interrupt or exception (see `:throw`).
 
 							*:th* *:throw* *E608*
 :th[row] {expr1}	The {expr1} is evaluated and thrown as an exception.
-			If the ":throw" is used after a |:try| but before the
-			first corresponding |:catch|, commands are skipped
-			until the first ":catch" matching {expr1} is reached.
-			If there is no such ":catch" or if the ":throw" is
-			used after a ":catch" but before the |:finally|, the
-			commands following the ":finally" (if present) up to
-			the matching |:endtry| are executed.  If the ":throw"
-			is after the ":finally", commands up to the ":endtry"
-			are skipped.  At the ":endtry", this process applies
-			again for the next dynamically surrounding ":try"
+			If the `:throw` is used after a `:try` but before the
+			first corresponding `:catch`, commands are skipped
+			until the first `:catch` matching {expr1} is reached.
+			If there is no such `:catch` or if the `:throw` is
+			used after a `:catch` but before the `:finally`, the
+			commands following the `:finally` (if present) up to
+			the matching `:endtry` are executed.  If the `:throw`
+			is after the `:finally`, commands up to the `:endtry`
+			are skipped.  At the `:endtry`, this process applies
+			again for the next dynamically surrounding `:try`
 			(which may be found in a calling function or sourcing
-			script), until a matching ":catch" has been found.
+			script), until a matching `:catch` has been found.
 			If the exception is not caught, the command processing
 			is terminated.
 			Example: >
@@ -3274,7 +3280,7 @@ text...
 			Also see |:comment|.
 			Use "\n" to start a new line.  Use "\r" to move the
 			cursor to the first column.
-			Uses the highlighting set by the |:echohl| command.
+			Uses the highlighting set by the `:echohl` command.
 			Cannot be followed by a comment.
 			Example: >
 		:echo "the value of 'shell' is" &shell
@@ -3283,9 +3289,9 @@ text...
 			And since Vim mostly postpones redrawing until it's
 			finished with a sequence of commands this happens
 			quite often.  To avoid that a command from before the
-			":echo" causes a redraw afterwards (redraws are often
+			`:echo` causes a redraw afterwards (redraws are often
 			postponed until you type something), force a redraw
-			with the |:redraw| command.  Example: >
+			with the `:redraw` command.  Example: >
 		:new | redraw | echo "there is a new window"
 <							*:echo-self-refer*
 			When printing nested containers echo prints second
@@ -3304,13 +3310,13 @@ text...
 							*:echon*
 :echon {expr1} ..	Echoes each {expr1}, without anything added.  Also see
 			|:comment|.
-			Uses the highlighting set by the |:echohl| command.
+			Uses the highlighting set by the `:echohl` command.
 			Cannot be followed by a comment.
 			Example: >
 				:echon "the value of 'shell' is " &shell
 <
-			Note the difference between using ":echo", which is a
-			Vim command, and ":!echo", which is an external shell
+			Note the difference between using `:echo`, which is a
+			Vim command, and `:!echo`, which is an external shell
 			command: >
 		:!echo %		--> filename
 <			The arguments of ":!" are expanded, see |:_%|. >
@@ -3326,8 +3332,8 @@ text...
 
 							*:echoh* *:echohl*
 :echoh[l] {name}	Use the highlight group {name} for the following
-			|:echo|, |:echon| and |:echomsg| commands.  Also used
-			for the |input()| prompt.  Example: >
+			`:echo`, `:echon` and `:echomsg` commands.  Also used
+			for the `input()` prompt.  Example: >
 		:echohl WarningMsg | echo "Don't panic!" | echohl None
 <			Don't forget to set the group back to "None",
 			otherwise all following echo's will be highlighted.
@@ -3336,14 +3342,14 @@ text...
 :echom[sg] {expr1} ..	Echo the expression(s) as a true message, saving the
 			message in the |message-history|.
 			Spaces are placed between the arguments as with the
-			|:echo| command.  But unprintable characters are
+			`:echo` command.  But unprintable characters are
 			displayed, not interpreted.
-			The parsing works slightly different from |:echo|,
-			more like |:execute|.  All the expressions are first
+			The parsing works slightly different from `:echo`,
+			more like `:execute`.  All the expressions are first
 			evaluated and concatenated before echoing anything.
 			If expressions does not evaluate to a Number or
 			String, string() is used to turn it into a string.
-			Uses the highlighting set by the |:echohl| command.
+			Uses the highlighting set by the `:echohl` command.
 			Example: >
 		:echomsg "It's a Zizzer Zazzer Zuzz, as you can plainly see."
 <			See |:echo-redraw| to avoid the message disappearing
@@ -3353,12 +3359,12 @@ text...
 			message in the |message-history|.  When used in a
 			script or function the line number will be added.
 			Spaces are placed between the arguments as with the
-			|:echomsg| command.  When used inside a try conditional,
+			`:echomsg` command.  When used inside a try conditional,
 			the message is raised as an error exception instead
 			(see |try-echoerr|).
 			Example: >
 		:echoerr "This script just failed!"
-<			If you just want a highlighted message use |:echohl|.
+<			If you just want a highlighted message use `:echohl`.
 			And to get a beep: >
 		:exe "normal \"
 <
diff --git a/runtime/doc/insert.txt b/runtime/doc/insert.txt
index 39682a2ab2..d9aecfe4fd 100644
--- a/runtime/doc/insert.txt
+++ b/runtime/doc/insert.txt
@@ -269,8 +269,8 @@ start	    allow backspacing over the start position of insert; CTRL-W and
 When 'backspace' is empty, Vi compatible backspacing is used.  You cannot
 backspace over autoindent, before column 1 or before where insert started.
 
-For backwards compatibility the values "0", "1" and "2" are also allowed, see
-|'backspace'|.
+For backwards compatibility the values "0", "1", "2" and "3" are also allowed,
+see |'backspace'|.
 
 If the 'backspace' option does contain "eol" and the cursor is in column 1
 when one of the three keys is used, the current line is joined with the
@@ -798,6 +798,7 @@ CTRL-X CTRL-K		Search the files given with the 'dictionary' option
 			the 'dictionary' option is empty.
 			For suggestions where to find a list of words, see the
 			'dictionary' option.
+			'ignorecase', 'smartcase' and 'infercase' apply.
 
 	CTRL-K	or
 	CTRL-N		Search forward for next matching keyword.  This
diff --git a/runtime/doc/pattern.txt b/runtime/doc/pattern.txt
index c3bd5baff2..680b853dab 100644
--- a/runtime/doc/pattern.txt
+++ b/runtime/doc/pattern.txt
@@ -153,9 +153,10 @@ index, on which the cursor is. This can look like this: >
 Note: the count does not take offset into account.
 
 When no match is found you get the error: *E486* Pattern not found
-Note that for the |:global| command this behaves like a normal message, for Vi
-compatibility.  For the |:s| command the "e" flag can be used to avoid the
-error message |:s_flags|.
+Note that for the `:global` command, you get a normal message "Pattern not
+found", for Vi compatibility.
+For the |:s| command the "e" flag can be used to avoid the error message
+|:s_flags|.
 
 					*search-offset* *{offset}*
 These commands search for the specified pattern.  With "/" and "?" an
@@ -1422,7 +1423,7 @@ Finally, these constructs are unique to Perl:
 		":2match" for another plugin.
 
 ==============================================================================
-11. Fuzzy matching					*fuzzy-match*
+11. Fuzzy matching					*fuzzy-matching*
 
 Fuzzy matching refers to matching strings using a non-exact search string.
 Fuzzy matching will match a string, if all the characters in the search string
diff --git a/runtime/doc/quickfix.txt b/runtime/doc/quickfix.txt
index 601384a71f..0345b14b7a 100644
--- a/runtime/doc/quickfix.txt
+++ b/runtime/doc/quickfix.txt
@@ -642,22 +642,25 @@ instead.  If the buffer in the used window has changed, and the error is in
 another file, jumping to the error will fail.  You will first have to make
 sure the window contains a buffer which can be abandoned.
 
-The following steps are used to find a window to open the file selected from
-the quickfix window:
-1. If 'switchbuf' contains "usetab", then find a window in any tabpage
-   (starting with the first tabpage) that has the selected file and jump to
-   it.
-2. Otherwise find a window displaying the selected file in the current tab
-   page (starting with the window before the quickfix window) and use it.
-3. Otherwise find a window displaying a normal buffer ('buftype' is empty)
-   starting with the window before the quickfix window. If a window is found,
-   open the file in that window.
-4. If a usable window is not found and 'switchbuf' contains "uselast", then
-   open the file in the last used window.
-5. Otherwise open the file in the window before the quickfix window.  If there
-   is no previous window, then open the file in the next window.
-6. If a usable window is not found in the above steps, then create a new
-   horizontally split window above the quickfix window and open the file.
+When you select a file from the quickfix window, the following steps are used
+to find a window to edit the file:
+
+1. If a window displaying the selected file is present in the current tabpage
+   (starting with the window before the quickfix window), then that window is
+   used.
+2. If the above step fails and if 'switchbuf' contains "usetab" and a window
+   displaying the selected file is present in any one of the tabpages
+   (starting with the first tabpage) then that window is used.
+3. If the above step fails then a window in the current tabpage displaying a
+   buffer with 'buftype' not set (starting with the window before the quickfix
+   window) is used.
+4. If the above step fails and if 'switchbuf' contains "uselast", then the
+   previously accessed window is used.
+5. If the above step fails then the window before the quickfix window is used.
+   If there is no previous window, then the window after the quickfix window
+   is used.
+6. If the above step fails, then a new horizontally split window above the
+   quickfix window is used.
 
 					*CTRL-W_* *CTRL-W_*
 You can use CTRL-W  to open a new window and jump to the error there.
@@ -697,13 +700,15 @@ this window, the displayed location list is used.
 When you select a file from the location list window, the following steps are
 used to find a window to edit the file:
 
-1. If a window with the location list displayed in the location list window is
-   present, then the file is opened in that window.
-2. If the above step fails and if the file is already opened in another
-   window, then that window is used.
-3. If the above step fails then an existing window showing a buffer with
-   'buftype' not set is used.
-4. If the above step fails, then the file is edited in a new window.
+1. If a non-quickfix window associated with the location list is present in
+   the current tabpage, then that window is used.
+2. If the above step fails and if the file is already opened in another window
+   in the current tabpage, then that window is used.
+3. If the above step fails and 'switchbuf' contains "usetab" and if the file
+   is opened in a window in any one of the tabpages, then that window is used.
+4. If the above step fails then a window in the current tabpage showing a
+   buffer with 'buftype' not set is used.
+5. If the above step fails, then the file is edited in a new window.
 
 In all of the above cases, if the location list for the selected window is not
 yet set, then it is set to the location list displayed in the location list
@@ -1036,7 +1041,7 @@ commands can be combined to create a NewGrep command: >
 			     matching is used to find matching lines. In this
 			     case, {pattern} is treated as a literal string
 			     instead of a regular expression.  See
-			     |fuzzy-match| for more information about fuzzy
+			     |fuzzy-matching| for more information about fuzzy
 			     matching strings.
 
 			|QuickFixCmdPre| and |QuickFixCmdPost| are triggered.
diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt
index 9084c5315a..c8280173fb 100644
--- a/runtime/doc/syntax.txt
+++ b/runtime/doc/syntax.txt
@@ -4388,7 +4388,7 @@ Leading context			*:syn-lc* *:syn-leading* *:syn-context*
 
 Note: This is an obsolete feature, only included for backwards compatibility
 with previous Vim versions.  It's now recommended to use the |/\@<=| construct
-in the pattern.
+in the pattern.  You can also often use |/\zs|.
 
 The "lc" offset specifies leading context -- a part of the pattern that must
 be present, but is not considered part of the match.  An offset of "lc=n" will
diff --git a/runtime/doc/uganda.txt b/runtime/doc/uganda.txt
index 79519da51e..23dfa082a0 100644
--- a/runtime/doc/uganda.txt
+++ b/runtime/doc/uganda.txt
@@ -129,11 +129,12 @@ Kibaale Children's Centre		*kcc* *Kibaale*  *charity*
 Kibaale Children's Centre (KCC) is located in Kibaale, a small town in the
 south of Uganda, near Tanzania, in East Africa.  The area is known as Rakai
 District.  The population is mostly farmers.  Although people are poor, there
-is enough food.  But this district is suffering from AIDS more than any other
-part of the world.  Some say that it started there.  Estimations are that 10
-to 30% of the Ugandans are infected with HIV.  Because parents die, there are
-many orphans.  In this district about 60,000 children have lost one or both
-parents, out of a population of 350,000.  And this is still continuing.
+usually is enough food.  But this district is suffering from AIDS more than
+any other part of the world.  Some say that it started there.  Estimations are
+that in the past 10 to 30% of the Ugandans are infected with HIV.  Because
+parents die, there are many orphans.  In this district about 60,000 children
+have lost one or both parents, out of a population of 350,000.  Although AIDS
+is now mostly under control, the problems are still continuing.
 
 The children need a lot of help.  The KCC is working hard to provide the needy
 with food, medical care and education.  Food and medical care to keep them
-- 
cgit 


From 5ed60804fe69e97a699ca64422f4f7f4cc20f3da Mon Sep 17 00:00:00 2001
From: bfredl 
Date: Wed, 9 Mar 2022 14:26:01 +0100
Subject: feat(lua): handle lazy submodules in `:lua vim.` wildmenu completion

---
 runtime/lua/vim/_editor.lua | 5 +++++
 1 file changed, 5 insertions(+)

(limited to 'runtime')

diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua
index 2251aca004..3136e36043 100644
--- a/runtime/lua/vim/_editor.lua
+++ b/runtime/lua/vim/_editor.lua
@@ -519,6 +519,8 @@ function vim._expand_pat(pat, env)
       local mt = getmetatable(final_env)
       if mt and type(mt.__index) == "table" then
         field = rawget(mt.__index, key)
+      elseif final_env == vim and vim._submodules[key] then
+        field = vim[key]
       end
     end
     final_env = field
@@ -545,6 +547,9 @@ function vim._expand_pat(pat, env)
   if mt and type(mt.__index) == "table" then
     insert_keys(mt.__index)
   end
+  if final_env == vim then
+    insert_keys(vim._submodules)
+  end
 
   table.sort(keys)
 
-- 
cgit 


From a7b1c8893c602196541e94b8b24c4c70c32c25b0 Mon Sep 17 00:00:00 2001
From: dundargoc <33953936+dundargoc@users.noreply.github.com>
Date: Thu, 10 Mar 2022 07:34:55 +0100
Subject: chore: fix typos (#17331)

Co-authored-by: Hongyi Lyu 
Co-authored-by: Gregory Anders 
Co-authored-by: notomo 
Co-authored-by: zeertzjq 
---
 runtime/doc/autocmd.txt    |  2 +-
 runtime/doc/diagnostic.txt |  2 +-
 runtime/doc/lsp.txt        |  4 ++--
 runtime/doc/lua.txt        |  2 +-
 runtime/doc/treesitter.txt | 13 +++++++------
 runtime/lua/vim/keymap.lua |  2 +-
 6 files changed, 13 insertions(+), 12 deletions(-)

(limited to 'runtime')

diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt
index 4b8c07fde4..ab0b0cd07c 100644
--- a/runtime/doc/autocmd.txt
+++ b/runtime/doc/autocmd.txt
@@ -1079,7 +1079,7 @@ WinLeave			Before leaving a window.  If the window to be
 				executes the BufLeave autocommands before the
 				WinLeave autocommands (but not for ":new").
 				Not used for ":qa" or ":q" when exiting Vim.
-				After WinClosed.
+				Before WinClosed.
 							*WinNew*
 WinNew				When a new window was created.  Not done for
 				the first window, when Vim has just started.
diff --git a/runtime/doc/diagnostic.txt b/runtime/doc/diagnostic.txt
index 781539cfb6..e33c786482 100644
--- a/runtime/doc/diagnostic.txt
+++ b/runtime/doc/diagnostic.txt
@@ -74,7 +74,7 @@ Functions that take a severity as an optional parameter (e.g.
 
 2. A table with a "min" or "max" key (or both): >
 
-	vim.diagnostic.get(0, { severity = {min=vim.diagnostic.severity.WARN})
+	vim.diagnostic.get(0, { severity = {min=vim.diagnostic.severity.WARN} })
 
 The latter form allows users to specify a range of severities.
 
diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt
index d717759444..54c648e171 100644
--- a/runtime/doc/lsp.txt
+++ b/runtime/doc/lsp.txt
@@ -355,8 +355,8 @@ To configure the behavior of a builtin |lsp-handler|, the convenient method
                                                       *lsp-handler-resolution*
 Handlers can be set by:
 
-- Setting a field in |vim.lsp.handlers|.                      *vim.lsp.handlers*
-    |vim.lsp.handlers| is a global table that contains the default mapping of
+- Setting a field in vim.lsp.handlers.                      *vim.lsp.handlers*
+    vim.lsp.handlers is a global table that contains the default mapping of
     |lsp-method| names to |lsp-handlers|.
 
     To override the handler for the `"textDocument/definition"` method: >
diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt
index 98af84e1cb..11629332ae 100644
--- a/runtime/doc/lua.txt
+++ b/runtime/doc/lua.txt
@@ -1083,7 +1083,7 @@ from within Lua.
             `vim.opt.wildignore = '*.o,*.a,__pycache__'`
 
         However, vim.opt also supports a more elegent way of setting
-        list-style options, but using lua tables:
+        list-style options by using lua tables:
             `vim.opt.wildignore = { '*.o', '*.a', '__pycache__' }`
 
     To replicate the behavior of |:set+=|, use: >
diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt
index dbd8ec6fef..02be20c5e8 100644
--- a/runtime/doc/treesitter.txt
+++ b/runtime/doc/treesitter.txt
@@ -207,14 +207,14 @@ Here is a list of built-in predicates :
 
 	`eq?`						*ts-predicate-eq?*
 		This predicate will check text correspondence between nodes or
-		strings : >
+		strings: >
 			((identifier) @foo (#eq? @foo "foo"))
 			((node1) @left (node2) @right (#eq? @left @right))
 <
 	`match?`					*ts-predicate-match?*
 	`vim-match?`				    *ts-predicate-vim-match?*
 		This will match if the provided vim regex matches the text
-		corresponding to a node : >
+		corresponding to a node: >
 			((identifier) @constant (#match? @constant "^[A-Z_]+$"))
 <		Note: the `^` and `$` anchors will respectively match the
 			start and end of the node's text.
@@ -225,17 +225,18 @@ Here is a list of built-in predicates :
 
 	`contains?`				     *ts-predicate-contains?*
 		Will check if any of the following arguments appears in the
-		text corresponding to the node : >
+		text corresponding to the node: >
 			((identifier) @foo (#contains? @foo "foo"))
 			((identifier) @foo-bar (#contains @foo-bar "foo" "bar"))
 <
 	`any-of?`				       *ts-predicate-any-of?*
-		Will check if the text is the same as any of the following.
+		Will check if the text is the same as any of the following
+		arguments: >
+			((identifier) @foo (#any-of? @foo "foo" "bar"))
+<
 		This is the recommended way to check if the node matches one
 		of many keywords for example, as it has been optimized for
 		this.
-		arguments : >
-			((identifier) @foo (#any-of? @foo "foo" "bar"))
 <
 						 *lua-treesitter-not-predicate*
 Each predicate has a `not-` prefixed predicate that is just the negation of
diff --git a/runtime/lua/vim/keymap.lua b/runtime/lua/vim/keymap.lua
index df49eff4b6..7f12372502 100644
--- a/runtime/lua/vim/keymap.lua
+++ b/runtime/lua/vim/keymap.lua
@@ -25,7 +25,7 @@ local keymap = {}
 ---    vim.keymap.set('n', 'asdf', require('jkl').my_fun)
 --- 
--- ---- the require('jkl') gets evaluated during this call in order to access the function. If you want to +--- the `require('jkl')` gets evaluated during this call in order to access the function. If you want to --- avoid this cost at startup you can wrap it in a function, for example: ---
 ---    vim.keymap.set('n', 'asdf', function() return require('jkl').my_fun() end)
-- 
cgit 


From 5862176764c7a86d5fdd2685122810e14a3d5b02 Mon Sep 17 00:00:00 2001
From: Charlie Groves 
Date: Wed, 16 Feb 2022 17:11:50 -0500
Subject: feat(remote): add basic --remote support

This is starting from @geekodour's work at
https://github.com/neovim/neovim/pull/8326
---
 runtime/lua/vim/_editor.lua | 72 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 72 insertions(+)

(limited to 'runtime')

diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua
index 3136e36043..5f3d66e108 100644
--- a/runtime/lua/vim/_editor.lua
+++ b/runtime/lua/vim/_editor.lua
@@ -636,6 +636,78 @@ function vim.pretty_print(...)
   return ...
 end
 
+local function __rpcrequest(...)
+  return vim.api.nvim_call_function("rpcrequest", {...})
+end
+
+function vim._cs_remote(rcid, args)
+
+  local f_silent = false
+  local f_wait = false
+  local f_tab = false
+  local should_exit = true
+  local command = 'edit '
+
+  local subcmd = string.sub(args[1],10)
+
+  if subcmd == '' then
+    -- no flags to set
+  elseif subcmd == 'tab' then
+    f_tab = true
+  elseif subcmd == 'silent' then
+    f_silent = true
+  elseif subcmd == 'wait' then
+    f_wait = true
+  elseif subcmd == 'wait-silent' then
+    f_wait = true
+    f_silent = true
+  elseif subcmd == 'tab-wait' then
+    f_tab = true
+    f_wait = true
+  elseif subcmd == 'tab-silent' then
+    f_tab = true
+    f_silent = true
+  elseif subcmd == 'tab-wait-silent' then
+    f_tab = true
+    f_wait = true
+    f_silent = true
+  elseif subcmd == 'send' then
+    __rpcrequest(rcid, 'nvim_input', args[2])
+    return { should_exit = should_exit, tabbed = f_tab, files = 0 }
+    -- should we show warning if --server doesn't exist in --send and --expr?
+  elseif subcmd == 'expr' then
+    local res = __rpcrequest(rcid, 'vim_eval', args[2])
+    print(res)
+    return { should_exit = should_exit, tabbed = f_tab, files = 0 }
+  else
+    print('--remote subcommand not found')
+  end
+
+  table.remove(args,1)
+
+  if not f_silent and rcid == 0 then
+    print('Remote server does not exist.')
+  end
+
+  if f_silent and rcid == 0 then
+    print('Remote server does not exist. starting new server')
+    should_exit = false
+  end
+
+  if f_tab then command = 'tabedit ' end
+
+  if rcid ~= 0 then
+    for _, key in ipairs(args) do
+      __rpcrequest(rcid, 'nvim_command', command .. key)
+    end
+  end
+
+  return {
+    should_exit = should_exit,
+    tabbed = f_tab,
+    files = table.getn(args)
+  }
+end
 
 require('vim._meta')
 
-- 
cgit 


From 039e94f491d2f8576cbef1aeacd5ea1f7bc0982a Mon Sep 17 00:00:00 2001
From: Charlie Groves 
Date: Thu, 24 Feb 2022 10:47:41 -0500
Subject: test(remote): add tests for --remote

This also fixes a fair number of issues found in running the tests
---
 runtime/lua/vim/_editor.lua | 57 +++++++++++++++++++++------------------------
 1 file changed, 26 insertions(+), 31 deletions(-)

(limited to 'runtime')

diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua
index 5f3d66e108..869a2706ac 100644
--- a/runtime/lua/vim/_editor.lua
+++ b/runtime/lua/vim/_editor.lua
@@ -636,17 +636,10 @@ function vim.pretty_print(...)
   return ...
 end
 
-local function __rpcrequest(...)
-  return vim.api.nvim_call_function("rpcrequest", {...})
-end
-
 function vim._cs_remote(rcid, args)
-
   local f_silent = false
   local f_wait = false
   local f_tab = false
-  local should_exit = true
-  local command = 'edit '
 
   local subcmd = string.sub(args[1],10)
 
@@ -672,40 +665,42 @@ function vim._cs_remote(rcid, args)
     f_wait = true
     f_silent = true
   elseif subcmd == 'send' then
-    __rpcrequest(rcid, 'nvim_input', args[2])
-    return { should_exit = should_exit, tabbed = f_tab, files = 0 }
-    -- should we show warning if --server doesn't exist in --send and --expr?
+    if rcid == 0 then
+      vim.cmd('echoerr "E247: Remote server does not exist. Send failed."')
+      return
+    end
+    vim.fn.rpcrequest(rcid, 'nvim_input', args[2])
+    return { should_exit = true, tabbed = false }
   elseif subcmd == 'expr' then
-    local res = __rpcrequest(rcid, 'vim_eval', args[2])
-    print(res)
-    return { should_exit = should_exit, tabbed = f_tab, files = 0 }
+    if rcid == 0 then
+      vim.cmd('echoerr "E247: Remote server does not exist. Send expression failed."')
+      return
+    end
+    vim.fn.rpcrequest(rcid, 'nvim_eval', args[2])
+    return { should_exit = true, tabbed = false }
   else
-    print('--remote subcommand not found')
+    vim.cmd('echoerr "Unknown option argument: ' .. args[1] .. '"')
+    return
   end
 
-  table.remove(args,1)
-
-  if not f_silent and rcid == 0 then
-    print('Remote server does not exist.')
-  end
-
-  if f_silent and rcid == 0 then
-    print('Remote server does not exist. starting new server')
+  if rcid == 0 then
+    if not f_silent then
+      vim.cmd('echohl WarningMsg | echomsg "E247: Remote server does not exist. Editing locally" | echohl None')
+    end
     should_exit = false
-  end
-
-  if f_tab then command = 'tabedit ' end
-
-  if rcid ~= 0 then
-    for _, key in ipairs(args) do
-      __rpcrequest(rcid, 'nvim_command', command .. key)
+  else
+    local command = {}
+    if f_tab then table.insert(command, 'tab') end
+    table.insert(command, 'drop')
+    for i = 2, #args do
+      table.insert(command, vim.fn.fnameescape(args[i]))
     end
+    vim.fn.rpcrequest(rcid, 'nvim_command', table.concat(command, ' '))
   end
 
   return {
-    should_exit = should_exit,
+    should_exit = rcid ~= 0,
     tabbed = f_tab,
-    files = table.getn(args)
   }
 end
 
-- 
cgit 


From fcdb1f372b4da5c33091ae2e69960b6168454695 Mon Sep 17 00:00:00 2001
From: Charlie Groves 
Date: Tue, 1 Mar 2022 16:23:57 -0500
Subject: docs(remote): restore remote.txt from removal in
 f2205b83c553367a76b6cad

---
 runtime/doc/remote.txt | 189 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 189 insertions(+)
 create mode 100644 runtime/doc/remote.txt

(limited to 'runtime')

diff --git a/runtime/doc/remote.txt b/runtime/doc/remote.txt
new file mode 100644
index 0000000000..6c2ceb45be
--- /dev/null
+++ b/runtime/doc/remote.txt
@@ -0,0 +1,189 @@
+*remote.txt*    Nvim
+
+
+		  VIM REFERENCE MANUAL    by Bram Moolenaar
+
+
+Vim client-server communication				*client-server*
+
+                                      Type |gO| to see the table of contents.
+
+==============================================================================
+1. Common functionality					*clientserver*
+
+When compiled with the |+clientserver| option, Vim can act as a command
+server.  It accepts messages from a client and executes them.  At the same
+time, Vim can function as a client and send commands to a Vim server.
+
+The following command line arguments are available:
+
+    argument			meaning	~
+
+   --remote [+{cmd}] {file} ...					*--remote*
+				Open the file list in a remote Vim.  When
+				there is no Vim server, execute locally.
+				There is one optional init command: +{cmd}.
+				This must be an Ex command that can be
+				followed by "|".
+				The rest of the command line is taken as the
+				file list.  Thus any non-file arguments must
+				come before this.
+				You cannot edit stdin this way |--|.
+				The remote Vim is raised.  If you don't want
+				this use >
+				 vim --remote-send ":n filename"
+<
+   --remote-silent [+{cmd}] {file} ...			*--remote-silent*
+				As above, but don't complain if there is no
+				server and the file is edited locally.
+   --remote-wait [+{cmd}] {file} ...				*--remote-wait*
+				As --remote, but wait for files to complete
+				(unload) in remote Vim.
+   --remote-wait-silent [+{cmd}] {file} ...		*--remote-wait-silent*
+				As --remote-wait, but don't complain if there
+				is no server.
+							*--remote-tab*
+   --remote-tab			Like --remote but open each file in a new
+				tabpage.
+							*--remote-tab-silent*
+   --remote-tab-silent		Like --remote-silent but open each file in a
+				new tabpage.
+							*--remote-tab-wait*
+   --remote-tab-wait		Like --remote-wait but open each file in a new
+				tabpage.
+
+						*--remote-tab-wait-silent*
+   --remote-tab-wait-silent	Like --remote-wait-silent but open each file
+				in a new tabpage.
+								*--remote-send*
+   --remote-send {keys}		Send {keys} to server and exit.  The {keys}
+   				are not mapped.  Special key names are
+				recognized, e.g., "" results in a CR
+				character.
+								*--remote-expr*
+   --remote-expr {expr}		Evaluate {expr} in server and print the result
+				on stdout.
+
+Examples ~
+
+Edit "file.txt" in an already running GVIM server: >
+    gvim --remote file.txt
+
+Edit "file.txt" in an already running server called FOOBAR: >
+    gvim --servername FOOBAR --remote file.txt
+
+Edit "file.txt" in server "FILES" if it exists, become server "FILES"
+otherwise: >
+    gvim --servername FILES --remote-silent file.txt
+
+This doesn't work, all arguments after --remote will be used as file names: >
+    gvim --remote --servername FOOBAR file.txt
+
+Edit file "+foo" in a remote server (note the use of "./" to avoid the special
+meaning of the leading plus): >
+    vim --remote ./+foo
+
+Tell the remote server "BLA" to write all files and exit: >
+    vim --servername BLA --remote-send ':wqa'
+
+
+SERVER NAME						*client-server-name*
+
+By default Vim will try to register the name under which it was invoked (gvim,
+egvim ...).  This can be overridden with the --servername argument.  If the
+specified name is not available, a postfix is applied until a free name is
+encountered, i.e. "gvim1" for the second invocation of gvim on a particular
+X-server.  The resulting name is available in the servername builtin variable
+|v:servername|.  The case of the server name is ignored, thus "gvim" and
+"GVIM" are considered equal.
+
+When Vim is invoked with --remote, --remote-wait or --remote-send it will try
+to locate the server name determined by the invocation name and --servername
+argument as described above.  If an exact match is not available, the first
+server with the number postfix will be used.  If a name with the number
+postfix is specified with the --servername argument, it must match exactly.
+
+If no server can be located and --remote or --remote-wait was used, Vim will
+start up according to the rest of the command line and do the editing by
+itself.  This way it is not necessary to know whether gvim is already started
+when sending command to it.
+
+The --serverlist argument will cause Vim to print a list of registered command
+servers on the standard output (stdout) and exit.
+
+Win32 Note: Making the Vim server go to the foreground doesn't always work,
+because MS-Windows doesn't allow it.  The client will move the server to the
+foreground when using the --remote or --remote-wait argument and the server
+name starts with "g".
+
+
+REMOTE EDITING
+
+The --remote argument will cause a |:drop| command to be constructed from the
+rest of the command line and sent as described above.
+The --remote-wait argument does the same thing and additionally sets up to
+wait for each of the files to have been edited.  This uses the BufUnload
+event, thus as soon as a file has been unloaded, Vim assumes you are done
+editing it.
+Note that the --remote and --remote-wait arguments will consume the rest of
+the command line.  I.e. all remaining arguments will be regarded as filenames.
+You can not put options there!
+
+
+FUNCTIONS
+								*E240* *E573*
+There are a number of Vim functions for scripting the command server.  See
+the description in |eval.txt| or use CTRL-] on the function name to jump to
+the full explanation.
+
+    synopsis				     explanation ~
+    remote_startserver( name)		     run a server
+    remote_expr( server, string, idvar)      send expression
+    remote_send( server, string, idvar)      send key sequence
+    serverlist()			     get a list of available servers
+    remote_peek( serverid, retvar)	     check for reply string
+    remote_read( serverid)		     read reply string
+    server2client( serverid, string)	     send reply string
+    remote_foreground( server)		     bring server to the front
+
+See also the explanation of |CTRL-\_CTRL-N|.  Very useful as a leading key
+sequence.
+The {serverid} for server2client() can be obtained with expand("")
+
+==============================================================================
+2. X11 specific items					*x11-clientserver*
+				    *E247* *E248* *E251* *E258* *E277*
+
+The communication between client and server goes through the X server.  The
+display of the Vim server must be specified.  The usual protection of the X
+server is used, you must be able to open a window on the X server for the
+communication to work.  It is possible to communicate between different
+systems.
+
+By default, a GUI Vim will register a name on the X-server by which it can be
+addressed for subsequent execution of injected strings.  Vim can also act as
+a client and send strings to other instances of Vim on the same X11 display.
+
+When an X11 GUI Vim (gvim) is started, it will try to register a send-server
+name on the 'VimRegistry' property on the root window.
+
+An empty --servername argument will cause the command server to be disabled.
+
+To send commands to a Vim server from another application, read the source
+file src/if_xcmdsrv.c, it contains some hints about the protocol used.
+
+==============================================================================
+3. Win32 specific items					*w32-clientserver*
+
+Every Win32 Vim can work as a server, also in the console.  You do not need a
+version compiled with OLE.  Windows messages are used, this works on any
+version of MS-Windows.  But only communication within one system is possible.
+
+Since MS-Windows messages are used, any other application should be able to
+communicate with a Vim server.
+
+When using gvim, the --remote-wait only works properly this way: >
+
+	start /w gvim --remote-wait file.txt
+<
+ vim:tw=78:sw=4:ts=8:noet:ft=help:norl:
-- 
cgit 


From e095a868cbc9ff504087b3df89e4d92d0421ab38 Mon Sep 17 00:00:00 2001
From: Charlie Groves 
Date: Wed, 2 Mar 2022 10:16:29 -0500
Subject: docs(remote): update remote.txt for current nvim implementation

---
 runtime/doc/remote.txt | 168 ++++++++++++++++---------------------------------
 1 file changed, 55 insertions(+), 113 deletions(-)

(limited to 'runtime')

diff --git a/runtime/doc/remote.txt b/runtime/doc/remote.txt
index 6c2ceb45be..dd5d44387d 100644
--- a/runtime/doc/remote.txt
+++ b/runtime/doc/remote.txt
@@ -11,9 +11,10 @@ Vim client-server communication				*client-server*
 ==============================================================================
 1. Common functionality					*clientserver*
 
-When compiled with the |+clientserver| option, Vim can act as a command
-server.  It accepts messages from a client and executes them.  At the same
-time, Vim can function as a client and send commands to a Vim server.
+Nvim's |RPC| functionality allows clients to programmatically control Nvim. Nvim
+itself takes command-line arguments that cause it to become a client to another
+Nvim running as a server. These arguments match those provided by Vim's
+clientserver option.
 
 The following command line arguments are available:
 
@@ -22,39 +23,27 @@ The following command line arguments are available:
    --remote [+{cmd}] {file} ...					*--remote*
 				Open the file list in a remote Vim.  When
 				there is no Vim server, execute locally.
-				There is one optional init command: +{cmd}.
+				Vim allows one init command: +{cmd}.
 				This must be an Ex command that can be
-				followed by "|".
+				followed by "|". It's not yet supported by
+				Nvim.
 				The rest of the command line is taken as the
 				file list.  Thus any non-file arguments must
 				come before this.
 				You cannot edit stdin this way |--|.
 				The remote Vim is raised.  If you don't want
 				this use >
-				 vim --remote-send ":n filename"
+				 nvim --remote-send ":n filename"
 <
    --remote-silent [+{cmd}] {file} ...			*--remote-silent*
 				As above, but don't complain if there is no
 				server and the file is edited locally.
-   --remote-wait [+{cmd}] {file} ...				*--remote-wait*
-				As --remote, but wait for files to complete
-				(unload) in remote Vim.
-   --remote-wait-silent [+{cmd}] {file} ...		*--remote-wait-silent*
-				As --remote-wait, but don't complain if there
-				is no server.
 							*--remote-tab*
    --remote-tab			Like --remote but open each file in a new
 				tabpage.
 							*--remote-tab-silent*
    --remote-tab-silent		Like --remote-silent but open each file in a
 				new tabpage.
-							*--remote-tab-wait*
-   --remote-tab-wait		Like --remote-wait but open each file in a new
-				tabpage.
-
-						*--remote-tab-wait-silent*
-   --remote-tab-wait-silent	Like --remote-wait-silent but open each file
-				in a new tabpage.
 								*--remote-send*
    --remote-send {keys}		Send {keys} to server and exit.  The {keys}
    				are not mapped.  Special key names are
@@ -63,127 +52,80 @@ The following command line arguments are available:
 								*--remote-expr*
    --remote-expr {expr}		Evaluate {expr} in server and print the result
 				on stdout.
+								*--server*
+   --server {addr}		Connect to the named pipe or socket at the
+				given address for executing remote commands.
+				See |--listen| for specifying an address when
+				starting a server.
 
 Examples ~
 
-Edit "file.txt" in an already running GVIM server: >
-    gvim --remote file.txt
-
-Edit "file.txt" in an already running server called FOOBAR: >
-    gvim --servername FOOBAR --remote file.txt
+Start an Nvim server listening on a named pipe at '~/.cache/nvim/server.pipe': >
+    nvim --listen ~/.cache/nvim/server.pipe
 
-Edit "file.txt" in server "FILES" if it exists, become server "FILES"
-otherwise: >
-    gvim --servername FILES --remote-silent file.txt
+Edit "file.txt" in an Nvim server listening at '~/.cache/nvim/server.pipe': >
+    nvim --server ~/.cache/nvim/server.pipe --remote file.txt
 
 This doesn't work, all arguments after --remote will be used as file names: >
-    gvim --remote --servername FOOBAR file.txt
-
-Edit file "+foo" in a remote server (note the use of "./" to avoid the special
-meaning of the leading plus): >
-    vim --remote ./+foo
-
-Tell the remote server "BLA" to write all files and exit: >
-    vim --servername BLA --remote-send ':wqa'
-
-
-SERVER NAME						*client-server-name*
-
-By default Vim will try to register the name under which it was invoked (gvim,
-egvim ...).  This can be overridden with the --servername argument.  If the
-specified name is not available, a postfix is applied until a free name is
-encountered, i.e. "gvim1" for the second invocation of gvim on a particular
-X-server.  The resulting name is available in the servername builtin variable
-|v:servername|.  The case of the server name is ignored, thus "gvim" and
-"GVIM" are considered equal.
-
-When Vim is invoked with --remote, --remote-wait or --remote-send it will try
-to locate the server name determined by the invocation name and --servername
-argument as described above.  If an exact match is not available, the first
-server with the number postfix will be used.  If a name with the number
-postfix is specified with the --servername argument, it must match exactly.
+    nvim --remote --server ~/.cache/nvim/server.pipe file.txt
 
-If no server can be located and --remote or --remote-wait was used, Vim will
-start up according to the rest of the command line and do the editing by
-itself.  This way it is not necessary to know whether gvim is already started
-when sending command to it.
-
-The --serverlist argument will cause Vim to print a list of registered command
-servers on the standard output (stdout) and exit.
-
-Win32 Note: Making the Vim server go to the foreground doesn't always work,
-because MS-Windows doesn't allow it.  The client will move the server to the
-foreground when using the --remote or --remote-wait argument and the server
-name starts with "g".
+Tell the remote server to write all files and exit: >
+    nvim --server ~/.cache/nvim/server.pipe --remote-send ':wqa'
 
 
 REMOTE EDITING
 
 The --remote argument will cause a |:drop| command to be constructed from the
 rest of the command line and sent as described above.
-The --remote-wait argument does the same thing and additionally sets up to
-wait for each of the files to have been edited.  This uses the BufUnload
-event, thus as soon as a file has been unloaded, Vim assumes you are done
-editing it.
 Note that the --remote and --remote-wait arguments will consume the rest of
 the command line.  I.e. all remaining arguments will be regarded as filenames.
 You can not put options there!
 
 
-FUNCTIONS
-								*E240* *E573*
-There are a number of Vim functions for scripting the command server.  See
-the description in |eval.txt| or use CTRL-] on the function name to jump to
-the full explanation.
-
-    synopsis				     explanation ~
-    remote_startserver( name)		     run a server
-    remote_expr( server, string, idvar)      send expression
-    remote_send( server, string, idvar)      send key sequence
-    serverlist()			     get a list of available servers
-    remote_peek( serverid, retvar)	     check for reply string
-    remote_read( serverid)		     read reply string
-    server2client( serverid, string)	     send reply string
-    remote_foreground( server)		     bring server to the front
-
-See also the explanation of |CTRL-\_CTRL-N|.  Very useful as a leading key
-sequence.
-The {serverid} for server2client() can be obtained with expand("")
-
 ==============================================================================
-2. X11 specific items					*x11-clientserver*
-				    *E247* *E248* *E251* *E258* *E277*
+2. Missing functionality				*clientserver-missing*
 
-The communication between client and server goes through the X server.  The
-display of the Vim server must be specified.  The usual protection of the X
-server is used, you must be able to open a window on the X server for the
-communication to work.  It is possible to communicate between different
-systems.
+Vim supports additional functionality in clientserver that's not yet
+implemented in Nvim. In particular, none of the 'wait' variants are supported
+yet. The following command line arguments are not yet available:
 
-By default, a GUI Vim will register a name on the X-server by which it can be
-addressed for subsequent execution of injected strings.  Vim can also act as
-a client and send strings to other instances of Vim on the same X11 display.
+    argument			meaning	~
 
-When an X11 GUI Vim (gvim) is started, it will try to register a send-server
-name on the 'VimRegistry' property on the root window.
+   --remote-wait [+{cmd}] {file} ...				*--remote-wait*
+				Not yet supported by Nvim.
+				As --remote, but wait for files to complete
+				(unload) in remote Vim.
+   --remote-wait-silent [+{cmd}] {file} ...		*--remote-wait-silent*
+				Not yet supported by Nvim.
+				As --remote-wait, but don't complain if there
+				is no server.
+							*--remote-tab-wait*
+   --remote-tab-wait		Not yet supported by Nvim.
+				Like --remote-wait but open each file in a new
+				tabpage.
+						*--remote-tab-wait-silent*
+   --remote-tab-wait-silent	Not yet supported by Nvim.
+				Like --remote-wait-silent but open each file
+				in a new tabpage.
+							    *--servername*
+   --servername {name}          Not yet supported by Nvim.
+				Become the server {name}.  When used together
+                                with one of the --remote commands: connect to
+                                server {name} instead of the default (see
+                                below).  The name used will be uppercase.
 
-An empty --servername argument will cause the command server to be disabled.
+								*--serverlist*
+   --serverlist			Not yet supported by Nvim.
+				Output a list of server names.
 
-To send commands to a Vim server from another application, read the source
-file src/if_xcmdsrv.c, it contains some hints about the protocol used.
 
-==============================================================================
-3. Win32 specific items					*w32-clientserver*
 
-Every Win32 Vim can work as a server, also in the console.  You do not need a
-version compiled with OLE.  Windows messages are used, this works on any
-version of MS-Windows.  But only communication within one system is possible.
 
-Since MS-Windows messages are used, any other application should be able to
-communicate with a Vim server.
+SERVER NAME						*client-server-name*
 
-When using gvim, the --remote-wait only works properly this way: >
+By default Vim will try to register the name under which it was invoked (gvim,
+egvim ...).  This can be overridden with the --servername argument.  Nvim
+either listens on a named pipe or a socket and does not yet support this
+--servername functionality.
 
-	start /w gvim --remote-wait file.txt
-<
  vim:tw=78:sw=4:ts=8:noet:ft=help:norl:
-- 
cgit 


From 29c36322857b37263b07eb1301d71ccd8a2ae044 Mon Sep 17 00:00:00 2001
From: Charlie Groves 
Date: Thu, 3 Mar 2022 16:33:27 -0500
Subject: fix(remote): report on missing wait commands, typecheck lua results

Clean up lint errors, too
---
 runtime/doc/remote.txt      |  2 +-
 runtime/lua/vim/_editor.lua | 33 ++++++++-------------------------
 2 files changed, 9 insertions(+), 26 deletions(-)

(limited to 'runtime')

diff --git a/runtime/doc/remote.txt b/runtime/doc/remote.txt
index dd5d44387d..b8991be738 100644
--- a/runtime/doc/remote.txt
+++ b/runtime/doc/remote.txt
@@ -83,7 +83,7 @@ You can not put options there!
 
 
 ==============================================================================
-2. Missing functionality				*clientserver-missing*
+2. Missing functionality			*E5600* *clientserver-missing*
 
 Vim supports additional functionality in clientserver that's not yet
 implemented in Nvim. In particular, none of the 'wait' variants are supported
diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua
index 869a2706ac..030c3b40e8 100644
--- a/runtime/lua/vim/_editor.lua
+++ b/runtime/lua/vim/_editor.lua
@@ -638,56 +638,39 @@ end
 
 function vim._cs_remote(rcid, args)
   local f_silent = false
-  local f_wait = false
   local f_tab = false
 
   local subcmd = string.sub(args[1],10)
 
-  if subcmd == '' then
-    -- no flags to set
-  elseif subcmd == 'tab' then
+  if subcmd == 'tab' then
     f_tab = true
   elseif subcmd == 'silent' then
     f_silent = true
-  elseif subcmd == 'wait' then
-    f_wait = true
-  elseif subcmd == 'wait-silent' then
-    f_wait = true
-    f_silent = true
-  elseif subcmd == 'tab-wait' then
-    f_tab = true
-    f_wait = true
+  elseif subcmd == 'wait' or subcmd == 'wait-silent' or subcmd == 'tab-wait' or subcmd == 'tab-wait-silent' then
+    return { errmsg = 'E5600: Wait commands not yet implemented in nvim' }
   elseif subcmd == 'tab-silent' then
     f_tab = true
     f_silent = true
-  elseif subcmd == 'tab-wait-silent' then
-    f_tab = true
-    f_wait = true
-    f_silent = true
   elseif subcmd == 'send' then
     if rcid == 0 then
-      vim.cmd('echoerr "E247: Remote server does not exist. Send failed."')
-      return
+      return { errmsg = 'E247: Remote server does not exist. Send failed.' }
     end
     vim.fn.rpcrequest(rcid, 'nvim_input', args[2])
     return { should_exit = true, tabbed = false }
   elseif subcmd == 'expr' then
     if rcid == 0 then
-      vim.cmd('echoerr "E247: Remote server does not exist. Send expression failed."')
-      return
+      return { errmsg = 'E247: Remote server does not exist. Send expression failed.' }
     end
-    vim.fn.rpcrequest(rcid, 'nvim_eval', args[2])
+    print(vim.fn.rpcrequest(rcid, 'nvim_eval', args[2]))
     return { should_exit = true, tabbed = false }
-  else
-    vim.cmd('echoerr "Unknown option argument: ' .. args[1] .. '"')
-    return
+  elseif subcmd ~= '' then
+    return { errmsg='Unknown option argument: ' .. args[1] }
   end
 
   if rcid == 0 then
     if not f_silent then
       vim.cmd('echohl WarningMsg | echomsg "E247: Remote server does not exist. Editing locally" | echohl None')
     end
-    should_exit = false
   else
     local command = {}
     if f_tab then table.insert(command, 'tab') end
-- 
cgit 


From 1dbf8675c71dc500ae7502085161cd56e311ccf6 Mon Sep 17 00:00:00 2001
From: Charlie Groves 
Date: Fri, 11 Mar 2022 11:16:34 -0500
Subject: fix(remote): respect silent in error reporting

---
 runtime/lua/vim/_editor.lua | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

(limited to 'runtime')

diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua
index 030c3b40e8..a0c60a7dcf 100644
--- a/runtime/lua/vim/_editor.lua
+++ b/runtime/lua/vim/_editor.lua
@@ -636,12 +636,24 @@ function vim.pretty_print(...)
   return ...
 end
 
-function vim._cs_remote(rcid, args)
+function vim._cs_remote(rcid, server_addr, connect_error, args)
+  local function connection_failure_errmsg(consequence)
+    local explanation
+    if server_addr == '' then
+      explanation = "No server specified with --server"
+    else
+      explanation = "Failed to connect to '" .. server_addr .. "'"
+      if connect_error ~= "" then
+        explanation = explanation .. ": " .. connect_error
+      end
+    end
+    return "E247: " .. explanation .. ". " .. consequence
+  end
+
   local f_silent = false
   local f_tab = false
 
   local subcmd = string.sub(args[1],10)
-
   if subcmd == 'tab' then
     f_tab = true
   elseif subcmd == 'silent' then
@@ -653,13 +665,13 @@ function vim._cs_remote(rcid, args)
     f_silent = true
   elseif subcmd == 'send' then
     if rcid == 0 then
-      return { errmsg = 'E247: Remote server does not exist. Send failed.' }
+      return { errmsg = connection_failure_errmsg('Send failed.') }
     end
     vim.fn.rpcrequest(rcid, 'nvim_input', args[2])
     return { should_exit = true, tabbed = false }
   elseif subcmd == 'expr' then
     if rcid == 0 then
-      return { errmsg = 'E247: Remote server does not exist. Send expression failed.' }
+      return { errmsg = connection_failure_errmsg('Send expression failed.') }
     end
     print(vim.fn.rpcrequest(rcid, 'nvim_eval', args[2]))
     return { should_exit = true, tabbed = false }
@@ -669,7 +681,7 @@ function vim._cs_remote(rcid, args)
 
   if rcid == 0 then
     if not f_silent then
-      vim.cmd('echohl WarningMsg | echomsg "E247: Remote server does not exist. Editing locally" | echohl None')
+      vim.notify(connection_failure_errmsg("Editing locally"), vim.log.levels.WARN)
     end
   else
     local command = {}
-- 
cgit 


From 84af45f59f96d5492237094e5345c88d0cfec860 Mon Sep 17 00:00:00 2001
From: dundargoc <33953936+dundargoc@users.noreply.github.com>
Date: Fri, 11 Mar 2022 23:25:59 +0100
Subject: docs: remove "not in vi" notes (#17678)

[skip ci]
---
 runtime/doc/change.txt   | 8 ++++----
 runtime/doc/quickfix.txt | 4 ----
 2 files changed, 4 insertions(+), 8 deletions(-)

(limited to 'runtime')

diff --git a/runtime/doc/change.txt b/runtime/doc/change.txt
index b170f7cf65..28c652467d 100644
--- a/runtime/doc/change.txt
+++ b/runtime/doc/change.txt
@@ -355,14 +355,14 @@ CTRL-A			Add [count] to the number or alphabetic character at
 
                                                        *v_CTRL-A*
 {Visual}CTRL-A		Add [count] to the number or alphabetic character in
-			the highlighted text.  {not in Vi}
+			the highlighted text.
 
 							*v_g_CTRL-A*
 {Visual}g CTRL-A	Add [count] to the number or alphabetic character in
 			the highlighted text. If several lines are
 		        highlighted, each one will be incremented by an
 			additional [count] (so effectively creating a
-			[count] incrementing sequence).  {not in Vi}
+			[count] incrementing sequence).
 			For Example, if you have this list of numbers:
 				1. ~
 				1. ~
@@ -381,14 +381,14 @@ CTRL-X			Subtract [count] from the number or alphabetic
 
 							*v_CTRL-X*
 {Visual}CTRL-X		Subtract [count] from the number or alphabetic
-			character in the highlighted text.  {not in Vi}
+			character in the highlighted text.
 
 							*v_g_CTRL-X*
 {Visual}g CTRL-X	Subtract [count] from the number or alphabetic
 			character in the highlighted text. If several lines
 			are highlighted, each value will be decremented by an
 			additional [count] (so effectively creating a [count]
-			decrementing sequence).  {not in Vi}
+			decrementing sequence).
 
 The CTRL-A and CTRL-X commands work for (signed) decimal numbers, unsigned
 binary/octal/hexadecimal numbers and alphabetic characters.
diff --git a/runtime/doc/quickfix.txt b/runtime/doc/quickfix.txt
index 0345b14b7a..31a96298d2 100644
--- a/runtime/doc/quickfix.txt
+++ b/runtime/doc/quickfix.txt
@@ -497,7 +497,6 @@ EXECUTE A COMMAND IN ALL THE BUFFERS IN QUICKFIX OR LOCATION LIST:
 			autocommand event is disabled by adding it to
 			'eventignore'.  This considerably speeds up editing
 			each buffer.
-			{not in Vi}
 			Also see |:bufdo|, |:tabdo|, |:argdo|, |:windo|,
 			|:ldo|, |:cfdo| and |:lfdo|.
 
@@ -510,7 +509,6 @@ EXECUTE A COMMAND IN ALL THE BUFFERS IN QUICKFIX OR LOCATION LIST:
 				:{cmd}
 				etc.
 <			Otherwise it works the same as `:cdo`.
-			{not in Vi}
 
 							*:ldo*
 :ld[o][!] {cmd}		Execute {cmd} in each valid entry in the location list
@@ -523,7 +521,6 @@ EXECUTE A COMMAND IN ALL THE BUFFERS IN QUICKFIX OR LOCATION LIST:
 				etc.
 <			Only valid entries in the location list are used.
 			Otherwise it works the same as `:cdo`.
-			{not in Vi}
 
 							*:lfdo*
 :lfdo[!] {cmd}		Execute {cmd} in each file in the location list for
@@ -535,7 +532,6 @@ EXECUTE A COMMAND IN ALL THE BUFFERS IN QUICKFIX OR LOCATION LIST:
 				:{cmd}
 				etc.
 <			Otherwise it works the same as `:ldo`.
-			{not in Vi}
 
 FILTERING A QUICKFIX OR LOCATION LIST:
 				    *cfilter-plugin* *:Cfilter* *:Lfilter*
-- 
cgit 


From d4982e152c8e92ee7a4092a58c272ed364c79b64 Mon Sep 17 00:00:00 2001
From: zeertzjq 
Date: Sat, 12 Mar 2022 06:52:54 +0800
Subject: vim-patch:partial:a2baa73d1d33 (#17675)

Update runtime files.
https://github.com/vim/vim/commit/a2baa73d1d33014adea0fd9567949089ca21a782

Cherry-pick tabpage.txt changes from patch 8.2.1413.
Skip digraph functions: included in #17440.
Skip many error codes as they haven't been ported yet.
---
 runtime/doc/builtin.txt  |  4 +++-
 runtime/doc/change.txt   |  2 +-
 runtime/doc/cmdline.txt  |  2 +-
 runtime/doc/editing.txt  |  6 ++----
 runtime/doc/filetype.txt |  3 ++-
 runtime/doc/syntax.txt   | 11 ++++++++++-
 runtime/doc/tabpage.txt  | 10 +++++++++-
 runtime/doc/various.txt  |  2 +-
 8 files changed, 29 insertions(+), 11 deletions(-)

(limited to 'runtime')

diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt
index 5b0c7918e0..ea7a53fa3b 100644
--- a/runtime/doc/builtin.txt
+++ b/runtime/doc/builtin.txt
@@ -6880,12 +6880,14 @@ setqflist({list} [, {action} [, {what}]])		*setqflist()*
 		    filename	name of a file; only used when "bufnr" is not
 				present or it is invalid.
 		    module	name of a module; if given it will be used in
-				quickfix error window instead of the filename
+				quickfix error window instead of the filename.
 		    lnum	line number in the file
+		    end_lnum	end of lines, if the item spans multiple lines
 		    pattern	search pattern used to locate the error
 		    col		column number
 		    vcol	when non-zero: "col" is visual column
 				when zero: "col" is byte index
+		    end_col	end column, if the item spans multiple columns
 		    nr		error number
 		    text	description of the error
 		    type	single-character error type, 'E', 'W', etc.
diff --git a/runtime/doc/change.txt b/runtime/doc/change.txt
index 28c652467d..86e19c5ec5 100644
--- a/runtime/doc/change.txt
+++ b/runtime/doc/change.txt
@@ -1018,7 +1018,7 @@ inside of strings can change!  Also see 'softtabstop' option. >
 			in [range] (default: current line |cmdline-ranges|),
 			[into register x].
 
-							*p* *put* *E353*
+						*p* *put* *E353* *E1240*
 ["x]p			Put the text [from register x] after the cursor
 			[count] times.
 
diff --git a/runtime/doc/cmdline.txt b/runtime/doc/cmdline.txt
index c6e4bf003f..9fa2034718 100644
--- a/runtime/doc/cmdline.txt
+++ b/runtime/doc/cmdline.txt
@@ -679,7 +679,7 @@ If more line specifiers are given than required for the command, the first
 one(s) will be ignored.
 
 Line numbers may be specified with:		*:range* *{address}*
-	{number}	an absolute line number
+	{number}	an absolute line number  *E1247*
 	.		the current line			  *:.*
 	$		the last line in the file		  *:$*
 	%		equal to 1,$ (the entire file)		  *:%*
diff --git a/runtime/doc/editing.txt b/runtime/doc/editing.txt
index bfa01f45a7..1cc8c21462 100644
--- a/runtime/doc/editing.txt
+++ b/runtime/doc/editing.txt
@@ -1575,10 +1575,8 @@ There are three different types of searching:
 	/u/user_x/include
 
 <   Note: If your 'path' setting includes a non-existing directory, Vim will
-   skip the non-existing directory, but continues searching in the parent of
-   the non-existing directory if upwards searching is used.  E.g. when
-   searching "../include" and that doesn't exist, and upward searching is
-   used, also searches in "..".
+   skip the non-existing directory, and also does not search in the parent of
+   the non-existing directory if upwards searching is used.
 
 3) Combined up/downward search:
    If Vim's current path is /u/user_x/work/release and you do >
diff --git a/runtime/doc/filetype.txt b/runtime/doc/filetype.txt
index 5486c87af9..bd3acfcac7 100644
--- a/runtime/doc/filetype.txt
+++ b/runtime/doc/filetype.txt
@@ -140,7 +140,8 @@ variables can be used to overrule the filetype used for certain extensions:
 	*.asm		g:asmsyntax	|ft-asm-syntax|
 	*.asp		g:filetype_asp	|ft-aspvbs-syntax| |ft-aspperl-syntax|
 	*.bas		g:filetype_bas	|ft-basic-syntax|
-	*.fs		g:filetype_fs   |ft-forth-syntax|
+	*.frm		g:filetype_frm	|ft-form-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|
diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt
index c8280173fb..c5f93fd66f 100644
--- a/runtime/doc/syntax.txt
+++ b/runtime/doc/syntax.txt
@@ -188,7 +188,8 @@ A syntax group name doesn't specify any color or attributes itself.
 
 The name for a highlight or syntax group must consist of ASCII letters, digits
 and the underscore.  As a regexp: "[a-zA-Z0-9_]*".  However, Vim does not give
-an error when using other characters.
+an error when using other characters.  The maxium length of a group name is
+about 200 bytes.  *E1249*
 
 To be able to allow each user to pick their favorite set of colors, there must
 be preferred names for highlight groups that are common for many languages.
@@ -1500,6 +1501,14 @@ The enhanced mode also takes advantage of additional color features for a dark
 gvim display.  Here, statements are colored LightYellow instead of Yellow, and
 conditionals are LightBlue for better distinction.
 
+Both Visual Basic and FORM use the extension ".frm".  To detect which one
+should be used, Vim checks for the string "VB_Name" in the first five lines of
+the file.  If it is found, filetype will be "vb", otherwise "form".
+
+If the automatic detection doesn't work for you or you only edit, for
+example, FORM files, use this in your startup vimrc: >
+   :let filetype_frm = "form"
+
 
 FORTH						*forth.vim* *ft-forth-syntax*
 
diff --git a/runtime/doc/tabpage.txt b/runtime/doc/tabpage.txt
index c5b61e3a35..78b5101da7 100644
--- a/runtime/doc/tabpage.txt
+++ b/runtime/doc/tabpage.txt
@@ -133,7 +133,10 @@ something else.
 		    :tabclose +	    " close the next tab page
 		    :tabclose 3	    " close the third tab page
 		    :tabclose $	    " close the last tab page
-<
+		    :tabclose #     " close the last accessed tab page
+
+When a tab is closed the next tab page will become the current one.
+
 							*:tabo* *:tabonly*
 :tabo[nly][!]	Close all other tab pages.
 		When the 'hidden' option is set, all buffers in closed windows
@@ -159,6 +162,8 @@ something else.
 				    " one
 		    :tabonly 1	    " close all tab pages except the first one
 		    :tabonly $	    " close all tab pages except the last one
+		    :tabonly #	    " close all tab pages except the last
+				    " accessed one
 
 
 SWITCHING TO ANOTHER TAB PAGE:
@@ -181,6 +186,7 @@ gt					*i_CTRL-* *i_*
 		    :+2tabnext	" go to the two next tab page
 		    :1tabnext	" go to the first tab page
 		    :$tabnext	" go to the last tab page
+		    :tabnext #  " go to the last accessed tab page
 		    :tabnext $	" as above
 		    :tabnext -	" go to the previous tab page
 		    :tabnext -1	" as above
@@ -245,6 +251,8 @@ REORDERING TAB PAGES:
 		    :tabmove	" move the tab page to the last
 		    :$tabmove	" as above
 		    :tabmove $	" as above
+		    :tabmove #  " move the tab page after the last accessed
+				" tab page
 
 :tabm[ove] +[N]
 :tabm[ove] -[N]
diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt
index 19e429fde2..75ee0fdfdf 100644
--- a/runtime/doc/various.txt
+++ b/runtime/doc/various.txt
@@ -432,7 +432,7 @@ g8			Print the hex values of the bytes used in the
 			used.  In this example |:silent| is used to avoid the
 			message about reading the file and |:unsilent| to be
 			able to list the first line of each file. >
-    		:silent argdo unsilent echo expand('%') .. ": " .. getline(1)
+		:silent argdo unsilent echo expand('%') .. ": " .. getline(1)
 <
 
 						*:verb* *:verbose*
-- 
cgit 


From f291a0339c186cf6eb83174e88029555b3c2631a Mon Sep 17 00:00:00 2001
From: Gregory Anders <8965202+gpanders@users.noreply.github.com>
Date: Sat, 12 Mar 2022 17:56:53 -0700
Subject: fix: use normal!  in default  mapping (#17695)

---
 runtime/doc/vim_diff.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'runtime')

diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt
index 5ea6a9c5dd..7f944bbfe6 100644
--- a/runtime/doc/vim_diff.txt
+++ b/runtime/doc/vim_diff.txt
@@ -84,7 +84,7 @@ Nvim creates the following default mappings at |startup|. You can disable any
 of these in your config by simply removing the mapping, e.g. ":unmap Y".
 >
 	nnoremap Y y$
-	nnoremap  nohlsearchdiffupdate
+	nnoremap  nohlsearchdiffupdatenormal! 
 	inoremap  u
 	inoremap  u
 <
-- 
cgit 


From d33aebb821b7e7c9197b035c9152859e0b6ed712 Mon Sep 17 00:00:00 2001
From: dundargoc <33953936+dundargoc@users.noreply.github.com>
Date: Sun, 13 Mar 2022 05:52:45 +0100
Subject: feat(runtime): import cleanadd.vim from Vim (#17699)

Latest version from Vim v7.2a.
Closes https://github.com/neovim/neovim/issues/12875
---
 runtime/spell/cleanadd.vim | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 runtime/spell/cleanadd.vim

(limited to 'runtime')

diff --git a/runtime/spell/cleanadd.vim b/runtime/spell/cleanadd.vim
new file mode 100644
index 0000000000..6dc0692186
--- /dev/null
+++ b/runtime/spell/cleanadd.vim
@@ -0,0 +1,32 @@
+" Vim script to clean the ll.xxxxx.add files of commented out entries
+" Author:	Antonio Colombo, Bram Moolenaar
+" Last Update:	2008 Jun 3
+
+" Time in seconds after last time an ll.xxxxx.add file was updated
+" Default is one second.
+" If you invoke this script often set it to something bigger, e.g. 60 * 60
+" (one hour)
+if !exists("g:spell_clean_limit")
+  let g:spell_clean_limit = 1
+endif
+
+" Loop over all the runtime/spell/*.add files.
+" Delete all comment lines, except the ones starting with ##.
+for s:fname in split(globpath(&rtp, "spell/*.add"), "\n")
+  if filewritable(s:fname) && localtime() - getftime(s:fname) > g:spell_clean_limit
+    if exists('*fnameescape')
+      let s:f = fnameescape(s:fname)
+    else
+      let s:f = escape(s:fname, ' \|<')
+    endif
+    silent exe "tab split " . s:f
+    echo "Processing" s:f
+    silent! g/^#[^#]/d
+    silent update
+    close
+    unlet s:f
+  endif
+endfor
+unlet s:fname
+
+echo "Done"
-- 
cgit 


From 163ec00f44c99b08a932144164b8c467ec672c3c Mon Sep 17 00:00:00 2001
From: Jan Edmund Lazo 
Date: Sat, 10 Oct 2020 15:42:25 -0400
Subject: vim-patch:8.1.1015: quickfix buffer shows up in list, can't get
 buffer number

Problem:    Quickfix buffer shows up in list, can't get buffer number.
Solution:   Make the quickfix buffer unlisted when the quickfix window is
            closed.  get the quickfix buffer number with getqflist().
            (Yegappan Lakshmanan, closes vim/vim#4113)
https://github.com/vim/vim/commit/647e24ba3dbf7ff448aa471b1a659a18267ae056
---
 runtime/doc/builtin.txt  | 21 ++++++++++++++++-----
 runtime/doc/eval.txt     | 16 ++++++++--------
 runtime/doc/quickfix.txt | 13 ++++++++++++-
 3 files changed, 36 insertions(+), 14 deletions(-)

(limited to 'runtime')

diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt
index ea7a53fa3b..ccc02e83b2 100644
--- a/runtime/doc/builtin.txt
+++ b/runtime/doc/builtin.txt
@@ -1284,7 +1284,7 @@ complete_info([{what}])				*complete_info()*
 <
 						*confirm()*
 confirm({msg} [, {choices} [, {default} [, {type}]]])
-		Confirm() offers the user a dialog, from which a choice can be
+		confirm() offers the user a dialog, from which a choice can be
 		made.  It returns the number of the choice.  For the first
 		choice this is 1.
 
@@ -3039,10 +3039,16 @@ getloclist({nr} [, {what}])				*getloclist()*
 		If the optional {what} dictionary argument is supplied, then
 		returns the items listed in {what} as a dictionary. Refer to
 		|getqflist()| for the supported items in {what}.
-		If {what} contains 'filewinid', then returns the id of the
-		window used to display files from the location list. This
-		field is applicable only when called from a location list
-		window. See |location-list-file-window| for more details.
+
+		In addition to the items supported by |getqflist()| in {what},
+		the following item is supported by |getloclist()|:
+
+			filewinid 	id of the window used to display files
+					from the location list. This field is
+					applicable only when called from a
+					location list window. See
+					|location-list-file-window| for more
+					details.
 
 		Returns a |Dictionary| with default values if there is no
 		location list for the window {nr}.
@@ -3218,6 +3224,9 @@ getqflist([{what}])					*getqflist()*
 			nr	get information for this quickfix list; zero
 				means the current quickfix list and "$" means
 				the last quickfix list
+			qfbufnr number of the buffer displayed in the quickfix
+				window. Returns 0 if the quickfix buffer is
+				not present. See |quickfix-buffer|.
 			size	number of entries in the quickfix list
 			title	get the list title |quickfix-title|
 			winid	get the quickfix |window-ID|
@@ -3246,6 +3255,8 @@ getqflist([{what}])					*getqflist()*
 			items	quickfix list entries. If not present, set to
 				an empty list.
 			nr	quickfix list number. If not present, set to 0
+			qfbufnr	number of the buffer displayed in the quickfix
+				window. If not present, set to 0.
 			size	number of entries in the quickfix list. If not
 				present, set to 0.
 			title	quickfix list title text. If not present, set
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 9fcdbe4cc3..ca2334500c 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -3225,14 +3225,14 @@ text...
 			commands are skipped.
 			When {pattern} is omitted all errors are caught.
 			Examples: >
-		:catch /^Vim:Interrupt$/	" catch interrupts (CTRL-C)
-		:catch /^Vim\%((\a\+)\)\=:E/	" catch all Vim errors
-		:catch /^Vim\%((\a\+)\)\=:/	" catch errors and interrupts
-		:catch /^Vim(write):/		" catch all errors in :write
-		:catch /^Vim\%((\a\+)\)\=:E123/	" catch error E123
-		:catch /my-exception/		" catch user exception
-		:catch /.*/			" catch everything
-		:catch				" same as /.*/
+		:catch /^Vim:Interrupt$/	 " catch interrupts (CTRL-C)
+		:catch /^Vim\%((\a\+)\)\=:E/	 " catch all Vim errors
+		:catch /^Vim\%((\a\+)\)\=:/	 " catch errors and interrupts
+		:catch /^Vim(write):/		 " catch all errors in :write
+		:catch /^Vim\%((\a\+)\)\=:E123:/ " catch error E123
+		:catch /my-exception/		 " catch user exception
+		:catch /.*/			 " catch everything
+		:catch				 " same as /.*/
 <
 			Another character can be used instead of / around the
 			{pattern}, so long as it does not have a special
diff --git a/runtime/doc/quickfix.txt b/runtime/doc/quickfix.txt
index 31a96298d2..8e91b101cd 100644
--- a/runtime/doc/quickfix.txt
+++ b/runtime/doc/quickfix.txt
@@ -571,6 +571,7 @@ location list.
 			second quickfix window.  If [height] is given the
 			existing window will be resized to it.
 
+							*quickfix-buffer*
 			The window will contain a special buffer, with
 			'buftype' equal to "quickfix".  Don't change this!
 			The window will have the w:quickfix_title variable set
@@ -579,7 +580,11 @@ location list.
 			status line if the value of 'statusline' is adjusted
 			properly. Whenever this buffer is modified by a
 			quickfix command or function, the |b:changedtick|
-			variable is incremented.
+			variable is incremented.  You can get the number of
+			this buffer using the getqflist() and getloclist()
+			functions by passing the 'qfbufnr' item. For a
+			location list, this buffer is wiped out when the
+			location list is removed.
 
 							*:lop* *:lopen*
 :lop[en] [height]	Open a window to show the location list for the
@@ -768,12 +773,18 @@ using these functions are below:
     " get the quickfix list window id
     :echo getqflist({'winid' : 0}).winid
 
+    " get the quickfix list window buffer number
+    :echo getqflist({'qfbufnr' : 0}).qfbufnr
+
     " get the context of the current location list
     :echo getloclist(0, {'context' : 0}).context
 
     " get the location list window id of the third window
     :echo getloclist(3, {'winid' : 0}).winid
 
+    " get the location list window buffer number of the third window
+    :echo getloclist(3, {'qfbufnr' : 0}).qfbufnr
+
     " get the file window id of a location list window (winnr: 4)
     :echo getloclist(4, {'filewinid' : 0}).filewinid
 <
-- 
cgit 


From 9e6bc228ec58b787c0985a65139d1959c9d889f0 Mon Sep 17 00:00:00 2001
From: adrian5 
Date: Sun, 13 Mar 2022 13:42:12 +0100
Subject: docs(api): improve section on nvim_set_hl (#17692)

---
 runtime/doc/api.txt | 32 +++++++++++++++-----------------
 1 file changed, 15 insertions(+), 17 deletions(-)

(limited to 'runtime')

diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt
index eefe6e5a47..9c3c143045 100644
--- a/runtime/doc/api.txt
+++ b/runtime/doc/api.txt
@@ -1544,23 +1544,21 @@ nvim_set_current_win({window})                        *nvim_set_current_win()*
                     {window}  Window handle
 
 nvim_set_hl({ns_id}, {name}, {*val})                           *nvim_set_hl()*
-                Set a highlight group.
-
-                Parameters: ~
-                    {ns_id}  number of namespace for this highlight. Use value
-                             0 to set a highlight group in the global (
-                             `:highlight` ) namespace.
-                    {name}   highlight group name, like ErrorMsg
-                    {val}    highlight definition map, like
-                             |nvim_get_hl_by_name|. in addition the following
-                             keys are also recognized: `default` : don't
-                             override existing definition, like `hi default`
-                             `ctermfg` : sets foreground of cterm color
-                             `ctermbg` : sets background of cterm color
-                             `cterm` : cterm attribute map. sets attributed
-                             for cterm colors. similer to `hi cterm` Note: by
-                             default cterm attributes are same as attributes
-                             of gui color
+                Sets a highlight group.
+
+                Parameters: ~
+                    {ns_id}  Namespace id for this highlight |nvim_create_namespace()|.
+                             Use 0 to set a highlight group globally |:highlight|.
+                    {name}   Highlight group name, e.g. "ErrorMsg"
+                    {val}    Highlight definition map, like |synIDattr()|. In
+                             addition, the following keys are recognized:
+                             • default: Don't override existing definition |:hi-default|
+                             • ctermfg: Sets foreground of cterm color |highlight-ctermfg|
+                             • ctermbg: Sets background of cterm color |highlight-ctermbg|
+                             • cterm: cterm attribute map, like
+                               |highlight-args|.
+                               Note: Attributes default to those set for `gui`
+                                     if not set.
 
 nvim_set_keymap({mode}, {lhs}, {rhs}, {*opts})             *nvim_set_keymap()*
                 Sets a global |mapping| for the given mode.
-- 
cgit 


From f9f843e02e5a0a036caa35efa686897f0e04ee3c Mon Sep 17 00:00:00 2001
From: Gregory Anders <8965202+gpanders@users.noreply.github.com>
Date: Sun, 13 Mar 2022 15:52:41 -0600
Subject: refactor: use Lua autocommands in filetype.lua (#17711)

---
 runtime/filetype.lua | 38 ++++++++++++++++++++++++--------------
 1 file changed, 24 insertions(+), 14 deletions(-)

(limited to 'runtime')

diff --git a/runtime/filetype.lua b/runtime/filetype.lua
index 74e427c358..8224b79534 100644
--- a/runtime/filetype.lua
+++ b/runtime/filetype.lua
@@ -7,26 +7,36 @@ if vim.g.do_filetype_lua ~= 1 then
   return
 end
 
--- TODO: Remove vim.cmd once Lua autocommands land
-vim.cmd [[
-augroup filetypedetect
-au BufRead,BufNewFile * call v:lua.vim.filetype.match(expand(''))
+vim.api.nvim_create_augroup("filetypedetect", {clear = false})
+
+vim.api.nvim_create_autocmd({"BufRead", "BufNewFile"}, {
+  group = "filetypedetect",
+  callback = function()
+    vim.filetype.match(vim.fn.expand(""))
+  end,
+})
 
-" These *must* be sourced after the autocommand above is created
+-- These *must* be sourced after the autocommand above is created
+vim.cmd [[
 runtime! ftdetect/*.vim
 runtime! ftdetect/*.lua
+]]
 
-" Set a marker so that the ftdetect scripts are not sourced a second time by filetype.vim
-let g:did_load_ftdetect = 1
+-- Set a marker so that the ftdetect scripts are not sourced a second time by filetype.vim
+vim.g.did_load_ftdetect = 1
 
-" If filetype.vim is disabled, set up the autocmd to use scripts.vim
-if exists('did_load_filetypes')
-  au BufRead,BufNewFile * if !did_filetype() && expand('') !~ g:ft_ignore_pat | runtime! scripts.vim | endif
-  au StdinReadPost * if !did_filetype() | runtime! scripts.vim | endif
-endif
+-- If filetype.vim is disabled, set up the autocmd to use scripts.vim
+if vim.g.did_load_filetypes then
+  vim.api.nvim_create_autocmd({"BufRead", "BufNewFile"}, {
+    group = "filetypedetect",
+    command = "if !did_filetype() && expand('') !~ g:ft_ignore_pat | runtime! scripts.vim | endif",
+  })
 
-augroup END
-]]
+  vim.api.nvim_create_autocmd("StdinReadPost", {
+    group = "filetypedetect",
+    command = "if !did_filetype() | runtime! scripts.vim | endif",
+  })
+end
 
 if not vim.g.ft_ignore_pat then
   vim.g.ft_ignore_pat = "\\.\\(Z\\|gz\\|bz2\\|zip\\|tgz\\)$"
-- 
cgit 


From be2def41006f1f6395be546cc95c3ada32e7966a Mon Sep 17 00:00:00 2001
From: Daiki Mizukami 
Date: Sun, 13 Mar 2022 21:36:46 +0900
Subject: chore(gen_vimdoc): fall back to `brief_desc_node` when `desc_node` is
 empty

---
 runtime/doc/api.txt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

(limited to 'runtime')

diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt
index 9c3c143045..6c4d63e4c9 100644
--- a/runtime/doc/api.txt
+++ b/runtime/doc/api.txt
@@ -594,7 +594,8 @@ nvim__id_float({flt})                                       *nvim__id_float()*
                     its argument.
 
 nvim__inspect_cell({grid}, {row}, {col})                *nvim__inspect_cell()*
-                TODO: Documentation
+                NB: if your UI doesn't use hlstate, this will not return
+                hlstate first time.
 
 nvim__runtime_inspect()                              *nvim__runtime_inspect()*
                 TODO: Documentation
-- 
cgit 


From ecc36c3d1c3952541eb1ad667850573ecedd4d36 Mon Sep 17 00:00:00 2001
From: Daiki Mizukami 
Date: Sun, 13 Mar 2022 21:48:14 +0900
Subject: docs: remove extra whitespaces

---
 runtime/doc/api.txt        | 56 +++++++++++++++++---------------
 runtime/doc/diagnostic.txt |  8 ++---
 runtime/doc/lsp.txt        | 80 +++++++++++++++++++++++-----------------------
 runtime/doc/lua.txt        | 28 ++++++++--------
 runtime/doc/treesitter.txt |  6 ++--
 5 files changed, 91 insertions(+), 87 deletions(-)

(limited to 'runtime')

diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt
index 6c4d63e4c9..4af13a3bbf 100644
--- a/runtime/doc/api.txt
+++ b/runtime/doc/api.txt
@@ -710,7 +710,7 @@ nvim_call_atomic({calls})                                 *nvim_call_atomic()*
                     be returned.
 
 nvim_chan_send({chan}, {data})                              *nvim_chan_send()*
-                Send data to channel `id` . For a job, it writes it to the
+                Send data to channel `id`. For a job, it writes it to the
                 stdin of the process. For the stdio channel |channel-stdio|,
                 it writes to Nvim's stdout. For an internal terminal instance
                 (|nvim_open_term()|) it writes directly to terminal output.
@@ -850,7 +850,7 @@ nvim_exec_lua({code}, {args})                                *nvim_exec_lua()*
                 inside the chunk. The chunk can return a value.
 
                 Only statements are executed. To evaluate an expression,
-                prefix it with `return` : return my_function(...)
+                prefix it with `return`: return my_function(...)
 
                 Parameters: ~
                     {code}  Lua code to execute
@@ -1133,13 +1133,13 @@ nvim_get_option_value({name}, {*opts})               *nvim_get_option_value()*
                     Option value
 
 nvim_get_proc({pid})                                         *nvim_get_proc()*
-                Gets info describing process `pid` .
+                Gets info describing process `pid`.
 
                 Return: ~
                     Map of process properties, or NIL if process not found.
 
 nvim_get_proc_children({pid})                       *nvim_get_proc_children()*
-                Gets the immediate children of process `pid` .
+                Gets the immediate children of process `pid`.
 
                 Return: ~
                     Array of child process ids, empty if process not found.
@@ -1248,8 +1248,8 @@ nvim_input_mouse({button}, {action}, {modifier}, {grid}, {row}, {col})
 nvim_list_bufs()                                            *nvim_list_bufs()*
                 Gets the current list of buffer handles
 
-                Includes unlisted (unloaded/deleted) buffers, like `:ls!` .
-                Use |nvim_buf_is_loaded()| to check if a buffer is loaded.
+                Includes unlisted (unloaded/deleted) buffers, like `:ls!`. Use
+                |nvim_buf_is_loaded()| to check if a buffer is loaded.
 
                 Return: ~
                     List of buffer handles
@@ -1358,7 +1358,7 @@ nvim_paste({data}, {crlf}, {phase})                             *nvim_paste()*
 
                 Errors ('nomodifiable', `vim.paste()` failure, …) are
                 reflected in `err` but do not affect the return value (which
-                is strictly decided by `vim.paste()` ). On error, subsequent
+                is strictly decided by `vim.paste()`). On error, subsequent
                 calls are ignored ("drained") until the next paste is
                 initiated (phase 1 or -1).
 
@@ -1435,7 +1435,7 @@ nvim_select_popupmenu_item({item}, {insert}, {finish}, {opts})
                     {insert}  Whether the selection should be inserted in the
                               buffer.
                     {finish}  Finish the completion and dismiss the popupmenu.
-                              Implies `insert` .
+                              Implies `insert`.
                     {opts}    Optional parameters. Reserved for future use.
 
                                                       *nvim_set_client_info()*
@@ -1548,18 +1548,21 @@ nvim_set_hl({ns_id}, {name}, {*val})                           *nvim_set_hl()*
                 Sets a highlight group.
 
                 Parameters: ~
-                    {ns_id}  Namespace id for this highlight |nvim_create_namespace()|.
-                             Use 0 to set a highlight group globally |:highlight|.
+                    {ns_id}  Namespace id for this highlight
+                             |nvim_create_namespace()|. Use 0 to set a
+                             highlight group globally |:highlight|.
                     {name}   Highlight group name, e.g. "ErrorMsg"
                     {val}    Highlight definition map, like |synIDattr()|. In
                              addition, the following keys are recognized:
-                             • default: Don't override existing definition |:hi-default|
-                             • ctermfg: Sets foreground of cterm color |highlight-ctermfg|
-                             • ctermbg: Sets background of cterm color |highlight-ctermbg|
+                             • default: Don't override existing definition
+                               |:hi-default|
+                             • ctermfg: Sets foreground of cterm color
+                               |highlight-ctermfg|
+                             • ctermbg: Sets background of cterm color
+                               |highlight-ctermbg|
                              • cterm: cterm attribute map, like
-                               |highlight-args|.
-                               Note: Attributes default to those set for `gui`
-                                     if not set.
+                               |highlight-args|. Note: Attributes default to
+                               those set for `gui` if not set.
 
 nvim_set_keymap({mode}, {lhs}, {rhs}, {*opts})             *nvim_set_keymap()*
                 Sets a global |mapping| for the given mode.
@@ -1628,7 +1631,7 @@ nvim_set_vvar({name}, {value})                               *nvim_set_vvar()*
                     {value}  Variable value
 
 nvim_strwidth({text})                                        *nvim_strwidth()*
-                Calculates the number of display cells occupied by `text` .
+                Calculates the number of display cells occupied by `text`.
                  counts as one cell.
 
                 Parameters: ~
@@ -1880,9 +1883,10 @@ nvim_buf_attach({buffer}, {send_buffer}, {opts})           *nvim_buf_attach()*
                     {buffer}       Buffer handle, or 0 for current buffer
                     {send_buffer}  True if the initial notification should
                                    contain the whole buffer: first
-                                   notification will be `nvim_buf_lines_event`
-                                   . Else the first notification will be
-                                   `nvim_buf_changedtick_event` . Not for Lua
+                                   notification will be
+                                   `nvim_buf_lines_event`. Else the first
+                                   notification will be
+                                   `nvim_buf_changedtick_event`. Not for Lua
                                    callbacks.
                     {opts}         Optional parameters.
                                    • on_lines: Lua callback invoked on change.
@@ -1938,7 +1942,7 @@ nvim_buf_attach({buffer}, {send_buffer}, {opts})           *nvim_buf_attach()*
 
                                    • utf_sizes: include UTF-32 and UTF-16 size
                                      of the replaced region, as args to
-                                     `on_lines` .
+                                     `on_lines`.
                                    • preview: also attach to command preview
                                      (i.e. 'inccommand') events.
 
@@ -2353,7 +2357,7 @@ nvim_buf_add_highlight({buffer}, {ns_id}, {hl_group}, {line}, {col_start},
                 namespace. All highlights in the same namespace can then be
                 cleared with single call to |nvim_buf_clear_namespace()|. If
                 the highlight never will be deleted by an API call, pass
-                `ns_id = -1` .
+                `ns_id = -1`.
 
                 As a shorthand, `ns_id = 0` can be used to create a new
                 namespace for the highlight, the allocated id is then
@@ -2433,8 +2437,8 @@ nvim_buf_get_extmarks({buffer}, {ns_id}, {start}, {end}, {opts})
     nvim_buf_get_extmarks(0, my_ns, [0,0], [-1,-1], {})
 <
 
-                If `end` is less than `start` , traversal works backwards.
-                (Useful with `limit` , to get the first marks prior to a given
+                If `end` is less than `start`, traversal works backwards.
+                (Useful with `limit`, to get the first marks prior to a given
                 position.)
 
                 Example:
@@ -2781,7 +2785,7 @@ nvim_win_hide({window})                                      *nvim_win_hide()*
                 |:hide| with a |window-ID|).
 
                 Like |:hide| the buffer becomes hidden unless another window
-                is editing it, or 'bufhidden' is `unload` , `delete` or `wipe`
+                is editing it, or 'bufhidden' is `unload`, `delete` or `wipe`
                 as opposed to |:close| or |nvim_win_close|, which will close
                 the buffer.
 
@@ -3029,7 +3033,7 @@ nvim_win_set_config({window}, {*config})               *nvim_win_set_config()*
                 layouts).
 
                 When reconfiguring a floating window, absent option keys will
-                not be changed. `row` / `col` and `relative` must be
+                not be changed. `row`/`col` and `relative` must be
                 reconfigured together.
 
                 Parameters: ~
diff --git a/runtime/doc/diagnostic.txt b/runtime/doc/diagnostic.txt
index e33c786482..32936a7ee6 100644
--- a/runtime/doc/diagnostic.txt
+++ b/runtime/doc/diagnostic.txt
@@ -328,11 +328,11 @@ config({opts}, {namespace})                          *vim.diagnostic.config()*
                 Note:
                     Each of the configuration options below accepts one of the
                     following:
-                    • `false` : Disable this feature
-                    • `true` : Enable this feature, use default settings.
-                    • `table` : Enable this feature with overrides. Use an
+                    • `false`: Disable this feature
+                    • `true`: Enable this feature, use default settings.
+                    • `table`: Enable this feature with overrides. Use an
                       empty table to use default values.
-                    • `function` : Function with signature (namespace, bufnr)
+                    • `function`: Function with signature (namespace, bufnr)
                       that returns any of the above.
 
                 Parameters: ~
diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt
index 54c648e171..a9ebcd27ae 100644
--- a/runtime/doc/lsp.txt
+++ b/runtime/doc/lsp.txt
@@ -563,7 +563,7 @@ buf_request_all({bufnr}, {method}, {params}, {callback})
 
                 Return: ~
                     (function) A function that will cancel all requests which
-                    is the same as the one returned from `buf_request` .
+                    is the same as the one returned from `buf_request`.
 
                                                   *vim.lsp.buf_request_sync()*
 buf_request_sync({bufnr}, {method}, {params}, {timeout_ms})
@@ -600,9 +600,9 @@ client()                                                      *vim.lsp.client*
                     {handler} is not specified, If one is not found there,
                     then an error will occur. Returns: {status},
                     {[client_id]}. {status} is a boolean indicating if the
-                    notification was successful. If it is `false` , then it
+                    notification was successful. If it is `false`, then it
                     will always be `false` (the client has shutdown). If
-                    {status} is `true` , the function returns {request_id} as
+                    {status} is `true`, the function returns {request_id} as
                     the second result. You can use this with
                     `client.cancel_request(request_id)` to cancel the request.
                   • request_sync(method, params, timeout_ms, bufnr) Sends a
@@ -612,13 +612,13 @@ client()                                                      *vim.lsp.client*
                     `err` and `result` come from the |lsp-handler|. On
                     timeout, cancel or error, returns `(nil, err)` where `err`
                     is a string describing the failure reason. If the request
-                    was unsuccessful returns `nil` .
+                    was unsuccessful returns `nil`.
                   • notify(method, params) Sends a notification to an LSP
                     server. Returns: a boolean to indicate if the notification
                     was successful. If it is false, then it will always be
                     false (the client has shutdown).
                   • cancel_request(id) Cancels a request with a given request
-                    id. Returns: same as `notify()` .
+                    id. Returns: same as `notify()`.
                   • stop([force]) Stops a client, optionally with force. By
                     default, it will just ask the server to shutdown without
                     force. If you request to stop a client which has
@@ -639,14 +639,14 @@ client()                                                      *vim.lsp.client*
                     interaction with the client. See |vim.lsp.rpc.start()|.
                   • {offset_encoding} (string): The encoding used for
                     communicating with the server. You can modify this in the
-                    `config` 's `on_init` method before text is sent to the
+                    `config`'s `on_init` method before text is sent to the
                     server.
                   • {handlers} (table): The handlers used by the client as
                     described in |lsp-handler|.
                   • {requests} (table): The current pending requests in flight
                     to the server. Entries are key-value pairs with the key
                     being the request ID while the value is a table with
-                    `type` , `bufnr` , and `method` key-value pairs. `type` is
+                    `type`, `bufnr`, and `method` key-value pairs. `type` is
                     either "pending" for an active request, or "cancel" for a
                     cancel request.
                   • {config} (table): copy of the table that was passed by the
@@ -655,7 +655,7 @@ client()                                                      *vim.lsp.client*
                     sent on `initialize` describing the server's capabilities.
                   • {resolved_capabilities} (table): Normalized table of
                     capabilities that we have detected based on the initialize
-                    response from the server in `server_capabilities` .
+                    response from the server in `server_capabilities`.
 
 client_is_stopped({client_id})                   *vim.lsp.client_is_stopped()*
                 Checks whether a client is stopped.
@@ -775,7 +775,7 @@ start_client({config})                                *vim.lsp.start_client()*
                                          initiates the LSP client.
                     {cmd_cwd}            (string, default=|getcwd()|)
                                          Directory to launch the `cmd`
-                                         process. Not related to `root_dir` .
+                                         process. Not related to `root_dir`.
                     {cmd_env}            (table) Environment flags to pass to
                                          the LSP on spawn. Can be specified
                                          using keys like a map or as a list
@@ -800,15 +800,15 @@ start_client({config})                                *vim.lsp.start_client()*
                                          its result.
                                          • Note: To send an empty dictionary
                                            use
-                                           `{[vim.type_idx]=vim.types.dictionary}`
-                                           , else it will be encoded as an
+                                           `{[vim.type_idx]=vim.types.dictionary}`,
+                                           else it will be encoded as an
                                            array.
                     {handlers}           Map of language server method names
                                          to |lsp-handler|
                     {settings}           Map with language server specific
                                          settings. These are returned to the
                                          language server if requested via
-                                         `workspace/configuration` . Keys are
+                                         `workspace/configuration`. Keys are
                                          case-sensitive.
                     {commands}           table Table that maps string of
                                          clientside commands to user-defined
@@ -821,7 +821,7 @@ start_client({config})                                *vim.lsp.start_client()*
                                          action, code lenses, ...) triggers
                                          the command.
                     {init_options}       Values to pass in the initialization
-                                         request as `initializationOptions` .
+                                         request as `initializationOptions`.
                                          See `initialize` in the LSP spec.
                     {name}               (string, default=client-id) Name in
                                          log messages.
@@ -976,7 +976,7 @@ code_action({context})                             *vim.lsp.buf.code_action()*
                                • only: (string|nil) LSP `CodeActionKind` used
                                  to filter the code actions. Most language
                                  servers support values like `refactor` or
-                                 `quickfix` .
+                                 `quickfix`.
 
                 See also: ~
                     https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_codeAction
@@ -1007,7 +1007,7 @@ definition()                                        *vim.lsp.buf.definition()*
 document_highlight()                        *vim.lsp.buf.document_highlight()*
                 Send request to the server to resolve document highlights for
                 the current text document position. This request can be
-                triggered by a key mapping or by events such as `CursorHold` ,
+                triggered by a key mapping or by events such as `CursorHold`,
                 e.g.:
 >
     autocmd CursorHold   lua vim.lsp.buf.document_highlight()
@@ -1124,7 +1124,7 @@ range_code_action({context}, {start_pos}, {end_pos})
                                  • only: (string|nil) LSP `CodeActionKind`
                                    used to filter the code actions. Most
                                    language servers support values like
-                                   `refactor` or `quickfix` .
+                                   `refactor` or `quickfix`.
                     {start_pos}  ({number, number}, optional) mark-indexed
                                  position. Defaults to the start of the last
                                  visual selection.
@@ -1246,8 +1246,8 @@ display({lenses}, {bufnr}, {client_id})           *vim.lsp.codelens.display()*
                 Display the lenses using virtual text
 
                 Parameters: ~
-                    {lenses}     table of lenses to display ( `CodeLens[] |
-                                 null` )
+                    {lenses}     table of lenses to display (`CodeLens[] |
+                                 null`)
                     {bufnr}      number
                     {client_id}  number
 
@@ -1259,7 +1259,7 @@ get({bufnr})                                          *vim.lsp.codelens.get()*
                              current buffer.
 
                 Return: ~
-                    table ( `CodeLens[]` )
+                    table (`CodeLens[]`)
 
                                               *vim.lsp.codelens.on_codelens()*
 on_codelens({err}, {result}, {ctx}, {_})
@@ -1281,8 +1281,8 @@ save({lenses}, {bufnr}, {client_id})                 *vim.lsp.codelens.save()*
                 Store lenses for a specific buffer and client
 
                 Parameters: ~
-                    {lenses}     table of lenses to store ( `CodeLens[] |
-                                 null` )
+                    {lenses}     table of lenses to store (`CodeLens[] |
+                                 null`)
                     {bufnr}      number
                     {client_id}  number
 
@@ -1333,7 +1333,7 @@ Lua module: vim.lsp.util                                            *lsp-util*
 
                                      *vim.lsp.util.apply_text_document_edit()*
 apply_text_document_edit({text_document_edit}, {index}, {offset_encoding})
-                Applies a `TextDocumentEdit` , which is a list of changes to a
+                Applies a `TextDocumentEdit`, which is a list of changes to a
                 single document.
 
                 Parameters: ~
@@ -1360,7 +1360,7 @@ apply_text_edits({text_edits}, {bufnr}, {offset_encoding})
 
                                          *vim.lsp.util.apply_workspace_edit()*
 apply_workspace_edit({workspace_edit}, {offset_encoding})
-                Applies a `WorkspaceEdit` .
+                Applies a `WorkspaceEdit`.
 
                 Parameters: ~
                     {workspace_edit}   table `WorkspaceEdit`
@@ -1408,13 +1408,13 @@ convert_input_to_markdown_lines({input}, {contents})
                 Converts any of `MarkedString` | `MarkedString[]` |
                 `MarkupContent` into a list of lines containing valid
                 markdown. Useful to populate the hover window for
-                `textDocument/hover` , for parsing the result of
-                `textDocument/signatureHelp` , and potentially others.
+                `textDocument/hover`, for parsing the result of
+                `textDocument/signatureHelp`, and potentially others.
 
                 Parameters: ~
-                    {input}     ( `MarkedString` | `MarkedString[]` |
-                                `MarkupContent` )
-                    {contents}  (table, optional, default `{}` ) List of
+                    {input}     (`MarkedString` | `MarkedString[]` |
+                                `MarkupContent`)
+                    {contents}  (table, optional, default `{}`) List of
                                 strings to extend with converted lines
 
                 Return: ~
@@ -1475,7 +1475,7 @@ jump_to_location({location}, {offset_encoding})
                 Jumps to a location.
 
                 Parameters: ~
-                    {location}         table ( `Location` | `LocationLink` )
+                    {location}         table (`Location`|`LocationLink`)
                     {offset_encoding}  string utf-8|utf-16|utf-32 (required)
 
                 Return: ~
@@ -1491,8 +1491,8 @@ locations_to_items({locations}, {offset_encoding})
                 |setqflist()| or |setloclist()|.
 
                 Parameters: ~
-                    {locations}        table list of `Location` s or
-                                       `LocationLink` s
+                    {locations}        table list of `Location`s or
+                                       `LocationLink`s
                     {offset_encoding}  string offset_encoding for locations
                                        utf-8|utf-16|utf-32
 
@@ -1526,7 +1526,7 @@ make_floating_popup_options({width}, {height}, {opts})
                               • border (string or table) override `border`
                               • focusable (string or table) override
                                 `focusable`
-                              • zindex (string or table) override `zindex` ,
+                              • zindex (string or table) override `zindex`,
                                 defaults to 50
 
                 Return: ~
@@ -1566,7 +1566,7 @@ make_given_range_params({start_pos}, {end_pos}, {bufnr}, {offset_encoding})
 
                 Return: ~
                     { textDocument = { uri = `current_file_uri` }, range = {
-                    start = `start_position` , end = `end_position` } }
+                    start = `start_position`, end = `end_position` } }
 
                                          *vim.lsp.util.make_position_params()*
 make_position_params({window}, {offset_encoding})
@@ -1590,9 +1590,9 @@ make_position_params({window}, {offset_encoding})
 make_range_params({window}, {offset_encoding})
                 Using the current position in the current buffer, creates an
                 object that can be used as a building block for several LSP
-                requests, such as `textDocument/codeAction` ,
-                `textDocument/colorPresentation` ,
-                `textDocument/rangeFormatting` .
+                requests, such as `textDocument/codeAction`,
+                `textDocument/colorPresentation`,
+                `textDocument/rangeFormatting`.
 
                 Parameters: ~
                     {window}           (optional, number): window handle or 0
@@ -1603,7 +1603,7 @@ make_range_params({window}, {offset_encoding})
 
                 Return: ~
                     { textDocument = { uri = `current_file_uri` }, range = {
-                    start = `current_position` , end = `current_position` } }
+                    start = `current_position`, end = `current_position` } }
 
                                     *vim.lsp.util.make_text_document_params()*
 make_text_document_params({bufnr})
@@ -1657,8 +1657,8 @@ open_floating_preview({contents}, {syntax}, {opts})
                                   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
+                                • focus: (boolean, default true) If `true`,
+                                  and if {focusable} is also `true`, focus an
                                   existing floating window with the same
                                   {focus_id}
 
@@ -1757,7 +1757,7 @@ text_document_completion_list_to_complete_items({result}, {prefix})
                 Parameters: ~
                     {result}  The result of a `textDocument/completion` call,
                               e.g. from |vim.lsp.buf.completion()|, which may
-                              be one of `CompletionItem[]` , `CompletionList`
+                              be one of `CompletionItem[]`, `CompletionList`
                               or `null`
                     {prefix}  (string) the prefix to filter the completion
                               items
diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt
index 11629332ae..93386ddfe9 100644
--- a/runtime/doc/lua.txt
+++ b/runtime/doc/lua.txt
@@ -1418,7 +1418,7 @@ deep_equal({a}, {b})                                        *vim.deep_equal()*
                     {b}  second value
 
                 Return: ~
-                    `true` if values are equals, else `false` .
+                    `true` if values are equals, else `false`.
 
 deepcopy({orig})                                              *vim.deepcopy()*
                 Returns a deep copy of the given object. Non-table objects are
@@ -1435,7 +1435,7 @@ deepcopy({orig})                                              *vim.deepcopy()*
                     New table of copied keys and (nested) values.
 
 endswith({s}, {suffix})                                       *vim.endswith()*
-                Tests if `s` ends with `suffix` .
+                Tests if `s` ends with `suffix`.
 
                 Parameters: ~
                     {s}       (string) a string
@@ -1539,7 +1539,7 @@ split({s}, {sep}, {kwargs})                                      *vim.split()*
                     |vim.gsplit()|
 
 startswith({s}, {prefix})                                   *vim.startswith()*
-                Tests if `s` starts with `prefix` .
+                Tests if `s` starts with `prefix`.
 
                 Parameters: ~
                     {s}       (string) a string
@@ -1556,7 +1556,7 @@ tbl_add_reverse_lookup({o})                     *vim.tbl_add_reverse_lookup()*
                     {o}  table The table to add the reverse to.
 
 tbl_contains({t}, {value})                                *vim.tbl_contains()*
-                Checks if a list-like (vector) table contains `value` .
+                Checks if a list-like (vector) table contains `value`.
 
                 Parameters: ~
                     {t}      Table to check
@@ -1566,7 +1566,7 @@ tbl_contains({t}, {value})                                *vim.tbl_contains()*
                     true if `t` contains `value`
 
 tbl_count({t})                                               *vim.tbl_count()*
-                Counts the number of non-nil values in table `t` .
+                Counts the number of non-nil values in table `t`.
 >
 
     vim.tbl_count({ a=1, b=2 }) => 2
@@ -1651,7 +1651,7 @@ tbl_islist({t})                                             *vim.tbl_islist()*
                     {t}  Table
 
                 Return: ~
-                    `true` if array-like table, else `false` .
+                    `true` if array-like table, else `false`.
 
 tbl_keys({t})                                                 *vim.tbl_keys()*
                 Return a list of all keys used in a table. However, the order
@@ -1813,7 +1813,7 @@ input({opts}, {on_confirm})                                   *vim.ui.input()*
                 Parameters: ~
                     {opts}        table Additional options. See |input()|
                                   • prompt (string|nil) Text of the prompt.
-                                    Defaults to `Input:` .
+                                    Defaults to `Input:`.
                                   • default (string|nil) Default reply to the
                                     input
                                   • completion (string|nil) Specifies type of
@@ -1856,16 +1856,16 @@ select({items}, {opts}, {on_choice})                         *vim.ui.select()*
                                    Defaults to `Select one of:`
                                  • format_item (function item -> text)
                                    Function to format an individual item from
-                                   `items` . Defaults to `tostring` .
+                                   `items`. Defaults to `tostring`.
                                  • kind (string|nil) Arbitrary hint string
                                    indicating the item shape. Plugins
                                    reimplementing `vim.ui.select` may wish to
                                    use this to infer the structure or
-                                   semantics of `items` , or the context in
+                                   semantics of `items`, or the context in
                                    which select() was called.
                     {on_choice}  function ((item|nil, idx|nil) -> ()) Called
                                  once the user made a choice. `idx` is the
-                                 1-based index of `item` within `item` . `nil`
+                                 1-based index of `item` within `item`. `nil`
                                  if the user aborted the dialog.
 
 
@@ -1990,9 +1990,9 @@ set({mode}, {lhs}, {rhs}, {opts})                           *vim.keymap.set()*
                     vim.keymap.set('n', 'asdf', require('jkl').my_fun)
 <
 
-                the require('jkl') gets evaluated during this call in order to
-                access the function. If you want to avoid this cost at startup
-                you can wrap it in a function, for example: >
+                the require('jkl )` gets evaluated during this call in order to access the
+                function. If you want to avoid this cost at startup you can
+                wrap it in a function, for example: >
 
                     vim.keymap.set('n', 'asdf', function() return require('jkl').my_fun() end)
 <
@@ -2014,7 +2014,7 @@ set({mode}, {lhs}, {rhs}, {opts})                           *vim.keymap.set()*
                               result of Lua expr maps.
                             • remap: (boolean) Make the mapping recursive.
                               This is the inverse of the "noremap" option from
-                              |nvim_set_keymap()|. Default `false` .
+                              |nvim_set_keymap()|. Default `false`.
 
                 See also: ~
                     |nvim_set_keymap()|
diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt
index 02be20c5e8..a9d9f81849 100644
--- a/runtime/doc/treesitter.txt
+++ b/runtime/doc/treesitter.txt
@@ -468,7 +468,7 @@ parse_query({lang}, {query})                                   *parse_query()*
 
                 Exposes `info` and `captures` with additional context about {query}.
                 • `captures` contains the list of unique capture names defined
-                  in {query}. - `info.captures` also points to `captures` .
+                  in {query}. -`info.captures` also points to `captures`.
                 • `info.patterns` contains information about predicates.
 
                 Parameters: ~
@@ -528,8 +528,8 @@ Query:iter_matches({self}, {node}, {source}, {start}, {stop})
                 a table mapping capture indices to nodes, and metadata from
                 any directives processing the match. If the query has more
                 than one pattern the capture table might be sparse, and e.g.
-                `pairs()` method should be used over `ipairs` . Here an
-                example iterating over all captures in every match:
+                `pairs()` method should be used over `ipairs`. Here an example
+                iterating over all captures in every match:
 >
 
     for pattern, match, metadata in cquery:iter_matches(tree:root(), bufnr, first, last) do
-- 
cgit 


From c5f190e0c21b4e8465502fd9f260c3d49a4102ab Mon Sep 17 00:00:00 2001
From: Sean Dewar 
Date: Mon, 14 Mar 2022 11:37:44 +0000
Subject: vim-patch:8.2.1401: cannot jump to the last used tabpage

Problem:    Cannot jump to the last used tabpage.
Solution:   Add g and tabpagnr('#'). (Yegappan Lakshmanan, closes vim/vim#6661,
            neovim #11626)
https://github.com/vim/vim/commit/62a232506d06f6d1b3b7271801c907d6294dfe84

Nvim implemented this feature before Vim, but Vim made some useful changes (e.g:
beeping on failure). Port the changes to closer match Vim (also makes porting
future patches easier).

Also note that because CHECK_CMDWIN was added to goto_tabpage_tp, there is no
need to do the extra work with tabpage_index and goto_tabpage inside
goto_tabpage_lastused to fix cmdwin issues any more (#11692).
Note that while goto_tabpage_tp doesn't check for textlock like goto_tabpage
does, it shouldn't matter as it is already checked for earlier.

Add tags for  to tabpage.txt, and refer to  over CTRL-Tab to be
consistent with other docs like the patch.
Remove mention of "previous tabpage" (it can be confused with the tabpage to the
left, e.g: `:tabprevious`).
Similarly, don't rename old_curtab to last_tab in enter_tabpage (it might be
confused with the right-most tabpage, e.g: `:tablast`).

Cherry-pick Test_tabpage change from v8.2.0634.
https://github.com/vim/vim/commit/92b83ccfda7a1d654ccaaf161a9c8a8e01fbcf76
---
 runtime/doc/builtin.txt | 8 ++++----
 runtime/doc/index.txt   | 3 ++-
 runtime/doc/tabpage.txt | 7 +++----
 3 files changed, 9 insertions(+), 9 deletions(-)

(limited to 'runtime')

diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt
index ccc02e83b2..9eec23b7b7 100644
--- a/runtime/doc/builtin.txt
+++ b/runtime/doc/builtin.txt
@@ -8103,15 +8103,15 @@ tabpagebuflist([{arg}])					*tabpagebuflist()*
 tabpagenr([{arg}])					*tabpagenr()*
 		The result is a Number, which is the number of the current
 		tab page.  The first tab page has number 1.
+
 		The optional argument {arg} supports the following values:
 			$	the number of the last tab page (the tab page
 				count).
-			#	the number of the last accessed tab page (where
-				|g| goes to).  If there is no previous
-				tab page, 0 is returned.
+			#	the number of the last accessed tab page
+				(where |g| goes to).  If there is no
+				previous tab page, 0 is returned.
 		The number can be used with the |:tab| command.
 
-
 tabpagewinnr({tabarg} [, {arg}])			*tabpagewinnr()*
 		Like |winnr()| but for tab page {tabarg}.
 		{tabarg} specifies the number of tab page to be used.
diff --git a/runtime/doc/index.txt b/runtime/doc/index.txt
index d02ab1b759..572b4e3f93 100644
--- a/runtime/doc/index.txt
+++ b/runtime/doc/index.txt
@@ -431,6 +431,7 @@ tag		char	      note action in Normal mode	~
 ||		   ":ta" to the keyword at the mouse click
 ||		1  same as "w"
 || 	   same as "CTRL-T"
+||			   same as "g"
 ||		["x]	2  same as "x"
 |N|	{count}	   remove the last digit from {count}
 ||			1  same as "j"
@@ -577,7 +578,7 @@ tag		command		   action in Normal mode	~
 				   following the file name.
 |CTRL-W_gt|	CTRL-W g t	   same as `gt`: go to next tab page
 |CTRL-W_gT|	CTRL-W g T	   same as `gT`: go to previous tab page
-|CTRL-W_g|	CTRL-W g 	   same as `g` : go to last accessed tab
+|CTRL-W_g|	CTRL-W g 	   same as |g|: go to last accessed tab
 				   page
 |CTRL-W_h|	CTRL-W h	   go to Nth left window (stop at first window)
 |CTRL-W_i|	CTRL-W i	   split window and jump to declaration of
diff --git a/runtime/doc/tabpage.txt b/runtime/doc/tabpage.txt
index 78b5101da7..f06a6bcc34 100644
--- a/runtime/doc/tabpage.txt
+++ b/runtime/doc/tabpage.txt
@@ -196,10 +196,6 @@ gt					*i_CTRL-* *i_*
 {count}
 {count}gt	Go to tab page {count}.  The first tab page has number one.
 
-CTRL-					*CTRL-*
-CTRL-W g					*g* *CTRL-W_g*
-g		Go to previous (last accessed) tab page.
-
 :tabp[revious]				*:tabp* *:tabprevious* *gT* *:tabN*
 :tabN[ext]				*:tabNext* *CTRL-*
 			 ** *i_CTRL-* *i_*
@@ -219,6 +215,9 @@ gT		Go to the previous tab page.  Wraps around from the first one
 							*:tabl* *:tablast*
 :tabl[ast]	Go to the last tab page.
 
+						*CTRL-* **
+CTRL-W g					*g* *CTRL-W_g*
+g		Go to the last accessed tab page.
 
 Other commands:
 							*:tabs*
-- 
cgit 


From 9b1e1fbc9f795921afd25ba38be5c79dec8b04d2 Mon Sep 17 00:00:00 2001
From: zeertzjq 
Date: Sun, 6 Mar 2022 06:56:24 +0800
Subject: fix(paste): use getcmdtype() to determine whether in cmdline mode

---
 runtime/lua/vim/_editor.lua | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

(limited to 'runtime')

diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua
index a0c60a7dcf..8000730795 100644
--- a/runtime/lua/vim/_editor.lua
+++ b/runtime/lua/vim/_editor.lua
@@ -156,21 +156,21 @@ do
   ---                - 3: ends the paste (exactly once)
   ---@returns false if client should cancel the paste.
   function vim.paste(lines, phase)
-    local call = vim.api.nvim_call_function
     local now = vim.loop.now()
-    local mode = call('mode', {}):sub(1,1)
+    local mode = vim.api.nvim_get_mode().mode
+    local is_cmdline = vim.fn.getcmdtype() ~= ''
     if phase < 2 then  -- Reset flags.
       tdots, tick, got_line1 = now, 0, false
-    elseif mode ~= 'c' then
+    elseif not is_cmdline then
       vim.api.nvim_command('undojoin')
     end
-    if mode == 'c' and not got_line1 then  -- cmdline-mode: paste only 1 line.
+    if is_cmdline and not got_line1 then  -- cmdline-mode: paste only 1 line.
       got_line1 = (#lines > 1)
       vim.api.nvim_set_option('paste', true)  -- For nvim_input().
       local line1 = lines[1]:gsub('<', ''):gsub('[\r\n\012\027]', ' ')  -- Scrub.
       vim.api.nvim_input(line1)
       vim.api.nvim_set_option('paste', false)
-    elseif mode ~= 'c' then
+    elseif not is_cmdline then
       if phase < 2 and mode:find('^[vV\22sS\19]') then
         vim.api.nvim_command([[exe "normal! \"]])
         vim.api.nvim_put(lines, 'c', false, true)
@@ -178,7 +178,7 @@ do
         vim.api.nvim_put(lines, 'c', true, true)
         -- XXX: Normal-mode: workaround bad cursor-placement after first chunk.
         vim.api.nvim_command('normal! a')
-      elseif phase < 2 and mode == 'R' then
+      elseif phase < 2 and mode:find('^R') then
         local nchars = 0
         for _, line in ipairs(lines) do
             nchars = nchars + line:len()
-- 
cgit 


From 2601e0873ff50ed804487dff00bd27e233709beb Mon Sep 17 00:00:00 2001
From: zeertzjq 
Date: Sun, 6 Mar 2022 06:56:24 +0800
Subject: fix(paste): don't move cursor past the end of pasted text in Normal
 mode

---
 runtime/lua/vim/_editor.lua | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

(limited to 'runtime')

diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua
index 8000730795..8e49b51cec 100644
--- a/runtime/lua/vim/_editor.lua
+++ b/runtime/lua/vim/_editor.lua
@@ -171,27 +171,34 @@ do
       vim.api.nvim_input(line1)
       vim.api.nvim_set_option('paste', false)
     elseif not is_cmdline then
-      if phase < 2 and mode:find('^[vV\22sS\19]') then
-        vim.api.nvim_command([[exe "normal! \"]])
+      if mode:find('^i') or mode:find('^n?t') then  -- Insert mode or Terminal buffer
         vim.api.nvim_put(lines, 'c', false, true)
-      elseif phase < 2 and not mode:find('^[iRt]') then
-        vim.api.nvim_put(lines, 'c', true, true)
-        -- XXX: Normal-mode: workaround bad cursor-placement after first chunk.
-        vim.api.nvim_command('normal! a')
-      elseif phase < 2 and mode:find('^R') then
+      elseif phase < 2 and mode:find('^R') and not mode:find('^Rv') then  -- Replace mode
+        -- TODO: implement Replace mode streamed pasting
+        -- TODO: support Virtual Replace mode
         local nchars = 0
         for _, line in ipairs(lines) do
-            nchars = nchars + line:len()
+          nchars = nchars + line:len()
         end
         local row, col = unpack(vim.api.nvim_win_get_cursor(0))
         local bufline = vim.api.nvim_buf_get_lines(0, row-1, row, true)[1]
         local firstline = lines[1]
         firstline = bufline:sub(1, col)..firstline
         lines[1] = firstline
+        -- FIXME: #lines can be 0
         lines[#lines] = lines[#lines]..bufline:sub(col + nchars + 1, bufline:len())
         vim.api.nvim_buf_set_lines(0, row-1, row, false, lines)
-      else
-        vim.api.nvim_put(lines, 'c', false, true)
+      elseif mode:find('^[nvV\22sS\19]') then  -- Normal or Visual or Select mode
+        if mode:find('^n') then  -- Normal mode
+          vim.api.nvim_put(lines, 'c', true, false)
+        else  -- Visual or Select mode
+          vim.api.nvim_command([[exe "normal! \"]])
+          vim.api.nvim_put(lines, 'c', false, false)
+        end
+        -- put cursor at the end of the text instead of one character after it
+        vim.fn.setpos('.', vim.fn.getpos("']"))
+      else  -- Don't know what to do in other modes
+        return false
       end
     end
     if phase ~= -1 and (now - tdots >= 100) then
-- 
cgit 


From bfb77544425b7cca372cb87f00ef6b6e87c5f6d5 Mon Sep 17 00:00:00 2001
From: zeertzjq 
Date: Sun, 6 Mar 2022 06:56:24 +0800
Subject: fix(paste): deal with eol and eof in Visual mode

---
 runtime/lua/vim/_editor.lua | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

(limited to 'runtime')

diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua
index 8e49b51cec..6b1725c9ff 100644
--- a/runtime/lua/vim/_editor.lua
+++ b/runtime/lua/vim/_editor.lua
@@ -192,8 +192,19 @@ do
         if mode:find('^n') then  -- Normal mode
           vim.api.nvim_put(lines, 'c', true, false)
         else  -- Visual or Select mode
-          vim.api.nvim_command([[exe "normal! \"]])
-          vim.api.nvim_put(lines, 'c', false, false)
+          vim.api.nvim_command([[exe "silent normal! \"]])
+          local del_start = vim.fn.getpos("'[")
+          local cursor_pos = vim.fn.getpos('.')
+          if mode:find('^[VS]') then  -- linewise
+            if cursor_pos[2] < del_start[2] then  -- replacing lines at eof
+              -- create a new line
+              vim.api.nvim_put({''}, 'l', true, true)
+            end
+            vim.api.nvim_put(lines, 'c', false, false)
+          else
+            -- paste after cursor when replacing text at eol, otherwise paste before cursor
+            vim.api.nvim_put(lines, 'c', cursor_pos[3] < del_start[3], false)
+          end
         end
         -- put cursor at the end of the text instead of one character after it
         vim.fn.setpos('.', vim.fn.getpos("']"))
-- 
cgit 


From 21ba2d81a848e7b85739fc3e9aa2eb0b5e35c879 Mon Sep 17 00:00:00 2001
From: zeertzjq 
Date: Sun, 6 Mar 2022 06:56:24 +0800
Subject: refactor(paste): do not print dots in cmdline mode

---
 runtime/lua/vim/_editor.lua | 100 +++++++++++++++++++++++---------------------
 1 file changed, 52 insertions(+), 48 deletions(-)

(limited to 'runtime')

diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua
index 6b1725c9ff..a7f8f0e7b6 100644
--- a/runtime/lua/vim/_editor.lua
+++ b/runtime/lua/vim/_editor.lua
@@ -157,60 +157,64 @@ do
   ---@returns false if client should cancel the paste.
   function vim.paste(lines, phase)
     local now = vim.loop.now()
-    local mode = vim.api.nvim_get_mode().mode
-    local is_cmdline = vim.fn.getcmdtype() ~= ''
-    if phase < 2 then  -- Reset flags.
+    local is_first_chunk = phase < 2
+    if is_first_chunk then  -- Reset flags.
       tdots, tick, got_line1 = now, 0, false
-    elseif not is_cmdline then
+    end
+    -- Note: mode doesn't always start with "c" in cmdline mode, so use getcmdtype() instead.
+    if vim.fn.getcmdtype() ~= '' then  -- cmdline-mode: paste only 1 line.
+      if not got_line1 then
+        got_line1 = (#lines > 1)
+        vim.api.nvim_set_option('paste', true)  -- For nvim_input().
+        local line1 = lines[1]:gsub('<', ''):gsub('[\r\n\012\027]', ' ')  -- Scrub.
+        vim.api.nvim_input(line1)
+        vim.api.nvim_set_option('paste', false)
+      end
+      return true
+    end
+    local mode = vim.api.nvim_get_mode().mode
+    if not is_first_chunk then
       vim.api.nvim_command('undojoin')
     end
-    if is_cmdline and not got_line1 then  -- cmdline-mode: paste only 1 line.
-      got_line1 = (#lines > 1)
-      vim.api.nvim_set_option('paste', true)  -- For nvim_input().
-      local line1 = lines[1]:gsub('<', ''):gsub('[\r\n\012\027]', ' ')  -- Scrub.
-      vim.api.nvim_input(line1)
-      vim.api.nvim_set_option('paste', false)
-    elseif not is_cmdline then
-      if mode:find('^i') or mode:find('^n?t') then  -- Insert mode or Terminal buffer
-        vim.api.nvim_put(lines, 'c', false, true)
-      elseif phase < 2 and mode:find('^R') and not mode:find('^Rv') then  -- Replace mode
-        -- TODO: implement Replace mode streamed pasting
-        -- TODO: support Virtual Replace mode
-        local nchars = 0
-        for _, line in ipairs(lines) do
-          nchars = nchars + line:len()
-        end
-        local row, col = unpack(vim.api.nvim_win_get_cursor(0))
-        local bufline = vim.api.nvim_buf_get_lines(0, row-1, row, true)[1]
-        local firstline = lines[1]
-        firstline = bufline:sub(1, col)..firstline
-        lines[1] = firstline
-        -- FIXME: #lines can be 0
-        lines[#lines] = lines[#lines]..bufline:sub(col + nchars + 1, bufline:len())
-        vim.api.nvim_buf_set_lines(0, row-1, row, false, lines)
-      elseif mode:find('^[nvV\22sS\19]') then  -- Normal or Visual or Select mode
-        if mode:find('^n') then  -- Normal mode
-          vim.api.nvim_put(lines, 'c', true, false)
-        else  -- Visual or Select mode
-          vim.api.nvim_command([[exe "silent normal! \"]])
-          local del_start = vim.fn.getpos("'[")
-          local cursor_pos = vim.fn.getpos('.')
-          if mode:find('^[VS]') then  -- linewise
-            if cursor_pos[2] < del_start[2] then  -- replacing lines at eof
-              -- create a new line
-              vim.api.nvim_put({''}, 'l', true, true)
-            end
-            vim.api.nvim_put(lines, 'c', false, false)
-          else
-            -- paste after cursor when replacing text at eol, otherwise paste before cursor
-            vim.api.nvim_put(lines, 'c', cursor_pos[3] < del_start[3], false)
+    if mode:find('^i') or mode:find('^n?t') then  -- Insert mode or Terminal buffer
+      vim.api.nvim_put(lines, 'c', false, true)
+    elseif phase < 2 and mode:find('^R') and not mode:find('^Rv') then  -- Replace mode
+      -- TODO: implement Replace mode streamed pasting
+      -- TODO: support Virtual Replace mode
+      local nchars = 0
+      for _, line in ipairs(lines) do
+        nchars = nchars + line:len()
+      end
+      local row, col = unpack(vim.api.nvim_win_get_cursor(0))
+      local bufline = vim.api.nvim_buf_get_lines(0, row-1, row, true)[1]
+      local firstline = lines[1]
+      firstline = bufline:sub(1, col)..firstline
+      lines[1] = firstline
+      -- FIXME: #lines can be 0
+      lines[#lines] = lines[#lines]..bufline:sub(col + nchars + 1, bufline:len())
+      vim.api.nvim_buf_set_lines(0, row-1, row, false, lines)
+    elseif mode:find('^[nvV\22sS\19]') then  -- Normal or Visual or Select mode
+      if mode:find('^n') then  -- Normal mode
+        vim.api.nvim_put(lines, 'c', true, false)
+      else  -- Visual or Select mode
+        vim.api.nvim_command([[exe "silent normal! \"]])
+        local del_start = vim.fn.getpos("'[")
+        local cursor_pos = vim.fn.getpos('.')
+        if mode:find('^[VS]') then  -- linewise
+          if cursor_pos[2] < del_start[2] then  -- replacing lines at eof
+            -- create a new line
+            vim.api.nvim_put({''}, 'l', true, true)
           end
+          vim.api.nvim_put(lines, 'c', false, false)
+        else
+          -- paste after cursor when replacing text at eol, otherwise paste before cursor
+          vim.api.nvim_put(lines, 'c', cursor_pos[3] < del_start[3], false)
         end
-        -- put cursor at the end of the text instead of one character after it
-        vim.fn.setpos('.', vim.fn.getpos("']"))
-      else  -- Don't know what to do in other modes
-        return false
       end
+      -- put cursor at the end of the text instead of one character after it
+      vim.fn.setpos('.', vim.fn.getpos("']"))
+    else  -- Don't know what to do in other modes
+      return false
     end
     if phase ~= -1 and (now - tdots >= 100) then
       local dots = ('.'):rep(tick % 4)
-- 
cgit 


From fcc6f66cf2a67cf85e72727a08e19d0f800badb9 Mon Sep 17 00:00:00 2001
From: zeertzjq 
Date: Sun, 6 Mar 2022 06:56:24 +0800
Subject: fix(paste): avoid edges cases caused by empty chunk

---
 runtime/lua/vim/_editor.lua | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

(limited to 'runtime')

diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua
index a7f8f0e7b6..42adda6e7f 100644
--- a/runtime/lua/vim/_editor.lua
+++ b/runtime/lua/vim/_editor.lua
@@ -128,7 +128,7 @@ local function inspect(object, options)  -- luacheck: no unused
 end
 
 do
-  local tdots, tick, got_line1 = 0, 0, false
+  local tdots, tick, got_line1, undo_started = 0, 0, false, false
 
   --- Paste handler, invoked by |nvim_paste()| when a conforming UI
   --- (such as the |TUI|) pastes text into the editor.
@@ -158,8 +158,17 @@ do
   function vim.paste(lines, phase)
     local now = vim.loop.now()
     local is_first_chunk = phase < 2
+    local is_last_chunk = phase == -1 or phase == 3
     if is_first_chunk then  -- Reset flags.
-      tdots, tick, got_line1 = now, 0, false
+      tdots, tick, got_line1, undo_started = now, 0, false, false
+    end
+    if #lines == 0 then
+      lines = {''}
+    end
+    if #lines == 1 and lines[1] == '' and not is_last_chunk then
+      -- An empty chunk can cause some edge cases in streamed pasting,
+      -- so don't do anything unless it is the last chunk.
+      return true
     end
     -- Note: mode doesn't always start with "c" in cmdline mode, so use getcmdtype() instead.
     if vim.fn.getcmdtype() ~= '' then  -- cmdline-mode: paste only 1 line.
@@ -173,7 +182,7 @@ do
       return true
     end
     local mode = vim.api.nvim_get_mode().mode
-    if not is_first_chunk then
+    if undo_started then
       vim.api.nvim_command('undojoin')
     end
     if mode:find('^i') or mode:find('^n?t') then  -- Insert mode or Terminal buffer
@@ -190,7 +199,6 @@ do
       local firstline = lines[1]
       firstline = bufline:sub(1, col)..firstline
       lines[1] = firstline
-      -- FIXME: #lines can be 0
       lines[#lines] = lines[#lines]..bufline:sub(col + nchars + 1, bufline:len())
       vim.api.nvim_buf_set_lines(0, row-1, row, false, lines)
     elseif mode:find('^[nvV\22sS\19]') then  -- Normal or Visual or Select mode
@@ -216,6 +224,7 @@ do
     else  -- Don't know what to do in other modes
       return false
     end
+    undo_started = true
     if phase ~= -1 and (now - tdots >= 100) then
       local dots = ('.'):rep(tick % 4)
       tdots = now
@@ -224,7 +233,7 @@ do
       -- message when there are zero dots.
       vim.api.nvim_command(('echo "%s"'):format(dots))
     end
-    if phase == -1 or phase == 3 then
+    if is_last_chunk then
       vim.api.nvim_command('redraw'..(tick > 1 and '|echo ""' or ''))
     end
     return true  -- Paste will not continue if not returning `true`.
-- 
cgit 


From a6eafc77ceaf2d7036aed89361b6556f46131b17 Mon Sep 17 00:00:00 2001
From: zeertzjq 
Date: Sun, 6 Mar 2022 06:56:24 +0800
Subject: fix(paste): deal with trailing new line in chunk

---
 runtime/lua/vim/_editor.lua | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

(limited to 'runtime')

diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua
index 42adda6e7f..26b9693189 100644
--- a/runtime/lua/vim/_editor.lua
+++ b/runtime/lua/vim/_editor.lua
@@ -128,7 +128,7 @@ local function inspect(object, options)  -- luacheck: no unused
 end
 
 do
-  local tdots, tick, got_line1, undo_started = 0, 0, false, false
+  local tdots, tick, got_line1, undo_started, trailing_nl = 0, 0, false, false, false
 
   --- Paste handler, invoked by |nvim_paste()| when a conforming UI
   --- (such as the |TUI|) pastes text into the editor.
@@ -160,7 +160,7 @@ do
     local is_first_chunk = phase < 2
     local is_last_chunk = phase == -1 or phase == 3
     if is_first_chunk then  -- Reset flags.
-      tdots, tick, got_line1, undo_started = now, 0, false, false
+      tdots, tick, got_line1, undo_started, trailing_nl = now, 0, false, false, false
     end
     if #lines == 0 then
       lines = {''}
@@ -203,7 +203,10 @@ do
       vim.api.nvim_buf_set_lines(0, row-1, row, false, lines)
     elseif mode:find('^[nvV\22sS\19]') then  -- Normal or Visual or Select mode
       if mode:find('^n') then  -- Normal mode
-        vim.api.nvim_put(lines, 'c', true, false)
+        -- When there was a trailing new line in the previous chunk,
+        -- the cursor is on the first character of the next line,
+        -- so paste before the cursor instead of after it.
+        vim.api.nvim_put(lines, 'c', not trailing_nl, false)
       else  -- Visual or Select mode
         vim.api.nvim_command([[exe "silent normal! \"]])
         local del_start = vim.fn.getpos("'[")
@@ -221,6 +224,7 @@ do
       end
       -- put cursor at the end of the text instead of one character after it
       vim.fn.setpos('.', vim.fn.getpos("']"))
+      trailing_nl = lines[#lines] == ''
     else  -- Don't know what to do in other modes
       return false
     end
-- 
cgit 


From e263afc0e972d11d3b9b663c3ac0b5575c4deb88 Mon Sep 17 00:00:00 2001
From: zeertzjq 
Date: Tue, 15 Mar 2022 06:04:50 +0800
Subject: fix(paste): escape control characters in Cmdline mode

---
 runtime/lua/vim/_editor.lua | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

(limited to 'runtime')

diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua
index 26b9693189..d4db4850bd 100644
--- a/runtime/lua/vim/_editor.lua
+++ b/runtime/lua/vim/_editor.lua
@@ -175,7 +175,8 @@ do
       if not got_line1 then
         got_line1 = (#lines > 1)
         vim.api.nvim_set_option('paste', true)  -- For nvim_input().
-        local line1 = lines[1]:gsub('<', ''):gsub('[\r\n\012\027]', ' ')  -- Scrub.
+        -- Escape "<" and control characters
+        local line1 = lines[1]:gsub('<', ''):gsub('(%c)', '\022%1')
         vim.api.nvim_input(line1)
         vim.api.nvim_set_option('paste', false)
       end
-- 
cgit 


From 5a8bf31d328ecdb79453bf1eb22ff10aabbe0422 Mon Sep 17 00:00:00 2001
From: Jade Lovelace 
Date: Tue, 15 Mar 2022 14:46:32 -0700
Subject: vim-patch:8.2.4571: not all gdb files are recognized (#17727)

Problem:    Not all gdb files are recognized.
Solution:   Add a few more patterns for gdb.
            (closes https://github.com/vim/vim/pull/9956)
https://github.com/vim/vim/commit/8d5e514d77bd4b1956656ad2be2ce7094bd43a72
---
 runtime/filetype.vim         | 2 +-
 runtime/lua/vim/filetype.lua | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

(limited to 'runtime')

diff --git a/runtime/filetype.vim b/runtime/filetype.vim
index 8114ad4092..9df89674e3 100644
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -664,7 +664,7 @@ au BufNewFile,BufRead *.fs			call dist#ft#FTfs()
 au BufNewFile,BufRead *.fsi,*.fsx		setf fsharp
 
 " GDB command files
-au BufNewFile,BufRead .gdbinit,gdbinit		setf gdb
+au BufNewFile,BufRead .gdbinit,gdbinit,.gdbearlyinit,gdbearlyinit,*.gdb		setf gdb
 
 " GDMO
 au BufNewFile,BufRead *.mo,*.gdmo		setf gdmo
diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua
index f5e4dabfb6..b356f5e3dc 100644
--- a/runtime/lua/vim/filetype.lua
+++ b/runtime/lua/vim/filetype.lua
@@ -225,6 +225,7 @@ local extension = {
   fsi = "fsharp",
   fsx = "fsharp",
   fusion = "fusion",
+  gdb = "gdb",
   gdmo = "gdmo",
   mo = "gdmo",
   tres = "gdresource",
@@ -919,6 +920,8 @@ local filename = {
   mtab = "fstab",
   [".gdbinit"] = "gdb",
   gdbinit = "gdb",
+  [".gdbearlyinit"] = "gdb",
+  gdbearlyinit = "gdb",
   ["lltxxxxx.txt"] = "gedcom",
   ["TAG_EDITMSG"] = "gitcommit",
   ["MERGE_MSG"] = "gitcommit",
-- 
cgit 


From 33ada232c7566bd303579683dd5b769fe705462b Mon Sep 17 00:00:00 2001
From: dundargoc <33953936+dundargoc@users.noreply.github.com>
Date: Wed, 16 Mar 2022 09:36:26 +0100
Subject: fix(checkhealth): make provider checkhealth output more consistent
 (#17722)

Change missing provider plugins from errors to warnings for python and
perl. Also give proper advice under the ADVICE section instead of just
the errors.
---
 runtime/autoload/health/provider.vim  | 18 ++++++++++++------
 runtime/autoload/provider/pythonx.vim |  4 ++--
 2 files changed, 14 insertions(+), 8 deletions(-)

(limited to 'runtime')

diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim
index 2f35179338..7325220aa4 100644
--- a/runtime/autoload/health/provider.vim
+++ b/runtime/autoload/health/provider.vim
@@ -312,7 +312,10 @@ function! s:check_python() abort
 
   " No Python executable could `import neovim`, or host_prog_var was used.
   if !empty(pythonx_errors)
-    call health#report_error('Python provider error:', pythonx_errors)
+    call health#report_warn(pythonx_errors, ["See :help provider-python for more information.", 
+          \ "You may disable this provider (and warning) by adding `let g:loaded_python3_provider = 0` to your init.vim"
+          \])
+"If you wish to disable the Python provider (and this warning), then "
 
   elseif !empty(pyname) && empty(python_exe)
     if !exists('g:'.host_prog_var)
@@ -573,7 +576,8 @@ function! s:check_ruby() abort
           \ ['Run `gem install neovim` to ensure the neovim RubyGem is installed.',
           \  'Run `gem environment` to ensure the gem bin directory is in $PATH.',
           \  'If you are using rvm/rbenv/chruby, try "rehashing".',
-          \  'See :help g:ruby_host_prog for non-standard gem installations.'])
+          \  'See :help g:ruby_host_prog for non-standard gem installations.',
+          \ "You may disable this provider (and warning) by adding `let g:loaded_ruby_provider = 0` to your init.vim"])
     return
   endif
   call health#report_info('Host: '. host)
@@ -634,7 +638,8 @@ function! s:check_node() abort
   if empty(host)
     call health#report_warn('Missing "neovim" npm (or yarn) package.',
           \ ['Run in shell: npm install -g neovim',
-          \  'Run in shell (if you use yarn): yarn global add neovim'])
+          \  'Run in shell (if you use yarn): yarn global add neovim',
+          \ "You may disable this provider (and warning) by adding `let g:loaded_node_provider = 0` to your init.vim"])
     return
   endif
   call health#report_info('Nvim node.js host: '. host)
@@ -683,10 +688,11 @@ function! s:check_perl() abort
     return
   endif
 
-  let [perl_exec, perl_errors] = provider#perl#Detect()
+  let [perl_exec, perl_warnings] = provider#perl#Detect()
   if empty(perl_exec)
-    if !empty(perl_errors)
-      call health#report_error('perl provider error:', perl_errors)
+    if !empty(perl_warnings)
+      call health#report_warn(perl_warnings,["See :help provider-perl for more information." ,
+            \ "You may disable this provider (and warning) by adding `let g:loaded_node_provider = 0` to your init.vim"])
 	else
       call health#report_warn('No usable perl executable found')
     endif
diff --git a/runtime/autoload/provider/pythonx.vim b/runtime/autoload/provider/pythonx.vim
index 5b299b322c..048f898e62 100644
--- a/runtime/autoload/provider/pythonx.vim
+++ b/runtime/autoload/provider/pythonx.vim
@@ -56,7 +56,7 @@ function! provider#pythonx#DetectByModule(module, major_version) abort
   endfor
 
   " No suitable Python executable found.
-  return ['', 'provider/pythonx: Could not load Python '.a:major_version.":\n".join(errors, "\n")]
+  return ['', 'Could not load Python '.a:major_version.":\n".join(errors, "\n")]
 endfunction
 
 " Returns array: [prog_exitcode, prog_version]
@@ -99,7 +99,7 @@ function! provider#pythonx#CheckForModule(prog, module, major_version) abort
   endif
 
   if prog_exitcode == 2
-    return [0, prog_path.' does not have the "' . a:module . '" module. :help provider-python']
+    return [0, prog_path.' does not have the "' . a:module . '" module.']
   elseif prog_exitcode == 127
     " This can happen with pyenv's shims.
     return [0, prog_path . ' does not exist: ' . prog_version]
-- 
cgit 


From fa79a016bc894d3f89eddc7744868d2dd5458d51 Mon Sep 17 00:00:00 2001
From: Sean Dewar 
Date: Wed, 16 Mar 2022 09:46:14 +0000
Subject: chore(checkhealth/provider): style fixes (#17738)

---
 runtime/autoload/health/provider.vim | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

(limited to 'runtime')

diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim
index 7325220aa4..6022e05c22 100644
--- a/runtime/autoload/health/provider.vim
+++ b/runtime/autoload/health/provider.vim
@@ -301,7 +301,7 @@ function! s:check_python() abort
     call health#report_info(printf('Using: g:%s = "%s"', host_prog_var, get(g:, host_prog_var)))
   endif
 
-  let [pyname, pythonx_errors] = provider#pythonx#Detect(3)
+  let [pyname, pythonx_warnings] = provider#pythonx#Detect(3)
 
   if empty(pyname)
     call health#report_warn('No Python executable found that can `import neovim`. '
@@ -311,11 +311,9 @@ function! s:check_python() abort
   endif
 
   " No Python executable could `import neovim`, or host_prog_var was used.
-  if !empty(pythonx_errors)
-    call health#report_warn(pythonx_errors, ["See :help provider-python for more information.", 
-          \ "You may disable this provider (and warning) by adding `let g:loaded_python3_provider = 0` to your init.vim"
-          \])
-"If you wish to disable the Python provider (and this warning), then "
+  if !empty(pythonx_warnings)
+    call health#report_warn(pythonx_warnings, ['See :help provider-python for more information.',
+          \ 'You may disable this provider (and warning) by adding `let g:loaded_python3_provider = 0` to your init.vim'])
 
   elseif !empty(pyname) && empty(python_exe)
     if !exists('g:'.host_prog_var)
@@ -577,7 +575,7 @@ function! s:check_ruby() abort
           \  'Run `gem environment` to ensure the gem bin directory is in $PATH.',
           \  'If you are using rvm/rbenv/chruby, try "rehashing".',
           \  'See :help g:ruby_host_prog for non-standard gem installations.',
-          \ "You may disable this provider (and warning) by adding `let g:loaded_ruby_provider = 0` to your init.vim"])
+          \  'You may disable this provider (and warning) by adding `let g:loaded_ruby_provider = 0` to your init.vim'])
     return
   endif
   call health#report_info('Host: '. host)
@@ -639,7 +637,7 @@ function! s:check_node() abort
     call health#report_warn('Missing "neovim" npm (or yarn) package.',
           \ ['Run in shell: npm install -g neovim',
           \  'Run in shell (if you use yarn): yarn global add neovim',
-          \ "You may disable this provider (and warning) by adding `let g:loaded_node_provider = 0` to your init.vim"])
+          \  'You may disable this provider (and warning) by adding `let g:loaded_node_provider = 0` to your init.vim'])
     return
   endif
   call health#report_info('Nvim node.js host: '. host)
@@ -691,12 +689,12 @@ function! s:check_perl() abort
   let [perl_exec, perl_warnings] = provider#perl#Detect()
   if empty(perl_exec)
     if !empty(perl_warnings)
-      call health#report_warn(perl_warnings,["See :help provider-perl for more information." ,
-            \ "You may disable this provider (and warning) by adding `let g:loaded_node_provider = 0` to your init.vim"])
-	else
+      call health#report_warn(perl_warnings, ['See :help provider-perl for more information.',
+            \ 'You may disable this provider (and warning) by adding `let g:loaded_node_provider = 0` to your init.vim'])
+    else
       call health#report_warn('No usable perl executable found')
     endif
-	return
+    return
   endif
 
   call health#report_info('perl executable: '. perl_exec)
-- 
cgit 


From d238b8f6003d34cae7f65ff7585b48a2cd9449fb Mon Sep 17 00:00:00 2001
From: dundargoc <33953936+dundargoc@users.noreply.github.com>
Date: Thu, 17 Mar 2022 06:21:24 +0100
Subject: chore: fix typos (#17670)

Co-authored-by: zeertzjq 
---
 runtime/doc/remote.txt     | 2 +-
 runtime/lua/vim/keymap.lua | 4 ++--
 runtime/lua/vim/lsp.lua    | 2 +-
 runtime/lua/vim/shared.lua | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

(limited to 'runtime')

diff --git a/runtime/doc/remote.txt b/runtime/doc/remote.txt
index b8991be738..0c1e3438de 100644
--- a/runtime/doc/remote.txt
+++ b/runtime/doc/remote.txt
@@ -86,7 +86,7 @@ You can not put options there!
 2. Missing functionality			*E5600* *clientserver-missing*
 
 Vim supports additional functionality in clientserver that's not yet
-implemented in Nvim. In particular, none of the 'wait' variants are supported
+implemented in Nvim. In particular, none of the "wait" variants are supported
 yet. The following command line arguments are not yet available:
 
     argument			meaning	~
diff --git a/runtime/lua/vim/keymap.lua b/runtime/lua/vim/keymap.lua
index 7f12372502..1be40b0081 100644
--- a/runtime/lua/vim/keymap.lua
+++ b/runtime/lua/vim/keymap.lua
@@ -25,8 +25,8 @@ local keymap = {}
 ---    vim.keymap.set('n', 'asdf', require('jkl').my_fun)
 --- 
--- ---- the `require('jkl')` gets evaluated during this call in order to access the function. If you want to ---- avoid this cost at startup you can wrap it in a function, for example: +--- the ``require('jkl')`` gets evaluated during this call in order to access the function. +--- If you want to avoid this cost at startup you can wrap it in a function, for example: ---
 ---    vim.keymap.set('n', 'asdf', function() return require('jkl').my_fun() end)
 --- 
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua index 8d11b4621c..105e7c4621 100644 --- a/runtime/lua/vim/lsp.lua +++ b/runtime/lua/vim/lsp.lua @@ -1689,7 +1689,7 @@ end --- --- Currently only supports a single client. This can be set via --- `setlocal formatexpr=v:lua.vim.lsp.formatexpr()` but will typically or in `on_attach` ---- via `vim.api.nvim_buf_set_option(bufnr, 'formatexpr', 'v:lua.vim.lsp.formatexpr(#{timeout_ms:250})')`. +--- via ``vim.api.nvim_buf_set_option(bufnr, 'formatexpr', 'v:lua.vim.lsp.formatexpr(#{timeout_ms:250})')``. --- ---@param opts table options for customizing the formatting expression which takes the --- following optional keys: diff --git a/runtime/lua/vim/shared.lua b/runtime/lua/vim/shared.lua index 8124b23eb1..3eb332279a 100644 --- a/runtime/lua/vim/shared.lua +++ b/runtime/lua/vim/shared.lua @@ -331,7 +331,7 @@ end --- Add the reverse lookup values to an existing table. --- For example: ---- `tbl_add_reverse_lookup { A = 1 } == { [1] = 'A', A = 1 }` +--- ``tbl_add_reverse_lookup { A = 1 } == { [1] = 'A', A = 1 }`` -- --Do note that it *modifies* the input. ---@param o table The table to add the reverse to. -- cgit From 5ab122917474b3f9e88be4ee88bc6d627980cfe0 Mon Sep 17 00:00:00 2001 From: Famiu Haque Date: Sun, 30 Jan 2022 11:57:41 +0600 Subject: feat: add support for global statusline Ref: #9342 Adds the option to have a single global statusline for the current window at the bottom of the screen instead of a statusline at the bottom of every window. Enabled by setting `laststatus = 3`. Due to the fact that statuslines at the bottom of windows are removed when global statusline is enabled, horizontal separators are used instead to separate horizontal splits. The horizontal separator character is configurable through the`horiz` item in `'fillchars'`. Separator connector characters are also used to connect the horizontal and vertical separators together, which are also configurable through the `horizup`, `horizdown`, `vertleft`, `vertright` and `verthoriz` items in `fillchars`. The window separators are highlighted using the `WinSeparator` highlight group, which supersedes `VertSplit` and is linked to `VertSplit` by default in order to maintain backwards compatibility. --- runtime/doc/arabic.txt | 2 +- runtime/doc/options.txt | 28 ++++++++++++++++++++++++---- runtime/doc/syntax.txt | 4 ++-- runtime/doc/usr_08.txt | 2 ++ runtime/doc/vim_diff.txt | 6 +++++- runtime/doc/windows.txt | 2 ++ 6 files changed, 36 insertions(+), 8 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/arabic.txt b/runtime/doc/arabic.txt index 5d3bf7a761..0df861111c 100644 --- a/runtime/doc/arabic.txt +++ b/runtime/doc/arabic.txt @@ -175,7 +175,7 @@ o Enable Arabic settings [short-cut] vertical separator like "l" or "𝖨" may be used. It may also be hidden by changing its color to the foreground color: > :set fillchars=vert:l - :hi VertSplit ctermbg=White + :hi WinSeparator ctermbg=White < Note that this is a workaround, not a proper solution. If, on the other hand, you'd like to be verbose and explicit and diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 6e2bc228d0..66048c2e5f 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -2441,7 +2441,14 @@ A jump table for the options with a short description can be found at |Q_op|. item default Used for ~ stl:c ' ' or '^' statusline of the current window stlnc:c ' ' or '=' statusline of the non-current windows + horiz:c '─' or '-' horizontal separators |:split| + horizup:c '┴' or '-' upwards facing horizontal separator + horizdown:c '┬' or '-' downwards facing horizontal separator vert:c '│' or '|' vertical separators |:vsplit| + vertleft:c '┤' or '|' left facing vertical separator + vertright:c '├' or '|' right facing vertical separator + verthoriz:c '┼' or '+' overlapping vertical and horizontal + separator fold:c '·' or '-' filling 'foldtext' foldopen:c '-' mark the beginning of a fold foldclose:c '+' show a closed fold @@ -2454,8 +2461,13 @@ A jump table for the options with a short description can be found at |Q_op|. "stlnc" the space will be used when there is highlighting, '^' or '=' otherwise. - If 'ambiwidth' is "double" then "vert", "foldsep" and "fold" default to - single-byte alternatives. + Note that "horiz", "horizup", "horizdown", "vertleft", "vertright" and + "verthoriz" are only used when 'laststatus' is 3, since only vertical + window separators are used otherwise. + + If 'ambiwidth' is "double" then "horiz", "horizup", "horizdown", + "vert", "vertleft", "vertright", "verthoriz", "foldsep" and "fold" + default to single-byte alternatives. Example: > :set fillchars=stl:^,stlnc:=,vert:│,fold:·,diff:- @@ -2469,7 +2481,13 @@ A jump table for the options with a short description can be found at |Q_op|. item highlight group ~ stl:c StatusLine |hl-StatusLine| stlnc:c StatusLineNC |hl-StatusLineNC| - vert:c VertSplit |hl-VertSplit| + horiz:c WinSeparator |hl-WinSeparator| + horizup:c WinSeparator |hl-WinSeparator| + horizdown:c WinSeparator |hl-WinSeparator| + vert:c WinSeparator |hl-WinSeparator| + vertleft:c WinSeparator |hl-WinSeparator| + vertright:c WinSeparator |hl-WinSeparator| + verthoriz:c WinSeparator |hl-WinSeparator| fold:c Folded |hl-Folded| diff:c DiffDelete |hl-DiffDelete| eob:c EndOfBuffer |hl-EndOfBuffer| @@ -3652,6 +3670,8 @@ A jump table for the options with a short description can be found at |Q_op|. 0: never 1: only if there are at least two windows 2: always + 3: have a global statusline at the bottom instead of one for + each window The screen looks nicer with a status line if you have several windows, but it takes another screen line. |status-line| @@ -5929,7 +5949,7 @@ A jump table for the options with a short description can be found at |Q_op|. empty to avoid further errors. Otherwise screen updating would loop. Note that the only effect of 'ruler' when this option is set (and - 'laststatus' is 2) is controlling the output of |CTRL-G|. + 'laststatus' is 2 or 3) is controlling the output of |CTRL-G|. field meaning ~ - Left justify the item. The default is right justified diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt index 319a715e40..5446bd3a88 100644 --- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -5105,8 +5105,8 @@ TermCursor cursor in a focused terminal TermCursorNC cursor in an unfocused terminal *hl-ErrorMsg* ErrorMsg error messages on the command line - *hl-VertSplit* -VertSplit the column separating vertically split windows + *hl-WinSeparator* +WinSeparator separators between window splits *hl-Folded* Folded line used for closed folds *hl-FoldColumn* diff --git a/runtime/doc/usr_08.txt b/runtime/doc/usr_08.txt index 8ccaa73006..1d20913a14 100644 --- a/runtime/doc/usr_08.txt +++ b/runtime/doc/usr_08.txt @@ -482,6 +482,8 @@ statusline: 0 never 1 only when there are split windows (the default) 2 always + 3 have a global statusline at the bottom instead of one for each + window Many commands that edit another file have a variant that splits the window. For Command-line commands this is done by prepending an "s". For example: diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index 7892b82137..69b0e0081a 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -211,6 +211,7 @@ Highlight groups: |hl-Substitute| |hl-TermCursor| |hl-TermCursorNC| + |hl-WinSeparator| highlights window separators |hl-Whitespace| highlights 'listchars' whitespace Input/Mappings: @@ -227,9 +228,11 @@ Options: 'cpoptions' flags: |cpo-_| 'display' flags: "msgsep" minimizes scrolling when showing messages 'guicursor' works in the terminal - 'fillchars' flags: "msgsep" (see 'display') + 'fillchars' flags: "msgsep" (see 'display'), "horiz", "horizup", + "horizdown", "vertleft", "vertright", "verthoriz" 'foldcolumn' supports up to 9 dynamic/fixed columns 'inccommand' shows interactive results for |:substitute|-like commands + 'laststatus' global statusline support 'pumblend' pseudo-transparent popupmenu 'scrollback' 'signcolumn' supports up to 9 dynamic/fixed columns @@ -348,6 +351,7 @@ Highlight groups: |hl-ColorColumn|, |hl-CursorColumn| are lower priority than most other groups |hl-CursorLine| is low-priority unless foreground color is set + *hl-VertSplit* superseded by |hl-WinSeparator| Macro/|recording| behavior Replay of a macro recorded during :lmap produces the same actions as when it diff --git a/runtime/doc/windows.txt b/runtime/doc/windows.txt index 5b91321c40..f8a8a557ef 100644 --- a/runtime/doc/windows.txt +++ b/runtime/doc/windows.txt @@ -104,6 +104,8 @@ when the last window also has a status line: 'laststatus' = 0 never a status line 'laststatus' = 1 status line if there is more than one window 'laststatus' = 2 always a status line + 'laststatus' = 3 have a global statusline at the bottom instead + of one for each window You can change the contents of the status line with the 'statusline' option. This option can be local to the window, so that you can have a different -- cgit From f2e5f509d995b291e4b9e05a0c059e83490a18e1 Mon Sep 17 00:00:00 2001 From: Xiretza Date: Fri, 18 Mar 2022 19:58:00 +0100 Subject: docs: reword description for nvim_buf_line_count() (#17766) This adds a few more keywords to make the function easier to find. --- runtime/doc/api.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index 4af13a3bbf..dbf87bfd9f 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -2215,7 +2215,7 @@ nvim_buf_is_valid({buffer}) *nvim_buf_is_valid()* true if the buffer is valid, false otherwise. nvim_buf_line_count({buffer}) *nvim_buf_line_count()* - Gets the buffer line count + Returns the number of lines in the given buffer. Parameters: ~ {buffer} Buffer handle, or 0 for current buffer -- cgit From 75157d2572248c330858586fa23649e7acf33416 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sun, 20 Mar 2022 10:48:10 +0100 Subject: vim-patch:47c532e2bc55 (#17780) Update runtime files https://github.com/vim/vim/commit/47c532e2bc55e8a48f7f47e1fae1ed30144f2fa1 --- runtime/doc/builtin.txt | 2 +- runtime/doc/ft_ada.txt | 24 +++++++++++----------- runtime/doc/insert.txt | 20 ++++++++++++------ runtime/doc/options.txt | 7 ++++--- runtime/doc/syntax.txt | 5 +++-- runtime/doc/tagsrch.txt | 3 ++- runtime/doc/usr_29.txt | 19 +++++++++-------- runtime/ftplugin/liquid.vim | 4 ++-- runtime/ftplugin/php.vim | 3 ++- runtime/indent/bst.vim | 6 ++---- runtime/indent/haml.vim | 4 +++- runtime/indent/liquid.vim | 23 ++++++++++++--------- runtime/indent/sass.vim | 4 +++- .../pack/dist/opt/termdebug/plugin/termdebug.vim | 11 +++++----- runtime/syntax/c.vim | 17 +++++++-------- runtime/syntax/liquid.vim | 24 +++++++++++----------- runtime/syntax/sass.vim | 3 ++- 17 files changed, 101 insertions(+), 78 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 9eec23b7b7..14353662d1 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -8152,7 +8152,7 @@ taglist({expr} [, {filename}]) *taglist()* entry depends on the language specific kind values. Only available when using a tags file generated by - Exuberant ctags or hdrtag. + Universal/Exuberant ctags or hdrtag. static A file specific tag. Refer to |static-tag| for more information. More entries may be present, depending on the content of the diff --git a/runtime/doc/ft_ada.txt b/runtime/doc/ft_ada.txt index 771ccc3302..f6dfa708fb 100644 --- a/runtime/doc/ft_ada.txt +++ b/runtime/doc/ft_ada.txt @@ -89,9 +89,9 @@ file is opened and adds Ada related entries to the main and pop-up menu. *ft-ada-omni* The Ada omni-completions (|i_CTRL-X_CTRL-O|) uses tags database created either -by "gnat xref -v" or the "exuberant Ctags (http://ctags.sourceforge.net). The -complete function will automatically detect which tool was used to create the -tags file. +by "gnat xref -v" or the "Universal Ctags" (https://ctags.io). The complete +function will automatically detect which tool was used to create the tags +file. ------------------------------------------------------------------------------ 3.1 Omni Completion with "gnat xref" ~ @@ -125,18 +125,18 @@ NOTE: "gnat xref -v" is very tricky to use as it has almost no diagnostic 3.2 Omni Completion with "ctags"~ *ada-ctags* -Exuberant Ctags uses its own multi-language code parser. The parser is quite -fast, produces a lot of extra information (hence the name "Exuberant Ctags") -and can run on files which currently do not compile. +Universal/Exuberant Ctags use their own multi-language code parser. The +parser is quite fast, produces a lot of extra information and can run on files +which currently do not compile. -There are also lots of other Vim-tools which use exuberant Ctags. +There are also lots of other Vim-tools which use Universal/Exuberant Ctags. +Universal Ctags is preferred, Exuberant Ctags is no longer being developed. -You will need to install a version of the Exuberant Ctags which has Ada -support patched in. Such a version is available from the GNU Ada Project -(http://gnuada.sourceforge.net). +You will need to install Universal Ctags which is available from +https://ctags.io -The Ada parser for Exuberant Ctags is fairly new - don't expect complete -support yet. +The Ada parser for Universal/Exuberant Ctags is fairly new - don't expect +complete support yet. ============================================================================== 4. Compiler Support ~ diff --git a/runtime/doc/insert.txt b/runtime/doc/insert.txt index d9aecfe4fd..cd6c2c8622 100644 --- a/runtime/doc/insert.txt +++ b/runtime/doc/insert.txt @@ -1342,11 +1342,16 @@ in 'runtimepath'. Thus for "java" it is autoload/javacomplete.vim. C *ft-c-omni* -Completion of C code requires a tags file. You should use Exuberant ctags, -because it adds extra information that is needed for completion. You can find -it here: http://ctags.sourceforge.net/ Version 5.6 or later is recommended. +Completion of C code requires a tags file. You should use Universal/ +Exuberant ctags, because it adds extra information that is needed for +completion. You can find it here: + Universal Ctags: https://ctags.io + Exuberant Ctags: http://ctags.sourceforge.net -For version 5.5.4 you should add a patch that adds the "typename:" field: +Universal Ctags is preferred, Exuberant Ctags is no longer being developed. + +For Exuberant ctags, version 5.6 or later is recommended. For version 5.5.4 +you should add a patch that adds the "typename:" field: ftp://ftp.vim.org/pub/vim/unstable/patches/ctags-5.5.4.patch A compiled .exe for MS-Windows can be found at: http://ctags.sourceforge.net/ @@ -1467,8 +1472,11 @@ will be suggested. All other elements are not placed in suggestion list. PHP *ft-php-omni* Completion of PHP code requires a tags file for completion of data from -external files and for class aware completion. You should use Exuberant ctags -version 5.5.4 or newer. You can find it here: http://ctags.sourceforge.net/ +external files and for class aware completion. You should use Universal/ +Exuberant ctags version 5.5.4 or newer. You can find it here: + + Universal Ctags: https://ctags.io + Exuberant Ctags: http://ctags.sourceforge.net Script completes: diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index b2bbf5ddad..8323ec3e9d 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -6333,9 +6333,10 @@ A jump table for the options with a short description can be found at |Q_op|. linear search can be avoided when case is ignored. Use a value of '2' in the "!_TAG_FILE_SORTED" line for this. A tag file can be case-fold sorted with the -f switch to "sort" in most unices, as in the command: - "sort -f -o tags tags". For "Exuberant ctags" version 5.x or higher - (at least 5.5) the --sort=foldcase switch can be used for this as - well. Note that case must be folded to uppercase for this to work. + "sort -f -o tags tags". For Universal ctags and Exuberant ctags + version 5.x or higher (at least 5.5) the --sort=foldcase switch can be + used for this as well. Note that case must be folded to uppercase for + this to work. By default, tag searches are case-sensitive. Case is ignored when 'ignorecase' is set and 'tagcase' is "followic", or when 'tagcase' is diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt index 0ff31e81ab..2af4ec1549 100644 --- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -5363,11 +5363,12 @@ WARNING: The longer the tags file, the slower this will be, and the more memory Vim will consume. Only highlighting typedefs, unions and structs can be done too. For this you -must use Exuberant ctags (found at http://ctags.sf.net). +must use Universal Ctags (found at https://ctags.io) or Exuberant ctags (found +at http://ctags.sf.net). Put these lines in your Makefile: -# Make a highlight file for types. Requires Exuberant ctags and awk +# Make a highlight file for types. Requires Universal/Exuberant ctags and awk types: types.vim types.vim: *.[ch] ctags --c-kinds=gstu -o- *.[ch] |\ diff --git a/runtime/doc/tagsrch.txt b/runtime/doc/tagsrch.txt index 5a0d16d6b8..2485290667 100644 --- a/runtime/doc/tagsrch.txt +++ b/runtime/doc/tagsrch.txt @@ -544,7 +544,8 @@ also works. The and characters can never appear inside a line. The second format is new. It includes additional information in optional fields at the end of each line. It is backwards compatible with Vi. It is -only supported by new versions of ctags (such as Exuberant ctags). +only supported by new versions of ctags (such as Universal ctags or Exuberant +ctags). {tagname} The identifier. Normally the name of a function, but it can be any identifier. It cannot contain a . diff --git a/runtime/doc/usr_29.txt b/runtime/doc/usr_29.txt index 3381d1870c..d8c556c281 100644 --- a/runtime/doc/usr_29.txt +++ b/runtime/doc/usr_29.txt @@ -33,10 +33,12 @@ following command: > ctags *.c "ctags" is a separate program. Most Unix systems already have it installed. -If you do not have it yet, you can find Exuberant ctags here: - +If you do not have it yet, you can find Universal/Exuberant ctags at: + http://ctags.io ~ http://ctags.sf.net ~ +Universal ctags is preferred, Exuberant ctags is no longer being developed. + Now when you are in Vim and you want to go to a function definition, you can jump to it by using the following command: > @@ -142,15 +144,15 @@ ONE TAGS FILE When Vim has to search many places for tags files, you can hear the disk rattling. It may get a bit slow. In that case it's better to spend this time while generating one big tags file. You might do this overnight. - This requires the Exuberant ctags program, mentioned above. It offers an -argument to search a whole directory tree: > + This requires the Universal or Exuberant ctags program, mentioned above. +It offers an argument to search a whole directory tree: > cd ~/proj ctags -R . -The nice thing about this is that Exuberant ctags recognizes various file -types. Thus this doesn't work just for C and C++ programs, also for Eiffel -and even Vim scripts. See the ctags documentation to tune this. +The nice thing about this is that Universal/Exuberant ctags recognizes various +file types. Thus this doesn't work just for C and C++ programs, also for +Eiffel and even Vim scripts. See the ctags documentation to tune this. Now you only need to tell Vim where your big tags file is: > :set tags=~/proj/tags @@ -232,7 +234,8 @@ A TAGS BROWSER Since CTRL-] takes you to the definition of the identifier under the cursor, you can use a list of identifier names as a table of contents. Here is an example. - First create a list of identifiers (this requires Exuberant ctags): > + First create a list of identifiers (this requires Universal or Exuberant +ctags): > ctags --c-types=f -f functions *.c diff --git a/runtime/ftplugin/liquid.vim b/runtime/ftplugin/liquid.vim index b211a884c6..f24ec4cbb2 100644 --- a/runtime/ftplugin/liquid.vim +++ b/runtime/ftplugin/liquid.vim @@ -1,7 +1,7 @@ " Vim filetype plugin " Language: Liquid " Maintainer: Tim Pope -" Last Change: 2010 May 21 +" Last Change: 2022 Mar 15 if exists('b:did_ftplugin') finish @@ -53,7 +53,7 @@ if has('gui_win32') endif if exists('loaded_matchit') - let b:match_words .= '\<\%(if\w*\|unless\|case\)\>:\<\%(elsif\|else\|when\)\>:\,\<\%(for\|tablerow\)\>:\%({%\s*\)\@<=empty\>:\,<\(capture\|comment\|highlight\)\>:\' + let b:match_words .= '\<\%(if\w*\|unless\|case\)\>:\<\%(elsif\|else\|when\)\>:\,\<\%(for\|tablerow\)\>:\%({%\s*\)\@<=empty\>:\,\<\(capture\|comment\|highlight\)\>:\' endif setlocal commentstring={%\ comment\ %}%s{%\ endcomment\ %} diff --git a/runtime/ftplugin/php.vim b/runtime/ftplugin/php.vim index 3ff0828ffe..2824a5853b 100644 --- a/runtime/ftplugin/php.vim +++ b/runtime/ftplugin/php.vim @@ -73,10 +73,11 @@ exe 'nno ]] /' . escape(s:section, '|') . '/:nohls' exe 'ono [[ ?' . escape(s:section, '|') . '?:nohls' exe 'ono ]] /' . escape(s:section, '|') . '/:nohls' +setlocal suffixesadd=.php setlocal commentstring=/*%s*/ " Undo the stuff we changed. -let b:undo_ftplugin = "setlocal commentstring< include< omnifunc<" . +let b:undo_ftplugin = "setlocal suffixesadd< commentstring< include< omnifunc<" . \ " | unlet! b:browsefilter b:match_words | " . \ s:undo_ftplugin diff --git a/runtime/indent/bst.vim b/runtime/indent/bst.vim index 47e3058810..3dd8d711a8 100644 --- a/runtime/indent/bst.vim +++ b/runtime/indent/bst.vim @@ -1,20 +1,18 @@ " Vim indent file " Language: bst " Author: Tim Pope -" $Id: bst.vim,v 1.1 2007/05/05 18:11:12 vimboss Exp $ +" Last Change: 2022 Mar 15 if exists("b:did_indent") finish endif let b:did_indent = 1 -setlocal expandtab setlocal indentexpr=GetBstIndent(v:lnum) -"setlocal smartindent setlocal cinkeys& setlocal cinkeys-=0# setlocal indentkeys& -"setlocal indentkeys+=0% +let b:undo_indent = 'setlocal indentexpr< cinkeys< indentkeys<' " Only define the function once. if exists("*GetBstIndent") diff --git a/runtime/indent/haml.vim b/runtime/indent/haml.vim index baca1d49d9..acd99d9c7d 100644 --- a/runtime/indent/haml.vim +++ b/runtime/indent/haml.vim @@ -1,7 +1,7 @@ " Vim indent file " Language: Haml " Maintainer: Tim Pope -" Last Change: 2019 Dec 05 +" Last Change: 2022 Mar 15 if exists("b:did_indent") finish @@ -14,6 +14,8 @@ setlocal autoindent setlocal indentexpr=GetHamlIndent() setlocal indentkeys=o,O,*,},],0),!^F,=end,=else,=elsif,=rescue,=ensure,=when +let b:undo_indent = "setl ai< inde< indk<" + " Only define the function once. if exists("*GetHamlIndent") finish diff --git a/runtime/indent/liquid.vim b/runtime/indent/liquid.vim index 7beb0388d1..6fc933797e 100644 --- a/runtime/indent/liquid.vim +++ b/runtime/indent/liquid.vim @@ -1,7 +1,7 @@ " Vim indent file " Language: Liquid " Maintainer: Tim Pope -" Last Change: 2017 Jun 13 +" Last Change: 2022 Mar 15 if exists('b:did_indent') finish @@ -29,17 +29,19 @@ let b:did_indent = 1 setlocal indentexpr=GetLiquidIndent() setlocal indentkeys=o,O,*,<>>,{,},0),0],o,O,!^F,=end,=endif,=endunless,=endifchanged,=endcase,=endfor,=endtablerow,=endcapture,=else,=elsif,=when,=empty +let b:undo_indent = "setl inde< indk<" + " Only define the function once. if exists('*GetLiquidIndent') finish endif -function! s:count(string,pattern) +function! s:count(string, pattern) abort let string = substitute(a:string,'\C'.a:pattern,"\n",'g') return strlen(substitute(string,"[^\n]",'','g')) endfunction -function! GetLiquidIndent(...) +function! GetLiquidIndent(...) abort if a:0 && a:1 == '.' let v:lnum = line('.') elseif a:0 && a:1 =~ '^\d' @@ -51,13 +53,14 @@ function! GetLiquidIndent(...) let lnum = prevnonblank(v:lnum-1) let line = getline(lnum) let cline = getline(v:lnum) - let line = substitute(line,'\C^\%(\s*{%\s*end\w*\s*%}\)\+','','') - let line .= matchstr(cline,'\C^\%(\s*{%\s*end\w*\s*%}\)\+') - let cline = substitute(cline,'\C^\%(\s*{%\s*end\w*\s*%}\)\+','','') + let line = substitute(line,'\C^\%(\s*{%-\=\s*end\w*\s*-\=%}\)\+','','') + let line = substitute(line,'\C\%(\s*{%-\=\s*if.\+-\=%}.\+{%-\=\s*endif\s*-\=%}\)\+','','g') + let line .= matchstr(cline,'\C^\%(\s*{%-\=\s*end\w*\s*-\=%}\)\+') + let cline = substitute(cline,'\C^\%(\s*{%-\=\s*end\w*\s*-\=%}\)\+','','') let sw = shiftwidth() - let ind += sw * s:count(line,'{%\s*\%(if\|elsif\|else\|unless\|ifchanged\|case\|when\|for\|empty\|tablerow\|capture\)\>') - let ind -= sw * s:count(line,'{%\s*end\%(if\|unless\|ifchanged\|case\|for\|tablerow\|capture\)\>') - let ind -= sw * s:count(cline,'{%\s*\%(elsif\|else\|when\|empty\)\>') - let ind -= sw * s:count(cline,'{%\s*end\w*$') + let ind += sw * s:count(line,'{%-\=\s*\%(if\|elsif\|else\|unless\|ifchanged\|case\|when\|for\|empty\|tablerow\|capture\)\>') + let ind -= sw * s:count(line,'{%-\=\s*end\%(if\|unless\|ifchanged\|case\|for\|tablerow\|capture\)\>') + let ind -= sw * s:count(cline,'{%-\=\s*\%(elsif\|else\|when\|empty\)\>') + let ind -= sw * s:count(cline,'{%-\=\s*end\w*$') return ind endfunction diff --git a/runtime/indent/sass.vim b/runtime/indent/sass.vim index d6dbf3a8bb..8c0ecd0746 100644 --- a/runtime/indent/sass.vim +++ b/runtime/indent/sass.vim @@ -1,7 +1,7 @@ " Vim indent file " Language: Sass " Maintainer: Tim Pope -" Last Change: 2017 Jun 13 +" Last Change: 2022 Mar 15 if exists("b:did_indent") finish @@ -12,6 +12,8 @@ setlocal autoindent sw=2 et setlocal indentexpr=GetSassIndent() setlocal indentkeys=o,O,*,<:>,!^F +let b:undo_indent = "setl ai< inde< indk<" + " Only define the function once. if exists("*GetSassIndent") finish diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index 49d9389773..63aba72f0d 100644 --- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim +++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @@ -4,10 +4,11 @@ " Copyright: Vim license applies, see ":help license" " Last Change: 2022 Jan 17 " -" WORK IN PROGRESS - Only the basics work -" Note: On MS-Windows you need a recent version of gdb. The one included with -" MingW is too old (7.6.1). -" I used version 7.12 from http://www.equation.com/servlet/equation.cmd?fa=gdb +" WORK IN PROGRESS - The basics works stable, more to come +" Note: In general you need at least GDB 7.12 because this provides the +" frame= response in MI thread-selected events we need to sync stack to file. +" The one included with "old" MingW is too old (7.6.1), you may upgrade it or +" use a newer version from http://www.equation.com/servlet/equation.cmd?fa=gdb " " There are two ways to run gdb: " - In a terminal window; used if possible, does not work on MS-Windows @@ -1026,7 +1027,7 @@ func s:Evaluate(range, arg) call s:SendEval(expr) endfunc -" get what is specified / under the cursor +" get what is specified / under the cursor func s:GetEvaluationExpression(range, arg) if a:arg != '' " user supplied evaluation diff --git a/runtime/syntax/c.vim b/runtime/syntax/c.vim index e86e1b8669..2dc21f0b6a 100644 --- a/runtime/syntax/c.vim +++ b/runtime/syntax/c.vim @@ -1,7 +1,7 @@ " Vim syntax file " Language: C " Maintainer: Bram Moolenaar -" Last Change: 2021 Dec 07 +" Last Change: 2022 Mar 17 " Quit when a (custom) syntax file was already loaded if exists("b:current_syntax") @@ -245,8 +245,14 @@ syn match cWrongComTail display "\*/" syn keyword cOperator sizeof if exists("c_gnu") + syn keyword cType __label__ __complex__ syn keyword cStatement __asm__ - syn keyword cOperator typeof __real__ __imag__ + syn keyword cOperator __alignof__ + syn keyword cOperator typeof __typeof__ + syn keyword cOperator __real__ __imag__ + syn keyword cStorageClass __attribute__ __const__ __extension__ + syn keyword cStorageClass inline __inline__ + syn keyword cStorageClass __restrict__ __volatile__ __noreturn__ endif syn keyword cType int long short char void syn keyword cType signed unsigned float double @@ -270,16 +276,10 @@ if !exists("c_no_c99") " ISO C99 syn keyword cType intptr_t uintptr_t syn keyword cType intmax_t uintmax_t endif -if exists("c_gnu") - syn keyword cType __label__ __complex__ __volatile__ -endif syn keyword cTypedef typedef syn keyword cStructure struct union enum syn keyword cStorageClass static register auto volatile extern const -if exists("c_gnu") - syn keyword cStorageClass inline __attribute__ -endif if !exists("c_no_c99") && !s:in_cpp_family syn keyword cStorageClass inline restrict endif @@ -292,6 +292,7 @@ if !exists("c_no_c11") syn keyword cOperator _Static_assert static_assert syn keyword cStorageClass _Thread_local thread_local syn keyword cType char16_t char32_t + syn keyword cType max_align_t " C11 atomics (take down the shield wall!) syn keyword cType atomic_bool atomic_char atomic_schar atomic_uchar syn keyword Ctype atomic_short atomic_ushort atomic_int atomic_uint diff --git a/runtime/syntax/liquid.vim b/runtime/syntax/liquid.vim index 295a91775e..966b60f6f8 100644 --- a/runtime/syntax/liquid.vim +++ b/runtime/syntax/liquid.vim @@ -2,7 +2,7 @@ " Language: Liquid " Maintainer: Tim Pope " Filenames: *.liquid -" Last Change: 2013 May 30 +" Last Change: 2022 Mar 15 if exists('b:current_syntax') finish @@ -68,10 +68,10 @@ if !exists('s:subtype') unlet s:subtype endif -syn region liquidStatement matchgroup=liquidDelimiter start="{%" end="%}" contains=@liquidStatement containedin=ALLBUT,@liquidExempt keepend -syn region liquidExpression matchgroup=liquidDelimiter start="{{" end="}}" contains=@liquidExpression containedin=ALLBUT,@liquidExempt keepend -syn region liquidComment matchgroup=liquidDelimiter start="{%\s*comment\s*%}" end="{%\s*endcomment\s*%}" contains=liquidTodo,@Spell containedin=ALLBUT,@liquidExempt keepend -syn region liquidRaw matchgroup=liquidDelimiter start="{%\s*raw\s*%}" end="{%\s*endraw\s*%}" contains=TOP,@liquidExempt containedin=ALLBUT,@liquidExempt keepend +syn region liquidStatement matchgroup=liquidDelimiter start="{%-\=" end="-\=%}" contains=@liquidStatement containedin=ALLBUT,@liquidExempt keepend +syn region liquidExpression matchgroup=liquidDelimiter start="{{-\=" end="-\=}}" contains=@liquidExpression containedin=ALLBUT,@liquidExempt keepend +syn region liquidComment matchgroup=liquidDelimiter start="{%-\=\s*comment\s*-\=%}" end="{%-\=\s*endcomment\s*-\=%}" contains=liquidTodo,@Spell containedin=ALLBUT,@liquidExempt keepend +syn region liquidRaw matchgroup=liquidDelimiter start="{%-\=\s*raw\s*-\=%}" end="{%-\=\s*endraw\s*-\=%}" contains=TOP,@liquidExempt containedin=ALLBUT,@liquidExempt keepend syn cluster liquidExempt contains=liquidStatement,liquidExpression,liquidComment,liquidRaw,@liquidStatement,liquidYamlHead syn cluster liquidStatement contains=liquidConditional,liquidRepeat,liquidKeyword,@liquidExpression @@ -79,11 +79,11 @@ syn cluster liquidExpression contains=liquidOperator,liquidString,liquidNumber,l syn keyword liquidKeyword highlight nextgroup=liquidTypeHighlight skipwhite contained syn keyword liquidKeyword endhighlight contained -syn region liquidHighlight start="{%\s*highlight\s\+\w\+\s*%}" end="{% endhighlight %}" keepend +syn region liquidHighlight start="{%-\=\s*highlight\s\+\w\+\s*-\=%}" end="{%-\= endhighlight -\=%}" keepend for s:type in g:liquid_highlight_types exe 'syn match liquidTypeHighlight "\<'.matchstr(s:type,'[^=]*').'\>" contained' - exe 'syn region liquidHighlight'.substitute(matchstr(s:type,'[^=]*$'),'\..*','','').' start="{%\s*highlight\s\+'.matchstr(s:type,'[^=]*').'\s*%}" end="{% endhighlight %}" keepend contains=@liquidHighlight'.substitute(matchstr(s:type,'[^=]*$'),'\.','','g') + exe 'syn region liquidHighlight'.substitute(matchstr(s:type,'[^=]*$'),'\..*','','').' start="{%-\=\s*highlight\s\+'.matchstr(s:type,'[^=]*').'\s*-\=%}" end="{%-\= endhighlight -\=%}" keepend contains=@liquidHighlight'.substitute(matchstr(s:type,'[^=]*$'),'\.','','g') endfor unlet! s:type @@ -92,18 +92,18 @@ syn region liquidString matchgroup=liquidQuote start=+'+ end=+'+ contained syn match liquidNumber "-\=\<\d\+\>" contained syn match liquidFloat "-\=\<\d\+\>\.\.\@!\%(\d\+\>\)\=" contained syn keyword liquidBoolean true false contained -syn keyword liquidNull null nil contained +syn keyword liquidNull null nil blank contained syn match liquidEmpty "\" contained syn keyword liquidOperator and or not contained syn match liquidPipe '|' contained skipwhite nextgroup=liquidFilter -syn keyword liquidFilter date capitalize downcase upcase first last join sort size strip_html strip_newlines newline_to_br replace replace_first remove remove_first truncate truncatewords prepend append minus plus times divided_by contained +syn keyword liquidFilter date capitalize downcase upcase escape escape_once first last join sort size where uniq strip_html strip_newlines newline_to_br replace replace_first remove remove_first slice split strip truncate truncatewords prepend append url_encode url_decode abs at_most at_least ceil divided_by floor minus plus round times modulo contained syn keyword liquidConditional if elsif else endif unless endunless case when endcase ifchanged endifchanged contained -syn keyword liquidRepeat for endfor tablerow endtablerow in contained -syn match liquidRepeat "\%({%\s*\)\@<=empty\>" contained -syn keyword liquidKeyword assign cycle include with contained +syn keyword liquidRepeat for endfor tablerow endtablerow in break continue limit offset reversed contained +syn match liquidRepeat "\%({%-\=\s*\)\@<=empty\>" contained +syn keyword liquidKeyword assign capture endcapture increasement decreasement cycle include with render contained syn keyword liquidForloop forloop nextgroup=liquidForloopDot contained syn match liquidForloopDot "\." nextgroup=liquidForloopAttribute contained diff --git a/runtime/syntax/sass.vim b/runtime/syntax/sass.vim index b51a0ae26b..8f41aba4f7 100644 --- a/runtime/syntax/sass.vim +++ b/runtime/syntax/sass.vim @@ -2,7 +2,7 @@ " Language: Sass " Maintainer: Tim Pope " Filenames: *.sass -" Last Change: 2019 Dec 05 +" Last Change: 2022 Mar 15 if exists("b:current_syntax") finish @@ -58,6 +58,7 @@ syn match sassAmpersand "&" " TODO: Arithmetic (including strings and concatenation) syn region sassMediaQuery matchgroup=sassMedia start="@media" end="[{};]\@=\|$" contains=sassMediaOperators +syn region sassKeyframe matchgroup=cssAtKeyword start=/@\(-[a-z]\+-\)\=keyframes\>/ end=";\|$" contains=cssVendor,cssComment nextgroup=cssDefinition syn keyword sassMediaOperators and not only contained syn region sassCharset start="@charset" end=";\|$" contains=scssComment,cssStringQ,cssStringQQ,cssURL,cssUnicodeEscape,cssMediaType syn region sassInclude start="@import" end=";\|$" contains=scssComment,cssStringQ,cssStringQQ,cssURL,cssUnicodeEscape,cssMediaType -- cgit From 315858bf67599d39c38628cd2ab8bff1074d7fe4 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Sun, 20 Mar 2022 10:10:01 +0000 Subject: fix(termdebug): handle exiting during startup properly (#16790) s:EndTermDebug should only be called when exiting if the debugger started without error, otherwise the plugin breaks. Vim handles this by using job_setoptions to set the on_exit callback to s:EndTermDebug after startup succeeds. However, Nvim does not have such functionality; instead; use s:starting to mimic this behaviour. Also, introduce s:running to fix s:CheckGdbRunning; it did not work correctly due to the "[Process exited X]" message keeping the job's channel alive (though the stream is closed). This means nvim_get_chan_info cannot be used to check if the debugger has exited, as it may still return a non-empty dict. --- runtime/pack/dist/opt/termdebug/plugin/termdebug.vim | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index 63aba72f0d..71456e788d 100644 --- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim +++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @@ -197,7 +197,7 @@ func s:CloseBuffers() endfunc func s:CheckGdbRunning() - if nvim_get_chan_info(s:gdb_job_id) == {} + if !s:running echoerr string(s:GetCommand()[0]) . ' exited unexpectedly' call s:CloseBuffers() return '' @@ -280,6 +280,8 @@ func s:StartDebug_term(dict) call s:CloseBuffers() return endif + let s:running = v:true + let s:starting = v:true let gdb_job_info = nvim_get_chan_info(s:gdb_job_id) let s:gdbbuf = gdb_job_info['buffer'] let s:gdbwin = win_getid(winnr()) @@ -355,6 +357,8 @@ func s:StartDebug_term(dict) sleep 10m endwhile + let s:starting = v:false + " Set the filetype, this can be used to add mappings. set filetype=termdebug @@ -663,6 +667,11 @@ func s:GetAsmAddr(msg) endfunc function s:EndTermDebug(job_id, exit_code, event) + let s:running = v:false + if s:starting + return + endif + if exists('#User#TermdebugStopPre') doauto User TermdebugStopPre endif -- cgit From 6eca9b69c4a1f40f27a6b41961af787327259de8 Mon Sep 17 00:00:00 2001 From: bfredl Date: Sat, 19 Mar 2022 13:48:03 +0100 Subject: feat(ui): allow conceal to be defined in decorations Unlike syntax conceal, change highlight of concealed char Can be used in tree-sitter using "conceal" metadata. --- runtime/lua/vim/treesitter/highlighter.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/lua/vim/treesitter/highlighter.lua b/runtime/lua/vim/treesitter/highlighter.lua index b6f61cfb2e..e1ffd42a7f 100644 --- a/runtime/lua/vim/treesitter/highlighter.lua +++ b/runtime/lua/vim/treesitter/highlighter.lua @@ -274,7 +274,8 @@ local function on_line_impl(self, buf, line) { end_line = end_row, end_col = end_col, hl_group = hl, ephemeral = true, - priority = tonumber(metadata.priority) or 100 -- Low but leaves room below + priority = tonumber(metadata.priority) or 100, -- Low but leaves room below + conceal = metadata.conceal, }) end if start_row > line then -- cgit From af427dedf663b1987fa54c5f885409ad51824a20 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Sun, 20 Mar 2022 13:41:46 -0400 Subject: fix(lsp): set tabSize from 'shiftwidth', not 'softtabstop' (#17787) The use of 'softtabstop' to set tabSize was introduced in 5d5b068, replacing 'tabstop'. If we look past the name tabSize and at the actual purpose of the field, it's the indentation width used when formatting. This corresponds to the Vim option 'shiftwidth', not 'softtabstop'. The latter has the comparatively mundane purpose of controlling what happens when you hit the tab key (and even this is incomplete, as it fails to account for 'smarttab'). --- runtime/doc/lsp.txt | 6 +++--- runtime/lua/vim/lsp/util.lua | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt index a9ebcd27ae..9a94570d80 100644 --- a/runtime/doc/lsp.txt +++ b/runtime/doc/lsp.txt @@ -1458,17 +1458,17 @@ extract_completion_items({result}) https://microsoft.github.io/language-server-protocol/specification#textDocument_completion get_effective_tabstop({bufnr}) *vim.lsp.util.get_effective_tabstop()* - Returns visual width of tabstop. + Returns indentation size. Parameters: ~ {bufnr} (optional, number): Buffer handle, defaults to current Return: ~ - (number) tabstop visual width + (number) indentation size See also: ~ - |softtabstop| + |shiftwidth| *vim.lsp.util.jump_to_location()* jump_to_location({location}, {offset_encoding}) diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index 59ab3d7e1f..cec3891418 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -1894,16 +1894,16 @@ end function M.make_workspace_params(added, removed) return { event = { added = added; removed = removed; } } end ---- Returns visual width of tabstop. +--- Returns indentation size. --- ----@see |softtabstop| +---@see |shiftwidth| ---@param bufnr (optional, number): Buffer handle, defaults to current ----@returns (number) tabstop visual width +---@returns (number) indentation size function M.get_effective_tabstop(bufnr) validate { bufnr = {bufnr, 'n', true} } local bo = bufnr and vim.bo[bufnr] or vim.bo - local sts = bo.softtabstop - return (sts > 0 and sts) or (sts < 0 and bo.shiftwidth) or bo.tabstop + local sw = bo.shiftwidth + return (sw == 0 and bo.tabstop) or sw end --- Creates a `DocumentFormattingParams` object for the current buffer and cursor position. -- cgit From 809dd65396e37db275e28ca7a6f87cc4485a1b35 Mon Sep 17 00:00:00 2001 From: marvim Date: Sun, 20 Mar 2022 18:00:30 +0000 Subject: docs: regenerate [skip ci] --- runtime/doc/api.txt | 47 ++++++++++++++++++++++++++++++++++++++++++----- runtime/doc/lsp.txt | 6 +++++- runtime/doc/lua.txt | 8 ++++++-- 3 files changed, 53 insertions(+), 8 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index dbf87bfd9f..fa2f8f974a 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -826,6 +826,7 @@ nvim_eval_statusline({str}, {*opts}) *nvim_eval_statusline()* • maxwidth: (number) Maximum width of statusline. • fillchar: (string) Character to fill blank spaces in the statusline (see 'fillchars'). + Treated as single-width even if it isn't. • highlights: (boolean) Return highlight information. • use_tabline: (boolean) Evaluate tabline instead @@ -1547,6 +1548,11 @@ nvim_set_current_win({window}) *nvim_set_current_win()* nvim_set_hl({ns_id}, {name}, {*val}) *nvim_set_hl()* Sets a highlight group. + Note: Unlike the `:highlight` command which can update a + highlight group, this function completely replaces the + definition. For example: `nvim_set_hl(0, 'Visual', {})` will + clear the highlight group 'Visual'. + Parameters: ~ {ns_id} Namespace id for this highlight |nvim_create_namespace()|. Use 0 to set a @@ -1937,7 +1943,7 @@ nvim_buf_attach({buffer}, {send_buffer}, {opts}) *nvim_buf_attach()* • on_reload: Lua callback invoked on reload. The entire buffer content should be considered changed. Args: - • the string "detach" + • the string "reload" • buffer handle • utf_sizes: include UTF-32 and UTF-16 size @@ -2582,6 +2588,35 @@ nvim_buf_set_extmark({buffer}, {ns_id}, {line}, {col}, {*opts}) not be placed if the line or column value is past the end of the buffer or end of the line respectively. Defaults to true. + • sign_text: string of length 1-2 used to + display in the sign column. Note: ranges are + unsupported and decorations are only applied + to start_row + • sign_hl_group: name of the highlight group + used to highlight the sign column text. Note: + ranges are unsupported and decorations are + only applied to start_row + • number_hl_group: name of the highlight group + used to highlight the number column. Note: + ranges are unsupported and decorations are + only applied to start_row + • line_hl_group: name of the highlight group + used to highlight the whole line. Note: ranges + are unsupported and decorations are only + applied to start_row + • cursorline_hl_group: name of the highlight + group used to highlight the line when the + cursor is on the same line as the mark and + 'cursorline' is enabled. Note: ranges are + unsupported and decorations are only applied + to start_row + • conceal: string which should be either empty + or a single character. Enable concealing + similar to |:syn-conceal|. When a character is + supplied it is used as |:syn-cchar|. + "hl_group" is used as highlight for the cchar + if provided, otherwise it defaults to + |hl-Conceal|. Return: ~ Id of the created/updated extmark @@ -2816,7 +2851,8 @@ nvim_win_set_buf({window}, {buffer}) *nvim_win_set_buf()* nvim_win_set_cursor({window}, {pos}) *nvim_win_set_cursor()* Sets the (1,0)-indexed cursor position in the window. - |api-indexing| + |api-indexing| This scrolls the window even if it is not the + current one. Parameters: ~ {window} Window handle, or 0 for current window @@ -3001,9 +3037,10 @@ nvim_open_win({buffer}, {enter}, {*config}) *nvim_open_win()* ">", "", "", "", "<" ] will only make vertical borders but not horizontal ones. By default, `FloatBorder` highlight is used, - which links to `VertSplit` when not defined. - It could also be specified by character: [ - {"+", "MyCorner"}, {"x", "MyBorder"} ]. + which links to `WinSeparator` when not + defined. It could also be specified by + character: [ {"+", "MyCorner"}, {"x", + "MyBorder"} ]. • noautocmd: If true then no buffer-related autocommand events such as |BufEnter|, diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt index 9a94570d80..9dfc65f999 100644 --- a/runtime/doc/lsp.txt +++ b/runtime/doc/lsp.txt @@ -686,7 +686,11 @@ formatexpr({opts}) *vim.lsp.formatexpr()* Provides an interface between the built-in client and a `formatexpr` function. - Currently only supports a single client. This can be set via `setlocal formatexpr=v:lua.vim.lsp.formatexpr()` but will typically or in `on_attach` via vim.api.nvim_buf_set_option(bufnr, 'formatexpr , 'v:lua.vim.lsp.formatexpr(#{timeout_ms:250})')`. + Currently only supports a single client. This can be set via + `setlocal formatexpr=v:lua.vim.lsp.formatexpr()` but will + typically or in `on_attach` via + `vim.api.nvim_buf_set_option(bufnr, 'formatexpr', + 'v:lua.vim.lsp.formatexpr(#{timeout_ms:250})')`. Parameters: ~ {opts} table options for customizing the formatting diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index 93386ddfe9..bd821c4f9e 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -1259,6 +1259,10 @@ vim.wo *vim.wo* ============================================================================== Lua module: vim *lua-vim* + *vim.connection_failure_errmsg()* +connection_failure_errmsg({consequence}) + TODO: Documentation + defer_fn({fn}, {timeout}) *vim.defer_fn()* Defers calling `fn` until `timeout` ms passes. @@ -1550,7 +1554,7 @@ startswith({s}, {prefix}) *vim.startswith()* tbl_add_reverse_lookup({o}) *vim.tbl_add_reverse_lookup()* Add the reverse lookup values to an existing table. For - example: tbl_add_reverse_lookup { A = 1 } == { [1] = 'A , A = 1 }` + example: `tbl_add_reverse_lookup { A = 1 } == { [1] = 'A', A = 1 }` Parameters: ~ {o} table The table to add the reverse to. @@ -1990,7 +1994,7 @@ set({mode}, {lhs}, {rhs}, {opts}) *vim.keymap.set()* vim.keymap.set('n', 'asdf', require('jkl').my_fun) < - the require('jkl )` gets evaluated during this call in order to access the + the `require('jkl')` gets evaluated during this call in order to access the function. If you want to avoid this cost at startup you can wrap it in a function, for example: > -- cgit From f5a3edb0c0f761a82b22cd1ac193538220fdee95 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 23 Mar 2022 19:52:50 +0800 Subject: refactor: remove cpo-& behavior (#17745) cpo-& has been removed, but its behavior was accidentally made the default behavior. That should be removed instead. --- runtime/doc/recover.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/doc/recover.txt b/runtime/doc/recover.txt index 9ef5a37452..d9aaa757ad 100644 --- a/runtime/doc/recover.txt +++ b/runtime/doc/recover.txt @@ -108,7 +108,7 @@ command: *:pre* *:preserve* *E313* *E314* :pre[serve] Write all text for the current buffer into its swap file. The original file is no longer needed for - recovery. This sets a flag in the current buffer. + recovery. A Vim swap file can be recognized by the first six characters: "b0VIM ". After that comes the version number, e.g., "3.0". -- cgit From 58140a94283b1c6e45099c89e66a0c94e9d90931 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Thu, 24 Mar 2022 13:22:58 +0000 Subject: feat(keymap): return nil from an expr keymap For Lua callback expr keymaps, returning `nil` or `false` is equivalent to an empty string --- runtime/doc/lua.txt | 4 +++- runtime/lua/vim/keymap.lua | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index bd821c4f9e..e5bc60a8cd 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -2007,7 +2007,9 @@ set({mode}, {lhs}, {rhs}, {opts}) *vim.keymap.set()* create mapping on multiple modes. {lhs} string Left-hand side |{lhs}| of the mapping. {rhs} string|function Right-hand side |{rhs}| of the - mapping. Can also be a Lua function. + mapping. Can also be a Lua function. If a Lua + function and `opts.expr == true`, returning `nil` + or `false` is equivalent to an empty string. {opts} table A table of |:map-arguments| such as "silent". In addition to the options listed in |nvim_set_keymap()|, this table also accepts the diff --git a/runtime/lua/vim/keymap.lua b/runtime/lua/vim/keymap.lua index 1be40b0081..c193a13a7b 100644 --- a/runtime/lua/vim/keymap.lua +++ b/runtime/lua/vim/keymap.lua @@ -35,6 +35,8 @@ local keymap = {} --- Can also be list of modes to create mapping on multiple modes. ---@param lhs string Left-hand side |{lhs}| of the mapping. ---@param rhs string|function Right-hand side |{rhs}| of the mapping. Can also be a Lua function. +--- If a Lua function and `opts.expr == true`, returning `nil` or `false` +--- is equivalent to an empty string. -- ---@param opts table A table of |:map-arguments| such as "silent". In addition to the options --- listed in |nvim_set_keymap()|, this table also accepts the following keys: @@ -56,10 +58,18 @@ function keymap.set(mode, lhs, rhs, opts) local is_rhs_luaref = type(rhs) == "function" mode = type(mode) == 'string' and {mode} or mode - if is_rhs_luaref and opts.expr and opts.replace_keycodes ~= false then + if is_rhs_luaref and opts.expr then local user_rhs = rhs rhs = function () - return vim.api.nvim_replace_termcodes(user_rhs(), true, true, true) + local res = user_rhs() + if not res then + -- TODO(lewis6991): Handle this in C? + return '' + elseif opts.replace_keycodes ~= false then + return vim.api.nvim_replace_termcodes(res, true, true, true) + else + return res + end end end -- clear replace_keycodes from opts table -- cgit From 02fd00c042d2b8a66c892dd31c1659ee98a1dbbf Mon Sep 17 00:00:00 2001 From: Gregory Anders <8965202+gpanders@users.noreply.github.com> Date: Thu, 24 Mar 2022 08:05:13 -0600 Subject: feat(runtime): include Lua in C++ ftplugin (#17843) --- runtime/ftplugin/cpp.vim | 1 + 1 file changed, 1 insertion(+) (limited to 'runtime') diff --git a/runtime/ftplugin/cpp.vim b/runtime/ftplugin/cpp.vim index f9d31cbec3..58c4e4b24a 100644 --- a/runtime/ftplugin/cpp.vim +++ b/runtime/ftplugin/cpp.vim @@ -10,6 +10,7 @@ endif " Behaves mostly just like C runtime! ftplugin/c.vim ftplugin/c_*.vim ftplugin/c/*.vim +runtime! ftplugin/c.lua ftplugin/c_*.lua ftplugin/c/*.lua " C++ uses templates with " Disabled, because it gives an error for typing an unmatched ">". -- cgit From 69f1de86dca28d6e339351082df1309ef4fbb6a6 Mon Sep 17 00:00:00 2001 From: Michael Lingelbach Date: Thu, 24 Mar 2022 12:01:04 -0700 Subject: feat: add vim.tbl_get (#17831) vim.tbl_get takes a table with subsequent string arguments (variadic) that index into the table. If the value pointed to by the set of keys exists, the function returns the value. If the set of keys does not exist, the function returns nil. --- runtime/doc/lua.txt | 16 ++++++++++++++++ runtime/lua/vim/shared.lua | 27 +++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) (limited to 'runtime') diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index bd821c4f9e..21f44ce02e 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -1634,6 +1634,22 @@ tbl_flatten({t}) *vim.tbl_flatten()* See also: ~ From https://github.com/premake/premake-core/blob/master/src/base/table.lua +tbl_get({o}, {...}) *vim.tbl_get()* + Index into a table (first argument) via string keys passed as + subsequent arguments. Return `nil` if the key does not exist. Examples: > + + vim.tbl_get({ key = { nested_key = true }}, 'key', 'nested_key') == true + vim.tbl_get({ key = {}}, 'key', 'nested_key') == nil +< + + Parameters: ~ + {o} Table to index + {...} Optional strings (0 or more, variadic) via which to + index the table + + Return: ~ + nested value indexed by key if it exists, else nil + tbl_isempty({t}) *vim.tbl_isempty()* Checks if a table is empty. diff --git a/runtime/lua/vim/shared.lua b/runtime/lua/vim/shared.lua index 3eb332279a..f0dc34608c 100644 --- a/runtime/lua/vim/shared.lua +++ b/runtime/lua/vim/shared.lua @@ -347,6 +347,33 @@ function vim.tbl_add_reverse_lookup(o) return o end +--- Index into a table (first argument) via string keys passed as subsequent arguments. +--- Return `nil` if the key does not exist. +--_ +--- Examples: +---
+---  vim.tbl_get({ key = { nested_key = true }}, 'key', 'nested_key') == true
+---  vim.tbl_get({ key = {}}, 'key', 'nested_key') == nil
+--- 
+--- +---@param o Table to index +---@param ... Optional strings (0 or more, variadic) via which to index the table +--- +---@returns nested value indexed by key if it exists, else nil +function vim.tbl_get(o, ...) + local keys = {...} + if #keys == 0 then + return + end + for _, k in ipairs(keys) do + o = o[k] + if o == nil then + return + end + end + return o +end + --- Extends a list-like table with the values of another list-like table. --- --- NOTE: This mutates dst! -- cgit From 5e64d65df690000e56fd91577978e1744d6e9e8e Mon Sep 17 00:00:00 2001 From: Jared Weakly Date: Fri, 25 Mar 2022 11:12:00 -0700 Subject: fix(filetype.lua): always return a string in getline helper function (#17852) Uses of `getline` in `filetype.lua` currently assume it always returns a string. However, if the buffer is unloaded when filetype detection runs, `getline` returns `nil`. Fixing this prevents errors when filetype detection is run on unloaded buffers. --- runtime/lua/vim/filetype.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index b356f5e3dc..ab71de54f8 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -21,7 +21,7 @@ end ---@private local function getline(bufnr, lnum) - return api.nvim_buf_get_lines(bufnr, lnum-1, lnum, false)[1] + return api.nvim_buf_get_lines(bufnr, lnum-1, lnum, false)[1] or "" end -- Filetypes based on file extension -- cgit From 174deafcef27bc98df36c952ee93e316488bc765 Mon Sep 17 00:00:00 2001 From: Javier Lopez Date: Fri, 25 Mar 2022 13:24:53 -0500 Subject: docs(api): improve autocommand docs (#17545) [skip ci] --- runtime/doc/api.txt | 251 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 164 insertions(+), 87 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index fa2f8f974a..13179e9d9e 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -3152,129 +3152,206 @@ nvim_tabpage_set_var({tabpage}, {name}, {value}) Autocmd Functions *api-autocmd* nvim_create_augroup({name}, {*opts}) *nvim_create_augroup()* - Create or get an augroup. + Create or get an autocommand group |autocmd-groups|. - To get an existing augroup ID, do: > - local id = vim.api.nvim_create_augroup(name, { + To get an existing group id, do: > + local id = vim.api.nvim_create_augroup("MyGroup", { clear = false }) < Parameters: ~ - {name} String: The name of the augroup to create - {opts} Parameters - • clear (bool): Whether to clear existing commands - or not. Defaults to true. See |autocmd-groups| + {name} String: The name of the group + {opts} Dictionary Parameters + • clear (bool) optional: defaults to true. Clear + existing commands if the group already exists + |autocmd-groups|. Return: ~ - opaque value to use with nvim_del_augroup_by_id + Integer id of the created group. + + See also: ~ + |autocmd-groups| nvim_create_autocmd({event}, {*opts}) *nvim_create_autocmd()* - Create an autocmd. + Create an |autocommand| - Examples: - • event: "pat1,pat2,pat3", - • event: "pat1" - • event: { "pat1" } - • event: { "pat1", "pat2", "pat3" } + The API allows for two (mutually exclusive) types of actions + to be executed when the autocommand triggers: a callback + function (Lua or Vimscript), or a command (like regular + autocommands). - Parameters: ~ - {event} The event or events to register this autocmd - Required keys: event: string | ArrayOf(string) + Example using callback: > + -- Lua function + local myluafun = function() print("This buffer enters") end - Parameters: ~ - {opts} Optional Parameters: - • callback: (string|function) - • (string): The name of the viml function to - execute when triggering this autocmd - • (function): The lua function to execute when - triggering this autocmd - • NOTE: Cannot be used with {command} + -- Vimscript function name (as a string) + local myvimfun = "g:MyVimFunction" - • command: (string) command - • vimscript command - • NOTE: Cannot be used with {callback} Eg. - command = "let g:value_set = v:true" + vim.api.nvim_create_autocmd({ + event = {"BufEnter", "BufWinEnter"}, + pattern = {"*.c", "*.h"}, + callback = myluafun, -- Or myvimfun + }) +< + + Example using command: > + vim.api.nvim_create_autocmd({ + event = {"BufEnter", "BufWinEnter"}, + pattern = {"*.c", "*.h"}, + command = "echo 'Entering a C or C++ file'", + }) +< - • pattern: (string|table) - • pattern or patterns to match against - • defaults to "*". - • NOTE: Cannot be used with {buffer} + Example values for pattern: > + pattern = "*.py" + pattern = { "*.py", "*.pyi" } +< - • buffer: (bufnr) - • create a |autocmd-buflocal| autocmd. - • NOTE: Cannot be used with {pattern} + Examples values for event: > + event = "BufPreWrite" + event = {"CursorHold", "BufPreWrite", "BufPostWrite"} +< - • group: (string|int) The augroup name or id - • once: (boolean) - See |autocmd-once| - • nested: (boolean) - See |autocmd-nested| - • desc: (string) - Description of the autocmd + Parameters: ~ + {event} (String|Array) The event or events to register + this autocommand + {opts} Dictionary of autocommand options: + • group (string|integer) optional: the + autocommand group name or id to match against. + • pattern (string|array) optional: pattern or + patterns to match against |autocmd-pattern|. + • buffer (integer) optional: buffer number for + buffer local autocommands |autocmd-buflocal|. + Cannot be used with {pattern}. + • desc (string) optional: description of the + autocommand. + • callback (function|string) optional: Lua + function or Vim function (as string) to execute + on event. Cannot be used with {command} + • command (string) optional: Vim command to + execute on event. Cannot be used with + {callback} + • once (boolean) optional: defaults to false. Run + the autocommand only once |autocmd-once|. + • nested (boolean) optional: defaults to false. + Run nested autocommands |autocmd-nested|. + + Return: ~ + Integer id of the created autocommand. - Return: ~ - opaque value to use with nvim_del_autocmd + See also: ~ + |autocommand| + |nvim_del_autocmd()| nvim_del_augroup_by_id({id}) *nvim_del_augroup_by_id()* - Delete an augroup by {id}. {id} can only be returned when - augroup was created with |nvim_create_augroup|. + Delete an autocommand group by id. - NOTE: behavior differs from augroup-delete. + To get a group id one can use |nvim_get_autocmds()|. - When deleting an augroup, autocmds contained by this augroup - will also be deleted and cleared. This augroup will no longer - exist + NOTE: behavior differs from |augroup-delete|. When deleting a + group, autocommands contained in this group will also be + deleted and cleared. This group will no longer exist. -nvim_del_augroup_by_name({name}) *nvim_del_augroup_by_name()* - Delete an augroup by {name}. + Parameters: ~ + {id} Integer The id of the group. - NOTE: behavior differs from augroup-delete. + See also: ~ + |nvim_del_augroup_by_name()| + |nvim_create_augroup()| - When deleting an augroup, autocmds contained by this augroup - will also be deleted and cleared. This augroup will no longer - exist +nvim_del_augroup_by_name({name}) *nvim_del_augroup_by_name()* + Delete an autocommand group by name. -nvim_del_autocmd({id}) *nvim_del_autocmd()* - Delete an autocmd by {id}. Autocmds only return IDs when - created via the API. Will not error if called and no autocmds - match the {id}. + NOTE: behavior differs from |augroup-delete|. When deleting a + group, autocommands contained in this group will also be + deleted and cleared. This group will no longer exist. Parameters: ~ - {id} Integer The ID returned by nvim_create_autocmd + {name} String The name of the group. -nvim_do_autocmd({event}, {*opts}) *nvim_do_autocmd()* - Do one autocmd. + See also: ~ + |autocommand-groups| + +nvim_del_autocmd({id}) *nvim_del_autocmd()* + Delete an autocommand by id. + + NOTE: Only autocommands created via the API have an id. Parameters: ~ - {event} The event or events to execute - {opts} Optional Parameters: - • buffer (number) - buffer number - • NOTE: Cannot be used with {pattern} + {id} Integer The id returned by nvim_create_autocmd - • pattern (string|table) - optional, defaults to - "*". - • NOTE: Cannot be used with {buffer} + See also: ~ + |nvim_create_autocmd()| - • group (string|int) - autocmd group name or id - • modeline (boolean) - Default true, see - || +nvim_do_autocmd({event}, {*opts}) *nvim_do_autocmd()* + Execute an autocommand |autocmd-execute|. + + Parameters: ~ + {event} (String|Array) The event or events to execute + {opts} Dictionary of autocommand options: + • group (string|integer) optional: the + autocommand group name or id to match against. + |autocmd-groups|. + • pattern (string|array) optional: defaults to + "*" |autocmd-pattern|. Cannot be used with + {buffer}. + • buffer (integer) optional: buffer number + |autocmd-buflocal|. Cannot be used with + {pattern}. + • modeline (bool) optional: defaults to true. + Process the modeline after the autocommands + ||. -nvim_get_autocmds({*opts}) *nvim_get_autocmds()* - Get autocmds that match the requirements passed to {opts}. + See also: ~ + |:doautocmd| - Parameters: ~ - {opts} Optional Parameters: - • event : Name or list of name of events to match - against - • group (string|int): Name or id of group to match - against - • pattern: Pattern or list of patterns to match - against. Cannot be used with {buffer} - • buffer: Buffer number or list of buffer numbers - for buffer local autocommands - |autocmd-buflocal|. Cannot be used with - {pattern} +nvim_get_autocmds({*opts}) *nvim_get_autocmds()* + Get autocommands that match the requirements passed to {opts}. + + These examples will get autocommands matching ALL the given + criteria: > + -- Matches all criteria + autocommands = vim.api.nvim_get_autocmds({ + group = "MyGroup", + event = {"BufEnter", "BufWinEnter"}, + pattern = {"*.c", "*.h"} + }) + + -- All commands from one group + autocommands = vim.api.nvim_get_autocmds({ + group = "MyGroup", + }) +< - Return: ~ - A list of autocmds that match + NOTE: When multiple patterns or events are provided, it will + find all the autocommands that match any combination of them. + + Parameters: ~ + {opts} Dictionary with at least one of the following: + • group (string|integer): the autocommand group + name or id to match against. + • event (string|array): event or events to match + against |autocmd-events|. + • pattern (string|array): pattern or patterns to + match against |autocmd-pattern|. + + Return: ~ + Array of autocommands matching the criteria, with each + item containing the following fields: + • id (number): the autocommand id (only when defined with + the API). + • group (integer): the autocommand group id. + • desc (string): the autocommand description. + • event (string): the autocommand event. + • command (string): the autocommand command. + • once (boolean): whether the autocommand is only run + once. + • pattern (string): the autocommand pattern. If the + autocommand is buffer local |autocmd-buffer-local|: + • buflocal (boolean): true if the autocommand is buffer + local. + • buffer (number): the buffer number. ============================================================================== -- cgit From 61205c1defb64ac5466496b5451e4a7f3171e21e Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Fri, 25 Mar 2022 19:57:59 +0100 Subject: chore: fix typos (#17755) Co-authored-by: Jordan Haine --- runtime/autoload/health.vim | 2 +- runtime/autoload/health/provider.vim | 2 +- runtime/doc/api.txt | 12 ++++++------ runtime/doc/message.txt | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) (limited to 'runtime') diff --git a/runtime/autoload/health.vim b/runtime/autoload/health.vim index ec030adf04..1292e4344e 100644 --- a/runtime/autoload/health.vim +++ b/runtime/autoload/health.vim @@ -188,7 +188,7 @@ function! s:get_healthcheck_list(plugin_names) abort \ + nvim_get_runtime_file('lua/**/'.p.'/health/init.lua', v:true) \ + nvim_get_runtime_file('lua/**/'.p.'/health.lua', v:true) if len(paths) == 0 - let healthchecks += [[p, '', '']] " healthchek not found + let healthchecks += [[p, '', '']] " healthcheck not found else let healthchecks += map(uniq(sort(paths)), \'filepath_to_healthcheck(v:val)') diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index 6022e05c22..a01cb9631c 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -690,7 +690,7 @@ function! s:check_perl() abort if empty(perl_exec) if !empty(perl_warnings) call health#report_warn(perl_warnings, ['See :help provider-perl for more information.', - \ 'You may disable this provider (and warning) by adding `let g:loaded_node_provider = 0` to your init.vim']) + \ 'You may disable this provider (and warning) by adding `let g:loaded_perl_provider = 0` to your init.vim']) else call health#report_warn('No usable perl executable found') endif diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index 13179e9d9e..d912b22197 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -452,7 +452,7 @@ Extended marks (extmarks) represent buffer annotations that track text changes in the buffer. They can represent cursors, folds, misspelled words, anything that needs to track a logical location in the buffer over time. |api-indexing| -Extmark position works like "bar" cursor: it exists between characters. Thus +Extmark position works like "bar" cursor: it exists between characters. Thus, the maximum extmark index on a line is 1 more than the character index: > f o o b a r line contents @@ -468,7 +468,7 @@ extmark position and enter some text, the extmark migrates forward. > f o o z|b a r line (| = cursor) 4 extmark (after typing "z") -If an extmark is on the last index of a line and you inputs a newline at that +If an extmark is on the last index of a line and you input a newline at that point, the extmark will accordingly migrate to the next line: > f o o z b a r| line (| = cursor) @@ -1802,7 +1802,7 @@ nvim_parse_expression({expr}, {flags}, {highlight}) there for debugging purposes primary (debugging parser and providing debug information). • "children": a list of nodes described in top/"ast". - There always is zero, one or two children, key will + There is always zero, one or two children, key will not be present if node has no children. Maximum number of children may be found in node_maxchildren array. @@ -1967,7 +1967,7 @@ nvim_buf_call({buffer}, {fun}) *nvim_buf_call()* 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 + set as current window temporarily. Otherwise, a temporary scratch window (called the "autocmd window" for historical reasons) will be used. @@ -2362,7 +2362,7 @@ nvim_buf_add_highlight({buffer}, {ns_id}, {hl_group}, {line}, {col_start}, it in to this function as `ns_id` to add highlights to the namespace. All highlights in the same namespace can then be cleared with single call to |nvim_buf_clear_namespace()|. If - the highlight never will be deleted by an API call, pass + the highlight will never be deleted by an API call, pass `ns_id = -1`. As a shorthand, `ns_id = 0` can be used to create a new @@ -3029,7 +3029,7 @@ nvim_open_win({buffer}, {enter}, {*config}) *nvim_open_win()* double box style could be specified as [ "╔", "═" ,"╗", "║", "╝", "═", "╚", "║" ]. If the number of chars are less than eight, - they will be repeated. Thus an ASCII border + they will be repeated. Thus, an ASCII border could be specified as [ "/", "-", "\\", "|" ], or all chars the same as [ "x" ]. An empty string can be used to turn off a diff --git a/runtime/doc/message.txt b/runtime/doc/message.txt index fa1bc6f7da..dac4df5ee9 100644 --- a/runtime/doc/message.txt +++ b/runtime/doc/message.txt @@ -61,7 +61,7 @@ If you are lazy, it also works without the shift key: > When an error message is displayed, but it is removed before you could read it, you can see it again with: > - :echo errmsg + :echo v:errmsg Or view a list of recent messages with: > :messages See `:messages` above. -- cgit From 85821d8b6fa366f7361f84e07e62dc8fc951f26d Mon Sep 17 00:00:00 2001 From: かわえもん Date: Sat, 26 Mar 2022 21:21:32 +0900 Subject: docs(api): fix wrong documentation of `nvim_create_autocmd` (#17870) also add doc changes from typofix PR --- runtime/doc/api.txt | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index d912b22197..02a27e15f8 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -1802,7 +1802,7 @@ nvim_parse_expression({expr}, {flags}, {highlight}) there for debugging purposes primary (debugging parser and providing debug information). • "children": a list of nodes described in top/"ast". - There is always zero, one or two children, key will + There always is zero, one or two children, key will not be present if node has no children. Maximum number of children may be found in node_maxchildren array. @@ -1967,7 +1967,7 @@ nvim_buf_call({buffer}, {fun}) *nvim_buf_call()* 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 + set as current window temporarily. Otherwise a temporary scratch window (called the "autocmd window" for historical reasons) will be used. @@ -2362,7 +2362,7 @@ nvim_buf_add_highlight({buffer}, {ns_id}, {hl_group}, {line}, {col_start}, it in to this function as `ns_id` to add highlights to the namespace. All highlights in the same namespace can then be cleared with single call to |nvim_buf_clear_namespace()|. If - the highlight will never be deleted by an API call, pass + the highlight never will be deleted by an API call, pass `ns_id = -1`. As a shorthand, `ns_id = 0` can be used to create a new @@ -3029,7 +3029,7 @@ nvim_open_win({buffer}, {enter}, {*config}) *nvim_open_win()* double box style could be specified as [ "╔", "═" ,"╗", "║", "╝", "═", "╚", "║" ]. If the number of chars are less than eight, - they will be repeated. Thus, an ASCII border + they will be repeated. Thus an ASCII border could be specified as [ "/", "-", "\\", "|" ], or all chars the same as [ "x" ]. An empty string can be used to turn off a @@ -3188,16 +3188,14 @@ nvim_create_autocmd({event}, {*opts}) *nvim_create_autocmd()* -- Vimscript function name (as a string) local myvimfun = "g:MyVimFunction" - vim.api.nvim_create_autocmd({ - event = {"BufEnter", "BufWinEnter"}, + vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, { pattern = {"*.c", "*.h"}, callback = myluafun, -- Or myvimfun }) < Example using command: > - vim.api.nvim_create_autocmd({ - event = {"BufEnter", "BufWinEnter"}, + vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, { pattern = {"*.c", "*.h"}, command = "echo 'Entering a C or C++ file'", }) @@ -3209,8 +3207,8 @@ nvim_create_autocmd({event}, {*opts}) *nvim_create_autocmd()* < Examples values for event: > - event = "BufPreWrite" - event = {"CursorHold", "BufPreWrite", "BufPostWrite"} + "BufPreWrite" + {"CursorHold", "BufPreWrite", "BufPostWrite"} < Parameters: ~ -- cgit From a490db5ba819218e9188cbb51d885dbf3a194000 Mon Sep 17 00:00:00 2001 From: Javier Lopez Date: Sat, 26 Mar 2022 09:34:56 -0500 Subject: refactor!: rename nvim_do_autocmd to nvim_exec_autocmd (#17854) according to established code standards (`:h dev-api`) --- runtime/doc/api.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index 02a27e15f8..0a8a3e9a2c 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -3282,7 +3282,7 @@ nvim_del_autocmd({id}) *nvim_del_autocmd()* See also: ~ |nvim_create_autocmd()| -nvim_do_autocmd({event}, {*opts}) *nvim_do_autocmd()* +nvim_exec_autocmd({event}, {*opts}) *nvim_exec_autocmd()* Execute an autocommand |autocmd-execute|. Parameters: ~ -- cgit From a86d3d3780402f42f5ccbde919ff3b4fb48f15ed Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 27 Mar 2022 17:02:44 +0800 Subject: docs: correct CursorMoved documentation (#17880) behavior was changed in https://github.com/neovim/neovim/pull/9807 --- runtime/doc/autocmd.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt index ab0b0cd07c..54fb4c14a0 100644 --- a/runtime/doc/autocmd.txt +++ b/runtime/doc/autocmd.txt @@ -500,9 +500,9 @@ CursorMoved After the cursor was moved in Normal or Visual of the cursor line has been changed, e.g. with "x", "rx" or "p". Not triggered when there is typeahead, while - executing a script file, when an operator is - pending, or when moving to another window while - remaining at the same cursor position. + executing a script file, or when an operator + is pending. Always triggered when moving to + another window. For an example see |match-parens|. Note: Cannot be skipped with |:noautocmd|. Careful: This is triggered very often, don't -- cgit From a8e2c45b9462b740f22305397342b96586b88681 Mon Sep 17 00:00:00 2001 From: Smitesh Patil Date: Sun, 27 Mar 2022 19:40:03 +0530 Subject: fix(diagnostic): make `open_float` respect global diagnostic options (#17879) * make `open_float` respect `scope` option set in `vim.diagnostic.config` * Closes #17878 --- runtime/lua/vim/diagnostic.lua | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'runtime') diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua index fcb1e61764..1ec66d7c55 100644 --- a/runtime/lua/vim/diagnostic.lua +++ b/runtime/lua/vim/diagnostic.lua @@ -1224,6 +1224,18 @@ function M.open_float(opts, ...) opts = opts or {} bufnr = get_bufnr(bufnr or opts.bufnr) + + do + -- Resolve options with user settings from vim.diagnostic.config + -- Unlike the other decoration functions (e.g. set_virtual_text, set_signs, etc.) `open_float` + -- does not have a dedicated table for configuration options; instead, the options are mixed in + -- with its `opts` table which also includes "keyword" parameters. So we create a dedicated + -- options table that inherits missing keys from the global configuration before resolving. + local t = global_diagnostic_options.float + local float_opts = vim.tbl_extend("keep", opts, type(t) == "table" and t or {}) + opts = get_resolved_options({ float = float_opts }, nil, bufnr).float + end + local scope = ({l = "line", c = "cursor", b = "buffer"})[opts.scope] or opts.scope or "line" local lnum, col if scope == "line" or scope == "cursor" then @@ -1242,17 +1254,6 @@ function M.open_float(opts, ...) error("Invalid value for option 'scope'") end - do - -- Resolve options with user settings from vim.diagnostic.config - -- Unlike the other decoration functions (e.g. set_virtual_text, set_signs, etc.) `open_float` - -- does not have a dedicated table for configuration options; instead, the options are mixed in - -- with its `opts` table which also includes "keyword" parameters. So we create a dedicated - -- options table that inherits missing keys from the global configuration before resolving. - local t = global_diagnostic_options.float - local float_opts = vim.tbl_extend("keep", opts, type(t) == "table" and t or {}) - opts = get_resolved_options({ float = float_opts }, nil, bufnr).float - end - local diagnostics = get_diagnostics(bufnr, opts, true) if scope == "line" then -- cgit From 72652cbc46f568128bfc296ba63fb2d26941da8e Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 27 Mar 2022 10:25:55 -0700 Subject: feat(test): use nvim_exec in helpers.source() #16064 helpers.source() was a hack to work around the lack of anonymous :source. Its "create tempfile" behavior is not a required part of most tests that use it. Some tests still need the old "create tempfile" behavior either because they test SID behavior, or because of missing nvim_exec features: #16071 --- runtime/doc/options.txt | 3 +-- runtime/doc/repeat.txt | 3 +-- runtime/doc/vim_diff.txt | 1 + 3 files changed, 3 insertions(+), 4 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 8323ec3e9d..c0a7b73438 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -3670,8 +3670,7 @@ A jump table for the options with a short description can be found at |Q_op|. 0: never 1: only if there are at least two windows 2: always - 3: have a global statusline at the bottom instead of one for - each window + 3: always and ONLY the last window The screen looks nicer with a status line if you have several windows, but it takes another screen line. |status-line| diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt index 994f97bba0..508565dea4 100644 --- a/runtime/doc/repeat.txt +++ b/runtime/doc/repeat.txt @@ -182,8 +182,7 @@ For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|. *:so* *:source* *load-vim-script* :[range]so[urce] [file] Runs |Ex| commands or Lua code (".lua" files) from - [file], or from the current buffer if no [file] is - given. + [file], or current buffer if no [file]. Triggers the |SourcePre| autocommand. *:source!* :[range]so[urce]! {file} diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index 9ca5faf112..59f085977b 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -180,6 +180,7 @@ Commands: |:Man| is available by default, with many improvements such as completion |:sign-define| accepts a `numhl` argument, to highlight the line number |:match| can be invoked before highlight group is defined + |:source| works with Lua and anonymous (no file) scripts Events: |RecordingEnter| -- cgit From 4d3acd6bebbdffa3fefc4e102d9ff36845c7a18f Mon Sep 17 00:00:00 2001 From: Jaehwang Jung Date: Tue, 29 Mar 2022 01:16:11 +0900 Subject: fix(lsp): use "text" filetype for plaintext (#17898) --- runtime/lua/vim/lsp/util.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index cec3891418..991c4be950 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -1138,7 +1138,7 @@ function M.stylize_markdown(bufnr, contents, opts) block = {nil, "```+([a-zA-Z0-9_]*)", "```+"}, pre = {"", "
", "
"}, code = {"", "", ""}, - text = {"plaintex", "", ""}, + text = {"text", "", ""}, } local match_begin = function(line) -- cgit From d89a80fafc6cdf12f72dac2bcbd5055038a241dc Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 29 Mar 2022 13:38:29 +0800 Subject: docs: update hl-Whitespace documentation (#17901) --- runtime/doc/syntax.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt index 2af4ec1549..2d239d9198 100644 --- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -5226,7 +5226,8 @@ VisualNOS Visual mode selection when vim is "Not Owning the Selection". *hl-WarningMsg* WarningMsg warning messages *hl-Whitespace* -Whitespace "nbsp", "space", "tab" and "trail" in 'listchars' +Whitespace "nbsp", "space", "tab", "multispace", "lead" and "trail" + in 'listchars' *hl-WildMenu* WildMenu current match in 'wildmenu' completion -- cgit From 1bbe8ec2820497b8a61adcd138da350445b0ad92 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 19 Mar 2022 16:42:24 +0800 Subject: vim-patch:8.2.3110: a pattern that matches the cursor position is complicated Problem: A pattern that matches the cursor position is bit complicated. Solution: Use a dot to indicate the cursor line and column. (Christian Brabandt, closes vim/vim#8497, closes vim/vim#8179) https://github.com/vim/vim/commit/04db26b36000a4677b95403ec94bd11f6cc73975 Also use `n = ++vcol` in regexp_bt.c as `++vcol` alone fails lint. --- runtime/doc/pattern.txt | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/pattern.txt b/runtime/doc/pattern.txt index 680b853dab..c12a099469 100644 --- a/runtime/doc/pattern.txt +++ b/runtime/doc/pattern.txt @@ -918,13 +918,20 @@ $ At end of pattern or in front of "\|", "\)" or "\n" ('magic' on): \%23l Matches in a specific line. \%<23l Matches above a specific line (lower line number). \%>23l Matches below a specific line (higher line number). +\%.l Matches at the cursor line. +\%<.l Matches above the cursor line. +\%>.l Matches below the cursor line. These three can be used to match specific lines in a buffer. The "23" can be any line number. The first line is 1. WARNING: When inserting or deleting lines Vim does not automatically update the matches. This means Syntax highlighting quickly becomes - wrong. + wrong. Also when refering to the cursor position (".") and + the cursor moves the display isn't updated for this change. An update + is done when using the |CTRL-L| command (the whole screen is updated). Example, to highlight the line where the cursor currently is: > - :exe '/\%' .. line(".") .. 'l.*' + :exe '/\%' .. line(".") .. 'l' +< Alternatively use: > + /\%.l < When 'hlsearch' is set and you move the cursor around and make changes this will clearly show when the match is updated or not. @@ -932,15 +939,23 @@ $ At end of pattern or in front of "\|", "\)" or "\n" ('magic' on): \%23c Matches in a specific column. \%<23c Matches before a specific column. \%>23c Matches after a specific column. +\%.c Matches at the cursor column. +\%<.c Matches before the cursor column. +\%>.c Matches after the cursor column. These three can be used to match specific columns in a buffer or string. The "23" can be any column number. The first column is 1. Actually, the column is the byte number (thus it's not exactly right for multibyte characters). WARNING: When inserting or deleting text Vim does not automatically update the matches. This means Syntax highlighting quickly becomes - wrong. + wrong. Also when refering to the cursor position (".") and + the cursor moves the display isn't updated for this change. An update + is done when using the |CTRL-L| command (the whole screen is updated). + Example, to highlight the column where the cursor currently is: > :exe '/\%' .. col(".") .. 'c' +< Alternatively use: > + /\%.c < When 'hlsearch' is set and you move the cursor around and make changes this will clearly show when the match is updated or not. Example for matching a single byte in column 44: > @@ -951,6 +966,9 @@ $ At end of pattern or in front of "\|", "\)" or "\n" ('magic' on): \%23v Matches in a specific virtual column. \%<23v Matches before a specific virtual column. \%>23v Matches after a specific virtual column. +\%.v Matches at the current virtual column. +\%<.v Matches before the current virtual column. +\%>.v Matches after the current virtual column. These three can be used to match specific virtual columns in a buffer or string. When not matching with a buffer in a window, the option values of the current window are used (e.g., 'tabstop'). @@ -960,13 +978,18 @@ $ At end of pattern or in front of "\|", "\)" or "\n" ('magic' on): one screen character. WARNING: When inserting or deleting text Vim does not automatically update highlighted matches. This means Syntax highlighting quickly - becomes wrong. + becomes wrong. Also when refering to the cursor position (".") and + the cursor moves the display isn't updated for this change. An update + is done when using the |CTRL-L| command (the whole screen is updated). Example, to highlight all the characters after virtual column 72: > /\%>72v.* < When 'hlsearch' is set and you move the cursor around and make changes this will clearly show when the match is updated or not. To match the text up to column 17: > /^.*\%17v +< To match all characters after the current virtual column (where the + cursor is): > + /\%>.v.* < Column 17 is not included, because this is a |/zero-width| match. To include the column use: > /^.*\%17v. -- cgit From b2819eec26c6e18fe41b103efad641fc2f227450 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 19 Mar 2022 17:48:20 +0800 Subject: docs(pattern.txt): cherry-pick latests changes from Vim runtime updates Update runtime files https://github.com/vim/vim/commit/53f7fccc9413c9f770694b56f40f242d383b2d5f Update runtime files https://github.com/vim/vim/commit/2286304cdbba53ceb52b3ba2ba4a521b0a2f8d0f Update runtime files https://github.com/vim/vim/commit/2f0936cb9a2eb026acac03e6a8fd0b2a5d97508b Update runtime files. https://github.com/vim/vim/commit/a2baa73d1d33014adea0fd9567949089ca21a782 --- runtime/doc/pattern.txt | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/pattern.txt b/runtime/doc/pattern.txt index c12a099469..35f5b311ff 100644 --- a/runtime/doc/pattern.txt +++ b/runtime/doc/pattern.txt @@ -914,18 +914,18 @@ $ At end of pattern or in front of "\|", "\)" or "\n" ('magic' on): becomes invalid. Vim doesn't automatically update the matches. Similar to moving the cursor for "\%#" |/\%#|. - */\%l* */\%>l* */\%l* */\%23l Matches below a specific line (higher line number). -\%.l Matches at the cursor line. -\%<.l Matches above the cursor line. -\%>.l Matches below the cursor line. - These three can be used to match specific lines in a buffer. The "23" +\%.l Matches at the cursor line. +\%<.l Matches above the cursor line. +\%>.l Matches below the cursor line. + These six can be used to match specific lines in a buffer. The "23" can be any line number. The first line is 1. WARNING: When inserting or deleting lines Vim does not automatically update the matches. This means Syntax highlighting quickly becomes - wrong. Also when refering to the cursor position (".") and + wrong. Also when referring to the cursor position (".") and the cursor moves the display isn't updated for this change. An update is done when using the |CTRL-L| command (the whole screen is updated). Example, to highlight the line where the cursor currently is: > @@ -939,19 +939,18 @@ $ At end of pattern or in front of "\|", "\)" or "\n" ('magic' on): \%23c Matches in a specific column. \%<23c Matches before a specific column. \%>23c Matches after a specific column. -\%.c Matches at the cursor column. -\%<.c Matches before the cursor column. -\%>.c Matches after the cursor column. - These three can be used to match specific columns in a buffer or - string. The "23" can be any column number. The first column is 1. - Actually, the column is the byte number (thus it's not exactly right - for multibyte characters). +\%.c Matches at the cursor column. +\%<.c Matches before the cursor column. +\%>.c Matches after the cursor column. + These six can be used to match specific columns in a buffer or string. + The "23" can be any column number. The first column is 1. Actually, + the column is the byte number (thus it's not exactly right for + multibyte characters). WARNING: When inserting or deleting text Vim does not automatically update the matches. This means Syntax highlighting quickly becomes - wrong. Also when refering to the cursor position (".") and + wrong. Also when referring to the cursor position (".") and the cursor moves the display isn't updated for this change. An update is done when using the |CTRL-L| command (the whole screen is updated). - Example, to highlight the column where the cursor currently is: > :exe '/\%' .. col(".") .. 'c' < Alternatively use: > @@ -966,11 +965,11 @@ $ At end of pattern or in front of "\|", "\)" or "\n" ('magic' on): \%23v Matches in a specific virtual column. \%<23v Matches before a specific virtual column. \%>23v Matches after a specific virtual column. -\%.v Matches at the current virtual column. -\%<.v Matches before the current virtual column. -\%>.v Matches after the current virtual column. - These three can be used to match specific virtual columns in a buffer - or string. When not matching with a buffer in a window, the option +\%.v Matches at the current virtual column. +\%<.v Matches before the current virtual column. +\%>.v Matches after the current virtual column. + These six can be used to match specific virtual columns in a buffer or + string. When not matching with a buffer in a window, the option values of the current window are used (e.g., 'tabstop'). The "23" can be any column number. The first column is 1. Note that some virtual column positions will never match, because they @@ -978,7 +977,7 @@ $ At end of pattern or in front of "\|", "\)" or "\n" ('magic' on): one screen character. WARNING: When inserting or deleting text Vim does not automatically update highlighted matches. This means Syntax highlighting quickly - becomes wrong. Also when refering to the cursor position (".") and + becomes wrong. Also when referring to the cursor position (".") and the cursor moves the display isn't updated for this change. An update is done when using the |CTRL-L| command (the whole screen is updated). Example, to highlight all the characters after virtual column 72: > -- cgit From ac1dd046c01e0685b0f8eeaa36e622b3c2f339ad Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Wed, 30 Mar 2022 13:12:12 +0200 Subject: vim-patch:46eea444d (#17920) Update runtime files https://github.com/vim/vim/commit/46eea444d992c2ae985cabb775a5d283f8e16df3 Skip repeat.txt as it only has vim9-specific changes. --- runtime/autoload/clojurecomplete.vim | 8 +-- runtime/autoload/python3complete.vim | 5 +- runtime/doc/autocmd.txt | 8 +-- runtime/doc/builtin.txt | 17 ++--- runtime/doc/insert.txt | 2 +- runtime/doc/options.txt | 3 +- runtime/ftplugin/clojure.vim | 12 ++-- runtime/ftplugin/ruby.vim | 44 +++++++----- runtime/indent/clojure.vim | 2 +- runtime/indent/ruby.vim | 48 ++++++++++--- runtime/syntax/clojure.vim | 42 ++++++------ runtime/syntax/debchangelog.vim | 6 +- runtime/syntax/debsources.vim | 6 +- runtime/syntax/eruby.vim | 12 ++-- runtime/syntax/ruby.vim | 16 ++++- runtime/syntax/tmux.vim | 127 ++++++++++++++++++++++------------- 16 files changed, 217 insertions(+), 141 deletions(-) (limited to 'runtime') diff --git a/runtime/autoload/clojurecomplete.vim b/runtime/autoload/clojurecomplete.vim index 9f2c39081a..02262a6f91 100644 --- a/runtime/autoload/clojurecomplete.vim +++ b/runtime/autoload/clojurecomplete.vim @@ -4,12 +4,12 @@ " Former Maintainers: Sung Pae " URL: https://github.com/clojure-vim/clojure.vim " License: Vim (see :h license) -" Last Change: 2021-10-26 +" Last Change: 2022-03-24 " -*- COMPLETION WORDS -*- -" Generated from https://github.com/clojure-vim/clojure.vim/blob/62b215f079ce0f3834fd295c7a7f6bd8cc54bcc3/clj/src/vim_clojure_static/generate.clj -" Clojure version 1.10.3 -let s:words = ["*","*'","*1","*2","*3","*agent*","*allow-unresolved-vars*","*assert*","*clojure-version*","*command-line-args*","*compile-files*","*compile-path*","*compiler-options*","*data-readers*","*default-data-reader-fn*","*e","*err*","*file*","*flush-on-newline*","*fn-loader*","*in*","*math-context*","*ns*","*out*","*print-dup*","*print-length*","*print-level*","*print-meta*","*print-namespace-maps*","*print-readably*","*read-eval*","*reader-resolver*","*source-path*","*suppress-read*","*unchecked-math*","*use-context-classloader*","*verbose-defrecords*","*warn-on-reflection*","+","+'","-","-'","->","->>","->ArrayChunk","->Eduction","->Vec","->VecNode","->VecSeq","-cache-protocol-fn","-reset-methods",".","..","/","<","<=","=","==",">",">=","EMPTY-NODE","Inst","PrintWriter-on","StackTraceElement->vec","Throwable->map","accessor","aclone","add-classpath","add-tap","add-watch","agent","agent-error","agent-errors","aget","alength","alias","all-ns","alter","alter-meta!","alter-var-root","amap","ancestors","and","any?","apply","areduce","array-map","as->","aset","aset-boolean","aset-byte","aset-char","aset-double","aset-float","aset-int","aset-long","aset-short","assert","assoc!","assoc","assoc-in","associative?","atom","await","await-for","await1","bases","bean","bigdec","bigint","biginteger","binding","bit-and","bit-and-not","bit-clear","bit-flip","bit-not","bit-or","bit-set","bit-shift-left","bit-shift-right","bit-test","bit-xor","boolean","boolean-array","boolean?","booleans","bound-fn","bound-fn*","bound?","bounded-count","butlast","byte","byte-array","bytes","bytes?","case","cast","cat","catch","char","char-array","char-escape-string","char-name-string","char?","chars","chunk","chunk-append","chunk-buffer","chunk-cons","chunk-first","chunk-next","chunk-rest","chunked-seq?","class","class?","clear-agent-errors","clojure-version","coll?","comment","commute","comp","comparator","compare","compare-and-set!","compile","complement","completing","concat","cond","cond->","cond->>","condp","conj!","conj","cons","constantly","construct-proxy","contains?","count","counted?","create-ns","create-struct","cycle","dec","dec'","decimal?","declare","dedupe","def","default-data-readers","definline","definterface","defmacro","defmethod","defmulti","defn","defn-","defonce","defprotocol","defrecord","defstruct","deftype","delay","delay?","deliver","denominator","deref","derive","descendants","destructure","disj!","disj","dissoc!","dissoc","distinct","distinct?","do","doall","dorun","doseq","dosync","dotimes","doto","double","double-array","double?","doubles","drop","drop-last","drop-while","eduction","empty","empty?","ensure","ensure-reduced","enumeration-seq","error-handler","error-mode","eval","even?","every-pred","every?","ex-cause","ex-data","ex-info","ex-message","extend","extend-protocol","extend-type","extenders","extends?","false?","ffirst","file-seq","filter","filterv","finally","find","find-keyword","find-ns","find-protocol-impl","find-protocol-method","find-var","first","flatten","float","float-array","float?","floats","flush","fn","fn","fn?","fnext","fnil","for","force","format","frequencies","future","future-call","future-cancel","future-cancelled?","future-done?","future?","gen-class","gen-interface","gensym","get","get-in","get-method","get-proxy-class","get-thread-bindings","get-validator","group-by","halt-when","hash","hash-combine","hash-map","hash-ordered-coll","hash-set","hash-unordered-coll","ident?","identical?","identity","if","if-let","if-not","if-some","ifn?","import","in-ns","inc","inc'","indexed?","init-proxy","inst-ms","inst-ms*","inst?","instance?","int","int-array","int?","integer?","interleave","intern","interpose","into","into-array","ints","io!","isa?","iterate","iterator-seq","juxt","keep","keep-indexed","key","keys","keyword","keyword?","last","lazy-cat","lazy-seq","let","let","letfn","line-seq","list","list*","list?","load","load-file","load-reader","load-string","loaded-libs","locking","long","long-array","longs","loop","loop","macroexpand","macroexpand-1","make-array","make-hierarchy","map","map-entry?","map-indexed","map?","mapcat","mapv","max","max-key","memfn","memoize","merge","merge-with","meta","method-sig","methods","min","min-key","mix-collection-hash","mod","monitor-enter","monitor-exit","munge","name","namespace","namespace-munge","nat-int?","neg-int?","neg?","new","newline","next","nfirst","nil?","nnext","not","not-any?","not-empty","not-every?","not=","ns","ns-aliases","ns-imports","ns-interns","ns-map","ns-name","ns-publics","ns-refers","ns-resolve","ns-unalias","ns-unmap","nth","nthnext","nthrest","num","number?","numerator","object-array","odd?","or","parents","partial","partition","partition-all","partition-by","pcalls","peek","persistent!","pmap","pop!","pop","pop-thread-bindings","pos-int?","pos?","pr","pr-str","prefer-method","prefers","primitives-classnames","print","print-ctor","print-dup","print-method","print-simple","print-str","printf","println","println-str","prn","prn-str","promise","proxy","proxy-call-with-super","proxy-mappings","proxy-name","proxy-super","push-thread-bindings","pvalues","qualified-ident?","qualified-keyword?","qualified-symbol?","quot","quote","rand","rand-int","rand-nth","random-sample","range","ratio?","rational?","rationalize","re-find","re-groups","re-matcher","re-matches","re-pattern","re-seq","read","read+string","read-line","read-string","reader-conditional","reader-conditional?","realized?","record?","recur","reduce","reduce-kv","reduced","reduced?","reductions","ref","ref-history-count","ref-max-history","ref-min-history","ref-set","refer","refer-clojure","reify","release-pending-sends","rem","remove","remove-all-methods","remove-method","remove-ns","remove-tap","remove-watch","repeat","repeatedly","replace","replicate","require","requiring-resolve","reset!","reset-meta!","reset-vals!","resolve","rest","restart-agent","resultset-seq","reverse","reversible?","rseq","rsubseq","run!","satisfies?","second","select-keys","send","send-off","send-via","seq","seq?","seqable?","seque","sequence","sequential?","set!","set","set-agent-send-executor!","set-agent-send-off-executor!","set-error-handler!","set-error-mode!","set-validator!","set?","short","short-array","shorts","shuffle","shutdown-agents","simple-ident?","simple-keyword?","simple-symbol?","slurp","some","some->","some->>","some-fn","some?","sort","sort-by","sorted-map","sorted-map-by","sorted-set","sorted-set-by","sorted?","special-symbol?","spit","split-at","split-with","str","string?","struct","struct-map","subs","subseq","subvec","supers","swap!","swap-vals!","symbol","symbol?","sync","tagged-literal","tagged-literal?","take","take-last","take-nth","take-while","tap>","test","the-ns","thread-bound?","throw","time","to-array","to-array-2d","trampoline","transduce","transient","tree-seq","true?","try","type","unchecked-add","unchecked-add-int","unchecked-byte","unchecked-char","unchecked-dec","unchecked-dec-int","unchecked-divide-int","unchecked-double","unchecked-float","unchecked-inc","unchecked-inc-int","unchecked-int","unchecked-long","unchecked-multiply","unchecked-multiply-int","unchecked-negate","unchecked-negate-int","unchecked-remainder-int","unchecked-short","unchecked-subtract","unchecked-subtract-int","underive","unquote","unquote-splicing","unreduced","unsigned-bit-shift-right","update","update-in","update-proxy","uri?","use","uuid?","val","vals","var","var-get","var-set","var?","vary-meta","vec","vector","vector-of","vector?","volatile!","volatile?","vreset!","vswap!","when","when-first","when-let","when-not","when-some","while","with-bindings","with-bindings*","with-in-str","with-loading-context","with-local-vars","with-meta","with-open","with-out-str","with-precision","with-redefs","with-redefs-fn","xml-seq","zero?","zipmap"] +" Generated from https://github.com/clojure-vim/clojure.vim/blob/fd280e33e84c88e97860930557dba3ff80b1a82d/clj/src/vim_clojure_static/generate.clj +" Clojure version 1.11.0 +let s:words = ["&","*","*'","*1","*2","*3","*agent*","*allow-unresolved-vars*","*assert*","*clojure-version*","*command-line-args*","*compile-files*","*compile-path*","*compiler-options*","*data-readers*","*default-data-reader-fn*","*e","*err*","*file*","*flush-on-newline*","*fn-loader*","*in*","*math-context*","*ns*","*out*","*print-dup*","*print-length*","*print-level*","*print-meta*","*print-namespace-maps*","*print-readably*","*read-eval*","*reader-resolver*","*source-path*","*suppress-read*","*unchecked-math*","*use-context-classloader*","*verbose-defrecords*","*warn-on-reflection*","+","+'","-","-'","->","->>","->ArrayChunk","->Eduction","->Vec","->VecNode","->VecSeq","-cache-protocol-fn","-reset-methods",".","..","/","<","<=","=","==",">",">=","EMPTY-NODE","Inst","NaN?","PrintWriter-on","StackTraceElement->vec","Throwable->map","abs","accessor","aclone","add-classpath","add-tap","add-watch","agent","agent-error","agent-errors","aget","alength","alias","all-ns","alter","alter-meta!","alter-var-root","amap","ancestors","and","any?","apply","areduce","array-map","as->","aset","aset-boolean","aset-byte","aset-char","aset-double","aset-float","aset-int","aset-long","aset-short","assert","assoc","assoc!","assoc-in","associative?","atom","await","await-for","await1","bases","bean","bigdec","bigint","biginteger","binding","bit-and","bit-and-not","bit-clear","bit-flip","bit-not","bit-or","bit-set","bit-shift-left","bit-shift-right","bit-test","bit-xor","boolean","boolean-array","boolean?","booleans","bound-fn","bound-fn*","bound?","bounded-count","butlast","byte","byte-array","bytes","bytes?","case","case*","cast","cat","catch","char","char-array","char-escape-string","char-name-string","char?","chars","chunk","chunk-append","chunk-buffer","chunk-cons","chunk-first","chunk-next","chunk-rest","chunked-seq?","class","class?","clear-agent-errors","clojure-version","coll?","comment","commute","comp","comparator","compare","compare-and-set!","compile","complement","completing","concat","cond","cond->","cond->>","condp","conj","conj!","cons","constantly","construct-proxy","contains?","count","counted?","create-ns","create-struct","cycle","dec","dec'","decimal?","declare","dedupe","def","default-data-readers","definline","definterface","defmacro","defmethod","defmulti","defn","defn-","defonce","defprotocol","defrecord","defstruct","deftype","deftype*","delay","delay?","deliver","denominator","deref","derive","descendants","destructure","disj","disj!","dissoc","dissoc!","distinct","distinct?","do","doall","dorun","doseq","dosync","dotimes","doto","double","double-array","double?","doubles","drop","drop-last","drop-while","eduction","empty","empty?","ensure","ensure-reduced","enumeration-seq","error-handler","error-mode","eval","even?","every-pred","every?","ex-cause","ex-data","ex-info","ex-message","extend","extend-protocol","extend-type","extenders","extends?","false","false?","ffirst","file-seq","filter","filterv","finally","find","find-keyword","find-ns","find-protocol-impl","find-protocol-method","find-var","first","flatten","float","float-array","float?","floats","flush","fn","fn*","fn?","fnext","fnil","for","force","format","frequencies","future","future-call","future-cancel","future-cancelled?","future-done?","future?","gen-class","gen-interface","gensym","get","get-in","get-method","get-proxy-class","get-thread-bindings","get-validator","group-by","halt-when","hash","hash-combine","hash-map","hash-ordered-coll","hash-set","hash-unordered-coll","ident?","identical?","identity","if","if-let","if-not","if-some","ifn?","import","in-ns","inc","inc'","indexed?","infinite?","init-proxy","inst-ms","inst-ms*","inst?","instance?","int","int-array","int?","integer?","interleave","intern","interpose","into","into-array","ints","io!","isa?","iterate","iteration","iterator-seq","juxt","keep","keep-indexed","key","keys","keyword","keyword?","last","lazy-cat","lazy-seq","let","let*","letfn","letfn*","line-seq","list","list*","list?","load","load-file","load-reader","load-string","loaded-libs","locking","long","long-array","longs","loop","loop*","macroexpand","macroexpand-1","make-array","make-hierarchy","map","map-entry?","map-indexed","map?","mapcat","mapv","max","max-key","memfn","memoize","merge","merge-with","meta","method-sig","methods","min","min-key","mix-collection-hash","mod","monitor-enter","monitor-exit","munge","name","namespace","namespace-munge","nat-int?","neg-int?","neg?","new","newline","next","nfirst","nil","nil?","nnext","not","not-any?","not-empty","not-every?","not=","ns","ns-aliases","ns-imports","ns-interns","ns-map","ns-name","ns-publics","ns-refers","ns-resolve","ns-unalias","ns-unmap","nth","nthnext","nthrest","num","number?","numerator","object-array","odd?","or","parents","parse-boolean","parse-double","parse-long","parse-uuid","partial","partition","partition-all","partition-by","pcalls","peek","persistent!","pmap","pop","pop!","pop-thread-bindings","pos-int?","pos?","pr","pr-str","prefer-method","prefers","primitives-classnames","print","print-ctor","print-dup","print-method","print-simple","print-str","printf","println","println-str","prn","prn-str","promise","proxy","proxy-call-with-super","proxy-mappings","proxy-name","proxy-super","push-thread-bindings","pvalues","qualified-ident?","qualified-keyword?","qualified-symbol?","quot","quote","rand","rand-int","rand-nth","random-sample","random-uuid","range","ratio?","rational?","rationalize","re-find","re-groups","re-matcher","re-matches","re-pattern","re-seq","read","read+string","read-line","read-string","reader-conditional","reader-conditional?","realized?","record?","recur","reduce","reduce-kv","reduced","reduced?","reductions","ref","ref-history-count","ref-max-history","ref-min-history","ref-set","refer","refer-clojure","reify","reify*","release-pending-sends","rem","remove","remove-all-methods","remove-method","remove-ns","remove-tap","remove-watch","repeat","repeatedly","replace","replicate","require","requiring-resolve","reset!","reset-meta!","reset-vals!","resolve","rest","restart-agent","resultset-seq","reverse","reversible?","rseq","rsubseq","run!","satisfies?","second","select-keys","send","send-off","send-via","seq","seq-to-map-for-destructuring","seq?","seqable?","seque","sequence","sequential?","set","set!","set-agent-send-executor!","set-agent-send-off-executor!","set-error-handler!","set-error-mode!","set-validator!","set?","short","short-array","shorts","shuffle","shutdown-agents","simple-ident?","simple-keyword?","simple-symbol?","slurp","some","some->","some->>","some-fn","some?","sort","sort-by","sorted-map","sorted-map-by","sorted-set","sorted-set-by","sorted?","special-symbol?","spit","split-at","split-with","str","string?","struct","struct-map","subs","subseq","subvec","supers","swap!","swap-vals!","symbol","symbol?","sync","tagged-literal","tagged-literal?","take","take-last","take-nth","take-while","tap>","test","the-ns","thread-bound?","throw","time","to-array","to-array-2d","trampoline","transduce","transient","tree-seq","true","true?","try","type","unchecked-add","unchecked-add-int","unchecked-byte","unchecked-char","unchecked-dec","unchecked-dec-int","unchecked-divide-int","unchecked-double","unchecked-float","unchecked-inc","unchecked-inc-int","unchecked-int","unchecked-long","unchecked-multiply","unchecked-multiply-int","unchecked-negate","unchecked-negate-int","unchecked-remainder-int","unchecked-short","unchecked-subtract","unchecked-subtract-int","underive","unquote","unquote-splicing","unreduced","unsigned-bit-shift-right","update","update-in","update-keys","update-proxy","update-vals","uri?","use","uuid?","val","vals","var","var-get","var-set","var?","vary-meta","vec","vector","vector-of","vector?","volatile!","volatile?","vreset!","vswap!","when","when-first","when-let","when-not","when-some","while","with-bindings","with-bindings*","with-in-str","with-loading-context","with-local-vars","with-meta","with-open","with-out-str","with-precision","with-redefs","with-redefs-fn","xml-seq","zero?","zipmap"] " Simple word completion for special forms and public vars in clojure.core function! clojurecomplete#Complete(findstart, base) diff --git a/runtime/autoload/python3complete.vim b/runtime/autoload/python3complete.vim index 192e9e6df8..b0781864c5 100644 --- a/runtime/autoload/python3complete.vim +++ b/runtime/autoload/python3complete.vim @@ -2,7 +2,7 @@ " Maintainer: " Previous Maintainer: Aaron Griffin " Version: 0.9 -" Last Updated: 2020 Oct 9 +" Last Updated: 2022 Mar 30 " " Roland Puntaier: this file contains adaptations for python3 and is parallel to pythoncomplete.vim " @@ -91,6 +91,9 @@ endfunction function! s:DefPython() py3 << PYTHONEOF +import warnings +warnings.simplefilter(action='ignore', category=FutureWarning) + import sys, tokenize, io, types from token import NAME, DEDENT, NEWLINE, STRING diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt index 54fb4c14a0..7cfac4b5d1 100644 --- a/runtime/doc/autocmd.txt +++ b/runtime/doc/autocmd.txt @@ -499,10 +499,10 @@ CursorMoved After the cursor was moved in Normal or Visual mode or to another window. Also when the text of the cursor line has been changed, e.g. with "x", "rx" or "p". - Not triggered when there is typeahead, while - executing a script file, or when an operator - is pending. Always triggered when moving to - another window. + Not always triggered when there is typeahead, + while executing commands in a script file, or + when an operator is pending. Always triggered + when moving to another window. For an example see |match-parens|. Note: Cannot be skipped with |:noautocmd|. Careful: This is triggered very often, don't diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 14353662d1..062f39f3e7 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -1319,14 +1319,15 @@ confirm({msg} [, {choices} [, {default} [, {type}]]]) or another valid interrupt key, confirm() returns 0. An example: > - :let choice = confirm("What do you want?", "&Apples\n&Oranges\n&Bananas", 2) - :if choice == 0 - : echo "make up your mind!" - :elseif choice == 3 - : echo "tasteful" - :else - : echo "I prefer bananas myself." - :endif + let choice = confirm("What do you want?", + \ "&Apples\n&Oranges\n&Bananas", 2) + if choice == 0 + echo "make up your mind!" + elseif choice == 3 + echo "tasteful" + else + echo "I prefer bananas myself." + endif < In a GUI dialog, buttons are used. The layout of the buttons depends on the 'v' flag in 'guioptions'. If it is included, the buttons are always put vertically. Otherwise, confirm() diff --git a/runtime/doc/insert.txt b/runtime/doc/insert.txt index cd6c2c8622..05bf0fe4ba 100644 --- a/runtime/doc/insert.txt +++ b/runtime/doc/insert.txt @@ -780,7 +780,7 @@ If the previous expansion was split, because it got longer than 'textwidth', then just the text in the current line will be used. If the match found is at the end of a line, then the first word in the next -line will be inserted and the message "word from next line" displayed, if +line will be inserted and the message "Word from other line" displayed, if this word is accepted the next CTRL-X CTRL-P or CTRL-X CTRL-N will search for those lines starting with this word. diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index c0a7b73438..b825a5fe15 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -751,7 +751,8 @@ A jump table for the options with a short description can be found at |Q_op|. nostop like start, except CTRL-W and CTRL-U do not stop at the start of insert. - When the value is empty, Vi compatible backspacing is used. + When the value is empty, Vi compatible backspacing is used, none of + the ways mentioned for the items above are possible. For backwards compatibility with version 5.4 and earlier: value effect ~ diff --git a/runtime/ftplugin/clojure.vim b/runtime/ftplugin/clojure.vim index 81d53b1227..c922d75699 100644 --- a/runtime/ftplugin/clojure.vim +++ b/runtime/ftplugin/clojure.vim @@ -5,7 +5,7 @@ " Meikel Brandmeyer " URL: https://github.com/clojure-vim/clojure.vim " License: Vim (see :h license) -" Last Change: 2021-10-26 +" Last Change: 2022-03-24 if exists("b:did_ftplugin") finish @@ -43,7 +43,7 @@ setlocal commentstring=;\ %s " specially and hence are not indented specially. " " -*- LISPWORDS -*- -" Generated from https://github.com/clojure-vim/clojure.vim/blob/62b215f079ce0f3834fd295c7a7f6bd8cc54bcc3/clj/src/vim_clojure_static/generate.clj +" Generated from https://github.com/clojure-vim/clojure.vim/blob/fd280e33e84c88e97860930557dba3ff80b1a82d/clj/src/vim_clojure_static/generate.clj setlocal lispwords=as->,binding,bound-fn,case,catch,cond->,cond->>,condp,def,definline,definterface,defmacro,defmethod,defmulti,defn,defn-,defonce,defprotocol,defrecord,defstruct,deftest,deftest-,deftype,doseq,dotimes,doto,extend,extend-protocol,extend-type,fn,for,if,if-let,if-not,if-some,let,letfn,locking,loop,ns,proxy,reify,set-test,testing,when,when-first,when-let,when-not,when-some,while,with-bindings,with-in-str,with-local-vars,with-open,with-precision,with-redefs,with-redefs-fn,with-test " Provide insert mode completions for special forms and clojure.core. As @@ -66,10 +66,10 @@ endif " Filter files in the browse dialog if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") - let b:browsefilter = "Clojure Source Files (*.clj)\t*.clj\n" . - \ "ClojureScript Source Files (*.cljs)\t*.cljs\n" . - \ "Java Source Files (*.java)\t*.java\n" . - \ "All Files (*.*)\t*.*\n" + let b:browsefilter = "All Files\t*\n" . + \ "Clojure Files\t*.clj;*.cljc;*.cljs;*.cljx\n" . + \ "EDN Files\t*.edn\n" . + \ "Java Files\t*.java\n" let b:undo_ftplugin .= ' | unlet! b:browsefilter' endif diff --git a/runtime/ftplugin/ruby.vim b/runtime/ftplugin/ruby.vim index 4a476fd8cf..8c1f47731c 100644 --- a/runtime/ftplugin/ruby.vim +++ b/runtime/ftplugin/ruby.vim @@ -3,7 +3,7 @@ " Maintainer: Tim Pope " URL: https://github.com/vim-ruby/vim-ruby " Release Coordinator: Doug Kearns -" Last Change: 2020 Feb 13 +" Last Change: 2022 Mar 21 if (exists("b:did_ftplugin")) finish @@ -53,7 +53,7 @@ endif " TODO: "setlocal define=^\\s*def -setlocal comments=:# +setlocal comments=b:# setlocal commentstring=#\ %s if !exists('g:ruby_version_paths') @@ -87,8 +87,14 @@ endfunction function! s:build_path(path) abort let path = join(map(copy(a:path), 'v:val ==# "." ? "" : v:val'), ',') - if &g:path !~# '\v^%(\.,)=%(/%(usr|emx)/include,)=,$' - let path = substitute(&g:path,',,$',',','') . ',' . path + if &g:path =~# '\v^%(\.,)=%(/%(usr|emx)/include,)=,$' + let path = path . ',.,,' + elseif &g:path =~# ',\.,,$' + let path = &g:path[0:-4] . path . ',.,,' + elseif &g:path =~# ',,$' + let path = &g:path[0:-2] . path . ',,' + else + let path = substitute(&g:path, '[^,]\zs$', ',', '') . path endif return path endfunction @@ -164,6 +170,8 @@ let b:undo_ftplugin .= "| sil! cunmap | sil! cunmap