-
-
Notifications
You must be signed in to change notification settings - Fork 97
Closed
Description
Highlight cells based on content is explained in the README. Though I cannot find it in the docs.
It's coded here.
I want to add custom highlights for cells starting with not only 'yes', 'no' or '?'.
How to redefine the main Table syntax rule without rewriting the whole syntax group "Table" ? I.e. just expand its contains? Search TODO in code below.
One could fork the plugin and edit the script. Not ideal.
Next code works. Once :TableModeToggle runs I get the desired highlights:
Highlights
hi yesCell ctermfg=2 guifg=Green
hi noCell ctermfg=1 guifg=Red
hi maybeCell ctermfg=3 guifg=Orange
hi highPriorityCell ctermfg=1 guifg=Red cterm=bold gui=bold
hi completeCell ctermfg=2 guifg=Green cterm=bold gui=bold
hi link infoCell Comment " Or make it look like comments in your colorschemeCode to run if triggered autocmd User TableModeEnabled
function! g:TableModeColorCellsCustom()
if !exists('b:table_mode_active') || !b:table_mode_active
return
endif
" 1. FIRST: Redefine the main Table syntax rule with our custom groups added to contains
" TODO, do NOT redefine, avoid hard-copy
syntax clear Table
syntax match Table /|.\+|/
\ contains=TableBorder,TableSeparator,TableColumnAlign,
\yesCell,noCell,maybeCell,redCell,greenCell,yellowCell,blueCell,whiteCell,darkCell,
\highPriorityCell,completeCell,infoCell
\ containedin=ALL
" 2. THEN: Define our custom syntax patterns as contained
syntax match highPriorityCell /|\@<= *\![^|]*/ contained
syntax match completeCell /|\@<= *X[^|]*/ contained
syntax match infoCell /|\@<= *\/\/[^|]*/ contained
endfunction
augroup TableModeColorCellsCustom
autocmd!
" Call it after a short delay when table mode is enabled
autocmd User TableModeEnabled call timer_start(10, {-> g:TableModeColorCellsCustom()})
" If error then manually run ":call g:TableModeColorCellsCustom()"
augroup ENDNote, original :execute('syntax list Table') echoes:
--- Syntax items ---
Table xxx match /|.\+|/ contains=TableBorder,TableSeparator,TableColumnAlign,yesCell,noCell,maybeCell,redCell,greenCell,yellowCell,blueCell,whiteCell,darkCell containedin=ALL
Metadata
Metadata
Assignees
Labels
No labels