File tree Expand file tree Collapse file tree 5 files changed +10
-10
lines changed Expand file tree Collapse file tree 5 files changed +10
-10
lines changed Original file line number Diff line number Diff line change 66
77### Added
88
9+ - Added support for comments in the ` json ` configuration files
10+ ([ #137 ] ( https://github.com/gnikit/fortls/issues/137 ) )
911- Added ` sitemap.xml ` to documentation webpage
1012 ([ #134 ] ( https://github.com/gnikit/fortls/pull/134 ) )
1113
Original file line number Diff line number Diff line change 1- # TODO: enable jsonc C-style comments
21from __future__ import annotations
32
43import json
1413from typing import Pattern
1514from urllib .error import URLError
1615
16+ import json5
1717from packaging import version
1818
1919# Local modules
@@ -1502,12 +1502,7 @@ def _load_config_file(self) -> None:
15021502
15031503 try :
15041504 with open (config_path , "r" ) as jsonfile :
1505- # Allow for jsonc C-style commnets
1506- # jsondata = "".join(
1507- # line for line in jsonfile if not line.startswith("//")
1508- # )
1509- # config_dict = json.loads(jsondata)
1510- config_dict = json .load (jsonfile )
1505+ config_dict = json5 .load (jsonfile )
15111506
15121507 # Include and Exclude directories
15131508 self ._load_config_file_dirs (config_dict )
@@ -1530,7 +1525,7 @@ def _load_config_file(self) -> None:
15301525
15311526 # Erroneous json file syntax
15321527 except ValueError as e :
1533- msg = f" Error: ' { e } ' while reading ' { self .config } ' Configuration file"
1528+ msg = f' Error: " { e } " while reading " { self .config } " Configuration file'
15341529 self .post_message (msg )
15351530
15361531 def _load_config_file_dirs (self , config_dict : dict ) -> None :
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ project_urls =
3939packages = find:
4040python_requires = >= 3.7
4141install_requires =
42+ json5
4243 packaging
4344 importlib-metadata; python_version < "3.8"
4445 typing-extensions; python_version < "3.8"
Original file line number Diff line number Diff line change @@ -22,8 +22,8 @@ def test_config_file_non_existent_options():
2222 ref = {
2323 "type" : 1 ,
2424 "message" : (
25- " Error: 'Expecting ':' delimiter: line 2 column 18 (char 19)' while reading"
26- " ' wrong_syntax.json' Configuration file"
25+ ' Error: "<string>:2 Unexpected "," at column 18" while reading'
26+ ' " wrong_syntax.json" Configuration file'
2727 ),
2828 }
2929 assert errcode == 0
Original file line number Diff line number Diff line change 11{
2+ // Directories to be scanned for source files
23 "source_dirs": [
34 "**/"
45 ],
6+ // These are regular expressions, files and paths that can be ignored
57 "excl_paths": [
68 "excldir/**",
79 "./diag/",
You can’t perform that action at this time.
0 commit comments