-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
[RFC] Implement type/call hierarchy handling #4221
Open
bstaletic
wants to merge
17
commits into
ycm-core:master
Choose a base branch
from
bstaletic:hierarchies
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This makes the popup disappear if you keep typing or enter inser mode or move the cursor etc. I found it jarring that previously it would just move the cursor behind the popup and such until you hit escape. Makes the popup more "modal" but without actually stopping you from continueing. Also: - Use simliar up/down keys as the symbol finder (c-p, c-k, c-n, c-j etc.) - SetupFoo -> SetUpFoo because the verb is "To set up" (rather than the noun "a setup". - purge barbaric 80+ character lines
We try to be a bit consistent with the finder poppup, but implementation-wise this is simpler. The idea is that there are 3 columns, each having 1/3 of the popup width. We fix the width of the popup (like we do for the finder) and set the tabstop to 1/3 of the internal width (core_width). Then when displaying text, we truncate "columnns" according to that tabstop (to avoid mess). To do this, we pass structured data from the python layer to vimscript and construct the line text there. This will also help later when we add in the syntax highlight (text properties) like we have for the finder popup.
This basically involves moving the properties mapping to its own place, and creating text properties to overlap the various parts of the popup columns. Style matches, and feels correct. Fiddly part is that we have to (for some reason) set cursorline every time we move the cursor, but ain't nobody gonna be able to explain why, and why that only necessary after launching the finder popup window once. Some wierd vim bug is my guess.
This makes the columns seem less broken, particularly for leading whitespace. This is particularly problematic due to our use of tabstop: if the leading whitespace was a tab, it would go nuts. It would still go nuts for any other literal tab in the description. Perhaps we should fix that too.
bstaletic
force-pushed
the
hierarchies
branch
3 times, most recently
from
May 17, 2024 04:16
7e16c1f
to
9d8d267
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Prelude
Thank you for working on YCM! :)
Please complete these steps and check these boxes (by putting an
x
insidethe brackets) before filing your PR:
rationale for why I haven't.
actually perform all of these steps.
Why this change is necessary and useful
This is the client side pull request related to ycm-core/ycmd#1733
Again, tests and documentations are missing. Documentation is the easy part, but tests would be dreadful...
popup look
I have not paid much attention to the look of the popup.
The look is slightly off - for deep hierarchies the location of references in the file (
foo.cpp:8
for example) becomes misaligned.The context is is not right aligned either.
Basically, it's functional but ugly. If someone would be up for it, please send patches my way.
How to use this thing?
The only publicly available function here is
youcompleteme#hierarchy#StartRequest( kind )
. It takes'call'
or'type'
as the argyment. From there, YCM will fire a "prepare hierarchy" request and then open a popup with the results.While the popup is open, the following keys are used:
<Tab>
to resolve a hierarchy item in the "subtypes" / "incoming" direction.<S-Tab>
to resolve a hierarchy item in the "supertypes"/"outgoing" direction.<Up>
/<Down>
to select items in the popup.<CR>
to jump to the selected item and close the popup.<Esc>
to close the popup without jumping.Maybe we want more key bindings here?
<C-n>
/<C-p>
andj
/k
come to mind...Oh yes, there's also
<plug>(YCMCallHierarchy)
and<plug>(YCMTypeHierarchy)
that just callyoucompletem#hierarchy#StartRequest()
. Users should be using these, instead of directly calling the function.This change is