local function import(name)
    return function()
        require(name)
    end
end

return {
    {
        'nvim-mini/mini.nvim',
        version = false
    },

    {
        "RRethy/base16-nvim",
    },

    {
        "vim-airline/vim-airline",
        dependencies = {
            "ryanoasis/vim-devicons",
        },
    },

    {
        "mustache/vim-mustache-handlebars",
    },

    {
        "whonore/Coqtail",
    },

    {
        "Julian/lean.nvim",
        dependencies = {
            "nvim-lua/plenary.nvim",
        },
        config = function()
            require("lean").setup({
                opts = { mappings = true }
            })
        end,
    },

    {
        "noir-lang/noir-nvim",
    },

    {
        "nvim-treesitter/nvim-treesitter",
        lazy = false,
        version = false,
        build = function()
            vim.cmd(":TSUpdate")
        end,
        opts = {
            highlight = {
                enable = true,
                disable = { "ipkg", "markdown", "md" }
            },
            indent = {
                enable = true,
                disable = { "markdown", "md" }
            },
            ensure_installed = "all",
            ignore_install = { "ipkg", "markdown", "md" },
        },
    },

    {
        "petRUShka/vim-sage",
    },

    {
        "evanleck/vim-svelte",
    },

    {
        "wuelnerdotexe/vim-astro",
    },

    {
        "tpope/vim-fugitive",
        config = function()
            local map = vim.api.nvim_set_keymap
            map('n', '<Leader>g', '<Cmd>Git<CR>', { noremap = true })
        end,
    },

    {
        "tpope/vim-surround",
    },

    {
        "tpope/vim-repeat",
    },

    {
        "nvim-lua/plenary.nvim",
    },

    {
        "lewis6991/gitsigns.nvim",
        dependencies = {
            "nvim-lua/plenary.nvim",
        },
        config = function()
            require('gitsigns').setup {
                signs = {
                    add = {
                        text = '│',
                    },
                    change = {
                        text = '│',
                    },
                    delete = {
                        text = '_',
                    },
                    topdelete = {
                        text = '‾',
                    },
                    changedelete = {
                        text = '~',
                    },
                },
            }
        end,
    },

    {
        "akinsho/flutter-tools.nvim",
        dependencies = {
            "nvim-lua/plenary.nvim",
        },
        config = function()
            require('flutter-tools').setup {
                -- lsp = {
                --     color = {
                --         enabled = false
                --     }
                -- }
            }
        end,
    },

    {
        "numToStr/Comment.nvim",
        config = function()
            local map = vim.api.nvim_set_keymap

            require('Comment').setup({})

            map(
                'n',
                '<C-_>',
                '<Cmd>lua require("Comment.api").toggle_linewise_op(vim.fn.visualmode())<CR>',
                { noremap = true, silent = true }
            )
        end,
    },

    {
        "nvim-telescope/telescope.nvim",
        dependencies = {
            "nvim-lua/plenary.nvim",

            {
                "nvim-telescope/telescope-fzf-native.nvim",
                build = "make",
            },

            "nvim-telescope/telescope-symbols.nvim",
        },
        config = import("tel"),
    },

    {
        "stevearc/dressing.nvim",
        config = function()
            require('dressing').setup({
                input = {
                    default_prompt = '❯',
                    win_options = {
                        winhighlight = 'NormalFloat:Normal',
                    },
                },
            })

            vim.cmd [[highlight link FloatTitle NonText]]
            vim.cmd [[highlight link DressingInputText Normal]]
        end,
    },

    {
        "antoinemadec/FixCursorHold.nvim",
        config = function()
            vim.g.cursorhold_updatetime = 500
        end,
    },

    {
        "sirver/ultisnips",
        ft = { 'latex', 'plaintex', 'tex' },

        config = function()
            vim.g.UltiSnipsExpandTrigger = '<tab>'
            vim.g.UltiSnipsJumpForwardTrigger = '<C-h>'
            vim.g.UltiSnipsJumpBackwardTrigger = '<C-b>'
        end,
    },

    {
        "ms-jpq/coq.artifacts",
        branch = "artifacts",
        lazy = false
    },

    {
        "ms-jpq/coq_nvim",
        branch = "coq",
        lazy = false,
        dependencies = {
            {
                "ms-jpq/coq.artifacts",
                branch = "artifacts",
                lazy = false,
            },
            {
                "ms-jpq/coq.thirdparty",
                branch = "3p",
                lazy = false,
            },
        },
        init = function()
            vim.g.coq_settings = {
                -- auto_start = 'shut-up',
                keymap = {
                    eval_snips = "<Leader>se",
                },
                -- match = {
                --     look_ahead = 1,
                -- },
                clients = {
                    snippets = {
                        always_on_top = true,
                        enabled = true,
                        weight_adjust = 100,
                    },
                    buffers = {
                        enabled = true,
                        weight_adjust = -2.0,
                    },
                    tree_sitter = {
                        enabled = true,
                        weight_adjust = -1.5,
                    },
                    lsp = {
                        enabled = true,
                        weight_adjust = -100,
                    },
                    third_party = {
                        enabled = true,
                        weight_adjust = -1.5,
                    }
                }
            }

            require('coq_3p') {
                { src = 'vimtex',  short_name = 'TEX' },
                { src = 'nvimlua', short_name = 'NLUA', conf_only = true },
                { src = 'bc',      short_name = 'CALC', precision = 8 },
            }
        end,
        build = function()
            require("coq")
            vim.cmd(":COQdeps")
        end,
        config = function()
            require('coq_3p') {
                { src = 'vimtex',  short_name = 'TEX' },
                { src = 'nvimlua', short_name = 'NLUA', conf_only = true },
                { src = 'bc',      short_name = 'CALC', precision = 8 },
            }
        end
    },

    {
        "ms-jpq/coq.thirdparty",
        branch = "3p",
        lazy = false,
    },

    {
        "nvim-lua/lsp-status.nvim",
        lazy = false,
    },

    {
        "neovim/nvim-lspconfig",
        lazy = false,

        dependencies = {
            {
                "nvim-lua/lsp-status.nvim",
                lazy = false,
            },

            {
                "ms-jpq/coq.thirdparty",
                branch = "3p",
                lazy = false,
            },

            {
                "ms-jpq/coq.artifacts",
                branch = "artifacts",
                lazy = false,
            },

            {
                "ms-jpq/coq_nvim",
                branch = "coq",
                lazy = false,

                dependencies = {
                    {
                        "ms-jpq/coq.artifacts",
                        branch = "artifacts",
                        lazy = false,
                    },
                },
            },
        },

        config = function()
            local capabilities = require("coq").lsp_ensure_capabilities()
            -- extend coq completion capabilities all lsps
            vim.lsp.config('*', {
                capabilities = capabilities,
            })
            vim.lsp.enable("lua_ls")
            require("lsp")
        end,
    },

    {
        "lervag/vimtex",

        config = function()
            vim.g.vimtex_view_general_viewer = 'zathura'
            vim.g.vimtex_compiler_method = "latexmk"

            -- vim.g.vimtex_view_general_options = = '-x nvim -n -c "Vimtex'
            -- 'file:@pdf\\#src:@line@tex'
            -- vim.g.vimtex_quickfix_enabled = 0
            -- vim.g.Tex_GotoError = 0
            -- vim.g.Tex_ShowErrorContext = 0
        end,
    },

    {
        "iamcco/markdown-preview.nvim",

        ft = { "markdown" },

        init = function()
            vim.g.mkdp_filetypes = { "markdown" }
        end,

        build = function()
            vim.fn.system("cd app && npm install")
        end,

        config = function()
            local map = vim.api.nvim_set_keymap

            map('n', '<C-m>', '<Plug>MarkdownPreviewToggle', {})
            map('n', '<Leader>m', '<Plug>MarkdownPreviewToggle', {})

            vim.g.mkdp_markdown_css =
                os.getenv("HOME") .. "/.config/nvim/lua/markdownStyle.css"

            vim.g.mkdp_highlight_css =
                os.getenv("HOME") .. "/.cache/wal/colors.css"
        end,
    },
}
