Ejemplo n.º 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]
Ejemplo n.º 2
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 []
Ejemplo n.º 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.encode('utf-8') ) }
              for snip in rawsnips ]
  except:
    return []
Ejemplo n.º 4
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]
Ejemplo n.º 5
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 ]
Ejemplo n.º 6
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]
Ejemplo n.º 7
0
    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
Ejemplo n.º 8
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 ]
Ejemplo n.º 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