8000 make path separator escape configurable (#373) · dbazile/python-lsp-server@7456f2c · GitHub
[go: up one dir, main page]

Skip to content

Commit 7456f2c

Browse files
authored
make path separator escape configurable (python-lsp#373)
1 parent eb61ccd commit 7456f2c

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

CONFIGURATION.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ This server can be configured using the `workspace/didChangeConfiguration` metho
2525
| `pylsp.plugins.jedi.env_vars` | `object` | Define environment variables for jedi.Script and Jedi.names. | `null` |
2626
| `pylsp.plugins.jedi.environment` | `string` | Define environment for jedi.Script and Jedi.names. | `null` |
2727
| `pylsp.plugins.jedi_completion.enabled` | `boolean` | Enable or disable the plugin. | `true` |
28+
| `pylsp.plugins.jedi_completion.escape_path_sep` | `boolean` | Force path separators to be escaped in file path completions. | `true` |
2829
| `pylsp.plugins.jedi_completion.include_params` | `boolean` | Auto-completes methods and classes with tabstops for each parameter. | `true` |
2930
| `pylsp.plugins.jedi_completion.include_class_objects` | `boolean` | Adds class objects as a separate completion item. | `false` |
3031
| `pylsp.plugins.jedi_completion.include_function_objects` | `boolean` | Adds function objects as a separate completion item. | `false` |

pylsp/plugins/jedi_completion.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,16 @@ def pylsp_completions(config, document, position):
8080
and use_snippets(document, position)
8181
)
8282

83+
escape_path_sep = settings.get("escape_path_sep", snippet_support)
84+
8385
ready_completions = [
8486
_format_completion(
8587
c,
8688
markup_kind=preferred_markup_kind,
8789
include_params=include_params if c.type in ["class", "function"] else False,
8890
resolve=resolve_eagerly,
8991
resolve_label_or_snippet=(i < max_to_resolve),
90-
snippet_support=snippet_support,
92+
escape_path_sep=escape_path_sep,
9193
)
9294
for i, c in enumerate(completions)
9395
]
@@ -102,7 +104,7 @@ def pylsp_completions(config, document, position):
102104
include_params=False,
103105
resolve=resolve_eagerly,
104106
resolve_label_or_snippet=(i < max_to_resolve),
105-
snippet_support=snippet_support,
107+
escape_path_sep=escape_path_sep,
106108
)
107109
completion_dict["kind"] = lsp.CompletionItemKind.TypeParameter
108110
completion_dict["label"] += " object"
@@ -117,7 +119,7 @@ def pylsp_completions(config, document, position):
117119
include_params=False,
118120
resolve=resolve_eagerly,
119121
resolve_label_or_snippet=(i < max_to_resolve),
120-
snippet_support=snippet_support,
122+
escape_path_sep=escape_path_sep,
121123
)
122124
completion_dict["kind"] = lsp.CompletionItemKind.TypeParameter
123125
completion_dict["label"] += " object"
@@ -227,7 +229,7 @@ def _format_completion(
227229
include_params=True,
228230
resolve=False,
229231
resolve_label_or_snippet=False,
230-
snippet_support=False,
232+
escape_path_sep=False,
231233
):
232234
completion = {
233235
"label": _label(d, resolve_label_or_snippet),
@@ -253,7 +255,7 @@ def _format_completion(
253255

254256
# Escape to prevent conflicts with the code snippets grammer
255257
# See also https://github.com/python-lsp/python-lsp-server/issues/373
256-
if snippet_support:
258+
if escape_path_sep:
257259
path = path.replace("\\", "\\\\")
258260
path = path.replace("/", "\\/")
259261

0 commit comments

Comments
 (0)
0