Beispiel #1
0
 def run_alias(self, start, end, alias, clear=False):
     """Lookup a command given its alias and execute it."""
     command = settings.get('aliases').get(alias)
     if command:
         self.run_command(start, end, command, clear)
     else:
         v.echo("'{}' alias not found".format(alias))
Beispiel #2
0
    def run_command(self, start, end, command, clear=False):
        """To Run the command as the given command"""
        self.last_command = command

        if command and settings.get('bufname_expansion', bool):
            command = misc.expand_chars(command, '%', vim.current.buffer.name)

        if command and settings.get('selection_expansion', bool):
            command = misc.expand_chars(
                command, '@', '\r'.join(vim.current.buffer[start - 1:end]))

        if command and settings.get('function_expansion', bool):
            try:
                command = misc.expand_functions(command)
            except NameError:  # the function does not exist
                v.echo('unknown function')
                return
            except ValueError:  # bad arguments
                v.echo('bad arguments')
                return

        if not command or settings.get('always_clear_screen', bool):
            clear = True

        self.run(command, clear=clear)
Beispiel #3
0
 def run_alias(self, start, end, alias, clear=False):
     """Lookup a command given its alias and execute it."""
     command = settings.get('aliases').get(alias)
     if command:
         self.run_command(start, end, command, clear)
     else:
         v.echo("'{}' alias not found".format(alias))
Beispiel #4
0
    def run_command(self, start, end, command, clear=False):
        """To Run the command as the given command"""
        self.last_command = command

        if command and settings.get('bufname_expansion', bool):
            command = misc.expand_chars(command, '%', vim.current.buffer.name)

        if command and settings.get('selection_expansion', bool):
            command = misc.expand_chars(
                command, '@', '\r'.join(vim.current.buffer[start-1:end]))

        if command and settings.get('function_expansion', bool):
            try:
                command = misc.expand_functions(command)
            except NameError:  # the function does not exist
                v.echo('unknown function')
                return
            except ValueError:  # bad arguments
                v.echo('bad arguments')
                return

        if not command or settings.get('always_clear_screen', bool):
            clear = True

        self.run(command, clear=clear)
Beispiel #5
0
 def show_aliases(self):
     """To show all defined aliases."""
     aliases = settings.get('aliases')
     if aliases:
         print('+ aliases')
         for i, alias in enumerate(aliases):
             conn = '└─ ' if i == len(aliases) - 1 else '├─ '
             print(conn + alias + ': ' + aliases[alias])
     else:
         v.echo('no aliases found')
Beispiel #6
0
 def show_aliases(self):
     """To show all defined aliases."""
     aliases = settings.get('aliases')
     if aliases:
         print('+ aliases')
         for i, alias in enumerate(aliases):
             conn = '└─ ' if i == len(aliases)-1 else '├─ '
             print(conn + alias + ': ' + aliases[alias])
     else:
         v.echo('no aliases found')
Beispiel #7
0
 def run_last_command(self):
     """Execute the last executed command."""
     if self.last_command:
         self.run_command(1, 1, self.last_command)
     else:
         v.echo('no last command to execute')
Beispiel #8
0
 def run_last_command(self):
     """Execute the last executed command."""
     if self.last_command:
         self.run_command(1, 1, self.last_command)
     else:
         v.echo('no last command to execute')