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
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.
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.