def _load(): try: from NeoVintageous.nv.ex_cmds import do_ex_cmdline window = sublime.active_window() with builtins.open(_file_name(), 'r') as f: for line in f: ex_cmdline = _parse_line(line) if ex_cmdline: do_ex_cmdline(window, ex_cmdline) print('vinageousrc file loaded') except FileNotFoundError: _log.info('rcfile not found')
def on_done(self, cmdline): if len(cmdline) <= 1: return if cmdline[0] != ':': return if _nv_cmdline.interactive_call: history_update(cmdline) _nv_cmdline_feed_key.reset_last_history_index() do_ex_cmdline(self.window, cmdline)
def _load() -> None: try: from NeoVintageous.nv.ex_cmds import do_ex_cmdline window = sublime.active_window() with builtins.open(_file_path(), 'r', encoding='utf=8', errors='replace') as f: for line in f: ex_cmdline = _parse_line(line) if ex_cmdline: do_ex_cmdline(window, ex_cmdline) print('%s file loaded' % _file_name()) except FileNotFoundError: _log.info('%s file not found', _file_name())
def _run(): _log.debug('run %s', _file_name()) from NeoVintageous.nv.ex_cmds import do_ex_cmdline try: window = sublime.active_window() with builtins.open(_file_name(), 'r') as f: for line in f: cmdline = _parse_line(line) if cmdline: # TODO [review] Should do_ex_cmdline() make the colon optional? do_ex_cmdline(window, ':' + cmdline) except FileNotFoundError: _log.debug('rcfile not found')
def do_modeline(view) -> None: # A feature similar to vim modeline. A number of lines at the beginning and # end of the file are checked for modelines. The number of lines checked is # controlled by the 'modelines' option, the default is 5. # # Examples: # vim: number # vim: nonumber # vim: tabstop=4 # vim: ts=4 noet window = view.window() # If the view is "transient" (for example when opened in in preview via the # CTRL-p overlay) then the view won't have a window object. Some ST events # like on_load() may open transient views. if not window: window = active_window() if window: modelines = get_option(view, 'modelines') line_count = view.rowcol(view.size())[0] + 1 head_lines = range(0, min(modelines, line_count)) tail_lines = range(max(0, line_count - modelines), line_count) lines = list(set(list(head_lines) + list(tail_lines))) for i in lines: line = view.line(view.text_point(i, 0)) if line.size() > 0: options = _parse_line(view.substr(line)) if options: for option in options: if option.strip().startswith('shell'): message('Error detected while processing modelines:') message('line %s:', str(i + 1)) message('E520: Not allowed in a modeline: %s', option) else: do_ex_cmdline(window, ':setlocal ' + option)