diff --git a/README.md b/README.md index da1f915f99..c81c0473df 100644 --- a/README.md +++ b/README.md @@ -26,9 +26,18 @@ This is *very* early stage software. - [Install specific GHC Version](#install-specific-ghc-version) - [Project Configuration](#project-configuration) - [Editor Integration](#editor-integration) - - [With emacs](#using-haskell-language-server-with-emacs) - - [With doom emacs](#using-haskell-language-server-with-doom-emacs) - - [With Kakoune](#using-haskell-language-server-with-kakoune) + - [VS Code](#using-haskell-language-server-with-vs-code) + - [Sublime Text](#using-haskell-language-server-with-sublime-text) + - [Vim or Neovim](#using-haskell-language-server-with-vim-or-neovim) + - [Coc](#coc) + - [LanguageClient-neovim](#languageclient-neovim) + - [vim-plug](#vim-plug) + - [Clone the LanguageClient-neovim repo](#clone-the-languageclient-neovim-repo) + - [Sample `~/.vimrc`](#sample-vimrc) + - [Atom](#using-haskell-language-server-with-atom) + - [Emacs](#using-haskell-language-server-with-emacs) + - [Doom emacs](#using-haskell-language-server-with-doom-emacs) + - [Kakoune](#using-haskell-language-server-with-kakoune) - [Contributing](#contributing) - [It's time to join the project!](#its-time-to-join-the-project) @@ -273,9 +282,149 @@ dependencies: ## Editor Integration -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. +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. -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). +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). + +### Using Haskell Language Server with VS Code + +Install from +[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). + +Choose `haskell-language-server` in the extension setting `languageServerHaskell.hieVariant`. + +### Using Haskell Language Server with Sublime Text + +- Install [LSP](https://packagecontrol.io/packages/LSP) using [Package Control](https://packagecontrol.io/) +- From Sublime Text, go to Preferences and search for LSP Settings +- Paste in these settings. Make sure to change the command path to your `haskell-language-server-wrapper` + +```json +{ + "clients": { + "haskell-language-server": { + "command": ["haskell-language-server-wrapper", "--lsp"], + "scopes": ["source.haskell"], + "syntaxes": ["Packages/Haskell/Haskell.sublime-syntax"], + "languageId": "haskell", + }, + }, +} +``` + +Now open a Haskell project with Sublime Text and enable Language Server in the project. +You should have these features available: + +1. Errors are underlined in red +2. LSP: Show Diagnostics will show a list of hints and errors +3. LSP: Format Document will prettify the file + +### Using Haskell Language Server with Vim or Neovim + +You can use [Coc](https://github.com/neoclide/coc.nvim), [LanguageClient-neovim](https://github.com/autozimu/LanguageClient-neovim) +or any other Vim Language server protocol client. +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. + +#### Coc + +Follow Coc's [installation instructions](https://github.com/neoclide/coc.nvim). +Then issue `:CocConfig` and add the following to your Coc config file. + +```json +"languageserver": { + "haskell": { + "command": "haskell-language-server-wrapper", + "args": ["--lsp"], + "rootPatterns": [ + "*.cabal", + "stack.yaml", + "cabal.project", + "package.yaml" + ], + "filetypes": [ + "hs", + "lhs", + "haskell" + ], + "initializationOptions": { + "languageServerHaskell": { + } + } + } +} +``` + +#### LanguageClient-neovim + +##### vim-plug + +If you use [vim-plug](https://github.com/junegunn/vim-plug), then you can do this by e.g., +including the following line in the Plug section of your `init.vim` or `~/.vimrc`: + +```text +Plug 'autozimu/LanguageClient-neovim', { + \ 'branch': 'next', + \ 'do': 'bash install.sh' + \ } +``` + +and issuing a `:PlugInstall` command within Neovim or Vim. + +##### Clone the LanguageClient-neovim repo + +As an alternative to using [vim-plug](https://github.com/junegunn/vim-plug) shown above, clone [LanguageClient-neovim](https://github.com/autozimu/LanguageClient-neovim) +into `~/.vim/pack/XXX/start/`, where `XXX` is just a name for your "plugin suite". + +##### Sample `~/.vimrc` + +```vim +set rtp+=~/.vim/pack/XXX/start/LanguageClient-neovim +let g:LanguageClient_serverCommands = { 'haskell': ['haskell-language-server-wrapper', '--lsp'] } +``` + +You'll probably want to add some mappings for common commands: + +```vim +nnoremap :call LanguageClient_contextMenu() +map lk :call LanguageClient#textDocument_hover() +map lg :call LanguageClient#textDocument_definition() +map lr :call LanguageClient#textDocument_rename() +map lf :call LanguageClient#textDocument_formatting() +map lb :call LanguageClient#textDocument_references() +map la :call LanguageClient#textDocument_codeAction() +map ls :call LanguageClient#textDocument_documentSymbol() +``` + +Use Ctrl+xCtrl+o (``) to open up the auto-complete menu, +or for asynchronous auto-completion, follow the setup instructions on +[LanguageClient](https://github.com/autozimu/LanguageClient-neovim). + +If you'd like diagnostics to be highlighted, add a highlight group for `ALEError`/`ALEWarning`/`ALEInfo`, +or customize `g:LanguageClient_diagnosticsDisplay`: + +```vim +hi link ALEError Error +hi Warning term=underline cterm=underline ctermfg=Yellow gui=undercurl guisp=Gold +hi link ALEWarning Warning +hi link ALEInfo SpellCap +``` + +If you're finding that the server isn't starting at the correct project root, +it may also be helpful to also specify root markers: + +```vim +let g:LanguageClient_rootMarkers = ['*.cabal', 'stack.yaml'] +``` + +### Using Haskell Language Server with Atom + +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), + +```bash +$ apm install language-haskell atom-ide-ui ide-haskell-hie +``` + +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`. ### Using haskell-language-server with Emacs @@ -297,11 +446,10 @@ Make sure to follow the instructions in the README of each of these packages. ) ``` - - ### Using haskell-language-server with [doom-emacs](https://github.com/hlissner/doom-emacs/tree/develop/modules/lang/haskell#module-flags) Install haskell-language-server, and then enable haskell lang module with lsp flag in `.doom.d/init.el` + ``` emacs-lisp :lang (haskell +lsp) @@ -321,7 +469,6 @@ in your `.doom.d/config.el` file then do `$HOME/.emacs.d/bin/doom refresh` - ### Using haskell-language-server with [Kakoune](https://github.com/mawww/kakoune) 1. Grab a copy of [kak-lsp](https://github.com/ul/kak-lsp), and follow the setup instructions. @@ -337,7 +484,7 @@ args = ["--lsp"] ## Contributing -### It's time to join the project! +### It's time to join the project :heart: Haskell tooling dream is near, we need your help! :heart: