line completion working
This commit is contained in:
		
							
								
								
									
										32
									
								
								exp.txt
									
									
									
									
									
								
							
							
						
						
									
										32
									
								
								exp.txt
									
									
									
									
									
								
							@@ -1,32 +0,0 @@
 | 
				
			|||||||
 | 
					 | 
				
			||||||
fo
 | 
					 | 
				
			||||||
bar
 | 
					 | 
				
			||||||
bar
 | 
					 | 
				
			||||||
hello
 | 
					 | 
				
			||||||
bar
 | 
					 | 
				
			||||||
hello
 | 
					 | 
				
			||||||
hello
 | 
					 | 
				
			||||||
f
 | 
					 | 
				
			||||||
abcd
 | 
					 | 
				
			||||||
fo
 | 
					 | 
				
			||||||
hello
 | 
					 | 
				
			||||||
fo
 | 
					 | 
				
			||||||
bcd
 | 
					 | 
				
			||||||
hello world and ha ha ha
 | 
					 | 
				
			||||||
foo bar and ha ha ha
 | 
					 | 
				
			||||||
xdfadf bar and ha ha he
 | 
					 | 
				
			||||||
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
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
							
								
								
									
										27
									
								
								lc.vim
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								lc.vim
									
									
									
									
									
								
							@@ -22,14 +22,15 @@ def GetMatch(base: string, line: string, add_base: bool): Item
 | 
				
			|||||||
    endif
 | 
					    endif
 | 
				
			||||||
enddef
 | 
					enddef
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def GetMatches(base: string): list<string>
 | 
					def GetMatches(base: string, add_base: bool): list<string>
 | 
				
			||||||
    return getbufinfo()
 | 
					    return getbufinfo()
 | 
				
			||||||
 | 
					        ->filter( (_, bf) => bf.listed )
 | 
				
			||||||
        ->map( (_, buf) => getbufline(buf["bufnr"], 1, "$"))
 | 
					        ->map( (_, buf) => getbufline(buf["bufnr"], 1, "$"))
 | 
				
			||||||
        ->flattennew()
 | 
					        ->flattennew()
 | 
				
			||||||
        ->sort()
 | 
					        ->sort()
 | 
				
			||||||
        ->uniq()
 | 
					        ->uniq()
 | 
				
			||||||
        ->map( (_, v) => GetMatch(base, v, true) )
 | 
					        ->map( (_, v) => GetMatch(base, v, add_base) )
 | 
				
			||||||
        ->filter( (_, i) => i.len != 0 )
 | 
					        ->filter( (_, i) => i.len > 3 )
 | 
				
			||||||
        ->sort( (x, y) => y.len - x.len )
 | 
					        ->sort( (x, y) => y.len - x.len )
 | 
				
			||||||
        ->map( (_, i) => i.val )
 | 
					        ->map( (_, i) => i.val )
 | 
				
			||||||
enddef
 | 
					enddef
 | 
				
			||||||
@@ -38,25 +39,13 @@ def LineSuffixCompl(findstart: bool, base: string): any
 | 
				
			|||||||
    if findstart
 | 
					    if findstart
 | 
				
			||||||
        return 0
 | 
					        return 0
 | 
				
			||||||
    endif
 | 
					    endif
 | 
				
			||||||
    return GetMatches(base)
 | 
					    return GetMatches(base, true)
 | 
				
			||||||
enddef
 | 
					enddef
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def DoLSCmpl(): string
 | 
					def DoLSCmpl()
 | 
				
			||||||
    const base = getline('.')
 | 
					    GetMatches(getline('.'), false)->complete(col('.'))
 | 
				
			||||||
    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 ''
 | 
					 | 
				
			||||||
enddef
 | 
					enddef
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# inoremap <C-X><C-L> <C-R>=<SID>DoLSCmpl()<CR>
 | 
					inoremap <C-X><C-L> <C-R>=<SID>DoLSCmpl()<CR>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
set completefunc=LineSuffixCompl
 | 
					set completefunc=LineSuffixCompl
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user