purcell / emacs.d

An Emacs configuration bundle with batteries included
BSD 2-Clause "Simplified" License
6.82k stars 2.04k forks source link

Enable xref-js2 in js-ts-mode #850

Closed archer-n closed 7 months ago

purcell commented 11 months ago

I pushed my version of this change in master, let me know if it looks okay to you.

archer-n commented 7 months ago

I pushed my version of this change in master, let me know if it looks okay to you.

He doesn't fix the problem, because js-ts-mode-map is copied from js-mode-map rather than inherited, so just modifying js-mode-map is invalid.

(defvar js-ts-mode-map (copy-keymap js-mode-map)
  "Keymap used in `js-ts-mode'.")

I think this could work:

(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)
+    (define-key js-ts-mode-map (kbd "M-.") nil)
))

But there is another good news. In the emacs master branch, the commit Remove 'M-.' binding from js-mode and js-ts-mode has deleted this keybind.

purcell commented 7 months ago

Thanks. I committed a further fix here anyway.