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 6
6
7
7
### Added
8
8
9
+ - Added support for comments in the ` json ` configuration files
10
+ ([ #137 ] ( https://github.com/gnikit/fortls/issues/137 ) )
9
11
- Added ` sitemap.xml ` to documentation webpage
10
12
([ #134 ] ( https://github.com/gnikit/fortls/pull/134 ) )
11
13
Original file line number Diff line number Diff line change 1
- # TODO: enable jsonc C-style comments
2
1
from __future__ import annotations
3
2
4
3
import json
14
13
from typing import Pattern
15
14
from urllib .error import URLError
16
15
16
+ import json5
17
17
from packaging import version
18
18
19
19
# Local modules
@@ -1502,12 +1502,7 @@ def _load_config_file(self) -> None:
1502
1502
1503
1503
try :
1504
1504
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 )
1511
1506
1512
1507
# Include and Exclude directories
1513
1508
self ._load_config_file_dirs (config_dict )
@@ -1530,7 +1525,7 @@ def _load_config_file(self) -> None:
1530
1525
1531
1526
# Erroneous json file syntax
1532
1527
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'
1534
1529
self .post_message (msg )
1535
1530
1536
1531
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 =
39
39
packages = find:
40
40
python_requires = >= 3.7
41
41
install_requires =
42
+ json5
42
43
packaging
43
44
importlib-metadata; python_version < "3.8"
44
45
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():
22
22
ref = {
23
23
"type" : 1 ,
24
24
"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'
27
27
),
28
28
}
29
29
assert errcode == 0
Original file line number Diff line number Diff line change 1
1
{
2
+ // Directories to be scanned for source files
2
3
"source_dirs": [
3
4
"**/"
4
5
],
6
+ // These are regular expressions, files and paths that can be ignored
5
7
"excl_paths": [
6
8
"excldir/**",
7
9
"./diag/",
You can’t perform that action at this time.
0 commit comments