diff --git a/exp.txt b/exp.txt index 89eb9fc..ea96288 100644 --- a/exp.txt +++ b/exp.txt @@ -19,5 +19,14 @@ skafjds bar and ha ha ha hello ha ha ha foob and ha ha ha skafjds bar and ha ha ha +fjds bar and ha ha ha +a b c and ha ha ha + +var foo = SomeBigName(arg1, arg2, arg3) +var bar = SomeBigName(arg1, arg2, arg3) +var xyz = SomeBigName(arg1, arg2, arg3) +var xdf = Som + + diff --git a/lc.vim b/lc.vim index 5b2fc2e..6461fb1 100644 --- a/lc.vim +++ b/lc.vim @@ -1,28 +1,30 @@ vim9script -def GetMatch(b: string, l: string): list - var s = b - while stridx(l, s) == -1 +def GetMatch(base: string, line: string): list + var s = base + while stridx(line, s) == -1 s = strpart(s, 1) if strlen(s) == 0 return [0, ""] endif endwhile - const idx = stridx(l, s) + const idx = stridx(line, s) const slen = strlen(s) - return [slen, b .. strpart(l, idx + slen)] + return [slen, base .. strpart(line, idx + slen)] enddef -export def WholeLineCompl(f: bool, b: string): any - if f +def LineSuffixCompl(findstart: bool, base: string): any + if findstart return 0 endif - return getline(0, '$') + return getbufinfo() + ->map( (_, buf) => getbufline(buf["bufnr"], 1, "$")) + ->flattennew() ->sort() ->uniq() - ->map( (_, v) => GetMatch(b, v) ) + ->map( (_, v) => GetMatch(base, v) ) ->sort( (x, y) => y[0] - x[0] ) ->map( (_, v) => v[1] ) enddef -setlocal completefunc=WholeLineCompl +setlocal completefunc=LineSuffixCompl