sublimelsp / LSP-rust-analyzer

Convenience package for rust-analyzer
MIT License
70 stars 11 forks source link

project specific configuration at the root of the project #82

Closed alexzanderr closed 2 years ago

alexzanderr commented 2 years ago

Hello.

This is more like a question issue than a problem issue.

I've seen that this plugin offers a LSP-rust-analyzer/LSP-rust-analyzer.sublime-settings with configuration for rust-analyzer.

But is it possible to create project specific configuration in the project root?

Do I need to put it inside rust-project.json, *.sublime-project or what file should be?

I've put rust-project.json at the root of my project:

{
    "settings": {
        "rust-analyzer.inlayHints.typeHints.enable": true,
        "rust-analyzer.procMacro.enable": true,
        "rust-analyzer.lens.enable": false,
        "rust-analyzer.checkOnSave.enable": true,
        "rust-analyzer.diagnostics.disabled": [
            "inactive-code",
            "unresolved-macro-call",
            "unresolved-proc-macro",
            "macro-error"
        ],
        "rust-analyzer.completion.autoimport.enable": false,
        "rust-analyzer.inlayHints.chainingHints.enable": true,
        "rust-analyzer.cargo.features": [],
        "rust-analyzer.typing.autoClosingAngleBrackets.enable": true
    }
}

but doesnt seem to work.

I see that the message I get inside sublime is rust-analyzer: failed to load workspace.

Thanks in advance.

alexzanderr commented 2 years ago

Okey, I found the solution.

<project_name>.sublime-project file is needed and needs to contain rust-analyzer specific configuration:

    "settings": {
        "LSP": {
            "rust-analyzer": {
                "settings": {
                    "rust-analyzer.inlayHints.typeHints.enable": true,
                    "rust-analyzer.procMacro.enable": true,
                    "rust-analyzer.lens.enable": false,
                    "rust-analyzer.checkOnSave.enable": true,
                    "rust-analyzer.diagnostics.disabled": [
                        "inactive-code",
                        "unresolved-macro-call",
                        "unresolved-proc-macro",
                        "macro-error"
                    ],
                    "rust-analyzer.completion.autoimport.enable": false,
                    "rust-analyzer.inlayHints.chainingHints.enable": true,
                    "rust-analyzer.cargo.features": [],
                    "rust-analyzer.typing.autoClosingAngleBrackets.enable": true
                },
            }
        }
    },

That will override the global configuration set in the plugin and will be project specific.

rchl commented 2 years ago

fyi: https://lsp.sublimetext.io/guides/client_configuration/#per-project-overrides

alexzanderr commented 2 years ago

yeah, thanks.