I'm planning to implement some utility mappings for my LaTeX plugin to simplify typing of mathematics. For instance, I want to create abbreviations similar to`a : \alpha`b : \beta-> : \to=> : \RightarrowAnd similar. I want (some of) the mappings only to be available inside math environments, and not outside.I know that I can recognize math environments through the syntax groups, i.e. texMathZoneE and texMathZoneX. However, I do not know how to use this in order to make context sensitive mappings or abbreviations.
Context sensitive insert mode mapping or abbreviation
key bindings;filetype tex;abbreviations
Perhaps like this:let s:TeXmaps = {    \ '`a': '\alpha',    \ '`b': '\beta',    \ '->': '\to',    \ '=>': '\Rightarrow' }function! <SID>IsTeXMath()    return &ft ==# 'tex' && match(map( synstack(line('.'), col('.')), 'synIDattr(v:val, name)' ), '\m^texMathZone[EX]$') >= 0endfunctionfor s:k in keys(s:TeXmaps)    silent! exec 'inoremap <silent> ' . s:k . ' <C-r>=<SID>IsTeXMath()?' . string(s:TeXmaps[s:k]) . ':' . string(s:k) . '<CR>'endfor