Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No examples of argTypes on README.md #30

Open
iMatthias opened this issue Aug 7, 2019 · 2 comments
Open

No examples of argTypes on README.md #30

iMatthias opened this issue Aug 7, 2019 · 2 comments

Comments

@iMatthias
Copy link

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?

@dapetcu21
Copy link
Owner

I believe that is how it's supposed to work, yes.

@iMatthias
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants