Skip to content

Commit 6c8b76d

Browse files
committed
Fixes debug_log not initialising from .fortls file
1 parent 4a09b10 commit 6c8b76d

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

fortls/langserver.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def init_file(filepath, pp_defs, pp_suffixes, include_dirs):
8383

8484

8585
class LangServer:
86-
def __init__(self, conn, debug_log=False, settings={}):
86+
def __init__(self, conn, debug_log: bool = False, settings: dict = {}):
8787
self.conn = conn
8888
self.running = True
8989
self.root_path = None
@@ -221,7 +221,9 @@ def serve_initialize(self, request):
221221
)
222222
self.source_dirs.add(self.root_path)
223223
self.__config_logger(request)
224-
self.__load_config_file()
224+
init_debug_log = self.__load_config_file()
225+
if init_debug_log:
226+
self.__config_logger(request)
225227
self.__load_intrinsics()
226228
self.__add_source_dirs()
227229

@@ -1432,7 +1434,7 @@ def serve_default(self, request):
14321434
code=-32601, message="method {} not found".format(request["method"])
14331435
)
14341436

1435-
def __load_config_file(self) -> None:
1437+
def __load_config_file(self) -> bool | None:
14361438
"""Loads the configuration file for the Language Server"""
14371439

14381440
# Check for config file
@@ -1459,7 +1461,13 @@ def __load_config_file(self) -> None:
14591461
self.__load_config_file_preproc(config_dict)
14601462

14611463
# Debug options
1462-
self.debug_log = config_dict.get("debug_log", self.debug_log)
1464+
debugging: bool = config_dict.get("debug_log", self.debug_log)
1465+
# If conf option is different than the debug option passed as a
1466+
# command line argument return True so that debug log is setup
1467+
if debugging != self.debug_log and not self.debug_log:
1468+
self.debug_log = True
1469+
return True
1470+
return False
14631471

14641472
except FileNotFoundError:
14651473
msg = f"Error settings file '{self.config}' not found"

test/test_source/pp/.pp_conf.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"variable_hover": true,
55
"hover_signature": true,
66
"enable_code_actions": true,
7+
"pp_suffixes": [".h", ".F90"],
78
"incl_suffixes": [".h"],
89
"include_dirs": ["include"]
910
}

0 commit comments

Comments
 (0)