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 authored and fendor committed Nov 25, 2022
1 parent d333cab commit 7f191db
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 @@ -288,7 +288,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 @@ -328,7 +331,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 @@ -480,6 +483,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 @@ -501,7 +514,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 7f191db

Please sign in to comment.