return {
    'saghen/blink.cmp',
    dependencies = {
        'rafamadriz/friendly-snippets',
        'honza/vim-snippets',
        'neovim/nvim-lspconfig',
        'williamboman/mason-lspconfig.nvim',
    },
    build = 'nix run --extra-experimental-features flakes --extra-experimental-features nix-command .#build-plugin',
    keys = {
        {"<leader>n", vim.diagnostic.goto_next},
        {"<leader>p", vim.diagnostic.goto_prev},
        {"<leader>f", vim.lsp.buf.code_action},
        {"gd", vim.lsp.buf.definition},
        {"gr", vim.lsp.buf.references},
        {"<space><space>", vim.lsp.buf.hover},
        {"<leader>rn", vim.lsp.buf.rename},
    },
    opts = {
        keymap = {
            ['<CR>'] = { 'accept', 'fallback' },
            ['<Tab>'] = { 'select_next', 'snippet_forward', 'fallback' },
            ['<S-Tab>'] = { 'snippet_backward', 'fallback' },
            ['<Up>'] = { 'select_prev', 'fallback' },
            ['<Down>'] = { 'select_next', 'fallback' },
            ['<C-k>'] = { 'select_prev', 'fallback' },
            ['<C-j>'] = { 'select_next', 'fallback' },
            ['<C-S-k>'] = { 'scroll_documentation_up', 'fallback' },
            ['<C-S-j>'] = { 'scroll_documentation_down', 'fallback' },
        },
        appearance = {
            nerd_font_variant = 'mono'
        },
        sources = {
            default = { 'lsp', 'path', 'snippets', 'buffer' },
            transform_items = function(_, items)
                for _, item in ipairs(items) do
                    local types = require('blink.cmp.types')
                    local map = {}
                    map[types.CompletionItemKind.Text] = -3
                    map[types.CompletionItemKind.Method] = 10
                    map[types.CompletionItemKind.Function] = 9
                    map[types.CompletionItemKind.Field] = 8
                    map[types.CompletionItemKind.Class] = 7
                    map[types.CompletionItemKind.Variable] = 6
                    map[types.CompletionItemKind.Property] = 5

                    if map[item.kind] ~= nil then
                        item.score_offset = item.score_offset + map[item.kind]
                    end
                    if item.label:match("^__") then
                        item.score_offset = item.score_offset - 3
                    end
                end
                return items
            end,
            providers = {
                lsp = {
                    async = true,
                    timeout_ms = 0,
                }
            }
        },
        completion = {
            menu = {
                min_width = 25,
            },
            documentation = {
                auto_show = true,
                auto_show_delay_ms = 0,
            },
            list = {
                selection = 'auto_insert',
            }
        },
        -- experimental signature help support
       signature = { enabled = true }
    },
    lazy = false,
    config = function(_, opts)
        require('blink.cmp').setup(opts)
        local lspconfig = require('lspconfig')
        local filetypes = { "bibtex", "gitcommit", "markdown", "org", "tex", "restructuredtext", "rsweave", "latex", "quarto", "rmd", "context", "html", "xhtml", "typst", "mail" }
        local lsp_opts = {
            servers = {
                basedpyright = {
                    settings = {
                        basedpyright = {
                            analysis = {
                                typeCheckingMode = "basic",
                                autoImportCompletions = true
                            }
                        }
                    }
                },
                emmet_ls = {
                    filetypes = { "css", "eruby", "html", "javascript", "javascriptreact", "less", "sass", "scss", "svelte", "pug", "typescriptreact", "vue" },
                    init_options = {
                        html = {
                            options = {
                                ["bem.enabled"] = true,
                            },
                        },
                    }
                },
                clangd = {
                    cmd = {
                        "clangd",
                        "--background-index",
                        "--clang-tidy",
                        "-j=8",
                        "--clang-tidy-checks=*",
                        "--all-scopes-completion",
                        "--completion-style=bundled",
                        "--cross-file-rename",
                        "--completion-style=detailed",
                        "--header-insertion-decorators",
                        "--header-insertion=iwyu",
                        "--pch-storage=memory"
                    }
                },
                tinymist = {
                    offset_encoding = "utf-8",
                },
                lua_ls = {
                    settings = {
                        Lua = {
                            runtime = {
                                -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
                                version = 'LuaJIT',
                            },
                            diagnostics = {
                                -- Get the language server to recognize the `vim` global
                                globals = {'vim', 'use', 'awesome', 'client', 'root'},
                            },
                            workspace = {
                                -- Make the server aware of Neovim runtime files
                                library = {
                                    ['/usr/share/nvim/runtime/lua'] = true,
                                    ['/usr/share/nvim/runtime/lua/lsp'] = true,
                                    ['/usr/share/awesome/lib'] = true
                                }
                            },
                            -- Do not send telemetry data containing a randomized but unique identifier
                            telemetry = {
                                enable = false,
                            },
                        },
                    },
                },
                ltex = {
                    on_attach = function(_, _)
                        require("ltex_extra").setup{
                            load_langs = {"nl-BE", "en-US", "en-GB"},
                            init_check = true,
                        }
                    end,
                    settings = {
                        ltex = {
                            enabled = filetypes,
                            language = "en-GB"
                        },
                    },
                    filetypes = filetypes
                },
                texlab = {},
                nixd = {},
                bashls = {},
                csharp_ls = {},
                cmake = {},
                jsonls = {},
                kotlin_language_server = {},
                dockerls = {},
                vimls = {},
                html = {},
                yamlls = {},
                cssls = {},
                jdtls = {},
                rust_analyzer = {},
                gopls = {},
                ruff = {},
            }
        }
        for server, config in pairs(lsp_opts.servers) do
            config.capabilities = require('blink.cmp').get_lsp_capabilities(config.capabilities)
            lspconfig[server].setup(config)
        end
        vim.diagnostic.config({
            virtual_text = false
        })
        vim.cmd("autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focus=false})")
    end
}