From 146b6ca2ea2d92a46c6ae1bd6c9099a2ac1ee15f Mon Sep 17 00:00:00 2001 From: willbush Date: Sat, 19 Sep 2020 22:36:50 -0500 Subject: [PATCH 1/2] Improve missing brittany format provider error message (#269) --- hls-plugin-api/src/Ide/Plugin/Formatter.hs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/hls-plugin-api/src/Ide/Plugin/Formatter.hs b/hls-plugin-api/src/Ide/Plugin/Formatter.hs index 1d2d8f8480..98180c6fb9 100644 --- a/hls-plugin-api/src/Ide/Plugin/Formatter.hs +++ b/hls-plugin-api/src/Ide/Plugin/Formatter.hs @@ -62,7 +62,19 @@ doFormatting lf providers ideState ft uri params = do provider lf ideState ft contents fp params Nothing -> return $ Left $ responseError $ T.pack $ "Formatter plugin: could not get file contents for " ++ show uri Nothing -> return $ Left $ responseError $ T.pack $ "Formatter plugin: uriToFilePath failed for: " ++ show uri - Nothing -> return $ Left $ responseError $ T.pack $ "Formatter plugin: no formatter found for:[" ++ T.unpack mf ++ "]" + Nothing -> return $ Left $ responseError $ mconcat + [ "Formatter plugin: no formatter found for:[" + , mf + , "]" + , if mf == "brittany" + then T.unlines + [ "\nThe haskell-language-server must be compiled with the agpl flag to provide Brittany." + , "Stack users add 'agpl: true' in the flags section of the 'stack.yaml' file." + , "The 'haskell-language-server.cabal' file already has this flag enabled by default." + , "For more information see: https://github.com/haskell/haskell-language-server/issues/269" + ] + else "" + ] -- --------------------------------------------------------------------- @@ -73,7 +85,6 @@ noneProvider _ _ _ _ _ _ = return $ Right (List []) responseError :: T.Text -> ResponseError responseError txt = ResponseError InvalidParams txt Nothing - -- --------------------------------------------------------------------- extractRange :: Range -> T.Text -> T.Text From 8d9631137f0e14b319487cea203a58827adf9bad Mon Sep 17 00:00:00 2001 From: willbush Date: Sat, 19 Sep 2020 22:52:24 -0500 Subject: [PATCH 2/2] Add spacing back which was removed by mistake --- hls-plugin-api/src/Ide/Plugin/Formatter.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/hls-plugin-api/src/Ide/Plugin/Formatter.hs b/hls-plugin-api/src/Ide/Plugin/Formatter.hs index 98180c6fb9..ba78c24c9c 100644 --- a/hls-plugin-api/src/Ide/Plugin/Formatter.hs +++ b/hls-plugin-api/src/Ide/Plugin/Formatter.hs @@ -85,6 +85,7 @@ noneProvider _ _ _ _ _ _ = return $ Right (List []) responseError :: T.Text -> ResponseError responseError txt = ResponseError InvalidParams txt Nothing + -- --------------------------------------------------------------------- extractRange :: Range -> T.Text -> T.Text