javascript: add default value for tern-command and remove toggle
Since now we support multiple backends, the toggle based on tern executable seems not necessary anymore.
This commit is contained in:
parent
70c1737c44
commit
f9968bf326
3 changed files with 16 additions and 18 deletions
|
@ -19,3 +19,6 @@
|
|||
(defvar javascript-backend 'tern
|
||||
"The backend to use for IDE features. Possible values are `tern'
|
||||
and `lsp'.")
|
||||
|
||||
(defvar tern-command nil
|
||||
"Path to the tern server. Used when `javascript-backend' is set to `tern'.")
|
||||
|
|
|
@ -100,19 +100,21 @@
|
|||
|
||||
(defun spacemacs//javascript-setup-tern ()
|
||||
"Setup tern backend."
|
||||
(add-hook 'js2-mode-hook 'tern-mode)
|
||||
(progn
|
||||
(spacemacs|hide-lighter tern-mode)
|
||||
(when javascript-disable-tern-port-files
|
||||
(add-to-list 'tern-command "--no-port-file" 'append))
|
||||
(spacemacs//set-tern-key-bindings 'js2-mode)))
|
||||
(when tern-command
|
||||
(add-hook 'js2-mode-hook 'tern-mode)
|
||||
(progn
|
||||
(spacemacs|hide-lighter tern-mode)
|
||||
(when javascript-disable-tern-port-files
|
||||
(add-to-list 'tern-command "--no-port-file" 'append))
|
||||
(spacemacs//set-tern-key-bindings 'js2-mode))))
|
||||
|
||||
(defun spacemacs//javascript-setup-tern-company ()
|
||||
"Setup tern auto-completion."
|
||||
(spacemacs|add-company-backends
|
||||
:backends company-tern
|
||||
:modes js2-mode)
|
||||
(company-mode))
|
||||
(when tern-command
|
||||
(spacemacs|add-company-backends
|
||||
:backends company-tern
|
||||
:modes js2-mode)
|
||||
(company-mode)))
|
||||
|
||||
(defun spacemacs//set-tern-key-bindings (mode)
|
||||
"Set the key bindings for tern and the given MODE."
|
||||
|
@ -125,13 +127,6 @@
|
|||
(kbd "C-g") 'tern-pop-find-definition
|
||||
"ht" 'tern-get-type))
|
||||
|
||||
(defun spacemacs//tern-detect ()
|
||||
"Detect tern binary and warn if not found."
|
||||
(let ((found (executable-find "tern")))
|
||||
(unless found
|
||||
(spacemacs-buffer/warning "tern binary not found!"))
|
||||
found))
|
||||
|
||||
|
||||
;; lsp
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
js2-refactor
|
||||
json-mode
|
||||
json-snatcher
|
||||
(tern :toggle (spacemacs//tern-detect))
|
||||
tern
|
||||
web-beautify
|
||||
skewer-mode
|
||||
livid-mode
|
||||
|
|
Reference in a new issue