No examples of argTypes on README.md
Opened this issue · 2 comments
README.md
lacks an example of field argTypes
in .luacompleterc
. I tried to write like the following but it didn't seem to have any effect.
"namedTypes": {
"cat": {
"type": "table",
"fields": {
"color": { "type": "string" },
"is_fluffy": { "type": "boolean" },
"meow":
{
"type": "function",
"args": [{ "name": "self" }, { "name": "arg1" }, { "name": "arg2" }],
"argTypes": [{ "type": "ref", "name": "cat" }, { "type": "ref", "name": "cat" }, { "type": "ref", "name": "cat" }],
"returnTypes": [{ "type": "ref", "name": "cat" }]
}
}
}
},
My expectation was that with a settings like the above, I will be able to see an autocomplete based on the type:
function cat.meow(self, arg1, arg2)
arg1. -- ... autocomplete?
end
Is argTypes not supposed to work that way?
I believe that is how it's supposed to work, yes.
I'm new to this extension and it might be I'm misunderstanding a thing or two. I'd like to ask you to take a look at my settings and if anything is missing.
I think my problem is when I get the type cat from a global function like make_a_cat()
then the autocomplete works beautifully. But when I try to define a cat
object from scratch like in cat.lua
, I don't see any suggestions.
I'm hoping to be able to see dropdown suggestions for type cat
in cat.lua
, and especially type inference for arg1
as cat
when I'm writing the implementation of function cat.meow()
. Could you please advise how I can achieve it?
~/.luacompleterc
{
"global": {
"type": "table",
"fields": {
"make_a_cat": {
"type": "function",
"returnTypes": [{ "type": "ref", "name": "cat" }]
},
"make_a_cat_somehow_else": {
"type": "function",
"returnTypes": [{ "type": "ref", "name": "cat" }]
}
}
},
"namedTypes":
{
"student":
{ // Type definition for a student
"type": "table",
"fields": {
"name": { "type": "string" },
"surname": { "type": "string" },
"height": { "type": "number" }
},
"metatable": {
"type": "table",
"fields": {
"__index": {
"type": "table",
"fields": { "skip_rope": { "type": "function" } }
}
}
}
}
"cat": {
"type": "table",
"fields": {
"color": { "type": "string" },
"is_fluffy": { "type": "boolean" },
"meow":
{
"type": "function",
"args": [{ "name": "self" }, { "name": "arg1" }, { "name": "arg2" }],
"argTypes": [{ "type": "ref", "name": "cat" }, { "type": "ref", "name": "cat" }, { "type": "ref", "name": "cat" }],
"returnTypes": [{ "type": "ref", "name": "cat" }]
}
}
}
}
}
~/cat.lua
local cat = {}
function cat.meow(self, arg1, arg2)
cat. -- ... autocomplete?
end
student. -- no autocompletion
return cat