Skip to main content

Extended refactoring capabilities for Python LSP Server using Rope.

Project description

pylsp-rope

Tests

Extended refactoring capabilities for Python LSP Server using Rope.

This is a plugin for Python LSP Server, so you also need to have it installed.

python-lsp-server already has basic built-in support for using Rope, but it's currently limited to just renaming and completion. Installing this plugin adds more refactoring functionality to python-lsp-server.

Installation

To use this plugin, you need to install this plugin in the same virtualenv as python-lsp-server itself.

pip install pylsp-rope

Then run pylsp as usual, the plugin will be auto-discovered by python-lsp-server if you've installed it to the right environment. On Vim, refer to Rope in Vim or Neovim. For other editors, refer to your IDE/text editor's documentation on how to setup a language server.

Configuration

There is no configuration yet.

Features

This plugin adds the following features to python-lsp-server:

  • extract method (codeAction)
  • extract variable (codeAction)
  • inline method/variable/parameter (codeAction)
  • use function (codeAction)
  • method to method object (codeAction)
  • convert local variable to field (codeAction)
  • organize imports (codeAction)
  • introduce parameter (codeAction)
  • more to come...

Refer to Rope documentation for more details on how these refactoring works.

Usage

Extract method

Variants:

  • Extract method
  • Extract global method
  • Extract method including similar statements
  • Extract global method including similar statements

This refactoring works by triggering CodeAction when selecting a block of code. Optionally, similar statements can also be extracted.

Extract variable

  • Extract variable
  • Extract global variable
  • Extract variable including similar statements
  • Extract global variable including similar statements

This refactoring works by triggering CodeAction when selecting a Python expression. Optionally, similar statements can also be extracted.

Inline

This refactoring works by triggering CodeAction when the cursor is on a resolvable Python identifier.

Use function

This refactoring works by triggering CodeAction when the cursor is on the function name of a def statement.

Method to method object

This refactoring works by triggering CodeAction when the cursor is on the function name of a def statement.

Convert local variable to field

This refactoring works by triggering CodeAction when the cursor is on a local variable.

Organize import

This refactoring works by triggering CodeAction anywhere.

Introduce parameter

This refactoring works by triggering CodeAction when the cursor is selecting a Python identifier, including attribute access.

Caveat

Support for working on unsaved document is currently experimental.

This plugin is in early development, so expect some bugs. Please report in Github issue tracker if you had any issues with the plugin.

Developing

See CONTRIBUTING.md.

Credits

This package was created with Cookiecutter from lieryan/cookiecutter-pylsp-plugin project template.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pylsp-rope-0.1.10.tar.gz (17.4 kB view details)

Uploaded Source

Built Distribution

pylsp_rope-0.1.10-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file pylsp-rope-0.1.10.tar.gz.

File metadata

  • Download URL: pylsp-rope-0.1.10.tar.gz
  • Upload date:
  • Size: 17.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for pylsp-rope-0.1.10.tar.gz
Algorithm Hash digest
SHA256 9e6104f15f922f633a4ba06ba0280f08a5e18973028f9bbdcae57b715d81cdd7
MD5 d6e0e6b1bc561a28cc30b671dfe6e08b
BLAKE2b-256 dd0434ada14854157ef4aea9bd292fd521cac36ddbe013b9fe9900aa399ade79

See more details on using hashes here.

File details

Details for the file pylsp_rope-0.1.10-py3-none-any.whl.

File metadata

  • Download URL: pylsp_rope-0.1.10-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for pylsp_rope-0.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 d5e9094415ff848b2034d4b64b4fdc5ec172ddf4e2a5d85c77bfa2da6f6ec61f
MD5 87d63fb4a43ed58f096533e79426e486
BLAKE2b-256 4bef77f89386626444bd467e05725834a927818c8453d940dbee132a1b0bdbff

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page