-
-
Notifications
You must be signed in to change notification settings - Fork 97
Issue #244 #245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue #244 #245
Conversation
Test with next VIMRC settings:
let g:table_mode_color_cells = 1
function! g:TableModeColorCellsCustom()
let g:TableModeSyntaxDict.contains .= ',highPriorityCell,completeCell,infoCell'
syntax match highPriorityCell /|\@<= *\![^|]*/ contained
syntax match completeCell /|\@<= *X[^|]*/ contained
syntax match infoCell /|\@<= *\/\/[^|]*/ contained
endfunction
autocmd VimEnter * call timer_start(10, {-> g:TableModeColorCellsCustom()})
|
Amend. E.g. 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 colorscheme |
Test with next VIMRC settings:
let g:table_mode_color_cells = 1
function! g:TableModeColorCellsCustom()
let g:table_mode_syntax_dict.contains .= ',highPriorityCell,completeCell,infoCell'
syntax match highPriorityCell /|\@<= *\![^|]*/ contained
syntax match completeCell /|\@<= *X[^|]*/ contained
syntax match infoCell /|\@<= *\/\/[^|]*/ contained
endfunction
autocmd VimEnter * call timer_start(10, {-> g:TableModeColorCellsCustom()})
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 colorscheme
Code adapted to plugin syntaxWe achieved that my dirty initial commit is adapted to syntax and other preferences of the plugin development. Thanks for merging it! TestFor everyone reading this issue. Test the PR with next VIMRC settings: let g:table_mode_always_active = 0 " default
let g:table_mode_color_cells = 1
function! g:TableModeColorCellsCustom()
let g:table_mode_syntax_dict.contains .= ',highPriorityCell,completeCell,infoCell'
syntax match highPriorityCell /|\@<= *\![^|]*/ contained
syntax match completeCell /|\@<= *X[^|]*/ contained
syntax match infoCell /|\@<= *\/\/[^|]*/ contained
endfunction
autocmd VimEnter * call timer_start(10, {-> g:TableModeColorCellsCustom()})Open a TXT buffer. It must have a table with cells like in #244 initial message. E.g. starting with ToDo-sToDo-s of my initial message in this PR. I copy-paste them but now numbered:
Which
|
|
Amend. @dhruvasagar I forgot to tag you. My bad. |
From my last comment I must fix:
It should be: Solution. Edit e.g. function! g:TableModeColorCellsCustom()
if v:true " ‼️‼️
" Expand string
let g:table_mode_syntax_dict.contains .= ',highPriorityCell,completeCell,infoCell'
" let g:table_mode_syntax_dict.contains .= ',highPriorityCell,xxxCell'
else
" Get default string just once
if !exists('g:table_mode_syntax_contains_default')
let g:table_mode_syntax_contains_default = g:table_mode_syntax_dict.contains
endif
" Alternative, edit the default string directly (hard-copy)
if v:false
let g:table_mode_syntax_contains_default = 'TableBorder,TableSeparator,TableColumnAlign'
let g:table_mode_syntax_contains_default .= ',yesCell,noCell,maybeCell'
let g:table_mode_syntax_contains_default .= ',redCell,greenCell,yellowCell,blueCell,whiteCell,darkCell'
endif
" Overwrite
let g:table_mode_syntax_dict.contains = g:table_mode_syntax_contains_default
" Expand
let g:table_mode_syntax_dict.contains .= ',highPriorityCell,completeCell,infoCell'
" let g:table_mode_syntax_dict.contains .= ',highPriorityCell,xxxCell'
endif
" Sort and apply unique ‼️‼️
let g:table_mode_syntax_dict.contains = s:StringSortedUnique(g:table_mode_syntax_dict.contains)
syntax clear highPriorityCell " Never comment this line
syntax match highPriorityCell /|\@<= *\![^|]*/ contained " Comment if desired
syntax clear completeCell " Never comment this line
syntax match completeCell /|\@<= *X[^|]*/ contained
syntax clear infoCell " Never comment this line
syntax match infoCell /|\@<= *\/\/[^|]*/ contained
endfunction
function! s:StringSortedUnique(input) abort
" Split string into array
let arr = split(a:input, ',')
" Trim spaces
let arr = map(arr, 'trim(v:val)')
" Sort and apply unique
let arr = uniq(sort(arr))
" Rejoin to a string
return join(arr, ',')
endfunctionNote. Ideally, Test:
A more real test:
Notice that the An alternative is the This later approach even lets the user edit the default highlights!
I recommend this later approach whose function! g:TableModeColorCellsCustom()
" Get default string just once
if !exists('g:table_mode_syntax_contains_default')
let g:table_mode_syntax_contains_default = g:table_mode_syntax_dict.contains
endif
" Alternative, edit the default string directly (hard-copied from plugin's scripts)
if v:false
let g:table_mode_syntax_contains_default = 'TableBorder,TableSeparator,TableColumnAlign'
let g:table_mode_syntax_contains_default .= ',yesCell,noCell,maybeCell'
let g:table_mode_syntax_contains_default .= ',redCell,greenCell,yellowCell,blueCell,whiteCell,darkCell'
endif
" Overwrite
let g:table_mode_syntax_dict.contains = g:table_mode_syntax_contains_default
" Expand
let g:table_mode_syntax_dict.contains .= ',highPriorityCell,completeCell,infoCell'
" let g:table_mode_syntax_dict.contains .= ',highPriorityCell,xxxCell'
" Sort and apply unique
let g:table_mode_syntax_dict.contains = s:StringSortedUnique(g:table_mode_syntax_dict.contains)
syntax clear highPriorityCell " Never comment this line
syntax match highPriorityCell /|\@<= *\![^|]*/ contained " Comment if desired
syntax clear completeCell " Never comment this line
syntax match completeCell /|\@<= *X[^|]*/ contained
syntax clear infoCell " Never comment this line
syntax match infoCell /|\@<= *\/\/[^|]*/ contained
endfunction
function! s:StringSortedUnique(input) abort
" Split string into array
let arr = split(a:input, ',')
" Trim spaces
let arr = map(arr, 'trim(v:val)')
" Sort and apply unique
let arr = uniq(sort(arr))
" Rejoin to a string
return join(arr, ',')
endfunction@dhruvasagar please read this comment too. |
#244
Test with next VIMRC settings:
Notes:
plugin/declared the dict to auto-run and so aboveautocmd VimEntercan run tocall timer_start(10seems not best option. It should just run once the plugin is loaded (idk how)g:TableModeSyntaxDict.containedincould be other thanALL? I just blinded copied it.