mirror of
https://github.com/freitass/todo.txt-vim.git
synced 2025-11-14 12:53:46 -05:00
Overdue date syntax highlight
This commit is contained in:
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
[submodule "python/dateregex"]
|
||||||
|
path = python/dateregex
|
||||||
|
url = git@github.com:victal/dateregex.git
|
||||||
1
python/dateregex
Submodule
1
python/dateregex
Submodule
Submodule python/dateregex added at 7db2e6ca01
25
python/todo.py
Normal file
25
python/todo.py
Normal 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()
|
||||||
@@ -52,6 +52,7 @@ highlight default link TodoContext Special
|
|||||||
|
|
||||||
if has('python')
|
if has('python')
|
||||||
let b:curdir = expand('<sfile>:p:h')
|
let b:curdir = expand('<sfile>:p:h')
|
||||||
|
let s:script_dir = b:curdir . "/../python/"
|
||||||
execute "pyfile " . b:curdir . "/../python/todo.py"
|
execute "pyfile " . b:curdir . "/../python/todo.py"
|
||||||
else
|
else
|
||||||
echom "Your version of vim has no python support. Overdue dates won't be highlighted"
|
echom "Your version of vim has no python support. Overdue dates won't be highlighted"
|
||||||
|
|||||||
Reference in New Issue
Block a user