sublimelsp / LSP-ruff

LSP helper for ruff - an extremely fast Python linter, written in Rust.

Home Page:https://packagecontrol.io/packages/LSP-ruff

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Adding the option to format the selection in addition to format file

seperman opened this issue · comments

Hello,
Is it possible to add the option to format the selection?
Currently, we can only format the whole file.
Thanks

looks good to me?
image

My menu looks very different than yours. How come?
image

Are you still using ST 3?

I'm on Sublime build 4169. So I assume it is ST 4?

Looks good. I just tried a clean portable ST but it still works on my side. So I have no idea what's happening here.

I do see a payload sent to the server and it works...

:: [02:46:07.137] --> LSP-ruff textDocument/rangeFormatting (5): {'textDocument': {'uri': 'file:///xxx.py'}, 'options': {'insertSpaces': True, 'insertFinalNewline': True, 'tabSize': 4, 'trimFinalNewlines': True, 'trimTrailingWhitespace': True}, 'range': {'end': {'character': 0, 'line': 1}, 'start': {'character': 0, 'line': 0}}, 'workDoneToken': '$ublime-work-done-progress-5'}

I uninstalled and re-installed lsp and lsp-ruff. Also changed the interpreter path to another virtualenv. My menu doesn't look like yours but at least I have the "format selection" option now.

image
image

Also, I am on Ubuntu if that matters. I tried to avoid installing the debian package for virtualenv but gave up. All I wanted to do was to point lsp to the ruff-lsp package in a virtualenv, instead of having lsp-ruff create its own virtualenv in the ~/.cache folder.

The version of ruff that you were using likely didn't support it yet. That's why it's safest to use the bundled version.

(@jfcherng was showing you the right-click menu. That's why it's different from yours.)

Ok thanks. I'm happy the selection format works now.