Skip to content

Commit

Permalink
Add value completion for cabal-version
Browse files Browse the repository at this point in the history
  • Loading branch information
Jana Chadt committed Oct 9, 2022
1 parent 9bf0eaf commit cd58428
Showing 1 changed file with 36 additions and 3 deletions.
39 changes: 36 additions & 3 deletions plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,10 @@ completion _ide _ complParams = do
result :: Maybe VFS.PosPrefixInfo -> VirtualFile -> J.List CompletionItem
result Nothing _ = J.List []
result (Just pfix) cnts
| pos ^. JL.line == 0 = J.List [buildCompletion (fst cabalVersionKeyword)]
| pos ^. JL.line == 0 = case traceShowId $ context of
Just (_, kw)
| KeyWord _ <- kw -> J.List $ map buildCompletion $ snd cabalVersionKeyword
_ -> J.List [buildCompletion (fst cabalVersionKeyword)]
| Just ctx <- context = J.List $ makeCompletionItems pfix (getCompletionsForContext ctx)
| otherwise = J.List []
where
Expand Down Expand Up @@ -223,7 +226,7 @@ getContext :: Position -> [T.Text] -> Maybe Context
getContext pos ls =
case lvlContext of
TopLevel -> do
kwContext <- getKeyWordContext pos ls cabalKeywords
kwContext <- getKeyWordContext pos ls (uncurry Map.insert cabalVersionKeyword cabalKeywords)
pure (TopLevel, kwContext)
Stanza s ->
case Map.lookup (traceShowId s) stanzaKeywordMap of
Expand Down Expand Up @@ -375,6 +378,16 @@ stanzaKeywordMap =
("lib-version-info:", []),
("lib-version-linux:", [])
]
),
( "flag",
Map.fromList
[ ("description:", []),
("default:", ["True", "False"]),
("manual:", ["False", "True"]),
("lib-def-file:", []),
("lib-version-info:", []),
("lib-version-linux:", [])
]
)
]
where
Expand All @@ -396,7 +409,27 @@ stanzaKeywordMap =
("ghcjs-prof-options:", []),
("ghcjs-shared-options:", []),
("includes:", []),
("install-includes:", [])
("install-includes:", []),
("include-dirs:", []),
("c-sources:", []),
("cxx-sources:", []),
("asm-sources:", []),
("cmm-sources:", []),
("js-sources:", []),
("extra-libraries:", []),
("extra-ghci-libraries:", []),
("extra-bundled-libraries:", []),
("extra-lib-dirs:", []),
("cc-options:", []),
("cpp-options:", []),
("cxx-options:", []),
("cmm-options:", []),
("asm-options:", []),
("ld-options:", []),
("pkgconfig-depends:", []),
("frameworks:", []),
("extra-framework-dirs:", []),
("mixins:", [])
]

-- cabalFlagKeywords :: [(T.Text, T.Text)]
Expand Down

0 comments on commit cd58428

Please sign in to comment.