|
1 |
| -{-# LANGUAGE CPP #-} |
2 |
| -{-# LANGUAGE DataKinds #-} |
3 |
| -{-# LANGUAGE GADTs #-} |
4 |
| -{-# LANGUAGE OverloadedStrings #-} |
5 |
| -{-# LANGUAGE PartialTypeSignatures #-} |
6 |
| -{-# LANGUAGE TemplateHaskell #-} |
7 |
| -module Haskell.Ide.Engine.Plugin.Base where |
| 1 | +{-# LANGUAGE CPP, TemplateHaskell, OverloadedStrings #-} |
| 2 | +-- | Information and display strings for HIE's version |
| 3 | +-- and the current project's version |
| 4 | +module Haskell.Ide.Engine.Version where |
8 | 5 |
|
9 | 6 | import Control.Exception
|
10 |
| -import Data.Aeson |
11 |
| -import Data.Foldable |
12 |
| -import qualified Data.Map as Map |
13 | 7 | import Data.Maybe
|
14 |
| -import qualified Data.Text as T |
15 |
| -import qualified Data.Versions as V |
16 | 8 | import Development.GitRev (gitCommitCount)
|
17 | 9 | import Distribution.System (buildArch)
|
18 | 10 | import Distribution.Text (display)
|
19 |
| -import Haskell.Ide.Engine.MonadTypes |
| 11 | +import Options.Applicative.Simple (simpleVersion) |
20 | 12 | import Haskell.Ide.Engine.Cradle (isStackCradle)
|
21 | 13 | import qualified HIE.Bios.Types as BIOS
|
22 |
| -import Options.Applicative.Simple (simpleVersion) |
23 | 14 | import qualified Paths_haskell_ide_engine as Meta
|
24 |
| - |
| 15 | +import qualified System.Log.Logger as L |
| 16 | +import qualified Data.Text as T |
| 17 | +import qualified Data.Versions as V |
25 | 18 | import System.Directory
|
26 | 19 | import System.Info
|
27 | 20 | import System.Process
|
28 |
| -import qualified System.Log.Logger as L |
29 |
| - |
30 |
| --- --------------------------------------------------------------------- |
31 |
| - |
32 |
| -baseDescriptor :: PluginId -> PluginDescriptor |
33 |
| -baseDescriptor plId = PluginDescriptor |
34 |
| - { pluginId = plId |
35 |
| - , pluginName = "HIE Base" |
36 |
| - , pluginDesc = "Commands for HIE itself" |
37 |
| - , pluginCommands = |
38 |
| - [ PluginCommand "version" "return HIE version" versionCmd |
39 |
| - , PluginCommand "plugins" "list available plugins" pluginsCmd |
40 |
| - , PluginCommand "commands" "list available commands for a given plugin" commandsCmd |
41 |
| - , PluginCommand "commandDetail" "list parameters required for a given command" commandDetailCmd |
42 |
| - ] |
43 |
| - , pluginCodeActionProvider = Nothing |
44 |
| - , pluginDiagnosticProvider = Nothing |
45 |
| - , pluginHoverProvider = Nothing |
46 |
| - , pluginSymbolProvider = Nothing |
47 |
| - , pluginFormattingProvider = Nothing |
48 |
| - } |
49 |
| - |
50 |
| --- --------------------------------------------------------------------- |
51 |
| - |
52 |
| -versionCmd :: CommandFunc () T.Text |
53 |
| -versionCmd = CmdSync $ \_ -> return $ IdeResultOk (T.pack version) |
54 |
| - |
55 |
| -pluginsCmd :: CommandFunc () IdePlugins |
56 |
| -pluginsCmd = CmdSync $ \_ -> |
57 |
| - IdeResultOk <$> getPlugins |
58 |
| - |
59 |
| -commandsCmd :: CommandFunc T.Text [CommandName] |
60 |
| -commandsCmd = CmdSync $ \p -> do |
61 |
| - IdePlugins plugins <- getPlugins |
62 |
| - case Map.lookup p plugins of |
63 |
| - Nothing -> return $ IdeResultFail $ IdeError |
64 |
| - { ideCode = UnknownPlugin |
65 |
| - , ideMessage = "Can't find plugin:" <> p |
66 |
| - , ideInfo = toJSON p |
67 |
| - } |
68 |
| - Just pl -> return $ IdeResultOk $ map commandName $ pluginCommands pl |
69 |
| - |
70 |
| -commandDetailCmd :: CommandFunc (T.Text, T.Text) T.Text |
71 |
| -commandDetailCmd = CmdSync $ \(p,command) -> do |
72 |
| - IdePlugins plugins <- getPlugins |
73 |
| - case Map.lookup p plugins of |
74 |
| - Nothing -> return $ IdeResultFail $ IdeError |
75 |
| - { ideCode = UnknownPlugin |
76 |
| - , ideMessage = "Can't find plugin:" <> p |
77 |
| - , ideInfo = toJSON p |
78 |
| - } |
79 |
| - Just pl -> case find (\cmd -> command == commandName cmd) (pluginCommands pl) of |
80 |
| - Nothing -> return $ IdeResultFail $ IdeError |
81 |
| - { ideCode = UnknownCommand |
82 |
| - , ideMessage = "Can't find command:" <> command |
83 |
| - , ideInfo = toJSON command |
84 |
| - } |
85 |
| - Just detail -> return $ IdeResultOk (commandDesc detail) |
86 |
| - |
87 |
| --- --------------------------------------------------------------------- |
88 | 21 |
|
89 |
| -version :: String |
90 |
| -version = |
| 22 | +hieVersion :: String |
| 23 | +hieVersion = |
91 | 24 | let commitCount = $gitCommitCount
|
92 | 25 | in concat $ concat
|
93 | 26 | [ [$(simpleVersion Meta.version)]
|
|
0 commit comments