@@ -16,6 +16,13 @@ import Ide.Plugin.Cabal.Completion.Completer.Types (Completer)
1616import Ide.Plugin.Cabal.Completion.Types
1717-- import Ide.Plugin.Cabal.LicenseSuggest (licenseNames)
1818
19+ -- | Ad-hoc data type for modelling the available top-level stanzas.
20+ -- Not intended right now for anything else but to avoid string
21+ -- comparisons in 'stanzaKeywordMap' and 'libExecTestBenchCommons'.
22+ data TopLevelStanza
23+ = Package
24+ | ProgramOptions
25+
1926-- ----------------------------------------------------------------
2027-- Completion Data
2128-- ----------------------------------------------------------------
@@ -44,27 +51,27 @@ cabalProjectKeywords =
4451 (" optional-packages:" , noopCompleter),
4552 (" extra-packages:" , noopCompleter),
4653 -- projectConfigBuildOnlyFieldGrammar
47- (" verbose:" , constantCompleter [" 0" , " 1" , " 2" , " 3" ]), -- not sure if this works/makes sense?
54+ (" verbose:" , constantCompleter [" 0" , " 1" , " 2" , " 3" ]),
4855 (" build-summary:" , noopCompleter),
4956 (" build-log:" , noopCompleter),
5057 (" remote-build-reporting:" , noopCompleter),
5158 (" report-planning-failure:" , noopCompleter),
5259 (" symlink-bindir:" , noopCompleter),
5360 (" jobs:" , noopCompleter),
5461 (" semaphore:" , noopCompleter),
55- (" keep-going:" , noopCompleter ),
62+ (" keep-going:" , constantCompleter [ " False " , " True " ] ),
5663 (" offline:" , noopCompleter),
57- (" haddock-keep-temp-files:" , noopCompleter ),
58- (" http-transport:" , noopCompleter ),
59- (" ignore-expiry:" , noopCompleter ),
64+ (" haddock-keep-temp-files:" , constantCompleter [ " False " , " True " ] ),
65+ (" http-transport:" , constantCompleter [ " curl " , " wget " , " powershell " , " plain-http " ] ),
66+ (" ignore-expiry:" , constantCompleter [ " False " , " True " ] ),
6067 (" remote-repo-cache:" , noopCompleter),
6168 (" logs-dir:" , noopCompleter),
6269 -- projectConfigSharedFieldGrammar
6370 (" builddir:" , noopCompleter),
6471 (" project-dir:" , noopCompleter),
6572 (" project-file:" , noopCompleter),
6673 (" ignore-project:" , noopCompleter),
67- (" compiler:" , noopCompleter ),
74+ (" compiler:" , constantCompleter [ " ghc " , " ghcjs " , " jhc " , " lhc " , " uhc " , " haskell-suite " ] ),
6875 (" with-compiler:" , noopCompleter),
6976 (" with-hc-pkg:" , noopCompleter),
7077 (" doc-index-file:" , noopCompleter),
@@ -75,73 +82,76 @@ cabalProjectKeywords =
7582 (" constraints:" , noopCompleter),
7683 (" preferences:" , noopCompleter),
7784 (" cabal-lib-version:" , noopCompleter),
78- (" solver:" , noopCompleter ),
85+ (" solver:" , constantCompleter [ " modular " ] ),
7986 (" allow-older:" , noopCompleter),
8087 (" allow-newer:" , noopCompleter),
81- (" write-ghc-environment-files:" , noopCompleter ),
88+ (" write-ghc-environment-files:" , constantCompleter [ " never " , " always " , " ghc8.4.4+ " ] ),
8289 (" max-backjumps:" , noopCompleter),
83- (" reorder-goals:" , noopCompleter ),
84- (" count-conflicts:" , noopCompleter ),
85- (" fine-grained-conflicts:" , noopCompleter ),
86- (" minimize-conflict-set:" , noopCompleter ),
87- (" strong-flags:" , noopCompleter ),
88- (" allow-boot-library-installs:" , noopCompleter ),
90+ (" reorder-goals:" , constantCompleter [ " False " , " True " ] ),
91+ (" count-conflicts:" , constantCompleter [ " True " , " False " ] ),
92+ (" fine-grained-conflicts:" , constantCompleter [ " True " , " False " ] ),
93+ (" minimize-conflict-set:" , constantCompleter [ " False " , " True " ] ),
94+ (" strong-flags:" , constantCompleter [ " False " , " True " ] ),
95+ (" allow-boot-library-installs:" , constantCompleter [ " False " , " True " ] ),
8996 (" reject-unconstrained-dependencies:" , noopCompleter),
9097 (" per-component:" , noopCompleter),
9198 (" independent-goals:" , noopCompleter),
9299 (" prefer-oldest:" , noopCompleter),
93100 (" extra-prog-path-shared-only:" , noopCompleter),
94- (" multi-repl:" , noopCompleter)
101+ (" multi-repl:" , noopCompleter),
102+ -- extras
103+ (" benchmarks:" , constantCompleter [" False" , " True" ])
104+
95105 ]
96106
97107packageFields :: Map KeyWordName Completer
98108packageFields =
99109 Map. fromList
100110 [ -- packageConfigFieldGrammar
101- (" haddock-all:" , noopCompleter ),
111+ (" haddock-all:" , constantCompleter [ " False " , " True " ] ),
102112 (" extra-prog-path:" , noopCompleter),
103113 (" flags:" , noopCompleter),
104- (" library-vanilla:" , noopCompleter ),
105- (" shared:" , noopCompleter ),
106- (" static:" , noopCompleter ),
107- (" exectable-dynamic:" , noopCompleter ),
108- (" executable-static:" , noopCompleter ),
109- (" profiling:" , noopCompleter ),
110- (" library-profiling:" , noopCompleter ),
114+ (" library-vanilla:" , constantCompleter [ " True " , " False " ] ),
115+ (" shared:" , constantCompleter [ " False " , " True " ] ),
116+ (" static:" , constantCompleter [ " False " , " True " ] ),
117+ (" exectable-dynamic:" , constantCompleter [ " False " , " True " ] ),
118+ (" executable-static:" , constantCompleter [ " False " , " True " ] ),
119+ (" profiling:" , constantCompleter [ " False " , " True " ] ),
120+ (" library-profiling:" , constantCompleter [ " False " , " True " ] ),
111121 (" profiling-shared:" , noopCompleter),
112- (" exectable-profiling:" , noopCompleter ),
113- (" profiling-detail:" , noopCompleter ),
114- (" library-profiling-detail:" , noopCompleter ),
122+ (" exectable-profiling:" , constantCompleter [ " False " , " True " ] ),
123+ (" profiling-detail:" , constantCompleter [ " default " , " none " , " exported-functions " , " toplevel-functions " , " all-functions " ] ),
124+ (" library-profiling-detail:" , constantCompleter [ " default " , " none " , " exported-functions " , " toplevel-functions " , " all-functions " ] ),
115125 (" configure-options:" , noopCompleter),
116- (" optimization:" , noopCompleter ),
126+ (" optimization:" , constantCompleter [ " 0 " , " 1 " , " 2 " , " True " , " False " ] ),
117127 (" program-prefix:" , noopCompleter),
118128 (" program-suffix:" , noopCompleter),
119129 (" extra-lib-dirs:" , noopCompleter),
120130 (" extra-lib-dirs-static:" , noopCompleter),
121131 (" extra-framework-dirs:" , noopCompleter),
122132 (" extra-include-dirs:" , noopCompleter),
123- (" library-for-ghci:" , noopCompleter ),
124- (" split-sections:" , noopCompleter ),
125- (" split-objs:" , noopCompleter ),
126- (" executable-stripping:" , noopCompleter ),
127- (" library-stripping:" , noopCompleter ),
128- (" tests:" , noopCompleter ),
129- (" benchmarks:" , noopCompleter ),
130- (" relocatable:" , noopCompleter ),
133+ (" library-for-ghci:" , constantCompleter [ " True " , " False " ] ),
134+ (" split-sections:" , constantCompleter [ " False " , " True " ] ),
135+ (" split-objs:" , constantCompleter [ " False " , " True " ] ),
136+ (" executable-stripping:" , constantCompleter [ " True " , " False " ] ),
137+ (" library-stripping:" , constantCompleter [ " False " , " True " ] ),
138+ (" tests:" , constantCompleter [ " False " , " True " ] ),
139+ (" benchmarks:" , constantCompleter [ " False " , " True " ] ),
140+ (" relocatable:" , constantCompleter [ " False " , " True " ] ),
131141 (" debug-info:" , noopCompleter),
132142 (" build-info:" , noopCompleter),
133- (" run-tests:" , noopCompleter ),
134- (" documentation:" , noopCompleter ),
135- (" haddock-hoogle:" , noopCompleter ),
136- (" haddock-html:" , noopCompleter ),
143+ (" run-tests:" , constantCompleter [ " False " , " True " ] ),
144+ (" documentation:" , constantCompleter [ " False " , " True " ] ),
145+ (" haddock-hoogle:" , constantCompleter [ " False " , " True " ] ),
146+ (" haddock-html:" , constantCompleter [ " True " , " False " ] ),
137147 (" haddock-html-location:" , noopCompleter),
138148 (" haddock-foreign-libraries:" , noopCompleter),
139- (" haddock-executables:" , noopCompleter ),
140- (" haddock-tests:" , noopCompleter ),
141- (" haddock-benchmarks:" , noopCompleter ),
142- (" haddock-internal:" , noopCompleter ),
149+ (" haddock-executables:" , constantCompleter [ " False " , " True " ] ),
150+ (" haddock-tests:" , constantCompleter [ " False " , " True " ] ),
151+ (" haddock-benchmarks:" , constantCompleter [ " False " , " True " ] ),
152+ (" haddock-internal:" , constantCompleter [ " False " , " True " ] ),
143153 (" haddock-css:" , noopCompleter),
144- (" haddock-hyperlink-source:" , noopCompleter ),
154+ (" haddock-hyperlink-source:" , constantCompleter [ " False " , " True " ] ),
145155 (" haddock-quickjump:" , noopCompleter),
146156 (" haddock-hscolour-css:" , noopCompleter),
147157 (" haddock-contents-location:" , noopCompleter),
@@ -160,13 +170,42 @@ packageFields =
160170 (" test-options:" , noopCompleter),
161171 (" benchmark-options:" , noopCompleter),
162172 -- packageConfigCoverageGrammar
163- (" coverage:" , noopCompleter)
173+ (" coverage:" , constantCompleter [" False" , " True" ]),
174+ -- other
175+ (" ghc-options:" , noopCompleter)
176+ ]
177+
178+ -- just for testing right now, to be filled in later
179+ programOptionsFields :: Map KeyWordName Completer
180+ programOptionsFields = Map. fromList
181+ [ (" ghc-options:" , noopCompleter)
182+ ]
183+
184+ sourceRepoFields :: Map KeyWordName Completer
185+ sourceRepoFields = Map. fromList
186+ [ (" type:" , constantCompleter
187+ [ " darcs" ,
188+ " git" ,
189+ " svn" ,
190+ " cvs" ,
191+ " mercurial" ,
192+ " hg" ,
193+ " bazaar" ,
194+ " bzr" ,
195+ " arch" ,
196+ " monotone"
197+ ]), -- just used the one from cabal
198+ (" location:" , noopCompleter),
199+ (" tag:" , noopCompleter),
200+ (" subdir:" , noopCompleter)
164201 ]
165202
166203-- | Map, containing all stanzas in a cabal file as keys,
167204-- and lists of their possible nested keywords as values.
168205stanzaKeywordMap :: Map StanzaType (Map KeyWordName Completer )
169206stanzaKeywordMap =
170207 Map. fromList
171- [ (" package" , packageFields)
208+ [ (" package" , packageFields),
209+ (" program-options" , programOptionsFields),
210+ (" source-repository-package" , sourceRepoFields)
172211 ]
0 commit comments