Skip to content

Commit d129676

Browse files
committed
Rename resolve options because they apply now to labels and snippets
1 parent 8483efd commit d129676

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

CONFIGURATION.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ This server can be configured using `workspace/didChangeConfiguration` method. E
2222
| `pylsp.plugins.jedi_completion.include_class_objects` | `boolean` | Adds class objects as a separate completion item. | `true` |
2323
| `pylsp.plugins.jedi_completion.fuzzy` | `boolean` | Enable fuzzy when requesting autocomplete. | `false` |
2424
| `pylsp.plugins.jedi_completion.eager` | `boolean` | Resolve documentation and detail eagerly. | `false` |
25-
| `pylsp.plugins.jedi_completion.resolve_at_most_labels` | `number` | How many labels (at most) should be resolved? | `25` |
26-
| `pylsp.plugins.jedi_completion.cache_labels_for` | `array` of `string` items | Modules for which the labels should be cached. | `["pandas", "numpy", "tensorflow", "matplotlib"]` |
25+
| `pylsp.plugins.jedi_completion.resolve_at_most` | `number` | How many labels and snippets (at most) should be resolved? | `25` |
26+
| `pylsp.plugins.jedi_completion.cache_for` | `array` of `string` items | Modules for which labels and snippets should be cached. | `["pandas", "numpy", "tensorflow", "matplotlib"]` |
2727
| `pylsp.plugins.jedi_definition.enabled` | `boolean` | Enable or disable the plugin. | `true` |
2828
| `pylsp.plugins.jedi_definition.follow_imports` | `boolean` | The goto call will follow imports. | `true` |
2929
| `pylsp.plugins.jedi_definition.follow_builtin_imports` | `boolean` | If follow_imports is True will decide if it follow builtin imports. | `true` |

pylsp/config/schema.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,18 +104,18 @@
104104
"default": false,
105105
"description": "Resolve documentation and detail eagerly."
106106
},
107-
"pylsp.plugins.jedi_completion.resolve_at_most_labels": {
107+
"pylsp.plugins.jedi_completion.resolve_at_most": {
108108
"type": "number",
109109
"default": 25,
110-
"description": "How many labels (at most) should be resolved?"
110+
"description": "How many labels and snippets (at most) should be resolved?"
111111
},
112-
"pylsp.plugins.jedi_completion.cache_labels_for": {
112+
"pylsp.plugins.jedi_completion.cache_for": {
113113
"type": "array",
114114
"items": {
115115
"type": "string"
116116
},
117117
"default": ["pandas", "numpy", "tensorflow", "matplotlib"],
118-
"description": "Modules for which the labels should be cached."
118+
"description": "Modules for which labels and snippets should be cached."
119119
},
120120
"pylsp.plugins.jedi_definition.enabled": {
121121
"type": "boolean",

pylsp/plugins/jedi_completion.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ def pylsp_completions(config, document, position):
5555
should_include_params = settings.get('include_params')
5656
should_include_class_objects = settings.get('include_class_objects', True)
5757

58-
max_labels_resolve = settings.get('resolve_at_most_labels', 25)
59-
modules_to_cache_labels_for = settings.get('cache_labels_for', None)
60-
if modules_to_cache_labels_for is not None:
61-
LABEL_RESOLVER.cached_modules = modules_to_cache_labels_for
62-
SNIPPET_RESOLVER.cached_modules = modules_to_cache_labels_for
58+
max_to_resolve = settings.get('resolve_at_most', 25)
59+
modules_to_cache_for = settings.get('cache_for', None)
60+
if modules_to_cache_for is not None:
61+
LABEL_RESOLVER.cached_modules = modules_to_cache_for
62+
SNIPPET_RESOLVER.cached_modules = modules_to_cache_for
6363

6464
include_params = snippet_support and should_include_params and use_snippets(document, position)
6565
include_class_objects = snippet_support and should_include_class_objects and use_snippets(document, position)
@@ -69,7 +69,7 @@ def pylsp_completions(config, document, position):
6969
c,
7070
include_params,
7171
resolve=resolve_eagerly,
72-
resolve_label_or_snippet=(i < max_labels_resolve)
72+
resolve_label_or_snippet=(i < max_to_resolve)
7373
)
7474
for i, c in enumerate(completions)
7575
]
@@ -82,7 +82,7 @@ def pylsp_completions(config, document, position):
8282
c,
8383
False,
8484
resolve=resolve_eagerly,
85-
resolve_label_or_snippet=(i < max_labels_resolve)
85+
resolve_label_or_snippet=(i < max_to_resolve)
8686
)
8787
completion_dict['kind'] = lsp.CompletionItemKind.TypeParameter
8888
completion_dict['label'] += ' object'

test/plugins/test_completion.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def test_jedi_completion_item_resolve(config, workspace):
149149
# Over the blank line
150150
com_position = {'line': 8, 'character': 0}
151151
doc = Document(DOC_URI, workspace, DOC)
152-
config.update({'plugins': {'jedi_completion': {'resolve_at_most_labels': math.inf}}})
152+
config.update({'plugins': {'jedi_completion': {'resolve_at_most': math.inf}}})
153153
completions = pylsp_jedi_completions(config, doc, com_position)
154154

155155
items = {c['label']: c for c in completions}
@@ -187,13 +187,13 @@ def test_jedi_completion_resolve_at_most(config, workspace):
187187
doc = Document(DOC_URI, workspace, DOC)
188188

189189
# Do not resolve any labels
190-
config.update({'plugins': {'jedi_completion': {'resolve_at_most_labels': 0}}})
190+
config.update({'plugins': {'jedi_completion': {'resolve_at_most': 0}}})
191191
items = pylsp_jedi_completions(config, doc, com_position)
192192
labels = {i['label'] for i in items}
193193
assert 'isabs' in labels
194194

195195
# Resolve all items
196-
config.update({'plugins': {'jedi_completion': {'resolve_at_most_labels': math.inf}}})
196+
config.update({'plugins': {'jedi_completion': {'resolve_at_most': math.inf}}})
197197
items = pylsp_jedi_completions(config, doc, com_position)
198198
labels = {i['label'] for i in items}
199199
assert 'isabs(path)' in labels
@@ -214,7 +214,7 @@ def test_jedi_completion_ordering(config, workspace):
214214
# Over the blank line
215215
com_position = {'line': 8, 'character': 0}
216216
doc = Document(DOC_URI, workspace, DOC)
217-
config.update({'plugins': {'jedi_completion': {'resolve_at_most_labels': math.inf}}})
217+
config.update({'plugins': {'jedi_completion': {'resolve_at_most': math.inf}}})
218218
completions = pylsp_jedi_completions(config, doc, com_position)
219219

220220
items = {c['label']: c['sortText'] for c in completions}

0 commit comments

Comments
 (0)