1- use super :: configuration:: { resolve_config, Configuration } ;
1+ use super :: configuration:: resolve_config;
2+ use super :: configuration:: Configuration ;
23
3- use dprint_core:: configuration:: { ConfigKeyMap , GlobalConfiguration , ResolveConfigurationResult } ;
4+ use dprint_core:: configuration:: ConfigKeyMap ;
5+ use dprint_core:: configuration:: GlobalConfiguration ;
46use dprint_core:: generate_plugin_code;
7+ use dprint_core:: plugins:: CheckConfigUpdatesMessage ;
8+ use dprint_core:: plugins:: ConfigChange ;
59use dprint_core:: plugins:: FileMatchingInfo ;
10+ use dprint_core:: plugins:: FormatRange ;
611use dprint_core:: plugins:: FormatResult ;
712use dprint_core:: plugins:: PluginInfo ;
13+ use dprint_core:: plugins:: PluginResolveConfigurationResult ;
14+ use dprint_core:: plugins:: SyncFormatRequest ;
15+ use dprint_core:: plugins:: SyncHostFormatRequest ;
816use dprint_core:: plugins:: SyncPluginHandler ;
9- use dprint_core:: plugins:: SyncPluginInfo ;
10- use std:: path:: Path ;
1117
1218struct JupyterPluginHandler ;
1319
@@ -16,45 +22,56 @@ impl SyncPluginHandler<Configuration> for JupyterPluginHandler {
1622 & mut self ,
1723 config : ConfigKeyMap ,
1824 global_config : & GlobalConfiguration ,
19- ) -> ResolveConfigurationResult < Configuration > {
20- resolve_config ( config, global_config)
21- }
22-
23- fn plugin_info ( & mut self ) -> SyncPluginInfo {
24- let version = env ! ( "CARGO_PKG_VERSION" ) . to_string ( ) ;
25- SyncPluginInfo {
26- info : PluginInfo {
27- name : env ! ( "CARGO_PKG_NAME" ) . to_string ( ) ,
28- version : version. clone ( ) ,
29- config_key : "jupyter" . to_string ( ) ,
30- help_url : "https://dprint.dev/plugins/jupyter" . to_string ( ) ,
31- config_schema_url : format ! (
32- "https://plugins.dprint.dev/dprint/dprint-plugin-jupyter/{}/schema.json" ,
33- version
34- ) ,
35- update_url : Some ( "https://plugins.dprint.dev/dprint/dprint-plugin-jupyter/latest.json" . to_string ( ) ) ,
36- } ,
25+ ) -> PluginResolveConfigurationResult < Configuration > {
26+ let config = resolve_config ( config, global_config) ;
27+ PluginResolveConfigurationResult {
28+ config : config. config ,
29+ diagnostics : config. diagnostics ,
3730 file_matching : FileMatchingInfo {
3831 file_extensions : vec ! [ "ipynb" . to_string( ) ] ,
3932 file_names : vec ! [ ] ,
4033 } ,
4134 }
4235 }
4336
37+ fn plugin_info ( & mut self ) -> PluginInfo {
38+ let version = env ! ( "CARGO_PKG_VERSION" ) . to_string ( ) ;
39+ PluginInfo {
40+ name : env ! ( "CARGO_PKG_NAME" ) . to_string ( ) ,
41+ version : version. clone ( ) ,
42+ config_key : "jupyter" . to_string ( ) ,
43+ help_url : "https://dprint.dev/plugins/jupyter" . to_string ( ) ,
44+ config_schema_url : format ! (
45+ "https://plugins.dprint.dev/dprint/dprint-plugin-jupyter/{}/schema.json" ,
46+ version
47+ ) ,
48+ update_url : Some ( "https://plugins.dprint.dev/dprint/dprint-plugin-jupyter/latest.json" . to_string ( ) ) ,
49+ }
50+ }
51+
52+ fn check_config_updates ( & self , _message : CheckConfigUpdatesMessage ) -> Result < Vec < ConfigChange > , anyhow:: Error > {
53+ Ok ( Vec :: new ( ) )
54+ }
55+
4456 fn license_text ( & mut self ) -> String {
4557 std:: str:: from_utf8 ( include_bytes ! ( "../LICENSE" ) ) . unwrap ( ) . into ( )
4658 }
4759
4860 fn format (
4961 & mut self ,
50- _file_path : & Path ,
51- file_bytes : Vec < u8 > ,
52- _config : & Configuration ,
53- mut format_with_host : impl FnMut ( & Path , Vec < u8 > , & ConfigKeyMap ) -> FormatResult ,
62+ request : SyncFormatRequest < Configuration > ,
63+ _format_with_host : impl FnMut ( SyncHostFormatRequest ) -> FormatResult ,
5464 ) -> FormatResult {
55- let file_text = String :: from_utf8 ( file_bytes) ?;
65+ let file_text = String :: from_utf8 ( request . file_bytes ) ?;
5666 super :: format_text ( & file_text, |path, text| {
57- let maybe_bytes = format_with_host ( path, text. into_bytes ( ) , & ConfigKeyMap :: new ( ) ) ?;
67+ let additional_config = ConfigKeyMap :: new ( ) ;
68+ let request = SyncHostFormatRequest {
69+ file_path : & path,
70+ file_bytes : text. as_bytes ( ) ,
71+ range : FormatRange :: None ,
72+ override_config : & additional_config,
73+ } ;
74+ let maybe_bytes = format_with_host ( request) ?;
5875 match maybe_bytes {
5976 Some ( bytes) => Ok ( Some ( String :: from_utf8 ( bytes) ?) ) ,
6077 None => Ok ( None ) ,
0 commit comments