Skip to content

Commit

Permalink
Wingman: add emacs example config to Readme (#1988)
Browse files Browse the repository at this point in the history
This adds a barebones example config for emacs. Most things work out of
the box anyways, but I found the `lsp-make-interactive-code-action`
function somewhat hard to find, so I think the pointer to it would
probably benefit people.

Co-authored-by: Javier Neira <atreyu.bbb@gmail.com>
  • Loading branch information
stuebinm and jneira committed Jun 30, 2021
1 parent 2df3d30 commit d6de2bb
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions plugins/hls-tactics-plugin/README.md
Expand Up @@ -99,6 +99,33 @@ function! s:WingmanUseCtor(type)
endfunction
```

### Emacs

When using Emacs, wingman actions should be available out-of-the-box and
show up e.g. when using `M-x helm-lsp-code-actions RET` provided by
[helm-lsp](https://github.com/emacs-lsp/helm-lsp) or as popups via
[lsp-ui-sideline](https://emacs-lsp.github.io/lsp-ui/#lsp-ui-sideline).

Additionally, if you want to bind wingman actions directly to specific
keybindings or use them from Emacs Lisp, you can do so like this:

``` emacs-lisp
;; will define elisp functions for the given lsp code actions, prefixing the
;; given function names with "lsp"
(lsp-make-interactive-code-action wingman-fill-hole "refactor.wingman.fillHole")
(lsp-make-interactive-code-action wingman-case-split "refactor.wingman.caseSplit")
(lsp-make-interactive-code-action wingman-refine "refactor.wingman.refine")
(lsp-make-interactive-code-action wingman-split-func-args "refactor.wingman.spltFuncArgs")
(lsp-make-interactive-code-action wingman-use-constructor "refactor.wingman.useConstructor")
;; example key bindings
(define-key haskell-mode-map (kbd "C-c d") #'lsp-wingman-case-split)
(define-key haskell-mode-map (kbd "C-c n") #'lsp-wingman-fill-hole)
(define-key haskell-mode-map (kbd "C-c r") #'lsp-wingman-refine)
(define-key haskell-mode-map (kbd "C-c c") #'lsp-wingman-use-constructor)
(define-key haskell-mode-map (kbd "C-c a") #'lsp-wingman-split-func-args)
```

### Other Editors

Please open a PR if you have a working configuration!
Expand Down

0 comments on commit d6de2bb

Please sign in to comment.