Skip to content

Commit

Permalink
Merge branch 'master' into fix-win-cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Ailrun authored Jan 11, 2021
2 parents 54ada8b + e766971 commit 7a75f91
Show file tree
Hide file tree
Showing 25 changed files with 740 additions and 326 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ jobs:
- uses: cachix/cachix-action@v8
with:
name: haskell-language-server
authToken: '${{ secrets.HLS_CACHIX_AUTH_TOKEN }}'
authToken: ${{ secrets.HLS_CACHIX_AUTH_TOKEN }}
- run: nix-shell --argstr compiler ${{ matrix.ghc }} --run "cabal update && cabal build"
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ background](https://neilmitchell.blogspot.com/2020/01/one-haskell-ide-to-rule-th
- [Building](#building)
- [Install via cabal](#install-via-cabal)
- [Install specific GHC Version](#install-specific-ghc-version)
- [Installation from Hackage](#installation-from-hackage)
- [Configuring haskell-language-server](#configuring-haskell-language-server)
- [Configuring your project build](#configuring-your-project-build)
- [Configuring your editor](#configuring-your-editor)
Expand Down Expand Up @@ -245,6 +246,12 @@ If your desired ghc has been found, you use it to install haskell-language-serve
./cabal-hls-install hls-8.6.5
```

### Installation from Hackage

Direct installation from Hackage, while possible via `cabal install haskell-language-server`, is not recommended for most people.
Said command builds the `haskell-language-server` binary and installs it in the default Cabal binaries folder,
but the binary will only work with projects that use the same GHC version that built it.

## Configuring `haskell-language-server`

Language servers like `haskell-language-server` expose most of their configuration via the client (i.e. the editor).
Expand Down
21 changes: 12 additions & 9 deletions ghcide/bench/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,23 @@ examples:
# Medium-sized project without TH
- name: Cabal
version: 3.0.0.0
module: Distribution/Simple.hs
modules:
- Distribution/Simple.hs
- Distribution/Types/Module.hs
# Small-sized project with TH
- name: haskell-lsp-types
version: 0.22.0.0
module: src/Language/Haskell/LSP/Types/Lens.hs
# - path: path-to-example
# module: path-to-module
- name: lsp-types
version: 1.0.0.1
modules:
- src/Language/LSP/VFS.hs
- src/Language/LSP/Types/Lens.hs

# The set of experiments to execute
experiments:
- hover
- edit
- getDefinition
- "edit"
- "hover"
- "hover after edit"
- "getDefinition"
- "getDefinition after edit"
- "completions after edit"
- "code actions"
- "code actions after edit"
Expand Down
13 changes: 11 additions & 2 deletions ghcide/bench/exe/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,23 @@
import Control.Exception.Safe
import Experiments
import Options.Applicative
import System.IO
import Control.Monad

optsP :: Parser (Config, Bool)
optsP = (,) <$> configP <*> switch (long "no-clean")

main :: IO ()
main = do
config <- execParser $ info (configP <**> helper) fullDesc
hSetBuffering stdout LineBuffering
hSetBuffering stderr LineBuffering
(config, noClean) <- execParser $ info (optsP <**> helper) fullDesc
let ?config = config

hPrint stderr config

output "starting test"

SetupResult{..} <- setup

runBenchmarks experiments `finally` cleanUp
runBenchmarks experiments `finally` unless noClean cleanUp
14 changes: 10 additions & 4 deletions ghcide/bench/hist/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import Experiments.Types (Example, exampleToOptions)
import qualified Experiments.Types as E
import GHC.Generics (Generic)
import Numeric.Natural (Natural)
import Development.Shake.Classes


config :: FilePath
Expand All @@ -70,7 +71,7 @@ main = shakeArgs shakeOptions {shakeChange = ChangeModtimeAndDigest} $ do
configStatic <- liftIO $ readConfigIO config
let build = outputFolder configStatic
buildRules build ghcideBuildRules
benchRules build resource (MkBenchRules (benchGhcide $ samples configStatic) "ghcide")
benchRules build resource (MkBenchRules (askOracle $ GetSamples ()) benchGhcide "ghcide")
csvRules build
svgRules build
action $ allTargets build
Expand Down Expand Up @@ -98,14 +99,18 @@ createBuildSystem userRules = do

_ <- addOracle $ \GetExperiments {} -> experiments <$> readConfig config
_ <- addOracle $ \GetVersions {} -> versions <$> readConfig config
_ <- addOracle $ \GetExamples{} -> examples <$> readConfig config
_ <- addOracle $ \(GetExample name) -> find (\e -> getExampleName e == name) . examples <$> readConfig config
_ <- versioned 1 $ addOracle $ \GetExamples{} -> examples <$> readConfig config
_ <- versioned 1 $ addOracle $ \(GetExample name) -> find (\e -> getExampleName e == name) . examples <$> readConfig config
_ <- addOracle $ \GetBuildSystem {} -> buildTool <$> readConfig config
_ <- addOracle $ \GetSamples{} -> samples <$> readConfig config

benchResource <- newResource "ghcide-bench" 1

userRules benchResource

newtype GetSamples = GetSamples () deriving newtype (Binary, Eq, Hashable, NFData, Show)
type instance RuleResult GetSamples = Natural

--------------------------------------------------------------------------------

buildGhcide :: BuildSystem -> [CmdOption] -> FilePath -> Action ()
Expand All @@ -130,9 +135,10 @@ buildGhcide Stack args out =

benchGhcide
:: Natural -> BuildSystem -> [CmdOption] -> BenchProject Example -> Action ()
benchGhcide samples buildSystem args BenchProject{..} =
benchGhcide samples buildSystem args BenchProject{..} = do
command_ args "ghcide-bench" $
[ "--timeout=3000",
"--no-clean",
"-v",
"--samples=" <> show samples,
"--csv=" <> outcsv,
Expand Down
Loading

0 comments on commit 7a75f91

Please sign in to comment.