Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Visit tags table" prompt on jumping to definition? #11

Open
dbarros opened this issue Oct 13, 2017 · 5 comments
Open

"Visit tags table" prompt on jumping to definition? #11

dbarros opened this issue Oct 13, 2017 · 5 comments

Comments

@dbarros
Copy link

dbarros commented Oct 13, 2017

When I press the bound M-. to jump to a definition, I am prompted with:

Visit tags table (default TAGS): ~/projects/app/

I've double-checked the installation requirements, but am not able to avoid this prompt. Is there something you can recommend I try?

@TatriX
Copy link
Contributor

TatriX commented Oct 13, 2017

First try using AST of the js2-mode. If it fails, fall back to xref.

(defun my-js-jump-to-definition ()
  "Jump to a definition."
  (interactive)
  ;; (tern-find-definition)
  (condition-case-unless-debug nil
      (js2-jump-to-definition)
    (error
     (xref-pop-marker-stack)
     (xref-find-definitions (xref-backend-identifier-at-point (xref-find-backend))))))



(define-key js2-mode-map (kbd "M-.") #'my-js-jump-to-definition)
(add-hook 'xref-backend-functions #'xref-js2-xref-backend nil t)

@NicolasPetton
Copy link
Collaborator

You should set the xref backend in js2 buffers:

(add-hook 'js2-mode-hook (lambda ()
  (add-hook 'xref-backend-functions #'xref-js2-xref-backend nil t)))

@NicolasPetton
Copy link
Collaborator

@dbarros are you using js2 and Emacs >= 25.1?

@dbarros
Copy link
Author

dbarros commented Oct 14, 2017

@NicolasPetton Yes, I have js2 and Emacs 25.2

@NicolasPetton
Copy link
Collaborator

NicolasPetton commented Oct 16, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants