How to convert this:
" txt strikeout ~~ (background black) ~~
au BufRead,BufNewFile *.txt syntax match StrikeoutMatch /\~\~.*\~\~/
hi def StrikeoutColor ctermbg=016 ctermfg=black
hi link StrikeoutMatch StrikeoutColor
To neovim lua using probably vim.api.nvim_create_autocmd
, I would like to prevent using:
vim.cmd([[
augroup StrikeoutMatch
autocmd!
autocmd BufRead,BufNewFile *.txt syntax match StrikeoutMatch /\~\~.*\~\~/
augroup END
]])
See "Autocmd Functions" in Neovim API to use vim.api.nvim_create_autocmd
and vim.api.nvim_set_hl
to set Highlight groups.
To set your pattern/regexp, you could use VIM function matchadd
via vim.fn.matchadd
.
You could convert your code in Lua:
vim.api.nvim_create_autocmd({'BufRead', 'BufNewFile'}, {
group = vim.api.nvim_create_augroup('StrikeoutMatch', { clear = true }),
pattern = { '*.txt' },
callback = function()
vim.fn.matchadd('StrikeoutMatch', '\\~\\~.*\\~\\~')
vim.api.nvim_set_hl(0, 'StrikeoutColor', { bg=016, fg='Black' })
vim.api.nvim_set_hl(0, 'StrikeoutMatch', { link='StrikeoutColor' })
end,
})