mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 11:58:17 +00:00
feat(lsp): highlight semantic token modifiers (#21390)
Apply semantic token modifiers as separate extmarks with corresponding highlight groups (e.g., `@readonly`). This is a low-effort PR to enable the most common use cases (applying, e.g., italics or backgrounds on top of type highlights; language-specific fallbacks like `@global.lua` are also available). This can be replaced by more complicated selector-style themes later on.
This commit is contained in:
@@ -409,7 +409,17 @@ function STHighlighter:on_win(topline, botline)
|
||||
strict = false,
|
||||
})
|
||||
|
||||
--TODO(jdrouhard): do something with the modifiers
|
||||
-- TODO(bfredl) use single extmark when hl_group supports table
|
||||
if #token.modifiers > 0 then
|
||||
for _, modifier in pairs(token.modifiers) do
|
||||
api.nvim_buf_set_extmark(self.bufnr, state.namespace, token.line, token.start_col, {
|
||||
hl_group = '@' .. modifier,
|
||||
end_col = token.end_col,
|
||||
priority = vim.highlight.priorities.semantic_tokens,
|
||||
strict = false,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
token.extmark_added = true
|
||||
end
|
||||
@@ -494,7 +504,7 @@ local M = {}
|
||||
--- opt-out of semantic highlighting with a server that supports it, you can
|
||||
--- delete the semanticTokensProvider table from the {server_capabilities} of
|
||||
--- your client in your |LspAttach| callback or your configuration's
|
||||
--- `on_attach` callback.
|
||||
--- `on_attach` callback:
|
||||
--- <pre>lua
|
||||
--- client.server_capabilities.semanticTokensProvider = nil
|
||||
--- </pre>
|
||||
|
Reference in New Issue
Block a user