aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/api.txt11
-rw-r--r--runtime/doc/lua.txt4
-rw-r--r--runtime/doc/luvref.txt7
-rw-r--r--runtime/doc/news.txt9
-rw-r--r--runtime/doc/treesitter.txt37
-rw-r--r--runtime/lua/vim/shared.lua8
-rw-r--r--runtime/lua/vim/treesitter/health.lua2
-rw-r--r--runtime/lua/vim/treesitter/language.lua4
-rw-r--r--runtime/queries/c/highlights.scm115
-rw-r--r--runtime/queries/c/injections.scm4
-rw-r--r--runtime/queries/lua/highlights.scm43
-rw-r--r--runtime/queries/lua/injections.scm12
-rw-r--r--runtime/queries/vim/highlights.scm2
-rw-r--r--runtime/queries/vimdoc/highlights.scm (renamed from runtime/queries/help/highlights.scm)0
-rw-r--r--runtime/queries/vimdoc/injections.scm (renamed from runtime/queries/help/injections.scm)0
15 files changed, 166 insertions, 92 deletions
diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt
index 844bf772f1..3c3e66dd57 100644
--- a/runtime/doc/api.txt
+++ b/runtime/doc/api.txt
@@ -2546,6 +2546,8 @@ nvim_buf_get_extmark_by_id({buffer}, {ns_id}, {id}, {opts})
• {id} Extmark id
• {opts} Optional parameters. Keys:
• details: Whether to include the details dict
+ • hl_name: Whether to include highlight group name instead
+ of id, true if omitted
Return: ~
0-indexed (row, col) tuple or empty list () if extmark id was absent
@@ -2582,7 +2584,8 @@ nvim_buf_get_extmarks({buffer}, {ns_id}, {start}, {end}, {opts})
Parameters: ~
• {buffer} Buffer handle, or 0 for current buffer
- • {ns_id} Namespace id from |nvim_create_namespace()|
+ • {ns_id} Namespace id from |nvim_create_namespace()| or -1 for all
+ namespaces
• {start} Start of range: a 0-indexed (row, col) or valid extmark id
(whose position defines the bound). |api-indexing|
• {end} End of range (inclusive): a 0-indexed (row, col) or valid
@@ -2590,7 +2593,11 @@ nvim_buf_get_extmarks({buffer}, {ns_id}, {start}, {end}, {opts})
|api-indexing|
• {opts} Optional parameters. Keys:
• limit: Maximum number of marks to return
- • details Whether to include the details dict
+ • details: Whether to include the details dict
+ • hl_name: Whether to include highlight group name instead
+ of id, true if omitted
+ • type: Filter marks by type: "highlight", "sign",
+ "virt_text" and "virt_lines"
Return: ~
List of [extmark_id, row, col] tuples in "traversal order".
diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt
index 14f2ba2b04..ebbf8bb463 100644
--- a/runtime/doc/lua.txt
+++ b/runtime/doc/lua.txt
@@ -1635,8 +1635,8 @@ defaulttable({create}) *vim.defaulttable()*
<
Parameters: ~
- • {create} (function|nil) The function called to create a missing
- value.
+ • {create} function?(key:any):any The function called to create a
+ missing value.
Return: ~
(table) Empty table with metamethod
diff --git a/runtime/doc/luvref.txt b/runtime/doc/luvref.txt
index 0fdd010880..799d0f6f74 100644
--- a/runtime/doc/luvref.txt
+++ b/runtime/doc/luvref.txt
@@ -91,7 +91,7 @@ used here to facilitate documenting consistent behavior:
metamethod
- `buffer`: a `string` or a sequential `table` of `string`s
- `threadargs`: variable arguments (`...`) of type `nil`, `boolean`, `number`,
- `string`, or `userdata`
+ `string`, or `userdata`; number of arguments limited to 9.
==============================================================================
CONTENTS *luv-contents*
@@ -2576,7 +2576,7 @@ uv.fs_poll_start({fs_poll}, {path}, {interval}, {callback}) *uv.fs_poll_start()*
> method form `fs_poll:start(path, interval, callback)`
Parameters:
- - `fs_event`: `uv_fs_event_t userdata`
+ - `fs_poll`: `uv_fs_poll_t userdata`
- `path`: `string`
- `interval`: `integer`
- `callback`: `callable`
@@ -3484,6 +3484,9 @@ uv.new_thread([{options}, ] {entry}, {...}) *uv.new_thread()*
Returns: `luv_thread_t userdata` or `fail`
+ Note: unsafe, please make sure that the thread's end of life
+ is before Lua state is closed.
+
uv.thread_equal({thread}, {other_thread}) *uv.thread_equal()*
> method form `thread:equal(other_thread)`
diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt
index 401719b432..7b71b53b29 100644
--- a/runtime/doc/news.txt
+++ b/runtime/doc/news.txt
@@ -62,11 +62,20 @@ The following changes may require adaptations in user config or plugins.
• |nvim_exec()| is now deprecated in favor of |nvim_exec2()|.
+• `help` treesitter parser was renamed to `vimdoc`. The only user-visible
+ change is that language-specific highlight groups need to be renamed from
+ `@foo.help` to `@foo.vimdoc`.
+
==============================================================================
NEW FEATURES *news-features*
The following new APIs or features were added.
+• |nvim_buf_get_extmarks()| now accepts a -1 `ns_id` to request extmarks from
+ all namespaces and adds the namespace id to the details array.
+ Other missing properties have been added to the details array and marks can
+ be filtered by type.
+
• Added a new experimental |lua-loader| that byte-compiles and caches lua files.
To enable the new loader, add the following at the top of your |init.lua|: >lua
vim.loader.enable()
diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt
index 96021d6272..0298f5a9b1 100644
--- a/runtime/doc/treesitter.txt
+++ b/runtime/doc/treesitter.txt
@@ -195,7 +195,7 @@ treesitter queries from Lua.
TREESITTER QUERY PREDICATES *treesitter-predicates*
Predicates are special scheme nodes that are evaluated to conditionally capture
-nodes. For example, the `eq?` predicate can be used as follows: >
+nodes. For example, the `eq?` predicate can be used as follows: >query
((identifier) @foo (#eq? @foo "foo"))
<
@@ -204,13 +204,13 @@ to only match identifier corresponding to the `"foo"` text.
The following predicates are built in:
`eq?` *treesitter-predicate-eq?*
- Match a string against the text corresponding to a node: >
+ Match a string against the text corresponding to a node: >query
((identifier) @foo (#eq? @foo "foo"))
((node1) @left (node2) @right (#eq? @left @right))
<
`match?` *treesitter-predicate-match?*
`vim-match?` *treesitter-predicate-vim-match?*
- Match a |regexp| against the text corresponding to a node: >
+ Match a |regexp| against the text corresponding to a node: >query
((identifier) @constant (#match? @constant "^[A-Z_]+$"))
< Note: The `^` and `$` anchors will match the start and end of the
node's text.
@@ -220,13 +220,14 @@ The following predicates are built in:
similar to `match?`
`contains?` *treesitter-predicate-contains?*
- Match a string against parts of the text corresponding to a node: >
+ Match a string against parts of the text corresponding to a node:
+ >query
((identifier) @foo (#contains? @foo "foo"))
((identifier) @foo-bar (#contains? @foo-bar "foo" "bar"))
<
`any-of?` *treesitter-predicate-any-of?*
Match any of the given strings against the text corresponding to
- a node: >
+ a node: >query
((identifier) @foo (#any-of? @foo "foo" "bar"))
<
This is the recommended way to check if the node matches one of many
@@ -243,7 +244,7 @@ Use |vim.treesitter.query.list_predicates()| to list all available predicates.
TREESITTER QUERY DIRECTIVES *treesitter-directives*
Treesitter directives store metadata for a node or match and perform side
-effects. For example, the `set!` directive sets metadata on the match or node: >
+effects. For example, the `set!` directive sets metadata on the match or node: >query
((identifier) @foo (#set! "type" "parameter"))
<
@@ -259,7 +260,7 @@ The following directives are built in:
{key}
{value}
- Examples: >
+ Examples: >query
((identifier) @foo (#set! @foo "kind" "parameter"))
((node1) @left (node2) @right (#set! "type" "pair"))
<
@@ -275,7 +276,7 @@ The following directives are built in:
{end_row}
{end_col}
- Example: >
+ Example: >query
((identifier) @constant (#offset! @constant 0 1 0 -1))
<
@@ -304,7 +305,8 @@ currently supported modeline alternatives:
a base depends on your 'runtimepath' value.
Note: These modeline comments must be at the top of the query, but can be
-repeated, for example, the following two modeline blocks are both valid: >
+repeated, for example, the following two modeline blocks are both valid:
+>query
;; inherits: foo,bar
;; extends
@@ -318,13 +320,13 @@ TREESITTER SYNTAX HIGHLIGHTING *treesitter-highlight*
Syntax highlighting is specified through queries named `highlights.scm`,
which match a |TSNode| in the parsed |TSTree| to a `capture` that can be
-assigned a highlight group. For example, the query >
+assigned a highlight group. For example, the query >query
(parameters (identifier) @parameter)
<
matches any `identifier` node inside a function `parameter` node (e.g., the
`bar` in `foo(bar)`) to the capture named `@parameter`. It is also possible to
-match literal expressions (provided the parser returns them): >
+match literal expressions (provided the parser returns them): >query
"return" @keyword.return
<
@@ -409,7 +411,7 @@ The following captures are linked by default to standard |group-name|s:
*treesitter-highlight-spell*
The special `@spell` capture can be used to indicate that a node should be
spell checked by Nvim's builtin |spell| checker. For example, the following
-capture marks comments as to be checked: >
+capture marks comments as to be checked: >query
(comment) @spell
<
@@ -420,14 +422,14 @@ There is also `@nospell` which disables spellchecking regions with `@spell`.
Treesitter highlighting supports |conceal| via the `conceal` metadata. By
convention, nodes to be concealed are captured as `@conceal`, but any capture
can be used. For example, the following query can be used to hide code block
-delimiters in Markdown: >
+delimiters in Markdown: >query
- (fenced_code_block_delimiter) @conceal (#set! conceal "")
+ (fenced_code_block_delimiter @conceal (#set! conceal ""))
<
It is also possible to replace a node with a single character, which (unlike
legacy syntax) can be given a custom highlight. For example, the following
(ill-advised) query replaces the `!=` operator by a Unicode glyph, which is
-still highlighted the same as other operators: >
+still highlighted the same as other operators: >query
"!=" @operator (#set! conceal "≠")
<
@@ -438,9 +440,10 @@ Treesitter 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: >
+attribute: >query
- (super_important_node) @ImportantHighlight (#set! "priority" 105)
+ ((super_important_node) @superimportant (#set! "priority" 105))
+<
==============================================================================
TREESITTER LANGUAGE INJECTIONS *treesitter-language-injections*
diff --git a/runtime/lua/vim/shared.lua b/runtime/lua/vim/shared.lua
index 884929e33a..9e337e93e8 100644
--- a/runtime/lua/vim/shared.lua
+++ b/runtime/lua/vim/shared.lua
@@ -796,13 +796,15 @@ end
--- a.b.c = 1
--- </pre>
---
----@param create function|nil The function called to create a missing value.
+---@param create function?(key:any):any The function called to create a missing value.
---@return table Empty table with metamethod
function vim.defaulttable(create)
- create = create or vim.defaulttable
+ create = create or function(_)
+ return vim.defaulttable()
+ end
return setmetatable({}, {
__index = function(tbl, key)
- rawset(tbl, key, create())
+ rawset(tbl, key, create(key))
return rawget(tbl, key)
end,
})
diff --git a/runtime/lua/vim/treesitter/health.lua b/runtime/lua/vim/treesitter/health.lua
index fd1188fde4..dabf2cdf6c 100644
--- a/runtime/lua/vim/treesitter/health.lua
+++ b/runtime/lua/vim/treesitter/health.lua
@@ -22,7 +22,7 @@ function M.check()
)
)
else
- local lang = ts.language.inspect_language(parsername)
+ local lang = ts.language.inspect(parsername)
health.report_ok(
string.format('Parser: %-10s ABI: %d, path: %s', parsername, lang._abi_version, parser)
)
diff --git a/runtime/lua/vim/treesitter/language.lua b/runtime/lua/vim/treesitter/language.lua
index b1c788e6ba..5b74bb6200 100644
--- a/runtime/lua/vim/treesitter/language.lua
+++ b/runtime/lua/vim/treesitter/language.lua
@@ -4,7 +4,9 @@ local a = vim.api
local M = {}
---@type table<string,string>
-local ft_to_lang = {}
+local ft_to_lang = {
+ help = 'vimdoc',
+}
--- Get the filetypes associated with the parser named {lang}.
--- @param lang string Name of parser
diff --git a/runtime/queries/c/highlights.scm b/runtime/queries/c/highlights.scm
index 33e6df74ab..dee70f9cc7 100644
--- a/runtime/queries/c/highlights.scm
+++ b/runtime/queries/c/highlights.scm
@@ -1,22 +1,19 @@
-(identifier) @variable
+; Lower priority to prefer @parameter when identifier appears in parameter_declaration.
+((identifier) @variable (#set! "priority" 95))
[
- "const"
"default"
"enum"
- "extern"
- "inline"
- "return"
- "sizeof"
- "static"
"struct"
"typedef"
"union"
- "volatile"
"goto"
- "register"
] @keyword
+"sizeof" @keyword.operator
+
+"return" @keyword.return
+
[
"while"
"for"
@@ -32,7 +29,6 @@
"switch"
] @conditional
-"#define" @constant.macro
[
"#if"
"#ifdef"
@@ -41,10 +37,18 @@
"#elif"
"#endif"
(preproc_directive)
-] @keyword
+] @preproc
+
+"#define" @define
"#include" @include
+[ ";" ":" "," ] @punctuation.delimiter
+
+"..." @punctuation.special
+
+[ "(" ")" "[" "]" "{" "}"] @punctuation.bracket
+
[
"="
@@ -62,6 +66,7 @@
">>"
"->"
+ "."
"<"
"<="
@@ -88,35 +93,25 @@
"++"
] @operator
+;; Make sure the comma operator is given a highlight group after the comma
+;; punctuator so the operator is highlighted properly.
+(comma_expression [ "," ] @operator)
+
[
(true)
(false)
] @boolean
-[ "." ";" ":" "," ] @punctuation.delimiter
-
-(conditional_expression [ "?" ":" ] @conditional)
-
-
-[ "(" ")" "[" "]" "{" "}"] @punctuation.bracket
+(conditional_expression [ "?" ":" ] @conditional.ternary)
(string_literal) @string
-(string_literal) @spell
(system_lib_string) @string
+(escape_sequence) @string.escape
(null) @constant.builtin
(number_literal) @number
-(char_literal) @number
+(char_literal) @character
-(call_expression
- function: (identifier) @function)
-(call_expression
- function: (field_expression
- field: (field_identifier) @function))
-(function_declarator
- declarator: (identifier) @function)
-(preproc_function_def
- name: (identifier) @function.macro)
[
(preproc_arg)
(preproc_defined)
@@ -126,18 +121,32 @@
(statement_identifier) @label
[
-(type_identifier)
-(primitive_type)
-(sized_type_specifier)
-(type_descriptor)
- ] @type
+ (type_identifier)
+ (sized_type_specifier)
+ (type_descriptor)
+] @type
+
+(storage_class_specifier) @storageclass
+
+(type_qualifier) @type.qualifier
+
+(linkage_specification
+ "extern" @storageclass)
-(declaration (type_qualifier) @type)
-(cast_expression type: (type_descriptor) @type)
-(sizeof_expression value: (parenthesized_expression (identifier) @type))
+(type_definition
+ declarator: (type_identifier) @type.definition)
+
+(primitive_type) @type.builtin
((identifier) @constant
- (#match? @constant "^[A-Z][A-Z0-9_]+$"))
+ (#lua-match? @constant "^[A-Z][A-Z0-9_]+$"))
+(enumerator
+ name: (identifier) @constant)
+(case_statement
+ value: (identifier) @constant)
+
+((identifier) @constant.builtin
+ (#any-of? @constant.builtin "stderr" "stdin" "stdout"))
;; Preproc def / undef
(preproc_def
@@ -147,9 +156,20 @@
argument: (_) @constant
(#eq? @_u "#undef"))
+(call_expression
+ function: (identifier) @function.call)
+(call_expression
+ function: (field_expression
+ field: (field_identifier) @function.call))
+(function_declarator
+ declarator: (identifier) @function)
+(preproc_function_def
+ name: (identifier) @function.macro)
+
+(comment) @comment @spell
-(comment) @comment
-(comment) @spell
+((comment) @comment.documentation
+ (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
;; Parameters
(parameter_declaration
@@ -158,7 +178,20 @@
(parameter_declaration
declarator: (pointer_declarator) @parameter)
-(preproc_params
- (identifier)) @parameter
+(preproc_params (identifier) @parameter)
+
+[
+ "__attribute__"
+ "__cdecl"
+ "__clrcall"
+ "__stdcall"
+ "__fastcall"
+ "__thiscall"
+ "__vectorcall"
+ "_unaligned"
+ "__unaligned"
+ "__declspec"
+ (attribute_declaration)
+] @attribute
(ERROR) @error
diff --git a/runtime/queries/c/injections.scm b/runtime/queries/c/injections.scm
index 84ae33683e..3b99c7a444 100644
--- a/runtime/queries/c/injections.scm
+++ b/runtime/queries/c/injections.scm
@@ -1,5 +1,5 @@
-((preproc_arg) @injection.content
- (#set! injection.language "c"))
+; ((preproc_arg) @injection.content
+; (#set! injection.language "c"))
; ((comment) @injection.content
; (#set! injection.language "comment"))
diff --git a/runtime/queries/lua/highlights.scm b/runtime/queries/lua/highlights.scm
index 2c0dc5447a..5fbf8a1833 100644
--- a/runtime/queries/lua/highlights.scm
+++ b/runtime/queries/lua/highlights.scm
@@ -8,8 +8,6 @@
"local"
] @keyword
-(label_statement) @label
-
(break_statement) @keyword
(do_statement
@@ -109,6 +107,7 @@
[
";"
":"
+ "::"
","
"."
] @punctuation.delimiter
@@ -129,12 +128,21 @@
(identifier) @variable
((identifier) @variable.builtin
- (#eq? @variable.builtin "self"))
+ (#any-of? @variable.builtin "_G" "_VERSION" "debug" "io" "jit" "math" "os" "package" "self" "string" "table" "utf8"))
+
+((identifier) @keyword.coroutine
+ (#eq? @keyword.coroutine "coroutine"))
(variable_list
- attribute: (attribute
- (["<" ">"] @punctuation.bracket
- (identifier) @attribute)))
+ attribute: (attribute
+ (["<" ">"] @punctuation.bracket
+ (identifier) @attribute)))
+
+;; Labels
+
+(label_statement (identifier) @label)
+
+(goto_statement (identifier) @label)
;; Constants
@@ -172,7 +180,7 @@
(function_call name: (dot_index_expression field: (identifier) @function.call))
(function_declaration name: (dot_index_expression field: (identifier) @function))
-(method_index_expression method: (identifier) @method)
+(method_index_expression method: (identifier) @method.call)
(function_call
(identifier) @function.builtin
@@ -180,20 +188,27 @@
;; built-in functions in Lua 5.1
"assert" "collectgarbage" "dofile" "error" "getfenv" "getmetatable" "ipairs"
"load" "loadfile" "loadstring" "module" "next" "pairs" "pcall" "print"
- "rawequal" "rawget" "rawset" "require" "select" "setfenv" "setmetatable"
- "tonumber" "tostring" "type" "unpack" "xpcall"))
+ "rawequal" "rawget" "rawlen" "rawset" "require" "select" "setfenv" "setmetatable"
+ "tonumber" "tostring" "type" "unpack" "xpcall"
+ "__add" "__band" "__bnot" "__bor" "__bxor" "__call" "__concat" "__div" "__eq" "__gc"
+ "__idiv" "__index" "__le" "__len" "__lt" "__metatable" "__mod" "__mul" "__name" "__newindex"
+ "__pairs" "__pow" "__shl" "__shr" "__sub" "__tostring" "__unm"))
;; Others
-(comment) @comment
-(comment) @spell
+(comment) @comment @spell
+
+((comment) @comment.documentation
+ (#lua-match? @comment.documentation "^[-][-][-]"))
+
+((comment) @comment.documentation
+ (#lua-match? @comment.documentation "^[-][-](%s?)@"))
-(hash_bang_line) @comment
+(hash_bang_line) @preproc
(number) @number
-(string) @string
-(string) @spell
+(string) @string @spell
;; Error
(ERROR) @error
diff --git a/runtime/queries/lua/injections.scm b/runtime/queries/lua/injections.scm
index 10eb4c4054..1c7bdaf951 100644
--- a/runtime/queries/lua/injections.scm
+++ b/runtime/queries/lua/injections.scm
@@ -11,18 +11,18 @@
name: (_) @_vimcmd_identifier
arguments: (arguments (string content: _ @injection.content)))
(#set! injection.language "vim")
- (#any-of? @_vimcmd_identifier "vim.cmd" "vim.api.nvim_command" "vim.api.nvim_exec" "vim.api.nvim_cmd"))
+ (#any-of? @_vimcmd_identifier "vim.cmd" "vim.api.nvim_command" "vim.api.nvim_exec2" "vim.api.nvim_cmd"))
((function_call
name: (_) @_vimcmd_identifier
arguments: (arguments (string content: _ @injection.content) .))
(#set! injection.language "query")
- (#eq? @_vimcmd_identifier "vim.treesitter.query.set_query"))
+ (#any-of? @_vimcmd_identifier "vim.treesitter.query.set" "vim.treesitter.query.parse"))
-; ;; highlight string as query if starts with `;; query`
-; ((string ("string_content") @injection.content)
-; (#set! injection.language "query")
-; (#lua-match? @injection.content "^%s*;+%s?query"))
+;; highlight string as query if starts with `;; query`
+((string ("string_content") @injection.content)
+ (#set! injection.language "query")
+ (#lua-match? @injection.content "^%s*;+%s?query"))
; ((comment) @injection.content
; (#set! injection.language "comment"))
diff --git a/runtime/queries/vim/highlights.scm b/runtime/queries/vim/highlights.scm
index 239b0a0b37..ce25b13b9f 100644
--- a/runtime/queries/vim/highlights.scm
+++ b/runtime/queries/vim/highlights.scm
@@ -271,7 +271,7 @@
":"
] @punctuation.delimiter
-(ternary_expression ["?" ":"] @conditional)
+(ternary_expression ["?" ":"] @conditional.ternary)
; Options
((set_value) @number
diff --git a/runtime/queries/help/highlights.scm b/runtime/queries/vimdoc/highlights.scm
index c0d88301bc..c0d88301bc 100644
--- a/runtime/queries/help/highlights.scm
+++ b/runtime/queries/vimdoc/highlights.scm
diff --git a/runtime/queries/help/injections.scm b/runtime/queries/vimdoc/injections.scm
index 260a05d863..260a05d863 100644
--- a/runtime/queries/help/injections.scm
+++ b/runtime/queries/vimdoc/injections.scm