-- Define the configuration for pyright
vim.lsp.config('pyright', {
    -- The command to start the server (usually the same as lspconfig's default)
    cmd = { "pyright-langserver", "--stdio" },
    filetypes = { "python" },
    root_markers = { ".git", "pyproject.toml", "setup.py", "requirements.txt" },

    -- Your custom settings move here
    settings = {
        python = {
            analysis = {
                autoSearchPaths = true,
                useLibraryCodeForTypes = true,
            },
        },
    },
})

-- Handle the on_attach logic
vim.api.nvim_create_autocmd('LspAttach', {
    callback = function(args)
        local client = vim.lsp.get_client_by_id(args.data.client_id)
        if client and client.name == 'pyright' then
            local bufnr = args.buf
            -- Your custom keymaps and commands for pyright go here
            -- Example: vim.keymap.set('n', 'K', vim.lsp.buf.hover, { buffer = bufnr })
        end
    end,
})

-- Finally, enable the server
vim.lsp.enable('pyright')
