@@ -451,6 +451,22 @@ def debug_server_parser(args):
451
451
args : Namespace
452
452
The arguments parsed from the `ArgumentParser`
453
453
"""
454
+
455
+ def locate_config (root : str ) -> str | None :
456
+ default_conf_files = [args .config , ".fortlsrc" , ".fortls.json" , ".fortls" ]
457
+ present_conf_files = [
458
+ os .path .isfile (os .path .join (root , f )) for f in default_conf_files
459
+ ]
460
+ if not any (present_conf_files ):
461
+ return None
462
+
463
+ # Load the first config file found
464
+ for f , present in zip (default_conf_files , present_conf_files ):
465
+ if not present :
466
+ continue
467
+ config_path = os .path .join (root , f )
468
+ return config_path
469
+
454
470
if args .debug_filepath is None :
455
471
error_exit ("'debug_filepath' not specified for parsing test" )
456
472
file_exists = os .path .isfile (args .debug_filepath )
@@ -461,7 +477,8 @@ def debug_server_parser(args):
461
477
pp_defs = {}
462
478
include_dirs = set ()
463
479
if args .debug_rootpath :
464
- config_path = os .path .join (args .debug_rootpath , args .config )
480
+ # Check for config files
481
+ config_path = locate_config (args .debug_rootpath )
465
482
config_exists = os .path .isfile (config_path )
466
483
if config_exists :
467
484
try :
@@ -479,7 +496,7 @@ def debug_server_parser(args):
479
496
pp_defs = {key : "" for key in pp_defs }
480
497
except :
481
498
print (f"Error while parsing '{ args .config } ' settings file" )
482
- #
499
+
483
500
print ("\n Testing parser" )
484
501
print (' File = "{}"' .format (args .debug_filepath ))
485
502
file_obj = FortranFile (args .debug_filepath , pp_suffixes )
0 commit comments