Skip to content
forked from neovim/neovim

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
justinmk committed Jun 19, 2023
1 parent cee981b commit d7e515e
Show file tree
Hide file tree
Showing 13 changed files with 80 additions and 86 deletions.
9 changes: 6 additions & 3 deletions runtime/doc/builtin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8842,10 +8842,13 @@ termopen({cmd} [, {opts}]) *termopen()*
to the current (unmodified) buffer. Parameters and behavior
are the same as |jobstart()| except "pty", "width", "height",
and "TERM" are ignored: "height" and "width" are taken from
the current window.
Returns the same values as |jobstart()|.
the current window. Note that termopen() implies a "pty" arg
to jobstart(), and thus has the implications documented at
|jobstart()|.

Terminal environment is initialized as in ||jobstart-env|,
Returns the same values as jobstart().

Terminal environment is initialized as in |jobstart-env|,
except $TERM is set to "xterm-256color". Full behavior is
described in |terminal|.

Expand Down
7 changes: 7 additions & 0 deletions runtime/doc/deprecated.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ internally and are no longer exposed as part of the API. Instead, use
- *vim.lsp.diagnostic.set_virtual_text()*

LSP FUNCTIONS
- *vim.lsp.buf.server_ready()*
Use |LspAttach| instead, depending on your use-case. "Server ready" is not
part of the LSP spec, so the Nvim LSP client cannot meaningfully implement
it. "Ready" is ambiguous because:
- Language servers may finish analyzing the workspace, but edits can always
re-trigger analysis/builds.
- Language servers can serve some requests even while processing changes.
- *vim.lsp.buf.range_code_action()* Use |vim.lsp.buf.code_action()| with
the `range` parameter.
- *vim.lsp.util.diagnostics_to_items()* Use |vim.diagnostic.toqflist()| instead.
Expand Down
63 changes: 27 additions & 36 deletions runtime/doc/lsp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,10 @@ specification. These LSP requests/notifications are defined by default:

*lsp-handler*

lsp-handlers are functions with special signatures that are designed to handle
responses and notifications from LSP servers.
LSP handlers are functions with signatures designed to handle LSP responses
and notifications.

For |lsp-request|, each |lsp-handler| has this signature: >
For |lsp-response|, each |lsp-handler| has this signature: >
function(err, result, ctx, config)
<
Expand Down Expand Up @@ -363,42 +363,37 @@ To configure the behavior of a builtin |lsp-handler|, the convenient method
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
|lsp-method| names to |lsp-handlers|.

To override the handler for the `"textDocument/definition"` method: >lua
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: >lua

vim.lsp.handlers["textDocument/definition"] = my_custom_default_definition
<
- The {handlers} parameter for |vim.lsp.start_client()|.
This will set the |lsp-handler| as the default handler for this server.

For example: >lua
- The {handlers} parameter of |vim.lsp.start()|. This sets the default
|lsp-handler| for the server being started. Example: >lua

vim.lsp.start_client {
vim.lsp.start {
..., -- Other configuration omitted.
handlers = {
["textDocument/definition"] = my_custom_server_definition
},
}

- The {handler} parameter for |vim.lsp.buf_request()|.
This will set the |lsp-handler| ONLY for the current request.

For example: >lua
- The {handler} parameter of |vim.lsp.buf_request_all()|. This sets
the |lsp-handler| ONLY for the given request(s). Example: >lua

vim.lsp.buf_request(
vim.lsp.buf_request_all(
0,
"textDocument/definition",
definition_params,
my_request_custom_definition
my_request_params,
my_handler
)
<
In summary, the |lsp-handler| will be chosen based on the current |lsp-method|
in the following order:

1. Handler passed to |vim.lsp.buf_request()|, if any.
2. Handler defined in |vim.lsp.start_client()|, if any.
1. Handler passed to |vim.lsp.buf_request_all()|, if any.
2. Handler defined in |vim.lsp.start()|, if any.
3. Handler defined in |vim.lsp.handlers|, if any.

*vim.lsp.log_levels*
Expand Down Expand Up @@ -709,31 +704,27 @@ buf_notify({bufnr}, {method}, {params}) *vim.lsp.buf_notify()*
(boolean) success true if any client returns true; false otherwise

*vim.lsp.buf_request_all()*
buf_request_all({bufnr}, {method}, {params}, {callback})
Sends an async request for all active clients attached to the buffer.
Executes the callback on the combined result. Parameters are the same as
|vim.lsp.buf_request()| but the return result and callback are different.
buf_request_all({bufnr}, {method}, {params}, {handler})
Sends an async request for all active clients attached to the buffer and
executes the `handler` callback with the combined result.

Parameters: ~
{bufnr} (integer) Buffer handle, or 0 for current.
{method} (string) LSP method name
{params} (table|nil) Parameters to send to the server
{callback} (function) The callback to call when all requests are
finished. Unlike `buf_request`, this will collect all the
responses from each server instead of handling them. A map
of client_id:request_result will be provided to the
callback.
{bufnr} (integer) Buffer handle, or 0 for current.
{method} (string) LSP method name
{params} (table|nil) Parameters to send to the server
{handler} (function) Handler called after all requests are completed.
Server results are passed as a `client_id:result` map.

Return: ~
fun() cancel A function that will cancel all requests
fun() cancel Function that cancels all requests.

*vim.lsp.buf_request_sync()*
buf_request_sync({bufnr}, {method}, {params}, {timeout_ms})
Sends a request to all server and waits for the response of all of them.

Calls |vim.lsp.buf_request_all()| but blocks Nvim while awaiting the
result. Parameters are the same as |vim.lsp.buf_request()| but the return
result is different. Wait maximum of {timeout_ms} (default 1000) ms.
result. Parameters are the same as |vim.lsp.buf_request_all()| but the
result is different. Waits a maximum of {timeout_ms} (default 1000) ms.

Parameters: ~
{bufnr} (integer) Buffer handle, or 0 for current.
Expand Down
14 changes: 11 additions & 3 deletions runtime/doc/lua.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1002,10 +1002,18 @@ Log levels are one of the values defined in `vim.log.levels`:
------------------------------------------------------------------------------
LUA-VIMSCRIPT BRIDGE *lua-vimscript*

Nvim Lua provides an interface to Vimscript variables and functions, and
editor commands and options.
Nvim Lua provides an interface or "bridge" to Vimscript variables and
functions, and editor commands and options.

Objects passed over this bridge are COPIED (marshalled): there are no
"references". |lua-guide-variables| For example, using `vim.fn.remove()` on
a Lua list copies the list object to Vimscript and does NOT modify the Lua
list: >lua

local list = { 1, 2, 3 }
vim.fn.remove(list, 0)
vim.print(list) --> "{ 1, 2, 3 }"

See also https://github.com/nanotee/nvim-lua-guide.

vim.call({func}, {...}) *vim.call()*
Invokes |vim-function| or |user-function| {func} with arguments {...}.
Expand Down
1 change: 1 addition & 0 deletions runtime/doc/map.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1546,6 +1546,7 @@ supports incremental command preview:
-- If invoked as a preview callback, performs 'inccommand' preview by
-- highlighting trailing whitespace in the current buffer.
local function trim_space_preview(opts, preview_ns, preview_buf)
vim.cmd('hi clear Whitespace')
local line1 = opts.line1
local line2 = opts.line2
local buf = vim.api.nvim_get_current_buf()
Expand Down
18 changes: 7 additions & 11 deletions runtime/doc/options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2088,17 +2088,13 @@ A jump table for the options with a short description can be found at |Q_op|.
:set dir=c:\\tmp,\ dir\\,with\\,commas,\\\ dir\ with\ spaces
< - For backwards compatibility with Vim version 3.0 a '>' at the start
of the option is removed.
Using "." first in the list is recommended. This means that editing
the same file twice will result in a warning. Using "/tmp" on Unix is
discouraged: When the system crashes you lose the swap file.
"/var/tmp" is often not cleared when rebooting, thus is a better
choice than "/tmp". But others on the computer may be able to see the
files, and it can contain a lot of files, your swap files get lost in
the crowd. That is why a "tmp" directory in your home directory is
tried first.
The use of |:set+=| and |:set-=| is preferred when adding or removing
directories from the list. This avoids problems when a future version
uses another default.

Editing the same file twice will result in a warning. Using "/tmp" on
is discouraged: if the system crashes you lose the swap file. And
others on the computer may be able to see the files.
Use |:set+=| and |:set-=| when adding or removing directories from the
list, this avoids problems if the Nvim default is changed.

This option cannot be set from a |modeline| or in the |sandbox|, for
security reasons.

Expand Down
1 change: 0 additions & 1 deletion runtime/doc/pattern.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1298,7 +1298,6 @@ will probably never match.
When "\Z" appears anywhere in the pattern, all composing characters are
ignored. Thus only the base characters need to match, the composing
characters may be different and the number of composing characters may differ.
Only relevant when 'encoding' is "utf-8".
Exception: If the pattern starts with one or more composing characters, these
must match.
*/\%C*
Expand Down
1 change: 0 additions & 1 deletion runtime/doc/russian.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ enter Normal mode command, you can also set 'langmap' option:
:set langmap=ФИСВУАПРШОЛДЬТЩЗЙКЫЕГМЦЧНЯ;ABCDEFGHIJKLMNOPQRSTUVWXYZ,
фисвуапршолдьтщзйкыегмцчня;abcdefghijklmnopqrstuvwxyz
This is in utf-8, you cannot read this if your 'encoding' is not utf-8.
You have to type this command in one line, it is wrapped for the sake of
readability.

Expand Down
5 changes: 2 additions & 3 deletions runtime/doc/usr_11.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,8 @@ You must be in the right directory, otherwise Vim can't find the swap file.
==============================================================================
*11.2* Where is the swap file?

Vim can store the swap file in several places. Normally it is in the same
directory as the original file. To find it, change to the directory of the
file, and use: >
Vim can store the swap file in several places. To find it, change to the
directory of the file, and use: >
vim -r
Expand Down
3 changes: 1 addition & 2 deletions runtime/doc/usr_45.txt
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,7 @@ font. Example: >
xterm -u8 -fn -misc-fixed-medium-r-normal--18-120-100-100-c-90-iso10646-1
Now you can run Vim inside this terminal. Set 'encoding' to "utf-8" as
before. That's all.
Now you can run Vim inside this terminal.


USING UNICODE IN AN ORDINARY TERMINAL
Expand Down
11 changes: 4 additions & 7 deletions runtime/doc/various.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,10 @@ g8 Print the hex values of the bytes used in the

*8g8*
8g8 Find an illegal UTF-8 byte sequence at or after the
cursor. This works in two situations:
1. when 'encoding' is any 8-bit encoding
2. when 'encoding' is "utf-8" and 'fileencoding' is
any 8-bit encoding
Thus it can be used when editing a file that was
supposed to be UTF-8 but was read as if it is an 8-bit
encoding because it contains illegal bytes.
cursor.
Can be used when editing a file that was supposed to
be UTF-8 but was read as if it is an 8-bit encoding
because it contains illegal bytes.
Does not wrap around the end of the file.
Note that when the cursor is on an illegal byte or the
cursor is halfway through a multibyte character the
Expand Down
31 changes: 14 additions & 17 deletions runtime/lua/vim/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1491,7 +1491,7 @@ function lsp.start_client(config)
---successful, then it will return {request_id} as the
---second result. You can use this with `client.cancel_request(request_id)`
---to cancel the-request.
---@see |vim.lsp.buf_request()|
---@see |vim.lsp.buf_request_all()|
function client.request(method, params, handler, bufnr)
if not handler then
handler = assert(
Expand Down Expand Up @@ -2119,22 +2119,19 @@ function lsp.buf_request(bufnr, method, params, handler)
return client_request_ids, _cancel_all_requests
end

---Sends an async request for all active clients attached to the buffer.
---Executes the callback on the combined result.
---Parameters are the same as |vim.lsp.buf_request()| but the return result and callback are
---different.
--- Sends an async request for all active clients attached to the buffer and executes the `handler`
--- callback with the combined result.
---
---@param bufnr (integer) Buffer handle, or 0 for current.
---@param method (string) LSP method name
---@param params (table|nil) Parameters to send to the server
---@param callback fun(request_results: table<integer, {error: lsp.ResponseError, result: any}>) (function)
--- The callback to call when all requests are finished.
--- Unlike `buf_request`, this will collect all the responses from each server instead of handling them.
--- A map of client_id:request_result will be provided to the callback.
---
---@return fun() cancel A function that will cancel all requests
function lsp.buf_request_all(bufnr, method, params, callback)
local request_results = {}
---@param handler fun(results: table<integer, {error: lsp.ResponseError, result: any}>) (function)
--- Handler called after all requests are completed. Server results are passed as
--- a `client_id:result` map.
---
---@return fun() cancel Function that cancels all requests.
function lsp.buf_request_all(bufnr, method, params, handler)
local results = {}
local result_count = 0
local expected_result_count = 0

Expand All @@ -2147,12 +2144,12 @@ function lsp.buf_request_all(bufnr, method, params, callback)
end)

local function _sync_handler(err, result, ctx)
request_results[ctx.client_id] = { error = err, result = result }
results[ctx.client_id] = { error = err, result = result }
result_count = result_count + 1
set_expected_result_count()

if result_count >= expected_result_count then
callback(request_results)
handler(results)
end
end

Expand All @@ -2164,8 +2161,8 @@ end
--- Sends a request to all server and waits for the response of all of them.
---
--- Calls |vim.lsp.buf_request_all()| but blocks Nvim while awaiting the result.
--- Parameters are the same as |vim.lsp.buf_request()| but the return result is
--- different. Wait maximum of {timeout_ms} (default 1000) ms.
--- Parameters are the same as |vim.lsp.buf_request_all()| but the result is
--- different. Waits a maximum of {timeout_ms} (default 1000) ms.
---
---@param bufnr (integer) Buffer handle, or 0 for current.
---@param method (string) LSP method name
Expand Down
2 changes: 0 additions & 2 deletions scripts/gen_help_html.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,13 @@ local exclude_invalid = {
["'string'"] = "eval.txt",
Query = 'treesitter.txt',
['eq?'] = 'treesitter.txt',
['lsp-request'] = 'lsp.txt',
matchit = 'vim_diff.txt',
['matchit.txt'] = 'help.txt',
["set!"] = "treesitter.txt",
['v:_null_blob'] = 'builtin.txt',
['v:_null_dict'] = 'builtin.txt',
['v:_null_list'] = 'builtin.txt',
['v:_null_string'] = 'builtin.txt',
['vim.lsp.buf_request()'] = 'lsp.txt',
['vim.lsp.util.get_progress_messages()'] = 'lsp.txt',
}

Expand Down

0 comments on commit d7e515e

Please sign in to comment.