mirror of
https://github.com/haskell/haskell-language-server.git
synced 2024-09-11 08:45:35 +03:00
Sort vscode extension schema json by keys (#3203)
Makes it easier to copy and paste configurations into VSCode and reviewing what options have been added and removed. Remove code-duplication, namely ghcide exe loses some capabilities, as it is destined to be removed sooner or later. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Michael Peyton Jones <me@michaelpj.com>
This commit is contained in:
parent
c422cf373a
commit
6f9b435331
@ -190,8 +190,6 @@ data Command
|
||||
| Db {hieOptions :: HieDb.Options, hieCommand :: HieDb.Command}
|
||||
-- ^ Run a command in the hiedb
|
||||
| LSP -- ^ Run the LSP server
|
||||
| PrintExtensionSchema
|
||||
| PrintDefaultConfig
|
||||
| Custom {ideCommand :: IdeCommand IdeState} -- ^ User defined
|
||||
deriving Show
|
||||
|
||||
@ -208,8 +206,6 @@ commandP plugins =
|
||||
hsubparser(command "typecheck" (info (Check <$> fileCmd) fileInfo)
|
||||
<> command "hiedb" (info (Db <$> HieDb.optParser "" True <*> HieDb.cmdParser) hieInfo)
|
||||
<> command "lsp" (info (pure LSP) lspInfo)
|
||||
<> command "vscode-extension-schema" extensionSchemaCommand
|
||||
<> command "generate-default-config" generateDefaultConfigCommand
|
||||
<> pluginCommands
|
||||
)
|
||||
where
|
||||
@ -217,12 +213,6 @@ commandP plugins =
|
||||
lspInfo = fullDesc <> progDesc "Start talking to an LSP client"
|
||||
fileInfo = fullDesc <> progDesc "Used as a test bed to check your IDE will work"
|
||||
hieInfo = fullDesc <> progDesc "Query .hie files"
|
||||
extensionSchemaCommand =
|
||||
info (pure PrintExtensionSchema)
|
||||
(fullDesc <> progDesc "Print generic config schema for plugins (used in the package.json of haskell vscode extension)")
|
||||
generateDefaultConfigCommand =
|
||||
info (pure PrintDefaultConfig)
|
||||
(fullDesc <> progDesc "Print config supported by the server with default values")
|
||||
|
||||
pluginCommands = mconcat
|
||||
[ command (T.unpack pId) (Custom <$> p)
|
||||
@ -330,10 +320,6 @@ defaultMain recorder Arguments{..} = withHeapStats (cmapWithPrio LogHeapStats re
|
||||
numProcessors <- getNumProcessors
|
||||
|
||||
case argCommand of
|
||||
PrintExtensionSchema ->
|
||||
LT.putStrLn $ decodeUtf8 $ A.encodePretty $ pluginsToVSCodeExtensionSchema argsHlsPlugins
|
||||
PrintDefaultConfig ->
|
||||
LT.putStrLn $ decodeUtf8 $ A.encodePretty $ pluginsToDefaultConfig argsHlsPlugins
|
||||
LSP -> withNumCapabilities (maybe (numProcessors `div` 2) fromIntegral argsThreads) $ do
|
||||
t <- offsetTime
|
||||
log Info $ LogLspStart (pluginId <$> ipMap argsHlsPlugins)
|
||||
|
@ -66,6 +66,10 @@ getArguments exeName plugins = execParser opts
|
||||
opts = info ((
|
||||
VersionMode <$> printVersionParser exeName
|
||||
<|> probeToolsParser exeName
|
||||
<|> hsubparser
|
||||
( command "vscode-extension-schema" extensionSchemaCommand
|
||||
<> command "generate-default-config" generateDefaultConfigCommand
|
||||
)
|
||||
<|> listPluginsParser
|
||||
<|> BiosMode <$> biosParser
|
||||
<|> Ghcide <$> arguments plugins
|
||||
@ -76,6 +80,13 @@ getArguments exeName plugins = execParser opts
|
||||
<> progDesc "Used as a test bed to check your IDE Client will work"
|
||||
<> header (exeName ++ " - GHC Haskell LSP server"))
|
||||
|
||||
extensionSchemaCommand =
|
||||
info (pure VSCodeExtensionSchemaMode)
|
||||
(fullDesc <> progDesc "Print generic config schema for plugins (used in the package.json of haskell vscode extension)")
|
||||
generateDefaultConfigCommand =
|
||||
info (pure DefaultConfigurationMode)
|
||||
(fullDesc <> progDesc "Print config supported by the server with default values")
|
||||
|
||||
printVersionParser :: String -> Parser PrintVersion
|
||||
printVersionParser exeName =
|
||||
flag' PrintVersion
|
||||
|
@ -12,12 +12,13 @@ module Ide.Main(defaultMain, runLspMode, Log(..)) where
|
||||
|
||||
import Control.Monad.Extra
|
||||
import qualified Data.Aeson.Encode.Pretty as A
|
||||
import qualified Data.ByteString.Lazy.Char8 as LBS
|
||||
import Data.Coerce (coerce)
|
||||
import Data.Default
|
||||
import Data.List (sort)
|
||||
import Data.Text (Text)
|
||||
import qualified Data.Text as T
|
||||
import Data.Text.Lazy.Encoding (decodeUtf8)
|
||||
import qualified Data.Text.Lazy.IO as LT
|
||||
import Development.IDE.Core.Rules hiding (Log, logToPriority)
|
||||
import Development.IDE.Core.Tracing (withTelemetryLogger)
|
||||
import Development.IDE.Main (isLSP)
|
||||
@ -96,10 +97,9 @@ defaultMain recorder args idePlugins = do
|
||||
runLspMode recorder ghcideArgs idePlugins
|
||||
|
||||
VSCodeExtensionSchemaMode -> do
|
||||
LBS.putStrLn $ A.encodePretty $ pluginsToVSCodeExtensionSchema idePlugins
|
||||
|
||||
LT.putStrLn $ decodeUtf8 $ encodePrettySorted $ pluginsToVSCodeExtensionSchema idePlugins
|
||||
DefaultConfigurationMode -> do
|
||||
LBS.putStrLn $ A.encodePretty $ pluginsToDefaultConfig idePlugins
|
||||
LT.putStrLn $ decodeUtf8 $ encodePrettySorted $ pluginsToDefaultConfig idePlugins
|
||||
PrintLibDir -> do
|
||||
d <- getCurrentDirectory
|
||||
let initialFp = d </> "a"
|
||||
@ -107,6 +107,10 @@ defaultMain recorder args idePlugins = do
|
||||
cradle <- Session.loadCradle def hieYaml d
|
||||
(CradleSuccess libdir) <- HieBios.getRuntimeGhcLibDir cradle
|
||||
putStr libdir
|
||||
where
|
||||
encodePrettySorted = A.encodePretty' A.defConfig
|
||||
{ A.confCompare = compare
|
||||
}
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user