File: unicode_math.vim

package info (click to toggle)
vim-vimtex 2.16-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,660 kB
  • sloc: makefile: 367; python: 103
file content (79 lines) | stat: -rw-r--r-- 3,837 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
" VimTeX - LaTeX plugin for Vim
"
" Maintainer: Karl Yngve Lervåg
" Email:      karl.yngve@gmail.com
"

function! vimtex#syntax#p#unicode_math#load(cfg) abort " {{{1
  syntax match texMathCmdStyle contained "\\symbb\>"
  syntax match texMathCmdStyle contained "\\symbf\>"
  syntax match texMathCmdStyle contained "\\symcal\>"
  syntax match texMathCmdStyle contained "\\symfrak\>"
  syntax match texMathCmdStyle contained "\\symit\>"
  syntax match texMathCmdStyle contained "\\symbfit\>"
  syntax match texMathCmdStyle contained "\\symnormal\>"
  syntax match texMathCmdStyle contained "\\symrm\>"
  syntax match texMathCmdStyle contained "\\symsf\>"
  syntax match texMathCmdStyle contained "\\symtt\>"
  syntax match texMathCmdStyle contained "\\symscr\>"

  let [l:conceal, l:concealends] =
        \ (g:vimtex_syntax_conceal.styles ? ['conceal', 'concealends'] : ['', ''])

  let l:map = {
        \ 'texMathCmdStyleBold': 'texMathStyleBold',
        \ 'texMathCmdStyleItal': 'texMathStyleItal',
        \ 'texMathCmdStyleBoth': 'texMathStyleBoth',
        \}

  for [l:group, l:pattern] in [
        \ ['texMathCmdStyleBold', 'symbf'],
        \ ['texMathCmdStyleItal', 'symit'],
        \ ['texMathCmdStyleBoth', 'symbfit'],
        \]
    execute 'syntax match' l:group '"\\' . l:pattern . '\>"'
          \ 'contained skipwhite nextgroup=' . l:map[l:group]
          \ l:conceal
  endfor

  if g:vimtex_syntax_conceal.styles
    syntax match texMathCmdStyle "\v\\sym%(rm|tt|normal|sf)>"
          \ contained conceal skipwhite nextgroup=texMathStyleConcArg
  endif

  if g:vimtex_syntax_conceal.math_symbols
    for [l:cmd, l:alphabet_map] in [
          \ ['sym\%(bb\%(b\|m\%(ss\|tt\)\?\)\?\|ds\)', 'double'],
          \ ['symfrak', 'fraktur'],
          \ ['sym\%(scr\|cal\)', 'script'],
          \ ['symbffrak', 'fraktur_bold'],
          \ ['symbf\%(scr\|cal\)', 'script_bold'],
          \]
      let l:pairs = vimtex#syntax#core#get_alphabet_map(l:alphabet_map)
      call vimtex#syntax#core#conceal_cmd_pairs(l:cmd, l:pairs)
    endfor

    syntax match texMathSymbol '\%#=1\\mathhyphen\>'        contained conceal cchar=‐
    syntax match texMathSymbol '\%#=1\\mathstraightquote\>' contained conceal cchar='
    syntax match texMathSymbol '\%#=1\\mathbacktick\>'      contained conceal cchar=`
    syntax match texMathSymbol '\%#=1\\slash\>'             contained conceal cchar=/
    syntax match texMathSymbol '\%#=1\\fracslash\>'         contained conceal cchar=⁄
    syntax match texMathSymbol '\%#=1\\divslash\>'          contained conceal cchar=∕
    syntax match texMathSymbol '\%#=1\\reversesolidus\>'    contained conceal cchar=⧵
    syntax match texMathSymbol '\%#=1\\cdotp\>'             contained conceal cchar=·
    syntax match texMathSymbol '\%#=1\\vysmblkcircle\>'     contained conceal cchar=∙
    syntax match texMathSymbol '\%#=1\\smblkcircle\>'       contained conceal cchar=•
    syntax match texMathSymbol '\%#=1\\mdsmblkcircle\>'     contained conceal cchar=⦁
    syntax match texMathSymbol '\%#=1\\mdblkcircle\>'       contained conceal cchar=⚫
    syntax match texMathSymbol '\%#=1\\mdlgblkcircle\>'     contained conceal cchar=●
    syntax match texMathSymbol '\%#=1\\lgblkcircle\>'       contained conceal cchar=⬤
    syntax match texMathSymbol '\%#=1\\vysmwhtcircle\>'     contained conceal cchar=∘
    syntax match texMathSymbol '\%#=1\\smwhtcircle\>'       contained conceal cchar=◦
    syntax match texMathSymbol '\%#=1\\mdsmwhtcircle\>'     contained conceal cchar=⚬
    syntax match texMathSymbol '\%#=1\\mdwhtcircle\>'       contained conceal cchar=⚪
    syntax match texMathSymbol '\%#=1\\mdlgwhtcircle\>'     contained conceal cchar=○
    syntax match texMathSymbol '\%#=1\\lgwhtcircle\>'       contained conceal cchar=◯
  endif
endfunction

" }}}1