kcl-lang / kcl

KCL Programming Language (CNCF Sandbox Project). https://kcl-lang.io
https://kcl-lang.io
Apache License 2.0
1.59k stars 113 forks source link

Show default values from models preview in the KCL language server #1578

Open soubinan opened 1 month ago

soubinan commented 1 month ago

Enhancement

What we have today image

The corresponding model is

schema DataGroup:
    class = "Data_Group"
    remark?: str
    keyDataType: "integer" | "ip" | "string" = "string"
    records: [Record]

Would be very useful to have default values from the preview so the user could know what are the default values at the time he wants to instanciate a configuration from a given model.

Peefy commented 1 month ago

Good Ideas! cc @He1pa

He1pa commented 1 month ago

good idea. I will impl this feature later

soubinan commented 1 month ago

Thank you @He1pa, I could say the case is applicable to lambdas functions too

Peefy commented 1 week ago

I would like to add that we can also add index signature hover information to the schema. e.g.,

schema Config[foo:str, bar:str]:
    [...str]: any
    domain: str = foo
    name: str = bar
    abc?: str = ""
    xyz?: bool = False