blob: ec5739faa42eb1176f5169e2469c7074bf3a2d95 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
2" Language: Vim help file
Christian Brabandte978b452023-08-13 10:33:05 +02003" Maintainer: The Vim Project <https://github.com/vim/vim>
Shougo Matsushita5ddcecf2024-12-25 10:55:48 +01004" Last Change: 2024 Dec 25
Christian Brabandte978b452023-08-13 10:33:05 +02005" Former Maintainer: Bram Moolenaar <Bram@vim.org>
Bram Moolenaar071d4272004-06-13 20:20:40 +00006
Bram Moolenaard857f0e2005-06-21 22:37:39 +00007" Quit when a (custom) syntax file was already loaded
8if exists("b:current_syntax")
Bram Moolenaar071d4272004-06-13 20:20:40 +00009 finish
10endif
11
Bram Moolenaar6ee8d892012-01-10 14:55:01 +010012let s:cpo_save = &cpo
13set cpo&vim
14
Shougo Matsushita5ddcecf2024-12-25 10:55:48 +010015if !exists('g:help_example_languages')
16 let g:help_example_languages = #{ vim: 'vim' }
17endif
18
Bram Moolenaard13166e2022-11-18 21:49:57 +000019syn match helpHeadline "^[A-Z.][-A-Z0-9 .,()_']*?\=\ze\(\s\+\*\|$\)"
Bram Moolenaar6c35bea2012-07-25 17:49:10 +020020syn match helpSectionDelim "^===.*===$"
21syn match helpSectionDelim "^---.*--$"
Shougo Matsushita6fea0a52024-12-15 20:47:37 +010022
Bram Moolenaardd007ed2013-07-09 15:44:17 +020023if has("conceal")
Shougo Matsushita5ddcecf2024-12-25 10:55:48 +010024 syn region helpExample matchgroup=helpIgnore
25 \ start="\%(^\| \)>[a-z0-9]*$" end="^[^ \t]"me=e-1 end="^<" concealends
Shougo Matsushita6fea0a52024-12-15 20:47:37 +010026 else
Shougo Matsushita5ddcecf2024-12-25 10:55:48 +010027 syn region helpExample matchgroup=helpIgnore
28 \ start="\%(^\| \)>[a-z0-9]*$" end="^[^ \t]"me=e-1 end="^<"
Bram Moolenaardd007ed2013-07-09 15:44:17 +020029endif
Shougo Matsushita5ddcecf2024-12-25 10:55:48 +010030
31for [s:lang, s:syntax] in g:help_example_languages->items()
32 unlet! b:current_syntax
33 " silent! to prevent E403
34 execute 'silent! syn include' $'@helpExampleHighlight_{s:lang}'
35 \ $'syntax/{s:syntax}.vim'
36
37 execute $'syn region helpExampleHighlight_{s:lang} matchgroup=helpIgnore'
38 \ $'start=/\%(^\| \)>{s:lang}$/'
39 \ 'end=/^[^ \t]/me=e-1 end=/^</'
40 \ (has("conceal") ? 'concealends' : '')
41 \ $'contains=@helpExampleHighlight_{s:lang} keepend'
42endfor
43unlet! s:lang s:syntax
44
Bram Moolenaar071d4272004-06-13 20:20:40 +000045if has("ebcdic")
Bram Moolenaar18144c82006-04-12 21:52:12 +000046 syn match helpHyperTextJump "\\\@<!|[^"*|]\+|" contains=helpBar
Bram Moolenaar7fc904b2006-04-13 20:37:35 +000047 syn match helpHyperTextEntry "\*[^"*|]\+\*\s"he=e-1 contains=helpStar
48 syn match helpHyperTextEntry "\*[^"*|]\+\*$" contains=helpStar
Bram Moolenaar071d4272004-06-13 20:20:40 +000049else
Bram Moolenaar18144c82006-04-12 21:52:12 +000050 syn match helpHyperTextJump "\\\@<!|[#-)!+-~]\+|" contains=helpBar
Bram Moolenaar7fc904b2006-04-13 20:37:35 +000051 syn match helpHyperTextEntry "\*[#-)!+-~]\+\*\s"he=e-1 contains=helpStar
52 syn match helpHyperTextEntry "\*[#-)!+-~]\+\*$" contains=helpStar
Bram Moolenaar071d4272004-06-13 20:20:40 +000053endif
Bram Moolenaar97293012011-07-18 19:40:27 +020054if has("conceal")
Bram Moolenaarfa13eef2013-02-06 17:34:04 +010055 syn match helpBar contained "|" conceal
56 syn match helpBacktick contained "`" conceal
Bram Moolenaar97293012011-07-18 19:40:27 +020057 syn match helpStar contained "\*" conceal
58else
Bram Moolenaarfa13eef2013-02-06 17:34:04 +010059 syn match helpBar contained "|"
60 syn match helpBacktick contained "`"
Bram Moolenaar97293012011-07-18 19:40:27 +020061 syn match helpStar contained "\*"
62endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000063syn match helpNormal "|.*====*|"
Bram Moolenaarf1568ec2011-12-14 21:17:39 +010064syn match helpNormal "|||"
Bram Moolenaar071d4272004-06-13 20:20:40 +000065syn match helpNormal ":|vim:|" " for :help modeline
Bram Moolenaar251835e2014-02-24 02:51:51 +010066syn match helpVim "\<Vim version [0-9][0-9.a-z]*"
Bram Moolenaar071d4272004-06-13 20:20:40 +000067syn match helpVim "VIM REFERENCE.*"
68syn match helpOption "'[a-z]\{2,\}'"
69syn match helpOption "'t_..'"
Bram Moolenaar9fbdbb82022-09-27 17:30:34 +010070syn match helpNormal "'ab'"
Bram Moolenaar7cba6c02013-09-05 22:13:31 +020071syn match helpCommand "`[^` \t]\+`"hs=s+1,he=e-1 contains=helpBacktick
Christian Brabandt4bfb8992024-10-16 21:58:17 +020072" doesn't allow a . directly after an ending backtick. See :helpgrep `[^`,]\+ [^`,]\+`\.
73syn match helpCommand "\(^\|[^a-z"[]\)\zs`[^`]\+`\ze\([^a-z\t."']\|[.?!]\?$\)"hs=s+1,he=e-1 contains=helpBacktick
Bram Moolenaar071d4272004-06-13 20:20:40 +000074syn match helpHeader "\s*\zs.\{-}\ze\s\=\~$" nextgroup=helpIgnore
Bram Moolenaar166af9b2010-11-16 20:34:40 +010075syn match helpGraphic ".* \ze`$" nextgroup=helpIgnore
Bram Moolenaar97293012011-07-18 19:40:27 +020076if has("conceal")
77 syn match helpIgnore "." contained conceal
78else
79 syn match helpIgnore "." contained
80endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000081syn keyword helpNote note Note NOTE note: Note: NOTE: Notes Notes:
Milly6c2fc372024-10-16 22:11:17 +020082syn match helpNote "\c(note\(:\|\>\)"ms=s+1
Bram Moolenaar3ec574f2017-06-13 18:12:01 +020083syn keyword helpWarning WARNING WARNING: Warning:
84syn keyword helpDeprecated DEPRECATED DEPRECATED: Deprecated:
Bram Moolenaar071d4272004-06-13 20:20:40 +000085syn match helpSpecial "\<N\>"
86syn match helpSpecial "\<N\.$"me=e-1
87syn match helpSpecial "\<N\.\s"me=e-2
88syn match helpSpecial "(N\>"ms=s+1
Bram Moolenaar01164a62017-11-02 22:58:42 +010089
Bram Moolenaar071d4272004-06-13 20:20:40 +000090syn match helpSpecial "\[N]"
Milly89872f52024-10-05 17:16:18 +020091" avoid highlighting N N in quickref.txt
Bram Moolenaar071d4272004-06-13 20:20:40 +000092syn match helpSpecial "N N"he=s+1
93syn match helpSpecial "Nth"me=e-2
94syn match helpSpecial "N-1"me=e-2
Milly6c2fc372024-10-16 22:11:17 +020095" highlighting N for :resize in windows.txt
96syn match helpSpecial "] -N\>"ms=s+3
97syn match helpSpecial "+N\>"ms=s+1
98syn match helpSpecial "\[+-]N\>"ms=s+4
Milly89872f52024-10-05 17:16:18 +020099" highlighting N of cinoptions-values in indent.txt
100syn match helpSpecial "^\t-\?\zsNs\?\s"me=s+1
101" highlighting N of cinoptions-values in indent.txt
102syn match helpSpecial "^\t[>enf{}^L:=lbghNEpti+cC/(uUwWkmMjJ)*#P]N\s"ms=s+2,me=e-1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000103syn match helpSpecial "{[-a-zA-Z0-9'"*+/:%#=[\]<>.,]\+}"
104syn match helpSpecial "\s\[[-a-z^A-Z0-9_]\{2,}]"ms=s+1
105syn match helpSpecial "<[-a-zA-Z0-9_]\+>"
106syn match helpSpecial "<[SCM]-.>"
107syn match helpNormal "<---*>"
108syn match helpSpecial "\[range]"
109syn match helpSpecial "\[line]"
110syn match helpSpecial "\[count]"
111syn match helpSpecial "\[offset]"
112syn match helpSpecial "\[cmd]"
Bram Moolenaar4d8f4762021-06-27 15:18:56 +0200113syn match helpNormal "vim9\[cmd]"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000114syn match helpSpecial "\[num]"
115syn match helpSpecial "\[+num]"
116syn match helpSpecial "\[-num]"
117syn match helpSpecial "\[+cmd]"
118syn match helpSpecial "\[++opt]"
119syn match helpSpecial "\[arg]"
120syn match helpSpecial "\[arguments]"
121syn match helpSpecial "\[ident]"
122syn match helpSpecial "\[addr]"
123syn match helpSpecial "\[group]"
Bram Moolenaar01164a62017-11-02 22:58:42 +0100124" Don't highlight [converted] and others that do not have a tag
125syn match helpNormal "\[\(readonly\|fifo\|socket\|converted\|crypted\)]"
126
Bram Moolenaar071d4272004-06-13 20:20:40 +0000127syn match helpSpecial "CTRL-."
Christian Brabandtd3b55d72024-10-08 20:20:23 +0200128syn match helpSpecial "CTRL-<\a\+>"
Bram Moolenaar0c0734d2019-11-26 21:44:46 +0100129syn match helpSpecial "CTRL-SHIFT-."
Bram Moolenaar071d4272004-06-13 20:20:40 +0000130syn match helpSpecial "CTRL-Break"
131syn match helpSpecial "CTRL-PageUp"
132syn match helpSpecial "CTRL-PageDown"
133syn match helpSpecial "CTRL-Insert"
134syn match helpSpecial "CTRL-Del"
135syn match helpSpecial "CTRL-{char}"
136syn region helpNotVi start="{Vi[: ]" start="{not" start="{only" end="}" contains=helpLeadBlank,helpHyperTextJump
137syn match helpLeadBlank "^\s\+" contained
138
139" Highlight group items in their own color.
140syn match helpComment "\t[* ]Comment\t\+[a-z].*"
141syn match helpConstant "\t[* ]Constant\t\+[a-z].*"
142syn match helpString "\t[* ]String\t\+[a-z].*"
143syn match helpCharacter "\t[* ]Character\t\+[a-z].*"
144syn match helpNumber "\t[* ]Number\t\+[a-z].*"
145syn match helpBoolean "\t[* ]Boolean\t\+[a-z].*"
146syn match helpFloat "\t[* ]Float\t\+[a-z].*"
147syn match helpIdentifier "\t[* ]Identifier\t\+[a-z].*"
148syn match helpFunction "\t[* ]Function\t\+[a-z].*"
149syn match helpStatement "\t[* ]Statement\t\+[a-z].*"
150syn match helpConditional "\t[* ]Conditional\t\+[a-z].*"
151syn match helpRepeat "\t[* ]Repeat\t\+[a-z].*"
152syn match helpLabel "\t[* ]Label\t\+[a-z].*"
153syn match helpOperator "\t[* ]Operator\t\+["a-z].*"
154syn match helpKeyword "\t[* ]Keyword\t\+[a-z].*"
155syn match helpException "\t[* ]Exception\t\+[a-z].*"
156syn match helpPreProc "\t[* ]PreProc\t\+[a-z].*"
157syn match helpInclude "\t[* ]Include\t\+[a-z].*"
158syn match helpDefine "\t[* ]Define\t\+[a-z].*"
159syn match helpMacro "\t[* ]Macro\t\+[a-z].*"
160syn match helpPreCondit "\t[* ]PreCondit\t\+[a-z].*"
161syn match helpType "\t[* ]Type\t\+[a-z].*"
162syn match helpStorageClass "\t[* ]StorageClass\t\+[a-z].*"
163syn match helpStructure "\t[* ]Structure\t\+[a-z].*"
164syn match helpTypedef "\t[* ]Typedef\t\+[Aa-z].*"
165syn match helpSpecial "\t[* ]Special\t\+[a-z].*"
166syn match helpSpecialChar "\t[* ]SpecialChar\t\+[a-z].*"
167syn match helpTag "\t[* ]Tag\t\+[a-z].*"
168syn match helpDelimiter "\t[* ]Delimiter\t\+[a-z].*"
169syn match helpSpecialComment "\t[* ]SpecialComment\t\+[a-z].*"
170syn match helpDebug "\t[* ]Debug\t\+[a-z].*"
171syn match helpUnderlined "\t[* ]Underlined\t\+[a-z].*"
172syn match helpError "\t[* ]Error\t\+[a-z].*"
173syn match helpTodo "\t[* ]Todo\t\+[a-z].*"
174
Milly6c2fc372024-10-16 22:11:17 +0200175syn match helpURL `\v<(((https?|ftp|gopher)://|(mailto|file|news):)[^'" \t<>{}]+|(www|web|w3)[a-z0-9_-]*\.[a-z0-9._-]+\.[^'" \t<>{}]+)[a-zA-Z0-9/]`
Bram Moolenaar071d4272004-06-13 20:20:40 +0000176
Romain Lafourcade124371c2024-01-07 15:08:31 +0100177syn match helpDiffAdded "\t[* ]Added\t\+[a-z].*"
178syn match helpDiffChanged "\t[* ]Changed\t\+[a-z].*"
179syn match helpDiffRemoved "\t[* ]Removed\t\+[a-z].*"
180
Bram Moolenaar071d4272004-06-13 20:20:40 +0000181" Additionally load a language-specific syntax file "help_ab.vim".
Bram Moolenaar13fcaaf2005-04-15 21:13:42 +0000182let s:i = match(expand("%"), '\.\a\ax$')
183if s:i > 0
184 exe "runtime syntax/help_" . strpart(expand("%"), s:i + 1, 2) . ".vim"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000185endif
186
187syn sync minlines=40
188
189
190" Define the default highlighting.
Bram Moolenaard857f0e2005-06-21 22:37:39 +0000191" Only used when an item doesn't have highlighting yet
Bram Moolenaard857f0e2005-06-21 22:37:39 +0000192hi def link helpIgnore Ignore
Bram Moolenaar36782082013-11-28 13:53:34 +0100193hi def link helpHyperTextJump Identifier
Bram Moolenaar18144c82006-04-12 21:52:12 +0000194hi def link helpBar Ignore
Bram Moolenaarfa13eef2013-02-06 17:34:04 +0100195hi def link helpBacktick Ignore
Bram Moolenaar7fc904b2006-04-13 20:37:35 +0000196hi def link helpStar Ignore
Bram Moolenaard857f0e2005-06-21 22:37:39 +0000197hi def link helpHyperTextEntry String
198hi def link helpHeadline Statement
199hi def link helpHeader PreProc
200hi def link helpSectionDelim PreProc
201hi def link helpVim Identifier
Bram Moolenaard38b0552012-04-25 19:07:41 +0200202hi def link helpCommand Comment
Bram Moolenaard857f0e2005-06-21 22:37:39 +0000203hi def link helpExample Comment
204hi def link helpOption Type
205hi def link helpNotVi Special
206hi def link helpSpecial Special
207hi def link helpNote Todo
Bram Moolenaar64d8e252016-09-06 22:12:34 +0200208hi def link helpWarning Todo
Bram Moolenaar3ec574f2017-06-13 18:12:01 +0200209hi def link helpDeprecated Todo
Bram Moolenaar071d4272004-06-13 20:20:40 +0000210
Bram Moolenaard857f0e2005-06-21 22:37:39 +0000211hi def link helpComment Comment
212hi def link helpConstant Constant
213hi def link helpString String
214hi def link helpCharacter Character
215hi def link helpNumber Number
216hi def link helpBoolean Boolean
217hi def link helpFloat Float
218hi def link helpIdentifier Identifier
219hi def link helpFunction Function
220hi def link helpStatement Statement
221hi def link helpConditional Conditional
222hi def link helpRepeat Repeat
223hi def link helpLabel Label
224hi def link helpOperator Operator
225hi def link helpKeyword Keyword
226hi def link helpException Exception
227hi def link helpPreProc PreProc
228hi def link helpInclude Include
229hi def link helpDefine Define
230hi def link helpMacro Macro
231hi def link helpPreCondit PreCondit
232hi def link helpType Type
233hi def link helpStorageClass StorageClass
234hi def link helpStructure Structure
235hi def link helpTypedef Typedef
236hi def link helpSpecialChar SpecialChar
237hi def link helpTag Tag
238hi def link helpDelimiter Delimiter
239hi def link helpSpecialComment SpecialComment
240hi def link helpDebug Debug
241hi def link helpUnderlined Underlined
242hi def link helpError Error
243hi def link helpTodo Todo
Bram Moolenaare344bea2005-09-01 20:46:49 +0000244hi def link helpURL String
Romain Lafourcade124371c2024-01-07 15:08:31 +0100245hi def link helpDiffAdded Added
246hi def link helpDiffChanged Changed
247hi def link helpDiffRemoved Removed
Bram Moolenaar071d4272004-06-13 20:20:40 +0000248
Bram Moolenaar2d8ed022022-05-21 13:08:16 +0100249if has('textprop') && expand('%:p') =~ '[/\\]doc[/\\]syntax.txt'
Bram Moolenaard899e512022-05-07 21:54:03 +0100250 " highlight groups with their respective color
251 import 'dist/vimhelp.vim'
252 call vimhelp.HighlightGroups()
253endif
254
Bram Moolenaar071d4272004-06-13 20:20:40 +0000255let b:current_syntax = "help"
256
Bram Moolenaar6ee8d892012-01-10 14:55:01 +0100257let &cpo = s:cpo_save
258unlet s:cpo_save
Bram Moolenaar071d4272004-06-13 20:20:40 +0000259" vim: ts=8 sw=2