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. Refer to your IDE/text editor's documentation on how to setup a language server in your IDE/text editor.

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)
  • more to come...

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

Usage

Extract method

This refactoring works by triggering a CodeAction when selecting a block of code.

Extract variable

This refactoring works by triggering a CodeAction when selecting a Python expression.

Inline

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

Use function

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

Method to method object

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

Caveat

Support for working on unsaved document is currently incomplete.

Before you start refactoring you must save all unsaved changes in your text editor. I highly recommended that you enable autosave on your text editor.

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.6.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

pylsp_rope-0.1.6-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pylsp-rope-0.1.6.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

File hashes

Hashes for pylsp-rope-0.1.6.tar.gz
Algorithm Hash digest
SHA256 272a58bb18128624c8a1b13a7a6d95dd38c0f452deb37c0454e1887a6ebda8be
MD5 bdf4fa52ed4997a754a2a2d180188bf6
BLAKE2b-256 9d32980db1d92ced1525dcd868a918e3fe612f2dca691c8e42ced1aa37484218

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pylsp_rope-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 17.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

File hashes

Hashes for pylsp_rope-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 e9ce62b2f86b8933fb60333587d91110928e00b3d023195e6bfc408dde7fb0bc
MD5 78b967a43c7f8edc4d7ea173bf67fb0c
BLAKE2b-256 8642daf466b032f6ea46a7be2e6b6a6711a2fc109ac0c5253bfcd5c22e59c469

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