ess: refactor

- Moved backend determination to `config.el`
This commit is contained in:
Lucius Hu 2021-03-18 00:07:30 -04:00 committed by duianto
parent b265984d17
commit a427fa10df
3 changed files with 6 additions and 13 deletions

View file

@ -25,7 +25,7 @@
;; Variables
(defvar ess-r-backend 'nil
(defvar ess-r-backend (if (configuration-layer/layer-used-p 'lsp) 'lsp 'ess)
"The backend to use for IDE features. Possible values are `ess' and `lsp'.")
(defvar ess-assign-key nil

View file

@ -24,16 +24,9 @@
;; R
(defun spacemacs//ess-r-backend ()
"Returns selected backend."
(if ess-r-backend
ess-r-backend
(cond ((configuration-layer/layer-used-p 'lsp) 'lsp)
(t 'ess))))
(defun spacemacs//ess-may-setup-r-lsp ()
"Conditionally setup LSP based on backend."
(when (eq (spacemacs//ess-r-backend) 'lsp)
(when (eq ess-r-backend 'lsp)
(spacemacs//ess-setup-r-lsp)))
(defun spacemacs//ess-setup-r-lsp ()
@ -56,8 +49,8 @@
"h" 'ess-doc-map ;; help
"d" 'ess-dev-map ;; debug
"D" 'ess-r-package-dev-map ;; devtools
"E" 'ess-extra-map ;; extra
))
"E" 'ess-extra-map)) ;; extra
(defun spacemacs//ess-bind-repl-keys-for-mode (mode)
"Set the REPL keys in MODE."

View file

@ -41,7 +41,7 @@
:modes inferior-ess-r-mode)
;; Set R company to lsp manually to include file completion
(unless (eq (spacemacs//ess-r-backend) 'lsp)
(unless (eq ess-r-backend 'lsp)
(spacemacs|add-company-backends
:backends (company-R-library company-R-args company-R-objects :separate)
:modes ess-r-mode)))
@ -99,7 +99,7 @@
(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)
(unless (eq 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