Skip to content

Commit

Permalink
feat: lsp hover keyword highlight (#1331)
Browse files Browse the repository at this point in the history
* feat: syntax highlighting for hover content

Signed-off-by: shruti2522 <[email protected]>

fmt check

Signed-off-by: shruti2522 <[email protected]>

kcl formatting

Signed-off-by: shruti2522 <[email protected]>

fmt check

Signed-off-by: shruti2522 <[email protected]>

updated test cases

Signed-off-by: shruti2522 <[email protected]>

fmt check

Signed-off-by: shruti2522 <[email protected]>

feat: syntax highlighting for hover content

Signed-off-by: shruti2522 <[email protected]>

updated tests

Signed-off-by: shruti2522 <[email protected]>

updated tests

Signed-off-by: shruti2522 <[email protected]>

test check

Signed-off-by: shruti2522 <[email protected]>

feat: syntax highlighting for hover content

Signed-off-by: shruti2522 <[email protected]>

add markup

Signed-off-by: shruti2522 <[email protected]>

fmt check

Signed-off-by: shruti2522 <[email protected]>

resolved func formatting error

Signed-off-by: shruti2522 <[email protected]>

updated test cases

Signed-off-by: shruti2522 <[email protected]>

updated tests

Signed-off-by: shruti2522 <[email protected]>

feat: syntax highlighting for hover content

Signed-off-by: shruti2522 <[email protected]>

updated test cases for tests.rs

Signed-off-by: shruti2522 <[email protected]>

feat: syntax highlighting for hover content

Signed-off-by: shruti2522 <[email protected]>

syntax highlighting with LanguageString

Signed-off-by: shruti2522 <[email protected]>

fmt check

Signed-off-by: shruti2522 <[email protected]>

updated tests

Signed-off-by: shruti2522 <[email protected]>

fmt check

Signed-off-by: shruti2522 <[email protected]>

fmt check

Signed-off-by: shruti2522 <[email protected]>

feat: syntax highlighting for hover content

Signed-off-by: shruti2522 <[email protected]>

updated test case

Signed-off-by: shruti2522 <[email protected]>

updated tests.rs

Signed-off-by: shruti2522 <[email protected]>

feat: syntax highlighting for hover content

Signed-off-by: shruti2522 <[email protected]>

fmt check

Signed-off-by: shruti2522 <[email protected]>

fixed ci

Signed-off-by: shruti2522 <[email protected]>

add pkgpath without override

Signed-off-by: shruti2522 <[email protected]>

updated completion.rs

Signed-off-by: shruti2522 <[email protected]>

updated tests.rs

Signed-off-by: shruti2522 <[email protected]>

feat: syntax highlighting for hover content

Signed-off-by: shruti2522 <[email protected]>

updated doc style

Signed-off-by: shruti2522 <[email protected]>

fix ci

Signed-off-by: shruti2522 <[email protected]>

updated comment

Signed-off-by: shruti2522 <[email protected]>

added indentation for attrs

Signed-off-by: shruti2522 <[email protected]>

fix ci

Signed-off-by: shruti2522 <[email protected]>

merge schema attr docs

Signed-off-by: shruti2522 <[email protected]>

feat: syntax highlighting for hover content

Signed-off-by: shruti2522 <[email protected]>

update hover def comment

Signed-off-by: shruti2522 <[email protected]>

updated tests

Signed-off-by: shruti2522 <[email protected]>

feat: syntax highlighting for hover content

Signed-off-by: shruti2522 <[email protected]>

fix ci

Signed-off-by: shruti2522 <[email protected]>

render doc at end

Signed-off-by: shruti2522 <[email protected]>

fix ci

Signed-off-by: shruti2522 <[email protected]>

removed additional def

Signed-off-by: shruti2522 <[email protected]>

feat: syntax highlighting for hover content

Signed-off-by: shruti2522 <[email protected]>

fix ci

Signed-off-by: shruti2522 <[email protected]>

fix dict_key_in_schema test

Signed-off-by: shruti2522 <[email protected]>

merged rest_sign and attr

Signed-off-by: shruti2522 <[email protected]>

fixed ci

Signed-off-by: shruti2522 <[email protected]>

fmt check

Signed-off-by: shruti2522 <[email protected]>

feat: syntax highlighting for hover content

Signed-off-by: shruti2522 <[email protected]>

* feat: syntax highlighting for hover content

Signed-off-by: shruti2522 <[email protected]>

fmt check

Signed-off-by: shruti2522 <[email protected]>

kcl formatting

Signed-off-by: shruti2522 <[email protected]>

fmt check

Signed-off-by: shruti2522 <[email protected]>

updated test cases

Signed-off-by: shruti2522 <[email protected]>

fmt check

Signed-off-by: shruti2522 <[email protected]>

feat: syntax highlighting for hover content

Signed-off-by: shruti2522 <[email protected]>

updated tests

Signed-off-by: shruti2522 <[email protected]>

updated tests

Signed-off-by: shruti2522 <[email protected]>

test check

Signed-off-by: shruti2522 <[email protected]>

feat: syntax highlighting for hover content

Signed-off-by: shruti2522 <[email protected]>

add markup

Signed-off-by: shruti2522 <[email protected]>

fmt check

Signed-off-by: shruti2522 <[email protected]>

resolved func formatting error

Signed-off-by: shruti2522 <[email protected]>

updated test cases

Signed-off-by: shruti2522 <[email protected]>

updated tests

Signed-off-by: shruti2522 <[email protected]>

feat: syntax highlighting for hover content

Signed-off-by: shruti2522 <[email protected]>

updated test cases for tests.rs

Signed-off-by: shruti2522 <[email protected]>

feat: syntax highlighting for hover content

Signed-off-by: shruti2522 <[email protected]>

syntax highlighting with LanguageString

Signed-off-by: shruti2522 <[email protected]>

fmt check

Signed-off-by: shruti2522 <[email protected]>

updated tests

Signed-off-by: shruti2522 <[email protected]>

fmt check

Signed-off-by: shruti2522 <[email protected]>

fmt check

Signed-off-by: shruti2522 <[email protected]>

feat: syntax highlighting for hover content

Signed-off-by: shruti2522 <[email protected]>

updated test case

Signed-off-by: shruti2522 <[email protected]>

updated tests.rs

Signed-off-by: shruti2522 <[email protected]>

feat: syntax highlighting for hover content

Signed-off-by: shruti2522 <[email protected]>

fmt check

Signed-off-by: shruti2522 <[email protected]>

fixed ci

Signed-off-by: shruti2522 <[email protected]>

add pkgpath without override

Signed-off-by: shruti2522 <[email protected]>

updated completion.rs

Signed-off-by: shruti2522 <[email protected]>

updated tests.rs

Signed-off-by: shruti2522 <[email protected]>

feat: syntax highlighting for hover content

Signed-off-by: shruti2522 <[email protected]>

updated doc style

Signed-off-by: shruti2522 <[email protected]>

fix ci

Signed-off-by: shruti2522 <[email protected]>

updated comment

Signed-off-by: shruti2522 <[email protected]>

added indentation for attrs

Signed-off-by: shruti2522 <[email protected]>

fix ci

Signed-off-by: shruti2522 <[email protected]>

merge schema attr docs

Signed-off-by: shruti2522 <[email protected]>

feat: syntax highlighting for hover content

Signed-off-by: shruti2522 <[email protected]>

update hover def comment

Signed-off-by: shruti2522 <[email protected]>

updated tests

Signed-off-by: shruti2522 <[email protected]>

feat: syntax highlighting for hover content

Signed-off-by: shruti2522 <[email protected]>

fix ci

Signed-off-by: shruti2522 <[email protected]>

render doc at end

Signed-off-by: shruti2522 <[email protected]>

fix ci

Signed-off-by: shruti2522 <[email protected]>

removed additional def

Signed-off-by: shruti2522 <[email protected]>

feat: syntax highlighting for hover content

Signed-off-by: shruti2522 <[email protected]>

fix ci

Signed-off-by: shruti2522 <[email protected]>

fix dict_key_in_schema test

Signed-off-by: shruti2522 <[email protected]>

merged rest_sign and attr

Signed-off-by: shruti2522 <[email protected]>

fixed ci

Signed-off-by: shruti2522 <[email protected]>

fmt check

Signed-off-by: shruti2522 <[email protected]>

feat: syntax highlighting for hover content

Signed-off-by: shruti2522 <[email protected]>

* fmt check

Signed-off-by: shruti2522 <[email protected]>

* added MarkedStringType to hover

Signed-off-by: shruti2522 <[email protected]>

* fmt check

Signed-off-by: shruti2522 <[email protected]>

* add spaces and fix ci

Signed-off-by: shruti2522 <[email protected]>

* fix ci

Signed-off-by: shruti2522 <[email protected]>

* updated hover tests

Signed-off-by: shruti2522 <[email protected]>

* update pkgpath handling

Signed-off-by: shruti2522 <[email protected]>

* fmt check

Signed-off-by: shruti2522 <[email protected]>

---------

Signed-off-by: shruti2522 <[email protected]>
  • Loading branch information
shruti2522 authored May 22, 2024
1 parent 6bf352c commit dac7abf
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 86 deletions.
15 changes: 4 additions & 11 deletions kclvm/sema/src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ impl SchemaType {
}
}

pub fn schema_ty_signature_str(&self) -> String {
pub fn schema_ty_signature_str(&self) -> (String, String) {
let base: String = if let Some(base) = &self.base {
format!("({})", base.name)
} else {
Expand All @@ -312,17 +312,10 @@ impl SchemaType {
.join(", ")
)
};
let params_str = if !params.is_empty() && !base.is_empty() {
format!("\\{}{}", params, base)
} else if !params.is_empty() {
format!("{}", params)
} else if !base.is_empty() {
format!("{}", base)
} else {
"".to_string()
};

format!("{}\n\nschema {}{}", self.pkgpath, self.name, params_str)
let rest_sign = format!("schema {}{}{}:", self.name, params, base);

(self.pkgpath.clone(), rest_sign)
}

pub fn schema_ty_signature_no_pkg(&self) -> String {
Expand Down
8 changes: 5 additions & 3 deletions kclvm/tools/src/LSP/src/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,8 @@ fn schema_ty_to_value_complete_item(schema_ty: &SchemaType) -> KCLCompletionItem
);
let detail = {
let mut details = vec![];
details.push(schema_ty.schema_ty_signature_str());
let (pkgpath, rest_sign) = schema_ty.schema_ty_signature_str();
details.push(format!("{}\n\n{}", pkgpath, rest_sign));
details.push("Attributes:".to_string());
for (name, attr) in &schema_ty.attrs {
details.push(format!(
Expand Down Expand Up @@ -543,7 +544,8 @@ fn schema_ty_to_value_complete_item(schema_ty: &SchemaType) -> KCLCompletionItem
fn schema_ty_to_type_complete_item(schema_ty: &SchemaType) -> KCLCompletionItem {
let detail = {
let mut details = vec![];
details.push(schema_ty.schema_ty_signature_str());
let (pkgpath, rest_sign) = schema_ty.schema_ty_signature_str();
details.push(format!("{}\n\n{}", pkgpath, rest_sign));
details.push("Attributes:".to_string());
for (name, attr) in &schema_ty.attrs {
details.push(format!(
Expand Down Expand Up @@ -1259,7 +1261,7 @@ mod tests {
label: "Person(b){}".to_string(),
kind: Some(CompletionItemKind::CLASS),
detail: Some(
"__main__\n\nschema Person\\[b: int](Base)\nAttributes:\nc: int"
"__main__\n\nschema Person[b: int](Base):\nAttributes:\nc: int"
.to_string()
),
documentation: Some(lsp_types::Documentation::String("".to_string())),
Expand Down
Loading

0 comments on commit dac7abf

Please sign in to comment.