Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions autoload/vimtex/options.vim
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,7 @@ function! s:init_highlights() abort " {{{1
\ ['VimtexWarning', 'WarningMsg'],
\ ['VimtexError', 'Error'],
\ ['VimtexFatal', 'ErrorMsg'],
\ ['VimtexBlink', 'PMenu'],
\ ['VimtexTocHelp', 'helpVim'],
\ ['VimtexTocHelpKey', 'ModeMsg'],
\ ['VimtexTocHelpLayerOn', 'Statement'],
Expand Down
49 changes: 25 additions & 24 deletions autoload/vimtex/ui.vim
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
" Email: [email protected]
"

function! vimtex#ui#echo(input, ...) abort " {{{1
function! vimtex#ui#echo(input, ...) abort
if empty(a:input) | return | endif
let l:opts = extend({'indent': 0}, a:0 > 0 ? a:1 : {})

Expand All @@ -19,14 +19,11 @@ function! vimtex#ui#echo(input, ...) abort " {{{1
endif
endfunction

" }}}1

function! vimtex#ui#confirm(prompt) abort " {{{1
function! vimtex#ui#confirm(prompt) abort
return vimtex#ui#{g:vimtex_ui_method.confirm}#confirm(a:prompt)
endfunction

" }}}1
function! vimtex#ui#input(options) abort " {{{1
function! vimtex#ui#input(options) abort
let l:options = extend({
\ 'prompt': '> ',
\ 'text': '',
Expand All @@ -36,8 +33,7 @@ function! vimtex#ui#input(options) abort " {{{1
return vimtex#ui#{g:vimtex_ui_method.input}#input(l:options)
endfunction

" }}}1
function! vimtex#ui#menu(actions) abort " {{{1
function! vimtex#ui#menu(actions) abort
" Argument: The 'actions' argument is a dictionary/object which contains
" a list of menu items and corresponding actions (dict functions).
" Something like this:
Expand Down Expand Up @@ -69,8 +65,7 @@ function! vimtex#ui#menu(actions) abort " {{{1
endtry
endfunction

" }}}1
function! vimtex#ui#select(container, ...) abort " {{{1
function! vimtex#ui#select(container, ...) abort
let l:options = extend(
\ {
\ 'prompt': 'Please choose item:',
Expand Down Expand Up @@ -100,9 +95,7 @@ function! vimtex#ui#select(container, ...) abort " {{{1
return l:index
endfunction

" }}}1

function! vimtex#ui#get_number(max, digits, force_choice, do_echo) abort " {{{1
function! vimtex#ui#get_number(max, digits, force_choice, do_echo) abort
let l:choice = ''

if a:do_echo
Expand Down Expand Up @@ -140,9 +133,7 @@ function! vimtex#ui#get_number(max, digits, force_choice, do_echo) abort " {{{1
return l:choice - 1
endfunction

" }}}1

function! vimtex#ui#get_winwidth() abort " {{{1
function! vimtex#ui#get_winwidth() abort
let l:numwidth = (&number || &relativenumber)
\ ? max([&numberwidth, strlen(line('$')) + 1])
\ : 0
Expand Down Expand Up @@ -175,16 +166,29 @@ function! vimtex#ui#get_winwidth() abort " {{{1
return winwidth(0) - l:numwidth - l:foldwidth - l:signwidth
endfunction

" }}}1
function! vimtex#ui#blink() abort
call sign_define('vimtexblink', #{ linehl: 'VimtexBlink' })

for i in range(1, 4)
call sign_place(1, 'vimtex', 'vimtexblink', '', #{ lnum: '.' })
redraw
sleep 150m
call sign_unplace('vimtex')
redraw
sleep 150m
endfor

function! s:echo_string(msg, opts) abort " {{{1
call sign_undefine("vimtexblink")
endfunction


function! s:echo_string(msg, opts) abort
echohl VimtexMsg
echo repeat(' ', a:opts.indent) . a:msg
echohl None
endfunction

" }}}1
function! s:echo_formatted(parts, opts) abort " {{{1
function! s:echo_formatted(parts, opts) abort
echo repeat(' ', a:opts.indent)
try
for l:part in a:parts
Expand All @@ -202,11 +206,8 @@ function! s:echo_formatted(parts, opts) abort " {{{1
endtry
endfunction

" }}}1
function! s:echo_dict(dict, opts) abort " {{{1
function! s:echo_dict(dict, opts) abort
for [l:key, l:val] in items(a:dict)
call s:echo_formatted([['Label', l:key . ': '], l:val], a:opts)
endfor
endfunction

" }}}1
17 changes: 5 additions & 12 deletions autoload/vimtex/ui/nvim.vim
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
" Email: [email protected]
"

function! vimtex#ui#nvim#confirm(prompt) abort " {{{1
function! vimtex#ui#nvim#confirm(prompt) abort
let l:content = [s:formatted_to_string(a:prompt)]
let l:content += ['']
let l:content += [' y = Yes']
Expand All @@ -31,8 +31,7 @@ function! vimtex#ui#nvim#confirm(prompt) abort " {{{1
return l:input ==? 'y'
endfunction

" }}}1
function! vimtex#ui#nvim#input(options) abort " {{{1
function! vimtex#ui#nvim#input(options) abort
if has_key(a:options, 'completion')
" We can't replicate completion, so let's just fall back.
return vimtex#ui#vim#input(a:options)
Expand Down Expand Up @@ -86,8 +85,7 @@ function! vimtex#ui#nvim#input(options) abort " {{{1
return l:value
endfunction

" }}}1
function! vimtex#ui#nvim#select(options, list) abort " {{{1
function! vimtex#ui#nvim#select(options, list) abort
let l:length = len(a:list)
let l:digits = len(l:length)

Expand Down Expand Up @@ -140,9 +138,7 @@ function! vimtex#ui#nvim#select(options, list) abort " {{{1
return l:value
endfunction

" }}}1

function! vimtex#ui#nvim#popup(cfg) abort " {{{1
function! vimtex#ui#nvim#popup(cfg) abort
let l:popup = extend({
\ 'content': [],
\ 'padding': 1,
Expand Down Expand Up @@ -239,9 +235,8 @@ function! vimtex#ui#nvim#popup(cfg) abort " {{{1
return l:popup
endfunction

" }}}1

function! s:formatted_to_string(list_or_string) abort " {{{1
function! s:formatted_to_string(list_or_string) abort
" The input can be a string or an echo-formatted list (see vimtex#ui#echo).
" If the latter, then we must "flatten" and join it.
if type(a:list_or_string) == v:t_string
Expand All @@ -253,5 +248,3 @@ function! s:formatted_to_string(list_or_string) abort " {{{1
\ { _, x -> type(x) == v:t_list ? x[1] : x })
return join(l:strings, '')
endfunction

" }}}1
10 changes: 3 additions & 7 deletions autoload/vimtex/ui/vim.vim
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,14 @@
" Email: [email protected]
"

function! vimtex#ui#vim#confirm(prompt) abort " {{{1
function! vimtex#ui#vim#confirm(prompt) abort
return vimtex#ui#legacy#confirm(a:prompt)
endfunction

" }}}1
function! vimtex#ui#vim#input(options) abort " {{{1
function! vimtex#ui#vim#input(options) abort
return vimtex#ui#legacy#input(a:options)
endfunction

" }}}1
function! vimtex#ui#vim#select(options, list) abort " {{{1
function! vimtex#ui#vim#select(options, list) abort
return vimtex#ui#legacy#select(a:options, a:list)
endfunction

" }}}1
32 changes: 12 additions & 20 deletions autoload/vimtex/view.vim
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
" Email: [email protected]
"

function! vimtex#view#init_buffer() abort " {{{1
function! vimtex#view#init_buffer() abort
if !g:vimtex_view_enabled | return | endif

command! -buffer -nargs=? -complete=file VimtexView
Expand All @@ -17,8 +17,7 @@ function! vimtex#view#init_buffer() abort " {{{1
endif
endfunction

" }}}1
function! vimtex#view#init_state(state) abort " {{{1
function! vimtex#view#init_state(state) abort
if !g:vimtex_view_enabled | return | endif
if has_key(a:state, 'viewer') | return | endif

Expand All @@ -38,16 +37,14 @@ function! vimtex#view#init_state(state) abort " {{{1
endtry
endfunction

" }}}1

function! vimtex#view#view(...) abort " {{{1
function! vimtex#view#view(...) abort
if exists('*b:vimtex.viewer.view')
call b:vimtex.viewer.view(a:0 > 0 ? a:1 : '')
endif
endfunction

" }}}1
function! vimtex#view#compiler_callback() abort " {{{1
function! vimtex#view#compiler_callback() abort
if exists('*b:vimtex.viewer.compiler_callback')
if !b:vimtex.viewer.check() | return | endif

Expand All @@ -58,16 +55,14 @@ function! vimtex#view#compiler_callback() abort " {{{1
endif
endfunction

" }}}1
function! vimtex#view#compiler_stopped() abort " {{{1
function! vimtex#view#compiler_stopped() abort
if exists('*b:vimtex.viewer.compiler_stopped')
call b:vimtex.viewer.compiler_stopped()
endif
endfunction

" }}}1

function! vimtex#view#inverse_search(line, filename, column = 0) abort " {{{1
function! vimtex#view#inverse_search(line, filename, column = 0) abort
" Only activate in VimTeX buffers
if !exists('b:vimtex') | return -1 | endif

Expand Down Expand Up @@ -123,13 +118,14 @@ function! vimtex#view#inverse_search(line, filename, column = 0) abort " {{{1
endif
redraw

call vimtex#ui#blink()

if exists('#User#VimtexEventViewReverse')
doautocmd <nomodeline> User VimtexEventViewReverse
endif
endfunction

" }}}1
function! vimtex#view#inverse_search_cmd(line, filename, column) abort " {{{1
function! vimtex#view#inverse_search_cmd(line, filename, column) abort
" One may call this function manually, but the main usage is to through the
" command "VimtexInverseSearch". See ":help vimtex-synctex-inverse-search"
" for more info.
Expand All @@ -148,9 +144,8 @@ function! vimtex#view#inverse_search_cmd(line, filename, column) abort " {{{1
quitall!
endfunction

" }}}1

function! s:inverse_search_cmd_nvim(line, filename, column) abort " {{{1
function! s:inverse_search_cmd_nvim(line, filename, column) abort
if !filereadable(s:nvim_servernames) | return | endif

for l:server in readfile(s:nvim_servernames)
Expand All @@ -167,17 +162,16 @@ function! s:inverse_search_cmd_nvim(line, filename, column) abort " {{{1
endfor
endfunction

function! s:inverse_search_cmd_vim(line, filename, column) abort " {{{1
function! s:inverse_search_cmd_vim(line, filename, column) abort
for l:server in split(serverlist(), "\n")
call remote_expr(l:server,
\ printf("vimtex#view#inverse_search(%d, '%s', %d)",
\ a:line, a:filename, a:column))
endfor
endfunction

" }}}1

function! s:nvim_prune_servernames() abort " {{{1
function! s:nvim_prune_servernames() abort
" Load servernames from file
let l:servers = filereadable(s:nvim_servernames)
\ ? readfile(s:nvim_servernames)
Expand All @@ -198,7 +192,5 @@ function! s:nvim_prune_servernames() abort " {{{1
call writefile(l:available_servernames, s:nvim_servernames)
endfunction

" }}}1


let s:nvim_servernames = vimtex#cache#path('nvim_servernames.log')