@@ -14,7 +14,7 @@ import qualified Data.Map as Map
14
14
import Data.Maybe (fromMaybe )
15
15
import qualified Data.Text as T
16
16
import Development.IDE as D
17
- import Distribution.CabalSpecVersion (CabalSpecVersion (CabalSpecV1_2 ),
17
+ import Distribution.CabalSpecVersion (CabalSpecVersion (CabalSpecV2_2 ),
18
18
showCabalSpecVersion )
19
19
import Distribution.Compat.Lens ((^.) )
20
20
import Ide.Plugin.Cabal.LicenseSuggest (licenseNames )
@@ -92,11 +92,11 @@ contextToCompleter :: Context -> Completer
92
92
-- if we are in the top level of the cabal file and not in a keyword context,
93
93
-- we can write any top level keywords or a stanza declaration
94
94
contextToCompleter (TopLevel , None ) =
95
- constantCompleter $ Map. keys cabalKeywords ++ Map. keys stanzaKeywordMap
95
+ constantCompleter $ Map. keys ( cabalKeywords <> cabalVersionKeyword) ++ Map. keys stanzaKeywordMap
96
96
-- if we are in a keyword context in the top level,
97
- -- we look up that keyword in the toplevel context and can complete its possible values
97
+ -- we look up that keyword in the top level context and can complete its possible values
98
98
contextToCompleter (TopLevel , KeyWord kw) =
99
- case Map. lookup kw cabalKeywords of
99
+ case Map. lookup kw ( cabalKeywords <> cabalVersionKeyword) of
100
100
Nothing -> noopCompleter
101
101
Just l -> l
102
102
-- if we are in a stanza and not in a keyword context,
@@ -154,8 +154,8 @@ getKeyWordContext pos ls keywords = do
154
154
case lastNonEmptyLineM of
155
155
Nothing -> Just None
156
156
Just lastLine' -> do
157
- let (whitespaces , lastLine) = T. span (== ' ' ) lastLine'
158
- let keywordIndentation = T. length whitespaces
157
+ let (whiteSpaces , lastLine) = T. span (== ' ' ) lastLine'
158
+ let keywordIndentation = T. length whiteSpaces
159
159
let cursorIndentation = fromIntegral (pos ^. JL. character)
160
160
-- in order to be in a keyword context the cursor needs to be indented more than the keyword
161
161
if cursorIndentation > keywordIndentation
@@ -252,7 +252,7 @@ makeSimpleCabalCompletionItem :: Range -> T.Text -> CabalCompletionItem
252
252
makeSimpleCabalCompletionItem r txt = CabalCompletionItem txt Nothing r
253
253
254
254
{- | Returns a CabalCompletionItem with the given starting position,
255
- text to be inserted and text to be displayed in completionsuggestion
255
+ text to be inserted and text to be displayed in the completion suggestion
256
256
-}
257
257
makeCabalCompletionItem :: Range -> T. Text -> T. Text -> CabalCompletionItem
258
258
makeCabalCompletionItem r insertTxt displayTxt = CabalCompletionItem insertTxt (Just displayTxt) r
@@ -364,7 +364,7 @@ cabalVersionKeyword :: Map T.Text Completer
364
364
cabalVersionKeyword =
365
365
Map. singleton " cabal-version:" $
366
366
constantCompleter $
367
- map (T. pack . showCabalSpecVersion) [CabalSpecV1_2 .. maxBound ]
367
+ map (T. pack . showCabalSpecVersion) [CabalSpecV2_2 .. maxBound ]
368
368
369
369
-- todo: we could add file path completion for file path fields
370
370
-- we could add descriptions of field values and then show them when inside the field's context
@@ -408,7 +408,7 @@ stanzaKeywordMap =
408
408
, (" virtual-modules:" , noopCompleter)
409
409
, (" exposed:" , constantCompleter [" True" , " False" ])
410
410
, (" visibility:" , constantCompleter [" private" , " public" ])
411
- , (" reexported-modules:" , noopCompleter) -- exportlist , i.e. "orig-okg:Name as NewName"
411
+ , (" reexported-modules:" , noopCompleter) -- export list , i.e. "orig-okg:Name as NewName"
412
412
, (" signatures:" , noopCompleter) -- list of signatures
413
413
]
414
414
++ libExecTestBenchCommons
0 commit comments