You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
rope alread internally supports moving modules using rename, but I hadn't figured out how moving files work in lsp protocol yet. That should be fairly easy, but I just hadn't got the chance to look at it yet, but yes, once this is implemented, rename should support moving files as well.
I have created a work-in-progress PR for this some time ago but had not had the chance to finish it. It was basically just porting the pylsp core's implementation of rope_rename into here. I'm not currently actively working on it so feel free to either pick up the PR and improve on it, or to restart the effort from fresh instead.
Mainly the PR hasn't really been tested on how it interacts if rope rename feature is also enabled in pylsp core. Ideally I think there shouldn't be two separate implementation of rope between pylsp core and pylsp-rope, so removing rope support out of core and into pylsp-rope might be something we want to explore in the future, but this will be something that will need to be coordinated with core pylsp maintainers.
However, in the mean time, if we implement rename in pylsp-core, it's going to be confusing if the user accidentally enabled two separate implementations of rename rope. I think installing pylsp-rope should probably just force disable pylsp core's rename. There's some thinking that needs to be done to plan such transition, if it's even desirable to merge the implementations.
Activity
italovieira commentedon Nov 20, 2023
Does this also include rename modules (and moving files if necessary)?
lieryan commentedon Nov 23, 2023
rope alread internally supports moving modules using rename, but I hadn't figured out how moving files work in lsp protocol yet. That should be fairly easy, but I just hadn't got the chance to look at it yet, but yes, once this is implemented, rename should support moving files as well.
tkrabel commentedon Dec 24, 2023
@lieryan any progress on this? Happy to help!
lieryan commentedon Dec 24, 2023
I have created a work-in-progress PR for this some time ago but had not had the chance to finish it. It was basically just porting the pylsp core's implementation of rope_rename into here. I'm not currently actively working on it so feel free to either pick up the PR and improve on it, or to restart the effort from fresh instead.
Mainly the PR hasn't really been tested on how it interacts if rope rename feature is also enabled in pylsp core. Ideally I think there shouldn't be two separate implementation of rope between pylsp core and pylsp-rope, so removing rope support out of core and into pylsp-rope might be something we want to explore in the future, but this will be something that will need to be coordinated with core pylsp maintainers.
However, in the mean time, if we implement rename in pylsp-core, it's going to be confusing if the user accidentally enabled two separate implementations of rename rope. I think installing pylsp-rope should probably just force disable pylsp core's rename. There's some thinking that needs to be done to plan such transition, if it's even desirable to merge the implementations.
HAOCHENYE commentedon Aug 19, 2024
This might be a silly question... How should I use the rename file/rename module functionality? For example, if I have two files
a.pyandb.py:a.pyb.pyNow, I want to rename
a.pyto something likec.py, and I want the code inb.pyto automatically update to importafromc.py.I'm not sure how to configure my LSP client for this... For renaming variables, the following configuration works fine:
{ "neovim/nvim-lspconfig", ---@class PluginLspOpts opts = { ---@type lspconfig.options servers = { -- pyright will be automatically installed with mason and loaded with lspconfig pylsp = { cmd = { "pylsp", "--verbose", "--log-file", "/tmp/pylsp-log.txt" }, plugins = { pylsp_rope = { rename = true }, rope_rename = { enabled = false }, jedi_rename = { enabled = false }, }, on_attach = function(client, bufnr) vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', { noremap = true, silent = true }) end, }, }, }, },However, I'm not sure how to perform a rename file operation. Any guidance would be appreciated.