mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
docs(luacats): add tuple support
This commit is contained in:

committed by
Lewis Russell

parent
6566a59b3a
commit
d87ecfc8bc
@@ -170,7 +170,7 @@ local grammar = P {
|
|||||||
ltype = parenOpt(v.ty_union),
|
ltype = parenOpt(v.ty_union),
|
||||||
|
|
||||||
ty_union = v.ty_opt * rep(Pf('|') * v.ty_opt),
|
ty_union = v.ty_opt * rep(Pf('|') * v.ty_opt),
|
||||||
ty = v.ty_fun + ident + v.ty_table + literal + paren(v.ty) + v.ty_generic,
|
ty = v.ty_fun + ident + v.ty_table + literal + paren(v.ty) + v.ty_generic + v.ty_tuple,
|
||||||
ty_param = Pf('<') * comma1(v.ltype) * fill * P('>'),
|
ty_param = Pf('<') * comma1(v.ltype) * fill * P('>'),
|
||||||
ty_opt = v.ty * opt(v.ty_param) * opt(P('[]')) * opt(P('?')),
|
ty_opt = v.ty * opt(v.ty_param) * opt(P('[]')) * opt(P('?')),
|
||||||
ty_index = (Pf('[') * (v.ltype + ident + rep1(num)) * fill * P(']')),
|
ty_index = (Pf('[') * (v.ltype + ident + rep1(num)) * fill * P(']')),
|
||||||
@@ -180,6 +180,7 @@ local grammar = P {
|
|||||||
fun_param = lname * opt(colon * v.ltype),
|
fun_param = lname * opt(colon * v.ltype),
|
||||||
ty_fun = Pf('fun') * paren(comma(lname * opt(colon * v.ltype))) * opt(colon * comma1(v.ltype)),
|
ty_fun = Pf('fun') * paren(comma(lname * opt(colon * v.ltype))) * opt(colon * comma1(v.ltype)),
|
||||||
ty_generic = P('`') * letter * P('`'),
|
ty_generic = P('`') * letter * P('`'),
|
||||||
|
ty_tuple = Pf('[') * comma(v.ty_opt) * fill * P(']')
|
||||||
}
|
}
|
||||||
|
|
||||||
return grammar --[[@as nvim.luacats.grammar]]
|
return grammar --[[@as nvim.luacats.grammar]]
|
||||||
|
@@ -159,4 +159,11 @@ describe('luacats grammar', function()
|
|||||||
name = 'type',
|
name = 'type',
|
||||||
type = '`T`',
|
type = '`T`',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('@param type [number,string] this is a tuple type', {
|
||||||
|
desc = 'this is a tuple type',
|
||||||
|
kind = 'param',
|
||||||
|
name = 'type',
|
||||||
|
type = '[number,string]',
|
||||||
|
})
|
||||||
end)
|
end)
|
||||||
|
Reference in New Issue
Block a user