Skip to content
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

Import smart_auto_mappings: use a timer if available #708

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

blueyed
Copy link
Collaborator

@blueyed blueyed commented May 19, 2017

Fixes #568.

@Flimm
Copy link
Contributor

Flimm commented May 22, 2017

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

@blueyed
Copy link
Collaborator Author

blueyed commented May 24, 2017

@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?

@Flimm
Copy link
Contributor

Flimm commented May 25, 2017

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.

@davidhalter
Copy link
Owner

Hmm, @Flimm did you try?

@Flimm
Copy link
Contributor

Flimm commented Jun 5, 2017

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

@blueyed
Copy link
Collaborator Author

blueyed commented Jun 5, 2017

Is it Vim 8.0.0000 on both really?

@blueyed
Copy link
Collaborator Author

blueyed commented Jun 5, 2017

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

@blueyed blueyed force-pushed the improve-smart-auto-mappings branch from 3176b49 to d3f91c4 Compare July 5, 2017 13:30
@blueyed blueyed force-pushed the improve-smart-auto-mappings branch from d3f91c4 to 1374268 Compare August 7, 2017 18:55
@blueyed
Copy link
Collaborator Author

blueyed commented Aug 7, 2017

Rebased on master for now.

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

@blueyed blueyed added the feature label Aug 7, 2017
@Flimm
Copy link
Contributor

Flimm commented Aug 10, 2017

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.

@blueyed
Copy link
Collaborator Author

blueyed commented Aug 10, 2017

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 blueyed force-pushed the improve-smart-auto-mappings branch from 414c646 to 3dfe547 Compare April 11, 2018 11:45
@blueyed blueyed force-pushed the improve-smart-auto-mappings branch from 3dfe547 to aa55389 Compare July 15, 2018 16:27
endif
endif
return
elseif search('\m^\s*from\s\+[A-Za-z0-9._]\{1,50}\%#\s*$', 'bcn', line('.'))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The search should be done only in the timer callback (more lazy).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants