robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

zeertzjqMerge pull request #40437 from zeertzjq/vim-9.2.07164de7038762

master
7.9 KiB279 linesraw
1" Vim syntax file
2" Language:     Haskell Cabal Build file
3" Author:	Vincent Berthoux <twinside@gmail.com>
4" Maintainer:   Marcin Szamotulski <profunctor@pm.me>
5" Previous Maintainer:	Vincent Berthoux <twinside@gmail.com>
6" File Types:   .cabal
7" Last Change:  22 Oct 2022
8"
9" 2026 Apr 29 by Léana: add missing haskell language editions
10" 2026 Apr 20 by Vim project: remove wrong oneline keyword #20018
11" 2026 Jun 26 by Vim project: add elif keyword #20623
12"
13" v1.6: Added support for foreign-libraries
14"       Added highlighting for various fields
15" v1.5: Incorporated changes from
16"       https://github.com/sdiehl/haskell-vim-proto/blob/master/vim/syntax/cabal.vim
17"       Use `syn keyword` instead of `syn match`.
18"       Added cabalStatementRegion to limit matches of keywords, which fixes
19"       the highlighting of description's value.
20"       Added cabalVersionRegion to limit the scope of cabalVersionOperator
21"       and cabalVersion matches.
22"       Added cabalLanguage keyword.
23"       Added calbalTitle, cabalAuthor and cabalMaintainer syntax groups.
24"       Added ! and ^>= operators (calbal 2.0)
25"       Added build-type keywords
26" v1.4: Add benchmark support, thanks to Simon Meier
27" v1.3: Updated to the last version of cabal
28"       Added more highlighting for cabal function, true/false
29"       and version number. Also added missing comment highlighting.
30"       Cabal known compiler are highlighted too.
31"
32" V1.2: Added cpp-options which was missing. Feature implemented
33"       by GHC, found with a GHC warning, but undocumented.
34"       Whatever...
35"
36" v1.1: Fixed operator problems and added ftdetect file
37"       (thanks to Sebastian Schwarz)
38"
39" v1.0: Cabal syntax in vimball format
40"       (thanks to Magnus Therning)
41
42" quit when a syntax file was already loaded
43if exists("b:current_syntax")
44  finish
45endif
46
47" this file uses line continuation
48let s:cpo_save = &cpo
49set cpo&vim
50
51" set iskeyword for this syntax script
52syn iskeyword @,48-57,192-255,-
53
54" Case sensitive matches
55syn case match
56
57syn keyword cabalConditional	if elif else
58syn keyword cabalFunction	os arche impl flag
59syn match cabalComment		/--.*$/
60
61" Case insensitive matches
62syn case ignore
63
64syn keyword cabalCategory contained
65	\ executable
66	\ library
67	\ benchmark
68	\ test-suite
69	\ source-repository
70	\ flag
71        \ foreign-library
72	\ custom-setup
73	\ common
74syn match cabalCategoryTitle contained /[^{]*\ze{\?/
75syn match cabalCategoryRegion
76	\ contains=cabalCategory,cabalCategoryTitle
77	\ nextgroup=cabalCategory skipwhite
78	\ /^\c\s*\(contained\|executable\|library\|benchmark\|test-suite\|source-repository\|flag\|foreign-library\|custom-setup\|common\)\+\s*\%(.*$\|$\)/
79syn keyword cabalTruth true false
80
81" cabalStatementRegion which limits the scope of cabalStatement keywords, this
82" way they are not highlighted in description.
83syn region cabalStatementRegion start=+^\s*\(--\)\@<!\k\+\s*:+ end=+:+
84syn keyword cabalStatement contained containedin=cabalStatementRegion
85	\ default-language
86	\ default-extensions
87	\ author
88        \ autogen-includes
89        \ autogen-modules
90        \ asm-sources
91        \ asm-options
92	\ branch
93	\ bug-reports
94	\ build-depends
95	\ build-tools
96        \ build-tool-depends
97	\ build-type
98	\ buildable
99	\ c-sources
100	\ cabal-version
101	\ category
102	\ cc-options
103	\ copyright
104        \ cmm-sources
105        \ cmm-options
106	\ cpp-options
107        \ cxx-options
108        \ cxx-sources
109	\ data-dir
110	\ data-files
111	\ default
112        \ default-extensions
113	\ description
114	\ executable
115	\ exposed-modules
116	\ exposed
117	\ extensions
118        \ extra-bundled-libraries
119	\ extra-doc-files
120	\ extra-dynamic-library-flavours
121        \ extra-framework-dirs
122        \ extra-ghci-libraries
123	\ extra-lib-dirs
124	\ extra-lib-dirs-static
125	\ extra-libraries
126	\ extra-libraries-static
127	\ extra-library-flavours
128	\ extra-source-files
129	\ extra-tmp-files
130	\ for example
131	\ frameworks
132	\ ghc-options
133	\ ghc-prof-options
134	\ ghc-shared-options
135        \ ghcjs-options
136        \ ghcjs-prof-options
137        \ ghcjs-shared-options
138	\ homepage
139        \ hs-source-dir
140	\ hs-source-dirs
141	\ hugs-options
142	\ import
143	\ include-dirs
144	\ includes
145	\ install-includes
146        \ js-sources
147	\ ld-options
148        \ lib-version-info
149        \ lib-version-linux
150	\ license
151	\ license-file
152	\ location
153	\ main-is
154	\ maintainer
155	\ manual
156        \ mixins
157	\ module
158        \ mod-def-file
159	\ name
160	\ nhc98-options
161        \ options
162	\ other-extensions
163        \ other-language
164        \ other-languages
165	\ other-modules
166	\ package-url
167	\ pkgconfig-depends
168        \ scope
169	\ setup-depends
170        \ signatures
171	\ stability
172	\ subdir
173	\ synopsis
174        \ reexported-modules
175	\ tag
176	\ tested-with
177        \ test-module
178	\ type
179	\ version
180	\ virtual-modules
181
182" operators and version operators
183syn match cabalOperator /&&\|||\|!/
184syn match cabalVersionOperator contained
185	\ /!\|==\|\^\?>=\|<=\|<\|>/
186" match version: `[%]\@<!` is to exclude `%20` in http addresses.
187syn match cabalVersion contained
188	\ /[%$_-]\@<!\<\d\+\%(\.\d\+\)*\%(\.\*\)\?\>/
189" cabalVersionRegion which limits the scope of cabalVersion pattern.
190syn match cabalVersionRegionA
191	\ contains=cabalVersionOperator,cabalVersion
192	\ keepend
193	\ /\%(==\|\^\?>=\|<=\|<\|>\)\s*\d\+\%(\.\d\+\)*\%(\.\*\)\?\>/
194" version inside `version: ...`
195syn match cabalVersionRegionB
196	\ contains=cabalStatementRegion,cabalVersionOperator,cabalVersion
197	\ /^\s*\%(cabal-\)\?version\s*:.*$/
198
199" See the following link for all Haskell language editions supported by Cabal.
200" https://cabal.readthedocs.io/en/stable/cabal-package-description-file.html#pkg-field-default-language
201syn keyword cabalLanguage Haskell98 Haskell2010 GHC2021 GHC2024
202
203" title region
204syn match cabalName contained /:\@<=.*/
205syn match cabalNameRegion
206	\ contains=cabalStatementRegion,cabalName
207	\ nextgroup=cabalStatementRegion
208	\ /^\c\s*name\s*:.*$/
209
210" author region
211syn match cabalAuthor contained /:\@<=.*/
212syn match cabalAuthorRegion
213	\ contains=cabalStatementRegion,cabalStatement,cabalAuthor
214	\ nextgroup=cabalStatementRegion
215	\ /^\c\s*author\s*:.*$/
216
217" maintainer region
218syn match cabalMaintainer contained /:\@<=.*/
219syn match cabalMaintainerRegion
220	\ contains=cabalStatementRegion,cabalStatement,cabalMaintainer
221	\ nextgroup=cabalStatementRegion
222	\ /^\c\s*maintainer\s*:.*$/
223
224" license region
225syn match cabalLicense contained /:\@<=.*/
226syn match cabalLicenseRegion
227	\ contains=cabalStatementRegion,cabalStatement,cabalLicense
228	\ nextgroup=cabalStatementRegion
229	\ /^\c\s*license\s*:.*$/
230
231" license-file region
232syn match cabalLicenseFile contained /:\@<=.*/
233syn match cabalLicenseFileRegion
234	\ contains=cabalStatementRegion,cabalStatement,cabalLicenseFile
235	\ nextgroup=cabalStatementRegion
236	\ /^\c\s*license-file\s*:.*$/
237
238" tested-with region with compilers and versions
239syn keyword cabalCompiler contained ghc nhc yhc hugs hbc helium jhc lhc
240syn match cabalTestedWithRegion
241	\ contains=cabalStatementRegion,cabalStatement,cabalCompiler,cabalVersionRegionA
242	\ nextgroup=cabalStatementRegion
243	\ /^\c\s*tested-with\s*:.*$/
244
245" build type keywords
246syn keyword cabalBuildType contained
247	\ simple custom configure
248syn match cabalBuildTypeRegion
249	\ contains=cabalStatementRegion,cabalStatement,cabalBuildType
250	\ nextgroup=cabalStatementRegion
251	\ /^\c\s*build-type\s*:.*$/
252
253" Define the default highlighting.
254" Only when an item doesn't have highlighting yet
255hi def link cabalName	      Title
256hi def link cabalAuthor	      Normal
257hi def link cabalMaintainer   Normal
258hi def link cabalCategoryTitle Title
259hi def link cabalLicense      Normal
260hi def link cabalLicenseFile  Normal
261hi def link cabalBuildType    Keyword
262hi def link cabalVersion      Number
263hi def link cabalTruth        Boolean
264hi def link cabalComment      Comment
265hi def link cabalStatement    Statement
266hi def link cabalLanguage     Type
267hi def link cabalCategory     Type
268hi def link cabalFunction     Function
269hi def link cabalConditional  Conditional
270hi def link cabalOperator     Operator
271hi def link cabalVersionOperator Operator
272hi def link cabalCompiler     Constant
273
274let b:current_syntax = "cabal"
275
276let &cpo = s:cpo_save
277unlet! s:cpo_save
278
279" vim: ts=8