@@ -14,22 +14,36 @@ use std::io;
1414use std:: path:: { Path , PathBuf } ;
1515use vhdl_lang:: { Config , Diagnostic , Message , Project , Severity , Source , SrcPos } ;
1616
17+ #[ derive( Default , Clone ) ]
18+ pub struct VHDLServerSettings {
19+ pub no_lint : bool ,
20+ }
21+
1722pub struct VHDLServer < T : RpcChannel + Clone > {
1823 rpc_channel : T ,
24+ settings : VHDLServerSettings ,
1925 // To have well defined unit tests that are not affected by environment
2026 use_external_config : bool ,
2127 server : Option < InitializedVHDLServer < T > > ,
2228 config_file : Option < PathBuf > ,
2329}
2430
2531impl < T : RpcChannel + Clone > VHDLServer < T > {
26- pub fn new ( rpc_channel : T ) -> VHDLServer < T > {
27- Self :: new_external_config ( rpc_channel, true )
32+ pub fn new_settings ( rpc_channel : T , settings : VHDLServerSettings ) -> VHDLServer < T > {
33+ VHDLServer {
34+ rpc_channel,
35+ settings,
36+ use_external_config : true ,
37+ server : None ,
38+ config_file : None ,
39+ }
2840 }
2941
42+ #[ cfg( test) ]
3043 fn new_external_config ( rpc_channel : T , use_external_config : bool ) -> VHDLServer < T > {
3144 VHDLServer {
3245 rpc_channel,
46+ settings : Default :: default ( ) ,
3347 use_external_config,
3448 server : None ,
3549 config_file : None ,
@@ -86,7 +100,12 @@ impl<T: RpcChannel + Clone> VHDLServer<T> {
86100 pub fn initialize_request ( & mut self , params : InitializeParams ) -> InitializeResult {
87101 self . config_file = self . root_uri_config_file ( & params) ;
88102 let config = self . load_config ( ) ;
89- let ( server, result) = InitializedVHDLServer :: new ( self . rpc_channel . clone ( ) , config, params) ;
103+ let ( server, result) = InitializedVHDLServer :: new (
104+ self . rpc_channel . clone ( ) ,
105+ self . settings . clone ( ) ,
106+ config,
107+ params,
108+ ) ;
90109 self . server = Some ( server) ;
91110 result
92111 }
@@ -212,6 +231,7 @@ impl<T: RpcChannel + Clone> VHDLServer<T> {
212231
213232struct InitializedVHDLServer < T : RpcChannel > {
214233 rpc_channel : T ,
234+ settings : VHDLServerSettings ,
215235 init_params : InitializeParams ,
216236 project : Project ,
217237 files_with_notifications : FnvHashMap < Url , ( ) > ,
@@ -235,13 +255,15 @@ impl<T: RpcChannel> RpcChannel for InitializedVHDLServer<T> {
235255impl < T : RpcChannel + Clone > InitializedVHDLServer < T > {
236256 pub fn new (
237257 rpc_channel : T ,
258+ settings : VHDLServerSettings ,
238259 config : Config ,
239260 init_params : InitializeParams ,
240261 ) -> ( InitializedVHDLServer < T > , InitializeResult ) {
241262 let project = Project :: from_config ( & config, & mut MessageChannel :: new ( & rpc_channel) ) ;
242263
243264 let server = InitializedVHDLServer {
244265 rpc_channel,
266+ settings,
245267 init_params,
246268 project,
247269 files_with_notifications : FnvHashMap :: default ( ) ,
@@ -303,6 +325,10 @@ impl<T: RpcChannel + Clone> InitializedVHDLServer<T> {
303325 }
304326
305327 fn publish_diagnostics ( & mut self ) {
328+ if self . settings . no_lint {
329+ return ;
330+ }
331+
306332 let supports_related_information = self . client_supports_related_information ( ) ;
307333 let diagnostics = self . project . analyse ( ) ;
308334 let diagnostics = {
0 commit comments