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

Suggest/complete primitive indexed fields #28

Open
Benjamin-Dobell opened this issue Jan 2, 2021 · 1 comment
Open

Suggest/complete primitive indexed fields #28

Benjamin-Dobell opened this issue Jan 2, 2021 · 1 comment
Labels
completion Pertains to auto-completion enhancement New feature or request

Comments

@Benjamin-Dobell
Copy link
Owner

Benjamin-Dobell commented Jan 2, 2021

Presently only named fields are suggested/completed.

For example:

---@class Vector
---@field x number
---@field y number
---@field [1] number
---@field [2] number

---@type Vector
local myVector

myVector.--<cursor here>

This will display a completion prompt that only includes the members x and y. However, it could also suggest [1] and [2] and upon completion delete the period.

Additionally, index expressions using brackets could similar be completed e.g.

myVector[--<cursor here>

If we're going to be completing all fields in brackets then we'll presumably want to prioritise primitive indexed fields over regular named fields and vice versa when completing fields after a period.

See #27 for initial report.

Considerations / Additional Thoughts

We're only going to be completing primitives, but what about aliases? e.g.

---@alias Color "Red" | "Blue"

---@class Palette
---@field [Color] number

---@type Palette
local palette

palette.--<cursor here>

Should we suggest "Red" and "Blue"?

We certainly can, however completion prompts ought to be very responsive, so minimising work is a good idea 😕

@Benjamin-Dobell Benjamin-Dobell added enhancement New feature or request completion Pertains to auto-completion labels Jan 2, 2021
@ChloeDawn
Copy link

ChloeDawn commented Apr 17, 2022

It would also be useful to have aliases auto-complete when used as an explicit argument to a function

---@alias Color "Red" | "Blue"
---@param color Color
function setColor(color) end

setColor(" --<suggest Color aliases>
---@param color Color | string
function setCustomColor(color) end

setCustomColor(" --<also suggest Color aliases>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
completion Pertains to auto-completion enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants