summaryrefslogtreecommitdiff
path: root/vis/vis-org-mode.patch
blob: b0a827440aafeea544bd6f006e592d001d4b009e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
diff -Naur a/lua/lexers/lexer.lua b/lua/lexers/lexer.lua
--- a/lua/lexers/lexer.lua	2025-01-23 15:41:23.483390473 -0500
+++ b/lua/lexers/lexer.lua	2025-01-23 15:44:58.590614820 -0500
@@ -1684,6 +1684,7 @@
 		nsh = 'nsis', nsi = 'nsis', nsis = 'nsis', --
 		obs = 'objeck', --
 		m = 'objective_c', mm = 'objective_c', objc = 'objective_c', --
+		org = 'org', --
 		caml = 'caml', ml = 'caml', mli = 'caml', mll = 'caml', mly = 'caml', --
 		dpk = 'pascal', dpr = 'pascal', p = 'pascal', pas = 'pascal', --
 		al = 'perl', perl = 'perl', pl = 'perl', pm = 'perl', pod = 'perl', --
diff -Naur a/lua/lexers/org.lua b/lua/lexers/org.lua
--- a/lua/lexers/org.lua	1969-12-31 19:00:00.000000000 -0500
+++ b/lua/lexers/org.lua	2025-01-23 15:44:58.593948110 -0500
@@ -0,0 +1,103 @@
+--[[ Textadept Org module -- Org agenda LPeg lexer
+Copyright (c) 2012 joten
+Copyright (c) 2025 Matěj Cepl (@mcepl everywhere)
+Released under the conditions described in the LICENSE file.
+--]]
+
+local lexer = lexer
+local word_match = lexer.word_match
+local P, R, S, V = lpeg.P, lpeg.R, lpeg.S, lpeg.V
+
+local lex = lexer.new(...)
+
+--[[Overview. Used examples.
+* Heading 1-5 (8)
+	TODO special color, bold
+	DONE special color, bold
+	[#priority]
+	:tag: bold
+<date> / [date] like heading 3, underlined
+	keywords: CLOSED: DEADLINE: SCHEDULED: like heading 3, not underlined
+| table | like heading 1
+[[link][description] ]
+formatting:
+	*bold*
+	/italic/
+	_underline_
+	+strike+
+--]]
+
+-- Font formats.
+lex:add_rule('bold', lex:tag('BOLD',      '*' * lexer.word * '*'))
+lex:add_rule('italic', lex:tag('ITALIC',    '/' * lexer.word * '/'))
+lex:add_rule('underline', lex:tag('UNDERLINE', '_' * lexer.alnum * '_'))
+
+-- ToDos.
+lex:add_rule('todo', lex:tag('TODO', lex:word_match('TODO')))
+lex:add_rule('done', lex:tag('DONE', lex:word_match('DONE')))
+lex:add_rule('wontfix', lex:tag('WONTFIX', lex:word_match('WONTFIX')))
+local agenda_tags = P('TODO') + 'DONE' + 'WONTFIX'
+
+-- DateTime.
+local DD =   lexer.digit * lexer.digit
+local date = DD * DD * '-' * DD * '-' * DD
+local time_range = (' ' * DD * ':' * DD)^0 * ('-' * DD * ':' * DD)^0
+local repeater =   (' +' * lexer.integer * S('dwmy'))^0
+local alarm =      (' -' * lexer.integer * S('dwmy'))^0
+local pattern_datetime1 = S('<[')^-1 * 'date' * 'wday' * time_range * repeater * alarm * S('>]')^-1
+local pattern_datetime2 = lexer.starts_line('weekday') * lexer.space^1 * DD * '. ' * 'month' * lexer.space^1 * DD * DD
+local datetime =   pattern_datetime1 + pattern_datetime2
+
+lex:add_rule('current_date', lex:tag('CURRENT_DATE', lexer.starts_line(lex:word_match('weekday')) * lexer.space^1 * DD * '. ' * lex:word_match('month') * lexer.space^1 * DD * DD * '|'))
+lex:add_rule('time', lex:tag(lexer.CLASS, DD * ':' * DD))
+lex:add_rule('week', lex:tag('UNDERLINE', lexer.starts_line('KW ' * DD * lexer.space^25) + lexer.starts_line('Wk ' * DD * lexer.space^25)))
+lex:add_rule('datetime', lex:tag(lexer.NUMBER, lex:word_match('datetime')))
+
+-- Heading patterns.
+local function h(n)
+	return lex:tag(string.format('%s.h%s', lexer.HEADING, n),
+		lexer.starts_line(P(string.rep('*', n)) * ' '))
+end
+lex:add_rule('header', h(6) + h(5) + h(4) + h(3) + h(2) + h(1))
+
+-- Links.
+local orgmode_link = '[[' * (lexer.nonnewline - ' ' - ']')^1 * ']' * ('[' * (lexer.nonnewline - ']')^1 * ']')^0 * ']'
+lex:add_rule('link', lex:tag(lexer.LINK, orgmode_link))
+
+-- Strings.
+lex:add_rule('string', lex:tag(lexer.STRING, P('L')^-1 * lexer.range('"')))
+
+-- Comments.
+local line_comment = lexer.starts_line(lexer.to_eol('# ')) 
+local block_comment = lexer.range(lexer.starts_line('#+BEGIN_COMMENT'),
+		lexer.starts_line('#+END_COMMENT'))
+lex:add_rule('comment', lex:tag(lexer.COMMENT, block_comment + line_comment))
+
+-- Word lists.
+lex:set_word_list('TODO', {'TODO', 'DELEGATED', 'WAITING'})
+
+lex:set_word_list('DONE', {'DONE'})
+
+lex:set_word_list('WONTFIX', {'WONTFIX', 'INVALID'})
+
+lex:set_word_list('wday', {
+	'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So',
+	'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun',
+	'Po', 'Út', 'St', 'Čt', 'Pá', 'So', 'Ne'
+})
+
+lex:set_word_list('weekday', {
+	'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag', 'Sonntag',
+	'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday',
+	'Pondělí', 'Úterý', 'Středa', 'Čtvrtek', 'Pátek', 'Sobota', 'Neděle'
+})
+
+lex:set_word_list('month', {
+	'Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember',
+	'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December',
+	'Leden', 'Únor', 'Březen', 'Duben', 'Květen', 'Červen', 'Červenec', 'Srpen', 'Září', 'Říjen', 'Listopad', 'Prosince'
+})
+
+lexer.property['scintillua.comment'] = '#'
+
+return lex