mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
runtime(ccomplete): return partial results on complete_check()
closes: #17838 Signed-off-by: Maxim Kim <habamax@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
parent
b124b8d276
commit
44309b9d08
@ -3,7 +3,7 @@ vim9script noclear
|
|||||||
# Vim completion script
|
# Vim completion script
|
||||||
# Language: C
|
# Language: C
|
||||||
# Maintainer: The Vim Project <https://github.com/vim/vim>
|
# Maintainer: The Vim Project <https://github.com/vim/vim>
|
||||||
# Last Change: 2025 Jul 23
|
# Last Change: 2025 Jul 24
|
||||||
# Rewritten in Vim9 script by github user lacygoill
|
# Rewritten in Vim9 script by github user lacygoill
|
||||||
# Former Maintainer: Bram Moolenaar <Bram@vim.org>
|
# Former Maintainer: Bram Moolenaar <Bram@vim.org>
|
||||||
|
|
||||||
@ -82,9 +82,6 @@ export def Complete(findstart: bool, abase: string): any # {{{1
|
|||||||
var s: number = 0
|
var s: number = 0
|
||||||
var arrays: number = 0
|
var arrays: number = 0
|
||||||
while 1
|
while 1
|
||||||
if complete_check()
|
|
||||||
return v:none
|
|
||||||
endif
|
|
||||||
var e: number = base->charidx(match(base, '\.\|->\|\[', s))
|
var e: number = base->charidx(match(base, '\.\|->\|\[', s))
|
||||||
if e < 0
|
if e < 0
|
||||||
if s == 0 || base[s - 1] != ']'
|
if s == 0 || base[s - 1] != ']'
|
||||||
@ -107,9 +104,6 @@ export def Complete(findstart: bool, abase: string): any # {{{1
|
|||||||
s = e
|
s = e
|
||||||
++e
|
++e
|
||||||
while e < strcharlen(base)
|
while e < strcharlen(base)
|
||||||
if complete_check()
|
|
||||||
return v:none
|
|
||||||
endif
|
|
||||||
if base[e] == ']'
|
if base[e] == ']'
|
||||||
if n == 0
|
if n == 0
|
||||||
break
|
break
|
||||||
@ -146,7 +140,7 @@ export def Complete(findstart: bool, abase: string): any # {{{1
|
|||||||
var col2: number = col - 1
|
var col2: number = col - 1
|
||||||
while line[col2] != ';'
|
while line[col2] != ';'
|
||||||
if complete_check()
|
if complete_check()
|
||||||
return v:none
|
return res
|
||||||
endif
|
endif
|
||||||
--col2
|
--col2
|
||||||
endwhile
|
endwhile
|
||||||
@ -159,7 +153,7 @@ export def Complete(findstart: bool, abase: string): any # {{{1
|
|||||||
var col2: number = col - 1
|
var col2: number = col - 1
|
||||||
while line[col2] != ','
|
while line[col2] != ','
|
||||||
if complete_check()
|
if complete_check()
|
||||||
return v:none
|
return res
|
||||||
endif
|
endif
|
||||||
--col2
|
--col2
|
||||||
endwhile
|
endwhile
|
||||||
@ -200,10 +194,6 @@ export def Complete(findstart: bool, abase: string): any # {{{1
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if complete_check()
|
|
||||||
return v:none
|
|
||||||
endif
|
|
||||||
|
|
||||||
if len(items) == 1 || len(items) == arrays + 1
|
if len(items) == 1 || len(items) == arrays + 1
|
||||||
# Only one part, no "." or "->": complete from tags file.
|
# Only one part, no "." or "->": complete from tags file.
|
||||||
var tags: list<dict<any>>
|
var tags: list<dict<any>>
|
||||||
@ -226,10 +216,6 @@ export def Complete(findstart: bool, abase: string): any # {{{1
|
|||||||
res = res->extend(tags->map((_, v: dict<any>) => Tag2item(v)))
|
res = res->extend(tags->map((_, v: dict<any>) => Tag2item(v)))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if complete_check()
|
|
||||||
return v:none
|
|
||||||
endif
|
|
||||||
|
|
||||||
if len(res) == 0
|
if len(res) == 0
|
||||||
# Find the variable in the tags file(s)
|
# Find the variable in the tags file(s)
|
||||||
var diclist: list<dict<any>> = taglist('^' .. items[0] .. '$')
|
var diclist: list<dict<any>> = taglist('^' .. items[0] .. '$')
|
||||||
@ -240,7 +226,7 @@ export def Complete(findstart: bool, abase: string): any # {{{1
|
|||||||
res = []
|
res = []
|
||||||
for i: number in len(diclist)->range()
|
for i: number in len(diclist)->range()
|
||||||
if complete_check()
|
if complete_check()
|
||||||
return []
|
return res
|
||||||
endif
|
endif
|
||||||
# New ctags has the "typeref" field. Patched version has "typename".
|
# New ctags has the "typeref" field. Patched version has "typename".
|
||||||
if diclist[i]->has_key('typename')
|
if diclist[i]->has_key('typename')
|
||||||
@ -261,10 +247,6 @@ export def Complete(findstart: bool, abase: string): any # {{{1
|
|||||||
endfor
|
endfor
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if complete_check()
|
|
||||||
return v:none
|
|
||||||
endif
|
|
||||||
|
|
||||||
if len(res) == 0 && items[0]->searchdecl(true) == 0
|
if len(res) == 0 && items[0]->searchdecl(true) == 0
|
||||||
# Found, now figure out the type.
|
# Found, now figure out the type.
|
||||||
# TODO: join previous line if it makes sense
|
# TODO: join previous line if it makes sense
|
||||||
@ -278,7 +260,7 @@ export def Complete(findstart: bool, abase: string): any # {{{1
|
|||||||
var brackets: string = ''
|
var brackets: string = ''
|
||||||
while last >= 0
|
while last >= 0
|
||||||
if complete_check()
|
if complete_check()
|
||||||
return v:none
|
return res
|
||||||
endif
|
endif
|
||||||
if items[last][0] != '['
|
if items[last][0] != '['
|
||||||
break
|
break
|
||||||
@ -346,7 +328,7 @@ def Dict2info(dict: dict<any>): string # {{{1
|
|||||||
var info: string = ''
|
var info: string = ''
|
||||||
for k: string in dict->keys()->sort()
|
for k: string in dict->keys()->sort()
|
||||||
if complete_check()
|
if complete_check()
|
||||||
return ""
|
return info
|
||||||
endif
|
endif
|
||||||
info ..= k .. repeat(' ', 10 - strlen(k))
|
info ..= k .. repeat(' ', 10 - strlen(k))
|
||||||
if k == 'cmd'
|
if k == 'cmd'
|
||||||
@ -384,7 +366,7 @@ def ParseTagline(line: string): dict<any> # {{{1
|
|||||||
endif
|
endif
|
||||||
for i: number in range(n + 1, len(l) - 1)
|
for i: number in range(n + 1, len(l) - 1)
|
||||||
if complete_check()
|
if complete_check()
|
||||||
return {}
|
return d
|
||||||
endif
|
endif
|
||||||
if l[i] == 'file:'
|
if l[i] == 'file:'
|
||||||
d['static'] = 1
|
d['static'] = 1
|
||||||
@ -482,7 +464,7 @@ def Nextitem( # {{{1
|
|||||||
var res: list<dict<string>>
|
var res: list<dict<string>>
|
||||||
for tidx: number in len(tokens)->range()
|
for tidx: number in len(tokens)->range()
|
||||||
if complete_check()
|
if complete_check()
|
||||||
return []
|
return res
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Skip tokens starting with a non-ID character.
|
# Skip tokens starting with a non-ID character.
|
||||||
@ -510,9 +492,11 @@ def Nextitem( # {{{1
|
|||||||
# Use the tags file to find out if this is a typedef.
|
# Use the tags file to find out if this is a typedef.
|
||||||
var diclist: list<dict<any>> = taglist('^' .. tokens[tidx] .. '$')
|
var diclist: list<dict<any>> = taglist('^' .. tokens[tidx] .. '$')
|
||||||
for tagidx: number in len(diclist)->range()
|
for tagidx: number in len(diclist)->range()
|
||||||
if complete_check()
|
|
||||||
return []
|
if complete_check()
|
||||||
endif
|
return res
|
||||||
|
endif
|
||||||
|
|
||||||
var item: dict<any> = diclist[tagidx]
|
var item: dict<any> = diclist[tagidx]
|
||||||
|
|
||||||
# New ctags has the "typeref" field. Patched version has "typename".
|
# New ctags has the "typeref" field. Patched version has "typename".
|
||||||
@ -672,7 +656,7 @@ def StructMembers( # {{{1
|
|||||||
++idx
|
++idx
|
||||||
while 1
|
while 1
|
||||||
if complete_check()
|
if complete_check()
|
||||||
return []
|
return matches
|
||||||
endif
|
endif
|
||||||
if idx >= len(items)
|
if idx >= len(items)
|
||||||
return matches # No further items, return the result.
|
return matches # No further items, return the result.
|
||||||
@ -702,7 +686,7 @@ def SearchMembers( # {{{1
|
|||||||
var res: list<dict<string>>
|
var res: list<dict<string>>
|
||||||
for i: number in len(matches)->range()
|
for i: number in len(matches)->range()
|
||||||
if complete_check()
|
if complete_check()
|
||||||
return []
|
return res
|
||||||
endif
|
endif
|
||||||
var typename: string = ''
|
var typename: string = ''
|
||||||
var line: string
|
var line: string
|
||||||
|
Loading…
x
Reference in New Issue
Block a user