-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add TypeScript autoimport support for deoplete #2779
Add TypeScript autoimport support for deoplete #2779
Conversation
Thanks for this! I'll ask around on IRC to see if anyone wants to try this out. |
You are awesome! Just tested and it worked for me! |
I tested it and it worked when I removed These are my deoplete settings: Plug 'Shougo/deoplete.nvim'
let g:deoplete#enable_at_startup = 1
set completeopt-=preview
let g:deoplete#max_abbr_width = -1
let g:deoplete#max_menu_width = -1
let g:deoplete#ignore_sources = {}
let g:deoplete#ignore_sources._ = [
\ 'tags', 'buffer', 'around', 'local',
\ 'file', 'member', 'omni', 'link',
\ 'LanguageClient'
\]
autocmd FileType * call deoplete#custom#option({
\ 'auto_complete': v:true,
\ 'auto_complete_delay': 0,
\ 'smart_case': v:true,
\ 'min_pattern_length': 1
\ })
autocmd FileType * call deoplete#custom#option('sources', {
\ '_': ['ale']
\})
Maybe it one of these settings that is causing the different behavior? |
Just tested your config and I am unable to reproduce this. Which version of deoplete are you running? |
@thisjeremiah I took another look at this, this time I ran it in a clean neovim environment in Docker: call plug#begin('~/.config/nvim/plugged')
Plug 'jeremija/ale', { 'branch': 'feature/autoimport-deoplete' }
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
call plug#end()
augroup FiletypeGroup
autocmd!
au BufNewFile,BufRead *.ts set filetype=typescript
augroup END
let g:ale_completion_tsserver_autoimport = 1
let g:deoplete#enable_at_startup = 1
autocmd FileType * call deoplete#custom#option('sources', {
\ '_': ['ale']
\}) I added some I've already noticed this before and commented about it here:
|
4468b09
to
3dce8bf
Compare
Shuogo, the author of Deoplete, does not recommend using the `is_async` option: > I think is_async is not recommended. It is not so useful and broken. > You should use callback system instead. Link: Shougo/deoplete.nvim#1006 (comment) Incidentally, the same thread mentiones an issue started by w0rp: Shougo/deoplete.nvim#976 The deoplete docs also say is_async is deprecated: > is_async (Bool) > If the gather is asynchronous, the source must set > it to "True". A typical strategy for an asynchronous > gather_candidates method to use this flag is to > set is_async flag to True while results are being > produced in the background (optionally, returning them > as they become ready). Once background processing > has completed, is_async flag should be set to False > indicating that this is the last portion of the > candidates. > > Note: The feature is deprecated and not recommended. > You should use callback system by > |deoplete#auto_complete()| instead. Link: https://github.com/Shougo/deoplete.nvim/blob/master/doc/deoplete.txt
3dce8bf
to
bdb7c74
Compare
@thisjeremiah can you test now? |
How recently was the newer callback system added? |
It seems that a pretty recent change introduced problems for some people. See:
The My latest commit message has some more details. |
If it's a very recent change, then we should still support Maybe we can detect if the newer feature exists or not, and use one thing or the other. |
Yeah, it looks like the latest changes in this PR will work only since a very recent commit in Deoplete:
|
Yes, I updated deoplete and tested with your updated branch. It works for me now! |
Okay, I think some detection of the Deoplete version is needed, and maybe we can only enable support for autoimports in Deoplete if the Deoplete version is new enough. |
I agree, I'm just not sure what would be the best way to check for this, since the old autocomplete functionality is buggy in the current version of deoplete (is_async callbacks sometimes work, and sometimes do not because it calls AFAIK, there is no way to retrieve Deoplete version from vim/python - the only place I found it was in If anybody has an idea on how to reliably check for the new feature (or the bug), I'd love to hear it! |
I think we can check |
Unfortunately, this function was in deoplete before Shougo/deoplete.nvim@782fdaf, which is the most recent commit that my fixes work with :/ |
Maybe there's something else we can use to detect if Deoplete is new enough. |
Using deoplete at that version together with your branch gives me working auto-import functionality. It's really cool. |
At this point, I'll merge this, and if anyone has problems they can update Deoplete. The version which works with this is old enough now. |
Cheers! 🍻 |
* Add autoimport support for deoplete * Fix test_deoplete_source.py * Use callback instead of is_async for deoplete Shuogo, the author of Deoplete, does not recommend using the `is_async` option: > I think is_async is not recommended. It is not so useful and broken. > You should use callback system instead. Link: Shougo/deoplete.nvim#1006 (comment) Incidentally, the same thread mentiones an issue started by w0rp: Shougo/deoplete.nvim#976 The deoplete docs also say is_async is deprecated: > is_async (Bool) > If the gather is asynchronous, the source must set > it to "True". A typical strategy for an asynchronous > gather_candidates method to use this flag is to > set is_async flag to True while results are being > produced in the background (optionally, returning them > as they become ready). Once background processing > has completed, is_async flag should be set to False > indicating that this is the last portion of the > candidates. > > Note: The feature is deprecated and not recommended. > You should use callback system by > |deoplete#auto_complete()| instead. Link: https://github.com/Shougo/deoplete.nvim/blob/master/doc/deoplete.txt Co-authored-by: w0rp <w0rp@users.noreply.github.com>
This should add support for TypeScript autoimport in deoplete.
This also fixes a bug with the current ALE source for Deoplete since ALE limits the number of completions to
g:ale_completion_max_suggestions
(default50
). Whenwindow.
is typed, there will be a lot more results than50
, so most will be filtered out. Because of this, whenwindow.Syn
is typedSyntaxError
will not be shown. I've tried increasing the limit to a higher number, but then TypeScript completions become really slow (possibly because of completion entry details requests), so I've set theis_volatile = True
variable to ALE source.From deoplete docs:
It would be great if somebody actively using deoplete (and TypeScript) would be able to test this before merging!