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
|
|
|
|
|
2020-02-08 08:57:21 +00:00
|
|
|
(defconst ess-packages
|
|
|
|
'(
|
|
|
|
company
|
|
|
|
flycheck
|
|
|
|
ess
|
|
|
|
ess-R-data-view
|
|
|
|
golden-ratio
|
|
|
|
org))
|
2014-11-12 04:02:50 +00:00
|
|
|
|
2019-11-12 02:50:37 +00:00
|
|
|
(defun ess/post-init-company ()
|
|
|
|
;; Julia
|
|
|
|
(spacemacs|add-company-backends
|
|
|
|
:backends company-ess-julia-objects
|
|
|
|
:modes ess-julia-mode inferior-ess-julia-mode)
|
|
|
|
;; R
|
|
|
|
(spacemacs|add-company-backends
|
|
|
|
:backends (company-R-library company-R-args company-R-objects :separate)
|
2020-02-08 08:57:21 +00:00
|
|
|
:modes inferior-ess-r-mode)
|
|
|
|
|
|
|
|
;; Set R company to lsp manually to include file completion
|
|
|
|
(if (eq (spacemacs//ess-r-backend) 'lsp)
|
|
|
|
(spacemacs|add-company-backends
|
|
|
|
:backends company-lsp
|
|
|
|
:modes ess-r-mode)
|
|
|
|
(spacemacs|add-company-backends
|
|
|
|
:backends (company-R-library company-R-args company-R-objects :separate)
|
|
|
|
:modes ess-r-mode)))
|
2019-11-12 02:50:37 +00:00
|
|
|
|
|
|
|
(defun ess/post-init-flycheck ()
|
|
|
|
(spacemacs/enable-flycheck 'ess-r-mode))
|
|
|
|
|
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
|
2019-11-12 02:50:37 +00:00
|
|
|
(setq ess-use-company nil
|
|
|
|
;; Follow Hadley Wickham's R style guide
|
|
|
|
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)
|
2015-02-05 16:09:21 +00:00
|
|
|
|
2019-11-12 02:50:37 +00:00
|
|
|
;; add support for evil states
|
|
|
|
(evil-set-initial-state 'ess-help-mode 'motion)
|
2019-01-14 10:25:22 +00:00
|
|
|
|
2019-11-12 02:50:37 +00:00
|
|
|
(spacemacs/register-repl 'ess-site #'spacemacs/ess-start-repl)
|
2015-10-14 14:52:26 +00:00
|
|
|
|
2019-11-12 02:50:37 +00:00
|
|
|
(add-hook 'ess-r-mode-hook #'spacemacs//ess-may-setup-r-lsp)
|
|
|
|
(add-hook 'inferior-ess-mode-hook
|
|
|
|
'spacemacs//ess-fix-read-only-inferior-ess-mode)
|
2018-06-26 13:31:53 +00:00
|
|
|
|
2019-11-12 02:50:37 +00:00
|
|
|
(with-eval-after-load 'ess-julia
|
|
|
|
(spacemacs/ess-bind-keys-for-julia))
|
|
|
|
(with-eval-after-load 'ess-r-mode
|
|
|
|
(spacemacs/ess-bind-keys-for-r)
|
|
|
|
(unless (eq (spacemacs//ess-r-backend) 'lsp)
|
|
|
|
(spacemacs/declare-prefix-for-mode 'ess-r-mode "mg" "goto")
|
|
|
|
(define-key ess-doc-map "h" #'ess-display-help-on-object)))
|
|
|
|
(with-eval-after-load 'ess-inf-mode
|
|
|
|
(spacemacs/ess-bind-keys-for-inferior)))
|
|
|
|
:config
|
|
|
|
(define-key ess-mode-map (kbd "<s-return>") #'ess-eval-line))
|
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))
|
|
|
|
|
2019-11-12 02:50:37 +00:00
|
|
|
(defun ess/init-ess-R-data-view ()
|
|
|
|
(use-package ess-R-data-view
|
|
|
|
:defer t
|
|
|
|
:config
|
|
|
|
(dolist (mode '(ess-julia-mode ess-r-mode inferior-ess-mode))
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode mode
|
|
|
|
"hp" #'ess-R-dv-pprint
|
|
|
|
"ht" #'ess-R-dv-ctable))))
|
2015-04-03 21:35:33 +00:00
|
|
|
|
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))))
|