Skip to content

Commit 2a5a953

Browse files
tkrabel-dbccordoba12krassowski
authored
Add code completions to rope_autoimport plugin (#471)
Co-authored-by: Carlos Cordoba <[email protected]> Co-authored-by: Michał Krassowski <[email protected]>
1 parent 728929c commit 2a5a953

File tree

8 files changed

+381
-135
lines changed

8 files changed

+381
-135
lines changed

Diff for: CONFIGURATION.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ This server can be configured using the `workspace/didChangeConfiguration` metho
6464
| `pylsp.plugins.pylint.enabled` | `boolean` | Enable or disable the plugin. | `false` |
6565
| `pylsp.plugins.pylint.args` | `array` of non-unique `string` items | Arguments to pass to pylint. | `[]` |
6666
| `pylsp.plugins.pylint.executable` | `string` | Executable to run pylint with. Enabling this will run pylint on unsaved files via stdin. Can slow down workflow. Only works with python3. | `null` |
67-
| `pylsp.plugins.rope_autoimport.enabled` | `boolean` | Enable or disable autoimport. | `false` |
67+
| `pylsp.plugins.rope_autoimport.enabled` | `boolean` | Enable or disable autoimport. If false, neither completions nor code actions are enabled. If true, the respective features can be enabled or disabled individually. | `false` |
68+
| `pylsp.plugins.rope_autoimport.completions.enabled` | `boolean` | Enable or disable autoimport completions. | `true` |
69+
| `pylsp.plugins.rope_autoimport.code_actions.enabled` | `boolean` | Enable or disable autoimport code actions (e.g. for quick fixes). | `true` |
6870
| `pylsp.plugins.rope_autoimport.memory` | `boolean` | Make the autoimport database memory only. Drastically increases startup time. | `false` |
6971
| `pylsp.plugins.rope_completion.enabled` | `boolean` | Enable or disable the plugin. | `false` |
7072
| `pylsp.plugins.rope_completion.eager` | `boolean` | Resolve documentation and detail eagerly. | `false` |

Diff for: docs/autoimport.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Requirements:
44

55
1. install `python-lsp-server[rope]`
66
2. set `pylsp.plugins.rope_autoimport.enabled` to `true`
7+
3. This enables both completions and code actions. You can switch them off by setting `pylsp.plugins.rope_autoimport.completions.enabled` and/or `pylsp.plugins.rope_autoimport.code_actions.enabled` to `false`
78

89
## Startup
910

Diff for: pylsp/config/schema.json

+105-25
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,16 @@
66
"properties": {
77
"pylsp.configurationSources": {
88
"type": "array",
9-
"default": ["pycodestyle"],
9+
"default": [
10+
"pycodestyle"
11+
],
1012
"description": "List of configuration sources to use.",
1113
"items": {
1214
"type": "string",
13-
"enum": ["pycodestyle", "flake8"]
15+
"enum": [
16+
"pycodestyle",
17+
"flake8"
18+
]
1419
},
1520
"uniqueItems": true
1621
},
@@ -20,7 +25,10 @@
2025
"description": "Enable or disable the plugin (disabling required to use `yapf`)."
2126
},
2227
"pylsp.plugins.flake8.config": {
23-
"type": ["string", "null"],
28+
"type": [
29+
"string",
30+
"null"
31+
],
2432
"default": null,
2533
"description": "Path to the config file that will be the authoritative config source."
2634
},
@@ -51,12 +59,18 @@
5159
"description": "Path to the flake8 executable."
5260
},
5361
"pylsp.plugins.flake8.filename": {
54-
"type": ["string", "null"],
62+
"type": [
63+
"string",
64+
"null"
65+
],
5566
"default": null,
5667
"description": "Only check for filenames matching the patterns in this list."
5768
},
5869
"pylsp.plugins.flake8.hangClosing": {
59-
"type": ["boolean", "null"],
70+
"type": [
71+
"boolean",
72+
"null"
73+
],
6074
"default": null,
6175
"description": "Hang closing bracket instead of matching indentation of opening bracket's line."
6276
},
@@ -74,25 +88,36 @@
7488
"description": "Maximum allowed complexity threshold."
7589
},
7690
"pylsp.plugins.flake8.maxLineLength": {
77-
"type": ["integer", "null"],
91+
"type": [
92+
"integer",
93+
"null"
94+
],
7895
"default": null,
7996
"description": "Maximum allowed line length for the entirety of this run."
8097
},
8198
"pylsp.plugins.flake8.indentSize": {
82-
"type": ["integer", "null"],
99+
"type": [
100+
"integer",
101+
"null"
102+
],
83103
"default": null,
84104
"description": "Set indentation spaces."
85105
},
86106
"pylsp.plugins.flake8.perFileIgnores": {
87-
"type": ["array"],
107+
"type": [
108+
"array"
109+
],
88110
"default": [],
89111
"items": {
90112
"type": "string"
91113
},
92114
"description": "A pairing of filenames and violation codes that defines which violations to ignore in a particular file, for example: `[\"file_path.py:W305,W304\"]`)."
93115
},
94116
"pylsp.plugins.flake8.select": {
95-
"type": ["array", "null"],
117+
"type": [
118+
"array",
119+
"null"
120+
],
96121
"default": null,
97122
"items": {
98123
"type": "string"
@@ -102,7 +127,9 @@
102127
},
103128
"pylsp.plugins.jedi.auto_import_modules": {
104129
"type": "array",
105-
"default": ["numpy"],
130+
"default": [
131+
"numpy"
132+
],
106133
"items": {
107134
"type": "string"
108135
},
@@ -117,12 +144,18 @@
117144
"description": "Define extra paths for jedi.Script."
118145
},
119146
"pylsp.plugins.jedi.env_vars": {
120-
"type": ["object", "null"],
147+
"type": [
148+
"object",
149+
"null"
150+
],
121151
"default": null,
122152
"description": "Define environment variables for jedi.Script and Jedi.names."
123153
},
124154
"pylsp.plugins.jedi.environment": {
125-
"type": ["string", "null"],
155+
"type": [
156+
"string",
157+
"null"
158+
],
126159
"default": null,
127160
"description": "Define environment for jedi.Script and Jedi.names."
128161
},
@@ -166,7 +199,12 @@
166199
"items": {
167200
"type": "string"
168201
},
169-
"default": ["pandas", "numpy", "tensorflow", "matplotlib"],
202+
"default": [
203+
"pandas",
204+
"numpy",
205+
"tensorflow",
206+
"matplotlib"
207+
],
170208
"description": "Modules for which labels and snippets should be cached."
171209
},
172210
"pylsp.plugins.jedi_definition.enabled": {
@@ -267,7 +305,10 @@
267305
"description": "When parsing directories, only check filenames matching these patterns."
268306
},
269307
"pylsp.plugins.pycodestyle.select": {
270-
"type": ["array", "null"],
308+
"type": [
309+
"array",
310+
"null"
311+
],
271312
"default": null,
272313
"items": {
273314
"type": "string"
@@ -285,17 +326,26 @@
285326
"description": "Ignore errors and warnings"
286327
},
287328
"pylsp.plugins.pycodestyle.hangClosing": {
288-
"type": ["boolean", "null"],
329+
"type": [
330+
"boolean",
331+
"null"
332+
],
289333
"default": null,
290334
"description": "Hang closing bracket instead of matching indentation of opening bracket's line."
291335
},
292336
"pylsp.plugins.pycodestyle.maxLineLength": {
293-
"type": ["integer", "null"],
337+
"type": [
338+
"integer",
339+
"null"
340+
],
294341
"default": null,
295342
"description": "Set maximum allowed line length."
296343
},
297344
"pylsp.plugins.pycodestyle.indentSize": {
298-
"type": ["integer", "null"],
345+
"type": [
346+
"integer",
347+
"null"
348+
],
299349
"default": null,
300350
"description": "Set indentation spaces."
301351
},
@@ -305,9 +355,17 @@
305355
"description": "Enable or disable the plugin."
306356
},
307357
"pylsp.plugins.pydocstyle.convention": {
308-
"type": ["string", "null"],
358+
"type": [
359+
"string",
360+
"null"
361+
],
309362
"default": null,
310-
"enum": ["pep257", "numpy", "google", null],
363+
"enum": [
364+
"pep257",
365+
"numpy",
366+
"google",
367+
null
368+
],
311369
"description": "Choose the basic list of checked errors by specifying an existing convention."
312370
},
313371
"pylsp.plugins.pydocstyle.addIgnore": {
@@ -338,7 +396,10 @@
338396
"description": "Ignore errors and warnings"
339397
},
340398
"pylsp.plugins.pydocstyle.select": {
341-
"type": ["array", "null"],
399+
"type": [
400+
"array",
401+
"null"
402+
],
342403
"default": null,
343404
"items": {
344405
"type": "string"
@@ -376,14 +437,27 @@
376437
"description": "Arguments to pass to pylint."
377438
},
378439
"pylsp.plugins.pylint.executable": {
379-
"type": ["string", "null"],
440+
"type": [
441+
"string",
442+
"null"
443+
],
380444
"default": null,
381445
"description": "Executable to run pylint with. Enabling this will run pylint on unsaved files via stdin. Can slow down workflow. Only works with python3."
382446
},
383447
"pylsp.plugins.rope_autoimport.enabled": {
384448
"type": "boolean",
385449
"default": false,
386-
"description": "Enable or disable autoimport."
450+
"description": "Enable or disable autoimport. If false, neither completions nor code actions are enabled. If true, the respective features can be enabled or disabled individually."
451+
},
452+
"pylsp.plugins.rope_autoimport.completions.enabled": {
453+
"type": "boolean",
454+
"default": true,
455+
"description": "Enable or disable autoimport completions."
456+
},
457+
"pylsp.plugins.rope_autoimport.code_actions.enabled": {
458+
"type": "boolean",
459+
"default": true,
460+
"description": "Enable or disable autoimport code actions (e.g. for quick fixes)."
387461
},
388462
"pylsp.plugins.rope_autoimport.memory": {
389463
"type": "boolean",
@@ -406,12 +480,18 @@
406480
"description": "Enable or disable the plugin."
407481
},
408482
"pylsp.rope.extensionModules": {
409-
"type": ["string", "null"],
483+
"type": [
484+
"string",
485+
"null"
486+
],
410487
"default": null,
411488
"description": "Builtin and c-extension modules that are allowed to be imported and inspected by rope."
412489
},
413490
"pylsp.rope.ropeFolder": {
414-
"type": ["array", "null"],
491+
"type": [
492+
"array",
493+
"null"
494+
],
415495
"default": null,
416496
"items": {
417497
"type": "string"
@@ -420,4 +500,4 @@
420500
"description": "The name of the folder in which rope stores project configurations and data. Pass `null` for not using such a folder at all."
421501
}
422502
}
423-
}
503+
}

0 commit comments

Comments
 (0)