-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(hl): use real hl_group ids on nightly instead of ffi
- Loading branch information
Showing
1 changed file
with
5 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ local Highlight = require("noice.text.highlight") | |
local NuiLine = require("nui.line") | ||
local Object = require("nui.object") | ||
|
||
---@alias NoiceChunk { [0]: integer, [1]: string} | ||
---@alias NoiceChunk { [0]: integer, [1]: string, [2]?: integer} | ||
---@alias NoiceContent string|NoiceChunk|NuiLine|NuiText|NoiceBlock | ||
|
||
---@class NoiceBlock | ||
|
@@ -165,7 +165,7 @@ function Block:append(contents, highlight) | |
---@cast content NoiceChunk | ||
-- Handle newlines | ||
---@type number|string|table, string | ||
local attr_id, text = unpack(content) | ||
local attr_id, text, hl_id = unpack(content) | ||
-- msg_show messages can contain invalid \r characters | ||
if self.fix_cr ~= false then | ||
text = text:gsub("%^M", "\r") | ||
|
@@ -174,7 +174,9 @@ function Block:append(contents, highlight) | |
|
||
---@type string|table|nil | ||
local hl_group | ||
if type(attr_id) == "number" then | ||
if type(hl_id) == "number" then | ||
hl_group = vim.fn.synIDattr(hl_id, "name") | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
folke
Author
Owner
|
||
elseif type(attr_id) == "number" then | ||
hl_group = attr_id ~= 0 and Highlight.get_hl_group(attr_id) or nil | ||
else | ||
hl_group = attr_id | ||
|
You can use the chunk's highlight ID directly as input to
nvim_buf_set_extmark(.., {hl_group = hl_id })
@folke. I forgot about this when writing the commit message for the PR and later updated the docs in neovim/neovim#31195.