require("rc.mise").set_env() local deck = require("deck") require("deck.easy").setup() local ignore_globs = { "**/.git/**" } deck.register_start_preset("files", function() deck.start({ require("deck.builtin.source.files")({ root_dir = assert(vim.uv.cwd()), ignore_globs = ignore_globs, }), }) end) -- local home = vim.uv.os_homedir() -- -- deck.register_start_preset("mrw", function() -- deck.start({ -- name = "mrw", -- execute = function(cx) -- local cwd = vim.uv.cwd() -- for _, v in ipairs(vim.fn["mr#mrw#list"]()) do -- local text = v ---@type string -- if cwd and text:sub(1, #cwd) == cwd then -- text = text:sub(#cwd + 2) -- elseif home and text:sub(1, #home) == home then -- text = "~" .. text:sub(#home + 1) -- end -- cx.item({ -- display_text = text, -- data = { -- filename = v, -- }, -- }) -- end -- cx.done() -- end, -- actions = { -- deck.alias_action("default", "open"), -- }, -- }) -- end) vim.api.nvim_create_autocmd("User", { pattern = "DeckShow", callback = function() vim.wo.cursorline = true vim.o.signcolumn = "yes:1" vim.o.statuscolumn = "%=%s" if vim.o.cmdheight == 0 then vim.o.cmdheight = 1 vim.api.nvim_create_autocmd("User", { once = true, pattern = "DeckHide", callback = function() vim.o.cmdheight = 0 end, }) end end, }) vim.api.nvim_create_autocmd("User", { pattern = "DeckStart", callback = function(e) local cx = e.data.ctx cx.keymap("n", "o", deck.action_mapping("choose_action")) cx.keymap("n", "i", deck.action_mapping("prompt")) cx.keymap("n", "a", deck.action_mapping("prompt")) cx.keymap({ "c", "n" }, "", deck.action_mapping("refresh")) cx.keymap({ "c", "n" }, "", deck.action_mapping("toggle_preview_mode")) cx.keymap({ "c", "n" }, "", deck.action_mapping("toggle_select")) cx.keymap({ "c", "n" }, "", deck.action_mapping("toggle_select_all")) cx.keymap({ "c", "n" }, "", deck.action_mapping("scroll_preview_down")) cx.keymap({ "c", "n" }, "", deck.action_mapping("scroll_preview_up")) cx.keymap("c", "", function() cx.set_cursor(cx.get_cursor() + 1) end) cx.keymap("c", "", function() cx.set_cursor(cx.get_cursor() - 1) end) cx.keymap("n", "", deck.action_mapping("default")) cx.keymap("c", "", function() vim.api.nvim_feedkeys(vim.keycode(""), "n", true) -- vim.schedule(function() -- cx.do_action("default") -- end) end) cx.keymap("n", "", cx.hide) cx.keymap("n", "", cx.hide) cx.keymap("c", "", function() vim.api.nvim_feedkeys(vim.keycode(""), "n", true) vim.schedule(cx.hide) end) -- cx.prompt() end, }) vim.api.nvim_create_autocmd("User", { pattern = "DeckStart:explorer", callback = function(e) local cx = e.data.ctx cx.keymap("n", "", cx.hide) cx.keymap("n", "", cx.hide) cx.keymap("n", "-", deck.action_mapping("explorer.cd_up")) cx.keymap("n", "h", deck.action_mapping("explorer.collapse")) cx.keymap("n", "l", deck.action_mapping("explorer.expand")) cx.keymap("n", ".", deck.action_mapping("explorer.toggle_dotfiles")) cx.keymap("n", "c", deck.action_mapping("explorer.clipboard.save_copy")) cx.keymap("n", "m", deck.action_mapping("explorer.clipboard.save_move")) cx.keymap("n", "p", deck.action_mapping("explorer.clipboard.paste")) cx.keymap("n", "~", function() cx.do_action("explorer.get_api").set_cwd(vim.fs.normalize("~")) end) cx.keymap("n", "\\", function() cx.do_action("explorer.get_api").set_cwd(vim.fs.normalize("/")) end) end, })