Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ergonomic ability to restart with updated settings #2821

Open
ModProg opened this issue Sep 19, 2023 · 0 comments
Open

Ergonomic ability to restart with updated settings #2821

ModProg opened this issue Sep 19, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@ModProg
Copy link

ModProg commented Sep 19, 2023

Language server

rust-analyzer

Requested feature

I want to be able to activate Features and change the target, for which I need to restart the language server.

I'm currently doing this:

function RustTarget(target)
    for _, client in ipairs(vim.lsp.get_active_clients()) do
        if client.name == "rust_analyzer" then
            local settings = client.config.settings
            client.stop()
            settings["rust-analyzer"] = vim.tbl_deep_extend("force",
            settings["rust-analyzer"], { cargo = { target = target } })

            local config = require("lspconfig.configs")["rust_analyzer"]
            config.setup({
                settings = settings
            })

            config.launch()
        end
    end
end

Ideally, I'd like a way to do client.restart({settings = updated_settings}).

It would also be nice, if I could get a better way to access a client i.e.

something_get_client("rust-analyzer")
-- instead of
for _, client in ipairs(vim.lsp.get_active_clients()) do
    if client.name == "rust_analyzer" then

Other clients which have this feature

No response

@ModProg ModProg added the enhancement New feature or request label Sep 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant