This commit is contained in:
ry
2022-01-11 18:05:13 -08:00
parent 2046befee2
commit 8e7b654716
846 changed files with 71287 additions and 4 deletions

View File

@@ -0,0 +1,70 @@
#+TITLE: lang/racket
#+DATE: July 29, 2018
#+SINCE: v2.0.9
#+STARTUP: inlineimages nofold
* Table of Contents :TOC_3:noexport:
- [[#description][Description]]
- [[#maintainers][Maintainers]]
- [[#module-flags][Module Flags]]
- [[#plugins][Plugins]]
- [[#prerequisites][Prerequisites]]
- [[#arch-linux][Arch Linux]]
- [[#features][Features]]
- [[#configuration][Configuration]]
- [[#racket-smart-open-bracket-mode][racket-smart-open-bracket-mode]]
- [[#unicode-input][Unicode Input]]
- [[#troubleshooting][Troubleshooting]]
* Description
This module provides integration for [[https://github.com/greghendershott/racket-mode][racket-mode]].
** Maintainers
This module has no dedicated maintainers.
** Module Flags
+ =+lsp= Enables LSP support. Requires jeapostrophe/racket-langserver.
+ =+xp= Enables the explore mode, which "analyzes expanded code to explain and explore."
** Plugins
+ [[https://github.com/greghendershott/racket-mode][racket-mode]]
* Prerequisites
This module only requires ~racket~. Install it directly from the [[https://download.racket-lang.org/][racket website]],
or check your package manger.
** Arch Linux
#+begin_src bash
pacman -S racket
#+end_src
Or, for fewer dependencies:
#+begin_src bash
pacman -S racket-minimal
#+end_src
* TODO Features
* Configuration
** racket-smart-open-bracket-mode
~racket-smart-open-bracket-mode~ gets turned off automatically if you use ~parinfer~,
~lispy~. If you wish to enable it, add the following to your ~config.el~:
#+BEGIN_SRC elisp
(after! racket-mode
(add-hook! racket-mode
#'racket-smart-open-bracket-mode))
#+END_SRC
** Unicode Input
The optional ~racket-unicode~ input method lets you type unicode characters such as λ or π.
To enable unicode input for a single buffer, run ~racket-unicode-input-method-enable~.
To enable unicode input by default on all racket buffers, add the following hooks
to your ~config.el~:
#+BEGIN_SRC elisp
(add-hook 'racket-mode-hook #'racket-unicode-input-method-enable)
(add-hook 'racket-repl-mode-hook #'racket-unicode-input-method-enable)
#+END_SRC
Once enabled, unicode input can be toggled by pressing C-\ or running ~toggle-input-method~.
* TODO Troubleshooting

View File

@@ -0,0 +1,30 @@
;;; lang/racket/autoload.el -*- lexical-binding: t; -*-
;;;###autoload
(defun +racket/open-repl ()
"Open the Racket REPL."
(interactive)
(pop-to-buffer
(or (get-buffer "*Racket REPL*")
(progn (racket-run-and-switch-to-repl)
(let ((buf (get-buffer "*Racket REPL*")))
(bury-buffer buf)
buf)))))
;;;###autoload
(defun +racket-lookup-documentation (thing)
"A `+lookup/documentation' handler for `racket-mode' and `racket-xp-mode'."
(let ((buf (if racket-xp-mode
(racket-xp-describe thing)
(racket-repl-describe thing))))
(when buf
(pop-to-buffer buf)
t)))
;;;###autoload
(defun +racket-lookup-definition (_thing)
"A `+lookup/definition' handler for `racket-mode' and `racket-xp-mode'."
(call-interactively
(if racket-xp-mode
#'racket-xp-visit-definition
#'racket-repl-visit-definition)))

View File

@@ -0,0 +1,93 @@
;;; lang/racket/config.el -*- lexical-binding: t; -*-
(after! projectile
(add-to-list 'projectile-project-root-files "info.rkt"))
;;
;;; Packages
(use-package! racket-mode
:mode "\\.rkt\\'" ; give it precedence over :lang scheme
:config
(set-repl-handler! 'racket-mode #'+racket/open-repl)
(set-lookup-handlers! '(racket-mode racket-repl-mode)
:definition #'+racket-lookup-definition
:documentation #'+racket-lookup-documentation)
(set-docsets! 'racket-mode "Racket")
(set-ligatures! 'racket-mode
:lambda "lambda"
:map "map"
:dot ".")
(set-rotate-patterns! 'racket-mode
:symbols '(("#true" "#false")))
(add-hook! 'racket-mode-hook
#'rainbow-delimiters-mode
#'highlight-quoted-mode)
(when (featurep! +lsp)
(add-hook 'racket-mode-local-vars-hook #'lsp!))
(when (featurep! +xp)
(add-hook 'racket-mode-local-vars-hook #'racket-xp-mode)
;; Both flycheck and racket-xp produce error popups, but racket-xp's are
;; higher quality so disable flycheck's:
(when (featurep! :checkers syntax)
(add-hook! 'racket-xp-mode-hook
(defun +racket-disable-flycheck-h ()
(cl-pushnew 'racket flycheck-disabled-checkers)))))
(unless (or (featurep! :editor parinfer)
(featurep! :editor lispy))
(add-hook 'racket-mode-hook #'racket-smart-open-bracket-mode))
(map! (:map racket-xp-mode-map
[remap racket-doc] #'racket-xp-documentation
[remap racket-visit-definition] #'racket-xp-visit-definition
[remap next-error] #'racket-xp-next-error
[remap previous-error] #'racket-xp-previous-error)
(:localleader
:map racket-mode-map
"a" #'racket-align
"A" #'racket-unalign
"f" #'racket-fold-all-tests
"F" #'racket-unfold-all-tests
"h" #'racket-doc
"i" #'racket-unicode-input-method-enable
"l" #'racket-logger
"o" #'racket-profile
"p" #'racket-cycle-paren-shapes
"r" #'racket-run
"R" #'racket-run-and-switch-to-repl
"t" #'racket-test
"u" #'racket-backward-up-list
"y" #'racket-insert-lambda
(:prefix ("m" . "macros")
"d" #'racket-expand-definition
"e" #'racket-expand-last-sexp
"r" #'racket-expand-region
"a" #'racket-expand-again)
(:prefix ("g" . "goto")
"b" #'racket-unvisit
"d" #'racket-visit-definition
"m" #'racket-visit-module
"r" #'racket-open-require-path)
(:prefix ("s" . "send")
"d" #'racket-send-definition
"e" #'racket-send-last-sexp
"r" #'racket-send-region)
:map racket-repl-mode-map
"l" #'racket-logger
"h" #'racket-repl-documentation
"y" #'racket-insert-lambda
"u" #'racket-backward-up-list
(:prefix ("m" . "macros")
"d" #'racket-expand-definition
"e" #'racket-expand-last-sexp
"f" #'racket-expand-file
"r" #'racket-expand-region)
(:prefix ("g" . "goto")
"b" #'racket-unvisit
"m" #'racket-visit-module
"d" #'racket-repl-visit-definition))))

View File

@@ -0,0 +1,11 @@
;; -*- lexical-binding: t; no-byte-compile: t; -*-
;;; lang/racket/doctor.el
(unless (executable-find "drracket")
(warn! "Could not find drracket executable; code-completion and syntax checking will not work."))
(unless (executable-find "racket")
(warn! "Could not find racket executable; REPL will not work."))
(unless (executable-find "raco")
(warn! "Could not find raco executable; commands for install packages and build libraries will not work."))

View File

@@ -0,0 +1,4 @@
;; -*- no-byte-compile: t; -*-
;;; lang/racket/packages.el
(package! racket-mode :pin "a879a8d67b062c9aa0c6e60602eedba80a2069c5")