@@ -141,7 +141,7 @@ def only_dirs(paths: list[str], err_msg: list = []) -> list[str]:
141
141
continue
142
142
else :
143
143
msg : str = (
144
- f"Directory '{ p } ' specified in '.fortls' settings file does not exist"
144
+ f"Directory '{ p } ' specified in Configuration settings file does not exist"
145
145
)
146
146
if err_msg :
147
147
err_msg .append ([2 , msg ])
@@ -177,6 +177,7 @@ def __init__(self, conn, debug_log=False, settings={}):
177
177
self .intrinsic_mods ,
178
178
) = load_intrinsics ()
179
179
# Get launch settings
180
+ self .config = settings .get ("config" , ".fortls" )
180
181
self .nthreads = settings .get ("nthreads" , 4 )
181
182
self .notify_init = settings .get ("notify_init" , False )
182
183
self .symbol_include_mem = settings .get ("symbol_include_mem" , True )
@@ -1475,8 +1476,7 @@ def __load_config_file(self) -> None:
1475
1476
"""Loads the configuration file for the Language Server"""
1476
1477
1477
1478
# Check for config file
1478
- config_fname = ".fortls"
1479
- config_path = os .path .join (self .root_path , config_fname )
1479
+ config_path = os .path .join (self .root_path , self .config )
1480
1480
if not os .path .isfile (config_path ):
1481
1481
return None
1482
1482
@@ -1489,63 +1489,81 @@ def __load_config_file(self) -> None:
1489
1489
# config_dict = json.loads(jsondata)
1490
1490
config_dict = json .load (jsonfile )
1491
1491
1492
- # Exclude paths (directories & files)
1493
- # with glob resolution
1494
- for path in config_dict .get ("excl_paths" , []):
1495
- self .excl_paths .update (set (resolve_globs (path , self .root_path )))
1496
-
1497
- # Source directory paths (directories)
1498
- # with glob resolution
1499
- source_dirs = config_dict .get ("source_dirs" , [])
1500
- for path in source_dirs :
1501
- self .source_dirs .update (
1502
- set (
1503
- only_dirs (
1504
- resolve_globs (path , self .root_path ),
1505
- self .post_messages ,
1506
- )
1507
- )
1508
- )
1509
- # Keep all directories present in source_dirs but not excl_paths
1510
- self .source_dirs = {
1511
- i for i in self .source_dirs if i not in self .excl_paths
1512
- }
1492
+ # Include and Exclude directories
1493
+ self .__load_config_file_dirs (config_dict )
1513
1494
1514
- self .excl_suffixes = config_dict .get ("excl_suffixes" , [])
1515
- self .lowercase_intrinsics = config_dict .get (
1516
- "lowercase_intrinsics" , self .lowercase_intrinsics
1517
- )
1495
+ # General options
1496
+ self .__load_config_file_general (config_dict )
1497
+
1498
+ # Preprocessor options
1499
+ self .__load_config_file_preproc (config_dict )
1500
+
1501
+ # Debug options
1518
1502
self .debug_log = config_dict .get ("debug_log" , self .debug_log )
1519
- self .disable_diagnostics = config_dict .get (
1520
- "disable_diagnostics" , self .disable_diagnostics
1521
- )
1522
- self .pp_suffixes = config_dict .get ("pp_suffixes" , None )
1523
- self .pp_defs = config_dict .get ("pp_defs" , {})
1524
- for path in config_dict .get ("include_dirs" , []):
1525
- self .include_dirs .extend (
1526
- only_dirs (
1527
- resolve_globs (path , self .root_path ), self .post_messages
1528
- )
1529
- )
1530
- self .max_line_length = config_dict .get (
1531
- "max_line_length" , self .max_line_length
1532
- )
1533
- self .max_comment_line_length = config_dict .get (
1534
- "max_comment_line_length" , self .max_comment_line_length
1535
- )
1536
- if isinstance (self .pp_defs , list ):
1537
- self .pp_defs = {key : "" for key in self .pp_defs }
1538
1503
1539
1504
except FileNotFoundError :
1540
- msg = f"Error settings file '{ config_fname } ' not found"
1505
+ msg = f"Error settings file '{ self . config } ' not found"
1541
1506
self .post_messages .append ([1 , msg ])
1542
1507
log .error (msg )
1543
1508
1544
1509
except ValueError :
1545
- msg = f"Error while parsing '{ config_fname } ' settings file"
1510
+ msg = f"Error while parsing '{ self . config } ' settings file"
1546
1511
self .post_messages .append ([1 , msg ])
1547
1512
log .error (msg )
1548
1513
1514
+ def __load_config_file_dirs (self , config_dict ) -> None :
1515
+ # Exclude paths (directories & files)
1516
+ # with glob resolution
1517
+ for path in config_dict .get ("excl_paths" , []):
1518
+ self .excl_paths .update (set (resolve_globs (path , self .root_path )))
1519
+
1520
+ # Source directory paths (directories)
1521
+ # with glob resolution
1522
+ source_dirs = config_dict .get ("source_dirs" , [])
1523
+ for path in source_dirs :
1524
+ self .source_dirs .update (
1525
+ set (
1526
+ only_dirs (
1527
+ resolve_globs (path , self .root_path ),
1528
+ self .post_messages ,
1529
+ )
1530
+ )
1531
+ )
1532
+ # Keep all directories present in source_dirs but not excl_paths
1533
+ self .source_dirs = {i for i in self .source_dirs if i not in self .excl_paths }
1534
+
1535
+ def __load_config_file_general (self , config_dict ) -> None :
1536
+ self .excl_suffixes = config_dict .get ("excl_suffixes" , [])
1537
+ self .lowercase_intrinsics = config_dict .get (
1538
+ "lowercase_intrinsics" , self .lowercase_intrinsics
1539
+ )
1540
+ self .use_signature_help = config_dict .get (
1541
+ "use_signature_help" , self .use_signature_help
1542
+ )
1543
+ self .variable_hover = config_dict .get ("variable_hover" , self .variable_hover )
1544
+ self .hover_signature = config_dict .get ("hover_signature" , self .hover_signature )
1545
+ self .enable_code_actions = config_dict .get (
1546
+ "enable_code_actions" , self .enable_code_actions
1547
+ )
1548
+ self .disable_diagnostics = config_dict .get (
1549
+ "disable_diagnostics" , self .disable_diagnostics
1550
+ )
1551
+ self .max_line_length = config_dict .get ("max_line_length" , self .max_line_length )
1552
+ self .max_comment_line_length = config_dict .get (
1553
+ "max_comment_line_length" , self .max_comment_line_length
1554
+ )
1555
+
1556
+ def __load_config_file_preproc (self , config_dict ) -> None :
1557
+ self .pp_suffixes = config_dict .get ("pp_suffixes" , None )
1558
+ self .pp_defs = config_dict .get ("pp_defs" , {})
1559
+ if isinstance (self .pp_defs , list ):
1560
+ self .pp_defs = {key : "" for key in self .pp_defs }
1561
+
1562
+ for path in config_dict .get ("include_dirs" , []):
1563
+ self .include_dirs .extend (
1564
+ only_dirs (resolve_globs (path , self .root_path ), self .post_messages )
1565
+ )
1566
+
1549
1567
def __add_source_dirs (self ) -> None :
1550
1568
"""Will recursively add all subdirectories that contain Fortran
1551
1569
source files only if the option `source_dirs` has not been specified
0 commit comments