-
Notifications
You must be signed in to change notification settings - Fork 43
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
Suggestions for empty line. #5
Comments
This is part of cmp. I believe cmp has a controllable number of characters required to trigger completion. Setting that to 0 may give you what you want, but there's nothing I can do on my end to force them to appear unless @hrsh7th knows something about this I am unaware of. |
This is awesome plugin, but sorry for reopening this issue, as this in the main patern I use copilot as. |
I did some testing. I set a hotkey to trigger copilot completions and tested it with no content on the line. The completion function triggers, but copilot returns no completions. Are you certain that copilot does this? If i type a comment character copilot completes comments fine. I guess I may be able to spoof a comment char on an empty line, but that seems weird. |
Yes, it does. For example: https://youtu.be/FL70Locz6oY?t=299 |
I'll look into this. It may take a bit though. |
@vishfrnds Quick update on this. The other day I actually managed to get copilot to get a completion on a newline, but cmp refused to show it, stating something along the lines of 'no prior character to complete' even when I try to manually trigger the menu. I think that this functionality is just incompatible with the way cmp is written. Unfortunately this is just an upstream problem I don't really have control over. I am debating attempting to make a somewhat sizable PR to cmp which would fix this, but due to the scope of what is involved it would likely sit in the development branch for ages if it gets merged at all. I'll try digging into it at some point and see if there isn't an easier way, but I really wouldn't get your hopes up. I am working on a few mechanical things that would make this type of feature work more smoothly which will be part of a rather sizable update coming soon:tm: but I think that for the time being getting this to integrate with cmp like the other results do is simply unrealistic. I'll continue to leave this open so that I can address it with the solution once said update is out, and I will probably put it in the docs as well. As for the example implementations, I am happy to take input. Currently I was thinking that I would create a preview window triggerable by some command with selections and code previews. Edit: Sorry if this notifies someone who saw it on a different thread, I was on mobile and posted this comment to the wrong one a bit ago... |
@zbirenbaum I was just wondering: have you figured out what was preventing copilot from creating the suggestions? From my usage I see that the popup with completion appears and then if "refreshes" with copilot completions. What's preventing this from happening on new line? |
I'm a bit confused here. You should definitely not have any problems with completions appearing. If you are, you should check your node version. For empty lines, that's more of a cmp issue than anything. Cmp requires a prefix to trigger a completion. I got it working at one point, but it was rough because pressing tab which I think most people use to navigate completions could no longer indent. |
I have no problems with completions appearing, I was just wondering why it cannot be done with an empty line. |
Hello, I have had some time to try and tackle this issue. I think something odd may happen when calling -- line: 66, completion_functions.lua
callback(format_completions({}, params.context, self.formatters)) Commenting this line gives the following example result (the completion is triggered immediately on the blank line): @zbirenbaum I understand the point of the callback with the empty collections, but is there a way to go around this? |
@zbirenbaum @vishfrnds deleting the line mentioned by @lpoto it worked for me |
Closing since this is implemented |
Hi I see that the last comment with fix was in February and it seems that the code in Edit: OK I found that on empty lines (e.g. right after a comment line) I could get the complete menu containing Copilot suggestions to show up by typing a |
Still having this issue. I have no suggestions on start of a blank line. |
Could you post your config? |
@jiriks74 I have it added and it works in cases. When I type some symbols.
|
Please use ``` to create a codeblock and <details> to hide the code until clicked (you can copy-paste from below): <details> ``` </details> |
@Zik42 |
this works for me, but it's somewhat annoying because for me it actually breaks indentation (astronvim), confusingly, i'm not even sure if this is related to copilot-cmp. i think it might be copilot.lua which has different behaviour here compared to the OG github plugin |
So this might've been fixed in the past, but it's definitely not working with the current version of the code. I dug into it and added some print statements after the Copilot API call here: copilot-cmp/lua/copilot_cmp/completion_functions.lua Lines 18 to 20 in be98d3a
And when forcing a manual completion, it definitely returns results. So I don't think copilot.lua is the issue. For whatever reason cmp doesn't seem to render the completions in the menu though. I also found that by changing the label here to something like copilot-cmp/lua/copilot_cmp/format.lua Line 151 in be98d3a
I was able to get a Copilot completion by just idling on an empty new line: Of course the indentation is off, but at least cmp now shows it. So is it just an upstream issue with cmp? I'm not so sure because if I take the old fix above NOBLES5E@8c12903#diff-5be4b7ceb2cb4e7373fba2cdc1d29a636eb8c9a48bb5efdcd85d5286a7f3ffdf and check that out, cmp properly renders it: The old version of the code is not very useable but this suggests it's not entirely cmp's issue. I'm not sure if there's any nicer solutions. However this issue definitely still exists and should probably be reopened. |
@andreykaipov just used your solution and it appears to be working. I think this issue should be reopened as well |
I also have this issue |
I have spent hours to find what's happening and also found out that the suggesions are received, just don't show up. The weirdest part for me is that the completion shows up for a split second when I press Backspace (with It seems, though, that the author of this repo isn't really active anymore. |
Currently making do with @andreykaipov solution, modified that line. Atleast it shows after pressing space now. |
I tried to figure what's going on, unfortunately it seems that It forbids modifying text before the cursor, that's why indented lines don't work, because this plugin tries to replace the entire line, instead of just pasting the completion. The second issue is a harder one to figure out. After any change to the indentation, the copilot results stop appearing. There might be a race condition - completion function returns immediately with response I can get the completion show up twice (once more after hiding/ESCaping the completion menu), but not after that for as long as I have indentation before the cursor (but no indentation works after commenting the line mentioned above). Also for whatever reason |
So, I managed to find all the issues I experienced myself and fix them, though there may be some usecases I missed. I made a PR (#105) with more detailed explanation of what is actually happening. But because it seems that this repo is kind of stale, I will try to keep up a fork myself (at least until this repo becomes active again). Right now, I just merged all other PRs (#104, #102) waiting in this repo and did a small refactor to conform to the standard If anyone would like to try it out, and should any other issues be found, I will do my best to help. |
a fork of copilot-cmp can now show results on empty lines zbirenbaum/copilot-cmp#5 (comment)
Common use case of copilot is
1 write a comment
2 go to next line
3 accept suggestion
This is not working, even when I force trigger cmp (cmp.mapping.complete()) then also it does not show any completion from copilot, but has other sources like buffer.
If I write a character copilot suggestion works, but not on empty line.
The text was updated successfully, but these errors were encountered: