From 0b44b1c760d77673e3f8eac6cc2285dce4ac79a2 Mon Sep 17 00:00:00 2001 From: July541 Date: Sun, 29 Aug 2021 17:17:32 +0800 Subject: [PATCH 1/2] List all available plugins --- src/Ide/Arguments.hs | 7 +++++++ src/Ide/Main.hs | 10 +++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Ide/Arguments.hs b/src/Ide/Arguments.hs index a7c5433ff5..39ced77cd2 100644 --- a/src/Ide/Arguments.hs +++ b/src/Ide/Arguments.hs @@ -30,6 +30,7 @@ import System.Environment data Arguments = VersionMode PrintVersion | ProbeToolsMode + | ListPluginsMode | BiosMode BiosAction | Ghcide GhcideArguments | VSCodeExtensionSchemaMode @@ -64,6 +65,7 @@ getArguments exeName plugins = execParser opts opts = info (( VersionMode <$> printVersionParser exeName <|> probeToolsParser exeName + <|> listPluginsParser <|> BiosMode <$> biosParser <|> Ghcide <$> arguments plugins ) @@ -90,6 +92,11 @@ probeToolsParser exeName = flag' ProbeToolsMode (long "probe-tools" <> help ("Show " ++ exeName ++ " version and other tools of interest")) +listPluginsParser :: Parser Arguments +listPluginsParser = + flag' ListPluginsMode + (long "list-plugins" <> help "List all avaliable plugins") + arguments :: IdePlugins IdeState -> Parser GhcideArguments arguments plugins = GhcideArguments <$> (commandP plugins <|> lspCommand <|> checkCommand) diff --git a/src/Ide/Main.hs b/src/Ide/Main.hs index 54a6e7af3f..b54a798603 100644 --- a/src/Ide/Main.hs +++ b/src/Ide/Main.hs @@ -13,6 +13,7 @@ import Control.Monad.Extra import qualified Data.Aeson.Encode.Pretty as A import qualified Data.ByteString.Lazy.Char8 as LBS import Data.Default +import Data.List (sort) import qualified Data.Text as T import Development.IDE.Core.Rules import Development.IDE.Graph (ShakeOptions (shakeThreads)) @@ -25,7 +26,8 @@ import Ide.Arguments import Ide.Logger import Ide.Plugin.ConfigUtils (pluginsToDefaultConfig, pluginsToVSCodeExtensionSchema) -import Ide.Types (IdePlugins, ipMap) +import Ide.Types (IdePlugins, PluginId (PluginId), + ipMap) import Ide.Version import qualified Language.LSP.Server as LSP import qualified System.Directory.Extra as IO @@ -51,6 +53,12 @@ defaultMain args idePlugins = do VersionMode PrintNumericVersion -> putStrLn haskellLanguageServerNumericVersion + ListPluginsMode -> do + let pluginNames = sort + $ map ((\(PluginId t) -> T.unpack t) . fst) + $ ipMap idePlugins + mapM_ putStrLn pluginNames + BiosMode PrintCradleType -> do dir <- IO.getCurrentDirectory hieYaml <- Session.findCradle def dir From 0d9b548d8df6a7f6865a9727483633bc13fa5778 Mon Sep 17 00:00:00 2001 From: July541 Date: Sun, 29 Aug 2021 18:07:29 +0800 Subject: [PATCH 2/2] Make hlint happy --- ghcide/src/Development/IDE/Core/FileStore.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ghcide/src/Development/IDE/Core/FileStore.hs b/ghcide/src/Development/IDE/Core/FileStore.hs index 2bab6607d4..e82ebd8e5f 100644 --- a/ghcide/src/Development/IDE/Core/FileStore.hs +++ b/ghcide/src/Development/IDE/Core/FileStore.hs @@ -289,7 +289,7 @@ typecheckParentsAction nfp = do Just rs -> do liftIO $ (log $ "Typechecking reverse dependencies for " ++ show nfp ++ ": " ++ show revs) `catch` \(e :: SomeException) -> log (show e) - () <$ uses GetModIface rs + void (uses GetModIface rs) -- | Note that some keys have been modified and restart the session -- Only valid if the virtual file system was initialised by LSP, as that