Skip to content

Commit

Permalink
doc Emacs setup with LSP
Browse files Browse the repository at this point in the history
  • Loading branch information
unhammer committed Jan 16, 2023
1 parent 07a7def commit e49951a
Showing 1 changed file with 44 additions and 8 deletions.
52 changes: 44 additions & 8 deletions Guide/editors.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,56 @@ export IHP_EDITOR="sublime"

## Using IHP with Emacs

Install the following packages from [Melpa](https://melpa.org/#/getting-started):
This section describes the minimal setup needed to get syntax
highlighting, goto-definition, type errors and linting of IHP projects
in Emacs with few external dependencies.

- `dante` – gives IDE features via ghci, see https://github.com/jyp/dante#installation
- `direnv-mode` – lets haskell-mode and dante-mode find the PATH to ghci, see https://github.com/wbolster/emacs-direnv#installation
- `attrap` (optional) – apply fixes at point, see https://github.com/jyp/attrap
If you have Emacs 29 or later, the language server package `eglot` is
already included. If you're stuck on an older Emacs version, install
it from ELPA with `M-x package-install eglot RET`.

and put a `.dir-locals.el` file in your project root with:
Install the following additional packages from [Melpa](https://melpa.org/#/getting-started):

- `haskell-mode` – enable basic Haskell support, syntax highlighting, ghci interaction
- `envrc-mode` – lets eglot find the PATH to Haskell Language Server etc.

At the very least you need `(add-hook 'haskell-mode-hook #'eglot-ensure)`
and `(envrc-global-mode +1)` in your ~/.emacs.d/init.el, but you may also
want to set up some keybindings to common language server functions
(since by default none are included). Here's an example init file:

```emacs-lisp
((nil
(dante-repl-command-line . ("ghci"))
(haskell-process-type . ghci)))
(use-package envrc
:config
(envrc-global-mode +1))
(use-package eglot
:config
(add-hook 'haskell-mode-hook #'eglot-ensure)
;; Optionally add keybindings to some common functions:
:bind ((:map eglot-mode-map
("C-c C-e r" . eglot-rename)
("C-c C-e l" . flymake-show-buffer-diagnostics)
("C-c C-e p" . flymake-show-project-diagnostics)
("C-c C-e C" . eglot-show-workspace-configuration)
("C-c C-e R" . eglot-reconnect)
("C-c C-e S" . eglot-shutdown)
("C-c C-e A" . eglot-shutdown-all)
("C-c C-e a" . eglot-code-actions)
("C-c C-e f" . eglot-format))))
;; Optional: Show/pick completions on tab, sane max height:
(setq tab-always-indent 'complete
completions-max-height 20
completion-auto-select 'second-tab)
```

(The built-in completion menu isn't very modern-looking, a good
alternative if you want to add another plugin is
[corfu](https://github.com/minad/corfu).)



## Using IHP with Vim / NeoVim

### Using CoC
Expand Down

0 comments on commit e49951a

Please sign in to comment.