docs(api): nvim_set_hl attributes #18558

This commit is contained in:
Oliver Marriott
2022-05-16 07:06:06 +10:00
committed by GitHub
parent 0a3d615b1c
commit 5e3b16836a
2 changed files with 67 additions and 17 deletions

View File

@@ -1570,18 +1570,46 @@ nvim_set_current_win({window}) *nvim_set_current_win()*
nvim_set_hl({ns_id}, {name}, {*val}) *nvim_set_hl()* nvim_set_hl({ns_id}, {name}, {*val}) *nvim_set_hl()*
Sets a highlight group. Sets a highlight group.
Note: Unlike the `:highlight` command which can update a Note:
Unlike the `:highlight` command which can update a
highlight group, this function completely replaces the highlight group, this function completely replaces the
definition. For example: `nvim_set_hl(0, 'Visual', {})` will definition. For example: `nvim_set_hl(0, 'Visual', {})`
clear the highlight group 'Visual'. will clear the highlight group 'Visual'.
Note:
The fg and bg keys also accept the string values `"fg"` or
`"bg"` which act as aliases to the corresponding
foreground and background values of the Normal group. If
the Normal group has not been defined, using these values
results in an error.
Parameters: ~ Parameters: ~
{ns_id} Namespace id for this highlight {ns_id} Namespace id for this highlight
|nvim_create_namespace()|. Use 0 to set a |nvim_create_namespace()|. Use 0 to set a
highlight group globally |:highlight|. highlight group globally |:highlight|.
{name} Highlight group name, e.g. "ErrorMsg" {name} Highlight group name, e.g. "ErrorMsg"
{val} Highlight definition map, like |synIDattr()|. In {val} Highlight definition map, accepts the following
addition, the following keys are recognized: keys:
• fg (or foreground): color name or "#RRGGBB",
see note.
• bg (or background): color name or "#RRGGBB",
see note.
• sp (or special): color name or "#RRGGBB"
• blend: integer between 0 and 100
• bold: boolean
• standout: boolean
• underline: boolean
• underlineline: boolean
• undercurl: boolean
• underdot: boolean
• underdash: boolean
• strikethrough: boolean
• italic: boolean
• reverse: boolean
• nocombine: boolean
• link: name of another highlight group to link
to, see |:hi-link|. Additionally, the following
keys are recognized:
• default: Don't override existing definition • default: Don't override existing definition
|:hi-default| |:hi-default|
• ctermfg: Sets foreground of cterm color • ctermfg: Sets foreground of cterm color
@@ -1589,8 +1617,9 @@ nvim_set_hl({ns_id}, {name}, {*val}) *nvim_set_hl()*
• ctermbg: Sets background of cterm color • ctermbg: Sets background of cterm color
|highlight-ctermbg| |highlight-ctermbg|
• cterm: cterm attribute map, like • cterm: cterm attribute map, like
|highlight-args|. Note: Attributes default to |highlight-args|. If not set, cterm attributes
those set for `gui` if not set. will match those from the attribute map
documented above.
nvim_set_keymap({mode}, {lhs}, {rhs}, {*opts}) *nvim_set_keymap()* nvim_set_keymap({mode}, {lhs}, {rhs}, {*opts}) *nvim_set_keymap()*
Sets a global |mapping| for the given mode. Sets a global |mapping| for the given mode.

View File

@@ -126,22 +126,43 @@ Dictionary nvim__get_hl_defs(Integer ns_id, Error *err)
/// Sets a highlight group. /// Sets a highlight group.
/// ///
/// Note: Unlike the `:highlight` command which can update a highlight group, /// @note Unlike the `:highlight` command which can update a highlight group,
/// this function completely replaces the definition. For example: /// this function completely replaces the definition. For example:
/// ``nvim_set_hl(0, 'Visual', {})`` will clear the highlight group 'Visual'. /// ``nvim_set_hl(0, 'Visual', {})`` will clear the highlight group
/// 'Visual'.
///
/// @note The fg and bg keys also accept the string values `"fg"` or `"bg"`
/// which act as aliases to the corresponding foreground and background
/// values of the Normal group. If the Normal group has not been defined,
/// using these values results in an error.
/// ///
/// @param ns_id Namespace id for this highlight |nvim_create_namespace()|. /// @param ns_id Namespace id for this highlight |nvim_create_namespace()|.
/// Use 0 to set a highlight group globally |:highlight|. /// Use 0 to set a highlight group globally |:highlight|.
/// @param name Highlight group name, e.g. "ErrorMsg" /// @param name Highlight group name, e.g. "ErrorMsg"
/// @param val Highlight definition map, like |synIDattr()|. In /// @param val Highlight definition map, accepts the following keys:
/// addition, the following keys are recognized: /// - fg (or foreground): color name or "#RRGGBB", see note.
/// - bg (or background): color name or "#RRGGBB", see note.
/// - sp (or special): color name or "#RRGGBB"
/// - blend: integer between 0 and 100
/// - bold: boolean
/// - standout: boolean
/// - underline: boolean
/// - underlineline: boolean
/// - undercurl: boolean
/// - underdot: boolean
/// - underdash: boolean
/// - strikethrough: boolean
/// - italic: boolean
/// - reverse: boolean
/// - nocombine: boolean
/// - link: name of another highlight group to link to, see |:hi-link|.
/// Additionally, the following keys are recognized:
/// - default: Don't override existing definition |:hi-default| /// - default: Don't override existing definition |:hi-default|
/// - ctermfg: Sets foreground of cterm color |highlight-ctermfg| /// - ctermfg: Sets foreground of cterm color |highlight-ctermfg|
/// - ctermbg: Sets background of cterm color |highlight-ctermbg| /// - ctermbg: Sets background of cterm color |highlight-ctermbg|
/// - cterm: cterm attribute map, like /// - cterm: cterm attribute map, like |highlight-args|. If not set,
/// |highlight-args|. /// cterm attributes will match those from the attribute map
/// Note: Attributes default to those set for `gui` /// documented above.
/// if not set.
/// @param[out] err Error details, if any /// @param[out] err Error details, if any
/// ///
// TODO(bfredl): val should take update vs reset flag // TODO(bfredl): val should take update vs reset flag