GithubHelp home page GithubHelp logo

mpickering / ghcide Goto Github PK

View Code? Open in Web Editor NEW

This project forked from haskell/ghcide

4.0 8.0 2.0 2.9 MB

A library for building Haskell IDE tooling

License: Apache License 2.0

C 0.09% Haskell 99.65% TypeScript 0.16% Shell 0.02% Batchfile 0.08%

ghcide's Introduction

ghcide - A library for building Haskell IDE tooling

Note: ghcide was previously called hie-core.

Our vision is that you should build an IDE by combining:

vscode

  • hie-bios for determining where your files are, what are their dependencies, what extensions are enabled and so on;
  • 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 and hie-ormolu, to choose which features you want;
  • haskell-lsp for sending those messages to a Language Server Protocol (LSP) server;
  • An extension for your editor. We provide a VS Code extension as extension in this directory, although the components work in other LSP editors too (see below for instructions using Emacs).

There are more details about our approach in this blog post.

Features

ghcide already exports the following features via the lsp protocol:

Feature LSP name
Display error messages (parse errors, typecheck errors, etc.) and enabled warnings. diagnostics
Go to definition in local package definition
Display type and source module of values hover
Remove redundant imports, replace suggested typos for values and module imports, fill type holes, insert missing type signatures, add suggested ghc extensions codeAction (quickfix)

Using it

Install ghcide

With Nix

See ghcide-nix repository

With Cabal or Stack

First install the ghcide binary using stack or cabal, e.g.

  1. git clone https://github.com/digital-asset/ghcide.git
  2. cd ghcide
  3. cabal install or stack install (and make sure ~/.local/bin is on your $PATH)

It's important that ghcide is compiled with the same compiler you use to build your projects.

Test ghcide

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, running ghcide gives some error messages and warnings before reporting at the end:

Files that failed:
 * .\model\Main.hs
 * .\model\Model.hs
 * .\model\Test.hs
 * .\model\Util.hs
 * .\output\docs\Main.hs
 * .\output\docs\Part_Architecture_md.hs
Completed (152 worked, 6 failed)

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 ghcide executable mostly relies on hie-bios to do the difficult work of setting up your GHC environment. If it doesn't work, see the hie-bios manual to get it working. My default fallback is to figure it out by hand and create a direct style hie.yaml listing the command line arguments to load the project.

If you can't get ghcide working outside the editor, see this setup troubleshooting guide. Once you have got ghcide working outside the editor, the next step is to pick which editor to integrate with.

Optimal project setup

ghcide has been designed to handle projects with hundreds or thousands of modules. If ghci can handle it, then ghcide should be able to handle it. The only caveat is that this currently requires GHC >= 8.6, and that the first time a module is loaded in the editor will trigger generation of support files in the background if those do not already exist.

Using with VS Code

You can install the VSCode extension from the VSCode marketplace.

Using with Atom

You can follow the instructions to install with apm.

Using with Sublime Text

  • Install LSP
  • Press Ctrl+Shift+P or Cmd+Shift+P in Sublime Text and search for Preferences: LSP Settings, then paste these settings
{
  "clients":
  {
    "ghcide":
    {
      "enabled"   : true,
      "languageId": "haskell",
      "command"   : ["ghcide", "--lsp"],
      "scopes"    : ["source.haskell"],
      "syntaxes"  : ["Packages/Haskell/Haskell.sublime-syntax"]
    }
  }
}

Using with Emacs

If you don't already have MELPA package installation configured, visit MELPA getting started page to get set up. Then, install use-package.

Now you have a choice of two different Emacs packages which can be used to communicate with the ghcide LSP server:

  • lsp-ui
  • eglot (requires Emacs 26.1+)

In each case, you can enable support by adding the shown lines to your .emacs:

lsp-ui

;; LSP
(use-package flycheck
  :ensure t
  :init
  (global-flycheck-mode t))
(use-package yasnippet
  :ensure t)
(use-package lsp-mode
  :ensure t
  :hook (haskell-mode . lsp)
  :commands lsp)
(use-package lsp-ui
  :ensure t
  :commands lsp-ui-mode)
(use-package lsp-haskell
 :ensure t
 :config
 (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)
)

eglot

(use-package eglot
  :ensure t
  :config
  (add-to-list 'eglot-server-programs '(haskell-mode . ("ghcide" "--lsp"))))

Using with Vim/Neovim

LanguageClient-neovim

Install LanguageClient-neovim

Add this to your vim config:

let g:LanguageClient_rootMarkers = ['*.cabal', 'stack.yaml']
let g:LanguageClient_serverCommands = {
    \ 'rust': ['rls'],
    \ 'haskell': ['ghcide', '--lsp'],
    \ }

Refer to :he LanguageClient for more details on usage and configuration.

vim-lsp

Install vim-lsp.

Add this to your vim config:

au User lsp_setup call lsp#register_server({
    \ 'name': 'ghcide',
    \ 'cmd': {server_info->['/your/path/to/ghcide', '--lsp']},
    \ 'whitelist': ['haskell'],
    \ })

To verify it works move your cursor over a symbol and run :LspHover.

coc.nvim

Install coc.nvim

Add this to your coc-settings.json (which you can edit with :CocConfig):

{
  "languageserver": {
    "haskell": {
      "command": "ghcide",
      "args": [
        "--lsp"
      ],
      "rootPatterns": [
        ".stack.yaml",
        ".hie-bios",
        "BUILD.bazel",
        "cabal.config",
        "package.yaml"
      ],
      "filetypes": [
        "hs",
        "lhs",
        "haskell"
      ]
    }
  }
}

Here's a nice article on setting up neovim and coc: Vim and Haskell in 2019 (this is actually for haskell-ide, not ghcide)

Here is a Docker container that pins down the build and configuration for Neovim and ghcide on a minimal Debian 10 base system: docker-ghcide-neovim.

SpaceVim

In the autocomplete layer, add the autocomplete_method option to force the use of coc:

[[layers]]
  name = 'autocomplete'
  auto-completion-return-key-behavior = "complete"
  auto-completion-tab-key-behavior = "smart"
  [options]
    autocomplete_method = "coc"

Add this to your coc-settings.json (which you can edit with :CocConfig):

{
  "languageserver": {
    "haskell": {
      "command": "ghcide",
      "args": [
        "--lsp"
      ],
      "rootPatterns": [
        ".stack.yaml",
        ".hie-bios",
        "BUILD.bazel",
        "cabal.config",
        "package.yaml"
      ],
      "filetypes": [
        "hs",
        "lhs",
        "haskell"
      ]
    }
  }
}

This example above describes a setup in which ghcide is installed using stack install ghcide within a project.

Hacking on ghcide

To build and work on ghcide itself, you can use Stack or cabal, e.g., running stack test will execute the test suite. If you are using Windows, you should disable the auto.crlf setting and configure your editor to use LF line endings, directly or making it use the existing .editor-config.

If you are chasing down test failures, you can use the tasty-rerun feature by running tests as

stack --stack-yaml=stack84.yaml test --test-arguments "--rerun"

This writes a log file called .tasty-rerun-log of the failures, and only runs those. See the tasty-rerun documentation for other options.

Building the extension

For development, you can also the VSCode extension from this repository (see https://code.visualstudio.com/docs/setup/mac for details on adding code to your $PATH):

  1. cd extension/
  2. npm ci
  3. npm run vscepackage
  4. code --install-extension ghcide-0.0.1.vsix

Now opening a .hs file should work with ghcide.

History and relationship to other Haskell IDE's

The teams behind this project and the haskell-ide-engine have agreed to join forces under the haskell-language-server project, see the original announcement. The technical work is ongoing, with the likely model being that this project serves as the core, while plugins and integrations are kept in the haskell-language-server project.

The code behind ghcide was originally developed by Digital Asset as part of the DAML programming language. DAML is a smart contract language targeting distributed-ledger runtimes, based on GHC with custom language extensions. The DAML programming language has an IDE, and work was done to separate off a reusable Haskell-only IDE (what is now ghcide) which the DAML IDE then builds upon. Since that time, there have been various non-Digital Asset contributors, in addition to continued investment by Digital Asset. All contributions require a Contributor License Agreement that states you license the code under the Apache License.

The Haskell community has various IDE choices, but the one that had been gathering momentum is haskell-ide-engine. Our project owes a debt of gratitude to the haskell-ide-engine. We reuse libraries from their ecosystem, including hie-bios (a likely future environment setup layer in haskell-ide-engine), haskell-lsp and lsp-test (the haskell-ide-engine LSP protocol pieces). We make heavy use of their contributions to GHC itself, in particular the work to make GHC take string buffers rather than files.

The best summary of the architecture of ghcide is available this talk (slides), given at MuniHac 2019. However, since that talk the project has renamed from hie-core to ghcide, and the repo has moved to this location.

ghcide's People

Contributors

cocreature avatar ndmitchell avatar neil-da avatar mpickering avatar pepeiborra avatar jacg avatar serras avatar wz1000 avatar alanz avatar aherrmann-da avatar maralorn avatar davidm-d avatar hurryabit avatar hsenag avatar ethercrow avatar jinwoo avatar ollef avatar fendor avatar garyverhaegen-da avatar sheaf avatar jneira avatar domenkozar avatar moodmosaic avatar martin-drhu-da avatar lukel97 avatar carlohamalainen avatar codiepp avatar mpardalos avatar nc6 avatar ocharles avatar

Stargazers

 avatar  avatar Wayne Kearns avatar John avatar

Watchers

 avatar James Cloos avatar  avatar  avatar  avatar  avatar Avi Dessauer avatar  avatar

ghcide's Issues

Error using stack explicit cradle: No prefixes matched for Paths_haskell_language_server.hs

  • Opening hls (./exe/Main.hs) with a corrected stack based hie.yaml
  • With the cabal based hie.yaml, it works
  • Message
Multi Cradle: No prefixes matched
pwd: D:\dev\ws\haskell\hls
filepath: D:\dev\ws\haskell\hls\.stack-work\dist\e626a42b\build\haskell-language-server\autogen\Paths_haskell_language_server.hs
prefixes:
("./test/functional/",Stack {component = Just "haskell-language-server:func-test"})
("./exe/Main.hs",Stack {component = Just "haskell-language-server:exe:haskell-language-server"})
("./exe/Wrapper.hs",Stack {component = Just "haskell-language-server:exe:haskell-language-server-wrapper"})
("./src",Stack {component = Just "haskell-language-server:lib"})
("./ghcide/src",Stack {component = Just "ghcide:lib:ghcide"})
("./ghcide/exe",Stack {component = Just "ghcide:exe:ghcide"})
Log
[client] run command = "ghcide --lsp"
[client] debug command = "ghcide --lsp"
ghcide version: 0.1.0 (GHC: 8.8.3) (PATH: D:\bin\ghcide.exe) (GIT hash: )
Starting LSP server...
If you are seeing this in a terminal, you probably should have run ghcide WITHOUT the --lsp option!
 Started LSP server in 0.01s
[INFO] Opened text document: file:///d%3A/dev/ws/haskell/hls/exe/Main.hs
Consulting the cradle for "D:\\dev\\ws\\haskell\\hls\\exe\\Main.hs"
> �[0mUsing main module: 1. Package `haskell-language-server' component haskell-language-server:exe:haskell-language-server with main-is file: D:\dev\ws\haskell\hls\exe\Main.hs�[0m
> �[0mghcide-0.1.0: unregistering (local file changes: ghcide.cabal src\Development\IDE\Core\FileStore.hs src\Development\IDE\Core\Rules.hs src\Developm...)�[0m
> �[0mghcide                 > configure (lib + exe)�[0m
> �[0mghcide                 > Configuring ghcide-0.1.0...�[0m
> �[0mghcide                 > build (lib + exe)�[0m
> �[0mghcide                 > Preprocessing executable 'ghcide-test-preprocessor' for ghcide-0.1.0..�[0m
> �[0mghcide                 > Building executable 'ghcide-test-preprocessor' for ghcide-0.1.0..�[0m
> �[0mghcide                 > Preprocessing library for ghcide-0.1.0..�[0m
> �[0mghcide                 > Building library for ghcide-0.1.0..�[0m
> �[0mghcide                 > [27 of 48] Compiling Development.IDE.Import.FindImports�[0m
> �[0mghcide                 > [28 of 48] Compiling Development.IDE.Import.DependencyInformation [Development.IDE.Import.FindImports changed]�[0m
> �[0mghcide                 > [29 of 48] Compiling Development.IDE.Core.RuleTypes [Development.IDE.Import.DependencyInformation changed]�[0m
> �[0mghcide                 > [30 of 48] Compiling Development.IDE.Core.Shake�[0m
> �[0mghcide                 > [31 of 48] Compiling Development.IDE.Core.OfInterest [Development.IDE.Core.Shake changed]�[0m
> �[0mghcide                 > [32 of 48] Compiling Development.IDE.Core.IdeConfiguration [Development.IDE.Core.Shake changed]�[0m
> �[0mghcide                 > [33 of 48] Compiling Development.IDE.Core.FileStore�[0m
> �[0mghcide                 > [34 of 48] Compiling Development.IDE.Core.FileExists [Development.IDE.Core.Shake changed]�[0m
> �[0mghcide                 > [35 of 48] Compiling Development.IDE.Core.Service [Development.IDE.Core.Shake changed]�[0m
> �[0mghcide                 > [37 of 48] Compiling Development.IDE.LSP.Notifications�[0m
> �[0mghcide                 > [38 of 48] Compiling Development.IDE.Core.Compile [Development.IDE.Core.Shake changed]�[0m
> �[0mghcide                 > �[0m
> �[0mghcide                 > �[;1msrc\Development\IDE\Core\Compile.hs:64:1: �[;1m�[35mwarning:�[0m�[0m�[;1m [�[;1m�[35m-Wunused-imports�[0m�[0m�[;1m]�[0m�[0m�[;1m�[0m
> �[0mghcide                 >     The import of `NameCache' is redundant�[0m
> �[0mghcide                 >       except perhaps to import instances from `NameCache'�[0m
> �[0mghcide                 >     To import instances alone, use: import NameCache()�[0m�[0m�[0m
> �[0mghcide                 > �[;1m�[34m   |�[0m�[0m�[0m
> �[0mghcide                 > �[;1m�[34m64 |�[0m�[0m �[;1m�[35mimport           NameCache�[0m�[0m�[0m
> �[0mghcide                 > �[;1m�[34m   |�[0m�[0m�[;1m�[35m ^^^^^^^^^^^^^^^^^^^^^^^^^^�[0m�[0m�[0m
> �[0mghcide                 > [41 of 48] Compiling Development.IDE.Core.Rules�[0m
> �[0mghcide                 > �[0m�[0m�[0m�[0m
> �[0mghcide                 > �[;1msrc\Development\IDE\Core\Rules.hs:35:1: �[;1m�[35mwarning:�[0m�[0m�[;1m [�[;1m�[35m-Wunused-imports�[0m�[0m�[;1m]�[0m�[0m�[;1m�[0m
> �[0mghcide                 >     The import of `Data.Bifunctor' is redundant�[0m
> �[0mghcide                 >       except perhaps to import instances from `Data.Bifunctor'�[0m
> �[0mghcide                 >     To import instances alone, use: import Data.Bifunctor()�[0m�[0m�[0m
> �[0mghcide                 > �[;1m�[34m   |�[0m�[0m�[0m
> �[0mghcide                 > �[;1m�[34m35 |�[0m�[0m �[;1m�[35mimport Data.Bifunctor (second)�[0m�[0m�[0m
> �[0mghcide                 > �[;1m�[34m   |�[0m�[0m�[;1m�[35m ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^�[0m�[0m�[0m
> �[0mghcide                 > �[0m�[0m�[0m�[0m
> �[0mghcide                 > �[;1msrc\Development\IDE\Core\Rules.hs:37:1: �[;1m�[35mwarning:�[0m�[0m�[;1m [�[;1m�[35m-Wunused-imports�[0m�[0m�[;1m]�[0m�[0m�[;1m�[0m
> �[0mghcide                 >     The import of `Control.Applicative' is redundant�[0m
> �[0mghcide                 >       except perhaps to import instances from `Control.Applicative'�[0m
> �[0mghcide                 >     To import instances alone, use: import Control.Applicative()�[0m�[0m�[0m
> �[0mghcide                 > �[;1m�[34m   |�[0m�[0m�[0m
> �[0mghcide                 > �[;1m�[34m37 |�[0m�[0m �[;1m�[35mimport Control.Applicative�[0m�[0m�[0m
> �[0mghcide                 > �[;1m�[34m   |�[0m�[0m�[;1m�[35m ^^^^^^^^^^^^^^^^^^^^^^^^^^�[0m�[0m�[0m
> �[0mghcide                 > �[0m�[0m�[0m�[0m
> �[0mghcide                 > �[;1msrc\Development\IDE\Core\Rules.hs:54:1: �[;1m�[35mwarning:�[0m�[0m�[;1m [�[;1m�[35m-Wunused-imports�[0m�[0m�[;1m]�[0m�[0m�[;1m�[0m
> �[0mghcide                 >     The qualified import of `Development.IDE.Types.Logger' is redundant�[0m
> �[0mghcide                 >       except perhaps to import instances from `Development.IDE.Types.Logger'�[0m
> �[0mghcide                 >     To import instances alone, use: import Development.IDE.Types.Logger()�[0m�[0m�[0m
> �[0mghcide                 > �[;1m�[34m   |�[0m�[0m�[0m
> �[0mghcide                 > �[;1m�[34m54 |�[0m�[0m �[;1m�[35mimport qualified Development.IDE.Types.Logger as L�[0m�[0m�[0m
> �[0mghcide                 > �[;1m�[34m   |�[0m�[0m�[;1m�[35m ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^�[0m�[0m�[0m
> �[0mghcide                 > [42 of 48] Compiling Development.IDE.Plugin.CodeAction.Rules [Development.IDE.Core.Rules changed]�[0m
> �[0mghcide                 > [43 of 48] Compiling Development.IDE.Plugin [Development.IDE.Core.Rules changed]�[0m
> �[0mghcide                 > [44 of 48] Compiling Development.IDE.Plugin.Completions [Development.IDE.Core.Shake changed]�[0m
> �[0mghcide                 > [45 of 48] Compiling Development.IDE.Plugin.CodeAction [Development.IDE.Core.Rules changed]�[0m
> �[0mghcide                 > [46 of 48] Compiling Development.IDE.LSP.Outline [Development.IDE.Core.Rules changed]�[0m
> �[0mghcide                 > [47 of 48] Compiling Development.IDE.LSP.HoverDefinition [Development.IDE.Core.Rules changed]�[0m
> �[0mghcide                 > [48 of 48] Compiling Development.IDE.LSP.LanguageServer [Development.IDE.Core.Shake changed]�[0m
> �[0mghcide                 > Preprocessing executable 'ghcide' for ghcide-0.1.0..�[0m
> �[0mghcide                 > Building executable 'ghcide' for ghcide-0.1.0..�[0m
> �[0mghcide                 > [4 of 4] Compiling Main [Development.IDE.Core.FileStore changed]�[0m
> �[0mghcide                 > �[0m�[0m�[0m�[0m
> �[0mghcide                 > �[;1mexe\Main.hs:56:1: �[;1m�[35mwarning:�[0m�[0m�[;1m [�[;1m�[35m-Wunused-imports�[0m�[0m�[;1m]�[0m�[0m�[;1m�[0m
> �[0mghcide                 >     The import of `Development.GitRev' is redundant�[0m
> �[0mghcide                 >       except perhaps to import instances from `Development.GitRev'�[0m
> �[0mghcide                 >     To import instances alone, use: import Development.GitRev()�[0m�[0m�[0m
> �[0mghcide                 > �[;1m�[34m   |�[0m�[0m�[0m
> �[0mghcide                 > �[;1m�[34m56 |�[0m�[0m �[;1m�[35mimport Development.GitRev�[0m�[0m�[0m
> �[0mghcide                 > �[;1m�[34m   |�[0m�[0m�[;1m�[35m ^^^^^^^^^^^^^^^^^^^^^^^^^�[0m�[0m�[0m
> �[0mghcide                 > �[0m�[0m�[0m�[0m
> �[0mghcide                 > �[;1mexe\Main.hs:57:1: �[;1m�[35mwarning:�[0m�[0m�[;1m [�[;1m�[35m-Wunused-imports�[0m�[0m�[;1m]�[0m�[0m�[;1m�[0m
> �[0mghcide                 >     The import of `action' from module `Development.Shake' is redundant�[0m�[0m�[0m
> �[0mghcide                 > �[;1m�[34m   |�[0m�[0m�[0m
> �[0mghcide                 > �[;1m�[34m57 |�[0m�[0m �[;1m�[35mimport Development.Shake (Action,  action)�[0m�[0m�[0m
> �[0mghcide                 > �[;1m�[34m   |�[0m�[0m�[;1m�[35m ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^�[0m�[0m�[0m
> �[0mghcide                 > �[0m�[0m�[0m�[0m
> �[0mghcide                 > �[;1mexe\Main.hs:83:1: �[;1m�[35mwarning:�[0m�[0m�[;1m [�[;1m�[35m-Wunused-imports�[0m�[0m�[;1m]�[0m�[0m�[;1m�[0m
> �[0mghcide                 >     The import of `Debug.Trace' is redundant�[0m
> �[0mghcide                 >       except perhaps to import instances from `Debug.Trace'�[0m
> �[0mghcide                 >     To import instances alone, use: import Debug.Trace()�[0m�[0m�[0m
> �[0mghcide                 > �[;1m�[34m   |�[0m�[0m�[0m
> �[0mghcide                 > �[;1m�[34m83 |�[0m�[0m �[;1m�[35mimport Debug.Trace�[0m�[0m�[0m
> �[0mghcide                 > �[;1m�[34m   |�[0m�[0m�[;1m�[35m ^^^^^^^^^^^^^^^^^^�[0m�[0m�[0m
> �[0mghcide                 > Linking .stack-work\dist\e626a42b\build\ghcide\ghcide.exe ...�[0m
> �[0mghcide                 > �[0m�[0m�[0m�[0m
> �[0mghcide                 > copy/register�[0m
> �[0mghcide                 > Installing executable ghcide-test-preprocessor in D:\dev\ws\haskell\hls\.stack-work\install\15d153f3\bin�[0m
> �[0mghcide                 > Installing library in D:\dev\ws\haskell\hls\.stack-work\install\15d153f3\lib\x86_64-windows-ghc-8.6.5\ghcide-0.1.0-KhREzo7jDNU4tRViaOnMFo�[0m
> �[0mghcide                 > Installing executable ghcide in D:\dev\ws\haskell\hls\.stack-work\install\15d153f3\bin�[0m
> �[0mghcide                 > Registering library for ghcide-0.1.0..�[0m
> �[0mhaskell-language-server> configure (lib + internal-lib + exe)�[0m
> �[0mConfiguring haskell-language-server-0.1.0.0...�[0m
> �[0mhaskell-language-server> initial-build-steps (lib + internal-lib + exe)�[0m
> �[0mCompleted 2 action(s).�[0m
> �[0mThe following GHC options are incompatible with GHCi and have not been passed to it: -threaded�[0m
> �[0mConfiguring GHCi with the following packages: haskell-language-server�[0m
> D:\dev\ws\haskell\hls\.stack-work\install\15d153f3\pkgdb;C:\sr\snapshots\5abeca39\pkgdb;D:\bin\stack\x86_64-windows\ghc-8.6.5\lib\package.conf.d
Right (ComponentOptions {componentOptions = ["-i","-odir=D:\\dev\\ws\\haskell\\hls\\.stack-work\\odir","-hidir=D:\\dev\\ws\\haskell\\hls\\.stack-work\\odir","-hide-all-packages","-iD:\\dev\\ws\\haskell\\hls\\.stack-work\\dist\\e626a42b\\build\\haskell-language-server","-iD:\\dev\\ws\\haskell\\hls\\exe","-iD:\\dev\\ws\\haskell\\hls\\.stack-work\\dist\\e626a42b\\build\\haskell-language-server\\autogen","-iD:\\dev\\ws\\haskell\\hls\\.stack-work\\dist\\e626a42b\\build\\global-autogen","-iD:\\dev\\ws\\haskell\\hls\\.stack-work\\dist\\e626a42b\\build\\haskell-language-server\\haskell-language-server-tmp","-stubdir=D:\\dev\\ws\\haskell\\hls\\.stack-work\\dist\\e626a42b\\build","-ID:\\bin\\stack\\x86_64-windows\\msys2-20180531\\mingw64\\include","-LD:\\bin\\stack\\x86_64-windows\\msys2-20180531\\mingw64\\lib","-LD:\\bin\\stack\\x86_64-windows\\msys2-20180531\\mingw64\\bin","-package-id=haskell-language-server-0.1.0.0-6JSj9p8L1gBAnseU8jhOh9-hls-test-utils","-package-id=base-4.12.0.0","-package-id=aeson-1.4.6.0-DsrnuPFXLAlILCFBQ2AzgE","-package-id=async-2.2.2-EbxQ7tk0OFk9dJNMtaidSf","-package-id=base16-bytestring-0.1.1.6-17atVnUhDnM13pAkKbwL6I","-package-id=binary-0.8.6.0","-package-id=bytestring-0.10.8.2","-package-id=cryptohash-sha1-0.11.100.1-FedZHhK3zTs7eOQXIrPeso","-package-id=containers-0.6.0.1","-package-id=data-default-0.7.1.1-COovZVyOTYqEavTGLlfqy8","-package-id=deepseq-1.4.4.0","-package-id=directory-1.3.3.0","-package-id=extra-1.7.1-PSuBSigoW23dwesYtnXfZ","-package-id=filepath-1.4.2.1","-package-id=ghc-8.6.5","-package-id=ghc-check-0.3.0.1-4A801B9g1biEE5sFqd62dN","-package-id=ghc-paths-0.1.0.12-8MhNqRZlSJXAzmVO0F6ybT","-package-id=ghcide-0.1.0-KhREzo7jDNU4tRViaOnMFo","-package-id=gitrev-1.3.1-7TThbNd1bbyEHouSCbophD","-package-id=hashable-1.2.7.0-2SI038axTEd7AEZJ275kpi","-package-id=haskell-lsp-0.22.0.0-3piifcNOUrW3byFYhRQLQo","-package-id=hie-bios-0.5.0-5VZcc8LU1z2GHE3wORzrDN","-package-id=haskell-language-server-0.1.0.0-ICCqwzjKs3aCsXolUe8wdE","-package-id=hslogger-1.2.12-IV3VyzKmB3vIKqKHt4daAX","-package-id=optparse-applicative-0.15.1.0-FihWsyor2QQHorNvaQqP8c","-package-id=shake-0.19-F4KIhMxli1gEdS9eVwdqx3","-package-id=text-1.2.3.1","-package-id=time-1.8.0.2","-package-id=unordered-containers-0.2.10.0-LgoTL3wbBEY5bZIDJiyxW4","-Wall","-Wno-name-shadowing","-Wredundant-constraints","-rtsopts","-with-rtsopts=-I0 -qg -A128M","-DAGPL","-optP-include","-optPD:\\dev\\ws\\haskell\\hls\\.stack-work\\ghci\\3c86ed7a\\cabal_macros.h","-ghci-script=C:\\TEMP\\haskell-stack-ghci\\556c9616\\ghci-script","-package-db","D:\\dev\\ws\\haskell\\hls\\.stack-work\\install\\15d153f3\\pkgdb","-package-db","C:\\sr\\snapshots\\5abeca39\\pkgdb","-package-db","D:\\bin\\stack\\x86_64-windows\\ghc-8.6.5\\lib\\package.conf.d"], componentRoot = "D:\\dev\\ws\\haskell\\hls", componentDependencies = ["haskell-language-server.cabal","package.yaml","stack.yaml"]})
"Making new HscEnv[main]"
Error while checking GHC version: "D:\\\\bin\\\\stack\\\\x86_64-windows\\\\ghc-8.8.3\\\\lib\\bin\\ghc: readCreateProcess: does not exist (No such file or directory)"
(([],Just HscEnvEq 4),fromList [("haskell-language-server.cabal",Just 2020-05-25 05:45:02.6526252 UTC),("package.yaml",Nothing),("stack.yaml",Just 2020-05-25 05:45:03.0206265 UTC)])
Consulting the cradle for "D:\\dev\\ws\\haskell\\hls\\.stack-work\\dist\\e626a42b\\build\\haskell-language-server\\autogen\\Paths_haskell_language_server.hs"
Left [CradleError ExitSuccess ["Multi Cradle: No prefixes matched","pwd: D:\\dev\\ws\\haskell\\hls","filepath: D:\\dev\\ws\\haskell\\hls\\.stack-work\\dist\\e626a42b\\build\\haskell-language-server\\autogen\\Paths_haskell_language_server.hs","prefixes:","(\"./test/functional/\",Stack {component = Just \"haskell-language-server:func-test\"})","(\"./exe/Main.hs\",Stack {component = Just \"haskell-language-server:exe:haskell-language-server\"})","(\"./exe/Wrapper.hs\",Stack {component = Just \"haskell-language-server:exe:haskell-language-server-wrapper\"})","(\"./src\",Stack {component = Just \"haskell-language-server:lib\"})","(\"./ghcide/src\",Stack {component = Just \"ghcide:lib:ghcide\"})","(\"./ghcide/exe\",Stack {component = Just \"ghcide:exe:ghcide\"})"]]
[INFO] finish: FileStoreTC (took 4m08s)
[INFO] finish: CodeAction (took 0.01s)
[INFO] finish: InitialLoad (took 0.01s)
[INFO] finish: InitialLoad (took 0.31s)
[INFO] finish: CodeAction:PackageExports (took 1.30s)
[INFO] Hover request at position 472:8 in file: d:\dev\ws\haskell\hls\exe\Main.hs

Goto definition blocks

I have no idea why sometimes goto definition is blocked until typechecking is finished. It should return
instantly.

ghcide analyzes the whole project on startup

Compare with digital-asset/ghcide which only analyzes the files of interest.

I think this explains the issues that I shared on Friday by email while testing on a codebase with ~5000 modules which takes quite a while to load in this branch

Multi component: PackageImports do not work

The module finding code is hard-wired to look in only external packages if you use package imports.

It looks like it might be possible to trick GHC by injecting some entries into the ModuleToPkgConfAll map.

This is something @fendor will need to fix upstream this summer.

Test case: generic-lens.

Cannot find PackageName for installed unit-id.

Reproduce:

git clone https://github.com/kcsongor/generic-lens
cd generic-lens
echo "cradle: { cabal: {}}" > hie.yaml

Opening any file using PackageImports, the following error is shown:

very bad
CallStack (from HasCallStack):
  error, called at src\\Development\\IDE\\Import\\FindImports.hs:87:23 in ghcide-0.1.0-10c2bb614e6777502ff4a3c9565e86a7c68c2766:Development.IDE.Import.FindImports

Which comes from this line: https://github.com/mpickering/ghcide/blob/hls/src/Development/IDE/Import/FindImports.hs#L87

Rebase onto da/master

There are quite a few changes in master we should rebase onto.

My preference is to rebase the whole branch onto da/master and force push to hls. I will do the rebase if we agree this is the correct way to proceed.

New feature: call hierarchy support

  • It is a feature common in other ides like eclipse or intellij
  • It shows the graph of all transitive calls of a function, in a tree:
    • The nodes are selectable (shows info in the right pane) and navigable with ctrl+click
    • In the right pane other info like the possible multiple calls in the same funcion, with the line number (also navigables to the concrete line)

imagen

imagen

Usability tweaks

  • Need to cancel duplicated events in the priority queue, typing can lead to a lot of propagate events queuing up which can lead to some blocking.
  • Need to put each Propagate individually into the queue rather than as one action as it can cause
    the batch to take a long time
  • Only propagate when the module is saved? This could be a nice UI.

Improve CPP hygiene

All uses of CPP should be confined to specific modules. At the moment there is a bunch of CPP in core code paths to distinguish between ghc-lib and normal ghc code paths. These should all be moved into their own module like the GHC API compat CPP.

Command line: Add an option to prepopulate the caches

There are quite a few cached artifacts now. There should be a command on the command line which builds all the .hi and .hie files so that the initial load into the editor is faster.

Conceptually it is similar to uses TypeCheck but instead calls the typecheck definition directly to avoid high memory usage caused by storing all typechecked modules.

Build with ghc-lib fails

  • cabal build -w ghc-8.8.3 -fghc-libfails with:
[12 of 48] Compiling Development.IDE.GHC.HieTypes ( src-ghc86\Development\IDE\GHC\HieTypes.hs, D:\dev\ws\haskell\ghcide\dist-newstyle\build\x86_64-windows\ghc-8.8.3\ghcide-0.1.0\build\Development\IDE\GHC\HieTypes.o )

src-ghc86\Development\IDE\GHC\HieTypes.hs:34:10: error:
    Duplicate instance declarations:
      instance Binary RealSrcSpan
        -- Defined at src-ghc86\Development\IDE\GHC\HieTypes.hs:34:10
      instance Binary RealSrcSpan -- Defined in ‘Binary’
   |
34 | instance Binary RealSrcSpan where
   |          ^^^^^^^^^^^^^^^^^^

src-ghc86\Development\IDE\GHC\HieTypes.hs:51:10: error:
    Duplicate instance declarations:
      instance (A.Ix a, Binary a, Binary b) => Binary (A.Array a b)
        -- Defined at src-ghc86\Development\IDE\GHC\HieTypes.hs:51:10
      instance (A.Ix a, Binary a, Binary b) => Binary (A.Array a b)
        -- Defined in ‘Binary’
   |
51 | instance (A.Ix a, Binary a, Binary b) => Binary (A.Array a b) where
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cabal.exe: Failed to build ghcide-0.1.0.

Improve ghc session error handling

  • If cradle run is succesful but ghc session crashes the ide does not get any error and progress gets stuck
  • The workaround is extract compiler args and call ghc directly on command line to see what is going on
  • Detected when opening ghc with hls on windows but i think the behaviour is similar with other projects

Multi component: Interface files get our of sync

If you generate interface files with one component loaded and then load another component you can get confusing error messages which don't resolve until you delete ~/.cache/ghcide. For example

haskell/haskell-language-server#23 (comment)

We need to make sure that the hash for the interface files cache takes into account all the components in the current session rather than just a hash of the options for one component.

LSP Specification Tracking Issue

This is a tracking issue to verify that we support all the recent LSP features and to think about whether any of the unused features could provide a better experience. For each item in the list we should understand what it means in terms of the specification and then comment about whether we can use it or not.

3.16.0 (xx/xx/xxxx)

  • Add semantic token support
  • Add call hierarchy support (#18)
  • Add support for insert and replace ranges on CompletionItem
  • Add support for diagnsotic codes
  • Add support for tags on SymbolInformation and DocumentSymbol

3.15.0 (01/14/2020)

  • Add generic progress reporting support.
  • Add specific work done progress reporting support to requests where applicable.
  • Add specific partial result progress support to requests where applicable.
  • Add support for textDocument/selectionRange.
  • Add support for server and client information.
  • Add signature help context.
  • Add version on PublishDiagnosticsParams
  • Add CodeAction#isPreferred support.
  • Add CompletionItem#tag support.
  • Add Diagnostic#tag support.
  • Add DocumentLink#tooltip support.
  • Add trimTrailingWhitespace, insertFinalNewline and trimFinalNewlines to FormattingOptions.
  • Clarified WorkspaceSymbolParams#query parameter.

3.14.0 (12/13/2018)

  • Add support for signature label offsets.
  • Add support for location links.
  • Add support for textDocument/declaration request.

3.13.0 (9/11/2018)

  • Add support for file and folder operations (create, rename, move) to workspace edits.

3.12.0 (8/23/2018)

  • Add support for textDocument/prepareRename request.

3.11.0 (8/21/2018)

  • Add support for CodeActionOptions to allow a server to provide a list of code action it supports.

3.10.0 (7/23/2018)

  • Add support for hierarchical document symbols as a valid response to a textDocument/documentSymbol request.
  • Add support for folding ranges as a valid response to a textDocument/foldingRange request.

3.9.0 (7/10/2018)

  • Add support for preselect property in CompletionItem

3.8.0 (6/11/2018)

  • Added support for CodeAction literals to the textDocument/codeAction request.
  • ColorServerCapabilities.colorProvider can also be a boolean
  • Corrected ColorPresentationParams.colorInfo to color (as in the d.ts and in implementations)

3.7.0 (4/5/2018)

  • Added support for related information to Diagnostics.

Substantiate the value of ShakeQueue

ShakeQueue adds substantial complexity and the benefits are unclear.

  • What problem does the queue solve?
  • What are priorities used for?
  • What are retries used for?
  • How does cancellation work now?

It seems to me that the queue is designed with useWithState in mind, but it will overall make ghcide either less responsive or less accurate.

Would this be needed if the Shake database could handle multiple concurrent computations?

Key lookup failure on save

Steps to reproduce:

  1. Edit a file
  2. Save the file
DEBUG] Starting: (2,0):[DelayedAction: FileStoreTC,DelayedAction: ParentTC]
[DEBUG] finish shakeRun: batch (took 0.08s, exception: Error when running Shake build system:
  at error, called at ./Data/HashMap/Base.hs:631:16 in unordered-containers-0.2.10.0-dc6e10219c0a2baf381b92e75f02b1280582860e9675d123989f5554e67cf4d1:Data.HashMap.Base
* Raised the exception:
Data.HashMap.Base.(!): key not found

Seems to be mostly harmless, but concerning.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.