2 " Author: Peter Odding <peter@peterodding.com>
3 " Last Change: July 23, 2011
4 " URL: http://peterodding.com/code/vim/notes/
6 " Note: This file is encoded in UTF-8 including a byte order mark so
7 " that Vim loads the script using the right encoding transparently.
9 " Quit when a syntax file was already loaded.
10 if exists('b:current_syntax')
14 " Check for spelling errors in all text.
17 " Inline elements. {{{1
19 " Cluster of elements which never contain a newline character.
20 syntax cluster notesInline contains=notesName
22 " Default highlighting style for notes syntax markers.
23 highlight def link notesHiddenMarker Ignore
25 " Highlight note names as hyperlinks. {{{2
26 call xolox#notes#highlight_names(1)
27 syntax cluster notesInline add=notesName
28 highlight def link notesName Underlined
30 " Highlight @tags as hyperlinks. {{{2
31 syntax match notesTagName /\(^\|\s\)\@<=@\k\+/
32 highlight def link notesTagName Underlined
34 " Highlight list bullets and numbers. {{{2
35 syntax match notesListBullet /^\s*\zs\(•\|\*\)/
36 highlight def link notesListBullet Comment
37 syntax match notesListNumber /^\s*\zs\d\+[[:punct:]]\?\ze\s/
38 highlight def link notesListNumber Comment
40 " Highlight quoted fragments (inside single quotes). {{{2
41 if xolox#notes#unicode_enabled()
42 syntax match notesQuotedFragment /‘.\{-}’/
44 syntax match notesQuotedFragment /`.\{-}'/
46 highlight def link notesQuotedFragment Special
48 " Highlight text emphasized in italic font. {{{2
50 syntax region notesItalic matchgroup=notesItalicMarker start=/\<_\k\@=/ end=/_\>\|\n/ contains=@Spell concealends
51 highlight link notesItalicMarker notesHiddenMarker
53 syntax match notesItalic /\<_\k[^_]*\k_\>/
55 syntax cluster notesInline add=notesItalic
56 highlight notesItalic gui=italic
58 " Highlight text emphasized in bold font. {{{2
60 syntax region notesBold matchgroup=notesBoldMarker start=/\*\k\@=/ end=/\k\@<=\*/ contains=@Spell concealends
61 highlight link notesBoldMarker notesHiddenMarker
63 syntax match notesBold /\*\k[^*]*\k\*/
65 syntax cluster notesInline add=notesBold
66 highlight notesBold gui=bold
68 " Highlight domain names, URLs, e-mail addresses and filenames. {{{2
70 " FIXME This setting is lost once the user switches color scheme!
71 highlight notesSubtleURL gui=underline guifg=fg
73 syntax match notesTextURL @\<www\.\(\S*\w\)\+/\?@
74 syntax cluster notesInline add=notesTextURL
75 highlight def link notesTextURL notesSubtleURL
76 syntax match notesRealURL @\<\(mailto:\|javascript:\|\w\{3,}://\)\(\S*\w\)\+/\?@
77 syntax cluster notesInline add=notesRealURL
78 highlight def link notesRealURL notesSubtleURL
80 syntax match notesUrlScheme @\(mailto:\|javascript:\|\w\{3,}://\)@ contained containedin=notesRealURL conceal
81 highlight def link notesUrlScheme notesRealURL
83 syntax match notesEmailAddr /\<\w[^@ \t\r]*\w@\w[^@ \t\r]\+\w\>/
84 syntax cluster notesInline add=notesEmailAddr
85 highlight def link notesEmailAddr notesSubtleURL
86 syntax match notesUnixPath /\k\@<![\/~]\S\+\(\/\|[^ [:punct:]]\)/
87 syntax cluster notesInline add=notesUnixPath
88 highlight def link notesUnixPath Directory
89 syntax match notesPathLnum /:\d\+/ contained containedin=notesUnixPath
90 highlight def link notesPathLnum Comment
91 syntax match notesWindowsPath /\k\@<![A-Za-z]:\S\+\([\\/]\|[^ [:punct:]]\)/
92 syntax cluster notesInline add=notesWindowsPath
93 highlight def link notesWindowsPath Directory
95 " Highlight TODO, DONE, FIXME and XXX markers. {{{2
96 syntax match notesTodo /\<TODO\>/
97 syntax match notesXXX /\<XXX\>/
98 syntax match notesFixMe /\<FIXME\>/
99 syntax match notesDoneItem /^\(\s\+\).*\<DONE\>.*\(\n\1\s.*\)*/ contains=@notesInline
100 syntax match notesDoneMarker /\<DONE\>/ containedin=notesDoneItem
101 highlight def link notesTodo WarningMsg
102 highlight def link notesXXX WarningMsg
103 highlight def link notesFixMe WarningMsg
104 highlight def link notesDoneItem Comment
105 highlight def link notesDoneMarker Question
107 " Highlight Vim command names in :this notation. {{{2
108 syntax match notesVimCmd /:\w\+\(!\|\>\)/ contains=ALLBUT,@Spell
109 syntax cluster notesInline add=notesVimCmd
110 highlight def link notesVimCmd Special
112 " Block level elements. {{{1
114 " The first line of each note contains the title. {{{2
115 syntax match notesTitle /^.*\%1l.*$/ contains=@notesInline
116 highlight def link notesTitle ModeMsg
118 " Short sentences ending in a colon are considered headings. {{{2
119 syntax match notesShortHeading /^\s*\zs\u.\{1,50}\k:\ze\(\s\|$\)/ contains=@notesInline
120 highlight def link notesShortHeading Title
122 " Atx style headings are also supported. {{{2
123 syntax match notesAtxHeading /^#\+.*/ contains=notesAtxMarker,@notesInline
124 highlight def link notesAtxHeading Title
125 syntax match notesAtxMarker /^#\+/ contained
126 highlight def link notesAtxMarker Comment
128 " E-mail style block quotes are highlighted as comments. {{{2
129 syntax match notesBlockQuote /\(^\s*>.*\n\)\+/ contains=@notesInline
130 highlight def link notesBlockQuote Comment
132 " Horizontal rulers. {{{2
133 syntax match notesRule /\(^\s\+\)\zs\*\s\*\s\*$/
134 highlight def link notesRule Comment
136 " Highlight embedded blocks of source code, log file messages, basically anything Vim can highlight. {{{2
137 " NB: I've escaped these markers so that Vim doesn't interpret them when editing this file…
138 syntax match notesCodeStart /{{[{]\w*/
139 syntax match notesCodeEnd /}}[}]/
140 highlight def link notesCodeStart Ignore
141 highlight def link notesCodeEnd Ignore
142 call xolox#notes#highlight_sources('notesCodeStart', 'notesCodeEnd')
144 " Hide mode line at end of file. {{{2
145 syntax match notesModeLine /\_^vim:.*\_s*\%$/
146 highlight def link notesModeLine LineNr
148 syntax match notesLastEdited /(last edited \(today\|yesterday\|\w\+, \w\+ \d\+, \d\+\))/
149 highlight def link notesLastEdited LineNr
153 " Set the currently loaded syntax mode.
154 let b:current_syntax = 'notes'
156 " vim: ts=2 sw=2 et bomb fdl=1