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

127 lines
4.4 KiB
EmacsLisp
Raw Normal View History

;;; packages.el --- ESS (R) Layer packages File for Spacemacs
;;
2018-01-04 07:00:25 +00:00
;; Copyright (c) 2012-2018 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
(defconst ess-packages
'(
company
flycheck
ess
ess-R-data-view
golden-ratio
org))
(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)
: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)))
(defun ess/post-init-flycheck ()
(spacemacs/enable-flycheck 'ess-r-mode))
(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)
("\\.[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)
:init
(progn
(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)
;; add support for evil states
(evil-set-initial-state 'ess-help-mode 'motion)
2019-01-14 10:25:22 +00:00
(spacemacs/register-repl 'ess-site #'spacemacs/ess-start-repl)
(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
(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))
(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
(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))))