nvim/.config/nvim/lua/plugins/lsp/python.lua

-- nvim/.config/nvim/lua/plugins/lsp/python.lua
-- pyright for types, ruff for lint/format.

return {
  "neovim/nvim-lspconfig",
  opts = {
    servers = {
      pyright = {
        on_attach = function(client, _)
          client.server_capabilities.documentFormattingProvider = false
          client.server_capabilities.hoverProvider = false -- defer hover to ruff
        end,
        settings = {
          python = {
            analysis = {
              typeCheckingMode = "basic",
              diagnosticMode   = "openFilesOnly",
              autoSearchPaths  = true,
              useLibraryCodeForTypes = true,
              diagnosticSeverityOverrides = {
                reportUnusedImport    = "information",
                reportUnusedFunction  = "information",
                reportUnusedVariable  = "information",
              },
            },
          },
        },
      },
      ruff = {
        init_options = {
          settings = {
            args = {
              "--line-length=100",
              "--select=E,F,W,I,UP,B,SIM",
              "--ignore=E501",
            },
          },
        },
      },
    },
  },
}