Skip to content

Commit

Permalink
Set up xref-js2 in all the JS modes
Browse files Browse the repository at this point in the history
  • Loading branch information
purcell committed Aug 23, 2023
1 parent aa0d9d9 commit 97f5438
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lisp/init-javascript.el
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,21 @@
(sanityinc/major-mode-lighter 'js2-jsx-mode "JSX2"))



(require 'derived)
(when (and (or (executable-find "rg") (executable-find "ag"))
(maybe-require-package 'xref-js2))
(when (executable-find "rg")
(setq-default xref-js2-search-program 'rg))

(defun sanityinc/enable-xref-js2 ()
(add-hook 'xref-backend-functions #'xref-js2-xref-backend nil t))
(with-eval-after-load 'js
(define-key js-mode-map (kbd "M-.") nil)
(add-hook 'js-mode-hook 'sanityinc/enable-xref-js2))

(let ((base-mode (if (fboundp 'js-base-mode) 'js-base-mode 'js-mode)))
(with-eval-after-load 'js
(add-hook (derived-mode-hook-name base-mode) 'sanityinc/enable-xref-js2)
(define-key 'js-mode-map (kbd "M-.") nil)))
(with-eval-after-load 'js2-mode
(define-key js2-mode-map (kbd "M-.") nil)
(add-hook 'js2-mode-hook 'sanityinc/enable-xref-js2)))
(define-key js2-mode-map (kbd "M-.") nil))



Expand Down

0 comments on commit 97f5438

Please sign in to comment.