kcl icon indicating copy to clipboard operation
kcl copied to clipboard

[LFX PreTest] pretest for LFX LSP hover content

Open He1pa opened this issue 1 year ago • 1 comments

pretest for https://github.com/kcl-lang/kcl/issues/1244

Provide keyword syntax highlight in lsp hover now: image

expect: image

pretest only needs to implement keyword highlighting, such as schema, Attribute, str, int

He1pa avatar May 10 '24 03:05 He1pa

@He1pa, can I work on this issue

Vishalk91-4 avatar May 11 '24 04:05 Vishalk91-4

@Peefy I worked on hover.rs chnaged few things in build_schema and inside the hover function

But, can you exactly tell what the change needs to look like and if you have a little idea on where I mean I get the current one, like I'm seeing the same thing on hovering in the above example for the expected one

Vishalk91-4 avatar May 13 '24 10:05 Vishalk91-4

cc @He1pa

Peefy avatar May 13 '24 11:05 Peefy

Hey @Peefy , i was understanding the code for the same and have made a PR regarding a test case for the same, please have a look. #1311 . Though it doesn't solve this issue but i'll get it done by my next PR.

d4v1d03 avatar May 13 '24 19:05 d4v1d03

@Peefy I worked on hover.rs chnaged few things in build_schema and inside the hover function

But, can you exactly tell what the change needs to look like and if you have a little idea on where I mean I get the current one, like I'm seeing the same thing on hovering in the above example for the expected one

I don't understand what your problem is. Our current hover is a text rendered in markdown format, like the first picture. But we need to optimize it and add syntax highlighting to some keywords, like in the second picture (this is Rust's hover by rust-analyzer). You need to investigate how to render colors in lsp hover. You can refer to other common language lsp practices. For example: https://github.com/rust-lang/rust-analyzer/blob/c0732c9f0f91bdc31d8da320be16d1db06c848d8/crates/rust-analyzer/src/handlers/request.rs#L1059

He1pa avatar May 15 '24 09:05 He1pa

Rust-analyzer solution does not seem to be suitable, it is highlighted through markdown code blocks, like

```rust some code ```

but ```kcl is not work in markdown. Maybe we can ref: https://github.com/tweag/nickel/blob/2c7dd14b5422ad4d7db6f3868db630d5482b2a75/lsp/nls/src/requests/hover.rs#L128

He1pa avatar May 20 '24 08:05 He1pa