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

[LFX] [Track] LSP inlayhint and hover content content optimization #1244

Closed
He1pa opened this issue Apr 24, 2024 · 9 comments · Fixed by #1431
Closed

[LFX] [Track] LSP inlayhint and hover content content optimization #1244

He1pa opened this issue Apr 24, 2024 · 9 comments · Fixed by #1431
Assignees
Labels
good first issue Good for newcomers help wanted Extra attention is needed lsp

Comments

@He1pa
Copy link
Contributor

He1pa commented Apr 24, 2024

Enhancement

Task

  1. Provide type inlay hint as shown below to improve the readability of kcl code
    image

  2. Optimize the display content of hover, including but not limited to better styles, indentation, highlighting, hyperlinks, etc.

Pretest

#1304

@Peefy Peefy changed the title [Track] LSP inlayhint and hover content content optimization [LFX] [Track] LSP inlayhint and hover content content optimization Apr 24, 2024
@Peefy Peefy added help wanted Extra attention is needed good first issue Good for newcomers lsp labels Apr 26, 2024
@Peefy Peefy added this to the v0.9.0 Release milestone Apr 26, 2024
@Peefy
Copy link
Contributor

Peefy commented May 4, 2024

cc @He1pa The first one maybe the pretest.

@d4v1d03
Copy link
Contributor

d4v1d03 commented May 10, 2024

Hey @Peefy , @He1pa , what's the pre-test being decided for the same.

@literalEval
Copy link

@He1pa the pretest for this project seems to be closed. What tasks do new applicants need to do for selection ? Thanks.

@Peefy Peefy removed this from the v0.9.0 Release milestone Jul 1, 2024
@shruti2522
Copy link
Contributor

KCL Inlay Hints

1. Introduction

  • Inlay hints are provided for the cases when there is no explicit type declaration.
  • [x] is used for the hints where x represents the type name.
  • Hints are displayed only for left valued variables without explicit type annotations.

2. Design principles

TypeKind::Str|Int|Float|Bool|Any

  • Hints show the type enclosed in brackets [: x] if it is not already assigned.
    Examples:
    • int/float: n [: float] = 1
    • str: x [: str] = "kcl"
    • bool: value [: bool] = True
    • any: func = lambda x [: any] { x }

TypeKind::Schema

  • schema definition:

    for example,

    schema Persons:
      n1 [: int] = n - 1
      n2 [: int] = n1 - 1
      n: int
      value: int
    

    No inlay hints applied for the following cases:

    • schema signature string

      schema Persons:
      
    • schema attributes with type definition

        n: int
        value: int
      
  • schema assign statements:

    • for type definition no hints are provided

      p: Person = Person{}
      
    • hints when there is no type definition

      p [: Person] = Person{}
      

TypeKind::Function

  • for function definition

    func = lambda x[: any]{
          x
    }
    
  • for function call

    z = func([x:] y)
    

    where, y is the argument and x is the param name in func definition.

  • no inlay hints for builtin function calls

TypeKind::List

  • for list assignments

    _list1 [: [int]] = [1, 2, 3]
    _list2 [: [str]] = ["kcl","lang"]
    

TypeKind::Dict

  • for dict assignments

    data1 [: {str:str}] = {
      if False: "key1": "value1"
      "key2": "value2"
      if True: "key3": "value3"
    }
    

TypeKind::NumberMultiplier

  • for number multiplier assign stmts

    x0: units.NumberMultiplier = 1M
    x1 [: number_multiplier] = x0
    

TypeKind::Union

  • for union types the name of the union type is provided as inlay hint

    type num = int | float
    n [: num] = 1
    
  • no inlay hint for type assignment

    n: num = 1
    

@shruti2522
Copy link
Contributor

shruti2522 commented Jul 1, 2024

cc @He1pa @Peefy
I will create separate PRs for each implementation in the above design doc. Please assign.

@Peefy
Copy link
Contributor

Peefy commented Aug 14, 2024

Closed by #1468, #1473, #1488 and #1491

@Peefy Peefy closed this as completed Aug 14, 2024
@Peefy
Copy link
Contributor

Peefy commented Aug 15, 2024

fyi #1575

cc @shruti2522 @He1pa

@shruti2522
Copy link
Contributor

fyi #1575

cc @shruti2522 @He1pa

working on it @Peefy

@Peefy
Copy link
Contributor

Peefy commented Aug 15, 2024

Good Job! @shruti2522 Thank you! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed lsp
Projects
None yet
5 participants