Compare commits

..

29 Commits

Author SHA1 Message Date
Karl Yngve Lervåg
de61b31cf8 Fixed #663: Correct warning and handling of missing xdotool 2017-02-09 21:54:44 +01:00
Karl Yngve Lervåg
9ef8463dae Fixed #679: Foldtext for indented single_opt 2017-02-09 21:42:18 +01:00
Karl Yngve Lervåg
d57b7720f8 Updated SumatraPDF suggestions according to #680 2017-02-09 21:35:06 +01:00
Karl Yngve Lervåg
008b9eb78d Fixed #682 2017-02-09 21:29:05 +01:00
Karl Yngve Lervåg
e0624cb5e7 Added test files for #682 2017-02-09 21:28:56 +01:00
Karl Yngve Lervåg
beb5d4eb59 Merge pull request #678 from tokoro10g/feature/empty-latexmk-option
Modified latexmk.vim to allow empty option
2017-02-03 12:15:42 +01:00
Teng Tokoro
87ce498b0e Modified latexmk.vim to allow empty option 2017-02-03 15:56:35 +09:00
Karl Yngve Lervåg
a070901fb2 Improve speed of s:is_verbatim 2017-02-01 13:38:14 +01:00
Karl Yngve Lervåg
3e63a12448 Only indent tikz if tikz is loaded 2017-02-01 13:25:56 +01:00
Karl Yngve Lervåg
a5d006513f Improve syntax (due to linter warnings) 2017-02-01 13:23:44 +01:00
Karl Yngve Lervåg
4968c11868 Added vintrc file 2017-02-01 13:23:44 +01:00
Karl Yngve Lervåg
9d614b6a1b Merge Pull Request #674 2017-01-28 23:33:56 +01:00
slaiba
f535f07a6d Modified complete.vim to improve parsing of equation numbers and support subfile command 2017-01-26 20:05:44 +01:00
Karl Yngve Lervåg
2495c848ed Fixed #669: Better bookkeeping and exit handling
* Don't remove blobs on exit
* Properly reuse existing local blobs
2017-01-24 21:36:54 +01:00
Karl Yngve Lervåg
7c1b6c02e7 Merge pull request #672 from zhouyan/patch-1
Use `strchars` for calculating line length
2017-01-24 20:46:29 +01:00
Yan Zhou
8e5ccd4e1c Use strchars for calculating line length
The original, which use `len` to calculate the line length, cause multibyte characters, (such as UTF-8 characters outside the ASCII range) to count as 2 characters or more. And thus visually, the lines look shorter than expected after formatting.

Compare, (`tw = 79`)

New formatting
```
It was in July, 1805, and the speaker was the well-known Anna Pávlovna Schérer,
maid of honor and favorite of the Empress Márya Fëdorovna. With these words she
greeted Prince Vasíli Kurágin, a man of high rank and importance, who was the
first to arrive at her reception. Anna Pávlovna had had a cough for some days.
She was, as she said, suffering from \emph{la grippe;} \emph{grippe} being then
a new word in St.~Petersburg, used only by the elite.
```

Old formatting
```
It was in July, 1805, and the speaker was the well-known Anna Pávlovna
Schérer, maid of honor and favorite of the Empress Márya Fëdorovna. With these
words she greeted Prince Vasíli Kurágin, a man of high rank and importance, who
was the first to arrive at her reception. Anna Pávlovna had had a cough for
some days. She was, as she said, suffering from \emph{la grippe;} \emph{grippe}
being then a new word in St.~Petersburg, used only by the elite.
```
2017-01-24 21:02:54 +08:00
Karl Yngve Lervåg
85cf4215ea Fixed #668: Improve graphics completion 2017-01-21 21:40:48 +01:00
Karl Yngve Lervåg
05697bddb0 Added test files for #664 2017-01-19 22:09:48 +01:00
Karl Yngve Lervåg
96ce49de01 Fixed #664: Regex matched too much 2017-01-19 22:04:58 +01:00
Karl Yngve Lervåg
a9e8f2e502 Must press ENTER (cf. #661) 2017-01-18 21:33:27 +01:00
Karl Yngve Lervåg
10372c7d3a Merge branch 'issue-640/feature/improve-img-completion' 2017-01-18 19:16:17 +01:00
Karl Yngve Lervåg
f86a72ce90 Fixed #640: Parse \graphicspath for img completion
Note: This deprecates the option g:vimtex_complete_img_use_tail!
2017-01-18 19:12:40 +01:00
Karl Yngve Lervåg
c98b178377 Added functions to calculate relative path 2017-01-18 19:12:40 +01:00
Karl Yngve Lervåg
184fca889a Added test files for #640 2017-01-18 19:12:09 +01:00
Karl Yngve Lervåg
b344cfa968 Fixed #660: Error in luacode nested syntax 2017-01-14 22:14:26 +01:00
Karl Yngve Lervåg
ce316881ef Merge pull request #658 from Libbum/docfix
Corrected Okular options in documentation
2017-01-10 20:36:40 +01:00
Tim DuBois
1e565580d5 Fix Okular options 2017-01-10 19:55:32 +01:00
Karl Yngve Lervåg
baa6467bc6 Fixed #649: Silly regex bug 2017-01-04 12:37:36 +01:00
Karl Yngve Lervåg
4c76e8f740 Refactored and improved recursive file finder 2017-01-03 23:25:42 +01:00
34 changed files with 262 additions and 192 deletions

3
.vintrc.yaml Normal file
View File

@ -0,0 +1,3 @@
policies:
ProhibitAbbreviationOption:
enabled: false

View File

@ -81,7 +81,7 @@ if get(g:, 'tex_fast', 'r') =~# 'r'
\ '[Ppf]?[Nn]otecite', \ '[Ppf]?[Nn]otecite',
\] \]
execute 'syntax match texStatement' execute 'syntax match texStatement'
\ '/\v\\' . s:pattern . '\ze\s*\{/' \ '/\v\\' . s:pattern . '\ze\s*%(\[|\{)/'
\ 'nextgroup=texRefOption,texCite' \ 'nextgroup=texRefOption,texCite'
endfor endfor
@ -97,7 +97,7 @@ if get(g:, 'tex_fast', 'r') =~# 'r'
\ 'cite%(field|list|name)', \ 'cite%(field|list|name)',
\] \]
execute 'syntax match texStatement' execute 'syntax match texStatement'
\ '/\v\\' . s:pattern . '\ze\s*\{/' \ '/\v\\' . s:pattern . '\ze\s*%(\[|\{)/'
\ 'nextgroup=texRefOptions,texCites' \ 'nextgroup=texRefOptions,texCites'
endfor endfor
@ -175,12 +175,12 @@ syntax region texZone
\ keepend \ keepend
\ transparent \ transparent
\ contains=texBeginEnd,@LUA \ contains=texBeginEnd,@LUA
syntax region texZone syntax match texStatement '\\\(directlua\|luadirect\)' nextgroup=texZoneLua
\ start='\\\(directlua\|luadirect\){'rs=s syntax region texZoneLua matchgroup=Delimiter
\ end='}'re=e \ start='{'
\ keepend \ end='}'
\ transparent \ contained
\ contains=texBeginEnd,@LUA \ contains=@LUA
let b:current_syntax = 'tex' let b:current_syntax = 'tex'
" }}}1 " }}}1

View File

@ -427,7 +427,7 @@ function! s:init_mappings() " {{{1
call s:map('n', '<localleader>lY', '<plug>(vimtex-labels-toggle)') call s:map('n', '<localleader>lY', '<plug>(vimtex-labels-toggle)')
endif endif
if get(g:, 'vimtex_view_enabled', 0) if has_key(b:vimtex, 'viewer')
call s:map('n', '<localleader>lv', '<plug>(vimtex-view)') call s:map('n', '<localleader>lv', '<plug>(vimtex-view)')
if has_key(b:vimtex.viewer, 'reverse_search') if has_key(b:vimtex.viewer, 'reverse_search')
call s:map('n', '<localleader>lr', '<plug>(vimtex-reverse-search)') call s:map('n', '<localleader>lr', '<plug>(vimtex-reverse-search)')
@ -456,12 +456,20 @@ function! s:init_local_blob() " {{{1
let l:filename = expand('%:p') let l:filename = expand('%:p')
if b:vimtex.tex !=# l:filename if b:vimtex.tex !=# l:filename
let l:vimtex_id = s:get_id(l:filename)
if l:vimtex_id >= 0
let b:vimtex_local = {
\ 'active' : 0,
\ 'main_id' : b:vimtex_id,
\ 'sub_id' : l:vimtex_id,
\}
else
let l:local = deepcopy(b:vimtex) let l:local = deepcopy(b:vimtex)
let l:local.tex = l:filename let l:local.tex = l:filename
let l:local.pid = 0 let l:local.pid = 0
let l:local.name = fnamemodify(l:filename, ':t:r') let l:local.name = fnamemodify(l:filename, ':t:r')
let l:local.root = get(s:, 'root', fnamemodify(l:filename, ':h')) let l:local.root = fnamemodify(l:filename, ':h')
let l:local.base = get(s:, 'base', fnamemodify(l:filename, ':t')) let l:local.base = fnamemodify(l:filename, ':t')
let s:vimtex_next_id += 1 let s:vimtex_next_id += 1
let g:vimtex_data[s:vimtex_next_id] = l:local let g:vimtex_data[s:vimtex_next_id] = l:local
@ -472,12 +480,22 @@ function! s:init_local_blob() " {{{1
\ 'sub_id' : s:vimtex_next_id, \ 'sub_id' : s:vimtex_next_id,
\} \}
endif endif
endif
endfunction endfunction
" }}}1 " }}}1
function! s:init_local_options() " {{{1 function! s:init_local_options() " {{{1
let b:vimtex.sources = [] let b:vimtex.packages = {}
for l:line in vimtex#parser#tex(b:vimtex.tex, {
\ 'detailed' : 0,
\ 're_stop' : '\\begin\s*{document}',
\})
if l:line =~# '\\usepackage.*{tikz}'
let b:vimtex.packages.tikz = 1
endif
endfor
let b:vimtex.sources = []
for [l:file, l:lnum, l:line] in vimtex#parser#tex(b:vimtex.tex) for [l:file, l:lnum, l:line] in vimtex#parser#tex(b:vimtex.tex)
let l:cand = substitute(l:file, '\M' . b:vimtex.root, '', '') let l:cand = substitute(l:file, '\M' . b:vimtex.root, '', '')
if l:cand[0] ==# '/' | let l:cand = l:cand[1:] | endif if l:cand[0] ==# '/' | let l:cand = l:cand[1:] | endif
@ -519,7 +537,8 @@ function! s:get_main() " {{{1
" Search for TEX root specifier at the beginning of file. This is used by " Search for TEX root specifier at the beginning of file. This is used by
" several other plugins and editors. " several other plugins and editors.
" "
let l:candidate = s:get_main_from_texroot() let l:candidate = s:get_main_from_specifier(
\ '^\c\s*%\s*!\?\s*tex\s\+root\s*=\s*\zs.*\ze\s*$')
if !empty(l:candidate) if !empty(l:candidate)
return l:candidate return l:candidate
endif endif
@ -527,7 +546,8 @@ function! s:get_main() " {{{1
" "
" Support for subfiles package " Support for subfiles package
" "
let l:candidate = s:get_main_from_subfile() let l:candidate = s:get_main_from_specifier(
\ '^\C\s*\\documentclass\[\zs.*\ze\]{subfiles}')
if !empty(l:candidate) if !empty(l:candidate)
return l:candidate return l:candidate
endif endif
@ -568,47 +588,21 @@ function! s:get_main() " {{{1
endfunction endfunction
" }}}1 " }}}1
function! s:get_main_from_texroot() " {{{1 function! s:get_main_from_specifier(spec) " {{{1
for l:line in getline(1, 5) for l:line in getline(1, 5)
let l:filename = matchstr(l:line, let l:filename = matchstr(l:line, a:spec)
\ '^\c\s*%\s*!\?\s*tex\s\+root\s*=\s*\zs.*\ze\s*$')
if len(l:filename) > 0 if len(l:filename) > 0
if l:filename[0] ==# '/' if l:filename[0] ==# '/'
if filereadable(l:filename) | return l:filename | endif if filereadable(l:filename) | return l:filename | endif
else else
let l:candidate = simplify(expand('%:p:h') . '/' . l:filename) " The candidate may be relative both to the current buffer file and to
" the working directory (for subfile package)
for l:candidate in map([
\ expand('%:p:h'),
\ getcwd()],
\ 'simplify(v:val . ''/'' . l:filename)')
if filereadable(l:candidate) | return l:candidate | endif if filereadable(l:candidate) | return l:candidate | endif
endif
endif
endfor endfor
return ''
endfunction
" }}}1
function! s:get_main_from_subfile() " {{{1
for l:line in getline(1, 5)
let l:filename = matchstr(l:line,
\ '^\C\s*\\documentclass\[\zs.*\ze\]{subfiles}')
if len(l:filename) > 0
if l:filename[0] ==# '/'
" Specified path is absolute
if filereadable(l:filename) | return l:filename | endif
else
" Try specified path as relative to current file path
let l:candidate = simplify(expand('%:p:h') . '/' . l:filename)
if filereadable(l:candidate) | return l:candidate | endif
" Try specified path as relative to the project main file. This is
" difficult, since the main file is the one we are looking for. We
" therefore assume that the main file lives somewhere upwards in the
" directory tree.
let l:candidate = findfile(l:filename, '.;')
if filereadable(l:candidate)
let s:root = fnamemodify(l:candidate, ':h')
let s:base = strpart(expand('%:p'), len(s:root) + 1)
return l:candidate
endif
endif endif
endif endif
endfor endfor
@ -618,21 +612,7 @@ endfunction
" }}}1 " }}}1
function! s:get_main_latexmain(file) " {{{1 function! s:get_main_latexmain(file) " {{{1
" for l:cand in s:findfiles_recursive('*.latexmain', expand('%:p:h'))
" Gather candidate files
"
let l:path = expand('%:p:h')
let l:dirs = l:path
while l:path != fnamemodify(l:path, ':h')
let l:path = fnamemodify(l:path, ':h')
let l:dirs .= ',' . l:path
endwhile
let l:candidates = split(globpath(fnameescape(l:dirs), '*.latexmain'), '\n')
"
" Use first valid candidate
"
for l:cand in l:candidates
let l:cand = fnamemodify(l:cand, ':p:r') let l:cand = fnamemodify(l:cand, ':p:r')
if s:file_reaches_current(l:cand) if s:file_reaches_current(l:cand)
return l:cand return l:cand
@ -660,20 +640,9 @@ function! s:get_main_recurse(...) " {{{1
endif endif
" "
" Gather candidate files " Search through candidates found recursively upwards in the directory tree
" "
let l:path = fnamemodify(l:file, ':p:h') for l:cand in s:findfiles_recursive('*.tex', fnamemodify(l:file, ':p:h'))
let l:dirs = l:path
while l:path != fnamemodify(l:path, ':h')
let l:path = fnamemodify(l:path, ':h')
let l:dirs .= ',' . l:path
endwhile
let l:candidates = split(globpath(fnameescape(l:dirs), '*.tex'), '\n')
"
" Search through candidates
"
for l:cand in l:candidates
" Avoid infinite recursion (checking the same file repeatedly) " Avoid infinite recursion (checking the same file repeatedly)
if l:cand == l:file | continue | endif if l:cand == l:file | continue | endif
@ -730,6 +699,17 @@ function! s:file_reaches_current(file) " {{{1
return 0 return 0
endfunction endfunction
" }}}1
function! s:findfiles_recursive(expr, path) " {{{1
let l:path = a:path
let l:dirs = l:path
while l:path != fnamemodify(l:path, ':h')
let l:path = fnamemodify(l:path, ':h')
let l:dirs .= ',' . l:path
endwhile
return split(globpath(fnameescape(l:dirs), a:expr), '\n')
endfunction
" }}}1 " }}}1
function! s:get_log() dict " {{{1 function! s:get_log() dict " {{{1
@ -868,7 +848,7 @@ function! s:buffer_deleted(...) " {{{1
" latex project " latex project
" "
if l:count <= 1 if l:count <= 1
let l:vimtex = remove(g:vimtex_data, l:vimtex_id) let l:vimtex = g:vimtex_data[l:vimtex_id]
if exists('#User#VimtexEventQuit') if exists('#User#VimtexEventQuit')
if exists('b:vimtex') if exists('b:vimtex')

View File

@ -10,7 +10,6 @@ function! vimtex#complete#init_options() " {{{1
call vimtex#util#set_default('g:vimtex_complete_close_braces', 0) call vimtex#util#set_default('g:vimtex_complete_close_braces', 0)
call vimtex#util#set_default('g:vimtex_complete_recursive_bib', 0) call vimtex#util#set_default('g:vimtex_complete_recursive_bib', 0)
call vimtex#util#set_default('g:vimtex_complete_img_use_tail', 0)
endfunction endfunction
" }}}1 " }}}1
@ -367,7 +366,8 @@ function! s:ref.parse_number(num_tree) dict " {{{2
return self.parse_number(a:num_tree[l:index]) return self.parse_number(a:num_tree[l:index])
endif endif
else else
return str2nr(a:num_tree) > 0 ? a:num_tree : '-' let l:matches = matchlist(a:num_tree, '\v(^|.*\s)((\u|\d+)(\.\d+)*)($|\s.*)')
return len(l:matches) > 3 ? l:matches[2] : '-'
endif endif
endfunction endfunction
@ -378,39 +378,68 @@ let s:img = {
\ 'patterns' : ['\v\\includegraphics\*?%(\s*\[[^]]*\]){0,2}\s*\{[^}]*$'], \ 'patterns' : ['\v\\includegraphics\*?%(\s*\[[^]]*\]){0,2}\s*\{[^}]*$'],
\ 'ext_re' : '\v\.%(' \ 'ext_re' : '\v\.%('
\ . join(['png', 'jpg', 'eps', 'pdf', 'pgf', 'tikz'], '|') \ . join(['png', 'jpg', 'eps', 'pdf', 'pgf', 'tikz'], '|')
\ . ')$' \ . ')$',
\} \}
function! s:img.complete(regex) dict " {{{2 function! s:img.complete(regex) dict " {{{2
let self.candidates = [] call self.gather_candidates()
let self.candidates = split(globpath(b:vimtex.root, '**/*.*'), '\n')
let l:output = b:vimtex.out() call filter(self.candidates, 'v:val.word =~# a:regex')
call filter(self.candidates, 'v:val !=# l:output')
call filter(self.candidates, 'v:val =~? self.ext_re')
call filter(self.candidates, 'v:val =~# a:regex')
call map(self.candidates, 'strpart(v:val, len(b:vimtex.root)+1)')
call map(self.candidates, '{
\ ''abbr'' : v:val,
\ ''word'' : v:val,
\ ''menu'' : '' [graphics]'',
\ }')
if g:vimtex_complete_img_use_tail
for l:cand in self.candidates
let l:cand.word = fnamemodify(l:cand.word, ':t')
endfor
endif
return self.candidates return self.candidates
endfunction endfunction
function! s:img.graphicspaths() dict " {{{2
" Get preamble text and remove comments
let l:preamble = vimtex#parser#tex(b:vimtex.tex, {
\ 're_stop': '\\begin{document}',
\ 'detailed': 0,
\})
call map(l:preamble, 'substitute(v:val, ''\\\@<!%.*'', '''', '''')')
" Parse preamble for graphicspaths
let l:graphicspaths = []
for l:path in split(matchstr(join(l:preamble, ' '),
\ '\\graphicspath{\s*{\s*\zs.\{-}\ze\s*}\s*}'), '}\s*{')
if l:path[0] ==# '/'
call add(l:graphicspaths, l:path[:-2])
else
call add(l:graphicspaths, simplify(b:vimtex.root . '/' . l:path[:-2]))
endif
endfor
" Project root is always valid
return l:graphicspaths + [b:vimtex.root]
endfunction
" }}}2
function! s:img.gather_candidates() dict " {{{2
let l:added_files = []
let l:generated_pdf = b:vimtex.out()
let self.candidates = []
for l:path in self.graphicspaths()
for l:file in split(globpath(l:path, '**/*.*'), '\n')
if l:file !~? self.ext_re
\ || l:file ==# l:generated_pdf
\ || index(l:added_files, l:file) >= 0 | continue | endif
call add(l:added_files, l:file)
call add(self.candidates, {
\ 'abbr': vimtex#paths#shorten_relative(l:file),
\ 'word': vimtex#paths#relative(l:file, l:path),
\ 'menu': '[graphics]',
\})
endfor
endfor
endfunction
" }}}1 " }}}1
" {{{1 Filenames (\input and \include) " {{{1 Filenames (\input and \include)
let s:inc = { let s:inc = {
\ 'patterns' : ['\v\\%(include%(only)?|input)\s*\{[^}]*$'], \ 'patterns' : ['\v\\%(include%(only)?|input|subfile)\s*\{[^}]*$'],
\} \}
function! s:inc.complete(regex) dict " {{{2 function! s:inc.complete(regex) dict " {{{2

View File

@ -19,7 +19,7 @@ function! vimtex#echo#wait() " {{{1
if filereadable(expand('%')) if filereadable(expand('%'))
echohl VimtexMsg echohl VimtexMsg
call input('Press any key to continue ...') call input('Press ENTER to continue')
echohl None echohl None
else else
sleep 1 sleep 1

View File

@ -118,8 +118,9 @@ endfunction
" }}}1 " }}}1
function! vimtex#env#is_inside(env) " {{{1 function! vimtex#env#is_inside(env) " {{{1
let l:stopline = max([line('.') - 50, 1])
return searchpair('\\begin\s*{' . a:env . '\*\?}', '', return searchpair('\\begin\s*{' . a:env . '\*\?}', '',
\ '\\end\s*{' . a:env . '\*\?}', 'bnW') \ '\\end\s*{' . a:env . '\*\?}', 'bnW', 0, l:stopline)
endfunction endfunction
" }}}1 " }}}1

View File

@ -430,8 +430,9 @@ function! s:cmd_single_opt(cmds) " {{{1
endfunction endfunction
function! l:fold.text(line) dict function! l:fold.text(line) dict
let l:col = strlen(matchstr(a:line, '^\s*')) + 1
return matchstr(a:line, self.re.text) . '[...]{' return matchstr(a:line, self.re.text) . '[...]{'
\ . vimtex#cmd#get_at(v:foldstart, 1).args[0].text . '}' \ . vimtex#cmd#get_at(v:foldstart, l:col).args[0].text . '}'
endfunction endfunction
return l:fold return l:fold

View File

@ -110,7 +110,7 @@ function! s:format(top, bottom) " {{{1
endif endif
" Handle long lines " Handle long lines
if len(l:line) > s:textwidth if strchars(l:line) > s:textwidth
let l:bottom += s:format_build_lines(l:current, l:mark) let l:bottom += s:format_build_lines(l:current, l:mark)
let l:mark = l:current-1 let l:mark = l:current-1
endif endif
@ -160,7 +160,7 @@ function! s:format_build_lines(start, end) " {{{1
let l:lnum = a:start-1 let l:lnum = a:start-1
let l:current = repeat(' ', indent(a:start)) let l:current = repeat(' ', indent(a:start))
for l:word in l:words for l:word in l:words
if len(l:word) + len(l:current) > s:textwidth if strchars(l:word) + strchars(l:current) > s:textwidth
call append(l:lnum, substitute(l:current, '\s$', '', '')) call append(l:lnum, substitute(l:current, '\s$', '', ''))
let l:lnum += 1 let l:lnum += 1
let l:current = repeat(' ', VimtexIndent(a:start)) let l:current = repeat(' ', VimtexIndent(a:start))

View File

@ -15,7 +15,8 @@ function! vimtex#latexmk#init_options() " {{{1
call vimtex#util#set_default('g:vimtex_latexmk_background', 0) call vimtex#util#set_default('g:vimtex_latexmk_background', 0)
call vimtex#util#set_default('g:vimtex_latexmk_callback', 1) call vimtex#util#set_default('g:vimtex_latexmk_callback', 1)
call vimtex#util#set_default('g:vimtex_latexmk_continuous', 1) call vimtex#util#set_default('g:vimtex_latexmk_continuous', 1)
call vimtex#util#set_default('g:vimtex_latexmk_options', '') call vimtex#util#set_default('g:vimtex_latexmk_options',
\ '-verbose -pdf -file-line-error -synctex=1 -interaction=nonstopmode')
call vimtex#util#set_default('g:vimtex_quickfix_autojump', '0') call vimtex#util#set_default('g:vimtex_quickfix_autojump', '0')
call vimtex#util#set_default('g:vimtex_quickfix_ignore_all_warnings', 0) call vimtex#util#set_default('g:vimtex_quickfix_ignore_all_warnings', 0)
call vimtex#util#set_default('g:vimtex_quickfix_ignored_warnings', []) call vimtex#util#set_default('g:vimtex_quickfix_ignored_warnings', [])
@ -580,13 +581,7 @@ function! s:latexmk_build_cmd() " {{{1
endif endif
endif endif
" Add general options for latexmk
if !empty(g:vimtex_latexmk_options)
let cmd .= ' ' . g:vimtex_latexmk_options let cmd .= ' ' . g:vimtex_latexmk_options
else
let cmd .= ' -verbose -pdf -file-line-error'
let cmd .= ' -synctex=1 -interaction=nonstopmode'
endif
if g:vimtex_latexmk_build_dir !=# '' if g:vimtex_latexmk_build_dir !=# ''
let cmd .= ' -outdir=' . g:vimtex_latexmk_build_dir let cmd .= ' -outdir=' . g:vimtex_latexmk_build_dir
@ -667,13 +662,7 @@ function! s:latexmk_build_cmd_selected(fname) " {{{1
endif endif
endif endif
" Add general options for latexmk
if !empty(g:vimtex_latexmk_options)
let cmd .= ' ' . g:vimtex_latexmk_options let cmd .= ' ' . g:vimtex_latexmk_options
else
let cmd .= ' -verbose -pdf -file-line-error'
let cmd .= ' -synctex=1 -interaction=nonstopmode'
endif
let cmd .= ' ' . vimtex#util#shellescape(a:fname) let cmd .= ' ' . vimtex#util#shellescape(a:fname)

44
autoload/vimtex/paths.vim Normal file
View File

@ -0,0 +1,44 @@
" vimtex - LaTeX plugin for Vim
"
" Maintainer: Karl Yngve Lervåg
" Email: karl.yngve@gmail.com
"
function! vimtex#paths#shorten_relative(path) " {{{1
" Input: An absolute path
" Output: Relative path with respect to the vimtex root, path relative to
" vimtex root (unless absolute path is shorter)
let l:relative = vimtex#paths#relative(a:path, b:vimtex.root)
return strlen(l:relative) < strlen(a:path)
\ ? l:relative : a:path
endfunction
" }}}1
function! vimtex#paths#relative(path, current) " {{{1
" Note: This algorithm is based on the one presented by @Offirmo at SO,
" http://stackoverflow.com/a/12498485/51634
let l:target = a:path
let l:common = a:current
let l:result = ''
while substitute(l:target, '^' . l:common, '', '') ==# l:target
let l:common = fnamemodify(l:common, ':h')
let l:result = empty(l:result) ? '..' : '../' . l:result
endwhile
if l:common ==# '/'
let l:result .= '/'
endif
let l:forward = substitute(l:target, '^' . l:common, '', '')
if !empty(l:forward)
let l:result = empty(l:result)
\ ? l:forward[1:]
\ : l:result . l:forward
endif
return l:result
endfunction
" }}}1

View File

@ -24,8 +24,7 @@ function! vimtex#view#zathura#new() " {{{1
" Check if the xdotool is available " Check if the xdotool is available
" "
if !executable('xdotool') if !executable('xdotool')
call vimtex#echo#warning('Zathura requires xdotool!') call vimtex#echo#warning('Zathura requires xdotool for forward search!')
return {}
endif endif
" "

View File

@ -375,12 +375,6 @@ Options~
Default value: 0 Default value: 0
*g:vimtex_complete_img_use_tail*
If enabled, only the tail part of file names are completed. This is useful
if one uses the `graphicx` package and the `\graphicspath` command.
Default value: 0
*g:vimtex_delim_toggle_mod_list* *g:vimtex_delim_toggle_mod_list*
Define list of delimiter modifiers to toggle through with Define list of delimiter modifiers to toggle through with
|<plug>(vimtex-delim-toggle-modifier)|. |<plug>(vimtex-delim-toggle-modifier)|.
@ -769,8 +763,8 @@ Options~
-synctex=1 -- Generate synctex data -synctex=1 -- Generate synctex data
-interaction=nonstopmode -- Disable interactive mode -interaction=nonstopmode -- Disable interactive mode
< However, if `g:vimtex_latexmk_options` is defined and is nonzero, it will < However, if `g:vimtex_latexmk_options` is defined, it will override the
override the above with the user supplied options. above with the user supplied options.
Note: Options may also be specified indirectly to `latexmk` through Note: Options may also be specified indirectly to `latexmk` through
both a global and a project specific `.latexmkrc` file. One should both a global and a project specific `.latexmkrc` file. One should
@ -779,7 +773,8 @@ Options~
one has to set `g:vimtex_latexmk_options` to a string that contains one has to set `g:vimtex_latexmk_options` to a string that contains
the desired options. the desired options.
Default value: '' Default value:
'-verbose -pdf -file-line-error -synctex=1 -interaction=nonstopmode'
*g:vimtex_latexmk_progname* *g:vimtex_latexmk_progname*
Path to vim executable. This is used for the callback functionality, and it Path to vim executable. This is used for the callback functionality, and it
@ -921,7 +916,7 @@ Options~
and backward search. Recommended settings are: > and backward search. Recommended settings are: >
let g:vimtex_view_general_viewer = 'okular' let g:vimtex_view_general_viewer = 'okular'
let g:vimtex_view_general_options = '--unique @pdf\#src:@line@tex' let g:vimtex_view_general_options = '--unique file:@pdf\#src:@line@tex'
let g:vimtex_view_general_options_latexmk = '--unique' let g:vimtex_view_general_options_latexmk = '--unique'
< Backward search must be set up from the viewer through < Backward search must be set up from the viewer through
@ -991,13 +986,15 @@ Options~
the command line. This can be utilized to set the correct the command line. This can be utilized to set the correct
|servername| for inverse search: > |servername| for inverse search: >
let g:vimtex_view_general_viewer = 'SumatraPDF -reuse-instance ' let g:vimtex_view_general_viewer = 'SumatraPDF'
let g:vimtex_view_general_options
\ = '-reuse-instance -forward-search @tex @line @pdf'
\ . '-inverse-search "gvim --servername ' . v:servername \ . '-inverse-search "gvim --servername ' . v:servername
\ . ' --remote-send \"^<C-\^>^<C-n^>' \ . ' --remote-send \"^<C-\^>^<C-n^>'
\ . ':drop \%f^<CR^>:\%l^<CR^>:normal\! zzzv^<CR^>' \ . ':drop \%f^<CR^>:\%l^<CR^>:normal\! zzzv^<CR^>'
\ . ':execute ''drop '' . fnameescape(''\%f'')^<CR^>' \ . ':execute ''drop '' . fnameescape(''\%f'')^<CR^>'
\ . ':\%l^<CR^>:normal\! zzzv^<CR^>' \ . ':\%l^<CR^>:normal\! zzzv^<CR^>'
\ . ':call remote_foreground('''.v:servername.''')^<CR^>\""' \ . ':call remote_foreground('''.v:servername.''')^<CR^>^<CR^>\""'
< <
*vimtex_viewer_mupdf* *vimtex_viewer_mupdf*
http://www.mupdf.com/ http://www.mupdf.com/
@ -2008,9 +2005,9 @@ to go from a specific position in the pdf file to the corresponding position
in vim (inverse/backward search). in vim (inverse/backward search).
To make synctex work, it must be enabled. vimtex enables this by default by To make synctex work, it must be enabled. vimtex enables this by default by
passing `-synctex=1` on the command line, unless the user sets the option passing `-synctex=1` on the command line, unless the user overrides the option
|g:vimtex_latexmk_options| to a nonempty value. In the latter case, the user |g:vimtex_latexmk_options|. In the latter case, the user should ensure that the
should ensure that the synctex flag is passed, i.e. with: > synctex flag is passed, i.e. with: >
let g:vimtex_latexmk_options = '... -synctex=1 ...' let g:vimtex_latexmk_options = '... -synctex=1 ...'

View File

@ -16,8 +16,8 @@ call vimtex#util#set_default('g:vimtex_indent_ignored_envs', [
\ 'document', \ 'document',
\]) \])
let s:cpo_save = &cpo let s:cpo_save = &cpoptions
set cpo&vim set cpoptions&vim
setlocal autoindent setlocal autoindent
setlocal indentexpr=VimtexIndent(v:lnum) setlocal indentexpr=VimtexIndent(v:lnum)
@ -80,9 +80,8 @@ endfunction
" }}}1 " }}}1
function! s:is_verbatim(line, lnum) " {{{1 function! s:is_verbatim(line, lnum) " {{{1
let l:env = a:line !~# '\v\\%(begin|end)\{%(verbatim|lstlisting|minted)' return a:line !~# '\v\\%(begin|end)\{%(verbatim|lstlisting|minted)'
let l:syn = synIDattr(synID(a:lnum, 1, 1), 'name') ==# 'texZone' \ && vimtex#env#is_inside('\%(lstlisting\|verbatim\|minted\)')
return l:env && l:syn
endfunction endfunction
" }}}1 " }}}1
@ -138,6 +137,8 @@ let s:re_delims = vimtex#delim#get_delim_regexes()
" }}}1 " }}}1
function! s:indent_tikz(lnum, prev) " {{{1 function! s:indent_tikz(lnum, prev) " {{{1
if !has_key(b:vimtex.packages, 'tikz') | return 0 | endif
let l:env_lnum = vimtex#env#is_inside('tikzpicture') let l:env_lnum = vimtex#env#is_inside('tikzpicture')
if l:env_lnum > 0 && l:env_lnum < a:lnum if l:env_lnum > 0 && l:env_lnum < a:lnum
let l:prev_starts = a:prev =~# s:tikz_commands let l:prev_starts = a:prev =~# s:tikz_commands
@ -267,7 +268,7 @@ endfunction
" }}}1 " }}}1
let &cpo = s:cpo_save let &cpoptions = s:cpo_save
unlet s:cpo_save unlet s:cpo_save
" vim: fdm=marker sw=2 " vim: fdm=marker sw=2

View File

@ -90,6 +90,8 @@ const double pi = 3.1415926535
% Cite commands % Cite commands
\cite{} \cite{}
\citet*{} \citet*{}
\citep{bibtexkey1}
\citep[e.g.][]{bibtexkey2}
\citealt{} \citealt{}
\citealt*{} \citealt*{}
\citealp{} \citealp{}
@ -102,6 +104,18 @@ const double pi = 3.1415926535
\citeyearpar{} \citeyearpar{}
\bibentry{} \bibentry{}
\directlua{
if pdf.getminorversion() \string~= 7 then
print "pfd version 1.7"
end
}
\begin{luacode}
if pdf.getminorversion() \string~= 7 then
print "pfd version 1.7"
end
\end{luacode}
\end{document} \end{document}
% vim: fdl=9 % vim: fdl=9

View File

@ -1,2 +0,0 @@
\ProvidesPackage{localpackage}
\endinput

View File

@ -1,10 +0,0 @@
\documentclass{article}
\usepackage{filecontents}
\usepackage{subfiles}
\usepackage{localpackage}
\begin{document}
\subfile{sub/sub.tex}
b
\end{document}

View File

@ -1,17 +0,0 @@
set nocompatible
let &rtp = '~/.vim/bundle/vimtex,' . &rtp
let &rtp .= ',~/.vim/bundle/vimtex/after'
filetype plugin indent on
syntax enable
let g:tex_flavor = "latex"
let g:vimtex_latexmk_background = 1
let g:vimtex_view_general_viewer = 'SumatraPDF'
let g:vimtex_view_general_options =
\ '-reuse-instance -forward-search @line @pdf @tex'
let g:vimtex_view_general_options_latexmk = '-reuse-instance'
if !has('win32')
echoerr 'This test case should be run on windows!'
endif

View File

@ -1,5 +0,0 @@
\documentclass[main.tex]{subfiles}
\begin{document}
a
\end{document}

View File

View File

View File

View File

@ -0,0 +1,13 @@
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\graphicspath{{test} {testing}%
{../}
{../testagain/}
}
\begin{document}
\includegraphics[width=0.9\linewidth]{}
\end{document}

View File

View File

View File

View File

View File

View File

View File

View File

@ -0,0 +1,5 @@
set nocompatible
let &rtp = '~/.vim/bundle/vimtex,' . &rtp
let &rtp .= ',~/.vim/bundle/vimtex/after'
filetype plugin indent on
syntax enable

15
test/issues/664/test.tex Normal file
View File

@ -0,0 +1,15 @@
\documentclass{beamer}
\graphicspath{{figs1/}{figs2/}}
\begin{textblock*}{100mm}(\textwidth, 0.1cm)
\includegraphics[height=0.9cm]{fig1_1.png}
\end{textblock*}}
\begin{document}
\begin{frame}
\titlepage
\includegraphics[width=0.9\linewidth]{}
\end{frame}
\end{document}

View File

@ -0,0 +1,9 @@
set nocompatible
let &rtp = '~/.vim/bundle/vimtex,' . &rtp
let &rtp .= ',~/.vim/bundle/vimtex/after'
filetype plugin indent on
syntax enable
let g:vimtex_view_enabled = 1
edit test.sty
quit

3
test/issues/682/test.sty Normal file
View File

@ -0,0 +1,3 @@
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{varticle}
\endimput

View File

@ -141,8 +141,9 @@ Given tex (Indent: tikz):
\end{axis} \end{axis}
\end{tikzpicture} \end{tikzpicture}
Do (Indent): Execute (Indent):
gg=G let b:vimtex.packages.tikz = 1
normal gg=G
Expect tex (Verify): Expect tex (Verify):
\tikz \fill[green] rectangle (0.5,0.5); Something \tikz \fill[green] rectangle (0.5,0.5); Something