neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 9b768d6b3d4087109d1fe697d3584a7699ba9f32
parent 7a866e6b2008472cceef49d05533d2988c838bff
Author: Justin M. Keyes <justinkz@gmail.com>
Date:   Mon, 15 Dec 2025 23:10:33 -0500

Merge #36860 from justinmk/doc2


Diffstat:
MMAINTAIN.md | 6+++---
Mbuild.zig.zon | 4++--
Mcmake.deps/deps.txt | 4++--
Mruntime/doc/api-ui-events.txt | 4----
Mruntime/doc/api.txt | 46++++++++++++++++++++++++++++------------------
Mruntime/doc/change.txt | 168++++++++++++++++++++++++++++++++++++++++++++++---------------------------------
Mruntime/doc/channel.txt | 18+++++++-----------
Mruntime/doc/dev.txt | 3+--
Mruntime/doc/dev_vimpatch.txt | 10++--------
Mruntime/doc/diagnostic.txt | 11++++-------
Mruntime/doc/insert.txt | 53+++++++++++++++++++++++++----------------------------
Mruntime/doc/lsp.txt | 7+------
Mruntime/doc/lua-guide.txt | 2--
Mruntime/doc/lua-plugin.txt | 2--
Mruntime/doc/lua.txt | 12++++++++----
Mruntime/doc/luaref.txt | 10+++++-----
Mruntime/doc/mbyte.txt | 2+-
Mruntime/doc/nvim.txt | 6+++---
Mruntime/doc/pattern.txt | 8++++----
Mruntime/doc/pi_msgpack.txt | 24+++---------------------
Mruntime/doc/plugins.txt | 29++++++++++++++++++++++-------
Mruntime/doc/usr_27.txt | 6+++---
Mruntime/doc/windows.txt | 48+++++++++++++++++++++++++-----------------------
Mruntime/lua/editorconfig.lua | 25++++++++++++++++++++-----
Mruntime/lua/vim/_meta/builtin.lua | 9+++++----
Mruntime/lua/vim/lsp/health.lua | 4+++-
Mruntime/lua/vim/shared.lua | 1+
Msrc/clint.lua | 2+-
Msrc/gen/gen_help_html.lua | 90++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------
Msrc/nvim/api/vim.c | 29++++++++++++++++++++---------
Msrc/nvim/drawline.c | 3++-
Msrc/nvim/grid.c | 18+++++++++---------
Mtest/functional/script/clint_spec.lua | 4++--
33 files changed, 376 insertions(+), 292 deletions(-)

diff --git a/MAINTAIN.md b/MAINTAIN.md @@ -246,8 +246,8 @@ Multiple Vim versions are tracked in `version.c`, so that `has('patch-x.y.z')` works even if `v:version` is "behind". Whenever we "complete" merging all patches from a Vim `v:version`, the steps to bump `v:version` are: -1. Remove the fully-merged version from `version.c:Versions`. -2. Adjust the regexp in `vim-patch.sh`. For example to remove 8.1: +1. Remove the fully-merged version from `vim-patch.sh` by adjusting the regexp. + For example, to remove version "8.1": ```diff diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh index d64f6b6..1d3dcdf 100755 @@ -263,7 +263,7 @@ patches from a Vim `v:version`, the steps to bump `v:version` are: git -C "${NVIM_SOURCE_DIR}" log --format="%s%n%b" -E --grep="^[* ]*vim-patch:${patch_pat}" | grep -oE "^[* ]*vim-patch:${patch_pat}" | ``` -3. Run `nvim -l scripts/vimpatch.lua` to regenerate `version.c`. Or wait for the +2. Run `nvim -l scripts/vimpatch.lua` to regenerate `version.c`. Or wait for the `vim_patches.yml` CI job to do it. diff --git a/build.zig.zon b/build.zig.zon @@ -57,8 +57,8 @@ .hash = "N-V-__8AAMArVAB4uo2wg2XRs8HBviQ4Pq366cC_iRolX4Vc", }, .treesitter_vimdoc = .{ - .url = "git+https://github.com/neovim/tree-sitter-vimdoc?ref=v4.0.2#1cf949678153b63a280dabff92567752563d65f4", - .hash = "N-V-__8AAJiQCgDlPQgrd6tAJq-g2lNkYgZlFaI7NBPKtVCx", + .url = "git+https://github.com/neovim/tree-sitter-vimdoc?ref=v4.1.0#f061895a0eff1d5b90e4fb60d21d87be3267031a", + .hash = "N-V-__8AAI7VCgBqRcQ-vIxB8DJJFhmLG42p6rfwCWIdypSJ", }, .treesitter_query = .{ .url = "git+https://github.com/tree-sitter-grammars/tree-sitter-query?ref=v0.8.0#a225e21d81201be77da58de614e2b7851735677a", diff --git a/cmake.deps/deps.txt b/cmake.deps/deps.txt @@ -40,8 +40,8 @@ TREESITTER_LUA_URL https://github.com/tree-sitter-grammars/tree-sitter-lua/archi TREESITTER_LUA_SHA256 b0977aced4a63bb75f26725787e047b8f5f4a092712c840ea7070765d4049559 TREESITTER_VIM_URL https://github.com/tree-sitter-grammars/tree-sitter-vim/archive/v0.7.0.tar.gz TREESITTER_VIM_SHA256 44eabc31127c4feacda19f2a05a5788272128ff561ce01093a8b7a53aadcc7b2 -TREESITTER_VIMDOC_URL https://github.com/neovim/tree-sitter-vimdoc/archive/v4.0.2.tar.gz -TREESITTER_VIMDOC_SHA256 13f2dd182436e0b75db33cc1d097ab0442e0c3135375998f15331dbe9c6b74ab +TREESITTER_VIMDOC_URL https://github.com/neovim/tree-sitter-vimdoc/archive/v4.1.0.tar.gz +TREESITTER_VIMDOC_SHA256 020e8f117f648c8697fca967995c342e92dbd81dab137a115cc7555207fbc84f TREESITTER_QUERY_URL https://github.com/tree-sitter-grammars/tree-sitter-query/archive/v0.8.0.tar.gz TREESITTER_QUERY_SHA256 c2b23b9a54cffcc999ded4a5d3949daf338bebb7945dece229f832332e6e6a7d TREESITTER_MARKDOWN_URL https://github.com/tree-sitter-grammars/tree-sitter-markdown/archive/v0.5.1.tar.gz diff --git a/runtime/doc/api-ui-events.txt b/runtime/doc/api-ui-events.txt @@ -135,18 +135,14 @@ procedure: 1. Invoke |nvim_get_api_info()|, if needed to setup the client library and/or to get the list of supported UI extensions. - 2. Do any configuration that should be happen before user config is loaded. Buffers and windows are not available at this point, but this could be used to set |g:| variables visible to init.vim - 3. If the UI wants to do additional setup after user config is loaded, register a VimEnter autocmd: >lua nvim_command("autocmd VimEnter * call rpcrequest(1, 'vimenter')") - 4. Now invoke |nvim_ui_attach()|. The UI must handle user input by now: sourcing init.vim and loading buffers might lead to blocking prompts. - 5. If step 3 was used, Nvim will send a blocking "vimenter" request to the UI. Inside this request handler, the UI can safely do any initialization before entering normal mode, for example reading variables set by init.vim. diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt @@ -204,18 +204,17 @@ About the `functions` map: External programs (clients) can use the metadata to discover the API, using any of these approaches: - 1. Connect to a running Nvim instance and call |nvim_get_api_info()| via - msgpack-RPC. This is best for clients written in dynamic languages which - can define functions at runtime. - - 2. Start Nvim with |--api-info|. Useful for statically-compiled clients. - Example (requires Python "pyyaml" and "msgpack-python" modules): > +1. Connect to a running Nvim instance and call |nvim_get_api_info()| via + msgpack-RPC. This is best for clients written in dynamic languages which + can define functions at runtime. +2. Use the |--api-info| startup arg. Useful for statically-compiled clients. + Example (requires Python "pyyaml" and "msgpack-python" modules): > nvim --api-info | python -c 'import msgpack, sys, yaml; yaml.dump(msgpack.unpackb(sys.stdin.buffer.read()), sys.stdout)' -< - 3. Use the |api_info()| Vimscript function. >vim +3. Use the |api_info()| function. >vim :lua vim.print(vim.fn.api_info()) -< Example using |filter()| to exclude non-deprecated API functions: >vim + " Example using filter() to exclude non-deprecated API functions: :new|put =map(filter(api_info().functions, '!has_key(v:val,''deprecated_since'')'), 'v:val.name') +< ============================================================================== API contract *api-contract* @@ -282,9 +281,9 @@ nvim_buf_lines_event[{buf}, {changedtick}, {firstline}, {lastline}, {linedata}, part of your request to ensure that no other changes have been made. {firstline} integer line number of the first line that was replaced. - Zero-indexed: if line 1 was replaced then {firstline} will be 0, not - 1. {firstline} is always less than or equal to the number of lines - that were in the buffer before the lines were replaced. + Zero-indexed: if line 1 was replaced then {firstline} will be zero, + not one. {firstline} is always less than or equal to the number of + lines that were in the buffer before the lines were replaced. {lastline} integer line number of the first line that was not replaced (i.e. the range {firstline}, {lastline} is end-exclusive). @@ -745,22 +744,33 @@ nvim_eval_statusline({str}, {opts}) *nvim_eval_statusline()* priority last). nvim_exec_lua({code}, {args}) *nvim_exec_lua()* - Execute Lua code. Parameters (if any) are available as `...` inside the - chunk. The chunk can return a value. + Executes Lua code. Arguments are available as `...` inside the chunk. The + chunk can return a value. Only statements are executed. To evaluate an expression, prefix it with - `return`: return my_function(...) + "return": `return my_function(...)` + + Example: >lua + local peer = vim.fn.jobstart({ vim.v.progpath, '--clean', '--embed' }, { rpc=true }) + vim.print(vim.rpcrequest(peer, 'nvim_exec_lua', [[ + local a, b = ... + return ('result: %s'):format(a + b) + ]], + { 1, 3 } + ) + ) +< Attributes: ~ |RPC| only Since: 0.5.0 Parameters: ~ - • {code} (`string`) Lua code to execute - • {args} (`any[]`) Arguments to the code + • {code} (`string`) Lua code to execute. + • {args} (`any[]`) Arguments to the Lua code. Return: ~ - (`any`) Return value of Lua code if present or NIL. + (`any`) Value returned by the Lua code (if any), or NIL. nvim_feedkeys({keys}, {mode}, {escape_ks}) *nvim_feedkeys()* Sends input-keys to Nvim, subject to various quirks controlled by `mode` diff --git a/runtime/doc/change.txt b/runtime/doc/change.txt @@ -369,18 +369,18 @@ CTRL-A Add [count] to the number or alphabetic character at highlighted, each one will be incremented by an additional [count] (so effectively creating a [count] incrementing sequence). - For Example, if you have this list of numbers: - 1. ~ - 1. ~ - 1. ~ - 1. ~ - Move to the second "1." and Visually select three - lines, pressing g CTRL-A results in: - 1. ~ - 2. ~ - 3. ~ - 4. ~ - + For Example, if you have this list of numbers: > + 1. + 1. + 1. + 1. +< Move to the second "1." and Visually select three + lines, pressing g CTRL-A results in: > + 1. + 2. + 3. + 4. +< *CTRL-X* CTRL-X Subtract [count] from the number or alphabetic character at or after the cursor. @@ -1207,7 +1207,10 @@ Rationale: In Vi the "y" command followed by a backwards motion would With a linewise yank command the cursor is put in the first line, but the column is unmodified, thus it may not be on the first yanked character. -There are ten types of registers: *registers* *{register}* *E354* +============================================================================= +Registers *registers* *{register}* *E354* + +There are ten types of registers: 1. The unnamed register "" 2. 10 numbered registers "0 to "9 3. The small delete register "- @@ -1219,7 +1222,9 @@ There are ten types of registers: *registers* *{register}* *E354* 9. The black hole register "_ 10. Last search pattern register "/ -1. Unnamed register "" *quote_quote* *quotequote* +----------------------------------------------------------------------------- +1. Unnamed register "" *quote_quote* *quotequote* + Vim fills this register with text deleted with the "d", "c", "s", "x" commands or copied with the yank "y" command, regardless of whether or not a specific register was used (e.g. "xdd). This is like the unnamed register is pointing @@ -1232,20 +1237,25 @@ which does not specify a register. Additionally you can access it with the name '"'. This means you have to type two double quotes. Writing to the "" register writes to register "0. -2. Numbered registers "0 to "9 *quote_number* *quote0* *quote1* - *quote2* *quote3* *quote4* *quote9* +----------------------------------------------------------------------------- +2. Numbered registers "0 to "9 *quote_number* + *quote0* *quote1* *quote2* *quote3* *quote4* *quote9* + Vim fills these registers with text from yank and delete commands. - Numbered register 0 contains the text from the most recent yank command, +Numbered register 0 contains the text from the most recent yank command, unless the command specified another register with ["x]. - Numbered register 1 contains the text deleted by the most recent delete or + +Numbered register 1 contains the text deleted by the most recent delete or change command (even when the command specified another register), unless the text is less than one line (the small delete register is used then). An exception is made for the delete operator with these movement commands: |%|, |(|, |)|, |`|, |/|, |?|, |n|, |N|, |{| and |}|. + Register "1 is always used then (this is Vi compatible). The "- register is used as well if the delete is within a line. Note that these characters may be mapped. E.g. |%| is mapped by the matchit plugin. - With each successive deletion or change, Vim shifts the previous contents + +With each successive deletion or change, Vim shifts the previous contents of register 1 into register 2, 2 into 3, and so forth, losing the previous contents of register 9. *yankring* @@ -1260,92 +1270,110 @@ To also store yanks (not only deletions) in registers 1-9, try this: >lua end end, }) +< +----------------------------------------------------------------------------- +3. Small delete register "- *quote_-* *quote-* -3. Small delete register "- *quote_-* *quote-* This register contains text from commands that delete less than one line, except when the command specifies a register with ["x]. -4. Named registers "a to "z or "A to "Z *quote_alpha* *quotea* +----------------------------------------------------------------------------- +4. Named registers "a to "z or "A to "Z *quote_alpha* *quotea* + Vim fills these registers only when you say so. Specify them as lowercase letters to replace their previous contents or as uppercase letters to append to their previous contents. When the '>' flag is present in 'cpoptions' then a line break is inserted before the appended text. +----------------------------------------------------------------------------- 5. Read-only registers ":, ". and "% + These are '%', ':' and '.'. You can use them only with the "p", "P", and ":put" commands and with CTRL-R. + *quote_.* *quote.* *E29* - ". Contains the last inserted text (the same as what is inserted - with the insert mode commands CTRL-A and CTRL-@). Note: this - doesn't work with CTRL-R on the command-line. It works a bit - differently, like inserting the text instead of putting it - ('textwidth' and other options affect what is inserted). + - ". Contains the last inserted text (the same as what is inserted + with the insert mode commands CTRL-A and CTRL-@). Note: this doesn't + work with CTRL-R on the command-line. It works a bit differently, + like inserting the text instead of putting it ('textwidth' and other + options affect what is inserted). *quote_%* *quote%* - "% Contains the name of the current file. + - "% Contains the name of the current file. *quote_:* *quote:* *E30* - ": Contains the most recent executed command-line. Example: Use - "@:" to repeat the previous command-line command. - The command-line is only stored in this register when at least - one character of it was typed. Thus it remains unchanged if - the command was executed completely from a mapping. - - *quote_#* *quote#* -6. Alternate file register "# + - ": Contains the most recent executed command-line. Example: Use + "@:" to repeat the previous command-line command. The command-line is + only stored in this register when at least one character of it was + typed. Thus it remains unchanged if the command was executed + completely from a mapping. + +----------------------------------------------------------------------------- +6. Alternate file register "# *quote_#* *quote#* + Contains the name of the alternate file for the current window. It will -change how the |CTRL-^| command works. -This register is writable, mainly to allow for restoring it after a plugin has -changed it. It accepts buffer number: > - let altbuf = bufnr(@#) - ... - let @# = altbuf +change how the |CTRL-^| command works. This register is writable, mainly to +allow for restoring it after a plugin has +changed it. + +It accepts buffer number: > + let altbuf = bufnr(@#) + ... + let @# = altbuf + It will give error |E86| if you pass buffer number and this buffer does not exist. + It can also accept a match with an existing buffer name: > - let @# = 'buffer_name' -Error |E93| if there is more than one buffer matching the given name or |E94| -if none of buffers matches the given name. + let @# = 'buffer_name' + +Error |E93| if there is more than one buffer matching the given name or +|E94| if none of buffers matches the given name. + +----------------------------------------------------------------------------- +7. Expression register "= *quote_=* *quote=* *@=* -7. Expression register "= *quote_=* *quote=* *@=* This is not really a register that stores text, but is a way to use an expression in commands which use a register. The expression register is read-write. -When typing the '=' after " or CTRL-R the cursor moves to the command-line, -where you can enter any expression (see |expression|). All normal -command-line editing commands are available, including a special history for -expressions. When you end the command-line by typing <CR>, Vim computes the -result of the expression. If you end it with <Esc>, Vim abandons the -expression. If you do not enter an expression, Vim uses the previous -expression (like with the "/" command). - -The expression must evaluate to a String. A Number is always automatically -converted to a String. For the "p" and ":put" command, if the result is a -Float it's converted into a String. If the result is a List each element is -turned into a String and used as a line. A Dictionary is converted into a -String. A Funcref results in an error message (use string() to convert). - -If the "= register is used for the "p" command, the String is split up at <NL> -characters. If the String ends in a <NL>, it is regarded as a linewise -register. - +- When typing the '=' after " or CTRL-R the cursor moves to the command-line, + where you can enter any expression (see |expression|). All normal + command-line editing commands are available, including a special history for + expressions. When you end the command-line by typing <CR>, Vim computes the + result of the expression. If you end it with <Esc>, Vim abandons the + expression. If you do not enter an expression, Vim uses the previous + expression (like with the "/" command). +- The expression must evaluate to a String. A Number is always automatically + converted to a String. For the "p" and ":put" command, if the result is + a Float it's converted into a String. If the result is a List each element + is turned into a String and used as a line. A Dictionary is converted into + a String. A Funcref results in an error message (use string() to convert). +- If the "= register is used for the "p" command, the String is split up at + <NL> characters. If the String ends in a <NL>, it is regarded as a linewise + register. + +----------------------------------------------------------------------------- 8. Selection registers "* and "+ + Use these registers for storing and retrieving the selected text for the GUI. See |quotestar| and |quoteplus|. When the clipboard is not available or not working, the unnamed register is used instead. For Unix systems and Mac OS X, see |primary-selection|. -9. Black hole register "_ *quote_* +----------------------------------------------------------------------------- +9. Black hole register "_ *quote_* + When writing to this register, nothing happens. This can be used to delete -text without affecting the normal registers. When reading from this register, -nothing is returned. +text without affecting the normal registers. When reading from this +register, nothing is returned. + +----------------------------------------------------------------------------- +10. Last search pattern register "/ *quote_/* *quote/* -10. Last search pattern register "/ *quote_/* *quote/* Contains the most recent search-pattern. This is used for "n" and 'hlsearch'. It is writable with `:let`, you can change it to have 'hlsearch' highlight other matches without actually searching. You can't yank or delete into this -register. The search direction is available in |v:searchforward|. -Note that the value is restored when returning from a function -|function-search-undo|. +register. The search direction is available in |v:searchforward|. Note that +the value is restored when returning from a function |function-search-undo|. *@/* You can write to a register with a `:let` command |:let-@|. Example: > diff --git a/runtime/doc/channel.txt b/runtime/doc/channel.txt @@ -15,17 +15,13 @@ Channels are Nvim's way of communicating with external processes. There are several ways to open a channel: - 1. Through stdin/stdout when `nvim` is started with `--headless` and a startup - script or `--cmd` command opens the stdio channel using |stdioopen()|. - - 2. Through stdin, stdout and stderr of a process spawned by |jobstart()|. - - 3. Through the PTY master end opened with `jobstart(…, {'pty': v:true})`. - - 4. By connecting to a TCP/IP socket or named pipe with |sockconnect()|. - - 5. By another process connecting to a socket listened to by Nvim. This only - supports RPC channels, see |rpc-connecting|. +1. Through stdin/stdout when `nvim` is started with `--headless` and a startup + script or `--cmd` command opens the stdio channel using |stdioopen()|. +2. Through stdin, stdout and stderr of a process spawned by |jobstart()|. +3. Through the PTY master end opened with `jobstart(…, {'pty': v:true})`. +4. By connecting to a TCP/IP socket or named pipe with |sockconnect()|. +5. By another process connecting to a socket listened to by Nvim. This only + supports RPC channels, see |rpc-connecting|. Channels support multiple modes or protocols. In the most basic mode of operation, raw bytes are read and written to the channel. diff --git a/runtime/doc/dev.txt b/runtime/doc/dev.txt @@ -92,7 +92,6 @@ Examples: 1. In the Vim source code, clipboard logic accounts for more than 1k lines of C source code (ui.c), to perform two tasks that are now accomplished with shell commands such as xclip or pbcopy/pbpaste. - 2. Python scripting support: Vim has three files dedicated to embedding the Python interpreter: if_python.c, if_python3.c and if_py_both.h. Together these files sum about 9.5k lines of C source code. In contrast, Nvim Python @@ -340,7 +339,7 @@ preference): 4. `on_error` callback - For async and "visitors" traversing a graph, where many errors may be collected while work continues. -5. `vim.notify` (sometimes with optional `opts.silent` (async, visitors ^)) +5. `vim.notify` (sometimes with optional `opts.silent` (async, visitors)) - High-level / application-level messages. End-user invokes these directly. *dev-patterns* diff --git a/runtime/doc/dev_vimpatch.txt b/runtime/doc/dev_vimpatch.txt @@ -22,19 +22,13 @@ See |dev-vimpatch-quickstart| to get started immediately. ============================================================================== QUICKSTART *dev-vimpatch-quickstart* -1. Pull the Nvim source: ->bash - git clone https://github.com/neovim/neovim.git -< +1. Pull the Nvim source: >bash + git clone https://github.com/neovim/neovim.git 2. Run `./scripts/vim-patch.sh -l` to see the list of missing Vim patches. - 3. Choose a patch from the list (usually the oldest one), e.g. `8.0.0123`. - - Check for open vim-patch PRs https://github.com/neovim/neovim/pulls?q=is%3Apr+is%3Aopen+label%3Avim-patch. - 4. Run `./scripts/vim-patch.sh -p 8.0.0123` - 5. Follow the instructions given by the script. NOTES ~ diff --git a/runtime/doc/diagnostic.txt b/runtime/doc/diagnostic.txt @@ -40,7 +40,7 @@ requires a namespace. *vim.diagnostic.severity* *diagnostic-severity* The "severity" key in a diagnostic is one of the values defined in -`vim.diagnostic.severity`: +`vim.diagnostic.severity`: > vim.diagnostic.severity.ERROR vim.diagnostic.severity.WARN @@ -54,20 +54,17 @@ Functions that take a severity as an optional parameter (e.g. vim.diagnostic.get(0, { severity = vim.diagnostic.severity.WARN }) -2. A table with a "min" or "max" key (or both): >lua +2. A table with a "min" or "max" key (or both). This form allows users to + specify a range of severities: >lua vim.diagnostic.get(0, { severity = { min = vim.diagnostic.severity.WARN } }) -< - This form allows users to specify a range of severities. - -3. A list-like table: >lua +3. A list-like table. This form allows filtering for specific severities: >lua vim.diagnostic.get(0, { severity = { vim.diagnostic.severity.WARN, vim.diagnostic.severity.INFO, } }) < - This form allows users to filter for specific severities ============================================================================== DEFAULTS *diagnostic-defaults* diff --git a/runtime/doc/insert.txt b/runtime/doc/insert.txt @@ -1620,30 +1620,27 @@ The completions provided by CTRL-X CTRL-O are sensitive to the context: CONTEXT COMPLETIONS PROVIDED ~ - 1. Not inside a class definition Classes, constants and globals - - 2. Inside a class definition Methods or constants defined in the class - - 3. After '.', '::' or ':' Methods applicable to the object being - dereferenced - - 4. After ':' or ':foo' Symbol name (beginning with "foo") + 1. Not inside a class definition: Classes, constants and globals + 2. Inside a class definition: Methods or constants defined in the class + 3. After '.', '::' or ':': Methods applicable to the object being + dereferenced + 4. After ':' or ':foo': Symbol name (beginning with "foo") Notes: - - Vim will load/evaluate code in order to provide completions. This may - cause some code execution, which may be a concern. This is no longer - enabled by default, to enable this feature add > +- Vim will load/evaluate code in order to provide completions. This may + cause some code execution, which may be a concern. This is no longer + enabled by default, to enable this feature add > let g:rubycomplete_buffer_loading = 1 -<- In context 1 above, Vim can parse the entire buffer to add a list of - classes to the completion results. This feature is turned off by default, - to enable it add > +- In context 1 above, Vim can parse the entire buffer to add a list of + classes to the completion results. This feature is turned off by default, + to enable it add > let g:rubycomplete_classes_in_global = 1 < to your vimrc - - In context 2 above, anonymous classes are not supported. - - In context 3 above, Vim will attempt to determine the methods supported by - the object. - - Vim can detect and load the Rails environment for files within a rails - project. The feature is disabled by default, to enable it add > +- In context 2 above, anonymous classes are not supported. +- In context 3 above, Vim will attempt to determine the methods supported by + the object. +- Vim can detect and load the Rails environment for files within a rails + project. The feature is disabled by default, to enable it add > let g:rubycomplete_rails = 1 < to your vimrc @@ -1737,15 +1734,15 @@ SQL file (:e syntax.sql) you can use the ":syntax list" command to see the various groups and syntax items. For example: > syntax list -Yields data similar to this: - sqlOperator xxx some prior all like and any escape exists in is not ~ - or intersect minus between distinct ~ - links to Operator ~ - sqlType xxx varbit varchar nvarchar bigint int uniqueidentifier ~ - date money long tinyint unsigned xml text smalldate ~ - double datetime nchar smallint numeric time bit char ~ - varbinary binary smallmoney ~ - image float integer timestamp real decimal ~ +Yields data similar to this: > + sqlOperator xxx some prior all like and any escape exists in is not + or intersect minus between distinct + links to Operator + sqlType xxx varbit varchar nvarchar bigint int uniqueidentifier + date money long tinyint unsigned xml text smalldate + double datetime nchar smallint numeric time bit char + varbinary binary smallmoney + image float integer timestamp real decimal There are two syntax groups listed here: sqlOperator and sqlType. To retrieve a List of syntax items you can call OmniSyntaxList a number of different diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt @@ -27,7 +27,6 @@ Follow these steps to get LSP features: 1. Install language servers using your package manager or by following the upstream installation instructions. You can find language servers here: https://microsoft.github.io/language-server-protocol/implementors/servers/ - 2. Define a new config |lsp-new-config| (or install https://github.com/neovim/nvim-lspconfig). Example: >lua vim.lsp.config['lua_ls'] = { @@ -49,18 +48,14 @@ Follow these steps to get LSP features: } } } - 3. Use |vim.lsp.enable()| to enable the config. Example: >lua vim.lsp.enable('lua_ls') -< 4. Open a code file matching one of the `filetypes` specified in the config. Note: Depending on the LSP server, you may need to ensure your project has a |lsp-root_markers| file so the workspace can be recognized. - 5. Check that LSP is active ("attached") for the buffer: >vim - :checkhealth vim.lsp -< + :checkhealth vim.lsp 6. (Optional) Configure keymaps and autocommands to use LSP features. |lsp-attach| diff --git a/runtime/doc/lua-guide.txt b/runtime/doc/lua-guide.txt @@ -33,10 +33,8 @@ layers: as well as |user-function|s in Vimscript. These are accessed through |vim.cmd()| and |vim.fn| respectively, which are discussed under |lua-guide-vimscript| below. - 2. The "Nvim API" written in C for use in remote plugins and GUIs; see |api|. These functions are accessed through |vim.api|. - 3. The "Lua API" written in and specifically for Lua. These are any other functions accessible through `vim.*` not mentioned already; see |lua-stdlib|. diff --git a/runtime/doc/lua-plugin.txt b/runtime/doc/lua-plugin.txt @@ -25,11 +25,9 @@ You can try it right now: 1. Visit your config directory: > :exe 'edit' stdpath('config') -< 2. Create a `plugin/foo.lua` file in there. 3. Add something to it, like: >lua vim.print('Hello World') -< 4. Start `nvim` and notice that it prints "Hello World" in the messages area. Check `:messages` if you don't see it. diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt @@ -703,11 +703,12 @@ vim.rpcnotify({channel}, {method}, {...}) *vim.rpcnotify()* • {...} (`any?`) vim.rpcrequest({channel}, {method}, {...}) *vim.rpcrequest()* - Sends a request to {channel} to invoke {method} via |RPC| and blocks until - a response is received. + Invokes |RPC| `method` on `channel` and blocks until a response is + received. - Note: NIL values as part of the return value is represented as |vim.NIL| - special value + Note: Msgpack NIL values in the response are represented as |vim.NIL|. + + Example: see |nvim_exec_lua()| Parameters: ~ • {channel} (`integer`) @@ -2091,6 +2092,9 @@ vim.tbl_get({o}, {...}) *vim.tbl_get()* Return: ~ (`any`) Nested value indexed by key (if it exists), else nil + See also: ~ + • |unpack()| + vim.tbl_isempty({t}) *vim.tbl_isempty()* Checks if a table is empty. diff --git a/runtime/doc/luaref.txt b/runtime/doc/luaref.txt @@ -2541,10 +2541,10 @@ lua_toboolean *lua_toboolean()* < Converts the Lua value at the given acceptable index to a C boolean value (0 or 1). Like all tests in Lua, `lua_toboolean` returns 1 for - any Lua value different from `false` and `nil`; otherwise it returns - 0. It also returns 0 when called with a non-valid index. (If you want - to accept only actual boolean values, use `lua_isboolean` - |lua_isboolean()| to test the value's type.) + any Lua value different from `false` and `nil`; otherwise it returns 0. + It also returns 0 when called with a non-valid index. (If you want to + accept only actual boolean values, use `lua_isboolean` + |lua_isboolean()| to test the value's type.) lua_tocfunction *lua_tocfunction()* >c @@ -3947,7 +3947,7 @@ package.path *package.path* files `./foo.lua`, `./foo.lc`, and `/usr/local/foo/init.lua`, in that order. -package.preload *package.preload()* +package.preload *package.preload* A table to store loaders for specific modules (see |require()|). package.seeall({module}) *package.seeall()* diff --git a/runtime/doc/mbyte.txt b/runtime/doc/mbyte.txt @@ -690,7 +690,7 @@ doesn't always work. See the system specific remarks below, and 'langmenu'. USING UTF-8 IN X-WINDOWS *utf-8-in-xwindows* You need to specify a font to be used. For double-wide characters another -font is required, which is exactly twice as wide. There are three ways to do +font is required, which is exactly twice as wide. There are two ways to do this: 1. Set 'guifont' and let Nvim find a matching 'guifontwide' diff --git a/runtime/doc/nvim.txt b/runtime/doc/nvim.txt @@ -77,19 +77,19 @@ because mouse support is always enabled if possible. If you use the same like so: >vim if !has('nvim') - set ttymouse=xterm2 + set ttymouse=xterm2 endif And for Nvim-specific configuration, you can do this: >vim if has('nvim') - tnoremap <Esc> <C-\><C-n> + tnoremap <Esc> <C-\><C-n> endif For a more granular approach use |exists()|: >vim if exists(':tnoremap') - tnoremap <Esc> <C-\><C-n> + tnoremap <Esc> <C-\><C-n> endif Now you should be able to explore Nvim more comfortably. Check |nvim-features| diff --git a/runtime/doc/pattern.txt b/runtime/doc/pattern.txt @@ -345,10 +345,10 @@ For starters, read chapter 27 of the user manual |usr_27.txt|. */branch* */\&* 2. A branch is one or more concats, separated by "\&". It matches the last concat, but only if all the preceding concats also match at the same - position. Examples: + position. Examples: > "foobeep\&..." matches "foo" in "foobeep". ".*Peter\&.*Bob" matches in a line containing both "Peter" and "Bob" - +< branch ::= concat or concat \& concat or concat \& concat \& concat @@ -609,13 +609,13 @@ overview. */star* */\star* * (use \* when 'magic' is not set) Matches 0 or more of the preceding atom, as many as possible. - Example 'nomagic' matches ~ + Example 'nomagic' matches > a* a\* "", "a", "aa", "aaa", etc. .* \.\* anything, also an empty string, no end-of-line \_.* \_.\* everything up to the end of the buffer \_.*END \_.\*END everything up to and including the last "END" in the buffer - +< Exception: When "*" is used at the start of the pattern or just after "^" it matches the star character. diff --git a/runtime/doc/pi_msgpack.txt b/runtime/doc/pi_msgpack.txt @@ -12,34 +12,16 @@ merchantability. No guarantees of suitability for any purpose. By using this plugin, you agree that in no event will the copyright holder be liable for any damages resulting from the use of this software. Use at your own risk! -============================================================================== -1. Contents *msgpack.vim-contents* - - 1. Contents..............................: |msgpack.vim-contents| - 2. Msgpack.vim introduction..............: |msgpack.vim-intro| - 3. Msgpack.vim manual....................: |msgpack.vim-manual| - Function arguments....................: |msgpack.vim-arguments| - msgpack#is_int function...............: |msgpack#is_int()| - msgpack#is_uint function..............: |msgpack#is_uint()| - msgpack#strftime function.............: |msgpack#strftime()| - msgpack#strptime function.............: |msgpack#strptime()| - msgpack#int_dict_to_str function......: |msgpack#int_dict_to_str()| - msgpack#special_type function.........: |msgpack#special_type()| - msgpack#type function.................: |msgpack#type()| - msgpack#deepcopy function.............: |msgpack#deepcopy()| - msgpack#string function...............: |msgpack#string()| - msgpack#eval function.................: |msgpack#eval()| - msgpack#equal function................: |msgpack#equal()| - + Type |gO| to see the table of contents. ============================================================================== -2. Msgpack.vim introduction *msgpack.vim-intro* +Msgpack.vim introduction *msgpack.vim-intro* This plugin contains utility functions to be used in conjunction with |msgpackdump()| and |msgpackparse()| functions. ============================================================================== -3. Msgpack.vim manual *msgpack.vim-manual* +Msgpack.vim manual *msgpack.vim-manual* FUNCTION ARGUMENTS *msgpack.vim-arguments* diff --git a/runtime/doc/plugins.txt b/runtime/doc/plugins.txt @@ -15,8 +15,8 @@ available from the global `vim` module namespace. Some of the plugins are loaded by default while others are not loaded until requested by |:packadd|. ============================================================================== -Standard plugins ~ - *standard-plugin-list* +Standard plugins *standard-plugin-list* + Help-link Loaded Short description ~ |difftool| No Compares two directories or files side-by-side |editorconfig| Yes Detect and interpret editorconfig @@ -84,11 +84,26 @@ open({left}, {right}, {opt}) *difftool.open()* ============================================================================== Builtin plugin: editorconfig *editorconfig* -Nvim supports EditorConfig. When a file is opened, after running |ftplugin|s -and |FileType| autocommands, Nvim searches all parent directories of that file -for ".editorconfig" files, parses them, and applies any properties that match -the opened file. Think of it like 'modeline' for an entire (recursive) -directory. For more information see https://editorconfig.org/. +EditorConfig is like 'modeline' for an entire (recursive) directory. When a +file is opened, after running |ftplugin|s and |FileType| autocommands, the +EditorConfig feature searches all parent directories of that file for +`.editorconfig` files, parses them, and applies their properties. For more +information see https://editorconfig.org/. + +Example `.editorconfig` file: >ini + root = true + + [*] + charset = utf-8 + end_of_line = lf + indent_size = 4 + indent_style = space + max_line_length = 42 + trim_trailing_whitespace = true + + [*.{diff,md}] + trim_trailing_whitespace = false +< *g:editorconfig* *b:editorconfig* diff --git a/runtime/doc/usr_27.txt b/runtime/doc/usr_27.txt @@ -481,7 +481,7 @@ break. This will match at a line that ends in "one" and the next line starts with "two". To match "one two" as well, you need to match a space or a line -break. The item to use for it is "\_s": > +break. The item to use for it is `\_s`: > /one\_stwo @@ -501,10 +501,10 @@ Many other items can be made to match a line break by prepending "\_". For example: "\_." matches any character or a line break. Note: - "\_.*" matches everything until the end of the file. Be careful with + `\_.*` matches everything until the end of the file. Be careful with this, it can make a search command very slow. -Another example is "\_[]", a character range that includes a line break: > +Another example is `\_[]`, a character range that includes a line break: > /"\_[^"]*" diff --git a/runtime/doc/windows.txt b/runtime/doc/windows.txt @@ -682,30 +682,32 @@ positions are stored and used to decide whether there was a change. 7. Argument and buffer list commands *buffer-list* args list buffer list meaning ~ -1. :[N]argument [N] 11. :[N]buffer [N] to arg/buf N -2. :[N]next [file ..] 12. :[N]bnext [N] to Nth next arg/buf -3. :[N]Next [N] 13. :[N]bNext [N] to Nth previous arg/buf -4. :[N]previous [N] 14. :[N]bprevious [N] to Nth previous arg/buf -5. :rewind / :first 15. :brewind / :bfirst to first arg/buf -6. :last 16. :blast to last arg/buf -7. :all 17. :ball edit all args/buffers - 18. :unhide edit all loaded buffers - 19. :[N]bmod [N] to Nth modified buf - +> + 1. :[N]argument [N] 11. :[N]buffer [N] to arg/buf N + 2. :[N]next [file ..] 12. :[N]bnext [N] to Nth next arg/buf + 3. :[N]Next [N] 13. :[N]bNext [N] to Nth previous arg/buf + 4. :[N]previous [N] 14. :[N]bprevious [N] to Nth previous arg/buf + 5. :rewind / :first 15. :brewind / :bfirst to first arg/buf + 6. :last 16. :blast to last arg/buf + 7. :all 17. :ball edit all args/buffers + 18. :unhide edit all loaded buffers + 19. :[N]bmod [N] to Nth modified buf +< split & args list split & buffer list meaning ~ -21. :[N]sargument [N] 31. :[N]sbuffer [N] split + to arg/buf N -22. :[N]snext [file ..] 32. :[N]sbnext [N] split + to Nth next arg/buf -23. :[N]sNext [N] 33. :[N]sbNext [N] split + to Nth previous arg/buf -24. :[N]sprevious [N] 34. :[N]sbprevious [N] split + to Nth previous arg/buf -25. :srewind / :sfirst 35. :sbrewind / :sbfirst split + to first arg/buf -26. :slast 36. :sblast split + to last arg/buf -27. :sall 37. :sball edit all args/buffers - 38. :sunhide edit all loaded buffers - 39. :[N]sbmod [N] split + to Nth modified buf - -40. :args list of arguments -41. :buffers list of buffers - +> + 21. :[N]sargument [N] 31. :[N]sbuffer [N] split + to arg/buf N + 22. :[N]snext [file ..] 32. :[N]sbnext [N] split + to Nth next arg/buf + 23. :[N]sNext [N] 33. :[N]sbNext [N] split + to Nth previous arg/buf + 24. :[N]sprevious [N] 34. :[N]sbprevious [N] split + to Nth previous arg/buf + 25. :srewind / :sfirst 35. :sbrewind / :sbfirst split + to first arg/buf + 26. :slast 36. :sblast split + to last arg/buf + 27. :sall 37. :sball edit all args/buffers + 38. :sunhide edit all loaded buffers + 39. :[N]sbmod [N] split + to Nth modified buf + + 40. :args list of arguments + 41. :buffers list of buffers +< The meaning of [N] depends on the command: [N] is the number of buffers to go forward/backward on 2/12/22/32, 3/13/23/33, and 4/14/24/34 diff --git a/runtime/lua/editorconfig.lua b/runtime/lua/editorconfig.lua @@ -1,9 +1,24 @@ --- @brief ---- Nvim supports EditorConfig. When a file is opened, after running |ftplugin|s ---- and |FileType| autocommands, Nvim searches all parent directories of that file ---- for ".editorconfig" files, parses them, and applies any properties that match ---- the opened file. Think of it like 'modeline' for an entire (recursive) ---- directory. For more information see https://editorconfig.org/. +--- EditorConfig is like 'modeline' for an entire (recursive) directory. When a file is opened, +--- after running |ftplugin|s and |FileType| autocommands, the EditorConfig feature searches all +--- parent directories of that file for `.editorconfig` files, parses them, and applies their +--- properties. For more information see https://editorconfig.org/. +--- +--- Example `.editorconfig` file: +--- ```ini +--- root = true +--- +--- [*] +--- charset = utf-8 +--- end_of_line = lf +--- indent_size = 4 +--- indent_style = space +--- max_line_length = 42 +--- trim_trailing_whitespace = true +--- +--- [*.{diff,md}] +--- trim_trailing_whitespace = false +--- ``` --- @brief [g:editorconfig]() [b:editorconfig]() --- diff --git a/runtime/lua/vim/_meta/builtin.lua b/runtime/lua/vim/_meta/builtin.lua @@ -94,11 +94,12 @@ function vim.empty_dict() end --- @param ...? any function vim.rpcnotify(channel, method, ...) end ---- Sends a request to {channel} to invoke {method} via |RPC| and blocks until ---- a response is received. +--- Invokes |RPC| `method` on `channel` and blocks until a response is received. +--- +--- Note: Msgpack NIL values in the response are represented as |vim.NIL|. +--- +--- Example: see [nvim_exec_lua()] --- ---- Note: NIL values as part of the return value is represented as |vim.NIL| ---- special value --- @param channel integer --- @param method string --- @param ...? any diff --git a/runtime/lua/vim/lsp/health.lua b/runtime/lua/vim/lsp/health.lua @@ -249,7 +249,9 @@ local function check_enabled_configs() ipairs(v --[[@as string[] ]]) do if not vim.list_contains(valid_filetypes, filetype) then - report_warn(("Unknown filetype '%s'."):format(filetype)) + report_warn( + ("Unknown filetype '%s' (Hint: filename extension != filetype)."):format(filetype) + ) end end end diff --git a/runtime/lua/vim/shared.lua b/runtime/lua/vim/shared.lua @@ -717,6 +717,7 @@ end --- vim.tbl_get({ key = { nested_key = true }}, 'key', 'nested_key') == true --- vim.tbl_get({ key = {}}, 'key', 'nested_key') == nil --- ``` +---@see |unpack()| --- ---@param o table Table to index ---@param ... any Optional keys (0 or more, variadic) via which to index the table diff --git a/src/clint.lua b/src/clint.lua @@ -1193,7 +1193,7 @@ local function check_language(filename, clean_lines, linenum, error) -- Check for MAYBE if maybe_regex:match_str(line) then - error(filename, linenum, 'readability/bool', 4, 'Use kNONE from TriState instead of MAYBE.') + error(filename, linenum, 'readability/bool', 4, 'Use kNone from TriState instead of MAYBE.') end -- Detect preincrement/predecrement at start of line diff --git a/src/gen/gen_help_html.lua b/src/gen/gen_help_html.lua @@ -29,6 +29,9 @@ -- * visit_node() is the core function used by gen() to traverse the document tree and produce HTML. -- * visit_validate() is the core function used by validate(). -- * Files in `new_layout` will be generated with a "flow" layout instead of preformatted/fixed-width layout. +-- +-- TODO: +-- * Conjoin listitem "blocks" (blank-separated). Example: starting.txt local pending_urls = 0 local tagmap = nil ---@type table<string, string> @@ -78,6 +81,7 @@ local new_layout = { ['dev_theme.txt'] = true, ['dev_tools.txt'] = true, ['dev_vimpatch.txt'] = true, + ['diagnostic.txt'] = true, ['help.txt'] = true, ['faq.txt'] = true, ['gui.txt'] = true, @@ -629,25 +633,33 @@ local function visit_node(root, level, lang_tree, headings, opt, stats) and root:child(0) and vim.list_contains({ 'column_heading', 'h1', 'h2', 'h3' }, root:child(0):type()) return string.format('%s%s', div and trim(text) or text, div and '' or '\n') + elseif parent == 'line_li' and node_name == 'prefix' then + return '' elseif node_name == 'line_li' then + local prefix = first(root, 'prefix') + local numli = prefix and trim(node_text(prefix)):match('%d') -- Numbered listitem? local sib = root:prev_sibling() local prev_li = sib and sib:type() == 'line_li' + local cssclass = numli and 'help-li-num' or 'help-li' if not prev_li then opt.indent = 1 else - -- The previous listitem _sibling_ is _logically_ the _parent_ if it is indented less. - local parent_indent = get_indent(node_text(sib)) - local this_indent = get_indent(node_text()) - if this_indent > parent_indent then + local sib_ws = ws(sib) + local this_ws = ws() + if get_indent(node_text()) == 0 then + opt.indent = 1 + elseif this_ws > sib_ws then + -- Previous sibling is logically the _parent_ if it is indented less. opt.indent = opt.indent + 1 - elseif this_indent < parent_indent then + elseif this_ws < sib_ws then + -- TODO(justinmk): This is buggy. Need to track exact whitespace length for each level. opt.indent = math.max(1, opt.indent - 1) end end local margin = opt.indent == 1 and '' or ('margin-left: %drem;'):format((1.5 * opt.indent)) - return string.format('<div class="help-li" style="%s">%s</div>', margin, text) + return string.format('<div class="%s" style="%s">%s</div>', cssclass, margin, text) elseif node_name == 'taglink' or node_name == 'optionlink' then local helppage, tagname, ignored = validate_link(root, opt.buf, opt.fname) if ignored or not helppage then @@ -813,15 +825,14 @@ end --- --- @param fname string :help file to parse --- @param text string? :help file contents ---- @param parser_path string? path to non-default vimdoc.so --- @return vim.treesitter.LanguageTree, integer (lang_tree, bufnr) -local function parse_buf(fname, text, parser_path) +local function parse_buf(fname, text) local buf ---@type integer + if text then vim.cmd('split new') -- Text contents. vim.api.nvim_put(vim.split(text, '\n'), '', false, false) vim.cmd('setfiletype help') - -- vim.treesitter.language.add('vimdoc') buf = vim.api.nvim_get_current_buf() elseif type(fname) == 'string' then vim.cmd('split ' .. vim.fn.fnameescape(fname)) -- Filename. @@ -832,9 +843,6 @@ local function parse_buf(fname, text, parser_path) buf = fname vim.cmd('sbuffer ' .. tostring(fname)) -- Buffer number. end - if parser_path then - vim.treesitter.language.add('vimdoc', { path = parser_path }) - end local lang_tree = assert(vim.treesitter.get_parser(buf, nil, { error = false })) lang_tree:parse() return lang_tree, buf @@ -845,14 +853,13 @@ end --- - recursively counts parse errors ("ERROR" nodes) --- --- @param fname string help file to validate ---- @param parser_path string? path to non-default vimdoc.so --- @param request_urls boolean? whether to make requests to the URLs --- @return { invalid_links: number, parse_errors: string[] } -local function validate_one(fname, parser_path, request_urls) +local function validate_one(fname, request_urls) local stats = { parse_errors = {}, } - local lang_tree, buf = parse_buf(fname, nil, parser_path) + local lang_tree, buf = parse_buf(fname, nil) for _, tree in ipairs(lang_tree:trees()) do visit_validate(tree:root(), 0, tree, { buf = buf, @@ -871,17 +878,16 @@ end --- @param text string|nil Source :help file contents, or nil to read `fname`. --- @param to_fname string Destination .html file --- @param old boolean Preformat paragraphs (for old :help files which are full of arbitrary whitespace) ---- @param parser_path string? path to non-default vimdoc.so --- --- @return string html --- @return table stats -local function gen_one(fname, text, to_fname, old, commit, parser_path) +local function gen_one(fname, text, to_fname, old, commit) local stats = { noise_lines = {}, parse_errors = {}, first_tags = {}, -- Track the first few tags in doc. } - local lang_tree, buf = parse_buf(fname, text, parser_path) + local lang_tree, buf = parse_buf(fname, text) ---@type nvim.gen_help_html.heading[] local headings = {} -- Headings (for ToC). 2-dimensional: h1 contains h2/h3. local title = to_titlecase(basename_noext(fname)) @@ -1217,13 +1223,31 @@ local function gen_css(fname) /* font-family: ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace; */ } .help-li { + display: list-item; white-space: normal; + margin-left: 1.5rem; /* padding-left: 1rem; */ + /* margin-top: .1em; */ + /* margin-bottom: .1em; */ + } + .help-li-num { display: list-item; + list-style: none; + /* Sibling UNordered help-li items will increment the builtin counter :( */ + /* list-style-type: decimal; */ + white-space: normal; margin-left: 1.5rem; /* padding-left: 1rem; */ + margin-top: .1em; + margin-bottom: .1em; + } + .help-li-num::before { + margin-left: -1em; + counter-increment: my-li-counter; + content: counter(my-li-counter) ". "; } .help-para { padding-top: 10px; padding-bottom: 10px; + counter-reset: my-li-counter; /* Manually manage listitem numbering. */ } .old-help-para { @@ -1235,6 +1259,7 @@ local function gen_css(fname) font-size: 16px; font-family: ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace; word-wrap: break-word; + counter-reset: my-li-counter; /* Manually manage listitem numbering. */ } .old-help-para pre, .old-help-para pre:hover { /* Text following <pre> is already visually separated by the linebreak. */ @@ -1407,6 +1432,8 @@ end --- @param help_dir string Source directory containing the :help files. Must run `make helptags` first. --- @param to_dir string Target directory where the .html files will be written. --- @param include string[]|nil Process only these filenames. Example: {'api.txt', 'autocmd.txt', 'channel.txt'} +--- @param commit string? +--- @param parser_path string? path to non-default vimdoc.so/dylib/dll --- --- @return nvim.gen_help_html.gen_result result function M.gen(help_dir, to_dir, include, commit, parser_path) @@ -1423,10 +1450,18 @@ function M.gen(help_dir, to_dir, include, commit, parser_path) local err_count = 0 local redirects_count = 0 ensure_runtimepath() + + parser_path = parser_path and vim.fs.normalize(parser_path) or nil + if parser_path then + -- XXX: Delete the installed .so files first, else this won't work :( + -- /usr/local/lib/nvim/parser/vimdoc.so + -- ./build/lib/nvim/parser/vimdoc.so + vim.treesitter.language.add('vimdoc', { path = parser_path }) + end + tagmap = get_helptags(vim.fs.normalize(help_dir)) helpfiles = get_helpfiles(help_dir, include) to_dir = vim.fs.normalize(to_dir) - parser_path = parser_path and vim.fs.normalize(parser_path) or nil print(('output dir: %s\n\n'):format(to_dir)) vim.fn.mkdir(to_dir, 'p') @@ -1439,8 +1474,7 @@ function M.gen(help_dir, to_dir, include, commit, parser_path) local helpfile = vim.fs.basename(f) -- "to/dir/foo.html" local to_fname = ('%s/%s'):format(to_dir, get_helppage(helpfile)) - local html, stats = - gen_one(f, nil, to_fname, not new_layout[helpfile], commit or '?', parser_path) + local html, stats = gen_one(f, nil, to_fname, not new_layout[helpfile], commit or '?') tofile(to_fname, html) print( ('generated (%-2s errors): %-15s => %s'):format( @@ -1474,7 +1508,7 @@ function M.gen(help_dir, to_dir, include, commit, parser_path) :format(redirect_from, helpfile_tag, helpfile_tag, helpfile_tag, helpfile_tag, helpfile_tag) local redirect_to = ('%s/%s'):format(to_dir, get_helppage(redirect_from)) local redirect_html, _ = - gen_one(redirect_from, redirect_text, redirect_to, false, commit or '?', parser_path) + gen_one(redirect_from, redirect_text, redirect_to, false, commit or '?') assert( redirect_html:find(vim.pesc(helpfile_tag)), ('not found in redirect html: %s'):format(helpfile_tag) @@ -1535,13 +1569,21 @@ function M.validate(help_dir, include, parser_path, request_urls) local err_count = 0 ---@type integer local files_to_errors = {} ---@type table<string, string[]> ensure_runtimepath() + + parser_path = parser_path and vim.fs.normalize(parser_path) or nil + if parser_path then + -- XXX: Delete the installed .so files first, else this won't work :( + -- /usr/local/lib/nvim/parser/vimdoc.so + -- ./build/lib/nvim/parser/vimdoc.so + vim.treesitter.language.add('vimdoc', { path = parser_path }) + end + tagmap = get_helptags(vim.fs.normalize(help_dir)) helpfiles = get_helpfiles(help_dir, include) - parser_path = parser_path and vim.fs.normalize(parser_path) or nil for _, f in ipairs(helpfiles) do local helpfile = vim.fs.basename(f) - local rv = validate_one(f, parser_path, request_urls) + local rv = validate_one(f, request_urls) print(('validated (%-4s errors): %s'):format(#rv.parse_errors, helpfile)) if #rv.parse_errors > 0 then files_to_errors[helpfile] = rv.parse_errors diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c @@ -497,18 +497,29 @@ String nvim_replace_termcodes(String str, Boolean from_part, Boolean do_lt, Bool return cstr_as_string(ptr); } -/// Execute Lua code. Parameters (if any) are available as `...` inside the -/// chunk. The chunk can return a value. +/// Executes Lua code. Arguments are available as `...` inside the chunk. The chunk can return +/// a value. /// -/// Only statements are executed. To evaluate an expression, prefix it -/// with `return`: return my_function(...) +/// Only statements are executed. To evaluate an expression, prefix it with "return": `return +/// my_function(...)` /// -/// @param code Lua code to execute -/// @param args Arguments to the code -/// @param[out] err Details of an error encountered while parsing -/// or executing the Lua code. +/// Example: +/// ```lua +/// local peer = vim.fn.jobstart({ vim.v.progpath, '--clean', '--embed' }, { rpc=true }) +/// vim.print(vim.rpcrequest(peer, 'nvim_exec_lua', [[ +/// local a, b = ... +/// return ('result: %s'):format(a + b) +/// ]], +/// { 1, 3 } +/// ) +/// ) +/// ``` /// -/// @return Return value of Lua code if present or NIL. +/// @param code Lua code to execute. +/// @param args Arguments to the Lua code. +/// @param[out] err Lua error raised while parsing or executing the Lua code. +/// +/// @return Value returned by the Lua code (if any), or NIL. Object nvim_exec_lua(String code, Array args, Arena *arena, Error *err) FUNC_API_SINCE(7) FUNC_API_REMOTE_ONLY diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c @@ -1668,7 +1668,8 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int col_rows, b = !has_foldtext && buf_meta_total(wp->w_buffer, kMTMetaInline) > 0; int virt_line_index = -1; int virt_line_flags = 0; - // Repeat for the whole displayed line. + + // Repeat for each cell in the displayed line. while (true) { int has_match_conc = 0; ///< match wants to conceal int decor_conceal = 0; diff --git a/src/nvim/grid.c b/src/nvim/grid.c @@ -1084,14 +1084,15 @@ void grid_del_lines(ScreenGrid *grid, int row, int line_count, int end, int col, } } +/// @param overflow Number of cells to skip. static void grid_draw_bordertext(VirtText vt, int col, int winbl, const int *hl_attr, - BorderTextType bt, int over_flow) + BorderTextType bt, int overflow) { int default_attr = hl_attr[bt == kBorderTextTitle ? HLF_BTITLE : HLF_BFOOTER]; - if (over_flow > 0) { + if (overflow > 0) { grid_line_puts(1, "<", -1, hl_apply_winblend(winbl, default_attr)); col += 1; - over_flow += 1; + overflow += 1; } for (size_t i = 0; i < kv_size(vt);) { @@ -1104,18 +1105,17 @@ static void grid_draw_bordertext(VirtText vt, int col, int winbl, const int *hl_ attr = default_attr; } // Skip characters from the beginning when title overflows available width. - // over_flow contains the number of cells to skip. - if (over_flow > 0) { + if (overflow > 0) { int cells = (int)mb_string2cells(text); // Skip entire chunk if overflow is larger than chunk width. - if (over_flow >= cells) { - over_flow -= cells; + if (overflow >= cells) { + overflow -= cells; continue; } // Skip partial characters within the chunk. char *p = text; - while (*p && over_flow > 0) { - over_flow -= utf_ptr2cells(p); + while (*p && overflow > 0) { + overflow -= utf_ptr2cells(p); p += utfc_ptr2len(p); } text = p; diff --git a/test/functional/script/clint_spec.lua b/test/functional/script/clint_spec.lua @@ -20,10 +20,10 @@ describe('clint.lua', function() 'test/functional/fixtures/clint_test.c:22: Storage class (static, extern, typedef, etc) should be first. [build/storage_class] [5]', 'test/functional/fixtures/clint_test.c:25: Use true instead of TRUE. [readability/bool] [4]', 'test/functional/fixtures/clint_test.c:26: Use false instead of FALSE. [readability/bool] [4]', - 'test/functional/fixtures/clint_test.c:27: Use kNONE from TriState instead of MAYBE. [readability/bool] [4]', + 'test/functional/fixtures/clint_test.c:27: Use kNone from TriState instead of MAYBE. [readability/bool] [4]', 'test/functional/fixtures/clint_test.c:31: Use true instead of TRUE. [readability/bool] [4]', 'test/functional/fixtures/clint_test.c:32: Use false instead of FALSE. [readability/bool] [4]', - 'test/functional/fixtures/clint_test.c:35: Use kNONE from TriState instead of MAYBE. [readability/bool] [4]', + 'test/functional/fixtures/clint_test.c:35: Use kNone from TriState instead of MAYBE. [readability/bool] [4]', 'test/functional/fixtures/clint_test.c:41: /*-style comment found, it should be replaced with //-style. /*-style comments are only allowed inside macros. Note that you should not use /*-style comments to document macros itself, use doxygen-style comments for this. [readability/old_style_comment] [5]', 'test/functional/fixtures/clint_test.c:54: Do not use preincrement in statements, use postincrement instead [readability/increment] [5]', 'test/functional/fixtures/clint_test.c:55: Do not use preincrement in statements, including for(;; action) [readability/increment] [4]',