File: test_Autocommands.py

package info (click to toggle)
vim-ultisnips 3.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,924 kB
  • sloc: python: 8,353; sh: 64; makefile: 38
file content (40 lines) | stat: -rw-r--r-- 1,336 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
# encoding: utf-8
from test.vim_test_case import VimTestCase as _VimTest
from test.constant import *


class Autocommands(_VimTest):
    snippets = ("test", "[ ${1:foo} ]")
    args = ""
    keys = (
        "test"
        + EX
        + "test"
        + EX
        + "bar"
        + JF
        + JF
        + " done "
        + ESC
        + ':execute "normal aM" . g:mapper_call_count . "\\<Esc>"'
        + "\n"
        + ':execute "normal aU" . g:unmapper_call_count . "\\<Esc>"'
        + "\n"
    )
    wanted = "[ [ bar ] ] done M1U1"

    def _extra_vim_config(self, vim_config):
        vim_config.append("let g:mapper_call_count = 0")
        vim_config.append("function! CustomMapper()")
        vim_config.append("  let g:mapper_call_count += 1")
        vim_config.append("endfunction")

        vim_config.append("let g:unmapper_call_count = 0")
        vim_config.append("function! CustomUnmapper()")
        vim_config.append("  let g:unmapper_call_count += 1")
        vim_config.append("endfunction")

        vim_config.append("autocmd! User UltiSnipsEnterFirstSnippet")
        vim_config.append("autocmd User UltiSnipsEnterFirstSnippet call CustomMapper()")
        vim_config.append("autocmd! User UltiSnipsExitLastSnippet")
        vim_config.append("autocmd User UltiSnipsExitLastSnippet call CustomUnmapper()")