Skip to content

Add more features and demos in docs #2257

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 7, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 49 additions & 21 deletions docs/features.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,64 @@
# Features

- Code evaluation codelens ([Tutorial](https://github.com/haskell/haskell-language-server/tree/master/plugins/hls-eval-plugin/README.md)):
- Warning and error diagnostics from GHC
- Type information and documentation on hover, [including your own comments](#how-to-show-local-documentation-on-hover).
- Jump to definition: [for now only for local code definitions](https://github.com/haskell/haskell-language-server/issues/708)
- Document symbols
- Highlight references in document
- Code completion
- Formatting via Brittany, Floskell, Fourmolu, Ormolu or Stylish Haskell
- Code evaluation (Haskell Language Server), see ([Tutorial](https://github.com/haskell/haskell-language-server/blob/master/plugins/hls-eval-plugin/README.md))

![Eval Demo](https://github.com/haskell/haskell-language-server/tree/master/plugins/hls-eval-plugin/demo.gif)
![Eval Demo](https://raw.githubusercontent.com/haskell/haskell-language-server/master/plugins/hls-eval-plugin/demo.gif)

- Type information and documentation on hover. Note that currently, in order for docs to be displayed for dependencies, they must have been built with GHC's `-haddock` flag:
- Integration with [retrie](https://hackage.haskell.org/package/retrie)

- For cabal:
- Add to your global config file (e.g. `~/.cabal/config`):
![Retrie Demo](https://i.imgur.com/Ev7B87k.gif)

```
program-default-options
ghc-options: -haddock
```
- Code lenses for explicit import lists

- Or, for a single project, run `cabal configure --ghc-options=-haddock`
![Imports code lens Demo](https://imgur.com/pX9kvY4.gif)

- For stack, add to global `$STACK_ROOT\config.yaml`, or project's `stack.yaml`:
- Generate functions from type signatures, and intelligently complete holes using [Wingman (tactics)](https://github.com/haskell/haskell-language-server/tree/master/plugins/hls-tactics-plugin)

```
ghc-options:
"$everything": -haddock
```
![Wingman Demo](https://user-images.githubusercontent.com/307223/92657198-3d4be400-f2a9-11ea-8ad3-f541c8eea891.gif)

- Integration with [hlint](https://github.com/ndmitchell/hlint) to show diagnostics and apply hints via [apply-refact](https://github.com/mpickering/apply-refact)

![Hlint Demo](https://user-images.githubusercontent.com/54035/110860028-8f9fa900-82bc-11eb-9fe5-6483d8bb95e6.gif)

- Module name suggestions for insertion or correction

![Module Name Demo](https://user-images.githubusercontent.com/54035/110860755-78ad8680-82bd-11eb-9845-9ea4b1cc1f76.gif)

This will cause compilation errors if a dependency contains invalid Haddock markup, though from GHC version 9.0, [these will be demoted to warnings](https://gitlab.haskell.org/ghc/ghc/-/merge_requests/2377).
- Call hierarchy support

- Integration with [retrie](https://hackage.haskell.org/package/retrie)
![Call Hierarchy in VSCode](https://github.com/haskell/haskell-language-server/raw/2857eeece0398e1cd4b2ffb6069b05c4d2308b39/plugins/hls-call-hierarchy-plugin/call-hierarchy-in-vscode.gif)


## How to show local documentation on hover
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem like it belongs in a "features" list per se? It's more like "setup instructions to get this feature to work". I'm not sure where that belongs, perhaps in Configuration?

Copy link
Member Author

@jneira jneira Oct 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm yeah you are right, thanks for the suggestion

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!


Haskell Language Server can display Haddock documentation on hover and completions if the project and
its dependencies have been built with the `-haddock` GHC flag.

- For cabal:

- Add to your global config file (e.g. `~/.cabal/config`):

```yaml
program-default-options
ghc-options: -haddock
```

![Retrie](https://i.imgur.com/Ev7B87k.gif)
- Or, for a single project, run `cabal configure --ghc-options=-haddock`

- Code lenses for explicit import lists
- For stack, add to global `$STACK_ROOT\config.yaml`, or project's `stack.yaml`:

![Imports code lens](https://imgur.com/pX9kvY4.gif)
```yaml
ghc-options:
'$everything': -haddock
```

- Many more (TBD)
Note that this flag will cause compilation errors if a dependency contains invalid Haddock markup,
until GHC 9.0 which [will report warnings](https://gitlab.haskell.org/ghc/ghc/-/merge_requests/2377)
instead.