Coder Social home page Coder Social logo

ddc-source-file's Introduction

ddc-file

Doc

Powerful and performant file name completion for ddc.vim.

Required

Configuration

call ddc#custom#patch_global('sources', ['file'])
call ddc#custom#patch_global('sourceOptions', {
    \ 'file': {
    \   'mark': 'F',
    \   'isVolatile': v:true,
    \   'forceCompletionPattern': '\S/\S*',
    \ }})
call ddc#custom#patch_filetype(
    \ ['ps1', 'dosbatch', 'autohotkey', 'registry'], {
    \ 'sourceOptions': {
    \   'file': {
    \     'forceCompletionPattern': '\S\\\S*',
    \   },
    \ },
    \ 'sourceParams': {
    \   'file': {
    \     'mode': 'win32',
    \   },
    \ }})

ddc-source-file's People

Contributors

hokorobi avatar lumakernel avatar shougo avatar shun avatar ujihisa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ddc-source-file's Issues

ddc_file#internal#info() is broken

diff --git a/autoload/ddc_file/internal.vim b/autoload/ddc_file/internal.vim
index 8b50071..c8b900c 100644
--- a/autoload/ddc_file/internal.vim
+++ b/autoload/ddc_file/internal.vim
@@ -22,9 +22,8 @@ endfunction
 "   string,
 "   string,
 " ]}
-function! ddc_file#internal#info(is_posix) abort
-  let input_line = getline('.')[: col('.') - 2]
-  let input_file_full = s:line_to_file_full(input_line, a:is_posix)
+function! ddc_file#internal#info(is_posix, input_line) abort
+  let input_file_full = s:line_to_file_full(a:input_line, a:is_posix)
   let input_file_base_prefix = s:full_to_base_prefix(input_file_full, a:is_posix)
   let buf_path = expand('%:p')
   return [
diff --git a/denops/@ddc-file/internal_autoload_fn.ts b/denops/@ddc-file/internal_autoload_fn.ts
index beabbac..a2edefb 100644
--- a/denops/@ddc-file/internal_autoload_fn.ts
+++ b/denops/@ddc-file/internal_autoload_fn.ts
@@ -12,6 +12,7 @@ const createCaller = (name: string): any => {
 export type Info = (
   denops: Denops,
   isPosix: boolean,
+  inputLine: string,
 ) => Promise<[
   string,
   string,
diff --git a/denops/@ddc-sources/file.ts b/denops/@ddc-sources/file.ts
index 00173b6..f87518d 100644
--- a/denops/@ddc-sources/file.ts
+++ b/denops/@ddc-sources/file.ts
@@ -80,6 +80,7 @@ export class Source extends BaseSource<Params> {
     const [inputFileFull, inputFileBasePrefix, bufPath] = await internal.info(
       args.denops,
       mode === "posix",
+      args.context.input,
     );

     // e.g. '/home/ubuntu/config' for inputFileFull = '~/config'

Please don't use getline() in source.
It does not work in command line.

bug: cannot use matcher other than matcher_head

my japanese brain dump matcher_head 互換のフィルターしか使えず、かつ、matcher_head 相当の機能しか提供できない

#4 を考慮する必要がある

matcher は search(input) が matched の 部分列 (sub sequence) であることは多分仮定していい。 (matcher_reversed のようなものは現実的に意味がない)
これに加えてもう一つ仮定を加えるとおそらく対処法がある。
「 ∀a, a',b,c; match(a+b, a'+c) && match(a, a') ⇒ match(b, c)」とかだと思う。(要検討)

もしくは matcher_head 以外サポートしないか。

EDIT:

now we can use only matcher_head like behavior even if setting matchers.
it is fixed by sending all filenames.

we should take care about #4, but it can be resolved by sending with cutting common-prefix ending with non-keyword. please read #7 's test for details.

bug: non-keyword completion

.git
image

aaaa.bbbb.cccc.dddd
image

I've already implemented the solution.

My brain dump:
inpt: input
actu: acutual
want: want
slic: sliced actual by input
trai: trailing isk of input

inpt: a
actu: aaaa.bbbb.cccc.dddd
want: aaaa.bbbb.cccc.dddd
slic:  __________________
trai: -

inpt: aa
actu: aaaa.bbbb.cccc.dddd
want: aaaa.bbbb.cccc.dddd
slic:   _________________
trai: --

inpt: aaaa
actu: aaaa.bbbb.cccc.dddd
want: aaaa.bbbb.cccc.dddd

inpt: aaaa.
actu: aaaa.bbbb.cccc.dddd
want:     .bbbb.cccc.dddd
slic:      ______________
trai:

inpt: aaaa.b
actu: aaaa.bbbb.cccc.dddd
want:      bbbb.cccc.dddd
slic:       _____________
trai:      -

inpt: aaaa.bbbb
actu: aaaa.bbbb.cccc.dddd
want:      bbbb.cccc.dddd
slic:          __________
trai:      ----

inpt: aaaa.bbbb.
actu: aaaa.bbbb.cccc.dddd
want:           cccc.dddd
slic:           _________
trai:

feature: Add vim path variable completion support

Thanks for your work!
Can you add vim variable path completion support?
For example, here's a path variable named $VIM_PATH, which is let $VIM_PATH = fnamemodify(resolve(expand('<sfile>:p')), ':h:h') , I want to get completion infomation when I type VIM_PATH/, any idea for this? Thanks.

how to list files in the curret cwd only?

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.