Import smart_auto_mappings: use a timer if available
Fixes https://github.com/davidhalter/jedi-vim/issues/568.
(Ignore my previous deleted comment.)
I like this behaviour better than the existing behaviour. If I type from os import without any pauses between keystrokes, I don't end up with from os import import, which is good. So I'm excited about this change. 👍
Ideally, I would like to see two more changes:
- If I type
from os, I don't want the plugin to automatically typeimportfor me, even after a delay. I don't want the plugin to automatically type anything for me. (But by all means, show the pop-up and insert a suggestion once selected.) - If I type
from os import, I would like the pop-up to appear. Right now, it only appears if I typefrom osand then wait.
@Flimm Thanks for your feedback.
-
If I type from os, I don't want the plugin to automatically type import for me, even after a delay
The set g:jedi#smart_auto_mappings = 0.
-
If I type from os import, I would like the pop-up to appear. Right now, it only appears if I type from os and then wait.
jedi-vim does no autocompletion while typing, but only on dots (with g:jedi#popup_on_dot = 1 (and g:jedi#completions_enabled = 1).
I will add special handling for g:jedi#completions_enabled = 0, where it will only put the `import.
This is meant to be used with deoplete-jedi or other completion systems.
And while we could have something for your use case there also, I think it would require to have a separate setting for this (or use something like 2 etc for the value).
We could handle g:jedi#smart_auto_mappings as a dict, with something like
-
type_import -
type_import_delay -
complete_after_import -
complete_after_import_delay
It might be better for you to just have a custom mapping maybe?
I just tested this on my home Ubuntu 17.04 computer with vim 8.0, and I couldn't get suggestions or autocompletions to work after typing from os , neither in 3176b49 or d2d77fa , it simply does nothing. It does work with the code in master. I'll try again from my other computer and respond to your comments.
Hmm, @Flimm did you try?
It works on my work computer (macOS, vim 8.0), just not on my Ubuntu 17.04 computer (vim 8.0).
Is it Vim 8.0.0000 on both really?
What does not work exactly? You could add some echom "here …" to see what is going on by looking at :mess later.
Rebased on master for now.
@Flimm Would be helpful if you could try/test it again.
Again, it works on my work computer (macOS), but not on my home computer (Ubuntu 17.04, vim 8.0, package version: 2:8.0.0095-1ubuntu3).
Sorry, I realise that's not very useful, I hope to be able to find time to brush up on my vimscript and debug this, but it's not going to be in the next few days. For the record, I really dislike the old behaviour of typing for me without a timeout, I dislike it so much that I prefer this new behaviour, even when it doesn't anything at all on my Ubuntu computer.
I see.
For debugging:
- check that
:echom has('timers')displays 1 - put some
echom string(…)into thejedi#smart_auto_mappingsfunction to figure out what is happening, and use:messto display the output. Maybe some of the conditions in the timer callback do not match what is expected? (https://github.com/davidhalter/jedi-vim/pull/708/files#diff-fbb97b52e757230b3e1ea93f959c64a2R634)