def error_tb(vim: Nvim, msg: str) -> None: lines: typing.List[str] = [] t, v, tb = sys.exc_info() if t and v and tb: lines += traceback.format_exc().splitlines() lines += ['%s. Use :messages / see above for error details.' % msg] if hasattr(vim, 'err_write'): vim.err_write('[denite] %s\n' % '\n'.join(lines)) else: for line in lines: error(vim, line)
def error(vim: Nvim, expr: typing.Any) -> None: if hasattr(vim, 'err_write'): vim.err_write(f'[deoplete] {expr}\n') else: vim.call('deoplete#util#print_error', expr)
def error(vim: Nvim, expr: typing.Any) -> None: if hasattr(vim, 'err_write'): string = (expr if isinstance(expr, str) else str(expr)) vim.err_write('[deoplete] ' + string + '\n') else: vim.call('deoplete#util#print_error', expr)
def make_diary( nvim: Nvim, options: PluginOptions, gcal_service: SimpleNvimGoogleCal, github_service: SimpleNvimGithub, auto_command: bool = False, ) -> None: """make_diary Make the actual diary markdown file. This includes the following steps: * Open the file if it already exists. * If not, put the default template in and save. """ # If the buffer is not empty, don't continue. Issue an error if manually # called, don't issue an error for an autocommand. if not is_buffer_empty(nvim): if not auto_command: nvim.err_write("Buffer is not empty, can't create diary.\n") return # If options is none, then everything else probably wasn't setup either. if options is None: nvim.err_write("Options weren't initialised, aborting.\n") return full_markdown: List[str] = [] diary_date: str = get_diary_date(nvim) diary_metadata: Dict[str, str] = {"Date": diary_date} full_markdown.extend(generate_markdown_metadata(diary_metadata)) set_buffer_contents(nvim, full_markdown) for heading in options.daily_headings: full_markdown.append(f"## {heading}") full_markdown.append("") set_buffer_contents(nvim, full_markdown) # Add in issues section issues: List[GitHubIssue] = [] if options.use_github_repo and github_service and github_service.active: issues = github_service.active_issues issue_markdown: List[str] = produce_issue_markdown(options, issues) full_markdown.extend(issue_markdown) set_buffer_contents(nvim, full_markdown) # Add in the calendar entries days_events: List[CalendarEvent] = [] if options.use_google_calendar and gcal_service and gcal_service.active: date_today_object: date = parser.parse(diary_date).date() if date_today_object == date.today(): days_events = gcal_service.active_events else: days_events = gcal_service.get_events_for_date(date_today_object) schedule_markdown: List[str] = produce_schedule_markdown(days_events) full_markdown.extend(schedule_markdown) # Set the buffer contents and save the file. set_buffer_contents(nvim, full_markdown) nvim.command(":w") if options.auto_generate_diary_index: generate_diary_index(options)