diff options
Diffstat (limited to 'crates/ra_lsp_server')
-rw-r--r-- | crates/ra_lsp_server/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/caps.rs | 11 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/main_loop.rs | 2 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/handlers.rs | 2 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/req.rs | 27 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/world.rs | 20 |
6 files changed, 20 insertions, 44 deletions
diff --git a/crates/ra_lsp_server/Cargo.toml b/crates/ra_lsp_server/Cargo.toml index e29b688fd..e826c10ef 100644 --- a/crates/ra_lsp_server/Cargo.toml +++ b/crates/ra_lsp_server/Cargo.toml | |||
@@ -14,7 +14,7 @@ serde_json = "1.0.34" | |||
14 | serde = { version = "1.0.83", features = ["derive"] } | 14 | serde = { version = "1.0.83", features = ["derive"] } |
15 | crossbeam-channel = "0.4" | 15 | crossbeam-channel = "0.4" |
16 | log = "0.4.3" | 16 | log = "0.4.3" |
17 | lsp-types = { version = "0.63.1", features = ["proposed"] } | 17 | lsp-types = { version = "0.65.0", features = ["proposed"] } |
18 | rustc-hash = "1.0" | 18 | rustc-hash = "1.0" |
19 | parking_lot = "0.10.0" | 19 | parking_lot = "0.10.0" |
20 | jod-thread = "0.1.0" | 20 | jod-thread = "0.1.0" |
diff --git a/crates/ra_lsp_server/src/caps.rs b/crates/ra_lsp_server/src/caps.rs index e0bb75666..d812ff7ca 100644 --- a/crates/ra_lsp_server/src/caps.rs +++ b/crates/ra_lsp_server/src/caps.rs | |||
@@ -2,10 +2,11 @@ | |||
2 | 2 | ||
3 | use lsp_types::{ | 3 | use lsp_types::{ |
4 | CodeActionProviderCapability, CodeLensOptions, CompletionOptions, | 4 | CodeActionProviderCapability, CodeLensOptions, CompletionOptions, |
5 | DocumentOnTypeFormattingOptions, FoldingRangeProviderCapability, GenericCapability, | 5 | DocumentOnTypeFormattingOptions, FoldingRangeProviderCapability, |
6 | ImplementationProviderCapability, RenameOptions, RenameProviderCapability, ServerCapabilities, | 6 | ImplementationProviderCapability, RenameOptions, RenameProviderCapability, |
7 | SignatureHelpOptions, TextDocumentSyncCapability, TextDocumentSyncKind, | 7 | SelectionRangeProviderCapability, ServerCapabilities, SignatureHelpOptions, |
8 | TextDocumentSyncOptions, TypeDefinitionProviderCapability, WorkDoneProgressOptions, | 8 | TextDocumentSyncCapability, TextDocumentSyncKind, TextDocumentSyncOptions, |
9 | TypeDefinitionProviderCapability, WorkDoneProgressOptions, | ||
9 | }; | 10 | }; |
10 | 11 | ||
11 | pub fn server_capabilities() -> ServerCapabilities { | 12 | pub fn server_capabilities() -> ServerCapabilities { |
@@ -44,7 +45,7 @@ pub fn server_capabilities() -> ServerCapabilities { | |||
44 | first_trigger_character: "=".to_string(), | 45 | first_trigger_character: "=".to_string(), |
45 | more_trigger_character: Some(vec![".".to_string(), ">".to_string()]), | 46 | more_trigger_character: Some(vec![".".to_string(), ">".to_string()]), |
46 | }), | 47 | }), |
47 | selection_range_provider: Some(GenericCapability::default()), | 48 | selection_range_provider: Some(SelectionRangeProviderCapability::Simple(true)), |
48 | folding_range_provider: Some(FoldingRangeProviderCapability::Simple(true)), | 49 | folding_range_provider: Some(FoldingRangeProviderCapability::Simple(true)), |
49 | rename_provider: Some(RenameProviderCapability::Options(RenameOptions { | 50 | rename_provider: Some(RenameProviderCapability::Options(RenameOptions { |
50 | prepare_provider: Some(true), | 51 | prepare_provider: Some(true), |
diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index 965e7c53c..9e207415e 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs | |||
@@ -131,7 +131,7 @@ pub fn main_loop( | |||
131 | let feature_flags = { | 131 | let feature_flags = { |
132 | let mut ff = FeatureFlags::default(); | 132 | let mut ff = FeatureFlags::default(); |
133 | for (flag, value) in config.feature_flags { | 133 | for (flag, value) in config.feature_flags { |
134 | if let Err(_) = ff.set(flag.as_str(), value) { | 134 | if ff.set(flag.as_str(), value).is_err() { |
135 | log::error!("unknown feature flag: {:?}", flag); | 135 | log::error!("unknown feature flag: {:?}", flag); |
136 | show_message( | 136 | show_message( |
137 | req::MessageType::Error, | 137 | req::MessageType::Error, |
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 5b64b27cd..5e3b1a73f 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs | |||
@@ -164,7 +164,7 @@ pub fn handle_on_type_formatting( | |||
164 | 164 | ||
165 | // in `ra_ide`, the `on_type` invariant is that | 165 | // in `ra_ide`, the `on_type` invariant is that |
166 | // `text.char_at(position) == typed_char`. | 166 | // `text.char_at(position) == typed_char`. |
167 | position.offset = position.offset - TextUnit::of_char('.'); | 167 | position.offset -= TextUnit::of_char('.'); |
168 | let char_typed = params.ch.chars().next().unwrap_or('\0'); | 168 | let char_typed = params.ch.chars().next().unwrap_or('\0'); |
169 | 169 | ||
170 | // We have an assist that inserts ` ` after typing `->` in `fn foo() ->{`, | 170 | // We have an assist that inserts ` ` after typing `->` in `fn foo() ->{`, |
diff --git a/crates/ra_lsp_server/src/req.rs b/crates/ra_lsp_server/src/req.rs index 39361b7e8..2a22b655c 100644 --- a/crates/ra_lsp_server/src/req.rs +++ b/crates/ra_lsp_server/src/req.rs | |||
@@ -10,8 +10,9 @@ pub use lsp_types::{ | |||
10 | DidChangeWatchedFilesParams, DidChangeWatchedFilesRegistrationOptions, | 10 | DidChangeWatchedFilesParams, DidChangeWatchedFilesRegistrationOptions, |
11 | DocumentOnTypeFormattingParams, DocumentSymbolParams, DocumentSymbolResponse, | 11 | DocumentOnTypeFormattingParams, DocumentSymbolParams, DocumentSymbolResponse, |
12 | FileSystemWatcher, Hover, InitializeResult, MessageType, PublishDiagnosticsParams, | 12 | FileSystemWatcher, Hover, InitializeResult, MessageType, PublishDiagnosticsParams, |
13 | ReferenceParams, Registration, RegistrationParams, ShowMessageParams, SignatureHelp, | 13 | ReferenceParams, Registration, RegistrationParams, SelectionRange, SelectionRangeParams, |
14 | TextDocumentEdit, TextDocumentPositionParams, TextEdit, WorkspaceEdit, WorkspaceSymbolParams, | 14 | ShowMessageParams, SignatureHelp, TextDocumentEdit, TextDocumentPositionParams, TextEdit, |
15 | WorkspaceEdit, WorkspaceSymbolParams, | ||
15 | }; | 16 | }; |
16 | 17 | ||
17 | pub enum AnalyzerStatus {} | 18 | pub enum AnalyzerStatus {} |
@@ -67,28 +68,6 @@ pub struct ExpandMacroParams { | |||
67 | pub position: Option<Position>, | 68 | pub position: Option<Position>, |
68 | } | 69 | } |
69 | 70 | ||
70 | pub enum SelectionRangeRequest {} | ||
71 | |||
72 | impl Request for SelectionRangeRequest { | ||
73 | type Params = SelectionRangeParams; | ||
74 | type Result = Vec<SelectionRange>; | ||
75 | const METHOD: &'static str = "textDocument/selectionRange"; | ||
76 | } | ||
77 | |||
78 | #[derive(Deserialize, Debug)] | ||
79 | #[serde(rename_all = "camelCase")] | ||
80 | pub struct SelectionRangeParams { | ||
81 | pub text_document: TextDocumentIdentifier, | ||
82 | pub positions: Vec<Position>, | ||
83 | } | ||
84 | |||
85 | #[derive(Serialize, Debug)] | ||
86 | #[serde(rename_all = "camelCase")] | ||
87 | pub struct SelectionRange { | ||
88 | pub range: Range, | ||
89 | pub parent: Option<Box<SelectionRange>>, | ||
90 | } | ||
91 | |||
92 | pub enum FindMatchingBrace {} | 71 | pub enum FindMatchingBrace {} |
93 | 72 | ||
94 | impl Request for FindMatchingBrace { | 73 | impl Request for FindMatchingBrace { |
diff --git a/crates/ra_lsp_server/src/world.rs b/crates/ra_lsp_server/src/world.rs index 16cc11e8c..f89b23089 100644 --- a/crates/ra_lsp_server/src/world.rs +++ b/crates/ra_lsp_server/src/world.rs | |||
@@ -287,19 +287,15 @@ impl WorldSnapshot { | |||
287 | /// | 287 | /// |
288 | /// When processing non-windows path, this is essentially the same as `Url::from_file_path`. | 288 | /// When processing non-windows path, this is essentially the same as `Url::from_file_path`. |
289 | fn url_from_path_with_drive_lowercasing(path: impl AsRef<Path>) -> Result<Url> { | 289 | fn url_from_path_with_drive_lowercasing(path: impl AsRef<Path>) -> Result<Url> { |
290 | let component_has_windows_drive = path | 290 | let component_has_windows_drive = path.as_ref().components().any(|comp| { |
291 | .as_ref() | 291 | if let Component::Prefix(c) = comp { |
292 | .components() | 292 | match c.kind() { |
293 | .find(|comp| { | 293 | Prefix::Disk(_) | Prefix::VerbatimDisk(_) => return true, |
294 | if let Component::Prefix(c) = comp { | 294 | _ => return false, |
295 | match c.kind() { | ||
296 | Prefix::Disk(_) | Prefix::VerbatimDisk(_) => return true, | ||
297 | _ => return false, | ||
298 | } | ||
299 | } | 295 | } |
300 | false | 296 | } |
301 | }) | 297 | false |
302 | .is_some(); | 298 | }); |
303 | 299 | ||
304 | // VSCode expects drive letters to be lowercased, where rust will uppercase the drive letters. | 300 | // VSCode expects drive letters to be lowercased, where rust will uppercase the drive letters. |
305 | if component_has_windows_drive { | 301 | if component_has_windows_drive { |