96 Commits

Author SHA1 Message Date
Daniel Hahler
8c257e24e0 VimBuffer: use vim.current.buffer.number instead of vim.eval
This should be more performant.
2015-06-27 18:23:46 +02:00
Holger Rapp
d6098193ef Merge pull request #446 from seletskiy/context-snippets
New feature: Context-aware snippets
2015-05-01 14:35:19 +02:00
Stanislav Seletskiy
463e68a611 fix for correct error reporting 2015-05-01 18:03:21 +06:00
Stanislav Seletskiy
099d3bcfbc Add more precise undo levels (expanding, jumping)
Breaking undo achieved through re-setting &undolevel:

    Setting the value of 'undolevels' also breaks undo. Even when the new
    value is equal to the old value.

    [:h :undoj]
2015-04-27 19:30:17 +06:00
Stanislav Seletskiy
904fbdecf5 review fixes 2015-04-25 21:38:22 +06:00
Stanislav Seletskiy
709f8dc93f minor doc fix and new cursor variable 2015-04-19 11:08:14 +06:00
Stanislav Seletskiy
66bc2e8f6e documentation, pull-requests fixes 2015-04-19 11:08:14 +06:00
Stanislav Seletskiy
0beefd4a19 fix context match on False value 2015-04-19 11:06:03 +06:00
Stanislav Seletskiy
ed8cf49115 fix tests 2015-04-19 11:06:03 +06:00
Stanislav Seletskiy
b3aec07053 proof of concept for context snips 2015-04-19 11:04:57 +06:00
Holger Rapp
4b39bf6558 Priority must always be an integer. 2015-04-18 17:32:36 +02:00
Holger Rapp
99eede1bf6 Started to test py2 and py3 on travis now.
I also learned that Vim 7.3 does not seem to be working at all anymore.
Fixes a bug that only happens with python3.
2015-04-18 17:15:05 +02:00
kawing.chiu
f9a22111f0 Fix adjacent tabstop input issue.
Previously, adjacent tabstops like $1$2 were not handled properly.
$2 could be jumped to but no text could be added. See issue #457.
2015-03-13 23:49:45 +08:00
Holger Rapp
09876e0084 Support for m (trim) snippet option. 2015-02-14 14:20:03 +01:00
Dettorer
c1bde18cdf Add support vim's langnoremap new option
This fixes the following issue:
https://github.com/SirVer/ultisnips/issues/431
2015-02-12 16:27:25 +01:00
Stanislav Seletskiy
81a628c6ea Add option 'm' for trimming whitespaces in snippet
Fix #391
2015-02-04 11:55:28 +06:00
Stanislav Seletskiy
b47e686521 do not walk &rtp if abs path to snips specified 2015-01-21 17:57:33 +06:00
Holger Rapp
6a787cdc7b Applied pyformat on entire codebase. 2015-01-20 21:26:03 +01:00
Holger Rapp
e1436a8aeb Accept numbers and text for disabling snipMate. 2015-01-15 08:17:37 +01:00
Holger Rapp
7df82bbe53 Merge pull request #415 from seletskiy/toggle-snipmate
add g:UltiSnipsEnableSnipMate
2014-12-20 18:39:50 +01:00
Stanislav Seletskiy
fc080b4fd5 add g:UltiSnipsEnableSnipMate 2014-12-18 12:05:52 +06:00
Michael Reed
c050d68e5a Check if editor is Neovim when setting snippet_dir 2014-12-06 00:41:13 -05:00
John Szakmeister
e502c9ba84 Fix a couple of typos. 2014-11-24 04:06:31 -05:00
John Szakmeister
8b2115ec26 Fix #171: UltiSnips crashes in new file with text containing 0x80 char
It turns out that vim.eval() will attempt to do Unicode conversion and
can fail when raw bytes are present in the unnamed register.  To avoid
this problem, let's not carry the value across the bridge, and instead
store the cached value in Vim directly.  This successfully sidesteps the
issue entirely, and provides the correct save and restore behavior.

This also adds a test case for the issue.  Since expansion can finish
(despite the errors), the test has to capture the error messages and
examine them for a failure.
2014-11-21 06:09:49 -05:00
John Szakmeister
f4df1bd9e8 Teach _vim_enc to handle UnicodeDecodeErrors.
It's possible that when using _vim_dec with Python 2 that we fail to
convert the string to Unicode and just return the raw string instead.
This could happen, for instance, when there was arbitrary data in the
unnamed register during the save/restore process.  During restoration,
we'd attempt to encode the string, but this may fail with a
UnicodeDecodeError as Python attempts to first convert to Unicode and
then to the requested encoding.

To fix this, let's also catch `UnicodeDecodeError` and return the raw
string if we fail to convert.
2014-11-21 06:09:18 -05:00
Glenn Griffin
482650a009 Use shiftwidth() where available. This allows UltiSnips to work properly when
shiftwidth is zero. Per ":help shiftwidth":

shiftwidth()                                            shiftwidth()
                Returns the effective value of 'shiftwidth'. This is the
                'shiftwidth' value unless it is zero, in which case it is the
                'tabstop' value.  To be backwards compatible in indent
                plugins, use this:
                        if exists('*shiftwidth')
                          func s:sw()
                            return shiftwidth()
                          endfunc
                        else
                          func s:sw()
                            return &sw
                          endfunc
                        endif
                And then use s:sw() instead of &sw.
2014-10-07 17:24:55 -07:00
Holger Rapp
c3660128ac Implements clearsnippets by priority. 2014-08-02 14:55:27 +02:00
cwahbong
0abfc3bece Some refinements.
1. Add docstrings.
2. Re-implement get_deep_extends().
3. Remove all inners.
2014-08-01 14:32:47 +08:00
cwahbong
4784a9e126 Refactor: snippet dictionary does not keep the extend info now. 2014-08-01 14:32:47 +08:00
cwahbong
20f3832ffa Code cleanup.
Full tested and does not break and old tests.
2014-08-01 14:32:47 +08:00
cwahbong
5c87806d7b Implement priority-based clearsnippets. 2014-08-01 14:32:47 +08:00
cwahbong
a053433e48 Variable rename and illustration. 2014-07-31 21:03:10 +08:00
cwahbong
e05788cece Fix issue #341 (github). 2014-07-29 13:02:26 +08:00
Kevin Ballard
4b73864b74 Fix the docstring for ShellCodeToken
It's not vim-syntax-related, but it was bugging me.
2014-06-30 15:56:32 -07:00
Holger Rapp
ee1a2bb2b8 Escape '\\' in UltiSnipsEdit.
Fixes #308.
2014-05-27 04:15:19 +02:00
Mathias Fussenegger
da5b124af5 add support for selection=old 2014-05-02 20:00:42 +02:00
Andrew Ruder
cae27fba5c Ensure that _vim_{dec,enc} always succeeds on py3
In py2 we could get by with attempting to encode/decode a string and if
it failed just ignore and return.  Unfortunately on py3 a string decodes
to a bytearray and a bytearray encodes to a string.  We can't simply
return the original object when we fail.  We choose replace for handling
bytes we don't understand.

Test case (using python3 for UltiSnips):
open a new file
:set encoding=utf-8
qa<Backspace>q
"ap

Warning: this test case makes it very difficult to exit vim cleanly and
save files!

Signed-off-by: Andrew Ruder <andrew.ruder@elecsyscorp.com>
2014-04-10 08:06:56 -05:00
Holger Rapp
a3e654fc54 _vimfiles -> vimfiles. Patch b Oberon. 2014-04-06 16:33:02 +02:00
skeept
ae70ec8956 Escape correctly file names in windows.
In windows when expanding snippets the names of the snippet files look weird because \ is not escaped properly.

Also I think there should be an option to show only part of the file name, say the path relative to ~/.vim, because this way most of the screen is taken with the paths of the file.

Going even further I think it would it look nicer if you had some kind of alignment for the string. Say "%2i: %-15s (%s)".
Of course this last suggestion might not be consensual, but maybe a option might be offered to the user.
2014-03-30 05:57:44 +00:00
Holger Rapp
4b4ee48858 Overwrite all snippets with lower priority on expansion.
Fixes #233.
2014-03-23 17:30:44 +01:00
Holger Rapp
360f58dbf6 Show where snippets are defined in selection.
Fixes #184.
2014-03-22 20:20:56 +01:00
Holger Rapp
7c34a3400b Escape \ when asking for snippets.
Fixes #176.
2014-03-22 19:53:01 +01:00
Holger Rapp
cd99bdd3b3 selection=old cannot work with UltiSnips.
Kind of fixes #173.
2014-03-22 19:47:59 +01:00
Holger Rapp
69e0acd58a Change the way placeholders are selected.
Fixes #157.
2014-03-22 16:43:57 +01:00
Holger Rapp
5aaeae5e85 Do not delete child that is already gone.
Fixes #154
2014-03-22 11:28:44 +01:00
Holger Rapp
f40c3ac5e0 Made UltiSnipsEdit! more consistent with multiple filetypes. 2014-03-15 15:55:03 +01:00
Holger Rapp
5ac0436694 Retry unmapping when we switched buffers.
Fixes #229.
2014-03-14 20:35:14 +01:00
Holger Rapp
c6906d85be Fixed a bug in UltiSnipsEdit!
Closes #237
2014-03-07 10:51:04 +01:00
Holger Rapp
6398a598b5 Made UltiSnipsEdit more useful and consistent.
It now by default only edits private files, add a ! if you want to edit
non private files.
2014-03-06 09:10:48 +01:00
Holger Rapp
a800b51e0e Removed no longer planned TODOs 2014-03-05 19:04:16 +01:00