Skip to content

nested tables and multiple ones in autocomplete of custom tables #407

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

Closed
serg3295 opened this issue Feb 21, 2021 · 9 comments
Closed

nested tables and multiple ones in autocomplete of custom tables #407

serg3295 opened this issue Feb 21, 2021 · 9 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@serg3295
Copy link
Contributor

Question
Is it possible to implement support nested tables and multiple ones in autocomplete of custom tables for the function?

---@class GpioConfig
---@field gpio integer|table
---@field dir integer
---@field opendrain integer
---@field pull integer

---Configure GPIO mode for one or more pins.
---@param tbl GpioConfig List of configuration tables:
---**gpio** one or more (given as list) pins,
---**dir** direction
---**opendrain** 1 enables opendrain mode, defaults to 0 if omitted
---**pull** enable pull-up and -down resistors
---@vararg GpioConfig
---@return nil
function gpio.config(tbl, ...) end

gpio.config( { gpio={19,21}, dir=gpio.OUT }, { gpio=22, dir=gpio.IN, pull=gpio.PULL_UP } )

Expected behavior

  1. don't show table fields in nested table e.g. gpio={
  2. get properties autocompleted within the next table { } , { }
  3. allow input arbitrary index e.g. [1] = gpio.HIGH within the table
@sumneko sumneko added the enhancement New feature or request label Feb 21, 2021
@sumneko sumneko added the bug Something isn't working label Mar 16, 2021
@sumneko
Copy link
Collaborator

sumneko commented Mar 16, 2021

3. allow input arbitrary index e.g. [1] = gpio.HIGH within the table

Im not understand this, could you please tell more detail?

sumneko added a commit that referenced this issue Mar 16, 2021
@serg3295
Copy link
Contributor Author

This does not apply to auto-completion. Previously, there was a situation where the first bracket [ caused an error. See #400 Everything is currently working well.

@sumneko
Copy link
Collaborator

sumneko commented Mar 16, 2021

I dont know what should be applied when [1] = gpio.HIGH

@serg3295
Copy link
Contributor Author

My English is not good, and Google Translate doesn't always help. 😕
[1] = ... does not require any processing or automatic completion.

@sumneko
Copy link
Collaborator

sumneko commented Mar 16, 2021

Could you provide an example like this:

---@class C
---@field xxx number

---@type C
local t = {
    $ -- provide 'xxx' here
}

@serg3295
Copy link
Contributor Author

gpio.mode(1, gpio.OUTPUT)
gpio.mode(2, gpio.OUTPUT)

pulser = gpio.pulse.build( {
  { [1] = gpio.HIGH, [2] = gpio.LOW, delay=250000 },
  { [1] = gpio.LOW, [2] = gpio.HIGH, delay=250000, loop=1, count=20, min=240000, max=260000 }
})

pulser:start(function() print ('done') end)

@serg3295
Copy link
Contributor Author

---@class GpioPulse
---@field delay integer
---@field min integer
---@field max integer
---@field count integer
---@field loop integer

---This builds the `gpio.pulse` object from the supplied argument
---@param tbl GpioPulse this is view as an array of instructions. Each instruction is represented by a table as follows:
--**[pin] = gpio.level** For example { [1] = gpio.HIGH, }. All numeric keys are considered to be pin numbers. The values of each are the value to be set onto the respective GPIO line.
--**delay** specifies the number of microseconds after setting the pin values to wait until moving to the next state.
--**min** and **max** can be used to specify (along with delay) that this time can be varied.
--**count** and **loop** allow simple looping.
---@vararg GpioPulse
---@return pulser obj gpio.pulse object.
function gpio.pulse.build(tbl, ...) end

@sumneko
Copy link
Collaborator

sumneko commented Mar 16, 2021

Please confirm whether the problem you mentioned in the latest version still exists, if it exists, please provide a screenshot or gif

@serg3295
Copy link
Contributor Author

Do you mean the problem with [1] ? No this problem anymore . It is now working properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants