Overdue date syntax highlight

This commit is contained in:
Guilherme Victal
2016-01-24 16:57:01 -02:00
parent 03f5575363
commit 6e1bcc0e1a
4 changed files with 30 additions and 0 deletions

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "python/dateregex"]
path = python/dateregex
url = git@github.com:victal/dateregex.git

1
python/dateregex Submodule

Submodule python/dateregex added at 7db2e6ca01

25
python/todo.py Normal file
View File

@@ -0,0 +1,25 @@
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
import vim
import os
import sys
from datetime import date
dateregex_dir = os.path.join(vim.eval('s:script_dir'), 'dateregex')
if os.path.isdir(dateregex_dir):
sys.path.insert(0, dateregex_dir)
def add_due_date_syntax_highlight():
try:
from dateregex import regex_date_before
except ImportError:
print("dateregex module not found. Overdue dates won't be highlighted")
return
regex = regex_date_before(date.today())
regex = r'(^|<)due:%s(>|$)' % regex
vim.command("syntax match OverDueDate '\\v%s'" % regex)
vim.command("highlight default link OverDueDate Error")
add_due_date_syntax_highlight()

View File

@@ -52,6 +52,7 @@ highlight default link TodoContext Special
if has('python')
let b:curdir = expand('<sfile>:p:h')
let s:script_dir = b:curdir . "/../python/"
execute "pyfile " . b:curdir . "/../python/todo.py"
else
echom "Your version of vim has no python support. Overdue dates won't be highlighted"