Skip to content

Commit e043b67

Browse files
committed
Rewrite cabal syntax file
1 parent 3f397c0 commit e043b67

File tree

4 files changed

+707
-461
lines changed

4 files changed

+707
-461
lines changed

Cabal/src/Distribution/PackageDescription/FieldGrammar.hs

+10-7
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ formatOtherModules = alaList' VCat MQuoted
702702
--
703703
_syntaxFieldNames :: IO ()
704704
_syntaxFieldNames = sequence_
705-
[ BS8.putStrLn $ "syn keyword cabalStatement " <> n <> ":"
705+
[ BS8.putStrLn $ " \\ " <> n
706706
| n <- nub $ sort $ mconcat
707707
[ fieldGrammarKnownFieldList packageDescriptionFieldGrammar
708708
, fieldGrammarKnownFieldList $ libraryFieldGrammar LMainLibName
@@ -718,11 +718,14 @@ _syntaxFieldNames = sequence_
718718

719719
_syntaxExtensions :: IO ()
720720
_syntaxExtensions = sequence_
721-
[ putStrLn $ "syn keyword cabalExtension " <> e
722-
| e <- nub $ sort
723-
[ prettyShow e'
721+
[ putStrLn $ " \\ " <> e
722+
| e <- ["Safe","Trustworthy","Unsafe"]
723+
++ es
724+
++ map ("No"++) es
725+
]
726+
where
727+
es = nub $ sort
728+
[ prettyShow e
724729
| e <- [ minBound .. maxBound ]
725-
, e' <- [EnableExtension e, DisableExtension e]
730+
, e `notElem` [Safe,Unsafe,Trustworthy]
726731
]
727-
, e `notElem` ["NoSafe", "NoUnsafe", "NoTrustworthy"]
728-
]

editors/vim/example.cabal

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
cabal-version: 1.12
2+
name: example
3+
version: 1
4+
synopsis: Synopsis is short, Example file for highlighting testing
5+
author: Oleg Grenrus
6+
maintainer: Oleg Grenrus <[email protected]>
7+
homepage: http://example.com/url%20with%20spaces
8+
category: Example
9+
license: BSD-3-Clause
10+
license-file: LICENSE
11+
build-type: Simple
12+
description:
13+
description: Trying to fool highlighter, successfully?
14+
Description is long and often written on multiple lines Haskell2010
15+
type subdir extensions:, the colon could fool highligher
16+
DeriveFunctor
17+
as if else elif should not be matched here
18+
tested-with:
19+
GHC (>=7.0.4 && <8)
20+
|| ==8.0.2
21+
|| ==8.2.2
22+
|| ==8.4.4
23+
|| ==8.6.5
24+
|| ==8.8.4
25+
|| ==8.10.2
26+
27+
flag some-flag
28+
manual: True
29+
30+
common name
31+
default-language: Haskell2010
32+
build-depends: base ^>=1.2.3
33+
34+
source-repository head
35+
type: git
36+
location: https://example.com/url%20with%20spaces.git
37+
38+
library
39+
import: deps
40+
exposed-modules: Foobar
41+
build-depends: base
42+
43+
buildable: True
44+
45+
if flag(some-flag)
46+
build-depends: containers
47+
elif !impl(ghc >=8.0) && True
48+
build-depends: semigroups
49+
if flag(some-flag)
50+
build-depends: nested
51+
else
52+
build-depends: void
53+
54+
-- test empty lines
55+
build-depends:
56+
, containers >= 0.5.0.0 && <0.6
57+
, base ^>=4.4.0.0 || ^>=4.5.0.0
58+
59+
-- Case insensitivity
60+
default-extensions:
61+
DeriveFoldable
62+
DeriveFunctor
63+
64+
other-extensions:
65+
ImpredicativeTypes
66+
LinearTypes
67+
68+
executable my-executable
69+
import: deps
70+
main-is: Executable.hs
71+
72+
test-suite my-tests
73+
import: deps
74+
75+
-- exitcode-stdio-1.0 or detailed-0.9
76+
type: exitcode-stdio-1.0
77+
main-is: Tests.hs
78+
79+
benchmark my-benchmark
80+
import: deps
81+
type: exitcode-stdio-1.0
82+
main-is: Bench.hs
83+
84+
foreign-library my-flib
85+
import: deps
86+
87+
-- native-shared or native-static
88+
type: native-shared

editors/vim/ftplugin/cabal.vim

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
" Vim ftplugin file
22
" Language: Haskell Cabal Build file
33
" Maintainer: Cabal Development team <[email protected]>
4-
if exists('b:cabal_ftplugin')
5-
finish
4+
if exists("b:did_ftplugin")
5+
finish
66
endif
7-
let b:cabal_ftplugin = 1
7+
let b:did_ftplugin = 1
88

9-
" dashes are ok in keywords, and also colons (for field names)
10-
setlocal iskeyword+=-
11-
setlocal iskeyword+=:
12-
setlocal iskeyword+=.
9+
10+
" dashes are ok in keywords, and occasionally a dot
11+
setlocal iskeyword=a-z,A-Z,48-57,192-255,-,.
1312

1413
" comments start with --
1514
setlocal commentstring=--\ %s

0 commit comments

Comments
 (0)