-
-
Notifications
You must be signed in to change notification settings - Fork 226
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
YouCompleteMe-style tab completion? #526
Comments
Hi Val, I'm glad you're happy with company-mode overall. Thanks for the great explanation; we've discussed this before in the issue #343, and there's a gist linked there that implements this, albeit in a not very clean fashion. |
Here's the gist for reference: https://gist.github.com/aaronjensen/a46f88dbd1ab9bb3aa22 I haven't had time to pull request it properly. It has been working well for me, however. |
There's still work to do on the design here. In particular:
|
I would guess that this would negatively impact the UX unless we could do something like the
Agreed, though from what I could tell, it was the only way I knew how to get this working with the current code. |
We would. Hence "two new frontends".
It causes complexity. I don't see why we'd want to do that. You can't press
Advising the frontends would only change the display. Do any of the frontends call The "no selection" would be indicated by a new boolean variable. |
Not giving up on this request, but in the meantime you could try out the recipe at the bottom of https://github.com/company-mode/company-mode/wiki/Switching-from-AC. |
@dgutov
|
@sickHamm Sorry, this doesn't look like a good approach, even if it works for now. Frontends aren't supposed to change anything, they're only for visualization.
Yes. But no more than calling private methods, I suppose. |
Any possible reason whey the gist by @aaronjensen does not work in Spacemacs? |
@sergei-dyshel it works for me. Here's the most up to date version: https://github.com/aaronjensen/spacemacs.d/blob/master/lisp/company-simple-complete.el I require it in user-config https://github.com/aaronjensen/spacemacs.d/blob/master/init.el#L397 |
I see. My problem was that I required it outside of |
Thank you Aaron and Valloric! I moved from Vim to Spacemacs about 6 months ago, and YouCompleteMe TAB key behavior was the one thing I've been missing. Countless times I'd be at the end of a line typing something like |
Hi everyone, I implemented this completion style as a frontend that doesn't modify the buffer during completion and with minimal advice on the internal rendering code. The frontend creates an overlay at point and updates it every time company selection is updated to make it look as if the text is already inserted into the buffer. It uses https://gist.github.com/nikital/0362abcaf003f2b81f0d0f9bda7be1f8 I hope that you will find this useful :) @dgutov, what do you think about the gist? Would you consider this design clean enough to integrate into company-mode? If yes I can make it into a pull request and if no I'm open for critique. |
@nikital nice! I definitely like the overlay. One of the things it's missing from my implementation is the ability to abort--tab and then shift-tab would result in nothing selected. Of course, that's where most of the advice I added comes in, so it may not be easy w/o more advice. |
@aaronjensen If I understood the behavior you describe correctly, it is very easy to implement. I updated the gist with the new behavior. Now pressing shift-tab when standing on the first entry will deselect it. https://gist.github.com/nikital/0362abcaf003f2b81f0d0f9bda7be1f8 The diff is pretty small and has no design changes: https://gist.github.com/nikital/0362abcaf003f2b81f0d0f9bda7be1f8/revisions?diff=split |
@nikital great, that seems to work for me. I'll keep giving it a shot and let you know if I run into anything else. One thing is I believe this is required too: (evil-declare-ignore-repeat 'company-select-previous-then-none) |
@aaronjensen Oops, correct, fixed. Thanks for testing it out :) |
@nikital It's a clean, clever hack, but the resulting frontend is not a "proper" frontend anyway, with how it's doing a lot of stuff other than visualization. But I think you can release this as a separate package. I'll try not to break it unnecessarily. |
@dgutov Out of curiosity, do you see a path to this being a core capability within company-mode? It's fine if not, it just seems there is a decent amount of interest in it and it would be nice for it to be supported w/o need for advice and as a "proper" frontend. |
I'd like for it to be supported, but the way to do it is not obvious. Maybe some new extensibility surface, alongside backends and frontends? Nothing concrete. As long as you have to rebind several key combinations yourself, as a user, it won't look like a "core capability" to me anyway. I think we can do away with the necessity to use an advice, though, by using |
Could it be a flag that changed the behavior of It does seem like it's still more of a "recipe" than anything, but I don't necessarily see anything wrong w/ that. |
Maybe you're right. We certainly have some other optional commands that users can bind in the active keymap at their preference. So I have two main concerns:
|
Could you expand on this? From a purely usage standpoint, I see it as a version of
I'm totally fine with that. I think I'd prefer them to be a separate, cohesive group of things than having to add more codepaths to existing commands. Some name ideas:
It's probably going to be hard to capture the behavior w/ the name, but I'm sure there are many out there better at naming than I. |
That's not how this term is used in this package. See the first sentence in
Rather, the fact that calling Advising
Let's wait for those people. 😃 |
Just dropping in to say thanks to the guys working on this. It works nicely. |
Yep, thanks! YouCompleteMe style completion is what I did really miss in emacs. |
How about Or |
OK, I think any of these names is fine. @nikital Will your sign the copyright assignment papers for Emacs? This is necessary for contributing to this package. The instructions are here: http://orgmode.org/cgit.cgi/org-mode.git/plain/request-assign-future.txt |
Yes I can sign the copyright assignment, but first I want to spend a few more evenings to think about a better solution that won't involve calling |
I'm not sure this is the best use of your time, but please do as you see fit. There are options, like using Other things to consider:
Please pick one the subpackage name, and put the code in a file with that name, as well as prefix the function names with it. These options sound best to me, unless you have a different idea:
Also note that I'll only merge the PR after the assignment is complete. |
It's because of the order of the hooks. Evil implements repeat by installing global
Currently the only code path inside Company that will trigger completion from a hook is When we call |
So evil-repeat doesn't work with What if the code in your frontend added a new item to |
It does work, because
I don't like it because it would really complicate the code (with adding, removing and enforcing order of hooks), with the only benefit I see is easier Evil integration later on. If we want to make Evil integration easier, it's better to make it explicit. If we don't care about Evil integration, it's better to keep Company clean and separately figure out how to integrate repeat on Evil's side. However, I came up with a way to avoid directly calling
The diff is here: https://gist.github.com/nikital/0362abcaf003f2b81f0d0f9bda7be1f8/revisions The benefit of this approach is that it runs What do you think about this? |
I see, thanks. But! The idea behind So I imagine your code could use Or even: couldn't you simply set
Yes, but we'd want to make it possible at least, I believe.
Not sure I understand. Are you setting Does the documentation say anything about this particular usage? You are allowed to change |
Unfortunately, no. This would be the cleanest solution and it was the first thing I tried. But because
If we call
I couldn't find anything in the documentation about this pattern, but looking through Emacs' source code, it seems to be a known pattern:
|
OK.
Curious. It still might change (since it's undocumented), but the odds seem small. So go ahead. |
Closing, having merged #706. If it's not enough somehow, please describe why. |
Hi! |
NVM, I figured it out.
|
I'm sorry, I understand that this was meant to be used with the tooltip stytle of completion. |
Hi!
As soon as the completion text is "inserted", you don't get to type more. Any subsequent character keypress is taken to mean you are finished and typing code for after it is inserted. I believe that is the YouCompleteMe workflow anyway.
I guess you wanted something else than |
[Full disclosure: I'm the author of YCM so I'm biased. :)]
I've been trying out emacs lately to see can I replicate my uber-customized Vim setup on the dark side :). I'm using company-mode with emacs-ycmd and it's great! Thanks for making company-mode awesome and for continuing to maintain it; OSS dev work is often thankless.
Other than one missing feature, company-mode is doing everything I want it to do.
The best way to describe the feature is with the following gif. (Wait until the part where
LongestCommonSubsequenceLength
is being completed.)In the gif, only tab is being used, nothing else (no enter).
In YCM, tab is used to both select a completion candidate from the list and to insert it in the buffer. So the user types and gets completions. Pressing tab selects the first item in the completion menu and inserts it in the buffer. Pressing tab again selects the second item and replaces the inserted item with the second one. This can continue as long as the user wishes to cycle through the menu.
The benefits are the following:
Any chance company-mode can get an option of some sort to behave like this? Something like
complete-and-cycle
forauto-completion-tab-key-behavior
. It would be greatly appreciated, if for any reason then to lessen the cognitive load on those Vim users using Emacs.The text was updated successfully, but these errors were encountered: