return { { 'windwp/nvim-autopairs', config = true, }, { 'folke/flash.nvim', opts = { modes = { search = { enabled = true } }, }, config = function(_, opts) require('flash').setup(opts) map({ 'n', 'x', 'o' }, 's', function() require('flash').jump() end) map({ 'n', 'x', 'o' }, 'S', function() require('flash').treesitter() end) map('o', 'r', function() require('flash').remote() end) map({ 'o', 'x' }, 'R', function() require('flash').treesitter_search() end) map('c', '', function() require('flash').toggle() end) end, }, { 'kylechui/nvim-surround', config = true, }, { 'kevinhwang91/nvim-ufo', dependencies = { 'kevinhwang91/promise-async' }, opts = { provider_selector = function() return { 'treesitter', 'indent' } end, }, config = function(_, opts) require('ufo').setup(opts) map('n', 'zR', require('ufo').openAllFolds) map('n', 'zM', require('ufo').closeAllFolds) end, }, { 'barrettruth/cp.nvim', dependencies = { 'ibhagwan/fzf-lua' }, init = function() -- Keep uv cache in-project so cp.nvim scraping works in restricted environments. if vim.env.UV_CACHE_DIR == nil or vim.env.UV_CACHE_DIR == '' then local uv_cache_dir = vim.fn.getcwd() .. '/.uv-cache' vim.fn.mkdir(uv_cache_dir, 'p') vim.env.UV_CACHE_DIR = uv_cache_dir end vim.g.cp = { languages = { python = { extension = 'py', commands = { run = { 'python3', '{source}' }, debug = { 'python3', '{source}' }, }, }, }, platforms = { codeforces = { enabled_languages = { 'python' }, default_language = 'python', }, atcoder = { enabled_languages = { 'python' }, default_language = 'python', }, cses = { enabled_languages = { 'python' }, default_language = 'python', }, }, open_url = true, ui = { picker = 'fzf-lua', }, } end, config = function() local function open_url(url) local ok_ui_open, opened = pcall(vim.ui.open, url) if ok_ui_open and opened ~= false then return end local opener = nil if vim.fn.has('macunix') == 1 then opener = 'open' elseif vim.fn.has('unix') == 1 then opener = 'xdg-open' end if opener then vim.fn.jobstart({ opener, url }, { detach = true }) end end local function open_current_cp_problem_url() local ok_state, state = pcall(require, 'cp.state') local ok_cache, cache = pcall(require, 'cp.cache') if not (ok_state and ok_cache) then return end local platform = state.get_platform() local contest_id = state.get_contest_id() local problem_id = state.get_problem_id() if not (platform and contest_id and problem_id) then return end cache.load() local contest = cache.get_contest_data(platform, contest_id) if contest and contest.url then open_url(contest.url:format(problem_id)) end end -- cp.nvim only opens URLs when first entering a contest; extend this locally for next/prev. local ok_setup, setup = pcall(require, 'cp.setup') local ok_config, cp_config = pcall(require, 'cp.config') if ok_setup and ok_config and not setup._url_open_patch_applied then local original_navigate_problem = setup.navigate_problem setup.navigate_problem = function(direction, language) local ok_state, state = pcall(require, 'cp.state') local old_problem_id = ok_state and state.get_problem_id() or nil original_navigate_problem(direction, language) local cfg = cp_config.get_config() local new_problem_id = ok_state and state.get_problem_id() or nil local moved = old_problem_id ~= nil and new_problem_id ~= nil and old_problem_id ~= new_problem_id if cfg and cfg.open_url and moved then vim.schedule(open_current_cp_problem_url) end end setup._url_open_patch_applied = true end map('n', 'cr', 'CP run', { desc = 'CP run' }) map('n', 'cp', 'CP panel', { desc = 'CP panel' }) map('n', 'ce', 'CP edit', { desc = 'CP edit tests' }) map('n', 'cn', 'CP next', { desc = 'CP next problem' }) map('n', 'cN', 'CP prev', { desc = 'CP previous problem' }) map('n', 'cc', 'CP pick', { desc = 'CP contest picker' }) map('n', 'ci', 'CP interact', { desc = 'CP interact' }) map('n', 'co', open_current_cp_problem_url, { desc = 'CP open problem url' }) end, }, { 'supermaven-inc/supermaven-nvim', opts = { keymaps = { accept_suggestion = '', clear_suggestion = '', accept_word = '', }, ignore_filetypes = { gitcommit = true }, color = { suggestion_color = vim.api.nvim_get_hl(0, { name = 'Comment' }).fg, cterm = 244, }, }, }, { 'barrettruth/preview.nvim', init = function() vim.g.preview = { typst = true, latex = true } end, }, }