Shougo / ddc.vim

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

Cannot restore options when vim invoke `DDCCmdlineLeave` #87

Closed 4513ECHO closed 2 years ago

4513ECHO commented 2 years ago

Warning: I will close the issue without the minimal init.vim and the reproduction instructions.

Problems summary

Cannot restore options when vim invoke DDCCmdlineLeave.

Expected

Environment Information

8c827a0

e2f1704

deno 1.18.2
Ubuntu 5.11.0-1027.30-raspi 5.11.22
neovim version output ``` NVIM v0.7.0-dev+1094-gdeb33a977 Build type: RelWithDebInfo LuaJIT 2.1.0-beta3 Compilation: /usr/bin/cc -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -DNVIM_TS_HAS_SET_ALLOCATOR -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/hibiki/Develops/github.com/neovim/neovim/build/config -I/home/hibiki/Develops/github.com/neovim/neovim/src -I/home/hibiki/Develops/github.com/neovim/neovim/.deps/usr/include -I/usr/include -I/home/hibiki/Develops/github.com/neovim/neovim/build/src/nvim/auto -I/home/hibiki/Develops/github.com/neovim/neovim/build/include Compiled by hibiki@rpi0ubuntu Features: +acl +iconv +tui See ":help feature-compile" システム vimrc: "$VIM/sysinit.vim" 省略時の $VIM: "/usr/local/share/nvim" Run :checkhealth for more info ```
`:checkhealth` output ```markdown denops: health#denops#check ======================================================================== - INFO: Supported Deno version: `1.17.1` - INFO: Detected Deno version: `1.18.2` - OK: Deno version check: passed - INFO: Supported Neovim version: `0.6.0` - INFO: Detected Neovim version: `0.7.0` - OK: Neovim version check: passed - INFO: Denops status: `running` - OK: Denops status check: passed nvim: health#nvim#check ======================================================================== ## Configuration - OK: no issues found ## Performance - OK: Build type: RelWithDebInfo ## Remote Plugins - OK: Up to date ## terminal - INFO: key_backspace (kbs) terminfo entry: key_backspace=\177 - INFO: key_dc (kdch1) terminfo entry: key_dc=\E[3~ - INFO: $SSH_TTY='/dev/pts/0' ## tmux - OK: escape-time: 1 - INFO: Checking stuff - OK: focus-events: on - INFO: $TERM: tmux-256color provider: health#provider#check ======================================================================== ## Clipboard (optional) - OK: Clipboard tool found: tmux ## Python 3 provider (optional) - INFO: Using: g:python3_host_prog = "/home/hibiki/.local/share/nvim/venv/bin/python" - INFO: Executable: /home/hibiki/.local/share/nvim/venv/bin/python - INFO: Python version: 3.9.5 - INFO: pynvim version: 0.4.3 - OK: Latest pynvim is installed. ## Python virtualenv - OK: no $VIRTUAL_ENV ## Ruby provider (optional) - INFO: Ruby: ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [aarch64-linux-gnu] - WARNING: `neovim-ruby-host` not found. - ADVICE: - Run `gem install neovim` to ensure the neovim RubyGem is installed. - Run `gem environment` to ensure the gem bin directory is in $PATH. - If you are using rvm/rbenv/chruby, try "rehashing". - See :help |g:ruby_host_prog| for non-standard gem installations. ## Node.js provider (optional) - INFO: Node.js: v12.21.0 - WARNING: Missing "neovim" npm (or yarn) package. - ADVICE: - Run in shell: npm install -g neovim - Run in shell (if you use yarn): yarn global add neovim ## Perl provider (optional) - ERROR: perl provider error: - ADVICE: - "Neovim::Ext" cpan module is not installed vim.lsp: require("vim.lsp.health").check() ======================================================================== - INFO: LSP log level : WARN - INFO: Log path: /home/hibiki/.cache/nvim/lsp.log - INFO: Log size: 6 KB vim.treesitter: require("vim.treesitter.health").check() ======================================================================== - INFO: Runtime ABI version : 14 - OK: Loaded parser for c: ABI version 13 ```

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

if &compatible
  set nocompatible
endif

set runtimepath+=~/.cache/vim/dein/repos/github.com/vim-denops/denops.vim
set runtimepath+=~/.cache/vim/dein/repos/github.com/Shougo/ddc.vim
set runtimepath+=~/.cache/vim/dein/repos/github.com/Shougo/ddc-around
set runtimepath+=~/.cache/vim/dein/repos/github.com/Shougo/ddc-cmdline
set runtimepath+=~/.cache/vim/dein/repos/github.com/Shougo/pum.vim

call ddc#custom#patch_global({
      \ 'sources': ['around'],
      \ 'completionMenu': 'pum.vim',
      \ 'sourceOptions': {
      \   'around': {'mark': 'ard'},
      \   'cmdline': {'mark': 'cmd'},
      \ }})

nnoremap : <Cmd>call CmdlinePre()<CR>:
cnoremap <expr> <Tab> pum#visible()
      \ ? '<Cmd>call pum#map#select_relative(+1)<CR>'
      \ : ddc#map#manual_complete()

function! CmdlinePre() abort
  let b:prev_config = ddc#custom#get_buffer()
  call ddc#custom#patch_buffer({'sources': ['cmdline']})
  autocmd User DDCCmdlineLeave ++once call CmdlinePost()
  call ddc#enable_cmdline_completion()
  call ddc#enable()
endfunction

function! CmdlinePost() abort
  call ddc#custom#set_buffer(b:prev_config)
  unlet b:prev_config
endfunction

call ddc#enable()

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

  1. type <C-w>n (make new window)
  2. execute :quit! on cmdline

Screenshot (if possible)

Shougo commented 2 years ago

Reproduced. But sorry, it is your fault. DDCCmdlineLeave buffer may be changed if you have quit the buffer. So you need to check it.

Shougo commented 2 years ago
function! CmdlinePre() abort
  let b:prev_config = ddc#custom#get_buffer()
  call ddc#custom#patch_buffer({'sources': ['cmdline']})
  autocmd User DDCCmdlineLeave ++once call CmdlinePost()
  call ddc#enable_cmdline_completion()
  call ddc#enable()
endfunction

function! CmdlinePost() abort
  if exists('b:prev_config')
    call ddc#custom#set_buffer(b:prev_config)
    unlet b:prev_config
  endif
endfunction
4513ECHO commented 2 years ago

Ok, Thank you.