Shougo / ddc.vim

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

manual_complete does not open after first trigger and does not update when typing #140

Closed phgz closed 1 year ago

phgz commented 1 year ago

Problems summary

ddc#map#manual_complete (with UI "native") does not open after first trigger or does not update when typing. I do not know if this problem is related to "native" UI or ddc itself.

Expected

A single call to the function should open the UI and typing text should update items.

Environment Information

Provide a minimal init.vim/vimrc without plugin managers (Required!)

" Your minimal init.vim/vimrc
set rtp+=~/denops.vim
set rtp+=~/ddc.vim
set rtp+=~/ddc-ui-native
set rtp+=~/ddc-ui-none
set rtp+=~/ddc-source-around

set completeopt=menu,menuone,noinsert,noselect

call ddc#custom#load_config(expand('~/ddc-config.ts'))
call ddc#enable()

inoremap <silent> <expr> <S-Tab> pumvisible() ? '<up>' : ddc#map#manual_complete(#{sources: ['around'], ui: 'native'})
inoremap <silent> <expr> <Tab> pumvisible() ? '<down>' : '<tab>'
inoremap <silent> <expr> <esc> pumvisible() ? '<c-e>' : '<esc>'
inoremap <silent> <expr> <cr> pumvisible() ? '<c-y>' : '<cr>'

ddc-config.ts

import { BaseConfig } from "https://deno.land/x/ddc_vim@v3.9.0/types.ts";
import { ConfigArguments } from "https://deno.land/x/ddc_vim@v3.9.0/base/config.ts";

export class Config extends BaseConfig {
  override config(args: ConfigArguments): Promise<void> {
    args.contextBuilder.patchGlobal({
      ui: "none",
      sources: [],
      autoCompleteEvents: [
        "InsertEnter",
        "TextChangedI",
        "TextChangedP",
      ],
      sourceOptions: {
        _: {
          minAutoCompleteLength : 1,
        },
        around: {
          mark: "A",
        },
      },
      backspaceCompletion: true,
    });
  }
}

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

  1. enter init.vim file
  2. type o (new line in insert mode)
  3. type <S-Tab> (nothing happens)
  4. type <S-Tab> (menu now opens)
  5. start typing "nat" (menu disapear)
  6. reopen menu (menu items are not updated)
Shougo commented 1 year ago

type (nothing happens)

It is not nothing happens. The popup menu seems closed.

Shougo commented 1 year ago

Fixed.

Shougo commented 1 year ago

reopen menu (menu items are not updated)

The update is feature. Because you don't set filter in your config. No magic.

phgz commented 1 year ago

Thanks for 2abe9a6!

Sorry I forgot to put matcher in minimal repro.

Add: set rtp+=~/ddc-matcher_head in init.vim. Change sourceOptions to

sourceOptions: {
  _: {
    matchers: ["matcher_head"],
    minAutoCompleteLength : 1,
  },
  around: {
    mark: "A",
  },
},

in ddc-config.ts.

In the video (after patch), I first use regular native + around for completion (items update), then manual complete with native + around (items stay the same). ezgif-5-a386ec8d01

Shougo commented 1 year ago

Fixed the behavior.

But you need to know the documentation.

                                                   *ddc#map#manual_complete()*
ddc#map#manual_complete([{options}])
        Manual trigger ddc completion.
        {options} is |ddc-options|.
        NOTE: Manual completion ignores
        |ddc-source-option-minAutoCompleteLength|.
        NOTE: After you open completion UI in manual completion, your
        next input will be used as manual completion until the items
        are empty or |ddc#hide()| is called.

It is the limitation behavior.

phgz commented 1 year ago

Thank you very much!