Closed user202729 closed 1 month ago
Thanks, I don't see any reason not to add this. It seems backward compatible and will allow to pass the column position if you are able to get it. It's probably not useful to most people right now, but perhaps it may be useful to more people in the future.
Maybe it's a good idea to configure the -x
flag passed to zathura in autoload/vimtex/view/zathura.vim
too.
function! vimtex#view#zathura#cmdline(outfile, synctex, start) abort " {{{1
let l:cmd = 'zathura'
if a:start
let l:cmd .= ' ' . g:vimtex_view_zathura_options
if a:synctex
let l:cmd .= printf(
\ ' -x "%s -c \"VimtexInverseSearch %%{line} ''%%{input}''\""',
\ s:inverse_search_cmd)
endif
endif
Edit %%{line}
to %%{line}:%%{column}
, I think. (zathura has been supporting %{column}
since forever despite no actual support from from synctex so it should be safe right?)
Also at the moment looks like zathura will return -1 if column number is not supported. So it would be a good idea to
diff --git a/plugin/vimtex.vim b/plugin/vimtex.vim
index 72ea520c..624aec38 100644
--- a/plugin/vimtex.vim
+++ b/plugin/vimtex.vim
@@ -19,14 +19,14 @@ function! s:parse_args(args) abort
" parse_args("5 a.tex") = [5, 'a.tex', 0]
" parse_args("5 'a.tex'") = [5, 'a.tex', 0]
" parse_args("5:3 a.tex") = [5, 'a.tex', 3]
- let l:matchlist = matchlist(a:args, '^\s*\(\d\+\)\%(:\(\d\+\)\)\?\s\+\(.*\)')
- if empty(l:matchlist) | return [-1, ''] | endif
+ let l:matchlist = matchlist(a:args, '^\s*\(\d\+\)\%(:\(-\?\d\+\)\)\?\s\+\(.*\)')
+ if empty(l:matchlist) | return [-1, '', 0] | endif
let l:lnum = str2nr(l:matchlist[1])
let l:cnum = str2nr(l:matchlist[2])
let l:file = l:matchlist[3]
let l:file = substitute(l:file, '\v^([''"])(.*)\1\s*', '\2', '')
- if empty(l:file) | return [-1, ''] | endif
+ if empty(l:file) | return [-1, '', 0] | endif
return [l:lnum, l:file, l:cnum]
endfunction
Thanks!
Is your feature request related to a problem? Please describe it.
Currently,
VimtexInverseSearch
only supports passing line and file. It would be nice if it support column as well.That said, currently TeX itself does not output column information. But this is in theory possible, I have a preliminary patch to luatex that implements this. https://github.com/user202729/luatex/tree/synctex-column
Since it's a lot of hassle to recompile LuaTeX just for this, this is a TeX+PDF+synctex file which hopefully is testable. a.zip
Describe the solution you'd like Maybe something like this? (I try to make the change backwards compatible. Not sure about other editors but the suggested command works for Zathura for me.)