-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Refactor jump to definition #6815
Conversation
Note, with this is it potentially possible to make gtags work automatically in all modes that use spacemacs|define-jump-handlers without listing the package everywhere. I haven't done that here. |
Another option would be to use the new xref functions from 25 and create xref backends for the jumpers. |
That looks promising, but we can't drop support for 24 for a good while yet. I assume we will also need to wait for upstream jumpers to integrate with xref. |
(add-hook 'spacemacs-jump-handlers-c++-mode 'ycmd-goto) | ||
(add-hook 'spacemacs-jump-handlers-c-mode 'ycmd-goto) | ||
(dolist (mode '(c++-mode c-mode)) | ||
(spacemacs/set-leader-keys-for-major-mode 'c++-mode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this not be a dolist
, or should it be mode
instead of 'c++-mode
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be a dolist, I just messed up the mode.
I have been using this for a few days now and I'm quite happy with it. If there are no complaints I might just merge it soon. |
ef70502
to
39ba4cf
Compare
This commit defines: - spacemacs-default-jump-handlers: a list of functions that can jump to definition in ALL modes. - spacemacs-jump-handlers-MODE: a list of functions that can jump to definition in MODE. - spacemacs-jump-handlers: a buffer-local list of functions that can jump to definition. This is made up of the values of the two previous variables whenever a given major mode is activated. - spacemacs/jump-to-definition: a function that tries each function in spacemacs-jump-handlers in order, and stops when one of them takes us somewhere new. - spacemacs|define-jump-handlers: a macro that * defines spacemacs-jump-handlers-MODE, possibly filled with initial functions * defines a function that is added to the hook of the given MODE * binds “SPC m g g” of that MODE to spacemacs/jump-to-definition This is an attempt to harmonize all the different approaches to jumping. Specifically, - Existing intelligent jump packages that work for only a single mode should go to the beginning of spacemacs-jump-handlers-MODE. E.g. anaconda for python, ensime for scala, etc. - Packages like gtags that work for several modes (but potentially not all) and which is dumber than the intelligent jumpers should go the the END of spacemacs-jump-handlers-MODE. - Packages like dumb-jump that work for all modes should go to spacemacs-default-jump-handlers. In all cases the order of the jump handlers in each list should be from most to least intelligent. Fixes syl20bnr#6619
Merged. |
According to discussion with @syl20bnr.
This commit defines:
definition in ALL modes.
definition in MODE.
jump to definition. This is made up of the values of the two previous
variables whenever a given major mode is activated.
spacemacs-jump-handlers in order, and stops when one of them takes us
somewhere new.
functions
This is an attempt to harmonize all the different approaches to jumping.
Specifically,
should go to the beginning of spacemacs-jump-handlers-MODE. E.g.
anaconda for python, ensime for scala, etc.
all) and which is dumber than the intelligent jumpers should go the
the END of spacemacs-jump-handlers-MODE.
spacemacs-default-jump-handlers.
In all cases the order of the jump handlers in each list should be from
most to least intelligent.
Fixes #6619, and to some degree supersedes #6164 (CC @axyz re: dumb-jump)