local root_files = { "pyproject.toml", "setup.py", "setup.cfg", "requirements.txt", "Pipfile", "pyrightconfig.json", ".git", } local root_dir = vim.fs.dirname(vim.fs.find(root_files, { upward = true })[1]) vim.api.nvim_create_autocmd("FileType", { pattern = "python", callback = function() vim.lsp.start({ name = "pylsp", cmd = { "pylsp", "--log-config", "/tmp/logging.json", }, root_dir = root_dir, settings = { pylsp = { plugins = { pyflakes = { enabled = false, }, pycodestyle = { enabled = false, }, mccabe = { enabled = false, }, flake8 = { enabled = true, }, pylsp_mypy = { enabled = true, }, }, }, }, }) end, })