line completion working

This commit is contained in:
2025-09-08 22:55:27 -04:00
parent c6e2d2a8f4
commit caa42275f6
2 changed files with 8 additions and 51 deletions

27
lc.vim
View File

@@ -22,14 +22,15 @@ def GetMatch(base: string, line: string, add_base: bool): Item
endif
enddef
def GetMatches(base: string): list<string>
def GetMatches(base: string, add_base: bool): list<string>
return getbufinfo()
->filter( (_, bf) => bf.listed )
->map( (_, buf) => getbufline(buf["bufnr"], 1, "$"))
->flattennew()
->sort()
->uniq()
->map( (_, v) => GetMatch(base, v, true) )
->filter( (_, i) => i.len != 0 )
->map( (_, v) => GetMatch(base, v, add_base) )
->filter( (_, i) => i.len > 3 )
->sort( (x, y) => y.len - x.len )
->map( (_, i) => i.val )
enddef
@@ -38,25 +39,13 @@ def LineSuffixCompl(findstart: bool, base: string): any
if findstart
return 0
endif
return GetMatches(base)
return GetMatches(base, true)
enddef
def DoLSCmpl(): string
const base = getline('.')
const lines = getbufinfo()
->map( (_, buf) => getbufline(buf["bufnr"], 1, "$"))
->flattennew()
->sort()
->uniq()
->map( (_, v) => GetMatch(base, v, v:false) )
->filter( (_, v) => GetMatch(base, v, v:false) )
->sort( (x, y) => y[0] - x[0] )
->map( (_, v) => v[1] )
complete(col('.'), lines)
return ''
def DoLSCmpl()
GetMatches(getline('.'), false)->complete(col('.'))
enddef
# inoremap <C-X><C-L> <C-R>=<SID>DoLSCmpl()<CR>
inoremap <C-X><C-L> <C-R>=<SID>DoLSCmpl()<CR>
set completefunc=LineSuffixCompl