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

Autocomplete / Display custom table types #384

Closed
gotschmarcel-ni opened this issue Feb 5, 2021 · 1 comment
Closed

Autocomplete / Display custom table types #384

gotschmarcel-ni opened this issue Feb 5, 2021 · 1 comment
Labels
enhancement New feature or request feat/LuaCats Annotations Related to Lua Language Server Annotations (LuaCats)

Comments

@gotschmarcel-ni
Copy link

gotschmarcel-ni commented Feb 5, 2021

It would be awesome if it was possible to describe custom tables that expect certain properties, similar to TypeScript's interface declarations:

interface SquareConfig {
  color?: string;
  width?: number;
}

I know it's already possible to do something like that via the @class and @field annotations, but using the class type for a parameter doesn't autocomplete or display the possible fields when calling the function.

Example:

---@class rectangle_props
---@field color string
local rectangle_props = {}

--- Creates a Rectangle
---@param props rectangle_props
---@return table rectangle
function make_rectangle(props)
    return {}
end

When calling make_rectangle it would be nice to see the allowed properties and even get them autocompleted within the table literal.

@sumneko sumneko added enhancement New feature or request feat/LuaCats Annotations Related to Lua Language Server Annotations (LuaCats) labels Feb 5, 2021
@gotschmarcel-ni
Copy link
Author

gotschmarcel-ni commented Feb 23, 2021

Thanks for implementing this so quickly. I just checked it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feat/LuaCats Annotations Related to Lua Language Server Annotations (LuaCats)
Projects
None yet
Development

No branches or pull requests

2 participants