LumaKernel / ddc-source-file

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

how to list files in the curret cwd only? #22

Closed chunxuan-hs closed 9 months ago

chunxuan-hs commented 9 months ago

How to make ddc-source-fileonly list the files under the current folder. At the moment when I start to type, it seems to list folder starting from my home folder.

Here is my config:

call ddc#custom#patch_global('sources', ['buffer', 'file', 'vsnip', 'lsp', 'rg', 'mocword'])

call ddc#custom#patch_global('sourceOptions', {
  \ '_': {
  \   'matchers': ['matcher_fuzzy', 'matcher_length'],
  \   'converters': ['converter_truncate', 'converter_remove_overlap'],
  \   'ignoreCase': v:true,
  \   'sorters': ['sorter_rank'],
  \   'minAutoCompleteLength': 1},
  \ 'file': {
  \   'mark': 'F',
  \   'matchers': ['matcher_full_fuzzy'],
  \   'dup': v:true,
  \   'isVolatile': v:true,
  \   'forceCompletionPattern': '\S/\S*'},
  \ })

call ddc#custom#patch_filetype(
  \ ['ps1', 'dosbatch', 'autohotkey', 'registry'], {
  \ 'sourceOptions': {
  \   'file': {
  \     'forceCompletionPattern': '\S\\\S*',
  \   }},
  \ 'sourceParams': {
  \   'file': {
  \     'bufMaxItem': 0,
  \     'projFromCwdMaxItems': 0,
  \   }}})

In the screenshot, when I typed "lib", popup menu suggest "Library/", which I am not interested at all.

Screenshot 2024-02-21 at 21 43 15
LumaKernel commented 9 months ago

It seems Library/ is found by project-root search. Configuring projFromCwdMaxItems = [] and projFromBufMaxItems = [] then you can disable proj root search completely. Is this fixing your case?

See docs for details about settings: https://github.com/LumaKernel/ddc-source-file/blob/main/doc/ddc-file.txt

chunxuan-hs commented 9 months ago

Seems not working.

New conifg

call ddc#custom#patch_filetype(
  \ ['ps1', 'dosbatch', 'autohotkey', 'registry'], {
  \ 'sourceOptions': {
  \   'file': {
  \     'forceCompletionPattern': '\S\\\S*',
  \   }},
  \ 'sourceParams': {
  \   'file': {
  \     'projFromCwdMaxItems': [],
  \     'projFromBufMaxItems': [],
  \   }}})

As showed in the screenshot, I edited a file in Download folder, but Library, .matplotlib under home folder "~" are still in the popup:

Screenshot 2024-02-22 at 09 44 30

I am using nvim 0.9.4, willing to provide more info.

Shougo commented 9 months ago

Hm... I will test it later.

But please create the minimal vimrc. Your config is not minimal.

Shougo commented 9 months ago

I have created the minimal vimrc.

set nocompatible

set runtimepath+=~/work/denops.vim
set runtimepath+=~/work/ddc.vim
set runtimepath+=~/src/ddc-source-file
set runtimepath+=~/work/ddc-filter-matcher_head
set runtimepath+=~/work/ddc-filter-sorter_rank
set runtimepath+=~/work/ddc-ui-native

" Customize global settings

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

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

call ddc#custom#patch_global('sourceOptions', {
      \ '_': {
      \   'matchers': ['matcher_head'],
      \   'ignoreCase': v:true,
      \   'sorters': ['sorter_rank'],
      \   'minAutoCompleteLength': 1},
      \ 'file': {
      \   'mark': 'F',
      \   'matchers': ['matcher_head'],
      \   'dup': v:true,
      \   'isVolatile': v:true,
      \   'forceCompletionPattern': '\S/\S*'},
      \ })

call ddc#custom#patch_global({
      \ 'sourceParams': {
      \   'file': {
      \     'projFromCwdMaxItems': [],
      \     'projFromBufMaxItems': [],
      \   }
      \ }
      \ })

" Use ddc.
call ddc#enable()

Please provide the instruction to reproduce your problem.

Shougo commented 9 months ago

@chunxuan-hs Why you only set the config for ['ps1', 'dosbatch', 'autohotkey', 'registry'] files? Because you have tested it on R files(r filetype).

chunxuan-hs commented 9 months ago

@Shougo The config is taken from the readme of this plugin, actually I am not sure about the meanings. See https://github.com/LumaKernel/ddc-source-file?tab=readme-ov-file#configuration

Shougo commented 9 months ago

Oh, you need to understand what you configure. Because it is ddc.vim's policy.

If so please test my minimal config.

chunxuan-hs commented 9 months ago

@Shougo @LumaKernel Thanks you all for helpful ideas, the new configs seem to work well:

call ddc#custom#patch_global({
      \ 'sourceParams': {
      \   'file': {
      \     'projFromCwdMaxItems': [],
      \     'projFromBufMaxItems': [],
      \     'bufMaxItems': 0,
      \   }
      \ }
      \ })