Skip to content

Commit 146b6ca

Browse files
committed
Improve missing brittany format provider error message (#269)
1 parent b43a8cd commit 146b6ca

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

hls-plugin-api/src/Ide/Plugin/Formatter.hs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,19 @@ doFormatting lf providers ideState ft uri params = do
6262
provider lf ideState ft contents fp params
6363
Nothing -> return $ Left $ responseError $ T.pack $ "Formatter plugin: could not get file contents for " ++ show uri
6464
Nothing -> return $ Left $ responseError $ T.pack $ "Formatter plugin: uriToFilePath failed for: " ++ show uri
65-
Nothing -> return $ Left $ responseError $ T.pack $ "Formatter plugin: no formatter found for:[" ++ T.unpack mf ++ "]"
65+
Nothing -> return $ Left $ responseError $ mconcat
66+
[ "Formatter plugin: no formatter found for:["
67+
, mf
68+
, "]"
69+
, if mf == "brittany"
70+
then T.unlines
71+
[ "\nThe haskell-language-server must be compiled with the agpl flag to provide Brittany."
72+
, "Stack users add 'agpl: true' in the flags section of the 'stack.yaml' file."
73+
, "The 'haskell-language-server.cabal' file already has this flag enabled by default."
74+
, "For more information see: https://github.com/haskell/haskell-language-server/issues/269"
75+
]
76+
else ""
77+
]
6678

6779
-- ---------------------------------------------------------------------
6880

@@ -73,7 +85,6 @@ noneProvider _ _ _ _ _ _ = return $ Right (List [])
7385

7486
responseError :: T.Text -> ResponseError
7587
responseError txt = ResponseError InvalidParams txt Nothing
76-
7788
-- ---------------------------------------------------------------------
7889

7990
extractRange :: Range -> T.Text -> T.Text

0 commit comments

Comments
 (0)