Shougo / deoplete.nvim

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

入力文字数以下の文字数の候補を表示する方法 #1019

Closed iranoan closed 5 years ago

iranoan commented 5 years ago

Problems summary

[Feature request] Get word suggestions when using "set spell" #235 でも話題になっていた deoplete-spell を試しているのですが、補完候補には入力されている文字数以下の候補が表示されません

入力文字数以下の候補も表示する方法は有るのでしょうか?

Expected

spellsuggest() の結果も合わせて候補に表示して欲しい 今はこの中から入力文字数以下の候補が除外されている

Environment Information

以下引用部分は個人環境に該当しそうな部分は一部xで書き換えています

Version: 5.2

`$ pwd`

/home/xxx/.vim/bundle/repos/github.com/Shougo/deoplete.nvim

`$ git log`

commit 98566131d5f574ee2896138bdda08afa68bda416 (HEAD -> master, origin/master, origin/HEAD) Author: Shougo Matsushita xxxxxxxxx@gmail.com Date: Thu Sep 19 20:58:19 2019 +0900

Fix lint

 * OS:

`$ lsb_release -a`

No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 19.04 Release: 19.04 Codename: disco

`$ uname -a`

Linux xxx 5.0.0-29-generic #31-Ubuntu SMP Thu Sep 12 13:05:32 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux


 * neovim/Vim `:version` output:

`$ vim --version`

VIM - Vi IMproved 8.1 (2018 May 18, compiled Jun 07 2019 11:42:36) 適用済パッチ: 1-320 Modified by team+vim@tracker.debian.org Compiled by team+vim@tracker.debian.org Huge 版 with GTK3 GUI. 機能の一覧 有効(+)/無効(-)


 * `:checkhealth` or `:CheckHealth` result(neovim only):

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

`:r!grep -Ev '^\s*"' ~/.vim/vimrc`

scriptencoding utf-8 if has('vim_starting') if &compatible set nocompatible endif let s:cache_home = empty($XDG_CACHE_HOME) ? expand('~/.vim') : $XDG_CACHE_HOME let s:dein_dir = s:cache_home . '/bundle' let s:dein_repo_dir = s:dein_dir . '/repos/github.com/Shougo/dein.vim' if !isdirectory(s:dein_repo_dir) call system('git clone https://github.com/Shougo/dein.vim ' . shellescape(s:dein_repo_dir)) endif let &runtimepath = &runtimepath . ',' . s:dein_repo_dir if dein#load_state(s:dein_dir) call dein#begin(s:dein_dir) let g:rc_dir = expand('~/.vim/rc') let s:toml = g:rc_dir . '/dein.toml' let s:lazy_toml = g:rc_dir . '/dein_lazy.toml' call dein#load_toml(s:toml, {'lazy': 0}) call dein#load_toml(s:lazy_toml, {'lazy': 1}) call dein#end() call dein#save_state() if dein#check_install() call dein#install() endif endif endif filetype plugin indent on set spelllang+=cjk set spell


`:r!grep -Ev ^\# ~/.vim/rc/dein.toml | grep -Ev '^\s*"'`

[[plugins]] repo = 'Shougo/dein.vim' [[plugins]] repo = 'Shougo/context_filetype.vim'


`:r!grep -Ev ^\# ~/.vim/rc/dein_lazy.toml | grep -Ev '^\s*"'`

[[plugins]] repo = 'roxma/vim-hug-neovim-rpc' if = '''! has('nvim')''' [[plugins]] repo = 'roxma/nvim-yarp' depends = 'vim-hug-neovim-rpc' if = '''! has('nvim')''' [[plugins]] repo = 'Shougo/deoplete.nvim' depends = ['context_filetype.vim', 'vim-hug-neovim-rpc', 'nvim-yarp'] if = ''' has('python3') ''' on_event = 'InsertEnter' hook_source = ''' let g:deoplete#enable_at_startup = 1 ''' [[plugins]] repo = 'deathlyfrantic/deoplete-spell' on_event = 'InsertEnter' depends = ['deoplete.nvim']


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

presuing excersized

の内容で、

1. `:echo spellsuggest('presuing')`
      で期待する候補が含まれていることを確認
2. ファイル先頭で A で入力モードに移行し、deoplete.nvim が候補を出す

のスクショが次のとおりです
![spell](https://user-images.githubusercontent.com/24851657/65311470-5c9abe80-dbcb-11e9-8225-82cb94d0ea71.gif)

導入していないので、まともな動作にならないと解りつつ、下記の環境に加えて deoplete-spell の設定に

hook_source = ''' call deoplete#custom#source('spell', 'matchers', ['matcher_cpsm']) '''

を加えると、入力文字数以下の候補も表示されます
![Screenshot from 2019-09-20 13-11-39](https://user-images.githubusercontent.com/24851657/65311490-66bcbd00-dbcb-11e9-99d2-ce80703af06f.png)

正しく動作するように

[[plugins]] repo = 'nixprime/cpsm' build = 'sh -c "PY3=ON ./install.sh"'


も加えると出なくなります

matcher_length 以外ならば、入力文字数以下の候補も表示されると考えたのです、そうではないのでしょうか?
Shougo commented 5 years ago

matcher_length 以外ならば、入力文字数以下の候補も表示されると考えたのです、そうではないのでしょうか?

これは当然の結果です。 この場合、入力文字数以下の候補を制限しているのは matcher だからです。 matcher が正しく動作しない状態だと、matcher は何もしないので全ての候補が出ます。

これに対処するには、matcher を無効化するしかありません。 どの種類の matcher も文字列とのマッチでチェックしているので、 入力文字列以下の候補は基本的に出ません。

call deoplete#custom#source('spell', 'matchers', [])
iranoan commented 5 years ago

これは当然の結果です。 この場合、入力文字数以下の候補を制限しているのは matcher だからです。 matcher が正しく動作しない状態だと、matcher は何もしないので全ての候補が出ます。

これに対処するには、matcher を無効化するしかありません。 どの種類の matcher も文字列とのマッチでチェックしているので、 入力文字列以下の候補は基本的に出ません。

call deoplete#custom#source('spell', 'matchers', [])

無効にすることができるんですね ドキュメントのどれかを指定しなければならないと思いこんでいました ありがとうござました