Any hints on how I can enable/disable an LSP server for buffers with certain filenames?

Howdie folks,

I’m familiar how to configure LSP servers to activate for certain filetypes as detected by neovim, so this question is not about that: nvim-lspconfig/lspconfig.txt at master · neovim/nvim-lspconfig · GitHub

I’d like to configure the “denols” server so that it’s only active when editing files named like “something.deno.js” or “another.deno.ts” (i.e. matching the regular expression .*\.deno\..* or containing a “.deno.” substring)

These files already get detected as “javascript” / “typescript”, and I have other tooling that relies on this, so I’m reluctant to change the way these files are detected

But, to clarify, I don’t want it to run deno fmt or deno lint on JavaScript/TypeScript files unless they have “.deno.” in the filename

I did try to set root_dir to a function that returns nil if the filename doesn’t match (using string.find()) but this doesn’t seem to have had the effect I was looking for

Any ideas?

My configuration file can be found here: config/nvim/lua/lsp.lua · main · Ron Waldon / dotfiles · GitLab