Skip to content

Commit cd58428

Browse files
author
Jana Chadt
committed
Add value completion for cabal-version
1 parent 9bf0eaf commit cd58428

File tree

1 file changed

+36
-3
lines changed
  • plugins/hls-cabal-plugin/src/Ide/Plugin

1 file changed

+36
-3
lines changed

plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal.hs

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,10 @@ completion _ide _ complParams = do
183183
result :: Maybe VFS.PosPrefixInfo -> VirtualFile -> J.List CompletionItem
184184
result Nothing _ = J.List []
185185
result (Just pfix) cnts
186-
| pos ^. JL.line == 0 = J.List [buildCompletion (fst cabalVersionKeyword)]
186+
| pos ^. JL.line == 0 = case traceShowId $ context of
187+
Just (_, kw)
188+
| KeyWord _ <- kw -> J.List $ map buildCompletion $ snd cabalVersionKeyword
189+
_ -> J.List [buildCompletion (fst cabalVersionKeyword)]
187190
| Just ctx <- context = J.List $ makeCompletionItems pfix (getCompletionsForContext ctx)
188191
| otherwise = J.List []
189192
where
@@ -223,7 +226,7 @@ getContext :: Position -> [T.Text] -> Maybe Context
223226
getContext pos ls =
224227
case lvlContext of
225228
TopLevel -> do
226-
kwContext <- getKeyWordContext pos ls cabalKeywords
229+
kwContext <- getKeyWordContext pos ls (uncurry Map.insert cabalVersionKeyword cabalKeywords)
227230
pure (TopLevel, kwContext)
228231
Stanza s ->
229232
case Map.lookup (traceShowId s) stanzaKeywordMap of
@@ -375,6 +378,16 @@ stanzaKeywordMap =
375378
("lib-version-info:", []),
376379
("lib-version-linux:", [])
377380
]
381+
),
382+
( "flag",
383+
Map.fromList
384+
[ ("description:", []),
385+
("default:", ["True", "False"]),
386+
("manual:", ["False", "True"]),
387+
("lib-def-file:", []),
388+
("lib-version-info:", []),
389+
("lib-version-linux:", [])
390+
]
378391
)
379392
]
380393
where
@@ -396,7 +409,27 @@ stanzaKeywordMap =
396409
("ghcjs-prof-options:", []),
397410
("ghcjs-shared-options:", []),
398411
("includes:", []),
399-
("install-includes:", [])
412+
("install-includes:", []),
413+
("include-dirs:", []),
414+
("c-sources:", []),
415+
("cxx-sources:", []),
416+
("asm-sources:", []),
417+
("cmm-sources:", []),
418+
("js-sources:", []),
419+
("extra-libraries:", []),
420+
("extra-ghci-libraries:", []),
421+
("extra-bundled-libraries:", []),
422+
("extra-lib-dirs:", []),
423+
("cc-options:", []),
424+
("cpp-options:", []),
425+
("cxx-options:", []),
426+
("cmm-options:", []),
427+
("asm-options:", []),
428+
("ld-options:", []),
429+
("pkgconfig-depends:", []),
430+
("frameworks:", []),
431+
("extra-framework-dirs:", []),
432+
("mixins:", [])
400433
]
401434

402435
-- cabalFlagKeywords :: [(T.Text, T.Text)]

0 commit comments

Comments
 (0)