mirror of
https://github.com/neovim/neovim.git
synced 2026-08-27 09:31:47 +00:00
feat(treesitter/extmark): support removing a conceal highlight #35087
Problem: Cannot remove a `@conceal` highlight when defined in highlights.scm. Solution: Support a `@noconceal` highlight that works similarly to `@nospell` where it overrides the conceal set on the range to remove it. Additionally, can set the conceal metadata field to false for the same behavior.
This commit is contained in:
13
runtime/lua/vim/_meta/api.gen.lua
generated
13
runtime/lua/vim/_meta/api.gen.lua
generated
@@ -702,11 +702,14 @@ function vim.api.nvim_buf_line_count(buf) end
|
||||
--- - cursorline_hl_group: highlight group used for the sign
|
||||
--- column text when the cursor is on the same line as the
|
||||
--- mark and 'cursorline' is enabled.
|
||||
--- - conceal: string which should be either empty or a single
|
||||
--- character. Enable concealing similar to `:syn-conceal`.
|
||||
--- When a character is supplied it is used as `:syn-cchar`.
|
||||
--- "hl_group" is used as highlight for the cchar if provided,
|
||||
--- otherwise it defaults to `hl-Conceal`.
|
||||
--- - conceal: either a boolean or a string.
|
||||
--- - when a string is given, it should be either empty or a single
|
||||
--- character. Enable concealing similar to `:syn-conceal`.
|
||||
--- When a character is supplied it is used as `:syn-cchar`.
|
||||
--- "hl_group" is used as highlight for the cchar if provided,
|
||||
--- otherwise it defaults to `hl-Conceal`.
|
||||
--- - when a boolean is given, true is equivalent to "" and false
|
||||
--- overrides any existing conceal to remove it.
|
||||
--- - conceal_lines: string which should be empty. When
|
||||
--- provided, lines in the range are not drawn at all
|
||||
--- (according to 'conceallevel'); the next unconcealed line
|
||||
|
||||
2
runtime/lua/vim/_meta/api_keysets.gen.lua
generated
2
runtime/lua/vim/_meta/api_keysets.gen.lua
generated
@@ -437,7 +437,7 @@ error('Cannot require a meta file')
|
||||
--- @field number_hl_group? integer|string
|
||||
--- @field line_hl_group? integer|string
|
||||
--- @field cursorline_hl_group? integer|string
|
||||
--- @field conceal? string
|
||||
--- @field conceal? string|boolean
|
||||
--- @field conceal_lines? string
|
||||
--- @field spell? boolean
|
||||
--- @field ui_watched? boolean
|
||||
|
||||
@@ -22,7 +22,7 @@ error('Cannot require a meta file')
|
||||
--- @field hl_group? string
|
||||
--- @field hl_eol? boolean
|
||||
---
|
||||
--- @field conceal? string
|
||||
--- @field conceal? string|false
|
||||
--- @field spell? boolean
|
||||
--- @field ui_watched? boolean
|
||||
--- @field url? string
|
||||
|
||||
@@ -427,14 +427,29 @@ local function on_range_impl(
|
||||
|
||||
local spell, spell_pri_offset = get_spell(capture_name)
|
||||
|
||||
local is_noconceal = capture_name == 'noconceal'
|
||||
-- The "conceal" attribute can be set at the pattern level or on a particular capture
|
||||
local conceal_attr = (metadata.conceal ~= nil and metadata.conceal)
|
||||
or (metadata[capture] and metadata[capture].conceal)
|
||||
local conceal ---@type boolean|string?
|
||||
if is_noconceal then
|
||||
conceal = false
|
||||
else
|
||||
conceal = conceal_attr
|
||||
if conceal_attr == false then
|
||||
is_noconceal = true
|
||||
end
|
||||
end
|
||||
is_noconceal = is_noconceal or conceal_attr == false
|
||||
local conceal_pri_offset = is_noconceal and 1 or 0
|
||||
|
||||
-- The "priority" attribute can be set at the pattern level or on a particular capture
|
||||
local priority = (
|
||||
vim._tointeger(metadata.priority or metadata[capture] and metadata[capture].priority)
|
||||
or vim.hl.priorities.treesitter
|
||||
) + spell_pri_offset
|
||||
|
||||
-- The "conceal" attribute can be set at the pattern level or on a particular capture
|
||||
local conceal = metadata.conceal or metadata[capture] and metadata[capture].conceal
|
||||
)
|
||||
+ spell_pri_offset
|
||||
+ conceal_pri_offset
|
||||
|
||||
local url = get_url(match, buf, capture, metadata)
|
||||
|
||||
|
||||
@@ -609,7 +609,7 @@ predicate_handlers['any-vim-match?'] = predicate_handlers['any-match?']
|
||||
---@class vim.treesitter.query.TSMetadata
|
||||
---@field range? Range
|
||||
---@field offset? Range4
|
||||
---@field conceal? string
|
||||
---@field conceal? string|boolean
|
||||
---@field bo.commentstring? string
|
||||
---@field [integer]? vim.treesitter.query.TSMetadata
|
||||
---@field [string]? integer|string
|
||||
|
||||
Reference in New Issue
Block a user