Shougo / ddc.vim

Dark deno-powered completion framework for Vim/Neovim
MIT License
676 stars 32 forks source link

How to enable completions after a `.` #38

Closed amadeus closed 3 years ago

amadeus commented 3 years ago

Problems summary

Ale completions not working after using .

Expected

See completions after pressing . and also while typing text

Environment Information

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

call plug#begin('~/.vim/bundle')
Plug 'vim-denops/denops.vim'
Plug 'Shougo/ddc.vim'
Plug 'statiolake/ddc-ale'
call plug#end()

call ddc#custom#patch_global('sources', ['ale'])
call ddc#enable()

How to reproduce the problem from neovim/Vim startup (Required!)

  1. See attached video

Video Example

https://user-images.githubusercontent.com/83376/131266531-cd400bb3-eeea-4409-8cb3-54d86f324420.mp4

delphinus commented 3 years ago

Use forceCompletionPattern. See README in https://github.com/Shougo/ddc-nvim-lsp . It should be useful also in ddc-ale.

amadeus commented 3 years ago

Interestingly this didn't seem to help my problem, (using this configuration):

call ddc#custom#patch_global('sourceOptions', {
  \ 'ale': { 'forceCompletionPattern': '\.|:|->' },
\ })

Is this something that the ale plugin needs to be able to support?

amadeus commented 3 years ago

Ok! I think I have fixed the problem, but this has been a bit of an interesting rabbit hole, but I think I have it figured out!

The TL;DR: Doing some digging, I realized this was only breaking when using import * as React from 'react', because Deno appears to have an issue with react types. I had to disable deno as a linter in Ale and it all seemed to be working again (at least also using forceCompletionPattern).

The longer version: I added a bunch of logging throughout ddc-ale and ale's actual functions that were getting called, and I was noticing that in certain cases (after typing the ., the async handlers from ale were never getting resolved. However ale was not throwing any errors, or anything, it was just silently not responding.

I started testing out just creating my own objects with properties and immediately they were autocompleting just fine. I initially thought that this might have something to do with perhaps too many results (I did notice that Ale limited things to 50) but then as I was continuing to test and debug - I started noticing that Ale was kicking up linter errors with deno. Specifically - these linter errors were around JSX elements and having no interface (a lot like these: https://github.com/denoland/deno/issues/9425 ). I went in and disabled deno as a linter, and boom, everything started to work as expected. I will probably need to do some separate digging to figure out what was going on here, but it was interesting that deno having issues with types somehow cause Ale's completion handlers to NOT fire properly.

Shougo commented 3 years ago

It works for me.

call ddc#custom#patch_global('sourceOptions', {
  \ 'ale': { 'forceCompletionPattern': '\.|:|->' },
\ })

I have tested it for console. pattern.

Shougo commented 3 years ago

It is not ddc problem.