stevearc / overseer.nvim

A task runner and job management plugin for Neovim

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bug: How to keep in task log window

JefferyBoy opened this issue · comments

Neovim version (nvim -v)

0.9.5

Operating system/version

linux

Describe the bug

After run a job. I need to see the all logs. But on the log window, press any key will close the window. How to keep in log window?
Uploading 2024-04-21_11-49-42.png…

What is the severity of this bug?

minor (annoyance)

Steps To Reproduce

run any job

Expected Behavior

keep in log window

Minimal example file

No response

Minimal init.lua

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "--single-branch",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  { "stevearc/dressing.nvim", config = true },
  {
    "stevearc/overseer.nvim",
    config = function()
      require("overseer").setup({
        -- add your overseer config here
      })
    end,
  },
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

Additional context

No response

commented

Hi! I couldn't tell exactly what happens but by default the log output for a task is displayed in terminal window. If the output ends with [Process exited 0] you might need to leave input mode <C-\><C-n> to be able to scroll the terminal buffer (if it is in the TERMINAL mode, similar to INSERT mode of a regular buffer). But normally the buffer defaults to the NORMAL mode and shouldn't close on any key press, so something else might be going on, though. I hope that helps still.

Very likely you are in insert mode (technically "terminal mode") in the terminal. As @axelhj mentioned, if you see [Process exited 0] that indicates that the terminal process has ended, and by default the neovim terminal will exit and close upon the next keypress. You can do <C-\><C-n> to escape terminal mode and avoid this behavior. You can also change the default run strategy to jobstart, as these types of terminals do not have the same auto-close behavior

require("overseer").setup({
  strategy = "jobstart",
})

As for why you're in terminal mode? My guess is that you have an autocmd set up to do it for you. This is quite common because it's mentioned in the neovim help docs. If you do, I recommend making some tweaks from the default:

vim.api.nvim_create_autocmd("TermOpen", {
  desc = "Auto enter insert mode when opening a terminal",
  pattern = "*",
  callback = function()
    -- Wait briefly just in case we immediately switch out of the buffer
    vim.defer_fn(function()
      -- Make sure this is still a terminal, and it's not overseer task output
      if vim.bo.buftype == "terminal" and not vim.b.overseer_task then
        vim.cmd.startinsert()
      end
    end, 100)
  end,
})