-
Notifications
You must be signed in to change notification settings - Fork 22
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
NCM2 completion support? #10
Comments
Hi! When deoplete wants to do completion, it sends a rpc request to comrade intelliJ side through Line 25 in 33c0d2f
IntelliJ side handles the request here https://github.com/beeender/ComradeNeovim/blob/6006eaf8b26f1baec12cd84e190d7dc96cda4ed2/src/main/kotlin/org/beeender/comradeneovim/completion/CompletionManager.kt#L42 The response definition can be seen at https://github.com/beeender/ComradeNeovim/blob/6006eaf8b26f1baec12cd84e190d7dc96cda4ed2/src/main/kotlin/org/beeender/comradeneovim/completion/CompletionManager.kt#L12
the way that deoplete handles async can be seen at
The whole process is something like:
The intelliJ part code is a bit bind with the deoplete work flow especially this kind of delta report. I am not sure if NCM2 supports something similar. But it won't be too difficult to support both of them. |
Wow, thank you for the detailed response, especially the last part. If I understand this part correctly
Comrade immediately returns a dictionary of incomplete results, then keeps collecting more results on a separate thread. Every time Deoplete requests more results ( |
Yes! correct! |
I think I'm getting somewhere, but it's not quite there yet. The manual scheduling of repeated requests is what is giving me trouble. " This function sends a blocking request to IntelliJ; IntelliJ returns almost
" immediately, but the result is incomplete, it keeps building up further
" results in the background.
function! s:send_request(ctx, buf_id, ret)
" body
let l:results = comrade#RequestCompletion(a:buf_id, a:ret)
let a:ret['new_request'] = v:false
while !l:results['is_finished']
let l:results = comrade#RequestCompletion(a:buf_id, a:ret)
if !empty(l:results.candidates)
call ncm2#complete(a:ctx, a:ctx.startccol, l:results.candidates)
endif
call wait(10, { -> v:false })
endwhile
endfunction It does generate completion results, but not beyond the first two characters. And the results are not the same as in IntelliJ, for example
I am no expert when it comes to NCM2, but in general there are two functions: the first one is a callback defined by the user which gets called when completions need to be generated, the other one is defined by NCM2 and gets called by the completion source. The way I did it in Vlime is a follows:
This leaves me only with having to connect the callbacks and massage the data into the proper shape. All the scheduling Is done already for me. |
It's me again, I tried Comrade with Deoplete to see how it fares, and I am not getting the same completion results as I am getting in IntelliJ. It will only complete symbols which are inside the current class (like I also found that my LSP plugin (LanguageClient-neovim) does not work at all if Comrade is installed and IntelliJ is running. No completion suggestions or anything, even though it does load. |
Right, the completion results are not exact same with IntelliJ. The completion system of IntelliJ is quite complex, and it is not fully designed to be used like this.
I found the same problem some days ago. Maybe it is caused by the nature that this plugin has to do the buffer sync with Also, from |
Oh, that really sucks. It means I won't be able to use Comrade for my work where I need to depend on much better completion. I'll still try to finish my work now that I have started it (I just found out a few days ago that Vim 8 introduced timers and that Neovim has merged that feature as well, should make things much easier). I can send you a PR, or I can make it into a standalone plugin if you don't want code you don't maintain yourself in your repo.
I have seen that and I have taken a peek at the API in the currently nightly builds. It looks really cool that it is so low-level, that way I should be able to really make it my own and hook up anything I want. I really hate how IDEs are built in such a way that they force you into writing your project in The One True Way. I much prefer Vim as a "desintegrated development environment" where you have a number of specialized tools that you wire up the way you want it. |
Do you have any special completion case that comrade doesn't work but the IntelliJ does? Maybe I can take a look at the IntelliJ plugin side to see if there is any options can be tuned to support that.
|
For example if you take the following main class: package com.company;
public class Main {
public static void main(String[] args) {
}
} And start typing
OK |
what does "support both of them" mean? I'm interested because Im making an extension for coc
currently i'm using some logic kind like this (by HiPhish), about coc |
@joshua7v Maybe you can try to check the JetBrain side log to see if it receives the request from coc plugin. |
@beeender thanks, well, with the logic mentioned above, completion actually works,
ncm2 / coc.nvim may not support this delta report thing, could comrade provide another approach like |
@joshua7v I have a fork of Comrade if you want to know how I did it. It's a pretty ugly hack though: I use a timer to repeatedly poll Comrade for completion results and display whatever is available. Once Comrade tells me that it is done I deleted the timer. I haven't bothered making a pull request because the result is pretty wonky and I don't use Comrade anymore. @beeender If you are OK with half-assed support for NCM2 I can make a pull request. Otherwise this issue can be closed as far as I'm concerned. |
Hi there,
This is a great plugin, but I would like to make completion work with ncm2 rather than Deoplete. I know how to write a source (done that already for Vlime), but I need a bit of help understanding how completion is implemented in Comrade.
Looking at the Deoplete source and
comrade#RequestCompletion
it appears that you are using a blocking RPC request to fetch completion results. You then use a combination of Deoplete'sis_async
context entry and theis_finished
entry of theresults
object.Can you please elaborate how they fit together? NCM2 uses callbacks instead, the idea is that when completion is requested you send off an RPC notification and specify a callback which will be called when the other side notifies Neovim that it is done. See here for an example where I pass a lambda as the callback.
I think once I understand this part I can write the NCM2 source with ease.
The text was updated successfully, but these errors were encountered: