File: test.vim

package info (click to toggle)
vim-vimtex 2.17-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,844 kB
  • sloc: makefile: 360; python: 103
file content (69 lines) | stat: -rw-r--r-- 1,541 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
set nocompatible
let &rtp = 'targets.vim,' . &rtp
let &rtp = '../..,' . &rtp
filetype plugin on

runtime plugin/targets.vim

set noswapfile
set softtabstop=16
set expandtab

silent edit test.tex

if empty($INMAKE) | finish | endif

" IMPORTANT NOTE 2025-06-28
" As of neovim 0.12 there is a default mapping clash that prevents
" vin, v1in, v2in, van, v1an, v2an of working. There are therefore ignored in
" the tests.

function! s:testVimtexCmdtargets(name)
  silent! edit!
  normal! "lyy

  for operator in ['c', 'd', 'y', 'v']
    for cnt in ['', '1', '2']
      for lastnext in ['l', '', 'n']
        for iaIA in ['I', 'i', 'a', 'A']
          let l:motion = cnt . iaIA . lastnext . 'c'
          if (operator ==# 'c' && l:motion =~# '^2.c$')
                \ || (operator ==# 'v' && l:motion =~# '[ia]nc$')
            continue
          endif

          normal! "lpfx
          call s:execute(operator, l:motion)
        endfor
      endfor
    endfor
  endfor

  normal! "lp2f}l
  call s:execute('v', 'ilc')

  execute 'silent write!' a:name
endfunction

function! s:execute(operation, motions)
  let l:cmd = a:operation . a:motions . (a:operation ==# 'c' ? '_' : '')
  silent execute 'normal' l:cmd

  if a:operation ==# 'v'
    normal! r_
  endif

  if a:operation ==# 'y'
    execute "normal! A\<tab>'\<c-r>\"'"
  endif

  execute 'normal! I' . l:cmd . "\<tab>"
endfunction

call s:testVimtexCmdtargets('test1.out')

" Tests should pass with this setting too
set selection=exclusive
call s:testVimtexCmdtargets('test2.out')

quit!