Lspconfig: prevent buffer attach for buffers with specific scheme

With lspconfig, is there a way to configure it to ignore attaching to buffers with a a certain scheme? Only discussion I’ve seen from similar topics is disabling in node_modules, which involves some autocmds to stop an (or all) LSP client entirely.

I need this as I’m finishing up distant.nvim, which uses a name scheme of distant://path/to/file on buffers referencing files being managed on a remote machine. I’m able to also speak with remote LSP servers, but the problem is that an LSP server is started locally because the filetype is recognized for my local config.

For instance, distant://path/to/file.rs starts a local rust-analzyer server alongside my remote version that I’ve configured to start and attach to buffers with distant:// as the scheme.

This currently is not possible. The code for lspconfig’s server management is pretty primitive (check out configs.lua). I would have to add it as a feature. Alternatively, you can use start_client directly and bypass lspconfig (for now).

Given that neovim’s LSP client and the lspconfig plugin are frequently used together, having the ability to disable would be nice for sure :slight_smile:

For distant.nvim, you configure it with the LSP servers you want to run on remote servers and then it runs start_client for you automatically just like lspconfig. Ideally, I’d like for my plugin to be able to coexist with lspconfig.

@mjlbach could look into making a PR to support this if it’s something you’d be willing to have included in lspconfig.

I think we would need to settle on the configuration options. Do we match on a regex? Specific files (which would require project specific settings)?

I wrote a roadmap last night about planned changes to lspconfig to be a bit more flexible for usecases like yours: lspconfig roadmap · Issue #1221 · neovim/nvim-lspconfig · GitHub

We can always chat more interactively on the matrix channel too.

Good point about the configuration options. At for my use case, having a regex where I can say, “Exclude anything prefixed with distant:// scheme as buffer name” would be what I need to make this work.

I’m not familiar with matrix, but will give it a look to see if we can discuss there if that’s what you want.

I’m not familiar with matrix, but will give it a look to see if we can discuss there if that’s what you want.

It’s where the developer chat is :slight_smile: