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