jedi-vim icon indicating copy to clipboard operation
jedi-vim copied to clipboard

Import smart_auto_mappings: use a timer if available

Open blueyed opened this issue 8 years ago • 10 comments

Fixes https://github.com/davidhalter/jedi-vim/issues/568.

blueyed avatar May 19 '17 15:05 blueyed

(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 type import for 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 type from os and then wait.

Flimm avatar May 22 '17 09:05 Flimm

@Flimm Thanks for your feedback.

  1. 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.

  1. 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?

blueyed avatar May 24 '17 18:05 blueyed

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.

Flimm avatar May 25 '17 06:05 Flimm

Hmm, @Flimm did you try?

davidhalter avatar Jun 03 '17 18:06 davidhalter

It works on my work computer (macOS, vim 8.0), just not on my Ubuntu 17.04 computer (vim 8.0).

Flimm avatar Jun 05 '17 09:06 Flimm

Is it Vim 8.0.0000 on both really?

blueyed avatar Jun 05 '17 11:06 blueyed

What does not work exactly? You could add some echom "here …" to see what is going on by looking at :mess later.

blueyed avatar Jun 05 '17 11:06 blueyed

Rebased on master for now.

@Flimm Would be helpful if you could try/test it again.

blueyed avatar Aug 07 '17 18:08 blueyed

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.

Flimm avatar Aug 10 '17 08:08 Flimm

I see.

For debugging:

  1. check that :echom has('timers') displays 1
  2. put some echom string(…) into the jedi#smart_auto_mappings function to figure out what is happening, and use :mess to 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)

blueyed avatar Aug 10 '17 08:08 blueyed