local writing_ft = { "quarto", "pandoc", "markdown", "text", "tex" }

return {
    -- vim plugs
    -- essential
    { 'numToStr/Navigator.nvim',           branch = "master", config = true }, -- allow seamless navigation between vim buffers and tmux/wezterm splits
    { 'jeffkreeftmeijer/vim-numbertoggle', event = "BufEnter" }, -- toggles numbers to absolute for all buffers but the current which is relative
    { 'ojroques/vim-oscyank',              event = "VeryLazy" }, -- yank from *anywhere* (even ssh session) to clipboard, using :OSCYank
    { 'ggandor/lightspeed.nvim',           event = "VeryLazy" }, -- jump between letters with improved fFtT quicksearch, mimics sneak
    -- files
    { 'vifm/vifm.vim' }, -- integrate file manager
    {
        'lewis6991/gitsigns.nvim', -- show vcs changes on left-hand gutter
        opts = { numhl = true, signcolumn = false },
        event = "BufRead"
    },
    { 'RRethy/nvim-base16', event = "BufWinEnter",
        dependencies = { 'rktjmp/fwatch.nvim' } }, {
    'norcalli/nvim-colorizer.lua', -- color hex, named colors in the correct preview scheme
    config = true,
    event = "VeryLazy"
}, {
    'mhartington/formatter.nvim', -- auto formatting on save
    config = function() require('plug._format') end,
    event = "VeryLazy"
}, -- editing
    { 'kylechui/nvim-surround',      version = '*',  config = true, event = "VeryLazy" }, -- surround things with other things using ys/cs/ds
    {
        'monaqa/dial.nvim', -- extend the ^a / ^x possibilities to dates, hex, alphabets, markdown headers
        config = function()
            local augend = require("dial.augend")
            require("dial.config").augends:register_group {
                -- default augends used when no group name is specified
                default = {
                    augend.integer.alias.decimal, augend.integer.alias.hex,
                    augend.date.alias["%Y/%m/%d"],
                    augend.date.alias["%Y-%m-%d"], augend.date.alias["%m/%d"],
                    augend.date.alias["%H:%M:%S"], augend.date.alias["%H:%M"],
                    augend.constant.alias.de_weekday_full,
                    augend.constant.alias.de_weekday,
                    augend.constant.alias.bool, augend.semver.alias.semver,
                    augend.constant.alias.Alpha, augend.constant.alias.alpha,
                    augend.hexcolor.new { case = "lower" }, augend.constant.new {
                    elements = { "and", "or" },
                    word = true, -- if false, "sand" is incremented into "sor", "doctor" into "doctand", etc.
                    cyclic = true -- "or" is incremented into "and".
                },
                    augend.constant
                    .new {
                        elements = { "&&", "||" },
                        word = false,
                        cyclic = true
                    }
                }
            }
        end,
        event = "VeryLazy"
    }, {
    'tommcdo/vim-exchange', -- adds exchange operator with cx. common use: cxiw . on 2 words to switch
    event = "VeryLazy"
}, {
    'junegunn/vim-easy-align', -- Align tables and other alignable things
    event = "VeryLazy"
}, { 'edKotinsky/Arduino.nvim', ft = 'arduino', config = true }, -- statusline
    {
        'nvim-lualine/lualine.nvim',
        requires = { 'kyazdani42/nvim-web-devicons', opt = true },
        config = function() require('plug._lualine') end
    }, -- writing
    { 'vim-pandoc/vim-criticmarkup', ft = writing_ft }, {
    'mickael-menu/zk-nvim',
    config = function() require('zk').setup({ picker = "telescope" }) end
}, {
    'andrewferrier/wrapping.nvim',
    config = function()
        require('wrapping').setup({
            create_keymappings = false,
            notify_on_switch = false
        })
    end
}, {
    'quarto-dev/quarto-nvim',
    dependencies = {
        'jmbuhr/otter.nvim', 'neovim/nvim-lspconfig',
        'vim-pandoc/vim-pandoc-syntax'
    },
    config = function()
        require 'quarto'.setup {
            lspFeatures = {
                enabled = true,
                languages = { 'r', 'python', 'julia' },
                diagnostics = { enabled = true, triggers = { "BufWrite" } },
                completion = { enabled = true }
            }
        }
    end,
    ft = "quarto"
}, {
    "lkhphuc/jupyter-kernel.nvim",
    config = true,
    cmd = "JupyterAttach",
    build = ":UpdateRemotePlugins",
    keys = {
        {
            "<localleader>ck",
            "<Cmd>JupyterInspect<CR>",
            desc = "Inspect object in kernel"
        }
    }
}, { 'micarmst/vim-spellsync',     event = "VeryLazy" }, -- personal dict improvements for git sync
    { 'folke/zen-mode.nvim',           config = true,     event = "VeryLazy" }, -- provide distraction free writing
    { 'folke/twilight.nvim',           event = "VeryLazy" }, -- provide even distraction free-er writing (lowlight paragraphs)
    { 'JellyApple102/easyread.nvim',   config = true,     ft = writing_ft,   cmd = 'EasyreadToggle' }, -- enable 'speed-reading' mode (bionic reading)
    { 'marty-oehme/zettelkasten.nvim', ft = writing_ft,   event = "VeryLazy" }, -- simple static markdown linking
    {
        "iamcco/markdown-preview.nvim", -- generate an auto-updating html preview for md files
        build = function() vim.fn["mkdp#util#install"]() end,
        ft = writing_ft
    }, -- languages
    { 'euclidianAce/BetterLua.vim', ft = 'lua' }, -- better syntax highlighting for lua
    { 'aliou/bats.vim',             ft = { "bash", "sh", "zsh", "bats" } }, -- enable syntax for bats shell-code testing library

    -- REPL work
    {
        'WhiteBlackGoose/magma-nvim-goose',
        build = ":UpdateRemotePlugins",
        config = function()
            vim.g.magma_image_provider = "kitty"
            vim.g.magma_automatically_open_output = false
        end
    }, -- nvim plugs
    {
        'echasnovski/mini.nvim',
        version = '*',
        config = function() require('plug._mini') end
    }, {
    "akinsho/nvim-toggleterm.lua", -- simpler, programmable and multiple terminal toggling for nvim
    config = function() require('plug._toggleterm') end
},
    {
        "folke/which-key.nvim",
        config = function() require("which-key").setup {} end
    }, -- fuzzy matching
    { "nvim-telescope/telescope-fzf-native.nvim", build = 'make' }, {
    "nvim-telescope/telescope.nvim",
    dependencies = { "nvim-lua/popup.nvim", "nvim-lua/plenary.nvim" },
    config = function() require('plug._telescope') end
}, {
    "dense-analysis/neural",
    dependencies = { "MunifTanjim/nui.nvim", "elpiloto/significant.nvim" },
    config = function()
        require('neural').setup({
            source = { openai = { api_key = vim.env.OPENAI_API_KEY } }
        })
    end
}, -- treesitter
    {
        'nvim-treesitter/nvim-treesitter',
        build = ':TSUpdate',
        config = function() require('plug._treesitter') end,
        event = "BufReadPre",
        -- rainbow brackets using treesitter
        -- show current cursor context at top of buffer
        -- improves commenting plugin above by using ts
        dependencies = {
            'https://gitlab.com/HiPhish/nvim-ts-rainbow2.git',
            { 'romgrk/nvim-treesitter-context', config = true },
            'JoosepAlviste/nvim-ts-context-commentstring'
        }
    },
    { 'nvim-treesitter/playground',               cmd = "TSPlaygroundToggle" }, -- interactively view and query the treesitter tree
    {
        'RRethy/nvim-treesitter-textsubjects', -- allows using . and ; to target treesitter branches
        config = function()
            require 'nvim-treesitter.configs'.setup {
                textsubjects = {
                    enable = true,
                    keymaps = {
                        ['.'] = 'textsubjects-smart',
                        [';'] = 'textsubjects-container-outer'
                    }
                }
            }
        end,
        event = "BufReadPre"
    }, {
    'lewis6991/spellsitter.nvim', -- uses treesitter to highlight spelling errors
    config = function() require('spellsitter').setup() end,
    event = "BufReadPre"
}, -- lsp
    {
        "VonHeikemen/lsp-zero.nvim",
        dependencies = {
            { "neovim/nvim-lspconfig",         branch = "master" },
            "williamboman/mason.nvim", "williamboman/mason-lspconfig.nvim", {
            "hrsh7th/nvim-cmp",
            branch = "main",
            dependencies = {
                "hrsh7th/cmp-buffer", "hrsh7th/cmp-path",
                "saadparwaiz1/cmp_luasnip", "hrsh7th/cmp-nvim-lsp",
                "hrsh7th/cmp-nvim-lua", "andersevenrud/cmp-tmux",
                "hrsh7th/cmp-nvim-lsp", "kdheepak/cmp-latex-symbols",
                "ray-x/cmp-treesitter", "f3fora/cmp-spell",
                "hrsh7th/cmp-cmdline", "cbarrete/completion-vcard",
                "jc-doyle/cmp-pandoc-references",
            }
        }, "L3MON4D3/LuaSnip", "rafamadriz/friendly-snippets",
            { "lukas-reineke/lsp-format.nvim", config = true }
        },
        config = function() require('plug._lsp') end
    }, { 'simrat39/symbols-outline.nvim', config = true, event = "VeryLazy" }, -- vista-like outline view for code
    { 'ray-x/lsp_signature.nvim',      config = true }, -- UI improvements
    { 'stevearc/dressing.nvim',        config = true }, {
    'rcarriga/nvim-notify',
    config = function() vim.notify = require("notify") end
}
    -- { -- REQUIRES custom `yay -S --asdeps lua51-lyaml invocation` AND is suuper slow
    --     "jghauser/papis.nvim",
    --     after = { "telescope.nvim", "nvim-cmp" },
    --     dependencies = {
    --         "kkharji/sqlite.lua", "nvim-lua/plenary.nvim",
    --         "MunifTanjim/nui.nvim", "nvim-treesitter/nvim-treesitter"
    --     },
    --     ft = writing_ft,
    --     rocks = { "lyaml" },
    --     config = function()
    --         require('papis').setup({
    --             papis_python = {
    --                 dir = "/home/marty/documents/library/academia",
    --                 info_name = "info.yaml",
    --                 notes_name = [[notes.qmd]]
    --             }
    --         })
    --     end
    -- }
}
