Merge pull request #19685 from ii14/gen_vimdoc_indentation

docs: change gen_vimdoc indentation level
This commit is contained in:
Christian Clason 2022-08-11 14:34:00 +02:00 committed by GitHub
commit d1fb0dd8b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 5007 additions and 5561 deletions

File diff suppressed because it is too large Load Diff

View File

@ -304,14 +304,13 @@ Example: >
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 >
@ -326,48 +325,41 @@ config({opts}, {namespace}) *vim.diagnostic.config()*
then virtual text will not be enabled for those diagnostics.
Note:
Each of the configuration options below accepts one of the
following:
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.
• `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:
{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|
• 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: >
• 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
@ -377,60 +369,53 @@ config({opts}, {namespace}) *vim.diagnostic.config()*
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.
• 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.
• 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.
{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.
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.
{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.
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.
{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.
Parameters: ~
{list} (table) A list of quickfix items from
|getqflist()| or |getloclist()|.
{list} (table) A list of quickfix items from |getqflist()| or
|getloclist()|.
Return: ~
array of diagnostics |diagnostic-structure|
@ -439,14 +424,12 @@ 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.
{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.
• namespace: (number) Limit diagnostics to the given
namespace.
• lnum: (number) Limit diagnostics to the given line number.
• severity: See |diagnostic-severity|.
Return: ~
@ -465,8 +448,7 @@ get_namespaces() *vim.diagnostic.get_namespaces()*
Get current diagnostic namespaces.
Return: ~
(table) A list of active diagnostic namespaces
|vim.diagnostic|.
(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.
@ -478,8 +460,7 @@ get_next({opts}) *vim.diagnostic.get_next()*
(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()|
@ -497,37 +478,32 @@ get_prev({opts}) *vim.diagnostic.get_prev()*
(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()|
Return: ~
(table) Previous diagnostic position as a (row, col)
tuple.
(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'.
{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
• 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
@ -540,21 +516,18 @@ goto_prev({opts}) *vim.diagnostic.goto_prev()*
hide({namespace}, {bufnr}) *vim.diagnostic.hide()*
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()|.
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.
{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})
@ -565,8 +538,7 @@ match({str}, {pat}, {groups}, {severity_map}, {defaults})
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+): (.+)$"
@ -577,81 +549,66 @@ match({str}, {pat}, {groups}, {severity_map}, {defaults})
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.
{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}.
diagnostic |diagnostic-structure| or `nil` if {pat} fails to match
{str}.
open_float({opts}, {...}) *vim.diagnostic.open_float()*
Show diagnostics in a floating window.
Parameters: ~
{opts} (table|nil) Configuration table with the same keys
as |vim.lsp.util.open_floating_preview()| in
addition to the following:
• bufnr: (number) Buffer number to show
diagnostics from. Defaults to the current
buffer.
• namespace: (number) Limit diagnostics to the
given namespace
• scope: (string, default "line") Show diagnostics
from the whole buffer ("buffer"), the current
cursor line ("line"), or the current cursor
position ("cursor"). Shorthand versions are also
accepted ("c" for "cursor", "l" for "line", "b"
for "buffer").
• pos: (number or table) If {scope} is "line" or
"cursor", use this position rather than the
cursor position. If a number, interpreted as a
line number; otherwise, a (row, col) tuple.
• severity_sort: (default false) Sort diagnostics
by severity. Overrides the setting from
{opts} (table|nil) Configuration table with the same keys as
|vim.lsp.util.open_floating_preview()| in addition to the
following:
• bufnr: (number) Buffer number to show diagnostics from.
Defaults to the current buffer.
• namespace: (number) Limit diagnostics to the given namespace
• scope: (string, default "line") Show diagnostics from the
whole buffer ("buffer"), the current cursor line ("line"),
or the current cursor position ("cursor"). Shorthand
versions are also accepted ("c" for "cursor", "l" for
"line", "b" for "buffer").
• pos: (number or table) If {scope} is "line" or "cursor", use
this position rather than the cursor position. If a number,
interpreted as a line number; otherwise, a (row, col) tuple.
• severity_sort: (default false) Sort diagnostics by severity.
Overrides the setting from |vim.diagnostic.config()|.
• severity: See |diagnostic-severity|. Overrides the setting
from |vim.diagnostic.config()|.
• header: (string or table) String to use as the header for
the floating window. If a table, it is interpreted as a
[text, hl_group] tuple. Overrides the setting from
|vim.diagnostic.config()|.
• severity: See |diagnostic-severity|. Overrides
the setting from |vim.diagnostic.config()|.
• header: (string or table) String to use as the
header for the floating window. If a table, it
is interpreted as a [text, hl_group] tuple.
Overrides the setting from
|vim.diagnostic.config()|.
• source: (boolean or string) Include the
diagnostic source in the message. Use "if_many"
to only show sources if there is more than one
source of diagnostics in the buffer. Otherwise,
any truthy value means to always show the
• source: (boolean or string) Include the diagnostic source in
the message. Use "if_many" to only show sources if there is
more than one source of diagnostics in the buffer.
Otherwise, any truthy value means to always show the
diagnostic source. Overrides the setting from
|vim.diagnostic.config()|.
• 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. Overrides the setting from
• 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. Overrides the setting from
|vim.diagnostic.config()|.
• prefix: (function, string, or table) Prefix each
diagnostic in the floating window. If a
function, it must have the signature
(diagnostic, i, total) -> (string, string),
where {i} is the index of the diagnostic being
evaluated and {total} is the total number of
diagnostics displayed in the window. The
function should return a string which is
prepended to each diagnostic in the window as
well as an (optional) highlight group which will
be used to highlight the prefix. If {prefix} is
a table, it is interpreted as a [text, hl_group]
tuple as in |nvim_echo()|; otherwise, if
{prefix} is a string, it is prepended to each
diagnostic in the window with no highlight.
Overrides the setting from
• prefix: (function, string, or table) Prefix each diagnostic
in the floating window. If a function, it must have the
signature (diagnostic, i, total) -> (string, string), where
{i} is the index of the diagnostic being evaluated and
{total} is the total number of diagnostics displayed in the
window. The function should return a string which is
prepended to each diagnostic in the window as well as an
(optional) highlight group which will be used to highlight
the prefix. If {prefix} is a table, it is interpreted as a
[text, hl_group] tuple as in |nvim_echo()|; otherwise, if
{prefix} is a string, it is prepended to each diagnostic in
the window with no highlight. Overrides the setting from
|vim.diagnostic.config()|.
Return: ~
@ -660,19 +617,16 @@ open_float({opts}, {...}) *vim.diagnostic.open_float()*
reset({namespace}, {bufnr}) *vim.diagnostic.reset()*
Remove all diagnostics from the given namespace.
Unlike |vim.diagnostic.hide()|, this function removes all
saved diagnostics. They cannot be redisplayed using
|vim.diagnostic.show()|. To simply remove diagnostic
decorations in a way that they can be re-displayed, use
|vim.diagnostic.hide()|.
Unlike |vim.diagnostic.hide()|, this function removes all saved
diagnostics. They cannot be redisplayed using |vim.diagnostic.show()|. To
simply remove diagnostic decorations in a way that they can be
re-displayed, use |vim.diagnostic.hide()|.
Parameters: ~
{namespace} (number|nil) Diagnostic namespace. When
omitted, remove diagnostics from all
namespaces.
{bufnr} (number|nil) Remove diagnostics for the given
buffer. When omitted, diagnostics are removed
for all buffers.
{namespace} (number|nil) Diagnostic namespace. When omitted, remove
diagnostics from all namespaces.
{bufnr} (number|nil) Remove diagnostics for the given buffer.
When omitted, diagnostics are removed for all buffers.
set({namespace}, {bufnr}, {diagnostics}, {opts}) *vim.diagnostic.set()*
Set diagnostics for the given namespace and buffer.
@ -689,30 +643,28 @@ setloclist({opts}) *vim.diagnostic.setloclist()*
Add buffer diagnostics to the location list.
Parameters: ~
{opts} (table|nil) Configuration table with the following
keys:
• namespace: (number) Only add diagnostics from
the given namespace.
• winnr: (number, default 0) Window number to set
location list for.
• open: (boolean, default true) Open the location
list after setting.
• title: (string) Title of the location list.
Defaults to "Diagnostics".
{opts} (table|nil) Configuration table with the following keys:
• namespace: (number) Only add diagnostics from the given
namespace.
• winnr: (number, default 0) Window number to set location
list for.
• open: (boolean, default true) Open the location list after
setting.
• title: (string) Title of the location list. Defaults to
"Diagnostics".
• severity: See |diagnostic-severity|.
setqflist({opts}) *vim.diagnostic.setqflist()*
Add all diagnostics to the quickfix list.
Parameters: ~
{opts} (table|nil) Configuration table with the following
keys:
• namespace: (number) Only add diagnostics from
the given namespace.
• open: (boolean, default true) Open quickfix list
after setting.
• title: (string) Title of quickfix list. Defaults
to "Diagnostics".
{opts} (table|nil) Configuration table with the following keys:
• namespace: (number) Only add diagnostics from the given
namespace.
• open: (boolean, default true) Open quickfix list after
setting.
• title: (string) Title of quickfix list. Defaults to
"Diagnostics".
• severity: See |diagnostic-severity|.
*vim.diagnostic.show()*
@ -720,31 +672,27 @@ show({namespace}, {bufnr}, {diagnostics}, {opts})
Display diagnostics for the given namespace and buffer.
Parameters: ~
{namespace} (number|nil) Diagnostic namespace. When
omitted, show diagnostics from all
namespaces.
{bufnr} (number|nil) Buffer number, or 0 for
current buffer. When omitted, show
diagnostics in all buffers.
{diagnostics} (table|nil) The diagnostics to display.
When omitted, use the saved diagnostics for
the given namespace and buffer. This can be
used to display a list of diagnostics
without saving them or to display only a
subset of diagnostics. May not be used when
{namespace} or {bufnr} is nil.
{namespace} (number|nil) Diagnostic namespace. When omitted, show
diagnostics from all namespaces.
{bufnr} (number|nil) Buffer number, or 0 for current buffer.
When omitted, show diagnostics in all buffers.
{diagnostics} (table|nil) The diagnostics to display. When omitted,
use the saved diagnostics for the given namespace and
buffer. This can be used to display a list of
diagnostics without saving them or to display only a
subset of diagnostics. May not be used when {namespace}
or {bufnr} is nil.
{opts} (table|nil) Display options. See
|vim.diagnostic.config()|.
toqflist({diagnostics}) *vim.diagnostic.toqflist()*
Convert a list of diagnostics to a list of quickfix items that
can be passed to |setqflist()| or |setloclist()|.
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|.
{diagnostics} (table) List of diagnostics |diagnostic-structure|.
Return: ~
array of quickfix list items |setqflist-what|
vim:tw=78:ts=8:ft=help:norl:
vim:tw=78:ts=8:sw=4:sts=4:et:ft=help:norl:

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -64,16 +64,15 @@ be very frequent. Rather a plugin that does any kind of analysis on a tree
should use a timer to throttle too frequent updates.
tsparser:set_included_regions({region_list}) *tsparser:set_included_regions()*
Changes the regions the parser should consider. This is used for
language injection. {region_list} should be of the form
(all zero-based): >
Changes the regions the parser should consider. This is used for language
injection. {region_list} should be of the form (all zero-based): >
{
{node1, node2},
...
}
<
`node1` and `node2` are both considered part of the same region and
will be parsed together with the parser in the same context.
`node1` and `node2` are both considered part of the same region and will
be parsed together with the parser in the same context.
Tree methods *lua-treesitter-tree*
@ -102,10 +101,10 @@ tsnode:prev_named_sibling() *tsnode:prev_named_sibling()*
Get the node's previous named sibling.
tsnode:iter_children() *tsnode:iter_children()*
Iterates over all the direct children of {tsnode}, regardless of
whether they are named or not.
Returns the child node plus the eventual field name corresponding to
this child node.
Iterates over all the direct children of {tsnode}, regardless of whether
they are named or not.
Returns the child node plus the eventual field name corresponding to this
child node.
tsnode:field({name}) *tsnode:field()*
Returns a table of the nodes corresponding to the {name} field.
@ -114,27 +113,27 @@ tsnode:child_count() *tsnode:child_count()*
Get the node's number of children.
tsnode:child({index}) *tsnode:child()*
Get the node's child at the given {index}, where zero represents the
first child.
Get the node's child at the given {index}, where zero represents the first
child.
tsnode:named_child_count() *tsnode:named_child_count()*
Get the node's number of named children.
tsnode:named_child({index}) *tsnode:named_child()*
Get the node's named child at the given {index}, where zero represents
the first named child.
Get the node's named child at the given {index}, where zero represents the
first named child.
tsnode:start() *tsnode:start()*
Get the node's start position. Return three values: the row, column
and total byte count (all zero-based).
Get the node's start position. Return three values: the row, column and
total byte count (all zero-based).
tsnode:end_() *tsnode:end_()*
Get the node's end position. Return three values: the row, column
and total byte count (all zero-based).
Get the node's end position. Return three values: the row, column and
total byte count (all zero-based).
tsnode:range() *tsnode:range()*
Get the range of the node. Return four values: the row, column
of the start position, then the row, column of the end position.
Get the range of the node. Return four values: the row, column of the
start position, then the row, column of the end position.
tsnode:type() *tsnode:type()*
Get the node's type as a string.
@ -143,13 +142,13 @@ tsnode:symbol() *tsnode:symbol()*
Get the node's type as a numerical id.
tsnode:named() *tsnode:named()*
Check if the node is named. Named nodes correspond to named rules in
the grammar, whereas anonymous nodes correspond to string literals
in the grammar.
Check if the node is named. Named nodes correspond to named rules in the
grammar, whereas anonymous nodes correspond to string literals in the
grammar.
tsnode:missing() *tsnode:missing()*
Check if the node is missing. Missing nodes are inserted by the
parser in order to recover from certain kinds of syntax errors.
Check if the node is missing. Missing nodes are inserted by the parser in
order to recover from certain kinds of syntax errors.
tsnode:has_error() *tsnode:has_error()*
Check if the node is a syntax error or contains any syntax errors.
@ -160,22 +159,22 @@ tsnode:sexpr() *tsnode:sexpr()*
tsnode:id() *tsnode:id()*
Get an unique identifier for the node inside its own tree.
No guarantees are made about this identifier's internal
representation, except for being a primitive lua type with value
equality (so not a table). Presently it is a (non-printable) string.
No guarantees are made about this identifier's internal representation,
except for being a primitive lua type with value equality (so not a
table). Presently it is a (non-printable) string.
Note: the id is not guaranteed to be unique for nodes from different
trees.
*tsnode:descendant_for_range()*
tsnode:descendant_for_range({start_row}, {start_col}, {end_row}, {end_col})
Get the smallest node within this node that spans the given range of
(row, column) positions
Get the smallest node within this node that spans the given range of (row,
column) positions
*tsnode:named_descendant_for_range()*
tsnode:named_descendant_for_range({start_row}, {start_col}, {end_row}, {end_col})
Get the smallest named node within this node that spans the given
range of (row, column) positions
Get the smallest named node within this node that spans the given range of
(row, column) positions
Query *lua-treesitter-query*
@ -216,27 +215,24 @@ Here is a list of built-in predicates :
This will match if the provided vim regex matches the text
corresponding to a node: >
((identifier) @constant (#match? @constant "^[A-Z_]+$"))
< Note: the `^` and `$` anchors will respectively match the
start and end of the node's text.
< Note: the `^` and `$` anchors will respectively match the start and
end of the node's text.
`lua-match?` *ts-predicate-lua-match?*
This will match the same way than |match?| but using lua
regexes.
This will match the same way than |match?| but using lua regexes.
`contains?` *ts-predicate-contains?*
Will check if any of the following arguments appears in the
text corresponding to the node: >
Will check if any of the following arguments appears in the text
corresponding to the node: >
((identifier) @foo (#contains? @foo "foo"))
((identifier) @foo-bar (#contains @foo-bar "foo" "bar"))
<
`any-of?` *ts-predicate-any-of?*
Will check if the text is the same as any of the following
arguments: >
Will check if the text is the same as any of the following arguments: >
((identifier) @foo (#any-of? @foo "foo" "bar"))
<
This is the recommended way to check if the node matches one
of many keywords for example, as it has been optimized for
this.
This is the recommended way to check if the node matches one of many
keywords for example, as it has been optimized for this.
<
*lua-treesitter-not-predicate*
Each predicate has a `not-` prefixed predicate that is just the negation of
@ -264,9 +260,9 @@ predicate sets metadata on the match or node : >
Built-in directives:
`set!` *ts-directive-set!*
Sets key/value metadata for a specific match or capture.
Value is accessible as either `metadata[key]` (match
specific) or `metadata[capture_id][key]` (capture specific).
Sets key/value metadata for a specific match or capture. Value is
accessible as either `metadata[key]` (match specific) or
`metadata[capture_id][key]` (capture specific).
Parameters: ~
{capture_id} (optional)
@ -278,9 +274,9 @@ Built-in directives:
((node1) @left (node2) @right (#set! "type" "pair"))
<
`offset!` *ts-directive-offset!*
Takes the range of the captured node and applies an offset.
This will generate a new range object for the captured node
as `metadata[capture_id].range`.
Takes the range of the captured node and applies an offset. This will
generate a new range object for the captured node as
`metadata[capture_id].range`.
Parameters: ~
{capture_id}
@ -359,14 +355,13 @@ Lua module: vim.treesitter *lua-treesitter-core*
get_parser({bufnr}, {lang}, {opts}) *get_parser()*
Gets the parser for this bufnr / ft combination.
If needed this will create the parser. Unconditionally attach
the provided callback
If needed this will create the parser. Unconditionally attach the provided
callback
Parameters: ~
{bufnr} The buffer the parser should be tied to
{lang} The filetype of this parser
{opts} Options object to pass to the created language
tree
{opts} Options object to pass to the created language tree
Return: ~
The parser
@ -386,15 +381,15 @@ Lua module: vim.treesitter.language *treesitter-language*
inspect_language({lang}) *inspect_language()*
Inspects the provided language.
Inspecting provides some useful information on the language
like node names, ...
Inspecting provides some useful information on the language like node
names, ...
Parameters: ~
{lang} The language.
require_language({lang}, {path}, {silent}) *require_language()*
Asserts that the provided language is installed, and
optionally provide a path for the parser
Asserts that the provided language is installed, and optionally provide a
path for the parser
Parsers are searched in the `parser` runtime directory.
@ -410,31 +405,30 @@ Lua module: vim.treesitter.query *treesitter-query*
add_directive({name}, {handler}, {force}) *add_directive()*
Adds a new directive to be used in queries
Handlers can set match level data by setting directly on the
metadata object `metadata.key = value`, additionally, handlers
can set node level data by using the capture id on the
metadata table `metadata[capture_id].key = value`
Handlers can set match level data by setting directly on the metadata
object `metadata.key = value`, additionally, handlers can set node level
data by using the capture id on the metadata table
`metadata[capture_id].key = value`
Parameters: ~
{name} the name of the directive, without leading #
{handler} the handler function to be used signature will
be (match, pattern, bufnr, predicate, metadata)
{handler} the handler function to be used signature will be (match,
pattern, bufnr, predicate, metadata)
add_predicate({name}, {handler}, {force}) *add_predicate()*
Adds a new predicate to be used in queries
Parameters: ~
{name} the name of the predicate, without leading #
{handler} the handler function to be used signature will
be (match, pattern, bufnr, predicate)
{handler} the handler function to be used signature will be (match,
pattern, bufnr, predicate)
get_node_text({node}, {source}) *get_node_text()*
Gets the text corresponding to a given node
Parameters: ~
{node} the node
{source} The buffer or string from which the node is
extracted
{source} The buffer or string from which the node is extracted
get_query({lang}, {query_name}) *get_query()*
Returns the runtime query {query_name} for {lang}.
@ -453,8 +447,7 @@ get_query_files({lang}, {query_name}, {is_included})
Parameters: ~
{lang} The language
{query_name} The name of the query to load
{is_included} Internal parameter, most of the time left
as `nil`
{is_included} Internal parameter, most of the time left as `nil`
list_directives() *list_directives()*
Lists the currently available directives to use in queries.
@ -467,22 +460,21 @@ list_predicates() *list_predicates()*
The list of supported predicates.
parse_query({lang}, {query}) *parse_query()*
Parse {query} as a string. (If the query is in a file, the
caller should read the contents into a string before calling).
Parse {query} as a string. (If the query is in a file, the caller should
read the contents into a string before calling).
Returns a `Query` (see |lua-treesitter-query|) object which
can be used to search nodes in the syntax tree for the
patterns defined in {query} using `iter_*` methods below.
Returns a `Query` (see |lua-treesitter-query|) object which can be used to
search nodes in the syntax tree for the patterns defined in {query} using
`iter_*` methods below.
Exposes `info` and `captures` with additional context about {query}.
• `captures` contains the list of unique capture names defined
in {query}. -`info.captures` also points to `captures`.
• `captures` contains the list of unique capture names defined in {query}.
-`info.captures` also points to `captures`.
• `info.patterns` contains information about predicates.
Parameters: ~
{lang} (string) The language
{query} (string) A string containing the query (s-expr
syntax)
{query} (string) A string containing the query (s-expr syntax)
Return: ~
The query
@ -491,19 +483,16 @@ parse_query({lang}, {query}) *parse_query()*
Query:iter_captures({self}, {node}, {source}, {start}, {stop})
Iterate over all captures from all matches inside {node}
{source} is needed if the query contains predicates, then the
caller must ensure to use a freshly parsed tree consistent
with the current text of the buffer (if relevant). {start_row}
and {end_row} can be used to limit matches inside a row range
(this is typically used with root node as the node, i e to get
syntax highlight matches in the current viewport). When
omitted the start and end row values are used from the given
node.
{source} is needed if the query contains predicates, then the caller must
ensure to use a freshly parsed tree consistent with the current text of
the buffer (if relevant). {start_row} and {end_row} can be used to limit
matches inside a row range (this is typically used with root node as the
node, i e to get syntax highlight matches in the current viewport). When
omitted the start and end row values are used from the given node.
The iterator returns three values, a numeric id identifying
the capture, the captured node, and metadata from any
directives processing the match. The following example shows
how to get captures by name:
The iterator returns three values, a numeric id identifying the capture,
the captured node, and metadata from any directives processing the match.
The following example shows how to get captures by name:
>
for id, node, metadata in query:iter_captures(tree:root(), bufnr, first, last) do
@ -530,13 +519,12 @@ Query:iter_captures({self}, {node}, {source}, {start}, {stop})
Query:iter_matches({self}, {node}, {source}, {start}, {stop})
Iterates the matches of self on a given range.
Iterate over all matches within a node. The arguments are the
same as for |query:iter_captures()| but the iterated values
are different: an (1-based) index of the pattern in the query,
a table mapping capture indices to nodes, and metadata from
any directives processing the match. If the query has more
than one pattern the capture table might be sparse, and e.g.
`pairs()` method should be used over `ipairs`. Here an example
Iterate over all matches within a node. The arguments are the same as for
|query:iter_captures()| but the iterated values are different: an
(1-based) index of the pattern in the query, a table mapping capture
indices to nodes, and metadata from any directives processing the match.
If the query has more than one pattern the capture table might be sparse,
and e.g. `pairs()` method should be used over `ipairs`. Here an example
iterating over all captures in every match:
>
@ -566,13 +554,12 @@ Query:iter_matches({self}, {node}, {source}, {start}, {stop})
set_query({lang}, {query_name}, {text}) *set_query()*
Sets the runtime query {query_name} for {lang}
This allows users to override any runtime files and/or
configuration set by plugins.
This allows users to override any runtime files and/or configuration set
by plugins.
Parameters: ~
{lang} string: The language to use for the query
{query_name} string: The name of the query (i.e.
"highlights")
{query_name} string: The name of the query (i.e. "highlights")
{text} string: The query text (unparsed).
@ -585,8 +572,7 @@ new({tree}, {opts}) *highlighter.new()*
Parameters: ~
{tree} The language tree to use for highlighting
{opts} Table used to configure the highlighter
• queries: Table to overwrite queries used by the
highlighter
• queries: Table to overwrite queries used by the highlighter
TSHighlighter:destroy({self}) *TSHighlighter:destroy()*
Removes all internal references to the highlighter
@ -608,8 +594,7 @@ Lua module: vim.treesitter.languagetree *treesitter-languagetree*
LanguageTree:add_child({self}, {lang}) *LanguageTree:add_child()*
Adds a child language to this tree.
If the language already exists as a child, it will first be
removed.
If the language already exists as a child, it will first be removed.
Parameters: ~
{lang} The language to add.
@ -625,8 +610,8 @@ LanguageTree:contains({self}, {range}) *LanguageTree:contains()*
Determines whether {range} is contained in this language tree
Parameters: ~
{range} A range, that is a `{ start_line, start_col,
end_line, end_col }` table.
{range} A range, that is a `{ start_line, start_col, end_line,
end_col }` table.
{self}
LanguageTree:destroy({self}) *LanguageTree:destroy()*
@ -641,27 +626,22 @@ LanguageTree:destroy({self}) *LanguageTree:destroy()*
*LanguageTree:for_each_child()*
LanguageTree:for_each_child({self}, {fn}, {include_self})
Invokes the callback for each LanguageTree and it's children
recursively
Invokes the callback for each LanguageTree and it's children recursively
Parameters: ~
{fn} The function to invoke. This is invoked
with arguments (tree: LanguageTree, lang:
string)
{include_self} Whether to include the invoking tree in
the results.
{fn} The function to invoke. This is invoked with arguments
(tree: LanguageTree, lang: string)
{include_self} Whether to include the invoking tree in the results.
{self}
LanguageTree:for_each_tree({self}, {fn}) *LanguageTree:for_each_tree()*
Invokes the callback for each treesitter trees recursively.
Note, this includes the invoking language tree's trees as
well.
Note, this includes the invoking language tree's trees as well.
Parameters: ~
{fn} The callback to invoke. The callback is invoked
with arguments (tree: TSTree, languageTree:
LanguageTree)
{fn} The callback to invoke. The callback is invoked with arguments
(tree: TSTree, languageTree: LanguageTree)
{self}
LanguageTree:included_regions({self}) *LanguageTree:included_regions()*
@ -677,8 +657,7 @@ LanguageTree:invalidate({self}, {reload}) *LanguageTree:invalidate()*
{self}
LanguageTree:is_valid({self}) *LanguageTree:is_valid()*
Determines whether this tree is valid. If the tree is invalid,
call `parse()` . This will return the updated tree.
Determines whether this tree is valid. If the tree is invalid, call `parse()` . This will return the updated tree.
Parameters: ~
{self}
@ -698,10 +677,9 @@ LanguageTree:language_for_range({self}, {range})
{self}
LanguageTree:parse({self}) *LanguageTree:parse()*
Parses all defined regions using a treesitter parser for the
language this tree represents. This will run the injection
query for this language to determine if any child languages
should be created.
Parses all defined regions using a treesitter parser for the language this
tree represents. This will run the injection query for this language to
determine if any child languages should be created.
Parameters: ~
{self}
@ -710,19 +688,17 @@ LanguageTree:register_cbs({self}, {cbs}) *LanguageTree:register_cbs()*
Registers callbacks for the parser.
Parameters: ~
{cbs} (table) An |nvim_buf_attach()|-like table argument
with the following keys :
• `on_bytes` : see |nvim_buf_attach()|, but this will be
called after the parsers callback.
• `on_changedtree` : a callback that will be
called every time the tree has syntactical
changes. It will only be passed one argument,
which is a table of the ranges (as node ranges)
{cbs} (table) An |nvim_buf_attach()|-like table argument with the
following keys :
• `on_bytes` : see |nvim_buf_attach()|, but this will be called after the parsers callback.
• `on_changedtree` : a callback that will be called every time
the tree has syntactical changes. It will only be passed one
argument, which is a table of the ranges (as node ranges)
that changed.
• `on_child_added` : emitted when a child is added
to the tree.
• `on_child_removed` : emitted when a child is
removed from the tree.
• `on_child_added` : emitted when a child is added to the
tree.
• `on_child_removed` : emitted when a child is removed from
the tree.
{self}
LanguageTree:remove_child({self}, {lang}) *LanguageTree:remove_child()*
@ -734,58 +710,50 @@ LanguageTree:remove_child({self}, {lang}) *LanguageTree:remove_child()*
*LanguageTree:set_included_regions()*
LanguageTree:set_included_regions({self}, {regions})
Sets the included regions that should be parsed by this
parser. A region is a set of nodes and/or ranges that will be
parsed in the same context.
Sets the included regions that should be parsed by this parser. A region
is a set of nodes and/or ranges that will be parsed in the same context.
For example, `{ { node1 }, { node2} }` is two separate
regions. This will be parsed by the parser in two different
contexts... thus resulting in two separate trees.
For example, `{ { node1 }, { node2} }` is two separate regions. This will
be parsed by the parser in two different contexts... thus resulting in two
separate trees.
`{ { node1, node2 } }` is a single region consisting of two
nodes. This will be parsed by the parser in a single
context... thus resulting in a single tree.
`{ { node1, node2 } }` is a single region consisting of two nodes. This
will be parsed by the parser in a single context... thus resulting in a
single tree.
This allows for embedded languages to be parsed together
across different nodes, which is useful for templating
languages like ERB and EJS.
This allows for embedded languages to be parsed together across different
nodes, which is useful for templating languages like ERB and EJS.
Note, this call invalidates the tree and requires it to be
parsed again.
Note, this call invalidates the tree and requires it to be parsed again.
Parameters: ~
{regions} (table) list of regions this tree should manage
and parse.
{regions} (table) list of regions this tree should manage and parse.
{self}
LanguageTree:source({self}) *LanguageTree:source()*
Returns the source content of the language tree (bufnr or
string).
Returns the source content of the language tree (bufnr or string).
Parameters: ~
{self}
LanguageTree:trees({self}) *LanguageTree:trees()*
Returns all trees this language tree contains. Does not
include child languages.
Returns all trees this language tree contains. Does not include child
languages.
Parameters: ~
{self}
new({source}, {lang}, {opts}) *languagetree.new()*
Represents a single treesitter parser for a language. The
language can contain child languages with in its range, hence
the tree.
Represents a single treesitter parser for a language. The language can
contain child languages with in its range, hence the tree.
Parameters: ~
{source} Can be a bufnr or a string of text to
parse
{source} Can be a bufnr or a string of text to parse
{lang} The language this tree represents
{opts} Options table
{opts.injections} A table of language to injection query
strings. This is useful for overriding
the built-in runtime file searching for
the injection language query per
{opts.injections} A table of language to injection query strings.
This is useful for overriding the built-in runtime
file searching for the injection language query per
language.
vim:tw=78:ts=8:ft=help:norl:
vim:tw=78:ts=8:sw=4:sts=4:et:ft=help:norl:

View File

@ -26,7 +26,7 @@ Each function :help block is formatted as follows:
- Max width of 78 columns (`text_width`).
- Indent with spaces (not tabs).
- Indent of 16 columns for body text.
- Indent of 4 columns for body text (`indentation`).
- Function signature and helptag (right-aligned) on the same line.
- Signature and helptag must have a minimum of 8 spaces between them.
- If the signature is too long, it is placed on the line after the helptag.
@ -80,6 +80,7 @@ LOG_LEVELS = {
}
text_width = 78
indentation = 4
script_path = os.path.abspath(__file__)
base_dir = os.path.dirname(os.path.dirname(script_path))
out_dir = os.path.join(base_dir, 'tmp-{target}-doc')
@ -456,7 +457,7 @@ def max_name(names):
return max(len(name) for name in names)
def update_params_map(parent, ret_map, width=62):
def update_params_map(parent, ret_map, width=text_width - indentation):
"""Updates `ret_map` with name:desc key-value pairs extracted
from Doxygen XML node `parent`.
"""
@ -483,7 +484,8 @@ def update_params_map(parent, ret_map, width=62):
return ret_map
def render_node(n, text, prefix='', indent='', width=62, fmt_vimhelp=False):
def render_node(n, text, prefix='', indent='', width=text_width - indentation,
fmt_vimhelp=False):
"""Renders a node as Vim help text, recursively traversing all descendants."""
def ind(s):
@ -562,7 +564,7 @@ def render_node(n, text, prefix='', indent='', width=62, fmt_vimhelp=False):
return text
def para_as_map(parent, indent='', width=62, fmt_vimhelp=False):
def para_as_map(parent, indent='', width=text_width - indentation, fmt_vimhelp=False):
"""Extracts a Doxygen XML <para> node to a map.
Keys:
@ -656,7 +658,8 @@ def para_as_map(parent, indent='', width=62, fmt_vimhelp=False):
return chunks, xrefs
def fmt_node_as_vimhelp(parent, width=62, indent='', fmt_vimhelp=False):
def fmt_node_as_vimhelp(parent, width=text_width - indentation, indent='',
fmt_vimhelp=False):
"""Renders (nested) Doxygen <para> nodes as Vim :help text.
NB: Blank lines in a docstring manifest as <para> tags.
@ -838,7 +841,8 @@ def extract_from_xml(filename, target, width, fmt_vimhelp):
log.debug(
textwrap.indent(
re.sub(r'\n\s*\n+', '\n',
desc.toprettyxml(indent=' ', newl='\n')), ' ' * 16))
desc.toprettyxml(indent=' ', newl='\n')),
' ' * indentation))
fn = {
'annotations': list(annotations),
@ -918,7 +922,7 @@ def fmt_doxygen_xml_as_vimhelp(filename, target):
doc += '\n<'
func_doc = fn['signature'] + '\n'
func_doc += textwrap.indent(clean_lines(doc), ' ' * 16)
func_doc += textwrap.indent(clean_lines(doc), ' ' * indentation)
# Verbatim handling.
func_doc = re.sub(r'^\s+([<>])$', r'\1', func_doc, flags=re.M)
@ -1114,7 +1118,7 @@ def main(config, args):
docs += '\n\n\n'
docs = docs.rstrip() + '\n\n'
docs += ' vim:tw=78:ts=8:ft=help:norl:\n'
docs += f' vim:tw=78:ts=8:sw={indentation}:sts={indentation}:et:ft=help:norl:\n'
doc_file = os.path.join(base_dir, 'runtime', 'doc',
CONFIG[target]['filename'])