There's no official polymode
layer for Spacemacs, but I've found a couple of implementations in random configs on GitHub. Here's one that works for me:
;;; packages.el --- polymode layer packages file for Spacemacs.
;;
;; Copyright (c) 2012-2016 Sylvain Benner & Contributors
;;
;; Author: Walmes Zeviani & Fernando Mayer
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; Layer retrieved from here:
;; https://github.com/MilesMcBain/spacemacs_cfg/blob/master/private/polymode/packages.el
;;
;;; Code:
(defconst polymode-packages
'(polymode
poly-R
poly-markdown))
(defun polymode/init-poly-R ())
(defun polymode/init-poly-markdown ())
(defun polymode/init-polymode ()
(use-package polymode
:mode (("\\.Rmd" . Rmd-mode))
:init
(progn
(defun Rmd-mode ()
"ESS Markdown mode for Rmd files"
(interactive)
(require 'poly-R)
(require 'poly-markdown)
(R-mode)
(poly-markdown+r-mode))
))
)
;;; packages.el ends here
There are a few ways to work with private custom layers like this, but one straightforward and easy way is to...
- Save the code above as a file named
packages.el
in ~/.emacs.d/layers/private/polymode/
.
- Add
polymode
to your list of dotspacemacs/layers
, e.g.
(defun dotspacemacs/layers ()
ess
polymode
python
...
- Restart Emacs and the
polymode
package should install.
Using this, you shouldn't have to use (add-to-list 'auto-mode-alist...
to declare the particular mode that .Rmd
files should use since it's defined in the layer. I retrieved this particular layer from here. I tried one or two others as well, but they didn't work for me.