diff options
Diffstat (limited to 'runtime/doc')
| -rw-r--r-- | runtime/doc/api.txt | 6 | ||||
| -rw-r--r-- | runtime/doc/deprecated.txt | 3 | ||||
| -rw-r--r-- | runtime/doc/diagnostic.txt | 150 | ||||
| -rw-r--r-- | runtime/doc/lsp.txt | 25 | ||||
| -rw-r--r-- | runtime/doc/lua.txt | 13 |
5 files changed, 142 insertions, 55 deletions
diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index 1573bec7ac..bb8e83f84a 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -1078,7 +1078,7 @@ nvim_get_keymap({mode}) *nvim_get_keymap()* Array of maparg()-like dictionaries describing mappings. The "buffer" key is always zero. -nvim_get_mark({name}) *nvim_get_mark()* +nvim_get_mark({name}, {opts}) *nvim_get_mark()* Return a tuple (row, col, buffer, buffername) representing the position of the uppercase/file named mark. See |mark-motions|. @@ -1090,6 +1090,7 @@ nvim_get_mark({name}) *nvim_get_mark()* Parameters: ~ {name} Mark name + {opts} Optional parameters. Reserved for future use. Return: ~ 4-tuple (row, col, buffer, buffername), (0, 0, 0, '') if @@ -2420,7 +2421,7 @@ nvim_buf_set_lines({buffer}, {start}, {end}, {strict_indexing}, {replacement}) {replacement} Array of lines to use as replacement *nvim_buf_set_mark()* -nvim_buf_set_mark({buffer}, {name}, {line}, {col}) +nvim_buf_set_mark({buffer}, {name}, {line}, {col}, {opts}) Sets a named mark in the given buffer, all marks are allowed file/uppercase, visual, last change, etc. See |mark-motions|. @@ -2434,6 +2435,7 @@ nvim_buf_set_mark({buffer}, {name}, {line}, {col}) {name} Mark name {line} Line number {col} Column/row number + {opts} Optional parameters. Reserved for future use. Return: ~ true if the mark was set, else false. diff --git a/runtime/doc/deprecated.txt b/runtime/doc/deprecated.txt index a7ce4135af..21a34178b3 100644 --- a/runtime/doc/deprecated.txt +++ b/runtime/doc/deprecated.txt @@ -85,6 +85,9 @@ For each of the functions below, use the corresponding function in *vim.lsp.diagnostic.save()* Use |vim.diagnostic.set()| instead. *vim.lsp.diagnostic.set_loclist()* Use |vim.diagnostic.setloclist()| instead. *vim.lsp.diagnostic.set_qflist()* Use |vim.diagnostic.setqflist()| instead. + +The following have been replaced by |vim.diagnostic.open_float()|. + *vim.lsp.diagnostic.show_line_diagnostics()* *vim.lsp.diagnostic.show_position_diagnostics()* diff --git a/runtime/doc/diagnostic.txt b/runtime/doc/diagnostic.txt index 4d1e5ac997..d121dba435 100644 --- a/runtime/doc/diagnostic.txt +++ b/runtime/doc/diagnostic.txt @@ -75,6 +75,100 @@ Functions that take a severity as an optional parameter (e.g. The latter form allows users to specify a range of severities. ============================================================================== +HANDLERS *diagnostic-handlers* + +Diagnostics are shown to the user with |vim.diagnostic.show()|. The display of +diagnostics is managed through handlers. A handler is a table with a "show" +and (optionally) a "hide" function. The "show" function has the signature +> + function(namespace, bufnr, diagnostics, opts) +< +and is responsible for displaying or otherwise handling the given +diagnostics. The "hide" function takes care of "cleaning up" any actions taken +by the "show" function and has the signature +> + function(namespace, bufnr) +< +Handlers can be configured with |vim.diagnostic.config()| and added by +creating a new key in `vim.diagnostic.handlers` (see +|diagnostic-handlers-example|). + +The {opts} table passed to a handler is the full set of configuration options +(that is, it is not limited to just the options for the handler itself). The +values in the table are already resolved (i.e. if a user specifies a +function for a config option, the function has already been evaluated). + +Nvim provides these handlers by default: "virtual_text", "signs", and +"underline". + + *diagnostic-handlers-example* +The example below creates a new handler that notifies the user of diagnostics +with |vim.notify()|: > + + -- It's good practice to namespace custom handlers to avoid collisions + vim.diagnostic.handlers["my/notify"] = { + show = function(namespace, bufnr, diagnostics, opts) + -- In our example, the opts table has a "log_level" option + local level = opts["my/notify"].log_level + + local name = vim.diagnostic.get_namespace(namespace).name + local msg = string.format("%d diagnostics in buffer %d from %s", + #diagnostics, + bufnr, + name) + vim.notify(msg, level) + end, + } + + -- Users can configure the handler + vim.diagnostic.config({ + ["my/notify"] = { + log_level = vim.log.levels.INFO + } + }) +< +In this example, there is nothing to do when diagnostics are hidden, so we +omit the "hide" function. + +Existing handlers can be overriden. For example, use the following to only +show a sign for the highest severity diagnostic on a given line: > + + -- Create a custom namespace. This will aggregate signs from all other + -- namespaces and only show the one with the highest severity on a + -- given line + local ns = vim.api.nvim_create_namespace("my_namespace") + + -- Get a reference to the original signs handler + local orig_signs_handler = vim.diagnostic.handlers.signs + + -- Override the built-in signs handler + vim.diagnostic.handlers.signs = { + show = function(_, bufnr, _, opts) + -- Get all diagnostics from the whole buffer rather than just the + -- diagnostics passed to the handler + local diagnostics = vim.diagnostic.get(bufnr) + + -- Find the "worst" diagnostic per line + local max_severity_per_line = {} + for _, d in pairs(diagnostics) do + local m = max_severity_per_line[d.lnum] + if not m or d.severity < m.severity then + max_severity_per_line[d.lnum] = d + end + end + + -- Pass the filtered diagnostics (with our custom namespace) to + -- the original handler + local filtered_diagnostics = vim.tbl_values(max_severity_per_line) + orig_signs_handler.show(ns, bufnr, filtered_diagnostics, opts) + end, + hide = function(_, bufnr) + orig_signs_handler.hide(ns, bufnr) + end, + } +< + +============================================================================== HIGHLIGHTS *diagnostic-highlights* All highlights defined for diagnostics begin with `Diagnostic` followed by @@ -202,51 +296,6 @@ Example: > autocmd User DiagnosticsChanged lua vim.diagnostic.setqflist({open = false }) < ============================================================================== -CUSTOMIZATION *diagnostic-config* - -If you need more customization over the way diagnostics are displayed than the -built-in configuration options provide, you can override the display handler -explicitly. For example, use the following to only show a sign for the highest -severity diagnostic on a given line: > - - -- Disable the default signs handler - vim.diagnostic.config({signs = false}) - - -- Create a namespace. This won't be used to add any diagnostics, - -- only to display them. - local ns = vim.api.nvim_create_namespace("my_namespace") - - -- Create a reference to the original function - local orig_show = vim.diagnostic.show - - local function set_signs(bufnr) - -- Get all diagnostics from the current buffer - local diagnostics = vim.diagnostic.get(bufnr) - - -- Find the "worst" diagnostic per line - local max_severity_per_line = {} - for _, d in pairs(diagnostics) do - local m = max_severity_per_line[d.lnum] - if not m or d.severity < m.severity then - max_severity_per_line[d.lnum] = d - end - end - - -- Show the filtered diagnostics using the custom namespace. Use the - -- reference to the original function to avoid a loop. - local filtered_diagnostics = vim.tbl_values(max_severity_per_line) - orig_show(ns, bufnr, filtered_diagnostics, { - virtual_text=false, - underline=false, - signs=true - }) - end - - function vim.diagnostic.show(namespace, bufnr, ...) - orig_show(namespace, bufnr, ...) - set_signs(bufnr) - end -< ============================================================================== Lua module: vim.diagnostic *diagnostic-api* @@ -394,6 +443,15 @@ get({bufnr}, {opts}) *vim.diagnostic.get()* Return: ~ table A list of diagnostic items |diagnostic-structure|. +get_namespace({namespace}) *vim.diagnostic.get_namespace()* + Get namespace metadata. + + Parameters: ~ + {ns} number Diagnostic namespace + + Return: ~ + table Namespace metadata + get_namespaces() *vim.diagnostic.get_namespaces()* Get current diagnostic namespaces. @@ -619,7 +677,7 @@ show({namespace}, {bufnr}, {diagnostics}, {opts}) Display diagnostics for the given namespace and buffer. Parameters: ~ - {namespace} number Diagnostic namespace + {namespace} number Diagnostic namespace. {bufnr} number|nil Buffer number. Defaults to the current buffer. {diagnostics} table|nil The diagnostics to display. When diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt index 5549d3c180..80ac762792 100644 --- a/runtime/doc/lsp.txt +++ b/runtime/doc/lsp.txt @@ -61,6 +61,10 @@ Example config (in init.vim): > -- See `:help omnifunc` and `:help ins-completion` for more information. vim.api.nvim_buf_set_option(0, 'omnifunc', 'v:lua.vim.lsp.omnifunc') + -- Use LSP as the handler for formatexpr. + -- See `:help formatexpr` for more information. + vim.api.nvim_buf_set_option(0, 'formatexpr', 'v:lua.vim.lsp.formatexpr()') + -- For plugins with an `on_attach` callback, call them here. For example: -- require('completion').on_attach() end @@ -452,6 +456,22 @@ LspSignatureActiveParameter |vim.lsp.handlers.signature_help()|. ============================================================================== +EVENTS *lsp-events* + +LspProgressUpdate *LspProgressUpdate* + Upon receipt of a progress notification from the server. See + |vim.lsp.util.get_progress_messages()|. + +LspRequest *LspRequest* + After a change to the active set of pending LSP requests. See {requests} + in |vim.lsp.client|. + +Example: > + autocmd User LspProgressUpdate redrawstatus + autocmd User LspRequest redrawstatus +< + +============================================================================== Lua module: vim.lsp *lsp-core* buf_attach_client({bufnr}, {client_id}) *vim.lsp.buf_attach_client()* @@ -608,6 +628,11 @@ client() *vim.lsp.client* 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 either "pending" + for an active request, or "cancel" for a cancel request. • {config} (table): copy of the table that was passed by the user to |vim.lsp.start_client()|. • {server_capabilities} (table): Response from the server diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index 877c838602..1e058874bd 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -698,15 +698,14 @@ vim.diff({a}, {b}, {opts}) *vim.diff()* ------------------------------------------------------------------------------ VIM.MPACK *lua-mpack* -The *vim.mpack* module provides packing and unpacking of lua objects to -msgpack encoded strings. |vim.NIL| and |vim.empty_dict()| are supported. +The *vim.mpack* module provides encoding and decoding of Lua objects to and +from msgpack-encoded strings. Supports |vim.NIL| and |vim.empty_dict()|. -vim.mpack.pack({obj}) *vim.mpack.pack* - Packs a lua object {obj} and returns the msgpack representation as - a string +vim.mpack.encode({obj}) *vim.mpack.encode* + Encodes (or "packs") Lua object {obj} as msgpack in a Lua string. -vim.mpack.unpack({str}) *vim.mpack.unpack* - Unpacks the msgpack encoded {str} and returns a lua object +vim.mpack.decode({str}) *vim.mpack.decode* + Decodes (or "unpacks") the msgpack-encoded {str} to a Lua object. ------------------------------------------------------------------------------ VIM *lua-builtin* |