rcarriga / nvim-dap-ui

A UI for nvim-dap
MIT License
2.7k stars 103 forks source link

Focus Terminal window automatically #281

Open lavish440 opened 1 year ago

lavish440 commented 1 year ago

I really love your plugin. But the thing that bothers me is that I have to manually switch to the terminal buffer for providing input to the program. I tried using nvim-dap's dap.defaults.fallback.focus.terminal = true but no avail. Is there anything I can do to solve my problem?

rcarriga commented 1 year ago

You can do this

  vim.api.nvim_create_autocmd("BufWinEnter", {
    pattern = "\\[dap-repl\\]",
    callback = vim.schedule_wrap(function(args)
      vim.api.nvim_set_current_win(vim.fn.bufwinid(args.buf))
    end)
  })

schedule_wrap is used because the current window is changed when opening nvim-dap-ui so it defers running it until after all windows have been opened