-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpolymode-config.el
72 lines (67 loc) · 2.47 KB
/
polymode-config.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
;; Time-stamp: <2022-05-27 10:38:04 (lanes1)>
;; Split out package loading into a separate file.
;; Code highlighting via polymode
(use-package markdown-mode
:ensure t
:mode
(("README\\.md\\'" . gfm-mode)
("\\.md\\'" . markdown-mode)
("\\.markdown\\'" . markdown-mode))
:init
(setq markdown-command "markdown")
)
(use-package polymode
:ensure markdown-mode
:ensure poly-R
:ensure poly-noweb
:config
;; R/tex polymodes
(add-to-list 'auto-mode-alist '("\\.Rnw" . poly-noweb+r-mode))
(add-to-list 'auto-mode-alist '("\\.rnw" . poly-noweb+r-mode))
;; (add-to-list 'auto-mode-alist '("\\.Rmd" . poly-markdown+r-mode))
(add-to-list 'auto-mode-alist '("\\.Rmd" . poly-markdown))
(add-to-list 'auto-mode-alist '("\\.qmd" . poly-markdown))
;; org-mode poly (not working at the moment)
;; (add-to-list 'auto-mode-alist '("\\.org" . poly-org-mode))
;; Make sure r-mode is loaded
;; (autoload 'r-mode "ess-site.el" "Major mode for editing R source." t)
;; Add a chunk for rmarkdown
;; Need to add a keyboard shortcut
;; https://emacs.stackexchange.com/questions/27405/insert-code-chunk-in-r-markdown-with-yasnippet-and-polymode
;; (defun insert-r-chunk (header)
;; "Insert an r-chunk in markdown mode. Necessary due to interactions between polymode and yas snippet"
;; (interactive "sHeader: ")
;; (insert (concat "```{r " header "}\n\n\n```"))
;; (forward-line -2))
;; (define-key poly-markdown+r-mode-map (kbd "M-c") #'insert-r-chunk)
)
(use-package poly-markdown
:ensure polymode
:defer t
:config
;; Wrap lines at column limit, but don't put hard returns in
(add-hook 'markdown-mode-hook (lambda () (visual-line-mode 1)))
;; Flyspell on
(add-hook 'markdown-mode-hook (lambda () (flyspell-mode 1)))
)
;; poly-R
(use-package poly-R
:ensure polymode
:ensure poly-markdown
:ensure poly-noweb
:defer t
:config
;; Add a chunk for rmarkdown
;; Need to add a keyboard shortcut
;; https://emacs.stackexchange.com/questions/27405/insert-code-chunk-in-r-markdown-with-yasnippet-and-polymode
;; (defun insert-r-chunk (header)
;; "Insert an r-chunk in markdown mode. Necessary due to interactions between polymode and yas snippet"
;; (interactive "sHeader: ")
;; (insert (concat "```{r " header "}\n\n\n```"))
;; (forward-line -2))
;; (define-key poly-markdown+r-mode-map (kbd "M-c") #'insert-r-chunk)
)
;; Add yaml to markdown an .yml files
(use-package yaml-mode
:ensure t
:mode (("\\.yml\\'" . yaml-mode)))