mirror of
https://github.com/haskell/ghcide.git
synced 2024-08-16 09:01:13 +03:00
Rename hie-core to ghcide (#2820)
* Rename hie-core to ghcide The name `hie-core` has caused a lot of confusion as to how we relate to haskell-ide-engine so changing it should hopefully help with that. I also think that ghcide is still a good name once we hopefully integrate with haskell-ide-engine more closely. The name ghcide seems to have a reasonable amount of support on Twitter https://twitter.com/ndm_haskell/status/1170681262987710464 which is of course the only good way to come up with names. * Add a readme that points people to the new directory. * Fix bogus replacements * Use a proper link * links are hard
This commit is contained in:
parent
5ac4265e9b
commit
5da86c3e44
21
.ghci
21
.ghci
@ -1,21 +0,0 @@
|
||||
:set -Wunused-binds -Wunused-imports -Worphans -Wunused-matches -Wincomplete-patterns
|
||||
|
||||
:set -XBangPatterns
|
||||
:set -XDeriveFunctor
|
||||
:set -XDeriveGeneric
|
||||
:set -XGeneralizedNewtypeDeriving
|
||||
:set -XLambdaCase
|
||||
:set -XNamedFieldPuns
|
||||
:set -XOverloadedStrings
|
||||
:set -XRecordWildCards
|
||||
:set -XScopedTypeVariables
|
||||
:set -XStandaloneDeriving
|
||||
:set -XTupleSections
|
||||
:set -XTypeApplications
|
||||
:set -XViewPatterns
|
||||
|
||||
:set -package=ghc
|
||||
:set -hide-package=ghc-lib-parser
|
||||
:set -DGHC_STABLE
|
||||
:set -isrc -iexe
|
||||
:load Main
|
@ -60,7 +60,7 @@ hidden = [
|
||||
]
|
||||
|
||||
da_haskell_library(
|
||||
name = "hie-core",
|
||||
name = "ghcide",
|
||||
srcs = glob(["src/**/*.hs"]),
|
||||
hackage_deps = depends + [
|
||||
"ghc-lib",
|
||||
@ -83,7 +83,7 @@ cc_library(
|
||||
) if not is_windows else None
|
||||
|
||||
da_haskell_library(
|
||||
name = "hie-core-public",
|
||||
name = "ghcide-public",
|
||||
srcs = glob(["src/**/*.hs"]),
|
||||
compiler_flags = ["-DGHC_STABLE"],
|
||||
hackage_deps = depends + [
|
||||
@ -104,7 +104,7 @@ da_haskell_library(
|
||||
)
|
||||
|
||||
da_haskell_binary(
|
||||
name = "hie-core-exe",
|
||||
name = "ghcide-exe",
|
||||
srcs = glob(["exe/**/*.hs"]),
|
||||
hackage_deps = [
|
||||
"base",
|
||||
@ -124,6 +124,6 @@ da_haskell_binary(
|
||||
src_strip_prefix = "test",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"hie-core-public",
|
||||
"ghcide-public",
|
||||
],
|
||||
)
|
||||
|
34
README.md
34
README.md
@ -1,4 +1,4 @@
|
||||
# `hie-core` (Haskell IDE engine)
|
||||
# `ghcide`
|
||||
|
||||
Our vision is that you should build an IDE by combining:
|
||||
|
||||
@ -6,7 +6,7 @@ Our vision is that you should build an IDE by combining:
|
||||
<img style="float:right;" src="img/vscode2.png"/>
|
||||
|
||||
* [`hie-bios`](https://github.com/mpickering/hie-bios) for determining where your files are, what are their dependencies, what extensions are enabled and so on;
|
||||
* `hie-core` (i.e. this library) for defining how to type check, when to type check, and producing diagnostic messages;
|
||||
* `ghcide` (i.e. this library) for defining how to type check, when to type check, and producing diagnostic messages;
|
||||
* A bunch of plugins that haven't yet been written, e.g. [`hie-hlint`](https://github.com/ndmitchell/hlint) and [`hie-ormolu`](https://github.com/tweag/ormolu), to choose which features you want;
|
||||
* [`haskell-lsp`](https://github.com/alanz/haskell-lsp) for sending those messages to a [Language Server Protocol (LSP)](https://microsoft.github.io/language-server-protocol/) server;
|
||||
* An extension for your editor. We provide a [VS Code extension](https://code.visualstudio.com/api) as `extension` in this directory, although the components work in other LSP editors too (see below for instructions using Emacs).
|
||||
@ -15,7 +15,7 @@ There are more details about our approach [in this blog post](https://4ta.uk/p/s
|
||||
|
||||
## Using it
|
||||
|
||||
### Install `hie-core`
|
||||
### Install `ghcide`
|
||||
|
||||
#### With Nix
|
||||
|
||||
@ -23,17 +23,17 @@ There are more details about our approach [in this blog post](https://4ta.uk/p/s
|
||||
|
||||
#### With Cabal or Stack
|
||||
|
||||
First install the `hie-core` binary using `stack` or `cabal`, e.g.
|
||||
First install the `ghcide` binary using `stack` or `cabal`, e.g.
|
||||
|
||||
1. `git clone https://github.com/digital-asset/daml.git`
|
||||
2. `cd daml/compiler/hie-core`
|
||||
2. `cd daml/compiler/ghcide`
|
||||
3. `cabal install` or `stack install` (and make sure `~/.local/bin` is on your `$PATH`)
|
||||
|
||||
It's important that `hie-core` is compiled with the same compiler you use to build your projects.
|
||||
It's important that `ghcide` is compiled with the same compiler you use to build your projects.
|
||||
|
||||
### Test `hie-core`
|
||||
### Test `ghcide`
|
||||
|
||||
Next, check that `hie-core` is capable of loading your code. Change to the project directory and run `hie-core`, which will try and load everything using the same code as the IDE, but in a way that's much easier to understand. For example, taking the example of [`shake`](https://github.com/ndmitchell/shake), running `hie-core` gives some error messages and warnings before reporting at the end:
|
||||
Next, check that `ghcide` is capable of loading your code. Change to the project directory and run `ghcide`, which will try and load everything using the same code as the IDE, but in a way that's much easier to understand. For example, taking the example of [`shake`](https://github.com/ndmitchell/shake), running `ghcide` gives some error messages and warnings before reporting at the end:
|
||||
|
||||
```
|
||||
Files that worked: 152
|
||||
@ -49,21 +49,21 @@ Done
|
||||
|
||||
Of the 158 files in Shake, as of this moment, 152 can be loaded by the IDE, but 6 can't (error messages for the reasons they can't be loaded are given earlier). The failing files are all prototype work or test output, meaning I can confidently use Shake.
|
||||
|
||||
The `hie-core` executable mostly relies on [`hie-bios`](https://github.com/mpickering/hie-bios) to do the difficult work of setting up your GHC environment. If it doesn't work, see [the `hie-bios` manual](https://github.com/mpickering/hie-bios#readme) to get it working. My default fallback is to figure it out by hand and create a `direct` style [`hie.yaml`](https://github.com/ndmitchell/shake/blob/master/hie.yaml) listing the command line arguments to load the project.
|
||||
The `ghcide` executable mostly relies on [`hie-bios`](https://github.com/mpickering/hie-bios) to do the difficult work of setting up your GHC environment. If it doesn't work, see [the `hie-bios` manual](https://github.com/mpickering/hie-bios#readme) to get it working. My default fallback is to figure it out by hand and create a `direct` style [`hie.yaml`](https://github.com/ndmitchell/shake/blob/master/hie.yaml) listing the command line arguments to load the project.
|
||||
|
||||
Once you have got `hie-core` working outside the editor, the next step is to pick which editor to integrate with.
|
||||
Once you have got `ghcide` working outside the editor, the next step is to pick which editor to integrate with.
|
||||
|
||||
### Using with VS Code
|
||||
|
||||
Install the VS code extension (see https://code.visualstudio.com/docs/setup/mac for details on adding `code` to your `$PATH`):
|
||||
|
||||
1. `cd compiler/hie-core/extension`
|
||||
1. `cd compiler/ghcide/extension`
|
||||
2. `npm ci`
|
||||
3. `npm install vsce --global` (may require `sudo`)
|
||||
4. `vsce package`
|
||||
5. `code --install-extension hie-core-0.0.1.vsix`
|
||||
5. `code --install-extension ghcide-0.0.1.vsix`
|
||||
|
||||
Now openning a `.hs` file should work with `hie-core`.
|
||||
Now openning a `.hs` file should work with `ghcide`.
|
||||
|
||||
### Using with Emacs
|
||||
|
||||
@ -86,7 +86,7 @@ If you don't already have [MELPA](https://melpa.org/#/) package installation con
|
||||
(use-package lsp-haskell
|
||||
:ensure t
|
||||
:config
|
||||
(setq lsp-haskell-process-path-hie "hie-core")
|
||||
(setq lsp-haskell-process-path-hie "ghcide")
|
||||
(setq lsp-haskell-process-args-hie '())
|
||||
;; Comment/uncomment this line to see interactions between lsp client/server.
|
||||
;;(setq lsp-log-io t)
|
||||
@ -103,7 +103,7 @@ Add this to your vim config:
|
||||
let g:LanguageClient_rootMarkers = ['*.cabal', 'stack.yaml']
|
||||
let g:LanguageClient_serverCommands = {
|
||||
\ 'rust': ['rls'],
|
||||
\ 'haskell': ['hie-core', '--lsp'],
|
||||
\ 'haskell': ['ghcide', '--lsp'],
|
||||
\ }
|
||||
```
|
||||
|
||||
@ -116,8 +116,8 @@ Add this to your vim config:
|
||||
|
||||
```vim
|
||||
au User lsp_setup call lsp#register_server({
|
||||
\ 'name': 'hie-core',
|
||||
\ 'cmd': {server_info->['/your/path/to/hie-core', '--lsp']},
|
||||
\ 'name': 'ghcide',
|
||||
\ 'cmd': {server_info->['/your/path/to/ghcide', '--lsp']},
|
||||
\ 'whitelist': ['haskell'],
|
||||
\ })
|
||||
```
|
||||
|
@ -18,7 +18,7 @@ getArguments = execParser opts
|
||||
opts = info (arguments <**> helper)
|
||||
( fullDesc
|
||||
<> progDesc "Used as a test bed to check your IDE will work"
|
||||
<> header "hie-core - the core of a Haskell IDE")
|
||||
<> header "ghcide - the core of a Haskell IDE")
|
||||
|
||||
arguments :: Parser Arguments
|
||||
arguments = Arguments
|
||||
|
@ -52,7 +52,7 @@ main :: IO ()
|
||||
main = do
|
||||
-- WARNING: If you write to stdout before runLanguageServer
|
||||
-- then the language server will not work
|
||||
hPutStrLn stderr $ "Starting hie-core (GHC v" ++ showVersion compilerVersion ++ ")"
|
||||
hPutStrLn stderr $ "Starting ghcide (GHC v" ++ showVersion compilerVersion ++ ")"
|
||||
Arguments{..} <- getArguments
|
||||
|
||||
-- lock to avoid overlapping output on stdout
|
||||
|
2
extension/package-lock.json
generated
2
extension/package-lock.json
generated
@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "hie-core",
|
||||
"name": "ghcide",
|
||||
"version": "0.0.1",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hie-core",
|
||||
"displayName": "hie-core",
|
||||
"name": "ghcide",
|
||||
"displayName": "ghcide",
|
||||
"publisher": "digitalasset",
|
||||
"repository": {
|
||||
"type" : "git",
|
||||
@ -31,8 +31,8 @@
|
||||
"properties": {
|
||||
"hic.executablePath": {
|
||||
"type": "string",
|
||||
"default": "hie-core",
|
||||
"description": "The location of your hie-core executable"
|
||||
"default": "ghcide",
|
||||
"description": "The location of your ghcide executable"
|
||||
},
|
||||
"hic.arguments": {
|
||||
"type": "string",
|
||||
|
@ -7,9 +7,9 @@ cd "$(dirname "$0")"/../..
|
||||
export RULES_HASKELL_EXEC_ROOT=$PWD/
|
||||
ENV_FILE=$(mktemp)
|
||||
ARGS_FILE=$(mktemp)
|
||||
bazel build //compiler/hie-core:hie-core-exe >/dev/null 2>&1
|
||||
bazel build //compiler/ghcide:ghcide-exe >/dev/null 2>&1
|
||||
bazel run --define hie_bios_ghci=True //compiler/damlc:damlc@ghci -- "$ENV_FILE" "$ARGS_FILE" >/dev/null 2>&1
|
||||
source "$ENV_FILE"
|
||||
export HIE_BIOS_ARGS="$ARGS_FILE"
|
||||
./bazel-bin/compiler/hie-core/hie-core-exe $@
|
||||
./bazel-bin/compiler/ghcide/ghcide-exe $@
|
||||
|
@ -1,7 +1,7 @@
|
||||
cabal-version: 1.20
|
||||
build-type: Simple
|
||||
category: Development
|
||||
name: hie-core
|
||||
name: ghcide
|
||||
version: 0.0.1
|
||||
license: Apache-2.0
|
||||
license-file: LICENSE
|
||||
@ -114,7 +114,7 @@ library
|
||||
Development.IDE.Spans.Documentation
|
||||
Development.IDE.Spans.Type
|
||||
|
||||
executable hie-core
|
||||
executable ghcide
|
||||
default-language: Haskell2010
|
||||
hs-source-dirs: exe
|
||||
ghc-options: -threaded
|
||||
@ -130,7 +130,7 @@ executable hie-core
|
||||
ghc,
|
||||
haskell-lsp,
|
||||
hie-bios,
|
||||
hie-core,
|
||||
ghcide,
|
||||
optparse-applicative,
|
||||
shake,
|
||||
text
|
||||
@ -142,11 +142,11 @@ executable hie-core
|
||||
TupleSections
|
||||
ViewPatterns
|
||||
|
||||
test-suite hie-core-tests
|
||||
test-suite ghcide-tests
|
||||
type: exitcode-stdio-1.0
|
||||
default-language: Haskell2010
|
||||
build-tool-depends:
|
||||
hie-core:hie-core
|
||||
ghcide:ghcide
|
||||
build-depends:
|
||||
base,
|
||||
containers,
|
@ -1,6 +1,6 @@
|
||||
:: Copyright (c) 2019 The DAML Authors. All rights reserved.
|
||||
:: SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
@REM Install hie-core where cabal install would put it on Windows
|
||||
@REM Install ghcide where cabal install would put it on Windows
|
||||
@REM but avoid checking configure or installing local libraries (faster)
|
||||
ghc Main -o dist\obj\hie-core.exe -XBangPatterns -XDeriveGeneric -XGeneralizedNewtypeDeriving -XLambdaCase -XNamedFieldPuns -XRecordWildCards -XScopedTypeVariables -XStandaloneDeriving -XTupleSections -XTypeApplications -XViewPatterns -package=ghc -DGHC_STABLE -isrc -iexe -outputdir dist\obj && copy dist\obj\hie-core.exe %AppData%\cabal\bin\hie-core.exe
|
||||
ghc Main -o dist\obj\ghcide.exe -XBangPatterns -XDeriveGeneric -XGeneralizedNewtypeDeriving -XLambdaCase -XNamedFieldPuns -XRecordWildCards -XScopedTypeVariables -XStandaloneDeriving -XTupleSections -XTypeApplications -XViewPatterns -package=ghc -DGHC_STABLE -isrc -iexe -outputdir dist\obj && copy dist\obj\ghcide.exe %AppData%\cabal\bin\ghcide.exe
|
||||
|
@ -281,16 +281,16 @@ runCpp dflags filename contents = withTempDir $ \dir -> do
|
||||
dflags <- return $ addIncludePathsQuote (takeDirectory filename) dflags
|
||||
|
||||
-- Location information is wrong, so we fix that by patching it afterwards.
|
||||
let inp = dir </> "___HIE_CORE_MAGIC___"
|
||||
let inp = dir </> "___GHCIDE_MAGIC___"
|
||||
withBinaryFile inp WriteMode $ \h ->
|
||||
hPutStringBuffer h contents
|
||||
doCpp dflags True inp out
|
||||
|
||||
-- Fix up the filename in lines like:
|
||||
-- # 1 "C:/Temp/extra-dir-914611385186/___HIE_CORE_MAGIC___"
|
||||
-- # 1 "C:/Temp/extra-dir-914611385186/___GHCIDE_MAGIC___"
|
||||
let tweak x
|
||||
| Just x <- stripPrefix "# " x
|
||||
, "___HIE_CORE_MAGIC___" `isInfixOf` x
|
||||
, "___GHCIDE_MAGIC___" `isInfixOf` x
|
||||
, let num = takeWhile (not . isSpace) x
|
||||
-- important to use /, and never \ for paths, even on Windows, since then C escapes them
|
||||
-- and GHC gets all confused
|
||||
|
@ -34,7 +34,7 @@ diagFromText diagSource sev loc msg = (toNormalizedFilePath $ srcSpanToFilename
|
||||
Diagnostic
|
||||
{ _range = srcSpanToRange loc
|
||||
, _severity = Just sev
|
||||
, _source = Just diagSource -- not shown in the IDE, but useful for hie-core developers
|
||||
, _source = Just diagSource -- not shown in the IDE, but useful for ghcide developers
|
||||
, _message = msg
|
||||
, _code = Nothing
|
||||
, _relatedInformation = Nothing
|
||||
|
@ -8,7 +8,7 @@ load(
|
||||
)
|
||||
|
||||
da_haskell_library(
|
||||
name = "hie-core-testing",
|
||||
name = "ghcide-testing",
|
||||
srcs = glob(["src/**/*.hs"]),
|
||||
hackage_deps = [
|
||||
"base",
|
||||
@ -23,12 +23,12 @@ da_haskell_library(
|
||||
src_strip_prefix = "src",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//compiler/hie-core",
|
||||
"//compiler/ghcide",
|
||||
],
|
||||
)
|
||||
|
||||
da_haskell_library(
|
||||
name = "hie-core-test-runfiles",
|
||||
name = "ghcide-test-runfiles",
|
||||
srcs = glob(["bazel/**/*.hs"]),
|
||||
hackage_deps = [
|
||||
"base",
|
||||
@ -42,9 +42,9 @@ da_haskell_library(
|
||||
)
|
||||
|
||||
da_haskell_test(
|
||||
name = "hie-core-tests",
|
||||
name = "ghcide-tests",
|
||||
srcs = glob(["exe/**/*.hs"]),
|
||||
data = ["//compiler/hie-core:hie-core-exe"],
|
||||
data = ["//compiler/ghcide:ghcide-exe"],
|
||||
hackage_deps = [
|
||||
"base",
|
||||
"extra",
|
||||
@ -57,8 +57,8 @@ da_haskell_test(
|
||||
],
|
||||
src_strip_prefix = "exe",
|
||||
deps = [
|
||||
":hie-core-test-runfiles",
|
||||
":hie-core-testing",
|
||||
"//compiler/hie-core",
|
||||
":ghcide-test-runfiles",
|
||||
":ghcide-testing",
|
||||
"//compiler/ghcide",
|
||||
],
|
||||
)
|
||||
|
@ -2,7 +2,7 @@
|
||||
-- SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
module Development.IDE.Test.Runfiles
|
||||
( locateHieCoreExecutable
|
||||
( locateGhcideExecutable
|
||||
) where
|
||||
|
||||
import System.FilePath ((</>), FilePath)
|
||||
@ -10,7 +10,7 @@ import System.FilePath ((</>), FilePath)
|
||||
import DA.Bazel.Runfiles
|
||||
|
||||
|
||||
locateHieCoreExecutable :: IO FilePath
|
||||
locateHieCoreExecutable = locateRunfiles hieCoreExePath
|
||||
locateGhcideExecutable :: IO FilePath
|
||||
locateGhcideExecutable = locateRunfiles ghcideExePath
|
||||
where
|
||||
hieCoreExePath = mainWorkspace </> exe "compiler/hie-core/hie-core-exe"
|
||||
ghcideExePath = mainWorkspace </> exe "compiler/ghcide/ghcide-exe"
|
||||
|
@ -2,11 +2,11 @@
|
||||
-- SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
module Development.IDE.Test.Runfiles
|
||||
( locateHieCoreExecutable
|
||||
( locateGhcideExecutable
|
||||
) where
|
||||
|
||||
import System.FilePath (FilePath)
|
||||
|
||||
|
||||
locateHieCoreExecutable :: IO FilePath
|
||||
locateHieCoreExecutable = pure "hie-core"
|
||||
locateGhcideExecutable :: IO FilePath
|
||||
locateGhcideExecutable = pure "ghcide"
|
||||
|
@ -152,8 +152,8 @@ testSession name = testCase name . run
|
||||
|
||||
run :: Session a -> IO a
|
||||
run s = withTempDir $ \dir -> do
|
||||
hieCoreExe <- locateHieCoreExecutable
|
||||
let cmd = unwords [hieCoreExe, "--lsp", "--cwd", dir]
|
||||
ghcideExe <- locateGhcideExecutable
|
||||
let cmd = unwords [ghcideExe, "--lsp", "--cwd", dir]
|
||||
-- HIE calls getXgdDirectory which assumes that HOME is set.
|
||||
-- Only sets HOME if it wasn't already set.
|
||||
setEnv "HOME" "/homeless-shelter" False
|
||||
|
Loading…
Reference in New Issue
Block a user