aboutsummaryrefslogtreecommitdiffstats
path: root/neovim/.config/nvim/lua/plugins/overseer.lua
blob: 99d0f5fbe0857936f6d89ec310c04701d93d0a31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
-- Run configurations (PyCharm-style "run this again"), language-agnostic:
-- works for npm scripts, make, cargo, arbitrary shell commands, python
-- scripts, etc, unlike DAP which is Python-only for now.
return {
  "stevearc/overseer.nvim",
  -- Not left to lazy-load off `cmd`/`keys`: a project's .nvim.lua (see
  -- lua/config/project_run.lua) needs `require("overseer")` to work
  -- immediately when exrc sources it, which requires the plugin already
  -- being on runtimepath rather than deferred until first use.
  lazy = false,
  keys = {
    { "<leader>rr", "<cmd>OverseerRun<cr>", desc = "Run task" },
    {
      "<leader>rl",
      function()
        -- :OverseerRestartLast exists in current overseer.nvim versions; the
        -- run_action fallback covers older/newer versions that lack it
        -- rather than hard-failing the keymap.
        if vim.fn.exists(":OverseerRestartLast") == 2 then
          vim.cmd("OverseerRestartLast")
          return
        end
        local overseer = require("overseer")
        local tasks = overseer.list_tasks({ recent_first = true })
        if vim.tbl_isempty(tasks) then
          vim.notify("No previous task to rerun", vim.log.levels.WARN)
        else
          overseer.run_action(tasks[1], "restart")
        end
      end,
      desc = "Rerun last task",
    },
    { "<leader>ro", "<cmd>OverseerToggle<cr>", desc = "Toggle task list/output" },
    { "<leader>rq", "<cmd>OverseerQuickAction<cr>", desc = "Quick action on task" },
  },
  opts = {
    -- Patches nvim-dap so a debug config can set preLaunchTask/postDebugTask
    -- to an overseer task name (or "${defaultBuildTask}" for whatever task
    -- is tagged BUILD) - lets a dap.configurations entry build before it
    -- launches the debugger. See README's Debugging section.
    dap = true,
    -- overseer's actual default components (on_exit_set_status,
    -- on_complete_notify, on_complete_dispose) don't open the output panel
    -- on their own - without open_output added here, starting any task
    -- (whether from a template, .nvim.lua/project_run.lua, or auto-detected
    -- npm/make scripts) runs silently until you manually <leader>ro to look.
    -- Adding it here applies to every task, not just custom ones.
    component_aliases = {
      default = {
        "on_exit_set_status",
        "on_complete_notify",
        { "on_complete_dispose", require_view = { "SUCCESS", "FAILURE" } },
        { "open_output", direction = "dock", focus = false, on_start = "always" },
      },
    },
  },
}