2015-04-19 03:40:24 +00:00
|
|
|
(setq racket-packages
|
2015-04-09 04:40:49 +00:00
|
|
|
'(
|
|
|
|
company
|
2015-11-20 18:25:53 +00:00
|
|
|
company-quickhelp
|
2015-04-09 04:40:49 +00:00
|
|
|
racket-mode
|
|
|
|
))
|
|
|
|
|
|
|
|
(defun racket/post-init-company ()
|
|
|
|
;; this is the only thing to do to enable company in racket-mode
|
|
|
|
;; because racket-mode handle everything for us when company
|
|
|
|
;; is loaded.
|
|
|
|
(add-hook 'racket-mode-hook 'company-mode))
|
|
|
|
|
|
|
|
(defun racket/post-init-company-quickhelp ()
|
|
|
|
;; Bug exists in Racket company backend that opens docs in new window when
|
|
|
|
;; company-quickhelp calls it. Note hook is appendended for proper ordering.
|
|
|
|
(add-hook 'company-mode-hook
|
|
|
|
'(lambda ()
|
|
|
|
(when (equal major-mode 'racket-mode)
|
|
|
|
(company-quickhelp-mode -1))) t))
|
2015-03-25 23:16:55 +00:00
|
|
|
|
|
|
|
(defun racket/init-racket-mode ()
|
|
|
|
(use-package racket-mode
|
|
|
|
:defer t
|
|
|
|
:config
|
|
|
|
(progn
|
2015-03-28 03:37:33 +00:00
|
|
|
;; smartparens configuration
|
2015-09-29 05:07:57 +00:00
|
|
|
(with-eval-after-load 'smartparens
|
|
|
|
(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)))
|
2015-03-28 03:37:33 +00:00
|
|
|
|
|
|
|
(defun spacemacs/racket-test-with-coverage ()
|
|
|
|
"Call `racket-test' with universal argument."
|
|
|
|
(interactive)
|
|
|
|
(racket-test t))
|
|
|
|
|
2015-07-31 15:30:27 +00:00
|
|
|
(defun spacemacs/racket-run-and-switch-to-repl ()
|
|
|
|
"Call `racket-run-and-switch-to-repl' and enable
|
|
|
|
`insert state'."
|
|
|
|
(interactive)
|
|
|
|
(racket-run-and-switch-to-repl)
|
|
|
|
(evil-insert-state))
|
|
|
|
|
2015-03-28 03:37:33 +00:00
|
|
|
(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))
|
|
|
|
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'racket-mode
|
2015-03-28 03:37:33 +00:00
|
|
|
;; navigation
|
2015-11-18 00:38:05 +00:00
|
|
|
"g`" 'racket-unvisit
|
|
|
|
"gg" 'racket-visit-definition
|
|
|
|
"gm" 'racket-visit-module
|
|
|
|
"gr" 'racket-open-require-path
|
2015-03-28 03:37:33 +00:00
|
|
|
;; doc
|
2015-11-18 00:38:05 +00:00
|
|
|
"hd" 'racket-describe
|
|
|
|
"hh" 'racket-doc
|
2015-03-28 03:37:33 +00:00
|
|
|
;; insert
|
2015-11-18 00:38:05 +00:00
|
|
|
"il" 'racket-insert-lambda
|
2015-03-28 03:37:33 +00:00
|
|
|
;; REPL
|
2015-11-18 00:38:05 +00:00
|
|
|
"sb" 'racket-run
|
|
|
|
"sB" 'spacemacs/racket-run-and-switch-to-repl
|
|
|
|
"se" 'racket-send-last-sexp
|
|
|
|
"sE" 'spacemacs/racket-send-last-sexp-focus
|
|
|
|
"sf" 'racket-send-definition
|
|
|
|
"sF" 'spacemacs/racket-send-definition-focus
|
|
|
|
"si" 'racket-repl
|
|
|
|
"sr" 'racket-send-region
|
|
|
|
"sR" 'spacemacs/racket-send-region-focus
|
|
|
|
"ss" 'racket-repl
|
2015-03-28 03:37:33 +00:00
|
|
|
;; Tests
|
2015-11-18 00:38:05 +00:00
|
|
|
"tb" 'racket-test
|
|
|
|
"tB" 'spacemacs/racket-test-with-coverage)
|
2015-06-30 06:18:04 +00:00
|
|
|
(define-key racket-mode-map (kbd "H-r") 'racket-run)
|
2015-07-01 05:41:57 +00:00
|
|
|
;; remove racket auto-insert of closing delimiter
|
|
|
|
;; see https://github.com/greghendershott/racket-mode/issues/140
|
2015-06-30 06:18:04 +00:00
|
|
|
(define-key racket-mode-map ")" 'self-insert-command)
|
|
|
|
(define-key racket-mode-map "]" 'self-insert-command)
|
|
|
|
(define-key racket-mode-map "}" 'self-insert-command))))
|