Skip to content

Commit f20b114

Browse files
committed
feat(syntax): support zref-clever
refer: #2394
1 parent c50ba2f commit f20b114

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
" VimTeX - LaTeX plugin for Vim
2+
"
3+
" Maintainer: Karl Yngve Lervåg
4+
" Email: karl.yngve@gmail.com
5+
"
6+
7+
function! vimtex#syntax#p#zref_clever#load(cfg) abort " {{{1
8+
syntax match texCmdZRef "\v\\zc?ref>"
9+
\ skipwhite skipnl
10+
\ nextgroup=texZRefArg
11+
12+
syntax match texCmdZRef "\\zlabel\>"
13+
\ skipwhite skipnl
14+
\ nextgroup=texZRefOpt,texRefArg
15+
16+
call vimtex#syntax#core#new_arg('texZRefArg', {
17+
\ 'contains': 'texComment,@NoSpell',
18+
\})
19+
call vimtex#syntax#core#new_opt('texZRefOpt', {
20+
\ 'next': 'texRefArg',
21+
\ 'opts': 'oneline',
22+
\})
23+
24+
highlight def link texZRefArg texRefArg
25+
highlight def link texZRefOpt texRefOpt
26+
highlight def link texCmdZRef texCmdRef
27+
endfunction
28+
29+
" }}}1

test/test-syntax/test-zref.tex

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
\documentclass{scrartcl}
2+
\usepackage{amsmath}
3+
\usepackage{hyperref}
4+
\usepackage{zref-user}
5+
\usepackage{zref-clever}
6+
7+
\begin{document}
8+
9+
\section{sub3 with spaces}\zlabel{sec:sub3 with spaces}
10+
11+
\begin{equation}
12+
f(x) = 42
13+
\label{eq:sub3 with spaces}
14+
\end{equation}
15+
16+
This is \zcref{sec:sub3 with spaces}, and \zcref{eq:sub3 with spaces} is up top.
17+
The same here, but without anything clever done to it: \zref{eq:sub3 with spaces}.
18+
19+
\end{document}

0 commit comments

Comments
 (0)