or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/coc.nvim@0.0.x

docs

index.md
tile.json

tessl/npm-coc-nvim

tessl install tessl/npm-coc-nvim@0.0.0

LSP based intellisense engine for neovim & vim8.

highlights-colors.mddocs/ui/

Highlights and Colors [Intermediate]

Complexity: Intermediate | Category: UI

Common Tasks: Highlight symbols | Pick colors | Customize highlights | Semantic tokens

Document highlighting, semantic highlighting, color management, and all highlight groups used by coc.nvim.

Table of Contents

Common Tasks

Auto-Highlight Symbol

autocmd CursorHold * silent call CocActionAsync('highlight')

Automatically highlight symbol under cursor.

Pick a Color

call CocAction('pickColor')

Open system color picker dialog.

Convert Color Format

call CocAction('colorPresentation')

Show different color representations (hex, rgb, hsl).

Customize Diagnostic Colors

highlight CocErrorSign ctermfg=Red guifg=#ff0000
highlight CocWarningSign ctermfg=Yellow guifg=#ffcc00

CocAction API

highlight

CocAction('highlight')

Highlight symbol under cursor and all its occurrences in the document.

Example:

autocmd CursorHold * silent call CocActionAsync('highlight')
set updatetime=300

semanticHighlight

CocAction('semanticHighlight')

Update semantic highlights for the current buffer.

Example:

call CocAction('semanticHighlight')

inspectSemanticToken

CocAction('inspectSemanticToken')

Inspect semantic token information at cursor position.

Example:

nnoremap <silent> <leader>hi :call CocAction('inspectSemanticToken')<CR>

pickColor

CocAction('pickColor')

Open system color picker to select a color.

Example:

nnoremap <silent> <leader>cp :call CocAction('pickColor')<CR>

colorPresentation

CocAction('colorPresentation')

Show different representations of color under cursor (hex, rgb, hsl, etc.).

Example:

nnoremap <silent> <leader>cc :call CocAction('colorPresentation')<CR>

Highlight Functions

coc#highlight#buffer_update()

coc#highlight#buffer_update(bufnr, key, highlights, [start], [end])

Update buffer highlights.

Parameters:

  • bufnr: Buffer number
  • key: Highlight key/namespace
  • highlights: List of highlight items
  • start: Optional start line
  • end: Optional end line

coc#highlight#update_highlights()

coc#highlight#update_highlights(bufnr, key, highlights, [start], [end])

Update highlights incrementally.

Parameters:

  • bufnr: Buffer number
  • key: Highlight key
  • highlights: Highlight items
  • start: Optional start line
  • end: Optional end line

coc#highlight#set()

coc#highlight#set(bufnr, key, highlights, priority)

Set highlights for buffer with priority.

Parameters:

  • bufnr: Buffer number
  • key: Highlight key
  • highlights: Highlight items
  • priority: Highlight priority

coc#highlight#clear()

coc#highlight#clear(bufnr, key, lnums)

Clear highlights from buffer.

Parameters:

  • bufnr: Buffer number
  • key: Highlight key
  • lnums: Line numbers to clear

coc#highlight#ranges()

coc#highlight#ranges(bufnr, key, hlGroup, ranges, [priority])

Highlight specific ranges.

Parameters:

  • bufnr: Buffer number
  • key: Highlight key
  • hlGroup: Highlight group name
  • ranges: List of ranges
  • priority: Optional priority

coc#highlight#add_highlight()

coc#highlight#add_highlight(bufnr, src_id, hl_group, line, col_start, col_end)
" Returns: number

Add single highlight.

Parameters:

  • bufnr: Buffer number
  • src_id: Source ID
  • hl_group: Highlight group
  • line: Line number (0-based)
  • col_start: Start column (0-based)
  • col_end: End column (-1 for end of line)

Returns: Source ID.

coc#highlight#clear_highlight()

coc#highlight#clear_highlight(bufnr, key, start_line, end_line)

Clear highlight range.

Parameters:

  • bufnr: Buffer number
  • key: Highlight key
  • start_line: Start line
  • end_line: End line

coc#highlight#clear_all()

coc#highlight#clear_all()

Clear all coc highlights.

coc#highlight#create_namespace()

coc#highlight#create_namespace(key)
" Returns: number

Create highlight namespace.

Parameters:

  • key: Namespace key

Returns: Namespace ID.

coc#highlight#get_syntax_name()

coc#highlight#get_syntax_name(lnum, col)
" Returns: string

Get syntax name at position.

Parameters:

  • lnum: Line number
  • col: Column

Returns: Syntax name.

Color Functions

coc#color#rgb2term()

coc#color#rgb2term(rgb)
" Returns: number

Convert RGB hex color to terminal color code.

Parameters:

  • rgb: RGB hex color (e.g., '#ff0000')

Returns: Terminal color code.

Example:

let term_color = coc#color#rgb2term('#ff0000')
echo 'Terminal color: ' . term_color

coc#color#pick_color()

coc#color#pick_color(default_color)
" Returns: list or false

Open system color picker.

Parameters:

  • default_color: Default color to show

Returns: List [r, g, b] or v:false if cancelled.

Example:

let color = coc#color#pick_color('#ffffff')
if color isnot v:false
  echo 'Selected: ' . color
endif

Utility Functions

coc#util#semantic_hlgroups()

coc#util#semantic_hlgroups()
" Returns: list

Get list of semantic highlight groups.

Returns: List of highlight group names.

Example:

let groups = coc#util#semantic_hlgroups()
for group in groups
  echo group
endfor

coc#util#synname()

coc#util#synname()
" Returns: string

Get syntax name under cursor.

Returns: Syntax/highlight group name.

Example:

nnoremap <silent> <F10> :echo coc#util#synname()<CR>

Global Variables

g:coc_default_semantic_highlight_groups

let g:coc_default_semantic_highlight_groups = 1

Create default semantic highlight groups.

Type: Number Default: 1

Example:

" Disable default semantic highlight groups
let g:coc_default_semantic_highlight_groups = 0

g:coc_highlight_maximum_count

let g:coc_highlight_maximum_count = 100

Maximum number of highlights before grouping.

Type: Number Default: 100

Example:

let g:coc_highlight_maximum_count = 200

Highlight Groups Reference

Text Style

CocBold

CocBold

Bold text in documentation and UI elements.

Example:

highlight CocBold cterm=bold gui=bold

CocItalic

CocItalic

Italic text in documentation and UI elements.

Example:

highlight CocItalic cterm=italic gui=italic

CocUnderline

CocUnderline

Underlined text.

Example:

highlight CocUnderline cterm=underline gui=underline

CocStrikeThrough

CocStrikeThrough

Strikethrough text for deprecated items.

Example:

highlight CocStrikeThrough cterm=strikethrough gui=strikethrough

CocFadeOut

CocFadeOut

Faded out text for inactive elements.

Example:

highlight CocFadeOut ctermfg=245 guifg=#928374

CocDisabled

CocDisabled

Disabled UI items.

Example:

highlight CocDisabled ctermfg=240 guifg=#585858

Markdown

CocMarkdownCode

CocMarkdownCode

Inline code in markdown documentation.

Example:

highlight CocMarkdownCode ctermfg=109 guifg=#83a598

CocMarkdownHeader

CocMarkdownHeader

Markdown headers in documentation.

Example:

highlight CocMarkdownHeader ctermfg=214 guifg=#fabd2f cterm=bold gui=bold

CocMarkdownLink

CocMarkdownLink

Markdown links.

Example:

highlight CocMarkdownLink ctermfg=109 guifg=#83a598 cterm=underline gui=underline

Diagnostic Signs

CocErrorSign

CocErrorSign

Error signs in sign column.

Example:

highlight CocErrorSign ctermfg=Red guifg=#ff0000

CocWarningSign

CocWarningSign

Warning signs in sign column.

Example:

highlight CocWarningSign ctermfg=Yellow guifg=#ffcc00

CocInfoSign

CocInfoSign

Information signs in sign column.

Example:

highlight CocInfoSign ctermfg=Blue guifg=#0088ff

CocHintSign

CocHintSign

Hint signs in sign column.

Example:

highlight CocHintSign ctermfg=Cyan guifg=#00ffaa

Diagnostic Virtual Text

CocErrorVirtualText

CocErrorVirtualText

Error virtual text at end of line.

Example:

highlight CocErrorVirtualText ctermfg=Red guifg=#ff0000

CocWarningVirtualText

CocWarningVirtualText

Warning virtual text.

Example:

highlight CocWarningVirtualText ctermfg=Yellow guifg=#ffcc00

CocInfoVirtualText

CocInfoVirtualText

Info virtual text.

Example:

highlight CocInfoVirtualText ctermfg=Blue guifg=#0088ff

CocHintVirtualText

CocHintVirtualText

Hint virtual text.

Example:

highlight CocHintVirtualText ctermfg=Cyan guifg=#00ffaa

Diagnostic Highlights

CocErrorHighlight

CocErrorHighlight

Error code range highlighting.

Example:

highlight CocErrorHighlight ctermbg=52 guibg=#5f0000 cterm=undercurl gui=undercurl guisp=#ff0000

CocWarningHighlight

CocWarningHighlight

Warning code range highlighting.

Example:

highlight CocWarningHighlight ctermbg=58 guibg=#5f5f00 cterm=undercurl gui=undercurl guisp=#ffcc00

CocInfoHighlight

CocInfoHighlight

Info code range highlighting.

Example:

highlight CocInfoHighlight ctermbg=17 guibg=#00005f cterm=undercurl gui=undercurl guisp=#0088ff

CocHintHighlight

CocHintHighlight

Hint code range highlighting.

Example:

highlight CocHintHighlight ctermbg=23 guibg=#005f5f cterm=undercurl gui=undercurl guisp=#00ffaa

CocDeprecatedHighlight

CocDeprecatedHighlight

Deprecated code highlighting.

Example:

highlight CocDeprecatedHighlight cterm=strikethrough gui=strikethrough guisp=#888888

CocUnusedHighlight

CocUnusedHighlight

Unused code highlighting.

Example:

highlight CocUnusedHighlight ctermfg=240 guifg=#585858

Diagnostic Lines

CocErrorLine

CocErrorLine

Full line highlight for errors.

Example:

highlight CocErrorLine ctermbg=52 guibg=#3f0000

CocWarningLine

CocWarningLine

Full line highlight for warnings.

Example:

highlight CocWarningLine ctermbg=58 guibg=#3f3f00

CocInfoLine

CocInfoLine

Full line highlight for info.

Example:

highlight CocInfoLine ctermbg=17 guibg=#00003f

CocHintLine

CocHintLine

Full line highlight for hints.

Example:

highlight CocHintLine ctermbg=23 guibg=#003f3f

Document Highlights

CocHighlightText

CocHighlightText

Default symbol highlight (read/write).

Example:

highlight CocHighlightText ctermbg=237 guibg=#3a3a3a

CocHighlightRead

CocHighlightRead

Symbol read occurrence highlight.

Example:

highlight CocHighlightRead ctermbg=22 guibg=#2a4a2a

CocHighlightWrite

CocHighlightWrite

Symbol write occurrence highlight.

Example:

highlight CocHighlightWrite ctermbg=52 guibg=#4a2a2a

CocHoverRange

CocHoverRange

Hovered symbol range.

Example:

highlight CocHoverRange ctermbg=237 guibg=#3a3a3a

CocCursorRange

CocCursorRange

Cursor range for multi-cursor.

Example:

highlight CocCursorRange ctermbg=237 guibg=#3a3a3a

CocLinkedEditing

CocLinkedEditing

Linked editing ranges.

Example:

highlight CocLinkedEditing ctermbg=237 guibg=#3a3a3a

CocSelectedRange

CocSelectedRange

Selected ranges.

Example:

highlight CocSelectedRange ctermbg=237 guibg=#3a3a3a

Float Windows

CocFloating

CocFloating

Default floating window background.

Example:

highlight CocFloating ctermbg=235 guibg=#1e1e1e

CocErrorFloat

CocErrorFloat

Error text in floating windows.

Example:

highlight CocErrorFloat ctermfg=Red guifg=#ff0000

CocWarningFloat

CocWarningFloat

Warning text in floating windows.

Example:

highlight CocWarningFloat ctermfg=Yellow guifg=#ffcc00

CocInfoFloat

CocInfoFloat

Info text in floating windows.

Example:

highlight CocInfoFloat ctermfg=Blue guifg=#0088ff

CocHintFloat

CocHintFloat

Hint text in floating windows.

Example:

highlight CocHintFloat ctermfg=Cyan guifg=#00ffaa

Notifications

CocNotificationProgress

CocNotificationProgress

Progress notification line.

Example:

highlight CocNotificationProgress ctermfg=109 guifg=#83a598

CocNotificationButton

CocNotificationButton

Action buttons in notifications.

Example:

highlight CocNotificationButton ctermbg=237 guibg=#3a3a3a

CocNotificationError

CocNotificationError

Error notification border.

Example:

highlight CocNotificationError ctermfg=Red guifg=#ff0000

CocNotificationWarning

CocNotificationWarning

Warning notification border.

Example:

highlight CocNotificationWarning ctermfg=Yellow guifg=#ffcc00

CocNotificationInfo

CocNotificationInfo

Info notification border.

Example:

highlight CocNotificationInfo ctermfg=Blue guifg=#0088ff

List Interface

CocListLine

CocListLine

Current selected line in list.

Example:

highlight CocListLine ctermbg=237 guibg=#3a3a3a

CocListSearch

CocListSearch

Matched search characters in list.

Example:

highlight CocListSearch ctermfg=214 guifg=#fabd2f cterm=bold gui=bold

CocListMode

CocListMode

Mode indicator text in list.

Example:

highlight CocListMode ctermfg=109 guifg=#83a598

CocListPath

CocListPath

File path text in list.

Example:

highlight CocListPath ctermfg=245 guifg=#928374

CocSelectedText

CocSelectedText

Sign for selected text.

Example:

highlight CocSelectedText ctermfg=214 guifg=#fabd2f

CocSelectedLine

CocSelectedLine

Selected line background.

Example:

highlight CocSelectedLine ctermbg=237 guibg=#3a3a3a

CocSearch

CocSearch

General search result highlight.

Example:

highlight CocSearch ctermfg=214 guifg=#fabd2f ctermbg=237 guibg=#3a3a3a

Tree View

CocTreeTitle

CocTreeTitle

Tree view title.

Example:

highlight CocTreeTitle ctermfg=214 guifg=#fabd2f cterm=bold gui=bold

CocTreeDescription

CocTreeDescription

Tree item descriptions.

Example:

highlight CocTreeDescription ctermfg=245 guifg=#928374

CocTreeOpenClose

CocTreeOpenClose

Tree expand/collapse icons.

Example:

highlight CocTreeOpenClose ctermfg=109 guifg=#83a598

CocTreeSelected

CocTreeSelected

Selected tree item.

Example:

highlight CocTreeSelected ctermbg=237 guibg=#3a3a3a

Popup Menu (Completion)

CocPumSearch

CocPumSearch

Matched input characters in completion menu.

Example:

highlight CocPumSearch ctermfg=214 guifg=#fabd2f cterm=bold gui=bold

CocPumMenu

CocPumMenu

Completion menu background.

Example:

highlight CocPumMenu ctermbg=235 guibg=#262626

CocPumShortcut

CocPumShortcut

Source shortcut in completion.

Example:

highlight CocPumShortcut ctermfg=245 guifg=#928374

CocPumDeprecated

CocPumDeprecated

Deprecated completion items.

Example:

highlight CocPumDeprecated cterm=strikethrough gui=strikethrough

CocPumVirtualText

CocPumVirtualText

Virtual text in completion menu.

Example:

highlight CocPumVirtualText ctermfg=245 guifg=#928374

CocMenuSel

CocMenuSel

Selected completion item.

Example:

highlight CocMenuSel ctermbg=237 guibg=#3a3a3a

Symbol Icons (Kind Highlights)

All symbol kind highlights follow the pattern CocSymbol{Kind}:

CocSymbolDefault

CocSymbolDefault

Default symbol kind.

Completion/Symbol Kind Highlights

CocSymbolText
CocSymbolMethod
CocSymbolFunction
CocSymbolConstructor
CocSymbolField
CocSymbolVariable
CocSymbolClass
CocSymbolInterface
CocSymbolModule
CocSymbolProperty
CocSymbolUnit
CocSymbolValue
CocSymbolEnum
CocSymbolKeyword
CocSymbolSnippet
CocSymbolColor
CocSymbolFile
CocSymbolReference
CocSymbolFolder
CocSymbolEnumMember
CocSymbolConstant
CocSymbolStruct
CocSymbolEvent
CocSymbolOperator
CocSymbolTypeParameter
CocSymbolNamespace
CocSymbolPackage
CocSymbolString
CocSymbolNumber
CocSymbolBoolean
CocSymbolArray
CocSymbolObject
CocSymbolKey
CocSymbolNull

Example:

highlight CocSymbolClass ctermfg=214 guifg=#fabd2f
highlight CocSymbolFunction ctermfg=109 guifg=#83a598
highlight CocSymbolVariable ctermfg=142 guifg=#b8bb26

Semantic Tokens

All semantic token highlights follow the pattern CocSem{TokenType}:

CocSemNamespace
CocSemType
CocSemClass
CocSemEnum
CocSemInterface
CocSemStruct
CocSemTypeParameter
CocSemParameter
CocSemVariable
CocSemProperty
CocSemEnumMember
CocSemEvent
CocSemFunction
CocSemMethod
CocSemMacro
CocSemKeyword
CocSemModifier
CocSemComment
CocSemString
CocSemNumber
CocSemBoolean
CocSemRegexp
CocSemOperator
CocSemDecorator
CocSemDeprecated

Example:

highlight CocSemClass ctermfg=214 guifg=#4ec9b0
highlight CocSemFunction ctermfg=109 guifg=#dcdcaa
highlight CocSemVariable ctermfg=142 guifg=#9cdcfe

Other Highlights

CocCodeLens

CocCodeLens

CodeLens virtual text.

Example:

highlight CocCodeLens ctermfg=245 guifg=#999999

CocSnippetVisual

CocSnippetVisual

Snippet visual selection.

Example:

highlight CocSnippetVisual ctermbg=237 guibg=#3a3a3a

CocInlayHint

CocInlayHint

Inlay hint virtual text.

Example:

highlight CocInlayHint ctermfg=245 guifg=#999999

Configuration

Highlight settings in coc-settings.json:

{
  "semanticTokens.enable": true,
  "semanticTokens.filetypes": ["*"],
  "colors.enable": true,
  "suggest.completionItemKindLabels": {
    "keyword": "ξ",
    "variable": "ψ",
    "value": "λ"
  }
}

Usage Examples

Auto-Highlight Symbol

" Highlight symbol under cursor on hold
autocmd CursorHold * silent call CocActionAsync('highlight')
set updatetime=300

" Clear highlights on cursor move
autocmd CursorMoved * silent call coc#highlight#clear_all()

Color Picker Integration

function! PickColorAndInsert() abort
  let color = coc#color#pick_color('#000000')

  if color isnot v:false
    let hex = printf('#%02x%02x%02x', color[0], color[1], color[2])
    execute "normal! a" . hex
    echo 'Inserted color: ' . hex
  endif
endfunction

nnoremap <silent> <leader>cp :call PickColorAndInsert()<CR>

Convert Color Format

function! ConvertColorFormat() abort
  " Show different color representations
  call CocAction('colorPresentation')
endfunction

nnoremap <silent> <leader>cf :call ConvertColorFormat()<CR>

Show Syntax Info

function! ShowSyntaxInfo() abort
  let synname = coc#util#synname()
  let lnum = line('.')
  let col = col('.')
  let hlname = coc#highlight#get_syntax_name(lnum, col)

  echo 'Syntax: ' . synname
  echo 'Highlight: ' . hlname
endfunction

nnoremap <silent> <F10> :call ShowSyntaxInfo()<CR>

Custom Highlight Ranges

function! HighlightCurrentWord() abort
  let word = expand('<cword>')
  let ranges = []
  let lnum = 1

  while lnum <= line('$')
    let line = getline(lnum)
    let col = 0

    while 1
      let col = match(line, '\<' . word . '\>', col)
      if col == -1
        break
      endif

      call add(ranges, {
        \ 'start': {'line': lnum - 1, 'character': col},
        \ 'end': {'line': lnum - 1, 'character': col + len(word)}
        \ })

      let col += 1
    endwhile

    let lnum += 1
  endwhile

  call coc#highlight#ranges(bufnr('%'), 'word', 'CocHighlightText', ranges, 10)
endfunction

nnoremap <silent> <leader>hw :call HighlightCurrentWord()<CR>

Semantic Token Inspection

function! InspectToken() abort
  call CocAction('inspectSemanticToken')
endfunction

nnoremap <silent> <leader>it :call InspectToken()<CR>

Toggle Semantic Highlighting

let g:semantic_highlights_enabled = 1

function! ToggleSemanticHighlights() abort
  if g:semantic_highlights_enabled
    let g:semantic_highlights_enabled = 0
    call coc#config('semanticTokens.enable', v:false)
    echo 'Semantic highlighting disabled'
  else
    let g:semantic_highlights_enabled = 1
    call coc#config('semanticTokens.enable', v:true)
    call CocAction('semanticHighlight')
    echo 'Semantic highlighting enabled'
  endif
endfunction

command! ToggleSemanticHighlights call ToggleSemanticHighlights()

Color Preview

function! PreviewColorUnderCursor() abort
  let line = getline('.')
  let col = col('.')

  " Match hex color
  let hex = matchstr(line, '#\x\{6}', col - 7)

  if !empty(hex)
    " Show color preview (could use terminal colors or float window)
    echo 'Color: ' . hex
    " Convert to RGB
    let r = str2nr(hex[1:2], 16)
    let g = str2nr(hex[3:4], 16)
    let b = str2nr(hex[5:6], 16)
    echo 'RGB: ' . r . ', ' . g . ', ' . b
  endif
endfunction

nnoremap <silent> <leader>pc :call PreviewColorUnderCursor()<CR>

Highlight Customization

" Customize symbol highlight colors
highlight CocHighlightText guibg=#3a3a3a ctermbg=237
highlight CocHighlightRead guibg=#2a4a2a ctermbg=22
highlight CocHighlightWrite guibg=#4a2a2a ctermbg=52

" Customize semantic token colors
highlight CocSemClass guifg=#4ec9b0
highlight CocSemFunction guifg=#dcdcaa
highlight CocSemVariable guifg=#9cdcfe
highlight CocSemParameter guifg=#9cdcfe
highlight CocSemProperty guifg=#9cdcfe

Clear Highlights on Command

function! ClearAllHighlights() abort
  call coc#highlight#clear_all()
  echo 'Cleared all highlights'
endfunction

command! ClearHighlights call ClearAllHighlights()
nnoremap <silent> <leader>ch :ClearHighlights<CR>

Highlight Group List

function! ListSemanticHighlights() abort
  let groups = coc#util#semantic_hlgroups()

  echo '=== Semantic Highlight Groups ==='
  for group in groups
    echo group
  endfor
endfunction

command! SemanticGroups call ListSemanticHighlights()

RGB to Hex Converter

function! RgbToHex(r, g, b) abort
  return printf('#%02x%02x%02x', a:r, a:g, a:b)
endfunction

function! HexToRgb(hex) abort
  let hex = substitute(a:hex, '^#', '', '')
  return [
    \ str2nr(hex[0:1], 16),
    \ str2nr(hex[2:3], 16),
    \ str2nr(hex[4:5], 16)
    \ ]
endfunction

" Usage
echo RgbToHex(255, 0, 0)  " #ff0000
echo HexToRgb('#ff0000')   " [255, 0, 0]

Complete Color Scheme Example

" Diagnostics
highlight CocErrorSign ctermfg=Red guifg=#e06c75
highlight CocWarningSign ctermfg=Yellow guifg=#e5c07b
highlight CocInfoSign ctermfg=Blue guifg=#61afef
highlight CocHintSign ctermfg=Cyan guifg=#56b6c2

highlight CocErrorHighlight cterm=undercurl gui=undercurl guisp=#e06c75
highlight CocWarningHighlight cterm=undercurl gui=undercurl guisp=#e5c07b

" Document highlights
highlight CocHighlightText ctermbg=237 guibg=#3e4452
highlight CocHighlightRead ctermbg=22 guibg=#2a4a2a
highlight CocHighlightWrite ctermbg=52 guibg=#4a2a2a

" Float windows
highlight CocFloating ctermbg=235 guibg=#282c34

" List
highlight CocListLine ctermbg=237 guibg=#3e4452
highlight CocListSearch ctermfg=214 guifg=#e5c07b cterm=bold gui=bold

" Completion
highlight CocMenuSel ctermbg=237 guibg=#3e4452
highlight CocPumSearch ctermfg=214 guifg=#e5c07b cterm=bold gui=bold

" Symbols
highlight CocSymbolClass ctermfg=214 guifg=#e5c07b
highlight CocSymbolFunction ctermfg=109 guifg=#61afef
highlight CocSymbolVariable ctermfg=142 guifg=#98c379

Error Handling

Color Picker Cancelled

let color = coc#color#pick_color('#000000')
if color is v:false
  echo "Color picker was cancelled"
else
  " Process color
endif

Invalid Highlight Group

try
  highlight link MyGroup CocInvalidGroup
catch
  echohl Error
  echo "Invalid highlight group"
  echohl None
endtry

Semantic Tokens Not Available

if !CocHasProvider('semanticTokens')
  echohl WarningMsg
  echo "Semantic tokens not available for this buffer"
  echohl None
else
  call CocAction('semanticHighlight')
endif

Troubleshooting

Highlights Not Showing

  • Check if semantic tokens are enabled in settings
  • Verify language server supports semantic tokens
  • Check highlight group definitions with :hi CocSemClass
  • Ensure colorscheme doesn't override coc highlights

Colors Not Matching Theme

  • Link coc highlights to theme colors:
    highlight! link CocErrorSign ErrorMsg
    highlight! link CocWarningSign WarningMsg
  • Or define custom colors after theme loads

Symbol Highlighting Not Working

  • Verify updatetime is set appropriately (300ms recommended)
  • Check CursorHold autocommand is defined
  • Ensure buffer has LSP attached

Performance Issues with Highlighting

  • Reduce g:coc_highlight_maximum_count
  • Disable semantic highlighting: "semanticTokens.enable": false
  • Limit highlight range with buffer constraints

See Also

  • Float Windows - Float window highlights
  • List Interface - List highlight customization
  • Diagnostics - Diagnostic highlight configuration
  • Configuration - Highlight settings