@@ -5,15 +5,16 @@ use tracing::{error, info};
55use async_lsp:: lsp_types:: {
66 CompletionItem , CompletionItemKind , CompletionOptions , CompletionParams , CompletionResponse ,
77 CreateFilesParams , DeleteFilesParams , DidChangeConfigurationParams ,
8- DidChangeTextDocumentParams , DidCloseTextDocumentParams , DidOpenTextDocumentParams ,
9- DidSaveTextDocumentParams , DocumentFormattingParams , DocumentRangeFormattingParams ,
10- DocumentSymbolParams , DocumentSymbolResponse , FileOperationFilter , FileOperationPattern ,
11- FileOperationPatternKind , FileOperationRegistrationOptions , GotoDefinitionParams ,
12- GotoDefinitionResponse , Hover , HoverContents , HoverParams , HoverProviderCapability ,
13- InitializeParams , InitializeResult , Location , OneOf , PrepareRenameResponse , ReferenceParams ,
14- RenameFilesParams , RenameOptions , RenameParams , ServerCapabilities , ServerInfo ,
15- TextDocumentPositionParams , TextDocumentSyncCapability , TextDocumentSyncKind , TextEdit , Url ,
16- WorkspaceEdit , WorkspaceFileOperationsServerCapabilities , WorkspaceFoldersServerCapabilities ,
8+ DidChangeTextDocumentParams , DidChangeWorkspaceFoldersParams , DidCloseTextDocumentParams ,
9+ DidOpenTextDocumentParams , DidSaveTextDocumentParams , DocumentFormattingParams ,
10+ DocumentRangeFormattingParams , DocumentSymbolParams , DocumentSymbolResponse ,
11+ FileOperationFilter , FileOperationPattern , FileOperationPatternKind ,
12+ FileOperationRegistrationOptions , GotoDefinitionParams , GotoDefinitionResponse , Hover ,
13+ HoverContents , HoverParams , HoverProviderCapability , InitializeParams , InitializeResult ,
14+ Location , OneOf , PrepareRenameResponse , ReferenceParams , RenameFilesParams , RenameOptions ,
15+ RenameParams , ServerCapabilities , ServerInfo , TextDocumentPositionParams ,
16+ TextDocumentSyncCapability , TextDocumentSyncKind , TextEdit , Url , WorkspaceEdit ,
17+ WorkspaceFileOperationsServerCapabilities , WorkspaceFoldersServerCapabilities ,
1718 WorkspaceServerCapabilities ,
1819} ;
1920use async_lsp:: { LanguageClient , LanguageServer , ResponseError } ;
@@ -134,7 +135,7 @@ impl LanguageServer for ProtoLanguageServer {
134135 let current_package_name = tree. get_package_name ( content. as_bytes ( ) ) ;
135136
136137 let Some ( hv) = hv else {
137- error ! ( uri=%uri, "failed to get identifier" ) ;
138+ error ! ( uri=%uri, "failed to get hoverable identifier" ) ;
138139 return Box :: pin ( async move { Ok ( None ) } ) ;
139140 } ;
140141
@@ -153,6 +154,7 @@ impl LanguageServer for ProtoLanguageServer {
153154 } ) )
154155 } )
155156 }
157+
156158 fn completion (
157159 & mut self ,
158160 params : CompletionParams ,
@@ -288,11 +290,11 @@ impl LanguageServer for ProtoLanguageServer {
288290 } ;
289291
290292 let content = self . state . get_content ( & uri) ;
291- let identifier = tree. get_user_defined_text ( & pos, content. as_bytes ( ) ) ;
293+ let jump = tree. get_jumpable_at_position ( & pos, content. as_bytes ( ) ) ;
292294 let current_package_name = tree. get_package_name ( content. as_bytes ( ) ) ;
293295
294- let Some ( identifier ) = identifier else {
295- error ! ( uri=%uri, "failed to get identifier" ) ;
296+ let Some ( jump ) = jump else {
297+ error ! ( uri=%uri, "failed to get jump identifier" ) ;
296298 return Box :: pin ( async move { Ok ( None ) } ) ;
297299 } ;
298300
@@ -301,9 +303,10 @@ impl LanguageServer for ProtoLanguageServer {
301303 return Box :: pin ( async move { Ok ( None ) } ) ;
302304 } ;
303305
306+ let ipath = self . configs . get_include_paths ( & uri) . unwrap_or_default ( ) ;
304307 let locations = self
305308 . state
306- . definition ( current_package_name. as_ref ( ) , identifier . as_ref ( ) ) ;
309+ . definition ( & ipath , current_package_name. as_ref ( ) , jump ) ;
307310
308311 let response = match locations. len ( ) {
309312 0 => None ,
@@ -464,4 +467,12 @@ impl LanguageServer for ProtoLanguageServer {
464467 fn did_change_configuration ( & mut self , _: DidChangeConfigurationParams ) -> Self :: NotifyResult {
465468 ControlFlow :: Continue ( ( ) )
466469 }
470+
471+ // Required because when jumping to outside the workspace; this is triggered
472+ fn did_change_workspace_folders (
473+ & mut self ,
474+ _: DidChangeWorkspaceFoldersParams ,
475+ ) -> Self :: NotifyResult {
476+ ControlFlow :: Continue ( ( ) )
477+ }
467478}
0 commit comments