Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions autoload/vimtex/fzf.vim
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,21 @@ function! vimtex#fzf#run(...) abort " {{{1
" Note: The '--with-nth 3..' option hides the first two words from the fzf
" window. These words are the file name and line number and are used by
" the sink.
" Using \u2007 as delimiter allows spaces in the file path, while
" keeping the visuals in fzf window unaffected.
let l:opts = extend({
\ 'source': <sid>parse_toc(a:0 == 0 ? 'ctli' : a:1),
\ 'sink': function('vimtex#fzf#open_selection'),
\ 'options': '--ansi --with-nth 3..',
\ 'options': "--ansi --with-nth 3.. --delimiter '\u2007'",
\}, a:0 > 1 ? a:2 : {})

call fzf#run(l:opts)
endfunction

" }}}1
function! vimtex#fzf#open_selection(sel) abort " {{{1
let line = split(a:sel)[0]
let file = split(a:sel)[1]
let line = split(a:sel, '\%u2007')[0]
let file = split(a:sel, '\%u2007')[1]
let curr_file = expand('%:p')

if curr_file == file
Expand Down Expand Up @@ -91,7 +93,9 @@ def colorize(e):

def create_candidate(e, depth):
number = format_number(dict(e['number']))
return f"{e.get('line', 0)} {e['file']} {colorize(e)} {number}"
return (
f"{e.get('line', 0)}\u2007{e['file']}\u2007{colorize(e)}\u2007{number}"
)

entries = vim.eval('vimtex#parser#toc()')
depth = max([int(e['level']) for e in entries])
Expand Down