LumaKernel / ddc-source-file

Powerful and performant file name completion for ddc.vim.
MIT License
47 stars 6 forks source link

ddc-source-file shows candidates when it shouldn't #25

Closed Coacher closed 2 months ago

Coacher commented 2 months ago

Hello.

The minimal vimrc:

set nocompatible

call plug#begin('~/.vim/plugins/')
Plug 'junegunn/vim-plug'
Plug 'vim-denops/denops.vim'
Plug 'Shougo/ddc.vim'
Plug 'Shougo/ddc-ui-native'
Plug 'Shougo/ddc-filter-matcher_head'
Plug 'Shougo/ddc-filter-sorter_rank'
Plug 'Shougo/ddc-filter-converter_remove_overlap'
Plug 'Shougo/ddc-filter-converter_truncate_abbr'
Plug 'LumaKernel/ddc-source-file'
call plug#end()

call ddc#custom#patch_global('ui', 'native')

call ddc#custom#patch_global('sourceOptions', {
    \ '_': {
    \   'maxItems': 10,
    \   'minAutoCompleteLength': 3,
    \   'keywordPattern': '\k+',
    \   'matchers': ['matcher_head'],
    \   'sorters': ['sorter_rank'],
    \   'converters': ['converter_remove_overlap', 'converter_truncate_abbr'],
    \ },
\})

call ddc#custom#patch_global('sources', [
    \ 'file'
\])

call ddc#custom#patch_global('sourceOptions', {
    \ 'file': {
    \   'mark': '[file]',
    \   'maxItems': 32,
    \   'isVolatile': v:true,
    \   'forceCompletionPattern': '\S\/\S*',
    \ },
\})
call ddc#custom#patch_global('sourceParams', {
    \ 'file': {
    \   'mode': 'os',
    \   'trailingSlash': v:true,
    \   'followSymlinks': v:true,
    \   'disableMenu': v:true,
    \ },
\})

inoremap <expr> <Tab> pumvisible() ? "\<C-N>" : ddc#map#manual_complete({'ui': 'native'})

call ddc#enable()

Steps to reproduce:

  1. vim -u vimrc.minimal
  2. iclass test(<Tab>

Expected results:

Actual results:

vim --version:

VIM - Vi IMproved 9.1 (2024 Jan 02, compiled May 31 2024 00:00:00)
Included patches: 1-452
Modified by <bugzilla@redhat.com>
Compiled by <bugzilla@redhat.com>
Huge version with GTK3 GUI.  Features included (+) or not (-):
+acl               +file_in_path      +mouse_urxvt       -tag_any_white
+arabic            +find_in_path      +mouse_xterm       -tcl
+autocmd           +float             +multi_byte        +termguicolors
+autochdir         +folding           +multi_lang        +terminal
-autoservername    -footer            -mzscheme          +terminfo
+balloon_eval      +fork()            +netbeans_intg     +termresponse
+balloon_eval_term +gettext           +num64             +textobjects
+browse            -hangul_input      +packages          +textprop
++builtin_terms    +iconv             +path_extra        +timers
+byte_offset       +insert_expand     +perl/dyn          +title
+channel           +ipv6              +persistent_undo   +toolbar
+cindent           +job               +popupwin          +user_commands
+clientserver      +jumplist          +postscript        +vartabs
+clipboard         +keymap            +printer           +vertsplit
+cmdline_compl     +lambda            +profile           +vim9script
+cmdline_hist      +langmap           -python            +viminfo
+cmdline_info      +libcall           +python3/dyn       +virtualedit
+comments          +linebreak         +quickfix          +visual
+conceal           +lispindent        +reltime           +visualextra
+cryptv            +listcmds          +rightleft         +vreplace
+cscope            +localmap          +ruby/dyn          +wildignore
+cursorbind        +lua/dyn           +scrollbind        +wildmenu
+cursorshape       +menu              +signs             +windows
+dialog_con_gui    +mksession         +smartindent       +writebackup
+diff              +modify_fname      +sodium            +X11
+digraphs          +mouse             +sound             +xattr
+dnd               +mouseshape        +spell             -xfontset
-ebcdic            +mouse_dec         +startuptime       +xim
+emacs_tags        +mouse_gpm         +statusline        +xpm
+eval              -mouse_jsbterm     -sun_workshop      +xsmp_interact
+ex_extra          +mouse_netterm     +syntax            +xterm_clipboard
+extra_search      +mouse_sgr         +tag_binary        -xterm_save
-farsi             -mouse_sysmouse    -tag_old_static
   system vimrc file: "/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
 3rd user vimrc file: "~/.config/vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
3rd user gvimrc file: "~/.config/vim/gvimrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/atk-1.0 -I/usr/include/freetype2 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/cloudproviders -I/usr/include/webp -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include -I/usr/include/fribidi -I/usr/include/libxml2 -I/usr/include/pixman-1 -I/usr/include/libpng16 -I/usr/include/gio-unix-2.0 -DWITH_GZFILEOP -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/sysprof-6 -pthread -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Wno-complain-wrong-lang -Werror=format-security -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -DSYS_VIMRC_FILE=/etc/vimrc -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -Wl,--enable-new-dtags -Wl,-z,relro -Wl,--as-needed -Wl,-z,pack-relative-relocs -Wl,-z,now -Wl,--build-id=sha1 -Wl,-z,relro -Wl,--as-needed -Wl,-z,pack-relative-relocs -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld-errors -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -specs=/usr/lib/rpm/redhat/redhat-package-notes -L/usr/local/lib -o vim -lgtk-3 -lgdk-3 -lz -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lSM -lICE -lXpm -lXt -lX11 -lSM -lICE -lm -lselinux -lncurses -lcanberra -lsodium -lacl -lattr -lgpm
Shougo commented 2 months ago

Hi. It is intended behavior.

Because:

no file completion candidates shown since keywordPattern and forceCompletionPattern are not matched

auto completion length is ignored when you use ddc#map#manual_complete().

Coacher commented 2 months ago

Hi. It is intended behavior.

Because:

no file completion candidates shown since keywordPattern and forceCompletionPattern are not matched

auto completion length is ignored when you use ddc#map#manual_complete().

Yes, the length is ignored for manual completion.

I am talking about patterns, though. Notice that keywordPattern is '\k+', not the default '\k*'. In this case I think completion shouldn't happen right after '('.

Or keywordPattern is also ignored for manual completion?

Shougo commented 2 months ago

Or keywordPattern is also ignored for manual completion?

ddc-source-file does not use keywordPattern. So it is ignored.

                        *ddc-file-param-filenameChars*
filenameChars   (string)
        The characters as filename pattern.
        The pattern is |/collection| pattern.

        Default: "[:keyword:]"

filenameChars is used instead.