rust-lang / rust-enhanced

The official Sublime Text 4 package for the Rust Programming Language
MIT License
780 stars 104 forks source link

Format selection disabled in context menu but Format document is not #449

Closed detly closed 3 years ago

detly commented 3 years ago

Sublime Text 3 (Build 3211) Rust enhanced v2.22.0 OS Name: Ubuntu 20.04

I have LSP installed via Package Control, and the stable and beta releases of RLS installed via Rustup. I do not have Cargo etc. on my system path, but I have added:

    "clients":
    {
        "rls":
        {
            "command": ["~/.cargo/bin/rustup", "run", "beta", "rls"],
        }
    },

...to my LSP settings.

Expected behavior

Both Format document and Format selection should be enabled in the context menu.

Actual behavior

Format document is enabled. Format selection is not.

The fact that Format document is enabled and works makes me think that LSP and RLS are communicating fine, but there's a capability missing or something like that.

Here's some console messages (I removed what I thought was from unrelated plugins, let me know if you want that too):

LSP: global configs ['flow=False', 'jdtls=False', 'haskell-ide-engine=False', 'erlang-ls=False', 'intelephense-ls=False', 'lsp-tsserver=False', 'dart=False', 'rlang=False', 'elixir-ls=False', 'ruby=False', 'javascript-typescript-langserver=False', 'pyls=False', 'cquery=False', 'golsp=False', 'reason=False', 'gopls=False', 'rls=False', 'polymer-ide=False', 'rust-analyzer=False', 'sourcekit-lsp=False', 'clangd=False', 'vscode-css=False', 'typescript-language-server=False', 'sorbet=False', 'bashls=False', 'phpls=False', 'ocaml=False']
LSP: applying .sublime-project override for rls
LSP: group 0 view /home/jason/Code/td-aseconf/src/lib.rs
LSP: window 2 starting 1 initial views
LSP: applying .sublime-project override for rls
LSP: window 2 requests rls for /home/jason/Code/td-aseconf/src/lib.rs
LSP: starting ['/home/jason/.cargo/bin/rustup', 'run', 'beta', 'rls']
LSP: window 2 added session rls
LSP: single folder session: /home/jason/Code/td-aseconf
LSP: rls: Supported execute commands: ['rls.applySuggestion-71626', 'rls.deglobImports-71626']
LSP: rls: registering capability: didChangeWatchedFilesProvider
Unable to open /home/jason/Code/config-st3/Packages/Rust Enhanced/RustEnhanced.sublime-settings
reloading settings Packages/User/RustEnhanced.sublime-settings
LSP: found ready session rls for /home/jason/Code/td-aseconf/src/main.rs
LSP: applying .sublime-project override for rls
LSP: found ready session rls for /home/jason/Code/td-aseconf/src/main.rs
Unable to open /home/jason/Code/config-st3/Packages/LSP/LSP.sublime-settings

I honestly don't know what Unable to open /home/jason/Code/config-st3/Packages/LSP/LSP.sublime-settings is doing there, since LSP works fine. Unable to open /home/jason/Code/config-st3/Packages/Rust Enhanced/RustEnhanced.sublime-settings is also a bit weird, since Rust Enhanced seems to use my settings for eg. appearances, Cargo path.

ehuss commented 3 years ago

Format Selection/Format Document are options provided by the LSP plugin and are unrelated to Rust Enhanced. Perhaps file an issue over there? It could also be an issue with RLS, IIRC range-formatting used to require unstable options, but I don't know what the current status is. You could also try one of the user forums.

detly commented 3 years ago

Thanks!

detly commented 3 years ago

FYI I raised this over on the LSP issues but it turns out that the problem is... neither rls nor rust-analyzer support formatting a selected range. So perhaps this is a documentation issue with this repo, but I'll leave it to your discretion.