2015-01-14 04:12:56 +00:00
|
|
|
;;; packages.el --- ESS (R) Layer packages File for Spacemacs
|
|
|
|
;;
|
|
|
|
;; Copyright (c) 2012-2014 Sylvain Benner
|
|
|
|
;; Copyright (c) 2014-2015 Sylvain Benner & Contributors
|
|
|
|
;;
|
|
|
|
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
|
|
|
;;; License: GPLv3
|
|
|
|
|
2014-11-11 03:27:06 +00:00
|
|
|
(defvar ess-packages
|
|
|
|
'(
|
|
|
|
ess
|
|
|
|
ess-R-data-view
|
|
|
|
ess-R-object-popup
|
2015-03-02 23:37:34 +00:00
|
|
|
ess-smart-equals
|
2015-02-05 00:33:10 +00:00
|
|
|
rainbow-delimiters
|
2014-11-11 03:27:06 +00:00
|
|
|
)
|
|
|
|
"List of all packages to install and/or initialize. Built-in packages
|
|
|
|
which require an initialization must be listed explicitly in the list.")
|
|
|
|
|
2014-11-12 04:02:50 +00:00
|
|
|
(defvar ess-excluded-packages '()
|
|
|
|
"List of packages to exclude.")
|
|
|
|
|
2015-02-10 15:13:51 +00:00
|
|
|
;; Only load company-ess if company-mode is enabled
|
2015-02-11 04:23:33 +00:00
|
|
|
(when (configuration-layer/layer-declaredp 'company-mode)
|
2015-02-10 15:13:51 +00:00
|
|
|
(add-to-list 'ess-packages 'company-ess))
|
|
|
|
|
2014-11-11 05:08:23 +00:00
|
|
|
(defun ess/init-ess ()
|
2014-11-11 03:27:06 +00:00
|
|
|
;; ESS is not quick to load so we just load it when
|
|
|
|
;; we need it (see my-keybindings.el for the associated
|
|
|
|
;; keybinding)
|
|
|
|
(defun load-ess-on-demand ()
|
|
|
|
(interactive)
|
2015-02-05 16:09:21 +00:00
|
|
|
(-all? '---truthy? (list
|
|
|
|
(use-package ess-site)
|
|
|
|
(use-package ess-R-object-popup)
|
|
|
|
(use-package ess-R-data-view))))
|
|
|
|
|
2014-11-11 03:27:06 +00:00
|
|
|
(evil-leader/set-key "ess" 'load-ess-on-demand)
|
|
|
|
|
2015-02-05 16:09:21 +00:00
|
|
|
(use-package ess
|
|
|
|
:defer t
|
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(setq auto-mode-alist (append
|
|
|
|
'(("\\.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))
|
|
|
|
auto-mode-alist))
|
|
|
|
|
|
|
|
(defun ess/auto-load-hack (mode-symbol)
|
|
|
|
(eval
|
|
|
|
`(defun ,mode-symbol ()
|
|
|
|
"This is a function that will hijack itself with its
|
|
|
|
definition from ess. The reason this exists is that ess does
|
|
|
|
not play nicely with autoloads"
|
|
|
|
(when (load-ess-on-demand)
|
|
|
|
(,mode-symbol)))))
|
|
|
|
|
|
|
|
(defvar ess/r-modes-list '(R-mode R-transcript-mode Rd-mode Rnw-mode S-mode S-transcript-mode
|
|
|
|
SAS-mode STA-mode Snw-mode XLS-mode ess-bugs-mode ess-jags-mode omegahat-mode)
|
|
|
|
"This is the list of modes defined by ess")
|
|
|
|
|
|
|
|
(mapc (lambda (sym) (ess/auto-load-hack sym)) ess/r-modes-list)))
|
|
|
|
|
2014-11-11 03:27:06 +00:00
|
|
|
;; R --------------------------------------------------------------------------
|
|
|
|
(eval-after-load "ess-site"
|
|
|
|
'(progn
|
2015-02-05 00:33:10 +00:00
|
|
|
(add-to-list 'auto-mode-alist '("\\.R$" . R-mode))
|
|
|
|
;; 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)
|
2014-11-11 03:27:06 +00:00
|
|
|
(evil-leader/set-key-for-mode 'ess-mode
|
2015-02-18 03:08:58 +00:00
|
|
|
"msi" 'R
|
2015-01-31 03:18:30 +00:00
|
|
|
;; noweb
|
2015-01-29 02:43:17 +00:00
|
|
|
"mcC" 'ess-eval-chunk-and-go
|
|
|
|
"mcc" 'ess-eval-chunk
|
|
|
|
"mcd" 'ess-eval-chunk-and-step
|
|
|
|
"mcm" 'ess-noweb-mark-chunk
|
|
|
|
"mcN" 'ess-noweb-previous-chunk
|
|
|
|
"mcn" 'ess-noweb-next-chunk
|
2015-01-31 03:18:30 +00:00
|
|
|
;; helpers
|
|
|
|
"mhd" 'ess-R-dv-pprint
|
|
|
|
"mhi" 'ess-R-object-popup
|
|
|
|
"mht" 'ess-R-dv-ctable
|
|
|
|
;; REPL
|
|
|
|
"msB" 'ess-eval-buffer-and-go
|
|
|
|
"msb" 'ess-eval-buffer
|
|
|
|
"msD" 'ess-eval-function-or-paragraph-and-step
|
|
|
|
"msd" 'ess-eval-region-or-line-and-step
|
|
|
|
"msL" 'ess-eval-line-and-go
|
|
|
|
"msl" 'ess-eval-line
|
|
|
|
"msR" 'ess-eval-region-and-go
|
|
|
|
"msr" 'ess-eval-region
|
|
|
|
"msT" 'ess-eval-function-and-go
|
|
|
|
"mst" 'ess-eval-function
|
2014-11-11 03:27:06 +00:00
|
|
|
)
|
2015-02-05 00:33:10 +00:00
|
|
|
(define-key ess-mode-map (kbd "<s-return>") 'ess-eval-line)
|
2014-11-11 03:27:06 +00:00
|
|
|
(define-key inferior-ess-mode-map (kbd "C-j") 'comint-next-input)
|
|
|
|
(define-key inferior-ess-mode-map (kbd "C-k") 'comint-previous-input))))
|
2015-02-05 00:33:10 +00:00
|
|
|
|
2015-03-20 15:57:54 +00:00
|
|
|
(defun ess/init-ess-R-data-view ())
|
|
|
|
|
|
|
|
(defun ess/init-ess-R-object-popup ())
|
|
|
|
|
2015-02-05 00:33:10 +00:00
|
|
|
(defun ess/init-rainbow-delimiters ()
|
|
|
|
(add-hook 'ess-mode-hook #'rainbow-delimiters-mode))
|
|
|
|
|
|
|
|
(defun ess/init-ess-smart-equals ()
|
2015-02-25 18:47:50 +00:00
|
|
|
(use-package ess-smart-equals
|
|
|
|
:defer t
|
|
|
|
:if ess-enable-smart-equals
|
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(add-hook 'ess-mode-hook 'ess-smart-equals-mode)
|
|
|
|
(add-hook 'inferior-ess-mode-hook 'ess-smart-equals-mode))))
|
2015-02-10 15:13:51 +00:00
|
|
|
|
|
|
|
(defun ess/init-company-ess ()
|
|
|
|
(use-package company-ess
|
2015-03-22 06:23:12 +00:00
|
|
|
:if (configuration-layer/package-declaredp 'company)
|
2015-02-10 15:13:51 +00:00
|
|
|
:defer t
|
|
|
|
:init
|
2015-03-22 06:23:12 +00:00
|
|
|
(progn
|
|
|
|
(spacemacs|reset-local-company-backends ess-mode)
|
|
|
|
(defun spacemacs//ess-company-backend ()
|
|
|
|
"Add ESS company backend."
|
|
|
|
(push (spacemacs/company-backend-with-yas 'company-ess-backend)
|
|
|
|
company-backends))
|
|
|
|
(add-hook 'ess-mode-hook 'spacemacs//ess-company-backend t))))
|