diff --git a/exp.txt b/exp.txt deleted file mode 100644 index ea96288..0000000 --- a/exp.txt +++ /dev/null @@ -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 - - - - diff --git a/lc.vim b/lc.vim index 86faa7a..4c877db 100644 --- a/lc.vim +++ b/lc.vim @@ -22,14 +22,15 @@ def GetMatch(base: string, line: string, add_base: bool): Item endif enddef -def GetMatches(base: string): list +def GetMatches(base: string, add_base: bool): list 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 =DoLSCmpl() +inoremap =DoLSCmpl() set completefunc=LineSuffixCompl