aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/autoload/freebasic.vim3
-rw-r--r--runtime/doc/api.txt29
-rw-r--r--runtime/doc/builtin.txt24
-rw-r--r--runtime/doc/editing.txt5
-rw-r--r--runtime/doc/eval.txt5
-rw-r--r--runtime/doc/lsp.txt4
-rw-r--r--runtime/doc/lua.txt23
-rw-r--r--runtime/doc/map.txt4
-rw-r--r--runtime/doc/treesitter.txt132
-rw-r--r--runtime/filetype.vim3
-rw-r--r--runtime/lua/vim/filetype.lua2
-rw-r--r--runtime/lua/vim/lsp.lua2
-rw-r--r--runtime/lua/vim/treesitter/highlighter.lua18
-rw-r--r--runtime/lua/vim/treesitter/languagetree.lua28
-rw-r--r--runtime/lua/vim/treesitter/query.lua16
15 files changed, 192 insertions, 106 deletions
diff --git a/runtime/autoload/freebasic.vim b/runtime/autoload/freebasic.vim
index fe6d2745be..428cf1382b 100644
--- a/runtime/autoload/freebasic.vim
+++ b/runtime/autoload/freebasic.vim
@@ -23,8 +23,7 @@ function! freebasic#GetDialect() abort
let save_cursor = getcurpos()
call cursor(1, 1)
- " let lnum = search(pat, 'n', '', '', skip) " 'skip' needs 8.2.0915
- let lnum = search(pat, 'n', '', '')
+ let lnum = search(pat, 'n', '', '', skip)
call setpos('.', save_cursor)
if lnum
diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt
index 7bae5bb94b..1e1534c31f 100644
--- a/runtime/doc/api.txt
+++ b/runtime/doc/api.txt
@@ -855,7 +855,7 @@ nvim_exec_lua({code}, {args}) *nvim_exec_lua()*
Return: ~
Return value of Lua code if present or NIL.
-nvim_feedkeys({keys}, {mode}, {escape_csi}) *nvim_feedkeys()*
+nvim_feedkeys({keys}, {mode}, {escape_ks}) *nvim_feedkeys()*
Sends input-keys to Nvim, subject to various quirks controlled
by `mode` flags. This is a blocking call, unlike
|nvim_input()|.
@@ -863,23 +863,25 @@ nvim_feedkeys({keys}, {mode}, {escape_csi}) *nvim_feedkeys()*
On execution error: does not fail, but updates v:errmsg.
To input sequences like <C-o> use |nvim_replace_termcodes()|
- (typically with escape_csi=true) to replace |keycodes|, then
+ (typically with escape_ks=false) to replace |keycodes|, then
pass the result to nvim_feedkeys().
Example: >
:let key = nvim_replace_termcodes("<C-o>", v:true, v:false, v:true)
- :call nvim_feedkeys(key, 'n', v:true)
+ :call nvim_feedkeys(key, 'n', v:false)
<
Parameters: ~
- {keys} to be typed
- {mode} behavior flags, see |feedkeys()|
- {escape_csi} If true, escape K_SPECIAL/CSI bytes in
- `keys`
+ {keys} to be typed
+ {mode} behavior flags, see |feedkeys()|
+ {escape_ks} If true, escape K_SPECIAL bytes in `keys`
+ This should be false if you already used
+ |nvim_replace_termcodes()|, and true
+ otherwise.
See also: ~
feedkeys()
- vim_strsave_escape_csi
+ vim_strsave_escape_ks
nvim_get_all_options_info() *nvim_get_all_options_info()*
Gets the option information for all options.
@@ -1538,14 +1540,13 @@ nvim_set_current_win({window}) *nvim_set_current_win()*
Parameters: ~
{window} Window handle
-nvim_set_hl({ns_id}, {name}, {val}) *nvim_set_hl()*
+nvim_set_hl({ns_id}, {name}, {*val}) *nvim_set_hl()*
Set a highlight group.
- TODO: ns_id = 0, should modify :highlight namespace TODO val
- should take update vs reset flag
-
Parameters: ~
- {ns_id} number of namespace for this highlight
+ {ns_id} number of namespace for this highlight. Use value
+ 0 to set a highlight group in the global (
+ `:highlight` ) namespace.
{name} highlight group name, like ErrorMsg
{val} highlight definition map, like
|nvim_get_hl_by_name|. in addition the following
@@ -1583,7 +1584,7 @@ nvim_set_keymap({mode}, {lhs}, {rhs}, {*opts}) *nvim_set_keymap()*
{rhs} Right-hand-side |{rhs}| of the mapping.
{opts} Optional parameters map. Accepts all
|:map-arguments| as keys excluding |<buffer>| but
- including |noremap| and "desc". |desc| can be used
+ including |noremap| and "desc". "desc" can be used
to give a description to keymap. When called from
Lua, also accepts a "callback" key that takes a
Lua function to call when the mapping is executed.
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt
index 6195dd4a0b..35a232c0c2 100644
--- a/runtime/doc/builtin.txt
+++ b/runtime/doc/builtin.txt
@@ -380,7 +380,7 @@ screencol() Number current cursor column
screenpos({winid}, {lnum}, {col}) Dict screen row and col of a text character
screenrow() Number current cursor row
screenstring({row}, {col}) String characters at screen position
-search({pattern} [, {flags} [, {stopline} [, {timeout}]]])
+search({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]])
Number search for {pattern}
searchcount([{options}]) Dict Get or update the last search count
searchdecl({name} [, {global} [, {thisblock}]])
@@ -389,7 +389,7 @@ searchpair({start}, {middle}, {end} [, {flags} [, {skip} [...]]])
Number search for other end of start/end pair
searchpairpos({start}, {middle}, {end} [, {flags} [, {skip} [...]]])
List search for other end of start/end pair
-searchpos({pattern} [, {flags} [, {stopline} [, {timeout}]]])
+searchpos({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]])
List search for {pattern}
server2client({clientid}, {string})
Number send reply string
@@ -6169,8 +6169,9 @@ screenstring({row}, {col}) *screenstring()*
Can also be used as a |method|: >
GetRow()->screenstring(col)
-
-search({pattern} [, {flags} [, {stopline} [, {timeout}]]]) *search()*
+<
+ *search()*
+search({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]])
Search for regexp pattern {pattern}. The search starts at the
cursor position (you can use |cursor()| to set it).
@@ -6222,6 +6223,15 @@ search({pattern} [, {flags} [, {stopline} [, {timeout}]]]) *search()*
The value must not be negative. A zero value is like not
giving the argument.
+ If the {skip} expression is given it is evaluated with the
+ cursor positioned on the start of a match. If it evaluates to
+ non-zero this match is skipped. This can be used, for
+ example, to skip a match in a comment or a string.
+ {skip} can be a string, which is evaluated as an expression, a
+ function reference or a lambda.
+ When {skip} is omitted or empty, every match is accepted.
+ When evaluating {skip} causes an error the search is aborted
+ and -1 returned.
*search()-sub-match*
With the 'p' flag the returned value is one more than the
first sub-match in \(\). One if none of them matched but the
@@ -6505,7 +6515,8 @@ searchpairpos({start}, {middle}, {end} [, {flags} [, {skip}
<
See |match-parens| for a bigger and more useful example.
-searchpos({pattern} [, {flags} [, {stopline} [, {timeout}]]]) *searchpos()*
+ *searchpos()*
+searchpos({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]])
Same as |search()|, but returns a |List| with the line and
column position of the match. The first element of the |List|
is the line number and the second element is the byte index of
@@ -7433,6 +7444,9 @@ stdioopen({opts}) *stdioopen()*
{opts} is a dictionary with these keys:
|on_stdin| : callback invoked when stdin is written to.
+ on_print : callback invoked when Nvim needs to print a
+ message, with the message (whose type is string)
+ as sole argument.
stdin_buffered : read stdin in |channel-buffered| mode.
rpc : If set, |msgpack-rpc| will be used to communicate
over stdio
diff --git a/runtime/doc/editing.txt b/runtime/doc/editing.txt
index 3d0287b0cd..8ddc661c0e 100644
--- a/runtime/doc/editing.txt
+++ b/runtime/doc/editing.txt
@@ -1450,6 +1450,11 @@ If you don't get warned often enough you can use the following command.
if it exists now.
Once a file has been checked the timestamp is reset,
you will not be warned again.
+ Syntax highlighting, marks, diff status,
+ 'fileencoding', 'fileformat' and 'binary' options
+ are not changed. See |v:fcs_choice| to reload these
+ too (for example, if a code formatting tools has
+ changed the file).
:[N]checkt[ime] {filename}
:[N]checkt[ime] [N]
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index fc788fba59..fc422f13e5 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -1882,6 +1882,11 @@ v:fcs_choice What should happen after a |FileChangedShell| event was
do with the affected buffer:
reload Reload the buffer (does not work if
the file was deleted).
+ edit Reload the buffer and detect the
+ values for options such as
+ 'fileformat', 'fileencoding', 'binary'
+ (does not work if the file was
+ deleted).
ask Ask the user what to do, as if there
was no autocommand. Except that when
only the timestamp changed nothing
diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt
index f6fcbe8fb9..d717759444 100644
--- a/runtime/doc/lsp.txt
+++ b/runtime/doc/lsp.txt
@@ -1225,8 +1225,8 @@ on_publish_diagnostics({_}, {result}, {ctx}, {config})
},
-- Use a function to dynamically turn signs off
-- and on, using buffer local variables
- signs = function(bufnr, client_id)
- return vim.bo[bufnr].show_signs == false
+ signs = function(namespace, bufnr)
+ return vim.b[bufnr].show_signs == true
end,
-- Disable a feature
update_in_insert = false,
diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt
index 77f1dad6c7..1a2d845281 100644
--- a/runtime/doc/lua.txt
+++ b/runtime/doc/lua.txt
@@ -1763,6 +1763,13 @@ Lua module: ui *lua-ui*
input({opts}, {on_confirm}) *vim.ui.input()*
Prompts the user for input
+ Example: >
+
+ vim.ui.input({ prompt = 'Enter value for shiftwidth: ' }, function(input)
+ vim.o.shiftwidth = tonumber(input)
+ end)
+<
+
Parameters: ~
{opts} table Additional options. See |input()|
• prompt (string|nil) Text of the prompt.
@@ -1786,6 +1793,22 @@ select({items}, {opts}, {on_choice}) *vim.ui.select()*
Prompts the user to pick a single item from a collection of
entries
+ Example: >
+
+ vim.ui.select({ 'tabs', 'spaces' }, {
+ prompt = 'Select tabs or spaces:',
+ format_item = function(item)
+ return "I'd like to choose " .. item
+ end,
+ }, function(choice)
+ if choice == 'spaces' then
+ vim.o.expandtab = true
+ else
+ vim.o.expandtab = false
+ end
+ end)
+<
+
Parameters: ~
{items} table Arbitrary items
{opts} table Additional options
diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt
index 2d2795b1ca..358e944261 100644
--- a/runtime/doc/map.txt
+++ b/runtime/doc/map.txt
@@ -502,7 +502,9 @@ Note: When using mappings for Visual mode, you can use the "'<" mark, which
is the start of the last selected Visual area in the current buffer |'<|.
The |:filter| command can be used to select what mappings to list. The
-pattern is matched against the {lhs} and {rhs} in the raw form.
+pattern is matched against the {lhs} and {rhs} in the raw form. If a
+description was added using |nvim_set_keymap()| or |nvim_buf_set_keymap()|
+then the pattern is also matched against it.
*:map-verbose*
When 'verbose' is non-zero, listing a key map will also display where it was
diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt
index 5829dbdd6b..dbd8ec6fef 100644
--- a/runtime/doc/treesitter.txt
+++ b/runtime/doc/treesitter.txt
@@ -14,10 +14,12 @@ VIM.TREESITTER *lua-treesitter*
Nvim integrates the tree-sitter library for incremental parsing of buffers.
*vim.treesitter.language_version*
-To check which language version is compiled with neovim, the number is stored
-within `vim.treesitter.language_version`. This number is not too helpful
-unless you are wondering about compatibility between different versions of
-compiled grammars.
+The latest parser ABI version that is supported by the bundled tree-sitter
+library.
+
+ *vim.treesitter.minimum_language_version*
+The earliest parser ABI version that is supported by the bundled tree-sitter
+library.
Parser files *treesitter-parsers*
@@ -49,10 +51,10 @@ Whenever you need to access the current syntax tree, parse the buffer: >
tstree = parser:parse()
-<This will return a table of immutable trees that represent the current state of the
-buffer. When the plugin wants to access the state after a (possible) edit
-it should call `parse()` again. If the buffer wasn't edited, the same tree will
-be returned again without extra work. If the buffer was parsed before,
+<This will return a table of immutable trees that represent the current state
+of the buffer. When the plugin wants to access the state after a (possible)
+edit it should call `parse()` again. If the buffer wasn't edited, the same tree
+will be returned again without extra work. If the buffer was parsed before,
incremental parsing will be done of the changed parts.
Note: to use the parser directly inside a |nvim_buf_attach| Lua callback, you
@@ -61,9 +63,10 @@ parsing shouldn't be done directly in the change callback anyway as they will
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()*
+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): >
+ language injection. {region_list} should be of the form
+ (all zero-based): >
{
{node1, node2},
...
@@ -92,13 +95,13 @@ tsnode:next_sibling() *tsnode:next_sibling()*
tsnode:prev_sibling() *tsnode:prev_sibling()*
Get the node's previous sibling.
-tsnode:next_named_sibling() *tsnode:next_named_sibling()*
+tsnode:next_named_sibling() *tsnode:next_named_sibling()*
Get the node's next named sibling.
-tsnode:prev_named_sibling() *tsnode:prev_named_sibling()*
+tsnode:prev_named_sibling() *tsnode:prev_named_sibling()*
Get the node's previous named sibling.
-tsnode:iter_children() *tsnode:iter_children()*
+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
@@ -114,10 +117,10 @@ tsnode:child({index}) *tsnode:child()*
Get the node's child at the given {index}, where zero represents the
first child.
-tsnode:named_child_count() *tsnode:named_child_count()*
+tsnode:named_child_count() *tsnode:named_child_count()*
Get the node's number of named children.
-tsnode:named_child({index}) *tsnode:named_child()*
+tsnode:named_child({index}) *tsnode:named_child()*
Get the node's named child at the given {index}, where zero represents
the first named child.
@@ -157,20 +160,20 @@ 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})
- *tsnode:descendant_for_range()*
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})
- *tsnode:named_descendant_for_range()*
Get the smallest named node within this node that spans the given
range of (row, column) positions
@@ -192,11 +195,11 @@ and predicates. A `capture` allows you to associate names with a specific
node in a pattern. A `predicate` adds arbitrary metadata and conditional data
to a match.
-Treesitter Query Predicates *lua-treesitter-predicates*
+Treesitter Query Predicates *lua-treesitter-predicates*
When writing queries for treesitter, one might use `predicates`, that is,
-special scheme nodes that are evaluated to verify things on a captured node for
-example, the |eq?| predicate : >
+special scheme nodes that are evaluated to verify things on a captured node
+for example, the |eq?| predicate : >
((identifier) @foo (#eq? @foo "foo"))
This will only match identifier corresponding to the `"foo"` text.
@@ -209,24 +212,24 @@ Here is a list of built-in predicates :
((node1) @left (node2) @right (#eq? @left @right))
<
`match?` *ts-predicate-match?*
- `vim-match?` *ts-predicate-vim-match?*
+ `vim-match?` *ts-predicate-vim-match?*
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.
- `lua-match?` *ts-predicate-lua-match?*
+ `lua-match?` *ts-predicate-lua-match?*
This will match the same way than |match?| but using lua
regexes.
- `contains?` *ts-predicate-contains?*
+ `contains?` *ts-predicate-contains?*
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?*
+ `any-of?` *ts-predicate-any-of?*
Will check if the text is the same as any of the following.
This is the recommended way to check if the node matches one
of many keywords for example, as it has been optimized for
@@ -234,27 +237,27 @@ Here is a list of built-in predicates :
arguments : >
((identifier) @foo (#any-of? @foo "foo" "bar"))
<
- *lua-treesitter-not-predicate*
+ *lua-treesitter-not-predicate*
Each predicate has a `not-` prefixed predicate that is just the negation of
the predicate.
- *vim.treesitter.query.add_predicate()*
+ *vim.treesitter.query.add_predicate()*
vim.treesitter.query.add_predicate({name}, {handler})
This adds a predicate with the name {name} to be used in queries.
{handler} should be a function whose signature will be : >
handler(match, pattern, bufnr, predicate)
<
- *vim.treesitter.query.list_predicates()*
+ *vim.treesitter.query.list_predicates()*
vim.treesitter.query.list_predicates()
This lists the currently available predicates to use in queries.
-Treesitter Query Directive *lua-treesitter-directives*
+Treesitter Query Directive *lua-treesitter-directives*
-Treesitter queries can also contain `directives`. Directives store metadata for a node
-or match and perform side effects. For example, the |set!| predicate sets metadata on
-the match or node : >
+Treesitter queries can also contain `directives`. Directives store metadata
+for a node or match and perform side effects. For example, the |set!|
+predicate sets metadata on the match or node : >
((identifier) @foo (#set! "type" "parameter"))
Here is a list of built-in directives:
@@ -268,8 +271,8 @@ Here is a list of built-in directives:
Takes the range of the captured node and applies the offsets
to it's range : >
((identifier) @constant (#offset! @constant 0 1 0 -1))
-< This will generate a range object for the captured node with the
- offsets applied. The arguments are
+< This will generate a range object for the captured node with
+ the offsets applied. The arguments are
`({capture_id}, {start_row}, {start_col}, {end_row}, {end_col}, {key?})`
The default key is "offset".
@@ -279,25 +282,25 @@ vim.treesitter.query.add_directive({name}, {handler})
This adds a directive with the name {name} to be used in queries.
{handler} should be a function whose signature will be : >
handler(match, pattern, bufnr, predicate, metadata)
-Handlers can set match level data by setting directly on the metadata object `metadata.key = value`
-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` Handlers can set node level data by using the capture
+id on the metadata table `metadata[capture_id].key = value`
*vim.treesitter.query.list_directives()*
vim.treesitter.query.list_directives()
This lists the currently available directives to use in queries.
-Treesitter syntax highlighting (WIP) *lua-treesitter-highlight*
+Treesitter syntax highlighting (WIP) *lua-treesitter-highlight*
NOTE: This is a partially implemented feature, and not usable as a default
solution yet. What is documented here is a temporary interface intended
for those who want to experiment with this feature and contribute to
its development.
-Highlights are defined in the same query format as in the tree-sitter highlight
-crate, with some limitations and additions. Set a highlight query for a
-buffer with this code: >
+Highlights are defined in the same query format as in the tree-sitter
+highlight crate, with some limitations and additions. Set a highlight query
+for a buffer with this code: >
local query = [[
"for" @keyword
@@ -338,7 +341,8 @@ Treesitter Highlighting Priority *lua-treesitter-highlight-priority*
Tree-sitter uses |nvim_buf_set_extmark()| to set highlights with a default
priority of 100. This enables plugins to set a highlighting priority lower or
higher than tree-sitter. It is also possible to change the priority of an
-individual query pattern manually by setting its `"priority"` metadata attribute: >
+individual query pattern manually by setting its `"priority"` metadata
+attribute: >
(
(super_important_node) @ImportantHighlight
@@ -461,7 +465,7 @@ parse_query({lang}, {query}) *parse_query()*
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 information about the {query}.
+ 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` .
• `info.patterns` contains information about predicates.
@@ -609,10 +613,9 @@ LanguageTree:children({self}) *LanguageTree:children()*
{self}
LanguageTree:contains({self}, {range}) *LanguageTree:contains()*
- Determines whether This goes down the tree to recursively check children.
+ Determines whether {range} is contained in this language tree
- Parameters: ~
- {range} is contained in this language tree
+ This goes down the tree to recursively check children.
Parameters: ~
{range} A range, that is a `{ start_line, start_col,
@@ -622,8 +625,9 @@ LanguageTree:contains({self}, {range}) *LanguageTree:contains()*
LanguageTree:destroy({self}) *LanguageTree:destroy()*
Destroys this language tree and all its children.
- Any cleanup logic should be performed here. Note, this DOES
- NOT remove this tree from a parent. `remove_child` must be called on the parent to remove it.
+ Any cleanup logic should be performed here.
+
+ Note: This DOES NOT remove this tree from a parent. Instead, `remove_child` must be called on the parent to remove it.
Parameters: ~
{self}
@@ -666,7 +670,8 @@ 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, `parse()` must be called to get the updated tree.
+ Determines whether this tree is valid. If the tree is invalid,
+ call `parse()` . This will return the updated tree.
Parameters: ~
{self}
@@ -679,7 +684,7 @@ LanguageTree:lang({self}) *LanguageTree:lang()*
*LanguageTree:language_for_range()*
LanguageTree:language_for_range({self}, {range})
- Gets the appropriate language that contains
+ Gets the appropriate language that contains {range}
Parameters: ~
{range} A text range, see |LanguageTree:contains|
@@ -695,13 +700,22 @@ LanguageTree:parse({self}) *LanguageTree:parse()*
{self}
LanguageTree:register_cbs({self}, {cbs}) *LanguageTree:register_cbs()*
- Registers callbacks for the parser
-
- Parameters: ~
- {cbs} 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, that 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.
+ 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)
+ 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.
{self}
LanguageTree:remove_child({self}, {lang}) *LanguageTree:remove_child()*
diff --git a/runtime/filetype.vim b/runtime/filetype.vim
index 8b40b43a04..35f4b25120 100644
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -1543,6 +1543,9 @@ au BufNewFile,BufRead *.r,*.R call dist#ft#FTr()
" Remind
au BufNewFile,BufRead .reminders,*.remind,*.rem setf remind
+" ReScript
+au BufNewFile,BufRead *.res,*.resi setf rescript
+
" Resolv.conf
au BufNewFile,BufRead resolv.conf setf resolv
diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua
index e2cf408f3b..2fe4aa3d32 100644
--- a/runtime/lua/vim/filetype.lua
+++ b/runtime/lua/vim/filetype.lua
@@ -514,6 +514,8 @@ local extension = {
rego = "rego",
rem = "remind",
remind = "remind",
+ res = "rescript",
+ resi = "rescript",
frt = "reva",
testUnit = "rexx",
rex = "rexx",
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua
index 37e222a5ce..8d11b4621c 100644
--- a/runtime/lua/vim/lsp.lua
+++ b/runtime/lua/vim/lsp.lua
@@ -1598,7 +1598,7 @@ end
local function adjust_start_col(lnum, line, items, encoding)
local min_start_char = nil
for _, item in pairs(items) do
- if item.textEdit and item.textEdit.range.start.line == lnum - 1 then
+ if item.filterText == nil and item.textEdit and item.textEdit.range.start.line == lnum - 1 then
if min_start_char and min_start_char ~= item.textEdit.range.start.character then
return nil
end
diff --git a/runtime/lua/vim/treesitter/highlighter.lua b/runtime/lua/vim/treesitter/highlighter.lua
index 22b528838c..b6f61cfb2e 100644
--- a/runtime/lua/vim/treesitter/highlighter.lua
+++ b/runtime/lua/vim/treesitter/highlighter.lua
@@ -22,7 +22,21 @@ local _link_default_highlight_once = function(from, to)
return from
end
-TSHighlighter.hl_map = {
+-- If @definition.special does not exist use @definition instead
+local subcapture_fallback = {
+ __index = function(self, capture)
+ local rtn
+ local shortened = capture
+ while not rtn and shortened do
+ shortened = shortened:match('(.*)%.')
+ rtn = shortened and rawget(self, shortened)
+ end
+ rawset(self, capture, rtn or "__notfound")
+ return rtn
+ end
+}
+
+TSHighlighter.hl_map = setmetatable({
["error"] = "Error",
-- Miscs
@@ -66,7 +80,7 @@ TSHighlighter.hl_map = {
["type.builtin"] = "Type",
["structure"] = "Structure",
["include"] = "Include",
-}
+}, subcapture_fallback)
---@private
local function is_highlight_name(capture_name)
diff --git a/runtime/lua/vim/treesitter/languagetree.lua b/runtime/lua/vim/treesitter/languagetree.lua
index 85fd5cd8e0..b83df65151 100644
--- a/runtime/lua/vim/treesitter/languagetree.lua
+++ b/runtime/lua/vim/treesitter/languagetree.lua
@@ -76,8 +76,8 @@ function LanguageTree:lang()
end
--- Determines whether this tree is valid.
---- If the tree is invalid, `parse()` must be called
---- to get the updated tree.
+--- If the tree is invalid, call `parse()`.
+--- This will return the updated tree.
function LanguageTree:is_valid()
return self._valid
end
@@ -234,7 +234,9 @@ end
--- Destroys this language tree and all its children.
---
--- Any cleanup logic should be performed here.
---- Note, this DOES NOT remove this tree from a parent.
+---
+--- Note:
+--- This DOES NOT remove this tree from a parent. Instead,
--- `remove_child` must be called on the parent to remove it.
function LanguageTree:destroy()
-- Cleanup here
@@ -448,14 +450,14 @@ function LanguageTree:_on_detach(...)
self:_do_callback('detach', ...)
end
---- Registers callbacks for the parser
----@param cbs 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, that 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.
+--- Registers callbacks for the parser.
+---@param 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.
function LanguageTree:register_cbs(cbs)
if not cbs then return end
@@ -493,7 +495,7 @@ local function tree_contains(tree, range)
return false
end
---- Determines whether @param range is contained in this language tree
+--- Determines whether {range} is contained in this language tree
---
--- This goes down the tree to recursively check children.
---
@@ -508,7 +510,7 @@ function LanguageTree:contains(range)
return false
end
---- Gets the appropriate language that contains @param range
+--- Gets the appropriate language that contains {range}
---
---@param range A text range, see |LanguageTree:contains|
function LanguageTree:language_for_range(range)
diff --git a/runtime/lua/vim/treesitter/query.lua b/runtime/lua/vim/treesitter/query.lua
index b3036ea679..8383551b5f 100644
--- a/runtime/lua/vim/treesitter/query.lua
+++ b/runtime/lua/vim/treesitter/query.lua
@@ -146,13 +146,13 @@ local query_cache = setmetatable({}, {
})
--- Parse {query} as a string. (If the query is in a file, the caller
---- should read the contents into a string before calling).
+--- 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.
---
---- Exposes `info` and `captures` with additional information about the {query}.
+--- 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`.
@@ -199,11 +199,13 @@ function M.get_node_text(node, source)
lines = a.nvim_buf_get_lines(source, start_row, end_row + 1, true)
end
- if #lines == 1 then
- lines[1] = string.sub(lines[1], start_col+1, end_col)
- else
- lines[1] = string.sub(lines[1], start_col+1)
- lines[#lines] = string.sub(lines[#lines], 1, end_col)
+ if #lines > 0 then
+ if #lines == 1 then
+ lines[1] = string.sub(lines[1], start_col+1, end_col)
+ else
+ lines[1] = string.sub(lines[1], start_col+1)
+ lines[#lines] = string.sub(lines[#lines], 1, end_col)
+ end
end
return table.concat(lines, "\n")