Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List all available plugins #2139

Merged
merged 6 commits into from
Sep 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/Ide/Arguments.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import System.Environment
data Arguments
= VersionMode PrintVersion
| ProbeToolsMode
| ListPluginsMode
| BiosMode BiosAction
| Ghcide GhcideArguments
| VSCodeExtensionSchemaMode
Expand Down Expand Up @@ -64,6 +65,7 @@ getArguments exeName plugins = execParser opts
opts = info ((
VersionMode <$> printVersionParser exeName
<|> probeToolsParser exeName
<|> listPluginsParser
<|> BiosMode <$> biosParser
<|> Ghcide <$> arguments plugins
)
Expand All @@ -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)
Expand Down
10 changes: 9 additions & 1 deletion src/Ide/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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
Expand All @@ -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
Expand Down