Add support for parinfer-rust-mode (#1)

This commit adds support for the module flag +rust, which will use parinfer-rust-mode
instead of parinfer-mode. Parinfer-rust-mode makes use of an external library named parinfer-rust
to do the heavy lifting. As such, --with-modules must be enabled.
This commit is contained in:
Johan Thorén 2021-02-18 21:49:49 +01:00 committed by Johan Thoren
parent 3f4cc77d2a
commit ec747395c6
No known key found for this signature in database
GPG key ID: C8808B69584976F6
3 changed files with 53 additions and 25 deletions

View file

@ -17,7 +17,9 @@ https://raw.githubusercontent.com/DogLooksGood/parinfer-mode/a7c041454e05ec2b883
More information can be found about it [[https://shaunlebron.github.io/parinfer/][in the project's documentation]]. More information can be found about it [[https://shaunlebron.github.io/parinfer/][in the project's documentation]].
** Module Flags ** Module Flags
This module provides no flags. + =+rust= Use [[github:justinbarclay/parinfer-rust-mode][parinfer-rust-mode]] instead of the now deprecated [[github:DogLooksGood/parinfer-mode][parinfer-mode]].
This depends on Emacs being compiled with the option `--with-modules`. The
pre-built library is only available for Linux, Windows and MacOS.
** Packages ** Packages
+ [[https://github.com/DogLooksGood/parinfer-mode][parinfer]] + [[https://github.com/DogLooksGood/parinfer-mode][parinfer]]

View file

@ -1,24 +1,48 @@
;;; editor/parinfer/config.el -*- lexical-binding: t; -*- ;;; editor/parinfer/config.el -*- lexical-binding: t; -*-
(use-package! parinfer (if (not (featurep! +rust))
:hook ((emacs-lisp-mode (use-package! parinfer
clojure-mode :hook ((emacs-lisp-mode
scheme-mode clojure-mode
lisp-mode scheme-mode
racket-mode lisp-mode
hy-mode) . parinfer-mode) racket-mode
:init hy-mode) . parinfer-mode)
(setq parinfer-extensions :init
'(defaults (setq parinfer-extensions
pretty-parens '(defaults
smart-tab pretty-parens
smart-yank)) smart-tab
(when (featurep! :editor evil +everywhere) smart-yank))
(push 'evil parinfer-extensions)) (when (featurep! :editor evil +everywhere)
:config (push 'evil parinfer-extensions))
(map! :map parinfer-mode-map :config
"\"" nil ; smartparens handles this (map! :map parinfer-mode-map
:i "<tab>" #'parinfer-smart-tab:dwim-right-or-complete "\"" nil ; smartparens handles this
:i "<backtab>" #'parinfer-smart-tab:dwim-left :i "<tab>" #'parinfer-smart-tab:dwim-right-or-complete
:localleader :i "<backtab>" #'parinfer-smart-tab:dwim-left
:desc "Toggle parinfer-mode" "m" #'parinfer-toggle-mode)) :localleader
:desc "Toggle parinfer-mode" "m" #'parinfer-toggle-mode))
(defvar parinfer-rust--doom-lib-name (cond ((eq system-type 'darwin)
"parinfer-rust-darwin.so")
((eq system-type 'gnu/linux)
"parinfer-rust-linux.so")
((eq system-type 'windows-nt)
"parinfer-rust-windows.dll")))
(use-package! parinfer-rust-mode
:hook ((emacs-lisp-mode
clojure-mode
scheme-mode
lisp-mode
racket-mode
hy-mode) . parinfer-rust-mode)
:init
(setq! parinfer-rust-library (concat user-emacs-directory
".local/etc/parinfer-rust/"
parinfer-rust--doom-lib-name))
:config
(map! :map parinfer-rust-mode-map
:localleader
:desc "Switch parinfer-rust-mode" "m" #'parinfer-rust-switch-mode
:desc "Temporarily disable parinfer-rust-mode" "M"
#'parinfer-rust-switch-mode)))

View file

@ -1,7 +1,7 @@
;; -*- no-byte-compile: t; -*- ;; -*- no-byte-compile: t; -*-
;;; editor/parinfer/packages.el ;;; editor/parinfer/packages.el
(when (featurep! :editor evil) (when (and (not (featurep! +rust)) (featurep! :editor evil))
;; Parinfer uses `evil-define-key' without loading evil, so if evil is ;; Parinfer uses `evil-define-key' without loading evil, so if evil is
;; installed *after* parinfer, parinfer will throw up void-function errors. ;; installed *after* parinfer, parinfer will throw up void-function errors.
;; because evil-define-key (a macro) wasn't expanded at compile-time. So we ;; because evil-define-key (a macro) wasn't expanded at compile-time. So we
@ -11,4 +11,6 @@
;; separate session: ;; separate session:
(autoload 'evil-define-key "evil-core" nil nil 'macro)) (autoload 'evil-define-key "evil-core" nil nil 'macro))
(package! parinfer :pin "8659c99a9475ee34af683fdf8f272728c6bebb3a") (if (featurep! +rust)
(package! parinfer-rust-mode :pin "c825606e6aca4a2ed18c0af321df5f36a3c8c774")
(package! parinfer :pin "8659c99a9475ee34af683fdf8f272728c6bebb3a"))