codekingpro/portable-devtools
114k
1" Vim syntax file2" Language: Haskell Cabal Build file3" Author: Vincent Berthoux <twinside@gmail.com>4" Maintainer: Marcin Szamotulski <profunctor@pm.me>5" Previous Maintainer: Vincent Berthoux <twinside@gmail.com>6" File Types: .cabal7" Last Change: 22 Oct 20228" v1.6: Added support for foreign-libraries9" Added highlighting for various fields 10" v1.5: Incorporated changes from11" https://github.com/sdiehl/haskell-vim-proto/blob/master/vim/syntax/cabal.vim12" Use `syn keyword` instead of `syn match`.13" Added cabalStatementRegion to limit matches of keywords, which fixes14" the highlighting of description's value.15" Added cabalVersionRegion to limit the scope of cabalVersionOperator16" 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 keywords21" v1.4: Add benchmark support, thanks to Simon Meier22" v1.3: Updated to the last version of cabal23" Added more highlighting for cabal function, true/false24" 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 implemented28" by GHC, found with a GHC warning, but undocumented. 29" Whatever...30"31" v1.1: Fixed operator problems and added ftdetect file32" (thanks to Sebastian Schwarz)33"34" v1.0: Cabal syntax in vimball format35" (thanks to Magnus Therning)36 37" quit when a syntax file was already loaded38if exists("b:current_syntax")39 finish40endif41 42" this file uses line continuation43let s:cpo_save = &cpo44set cpo&vim45 46" set iskeyword for this syntax script47syn iskeyword @,48-57,192-255,-48 49" Case sensitive matches50syn case match51 52syn keyword cabalConditional if else53syn keyword cabalFunction os arche impl flag54syn match cabalComment /--.*$/55 56" Case insensitive matches57syn case ignore58 59syn keyword cabalCategory contained60 \ executable61 \ library62 \ benchmark63 \ test-suite64 \ source-repository65 \ flag66 \ foreign-library67 \ custom-setup68 \ common69syn match cabalCategoryTitle contained /[^{]*\ze{\?/70syn match cabalCategoryRegion71 \ contains=cabalCategory,cabalCategoryTitle72 \ nextgroup=cabalCategory skipwhite73 \ /^\c\s*\(contained\|executable\|library\|benchmark\|test-suite\|source-repository\|flag\|foreign-library\|custom-setup\|common\)\+\s*\%(.*$\|$\)/74syn keyword cabalTruth true false75 76" cabalStatementRegion which limits the scope of cabalStatement keywords, this77" way they are not highlighted in description.78syn region cabalStatementRegion start=+^\s*\(--\)\@<!\k\+\s*:+ end=+:+79syn keyword cabalStatement contained containedin=cabalStatementRegion80 \ default-language81 \ default-extensions82 \ author83 \ autogen-includes84 \ autogen-modules85 \ asm-sources86 \ asm-options87 \ branch88 \ bug-reports89 \ build-depends90 \ build-tools91 \ build-tool-depends92 \ build-type93 \ buildable94 \ c-sources95 \ cabal-version96 \ category97 \ cc-options98 \ copyright99 \ cmm-sources100 \ cmm-options101 \ cpp-options102 \ cxx-options103 \ cxx-sources104 \ data-dir105 \ data-files106 \ default107 \ default-extensions108 \ description109 \ executable110 \ exposed-modules111 \ exposed112 \ extensions113 \ extra-bundled-libraries114 \ extra-doc-files115 \ extra-dynamic-library-flavours116 \ extra-framework-dirs117 \ extra-ghci-libraries118 \ extra-lib-dirs119 \ extra-lib-dirs-static120 \ extra-libraries121 \ extra-libraries-static122 \ extra-library-flavours123 \ extra-source-files124 \ extra-tmp-files125 \ for example126 \ frameworks127 \ ghc-options128 \ ghc-prof-options129 \ ghc-shared-options130 \ ghcjs-options131 \ ghcjs-prof-options132 \ ghcjs-shared-options133 \ homepage134 \ hs-source-dir135 \ hs-source-dirs136 \ hugs-options137 \ import138 \ include-dirs139 \ includes140 \ install-includes141 \ js-sources142 \ ld-options143 \ lib-version-info144 \ lib-version-linux145 \ license146 \ license-file147 \ location148 \ main-is149 \ maintainer150 \ manual151 \ mixins152 \ module153 \ mod-def-file154 \ name155 \ nhc98-options156 \ options157 \ other-extensions158 \ other-language159 \ other-languages160 \ other-modules161 \ package-url162 \ pkgconfig-depends163 \ scope164 \ setup-depends165 \ signatures166 \ stability167 \ subdir168 \ synopsis169 \ reexported-modules170 \ tag171 \ tested-with172 \ test-module173 \ type174 \ version175 \ virtual-modules176 177" operators and version operators178syn match cabalOperator /&&\|||\|!/179syn match cabalVersionOperator contained180 \ /!\|==\|\^\?>=\|<=\|<\|>/181" match version: `[%]\@<!` is to exclude `%20` in http addresses.182syn match cabalVersion contained183 \ /[%$_-]\@<!\<\d\+\%(\.\d\+\)*\%(\.\*\)\?\>/184" cabalVersionRegion which limits the scope of cabalVersion pattern.185syn match cabalVersionRegionA186 \ contains=cabalVersionOperator,cabalVersion187 \ keepend188 \ /\%(==\|\^\?>=\|<=\|<\|>\)\s*\d\+\%(\.\d\+\)*\%(\.\*\)\?\>/189" version inside `version: ...` 190syn match cabalVersionRegionB191 \ contains=cabalStatementRegion,cabalVersionOperator,cabalVersion192 \ /^\s*\%(cabal-\)\?version\s*:.*$/193 194syn keyword cabalLanguage Haskell98 Haskell2010195 196" title region197syn match cabalName contained /:\@<=.*/198syn match cabalNameRegion199 \ contains=cabalStatementRegion,cabalName200 \ nextgroup=cabalStatementRegion201 \ oneline202 \ /^\c\s*name\s*:.*$/203 204" author region205syn match cabalAuthor contained /:\@<=.*/206syn match cabalAuthorRegion207 \ contains=cabalStatementRegion,cabalStatement,cabalAuthor208 \ nextgroup=cabalStatementRegion209 \ oneline210 \ /^\c\s*author\s*:.*$/211 212" maintainer region213syn match cabalMaintainer contained /:\@<=.*/214syn match cabalMaintainerRegion215 \ contains=cabalStatementRegion,cabalStatement,cabalMaintainer216 \ nextgroup=cabalStatementRegion217 \ oneline218 \ /^\c\s*maintainer\s*:.*$/219 220" license region221syn match cabalLicense contained /:\@<=.*/222syn match cabalLicenseRegion223 \ contains=cabalStatementRegion,cabalStatement,cabalLicense224 \ nextgroup=cabalStatementRegion225 \ oneline226 \ /^\c\s*license\s*:.*$/227 228" license-file region229syn match cabalLicenseFile contained /:\@<=.*/230syn match cabalLicenseFileRegion231 \ contains=cabalStatementRegion,cabalStatement,cabalLicenseFile232 \ nextgroup=cabalStatementRegion233 \ oneline234 \ /^\c\s*license-file\s*:.*$/235 236" tested-with region with compilers and versions237syn keyword cabalCompiler contained ghc nhc yhc hugs hbc helium jhc lhc238syn match cabalTestedWithRegion239 \ contains=cabalStatementRegion,cabalStatement,cabalCompiler,cabalVersionRegionA240 \ nextgroup=cabalStatementRegion241 \ oneline242 \ /^\c\s*tested-with\s*:.*$/243 244" build type keywords245syn keyword cabalBuildType contained246 \ simple custom configure247syn match cabalBuildTypeRegion248 \ contains=cabalStatementRegion,cabalStatement,cabalBuildType249 \ nextgroup=cabalStatementRegion250 \ /^\c\s*build-type\s*:.*$/251 252" Define the default highlighting.253" Only when an item doesn't have highlighting yet254hi def link cabalName Title255hi def link cabalAuthor Normal256hi def link cabalMaintainer Normal257hi def link cabalCategoryTitle Title258hi def link cabalLicense Normal259hi def link cabalLicenseFile Normal260hi def link cabalBuildType Keyword261hi def link cabalVersion Number262hi def link cabalTruth Boolean263hi def link cabalComment Comment264hi def link cabalStatement Statement265hi def link cabalLanguage Type266hi def link cabalCategory Type267hi def link cabalFunction Function268hi def link cabalConditional Conditional269hi def link cabalOperator Operator270hi def link cabalVersionOperator Operator271hi def link cabalCompiler Constant272 273let b:current_syntax = "cabal"274 275let &cpo = s:cpo_save276unlet! s:cpo_save277 278" vim: ts=8279 