Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

disable setup LSP #183

Closed
junnplus opened this issue Apr 26, 2022 · 3 comments
Closed

disable setup LSP #183

junnplus opened this issue Apr 26, 2022 · 3 comments

Comments

@junnplus
Copy link

junnplus commented Apr 26, 2022

Thanks a lot for your work.

I wrote a plugin nvim-lsp-setup wrapping nvim-lspconfig and nvim-lsp-installer,
I try to integrate rust-tools, but rust-tools always setup lsp .
Is it possible to add a config to disable it, to setup via installer?

PS: I have read #89

@simrat39
Copy link
Owner

simrat39 commented May 1, 2022

I'm not sure if that's possible as the plugin is closely coupled with nvim-lspconfig. As for the users of your plugin, I think they should just not use it for setting up rust if they want to use rust-tools

@aryzing
Copy link

aryzing commented May 7, 2022

Seems that running nvim-lspconfig inside rust-tools is catching a few people by surprise, myself included. I had a similar problem to #177.

It would be great if rust-tools, depending on what it needs internally, had an API that didn't overwrite a user's call to lspconfig.rust.setup(). As it stands, I need to treat it like an exception,

local servers = {
  "eslint",
  "jsonls",
  "rust_analyzer",
  "sumneko_lua",
  "svelte",
  "tsserver",
  "yamlls",
}

for _, server in pairs(servers) do
  local serverOpts = {
    on_attach = on_attach, -- on_attach is defined outside this snippet
  }

  if server == "rust_analyzer" then
    local ok_rt, rust_tools = pcall(require, "rust-tools") 
    if not ok_rt then
      print("Failed to load rust tools, will set up `rust_analyzer` without `rust-tools`.")
    else
      rust_tools.setup({
        server = serverOpts,
      })
      -- We don't want to call lspconfig.rust_analyzer.setup() when using
      -- rust-tools. See
      -- * https://github.com/simrat39/rust-tools.nvim/issues/183
      -- * https://github.com/simrat39/rust-tools.nvim/issues/177
      goto continue
    end
  end

  lspconfig[server].setup(serverOpts)
  ::continue::
end

@simrat39
Copy link
Owner

TBH I don't see this changing, we make a lot of changes under the hood to the server options before calling lspconfig, and I think overall its easier for the users to set it up (if you're not calling it in a loop).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants