racket layer: refactor and apply conventions

Add more key bindings
This commit is contained in:
syl20bnr 2015-03-27 23:37:33 -04:00
parent 904ff2d9eb
commit 3e68321f6d
2 changed files with 110 additions and 13 deletions

View file

@ -2,15 +2,61 @@
![logo_racket](img/racket.png)
## Description
Adds support for the [Racket](http://racket-lang.org/) programming language.
## Install
To use this contribution add it to your `~/.spacemacs`
```elisp
(setq-default dotspacemacs-configuration-layers '(racket))
```
## Key Bindings
### Navigation
Key Binding | Description
----------------------|------------------------------------------------------------
<kbd>SPC m r</kbd> | Run current file and open REPL
<kbd>SPC m l</kbd> | Enter [Evil Lisp State](https://github.com/syl20bnr/evil-lisp-state)
<kbd>SPC m t</kbd> | Run tests
<kbd>SPC m g</kbd> | Visit definition
<kbd>SPC m h d</kbd> | Visit Documentation
<kbd>SPC m g `</kbd> | Return to previous location
<kbd>SPC m g g</kbd> | Go to definition of symbol at point
<kbd>SPC m g m</kbd> | Go to module at point
<kbd>SPC m g r</kbd> | Open require path
### Documentation
Key Binding | Description
----------------------|------------------------------------------------------------
<kbd>SPC m h d</kbd> | Describes the function at point in a `Racket Describe` buffer
<kbd>SPC m h h</kbd> | View documentation of the identifier or string at point.
### Tests
Key Binding | Description
----------------------|------------------------------------------------------------
<kbd>SPC m t b</kbd> | Run tests of buffer
<kbd>SPC m t B</kbd> | Run tests of buffer with coverage
### REPL
Key Binding | Description
----------------------|------------------------------------------------------------
<kbd>SPC m s b</kbd> | Send buffer to REPL
<kbd>SPC m s B</kbd> | Send buffer to REPL and switch to REPL buffer in `insert state`
<kbd>SPC m s e</kbd> | Send last sexp to REPL
<kbd>SPC m s E</kbd> | Send last sexp to REPL and switch to REPL in `insert state`
<kbd>SPC m s f</kbd> | Send function at point to REPL
<kbd>SPC m s F</kbd> | Send function at point and switch to REPL in `insert state`
<kbd>SPC m s i</kbd> | Start a REPL or switch to REPL buffer
<kbd>SPC m s r</kbd> | Send region to REPL
<kbd>SPC m s R</kbd> | Send region to REPL and switch to REPL in `insert state`
<kbd>SPC m s s</kbd> | Show and switch to REPL buffer
### Other key bindings
Key Binding | Description
----------------------|------------------------------------------------------------
<kbd>SPC m i l</kbd> | Insert lambda character
<kbd>H-r</kbd> | Run current file and open REPL (`H` is hyper, *may* be bound to command on OSX)

View file

@ -6,16 +6,67 @@
:defer t
:config
(progn
(use-package smartparens :config
(progn (add-to-list 'sp--lisp-modes 'racket-mode)
(when (fboundp 'sp-local-pair) (sp-local-pair 'racket-mode "`" nil :actions nil))))
;; smartparens configuration
(eval-after-load 'smartparens
'(progn (add-to-list 'sp--lisp-modes 'racket-mode)
(when (fboundp 'sp-local-pair)
(sp-local-pair 'racket-mode "`" nil :actions nil))))
(sp-local-pair 'racket-mode "'" nil :actions nil)
(defun spacemacs/racket-test-with-coverage ()
"Call `racket-test' with universal argument."
(interactive)
(racket-test t))
(defun spacemacs/racket-send-last-sexp-focus ()
"Call `racket-send-last-sexp' and switch to REPL buffer in
`insert state'."
(interactive)
(racket-send-last-sexp)
(racket-repl)
(evil-insert-state))
(defun spacemacs/racket-send-definition-focus ()
"Call `racket-send-definition' and switch to REPL buffer in
`insert state'."
(interactive)
(racket-send-definition)
(racket-repl)
(evil-insert-state))
(defun spacemacs/racket-send-region-focus (start end)
"Call `racket-send-region' and switch to REPL buffer in
`insert state'."
(interactive "r")
(racket-send-region start end)
(racket-repl)
(evil-insert-state))
(evil-leader/set-key-for-mode 'racket-mode
"ml" 'evil-lisp-state
"mt" 'racket-test
"mr" 'racket-run
"mg" 'racket-visit-definition
"mhd" 'racket-doc)
;; navigation
"mg`" 'racket-unvisit
"mgg" 'racket-visit-definition
"mgm" 'racket-visit-module
"mgr" 'racket-open-require-path
;; doc
"mhd" 'racket-describe
"mhh" 'racket-doc
;; insert
"mil" 'racket-insert-lambda
;; REPL
"msb" 'racket-run
"msB" 'racket-run-and-switch-to-repl
"mse" 'racket-send-last-sexp
"msE" 'spacemacs/racket-send-last-sexp-focus
"msf" 'racket-send-definition
"msF" 'spacemacs/racket-send-definition-focus
"msi" 'racket-repl
"msr" 'racket-send-region
"msR" 'spacemacs/racket-send-region-focus
"mss" 'racket-repl
;; Tests
"mtb" 'racket-test
"mtB" 'spacemacs/racket-test-with-coverage)
(define-key racket-mode-map (kbd "H-r") 'racket-run)
;; Bug exists in Racket company backend that opens docs in new window when
;; company-quickhelp calls it. Note hook is appendended for proper ordering.