lang/javascript: conform to naming conventions; refactor tide config
This commit is contained in:
parent
8af94e8731
commit
cc5bfc6dc0
2 changed files with 25 additions and 25 deletions
|
@ -75,30 +75,18 @@ Run this for any buffer you want to skewer."
|
|||
(if skewer-html-mode (skewer-html-mode -1)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun add-node-modules-path ()
|
||||
(defun +javascript|add-node-modules-path ()
|
||||
"Search the current buffer's parent directories for `node_modules/.bin`.
|
||||
If it's found, then add it to the `exec-path'."
|
||||
(defvar add-node-modules-path-debug nil)
|
||||
(interactive)
|
||||
(let* ((root (locate-dominating-file
|
||||
(or (buffer-file-name) default-directory)
|
||||
"node_modules"))
|
||||
(path (and root
|
||||
(expand-file-name "node_modules/.bin/" root))))
|
||||
(if root
|
||||
(progn
|
||||
(make-local-variable 'exec-path)
|
||||
(add-to-list 'exec-path path)
|
||||
(when add-node-modules-path-debug
|
||||
(message (concat "added " path " to exec-path"))))
|
||||
(when add-node-modules-path-debug
|
||||
(message (concat "node_modules not found in " root))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun set-up-tide-mode ()
|
||||
(interactive)
|
||||
(tide-setup)
|
||||
(if company-mode (push 'company-tide company-backends))
|
||||
(eldoc-mode +1)
|
||||
(tide-hl-identifier-mode +1)
|
||||
)
|
||||
(if-let* ((root (locate-dominating-file
|
||||
(or (buffer-file-name) default-directory)
|
||||
"node_modules"))
|
||||
(path (expand-file-name "node_modules/.bin/" root)))
|
||||
(progn
|
||||
(make-local-variable 'exec-path)
|
||||
(cl-pushnew path exec-path :test #'string=)
|
||||
(when doom-debug-mode
|
||||
(message "Added %s to exec-path" path)))
|
||||
(when doom-debug-mode
|
||||
(message "node_modules not found in %s" root))))
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
js2-mode-show-parse-errors nil
|
||||
js2-mode-show-strict-warnings nil)
|
||||
|
||||
(add-hook! 'js2-mode-hook #'(flycheck-mode set-up-tide-mode add-node-modules-path rainbow-delimiters-mode))
|
||||
(add-hook! 'js2-mode-hook
|
||||
#'(flycheck-mode rainbow-delimiters-mode +javascript|add-node-modules-path))
|
||||
|
||||
(set! :repl 'js2-mode #'+javascript/repl)
|
||||
(set! :electric 'js2-mode :chars '(?\} ?\) ?.))
|
||||
|
@ -45,6 +46,17 @@
|
|||
:n "S" #'+javascript/skewer-this-buffer))
|
||||
|
||||
|
||||
(def-package! tide
|
||||
:hook (js2-mode . tide-setup)
|
||||
:config
|
||||
(set! :company 'js2-mode 'company-tide)
|
||||
(set! :lookup 'js2-mode
|
||||
:definition #'tide-jump-to-definition
|
||||
:references #'tide-references
|
||||
:documentation #'tide-documentation-at-point)
|
||||
(add-hook! 'tide-mode-hook #'(eldoc-mode tide-hl-identifier-mode)))
|
||||
|
||||
|
||||
;; A find-{definition,references} backend for js2-mode. NOTE The xref API is
|
||||
;; unstable and may break with an Emacs update.
|
||||
(def-package! xref-js2
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue