Shougo / deoplete.nvim

:stars: Dark powered asynchronous completion framework for neovim/Vim8
Other
5.94k stars 295 forks source link

Regression: ctx['candidates'] should be dict, but is string #421

Closed skosch closed 7 years ago

skosch commented 7 years ago

d4e22ed8 moved the following piece of code into omni:

             if ctx['candidates'] and isinstance(ctx['candidates'][0], str):        
                  # Convert to dict     
                  ctx['candidates'] = [{'word': x}      
                                       for x in ctx['candidates']]

Unfortunately, ctx['candidates'] still seems to be a string sometimes, because since yesterday I've been getting a whole bunch of

[deoplete] Traceback (most recent call last):                                                                                                                           
[deoplete] Could not filter using: <deoplete.filter.sorter_rank.Filter object at 0x7f6b79a4acc0>.  Use :messages for error details.                                     
[deoplete]   File "/home/sebastian/.config/nvim/plugged/deoplete.nvim/rplugin/python3/deoplete/deoplete.py", line 131, in gather_results                                
[deoplete] Traceback (most recent call last):                                                                                                                           
[deoplete]     ctx['candidates'] = f.filter(ctx)                                                                                                                        
[deoplete]   File "/home/sebastian/.config/nvim/plugged/deoplete.nvim/rplugin/python3/deoplete/deoplete.py", line 131, in gather_results                                
[deoplete]   File "/home/sebastian/.config/nvim/plugged/deoplete.nvim/rplugin/python3/deoplete/filter/sorter_rank.py", line 23, in filter                               
[deoplete]     ctx['candidates'] = f.filter(ctx)                                                                                                                        
[deoplete]     key=lambda x: -1 * rank[x['word']]                                                                                                                       
[deoplete]   File "/home/sebastian/.config/nvim/plugged/deoplete.nvim/rplugin/python3/deoplete/filter/converter_truncate_abbr.py", line 26, in filter                   
[deoplete]   File "/home/sebastian/.config/nvim/plugged/deoplete.nvim/rplugin/python3/deoplete/filter/sorter_rank.py", line 24, in <lambda>                             
[deoplete]     candidate.get('abbr', candidate['word']),                                                                                                                
[deoplete]     if x['word'] in rank                                                                                                                                     
[deoplete] AttributeError: 'str' object has no attribute 'get'                                                                                                          
[deoplete] TypeError: string indices must be integers                                                                                                                   
[deoplete] Could not filter using: <deoplete.filter.converter_truncate_abbr.Filter object at 0x7f6b79a4ab70>.  Use :messages for error details.                         
[deoplete] Could not filter using: <deoplete.filter.sorter_rank.Filter object at 0x7f6b79a4acc0>.  Use :messages for error details.                                     
[deoplete] Too many errors from "elixir". This source is disabled until Neovim is restarted.                                                                            
[deoplete] Traceback (most recent call last):                                                                                                                                        
[deoplete]   File "/home/sebastian/.config/nvim/plugged/deoplete.nvim/rplugin/python3/deoplete/deoplete.py", line 131, in gather_results                                                                                                                                               
[deoplete]     ctx['candidates'] = f.filter(ctx)                                                                                                                      
[deoplete]   File "/home/sebastian/.config/nvim/plugged/deoplete.nvim/rplugin/python3/deoplete/filter/converter_truncate_abbr.py", line 26, in filter                                                                                          
[deoplete]     candidate.get('abbr', candidate['word']),                                                                                          
[deoplete] AttributeError: 'str' object has no attribute 'get'                                                                                                      
[deoplete] Could not filter using: <deoplete.filter.converter_truncate_abbr.Filter object at 0x7f6b79a4ab70>.  Use :messages for error details.                                                                                                  
[deoplete] Too many errors from "elixir". This source is disabled until Neovim is restarted.                                                                                                              
[deoplete] Traceback (most recent call last):                                                                                                                                                 
[deoplete]   File "/home/sebastian/.config/nvim/plugged/deoplete.nvim/rplugin/python3/deoplete/deoplete.py", line 153, in gather_results                                                                                                                                               
[deoplete]     candidate['icase'] = 1                                                                                                                                                                                          
[deoplete] TypeError: 'str' object does not support item assignment    

etc.

Environment Information

Provide a minimal init.vim with less than 50 lines (Required!)

" Your minimal init.vim
call plug#begin()
Plug 'awetzel/elixir.nvim', { 'do': 'yes \| ./install.sh' }
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'neomake/neomake'
call plug#end()
let g:deoplete#enable_at_startup = 1

The reproduce ways from neovim starting (Required!)

Deoplete works fine in most situations, but problems seem to occur with suggestions from awetzel's elixir.nvim package. Might this be a deoplete problem, or is the elixir plugin at fault?

I hope that's enough of a starting point – I'm happy to provide more info if needed.

Thank you for an otherwise fantastic plugin! :+1:

Shougo commented 7 years ago

OK. I should restore the behavior. Some plugins depends on the previous feature.

skosch commented 7 years ago

I'm afraid so. For what it's worth, I've plopped those four lines back in, in my local copy, and the problem hasn't come up since.

Maybe you can mark raw strings as deprecated, and remove this in the future – for now I think users would be grateful for backward compatibility. :)