This commit is contained in:
Balakrishnan Balasubramanian 2023-05-29 13:22:17 -04:00
parent a1c5082583
commit 4e887415c1
2 changed files with 21 additions and 10 deletions

View File

@ -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

22
lc.vim
View File

@ -1,28 +1,30 @@
vim9script
def GetMatch(b: string, l: string): list<any>
var s = b
while stridx(l, s) == -1
def GetMatch(base: string, line: string): list<any>
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