return { "neovim/nvim-lspconfig", opts = function(_, opts) local servers = { "bashls", "clangd", "eslint", "jsonls", "lua_ls", "marksman", "nginx_language_server", "ruff_lsp", "sqlls", "ts_ls", "yamlls", } if not opts.servers then opts.servers = {} end for _, server in ipairs(servers) do opts.servers[server] = opts.servers[server] or {} end --[[ -- I think I based this one on https://www.lazyvim.org/extras/lang/python though it doesn't refer to root_dir at all. opts.servers.ruff_lsp.root_dir = function(fname) return require("lspconfig.util").root_pattern( "pyproject.toml", "setup.py", "setup.cfg", "requirements.txt", "requirements.txt.m4", "Pipfile", ".git", "../trunk" )(fname) end --]] -- This is based on https://www.reddit.com/r/neovim/comments/ww41pz/lsp_root_pattern_problem/ -- And doesn't work. --[[ local nvim_lsp = require("lspconfig") nvim_lsp.ruff_lsp.setup({ root_dir = nvim_lsp.util.root_pattern( "pyproject.toml", "setup.py", "setup.cfg", "requirements.txt", "requirements.txt.m4", "Pipfile", ".git", "../trunk" ), }) --]] -- This is based on https://github.com/astral-sh/ruff-lsp/issues/78 -- It also doesn't appear to work. :-S --[[ setup = { ruff_lsp = { init_options = { settings = { root_dir = require("lspconfig.util").root_pattern( "pyproject.toml", "setup.py", "setup.cfg", "requirements.txt", "requirements.txt.m4", "Pipfile", ".git", "../trunk" ), }, }, }, } --]] -- This didn't work, and was probably too close to the LunarVim config from which it was derived. --[[ opts.servers["ruff_lsp"].setup.root_dir = require("lspconfig.util").root_pattern( "pyproject.toml", "setup.py", "setup.cfg", "requirements.txt", "requirements.txt.m4", "Pipfile", ".git" ) --]] for _, server in ipairs(servers) do opts.servers[server].enabled = true end end, }