Skip to content

About

😈 Naughty imps messing with your imports while you're renaming your files.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Latest commit

 

History

16 Commits

Folders and files

Repository files navigation

pyimp.nvim

Naughty imps messing with your imports while you're renaming your files.

pyimp.nvim is a tiny Neovim helper plus Rust LSP sidecar for ty. It listens for workspace/willRenameFiles and rewrites Python imports before files or package directories are renamed.

It exists to provide file/package rename refactoring that ty does not currently implement itself. See astral-sh/ty#1560.

What it does

  • Updates Python imports on file renames.
  • Updates imports on package/directory renames.
  • Supports absolute and relative imports.
  • Handles src/ layouts and namespace packages.
  • Runs as a sidecar to an already-attached ty client.

Install with lazy.nvim

{
  "AlexanderFarkas/pyimp.nvim",
  ft = "python",
  build = "./scripts/install.sh",
  config = function()
    require("pyimp").setup()
  end,
}

The install script downloads a prebuilt pyimp-lsp release binary into bin/pyimp-lsp. If no matching release binary is available, it falls back to cargo build --release and copies the built binary into bin/.

For Snacks explorer rename persistence, use snacks-rename-fix.nvim.

If you want to provide your own binary:

{
  "AlexanderFarkas/pyimp.nvim",
  ft = "python",
  config = function()
    require("pyimp").setup({
      cmd = { "/path/to/pyimp-lsp" },
    })
  end,
}

Requirements

  • Neovim with LSP file-operation support.
  • ty configured as your Python LSP client.
  • curl or wget for release downloads.
  • Rust toolchain only if a prebuilt binary is unavailable.

Releasing

Push a version tag to build release binaries:

git tag v0.1.1
git push origin v0.1.1

GitHub Actions publishes macOS and Linux tarballs named like:

pyimp-lsp-aarch64-apple-darwin.tar.gz
pyimp-lsp-x86_64-unknown-linux-gnu.tar.gz
pyimp-lsp-aarch64-unknown-linux-gnu.tar.gz

Notes

pyimp.nvim does not replace ty. It starts only after a ty client attaches and reuses ty's root/workspace folders.

About

😈 Naughty imps messing with your imports while you're renaming your files.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages