def resolve(self, sequence=None, mode=None, check_user_mappings=True): """ Looks at the current global state and returns the command mapped to the available sequence. It may be a 'missing' command. @sequence If a @sequence is passed, it is used instead of the global state's. This is necessary for some commands that aren't name spaces but act as them (for example, ys from the surround plugin). @mode If different than `None`, it will be used instead of the global state's. This is necessary when we are in operator pending mode and we receive a new action. By combining the existing action's name with name of the action just received we could find a new action. For example, this is the case of g~~. """ # we usually need to look at the partial sequence, but some commands do weird things, # like ys, which isn't a namespace but behaves as such sometimes. seq = sequence or self.state.partial_sequence seq = to_bare_command_name(seq) # TODO: Use same structure as in mappings (nested dicst). command = None if check_user_mappings: self.state.logger.info('[Mappings] checking user mappings') # TODO: We should be able to force a mode here too as, below. command = self.expand_first(seq) if command: self.state.logger.info('[Mappings] {0} equals command: {1}'.format( seq, command)) return command # return {'name': command.mapping, 'type': cmd_types.USER} else: self.state.logger.info('[Mappings] looking up >{0}<'.format(seq)) command = seq_to_command(self.state, seq, mode=mode) self.state.logger.info('[Mappings] got {0}'.format(command)) return command
def resolve(self, sequence=None, mode=None, check_user_mappings=True): """ Looks at the current global state and returns the command mapped to the available sequence. It may be a 'missing' command. @sequence If a @sequence is passed, it is used instead of the global state's. This is necessary for some commands that aren't name spaces but act as them (for example, ys from the surround plugin). @mode If different than `None`, it will be used instead of the global state's. This is necessary when we are in operator pending mode and we receive a new action. By combining the existing action's name with name of the action just received we could find a new action. For example, this is the case of g~~. """ # we usually need to look at the partial sequence, but some commands do weird things, # like ys, which isn't a namespace but behaves as such sometimes. seq = sequence or self.state.partial_sequence seq = to_bare_command_name(seq) # TODO: Use same structure as in mappings (nested dicst). command = None if check_user_mappings: self.state.logger.info('[Mappings] checking user mappings') # TODO: We should be able to force a mode here too as, below. command = self.expand_first(seq) if command: self.state.logger.info('[Mappings] {0} equals command: {1}'.format(seq, command)) return command # return {'name': command.mapping, 'type': cmd_types.USER} else: self.state.logger.info('[Mappings] looking up >{0}<'.format(seq)) command = seq_to_command(self.state, seq, mode=mode) self.state.logger.info('[Mappings] got {0}'.format(command)) return command
def transform(self, input_): return to_bare_command_name(input_)