This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
spacemacs/layers/+lang/ess/packages.el

138 lines
4.8 KiB
EmacsLisp
Raw Normal View History

;;; packages.el --- ESS (R) Layer packages File for Spacemacs
;;
;; Copyright (c) 2012-2017 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
(setq ess-packages
'(
ess
ess-R-data-view
(ess-smart-equals :toggle ess-enable-smart-equals)
golden-ratio
org))
(defun ess/init-ess ()
(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)
("\\.jl\\'" . ess-julia-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))
:commands (R stata julia SAS)
:init
(progn
(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)
;; Explicitly run prog-mode hooks since ess-mode does not derive from
;; prog-mode major-mode
(add-hook 'ess-mode-hook 'spacemacs/run-prog-mode-hooks)
(add-hook 'inferior-ess-mode-hook
'spacemacs//ess-fix-read-only-inferior-ess-mode)
(when (configuration-layer/package-used-p 'company)
(add-hook 'ess-mode-hook 'company-mode))))
2014-11-11 03:27:06 +00:00
;; R --------------------------------------------------------------------------
(with-eval-after-load 'ess-site
;; 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))
(spacemacs/set-leader-keys-for-major-mode 'ess-julia-mode
"'" 'julia
"si" 'julia)
(spacemacs/set-leader-keys-for-major-mode 'ess-mode
2017-10-23 18:57:43 +00:00
"," 'ess-eval-region-or-function-or-paragraph-and-step
"'" 'spacemacs/ess-start-repl
"si" 'spacemacs/ess-start-repl
2017-10-23 18:57:43 +00:00
"ss" 'ess-switch-to-inferior-or-script-buffer
"sS" 'ess-switch-process
;; REPL
"sb" 'ess-eval-buffer-and-go
"eb" '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
"el" 'ess-eval-line
"sr" 'ess-eval-region-and-go
"er" 'ess-eval-region
"sf" 'ess-eval-function-and-go
"ef" 'ess-eval-function
;; ESS doc map
"h" 'ess-doc-map
"hh" 'ess-display-help-on-object
;; R helpers
"hp" 'ess-R-dv-pprint
"ht" 'ess-R-dv-ctable
"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
)
(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)))
2015-04-03 21:35:33 +00:00
(defun ess/init-ess-R-data-view ())
(defun ess/init-ess-smart-equals ()
(use-package ess-smart-equals
:defer t
:init
(progn
(add-hook 'ess-mode-hook 'ess-smart-equals-mode)
(add-hook 'inferior-ess-mode-hook 'ess-smart-equals-mode))))
(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))))