abingham / emacs-ycmd

Emacs client for ycmd, the code completion system.
MIT License
384 stars 46 forks source link

Parsing and command completion interfere with each other #147

Open r4nt opened 9 years ago

r4nt commented 9 years ago

I find it's very hard to configure emacs-ycmd with idle-change in a way that code completion is not constantly stumped by parsing, even though parsing is pretty fast (0.3 seconds).

I'm wondering whether the ycmd-idle-change-delay is not counting from (the last command line completion returns || I hit a key), but only from "I hit a key".

abingham commented 9 years ago

Is this the problem where you try to do a completion but are told that parsing is happening?

abingham commented 9 years ago

Also, what settings are you using for ycmd-idle-change-delay and any potentially related stuff? I can try those settings myself and see what there is to see.

FWIW, I agree that this is a fiddly area.

r4nt commented 9 years ago

Yep, exactly. I have tried various settings for ycmd-idle-change-delay < 1 second and various settings for company-mode. I am mainly thinking this can be solved because the vim version doesn't have the problem that much (@Valloric for why that might be).

abingham commented 9 years ago

Can you point me at an example that's exhibiting these problems, maybe something in an open-source project?

r4nt commented 9 years ago

I'm mainly working on LLVM. Unfortunately there I still need to find time to create a self-compiled emacs (to the the upstream JSON improvement), because JSON escape times basically get in the way of everything else...

abingham commented 9 years ago

Right. I'll just keep this open and wait for you to get back with more info.

Valloric commented 9 years ago

Just to note, ycmd does in fact reject completion requests if a FileReadyToParse event came in and it hasn't yet been fully processed. YCM considers sending the event in the following cases:

  1. When the user leaves Insert mode.
  2. When the user moves the cursor in Normal mode.
  3. When the user switches to the buffer.
  4. When the user hasn't typed anything for 4 seconds (an idle timer). Note that this triggers only after the first (not every) 4 seconds of inactivity.

...but the event is sent ONLY if the buffer has been changed since the last time we considered sending it.

Note that completion requests will also parse the file.

The reason why subsequent parse events are dropped on the floor is because we used to not do that, and then ycmd would just get clogged with parse events if the file takes a long time to parse and everyone was unhappy. This turned out to be a much better system, because logically the parse events are "update the AST cache for me" and it makes no sense to queue up such events if the update is already happening.

dgutov commented 9 years ago

Unfortunately there I still need to find time to create a self-compiled emacs

Alas, that might not help, as long as #165 is unresolved.