mirror of
				https://github.com/astral-sh/ruff.git
				synced 2025-10-31 03:55:09 +00:00 
			
		
		
		
	[ty] Stabilize completions (#18650)
Specifically, this PR reverts "Make completions an opt-in LSP feature
(#17921)",
corresponding to commit 51e2effd2d.
In practice, this means you don't need to opt into completions working
by enabling experimental features. i.e., I was able to remove this from
my LSP configuration:
```
"experimental": {
    "completions": {
        "enable": true
    }
},
```
There's still a lot of work left to do to make completions awesome, but
I think it's in a state where it would be useful to get real user
feedback. It's also meaningfully using ty to provide completions that
use type information.
Ref astral-sh/ty#86
			
			
This commit is contained in:
		
							parent
							
								
									2f3bd24900
								
							
						
					
					
						commit
						869d7bf9a8
					
				
					 4 changed files with 7 additions and 39 deletions
				
			
		|  | @ -2,7 +2,7 @@ | |||
| 
 | ||||
| use self::schedule::spawn_main_loop; | ||||
| use crate::PositionEncoding; | ||||
| use crate::session::{AllSettings, ClientSettings, Experimental, Session}; | ||||
| use crate::session::{AllSettings, ClientSettings, Session}; | ||||
| use lsp_server::Connection; | ||||
| use lsp_types::{ | ||||
|     ClientCapabilities, DiagnosticOptions, DiagnosticServerCapabilities, HoverProviderCapability, | ||||
|  | @ -53,8 +53,7 @@ impl Server { | |||
| 
 | ||||
|         let client_capabilities = init_params.capabilities; | ||||
|         let position_encoding = Self::find_best_position_encoding(&client_capabilities); | ||||
|         let server_capabilities = | ||||
|             Self::server_capabilities(position_encoding, global_settings.experimental.as_ref()); | ||||
|         let server_capabilities = Self::server_capabilities(position_encoding); | ||||
| 
 | ||||
|         let connection = connection.initialize_finish( | ||||
|             id, | ||||
|  | @ -154,10 +153,7 @@ impl Server { | |||
|             .unwrap_or_default() | ||||
|     } | ||||
| 
 | ||||
|     fn server_capabilities( | ||||
|         position_encoding: PositionEncoding, | ||||
|         experimental: Option<&Experimental>, | ||||
|     ) -> ServerCapabilities { | ||||
|     fn server_capabilities(position_encoding: PositionEncoding) -> ServerCapabilities { | ||||
|         ServerCapabilities { | ||||
|             position_encoding: Some(position_encoding.into()), | ||||
|             diagnostic_provider: Some(DiagnosticServerCapabilities::Options(DiagnosticOptions { | ||||
|  | @ -177,12 +173,10 @@ impl Server { | |||
|             inlay_hint_provider: Some(lsp_types::OneOf::Right( | ||||
|                 InlayHintServerCapabilities::Options(InlayHintOptions::default()), | ||||
|             )), | ||||
|             completion_provider: experimental | ||||
|                 .is_some_and(Experimental::is_completions_enabled) | ||||
|                 .then_some(lsp_types::CompletionOptions { | ||||
|                     trigger_characters: Some(vec!['.'.to_string()]), | ||||
|                     ..Default::default() | ||||
|                 }), | ||||
|             completion_provider: Some(lsp_types::CompletionOptions { | ||||
|                 trigger_characters: Some(vec!['.'.to_string()]), | ||||
|                 ..Default::default() | ||||
|             }), | ||||
|             ..Default::default() | ||||
|         } | ||||
|     } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andrew Gallant
						Andrew Gallant