Skip to content

Commit b164810

Browse files
committed
implement check for client_capabilities.workspace.configuration
1 parent 897fe04 commit b164810

File tree

2 files changed

+45
-29
lines changed

2 files changed

+45
-29
lines changed

robotcode/language_server/common/parts/workspace.py

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -295,19 +295,35 @@ async def get_configuration(
295295
return None
296296

297297
return section.parse_obj(config)
298-
return (
299-
await self.parent.send_request(
300-
"workspace/configuration",
301-
ConfigurationParams(
302-
items=[
303-
ConfigurationItem(
304-
scope_uri=str(scope_uri) if isinstance(scope_uri, Uri) else scope_uri, section=str(section)
305-
)
306-
]
307-
),
308-
list,
309-
)
310-
)[0]
298+
299+
if (
300+
self.parent.client_capabilities
301+
and self.parent.client_capabilities.workspace
302+
and self.parent.client_capabilities.workspace.configuration
303+
):
304+
return (
305+
await self.parent.send_request(
306+
"workspace/configuration",
307+
ConfigurationParams(
308+
items=[
309+
ConfigurationItem(
310+
scope_uri=str(scope_uri) if isinstance(scope_uri, Uri) else scope_uri,
311+
section=str(section),
312+
)
313+
]
314+
),
315+
list,
316+
)
317+
)[0]
318+
319+
result = self.settings
320+
for sub_key in str(section).split("."):
321+
if sub_key in result:
322+
result = result.get(sub_key, None)
323+
else:
324+
result = {}
325+
break
326+
return self.settings.get(str(section), {})
311327

312328
def get_workspace_folder(self, uri: Union[Uri, str]) -> Optional[WorkspaceFolder]:
313329
if isinstance(uri, str):

robotcode/language_server/robotframework/configuration.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,39 @@
55

66
@config_section("robotcode.languageServer")
77
class LanguageServerConfig(ConfigBase):
8-
mode: str
9-
tcp_port: int
10-
args: Tuple[str, ...]
8+
mode: str = "stdio"
9+
tcp_port: int = 0
10+
args: Tuple[str, ...] = ()
1111

1212

1313
@config_section("robotcode.robot")
1414
class RobotConfig(ConfigBase):
15-
args: Tuple[str, ...]
16-
python_path: List[str]
17-
env: Dict[str, str]
18-
variables: Dict[str, str]
15+
args: Tuple[str, ...] = ()
16+
python_path: List[str] = []
17+
env: Dict[str, str] = {}
18+
variables: Dict[str, str] = {}
1919

2020

2121
@config_section("robotcode.syntax")
2222
class SyntaxConfig(ConfigBase):
23-
section_style: str
23+
section_style: str = "*** {name}s ***"
2424

2525

2626
@config_section("robotcode.robocop")
2727
class RoboCopConfig(ConfigBase):
28-
enabled: bool
29-
include: List[str]
30-
exclude: List[str]
31-
configurations: List[str]
28+
enabled: bool = True
29+
include: List[str] = []
30+
exclude: List[str] = []
31+
configurations: List[str] = []
3232

3333

3434
@config_section("robotcode.robotidy")
3535
class RoboTidyConfig(ConfigBase):
36-
enabled: bool
36+
enabled: bool = True
3737

3838

3939
@config_section("robotcode")
4040
class RobotCodeConfig(ConfigBase):
41-
language_server: LanguageServerConfig
42-
robot: RobotConfig
43-
syntax: SyntaxConfig
41+
language_server: LanguageServerConfig = LanguageServerConfig()
42+
robot: RobotConfig = RobotConfig()
43+
syntax: SyntaxConfig = SyntaxConfig()

0 commit comments

Comments
 (0)