Skip to content

Commit 9b2f3fc

Browse files
Jana ChadtVeryMilkyJoe
Jana Chadt
authored andcommitted
Add value completion for cabal-version
1 parent a48a937 commit 9b2f3fc

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
@@ -288,7 +288,10 @@ completion _ide _ complParams = do
288288
result :: Maybe VFS.PosPrefixInfo -> VirtualFile -> J.List CompletionItem
289289
result Nothing _ = J.List []
290290
result (Just pfix) cnts
291-
| pos ^. JL.line == 0 = J.List [buildCompletion (fst cabalVersionKeyword)]
291+
| pos ^. JL.line == 0 = case traceShowId $ context of
292+
Just (_, kw)
293+
| KeyWord _ <- kw -> J.List $ map buildCompletion $ snd cabalVersionKeyword
294+
_ -> J.List [buildCompletion (fst cabalVersionKeyword)]
292295
| Just ctx <- context = J.List $ makeCompletionItems pfix (getCompletionsForContext ctx)
293296
| otherwise = J.List []
294297
where
@@ -328,7 +331,7 @@ getContext :: Position -> [T.Text] -> Maybe Context
328331
getContext pos ls =
329332
case lvlContext of
330333
TopLevel -> do
331-
kwContext <- getKeyWordContext pos ls cabalKeywords
334+
kwContext <- getKeyWordContext pos ls (uncurry Map.insert cabalVersionKeyword cabalKeywords)
332335
pure (TopLevel, kwContext)
333336
Stanza s ->
334337
case Map.lookup (traceShowId s) stanzaKeywordMap of
@@ -480,6 +483,16 @@ stanzaKeywordMap =
480483
("lib-version-info:", []),
481484
("lib-version-linux:", [])
482485
]
486+
),
487+
( "flag",
488+
Map.fromList
489+
[ ("description:", []),
490+
("default:", ["True", "False"]),
491+
("manual:", ["False", "True"]),
492+
("lib-def-file:", []),
493+
("lib-version-info:", []),
494+
("lib-version-linux:", [])
495+
]
483496
)
484497
]
485498
where
@@ -501,7 +514,27 @@ stanzaKeywordMap =
501514
("ghcjs-prof-options:", []),
502515
("ghcjs-shared-options:", []),
503516
("includes:", []),
504-
("install-includes:", [])
517+
("install-includes:", []),
518+
("include-dirs:", []),
519+
("c-sources:", []),
520+
("cxx-sources:", []),
521+
("asm-sources:", []),
522+
("cmm-sources:", []),
523+
("js-sources:", []),
524+
("extra-libraries:", []),
525+
("extra-ghci-libraries:", []),
526+
("extra-bundled-libraries:", []),
527+
("extra-lib-dirs:", []),
528+
("cc-options:", []),
529+
("cpp-options:", []),
530+
("cxx-options:", []),
531+
("cmm-options:", []),
532+
("asm-options:", []),
533+
("ld-options:", []),
534+
("pkgconfig-depends:", []),
535+
("frameworks:", []),
536+
("extra-framework-dirs:", []),
537+
("mixins:", [])
505538
]
506539

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

0 commit comments

Comments
 (0)