[
  {
    "path": ".github/FUNDING.yml",
    "content": "github: SirVer\n"
  },
  {
    "path": ".github/issue_template.md",
    "content": "<!--\nThanks for reporting your issue. Please follow this template closely. Without\nall essential info the issue may be closed as unreproducible.\n\nFill out the table below ----- symbols and keep it at the end of your issue\ntext. Please provide an answer for every line.\n\nPlease provide an explanation of the issue below this line. -->\n\n**Expected behavior:**\n\n\n**Actual behavior:**\n\n\n**Steps to reproduce**\n\n<!--\nProvide a minimal viable repro case, ideally following\nhttps://github.com/SirVer/ultisnips/blob/master/CONTRIBUTING.md#reproducing-bugs\n\nIf this is not possible, post a minimal, complete `.vimrc`, snippet definition,\nand set of keystrokes that reproduces your problem.\n-->\n\n1.\n2.\n3.\n\n-----\n<!-- NOTE: contents inside arrows will be ignored. -->\n- **Operating System**: <!-- e.g. Windows XP / Ubuntu 16.04 / Mac OS 10.5 -->\n- **Vim Version**: <!-- first two lines of `:version` output -->\n- **UltiSnips Version**: <!-- e.g. 3.1. If you're using version from git \n                              run: `git rev-parse origin/master` -->\n- **Python inside Vim**: <!-- e.g. 3.9.1 / 3.6.5. If unsure run inside vim:\n                              `:py import sys; print(sys.version)` and\n                              `:py3 import sys; print(sys.version)' -->\n- **Docker repo/vimrc**: <!-- link to the branch containing the repro case, \n                              or the uploaded minimal vimrc -->\n"
  },
  {
    "path": ".github/workflows/main.yml",
    "content": "on:\n  push:\n    branches:\n      - master\n  pull_request:\n    branches:\n      - master\n\njobs:\n  test:\n    runs-on: ubuntu-latest\n    strategy:\n     fail-fast: false\n     matrix:\n      include:\n        - { vim_version: \"9.0.0000\", python_image: \"3.10-bookworm\", tag: \"vim_90_py310\" }\n        - { vim_version: \"9.1.0000\", python_image: \"3.10-bookworm\", tag: \"vim_91_py310\" }\n        - { vim_version: \"git\", python_image: \"3.10-bookworm\", tag: \"vim_git_py310\" }\n\n        - { vim_version: \"9.0.0000\", python_image: \"3.11-bookworm\", tag: \"vim_90_py311\" }\n        - { vim_version: \"9.1.0000\", python_image: \"3.11-bookworm\", tag: \"vim_91_py311\" }\n        - { vim_version: \"git\", python_image: \"3.11-bookworm\", tag: \"vim_git_py311\" }\n\n        - { vim_version: \"9.0.0000\", python_image: \"3.12-bookworm\", tag: \"vim_90_py312\" }\n        - { vim_version: \"9.1.0000\", python_image: \"3.12-bookworm\", tag: \"vim_91_py312\" }\n        - { vim_version: \"git\", python_image: \"3.12-bookworm\", tag: \"vim_git_py312\" }\n\n        # Vim 9.0 and 9.1 prior to 417 hang forever with python 3.13 due to a bug fixed here\n        # https://github.com/vim/vim/issues/14776.\n        - { vim_version: \"9.1.0417\", python_image: \"3.13-bookworm\", tag: \"vim_91_py313\" }\n        - { vim_version: \"git\", python_image: \"3.13-bookworm\", tag: \"vim_git_py313\" }\n\n    # Builds Vim and Tests it within docker.\n    name: CI\n    steps:\n      - uses: actions/checkout@v2\n      - name: Build the image\n        run: docker build -t ultisnips:${{ matrix.tag }} --build-arg PYTHON_IMAGE=${{ matrix.python_image }} --build-arg VIM_VERSION=${{ matrix.vim_version }} .\n      - name: Run the tests\n        run: docker run --rm -t ultisnips:${{ matrix.tag }} docker/run_tests.sh\n"
  },
  {
    "path": ".gitignore",
    "content": "*.pyc\n*.swp\ndoc/tags\n/.ropeproject/\n/.mypy_cache/\n"
  },
  {
    "path": "CONTRIBUTING.md",
    "content": "# Contributing to UltiSnips\n\n:+1::tada: First off, thanks for taking the time to contribute! :tada::+1:\n\nThis document will take you through the process of making your change, testing it, documenting it and sending it for review.\nNo new feature will be accepted without good test coverage, passing CI and proper documentation.\n\n## Before you add a feature\n\nUltiSnips is so rich on features that it borders on feature creep.\nIt is also an understaffed and undermaintained project.\nSince every feature needs to be maintained forever, we are very careful about new ones.\nPlease create alignment before putting too much work into a novel idea.\nThere are several ways of doing this:\n\n1. Open an issue to discuss your idea.\n2. Open a PR with a hackish or minimal implementation, i.e. no tests and no docs.\n3. Write a short (<= 1 page) design doc in a Gist or on Google Docs.\n\nShould there be agreement that your feature idea adds enough value to offset the maintenance burden, you can go ahead and implement it, including tests and documentation.\n\n## Debugging\n\nUltiSnips embeds some remote debugging facilities in the `UltiSnips.remote_pdb` module.\nWhen enabled (by setting `let g:UltiSnipsDebugServerEnable=1`), whenever an exception is raised, vim will pause\nand you will be able to connect to the debug server with netcat or telnet.\nBy default, the server listens on 'localhost:8080' (it can be changed).\n\nSee `:help UltiSnips-Advanced-Debugging` for more informations\n\n## Testing\n\nUltiSnips has a rigorous test suite and every new feature or bug fix is expected to come with a new test.\nThe overwhelming number of the > 500 test cases are integration tests.\nEach test case sets up a full on-disk Vim configuration, including `.vimrc`, plugins and snippet definitions.\nWe then simulate a user typing out a test case by programmatically sending keys into a [tmux](https://github.com/tmux/tmux/wiki) terminal that runs Vim.\n\nA test is a Python class in the `test` directory.\nSome simple examples are in [test_Expand.py](https://github.com/SirVer/ultisnips/blob/master/test/test_Expand.py).\nEach class contains at least\n\n- a `keys` property that defines the key strokes taken,\n- a `wanted` golden string that defines the expected output of the snippet, and\n- a `snippets` list that defines the snippet that are in scope for the test case.\n\nEach test types out a given set of key strokes and compares the resulting text in the Vim buffer to `wanted`.\n\n### Running the test suite.\n\nThe basic process of running the suite is simple:\n\n1. open a terminal and start a new tmux session in the current directory named\n   vim: `tmux new -s vim`. Do not type anything into the tmux session.\n2. In a second terminal, run `./test_all.py`.\n\nTo filter the tests that are executed, specify a pattern to be used to match the beginning of the test name.\nFor instance, the following will execute all tests that start with `SimpleExpand`:\n\n    $ ./test_all.py SimpleExpand\n\nCurrently, the test suite only runs under Linux and Mac, not under Windows.\nContributions to make it work under Windows again would be very much appreciated.\n\n\n#### Running using docker.\n\nThe problem with running tests on the system directly is that the user's environment can bleed into the test execution.\nTo avoid this problem, we strongly suggest running the tests inside of [Docker](https://www.docker.com/).\nIt is useful to think of Docker as a lightweight virtual machine, i.e. a way of running exactly the same OS and userland configuration on any machine.\n\nUltiSnips comes with a [Makefile](https://github.com/SirVer/ultisnips/blob/master/Makefile) that makes the use of Docker easy.\nFirst, build the image of the test environment (Vim 8.0, using Python 3):\n\n    $ make image_repro\n\nNow we can launch the image in a container and run the tmux session for testing.\n\n    $ make repro\n    ... now inside container\n    # tmux new -s vim\n\nThe container will have the current directory mounted under `/src/UltiSnips`.\nThis means all changes you make to UltiSnips' sources will directly be represented inside the container and therefore available for testing.\n\nIn a second terminal we'll use `docker run` to get another shell in the already running container.\nIn this shell we can then trigger the test execution:\n\n    $ make shell_in_repro\n    ... now inside container\n    # ./test_all.py\n\n### Enable the remote debug server\n\nThe test suite provides `--remote-pdb*` options equivalent to the config variables to enable the debug server during the test suite.\nNote that some tests may fail because the post-mortem will catch an expected exceptions and that these options are mainly useful for single test case debugging. \n\nCheck `./test_all.py --help` for more informations.\n\n## Documenting\n\nUser documentation goes into [`doc/UltiSnips.txt`](https://github.com/SirVer/ultisnips/blob/00_contributing/doc/UltiSnips.txt).\nDeveloper documentation should go into this file.\n\n# Reproducing Bugs\n\nReproducing bugs is the hardest part of getting them fixed.\nUltiSnips is usually used in complex interaction with other software and plugins.\nThis makes reproducing issues even harder.\n\nHere is a process of creating a minimal viable reproduction case for your particular problem.\nHaving this available in a bug report will increase the chances of your issue being fixed tremendously.\n\n1. Install [Docker](https://docs.docker.com/install/). It is useful to think of Docker as a lightweight virtual machine, i.e. a way of running exactly the same OS and userland configuration on any machine.\n2. Build the image using `make image_repro`.\n3. Launch the image using `make repro`. This drops you into a shell where you can run `vim` to get to a vim instance configured for UltiSnips.\n\nNow try to reproduce your issue.\nKeep in mind that all your changes to the container are lost once you exit the shell.\nYou must edit the configuration outside the container and rebuild the image.\nYou can add snippets to `docker/snippets/`.\nYou can also copy more and more of your own `.vimrc` into `docker/docker_vimrc.vim` until your issue reproduces.\nWhenever you have edited `snippets` or `docker_vimrc.vim` you need to rerun `make image_repo && make repro`.\n\nOnce you have a minimal complete repro case ready,\n\n1. fork UltiSnips,\n2. commit your changes to the Vim configuration into a branch,\n3. push the branch,\n4. link it in the issue.\n"
  },
  {
    "path": "COPYING.txt",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Use with the GNU Affero General Public License.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <http://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n    <program>  Copyright (C) <year>  <name of author>\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n<http://www.gnu.org/licenses/>.\n\n  The GNU General Public License does not permit incorporating your program\ninto proprietary programs.  If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.  But first, please read\n<http://www.gnu.org/philosophy/why-not-lgpl.html>.\n"
  },
  {
    "path": "ChangeLog",
    "content": "version 3.2 (05-Nov-2019):\n\t- This is the first release done again by @SirVer. And this is also posted\n\t  on vim.org again. `¯\\_(ツ)_/¯`\n\t- This is the last version to support Python 2.\n\t- Syntax highlighting improvements: a new one for unite & tweaks to others.\n\t- Support for transformations on multiple lines.\n\t- Python interpolation got more powerful, for example tabstops can now be\n\t  modified in python interpolation, you can access the last changed\n\t  placeholder text and more.\n\t- Support for deoplete.\n\t- Snippet files are no longer watched for changes. This increases\n\t  performance, but also means that if you change your snippet files outside\n\t  of Vim, UltiSnips will not know about it. You need to run `:call\n\t  UltiSnips#RefreshSnippets()` or restart Vim.\n\t- Text objects for selecting snippets in visual mode: iS, aS\n\nversion 3.1 (07-Dec-2015):\n\t- This is the last release done by @SirVer. The new maintainer of UltiSnips\n\t  is @seletskiy. The repository remains https://github.com/SirVer/ultisnips,\n\t  so this should not affect any users. This is also the last release to be\n\t  published on vim.org. Please follow the master branch on GitHub for the\n\t  latest stable version.\n\t- New option `e`: Context aware snippets. This gives very precise and\n\t  powerful control over which snippet should be expanded depending on\n\t  surrounding code. *UltiSnips-context-snippets*\n\t- New option `m`: Trim whitespace in all snippet lines.\n\t- Very powerful, freely configurable pre/post-expand and post-jump actions\n\t  allow for transforming the buffer outside the snippet. *UltiSnips-snippet-actions*\n\t- Automatic triggering of snippets without the need to press the expand\n\t  trigger. *UltiSnips-autotrigger*\n\t- Better error reporting for snippet errors including python stacktraces\n\t  and listing of executed code.\n\t- Undo is more granular. Each jump and expand is now a separate undo step.\n\t- UltiSnips now emits autocommands on certain events. *UltiSnips-custom-autocommands*\n\t- clearsnippets now clears all snippets below the current priority. This\n\t  fits better with the priority system introduced in 3.0.\n\t- snipMate snippets support can be disabled. *UltiSnipsEnableSnipMate*\n\t- UltiSnipsEditSplit got a new value 'context'. *UltiSnipsEditSplit*\n\t- Improved syntax highlighting for snippets filetype.\n\t- Mappings and autocommands are now only established when needed, i.e. when\n\t  a snippet is active. This boosts performance outside of snippets.\n\t- New integration with Unite, TagBar, and deoplete.\n\t- New Ctags configuration file for snippet definitions.\n\t- Bug fixes, performance improvements, code cleanups and refactorings.\n\t- No longer supports Vim < 7.4.\n\nversion 3.0 (02-Mar-2014):\n\t- Organisational changes: The project is now hosted on github. Snippets are\n\t  now shipped separately - please track honza/vim-snippets.\n\t- UltiSnips is now a drop in replacement for snipMate - it parses snipMate\n\t  snippets and expands them emulating snipMates smaller feature set.\n\t- Filetype tab completion for UltiSnipsEdit.\n\t- UltiSnipsEdit now only edits private snippet files. Use UltiSnipsEdit! if\n\t  you want to edit shipped files.\n\t- New option 's' which strips trailing whitespace before jumping to next\n\t  tabstop\n\t- New option 'a' which converts non-ascii characters into ascii characters\n\t  in transformations.\n\t- New keyword in snippet files: priority defines which snippets should\n\t  overwrite others. This deprecates the '!' option.\n\t  *UltiSnips-adding-snippets*\n\t- Remove common whitespace of visual line selections before inserting in an\n\t  indented tabstop.\n\t- Support for overwriting the snippet directory name on a per buffer basis\n\t  to support per project snippets. *UltiSnips-snippet-search-path*\n\t- The keymaps for jumping in snippets are now only mapped when a snippet is\n\t  active, allowing them to be used for something else otherwise.\n\t- Expanding and jumping no longer overwrites the unnamed register.\n\t- Integration with Valloric/YouCompleteMe and Shougo/neocomplete.vim.\n\t- Other plugins can add sources for snippets to create snippets on the fly.\n\t  *UltiSnips-extending*\n\t- Vim functions now indicates if it did any work.\n\t  *UltiSnips-trigger-functions*\n\t- For python extensions: UltiSnips adds itself to the sys.path and can be\n\t  easily imported if it is available. *UltiSnips-python-module-path*\n\t- A new function giving programmatic access to the snippets currently\n\t  available for expansion for other plugins integrating with UltiSnips.\n\t  *UltiSnips_SnippetsInCurrentScope*\n\t- New or improved snippets (now in a different repo): all, bib, c, cpp, cs,\n\t  d, django, eruby, go, haskell, html, html, htmljinja, java, javascript,\n\t  js, ledger, ocaml, perl, php, puppet, python, ruby, scss, sh, tex, vim,\n\t  xml, zsh.\n\nversion 2.2 (01-Sep-2012):\n\t- Support to silence Python-not-found warnings. *UltiSnips-python-warning*\n\t- Matchit support for snippet files.\n\t- Improvements to syntax file.\n\t- Various smaller bug fixes.\n\t- New command to manually add a filetype to the list for the current\n\t  buffer. *:UltiSnipsAddFiletypes*\n\t- New or improved snippets: all, snippets, haskell, bindzone, python, golang,\n\t  json, html, coffee, coffee_jasmine, javascript_jasmine, ruby, php,\n\t  markdown.\n\nversion 2.1 (14-Feb-2012):\n\t- Python interpolation access to text from visual selection via snip.v.\n\t- Support for transformations of ${VISUAL} texts.\n\t- New or improved snippets: python, tex, texmath, ruby, rails, html, django\n\nversion 2.0 (05-Feb-2012):\n\t- Backwards incompatible change: Support for normal mode editing. Snippets\n\t  are no longer exited when leaving insert mode but only by leaving the\n\t  text span of the snippets. This allows usage of normal mode commands and\n\t  autoformatting. It also increases compatibility with other plugins.\n\t- Backwards incompatible change: Changed glob patterns for snippets to\n\t  behave more like Vim *UltiSnips-adding-snippets*\n\t- Backwards incompatible change: Zero Tabstop is no longer removed in\n\t  nested snippets\n\t- Support for ${VISUAL:default text} placeholder. *UltiSnips-visual-placeholder*\n\t- Improved handling of utf-8 characters in files and snippet definitions.\n\t- Full support for :py3. UltiSnips now works with python >= 2.6 or >= 3.2.\n\t- New or improved snippets: python, all\n\nversion 1.6 (30-Dec-2011):\n\t- Significant speed improvements and a few bugs fixed.\n\t- Better handling of non ASCII chars in snippets by assuming UTF-8 encoding\n\t  when no other information is available.\n\t- Contributions for UltiSnips are now also accepted on GitHub: https://github.com/SirVer/ultisnips/\n\t- New or improved snippets: ruby, rails, xhtml\n\nversion 1.5 (24-Sep-2011):\n\t- Some critical bug fixes for new vim versions.\n\t- New or improved snippets: tex, texmath, python, jinja2, go, puppet, xhtml\n\t- Configuration of search path for snippets *UltiSnips-snippet-search-path*\n\t- New parser implementation: A little faster, more flexible and less bugged.\n\nversion 1.4 (17-Jul-2011):\n\t- New or improved snippets: php, html, djangohtml, mako, lua\n\t- Snippets are now listed alphabetically by their trigger, no longer in\n\t  order of appearance\n\t- Snippet files are now automatically reloaded when they change.\n\t- Support for other directory names for snippets beside\n\t  \"UltiSnips\" *UltiSnips-snippet-search-path*\n\t- Errors are now shown in a scratch window.\n\t- Now fully supports Windows with python >= 2.6. UltiSnips should now work\n\t  on all systems that Vim runs on.\n\t- a syntax file was added for snippets files with nice highlighting.\n\t- snippets definition files now have the filetype 'snippets'. It used to be\n\t  'snippet'.\n\nversion 1.3 (14-Feb-2011):\n\t- Erlang snippets (g0rdin)\n\t- Other VimScripts can now define and immediately expand anonymous snippets\n\t  ( *UltiSnips_Anon* ) (Ryan Wooden)\n\t- Other VimScripts can now define new snippets via a function\n\t  ( *UltiSnips_AddSnippet* ) (Ryan Wooden)\n\t- New Snippets for eruby and rails (Ches Martin).\n\t- A new Option 't' has been added to snippets that avoid expanding tabstops.\n\t  Be also more consistent with how indenting is handled. (Ryan Wooden)\n\t- Added a ftplugin script for .snippets files. Syntax highlighting still\n\t  missing. (Rupa Deadwyler)\n\t- Added UltiSnipsReset and UltiSnipsEdit (Idea by JCEB)\n\nversion 1.2 (24-Aug-2010):\n\t- many bugs were fixed\n\t- smode mappings for printable characters are now removed before expanding a\n\t  snippet. This is configurable. *UltiSnips-warning-smappings*\n\t- all shipped snippets are now fully compatible with UltiSnips\n\t- added support for global snippets which enhance python interpolation even\n\t  more *UltiSnips-globals*\n\t- added support for multi word and regular expression triggers. Very\n\t  powerful in combination with python interpolation.\n\t- Python interpolation became much more powerful *UltiSnips-python*\n\t- added support for clearsnippets command *UltiSnips-clearing-snippets*\n\t- added support for option w which is a little more strict than i.\n\t- added support for listing of valid triggers. Defaults to <c-tab>.\n\t- added support for option i (inword expansion)\n\t- extends keyword is now supported on the first line of snippet files. This makes it easy to\n\t  define special cases, for example cpp extends c: a cpp trigger is useless\n\t  in c, but a c trigger is valuable for cpp.\n\t- UltiSnips now adheres to expandtab and tabstop options of vim\n\nversion 1.1 (21-Jul-2009):\n\t- Made triggers configurable. You can also use the same trigger for\n\t  expanding and tabbing. The TextMate configuration <tab> and <s-tab> is now\n\t  possible.\n\t- Conditional Inserts can now be nested\n\t- Added support for b option. This only considers a snippet at the beginning\n\t  of a line ( *UltiSnips-adding-snippets* )\n\t- Added support for ! option. This overwrites previously defined snippets\n\t  with the same tab trigger ( *UltiSnips-adding-snippets* )\n\t- Support for dotted filetype syntax. Now snippets for more than one filetype\n\t  can be active ( *UltiSnips-adding-snippets* )\n"
  },
  {
    "path": "Dockerfile",
    "content": "ARG PYTHON_IMAGE\n\nFROM python:${PYTHON_IMAGE}\n\nARG VIM_VERSION\n\nCOPY docker/install_packages.sh src/scripts/\nRUN src/scripts/install_packages.sh\nCOPY docker/download_vim.sh src/scripts/\nRUN src/scripts/download_vim.sh\nCOPY docker/build_vim.sh src/scripts/\nRUN src/scripts/build_vim.sh\n\nRUN pip install unidecode\n\nCOPY . /src/UltiSnips\nWORKDIR /src/UltiSnips\n\nRUN ./test_all.py --clone-plugins\n"
  },
  {
    "path": "Dockerfile.repro",
    "content": "ARG BASE_IMAGE\n\nFROM ultisnips:${BASE_IMAGE}\n\nRUN curl -fLo ~/.vim/autoload/plug.vim --create-dirs \\\n    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim\n\nADD docker/docker_vimrc.vim /root/.vim/vimrc\nRUN vim -c 'PlugInstall | qa'\n\nADD docker/snippets /root/.vim/UltiSnips\n"
  },
  {
    "path": "Makefile",
    "content": "MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))\nMAKEFILE_DIR := $(dir ${MAKEFILE_PATH})\n\n# Test images as run on CI.\nimage_vim_80_py35:\n\tdocker build -t ultisnips:$@ --build-arg PYTHON_IMAGE=3.5-stretch --build-arg VIM_VERSION=8.0 .\nimage_vim_81_py35:\n\tdocker build -t ultisnips:$@ --build-arg PYTHON_IMAGE=3.5-stretch --build-arg VIM_VERSION=8.1 .\nimage_vim_82_py35:\n\tdocker build -t ultisnips:$@ --build-arg PYTHON_IMAGE=3.5-stretch --build-arg VIM_VERSION=8.2 .\nimage_vim_git_py35:\n\tdocker build -t ultisnips:$@ --build-arg PYTHON_IMAGE=3.5-stretch --build-arg VIM_VERSION=git .\nimage_vim_80_py36:\n\tdocker build -t ultisnips:$@ --build-arg PYTHON_IMAGE=3.6-stretch --build-arg VIM_VERSION=8.0 .\nimage_vim_81_py36:\n\tdocker build -t ultisnips:$@ --build-arg PYTHON_IMAGE=3.6-stretch --build-arg VIM_VERSION=8.1 .\nimage_vim_82_py36:\n\tdocker build -t ultisnips:$@ --build-arg PYTHON_IMAGE=3.6-stretch --build-arg VIM_VERSION=8.2 .\nimage_vim_git_py36:\n\tdocker build -t ultisnips:$@ --build-arg PYTHON_IMAGE=3.6-stretch --build-arg VIM_VERSION=git .\nimage_vim_81_py37:\n\tdocker build -t ultisnips:$@ --build-arg PYTHON_IMAGE=3.7-stretch --build-arg VIM_VERSION=8.1 .\nimage_vim_82_py37:\n\tdocker build -t ultisnips:$@ --build-arg PYTHON_IMAGE=3.7-stretch --build-arg VIM_VERSION=8.2 .\nimage_vim_git_py37:\n\tdocker build -t ultisnips:$@ --build-arg PYTHON_IMAGE=3.7-stretch --build-arg VIM_VERSION=git .\nimage_vim_81_py38:\n\tdocker build -t ultisnips:$@ --build-arg PYTHON_IMAGE=3.8-buster --build-arg VIM_VERSION=8.1 .\nimage_vim_82_py38:\n\tdocker build -t ultisnips:$@ --build-arg PYTHON_IMAGE=3.8-buster --build-arg VIM_VERSION=8.2 .\nimage_vim_git_py38:\n\tdocker build -t ultisnips:$@ --build-arg PYTHON_IMAGE=3.8-buster --build-arg VIM_VERSION=git .\nimage_vim_81_py39:\n\tdocker build -t ultisnips:$@ --build-arg PYTHON_IMAGE=3.9-buster --build-arg VIM_VERSION=8.1 .\nimage_vim_82_py39:\n\tdocker build -t ultisnips:$@ --build-arg PYTHON_IMAGE=3.9-buster --build-arg VIM_VERSION=8.2 .\nimage_vim_git_py39:\n\tdocker build -t ultisnips:$@ --build-arg PYTHON_IMAGE=3.9-buster --build-arg VIM_VERSION=git .\nimage_vim_git_py310:\n\tdocker build -t ultisnips:$@ --build-arg PYTHON_IMAGE=3.10-buster --build-arg VIM_VERSION=git .\n\nimage_repro: image_vim_82_py39\n\tdocker build -t ultisnips:repro --build-arg BASE_IMAGE=$< -f Dockerfile.repro .\n\n# A reproduction image that drops you into a naked environment,\n# with a Vim having UltiSnips and vim-snippets configured. See\n# docker/docker_vimrc.vim for the full vimrc. Need to run `make\n# image_repro` before this will work.\nrepro:\n\tdocker run -it -v ${MAKEFILE_DIR}:/src/UltiSnips ultisnips:repro /bin/bash\n\n# This assumes, the repro image is already running and it opens an extra shell\n# inside the running container\nshell_in_repro:\n\tdocker exec -it $(shell docker ps -q) /bin/bash\n\nformat:\n\tfind . -name '*.py' -print0 | xargs -0 black\n"
  },
  {
    "path": "Pipfile",
    "content": "[[source]]\nname = \"pypi\"\nurl = \"https://pypi.org/simple\"\nverify_ssl = true\n\n[dev-packages]\nblack = \"*\"\nmypy = \"*\"\npylint = \"*\"\n\n[packages]\nmypy = \"*\"\nblack = \"*\"\n\n[requires]\npython_version = \"3.10\"\n\n[pipenv]\nallow_prereleases = true\n"
  },
  {
    "path": "README.md",
    "content": "![Build Status](https://github.com/SirVer/ultisnips/actions/workflows/main.yml/badge.svg)\n[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/SirVer/ultisnips?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)\n\nUltiSnips\n=========\n\nUltiSnips is the ultimate solution for snippets in Vim. It has many features,\nspeed being one of them.\n\n![GIF Demo](https://raw.github.com/SirVer/ultisnips/master/doc/demo.gif)\n\nIn this demo I am editing a python file. I first expand the `#!` snippet, then\nthe `class` snippet. The completion menu comes from\n[YouCompleteMe](https://github.com/Valloric/YouCompleteMe), UltiSnips also\nintegrates with [deoplete](https://github.com/Shougo/deoplete.nvim),\n[vim-easycomplete](https://github.com/jayli/vim-easycomplete) and more. I can\njump through placeholders and add text while the snippet inserts text in other\nplaces automatically: when I add `Animal` as a base class, `__init__` gets\nupdated to call the base class constructor. When I add arguments to the\nconstructor, they automatically get assigned to instance variables. I then\ninsert my personal snippet for `print` debugging. Note that I left insert mode,\ninserted another snippet and went back to add an additional argument to\n`__init__` and the class snippet was still active and added another instance\nvariable.\n\nThe official home of UltiSnips is at <https://github.com/sirver/ultisnips>.\nPlease add pull requests and issues there.\n\nUltiSnips was started in Jun 2009 by @SirVer. In Dec 2015, maintenance was\nhanded over to [@seletskiy](https://github.com/seletskiy) who ran out of time\nin early 2017. Since Jun 2019, @SirVer is maintaining UltiSnips again on a\nvery constrained time budget. If you can help triaging issues it would be\ngreatly appreciated.\n\n\nQuick Start\n-----------\n\nThis assumes you are using [Vundle](https://github.com/gmarik/Vundle.vim). Adapt\nfor your plugin manager of choice. Put this into your `.vimrc`.\n\n    \" Track the engine.\n    Plugin 'SirVer/ultisnips'\n\n    \" Snippets are separated from the engine. Add this if you want them:\n    Plugin 'honza/vim-snippets'\n\n    \" Trigger configuration. You need to change this to something other than <tab> if you use one of the following:\n    \" - https://github.com/Valloric/YouCompleteMe\n    \" - https://github.com/nvim-lua/completion-nvim\n    let g:UltiSnipsExpandTrigger=\"<tab>\"\n    let g:UltiSnipsJumpForwardTrigger=\"<c-b>\"\n    let g:UltiSnipsJumpBackwardTrigger=\"<c-z>\"\n\n    \" If you want :UltiSnipsEdit to split your window.\n    let g:UltiSnipsEditSplit=\"vertical\"\n\nUltiSnips comes with comprehensive\n[documentation](https://github.com/SirVer/ultisnips/blob/master/doc/UltiSnips.txt).\nAs there are more options and tons of features I suggest you at least skim it.\n\nThere are example uses for some power user features here:\n\n  * [Snippets Aliases](doc/examples/snippets-aliasing/README.md)\n  * [Dynamic Tabstops/Tabstop Generation](doc/examples/tabstop-generation/README.md)\n\nScreencasts\n-----------\n\nFrom a gentle introduction to really advanced in a few minutes: The blog posts\nof the screencasts contain more advanced examples of the things discussed in the\nvideos.\n\n- [Episode 1: What are snippets and do I need them?](http://www.sirver.net/blog/2011/12/30/first-episode-of-ultisnips-screencast/)\n- [Episode 2: Creating Basic Snippets](http://www.sirver.net/blog/2012/01/08/second-episode-of-ultisnips-screencast/)\n- [Episode 3: What's new in version 2.0](http://www.sirver.net/blog/2012/02/05/third-episode-of-ultisnips-screencast/)\n- [Episode 4: Python Interpolation](http://www.sirver.net/blog/2012/03/31/fourth-episode-of-ultisnips-screencast/)\n\nAlso the excellent [Vimcasts](http://vimcasts.org) dedicated three episodes to\nUltiSnips:\n\n- [Meet UltiSnips](http://vimcasts.org/episodes/meet-ultisnips/)\n- [Using Python interpolation in UltiSnips snippets](http://vimcasts.org/episodes/ultisnips-python-interpolation/)\n- [Using selected text in UltiSnips snippets](http://vimcasts.org/episodes/ultisnips-visual-placeholder/)\n"
  },
  {
    "path": "after/plugin/UltiSnips_after.vim",
    "content": "\" Called after everything else to reclaim keys (Needed for Supertab)\n\nif exists(\"b:did_after_plugin_ultisnips_after\")\n   finish\nendif\nlet b:did_after_plugin_ultisnips_after = 1\n\ncall UltiSnips#map_keys#MapKeys()\n"
  },
  {
    "path": "autoload/UltiSnips/map_keys.vim",
    "content": "if exists(\"b:did_autoload_ultisnips_map_keys\")\n   finish\nendif\nlet b:did_autoload_ultisnips_map_keys = 1\n\n\" The trigger used to expand a snippet.\n\" NOTE: expansion and forward jumping can, but needn't be the same trigger\nif !exists(\"g:UltiSnipsExpandTrigger\")\n    let g:UltiSnipsExpandTrigger = \"<tab>\"\nendif\n\n\" The trigger used to display all triggers that could possible\n\" match in the current position. Use empty to disable.\nif !exists(\"g:UltiSnipsListSnippets\")\n    let g:UltiSnipsListSnippets = \"<c-tab>\"\nendif\n\n\" The trigger used to jump forward to the next placeholder.\n\" NOTE: expansion and forward jumping can be the same trigger.\nif !exists(\"g:UltiSnipsJumpForwardTrigger\")\n    let g:UltiSnipsJumpForwardTrigger = \"<c-j>\"\nendif\n\n\" The trigger to jump backward inside a snippet\nif !exists(\"g:UltiSnipsJumpBackwardTrigger\")\n    let g:UltiSnipsJumpBackwardTrigger = \"<c-k>\"\nendif\n\n\" Should UltiSnips unmap select mode mappings automagically?\nif !exists(\"g:UltiSnipsRemoveSelectModeMappings\")\n    let g:UltiSnipsRemoveSelectModeMappings = 1\nend\n\n\" If UltiSnips should remove Mappings, which should be ignored\nif !exists(\"g:UltiSnipsMappingsToIgnore\")\n    let g:UltiSnipsMappingsToIgnore = []\nendif\n\n\" UltiSnipsEdit will use this variable to decide if a new window\n\" is opened when editing. default is \"normal\", allowed are also\n\" \"tabdo\", \"vertical\", \"horizontal\", and \"context\".\nif !exists(\"g:UltiSnipsEditSplit\")\n    let g:UltiSnipsEditSplit = 'normal'\nendif\n\n\" A list of directory names that are searched for snippets.\nif !exists(\"g:UltiSnipsSnippetDirectories\")\n    let g:UltiSnipsSnippetDirectories = [ \"UltiSnips\" ]\nendif\n\n\" Enable or Disable snipmate snippet expansion.\nif !exists(\"g:UltiSnipsEnableSnipMate\")\n    let g:UltiSnipsEnableSnipMate = 1\nendif\n\nfunction! UltiSnips#map_keys#MapKeys() abort\n    if exists(\"g:UltiSnipsExpandOrJumpTrigger\")\n        exec \"inoremap <silent> \" . g:UltiSnipsExpandOrJumpTrigger . \" <C-R>=UltiSnips#ExpandSnippetOrJump()<cr>\"\n        exec \"snoremap <silent> \" . g:UltiSnipsExpandOrJumpTrigger . \" <Esc>:call UltiSnips#ExpandSnippetOrJump()<cr>\"\n    elseif exists(\"g:UltiSnipsJumpOrExpandTrigger\")\n        exec \"inoremap <silent> \" . g:UltiSnipsJumpOrExpandTrigger . \" <C-R>=UltiSnips#JumpOrExpandSnippet()<cr>\"\n        exec \"snoremap <silent> \" . g:UltiSnipsJumpOrExpandTrigger . \" <Esc>:call UltiSnips#JumpOrExpandSnippet()<cr>\"\n    elseif g:UltiSnipsExpandTrigger == g:UltiSnipsJumpForwardTrigger\n        exec \"inoremap <silent> \" . g:UltiSnipsExpandTrigger . \" <C-R>=UltiSnips#ExpandSnippetOrJump()<cr>\"\n        exec \"snoremap <silent> \" . g:UltiSnipsExpandTrigger . \" <Esc>:call UltiSnips#ExpandSnippetOrJump()<cr>\"\n    else\n        exec \"inoremap <silent> \" . g:UltiSnipsExpandTrigger . \" <C-R>=UltiSnips#ExpandSnippet()<cr>\"\n        exec \"snoremap <silent> \" . g:UltiSnipsExpandTrigger . \" <Esc>:call UltiSnips#ExpandSnippet()<cr>\"\n    endif\n    exec \"xnoremap <silent> \" . g:UltiSnipsExpandTrigger. \" :call UltiSnips#SaveLastVisualSelection()<cr>gvs\"\n    if len(g:UltiSnipsListSnippets) > 0\n       exec \"inoremap <silent> \" . g:UltiSnipsListSnippets . \" <C-R>=UltiSnips#ListSnippets()<cr>\"\n       exec \"snoremap <silent> \" . g:UltiSnipsListSnippets . \" <Esc>:call UltiSnips#ListSnippets()<cr>\"\n    endif\n\n    snoremap <silent> <BS> <c-g>\"_c\n    snoremap <silent> <DEL> <c-g>\"_c\n    snoremap <silent> <c-h> <c-g>\"_c\n    snoremap <c-r> <c-g>\"_c<c-r>\nendf\n"
  },
  {
    "path": "autoload/UltiSnips.vim",
    "content": "if exists(\"b:did_autoload_ultisnips\")\n    finish\nendif\nlet b:did_autoload_ultisnips = 1\n\n\" Ensure snippets are loaded for current buffer\nau UltiSnips_AutoTrigger FileType,BufEnter * call UltiSnips#CheckFiletype()\n\n\" Also import vim as we expect it to be imported in many places.\npy3 import vim\npy3 from UltiSnips import UltiSnips_Manager\n\nfunction! s:compensate_for_pum() abort\n    \"\"\" The CursorMovedI event is not triggered while the popup-menu is visible,\n    \"\"\" and it's by this event that UltiSnips updates its vim-state. The fix is\n    \"\"\" to explicitly check for the presence of the popup menu, and update\n    \"\"\" the vim-state accordingly.\n    if pumvisible()\n        py3 UltiSnips_Manager._cursor_moved()\n    endif\nendfunction\n\nfunction! s:is_floating(winId) abort\n    if has('nvim')\n        return get(nvim_win_get_config(a:winId), 'relative', '') !=# ''\n    endif\n\n    return 0\nendfunction\n\nfunction! UltiSnips#Edit(bang, ...) abort\n    if a:0 == 1 && a:1 != ''\n        let type = a:1\n    else\n        let type = \"\"\n    endif\n    py3 vim.command(\"let file = '%s'\" % UltiSnips_Manager._file_to_edit(vim.eval(\"type\"), vim.eval('a:bang')))\n\n    if !len(file)\n       return\n    endif\n\n    let mode = 'e'\n    if exists('g:UltiSnipsEditSplit')\n        if g:UltiSnipsEditSplit == 'vertical'\n            let mode = 'vs'\n        elseif g:UltiSnipsEditSplit == 'horizontal'\n            let mode = 'sp'\n        elseif g:UltiSnipsEditSplit == 'tabdo'\n            let mode = 'tabedit'\n        elseif g:UltiSnipsEditSplit == 'context'\n            let mode = 'vs'\n            if winwidth(0) <= 2 * (&tw ? &tw : 80)\n                let mode = 'sp'\n            endif\n        endif\n    endif\n    exe ':'.mode.' '.escape(file, ' ')\nendfunction\n\nfunction! UltiSnips#AddFiletypes(filetypes) abort\n    py3 UltiSnips_Manager.add_buffer_filetypes(vim.eval(\"a:filetypes\"))\n    return \"\"\nendfunction\n\nfunction! UltiSnips#FileTypeComplete(arglead, cmdline, cursorpos) abort\n    let ret = {}\n    let items = map(\n    \\   split(globpath(&runtimepath, 'syntax/*.vim'), '\\n'),\n    \\   'fnamemodify(v:val, \":t:r\")'\n    \\ )\n    call insert(items, 'all')\n    for item in items\n        if !has_key(ret, item) && item =~ '^'.a:arglead\n            let ret[item] = 1\n        endif\n    endfor\n\n    return sort(keys(ret))\nendfunction\n\nfunction! UltiSnips#ExpandSnippet() abort\n    py3 UltiSnips_Manager.expand()\n    return \"\"\nendfunction\n\nfunction! UltiSnips#ExpandSnippetOrJump() abort\n    call s:compensate_for_pum()\n    py3 UltiSnips_Manager.expand_or_jump()\n    return \"\"\nendfunction\n\nfunction! UltiSnips#JumpOrExpandSnippet() abort\n    call s:compensate_for_pum()\n    py3 UltiSnips_Manager.jump_or_expand()\n    return \"\"\nendfunction\n\nfunction! UltiSnips#ListSnippets() abort\n    py3 UltiSnips_Manager.list_snippets()\n    return \"\"\nendfunction\n\nfunction! UltiSnips#SnippetsInCurrentScope(...) abort\n    let g:current_ulti_dict = {}\n    let all = get(a:, 1, 0)\n    if all\n      let g:current_ulti_dict_info = {}\n    endif\n    py3 UltiSnips_Manager.snippets_in_current_scope(int(vim.eval(\"all\")))\n    return g:current_ulti_dict\nendfunction\n\nfunction! UltiSnips#CanExpandSnippet() abort\n\tpy3 vim.command(\"let can_expand = %d\" % UltiSnips_Manager.can_expand())\n\treturn can_expand\nendfunction\n\nfunction! UltiSnips#CanJumpForwards() abort\n\tpy3 vim.command(\"let can_jump_forwards = %d\" % UltiSnips_Manager.can_jump_forwards())\n\treturn can_jump_forwards\nendfunction\n\nfunction! UltiSnips#CanJumpBackwards() abort\n\tpy3 vim.command(\"let can_jump_backwards = %d\" % UltiSnips_Manager.can_jump_backwards())\n\treturn can_jump_backwards\nendfunction\n\nfunction! UltiSnips#ToggleAutoTrigger() abort\n    py3 vim.command(\"let autotrigger = %d\" % UltiSnips_Manager._toggle_autotrigger())\n    return autotrigger\nendfunction\n\nfunction! UltiSnips#SaveLastVisualSelection() range abort\n    py3 UltiSnips_Manager._save_last_visual_selection()\n    return \"\"\nendfunction\n\nfunction! UltiSnips#JumpBackwards() abort\n    call s:compensate_for_pum()\n    py3 UltiSnips_Manager.jump_backwards()\n    return \"\"\nendfunction\n\nfunction! UltiSnips#JumpForwards() abort\n    call s:compensate_for_pum()\n    py3 UltiSnips_Manager.jump_forwards()\n    return \"\"\nendfunction\n\nfunction! UltiSnips#AddSnippetWithPriority(trigger, value, description, options, filetype, priority) abort\n    py3 trigger = vim.eval(\"a:trigger\")\n    py3 value = vim.eval(\"a:value\")\n    py3 description = vim.eval(\"a:description\")\n    py3 options = vim.eval(\"a:options\")\n    py3 filetype = vim.eval(\"a:filetype\")\n    py3 priority = vim.eval(\"a:priority\")\n    py3 UltiSnips_Manager.add_snippet(trigger, value, description, options, filetype, priority)\n    return \"\"\nendfunction\n\nfunction! UltiSnips#Anon(value, ...) abort\n    \" Takes the same arguments as SnippetManager.expand_anon:\n    \" (value, trigger=\"\", description=\"\", options=\"\")\n    py3 args = vim.eval(\"a:000\")\n    py3 value = vim.eval(\"a:value\")\n    py3 UltiSnips_Manager.expand_anon(value, *args)\n    return \"\"\nendfunction\n\nfunction! UltiSnips#CursorMoved() abort\n    py3 UltiSnips_Manager._cursor_moved()\nendf\n\nfunction! UltiSnips#LeavingBuffer() abort\n    let from_preview = getwinvar(winnr('#'), '&previewwindow')\n    let to_preview = getwinvar(winnr(), '&previewwindow')\n    let from_floating = s:is_floating(win_getid('#'))\n    let to_floating = s:is_floating(win_getid())\n\n    if !(from_preview || to_preview || from_floating || to_floating)\n        py3 UltiSnips_Manager._leaving_buffer()\n    endif\nendf\n\nfunction! UltiSnips#LeavingInsertMode() abort\n    py3 UltiSnips_Manager._leaving_insert_mode()\nendfunction\n\nfunction! UltiSnips#TrackChange() abort\n    py3 UltiSnips_Manager._track_change()\nendfunction\n\nfunction! UltiSnips#CheckFiletype() abort\n    py3 UltiSnips_Manager._check_filetype(vim.eval('&ft'))\nendfunction\n\nfunction! UltiSnips#RefreshSnippets() abort\n    py3 UltiSnips_Manager._refresh_snippets()\nendfunction\n\" }}}\n"
  },
  {
    "path": "autoload/neocomplete/sources/ultisnips.vim",
    "content": "let s:save_cpo = &cpo\nset cpo&vim\n\nlet s:source = {\n   \\ 'name' : 'ultisnips',\n   \\ 'kind' : 'keyword',\n   \\ 'mark' : '[US]',\n   \\ 'rank' : 8,\n   \\ 'matchers' :\n      \\ (g:neocomplete#enable_fuzzy_completion ?\n      \\ ['matcher_fuzzy'] : ['matcher_head']),\n   \\ }\n\nfunction! s:source.gather_candidates(context) abort\n   let suggestions = []\n   let snippets = UltiSnips#SnippetsInCurrentScope()\n   for trigger in keys(snippets)\n      let description = get(snippets, trigger)\n      call add(suggestions, {\n         \\ 'word' : trigger,\n         \\ 'menu' : self.mark . ' '. description,\n         \\ 'kind' : 'snippet'\n         \\ })\n   endfor\n   return suggestions\nendfunction\n\nfunction! neocomplete#sources#ultisnips#define() abort\n   return s:source\nendfunction\n\nlet &cpo = s:save_cpo\nunlet s:save_cpo\n"
  },
  {
    "path": "autoload/unite/sources/ultisnips.vim",
    "content": "let s:save_cpo = &cpo\nset cpo&vim\n\nlet s:unite_source = {\n      \\ 'name': 'ultisnips',\n      \\ 'hooks': {},\n      \\ 'action_table': {},\n      \\ 'syntax' : 'uniteSource__Ultisnips',\n      \\ 'default_action': 'expand',\n      \\ }\n\nlet s:unite_source.action_table.preview = {\n      \\ 'description' : 'ultisnips snippets',\n      \\ 'is_quit' : 0,\n      \\ }\n\nfunction! s:unite_source.hooks.on_syntax(args, context) abort\n  syntax case ignore\n  syntax match uniteSource__UltisnipsHeader /^.*$/\n        \\ containedin=uniteSource__Ultisnips\n  syntax match uniteSource__UltisnipsTrigger /\\v^\\s.{-}\\ze\\s/ contained\n        \\ containedin=uniteSource__UltisnipsHeader\n        \\ nextgroup=uniteSource__UltisnipsDescription\n  syntax match uniteSource__UltisnipsDescription /\\v.{3}\\s\\zs\\w.*$/ contained\n        \\ containedin=uniteSource__UltisnipsHeader\n\n  highlight default link uniteSource__UltisnipsTrigger Identifier\n  highlight default link uniteSource__UltisnipsDescription Statement\nendfunction\n\nfunction! s:unite_source.action_table.preview.func(candidate) abort\n  \" no nice preview at this point, cannot get snippet text\n  let snippet_preview = a:candidate['word']\n  echo snippet_preview\nendfunction\n\nlet s:unite_source.action_table.expand = {\n      \\ 'description': 'expand the current snippet',\n      \\ 'is_quit': 1\n      \\}\n\nfunction! s:unite_source.action_table.expand.func(candidate) abort\n  let delCurrWord = (getline(\".\")[col(\".\")-1] == \" \") ? \"\" : \"diw\"\n  exe \"normal \" . delCurrWord . \"a\" . a:candidate['trigger'] . \" \"\n  call UltiSnips#ExpandSnippet()\n  return ''\nendfunction\n\nfunction! s:unite_source.get_longest_snippet_len(snippet_list) abort\n  let longest = 0\n  for snip in items(a:snippet_list)\n    if strlen(snip['word']) > longest\n      let longest = strlen(snip['word'])\n    endif\n  endfor\n  return longest\nendfunction\n\nfunction! s:unite_source.gather_candidates(args, context) abort\n  let default_val = {'word': '', 'unite__abbr': '', 'is_dummy': 0, 'source':\n        \\  'ultisnips', 'unite__is_marked': 0, 'kind': 'command', 'is_matched': 1,\n        \\    'is_multiline': 0}\n  let snippet_list = UltiSnips#SnippetsInCurrentScope()\n  let max_len = s:unite_source.get_longest_snippet_len(snippet_list)\n  let canditates = []\n  for snip in items(snippet_list)\n    let curr_val = copy(default_val)\n    let curr_val['word'] = printf('%-*s', max_len, snip[0]) . \"     \" . snip[1]\n    let curr_val['trigger'] = snip[0]\n    let curr_val['kind'] = 'common'\n    call add(canditates, curr_val)\n  endfor\n  return canditates\nendfunction\n\nfunction! unite#sources#ultisnips#define() abort\n  return s:unite_source\nendfunction\n\n\"unlet s:unite_source\n\nlet &cpo = s:save_cpo\nunlet s:save_cpo\n"
  },
  {
    "path": "ctags/UltiSnips.cnf",
    "content": "--langdef=UltiSnips\n--langmap=UltiSnips:.snippets\n--regex-UltiSnips=/^snippet (.*)/\\1/s,snippet/\n"
  },
  {
    "path": "doc/UltiSnips-advanced.txt",
    "content": "*UltiSnips-advanced.txt*    Advanced topics for UltiSnips\n\n\n1. Debugging                                    |UltiSnips-Advanced-Debugging|\n   1.1 Setting breakpoints                      |UltiSnips-Advanced-breakpoints|\n   1.2 Accessing Pdb                            |UltiSnips-Advanced-Pdb|\n\n=============================================================================\n1. Debugging                                   *UltiSnips-Advanced-Debugging*\n                                               *g:UltiSnipsDebugServerEnable*\nUltiSnips comes with a remote debugger disabled        *g:UltiSnipsDebugHost*\nby default. When authoring a complex snippet           *g:UltiSnipsDebugPort*\nwith python code, you may want to be able to     *g:UltiSnipsPMDebugBlocking*\nset breakpoints to inspect variables.\nIt is also useful when debugging UltiSnips itself.\n\nNote: Due to some technical limitations, it is not possible for pdb to print\nthe code of the snippet with the `l`/`ll` commands.\n\nYou can enable it and configure it with the folowing variables: >\n\n    let g:UltiSnipsDebugServerEnable=0\n        (bool) Set to 1 to Enable the debug server. If an exception occurs or\n        a breakpoint (see below) is set, a Pdb server is launched, and you can\n        connect to it through telnet.\n\n    let g:UltiSnipsDebugHost='localhost'\n        (string) The host the server listens on\n\n    let g:UltiSnipsDebugPort=8080\n        (int) The port the server listens to\n\n    let g:UltiSnipsPMDebugBlocking=0\n        (bool) Set whether the post mortem debugger should freeze vim.\n        If set to 0, vim will continue to run if an exception\n        arises while expanding a snippet and the error message describing the\n        error will be printed with the directives to connect to the remote\n        debug server. Internally, Pdb will run in another thread and the session\n        will use the python trace back object stored at the moment the error\n        was caught. The variable values and the application state may not reflect\n        the exact state at the moment of the error.\n        If set to 1, vim will simply freeze on the error and will resume\n        only after quiting the debugging session (you must connect via telnet\n        to type the Pdb's `quit` command to resume vim). However, the\n        execution is paused right after caughting the exception, reflecting\n        the exact state when the error occured.\n\nNOTE: Do not run vim as root with `g:UltiSnipsDebugServerEnable=1` since anything\ncan connect to it and do anything with root privileges.\nTry to use these features only for...  debugging... and turn it off when you\nare done.\n\nThese variables can be set at any moment. The debug server will be active\nonly when an exception arises (or a breakpoint set as below is reached),\nand only if `g:UltiSnipsDebugServerEnable` is set at the moment of the\nerror. It will be innactive as soon as the `quit` command is issued\nfrom telnet.\n\n1.1 Setting breakpoints                      *UltiSnips-Advanced-breakpoints*\n-----------------------\n\nThe easiest way of setting a breakpoint inside a snippet or UltiSnips\ninternal code is the following: >\n\n    from UltiSnips.remote_pdb import RemotePDB\n    RemotePDB.breakpoint()\n\n...You can also raise an exception since it will be caught, and then will\nlaunch the post-mortem session. However, using the breakpoint method allows\nto continue the execution once the debugger quit.\n\n1.2 Accessing Pdb                                    *UltiSnips-Advanced-Pdb*\n-----------------\n\nEven though it's possible to use the builtin Pdb, (or any other compatible\ndebugger), the best experience is achived with Pdb++.\nYou can install it this way: >\n\n    pip install pdbpp\n\nIt is a no-configuration replacement of the built-in pdb.\n\nTo connect to the pdb server, simply use a telnet-like client.\nTo have readline support (arrow keys working and history), you can use socat: >\n\n    socat READLINE,history=$HOME/.ultisnips-dbg-history TCP:localhost:8080\n\n(Change `localhost` and `8080` to match your configuration)\nTo leave the server and continue the execution, run Pdb's `quit` command\n\nKnown issue: Tab completion is not supported yet.\n\n"
  },
  {
    "path": "doc/UltiSnips.txt",
    "content": "*UltiSnips.txt*    For Vim version 8.0 or later.\n\n        The Ultimate Plugin for Snippets in Vim~\n\nUltiSnips                                      *snippet* *snippets* *UltiSnips*\n\n1. Description                                  |UltiSnips-description|\n   1.1 Requirements                             |UltiSnips-requirements|\n   1.2 Acknowledgments                          |UltiSnips-acknowledgments|\n2. Installation and Updating                    |UltiSnips-install-and-update|\n3. Settings & Commands                          |UltiSnips-settings|\n   3.1 Commands                                 |UltiSnips-commands|\n      3.1.1 UltiSnipsEdit                       |UltiSnipsEdit|\n      3.1.2 UltiSnipsAddFiletypes               |UltiSnipsAddFiletypes|\n   3.2 Triggers                                 |UltiSnips-triggers|\n      3.2.1 Trigger key mappings                |UltiSnips-trigger-key-mappings|\n      3.2.2 Using your own trigger functions    |UltiSnips-trigger-functions|\n      3.2.3 Custom autocommands                 |UltiSnips-custom-autocommands|\n      3.2.4 Direct use of Python API            |UltiSnips-use-python-api|\n   3.3 Warning About Select Mode Mappings       |UltiSnips-warning-smappings|\n   3.4 Functions                                |UltiSnips-functions|\n      3.4.1 UltiSnips#AddSnippetWithPriority    |UltiSnips#AddSnippetWithPriority|\n      3.4.2 UltiSnips#Anon                      |UltiSnips#Anon|\n      3.4.3 UltiSnips#SnippetsInCurrentScope    |UltiSnips#SnippetsInCurrentScope|\n      3.4.4 UltiSnips#CanExpandSnippet          |UltiSnips#CanExpandSnippet|\n      3.4.5 UltiSnips#CanJumpForwards           |UltiSnips#CanJumpForwards|\n      3.4.6 UltiSnips#CanJumpBackwards          |UltiSnips#CanJumpBackwards|\n   3.5 Missing python support                   |UltiSnips-python-warning|\n4. Authoring snippets                           |UltiSnips-authoring-snippets|\n   4.1 Basics                                   |UltiSnips-basics|\n      4.1.1 How snippets are loaded             |UltiSnips-how-snippets-are-loaded|\n      4.1.2 Basic syntax                        |UltiSnips-basic-syntax|\n      4.1.3 Snippet Options                     |UltiSnips-snippet-options|\n      4.1.4 Character Escaping                  |UltiSnips-character-escaping|\n      4.1.5 Snippets text-objects               |UltiSnips-snippet-text-objects|\n   4.2 Plaintext Snippets                       |UltiSnips-plaintext-snippets|\n   4.3 Visual Placeholder                       |UltiSnips-visual-placeholder|\n   4.4 Interpolation                            |UltiSnips-interpolation|\n      4.4.1 Shellcode                           |UltiSnips-shellcode|\n      4.4.2 VimScript                           |UltiSnips-vimscript|\n      4.4.3 Python                              |UltiSnips-python|\n      4.4.4 Global Snippets                     |UltiSnips-globals|\n   4.5 Tabstops and Placeholders                |UltiSnips-tabstops|\n   4.6 Mirrors                                  |UltiSnips-mirrors|\n   4.7 Transformations                          |UltiSnips-transformations|\n      4.7.1 Replacement String                  |UltiSnips-replacement-string|\n      4.7.2 Demos                               |UltiSnips-demos|\n   4.8 Clearing snippets                        |UltiSnips-clearing-snippets|\n   4.9 Custom context snippets                  |UltiSnips-custom-context-snippets|\n   4.10 Snippet actions                         |UltiSnips-snippet-actions|\n      4.10.1 Pre-expand actions                 |UltiSnips-pre-expand-actions|\n      4.10.2 Post-expand actions                |UltiSnips-post-expand-actions|\n      4.10.3 Post-jump actions                  |UltiSnips-post-jump-actions|\n   4.11 Autotrigger                             |UltiSnips-autotrigger|\n5. UltiSnips and Other Plugins                  |UltiSnips-other-plugins|\n   5.1 Existing Integrations                    |UltiSnips-integrations|\n   5.2 Extending UltiSnips                      |UltiSnips-extending|\n6. Debugging                                    |UltiSnips-Debugging|\n7. FAQ                                          |UltiSnips-FAQ|\n8. Helping Out                                  |UltiSnips-helping|\n9. Contributors                                 |UltiSnips-contributors|\n\nThis plugin only works if 'compatible' is not set.\n{Vi does not have any of these features}\n{only available when |+python3| has been enabled at compile time}\n\n\n==============================================================================\n1. Description                                        *UltiSnips-description*\n\nUltiSnips provides snippet management for the Vim editor. A snippet is a short\npiece of text that is either re-used often or contains a lot of redundant\ntext. UltiSnips allows you to insert a snippet with only a few key strokes.\nSnippets are common in structured text like source code but can also be used\nfor general editing like inserting a signature in an email or inserting the\ncurrent date in a text file.\n\n@SirVer posted several short screencasts which make a great introduction to\nUltiSnips, illustrating its features and usage.\n\nhttp://www.sirver.net/blog/2011/12/30/first-episode-of-ultisnips-screencast/\nhttp://www.sirver.net/blog/2012/01/08/second-episode-of-ultisnips-screencast/\nhttp://www.sirver.net/blog/2012/02/05/third-episode-of-ultisnips-screencast/\nhttp://www.sirver.net/blog/2012/03/31/fourth-episode-of-ultisnips-screencast/\n\nAlso the excellent [Vimcasts](http://vimcasts.org) dedicated three episodes to\nUltiSnips:\n\nhttp://vimcasts.org/episodes/meet-ultisnips/\nhttp://vimcasts.org/episodes/ultisnips-python-interpolation/\nhttp://vimcasts.org/episodes/ultisnips-visual-placeholder/\n\n1.1 Requirements                                     *UltiSnips-requirements*\n----------------\n\nThis plugin works with Vim version 8.0 or later with Python 3 support enabled.\nIt only works if the 'compatible' setting is not set.\n\nThe Python 3.x interface must be available. In other words, Vim\nmust be compiled with the |+python3| feature.\nThe following commands show how to test if you have python compiled in Vim.\nThey print '1' if the python version is compiled in, '0' if not.\n\nTest if Vim is compiled with python version 3.x: >\n    :echo has(\"python3\")\nThe python version Vim is linked against can be found with: >\n    :py3 import sys; print(sys.version)\n\nNote that Vim is maybe not using your system-wide installed python version, so\nmake sure to check the Python version inside of Vim.\n\n\n1.2 Acknowledgments                               *UltiSnips-acknowledgments*\n-------------------\n\nUltiSnips was inspired by the snippets feature of TextMate\n(http://macromates.com/), the GUI text editor for Mac OS X. Managing snippets\nin Vim is not new. I want to thank Michael Sanders, the author of snipMate,\nfor some implementation details I borrowed from his plugin and for the\npermission to use his snippets.\n\n\n=============================================================================\n2. Installation and Updating                       *UltiSnips-install-and-update*\n\nThe recommended way of getting UltiSnips is to track SirVer/ultisnips on\ngithub. The master branch is always stable.\n\nUsing Pathogen:                                     *UltiSnips-using-pathogen*\n\nIf you are a pathogen user, you can track the official mirror of UltiSnips on\ngithub: >\n\n   $ cd ~/.vim/bundle && git clone git://github.com/SirVer/ultisnips.git\n\nIf you also want the default snippets, also track >\n\n   $ cd ~/.vim/bundle && git clone git://github.com/honza/vim-snippets.git\n\nSee the pathogen documentation for more details on how to update a bundle.\n\n\nUsing a downloaded packet:               *UltiSnips-using-a-downloaded-packet*\n\nDownload the packet and unpack into a directory of your choice. Then add this\ndirectory to your Vim runtime path by adding this line to your vimrc file. >\n   set runtimepath+=~/.vim/ultisnips_rep\n\nUltiSnips also needs Vim files from the ftdetect/ directory. Unfortunately,\nVim only allows this directory in the .vim directory. You therefore have to\nsymlink/copy the files: >\n   mkdir -p ~/.vim/ftdetect/\n   ln -s ~/.vim/ultisnips_rep/ftdetect/* ~/.vim/ftdetect/\n\nRestart Vim and UltiSnips should work. To access the help, use >\n   :helptags ~/.vim/ultisnips_rep/doc\n   :help UltiSnips\n\nUltiSnips comes without snippets. An excellent selection of snippets can be\nfound here: https://github.com/honza/vim-snippets\n\n=============================================================================\n3. Settings & Commands                                   *UltiSnips-settings*\n\n3.1 Commands                                             *UltiSnips-commands*\n------------\n\n 3.1.1 UltiSnipsEdit                                     *:UltiSnipsEdit*\n\nThe UltiSnipsEdit command opens a private snippet definition file for the\ncurrent filetype. If no snippet file exists, a new file is created. If used as\nUltiSnipsEdit! all public snippet files that exist are taken into account too. If\nmultiple files match the search, the user gets to choose the file.\n\nThere are several variables associated with the UltiSnipsEdit command.\n\n                                                        *g:UltiSnipsEditSplit*\ng:UltiSnipsEditSplit        Defines how the edit window is opened. Possible\n                            values:\n                            |normal|         Default. Opens in the current window.\n                            |tabdo|          Opens the window in a new tab.\n                            |horizontal|     Splits the window horizontally.\n                            |vertical|       Splits the window vertically.\n                            |context|        Splits the window vertically or\n                                           horizontally depending on context.\n\n                                                        *g:UltiSnipsSnippetStorageDirectoryForUltiSnipsEdit*\ng:UltiSnipsSnippetStorageDirectoryForUltiSnipsEdit\n                            A single absolute path to a directory which will\n                            be used as the storage for location for\n                            `UltiSnipsEdit`. This means that UltiSnipsEdit no\n                            longer searches all paths in\n                            `g:UltiSnipsSnippetDirectories` for snippets to\n                            edit, but only this one. Note that this does not\n                            imply that the snippet expansion engine also\n                            searches this directory. Please read\n                            |UltiSnips-how-snippets-are-loaded| for details.\n\n\n                                                        *g:UltiSnipsSnippetDirectories*\ng:UltiSnipsSnippetDirectories\n                            An array of relative directory names OR an array\n                            with a single absolute path. Defaults to [\n                            \"UltiSnips\" ]. No entry in this list must be\n                            \"snippets\". Please read\n                            |UltiSnips-how-snippets-are-loaded| for details.\n\n                                                        *g:UltiSnipsEnableSnipMate*\ng:UltiSnipsEnableSnipMate\n                            Enable looking for SnipMate snippets in\n                            &runtimepath. UltiSnips will search only for\n                            directories named 'snippets' while looking for\n                            SnipMate snippets. Defaults to \"1\", so UltiSnips\n                            will look for SnipMate snippets.\n\n\n 3.1.2 UltiSnipsAddFiletypes                            *:UltiSnipsAddFiletypes*\n\nThe UltiSnipsAddFiletypes command allows for explicit merging of other snippet\nfiletypes for the current buffer. For example, if you edit a .rst file but\nalso want the Lua snippets to be available you can issue the command >\n\n   :UltiSnipsAddFiletypes rst.lua\n\nusing the dotted filetype syntax. Order is important, the first filetype in\nthis list will be the one used for UltiSnipsEdit and the list is\nordered by evaluation priority. For example you might add this to your\nftplugin/rails.vim >\n\n   :UltiSnipsAddFiletypes rails.ruby\n\nI mention rails first because I want to edit rails snippets when using\nUltiSnipsEdit and because rails snippets should overwrite equivalent ruby\nsnippets. The priority will now be rails -> ruby -> all. If you have some\nspecial programming snippets that should have lower priority than your ruby\nsnippets you can call >\n\n   :UltiSnipsAddFiletypes ruby.programming\n\nThe priority will then be rails -> ruby -> programming -> all.\n\n3.2 Triggers                                             *UltiSnips-triggers*\n------------\n\n 3.2.1 Trigger key mappings                   *UltiSnips-trigger-key-mappings*\n\n                           *g:UltiSnipsExpandTrigger* *g:UltiSnipsListSnippets*\n               *g:UltiSnipsJumpForwardTrigger* *g:UltiSnipsJumpBackwardTrigger*\n              *g:UltiSnipsExpandOrJumpTrigger* *g:UltiSnipsJumpOrExpandTrigger*\n\nYou can define the keys used to trigger UltiSnips actions by setting global\nvariables. Variables define the keys used to expand a snippet, jump forward\nand jump backwards within a snippet, and list all available snippets in the\ncurrent expand context. Be advised, that some terminal emulators don't send\n<c-tab> (and others, like <c-h>) to the running program. The variables with\ntheir default values are: >\n   g:UltiSnipsExpandTrigger               <tab>\n   g:UltiSnipsListSnippets                <c-tab>\n   g:UltiSnipsJumpForwardTrigger          <c-j>\n   g:UltiSnipsJumpBackwardTrigger         <c-k>\n\nUltiSnips will only map the jump triggers while a snippet is active to\ninterfere as little as possible with other mappings.\n\nThe default value for g:UltiSnipsJumpBackwardTrigger interferes with the\nbuilt-in complete function: |i_CTRL-X_CTRL-K|. A workaround is to add the\nfollowing to your vimrc file or switching to a plugin like Supertab or\nYouCompleteMe. >\n   inoremap <c-x><c-k> <c-x><c-k>\n\nIf you prefer to use the same trigger for expanding snippets and jumping\nforward, g:UltiSnipsExpandOrJumpTrigger and g:UltiSnipsJumpOrExpandTrigger\nvariables are what you want. Try to set g:UltiSnipsExpandOrJumpTrigger if\nyou give priority to expanding snippets. It'll expand snippets first when\nyou are in a position where you can both expand snippets and jump forward. >\n   let g:UltiSnipsExpandOrJumpTrigger = \"<tab>\"\n\nOr else, if you have a preference for jumping forward first, set\ng:UltiSnipsJumpOrExpandTrigger instead. >\n   let g:UltiSnipsJumpOrExpandTrigger = \"<tab>\"\n\nIf both g:UltiSnipsExpandOrJumpTrigger and g:UltiSnipsJumpOrExpandTrigger\nis set, g:UltiSnipsExpandOrJumpTrigger variable will take effects.\n\n3.2.2 Using your own trigger functions           *UltiSnips-trigger-functions*\n\nFor advanced users there are functions that you can map directly to a\nkey and that correspond to some of the triggers previously defined:\n   g:UltiSnipsExpandTrigger        <--> UltiSnips#ExpandSnippet\n   g:UltiSnipsJumpForwardTrigger   <--> UltiSnips#JumpForwards\n   g:UltiSnipsJumpBackwardTrigger  <--> UltiSnips#JumpBackwards\n   g:UltiSnipsExpandOrJumpTrigger  <--> UltiSnips#ExpandSnippetOrJump\n   g:UltiSnipsJumpOrExpandTrigger  <--> UltiSnips#JumpOrExpandSnippet\n\nIf you have g:UltiSnipsExpandTrigger and g:UltiSnipsJumpForwardTrigger set\nto the same value then the function you are actually going to use is\nUltiSnips#ExpandSnippetOrJump.\n\nEach time any of the functions UltiSnips#ExpandSnippet,\nUltiSnips#ExpandSnippetOrJump, UltiSnips#JumpOrExpandSnippet,\nUltiSnips#JumpForwards or UltiSnips#JumpBackwards is called a global variable\nis set that contains the return value of the corresponding function.\n\nThe corresponding variables and functions are:\nUltiSnips#ExpandSnippet       --> g:ulti_expand_res (0: fail, 1: success)\nUltiSnips#ExpandSnippetOrJump --> g:ulti_expand_or_jump_res (0: fail,\n                                                    1: expand, 2: jump)\nUltiSnips#JumpOrExpandSnippet --> g:ulti_expand_or_jump_res (0: fail,\n                                                    1: expand, 2: jump)\nUltiSnips#JumpForwards        --> g:ulti_jump_forwards_res (0: fail, 1: success)\nUltiSnips#JumpBackwards       --> g:ulti_jump_backwards_res (0: fail, 1: success)\n\nTo see how these return values may come in handy, suppose that you want to map\na key to expand or jump, but if none of these actions is successful you want\nto call another function. UltiSnips already does this automatically for\nsupertab, but this allows you individual fine tuning of your Tab key usage.\n\nUsage is as follows: You define a function >\n\n   let g:ulti_expand_or_jump_res = 0 \"default value, just set once\n   function! Ulti_ExpandOrJump_and_getRes()\n     call UltiSnips#ExpandSnippetOrJump()\n     return g:ulti_expand_or_jump_res\n   endfunction\n\nthen you define your mapping as >\n\n   inoremap <NL> <C-R>=(Ulti_ExpandOrJump_and_getRes() > 0)?\"\":IMAP_Jumpfunc('', 0)<CR>\n\nand if the you can't expand or jump from the current location then the\nalternative function IMAP_Jumpfunc('', 0) is called.\n\n 3.2.3 Custom autocommands                       *UltiSnips-custom-autocommands*\n\nNote Autocommands must not change the buffer in any way. If lines are added,\ndeleted, or modified it will confuse UltiSnips which might scramble your\nsnippet contents.\n\n                          *UltiSnipsEnterFirstSnippet* *UltiSnipsExitLastSnippet*\nFor maximum compatibility with other plug-ins, UltiSnips sets up some special\nstate, include mappings and autocommands, when a snippet starts being\nexpanded, and tears them down once the last snippet has been exited. In order\nto make it possible to override these \"inner\" settings, it fires the following\n\"User\" autocommands:\n\nUltiSnipsEnterFirstSnippet\nUltiSnipsExitLastSnippet\n\nFor example, to call a pair of custom functions in response to these events,\nyou might do: >\n\n   autocmd! User UltiSnipsEnterFirstSnippet\n   autocmd User UltiSnipsEnterFirstSnippet call CustomInnerKeyMapper()\n   autocmd! User UltiSnipsExitLastSnippet\n   autocmd User UltiSnipsExitLastSnippet call CustomInnerKeyUnmapper()\n\nNote that snippet expansion may be nested, in which case\n|UltiSnipsEnterFirstSnippet| will fire only as the first (outermost) snippet\nis entered, and |UltiSnipsExitLastSnippet| will only fire once the last\n(outermost) snippet have been exited.\n\n\n 3.2.4 Direct use of Python API                   *UltiSnips-use-python-api*\n\nFor even more advanced usage, you can directly write python functions using\nUltiSnip's python modules. This is an internal and therefore unstable API and\nnot recommended though.\n\nHere is a small example function that expands a snippet: >\n\n   function! s:Ulti_ExpandSnip()\n   Python << EOF\n   import sys, vim\n   from UltiSnips import UltiSnips_Manager\n   UltiSnips_Manager.expand()\n   EOF\n   return \"\"\n   endfunction\n\n\n3.3 Warning About Select Mode Mappings          *UltiSnips-warning-smappings*\n--------------------------------------\n\nVim's help document for |mapmode-s| states: >\n   NOTE: Mapping a printable character in Select mode may confuse the user.\n   It's better to explicitly use :xmap and :smap for printable characters.  Or\n   use :sunmap after defining the mapping.\n\nHowever, most Vim plugins, including some default Vim plugins, do not adhere\nto this. UltiSnips uses Select mode to mark tabstops in snippets for\noverwriting. Existing Visual+Select mode mappings will interfere. Therefore,\nUltiSnips issues a |:sunmap| command to remove each Select mode mapping for\nprintable characters. No other mappings are touched. In particular, UltiSnips\ndoes not change existing normal, insert or visual mode mappings.\n\nIf this behavior is not desired, you can disable it by adding this line to\nyour vimrc file. >\n   let g:UltiSnipsRemoveSelectModeMappings = 0\n\nIf you want to disable this feature for specific mappings only, add them to\nthe list of mappings to be ignored. For example, the following lines in your\nvimrc file will unmap all Select mode mappings except those mappings\ncontaining either the string \"somePlugin\" or the string \"otherPlugin\" in its\ncomplete definition as listed by the |:smap| command. >\n\n   let g:UltiSnipsRemoveSelectModeMappings = 1\n   let g:UltiSnipsMappingsToIgnore = [ \"somePlugin\", \"otherPlugin\" ]\n\n\n3.4 Functions                                           *UltiSnips-functions*\n-------------\n\nUltiSnips provides some functions for extending core functionality.\n\n\n 3.4.1 UltiSnips#AddSnippetWithPriority    *UltiSnips#AddSnippetWithPriority*\n\nThe first function is UltiSnips#AddSnippetWithPriority(trigger, value, description,\noptions, filetyp, priority). It adds a new snippet to the current list of\nsnippets. See |UltiSnips-authoring-snippets| for details most of the function\narguments. The priority is a number that defines which snippet should be\npreferred over others. See the priority keyword in |UltiSnips-basic-syntax|.\n\n\n 3.4.2 UltiSnips#Anon                                        *UltiSnips#Anon*\n\nThe second function is UltiSnips#Anon(value, ...). It expands an anonymous\nsnippet. Anonymous snippets are defined on the spot, expanded and immediately\ndiscarded again. Anonymous snippets are not added to the global list of\nsnippets, so they cannot be expanded a second time unless the function is\ncalled again. The function takes three optional arguments, in order: trigger,\ndescription, options. Arguments coincide with the arguments of the\n|UltiSnips#AddSnippetWithPriority| function of the same name. The trigger and\noptions arguments can change the way the snippet expands. Same options\ncan be specified as in the snippet definition. See full list of options at\n|UltiSnips-snippet-options|. The description is unused at this point.\n\nAn example use case might be this line from a reStructuredText plugin file:\n\n   inoremap <silent> $$ $$<C-R>=UltiSnips#Anon(':latex:\\`$1\\`', '$$')<cr>\n\nThis expands the snippet whenever two $ signs are typed.\nNote: The right-hand side of the mapping starts with an immediate retype of\nthe '$$' trigger and passes '$$' to the function as the trigger argument.\nThis is required in order for UltiSnips to have access to the characters\ntyped so it can determine if the trigger matches or not. A more elegant way of\ncreating such a snippet could be to use |UltiSnips-autotrigger|.\n\n 3.4.3 UltiSnips#SnippetsInCurrentScope    *UltiSnips#SnippetsInCurrentScope*\n\nUltiSnips#SnippetsInCurrentScope returns a vim dictionary with the snippets\nwhose trigger matches the current word.  If you need all snippets information\nfor the current buffer, you can simply pass 1 (which means all) as first\nargument of this function, and use a global variable g:current_ulti_dict_info\nto get the result (see example below).\n\nThis function does not add any new functionality to ultisnips directly but\nallows to use third party plugins to integrate the current available snippets.\nFor example, all completion plugins that integrate with UltiSnips use this\nfunction.\n\nAnother example on how to use this function consider the following function\nand mapping definition:\n\nfunction! ExpandPossibleShorterSnippet()\n  if len(UltiSnips#SnippetsInCurrentScope()) == 1 \"only one candidate...\n    let curr_key = keys(UltiSnips#SnippetsInCurrentScope())[0]\n    normal diw\n    exe \"normal a\" . curr_key\n    exe \"normal a \"\n    return 1\n  endif\n  return 0\nendfunction\ninoremap <silent> <C-L> <C-R>=(ExpandPossibleShorterSnippet() == 0? '': UltiSnips#ExpandSnippet())<CR>\n\nIf the trigger for your snippet is lorem, you type lor, and you have no other\nsnippets whose trigger matches lor then hitting <C-L> will expand to whatever\nlorem expands to.\n\nOne more example on how to use this function to extract all snippets available\nin the current buffer: >\n\nfunction! GetAllSnippets()\n  call UltiSnips#SnippetsInCurrentScope(1)\n  let list = []\n  for [key, info] in items(g:current_ulti_dict_info)\n    let parts = split(info.location, ':')\n    call add(list, {\n      \\\"key\": key,\n      \\\"path\": parts[0],\n      \\\"linenr\": parts[1],\n      \\\"description\": info.description,\n      \\})\n  endfor\n  return list\nendfunction\n\n 3.4.4 UltiSnips#CanExpandSnippet    *UltiSnips#CanExpandSnippet*\n\nThis function returns 1 if UltiSnips can actually do a meaningful expansion in\nthe current situation. This is useful in conditional mappings.\n\n 3.4.5 UltiSnips#CanJumpForwards    *UltiSnips#CanJumpForwards*\n\nThis function returns 1 if UltiSnips can jump forward in the current\nsituation. This is useful in conditional mappings.\n\n 3.4.6 UltiSnips#CanJumpBackwards    *UltiSnips#CanJumpBackwards*\n\nThis function returns 1 if UltiSnips can jump backwards in the current\nsituation. This is useful in conditional mappings.\n\n 3.4.7 UltiSnips#ToggleAutoTrigger              *UltiSnips#ToggleAutoTrigger*\n\nThis function toggles the `autotrigger` functionality. Its return value\ncorresponds to the new state of the `autotrigger` (0: disabled, 1: enabled).\n\nFor example, the following mapping can be used to toggle the `autotrigger`\nin the Insert mode: >\n    inoremap <silent> <C-t> <CMD>call UltiSnips#ToggleAutoTrigger()<CR>\n<\n                                                    *g:UltiSnipsAutoTrigger*\nBy default, `autotrigger` is enabled (relevant for snippets with the option 'A').\nIf you want to disable it by default, add the following line to your vimrc: >\n    let g:UltiSnipsAutoTrigger = 0\n\n\n3.5 Warning about missing python support           *UltiSnips-python-warning*\n----------------------------------------\n\nWhen UltiSnips is loaded, it will check that the running Vim was compiled with\npython support.  If no support is detected, a warning will be displayed and\nloading of UltiSnips will be skipped.\n\nIf you would like to suppress this warning message, you may add the following\nline to your vimrc file.\n\n    let g:UltiSnipsNoPythonWarning = 1\n\nThis may be useful if your Vim configuration files are shared across several\nsystems where some of them may not have Vim compiled with python support.\n\n=============================================================================\n4. Authoring snippets                             *UltiSnips-authoring-snippets*\n\n4.1 Basics                                        *UltiSnips-basics*\n----------\n\n 4.1.1 How snippets are loaded               *UltiSnips-how-snippets-are-loaded*\n\nSnippet definition files are stored in snippet directories. The main\ncontrolling variable for where these directories are searched for is the\nlist variable, set by default to >\n\n   let g:UltiSnipsSnippetDirectories=[\"UltiSnips\"]\n\nNote that \"snippets\" is reserved for snipMate snippets and cannot be used in\nthis list. Whether snipMate snippets are active or not is controlled by the\nvariable `g:UltiSnipsEnableSnipMate`.\n\nUltiSnips will search each 'runtimepath' directory for the subdirectory names\ndefined in g:UltiSnipsSnippetDirectories in the order they are defined. For\nexample, if you keep your snippets in `~/.vim/mycoolsnippets` and you want to\nmake use of the UltiSnips snippets that come with other plugins, add the\nfollowing to your vimrc file. >\n\n   let g:UltiSnipsSnippetDirectories=[\"UltiSnips\", \"mycoolsnippets\"]\n\nIf you do not want to use the third party snippets that come with plugins,\ndefine the variable accordingly: >\n\n   let g:UltiSnipsSnippetDirectories=[\"mycoolsnippets\"]\n\nIf the list has only one entry that is an absolute path, UltiSnips will not\niterate through &runtimepath but only look in this one directory for snippets.\nThis can lead to significant speedup. This means you will miss out on snippets\nthat are shipped with third party plugins. You'll need to copy them into this\ndirectory manually.\n\nAn example configuration could be: >\n\n    let g:UltiSnipsSnippetDirectories=[$HOME.'/.vim/UltiSnips']\n\nYou can also redefine the search path on a buffer by buffer basis by setting\nthe variable b:UltiSnipsSnippetDirectories. This variable takes precedence\nover the global variable.\n\nThere is an additional variable which does not control the search path for\nsnippets at expansion time, but controls where `:UltiSnipsEdit` is looking for\nsnippets. If this variable is set to a single absolute path it will only\naffect where the edit command is looking for and writing snippets too. This is\nuseful if you want to use third party snippets, but have all your self created\nsnippets in a single place without being asked where to put the file on edit.\n\nUsing a strategy similar to how Vim detects |ftplugins|, UltiSnips iterates\nover the snippet definition directories looking for files with names of the\nfollowing patterns: ft.snippets, ft_*.snippets, or ft/*, where \"ft\" is the\n'filetype' of the current document and \"*\" is a shell-like wildcard matching\nany string including the empty string. The following table shows some typical\nsnippet filenames and their associated filetype.\n\n    snippet filename         filetype ~\n    ruby.snippets            ruby\n    perl.snippets            perl\n    c.snippets               c\n    c_my.snippets            c\n    c/a                      c\n    c/b.snippets             c\n    all.snippets             all\n    all/a.snippets           all\n\nThe 'all' filetype is unique. It represents snippets available for use when\nediting any document regardless of the filetype. A date insertion snippet, for\nexample, would fit well in the all.snippets file.\n\nUltiSnips understands Vim's dotted filetype syntax. For example, if you define\na dotted filetype for the CUDA C++ framework, e.g. \":set ft=cuda.cpp\", then\nUltiSnips will search for and activate snippets for both the cuda and cpp\nfiletypes.\n\n 4.1.2 Basic syntax                                     *UltiSnips-basic-syntax*\n\nThe snippets file syntax is simple. All lines starting with a # character are\nconsidered comments. Comments are ignored by UltiSnips. Use them to document\nsnippets.\n\nA line beginning with the keyword 'extends' provides a way of combining\nsnippet files. When the 'extends' directive is included in a snippet file, it\ninstructs UltiSnips to include all snippets from the indicated filetypes.\n\nThe syntax looks like this: >\n   extends ft1, ft2, ft3\n\nFor example, the first line in cpp.snippets looks like this: >\n   extends c\nWhen UltiSnips activates snippets for a cpp file, it first looks for all c\nsnippets and activates them as well. This is a convenient way to create\nspecialized snippet files from more general ones. Multiple 'extends' lines are\npermitted in a snippet file, and they can be included anywhere in the file.\n\n\nA line beginning with the keyword 'priority' sets the priority for all\nsnippets defined in the current file after this line. The default priority for\na file is always 0. When a snippet should be expanded, UltiSnips will collect\nall snippet definitions from all sources that match the trigger and keep only\nthe ones with the highest priority. For example, all shipped snippets have a\npriority < 0, so that user defined snippets always overwrite shipped snippets.\n\n\nA line beginning with the keyword 'snippet' marks the beginning of a snippet\ndefinition and a line starting with  the keyword 'endsnippet' marks the end.\nThe snippet definition is placed between the lines. Here is a snippet of an\n'if' statement for the Unix shell (sh) filetype. >\n\n    snippet if \"if ... then (if)\"\n    if ${2:[[ ${1:condition} ]]}; then\n            ${0:#statements}\n    fi\n    endsnippet\n\nThe start line takes the following form: >\n\n   snippet trigger_word [ \"description\" [ options ] ]\n\nThe trigger_word is required, but the description and options are optional.\n\nThe 'trigger_word' is the word or string sequence used to trigger the snippet.\nGenerally a single word is used but the trigger_word can include spaces. If you\nwish to include spaces, you must wrap the tab trigger in quotes. >\n\n    snippet \"tab trigger\" [ \"description\" [ options ] ]\n\nThe quotes are not part of the trigger. To activate the snippet type: tab trigger\nfollowed by the snippet expand character.\n\nIt is not technically necessary to use quotes to wrap a trigger with spaces.\nAny matching characters will do. For example, this is a valid snippet starting\nline. >\n    snippet !tab trigger! [ \"description\" [ options ] ]\n\nQuotes can be included as part of the trigger by wrapping the trigger in\nanother character. >\n    snippet !\"tab trigger\"! [ \"description\" [ options ] ]\n\nTo activate this snippet one would type: \"tab trigger\"\n\nThe 'description' is a string describing the trigger. It is helpful for\ndocumenting the snippet and for distinguishing it from other snippets with the\nsame tab trigger. When a snippet is activated and more than one tab trigger\nmatch, UltiSnips displays a list of the matching snippets with their\ndescriptions. The user then selects the snippet they want.\n\n\n\n\n 4.1.3 Snippet Options:                           *UltiSnips-snippet-options*\n\nThe 'options' control the behavior of the snippet. Options are indicated by\nsingle characters. The 'options' characters for a snippet are combined into\na word without spaces.\n\nThe options currently supported are: >\n   b   Beginning of line - A snippet with this option is expanded only if the\n       tab trigger is the first word on the line. In other words, if only\n       whitespace precedes the tab trigger, expand. The default is to expand\n       snippets at any position regardless of the preceding non-whitespace\n       characters.\n\n   i   In-word expansion - By default a snippet is expanded only if the tab\n       trigger is the first word on the line or is preceded by one or more\n       whitespace characters. A snippet with this option is expanded\n       regardless of the preceding character. In other words, the snippet can\n       be triggered in the middle of a word.\n\n   w   Word boundary - With this option, the snippet is expanded if\n       the tab trigger start matches a word boundary and the tab trigger end\n       matches a word boundary. In other words the tab trigger must be\n       preceded and followed by non-word characters. Word characters are\n       defined by the 'iskeyword' setting. Use this option, for example, to\n       permit expansion where the tab trigger follows punctuation without\n       expanding suffixes of larger words. This option overrides 'i'.\n\n   r   Regular expression - With this option, the tab trigger is expected to\n       be a python regular expression. The snippet is expanded if the recently\n       typed characters match the regular expression. Note: The regular\n       expression MUST be quoted (or surrounded with another character) like a\n       multi-word tab trigger (see above) whether it has spaces or not. A\n       resulting match is passed to any python code blocks in the snippet\n       definition as the local variable \"match\". Regular expression snippets\n       can be triggered in-word by default. To avoid this you can start your\n       regex pattern with '\\b', although this will not respect your\n       'iskeyword' setting.\n\n   t   Do not expand tabs - If a snippet definition includes leading tab\n       characters, by default UltiSnips expands the tab characters honoring\n       the Vim 'shiftwidth', 'softtabstop', 'expandtab' and 'tabstop'\n       indentation settings. (For example, if 'expandtab' is set, the tab is\n       replaced with spaces.) If this option is set, UltiSnips will ignore the\n       Vim settings and insert the tab characters as is. This option is useful\n       for snippets involved with tab delimited formats.\n\n   s   Remove whitespace immediately before the cursor at the end of a line\n       before jumping to the next tabstop.  This is useful if there is a\n       tabstop with optional text at the end of a line.\n\n   m   Trim all whitespaces from right side of snippet lines. Useful when\n       snippet contains empty lines which should remain empty after expanding.\n       Without this option empty lines in snippets definition will have\n       indentation too.\n\n   e   Custom context snippet - With this option expansion of snippet can be\n       controlled not only by previous characters in line, but by any given\n       python expression. This option can be specified along with other\n       options, like 'b'. See |UltiSnips-custom-context-snippets| for more info.\n\n   A   Snippet will be triggered automatically, when condition matches.\n       See |UltiSnips-autotrigger| for more info.\n\nThe end line is the 'endsnippet' keyword on a line by itself. >\n\n   endsnippet\n\nWhen parsing snippet files, UltiSnips chops the trailing newline character\nfrom the 'endsnippet' end line.\n\n\n 4.1.4 Character Escaping:                     *UltiSnips-character-escaping*\n\nIn snippet definitions, the characters '`', '{', '$' and '\\' have special\nmeaning. If you want to insert one of these characters literally, escape them\nwith a backslash, '\\'.\n\n\n 4.1.5 Snippets text-objects                   *UltiSnips-snippet-text-objects*\n\nInside a snippets buffer, the following text objects are available:\n>\n   iS   inside snippet\n   aS   around snippet (including empty lines that follow)\n\n\n4.2 Plaintext Snippets                         *UltiSnips-plaintext-snippets*\n----------------------\n\nTo illustrate plaintext snippets, let's begin with a simple example. You can\ntry the examples yourself. Simply edit a new file with Vim. Example snippets\nwill be added to the 'all.snippets' file, so you'll want to open it in Vim for\nediting as well in the same Vim instance. You can use |UltiSnipsEdit| for this,\nbut you can also just run >\n   :tabedit ~/.vim/UltiSnips/all.snippets\n\nAdd this snippet to 'all.snippets' and save the file.\n\n------------------- SNIP -------------------\n>\n    snippet bye \"My mail signature\"\n    Good bye, Sir. Hope to talk to you soon.\n    - Arthur, King of Britain\n    endsnippet\n<\n------------------- SNAP -------------------\n\nUltiSnips detects when you write changes to a snippets file and automatically\nmakes the changes active. So in the empty buffer, type the tab trigger 'bye'\nand then press the <Tab> key.\n\nbye<Tab> -->\nGood bye, Sir. Hope to talk to you soon.\n- Arthur, King of Britain\n\nThe word 'bye' will be replaced with the text of the snippet definition.\n\n\n4.3 Visual Placeholder                         *UltiSnips-visual-placeholder*\n----------------------\n\nSnippets can contain a special placeholder called ${VISUAL}. The ${VISUAL}\nvariable is expanded with the text selected just prior to expanding the\nsnippet.\n\nTo see how a snippet with a ${VISUAL} placeholder works, define a snippet with\nthe placeholder, use Vim's Visual mode to select some text, and then press the\nkey you use to trigger expanding a snippet (see g:UltiSnipsExpandTrigger). The\nselected text is deleted, and you are dropped into Insert mode. Now type the\nsnippet tab trigger and press the key to trigger expansion. As the snippet\nexpands, the previously selected text is printed in place of the ${VISUAL}\nplaceholder.\n\nThe ${VISUAL} placeholder can contain default text to use when the snippet has\nbeen triggered when not in Visual mode. The syntax is: >\n    ${VISUAL:default text}\n\nThe ${VISUAL} placeholder can also define a transformation (see\n|UltiSnips-transformations|). The syntax is: >\n    ${VISUAL:default/search/replace/option}.\n\nHere is a simple example illustrating a visual transformation. The snippet\nwill take selected text, replace every instance of \"should\" within it with\n\"is\", and wrap the result in tags.\n\n------------------- SNIP -------------------\n>\n    snippet t\n    <tag>${VISUAL:inside text/should/is/g}</tag>\n    endsnippet\n<\n------------------- SNAP -------------------\n\nStart with this line of text: >\n   this should be cool\n\nPosition the cursor on the word \"should\", then press the key sequence: viw\n(visual mode -> select inner word). Then press <Tab>, type \"t\" and press <Tab>\nagain. The result is: >\n   -> this <tag>is</tag> be cool\n\nIf you expand this snippet while not in Visual mode (e.g., in Insert mode type\nt<Tab>), you will get: >\n   <tag>inside text</tag>\n\n\n4.4 Interpolation                                   *UltiSnips-interpolation*\n-----------------\n\n 4.4.1 Shellcode:                                       *UltiSnips-shellcode*\n\nSnippets can include shellcode. Put a shell command in a snippet and when the\nsnippet is expanded, the shell command is replaced by the output produced when\nthe command is executed. The syntax for shellcode is simple: wrap the code in\nbackticks, '`'. When a snippet is expanded, UltiSnips runs shellcode by first\nwriting it to a temporary script and then executing the script. The shellcode\nis replaced by the standard output. Anything you can run as a script can be\nused in shellcode. Include a shebang line, for example, #!/usr/bin/perl, and\nyour snippet has the ability to run scripts using other programs, perl, for\nexample.\n\nHere are some examples. This snippet uses a shell command to insert the\ncurrent date.\n\n------------------- SNIP -------------------\n>\n    snippet today\n    Today is the `date +%d.%m.%y`.\n    endsnippet\n<\n------------------- SNAP -------------------\n\ntoday<tab> ->\nToday is the 15.07.09.\n\n\nThis example inserts the current date using perl.\n\n------------------- SNIP -------------------\n>\n    snippet today\n    Today is `#!/usr/bin/perl\n    @a = localtime(); print $a[3] . '.' . $a[4] . '.' . ($a[5]+1900);`.\n    endsnippet\n<\n------------------- SNAP -------------------\ntoday<tab> ->\nToday is 15.6.2009.\n\n\n 4.4.2 VimScript:                                       *UltiSnips-vimscript*\n\nYou can also use Vim scripts (sometimes called VimL) in interpolation. The\nsyntax is similar to shellcode. Wrap the code in backticks and to distinguish\nit as a Vim script, start the code with '!v'. Here is an example that counts\nthe indent of the current line:\n\n------------------- SNIP -------------------\n>\n    snippet indent\n    Indent is: `!v indent(\".\")`.\n    endsnippet\n<\n------------------- SNAP -------------------\n    (note the 4 spaces in front): indent<tab> ->\n    (note the 4 spaces in front): Indent is: 4.\n\n\n 4.4.3 Python:                                             *UltiSnips-python*\n\nPython interpolation is by far the most powerful. The syntax is similar to Vim\nscripts except code is started with '!p'. Python scripts can be run using the\npython shebang '#!/usr/bin/python', but using the '!p' format comes with some\npredefined objects and variables, which can simplify and shorten code. For\nexample, a 'snip' object instance is implied in python code. Python code using\nthe '!p' indicator differs also in another way. Generally when a snippet is\nexpanded the standard output of code replaces the code. With python code the\nvalue of the 'snip.rv' property replaces the code. Standard output is ignored.\n\nThe variables automatically defined in python code are: >\n\n   fn      - The current filename\n   path    - The complete path to the current file\n   t       - The values of the placeholders, t[1] is the text of ${1}, etc.\n   snip    - UltiSnips.TextObjects.SnippetUtil object instance. Has methods\n             that simplify indentation handling and owns the string that\n             should be inserted for the snippet.\n   context - Result of context condition. See |UltiSnips-custom-context-snippets|.\n   match   - Only in regular expression triggered snippets. This is the return\n             value of the match of the regular expression. See\n             http://docs.python.org/library/re.html#match-objects\n\nThe 'snip' object provides the following methods: >\n\n    snip.mkline(line=\"\", indent=None):\n        Returns a line ready to be appended to the result. If indent\n        is None, then mkline prepends spaces and/or tabs appropriate to the\n        current 'tabstop' and 'expandtab' variables.\n\n    snip.shift(amount=1):\n        Shifts the default indentation level used by mkline right by the\n        number of spaces defined by 'shiftwidth', 'amount' times.\n\n    snip.unshift(amount=1):\n        Shifts the default indentation level used by mkline left by the\n        number of spaces defined by 'shiftwidth', 'amount' times.\n\n    snip.reset_indent():\n        Resets the indentation level to its initial value.\n\n    snip.opt(var, default):\n        Checks if the Vim variable 'var' has been set. If so, it returns the\n        variable's value; otherwise, it returns the value of 'default'.\n\nThe 'snip' object provides some properties as well: >\n\n    snip.rv:\n        'rv' is the return value, the text that will replace the python block\n        in the snippet definition. It is initialized to the empty string. This\n        deprecates the 'res' variable.\n\n    snip.c:\n        The text currently in the python block's position within the snippet.\n        It is set to empty string as soon as interpolation is completed. Thus\n        you can check if snip.c is != \"\" to make sure that the interpolation\n        is only done once. This deprecates the \"cur\" variable.\n\n    snip.v:\n         Data related to the ${VISUAL} placeholder. This has two attributes:\n             snip.v.mode   ('v', 'V', '^V', see |visual-mode| )\n             snip.v.text   The text that was selected.\n\n    snip.fn:\n        The current filename.\n\n    snip.basename:\n        The current filename with the extension removed.\n\n    snip.ft:\n        The current filetype.\n\n    snip.p:\n        Last selected placeholder. Will contain placeholder object with\n        following properties:\n\n        'current_text' - text in the placeholder on the moment of selection;\n        'start' - placeholder start on the moment of selection;\n        'end' - placeholder end on the moment of selection;\n\nFor your convenience, the 'snip' object also provides the following\noperators: >\n\n    snip >> amount:\n        Equivalent to snip.shift(amount)\n    snip << amount:\n        Equivalent to snip.unshift(amount)\n    snip += line:\n        Equivalent to \"snip.rv += '\\n' + snip.mkline(line)\"\n\nAny variables defined in a python block can be used in other python blocks\nthat follow within the same snippet. Also, the python modules 'vim', 're',\n'os', 'string' and 'random' are pre-imported within the scope of snippet code.\nOther modules can be imported using the python 'import' command.\n\nPython code allows for very flexible snippets. For example, the following\nsnippet mirrors the first tabstop value on the same line but right aligned and\nin uppercase.\n\n------------------- SNIP -------------------\n>\n    snippet wow\n    ${1:Text}`!p snip.rv = (75-2*len(t[1]))*' '+t[1].upper()`\n    endsnippet\n<\n------------------- SNAP -------------------\nwow<tab>Hello World ->\nHello World                                                     HELLO WORLD\n\nThe following snippet uses the regular expression option and illustrates\nregular expression grouping using python's match object. It shows that the\nexpansion of a snippet can depend on the tab trigger used to define the\nsnippet, and that tab trigger itself can vary.\n\n------------------- SNIP -------------------\n>\n    snippet \"be(gin)?( (\\S+))?\" \"begin{} / end{}\" br\n    \\begin{${1:`!p\n    snip.rv = match.group(3) if match.group(2) is not None else \"something\"`}}\n        ${2:${VISUAL}}\n    \\end{$1}$0\n    endsnippet\n<\n------------------- SNAP -------------------\nbe<tab>center<c-j> ->\n\\begin{center}\n\n\\end{center}\n------------------- SNAP -------------------\nbe center<tab> ->\n\\begin{center}\n\n\\end{center}\n\nThe second form is a variation of the first; both produce the same result,\nbut it illustrates how regular expression grouping works. Using regular\nexpressions in this manner has some drawbacks:\n1. If you use the <Tab> key for both expanding snippets and completion then\n   if you typed \"be form<Tab>\" expecting the completion \"be formatted\", you\n   would end up with the above SNAP instead, not what you want.\n2. The snippet is harder to read.\n\nThe biggest advantage, however, is that you can create snippets that take into\naccount the text preceding a \"trigger\". This way, you can use it to create\npostfix snippets, which are popular in some IDEs.\n\n------------------- SNIP -------------------\n>\n    snippet \"(\\w+).par\" \"Parenthesis (postfix)\" r\n    (`!p snip.rv = match.group(1)`$1)$0\n    endsnippet\n<\n------------------- SNAP -------------------\nsomething.par<tab> ->\n(something)\n\n------------------- SNIP -------------------\n>\n    snippet \"([^\\s].*)\\.return\" \"Return (postfix)\" r\n    return `!p snip.rv = match.group(1)`$0\n    endsnippet\n<\n------------------- SNAP -------------------\nvalue.return<tab> ->\nreturn value\n\n\n 4.4.4 Global Snippets:                                   *UltiSnips-globals*\n\nGlobal snippets provide a way to reuse common code in multiple snippets.\nCurrently, only python code is supported. The result of executing the contents\nof a global snippet is put into the globals of each python block in the\nsnippet file. To create a global snippet, use the keyword 'global' in place of\n'snippet', and for python code, you use '!p' for the trigger. For example, the\nfollowing snippet produces the same output as the last example . However, with\nthis syntax the 'upper_right' snippet can be reused by other snippets.\n\n------------------- SNIP -------------------\n>\n    global !p\n    def upper_right(inp):\n        return (75 - 2 * len(inp))*' ' + inp.upper()\n    endglobal\n\n    snippet wow\n    ${1:Text}`!p snip.rv = upper_right(t[1])`\n    endsnippet\n<\n------------------- SNAP -------------------\nwow<tab>Hello World ->\nHello World                                                     HELLO WORLD\n\nPython global functions can be stored in a python module and then imported.\nThis makes global functions easily accessible to all snippet files. You can\njust drop python files into ~/.vim/pythonx and import them directly inside\nyour snippets. For example to use\n~/.vim/pythonx/my_snippets_helpers.py  >\n\n   global !p\n   from my_snippet_helpers import *\n   endglobal\n\n\n4.5 Tabstops and Placeholders   *UltiSnips-tabstops* *UltiSnips-placeholders*\n-----------------------------\n\nSnippets are used to quickly insert reused text into a document. Often the\ntext has a fixed structure with variable components. Tabstops are used to\nsimplify modifying the variable content. With tabstops you can easily place\nthe cursor at the point of the variable content, enter the content you want,\nthen jump to the next variable component, enter that content, and continue\nuntil all the variable components are complete.\n\nThe syntax for a tabstop is the dollar sign followed by a number, for example,\n'$1'. Tabstops start at number 1 and are followed in sequential order. The\n'$0' tabstop is a special tabstop. It is always the last tabstop in the\nsnippet no matter how many tabstops are defined. If there is no '$0' defined,\n'$0' tabstop will be defined at the end of the snippet.\n\nHere is a simple example.\n\n------------------- SNIP -------------------\n>\n    snippet letter\n    Dear $1,\n    $0\n    Yours sincerely,\n    $2\n    endsnippet\n<\n------------------- SNAP -------------------\nletter<tab>Ben<c-j>Paul<c-j>Thanks for suggesting UltiSnips!->\nDear Ben,\nThanks for suggesting UltiSnips!\nYours sincerely,\nPaul\n\nYou can use <c-j> to jump to the next tabstop, and <c-k> to jump to the\nprevious. The <Tab> key was not used for jumping forward because it is\ncommonly used for completion. See |UltiSnips-triggers| for help on defining\ndifferent keys for motions.\n\nIt is often useful to have some default text for a tabstop. The default text\nmay be a value commonly used for the variable component, or it may be a word\nor phrase that reminds you what is expected for the variable component. To\ninclude default text, the syntax is '${1:value}'.\n\nThe following example illustrates a snippet for the shell 'case' statement.\nThe tabstops use default values to remind the user of what value is expected.\n\n------------------- SNIP -------------------\n>\n    snippet case\n    case ${1:word} in\n        ${2:pattern} ) $0;;\n    esac\n    endsnippet\n<\n------------------- SNAP -------------------\n\ncase<tab>$option<c-j>-v<c-j>verbose=true\ncase $option in\n    -v ) verbose=true;;\nesac\n\n\nSometimes it is useful to have a tabstop within a tabstop. To do this, simply\ninclude the nested tabstop as part of the default text. Consider the following\nexample illustrating an HTML anchor snippet.\n\n------------------- SNIP -------------------\n>\n    snippet a\n    <a href=\"${1:http://www.${2:example.com}}\"\n        $0\n    </a>\n    endsnippet\n<\n------------------- SNAP -------------------\n\nWhen this snippet is expanded, the first tabstop has a default value of\n'http://www.example.com'. If you want the 'http://' schema, jump to the next\ntabstop. It has a default value of 'example.com'. This can be replaced by\ntyping whatever domain you want.\n\na<tab><c-j>google.com<c-j>Google ->\n<a href=\"http://www.google.com\">\n    Google\n</a>\n\nIf at the first tabstop you want a different url schema or want to replace the\ndefault url with a named anchor, '#name', for example, just type the value you\nwant.\n\na<tab>#top<c-j>Top ->\n<a href=\"#top\">\n    Top\n</a>\n\nIn the last example, typing any text at the first tabstop replaces the default\nvalue, including the second tabstop, with the typed text. So the second\ntabstop is essentially deleted. When a tabstop jump is triggered, UltiSnips\nmoves to the next remaining tabstop '$0'. This feature can be used\nintentionally as a handy way for providing optional tabstop values to the\nuser. Here is an example to illustrate.\n\n------------------- SNIP -------------------\n>\n    snippet a\n    <a href=\"$1\"${2: class=\"${3:link}\"}>\n        $0\n    </a>\n    endsnippet\n<\n------------------- SNAP -------------------\n\nHere, '$1' marks the first tabstop. It is assumed you always want to add a\nvalue for the 'href' attribute. After entering the url and pressing <c-j>, the\nsnippet will jump to the second tabstop, '$2'. This tabstop is optional. The\ndefault text is ' class=\"link\"'. You can press <c-j> to accept the tabstop,\nand the snippet will jump to the third tabstop, '$3', and you can enter the\nclass attribute value, or, at the second tabstop you can press the backspace\nkey thereby replacing the second tabstop default with an empty string,\nessentially removing it. In either case, continue by pressing <c-j> and the\nsnippet will jump to the final tabstop inside the anchor.\n\na<tab>http://www.google.com<c-j><c-j>visited<c-j>Google ->\n<a href=\"http://www.google.com\" class=\"visited\">\n    Google\n</a>\n\na<tab>http://www.google.com<c-j><BS><c-j>Google ->\n<a href=\"http://www.google.com\">\n    Google\n</a>\n\nAnother special type of tabstop is choice tabstop. It let's you to choose\nfrom a predefined list of items. The syntax of a choice tabstop is >\n    ${1|item1,item2,item3,...|}\nHere is an example to illustrate this feature.\n\n------------------- SNIP -------------------\n>\n    snippet q\n    Your age: ${1|<18,18~60,>60|}\n    Your height: ${2|<120cm,120cm~180cm,>180cm|}\n    endsnippet\n<\n------------------- SNAP -------------------\n\nq<tab>2<c-j>2\nYour age: 18~60\nYour height: 120cm~180cm\n\nThe default text of tabstops can also contain mirrors, transformations or\ninterpolation.\n\n\n4.6 Mirrors                                               *UltiSnips-mirrors*\n-----------\n\nMirrors repeat the content of a tabstop. During snippet expansion when you\nenter the value for a tabstop, all mirrors of that tabstop are replaced with\nthe same value. To mirror a tabstop simply insert the tabstop again using the\n\"dollar sign followed by a number\" syntax, e.g., '$1'.\n\nA tabstop can be mirrored multiple times in one snippet, and more than one\ntabstop can be mirrored in the same snippet. A mirrored tabstop can have a\ndefault value defined. Only the first instance of the tabstop need have a\ndefault value. Mirrored tabstop will take on the default value automatically.\n\nMirrors are handy for start-end tags, for example, TeX 'begin' and 'end' tag\nlabels, XML and HTML tags, and C code #ifndef blocks. Here are some snippet\nexamples.\n\n------------------- SNIP -------------------\n>\n    snippet env\n    \\begin{${1:enumerate}}\n        $0\n    \\end{$1}\n    endsnippet\n<\n------------------- SNAP -------------------\nenv<tab>itemize ->\n\\begin{itemize}\n\n\\end{itemize}\n\n------------------- SNIP -------------------\n>\n    snippet ifndef\n    #ifndef ${1:SOME_DEFINE}\n    #define $1\n    $0\n    #endif /* $1 */\n    endsnippet\n<\n------------------- SNAP -------------------\nifndef<tab>WIN32 ->\n#ifndef WIN32\n#define WIN32\n\n#endif /* WIN32 */\n\n\n4.7 Transformations                               *UltiSnips-transformations*\n-------------------\n\nNote: Transformations are a bit difficult to grasp so this chapter is divided\ninto two sections. The first describes transformations and their syntax, and\nthe second illustrates transformations with demos.\n\nTransformations are like mirrors but instead of just copying text from the\noriginal tabstop verbatim, a regular expression is matched to the content of\nthe referenced tabstop and a transformation is then applied to the matched\npattern. The syntax and functionality of transformations in UltiSnips follow\nvery closely to TextMate transformations.\n\nA transformation has the following syntax: >\n   ${<tab_stop_no/regular_expression/replacement/options}\n\nThe components are defined as follows: >\n   tab_stop_no        - The number of the tabstop to reference\n   regular_expression - The regular expression the value of the referenced\n                        tabstop is matched on\n   replacement        - The replacement string, explained in detail below\n   options            - Options for the regular expression\n\nThe options can be any combination of >\n   g    - global replace\n          By default, only the first match of the regular expression is\n          replaced. With this option all matches are replaced.\n   i    - case insensitive\n          By default, regular expression matching is case sensitive. With this\n          option, matching is done without regard to case.\n   m    - multiline\n          By default, the '^' and '$' special characters only apply to the\n          start and end of the entire string; so if you select multiple lines,\n          transformations are made on them entirely as a whole single line\n          string. With this option, '^' and '$' special characters match the\n          start or end of any line within a string ( separated by newline\n          character - '\\n' ).\n   a    - ascii conversion\n          By default, transformation are made on the raw utf-8 string. With\n          this option, matching is done on the corresponding ASCII string\n          instead, for example 'à' will become 'a'.\n          This option required the python package 'unidecode'.\n\nThe syntax of regular expressions is beyond the scope of this document. Python\nregular expressions are used internally, so the python 're' module can be used\nas a guide. See http://docs.python.org/library/re.html.\n\nThe syntax for the replacement string is unique. The next paragraph describes\nit in detail.\n\n\n 4.7.1 Replacement String:                     *UltiSnips-replacement-string*\n\nThe replacement string can contain $no variables, e.g., $1, which reference\nmatched groups in the regular expression. The $0 variable is special and\nyields the whole match. The replacement string can also contain special escape\nsequences: >\n   \\u   - Uppercase next letter\n   \\l   - Lowercase next letter\n   \\U   - Uppercase everything till the next \\E\n   \\L   - Lowercase everything till the next \\E\n   \\E   - End upper or lowercase started with \\L or \\U\n   \\n   - A newline\n   \\t   - A literal tab\n\nFinally, the replacement string can contain conditional replacements using the\nsyntax (?no:text:other text). This reads as follows: if the group $no has\nmatched, insert \"text\", otherwise insert \"other text\". \"other text\" is\noptional and if not provided defaults to the empty string, \"\". This feature\nis very powerful. It allows you to add optional text into snippets.\n\n\n 4.7.2 Demos:                                               *UltiSnips-demos*\n\nTransformations are very powerful but often the syntax is convoluted.\nHopefully the demos below help illustrate transformation features.\n\nDemo: Uppercase one character\n------------------- SNIP -------------------\n>\n    snippet title \"Title transformation\"\n    ${1:a text}\n    ${1/\\w+\\s*/\\u$0/}\n    endsnippet\n<\n------------------- SNAP -------------------\ntitle<tab>big small ->\nbig small\nBig small\n\n\nDemo: Uppercase one character and global replace\n------------------- SNIP -------------------\n>\n    snippet title \"Titlelize in the Transformation\"\n    ${1:a text}\n    ${1/\\w+\\s*/\\u$0/g}\n    endsnippet\n<\n------------------- SNAP -------------------\ntitle<tab>this is a title ->\nthis is a title\nThis Is A Title\n\n\nDemo: ASCII transformation\n------------------- SNIP -------------------\n>\n    snippet ascii \"Replace non ascii chars\"\n    ${1: an accentued text}\n    ${1/.*/$0/a}\n    endsnippet\n<\n------------------- SNAP -------------------\nascii<tab>à la pêche aux moules\nà la pêche aux moules\na la peche aux moules\n\n\nDemo: Regular expression grouping\n      This is a clever c-like printf snippet, the second tabstop is only shown\n      when there is a format (%) character in the first tabstop.\n\n------------------- SNIP -------------------\n>\n    snippet printf\n    printf(\"${1:%s}\\n\"${1/([^%]|%%)*(%.)?.*/(?2:, :\\);)/}$2${1/([^%]|%%)*(%.)?.*/(?2:\\);)/}\n    endsnippet\n<\n------------------- SNAP -------------------\nprintf<tab>Hello<c-j> // End of line ->\nprintf(\"Hello\\n\"); // End of line\n\nBut\nprintf<tab>A is: %s<c-j>A<c-j> // End of line ->\nprintf(\"A is: %s\\n\", A); // End of line\n\n\nThere are many more examples of what can be done with transformations in the\nvim-snippets repo.\n\n\n4.8 Clearing snippets                           *UltiSnips-clearing-snippets*\n\nTo remove snippets for the current file type, use the 'clearsnippets'\ndirective.\n\n------------------- SNIP -------------------\n>\n    clearsnippets\n<\n------------------- SNAP -------------------\n\n'clearsnippets' removes all snippets with a priority lower than the current\none. For example, the following cleares all snippets that have priority <= 1,\neven though the example snippet is defined after the 'clearsnippets'.\n\n------------------- SNIP -------------------\n>\n    priority 1\n    clearsnippets\n\n    priority -1\n    snippet example \"Cleared example\"\n        This will never be expanded.\n    endsnippet\n<\n------------------- SNAP -------------------\n\nTo clear one or more specific snippet, provide the triggers of the snippets as\narguments to the 'clearsnippets' command. The following example will clear the\nsnippets 'trigger1' and 'trigger2'.\n\n------------------- SNIP -------------------\n>\n    clearsnippets trigger1 trigger2\n<\n------------------- SNAP -------------------\n\n\n4.9 Custom context snippets                      *UltiSnips-custom-context-snippets*\n\nCustom context snippets can be enabled by using the 'e' option in the snippet\ndefinition.\n\nIn that case snippet should be defined using this syntax: >\n\n    snippet trigger_word \"description\" \"expression\" options\n\nThe context can also be defined using a special header: >\n\n    context \"python_expression\"\n    snippet trigger_word \"description\" options\n\nThe 'expression' can be any python expression. If 'expression' evaluates to\n'True', then this snippet will be eligible for expansion. The 'expression'\nmust be wrapped with double-quotes.\n\nThe following python modules are automatically imported into the scope before\n'expression' is evaluated: 're', 'os', 'vim', 'string', 'random'.\n\nGlobal variable `snip` will be available with following properties:\n    'snip.window' - alias for 'vim.current.window'\n    'snip.buffer' - alias for 'vim.current.window.buffer'\n    'snip.cursor' - cursor object, which behaves like\n        'vim.current.window.cursor', but zero-indexed and with following\n        additional methods:\n        - 'preserve()' - special method for executing pre/post/jump actions;\n        - 'set(line, column)' - sets cursor to specified line and column;\n        - 'to_vim_cursor()' - returns 1-indexed cursor, suitable for assigning\n          to 'vim.current.window.cursor';\n    'snip.line' and 'snip.column' - aliases for cursor position (zero-indexed);\n    'snip.visual_mode' - ('v', 'V', '^V', see |visual-mode|);\n    'snip.visual_text' - last visually-selected text;\n    'snip.last_placeholder' - last active placeholder from previous snippet\n        with following properties:\n\n        - 'current_text' - text in the placeholder on the moment of selection;\n        - 'start' - placeholder start on the moment of selection;\n        - 'end' - placeholder end on the moment of selection;\n    'snip.before' - contains the text in the current line up to and including\n        the matched snippet. Since 'snip.column' counts bytes, not characters,\n        this is **not** equivalent to 'snip.buffer[snip.line][:snip.column+1]'.\n        This property is only available in the scope of contexts but not in\n        that of actions.\n\n\nFor regular expression triggered snippets the variable `match` will contain\nthe return value of the match of the regular expression. See http://docs.python.org/library/re.html#match-objects.\n\n------------------- SNIP -------------------\n>\n    snippet r \"return\" \"re.match('^\\s+if err ', snip.buffer[snip.line-1])\" be\n    return err\n    endsnippet\n<\n------------------- SNAP -------------------\n\nThat snippet will expand to 'return err' only if the previous line is starting\nfrom 'if err' prefix.\n\nNote: custom context snippets are prioritized over other snippets. It makes possible\nto use other snippets as a fallback if no context can be matched:\n\n------------------- SNIP -------------------\n>\n    snippet i \"if ...\" b\n    if $1 {\n        $2\n    }\n    endsnippet\n\n    snippet i \"if err != nil\" \"re.match('^\\s+[^=]*err\\s*:?=', snip.buffer[snip.line-1])\" be\n    if err != nil {\n        $1\n    }\n    endsnippet\n<\n------------------- SNAP -------------------\n\nThat snippet will expand into 'if err != nil' if the previous line will match\n'err :=' prefix, otherwise the default 'if' snippet will be expanded.\n\nIt's a good idea to move context conditions to a separate module, so it can be\nused by other UltiSnips users. In that case, module should be imported\nusing 'global' keyword, like this:\n\n------------------- SNIP -------------------\n>\n    global !p\n    import my_utils\n    endglobal\n\n    snippet , \"return ..., nil/err\" \"my_utils.is_return_argument(snip)\" ie\n    , `!p if my_utils.is_in_err_condition():\n        snip.rv = \"err\"\n    else:\n        snip.rv = \"nil\"`\n    endsnippet\n<\n------------------- SNAP -------------------\n\nThat snippet will expand only if the cursor is located in the return statement,\nand then it will expand either to 'err' or to 'nil' depending on which 'if'\nstatement it's located. 'is_return_argument' and 'is_in_err_condition' are\npart of custom python module which is called 'my_utils' in this example.\n\nContext condition can return any value which python can use as condition in\nit's 'if' statement, and if it's considered 'True', then snippet will be\nexpanded. The evaluated value of 'condition' is available in the 'snip.context'\nvariable inside the snippet:\n\n------------------- SNIP -------------------\n>\n    snippet + \"var +=\" \"re.match('\\s*(.*?)\\s*:?=', snip.buffer[snip.line-1])\" ie\n    `!p snip.rv = snip.context.group(1)` += $1\n    endsnippet\n<\n------------------- SNAP -------------------\n\nThat snippet will expand to 'var1 +=' after line, which begins from 'var1 :='.\n\n                                                  *UltiSnips-capture-placeholder*\n\nYou can capture placeholder text from the previous snippet by using the\nfollowing trick:\n------------------- SNIP -------------------\n>\n    snippet = \"desc\" \"snip.last_placeholder\" Ae\n    `!p snip.rv = snip.context.current_text` == nil\n    endsnippet\n<\n------------------- SNAP -------------------\n\nThat snippet will be expanded only if you will replace selected tabstop in\nother snippet (like, as in 'if ${1:var}') and will replace that tabstop by\ntabstop value following by ' == nil'.\n\n\n4.10 Snippets actions                             *UltiSnips-snippet-actions*\n---------------------\n\nA snippet action is an arbitrary python code which can be executed at specific\npoints in the lifetime of a snippet expansion.\n\nThere are three types of actions:\n\n* Pre-expand - invoked just after trigger condition was matched, but before\n  snippet actually expanded;\n* Post-expand - invoked after snippet was expanded and interpolations\n  were applied for the first time, but before jump on the first placeholder.\n* Jump - invoked just after a jump to the next/prev placeholder.\n\nSpecified code will be evaluated at stages defined above and same global\nvariables and modules will be available that are stated in\nthe |UltiSnips-custom-context-snippets| section (except 'snip.before').\n\n                                                *UltiSnips-buffer-proxy*\n\nNote: special variable called 'snip.buffer' should be used for all buffer\nmodifications. Not 'vim.current.buffer' and not 'vim.command(\"...\")', because\nin that case UltiSnips will not be able to track changes to the buffer\ncorrectly.\n\n'snip.buffer' has the same interface as 'vim.current.window.buffer'.\n\n4.10.1 Pre-expand actions                       *UltiSnips-pre-expand-actions*\n\nPre-expand actions can be used to match snippet in one location and then\nexpand it in the different location. Some useful cases are: correcting\nindentation for snippet; expanding snippet for function declaration in another\nfunction body with moving expansion point beyond initial function; performing\nextract method refactoring via expanding snippet in different place.\n\nPre-expand action declared as follows: >\n    pre_expand \"python code here\"\n    snippet ...\n    endsnippet\n\nBuffer can be modified in pre-expand action code through variable called\n'snip.buffer', snippet expansion position will be automatically adjusted.\n\nIf cursor line (where trigger was matched) need to be modified, then special\nvariable method 'snip.cursor.set(line, column)' must be called with the\ndesired cursor position. In that case UltiSnips will not remove any matched\ntrigger text and it should be done manually in action code.\n\nTo addition to the scope variables defined above 'snip.visual_content' will be\nalso declared and will contain text that was selected before snippet expansion\n(similar to $VISUAL placeholder).\n\nFollowing snippet will be expanded at 4 spaces indentation level no matter\nwhere it was triggered.\n\n------------------- SNIP -------------------\n>\n    pre_expand \"snip.buffer[snip.line] = ' '*4; snip.cursor.set(snip.line, 4)\"\n    snippet d\n    def $1():\n        $0\n    endsnippet\n<\n------------------- SNAP -------------------\n\nFollowing snippet will move the selected code to the end of file and create\nnew method definition for it:\n\n------------------- SNIP -------------------\n>\n    pre_expand \"del snip.buffer[snip.line]; snip.buffer.append(''); snip.cursor.set(len(snip.buffer)-1, 0)\"\n    snippet x\n    def $1():\n        ${2:${VISUAL}}\n    endsnippet\n<\n------------------- SNAP -------------------\n\n4.10.2 Post-expand actions                     *UltiSnips-post-expand-actions*\n\nPost-expand actions can be used to perform some actions based on the expanded\nsnippet text. Some cases are: code style formatting (e.g. inserting newlines\nbefore and after method declaration), and apply actions depending on python\ninterpolation result.\n\nPost-expand action declared as follows: >\n    post_expand \"python code here\"\n    snippet ...\n    endsnippet\n\nBuffer can be modified in post-expand action code through variable called\n'snip.buffer', snippet expansion position will be automatically adjusted.\n\nVariables 'snip.snippet_start' and 'snip.snippet_end' will be defined at the\naction code scope and will point to positions of the start and end of expanded\nsnippet accordingly in the form '(line, column)'.\n\nNote: 'snip.snippet_start' and 'snip.snippet_end' will automatically adjust to\nthe correct positions if post-action will insert or delete lines before\nexpansion.\n\nFollowing snippet will expand to method definition and automatically insert\nadditional newline after end of the snippet. It's very useful to create a\nfunction that will insert as many newlines as required in specific context.\n\n------------------- SNIP -------------------\n>\n    post_expand \"snip.buffer[snip.snippet_end[0]+1:snip.snippet_end[0]+1] = ['']\"\n    snippet d \"Description\" b\n    def $1():\n        $2\n    endsnippet\n<\n------------------- SNAP -------------------\n\n4.10.3 Post-jump actions                         *UltiSnips-post-jump-actions*\n\nPost-jump actions can be used to trigger some code based on user input into\nthe placeholders. Notable use cases: expand another snippet after jump or\nanonymous snippet after last jump (e.g. perform move method refactoring and\nthen insert new method invokation); insert heading into TOC after last jump.\n\nJump-expand action declared as follows: >\n    post_jump \"python code here\"\n    snippet ...\n    endsnippet\n\nBuffer can be modified in post-jump action code through variable called\n'snip.buffer', snippet expansion position will be automatically adjusted.\n\nNext variables and methods will be also defined in the action code scope:\n* 'snip.tabstop' - number of tabstop jumped onto;\n* 'snip.jump_direction' - '1' if jumped forward and '-1' otherwise;\n* 'snip.tabstops' - list with tabstop objects, see above;\n* 'snip.snippet_start' - (line, column) of start of the expanded snippet;\n* 'snip.snippet_end' - (line, column) of end of the expanded snippet;\n* 'snip.expand_anon()' - alias for 'UltiSnips_Manager.expand_anon()';\n\nTabstop object has several useful properties:\n* 'start' - (line, column) of the starting position of the tabstop (also\n  accessible as 'tabstop.line' and 'tabstop.col').\n* 'end' - (line, column) of the ending position;\n* 'current_text' - text inside the tabstop.\n\nFollowing snippet will insert section in the Table of Contents in the vim-help\nfile:\n\n------------------- SNIP -------------------\n>\n    post_jump \"if snip.tabstop == 0: insert_toc_item(snip.tabstops[1], snip.buffer)\"\n    snippet s \"section\" b\n    `!p insert_delimiter_0(snip, t)`$1`!p insert_section_title(snip, t)`\n    `!p insert_delimiter_1(snip, t)`\n    $0\n    endsnippet\n<\n------------------- SNAP -------------------\n\n'insert_toc_item' will be called after first jump and will add newly entered\nsection into the TOC for current file.\n\nNote: It is also possible to trigger snippet expansion from the jump action.\nIn that case method 'snip.cursor.preserve()' should be called, so UltiSnips\nwill know that cursor is already at the required position.\n\nFollowing example will insert method call at the end of file after user jump\nout of method declaration snippet.\n\n------------------- SNIP -------------------\n>\n    global !p\n    def insert_method_call(name):\n        vim.command('normal G')\n        snip.expand_anon(name + '($1)\\n')\n    endglobal\n\n    post_jump \"if snip.tabstop == 0: insert_method_call(snip.tabstops[1].current_text)\"\n    snippet d \"method declaration\" b\n    def $1():\n        $2\n    endsnippet\n<\n------------------- SNAP -------------------\n\n4.11 Autotrigger                                       *UltiSnips-autotrigger*\n----------------\n\nMany language constructs can occur only at specific places, so it's\npossible to use snippets without manually triggering them.\n\nSnippet can be marked as autotriggered by specifying 'A' option in the snippet\ndefinition.\n\nAfter snippet is defined as being autotriggered, snippet condition will be\nchecked on every typed character and if condition matches, then the snippet\nwill be triggered.\n\n*Warning:* using of this feature might lead to significant vim slowdown. If\nyou discovered that, please report an issue.\n\nIf you want to temporarily disable autotriggering, the `autotrigger` behavior\ncan be toggled via |UltiSnips#ToggleAutoTrigger|. By default it is enabled,\nbut it is possible to customize it with |g:UltiSnipsAutoTrigger|.\n\nConsider following useful Go snippets:\n------------------- SNIP -------------------\n>\n    snippet \"^p\" \"package\" rbA\n    package ${1:main}\n    endsnippet\n\n    snippet \"^m\" \"func main\" rbA\n    func main() {\n        $1\n    }\n    endsnippet\n<\n------------------- SNAP -------------------\n\nWhen \"p\" character will occur in the beginning of the line, it will be\nautomatically expanded into \"package main\". Same with \"m\" character. There is\nno need to press the trigger key after \"m\"\n\n==============================================================================\n5. UltiSnips and Other Plugins                      *UltiSnips-other-plugins*\n\n5.1 Existing Integrations                            *UltiSnips-integrations*\n-------------------------\n\nUltiSnips has built-in support for some common plugins and there are others\nthat are aware of UltiSnips and use it to improve the user experience. This is\nan incomplete list - if you want to have your plugin listed here, just send a\npull request.\n\n                                                    *UltiSnips-snipMate*\n\nsnipMate - UltiSnips is a drop-in replacement for snipMate. It has many more\nfeatures, so porting snippets is still a good idea, but switching has low\nfriction. UltiSnips is trying hard to truly emulate snipMate, for example\nrecursive tabstops are not supported in snipMate snippets (but of course in\nUltiSnips snippets).\n\nYouCompleteMe - comes with out of the box completion support for UltiSnips. It\noffers a really nice completion dialogue for snippets.\n\nneocomplete - UltiSnips ships with a source for neocomplete and therefore\noffers out of the box completion dialogue support for it too.\n\ndeoplete - The successor of neocomplete is also supported. The completion \nsource is called 'ultisnips'.\n\nvim-easycomplete - Vim-EasyComplete needs ultisnips and vim-snippets for \nsnippets support. This two plugin is compatible with EasyComplete out of\nthe box. More information: <https://github.com/jayli/vim-easycomplete>\n\nunite - UltiSnips has a source for unite. As an example of how you can use\nit add the following function and mappings to your vimrc: >\n\n  function! UltiSnipsCallUnite()\n    Unite -start-insert -winheight=100 -immediately -no-empty ultisnips\n    return ''\n  endfunction\n\n  inoremap <silent> <F12> <C-R>=(pumvisible()? \"\\<LT>C-E>\":\"\")<CR><C-R>=UltiSnipsCallUnite()<CR>\n  nnoremap <silent> <F12> a<C-R>=(pumvisible()? \"\\<LT>C-E>\":\"\")<CR><C-R>=UltiSnipsCallUnite()<CR>\n\nWhen typing <F12> in either insert or normal mode you will get the unite\ninterface with matching snippets. Pressing enter will expand the corresponding\nsnippet. If only one snippet matches the text in front of the cursor will be\nexpanded when you press the <F12> key.\n\nSupertab - UltiSnips has built-in support for Supertab. Just use a recent\nenough version of both plugins and <tab> will either expand a snippet or defer\nto Supertab for expansion.\n\n5.2 Extending UltiSnips                               *UltiSnips-extending*\n-------------------------\n\nUltiSnips allows other plugins to add new snippets on the fly. Since UltiSnips\nis written in python, the integration is also on a python basis. A small\nexample can be found in `test/test_UltiSnipsFunc.py`, search for\nAddNewSnippetSource. Please contact us on github if you integrate UltiSnips\nwith your plugin so it can be listed in the docs.\n\n=============================================================================\n6. Debugging                                            *UltiSnips-Debugging*\n\nUltiSnips comes with a remote debugger disabled\nby default. When authoring a complex snippet\nwith python code, you may want to be able to\nset breakpoints to inspect variables.\nIt is also useful when debugging UltiSnips itself.\n\nSee |UltiSnips-Advanced-Debugging| for more informations\n\n=============================================================================\n7. FAQ                                                        *UltiSnips-FAQ*\n\nQ: Do I have to call UltiSnips#ExpandSnippet() to check if a snippet is\n   expandable? Is there instead an analog of neosnippet#expandable?\nA: Yes there is, try\n\n  function UltiSnips#IsExpandable()\n    return !empty(UltiSnips#SnippetsInCurrentScope())\n  endfunction\n\n  Consider that UltiSnips#SnippetsInCurrentScope() will return all the\n  snippets you have if you call it after a space character. If you want\n  UltiSnips#IsExpandable() to return false when you call it after a space\n  character use this a bit more complicated implementation:\n\n  function UltiSnips#IsExpandable()\n    return !(\n      \\ col('.') <= 1\n      \\ || !empty(matchstr(getline('.'), '\\%' . (col('.') - 1) . 'c\\s'))\n      \\ || empty(UltiSnips#SnippetsInCurrentScope())\n      \\ )\n  endfunction\n\n=============================================================================\n8. Helping Out                                            *UltiSnips-helping*\n\nUltiSnips needs the help of the Vim community to keep improving. Please\nconsider joining this effort by providing new features or bug reports.\n\n* Clone the repository on GitHub (git clone git@github.com:SirVer/ultisnips.git),\n  make your changes and send a pull request on GitHub.\n* Make a patch, report a bug/feature request (see below) and attach the patch\n  to it.\n\nYou can contribute by fixing or reporting bugs in our issue tracker:\nhttps://github.com/sirver/ultisnips/issues\n\n=============================================================================\n9. Contributors                                      *UltiSnips-contributors*\n\nUltiSnips has been started and maintained from Jun 2009 - Dec 2015 by Holger\nRapp (@SirVer, SirVer@gmx.de). Up to April 2018 it was maintained by Stanislav\nSeletskiy (@seletskiy). Now, it is maintained by a growing set of\ncontributors.\n\nThis is the list of contributors pre-git in chronological order. For a full\nlist of contributors take the union of this set and the authors according to\ngit log.\n\n   JCEB - Jan Christoph Ebersbach\n   Michael Henry\n   Chris Chambers\n   Ryan Wooden\n   rupa - Rupa Deadwyler\n   Timo Schmiade\n   blueyed - Daniel Hahler\n   expelledboy - Anthony Jackson\n   allait - Alexey Bezhan\n   peacech - Charles Gunawan\n   guns - Sung Pae\n   shlomif - Shlomi Fish\n   pberndt - Phillip Berndt\n   thanatermesis-elive - Thanatermesis\n   rico-ambiescent - Rico Sta. Cruz\n   Cody Frazer\n   suy - Alejandro Exojo\n   grota - Giuseppe Rota\n   iiijjjii - Jim Karsten\n   fgalassi - Federico Galassi\n   lucapette\n   Psycojoker - Laurent Peuch\n   aschrab - Aaron Schrab\n   stardiviner - NagatoPain\n   skeept - Jorge Rodrigues\n   buztard\n   stephenmckinney - Steve McKinney\n   Pedro Algarvio - s0undt3ch\n   Eric Van Dewoestine - ervandew\n   Matt Patterson - fidothe\n   Mike Morearty - mmorearty\n   Stanislav Golovanov - JazzCore\n   David Briscoe - DavidBriscoe\n   Keith Welch - paralogiki\n   Zhao Cai - zhaocai\n   John Szakmeister - jszakmeister\n   Jonas Diemer - diemer\n   Romain Giot - rgiot\n   Sergey Alexandrov - taketwo\n   Brian Mock - saikobee\n   Gernot Höflechner - LFDM\n   Marcelo D Montu - mMontu\n   Karl Yngve Lervåg - lervag\n   Pedro Ferrari - petobens\n   Ches Martin - ches\n   Christian - Oberon00\n   Andrew Ruder - aeruder\n   Mathias Fußenegger - mfussenegger\n   Kevin Ballard - kballard\n   Ahbong Chang - cwahbong\n   Glenn Griffin - ggriffiniii\n   Michael - Pyrohh\n   Stanislav Seletskiy - seletskiy\n   Pawel Palucki - ppalucki\n   Dettorer - dettorer\n   Zhao Jiarong - kawing-chiu\n   Ye Ding - dyng\n   Greg Hurrell - wincent\n\nvim:tw=78:ts=8:ft=help:norl:\n"
  },
  {
    "path": "doc/examples/autojump-if-empty/README.md",
    "content": "# Autojump from tabstop when it's empty\n\nUltiSnips offers enough API to support automatic jump from one tabstop to\nanother, when some condition is met.\n\nOne example of applying this behaviour is to jump to the next placeholder when the\ncurrent one becomes empty, when the user types <kbd>BackSpace</kbd> or another erase sequence while the\ntabstop is active.\n\nLet's imagine, that we have the following snippet:\n\n![snippet](https://raw.githubusercontent.com/SirVer/ultisnips/master/doc/examples/autojump-if-empty/snippet.gif)\n\nThe first placeholder, surrounded by parentheses, can be erased by the user, but then the \nsurrounding parentheses will be left untouched and the user has to remove the parentheses and\none space and only then jump to the next placeholder. That equates to **5** total\nkeypresses: <kbd>BackSpace</kbd> (erase placeholder), <kbd>BackSpace</kbd> and\n<kbd>Delete</kbd> (erase parentheses), <kbd>Delete</kbd> (erase space),\n<kbd>Tab</kbd> (jump to next placeholder).\n\nHowever, with UltiSnips, it can be done via only one keypress:\n<kbd>BackSpace</kbd>:\n\n![demo](https://raw.githubusercontent.com/SirVer/ultisnips/master/doc/examples/autojump-if-empty/demo.gif)\n\n## Implementation\n\nThis example uses the [vim-pythonx library](https://github.com/reconquest/vim-pythonx/blob/master/pythonx/px/snippets.py), which provides a set of functions to make coding a little bit easier.\n\n```\nglobal !p\nimport px.snippets\nendglobal\n\nglobal !p\n# This function will jump to next placeholder when first is empty.\ndef jump_to_second_when_first_is_empty(snip):\n    if px.snippets.get_jumper_position(snip) == 1:\n        if not px.snippets.get_jumper_text(snip):\n            px.snippets.advance_jumper(snip)\n\n# This function will clean up first placeholder when this is empty.\ndef clean_first_placeholder(snip):\n    # Jumper is a helper for performing jumps in UltiSnips.\n    px.snippets.make_jumper(snip)\n\n    if snip.tabstop == 2 and not px.snippets.get_jumper_text(snip):\n        line = snip.buffer[snip.cursor[0]]\n        snip.buffer[snip.cursor[0]] = \\\n            line[:snip.tabstops[1].start[1]-2] + \\\n            line[snip.tabstops[1].end[1]+1:]\n        snip.cursor.set(\n            snip.cursor[0],\n            snip.cursor[1] - 3,\n        )\nendglobal\n\ncontext \"px.snippets.make_context(snip)\"\npost_jump \"clean_first_placeholder(snip)\"\nsnippet x \"Description\" b\n`!p jump_to_second_when_first_is_empty(snip)\n`func (${1:blah}) $2() {\n    $3\n}\nendsnippet\n```\n"
  },
  {
    "path": "doc/examples/snippets-aliasing/README.md",
    "content": "# Aliases for snippets\n\n![gif](https://raw.githubusercontent.com/SirVer/ultisnips/master/doc/examples/snippets-aliasing/demo.gif)\n\nThese examples use thes [vim-pythonx library](https://github.com/reconquest/vim-pythonx/blob/master/pythonx/px/snippets.py) which provides set of functions to make coding little bit easier.\n\nLet's imagine we're editing a shell file and we need to debug some state.\n\nWe will probably end up with a snippet that will automatically insert the location of the debug statement, the variable name and its content:\n\n```\nglobal !p\nimport px.snippets\nendglobal\n\nsnippet pr \"print debug\" bw\n`!p\nprefix = t[1] + \": %q\\\\n' \"\nprefix = \"{}:{}: {}\".format(\n    os.path.basename(px.buffer.get().name),\n    str(px.cursor.get()[0]),\n    prefix\n)\n`printf 'XXXXXX `!p snip.rv=prefix`$1 >&2\nendsnippet\n```\n\nNow, we want to use same debug snippet, but dump output to a file.\nHow can we do it?\n\nSimple, declare new snippet in that way:\n\n```\npost_jump \"px.snippets.expand(snip)\"\nsnippet pd \"Description\" b\npr$1 >${2:/tmp/debug}\nendsnippet\n```\n\nThis snippet will expand the `pr` snippet automatically (note `pr$1` part) after\njumping to the first placeholder (jump will be done automatically by UltiSnips\nengine).\n\n`px.snippets.expand(snip)` is declared in that way:\n\n```python\ndef expand(snip, jump_pos=1):\n    if snip.tabstop != jump_pos:\n        return\n\n    vim.eval('feedkeys(\"\\<C-R>=UltiSnips#ExpandSnippet()\\<CR>\")')\n```\n\n`px.buffer.get()` and `px.cursor.get()` are simple helpers for the `vim.current.window.buffer` and `vim.current.window.cursor`.\n"
  },
  {
    "path": "doc/examples/tabstop-generation/README.md",
    "content": "# Dynamic tabstop generation\n\n![gif](https://raw.githubusercontent.com/SirVer/ultisnips/master/doc/examples/tabstop-generation/demo.gif)\n\nUltiSnips at the present day is more than snippet engine. It's more like\nconstructor, where you can implement some complex features without prior\nfeature implementation in the snippet by itself.\n\nOne of that features is dynamic tabstop generation.\n\nConsider case, where you want set of snippets for inserting latex rows of\nvarious lengths. No-brainer solution is just implement snippet for every\nrow length you're possible will want, like this:\n\n```\nsnippet tr9 \"LaTeX table row of length nine\"\n$1 & $2 & $3 & $4 & $5 & $6 & $7 & $8 & $9\nendsnippet\n```\n\nBut soon it becomes a burden to maintain that kind of snippets.\n\nGladly, tabstops can be generated by using anonymous snippet expansion:\n\n```\nglobal !p\ndef create_row_placeholders(snip):\n    # retrieving single line from current string and treat it like tabstops\n    # count\n    placeholders_amount = int(snip.buffer[snip.line].strip())\n\n    # erase current line\n    snip.buffer[snip.line] = ''\n\n    # create anonymous snippet with expected content and number of tabstops\n    anon_snippet_body = ' & '.join(['$' + str(i+1)\n                                    for i in range(placeholders_amount)])\n\n    # expand anonymous snippet\n    snip.expand_anon(anon_snippet_body)\nendglobal\n\npost_jump \"create_row_placeholders(snip)\"\nsnippet \"tr(\\d+)\" \"latex table row variable\" br\n`!p snip.rv = match.group(1)`\nendsnippet\n```\n\nSnippet is declared via regular expression and will expand to any required\nnumber of fields in row.\n\nNow, for a more robust tabstop generation, to create placeholders within\nmultiple lines:\n\n```\nglobal !p\ndef create_matrix_placeholders(snip):\n\t# Create anonymous snippet body\n\tanon_snippet_body = \"\"\n\n\t# Get start and end line number of expanded snippet\n\tstart = snip.snippet_start[0]\n\tend = snip.snippet_end[0]\n\n  # Append current line into anonymous snippet\n\tfor i in range(start, end + 1):\n\t\tanon_snippet_body += snip.buffer[i]\n\t\tanon_snippet_body += \"\" if i == end else \"\\n\"\n\n\t# Delete expanded snippet line till second to last line\n\tfor i in range(start, end):\n\t\tdel snip.buffer[start]\n\n\t# Empty last expanded snippet line while preserving the line\n\tsnip.buffer[start] = ''\n\n\t# Expand anonymous snippet\n\tsnip.expand_anon(anon_snippet_body)\n\ndef create_matrix(cols, rows, sep, start, end):\n\tres = \"\"\n\tplaceholder = 1\n\tfor _ in range(0, int(rows)):\n\t\tres += start + f\"${placeholder} \"\n\t\tplaceholder += 1\n\t\tfor _ in range(0, int(cols) - 1):\n\t\t\tres += sep + f\" ${placeholder} \"\n\t\t\tplaceholder += 1\n\t\tres += end\n\treturn res[:-1]\nendglobal\n\npost_jump \"create_matrix_placeholders(snip)\"\nsnippet 'arr(\\d+),(\\d+)' \"LaTeX array\" br\n\\begin{array}{`!p\norient = \"\"\nfor _ in range(0, int(match.group(1))): orient += \"l\"\nsnip.rv = orient`}\n`!p\nsnip.rv = create_matrix(match.group(1), match.group(2), \"&\", \"\\t\", \"\\\\\\\\\\\\\\\\\\n\")\n`$0\n\\end{array}\nendsnippet\n```\n\n![gif](demo1.gif)\n"
  },
  {
    "path": "docker/build_vim.sh",
    "content": "#!/bin/bash\n\nset -o errexit\nset -o verbose\n\ncd /src/vim\n\nPYTHON_BUILD_CONFIG=\"--enable-python3interp\"\n\nexport CFLAGS=\"$(python-config --cflags)\"\necho $CFLAGS\n./configure \\\n   --disable-gpm \\\n   --disable-nls \\\n   --disable-sysmouse \\\n   --enable-gui=no \\\n   --enable-multibyte \\\n   --enable-python3interp \\\n   --with-features=huge \\\n   --with-tlib=ncurses \\\n   --without-x \\\n   || cat $(find . -name 'config.log')\nmake install\n"
  },
  {
    "path": "docker/docker_vimrc.vim",
    "content": "call plug#begin('~/.vim_plugged')\n\nPlug '/src/UltiSnips'\nPlug 'honza/vim-snippets'\n\nlet g:UltiSnipsExpandTrigger=\"<tab>\"\n\n\" Weird choices for triggers, but I wanted something that is rarely typed and\n\" never eaten by the shell.\nlet g:UltiSnipsListSnippets=\"9\"\nlet g:UltiSnipsJumpForwardTrigger=\"2\"\nlet g:UltiSnipsJumpBackwardTrigger=\"1\"\n\nlet g:UltiSnipsEditSplit=\"vertical\"\n\ncall plug#end()\n"
  },
  {
    "path": "docker/download_vim.sh",
    "content": "#!/bin/bash\n\nset -o errexit\nset -o verbose\n\nmkdir -p /src && cd /src\n\nif [[ $VIM_VERSION == \"git\" ]]; then\n   git clone https://github.com/vim/vim\nelse\n   curl -L https://github.com/vim/vim/archive/refs/tags/v${VIM_VERSION}.tar.gz  -o vim.tar.gz\n   tar xf vim.tar.gz && rm vim.tar.gz\n   mv -v vim* vim\nfi\n"
  },
  {
    "path": "docker/install_packages.sh",
    "content": "#!/bin/sh\n\nset -o errexit\nset -o verbose\n\napt-get update\napt-get install -y \\\n    g++ \\\n    moreutils \\\n    tmux \\\n    git\napt-get clean\n"
  },
  {
    "path": "docker/run_tests.sh",
    "content": "#!/usr/bin/env bash\n\nset -e -o pipefail\n\nPYTHON_CMD=\"$(which python)\"\nVIM=\"/usr/local/bin/vim\"\nPYTHON_VERSION=$($PYTHON_CMD -c 'import sys;print(sys.version.split()[0])')\necho \"Using python from: $PYTHON_CMD Version: $PYTHON_VERSION\"\necho \"Using vim from: $VIM\"\n$VIM --version | head -n 3\n\nset -x\n\ntmux new -d -s vim\n\n# Tests on CI sometimes hang, but we do not know which test it is for sure,\n# since all we see are lines of the prior passed tests. In an attempt to have\n# every character appear unbuffered we hope to uncover where the test actually\n# hangs.\n# We also use the `ts` tool to inform us when each line was printed to increase\n# the likelyhood to find the failing test faster. Adding these debug helps seem\n# to have reduced the likelyhood of the tests failing though.\n# See https://stackoverflow.com/questions/3465619/how-to-make-output-of-any-shell-command-unbuffered/25548995\nstdbuf -i0 -o0 -e0 \\\n   $PYTHON_CMD ./test_all.py \\\n   -v \\\n   --failfast \\\n   --plugins \\\n   --session vim \\\n   --vim $VIM \\\n   --interface tmux \\\n   --expected-python-version $PYTHON_VERSION \\\n   2>&1 | ts '[%Y-%m-%d %H:%M:%S]'\n"
  },
  {
    "path": "docker/snippets/all.snippets",
    "content": "snippet example \"Repro case example\"\nThis is a simple snippet example\nendsnippet\n"
  },
  {
    "path": "ftdetect/snippets.vim",
    "content": "\" recognize .snippet files\nif has(\"autocmd\")\n    autocmd BufNewFile,BufRead *.snippets setf snippets\nendif\n"
  },
  {
    "path": "ftplugin/snippets.vim",
    "content": "\" Set some sane defaults for snippet files\n\nif exists('b:did_ftplugin')\n    finish\nendif\nlet b:did_ftplugin = 1\n\nlet s:save_cpo = &cpo\nset cpo&vim\n\n\" Fold by syntax, but open all folds by default\nsetlocal foldmethod=syntax\nsetlocal foldlevel=99\n\nsetlocal commentstring=#%s\n\nsetlocal noexpandtab\nsetlocal autoindent nosmartindent nocindent\n\n\" Whenever a snippets file is written, we ask UltiSnips to reload all snippet\n\" files. This feels like auto-updating, but is of course just an\n\" approximation: If files change outside of the current Vim instance, we will\n\" not notice.\naugroup ultisnips_snippets.vim\nautocmd!\nautocmd BufWritePost <buffer> call UltiSnips#RefreshSnippets()\naugroup END\n\n\" Define match words for use with matchit plugin\n\" http://www.vim.org/scripts/script.php?script_id=39\nif exists(\"loaded_matchit\") && !exists(\"b:match_words\")\n  let b:match_ignorecase = 0\n  function! s:set_match_words() abort\n    let pairs = [\n                \\ ['^snippet\\>', '^endsnippet\\>'],\n                \\ ['^global\\>', '^endglobal\\>'],\n                \\ ]\n\n    \" Note: Keep the related patterns into a pattern\n    \" Because tabstop-patterns such as ${1}, ${1:foo}, ${VISUAL}, ..., end with\n    \" the same pattern, '}', matchit could fail to get corresponding '}' in\n    \" nested patterns like ${1:${VISUAL:bar}} when the end-pattern is simply\n    \" set to '}'.\n    call add(pairs, ['\\${\\%(\\d\\|VISUAL\\)|\\ze.*\\\\\\@<!|}', '\\\\\\@<!|}']) \" ${1|baz,qux|}\n    call add(pairs, ['\\${\\%(\\d\\|VISUAL\\)\\/\\ze.*\\\\\\@<!\\/[gima]*}', '\\\\\\@<!\\/[gima]*}']) \" ${1/garply/waldo/g}\n    call add(pairs, ['\\${\\%(\\%(\\d\\|VISUAL\\)\\:\\ze\\|\\ze\\%(\\d\\|VISUAL\\)\\).*\\\\\\@<!}', '\\\\\\@<!}']) \" ${1:foo}, ${VISUAL:bar}, ... or ${1}, ${VISUAL}, ...\n    call add(pairs, ['\\\\\\@<!`\\%(![pv]\\|#!\\/\\f\\+\\)\\%( \\|$\\)', '\\\\\\@<!`']) \" `!p quux`, `!v corge`, `#!/usr/bin/bash grault`, ... (indicators includes a whitespace or end-of-line)\n\n    let pats = map(deepcopy(pairs), 'join(v:val, \":\")')\n    let match_words = join(pats, ',')\n    return match_words\n  endfunction\n  let b:match_words = s:set_match_words()\n  delfunction s:set_match_words\n  let s:set_match_words = 1\nendif\n\n\" Add TagBar support\nlet g:tagbar_type_snippets = {\n            \\ 'ctagstype': 'UltiSnips',\n            \\ 'kinds': [\n                \\ 's:snippets',\n            \\ ],\n            \\ 'deffile': expand('<sfile>:p:h:h') . '/ctags/UltiSnips.cnf',\n        \\ }\n\n\" don't unset g:tagbar_type_snippets, it serves no purpose\nlet b:undo_ftplugin = \"\n            \\ setlocal foldmethod< foldlevel< commentstring<\n            \\|setlocal expandtab< autoindent< smartindent< cindent<\n            \\|if get(s:, 'set_match_words')\n                \\|unlet! b:match_ignorecase b:match_words s:set_match_words\n            \\|endif\n            \\\"\n\n\" snippet text object:\n\" iS: inside snippet\n\" aS: around snippet (including empty lines that follow)\nfun! s:UltiSnippetTextObj(inner) abort\n  normal! 0\n  let start = search('^snippet', 'nbcW')\n  let end   = search('^endsnippet', 'ncW')\n  let prev  = search('^endsnippet', 'nbW')\n\n  if !start || !end || prev > start\n    return feedkeys(\"\\<Esc>\", 'n')\n  endif\n\n  exe end\n\n  if a:inner\n    let start += 1\n    let end   -= 1\n\n  else\n    if search('^\\S') <= (end + 1)\n      exe end\n    else\n      let end = line('.') - 1\n    endif\n  endif\n\n  exe start\n  k<\n  exe end\n  normal! $m>gv\nendfun\n\nonoremap <silent><buffer> iS :<C-U>call <SID>UltiSnippetTextObj(1)<CR>\nxnoremap <silent><buffer> iS :<C-U>call <SID>UltiSnippetTextObj(1)<CR>\nonoremap <silent><buffer> aS :<C-U>call <SID>UltiSnippetTextObj(0)<CR>\nxnoremap <silent><buffer> aS :<C-U>call <SID>UltiSnippetTextObj(0)<CR>\n\nlet &cpo = s:save_cpo\nunlet s:save_cpo\n"
  },
  {
    "path": "mypy.ini",
    "content": "# Global options:\n\n[mypy]\npython_version = 3.7\nwarn_return_any = True\nwarn_unused_configs = True\nmypy_path=pythonx/UltiSnips\n\n[mypy-vim]\nignore_missing_imports = True\n\n[mypy-unidecode]\nignore_missing_imports = True\n"
  },
  {
    "path": "plugin/UltiSnips.vim",
    "content": "if exists('did_plugin_ultisnips') || &cp\n    finish\nendif\nlet did_plugin_ultisnips=1\n\nif version < 800\n   echohl WarningMsg\n   echom  \"UltiSnips requires Vim >= 8.0\"\n   echohl None\n   finish\nendif\n\n\" Enable Post debug server config\nif !exists(\"g:UltiSnipsDebugServerEnable\")\n   let g:UltiSnipsDebugServerEnable = 0\nendif\n\nif !exists(\"g:UltiSnipsDebugHost\")\n   let g:UltiSnipsDebugHost = 'localhost'\nendif\n\nif !exists(\"g:UltiSnipsDebugPort\")\n   let g:UltiSnipsDebugPort = 8080\nendif\n\nif !exists(\"g:UltiSnipsPMDebugBlocking\")\n   let g:UltiSnipsPMDebugBlocking = 0\nendif\n\n\n\" The Commands we define.\ncommand! -bang -nargs=? -complete=customlist,UltiSnips#FileTypeComplete UltiSnipsEdit\n    \\ :call UltiSnips#Edit(<q-bang>, <q-args>)\n\ncommand! -nargs=1 UltiSnipsAddFiletypes :call UltiSnips#AddFiletypes(<q-args>)\n\naugroup UltiSnips_AutoTrigger\n    au!\n    au InsertCharPre * call UltiSnips#TrackChange()\n    au TextChangedI * call UltiSnips#TrackChange()\n    if exists('##TextChangedP')\n        au TextChangedP * call UltiSnips#TrackChange()\n    endif\naugroup END\n\ncall UltiSnips#map_keys#MapKeys()\n\n\" vim: ts=8 sts=4 sw=4\n"
  },
  {
    "path": "pylintrc",
    "content": "[MASTER]\n\n# Python code to execute, usually for sys.path manipulation such as\n# pygtk.require().\ninit-hook='import sys; sys.path.append(\"pythonx/\")'\n\n# Add files or directories to the blacklist. They should be base names, not\n# paths.\nignore=CVS,compatibility_py3\n\n# Pickle collected data for later comparisons.\npersistent=no\n\n# List of plugins (as comma separated values of python modules names) to load,\n# usually to register additional checkers.\nload-plugins=\n\n\n[MESSAGES CONTROL]\n\n# Enable the message, report, category or checker with the given id(s). You can\n# either give multiple identifier separated by comma (,) or put this option\n# multiple time. See also the \"--disable\" option for examples.\n#enable=\n\n# Disable the message, report, category or checker with the given id(s). You\n# can either give multiple identifiers separated by comma (,) or put this\n# option multiple times (only on the command line, not in the configuration\n# file where it should appear only once).You can also use \"--disable=all\" to\n# disable everything first and then reenable specific checks. For example, if\n# you want to run only the similarities checker, you can use \"--disable=all\n# --enable=similarities\". If you want to run only the classes checker, but have\n# no Warning level messages displayed, use\"--disable=all --enable=classes\n# --disable=W\"\ndisable=\n   attribute-defined-outside-init,\n   bad-continuation,\n   fixme,\n   import-error,\n   missing-class-docstring,\n   missing-function-docstring,\n   missing-module-docstring,\n   redefined-builtin,\n   too-few-public-methods,\n   too-many-arguments,\n   too-many-branches,\n   too-many-instance-attributes, \n   too-many-locals,\n   too-many-public-methods, \n   too-many-return-statements,\n   too-many-statements\n\n\n\n[REPORTS]\n\n# Set the output format. Available formats are text, parseable, colorized, msvs\n# (visual studio) and html. You can also give a reporter class, eg\n# mypackage.mymodule.MyReporterClass.\noutput-format=text\n\n# Tells whether to display a full report or only the messages\nreports=no\n\nmsg-template=\"{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}\"\n\n\n\n[BASIC]\n\n# Required attributes for module, separated by a comma\nrequired-attributes=\n\n# List of builtins function names that should not be used, separated by a comma\nbad-functions=apply,input\n\n# Regular expression which should only match correct module names\nmodule-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$\n\n# Regular expression which should only match correct module level names\nconst-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$\n\n# Regular expression which should only match correct class names\nclass-rgx=[A-Z_][a-zA-Z0-9]+$\n\n# Regular expression which should only match correct function names\nfunction-rgx=_?[a-z_][a-z0-9_]{2,50}$\n\n# Regular expression which should only match correct method names\nmethod-rgx=[a-z_][a-z0-9_]{2,50}$\n\n# Regular expression which should only match correct instance attribute names\nattr-rgx=[a-z_][a-z0-9_]{2,50}$\n\n# Regular expression which should only match correct argument names\nargument-rgx=[a-z_][a-z0-9_]{1,50}$\n\n# Regular expression which should only match correct variable names\nvariable-rgx=[a-z_][a-z0-9_]{1,50}$\n\n# Regular expression which should only match correct attribute names in class\n# bodies\nclass-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$\n\n# Regular expression which should only match correct list comprehension /\n# generator expression variable names\ninlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$\n\n# Good variable names which should always be accepted, separated by a comma\ngood-names=i,j,a,b,x,y,k,ex,Run,_\n\n# Bad variable names which should always be refused, separated by a comma\nbad-names=foo,bar,baz,toto,tutu,tata\n\n# Regular expression which should only match function or class names that do\n# not require a docstring.\nno-docstring-rgx=(__.*__|wrapper)\n\n# Minimum line length for functions/classes that require docstrings, shorter\n# ones are exempt.\ndocstring-min-length=-1\n\n\n[FORMAT]\n\n# Maximum number of characters on a single line.\nmax-line-length=110\n\n# Regexp for a line that is allowed to be longer than the limit.\nignore-long-lines=^\\s*(# )?<?https?://\\S+>?$\n\n# Allow the body of an if to be on the same line as the test if there is no\n# else.\nsingle-line-if-stmt=no\n\n# List of optional constructs for which whitespace checking is disabled\nno-space-check=trailing-comma,dict-separator\n\n# Maximum number of lines in a module\nmax-module-lines=1000\n\n# String used as indentation unit. This is usually \" \" (4 spaces) or \"\\t\" (1\n# tab).\nindent-string='    '\n\n\n[SIMILARITIES]\n\n# Minimum lines number of a similarity.\nmin-similarity-lines=4\n\n# Ignore comments when computing similarities.\nignore-comments=yes\n\n# Ignore docstrings when computing similarities.\nignore-docstrings=yes\n\n# Ignore imports when computing similarities.\nignore-imports=no\n\n\n[TYPECHECK]\n\n# Tells whether missing members accessed in mixin class should be ignored. A\n# mixin class is detected if its name ends with \"mixin\" (case insensitive).\nignore-mixin-members=yes\n\n# List of classes names for which member attributes should not be checked\n# (useful for classes with attributes dynamically set).\nignored-classes=SQLObject\nignored-modules=vim\n\n# When zope mode is activated, add a predefined set of Zope acquired attributes\n# to generated-members.\nzope=no\n\n# List of members which are set dynamically and missed by pylint inference\n# system, and so shouldn't trigger E0201 when accessed. Python regular\n# expressions are accepted.\ngenerated-members=REQUEST,acl_users,aq_parent\n\n\n[VARIABLES]\n\n# Tells whether we should check for unused import in __init__ files.\ninit-import=no\n\n# A regular expression matching the beginning of the name of dummy variables\n# (i.e. not used).\ndummy-variables-rgx=_$|dummy\n\n# List of additional names supposed to be defined in builtins. Remember that\n# you should avoid to define new builtins when possible.\nadditional-builtins=\n\n\n[CLASSES]\n\n# List of interface methods to ignore, separated by a comma. This is used for\n# instance to not check methods defines in Zope's Interface base class.\nignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by\n\n# List of method names used to declare (i.e. assign) instance attributes.\ndefining-attr-methods=__init__,__new__,setUp\n\n# List of valid names for the first argument in a class method.\nvalid-classmethod-first-arg=cls\n\n# List of valid names for the first argument in a metaclass class method.\nvalid-metaclass-classmethod-first-arg=mcs\n\n\n[DESIGN]\n\n# Maximum number of arguments for function / method\nmax-args=5\n\n# Argument names that match this expression will be ignored. Default to name\n# with leading underscore\nignored-argument-names=_.*\n\n# Maximum number of locals for function / method body\nmax-locals=15\n\n# Maximum number of return / yield for function / method body\nmax-returns=6\n\n# Maximum number of branch for function / method body\nmax-branches=12\n\n# Maximum number of statements in function / method body\nmax-statements=50\n\n# Maximum number of parents for a class (see R0901).\nmax-parents=7\n\n# Maximum number of attributes for a class (see R0902).\nmax-attributes=7\n\n# Minimum number of public methods for a class (see R0903).\nmin-public-methods=2\n\n# Maximum number of public methods for a class (see R0904).\nmax-public-methods=20\n\n\n[IMPORTS]\n\n# Deprecated modules which should not be used, separated by a comma\ndeprecated-modules=regsub,TERMIOS,Bastion,rexec\n\n# Create a graph of every (i.e. internal and external) dependencies in the\n# given file (report RP0402 must not be disabled)\nimport-graph=\n\n# Create a graph of external dependencies in the given file (report RP0402 must\n# not be disabled)\next-import-graph=\n\n# Create a graph of internal dependencies in the given file (report RP0402 must\n# not be disabled)\nint-import-graph=\n\n\n[EXCEPTIONS]\n\n# Exceptions that will emit a warning when being caught. Defaults to\n# \"Exception\"\novergeneral-exceptions=Exception\n"
  },
  {
    "path": "pythonx/UltiSnips/__init__.py",
    "content": "#!/usr/bin/env python3\n# encoding: utf-8\n\n\"\"\"Entry point for all things UltiSnips.\"\"\"\n\nfrom UltiSnips.snippet_manager import UltiSnips_Manager\n"
  },
  {
    "path": "pythonx/UltiSnips/buffer_proxy.py",
    "content": "# coding=utf8\n\nimport vim\nfrom UltiSnips import vim_helper\nfrom UltiSnips.diff import diff\nfrom UltiSnips.error import PebkacError\nfrom UltiSnips.position import Position\n\nfrom contextlib import contextmanager\n\n\n@contextmanager\ndef use_proxy_buffer(snippets_stack, vstate):\n    \"\"\"\n    Forward all changes made in the buffer to the current snippet stack while\n    function call.\n    \"\"\"\n    buffer_proxy = VimBufferProxy(snippets_stack, vstate)\n    old_buffer = vim_helper.buf\n    try:\n        vim_helper.buf = buffer_proxy\n        yield\n    finally:\n        vim_helper.buf = old_buffer\n    buffer_proxy.validate_buffer()\n\n\n@contextmanager\ndef suspend_proxy_edits():\n    \"\"\"\n    Prevents changes being applied to the snippet stack while function call.\n    \"\"\"\n    if not isinstance(vim_helper.buf, VimBufferProxy):\n        yield\n    else:\n        try:\n            vim_helper.buf._disable_edits()\n            yield\n        finally:\n            vim_helper.buf._enable_edits()\n\n\nclass VimBufferProxy(vim_helper.VimBuffer):\n    \"\"\"\n    Proxy object used for tracking changes that made from snippet actions.\n\n    Unfortunately, vim by itself lacks of the API for changing text in\n    trackable maner.\n\n    Vim marks offers limited functionality for tracking line additions and\n    deletions, but nothing offered for tracking changes withing single line.\n\n    Instance of this class is passed to all snippet actions and behaves as\n    internal vim.current.window.buffer.\n\n    All changes that are made by user passed to diff algorithm, and resulting\n    diff applied to internal snippet structures to ensure they are in sync with\n    actual buffer contents.\n    \"\"\"\n\n    def __init__(self, snippets_stack, vstate):\n        \"\"\"\n        Instantiate new object.\n\n        snippets_stack is a slice of currently active snippets.\n        \"\"\"\n        self._snippets_stack = snippets_stack\n        self._buffer = vim.current.buffer\n        self._change_tick = int(vim.eval(\"b:changedtick\"))\n        self._forward_edits = True\n        self._vstate = vstate\n\n    def is_buffer_changed_outside(self):\n        \"\"\"\n        Returns true, if buffer was changed without using proxy object, like\n        with vim.command() or through internal vim.current.window.buffer.\n        \"\"\"\n        return self._change_tick < int(vim.eval(\"b:changedtick\"))\n\n    def validate_buffer(self):\n        \"\"\"\n        Raises exception if buffer is changes beyound proxy object.\n        \"\"\"\n        if self.is_buffer_changed_outside():\n            raise PebkacError(\n                \"buffer was modified using vim.command or \"\n                + \"vim.current.buffer; that changes are untrackable and leads to \"\n                + \"errors in snippet expansion; use special variable `snip.buffer` \"\n                \"for buffer modifications.\\n\\n\"\n                + \"See :help UltiSnips-buffer-proxy for more info.\"\n            )\n\n    def __setitem__(self, key, value):\n        \"\"\"\n        Behaves as vim.current.window.buffer.__setitem__ except it tracks\n        changes and applies them to the current snippet stack.\n        \"\"\"\n        if isinstance(key, slice):\n            value = [line for line in value]\n            changes = list(self._get_diff(key.start, key.stop, value))\n            self._buffer[key.start : key.stop] = [line.strip(\"\\n\") for line in value]\n        else:\n            value = value\n            changes = list(self._get_line_diff(key, self._buffer[key], value))\n            self._buffer[key] = value\n\n        self._change_tick += 1\n\n        if self._forward_edits:\n            for change in changes:\n                self._apply_change(change)\n            if self._snippets_stack:\n                self._vstate.remember_buffer(self._snippets_stack[0])\n\n    def __setslice__(self, i, j, text):\n        \"\"\"\n        Same as __setitem__.\n        \"\"\"\n        self.__setitem__(slice(i, j), text)\n\n    def __getitem__(self, key):\n        \"\"\"\n        Just passing call to the vim.current.window.buffer.__getitem__.\n        \"\"\"\n        return self._buffer[key]\n\n    def __getslice__(self, i, j):\n        \"\"\"\n        Same as __getitem__.\n        \"\"\"\n        return self.__getitem__(slice(i, j))\n\n    def __len__(self):\n        \"\"\"\n        Same as len(vim.current.window.buffer).\n        \"\"\"\n        return len(self._buffer)\n\n    def append(self, line, line_number=-1):\n        \"\"\"\n        Same as vim.current.window.buffer.append(), but with tracking changes.\n        \"\"\"\n        if line_number < 0:\n            line_number = len(self)\n        if not isinstance(line, list):\n            line = [line]\n        self[line_number:line_number] = [l for l in line]\n\n    def __delitem__(self, key):\n        if isinstance(key, slice):\n            self.__setitem__(key, [])\n        else:\n            self.__setitem__(slice(key, key + 1), [])\n\n    def _get_diff(self, start, end, new_value):\n        \"\"\"\n        Very fast diffing algorithm when changes are across many lines.\n        \"\"\"\n        for line_number in range(start, end):\n            if line_number < 0:\n                line_number = len(self._buffer) + line_number\n            yield (\"D\", line_number, 0, self._buffer[line_number], True)\n\n        if start < 0:\n            start = len(self._buffer) + start\n        for line_number in range(0, len(new_value)):\n            yield (\"I\", start + line_number, 0, new_value[line_number], True)\n\n    def _get_line_diff(self, line_number, before, after):\n        \"\"\"\n        Use precise diffing for tracking changes in single line.\n        \"\"\"\n        if before == \"\":\n            for change in self._get_diff(line_number, line_number + 1, [after]):\n                yield change\n        else:\n            for change in diff(before, after):\n                yield (change[0], line_number, change[2], change[3])\n\n    def _apply_change(self, change):\n        \"\"\"\n        Apply changeset to current snippets stack, correctly moving around\n        snippet itself or its child.\n        \"\"\"\n        if not self._snippets_stack:\n            return\n\n        change_type, line_number, column_number, change_text = change[0:4]\n\n        line_before = line_number <= self._snippets_stack[0]._start.line\n        column_before = column_number <= self._snippets_stack[0]._start.col\n        if line_before and column_before:\n            direction = 1\n            if change_type == \"D\":\n                direction = -1\n\n            diff = Position(direction, 0)\n            if len(change) != 5:\n                diff = Position(0, direction * len(change_text))\n\n            self._snippets_stack[0]._move(Position(line_number, column_number), diff)\n        else:\n            if line_number > self._snippets_stack[0]._end.line:\n                return\n            if column_number >= self._snippets_stack[0]._end.col:\n                return\n            self._snippets_stack[0]._do_edit(change[0:4])\n\n    def _disable_edits(self):\n        \"\"\"\n        Temporary disable applying changes to snippets stack. Should be done\n        while expanding anonymous snippet in the middle of jump to prevent\n        double tracking.\n        \"\"\"\n        self._forward_edits = False\n\n    def _enable_edits(self):\n        \"\"\"\n        Enables changes forwarding back.\n        \"\"\"\n        self._forward_edits = True\n"
  },
  {
    "path": "pythonx/UltiSnips/compatibility.py",
    "content": "#!/usr/bin/env python3\n# encoding: utf-8\n\n\"\"\"This file contains compatibility code to stay compatible with as many python\nversions as possible.\"\"\"\n\nimport vim\n\n\ndef _vim_dec(string):\n    \"\"\"Decode 'string' using &encoding.\"\"\"\n    # We don't have the luxury here of failing, everything\n    # falls apart if we don't return a bytearray from the\n    # passed in string\n    return string.decode(vim.eval(\"&encoding\"), \"replace\")\n\n\ndef _vim_enc(bytearray):\n    \"\"\"Encode 'string' using &encoding.\"\"\"\n    # We don't have the luxury here of failing, everything\n    # falls apart if we don't return a string from the passed\n    # in bytearray\n    return bytearray.encode(vim.eval(\"&encoding\"), \"replace\")\n\n\ndef col2byte(line, col):\n    \"\"\"Convert a valid column index into a byte index inside of vims\n    buffer.\"\"\"\n    # We pad the line so that selecting the +1 st column still works.\n    pre_chars = (vim.current.buffer[line - 1] + \"  \")[:col]\n    return len(_vim_enc(pre_chars))\n\n\ndef byte2col(line, nbyte):\n    \"\"\"Convert a column into a byteidx suitable for a mark or cursor\n    position inside of vim.\"\"\"\n    line = vim.current.buffer[line - 1]\n    raw_bytes = _vim_enc(line)[:nbyte]\n    return len(_vim_dec(raw_bytes))\n"
  },
  {
    "path": "pythonx/UltiSnips/debug.py",
    "content": "#!/usr/bin/env python3\n# encoding: utf-8\n\n\"\"\"Convenience methods that help with debugging.\n\nThey should never be used in production code.\n\n\"\"\"\n\nimport sys\n\nDUMP_FILENAME = (\n    \"/tmp/file.txt\"\n    if not sys.platform.lower().startswith(\"win\")\n    else \"C:/windows/temp/ultisnips.txt\"\n)\nwith open(DUMP_FILENAME, \"w\"):\n    pass  # clears the file\n\n\ndef echo_to_hierarchy(text_object):\n    \"\"\"Outputs the given 'text_object' and its children hierarchically.\"\"\"\n    # pylint:disable=protected-access\n    orig = text_object\n    parent = text_object\n    while parent._parent:\n        parent = parent._parent\n\n    def _do_print(text_object, indent=\"\"):\n        \"\"\"prints recursively.\"\"\"\n        debug(indent + (\"MAIN: \" if text_object == orig else \"\") + str(text_object))\n        try:\n            for child in text_object._children:\n                _do_print(child, indent=indent + \"  \")\n        except AttributeError:\n            pass\n\n    _do_print(parent)\n\n\ndef debug(msg):\n    \"\"\"Dumb 'msg' into the debug file.\"\"\"\n    with open(DUMP_FILENAME, \"ab\") as dump_file:\n        dump_file.write((msg + \"\\n\").encode(\"utf-8\"))\n\n\ndef print_stack():\n    \"\"\"Dump a stack trace into the debug file.\"\"\"\n    import traceback\n\n    with open(DUMP_FILENAME, \"a\") as dump_file:\n        traceback.print_stack(file=dump_file)\n"
  },
  {
    "path": "pythonx/UltiSnips/diff.py",
    "content": "#!/usr/bin/env python3\n# encoding: utf-8\n\n\"\"\"Commands to compare text objects and to guess how to transform from one to\nanother.\"\"\"\n\nfrom collections import defaultdict\nimport sys\n\nfrom UltiSnips import vim_helper\nfrom UltiSnips.position import Position\n\n\ndef is_complete_edit(initial_line, original, wanted, cmds):\n    \"\"\"Returns true if 'original' is changed to 'wanted' with the edit commands\n    in 'cmds'.\n\n    Initial line is to change the line numbers in 'cmds'.\n\n    \"\"\"\n    buf = original[:]\n    for cmd in cmds:\n        ctype, line, col, char = cmd\n        line -= initial_line\n        if ctype == \"D\":\n            if char != \"\\n\":\n                buf[line] = buf[line][:col] + buf[line][col + len(char) :]\n            else:\n                if line + 1 < len(buf):\n                    buf[line] = buf[line] + buf[line + 1]\n                    del buf[line + 1]\n                else:\n                    del buf[line]\n        elif ctype == \"I\":\n            buf[line] = buf[line][:col] + char + buf[line][col:]\n        buf = \"\\n\".join(buf).split(\"\\n\")\n    return len(buf) == len(wanted) and all(j == k for j, k in zip(buf, wanted))\n\n\ndef guess_edit(initial_line, last_text, current_text, vim_state):\n    \"\"\"Try to guess what the user might have done by heuristically looking at\n    cursor movement, number of changed lines and if they got longer or shorter.\n    This will detect most simple movements like insertion, deletion of a line\n    or carriage return. 'initial_text' is the index of where the comparison\n    starts, 'last_text' is the last text of the snippet, 'current_text' is the\n    current text of the snippet and 'vim_state' is the cached vim state.\n\n    Returns (True, edit_cmds) when the edit could be guessed, (False,\n    None) otherwise.\n\n    \"\"\"\n    if not len(last_text) and not len(current_text):\n        return True, ()\n    pos = vim_state.pos\n    ppos = vim_state.ppos\n\n    # All text deleted?\n    if len(last_text) and (\n        not current_text or (len(current_text) == 1 and not current_text[0])\n    ):\n        es = []\n        if not current_text:\n            current_text = [\"\"]\n        for i in last_text:\n            es.append((\"D\", initial_line, 0, i))\n            es.append((\"D\", initial_line, 0, \"\\n\"))\n        es.pop()  # Remove final \\n because it is not really removed\n        if is_complete_edit(initial_line, last_text, current_text, es):\n            return True, es\n    if ppos.mode == \"v\":  # Maybe selectmode?\n        sv = list(map(int, vim_helper.eval(\"\"\"getpos(\"'<\")\"\"\")))\n        sv = Position(sv[1] - 1, sv[2] - 1)\n        ev = list(map(int, vim_helper.eval(\"\"\"getpos(\"'>\")\"\"\")))\n        ev = Position(ev[1] - 1, ev[2] - 1)\n        if \"exclusive\" in vim_helper.eval(\"&selection\"):\n            ppos.col -= 1  # We want to be inclusive, sorry.\n            ev.col -= 1\n        es = []\n        if sv.line == ev.line:\n            es.append(\n                (\n                    \"D\",\n                    sv.line,\n                    sv.col,\n                    last_text[sv.line - initial_line][sv.col : ev.col + 1],\n                )\n            )\n            if sv != pos and sv.line == pos.line:\n                es.append(\n                    (\n                        \"I\",\n                        sv.line,\n                        sv.col,\n                        current_text[sv.line - initial_line][sv.col : pos.col + 1],\n                    )\n                )\n        if is_complete_edit(initial_line, last_text, current_text, es):\n            return True, es\n    if pos.line == ppos.line:\n        if len(last_text) == len(current_text):  # Movement only in one line\n            llen = len(last_text[ppos.line - initial_line])\n            clen = len(current_text[pos.line - initial_line])\n            if ppos < pos and clen > llen:  # maybe only chars have been added\n                es = (\n                    (\n                        \"I\",\n                        ppos.line,\n                        ppos.col,\n                        current_text[ppos.line - initial_line][ppos.col : pos.col],\n                    ),\n                )\n                if is_complete_edit(initial_line, last_text, current_text, es):\n                    return True, es\n            if clen < llen:\n                if ppos == pos:  # 'x' or DEL or dt or something\n                    es = (\n                        (\n                            \"D\",\n                            pos.line,\n                            pos.col,\n                            last_text[ppos.line - initial_line][\n                                ppos.col : ppos.col + (llen - clen)\n                            ],\n                        ),\n                    )\n                    if is_complete_edit(initial_line, last_text, current_text, es):\n                        return True, es\n                if pos < ppos:  # Backspacing or dT dF?\n                    es = (\n                        (\n                            \"D\",\n                            pos.line,\n                            pos.col,\n                            last_text[pos.line - initial_line][\n                                pos.col : pos.col + llen - clen\n                            ],\n                        ),\n                    )\n                    if is_complete_edit(initial_line, last_text, current_text, es):\n                        return True, es\n        elif len(current_text) < len(last_text):\n            # were some lines deleted? (dd or so)\n            es = []\n            for i in range(len(last_text) - len(current_text)):\n                es.append((\"D\", pos.line, 0, last_text[pos.line - initial_line + i]))\n                es.append((\"D\", pos.line, 0, \"\\n\"))\n            if is_complete_edit(initial_line, last_text, current_text, es):\n                return True, es\n    else:\n        # Movement in more than one line\n        if ppos.line + 1 == pos.line and pos.col == 0:  # Carriage return?\n            es = ((\"I\", ppos.line, ppos.col, \"\\n\"),)\n            if is_complete_edit(initial_line, last_text, current_text, es):\n                return True, es\n    return False, None\n\n\ndef diff(a, b, sline=0):\n    \"\"\"\n    Return a list of deletions and insertions that will turn 'a' into 'b'. This\n    is done by traversing an implicit edit graph and searching for the shortest\n    route. The basic idea is as follows:\n\n        - Matching a character is free as long as there was no\n          deletion/insertion before. Then, matching will be seen as delete +\n          insert [1].\n        - Deleting one character has the same cost everywhere. Each additional\n          character costs only have of the first deletion.\n        - Insertion is cheaper the earlier it happens. The first character is\n          more expensive that any later [2].\n\n    [1] This is that world -> aolsa will be \"D\" world + \"I\" aolsa instead of\n        \"D\" w , \"D\" rld, \"I\" a, \"I\" lsa\n    [2] This is that \"hello\\n\\n\" -> \"hello\\n\\n\\n\" will insert a newline after\n        hello and not after \\n\n    \"\"\"\n    d = defaultdict(list)  # pylint:disable=invalid-name\n    seen = defaultdict(lambda: sys.maxsize)\n\n    d[0] = [(0, 0, sline, 0, ())]\n    cost = 0\n    deletion_cost = len(a) + len(b)\n    insertion_cost = len(a) + len(b)\n    while True:\n        while len(d[cost]):\n            x, y, line, col, what = d[cost].pop()\n\n            if a[x:] == b[y:]:\n                return what\n\n            if x < len(a) and y < len(b) and a[x] == b[y]:\n                ncol = col + 1\n                nline = line\n                if a[x] == \"\\n\":\n                    ncol = 0\n                    nline += 1\n                lcost = cost + 1\n                if (\n                    what\n                    and what[-1][0] == \"D\"\n                    and what[-1][1] == line\n                    and what[-1][2] == col\n                    and a[x] != \"\\n\"\n                ):\n                    # Matching directly after a deletion should be as costly as\n                    # DELETE + INSERT + a bit\n                    lcost = (deletion_cost + insertion_cost) * 1.5\n                if seen[x + 1, y + 1] > lcost:\n                    d[lcost].append((x + 1, y + 1, nline, ncol, what))\n                    seen[x + 1, y + 1] = lcost\n            if y < len(b):  # INSERT\n                ncol = col + 1\n                nline = line\n                if b[y] == \"\\n\":\n                    ncol = 0\n                    nline += 1\n                if (\n                    what\n                    and what[-1][0] == \"I\"\n                    and what[-1][1] == nline\n                    and what[-1][2] + len(what[-1][-1]) == col\n                    and b[y] != \"\\n\"\n                    and seen[x, y + 1] > cost + (insertion_cost + ncol) // 2\n                ):\n                    seen[x, y + 1] = cost + (insertion_cost + ncol) // 2\n                    d[cost + (insertion_cost + ncol) // 2].append(\n                        (\n                            x,\n                            y + 1,\n                            line,\n                            ncol,\n                            what[:-1]\n                            + ((\"I\", what[-1][1], what[-1][2], what[-1][-1] + b[y]),),\n                        )\n                    )\n                elif seen[x, y + 1] > cost + insertion_cost + ncol:\n                    seen[x, y + 1] = cost + insertion_cost + ncol\n                    d[cost + ncol + insertion_cost].append(\n                        (x, y + 1, nline, ncol, what + ((\"I\", line, col, b[y]),))\n                    )\n            if x < len(a):  # DELETE\n                if (\n                    what\n                    and what[-1][0] == \"D\"\n                    and what[-1][1] == line\n                    and what[-1][2] == col\n                    and a[x] != \"\\n\"\n                    and what[-1][-1] != \"\\n\"\n                    and seen[x + 1, y] > cost + deletion_cost // 2\n                ):\n                    seen[x + 1, y] = cost + deletion_cost // 2\n                    d[cost + deletion_cost // 2].append(\n                        (\n                            x + 1,\n                            y,\n                            line,\n                            col,\n                            what[:-1] + ((\"D\", line, col, what[-1][-1] + a[x]),),\n                        )\n                    )\n                elif seen[x + 1, y] > cost + deletion_cost:\n                    seen[x + 1, y] = cost + deletion_cost\n                    d[cost + deletion_cost].append(\n                        (x + 1, y, line, col, what + ((\"D\", line, col, a[x]),))\n                    )\n        cost += 1\n"
  },
  {
    "path": "pythonx/UltiSnips/err_to_scratch_buffer.py",
    "content": "# coding=utf8\n\nfrom functools import wraps\nimport traceback\nimport re\nimport sys\nimport time\nfrom bdb import BdbQuit\n\nfrom UltiSnips import vim_helper\nfrom UltiSnips.error import PebkacError\nfrom UltiSnips.remote_pdb import RemotePDB\n\n\ndef _report_exception(self, msg, e):\n    if hasattr(e, \"snippet_info\"):\n        msg += \"\\nSnippet, caused error:\\n\"\n        msg += re.sub(r\"^(?=\\S)\", \"  \", e.snippet_info, flags=re.MULTILINE)\n    # snippet_code comes from _python_code.py, it's set manually for\n    # providing error message with stacktrace of failed python code\n    # inside of the snippet.\n    if hasattr(e, \"snippet_code\"):\n        _, _, tb = sys.exc_info()\n        tb_top = traceback.extract_tb(tb)[-1]\n        msg += \"\\nExecuted snippet code:\\n\"\n        lines = e.snippet_code.split(\"\\n\")\n        for number, line in enumerate(lines, 1):\n            msg += str(number).rjust(3)\n            prefix = \"   \" if line else \"\"\n            if tb_top[1] == number:\n                prefix = \" > \"\n            msg += prefix + line + \"\\n\"\n\n    # Vim sends no WinLeave msg here.\n    if hasattr(self, \"_leaving_buffer\"):\n        self._leaving_buffer()  # pylint:disable=protected-access\n    vim_helper.new_scratch_buffer(msg)\n\n\ndef wrap(func):\n    \"\"\"Decorator that will catch any Exception that 'func' throws and displays\n    it in a new Vim scratch buffer.\"\"\"\n\n    @wraps(func)\n    def wrapper(self, *args, **kwds):\n        try:\n            return func(self, *args, **kwds)\n        except BdbQuit:\n            pass  # A debugger stopped, but it's not really an error\n        except PebkacError as e:\n            if RemotePDB.is_enable():\n                RemotePDB.pm()\n            msg = \"UltiSnips Error:\\n\\n\"\n            msg += str(e).strip()\n            if RemotePDB.is_enable():\n                host, port = RemotePDB.get_host_port()\n                msg += \"\\nUltisnips' post mortem debug server caught the error. Run `telnet {}:{}` to inspect it with pdb\\n\".format(\n                    host, port\n                )\n            _report_exception(self, msg, e)\n        except Exception as e:  # pylint: disable=bare-except\n            if RemotePDB.is_enable():\n                RemotePDB.pm()\n            msg = \"\"\"An error occured. This is either a bug in UltiSnips or a bug in a\nsnippet definition. If you think this is a bug, please report it to\nhttps://github.com/SirVer/ultisnips/issues/new\nPlease read and follow:\nhttps://github.com/SirVer/ultisnips/blob/master/CONTRIBUTING.md#reproducing-bugs\n\nFollowing is the full stack trace:\n\"\"\"\n            msg += traceback.format_exc()\n            if RemotePDB.is_enable():\n                host, port = RemotePDB.get_host_port()\n                msg += \"\\nUltisnips' post mortem debug server caught the error. Run `telnet {}:{}` to inspect it with pdb\\n\".format(\n                    host, port\n                )\n\n            _report_exception(self, msg, e)\n\n    return wrapper\n"
  },
  {
    "path": "pythonx/UltiSnips/error.py",
    "content": "#!/usr/bin/env python\n# encoding: utf-8\n\n\nclass PebkacError(RuntimeError):\n    \"\"\"An error that was caused by a misconfiguration or error in a snippet,\n    i.e. caused by the user. Hence: \"Problem exists between keyboard and\n    chair\".\n    \"\"\"\n\n    pass\n"
  },
  {
    "path": "pythonx/UltiSnips/indent_util.py",
    "content": "#!/usr/bin/env python3\n# encoding: utf-8\n\n\"\"\"See module doc.\"\"\"\n\nfrom UltiSnips import vim_helper\n\n\nclass IndentUtil:\n\n    \"\"\"Utility class for dealing properly with indentation.\"\"\"\n\n    def __init__(self):\n        self.reset()\n\n    def reset(self):\n        \"\"\"Gets the spacing properties from Vim.\"\"\"\n        self.shiftwidth = int(\n            vim_helper.eval(\"exists('*shiftwidth') ? shiftwidth() : &shiftwidth\")\n        )\n        self._expandtab = vim_helper.eval(\"&expandtab\") == \"1\"\n        self._tabstop = int(vim_helper.eval(\"&tabstop\"))\n\n    def ntabs_to_proper_indent(self, ntabs):\n        \"\"\"Convert 'ntabs' number of tabs to the proper indent prefix.\"\"\"\n        line_ind = ntabs * self.shiftwidth * \" \"\n        line_ind = self.indent_to_spaces(line_ind)\n        line_ind = self.spaces_to_indent(line_ind)\n        return line_ind\n\n    def indent_to_spaces(self, indent):\n        \"\"\"Converts indentation to spaces respecting Vim settings.\"\"\"\n        indent = indent.expandtabs(self._tabstop)\n        right = (len(indent) - len(indent.rstrip(\" \"))) * \" \"\n        indent = indent.replace(\" \", \"\")\n        indent = indent.replace(\"\\t\", \" \" * self._tabstop)\n        return indent + right\n\n    def spaces_to_indent(self, indent):\n        \"\"\"Converts spaces to proper indentation respecting Vim settings.\"\"\"\n        if not self._expandtab:\n            indent = indent.replace(\" \" * self._tabstop, \"\\t\")\n        return indent\n"
  },
  {
    "path": "pythonx/UltiSnips/position.py",
    "content": "#!/usr/bin/env python3\n# encoding: utf-8\n\nfrom enum import Enum\n\n\nclass JumpDirection(Enum):\n    FORWARD = 1\n    BACKWARD = 2\n\n\nclass Position:\n    \"\"\"Represents a Position in a text file: (0 based line index, 0 based column\n    index) and provides methods for moving them around.\"\"\"\n\n    def __init__(self, line, col):\n        self.line = line\n        self.col = col\n\n    def move(self, pivot, delta):\n        \"\"\"'pivot' is the position of the first changed character, 'delta' is\n        how text after it moved.\"\"\"\n        if self < pivot:\n            return\n        if delta.line == 0:\n            if self.line == pivot.line:\n                self.col += delta.col\n        elif delta.line > 0:\n            if self.line == pivot.line:\n                self.col += delta.col - pivot.col\n            self.line += delta.line\n        else:\n            self.line += delta.line\n            if self.line == pivot.line:\n                self.col += -delta.col + pivot.col\n\n    def delta(self, pos):\n        \"\"\"Returns the difference that the cursor must move to come from 'pos'\n        to us.\"\"\"\n        assert isinstance(pos, Position)\n        if self.line == pos.line:\n            return Position(0, self.col - pos.col)\n        if self > pos:\n            return Position(self.line - pos.line, self.col)\n        return Position(self.line - pos.line, pos.col)\n\n    def __add__(self, pos):\n        assert isinstance(pos, Position)\n        return Position(self.line + pos.line, self.col + pos.col)\n\n    def __sub__(self, pos):\n        assert isinstance(pos, Position)\n        return Position(self.line - pos.line, self.col - pos.col)\n\n    def __eq__(self, other):\n        return (self.line, self.col) == (other.line, other.col)\n\n    def __ne__(self, other):\n        return (self.line, self.col) != (other.line, other.col)\n\n    def __lt__(self, other):\n        return (self.line, self.col) < (other.line, other.col)\n\n    def __le__(self, other):\n        return (self.line, self.col) <= (other.line, other.col)\n\n    def __repr__(self):\n        return \"(%i,%i)\" % (self.line, self.col)\n\n    def __getitem__(self, index):\n        if index > 1:\n            raise IndexError(\"position can be indexed only 0 (line) and 1 (column)\")\n        if index == 0:\n            return self.line\n        else:\n            return self.col\n"
  },
  {
    "path": "pythonx/UltiSnips/remote_pdb.py",
    "content": "import sys\nimport threading\nfrom bdb import BdbQuit\n\nfrom UltiSnips import vim_helper\n\n\nclass RemotePDB(object):\n    \"\"\"\n    Launch a pdb instance listening on (host, port).\n    Used to provide debug facilities you can access with netcat or telnet.\n    \"\"\"\n\n    singleton = None\n\n    def __init__(self, host, port):\n        self.host = host\n        self.port = port\n        self._pdb = None\n\n    def start_server(self):\n        \"\"\"\n        Create an instance of Pdb bound to a socket\n        \"\"\"\n        if self._pdb is not None:\n            return\n        import pdb\n        import socket\n\n        self.server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n        self.server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, True)\n        self.server.bind((self.host, self.port))\n        self.server.listen(1)\n        self.connection, address = self.server.accept()\n        io = self.connection.makefile(\"rw\")\n        parent = self\n\n        class Pdb(pdb.Pdb):\n            \"\"\"Patch quit to close the connection\"\"\"\n\n            def set_quit(self):\n                parent._shutdown()\n                super().set_quit()\n\n        self._pdb = Pdb(stdin=io, stdout=io)\n\n    def _pm(self, tb):\n        \"\"\"\n        Launch the server as post mortem on the currently handled exception\n        \"\"\"\n        try:\n            self._pdb.interaction(None, tb)\n        except:  # Ignore all exceptions part of debugger shutdown (and bugs... https://bugs.python.org/issue44461 )\n            pass\n\n    def set_trace(self, frame):\n        self._pdb.set_trace(frame)\n\n    def _shutdown(self):\n        if self._pdb is not None:\n            import socket\n\n            self.connection.shutdown(socket.SHUT_RDWR)\n            self.connection.close()\n            self.server.close()\n            self._pdb = None\n\n    @staticmethod\n    def get_host_port(host=None, port=None):\n        if host is None:\n            host = vim_helper.eval(\"g:UltiSnipsDebugHost\")\n        if port is None:\n            port = int(vim_helper.eval(\"g:UltiSnipsDebugPort\"))\n        return host, port\n\n    @staticmethod\n    def is_enable():\n        return bool(int(vim_helper.eval(\"g:UltiSnipsDebugServerEnable\")))\n\n    @staticmethod\n    def is_blocking():\n        return bool(int(vim_helper.eval(\"g:UltiSnipsPMDebugBlocking\")))\n\n    @classmethod\n    def _create(cls):\n        if cls.singleton is None:\n            cls.singleton = cls(*cls.get_host_port())\n\n    @classmethod\n    def breakpoint(cls, host=None, port=None):\n        if cls.singleton is None and not cls.is_enable():\n            return\n        cls._create()\n        cls.singleton.start_server()\n        cls.singleton.set_trace(sys._getframe().f_back)\n\n    @classmethod\n    def pm(cls):\n        \"\"\"\n        Launch the server as post mortem on the currently handled exception\n        \"\"\"\n        if cls.singleton is None and not cls.is_enable():\n            return\n        cls._create()\n        t, val, tb = sys.exc_info()\n\n        def _thread_run():\n            cls.singleton.start_server()\n            cls.singleton._pm(tb)\n\n        if cls.is_blocking():\n            _thread_run()\n        else:\n            thread = threading.Thread(target=_thread_run)\n            thread.start()\n"
  },
  {
    "path": "pythonx/UltiSnips/snippet/__init__.py",
    "content": "\"\"\"Code related to snippets.\"\"\"\n"
  },
  {
    "path": "pythonx/UltiSnips/snippet/definition/__init__.py",
    "content": "\"\"\"In memory representation of snippet definitions.\"\"\"\n\nfrom UltiSnips.snippet.definition.ulti_snips import UltiSnipsSnippetDefinition\nfrom UltiSnips.snippet.definition.snipmate import SnipMateSnippetDefinition\n"
  },
  {
    "path": "pythonx/UltiSnips/snippet/definition/base.py",
    "content": "#!/usr/bin/env python3\n# encoding: utf-8\n\n\"\"\"Snippet representation after parsing.\"\"\"\n\nimport re\n\nimport vim\nimport textwrap\n\nfrom UltiSnips import vim_helper\nfrom UltiSnips.error import PebkacError\nfrom UltiSnips.indent_util import IndentUtil\nfrom UltiSnips.position import Position\nfrom UltiSnips.text import escape\nfrom UltiSnips.text_objects import SnippetInstance\nfrom UltiSnips.text_objects.python_code import SnippetUtilForAction, cached_compile\n\n\n__WHITESPACE_SPLIT = re.compile(r\"\\s\")\n\n\nclass _SnippetUtilCursor:\n    def __init__(self, cursor):\n        self._cursor = [cursor[0] - 1, cursor[1]]\n        self._set = False\n\n    def preserve(self):\n        self._set = True\n        self._cursor = [vim_helper.buf.cursor[0], vim_helper.buf.cursor[1]]\n\n    def is_set(self):\n        return self._set\n\n    def set(self, line, column):\n        self.__setitem__(0, line)\n        self.__setitem__(1, column)\n\n    def to_vim_cursor(self):\n        return (self._cursor[0] + 1, self._cursor[1])\n\n    def __getitem__(self, index):\n        return self._cursor[index]\n\n    def __setitem__(self, index, value):\n        self._set = True\n        self._cursor[index] = value\n\n    def __len__(self):\n        return 2\n\n    def __str__(self):\n        return str((self._cursor[0], self._cursor[1]))\n\n\ndef split_at_whitespace(string):\n    \"\"\"Like string.split(), but keeps empty words as empty words.\"\"\"\n    return re.split(__WHITESPACE_SPLIT, string)\n\n\ndef _words_for_line(trigger, before, num_words=None):\n    \"\"\"Gets the final 'num_words' words from 'before'.\n\n    If num_words is None, then use the number of words in 'trigger'.\n\n    \"\"\"\n    if num_words is None:\n        num_words = len(split_at_whitespace(trigger))\n\n    word_list = split_at_whitespace(before)\n    if len(word_list) <= num_words:\n        return before.strip()\n    else:\n        before_words = before\n        for i in range(-1, -(num_words + 1), -1):\n            left = before_words.rfind(word_list[i])\n            before_words = before_words[:left]\n        return before[len(before_words) :].strip()\n\n\nclass SnippetDefinition:\n\n    \"\"\"Represents a snippet as parsed from a file.\"\"\"\n\n    _INDENT = re.compile(r\"^[ \\t]*\")\n    _TABS = re.compile(r\"^\\t*\")\n\n    def __init__(\n        self,\n        priority,\n        trigger,\n        value,\n        description,\n        options,\n        globals,\n        location,\n        context,\n        actions,\n    ):\n        self._priority = int(priority)\n        self._trigger = trigger\n        self._value = value\n        self._description = description\n        self._opts = options\n        self._matched = \"\"\n        self._last_re = None\n        self._globals = globals\n        self._compiled_globals = None\n        self._location = location\n\n        # Make sure that we actually match our trigger in case we are\n        # immediately expanded. At this point we don't take into\n        # account a any context code\n        self._context_code = None\n        self.matches(self._trigger)\n\n        self._context_code = context\n        if context:\n            self._compiled_context_code = cached_compile(\n                \"snip.context = \" + context, \"<context-code>\", \"exec\"\n            )\n        self._context = None\n        self._actions = actions or {}\n        self._compiled_actions = {\n            action: cached_compile(source, \"<action-code>\", \"exec\")\n            for action, source in self._actions.items()\n        }\n\n    def __repr__(self):\n        return \"_SnippetDefinition(%r,%s,%s,%s)\" % (\n            self._priority,\n            self._trigger,\n            self._description,\n            self._opts,\n        )\n\n    def _re_match(self, trigger):\n        \"\"\"Test if the current regex trigger matches `trigger`.\n\n        If so, set _last_re and _matched.\n\n        \"\"\"\n        for match in re.finditer(self._trigger, trigger):\n            if match.end() != len(trigger):\n                continue\n            else:\n                self._matched = trigger[match.start() : match.end()]\n\n            self._last_re = match\n            return match\n        return False\n\n    def _context_match(self, visual_content, before):\n        # skip on empty buffer\n        if len(vim.current.buffer) == 1 and vim.current.buffer[0] == \"\":\n            return\n\n        locals = {\n            \"context\": None,\n            \"visual_mode\": \"\",\n            \"visual_text\": \"\",\n            \"last_placeholder\": None,\n            \"before\": before,\n        }\n\n        if visual_content:\n            locals[\"visual_mode\"] = visual_content.mode\n            locals[\"visual_text\"] = visual_content.text\n            locals[\"last_placeholder\"] = visual_content.placeholder\n\n        return self._eval_code(\n            \"snip.context = \" + self._context_code, locals, self._compiled_context_code\n        ).context\n\n    def _eval_code(self, code, additional_locals={}, compiled_code=None):\n        current = vim.current\n\n        locals = {\n            \"window\": current.window,\n            \"buffer\": current.buffer,\n            \"line\": current.window.cursor[0] - 1,\n            \"column\": current.window.cursor[1] - 1,\n            \"cursor\": _SnippetUtilCursor(current.window.cursor),\n        }\n\n        locals.update(additional_locals)\n\n        snip = SnippetUtilForAction(locals)\n\n        try:\n            if self._compiled_globals is None:\n                self._precompile_globals()\n            glob = {\"snip\": snip, \"match\": self._last_re}\n            exec(self._compiled_globals, glob)\n            exec(compiled_code or code, glob)\n        except Exception as e:\n            code = \"\\n\".join(\n                [\n                    \"import re, os, vim, string, random\",\n                    \"\\n\".join(self._globals.get(\"!p\", [])).replace(\"\\r\\n\", \"\\n\"),\n                    code,\n                ]\n            )\n            self._make_debug_exception(e, code)\n            raise\n\n        return snip\n\n    def _execute_action(\n        self, action, context, additional_locals={}, compiled_action=None\n    ):\n        mark_to_use = \"`\"\n        with vim_helper.save_mark(mark_to_use):\n            vim_helper.set_mark_from_pos(mark_to_use, vim_helper.get_cursor_pos())\n\n            cursor_line_before = vim_helper.buf.line_till_cursor\n\n            locals = {\"context\": context}\n\n            locals.update(additional_locals)\n\n            snip = self._eval_code(action, locals, compiled_action)\n\n            if snip.cursor.is_set():\n                vim_helper.buf.cursor = Position(\n                    snip.cursor._cursor[0], snip.cursor._cursor[1]\n                )\n            else:\n                new_mark_pos = vim_helper.get_mark_pos(mark_to_use)\n\n                cursor_invalid = False\n\n                if vim_helper._is_pos_zero(new_mark_pos):\n                    cursor_invalid = True\n                else:\n                    vim_helper.set_cursor_from_pos(new_mark_pos)\n                    if cursor_line_before != vim_helper.buf.line_till_cursor:\n                        cursor_invalid = True\n\n                if cursor_invalid:\n                    raise PebkacError(\n                        \"line under the cursor was modified, but \"\n                        + '\"snip.cursor\" variable is not set; either set set '\n                        + '\"snip.cursor\" to new cursor position, or do not '\n                        + \"modify cursor line\"\n                    )\n\n        return snip\n\n    def _make_debug_exception(self, e, code=\"\"):\n        e.snippet_info = textwrap.dedent(\n            \"\"\"\n            Defined in: {}\n            Trigger: {}\n            Description: {}\n            Context: {}\n            Pre-expand: {}\n            Post-expand: {}\n        \"\"\"\n        ).format(\n            self._location,\n            self._trigger,\n            self._description,\n            self._context_code if self._context_code else \"<none>\",\n            self._actions[\"pre_expand\"] if \"pre_expand\" in self._actions else \"<none>\",\n            self._actions[\"post_expand\"]\n            if \"post_expand\" in self._actions\n            else \"<none>\",\n            code,\n        )\n\n        e.snippet_code = code\n\n    def _precompile_globals(self):\n        self._compiled_globals = cached_compile(\n            \"\\n\".join(\n                [\n                    \"import re, os, vim, string, random\",\n                    \"\\n\".join(self._globals.get(\"!p\", [])).replace(\"\\r\\n\", \"\\n\"),\n                ]\n            ),\n            \"<global-snippets>\",\n            \"exec\",\n        )\n\n    def has_option(self, opt):\n        \"\"\"Check if the named option is set.\"\"\"\n        return opt in self._opts\n\n    @property\n    def description(self):\n        \"\"\"Descriptive text for this snippet.\"\"\"\n        return (\"(%s) %s\" % (self._trigger, self._description)).strip()\n\n    @property\n    def priority(self):\n        \"\"\"The snippets priority, which defines which snippet will be preferred\n        over others with the same trigger.\"\"\"\n        return self._priority\n\n    @property\n    def trigger(self):\n        \"\"\"The trigger text for the snippet.\"\"\"\n        return self._trigger\n\n    @property\n    def matched(self):\n        \"\"\"The last text that matched this snippet in match() or\n        could_match().\"\"\"\n        return self._matched\n\n    @property\n    def location(self):\n        \"\"\"Where this snippet was defined.\"\"\"\n        return self._location\n\n    @property\n    def context(self):\n        \"\"\"The matched context.\"\"\"\n        return self._context\n\n    def matches(self, before, visual_content=None):\n        \"\"\"Returns True if this snippet matches 'before'.\"\"\"\n        # If user supplies both \"w\" and \"i\", it should perhaps be an\n        # error, but if permitted it seems that \"w\" should take precedence\n        # (since matching at word boundary and within a word == matching at word\n        # boundary).\n        self._matched = \"\"\n\n        words = _words_for_line(self._trigger, before)\n\n        if \"r\" in self._opts:\n            try:\n                match = self._re_match(before)\n            except Exception as e:\n                self._make_debug_exception(e)\n                raise\n\n        elif \"w\" in self._opts:\n            words_len = len(self._trigger)\n            words_prefix = words[:-words_len]\n            words_suffix = words[-words_len:]\n            match = words_suffix == self._trigger\n            if match and words_prefix:\n                # Require a word boundary between prefix and suffix.\n                boundary_chars = escape(words_prefix[-1:] + words_suffix[:1], r\"\\\"\")\n                match = vim_helper.eval('\"%s\" =~# \"\\\\\\\\v.<.\"' % boundary_chars) != \"0\"\n        elif \"i\" in self._opts:\n            match = words.endswith(self._trigger)\n        else:\n            match = words == self._trigger\n\n        # By default, we match the whole trigger\n        if match and not self._matched:\n            self._matched = self._trigger\n\n        # Ensure the match was on a word boundry if needed\n        if \"b\" in self._opts and match:\n            text_before = before.rstrip()[: -len(self._matched)]\n            if text_before.strip(\" \\t\") != \"\":\n                self._matched = \"\"\n                return False\n\n        self._context = None\n        if match and self._context_code:\n            self._context = self._context_match(visual_content, before)\n            if not self.context:\n                match = False\n\n        return match\n\n    def could_match(self, before):\n        \"\"\"Return True if this snippet could match the (partial) 'before'.\"\"\"\n        self._matched = \"\"\n\n        # List all on whitespace.\n        if before and before[-1] in (\" \", \"\\t\"):\n            before = \"\"\n        if before and before.rstrip() is not before:\n            return False\n\n        words = _words_for_line(self._trigger, before)\n\n        if \"r\" in self._opts:\n            # Test for full match only\n            match = self._re_match(before)\n        elif \"w\" in self._opts:\n            # Trim non-empty prefix up to word boundary, if present.\n            qwords = escape(words, r\"\\\"\")\n            words_suffix = vim_helper.eval(\n                'substitute(\"%s\", \"\\\\\\\\v^.+<(.+)\", \"\\\\\\\\1\", \"\")' % qwords\n            )\n            match = self._trigger.startswith(words_suffix)\n            self._matched = words_suffix\n\n            # TODO: list_snippets() function cannot handle partial-trigger\n            # matches yet, so for now fail if we trimmed the prefix.\n            if words_suffix != words:\n                match = False\n        elif \"i\" in self._opts:\n            # TODO: It is hard to define when a inword snippet could match,\n            # therefore we check only for full-word trigger.\n            match = self._trigger.startswith(words)\n        else:\n            match = self._trigger.startswith(words)\n\n        # By default, we match the words from the trigger\n        if match and not self._matched:\n            self._matched = words\n\n        # Ensure the match was on a word boundry if needed\n        if \"b\" in self._opts and match:\n            text_before = before.rstrip()[: -len(self._matched)]\n            if text_before.strip(\" \\t\") != \"\":\n                self._matched = \"\"\n                return False\n\n        return match\n\n    def instantiate(self, snippet_instance, initial_text, indent):\n        \"\"\"Parses the content of this snippet and brings the corresponding text\n        objects alive inside of Vim.\"\"\"\n        raise NotImplementedError()\n\n    def do_pre_expand(self, visual_content, snippets_stack):\n        if \"pre_expand\" in self._actions:\n            locals = {\"buffer\": vim_helper.buf, \"visual_content\": visual_content}\n\n            snip = self._execute_action(\n                self._actions[\"pre_expand\"],\n                self._context,\n                locals,\n                self._compiled_actions[\"pre_expand\"],\n            )\n            self._context = snip.context\n            return snip.cursor.is_set()\n        else:\n            return False\n\n    def do_post_expand(self, start, end, snippets_stack):\n        if \"post_expand\" in self._actions:\n            locals = {\n                \"snippet_start\": start,\n                \"snippet_end\": end,\n                \"buffer\": vim_helper.buf,\n            }\n\n            snip = self._execute_action(\n                self._actions[\"post_expand\"],\n                snippets_stack[-1].context,\n                locals,\n                self._compiled_actions[\"post_expand\"],\n            )\n\n            snippets_stack[-1].context = snip.context\n\n            return snip.cursor.is_set()\n        else:\n            return False\n\n    def do_post_jump(\n        self, tabstop_number, jump_direction, snippets_stack, current_snippet\n    ):\n        if \"post_jump\" in self._actions:\n            start = current_snippet.start\n            end = current_snippet.end\n\n            locals = {\n                \"tabstop\": tabstop_number,\n                \"jump_direction\": jump_direction,\n                \"tabstops\": current_snippet.get_tabstops(),\n                \"snippet_start\": start,\n                \"snippet_end\": end,\n                \"buffer\": vim_helper.buf,\n            }\n\n            snip = self._execute_action(\n                self._actions[\"post_jump\"],\n                current_snippet.context,\n                locals,\n                self._compiled_actions[\"post_jump\"],\n            )\n\n            current_snippet.context = snip.context\n\n            return snip.cursor.is_set()\n        else:\n            return False\n\n    def launch(self, text_before, visual_content, parent, start, end):\n        \"\"\"Launch this snippet, overwriting the text 'start' to 'end' and\n        keeping the 'text_before' on the launch line.\n\n        'Parent' is the parent snippet instance if any.\n\n        \"\"\"\n        indent = self._INDENT.match(text_before).group(0)\n        lines = (self._value + \"\\n\").splitlines()\n        ind_util = IndentUtil()\n\n        # Replace leading tabs in the snippet definition via proper indenting\n        initial_text = []\n        for line_num, line in enumerate(lines):\n            if \"t\" in self._opts:\n                tabs = 0\n            else:\n                tabs = len(self._TABS.match(line).group(0))\n            line_ind = ind_util.ntabs_to_proper_indent(tabs)\n            if line_num != 0:\n                line_ind = indent + line_ind\n\n            result_line = line_ind + line[tabs:]\n            if \"m\" in self._opts:\n                result_line = result_line.rstrip()\n            initial_text.append(result_line)\n        initial_text = \"\\n\".join(initial_text)\n\n        if self._compiled_globals is None:\n            self._precompile_globals()\n        snippet_instance = SnippetInstance(\n            self,\n            parent,\n            initial_text,\n            start,\n            end,\n            visual_content,\n            last_re=self._last_re,\n            globals=self._globals,\n            context=self._context,\n            _compiled_globals=self._compiled_globals,\n        )\n        self.instantiate(snippet_instance, initial_text, indent)\n        snippet_instance.replace_initial_text(vim_helper.buf)\n        snippet_instance.update_textobjects(vim_helper.buf)\n        return snippet_instance\n"
  },
  {
    "path": "pythonx/UltiSnips/snippet/definition/snipmate.py",
    "content": "#!/usr/bin/env python3\n# encoding: utf-8\n\n\"\"\"A snipMate snippet after parsing.\"\"\"\n\nfrom UltiSnips.snippet.definition.base import SnippetDefinition\nfrom UltiSnips.snippet.parsing.snipmate import parse_and_instantiate\n\n\nclass SnipMateSnippetDefinition(SnippetDefinition):\n\n    \"\"\"See module doc.\"\"\"\n\n    SNIPMATE_SNIPPET_PRIORITY = -1000\n\n    def __init__(self, trigger, value, description, location):\n        SnippetDefinition.__init__(\n            self,\n            self.SNIPMATE_SNIPPET_PRIORITY,\n            trigger,\n            value,\n            description,\n            \"w\",\n            {},\n            location,\n            None,\n            {},\n        )\n\n    def instantiate(self, snippet_instance, initial_text, indent):\n        parse_and_instantiate(snippet_instance, initial_text, indent)\n"
  },
  {
    "path": "pythonx/UltiSnips/snippet/definition/ulti_snips.py",
    "content": "#!/usr/bin/env python3\n# encoding: utf-8\n\n\"\"\"A UltiSnips snippet after parsing.\"\"\"\n\nfrom UltiSnips.snippet.definition.base import SnippetDefinition\nfrom UltiSnips.snippet.parsing.ulti_snips import parse_and_instantiate\n\n\nclass UltiSnipsSnippetDefinition(SnippetDefinition):\n\n    \"\"\"See module doc.\"\"\"\n\n    def instantiate(self, snippet_instance, initial_text, indent):\n        return parse_and_instantiate(snippet_instance, initial_text, indent)\n"
  },
  {
    "path": "pythonx/UltiSnips/snippet/parsing/__init__.py",
    "content": "\"\"\"Code related to turning text into snippets.\"\"\"\n"
  },
  {
    "path": "pythonx/UltiSnips/snippet/parsing/base.py",
    "content": "#!/usr/bin/env python3\n# encoding: utf-8\n\n\"\"\"Common functionality of the snippet parsing codes.\"\"\"\n\nfrom UltiSnips.position import Position\nfrom UltiSnips.snippet.parsing.lexer import tokenize, TabStopToken\nfrom UltiSnips.text_objects import TabStop\n\nfrom UltiSnips.text_objects import Mirror\nfrom UltiSnips.snippet.parsing.lexer import MirrorToken\n\n\ndef resolve_ambiguity(all_tokens, seen_ts):\n    \"\"\"$1 could be a Mirror or a TabStop.\n\n    This figures this out.\n\n    \"\"\"\n    for parent, token in all_tokens:\n        if isinstance(token, MirrorToken):\n            if token.number not in seen_ts:\n                seen_ts[token.number] = TabStop(parent, token)\n            else:\n                Mirror(parent, seen_ts[token.number], token)\n\n\ndef tokenize_snippet_text(\n    snippet_instance,\n    text,\n    indent,\n    allowed_tokens_in_text,\n    allowed_tokens_in_tabstops,\n    token_to_textobject,\n):\n    \"\"\"Turns 'text' into a stream of tokens and creates the text objects from\n    those tokens that are mentioned in 'token_to_textobject' assuming the\n    current 'indent'.\n\n    The 'allowed_tokens_in_text' define which tokens will be recognized\n    in 'text' while 'allowed_tokens_in_tabstops' are the tokens that\n    will be recognized in TabStop placeholder text.\n\n    \"\"\"\n    seen_ts = {}\n    all_tokens = []\n\n    def _do_parse(parent, text, allowed_tokens):\n        \"\"\"Recursive function that actually creates the objects.\"\"\"\n        tokens = list(tokenize(text, indent, parent.start, allowed_tokens))\n        for token in tokens:\n            all_tokens.append((parent, token))\n            if isinstance(token, TabStopToken):\n                ts = TabStop(parent, token)\n                seen_ts[token.number] = ts\n                _do_parse(ts, token.initial_text, allowed_tokens_in_tabstops)\n            else:\n                klass = token_to_textobject.get(token.__class__, None)\n                if klass is not None:\n                    text_object = klass(parent, token)\n\n                    # TabStop has some subclasses (e.g. Choices)\n                    if isinstance(text_object, TabStop):\n                        seen_ts[text_object.number] = text_object\n\n    _do_parse(snippet_instance, text, allowed_tokens_in_text)\n    return all_tokens, seen_ts\n\n\ndef finalize(all_tokens, seen_ts, snippet_instance):\n    \"\"\"Adds a tabstop 0 if non is in 'seen_ts' and brings the text of the\n    snippet instance into Vim.\"\"\"\n    if 0 not in seen_ts:\n        mark = all_tokens[-1][1].end  # Last token is always EndOfText\n        m1 = Position(mark.line, mark.col)\n        TabStop(snippet_instance, 0, mark, m1)\n"
  },
  {
    "path": "pythonx/UltiSnips/snippet/parsing/lexer.py",
    "content": "#!/usr/bin/env python3\n# encoding: utf-8\n\n\"\"\"Not really a lexer in the classical sense, but code to convert snippet\ndefinitions into logical units called Tokens.\"\"\"\n\nimport string\nimport re\n\nfrom UltiSnips.error import PebkacError\nfrom UltiSnips.position import Position\nfrom UltiSnips.text import unescape\n\n\nclass _TextIterator:\n\n    \"\"\"Helper class to make iterating over text easier.\"\"\"\n\n    def __init__(self, text, offset):\n        self._text = text\n        self._line = offset.line\n        self._col = offset.col\n\n        self._idx = 0\n\n    def __iter__(self):\n        \"\"\"Iterator interface.\"\"\"\n        return self\n\n    def __next__(self):\n        \"\"\"Returns the next character.\"\"\"\n        if self._idx >= len(self._text):\n            raise StopIteration\n\n        rv = self._text[self._idx]\n        if self._text[self._idx] in (\"\\n\", \"\\r\\n\"):\n            self._line += 1\n            self._col = 0\n        else:\n            self._col += 1\n        self._idx += 1\n        return rv\n\n    def peek(self, count=1):\n        \"\"\"Returns the next 'count' characters without advancing the stream.\"\"\"\n        if count > 1:  # This might return '' if nothing is found\n            return self._text[self._idx : self._idx + count]\n        try:\n            return self._text[self._idx]\n        except IndexError:\n            return None\n\n    @property\n    def pos(self):\n        \"\"\"Current position in the text.\"\"\"\n        return Position(self._line, self._col)\n\n\ndef _parse_number(stream):\n    \"\"\"Expects the stream to contain a number next, returns the number without\n    consuming any more bytes.\"\"\"\n    rv = \"\"\n    while stream.peek() and stream.peek() in string.digits:\n        rv += next(stream)\n\n    return int(rv)\n\n\ndef _parse_till_closing_brace(stream):\n    \"\"\"\n    Returns all chars till a non-escaped } is found. Other\n    non escaped { are taken into account and skipped over.\n\n    Will also consume the closing }, but not return it\n    \"\"\"\n    rv = \"\"\n    in_braces = 1\n    while True:\n        if EscapeCharToken.starts_here(stream, \"\\\\{}\"):\n            rv += next(stream) + next(stream)\n        else:\n            char = next(stream)\n            if char == \"{\":\n                in_braces += 1\n            elif char == \"}\":\n                in_braces -= 1\n            if in_braces == 0:\n                break\n            rv += char\n    return rv\n\n\ndef _parse_till_unescaped_char(stream, chars):\n    \"\"\"\n    Returns all chars till a non-escaped char is found.\n\n    Will also consume the closing char, but and return it as second\n    return value\n    \"\"\"\n    rv = \"\"\n    while True:\n        escaped = False\n        for char in chars:\n            if EscapeCharToken.starts_here(stream, char):\n                rv += next(stream) + next(stream)\n                escaped = True\n        if not escaped:\n            char = next(stream)\n            if char in chars:\n                break\n            rv += char\n    return rv, char\n\n\nclass Token:\n\n    \"\"\"Represents a Token as parsed from a snippet definition.\"\"\"\n\n    def __init__(self, gen, indent):\n        self.initial_text = \"\"\n        self.start = gen.pos\n        self._parse(gen, indent)\n        self.end = gen.pos\n\n    def _parse(self, stream, indent):\n        \"\"\"Parses the token from 'stream' with the current 'indent'.\"\"\"\n        pass  # Does nothing\n\n\nclass TabStopToken(Token):\n\n    \"\"\"${1:blub}\"\"\"\n\n    CHECK = re.compile(r\"^\\${\\d+[:}]\")\n\n    @classmethod\n    def starts_here(cls, stream):\n        \"\"\"Returns true if this token starts at the current position in\n        'stream'.\"\"\"\n        return cls.CHECK.match(stream.peek(10)) is not None\n\n    def _parse(self, stream, indent):\n        next(stream)  # $\n        next(stream)  # {\n\n        self.number = _parse_number(stream)\n\n        if stream.peek() == \":\":\n            next(stream)\n        self.initial_text = _parse_till_closing_brace(stream)\n\n    def __repr__(self):\n        return \"TabStopToken(%r,%r,%r,%r)\" % (\n            self.start,\n            self.end,\n            self.number,\n            self.initial_text,\n        )\n\n\nclass VisualToken(Token):\n\n    \"\"\"${VISUAL}\"\"\"\n\n    CHECK = re.compile(r\"^\\${VISUAL[:}/]\")\n\n    @classmethod\n    def starts_here(cls, stream):\n        \"\"\"Returns true if this token starts at the current position in\n        'stream'.\"\"\"\n        return cls.CHECK.match(stream.peek(10)) is not None\n\n    def _parse(self, stream, indent):\n        for _ in range(8):  # ${VISUAL\n            next(stream)\n\n        if stream.peek() == \":\":\n            next(stream)\n        self.alternative_text, char = _parse_till_unescaped_char(stream, \"/}\")\n        self.alternative_text = unescape(self.alternative_text)\n\n        if char == \"/\":  # Transformation going on\n            try:\n                self.search = _parse_till_unescaped_char(stream, \"/\")[0]\n                self.replace = _parse_till_unescaped_char(stream, \"/\")[0]\n                self.options = _parse_till_closing_brace(stream)\n            except StopIteration:\n                raise PebkacError(\n                    \"Invalid ${VISUAL} transformation! Forgot to escape a '/'?\"\n                )\n        else:\n            self.search = None\n            self.replace = None\n            self.options = None\n\n    def __repr__(self):\n        return \"VisualToken(%r,%r)\" % (self.start, self.end)\n\n\nclass TransformationToken(Token):\n\n    \"\"\"${1/match/replace/options}\"\"\"\n\n    CHECK = re.compile(r\"^\\${\\d+\\/\")\n\n    @classmethod\n    def starts_here(cls, stream):\n        \"\"\"Returns true if this token starts at the current position in\n        'stream'.\"\"\"\n        return cls.CHECK.match(stream.peek(10)) is not None\n\n    def _parse(self, stream, indent):\n        next(stream)  # $\n        next(stream)  # {\n\n        self.number = _parse_number(stream)\n\n        next(stream)  # /\n\n        self.search = _parse_till_unescaped_char(stream, \"/\")[0]\n        self.replace = _parse_till_unescaped_char(stream, \"/\")[0]\n        self.options = _parse_till_closing_brace(stream)\n\n    def __repr__(self):\n        return \"TransformationToken(%r,%r,%r,%r,%r)\" % (\n            self.start,\n            self.end,\n            self.number,\n            self.search,\n            self.replace,\n        )\n\n\nclass MirrorToken(Token):\n\n    \"\"\"$1.\"\"\"\n\n    CHECK = re.compile(r\"^\\$\\d+\")\n\n    @classmethod\n    def starts_here(cls, stream):\n        \"\"\"Returns true if this token starts at the current position in\n        'stream'.\"\"\"\n        return cls.CHECK.match(stream.peek(10)) is not None\n\n    def _parse(self, stream, indent):\n        next(stream)  # $\n        self.number = _parse_number(stream)\n\n    def __repr__(self):\n        return \"MirrorToken(%r,%r,%r)\" % (self.start, self.end, self.number)\n\n\nclass ChoicesToken(Token):\n\n    \"\"\"${1|o1,o2,o3|}\n    P.S. This is not a subclass of TabStop,\n         so its content will not be parsed recursively.\n    \"\"\"\n\n    CHECK = re.compile(r\"^\\${\\d+\\|\")\n\n    @classmethod\n    def starts_here(cls, stream):\n        \"\"\"Returns true if this token starts at the current position in\n        'stream'.\"\"\"\n        return cls.CHECK.match(stream.peek(10)) is not None\n\n    def _parse(self, stream, indent):\n        next(stream)  # $\n        next(stream)  # {\n\n        self.number = _parse_number(stream)\n\n        if self.number == 0:\n            raise PebkacError(\"Choices selection is not supported on $0\")\n\n        next(stream)  # |\n\n        choices_text = _parse_till_unescaped_char(stream, \"|\")[0]\n\n        choice_list = []\n        # inside choice item, comma can be escaped by \"\\,\"\n        # we need to do a little bit smarter parsing than simply splitting\n        choice_stream = _TextIterator(choices_text, Position(0, 0))\n        while True:\n            cur_col = choice_stream.pos.col\n            try:\n                result = _parse_till_unescaped_char(choice_stream, \",\")[0]\n                if not result:\n                    continue\n                choice_list.append(self._get_unescaped_choice_item(result))\n            except:\n                last_choice_item = self._get_unescaped_choice_item(\n                    choices_text[cur_col:]\n                )\n                if last_choice_item:\n                    choice_list.append(last_choice_item)\n                break\n        self.choice_list = choice_list\n        self.initial_text = \"|{0}|\".format(\",\".join(choice_list))\n\n        _parse_till_closing_brace(stream)\n\n    def _get_unescaped_choice_item(self, escaped_choice_item):\n        \"\"\"unescape common inside choice item\"\"\"\n        return escaped_choice_item.replace(r\"\\,\", \",\")\n\n    def __repr__(self):\n        return \"ChoicesToken(%r,%r,%r,|%r|)\" % (\n            self.start,\n            self.end,\n            self.number,\n            self.initial_text,\n        )\n\n\nclass EscapeCharToken(Token):\n\n    \"\"\"\\\\n.\"\"\"\n\n    @classmethod\n    def starts_here(cls, stream, chars=r\"{}\\$`\"):\n        \"\"\"Returns true if this token starts at the current position in\n        'stream'.\"\"\"\n        cs = stream.peek(2)\n        if len(cs) == 2 and cs[0] == \"\\\\\" and cs[1] in chars:\n            return True\n\n    def _parse(self, stream, indent):\n        next(stream)  # \\\n        self.initial_text = next(stream)\n\n    def __repr__(self):\n        return \"EscapeCharToken(%r,%r,%r)\" % (self.start, self.end, self.initial_text)\n\n\nclass ShellCodeToken(Token):\n\n    \"\"\"`echo \"hi\"`\"\"\"\n\n    @classmethod\n    def starts_here(cls, stream):\n        \"\"\"Returns true if this token starts at the current position in\n        'stream'.\"\"\"\n        return stream.peek(1) == \"`\"\n\n    def _parse(self, stream, indent):\n        next(stream)  # `\n        self.code = _parse_till_unescaped_char(stream, \"`\")[0]\n\n    def __repr__(self):\n        return \"ShellCodeToken(%r,%r,%r)\" % (self.start, self.end, self.code)\n\n\nclass PythonCodeToken(Token):\n\n    \"\"\"`!p snip.rv = \"Hi\"`\"\"\"\n\n    CHECK = re.compile(r\"^`!p\\s\")\n\n    @classmethod\n    def starts_here(cls, stream):\n        \"\"\"Returns true if this token starts at the current position in\n        'stream'.\"\"\"\n        return cls.CHECK.match(stream.peek(4)) is not None\n\n    def _parse(self, stream, indent):\n        for _ in range(3):\n            next(stream)  # `!p\n        if stream.peek() in \"\\t \":\n            next(stream)\n\n        code = _parse_till_unescaped_char(stream, \"`\")[0]\n\n        # Strip the indent if any\n        if len(indent):\n            lines = code.splitlines()\n            self.code = lines[0] + \"\\n\"\n            self.code += \"\\n\".join([l[len(indent) :] for l in lines[1:]])\n        else:\n            self.code = code\n        self.indent = indent\n\n    def __repr__(self):\n        return \"PythonCodeToken(%r,%r,%r)\" % (self.start, self.end, self.code)\n\n\nclass VimLCodeToken(Token):\n\n    \"\"\"`!v g:hi`\"\"\"\n\n    CHECK = re.compile(r\"^`!v\\s\")\n\n    @classmethod\n    def starts_here(cls, stream):\n        \"\"\"Returns true if this token starts at the current position in\n        'stream'.\"\"\"\n        return cls.CHECK.match(stream.peek(4)) is not None\n\n    def _parse(self, stream, indent):\n        for _ in range(4):\n            next(stream)  # `!v\n        self.code = _parse_till_unescaped_char(stream, \"`\")[0]\n\n    def __repr__(self):\n        return \"VimLCodeToken(%r,%r,%r)\" % (self.start, self.end, self.code)\n\n\nclass EndOfTextToken(Token):\n\n    \"\"\"Appears at the end of the text.\"\"\"\n\n    def __repr__(self):\n        return \"EndOfText(%r)\" % self.end\n\n\ndef tokenize(text, indent, offset, allowed_tokens):\n    \"\"\"Returns an iterator of tokens of 'text'['offset':] which is assumed to\n    have 'indent' as the whitespace of the begging of the lines. Only\n    'allowed_tokens' are considered to be valid tokens.\"\"\"\n    stream = _TextIterator(text, offset)\n    try:\n        while True:\n            done_something = False\n            for token in allowed_tokens:\n                if token.starts_here(stream):\n                    yield token(stream, indent)\n                    done_something = True\n                    break\n            if not done_something:\n                next(stream)\n    except StopIteration:\n        yield EndOfTextToken(stream, indent)\n"
  },
  {
    "path": "pythonx/UltiSnips/snippet/parsing/snipmate.py",
    "content": "#!/usr/bin/env python3\n# encoding: utf-8\n\n\"\"\"Parses a snipMate snippet definition and launches it into Vim.\"\"\"\n\nfrom UltiSnips.snippet.parsing.base import (\n    tokenize_snippet_text,\n    finalize,\n    resolve_ambiguity,\n)\nfrom UltiSnips.snippet.parsing.lexer import (\n    EscapeCharToken,\n    VisualToken,\n    TabStopToken,\n    MirrorToken,\n    ShellCodeToken,\n)\nfrom UltiSnips.text_objects import EscapedChar, Mirror, VimLCode, Visual\n\n_TOKEN_TO_TEXTOBJECT = {\n    EscapeCharToken: EscapedChar,\n    VisualToken: Visual,\n    ShellCodeToken: VimLCode,  # `` is VimL in snipMate\n}\n\n__ALLOWED_TOKENS = [\n    EscapeCharToken,\n    VisualToken,\n    TabStopToken,\n    MirrorToken,\n    ShellCodeToken,\n]\n\n__ALLOWED_TOKENS_IN_TABSTOPS = [\n    EscapeCharToken,\n    VisualToken,\n    MirrorToken,\n    ShellCodeToken,\n]\n\n\ndef parse_and_instantiate(parent_to, text, indent):\n    \"\"\"Parses a snippet definition in snipMate format from 'text' assuming the\n    current 'indent'.\n\n    Will instantiate all the objects and link them as children to\n    parent_to. Will also put the initial text into Vim.\n\n    \"\"\"\n    all_tokens, seen_ts = tokenize_snippet_text(\n        parent_to,\n        text,\n        indent,\n        __ALLOWED_TOKENS,\n        __ALLOWED_TOKENS_IN_TABSTOPS,\n        _TOKEN_TO_TEXTOBJECT,\n    )\n    resolve_ambiguity(all_tokens, seen_ts)\n    finalize(all_tokens, seen_ts, parent_to)\n"
  },
  {
    "path": "pythonx/UltiSnips/snippet/parsing/ulti_snips.py",
    "content": "#!/usr/bin/env python3\n# encoding: utf-8\n\n\"\"\"Parses a UltiSnips snippet definition and launches it into Vim.\"\"\"\n\nfrom UltiSnips.snippet.parsing.base import (\n    tokenize_snippet_text,\n    finalize,\n    resolve_ambiguity,\n)\nfrom UltiSnips.snippet.parsing.lexer import (\n    EscapeCharToken,\n    VisualToken,\n    TransformationToken,\n    ChoicesToken,\n    TabStopToken,\n    MirrorToken,\n    PythonCodeToken,\n    VimLCodeToken,\n    ShellCodeToken,\n)\nfrom UltiSnips.text_objects import (\n    EscapedChar,\n    Mirror,\n    PythonCode,\n    ShellCode,\n    TabStop,\n    Transformation,\n    VimLCode,\n    Visual,\n    Choices,\n)\nfrom UltiSnips.error import PebkacError\n\n_TOKEN_TO_TEXTOBJECT = {\n    EscapeCharToken: EscapedChar,\n    VisualToken: Visual,\n    ShellCodeToken: ShellCode,\n    PythonCodeToken: PythonCode,\n    VimLCodeToken: VimLCode,\n    ChoicesToken: Choices,\n}\n\n__ALLOWED_TOKENS = [\n    EscapeCharToken,\n    VisualToken,\n    TransformationToken,\n    ChoicesToken,\n    TabStopToken,\n    MirrorToken,\n    PythonCodeToken,\n    VimLCodeToken,\n    ShellCodeToken,\n]\n\n\ndef _create_transformations(all_tokens, seen_ts):\n    \"\"\"Create the objects that need to know about tabstops.\"\"\"\n    for parent, token in all_tokens:\n        if isinstance(token, TransformationToken):\n            if token.number not in seen_ts:\n                raise PebkacError(\n                    \"Tabstop %i is not known but is used by a Transformation\"\n                    % token.number\n                )\n            Transformation(parent, seen_ts[token.number], token)\n\n\ndef parse_and_instantiate(parent_to, text, indent):\n    \"\"\"Parses a snippet definition in UltiSnips format from 'text' assuming the\n    current 'indent'.\n\n    Will instantiate all the objects and link them as children to\n    parent_to. Will also put the initial text into Vim.\n\n    \"\"\"\n    all_tokens, seen_ts = tokenize_snippet_text(\n        parent_to,\n        text,\n        indent,\n        __ALLOWED_TOKENS,\n        __ALLOWED_TOKENS,\n        _TOKEN_TO_TEXTOBJECT,\n    )\n    resolve_ambiguity(all_tokens, seen_ts)\n    _create_transformations(all_tokens, seen_ts)\n    finalize(all_tokens, seen_ts, parent_to)\n"
  },
  {
    "path": "pythonx/UltiSnips/snippet/source/__init__.py",
    "content": "#!/usr/bin/env python3\n# encoding: utf-8\n\n\"\"\"Sources of snippet definitions.\"\"\"\n\nfrom UltiSnips.snippet.source.base import SnippetSource\nfrom UltiSnips.snippet.source.added import AddedSnippetsSource\nfrom UltiSnips.snippet.source.file.snipmate import SnipMateFileSource\nfrom UltiSnips.snippet.source.file.ulti_snips import (\n    UltiSnipsFileSource,\n    find_all_snippet_directories,\n    find_all_snippet_files,\n    find_snippet_files,\n)\n"
  },
  {
    "path": "pythonx/UltiSnips/snippet/source/added.py",
    "content": "#!/usr/bin/env python3\n# encoding: utf-8\n\n\"\"\"Handles manually added snippets UltiSnips_Manager.add_snippet().\"\"\"\n\nfrom UltiSnips.snippet.source.base import SnippetSource\n\n\nclass AddedSnippetsSource(SnippetSource):\n\n    \"\"\"See module docstring.\"\"\"\n\n    def add_snippet(self, ft, snippet):\n        \"\"\"Adds the given 'snippet' for 'ft'.\"\"\"\n        self._snippets[ft].add_snippet(snippet)\n"
  },
  {
    "path": "pythonx/UltiSnips/snippet/source/base.py",
    "content": "#!/usr/bin/env python3\n# encoding: utf-8\n\n\"\"\"Base class for snippet sources.\"\"\"\n\nfrom collections import defaultdict\n\nfrom UltiSnips.snippet.source.snippet_dictionary import SnippetDictionary\n\n\nclass SnippetSource:\n\n    \"\"\"See module docstring.\"\"\"\n\n    def __init__(self):\n        self._snippets = defaultdict(SnippetDictionary)\n        self._extends = defaultdict(set)\n        self.must_ensure = True\n\n    def ensure(self, filetypes):\n        \"\"\"Ensures that snippets are loaded.\"\"\"\n\n    def refresh(self):\n        \"\"\"Resets all snippets, so that they are reloaded on the next call to\n        ensure.\n        \"\"\"\n\n    def _get_existing_deep_extends(self, base_filetypes):\n        \"\"\"Helper for get all existing filetypes extended by base filetypes.\"\"\"\n        deep_extends = self.get_deep_extends(base_filetypes)\n        return [ft for ft in deep_extends if ft in self._snippets]\n\n    def get_snippets(\n        self, filetypes, before, possible, autotrigger_only, visual_content\n    ):\n        \"\"\"Returns the snippets for all 'filetypes' (in order) and their\n        parents matching the text 'before'. If 'possible' is true, a partial\n        match is enough. Base classes can override this method to provide means\n        of creating snippets on the fly.\n\n        Returns a list of SnippetDefinition s.\n\n        \"\"\"\n        result = []\n        for ft in self._get_existing_deep_extends(filetypes):\n            snips = self._snippets[ft]\n            result.extend(\n                snips.get_matching_snippets(\n                    before, possible, autotrigger_only, visual_content\n                )\n            )\n        return result\n\n    def get_clear_priority(self, filetypes):\n        \"\"\"Get maximum clearsnippets priority without arguments for specified\n        filetypes, if any.\n\n        It returns None if there are no clearsnippets.\n\n        \"\"\"\n        pri = None\n        for ft in self._get_existing_deep_extends(filetypes):\n            snippets = self._snippets[ft]\n            if pri is None or snippets._clear_priority > pri:\n                pri = snippets._clear_priority\n        return pri\n\n    def get_cleared(self, filetypes):\n        \"\"\"Get a set of cleared snippets marked by clearsnippets with arguments\n        for specified filetypes.\"\"\"\n        cleared = {}\n        for ft in self._get_existing_deep_extends(filetypes):\n            snippets = self._snippets[ft]\n            for key, value in snippets._cleared.items():\n                if key not in cleared or value > cleared[key]:\n                    cleared[key] = value\n        return cleared\n\n    def update_extends(self, child_ft, parent_fts):\n        \"\"\"Update the extending relation by given child filetype and its parent\n        filetypes.\"\"\"\n        self._extends[child_ft].update(parent_fts)\n\n    def get_deep_extends(self, base_filetypes):\n        \"\"\"Get a list of filetypes that is either directed or indirected\n        extended by given base filetypes.\n\n        Note that the returned list include the root filetype itself.\n\n        \"\"\"\n        seen = set(base_filetypes)\n        todo_fts = list(set(base_filetypes))\n        while todo_fts:\n            todo_ft = todo_fts.pop()\n            unseen_extends = set(ft for ft in self._extends[todo_ft] if ft not in seen)\n            seen.update(unseen_extends)\n            todo_fts.extend(unseen_extends)\n        return seen\n"
  },
  {
    "path": "pythonx/UltiSnips/snippet/source/file/__init__.py",
    "content": "\"\"\"Snippet sources that are file based.\"\"\"\n"
  },
  {
    "path": "pythonx/UltiSnips/snippet/source/file/base.py",
    "content": "#!/usr/bin/env python3\n# encoding: utf-8\n\n\"\"\"Code to provide access to UltiSnips files from disk.\"\"\"\n\nfrom collections import defaultdict\nimport os\n\nfrom UltiSnips import compatibility\nfrom UltiSnips import vim_helper\nfrom UltiSnips.error import PebkacError\nfrom UltiSnips.snippet.source.base import SnippetSource\n\n\nclass SnippetSyntaxError(PebkacError):\n\n    \"\"\"Thrown when a syntax error is found in a file.\"\"\"\n\n    def __init__(self, filename, line_index, msg):\n        RuntimeError.__init__(self, \"%s in %s:%d\" % (msg, filename, line_index))\n\n\nclass SnippetFileSource(SnippetSource):\n    \"\"\"Base class that abstracts away 'extends' info and file hashes.\"\"\"\n\n    def __init__(self):\n        SnippetSource.__init__(self)\n\n    def ensure(self, filetypes):\n        if self.must_ensure:\n            for ft in self.get_deep_extends(filetypes):\n                if self._needs_update(ft):\n                    self._load_snippets_for(ft)\n            self.must_ensure = False\n\n    def refresh(self):\n        self.__init__()\n\n    def _get_all_snippet_files_for(self, ft):\n        \"\"\"Returns a set of all files that define snippets for 'ft'.\"\"\"\n        raise NotImplementedError()\n\n    def _parse_snippet_file(self, filedata, filename):\n        \"\"\"Parses 'filedata' as a snippet file and yields events.\"\"\"\n        raise NotImplementedError()\n\n    def _needs_update(self, ft):\n        \"\"\"Returns true if any files for 'ft' have changed and must be\n        reloaded.\"\"\"\n        return not (ft in self._snippets)\n\n    def _load_snippets_for(self, ft):\n        \"\"\"Load all snippets for the given 'ft'.\"\"\"\n        assert ft not in self._snippets\n        for fn in self._get_all_snippet_files_for(ft):\n            self._parse_snippets(ft, fn)\n        # Now load for the parents\n        for parent_ft in self.get_deep_extends([ft]):\n            if parent_ft != ft and self._needs_update(parent_ft):\n                self._load_snippets_for(parent_ft)\n\n    def _parse_snippets(self, ft, filename):\n        \"\"\"Parse the 'filename' for the given 'ft'.\"\"\"\n        with open(filename, \"r\", encoding=\"utf-8-sig\") as to_read:\n            file_data = to_read.read()\n        self._snippets[ft]  # Make sure the dictionary exists\n        for event, data in self._parse_snippet_file(file_data, filename):\n            if event == \"error\":\n                msg, line_index = data\n                filename = vim_helper.eval(\n                    \"\"\"fnamemodify(%s, \":~:.\")\"\"\" % vim_helper.escape(filename)\n                )\n                raise SnippetSyntaxError(filename, line_index, msg)\n            elif event == \"clearsnippets\":\n                priority, triggers = data\n                self._snippets[ft].clear_snippets(priority, triggers)\n            elif event == \"extends\":\n                # TODO(sirver): extends information is more global\n                # than one snippet source.\n                (filetypes,) = data\n                self.update_extends(ft, filetypes)\n            elif event == \"snippet\":\n                (snippet,) = data\n                self._snippets[ft].add_snippet(snippet)\n            else:\n                assert False, \"Unhandled %s: %r\" % (event, data)\n        # precompile global snippets code for all snipepts we just sourced\n        for snippet in self._snippets[ft]:\n            snippet._precompile_globals()\n"
  },
  {
    "path": "pythonx/UltiSnips/snippet/source/file/common.py",
    "content": "#!/usr/bin/env python3\n# encoding: utf-8\n\n\"\"\"Common code for snipMate and UltiSnips snippet files.\"\"\"\n\nimport os.path\n\n\ndef normalize_file_path(path: str) -> str:\n    \"\"\"Calls normpath and normcase on path\"\"\"\n    path = os.path.realpath(path)\n    return os.path.normcase(os.path.normpath(path))\n\n\ndef handle_extends(tail, line_index):\n    \"\"\"Handles an extends line in a snippet.\"\"\"\n    if tail:\n        return \"extends\", ([p.strip() for p in tail.split(\",\")],)\n    else:\n        return \"error\", (\"'extends' without file types\", line_index)\n\n\ndef handle_action(head, tail, line_index):\n    if tail:\n        action = tail.strip('\"').replace(r\"\\\"\", '\"').replace(r\"\\\\\\\\\", r\"\\\\\")\n        return head, (action,)\n    else:\n        return \"error\", (\"'{}' without specified action\".format(head), line_index)\n\n\ndef handle_context(tail, line_index):\n    if tail:\n        return \"context\", tail.strip('\"').replace(r\"\\\"\", '\"').replace(r\"\\\\\\\\\", r\"\\\\\")\n    else:\n        return \"error\", (\"'context' without body\", line_index)\n"
  },
  {
    "path": "pythonx/UltiSnips/snippet/source/file/snipmate.py",
    "content": "#!/usr/bin/env python3\n# encoding: utf-8\n\n\"\"\"Parses snipMate files.\"\"\"\n\nimport os\nimport glob\n\nfrom UltiSnips import vim_helper\nfrom UltiSnips.snippet.definition import SnipMateSnippetDefinition\nfrom UltiSnips.snippet.source.file.base import SnippetFileSource\nfrom UltiSnips.snippet.source.file.common import handle_extends, normalize_file_path\nfrom UltiSnips.text import LineIterator, head_tail\n\n\ndef _splitall(path):\n    \"\"\"Split 'path' into all its components.\"\"\"\n    # From http://my.safaribooksonline.com/book/programming/\n    # python/0596001673/files/pythoncook-chp-4-sect-16\n    allparts = []\n    while True:\n        parts = os.path.split(path)\n        if parts[0] == path:  # sentinel for absolute paths\n            allparts.insert(0, parts[0])\n            break\n        elif parts[1] == path:  # sentinel for relative paths\n            allparts.insert(0, parts[1])\n            break\n        else:\n            path = parts[0]\n            allparts.insert(0, parts[1])\n    return allparts\n\n\ndef _snipmate_files_for(ft):\n    \"\"\"Returns all snipMate files we need to look at for 'ft'.\"\"\"\n    if ft == \"all\":\n        ft = \"_\"\n    patterns = [\n        \"%s.snippets\" % ft,\n        os.path.join(ft, \"*.snippets\"),\n        os.path.join(ft, \"*.snippet\"),\n        os.path.join(ft, \"*/*.snippet\"),\n    ]\n    ret = set()\n    for rtp in vim_helper.eval(\"&runtimepath\").split(\",\"):\n        path = normalize_file_path(os.path.expanduser(os.path.join(rtp, \"snippets\")))\n        for pattern in patterns:\n            for fn in glob.glob(os.path.join(path, pattern)):\n                ret.add(fn)\n    return ret\n\n\ndef _parse_snippet_file(content, full_filename):\n    \"\"\"Parses 'content' assuming it is a .snippet file and yields events.\"\"\"\n    filename = full_filename[: -len(\".snippet\")]  # strip extension\n    segments = _splitall(filename)\n    segments = segments[segments.index(\"snippets\") + 1 :]\n    assert len(segments) in (2, 3)\n\n    trigger = segments[1]\n    description = segments[2] if 2 < len(segments) else \"\"\n\n    # Chomp \\n if any.\n    if content and content.endswith(os.linesep):\n        content = content[: -len(os.linesep)]\n    yield \"snippet\", (\n        SnipMateSnippetDefinition(trigger, content, description, full_filename),\n    )\n\n\ndef _parse_snippet(line, lines, filename):\n    \"\"\"Parse a snippet definition.\"\"\"\n    start_line_index = lines.line_index\n    trigger, description = head_tail(line[len(\"snippet\") :].lstrip())\n    content = \"\"\n    while True:\n        next_line = lines.peek()\n        if next_line is None:\n            break\n        if next_line.strip() and not next_line.startswith(\"\\t\"):\n            break\n        line = next(lines)\n        if line[0] == \"\\t\":\n            line = line[1:]\n        content += line\n    content = content[:-1]  # Chomp the last newline\n    return (\n        \"snippet\",\n        (\n            SnipMateSnippetDefinition(\n                trigger, content, description, \"%s:%i\" % (filename, start_line_index)\n            ),\n        ),\n    )\n\n\ndef _parse_snippets_file(data, filename):\n    \"\"\"Parse 'data' assuming it is a .snippets file.\n\n    Yields events in the file.\n\n    \"\"\"\n    lines = LineIterator(data)\n    for line in lines:\n        if not line.strip():\n            continue\n\n        head, tail = head_tail(line)\n        if head == \"extends\":\n            yield handle_extends(tail, lines.line_index)\n        elif head == \"snippet\":\n            snippet = _parse_snippet(line, lines, filename)\n            if snippet is not None:\n                yield snippet\n        elif head and not head.startswith(\"#\"):\n            yield \"error\", (\"Invalid line %r\" % line.rstrip(), lines.line_index)\n\n\nclass SnipMateFileSource(SnippetFileSource):\n\n    \"\"\"Manages all snipMate snippet definitions found in rtp.\"\"\"\n\n    def _get_all_snippet_files_for(self, ft):\n        return _snipmate_files_for(ft)\n\n    def _parse_snippet_file(self, filedata, filename):\n        if filename.lower().endswith(\"snippet\"):\n            for event, data in _parse_snippet_file(filedata, filename):\n                yield event, data\n        else:\n            for event, data in _parse_snippets_file(filedata, filename):\n                yield event, data\n"
  },
  {
    "path": "pythonx/UltiSnips/snippet/source/file/ulti_snips.py",
    "content": "#!/usr/bin/env python3\n# encoding: utf-8\n\n\"\"\"Parsing of snippet files.\"\"\"\n\nfrom collections import defaultdict\nimport glob\nimport os\nfrom typing import Set, List\n\nfrom UltiSnips import vim_helper\nfrom UltiSnips.error import PebkacError\nfrom UltiSnips.snippet.definition import UltiSnipsSnippetDefinition\nfrom UltiSnips.snippet.source.file.base import SnippetFileSource\nfrom UltiSnips.snippet.source.file.common import (\n    handle_action,\n    handle_context,\n    handle_extends,\n    normalize_file_path,\n)\nfrom UltiSnips.text import LineIterator, head_tail\n\n\ndef find_snippet_files(ft, directory: str) -> Set[str]:\n    \"\"\"Returns all matching snippet files for 'ft' in 'directory'.\"\"\"\n    patterns = [\"%s.snippets\", \"%s_*.snippets\", os.path.join(\"%s\", \"*\")]\n    ret = set()\n    directory = os.path.expanduser(directory)\n    for pattern in patterns:\n        for fn in glob.glob(os.path.join(directory, pattern % ft)):\n            ret.add(normalize_file_path(fn))\n    return ret\n\n\ndef find_all_snippet_directories() -> List[str]:\n    \"\"\"Returns a list of the absolute path of all potential snippet\n    directories, no matter if they exist or not.\"\"\"\n\n    if vim_helper.eval(\"exists('b:UltiSnipsSnippetDirectories')\") == \"1\":\n        snippet_dirs = vim_helper.eval(\"b:UltiSnipsSnippetDirectories\")\n    else:\n        snippet_dirs = vim_helper.eval(\"g:UltiSnipsSnippetDirectories\")\n\n    if len(snippet_dirs) == 1:\n        # To reduce confusion and increase consistency with\n        # `UltiSnipsSnippetsDir`, we expand ~ here too.\n        full_path = os.path.expanduser(snippet_dirs[0])\n        if os.path.isabs(full_path):\n            return [full_path]\n\n    all_dirs = []\n    check_dirs = vim_helper.eval(\"&runtimepath\").split(\",\")\n    for rtp in check_dirs:\n        for snippet_dir in snippet_dirs:\n            if snippet_dir == \"snippets\":\n                raise PebkacError(\n                    \"You have 'snippets' in UltiSnipsSnippetDirectories. This \"\n                    \"directory is reserved for snipMate snippets. Use another \"\n                    \"directory for UltiSnips snippets.\"\n                )\n            pth = normalize_file_path(\n                os.path.expanduser(os.path.join(rtp, snippet_dir))\n            )\n            # Runtimepath entries may contain wildcards.\n            all_dirs.extend(glob.glob(pth))\n    return all_dirs\n\n\ndef find_all_snippet_files(ft) -> Set[str]:\n    \"\"\"Returns all snippet files matching 'ft' in the given runtime path\n    directory.\"\"\"\n    patterns = [\"%s.snippets\", \"%s_*.snippets\", os.path.join(\"%s\", \"*\")]\n    ret = set()\n    for directory in find_all_snippet_directories():\n        if not os.path.isdir(directory):\n            continue\n        for pattern in patterns:\n            for fn in glob.glob(os.path.join(directory, pattern % ft)):\n                ret.add(fn)\n    return ret\n\n\ndef _handle_snippet_or_global(\n    filename, line, lines, python_globals, priority, pre_expand, context\n):\n    \"\"\"Parses the snippet that begins at the current line.\"\"\"\n    start_line_index = lines.line_index\n    descr = \"\"\n    opts = \"\"\n\n    # Ensure this is a snippet\n    snip = line.split()[0]\n\n    # Get and strip options if they exist\n    remain = line[len(snip) :].strip()\n    words = remain.split()\n\n    if len(words) > 2:\n        # second to last word ends with a quote\n        if '\"' not in words[-1] and words[-2][-1] == '\"':\n            opts = words[-1]\n            remain = remain[: -len(opts) - 1].rstrip()\n\n    if \"e\" in opts and not context:\n        left = remain[:-1].rfind('\"')\n        if left != -1 and left != 0:\n            context, remain = remain[left:].strip('\"'), remain[:left]\n\n    # Get and strip description if it exists\n    remain = remain.strip()\n    if len(remain.split()) > 1 and remain[-1] == '\"':\n        left = remain[:-1].rfind('\"')\n        if left != -1 and left != 0:\n            descr, remain = remain[left:], remain[:left]\n\n    # The rest is the trigger\n    trig = remain.strip()\n    if len(trig.split()) > 1 or \"r\" in opts:\n        if trig[0] != trig[-1]:\n            return \"error\", (\"Invalid multiword trigger: '%s'\" % trig, lines.line_index)\n        trig = trig[1:-1]\n    end = \"end\" + snip\n    content = \"\"\n\n    found_end = False\n    for line in lines:\n        if line.rstrip() == end:\n            content = content[:-1]  # Chomp the last newline\n            found_end = True\n            break\n        content += line\n\n    if not found_end:\n        return \"error\", (\"Missing 'endsnippet' for %r\" % trig, lines.line_index)\n\n    if snip == \"global\":\n        python_globals[trig].append(content)\n    elif snip == \"snippet\":\n        definition = UltiSnipsSnippetDefinition(\n            priority,\n            trig,\n            content,\n            descr,\n            opts,\n            python_globals,\n            \"%s:%i\" % (filename, start_line_index),\n            context,\n            pre_expand,\n        )\n        return \"snippet\", (definition,)\n    else:\n        return \"error\", (\"Invalid snippet type: '%s'\" % snip, lines.line_index)\n\n\ndef _parse_snippets_file(data, filename):\n    \"\"\"Parse 'data' assuming it is a snippet file.\n\n    Yields events in the file.\n\n    \"\"\"\n\n    python_globals = defaultdict(list)\n    lines = LineIterator(data)\n    current_priority = 0\n    actions = {}\n    context = None\n    for line in lines:\n        if not line.strip():\n            continue\n\n        head, tail = head_tail(line)\n        if head in (\"snippet\", \"global\"):\n            snippet = _handle_snippet_or_global(\n                filename,\n                line,\n                lines,\n                python_globals,\n                current_priority,\n                actions,\n                context,\n            )\n\n            actions = {}\n            context = None\n            if snippet is not None:\n                yield snippet\n        elif head == \"extends\":\n            yield handle_extends(tail, lines.line_index)\n        elif head == \"clearsnippets\":\n            yield \"clearsnippets\", (current_priority, tail.split())\n        elif head == \"context\":\n            (\n                head,\n                context,\n            ) = handle_context(tail, lines.line_index)\n            if head == \"error\":\n                yield (head, tail)\n        elif head == \"priority\":\n            try:\n                current_priority = int(tail.split()[0])\n            except (ValueError, IndexError):\n                yield \"error\", (\"Invalid priority %r\" % tail, lines.line_index)\n        elif head in [\"pre_expand\", \"post_expand\", \"post_jump\"]:\n            head, tail = handle_action(head, tail, lines.line_index)\n            if head == \"error\":\n                yield (head, tail)\n            else:\n                (actions[head],) = tail\n        elif head and not head.startswith(\"#\"):\n            yield \"error\", (\"Invalid line %r\" % line.rstrip(), lines.line_index)\n\n\nclass UltiSnipsFileSource(SnippetFileSource):\n\n    \"\"\"Manages all snippets definitions found in rtp for ultisnips.\"\"\"\n\n    def _get_all_snippet_files_for(self, ft):\n        return find_all_snippet_files(ft)\n\n    def _parse_snippet_file(self, filedata, filename):\n        for event, data in _parse_snippets_file(filedata, filename):\n            yield event, data\n"
  },
  {
    "path": "pythonx/UltiSnips/snippet/source/snippet_dictionary.py",
    "content": "#!/usr/bin/env python3\n# encoding: utf-8\n\n\"\"\"Implements a container for parsed snippets.\"\"\"\n\n\nclass SnippetDictionary:\n\n    \"\"\"See module docstring.\"\"\"\n\n    def __init__(self):\n        self._snippets = []\n        self._cleared = {}\n        self._clear_priority = float(\"-inf\")\n\n    def add_snippet(self, snippet):\n        \"\"\"Add 'snippet' to this dictionary.\"\"\"\n        self._snippets.append(snippet)\n\n    def get_matching_snippets(\n        self, trigger, potentially, autotrigger_only, visual_content\n    ):\n        \"\"\"Returns all snippets matching the given trigger.\n\n        If 'potentially' is true, returns all that could_match().\n\n        If 'autotrigger_only' is true, function will return only snippets which\n        are marked with flag 'A' (should be automatically expanded without\n        trigger key press).\n        It's handled specially to avoid walking down the list of all snippets,\n        which can be very slow, because function will be called on each change\n        made in insert mode.\n\n        \"\"\"\n        all_snippets = self._snippets\n        if autotrigger_only:\n            all_snippets = [s for s in all_snippets if s.has_option(\"A\")]\n\n        if not potentially:\n            return [s for s in all_snippets if s.matches(trigger, visual_content)]\n        else:\n            return [s for s in all_snippets if s.could_match(trigger)]\n\n    def clear_snippets(self, priority, triggers):\n        \"\"\"Clear the snippets by mark them as cleared.\n\n        If trigger is None, it updates the value of clear priority\n        instead.\n\n        \"\"\"\n        if not triggers:\n            if self._clear_priority is None or priority > self._clear_priority:\n                self._clear_priority = priority\n        else:\n            for trigger in triggers:\n                if trigger not in self._cleared or priority > self._cleared[trigger]:\n                    self._cleared[trigger] = priority\n\n    def __len__(self):\n        return len(self._snippets)\n\n    def __iter__(self):\n        return iter(self._snippets)\n"
  },
  {
    "path": "pythonx/UltiSnips/snippet_manager.py",
    "content": "#!/usr/bin/env python3\n# encoding: utf-8\n\n\"\"\"Contains the SnippetManager facade used by all Vim Functions.\"\"\"\n\nfrom collections import defaultdict\nfrom contextlib import contextmanager\nimport os\nfrom typing import Set\nfrom pathlib import Path\nimport vim\n\nfrom UltiSnips import vim_helper\nfrom UltiSnips import err_to_scratch_buffer\nfrom UltiSnips.diff import diff, guess_edit\nfrom UltiSnips.position import Position, JumpDirection\nfrom UltiSnips.snippet.definition import UltiSnipsSnippetDefinition\nfrom UltiSnips.snippet.source import (\n    AddedSnippetsSource,\n    SnipMateFileSource,\n    UltiSnipsFileSource,\n    find_all_snippet_directories,\n    find_all_snippet_files,\n    find_snippet_files,\n)\nfrom UltiSnips.snippet.source.file.common import (\n    normalize_file_path,\n)\nfrom UltiSnips.text import escape\nfrom UltiSnips.vim_state import VimState, VisualContentPreserver\nfrom UltiSnips.buffer_proxy import use_proxy_buffer, suspend_proxy_edits\n\n\ndef _ask_user(a, formatted):\n    \"\"\"Asks the user using inputlist() and returns the selected element or\n    None.\"\"\"\n    try:\n        rv = vim_helper.eval(\"inputlist(%s)\" % vim_helper.escape(formatted))\n        if rv is None or rv == \"0\":\n            return None\n        rv = int(rv)\n        if rv > len(a):\n            rv = len(a)\n        return a[rv - 1]\n    except vim_helper.error:\n        # Likely \"invalid expression\", but might be translated. We have no way\n        # of knowing the exact error, therefore, we ignore all errors silently.\n        return None\n    except KeyboardInterrupt:\n        return None\n\n\ndef _show_user_warning(msg):\n    \"\"\"Shows a Vim warning message to the user.\"\"\"\n    vim_helper.command(\"echohl WarningMsg\")\n    vim_helper.command('echom \"%s\"' % msg.replace('\"', '\\\\\"'))\n    vim_helper.command(\"echohl None\")\n\n\ndef _ask_snippets(snippets):\n    \"\"\"Given a list of snippets, ask the user which one they want to use, and\n    return it.\"\"\"\n    display = [\n        \"%i: %s (%s)\" % (i + 1, escape(s.description, \"\\\\\"), escape(s.location, \"\\\\\"))\n        for i, s in enumerate(snippets)\n    ]\n    return _ask_user(snippets, display)\n\n\ndef _select_and_create_file_to_edit(potentials: Set[str]) -> str:\n    assert len(potentials) >= 1\n\n    file_to_edit = \"\"\n    if len(potentials) > 1:\n        files = sorted(potentials)\n        exists = [os.path.exists(f) for f in files]\n        formatted = [\n            \"%s %i: %s\" % (\"*\" if exists else \" \", i, escape(fn, \"\\\\\"))\n            for i, (fn, exists) in enumerate(zip(files, exists), 1)\n        ]\n        file_to_edit = _ask_user(files, formatted)\n        if file_to_edit is None:\n            return \"\"\n    else:\n        file_to_edit = potentials.pop()\n\n    dirname = os.path.dirname(file_to_edit)\n    if not os.path.exists(dirname):\n        os.makedirs(dirname)\n\n    return file_to_edit\n\n\ndef _get_potential_snippet_filenames_to_edit(\n    snippet_dir: str, filetypes: str\n) -> Set[str]:\n    potentials = set()\n    for ft in filetypes:\n        ft_snippets_files = find_snippet_files(ft, snippet_dir)\n        potentials.update(ft_snippets_files)\n        if not ft_snippets_files:\n            # If there is no snippet file yet, we just default to `ft.snippets`.\n            fpath = os.path.join(snippet_dir, ft + \".snippets\")\n            fpath = normalize_file_path(fpath)\n            potentials.add(fpath)\n    return potentials\n\n\n# TODO(sirver): This class is still too long. It should only contain public\n# facing methods, most of the private methods should be moved outside of it.\nclass SnippetManager:\n\n    \"\"\"The main entry point for all UltiSnips functionality.\n\n    All Vim functions call methods in this class.\n\n    \"\"\"\n\n    def __init__(self, expand_trigger, forward_trigger, backward_trigger):\n        self.expand_trigger = expand_trigger\n        self.forward_trigger = forward_trigger\n        self.backward_trigger = backward_trigger\n        self._inner_state_up = False\n        self._supertab_keys = None\n\n        self._active_snippets = []\n        self._added_buffer_filetypes = defaultdict(lambda: [])\n\n        self._vstate = VimState()\n        self._visual_content = VisualContentPreserver()\n\n        self._snippet_sources = []\n        self._filetypes = []\n\n        self._snip_expanded_in_action = False\n        self._inside_action = False\n\n        self._last_change = (\"\", Position(-1, -1))\n\n        self._added_snippets_source = AddedSnippetsSource()\n        self.register_snippet_source(\"ultisnips_files\", UltiSnipsFileSource())\n        self.register_snippet_source(\"added\", self._added_snippets_source)\n\n        enable_snipmate = \"1\"\n        if vim_helper.eval(\"exists('g:UltiSnipsEnableSnipMate')\") == \"1\":\n            enable_snipmate = vim_helper.eval(\"g:UltiSnipsEnableSnipMate\")\n        if enable_snipmate == \"1\":\n            self.register_snippet_source(\"snipmate_files\", SnipMateFileSource())\n\n        self._autotrigger = True\n        if vim_helper.eval(\"exists('g:UltiSnipsAutoTrigger')\") == \"1\":\n            self._autotrigger = vim_helper.eval(\"g:UltiSnipsAutoTrigger\") == \"1\"\n\n        self._should_update_textobjects = False\n        self._should_reset_visual = False\n\n        self._reinit()\n\n    @err_to_scratch_buffer.wrap\n    def jump_forwards(self):\n        \"\"\"Jumps to the next tabstop.\"\"\"\n        vim_helper.command(\"let g:ulti_jump_forwards_res = 1\")\n        vim_helper.command(\"let &g:undolevels = &g:undolevels\")\n        if not self._jump(JumpDirection.FORWARD):\n            vim_helper.command(\"let g:ulti_jump_forwards_res = 0\")\n            return self._handle_failure(self.forward_trigger)\n        return None\n\n    @err_to_scratch_buffer.wrap\n    def jump_backwards(self):\n        \"\"\"Jumps to the previous tabstop.\"\"\"\n        vim_helper.command(\"let g:ulti_jump_backwards_res = 1\")\n        vim_helper.command(\"let &g:undolevels = &g:undolevels\")\n        if not self._jump(JumpDirection.BACKWARD):\n            vim_helper.command(\"let g:ulti_jump_backwards_res = 0\")\n            return self._handle_failure(self.backward_trigger)\n        return None\n\n    @err_to_scratch_buffer.wrap\n    def expand(self):\n        \"\"\"Try to expand a snippet at the current position.\"\"\"\n        vim_helper.command(\"let g:ulti_expand_res = 1\")\n        if not self._try_expand():\n            vim_helper.command(\"let g:ulti_expand_res = 0\")\n            self._handle_failure(self.expand_trigger, True)\n\n    @err_to_scratch_buffer.wrap\n    def expand_or_jump(self):\n        \"\"\"This function is used for people who want to have the same trigger\n        for expansion and forward jumping.\n\n        It first tries to expand a snippet, if this fails, it tries to\n        jump forward.\n\n        \"\"\"\n        vim_helper.command(\"let g:ulti_expand_or_jump_res = 1\")\n        rv = self._try_expand()\n        if not rv:\n            vim_helper.command(\"let g:ulti_expand_or_jump_res = 2\")\n            rv = self._jump(JumpDirection.FORWARD)\n        if not rv:\n            vim_helper.command(\"let g:ulti_expand_or_jump_res = 0\")\n            self._handle_failure(self.expand_trigger, True)\n\n    @err_to_scratch_buffer.wrap\n    def jump_or_expand(self):\n        \"\"\"This function is used for people who want to have the same trigger\n        for expansion and forward jumping.\n\n        It first tries to jump forward, if this fails, it tries to\n        expand a snippet.\n\n        \"\"\"\n        vim_helper.command(\"let g:ulti_expand_or_jump_res = 2\")\n        rv = self._jump(JumpDirection.FORWARD)\n        if not rv:\n            vim_helper.command(\"let g:ulti_expand_or_jump_res = 1\")\n            rv = self._try_expand()\n        if not rv:\n            vim_helper.command(\"let g:ulti_expand_or_jump_res = 0\")\n            self._handle_failure(self.expand_trigger, True)\n\n    @err_to_scratch_buffer.wrap\n    def snippets_in_current_scope(self, search_all):\n        \"\"\"Returns the snippets that could be expanded to Vim as a global\n        variable.\"\"\"\n        before = \"\" if search_all else vim_helper.buf.line_till_cursor\n        snippets = self._snips(before, True)\n\n        # Sort snippets alphabetically\n        snippets.sort(key=lambda x: x.trigger)\n        for snip in snippets:\n            description = snip.description[\n                snip.description.find(snip.trigger) + len(snip.trigger) + 2 :\n            ]\n\n            location = snip.location if snip.location else \"\"\n\n            key = snip.trigger\n\n            # remove surrounding \"\" or '' in snippet description if it exists\n            if len(description) > 2:\n                if description[0] == description[-1] and description[0] in \"'\\\"\":\n                    description = description[1:-1]\n\n            vim_helper.command(\n                \"let g:current_ulti_dict['{key}'] = '{val}'\".format(\n                    key=key.replace(\"'\", \"''\"), val=description.replace(\"'\", \"''\")\n                )\n            )\n\n            if search_all:\n                vim_helper.command(\n                    (\n                        \"let g:current_ulti_dict_info['{key}'] = {{\"\n                        \"'description': '{description}',\"\n                        \"'location': '{location}',\"\n                        \"}}\"\n                    ).format(\n                        key=key.replace(\"'\", \"''\"),\n                        location=location.replace(\"'\", \"''\"),\n                        description=description.replace(\"'\", \"''\"),\n                    )\n                )\n\n    @err_to_scratch_buffer.wrap\n    def list_snippets(self):\n        \"\"\"Shows the snippets that could be expanded to the User and let her\n        select one.\"\"\"\n        before = vim_helper.buf.line_till_cursor\n        snippets = self._snips(before, True)\n\n        if len(snippets) == 0:\n            self._handle_failure(vim.eval(\"g:UltiSnipsListSnippets\"))\n            return True\n\n        # Sort snippets alphabetically\n        snippets.sort(key=lambda x: x.trigger)\n\n        if not snippets:\n            return True\n\n        snippet = _ask_snippets(snippets)\n        if not snippet:\n            return True\n\n        self._do_snippet(snippet, before)\n\n        return True\n\n    @err_to_scratch_buffer.wrap\n    def add_snippet(\n        self,\n        trigger,\n        value,\n        description,\n        options,\n        ft=\"all\",\n        priority=0,\n        context=None,\n        actions=None,\n    ):\n        \"\"\"Add a snippet to the list of known snippets of the given 'ft'.\"\"\"\n        self._added_snippets_source.add_snippet(\n            ft,\n            UltiSnipsSnippetDefinition(\n                priority,\n                trigger,\n                value,\n                description,\n                options,\n                {},\n                \"added\",\n                context,\n                actions,\n            ),\n        )\n\n    @err_to_scratch_buffer.wrap\n    def expand_anon(\n        self, value, trigger=\"\", description=\"\", options=\"\", context=None, actions=None\n    ):\n        \"\"\"Expand an anonymous snippet right here.\"\"\"\n        before = vim_helper.buf.line_till_cursor\n        snip = UltiSnipsSnippetDefinition(\n            0, trigger, value, description, options, {}, \"\", context, actions\n        )\n\n        if not trigger or snip.matches(before, self._visual_content):\n            self._do_snippet(snip, before)\n            return True\n        return False\n\n    def register_snippet_source(self, name, snippet_source):\n        \"\"\"Registers a new 'snippet_source' with the given 'name'.\n\n        The given class must be an instance of SnippetSource. This\n        source will be queried for snippets.\n\n        \"\"\"\n        self._snippet_sources.append((name, snippet_source))\n\n    def unregister_snippet_source(self, name):\n        \"\"\"Unregister the source with the given 'name'.\n\n        Does nothing if it is not registered.\n\n        \"\"\"\n        for index, (source_name, _) in enumerate(self._snippet_sources):\n            if name == source_name:\n                self._snippet_sources = (\n                    self._snippet_sources[:index] + self._snippet_sources[index + 1 :]\n                )\n                break\n\n    def get_buffer_filetypes(self):\n        return (\n            self._added_buffer_filetypes[vim_helper.buf.number]\n            + vim_helper.buf.filetypes\n            + [\"all\"]\n        )\n\n    def add_buffer_filetypes(self, filetypes: str):\n        \"\"\"'filetypes' is a dotted filetype list, for example 'cuda.cpp'\"\"\"\n        buf_fts = self._added_buffer_filetypes[vim_helper.buf.number]\n        idx = -1\n        for ft in filetypes.split(\".\"):\n            ft = ft.strip()\n            if not ft:\n                continue\n            try:\n                idx = buf_fts.index(ft)\n            except ValueError:\n                self._added_buffer_filetypes[vim_helper.buf.number].insert(idx + 1, ft)\n                idx += 1\n\n    @err_to_scratch_buffer.wrap\n    def _cursor_moved(self):\n        \"\"\"Called whenever the cursor moved.\"\"\"\n        self._should_update_textobjects = False\n\n        self._vstate.remember_position()\n        if vim_helper.eval(\"mode()\") not in \"in\":\n            return\n\n        if self._ignore_movements:\n            self._ignore_movements = False\n            return\n\n        if self._active_snippets:\n            cstart = self._active_snippets[0].start.line\n            cend = (\n                self._active_snippets[0].end.line + self._vstate.diff_in_buffer_length\n            )\n            ct = vim_helper.buf[cstart : cend + 1]\n            lt = self._vstate.remembered_buffer\n            pos = vim_helper.buf.cursor\n\n            lt_span = [0, len(lt)]\n            ct_span = [0, len(ct)]\n            initial_line = cstart\n\n            # Cut down on lines searched for changes. Start from behind and\n            # remove all equal lines. Then do the same from the front.\n            if lt and ct:\n                while (\n                    lt[lt_span[1] - 1] == ct[ct_span[1] - 1]\n                    and self._vstate.ppos.line < initial_line + lt_span[1] - 1\n                    and pos.line < initial_line + ct_span[1] - 1\n                    and (lt_span[0] < lt_span[1])\n                    and (ct_span[0] < ct_span[1])\n                ):\n                    ct_span[1] -= 1\n                    lt_span[1] -= 1\n                while (\n                    lt_span[0] < lt_span[1]\n                    and ct_span[0] < ct_span[1]\n                    and lt[lt_span[0]] == ct[ct_span[0]]\n                    and self._vstate.ppos.line >= initial_line\n                    and pos.line >= initial_line\n                ):\n                    ct_span[0] += 1\n                    lt_span[0] += 1\n                    initial_line += 1\n            ct_span[0] = max(0, ct_span[0] - 1)\n            lt_span[0] = max(0, lt_span[0] - 1)\n            initial_line = max(cstart, initial_line - 1)\n\n            lt = lt[lt_span[0] : lt_span[1]]\n            ct = ct[ct_span[0] : ct_span[1]]\n\n            try:\n                rv, es = guess_edit(initial_line, lt, ct, self._vstate)\n                if not rv:\n                    lt = \"\\n\".join(lt)\n                    ct = \"\\n\".join(ct)\n                    es = diff(lt, ct, initial_line)\n                self._active_snippets[0].replay_user_edits(es, self._ctab)\n            except IndexError:\n                # Rather do nothing than throwing an error. It will be correct\n                # most of the time\n                pass\n\n        self._check_if_still_inside_snippet()\n        if self._active_snippets:\n            self._active_snippets[0].update_textobjects(vim_helper.buf)\n            self._vstate.remember_buffer(self._active_snippets[0])\n\n    def _setup_inner_state(self):\n        \"\"\"Map keys and create autocommands that should only be defined when a\n        snippet is active.\"\"\"\n        if self._inner_state_up:\n            return\n        if self.expand_trigger != self.forward_trigger:\n            vim_helper.command(\n                \"inoremap <buffer><nowait><silent> \"\n                + self.forward_trigger\n                + \" <C-R>=UltiSnips#JumpForwards()<cr>\"\n            )\n            vim_helper.command(\n                \"snoremap <buffer><nowait><silent> \"\n                + self.forward_trigger\n                + \" <Esc>:call UltiSnips#JumpForwards()<cr>\"\n            )\n        vim_helper.command(\n            \"inoremap <buffer><nowait><silent> \"\n            + self.backward_trigger\n            + \" <C-R>=UltiSnips#JumpBackwards()<cr>\"\n        )\n        vim_helper.command(\n            \"snoremap <buffer><nowait><silent> \"\n            + self.backward_trigger\n            + \" <Esc>:call UltiSnips#JumpBackwards()<cr>\"\n        )\n\n        # Setup the autogroups.\n        vim_helper.command(\"augroup UltiSnips\")\n        vim_helper.command(\"autocmd!\")\n        vim_helper.command(\"autocmd CursorMovedI * call UltiSnips#CursorMoved()\")\n        vim_helper.command(\"autocmd CursorMoved * call UltiSnips#CursorMoved()\")\n\n        vim_helper.command(\"autocmd InsertLeave * call UltiSnips#LeavingInsertMode()\")\n\n        vim_helper.command(\"autocmd BufEnter * call UltiSnips#LeavingBuffer()\")\n        vim_helper.command(\"autocmd CmdwinEnter * call UltiSnips#LeavingBuffer()\")\n        vim_helper.command(\"autocmd CmdwinLeave * call UltiSnips#LeavingBuffer()\")\n\n        # Also exit the snippet when we enter a unite complete buffer.\n        vim_helper.command(\"autocmd Filetype unite call UltiSnips#LeavingBuffer()\")\n\n        vim_helper.command(\"augroup END\")\n\n        vim_helper.command(\n            \"silent doautocmd <nomodeline> User UltiSnipsEnterFirstSnippet\"\n        )\n        self._inner_state_up = True\n\n    def _teardown_inner_state(self):\n        \"\"\"Reverse _setup_inner_state.\"\"\"\n        if not self._inner_state_up:\n            return\n        try:\n            vim_helper.command(\n                \"silent doautocmd <nomodeline> User UltiSnipsExitLastSnippet\"\n            )\n            if self.expand_trigger != self.forward_trigger:\n                vim_helper.command(\"iunmap <buffer> %s\" % self.forward_trigger)\n                vim_helper.command(\"sunmap <buffer> %s\" % self.forward_trigger)\n            vim_helper.command(\"iunmap <buffer> %s\" % self.backward_trigger)\n            vim_helper.command(\"sunmap <buffer> %s\" % self.backward_trigger)\n            vim_helper.command(\"augroup UltiSnips\")\n            vim_helper.command(\"autocmd!\")\n            vim_helper.command(\"augroup END\")\n        except vim_helper.error:\n            # This happens when a preview window was opened. This issues\n            # CursorMoved, but not BufLeave. We have no way to unmap, until we\n            # are back in our buffer\n            pass\n        finally:\n            self._inner_state_up = False\n\n    @err_to_scratch_buffer.wrap\n    def _save_last_visual_selection(self):\n        \"\"\"This is called when the expand trigger is pressed in visual mode.\n        Our job is to remember everything between '< and '> and pass it on to.\n\n        ${VISUAL} in case it will be needed.\n\n        \"\"\"\n        self._visual_content.conserve()\n\n    def _leaving_buffer(self):\n        \"\"\"Called when the user switches tabs/windows/buffers.\n\n        It basically means that all snippets must be properly\n        terminated.\n\n        \"\"\"\n        while self._active_snippets:\n            self._current_snippet_is_done()\n        self._reinit()\n\n    def _reinit(self):\n        \"\"\"Resets transient state.\"\"\"\n        self._ctab = None\n        self._ignore_movements = False\n\n    def _check_if_still_inside_snippet(self):\n        \"\"\"Checks if the cursor is outside of the current snippet.\"\"\"\n        if self._current_snippet and (\n            not self._current_snippet.start\n            <= vim_helper.buf.cursor\n            <= self._current_snippet.end\n        ):\n            self._current_snippet_is_done()\n            self._reinit()\n            self._check_if_still_inside_snippet()\n\n    def _current_snippet_is_done(self):\n        \"\"\"The current snippet should be terminated.\"\"\"\n        self._active_snippets.pop()\n        if not self._active_snippets:\n            self._teardown_inner_state()\n\n    def _jump(self, jump_direction: JumpDirection):\n        \"\"\"Helper method that does the actual jump.\"\"\"\n        if self._should_update_textobjects:\n            self._should_reset_visual = False\n            self._cursor_moved()\n\n        # we need to set 'onemore' there, because of limitations of the vim\n        # API regarding cursor movements; without that test\n        # 'CanExpandAnonSnippetInJumpActionWhileSelected' will fail\n        with vim_helper.option_set_to(\"ve\", \"onemore\"):\n            jumped = False\n\n            # We need to remember current snippets stack here because of\n            # post-jump action on the last tabstop should be able to access\n            # snippet instance which is ended just now.\n            stack_for_post_jump = self._active_snippets[:]\n\n            # If next tab has length 1 and the distance between itself and\n            # self._ctab is 1 then there is 1 less CursorMove events.  We\n            # cannot ignore next movement in such case.\n            ntab_short_and_near = False\n\n            if self._current_snippet:\n                snippet_for_action = self._current_snippet\n            elif stack_for_post_jump:\n                snippet_for_action = stack_for_post_jump[-1]\n            else:\n                snippet_for_action = None\n\n            if self._current_snippet:\n                ntab = self._current_snippet.select_next_tab(jump_direction)\n                if ntab:\n                    if self._current_snippet.snippet.has_option(\"s\"):\n                        lineno = vim_helper.buf.cursor.line\n                        vim_helper.buf[lineno] = vim_helper.buf[lineno].rstrip()\n                    vim_helper.select(ntab.start, ntab.end)\n                    jumped = True\n                    if (\n                        self._ctab is not None\n                        and ntab.start - self._ctab.end == Position(0, 1)\n                        and ntab.end - ntab.start == Position(0, 1)\n                    ):\n                        ntab_short_and_near = True\n\n                    self._ctab = ntab\n\n                    # Run interpolations again to update new placeholder\n                    # values, binded to currently newly jumped placeholder.\n                    self._visual_content.conserve_placeholder(self._ctab)\n                    self._current_snippet.current_placeholder = (\n                        self._visual_content.placeholder\n                    )\n                    self._should_reset_visual = False\n                    self._active_snippets[0].update_textobjects(vim_helper.buf)\n                    # Open any folds this might have created\n                    vim_helper.command(\"normal! zv\")\n                    self._vstate.remember_buffer(self._active_snippets[0])\n\n                    if ntab.number == 0 and self._active_snippets:\n                        self._current_snippet_is_done()\n                else:\n                    # This really shouldn't happen, because a snippet should\n                    # have been popped when its final tabstop was used.\n                    # Cleanup by removing current snippet and recursing.\n                    self._current_snippet_is_done()\n                    jumped = self._jump(jump_direction)\n\n            if jumped:\n                if self._ctab:\n                    self._vstate.remember_position()\n                    self._vstate.remember_unnamed_register(self._ctab.current_text)\n                if not ntab_short_and_near:\n                    self._ignore_movements = True\n\n            if len(stack_for_post_jump) > 0 and ntab is not None:\n                with use_proxy_buffer(stack_for_post_jump, self._vstate):\n                    snippet_for_action.snippet.do_post_jump(\n                        ntab.number,\n                        -1 if jump_direction == JumpDirection.BACKWARD else 1,\n                        stack_for_post_jump,\n                        snippet_for_action,\n                    )\n\n        return jumped\n\n    def _leaving_insert_mode(self):\n        \"\"\"Called whenever we leave the insert mode.\"\"\"\n        self._vstate.restore_unnamed_register()\n\n    def _handle_failure(self, trigger, pass_through=False):\n        \"\"\"Mainly make sure that we play well with SuperTab.\"\"\"\n        if trigger.lower() == \"<tab>\":\n            feedkey = \"\\\\\" + trigger\n        elif trigger.lower() == \"<s-tab>\":\n            feedkey = \"\\\\\" + trigger\n        elif pass_through:\n            # pass through the trigger key if it did nothing\n            feedkey = \"\\\\\" + trigger\n        else:\n            feedkey = None\n        mode = \"n\"\n        if not self._supertab_keys:\n            if vim_helper.eval(\"exists('g:SuperTabMappingForward')\") != \"0\":\n                self._supertab_keys = (\n                    vim_helper.eval(\"g:SuperTabMappingForward\"),\n                    vim_helper.eval(\"g:SuperTabMappingBackward\"),\n                )\n            else:\n                self._supertab_keys = [\"\", \"\"]\n\n        for idx, sttrig in enumerate(self._supertab_keys):\n            if trigger.lower() == sttrig.lower():\n                if idx == 0:\n                    feedkey = r\"\\<Plug>SuperTabForward\"\n                    mode = \"n\"\n                elif idx == 1:\n                    feedkey = r\"\\<Plug>SuperTabBackward\"\n                    mode = \"p\"\n                # Use remap mode so SuperTab mappings will be invoked.\n                break\n\n        if feedkey in (r\"\\<Plug>SuperTabForward\", r\"\\<Plug>SuperTabBackward\"):\n            vim_helper.command(\"return SuperTab(%s)\" % vim_helper.escape(mode))\n        elif feedkey:\n            vim_helper.command(\"return %s\" % vim_helper.escape(feedkey))\n\n    def _snips(self, before, partial, autotrigger_only=False):\n        \"\"\"Returns all the snippets for the given text before the cursor.\n\n        If partial is True, then get also return partial matches.\n\n        \"\"\"\n        filetypes = self.get_buffer_filetypes()[::-1]\n        matching_snippets = defaultdict(list)\n        clear_priority = None\n        cleared = {}\n        for _, source in self._snippet_sources:\n            source.ensure(filetypes)\n\n        # Collect cleared information from sources.\n        for _, source in self._snippet_sources:\n            sclear_priority = source.get_clear_priority(filetypes)\n            if sclear_priority is not None and (\n                clear_priority is None or sclear_priority > clear_priority\n            ):\n                clear_priority = sclear_priority\n            for key, value in source.get_cleared(filetypes).items():\n                if key not in cleared or value > cleared[key]:\n                    cleared[key] = value\n\n        for _, source in self._snippet_sources:\n            possible_snippets = source.get_snippets(\n                filetypes, before, partial, autotrigger_only, self._visual_content\n            )\n\n            for snippet in possible_snippets:\n                if (clear_priority is None or snippet.priority > clear_priority) and (\n                    snippet.trigger not in cleared\n                    or snippet.priority > cleared[snippet.trigger]\n                ):\n                    matching_snippets[snippet.trigger].append(snippet)\n        if not matching_snippets:\n            return []\n\n        # Now filter duplicates and only keep the one with the highest\n        # priority.\n        snippets = []\n        for snippets_with_trigger in matching_snippets.values():\n            highest_priority = max(s.priority for s in snippets_with_trigger)\n            snippets.extend(\n                s for s in snippets_with_trigger if s.priority == highest_priority\n            )\n\n        # For partial matches we are done, but if we want to expand a snippet,\n        # we have to go over them again and only keep those with the maximum\n        # priority.\n        if partial:\n            return snippets\n\n        highest_priority = max(s.priority for s in snippets)\n        return [s for s in snippets if s.priority == highest_priority]\n\n    def _do_snippet(self, snippet, before):\n        \"\"\"Expands the given snippet, and handles everything that needs to be\n        done with it.\"\"\"\n        self._setup_inner_state()\n\n        self._snip_expanded_in_action = False\n        self._should_update_textobjects = False\n\n        # Adjust before, maybe the trigger is not the complete word\n        text_before = before\n        if snippet.matched:\n            text_before = before[: -len(snippet.matched)]\n\n        with use_proxy_buffer(self._active_snippets, self._vstate):\n            with self._action_context():\n                cursor_set_in_action = snippet.do_pre_expand(\n                    self._visual_content.text, self._active_snippets\n                )\n\n        if cursor_set_in_action:\n            text_before = vim_helper.buf.line_till_cursor\n            before = vim_helper.buf.line_till_cursor\n\n        with suspend_proxy_edits():\n            start = Position(vim_helper.buf.cursor.line, len(text_before))\n            end = Position(vim_helper.buf.cursor.line, len(before))\n            parent = None\n            if self._current_snippet:\n                # If cursor is set in pre-action, then action was modified\n                # cursor line, in that case we do not need to do any edits, it\n                # can break snippet\n                if not cursor_set_in_action:\n                    # It could be that our trigger contains the content of\n                    # TextObjects in our containing snippet. If this is indeed\n                    # the case, we have to make sure that those are properly\n                    # killed. We do this by pretending that the user deleted\n                    # and retyped the text that our trigger matched.\n                    edit_actions = [\n                        (\"D\", start.line, start.col, snippet.matched),\n                        (\"I\", start.line, start.col, snippet.matched),\n                    ]\n                    self._active_snippets[0].replay_user_edits(edit_actions)\n                parent = self._current_snippet.find_parent_for_new_to(start)\n            snippet_instance = snippet.launch(\n                text_before, self._visual_content, parent, start, end\n            )\n            # Open any folds this might have created\n            vim_helper.command(\"normal! zv\")\n\n            self._visual_content.reset()\n            self._active_snippets.append(snippet_instance)\n\n            with use_proxy_buffer(self._active_snippets, self._vstate):\n                with self._action_context():\n                    snippet.do_post_expand(\n                        snippet_instance.start,\n                        snippet_instance.end,\n                        self._active_snippets,\n                    )\n\n            self._vstate.remember_buffer(self._active_snippets[0])\n\n            if not self._snip_expanded_in_action:\n                self._jump(JumpDirection.FORWARD)\n            elif self._current_snippet.current_text != \"\":\n                self._jump(JumpDirection.FORWARD)\n            else:\n                self._current_snippet_is_done()\n\n            if self._inside_action:\n                self._snip_expanded_in_action = True\n\n    def _can_expand(self, autotrigger_only=False):\n        before = vim_helper.buf.line_till_cursor\n        return before, self._snips(before, False, autotrigger_only)\n\n    def _try_expand(self, autotrigger_only=False):\n        \"\"\"Try to expand a snippet in the current place.\"\"\"\n        before, snippets = self._can_expand(autotrigger_only)\n        if snippets:\n            # prefer snippets with context if any\n            snippets_with_context = [s for s in snippets if s.context]\n            if snippets_with_context:\n                snippets = snippets_with_context\n        if not snippets:\n            # No snippet found\n            return False\n        vim_helper.command(\"let &g:undolevels = &g:undolevels\")\n        if len(snippets) == 1:\n            snippet = snippets[0]\n        else:\n            snippet = _ask_snippets(snippets)\n            if not snippet:\n                return True\n        self._do_snippet(snippet, before)\n        vim_helper.command(\"let &g:undolevels = &g:undolevels\")\n        return True\n\n    def can_expand(self, autotrigger_only=False):\n        \"\"\"Check if we would be able to successfully find a snippet in the current position.\"\"\"\n        return bool(self._can_expand(autotrigger_only)[1])\n\n    def can_jump(self, direction):\n        if self._current_snippet == None:\n            return False\n        return self._current_snippet.has_next_tab(direction)\n\n    def can_jump_forwards(self):\n        return self.can_jump(JumpDirection.FORWARD)\n\n    def can_jump_backwards(self):\n        return self.can_jump(JumpDirection.BACKWARD)\n\n    def _toggle_autotrigger(self):\n        self._autotrigger = not self._autotrigger\n        return self._autotrigger\n\n    @property\n    def _current_snippet(self):\n        \"\"\"The current snippet or None.\"\"\"\n        if not self._active_snippets:\n            return None\n        return self._active_snippets[-1]\n\n    def _file_to_edit(self, requested_ft, bang):\n        \"\"\"Returns a file to be edited for the given requested_ft.\n\n        If 'bang' is empty a reasonable first choice is opened (see docs), otherwise\n        all files are considered and the user gets to choose.\n        \"\"\"\n        filetypes = []\n        if requested_ft:\n            filetypes.append(requested_ft)\n        else:\n            if bang:\n                filetypes.extend(self.get_buffer_filetypes())\n            else:\n                filetypes.append(self.get_buffer_filetypes()[0])\n\n        potentials = set()\n\n        dot_vim_dirs = vim_helper.get_dot_vim()\n        all_snippet_directories = find_all_snippet_directories()\n        has_storage_dir = (\n            vim_helper.eval(\n                \"exists('g:UltiSnipsSnippetStorageDirectoryForUltiSnipsEdit')\"\n            )\n            == \"1\"\n        )\n        if has_storage_dir:\n            snippet_storage_dir = vim_helper.eval(\n                \"g:UltiSnipsSnippetStorageDirectoryForUltiSnipsEdit\"\n            )\n            full_path = os.path.expanduser(snippet_storage_dir)\n            potentials.update(\n                _get_potential_snippet_filenames_to_edit(full_path, filetypes)\n            )\n        if len(all_snippet_directories) == 1:\n            # Most likely the user has set g:UltiSnipsSnippetDirectories to a\n            # single absolute path.\n            potentials.update(\n                _get_potential_snippet_filenames_to_edit(\n                    all_snippet_directories[0], filetypes\n                )\n            )\n\n        if (len(all_snippet_directories) != 1 and not has_storage_dir) or (\n            has_storage_dir and bang\n        ):\n            # Likely the array contains things like [\"UltiSnips\",\n            # \"mycoolsnippets\"] There is no more obvious way to edit than in\n            # the users vim config directory.\n            for snippet_dir in all_snippet_directories:\n                for dot_vim_dir in dot_vim_dirs:\n                    if Path(dot_vim_dir) != Path(snippet_dir).parent:\n                        continue\n                    potentials.update(\n                        _get_potential_snippet_filenames_to_edit(snippet_dir, filetypes)\n                    )\n\n        if bang:\n            for ft in filetypes:\n                potentials.update(find_all_snippet_files(ft))\n        else:\n            if not potentials:\n                _show_user_warning(\n                    \"UltiSnips was not able to find a default directory for snippets. \"\n                    \"Do any of \" + dot_vim_dirs.__str__() + \" exist AND contain \"\n                    \"any of the folders in g:UltiSnipsSnippetDirectories ? \"\n                    \"With default vim settings that would be: ~/.vim/UltiSnips \"\n                    \"Try :UltiSnipsEdit! instead of :UltiSnipsEdit.\"\n                )\n                return \"\"\n        return _select_and_create_file_to_edit(potentials)\n\n    @contextmanager\n    def _action_context(self):\n        try:\n            old_flag = self._inside_action\n            self._inside_action = True\n            yield\n        finally:\n            self._inside_action = old_flag\n\n    @err_to_scratch_buffer.wrap\n    def _track_change(self):\n        self._should_update_textobjects = True\n\n        try:\n            inserted_char = vim_helper.eval(\"v:char\")\n        except UnicodeDecodeError:\n            return\n\n        if isinstance(inserted_char, bytes):\n            return\n\n        try:\n            if inserted_char == \"\":\n                before = vim_helper.buf.line_till_cursor\n\n                if (\n                    self._autotrigger\n                    and before\n                    and self._last_change[0] != \"\"\n                    and before[-1] == self._last_change[0]\n                ):\n                    self._try_expand(autotrigger_only=True)\n        finally:\n            self._last_change = (inserted_char, vim_helper.buf.cursor)\n\n        if self._should_reset_visual and self._visual_content.mode == \"\":\n            self._visual_content.reset()\n\n        self._should_reset_visual = True\n\n    @err_to_scratch_buffer.wrap\n    def _refresh_snippets(self):\n        for _, source in self._snippet_sources:\n            source.refresh()\n\n\n    @err_to_scratch_buffer.wrap\n    def _check_filetype(self, ft):\n        \"\"\"Ensure snippets are loaded for the current filetype.\"\"\"\n        if ft not in self._filetypes:\n            self._filetypes.append(ft)\n            for _, source in self._snippet_sources:\n                source.must_ensure = True\n\n\nUltiSnips_Manager = SnippetManager(  # pylint:disable=invalid-name\n    vim.eval(\"g:UltiSnipsExpandTrigger\"),\n    vim.eval(\"g:UltiSnipsJumpForwardTrigger\"),\n    vim.eval(\"g:UltiSnipsJumpBackwardTrigger\"),\n)\n"
  },
  {
    "path": "pythonx/UltiSnips/test_diff.py",
    "content": "#!/usr/bin/env python3\n# encoding: utf-8\n\n# pylint: skip-file\n\nimport unittest\n\nfrom diff import diff, guess_edit\nfrom position import Position\nfrom typing import List\n\n\ndef transform(a, cmds):\n    buf = a.split(\"\\n\")\n\n    for cmd in cmds:\n        ctype, line, col, char = cmd\n        if ctype == \"D\":\n            if char != \"\\n\":\n                buf[line] = buf[line][:col] + buf[line][col + len(char) :]\n            else:\n                buf[line] = buf[line] + buf[line + 1]\n                del buf[line + 1]\n        elif ctype == \"I\":\n            buf[line] = buf[line][:col] + char + buf[line][col:]\n        buf = \"\\n\".join(buf).split(\"\\n\")\n    return \"\\n\".join(buf)\n\n\nclass _BaseGuessing:\n    def runTest(self):\n        rv, es = guess_edit(\n            self.initial_line, self.a, self.b, Position(*self.ppos), Position(*self.pos)\n        )\n        self.assertEqual(rv, True)\n        self.assertEqual(self.wanted, es)\n\n\nclass TestGuessing_Noop0(_BaseGuessing, unittest.TestCase):\n    a: List[str] = []\n    b: List[str] = []\n    initial_line = 0\n    ppos, pos = (0, 6), (0, 7)\n    wanted = ()\n\n\nclass TestGuessing_InsertOneChar(_BaseGuessing, unittest.TestCase):\n    a, b = [\"Hello  World\"], [\"Hello   World\"]\n    initial_line = 0\n    ppos, pos = (0, 6), (0, 7)\n    wanted = ((\"I\", 0, 6, \" \"),)\n\n\nclass TestGuessing_InsertOneChar1(_BaseGuessing, unittest.TestCase):\n    a, b = [\"Hello  World\"], [\"Hello   World\"]\n    initial_line = 0\n    ppos, pos = (0, 7), (0, 8)\n    wanted = ((\"I\", 0, 7, \" \"),)\n\n\nclass TestGuessing_BackspaceOneChar(_BaseGuessing, unittest.TestCase):\n    a, b = [\"Hello  World\"], [\"Hello World\"]\n    initial_line = 0\n    ppos, pos = (0, 7), (0, 6)\n    wanted = ((\"D\", 0, 6, \" \"),)\n\n\nclass TestGuessing_DeleteOneChar(_BaseGuessing, unittest.TestCase):\n    a, b = [\"Hello  World\"], [\"Hello World\"]\n    initial_line = 0\n    ppos, pos = (0, 5), (0, 5)\n    wanted = ((\"D\", 0, 5, \" \"),)\n\n\nclass _Base:\n    def runTest(self):\n        es = diff(self.a, self.b)\n        tr = transform(self.a, es)\n        self.assertEqual(self.b, tr)\n        self.assertEqual(self.wanted, es)\n\n\nclass TestEmptyString(_Base, unittest.TestCase):\n    a, b = \"\", \"\"\n    wanted = ()\n\n\nclass TestAllMatch(_Base, unittest.TestCase):\n    a, b = \"abcdef\", \"abcdef\"\n    wanted = ()\n\n\nclass TestLotsaNewlines(_Base, unittest.TestCase):\n    a, b = \"Hello\", \"Hello\\nWorld\\nWorld\\nWorld\"\n    wanted = (\n        (\"I\", 0, 5, \"\\n\"),\n        (\"I\", 1, 0, \"World\"),\n        (\"I\", 1, 5, \"\\n\"),\n        (\"I\", 2, 0, \"World\"),\n        (\"I\", 2, 5, \"\\n\"),\n        (\"I\", 3, 0, \"World\"),\n    )\n\n\nclass TestCrash(_Base, unittest.TestCase):\n    a = \"hallo Blah mitte=sdfdsfsd\\nhallo kjsdhfjksdhfkjhsdfkh mittekjshdkfhkhsdfdsf\"\n    b = \"hallo Blah mitte=sdfdsfsd\\nhallo b mittekjshdkfhkhsdfdsf\"\n    wanted = ((\"D\", 1, 6, \"kjsdhfjksdhfkjhsdfkh\"), (\"I\", 1, 6, \"b\"))\n\n\nclass TestRealLife(_Base, unittest.TestCase):\n    a = \"hallo End Beginning\"\n    b = \"hallo End t\"\n    wanted = ((\"D\", 0, 10, \"Beginning\"), (\"I\", 0, 10, \"t\"))\n\n\nclass TestRealLife1(_Base, unittest.TestCase):\n    a = \"Vorne hallo Hinten\"\n    b = \"Vorne hallo  Hinten\"\n    wanted = ((\"I\", 0, 11, \" \"),)\n\n\nclass TestWithNewline(_Base, unittest.TestCase):\n    a = \"First Line\\nSecond Line\"\n    b = \"n\"\n    wanted = (\n        (\"D\", 0, 0, \"First Line\"),\n        (\"D\", 0, 0, \"\\n\"),\n        (\"D\", 0, 0, \"Second Line\"),\n        (\"I\", 0, 0, \"n\"),\n    )\n\n\nclass TestCheapDelete(_Base, unittest.TestCase):\n    a = \"Vorne hallo Hinten\"\n    b = \"Vorne Hinten\"\n    wanted = ((\"D\", 0, 5, \" hallo\"),)\n\n\nclass TestNoSubstring(_Base, unittest.TestCase):\n    a, b = \"abc\", \"def\"\n    wanted = ((\"D\", 0, 0, \"abc\"), (\"I\", 0, 0, \"def\"))\n\n\nclass TestCommonCharacters(_Base, unittest.TestCase):\n    a, b = \"hasomelongertextbl\", \"hol\"\n    wanted = ((\"D\", 0, 1, \"asomelongertextb\"), (\"I\", 0, 1, \"o\"))\n\n\nclass TestUltiSnipsProblem(_Base, unittest.TestCase):\n    a = \"this is it this is it this is it\"\n    b = \"this is it a this is it\"\n    wanted = ((\"D\", 0, 11, \"this is it\"), (\"I\", 0, 11, \"a\"))\n\n\nclass MatchIsTooCheap(_Base, unittest.TestCase):\n    a = \"stdin.h\"\n    b = \"s\"\n    wanted = ((\"D\", 0, 1, \"tdin.h\"),)\n\n\nclass MultiLine(_Base, unittest.TestCase):\n    a = \"hi first line\\nsecond line first line\\nsecond line world\"\n    b = \"hi first line\\nsecond line k world\"\n\n    wanted = (\n        (\"D\", 1, 12, \"first line\"),\n        (\"D\", 1, 12, \"\\n\"),\n        (\"D\", 1, 12, \"second line\"),\n        (\"I\", 1, 12, \"k\"),\n    )\n\n\nif __name__ == \"__main__\":\n    unittest.main()\n    # k = TestEditScript()\n    # unittest.TextTestRunner().run(k)\n"
  },
  {
    "path": "pythonx/UltiSnips/test_position.py",
    "content": "#!/usr/bin/env python3\n# encoding: utf-8\n\n# pylint: skip-file\n\nimport unittest\n\nfrom position import Position\n\n\nclass _MPBase:\n    def runTest(self):\n        obj = Position(*self.obj)\n        for pivot, delta, wanted in self.steps:\n            obj.move(Position(*pivot), Position(*delta))\n            self.assertEqual(Position(*wanted), obj)\n\n\nclass MovePosition_DelSameLine(_MPBase, unittest.TestCase):\n    # hello wor*ld -> h*ld -> hl*ld\n    obj = (0, 9)\n    steps = (((0, 1), (0, -8), (0, 1)), ((0, 1), (0, 1), (0, 2)))\n\n\nclass MovePosition_DelSameLine1(_MPBase, unittest.TestCase):\n    # hel*lo world -> hel*world -> hel*worl\n    obj = (0, 3)\n    steps = (((0, 4), (0, -3), (0, 3)), ((0, 8), (0, -1), (0, 3)))\n\n\nclass MovePosition_InsSameLine1(_MPBase, unittest.TestCase):\n    # hel*lo world -> hel*woresld\n    obj = (0, 3)\n    steps = (\n        ((0, 4), (0, -3), (0, 3)),\n        ((0, 6), (0, 2), (0, 3)),\n        ((0, 8), (0, -1), (0, 3)),\n    )\n\n\nclass MovePosition_InsSameLine2(_MPBase, unittest.TestCase):\n    # hello wor*ld -> helesdlo wor*ld\n    obj = (0, 9)\n    steps = (((0, 3), (0, 3), (0, 12)),)\n\n\nclass MovePosition_DelSecondLine(_MPBase, unittest.TestCase):\n    # hello world. sup   hello world.*a, was\n    # *a, was            ach nix\n    # ach nix\n    obj = (1, 0)\n    steps = (((0, 12), (0, -4), (1, 0)), ((0, 12), (-1, 0), (0, 12)))\n\n\nclass MovePosition_DelSecondLine1(_MPBase, unittest.TestCase):\n    # hello world. sup\n    # a, *was\n    # ach nix\n    # hello world.a*was\n    # ach nix\n    obj = (1, 3)\n    steps = (\n        ((0, 12), (0, -4), (1, 3)),\n        ((0, 12), (-1, 0), (0, 15)),\n        ((0, 12), (0, -3), (0, 12)),\n        ((0, 12), (0, 1), (0, 13)),\n    )\n\n\nif __name__ == \"__main__\":\n    unittest.main()\n"
  },
  {
    "path": "pythonx/UltiSnips/text.py",
    "content": "#!/usr/bin/env python3\n# encoding: utf-8\n\n\"\"\"Utilities to deal with text.\"\"\"\n\n\ndef unescape(text):\n    \"\"\"Removes '\\\\' escaping from 'text'.\"\"\"\n    rv = \"\"\n    i = 0\n    while i < len(text):\n        if i + 1 < len(text) and text[i] == \"\\\\\":\n            rv += text[i + 1]\n            i += 1\n        else:\n            rv += text[i]\n        i += 1\n    return rv\n\n\ndef escape(text, chars):\n    \"\"\"Escapes all characters in 'chars' in text using backspaces.\"\"\"\n    rv = \"\"\n    for char in text:\n        if char in chars:\n            rv += \"\\\\\"\n        rv += char\n    return rv\n\n\ndef fill_in_whitespace(text):\n    \"\"\"Returns 'text' with escaped whitespace replaced through whitespaces.\"\"\"\n    text = text.replace(r\"\\n\", \"\\n\")\n    text = text.replace(r\"\\t\", \"\\t\")\n    text = text.replace(r\"\\r\", \"\\r\")\n    text = text.replace(r\"\\a\", \"\\a\")\n    text = text.replace(r\"\\b\", \"\\b\")\n    return text\n\n\ndef head_tail(line):\n    \"\"\"Returns the first word in 'line' and the rest of 'line' or None if the\n    line is too short.\"\"\"\n    generator = (t.strip() for t in line.split(None, 1))\n    head = next(generator).strip()\n    tail = \"\"\n    try:\n        tail = next(generator).strip()\n    except StopIteration:\n        pass\n    return head, tail\n\n\nclass LineIterator:\n\n    \"\"\"Convenience class that keeps track of line numbers in files.\"\"\"\n\n    def __init__(self, text):\n        self._line_index = -1\n        self._lines = list(text.splitlines(True))\n\n    def __iter__(self):\n        return self\n\n    def __next__(self):\n        \"\"\"Returns the next line.\"\"\"\n        if self._line_index + 1 < len(self._lines):\n            self._line_index += 1\n            return self._lines[self._line_index]\n        raise StopIteration()\n\n    @property\n    def line_index(self):\n        \"\"\"The 1 based line index in the current file.\"\"\"\n        return self._line_index + 1\n\n    def peek(self):\n        \"\"\"Returns the next line (if there is any, otherwise None) without\n        advancing the iterator.\"\"\"\n        try:\n            return self._lines[self._line_index + 1]\n        except IndexError:\n            return None\n"
  },
  {
    "path": "pythonx/UltiSnips/text_objects/__init__.py",
    "content": "#!/usr/bin/env python3\n# encoding: utf-8\n\n\"\"\"Public facing classes for TextObjects.\"\"\"\n\nfrom UltiSnips.text_objects.escaped_char import EscapedChar\nfrom UltiSnips.text_objects.mirror import Mirror\nfrom UltiSnips.text_objects.python_code import PythonCode\nfrom UltiSnips.text_objects.shell_code import ShellCode\nfrom UltiSnips.text_objects.snippet_instance import SnippetInstance\nfrom UltiSnips.text_objects.tabstop import TabStop\nfrom UltiSnips.text_objects.transformation import Transformation\nfrom UltiSnips.text_objects.viml_code import VimLCode\nfrom UltiSnips.text_objects.visual import Visual\nfrom UltiSnips.text_objects.choices import Choices\n"
  },
  {
    "path": "pythonx/UltiSnips/text_objects/base.py",
    "content": "#!/usr/bin/env python3\n# encoding: utf-8\n\n\"\"\"Base classes for all text objects.\"\"\"\n\nfrom UltiSnips import vim_helper\nfrom UltiSnips.position import Position\n\n\ndef _calc_end(text, start):\n    \"\"\"Calculate the end position of the 'text' starting at 'start.\"\"\"\n    if len(text) == 1:\n        new_end = start + Position(0, len(text[0]))\n    else:\n        new_end = Position(start.line + len(text) - 1, len(text[-1]))\n    return new_end\n\n\ndef _replace_text(buf, start, end, text):\n    \"\"\"Copy the given text to the current buffer, overwriting the span 'start'\n    to 'end'.\"\"\"\n    lines = text.split(\"\\n\")\n\n    new_end = _calc_end(lines, start)\n\n    before = buf[start.line][: start.col]\n    after = buf[end.line][end.col :]\n\n    new_lines = []\n    if len(lines):\n        new_lines.append(before + lines[0])\n        new_lines.extend(lines[1:])\n        new_lines[-1] += after\n    buf[start.line : end.line + 1] = new_lines\n\n    return new_end\n\n\n# These classes use their subclasses a lot and we really do not want to expose\n# their functions more globally.\n# pylint: disable=protected-access\n\n\nclass TextObject:\n\n    \"\"\"Represents any object in the text that has a span in any ways.\"\"\"\n\n    def __init__(\n        self, parent, token_or_start, end=None, initial_text=\"\", tiebreaker=None\n    ):\n        self._parent = parent\n\n        if end is not None:  # Took 4 arguments\n            self._start = token_or_start\n            self._end = end\n            self._initial_text = initial_text\n        else:  # Initialize from token\n            self._start = token_or_start.start\n            self._end = token_or_start.end\n            self._initial_text = token_or_start.initial_text\n        self._tiebreaker = tiebreaker or Position(self._start.line, self._end.line)\n        if parent is not None:\n            parent._add_child(self)\n\n    def _move(self, pivot, diff):\n        \"\"\"Move this object by 'diff' while 'pivot' is the point of change.\"\"\"\n        self._start.move(pivot, diff)\n        self._end.move(pivot, diff)\n\n    def __lt__(self, other):\n        me_tuple = (\n            self.start.line,\n            self.start.col,\n            self._tiebreaker.line,\n            self._tiebreaker.col,\n        )\n        other_tuple = (\n            other._start.line,\n            other._start.col,\n            other._tiebreaker.line,\n            other._tiebreaker.col,\n        )\n        return me_tuple < other_tuple\n\n    def __le__(self, other):\n        me_tuple = (\n            self._start.line,\n            self._start.col,\n            self._tiebreaker.line,\n            self._tiebreaker.col,\n        )\n        other_tuple = (\n            other._start.line,\n            other._start.col,\n            other._tiebreaker.line,\n            other._tiebreaker.col,\n        )\n        return me_tuple <= other_tuple\n\n    def __repr__(self):\n        ct = \"\"\n        try:\n            ct = self.current_text\n        except IndexError:\n            ct = \"<err>\"\n\n        return \"%s(%r->%r,%r)\" % (self.__class__.__name__, self._start, self._end, ct)\n\n    @property\n    def current_text(self):\n        \"\"\"The current text of this object.\"\"\"\n        if self._start.line == self._end.line:\n            return vim_helper.buf[self._start.line][self._start.col : self._end.col]\n        else:\n            lines = [vim_helper.buf[self._start.line][self._start.col :]]\n            lines.extend(vim_helper.buf[self._start.line + 1 : self._end.line])\n            lines.append(vim_helper.buf[self._end.line][: self._end.col])\n            return \"\\n\".join(lines)\n\n    @property\n    def start(self):\n        \"\"\"The start position.\"\"\"\n        return self._start\n\n    @property\n    def end(self):\n        \"\"\"The end position.\"\"\"\n        return self._end\n\n    def overwrite_with_initial_text(self, buf):\n        self.overwrite(buf, self._initial_text)\n\n    def overwrite(self, buf, gtext):\n        \"\"\"Overwrite the text of this object in the Vim Buffer and update its\n        length information.\n\n        If 'gtext' is None use the initial text of this object.\n\n        \"\"\"\n        # We explicitly do not want to move our children around here as we\n        # either have non or we are replacing text initially which means we do\n        # not want to mess with their positions\n        if self.current_text == gtext:\n            return\n        old_end = self._end\n        self._end = _replace_text(buf, self._start, self._end, gtext)\n        if self._parent:\n            self._parent._child_has_moved(\n                self._parent._children.index(self),\n                min(old_end, self._end),\n                self._end.delta(old_end),\n            )\n\n    def _update(self, done, buf):\n        \"\"\"Update this object inside 'buf' which is a list of lines.\n\n        Return False if you need to be called again for this edit cycle.\n        Otherwise return True.\n\n        \"\"\"\n        raise NotImplementedError(\"Must be implemented by subclasses.\")\n\n\nclass EditableTextObject(TextObject):\n\n    \"\"\"This base class represents any object in the text that can be changed by\n    the user.\"\"\"\n\n    def __init__(self, *args, **kwargs):\n        TextObject.__init__(self, *args, **kwargs)\n        self._children = []\n        self._tabstops = {}\n\n    ##############\n    # Properties #\n    ##############\n    @property\n    def children(self):\n        \"\"\"List of all children.\"\"\"\n        return self._children\n\n    @property\n    def _editable_children(self):\n        \"\"\"List of all children that are EditableTextObjects.\"\"\"\n        return [\n            child for child in self._children if isinstance(child, EditableTextObject)\n        ]\n\n    ####################\n    # Public Functions #\n    ####################\n    def find_parent_for_new_to(self, pos):\n        \"\"\"Figure out the parent object for something at 'pos'.\"\"\"\n        for children in self._editable_children:\n            if children._start <= pos < children._end:\n                return children.find_parent_for_new_to(pos)\n            if children._start == pos and pos == children._end:\n                return children.find_parent_for_new_to(pos)\n        return self\n\n    ###############################\n    # Private/Protected functions #\n    ###############################\n    def _do_edit(self, cmd, ctab=None):\n        \"\"\"Apply the edit 'cmd' to this object.\"\"\"\n        ctype, line, col, text = cmd\n        assert (\"\\n\" not in text) or (text == \"\\n\")\n        pos = Position(line, col)\n\n        to_kill = set()\n        new_cmds = []\n        for child in self._children:\n            if ctype == \"I\":  # Insertion\n                if child._start < pos < Position(\n                    child._end.line, child._end.col\n                ) and isinstance(child, NoneditableTextObject):\n                    to_kill.add(child)\n                    new_cmds.append(cmd)\n                    break\n                elif (child._start <= pos <= child._end) and isinstance(\n                    child, EditableTextObject\n                ):\n                    if pos == child.end and not child.children:\n                        try:\n                            if ctab.number != child.number:\n                                continue\n                        except AttributeError:\n                            pass\n                    child._do_edit(cmd, ctab)\n                    return\n            else:  # Deletion\n                delend = (\n                    pos + Position(0, len(text))\n                    if text != \"\\n\"\n                    else Position(line + 1, 0)\n                )\n                if (child._start <= pos < child._end) and (\n                    child._start < delend <= child._end\n                ):\n                    # this edit command is completely for the child\n                    if isinstance(child, NoneditableTextObject):\n                        to_kill.add(child)\n                        new_cmds.append(cmd)\n                        break\n                    else:\n                        child._do_edit(cmd, ctab)\n                        return\n                elif (\n                    pos < child._start and child._end <= delend and child.start < delend\n                ) or (pos <= child._start and child._end < delend):\n                    # Case: this deletion removes the child\n                    to_kill.add(child)\n                    new_cmds.append(cmd)\n                    break\n                elif pos < child._start and (child._start < delend <= child._end):\n                    # Case: partially for us, partially for the child\n                    my_text = text[: (child._start - pos).col]\n                    c_text = text[(child._start - pos).col :]\n                    new_cmds.append((ctype, line, col, my_text))\n                    new_cmds.append((ctype, line, col, c_text))\n                    break\n                elif delend >= child._end and (child._start <= pos < child._end):\n                    # Case: partially for us, partially for the child\n                    c_text = text[(child._end - pos).col :]\n                    my_text = text[: (child._end - pos).col]\n                    new_cmds.append((ctype, line, col, c_text))\n                    new_cmds.append((ctype, line, col, my_text))\n                    break\n\n        for child in to_kill:\n            self._del_child(child)\n        if len(new_cmds):\n            for child in new_cmds:\n                self._do_edit(child)\n            return\n\n        # We have to handle this ourselves\n        delta = Position(1, 0) if text == \"\\n\" else Position(0, len(text))\n        if ctype == \"D\":\n            # Makes no sense to delete in empty textobject\n            if self._start == self._end:\n                return\n            delta.line *= -1\n            delta.col *= -1\n        pivot = Position(line, col)\n        idx = -1\n        for cidx, child in enumerate(self._children):\n            if child._start < pivot <= child._end:\n                idx = cidx\n        self._child_has_moved(idx, pivot, delta)\n\n    def _move(self, pivot, diff):\n        TextObject._move(self, pivot, diff)\n\n        for child in self._children:\n            child._move(pivot, diff)\n\n    def _child_has_moved(self, idx, pivot, diff):\n        \"\"\"Called when a the child with 'idx' has moved behind 'pivot' by\n        'diff'.\"\"\"\n        self._end.move(pivot, diff)\n\n        for child in self._children[idx + 1 :]:\n            child._move(pivot, diff)\n\n        if self._parent:\n            self._parent._child_has_moved(\n                self._parent._children.index(self), pivot, diff\n            )\n\n    def _get_next_tab(self, number):\n        \"\"\"Returns the next tabstop after 'number'.\"\"\"\n        if not len(self._tabstops.keys()):\n            return\n        tno_max = max(self._tabstops.keys())\n\n        possible_sol = []\n        i = number + 1\n        while i <= tno_max:\n            if i in self._tabstops:\n                possible_sol.append((i, self._tabstops[i]))\n                break\n            i += 1\n\n        child = [c._get_next_tab(number) for c in self._editable_children]\n        child = [c for c in child if c]\n\n        possible_sol += child\n\n        if not len(possible_sol):\n            return None\n\n        return min(possible_sol)\n\n    def _get_prev_tab(self, number):\n        \"\"\"Returns the previous tabstop before 'number'.\"\"\"\n        if not len(self._tabstops.keys()):\n            return\n        tno_min = min(self._tabstops.keys())\n\n        possible_sol = []\n        i = number - 1\n        while i >= tno_min and i > 0:\n            if i in self._tabstops:\n                possible_sol.append((i, self._tabstops[i]))\n                break\n            i -= 1\n\n        child = [c._get_prev_tab(number) for c in self._editable_children]\n        child = [c for c in child if c]\n\n        possible_sol += child\n\n        if not len(possible_sol):\n            return None\n\n        return max(possible_sol)\n\n    def _get_tabstop(self, requester, number):\n        \"\"\"Returns the tabstop 'number'.\n\n        'requester' is the class that is interested in this.\n\n        \"\"\"\n        if number in self._tabstops:\n            return self._tabstops[number]\n        for child in self._editable_children:\n            if child is requester:\n                continue\n            rv = child._get_tabstop(self, number)\n            if rv is not None:\n                return rv\n        if self._parent and requester is not self._parent:\n            return self._parent._get_tabstop(self, number)\n\n    def _update(self, done, buf):\n        if all((child in done) for child in self._children):\n            assert self not in done\n            done.add(self)\n        return True\n\n    def _add_child(self, child):\n        \"\"\"Add 'child' as a new child of this text object.\"\"\"\n        self._children.append(child)\n        self._children.sort()\n\n    def _del_child(self, child):\n        \"\"\"Delete this 'child'.\"\"\"\n        child._parent = None\n        self._children.remove(child)\n\n        # If this is a tabstop, delete it. Might have been deleted already if\n        # it was nested.\n        try:\n            del self._tabstops[child.number]\n        except (AttributeError, KeyError):\n            pass\n\n\nclass NoneditableTextObject(TextObject):\n\n    \"\"\"All passive text objects that the user can't edit by hand.\"\"\"\n\n    def _update(self, done, buf):\n        return True\n"
  },
  {
    "path": "pythonx/UltiSnips/text_objects/choices.py",
    "content": "#!/usr/bin/env python3\n# encoding: utf-8\n\n\"\"\"Choices are enumeration values you can choose, by selecting index number.\nIt is a special TabStop, its content are taken literally, thus said, they will not be parsed recursively.\n\"\"\"\n\nfrom UltiSnips import vim_helper\nfrom UltiSnips.position import Position\nfrom UltiSnips.text_objects.tabstop import TabStop\nfrom UltiSnips.snippet.parsing.lexer import ChoicesToken\n\n\nclass Choices(TabStop):\n    \"\"\"See module docstring.\"\"\"\n\n    def __init__(self, parent, token: ChoicesToken):\n        self._number = token.number  # for TabStop property 'number'\n        self._initial_text = token.initial_text\n\n        # empty choice will be discarded\n        self._choice_list = [s for s in token.choice_list if len(s) > 0]\n        self._done = False\n        self._input_chars = list(self._initial_text)\n        self._has_been_updated = False\n\n        TabStop.__init__(self, parent, token)\n\n    def _get_choices_placeholder(self) -> str:\n        # prefix choices with index number\n        # e.g. 'a,b,c' -> '1.a|2.b|3.c'\n        text_segs = []\n        index = 1\n        for choice in self._choice_list:\n            text_segs.append(\"%s.%s\" % (index, choice))\n            index += 1\n        text = \"|\".join(text_segs)\n        return text\n\n    def _update(self, done, buf):\n        if self._done:\n            return True\n\n        # expand initial text with select prefix number, only once\n        if not self._has_been_updated:\n            # '${1:||}' is not valid choice, should be downgraded to plain tabstop\n            are_choices_valid = len(self._choice_list) > 0\n            if are_choices_valid:\n                text = self._get_choices_placeholder()\n                self.overwrite(buf, text)\n            else:\n                self._done = True\n            self._has_been_updated = True\n        return True\n\n    def _do_edit(self, cmd, ctab=None):\n        if self._done:\n            # do as what parent class do\n            TabStop._do_edit(self, cmd, ctab)\n            return\n\n        ctype, line, col, cmd_text = cmd\n\n        cursor = vim_helper.get_cursor_pos()\n        [buf_num, cursor_line] = map(int, cursor[0:2])\n\n        # trying to get what user inputted in current buffer\n        if ctype == \"I\":\n            self._input_chars.append(cmd_text)\n        elif ctype == \"D\":\n            line_text = vim_helper.buf[cursor_line - 1]\n            self._input_chars = list(line_text[self._start.col : col])\n\n        inputted_text = \"\".join(self._input_chars)\n\n        if not self._input_chars:\n            return\n\n        # if there are more than 9 selection candidates,\n        # may need to wait for 2 inputs to determine selection number\n        is_all_digits = True\n        has_selection_terminator = False\n\n        # input string sub string of pure digits\n        inputted_text_for_num = inputted_text\n        for [i, s] in enumerate(self._input_chars):\n            if s == \" \":  # treat space as a terminator for selection\n                has_selection_terminator = True\n                inputted_text_for_num = inputted_text[0:i]\n            elif not s.isdigit():\n                is_all_digits = False\n\n        should_continue_input = False\n        if is_all_digits or has_selection_terminator:\n            index_strs = [\n                str(index) for index in list(range(1, len(self._choice_list) + 1))\n            ]\n            matched_index_strs = list(\n                filter(lambda s: s.startswith(inputted_text_for_num), index_strs)\n            )\n            remained_choice_list = []\n            if len(matched_index_strs) == 0:\n                remained_choice_list = []\n            elif has_selection_terminator:\n                if inputted_text_for_num:\n                    num = int(inputted_text_for_num)\n                    remained_choice_list = list(self._choice_list)[num - 1 : num]\n            elif len(matched_index_strs) == 1:\n                num = int(inputted_text_for_num)\n                remained_choice_list = list(self._choice_list)[num - 1 : num]\n            else:\n                should_continue_input = True\n        else:\n            remained_choice_list = []\n\n        if should_continue_input:\n            # will wait for further input\n            return\n\n        buf = vim_helper.buf\n        if len(remained_choice_list) == 0:\n            # no matched choice, should quit selection and go on with inputted text\n            overwrite_text = inputted_text_for_num\n            self._done = True\n        elif len(remained_choice_list) == 1:\n            # only one match\n            matched_choice = remained_choice_list[0]\n            overwrite_text = matched_choice\n            self._done = True\n\n        if overwrite_text is not None:\n            old_end_col = self._end.col\n\n            # change _end.col, thus `overwrite` won't alter texts after this tabstop\n            displayed_text_end_col = self._start.col + len(inputted_text)\n            self._end.col = displayed_text_end_col\n            self.overwrite(buf, overwrite_text)\n\n            # notify all tabstops those in the same line and after this to adjust their positions\n            pivot = Position(line, old_end_col)\n            diff_col = displayed_text_end_col - old_end_col\n            self._parent._child_has_moved(\n                self._parent.children.index(self), pivot, Position(0, diff_col)\n            )\n\n            vim_helper.set_cursor_from_pos([buf_num, cursor_line, self._end.col + 1])\n\n    def __repr__(self):\n        return \"Choices(%s,%r->%r,%r)\" % (\n            self._number,\n            self._start,\n            self._end,\n            self._initial_text,\n        )\n"
  },
  {
    "path": "pythonx/UltiSnips/text_objects/escaped_char.py",
    "content": "#!/usr/bin/env python3\n# encoding: utf-8\n\n\"\"\"See module comment.\"\"\"\n\nfrom UltiSnips.text_objects.base import NoneditableTextObject\n\n\nclass EscapedChar(NoneditableTextObject):\n\n    r\"\"\"\n    This class is a escape char like \\$. It is handled in a text object to make\n    sure that siblings are correctly moved after replacing the text.\n\n    This is a base class without functionality just to mark it in the code.\n    \"\"\"\n"
  },
  {
    "path": "pythonx/UltiSnips/text_objects/mirror.py",
    "content": "#!/usr/bin/env python3\n# encoding: utf-8\n\n\"\"\"A Mirror object contains the same text as its related tabstop.\"\"\"\n\nfrom UltiSnips.text_objects.base import NoneditableTextObject\n\n\nclass Mirror(NoneditableTextObject):\n\n    \"\"\"See module docstring.\"\"\"\n\n    def __init__(self, parent, tabstop, token):\n        NoneditableTextObject.__init__(self, parent, token)\n        self._ts = tabstop\n\n    def _update(self, done, buf):\n        if self._ts.is_killed:\n            self.overwrite(buf, \"\")\n            self._parent._del_child(self)  # pylint:disable=protected-access\n            return True\n\n        if self._ts not in done:\n            return False\n\n        self.overwrite(buf, self._get_text())\n        return True\n\n    def _get_text(self):\n        \"\"\"Returns the text used for mirroring.\n\n        Overwritten by base classes.\n\n        \"\"\"\n        return self._ts.current_text\n"
  },
  {
    "path": "pythonx/UltiSnips/text_objects/python_code.py",
    "content": "#!/usr/bin/env python3\n# encoding: utf-8\n\n\"\"\"Implements `!p ` interpolation.\"\"\"\n\nimport os\nfrom collections import namedtuple\n\nfrom UltiSnips import vim_helper\nfrom UltiSnips.indent_util import IndentUtil\nfrom UltiSnips.text_objects.base import NoneditableTextObject\nfrom UltiSnips.vim_state import _Placeholder\nimport UltiSnips.snippet_manager\n\n# We'll end up compiling the global snippets for every snippet so\n# caching compile() should pay off\nfrom functools import lru_cache\n\n\n@lru_cache(maxsize=None)\ndef cached_compile(*args):\n    return compile(*args)\n\n\nclass _Tabs:\n\n    \"\"\"Allows access to tabstop content via t[] inside of python code.\"\"\"\n\n    def __init__(self, to):\n        self._to = to\n\n    def __getitem__(self, no):\n        ts = self._to._get_tabstop(self._to, int(no))  # pylint:disable=protected-access\n        if ts is None:\n            return \"\"\n        return ts.current_text\n\n    def __setitem__(self, no, value):\n        ts = self._to._get_tabstop(self._to, int(no))  # pylint:disable=protected-access\n        if ts is None:\n            return\n        # TODO(sirver): The buffer should be passed into the object on construction.\n        ts.overwrite(vim_helper.buf, value)\n\n\n_VisualContent = namedtuple(\"_VisualContent\", [\"mode\", \"text\"])\n\n\nclass SnippetUtilForAction(dict):\n    def __init__(self, *args, **kwargs):\n        super(SnippetUtilForAction, self).__init__(*args, **kwargs)\n        self.__dict__ = self\n\n    def expand_anon(self, *args, **kwargs):\n        UltiSnips.snippet_manager.UltiSnips_Manager.expand_anon(*args, **kwargs)\n        self.cursor.preserve()\n\n\nclass SnippetUtil:\n\n    \"\"\"Provides easy access to indentation, etc.\n\n    This is the 'snip' object in python code.\n\n    \"\"\"\n\n    def __init__(self, initial_indent, vmode, vtext, context, parent):\n        self._ind = IndentUtil()\n        self._visual = _VisualContent(vmode, vtext)\n        self._initial_indent = self._ind.indent_to_spaces(initial_indent)\n        self._reset(\"\")\n        self._context = context\n        self._start = parent.start\n        self._end = parent.end\n        self._parent = parent\n\n    def _reset(self, cur):\n        \"\"\"Gets the snippet ready for another update.\n\n        :cur: the new value for c.\n\n        \"\"\"\n        self._ind.reset()\n        self._cur = cur\n        self._rv = \"\"\n        self._changed = False\n        self.reset_indent()\n\n    def shift(self, amount=1):\n        \"\"\"Shifts the indentation level. Note that this uses the shiftwidth\n        because thats what code formatters use.\n\n        :amount: the amount by which to shift.\n\n        \"\"\"\n        self.indent += \" \" * self._ind.shiftwidth * amount\n\n    def unshift(self, amount=1):\n        \"\"\"Unshift the indentation level. Note that this uses the shiftwidth\n        because thats what code formatters use.\n\n        :amount: the amount by which to unshift.\n\n        \"\"\"\n        by = -self._ind.shiftwidth * amount\n        try:\n            self.indent = self.indent[:by]\n        except IndexError:\n            self.indent = \"\"\n\n    def mkline(self, line=\"\", indent=None):\n        \"\"\"Creates a properly set up line.\n\n        :line: the text to add\n        :indent: the indentation to have at the beginning\n                 if None, it uses the default amount\n\n        \"\"\"\n        if indent is None:\n            indent = self.indent\n            # this deals with the fact that the first line is\n            # already properly indented\n            if \"\\n\" not in self._rv:\n                try:\n                    indent = indent[len(self._initial_indent) :]\n                except IndexError:\n                    indent = \"\"\n            indent = self._ind.spaces_to_indent(indent)\n\n        return indent + line\n\n    def reset_indent(self):\n        \"\"\"Clears the indentation.\"\"\"\n        self.indent = self._initial_indent\n\n    # Utility methods\n    @property\n    def fn(self):  # pylint:disable=no-self-use,invalid-name\n        \"\"\"The filename.\"\"\"\n        return vim_helper.eval('expand(\"%:t\")') or \"\"\n\n    @property\n    def basename(self):  # pylint:disable=no-self-use\n        \"\"\"The filename without extension.\"\"\"\n        return vim_helper.eval('expand(\"%:t:r\")') or \"\"\n\n    @property\n    def ft(self):  # pylint:disable=invalid-name\n        \"\"\"The filetype.\"\"\"\n        return self.opt(\"&filetype\", \"\")\n\n    @property\n    def rv(self):  # pylint:disable=invalid-name\n        \"\"\"The return value.\n\n        The text to insert at the location of the placeholder.\n\n        \"\"\"\n        return self._rv\n\n    @rv.setter\n    def rv(self, value):  # pylint:disable=invalid-name\n        \"\"\"See getter.\"\"\"\n        self._changed = True\n        self._rv = value\n\n    @property\n    def _rv_changed(self):\n        \"\"\"True if rv has changed.\"\"\"\n        return self._changed\n\n    @property\n    def c(self):  # pylint:disable=invalid-name\n        \"\"\"The current text of the placeholder.\"\"\"\n        return self._cur\n\n    @property\n    def v(self):  # pylint:disable=invalid-name\n        \"\"\"Content of visual expansions.\"\"\"\n        return self._visual\n\n    @property\n    def p(self):\n        if self._parent.current_placeholder:\n            return self._parent.current_placeholder\n        return _Placeholder(\"\", 0, 0)\n\n    @property\n    def context(self):\n        return self._context\n\n    def opt(self, option, default=None):  # pylint:disable=no-self-use\n        \"\"\"Gets a Vim variable.\"\"\"\n        if vim_helper.eval(\"exists('%s')\" % option) == \"1\":\n            try:\n                return vim_helper.eval(option)\n            except vim_helper.error:\n                pass\n        return default\n\n    def __add__(self, value):\n        \"\"\"Appends the given line to rv using mkline.\"\"\"\n        self.rv += \"\\n\"  # pylint:disable=invalid-name\n        self.rv += self.mkline(value)\n        return self\n\n    def __lshift__(self, other):\n        \"\"\"Same as unshift.\"\"\"\n        self.unshift(other)\n\n    def __rshift__(self, other):\n        \"\"\"Same as shift.\"\"\"\n        self.shift(other)\n\n    @property\n    def snippet_start(self):\n        \"\"\"\n        Returns start of the snippet in format (line, column).\n        \"\"\"\n        return self._start\n\n    @property\n    def snippet_end(self):\n        \"\"\"\n        Returns end of the snippet in format (line, column).\n        \"\"\"\n        return self._end\n\n    @property\n    def buffer(self):\n        return vim_helper.buf\n\n\nclass PythonCode(NoneditableTextObject):\n\n    \"\"\"See module docstring.\"\"\"\n\n    def __init__(self, parent, token):\n\n        # Find our containing snippet for snippet local data\n        snippet = parent\n        while snippet:\n            try:\n                self._locals = snippet.locals\n                text = snippet.visual_content.text\n                mode = snippet.visual_content.mode\n                context = snippet.context\n                break\n            except AttributeError:\n                snippet = snippet._parent  # pylint:disable=protected-access\n        self._snip = SnippetUtil(token.indent, mode, text, context, snippet)\n\n        self._codes = (\n            \"import re, os, vim, string, random\\n\"\n            + \"\\n\".join(snippet.globals.get(\"!p\", [])).replace(\"\\r\\n\", \"\\n\"),\n            token.code.replace(\"\\\\`\", \"`\"),\n        )\n        self._compiled_codes = (\n            snippet._compiled_globals\n            or cached_compile(self._codes[0], \"<exec-globals>\", \"exec\"),\n            cached_compile(\n                token.code.replace(\"\\\\`\", \"`\"), \"<exec-interpolation-code>\", \"exec\"\n            ),\n        )\n\n        NoneditableTextObject.__init__(self, parent, token)\n\n    def _update(self, done, buf):\n        path = vim_helper.eval('expand(\"%\")') or \"\"\n        ct = self.current_text\n        self._locals.update(\n            {\n                \"t\": _Tabs(self._parent),\n                \"fn\": os.path.basename(path),\n                \"path\": path,\n                \"cur\": ct,\n                \"res\": ct,\n                \"snip\": self._snip,\n            }\n        )\n        self._snip._reset(ct)  # pylint:disable=protected-access\n\n        for code, compiled_code in zip(self._codes, self._compiled_codes):\n            try:\n                exec(compiled_code, self._locals)  # pylint:disable=exec-used\n            except Exception as exception:\n                exception.snippet_code = code\n                raise\n\n        rv = str(\n            self._snip.rv if self._snip._rv_changed else self._locals[\"res\"]\n        )  # pylint:disable=protected-access\n\n        if ct != rv:\n            self.overwrite(buf, rv)\n            return False\n        return True\n"
  },
  {
    "path": "pythonx/UltiSnips/text_objects/shell_code.py",
    "content": "#!/usr/bin/env python3\n# encoding: utf-8\n\n\"\"\"Implements `echo hi` shell code interpolation.\"\"\"\n\nimport os\nimport platform\nfrom subprocess import Popen, PIPE\nimport stat\nimport tempfile\n\nfrom UltiSnips.text_objects.base import NoneditableTextObject\n\n\ndef _chomp(string):\n    \"\"\"Rather than rstrip(), remove only the last newline and preserve\n    purposeful whitespace.\"\"\"\n    if len(string) and string[-1] == \"\\n\":\n        string = string[:-1]\n    if len(string) and string[-1] == \"\\r\":\n        string = string[:-1]\n    return string\n\n\ndef _run_shell_command(cmd, tmpdir):\n    \"\"\"Write the code to a temporary file.\"\"\"\n    cmdsuf = \"\"\n    if platform.system() == \"Windows\":\n        # suffix required to run command on windows\n        cmdsuf = \".bat\"\n        # turn echo off\n        cmd = \"@echo off\\r\\n\" + cmd\n    handle, path = tempfile.mkstemp(text=True, dir=tmpdir, suffix=cmdsuf)\n    os.write(handle, cmd.encode(\"utf-8\"))\n    os.close(handle)\n    os.chmod(path, stat.S_IRWXU)\n\n    # Execute the file and read stdout\n    proc = Popen(path, shell=True, stdout=PIPE, stderr=PIPE)\n    proc.wait()\n    stdout, _ = proc.communicate()\n    os.unlink(path)\n    return _chomp(stdout.decode(\"utf-8\"))\n\n\ndef _get_tmp():\n    \"\"\"Find an executable tmp directory.\"\"\"\n    userdir = os.path.expanduser(\"~\")\n    for testdir in [\n        tempfile.gettempdir(),\n        os.path.join(userdir, \".cache\"),\n        os.path.join(userdir, \".tmp\"),\n        userdir,\n    ]:\n        if (\n            not os.path.exists(testdir)\n            or not _run_shell_command(\"echo success\", testdir) == \"success\"\n        ):\n            continue\n        return testdir\n    return \"\"\n\n\nclass ShellCode(NoneditableTextObject):\n\n    \"\"\"See module docstring.\"\"\"\n\n    def __init__(self, parent, token):\n        NoneditableTextObject.__init__(self, parent, token)\n        self._code = token.code.replace(\"\\\\`\", \"`\")\n        self._tmpdir = _get_tmp()\n\n    def _update(self, done, buf):\n        if not self._tmpdir:\n            output = \"Unable to find executable tmp directory, check noexec on /tmp\"\n        else:\n            output = _run_shell_command(self._code, self._tmpdir)\n        self.overwrite(buf, output)\n        self._parent._del_child(self)  # pylint:disable=protected-access\n        return True\n"
  },
  {
    "path": "pythonx/UltiSnips/text_objects/snippet_instance.py",
    "content": "#!/usr/bin/env python3\n# encoding: utf-8\n\n\"\"\"A Snippet instance is an instance of a Snippet Definition.\n\nThat is, when the user expands a snippet, a SnippetInstance is created\nto keep track of the corresponding TextObjects. The Snippet itself is\nalso a TextObject.\n\n\"\"\"\n\nfrom UltiSnips import vim_helper\nfrom UltiSnips.error import PebkacError\nfrom UltiSnips.position import Position, JumpDirection\nfrom UltiSnips.text_objects.base import EditableTextObject, NoneditableTextObject\nfrom UltiSnips.text_objects.tabstop import TabStop\n\n\nclass SnippetInstance(EditableTextObject):\n\n    \"\"\"See module docstring.\"\"\"\n\n    # pylint:disable=protected-access\n\n    def __init__(\n        self,\n        snippet,\n        parent,\n        initial_text,\n        start,\n        end,\n        visual_content,\n        last_re,\n        globals,\n        context,\n        _compiled_globals=None,\n    ):\n        if start is None:\n            start = Position(0, 0)\n        if end is None:\n            end = Position(0, 0)\n        self.snippet = snippet\n        self._cts = 0\n\n        self.context = context\n        self.locals = {\"match\": last_re, \"context\": context}\n        self.globals = globals\n        self._compiled_globals = _compiled_globals\n        self.visual_content = visual_content\n        self.current_placeholder = None\n\n        EditableTextObject.__init__(self, parent, start, end, initial_text)\n\n    def replace_initial_text(self, buf):\n        \"\"\"Puts the initial text of all text elements into Vim.\"\"\"\n\n        def _place_initial_text(obj):\n            \"\"\"recurses on the children to do the work.\"\"\"\n            obj.overwrite_with_initial_text(buf)\n            if isinstance(obj, EditableTextObject):\n                for child in obj._children:\n                    _place_initial_text(child)\n\n        _place_initial_text(self)\n\n    def replay_user_edits(self, cmds, ctab=None):\n        \"\"\"Replay the edits the user has done to keep endings of our Text\n        objects in sync with reality.\"\"\"\n        for cmd in cmds:\n            self._do_edit(cmd, ctab)\n\n    def update_textobjects(self, buf):\n        \"\"\"Update the text objects that should change automagically after the\n        users edits have been replayed.\n\n        This might also move the Cursor\n\n        \"\"\"\n        done = set()\n        not_done = set()\n\n        def _find_recursive(obj):\n            \"\"\"Finds all text objects and puts them into 'not_done'.\"\"\"\n            cursorInsideLowest = None\n            if isinstance(obj, EditableTextObject):\n                if obj.start <= vim_helper.buf.cursor <= obj.end and not (\n                    isinstance(obj, TabStop) and obj.number == 0\n                ):\n                    cursorInsideLowest = obj\n                for child in obj._children:\n                    cursorInsideLowest = _find_recursive(child) or cursorInsideLowest\n            not_done.add(obj)\n            return cursorInsideLowest\n\n        cursorInsideLowest = _find_recursive(self)\n        if cursorInsideLowest is not None:\n            vc = _VimCursor(cursorInsideLowest)\n        counter = 10\n        while (done != not_done) and counter:\n            # Order matters for python locals!\n            for obj in sorted(not_done - done):\n                if obj._update(done, buf):\n                    done.add(obj)\n            counter -= 1\n        if not counter:\n            raise PebkacError(\n                \"The snippets content did not converge: Check for Cyclic \"\n                \"dependencies or random strings in your snippet. You can use \"\n                \"'if not snip.c' to make sure to only expand random output \"\n                \"once.\"\n            )\n        if cursorInsideLowest is not None:\n            vc.to_vim()\n            cursorInsideLowest._del_child(vc)\n\n    def select_next_tab(self, jump_direction: JumpDirection):\n        \"\"\"Selects the next tabstop in the direction of 'jump_direction'.\"\"\"\n        if self._cts is None:\n            return\n\n        if jump_direction == JumpDirection.BACKWARD:\n            current_tabstop_backup = self._cts\n\n            res = self._get_prev_tab(self._cts)\n            if res is None:\n                self._cts = current_tabstop_backup\n                return self._tabstops.get(self._cts, None)\n            self._cts, ts = res\n            return ts\n        elif jump_direction == JumpDirection.FORWARD:\n            res = self._get_next_tab(self._cts)\n            if res is None:\n                self._cts = None\n\n                ts = self._get_tabstop(self, 0)\n                if ts:\n                    return ts\n\n                # TabStop 0 was deleted. It was probably killed through some\n                # edit action. Recreate it at the end of us.\n                start = Position(self.end.line, self.end.col)\n                end = Position(self.end.line, self.end.col)\n                return TabStop(self, 0, start, end)\n            else:\n                self._cts, ts = res\n                return ts\n        else:\n            assert False, \"Unknown JumpDirection: %r\" % jump_direction\n\n    def has_next_tab(self, jump_direction: JumpDirection):\n        if jump_direction == JumpDirection.BACKWARD:\n            return self._get_prev_tab(self._cts) is not None\n        # There is always a next tabstop if we jump forward, since the snippet\n        # instance is deleted once we reach tabstop 0.\n        return True\n\n    def _get_tabstop(self, requester, no):\n        # SnippetInstances are completely self contained, therefore, we do not\n        # need to ask our parent for Tabstops\n        cached_parent = self._parent\n        self._parent = None\n        rv = EditableTextObject._get_tabstop(self, requester, no)\n        self._parent = cached_parent\n        return rv\n\n    def get_tabstops(self):\n        return self._tabstops\n\n\nclass _VimCursor(NoneditableTextObject):\n\n    \"\"\"Helper class to keep track of the Vim Cursor when text objects expand\n    and move.\"\"\"\n\n    def __init__(self, parent):\n        NoneditableTextObject.__init__(\n            self,\n            parent,\n            vim_helper.buf.cursor,\n            vim_helper.buf.cursor,\n            tiebreaker=Position(-1, -1),\n        )\n\n    def to_vim(self):\n        \"\"\"Moves the cursor in the Vim to our position.\"\"\"\n        assert self._start == self._end\n        vim_helper.buf.cursor = self._start\n"
  },
  {
    "path": "pythonx/UltiSnips/text_objects/tabstop.py",
    "content": "#!/usr/bin/env python3\n# encoding: utf-8\n\n\"\"\"This is the most important TextObject.\n\nA TabStop is were the cursor comes to rest when the user taps through\nthe Snippet.\n\n\"\"\"\n\nfrom UltiSnips.text_objects.base import EditableTextObject\n\n\nclass TabStop(EditableTextObject):\n\n    \"\"\"See module docstring.\"\"\"\n\n    def __init__(self, parent, token, start=None, end=None):\n        if start is not None:\n            self._number = token\n            EditableTextObject.__init__(self, parent, start, end)\n        else:\n            self._number = token.number\n            EditableTextObject.__init__(self, parent, token)\n        parent._tabstops[self._number] = self  # pylint:disable=protected-access\n\n    @property\n    def number(self):\n        \"\"\"The tabstop number.\"\"\"\n        return self._number\n\n    @property\n    def is_killed(self):\n        \"\"\"True if this tabstop has been typed over and the user therefore can\n        no longer jump to it.\"\"\"\n        return self._parent is None\n\n    def __repr__(self):\n        try:\n            text = self.current_text\n        except IndexError:\n            text = \"<err>\"\n        return \"TabStop(%s,%r->%r,%r)\" % (self.number, self._start, self._end, text)\n"
  },
  {
    "path": "pythonx/UltiSnips/text_objects/transformation.py",
    "content": "#!/usr/bin/env python3\n# encoding: utf-8\n\n\"\"\"Implements TabStop transformations.\"\"\"\n\nimport re\nimport sys\n\nfrom UltiSnips.text import unescape, fill_in_whitespace\nfrom UltiSnips.text_objects.mirror import Mirror\n\n\ndef _find_closing_brace(string, start_pos):\n    \"\"\"Finds the corresponding closing brace after start_pos.\"\"\"\n    bracks_open = 1\n    escaped = False\n    for idx, char in enumerate(string[start_pos:]):\n        if char == \"(\":\n            if not escaped:\n                bracks_open += 1\n        elif char == \")\":\n            if not escaped:\n                bracks_open -= 1\n            if not bracks_open:\n                return start_pos + idx + 1\n        if char == \"\\\\\":\n            escaped = not escaped\n        else:\n            escaped = False\n\n\ndef _split_conditional(string):\n    \"\"\"Split the given conditional 'string' into its arguments.\"\"\"\n    bracks_open = 0\n    args = []\n    carg = \"\"\n    escaped = False\n    for idx, char in enumerate(string):\n        if char == \"(\":\n            if not escaped:\n                bracks_open += 1\n        elif char == \")\":\n            if not escaped:\n                bracks_open -= 1\n        elif char == \":\" and not bracks_open and not escaped:\n            args.append(carg)\n            carg = \"\"\n            escaped = False\n            continue\n        carg += char\n        if char == \"\\\\\":\n            escaped = not escaped\n        else:\n            escaped = False\n    args.append(carg)\n    return args\n\n\ndef _replace_conditional(match, string):\n    \"\"\"Replaces a conditional match in a transformation.\"\"\"\n    conditional_match = _CONDITIONAL.search(string)\n    while conditional_match:\n        start = conditional_match.start()\n        end = _find_closing_brace(string, start + 4)\n        args = _split_conditional(string[start + 4 : end - 1])\n        rv = \"\"\n        if match.group(int(conditional_match.group(1))):\n            rv = unescape(_replace_conditional(match, args[0]))\n        elif len(args) > 1:\n            rv = unescape(_replace_conditional(match, args[1]))\n        string = string[:start] + rv + string[end:]\n        conditional_match = _CONDITIONAL.search(string)\n    return string\n\n\n_ONE_CHAR_CASE_SWITCH = re.compile(r\"\\\\([ul].)\", re.DOTALL)\n_LONG_CASEFOLDINGS = re.compile(r\"\\\\([UL].*?)\\\\E\", re.DOTALL)\n_DOLLAR = re.compile(r\"\\$(\\d+)\", re.DOTALL)\n_CONDITIONAL = re.compile(r\"\\(\\?(\\d+):\", re.DOTALL)\n\n\nclass _CleverReplace:\n\n    \"\"\"Mimics TextMates replace syntax.\"\"\"\n\n    def __init__(self, expression):\n        self._expression = expression\n\n    def replace(self, match):\n        \"\"\"Replaces 'match' through the correct replacement string.\"\"\"\n        transformed = self._expression\n        # Replace all $? with capture groups\n        transformed = _DOLLAR.subn(lambda m: match.group(int(m.group(1))), transformed)[\n            0\n        ]\n\n        # Replace Case switches\n        def _one_char_case_change(match):\n            \"\"\"Replaces one character case changes.\"\"\"\n            if match.group(1)[0] == \"u\":\n                return match.group(1)[-1].upper()\n            else:\n                return match.group(1)[-1].lower()\n\n        transformed = _ONE_CHAR_CASE_SWITCH.subn(_one_char_case_change, transformed)[0]\n\n        def _multi_char_case_change(match):\n            \"\"\"Replaces multi character case changes.\"\"\"\n            if match.group(1)[0] == \"U\":\n                return match.group(1)[1:].upper()\n            else:\n                return match.group(1)[1:].lower()\n\n        transformed = _LONG_CASEFOLDINGS.subn(_multi_char_case_change, transformed)[0]\n        transformed = _replace_conditional(match, transformed)\n        return unescape(fill_in_whitespace(transformed))\n\n\n# flag used to display only one time the lack of unidecode\nUNIDECODE_ALERT_RAISED = False\n\n\nclass TextObjectTransformation:\n\n    \"\"\"Base class for Transformations and ${VISUAL}.\"\"\"\n\n    def __init__(self, token):\n        self._convert_to_ascii = False\n\n        self._find = None\n        if token.search is None:\n            return\n\n        flags = 0\n        self._match_this_many = 1\n        if token.options:\n            if \"g\" in token.options:\n                self._match_this_many = 0\n            if \"i\" in token.options:\n                flags |= re.IGNORECASE\n            if \"m\" in token.options:\n                flags |= re.MULTILINE\n            if \"a\" in token.options:\n                self._convert_to_ascii = True\n\n        self._find = re.compile(token.search, flags | re.DOTALL)\n        self._replace = _CleverReplace(token.replace)\n\n    def _transform(self, text):\n        \"\"\"Do the actual transform on the given text.\"\"\"\n        global UNIDECODE_ALERT_RAISED  # pylint:disable=global-statement\n        if self._convert_to_ascii:\n            try:\n                import unidecode\n\n                text = unidecode.unidecode(text)\n            except Exception:  # pylint:disable=broad-except\n                if UNIDECODE_ALERT_RAISED == False:\n                    UNIDECODE_ALERT_RAISED = True\n                    sys.stderr.write(\n                        \"Please install unidecode python package in order to \"\n                        \"be able to make ascii conversions.\\n\"\n                    )\n        if self._find is None:\n            return text\n        return self._find.subn(self._replace.replace, text, self._match_this_many)[0]\n\n\nclass Transformation(Mirror, TextObjectTransformation):\n\n    \"\"\"See module docstring.\"\"\"\n\n    def __init__(self, parent, ts, token):\n        Mirror.__init__(self, parent, ts, token)\n        TextObjectTransformation.__init__(self, token)\n\n    def _get_text(self):\n        return self._transform(self._ts.current_text)\n"
  },
  {
    "path": "pythonx/UltiSnips/text_objects/viml_code.py",
    "content": "#!/usr/bin/env python3\n# encoding: utf-8\n\n\"\"\"Implements `!v ` VimL interpolation.\"\"\"\n\nfrom UltiSnips import vim_helper\nfrom UltiSnips.text_objects.base import NoneditableTextObject\n\n\nclass VimLCode(NoneditableTextObject):\n\n    \"\"\"See module docstring.\"\"\"\n\n    def __init__(self, parent, token):\n        self._code = token.code.replace(\"\\\\`\", \"`\").strip()\n\n        NoneditableTextObject.__init__(self, parent, token)\n\n    def _update(self, done, buf):\n        self.overwrite(buf, vim_helper.eval(self._code))\n        return True\n"
  },
  {
    "path": "pythonx/UltiSnips/text_objects/visual.py",
    "content": "#!/usr/bin/env python3\n# encoding: utf-8\n\n\"\"\"A ${VISUAL} placeholder that will use the text that was last visually\nselected and insert it here.\n\nIf there was no text visually selected, this will be the empty string.\n\n\"\"\"\n\nimport re\nimport textwrap\n\nfrom UltiSnips.indent_util import IndentUtil\nfrom UltiSnips.text_objects.transformation import TextObjectTransformation\nfrom UltiSnips.text_objects.base import NoneditableTextObject\n\n_REPLACE_NON_WS = re.compile(r\"[^ \\t]\")\n\n\nclass Visual(NoneditableTextObject, TextObjectTransformation):\n\n    \"\"\"See module docstring.\"\"\"\n\n    def __init__(self, parent, token):\n        # Find our containing snippet for visual_content\n        snippet = parent\n        while snippet:\n            try:\n                self._text = snippet.visual_content.text\n                self._mode = snippet.visual_content.mode\n                break\n            except AttributeError:\n                snippet = snippet._parent  # pylint:disable=protected-access\n        if not self._text:\n            self._text = token.alternative_text\n            self._mode = \"v\"\n\n        NoneditableTextObject.__init__(self, parent, token)\n        TextObjectTransformation.__init__(self, token)\n\n    def _update(self, done, buf):\n        if self._mode == \"v\":  # Normal selection.\n            text = self._text\n        else:  # Block selection or line selection.\n            text_before = buf[self.start.line][: self.start.col]\n            indent = _REPLACE_NON_WS.sub(\" \", text_before)\n            iu = IndentUtil()\n            indent = iu.indent_to_spaces(indent)\n            indent = iu.spaces_to_indent(indent)\n            text = \"\"\n            for idx, line in enumerate(textwrap.dedent(self._text).splitlines(True)):\n                if idx != 0:\n                    text += indent\n                text += line\n            text = text[:-1]  # Strip final '\\n'\n\n        text = self._transform(text)\n        self.overwrite(buf, text)\n        self._parent._del_child(self)  # pylint:disable=protected-access\n\n        return True\n"
  },
  {
    "path": "pythonx/UltiSnips/vim_helper.py",
    "content": "#!/usr/bin/env python3\n# encoding: utf-8\n\n\"\"\"Wrapper functionality around the functions we need from Vim.\"\"\"\n\nfrom contextlib import contextmanager\nimport os\nimport platform\n\nfrom UltiSnips.compatibility import col2byte, byte2col\nfrom UltiSnips.error import PebkacError\nfrom UltiSnips.position import Position\nfrom UltiSnips.snippet.source.file.common import normalize_file_path\nfrom vim import error  # pylint:disable=import-error,unused-import\nimport vim  # pylint:disable=import-error\n\n\nclass VimBuffer:\n\n    \"\"\"Wrapper around the current Vim buffer.\"\"\"\n\n    def __getitem__(self, idx):\n        return vim.current.buffer[idx]\n\n    def __setitem__(self, idx, text):\n        vim.current.buffer[idx] = text\n\n    def __len__(self):\n        return len(vim.current.buffer)\n\n    # This is a workaround for a bug in Neovim's Python layer. See here for\n    # context https://github.com/SirVer/ultisnips/issues/1041\n    def __iter__(self):\n        return iter(vim.current.buffer)\n\n    @property\n    def line_till_cursor(self):  # pylint:disable=no-self-use\n        \"\"\"Returns the text before the cursor.\"\"\"\n        _, col = self.cursor\n        return vim.current.line[:col]\n\n    @property\n    def number(self):  # pylint:disable=no-self-use\n        \"\"\"The bufnr() of the current buffer.\"\"\"\n        return vim.current.buffer.number\n\n    @property\n    def filetypes(self):\n        return [ft for ft in vim.eval(\"&filetype\").split(\".\") if ft]\n\n    @property\n    def cursor(self):  # pylint:disable=no-self-use\n        \"\"\"The current windows cursor.\n\n        Note that this is 0 based in col and 0 based in line which is\n        different from Vim's cursor.\n\n        \"\"\"\n        line, nbyte = vim.current.window.cursor\n        col = byte2col(line, nbyte)\n        return Position(line - 1, col)\n\n    @cursor.setter\n    def cursor(self, pos):  # pylint:disable=no-self-use\n        \"\"\"See getter.\"\"\"\n        nbyte = col2byte(pos.line + 1, pos.col)\n        vim.current.window.cursor = pos.line + 1, nbyte\n\n\nbuf = VimBuffer()  # pylint:disable=invalid-name\n\n\n@contextmanager\ndef option_set_to(name, new_value):\n    old_value = vim.eval(\"&\" + name)\n    command(\"set {0}={1}\".format(name, new_value))\n    try:\n        yield\n    finally:\n        command(\"set {0}={1}\".format(name, old_value))\n\n\n@contextmanager\ndef save_mark(name):\n    old_pos = get_mark_pos(name)\n    try:\n        yield\n    finally:\n        if _is_pos_zero(old_pos):\n            delete_mark(name)\n        else:\n            set_mark_from_pos(name, old_pos)\n\n\ndef escape(inp):\n    \"\"\"Creates a vim-friendly string from a group of\n    dicts, lists and strings.\"\"\"\n\n    def conv(obj):\n        \"\"\"Convert obj.\"\"\"\n        if isinstance(obj, list):\n            rv = \"[\" + \",\".join(conv(o) for o in obj) + \"]\"\n        elif isinstance(obj, dict):\n            rv = (\n                \"{\"\n                + \",\".join(\n                    [\n                        \"%s:%s\" % (conv(key), conv(value))\n                        for key, value in obj.iteritems()\n                    ]\n                )\n                + \"}\"\n            )\n        else:\n            rv = '\"%s\"' % obj.replace('\"', '\\\\\"')\n        return rv\n\n    return conv(inp)\n\n\ndef command(cmd):\n    \"\"\"Wraps vim.command.\"\"\"\n    return vim.command(cmd)\n\n\ndef eval(text):\n    \"\"\"Wraps vim.eval.\"\"\"\n    # Replace null bytes with newlines, as vim raises a ValueError and neovim\n    # treats it as a terminator for the entire command.\n    text = text.replace(\"\\x00\", \"\\n\")\n    return vim.eval(text)\n\n\ndef bindeval(text):\n    \"\"\"Wraps vim.bindeval.\"\"\"\n    rv = vim.bindeval(text)\n    if not isinstance(rv, (dict, list)):\n        return rv.decode(vim.eval(\"&encoding\"), \"replace\")\n    return rv\n\n\ndef feedkeys(keys, mode=\"n\"):\n    \"\"\"Wrapper around vim's feedkeys function.\n\n    Mainly for convenience.\n\n    \"\"\"\n    if eval(\"mode()\") == \"n\":\n        if keys == \"a\":\n            cursor_pos = get_cursor_pos()\n            cursor_pos[2] = int(cursor_pos[2]) + 1\n            set_cursor_from_pos(cursor_pos)\n        if keys in \"ai\":\n            keys = \"startinsert\"\n\n    if keys == \"startinsert\":\n        command(\"startinsert\")\n    else:\n        command(r'call feedkeys(\"%s\", \"%s\")' % (keys, mode))\n\n\ndef new_scratch_buffer(text):\n    \"\"\"Create a new scratch buffer with the text given.\"\"\"\n    vim.command(\"botright new\")\n    vim.command(\"set ft=\")\n    vim.command(\"set buftype=nofile\")\n\n    vim.current.buffer[:] = text.splitlines()\n\n    feedkeys(r\"\\<Esc>\")\n\n    # Older versions of Vim always jumped the cursor to a new window, no matter\n    # how it was generated. Newer versions of Vim seem to not jump if the\n    # window is generated while in insert mode. Our tests rely that the cursor\n    # jumps when an error is thrown. Instead of doing the right thing of fixing\n    # how our test get the information about an error, we do the quick thing\n    # and make sure we always end up with the cursor in the scratch buffer.\n    feedkeys(r\"\\<c-w>\\<down>\")\n\n\ndef virtual_position(line, col):\n    \"\"\"Runs the position through virtcol() and returns the result.\"\"\"\n    nbytes = col2byte(line, col)\n    return line, int(eval(\"virtcol([%d, %d])\" % (line, nbytes)))\n\n\ndef select(start, end):\n    \"\"\"Select the span in Select mode.\"\"\"\n    _unmap_select_mode_mapping()\n\n    selection = eval(\"&selection\")\n\n    col = col2byte(start.line + 1, start.col)\n    buf.cursor = start\n\n    mode = eval(\"mode()\")\n\n    move_cmd = \"\"\n    if mode != \"n\":\n        move_cmd += r\"\\<Esc>\"\n\n    if start == end:\n        # Zero Length Tabstops, use 'i' or 'a'.\n        if col == 0 or mode not in \"i\" and col < len(buf[start.line]):\n            move_cmd += \"i\"\n        else:\n            move_cmd += \"a\"\n    else:\n        # Non zero length, use Visual selection.\n        move_cmd += \"v\"\n        if \"inclusive\" in selection:\n            if end.col == 0:\n                move_cmd += \"%iG$\" % end.line\n            else:\n                move_cmd += \"%iG%i|\" % virtual_position(end.line + 1, end.col)\n        elif \"old\" in selection:\n            move_cmd += \"%iG%i|\" % virtual_position(end.line + 1, end.col)\n        else:\n            move_cmd += \"%iG%i|\" % virtual_position(end.line + 1, end.col + 1)\n        move_cmd += \"o%iG%i|o\\\\<c-g>\" % virtual_position(start.line + 1, start.col + 1)\n    feedkeys(move_cmd)\n\n\ndef get_dot_vim():\n    \"\"\"Returns the likely places for ~/.vim for the current setup.\"\"\"\n    home = vim.eval(\"$HOME\")\n    candidates = []\n    if platform.system() == \"Windows\":\n        candidates.append(os.path.join(home, \"vimfiles\"))\n    if vim.eval(\"has('nvim')\") == \"1\":\n        xdg_home_config = vim.eval(\"$XDG_CONFIG_HOME\") or os.path.join(home, \".config\")\n        candidates.append(os.path.join(xdg_home_config, \"nvim\"))\n\n    candidates.append(os.path.join(home, \".vim\"))\n\n    # Note: this potentially adds a duplicate on nvim\n    # I assume nvim sets the MYVIMRC env variable (to beconfirmed)\n    if \"MYVIMRC\" in os.environ:\n        my_vimrc = os.path.expandvars(os.environ[\"MYVIMRC\"])\n        candidates.append(normalize_file_path(os.path.dirname(my_vimrc)))\n\n    candidates_normalized = []\n    for candidate in candidates:\n        if os.path.isdir(candidate):\n            candidates_normalized.append(normalize_file_path(candidate))\n    if candidates_normalized:\n        # We remove duplicates on return\n        return sorted(set(candidates_normalized))\n    raise PebkacError(\n        \"Unable to find user configuration directory. I tried '%s'.\" % candidates\n    )\n\n\ndef set_mark_from_pos(name, pos):\n    return _set_pos(\"'\" + name, pos)\n\n\ndef get_mark_pos(name):\n    return _get_pos(\"'\" + name)\n\n\ndef set_cursor_from_pos(pos):\n    return _set_pos(\".\", pos)\n\n\ndef get_cursor_pos():\n    return _get_pos(\".\")\n\n\ndef delete_mark(name):\n    try:\n        return command(\"delma \" + name)\n    except:\n        return False\n\n\ndef _set_pos(name, pos):\n    return eval('setpos(\"{0}\", {1})'.format(name, pos))\n\n\ndef _get_pos(name):\n    return eval('getpos(\"{0}\")'.format(name))\n\n\ndef _is_pos_zero(pos):\n    return [\"0\"] * 4 == pos or [0] == pos\n\n\ndef _unmap_select_mode_mapping():\n    \"\"\"This function unmaps select mode mappings if so wished by the user.\n\n    Removes select mode mappings that can actually be typed by the user\n    (ie, ignores things like <Plug>).\n\n    \"\"\"\n    if int(eval(\"g:UltiSnipsRemoveSelectModeMappings\")):\n        ignores = eval(\"g:UltiSnipsMappingsToIgnore\") + [\"UltiSnips\"]\n\n        for option in (\"<buffer>\", \"\"):\n            # Put all smaps into a var, and then read the var\n            command(r\"redir => _tmp_smaps | silent smap %s \" % option + \"| redir END\")\n\n            # Check if any mappings where found\n            if hasattr(vim, \"bindeval\"):\n                # Safer to use bindeval, if it exists, because it can deal with\n                # non-UTF-8 characters in mappings; see GH #690.\n                all_maps = bindeval(r\"_tmp_smaps\")\n            else:\n                all_maps = eval(r\"_tmp_smaps\")\n            all_maps = list(filter(len, all_maps.splitlines()))\n            if len(all_maps) == 1 and all_maps[0][0] not in \" sv\":\n                # \"No maps found\". String could be localized. Hopefully\n                # it doesn't start with any of these letters in any\n                # language\n                continue\n\n            # Only keep mappings that should not be ignored\n            maps = [\n                m\n                for m in all_maps\n                if not any(i in m for i in ignores) and len(m.strip())\n            ]\n\n            for map in maps:\n                # The first three chars are the modes, that might be listed.\n                # We are not interested in them here.\n                trig = map[3:].split()[0] if len(map[3:].split()) != 0 else None\n\n                if trig is None:\n                    continue\n\n                # The bar separates commands\n                if trig[-1] == \"|\":\n                    trig = trig[:-1] + \"<Bar>\"\n\n                # Special ones\n                if trig[0] == \"<\":\n                    add = False\n                    # Only allow these\n                    for valid in [\"Tab\", \"NL\", \"CR\", \"C-Tab\", \"BS\"]:\n                        if trig == \"<%s>\" % valid:\n                            add = True\n                    if not add:\n                        continue\n\n                # UltiSnips remaps <BS>. Keep this around.\n                if trig == \"<BS>\":\n                    continue\n\n                # Actually unmap it\n                try:\n                    command(\"silent! sunmap %s %s\" % (option, trig))\n                except:  # pylint:disable=bare-except\n                    # Bug 908139: ignore unmaps that fail because of\n                    # unprintable characters. This is not ideal because we\n                    # will not be able to unmap lhs with any unprintable\n                    # character. If the lhs stats with a printable\n                    # character this will leak to the user when he tries to\n                    # type this character as a first in a selected tabstop.\n                    # This case should be rare enough to not bother us\n                    # though.\n                    pass\n"
  },
  {
    "path": "pythonx/UltiSnips/vim_state.py",
    "content": "#!/usr/bin/env python3\n# encoding: utf-8\n\n\"\"\"Some classes to conserve Vim's state for comparing over time.\"\"\"\n\nfrom collections import deque, namedtuple\n\nfrom UltiSnips import vim_helper\nfrom UltiSnips.compatibility import byte2col\nfrom UltiSnips.position import Position\n\n_Placeholder = namedtuple(\"_FrozenPlaceholder\", [\"current_text\", \"start\", \"end\"])\n\n\nclass VimPosition(Position):\n\n    \"\"\"Represents the current position in the buffer, together with some status\n    variables that might change our decisions down the line.\"\"\"\n\n    def __init__(self):\n        pos = vim_helper.buf.cursor\n        self._mode = vim_helper.eval(\"mode()\")\n        Position.__init__(self, pos.line, pos.col)\n\n    @property\n    def mode(self):\n        \"\"\"Returns the mode() this position was created.\"\"\"\n        return self._mode\n\n\nclass VimState:\n\n    \"\"\"Caches some state information from Vim to better guess what editing\n    tasks the user might have done in the last step.\"\"\"\n\n    def __init__(self):\n        self._poss = deque(maxlen=5)\n        self._lvb = None\n\n        self._text_to_expect = \"\"\n        self._unnamed_reg_cached = False\n\n        # We store the cached value of the unnamed register in Vim directly to\n        # avoid any Unicode issues with saving and restoring the unnamed\n        # register across the Python bindings.  The unnamed register can contain\n        # data that cannot be coerced to Unicode, and so a simple vim.eval('@\"')\n        # fails badly.  Keeping the cached value in Vim directly, sidesteps the\n        # problem.\n        vim_helper.command('let g:_ultisnips_unnamed_reg_cache = \"\"')\n\n    def remember_unnamed_register(self, text_to_expect):\n        \"\"\"Save the unnamed register.\n\n        'text_to_expect' is text that we expect\n        to be contained in the register the next time this method is called -\n        this could be text from the tabstop that was selected and might have\n        been overwritten. We will not cache that then.\n\n        \"\"\"\n        self._unnamed_reg_cached = True\n        escaped_text = self._text_to_expect.replace(\"'\", \"''\")\n        res = int(vim_helper.eval('@\" != ' + \"'\" + escaped_text + \"'\"))\n        if res:\n            vim_helper.command('let g:_ultisnips_unnamed_reg_cache = @\"')\n        self._text_to_expect = text_to_expect\n\n    def restore_unnamed_register(self):\n        \"\"\"Restores the unnamed register and forgets what we cached.\"\"\"\n        if not self._unnamed_reg_cached:\n            return\n        vim_helper.command('let @\" = g:_ultisnips_unnamed_reg_cache')\n        self._unnamed_reg_cached = False\n\n    def remember_position(self):\n        \"\"\"Remember the current position as a previous pose.\"\"\"\n        self._poss.append(VimPosition())\n\n    def remember_buffer(self, to):\n        \"\"\"Remember the content of the buffer and the position.\"\"\"\n        self._lvb = vim_helper.buf[to.start.line : to.end.line + 1]\n        self._lvb_len = len(vim_helper.buf)\n        self.remember_position()\n\n    @property\n    def diff_in_buffer_length(self):\n        \"\"\"Returns the difference in the length of the current buffer compared\n        to the remembered.\"\"\"\n        return len(vim_helper.buf) - self._lvb_len\n\n    @property\n    def pos(self):\n        \"\"\"The last remembered position.\"\"\"\n        return self._poss[-1]\n\n    @property\n    def ppos(self):\n        \"\"\"The second to last remembered position.\"\"\"\n        return self._poss[-2]\n\n    @property\n    def remembered_buffer(self):\n        \"\"\"The content of the remembered buffer.\"\"\"\n        return self._lvb[:]\n\n\nclass VisualContentPreserver:\n\n    \"\"\"Saves the current visual selection and the selection mode it was done in\n    (e.g. line selection, block selection or regular selection.)\"\"\"\n\n    def __init__(self):\n        self.reset()\n\n    def reset(self):\n        \"\"\"Forget the preserved state.\"\"\"\n        self._mode = \"\"\n        self._text = \"\"\n        self._placeholder = None\n\n    def conserve(self):\n        \"\"\"Save the last visual selection and the mode it was made in.\"\"\"\n        sl, sbyte = map(\n            int, (vim_helper.eval(\"\"\"line(\"'<\")\"\"\"), vim_helper.eval(\"\"\"col(\"'<\")\"\"\"))\n        )\n        el, ebyte = map(\n            int, (vim_helper.eval(\"\"\"line(\"'>\")\"\"\"), vim_helper.eval(\"\"\"col(\"'>\")\"\"\"))\n        )\n        sc = byte2col(sl, sbyte - 1)\n        ec = byte2col(el, ebyte - 1)\n        self._mode = vim_helper.eval(\"visualmode()\")\n\n        # When 'selection' is 'exclusive', the > mark is one column behind the\n        # actual content being copied, but never before the < mark.\n        if vim_helper.eval(\"&selection\") == \"exclusive\":\n            if not (sl == el and sbyte == ebyte):\n                ec -= 1\n\n        _vim_line_with_eol = lambda ln: vim_helper.buf[ln] + \"\\n\"\n\n        if sl == el:\n            text = _vim_line_with_eol(sl - 1)[sc : ec + 1]\n        else:\n            text = _vim_line_with_eol(sl - 1)[sc:]\n            for cl in range(sl, el - 1):\n                text += _vim_line_with_eol(cl)\n            text += _vim_line_with_eol(el - 1)[: ec + 1]\n        self._text = text\n\n    def conserve_placeholder(self, placeholder):\n        if placeholder:\n            self._placeholder = _Placeholder(\n                placeholder.current_text, placeholder.start, placeholder.end\n            )\n        else:\n            self._placeholder = None\n\n    @property\n    def text(self):\n        \"\"\"The conserved text.\"\"\"\n        return self._text\n\n    @property\n    def mode(self):\n        \"\"\"The conserved visualmode().\"\"\"\n        return self._mode\n\n    @property\n    def placeholder(self):\n        \"\"\"Returns latest selected placeholder.\"\"\"\n        return self._placeholder\n"
  },
  {
    "path": "rplugin/python3/deoplete/sources/ultisnips.py",
    "content": "from deoplete.base.source import Base\n\n\nclass Source(Base):\n    def __init__(self, vim):\n        Base.__init__(self, vim)\n\n        self.name = \"ultisnips\"\n        self.mark = \"[US]\"\n        self.rank = 8\n        self.is_volatile = True\n\n    def gather_candidates(self, context):\n        suggestions = []\n        snippets = self.vim.eval(\"UltiSnips#SnippetsInCurrentScope()\")\n        for trigger in snippets:\n            suggestions.append(\n                {\n                    \"word\": trigger,\n                    \"menu\": self.mark + \" \" + snippets.get(trigger, \"\"),\n                    \"dup\": 1,\n                    \"kind\": \"snippet\",\n                }\n            )\n        return suggestions\n"
  },
  {
    "path": "syntax/snippets.vim",
    "content": "\" Syntax highlighting for snippet files (used for UltiSnips.vim)\n\" Revision: 26/03/11 19:53:33\n\nif exists(\"b:current_syntax\")\n  finish\nendif\n\nif expand(\"%:p:h\") =~ \"snippets\" && search(\"^endsnippet\", \"nw\") == 0\n            \\ && !exists(\"b:ultisnips_override_snipmate\")\n    \" this appears to be a snipmate file\n    \" It's in a directory called snippets/ and there's no endsnippet keyword\n    \" anywhere in the file.\n    source <sfile>:h/snippets_snipmate.vim\n    finish\nendif\n\n\" Embedded Syntaxes {{{1\n\ntry\n   syntax include @Python syntax/python.vim\n   unlet b:current_syntax\n   syntax include @Viml syntax/vim.vim\n   unlet b:current_syntax\n   syntax include @Shell syntax/sh.vim\n   unlet b:current_syntax\ncatch /E403/\n   \" Ignore errors about syntax files that can't be loaded more than once\nendtry\n\n\" Syntax definitions {{{1\n\n\" Comments {{{2\n\nsyn match snipComment \"^#.*\" contains=snipTODO,@Spell display\nsyn keyword snipTODO contained display FIXME NOTE NOTES TODO XXX\n\n\" Errors {{{2\n\nsyn match snipLeadingSpaces \"^\\t* \\+\" contained\n\n\" Extends {{{2\n\nsyn match snipExtends \"^extends\\%(\\s.*\\|$\\)\" contains=snipExtendsKeyword display\nsyn match snipExtendsKeyword \"^extends\" contained display\n\n\" Definitions {{{2\n\n\" snippet {{{3\n\nsyn region snipSnippet start=\"^snippet\\_s\" end=\"^endsnippet\\s*$\" contains=snipSnippetHeader fold keepend\nsyn match snipSnippetHeader \"^.*$\" nextgroup=snipSnippetBody,snipSnippetFooter skipnl contained contains=snipSnippetHeaderKeyword\nsyn match snipSnippetHeaderKeyword \"^snippet\" contained nextgroup=snipSnippetTrigger skipwhite\nsyn region snipSnippetBody start=\"\\_.\" end=\"^\\zeendsnippet\\s*$\" contained nextgroup=snipSnippetFooter contains=snipLeadingSpaces,@snipTokens\nsyn match snipSnippetFooter \"^endsnippet.*\" contained contains=snipSnippetFooterKeyword\nsyn match snipSnippetFooterKeyword \"^endsnippet\" contained\n\n\" The current parser is a bit lax about parsing. For example, given this:\n\"   snippet foo\"bar\"\n\" it treats `foo\"bar\"` as the trigger. But with this:\n\"   snippet foo\"bar baz\"\n\" it treats `foo` as the trigger and \"bar baz\" as the description.\n\" I think this is an accident. Instead, we'll assume the description must\n\" be surrounded by spaces. That means we'll treat\n\"   snippet foo\"bar\"\n\" as a trigger `foo\"bar\"` and\n\"   snippet foo\"bar baz\"\n\" as an attempted multiword snippet `foo\"bar baz\"` that is invalid.\n\" NB: UltiSnips parses right-to-left, which Vim doesn't support, so that makes\n\" the following patterns very complicated.\nsyn match snipSnippetTrigger \"\\S\\+\" contained nextgroup=snipSnippetDocString,snipSnippetTriggerInvalid skipwhite\n\" We want to match a trailing \" as the start of a doc comment, but we also\n\" want to allow for using \" as the delimiter in a multiword/pattern snippet.\n\" So we have to define this twice, once in the general case that matches a\n\" trailing \" as the doc comment, and once for the case of the multiword\n\" delimiter using \" that has more constraints\nsyn match snipSnippetTrigger ,\".\\{-}\"\\ze\\%(\\s\\+\"\\%(\\s*\\S\\)\\@=[^\"]*\\%(\"\\s\\+[^\"[:space:]]\\+\\|\"\\)\\=\\)\\=\\s*$, contained nextgroup=snipSnippetDocString skipwhite\nsyn match snipSnippetTrigger ,\\%(\\(\\S\\).\\{-}\\1\\|\\S\\+\\)\\ze\\%(\\s\\+\"[^\"]*\\%(\"\\s\\+\\%(\"[^\"]\\+\"\\s\\+[^\"[:space:]]*e[^\"[:space:]]*\\)\\|\"\\)\\=\\)\\=\\s*$, contained nextgroup=snipSnippetDocContextString skipwhite\nsyn match snipSnippetTrigger ,\\([^\"[:space:]]\\).\\{-}\\1\\%(\\s*$\\)\\@!\\ze\\%(\\s\\+\"[^\"]*\\%(\"\\s\\+\\%(\"[^\"]\\+\"\\s\\+[^\"[:space:]]*e[^\"[:space:]]*\\|[^\"[:space:]]\\+\\)\\|\"\\)\\=\\)\\=\\s*$, contained nextgroup=snipSnippetDocString skipwhite\nsyn match snipSnippetTriggerInvalid ,\\S\\@=.\\{-}\\S\\ze\\%(\\s\\+\"[^\"]*\\%(\"\\s\\+[^\"[:space:]]\\+\\s*\\|\"\\s*\\)\\=\\|\\s*\\)$, contained nextgroup=snipSnippetDocString skipwhite\nsyn match snipSnippetDocString ,\"[^\"]*\", contained nextgroup=snipSnippetOptions skipwhite\nsyn match snipSnippetDocContextString ,\"[^\"]*\", contained nextgroup=snipSnippetContext skipwhite\nsyn match snipSnippetContext ,\"[^\"]\\+\", contained skipwhite contains=snipSnippetContextP\nsyn region snipSnippetContextP start=,\"\\@<=., end=,\", contained contains=@Python nextgroup=snipSnippetOptions skipwhite keepend\nsyn match snipSnippetOptions ,\\S\\+, contained contains=snipSnippetOptionFlag\nsyn match snipSnippetOptionFlag ,[biwrtsmxAe], contained\n\n\" Command substitution {{{4\n\nsyn region snipCommand keepend matchgroup=snipCommandDelim start=\"`\" skip=\"\\\\[{}\\\\$`]\" end=\"`\" contained contains=snipPythonCommand,snipVimLCommand,snipShellCommand,snipCommandSyntaxOverride\nsyn region snipShellCommand start=\"\\ze\\_.\" skip=\"\\\\[{}\\\\$`]\" end=\"\\ze`\" contained contains=@Shell\nsyn region snipPythonCommand matchgroup=snipPythonCommandP start=\"`\\@<=!p\\_s\" skip=\"\\\\[{}\\\\$`]\" end=\"\\ze`\" contained contains=@Python\nsyn region snipVimLCommand matchgroup=snipVimLCommandV start=\"`\\@<=!v\\_s\" skip=\"\\\\[{}\\\\$`]\" end=\"\\ze`\" contained contains=@Viml\nsyn cluster snipTokens add=snipCommand\nsyn cluster snipTabStopTokens add=snipCommand\n\n\" unfortunately due to the balanced braces parsing of commands, if a { occurs\n\" in the command, we need to prevent the embedded syntax highlighting.\n\" Otherwise, we can't track the balanced braces properly.\n\nsyn region snipCommandSyntaxOverride start=\"\\%(\\\\[{}\\\\$`]\\|\\_[^`\"{]\\)*\\ze{\" skip=\"\\\\[{}\\\\$`]\" end=\"\\ze`\" contained contains=snipBalancedBraces transparent\n\n\" Tab Stops {{{4\n\nsyn match snipEscape \"\\\\[{}\\\\$`]\" contained\nsyn cluster snipTokens add=snipEscape\nsyn cluster snipTabStopTokens add=snipEscape\n\nsyn match snipMirror \"\\$\\d\\+\" contained\nsyn cluster snipTokens add=snipMirror\nsyn cluster snipTabStopTokens add=snipMirror\n\nsyn region snipTabStop matchgroup=snipTabStop start=\"\\${\\d\\+[:}]\\@=\" end=\"}\" contained contains=snipTabStopDefault extend\nsyn region snipTabStopDefault matchgroup=snipTabStop start=\":\" skip=\"\\\\[{}]\" end=\"\\ze}\" contained contains=snipTabStopEscape,snipBalancedBraces,@snipTabStopTokens keepend\nsyn match snipTabStopEscape \"\\\\[{}]\" contained\nsyn region snipBalancedBraces start=\"{\" end=\"}\" contained transparent extend\nsyn cluster snipTokens add=snipTabStop\nsyn cluster snipTabStopTokens add=snipTabStop\n\nsyn region snipVisual matchgroup=snipVisual start=\"\\${VISUAL[:}/]\\@=\" end=\"}\" contained contains=snipVisualDefault,snipTransformationPattern extend\nsyn region snipVisualDefault matchgroup=snipVisual start=\":\" end=\"\\ze[}/]\" contained contains=snipTabStopEscape nextgroup=snipTransformationPattern\nsyn cluster snipTokens add=snipVisual\nsyn cluster snipTabStopTokens add=snipVisual\n\nsyn region snipTransformation matchgroup=snipTransformation start=\"\\${\\d\\/\\@=\" end=\"}\" contained contains=snipTransformationPattern\nsyn region snipTransformationPattern matchgroup=snipTransformationPatternDelim start=\"/\" end=\"\\ze/\" contained contains=snipTransformationEscape nextgroup=snipTransformationReplace skipnl\nsyn region snipTransformationReplace matchgroup=snipTransformationPatternDelim start=\"/\" end=\"/\" contained contains=snipTransformationEscape nextgroup=snipTransformationOptions skipnl\nsyn region snipTransformationOptions start=\"\\ze[^}]\" end=\"\\ze}\" contained contains=snipTabStopEscape\nsyn match snipTransformationEscape \"\\\\/\" contained\nsyn cluster snipTokens add=snipTransformation\nsyn cluster snipTabStopTokens add=snipTransformation\n\n\" global {{{3\n\n\" Generic (non-Python) {{{4\n\nsyn region snipGlobal start=\"^global\\_s\" end=\"^endglobal\\s*$\" contains=snipGlobalHeader fold keepend\nsyn match snipGlobalHeader \"^.*$\" nextgroup=snipGlobalBody,snipGlobalFooter skipnl contained contains=snipGlobalHeaderKeyword\nsyn region snipGlobalBody start=\"\\_.\" end=\"^\\zeendglobal\\s*$\" contained nextgroup=snipGlobalFooter contains=snipLeadingSpaces\n\n\" Python (!p) {{{4\n\nsyn region snipGlobal start=,^global\\s\\+!p\\%(\\s\\+\"[^\"]*\\%(\"\\s\\+[^\"[:space:]]\\+\\|\"\\)\\=\\)\\=\\s*$, end=,^endglobal\\s*$, contains=snipGlobalPHeader fold keepend\nsyn match snipGlobalPHeader \"^.*$\" nextgroup=snipGlobalPBody,snipGlobalFooter skipnl contained contains=snipGlobalHeaderKeyword\nsyn match snipGlobalHeaderKeyword \"^global\" contained nextgroup=snipSnippetTrigger skipwhite\nsyn region snipGlobalPBody start=\"\\_.\" end=\"^\\zeendglobal\\s*$\" contained nextgroup=snipGlobalFooter contains=@Python\n\n\" Common {{{4\n\nsyn match snipGlobalFooter \"^endglobal.*\" contained contains=snipGlobalFooterKeyword\nsyn match snipGlobalFooterKeyword \"^endglobal\" contained\n\n\" priority {{{3\n\nsyn match snipPriority \"^priority\\%(\\s.*\\|$\\)\" contains=snipPriorityKeyword display\nsyn match snipPriorityKeyword \"^priority\" contained nextgroup=snipPriorityValue skipwhite display\nsyn match snipPriorityValue \"-\\?\\d\\+\" contained display\n\n\" context {{{3\n\nsyn match snipContext \"^context.*$\" contains=snipContextKeyword display skipwhite\nsyn match snipContextKeyword \"context\" contained nextgroup=snipContextValue skipwhite display\nsyn match snipContextValue '\"[^\"]*\"' contained contains=snipContextValueP\nsyn region snipContextValueP start=,\"\\@<=., end=,\\ze\", contained contains=@Python skipwhite keepend\n\n\" Actions {{{3\n\nsyn match snipAction \"^\\%(pre_expand\\|post_expand\\|post_jump\\).*$\" contains=snipActionKeyword display skipwhite\nsyn match snipActionKeyword \"\\%(pre_expand\\|post_expand\\|post_jump\\)\" contained nextgroup=snipActionValue skipwhite display\nsyn match snipActionValue '\"[^\"]*\"' contained contains=snipActionValueP\nsyn region snipActionValueP start=,\"\\@<=., end=,\\ze\", contained contains=@Python skipwhite keepend\n\n\" Snippt Clearing {{{2\n\nsyn match snipClear \"^clearsnippets\\%(\\s.*\\|$\\)\" contains=snipClearKeyword display\nsyn match snipClearKeyword \"^clearsnippets\" contained display\n\n\" Highlight groups {{{1\n\nhi def link snipComment          Comment\nhi def link snipTODO             Todo\nhi def snipLeadingSpaces term=reverse ctermfg=15 ctermbg=4 gui=reverse guifg=#dc322f\n\nhi def link snipKeyword          Keyword\n\nhi def link snipExtendsKeyword   snipKeyword\n\nhi def link snipSnippetHeaderKeyword snipKeyword\nhi def link snipSnippetFooterKeyword snipKeyword\n\nhi def link snipSnippetTrigger        Identifier\nhi def link snipSnippetTriggerInvalid Error\nhi def link snipSnippetDocString      String\nhi def link snipSnippetDocContextString String\nhi def link snipSnippetOptionFlag     Special\n\nhi def link snipGlobalHeaderKeyword  snipKeyword\nhi def link snipGlobalFooterKeyword  snipKeyword\n\nhi def link snipCommand          Special\nhi def link snipCommandDelim     snipCommand\nhi def link snipShellCommand     snipCommand\nhi def link snipVimLCommand      snipCommand\nhi def link snipPythonCommandP   PreProc\nhi def link snipVimLCommandV     PreProc\nhi def link snipSnippetContext   String\nhi def link snipContext          String\nhi def link snipAction           String\n\nhi def link snipEscape                     Special\nhi def link snipMirror                     StorageClass\nhi def link snipTabStop                    Define\nhi def link snipTabStopDefault             String\nhi def link snipTabStopEscape              Special\nhi def link snipVisual                     snipTabStop\nhi def link snipVisualDefault              snipTabStopDefault\nhi def link snipTransformation             snipTabStop\nhi def link snipTransformationPattern      String\nhi def link snipTransformationPatternDelim Operator\nhi def link snipTransformationReplace      String\nhi def link snipTransformationEscape       snipEscape\nhi def link snipTransformationOptions      Operator\n\nhi def link snipContextKeyword  Keyword\n\nhi def link snipPriorityKeyword  Keyword\nhi def link snipPriorityValue    Number\n\nhi def link snipActionKeyword  Keyword\n\nhi def link snipClearKeyword     Keyword\n\n\" }}}1\n\nlet b:current_syntax = \"snippets\"\n"
  },
  {
    "path": "syntax/snippets_snipmate.vim",
    "content": "\" Syntax highlighting variant used for snipmate snippets files\n\" The snippets.vim file sources this if it wants snipmate mode\n\nif exists(\"b:current_syntax\")\n    finish\nendif\n\n\" Embedded syntaxes {{{1\n\n\" Re-include the original file so we can share some of its definitions\nlet b:ultisnips_override_snipmate = 1\nsyn include <sfile>:h/snippets.vim\nunlet b:current_syntax\nunlet b:ultisnips_override_snipmate\n\nsyn cluster snipTokens contains=snipEscape,snipVisual,snipTabStop,snipMirror,snipmateCommand\nsyn cluster snipTabStopTokens contains=snipVisual,snipMirror,snipEscape,snipmateCommand\n\n\" Syntax definitions {{{1\n\nsyn match snipmateComment \"^#.*\"\n\nsyn match snipmateExtends \"^extends\\%(\\s.*\\|$\\)\" contains=snipExtendsKeyword display\n\nsyn region snipmateSnippet start=\"^snippet\\ze\\%(\\s\\|$\\)\" end=\"^\\ze[^[:tab:]]\" contains=snipmateSnippetHeader keepend\nsyn match snipmateSnippetHeader \"^.*\" contained contains=snipmateKeyword nextgroup=snipmateSnippetBody skipnl skipempty\nsyn match snipmateKeyword \"^snippet\\ze\\%(\\s\\|$\\)\" contained nextgroup=snipmateTrigger skipwhite\nsyn match snipmateTrigger \"\\S\\+\" contained nextgroup=snipmateDescription skipwhite\nsyn match snipmateDescription \"\\S.*\" contained\nsyn region snipmateSnippetBody start=\"^\\t\" end=\"^\\ze[^[:tab:]]\" contained contains=@snipTokens\n\nsyn region snipmateCommand keepend matchgroup=snipCommandDelim start=\"`\" skip=\"\\\\[{}\\\\$`]\" end=\"`\" contained contains=snipCommandSyntaxOverride,@Viml\n\n\" Highlight groups {{{1\n\nhi def link snipmateComment snipComment\n\nhi def link snipmateSnippet snipSnippet\nhi def link snipmateKeyword snipKeyword\nhi def link snipmateTrigger snipSnippetTrigger\nhi def link snipmateDescription snipSnippetDocString\n\nhi def link snipmateCommand snipCommand\n\n\" }}}1\n\nlet b:current_syntax = \"snippets\"\n"
  },
  {
    "path": "test/__init__.py",
    "content": ""
  },
  {
    "path": "test/constant.py",
    "content": "# Some constants for better reading\nBS = \"\\x7f\"\nESC = \"\\x1b\"\nARR_L = \"\\x1bOD\"\nARR_R = \"\\x1bOC\"\nARR_U = \"\\x1bOA\"\nARR_D = \"\\x1bOB\"\n\n# multi-key sequences generating a single key press\nSEQUENCES = [ARR_L, ARR_R, ARR_U, ARR_D]\n\n# Defined Constants\nJF = \"?\"  # Jump forwards\nJB = \"+\"  # Jump backwards\nLS = \"@\"  # List snippets\nEX = \"\\t\"  # EXPAND\nEA = \"#\"  # Expand anonymous\n\nCOMPL_KW = chr(24) + chr(14)\nCOMPL_ACCEPT = chr(25)\n\nCTRL_V = chr(22)\n"
  },
  {
    "path": "test/test_AnonymousExpansion.py",
    "content": "from test.vim_test_case import VimTestCase as _VimTest\nfrom test.constant import *\n\n\nclass _AnonBase(_VimTest):\n    args = \"\"\n\n    def _extra_vim_config(self, vim_config):\n        vim_config.append(\n            \"inoremap <silent> %s <C-R>=UltiSnips#Anon(%s)<cr>\" % (EA, self.args)\n        )\n\n\nclass Anon_NoTrigger_Simple(_AnonBase):\n    args = '\"simple expand\"'\n    keys = \"abc\" + EA\n    wanted = \"abcsimple expand\"\n\n\nclass Anon_NoTrigger_AfterSpace(_AnonBase):\n    args = '\"simple expand\"'\n    keys = \"abc \" + EA\n    wanted = \"abc simple expand\"\n\n\nclass Anon_NoTrigger_BeginningOfLine(_AnonBase):\n    args = r\"':latex:\\`$1\\`$0'\"\n    keys = EA + \"Hello\" + JF + \"World\"\n    wanted = \":latex:`Hello`World\"\n\n\nclass Anon_NoTrigger_FirstCharOfLine(_AnonBase):\n    args = r\"':latex:\\`$1\\`$0'\"\n    keys = \" \" + EA + \"Hello\" + JF + \"World\"\n    wanted = \" :latex:`Hello`World\"\n\n\nclass Anon_NoTrigger_Multi(_AnonBase):\n    args = '\"simple $1 expand $1 $0\"'\n    keys = \"abc\" + EA + \"123\" + JF + \"456\"\n    wanted = \"abcsimple 123 expand 123 456\"\n\n\nclass Anon_Trigger_Multi(_AnonBase):\n    args = '\"simple $1 expand $1 $0\", \"abc\"'\n    keys = \"123 abc\" + EA + \"123\" + JF + \"456\"\n    wanted = \"123 simple 123 expand 123 456\"\n\n\nclass Anon_Trigger_Simple(_AnonBase):\n    args = '\"simple expand\", \"abc\"'\n    keys = \"abc\" + EA\n    wanted = \"simple expand\"\n\n\nclass Anon_Trigger_Twice(_AnonBase):\n    args = '\"simple expand\", \"abc\"'\n    keys = \"abc\" + EA + \"\\nabc\" + EX\n    wanted = \"simple expand\\nabc\" + EX\n\n\nclass Anon_Trigger_Opts(_AnonBase):\n    args = '\"simple expand\", \".*abc\", \"desc\", \"r\"'\n    keys = \"blah blah abc\" + EA\n    wanted = \"simple expand\"\n"
  },
  {
    "path": "test/test_Autocommands.py",
    "content": "# encoding: utf-8\nfrom test.vim_test_case import VimTestCase as _VimTest\nfrom test.constant import *\n\n\nclass Autocommands(_VimTest):\n    snippets = (\"test\", \"[ ${1:foo} ]\")\n    args = \"\"\n    keys = (\n        \"test\"\n        + EX\n        + \"test\"\n        + EX\n        + \"bar\"\n        + JF\n        + JF\n        + \" done \"\n        + ESC\n        + ':execute \"normal aM\" . g:mapper_call_count . \"\\\\<Esc>\"'\n        + \"\\n\"\n        + ':execute \"normal aU\" . g:unmapper_call_count . \"\\\\<Esc>\"'\n        + \"\\n\"\n    )\n    wanted = \"[ [ bar ] ] done M1U1\"\n\n    def _extra_vim_config(self, vim_config):\n        vim_config.append(\"let g:mapper_call_count = 0\")\n        vim_config.append(\"function! CustomMapper()\")\n        vim_config.append(\"  let g:mapper_call_count += 1\")\n        vim_config.append(\"endfunction\")\n\n        vim_config.append(\"let g:unmapper_call_count = 0\")\n        vim_config.append(\"function! CustomUnmapper()\")\n        vim_config.append(\"  let g:unmapper_call_count += 1\")\n        vim_config.append(\"endfunction\")\n\n        vim_config.append(\"autocmd! User UltiSnipsEnterFirstSnippet\")\n        vim_config.append(\"autocmd User UltiSnipsEnterFirstSnippet call CustomMapper()\")\n        vim_config.append(\"autocmd! User UltiSnipsExitLastSnippet\")\n        vim_config.append(\"autocmd User UltiSnipsExitLastSnippet call CustomUnmapper()\")\n"
  },
  {
    "path": "test/test_Autotrigger.py",
    "content": "from test.vim_test_case import VimTestCase as _VimTest\nfrom test.constant import *\n\n\nclass Autotrigger_CanMatchSimpleTrigger(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        snippet a \"desc\" A\n        autotriggered\n        endsnippet\n        \"\"\"\n    }\n    keys = \"a\"\n    wanted = \"autotriggered\"\n\n\nclass Autotrigger_CanMatchContext(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        snippet a \"desc\" \"snip.line == 2\" Ae\n        autotriggered\n        endsnippet\n        \"\"\"\n    }\n    keys = \"a\\na\"\n    wanted = \"autotriggered\\na\"\n\n\nclass Autotrigger_CanExpandOnTriggerWithLengthMoreThanOne(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        snippet abc \"desc\" A\n        autotriggered\n        endsnippet\n        \"\"\"\n    }\n    keys = \"abc\"\n    wanted = \"autotriggered\"\n\n\nclass Autotrigger_CanMatchPreviouslySelectedPlaceholder(_VimTest):\n\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        snippet if \"desc\"\n        if ${1:var}: pass\n        endsnippet\n        snippet = \"desc\" \"snip.last_placeholder\" Ae\n        `!p snip.rv = snip.context.current_text` == nil\n        endsnippet\n        \"\"\"\n    }\n    keys = \"if\" + EX + \"=\" + ESC + \"o=\"\n    wanted = \"if var == nil: pass\\n=\"\n\nclass Autotrigger_GlobalDisable(_VimTest):\n    def _extra_vim_config(self, vim_config):\n        vim_config.append(\"let g:UltiSnipsAutoTrigger=0\")\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        snippet a \"desc\" A\n        autotriggered\n        endsnippet\n        \"\"\"\n    }\n    keys = \"a\"\n    wanted = \"a\"\n\nclass Autotrigger_CanToggle(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        snippet a \"desc\" A\n        autotriggered\n        endsnippet\n        \"\"\"\n    }\n    keys = (\n        \"a\"\n        + ESC + \":call UltiSnips#ToggleAutoTrigger()\\n\"\n        + \"o\" + \"a\"\n        + ESC + \":call UltiSnips#ToggleAutoTrigger()\\n\"\n        + \"o\" + \"a\"\n    )\n    wanted = \"autotriggered\\na\\nautotriggered\"\n\nclass Autotrigger_GlobalDisableThenToggle(_VimTest):\n    def _extra_vim_config(self, vim_config):\n        vim_config.append(\"let g:UltiSnipsAutoTrigger=0\")\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        snippet a \"desc\" A\n        autotriggered\n        endsnippet\n        \"\"\"\n    }\n    keys = (\n        \"a\"\n        + ESC + \":call UltiSnips#ToggleAutoTrigger()\\n\"\n        + \"o\" + \"a\"\n    )\n    wanted = \"a\\nautotriggered\"\n"
  },
  {
    "path": "test/test_Chars.py",
    "content": "# encoding: utf-8\nfrom test.vim_test_case import VimTestCase as _VimTest\nfrom test.constant import *\nfrom test.util import running_on_windows\n\n\ndef _snip_quote(qt):\n    return (\n        (\"te\" + qt + \"st\", \"Expand me\" + qt + \"!\", \"test: \" + qt),\n        (\"te\", \"Bad\", \"\"),\n    )\n\n\nclass Snippet_With_SingleQuote(_VimTest):\n    snippets = _snip_quote(\"'\")\n    keys = \"te'st\" + EX\n    wanted = \"Expand me'!\"\n\n\nclass Snippet_With_SingleQuote_List(_VimTest):\n    snippets = _snip_quote(\"'\")\n    keys = \"te\" + LS + \"2\\n\"\n    wanted = \"Expand me'!\"\n\n\nclass Snippet_With_DoubleQuote(_VimTest):\n    snippets = _snip_quote('\"')\n    keys = 'te\"st' + EX\n    wanted = 'Expand me\"!'\n\n\nclass Snippet_With_DoubleQuote_List(_VimTest):\n    snippets = _snip_quote('\"')\n    keys = \"te\" + LS + \"2\\n\"\n    wanted = 'Expand me\"!'\n\n\nclass RemoveTrailingWhitespace(_VimTest):\n    snippets = (\"test\", \"\"\"Hello\\t ${1:default}\\n$2\"\"\", \"\", \"s\")\n    wanted = \"\"\"Hello\\nGoodbye\"\"\"\n    keys = \"test\" + EX + BS + JF + \"Goodbye\"\n\n\nclass TrimSpacesAtEndOfLines(_VimTest):\n    snippets = (\"test\", \"\"\"next line\\n\\nshould be empty\"\"\", \"\", \"m\")\n    wanted = \"\"\"\\tnext line\\n\\n\\tshould be empty\"\"\"\n    keys = \"\\ttest\" + EX\n\n\nclass DoNotTrimSpacesAtEndOfLinesByDefault(_VimTest):\n    snippets = (\"test\", \"\"\"next line\\n\\nshould be empty\"\"\", \"\", \"\")\n    wanted = \"\"\"\\tnext line\\n\\t\\n\\tshould be empty\"\"\"\n    keys = \"\\ttest\" + EX\n\n\nclass LeaveTrailingWhitespace(_VimTest):\n    snippets = (\"test\", \"\"\"Hello \\t ${1:default}\\n$2\"\"\")\n    wanted = \"\"\"Hello \\t \\nGoodbye\"\"\"\n    keys = \"test\" + EX + BS + JF + \"Goodbye\"\n\n\n# Tests for bug 616315 #\n\n\nclass TrailingNewline_TabStop_NLInsideStuffBehind(_VimTest):\n    snippets = (\n        \"test\",\n        r\"\"\"\nx${1:\n}<-behind1\n$2<-behind2\"\"\",\n    )\n    keys = \"test\" + EX + \"j\" + JF + \"k\"\n    wanted = \"\"\"\nxj<-behind1\nk<-behind2\"\"\"\n\n\nclass TrailingNewline_TabStop_JustNL(_VimTest):\n    snippets = (\n        \"test\",\n        r\"\"\"\nx${1:\n}\n$2\"\"\",\n    )\n    keys = \"test\" + EX + \"j\" + JF + \"k\"\n    wanted = \"\"\"\nxj\nk\"\"\"\n\n\nclass TrailingNewline_TabStop_EndNL(_VimTest):\n    snippets = (\n        \"test\",\n        r\"\"\"\nx${1:a\n}\n$2\"\"\",\n    )\n    keys = \"test\" + EX + \"j\" + JF + \"k\"\n    wanted = \"\"\"\nxj\nk\"\"\"\n\n\nclass TrailingNewline_TabStop_StartNL(_VimTest):\n    snippets = (\n        \"test\",\n        r\"\"\"\nx${1:\na}\n$2\"\"\",\n    )\n    keys = \"test\" + EX + \"j\" + JF + \"k\"\n    wanted = \"\"\"\nxj\nk\"\"\"\n\n\nclass TrailingNewline_TabStop_EndStartNL(_VimTest):\n    snippets = (\n        \"test\",\n        r\"\"\"\nx${1:\na\n}\n$2\"\"\",\n    )\n    keys = \"test\" + EX + \"j\" + JF + \"k\"\n    wanted = \"\"\"\nxj\nk\"\"\"\n\n\nclass TrailingNewline_TabStop_NotEndStartNL(_VimTest):\n    snippets = (\n        \"test\",\n        r\"\"\"\nx${1:a\na}\n$2\"\"\",\n    )\n    keys = \"test\" + EX + \"j\" + JF + \"k\"\n    wanted = \"\"\"\nxj\nk\"\"\"\n\n\nclass TrailingNewline_TabStop_ExtraNL_ECR(_VimTest):\n    snippets = (\n        \"test\",\n        r\"\"\"\nx${1:a\na}\n$2\n\"\"\",\n    )\n    keys = \"test\" + EX + \"j\" + JF + \"k\"\n    wanted = \"\"\"\nxj\nk\n\"\"\"\n\n\nclass _MultiLineDefault(_VimTest):\n    snippets = (\n        \"test\",\n        r\"\"\"\nx${1:a\nb\nc\nd\ne\nf}\n$2\"\"\",\n    )\n\n\nclass MultiLineDefault_Jump(_MultiLineDefault):\n    keys = \"test\" + EX + JF + \"y\"\n    wanted = \"\"\"\nxa\nb\nc\nd\ne\nf\ny\"\"\"\n\n\nclass MultiLineDefault_Type(_MultiLineDefault):\n    keys = \"test\" + EX + \"z\" + JF + \"y\"\n    wanted = \"\"\"\nxz\ny\"\"\"\n\n\nclass MultiLineDefault_BS(_MultiLineDefault):\n    keys = \"test\" + EX + BS + JF + \"y\"\n    wanted = \"\"\"\nx\ny\"\"\"\n\n\nclass _UmlautsBase(_VimTest):\n    # SendKeys can't send UTF characters\n    skip_if = lambda self: running_on_windows()\n\n\nclass Snippet_With_Umlauts_List(_UmlautsBase):\n    snippets = _snip_quote(\"ü\")\n    keys = \"te\" + LS + \"2\\n\"\n    wanted = \"Expand meü!\"\n\n\nclass Snippet_With_Umlauts(_UmlautsBase):\n    snippets = _snip_quote(\"ü\")\n    keys = \"teüst\" + EX\n    wanted = \"Expand meü!\"\n\n\nclass Snippet_With_Umlauts_TypeOn(_UmlautsBase):\n    snippets = (\"ül\", \"üüüüüßßßß\")\n    keys = \"te ül\" + EX + \"more text\"\n    wanted = \"te üüüüüßßßßmore text\"\n\n\nclass Snippet_With_Umlauts_OverwriteFirst(_UmlautsBase):\n    snippets = (\"ül\", \"üü ${1:world} üü ${2:hello}ßß\\nüüüü\")\n    keys = \"te ül\" + EX + \"more text\" + JF + JF + \"end\"\n    wanted = \"te üü more text üü helloßß\\nüüüüend\"\n\n\nclass Snippet_With_Umlauts_OverwriteSecond(_UmlautsBase):\n    snippets = (\"ül\", \"üü ${1:world} üü ${2:hello}ßß\\nüüüü\")\n    keys = \"te ül\" + EX + JF + \"more text\" + JF + \"end\"\n    wanted = \"te üü world üü more textßß\\nüüüüend\"\n\n\nclass Snippet_With_Umlauts_OverwriteNone(_UmlautsBase):\n    snippets = (\"ül\", \"üü ${1:world} üü ${2:hello}ßß\\nüüüü\")\n    keys = \"te ül\" + EX + JF + JF + \"end\"\n    wanted = \"te üü world üü helloßß\\nüüüüend\"\n\n\nclass Snippet_With_Umlauts_Mirrors(_UmlautsBase):\n    snippets = (\"ül\", \"üü ${1:world} üü $1\")\n    keys = \"te ül\" + EX + \"hello\"\n    wanted = \"te üü hello üü hello\"\n\n\nclass Snippet_With_Umlauts_Python(_UmlautsBase):\n    snippets = (\"ül\", 'üü ${1:world} üü `!p snip.rv = len(t[1])*\"a\"`')\n    keys = \"te ül\" + EX + \"hüüll\"\n    wanted = \"te üü hüüll üü aaaaa\"\n\n\nclass UmlautsBeforeTriggerAndCharsAfter(_UmlautsBase):\n    snippets = (\"trig\", \"success\")\n    keys = \"ööuu trig b\" + 2 * ARR_L + EX\n    wanted = \"ööuu success b\"\n\n\nclass NoUmlautsBeforeTriggerAndCharsAfter(_UmlautsBase):\n    snippets = (\"trig\", \"success\")\n    keys = \"oouu trig b\" + 2 * ARR_L + EX\n    wanted = \"oouu success b\"\n"
  },
  {
    "path": "test/test_Choices.py",
    "content": "from test.vim_test_case import VimTestCase as _VimTest\nfrom test.constant import *\n\n\nclass Choices_WillBeExpandedToInlineSelection(_VimTest):\n    snippets = (\"test\", \"${1|red,gray|}\")\n    keys = \"test\" + EX\n    wanted = \"1.red|2.gray\"\n\n\nclass Choices_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"${1|red,gray|}\")\n    keys = \"test\" + EX + \"2\"\n    wanted = \"gray\"\n\n\nclass Choices_WillAbandonSelection_If_CharTyped(_VimTest):\n    snippets = (\"test\", \"${1|red,green|}\")\n    keys = \"test\" + EX + \"char\"\n    wanted = \"char\"\n\n\nclass Choices_WillAbandonSelection_If_InputIsGreaterThanMaxSelectionIndex(_VimTest):\n    snippets = (\"test\", \"${1|red,green|}\")\n    keys = \"test\" + EX + \"3\"\n    wanted = \"3\"\n\n\nclass Choices_WilNotMessWithTabstopsAfterIt(_VimTest):\n    snippets = (\"test\", \"${1|red,gray|} is ${2:color}\\nline 2\")\n    keys = \"test\" + EX + \"2\"\n    wanted = \"gray is color\\nline 2\"\n\n\nclass Choices_MoreThan9Candidates_ShouldWaitForInputs(_VimTest):\n    snippets = (\"test\", \"${1|a,b,c,d,e,f,g,h,i,j,k,l,m,n|} is ${2:a char}\")\n    keys = \"test\" + EX + \"1\"\n    wanted = \"1 is a char\"\n\n\nclass Choices_MoreThan9Candidates_ShouldTerminateWithSpace(_VimTest):\n    snippets = (\"test\", \"${1|a,b,c,d,e,f,g,h,i,j,k,l,m,n|} is ${2:a char}\")\n    keys = \"test\" + EX + \"1 \"\n    wanted = \"a is a char\"\n\n\nclass Choices_EmptyChoiceWillBeDiscarded(_VimTest):\n    snippets = (\"test\", \"${1|a,,c|}\")\n    keys = \"test\" + EX\n    wanted = \"1.a|2.c\"\n\n\nclass Choices_WillNotExpand_If_ChoiceListIsEmpty(_VimTest):\n    snippets = (\"test\", \"${1||}\")\n    keys = \"test\" + EX\n    wanted = \"||\"\n\n\nclass Choices_CanTakeNonAsciiCharacters(_VimTest):\n    snippets = (\"test\", \"${1|Русский язык,中文,한국어,öääö|}\")\n    keys = \"test\" + EX\n    wanted = \"1.Русский язык|2.中文|3.한국어|4.öääö\"\n\n\nclass Choices_AsNestedElement_ShouldOverwriteDefaultText(_VimTest):\n    snippets = (\"test\", \"${1:outer ${2|foo,blah|}}\")\n    keys = \"test\" + EX\n    wanted = \"outer 1.foo|2.blah\"\n\n\nclass Choices_AsNestedElement_ShallNotTakeActionIfParentInput(_VimTest):\n    snippets = (\"test\", \"${1:outer ${2|foo,blah|}}\")\n    keys = \"test\" + EX + \"input\"\n    wanted = \"input\"\n\n\nclass Choices_AsNestedElement_CanBeTabbedInto(_VimTest):\n    snippets = (\"test\", \"${1:outer ${2|foo,blah|}}\")\n    keys = \"test\" + EX + JF + \"1\"\n    wanted = \"outer foo\"\n\n\nclass Choices_AsNestedElement_CanBeTabbedThrough(_VimTest):\n    snippets = (\"test\", \"${1:outer ${2|foo,blah|}} ${3}\")\n    keys = \"test\" + EX + JF + JF + \"input\"\n    wanted = \"outer 1.foo|2.blah input\"\n\n\nclass Choices_With_Mirror(_VimTest):\n    snippets = (\"test\", \"${1|cyan,magenta|}, mirror: $1\")\n    keys = \"test\" + EX + \"1\"\n    wanted = \"cyan, mirror: cyan\"\n\n\nclass Choices_With_Mirror_ContinueMirroring_EvenAfterSelectionDone(_VimTest):\n    snippets = (\"test\", \"${1|cyan,magenta|}, mirror: $1\")\n    keys = \"test\" + EX + \"1 is a color\"\n    wanted = \"cyan is a color, mirror: cyan is a color\"\n\n\nclass Choices_ShouldThrowErrorWithZeroTabstop(_VimTest):\n    snippets = (\"test\", \"${0|red,blue|}\")\n    keys = \"test\" + EX\n    expected_error = r\"Choices selection is not supported on \\$0\"\n\n\nclass Choices_CanEscapeCommaInsideChoiceItem(_VimTest):\n    snippets = (\n        \"test\",\n        r\"${1|fun1(,fun2(param1\\, ,fun3(param1\\, param2\\, |}param_end) result: $1\",\n    )\n    keys = \"test\" + EX + \"2\"\n    wanted = \"fun2(param1, param_end) result: fun2(param1, \"\n"
  },
  {
    "path": "test/test_Completion.py",
    "content": "from test.vim_test_case import VimTestCase as _VimTest\nfrom test.constant import *\n\n\nclass Completion_SimpleExample_ECR(_VimTest):\n    snippets = (\"test\", \"$1 ${1:blah}\")\n    keys = (\n        \"superkallifragilistik\\ntest\"\n        + EX\n        + \"sup\"\n        + COMPL_KW\n        + COMPL_ACCEPT\n        + \" some more\"\n    )\n    wanted = (\n        \"superkallifragilistik\\nsuperkallifragilistik some more \"\n        \"superkallifragilistik some more\"\n    )\n\n\n# We need >2 different words with identical starts to create the\n# popup-menu:\nCOMPLETION_OPTIONS = \"completion1\\ncompletion2\\n\"\n\n\nclass Completion_ForwardsJumpWithoutCOMPL_ACCEPT(_VimTest):\n    # completions should not be truncated when JF is activated without having\n    # pressed COMPL_ACCEPT (Bug #598903)\n    snippets = (\"test\", \"$1 $2\")\n    keys = COMPLETION_OPTIONS + \"test\" + EX + \"com\" + COMPL_KW + JF + \"foo\"\n    wanted = COMPLETION_OPTIONS + \"completion1 foo\"\n\n\nclass Completion_BackwardsJumpWithoutCOMPL_ACCEPT(_VimTest):\n    # completions should not be truncated when JB is activated without having\n    # pressed COMPL_ACCEPT (Bug #598903)\n    snippets = (\"test\", \"$1 $2\")\n    keys = COMPLETION_OPTIONS + \"test\" + EX + \"foo\" + JF + \"com\" + COMPL_KW + JB + \"foo\"\n    wanted = COMPLETION_OPTIONS + \"foo completion1\"\n"
  },
  {
    "path": "test/test_ContextSnippets.py",
    "content": "from test.constant import *\nfrom test.vim_test_case import VimTestCase as _VimTest\n\n\nclass ContextSnippets_SimpleSnippet(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        snippet a \"desc\" \"True\" e\n        abc\n        endsnippet\n        \"\"\"\n    }\n    keys = \"a\" + EX\n    wanted = \"abc\"\n\n\nclass ContextSnippets_ExpandOnTrue(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        global !p\n        def check_context():\n            return True\n        endglobal\n\n        snippet a \"desc\" \"check_context()\" e\n        abc\n        endsnippet\n        \"\"\"\n    }\n    keys = \"a\" + EX\n    wanted = \"abc\"\n\n\nclass ContextSnippets_DoNotExpandOnFalse(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        global !p\n        def check_context():\n            return False\n        endglobal\n\n        snippet a \"desc\" \"check_context()\" e\n        abc\n        endsnippet\n        \"\"\"\n    }\n    keys = \"a\" + EX\n    wanted = keys\n\n\nclass ContextSnippets_Before(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        context \"len(snip.before) >= 5 and snip.before\"\n        snippet dup \"desc\" i\n        [`!p snip.rv = snip.context[:-3]`]\n        endsnippet\n        \"\"\"\n    }\n    word = \"Süßölgefäß\"\n    keys = \"adup\" + EX + \"\\n\" + word + \"dup\" + EX\n    wanted = \"adup\" + EX + \"\\n\" + word + \"[\" + word + \"]\"\n\n\nclass ContextSnippets_UseContext(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        global !p\n        def wrap(ins):\n            return \"< \" + ins + \" >\"\n        endglobal\n\n        snippet a \"desc\" \"wrap(snip.buffer[snip.line])\" e\n        { `!p snip.rv = context` }\n        endsnippet\n        \"\"\"\n    }\n    keys = \"a\" + EX\n    wanted = \"{ < a > }\"\n\n\nclass ContextSnippets_SnippetPriority(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        snippet i \"desc\" \"re.search('err :=', snip.buffer[snip.line-1])\" e\n        if err != nil {\n            ${1:// pass}\n        }\n        endsnippet\n\n        snippet i\n        if ${1:true} {\n            ${2:// pass}\n        }\n        endsnippet\n        \"\"\"\n    }\n\n    keys = (\n        r\"\"\"\n        err := some_call()\n        i\"\"\"\n        + EX\n        + JF\n        + \"\"\"\n        i\"\"\"\n        + EX\n    )\n    wanted = r\"\"\"\n        err := some_call()\n        if err != nil {\n            // pass\n        }\n        if true {\n            // pass\n        }\"\"\"\n\n\nclass ContextSnippets_PriorityKeyword(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        snippet i \"desc\" \"True\" e\n        a\n        endsnippet\n\n        priority 100\n        snippet i\n        b\n        endsnippet\n        \"\"\"\n    }\n\n    keys = \"i\" + EX\n    wanted = \"b\"\n\n\nclass ContextSnippets_ReportError(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        snippet e \"desc\" \"Tru\" e\n        error\n        endsnippet\n        \"\"\"\n    }\n\n    keys = \"e\" + EX\n    wanted = \"e\" + EX\n    expected_error = r\"NameError: name 'Tru' is not defined\"\n\n\nclass ContextSnippets_ReportErrorOnIndexOutOfRange(_VimTest):\n    # Working around: https://github.com/neovim/python-client/issues/128.\n    skip_if = lambda self: \"Bug in Neovim.\" if self.vim_flavor == \"neovim\" else None\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        snippet e \"desc\" \"snip.buffer[123]\" e\n        error\n        endsnippet\n        \"\"\"\n    }\n\n    keys = \"e\" + EX\n    wanted = \"e\" + EX\n    expected_error = r\"IndexError: line number out of range\"\n\n\nclass ContextSnippets_CursorIsZeroBased(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        snippet e \"desc\" \"snip.cursor\" e\n        `!p snip.rv = str(snip.context)`\n        endsnippet\n        \"\"\"\n    }\n\n    keys = \"e\" + EX\n    wanted = \"(2, 1)\"\n\n\nclass ContextSnippets_ContextIsClearedBeforeExpand(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        pre_expand \"snip.context = 1 if snip.context is None else 2\"\n        snippet e \"desc\" w\n        `!p snip.rv = str(snip.context)`\n        endsnippet\n        \"\"\"\n    }\n\n    keys = \"e\" + EX + \" \" + \"e\" + EX\n    wanted = \"1 1\"\n\n\nclass ContextSnippets_ContextHasAccessToVisual(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        snippet test \"desc\" \"snip.visual_text == '123'\" we\n        Yes\n        endsnippet\n\n        snippet test \"desc\" w\n        No\n        endsnippet\n        \"\"\"\n    }\n\n    keys = (\n        \"123\" + ESC + \"vhh\" + EX + \"test\" + EX + \" zzz\" + ESC + \"vhh\" + EX + \"test\" + EX\n    )\n    wanted = \"Yes No\"\n\n\nclass ContextSnippets_Header_ExpandOnTrue(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        global !p\n        def check_context():\n            return True\n        endglobal\n\n        context \"check_context()\"\n        snippet a \"desc\" e\n        abc\n        endsnippet\n        \"\"\"\n    }\n    keys = \"a\" + EX\n    wanted = \"abc\"\n\n\nclass ContextSnippets_Header_DoNotExpandOnFalse(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        global !p\n        def check_context():\n            return False\n        endglobal\n\n        context \"check_context()\"\n        snippet a \"desc\" e\n        abc\n        endsnippet\n        \"\"\"\n    }\n    keys = \"a\" + EX\n    wanted = keys\n\n\nclass ContextSnippets_ContextHasAccessToReMatch(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        context \"match.group(1) != 'no'\"\n        snippet \"(\\w*) xxx\" \"desc\" r\n        HERE\n        endsnippet\n        \"\"\"\n    }\n    negative = \"no xxx\"\n    positive = \"yes xxx\"\n    keys = negative + EX + positive + EX\n    wanted = negative + EX + \"HERE\"\n"
  },
  {
    "path": "test/test_Editing.py",
    "content": "from test.vim_test_case import VimTestCase as _VimTest\nfrom test.constant import *\n\n\nclass Undo_RemoveMultilineSnippet(_VimTest):\n    snippets = (\"test\", \"Hello\\naaa ${1} bbb\\nWorld\")\n    keys = \"test\" + EX + ESC + \"u\"\n    wanted = \"test\"\n\n\nclass Undo_RemoveEditInTabstop(_VimTest):\n    snippets = (\"test\", \"$1 Hello\\naaa ${1} bbb\\nWorld\")\n    keys = \"hello test\" + EX + \"upsi\" + ESC + \"hh\" + \"iabcdef\" + ESC + \"u\"\n    wanted = \"hello upsi Hello\\naaa upsi bbb\\nWorld\"\n\n\nclass Undo_RemoveWholeSnippet(_VimTest):\n    snippets = (\"test\", \"Hello\\n${1:Hello}World\")\n    keys = \"first line\\n\\n\\n\\n\\n\\nthird line\" + ESC + \"3k0itest\" + EX + ESC + \"u6j\"\n    wanted = \"first line\\n\\n\\ntest\\n\\n\\nthird line\"\n\n\nclass Undo_RemoveOneSnippetByTime(_VimTest):\n    snippets = (\"i\", \"if:\\n\\t$1\")\n    keys = \"i\" + EX + \"i\" + EX + ESC + \"u\"\n    wanted = \"if:\\n\\ti\"\n\n\nclass Undo_RemoveOneSnippetByTime2(_VimTest):\n    snippets = (\"i\", \"if:\\n\\t$1\")\n    keys = \"i\" + EX + \"i\" + EX + ESC + \"uu\"\n    wanted = \"if:\\n\\t\"\n\n\nclass Undo_ChangesInPlaceholder(_VimTest):\n    snippets = (\"i\", \"if $1:\\n\\t$2\")\n    keys = \"i\" + EX + \"asd\" + JF + ESC + \"u\"\n    wanted = \"if :\\n\\t\"\n\n\nclass Undo_CompletelyUndoSnippet(_VimTest):\n    snippets = (\"i\", \"if $1:\\n\\t$2\")\n    # undo 'feh'\n    # undo 'asd'\n    # undo snippet expansion\n    # undo entering of 'i'\n    keys = \"i\" + EX + \"asd\" + JF + \"feh\" + ESC + \"uuuu\"\n    wanted = \"\"\n\n\nclass JumpForward_DefSnippet(_VimTest):\n    snippets = (\"test\", \"${1}\\n`!p snip.rv = '\\\\n'.join(t[1].split())`\\n\\n${0:pass}\")\n    keys = \"test\" + EX + \"a b c\" + JF + \"shallnot\"\n    wanted = \"a b c\\na\\nb\\nc\\n\\nshallnot\"\n\n\nclass DeleteSnippetInsertion0(_VimTest):\n    snippets = (\"test\", \"${1:hello} $1\")\n    keys = \"test\" + EX + ESC + \"Vkx\" + \"i\\nworld\\n\"\n    wanted = \"world\"\n\n\nclass DeleteSnippetInsertion1(_VimTest):\n    snippets = (\"test\", r\"$1${1/(.*)/(?0::.)/}\")\n    keys = \"test\" + EX + ESC + \"u\"\n    wanted = \"test\"\n\n\nclass DoNotCrashOnUndoAndJumpInNestedSnippet(_VimTest):\n    snippets = (\"test\", r\"if $1: $2\")\n    keys = \"test\" + EX + \"a\" + JF + \"test\" + EX + ESC + \"u\" + JF\n    wanted = \"if a: test\"\n\n\n# Test for bug #927844\nclass DeleteLastTwoLinesInSnippet(_VimTest):\n    snippets = (\"test\", \"$1hello\\nnice\\nworld\")\n    keys = \"test\" + EX + ESC + \"j2dd\"\n    wanted = \"hello\"\n\n\nclass DeleteCurrentTabStop1_JumpBack(_VimTest):\n    snippets = (\"test\", \"${1:hi}\\nend\")\n    keys = \"test\" + EX + ESC + \"ddi\" + JB\n    wanted = \"end\"\n\n\nclass DeleteCurrentTabStop2_JumpBack(_VimTest):\n    snippets = (\"test\", \"${1:hi}\\n${2:world}\\nend\")\n    keys = \"test\" + EX + JF + ESC + \"ddi\" + JB + \"hello\"\n    wanted = \"hello\\nend\"\n\n\nclass DeleteCurrentTabStop3_JumpAround(_VimTest):\n    snippets = (\"test\", \"${1:hi}\\n${2:world}\\nend\")\n    keys = \"test\" + EX + JF + ESC + \"ddkji\" + JB + \"hello\" + JF + \"world\"\n    wanted = \"hello\\nendworld\"\n\n\n# Test for Bug #774917\n\n\nclass Backspace_TabStop_Zero(_VimTest):\n    snippets = (\"test\", \"A${1:C} ${0:DDD}\", \"This is Case 1\")\n    keys = \"test\" + EX + \"A\" + JF + BS + \"BBB\"\n    wanted = \"AA BBB\"\n\n\nclass Backspace_TabStop_NotZero(_VimTest):\n    snippets = (\"test\", \"A${1:C} ${2:DDD}\", \"This is Case 1\")\n    keys = \"test\" + EX + \"A\" + JF + BS + \"BBB\"\n    wanted = \"AA BBB\"\n\n\nclass UpdateModifiedSnippetWithoutCursorMove1(_VimTest):\n    snippets = (\"test\", \"${1:one}(${2:xxx})${3:three}\")\n    keys = \"test\" + EX + \"aaaaa\" + JF + BS + JF + \"3333\"\n    wanted = \"aaaaa()3333\"\n\n\nclass UpdateModifiedSnippetWithoutCursorMove2(_VimTest):\n    snippets = (\n        \"test\",\n        \"\"\"\\\nprivate function ${1:functionName}(${2:arguments}):${3:Void}\n{\n    ${VISUAL}$0\n}\"\"\",\n    )\n    keys = \"test\" + EX + \"a\" + JF + BS + JF + \"Int\" + JF + \"body\"\n    wanted = \"\"\"\\\nprivate function a():Int\n{\n    body\n}\"\"\"\n"
  },
  {
    "path": "test/test_Expand.py",
    "content": "from test.vim_test_case import VimTestCase as _VimTest\nfrom test.constant import *\n\n\nclass _SimpleExpands(_VimTest):\n    snippets = (\"hallo\", \"Hallo Welt!\")\n\n\nclass SimpleExpand_ExpectCorrectResult(_SimpleExpands):\n    keys = \"hallo\" + EX\n    wanted = \"Hallo Welt!\"\n\n\nclass SimpleExpandTwice_ExpectCorrectResult(_SimpleExpands):\n    keys = \"hallo\" + EX + \"\\nhallo\" + EX\n    wanted = \"Hallo Welt!\\nHallo Welt!\"\n\n\nclass SimpleExpandNewLineAndBackspae_ExpectCorrectResult(_SimpleExpands):\n    keys = \"hallo\" + EX + \"\\nHallo Welt!\\n\\n\\b\\b\\b\\b\\b\"\n    wanted = \"Hallo Welt!\\nHallo We\"\n\n    def _extra_vim_config(self, vim_config):\n        vim_config.append(\"set backspace=eol,start\")\n\n\nclass SimpleExpandTypeAfterExpand_ExpectCorrectResult(_SimpleExpands):\n    keys = \"hallo\" + EX + \"and again\"\n    wanted = \"Hallo Welt!and again\"\n\n\nclass SimpleExpandTypeAndDelete_ExpectCorrectResult(_SimpleExpands):\n    keys = \"na du hallo\" + EX + \"and again\\b\\b\\b\\b\\bblub\"\n    wanted = \"na du Hallo Welt!and blub\"\n\n\nclass DoNotExpandAfterSpace_ExpectCorrectResult(_SimpleExpands):\n    keys = \"hallo \" + EX\n    wanted = \"hallo \" + EX\n\n\nclass ExitSnippetModeAfterTabstopZero(_VimTest):\n    snippets = (\"test\", \"SimpleText\")\n    keys = \"test\" + EX + EX\n    wanted = \"SimpleText\" + EX\n\n\nclass ExpandInTheMiddleOfLine_ExpectCorrectResult(_SimpleExpands):\n    keys = \"Wie hallo gehts\" + ESC + \"bhi\" + EX\n    wanted = \"Wie Hallo Welt! gehts\"\n\n\nclass MultilineExpand_ExpectCorrectResult(_VimTest):\n    snippets = (\"hallo\", \"Hallo Welt!\\nUnd Wie gehts\")\n    keys = \"Wie hallo gehts\" + ESC + \"bhi\" + EX\n    wanted = \"Wie Hallo Welt!\\nUnd Wie gehts gehts\"\n\n\nclass MultilineExpandTestTyping_ExpectCorrectResult(_VimTest):\n    snippets = (\"hallo\", \"Hallo Welt!\\nUnd Wie gehts\")\n    wanted = \"Wie Hallo Welt!\\nUnd Wie gehtsHuiui! gehts\"\n    keys = \"Wie hallo gehts\" + ESC + \"bhi\" + EX + \"Huiui!\"\n\n\nclass SimpleExpandEndingWithNewline_ExpectCorrectResult(_VimTest):\n    snippets = (\"hallo\", \"Hallo Welt\\n\")\n    keys = \"hallo\" + EX + \"\\nAnd more\"\n    wanted = \"Hallo Welt\\n\\nAnd more\"\n\n\nclass SimpleExpand_DoNotClobberDefaultRegister(_VimTest):\n    snippets = (\"hallo\", \"Hallo ${1:Welt}\")\n    keys = \"hallo\" + EX + BS + ESC + \"o\" + ESC + \"P\"\n    wanted = \"Hallo \\n\"\n\n    def _extra_vim_config(self, vim_config):\n        vim_config.append('let @\"=\"\"')\n\n\nclass SimpleExpand_Issue1343(_VimTest):\n    snippets = (\"test\", r\"${1:\\Safe\\\\}\")\n    keys = \"test\" + EX + JF + \"foo\"\n    wanted = r\"\\Safe\\foo\"\n\nclass SimpleExpandJumpOrExpand_Expand(_VimTest):\n    snippets = (\"hallo\", \"Hallo Welt!\")\n    keys = \"hallo\" + EX\n    wanted = \"Hallo Welt!\"\n    \n    def _extra_vim_config(self, vim_config):\n        vim_config.append('let g:UltiSnipsJumpOrExpandTrigger=\"<tab>\"')\n\nclass SimpleExpandJumpOrExpand_Ambiguity(_VimTest):\n    snippets = (\"test\", r\"test$1 foo$0\")\n    keys = \"test\" + EX + EX + \"foo\"\n    wanted = \"test foofoo\"\n    \n    def _extra_vim_config(self, vim_config):\n        vim_config.append('let g:UltiSnipsJumpOrExpandTrigger=\"<tab>\"')\n\nclass SimpleExpandExpandOrJump_Expand(_VimTest):\n    snippets = (\"hallo\", \"Hallo Welt!\")\n    keys = \"hallo\" + EX\n    wanted = \"Hallo Welt!\"\n    \n    def _extra_vim_config(self, vim_config):\n        vim_config.append('let g:UltiSnipsExpandOrJumpTrigger=\"<tab>\"')\n\nclass SimpleExpandExpandOrJump_Ambiguity(_VimTest):\n    snippets = (\"test\", r\"test$1 foo$0\")\n    keys = \"test\" + EX + EX + \"foo\"\n    wanted = \"testfoo foo foo\"\n    \n    def _extra_vim_config(self, vim_config):\n        vim_config.append('let g:UltiSnipsExpandOrJumpTrigger=\"<tab>\"')"
  },
  {
    "path": "test/test_Fixes.py",
    "content": "import unittest\n\nfrom test.vim_test_case import VimTestCase as _VimTest\nfrom test.constant import *\n\n\nclass Bug1251994(_VimTest):\n    snippets = (\"test\", \"${2:#2} ${1:#1};$0\")\n    keys = \"  test\" + EX + \"hello\" + JF + \"world\" + JF + \"blub\"\n    wanted = \"  world hello;blub\"\n\n\n# Test for https://github.com/SirVer/ultisnips/issues/157 (virtualedit)\n\n\nclass VirtualEdit(_VimTest):\n    snippets = (\"pd\", \"padding: ${1:0}px\")\n    keys = \"\\t\\t\\tpd\" + EX + \"2\"\n    wanted = \"\\t\\t\\tpadding: 2px\"\n\n    def _extra_vim_config(self, vim_config):\n        vim_config.append(\"set virtualedit=all\")\n        vim_config.append(\"set noexpandtab\")\n\n\n# End: 1251994\n\n# Test for Github Pull Request #134 - Retain unnamed register\n\n\nclass RetainsTheUnnamedRegister(_VimTest):\n    snippets = (\"test\", \"${1:hello} ${2:world} ${0}\")\n    keys = \"yank\" + ESC + \"by4lea test\" + EX + \"HELLO\" + JF + JF + ESC + \"p\"\n    wanted = \"yank HELLO world yank\"\n\n\nclass RetainsTheUnnamedRegister_ButOnlyOnce(_VimTest):\n    snippets = (\"test\", \"${1:hello} ${2:world} ${0}\")\n    keys = (\n        \"blahfasel\"\n        + ESC\n        + \"v\"\n        + 4 * ARR_L\n        + \"xotest\"\n        + EX\n        + ESC\n        + ARR_U\n        + \"v0xo\"\n        + ESC\n        + \"p\"\n    )\n    wanted = \"\\nblah\\nhello world \"\n\n\n# End: Github Pull Request # 134\n\n# Test to ensure that shiftwidth follows tabstop when it's set to zero post\n# version 7.3.693. Prior to that version a shiftwidth of zero effectively\n# removes tabs.\n\n\nclass ShiftWidthZero(_VimTest):\n    def _extra_vim_config(self, vim_config):\n        vim_config += [\"if exists('*shiftwidth')\", \"  set shiftwidth=0\", \"endif\"]\n\n    snippets = (\"test\", \"\\t${1}${0}\")\n    keys = \"test\" + EX + \"foo\"\n    wanted = \"\\tfoo\"\n\n\n# Test for https://github.com/SirVer/ultisnips/issues/171\n# Make sure that we don't crash when trying to save and restore the clipboard\n# when it contains data that we can't coerce into Unicode.\n\n\nclass NonUnicodeDataInUnnamedRegister(_VimTest):\n    snippets = (\"test\", \"hello\")\n    keys = (\n        \"test\"\n        + EX\n        + ESC\n        + \"\\n\".join(\n            [\n                \":redir @a\",\n                \":messages\",\n                \":redir END\",\n                (\n                    \":if match(@a, 'Error') != -1 | \"\n                    + \"call setline('.', 'error detected') | \"\n                    + \"3put a | \"\n                    + \"endif\"\n                ),\n                \"\",\n            ]\n        )\n    )\n    wanted = \"hello\"\n\n    def _before_test(self):\n        # The string below was the one a user had on their clipboard when\n        # encountering the UnicodeDecodeError and could not be coerced into\n        # unicode.\n        self.vim.send_to_vim(\n            ':let @\" = \"\\\\x80kdI{\\\\x80@7 1},'\n            + '\\\\x80kh\\\\x80kh\\\\x80kd\\\\x80kdq\\\\x80kb\\\\x1b\"\\n'\n        )\n\n\n# End: #171\n\n\n# Test for #1184\n# UltiSnips should pass through any mapping that it currently can't execute as\n# the trigger key\n\n\nclass PassThroughNonexecutedTrigger(_VimTest):\n    snippets = (\"text\", \"Expand me!\", \"\", \"\")\n    keys = (\n        \"tex\"\n        + EX\n        + \"more\\n\"  # this should be passed through\n        + \"text\"\n        + EX  # this should be expanded\n    )\n    wanted = \"tex\" + EX + \"more\\nExpand me!\"\n\n\n# End: #1184\n\n\n# Tests for https://github.com/SirVer/ultisnips/issues/1386 (embedded null byte)\n\n\nNULL_BYTE = CTRL_V + \"000\"\n\n\nclass NullByte_ListSnippets(_VimTest):\n    snippets = (\"word\", \"never expanded\", \"\", \"w\")\n    keys = \"foobar\" + NULL_BYTE + LS + \"\\n\"\n    wanted = \"foobar\\x00\\n\"\n\n\nclass NullByte_ExpandAfter(_VimTest):\n    snippets = (\"test\", \"Expand me!\", \"\", \"w\")\n    keys = \"foobar \" + NULL_BYTE + \"test\" + EX\n    wanted = \"foobar \\x00Expand me!\"\n\n\n# End: #1386\n"
  },
  {
    "path": "test/test_Folding.py",
    "content": "from test.vim_test_case import VimTestCase as _VimTest\nfrom test.constant import *\n\n\nclass FoldingEnabled_SnippetWithFold_ExpectNoFolding(_VimTest):\n    def _extra_vim_config(self, vim_config):\n        vim_config.append(\"set foldlevel=0\")\n        vim_config.append(\"set foldmethod=marker\")\n\n    snippets = (\n        \"test\",\n        r\"\"\"Hello {{{\n${1:Welt} }}}\"\"\",\n    )\n    keys = \"test\" + EX + \"Ball\"\n    wanted = \"\"\"Hello {{{\nBall }}}\"\"\"\n\n\nclass FoldOverwrite_Simple_ECR(_VimTest):\n    snippets = (\n        \"fold\",\n        \"\"\"# ${1:Description}  `!p snip.rv = vim.eval(\"&foldmarker\").split(\",\")[0]`\n\n# End: $1  `!p snip.rv = vim.eval(\"&foldmarker\").split(\",\")[1]`\"\"\",\n    )\n    keys = \"fold\" + EX + \"hi\"\n    wanted = \"# hi  {{{\\n\\n# End: hi  }}}\"\n\n\nclass Fold_DeleteMiddleLine_ECR(_VimTest):\n    snippets = (\n        \"fold\",\n        \"\"\"# ${1:Description}  `!p snip.rv = vim.eval(\"&foldmarker\").split(\",\")[0]`\n\n\n# End: $1  `!p snip.rv = vim.eval(\"&foldmarker\").split(\",\")[1]`\"\"\",\n    )\n    keys = \"fold\" + EX + \"hi\" + ESC + \"jdd\"\n    wanted = \"# hi  {{{\\n\\n# End: hi  }}}\"\n\n\nclass PerlSyntaxFold(_VimTest):\n    def _extra_vim_config(self, vim_config):\n        vim_config.append(\"set foldlevel=0\")\n        vim_config.append(\"syntax enable\")\n        vim_config.append(\"set foldmethod=syntax\")\n        vim_config.append(\"let g:perl_fold = 1\")\n        vim_config.append(\"so $VIMRUNTIME/syntax/perl.vim\")\n\n    snippets = (\n        \"test\",\n        r\"\"\"package ${1:`!v printf('c%02d', 3)`};\n${0}\n1;\"\"\",\n    )\n    keys = \"test\" + EX + JF + \"sub junk {}\"\n    wanted = \"package c03;\\nsub junk {}\\n1;\"\n"
  },
  {
    "path": "test/test_Format.py",
    "content": "from test.vim_test_case import VimTestCase as _VimTest\nfrom test.constant import *\nfrom test.util import running_on_windows\n\n\nclass _ExpandTabs(_VimTest):\n    def _extra_vim_config(self, vim_config):\n        vim_config.append(\"set sw=3\")\n        vim_config.append(\"set expandtab\")\n\n\nclass RecTabStopsWithExpandtab_SimpleExample_ECR(_ExpandTabs):\n    snippets = (\"m\", \"\\tBlaahblah \\t\\t  \")\n    keys = \"m\" + EX\n    wanted = \"   Blaahblah \\t\\t  \"\n\n\nclass RecTabStopsWithExpandtab_SpecialIndentProblem_ECR(_ExpandTabs):\n    # Windows indents the Something line after pressing return, though it\n    # shouldn't because it contains a manual indent. All other vim versions do\n    # not do this. Windows vim does not interpret the changes made by :py as\n    # changes made 'manually', while the other vim version seem to do so. Since\n    # the fault is not with UltiSnips, we simply skip this test on windows\n    # completely.\n    skip_if = lambda self: running_on_windows()\n    snippets = ((\"m1\", \"Something\"), (\"m\", \"\\t$0\"))\n    keys = \"m\" + EX + \"m1\" + EX + \"\\nHallo\"\n    wanted = \"   Something\\n        Hallo\"\n\n    def _extra_vim_config(self, vim_config):\n        _ExpandTabs._extra_vim_config(self, vim_config)\n        vim_config.append(\"set indentkeys=o,O,*<Return>,<>>,{,}\")\n        vim_config.append(\"set indentexpr=8\")\n\n\nclass ProperIndenting_SimpleCase_ECR(_VimTest):\n    snippets = (\"test\", \"for\\n    blah\")\n    keys = \"    test\" + EX + \"Hui\"\n    wanted = \"    for\\n        blahHui\"\n\n\nclass ProperIndenting_SingleLineNoReindenting_ECR(_VimTest):\n    snippets = (\"test\", \"hui\")\n    keys = \"    test\" + EX + \"blah\"\n    wanted = \"    huiblah\"\n\n\nclass ProperIndenting_AutoIndentAndNewline_ECR(_VimTest):\n    snippets = (\"test\", \"hui\")\n    keys = \"    test\" + EX + \"\\n\" + \"blah\"\n    wanted = \"    hui\\n    blah\"\n\n    def _extra_vim_config(self, vim_config):\n        vim_config.append(\"set autoindent\")\n\n\n# Test for bug 1073816\n\n\nclass ProperIndenting_FirstLineInFile_ECR(_VimTest):\n    text_before = \"\"\n    text_after = \"\"\n    files = {\n        \"us/all.snippets\": r\"\"\"\nglobal !p\ndef complete(t, opts):\n  if t:\n    opts = [ m[len(t):] for m in opts if m.startswith(t) ]\n  if len(opts) == 1:\n    return opts[0]\n  elif len(opts) > 1:\n    return \"(\" + \"|\".join(opts) + \")\"\n  else:\n    return \"\"\nendglobal\n\nsnippet '^#?inc' \"#include <>\" !r\n#include <$1`!p snip.rv = complete(t[1], ['cassert', 'cstdio', 'cstdlib', 'cstring', 'fstream', 'iostream', 'sstream'])`>\nendsnippet\n        \"\"\"\n    }\n    keys = \"inc\" + EX + \"foo\"\n    wanted = \"#include <foo>\"\n\n\nclass ProperIndenting_FirstLineInFileComplete_ECR(ProperIndenting_FirstLineInFile_ECR):\n    keys = \"inc\" + EX + \"cstdl\"\n    wanted = \"#include <cstdlib>\"\n\n\nclass _FormatoptionsBase(_VimTest):\n    def _extra_vim_config(self, vim_config):\n        vim_config.append(\"set tw=20\")\n        vim_config.append(\"set fo=lrqntc\")\n\n\nclass FOSimple_Break_ExpectCorrectResult(_FormatoptionsBase):\n    snippets = (\"test\", \"${1:longer expand}\\n$1\\n$0\", \"\", \"f\")\n    keys = (\n        \"test\"\n        + EX\n        + \"This is a longer text that should wrap as formatoptions are  enabled\"\n        + JF\n        + \"end\"\n    )\n    wanted = (\n        \"This is a longer\\ntext that should\\nwrap as\\nformatoptions are\\nenabled\\n\"\n        + \"This is a longer\\ntext that should\\nwrap as\\nformatoptions are\\nenabled\\n\"\n        + \"end\"\n    )\n\n\nclass FOTextBeforeAndAfter_ExpectCorrectResult(_FormatoptionsBase):\n    snippets = (\"test\", \"Before${1:longer expand}After\\nstart$1end\")\n    keys = \"test\" + EX + \"This is a longer text that should wrap\"\n    wanted = \"\"\"BeforeThis is a\nlonger text that\nshould wrapAfter\nstartThis is a\nlonger text that\nshould wrapend\"\"\"\n\n\n# Tests for https://bugs.launchpad.net/bugs/719998\nclass FOTextAfter_ExpectCorrectResult(_FormatoptionsBase):\n    snippets = (\"test\", \"${1:longer expand}after\\nstart$1end\")\n    keys = (\n        \"test\" + EX + \"This is a longer snippet that should wrap properly \"\n        \"and the mirror below should work as well\"\n    )\n    wanted = \"\"\"This is a longer\nsnippet that should\nwrap properly and\nthe mirror below\nshould work as wellafter\nstartThis is a longer\nsnippet that should\nwrap properly and\nthe mirror below\nshould work as wellend\"\"\"\n\n\nclass FOWrapOnLongWord_ExpectCorrectResult(_FormatoptionsBase):\n    snippets = (\"test\", \"${1:longer expand}after\\nstart$1end\")\n    keys = \"test\" + EX + \"This is a longersnippet that should wrap properly\"\n    wanted = \"\"\"This is a\nlongersnippet that\nshould wrap properlyafter\nstartThis is a\nlongersnippet that\nshould wrap properlyend\"\"\"\n"
  },
  {
    "path": "test/test_Interpolation.py",
    "content": "# encoding: utf-8\nimport os\n\nfrom test.vim_test_case import VimTestCase as _VimTest\nfrom test.constant import EX, JF, ESC\nfrom test.util import running_on_windows\n\n\nclass TabStop_Shell_SimpleExample(_VimTest):\n    skip_if = lambda self: running_on_windows()\n    snippets = (\"test\", \"hi `echo hallo` you!\")\n    keys = \"test\" + EX + \"and more\"\n    wanted = \"hi hallo you!and more\"\n\n\nclass TabStop_Shell_WithUmlauts(_VimTest):\n    skip_if = lambda self: running_on_windows()\n    snippets = (\"test\", \"hi `echo höüäh` you!\")\n    keys = \"test\" + EX + \"and more\"\n    wanted = \"hi höüäh you!and more\"\n\n\nclass TabStop_Shell_TextInNextLine(_VimTest):\n    skip_if = lambda self: running_on_windows()\n    snippets = (\"test\", \"hi `echo hallo`\\nWeiter\")\n    keys = \"test\" + EX + \"and more\"\n    wanted = \"hi hallo\\nWeiterand more\"\n\n\nclass TabStop_Shell_InDefValue_Leave(_VimTest):\n    skip_if = lambda self: running_on_windows()\n    snippets = (\"test\", \"Hallo ${1:now `echo fromecho`} end\")\n    keys = \"test\" + EX + JF + \"and more\"\n    wanted = \"Hallo now fromecho endand more\"\n\n\nclass TabStop_Shell_InDefValue_Overwrite(_VimTest):\n    skip_if = lambda self: running_on_windows()\n    snippets = (\"test\", \"Hallo ${1:now `echo fromecho`} end\")\n    keys = \"test\" + EX + \"overwrite\" + JF + \"and more\"\n    wanted = \"Hallo overwrite endand more\"\n\n\nclass TabStop_Shell_TestEscapedChars_Overwrite(_VimTest):\n    skip_if = lambda self: running_on_windows()\n    snippets = (\"test\", r\"\"\"`echo \\`echo \"\\\\$hi\"\\``\"\"\")\n    keys = \"test\" + EX\n    wanted = \"$hi\"\n\n\nclass TabStop_Shell_TestEscapedCharsAndShellVars_Overwrite(_VimTest):\n    skip_if = lambda self: running_on_windows()\n    snippets = (\"test\", r\"\"\"`hi=\"blah\"; echo \\`echo \"$hi\"\\``\"\"\")\n    keys = \"test\" + EX\n    wanted = \"blah\"\n\n\nclass TabStop_Shell_ShebangPython(_VimTest):\n    skip_if = lambda self: running_on_windows()\n    snippets = (\n        \"test\",\n        \"\"\"Hallo ${1:now `#!/usr/bin/env %s\nprint(\"Hallo Welt\")\n`} end\"\"\"\n        % os.environ.get(\"PYTHON\", \"python3\"),\n    )\n    keys = \"test\" + EX + JF + \"and more\"\n    wanted = \"Hallo now Hallo Welt endand more\"\n\n\nclass TabStop_VimScriptInterpolation_SimpleExample(_VimTest):\n    snippets = (\"test\", \"\"\"hi `!v indent(\".\")` End\"\"\")\n    keys = \"    test\" + EX\n    wanted = \"    hi 4 End\"\n\n\nclass PythonCodeOld_SimpleExample(_VimTest):\n    snippets = (\"test\", \"\"\"hi `!p res = \"Hallo\"` End\"\"\")\n    keys = \"test\" + EX\n    wanted = \"hi Hallo End\"\n\n\nclass PythonCodeOld_ReferencePlaceholderAfter(_VimTest):\n    snippets = (\"test\", \"\"\"${1:hi} `!p res = t[1]+\".blah\"` End\"\"\")\n    keys = \"test\" + EX + \"ho\"\n    wanted = \"ho ho.blah End\"\n\n\nclass PythonCodeOld_ReferencePlaceholderBefore(_VimTest):\n    snippets = (\"test\", \"\"\"`!p res = len(t[1])*\"#\"`\\n${1:some text}\"\"\")\n    keys = \"test\" + EX + \"Hallo Welt\"\n    wanted = \"##########\\nHallo Welt\"\n\n\nclass PythonCodeOld_TransformedBeforeMultiLine(_VimTest):\n    snippets = (\n        \"test\",\n        \"\"\"${1/.+/egal/m} ${1:`!p\nres = \"Hallo\"`} End\"\"\",\n    )\n    keys = \"test\" + EX\n    wanted = \"egal Hallo End\"\n\n\nclass PythonCodeOld_IndentedMultiline(_VimTest):\n    snippets = (\n        \"test\",\n        \"\"\"start `!p a = 1\nb = 2\nif b > a:\n    res = \"b isbigger a\"\nelse:\n    res = \"a isbigger b\"` end\"\"\",\n    )\n    keys = \"    test\" + EX\n    wanted = \"    start b isbigger a end\"\n\n\nclass PythonCode_UseNewOverOld(_VimTest):\n    snippets = (\n        \"test\",\n        \"\"\"hi `!p res = \"Old\"\nsnip.rv = \"New\"` End\"\"\",\n    )\n    keys = \"test\" + EX\n    wanted = \"hi New End\"\n\n\nclass PythonCode_SimpleExample(_VimTest):\n    snippets = (\"test\", \"\"\"hi `!p snip.rv = \"Hallo\"` End\"\"\")\n    keys = \"test\" + EX\n    wanted = \"hi Hallo End\"\n\n\nclass PythonCode_SimpleExample_ReturnValueIsEmptyString(_VimTest):\n    snippets = (\"test\", \"\"\"hi`!p snip.rv = \"\"`End\"\"\")\n    keys = \"test\" + EX\n    wanted = \"hiEnd\"\n\n\nclass PythonCode_ReferencePlaceholder(_VimTest):\n    snippets = (\"test\", \"\"\"${1:hi} `!p snip.rv = t[1]+\".blah\"` End\"\"\")\n    keys = \"test\" + EX + \"ho\"\n    wanted = \"ho ho.blah End\"\n\n\nclass PythonCode_ReferencePlaceholderBefore(_VimTest):\n    snippets = (\"test\", \"\"\"`!p snip.rv = len(t[1])*\"#\"`\\n${1:some text}\"\"\")\n    keys = \"test\" + EX + \"Hallo Welt\"\n    wanted = \"##########\\nHallo Welt\"\n\n\nclass PythonCode_TransformedBeforeMultiLine(_VimTest):\n    snippets = (\n        \"test\",\n        \"\"\"${1/.+/egal/m} ${1:`!p\nsnip.rv = \"Hallo\"`} End\"\"\",\n    )\n    keys = \"test\" + EX\n    wanted = \"egal Hallo End\"\n\n\nclass PythonCode_MultilineIndented(_VimTest):\n    snippets = (\n        \"test\",\n        \"\"\"start `!p a = 1\nb = 2\nif b > a:\n    snip.rv = \"b isbigger a\"\nelse:\n    snip.rv = \"a isbigger b\"` end\"\"\",\n    )\n    keys = \"    test\" + EX\n    wanted = \"    start b isbigger a end\"\n\n\nclass PythonCode_SimpleAppend(_VimTest):\n    snippets = (\n        \"test\",\n        \"\"\"hi `!p snip.rv = \"Hallo1\"\nsnip += \"Hallo2\"` End\"\"\",\n    )\n    keys = \"test\" + EX\n    wanted = \"hi Hallo1\\nHallo2 End\"\n\n\nclass PythonCode_MultiAppend(_VimTest):\n    snippets = (\n        \"test\",\n        \"\"\"hi `!p snip.rv = \"Hallo1\"\nsnip += \"Hallo2\"\nsnip += \"Hallo3\"` End\"\"\",\n    )\n    keys = \"test\" + EX\n    wanted = \"hi Hallo1\\nHallo2\\nHallo3 End\"\n\n\nclass PythonCode_MultiAppendSimpleIndent(_VimTest):\n    snippets = (\n        \"test\",\n        \"\"\"hi\n`!p snip.rv=\"Hallo1\"\nsnip += \"Hallo2\"\nsnip += \"Hallo3\"`\nEnd\"\"\",\n    )\n    keys = (\n        \"\"\"\n    test\"\"\"\n        + EX\n    )\n    wanted = \"\"\"\n    hi\n    Hallo1\n    Hallo2\n    Hallo3\n    End\"\"\"\n\n\nclass PythonCode_SimpleMkline(_VimTest):\n    snippets = (\n        \"test\",\n        r\"\"\"hi\n`!p snip.rv=\"Hallo1\\n\"\nsnip.rv += snip.mkline(\"Hallo2\") + \"\\n\"\nsnip.rv += snip.mkline(\"Hallo3\")`\nEnd\"\"\",\n    )\n    keys = (\n        \"\"\"\n    test\"\"\"\n        + EX\n    )\n    wanted = \"\"\"\n    hi\n    Hallo1\n    Hallo2\n    Hallo3\n    End\"\"\"\n\n\nclass PythonCode_MultiAppendShift(_VimTest):\n    snippets = (\n        \"test\",\n        r\"\"\"hi\n`!p snip.rv=\"i1\"\nsnip += \"i1\"\nsnip >> 1\nsnip += \"i2\"\nsnip << 2\nsnip += \"i0\"\nsnip >> 3\nsnip += \"i3\"`\nEnd\"\"\",\n    )\n    keys = (\n        \"\"\"\n\ttest\"\"\"\n        + EX\n    )\n    wanted = \"\"\"\n\thi\n\ti1\n\ti1\n\t\ti2\ni0\n\t\t\ti3\n\tEnd\"\"\"\n\n\nclass PythonCode_MultiAppendShiftMethods(_VimTest):\n    snippets = (\n        \"test\",\n        r\"\"\"hi\n`!p snip.rv=\"i1\\n\"\nsnip.rv += snip.mkline(\"i1\\n\")\nsnip.shift(1)\nsnip.rv += snip.mkline(\"i2\\n\")\nsnip.unshift(2)\nsnip.rv += snip.mkline(\"i0\\n\")\nsnip.shift(3)\nsnip.rv += snip.mkline(\"i3\")`\nEnd\"\"\",\n    )\n    keys = (\n        \"\"\"\n\ttest\"\"\"\n        + EX\n    )\n    wanted = \"\"\"\n\thi\n\ti1\n\ti1\n\t\ti2\ni0\n\t\t\ti3\n\tEnd\"\"\"\n\n\nclass PythonCode_ResetIndent(_VimTest):\n    snippets = (\n        \"test\",\n        r\"\"\"hi\n`!p snip.rv=\"i1\"\nsnip >> 1\nsnip += \"i2\"\nsnip.reset_indent()\nsnip += \"i1\"\nsnip << 1\nsnip += \"i0\"\nsnip.reset_indent()\nsnip += \"i1\"`\nEnd\"\"\",\n    )\n    keys = (\n        \"\"\"\n\ttest\"\"\"\n        + EX\n    )\n    wanted = \"\"\"\n\thi\n\ti1\n\t\ti2\n\ti1\ni0\n\ti1\n\tEnd\"\"\"\n\n\nclass PythonCode_IndentEtSw(_VimTest):\n    def _extra_vim_config(self, vim_config):\n        vim_config.append(\"set sw=3\")\n        vim_config.append(\"set expandtab\")\n\n    snippets = (\n        \"test\",\n        r\"\"\"hi\n`!p snip.rv = \"i1\"\nsnip >> 1\nsnip += \"i2\"\nsnip << 2\nsnip += \"i0\"\nsnip >> 1\nsnip += \"i1\"\n`\nEnd\"\"\",\n    )\n    keys = \"\"\"   test\"\"\" + EX\n    wanted = \"\"\"   hi\n   i1\n      i2\ni0\n   i1\n   End\"\"\"\n\n\nclass PythonCode_IndentEtSwOffset(_VimTest):\n    def _extra_vim_config(self, vim_config):\n        vim_config.append(\"set sw=3\")\n        vim_config.append(\"set expandtab\")\n\n    snippets = (\n        \"test\",\n        r\"\"\"hi\n`!p snip.rv = \"i1\"\nsnip >> 1\nsnip += \"i2\"\nsnip << 2\nsnip += \"i0\"\nsnip >> 1\nsnip += \"i1\"\n`\nEnd\"\"\",\n    )\n    keys = \"\"\"    test\"\"\" + EX\n    wanted = \"\"\"    hi\n    i1\n       i2\n i0\n    i1\n    End\"\"\"\n\n\nclass PythonCode_IndentNoetSwTs(_VimTest):\n    def _extra_vim_config(self, vim_config):\n        vim_config.append(\"set sw=3\")\n        vim_config.append(\"set ts=4\")\n\n    snippets = (\n        \"test\",\n        r\"\"\"hi\n`!p snip.rv = \"i1\"\nsnip >> 1\nsnip += \"i2\"\nsnip << 2\nsnip += \"i0\"\nsnip >> 1\nsnip += \"i1\"\n`\nEnd\"\"\",\n    )\n    keys = \"\"\"   test\"\"\" + EX\n    wanted = \"\"\"   hi\n   i1\n\\t  i2\ni0\n   i1\n   End\"\"\"\n\n\n# Test using 'opt'\n\n\nclass PythonCode_OptExists(_VimTest):\n    def _extra_vim_config(self, vim_config):\n        vim_config.append('let g:UStest=\"yes\"')\n\n    snippets = (\"test\", r\"\"\"hi `!p snip.rv = snip.opt(\"g:UStest\") or \"no\"` End\"\"\")\n    keys = \"\"\"test\"\"\" + EX\n    wanted = \"\"\"hi yes End\"\"\"\n\n\nclass PythonCode_OptNoExists(_VimTest):\n    snippets = (\"test\", r\"\"\"hi `!p snip.rv = snip.opt(\"g:UStest\") or \"no\"` End\"\"\")\n    keys = \"\"\"test\"\"\" + EX\n    wanted = \"\"\"hi no End\"\"\"\n\n\nclass PythonCode_IndentProblem(_VimTest):\n    # A test case which is likely related to bug 719649\n    snippets = (\n        \"test\",\n        r\"\"\"hi `!p\nsnip.rv = \"World\"\n` End\"\"\",\n    )\n    keys = \" \" * 8 + \"test\" + EX  # < 8 works.\n    wanted = \"\"\"        hi World End\"\"\"\n\n\nclass PythonCode_TrickyReferences(_VimTest):\n    snippets = (\"test\", r\"\"\"${2:${1/.+/egal/}} ${1:$3} ${3:`!p snip.rv = \"hi\"`}\"\"\")\n    keys = \"ups test\" + EX\n    wanted = \"ups egal hi hi\"\n\n\n# locals\n\n\nclass PythonCode_Locals(_VimTest):\n    snippets = (\n        \"test\",\n        r\"\"\"hi `!p a = \"test\"\nsnip.rv = \"nothing\"` `!p snip.rv = a\n` End\"\"\",\n    )\n    keys = \"\"\"test\"\"\" + EX\n    wanted = \"\"\"hi nothing test End\"\"\"\n\n\nclass PythonCode_LongerTextThanSource_Chars(_VimTest):\n    snippets = (\"test\", r\"\"\"hi`!p snip.rv = \"a\" * 100`end\"\"\")\n    keys = \"\"\"test\"\"\" + EX + \"ups\"\n    wanted = \"hi\" + 100 * \"a\" + \"endups\"\n\n\nclass PythonCode_LongerTextThanSource_MultiLine(_VimTest):\n    snippets = (\"test\", r\"\"\"hi`!p snip.rv = \"a\" * 100 + '\\n'*100 + \"a\"*100`end\"\"\")\n    keys = \"\"\"test\"\"\" + EX + \"ups\"\n    wanted = \"hi\" + 100 * \"a\" + 100 * \"\\n\" + 100 * \"a\" + \"endups\"\n\n\nclass PythonCode_AccessKilledTabstop_OverwriteSecond(_VimTest):\n    snippets = (\n        \"test\",\n        r\"`!p snip.rv = t[2].upper()`${1:h${2:welt}o}`!p snip.rv = t[2].upper()`\",\n    )\n    keys = \"test\" + EX + JF + \"okay\"\n    wanted = \"OKAYhokayoOKAY\"\n\n\nclass PythonCode_AccessKilledTabstop_OverwriteFirst(_VimTest):\n    snippets = (\n        \"test\",\n        r\"`!p snip.rv = t[2].upper()`${1:h${2:welt}o}`!p snip.rv = t[2].upper()`\",\n    )\n    keys = \"test\" + EX + \"aaa\"\n    wanted = \"aaa\"\n\n\nclass PythonCode_CanOverwriteTabstop(_VimTest):\n    snippets = (\n        \"test\",\n        \"\"\"$1`!p if len(t[1]) > 3 and len(t[2]) == 0:\n            t[2] = t[1][2:];\n            t[1] = t[1][:2] + '-\\\\n\\\\t';\n            vim.command('call feedkeys(\"\\\\\\\\<End>\", \"n\")');\n            `$2\"\"\",\n    )\n    keys = \"test\" + EX + \"blah\" + \", bah\"\n    wanted = \"bl-\\n\\tah, bah\"\n\n\nclass PythonVisual_NoVisualSelection_Ignore(_VimTest):\n    snippets = (\"test\", \"h`!p snip.rv = snip.v.mode + snip.v.text`b\")\n    keys = \"test\" + EX + \"abc\"\n    wanted = \"hbabc\"\n\n\nclass PythonVisual_SelectOneWord(_VimTest):\n    snippets = (\"test\", \"h`!p snip.rv = snip.v.mode + snip.v.text`b\")\n    keys = \"blablub\" + ESC + \"0v6l\" + EX + \"test\" + EX\n    wanted = \"hvblablubb\"\n\n\nclass PythonVisual_LineSelect_Simple(_VimTest):\n    snippets = (\"test\", \"h`!p snip.rv = snip.v.mode + snip.v.text`b\")\n    keys = \"hello\\nnice\\nworld\" + ESC + \"Vkk\" + EX + \"test\" + EX\n    wanted = \"hVhello\\nnice\\nworld\\nb\"\n\n\nclass PythonVisual_HasAccessToSelectedPlaceholders(_VimTest):\n    snippets = (\n        \"test\",\n        \"\"\"${1:first} ${2:second} (`!p\nsnip.rv = \"placeholder: \" + snip.p.current_text`)\"\"\",\n    )\n    keys = \"test\" + EX + ESC + \"otest\" + EX + JF + ESC\n    wanted = \"\"\"first second (placeholder: first)\nfirst second (placeholder: second)\"\"\"\n\n\nclass PythonVisual_HasAccessToZeroPlaceholders(_VimTest):\n    snippets = (\n        \"test\",\n        \"\"\"${1:first} ${2:second} (`!p\nsnip.rv = \"placeholder: \" + snip.p.current_text`)\"\"\",\n    )\n    keys = \"test\" + EX + ESC + \"otest\" + EX + JF + JF + JF + JF\n    wanted = \"\"\"first second (placeholder: first second (placeholder: ))\nfirst second (placeholder: )\"\"\"\n\n\nclass Python_SnipRvCanBeNonText(_VimTest):\n    # Test for https://github.com/SirVer/ultisnips/issues/1132\n    snippets = (\"test\", \"`!p snip.rv = 5`\")\n    keys = \"test\" + EX\n    wanted = \"5\"\n"
  },
  {
    "path": "test/test_ListSnippets.py",
    "content": "from test.vim_test_case import VimTestCase as _VimTest\nfrom test.constant import *\n\n\nclass _ListAllSnippets(_VimTest):\n    snippets = (\n        (\"testblah\", \"BLAAH\", \"Say BLAH\"),\n        (\"test\", \"TEST ONE\", \"Say tst one\"),\n        (\"aloha\", \"OHEEEE\", \"Say OHEE\"),\n    )\n\n\nclass ListAllAvailable_NothingTyped_ExpectCorrectResult(_ListAllSnippets):\n    keys = \"\" + LS + \"3\\n\"\n    wanted = \"BLAAH\"\n\n\nclass ListAllAvailable_SpaceInFront_ExpectCorrectResult(_ListAllSnippets):\n    keys = \" \" + LS + \"3\\n\"\n    wanted = \" BLAAH\"\n\n\nclass ListAllAvailable_BraceInFront_ExpectCorrectResult(_ListAllSnippets):\n    keys = \"} \" + LS + \"3\\n\"\n    wanted = \"} BLAAH\"\n\n\nclass ListAllAvailable_testtyped_ExpectCorrectResult(_ListAllSnippets):\n    keys = \"hallo test\" + LS + \"2\\n\"\n    wanted = \"hallo BLAAH\"\n\n\nclass ListAllAvailable_testtypedSecondOpt_ExpectCorrectResult(_ListAllSnippets):\n    keys = \"hallo test\" + LS + \"1\\n\"\n    wanted = \"hallo TEST ONE\"\n\n\nclass ListAllAvailable_NonDefined_NoExpectionShouldBeRaised(_ListAllSnippets):\n    keys = \"hallo qualle\" + LS + \"Hi\"\n    wanted = \"hallo qualleHi\"\n\n\nclass ListAllAvailable_Disabled_ExpectCorrectResult(_ListAllSnippets):\n    keys = \"hallo test\" + LS + \"2\\n\"\n    wanted = \"hallo test\" + LS + \"2\\n\"\n\n    def _extra_vim_config(self, vim_config):\n        vim_config.append('let g:UltiSnipsListSnippets=\"\"')\n"
  },
  {
    "path": "test/test_Mirror.py",
    "content": "from test.vim_test_case import VimTestCase as _VimTest\nfrom test.constant import *\n\n\nclass TextTabStopTextAfterTab_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"$1 Hinten\\n$1\")\n    keys = \"test\" + EX + \"hallo\"\n    wanted = \"hallo Hinten\\nhallo\"\n\n\nclass TextTabStopTextBeforeTab_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"Vorne $1\\n$1\")\n    keys = \"test\" + EX + \"hallo\"\n    wanted = \"Vorne hallo\\nhallo\"\n\n\nclass TextTabStopTextSurroundedTab_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"Vorne $1 Hinten\\n$1\")\n    keys = \"test\" + EX + \"hallo test\"\n    wanted = \"Vorne hallo test Hinten\\nhallo test\"\n\n\nclass TextTabStopTextBeforeMirror_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"$1\\nVorne $1\")\n    keys = \"test\" + EX + \"hallo\"\n    wanted = \"hallo\\nVorne hallo\"\n\n\nclass TextTabStopAfterMirror_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"$1\\n$1 Hinten\")\n    keys = \"test\" + EX + \"hallo\"\n    wanted = \"hallo\\nhallo Hinten\"\n\n\nclass TextTabStopSurroundMirror_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"$1\\nVorne $1 Hinten\")\n    keys = \"test\" + EX + \"hallo welt\"\n    wanted = \"hallo welt\\nVorne hallo welt Hinten\"\n\n\nclass TextTabStopAllSurrounded_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"ObenVorne $1 ObenHinten\\nVorne $1 Hinten\")\n    keys = \"test\" + EX + \"hallo welt\"\n    wanted = \"ObenVorne hallo welt ObenHinten\\nVorne hallo welt Hinten\"\n\n\nclass MirrorBeforeTabstopLeave_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"$1 ${1:this is it} $1\")\n    keys = \"test\" + EX\n    wanted = \"this is it this is it this is it\"\n\n\nclass MirrorBeforeTabstopOverwrite_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"$1 ${1:this is it} $1\")\n    keys = \"test\" + EX + \"a\"\n    wanted = \"a a a\"\n\n\nclass TextTabStopSimpleMirrorMultiline_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"$1\\n$1\")\n    keys = \"test\" + EX + \"hallo\"\n    wanted = \"hallo\\nhallo\"\n\n\nclass SimpleMirrorMultilineMany_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"    $1\\n$1\\na$1b\\n$1\\ntest $1 mich\")\n    keys = \"test\" + EX + \"hallo\"\n    wanted = \"    hallo\\nhallo\\nahallob\\nhallo\\ntest hallo mich\"\n\n\nclass MultilineTabStopSimpleMirrorMultiline_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"$1\\n\\n$1\\n\\n$1\")\n    keys = \"test\" + EX + \"hallo Du\\nHi\"\n    wanted = \"hallo Du\\nHi\\n\\nhallo Du\\nHi\\n\\nhallo Du\\nHi\"\n\n\nclass MultilineTabStopSimpleMirrorMultiline1_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"$1\\n$1\\n$1\")\n    keys = \"test\" + EX + \"hallo Du\\nHi\"\n    wanted = \"hallo Du\\nHi\\nhallo Du\\nHi\\nhallo Du\\nHi\"\n\n\nclass MultilineTabStopSimpleMirrorDeleteInLine_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"$1\\n$1\\n$1\")\n    keys = \"test\" + EX + \"hallo Du\\nHi\\b\\bAch Blah\"\n    wanted = \"hallo Du\\nAch Blah\\nhallo Du\\nAch Blah\\nhallo Du\\nAch Blah\"\n\n\nclass TextTabStopSimpleMirrorMultilineMirrorInFront_ECR(_VimTest):\n    snippets = (\"test\", \"$1\\n${1:sometext}\")\n    keys = \"test\" + EX + \"hallo\\nagain\"\n    wanted = \"hallo\\nagain\\nhallo\\nagain\"\n\n\nclass SimpleMirrorDelete_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"$1\\n$1\")\n    keys = \"test\" + EX + \"hallo\\b\\b\"\n    wanted = \"hal\\nhal\"\n\n\nclass SimpleMirrorSameLine_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"$1 $1\")\n    keys = \"test\" + EX + \"hallo\"\n    wanted = \"hallo hallo\"\n\n\nclass SimpleMirrorSameLineNoSpace_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"$1$1\")\n    keys = \"test\" + EX + \"hallo\"\n    wanted = \"hallohallo\"\n\n\nclass SimpleMirrorSameLineNoSpaceInsideOther_ExpectCorrectResult(_VimTest):\n    snippets = ((\"test\", \"$1$1\"), (\"outer\", \"$1\"))\n    keys = \"outer\" + EX + \"test\" + EX + \"hallo\"\n    wanted = \"hallohallo\"\n\n\nclass SimpleMirrorSameLineNoSpaceSpaceAfter_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"$1$1 \")\n    keys = \"test\" + EX + \"hallo\"\n    wanted = \"hallohallo \"\n\n\nclass SimpleMirrorSameLineNoSpaceInsideOtherSpaceAfter_ExpectCorrectResult(_VimTest):\n    snippets = ((\"test\", \"$1$1 \"), (\"outer\", \"$1\"))\n    keys = \"outer\" + EX + \"test\" + EX + \"hallo\"\n    wanted = \"hallohallo \"\n\n\nclass SimpleMirrorSameLine_InText_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"$1 $1\")\n    keys = \"ups test blah\" + ESC + \"02f i\" + EX + \"hallo\"\n    wanted = \"ups hallo hallo blah\"\n\n\nclass SimpleMirrorSameLineBeforeTabDefVal_ECR(_VimTest):\n    snippets = (\"test\", \"$1 ${1:replace me}\")\n    keys = \"test\" + EX + \"hallo foo\"\n    wanted = \"hallo foo hallo foo\"\n\n\nclass SimpleMirrorSameLineBeforeTabDefVal_DelB4Typing_ECR(_VimTest):\n    snippets = (\"test\", \"$1 ${1:replace me}\")\n    keys = \"test\" + EX + BS + \"hallo foo\"\n    wanted = \"hallo foo hallo foo\"\n\n\nclass SimpleMirrorSameLineMany_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"$1 $1 $1 $1\")\n    keys = \"test\" + EX + \"hallo du\"\n    wanted = \"hallo du hallo du hallo du hallo du\"\n\n\nclass SimpleMirrorSameLineManyMultiline_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"$1 $1 $1 $1\")\n    keys = \"test\" + EX + \"hallo du\\nwie gehts\"\n    wanted = (\n        \"hallo du\\nwie gehts hallo du\\nwie gehts hallo du\\nwie gehts\"\n        \" hallo du\\nwie gehts\"\n    )\n\n\nclass SimpleMirrorDeleteSomeEnterSome_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"$1\\n$1\")\n    keys = \"test\" + EX + \"hallo\\b\\bhups\"\n    wanted = \"halhups\\nhalhups\"\n\n\nclass SimpleTabstopWithDefaultSimpelType_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"ha ${1:defa}\\n$1\")\n    keys = \"test\" + EX + \"world\"\n    wanted = \"ha world\\nworld\"\n\n\nclass SimpleTabstopWithDefaultComplexType_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"ha ${1:default value} $1\\nanother: $1 mirror\")\n    keys = \"test\" + EX + \"world\"\n    wanted = \"ha world world\\nanother: world mirror\"\n\n\nclass SimpleTabstopWithDefaultSimpelKeep_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"ha ${1:defa}\\n$1\")\n    keys = \"test\" + EX\n    wanted = \"ha defa\\ndefa\"\n\n\nclass SimpleTabstopWithDefaultComplexKeep_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"ha ${1:default value} $1\\nanother: $1 mirror\")\n    keys = \"test\" + EX\n    wanted = \"ha default value default value\\nanother: default value mirror\"\n\n\nclass TabstopWithMirrorManyFromAll_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"ha $5 ${1:blub} $4 $0 ${2:$1.h} $1 $3 ${4:More}\")\n    keys = (\n        \"test\"\n        + EX\n        + \"hi\"\n        + JF\n        + \"hu\"\n        + JF\n        + \"hub\"\n        + JF\n        + \"hulla\"\n        + JF\n        + \"blah\"\n        + JF\n        + \"end\"\n    )\n    wanted = \"ha blah hi hulla end hu hi hub hulla\"\n\n\nclass TabstopWithMirrorInDefaultNoType_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"ha ${1:blub} ${2:$1.h}\")\n    keys = \"test\" + EX\n    wanted = \"ha blub blub.h\"\n\n\nclass TabstopWithMirrorInDefaultNoType1_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"ha ${1:blub} ${2:$1}\")\n    keys = \"test\" + EX\n    wanted = \"ha blub blub\"\n\n\nclass TabstopWithMirrorInDefaultTwiceAndExtra_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"ha $1 ${2:$1.h $1.c}\\ntest $1\")\n    keys = \"test\" + EX + \"stdin\"\n    wanted = \"ha stdin stdin.h stdin.c\\ntest stdin\"\n\n\nclass TabstopWithMirrorInDefaultMultipleLeave_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"ha $1 ${2:snip} ${3:$1.h $2}\")\n    keys = \"test\" + EX + \"stdin\"\n    wanted = \"ha stdin snip stdin.h snip\"\n\n\nclass TabstopWithMirrorInDefaultMultipleOverwrite_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"ha $1 ${2:snip} ${3:$1.h $2}\")\n    keys = \"test\" + EX + \"stdin\" + JF + \"do snap\"\n    wanted = \"ha stdin do snap stdin.h do snap\"\n\n\nclass TabstopWithMirrorInDefaultOverwrite_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"ha $1 ${2:$1.h}\")\n    keys = \"test\" + EX + \"stdin\" + JF + \"overwritten\"\n    wanted = \"ha stdin overwritten\"\n\n\nclass TabstopWithMirrorInDefaultOverwrite1_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"ha $1 ${2:$1}\")\n    keys = \"test\" + EX + \"stdin\" + JF + \"overwritten\"\n    wanted = \"ha stdin overwritten\"\n\n\nclass TabstopWithMirrorInDefaultNoOverwrite1_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"ha $1 ${2:$1}\")\n    keys = \"test\" + EX + \"stdin\" + JF + JF + \"end\"\n    wanted = \"ha stdin stdinend\"\n\n\nclass MirrorRealLifeExample_ExpectCorrectResult(_VimTest):\n    snippets = (\n        (\n            \"for\",\n            \"for(size_t ${2:i} = 0; $2 < ${1:count}; ${3:++$2})\"\n            \"\\n{\\n\\t${0:/* code */}\\n}\",\n        ),\n    )\n    keys = (\n        \"for\"\n        + EX\n        + \"100\"\n        + JF\n        + \"avar\\b\\b\\b\\ba_variable\"\n        + JF\n        + \"a_variable *= 2\"\n        + JF\n        + \"// do nothing\"\n    )\n    wanted = \"\"\"for(size_t a_variable = 0; a_variable < 100; a_variable *= 2)\n{\n\\t// do nothing\n}\"\"\"\n\n\nclass Mirror_TestKill_InsertBefore_NoKill(_VimTest):\n    snippets = \"test\", \"$1 $1_\"\n    keys = \"hallo test\" + EX + \"auch\" + ESC + \"wihi\" + ESC + \"bb\" + \"ino\" + JF + \"end\"\n    wanted = \"hallo noauch hinoauch_end\"\n\n\nclass Mirror_TestKill_InsertAfter_NoKill(_VimTest):\n    snippets = \"test\", \"$1 $1_\"\n    keys = \"hallo test\" + EX + \"auch\" + ESC + \"eiab\" + ESC + \"bb\" + \"ino\" + JF + \"end\"\n    wanted = \"hallo noauch noauchab_end\"\n\n\nclass Mirror_TestKill_InsertBeginning_Kill(_VimTest):\n    snippets = \"test\", \"$1 $1_\"\n    keys = \"hallo test\" + EX + \"auch\" + ESC + \"wahi\" + ESC + \"bb\" + \"ino\" + JF + \"end\"\n    wanted = \"hallo noauch ahiuch_end\"\n\n\nclass Mirror_TestKill_InsertEnd_Kill(_VimTest):\n    snippets = \"test\", \"$1 $1_\"\n    keys = \"hallo test\" + EX + \"auch\" + ESC + \"ehihi\" + ESC + \"bb\" + \"ino\" + JF + \"end\"\n    wanted = \"hallo noauch auchih_end\"\n\n\nclass Mirror_TestKillTabstop_Kill(_VimTest):\n    snippets = \"test\", \"welt${1:welt${2:welt}welt} $2\"\n    keys = \"hallo test\" + EX + \"elt\"\n    wanted = \"hallo weltelt \"\n"
  },
  {
    "path": "test/test_Movement.py",
    "content": "from test.vim_test_case import VimTestCase as _VimTest\nfrom test.constant import *\n\n\nclass CursorMovement_Multiline_ECR(_VimTest):\n    snippets = (\"test\", r\"$1 ${1:a tab}\")\n    keys = \"test\" + EX + \"this is something\\nvery nice\\nnot\" + JF + \"more text\"\n    wanted = (\n        \"this is something\\nvery nice\\nnot \"\n        \"this is something\\nvery nice\\nnotmore text\"\n    )\n\n\nclass CursorMovement_BS_InEditMode(_VimTest):\n    def _extra_vim_config(self, vim_config):\n        vim_config.append(\"set backspace=eol,indent,start\")\n\n    snippets = (\"<trh\", \"<tr>\\n\\t<th>$1</th>\\n\\t$2\\n</tr>\\n$3\")\n    keys = \"<trh\" + EX + \"blah\" + JF + BS + BS + JF + \"end\"\n    wanted = \"<tr>\\n\\t<th>blah</th>\\n</tr>\\nend\"\n\n\nclass IMMoving_CursorsKeys_ECR(_VimTest):\n    snippets = (\"test\", \"${1:Some}\")\n    keys = \"test\" + EX + \"text\" + 3 * ARR_U + 6 * ARR_D\n    wanted = \"text\"\n\n\nclass IMMoving_AcceptInputWhenMoved_ECR(_VimTest):\n    snippets = (\"test\", r\"$1 ${1:a tab}\")\n    keys = \"test\" + EX + \"this\" + 2 * ARR_L + \"hallo\\nwelt\"\n    wanted = \"thhallo\\nweltis thhallo\\nweltis\"\n\n\nclass IMMoving_NoExiting_ECR(_VimTest):\n    snippets = (\"test\", r\"$1 ${2:a tab} ${1:Tab}\")\n    keys = \"hello test this\" + ESC + \"02f i\" + EX + \"tab\" + 7 * ARR_L + JF + \"hallo\"\n    wanted = \"hello tab hallo tab this\"\n\n\nclass IMMoving_NoExitingEventAtEnd_ECR(_VimTest):\n    snippets = (\"test\", r\"$1 ${2:a tab} ${1:Tab}\")\n    keys = \"hello test this\" + ESC + \"02f i\" + EX + \"tab\" + JF + \"hallo\"\n    wanted = \"hello tab hallo tab this\"\n\n\nclass IMMoving_ExitWhenOutsideRight_ECR(_VimTest):\n    snippets = (\"test\", r\"$1 ${2:blub} ${1:Tab}\")\n    keys = \"hello test this\" + ESC + \"02f i\" + EX + \"tab\" + ARR_R + JF + \"hallo\"\n    wanted = \"hello tab blub tab \" + JF + \"hallothis\"\n\n\nclass IMMoving_NotExitingWhenBarelyOutsideLeft_ECR(_VimTest):\n    snippets = (\"test\", r\"${1:Hi} ${2:blub}\")\n    keys = \"hello test this\" + ESC + \"02f i\" + EX + \"tab\" + 3 * ARR_L + JF + \"hallo\"\n    wanted = \"hello tab hallo this\"\n\n\nclass IMMoving_ExitWhenOutsideLeft_ECR(_VimTest):\n    snippets = (\"test\", r\"${1:Hi} ${2:blub}\")\n    keys = \"hello test this\" + ESC + \"02f i\" + EX + \"tab\" + 4 * ARR_L + JF + \"hallo\"\n    wanted = \"hello\" + JF + \"hallo tab blub this\"\n\n\nclass IMMoving_ExitWhenOutsideAbove_ECR(_VimTest):\n    snippets = (\"test\", \"${1:Hi}\\n${2:blub}\")\n    keys = (\n        \"hello test this\" + ESC + \"02f i\" + EX + \"tab\" + 1 * ARR_U + \"\\n\" + JF + \"hallo\"\n    )\n    wanted = JF + \"hallo\\nhello tab\\nblub this\"\n\n\nclass IMMoving_ExitWhenOutsideBelow_ECR(_VimTest):\n    snippets = (\"test\", \"${1:Hi}\\n${2:blub}\")\n    keys = (\n        \"hello test this\" + ESC + \"02f i\" + EX + \"tab\" + 2 * ARR_D + JF + \"testhallo\\n\"\n    )\n    wanted = \"hello tab\\nblub this\\n\" + JF + \"testhallo\"\n"
  },
  {
    "path": "test/test_MultipleMatches.py",
    "content": "from test.vim_test_case import VimTestCase as _VimTest\nfrom test.constant import *\n\n\nclass _MultipleMatches(_VimTest):\n    snippets = (\n        (\"test\", \"Case1\", \"This is Case 1\"),\n        (\"test\", \"Case2\", \"This is Case 2\"),\n    )\n\n\nclass Multiple_SimpleCaseSelectFirst_ECR(_MultipleMatches):\n    keys = \"test\" + EX + \"1\\n\"\n    wanted = \"Case1\"\n\n\nclass Multiple_SimpleCaseSelectSecond_ECR(_MultipleMatches):\n    keys = \"test\" + EX + \"2\\n\"\n    wanted = \"Case2\"\n\n\nclass Multiple_SimpleCaseSelectTooHigh_ESelectLast(_MultipleMatches):\n    keys = \"test\" + EX + \"5\\n\"\n    wanted = \"Case2\"\n\n\nclass Multiple_SimpleCaseSelectZero_EEscape(_MultipleMatches):\n    keys = \"test\" + EX + \"0\\n\" + \"hi\"\n    wanted = \"testhi\"\n\n\nclass Multiple_SimpleCaseEscapeOut_ECR(_MultipleMatches):\n    keys = \"test\" + EX + ESC + \"hi\"\n    wanted = \"testhi\"\n\n\nclass Multiple_ManySnippetsOneTrigger_ECR(_VimTest):\n    snippets = (\n        (\"test\", \"Case1\", \"This is Case 1\"),\n        (\"test\", \"Case2\", \"This is Case 2\"),\n        (\"test\", \"Case3\", \"This is Case 3\"),\n        (\"test\", \"Case4\", \"This is Case 4\"),\n        (\"test\", \"Case5\", \"This is Case 5\"),\n        (\"test\", \"Case6\", \"This is Case 6\"),\n        (\"test\", \"Case7\", \"This is Case 7\"),\n        (\"test\", \"Case8\", \"This is Case 8\"),\n        (\"test\", \"Case9\", \"This is Case 9\"),\n        (\"test\", \"Case10\", \"This is Case 10\"),\n        (\"test\", \"Case11\", \"This is Case 11\"),\n        (\"test\", \"Case12\", \"This is Case 12\"),\n        (\"test\", \"Case13\", \"This is Case 13\"),\n        (\"test\", \"Case14\", \"This is Case 14\"),\n        (\"test\", \"Case15\", \"This is Case 15\"),\n        (\"test\", \"Case16\", \"This is Case 16\"),\n        (\"test\", \"Case17\", \"This is Case 17\"),\n        (\"test\", \"Case18\", \"This is Case 18\"),\n        (\"test\", \"Case19\", \"This is Case 19\"),\n        (\"test\", \"Case20\", \"This is Case 20\"),\n        (\"test\", \"Case21\", \"This is Case 21\"),\n        (\"test\", \"Case22\", \"This is Case 22\"),\n        (\"test\", \"Case23\", \"This is Case 23\"),\n        (\"test\", \"Case24\", \"This is Case 24\"),\n        (\"test\", \"Case25\", \"This is Case 25\"),\n        (\"test\", \"Case26\", \"This is Case 26\"),\n        (\"test\", \"Case27\", \"This is Case 27\"),\n        (\"test\", \"Case28\", \"This is Case 28\"),\n        (\"test\", \"Case29\", \"This is Case 29\"),\n    )\n    keys = \"test\" + EX + \" \" + ESC + ESC + \"ahi\"\n    wanted = \"testhi\"\n"
  },
  {
    "path": "test/test_ParseSnippets.py",
    "content": "from test.vim_test_case import VimTestCase as _VimTest\nfrom test.constant import *\n\n\nclass ParseSnippets_SimpleSnippet(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        snippet testsnip \"Test Snippet\" b!\n        This is a test snippet!\n        endsnippet\n        \"\"\"\n    }\n    keys = \"testsnip\" + EX\n    wanted = \"This is a test snippet!\"\n\n\nclass ParseSnippets_MissingEndSnippet(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        snippet testsnip \"Test Snippet\" b!\n        This is a test snippet!\n        \"\"\"\n    }\n    keys = \"testsnip\" + EX\n    wanted = \"testsnip\" + EX\n    expected_error = r\"Missing 'endsnippet' for 'testsnip' in \\S+:4\"\n\n\nclass ParseSnippets_UnknownDirective(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        unknown directive\n        \"\"\"\n    }\n    keys = \"testsnip\" + EX\n    wanted = \"testsnip\" + EX\n    expected_error = r\"Invalid line 'unknown directive' in \\S+:2\"\n\n\nclass ParseSnippets_InvalidPartialSnippet(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        snip invalid\n        \"\"\"\n    }\n    keys = \"testsnip\" + EX\n    wanted = \"testsnip\" + EX\n    expected_error = r\"Invalid line 'snip invalid' in \\S+:2\"\n\n\nclass ParseSnippets_InvalidPriorityLine(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        priority - 50\n        \"\"\"\n    }\n    keys = \"testsnip\" + EX\n    wanted = \"testsnip\" + EX\n    expected_error = r\"Invalid priority '- 50' in \\S+:2\"\n\n\nclass ParseSnippets_InvalidPriorityLine1(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        priority\n        \"\"\"\n    }\n    keys = \"testsnip\" + EX\n    wanted = \"testsnip\" + EX\n    expected_error = r\"Invalid priority '' in \\S+:2\"\n\n\nclass ParseSnippets_ExtendsWithoutFiletype(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        extends\n        \"\"\"\n    }\n    keys = \"testsnip\" + EX\n    wanted = \"testsnip\" + EX\n    expected_error = r\"'extends' without file types in \\S+:2\"\n\n\nclass ParseSnippets_ClearAll(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        snippet testsnip \"Test snippet\"\n        This is a test.\n        endsnippet\n\n        clearsnippets\n        \"\"\"\n    }\n    keys = \"testsnip\" + EX\n    wanted = \"testsnip\" + EX\n\n\nclass ParseSnippets_ClearOne(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        clearsnippets toclear\n\n        snippet testsnip \"Test snippet\"\n        This is a test.\n        endsnippet\n\n        snippet toclear \"Snippet to clear\"\n        Do not expand.\n        endsnippet\n        \"\"\"\n    }\n    keys = \"toclear\" + EX + \"\\n\" + \"testsnip\" + EX\n    wanted = \"toclear\" + EX + \"\\n\" + \"This is a test.\"\n\n\nclass ParseSnippets_ClearTwo(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        clearsnippets testsnip toclear\n\n        snippet testsnip \"Test snippet\"\n        This is a test.\n        endsnippet\n\n        snippet toclear \"Snippet to clear\"\n        Do not expand.\n        endsnippet\n        \"\"\"\n    }\n    keys = \"toclear\" + EX + \"\\n\" + \"testsnip\" + EX\n    wanted = \"toclear\" + EX + \"\\n\" + \"testsnip\" + EX\n\n\nclass _ParseSnippets_MultiWord(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        snippet /test snip/\n        This is a test.\n        endsnippet\n\n        snippet !snip test! \"Another snippet\"\n        This is another test.\n        endsnippet\n\n        snippet \"snippet test\" \"Another snippet\" b\n        This is yet another test.\n        endsnippet\n        \"\"\"\n    }\n\n\nclass ParseSnippets_MultiWord_Simple(_ParseSnippets_MultiWord):\n    keys = \"test snip\" + EX\n    wanted = \"This is a test.\"\n\n\nclass ParseSnippets_MultiWord_Description(_ParseSnippets_MultiWord):\n    keys = \"snip test\" + EX\n    wanted = \"This is another test.\"\n\n\nclass ParseSnippets_MultiWord_Description_Option(_ParseSnippets_MultiWord):\n    keys = \"snippet test\" + EX\n    wanted = \"This is yet another test.\"\n\n\nclass _ParseSnippets_MultiWord_RE(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        snippet /[d-f]+/ \"\" r\n        az test\n        endsnippet\n\n        snippet !^(foo|bar)$! \"\" r\n        foo-bar test\n        endsnippet\n\n        snippet \"(test ?)+\" \"\" r\n        re-test\n        endsnippet\n        \"\"\"\n    }\n\n\nclass ParseSnippets_MultiWord_RE1(_ParseSnippets_MultiWord_RE):\n    keys = \"abc def\" + EX\n    wanted = \"abc az test\"\n\n\nclass ParseSnippets_MultiWord_RE2(_ParseSnippets_MultiWord_RE):\n    keys = \"foo\" + EX + \" bar\" + EX + \"\\nbar\" + EX\n    wanted = \"foo-bar test bar\\t\\nfoo-bar test\"\n\n\nclass ParseSnippets_MultiWord_RE3(_ParseSnippets_MultiWord_RE):\n    keys = \"test test test\" + EX\n    wanted = \"re-test\"\n\n\nclass ParseSnippets_MultiWord_Quotes(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        snippet \"test snip\"\n        This is a test.\n        endsnippet\n        \"\"\"\n    }\n    keys = \"test snip\" + EX\n    wanted = \"This is a test.\"\n\n\nclass ParseSnippets_MultiWord_WithQuotes(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        snippet !\"test snip\"!\n        This is a test.\n        endsnippet\n        \"\"\"\n    }\n    keys = '\"test snip\"' + EX\n    wanted = \"This is a test.\"\n\n\nclass ParseSnippets_MultiWord_NoContainer(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        snippet test snip\n        This is a test.\n        endsnippet\n        \"\"\"\n    }\n    keys = \"test snip\" + EX\n    wanted = keys\n    expected_error = \"Invalid multiword trigger: 'test snip' in \\\\S+:2\"\n\n\nclass ParseSnippets_MultiWord_UnmatchedContainer(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        snippet !inv snip/\n        This is a test.\n        endsnippet\n        \"\"\"\n    }\n    keys = \"inv snip\" + EX\n    wanted = keys\n    expected_error = \"Invalid multiword trigger: '!inv snip/' in \\\\S+:2\"\n\n\nclass ParseSnippets_Global_Python_After(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        snippet ab\n        x `!p snip.rv = tex(\"bob\")` y\n        endsnippet\n\n        context \"always()\"\n        snippet ac\n        x `!p snip.rv = tex(\"jon\")` y\n        endsnippet\n\n        global !p\n        def tex(ins):\n            return \"a \" + ins + \" b\"\n\n        def always():\n            return True\n        endglobal\n        \"\"\"\n    }\n    keys = \"ab\" + EX + \"\\nac\" + EX\n    wanted = \"x a bob b y\\nx a jon b y\"\n\n\nclass ParseSnippets_Global_Python(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        global !p\n        def tex(ins):\n            return \"a \" + ins + \" b\"\n        endglobal\n\n        snippet ab\n        x `!p snip.rv = tex(\"bob\")` y\n        endsnippet\n\n        snippet ac\n        x `!p snip.rv = tex(\"jon\")` y\n        endsnippet\n        \"\"\"\n    }\n    keys = \"ab\" + EX + \"\\nac\" + EX\n    wanted = \"x a bob b y\\nx a jon b y\"\n\n\nclass ParseSnippets_Global_Local_Python(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\nglobal !p\ndef tex(ins):\n    return \"a \" + ins + \" b\"\nendglobal\n\nsnippet ab\nx `!p first = tex(\"bob\")\nsnip.rv = \"first\"` `!p snip.rv = first` y\nendsnippet\n        \"\"\"\n    }\n    keys = \"ab\" + EX\n    wanted = \"x first a bob b y\"\n\n\nclass ParseSnippets_PrintPythonStacktrace(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        snippet test\n        `!p abc()`\n        endsnippet\n        \"\"\"\n    }\n    keys = \"test\" + EX\n    wanted = keys\n    expected_error = \" > abc\"\n\n\nclass ParseSnippets_PrintPythonStacktraceMultiline(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        snippet test\n        `!p if True:\n            qwe()`\n        endsnippet\n        \"\"\"\n    }\n    keys = \"test\" + EX\n    wanted = keys\n    expected_error = \" > \\\\s+qwe\"\n\n\nclass ParseSnippets_PrintErroneousSnippet(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        snippet test \"asd()\" e\n        endsnippet\n        \"\"\"\n    }\n    keys = \"test\" + EX\n    wanted = keys\n    expected_error = \"Trigger: test\"\n\n\nclass ParseSnippets_PrintErroneousSnippetContext(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        snippet test \"asd()\" e\n        endsnippet\n        \"\"\"\n    }\n    keys = \"test\" + EX\n    wanted = keys\n    expected_error = \"Context: asd\"\n\n\nclass ParseSnippets_PrintErroneousSnippetPreAction(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        pre_expand \"asd()\"\n        snippet test\n        endsnippet\n        \"\"\"\n    }\n    keys = \"test\" + EX\n    wanted = keys\n    expected_error = \"Pre-expand: asd\"\n\n\nclass ParseSnippets_PrintErroneousSnippetPostAction(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        post_expand \"asd()\"\n        snippet test\n        endsnippet\n        \"\"\"\n    }\n    keys = \"test\" + EX\n    wanted = keys\n    expected_error = \"Post-expand: asd\"\n\n\nclass ParseSnippets_PrintErroneousSnippetLocation(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        post_expand \"asd()\"\n        snippet test\n        endsnippet\n        \"\"\"\n    }\n    keys = \"test\" + EX\n    wanted = keys\n    expected_error = \"Defined in: .*/all.snippets\"\n"
  },
  {
    "path": "test/test_Plugin.py",
    "content": "import sys\n\nfrom test.vim_test_case import VimTestCase as _VimTest\nfrom test.constant import *\n\n\nclass Plugin_SuperTab_SimpleTest(_VimTest):\n    plugins = [\"ervandew/supertab\"]\n    snippets = (\"long\", \"Hello\", \"\", \"w\")\n    keys = (\n        \"longtextlongtext\\n\" + \"longt\" + EX + \"\\n\" + \"long\" + EX  # Should complete word\n    )  # Should expand\n    wanted = \"longtextlongtext\\nlongtextlongtext\\nHello\"\n\n    def _before_test(self):\n        # Make sure that UltiSnips has the keymap\n        self.vim.send_to_vim(\":call UltiSnips#map_keys#MapKeys()\\n\")\n\n    def _extra_vim_config(self, vim_config):\n        assert EX == \"\\t\"  # Otherwise this test needs changing.\n        vim_config.append('let g:SuperTabDefaultCompletionType = \"<c-p>\"')\n        vim_config.append('let g:SuperTabRetainCompletionDuration = \"insert\"')\n        vim_config.append(\"let g:SuperTabLongestHighlight = 1\")\n        vim_config.append(\"let g:SuperTabCrMapping = 0\")\n"
  },
  {
    "path": "test/test_Recursive.py",
    "content": "from test.vim_test_case import VimTestCase as _VimTest\nfrom test.constant import *\n\n\nclass RecTabStops_SimpleCase_ExpectCorrectResult(_VimTest):\n    snippets = (\"m\", \"[ ${1:first}  ${2:sec} ]\")\n    keys = \"m\" + EX + \"m\" + EX + \"hello\" + JF + \"world\" + JF + \"ups\" + JF + \"end\"\n    wanted = \"[ [ hello  world ]ups  end ]\"\n\n\nclass RecTabStops_SimpleCaseLeaveSecondSecond_ExpectCorrectResult(_VimTest):\n    snippets = (\"m\", \"[ ${1:first}  ${2:sec} ]\")\n    keys = \"m\" + EX + \"m\" + EX + \"hello\" + JF + \"world\" + JF + JF + JF + \"end\"\n    wanted = \"[ [ hello  world ]  sec ]end\"\n\n\nclass RecTabStops_SimpleCaseLeaveFirstSecond_ExpectCorrectResult(_VimTest):\n    snippets = (\"m\", \"[ ${1:first}  ${2:sec} ]\")\n    keys = \"m\" + EX + \"m\" + EX + \"hello\" + JF + JF + JF + \"world\" + JF + \"end\"\n    wanted = \"[ [ hello  sec ]  world ]end\"\n\n\nclass RecTabStops_InnerWOTabStop_ECR(_VimTest):\n    snippets = ((\"m1\", \"Just some Text\"), (\"m\", \"[ ${1:first}  ${2:sec} ]\"))\n    keys = \"m\" + EX + \"m1\" + EX + \"hi\" + JF + \"two\" + JF + \"end\"\n    wanted = \"[ Just some Texthi  two ]end\"\n\n\nclass RecTabStops_InnerWOTabStopTwiceDirectly_ECR(_VimTest):\n    snippets = ((\"m1\", \"JST\"), (\"m\", \"[ ${1:first}  ${2:sec} ]\"))\n    keys = \"m\" + EX + \"m1\" + EX + \" m1\" + EX + \"hi\" + JF + \"two\" + JF + \"end\"\n    wanted = \"[ JST JSThi  two ]end\"\n\n\nclass RecTabStops_InnerWOTabStopTwice_ECR(_VimTest):\n    snippets = ((\"m1\", \"JST\"), (\"m\", \"[ ${1:first}  ${2:sec} ]\"))\n    keys = \"m\" + EX + \"m1\" + EX + JF + \"m1\" + EX + \"hi\" + JF + \"end\"\n    wanted = \"[ JST  JSThi ]end\"\n\n\nclass RecTabStops_OuterOnlyWithZeroTS_ECR(_VimTest):\n    snippets = ((\"m\", \"A $0 B\"), (\"m1\", \"C $1 D $0 E\"))\n    keys = \"m\" + EX + \"m1\" + EX + \"CD\" + JF + \"DE\"\n    wanted = \"A C CD D DE E B\"\n\n\nclass RecTabStops_OuterOnlyWithZero_ECR(_VimTest):\n    snippets = ((\"m\", \"A $0 B\"), (\"m1\", \"C $1 D $0 E\"))\n    keys = \"m\" + EX + \"m1\" + EX + \"CD\" + JF + \"DE\"\n    wanted = \"A C CD D DE E B\"\n\n\nclass RecTabStops_ExpandedInZeroTS_ECR(_VimTest):\n    snippets = ((\"m\", \"A $0 B $1\"), (\"m1\", \"C $1 D $0 E\"))\n    keys = \"m\" + EX + \"hi\" + JF + \"m1\" + EX + \"CD\" + JF + \"DE\"\n    wanted = \"A C CD D DE E B hi\"\n\n\nclass RecTabStops_ExpandedInZeroTSTwice_ECR(_VimTest):\n    snippets = ((\"m\", \"A $0 B $1\"), (\"m1\", \"C $1 D $0 E\"))\n    keys = \"m\" + EX + \"hi\" + JF + \"m\" + EX + \"again\" + JF + \"m1\" + EX + \"CD\" + JF + \"DE\"\n    wanted = \"A A C CD D DE E B again B hi\"\n\n\nclass RecTabStops_ExpandedInZeroTSSecondTime_ECR(_VimTest):\n    snippets = ((\"m\", \"A $0 B $1\"), (\"m1\", \"C $1 D $0 E\"))\n    keys = \"m\" + EX + \"hi\" + JF + \"m\" + EX + \"m1\" + EX + \"CD\" + JF + \"DE\" + JF + \"AB\"\n    wanted = \"A A AB B C CD D DE E B hi\"\n\n\nclass RecTabsStops_TypeInZero_ECR(_VimTest):\n    snippets = (\n        (\"v\", r\"\\vec{$1}\", \"Vector\", \"w\"),\n        (\"frac\", r\"\\frac{${1:one}}${0:zero}{${2:two}}\", \"Fractio\", \"w\"),\n    )\n    keys = (\n        \"v\"\n        + EX\n        + \"frac\"\n        + EX\n        + \"a\"\n        + JF\n        + \"b\"\n        + JF\n        + \"frac\"\n        + EX\n        + \"aa\"\n        + JF\n        + JF\n        + \"cc\"\n        + JF\n        + \"hello frac\"\n        + EX\n        + JF\n        + JF\n        + \"world\"\n    )\n    wanted = r\"\\vec{\\frac{a}\\frac{aa}cc{two}{b}}hello \\frac{one}world{two}\"\n\n\nclass RecTabsStops_TypeInZero2_ECR(_VimTest):\n    snippets = ((\"m\", r\"_${0:explicit zero}\", \"snip\", \"i\"),)\n    keys = \"m\" + EX + \"hello m\" + EX + \"world m\" + EX + \"end\"\n    wanted = r\"_hello _world _end\"\n\n\nclass RecTabsStops_BackspaceZero_ECR(_VimTest):\n    snippets = ((\"m\", r\"${1:one}${0:explicit zero}${2:two}\", \"snip\", \"i\"),)\n    keys = \"m\" + EX + JF + JF + BS + \"m\" + EX\n    wanted = r\"oneoneexplicit zerotwotwo\"\n\n\nclass RecTabStops_MirrorInnerSnippet_ECR(_VimTest):\n    snippets = ((\"m\", \"[ $1 $2 ] $1\"), (\"m1\", \"ASnip $1 ASnip $2 ASnip\"))\n    keys = (\n        \"m\"\n        + EX\n        + \"m1\"\n        + EX\n        + \"Hallo\"\n        + JF\n        + \"Hi\"\n        + JF\n        + \"endone\"\n        + JF\n        + \"two\"\n        + JF\n        + \"totalend\"\n    )\n    wanted = \"[ ASnip Hallo ASnip Hi ASnipendone two ] ASnip Hallo ASnip Hi ASnipendonetotalend\"\n\n\nclass RecTabStops_NotAtBeginningOfTS_ExpectCorrectResult(_VimTest):\n    snippets = (\"m\", \"[ ${1:first}  ${2:sec} ]\")\n    keys = (\n        \"m\"\n        + EX\n        + \"hello m\"\n        + EX\n        + \"hi\"\n        + JF\n        + \"two\"\n        + JF\n        + \"ups\"\n        + JF\n        + \"three\"\n        + JF\n        + \"end\"\n    )\n    wanted = \"[ hello [ hi  two ]ups  three ]end\"\n\n\nclass RecTabStops_InNewlineInTabstop_ExpectCorrectResult(_VimTest):\n    snippets = (\"m\", \"[ ${1:first}  ${2:sec} ]\")\n    keys = (\n        \"m\"\n        + EX\n        + \"hello\\nm\"\n        + EX\n        + \"hi\"\n        + JF\n        + \"two\"\n        + JF\n        + \"ups\"\n        + JF\n        + \"three\"\n        + JF\n        + \"end\"\n    )\n    wanted = \"[ hello\\n[ hi  two ]ups  three ]end\"\n\n\nclass RecTabStops_InNewlineInTabstopNotAtBeginOfLine_ECR(_VimTest):\n    snippets = (\"m\", \"[ ${1:first}  ${2:sec} ]\")\n    keys = (\n        \"m\"\n        + EX\n        + \"hello\\nhello again m\"\n        + EX\n        + \"hi\"\n        + JF\n        + \"two\"\n        + JF\n        + \"ups\"\n        + JF\n        + \"three\"\n        + JF\n        + \"end\"\n    )\n    wanted = \"[ hello\\nhello again [ hi  two ]ups  three ]end\"\n\n\nclass RecTabStops_InNewlineMultiline_ECR(_VimTest):\n    snippets = (\"m\", \"M START\\n$0\\nM END\")\n    keys = \"m\" + EX + \"m\" + EX\n    wanted = \"M START\\nM START\\n\\nM END\\nM END\"\n\n\nclass RecTabStops_InNewlineManualIndent_ECR(_VimTest):\n    snippets = (\"m\", \"M START\\n$0\\nM END\")\n    keys = \"m\" + EX + \"    m\" + EX + \"hi\"\n    wanted = \"M START\\n    M START\\n    hi\\n    M END\\nM END\"\n\n\nclass RecTabStops_InNewlineManualIndentTextInFront_ECR(_VimTest):\n    snippets = (\"m\", \"M START\\n$0\\nM END\")\n    keys = \"m\" + EX + \"    hallo m\" + EX + \"hi\"\n    wanted = \"M START\\n    hallo M START\\n    hi\\n    M END\\nM END\"\n\n\nclass RecTabStops_InNewlineMultilineWithIndent_ECR(_VimTest):\n    snippets = (\"m\", \"M START\\n    $0\\nM END\")\n    keys = \"m\" + EX + \"m\" + EX + \"hi\"\n    wanted = \"M START\\n    M START\\n        hi\\n    M END\\nM END\"\n\n\nclass RecTabStops_InNewlineMultilineWithNonZeroTS_ECR(_VimTest):\n    snippets = (\"m\", \"M START\\n    $1\\nM END -> $0\")\n    keys = \"m\" + EX + \"m\" + EX + \"hi\" + JF + \"hallo\" + JF + \"end\"\n    wanted = \"M START\\n    M START\\n        hi\\n    M END -> hallo\\n\" \"M END -> end\"\n\n\nclass RecTabStops_BarelyNotLeavingInner_ECR(_VimTest):\n    snippets = ((\"m\", \"[ ${1:first} ${2:sec} ]\"),)\n    keys = (\n        \"m\"\n        + EX\n        + \"m\"\n        + EX\n        + \"a\"\n        + 3 * ARR_L\n        + JF\n        + \"hallo\"\n        + JF\n        + \"ups\"\n        + JF\n        + \"world\"\n        + JF\n        + \"end\"\n    )\n    wanted = \"[ [ a hallo ]ups world ]end\"\n\n\nclass RecTabStops_LeavingInner_ECR(_VimTest):\n    snippets = ((\"m\", \"[ ${1:first} ${2:sec} ]\"),)\n    keys = \"m\" + EX + \"m\" + EX + \"a\" + 4 * ARR_L + JF + \"hallo\" + JF + \"world\"\n    wanted = \"[ [ a sec ] hallo ]world\"\n\n\nclass RecTabStops_LeavingInnerInner_ECR(_VimTest):\n    snippets = ((\"m\", \"[ ${1:first} ${2:sec} ]\"),)\n    keys = (\n        \"m\"\n        + EX\n        + \"m\"\n        + EX\n        + \"m\"\n        + EX\n        + \"a\"\n        + 4 * ARR_L\n        + JF\n        + \"hallo\"\n        + JF\n        + \"ups\"\n        + JF\n        + \"world\"\n        + JF\n        + \"end\"\n    )\n    wanted = \"[ [ [ a sec ] hallo ]ups world ]end\"\n\n\nclass RecTabStops_LeavingInnerInnerTwo_ECR(_VimTest):\n    snippets = ((\"m\", \"[ ${1:first} ${2:sec} ]\"),)\n    keys = \"m\" + EX + \"m\" + EX + \"m\" + EX + \"a\" + 6 * ARR_L + JF + \"hallo\" + JF + \"end\"\n    wanted = \"[ [ [ a sec ] sec ] hallo ]end\"\n\n\nclass RecTabStops_ZeroTSisNothingSpecial_ECR(_VimTest):\n    snippets = ((\"m1\", \"[ ${1:first} $0 ${2:sec} ]\"), (\"m\", \"[ ${1:first} ${2:sec} ]\"))\n    keys = (\n        \"m\"\n        + EX\n        + \"m1\"\n        + EX\n        + \"one\"\n        + JF\n        + \"two\"\n        + JF\n        + \"three\"\n        + JF\n        + \"four\"\n        + JF\n        + \"end\"\n    )\n    wanted = \"[ [ one three two ] four ]end\"\n\n\nclass RecTabStops_MirroredZeroTS_ECR(_VimTest):\n    snippets = (\n        (\"m1\", \"[ ${1:first} ${0:Year, some default text} $0 ${2:sec} ]\"),\n        (\"m\", \"[ ${1:first} ${2:sec} ]\"),\n    )\n    keys = (\n        \"m\"\n        + EX\n        + \"m1\"\n        + EX\n        + \"one\"\n        + JF\n        + \"two\"\n        + JF\n        + \"three\"\n        + JF\n        + \"four\"\n        + JF\n        + \"end\"\n    )\n    wanted = \"[ [ one three three two ] four ]end\"\n\n\nclass RecTabStops_ChildTriggerContainsParentTextObjects(_VimTest):\n    # https://bugs.launchpad.net/bugs/1191617\n    files = {\n        \"us/all.snippets\": r\"\"\"\nglobal !p\ndef complete(t, opts):\n if t:\n   opts = [ q[len(t):] for q in opts if q.startswith(t) ]\n if len(opts) == 0:\n   return ''\n return opts[0] if len(opts) == 1 else \"(\" + '|'.join(opts) + ')'\ndef autocomplete_options(t, string, attr=None):\n   return complete(t[1], [opt for opt in attr if opt not in string])\nendglobal\nsnippet /form_for(.*){([^|]*)/ \"form_for html options\" rw!\n`!p\nauto = autocomplete_options(t, match.group(2), attr=[\"id: \", \"class: \", \"title:  \"])\nsnip.rv = \"form_for\" + match.group(1) + \"{\"`$1`!p if (snip.c != auto) : snip.rv=auto`\nendsnippet\n\"\"\"\n    }\n    keys = \"form_for user, namespace: some_namespace, html: {i\" + EX + \"i\" + EX\n    wanted = (\n        \"form_for user, namespace: some_namespace, html: {(id: |class: |title:  )d: \"\n    )\n"
  },
  {
    "path": "test/test_Selection.py",
    "content": "from test.vim_test_case import VimTestCase as _VimTest\nfrom test.constant import *\n\n# Test for bug 427298 #\n\n\nclass _SelectModeMappings(_VimTest):\n    snippets = (\"test\", \"${1:World}\")\n    keys = \"test\" + EX + \"Hello\"\n    wanted = \"Hello\"\n    maps = (\"\", \"\")\n    buffer_maps = (\"\", \"\")\n    do_unmapping = True\n    ignores = []\n\n    def _extra_vim_config(self, vim_config):\n        vim_config.append(\n            \":let g:UltiSnipsRemoveSelectModeMappings=%i\" % int(self.do_unmapping)\n        )\n        vim_config.append(\":let g:UltiSnipsMappingsToIgnore=%s\" % repr(self.ignores))\n\n        if not isinstance(self.maps[0], tuple):\n            self.maps = (self.maps,)\n        if not isinstance(self.buffer_maps[0], tuple):\n            self.buffer_maps = (self.buffer_maps,)\n\n        for key, m in self.maps:\n            if not len(key):\n                continue\n            vim_config.append(\":smap %s %s\" % (key, m))\n        for key, m in self.buffer_maps:\n            if not len(key):\n                continue\n            vim_config.append(\":smap <buffer> %s %s\" % (key, m))\n\n\nclass SelectModeMappings_RemoveBeforeSelecting_ECR(_SelectModeMappings):\n    maps = (\"H\", \"x\")\n    wanted = \"Hello\"\n\n\nclass SelectModeMappings_DisableRemoveBeforeSelecting_ECR(_SelectModeMappings):\n    do_unmapping = False\n    maps = (\"H\", \"x\")\n    wanted = \"xello\"\n\n\nclass SelectModeMappings_IgnoreMappings_ECR(_SelectModeMappings):\n    ignores = [\"e\"]\n    maps = (\"H\", \"x\"), (\"e\", \"l\")\n    wanted = \"Hello\"\n\n\nclass SelectModeMappings_IgnoreMappings1_ECR(_SelectModeMappings):\n    ignores = [\"H\"]\n    maps = (\"H\", \"x\"), (\"e\", \"l\")\n    wanted = \"xello\"\n\n\nclass SelectModeMappings_IgnoreMappings2_ECR(_SelectModeMappings):\n    ignores = [\"e\", \"H\"]\n    maps = (\"e\", \"l\"), (\"H\", \"x\")\n    wanted = \"xello\"\n\n\nclass SelectModeMappings_BufferLocalMappings_ECR(_SelectModeMappings):\n    buffer_maps = (\"H\", \"blah\")\n    wanted = \"Hello\"\n\n\nclass _ES_Base(_VimTest):\n    def _extra_vim_config(self, vim_config):\n        vim_config.append(\"set selection=exclusive\")\n\n\nclass ExclusiveSelection_SimpleTabstop_Test(_ES_Base):\n    snippets = (\"test\", \"h${1:blah}w $1\")\n    keys = \"test\" + EX + \"ui\" + JF\n    wanted = \"huiw ui\"\n\n\nclass ExclusiveSelection_RealWorldCase_Test(_ES_Base):\n    snippets = (\n        \"for\",\n        \"\"\"for ($${1:i} = ${2:0}; $$1 < ${3:count}; $$1${4:++}) {\n\t${5:// code}\n}\"\"\",\n    )\n    keys = \"for\" + EX + \"k\" + JF\n    wanted = \"\"\"for ($k = 0; $k < count; $k++) {\n\t// code\n}\"\"\"\n\n\nclass _OS_Base(_VimTest):\n    def _extra_vim_config(self, vim_config):\n        vim_config.append(\"set selection=old\")\n\n\nclass OldSelection_SimpleTabstop_Test(_OS_Base):\n    snippets = (\"test\", \"h${1:blah}w $1\")\n    keys = \"test\" + EX + \"ui\" + JF\n    wanted = \"huiw ui\"\n\n\nclass OldSelection_RealWorldCase_Test(_OS_Base):\n    snippets = (\n        \"for\",\n        \"\"\"for ($${1:i} = ${2:0}; $$1 < ${3:count}; $$1${4:++}) {\n\t${5:// code}\n}\"\"\",\n    )\n    keys = \"for\" + EX + \"k\" + JF\n    wanted = \"\"\"for ($k = 0; $k < count; $k++) {\n\t// code\n}\"\"\"\n"
  },
  {
    "path": "test/test_SnipMate.py",
    "content": "# encoding: utf-8\nfrom test.vim_test_case import VimTestCase as _VimTest\nfrom test.constant import *\n\n\nclass snipMate_SimpleSnippet(_VimTest):\n    files = {\n        \"snippets/_.snippets\": \"\"\"\nsnippet hello\n\\tThis is a test snippet\n\\t# With a comment\"\"\"\n    }\n    keys = \"hello\" + EX\n    wanted = \"This is a test snippet\\n# With a comment\"\n\n\nclass snipMate_Disabled(_VimTest):\n    files = {\n        \"snippets/_.snippets\": \"\"\"\nsnippet hello\n\\tThis is a test snippet\n\\t# With a comment\"\"\"\n    }\n    keys = \"hello\" + EX\n    wanted = \"hello\" + EX\n\n    def _extra_vim_config(self, vim_config):\n        vim_config.append(\"let g:UltiSnipsEnableSnipMate=0\")\n\n\nclass snipMate_OtherFiletype(_VimTest):\n    files = {\n        \"snippets/blubi.snippets\": \"\"\"\nsnippet hello\n\\tworked\"\"\"\n    }\n    keys = \"hello\" + EX + ESC + \":set ft=blubi\\nohello\" + EX\n    wanted = \"hello\" + EX + \"\\nworked\"\n\n\nclass snipMate_MultiMatches(_VimTest):\n    files = {\n        \"snippets/_.snippets\": \"\"\"\nsnippet hello The first snippet.\"\n\\tone\nsnippet hello The second snippet.\n\\ttwo\"\"\"\n    }\n    keys = \"hello\" + EX + \"2\\n\"\n    wanted = \"two\"\n\n\nclass snipMate_SimpleSnippetSubDirectory(_VimTest):\n    files = {\n        \"snippets/_/blub.snippets\": \"\"\"\nsnippet hello\n\\tThis is a test snippet\"\"\"\n    }\n    keys = \"hello\" + EX\n    wanted = \"This is a test snippet\"\n\n\nclass snipMate_SimpleSnippetInSnippetFile(_VimTest):\n    files = {\n        \"snippets/_/hello.snippet\": \"\"\"This is a stand alone snippet\"\"\",\n        \"snippets/_/hello1.snippet\": \"\"\"This is two stand alone snippet\"\"\",\n        \"snippets/_/hello2/this_is_my_cool_snippet.snippet\": \"\"\"Three\"\"\",\n    }\n    keys = \"hello\" + EX + \"\\nhello1\" + EX + \"\\nhello2\" + EX\n    wanted = \"This is a stand alone snippet\\nThis is two stand alone snippet\\nThree\"\n\n\nclass snipMate_Interpolation(_VimTest):\n    files = {\n        \"snippets/_.snippets\": \"\"\"\nsnippet test\n\\tla`printf('c%02d', 3)`lu\"\"\"\n    }\n    keys = \"test\" + EX\n    wanted = \"lac03lu\"\n\n\nclass snipMate_InterpolationWithSystem(_VimTest):\n    files = {\n        \"snippets/_.snippets\": \"\"\"\nsnippet test\n\\tla`system('echo -ne öäü')`lu\"\"\"\n    }\n    keys = \"test\" + EX\n    wanted = \"laöäülu\"\n\n\nclass snipMate_TestMirrors(_VimTest):\n    files = {\n        \"snippets/_.snippets\": \"\"\"\nsnippet for\n\\tfor (${2:i}; $2 < ${1:count}; $1++) {\n\\t\\t${4}\n\\t}\"\"\"\n    }\n    keys = \"for\" + EX + \"blub\" + JF + \"j\" + JF + \"hi\"\n    wanted = \"for (j; j < blub; blub++) {\\n\\thi\\n}\"\n\n\nclass snipMate_TestNoBraceTabstops(_VimTest):\n    files = {\n        \"snippets/_.snippets\": \"\"\"\nsnippet test\n\\t$1 is $2\"\"\"\n    }\n    keys = \"test\" + EX + \"blub\" + JF + \"blah\"\n    wanted = \"blub is blah\"\n\n\nclass snipMate_TestNoBraceTabstopsAndMirrors(_VimTest):\n    files = {\n        \"snippets/_.snippets\": \"\"\"\nsnippet test\n\\t$1 is $1, $2 is ${2}\"\"\"\n    }\n    keys = \"test\" + EX + \"blub\" + JF + \"blah\"\n    wanted = \"blub is blub, blah is blah\"\n\n\nclass snipMate_TestMirrorsInPlaceholders(_VimTest):\n    files = {\n        \"snippets/_.snippets\": \"\"\"\nsnippet opt\n\\t<option value=\"${1:option}\">${2:$1}</option>\"\"\"\n    }\n    keys = \"opt\" + EX + \"some\" + JF + JF + \"ende\"\n    wanted = \"\"\"<option value=\"some\">some</option>ende\"\"\"\n\n\nclass snipMate_TestMirrorsInPlaceholders_Overwrite(_VimTest):\n    files = {\n        \"snippets/_.snippets\": \"\"\"\nsnippet opt\n\\t<option value=\"${1:option}\">${2:$1}</option>\"\"\"\n    }\n    keys = \"opt\" + EX + \"some\" + JF + \"not\" + JF + \"ende\"\n    wanted = \"\"\"<option value=\"some\">not</option>ende\"\"\"\n\n\nclass snipMate_Visual_Simple(_VimTest):\n    files = {\n        \"snippets/_.snippets\": \"\"\"\nsnippet v\n\\th${VISUAL}b\"\"\"\n    }\n    keys = \"blablub\" + ESC + \"0v6l\" + EX + \"v\" + EX\n    wanted = \"hblablubb\"\n\n\nclass snipMate_NoNestedTabstops(_VimTest):\n    files = {\n        \"snippets/_.snippets\": \"\"\"\nsnippet test\n\\th$${1:${2:blub}}$$\"\"\"\n    }\n    keys = \"test\" + EX + JF + \"hi\"\n    wanted = \"h$${2:blub}$$hi\"\n\n\nclass snipMate_Extends(_VimTest):\n    files = {\n        \"snippets/a.snippets\": \"\"\"\nextends b\nsnippet test\n\\tblub\"\"\",\n        \"snippets/b.snippets\": \"\"\"\nsnippet test1\n\\tblah\"\"\",\n    }\n    keys = ESC + \":set ft=a\\n\" + \"itest1\" + EX\n    wanted = \"blah\"\n\n\nclass snipMate_EmptyLinesContinueSnippets(_VimTest):\n    files = {\n        \"snippets/_.snippets\": \"\"\"\nsnippet test\n\\tblub\n\n\\tblah\n\nsnippet test1\n\\ta\"\"\"\n    }\n    keys = \"test\" + EX\n    wanted = \"blub\\n\\nblah\\n\"\n\n\nclass snipMate_OverwrittenByRegExpTrigger(_VimTest):\n    files = {\n        \"snippets/_.snippets\": \"\"\"\nsnippet def\n\\tsnipmate\n\"\"\",\n        \"us/all.snippets\": r\"\"\"\nsnippet \"(de)?f\" \"blub\" r\nultisnips\nendsnippet\n\"\"\",\n    }\n    keys = \"def\" + EX\n    wanted = \"ultisnips\"\n\n\nclass snipMate_Issue658(_VimTest):\n    files = {\n        \"snippets/_.snippets\": \"\"\"\nsnippet /*\n\\t/*\n\\t * ${0}\n\\t */\n\"\"\"\n    }\n    keys = ESC + \":set fo=r\\n\" + \"i/*\" + EX + \"1\\n2\"\n    wanted = \"\"\"/*\n * 1\n * 2\n */\n\"\"\"\n\n\nclass snipMate_Issue1325(_VimTest):\n    # https://github.com/SirVer/ultisnips/issues/1325\n    files = {\n        \"snippets/_.snippets\": \"\"\"\nsnippet frac \\\\frac{}{}\n\\t\\\\\\\\frac{${1:num}}{${2:denom}} ${0}\n\"\"\".rstrip()\n    }\n    keys = \"$frac\" + EX + JF + JF + \"blub\"\n    wanted = r\"$\\frac{num}{denom} blub\"\n\n\nclass snipMate_Issue1344(_VimTest):\n    # https://github.com/SirVer/ultisnips/issues/144\n    files = {\n        \"snippets/_.snippets\": \"\"\"\nsnippet .\n\\tself.\n\"\"\".rstrip()\n    }\n    keys = \"os.\" + EX + \"foo\\n.\" + EX\n    wanted = \"os.\\tfoo\\nself.\"\n"
  },
  {
    "path": "test/test_SnippetActions.py",
    "content": "from test.vim_test_case import VimTestCase as _VimTest\nfrom test.constant import *\n\n\nclass SnippetActions_PreActionModifiesBuffer(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        pre_expand \"snip.buffer[snip.line:snip.line] = ['\\n']\"\n        snippet a \"desc\" \"True\" e\n        abc\n        endsnippet\n        \"\"\"\n    }\n    keys = \"a\" + EX\n    wanted = \"\\nabc\"\n\n\nclass SnippetActions_PostActionModifiesBuffer(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        post_expand \"snip.buffer[snip.line+1:snip.line+1] = ['\\n']\"\n        snippet a \"desc\" \"True\" e\n        abc\n        endsnippet\n        \"\"\"\n    }\n    keys = \"a\" + EX\n    wanted = \"abc\\n\"\n\n\nclass SnippetActions_ErrorOnBufferModificationThroughCommand(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        pre_expand \"vim.command('normal O')\"\n        snippet a \"desc\" \"True\" e\n        abc\n        endsnippet\n        \"\"\"\n    }\n    keys = \"a\" + EX\n    expected_error = \"changes are untrackable\"\n\n\nclass SnippetActions_ErrorOnModificationSnippetLine(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        post_expand \"vim.command('normal dd')\"\n        snippet i \"desc\" \"True\" e\n        if:\n            $1\n        endsnippet\n        \"\"\"\n    }\n    keys = \"i\" + EX\n    expected_error = \"line under the cursor was modified\"\n\n\nclass SnippetActions_EnsureIndent(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        pre_expand \"snip.buffer[snip.line] = ' '*4; snip.cursor[1] = 4\"\n        snippet i \"desc\" \"True\" e\n        if:\n            $1\n        endsnippet\n        \"\"\"\n    }\n    keys = \"\\ni\" + EX + \"i\" + EX + \"x\"\n    wanted = \"\"\"\n    if:\n    if:\n        x\"\"\"\n\n\nclass SnippetActions_PostActionCanUseSnippetRange(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        global !p\n        def ensure_newlines(start, end):\n            snip.buffer[start[0]:start[0]] = ['\\n'] * 2\n            snip.buffer[end[0]+1:end[0]+1] = ['\\n'] * 1\n        endglobal\n\n        post_expand \"ensure_newlines(snip.snippet_start, snip.snippet_end)\"\n        snippet i \"desc\"\n        if\n            $1\n        else\n            $2\n        end\n        endsnippet\n        \"\"\"\n    }\n    keys = \"\\ni\" + EX + \"x\" + JF + \"y\"\n    wanted = \"\"\"\n\n\nif\n    x\nelse\n    y\nend\n\"\"\"\n\n\nclass SnippetActions_CanModifyParentBody(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        global !p\n        def ensure_newlines(start, end):\n            snip.buffer[start[0]:start[0]] = ['\\n'] * 2\n        endglobal\n\n        post_expand \"ensure_newlines(snip.snippet_start, snip.snippet_end)\"\n        snippet i \"desc\"\n        if\n            $1\n        else\n            $2\n        end\n        endsnippet\n        \"\"\"\n    }\n    keys = \"\\ni\" + EX + \"i\" + EX + \"x\" + JF + \"y\" + JF + JF + \"z\"\n    wanted = \"\"\"\n\n\nif\n\n\n    if\n        x\n    else\n        y\n    end\nelse\n    z\nend\"\"\"\n\n\nclass SnippetActions_MoveParentSnippetFromChildInPreAction(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        global !p\n        def insert_import():\n            snip.buffer[2:2] = ['import smthing', '']\n        endglobal\n\n        pre_expand \"insert_import()\"\n        snippet p \"desc\"\n        print(smthing.traceback())\n        endsnippet\n\n        snippet i \"desc\"\n        if\n            $1\n        else\n            $2\n        end\n        endsnippet\n        \"\"\"\n    }\n    keys = \"i\" + EX + \"p\" + EX + JF + \"z\"\n    wanted = \"\"\"import smthing\n\nif\n    print(smthing.traceback())\nelse\n    z\nend\"\"\"\n\n\nclass SnippetActions_CanExpandSnippetInDifferentPlace(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        global !p\n        def expand_after_if(snip):\n            snip.buffer[snip.line] = snip.buffer[snip.line][:snip.column] + \\\n                snip.buffer[snip.line][snip.column+1:]\n            snip.cursor[1] = snip.buffer[snip.line].index('if ')+3\n        endglobal\n\n        pre_expand \"expand_after_if(snip)\"\n        snippet n \"append not to if\" w\n        not $0\n        endsnippet\n\n        snippet i \"if cond\" w\n        if $1: $2\n        endsnippet\n        \"\"\"\n    }\n    keys = \"i\" + EX + \"blah\" + JF + \"n\" + EX + JF + \"pass\"\n    wanted = \"\"\"if not blah: pass\"\"\"\n\n\nclass SnippetActions_MoveVisual(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        global !p\n        def extract_method(snip):\n            del snip.buffer[snip.line]\n            snip.buffer[len(snip.buffer)-1:len(snip.buffer)-1] = ['']\n            snip.cursor.set(len(snip.buffer)-2, 0)\n        endglobal\n\n        pre_expand \"extract_method(snip)\"\n        snippet n \"append not to if\" w\n        def $1:\n            ${VISUAL}\n\n        endsnippet\n        \"\"\"\n    }\n\n    keys = (\n        \"\"\"\ndef a:\n    x()\n    y()\n    z()\"\"\"\n        + ESC\n        + \"kVk\"\n        + EX\n        + \"n\"\n        + EX\n        + \"b\"\n    )\n\n    wanted = \"\"\"\ndef a:\n    z()\n\ndef b:\n    x()\n    y()\"\"\"\n\n\nclass SnippetActions_CanMirrorTabStopsOutsideOfSnippet(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        post_jump \"snip.buffer[2] = 'debug({})'.format(snip.tabstops[1].current_text)\"\n        snippet i \"desc\"\n        if $1:\n            $2\n        endsnippet\n        \"\"\"\n    }\n    keys = (\n        \"\"\"\n---\ni\"\"\"\n        + EX\n        + \"test(some(complex(cond(a))))\"\n        + JF\n        + \"x\"\n    )\n    wanted = \"\"\"debug(test(some(complex(cond(a)))))\n---\nif test(some(complex(cond(a)))):\n    x\"\"\"\n\n\nclass SnippetActions_CanExpandAnonSnippetInJumpAction(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        global !p\n        def expand_anon(snip):\n            if snip.tabstop == 0:\n                snip.expand_anon(\"a($2, $1)\")\n        endglobal\n\n        post_jump \"expand_anon(snip)\"\n        snippet i \"desc\"\n        if ${1:cond}:\n            $0\n        endsnippet\n        \"\"\"\n    }\n    keys = \"i\" + EX + \"x\" + JF + \"1\" + JF + \"2\" + JF + \";\"\n    wanted = \"\"\"if x:\n    a(2, 1);\"\"\"\n\n\nclass SnippetActions_CanExpandAnonSnippetInJumpActionWhileSelected(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        global !p\n        def expand_anon(snip):\n            if snip.tabstop == 0:\n                snip.expand_anon(\" // a($2, $1)\")\n        endglobal\n\n        post_jump \"expand_anon(snip)\"\n        snippet i \"desc\"\n        if ${1:cond}:\n            ${2:pass}\n        endsnippet\n        \"\"\"\n    }\n    keys = \"i\" + EX + \"x\" + JF + JF + \"1\" + JF + \"2\" + JF + \";\"\n    wanted = \"\"\"if x:\n    pass // a(2, 1);\"\"\"\n\n\nclass SnippetActions_CanUseContextFromContextMatch(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        pre_expand \"snip.buffer[snip.line:snip.line] = [snip.context]\"\n        snippet i \"desc\" \"'some context'\" e\n        body\n        endsnippet\n        \"\"\"\n    }\n    keys = \"i\" + EX\n    wanted = \"\"\"some context\nbody\"\"\"\n\n\nclass SnippetActions_CanExpandAnonSnippetOnFirstJump(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        global !p\n        def expand_new_snippet_on_first_jump(snip):\n            if snip.tabstop == 1:\n                snip.expand_anon(\"some_check($1, $2, $3)\")\n        endglobal\n\n        post_jump \"expand_new_snippet_on_first_jump(snip)\"\n        snippet \"test\" \"test new features\" \"True\" bwre\n        if $1: $2\n        endsnippet\n        \"\"\"\n    }\n    keys = \"test\" + EX + \"1\" + JF + \"2\" + JF + \"3\" + JF + \" or 4\" + JF + \"5\"\n    wanted = \"\"\"if some_check(1, 2, 3) or 4: 5\"\"\"\n\n\nclass SnippetActions_CanExpandAnonOnPreExpand(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        pre_expand \"snip.buffer[snip.line] = ''; snip.expand_anon('totally_different($2, $1)')\"\n        snippet test \"test new features\" wb\n        endsnippet\n        \"\"\"\n    }\n    keys = \"test\" + EX + \"1\" + JF + \"2\" + JF + \"3\"\n    wanted = \"\"\"totally_different(2, 1)3\"\"\"\n\n\nclass SnippetActions_CanEvenWrapSnippetInPreAction(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        pre_expand \"snip.buffer[snip.line] = ''; snip.expand_anon('some_wrapper($1): $2')\"\n        snippet test \"test new features\" wb\n        wrapme($2, $1)\n        endsnippet\n        \"\"\"\n    }\n    keys = \"test\" + EX + \"1\" + JF + \"2\" + JF + \"3\" + JF + \"4\"\n    wanted = \"\"\"some_wrapper(wrapme(2, 1)3): 4\"\"\"\n\n\nclass SnippetActions_CanVisuallySelectFirstPlaceholderInAnonSnippetInPre(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        pre_expand \"snip.buffer[snip.line] = ''; snip.expand_anon('${1:asd}, ${2:blah}')\"\n        snippet test \"test new features\" wb\n        endsnippet\n        \"\"\"\n    }\n    keys = \"test\" + EX + \"1\" + JF + \"2\"\n    wanted = \"\"\"1, 2\"\"\"\n\n\nclass SnippetActions_UseCorrectJumpActions(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        post_jump \"snip.buffer[-2:-2]=['a' + str(snip.tabstop)]\"\n        snippet a \"a\" wb\n        $1 {\n        $2\n        }\n        endsnippet\n\n        snippet b \"b\" wb\n        bbb\n        endsnippet\n\n        post_jump \"snip.buffer[-2:-2]=['c' + str(snip.tabstop)]\"\n        snippet c \"c\" w\n        $1 : $2 : $3\n        endsnippet\n        \"\"\"\n    }\n    keys = (\n        \"a\" + EX + \"1\" + JF + \"b\" + EX + \" c\" + EX + \"2\" + JF + \"3\" + JF + \"4\" + JF + JF\n    )\n    wanted = \"\"\"1 {\nbbb 2 : 3 : 4\n}\na1\na2\nc1\nc2\nc3\nc0\na0\"\"\"\n\n\nclass SnippetActions_PostActionModifiesCharAfterSnippet(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        post_expand \"snip.buffer[snip.snippet_end[0]] = snip.buffer[snip.snippet_end[0]][:-1]\"\n        snippet a \"desc\" i\n        ($1)\n        endsnippet\n        \"\"\"\n    }\n    keys = \"[]\" + ARR_L + \"a\" + EX + \"1\" + JF + \"2\"\n    wanted = \"[(1)2\"\n\n\nclass SnippetActions_PostActionModifiesLineAfterSnippet(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        post_expand \"snip.buffer[snip.snippet_end[0]+1:snip.snippet_end[0]+2] = []\"\n        snippet a \"desc\"\n        1: $1\n        $0\n        endsnippet\n        \"\"\"\n    }\n    keys = \"\\n3\" + ARR_U + \"a\" + EX + \"1\" + JF + \"2\"\n    wanted = \"1: 1\\n2\"\n\n\nclass SnippetActions_DoNotBreakCursorOnSingleLikeChange(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        post_expand \"snip.buffer[snip.snippet_end[0]] = 'def'; snip.cursor.preserve()\"\n        snippet a \"desc\"\n        asd\n        endsnippet\n        \"\"\"\n    }\n    keys = \"a\" + EX + \"123\"\n    wanted = \"def123\"\n"
  },
  {
    "path": "test/test_SnippetOptions.py",
    "content": "# encoding: utf-8\nfrom test.vim_test_case import VimTestCase as _VimTest\nfrom test.constant import *\nfrom test.util import running_on_windows\n\n\nclass SnippetOptions_OnlyExpandWhenWSInFront_Expand(_VimTest):\n    snippets = (\"test\", \"Expand me!\", \"\", \"b\")\n    keys = \"test\" + EX\n    wanted = \"Expand me!\"\n\n\nclass SnippetOptions_OnlyExpandWhenWSInFront_Expand2(_VimTest):\n    snippets = (\"test\", \"Expand me!\", \"\", \"b\")\n    keys = \"   test\" + EX\n    wanted = \"   Expand me!\"\n\n\nclass SnippetOptions_OnlyExpandWhenWSInFront_DontExpand(_VimTest):\n    snippets = (\"test\", \"Expand me!\", \"\", \"b\")\n    keys = \"a test\" + EX\n    wanted = \"a test\" + EX\n\n\nclass SnippetOptions_OnlyExpandWhenWSInFront_OneWithOneWO(_VimTest):\n    snippets = ((\"test\", \"Expand me!\", \"\", \"b\"), (\"test\", \"not at beginning\", \"\", \"\"))\n    keys = \"a test\" + EX\n    wanted = \"a not at beginning\"\n\n\nclass SnippetOptions_OnlyExpandWhenWSInFront_OneWithOneWOChoose(_VimTest):\n    snippets = ((\"test\", \"Expand me!\", \"\", \"b\"), (\"test\", \"not at beginning\", \"\", \"\"))\n    keys = \"  test\" + EX + \"1\\n\"\n    wanted = \"  Expand me!\"\n\n\nclass SnippetOptions_ExpandInwordSnippets_SimpleExpand(_VimTest):\n    snippets = ((\"test\", \"Expand me!\", \"\", \"i\"),)\n    keys = \"atest\" + EX\n    wanted = \"aExpand me!\"\n\n\nclass SnippetOptions_ExpandInwordSnippets_ExpandSingle(_VimTest):\n    snippets = ((\"test\", \"Expand me!\", \"\", \"i\"),)\n    keys = \"test\" + EX\n    wanted = \"Expand me!\"\n\n\nclass SnippetOptions_ExpandInwordSnippetsWithOtherChars_Expand(_VimTest):\n    snippets = ((\"test\", \"Expand me!\", \"\", \"i\"),)\n    keys = \"$test\" + EX\n    wanted = \"$Expand me!\"\n\n\nclass SnippetOptions_ExpandInwordSnippetsWithOtherChars_Expand2(_VimTest):\n    snippets = ((\"test\", \"Expand me!\", \"\", \"i\"),)\n    keys = \"-test\" + EX\n    wanted = \"-Expand me!\"\n\n\nclass SnippetOptions_ExpandInwordSnippetsWithOtherChars_Expand3(_VimTest):\n    skip_if = lambda self: running_on_windows()\n    snippets = ((\"test\", \"Expand me!\", \"\", \"i\"),)\n    keys = \"ßßtest\" + EX\n    wanted = \"ßßExpand me!\"\n\n\nclass _SnippetOptions_ExpandWordSnippets(_VimTest):\n    snippets = ((\"test\", \"Expand me!\", \"\", \"w\"),)\n\n\nclass SnippetOptions_ExpandWordSnippets_NormalExpand(\n    _SnippetOptions_ExpandWordSnippets\n):\n    keys = \"test\" + EX\n    wanted = \"Expand me!\"\n\n\nclass SnippetOptions_ExpandWordSnippets_NoExpand(_SnippetOptions_ExpandWordSnippets):\n    keys = \"atest\" + EX\n    wanted = \"atest\" + EX\n\n\nclass SnippetOptions_ExpandWordSnippets_ExpandSuffix(\n    _SnippetOptions_ExpandWordSnippets\n):\n    keys = \"a-test\" + EX\n    wanted = \"a-Expand me!\"\n\n\nclass SnippetOptions_ExpandWordSnippets_ExpandSuffix2(\n    _SnippetOptions_ExpandWordSnippets\n):\n    keys = \"a(test\" + EX\n    wanted = \"a(Expand me!\"\n\n\nclass SnippetOptions_ExpandWordSnippets_ExpandSuffix3(\n    _SnippetOptions_ExpandWordSnippets\n):\n    keys = \"[[test\" + EX\n    wanted = \"[[Expand me!\"\n\n\nclass _No_Tab_Expand(_VimTest):\n    snippets = (\"test\", \"\\t\\tExpand\\tme!\\t\", \"\", \"t\")\n\n\nclass No_Tab_Expand_Simple(_No_Tab_Expand):\n    keys = \"test\" + EX\n    wanted = \"\\t\\tExpand\\tme!\\t\"\n\n\nclass No_Tab_Expand_Leading_Spaces(_No_Tab_Expand):\n    keys = \"  test\" + EX\n    wanted = \"  \\t\\tExpand\\tme!\\t\"\n\n\nclass No_Tab_Expand_Leading_Tabs(_No_Tab_Expand):\n    keys = \"\\ttest\" + EX\n    wanted = \"\\t\\t\\tExpand\\tme!\\t\"\n\n\nclass No_Tab_Expand_No_TS(_No_Tab_Expand):\n    def _extra_vim_config(self, vim_config):\n        vim_config.append(\"set sw=3\")\n        vim_config.append(\"set sts=3\")\n\n    keys = \"test\" + EX\n    wanted = \"\\t\\tExpand\\tme!\\t\"\n\n\nclass No_Tab_Expand_ET(_No_Tab_Expand):\n    def _extra_vim_config(self, vim_config):\n        vim_config.append(\"set sw=3\")\n        vim_config.append(\"set expandtab\")\n\n    keys = \"test\" + EX\n    wanted = \"\\t\\tExpand\\tme!\\t\"\n\n\nclass No_Tab_Expand_ET_Leading_Spaces(_No_Tab_Expand):\n    def _extra_vim_config(self, vim_config):\n        vim_config.append(\"set sw=3\")\n        vim_config.append(\"set expandtab\")\n\n    keys = \"  test\" + EX\n    wanted = \"  \\t\\tExpand\\tme!\\t\"\n\n\nclass No_Tab_Expand_ET_SW(_No_Tab_Expand):\n    def _extra_vim_config(self, vim_config):\n        vim_config.append(\"set sw=8\")\n        vim_config.append(\"set expandtab\")\n\n    keys = \"test\" + EX\n    wanted = \"\\t\\tExpand\\tme!\\t\"\n\n\nclass No_Tab_Expand_ET_SW_TS(_No_Tab_Expand):\n    def _extra_vim_config(self, vim_config):\n        vim_config.append(\"set sw=3\")\n        vim_config.append(\"set sts=3\")\n        vim_config.append(\"set ts=3\")\n        vim_config.append(\"set expandtab\")\n\n    keys = \"test\" + EX\n    wanted = \"\\t\\tExpand\\tme!\\t\"\n\n\nclass _TabExpand_RealWorld:\n    snippets = (\n        \"hi\",\n        r\"\"\"hi\n`!p snip.rv=\"i1\\n\"\nsnip.rv += snip.mkline(\"i1\\n\")\nsnip.shift(1)\nsnip.rv += snip.mkline(\"i2\\n\")\nsnip.unshift(2)\nsnip.rv += snip.mkline(\"i0\\n\")\nsnip.shift(3)\nsnip.rv += snip.mkline(\"i3\")`\nsnip.rv = repr(snip.rv)\nEnd\"\"\",\n    )\n\n\nclass No_Tab_Expand_RealWorld(_TabExpand_RealWorld, _VimTest):\n    def _extra_vim_config(self, vim_config):\n        vim_config.append(\"set noexpandtab\")\n\n    keys = \"\\t\\thi\" + EX\n    wanted = \"\"\"\\t\\thi\n\\t\\ti1\n\\t\\ti1\n\\t\\t\\ti2\n\\ti0\n\\t\\t\\t\\ti3\n\\t\\tsnip.rv = repr(snip.rv)\n\\t\\tEnd\"\"\"\n\n\nclass SnippetOptions_Regex_Expand(_VimTest):\n    snippets = (\"(test)\", \"Expand me!\", \"\", \"r\")\n    keys = \"test\" + EX\n    wanted = \"Expand me!\"\n\n\nclass SnippetOptions_Regex_WithSpace(_VimTest):\n    snippets = (\"test \", \"Expand me!\", \"\", \"r\")\n    keys = \"test \" + EX\n    wanted = \"Expand me!\"\n\n\nclass SnippetOptions_Regex_Multiple(_VimTest):\n    snippets = (\"(test *)+\", \"Expand me!\", \"\", \"r\")\n    keys = \"test test test\" + EX\n    wanted = \"Expand me!\"\n\n\nclass _Regex_Self(_VimTest):\n    snippets = (\"((?<=\\\\W)|^)(\\\\.)\", \"self.\", \"\", \"r\")\n\n\nclass SnippetOptions_Regex_Self_Start(_Regex_Self):\n    keys = \".\" + EX\n    wanted = \"self.\"\n\n\nclass SnippetOptions_Regex_Self_Space(_Regex_Self):\n    keys = \" .\" + EX\n    wanted = \" self.\"\n\n\nclass SnippetOptions_Regex_Self_TextAfter(_Regex_Self):\n    keys = \" .a\" + EX\n    wanted = \" .a\" + EX\n\n\nclass SnippetOptions_Regex_Self_TextBefore(_Regex_Self):\n    keys = \"a.\" + EX\n    wanted = \"a.\" + EX\n\n\nclass SnippetOptions_Regex_PythonBlockMatch(_VimTest):\n    snippets = (\n        r\"([abc]+)([def]+)\",\n        r\"\"\"`!p m = match\nsnip.rv += m.group(2)\nsnip.rv += m.group(1)\n`\"\"\",\n        \"\",\n        \"r\",\n    )\n    keys = \"test cabfed\" + EX\n    wanted = \"test fedcab\"\n\n\nclass SnippetOptions_Regex_PythonBlockNoMatch(_VimTest):\n    snippets = (r\"cabfed\", r\"\"\"`!p snip.rv =  match or \"No match\"`\"\"\")\n    keys = \"test cabfed\" + EX\n    wanted = \"test No match\"\n\n\n# Tests for Bug #691575\n\n\nclass SnippetOptions_Regex_SameLine_Long_End(_VimTest):\n    snippets = (\"(test.*)\", \"Expand me!\", \"\", \"r\")\n    keys = \"test test abc\" + EX\n    wanted = \"Expand me!\"\n\n\nclass SnippetOptions_Regex_SameLine_Long_Start(_VimTest):\n    snippets = (\"(.*test)\", \"Expand me!\", \"\", \"r\")\n    keys = \"abc test test\" + EX\n    wanted = \"Expand me!\"\n\n\nclass SnippetOptions_Regex_SameLine_Simple(_VimTest):\n    snippets = (\"(test)\", \"Expand me!\", \"\", \"r\")\n    keys = \"abc test test\" + EX\n    wanted = \"abc test Expand me!\"\n\n\nclass MultiWordSnippet_Simple(_VimTest):\n    snippets = (\"test me\", \"Expand me!\")\n    keys = \"test me\" + EX\n    wanted = \"Expand me!\"\n\n\nclass MultiWord_SnippetOptions_OnlyExpandWhenWSInFront_Expand(_VimTest):\n    snippets = (\"test it\", \"Expand me!\", \"\", \"b\")\n    keys = \"test it\" + EX\n    wanted = \"Expand me!\"\n\n\nclass MultiWord_SnippetOptions_OnlyExpandWhenWSInFront_Expand2(_VimTest):\n    snippets = (\"test it\", \"Expand me!\", \"\", \"b\")\n    keys = \"   test it\" + EX\n    wanted = \"   Expand me!\"\n\n\nclass MultiWord_SnippetOptions_OnlyExpandWhenWSInFront_DontExpand(_VimTest):\n    snippets = (\"test it\", \"Expand me!\", \"\", \"b\")\n    keys = \"a test it\" + EX\n    wanted = \"a test it\" + EX\n\n\nclass MultiWord_SnippetOptions_OnlyExpandWhenWSInFront_OneWithOneWO(_VimTest):\n    snippets = (\n        (\"test it\", \"Expand me!\", \"\", \"b\"),\n        (\"test it\", \"not at beginning\", \"\", \"\"),\n    )\n    keys = \"a test it\" + EX\n    wanted = \"a not at beginning\"\n\n\nclass MultiWord_SnippetOptions_OnlyExpandWhenWSInFront_OneWithOneWOChoose(_VimTest):\n    snippets = (\n        (\"test it\", \"Expand me!\", \"\", \"b\"),\n        (\"test it\", \"not at beginning\", \"\", \"\"),\n    )\n    keys = \"  test it\" + EX + \"1\\n\"\n    wanted = \"  Expand me!\"\n\n\nclass MultiWord_SnippetOptions_ExpandInwordSnippets_SimpleExpand(_VimTest):\n    snippets = ((\"test it\", \"Expand me!\", \"\", \"i\"),)\n    keys = \"atest it\" + EX\n    wanted = \"aExpand me!\"\n\n\nclass MultiWord_SnippetOptions_ExpandInwordSnippets_ExpandSingle(_VimTest):\n    snippets = ((\"test it\", \"Expand me!\", \"\", \"i\"),)\n    keys = \"test it\" + EX\n    wanted = \"Expand me!\"\n\n\nclass _MultiWord_SnippetOptions_ExpandWordSnippets(_VimTest):\n    snippets = ((\"test it\", \"Expand me!\", \"\", \"w\"),)\n\n\nclass MultiWord_SnippetOptions_ExpandWordSnippets_NormalExpand(\n    _MultiWord_SnippetOptions_ExpandWordSnippets\n):\n    keys = \"test it\" + EX\n    wanted = \"Expand me!\"\n\n\nclass MultiWord_SnippetOptions_ExpandWordSnippets_NoExpand(\n    _MultiWord_SnippetOptions_ExpandWordSnippets\n):\n    keys = \"atest it\" + EX\n    wanted = \"atest it\" + EX\n\n\nclass MultiWord_SnippetOptions_ExpandWordSnippets_ExpandSuffix(\n    _MultiWord_SnippetOptions_ExpandWordSnippets\n):\n    keys = \"a-test it\" + EX\n    wanted = \"a-Expand me!\"\n"
  },
  {
    "path": "test/test_SnippetPriorities.py",
    "content": "from test.vim_test_case import VimTestCase as _VimTest\nfrom test.constant import EX, ESC\n\n\nclass SnippetPriorities_MultiWordTriggerOverwriteExisting(_VimTest):\n    snippets = (\n        (\"test me\", \"${1:Hallo}\", \"Types Hallo\"),\n        (\"test me\", \"${1:World}\", \"Types World\"),\n        (\"test me\", \"We overwrite\", \"Overwrite the two\", \"\", 1),\n    )\n    keys = \"test me\" + EX\n    wanted = \"We overwrite\"\n\n\nclass SnippetPriorities_DoNotCareAboutNonMatchings(_VimTest):\n    snippets = (\n        (\"test1\", \"Hallo\", \"Types Hallo\"),\n        (\"test2\", \"We overwrite\", \"Overwrite the two\", \"\", 1),\n    )\n    keys = \"test1\" + EX\n    wanted = \"Hallo\"\n\n\nclass SnippetPriorities_OverwriteExisting(_VimTest):\n    snippets = (\n        (\"test\", \"${1:Hallo}\", \"Types Hallo\"),\n        (\"test\", \"${1:World}\", \"Types World\"),\n        (\"test\", \"We overwrite\", \"Overwrite the two\", \"\", 1),\n    )\n    keys = \"test\" + EX\n    wanted = \"We overwrite\"\n\n\nclass SnippetPriorities_OverwriteTwice_ECR(_VimTest):\n    snippets = (\n        (\"test\", \"${1:Hallo}\", \"Types Hallo\"),\n        (\"test\", \"${1:World}\", \"Types World\"),\n        (\"test\", \"We overwrite\", \"Overwrite the two\", \"\", 1),\n        (\"test\", \"again\", \"Overwrite again\", \"\", 2),\n    )\n    keys = \"test\" + EX\n    wanted = \"again\"\n\n\nclass SnippetPriorities_OverwriteThenChoose_ECR(_VimTest):\n    snippets = (\n        (\"test\", \"${1:Hallo}\", \"Types Hallo\"),\n        (\"test\", \"${1:World}\", \"Types World\"),\n        (\"test\", \"We overwrite\", \"Overwrite the two\", \"\", 1),\n        (\"test\", \"No overwrite\", \"Not overwritten\", \"\", 1),\n    )\n    keys = \"test\" + EX + \"1\\n\\n\" + \"test\" + EX + \"2\\n\"\n    wanted = \"We overwrite\\nNo overwrite\"\n\n\nclass SnippetPriorities_AddedHasHigherThanFile(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        snippet test \"Test Snippet\" b\n        This is a test snippet\n        endsnippet\n        \"\"\"\n    }\n    snippets = ((\"test\", \"We overwrite\", \"Overwrite the two\", \"\", 1),)\n    keys = \"test\" + EX\n    wanted = \"We overwrite\"\n\n\nclass SnippetPriorities_FileHasHigherThanAdded(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        snippet test \"Test Snippet\" b\n        This is a test snippet\n        endsnippet\n        \"\"\"\n    }\n    snippets = ((\"test\", \"We do not overwrite\", \"Overwrite the two\", \"\", -1),)\n    keys = \"test\" + EX\n    wanted = \"This is a test snippet\"\n\n\nclass SnippetPriorities_FileHasHigherThanAdded_neg_prio(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        priority -3\n        snippet test \"Test Snippet\" b\n        This is a test snippet\n        endsnippet\n        \"\"\"\n    }\n    snippets = ((\"test\", \"We overwrite\", \"Overwrite the two\", \"\", -5),)\n    keys = \"test\" + EX\n    wanted = \"This is a test snippet\"\n\n\nclass SnippetPriorities_SimpleClear(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        priority 1\n        clearsnippets\n        priority -1\n        snippet test \"Test Snippet\"\n        Should not expand to this.\n        endsnippet\n        \"\"\"\n    }\n    keys = \"test\" + EX\n    wanted = \"test\" + EX\n\n\nclass SnippetPriorities_SimpleClear2(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        clearsnippets\n        snippet test \"Test snippet\"\n        Should not expand to this.\n        endsnippet\n        \"\"\"\n    }\n    keys = \"test\" + EX\n    wanted = \"test\" + EX\n\n\nclass SnippetPriorities_ClearedByParent(_VimTest):\n    files = {\n        \"us/p.snippets\": r\"\"\"\n        clearsnippets\n        \"\"\",\n        \"us/c.snippets\": r\"\"\"\n        extends p\n        snippet test \"Test snippets\"\n        Should not expand to this.\n        endsnippet\n        \"\"\",\n    }\n    keys = ESC + \":set ft=c\\n\" + \"itest\" + EX\n    wanted = \"test\" + EX\n\n\nclass SnippetPriorities_ClearedByChild(_VimTest):\n    files = {\n        \"us/p.snippets\": r\"\"\"\n        snippet test \"Test snippets\"\n        Should only expand in p.\n        endsnippet\n        \"\"\",\n        \"us/c.snippets\": r\"\"\"\n        extends p\n        clearsnippets\n        \"\"\",\n    }\n    keys = (\n        ESC\n        + \":set ft=p\\n\"\n        + \"itest\"\n        + EX\n        + \"\\n\"\n        + ESC\n        + \":set ft=c\\n\"\n        + \"itest\"\n        + EX\n        + ESC\n        + \":set ft=p\"\n    )\n    wanted = \"Should only expand in p.\\ntest\" + EX\n"
  },
  {
    "path": "test/test_TabStop.py",
    "content": "from test.vim_test_case import VimTestCase as _VimTest\nfrom test.constant import *\n\n\nclass TabStopSimpleReplace_ExpectCorrectResult(_VimTest):\n    snippets = (\"hallo\", \"hallo ${0:End} ${1:Beginning}\")\n    keys = \"hallo\" + EX + \"na\" + JF + \"Du Nase\"\n    wanted = \"hallo Du Nase na\"\n\n\nclass TabStopSimpleReplaceZeroLengthTabstops_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", r\":latex:\\`$1\\`$0\")\n    keys = \"test\" + EX + \"Hello\" + JF + \"World\"\n    wanted = \":latex:`Hello`World\"\n\n\nclass TabStopSimpleReplaceReversed_ExpectCorrectResult(_VimTest):\n    snippets = (\"hallo\", \"hallo ${1:End} ${0:Beginning}\")\n    keys = \"hallo\" + EX + \"na\" + JF + \"Du Nase\"\n    wanted = \"hallo na Du Nase\"\n\n\nclass TabStopSimpleReplaceSurrounded_ExpectCorrectResult(_VimTest):\n    snippets = (\"hallo\", \"hallo ${0:End} a small feed\")\n    keys = \"hallo\" + EX + \"Nase\"\n    wanted = \"hallo Nase a small feed\"\n\n\nclass TabStopSimpleReplaceSurrounded1_ExpectCorrectResult(_VimTest):\n    snippets = (\"hallo\", \"hallo $0 a small feed\")\n    keys = \"hallo\" + EX + \"Nase\"\n    wanted = \"hallo Nase a small feed\"\n\n\nclass TabStop_Exit_ExpectCorrectResult(_VimTest):\n    snippets = (\"echo\", \"$0 run\")\n    keys = \"echo\" + EX + \"test\"\n    wanted = \"test run\"\n\n\nclass TabStopNoReplace_ExpectCorrectResult(_VimTest):\n    snippets = (\"echo\", \"echo ${1:Hallo}\")\n    keys = \"echo\" + EX\n    wanted = \"echo Hallo\"\n\n\nclass TabStop_EscapingCharsBackticks(_VimTest):\n    snippets = (\"test\", r\"snip \\` literal\")\n    keys = \"test\" + EX\n    wanted = \"snip ` literal\"\n\n\nclass TabStop_EscapingCharsDollars(_VimTest):\n    snippets = (\"test\", r\"snip \\$0 $$0 end\")\n    keys = \"test\" + EX + \"hi\"\n    wanted = \"snip $0 $hi end\"\n\n\nclass TabStop_EscapingCharsDollars1(_VimTest):\n    snippets = (\"test\", r\"a\\${1:literal}\")\n    keys = \"test\" + EX\n    wanted = \"a${1:literal}\"\n\n\nclass TabStop_EscapingCharsDollars_BeginningOfLine(_VimTest):\n    snippets = (\"test\", \"\\n\\\\${1:literal}\")\n    keys = \"test\" + EX\n    wanted = \"\\n${1:literal}\"\n\n\nclass TabStop_EscapingCharsDollars_BeginningOfDefinitionText(_VimTest):\n    snippets = (\"test\", \"\\\\${1:literal}\")\n    keys = \"test\" + EX\n    wanted = \"${1:literal}\"\n\n\nclass TabStop_EscapingChars_Backslash(_VimTest):\n    snippets = (\"test\", r\"This \\ is a backslash!\")\n    keys = \"test\" + EX\n    wanted = \"This \\\\ is a backslash!\"\n\n\nclass TabStop_EscapingChars_Backslash2(_VimTest):\n    snippets = (\"test\", r\"This is a backslash \\\\ done\")\n    keys = \"test\" + EX\n    wanted = r\"This is a backslash \\ done\"\n\n\nclass TabStop_EscapingChars_Backslash3(_VimTest):\n    snippets = (\"test\", r\"These are two backslashes \\\\\\\\ done\")\n    keys = \"test\" + EX\n    wanted = r\"These are two backslashes \\\\ done\"\n\n\nclass TabStop_EscapingChars_Backslash4(_VimTest):\n    # Test for bug 746446\n    snippets = (\"test\", r\"\\\\$1{$2}\")\n    keys = \"test\" + EX + \"hello\" + JF + \"world\"\n    wanted = r\"\\hello{world}\"\n\n\nclass TabStop_EscapingChars_RealLife(_VimTest):\n    snippets = (\"test\", r\"usage: \\`basename \\$0\\` ${1:args}\")\n    keys = \"test\" + EX + \"[ -u -v -d ]\"\n    wanted = \"usage: `basename $0` [ -u -v -d ]\"\n\n\nclass TabStopEscapingWhenSelected_ECR(_VimTest):\n    snippets = (\"test\", \"snip ${1:default}\")\n    keys = \"test\" + EX + ESC + \"0ihi\"\n    wanted = \"hisnip default\"\n\n\nclass TabStopEscapingWhenSelectedSingleCharTS_ECR(_VimTest):\n    snippets = (\"test\", \"snip ${1:i}\")\n    keys = \"test\" + EX + ESC + \"0ihi\"\n    wanted = \"hisnip i\"\n\n\nclass TabStopEscapingWhenSelectedNoCharTS_ECR(_VimTest):\n    snippets = (\"test\", \"snip $1\")\n    keys = \"test\" + EX + ESC + \"0ihi\"\n    wanted = \"hisnip \"\n\n\nclass TabStopWithOneChar_ExpectCorrectResult(_VimTest):\n    snippets = (\"hallo\", \"nothing ${1:i} hups\")\n    keys = \"hallo\" + EX + \"ship\"\n    wanted = \"nothing ship hups\"\n\n\nclass TabStopTestJumping_ExpectCorrectResult(_VimTest):\n    snippets = (\"hallo\", \"hallo ${2:End} mitte ${1:Beginning}\")\n    keys = \"hallo\" + EX + JF + \"Test\" + JF + \"Hi\"\n    wanted = \"hallo Test mitte BeginningHi\"\n\n\nclass TabStopTestJumping2_ExpectCorrectResult(_VimTest):\n    snippets = (\"hallo\", \"hallo $2 $1\")\n    keys = \"hallo\" + EX + JF + \"Test\" + JF + \"Hi\"\n    wanted = \"hallo Test Hi\"\n\n\nclass TabStopTestJumpingRLExampleWithZeroTab_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"each_byte { |${1:byte}| $0 }\")\n    keys = \"test\" + EX + JF + \"Blah\"\n    wanted = \"each_byte { |byte| Blah }\"\n\n\nclass TabStopTestJumpingDontJumpToEndIfThereIsTabZero_ExpectCorrectResult(_VimTest):\n    snippets = (\"hallo\", \"hallo $0 $1\")\n    keys = \"hallo\" + EX + \"Test\" + JF + \"Hi\" + JF + JF + \"du\"\n    wanted = \"hallo Hi\" + 2 * JF + \"du Test\"\n\n\nclass TabStopTestBackwardJumping_ExpectCorrectResult(_VimTest):\n    snippets = (\"hallo\", \"hallo ${2:End} mitte${1:Beginning}\")\n    keys = (\n        \"hallo\"\n        + EX\n        + \"Somelengthy Text\"\n        + JF\n        + \"Hi\"\n        + JB\n        + \"Lets replace it again\"\n        + JF\n        + \"Blah\"\n        + JF\n        + JB * 2\n        + JF\n    )\n    wanted = \"hallo Blah mitteLets replace it again\" + JB * 2 + JF\n\n\nclass TabStopTestBackwardJumping2_ExpectCorrectResult(_VimTest):\n    snippets = (\"hallo\", \"hallo $2 $1\")\n    keys = (\n        \"hallo\"\n        + EX\n        + \"Somelengthy Text\"\n        + JF\n        + \"Hi\"\n        + JB\n        + \"Lets replace it again\"\n        + JF\n        + \"Blah\"\n        + JF\n        + JB * 2\n        + JF\n    )\n    wanted = \"hallo Blah Lets replace it again\" + JB * 2 + JF\n\n\nclass TabStopTestMultilineExpand_ExpectCorrectResult(_VimTest):\n    snippets = (\"hallo\", \"hallo $0\\nnice $1 work\\n$3 $2\\nSeem to work\")\n    keys = (\n        \"test hallo World\"\n        + ESC\n        + \"02f i\"\n        + EX\n        + \"world\"\n        + JF\n        + \"try\"\n        + JF\n        + \"test\"\n        + JF\n        + \"one more\"\n        + JF\n    )\n    wanted = (\n        \"test hallo one more\" + JF + \"\\nnice world work\\n\"\n        \"test try\\nSeem to work World\"\n    )\n\n\nclass TabStop_TSInDefaultTextRLExample_OverwriteNone_ECR(_VimTest):\n    snippets = (\"test\", \"\"\"<div${1: id=\"${2:some_id}\"}>\\n  $0\\n</div>\"\"\")\n    keys = \"test\" + EX\n    wanted = \"\"\"<div id=\"some_id\">\\n  \\n</div>\"\"\"\n\n\nclass TabStop_TSInDefaultTextRLExample_OverwriteFirst_NoJumpBack(_VimTest):\n    snippets = (\"test\", \"\"\"<div${1: id=\"${2:some_id}\"}>\\n  $0\\n</div>\"\"\")\n    keys = \"test\" + EX + \" blah\" + JF + \"Hallo\"\n    wanted = \"\"\"<div blah>\\n  Hallo\\n</div>\"\"\"\n\n\nclass TabStop_TSInDefaultTextRLExample_DeleteFirst(_VimTest):\n    snippets = (\"test\", \"\"\"<div${1: id=\"${2:some_id}\"}>\\n  $0\\n</div>\"\"\")\n    keys = \"test\" + EX + BS + JF + \"Hallo\"\n    wanted = \"\"\"<div>\\n  Hallo\\n</div>\"\"\"\n\n\nclass TabStop_TSInDefaultTextRLExample_OverwriteFirstJumpBack(_VimTest):\n    snippets = (\"test\", \"\"\"<div${1: id=\"${2:some_id}\"}>\\n  $3  $0\\n</div>\"\"\")\n    keys = (\n        \"test\"\n        + EX\n        + \"Hi\"\n        + JF\n        + \"Hallo\"\n        + JB\n        + \"SomethingElse\"\n        + JF\n        + \"Nupl\"\n        + JF\n        + \"Nox\"\n    )\n    wanted = \"\"\"<divSomethingElse>\\n  Nupl  Nox\\n</div>\"\"\"\n\n\nclass TabStop_TSInDefaultTextRLExample_OverwriteSecond(_VimTest):\n    snippets = (\"test\", \"\"\"<div${1: id=\"${2:some_id}\"}>\\n  $0\\n</div>\"\"\")\n    keys = \"test\" + EX + JF + \"no\" + JF + \"End\"\n    wanted = \"\"\"<div id=\"no\">\\n  End\\n</div>\"\"\"\n\n\nclass TabStop_TSInDefaultTextRLExample_OverwriteSecondTabBack(_VimTest):\n    snippets = (\"test\", \"\"\"<div${1: id=\"${2:some_id}\"}>\\n  $3 $0\\n</div>\"\"\")\n    keys = \"test\" + EX + JF + \"no\" + JF + \"End\" + JB + \"yes\" + JF + \"Begin\" + JF + \"Hi\"\n    wanted = \"\"\"<div id=\"yes\">\\n  Begin Hi\\n</div>\"\"\"\n\n\nclass TabStop_TSInDefaultTextRLExample_OverwriteSecondTabBackTwice(_VimTest):\n    snippets = (\"test\", \"\"\"<div${1: id=\"${2:some_id}\"}>\\n  $3 $0\\n</div>\"\"\")\n    keys = (\n        \"test\"\n        + EX\n        + JF\n        + \"no\"\n        + JF\n        + \"End\"\n        + JB\n        + \"yes\"\n        + JB\n        + \" allaway\"\n        + JF\n        + \"Third\"\n        + JF\n        + \"Last\"\n    )\n    wanted = \"\"\"<div allaway>\\n  Third Last\\n</div>\"\"\"\n\n\nclass TabStop_TSInDefaultText_ZeroLengthNested_OverwriteSecond(_VimTest):\n    snippets = (\"test\", \"\"\"h${1:a$2b}l\"\"\")\n    keys = \"test\" + EX + JF + \"ups\" + JF + \"End\"\n    wanted = \"\"\"haupsblEnd\"\"\"\n\n\nclass TabStop_TSInDefaultText_ZeroLengthZerothTabstop(_VimTest):\n    snippets = (\n        \"test\",\n        \"\"\"Test: ${1:snippet start\\nNested tabstop: $0\\nsnippet end}\\nTrailing text\"\"\",\n    )\n    keys = \"test\" + EX + JF + \"hello\"\n    wanted = \"Test: snippet start\\nNested tabstop: hello\\nsnippet end\\nTrailing text\"\n\n\nclass TabStop_TSInDefaultText_ZeroLengthZerothTabstop_Override(_VimTest):\n    snippets = (\n        \"test\",\n        \"\"\"Test: ${1:snippet start\\nNested tabstop: $0\\nsnippet end}\\nTrailing text\"\"\",\n    )\n    keys = \"test\" + EX + \"blub\" + JF + \"hello\"\n    wanted = \"Test: blub\\nTrailing texthello\"\n\n\nclass TabStop_TSInDefaultText_ZeroLengthNested_OverwriteFirst(_VimTest):\n    snippets = (\"test\", \"\"\"h${1:a$2b}l\"\"\")\n    keys = \"test\" + EX + \"ups\" + JF + \"End\"\n    wanted = \"\"\"hupslEnd\"\"\"\n\n\nclass TabStop_TSInDefaultText_ZeroLengthNested_OverwriteSecondJumpBackOverwrite(\n    _VimTest\n):\n    snippets = (\"test\", \"\"\"h${1:a$2b}l\"\"\")\n    keys = \"test\" + EX + JF + \"longertext\" + JB + \"overwrite\" + JF + \"End\"\n    wanted = \"\"\"hoverwritelEnd\"\"\"\n\n\nclass TabStop_TSInDefaultText_ZeroLengthNested_OverwriteSecondJumpBackAndForward0(\n    _VimTest\n):\n    snippets = (\"test\", \"\"\"h${1:a$2b}l\"\"\")\n    keys = \"test\" + EX + JF + \"longertext\" + JB + JF + \"overwrite\" + JF + \"End\"\n    wanted = \"\"\"haoverwriteblEnd\"\"\"\n\n\nclass TabStop_TSInDefaultText_ZeroLengthNested_OverwriteSecondJumpBackAndForward1(\n    _VimTest\n):\n    snippets = (\"test\", \"\"\"h${1:a$2b}l\"\"\")\n    keys = \"test\" + EX + JF + \"longertext\" + JB + JF + JF + \"End\"\n    wanted = \"\"\"halongertextblEnd\"\"\"\n\n\nclass TabStop_TSInDefaultNested_OverwriteOneJumpBackToOther(_VimTest):\n    snippets = (\"test\", \"hi ${1:this ${2:second ${3:third}}} $4\")\n    keys = \"test\" + EX + JF + \"Hallo\" + JF + \"Ende\"\n    wanted = \"hi this Hallo Ende\"\n\n\nclass TabStop_TSInDefaultNested_OverwriteOneJumpToThird(_VimTest):\n    snippets = (\"test\", \"hi ${1:this ${2:second ${3:third}}} $4\")\n    keys = \"test\" + EX + JF + JF + \"Hallo\" + JF + \"Ende\"\n    wanted = \"hi this second Hallo Ende\"\n\n\nclass TabStop_TSInDefaultNested_OverwriteOneJumpAround(_VimTest):\n    snippets = (\"test\", \"hi ${1:this ${2:second ${3:third}}} $4\")\n    keys = \"test\" + EX + JF + JF + \"Hallo\" + JB + JB + \"Blah\" + JF + \"Ende\"\n    wanted = \"hi Blah Ende\"\n\n\nclass TabStop_TSInDefault_MirrorsOutside_DoNothing(_VimTest):\n    snippets = (\"test\", \"hi ${1:this ${2:second}} $2\")\n    keys = \"test\" + EX\n    wanted = \"hi this second second\"\n\n\nclass TabStop_TSInDefault_MirrorsOutside_OverwriteSecond(_VimTest):\n    snippets = (\"test\", \"hi ${1:this ${2:second}} $2\")\n    keys = \"test\" + EX + JF + \"Hallo\"\n    wanted = \"hi this Hallo Hallo\"\n\n\nclass TabStop_TSInDefault_MirrorsOutside_Overwrite0(_VimTest):\n    snippets = (\"test\", \"hi ${1:this ${2:second}} $2\")\n    keys = \"test\" + EX + \"Hallo\"\n    wanted = \"hi Hallo \"\n\n\nclass TabStop_TSInDefault_MirrorsOutside_Overwrite1(_VimTest):\n    snippets = (\"test\", \"$1: ${1:'${2:second}'} $2\")\n    keys = \"test\" + EX + \"Hallo\"\n    wanted = \"Hallo: Hallo \"\n\n\nclass TabStop_TSInDefault_MirrorsOutside_OverwriteSecond1(_VimTest):\n    snippets = (\"test\", \"$1: ${1:'${2:second}'} $2\")\n    keys = \"test\" + EX + JF + \"Hallo\"\n    wanted = \"'Hallo': 'Hallo' Hallo\"\n\n\nclass TabStop_TSInDefault_MirrorsOutside_OverwriteFirstSwitchNumbers(_VimTest):\n    snippets = (\"test\", \"$2: ${2:'${1:second}'} $1\")\n    keys = \"test\" + EX + \"Hallo\"\n    wanted = \"'Hallo': 'Hallo' Hallo\"\n\n\nclass TabStop_TSInDefault_MirrorsOutside_OverwriteFirst_RLExample(_VimTest):\n    snippets = (\n        \"test\",\n        \"\"\"`!p snip.rv = t[1].split('/')[-1].lower().strip(\"'\")` = require(${1:'${2:sys}'})\"\"\",\n    )\n    keys = \"test\" + EX + \"WORLD\" + JF + \"End\"\n    wanted = \"world = require(WORLD)End\"\n\n\nclass TabStop_TSInDefault_MirrorsOutside_OverwriteSecond_RLExample(_VimTest):\n    snippets = (\n        \"test\",\n        \"\"\"`!p snip.rv = t[1].split('/')[-1].lower().strip(\"'\")` = require(${1:'${2:sys}'})\"\"\",\n    )\n    keys = \"test\" + EX + JF + \"WORLD\" + JF + \"End\"\n    wanted = \"world = require('WORLD')End\"\n\n\nclass TabStop_Multiline_Leave(_VimTest):\n    snippets = (\"test\", \"hi ${1:first line\\nsecond line} world\")\n    keys = \"test\" + EX\n    wanted = \"hi first line\\nsecond line world\"\n\n\nclass TabStop_Multiline_Overwrite(_VimTest):\n    snippets = (\"test\", \"hi ${1:first line\\nsecond line} world\")\n    keys = \"test\" + EX + \"Nothing\"\n    wanted = \"hi Nothing world\"\n\n\nclass TabStop_Multiline_MirrorInFront_Leave(_VimTest):\n    snippets = (\"test\", \"hi $1 ${1:first line\\nsecond line} world\")\n    keys = \"test\" + EX\n    wanted = \"hi first line\\nsecond line first line\\nsecond line world\"\n\n\nclass TabStop_Multiline_MirrorInFront_Overwrite(_VimTest):\n    snippets = (\"test\", \"hi $1 ${1:first line\\nsecond line} world\")\n    keys = \"test\" + EX + \"Nothing\"\n    wanted = \"hi Nothing Nothing world\"\n\n\nclass TabStop_Multiline_DelFirstOverwriteSecond_Overwrite(_VimTest):\n    snippets = (\"test\", \"hi $1 $2 ${1:first line\\nsecond line} ${2:Hi} world\")\n    keys = \"test\" + EX + BS + JF + \"Nothing\"\n    wanted = \"hi  Nothing  Nothing world\"\n\n\nclass TabStopNavigatingInInsertModeSimple_ExpectCorrectResult(_VimTest):\n    snippets = (\"hallo\", \"Hallo ${1:WELT} ups\")\n    keys = \"hallo\" + EX + \"haselnut\" + 2 * ARR_L + \"hips\" + JF + \"end\"\n    wanted = \"Hallo haselnhipsut upsend\"\n\n\nclass TabStop_CROnlyOnSelectedNear(_VimTest):\n    snippets = (\"test\", \"t$1t${2: }t{\\n\\t$0\\n}\")\n    keys = \"test\" + EX + JF + \"\\n\" + JF + \"t\"\n    wanted = \"tt\\nt{\\n\\tt\\n}\"\n\n\nclass TabStop_AdjacentTabStopAddText_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"[ $1$2 ] $1\")\n    keys = \"test\" + EX + \"Hello\" + JF + \"World\" + JF\n    wanted = \"[ HelloWorld ] Hello\"\n\n\nclass TabStop_KeepCorrectJumpListOnOverwriteOfPartOfSnippet(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        snippet i\n        ia$1: $2\n        endsnippet\n\n        snippet ia\n        ia($1, $2)\n        endsnippet\"\"\"\n    }\n    keys = \"i\" + EX + EX + \"1\" + JF + \"2\" + JF + \" after\" + JF + \"3\"\n    wanted = \"ia(1, 2) after: 3\"\n\n\nclass TabStop_KeepCorrectJumpListOnOverwriteOfPartOfSnippetRE(_VimTest):\n    files = {\n        \"us/all.snippets\": r\"\"\"\n        snippet i\n        ia$1: $2\n        endsnippet\n\n        snippet \"^ia\" \"regexp\" r\n        ia($1, $2)\n        endsnippet\"\"\"\n    }\n    keys = \"i\" + EX + EX + \"1\" + JF + \"2\" + JF + \" after\" + JF + \"3\"\n    wanted = \"ia(1, 2) after: 3\"\n"
  },
  {
    "path": "test/test_Transformation.py",
    "content": "# encoding: utf-8\nfrom test.vim_test_case import VimTestCase as _VimTest\nfrom test.constant import *\nfrom test.util import no_unidecode_available\n\n\nclass Transformation_SimpleCase_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"$1 ${1/foo/batzl/}\")\n    keys = \"test\" + EX + \"hallo foo boy\"\n    wanted = \"hallo foo boy hallo batzl boy\"\n\n\nclass Transformation_SimpleCaseNoTransform_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"$1 ${1/foo/batzl/}\")\n    keys = \"test\" + EX + \"hallo\"\n    wanted = \"hallo hallo\"\n\n\nclass Transformation_SimpleCaseTransformInFront_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"${1/foo/batzl/} $1\")\n    keys = \"test\" + EX + \"hallo foo\"\n    wanted = \"hallo batzl hallo foo\"\n\n\nclass Transformation_SimpleCaseTransformInFrontDefVal_ECR(_VimTest):\n    snippets = (\"test\", \"${1/foo/batzl/} ${1:replace me}\")\n    keys = \"test\" + EX + \"hallo foo\"\n    wanted = \"hallo batzl hallo foo\"\n\n\nclass Transformation_MultipleTransformations_ECR(_VimTest):\n    snippets = (\"test\", \"${1:Some Text}${1/.+/\\\\U$0\\\\E/}\\n${1/.+/\\\\L$0\\\\E/}\")\n    keys = \"test\" + EX + \"SomE tExt \"\n    wanted = \"SomE tExt SOME TEXT \\nsome text \"\n\n\nclass Transformation_TabIsAtEndAndDeleted_ECR(_VimTest):\n    snippets = (\"test\", \"${1/.+/is something/}${1:some}\")\n    keys = \"hallo test\" + EX + \"some\\b\\b\\b\\b\\b\"\n    wanted = \"hallo \"\n\n\nclass Transformation_TabIsAtEndAndDeleted1_ECR(_VimTest):\n    snippets = (\"test\", \"${1/.+/is something/}${1:some}\")\n    keys = \"hallo test\" + EX + \"some\\b\\b\\b\\bmore\"\n    wanted = \"hallo is somethingmore\"\n\n\nclass Transformation_TabIsAtEndNoTextLeave_ECR(_VimTest):\n    snippets = (\"test\", \"${1/.+/is something/}${1}\")\n    keys = \"hallo test\" + EX\n    wanted = \"hallo \"\n\n\nclass Transformation_TabIsAtEndNoTextType_ECR(_VimTest):\n    snippets = (\"test\", \"${1/.+/is something/}${1}\")\n    keys = \"hallo test\" + EX + \"b\"\n    wanted = \"hallo is somethingb\"\n\n\nclass Transformation_InsideTabLeaveAtDefault_ECR(_VimTest):\n    snippets = (\"test\", r\"$1 ${2:${1/.+/(?0:defined $0)/}}\")\n    keys = \"test\" + EX + \"sometext\" + JF\n    wanted = \"sometext defined sometext\"\n\n\nclass Transformation_InsideTabOvertype_ECR(_VimTest):\n    snippets = (\"test\", r\"$1 ${2:${1/.+/(?0:defined $0)/}}\")\n    keys = \"test\" + EX + \"sometext\" + JF + \"overwrite\"\n    wanted = \"sometext overwrite\"\n\n\nclass Transformation_Backreference_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"$1 ${1/([ab])oo/$1ull/}\")\n    keys = \"test\" + EX + \"foo boo aoo\"\n    wanted = \"foo boo aoo foo bull aoo\"\n\n\nclass Transformation_BackreferenceTwice_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", r\"$1 ${1/(dead) (par[^ ]*)/this $2 is a bit $1/}\")\n    keys = \"test\" + EX + \"dead parrot\"\n    wanted = \"dead parrot this parrot is a bit dead\"\n\n\nclass Transformation_CleverTransformUpercaseChar_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"$1 ${1/(.)/\\\\u$1/}\")\n    keys = \"test\" + EX + \"hallo\"\n    wanted = \"hallo Hallo\"\n\n\nclass Transformation_CleverTransformLowercaseChar_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"$1 ${1/(.*)/\\\\l$1/}\")\n    keys = \"test\" + EX + \"Hallo\"\n    wanted = \"Hallo hallo\"\n\n\nclass Transformation_CleverTransformLongUpper_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"$1 ${1/(.*)/\\\\U$1\\\\E/}\")\n    keys = \"test\" + EX + \"hallo\"\n    wanted = \"hallo HALLO\"\n\n\nclass Transformation_CleverTransformLongLower_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"$1 ${1/(.*)/\\\\L$1\\\\E/}\")\n    keys = \"test\" + EX + \"HALLO\"\n    wanted = \"HALLO hallo\"\n\n\nclass Transformation_SimpleCaseAsciiResult(_VimTest):\n    skip_if = lambda self: no_unidecode_available()\n    snippets = (\"ascii\", \"$1 ${1/(.*)/$1/a}\")\n    keys = \"ascii\" + EX + \"éèàçôïÉÈÀÇÔÏ€\"\n    wanted = \"éèàçôïÉÈÀÇÔÏ€ eeacoiEEACOIEUR\"\n\n\nclass Transformation_LowerCaseAsciiResult(_VimTest):\n    skip_if = lambda self: no_unidecode_available()\n    snippets = (\"ascii\", \"$1 ${1/(.*)/\\\\L$1\\\\E/a}\")\n    keys = \"ascii\" + EX + \"éèàçôïÉÈÀÇÔÏ€\"\n    wanted = \"éèàçôïÉÈÀÇÔÏ€ eeacoieeacoieur\"\n\n\nclass Transformation_ConditionalInsertionSimple_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"$1 ${1/(^a).*/(?0:began with an a)/}\")\n    keys = \"test\" + EX + \"a some more text\"\n    wanted = \"a some more text began with an a\"\n\n\nclass Transformation_CIBothDefinedNegative_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"$1 ${1/(?:(^a)|(^b)).*/(?1:yes:no)/}\")\n    keys = \"test\" + EX + \"b some\"\n    wanted = \"b some no\"\n\n\nclass Transformation_CIBothDefinedPositive_ExpectCorrectResult(_VimTest):\n    snippets = (\"test\", \"$1 ${1/(?:(^a)|(^b)).*/(?1:yes:no)/}\")\n    keys = \"test\" + EX + \"a some\"\n    wanted = \"a some yes\"\n\n\nclass Transformation_ConditionalInsertRWEllipsis_ECR(_VimTest):\n    snippets = (\"test\", r\"$1 ${1/(\\w+(?:\\W+\\w+){,7})\\W*(.+)?/$1(?2:...)/}\")\n    keys = \"test\" + EX + \"a b  c d e f ghhh h oha\"\n    wanted = \"a b  c d e f ghhh h oha a b  c d e f ghhh h...\"\n\n\nclass Transformation_ConditionalInConditional_ECR(_VimTest):\n    snippets = (\"test\", r\"$1 ${1/^.*?(-)?(>)?$/(?2::(?1:>:.))/}\")\n    keys = (\n        \"test\"\n        + EX\n        + \"hallo\"\n        + ESC\n        + \"$a\\n\"\n        + \"test\"\n        + EX\n        + \"hallo-\"\n        + ESC\n        + \"$a\\n\"\n        + \"test\"\n        + EX\n        + \"hallo->\"\n    )\n    wanted = \"hallo .\\nhallo- >\\nhallo-> \"\n\n\nclass Transformation_CINewlines_ECR(_VimTest):\n    snippets = (\"test\", r\"$1 ${1/, */\\n/}\")\n    keys = \"test\" + EX + \"test, hallo\"\n    wanted = \"test, hallo test\\nhallo\"\n\n\nclass Transformation_CITabstop_ECR(_VimTest):\n    snippets = (\"test\", r\"$1 ${1/, */\\t/}\")\n    keys = \"test\" + EX + \"test, hallo\"\n    wanted = \"test, hallo test\\thallo\"\n\n\nclass Transformation_CIEscapedParensinReplace_ECR(_VimTest):\n    snippets = (\"test\", r\"$1 ${1/hal((?:lo)|(?:ul))/(?1:ha\\($1\\))/}\")\n    keys = \"test\" + EX + \"test, halul\"\n    wanted = \"test, halul test, ha(ul)\"\n\n\nclass Transformation_OptionIgnoreCase_ECR(_VimTest):\n    snippets = (\"test\", r\"$1 ${1/test/blah/i}\")\n    keys = \"test\" + EX + \"TEST\"\n    wanted = \"TEST blah\"\n\n\nclass Transformation_OptionMultiline_ECR(_VimTest):\n    snippets = (\"test\", r\"${VISUAL/^/* /mg}\")\n    keys = \"test\\ntest\\ntest\" + ESC + \"V2k\" + EX + \"test\" + EX\n    wanted = \"* test\\n* test\\n* test\"\n\n\nclass Transformation_OptionReplaceGlobal_ECR(_VimTest):\n    snippets = (\"test\", r\"$1 ${1/, */-/g}\")\n    keys = \"test\" + EX + \"a, nice, building\"\n    wanted = \"a, nice, building a-nice-building\"\n\n\nclass Transformation_OptionReplaceGlobalMatchInReplace_ECR(_VimTest):\n    snippets = (\"test\", r\"$1 ${1/, */, /g}\")\n    keys = \"test\" + EX + \"a, nice,   building\"\n    wanted = \"a, nice,   building a, nice, building\"\n\n\nclass TransformationUsingBackspaceToDeleteDefaultValueInFirstTab_ECR(_VimTest):\n    snippets = (\n        \"test\",\n        \"snip ${1/.+/(?0:m1)/} ${2/.+/(?0:m2)/} \" \"${1:default} ${2:def}\",\n    )\n    keys = \"test\" + EX + BS + JF + \"hi\"\n    wanted = \"snip  m2  hi\"\n\n\nclass TransformationUsingBackspaceToDeleteDefaultValueInSecondTab_ECR(_VimTest):\n    snippets = (\n        \"test\",\n        \"snip ${1/.+/(?0:m1)/} ${2/.+/(?0:m2)/} \" \"${1:default} ${2:def}\",\n    )\n    keys = \"test\" + EX + \"hi\" + JF + BS\n    wanted = \"snip m1  hi \"\n\n\nclass TransformationUsingBackspaceToDeleteDefaultValueTypeSomethingThen_ECR(_VimTest):\n    snippets = (\"test\", \"snip ${1/.+/(?0:matched)/} ${1:default}\")\n    keys = \"test\" + EX + BS + \"hallo\"\n    wanted = \"snip matched hallo\"\n\n\nclass TransformationUsingBackspaceToDeleteDefaultValue_ECR(_VimTest):\n    snippets = (\"test\", \"snip ${1/.+/(?0:matched)/} ${1:default}\")\n    keys = \"test\" + EX + BS\n    wanted = \"snip  \"\n\n\nclass Transformation_TestKill_InsertBefore_NoKill(_VimTest):\n    snippets = \"test\", r\"$1 ${1/.*/\\L$0$0\\E/}_\"\n    keys = \"hallo test\" + EX + \"AUCH\" + ESC + \"wihi\" + ESC + \"bb\" + \"ino\" + JF + \"end\"\n    wanted = \"hallo noAUCH hinoauchnoauch_end\"\n\n\nclass Transformation_TestKill_InsertAfter_NoKill(_VimTest):\n    snippets = \"test\", r\"$1 ${1/.*/\\L$0$0\\E/}_\"\n    keys = \"hallo test\" + EX + \"AUCH\" + ESC + \"eiab\" + ESC + \"bb\" + \"ino\" + JF + \"end\"\n    wanted = \"hallo noAUCH noauchnoauchab_end\"\n\n\nclass Transformation_TestKill_InsertBeginning_Kill(_VimTest):\n    snippets = \"test\", r\"$1 ${1/.*/\\L$0$0\\E/}_\"\n    keys = \"hallo test\" + EX + \"AUCH\" + ESC + \"wahi\" + ESC + \"bb\" + \"ino\" + JF + \"end\"\n    wanted = \"hallo noAUCH ahiuchauch_end\"\n\n\nclass Transformation_TestKill_InsertEnd_Kill(_VimTest):\n    snippets = \"test\", r\"$1 ${1/.*/\\L$0$0\\E/}_\"\n    keys = \"hallo test\" + EX + \"AUCH\" + ESC + \"ehihi\" + ESC + \"bb\" + \"ino\" + JF + \"end\"\n    wanted = \"hallo noAUCH auchauchih_end\"\n\n\nclass Transformation_ConditionalWithEscapedDelimiter(_VimTest):\n    snippets = \"test\", r\"$1 ${1/(aa)|.*/(?1:yes\\:no\\))/}\"\n    keys = \"test\" + EX + \"aa\"\n    wanted = \"aa yes:no)\"\n\n\nclass Transformation_ConditionalWithBackslashBeforeDelimiter(_VimTest):\n    snippets = \"test\", r\"$1 ${1/(aa)|.*/(?1:yes\\\\:no)/}\"\n    keys = \"test\" + EX + \"aa\"\n    wanted = \"aa yes\\\\\"\n\n\nclass Transformation_ConditionalWithBackslashBeforeDelimiter1(_VimTest):\n    snippets = \"test\", r\"$1 ${1/(aa)|.*/(?1:yes:no\\\\)/}\"\n    keys = \"test\" + EX + \"ab\"\n    wanted = \"ab no\\\\\"\n"
  },
  {
    "path": "test/test_UltiSnipFunc.py",
    "content": "# encoding: utf-8\nfrom test.vim_test_case import VimTestCase as _VimTest\nfrom test.constant import *\nfrom test.util import running_on_windows\n\n\nclass _AddFuncBase(_VimTest):\n    args = \"\"\n\n    def _before_test(self):\n        self.vim.send_to_vim(\":call UltiSnips#AddSnippetWithPriority(%s)\\n\" % self.args)\n\n\nclass AddFunc_Simple(_AddFuncBase):\n    args = '\"test\", \"simple expand\", \"desc\", \"\", \"all\", 0'\n    keys = \"abc test\" + EX\n    wanted = \"abc simple expand\"\n\n\nclass AddFunc_Opt(_AddFuncBase):\n    args = '\".*test\", \"simple expand\", \"desc\", \"r\", \"all\", 0'\n    keys = \"abc test\" + EX\n    wanted = \"simple expand\"\n\n\n# Test for bug 501727 #\n\n\nclass TestNonEmptyLangmap_ExpectCorrectResult(_VimTest):\n    snippets = (\n        \"testme\",\n        \"\"\"my snipped ${1:some_default}\nand a mirror: $1\n$2...$3\n$0\"\"\",\n    )\n    keys = \"testme\" + EX + \"hi1\" + JF + \"hi2\" + JF + \"hi3\" + JF + \"hi4\"\n    wanted = \"\"\"my snipped hi1\nand a mirror: hi1\nhi2...hi3\nhi4\"\"\"\n\n    def _extra_vim_config(self, vim_config):\n        vim_config.append(\"set langmap=dj,rk,nl,ln,jd,kr,DJ,RK,NL,LN,JD,KR\")\n\n\n# Test for https://bugs.launchpad.net/bugs/501727 #\n\n\nclass TestNonEmptyLangmapWithSemi_ExpectCorrectResult(_VimTest):\n    snippets = (\n        \"testme\",\n        \"\"\"my snipped ${1:some_default}\nand a mirror: $1\n$2...$3\n$0\"\"\",\n    )\n    keys = \"testme\" + EX + \"hi;\" + JF + \"hi2\" + JF + \"hi3\" + JF + \"hi4\" + ESC + \";Hello\"\n    wanted = \"\"\"my snipped hi;\nand a mirror: hi;\nhi2...hi3\nhi4Hello\"\"\"\n\n    def _before_test(self):\n        self.vim.send_to_vim(\":set langmap=\\\\\\\\;;A\\n\")\n\n\n# Test for bug 871357 #\n\n\nclass TestLangmapWithUtf8_ExpectCorrectResult(_VimTest):\n    # SendKeys can't send UTF characters\n    skip_if = lambda self: running_on_windows()\n    snippets = (\n        \"testme\",\n        \"\"\"my snipped ${1:some_default}\nand a mirror: $1\n$2...$3\n$0\"\"\",\n    )\n    keys = \"testme\" + EX + \"hi1\" + JF + \"hi2\" + JF + \"hi3\" + JF + \"hi4\"\n    wanted = \"\"\"my snipped hi1\nand a mirror: hi1\nhi2...hi3\nhi4\"\"\"\n\n    def _before_test(self):\n        self.vim.send_to_vim(\n            \":set langmap=йq,цw,уe,кr,еt,нy,гu,шi,щo,зp,х[,ъ],фa,ыs,вd,аf,пg,рh,оj,лk,дl,ж\\\\;,э',яz,чx,сc,мv,иb,тn,ьm,ю.,ё',ЙQ,ЦW,УE,КR,ЕT,НY,ГU,ШI,ЩO,ЗP,Х\\\\{,Ъ\\\\},ФA,ЫS,ВD,АF,ПG,РH,ОJ,ЛK,ДL,Ж\\:,Э\\\",ЯZ,ЧX,СC,МV,ИB,ТN,ЬM,Б\\<,Ю\\>\\n\"\n        )\n\n\nclass VerifyVimDict1(_VimTest):\n\n    \"\"\"check:\n    correct type (4 means vim dictionary)\n    correct length of dictionary (in this case we have on element if the use same prefix, dictionary should have 1 element)\n    correct description (including the apostrophe)\n    if the prefix is mismatched no resulting dict should have 0 elements\n    \"\"\"\n\n    snippets = (\"testâ\", \"abc123ά\", \"123'êabc\")\n    keys = (\n        \"test\u0012=(type(UltiSnips#SnippetsInCurrentScope()) . len(UltiSnips#SnippetsInCurrentScope()) . \"\n        + 'UltiSnips#SnippetsInCurrentScope()[\"testâ\"]'\n        + \")\\n\"\n        + \"\u0012=len(UltiSnips#SnippetsInCurrentScope())\\n\"\n    )\n\n    wanted = \"test41123'êabc0\"\n\n\nclass VerifyVimDict2(_VimTest):\n\n    \"\"\"check:\n    can use \" in trigger\n    \"\"\"\n\n    snippets = ('te\"stâ', \"abc123ά\", \"123êabc\")\n    akey = \"'te{}stâ'\".format('\"')\n    keys = 'te\"\u0012=(UltiSnips#SnippetsInCurrentScope()[{}]'.format(akey) + \")\\n\"\n    wanted = 'te\"123êabc'\n\n\nclass VerifyVimDict3(_VimTest):\n\n    \"\"\"check:\n    can use ' in trigger\n    \"\"\"\n\n    snippets = (\"te'stâ\", \"abc123ά\", \"123êabc\")\n    akey = '\"te{}stâ\"'.format(\"'\")\n    keys = \"te'\u0012=(UltiSnips#SnippetsInCurrentScope()[{}]\".format(akey) + \")\\n\"\n    wanted = \"te'123êabc\"\n\n\nclass AddNewSnippetSource(_VimTest):\n    keys = (\n        \"blumba\"\n        + EX\n        + ESC\n        + \":py3 UltiSnips_Manager.register_snippet_source(\"\n        + \"'temp', MySnippetSource())\\n\"\n        + \"oblumba\"\n        + EX\n        + ESC\n        + \":py3 UltiSnips_Manager.unregister_snippet_source('temp')\\n\"\n        + \"oblumba\"\n        + EX\n    )\n    wanted = \"blumba\" + EX + \"\\n\" + \"this is a dynamic snippet\" + \"\\n\" + \"blumba\" + EX\n\n    def _extra_vim_config(self, vim_config):\n        self._create_file(\n            \"snippet_source.py\",\n            \"\"\"\nfrom UltiSnips.snippet.source import SnippetSource\nfrom UltiSnips.snippet.definition import UltiSnipsSnippetDefinition\n\nclass MySnippetSource(SnippetSource):\n  def get_snippets(self, filetypes, before, possible, autotrigger_only,\n                   visual_content):\n    if before.endswith('blumba') and autotrigger_only == False:\n      return [\n          UltiSnipsSnippetDefinition(\n              -100, \"blumba\", \"this is a dynamic snippet\", \"\", \"\", {}, \"blub\",\n              None, {})\n        ]\n    return []\n\"\"\",\n        )\n        vim_config.append(\"py3file %s\" % (self.name_temp(\"snippet_source.py\")))\n"
  },
  {
    "path": "test/test_Visual.py",
    "content": "from test.vim_test_case import VimTestCase as _VimTest\nfrom test.constant import *\n\n\nclass Visual_NoVisualSelection_Ignore(_VimTest):\n    snippets = (\"test\", \"h${VISUAL}b\")\n    keys = \"test\" + EX + \"abc\"\n    wanted = \"hbabc\"\n\n\nclass Visual_SelectOneWord(_VimTest):\n    snippets = (\"test\", \"h${VISUAL}b\")\n    keys = \"blablub\" + ESC + \"0v6l\" + EX + \"test\" + EX\n    wanted = \"hblablubb\"\n\n\nclass Visual_SelectOneWordInclusive(_VimTest):\n    snippets = (\"test\", \"h${VISUAL}b\", \"\", \"i\")\n    keys = \"xxxyyyyxxx\" + ESC + \"4|vlll\" + EX + \"test\" + EX\n    wanted = \"xxxhyyyybxxx\"\n\n\nclass Visual_SelectOneWordExclusive(_VimTest):\n    snippets = (\"test\", \"h${VISUAL}b\", \"\", \"i\")\n    keys = \"xxxyyyyxxx\" + ESC + \"4|vlll\" + EX + \"test\" + EX\n    wanted = \"xxxhyyybyxxx\"\n\n    def _extra_vim_config(self, vim_config):\n        vim_config.append(\"set selection=exclusive\")\n\n\nclass Visual_SelectOneWord_ProblemAfterTab(_VimTest):\n    snippets = (\"test\", \"h${VISUAL}b\", \"\", \"i\")\n    keys = \"\\tblablub\" + ESC + \"5hv3l\" + EX + \"test\" + EX\n    wanted = \"\\tbhlablbub\"\n\n\nclass VisualWithDefault_ExpandWithoutVisual(_VimTest):\n    snippets = (\"test\", \"h${VISUAL:world}b\")\n    keys = \"test\" + EX + \"hi\"\n    wanted = \"hworldbhi\"\n\n\nclass VisualWithDefaultWithSlashes_ExpandWithoutVisual(_VimTest):\n    snippets = (\"test\", r\"h${VISUAL:\\/\\/ body}b\")\n    keys = \"test\" + EX + \"hi\"\n    wanted = \"h// bodybhi\"\n\n\nclass VisualWithDefault_ExpandWithVisual(_VimTest):\n    snippets = (\"test\", \"h${VISUAL:world}b\")\n    keys = \"blablub\" + ESC + \"0v6l\" + EX + \"test\" + EX\n    wanted = \"hblablubb\"\n\n\nclass Visual_ExpandTwice(_VimTest):\n    snippets = (\"test\", \"h${VISUAL}b\")\n    keys = \"blablub\" + ESC + \"0v6l\" + EX + \"test\" + EX + \"\\ntest\" + EX\n    wanted = \"hblablubb\\nhb\"\n\n\nclass Visual_SelectOneWord_TwiceVisual(_VimTest):\n    snippets = (\"test\", \"h${VISUAL}b${VISUAL}a\")\n    keys = \"blablub\" + ESC + \"0v6l\" + EX + \"test\" + EX\n    wanted = \"hblablubbblabluba\"\n\n\nclass Visual_SelectOneWord_Inword(_VimTest):\n    snippets = (\"test\", \"h${VISUAL}b\", \"Description\", \"i\")\n    keys = \"blablub\" + ESC + \"0lv4l\" + EX + \"test\" + EX\n    wanted = \"bhlablubb\"\n\n\nclass Visual_SelectOneWord_TillEndOfLine(_VimTest):\n    snippets = (\"test\", \"h${VISUAL}b\", \"Description\", \"i\")\n    keys = \"blablub\" + ESC + \"0v$\" + EX + \"test\" + EX + ESC + \"o\"\n    wanted = \"hblablub\\nb\"\n\n\nclass Visual_SelectOneWordWithTabstop_TillEndOfLine(_VimTest):\n    snippets = (\"test\", \"h${2:ahh}${VISUAL}${1:ups}b\", \"Description\", \"i\")\n    keys = (\n        \"blablub\"\n        + ESC\n        + \"0v$\"\n        + EX\n        + \"test\"\n        + EX\n        + \"mmm\"\n        + JF\n        + \"n\"\n        + JF\n        + \"done\"\n        + ESC\n        + \"o\"\n    )\n    wanted = \"hnblablub\\nmmmbdone\"\n\n\nclass Visual_InDefaultText_SelectOneWord_NoOverwrite(_VimTest):\n    snippets = (\"test\", \"h${1:${VISUAL}}b\")\n    keys = \"blablub\" + ESC + \"0v6l\" + EX + \"test\" + EX + JF + \"hello\"\n    wanted = \"hblablubbhello\"\n\n\nclass Visual_InDefaultText_SelectOneWord(_VimTest):\n    snippets = (\"test\", \"h${1:${VISUAL}}b\")\n    keys = \"blablub\" + ESC + \"0v6l\" + EX + \"test\" + EX + \"hello\"\n    wanted = \"hhellob\"\n\n\nclass Visual_CrossOneLine(_VimTest):\n    snippets = (\"test\", \"h${VISUAL}b\")\n    keys = \"bla blub\\n  helloi\" + ESC + \"0k4lvjll\" + EX + \"test\" + EX\n    wanted = \"bla hblub\\n  hellobi\"\n\n\nclass Visual_LineSelect_Simple(_VimTest):\n    snippets = (\"test\", \"h${VISUAL}b\")\n    keys = \"hello\\nnice\\nworld\" + ESC + \"Vkk\" + EX + \"test\" + EX\n    wanted = \"hhello\\n nice\\n worldb\"\n\n\nclass Visual_InDefaultText_LineSelect_NoOverwrite(_VimTest):\n    snippets = (\"test\", \"h${1:bef${VISUAL}aft}b\")\n    keys = \"hello\\nnice\\nworld\" + ESC + \"Vkk\" + EX + \"test\" + EX + JF + \"hi\"\n    wanted = \"hbefhello\\n    nice\\n    worldaftbhi\"\n\n\nclass Visual_InDefaultText_LineSelect_Overwrite(_VimTest):\n    snippets = (\"test\", \"h${1:bef${VISUAL}aft}b\")\n    keys = \"hello\\nnice\\nworld\" + ESC + \"Vkk\" + EX + \"test\" + EX + \"jup\" + JF + \"hi\"\n    wanted = \"hjupbhi\"\n\n\nclass Visual_LineSelect_CheckIndentSimple(_VimTest):\n    snippets = (\"test\", \"beg\\n\\t${VISUAL}\\nend\")\n    keys = \"hello\\nnice\\nworld\" + ESC + \"Vkk\" + EX + \"test\" + EX\n    wanted = \"beg\\n\\thello\\n\\tnice\\n\\tworld\\nend\"\n\n\nclass Visual_LineSelect_CheckIndentTwice(_VimTest):\n    snippets = (\"test\", \"beg\\n\\t${VISUAL}\\nend\")\n    keys = \"    hello\\n    nice\\n\\tworld\" + ESC + \"Vkk\" + EX + \"test\" + EX\n    wanted = \"beg\\n\\t    hello\\n\\t    nice\\n\\t\\tworld\\nend\"\n\n\nclass Visual_InDefaultText_IndentSpacesToTabstop_NoOverwrite(_VimTest):\n    snippets = (\"test\", \"h${1:beforea${VISUAL}aft}b\")\n    keys = \"hello\\nnice\\nworld\" + ESC + \"Vkk\" + EX + \"test\" + EX + JF + \"hi\"\n    wanted = \"hbeforeahello\\n\\tnice\\n\\tworldaftbhi\"\n\n\nclass Visual_InDefaultText_IndentSpacesToTabstop_Overwrite(_VimTest):\n    snippets = (\"test\", \"h${1:beforea${VISUAL}aft}b\")\n    keys = \"hello\\nnice\\nworld\" + ESC + \"Vkk\" + EX + \"test\" + EX + \"ups\" + JF + \"hi\"\n    wanted = \"hupsbhi\"\n\n\nclass Visual_InDefaultText_IndentSpacesToTabstop_NoOverwrite1(_VimTest):\n    snippets = (\"test\", \"h${1:beforeaaa${VISUAL}aft}b\")\n    keys = \"hello\\nnice\\nworld\" + ESC + \"Vkk\" + EX + \"test\" + EX + JF + \"hi\"\n    wanted = \"hbeforeaaahello\\n\\t  nice\\n\\t  worldaftbhi\"\n\n\nclass Visual_InDefaultText_IndentBeforeTabstop_NoOverwrite(_VimTest):\n    snippets = (\"test\", \"hello\\n\\t ${1:${VISUAL}}\\nend\")\n    keys = \"hello\\nnice\\nworld\" + ESC + \"Vkk\" + EX + \"test\" + EX + JF + \"hi\"\n    wanted = \"hello\\n\\t hello\\n\\t nice\\n\\t world\\nendhi\"\n\n\nclass Visual_LineSelect_WithTabStop(_VimTest):\n    snippets = (\"test\", \"beg\\n\\t${VISUAL}\\n\\t${1:here_we_go}\\nend\")\n    keys = \"hello\\nnice\\nworld\" + ESC + \"Vkk\" + EX + \"test\" + EX + \"super\" + JF + \"done\"\n    wanted = \"beg\\n\\thello\\n\\tnice\\n\\tworld\\n\\tsuper\\nenddone\"\n\n\nclass Visual_LineSelect_CheckIndentWithTS_NoOverwrite(_VimTest):\n    snippets = (\"test\", \"beg\\n\\t${0:${VISUAL}}\\nend\")\n    keys = \"hello\\nnice\\nworld\" + ESC + \"Vkk\" + EX + \"test\" + EX\n    wanted = \"beg\\n\\thello\\n\\tnice\\n\\tworld\\nend\"\n\n\nclass Visual_LineSelect_DedentLine(_VimTest):\n    snippets = (\"if\", \"if {\\n\\t${VISUAL}$0\\n}\")\n    keys = (\n        \"if\"\n        + EX\n        + \"one\\n\\ttwo\\n\\tthree\"\n        + ESC\n        + ARR_U * 2\n        + \"V\"\n        + ARR_D\n        + EX\n        + \"\\tif\"\n        + EX\n    )\n    wanted = \"if {\\n\\tif {\\n\\t\\tone\\n\\t\\ttwo\\n\\t}\\n\\tthree\\n}\"\n\n\nclass VisualTransformation_SelectOneWord(_VimTest):\n    snippets = (\"test\", r\"h${VISUAL/./\\U$0\\E/g}b\")\n    keys = \"blablub\" + ESC + \"0v6l\" + EX + \"test\" + EX\n    wanted = \"hBLABLUBb\"\n\n\nclass VisualTransformationWithDefault_ExpandWithoutVisual(_VimTest):\n    snippets = (\"test\", r\"h${VISUAL:world/./\\U$0\\E/g}b\")\n    keys = \"test\" + EX + \"hi\"\n    wanted = \"hWORLDbhi\"\n\n\nclass VisualTransformationWithDefault_ExpandWithVisual(_VimTest):\n    snippets = (\"test\", r\"h${VISUAL:world/./\\U$0\\E/g}b\")\n    keys = \"blablub\" + ESC + \"0v6l\" + EX + \"test\" + EX\n    wanted = \"hBLABLUBb\"\n\n\nclass VisualTransformation_LineSelect_Simple(_VimTest):\n    snippets = (\"test\", r\"h${VISUAL/./\\U$0\\E/g}b\")\n    keys = \"hello\\nnice\\nworld\" + ESC + \"Vkk\" + EX + \"test\" + EX\n    wanted = \"hHELLO\\n NICE\\n WORLDb\"\n\n\nclass VisualTransformation_InDefaultText_LineSelect_NoOverwrite(_VimTest):\n    snippets = (\"test\", r\"h${1:bef${VISUAL/./\\U$0\\E/g}aft}b\")\n    keys = \"hello\\nnice\\nworld\" + ESC + \"Vkk\" + EX + \"test\" + EX + JF + \"hi\"\n    wanted = \"hbefHELLO\\n    NICE\\n    WORLDaftbhi\"\n\n\nclass VisualTransformation_InDefaultText_LineSelect_Overwrite(_VimTest):\n    snippets = (\"test\", r\"h${1:bef${VISUAL/./\\U$0\\E/g}aft}b\")\n    keys = \"hello\\nnice\\nworld\" + ESC + \"Vkk\" + EX + \"test\" + EX + \"jup\" + JF + \"hi\"\n    wanted = \"hjupbhi\"\n"
  },
  {
    "path": "test/util.py",
    "content": "import platform\n\ntry:\n    import unidecode\n\n    UNIDECODE_IMPORTED = True\nexcept ImportError:\n    UNIDECODE_IMPORTED = False\n\n\ndef running_on_windows():\n    if platform.system() == \"Windows\":\n        return \"Does not work on Windows.\"\n\n\ndef no_unidecode_available():\n    if not UNIDECODE_IMPORTED:\n        return \"unidecode is not available.\"\n"
  },
  {
    "path": "test/vim_interface.py",
    "content": "# encoding: utf-8\n\nimport os\nimport re\nimport shutil\nimport subprocess\nimport tempfile\nimport textwrap\nimport time\n\nfrom test.constant import ARR_D, ARR_L, ARR_R, ARR_U, BS, ESC, SEQUENCES\n\n\ndef wait_until_file_exists(file_path, times=None, interval=0.01):\n    while times is None or times:\n        if os.path.exists(file_path):\n            return True\n        time.sleep(interval)\n        if times is not None:\n            times -= 1\n    return False\n\n\ndef _read_text_file(filename):\n    \"\"\"Reads the content of a text file.\"\"\"\n    with open(filename, \"r\", encoding=\"utf-8\") as to_read:\n        return to_read.read()\n\n\ndef is_process_running(pid):\n    \"\"\"Returns true if a process with pid is running, false otherwise.\"\"\"\n    # from\n    # http://stackoverflow.com/questions/568271/how-to-check-if-there-exists-a-process-with-a-given-pid\n    try:\n        os.kill(pid, 0)\n    except OSError:\n        return False\n    else:\n        return True\n\n\ndef create_directory(dirname):\n    \"\"\"Creates 'dirname' and its parents if it does not exist.\"\"\"\n    try:\n        os.makedirs(dirname)\n    except OSError:\n        pass\n\n\nclass TempFileManager:\n    def __init__(self, name=\"\"):\n        self._temp_dir = tempfile.mkdtemp(prefix=\"UltiSnipsTest_\" + name)\n\n    def name_temp(self, file_path):\n        return os.path.join(self._temp_dir, file_path)\n\n    def write_temp(self, file_path, content):\n        abs_path = self.name_temp(file_path)\n        create_directory(os.path.dirname(abs_path))\n        with open(abs_path, \"w\", encoding=\"utf-8\") as f:\n            f.write(content)\n        return abs_path\n\n    def unique_name_temp(self, suffix=\"\", prefix=\"\"):\n        file_handler, abspath = tempfile.mkstemp(suffix, prefix, self._temp_dir)\n        os.close(file_handler)\n        os.remove(abspath)\n        return abspath\n\n    def clear_temp(self):\n        shutil.rmtree(self._temp_dir)\n        create_directory(self._temp_dir)\n\n\nclass VimInterface(TempFileManager):\n    def __init__(self, vim_executable, name):\n        TempFileManager.__init__(self, name)\n        self._vim_executable = vim_executable\n\n    @property\n    def vim_executable(self):\n        return self._vim_executable\n\n    def has_version(self, major, minor, patchlevel):\n        cmd = [\n            self._vim_executable, \"-e\", \"-c\",\n            \"if has('patch-%d.%d.%d') | quit | else | cquit | endif\"\n                % (major, minor, patchlevel),\n        ]\n        return not subprocess.call(cmd, stdout=subprocess.DEVNULL)\n\n    def get_buffer_data(self):\n        buffer_path = self.unique_name_temp(prefix=\"buffer_\")\n        self.send_to_vim(ESC + \":w! %s\\n\" % buffer_path)\n        if wait_until_file_exists(buffer_path, 50):\n            return _read_text_file(buffer_path)[:-1]\n\n    def send_to_terminal(self, s):\n        \"\"\"Types 's' into the terminal.\"\"\"\n        raise NotImplementedError()\n\n    def send_to_vim(self, s):\n        \"\"\"Types 's' into the vim instance under test.\"\"\"\n        raise NotImplementedError()\n\n    def launch(self, config=[]):\n        \"\"\"Returns the python version in Vim as a string, e.g. '3.7'\"\"\"\n        pid_file = self.name_temp(\"vim.pid\")\n        version_file = self.name_temp(\"vim_version\")\n        if os.path.exists(version_file):\n            os.remove(version_file)\n        done_file = self.name_temp(\"loading_done\")\n        if os.path.exists(done_file):\n            os.remove(done_file)\n\n        post_config = []\n        post_config.append(\"py3 << EOF\")\n        post_config.append(\"import vim, sys\")\n        post_config.append(\n            \"with open('%s', 'w') as pid_file: pid_file.write(vim.eval('getpid()'))\"\n            % pid_file\n        )\n        post_config.append(\"with open('%s', 'w') as version_file:\" % version_file)\n        post_config.append(\"    version_file.write('%i.%i.%i' % sys.version_info[:3])\")\n        post_config.append(\"with open('%s', 'w') as done_file:\" % done_file)\n        post_config.append(\"    done_file.write('all_done!')\")\n        post_config.append(\"EOF\")\n\n        config_path = self.write_temp(\n            \"vim_config.vim\",\n            textwrap.dedent(os.linesep.join(config + post_config) + \"\\n\"),\n        )\n\n        # Note the space to exclude it from shell history. Also we always set\n        # NVIM_LISTEN_ADDRESS, even when running vanilla Vim, because it will\n        # just not care.\n        self.send_to_terminal(\n            \"\"\" NVIM_LISTEN_ADDRESS=/tmp/nvim %s -u %s\\r\\n\"\"\"\n            % (self._vim_executable, config_path)\n        )\n        wait_until_file_exists(done_file)\n        self._vim_pid = int(_read_text_file(pid_file))\n        return _read_text_file(version_file).strip()\n\n    def leave_with_wait(self):\n        self.send_to_vim(3 * ESC + \":qa!\\n\")\n        while is_process_running(self._vim_pid):\n            time.sleep(0.01)\n\n\nclass VimInterfaceTmux(VimInterface):\n    def __init__(self, vim_executable, session):\n        VimInterface.__init__(self, vim_executable, \"Tmux\")\n        self.session = session\n        self._check_version()\n\n    def _send(self, s):\n        # I did not find any documentation on what needs escaping when sending\n        # to tmux, but it seems like this is all that is needed for now.\n        s = s.replace(\";\", r\"\\;\")\n\n        if len(s) == 1:\n            subprocess.check_call(\n                [\"tmux\", \"send-keys\", \"-t\", self.session, hex(ord(s))]\n            )\n        else:\n            subprocess.check_call([\"tmux\", \"send-keys\", \"-t\", self.session, \"-l\", s])\n\n    def send_to_terminal(self, s):\n        return self._send(s)\n\n    def send_to_vim(self, s):\n        return self._send(s)\n\n    def _check_version(self):\n        stdout, _ = subprocess.Popen(\n            [\"tmux\", \"-V\"], stdout=subprocess.PIPE, stderr=subprocess.PIPE\n        ).communicate()\n        stdout = stdout.decode(\"utf-8\")\n        m = re.match(r\"tmux (\\d+).(\\d+)\", stdout)\n        if not m or not (int(m.group(1)), int(m.group(2))) >= (1, 8):\n            raise RuntimeError(\"Need at least tmux 1.8, you have %s.\" % stdout.strip())\n\n\nclass VimInterfaceTmuxNeovim(VimInterfaceTmux):\n    def __init__(self, vim_executable, session):\n        VimInterfaceTmux.__init__(self, vim_executable, session)\n        self._nvim = None\n\n    def send_to_vim(self, s):\n        if s == ARR_L:\n            s = \"<Left>\"\n        elif s == ARR_R:\n            s = \"<Right>\"\n        elif s == ARR_U:\n            s = \"<Up>\"\n        elif s == ARR_D:\n            s = \"<Down>\"\n        elif s == BS:\n            s = \"<bs>\"\n        elif s == ESC:\n            s = \"<esc>\"\n        elif s == \"<\":\n            s = \"<lt>\"\n        self._nvim.input(s)\n\n    def launch(self, config=[]):\n        import neovim\n\n        rv = VimInterfaceTmux.launch(self, config)\n        self._nvim = neovim.attach(\"socket\", path=\"/tmp/nvim\")\n        return rv\n\n\nclass VimInterfaceWindows(VimInterface):\n    BRACES = re.compile(\"([}{])\")\n    WIN_ESCAPES = [\"+\", \"^\", \"%\", \"~\", \"[\", \"]\", \"<\", \">\", \"(\", \")\"]\n    WIN_REPLACES = [\n        (BS, \"{BS}\"),\n        (ARR_L, \"{LEFT}\"),\n        (ARR_R, \"{RIGHT}\"),\n        (ARR_U, \"{UP}\"),\n        (ARR_D, \"{DOWN}\"),\n        (\"\\t\", \"{TAB}\"),\n        (\"\\n\", \"~\"),\n        (ESC, \"{ESC}\"),\n        # On my system ` waits for a second keystroke, so `+SPACE = \"`\".  On\n        # most systems, `+Space = \"` \". I work around this, by sending the host\n        # ` as `+_+BS. Awkward, but the only way I found to get this working.\n        (\"`\", \"`_{BS}\"),\n        (\"´\", \"´_{BS}\"),\n        (\"{^}\", \"{^}_{BS}\"),\n    ]\n\n    def __init__(self):\n        # import windows specific modules\n        import win32com.client\n        import win32gui\n\n        self.win32gui = win32gui\n        self.shell = win32com.client.Dispatch(\"WScript.Shell\")\n\n    def is_focused(self, title=None):\n        cur_title = self.win32gui.GetWindowText(self.win32gui.GetForegroundWindow())\n        if (title or \"- GVIM\") in cur_title:\n            return True\n        return False\n\n    def focus(self, title=None):\n        if not self.shell.AppActivate(title or \"- GVIM\"):\n            raise Exception(\"Failed to switch to GVim window\")\n        time.sleep(1)\n\n    def convert_keys(self, keys):\n        keys = self.BRACES.sub(r\"{\\1}\", keys)\n        for k in self.WIN_ESCAPES:\n            keys = keys.replace(k, \"{%s}\" % k)\n        for f, r in self.WIN_REPLACES:\n            keys = keys.replace(f, r)\n        return keys\n\n    def send(self, keys):\n        keys = self.convert_keys(keys)\n\n        if not self.is_focused():\n            time.sleep(2)\n            self.focus()\n        if not self.is_focused():\n            # This is the only way I can find to stop test execution\n            raise KeyboardInterrupt(\"Failed to focus GVIM\")\n\n        self.shell.SendKeys(keys)\n"
  },
  {
    "path": "test/vim_test_case.py",
    "content": "# encoding: utf-8\n\n# pylint: skip-file\n\nimport os\nimport subprocess\nimport tempfile\nimport textwrap\nimport time\nimport unittest\n\nfrom test.constant import SEQUENCES, EX\nfrom test.vim_interface import create_directory, TempFileManager\n\n\ndef plugin_cache_dir():\n    \"\"\"The directory that we check out our bundles to.\"\"\"\n    return os.path.join(tempfile.gettempdir(), \"UltiSnips_test_vim_plugins\")\n\n\nclass VimTestCase(unittest.TestCase, TempFileManager):\n    snippets = ()\n    files = {}\n    text_before = \" --- some text before --- \\n\\n\"\n    text_after = \"\\n\\n --- some text after --- \"\n    expected_error = \"\"\n    wanted = \"\"\n    keys = \"\"\n    sleeptime = 0.00\n    output = \"\"\n    plugins = []\n    # Skip this test for the given reason or None for not skipping it.\n    skip_if = lambda self: None\n    version = None  # Will be set to vim --version output\n    maxDiff = None  # Show all diff output, always.\n    vim_flavor = None  # will be 'vim' or 'neovim'.\n    expected_python_version = (\n        None  # If set, we need to check that our Vim is running this python version.\n    )\n\n    def __init__(self, *args, **kwargs):\n        unittest.TestCase.__init__(self, *args, **kwargs)\n        TempFileManager.__init__(self, \"Case\")\n\n    def runTest(self):\n        if self.expected_python_version:\n            self.assertEqual(self.in_vim_python_version, self.expected_python_version)\n\n        # Only checks the output. All work is done in setUp().\n        wanted = self.text_before + self.wanted + self.text_after\n        SLEEPTIMES = [0.01, 0.15, 0.3, 0.4, 0.5, 1]\n        for i in range(self.retries):\n            if self.output and self.expected_error:\n                self.assertRegex(self.output, self.expected_error)\n                return\n            if self.output != wanted or self.output is None:\n                # Redo this, but slower\n                self.sleeptime = SLEEPTIMES[min(i, len(SLEEPTIMES) - 1)]\n                self.tearDown()\n                self.setUp()\n        self.assertMultiLineEqual(self.output, wanted)\n\n    def _extra_vim_config(self, vim_config):\n        \"\"\"Adds extra lines to the vim_config list.\"\"\"\n\n    def _before_test(self):\n        \"\"\"Send these keys before the test runs.\n\n        Used for buffer local variables and other options.\n\n        \"\"\"\n\n    def _create_file(self, file_path, content):\n        \"\"\"Creates a file in the runtimepath that is created for this test.\n\n        Returns the absolute path to the file.\n\n        \"\"\"\n        return self.write_temp(file_path, textwrap.dedent(content + \"\\n\"))\n\n    def _link_file(self, source, relative_destination):\n        \"\"\"Creates a link from 'source' to the 'relative_destination' in our\n        temp dir.\"\"\"\n        absdir = self.name_temp(relative_destination)\n        create_directory(absdir)\n        os.symlink(source, os.path.join(absdir, os.path.basename(source)))\n\n    def setUp(self):\n        if not VimTestCase.version:\n            VimTestCase.version, _ = subprocess.Popen(\n                [self.vim.vim_executable, \"--version\"],\n                stdout=subprocess.PIPE,\n                stderr=subprocess.PIPE,\n            ).communicate()\n            VimTestCase.version = VimTestCase.version.decode(\"utf-8\")\n\n        if self.plugins and not self.test_plugins:\n            return self.skipTest(\"Not testing integration with other plugins.\")\n        reason_for_skipping = self.skip_if()\n        if reason_for_skipping is not None:\n            return self.skipTest(reason_for_skipping)\n\n        vim_config = []\n        vim_config.append(\"set nocompatible\")\n        vim_config.append(\n            \"set runtimepath=$VIMRUNTIME,%s,%s\"\n            % (os.path.dirname(os.path.dirname(__file__)), self._temp_dir)\n        )\n\n        if self.plugins:\n            self._link_file(\n                os.path.join(plugin_cache_dir(), \"vim-pathogen\", \"autoload\"), \".\"\n            )\n            for plugin in self.plugins:\n                self._link_file(\n                    os.path.join(plugin_cache_dir(), os.path.basename(plugin)), \"bundle\"\n                )\n            vim_config.append(\"execute pathogen#infect()\")\n\n        # Some configurations are unnecessary for vanilla Vim, but Neovim\n        # defines some defaults differently.\n        vim_config.append(\"syntax on\")\n        vim_config.append(\"filetype plugin indent on\")\n        vim_config.append(\"set nosmarttab\")\n        vim_config.append(\"set noautoindent\")\n        vim_config.append('set backspace=\"\"')\n        vim_config.append('set clipboard=\"\"')\n        vim_config.append(\"set encoding=utf-8\")\n        vim_config.append(\"set fileencoding=utf-8\")\n        vim_config.append(\"set buftype=nofile\")\n        vim_config.append(\"set shortmess=at\")\n        vim_config.append('let @\" = \"\"')\n        assert EX == \"\\t\"  # Otherwise you need to change the next line\n        vim_config.append('let g:UltiSnipsExpandTrigger=\"<tab>\"')\n        vim_config.append('let g:UltiSnipsJumpForwardTrigger=\"?\"')\n        vim_config.append('let g:UltiSnipsJumpBackwardTrigger=\"+\"')\n        vim_config.append('let g:UltiSnipsListSnippets=\"@\"')\n\n        vim_config.append(\n            \"let g:UltiSnipsDebugServerEnable={}\".format(1 if self.pdb_enable else 0)\n        )\n        vim_config.append('let g:UltiSnipsDebugHost=\"{}\"'.format(self.pdb_host))\n        vim_config.append(\"let g:UltiSnipsDebugPort={}\".format(self.pdb_port))\n        vim_config.append(\n            \"let g:UltiSnipsPMDebugBlocking={}\".format(1 if self.pdb_block else 0)\n        )\n\n        # Work around https://github.com/vim/vim/issues/3117 for testing >\n        # py3.7 on Vim 8.1. Actually also reported against UltiSnips\n        # https://github.com/SirVer/ultisnips/issues/996\n        if \"Vi IMproved 8.1\" in self.version:\n            vim_config.append(\"silent! python3 1\")\n\n        vim_config.append('let g:UltiSnipsSnippetDirectories=[\"us\"]')\n        if self.python_host_prog:\n            vim_config.append('let g:python3_host_prog=\"%s\"' % self.python_host_prog)\n\n        self._extra_vim_config(vim_config)\n\n        # Finally, add the snippets and some configuration for the test.\n        vim_config.append(\"py3 << EOF\")\n        vim_config.append(\"from UltiSnips import UltiSnips_Manager\\n\")\n\n        if len(self.snippets) and not isinstance(self.snippets[0], tuple):\n            self.snippets = (self.snippets,)\n        for s in self.snippets:\n            sv, content = s[:2]\n            description = \"\"\n            options = \"\"\n            priority = 0\n            if len(s) > 2:\n                description = s[2]\n            if len(s) > 3:\n                options = s[3]\n            if len(s) > 4:\n                priority = s[4]\n            vim_config.append(\n                \"UltiSnips_Manager.add_snippet(%r, %r, %r, %r, priority=%i)\"\n                % (sv, content, description, options, priority)\n            )\n\n        # fill buffer with default text and place cursor in between.\n        prefilled_text = (self.text_before + self.text_after).splitlines()\n        vim_config.append(\"import vim\\n\")\n        vim_config.append(\"vim.current.buffer[:] = %r\\n\" % prefilled_text)\n        vim_config.append(\n            \"vim.current.window.cursor = (max(len(vim.current.buffer)//2, 1), 0)\"\n        )\n\n        # End of python stuff.\n        vim_config.append(\"EOF\")\n\n        for name, content in self.files.items():\n            self._create_file(name, content)\n\n        self.in_vim_python_version = self.vim.launch(vim_config)\n\n        self._before_test()\n\n        if not self.interrupt:\n            # Go into insert mode and type the keys but leave Vim some time to\n            # react.\n            text = \"i\" + self.keys\n            while text:\n                to_send = None\n                for seq in SEQUENCES:\n                    if text.startswith(seq):\n                        to_send = seq\n                        break\n                to_send = to_send or text[0]\n                self.vim.send_to_vim(to_send)\n                time.sleep(self.sleeptime)\n                text = text[len(to_send) :]\n            self.output = self.vim.get_buffer_data()\n\n    def tearDown(self):\n        if self.interrupt:\n            print(\"Working directory: %s\" % (self._temp_dir))\n            return\n        self.vim.leave_with_wait()\n        self.clear_temp()\n\n\n# vim:fileencoding=utf-8:\n"
  },
  {
    "path": "test_all.py",
    "content": "#!/usr/bin/env python3\n# encoding: utf-8\n#\n# See CONTRIBUTING.md for an explanation of this file.\n#\n# NOTE: The test suite is not working under Windows right now as I have no\n# access to a windows system for fixing it. Volunteers welcome. Here are some\n# comments from the last time I got the test suite running under windows.\n#\n# Under windows, COM's SendKeys is used to send keystrokes to the gvim window.\n# Note that Gvim must use english keyboard input (choose in windows registry)\n# for this to work properly as SendKeys is a piece of chunk. (i.e. it sends\n# <F13> when you send a | symbol while using german key mappings)\n\n# pylint: skip-file\n\nimport os\nimport platform\nimport subprocess\nimport unittest\nfrom test.vim_interface import (\n    create_directory,\n    tempfile,\n    VimInterfaceTmux,\n    VimInterfaceTmuxNeovim,\n)\n\n\ndef plugin_cache_dir():\n    \"\"\"The directory that we check out our bundles to.\"\"\"\n    return os.path.join(tempfile.gettempdir(), \"UltiSnips_test_vim_plugins\")\n\n\ndef clone_plugin(plugin):\n    \"\"\"Clone the given plugin into our plugin directory.\"\"\"\n    dirname = os.path.join(plugin_cache_dir(), os.path.basename(plugin))\n    print(\"Cloning %s -> %s\" % (plugin, dirname))\n    if os.path.exists(dirname):\n        print(\"Skip cloning of %s. Already there.\" % plugin)\n        return\n    create_directory(dirname)\n    subprocess.call(\n        [\n            \"git\",\n            \"clone\",\n            \"--recursive\",\n            \"--depth\",\n            \"1\",\n            \"https://github.com/%s\" % plugin,\n            dirname,\n        ]\n    )\n\n    if plugin == \"Valloric/YouCompleteMe\":\n        # CLUTCH: this plugin needs something extra.\n        subprocess.call(os.path.join(dirname, \"./install.sh\"), cwd=dirname)\n\n\ndef setup_other_plugins(all_plugins):\n    \"\"\"Creates /tmp/UltiSnips_test_vim_plugins and clones all plugins into\n    this.\"\"\"\n    clone_plugin(\"tpope/vim-pathogen\")\n    for plugin in all_plugins:\n        clone_plugin(plugin)\n\n\nif __name__ == \"__main__\":\n    import optparse\n    import sys\n\n    def parse_args():\n        p = optparse.OptionParser(\"%prog [OPTIONS] <test case names to run>\")\n\n        p.set_defaults(\n            session=\"vim\", interrupt=False, verbose=False, retries=4, plugins=False\n        )\n\n        p.add_option(\n            \"-v\",\n            \"--verbose\",\n            dest=\"verbose\",\n            action=\"store_true\",\n            help=\"print name of tests as they are executed\",\n        )\n        p.add_option(\n            \"--clone-plugins\",\n            action=\"store_true\",\n            help=\"Only clones dependant plugins and exits the test runner.\",\n        )\n        p.add_option(\n            \"--plugins\",\n            action=\"store_true\",\n            help=\"Run integration tests with other Vim plugins.\",\n        )\n        p.add_option(\n            \"-s\",\n            \"--session\",\n            dest=\"session\",\n            metavar=\"SESSION\",\n            help=\"session parameters for the terminal multiplexer SESSION [%default]\",\n        )\n        p.add_option(\n            \"-i\",\n            \"--interrupt\",\n            dest=\"interrupt\",\n            action=\"store_true\",\n            help=\"Stop after defining the snippet. This allows the user \"\n            \"to interactively test the snippet in vim. You must give \"\n            \"exactly one test case on the cmdline. The test will always fail.\",\n        )\n        p.add_option(\n            \"-r\",\n            \"--retries\",\n            dest=\"retries\",\n            type=int,\n            help=\"How often should each test be retried before it is \"\n            \"considered failed. Works around flakyness in the terminal \"\n            \"multiplexer and race conditions in writing to the file system.\",\n        )\n        p.add_option(\n            \"-f\",\n            \"--failfast\",\n            dest=\"failfast\",\n            action=\"store_true\",\n            help=\"Stop the test run on the first error or failure.\",\n        )\n        p.add_option(\n            \"--vim\",\n            dest=\"vim\",\n            type=str,\n            default=\"vim\",\n            help=\"executable to run when launching vim.\",\n        )\n        p.add_option(\n            \"--interface\",\n            dest=\"interface\",\n            type=str,\n            default=\"tmux\",\n            help=\"Interface to use. Use 'tmux' with vanilla Vim and 'tmux_nvim' \"\n            \"with Neovim.\",\n        )\n        p.add_option(\n            \"--python-host-prog\",\n            dest=\"python_host_prog\",\n            type=str,\n            default=\"\",\n            help=\"Neovim needs a variable to tell it which python interpretor to use for \"\n            \"py blocks. This needs to be set to point to the correct python interpretor. \"\n            \"It is ignored for vanilla Vim.\",\n        )\n        p.add_option(\n            \"--expected-python-version\",\n            dest=\"expected_python_version\",\n            type=str,\n            default=\"\",\n            help=\"If set, each test will check sys.version inside of vim to \"\n            \"verify we are testing against the expected Python version.\",\n        )\n        p.add_option(\n            \"--remote-pdb\",\n            dest=\"pdb_enable\",\n            action=\"store_true\",\n            help=\"If set, The remote pdb server will be run\",\n        )\n        p.add_option(\n            \"--remote-pdb-host\",\n            dest=\"pdb_host\",\n            type=str,\n            default=\"localhost\",\n            help=\"Remote pdb server host\",\n        )\n        p.add_option(\n            \"--remote-pdb-port\",\n            dest=\"pdb_port\",\n            type=int,\n            default=8080,\n            help=\"Remote pdb server port\",\n        )\n        p.add_option(\n            \"--remote-pdb-non-blocking\",\n            dest=\"pdb_block\",\n            action=\"store_false\",\n            help=\"If set, the server will not freeze vim on error\",\n        )\n\n        o, args = p.parse_args()\n        return o, args\n\n    def flatten_test_suite(suite):\n        flatten = unittest.TestSuite()\n        for test in suite:\n            if isinstance(test, unittest.TestSuite):\n                flatten.addTests(flatten_test_suite(test))\n            else:\n                flatten.addTest(test)\n        return flatten\n\n    def main():\n        options, selected_tests = parse_args()\n\n        all_test_suites = unittest.defaultTestLoader.discover(start_dir=\"test\")\n\n        has_nvim = subprocess.check_output(\n            [options.vim, \"-e\", \"-s\", \"-c\", \"verbose echo has('nvim')\", \"+q\"],\n            stderr=subprocess.STDOUT,\n        )\n        if has_nvim == b\"0\":\n            vim_flavor = \"vim\"\n        elif has_nvim == b\"1\":\n            vim_flavor = \"neovim\"\n        else:\n            assert 0, \"Unexpected output, has_nvim=%r\" % has_nvim\n\n        if options.interface == \"tmux\":\n            assert vim_flavor == \"vim\", (\n                \"Interface is tmux, but vim_flavor is %s\" % vim_flavor\n            )\n            vim = VimInterfaceTmux(options.vim, options.session)\n        else:\n            assert vim_flavor == \"neovim\", (\n                \"Interface is TmuxNeovim, but vim_flavor is %s\" % vim_flavor\n            )\n            vim = VimInterfaceTmuxNeovim(options.vim, options.session)\n\n        if not options.clone_plugins and platform.system() == \"Windows\":\n            raise RuntimeError(\n                \"TODO: TestSuite is broken under windows. Volunteers wanted!.\"\n            )\n            # vim = VimInterfaceWindows()\n            # vim.focus()\n\n        all_other_plugins = set()\n\n        tests = set()\n        suite = unittest.TestSuite()\n\n        for test in flatten_test_suite(all_test_suites):\n            test.interrupt = options.interrupt\n            test.retries = options.retries\n            test.test_plugins = options.plugins\n            test.python_host_prog = options.python_host_prog\n            test.expected_python_version = options.expected_python_version\n            test.vim = vim\n            test.vim_flavor = vim_flavor\n            test.pdb_enable = options.pdb_enable\n            test.pdb_host = options.pdb_host\n            test.pdb_port = options.pdb_port\n            test.pdb_block = options.pdb_block\n            all_other_plugins.update(test.plugins)\n\n            if len(selected_tests):\n                id = test.id().split(\".\")[1]\n                if not any([id.startswith(t) for t in selected_tests]):\n                    continue\n            tests.add(test)\n        suite.addTests(tests)\n\n        if options.plugins or options.clone_plugins:\n            setup_other_plugins(all_other_plugins)\n            if options.clone_plugins:\n                return\n\n        v = 2 if options.verbose else 1\n        successfull = (\n            unittest.TextTestRunner(verbosity=v, failfast=options.failfast)\n            .run(suite)\n            .wasSuccessful()\n        )\n        return 0 if successfull else 1\n\n    sys.exit(main())\n"
  }
]