From b265984d17c6b59310d98ce725b429fe061c7dcb Mon Sep 17 00:00:00 2001 From: Lucius Hu Date: Thu, 18 Mar 2021 00:05:07 -0400 Subject: [PATCH] erlang: refactor - Moved backend determination to `config.el` - Replaced `pcase` form with only one-arm with `when` or `unless` form --- layers/+lang/erlang/config.el | 2 +- layers/+lang/erlang/funcs.el | 26 ++++++++------------------ 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/layers/+lang/erlang/config.el b/layers/+lang/erlang/config.el index 76c345295..d8c19c024 100644 --- a/layers/+lang/erlang/config.el +++ b/layers/+lang/erlang/config.el @@ -30,7 +30,7 @@ ;; lsp - erlang_ls -(defvar erlang-backend nil +(defvar erlang-backend (if (configuration-layer/layer-used-p 'lsp) 'lsp 'company-erlang) "The backend to use for IDE features. Possible values are `lsp' or `company-erlang'. If `nil' then `company-erlang' is the default backend unless `lsp' layer is used.") diff --git a/layers/+lang/erlang/funcs.el b/layers/+lang/erlang/funcs.el index 7377b8933..e6b8e616b 100644 --- a/layers/+lang/erlang/funcs.el +++ b/layers/+lang/erlang/funcs.el @@ -21,29 +21,19 @@ ;; along with this program. If not, see . -(defun spacemacs//erlang-backend () - "Returns selected backend." - (if erlang-backend - erlang-backend - (cond - ((configuration-layer/layer-used-p 'lsp) 'lsp) - (t 'company-erlang)))) - (defun spacemacs//erlang-setup-backend () "Conditionally setup erlang backend." - (pcase (spacemacs//erlang-backend) - (`lsp (spacemacs//erlang-setup-lsp))) - ) + (when (eq erlang-backend 'lsp) (spacemacs//erlang-setup-lsp))) (defun spacemacs//erlang-setup-company () "Conditionally setup company based on backend." - (pcase (spacemacs//erlang-backend) - ;; Activate lsp company explicitly to activate - ;; standard backends as well - (`lsp (spacemacs|add-company-backends - :backends company-capf - :modes erlang-mode - :append-hooks t)))) + ;; Activate lsp company explicitly to activate + ;; standard backends as well + (when (eq erlang-backend 'lsp) + (spacemacs|add-company-backends + :backends company-capf + :modes erlang-mode + :append-hooks t))) (defun spacemacs//erlang-setup-lsp () "Setup lsp backend."