Skip to content

Commit 5dbd8c9

Browse files
authored
Merge pull request #18 from frederik-uni/static
Static hover
2 parents 4273608 + a5b9071 commit 5dbd8c9

File tree

14 files changed

+838
-309
lines changed

14 files changed

+838
-309
lines changed

Diff for: Cargo.lock

+11-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Cargo.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[workspace.package]
2-
version = "2.3.3"
2+
version = "2.3.4"
33
edition = "2021"
44

55
[workspace]
@@ -39,6 +39,7 @@ info-provider = { path = "./crates/info-provider" }
3939
crate_info = { path = "./crates/crate_info" }
4040
async-recursion = { version = "1" }
4141
byteorder = "1.5.0"
42-
42+
indexmap = "2.9.0"
43+
regex = "1.11.1"
4344
[patch.crates-io]
4445
html2md = { git = "https://gitlab.com/o0Frederik0o/html2md" }

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
- [x] available versions
5151
- [x] available features
5252
- [x] crate description(README)
53-
- [ ] Static
53+
- [x] Static
5454

5555
### Code completion
5656
- [ ] static manifest suggestions

Diff for: crates/lsp/src/lsp.rs

+47-9
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ use tower_lsp::lsp_types::{
1414
CodeActionProviderCapability, CodeActionResponse, Command, CompletionItem, CompletionItemKind,
1515
CompletionOptions, CompletionParams, CompletionResponse, CompletionTextEdit,
1616
DidChangeTextDocumentParams, DidChangeWorkspaceFoldersParams, DidOpenTextDocumentParams,
17-
DocumentFormattingParams, ExecuteCommandParams, Hover, HoverParams, HoverProviderCapability,
18-
InlayHint, InlayHintKind, InlayHintParams, MessageType, OneOf, Position, Range,
19-
ServerCapabilities, ServerInfo, SignatureHelpOptions, TextDocumentSyncCapability,
20-
TextDocumentSyncKind, TextDocumentSyncOptions, TextEdit, Url, WorkspaceEdit,
21-
WorkspaceFoldersServerCapabilities, WorkspaceServerCapabilities,
17+
DocumentFormattingParams, ExecuteCommandParams, Hover, HoverContents, HoverParams,
18+
HoverProviderCapability, InlayHint, InlayHintKind, InlayHintParams, MarkupKind, MessageType,
19+
OneOf, Position, Range, ServerCapabilities, ServerInfo, SignatureHelpOptions,
20+
TextDocumentSyncCapability, TextDocumentSyncKind, TextDocumentSyncOptions, TextEdit, Url,
21+
WorkspaceEdit, WorkspaceFoldersServerCapabilities, WorkspaceServerCapabilities,
2222
};
2323
use tower_lsp::{
2424
async_trait,
@@ -587,6 +587,40 @@ impl LanguageServer for Context {
587587
return Ok(Some(h));
588588
}
589589

590+
let path = lock
591+
.get_path(
592+
&uri,
593+
params.text_document_position_params.position.line,
594+
params.text_document_position_params.position.character,
595+
)
596+
.await;
597+
if let (Some(last), Some(path)) = (path.as_ref().and_then(|v| v.last()), &path) {
598+
let p = path
599+
.iter()
600+
.map(|v| v.tyoe.to_string())
601+
.collect::<Vec<String>>();
602+
let detail = try_option!(lock.static_data.get_detail(&p, 0, last.is_value()));
603+
let start = try_option!(lock.get_offset(&uri, last.range.start as usize));
604+
let end = try_option!(lock.get_offset(&uri, last.range.end as usize));
605+
606+
return Ok(Some(Hover {
607+
contents: HoverContents::Markup(tower_lsp::lsp_types::MarkupContent {
608+
kind: MarkupKind::PlainText,
609+
value: detail,
610+
}),
611+
range: Some(Range::new(
612+
Position {
613+
line: start.0 as u32,
614+
character: start.1 as u32,
615+
},
616+
Position {
617+
line: end.0 as u32,
618+
character: end.1 as u32,
619+
},
620+
)),
621+
}));
622+
}
623+
590624
Ok(None)
591625
}
592626

@@ -615,14 +649,14 @@ impl LanguageServer for Context {
615649
let start = try_option!(lock.get_offset(&uri, dep.start as usize));
616650
let end = try_option!(lock.get_offset(&uri, dep.end as usize));
617651

618-
return Ok(Some(CompletionResponse::Array(
652+
let out = Ok(Some(CompletionResponse::Array(
619653
info.into_iter()
620654
.enumerate()
621655
.map(|(i, v)| CompletionItem {
622-
label: v.name.clone(),
623-
kind: Some(CompletionItemKind::MODULE),
656+
label: format!("{i}. {}", v.name.clone()),
657+
// kind: Some(CompletionItemKind::MODULE),
624658
detail: v.description,
625-
preselect: Some(v.exact_match),
659+
// preselect: Some(v.exact_match),
626660
sort_text: Some(format!("{:06}", i)),
627661
text_edit: Some(CompletionTextEdit::Edit(TextEdit {
628662
range: Range {
@@ -666,6 +700,10 @@ impl LanguageServer for Context {
666700
})
667701
.collect(),
668702
)));
703+
self.client
704+
.log_message(MessageType::INFO, format!("{:#?}", out))
705+
.await;
706+
return out;
669707
}
670708
if let DepSource::Version { value, registry } = &dep.data.source {
671709
if value.value.contains(pos) {

Diff for: crates/old/parser/cargo.json

-188
This file was deleted.

Diff for: crates/old/parser/src/raw_to_tree.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl From<&Table> for Tree {
2929
let value = Value::from(value);
3030
TreeValue {
3131
value: match value.range() == Some(key.range) {
32-
true => Value::NoContent,
32+
true => value,
3333
false => value,
3434
},
3535
key,

Diff for: crates/parser/Cargo.toml

+5
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,8 @@ info-provider = { workspace = true }
1616
rust-version.workspace = true
1717
tokio = { workspace = true, features = ["sync"] }
1818
async-recursion.workspace = true
19+
indexmap = { workspace = true, features = ["serde"] }
20+
regex.workspace = true
21+
22+
[dev-dependencies]
23+
tokio = { workspace = true, features = ["full"] }

0 commit comments

Comments
 (0)