2015-01-14 04:12:56 +00:00
|
|
|
;;; packages.el --- ESS (R) Layer packages File for Spacemacs
|
|
|
|
;;
|
2018-01-04 07:00:25 +00:00
|
|
|
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors
|
2015-01-14 04:12:56 +00:00
|
|
|
;;
|
|
|
|
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
|
|
|
;;; License: GPLv3
|
|
|
|
|
2015-04-19 03:40:24 +00:00
|
|
|
(setq ess-packages
|
2017-06-16 07:51:24 +00:00
|
|
|
'(
|
|
|
|
ess
|
|
|
|
ess-R-data-view
|
|
|
|
(ess-smart-equals :toggle ess-enable-smart-equals)
|
|
|
|
golden-ratio
|
|
|
|
org))
|
2014-11-12 04:02:50 +00:00
|
|
|
|
2014-11-11 05:08:23 +00:00
|
|
|
(defun ess/init-ess ()
|
2015-10-12 03:01:45 +00:00
|
|
|
(use-package ess-site
|
|
|
|
:mode (("\\.sp\\'" . S-mode)
|
|
|
|
("/R/.*\\.q\\'" . R-mode)
|
|
|
|
("\\.[qsS]\\'" . S-mode)
|
|
|
|
("\\.ssc\\'" . S-mode)
|
|
|
|
("\\.SSC\\'" . S-mode)
|
|
|
|
("\\.[rR]\\'" . R-mode)
|
|
|
|
("\\.[rR]nw\\'" . Rnw-mode)
|
|
|
|
("\\.[sS]nw\\'" . Snw-mode)
|
|
|
|
("\\.[rR]profile\\'" . R-mode)
|
|
|
|
("NAMESPACE\\'" . R-mode)
|
|
|
|
("CITATION\\'" . R-mode)
|
|
|
|
("\\.omg\\'" . omegahat-mode)
|
|
|
|
("\\.hat\\'" . omegahat-mode)
|
|
|
|
("\\.lsp\\'" . XLS-mode)
|
|
|
|
("\\.do\\'" . STA-mode)
|
|
|
|
("\\.ado\\'" . STA-mode)
|
|
|
|
("\\.[Ss][Aa][Ss]\\'" . SAS-mode)
|
|
|
|
("\\.[Ss]t\\'" . S-transcript-mode)
|
|
|
|
("\\.Sout" . S-transcript-mode)
|
|
|
|
("\\.[Rr]out" . R-transcript-mode)
|
|
|
|
("\\.Rd\\'" . Rd-mode)
|
|
|
|
("\\.[Bb][Uu][Gg]\\'" . ess-bugs-mode)
|
|
|
|
("\\.[Bb][Oo][Gg]\\'" . ess-bugs-mode)
|
|
|
|
("\\.[Bb][Mm][Dd]\\'" . ess-bugs-mode)
|
|
|
|
("\\.[Jj][Aa][Gg]\\'" . ess-jags-mode)
|
|
|
|
("\\.[Jj][Oo][Gg]\\'" . ess-jags-mode)
|
|
|
|
("\\.[Jj][Mm][Dd]\\'" . ess-jags-mode))
|
2018-08-11 03:30:56 +00:00
|
|
|
:commands (R stata julia SAS ess-julia-mode)
|
2015-02-05 16:09:21 +00:00
|
|
|
:init
|
|
|
|
(progn
|
2018-08-11 03:30:56 +00:00
|
|
|
(spacemacs/register-repl 'ess-site 'julia)
|
2016-02-01 04:41:40 +00:00
|
|
|
(spacemacs/register-repl 'ess-site 'R)
|
|
|
|
(spacemacs/register-repl 'ess-site 'SAS)
|
|
|
|
(spacemacs/register-repl 'ess-site 'stata)
|
2017-04-25 13:47:44 +00:00
|
|
|
(add-hook 'inferior-ess-mode-hook
|
2017-04-29 03:00:03 +00:00
|
|
|
'spacemacs//ess-fix-read-only-inferior-ess-mode)
|
2017-07-02 13:48:06 +00:00
|
|
|
(when (configuration-layer/package-used-p 'company)
|
2017-06-16 07:51:24 +00:00
|
|
|
(add-hook 'ess-mode-hook 'company-mode))))
|
2015-02-05 16:09:21 +00:00
|
|
|
|
2014-11-11 03:27:06 +00:00
|
|
|
;; R --------------------------------------------------------------------------
|
2018-06-26 13:31:53 +00:00
|
|
|
(setq spacemacs/ess-config
|
|
|
|
'(progn
|
|
|
|
;; Follow Hadley Wickham's R style guide
|
|
|
|
(setq ess-first-continued-statement-offset 2
|
|
|
|
ess-continued-statement-offset 0
|
|
|
|
ess-expression-offset 2
|
|
|
|
ess-nuke-trailing-whitespace-p t
|
|
|
|
ess-default-style 'DEFAULT)
|
|
|
|
(when ess-disable-underscore-assign
|
|
|
|
(ess-toggle-underscore nil))
|
2015-10-14 14:52:26 +00:00
|
|
|
|
2018-06-26 13:31:53 +00:00
|
|
|
(define-key ess-doc-map "h" 'ess-display-help-on-object)
|
|
|
|
(define-key ess-doc-map "p" 'ess-R-dv-pprint)
|
|
|
|
(define-key ess-doc-map "t" 'ess-R-dv-ctable)
|
|
|
|
(dolist (mode '(ess-julia-mode ess-mode))
|
|
|
|
(spacemacs/declare-prefix-for-mode mode "ms" "repl")
|
|
|
|
(spacemacs/declare-prefix-for-mode mode "mh" "help")
|
|
|
|
(spacemacs/declare-prefix-for-mode mode "mr" "extra")
|
|
|
|
(spacemacs/declare-prefix-for-mode mode "mw" "pkg")
|
|
|
|
(spacemacs/declare-prefix-for-mode mode "md" "dev")
|
|
|
|
(spacemacs/declare-prefix-for-mode mode "mc" "noweb")
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode
|
|
|
|
mode
|
|
|
|
"," 'ess-eval-region-or-function-or-paragraph-and-step
|
|
|
|
"'" 'spacemacs/ess-start-repl
|
|
|
|
"si" 'spacemacs/ess-start-repl
|
|
|
|
"ss" 'ess-switch-to-inferior-or-script-buffer
|
|
|
|
"sS" 'ess-switch-process
|
|
|
|
;; REPL
|
|
|
|
"sB" 'ess-eval-buffer-and-go
|
|
|
|
"sb" 'ess-eval-buffer
|
|
|
|
"sd" 'ess-eval-region-or-line-and-step
|
|
|
|
"sD" 'ess-eval-function-or-paragraph-and-step
|
|
|
|
"sL" 'ess-eval-line-and-go
|
|
|
|
"sl" 'ess-eval-line
|
|
|
|
"sR" 'ess-eval-region-and-go
|
|
|
|
"sr" 'ess-eval-region
|
|
|
|
"sF" 'ess-eval-function-and-go
|
|
|
|
"sf" 'ess-eval-function
|
|
|
|
;; predefined keymaps
|
|
|
|
"h" 'ess-doc-map
|
|
|
|
"r" 'ess-extra-map
|
|
|
|
"w" 'ess-r-package-dev-map
|
|
|
|
"d" 'ess-dev-map
|
|
|
|
;; noweb
|
|
|
|
"cC" 'ess-eval-chunk-and-go
|
|
|
|
"cc" 'ess-eval-chunk
|
|
|
|
"cd" 'ess-eval-chunk-and-step
|
|
|
|
"cm" 'ess-noweb-mark-chunk
|
|
|
|
"cN" 'ess-noweb-previous-chunk
|
|
|
|
"cn" 'ess-noweb-next-chunk))
|
|
|
|
(dolist (mode '(inferior-ess-mode))
|
|
|
|
(spacemacs/declare-prefix-for-mode mode "ms" "repl")
|
|
|
|
(spacemacs/declare-prefix-for-mode mode "me" "eval")
|
|
|
|
(spacemacs/declare-prefix-for-mode mode "mg" "xref")
|
|
|
|
(spacemacs/declare-prefix-for-mode mode "mh" "help")
|
|
|
|
(spacemacs/declare-prefix-for-mode mode "mr" "extra")
|
|
|
|
(spacemacs/declare-prefix-for-mode mode "mw" "pkg")
|
|
|
|
(spacemacs/declare-prefix-for-mode mode "md" "dev")
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode
|
|
|
|
mode
|
|
|
|
"," 'ess-smart-comma
|
|
|
|
"ss" 'ess-switch-to-inferior-or-script-buffer
|
|
|
|
;; predefined keymaps
|
|
|
|
"h" 'ess-doc-map
|
|
|
|
"r" 'ess-extra-map
|
|
|
|
"w" 'ess-r-package-dev-map
|
|
|
|
"d" 'ess-dev-map))
|
|
|
|
(define-key ess-mode-map (kbd "<s-return>") 'ess-eval-line)
|
|
|
|
(define-key inferior-ess-mode-map (kbd "C-j") 'comint-next-input)
|
|
|
|
(define-key inferior-ess-mode-map (kbd "C-k") 'comint-previous-input)))
|
|
|
|
|
|
|
|
(eval-after-load "ess-r-mode" spacemacs/ess-config)
|
|
|
|
(eval-after-load "ess-julia" spacemacs/ess-config)
|
2018-01-30 16:04:23 +00:00
|
|
|
|
|
|
|
;; xref integration added with #96ef5a6
|
2018-06-26 13:31:53 +00:00
|
|
|
(spacemacs|define-jump-handlers ess-mode 'xref-find-definitions))
|
|
|
|
|
|
|
|
(defun ess/init-ess-help ()
|
|
|
|
(evilified-state-evilify-map ess-help-mode-map))
|
2015-02-05 00:33:10 +00:00
|
|
|
|
2015-04-03 21:35:33 +00:00
|
|
|
(defun ess/init-ess-R-data-view ())
|
|
|
|
|
2015-02-05 00:33:10 +00:00
|
|
|
(defun ess/init-ess-smart-equals ()
|
2015-02-25 18:47:50 +00:00
|
|
|
(use-package ess-smart-equals
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2015-02-25 18:47:50 +00:00
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(add-hook 'ess-mode-hook 'ess-smart-equals-mode)
|
|
|
|
(add-hook 'inferior-ess-mode-hook 'ess-smart-equals-mode))))
|
2016-06-08 14:06:02 +00:00
|
|
|
|
|
|
|
(defun ess/pre-init-golden-ratio ()
|
|
|
|
(spacemacs|use-package-add-hook golden-ratio
|
|
|
|
:post-config
|
|
|
|
(dolist (f '(ess-eval-buffer-and-go
|
|
|
|
ess-eval-function-and-go
|
|
|
|
ess-eval-line-and-go))
|
|
|
|
(add-to-list 'golden-ratio-extra-commands f))))
|
2016-06-29 19:09:43 +00:00
|
|
|
|
|
|
|
(defun ess/pre-init-org ()
|
|
|
|
(spacemacs|use-package-add-hook org
|
|
|
|
:post-config (add-to-list 'org-babel-load-languages '(R . t))))
|