sublimelsp / LSP-pylsp

Convenience package for the Python Language Server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Renaming plugin is invalid

mel0n0 opened this issue · comments

When I try to modify the function name, after typing the Command Palette LSP:Rename, the status bar prompts that:

Nothing to rename

Before I added the User configuration file, I found the plugin jedi_rename could not be found.

Screen Shot 2022-08-24 at 5 07 07 PM

I've tried it on a simplest of projects and it seemed to work for me without setting any options.

You should enable log_server and report what you are seeing in the logs. More details at https://lsp.sublimetext.io/troubleshooting/#self-help-instructions.

I've also made an issue with some questions in the pylsp repo: python-lsp/python-lsp-server#255

Yeah, when I comment out that:

// "pylsp.plugins.jedi_rename.enabled": true,

The plugins jedi_rename still works as you mentioned. But it fails, I looked at the log panel and it has a warning that is:

LSP-pylsp: WARNING - pylsp.config.config - Failed to load hook pylsp_rename: '/Users/xxx/test.py' is not in the subpath of '/Applications/Sublime Text.app/Contents/MacOS' OR one path is relative and the other is absolute.

Then I checked my PATH in Sublime Text, it contained the path/usr/local/bin, so I don't know what this warning means.

This could mean that you are trying to rename file that is not within a project. You should make sure that the project folder is added to the side bar.

You can also run LSP: Troubleshoot server when that file is open and it will tell more info.

Thanks for your reply:-)

Indeed, it is not a project file, and it is a single simple script. After your comment, I enabled Troubleshoot Server, but I can't find any exceptions. The information captured is: Gathered Troubleshoot info

And warnings in the log panel:

:: --> LSP-pylsp textDocument/rename(10): {'newName': 'reqs_by', 'workDoneToken': 'wd10', 'textDocument': {'uri': 'file:///Users/xxx/Desktop/remove_moudle.py'}, 'position': {'line': 41, 'character': 12}}
LSP-pylsp: 2022-08-27 - WARNING - pylsp.config.config - Failed to load hook pylsp_rename: '/Users/xxx/Desktop/remove_moudle.py' is not in the subpath of '/Applications/Sublime Text.app/Contents/MacOS' OR one path is relative and the other is absolute.
:: <<< LSP-pylsp 10: []

I tried to change the name of a variable within a file in my project and it had no problem. So I wonder if it is because of a single file that it can't be renamed?

I tried to change the name of a variable within a file in my project and it had no problem. So I wonder if it is because of a single file that it can't be renamed?

Yes, pylsp requires the file to be in a workspace folder so you need your file to be in a folder added to the ST sidebar (don't need to save it as a project).

I guess the messaging in pylsp could be clearer and exposed to the user (not only in the logs but in the UI). But that would have to be done in the pylsp repo.