aboutsummaryrefslogtreecommitdiff
path: root/runtime/doc
diff options
context:
space:
mode:
authorGregory Anders <greg@gpanders.com>2021-09-19 16:13:23 -0600
committerGitHub <noreply@github.com>2021-09-19 15:13:23 -0700
commite61ea7772e5eab2d0460dae858698f16b0ee8f27 (patch)
tree4991ac500046d80bb9cd28e3df7536c05f7d04cd /runtime/doc
parent853346a94d6aa78c97314a3b217fb5a5408a47f1 (diff)
downloadrneovim-e61ea7772e5eab2d0460dae858698f16b0ee8f27.tar.gz
rneovim-e61ea7772e5eab2d0460dae858698f16b0ee8f27.tar.bz2
rneovim-e61ea7772e5eab2d0460dae858698f16b0ee8f27.zip
feat(diagnostic): match(), tolist(), fromlist() #15704
* feat(diagnostic): add vim.diagnostic.match() Provide vim.diagnostic.match() to generate a diagnostic from a string and a Lua pattern. * feat(diagnostic): add tolist() and fromlist()
Diffstat (limited to 'runtime/doc')
-rw-r--r--runtime/doc/deprecated.txt1
-rw-r--r--runtime/doc/diagnostic.txt60
2 files changed, 59 insertions, 2 deletions
diff --git a/runtime/doc/deprecated.txt b/runtime/doc/deprecated.txt
index d1f26c8c81..a0c291964e 100644
--- a/runtime/doc/deprecated.txt
+++ b/runtime/doc/deprecated.txt
@@ -96,6 +96,7 @@ internally and are no longer exposed as part of the API. Instead, use
LSP Utility Functions ~
+*vim.lsp.util.diagnostics_to_items()* Use |vim.diagnostic.toqflist()| instead.
*vim.lsp.util.set_qflist()* Use |setqflist()| instead.
*vim.lsp.util.set_loclist()* Use |setloclist()| instead.
diff --git a/runtime/doc/diagnostic.txt b/runtime/doc/diagnostic.txt
index 199c04be98..59b73771a6 100644
--- a/runtime/doc/diagnostic.txt
+++ b/runtime/doc/diagnostic.txt
@@ -182,8 +182,8 @@ 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 DiagnosticSignWarning text=W texthl=DiagnosticSignWarning linehl= numhl=
- sign define DiagnosticSignInformation text=I texthl=DiagnosticSignInformation 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=
==============================================================================
@@ -265,6 +265,16 @@ enable({bufnr}, {namespace}) *vim.diagnostic.enable()*
{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.
+
+ Parameters: ~
+ {list} table A list of quickfix items from |getqflist()|
+ or |getloclist()|.
+
+ Return: ~
+ array of diagnostics |diagnostic-structure|
+
get({bufnr}, {opts}) *vim.diagnostic.get()*
Get current diagnostics.
@@ -384,6 +394,41 @@ hide({namespace}, {bufnr}) *vim.diagnostic.hide()*
{bufnr} number|nil Buffer number. Defaults to the
current buffer.
+ *vim.diagnostic.match()*
+match({str}, {pat}, {groups}, {severity_map}, {defaults})
+ Parse a diagnostic from a string.
+
+ For example, consider a line of output from a linter: >
+
+ WARNING filename:27:3: Variable 'foo' does not exist
+
+ < 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+): (.+)$"
+ local groups = {"severity", "lnum", "col", "message"}
+ vim.diagnostic.match(s, pattern, groups, {WARNING = vim.diagnostic.WARN})
+<
+
+ Parameters: ~
+ {str} string String to parse diagnostics from.
+ {pat} string Lua pattern with capture groups.
+ {groups} table List of fields in a
+ |diagnostic-structure| to associate with
+ captures from {pat}.
+ {severity_map} table A table mapping the severity field
+ from {groups} with an item from
+ |vim.diagnostic.severity|.
+ {defaults} table|nil Table of default values for any
+ fields not listed in {groups}. When
+ omitted, numeric values default to 0 and
+ "severity" defaults to ERROR.
+
+ Return: ~
+ diagnostic |diagnostic-structure| or `nil` if {pat} fails
+ to match {str}.
+
reset({namespace}, {bufnr}) *vim.diagnostic.reset()*
Remove all diagnostics from the given namespace.
@@ -495,4 +540,15 @@ show_position_diagnostics({opts}, {bufnr}, {position})
Return: ~
tuple ({popup_bufnr}, {win_id})
+toqflist({diagnostics}) *vim.diagnostic.toqflist()*
+ Convert a list of diagnostics to a list of quickfix items that
+ can be passed to |setqflist()| or |setloclist()|.
+
+ Parameters: ~
+ {diagnostics} table List of diagnostics
+ |diagnostic-structure|.
+
+ Return: ~
+ array of quickfix list items |setqflist-what|
+
vim:tw=78:ts=8:ft=help:norl: