Added preliminary support for neocomplete.
Patch by lervag. Closes #228
This commit is contained in:
parent
1ec523801d
commit
c017806b1d
16
autoload/neocomplete/sources/ultisnips.vim
Normal file
16
autoload/neocomplete/sources/ultisnips.vim
Normal file
@ -0,0 +1,16 @@
|
||||
let s:source = {
|
||||
\ 'name' : 'ultisnips',
|
||||
\ 'kind' : 'manual',
|
||||
\ 'mark' : '[U]',
|
||||
\ 'min_pattern_length' : 1,
|
||||
\ 'is_volatile' : 1,
|
||||
\ 'rank' : 10,
|
||||
\}
|
||||
|
||||
function! s:source.gather_candidates(context)
|
||||
return keys(UltiSnips#SnippetsInCurrentScope())
|
||||
endfunction
|
||||
|
||||
function! neocomplete#sources#ultisnips#define()
|
||||
return s:source
|
||||
endfunction
|
@ -1367,6 +1367,7 @@ individuals have contributed to UltiSnips (in chronological order):
|
||||
Brian Mock - saikobee
|
||||
Gernot Höflechner - LFDM
|
||||
Marcelo D Montu - mMontu
|
||||
Karl Yngve Lervåg - lervag
|
||||
|
||||
Thank you for your support.
|
||||
|
||||
|
@ -8,6 +8,7 @@ import re
|
||||
from UltiSnips import _vim
|
||||
from UltiSnips.compatibility import as_unicode
|
||||
from UltiSnips.indent_util import IndentUtil
|
||||
from UltiSnips.text import escape
|
||||
from UltiSnips.text_objects import SnippetInstance
|
||||
|
||||
def _words_for_line(trigger, before, num_words=None):
|
||||
@ -115,8 +116,7 @@ class SnippetDefinition(object):
|
||||
match = (words_suffix == self._trigger)
|
||||
if match and words_prefix:
|
||||
# Require a word boundary between prefix and suffix.
|
||||
boundary_chars = words_prefix[-1:] + words_suffix[:1]
|
||||
boundary_chars = boundary_chars.replace('"', '\\"')
|
||||
boundary_chars = escape(words_prefix[-1:] + words_suffix[:1], r'\"')
|
||||
match = _vim.eval('"%s" =~# "\\\\v.<."' % boundary_chars) != '0'
|
||||
elif "i" in self._opts:
|
||||
match = words.endswith(self._trigger)
|
||||
@ -152,7 +152,7 @@ class SnippetDefinition(object):
|
||||
match = self._re_match(trigger)
|
||||
elif "w" in self._opts:
|
||||
# Trim non-empty prefix up to word boundary, if present.
|
||||
qwords = words.replace('"', '\\"')
|
||||
qwords = escape(words, r'\"')
|
||||
words_suffix = _vim.eval(
|
||||
'substitute("%s", "\\\\v^.+<(.+)", "\\\\1", "")' % qwords)
|
||||
match = self._trigger.startswith(words_suffix)
|
||||
|
@ -16,6 +16,16 @@ def unescape(text):
|
||||
i += 1
|
||||
return rv
|
||||
|
||||
def escape(text, chars):
|
||||
"""Escapes all characters in 'chars' in text using backspaces."""
|
||||
rv = ""
|
||||
for char in text:
|
||||
if char in chars:
|
||||
rv += '\\'
|
||||
rv += char
|
||||
return rv
|
||||
|
||||
|
||||
def fill_in_whitespace(text):
|
||||
"""Returns 'text' with escaped whitespace replaced through whitespaces."""
|
||||
text = text.replace(r"\n", "\n")
|
||||
|
23
test.py
23
test.py
@ -3324,11 +3324,28 @@ class YouCompleteMe_IntegrationTest(_VimTest):
|
||||
self.vim.send(":set ft=python\n")
|
||||
# Give ycm a chance to catch up.
|
||||
time.sleep(1)
|
||||
|
||||
|
||||
|
||||
# End: Plugin: YouCompleteMe #}}}
|
||||
|
||||
# Plugin: Neocomplete {{{#
|
||||
class Neocomplete_BugTest(_VimTest):
|
||||
# Test for https://github.com/SirVer/ultisnips/issues/228
|
||||
def skip_if(self):
|
||||
if "+lua" not in self.version:
|
||||
return "Needs +lua"
|
||||
plugins = ["Shougo/neocomplete.vim"]
|
||||
snippets = ("t", "Hello", "", "w")
|
||||
keys = "iab\\ t" + EX
|
||||
wanted = "iab\\ Hello"
|
||||
|
||||
def _extra_options(self, vim_config):
|
||||
vim_config.append(r'set iskeyword+=\\ ')
|
||||
vim_config.append('let g:neocomplete#enable_at_startup = 1')
|
||||
vim_config.append('let g:neocomplete#enable_smart_case = 1')
|
||||
vim_config.append('let g:neocomplete#enable_camel_case = 1')
|
||||
vim_config.append('let g:neocomplete#enable_auto_delimiter = 1')
|
||||
vim_config.append('let g:neocomplete#enable_refresh_always = 1')
|
||||
# End: Plugin: Neocomplete #}}}
|
||||
|
||||
###########################################################################
|
||||
# END OF TEST #
|
||||
###########################################################################
|
||||
|
Loading…
Reference in New Issue
Block a user