@@ -451,6 +451,22 @@ def debug_server_parser(args):
451451 args : Namespace
452452 The arguments parsed from the `ArgumentParser`
453453 """
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+
454470 if args .debug_filepath is None :
455471 error_exit ("'debug_filepath' not specified for parsing test" )
456472 file_exists = os .path .isfile (args .debug_filepath )
@@ -461,7 +477,8 @@ def debug_server_parser(args):
461477 pp_defs = {}
462478 include_dirs = set ()
463479 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 )
465482 config_exists = os .path .isfile (config_path )
466483 if config_exists :
467484 try :
@@ -479,7 +496,7 @@ def debug_server_parser(args):
479496 pp_defs = {key : "" for key in pp_defs }
480497 except :
481498 print (f"Error while parsing '{ args .config } ' settings file" )
482- #
499+
483500 print ("\n Testing parser" )
484501 print (' File = "{}"' .format (args .debug_filepath ))
485502 file_obj = FortranFile (args .debug_filepath , pp_suffixes )
0 commit comments