Skip to content

Commit f5b6b8d

Browse files
authored
Merge pull request #41 from supercollider/topic/scdoc
add scdoc syntax highlighting
2 parents 551c477 + 562aa91 commit f5b6b8d

File tree

2 files changed

+210
-0
lines changed

2 files changed

+210
-0
lines changed

plugin/supercollider.vim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ au BufEnter,BufWinEnter,BufNewFile,BufRead *.sc,*.scd runtime ftplugin/supercoll
1111
au BufEnter,BufWinEnter,BufNewFile,BufRead *.sc,*.scd runtime indent/sc_indent.vim
1212
au BufEnter,BufWinEnter,BufNewFile,BufRead *.sc,*.scd let &iskeyword="@,48-57,_,192-255"
1313

14+
au BufEnter,BufWinEnter,BufNewFile,BufRead *.schelp set filetype=scdoc
15+
au BufEnter,BufWinEnter,BufNewFile,BufRead *.schelp runtime syntax/scdoc.vim
16+
1417
" set this via EXPORT ... if you want to change it
1518
if exists($SCVIM_TAGFILE)
1619
let s:sclangTagsFile = $SCVIM_TAGFILE

syntax/scdoc.vim

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
" This file is part of SCVIM.
2+
"
3+
" SCVIM is free software: you can redistribute it and/or modify
4+
" it under the terms of the GNU General Public License as published by
5+
" the Free Software Foundation, either version 3 of the License, or
6+
" (at your option) any later version.
7+
"
8+
" SCVIM is distributed in the hope that it will be useful,
9+
" but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
" GNU General Public License for more details.
12+
"
13+
" You should have received a copy of the GNU General Public License
14+
" along with SCVIM. If not, see <http://www.gnu.org/licenses/>.
15+
"
16+
" Vim syntax file
17+
" Language: scdoc (SuperCollider help file markup)
18+
19+
" For version 5.x: Clear all syntax items
20+
" For version 6.x: Quit when a syntax file was already loaded
21+
if version < 600
22+
syntax clear
23+
elseif exists("b:current_syntax")
24+
finish
25+
endif
26+
27+
setlocal iskeyword=a-z,A-Z,48-57,_
28+
29+
syn case ignore
30+
31+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
32+
" header tags
33+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
34+
35+
" TODO: highlighting of remainder of lines?
36+
syn match scdocTitle /\<title::/
37+
syn match scdocCategories /\<categories::/
38+
syn match scdocRelated /\<related::/
39+
syn match scdocSummary /\<summary::/
40+
syn match scdocRedirect /\<redirect::/
41+
42+
" deprecated
43+
syn match scdocClass /\<class::/
44+
45+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
46+
" section tags
47+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
48+
49+
" TODO: intelligent highlighting?
50+
syn match scdocSection /\<section::/
51+
syn match scdocDescription /\<description::/
52+
syn match scdocClassmethods /\<classmethods::/
53+
syn match scdocInstancemethods /\<instancemethods::/
54+
syn match scdocExamples /\<examples::/
55+
syn match scdocSubsection /\<subsection::/
56+
57+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
58+
" method tags
59+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
60+
61+
" TODO: intelligent highlighting
62+
syn match scdocMethod /\<method::/
63+
syn match scdocPrivate /\<private::/
64+
syn match scdocCopymethod /\<copymethod::/
65+
syn match scdocArgument /\<argument::/
66+
syn match scdocReturns /\<returns::/
67+
syn match scdocDiscussion /\<discussion::/
68+
69+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
70+
" modal tags
71+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
72+
73+
" TODO: link and image highlighting based on #-separators
74+
syn region scdocStrong matchgroup=scdocSimpleTag start=/\<strong::/ skip=/\\::/ end=/::/
75+
syn region scdocEmphasis matchgroup=scdocSimpleTag start=/\<emphasis::/ skip=/\\::/ end=/::/
76+
syn region scdocSoft matchgroup=scdocSimpleTag start=/\<soft::/ skip=/\\::/ end=/::/
77+
78+
" only highlight the first part of the link. order is important here
79+
syn region scdocRealLink keepend start=// end=/::/he=s-1 contained
80+
syn region scdocRealLink keepend start=// end=/#/he=s-1 contained
81+
syn region scdocRealLink keepend start=/\(\<::[^#]*#\)\@<=/ end=/::/he=s-1 contained
82+
syn region scdocRealLink keepend start=/\(\<::[^#]*#\)\@<=/ end=/#/he=s-1 contained
83+
syn region scdocLink keepend matchgroup=scdocSimpleTag start=/\<link::/ skip=/\\::/ end=/::/ contains=scdocRealLink
84+
85+
syn region scdocAnchor matchgroup=scdocSimpleTag start=/\<anchor::/ skip=/\\::/ end=/::/
86+
syn region scdocImage keepend matchgroup=scdocSimpleTag start=/\<image::/ skip=/\\::/ end=/::/ contains=scdocRealLink
87+
88+
89+
" teletype and code have inline and block forms
90+
" NOTE: make sure oneline version is last so it has priority!
91+
syn region scdocTeletype matchgroup=scdocSimpleTag start=/\<teletype::/ end=/^::/
92+
syn region scdocTeletype oneline matchgroup=scdocSimpleTag start=/\<teletype::/ skip=/\\::/ end=/::/
93+
94+
" code (see :syn-include)
95+
" keepend needed to avoid :: being matched as supercollider code
96+
syn include @SCCode syntax/supercollider.vim
97+
syn region scdocCode keepend matchgroup=scdocSimpleTag start=/\<code::/ end=/^::/ contains=@SCCode
98+
syn region scdocCode oneline keepend matchgroup=scdocSimpleTag start=/\<code::/ skip=/\\::/ end=/::/ contains=@SCCode
99+
100+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
101+
" notes and warnings
102+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
103+
104+
syn cluster SCDocModalTag contains=
105+
\scdocStrong,
106+
\scdocEmphasis,
107+
\scdocSoft,
108+
\scdocLink,
109+
\scdocAnchor,
110+
\scdocImage,
111+
\scdocCode,
112+
\scdocTeletype
113+
114+
syn region scdocNote matchgroup=scdocSimpleTag start=/\<note::/ skip=/\\::/ end=/::/ contains=@SCDocModalTag
115+
syn region scdocWarning matchgroup=scdocSimpleTag start=/\<warning::/ skip=/\\::/ end=/::/ contains=@SCDocModalTag
116+
syn region scdocFootnote matchgroup=scdocSimpleTag start=/\<footnote::/ skip=/\\::/ end=/::/ contains=@SCDocModalTag
117+
118+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
119+
" lists and tables
120+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
121+
122+
syn match scdocBullet /#\@<!##/ contained
123+
syn match scdocColumnSep /|\@<!||/ contained
124+
125+
syn region scdocTable matchgroup=scdocSimpleTag
126+
\ start=/\<Table::/ skip=/\\::/ end=/::/
127+
\ contains=@SCDocModalTag,scdocBullet,scdocColumnSep,@SCDocStructure
128+
129+
syn region scdocDefinitionList matchgroup=scdocSimpleTag
130+
\ start=/\<DefinitionList::/ skip=/\\::/ end=/::/
131+
\ contains=@SCDocModalTag,scdocBullet,scdocColumnSep,@SCDocStructure
132+
133+
syn region scdocList matchgroup=scdocSimpleTag
134+
\ start=/\<List::/ skip=/\\::/ end=/::/
135+
\ contains=@SCDocModalTag,scdocBullet,@SCDocStructure
136+
137+
syn region scdocNumberedList matchgroup=scdocSimpleTag
138+
\ start=/\<NumberedList::/ skip=/\\::/ end=/::/
139+
\ contains=@SCDocModalTag,scdocBullet,@SCDocStructure
140+
141+
syn region scdocTree matchgroup=scdocSimpleTag
142+
\ start=/\<Tree::/ skip=/\\::/ end=/::/
143+
\ contains=@SCDocModalTag,scdocBullet,@SCDocStructure
144+
145+
syn cluster SCDocStructure contains=
146+
\scdocTree,
147+
\scdocList,
148+
\scdocTable,
149+
\scdocDefinitionList,
150+
\scdocNumberedList
151+
152+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
153+
" other tags
154+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
155+
156+
syn match scdocKeyword /\<keyword::/
157+
syn match scdocClasstree /\<classtree::/
158+
159+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
160+
" linkage
161+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
162+
163+
syn case match
164+
165+
hi def link scdocTitle Constant
166+
hi def link scdocCategories Constant
167+
hi def link scdocRelated Constant
168+
hi def link scdocSummary Constant
169+
hi def link scdocRedirect Constant
170+
hi def link scdocClass Constant
171+
172+
hi def link scdocSection Identifier
173+
hi def link scdocDescription Identifier
174+
hi def link scdocClassmethods Identifier
175+
hi def link scdocInstancemethods Identifier
176+
hi def link scdocExamples Identifier
177+
178+
hi def link scdocSubsection Type
179+
180+
hi def link scdocMethod Statement
181+
hi def link scdocPrivate Statement
182+
hi def link scdocCopymethod Statement
183+
hi def link scdocArgument Statement
184+
hi def link scdocReturns Statement
185+
hi def link scdocDiscussion Statement
186+
187+
hi scdocStrong cterm=bold
188+
hi scdocEmphasis cterm=italic
189+
hi def link scdocSoft Comment
190+
hi def link scdocRealLink Underlined
191+
" don't link scdocLink or scdocImage
192+
hi def link scdocAnchor Underlined
193+
hi def link scdocTeletype Statement
194+
195+
hi def link scdocNote String
196+
hi def link scdocWarning Todo
197+
hi def link scdocFootnote Comment
198+
199+
hi def link scdocSimpleTag Special
200+
201+
hi def link scdocColumnSep PreProc
202+
hi def link scdocBullet PreProc
203+
204+
hi def link scdocClasstree PreProc
205+
hi def link scdocKeyword PreProc
206+
207+
let b:current_syntax = "schelp"

0 commit comments

Comments
 (0)