Skip to content

Commit 2915ae9

Browse files
authored
Config option to suppress proofstate styling (#1966)
1 parent a1e7193 commit 2915ae9

File tree

4 files changed

+25
-16
lines changed

4 files changed

+25
-16
lines changed

plugins/hls-tactics-plugin/src/Wingman/LanguageServer.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,11 @@ properties :: Properties
136136
, 'PropertyKey "max_use_ctor_actions" 'TInteger
137137
, 'PropertyKey "timeout_duration" 'TInteger
138138
, 'PropertyKey "auto_gas" 'TInteger
139+
, 'PropertyKey "proofstate_styling" 'TBoolean
139140
]
140141
properties = emptyProperties
142+
& defineBooleanProperty #proofstate_styling
143+
"Should Wingman emit styling markup when showing metaprogram proof states?" True
141144
& defineIntegerProperty #auto_gas
142145
"The depth of the search tree when performing \"Attempt to fill hole\". Bigger values will be able to derive more solutions, but will take exponentially more time." 4
143146
& defineIntegerProperty #timeout_duration
@@ -162,6 +165,7 @@ getTacticConfig pId =
162165
<$> usePropertyLsp #max_use_ctor_actions pId properties
163166
<*> usePropertyLsp #timeout_duration pId properties
164167
<*> usePropertyLsp #auto_gas pId properties
168+
<*> usePropertyLsp #proofstate_styling pId properties
165169

166170

167171
getIdeDynflags

plugins/hls-tactics-plugin/src/Wingman/Metaprogramming/Parser.hs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@ module Wingman.Metaprogramming.Parser where
88

99
import qualified Control.Monad.Combinators.Expr as P
1010
import qualified Control.Monad.Error.Class as E
11-
import Control.Monad.Reader (ask)
1211
import Data.Functor
1312
import Data.Maybe (listToMaybe)
1413
import qualified Data.Text as T
1514
import qualified Refinery.Tactic as R
1615
import qualified Text.Megaparsec as P
1716
import Wingman.Auto
18-
import Wingman.Machinery (useNameFromHypothesis, getOccNameType, createImportedHyInfo, useNameFromContext, lookupNameInContext, getCurrentDefinitions)
17+
import Wingman.Machinery (useNameFromHypothesis, useNameFromContext, getCurrentDefinitions)
1918
import Wingman.Metaprogramming.Lexer
2019
import Wingman.Metaprogramming.Parser.Documentation
2120
import Wingman.Metaprogramming.ProofState (proofState, layout)
@@ -454,7 +453,9 @@ attempt_it rsl ctx jdg program =
454453
tt
455454
pure $ case res of
456455
Left tes -> Left $ wrapError $ show tes
457-
Right rtr -> Right $ layout $ proofState rtr
456+
Right rtr -> Right
457+
$ layout (cfg_proofstate_styling $ ctxConfig ctx)
458+
$ proofState rtr
458459

459460

460461
parseMetaprogram :: T.Text -> TacticsM ()

plugins/hls-tactics-plugin/src/Wingman/Metaprogramming/ProofState.hs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,24 +43,26 @@ data Ann
4343
forceMarkdownNewlines :: String -> String
4444
forceMarkdownNewlines = unlines . fmap (<> " ") . lines
4545

46-
layout :: Doc Ann -> String
47-
layout
46+
layout :: Bool -> Doc Ann -> String
47+
layout use_styling
4848
= forceMarkdownNewlines
4949
. T.unpack
5050
. renderSimplyDecorated id
51-
renderAnn
52-
renderUnann
51+
(renderAnn use_styling)
52+
(renderUnann use_styling)
5353
. layoutPretty (LayoutOptions $ AvailablePerLine 80 0.6)
5454

55-
renderAnn :: Ann -> T.Text
56-
renderAnn Goal = "<span style='color:#ef4026;'>"
57-
renderAnn Hypoth = "```haskell\n"
58-
renderAnn Status = "<span style='color:#6495ED;'>"
59-
60-
renderUnann :: Ann -> T.Text
61-
renderUnann Goal = "</span>"
62-
renderUnann Hypoth = "\n```\n"
63-
renderUnann Status = "</span>"
55+
renderAnn :: Bool -> Ann -> T.Text
56+
renderAnn False _ = ""
57+
renderAnn _ Goal = "<span style='color:#ef4026;'>"
58+
renderAnn _ Hypoth = "```haskell\n"
59+
renderAnn _ Status = "<span style='color:#6495ED;'>"
60+
61+
renderUnann :: Bool -> Ann -> T.Text
62+
renderUnann False _ = ""
63+
renderUnann _ Goal = "</span>"
64+
renderUnann _ Hypoth = "\n```\n"
65+
renderUnann _ Status = "</span>"
6466

6567
proofState :: RunTacticResults -> Doc Ann
6668
proofState RunTacticResults{rtr_subgoals} =

plugins/hls-tactics-plugin/src/Wingman/Types.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ data Config = Config
8787
{ cfg_max_use_ctor_actions :: Int
8888
, cfg_timeout_seconds :: Int
8989
, cfg_auto_gas :: Int
90+
, cfg_proofstate_styling :: Bool
9091
}
9192
deriving (Eq, Ord, Show)
9293

@@ -95,6 +96,7 @@ emptyConfig = Config
9596
{ cfg_max_use_ctor_actions = 5
9697
, cfg_timeout_seconds = 2
9798
, cfg_auto_gas = 4
99+
, cfg_proofstate_styling = True
98100
}
99101

100102
------------------------------------------------------------------------------

0 commit comments

Comments
 (0)