erlang: refactor
- Moved backend determination to `config.el` - Replaced `pcase` form with only one-arm with `when` or `unless` form
This commit is contained in:
parent
f126f3e093
commit
b265984d17
2 changed files with 9 additions and 19 deletions
|
@ -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.")
|
||||
|
|
|
@ -21,29 +21,19 @@
|
|||
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
(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."
|
||||
|
|
Reference in a new issue