Beispiel #1
0
    def parse(self, base):
        try:
            snips = UltiSnips_Manager._snips(base, True)
        except Exception:
            return []

        return [{
            'word': snip.trigger,
            'menu': ' '.join(['[snip]', snip.description]),
        } for snip in snips]
def _AddUltiSnipsDataIfNeeded(extra_data):
    if not USE_ULTISNIPS_DATA:
        return

    try:
        # Since UltiSnips may run in a different python interpreter (python 3) than
        # YCM, UltiSnips_Manager singleton is not necessary the same as the one
        # used by YCM. In particular, it means that we cannot rely on UltiSnips to
        # set the current filetypes to the singleton. We need to do it ourself.
        UltiSnips_Manager.reset_buffer_filetypes()
        UltiSnips_Manager.add_buffer_filetypes(vimsupport.GetVariableValue("&filetype"))
        rawsnips = UltiSnips_Manager._snips("", True)
    except:
        return

    # UltiSnips_Manager._snips() returns a class instance where:
    # class.trigger - name of snippet trigger word ( e.g. defn or testcase )
    # class.description - description of the snippet
    extra_data["ultisnips_snippets"] = [{"trigger": x.trigger, "description": x.description} for x in rawsnips]
Beispiel #3
0
def _GetCandidates():
  try:
    rawsnips = UltiSnips_Manager._snips( '', 1 )

    # UltiSnips_Manager._snips() returns a class instance where:
    # class.trigger - name of snippet trigger word ( e.g. defn or testcase )
    # class.description - description of the snippet
    return  [ { 'word': str( snip.trigger ),
                'menu': str( '<snip> ' + snip.description ) }
              for snip in rawsnips ]
  except:
    return []
Beispiel #4
0
def _GetCandidates():
  try:
    rawsnips = UltiSnips_Manager._snips( '', 1 )

    # UltiSnips_Manager._snips() returns a class instance where:
    # class.trigger - name of snippet trigger word ( e.g. defn or testcase )
    # class.description - description of the snippet
    return  [ { 'word': str( snip.trigger ),
                'menu': str( '<snip> ' + snip.description.encode('utf-8') ) }
              for snip in rawsnips ]
  except:
    return []
Beispiel #5
0
def _AddUltiSnipsDataIfNeeded( extra_data ):
  if not USE_ULTISNIPS_DATA:
    return

  try:
    # Since UltiSnips may run in a different python interpreter (python 3) than
    # YCM, UltiSnips_Manager singleton is not necessary the same as the one
    # used by YCM. In particular, it means that we cannot rely on UltiSnips to
    # set the current filetypes to the singleton. We need to do it ourself.
    UltiSnips_Manager.reset_buffer_filetypes()
    UltiSnips_Manager.add_buffer_filetypes(
      vimsupport.GetVariableValue( '&filetype' ) )
    rawsnips = UltiSnips_Manager._snips( '', True )
  except:
    return

  # UltiSnips_Manager._snips() returns a class instance where:
  # class.trigger - name of snippet trigger word ( e.g. defn or testcase )
  # class.description - description of the snippet
  extra_data[ 'ultisnips_snippets' ] = [ { 'trigger': x.trigger,
                                           'description': x.description
                                         } for x in rawsnips ]
def _AddUltiSnipsDataIfNeeded(extra_data):
    if not USE_ULTISNIPS_DATA:
        return

    try:
        rawsnips = UltiSnips_Manager._snips("", 1)
    except:
        return

    # UltiSnips_Manager._snips() returns a class instance where:
    # class.trigger - name of snippet trigger word ( e.g. defn or testcase )
    # class.description - description of the snippet
    extra_data["ultisnips_snippets"] = [{"trigger": x.trigger, "description": x.description} for x in rawsnips]
Beispiel #7
0
def _AddUltiSnipsDataIfNeeded( extra_data ):
  if not USE_ULTISNIPS_DATA:
    return

  try:
    rawsnips = UltiSnips_Manager._snips( '', 1 )
  except:
    return

  # UltiSnips_Manager._snips() returns a class instance where:
  # class.trigger - name of snippet trigger word ( e.g. defn or testcase )
  # class.description - description of the snippet
  extra_data[ 'ultisnips_snippets' ] = [ { 'trigger': x.trigger,
                                           'description': x.description
                                         } for x in rawsnips ]
    def parse(self, base):
        token = self.input_data.split()[-1]
        try:
            snips = UltiSnips_Manager._snips(token, True)
        except Exception:
            return []
        candidates = [{
            'word': snip.trigger,
            'dup': 1,
            'menu': ' '.join(['[snip]', snip.description]),
        } for snip in snips]

        index = token.rfind(base)
        if index > 0 and candidates:
            prefix = len(token[:index])
            for c in candidates:
                c['abbr'] = c['word']
                c['word'] = c['word'][prefix:]
        return candidates
Beispiel #9
0
    def parse(self, base):
        if not base or base.endswith((' ', '\t')):
            return []
        token = base.split()[-1]
        try:
            snips = UltiSnips_Manager._snips(token, True)
        except Exception:
            return []
        offset = len(base) - len(token)
        candidates = [{
            'word': snip.trigger,
            'dup': 1,
            'offset': offset,
            'menu': ' '.join(['[snip]', snip.description]),
        } for snip in snips]

        index = token.rfind(base)
        if index > 0 and candidates:
            prefix = len(token[:index])
            for c in candidates:
                c['abbr'] = c['word']
                c['word'] = c['word'][prefix:]
        return candidates
Beispiel #10
0
def snippetsInit():
  global ultisnips_idx
  ultisnips_idx = 0
  UltiSnips_Manager.add_buffer_filetypes('%s.clang_complete' % vim.eval('&filetype'))
Beispiel #11
0
def snippetsReset():
  UltiSnips_Manager.clear_snippets(ft="clang_complete")
Beispiel #12
0
def snippetsTrigger():
  print vim.current.line
  UltiSnips_Manager.expand()
Beispiel #13
0
def snippetsAddSnippet(fullname, word, abbr):
  global ultisnips_idx
  ultisnips_idx = 0
  UltiSnips_Manager.add_snippet(fullname, word, fullname, "i", "clang_complete")
  return fullname
Beispiel #14
0
def register_postfix_snippets():
    UltiSnips_Manager.add_snippet(EXPR_REGEX + r'\.for',
                                  _POSTFIX_FOR_LOOP_VALUE, "Postfix for-loop",
                                  'r', 'cpp', -50)
    UltiSnips_Manager.add_snippet(EXPR_REGEX + r'\.fori',
                                  _POSTFIX_FOR_I_LOOP_VALUE,
                                  "Postfix for-i-loop", 'r', 'cpp', -50)
    UltiSnips_Manager.add_snippet(EXPR_REGEX + r'\.if', _POSTFIX_IF_VALUE,
                                  "Postfix if-expr", 'r', 'cpp', -50)
    UltiSnips_Manager.add_snippet(EXPR_REGEX + r'\.be',
                                  _POSTFIX_BEGIN_END_VALUE,
                                  "Postfix begin-end", 'r', 'cpp', -50)
    UltiSnips_Manager.add_snippet(EXPR_REGEX + r'\.mv',
                                  _POSTFIX_STD_MOVE_VALUE, "Postfix std::move",
                                  'r', 'cpp', -50)
    UltiSnips_Manager.add_snippet(EXPR_REGEX + r'\.rt', _POSTFIX_RETURN_VALUE,
                                  "Postfix return", 'r', 'cpp', -50)
Beispiel #15
0
def snippetsReset():
    UltiSnips_Manager.clear_snippets(ft="clang_complete")
Beispiel #16
0
def snippetsTrigger():
    print vim.current.line
    UltiSnips_Manager.expand()
Beispiel #17
0
def snippetsAddSnippet(fullname, word, abbr):
    global ultisnips_idx
    ultisnips_idx = 0
    UltiSnips_Manager.add_snippet(fullname, word, fullname, "i",
                                  "clang_complete")
    return fullname
Beispiel #18
0
def snippetsInit():
    global ultisnips_idx
    ultisnips_idx = 0
    UltiSnips_Manager.add_buffer_filetypes('%s.clang_complete' %
                                           vim.eval('&filetype'))