diff options
| author | Josh Rahm <rahm@google.com> | 2022-08-19 12:26:08 -0600 |
|---|---|---|
| committer | Josh Rahm <rahm@google.com> | 2022-08-19 13:06:41 -0600 |
| commit | a7237662f96933efe29eed8212464571e3778cd0 (patch) | |
| tree | 27930202726b4251437c8cfa53069f65b4db90dc /runtime/doc/diagnostic.txt | |
| parent | 02292344929069ea63c0bb872cc22d552d86b67f (diff) | |
| parent | b2f979b30beac67906b2dd717fcb6a34f46f5e54 (diff) | |
| download | rneovim-tmp.tar.gz rneovim-tmp.tar.bz2 rneovim-tmp.zip | |
Merge branch 'master' of https://github.com/neovim/neovim into rahmtmp
Diffstat (limited to 'runtime/doc/diagnostic.txt')
| -rw-r--r-- | runtime/doc/diagnostic.txt | 930 |
1 files changed, 439 insertions, 491 deletions
diff --git a/runtime/doc/diagnostic.txt b/runtime/doc/diagnostic.txt index 7fb10f2a66..e1b52746be 100644 --- a/runtime/doc/diagnostic.txt +++ b/runtime/doc/diagnostic.txt @@ -38,60 +38,60 @@ optionally supplied). A good rule of thumb is that if a method is meant to modify the diagnostics for a buffer (e.g. |vim.diagnostic.set()|) then it requires a namespace. - *diagnostic-structure* + *diagnostic-structure* 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 - end_lnum: The final line 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 - source: The source of the diagnostic - code: The diagnostic code - user_data: Arbitrary data plugins or users can add + bufnr: Buffer number + lnum(*): The starting line of the diagnostic + end_lnum: The final line 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 + 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 rows and columns). |api-indexing| - *vim.diagnostic.severity* *diagnostic-severity* + *vim.diagnostic.severity* *diagnostic-severity* The "severity" key in a diagnostic is one of the values defined in `vim.diagnostic.severity`: - vim.diagnostic.severity.ERROR - vim.diagnostic.severity.WARN - vim.diagnostic.severity.INFO - vim.diagnostic.severity.HINT + vim.diagnostic.severity.ERROR + vim.diagnostic.severity.WARN + vim.diagnostic.severity.INFO + vim.diagnostic.severity.HINT Functions that take a severity as an optional parameter (e.g. |vim.diagnostic.get()|) accept one of two forms: 1. A single |vim.diagnostic.severity| value: > - vim.diagnostic.get(0, { severity = vim.diagnostic.severity.WARN }) + vim.diagnostic.get(0, { severity = vim.diagnostic.severity.WARN }) 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. ============================================================================== -HANDLERS *diagnostic-handlers* +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) + 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) + function(namespace, bufnr) < Handlers can be configured with |vim.diagnostic.config()| and added by creating a new key in `vim.diagnostic.handlers` (see @@ -105,31 +105,31 @@ 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* + *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 - } - }) + -- 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. @@ -137,43 +137,43 @@ omit the "hide" function. Existing handlers can be overridden. 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, - } + -- 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* +HIGHLIGHTS *diagnostic-highlights* All highlights defined for diagnostics begin with `Diagnostic` followed by the type of highlight (e.g., `Sign`, `Underline`, etc.) and the severity (e.g. @@ -189,102 +189,102 @@ highlights), use the |:highlight| command: > highlight DiagnosticError guifg="BrightRed" < - *hl-DiagnosticError* + *hl-DiagnosticError* DiagnosticError - Used as the base highlight group. - Other Diagnostic highlights link to this by default (except Underline) + Used as the base highlight group. + Other Diagnostic highlights link to this by default (except Underline) - *hl-DiagnosticWarn* + *hl-DiagnosticWarn* DiagnosticWarn - Used as the base highlight group. - Other Diagnostic highlights link to this by default (except Underline) + Used as the base highlight group. + Other Diagnostic highlights link to this by default (except Underline) - *hl-DiagnosticInfo* + *hl-DiagnosticInfo* DiagnosticInfo - Used as the base highlight group. - Other Diagnostic highlights link to this by default (except Underline) + Used as the base highlight group. + Other Diagnostic highlights link to this by default (except Underline) - *hl-DiagnosticHint* + *hl-DiagnosticHint* DiagnosticHint - Used as the base highlight group. - Other Diagnostic highlights link to this by default (except Underline) + Used as the base highlight group. + Other Diagnostic highlights link to this by default (except Underline) - *hl-DiagnosticVirtualTextError* + *hl-DiagnosticVirtualTextError* DiagnosticVirtualTextError - Used for "Error" diagnostic virtual text. + Used for "Error" diagnostic virtual text. - *hl-DiagnosticVirtualTextWarn* + *hl-DiagnosticVirtualTextWarn* DiagnosticVirtualTextWarn - Used for "Warn" diagnostic virtual text. + Used for "Warn" diagnostic virtual text. - *hl-DiagnosticVirtualTextInfo* + *hl-DiagnosticVirtualTextInfo* DiagnosticVirtualTextInfo - Used for "Info" diagnostic virtual text. + Used for "Info" diagnostic virtual text. - *hl-DiagnosticVirtualTextHint* + *hl-DiagnosticVirtualTextHint* DiagnosticVirtualTextHint - Used for "Hint" diagnostic virtual text. + Used for "Hint" diagnostic virtual text. - *hl-DiagnosticUnderlineError* + *hl-DiagnosticUnderlineError* DiagnosticUnderlineError - Used to underline "Error" diagnostics. + Used to underline "Error" diagnostics. - *hl-DiagnosticUnderlineWarn* + *hl-DiagnosticUnderlineWarn* DiagnosticUnderlineWarn - Used to underline "Warn" diagnostics. + Used to underline "Warn" diagnostics. - *hl-DiagnosticUnderlineInfo* + *hl-DiagnosticUnderlineInfo* DiagnosticUnderlineInfo - Used to underline "Info" diagnostics. + Used to underline "Info" diagnostics. - *hl-DiagnosticUnderlineHint* + *hl-DiagnosticUnderlineHint* DiagnosticUnderlineHint - Used to underline "Hint" diagnostics. + Used to underline "Hint" diagnostics. - *hl-DiagnosticFloatingError* + *hl-DiagnosticFloatingError* DiagnosticFloatingError - Used to color "Error" diagnostic messages in diagnostics float. - See |vim.diagnostic.open_float()| + Used to color "Error" diagnostic messages in diagnostics float. + See |vim.diagnostic.open_float()| - *hl-DiagnosticFloatingWarn* + *hl-DiagnosticFloatingWarn* DiagnosticFloatingWarn - Used to color "Warn" diagnostic messages in diagnostics float. + Used to color "Warn" diagnostic messages in diagnostics float. - *hl-DiagnosticFloatingInfo* + *hl-DiagnosticFloatingInfo* DiagnosticFloatingInfo - Used to color "Info" diagnostic messages in diagnostics float. + Used to color "Info" diagnostic messages in diagnostics float. - *hl-DiagnosticFloatingHint* + *hl-DiagnosticFloatingHint* DiagnosticFloatingHint - Used to color "Hint" diagnostic messages in diagnostics float. + Used to color "Hint" diagnostic messages in diagnostics float. - *hl-DiagnosticSignError* + *hl-DiagnosticSignError* DiagnosticSignError - Used for "Error" signs in sign column. + Used for "Error" signs in sign column. - *hl-DiagnosticSignWarn* + *hl-DiagnosticSignWarn* DiagnosticSignWarn - Used for "Warn" signs in sign column. + Used for "Warn" signs in sign column. - *hl-DiagnosticSignInfo* + *hl-DiagnosticSignInfo* DiagnosticSignInfo - Used for "Info" signs in sign column. + Used for "Info" signs in sign column. - *hl-DiagnosticSignHint* + *hl-DiagnosticSignHint* DiagnosticSignHint - Used for "Hint" signs in sign column. + Used for "Hint" signs in sign column. ============================================================================== -SIGNS *diagnostic-signs* +SIGNS *diagnostic-signs* Signs are defined for each diagnostic severity. The default text for each sign is the first letter of the severity name (for example, "E" for ERROR). Signs can be customized using the following: > - sign define DiagnosticSignError text=E texthl=DiagnosticSignError linehl= numhl= - sign define DiagnosticSignWarn text=W texthl=DiagnosticSignWarn linehl= numhl= - sign define DiagnosticSignInfo text=I texthl=DiagnosticSignInfo linehl= numhl= - sign define DiagnosticSignHint text=H texthl=DiagnosticSignHint linehl= numhl= + sign define DiagnosticSignError text=E texthl=DiagnosticSignError linehl= numhl= + sign define DiagnosticSignWarn text=W texthl=DiagnosticSignWarn linehl= numhl= + sign define DiagnosticSignInfo text=I texthl=DiagnosticSignInfo linehl= numhl= + sign define DiagnosticSignHint text=H texthl=DiagnosticSignHint linehl= numhl= When the "severity_sort" option is set (see |vim.diagnostic.config()|) the priority of each sign depends on the severity of the associated diagnostic. @@ -292,459 +292,407 @@ Otherwise, all signs have the same priority (the value of the "priority" option in the "signs" table of |vim.diagnostic.config()| or 10 if unset). ============================================================================== -EVENTS *diagnostic-events* +EVENTS *diagnostic-events* - *DiagnosticChanged* -DiagnosticChanged After diagnostics have changed. + *DiagnosticChanged* +DiagnosticChanged After diagnostics have changed. Example: > - autocmd DiagnosticChanged * lua vim.diagnostic.setqflist({ open = false }) + autocmd DiagnosticChanged * lua vim.diagnostic.setqflist({ open = false }) < ============================================================================== Lua module: vim.diagnostic *diagnostic-api* config({opts}, {namespace}) *vim.diagnostic.config()* - Configure diagnostic options globally or for a specific - diagnostic namespace. + Configure diagnostic options globally or for a specific diagnostic + namespace. - Configuration can be specified globally, per-namespace, or - ephemerally (i.e. only for a single call to - |vim.diagnostic.set()| or |vim.diagnostic.show()|). Ephemeral - configuration has highest priority, followed by namespace - configuration, and finally global configuration. + Configuration can be specified globally, per-namespace, or ephemerally + (i.e. only for a single call to |vim.diagnostic.set()| or + |vim.diagnostic.show()|). Ephemeral configuration has highest priority, + followed by namespace configuration, and finally global configuration. - For example, if a user enables virtual text globally with > + For example, if a user enables virtual text globally with > - vim.diagnostic.config({ virtual_text = true }) + vim.diagnostic.config({ virtual_text = true }) < - and a diagnostic producer sets diagnostics with > + and a diagnostic producer sets diagnostics with > - vim.diagnostic.set(ns, 0, diagnostics, { virtual_text = false }) + vim.diagnostic.set(ns, 0, diagnostics, { virtual_text = false }) < - then virtual text will not be enabled for those diagnostics. - - 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 - empty table to use default values. - • `function`: Function with signature (namespace, bufnr) - that returns any of the above. - - Parameters: ~ - {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| - - • virtual_text: (default true) Use virtual - text for diagnostics. If multiple - diagnostics are set for a namespace, one - prefix per diagnostic + the last diagnostic - message are shown. Options: - • severity: Only show virtual text for - diagnostics matching the given severity - |diagnostic-severity| - • source: (boolean or string) Include the - diagnostic source in virtual text. Use - "if_many" to only show sources if there - is more than one diagnostic source in the - buffer. Otherwise, any truthy value means - to always show the diagnostic source. - • spacing: (number) Amount of empty spaces - inserted at the beginning of the virtual - text. - • prefix: (string) Prepend diagnostic - message with prefix. - • format: (function) A function that takes - a diagnostic as input and returns a - string. The return value is the text used - to display the diagnostic. Example: > - - function(diagnostic) - if diagnostic.severity == vim.diagnostic.severity.ERROR then - return string.format("E: %s", diagnostic.message) - end - return diagnostic.message - end + then virtual text will not be enabled for those diagnostics. + + 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 empty table to + use default values. + • `function`: Function with signature (namespace, bufnr) that returns + any of the above. + + Parameters: ~ + {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| + + • virtual_text: (default true) Use virtual text for + diagnostics. If multiple diagnostics are set for a + namespace, one prefix per diagnostic + the last + diagnostic message are shown. Options: + • severity: Only show virtual text for diagnostics + matching the given severity |diagnostic-severity| + • source: (boolean or string) Include the diagnostic + source in virtual text. Use "if_many" to only show + sources if there is more than one diagnostic source + in the buffer. Otherwise, any truthy value means to + always show the diagnostic source. + • spacing: (number) Amount of empty spaces inserted at + the beginning of the virtual text. + • prefix: (string) Prepend diagnostic message with + prefix. + • format: (function) A function that takes a diagnostic + as input and returns a string. The return value is + the text used to display the diagnostic. Example: > + + function(diagnostic) + if diagnostic.severity == vim.diagnostic.severity.ERROR then + return string.format("E: %s", diagnostic.message) + end + return diagnostic.message + end < - • signs: (default true) Use signs for - diagnostics. Options: - • severity: Only show signs for diagnostics - matching the given severity - |diagnostic-severity| - • priority: (number, default 10) Base - priority to use for signs. When - {severity_sort} is used, the priority of - a sign is adjusted based on its severity. - Otherwise, all signs use the same - priority. - - • float: Options for floating windows. See - |vim.diagnostic.open_float()|. - • update_in_insert: (default false) Update - diagnostics in Insert mode (if false, - diagnostics are updated on InsertLeave) - • severity_sort: (default false) Sort - diagnostics by severity. This affects the - order in which signs and virtual text are - displayed. When true, higher severities are - displayed before lower severities (e.g. - ERROR is displayed before WARN). Options: - • reverse: (boolean) Reverse sort order - {namespace} (number|nil) Update the options for the given - namespace. When omitted, update the global - diagnostic options. + • signs: (default true) Use signs for diagnostics. + Options: + • severity: Only show signs for diagnostics matching + the given severity |diagnostic-severity| + • priority: (number, default 10) Base priority to use + for signs. When {severity_sort} is used, the priority + of a sign is adjusted based on its severity. + Otherwise, all signs use the same priority. + + • float: Options for floating windows. See + |vim.diagnostic.open_float()|. + • update_in_insert: (default false) Update diagnostics in + Insert mode (if false, diagnostics are updated on + InsertLeave) + • severity_sort: (default false) Sort diagnostics by + severity. This affects the order in which signs and + virtual text are displayed. When true, higher + severities are displayed before lower severities (e.g. + ERROR is displayed before WARN). Options: + • reverse: (boolean) Reverse sort order + {namespace} (number|nil) Update the options for the given namespace. + When omitted, update the global diagnostic options. disable({bufnr}, {namespace}) *vim.diagnostic.disable()* - Disable diagnostics in the given buffer. + Disable diagnostics in the given buffer. - Parameters: ~ - {bufnr} (number|nil) Buffer number, or 0 for current - buffer. When omitted, disable diagnostics in - all buffers. - {namespace} (number|nil) Only disable diagnostics for the - given namespace. + Parameters: ~ + {bufnr} (number|nil) Buffer number, or 0 for current buffer. When + omitted, disable diagnostics in all buffers. + {namespace} (number|nil) Only disable diagnostics for the given + namespace. enable({bufnr}, {namespace}) *vim.diagnostic.enable()* - Enable diagnostics in the given buffer. + Enable diagnostics in the given buffer. - Parameters: ~ - {bufnr} (number|nil) Buffer number, or 0 for current - buffer. When omitted, enable diagnostics in - all buffers. - {namespace} (number|nil) Only enable diagnostics for the - given namespace. + Parameters: ~ + {bufnr} (number|nil) Buffer number, or 0 for current buffer. When + omitted, enable diagnostics in all buffers. + {namespace} (number|nil) Only enable diagnostics for the given + namespace. fromqflist({list}) *vim.diagnostic.fromqflist()* - Convert a list of quickfix items to a list of diagnostics. + Convert a list of quickfix items to a list of diagnostics. - Parameters: ~ - {list} (table) A list of quickfix items from - |getqflist()| or |getloclist()|. + Parameters: ~ + {list} (table) A list of quickfix items from |getqflist()| or + |getloclist()|. - Return: ~ - array of diagnostics |diagnostic-structure| + Return: ~ + array of diagnostics |diagnostic-structure| get({bufnr}, {opts}) *vim.diagnostic.get()* - Get current diagnostics. - - Parameters: ~ - {bufnr} (number|nil) Buffer number to get diagnostics - from. Use 0 for current buffer or nil for all - buffers. - {opts} (table|nil) A table with the following keys: - • namespace: (number) Limit diagnostics to the - given namespace. - • lnum: (number) Limit diagnostics to the given - line number. - • severity: See |diagnostic-severity|. - - Return: ~ - (table) A list of diagnostic items |diagnostic-structure|. + Get current diagnostics. + + Parameters: ~ + {bufnr} (number|nil) Buffer number to get diagnostics from. Use 0 for + current buffer or nil for all buffers. + {opts} (table|nil) A table with the following keys: + • namespace: (number) Limit diagnostics to the given + namespace. + • lnum: (number) Limit diagnostics to the given line number. + • severity: See |diagnostic-severity|. + + Return: ~ + (table) A list of diagnostic items |diagnostic-structure|. get_namespace({namespace}) *vim.diagnostic.get_namespace()* - Get namespace metadata. + Get namespace metadata. - Parameters: ~ - {namespace} (number) Diagnostic namespace + Parameters: ~ + {namespace} (number) Diagnostic namespace - Return: ~ - (table) Namespace metadata + Return: ~ + (table) Namespace metadata get_namespaces() *vim.diagnostic.get_namespaces()* - Get current diagnostic namespaces. + Get current diagnostic namespaces. - Return: ~ - (table) A list of active diagnostic namespaces - |vim.diagnostic|. + Return: ~ + (table) A list of active diagnostic namespaces |vim.diagnostic|. get_next({opts}) *vim.diagnostic.get_next()* - Get the next diagnostic closest to the cursor position. + Get the next diagnostic closest to the cursor position. - Parameters: ~ - {opts} (table) See |vim.diagnostic.goto_next()| + Parameters: ~ + {opts} (table) See |vim.diagnostic.goto_next()| - Return: ~ - (table) Next diagnostic + Return: ~ + (table) Next diagnostic get_next_pos({opts}) *vim.diagnostic.get_next_pos()* - Return the position of the next diagnostic in the current - buffer. + Return the position of the next diagnostic in the current buffer. - Parameters: ~ - {opts} (table) See |vim.diagnostic.goto_next()| + Parameters: ~ + {opts} (table) See |vim.diagnostic.goto_next()| - Return: ~ - (table) Next diagnostic position as a (row, col) tuple. + Return: ~ + (table) Next diagnostic position as a (row, col) tuple. get_prev({opts}) *vim.diagnostic.get_prev()* - Get the previous diagnostic closest to the cursor position. + Get the previous diagnostic closest to the cursor position. - Parameters: ~ - {opts} (table) See |vim.diagnostic.goto_next()| + Parameters: ~ + {opts} (table) See |vim.diagnostic.goto_next()| - Return: ~ - (table) Previous diagnostic + Return: ~ + (table) Previous diagnostic get_prev_pos({opts}) *vim.diagnostic.get_prev_pos()* - Return the position of the previous diagnostic in the current - buffer. + Return the position of the previous diagnostic in the current buffer. - Parameters: ~ - {opts} (table) See |vim.diagnostic.goto_next()| + Parameters: ~ + {opts} (table) See |vim.diagnostic.goto_next()| - Return: ~ - (table) Previous diagnostic position as a (row, col) - tuple. + Return: ~ + (table) Previous diagnostic position as a (row, col) tuple. goto_next({opts}) *vim.diagnostic.goto_next()* - Move to the next diagnostic. - - Parameters: ~ - {opts} (table|nil) Configuration table with the following - keys: - • namespace: (number) Only consider diagnostics - from the given namespace. - • cursor_position: (cursor position) Cursor - position as a (row, col) tuple. See - |nvim_win_get_cursor()|. Defaults to the current - cursor position. - • wrap: (boolean, default true) Whether to loop - around file or not. Similar to 'wrapscan'. - • severity: See |diagnostic-severity|. - • float: (boolean or table, default true) If - "true", call |vim.diagnostic.open_float()| after - moving. If a table, pass the table as the {opts} - parameter to |vim.diagnostic.open_float()|. - Unless overridden, the float will show - diagnostics at the new cursor position (as if - "cursor" were passed to the "scope" option). - • win_id: (number, default 0) Window ID + Move to the next diagnostic. + + Parameters: ~ + {opts} (table|nil) Configuration table with the following keys: + • namespace: (number) Only consider diagnostics from the given + namespace. + • cursor_position: (cursor position) Cursor position as a + (row, col) tuple. See |nvim_win_get_cursor()|. Defaults to + the current cursor position. + • wrap: (boolean, default true) Whether to loop around file or + not. Similar to 'wrapscan'. + • severity: See |diagnostic-severity|. + • float: (boolean or table, default true) If "true", call + |vim.diagnostic.open_float()| after moving. If a table, pass + the table as the {opts} parameter to + |vim.diagnostic.open_float()|. Unless overridden, the float + will show diagnostics at the new cursor position (as if + "cursor" were passed to the "scope" option). + • win_id: (number, default 0) Window ID goto_prev({opts}) *vim.diagnostic.goto_prev()* - Move to the previous diagnostic in the current buffer. + Move to the previous diagnostic in the current buffer. - Parameters: ~ - {opts} (table) See |vim.diagnostic.goto_next()| + Parameters: ~ + {opts} (table) See |vim.diagnostic.goto_next()| hide({namespace}, {bufnr}) *vim.diagnostic.hide()* - Hide currently displayed diagnostics. + Hide currently displayed diagnostics. - This only clears the decorations displayed in the buffer. - Diagnostics can be redisplayed with |vim.diagnostic.show()|. - To completely remove diagnostics, use - |vim.diagnostic.reset()|. + This only clears the decorations displayed in the buffer. Diagnostics can + be redisplayed with |vim.diagnostic.show()|. To completely remove + diagnostics, use |vim.diagnostic.reset()|. - To hide diagnostics and prevent them from re-displaying, use - |vim.diagnostic.disable()|. + To hide diagnostics and prevent them from re-displaying, use + |vim.diagnostic.disable()|. - Parameters: ~ - {namespace} (number|nil) Diagnostic namespace. When - omitted, hide diagnostics from all - namespaces. - {bufnr} (number|nil) Buffer number, or 0 for current - buffer. When omitted, hide diagnostics in all - buffers. + Parameters: ~ + {namespace} (number|nil) Diagnostic namespace. When omitted, hide + diagnostics from all namespaces. + {bufnr} (number|nil) Buffer number, or 0 for current buffer. When + omitted, hide diagnostics in all buffers. *vim.diagnostic.match()* match({str}, {pat}, {groups}, {severity_map}, {defaults}) - Parse a diagnostic from a string. + Parse a diagnostic from a string. - For example, consider a line of output from a linter: > + For example, consider a line of output from a linter: > - WARNING filename:27:3: Variable 'foo' does not exist + WARNING filename:27:3: Variable 'foo' does not exist < - This can be parsed into a diagnostic |diagnostic-structure| - with: > + This can be parsed into a diagnostic |diagnostic-structure| with: > - local s = "WARNING filename:27:3: Variable 'foo' does not exist" - local pattern = "^(%w+) %w+:(%d+):(%d+): (.+)$" |