diff --git a/plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Completion/Data.hs b/plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Completion/Data.hs index 158338c3cf..143dfaadff 100644 --- a/plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Completion/Data.hs +++ b/plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Completion/Data.hs @@ -63,7 +63,7 @@ cabalKeywords = ("extra-tmp-files:", filePathCompleter) ] --- | Map, containing all stanzas in a cabal file as keys +-- | Map, containing all stanzas in a cabal file as keys, -- and lists of their possible nested keywords as values. stanzaKeywordMap :: Map StanzaType (Map KeyWordName Completer) stanzaKeywordMap = @@ -73,6 +73,7 @@ stanzaKeywordMap = ("test-suite", testSuiteFields <> libExecTestBenchCommons), ("benchmark", benchmarkFields <> libExecTestBenchCommons), ("foreign-library", foreignLibraryFields <> libExecTestBenchCommons), + ("common", libExecTestBenchCommons), ("flag", flagFields), ("source-repository", sourceRepositoryFields) ] diff --git a/plugins/hls-cabal-plugin/test/Completer.hs b/plugins/hls-cabal-plugin/test/Completer.hs index 4d87bae01d..e7403e9a0e 100644 --- a/plugins/hls-cabal-plugin/test/Completer.hs +++ b/plugins/hls-cabal-plugin/test/Completer.hs @@ -51,6 +51,11 @@ basicCompleterTests = compls <- getCompletions doc (Position 8 2) let complTexts = getTextEditTexts compls liftIO $ assertBool "suggests benchmark" $ "benchmark" `elem` complTexts + , runCabalTestCaseSession "In top level context - stanza should be suggested" "" $ do + doc <- openDoc "completer.cabal" "cabal" + compls <- getCompletions doc (Position 13 2) + let complTexts = getTextEditTexts compls + liftIO $ assertBool "suggests common" $ "common" `elem` complTexts , runCabalTestCaseSession "Main-is completions should be relative to hs-source-dirs of same stanza" "filepath-completions" $ do doc <- openDoc "main-is.cabal" "cabal" compls <- getCompletions doc (Position 10 12) diff --git a/plugins/hls-cabal-plugin/test/Context.hs b/plugins/hls-cabal-plugin/test/Context.hs index e9e090c310..82d50ccf14 100644 --- a/plugins/hls-cabal-plugin/test/Context.hs +++ b/plugins/hls-cabal-plugin/test/Context.hs @@ -188,6 +188,9 @@ getContextTests = , (Stanza "source-repository" (Just "head"), KeyWord "type:") , (Stanza "source-repository" (Just "head"), KeyWord "type:") , (Stanza "source-repository" (Just "head"), None) + , (Stanza "common" (Just "cabalfmt"), None) + , (Stanza "common" (Just "cabalfmt"), None) + , (Stanza "common" (Just "cabalfmt"), KeyWord "build-depends:") ] $ \fileContent posPrefInfo -> callGetContext (cursorPos posPrefInfo) (prefixText posPrefInfo) fileContent @@ -276,4 +279,10 @@ source-repository head location: https://github.com/haskell/haskell-language-server ^ +common cabalfmt + + ^ + build-depends: haskell-language-server:hls-cabal-fmt-plugin + ^ ^ + cpp-options: -Dhls_cabalfmt |] diff --git a/plugins/hls-cabal-plugin/test/testdata/completer.cabal b/plugins/hls-cabal-plugin/test/testdata/completer.cabal index cd7c697026..141bdd7d2d 100644 --- a/plugins/hls-cabal-plugin/test/testdata/completer.cabal +++ b/plugins/hls-cabal-plugin/test/testdata/completer.cabal @@ -10,3 +10,5 @@ be library lib + +co \ No newline at end of file