Skip to content

Commit a55e371

Browse files
authored
Merge pull request #132 from jneira/readme-eds
Complete editor integrations
2 parents 0d2b83a + e59b4bd commit a55e371

File tree

1 file changed

+156
-9
lines changed

1 file changed

+156
-9
lines changed

README.md

Lines changed: 156 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,18 @@ This is *very* early stage software.
2626
- [Install specific GHC Version](#install-specific-ghc-version)
2727
- [Project Configuration](#project-configuration)
2828
- [Editor Integration](#editor-integration)
29-
- [With emacs](#using-haskell-language-server-with-emacs)
30-
- [With doom emacs](#using-haskell-language-server-with-doom-emacs)
31-
- [With Kakoune](#using-haskell-language-server-with-kakoune)
29+
- [VS Code](#using-haskell-language-server-with-vs-code)
30+
- [Sublime Text](#using-haskell-language-server-with-sublime-text)
31+
- [Vim or Neovim](#using-haskell-language-server-with-vim-or-neovim)
32+
- [Coc](#coc)
33+
- [LanguageClient-neovim](#languageclient-neovim)
34+
- [vim-plug](#vim-plug)
35+
- [Clone the LanguageClient-neovim repo](#clone-the-languageclient-neovim-repo)
36+
- [Sample `~/.vimrc`](#sample-vimrc)
37+
- [Atom](#using-haskell-language-server-with-atom)
38+
- [Emacs](#using-haskell-language-server-with-emacs)
39+
- [Doom emacs](#using-haskell-language-server-with-doom-emacs)
40+
- [Kakoune](#using-haskell-language-server-with-kakoune)
3241
- [Contributing](#contributing)
3342
- [It's time to join the project!](#its-time-to-join-the-project)
3443

@@ -276,9 +285,149 @@ dependencies:
276285

277286
## Editor Integration
278287

279-
Note to editor integrators: there is now a haskell-language-server-wrapper executable, which is installed alongside the haskell-language-server executable. When this is invoked in the project root directory, it attempts to work out the GHC version used in the project, and then launch the matching haskell-language-server executable.
288+
Note to editor integrators: there is a `haskell-language-server-wrapper` executable, which is installed alongside the `haskell-language-server` executable. When this is invoked in the project root directory, it attempts to work out the GHC version used in the project, and then launch the matching `haskell-language-server` executable.
280289

281-
All of the editor integrations assume that you have already installed haskell-language-server (see above) and that the installation script put the haskell-language-server binary in your path (usually `~/.local/bin` or `~/.cabal/bin` on linux and macOS).
290+
All of the editor integrations assume that you have already installed `haskell-language-server` (see above) and that the installation script put the `haskell-language-server` and `haskell-language-server-wrapper` binaries in your `PATH` (usually `~/.local/bin` or `~/.cabal/bin` on Linux and macOS, `%APPDATA%\local\bin` or `%APPDATA%\cabal\bin` on Windows).
291+
292+
### Using Haskell Language Server with VS Code
293+
294+
Install from
295+
[the VSCode marketplace](https://marketplace.visualstudio.com/items?itemName=alanz.vscode-hie-server), or manually from the repository [vscode-hie-server](https://github.com/alanz/vscode-hie-server).
296+
297+
Choose `haskell-language-server` in the extension setting `languageServerHaskell.hieVariant`.
298+
299+
### Using Haskell Language Server with Sublime Text
300+
301+
- Install [LSP](https://packagecontrol.io/packages/LSP) using [Package Control](https://packagecontrol.io/)
302+
- From Sublime Text, go to Preferences and search for LSP Settings
303+
- Paste in these settings. Make sure to change the command path to your `haskell-language-server-wrapper`
304+
305+
```json
306+
{
307+
"clients": {
308+
"haskell-language-server": {
309+
"command": ["haskell-language-server-wrapper", "--lsp"],
310+
"scopes": ["source.haskell"],
311+
"syntaxes": ["Packages/Haskell/Haskell.sublime-syntax"],
312+
"languageId": "haskell",
313+
},
314+
},
315+
}
316+
```
317+
318+
Now open a Haskell project with Sublime Text and enable Language Server in the project.
319+
You should have these features available:
320+
321+
1. Errors are underlined in red
322+
2. LSP: Show Diagnostics will show a list of hints and errors
323+
3. LSP: Format Document will prettify the file
324+
325+
### Using Haskell Language Server with Vim or Neovim
326+
327+
You can use [Coc](https://github.com/neoclide/coc.nvim), [LanguageClient-neovim](https://github.com/autozimu/LanguageClient-neovim)
328+
or any other Vim Language server protocol client.
329+
Coc is recommend since it is the only complete LSP implementation for Vim and Neovim and offers snippets and floating documentation out of the box.
330+
331+
#### Coc
332+
333+
Follow Coc's [installation instructions](https://github.com/neoclide/coc.nvim).
334+
Then issue `:CocConfig` and add the following to your Coc config file.
335+
336+
```json
337+
"languageserver": {
338+
"haskell": {
339+
"command": "haskell-language-server-wrapper",
340+
"args": ["--lsp"],
341+
"rootPatterns": [
342+
"*.cabal",
343+
"stack.yaml",
344+
"cabal.project",
345+
"package.yaml"
346+
],
347+
"filetypes": [
348+
"hs",
349+
"lhs",
350+
"haskell"
351+
],
352+
"initializationOptions": {
353+
"languageServerHaskell": {
354+
}
355+
}
356+
}
357+
}
358+
```
359+
360+
#### LanguageClient-neovim
361+
362+
##### vim-plug
363+
364+
If you use [vim-plug](https://github.com/junegunn/vim-plug), then you can do this by e.g.,
365+
including the following line in the Plug section of your `init.vim` or `~/.vimrc`:
366+
367+
```text
368+
Plug 'autozimu/LanguageClient-neovim', {
369+
\ 'branch': 'next',
370+
\ 'do': 'bash install.sh'
371+
\ }
372+
```
373+
374+
and issuing a `:PlugInstall` command within Neovim or Vim.
375+
376+
##### Clone the LanguageClient-neovim repo
377+
378+
As an alternative to using [vim-plug](https://github.com/junegunn/vim-plug) shown above, clone [LanguageClient-neovim](https://github.com/autozimu/LanguageClient-neovim)
379+
into `~/.vim/pack/XXX/start/`, where `XXX` is just a name for your "plugin suite".
380+
381+
##### Sample `~/.vimrc`
382+
383+
```vim
384+
set rtp+=~/.vim/pack/XXX/start/LanguageClient-neovim
385+
let g:LanguageClient_serverCommands = { 'haskell': ['haskell-language-server-wrapper', '--lsp'] }
386+
```
387+
388+
You'll probably want to add some mappings for common commands:
389+
390+
```vim
391+
nnoremap <F5> :call LanguageClient_contextMenu()<CR>
392+
map <Leader>lk :call LanguageClient#textDocument_hover()<CR>
393+
map <Leader>lg :call LanguageClient#textDocument_definition()<CR>
394+
map <Leader>lr :call LanguageClient#textDocument_rename()<CR>
395+
map <Leader>lf :call LanguageClient#textDocument_formatting()<CR>
396+
map <Leader>lb :call LanguageClient#textDocument_references()<CR>
397+
map <Leader>la :call LanguageClient#textDocument_codeAction()<CR>
398+
map <Leader>ls :call LanguageClient#textDocument_documentSymbol()<CR>
399+
```
400+
401+
Use <kbd>Ctrl+x</kbd><kbd>Ctrl+o</kbd> (`<C-x><C-o>`) to open up the auto-complete menu,
402+
or for asynchronous auto-completion, follow the setup instructions on
403+
[LanguageClient](https://github.com/autozimu/LanguageClient-neovim).
404+
405+
If you'd like diagnostics to be highlighted, add a highlight group for `ALEError`/`ALEWarning`/`ALEInfo`,
406+
or customize `g:LanguageClient_diagnosticsDisplay`:
407+
408+
```vim
409+
hi link ALEError Error
410+
hi Warning term=underline cterm=underline ctermfg=Yellow gui=undercurl guisp=Gold
411+
hi link ALEWarning Warning
412+
hi link ALEInfo SpellCap
413+
```
414+
415+
If you're finding that the server isn't starting at the correct project root,
416+
it may also be helpful to also specify root markers:
417+
418+
```vim
419+
let g:LanguageClient_rootMarkers = ['*.cabal', 'stack.yaml']
420+
```
421+
422+
### Using Haskell Language Server with Atom
423+
424+
Install the two Atom packages [atom-ide-ui](https://atom.io/packages/atom-ide-ui) and [ide-haskell-hie](https://atom.io/packages/ide-haskell-hie),
425+
426+
```bash
427+
$ apm install language-haskell atom-ide-ui ide-haskell-hie
428+
```
429+
430+
The plugin ide-haskell-hie is designed to work with haskell-ide-engine by default, so you will have to put the path to haskell-language-server-wrapper in the configuration option `Absolute path to hie executable`.
282431

283432
### Using haskell-language-server with Emacs
284433

@@ -300,11 +449,10 @@ Make sure to follow the instructions in the README of each of these packages.
300449
)
301450
```
302451

303-
304-
305452
### Using haskell-language-server with [doom-emacs](https://github.com/hlissner/doom-emacs/tree/develop/modules/lang/haskell#module-flags)
306453

307454
Install haskell-language-server, and then enable haskell lang module with lsp flag in `.doom.d/init.el`
455+
308456
``` emacs-lisp
309457
:lang
310458
(haskell +lsp)
@@ -324,7 +472,6 @@ in your `.doom.d/config.el` file
324472

325473
then do `$HOME/.emacs.d/bin/doom refresh`
326474

327-
328475
### Using haskell-language-server with [Kakoune](https://github.com/mawww/kakoune)
329476

330477
1. Grab a copy of [kak-lsp](https://github.com/ul/kak-lsp), and follow the setup instructions.
@@ -340,7 +487,7 @@ args = ["--lsp"]
340487

341488
## Contributing
342489

343-
### It's time to join the project!
490+
### It's time to join the project
344491

345492
:heart: Haskell tooling dream is near, we need your help! :heart:
346493

0 commit comments

Comments
 (0)