File: fontawesome5.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 (53 lines) | stat: -rw-r--r-- 1,697 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
" VimTeX - LaTeX plugin for Vim
"
" Maintainer: Karl Yngve Lervåg
" Email:      karl.yngve@gmail.com
"

function! vimtex#syntax#p#fontawesome5#load(cfg) abort " {{{1
  if !a:cfg.conceal | return | endif

  call vimtex#syntax#core#new_opt('texFontawesomeOpt', {
        \ 'contains': '',
        \ 'opts': 'conceal contained containedin=texCmdFontawesome',
        \})
  call vimtex#syntax#core#new_arg('texFontawesomeArg', {
        \ 'contains': '',
        \ 'opts': 'conceal contained containedin=texCmdFontawesome',
        \})

  for [l:name, l:symbol] in items(s:fontawesome.regular)
    let l:nameCased = substitute(l:name, '\v%(^|-)(.)', '\u\1', 'g')
    let l:re =
          \ '\v\\fa' . l:nameCased . '>%(\[\w*\])?|'
          \ . '\\faIcon%(\[\w*\])?\{' . l:name . '\}'

    execute printf(
          \ 'syntax match texCmdFontawesome "%s" conceal cchar=%s',
          \ l:re, l:symbol)
  endfor

  for [l:name, l:symbol] in items(s:fontawesome.starred)
    let l:nameCased = substitute(l:name, '\v%(^|-)(.)', '\u\1', 'g')
    let l:re =
          \ '\v\\fa' . l:nameCased . '\*%(\[\w*\])?|'
          \ . '\\faIcon\*%(\[\w*\])?\{' . l:name . '\}'

    execute printf(
          \ 'syntax match texCmdFontawesome "%s" conceal cchar=%s',
          \ l:re, l:symbol)
  endfor

  " This case does not have the \faNameCased variant
  syntax match texCmdFontawesome "\v\\faIcon%(\[\w*\])?\s*\{500px\}" conceal cchar=

  highlight def link texCmdFontawesome texCmd
  highlight def link texFontawesomeArg texArg
  highlight def link texFontawesomeOpt texOpt
endfunction

" }}}1

let s:fontawesome = json_decode(join(
      \ readfile(vimtex#paths#asset('json/fontawesome.json'))
      \))