Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add code completions to rope_autoimport plugin #471

Merged
merged 21 commits into from
Oct 28, 2023
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ This server can be configured using the `workspace/didChangeConfiguration` metho
| `pylsp.plugins.pylint.enabled` | `boolean` | Enable or disable the plugin. | `false` |
| `pylsp.plugins.pylint.args` | `array` of non-unique `string` items | Arguments to pass to pylint. | `[]` |
| `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` |
| `pylsp.plugins.rope_autoimport.enabled` | `boolean` | Enable or disable autoimport. | `false` |
ccordoba12 marked this conversation as resolved.
Show resolved Hide resolved
| `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` |
| `pylsp.plugins.rope_autoimport.completions.enabled` | `boolean` | Enable or disable autoimport completions. | `true` |
| `pylsp.plugins.rope_autoimport.code_actions.enabled` | `boolean` | Enable or disable autoimport code actions (e.g. for quick fixes). | `true` |
| `pylsp.plugins.rope_autoimport.memory` | `boolean` | Make the autoimport database memory only. Drastically increases startup time. | `false` |
| `pylsp.plugins.rope_completion.enabled` | `boolean` | Enable or disable the plugin. | `false` |
| `pylsp.plugins.rope_completion.eager` | `boolean` | Resolve documentation and detail eagerly. | `false` |
Expand Down
3 changes: 2 additions & 1 deletion docs/autoimport.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
Requirements:

1. install `python-lsp-server[rope]`
2. set `pylsp.plugins.rope_autoimport.enabled` to `true`
2. set `pylsp.plugins.rope_autoimport.enabled` to `true``
tkrabel-db marked this conversation as resolved.
Show resolved Hide resolved
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`

## Startup

Expand Down
130 changes: 105 additions & 25 deletions pylsp/config/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@
"properties": {
"pylsp.configurationSources": {
"type": "array",
"default": ["pycodestyle"],
"default": [
"pycodestyle"
],
"description": "List of configuration sources to use.",
"items": {
"type": "string",
"enum": ["pycodestyle", "flake8"]
"enum": [
"pycodestyle",
"flake8"
]
},
"uniqueItems": true
},
Expand All @@ -20,7 +25,10 @@
"description": "Enable or disable the plugin (disabling required to use `yapf`)."
},
"pylsp.plugins.flake8.config": {
"type": ["string", "null"],
"type": [
"string",
"null"
],
"default": null,
"description": "Path to the config file that will be the authoritative config source."
},
Expand Down Expand Up @@ -51,12 +59,18 @@
"description": "Path to the flake8 executable."
},
"pylsp.plugins.flake8.filename": {
"type": ["string", "null"],
"type": [
"string",
"null"
],
"default": null,
"description": "Only check for filenames matching the patterns in this list."
},
"pylsp.plugins.flake8.hangClosing": {
"type": ["boolean", "null"],
"type": [
"boolean",
"null"
],
"default": null,
"description": "Hang closing bracket instead of matching indentation of opening bracket's line."
},
Expand All @@ -74,25 +88,36 @@
"description": "Maximum allowed complexity threshold."
},
"pylsp.plugins.flake8.maxLineLength": {
"type": ["integer", "null"],
"type": [
"integer",
"null"
],
"default": null,
"description": "Maximum allowed line length for the entirety of this run."
},
"pylsp.plugins.flake8.indentSize": {
"type": ["integer", "null"],
"type": [
"integer",
"null"
],
"default": null,
"description": "Set indentation spaces."
},
"pylsp.plugins.flake8.perFileIgnores": {
"type": ["array"],
"type": [
"array"
],
"default": [],
"items": {
"type": "string"
},
"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\"]`)."
},
"pylsp.plugins.flake8.select": {
"type": ["array", "null"],
"type": [
"array",
"null"
],
"default": null,
"items": {
"type": "string"
Expand All @@ -102,7 +127,9 @@
},
"pylsp.plugins.jedi.auto_import_modules": {
"type": "array",
"default": ["numpy"],
"default": [
"numpy"
],
"items": {
"type": "string"
},
Expand All @@ -117,12 +144,18 @@
"description": "Define extra paths for jedi.Script."
},
"pylsp.plugins.jedi.env_vars": {
"type": ["object", "null"],
"type": [
"object",
"null"
],
"default": null,
"description": "Define environment variables for jedi.Script and Jedi.names."
},
"pylsp.plugins.jedi.environment": {
"type": ["string", "null"],
"type": [
"string",
"null"
],
"default": null,
"description": "Define environment for jedi.Script and Jedi.names."
},
Expand Down Expand Up @@ -166,7 +199,12 @@
"items": {
"type": "string"
},
"default": ["pandas", "numpy", "tensorflow", "matplotlib"],
"default": [
"pandas",
"numpy",
"tensorflow",
"matplotlib"
],
"description": "Modules for which labels and snippets should be cached."
},
"pylsp.plugins.jedi_definition.enabled": {
Expand Down Expand Up @@ -267,7 +305,10 @@
"description": "When parsing directories, only check filenames matching these patterns."
},
"pylsp.plugins.pycodestyle.select": {
"type": ["array", "null"],
"type": [
"array",
"null"
],
"default": null,
"items": {
"type": "string"
Expand All @@ -285,17 +326,26 @@
"description": "Ignore errors and warnings"
},
"pylsp.plugins.pycodestyle.hangClosing": {
"type": ["boolean", "null"],
"type": [
"boolean",
"null"
],
"default": null,
"description": "Hang closing bracket instead of matching indentation of opening bracket's line."
},
"pylsp.plugins.pycodestyle.maxLineLength": {
"type": ["integer", "null"],
"type": [
"integer",
"null"
],
"default": null,
"description": "Set maximum allowed line length."
},
"pylsp.plugins.pycodestyle.indentSize": {
"type": ["integer", "null"],
"type": [
"integer",
"null"
],
"default": null,
"description": "Set indentation spaces."
},
Expand All @@ -305,9 +355,17 @@
"description": "Enable or disable the plugin."
},
"pylsp.plugins.pydocstyle.convention": {
"type": ["string", "null"],
"type": [
"string",
"null"
],
"default": null,
"enum": ["pep257", "numpy", "google", null],
"enum": [
"pep257",
"numpy",
"google",
null
],
"description": "Choose the basic list of checked errors by specifying an existing convention."
},
"pylsp.plugins.pydocstyle.addIgnore": {
Expand Down Expand Up @@ -338,7 +396,10 @@
"description": "Ignore errors and warnings"
},
"pylsp.plugins.pydocstyle.select": {
"type": ["array", "null"],
"type": [
"array",
"null"
],
"default": null,
"items": {
"type": "string"
Expand Down Expand Up @@ -376,14 +437,27 @@
"description": "Arguments to pass to pylint."
},
"pylsp.plugins.pylint.executable": {
"type": ["string", "null"],
"type": [
"string",
"null"
],
"default": null,
"description": "Executable to run pylint with. Enabling this will run pylint on unsaved files via stdin. Can slow down workflow. Only works with python3."
},
"pylsp.plugins.rope_autoimport.enabled": {
"type": "boolean",
"default": false,
"description": "Enable or disable autoimport."
"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."
},
"pylsp.plugins.rope_autoimport.completions.enabled": {
"type": "boolean",
"default": true,
"description": "Enable or disable autoimport completions."
},
"pylsp.plugins.rope_autoimport.code_actions.enabled": {
"type": "boolean",
"default": true,
"description": "Enable or disable autoimport code actions (e.g. for quick fixes)."
},
"pylsp.plugins.rope_autoimport.memory": {
"type": "boolean",
Expand All @@ -406,12 +480,18 @@
"description": "Enable or disable the plugin."
},
"pylsp.rope.extensionModules": {
"type": ["string", "null"],
"type": [
"string",
"null"
],
"default": null,
"description": "Builtin and c-extension modules that are allowed to be imported and inspected by rope."
},
"pylsp.rope.ropeFolder": {
"type": ["array", "null"],
"type": [
"array",
"null"
],
"default": null,
"items": {
"type": "string"
Expand All @@ -420,4 +500,4 @@
"description": "The name of the folder in which rope stores project configurations and data. Pass `null` for not using such a folder at all."
}
}
}
}
Loading
Loading