Add support for hyperref command (#399)
This commit is contained in:
parent
1aabb84fa7
commit
d169631706
@ -39,7 +39,8 @@ for [style, group, commands] in [
|
|||||||
endfor
|
endfor
|
||||||
|
|
||||||
" }}}1
|
" }}}1
|
||||||
" {{{1 Add syntax highlighting for \url and \href
|
" {{{1 Add syntax highlighting for \url, \href, \hyperref
|
||||||
|
|
||||||
syntax match texStatement '\\url\ze[^\ta-zA-Z]' nextgroup=texUrlVerb
|
syntax match texStatement '\\url\ze[^\ta-zA-Z]' nextgroup=texUrlVerb
|
||||||
syntax match texStatement '\\url\ze\s*{' nextgroup=texUrl
|
syntax match texStatement '\\url\ze\s*{' nextgroup=texUrl
|
||||||
syntax match texStatement '\\href' nextgroup=texHref
|
syntax match texStatement '\\href' nextgroup=texHref
|
||||||
@ -53,10 +54,14 @@ syntax region texHref matchgroup=Delimiter start='{' end='}' contained
|
|||||||
syntax region texHrefLinkText matchgroup=Delimiter start='{' end='}' contained
|
syntax region texHrefLinkText matchgroup=Delimiter start='{' end='}' contained
|
||||||
\ contains=@Spell
|
\ contains=@Spell
|
||||||
|
|
||||||
|
syntax match texStatement '\\hyperref' nextgroup=texHyperref
|
||||||
|
syntax region texHyperref matchgroup=Delimiter start='\[' end='\]' contained
|
||||||
|
|
||||||
highlight link texUrl Function
|
highlight link texUrl Function
|
||||||
highlight link texUrlVerb texUrl
|
highlight link texUrlVerb texUrl
|
||||||
highlight link texHref texUrl
|
highlight link texHref texUrl
|
||||||
highlight link texHrefLinkText texSectionZone
|
highlight link texHrefLinkText texSectionZone
|
||||||
|
highlight link texHyperref texRefZone
|
||||||
|
|
||||||
" }}}1
|
" }}}1
|
||||||
" {{{1 Improve support for cite commands
|
" {{{1 Improve support for cite commands
|
||||||
|
@ -37,23 +37,26 @@ endfunction
|
|||||||
|
|
||||||
function! vimtex#complete#omnifunc(findstart, base) " {{{1
|
function! vimtex#complete#omnifunc(findstart, base) " {{{1
|
||||||
if a:findstart
|
if a:findstart
|
||||||
let pos = col('.') - 1
|
let l:pos = col('.') - 1
|
||||||
let line = getline('.')[:pos-1]
|
let l:line = getline('.')[:l:pos-1]
|
||||||
for l:completer in s:completers
|
for l:completer in s:completers
|
||||||
if !get(l:completer, 'enabled', 0) | return -3 | endif
|
if !get(l:completer, 'enabled', 0) | return -3 | endif
|
||||||
|
|
||||||
if line =~# l:completer.pattern . '$'
|
for l:pattern in l:completer.patterns
|
||||||
|
if l:line =~# l:pattern
|
||||||
let s:completer = l:completer
|
let s:completer = l:completer
|
||||||
while pos > 0
|
while l:pos > 0
|
||||||
if line[pos - 1] =~# '{\|,' || line[pos-2:pos-1] ==# ', '
|
if l:line[l:pos - 1] =~# '{\|,\|\['
|
||||||
return pos
|
\ || l:line[l:pos-2:l:pos-1] ==# ', '
|
||||||
|
return l:pos
|
||||||
else
|
else
|
||||||
let pos -= 1
|
let l:pos -= 1
|
||||||
endif
|
endif
|
||||||
endwhile
|
endwhile
|
||||||
return -2
|
return -2
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
endfor
|
||||||
return -3
|
return -3
|
||||||
else
|
else
|
||||||
return s:close_braces(s:completer.complete(a:base))
|
return s:close_braces(s:completer.complete(a:base))
|
||||||
@ -68,7 +71,7 @@ endfunction
|
|||||||
" {{{1 Bibtex
|
" {{{1 Bibtex
|
||||||
|
|
||||||
let s:bib = {
|
let s:bib = {
|
||||||
\ 'pattern' : '\v\\\a*cite\a*%(\s*\[[^]]*\]){0,2}\s*\{[^}]*',
|
\ 'patterns' : ['\v\\\a*cite\a*%(\s*\[[^]]*\]){0,2}\s*\{[^}]*$'],
|
||||||
\ 'enabled' : 1,
|
\ 'enabled' : 1,
|
||||||
\ 'bibs' : '''\v%(%(\\@<!%(\\\\)*)@<=\%.*)@<!'
|
\ 'bibs' : '''\v%(%(\\@<!%(\\\\)*)@<=\%.*)@<!'
|
||||||
\ . '\\(bibliography|add(bibresource|globalbib|sectionbib))'
|
\ . '\\(bibliography|add(bibresource|globalbib|sectionbib))'
|
||||||
@ -223,7 +226,10 @@ endfunction
|
|||||||
" {{{1 Labels
|
" {{{1 Labels
|
||||||
|
|
||||||
let s:ref = {
|
let s:ref = {
|
||||||
\ 'pattern' : '\v\\v?%(auto|eq|[cC]?%(page)?|labelc)?ref%(\s*\{[^}]*|range\s*\{[^,{}]*%(\}\{)?)',
|
\ 'patterns' : [
|
||||||
|
\ '\v\\v?%(auto|eq|[cC]?%(page)?|labelc)?ref%(\s*\{[^}]*|range\s*\{[^,{}]*%(\}\{)?)$',
|
||||||
|
\ '\\hyperref\s*\[[^]]*$'
|
||||||
|
\ ],
|
||||||
\ 'enabled' : 1,
|
\ 'enabled' : 1,
|
||||||
\ 'cache' : {},
|
\ 'cache' : {},
|
||||||
\}
|
\}
|
||||||
@ -337,7 +343,7 @@ endfunction
|
|||||||
" {{{1 Filenames (\includegraphics)
|
" {{{1 Filenames (\includegraphics)
|
||||||
|
|
||||||
let s:img = {
|
let s:img = {
|
||||||
\ 'pattern' : '\v\\includegraphics\*?%(\s*\[[^]]*\]){0,2}\s*\{[^}]*',
|
\ 'patterns' : ['\v\\includegraphics\*?%(\s*\[[^]]*\]){0,2}\s*\{[^}]*$'],
|
||||||
\ 'enabled' : 1,
|
\ 'enabled' : 1,
|
||||||
\}
|
\}
|
||||||
|
|
||||||
@ -370,7 +376,7 @@ endfunction
|
|||||||
" {{{1 Filenames (\input and \include)
|
" {{{1 Filenames (\input and \include)
|
||||||
|
|
||||||
let s:inc = {
|
let s:inc = {
|
||||||
\ 'pattern' : '\v\\%(include%(only)?|input)\s*\{[^}]*',
|
\ 'patterns' : ['\v\\%(include%(only)?|input)\s*\{[^}]*$'],
|
||||||
\ 'enabled' : 1,
|
\ 'enabled' : 1,
|
||||||
\}
|
\}
|
||||||
|
|
||||||
@ -390,7 +396,7 @@ endfunction
|
|||||||
" {{{1 Glossary
|
" {{{1 Glossary
|
||||||
|
|
||||||
let s:gls = {
|
let s:gls = {
|
||||||
\ 'pattern' : '\v\\gls\s*\{[^}]*',
|
\ 'patterns' : ['\v\\gls\s*\{[^}]*$'],
|
||||||
\ 'enabled' : 1,
|
\ 'enabled' : 1,
|
||||||
\}
|
\}
|
||||||
|
|
||||||
|
@ -1456,6 +1456,7 @@ documents with |neocomplete| and |vimtex|s omni completion function: >
|
|||||||
\ '\v\\%('
|
\ '\v\\%('
|
||||||
\ . '\a*cite\a*%(\s*\[[^]]*\]){0,2}\s*\{[^}]*'
|
\ . '\a*cite\a*%(\s*\[[^]]*\]){0,2}\s*\{[^}]*'
|
||||||
\ . '|\a*ref%(\s*\{[^}]*|range\s*\{[^,}]*%(}\{)?)'
|
\ . '|\a*ref%(\s*\{[^}]*|range\s*\{[^,}]*%(}\{)?)'
|
||||||
|
\ . '|hyperref\s*\[[^]]*'
|
||||||
\ . '|includegraphics\*?%(\s*\[[^]]*\]){0,2}\s*\{[^}]*'
|
\ . '|includegraphics\*?%(\s*\[[^]]*\]){0,2}\s*\{[^}]*'
|
||||||
\ . '|%(include%(only)?|input)\s*\{[^}]*'
|
\ . '|%(include%(only)?|input)\s*\{[^}]*'
|
||||||
\ . ')'
|
\ . ')'
|
||||||
|
@ -81,6 +81,7 @@ const double pi = 3.1415926535
|
|||||||
\url+http://www.google.com+
|
\url+http://www.google.com+
|
||||||
\href{http://example.com}{Title text}
|
\href{http://example.com}{Title text}
|
||||||
\urldef{\mysite}\url{http://example.com}
|
\urldef{\mysite}\url{http://example.com}
|
||||||
|
\hyperref[asdasd]{asd}
|
||||||
|
|
||||||
\end{document}
|
\end{document}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user