Esempio n. 1
0
 def _error(self, msg):
     msg = vim_string("UltiSnips: " + msg)
     if self._test_error:
         msg = msg.replace('"', r'\"')
         msg = msg.replace('|', r'\|')
         vim.command("let saved_pos=getpos('.')")
         vim.command("$:put =%s" % msg)
         vim.command("call setpos('.', saved_pos)")
     elif False:
         vim.command("echohl WarningMsg")
         vim.command("echomsg %s" % msg)
         vim.command("echohl None")
     else:
         vim.command("echoerr %s" % msg)
Esempio n. 2
0
    def _ask_snippets(self, snippets):
        """ Given a list of snippets, ask the user which one they
        want to use, and return it.
        """
        # make a python list
        display = [ "%i: %s" % (i+1,s.description) for i,s in enumerate(snippets)]

        try:
            # let vim_string format it as a vim list
            rv = vim.eval(make_suitable_for_vim(as_unicode("inputlist(%s)") % vim_string(display)))
            if rv is None or rv == '0':
                return None
            rv = int(rv)
            if rv > len(snippets):
                rv = len(snippets)
            return snippets[rv-1]
        except vim.error as e:
            if str(e) == 'invalid expression':
                return None
            raise
Esempio n. 3
0
def echom(mes, *args):
    mes = mes % args
    vim.command('echom %s' % vim_string(mes))
Esempio n. 4
0
 def _error(self, msg):
     fn = vim.eval("""fnamemodify(%s, ":~:.")""" % vim_string(self._fn))
     self._sm._error("%s in %s(%d)" % (msg, fn, self._idx + 1))