Initializes the server.
(&self, workspace_root: Option<String>)
| 634 | |
| 635 | /// Initializes the server. |
| 636 | pub async fn initialize(&self, workspace_root: Option<String>) -> Result<InitializeResult> { |
| 637 | info!("Initializing LSP server: {}", self.id); |
| 638 | |
| 639 | let root_uri = workspace_root.as_ref().map(|path| { |
| 640 | if cfg!(windows) { |
| 641 | format!("file:///{}", path.replace('\\', "/")) |
| 642 | } else { |
| 643 | format!("file://{}", path) |
| 644 | } |
| 645 | }); |
| 646 | |
| 647 | let workspace_folders = workspace_root.as_ref().map(|root| { |
| 648 | let uri = if cfg!(windows) { |
| 649 | format!("file:///{}", root.replace('\\', "/")) |
| 650 | } else { |
| 651 | format!("file://{}", root) |
| 652 | }; |
| 653 | |
| 654 | let name = std::path::Path::new(root) |
| 655 | .file_name() |
| 656 | .and_then(|n| n.to_str()) |
| 657 | .unwrap_or("workspace") |
| 658 | .to_string(); |
| 659 | |
| 660 | vec![WorkspaceFolder { uri, name }] |
| 661 | }); |
| 662 | |
| 663 | let params = InitializeParams { |
| 664 | process_id: Some(std::process::id()), |
| 665 | root_path: None, |
| 666 | root_uri: root_uri.clone(), |
| 667 | capabilities: ClientCapabilities { |
| 668 | window: Some(serde_json::json!({ |
| 669 | "workDoneProgress": true, |
| 670 | "showMessage": { |
| 671 | "messageActionItem": { |
| 672 | "additionalPropertiesSupport": false |
| 673 | } |
| 674 | }, |
| 675 | "showDocument": { |
| 676 | "support": true |
| 677 | } |
| 678 | })), |
| 679 | |
| 680 | workspace: Some(serde_json::json!({ |
| 681 | "applyEdit": true, |
| 682 | "workspaceEdit": { |
| 683 | "documentChanges": true, |
| 684 | "resourceOperations": ["create", "rename", "delete"] |
| 685 | }, |
| 686 | "didChangeConfiguration": { |
| 687 | "dynamicRegistration": false |
| 688 | }, |
| 689 | "didChangeWatchedFiles": { |
| 690 | "dynamicRegistration": false |
| 691 | }, |
| 692 | "symbol": { |
| 693 | "dynamicRegistration": false |
nothing calls this directly
no test coverage detected