1
- use std:: path:: { Path , PathBuf } ;
2
-
3
- use figment:: { providers:: Serialized , Figment } ;
4
- use serde:: { Deserialize , Serialize } ;
5
- use serde_json:: Value ;
6
-
7
1
use crate :: {
8
2
environment:: Environment ,
9
- utils :: { GlobRule , Normalize } ,
3
+ util :: { GlobRule , Normalize } ,
10
4
} ;
5
+ use serde:: { Deserialize , Serialize } ;
6
+ use std:: path:: Path ;
11
7
12
8
#[ derive( Debug , Default , Clone , Serialize , Deserialize ) ]
13
- pub struct RhaiConfig {
14
- pub source : RhaiSourceConfig ,
9
+ pub struct Config {
10
+ pub source : SourceConfig ,
15
11
}
16
12
17
- impl RhaiConfig {
13
+ impl Config {
18
14
pub fn prepare ( & mut self , e : & impl Environment , base : & Path ) -> anyhow:: Result < ( ) > {
19
15
self . source . prepare ( e, base)
20
16
}
21
17
}
22
18
23
19
#[ derive( Debug , Default , Clone , Serialize , Deserialize ) ]
24
- pub struct RhaiSourceConfig {
20
+ pub struct SourceConfig {
25
21
/// A list of UNIX-style glob patterns
26
22
/// for Rhai files that should be included.
27
23
pub include : Option < Vec < String > > ,
@@ -33,7 +29,7 @@ pub struct RhaiSourceConfig {
33
29
pub file_rule : Option < GlobRule > ,
34
30
}
35
31
36
- impl RhaiSourceConfig {
32
+ impl SourceConfig {
37
33
pub fn prepare ( & mut self , e : & impl Environment , base : & Path ) -> anyhow:: Result < ( ) > {
38
34
self . make_absolute ( e, base) ;
39
35
@@ -76,54 +72,3 @@ impl RhaiSourceConfig {
76
72
}
77
73
}
78
74
}
79
-
80
- #[ derive( Debug , Clone , Serialize , Deserialize ) ]
81
- #[ serde( rename_all = "camelCase" ) ]
82
- pub struct InitConfig {
83
- pub cache_path : Option < PathBuf > ,
84
- #[ serde( default = "default_configuration_section" ) ]
85
- pub configuration_section : String ,
86
- }
87
-
88
- impl Default for InitConfig {
89
- fn default ( ) -> Self {
90
- Self {
91
- cache_path : Default :: default ( ) ,
92
- configuration_section : default_configuration_section ( ) ,
93
- }
94
- }
95
- }
96
-
97
- fn default_configuration_section ( ) -> String {
98
- String :: from ( "rhai" )
99
- }
100
-
101
- #[ derive( Debug , Clone , Default , Serialize , Deserialize ) ]
102
- #[ serde( rename_all = "camelCase" ) ]
103
- pub struct LspConfig {
104
- pub syntax : SyntaxConfig ,
105
- }
106
-
107
- impl LspConfig {
108
- pub fn update_from_json ( & mut self , json : & Value ) -> Result < ( ) , anyhow:: Error > {
109
- * self = Figment :: new ( )
110
- . merge ( Serialized :: defaults ( & self ) )
111
- . merge ( Serialized :: defaults ( json) )
112
- . extract ( ) ?;
113
- Ok ( ( ) )
114
- }
115
- }
116
-
117
- #[ derive( Debug , Clone , Serialize , Deserialize ) ]
118
- #[ serde( rename_all = "camelCase" ) ]
119
- pub struct SyntaxConfig {
120
- pub semantic_tokens : bool ,
121
- }
122
-
123
- impl Default for SyntaxConfig {
124
- fn default ( ) -> Self {
125
- Self {
126
- semantic_tokens : true ,
127
- }
128
- }
129
- }
0 commit comments