@@ -14,11 +14,11 @@ use tower_lsp::lsp_types::{
14
14
CodeActionProviderCapability , CodeActionResponse , Command , CompletionItem , CompletionItemKind ,
15
15
CompletionOptions , CompletionParams , CompletionResponse , CompletionTextEdit ,
16
16
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 ,
22
22
} ;
23
23
use tower_lsp:: {
24
24
async_trait,
@@ -587,6 +587,40 @@ impl LanguageServer for Context {
587
587
return Ok ( Some ( h) ) ;
588
588
}
589
589
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
+
590
624
Ok ( None )
591
625
}
592
626
@@ -615,14 +649,14 @@ impl LanguageServer for Context {
615
649
let start = try_option ! ( lock. get_offset( & uri, dep. start as usize ) ) ;
616
650
let end = try_option ! ( lock. get_offset( & uri, dep. end as usize ) ) ;
617
651
618
- return Ok ( Some ( CompletionResponse :: Array (
652
+ let out = Ok ( Some ( CompletionResponse :: Array (
619
653
info. into_iter ( )
620
654
. enumerate ( )
621
655
. 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),
624
658
detail : v. description ,
625
- preselect : Some ( v. exact_match ) ,
659
+ // preselect: Some(v.exact_match),
626
660
sort_text : Some ( format ! ( "{:06}" , i) ) ,
627
661
text_edit : Some ( CompletionTextEdit :: Edit ( TextEdit {
628
662
range : Range {
@@ -666,6 +700,10 @@ impl LanguageServer for Context {
666
700
} )
667
701
. collect ( ) ,
668
702
) ) ) ;
703
+ self . client
704
+ . log_message ( MessageType :: INFO , format ! ( "{:#?}" , out) )
705
+ . await ;
706
+ return out;
669
707
}
670
708
if let DepSource :: Version { value, registry } = & dep. data . source {
671
709
if value. value . contains ( pos) {
0 commit comments