]>
Commit | Line | Data |
---|---|---|
1 | #!/usr/bin/env python2 | |
2 | # -*- coding: utf-8 -*- | |
3 | # File: todo.py | |
4 | # Description: Todo.txt overdue date syntax script | |
5 | # License: Vim license | |
6 | # Website: http://github.com/freitass/todo.txt-vim | |
7 | # Version: 0.1 | |
8 | ||
9 | import vim | |
10 | import os | |
11 | import sys | |
12 | from datetime import date | |
13 | ||
14 | dateregex_dir = os.path.join(vim.eval('s:script_dir'), 'dateregex') | |
15 | if os.path.isdir(dateregex_dir): | |
16 | sys.path.insert(0, dateregex_dir) | |
17 | ||
18 | def add_due_date_syntax_highlight(): | |
19 | try: | |
20 | from dateregex import regex_date_before | |
21 | except ImportError: | |
22 | print("dateregex module not found. Overdue dates won't be highlighted") | |
23 | return | |
24 | ||
25 | regex = regex_date_before(date.today()) | |
26 | regex = r'(^|<)due:%s(>|$)' % regex | |
27 | ||
28 | vim.command("syntax match OverDueDate '\\v%s'" % regex) | |
29 | vim.command("highlight default link OverDueDate Error") | |
30 | ||
31 | add_due_date_syntax_highlight() |