aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/CMakeLists.txt12
-rw-r--r--runtime/doc/api.txt12
-rw-r--r--runtime/doc/lua.txt46
-rw-r--r--runtime/doc/news.txt9
-rw-r--r--runtime/doc/treesitter.txt161
-rw-r--r--runtime/doc/ui.txt4
-rw-r--r--runtime/lua/vim/_editor.lua41
-rw-r--r--runtime/lua/vim/_meta/api.lua11
-rw-r--r--runtime/lua/vim/filetype.lua1
-rw-r--r--runtime/lua/vim/glob.lua40
-rw-r--r--runtime/lua/vim/lsp/_meta.lua7
-rw-r--r--runtime/lua/vim/lsp/_meta/protocol.lua13
-rw-r--r--runtime/lua/vim/version.lua42
-rw-r--r--runtime/queries/bash/folds.scm1
-rw-r--r--runtime/queries/bash/highlights.scm242
-rw-r--r--runtime/queries/c/folds.scm32
-rw-r--r--runtime/queries/c/highlights.scm182
-rw-r--r--runtime/queries/c/injections.scm23
-rw-r--r--runtime/queries/lua/folds.scm18
-rw-r--r--runtime/queries/lua/highlights.scm254
-rw-r--r--runtime/queries/lua/injections.scm119
-rw-r--r--runtime/queries/markdown/folds.scm16
-rw-r--r--runtime/queries/markdown/highlights.scm130
-rw-r--r--runtime/queries/markdown/injections.scm28
-rw-r--r--runtime/queries/markdown_inline/highlights.scm100
-rw-r--r--runtime/queries/markdown_inline/injections.scm9
-rw-r--r--runtime/queries/python/folds.scm5
-rw-r--r--runtime/queries/python/highlights.scm346
-rw-r--r--runtime/queries/query/highlights.scm79
-rw-r--r--runtime/queries/vim/folds.scm4
-rw-r--r--runtime/queries/vim/highlights.scm254
-rw-r--r--runtime/queries/vim/injections.scm64
-rw-r--r--runtime/queries/vimdoc/highlights.scm67
-rw-r--r--runtime/queries/vimdoc/injections.scm2
34 files changed, 1511 insertions, 863 deletions
diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt
index a44713d4ce..c9655ad9b9 100644
--- a/runtime/CMakeLists.txt
+++ b/runtime/CMakeLists.txt
@@ -1,5 +1,9 @@
-set(SYN_VIM_GENERATOR ${PROJECT_SOURCE_DIR}/src/nvim/generators/gen_vimvim.lua)
+set(GENERATED_RUNTIME_DIR ${PROJECT_BINARY_DIR}/runtime)
+
+set(GENERATED_HELP_TAGS ${GENERATED_RUNTIME_DIR}/doc/tags)
set(GENERATED_PACKAGE_DIR ${GENERATED_RUNTIME_DIR}/pack/dist/opt)
+set(GENERATED_SYN_VIM ${GENERATED_RUNTIME_DIR}/syntax/vim/generated.vim)
+set(SYN_VIM_GENERATOR ${PROJECT_SOURCE_DIR}/src/nvim/generators/gen_vimvim.lua)
file(MAKE_DIRECTORY ${GENERATED_RUNTIME_DIR}/syntax/vim)
@@ -32,7 +36,7 @@ foreach(PACKAGE ${PACKAGES})
COMMAND "${PROJECT_BINARY_DIR}/bin/nvim"
-u NONE -i NONE -e --headless -c "helptags doc" -c quit
DEPENDS
- nvim
+ nvim_bin
nvim_runtime_deps
WORKING_DIRECTORY "${GENERATED_PACKAGE_DIR}/${PACKNAME}"
)
@@ -66,7 +70,7 @@ add_custom_command(OUTPUT ${GENERATED_HELP_TAGS}
COMMAND "${PROJECT_BINARY_DIR}/bin/nvim"
-u NONE -i NONE -e --headless -c "helptags ++t doc" -c quit
DEPENDS
- nvim
+ nvim_bin
nvim_runtime_deps
WORKING_DIRECTORY "${GENERATED_RUNTIME_DIR}"
)
@@ -81,7 +85,7 @@ add_custom_target(doc_html
)
add_custom_target(
- runtime ALL
+ nvim_runtime
DEPENDS
${GENERATED_SYN_VIM}
${GENERATED_HELP_TAGS}
diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt
index b5a49f6002..f37d349fd8 100644
--- a/runtime/doc/api.txt
+++ b/runtime/doc/api.txt
@@ -2594,8 +2594,8 @@ nvim_buf_get_extmark_by_id({buffer}, {ns_id}, {id}, {*opts})
*nvim_buf_get_extmarks()*
nvim_buf_get_extmarks({buffer}, {ns_id}, {start}, {end}, {*opts})
- Gets |extmarks| (including |signs|) in "traversal order" from a |charwise|
- region defined by buffer positions (inclusive, 0-indexed |api-indexing|).
+ Gets |extmarks| in "traversal order" from a |charwise| region defined by
+ buffer positions (inclusive, 0-indexed |api-indexing|).
Region can be given as (row,col) tuples, or valid extmark ids (whose
positions define the bounds). 0 and -1 are understood as (0,0) and (-1,-1)
@@ -2611,6 +2611,10 @@ nvim_buf_get_extmarks({buffer}, {ns_id}, {start}, {end}, {*opts})
the `overlap` option might be useful. Otherwise only the start position of
an extmark will be considered.
+ Note: legacy signs placed through the |:sign| commands are implemented as
+ extmarks and will show up here. Their details array will contain a
+ `sign_name` field.
+
Example: >lua
local api = vim.api
local pos = api.nvim_win_get_cursor(0)
@@ -2742,7 +2746,9 @@ nvim_buf_set_extmark({buffer}, {ns_id}, {line}, {col}, {*opts})
text around the mark was deleted and then restored by
undo. Defaults to true.
• invalidate : boolean that indicates whether to hide the
- extmark if the entirety of its range is deleted. If
+ extmark if the entirety of its range is deleted. For
+ hidden marks, an "invalid" key is added to the "details"
+ array of |nvim_buf_get_extmarks()| and family. If
"undo_restore" is false, the extmark is deleted instead.
• priority: a priority value for the highlight group or sign
attribute. For example treesitter highlighting uses a
diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt
index 24474255ba..433a9fc266 100644
--- a/runtime/doc/lua.txt
+++ b/runtime/doc/lua.txt
@@ -3576,8 +3576,8 @@ vim.version.cmp({v1}, {v2}) *vim.version.cmp()*
otherwise-equivalent versions.
Parameters: ~
- • {v1} (`Version|number[]`) Version object.
- • {v2} (`Version|number[]`) Version to compare with `v1` .
+ • {v1} (`Version|number[]|string`) Version object.
+ • {v2} (`Version|number[]|string`) Version to compare with `v1` .
Return: ~
(`integer`) -1 if `v1 < v2`, 0 if `v1 == v2`, 1 if `v1 > v2`.
@@ -3587,8 +3587,18 @@ vim.version.eq({v1}, {v2}) *vim.version.eq()*
usage.
Parameters: ~
- • {v1} (`Version|number[]`)
- • {v2} (`Version|number[]`)
+ • {v1} (`Version|number[]|string`)
+ • {v2} (`Version|number[]|string`)
+
+ Return: ~
+ (`boolean`)
+
+vim.version.ge({v1}, {v2}) *vim.version.ge()*
+ Returns `true` if `v1 >= v2` . See |vim.version.cmp()| for usage.
+
+ Parameters: ~
+ • {v1} (`Version|number[]|string`)
+ • {v2} (`Version|number[]|string`)
Return: ~
(`boolean`)
@@ -3597,8 +3607,8 @@ vim.version.gt({v1}, {v2}) *vim.version.gt()*
Returns `true` if `v1 > v2` . See |vim.version.cmp()| for usage.
Parameters: ~
- • {v1} (`Version|number[]`)
- • {v2} (`Version|number[]`)
+ • {v1} (`Version|number[]|string`)
+ • {v2} (`Version|number[]|string`)
Return: ~
(`boolean`)
@@ -3612,12 +3622,22 @@ vim.version.last({versions}) *vim.version.last()*
Return: ~
(`Version?`)
+vim.version.le({v1}, {v2}) *vim.version.le()*
+ Returns `true` if `v1 <= v2` . See |vim.version.cmp()| for usage.
+
+ Parameters: ~
+ • {v1} (`Version|number[]|string`)
+ • {v2} (`Version|number[]|string`)
+
+ Return: ~
+ (`boolean`)
+
vim.version.lt({v1}, {v2}) *vim.version.lt()*
Returns `true` if `v1 < v2` . See |vim.version.cmp()| for usage.
Parameters: ~
- • {v1} (`Version|number[]`)
- • {v2} (`Version|number[]`)
+ • {v1} (`Version|number[]|string`)
+ • {v2} (`Version|number[]|string`)
Return: ~
(`boolean`)
@@ -3638,7 +3658,8 @@ vim.version.parse({version}, {opts}) *vim.version.parse()*
"1.0", "0-x", "tmux 3.2a" into valid versions.
Return: ~
- (`table?`) parsed_version Version object or `nil` if input is invalid.
+ (`Version?`) parsed_version Version object or `nil` if input is
+ invalid.
See also: ~
• # https://semver.org/spec/v2.0.0.html
@@ -3662,9 +3683,10 @@ vim.version.range({spec}) *vim.version.range()*
print(r:has(vim.version())) -- check against current Nvim version
<
- Or use cmp(), eq(), lt(), and gt() to compare `.to` and `.from` directly: >lua
- local r = vim.version.range('1.0.0 - 2.0.0')
- print(vim.version.gt({1,0,3}, r.from) and vim.version.lt({1,0,3}, r.to))
+ Or use cmp(), le(), lt(), ge(), gt(), and/or eq() to compare a version
+ against `.to` and `.from` directly: >lua
+ local r = vim.version.range('1.0.0 - 2.0.0') -- >=1.0, <2.0
+ print(vim.version.ge({1,0,3}, r.from) and vim.version.lt({1,0,3}, r.to))
<
Parameters: ~
diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt
index bc7619ad82..9ef9132c65 100644
--- a/runtime/doc/news.txt
+++ b/runtime/doc/news.txt
@@ -112,6 +112,11 @@ The following changes may require adaptations in user config or plugins.
• 'termguicolors' is enabled by default when Nvim is able to determine that
the host terminal emulator supports 24-bit color.
+• Treesitter highlight groups have been renamed to be more in line with
+ upstream tree-sitter and Helix to make it easier to share queries. The full
+ list is documented in |treesitter-highlight-groups|.
+
+
==============================================================================
BREAKING CHANGES IN HEAD *news-breaking-dev*
@@ -161,7 +166,7 @@ The following new APIs and features were added.
• |nvim_win_text_height()| computes the number of screen lines occupied
by a range of text in a given window.
-• |nvim_set_keymap()| and |nvim_del_keymap()| now support abbreviations.
+• Mapping APIs now support abbreviations when mode short-name has suffix "a".
• Better cmdline completion for string option value. |complete-set-option|
@@ -291,6 +296,8 @@ The following new APIs and features were added.
• Terminal buffers respond to OSC background and foreground requests. |default-autocmds|
+• |vim.version.le()| and |vim.version.ge()| are added to |vim.version|.
+
==============================================================================
CHANGED FEATURES *news-changed*
diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt
index 14dedbcbd9..d082aa8cc4 100644
--- a/runtime/doc/treesitter.txt
+++ b/runtime/doc/treesitter.txt
@@ -400,58 +400,115 @@ instance, to highlight comments differently per language: >vim
hi @comment.lua guifg=DarkBlue
hi link @comment.doc.java String
<
-The following captures are linked by default to standard |group-name|s:
-
-@text.literal Comment
-@text.reference Identifier
-@text.title Title
-@text.uri Underlined
-@text.underline Underlined
-@text.todo Todo
-
-@comment Comment
-@punctuation Delimiter
-
-@constant Constant
-@constant.builtin Special
-@constant.macro Define
-@define Define
-@macro Macro
-@string String
-@string.escape SpecialChar
-@string.special SpecialChar
-@character Character
-@character.special SpecialChar
-@number Number
-@boolean Boolean
-@float Float
-
-@function Function
-@function.builtin Special
-@function.macro Macro
-@parameter Identifier
-@method Function
-@field Identifier
-@property Identifier
-@constructor Special
-
-@conditional Conditional
-@repeat Repeat
-@label Label
-@operator Operator
-@keyword Keyword
-@exception Exception
-
-@variable Identifier
-@type Type
-@type.definition Typedef
-@storageclass StorageClass
-@structure Structure
-@namespace Identifier
-@include Include
-@preproc PreProc
-@debug Debug
-@tag Tag
+The following captures are linked by default to standard |group-name|s (use
+|:Inspect| on a group to see the current link):
+
+@variable various variable names
+@variable.builtin built-in variable names (e.g. `this`)
+@variable.parameter parameters of a function
+@variable.member object and struct fields
+
+@constant constant identifiers
+@constant.builtin built-in constant values
+@constant.macro constants defined by the preprocessor
+
+@module modules or namespaces
+@module.builtin built-in modules or namespaces
+@label GOTO and other labels (e.g. `label:` in C), including heredoc labels
+
+@string string literals
+@string.documentation string documenting code (e.g. Python docstrings)
+@string.regexp regular expressions
+@string.escape escape sequences
+@string.special other special strings (e.g. dates)
+@string.special.symbol symbols or atoms
+@string.special.path filenames
+@string.special.url URIs (e.g. hyperlinks)
+
+@character character literals
+@character.special special characters (e.g. wildcards)
+
+@boolean boolean literals
+@number numeric literals
+@number.float floating-point number literals
+
+@type type or class definitions and annotations
+@type.builtin built-in types
+@type.definition identifiers in type definitions (e.g. `typedef <type> <identifier>` in C)
+@type.qualifier type qualifiers (e.g. `const`)
+
+@attribute attribute annotations (e.g. Python decorators)
+@property the key in key/value pairs
+
+@function function definitions
+@function.builtin built-in functions
+@function.call function calls
+@function.macro preprocessor macros
+
+@function.method method definitions
+@function.method.call method calls
+
+@constructor constructor calls and definitions
+@operator symbolic operators (e.g. `+` / `*`)
+
+@keyword keywords not fitting into specific categories
+@keyword.coroutine keywords related to coroutines (e.g. `go` in Go, `async/await` in Python)
+@keyword.function keywords that define a function (e.g. `func` in Go, `def` in Python)
+@keyword.operator operators that are English words (e.g. `and` / `or`)
+@keyword.import keywords for including modules (e.g. `import` / `from` in Python)
+@keyword.storage modifiers that affect storage in memory or life-time
+@keyword.repeat keywords related to loops (e.g. `for` / `while`)
+@keyword.return keywords like `return` and `yield`
+@keyword.debug keywords related to debugging
+@keyword.exception keywords related to exceptions (e.g. `throw` / `catch`)
+
+@keyword.conditional keywords related to conditionals (e.g. `if` / `else`)
+@keyword.conditional.ternary ternary operator (e.g. `?` / `:`)
+
+@keyword.directive various preprocessor directives and shebangs
+@keyword.directive.define preprocessor definition directives
+
+@punctuation.delimiter delimiters (e.g. `;` / `.` / `,`)
+@punctuation.bracket brackets (e.g. `()` / `{}` / `[]`)
+@punctuation.special special symbols (e.g. `{}` in string interpolation)
+
+@comment line and block comments
+@comment.documentation comments documenting code
+
+@comment.error error-type comments (e.g. `ERROR`, `FIXME`, `DEPRECATED:`)
+@comment.warning warning-type comments (e.g. `WARNING:`, `FIX:`, `HACK:`)
+@comment.todo todo-type comments (e.g. `TODO:`, `WIP:`, `FIXME:`)
+@comment.note note-type comments (e.g. `NOTE:`, `INFO:`, `XXX`)
+
+@markup.strong bold text
+@markup.italic italic text
+@markup.strikethrough struck-through text
+@markup.underline underlined text (only for literal underline markup!)
+
+@markup.heading headings, titles (including markers)
+
+@markup.quote block quotes
+@markup.math math environments (e.g. `$ ... $` in LaTeX)
+@markup.environment environments (e.g. in LaTeX)
+
+@markup.link text references, footnotes, citations, etc.
+@markup.link.label link, reference descriptions
+@markup.link.url URL-style links
+
+@markup.raw literal or verbatim text (e.g. inline code)
+@markup.raw.block literal or verbatim text as a stand-alone block
+
+@markup.list list markers
+@markup.list.checked checked todo-style list markers
+@markup.list.unchecked unchecked todo-style list markers
+
+@diff.plus added text (for diff files)
+@diff.minus deleted text (for diff files)
+@diff.delta changed text (for diff files)
+
+@tag XML-style tag names (e.g. in XML, HTML, etc.)
+@tag.attribute XML-style tag attributes
+@tag.delimiter XML-style tag delimiters
*treesitter-highlight-spell*
The special `@spell` capture can be used to indicate that a node should be
diff --git a/runtime/doc/ui.txt b/runtime/doc/ui.txt
index 8546478935..c81420d1f2 100644
--- a/runtime/doc/ui.txt
+++ b/runtime/doc/ui.txt
@@ -228,6 +228,10 @@ the editor.
however a UI might still use such options when rendering raw text
sent from Nvim, like for |ui-cmdline|.
+["chdir", path] ~
+ The |current-directory| of the embedded Nvim process changed to
+ `path`.
+
["mode_change", mode, mode_idx] ~
Editor mode changed. The `mode` parameter is a string representing
the current mode. `mode_idx` is an index into the array emitted in
diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua
index 52a21587f4..fd49f63558 100644
--- a/runtime/lua/vim/_editor.lua
+++ b/runtime/lua/vim/_editor.lua
@@ -1033,21 +1033,44 @@ end
---
---@return string|nil # Deprecated message, or nil if no message was shown.
function vim.deprecate(name, alternative, version, plugin, backtrace)
+ vim.validate {
+ name = { name, 'string' },
+ alternative = { alternative, 'string', true },
+ version = { version, 'string', true },
+ plugin = { plugin, 'string', true },
+ }
+ plugin = plugin or 'Nvim'
+
-- Only issue warning if feature is hard-deprecated as specified by MAINTAIN.md.
- if plugin == nil then
- local current_version = vim.version()
- local deprecated_version = assert(vim.version.parse(version))
- local soft_deprecated_version =
- { deprecated_version.major, deprecated_version.minor - 1, deprecated_version.patch }
- local deprecate = vim.version.lt(current_version, soft_deprecated_version)
- if deprecate then
+ -- e.g., when planned to be removed in version = '0.12' (soft-deprecated since 0.10-dev),
+ -- show warnings since 0.11, including 0.11-dev (hard_deprecated_since = 0.11-dev).
+ if plugin == 'Nvim' then
+ local current_version = vim.version() ---@type Version
+ local removal_version = assert(vim.version.parse(version))
+ local is_hard_deprecated ---@type boolean
+
+ if removal_version.minor > 0 then
+ local hard_deprecated_since = assert(vim.version._version({
+ major = removal_version.major,
+ minor = removal_version.minor - 1,
+ patch = 0,
+ prerelease = 'dev', -- Show deprecation warnings in devel (nightly) version as well
+ }))
+ is_hard_deprecated = (current_version >= hard_deprecated_since)
+ else
+ -- Assume there will be no next minor version before bumping up the major version;
+ -- therefore we can always show a warning.
+ assert(removal_version.minor == 0, vim.inspect(removal_version))
+ is_hard_deprecated = true
+ end
+
+ if not is_hard_deprecated then
return
end
end
local msg = ('%s is deprecated'):format(name)
- plugin = plugin or 'Nvim'
- msg = alternative and ('%s, use %s instead.'):format(msg, alternative) or msg
+ msg = alternative and ('%s, use %s instead.'):format(msg, alternative) or (msg .. '.')
msg = ('%s%s\nThis feature will be removed in %s version %s'):format(
msg,
(plugin == 'Nvim' and ' :help deprecated' or ''),
diff --git a/runtime/lua/vim/_meta/api.lua b/runtime/lua/vim/_meta/api.lua
index 3f06d4fd43..f773ddd75c 100644
--- a/runtime/lua/vim/_meta/api.lua
+++ b/runtime/lua/vim/_meta/api.lua
@@ -323,8 +323,8 @@ function vim.api.nvim_buf_get_commands(buffer, opts) end
--- @return integer[]
function vim.api.nvim_buf_get_extmark_by_id(buffer, ns_id, id, opts) end
---- Gets `extmarks` (including `signs`) in "traversal order" from a `charwise`
---- region defined by buffer positions (inclusive, 0-indexed `api-indexing`).
+--- Gets `extmarks` in "traversal order" from a `charwise` region defined by
+--- buffer positions (inclusive, 0-indexed `api-indexing`).
--- Region can be given as (row,col) tuples, or valid extmark ids (whose
--- positions define the bounds). 0 and -1 are understood as (0,0) and (-1,-1)
--- respectively, thus the following are equivalent:
@@ -339,6 +339,9 @@ function vim.api.nvim_buf_get_extmark_by_id(buffer, ns_id, id, opts) end
--- Note: when using extmark ranges (marks with a end_row/end_col position)
--- the `overlap` option might be useful. Otherwise only the start position of
--- an extmark will be considered.
+--- Note: legacy signs placed through the `:sign` commands are implemented as
+--- extmarks and will show up here. Their details array will contain a
+--- `sign_name` field.
--- Example:
---
--- ```lua
@@ -567,7 +570,9 @@ function vim.api.nvim_buf_line_count(buffer) end
--- text around the mark was deleted and then restored by
--- undo. Defaults to true.
--- • invalidate : boolean that indicates whether to hide the
---- extmark if the entirety of its range is deleted. If
+--- extmark if the entirety of its range is deleted. For
+--- hidden marks, an "invalid" key is added to the "details"
+--- array of `nvim_buf_get_extmarks()` and family. If
--- "undo_restore" is false, the extmark is deleted instead.
--- • priority: a priority value for the highlight group or sign
--- attribute. For example treesitter highlighting uses a
diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua
index a83c74fd7c..7e1803f640 100644
--- a/runtime/lua/vim/filetype.lua
+++ b/runtime/lua/vim/filetype.lua
@@ -267,6 +267,7 @@ local extension = {
crdpro = 'chordpro',
cho = 'chordpro',
chordpro = 'chordpro',
+ ck = 'chuck',
eni = 'cl',
icl = 'clean',
cljx = 'clojure',
diff --git a/runtime/lua/vim/glob.lua b/runtime/lua/vim/glob.lua
index 764200dd36..ad4a915a94 100644
--- a/runtime/lua/vim/glob.lua
+++ b/runtime/lua/vim/glob.lua
@@ -1,7 +1,11 @@
local lpeg = vim.lpeg
+local P, S, V, R, B = lpeg.P, lpeg.S, lpeg.V, lpeg.R, lpeg.B
+local C, Cc, Ct, Cf = lpeg.C, lpeg.Cc, lpeg.Ct, lpeg.Cf
local M = {}
+local pathsep = P('/')
+
--- Parses a raw glob into an |lua-lpeg| pattern.
---
--- This uses glob semantics from LSP 3.17.0: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#pattern
@@ -17,18 +21,8 @@ local M = {}
---@param pattern string The raw glob pattern
---@return vim.lpeg.Pattern pattern An |lua-lpeg| representation of the pattern
function M.to_lpeg(pattern)
- local l = lpeg
-
- local P, S, V = lpeg.P, lpeg.S, lpeg.V
- local C, Cc, Ct, Cf = lpeg.C, lpeg.Cc, lpeg.Ct, lpeg.Cf
-
- local pathsep = '/'
-
local function class(inv, ranges)
- for i, r in ipairs(ranges) do
- ranges[i] = r[1] .. r[2]
- end
- local patt = l.R(unpack(ranges))
+ local patt = R(unpack(vim.tbl_map(table.concat, ranges)))
if inv == '!' then
patt = P(1) - patt
end
@@ -44,11 +38,11 @@ function M.to_lpeg(pattern)
end
local function star(stars, after)
- return (-after * (l.P(1) - pathsep)) ^ #stars * after
+ return (-after * (P(1) - pathsep)) ^ #stars * after
end
local function dstar(after)
- return (-after * l.P(1)) ^ 0 * after
+ return (-after * P(1)) ^ 0 * after
end
local p = P({
@@ -59,11 +53,17 @@ function M.to_lpeg(pattern)
* (V('Elem') + V('End')),
mul
),
- DStar = P('**') * (P(pathsep) * (V('Elem') + V('End')) + V('End')) / dstar,
+ DStar = (B(pathsep) + -B(P(1)))
+ * P('**')
+ * (pathsep * (V('Elem') + V('End')) + V('End'))
+ / dstar,
Star = C(P('*') ^ 1) * (V('Elem') + V('End')) / star,
- Ques = P('?') * Cc(l.P(1) - pathsep),
- Class = P('[') * C(P('!') ^ -1) * Ct(Ct(C(1) * '-' * C(P(1) - ']')) ^ 1 * ']') / class,
- CondList = P('{') * Cf(V('Cond') * (P(',') * V('Cond')) ^ 0, add) * '}',
+ Ques = P('?') * Cc(P(1) - pathsep),
+ Class = P('[')
+ * C(P('!') ^ -1)
+ * Ct(Ct(C(P(1)) * P('-') * C(P(1) - P(']'))) ^ 1 * P(']'))
+ / class,
+ CondList = P('{') * Cf(V('Cond') * (P(',') * V('Cond')) ^ 0, add) * P('}'),
-- TODO: '*' inside a {} condition is interpreted literally but should probably have the same
-- wildcard semantics it usually has.
-- Fixing this is non-trivial because '*' should match non-greedily up to "the rest of the
@@ -71,9 +71,9 @@ function M.to_lpeg(pattern)
-- condition means "everything after the {}" where several other options separated by ',' may
-- exist in between that should not be matched by '*'.
Cond = Cf((V('Ques') + V('Class') + V('CondList') + (V('Literal') - S(',}'))) ^ 1, mul)
- + Cc(l.P(0)),
- Literal = P(1) / l.P,
- End = P(-1) * Cc(l.P(-1)),
+ + Cc(P(0)),
+ Literal = P(1) / P,
+ End = P(-1) * Cc(P(-1)),
})
local lpeg_pattern = p:match(pattern) --[[@as vim.lpeg.Pattern?]]
diff --git a/runtime/lua/vim/lsp/_meta.lua b/runtime/lua/vim/lsp/_meta.lua
index 559939c236..be3222828d 100644
--- a/runtime/lua/vim/lsp/_meta.lua
+++ b/runtime/lua/vim/lsp/_meta.lua
@@ -14,10 +14,3 @@ error('Cannot require a meta file')
---@field code integer
---@field message string
---@field data string|number|boolean|table[]|table|nil
-
---- @class lsp.DocumentFilter
---- @field language? string
---- @field scheme? string
---- @field pattern? string
-
---- @alias lsp.RegisterOptions any | lsp.StaticRegistrationOptions | lsp.TextDocumentRegistrationOptions
diff --git a/runtime/lua/vim/lsp/_meta/protocol.lua b/runtime/lua/vim/lsp/_meta/protocol.lua
index 4c053cb57e..b897b6bba5 100644
--- a/runtime/lua/vim/lsp/_meta/protocol.lua
+++ b/runtime/lua/vim/lsp/_meta/protocol.lua
@@ -1,7 +1,11 @@
--[[
-This file is autogenerated from scripts/gen_lsp.lua
+THIS FILE IS GENERATED by scripts/gen_lsp.lua
+DO NOT EDIT MANUALLY
+
+Based on LSP protocol 3.18
+
Regenerate:
-nvim -l scripts/gen_lsp.lua gen --version 3.18 --out runtime/lua/vim/lsp/_meta/protocol.lua
+nvim -l scripts/gen_lsp.lua gen --version 3.18
--]]
---@meta
@@ -9,12 +13,9 @@ error('Cannot require a meta file')
---@alias lsp.null nil
---@alias uinteger integer
----@alias lsp.decimal number
+---@alias decimal number
---@alias lsp.DocumentUri string
---@alias lsp.URI string
----@alias lsp.LSPObject table<string, lsp.LSPAny>
----@alias lsp.LSPArray lsp.LSPAny[]
----@alias lsp.LSPAny lsp.LSPObject|lsp.LSPArray|string|number|boolean|nil
---@class lsp.ImplementationParams: lsp.TextDocumentPositionParams, lsp.WorkDoneProgressParams, lsp.PartialResultParams
diff --git a/runtime/lua/vim/version.lua b/runtime/lua/vim/version.lua
index 0873402e29..4f52938c6e 100644
--- a/runtime/lua/vim/version.lua
+++ b/runtime/lua/vim/version.lua
@@ -259,11 +259,12 @@ end
--- print(r:has(vim.version())) -- check against current Nvim version
--- ```
---
---- Or use cmp(), eq(), lt(), and gt() to compare `.to` and `.from` directly:
+--- Or use cmp(), le(), lt(), ge(), gt(), and/or eq() to compare a version
+--- against `.to` and `.from` directly:
---
--- ```lua
---- local r = vim.version.range('1.0.0 - 2.0.0')
---- print(vim.version.gt({1,0,3}, r.from) and vim.version.lt({1,0,3}, r.to))
+--- local r = vim.version.range('1.0.0 - 2.0.0') -- >=1.0, <2.0
+--- print(vim.version.ge({1,0,3}, r.from) and vim.version.lt({1,0,3}, r.to))
--- ```
---
--- @see # https://github.com/npm/node-semver#ranges
@@ -364,8 +365,8 @@ end
---
--- @note Per semver, build metadata is ignored when comparing two otherwise-equivalent versions.
---
----@param v1 Version|number[] Version object.
----@param v2 Version|number[] Version to compare with `v1`.
+---@param v1 Version|number[]|string Version object.
+---@param v2 Version|number[]|string Version to compare with `v1`.
---@return integer -1 if `v1 < v2`, 0 if `v1 == v2`, 1 if `v1 > v2`.
function M.cmp(v1, v2)
local v1_parsed = assert(M._version(v1), create_err_msg(v1))
@@ -380,24 +381,40 @@ function M.cmp(v1, v2)
end
---Returns `true` if the given versions are equal. See |vim.version.cmp()| for usage.
----@param v1 Version|number[]
----@param v2 Version|number[]
+---@param v1 Version|number[]|string
+---@param v2 Version|number[]|string
---@return boolean
function M.eq(v1, v2)
return M.cmp(v1, v2) == 0
end
+---Returns `true` if `v1 <= v2`. See |vim.version.cmp()| for usage.
+---@param v1 Version|number[]|string
+---@param v2 Version|number[]|string
+---@return boolean
+function M.le(v1, v2)
+ return M.cmp(v1, v2) <= 0
+end
+
---Returns `true` if `v1 < v2`. See |vim.version.cmp()| for usage.
----@param v1 Version|number[]
----@param v2 Version|number[]
+---@param v1 Version|number[]|string
+---@param v2 Version|number[]|string
---@return boolean
function M.lt(v1, v2)
return M.cmp(v1, v2) == -1
end
+---Returns `true` if `v1 >= v2`. See |vim.version.cmp()| for usage.
+---@param v1 Version|number[]|string
+---@param v2 Version|number[]|string
+---@return boolean
+function M.ge(v1, v2)
+ return M.cmp(v1, v2) >= 0
+end
+
---Returns `true` if `v1 > v2`. See |vim.version.cmp()| for usage.
----@param v1 Version|number[]
----@param v2 Version|number[]
+---@param v1 Version|number[]|string
+---@param v2 Version|number[]|string
---@return boolean
function M.gt(v1, v2)
return M.cmp(v1, v2) == 1
@@ -417,7 +434,7 @@ end
--- - strict (boolean): Default false. If `true`, no coercion is attempted on
--- input not conforming to semver v2.0.0. If `false`, `parse()` attempts to
--- coerce input such as "1.0", "0-x", "tmux 3.2a" into valid versions.
----@return table|nil parsed_version Version object or `nil` if input is invalid.
+---@return Version? parsed_version Version object or `nil` if input is invalid.
function M.parse(version, opts)
assert(type(version) == 'string', create_err_msg(version))
opts = opts or { strict = false }
@@ -426,6 +443,7 @@ end
setmetatable(M, {
--- Returns the current Nvim version.
+ ---@return Version
__call = function()
local version = vim.fn.api_info().version
-- Workaround: vim.fn.api_info().version reports "prerelease" as a boolean.
diff --git a/runtime/queries/bash/folds.scm b/runtime/queries/bash/folds.scm
index 851c67eed4..766dbe598b 100644
--- a/runtime/queries/bash/folds.scm
+++ b/runtime/queries/bash/folds.scm
@@ -5,4 +5,5 @@
(for_statement)
(while_statement)
(c_style_for_statement)
+ (heredoc_redirect)
] @fold
diff --git a/runtime/queries/bash/highlights.scm b/runtime/queries/bash/highlights.scm
index 23bf03e697..21346ded8f 100644
--- a/runtime/queries/bash/highlights.scm
+++ b/runtime/queries/bash/highlights.scm
@@ -1,81 +1,100 @@
-(simple_expansion) @none
-(expansion
- "${" @punctuation.special
- "}" @punctuation.special) @none
[
- "("
- ")"
- "(("
- "))"
- "{"
- "}"
- "["
- "]"
- "[["
- "]]"
- ] @punctuation.bracket
+ "("
+ ")"
+ "{"
+ "}"
+ "["
+ "]"
+ "[["
+ "]]"
+ "(("
+ "))"
+] @punctuation.bracket
[
- ";"
- ";;"
- (heredoc_start)
- ] @punctuation.delimiter
+ ";"
+ ";;"
+ ";&"
+ ";;&"
+ "&"
+] @punctuation.delimiter
[
- "$"
-] @punctuation.special
-
+ ">"
+ ">>"
+ "<"
+ "<<"
+ "&&"
+ "|"
+ "|&"
+ "||"
+ "="
+ "+="
+ "=~"
+ "=="
+ "!="
+ "&>"
+ "&>>"
+ "<&"
+ ">&"
+ ">|"
+ "<&-"
+ ">&-"
+ "<<-"
+ "<<<"
+ ".."
+] @operator
+
+; Do *not* spell check strings since they typically have some sort of
+; interpolation in them, or, are typically used for things like filenames, URLs,
+; flags and file content.
[
- ">"
- ">>"
- "<"
- "<<"
- "&"
- "&&"
- "|"
- "||"
- "="
- "=~"
- "=="
- "!="
- ] @operator
+ (string)
+ (raw_string)
+ (ansi_c_string)
+ (heredoc_body)
+] @string
[
- (string)
- (raw_string)
- (ansi_c_string)
- (heredoc_body)
-] @string @spell
+ (heredoc_start)
+ (heredoc_end)
+] @label
-(variable_assignment (word) @string)
+(variable_assignment
+ (word) @string)
+
+(command
+ argument: "$" @string) ; bare dollar
[
- "if"
- "then"
- "else"
- "elif"
- "fi"
- "case"
- "in"
- "esac"
- ] @conditional
+ "if"
+ "then"
+ "else"
+ "elif"
+ "fi"
+ "case"
+ "in"
+ "esac"
+] @keyword.conditional
[
- "for"
- "do"
- "done"
- "select"
- "until"
- "while"
- ] @repeat
+ "for"
+ "do"
+ "done"
+ "select"
+ "until"
+ "while"
+] @keyword.repeat
[
- "declare"
- "export"
- "local"
- "readonly"
- "unset"
- ] @keyword
+ "declare"
+ "typeset"
+ "export"
+ "readonly"
+ "local"
+ "unset"
+ "unsetenv"
+] @keyword
"function" @keyword.function
@@ -83,28 +102,56 @@
; trap -l
((word) @constant.builtin
- (#match? @constant.builtin "^SIG(HUP|INT|QUIT|ILL|TRAP|ABRT|BUS|FPE|KILL|USR[12]|SEGV|PIPE|ALRM|TERM|STKFLT|CHLD|CONT|STOP|TSTP|TT(IN|OU)|URG|XCPU|XFSZ|VTALRM|PROF|WINCH|IO|PWR|SYS|RTMIN([+]([1-9]|1[0-5]))?|RTMAX(-([1-9]|1[0-4]))?)$"))
+ (#match? @constant.builtin "^SIG(HUP|INT|QUIT|ILL|TRAP|ABRT|BUS|FPE|KILL|USR[12]|SEGV|PIPE|ALRM|TERM|STKFLT|CHLD|CONT|STOP|TSTP|TT(IN|OU)|URG|XCPU|XFSZ|VTALRM|PROF|WINCH|IO|PWR|SYS|RTMIN([+]([1-9]|1[0-5]))?|RTMAX(-([1-9]|1[0-4]))?)$"))
((word) @boolean
(#any-of? @boolean "true" "false"))
(comment) @comment @spell
-(test_operator) @string
+
+(test_operator) @operator
(command_substitution
- [ "$(" ")" ] @punctuation.bracket)
+ "$(" @punctuation.bracket)
(process_substitution
- [ "<(" ")" ] @punctuation.bracket)
+ "<(" @punctuation.bracket)
+(arithmetic_expansion
+ [
+ "$(("
+ "(("
+ ] @punctuation.special
+ "))" @punctuation.special)
+
+(arithmetic_expansion
+ "," @punctuation.delimiter)
+
+(ternary_expression
+ [
+ "?"
+ ":"
+ ] @keyword.conditional.ternary)
+
+(binary_expression
+ operator: _ @operator)
+
+(unary_expression
+ operator: _ @operator)
+
+(postfix_expression
+ operator: _ @operator)
(function_definition
name: (word) @function)
-(command_name (word) @function.call)
+(command_name
+ (word) @function.call)
-((command_name (word) @function.builtin)
- (#any-of? @function.builtin
+((command_name
+ (word) @function.builtin)
+ ; format-ignore
+ (#any-of? @function.builtin
"alias" "bg" "bind" "break" "builtin" "caller" "cd"
"command" "compgen" "complete" "compopt" "continue"
"coproc" "dirs" "disown" "echo" "enable" "eval"
@@ -116,30 +163,59 @@
"ulimit" "umask" "unalias" "wait"))
(command
- argument: [
- (word) @parameter
- (concatenation (word) @parameter)
- ])
+ argument:
+ [
+ (word) @variable.parameter
+ (concatenation
+ (word) @variable.parameter)
+ ])
+
+(number) @number
((word) @number
(#lua-match? @number "^[0-9]+$"))
(file_redirect
- descriptor: (file_descriptor) @operator
- destination: (word) @parameter)
+ destination: (word) @variable.parameter)
+
+(file_descriptor) @operator
+
+(simple_expansion
+ "$" @punctuation.special) @none
+
+(expansion
+ "${" @punctuation.special
+ "}" @punctuation.special) @none
(expansion
- [ "${" "}" ] @punctuation.bracket)
+ operator: _ @punctuation.special)
+
+(expansion
+ "@"
+ .
+ operator: _ @character.special)
+
+((expansion
+ (subscript
+ index: (word) @character.special))
+ (#any-of? @character.special "@" "*"))
+
+"``" @punctuation.special
(variable_name) @variable
((variable_name) @constant
- (#lua-match? @constant "^[A-Z][A-Z_0-9]*$"))
+ (#lua-match? @constant "^[A-Z][A-Z_0-9]*$"))
(case_item
- value: (word) @parameter)
-
-(regex) @string.regex
+ value: (word) @variable.parameter)
-((program . (comment) @preproc)
- (#lua-match? @preproc "^#!/"))
+[
+ (regex)
+ (extglob_pattern)
+] @string.regexp
+
+((program
+ .
+ (comment) @keyword.directive)
+ (#lua-match? @keyword.directive "^#!/"))
diff --git a/runtime/queries/c/folds.scm b/runtime/queries/c/folds.scm
index 5a35334a24..2e2a6b4d0c 100644
--- a/runtime/queries/c/folds.scm
+++ b/runtime/queries/c/folds.scm
@@ -1,19 +1,21 @@
[
- (for_statement)
- (if_statement)
- (while_statement)
- (switch_statement)
- (case_statement)
- (function_definition)
- (struct_specifier)
- (enum_specifier)
- (comment)
- (preproc_if)
- (preproc_elif)
- (preproc_else)
- (preproc_ifdef)
- (initializer_list)
- (gnu_asm_expression)
+ (for_statement)
+ (if_statement)
+ (while_statement)
+ (do_statement)
+ (switch_statement)
+ (case_statement)
+ (function_definition)
+ (struct_specifier)
+ (enum_specifier)
+ (comment)
+ (preproc_if)
+ (preproc_elif)
+ (preproc_else)
+ (preproc_ifdef)
+ (preproc_function_def)
+ (initializer_list)
+ (gnu_asm_expression)
] @fold
(compound_statement
diff --git a/runtime/queries/c/highlights.scm b/runtime/queries/c/highlights.scm
index 29fb5747ca..c848f68dca 100644
--- a/runtime/queries/c/highlights.scm
+++ b/runtime/queries/c/highlights.scm
@@ -1,6 +1,9 @@
-; Lower priority to prefer @parameter when identifier appears in parameter_declaration.
-((identifier) @variable (#set! "priority" 95))
-(preproc_def (preproc_arg) @variable)
+; Lower priority to prefer @variable.parameter when identifier appears in parameter_declaration.
+((identifier) @variable
+ (#set! "priority" 95))
+
+(preproc_def
+ (preproc_arg) @variable)
[
"default"
@@ -17,7 +20,10 @@
"sizeof"
"offsetof"
] @keyword.operator
-(alignof_expression . _ @keyword.operator)
+
+(alignof_expression
+ .
+ _ @keyword.operator)
"return" @keyword.return
@@ -27,14 +33,14 @@
"do"
"continue"
"break"
-] @repeat
+] @keyword.repeat
[
- "if"
- "else"
- "case"
- "switch"
-] @conditional
+ "if"
+ "else"
+ "case"
+ "switch"
+] @keyword.conditional
[
"#if"
@@ -46,48 +52,54 @@
"#elifdef"
"#elifndef"
(preproc_directive)
-] @preproc
+] @keyword.directive
-"#define" @define
+"#define" @keyword.directive.define
-"#include" @include
+"#include" @keyword.import
-[ ";" ":" "," "::" ] @punctuation.delimiter
+[
+ ";"
+ ":"
+ ","
+ "::"
+] @punctuation.delimiter
"..." @punctuation.special
-[ "(" ")" "[" "]" "{" "}"] @punctuation.bracket
+[
+ "("
+ ")"
+ "["
+ "]"
+ "{"
+ "}"
+] @punctuation.bracket
[
"="
-
"-"
"*"
"/"
"+"
"%"
-
"~"
"|"
"&"
"^"
"<<"
">>"
-
"->"
"."
-
"<"
"<="
">="
">"
"=="
"!="
-
"!"
"&&"
"||"
-
"-="
"+="
"*="
@@ -102,45 +114,57 @@
"++"
] @operator
-;; Make sure the comma operator is given a highlight group after the comma
-;; punctuator so the operator is highlighted properly.
-(comma_expression [ "," ] @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
-(conditional_expression [ "?" ":" ] @conditional.ternary)
+(conditional_expression
+ [
+ "?"
+ ":"
+ ] @keyword.conditional.ternary)
(string_literal) @string
+
(system_lib_string) @string
+
(escape_sequence) @string.escape
(null) @constant.builtin
+
(number_literal) @number
+
(char_literal) @character
-((preproc_arg) @function.macro (#set! "priority" 90))
+((preproc_arg) @function.macro
+ (#set! "priority" 90))
+
(preproc_defined) @function.macro
-(((field_expression
- (field_identifier) @property)) @_parent
- (#not-has-parent? @_parent template_method function_declarator call_expression))
+((field_expression
+ (field_identifier) @property) @_parent
+ (#not-has-parent? @_parent template_method function_declarator call_expression))
(field_designator) @property
-(((field_identifier) @property)
- (#has-ancestor? @property field_declaration)
- (#not-has-ancestor? @property function_declarator))
+
+((field_identifier) @property
+ (#has-ancestor? @property field_declaration)
+ (#not-has-ancestor? @property function_declarator))
(statement_identifier) @label
[
- (type_identifier)
- (type_descriptor)
+ (type_identifier)
+ (type_descriptor)
] @type
-(storage_class_specifier) @storageclass
+(storage_class_specifier) @keyword.storage
[
(type_qualifier)
@@ -149,25 +173,32 @@
] @type.qualifier
(linkage_specification
- "extern" @storageclass)
+ "extern" @keyword.storage)
(type_definition
declarator: (type_identifier) @type.definition)
(primitive_type) @type.builtin
-(sized_type_specifier _ @type.builtin type: _?)
+(sized_type_specifier
+ _ @type.builtin
+ type: _?)
((identifier) @constant
- (#lua-match? @constant "^[A-Z][A-Z0-9_]+$"))
-(preproc_def (preproc_arg) @constant
(#lua-match? @constant "^[A-Z][A-Z0-9_]+$"))
+
+(preproc_def
+ (preproc_arg) @constant
+ (#lua-match? @constant "^[A-Z][A-Z0-9_]+$"))
+
(enumerator
name: (identifier) @constant)
+
(case_statement
value: (identifier) @constant)
((identifier) @constant.builtin
+ ; format-ignore
(#any-of? @constant.builtin
"stderr" "stdin" "stdout"
"__FILE__" "__LINE__" "__DATE__" "__TIME__"
@@ -180,7 +211,10 @@
"__clang_wide_literal_encoding__"
"__FUNCTION__" "__func__" "__PRETTY_FUNCTION__"
"__VA_ARGS__" "__VA_OPT__"))
-(preproc_def (preproc_arg) @constant.builtin
+
+(preproc_def
+ (preproc_arg) @constant.builtin
+ ; format-ignore
(#any-of? @constant.builtin
"stderr" "stdin" "stdout"
"__FILE__" "__LINE__" "__DATE__" "__TIME__"
@@ -195,21 +229,26 @@
"__VA_ARGS__" "__VA_OPT__"))
(attribute_specifier
- (argument_list (identifier) @variable.builtin))
+ (argument_list
+ (identifier) @variable.builtin))
+
((attribute_specifier
- (argument_list (call_expression
- function: (identifier) @variable.builtin))))
+ (argument_list
+ (call_expression
+ function: (identifier) @variable.builtin))))
((call_expression
function: (identifier) @function.builtin)
(#lua-match? @function.builtin "^__builtin_"))
+
((call_expression
- function: (identifier) @function.builtin)
+ function: (identifier) @function.builtin)
(#has-ancestor? @function.builtin attribute_specifier))
-;; Preproc def / undef
+; Preproc def / undef
(preproc_def
name: (_) @constant)
+
(preproc_call
directive: (preproc_directive) @_u
argument: (_) @constant
@@ -217,15 +256,21 @@
(call_expression
function: (identifier) @function.call)
+
(call_expression
- function: (field_expression
- field: (field_identifier) @function.call))
+ function:
+ (field_expression
+ field: (field_identifier) @function.call))
+
(function_declarator
declarator: (identifier) @function)
+
(function_declarator
- declarator: (parenthesized_declarator
- (pointer_declarator
- declarator: (field_identifier) @function)))
+ declarator:
+ (parenthesized_declarator
+ (pointer_declarator
+ declarator: (field_identifier) @function)))
+
(preproc_function_def
name: (identifier) @function.macro)
@@ -234,17 +279,40 @@
((comment) @comment.documentation
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
-;; Parameters
+; Parameters
(parameter_declaration
- declarator: (identifier) @parameter)
+ declarator: (identifier) @variable.parameter)
(parameter_declaration
- declarator: (array_declarator) @parameter)
+ declarator: (array_declarator) @variable.parameter)
(parameter_declaration
- declarator: (pointer_declarator) @parameter)
-
-(preproc_params (identifier) @parameter)
+ declarator: (pointer_declarator) @variable.parameter)
+
+; K&R functions
+; To enable support for K&R functions,
+; add the following lines to your own query config and uncomment them.
+; They are commented out as they'll conflict with C++
+; Note that you'll need to have `; extends` at the top of your query file.
+;
+; (parameter_list (identifier) @variable.parameter)
+;
+; (function_definition
+; declarator: _
+; (declaration
+; declarator: (identifier) @variable.parameter))
+;
+; (function_definition
+; declarator: _
+; (declaration
+; declarator: (array_declarator) @variable.parameter))
+;
+; (function_definition
+; declarator: _
+; (declaration
+; declarator: (pointer_declarator) @variable.parameter))
+(preproc_params
+ (identifier) @variable.parameter)
[
"__attribute__"
@@ -259,5 +327,3 @@
(ms_pointer_modifier)
(attribute_declaration)
] @attribute
-
-(ERROR) @error
diff --git a/runtime/queries/c/injections.scm b/runtime/queries/c/injections.scm
index 5a49e20df5..ce2f88a215 100644
--- a/runtime/queries/c/injections.scm
+++ b/runtime/queries/c/injections.scm
@@ -1,21 +1,2 @@
-((preproc_def
- (preproc_arg) @injection.content)
- (#lua-match? @injection.content "\n")
- (#set! injection.language "c"))
-
-(preproc_function_def
- (preproc_arg) @injection.content
- (#set! injection.language "c"))
-
-(preproc_call
- (preproc_arg) @injection.content
- (#set! injection.language "c"))
-
-; ((comment) @injection.content
-; (#set! injection.language "comment"))
-
-; TODO: add when asm is added
-; (gnu_asm_expression assembly_code: (string_literal) @injection.content
-; (#set! injection.language "asm"))
-; (gnu_asm_expression assembly_code: (concatenated_string (string_literal) @injection.content)
-; (#set! injection.language "asm"))
+((preproc_arg) @injection.content
+ (#set! injection.self))
diff --git a/runtime/queries/lua/folds.scm b/runtime/queries/lua/folds.scm
index d8f0b42df3..9dfac3abc6 100644
--- a/runtime/queries/lua/folds.scm
+++ b/runtime/queries/lua/folds.scm
@@ -1,10 +1,12 @@
[
- (do_statement)
- (while_statement)
- (repeat_statement)
- (if_statement)
- (for_statement)
- (function_declaration)
- (function_definition)
- (table_constructor)
+ (do_statement)
+ (while_statement)
+ (repeat_statement)
+ (if_statement)
+ (for_statement)
+ (function_declaration)
+ (function_definition)
+ (parameters)
+ (arguments)
+ (table_constructor)
] @fold
diff --git a/runtime/queries/lua/highlights.scm b/runtime/queries/lua/highlights.scm
index 96ffeae793..0b0bf35a8b 100644
--- a/runtime/queries/lua/highlights.scm
+++ b/runtime/queries/lua/highlights.scm
@@ -1,81 +1,79 @@
-;; Keywords
-
+; Keywords
"return" @keyword.return
[
- "goto"
- "in"
- "local"
+ "goto"
+ "in"
+ "local"
] @keyword
(break_statement) @keyword
(do_statement
-[
- "do"
- "end"
-] @keyword)
+ [
+ "do"
+ "end"
+ ] @keyword)
(while_statement
-[
- "while"
- "do"
- "end"
-] @repeat)
+ [
+ "while"
+ "do"
+ "end"
+ ] @keyword.repeat)
(repeat_statement
-[
- "repeat"
- "until"
-] @repeat)
+ [
+ "repeat"
+ "until"
+ ] @keyword.repeat)
(if_statement
-[
- "if"
- "elseif"
- "else"
- "then"
- "end"
-] @conditional)
+ [
+ "if"
+ "elseif"
+ "else"
+ "then"
+ "end"
+ ] @keyword.conditional)
(elseif_statement
-[
- "elseif"
- "then"
- "end"
-] @conditional)
+ [
+ "elseif"
+ "then"
+ "end"
+ ] @keyword.conditional)
(else_statement
-[
- "else"
- "end"
-] @conditional)
+ [
+ "else"
+ "end"
+ ] @keyword.conditional)
(for_statement
-[
- "for"
- "do"
- "end"
-] @repeat)
+ [
+ "for"
+ "do"
+ "end"
+ ] @keyword.repeat)
(function_declaration
-[
- "function"
- "end"
-] @keyword.function)
+ [
+ "function"
+ "end"
+ ] @keyword.function)
(function_definition
-[
- "function"
- "end"
-] @keyword.function)
-
-;; Operators
+ [
+ "function"
+ "end"
+ ] @keyword.function)
+; Operators
[
- "and"
- "not"
- "or"
+ "and"
+ "not"
+ "or"
] @keyword.operator
[
@@ -102,8 +100,7 @@
".."
] @operator
-;; Punctuations
-
+; Punctuations
[
";"
":"
@@ -112,19 +109,17 @@
"."
] @punctuation.delimiter
-;; Brackets
-
+; Brackets
[
- "("
- ")"
- "["
- "]"
- "{"
- "}"
+ "("
+ ")"
+ "["
+ "]"
+ "{"
+ "}"
] @punctuation.bracket
-;; Variables
-
+; Variables
(identifier) @variable
((identifier) @constant.builtin
@@ -133,27 +128,28 @@
((identifier) @variable.builtin
(#eq? @variable.builtin "self"))
-((identifier) @namespace.builtin
- (#any-of? @namespace.builtin "_G" "debug" "io" "jit" "math" "os" "package" "string" "table" "utf8"))
+((identifier) @module.builtin
+ (#any-of? @module.builtin "_G" "debug" "io" "jit" "math" "os" "package" "string" "table" "utf8"))
((identifier) @keyword.coroutine
(#eq? @keyword.coroutine "coroutine"))
(variable_list
- attribute: (attribute
- (["<" ">"] @punctuation.bracket
- (identifier) @attribute)))
-
-;; Labels
+ (attribute
+ "<" @punctuation.bracket
+ (identifier) @attribute
+ ">" @punctuation.bracket))
-(label_statement (identifier) @label)
+; Labels
+(label_statement
+ (identifier) @label)
-(goto_statement (identifier) @label)
-
-;; Constants
+(goto_statement
+ (identifier) @label)
+; Constants
((identifier) @constant
- (#lua-match? @constant "^[A-Z][A-Z_0-9]*$"))
+ (#lua-match? @constant "^[A-Z][A-Z_0-9]*$"))
(vararg_expression) @constant
@@ -164,41 +160,49 @@
(true)
] @boolean
-;; Tables
-
-(field name: (identifier) @field)
+; Tables
+(field
+ name: (identifier) @variable.member)
-(dot_index_expression field: (identifier) @field)
+(dot_index_expression
+ field: (identifier) @variable.member)
(table_constructor
-[
- "{"
- "}"
-] @constructor)
+ [
+ "{"
+ "}"
+ ] @constructor)
-;; Functions
+; Functions
+(parameters
+ (identifier) @variable.parameter)
-(parameters (identifier) @parameter)
-
-(function_declaration
- name: [
- (identifier) @function
- (dot_index_expression
- field: (identifier) @function)
- ])
+(vararg_expression) @variable.parameter.builtin
(function_declaration
- name: (method_index_expression
- method: (identifier) @method))
-
-(assignment_statement
- (variable_list .
- name: [
+ name:
+ [
(identifier) @function
(dot_index_expression
field: (identifier) @function)
])
- (expression_list .
+
+(function_declaration
+ name:
+ (method_index_expression
+ method: (identifier) @function.method))
+
+(assignment_statement
+ (variable_list
+ .
+ name:
+ [
+ (identifier) @function
+ (dot_index_expression
+ field: (identifier) @function)
+ ])
+ (expression_list
+ .
value: (function_definition)))
(table_constructor
@@ -207,18 +211,20 @@
value: (function_definition)))
(function_call
- name: [
- (identifier) @function.call
- (dot_index_expression
- field: (identifier) @function.call)
- (method_index_expression
- method: (identifier) @method.call)
- ])
+ name:
+ [
+ (identifier) @function.call
+ (dot_index_expression
+ field: (identifier) @function.call)
+ (method_index_expression
+ method: (identifier) @function.method.call)
+ ])
(function_call
(identifier) @function.builtin
+ ; format-ignore
(#any-of? @function.builtin
- ;; built-in functions in Lua 5.1
+ ; built-in functions in Lua 5.1
"assert" "collectgarbage" "dofile" "error" "getfenv" "getmetatable" "ipairs"
"load" "loadfile" "loadstring" "module" "next" "pairs" "pcall" "print"
"rawequal" "rawget" "rawlen" "rawset" "require" "select" "setfenv" "setmetatable"
@@ -227,8 +233,7 @@
"__idiv" "__index" "__le" "__len" "__lt" "__metatable" "__mod" "__mul" "__name" "__newindex"
"__pairs" "__pow" "__shl" "__shr" "__sub" "__tostring" "__unm"))
-;; Others
-
+; Others
(comment) @comment @spell
((comment) @comment.documentation
@@ -237,13 +242,34 @@
((comment) @comment.documentation
(#lua-match? @comment.documentation "^[-][-](%s?)@"))
-(hash_bang_line) @preproc
+(hash_bang_line) @keyword.directive
(number) @number
-(string) @string @spell
+(string) @string
(escape_sequence) @string.escape
-;; Error
-(ERROR) @error
+; string.match("123", "%d+")
+(function_call
+ (dot_index_expression
+ field: (identifier) @_method
+ (#any-of? @_method "find" "match" "gmatch" "gsub"))
+ arguments:
+ (arguments
+ .
+ (_)
+ .
+ (string
+ content: (string_content) @string.regexp)))
+
+;("123"):match("%d+")
+(function_call
+ (method_index_expression
+ method: (identifier) @_method
+ (#any-of? @_method "find" "match" "gmatch" "gsub"))
+ arguments:
+ (arguments
+ .
+ (string
+ content: (string_content) @string.regexp)))
diff --git a/runtime/queries/lua/injections.scm b/runtime/queries/lua/injections.scm
index dbfe75ae31..c8a1843c84 100644
--- a/runtime/queries/lua/injections.scm
+++ b/runtime/queries/lua/injections.scm
@@ -1,35 +1,130 @@
((function_call
- name: [
- (identifier) @_cdef_identifier
- (_ _ (identifier) @_cdef_identifier)
- ]
+ name:
+ [
+ (identifier) @_cdef_identifier
+ (_
+ _
+ (identifier) @_cdef_identifier)
+ ]
arguments:
(arguments
- (string content: _ @injection.content)))
+ (string
+ content: _ @injection.content)))
(#set! injection.language "c")
(#eq? @_cdef_identifier "cdef"))
((function_call
name: (_) @_vimcmd_identifier
- arguments: (arguments (string content: _ @injection.content)))
+ arguments:
+ (arguments
+ (string
+ content: _ @injection.content)))
(#set! injection.language "vim")
(#any-of? @_vimcmd_identifier "vim.cmd" "vim.api.nvim_command" "vim.api.nvim_command" "vim.api.nvim_exec2"))
((function_call
name: (_) @_vimcmd_identifier
- arguments: (arguments (string content: _ @injection.content) .))
+ arguments:
+ (arguments
+ (string
+ content: _ @injection.content) .))
(#set! injection.language "query")
(#any-of? @_vimcmd_identifier "vim.treesitter.query.set" "vim.treesitter.query.parse"))
((function_call
name: (_) @_vimcmd_identifier
- arguments: (arguments . (_) . (string content: _ @_method) . (string content: _ @injection.content)))
+ arguments:
+ (arguments
+ .
+ (_)
+ .
+ (string
+ content: _ @_method)
+ .
+ (string
+ content: _ @injection.content)))
(#any-of? @_vimcmd_identifier "vim.rpcrequest" "vim.rpcnotify")
(#eq? @_method "nvim_exec_lua")
(#set! injection.language "lua"))
-;; highlight string as query if starts with `;; query`
-(string content: _ @injection.content
- (#lua-match? @injection.content "^%s*;+%s?query")
- (#set! injection.language "query"))
+; vim.api.nvim_create_autocmd("FileType", { command = "injected here" })
+(function_call
+ name: (_) @_vimcmd_identifier
+ arguments:
+ (arguments
+ .
+ (_)
+ .
+ (table_constructor
+ (field
+ name: (identifier) @_command
+ value:
+ (string
+ content: (_) @injection.content))) .)
+ ; limit so only 2-argument functions gets matched before pred handle
+ (#eq? @_vimcmd_identifier "vim.api.nvim_create_autocmd")
+ (#eq? @_command "command")
+ (#set! injection.language "vim"))
+
+(function_call
+ name: (_) @_user_cmd
+ arguments:
+ (arguments
+ .
+ (_)
+ .
+ (string
+ content: (_) @injection.content)
+ .
+ (_) .)
+ (#eq? @_user_cmd "vim.api.nvim_create_user_command")
+ (#set! injection.language "vim"))
+
+(function_call
+ name: (_) @_user_cmd
+ arguments:
+ (arguments
+ .
+ (_)
+ .
+ (_)
+ .
+ (string
+ content: (_) @injection.content)
+ .
+ (_) .)
+ ; Limiting predicate handling to only functions with 4 arguments
+ (#eq? @_user_cmd "vim.api.nvim_buf_create_user_command")
+ (#set! injection.language "vim"))
+; rhs highlighting for vim.keymap.set/vim.api.nvim_set_keymap/vim.api.nvim_buf_set_keymap
+; (function_call
+; name: (_) @_map
+; arguments:
+; (arguments
+; . (_)
+; . (_)
+; .
+; (string
+; content: (_) @injection.content))
+; (#any-of? @_map "vim.api.nvim_set_keymap" "vim.keymap.set")
+; (#set! injection.language "vim"))
+;
+; (function_call
+; name: (_) @_map
+; arguments:
+; (arguments
+; . (_)
+; . (_)
+; . (_)
+; .
+; (string
+; content: (_) @injection.content)
+; . (_) .)
+; (#eq? @_map "vim.api.nvim_buf_set_keymap")
+; (#set! injection.language "vim"))
+; highlight string as query if starts with `;; query`
+(string
+ content: _ @injection.content
+ (#lua-match? @injection.content "^%s*;+%s?query")
+ (#set! injection.language "query"))
diff --git a/runtime/queries/markdown/folds.scm b/runtime/queries/markdown/folds.scm
index 5900f7ffbe..a682e20e00 100644
--- a/runtime/queries/markdown/folds.scm
+++ b/runtime/queries/markdown/folds.scm
@@ -1,9 +1,7 @@
-(
- [
- (fenced_code_block)
- (indented_code_block)
- (list)
- (section)
- ] @fold
- (#trim! @fold)
-)
+([
+ (fenced_code_block)
+ (indented_code_block)
+ (list)
+ (section)
+] @fold
+ (#trim! @fold))
diff --git a/runtime/queries/markdown/highlights.scm b/runtime/queries/markdown/highlights.scm
index 2cc5546bac..7c26fd710c 100644
--- a/runtime/queries/markdown/highlights.scm
+++ b/runtime/queries/markdown/highlights.scm
@@ -1,40 +1,73 @@
;From MDeiml/tree-sitter-markdown & Helix
-(setext_heading (paragraph) @text.title.1 (setext_h1_underline) @text.title.1.marker)
-(setext_heading (paragraph) @text.title.2 (setext_h2_underline) @text.title.2.marker)
+(setext_heading
+ (paragraph) @markup.heading.1
+ (setext_h1_underline) @markup.heading.1.marker)
-(atx_heading (atx_h1_marker) @text.title.1.marker (inline) @text.title.1)
-(atx_heading (atx_h2_marker) @text.title.2.marker (inline) @text.title.2)
-(atx_heading (atx_h3_marker) @text.title.3.marker (inline) @text.title.3)
-(atx_heading (atx_h4_marker) @text.title.4.marker (inline) @text.title.4)
-(atx_heading (atx_h5_marker) @text.title.5.marker (inline) @text.title.5)
-(atx_heading (atx_h6_marker) @text.title.6.marker (inline) @text.title.6)
+(setext_heading
+ (paragraph) @markup.heading.2
+ (setext_h2_underline) @markup.heading.2.marker)
-(link_title) @text.literal
-(indented_code_block) @text.literal.block
-((fenced_code_block) @text.literal.block (#set! "priority" 90))
+(atx_heading
+ (atx_h1_marker) @markup.heading.1.marker
+ (inline) @markup.heading.1)
+
+(atx_heading
+ (atx_h2_marker) @markup.heading.2.marker
+ (inline) @markup.heading.2)
+
+(atx_heading
+ (atx_h3_marker) @markup.heading.3.marker
+ (inline) @markup.heading.3)
+
+(atx_heading
+ (atx_h4_marker) @markup.heading.4.marker
+ (inline) @markup.heading.4)
+
+(atx_heading
+ (atx_h5_marker) @markup.heading.5.marker
+ (inline) @markup.heading.5)
+
+(atx_heading
+ (atx_h6_marker) @markup.heading.6.marker
+ (inline) @markup.heading.6)
(info_string) @label
-(pipe_table_header (pipe_table_cell) @text.title)
+(pipe_table_header
+ (pipe_table_cell) @markup.heading)
+
+(pipe_table_header
+ "|" @punctuation.special)
+
+(pipe_table_row
+ "|" @punctuation.special)
+
+(pipe_table_delimiter_row
+ "|" @punctuation.special)
-(pipe_table_header "|" @punctuation.special)
-(pipe_table_row "|" @punctuation.special)
-(pipe_table_delimiter_row "|" @punctuation.special)
(pipe_table_delimiter_cell) @punctuation.special
-[
- (fenced_code_block_delimiter)
-] @punctuation.delimiter
+; Code blocks (conceal backticks and language annotation)
+(indented_code_block) @markup.raw.block
-(code_fence_content) @none
+((fenced_code_block) @markup.raw.block
+ (#set! "priority" 90))
-[
- (link_destination)
-] @text.uri
+(fenced_code_block
+ (fenced_code_block_delimiter) @markup.raw.delimiter
+ (#set! conceal ""))
+
+(fenced_code_block
+ (info_string
+ (language) @conceal
+ (#set! conceal "")))
+
+(link_destination) @markup.link.url
[
+ (link_title)
(link_label)
-] @text.reference
+] @markup.link.label
[
(list_marker_plus)
@@ -42,30 +75,43 @@
(list_marker_star)
(list_marker_dot)
(list_marker_parenthesis)
- (thematic_break)
-] @punctuation.special
-
-
-(task_list_marker_unchecked) @text.todo.unchecked
-(task_list_marker_checked) @text.todo.checked
-
-(block_quote) @text.quote
+] @markup.list
+
+; NOTE: The following has been commented out due to issues with spaces in the
+; list marker nodes generated by the parser. If those spaces ever get captured
+; by a different node (e.g. block_continuation) we can safely readd these
+; conceals.
+; ;; Conceal bullet points
+; ([(list_marker_plus) (list_marker_star)]
+; @punctuation.special
+; (#offset! @punctuation.special 0 0 0 -1)
+; (#set! conceal "•"))
+; ([(list_marker_plus) (list_marker_star)]
+; @punctuation.special
+; (#any-of? @punctuation.special "+" "*")
+; (#set! conceal "•"))
+; ((list_marker_minus)
+; @punctuation.special
+; (#offset! @punctuation.special 0 0 0 -1)
+; (#set! conceal "—"))
+; ((list_marker_minus)
+; @punctuation.special
+; (#eq? @punctuation.special "-")
+; (#set! conceal "—"))
+(thematic_break) @punctuation.special
+
+(task_list_marker_unchecked) @markup.list.unchecked
+
+(task_list_marker_checked) @markup.list.checked
+
+((block_quote) @markup.quote
+ (#set! "priority" 90))
[
(block_continuation)
(block_quote_marker)
] @punctuation.special
-[
- (backslash_escape)
-] @string.escape
+(backslash_escape) @string.escape
(inline) @spell
-
-;; Conceal backticks
-(fenced_code_block
- (fenced_code_block_delimiter) @conceal
- (#set! conceal ""))
-(fenced_code_block
- (info_string (language) @conceal
- (#set! conceal "")))
diff --git a/runtime/queries/markdown/injections.scm b/runtime/queries/markdown/injections.scm
index fda7036830..1f33c30b63 100644
--- a/runtime/queries/markdown/injections.scm
+++ b/runtime/queries/markdown/injections.scm
@@ -3,23 +3,23 @@
(language) @injection.language)
(code_fence_content) @injection.content)
-((html_block) @injection.content
- (#set! injection.language "html")
- (#set! injection.combined)
- (#set! injection.include-children))
+((html_block) @injection.content
+ (#set! injection.language "html")
+ (#set! injection.combined)
+ (#set! injection.include-children))
-((minus_metadata) @injection.content
- (#set! injection.language "yaml")
- (#offset! @injection.content 1 0 -1 0)
- (#set! injection.include-children))
+((minus_metadata) @injection.content
+ (#set! injection.language "yaml")
+ (#offset! @injection.content 1 0 -1 0)
+ (#set! injection.include-children))
-((plus_metadata) @injection.content
- (#set! injection.language "toml")
- (#offset! @injection.content 1 0 -1 0)
- (#set! injection.include-children))
+((plus_metadata) @injection.content
+ (#set! injection.language "toml")
+ (#offset! @injection.content 1 0 -1 0)
+ (#set! injection.include-children))
([
(inline)
(pipe_table_cell)
- ] @injection.content
- (#set! injection.language "markdown_inline"))
+] @injection.content
+ (#set! injection.language "markdown_inline"))
diff --git a/runtime/queries/markdown_inline/highlights.scm b/runtime/queries/markdown_inline/highlights.scm
index c75da478af..e9b41c31d5 100644
--- a/runtime/queries/markdown_inline/highlights.scm
+++ b/runtime/queries/markdown_inline/highlights.scm
@@ -1,49 +1,26 @@
-;; From MDeiml/tree-sitter-markdown
-[
- (code_span)
- (link_title)
-] @text.literal @nospell
-
-[
- (emphasis_delimiter)
- (code_span_delimiter)
-] @punctuation.delimiter
-
-(emphasis) @text.emphasis
+; From MDeiml/tree-sitter-markdown
+(code_span) @markup.raw @nospell
-(strong_emphasis) @text.strong
+(emphasis) @markup.italic
-(strikethrough) @text.strike
-
-[
- (link_destination)
- (uri_autolink)
-] @text.uri @nospell
+(strong_emphasis) @markup.strong
-(shortcut_link (link_text) @nospell)
+(strikethrough) @markup.strikethrough
-[
- (link_label)
- (link_text)
- (image_description)
-] @text.reference
+(shortcut_link
+ (link_text) @nospell)
[
(backslash_escape)
(hard_line_break)
] @string.escape
-(image "!" @punctuation.special)
-(image ["[" "]" "(" ")"] @punctuation.bracket)
-(inline_link ["[" "]" "(" ")"] @punctuation.bracket)
-(shortcut_link ["[" "]"] @punctuation.bracket)
-
; Conceal codeblock and text style markers
-([
- (code_span_delimiter)
- (emphasis_delimiter)
-] @conceal
-(#set! conceal ""))
+((code_span_delimiter) @markup.raw.delimiter
+ (#set! conceal ""))
+
+((emphasis_delimiter) @conceal
+ (#set! conceal ""))
; Conceal inline links
(inline_link
@@ -53,7 +30,7 @@
"("
(link_destination)
")"
- ] @conceal
+ ] @markup.link
(#set! conceal ""))
; Conceal image links
@@ -65,7 +42,7 @@
"("
(link_destination)
")"
- ] @conceal
+ ] @markup.link
(#set! conceal ""))
; Conceal full reference links
@@ -74,7 +51,7 @@
"["
"]"
(link_label)
- ] @conceal
+ ] @markup.link
(#set! conceal ""))
; Conceal collapsed reference links
@@ -82,7 +59,7 @@
[
"["
"]"
- ] @conceal
+ ] @markup.link
(#set! conceal ""))
; Conceal shortcut links
@@ -90,13 +67,42 @@
[
"["
"]"
- ] @conceal
+ ] @markup.link
(#set! conceal ""))
-;; Replace common HTML entities.
-((entity_reference) @conceal (#eq? @conceal "&nbsp;") (#set! conceal ""))
-((entity_reference) @conceal (#eq? @conceal "&lt;") (#set! conceal "<"))
-((entity_reference) @conceal (#eq? @conceal "&gt;") (#set! conceal ">"))
-((entity_reference) @conceal (#eq? @conceal "&amp;") (#set! conceal "&"))
-((entity_reference) @conceal (#eq? @conceal "&quot;") (#set! conceal "\""))
-((entity_reference) @conceal (#any-of? @conceal "&ensp;" "&emsp;") (#set! conceal " "))
+[
+ (link_destination)
+ (uri_autolink)
+] @markup.link.url @nospell
+
+[
+ (link_label)
+ (link_text)
+ (link_title)
+ (image_description)
+] @markup.link.label
+
+; Replace common HTML entities.
+((entity_reference) @character.special
+ (#eq? @character.special "&nbsp;")
+ (#set! conceal ""))
+
+((entity_reference) @character.special
+ (#eq? @character.special "&lt;")
+ (#set! conceal "<"))
+
+((entity_reference) @character.special
+ (#eq? @character.special "&gt;")
+ (#set! conceal ">"))
+
+((entity_reference) @character.special
+ (#eq? @character.special "&amp;")
+ (#set! conceal "&"))
+
+((entity_reference) @character.special
+ (#eq? @character.special "&quot;")
+ (#set! conceal "\""))
+
+((entity_reference) @character.special
+ (#any-of? @character.special "&ensp;" "&emsp;")
+ (#set! conceal " "))
diff --git a/runtime/queries/markdown_inline/injections.scm b/runtime/queries/markdown_inline/injections.scm
index f7aa19caff..6448b77c1b 100644
--- a/runtime/queries/markdown_inline/injections.scm
+++ b/runtime/queries/markdown_inline/injections.scm
@@ -1,8 +1,7 @@
((html_tag) @injection.content
- (#set! injection.language "html")
- (#set! injection.combined)
- (#set! injection.include-children))
+ (#set! injection.language "html")
+ (#set! injection.combined))
((latex_block) @injection.content
- (#set! injection.language "latex")
- (#set! injection.include-children))
+ (#set! injection.language "latex")
+ (#set! injection.include-children))
diff --git a/runtime/queries/python/folds.scm b/runtime/queries/python/folds.scm
index 78e1e2c00d..7c547db38f 100644
--- a/runtime/queries/python/folds.scm
+++ b/runtime/queries/python/folds.scm
@@ -1,28 +1,23 @@
[
(function_definition)
(class_definition)
-
(while_statement)
(for_statement)
(if_statement)
(with_statement)
(try_statement)
(match_statement)
-
(import_from_statement)
(parameters)
(argument_list)
-
(parenthesized_expression)
(generator_expression)
(list_comprehension)
(set_comprehension)
(dictionary_comprehension)
-
(tuple)
(list)
(set)
(dictionary)
-
(string)
] @fold
diff --git a/runtime/queries/python/highlights.scm b/runtime/queries/python/highlights.scm
index 04398668e9..764521c7be 100644
--- a/runtime/queries/python/highlights.scm
+++ b/runtime/queries/python/highlights.scm
@@ -1,183 +1,223 @@
-;; From tree-sitter-python licensed under MIT License
+; From tree-sitter-python licensed under MIT License
; Copyright (c) 2016 Max Brunsfeld
-
; Variables
(identifier) @variable
; Reset highlighting in f-string interpolations
(interpolation) @none
-;; Identifier naming conventions
+; Identifier naming conventions
((identifier) @type
- (#lua-match? @type "^[A-Z].*[a-z]"))
+ (#lua-match? @type "^[A-Z].*[a-z]"))
+
((identifier) @constant
- (#lua-match? @constant "^[A-Z][A-Z_0-9]*$"))
+ (#lua-match? @constant "^[A-Z][A-Z_0-9]*$"))
((identifier) @constant.builtin
- (#lua-match? @constant.builtin "^__[a-zA-Z0-9_]*__$"))
+ (#lua-match? @constant.builtin "^__[a-zA-Z0-9_]*__$"))
((identifier) @constant.builtin
- (#any-of? @constant.builtin
- ;; https://docs.python.org/3/library/constants.html
- "NotImplemented"
- "Ellipsis"
- "quit"
- "exit"
- "copyright"
- "credits"
- "license"))
+ ; format-ignore
+ (#any-of? @constant.builtin
+ ; https://docs.python.org/3/library/constants.html
+ "NotImplemented" "Ellipsis"
+ "quit" "exit" "copyright" "credits" "license"))
"_" @constant.builtin ; match wildcard
((attribute
- attribute: (identifier) @field)
- (#lua-match? @field "^[%l_].*$"))
+ attribute: (identifier) @variable.member)
+ (#lua-match? @variable.member "^[%l_].*$"))
((assignment
left: (identifier) @type.definition
- (type (identifier) @_annotation))
- (#eq? @_annotation "TypeAlias"))
+ (type
+ (identifier) @_annotation))
+ (#eq? @_annotation "TypeAlias"))
((assignment
left: (identifier) @type.definition
- right: (call
- function: (identifier) @_func))
- (#any-of? @_func "TypeVar" "NewType"))
+ right:
+ (call
+ function: (identifier) @_func))
+ (#any-of? @_func "TypeVar" "NewType"))
; Function calls
-
(call
function: (identifier) @function.call)
(call
- function: (attribute
- attribute: (identifier) @method.call))
+ function:
+ (attribute
+ attribute: (identifier) @function.method.call))
((call
- function: (identifier) @constructor)
- (#lua-match? @constructor "^%u"))
+ function: (identifier) @constructor)
+ (#lua-match? @constructor "^%u"))
((call
- function: (attribute
- attribute: (identifier) @constructor))
- (#lua-match? @constructor "^%u"))
-
-;; Decorators
+ function:
+ (attribute
+ attribute: (identifier) @constructor))
+ (#lua-match? @constructor "^%u"))
-((decorator "@" @attribute)
- (#set! "priority" 101))
+; Decorators
+((decorator
+ "@" @attribute)
+ (#set! "priority" 101))
(decorator
(identifier) @attribute)
+
(decorator
(attribute
attribute: (identifier) @attribute))
+
(decorator
- (call (identifier) @attribute))
+ (call
+ (identifier) @attribute))
+
(decorator
- (call (attribute
- attribute: (identifier) @attribute)))
+ (call
+ (attribute
+ attribute: (identifier) @attribute)))
((decorator
(identifier) @attribute.builtin)
- (#any-of? @attribute.builtin "classmethod" "property"))
-
-;; Builtin functions
+ (#any-of? @attribute.builtin "classmethod" "property"))
+; Builtin functions
((call
function: (identifier) @function.builtin)
- (#any-of? @function.builtin
- "abs" "all" "any" "ascii" "bin" "bool" "breakpoint" "bytearray" "bytes" "callable" "chr" "classmethod"
- "compile" "complex" "delattr" "dict" "dir" "divmod" "enumerate" "eval" "exec" "filter" "float" "format"
- "frozenset" "getattr" "globals" "hasattr" "hash" "help" "hex" "id" "input" "int" "isinstance" "issubclass"
- "iter" "len" "list" "locals" "map" "max" "memoryview" "min" "next" "object" "oct" "open" "ord" "pow"
- "print" "property" "range" "repr" "reversed" "round" "set" "setattr" "slice" "sorted" "staticmethod" "str"
- "sum" "super" "tuple" "type" "vars" "zip" "__import__"))
-
-;; Function definitions
+ (#any-of? @function.builtin "abs" "all" "any" "ascii" "bin" "bool" "breakpoint" "bytearray" "bytes" "callable" "chr" "classmethod" "compile" "complex" "delattr" "dict" "dir" "divmod" "enumerate" "eval" "exec" "filter" "float" "format" "frozenset" "getattr" "globals" "hasattr" "hash" "help" "hex" "id" "input" "int" "isinstance" "issubclass" "iter" "len" "list" "locals" "map" "max" "memoryview" "min" "next" "object" "oct" "open" "ord" "pow" "print" "property" "range" "repr" "reversed" "round" "set" "setattr" "slice" "sorted" "staticmethod" "str" "sum" "super" "tuple" "type" "vars" "zip" "__import__"))
+; Function definitions
(function_definition
name: (identifier) @function)
-(type (identifier) @type)
+(type
+ (identifier) @type)
+
(type
(subscript
(identifier) @type)) ; type subscript: Tuple[int]
((call
function: (identifier) @_isinstance
- arguments: (argument_list
- (_)
- (identifier) @type))
- (#eq? @_isinstance "isinstance"))
+ arguments:
+ (argument_list
+ (_)
+ (identifier) @type))
+ (#eq? @_isinstance "isinstance"))
-;; Normal parameters
+; Normal parameters
(parameters
- (identifier) @parameter)
-;; Lambda parameters
+ (identifier) @variable.parameter)
+
+; Lambda parameters
(lambda_parameters
- (identifier) @parameter)
+ (identifier) @variable.parameter)
+
(lambda_parameters
(tuple_pattern
- (identifier) @parameter))
+ (identifier) @variable.parameter))
+
; Default parameters
(keyword_argument
- name: (identifier) @parameter)
+ name: (identifier) @variable.parameter)
+
; Naming parameters on call-site
(default_parameter
- name: (identifier) @parameter)
+ name: (identifier) @variable.parameter)
+
(typed_parameter
- (identifier) @parameter)
+ (identifier) @variable.parameter)
+
(typed_default_parameter
- (identifier) @parameter)
+ name: (identifier) @variable.parameter)
+
; Variadic parameters *args, **kwargs
(parameters
(list_splat_pattern ; *args
- (identifier) @parameter))
+ (identifier) @variable.parameter))
+
(parameters
(dictionary_splat_pattern ; **kwargs
- (identifier) @parameter))
+ (identifier) @variable.parameter))
+; Typed variadic parameters
+(parameters
+ (typed_parameter
+ (list_splat_pattern ; *args: type
+ (identifier) @variable.parameter)))
-;; Literals
+(parameters
+ (typed_parameter
+ (dictionary_splat_pattern ; *kwargs: type
+ (identifier) @variable.parameter)))
+
+; Lambda parameters
+(lambda_parameters
+ (list_splat_pattern
+ (identifier) @variable.parameter))
+(lambda_parameters
+ (dictionary_splat_pattern
+ (identifier) @variable.parameter))
+
+; Literals
(none) @constant.builtin
-[(true) (false)] @boolean
+
+[
+ (true)
+ (false)
+] @boolean
+
((identifier) @variable.builtin
- (#eq? @variable.builtin "self"))
+ (#eq? @variable.builtin "self"))
+
((identifier) @variable.builtin
- (#eq? @variable.builtin "cls"))
+ (#eq? @variable.builtin "cls"))
(integer) @number
-(float) @float
+
+(float) @number.float
(comment) @comment @spell
-((module . (comment) @preproc)
- (#lua-match? @preproc "^#!/"))
+((module
+ .
+ (comment) @keyword.directive)
+ (#lua-match? @keyword.directive "^#!/"))
(string) @string
+
[
(escape_sequence)
(escape_interpolation)
] @string.escape
; doc-strings
-
-(module . (expression_statement (string) @string.documentation @spell))
+(module
+ .
+ (expression_statement
+ (string) @string.documentation @spell))
(class_definition
body:
(block
- . (expression_statement (string) @string.documentation @spell)))
+ .
+ (expression_statement
+ (string) @string.documentation @spell)))
(function_definition
body:
(block
- . (expression_statement (string) @string.documentation @spell)))
+ .
+ (expression_statement
+ (string) @string.documentation @spell)))
; Tokens
-
[
"-"
"-="
@@ -227,7 +267,6 @@
"or"
"is not"
"not in"
-
"del"
] @keyword.operator
@@ -258,19 +297,36 @@
"return"
"yield"
] @keyword.return
-(yield "from" @keyword.return)
+
+(yield
+ "from" @keyword.return)
(future_import_statement
- "from" @include
+ "from" @keyword.import
"__future__" @constant.builtin)
-(import_from_statement "from" @include)
-"import" @include
-(aliased_import "as" @include)
+(import_from_statement
+ "from" @keyword.import)
+
+"import" @keyword.import
-["if" "elif" "else" "match" "case"] @conditional
+(aliased_import
+ "as" @keyword.import)
-["for" "while" "break" "continue"] @repeat
+[
+ "if"
+ "elif"
+ "else"
+ "match"
+ "case"
+] @keyword.conditional
+
+[
+ "for"
+ "while"
+ "break"
+ "continue"
+] @keyword.repeat
[
"try"
@@ -278,15 +334,23 @@
"except*"
"raise"
"finally"
-] @exception
+] @keyword.exception
-(raise_statement "from" @exception)
+(raise_statement
+ "from" @keyword.exception)
(try_statement
(else_clause
- "else" @exception))
+ "else" @keyword.exception))
-["(" ")" "[" "]" "{" "}"] @punctuation.bracket
+[
+ "("
+ ")"
+ "["
+ "]"
+ "{"
+ "}"
+] @punctuation.bracket
(interpolation
"{" @punctuation.special
@@ -294,58 +358,80 @@
(type_conversion) @function.macro
-["," "." ":" ";" (ellipsis)] @punctuation.delimiter
-
-;; Class definitions
-
-(class_definition name: (identifier) @type)
+[
+ ","
+ "."
+ ":"
+ ";"
+ (ellipsis)
+] @punctuation.delimiter
+
+; Class definitions
+(class_definition
+ name: (identifier) @type)
(class_definition
- body: (block
- (function_definition
- name: (identifier) @method)))
+ body:
+ (block
+ (function_definition
+ name: (identifier) @function.method)))
(class_definition
- superclasses: (argument_list
- (identifier) @type))
+ superclasses:
+ (argument_list
+ (identifier) @type))
((class_definition
- body: (block
- (expression_statement
- (assignment
- left: (identifier) @field))))
- (#lua-match? @field "^%l.*$"))
+ body:
+ (block
+ (expression_statement
+ (assignment
+ left: (identifier) @variable.member))))
+ (#lua-match? @variable.member "^%l.*$"))
+
((class_definition
- body: (block
- (expression_statement
- (assignment
- left: (_
- (identifier) @field)))))
- (#lua-match? @field "^%l.*$"))
+ body:
+ (block
+ (expression_statement
+ (assignment
+ left:
+ (_
+ (identifier) @variable.member)))))
+ (#lua-match? @variable.member "^%l.*$"))
((class_definition
(block
(function_definition
name: (identifier) @constructor)))
- (#any-of? @constructor "__new__" "__init__"))
+ (#any-of? @constructor "__new__" "__init__"))
((identifier) @type.builtin
- (#any-of? @type.builtin
- ;; https://docs.python.org/3/library/exceptions.html
- "BaseException" "Exception" "ArithmeticError" "BufferError" "LookupError" "AssertionError" "AttributeError"
- "EOFError" "FloatingPointError" "GeneratorExit" "ImportError" "ModuleNotFoundError" "IndexError" "KeyError"
- "KeyboardInterrupt" "MemoryError" "NameError" "NotImplementedError" "OSError" "OverflowError" "RecursionError"
- "ReferenceError" "RuntimeError" "StopIteration" "StopAsyncIteration" "SyntaxError" "IndentationError" "TabError"
- "SystemError" "SystemExit" "TypeError" "UnboundLocalError" "UnicodeError" "UnicodeEncodeError" "UnicodeDecodeError"
- "UnicodeTranslateError" "ValueError" "ZeroDivisionError" "EnvironmentError" "IOError" "WindowsError"
- "BlockingIOError" "ChildProcessError" "ConnectionError" "BrokenPipeError" "ConnectionAbortedError"
- "ConnectionRefusedError" "ConnectionResetError" "FileExistsError" "FileNotFoundError" "InterruptedError"
- "IsADirectoryError" "NotADirectoryError" "PermissionError" "ProcessLookupError" "TimeoutError" "Warning"
- "UserWarning" "DeprecationWarning" "PendingDeprecationWarning" "SyntaxWarning" "RuntimeWarning"
- "FutureWarning" "ImportWarning" "UnicodeWarning" "BytesWarning" "ResourceWarning"
- ;; https://docs.python.org/3/library/stdtypes.html
- "bool" "int" "float" "complex" "list" "tuple" "range" "str"
- "bytes" "bytearray" "memoryview" "set" "frozenset" "dict" "type" "object"))
-
-;; Error
-(ERROR) @error
+ ; format-ignore
+ (#any-of? @type.builtin
+ ; https://docs.python.org/3/library/exceptions.html
+ "BaseException" "Exception" "ArithmeticError" "BufferError" "LookupError" "AssertionError" "AttributeError"
+ "EOFError" "FloatingPointError" "GeneratorExit" "ImportError" "ModuleNotFoundError" "IndexError" "KeyError"
+ "KeyboardInterrupt" "MemoryError" "NameError" "NotImplementedError" "OSError" "OverflowError" "RecursionError"
+ "ReferenceError" "RuntimeError" "StopIteration" "StopAsyncIteration" "SyntaxError" "IndentationError" "TabError"
+ "SystemError" "SystemExit" "TypeError" "UnboundLocalError" "UnicodeError" "UnicodeEncodeError" "UnicodeDecodeError"
+ "UnicodeTranslateError" "ValueError" "ZeroDivisionError" "EnvironmentError" "IOError" "WindowsError"
+ "BlockingIOError" "ChildProcessError" "ConnectionError" "BrokenPipeError" "ConnectionAbortedError"
+ "ConnectionRefusedError" "ConnectionResetError" "FileExistsError" "FileNotFoundError" "InterruptedError"
+ "IsADirectoryError" "NotADirectoryError" "PermissionError" "ProcessLookupError" "TimeoutError" "Warning"
+ "UserWarning" "DeprecationWarning" "PendingDeprecationWarning" "SyntaxWarning" "RuntimeWarning"
+ "FutureWarning" "ImportWarning" "UnicodeWarning" "BytesWarning" "ResourceWarning"
+ ; https://docs.python.org/3/library/stdtypes.html
+ "bool" "int" "float" "complex" "list" "tuple" "range" "str"
+ "bytes" "bytearray" "memoryview" "set" "frozenset" "dict" "type" "object"))
+
+; Regex from the `re` module
+(call
+ function:
+ (attribute
+ object: (identifier) @_re)
+ arguments:
+ (argument_list
+ .
+ (string
+ (string_content) @string.regexp))
+ (#eq? @_re "re"))
diff --git a/runtime/queries/query/highlights.scm b/runtime/queries/query/highlights.scm
index f2d2ef6c7f..cdedb23e29 100644
--- a/runtime/queries/query/highlights.scm
+++ b/runtime/queries/query/highlights.scm
@@ -1,14 +1,30 @@
(string) @string
+
(escape_sequence) @string.escape
-(capture (identifier) @type)
-(anonymous_node (identifier) @string)
-(predicate name: (identifier) @function)
-(named_node name: (identifier) @variable)
-(field_definition name: (identifier) @property)
-(negated_field "!" @operator (identifier) @property)
+
+(capture
+ (identifier) @type)
+
+(anonymous_node
+ (identifier) @string)
+
+(predicate
+ name: (identifier) @function.call)
+
+(named_node
+ name: (identifier) @variable)
+
+(field_definition
+ name: (identifier) @property)
+
+(negated_field
+ "!" @operator
+ (identifier) @property)
+
(comment) @comment @spell
(quantifier) @operator
+
(predicate_type) @punctuation.special
"." @operator
@@ -21,14 +37,51 @@
] @punctuation.bracket
":" @punctuation.delimiter
-["@" "#"] @punctuation.special
+
+[
+ "@"
+ "#"
+] @punctuation.special
+
"_" @constant
-((parameters (identifier) @number)
- (#match? @number "^[-+]?[0-9]+(.[0-9]+)?$"))
+((parameters
+ (identifier) @number)
+ (#match? @number "^[-+]?[0-9]+(.[0-9]+)?$"))
+
+((program
+ .
+ (comment)*
+ .
+ (comment) @keyword.import)
+ (#lua-match? @keyword.import "^;+ *inherits *:"))
+
+((program
+ .
+ (comment)*
+ .
+ (comment) @keyword.directive)
+ (#lua-match? @keyword.directive "^;+ *extends *$"))
+
+((comment) @keyword.directive
+ (#lua-match? @keyword.directive "^;+%s*format%-ignore%s*$"))
-((program . (comment)* . (comment) @include)
- (#lua-match? @include "^;+ *inherits *:"))
+((predicate
+ name: (identifier) @_name
+ parameters:
+ (parameters
+ (string
+ "\"" @string
+ "\"" @string) @string.regexp))
+ (#any-of? @_name "match" "not-match" "vim-match" "not-vim-match" "lua-match" "not-lua-match"))
-((program . (comment)* . (comment) @preproc)
- (#lua-match? @preproc "^;+ *extends"))
+((predicate
+ name: (identifier) @_name
+ parameters:
+ (parameters
+ (string
+ "\"" @string
+ "\"" @string) @string.regexp
+ .
+ (string) .))
+ (#any-of? @_name "gsub" "not-gsub"))
diff --git a/runtime/queries/vim/folds.scm b/runtime/queries/vim/folds.scm
index 4c99735836..0a1fb695f3 100644
--- a/runtime/queries/vim/folds.scm
+++ b/runtime/queries/vim/folds.scm
@@ -1,4 +1,4 @@
[
- (if_statement)
- (function_definition)
+ (if_statement)
+ (function_definition)
] @fold
diff --git a/runtime/queries/vim/highlights.scm b/runtime/queries/vim/highlights.scm
index 09188ddb68..54832ffa56 100644
--- a/runtime/queries/vim/highlights.scm
+++ b/runtime/queries/vim/highlights.scm
@@ -1,15 +1,15 @@
(identifier) @variable
-((identifier) @constant
- (#lua-match? @constant "^[A-Z][A-Z_0-9]*$"))
-;; Keywords
+((identifier) @constant
+ (#lua-match? @constant "^[A-Z][A-Z_0-9]*$"))
+; Keywords
[
"if"
"else"
"elseif"
"endif"
-] @conditional
+] @keyword.conditional
[
"try"
@@ -17,7 +17,7 @@
"finally"
"endtry"
"throw"
-] @exception
+] @keyword.exception
[
"for"
@@ -27,31 +27,50 @@
"endwhile"
"break"
"continue"
-] @repeat
+] @keyword.repeat
[
"function"
"endfunction"
] @keyword.function
-;; Function related
-(function_declaration name: (_) @function)
-(call_expression function: (identifier) @function.call)
-(call_expression function: (scoped_identifier (identifier) @function.call))
-(parameters (identifier) @parameter)
-(default_parameter (identifier) @parameter)
+; Function related
+(function_declaration
+ name: (_) @function)
+
+(call_expression
+ function: (identifier) @function.call)
+
+(call_expression
+ function:
+ (scoped_identifier
+ (identifier) @function.call))
-[ (bang) (spread) ] @punctuation.special
+(parameters
+ (identifier) @variable.parameter)
+
+(default_parameter
+ (identifier) @variable.parameter)
+
+[
+ (bang)
+ (spread)
+] @punctuation.special
+
+[
+ (no_option)
+ (inv_option)
+ (default_option)
+ (option_name)
+] @variable.builtin
-[ (no_option) (inv_option) (default_option) (option_name) ] @variable.builtin
[
(scope)
"a:"
"$"
-] @namespace
-
-;; Commands and user defined commands
+] @module
+; Commands and user defined commands
[
"let"
"unlet"
@@ -83,6 +102,7 @@
"delcommand"
"comclear"
"colorscheme"
+ "scriptencoding"
"startinsert"
"stopinsert"
"global"
@@ -106,41 +126,48 @@
"visual"
"view"
"eval"
+ "sign"
] @keyword
-(map_statement cmd: _ @keyword)
+
+(map_statement
+ cmd: _ @keyword)
+
(command_name) @function.macro
-;; Filetype command
-
-(filetype_statement [
- "detect"
- "plugin"
- "indent"
- "on"
- "off"
-] @keyword)
-
-;; Syntax command
-
-(syntax_statement (keyword) @string)
-(syntax_statement [
- "enable"
- "on"
- "off"
- "reset"
- "case"
- "spell"
- "foldlevel"
- "iskeyword"
- "keyword"
- "match"
- "cluster"
- "region"
- "clear"
- "include"
-] @keyword)
-
-(syntax_argument name: _ @keyword)
+; Filetype command
+(filetype_statement
+ [
+ "detect"
+ "plugin"
+ "indent"
+ "on"
+ "off"
+ ] @keyword)
+
+; Syntax command
+(syntax_statement
+ (keyword) @string)
+
+(syntax_statement
+ [
+ "enable"
+ "on"
+ "off"
+ "reset"
+ "case"
+ "spell"
+ "foldlevel"
+ "iskeyword"
+ "keyword"
+ "match"
+ "cluster"
+ "region"
+ "clear"
+ "include"
+ ] @keyword)
+
+(syntax_argument
+ name: _ @keyword)
[
"<buffer>"
@@ -151,70 +178,96 @@
"<unique>"
] @constant.builtin
-(augroup_name) @namespace
+(augroup_name) @module
(au_event) @constant
-(normal_statement (commands) @constant)
-;; Highlight command
+(normal_statement
+ (commands) @constant)
+; Highlight command
(hl_attribute
key: _ @property
val: _ @constant)
(hl_group) @type
-(highlight_statement [
- "default"
- "link"
- "clear"
-] @keyword)
-
-;; Command command
+(highlight_statement
+ [
+ "default"
+ "link"
+ "clear"
+ ] @keyword)
+; Command command
(command) @string
(command_attribute
name: _ @property
- val: (behavior
- name: _ @constant
- val: (identifier)? @function)?)
+ val:
+ (behavior
+ name: _ @constant
+ val: (identifier)? @function)?)
-;; Edit command
+; Edit command
(plus_plus_opt
val: _? @constant) @property
-(plus_cmd "+" @property) @property
-
-;; Runtime command
-(runtime_statement (where) @keyword.operator)
+(plus_cmd
+ "+" @property) @property
-;; Colorscheme command
+; Runtime command
+(runtime_statement
+ (where) @keyword.operator)
-(colorscheme_statement (name) @string)
+; Colorscheme command
+(colorscheme_statement
+ (name) @string)
-;; Literals
+; Scriptencoding command
+(scriptencoding_statement
+ (encoding) @string.special)
+; Literals
(string_literal) @string
+
(integer_literal) @number
-(float_literal) @float
+
+(float_literal) @number.float
+
(comment) @comment @spell
+
(line_continuation_comment) @comment @spell
+
(pattern) @string.special
-(pattern_multi) @string.regex
-(filename) @string
-(heredoc (body) @string)
-(heredoc (parameter) @keyword)
-[ (marker_definition) (endmarker) ] @label
-(literal_dictionary (literal_key) @label)
-((scoped_identifier
- (scope) @_scope . (identifier) @boolean)
- (#eq? @_scope "v:")
- (#any-of? @boolean "true" "false"))
-;; Operators
+(pattern_multi) @string.regexp
+
+(filename) @string.special.path
+
+(heredoc
+ (body) @string)
+
+(heredoc
+ (parameter) @keyword)
[
+ (marker_definition)
+ (endmarker)
+] @label
+
+(literal_dictionary
+ (literal_key) @property)
+
+((scoped_identifier
+ (scope) @_scope
+ .
+ (identifier) @boolean)
+ (#eq? @_scope "v:")
+ (#any-of? @boolean "true" "false"))
+
+; Operators
+[
"||"
"&&"
"&"
@@ -248,12 +301,13 @@
] @operator
; Some characters have different meanings based on the context
-(unary_operation "!" @operator)
-(binary_operation "." @operator)
-
+(unary_operation
+ "!" @operator)
-;; Punctuation
+(binary_operation
+ "." @operator)
+; Punctuation
[
"("
")"
@@ -264,27 +318,31 @@
"#{"
] @punctuation.bracket
-(field_expression "." @punctuation.delimiter)
+(field_expression
+ "." @punctuation.delimiter)
[
","
":"
] @punctuation.delimiter
-(ternary_expression ["?" ":"] @conditional.ternary)
+(ternary_expression
+ [
+ "?"
+ ":"
+ ] @keyword.conditional.ternary)
; Options
((set_value) @number
- (#lua-match? @number "^[%d]+(%.[%d]+)?$"))
+ (#lua-match? @number "^[%d]+(%.[%d]+)?$"))
+
+(inv_option
+ "!" @operator)
-(inv_option "!" @operator)
-(set_item "?" @operator)
+(set_item
+ "?" @operator)
((set_item
- option: (option_name) @_option
- value: (set_value) @function)
- (#any-of? @_option
- "tagfunc" "tfu"
- "completefunc" "cfu"
- "omnifunc" "ofu"
- "operatorfunc" "opfunc"))
+ option: (option_name) @_option
+ value: (set_value) @function)
+ (#any-of? @_option "tagfunc" "tfu" "completefunc" "cfu" "omnifunc" "ofu" "operatorfunc" "opfunc"))
diff --git a/runtime/queries/vim/injections.scm b/runtime/queries/vim/injections.scm
index 50f0190112..16ec57ca99 100644
--- a/runtime/queries/vim/injections.scm
+++ b/runtime/queries/vim/injections.scm
@@ -1,48 +1,32 @@
-((lua_statement (script (body) @injection.content))
- (#set! injection.language "lua"))
+(lua_statement
+ (script
+ (body) @injection.content
+ (#set! injection.language "lua")))
-((lua_statement (chunk) @injection.content)
- (#set! injection.language "lua"))
+(lua_statement
+ (chunk) @injection.content
+ (#set! injection.language "lua"))
-((ruby_statement (script (body) @injection.content))
- (#set! injection.language "ruby"))
+(ruby_statement
+ (script
+ (body) @injection.content
+ (#set! injection.language "ruby")))
-((ruby_statement (chunk) @injection.content)
- (#set! injection.language "ruby"))
+(ruby_statement
+ (chunk) @injection.content
+ (#set! injection.language "ruby"))
-((python_statement (script (body) @injection.content))
- (#set! injection.language "python"))
+(python_statement
+ (script
+ (body) @injection.content
+ (#set! injection.language "python")))
-((python_statement (chunk) @injection.content)
- (#set! injection.language "python"))
-
-;; If we support perl at some point...
-;; ((perl_statement (script (body) @injection.content))
-;; (#set! injection.language "perl"))
-;; ((perl_statement (chunk) @injection.content)
-;; (#set! injection.language "perl"))
-
-((autocmd_statement (pattern) @injection.content)
- (#set! injection.language "regex"))
+(python_statement
+ (chunk) @injection.content
+ (#set! injection.language "python"))
((set_item
- option: (option_name) @_option
- value: (set_value) @injection.content)
- (#any-of? @_option
- "includeexpr" "inex"
- "printexpr" "pexpr"
- "formatexpr" "fex"
- "indentexpr" "inde"
- "foldtext" "fdt"
- "foldexpr" "fde"
- "diffexpr" "dex"
- "patchexpr" "pex"
- "charconvert" "ccv")
+ option: (option_name) @_option
+ value: (set_value) @injection.content)
+ (#any-of? @_option "includeexpr" "inex" "printexpr" "pexpr" "formatexpr" "fex" "indentexpr" "inde" "foldtext" "fdt" "foldexpr" "fde" "diffexpr" "dex" "patchexpr" "pex" "charconvert" "ccv")
(#set! injection.language "vim"))
-
-
-; ((comment) @injection.content
-; (#set! injection.language "comment"))
-
-; ((line_continuation_comment) @injection.content
-; (#set! injection.language "comment"))
diff --git a/runtime/queries/vimdoc/highlights.scm b/runtime/queries/vimdoc/highlights.scm
index e0dce49b2a..294fa94f10 100644
--- a/runtime/queries/vimdoc/highlights.scm
+++ b/runtime/queries/vimdoc/highlights.scm
@@ -1,25 +1,58 @@
-(h1) @text.title.1
-(h2) @text.title.2
-(h3) @text.title.3
-(column_heading) @text.title.4
+(h1) @markup.heading.1
+
+(h2) @markup.heading.2
+
+(h3) @markup.heading.3
+
+(column_heading) @markup.heading.4
+
(column_heading
- "~" @conceal (#set! conceal ""))
+ "~" @markup.heading.4.marker
+ (#set! conceal ""))
+
(tag
- "*" @conceal (#set! conceal "")
- text: (_) @label)
+ "*" @markup.heading.5.marker
+ (#set! conceal "")
+ text: (_) @label)
+
(taglink
- "|" @conceal (#set! conceal "")
- text: (_) @text.reference)
+ "|" @markup.link
+ (#set! conceal "")
+ text: (_) @markup.link)
+
(optionlink
- text: (_) @text.reference)
+ text: (_) @markup.link)
+
(codespan
- "`" @conceal (#set! conceal "")
- text: (_) @text.literal)
-(codeblock) @text.literal
+ "`" @markup.raw.delimiter
+ (#set! conceal "")
+ text: (_) @markup.raw)
+
+((codeblock) @markup.raw.block
+ (#set! "priority" 90))
+
(codeblock
- [">" (language)] @conceal (#set! conceal ""))
+ [
+ ">"
+ (language)
+ ] @markup.raw.delimiter
+ (#set! conceal ""))
+
(block
- "<" @conceal (#set! conceal ""))
-(argument) @parameter
+ "<" @markup.raw.delimiter
+ (#set! conceal ""))
+
+(argument) @variable.parameter
+
(keycode) @string.special
-(url) @text.uri
+
+(url) @string.special.url
+
+((note) @comment.note
+ (#any-of? @comment.note "Note:" "NOTE:" "Notes:"))
+
+((note) @comment.warning
+ (#any-of? @comment.warning "Warning:" "WARNING:"))
+
+((note) @comment.error
+ (#any-of? @comment.error "Deprecated:" "DEPRECATED:"))
diff --git a/runtime/queries/vimdoc/injections.scm b/runtime/queries/vimdoc/injections.scm
index 260a05d863..3b8fbf0f36 100644
--- a/runtime/queries/vimdoc/injections.scm
+++ b/runtime/queries/vimdoc/injections.scm
@@ -1,4 +1,4 @@
((codeblock
(language) @injection.language
(code) @injection.content)
- (#set! injection.include-children))
+ (#set! injection.include-children))