-
Notifications
You must be signed in to change notification settings - Fork 391
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(syntax): add initial support for unicode-math
refer: #3004
- Loading branch information
Showing
3 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
" VimTeX - LaTeX plugin for Vim | ||
" | ||
" Maintainer: Karl Yngve Lervåg | ||
" Email: [email protected] | ||
" | ||
|
||
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 | ||
endif | ||
endfunction | ||
|
||
" }}}1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
\documentclass{minimal} | ||
\usepackage{unicode-math} | ||
|
||
\begin{document} | ||
|
||
\begin{equation} | ||
\symbb{P} | ||
\symbf{test} | ||
\symcal{a} | ||
\symcal{A} | ||
\symbfcal{a} | ||
\symbfcal{A} | ||
\symcal{aA} | ||
\symfrak{b} | ||
\symfrak{B} | ||
\symbffrak{b} | ||
\symbffrak{B} | ||
\symit{italized} | ||
\symbfit{bold itals} | ||
\symnormal{Re} | ||
\symrm{Re} | ||
\symsf{aA} | ||
\symtt{aA} | ||
\symscr{aA} | ||
\end{equation} | ||
|
||
\end{document} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
source common.vim | ||
|
||
EditConcealed test-unicode-math.tex | ||
|
||
if empty($INMAKE) | finish | endif | ||
|
||
call vimtex#test#finished() |