Skip to content

Commit 22f4def

Browse files
committed
Add common stanza to completion data
This allows fields and values to be completed correctly inside common stanzas
1 parent 7563439 commit 22f4def

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ cabalKeywords =
6363
("extra-tmp-files:", filePathCompleter)
6464
]
6565

66-
-- | Map, containing all stanzas in a cabal file as keys
66+
-- | Map, containing all stanzas in a cabal file as keys,
6767
-- and lists of their possible nested keywords as values.
6868
stanzaKeywordMap :: Map StanzaType (Map KeyWordName Completer)
6969
stanzaKeywordMap =
@@ -73,6 +73,7 @@ stanzaKeywordMap =
7373
("test-suite", testSuiteFields <> libExecTestBenchCommons),
7474
("benchmark", benchmarkFields <> libExecTestBenchCommons),
7575
("foreign-library", foreignLibraryFields <> libExecTestBenchCommons),
76+
("common", libExecTestBenchCommons),
7677
("flag", flagFields),
7778
("source-repository", sourceRepositoryFields)
7879
]

plugins/hls-cabal-plugin/test/Context.hs

+9
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ getContextTests =
188188
, (Stanza "source-repository" (Just "head"), KeyWord "type:")
189189
, (Stanza "source-repository" (Just "head"), KeyWord "type:")
190190
, (Stanza "source-repository" (Just "head"), None)
191+
, (Stanza "common" (Just "cabalfmt"), None)
192+
, (Stanza "common" (Just "cabalfmt"), None)
193+
, (Stanza "common" (Just "cabalfmt"), KeyWord "build-depends:")
191194
]
192195
$ \fileContent posPrefInfo ->
193196
callGetContext (cursorPos posPrefInfo) (prefixText posPrefInfo) fileContent
@@ -276,4 +279,10 @@ source-repository head
276279
location: https://github.com/haskell/haskell-language-server
277280

278281
^
282+
common cabalfmt
283+
284+
^
285+
build-depends: haskell-language-server:hls-cabal-fmt-plugin
286+
^ ^
287+
cpp-options: -Dhls_cabalfmt
279288
|]

0 commit comments

Comments
 (0)