pax_global_header 0000666 0000000 0000000 00000000064 12631231361 0014510 g ustar 00root root 0000000 0000000 52 comment=f95ce290bc6394d25cd51d0db2e197cd14d6d07b
ultisnips-3.1/ 0000775 0000000 0000000 00000000000 12631231361 0013405 5 ustar 00root root 0000000 0000000 ultisnips-3.1/.bzrignore 0000664 0000000 0000000 00000000023 12631231361 0015402 0 ustar 00root root 0000000 0000000 doc/tags
.bzr-repo
ultisnips-3.1/.gitignore 0000664 0000000 0000000 00000000025 12631231361 0015372 0 ustar 00root root 0000000 0000000 *.pyc
*.swp
doc/tags
ultisnips-3.1/.travis.yml 0000664 0000000 0000000 00000001560 12631231361 0015520 0 ustar 00root root 0000000 0000000 language: python
python:
- 2.7
- 3.3
- 3.4
env:
- VIM_VERSION="74"
- VIM_VERSION="mercurial"
# - VIM_VERSION="NEOVIM"
install:
# Some of these commands fail transiently. We keep retrying them until they succeed.
- until sudo add-apt-repository ppa:kalakris/tmux -y; do sleep 10; done
- until sudo add-apt-repository ppa:neovim-ppa/unstable -y; do sleep 10; done
- until sudo apt-get update -qq; do sleep 10; done
- until sudo apt-get install -qq -y --force-yes tmux xclip gdb neovim mercurial; do sleep 10; done
- ./travis_install.sh
script:
- ./travis_test.sh
notifications:
webhooks:
urls:
- https://webhooks.gitter.im/e/558acac434012ba838cd
on_success: change # options: [always|never|change] default: always
on_failure: always # options: [always|never|change] default: always
on_start: false # default: false
ultisnips-3.1/COPYING.txt 0000664 0000000 0000000 00000104513 12631231361 0015262 0 ustar 00root root 0000000 0000000 GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
Copyright (C)
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
.
ultisnips-3.1/ChangeLog 0000664 0000000 0000000 00000021650 12631231361 0015163 0 ustar 00root root 0000000 0000000 version 3.1 (07-Dec-2015):
- This is the last release done by @SirVer. The new maintainer of UltiSnips
is @seletskiy. The repository remains https://github.com/SirVer/ultisnips,
so this should not affect any users. This is also the last release to be
published on vim.org. Please follow the master branch on GitHub for the
latest stable version.
- New option `e`: Context aware snippets. This gives very precise and
powerful control over which snippet should be expanded depending on
surrounding code. *UltiSnips-context-snippets*
- New option `m`: Trim whitespace in all snippet lines.
- Very powerful, freely configurable pre/post-expand and post-jump actions
allow for transforming the buffer outside the snippet. *UltiSnips-snippet-actions*
- Automatic triggering of snippets without the need to press the expand
trigger. *UltiSnips-autotrigger*
- Better error reporting for snippet errors including python stacktraces
and listing of executed code.
- Undo is more granular. Each jump and expand is now a separate undo step.
- UltiSnips now emits autocommands on certain events. *UltiSnips-custom-autocommands*
- clearsnippets now clears all snippets below the current priority. This
fits better with the priority system introduced in 3.0.
- snipMate snippets support can be disabled. *UltiSnipsEnableSnipMate*
- UltiSnipsEditSplit got a new value 'context'. *UltiSnipsEditSplit*
- Improved syntax highlighting for snippets filetype.
- Mappings and autocommands are now only established when needed, i.e. when
a snippet is active. This boosts performance outside of snippets.
- New integration with Unite, TagBar, and deoplete.
- New Ctags configuration file for snippet definitions.
- Bug fixes, performance improvements, code cleanups and refactorings.
- No longer supports Vim < 7.4.
version 3.0 (02-Mar-2014):
- Organisational changes: The project is now hosted on github. Snippets are
now shipped separately - please track honza/vim-snippets.
- UltiSnips is now a drop in replacement for snipMate - it parses snipMate
snippets and expands them emulating snipMates smaller feature set.
- Filetype tab completion for UltiSnipsEdit.
- UltiSnipsEdit now only edits private snippet files. Use UltiSnipsEdit! if
you want to edit shipped files.
- New option 's' which strips trailing whitespace before jumping to next
tabstop
- New option 'a' which converts non-ascii characters into ascii characters
in transformations.
- New keyword in snippet files: priority defines which snippets should
overwrite others. This deprecates the '!' option.
*UltiSnips-adding-snippets*
- Remove common whitespace of visual line selections before inserting in an
indented tabstop.
- Support for overwriting the snippet directory name on a per buffer basis
to support per project snippets. *UltiSnips-snippet-search-path*
- The keymaps for jumping in snippets are now only mapped when a snippet is
active, allowing them to be used for something else otherwise.
- Expanding and jumping no longer overwrites the unnamed register.
- Integration with Valloric/YouCompleteMe and Shougo/neocomplete.vim.
- Other plugins can add sources for snippets to create snippets on the fly.
*UltiSnips-extending*
- Vim functions now indicates if it did any work.
*UltiSnips-trigger-functions*
- For python extensions: UltiSnips adds itself to the sys.path and can be
easily imported if it is available. *UltiSnips-python-module-path*
- A new function giving programmatic access to the snippets currently
available for expansion for other plugins integrating with UltiSnips.
*UltiSnips_SnippetsInCurrentScope*
- New or improved snippets (now in a different repo): all, bib, c, cpp, cs,
d, django, eruby, go, haskell, html, html, htmljinja, java, javascript,
js, ledger, ocaml, perl, php, puppet, python, ruby, scss, sh, tex, vim,
xml, zsh.
version 2.2 (01-Sep-2012):
- Support to silence Python-not-found warnings. *UltiSnips-python-warning*
- Matchit support for snippet files.
- Improvements to syntax file.
- Various smaller bug fixes.
- New command to manually add a filetype to the list for the current
buffer. *:UltiSnipsAddFiletypes*
- New or improved snippets: all, snippets, haskell, bindzone, python, golang,
json, html, coffee, coffee_jasmine, javascript_jasmine, ruby, php,
markdown.
version 2.1 (14-Feb-2012):
- Python interpolation access to text from visual selection via snip.v.
- Support for transformations of ${VISUAL} texts.
- New or improved snippets: python, tex, texmath, ruby, rails, html, django
version 2.0 (05-Feb-2012):
- Backwards incompatible change: Support for normal mode editing. Snippets
are no longer exited when leaving insert mode but only by leaving the
text span of the snippets. This allows usage of normal mode commands and
autoformatting. It also increases compatibility with other plugins.
- Backwards incompatible change: Changed glob patterns for snippets to
behave more like Vim *UltiSnips-adding-snippets*
- Backwards incompatible change: Zero Tabstop is no longer removed in
nested snippets
- Support for ${VISUAL:default text} placeholder. *UltiSnips-visual-placeholder*
- Improved handling of utf-8 characters in files and snippet definitions.
- Full support for :py3. UltiSnips now works with python >= 2.6 or >= 3.2.
- New or improved snippets: python, all
version 1.6 (30-Dec-2011):
- Significant speed improvements and a few bugs fixed.
- Better handling of non ASCII chars in snippets by assuming UTF-8 encoding
when no other information is available.
- Contributions for UltiSnips are now also accepted on GitHub: https://github.com/SirVer/ultisnips/
- New or improved snippets: ruby, rails, xhtml
version 1.5 (24-Sep-2011):
- Some critical bug fixes for new vim versions.
- New or improved snippets: tex, texmath, python, jinja2, go, puppet, xhtml
- Configuration of search path for snippets *UltiSnips-snippet-search-path*
- New parser implementation: A little faster, more flexible and less bugged.
version 1.4 (17-Jul-2011):
- New or improved snippets: php, html, djangohtml, mako, lua
- Snippets are now listed alphabetically by their trigger, no longer in
order of appearance
- Snippet files are now automatically reloaded when they change.
- Support for other directory names for snippets beside
"UltiSnips" *UltiSnips-snippet-search-path*
- Errors are now shown in a scratch window.
- Now fully supports Windows with python >= 2.6. UltiSnips should now work
on all systems that Vim runs on.
- a syntax file was added for snippets files with nice highlighting.
- snippets definition files now have the filetype 'snippets'. It used to be
'snippet'.
version 1.3 (14-Feb-2011):
- Erlang snippets (g0rdin)
- Other VimScripts can now define and immediately expand anonymous snippets
( *UltiSnips_Anon* ) (Ryan Wooden)
- Other VimScripts can now define new snippets via a function
( *UltiSnips_AddSnippet* ) (Ryan Wooden)
- New Snippets for eruby and rails (Ches Martin).
- A new Option 't' has been added to snippets that avoid expanding tabstops.
Be also more consistent with how indenting is handled. (Ryan Wooden)
- Added a ftplugin script for .snippets files. Syntax highlighting still
missing. (Rupa Deadwyler)
- Added UltiSnipsReset and UltiSnipsEdit (Idea by JCEB)
version 1.2 (24-Aug-2010):
- many bugs were fixed
- smode mappings for printable characters are now removed before expanding a
snippet. This is configurable. *UltiSnips-warning-smappings*
- all shipped snippets are now fully compatible with UltiSnips
- added support for global snippets which enhance python interpolation even
more *UltiSnips-globals*
- added support for multi word and regular expression triggers. Very
powerful in combination with python interpolation.
- Python interpolation became much more powerful *UltiSnips-python*
- added support for clearsnippets command *UltiSnips-clearing-snippets*
- added support for option w which is a little more strict than i.
- added support for listing of valid triggers. Defaults to .
- added support for option i (inword expansion)
- extends keyword is now supported on the first line of snippet files. This makes it easy to
define special cases, for example cpp extends c: a cpp trigger is useless
in c, but a c trigger is valuable for cpp.
- UltiSnips now adheres to expandtab and tabstop options of vim
version 1.1 (21-Jul-2009):
- Made triggers configurable. You can also use the same trigger for
expanding and tabbing. The TextMate configuration and is now
possible.
- Conditional Inserts can now be nested
- Added support for b option. This only considers a snippet at the beginning
of a line ( *UltiSnips-adding-snippets* )
- Added support for ! option. This overwrites previously defined snippets
with the same tab trigger ( *UltiSnips-adding-snippets* )
- Support for dotted filetype syntax. Now snippets for more than one filetype
can be active ( *UltiSnips-adding-snippets* )
ultisnips-3.1/README.md 0000664 0000000 0000000 00000006740 12631231361 0014673 0 ustar 00root root 0000000 0000000 [](https://travis-ci.org/SirVer/ultisnips)
[](https://waffle.io/SirVer/ultisnips)
[](https://gitter.im/SirVer/ultisnips?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
UltiSnips
=========
UltiSnips is the ultimate solution for snippets in Vim. It has tons of features
and is very fast.

In this demo I am editing a python file. I first expand the `#!` snippet, then
the `class` snippet. The completion menu comes from
[YouCompleteMe](https://github.com/Valloric/YouCompleteMe), UltiSnips also
integrates with [neocomplete](https://github.com/Shougo/neocomplete.vim). I can
jump through placeholders and add text while the snippet inserts text in other
places automatically: when I add `Animal` as a base class, `__init__` gets
updated to call the base class constructor. When I add arguments to the
constructor, they automatically get assigned to instance variables. I then
insert my personal snippet for `print` debugging. Note that I left insert mode,
inserted another snippet and went back to add an additional argument to
`__init__` and the class snippet was still active and added another instance
variable.
The official home of UltiSnips is at .
Please add pull requests and issues there.
UltiSnips was started in Jun 2009 by @SirVer. In Dec 2015, maintenance was
handed over to @seletskiy.
Quick Start
-----------
This assumes you are using [Vundle](https://github.com/gmarik/Vundle.vim). Adapt
for your plugin manager of choice. Put this into your `.vimrc`.
" Track the engine.
Plugin 'SirVer/ultisnips'
" Snippets are separated from the engine. Add this if you want them:
Plugin 'honza/vim-snippets'
" Trigger configuration. Do not use if you use https://github.com/Valloric/YouCompleteMe.
let g:UltiSnipsExpandTrigger=""
let g:UltiSnipsJumpForwardTrigger=""
let g:UltiSnipsJumpBackwardTrigger=""
" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsEditSplit="vertical"
UltiSnips comes with comprehensive
[documentation](https://github.com/SirVer/ultisnips/blob/master/doc/UltiSnips.txt).
As there are more options and tons of features I suggest you at least skim it.
Screencasts
-----------
From a gentle introduction to really advanced in a few minutes: The blog posts
of the screencasts contain more advanced examples of the things discussed in the
videos.
- [Episode 1: What are snippets and do I need them?](http://www.sirver.net/blog/2011/12/30/first-episode-of-ultisnips-screencast/)
- [Episode 2: Creating Basic Snippets](http://www.sirver.net/blog/2012/01/08/second-episode-of-ultisnips-screencast/)
- [Episode 3: What's new in version 2.0](http://www.sirver.net/blog/2012/02/05/third-episode-of-ultisnips-screencast/)
- [Episode 4: Python Interpolation](http://www.sirver.net/blog/2012/03/31/fourth-episode-of-ultisnips-screencast/)
Also the excellent [Vimcasts](http://vimcasts.org) dedicated three episodes to
UltiSnips:
- [Meet UltiSnips](http://vimcasts.org/episodes/meet-ultisnips/)
- [Using Python interpolation in UltiSnips snippets](http://vimcasts.org/episodes/ultisnips-python-interpolation/)
- [Using selected text in UltiSnips snippets](http://vimcasts.org/episodes/ultisnips-visual-placeholder/)
ultisnips-3.1/after/ 0000775 0000000 0000000 00000000000 12631231361 0014506 5 ustar 00root root 0000000 0000000 ultisnips-3.1/after/plugin/ 0000775 0000000 0000000 00000000000 12631231361 0016004 5 ustar 00root root 0000000 0000000 ultisnips-3.1/after/plugin/UltiSnips_after.vim 0000664 0000000 0000000 00000000352 12631231361 0021634 0 ustar 00root root 0000000 0000000 " Called after everything else to reclaim keys (Needed for Supertab)
if exists("b:did_after_plugin_ultisnips_after") || !exists("g:_uspy")
finish
endif
let b:did_after_plugin_ultisnips_after = 1
call UltiSnips#map_keys#MapKeys()
ultisnips-3.1/autoload/ 0000775 0000000 0000000 00000000000 12631231361 0015215 5 ustar 00root root 0000000 0000000 ultisnips-3.1/autoload/UltiSnips.vim 0000664 0000000 0000000 00000011306 12631231361 0017665 0 ustar 00root root 0000000 0000000 if exists("b:did_autoload_ultisnips") || !exists("g:_uspy")
" Define no-op function, called via ftdetect/UltiSnips.vim.
" TODO(sirver): Add a test for that using a bad g:UltiSnipsPythonVersion
" setting. Without this fix moving the cursor will spam errors, with this
" it should not.
function! UltiSnips#FileTypeChanged()
endfunction
finish
endif
let b:did_autoload_ultisnips = 1
" Also import vim as we expect it to be imported in many places.
exec g:_uspy "import vim"
exec g:_uspy "from UltiSnips import UltiSnips_Manager"
function! s:compensate_for_pum()
""" The CursorMovedI event is not triggered while the popup-menu is visible,
""" and it's by this event that UltiSnips updates its vim-state. The fix is
""" to explicitly check for the presence of the popup menu, and update
""" the vim-state accordingly.
if pumvisible()
exec g:_uspy "UltiSnips_Manager._cursor_moved()"
endif
endfunction
function! UltiSnips#Edit(bang, ...)
if a:0 == 1 && a:1 != ''
let type = a:1
else
let type = ""
endif
exec g:_uspy "vim.command(\"let file = '%s'\" % UltiSnips_Manager._file_to_edit(vim.eval(\"type\"), vim.eval('a:bang')))"
if !len(file)
return
endif
let mode = 'e'
if exists('g:UltiSnipsEditSplit')
if g:UltiSnipsEditSplit == 'vertical'
let mode = 'vs'
elseif g:UltiSnipsEditSplit == 'horizontal'
let mode = 'sp'
elseif g:UltiSnipsEditSplit == 'context'
let mode = 'vs'
if winwidth(0) <= 2 * (&tw ? &tw : 80)
let mode = 'sp'
endif
endif
endif
exe ':'.mode.' '.escape(file, ' ')
endfunction
function! UltiSnips#AddFiletypes(filetypes)
exec g:_uspy "UltiSnips_Manager.add_buffer_filetypes('" . a:filetypes . ".all')"
return ""
endfunction
function! UltiSnips#FileTypeComplete(arglead, cmdline, cursorpos)
let ret = {}
let items = map(
\ split(globpath(&runtimepath, 'syntax/*.vim'), '\n'),
\ 'fnamemodify(v:val, ":t:r")'
\ )
call insert(items, 'all')
for item in items
if !has_key(ret, item) && item =~ '^'.a:arglead
let ret[item] = 1
endif
endfor
return sort(keys(ret))
endfunction
function! UltiSnips#ExpandSnippet()
exec g:_uspy "UltiSnips_Manager.expand()"
return ""
endfunction
function! UltiSnips#ExpandSnippetOrJump()
call s:compensate_for_pum()
exec g:_uspy "UltiSnips_Manager.expand_or_jump()"
return ""
endfunction
function! UltiSnips#ListSnippets()
exec g:_uspy "UltiSnips_Manager.list_snippets()"
return ""
endfunction
function! UltiSnips#SnippetsInCurrentScope()
let g:current_ulti_dict = {}
exec g:_uspy "UltiSnips_Manager.snippets_in_current_scope()"
return g:current_ulti_dict
endfunction
function! UltiSnips#SaveLastVisualSelection()
exec g:_uspy "UltiSnips_Manager._save_last_visual_selection()"
return ""
endfunction
function! UltiSnips#JumpBackwards()
call s:compensate_for_pum()
exec g:_uspy "UltiSnips_Manager.jump_backwards()"
return ""
endfunction
function! UltiSnips#JumpForwards()
call s:compensate_for_pum()
exec g:_uspy "UltiSnips_Manager.jump_forwards()"
return ""
endfunction
function! UltiSnips#FileTypeChanged()
exec g:_uspy "UltiSnips_Manager.reset_buffer_filetypes()"
exec g:_uspy "UltiSnips_Manager.add_buffer_filetypes('" . &ft . "')"
return ""
endfunction
function! UltiSnips#AddSnippetWithPriority(trigger, value, description, options, filetype, priority)
exec g:_uspy "trigger = vim.eval(\"a:trigger\")"
exec g:_uspy "value = vim.eval(\"a:value\")"
exec g:_uspy "description = vim.eval(\"a:description\")"
exec g:_uspy "options = vim.eval(\"a:options\")"
exec g:_uspy "filetype = vim.eval(\"a:filetype\")"
exec g:_uspy "priority = vim.eval(\"a:priority\")"
exec g:_uspy "UltiSnips_Manager.add_snippet(trigger, value, description, options, filetype, priority)"
return ""
endfunction
function! UltiSnips#Anon(value, ...)
" Takes the same arguments as SnippetManager.expand_anon:
" (value, trigger="", description="", options="")
exec g:_uspy "args = vim.eval(\"a:000\")"
exec g:_uspy "value = vim.eval(\"a:value\")"
exec g:_uspy "UltiSnips_Manager.expand_anon(value, *args)"
return ""
endfunction
function! UltiSnips#CursorMoved()
exec g:_uspy "UltiSnips_Manager._cursor_moved()"
endf
function! UltiSnips#LeavingBuffer()
exec g:_uspy "UltiSnips_Manager._leaving_buffer()"
endf
function! UltiSnips#LeavingInsertMode()
exec g:_uspy "UltiSnips_Manager._leaving_insert_mode()"
endfunction
function! UltiSnips#TrackChange()
exec g:_uspy "UltiSnips_Manager._track_change()"
endfunction
" }}}
ultisnips-3.1/autoload/UltiSnips/ 0000775 0000000 0000000 00000000000 12631231361 0017147 5 ustar 00root root 0000000 0000000 ultisnips-3.1/autoload/UltiSnips/map_keys.vim 0000664 0000000 0000000 00000005312 12631231361 0021475 0 ustar 00root root 0000000 0000000 if exists("b:did_autoload_ultisnips_map_keys") || !exists("g:_uspy")
finish
endif
let b:did_autoload_ultisnips_map_keys = 1
" The trigger used to expand a snippet.
" NOTE: expansion and forward jumping can, but needn't be the same trigger
if !exists("g:UltiSnipsExpandTrigger")
let g:UltiSnipsExpandTrigger = ""
endif
" The trigger used to display all triggers that could possible
" match in the current position.
if !exists("g:UltiSnipsListSnippets")
let g:UltiSnipsListSnippets = ""
endif
" The trigger used to jump forward to the next placeholder.
" NOTE: expansion and forward jumping can be the same trigger.
if !exists("g:UltiSnipsJumpForwardTrigger")
let g:UltiSnipsJumpForwardTrigger = ""
endif
" The trigger to jump backward inside a snippet
if !exists("g:UltiSnipsJumpBackwardTrigger")
let g:UltiSnipsJumpBackwardTrigger = ""
endif
" Should UltiSnips unmap select mode mappings automagically?
if !exists("g:UltiSnipsRemoveSelectModeMappings")
let g:UltiSnipsRemoveSelectModeMappings = 1
end
" If UltiSnips should remove Mappings, which should be ignored
if !exists("g:UltiSnipsMappingsToIgnore")
let g:UltiSnipsMappingsToIgnore = []
endif
" UltiSnipsEdit will use this variable to decide if a new window
" is opened when editing. default is "normal", allowed are also
" "vertical", "horizontal", and "context".
if !exists("g:UltiSnipsEditSplit")
let g:UltiSnipsEditSplit = 'normal'
endif
" A list of directory names that are searched for snippets.
if !exists("g:UltiSnipsSnippetDirectories")
let g:UltiSnipsSnippetDirectories = [ "UltiSnips" ]
endif
" Enable or Disable snipmate snippet expansion.
if !exists("g:UltiSnipsEnableSnipMate")
let g:UltiSnipsEnableSnipMate = 1
endif
function! UltiSnips#map_keys#MapKeys()
if g:UltiSnipsExpandTrigger == g:UltiSnipsJumpForwardTrigger
exec "inoremap " . g:UltiSnipsExpandTrigger . " =UltiSnips#ExpandSnippetOrJump()"
exec "snoremap " . g:UltiSnipsExpandTrigger . " :call UltiSnips#ExpandSnippetOrJump()"
else
exec "inoremap " . g:UltiSnipsExpandTrigger . " =UltiSnips#ExpandSnippet()"
exec "snoremap " . g:UltiSnipsExpandTrigger . " :call UltiSnips#ExpandSnippet()"
endif
exec "xnoremap " . g:UltiSnipsExpandTrigger. " :call UltiSnips#SaveLastVisualSelection()gvs"
exec "inoremap " . g:UltiSnipsListSnippets . " =UltiSnips#ListSnippets()"
exec "snoremap " . g:UltiSnipsListSnippets . " :call UltiSnips#ListSnippets()"
snoremap c
snoremap c
snoremap c
snoremap "_c
endf
ultisnips-3.1/autoload/neocomplete/ 0000775 0000000 0000000 00000000000 12631231361 0017527 5 ustar 00root root 0000000 0000000 ultisnips-3.1/autoload/neocomplete/sources/ 0000775 0000000 0000000 00000000000 12631231361 0021212 5 ustar 00root root 0000000 0000000 ultisnips-3.1/autoload/neocomplete/sources/ultisnips.vim 0000664 0000000 0000000 00000001363 12631231361 0023764 0 ustar 00root root 0000000 0000000 let s:save_cpo = &cpo
set cpo&vim
let s:source = {
\ 'name' : 'ultisnips',
\ 'kind' : 'keyword',
\ 'mark' : '[US]',
\ 'rank' : 8,
\ 'matchers' :
\ (g:neocomplete#enable_fuzzy_completion ?
\ ['matcher_fuzzy'] : ['matcher_head']),
\ }
function! s:source.gather_candidates(context)
let suggestions = []
let snippets = UltiSnips#SnippetsInCurrentScope()
for trigger in keys(snippets)
let description = get(snippets, trigger)
call add(suggestions, {
\ 'word' : trigger,
\ 'menu' : self.mark . ' '. description
\ })
endfor
return suggestions
endfunction
function! neocomplete#sources#ultisnips#define()
return s:source
endfunction
let &cpo = s:save_cpo
unlet s:save_cpo
ultisnips-3.1/autoload/unite/ 0000775 0000000 0000000 00000000000 12631231361 0016341 5 ustar 00root root 0000000 0000000 ultisnips-3.1/autoload/unite/sources/ 0000775 0000000 0000000 00000000000 12631231361 0020024 5 ustar 00root root 0000000 0000000 ultisnips-3.1/autoload/unite/sources/ultisnips.vim 0000664 0000000 0000000 00000003622 12631231361 0022576 0 ustar 00root root 0000000 0000000 let s:save_cpo = &cpo
set cpo&vim
let s:unite_source = {
\ 'name': 'ultisnips',
\ 'hooks': {},
\ 'action_table': {},
\ 'default_action': 'expand',
\ }
let s:unite_source.action_table.preview = {
\ 'description' : 'ultisnips snippets',
\ 'is_quit' : 0,
\ }
function! s:unite_source.action_table.preview.func(candidate)
" no nice preview at this point, cannot get snippet text
let snippet_preview = a:candidate['word']
echo snippet_preview
endfunction
let s:unite_source.action_table.expand = {
\ 'description': 'expand the current snippet',
\ 'is_quit': 1
\}
function! s:unite_source.action_table.expand.func(candidate)
let delCurrWord = (getline(".")[col(".")-1] == " ") ? "" : "diw"
exe "normal " . delCurrWord . "a" . a:candidate['trigger'] . " "
call UltiSnips#ExpandSnippet()
return ''
endfunction
function! s:unite_source.get_longest_snippet_len(snippet_list)
let longest = 0
for snip in items(a:snippet_list)
if strlen(snip['word']) > longest
let longest = strlen(snip['word'])
endif
endfor
return longest
endfunction
function! s:unite_source.gather_candidates(args, context)
let default_val = {'word': '', 'unite__abbr': '', 'is_dummy': 0, 'source':
\ 'ultisnips', 'unite__is_marked': 0, 'kind': 'command', 'is_matched': 1,
\ 'is_multiline': 0}
let snippet_list = UltiSnips#SnippetsInCurrentScope()
let max_len = s:unite_source.get_longest_snippet_len(snippet_list)
let canditates = []
for snip in items(snippet_list)
let curr_val = copy(default_val)
let curr_val['word'] = printf('%-*s', max_len, snip[0]) . " " . snip[1]
let curr_val['trigger'] = snip[0]
call add(canditates, curr_val)
endfor
return canditates
endfunction
function! unite#sources#ultisnips#define()
return s:unite_source
endfunction
"unlet s:unite_source
let &cpo = s:save_cpo
unlet s:save_cpo
ultisnips-3.1/ctags/ 0000775 0000000 0000000 00000000000 12631231361 0014506 5 ustar 00root root 0000000 0000000 ultisnips-3.1/ctags/UltiSnips.cnf 0000664 0000000 0000000 00000000141 12631231361 0017124 0 ustar 00root root 0000000 0000000 --langdef=UltiSnips
--langmap=UltiSnips:.snippets
--regex-UltiSnips=/^snippet (.*)/\1/s,snippet/
ultisnips-3.1/doc/ 0000775 0000000 0000000 00000000000 12631231361 0014152 5 ustar 00root root 0000000 0000000 ultisnips-3.1/doc/UltiSnips.txt 0000664 0000000 0000000 00000216603 12631231361 0016655 0 ustar 00root root 0000000 0000000 *UltiSnips.txt* For Vim version 7.0 or later.
The Ultimate Plugin for Snippets in Vim~
UltiSnips *snippet* *snippets* *UltiSnips*
1. Description |UltiSnips-description|
1.1 Requirements |UltiSnips-requirements|
1.2 Acknowledgments |UltiSnips-acknowledgments|
2. Installation and Updating |UltiSnips-installnupdate|
3. Settings & Commands |UltiSnips-settings|
3.1 Commands |UltiSnips-commands|
3.2 Triggers |UltiSnips-triggers|
3.2.1 Using your own trigger functions |UltiSnips-trigger-functions|
3.2.2 Custom autocommands |UltiSnips-custom-autocommands|
3.2.3 Path to Python Module |UltiSnips-python-module-path|
3.3 Snippet Search Path |UltiSnips-snippet-search-path|
3.4 Warning About Select Mode Mappings |UltiSnips-warning-smappings|
3.5 Functions |UltiSnips-functions|
3.5.1 UltiSnips#AddSnippetWithPriority |UltiSnips#AddSnippetWithPriority|
3.5.2 UltiSnips#Anon |UltiSnips#Anon|
3.5.3 UltiSnips#SnippetsInCurrentScope |UltiSnips#SnippetsInCurrentScope|
3.6 Missing python support |UltiSnips-python-warning|
4. Syntax |UltiSnips-syntax|
4.1 Adding Snippets |UltiSnips-adding-snippets|
4.1.1 Character Escaping |UltiSnips-character-escaping|
4.2 Plaintext Snippets |UltiSnips-plaintext-snippets|
4.3 Visual Placeholder |UltiSnips-visual-placeholder|
4.4 Interpolation |UltiSnips-interpolation|
4.4.1 Shellcode |UltiSnips-shellcode|
4.4.2 VimScript |UltiSnips-vimscript|
4.4.3 Python |UltiSnips-python|
4.4.4 Global Snippets |UltiSnips-globals|
4.5 Tabstops and Placeholders |UltiSnips-tabstops|
4.6 Mirrors |UltiSnips-mirrors|
4.7 Transformations |UltiSnips-transformations|
4.7.1 Replacement String |UltiSnips-replacement-string|
4.7.2 Demos |UltiSnips-demos|
4.8 Clearing snippets |UltiSnips-clearing-snippets|
4.9 Context snippets |UltiSnips-context-snippets|
4.10 Snippet actions |UltiSnips-snippet-actions|
4.10.1 Pre-expand actions |UltiSnips-pre-expand-actions|
4.10.2 Post-expand actions |UltiSnips-post-expand-actions|
4.10.3 Post-jump actions |UltiSnips-post-jump-actions|
4.11 Autotrigger |UltiSnips-autotrigger|
5. UltiSnips and Other Plugins |UltiSnips-other-plugins|
5.1 Existing Integrations |UltiSnips-integrations|
5.2 Extending UltiSnips |UltiSnips-extending|
6. Helping Out |UltiSnips-helping|
7. Contributors |UltiSnips-contributors|
This plugin only works if 'compatible' is not set.
{Vi does not have any of these features}
{only available when |+python| or |+python3| have been enabled at compile time}
==============================================================================
1. Description *UltiSnips-description*
UltiSnips provides snippet management for the Vim editor. A snippet is a short
piece of text that is either re-used often or contains a lot of redundant
text. UltiSnips allows you to insert a snippet with only a few key strokes.
Snippets are common in structured text like source code but can also be used
for general editing like, for example, inserting a signature in an email or
inserting the current date in a text file.
@SirVer posted several short screencasts which make a great introduction to
UltiSnips, illustrating its features and usage.
http://www.sirver.net/blog/2011/12/30/first-episode-of-ultisnips-screencast/
http://www.sirver.net/blog/2012/01/08/second-episode-of-ultisnips-screencast/
http://www.sirver.net/blog/2012/02/05/third-episode-of-ultisnips-screencast/
http://www.sirver.net/blog/2012/03/31/fourth-episode-of-ultisnips-screencast/
Also the excellent [Vimcasts](http://vimcasts.org) dedicated three episodes to
UltiSnips:
http://vimcasts.org/episodes/meet-ultisnips/
http://vimcasts.org/episodes/ultisnips-python-interpolation/
http://vimcasts.org/episodes/ultisnips-visual-placeholder/
1.1 Requirements *UltiSnips-requirements*
----------------
This plugin works with Vim version 7.4 or later. It only works if the
'compatible' setting is not set.
This plugin is tested against Python 2.7, 3.3 or 3.4. All other versions are
unsupported, but might work.
The Python 2.x or Python 3.x interface must be available. In other words, Vim
must be compiled with either the |+python| feature or the |+python3| feature.
The following commands show how to test if you have python compiled in Vim.
They print '1' if the python version is compiled in, '0' if not.
Test if Vim is compiled with python version 2.x: >
:echo has("python")
The python version Vim is linked against can be found with: >
:py import sys; print(sys.version)
Test if Vim is compiled with python version 3.x: >
:echo has("python3")
The python version Vim is linked against can be found with: >
:py3 import sys; print(sys.version)
Note that Vim is maybe not using your system-wide installed python version, so
make sure to check the Python version inside of Vim.
UltiSnips attempts to auto-detect which python version is compiled into Vim.
Unfortunately, in some versions of Vim this detection does not work.
In that case you have to explicitly tell UltiSnips which version to use using
the 'UltiSnipsUsePythonVersion' global variable.
To use python version 2.x: >
let g:UltiSnipsUsePythonVersion = 2
To use python version 3.x: >
let g:UltiSnipsUsePythonVersion = 3
1.2 Acknowledgments *UltiSnips-acknowledgments*
-------------------
UltiSnips was inspired by the snippets feature of TextMate
(http://macromates.com/), the GUI text editor for Mac OS X. Managing snippets
in Vim is not new. I want to thank Michael Sanders, the author of snipMate,
for some implementation details I borrowed from his plugin and for the
permission to use his snippets.
=============================================================================
2. Installation and Updating *UltiSnips-installnupdate*
The recommended way of getting UltiSnips is to track SirVer/ultisnips on
github. The master branch is always stable.
Using Pathogen: *UltiSnips-using-pathogen*
If you are a pathogen user, you can track the official mirror of UltiSnips on
github: >
$ cd ~/.vim/bundle && git clone git://github.com/SirVer/ultisnips.git
If you also want the default snippets, also track >
$ cd ~/.vim/bundle && git clone git://github.com/honza/vim-snippets.git
See the pathogen documentation for more details on how to update a bundle.
Using a downloaded packet: *UltiSnips-using-a-downloaded-packet*
Download the packet and unpack into a directory of your choice. Then add this
directory to your Vim runtime path by adding this line to your vimrc file. >
set runtimepath+=~/.vim/ultisnips_rep
UltiSnips also needs that Vim sources files from the ftdetect/ directory.
Unfortunately, Vim only allows this directory in the .vim directory. You
therefore have to symlink/copy the files: >
mkdir -p ~/.vim/ftdetect/
ln -s ~/.vim/ultisnips_rep/ftdetect/* ~/.vim/ftdetect/
Restart Vim and UltiSnips should work. To access the help, use >
:helptags ~/.vim/ultisnips_rep/doc
:help UltiSnips
UltiSnips comes without snippets. The default snippets can be found here:
https://github.com/honza/vim-snippets
=============================================================================
3. Settings & Commands *UltiSnips-settings*
3.1 Commands *UltiSnips-commands*
------------
*:UltiSnipsEdit*
The UltiSnipsEdit command opens a private snippet definition file for the
current filetype. If no snippet file exists, a new file is created. If used as
UltiSnipsEdit! all public snippet files are taken into account too. If
multiple files match the search, the user gets to choose the file.
There are several variables associated with the UltiSnipsEdit command.
*g:UltiSnipsEditSplit*
g:UltiSnipsEditSplit Defines how the edit window is opened. Possible
values:
|normal| Default. Opens in the current window.
|horizontal| Splits the window horizontally.
|vertical| Splits the window vertically.
|context| Splits the window vertically or
horizontally depending on context.
*g:UltiSnipsSnippetsDir*
g:UltiSnipsSnippetsDir
Defines the directory private snippet definition
files are stored in. For example, if the variable
is set to "~/.vim/mydir/UltiSnips" and the current
'filetype' is "cpp", then :UltiSnipsEdit will open
"~/.vim/mydir/UltiSnips/cpp.snippets". Note that
directories named "snippets" are reserved for
snipMate snippets and cannot be used.
*g:UltiSnipsSnippetDirectories*
g:UltiSnipsSnippetDirectories
Defines the directories for looking for snippets.
Do not mix up this variable with previous one.
More information about that variable can
be found at section |UltiSnips-snippet-search-path|.
*g:UltiSnipsEnableSnipMate*
g:UltiSnipsEnableSnipMate
Enable looking for SnipMate snippets in
&runtimepath. UltiSnips will search only for
directories named 'snippets' while looking for
SnipMate snippets. Defaults to "1", so UltiSnips
will look for SnipMate snippets.
*:UltiSnipsAddFiletypes*
The UltiSnipsAddFiletypes command allows for explicit merging of other snippet
filetypes for the current buffer. For example, if you edit a .rst file but
also want the Lua snippets to be available you can issue the command >
:UltiSnipsAddFiletypes rst.lua
using the dotted filetype syntax. Order is important, the first filetype in
this list will be the one used for UltiSnipsEdit and the list is
ordered by evaluation priority. Consequently, you might add this to your
ftplugin/rails.vim >
:UltiSnipsAddFiletypes rails.ruby
I mention rails first because I want to edit rails snippets when using
UltiSnipsEdit and because rails snippets should overwrite equivalent ruby
snippets. The priority will now be rails -> ruby -> all. If you have some
special programming snippets that should have lower priority than your ruby
snippets you can call >
:UltiSnipsAddFiletypes ruby.programming
The priority will then be rails -> ruby -> programming -> all.
3.2 Triggers *UltiSnips-triggers*
------------
*g:UltiSnipsExpandTrigger* *g:UltiSnipsListSnippets*
*g:UltiSnipsJumpForwardTrigger* *g:UltiSnipsJumpBackwardTrigger*
You can define the keys used to trigger UltiSnips actions by setting global
variables. Variables define the keys used to expand a snippet, jump forward
and jump backwards within a snippet, and list all available snippets in the
current expand context. Be advised, that some terminal emulators don't send
to the running program. The variables with their default values are: >
g:UltiSnipsExpandTrigger
g:UltiSnipsListSnippets
g:UltiSnipsJumpForwardTrigger
g:UltiSnipsJumpBackwardTrigger
UltiSnips will only map the jump triggers while a snippet is active to
interfere as little as possible with other mappings.
The default value for g:UltiSnipsJumpBackwardTrigger interferes with the
built-in complete function: |i_CTRL-X_CTRL-K|. A workaround is to add the
following to your vimrc file or switching to a plugin like Supertab or
YouCompleteMe. >
inoremap
3.2.1 Using your own trigger functions *UltiSnips-trigger-functions*
--------------------------------------
For advanced users there are four functions that you can map directly to a
key and that correspond to some of the triggers previously defined:
g:UltiSnipsExpandTrigger <--> UltiSnips#ExpandSnippet
g:UltiSnipsJumpForwardTrigger <--> UltiSnips#JumpForwards
g:UltiSnipsJumpBackwardTrigger <--> UltiSnips#JumpBackwards
If you have g:UltiSnipsExpandTrigger and g:UltiSnipsJumpForwardTrigger set
to the same value then the function you are actually going to use is
UltiSnips#ExpandSnippetOrJump.
Each time any of the functions UltiSnips#ExpandSnippet,
UltiSnips#ExpandSnippetOrJump, UltiSnips#JumpForwards or
UltiSnips#JumpBackwards is called a global variable is set that contains the
return value of the corresponding function.
The corresponding variables and functions are:
UltiSnips#ExpandSnippet --> g:ulti_expand_res (0: fail, 1: success)
UltiSnips#ExpandSnippetOrJump --> g:ulti_expand_or_jump_res (0: fail,
1: expand, 2: jump)
UltiSnips#JumpForwards --> g:ulti_jump_forwards_res (0: fail, 1: success)
UltiSnips#JumpBackwards --> g:ulti_jump_backwards_res (0: fail, 1: success)
To see how these return values may come in handy, suppose that you want to map
a key to expand or jump, but if none of these actions is successful you want
to call another function. UltiSnips already does this automatically for
supertab, but this allows you individual fine tuning of your Tab key usage.
Usage is as follows: You define a function >
let g:ulti_expand_or_jump_res = 0 "default value, just set once
function! Ulti_ExpandOrJump_and_getRes()
call UltiSnips#ExpandSnippetOrJump()
return g:ulti_expand_or_jump_res
endfunction
then you define your mapping as >
inoremap =(Ulti_ExpandOrJump_and_getRes() > 0)?"":IMAP_Jumpfunc('', 0)
and if the you can't expand or jump from the current location then the
alternative function IMAP_Jumpfunc('', 0) is called.
3.2.2 Custom autocommands *UltiSnips-custom-autocommands*
-------------------------
Note Autocommands must *not* change the buffer in any way. If lines are added,
deleted, or modified it will confuse UltiSnips which might scramble your
snippets contents.
*UltiSnipsEnterFirstSnippet* *UltiSnipsExitLastSnippet*
For maximum compatibility with other plug-ins, UltiSnips sets up some special
state, include mappings and autocommands, when a snippet starts being
expanded, and tears them down once the last snippet has been exited. In order
to make it possible to override these "inner" settings, it fires the following
"User" autocommands:
UltiSnipsEnterFirstSnippet
UltiSnipsExitLastSnippet
For example, to call a pair of custom functions in response to these events,
you might do: >
autocmd! User UltiSnipsEnterFirstSnippet
autocmd User UltiSnipsEnterFirstSnippet call CustomInnerKeyMapper()
autocmd! User UltiSnipsExitLastSnippet
autocmd User UltiSnipsExitLastSnippet call CustomInnerKeyUnmapper()
Note that snippet expansion may be nested, in which case
|UltiSnipsEnterFirstSnippet| will fire only as the first (outermost) snippet
is entered, and |UltiSnipsExitLastSnippet| will only fire once the last
(outermost) snippet have been exited.
3.2.3 Path to Python module *UltiSnips-python-module-path*
---------------------------
For even more advanced usage, you can directly write python functions using
UltiSnip's python modules.
Here is a small example funtion that expands a snippet: >
function! s:Ulti_ExpandSnip()
Python << EOF
import sys, vim
from UltiSnips import UltiSnips_Manager
UltiSnips_Manager.expand()
EOF
return ""
endfunction
3.3 Snippet Search Path *UltiSnips-snippet-search-path*
-----------------------
UltiSnips snippet definition files are stored in one or more directories.
There are several variables used to indicate those directories and to define
how UltiSnips loads snippets.
Snippet definition files are stored in snippet directories. A snippet
directory must be a subdirectory of a directory defined in the 'runtimepath'
option. The variable g:UltiSnipsSnippetDirectories defines a list of names
used for snippet directories. Note that "snippets" is reserved for snipMate
snippets and cannot be used. The default is shown below. >
let g:UltiSnipsSnippetDirectories=["UltiSnips"]
UltiSnips will search each 'runtimepath' directory for the subdirectory names
defined in g:UltiSnipsSnippetDirectories in the order they are defined. For
example, if you keep your snippets in a .vim subdirectory called
"mycoolsnippets" and you want to make use of the default snippets that come
with UltiSnips, add the following to your vimrc file. >
let g:UltiSnipsSnippetDirectories=["UltiSnips", "mycoolsnippets"]
If you do not want to use the third party snippets that come with plugins,
define the variable accordingly: >
let g:UltiSnipsSnippetDirectories=["mycoolsnippets"]
You can also redefine the search path on a buffer by buffer basis by setting
the variable b:UltiSnipsSnippetDirectories. This variable takes precedence
over the global variable.
|UltiSnips-adding-snippets| explains which files are parsed for a given filetype.
If only one directory is specified in this variable and this directory is
specified by absolute path, UltiSnips will not look for snippets in
&runtimepath, which can lead to significant speedup. So, the common case is:
let g:UltiSnipsSnippetDirectories=[$HOME.'/.vim/UltiSnips']
However, you will not able to use snippets that are shipped with third party
plugins out of the box. You'll need to copy them into your chosen directory.
3.4 Warning About Select Mode Mappings *UltiSnips-warning-smappings*
--------------------------------------
Vim's help document for |mapmode-s| states: >
NOTE: Mapping a printable character in Select mode may confuse the user.
It's better to explicitly use :xmap and :smap for printable characters. Or
use :sunmap after defining the mapping.
However, most Vim plugins, including some default Vim plugins, do not adhere
to this. UltiSnips uses Select mode to mark tabstops in snippets for
overwriting. Existing Visual+Select mode mappings will interfere. Therefore,
UltiSnips issues a |:sunmap| command to remove each Select mode mapping for
printable characters. No other mappings are touched. In particular, UltiSnips
does not change existing normal, insert or visual mode mappings.
If this behavior is not desired, you can disable it by adding this line to
your vimrc file. >
let g:UltiSnipsRemoveSelectModeMappings = 0
If you want to disable this feature for specific mappings only, add them to
the list of mappings to be ignored. For example, the following lines in your
vimrc file will unmap all Select mode mappings except those mappings
containing either the string "somePlugin" or the string "otherPlugin" in its
complete definition as listed by the |:smap| command. >
let g:UltiSnipsRemoveSelectModeMappings = 1
let g:UltiSnipsMappingsToIgnore = [ "somePlugin", "otherPlugin" ]
3.5 Functions *UltiSnips-functions*
-------------
UltiSnips provides some functions for extending core functionality.
3.5.1 UltiSnips#AddSnippetWithPriority *UltiSnips#AddSnippetWithPriority*
The first function is UltiSnips#AddSnippetWithPriority(trigger, value, description,
options, filetyp, priority). It adds a new snippet with the provided trigger, value,
description, and options to the current list of snippets. See
|UltiSnips-syntax| for details on the meaning of the function arguments. The
Priority is a number that defines which snippet should be preferred over
others. See the priority keyword in|UltiSnips-add-snippets|.
3.5.2 UltiSnips#Anon *UltiSnips#Anon*
The second function is UltiSnips#Anon(value, ...). It expands an anonymous
snippet. Anonymous snippets are defined on the spot, expanded and immediately
discarded again. Anonymous snippets are not added to the global list of
snippets, so they cannot be expanded a second time unless the function is
called again. The function takes three optional arguments, in order: trigger,
description, options. Arguments coincide with the arguments of the
|UltiSnips#AddSnippetWithPriority| function of the same name. The trigger and
options arguments can change the way the snippet expands. The description is
unused at this point.
An example use case might be this line from a reStructuredText plugin file:
inoremap $$ $$=UltiSnips#Anon(':latex:\`$1\`', '$$')
This expands the snippet whenever two $ signs are typed.
Note: The right-hand side of the mapping starts with an immediate retype of
the '$$' trigger and passes '$$' to the function as the trigger argument.
This is required in order for UltiSnips to have access to the characters
typed so it can determine if the trigger matches or not.
3.5.3 UltiSnips#SnippetsInCurrentScope *UltiSnips#SnippetsInCurrentScope*
A third function is UltiSnips#SnippetsInCurrentScope which is the equivalent
of snipmate GetSnipsInCurrentScope function.
This function simply returns a vim dictionary with the snippets whose trigger
matches the current word.
This function does not add any new functionality to ultisnips directly but
allows to use third party plugins to integrate the current available snippets.
An example of such third party plugin is SnippetCompleteSnipMate which uses
the function GetSnipsInCurrentScope to integrate the current available
snippets with user defined abbreviations and provides these and a completion
menu.
This script is located in
http://www.vim.org/scripts/script.php?script_id=4276.
Note: If you check the above website it lists two dependencies: the
SnippetComplete plugin and snipmate.
You do need the SnippetComplete plugin but you obviously don't need snipmate,
you just have to define the function GetSnipsInCurrentScope. Put the following
in your vimrc:
function! GetSnipsInCurrentScope()
return UltiSnips#SnippetsInCurrentScope()
endfunction
As a second example on how to use this function consider the following
function and mapping definition:
function! ExpandPossibleShorterSnippet()
if len(UltiSnips#SnippetsInCurrentScope()) == 1 "only one candidate...
let curr_key = keys(UltiSnips#SnippetsInCurrentScope())[0]
normal diw
exe "normal a" . curr_key
exe "normal a "
return 1
endif
return 0
endfunction
inoremap =(ExpandPossibleShorterSnippet() == 0? '': UltiSnips#ExpandSnippet())
If the trigger for your snippet is lorem, you type lor, and you have no other
snippets whose trigger matches lor then hitting will expand to whatever
lorem expands to.
3.6 Warning about missing python support *UltiSnips-python-warning*
----------------------------------------
When UltiSnips is loaded, it will check that the running Vim was compiled with
python support. If no support is detected, a warning will be displayed and
loading of UltiSnips will be skipped.
If you would like to suppress this warning message, you may add the following
line to your vimrc file.
let g:UltiSnipsNoPythonWarning = 1
This may be useful if your Vim configuration files are shared across several
systems where some of them may not have Vim compiled with python support.
=============================================================================
4. Syntax *UltiSnips-syntax*
This chapter describes how to write your own snippets and snippet definition
syntax. Examples are used to help illustrate.
4.1 Adding Snippets *UltiSnips-adding-snippets*
-------------------
See |UltiSnips-snippet-search-path| for an explanation of where directories
with snippet definitions should be located.
Using a strategy similar to how Vim detects |ftplugins|, UltiSnips iterates
over the snippet definition directories looking for files with names of the
following patterns: ft.snippets, ft_*.snippets, or ft/*, where "ft" is the
'filetype' of the current document and "*" is a shell-like wildcard matching
any string including the empty string. The following table shows some typical
snippet filenames and their associated filetype.
snippet filename filetype ~
ruby.snippets ruby
perl.snippets perl
c.snippets c
c_my.snippets c
c/a c
c/b.snippets c
all.snippets *all
all/a.snippets *all
* The 'all' filetype is unique. It represents snippets available for use when
editing any document regardless of the filetype. A date insertion snippet, for
example, would fit well in the all.snippets file.
UltiSnips understands Vim's dotted filetype syntax. For example, if you define
a dotted filetype for the CUDA C++ framework, e.g. ":set ft=cuda.cpp", then
UltiSnips will search for and activate snippets for both the cuda and cpp
filetypes.
The snippets file syntax is simple. All lines starting with a # character are
considered comments. Comments are ignored by UltiSnips. Use them to document
snippets.
A line beginning with the keyword 'extends' provides a way of combining
snippet files. When the 'extends' directive is included in a snippet file, it
instructs UltiSnips to include all snippets from the indicated filetypes.
The syntax looks like this: >
extends ft1, ft2, ft3
For example, the first line in cpp.snippets looks like this: >
extends c
When UltiSnips activates snippets for a cpp file, it first looks for all c
snippets and activates them as well. This is a convenient way to create
specialized snippet files from more general ones. Multiple 'extends' lines are
permitted in a snippet file, and they can be included anywhere in the file.
A line beginning with the keyword 'priority' sets the priority for all
snippets defined in the current file after this line. The default priority for
a file is always 0. When a snippet should be expanded, UltiSnips will collect
all snippet definitions from all sources that match the trigger and keep only
the ones with the highest priority. For example, all shipped snippets have a
priority < 0, so that user defined snippets always overwrite shipped snippets.
A line beginning with the keyword 'snippet' marks the beginning of snippet
definition and a line starting with the keyword 'endsnippet' marks the end.
The snippet definition is placed between the lines. Here is a snippet of an
'if' statement for the Unix shell (sh) filetype.
snippet if "if ... then (if)"
if ${2:[[ ${1:condition} ]]}; then
${0:#statements}
fi
endsnippet
The start line takes the following form: >
snippet tab_trigger [ "description" [ options ] ]
The tab_trigger is required, but the description and options are optional.
The 'tab_trigger' is the word or string sequence used to trigger the snippet.
Generally a single word is used but the tab_trigger can include spaces. If you
wish to include spaces, you must wrap the tab trigger in quotes. >
snippet "tab trigger" [ "description" [ options ] ]
The quotes are not part of the trigger. To activate the snippet type: tab trigger
followed by the snippet expand character.
It is not technically necessary to use quotes to wrap a trigger with spaces.
Any matching characters will do. For example, this is a valid snippet starting
line. >
snippet !tab trigger! [ "description" [ options ] ]
Quotes can be included as part of the trigger by wrapping the trigger in
another character. >
snippet !"tab trigger"! [ "description" [ options ] ]
To activate this snippet one would type: "tab trigger"
The 'description' is a string describing the trigger. It is helpful for
documenting the snippet and for distinguishing it from other snippets with the
same tab trigger. When a snippet is activated and more than one tab trigger
match, UltiSnips displays a list of the matching snippets with their
descriptions. The user then selects the snippet they want.
The 'options' control the behavior of the snippet. Options are indicated by
single characters. The 'options' characters for a snippet are combined into
a word without spaces.
The options currently supported are: >
b Beginning of line - A snippet with this option is expanded only if the
tab trigger is the first word on the line. In other words, if only
whitespace precedes the tab trigger, expand. The default is to expand
snippets at any position regardless of the preceding non-whitespace
characters.
i In-word expansion - By default a snippet is expanded only if the tab
trigger is the first word on the line or is preceded by one or more
whitespace characters. A snippet with this option is expanded
regardless of the preceding character. In other words, the snippet can
be triggered in the middle of a word.
w Word boundary - With this option, the snippet is expanded if
the tab trigger start matches a word boundary and the tab trigger end
matches a word boundary. In other words the tab trigger must be
preceded and followed by non-word characters. Word characters are
defined by the 'iskeyword' setting. Use this option, for example, to
permit expansion where the tab trigger follows punctuation without
expanding suffixes of larger words.
r Regular expression - With this option, the tab trigger is expected to
be a python regular expression. The snippet is expanded if the recently
typed characters match the regular expression. Note: The regular
expression MUST be quoted (or surrounded with another character) like a
multi-word tab trigger (see above) whether it has spaces or not. A
resulting match is passed to any python code blocks in the snippet
definition as the local variable "match".
t Do not expand tabs - If a snippet definition includes leading tab
characters, by default UltiSnips expands the tab characters honoring
the Vim 'shiftwidth', 'softtabstop', 'expandtab' and 'tabstop'
indentation settings. (For example, if 'expandtab' is set, the tab is
replaced with spaces.) If this option is set, UltiSnips will ignore the
Vim settings and insert the tab characters as is. This option is useful
for snippets involved with tab delimited formats, for example.
s Remove whitespace immediately before the cursor at the end of a line
before jumping to the next tabstop. This is useful if there is a
tabstop with optional text at the end of a line.
m Trim all whitespaces from right side of snippet lines. Useful when
snippet contains empty lines which should remain empty after expanding.
Without this option empty lines in snippets definition will have
indentation too.
e Context snippets - With this option expansion of snippet can be
controlled not only by previous characters in line, but by any given
python expression. This option can be specified along with other
options, like 'b'. See |UltiSnips-context-snippets| for more info.
A Snippet will be triggered automatically, when condition matches.
See |UltiSnips-autotrigger| for more info.
The end line is the 'endsnippet' keyword on a line by itself. >
endsnippet
When parsing snippet files, UltiSnips chops the trailing newline character
from the 'endsnippet' end line.
4.1.1 Character Escaping: *UltiSnips-character-escaping*
In snippet definitions, the characters '`', '{', '$' and '\' have special
meaning. If you want to insert one of these characters literally, escape them
with a backslash, '\'.
4.2 Plaintext Snippets *UltiSnips-plaintext-snippets*
----------------------
To illustrate plaintext snippets, let's begin with a simple example. You can
try the examples yourself. Simply edit a new file with Vim. Example snippets
will be added to the 'all.snippets' file, so you'll want to open it in Vim for
editing as well. >
~/.vim/UltiSnips/all.snippets
Add this snippet to 'all.snippets' and save the file.
------------------- SNIP -------------------
snippet bye "My mail signature"
Good bye, Sir. Hope to talk to you soon.
- Arthur, King of Britain
endsnippet
------------------- SNAP -------------------
UltiSnips detects when you write changes to a snippets file and automatically
makes the changes active. So in the empty buffer, type the tab trigger 'bye'
and then press the key.
bye -->
Good bye, Sir. Hope to talk to you soon.
- Arthur, King of Britain
The word 'bye' will be replaced with the text of the snippet definition.
4.3 Visual Placeholder *UltiSnips-visual-placeholder*
----------------------
Snippets can contain a special placeholder called ${VISUAL}. The ${VISUAL}
variable is expanded with the text selected just prior to expanding the
snippet.
To see how a snippet with a ${VISUAL} placeholder works, define a snippet with
the placeholder, use Vim's Visual mode to select some text, and then press the
key you use to trigger expanding a snippet (see g:UltiSnipsExpandTrigger). The
selected text is deleted, and you are dropped into Insert mode. Now type the
snippet tab trigger and press the key to trigger expansion. As the snippet
expands, the previously selected text is printed in place of the ${VISUAL}
placeholder.
The ${VISUAL} placeholder can contain default text to use when the snippet has
been triggered when not in Visual mode. The syntax is: >
${VISUAL:default text}
The ${VISUAL} placeholder can also define a transformation (see
|UltiSnips-transformations|). The syntax is: >
${VISUAL:default/search/replace/option}.
Here is a simple example illustrating a visual transformation. The snippet
will take selected text, replace every instance of "should" within it with
"is" , and wrap the result in tags.
------------------- SNIP -------------------
snippet t
${VISUAL:inside text/should/is/g}
endsnippet
------------------- SNAP -------------------
Start with this line of text: >
this should be cool
Position the cursor on the word "should", then press the key sequence: viw
(visual mode -> select inner word). Then press , type "t" and press
again. The result is: >
-> this is be cool
If you expand this snippet while not in Visual mode (e.g., in Insert mode type
t), you will get: >
inside text
4.4 Interpolation *UltiSnips-interpolation*
-----------------
4.4.1 Shellcode: *UltiSnips-shellcode*
Snippets can include shellcode. Put a shell command in a snippet and when the
snippet is expanded, the shell command is replaced by the output produced when
the command is executed. The syntax for shellcode is simple: wrap the code in
backticks, '`'. When a snippet is expanded, UltiSnips runs shellcode by first
writing it to a temporary script and then executing the script. The shellcode
is replaced by the standard output. Anything you can run as a script can be
used in shellcode. Include a shebang line, for example, #!/usr/bin/perl, and
your snippet has the ability to run scripts using other programs, perl, for
example.
Here are some examples. This snippet uses a shell command to insert the
current date.
------------------- SNIP -------------------
snippet today
Today is the `date +%d.%m.%y`.
endsnippet
------------------- SNAP -------------------
today ->
Today is the 15.07.09.
This example inserts the current date using perl.
------------------- SNIP -------------------
snippet today
Today is `#!/usr/bin/perl
@a = localtime(); print $a[3] . '.' . $a[4] . '.' . ($a[5]+1900);`.
endsnippet
------------------- SNAP -------------------
today ->
Today is 15.6.2009.
4.4.2 VimScript: *UltiSnips-vimscript*
You can also use Vim scripts (sometimes called VimL) in interpolation. The
syntax is similar to shellcode. Wrap the code in backticks and to distinguish
it as a Vim script, start the code with '!v'. Here is an example that counts
the indent of the current line:
------------------- SNIP -------------------
snippet indent
Indent is: `!v indent(".")`.
endsnippet
------------------- SNAP -------------------
(note the 4 spaces in front): indent ->
(note the 4 spaces in front): Indent is: 4.
4.4.3 Python: *UltiSnips-python*
Python interpolation is by far the most powerful. The syntax is similar to Vim
scripts except code is started with '!p'. Python scripts can be run using the
python shebang '#!/usr/bin/python', but using the '!p' format comes with some
predefined objects and variables, which can simplify and shorten code. For
example, a 'snip' object instance is implied in python code. Python code using
the '!p' indicator differs in another way. Generally when a snippet is
expanded the standard output of code replaces the code. With python code the
value of the 'rv' property of the 'snip' instance replaces the code. Standard
output is ignored.
The variables automatically defined in python code are: >
fn - The current filename
path - The complete path to the current file
t - The values of the placeholders, t[1] is the text of ${1}, etc.
snip - UltiSnips.TextObjects.SnippetUtil object instance. Has methods
that simplify indentation handling.
context - Result of context condition. See |UltiSnips-context-snippets|.
The 'snip' object provides the following methods: >
snip.mkline(line="", indent=None):
Returns a line ready to be appended to the result. If indent
is None, then mkline prepends spaces and/or tabs appropriate to the
current 'tabstop' and 'expandtab' variables.
snip.shift(amount=1):
Shifts the default indentation level used by mkline right by the
number of spaces defined by 'shiftwidth', 'amount' times.
snip.unshift(amount=1):
Shifts the default indentation level used by mkline left by the
number of spaces defined by 'shiftwidth', 'amount' times.
snip.reset_indent():
Resets the indentation level to its initial value.
snip.opt(var, default):
Checks if the Vim variable 'var' has been set. If so, it returns the
variable's value; otherwise, it returns the value of 'default'.
The 'snip' object provides some properties as well: >
snip.rv:
'rv' is the return value, the text that will replace the python block
in the snippet definition. It is initialized to the empty string. This
deprecates the 'res' variable.
snip.c:
The text currently in the python block's position within the snippet.
It is set to empty string as soon as interpolation is completed. Thus
you can check if snip.c is != "" to make sure that the interpolation
is only done once. This deprecates the "cur" variable.
snip.v:
Data related to the ${VISUAL} placeholder. The property has two
attributes:
snip.v.mode ('v', 'V', '^V', see |visual-mode| )
snip.v.text The text that was selected.
snip.fn:
The current filename.
snip.basename:
The current filename with the extension removed.
snip.ft:
The current filetype.
For your convenience, the 'snip' object also provides the following
operators: >
snip >> amount:
Equivalent to snip.shift(amount)
snip << amount:
Equivalent to snip.unshift(amount)
snip += line:
Equivalent to "snip.rv += '\n' + snip.mkline(line)"
Any variables defined in a python block can be used in other python blocks
that follow within the same snippet. Also, the python modules 'vim', 're',
'os', 'string' and 'random' are pre-imported within the scope of snippet code.
Other modules can be imported using the python 'import' command.
Python code allows for very flexible snippets. For example, the following
snippet mirrors the first tabstop value on the same line but right aligned and
in uppercase.
------------------- SNIP -------------------
snippet wow
${1:Text}`!p snip.rv = (75-2*len(t[1]))*' '+t[1].upper()`
endsnippet
------------------- SNAP -------------------
wowHello World ->
Hello World HELLO WORLD
The following snippet uses the regular expression option and illustrates
regular expression grouping using python's match object. It shows that the
expansion of a snippet can depend on the tab trigger used to define the
snippet, and that tab trigger itself can vary.
------------------- SNIP -------------------
snippet "be(gin)?( (\S+))?" "begin{} / end{}" br
\begin{${1:`!p
snip.rv = match.group(3) if match.group(2) is not None else "something"`}}
${2:${VISUAL}}
\end{$1}$0
endsnippet
------------------- SNAP -------------------
becenter ->
\begin{center}
\end{center}
------------------- SNAP -------------------
be center ->
\begin{center}
\end{center}
The second form is a variation of the first; both produce the same result,
but it illustrates how regular expression grouping works. Using regular
expressions in this manner has some drawbacks:
1. If you use the key for both expanding snippets and completion then
if you typed "be form" expecting the completion "be formatted", you
would end up with the above SNAP instead, not what you want.
2. The snippet is harder to read.
4.4.4 Global Snippets: *UltiSnips-globals*
Global snippets provide a way to reuse common code in multiple snippets.
Currently, only python code is supported. The result of executing the contents
of a global snippet is put into the globals of each python block in the
snippet file. To create a global snippet, use the keyword 'global' in place of
'snippet', and for python code, you use '!p' for the trigger. For example, the
following snippet produces the same output as the last example . However, with
this syntax the 'upper_right' snippet can be reused by other snippets.
------------------- SNIP -------------------
global !p
def upper_right(inp):
return (75 - 2 * len(inp))*' ' + inp.upper()
endglobal
snippet wow
${1:Text}`!p snip.rv = upper_right(t[1])`
endsnippet
------------------- SNAP -------------------
wowHello World ->
Hello World HELLO WORLD
Python global functions can be stored in a python module and then imported.
This makes global functions easily accessible to all snippet files. Since Vim
7.4 you can just drop python files into ~/.vim/pythonx and import them
directly inside your snippets. For example to use
~/.vim/pythonx/my_snippets_helpers.py >
global !p
from my_snippet_helpers import *
endglobal
4.5 Tabstops and Placeholders *UltiSnips-tabstops* *UltiSnips-placeholders*
-----------------------------
Snippets are used to quickly insert reused text into a document. Often the
text has a fixed structure with variable components. Tabstops are used to
simplify modifying the variable content. With tabstops you can easily place
the cursor at the point of the variable content, enter the content you want,
then jump to the next variable component, enter that content, and continue
until all the variable components are complete.
The syntax for a tabstop is the dollar sign followed by a number, for example,
'$1'. Tabstops start at number 1 and are followed in sequential order. The
'$0' tabstop is a special tabstop. It is always the last tabstop in the
snippet no matter how many tabstops are defined. If there is no '$0' defined,
'$0' tabstop will be defined at the end of snippet.
Here is a simple example.
------------------- SNIP -------------------
snippet letter
Dear $1,
$0
Yours sincerely,
$2
endsnippet
------------------- SNAP -------------------
letterBenPaulThanks for suggesting UltiSnips!->
Dear Ben,
Thanks for suggesting UltiSnips!
Yours sincerely,
Paul
You can use to jump to the next tabstop, and to jump to the
previous. The key was not used for jumping forward because many people
(myself included) use for completion. See |UltiSnips-triggers| for
help on defining different keys for tabstops.
It is often useful to have some default text for a tabstop. The default text
may be a value commonly used for the variable component, or it may be a word
or phrase that reminds you what is expected for the variable component. To
include default text, the syntax is '${1:value}'.
The following example illustrates a snippet for the shell 'case' statement.
The tabstops use default values to remind the user of what value is expected.
------------------- SNIP -------------------
snippet case
case ${1:word} in
${2:pattern} ) $0;;
esac
endsnippet
------------------- SNAP -------------------
case$option-vverbose=true
case $option in
-v ) verbose=true;;
esac
Sometimes it is useful to have a tabstop within a tabstop. To do this, simply
include the nested tabstop as part of the default text. Consider the following
example illustrating an HTML anchor snippet.
------------------- SNIP -------------------
snippet a
$0
endsnippet
------------------- SNAP -------------------
When this snippet is expanded, the first tabstop has a default value of
'http://www.example.com'. If you want the 'http://' schema, jump to the next
tabstop. It has a default value of 'example.com'. This can be replaced by
typing whatever domain you want.
agoogle.comGoogle ->
Google
If at the first tabstop you want a different url schema or want to replace the
default url with a named anchor, '#name', for example, just type the value you
want.
a#topTop ->
Top
In the last example, typing any text at the first tabstop replaces the default
value, including the second tabstop, with the typed text. So the second
tabstop is essentially deleted. When a tabstop jump is triggered, UltiSnips
moves to the next remaining tabstop '$0'. This feature can be used
intentionally as a handy way for providing optional tabstop values to the
user. Here is an example to illustrate.
------------------- SNIP -------------------
snippet a
$0
endsnippet
------------------- SNAP -------------------
Here, '$1' marks the first tabstop. It is assumed you always want to add a
value for the 'href' attribute. After entering the url and pressing , the
snippet will jump to the second tabstop, '$2'. This tabstop is optional. The
default text is ' class="link"'. You can press to accept the tabstop,
and the snippet will jump to the third tabstop, '$3', and you can enter the
class attribute value, or, at the second tabstop you can press the backspace
key thereby replacing the second tabstop default with an empty string,
essentially removing it. In either case, continue by pressing and the
snippet will jump to the final tabstop inside the anchor.
ahttp://www.google.comvisitedGoogle ->
Google
ahttp://www.google.comGoogle ->
Google
The default text of tabstops can also contain mirrors, transformations or
interpolation.
4.6 Mirrors *UltiSnips-mirrors*
-----------
Mirrors repeat the content of a tabstop. During snippet expansion when you
enter the value for a tabstop, all mirrors of that tabstop are replaced with
the same value. To mirror a tabstop simply insert the tabstop again using the
"dollar sign followed by a number" syntax, e.g., '$1'.
A tabstop can be mirrored multiple times in one snippet, and more than one
tabstop can be mirrored in the same snippet. A mirrored tabstop can have a
default value defined. Only the first instance of the tabstop need have a
default value. Mirrored tabstop will take on the default value automatically.
Mirrors are handy for start-end tags, for example, TeX 'begin' and 'end' tag
labels, XML and HTML tags, and C code #ifndef blocks. Here are some snippet
examples.
------------------- SNIP -------------------
snippet env
\begin{${1:enumerate}}
$0
\end{$1}
endsnippet
------------------- SNAP -------------------
envitemize ->
\begin{itemize}
\end{itemize}
------------------- SNIP -------------------
snippet ifndef
#ifndef ${1:SOME_DEFINE}
#define $1
$0
#endif /* $1 */
endsnippet
------------------- SNAP -------------------
ifndefWIN32 ->
#ifndef WIN32
#define WIN32
#endif /* WIN32 */
4.7 Transformations *UltiSnips-transformations*
-------------------
Note: Transformations are a bit difficult to grasp so this chapter is divided
into two sections. The first describes transformations and their syntax, and
the second illustrates transformations with demos.
Transformations are like mirrors but instead of just copying text from the
original tabstop verbatim, a regular expression is matched to the content of
the referenced tabstop and a transformation is then applied to the matched
pattern. The syntax and functionality of transformations in UltiSnips follow
very closely to TextMate transformations.
A transformation has the following syntax: >
${
tab_stop_no - The number of the tabstop to reference
regular_expression - The regular expression the value of the referenced
tabstop is matched on
replacement - The replacement string, explained in detail below
options - Options for the regular expression
The options can be any combination of >
g - global replace
By default, only the first match of the regular expression is
replaced. With this option all matches are replaced.
i - case insensitive
By default, regular expression matching is case sensitive. With this
option, matching is done without regard to case.
a - ascii conversion
By default, transformation are made on the raw utf-8 string. With
this option, matching is done on the corresponding ASCII string
instead, for example 'à' will become 'a'.
This option required the python package 'unidecode'.
The syntax of regular expressions is beyond the scope of this document. Python
regular expressions are used internally, so the python 're' module can be used
as a guide. See http://docs.python.org/library/re.html.
The syntax for the replacement string is unique. The next paragraph describes
it in detail.
4.7.1 Replacement String: *UltiSnips-replacement-string*
The replacement string can contain $no variables, e.g., $1, which reference
matched groups in the regular expression. The $0 variable is special and
yields the whole match. The replacement string can also contain special escape
sequences: >
\u - Uppercase next letter
\l - Lowercase next letter
\U - Uppercase everything till the next \E
\L - Lowercase everything till the next \E
\E - End upper or lowercase started with \L or \U
\n - A newline
\t - A literal tab
Finally, the replacement string can contain conditional replacements using the
syntax (?no:text:other text). This reads as follows: if the group $no has
matched, insert "text", otherwise insert "other text". "other text" is
optional and if not provided defaults to the empty string, "". This feature
is very powerful. It allows you to add optional text into snippets.
4.7.2 Demos: *UltiSnips-demos*
Transformations are very powerful but often the syntax is convoluted.
Hopefully the demos below help illustrate transformation features.
Demo: Uppercase one character
------------------- SNIP -------------------
snippet title "Title transformation"
${1:a text}
${1/\w+\s*/\u$0/}
endsnippet
------------------- SNAP -------------------
titlebig small ->
big small
Big small
Demo: Uppercase one character and global replace
------------------- SNIP -------------------
snippet title "Titlelize in the Transformation"
${1:a text}
${1/\w+\s*/\u$0/g}
endsnippet
------------------- SNAP -------------------
titlethis is a title ->
this is a title
This Is A Title
Demo: ASCII transformation
------------------- SNIP -------------------
snippet ascii "Replace non ascii chars"
${1: an accentued text}
${1/.*/$0/a}
endsnippet
------------------- SNAP -------------------
asciià la pêche aux moules
à la pêche aux moules
a la peche aux moules
Demo: Regular expression grouping
This is a clever c-like printf snippet, the second tabstop is only shown
when there is a format (%) character in the first tabstop.
------------------- SNIP -------------------
snippet printf
printf("${1:%s}\n"${1/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$2${1/([^%]|%%)*(%.)?.*/(?2:\);)/}
endsnippet
------------------- SNAP -------------------
printfHello // End of line ->
printf("Hello\n"); // End of line
But
printfA is: %sA // End of line ->
printf("A is: %s\n", A); // End of line
There are many more examples of what can be done with transformations in the
bundled snippets.
4.8 Clearing snippets *UltiSnips-clearing-snippets*
To remove snippets for the current file type, use the 'clearsnippets'
directive.
------------------- SNIP -------------------
clearsnippets
------------------- SNAP -------------------
'clearsnippets' removes all snippets with a priority lower than the current
one. For example, the following cleares all snippets that have priority <= 1,
even though the example snippet is defined after the 'clearsnippets'.
------------------- SNIP -------------------
priority 1
clearsnippets
priority -1
snippet example "Cleared example"
This will never be expanded.
endsnippet
------------------- SNAP -------------------
To clear one or more specific snippet, provide the triggers of the snippets as
arguments to the 'clearsnippets' command. The following example will clear the
snippets 'trigger1' and 'trigger2'.
------------------- SNIP -------------------
clearsnippets trigger1 trigger2
------------------- SNAP -------------------
4.9 Context snippets *UltiSnips-context-snippets*
Context snippets can be enabled by using 'e' option in snippet definition.
In that case snippet should be defined using this syntax: >
snippet tab_trigger "description" "expression" options
The 'expression' can be any python expression. If 'expression' evaluates to
'True', then this snippet will be chosen for expansion. The 'expression' must
be wrapped with double-quotes.
The following python modules are automatically imported into the scope before
'expression' is evaluated: 're', 'os', 'vim', 'string', 'random'.
Global variable `snip` will be available with following properties:
'snip.window' - alias for 'vim.current.window'
'snip.buffer' - alias for 'vim.current.window.buffer'
'snip.cursor' - cursor object, which behaves like
'vim.current.window.cursor', but zero-indexed and with following
additional methods:
- 'preserve()' - special method for executing pre/post/jump actions;
- 'set(line, column)' - sets cursor to specified line and column;
- 'to_vim_cursor()' - returns 1-indexed cursor, suitable for assigning
to 'vim.current.window.cursor';
'snip.line' and 'snip.column' - aliases for cursor position (zero-indexed);
------------------- SNIP -------------------
snippet r "return" "re.match('^\s+if err ', snip.buffer[snip.line-1])" be
return err
endsnippet
------------------- SNAP -------------------
That snippet will expand to 'return err' only if the previous line is starting
from 'if err' prefix.
Note: context snippets prioritized over non-context ones. It makes possible to
use non-context snippets as fallback, if no context matched:
------------------- SNIP -------------------
snippet i "if ..." b
if $1 {
$2
}
endsnippet
snippet i "if err != nil" "re.match('^\s+[^=]*err\s*:?=', snip.buffer[snip.line-1])" be
if err != nil {
$1
}
endsnippet
------------------- SNAP -------------------
That snippet will expand into 'if err != nil' if previous line will
match 'err :=' prefix, otherwise the default 'if' snippet will be expanded.
It's a good idea to move context conditions to a separate module, so it can be
used by other UltiSnips users. In that case, module should be imported
using 'global' keyword, like this:
------------------- SNIP -------------------
global !p
import my_utils
endglobal
snippet , "return ..., nil/err" "my_utils.is_return_argument(snip)" ie
, `!p if my_utils.is_in_err_condition():
snip.rv = "err"
else:
snip.rv = "nil"`
endsnippet
------------------- SNAP -------------------
That snippet will expand only if the cursor is located in the return statement,
and then it will expand either to 'err' or to 'nil' depending on which 'if'
statement it's located. 'is_return_argument' and 'is_in_err_condition' are
part of custom python module which is called 'my_utils' in this example.
Context condition can return any value which python can use as condition in
it's 'if' statement, and if it's considered 'True', then snippet will be
expanded. The evaluated value of 'condition' is available in the 'snip.context'
variable inside the snippet:
------------------- SNIP -------------------
snippet + "var +=" "re.match('\s*(.*?)\s*:?=', snip.buffer[snip.line-1])" ie
`!p snip.rv = snip.context.group(1)` += $1
endsnippet
------------------- SNAP -------------------
That snippet will expand to 'var1 +=' after line, which begins from 'var1 :='.
4.10 Snippets actions *UltiSnips-snippet-actions*
---------------------
Snippet actions is an arbitrary python code which can be executed at specific
points in lifetime of the snippet.
There are three types of actions:
* Pre-expand - invoked just after trigger condition was matched, but before
snippet actually expanded;
* Post-expand - invoked after snippet was expanded and interpolations
was applied for the first time, but before jump on the first placeholder.
* Jump - invoked just after jump to the next/prev placeholder.
Specified code will be evaluated at stages defined above and same global
variables and modules will be available that are stated in
the |UltiSnips-context-snippets| section.
*UltiSnips-buffer-proxy*
Note: special variable called 'snip.buffer' should be used for all buffer
modifications. Not 'vim.current.buffer' and not 'vim.command("...")', because
of in that case UltiSnips will not be able to track changes buffer from
actions.
'snip.buffer' has the same interface as 'vim.current.window.buffer'.
4.10.1 Pre-expand actions *UltiSnips-pre-expand-actions*
Pre-expand actions can be used to match snippet in one location and then
expand it in the different location. Some useful cases are: correcting
indentation for snippet; expanding snippet for function declaration in another
function body with moving expansion point beyond initial function; performing
extract method refactoring via expanding snippet in different place.
Pre-expand action declared as follows: >
pre_expand "python code here"
snippet ...
endsnippet
Buffer can be modified in pre-expand action code through variable called
'snip.buffer', snippet expansion position will be automatically adjusted.
If cursor line (where trigger was matched) need to be modified, then special
variable method 'snip.cursor.set(line, column)' must be called with the
desired cursor position. In that case UltiSnips will not remove any matched
trigger text and it should be done manually in action code.
To addition to the scope variables defined above 'snip.visual_content' will be
also declared and will contain text that was selected before snippet expansion
(similar to $VISUAL placeholder).
Following snippet will be expanded at 4 spaces indentation level no matter
where it was triggered.
------------------- SNIP -------------------
pre_expand "snip.buffer[snip.line] = ' '*4; snip.cursor.set(line, 4)"
snippet d
def $1():
$0
endsnippet
------------------- SNAP -------------------
Following snippet will move the selected code to the end of file and create
new method definition for it:
------------------- SNIP -------------------
pre_expand "del snip.buffer[snip.line]; snip.buffer.append(''); snip.cursor.set(len(snip.buffer)-1, 0)"
snippet x
def $1():
${2:${VISUAL}}
endsnippet
------------------- SNAP -------------------
4.10.2 Post-expand actions *UltiSnips-post-expand-actions*
Post-expand actions can be used to perform some actions based on the expanded
snippet text. Some cases are: code style formatting (e.g. inserting newlines
before and after method declaration), apply actions depending on python
interpolation result.
Post-expand action declared as follows: >
post_expand "python code here"
snippet ...
endsnippet
Buffer can be modified in post-expand action code through variable called
'snip.buffer', snippet expansion position will be automatically adjusted.
Variables 'snip.snippet_start' and 'snip.snippet_end' will be defined at the
action code scope and will point to positions of the start and end of expanded
snippet accordingly in the form '(line, column)'.
Note: 'snip.snippet_start' and 'snip.snippet_end' will automatically adjust to
the correct positions if post-action will insert or delete lines before
expansion.
Following snippet will expand to method definition and automatically insert
additional newline after end of the snippet. It's very useful to create a
function that will insert as many newlines as required in specific context.
------------------- SNIP -------------------
post_expand "snip.buffer[snip.snippet_end[0]+1:snip.snippet_end[0]+1] = ['']"
snippet d "Description" b
def $1():
$2
endsnippet
------------------- SNAP -------------------
4.10.3 Post-jump actions *UltiSnips-post-jump-actions*
Post-jump actions can be used to trigger some code based on user input into
the placeholders. Notable use cases: expand another snippet after jump or
anonymous snippet after last jump (e.g. perform move method refactoring and
then insert new method invokation); insert heading into TOC after last jump.
Jump-expand action declared as follows: >
post_jump "python code here"
snippet ...
endsnippet
Buffer can be modified in post-expand action code through variable called
'snip.buffer', snippet expansion position will be automatically adjusted.
Next variables and methods will be also defined in the action code scope:
* 'snip.tabstop' - number of tabstop jumped onto;
* 'snip.jump_direction' - '1' if jumped forward and '-1' otherwise;
* 'snip.tabstops' - list with tabstop objects, see above;
* 'snip.snippet_start' - (line, column) of start of the expanded snippet;
* 'snip.snippet_end' - (line, column) of end of the expanded snippet;
* 'snip.expand_anon()' - alias for 'UltiSnips_Manager.expand_anon()';
Tabstop object has several useful properties:
* 'start' - (line, column) of the starting position of the tabstop (also
accessible as 'tabstop.line' and 'tabstop.col').
* 'end' - (line, column) of the ending position;
* 'current_text' - text inside the tabstop.
Following snippet will insert section in the Table of Contents in the vim-help
file:
------------------- SNIP -------------------
post_jump "if snip.tabstop == 0: insert_toc_item(snip.tabstops[1], snip.buffer)"
snippet s "section" b
`!p insert_delimiter_0(snip, t)`$1`!p insert_section_title(snip, t)`
`!p insert_delimiter_1(snip, t)`
$0
endsnippet
------------------- SNAP -------------------
'insert_toc_item' will be called after first jump and will add newly entered
section into the TOC for current file.
Note: It is also possible to trigger snippet expansion from the jump action.
In that case method 'snip.cursor.preserve()' should be called, so UltiSnips
will know that cursor is already at the required position.
Following example will insert method call at the end of file after user jump
out of method declaration snippet.
------------------- SNIP -------------------
global !p
def insert_method_call(name):
vim.command('normal G')
snip.expand_anon(name + '($1)\n')
endglobal
post_jump "if snip.tabstop == 0: insert_method_call(snip.tabstops[1].current_text)"
snippet d "method declaration" b
def $1():
$2
endsnippet
------------------- SNAP -------------------
4.11 Autotrigger *UltiSnips-autotrigger*
----------------
Note: vim should be newer than 7.4.214 to support this feature.
Many language constructs can occur only at specific places, so it's
possible to use snippets without manually triggering them.
Snippet can be marked as autotriggered by specifying 'A' option in the snippet
definition.
After snippet is defined as being autotriggered, snippet condition will be
checked on every typed character and if condition matches, then snippet will
be triggered.
*Warning:* using of this feature can lead to significant vim slowdown. If you
discovered that, report an issue to the github.com/SirVer/UltiSnips.
Consider following snippets, that can be usefull in Go programming:
------------------- SNIP -------------------
snippet "^p" "package" rbA
package ${1:main}
endsnippet
snippet "^m" "func main" rbA
func main() {
$1
}
endsnippet
------------------- SNAP -------------------
When "p" character will occur in the beginning of the line, it will be
automatically expanded into "package main". Same with "m" character. There is
no need to press trigger key after "m""
==============================================================================
5. UltiSnips and Other Plugins *UltiSnips-other-plugins*
5.1 Existing Integrations *UltiSnips-integrations*
-------------------------
UltiSnips has built-in support for some common plugins and there are others
that are aware of UltiSnips and use it to improve the user experience. This is
an incomplete list - if you want to have your plugin listed here, just send a
pull request.
*UltiSnips-snipMate*
snipMate - UltiSnips is a drop-in replacement for snipMate. It has many more
features, so porting snippets is still a good idea, but switching has low
friction now. UltiSnips is trying hard to truly emulate snipMate, for example
recursive tabstops are not supported in snipMate snippets (but of course in
UltiSnips snippets).
YouCompleteMe - comes with out of the box completion support for UltiSnips. It
offers a really nice completion dialogue for snippets.
neocomplete - UltiSnips ships with a source for neocomplete and therefore
offers out of the box completion dialogue support for it too.
unite - UltiSnips has a source for unite. As an example of how you can use
it add the following function and mappings to your vimrc: >
function! UltiSnipsCallUnite()
Unite -start-insert -winheight=100 -immediately -no-empty ultisnips
return ''
endfunction
inoremap =(pumvisible()? "\C-E>":"")=UltiSnipsCallUnite()
nnoremap a=(pumvisible()? "\C-E>":"")=UltiSnipsCallUnite()
When typing in either insert or normal mode you will get the unite
interface with matching snippets. Pressing enter will expand the corresponding
snippet. If only one snippet matches the text in front of the cursor will be
expanded when you press the key.
Supertab - UltiSnips has built-in support for Supertab. Just use a recent
enough version of both plugins and will either expand a snippet or defer
to Supertab for expansion.
5.2 Extending UltiSnips *UltiSnips-extending*
-------------------------
UltiSnips allows other plugins to add new snippets on the fly. Since UltiSnips
is written in python, the integration is also on a python basis. A small
example can be found in `test.py`, search for AddNewSnippetSource. Please
contact us on github if you integrate UltiSnips with your plugin so it can be
listed in the docs.
=============================================================================
6. Helping Out *UltiSnips-helping*
UltiSnips needs the help of the Vim community to keep improving. Please
consider joining this effort by providing new features or bug reports.
* Clone the repository on GitHub (git clone git@github.com:SirVer/ultisnips.git),
make your changes and send a pull request on GitHub.
* Make a patch, report a bug/feature request (see below) and attach the patch
to it.
You can contribute by fixing or reporting bugs in our issue tracker:
https://github.com/sirver/ultisnips/issues
=============================================================================
7. Contributors *UltiSnips-contributors*
UltiSnips has been started and maintained from Jun 2009 - Dec 2015 by Holger
Rapp (@SirVer, SirVer@gmx.de). It is now maintained by Stanislav Seletskiy
(@seletskiy).
This is the list of contributors pre-git in chronological order. For a full
list of contributors take the union of this set and the authors according to
git log.
JCEB - Jan Christoph Ebersbach
Michael Henry
Chris Chambers
Ryan Wooden
rupa - Rupa Deadwyler
Timo Schmiade
blueyed - Daniel Hahler
expelledboy - Anthony Jackson
allait - Alexey Bezhan
peacech - Charles Gunawan
guns - Sung Pae
shlomif - Shlomi Fish
pberndt - Phillip Berndt
thanatermesis-elive - Thanatermesis
rico-ambiescent - Rico Sta. Cruz
Cody Frazer
suy - Alejandro Exojo
grota - Giuseppe Rota
iiijjjii - Jim Karsten
fgalassi - Federico Galassi
lucapette
Psycojoker - Laurent Peuch
aschrab - Aaron Schrab
stardiviner - NagatoPain
skeept - Jorge Rodrigues
buztard
stephenmckinney - Steve McKinney
Pedro Algarvio - s0undt3ch
Eric Van Dewoestine - ervandew
Matt Patterson - fidothe
Mike Morearty - mmorearty
Stanislav Golovanov - JazzCore
David Briscoe - DavidBriscoe
Keith Welch - paralogiki
Zhao Cai - zhaocai
John Szakmeister - jszakmeister
Jonas Diemer - diemer
Romain Giot - rgiot
Sergey Alexandrov - taketwo
Brian Mock - saikobee
Gernot Höflechner - LFDM
Marcelo D Montu - mMontu
Karl Yngve Lervåg - lervag
Pedro Ferrari - petobens
Ches Martin - ches
Christian - Oberon00
Andrew Ruder - aeruder
Mathias Fußenegger - mfussenegger
Kevin Ballard - kballard
Ahbong Chang - cwahbong
Glenn Griffin - ggriffiniii
Michael - Pyrohh
Stanislav Seletskiy - seletskiy
Pawel Palucki - ppalucki
Dettorer - dettorer
Zhao Jiarong - kawing-chiu
Ye Ding - dyng
Greg Hurrell - wincent
vim:tw=78:ts=8:ft=help:norl:
ultisnips-3.1/doc/demo.gif 0000664 0000000 0000000 00004055135 12631231361 0015602 0 ustar 00root root 0000000 0000000 GIF89aE WFFFuVUJ4=DSSSV]WR;Vg="y&453Tud]0/9bV9;JT3rrǵ!MT
ID ELq"q