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

Support auto complete of callback arguments #460

Closed
gotschmarcel-ni opened this issue Mar 23, 2021 · 3 comments
Closed

Support auto complete of callback arguments #460

gotschmarcel-ni opened this issue Mar 23, 2021 · 3 comments
Labels
enhancement New feature or request feat/LuaCats Annotations Related to Lua Language Server Annotations (LuaCats) priority.normal A normal priority topic

Comments

@gotschmarcel-ni
Copy link

It would be awesome if functions that get passed as arguments (directly or via tables) to other functions get autocomplete for their argument types.

Examples

Directly pass a callback function to other function

---Work hard
---@param callback fun(value: number)
function work(callback)
    callback(22)
end

work(function (value)
  -- No autocomplete for value here
end)

or via custom table:

---@class work_item
---@field complete fun(value: number)
local work_item = {}

---Work hard
---@param item work_item
function work(item)
  item.complete(42)
end

work {
  complete = function (value)
    -- No autocomplete for value here
  end
}
@sumneko
Copy link
Collaborator

sumneko commented Mar 25, 2021

---@class Class
---@field x number
---@field y number

---@param callback fun(value: Class)
function work(callback)
end

work(function (value)
     value.$ -- provides `x` and `y` here
end)

Is this what you want?

@sumneko sumneko added the Info Needed More information is required label Mar 25, 2021
@gotschmarcel-ni
Copy link
Author

Yes, this is exactly what I mean.

@sumneko sumneko added feat/LuaCats Annotations Related to Lua Language Server Annotations (LuaCats) enhancement New feature or request and removed Info Needed More information is required labels Mar 25, 2021
@cryi
Copy link

cryi commented Apr 14, 2021

I need this as well. Do you need help?

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) priority.normal A normal priority topic
Projects
None yet
Development

No branches or pull requests

3 participants