local bin_name = "ruff"
local cmd = { bin_name, "server", }

local root_files = {
  "pyproject.toml",
  "requirements.txt",
  ".git",
}

vim.api.nvim_create_autocmd("FileType", {
  pattern = "python",
  callback = function()
    vim.lsp.start({
      name = "ruff-server",
      cmd = cmd,
      root_dir = vim.fs.dirname(vim.fs.find(root_files, { upward = true })[1]),
      settings = {
      },
    })

    -- vim.api.nvim_create_autocmd("BufWritePre", {
    --   pattern = { "*.py", "*.pyi" },
    --   callback = function()
    --     vim.lsp.buf.format { timeout_ms = 2000 }
    --   end,
    -- })
  end,
})
