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