Skip to content

Restyle Generate editor keywords #529

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

Merged
merged 1 commit into from
Jul 1, 2022
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
13 changes: 7 additions & 6 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

module Main where

import Data.Foldable (asum)
import Data.Text (
Text,
pack,
Expand All @@ -15,7 +16,6 @@ import Swarm.DocGen (EditorType (..), GenerateDocs (..), generateDocs)
import Swarm.Language.LSP (lspMain)
import Swarm.Language.Pipeline (processTerm)
import System.Exit
import Data.Foldable (asum)

data CLI
= Run
Expand Down Expand Up @@ -49,11 +49,12 @@ cliParser =
, command "editors" (info (EditorKeywords <$> editor <**> helper) $ progDesc "Output editor keywords")
]
editor :: Parser (Maybe EditorType)
editor = asum
[ pure Nothing
, Just VSCode <$ switch (long "code" <> help "Generate for the VS Code editor")
, Just EMacs <$ switch (long "emacs" <> help "Generate for the EMacs editor")
]
editor =
asum
[ pure Nothing
, Just VSCode <$ switch (long "code" <> help "Generate for the VS Code editor")
, Just EMacs <$ switch (long "emacs" <> help "Generate for the EMacs editor")
]
seed :: Parser (Maybe Int)
seed = optional $ option auto (long "seed" <> short 's' <> metavar "INT" <> help "Seed to use for world generation")
scenario :: Parser (Maybe String)
Expand Down
6 changes: 3 additions & 3 deletions src/Swarm/DocGen.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import Swarm.Game.Recipe (Recipe, loadRecipes, recipeInputs, recipeOutputs, reci
import Swarm.Game.Robot (installedDevices, robotInventory, setRobotID)
import Swarm.Game.Scenario (Scenario, loadScenario, scenarioRobots)
import Swarm.Game.WorldGen (testWorld2Entites)
import Swarm.Language.Syntax (ConstMeta (..), Const (..))
import Swarm.Language.Syntax (Const (..), ConstMeta (..))
import Swarm.Language.Syntax qualified as Syntax
import Swarm.Util (isRightOr)
import Text.Dot (Dot, NodeId, (.->.))
Expand Down Expand Up @@ -70,7 +70,7 @@ generateDocs = \case
putStrLn $ "-- " <> show et
putStrLn $ replicate 40 '-'
generateEditorKeywords et
mapM_ editorGen [minBound..maxBound]
mapM_ editorGen [minBound .. maxBound]

-- ----------------------------------------------------------------------------
-- GENERATE KEYWORDS: LIST OF WORDS TO BE HIGHLIGHTED
Expand Down Expand Up @@ -99,7 +99,7 @@ builtinCommandsEMacs = [If, Run, Return, Try, Fail, Force, Fst, Snd]
editorList :: EditorType -> [Text] -> Text
editorList = \case
EMacs -> T.unlines . map ((" " <>) . quote)
VSCode -> T.intercalate "|"
VSCode -> T.intercalate "|"
where
quote = T.cons '"' . flip T.snoc '"'

Expand Down