From d6de2bb0836b03233aeb6d36637513c8f3e35824 Mon Sep 17 00:00:00 2001 From: stuebinm Date: Wed, 30 Jun 2021 12:52:16 +0200 Subject: [PATCH] Wingman: add emacs example config to Readme (#1988) 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 --- plugins/hls-tactics-plugin/README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/plugins/hls-tactics-plugin/README.md b/plugins/hls-tactics-plugin/README.md index b8102a952a..8ef702b956 100644 --- a/plugins/hls-tactics-plugin/README.md +++ b/plugins/hls-tactics-plugin/README.md @@ -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!