mfussenegger / nvim-dap

Debug Adapter Protocol client implementation for Neovim
GNU General Public License v3.0
5.1k stars 179 forks source link

[BUG] autoscroll breaks goto line vim motion on repl #1131

Closed serranomorante closed 5 months ago

serranomorante commented 5 months ago

Debug adapter definition and debug configuration

Copy the following snippet into repro.lua and open vim with nvim --clean +'so repro.lua'

-- DO NOT change the paths
local root = vim.fn.fnamemodify("./.repro", ":p")
root = root:sub(-1) == "/" and root or root .. "/"

-- 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

--------------------------------------------------------------------------------

vim.g.mapleader = " "

--------------------------------------------------------------------------------

local plugins = {
  {
    "mfussenegger/nvim-dap",
    keys = {
      { "<leader>dR", function() require("dap").repl.toggle() end, desc = "Toggle REPL" },
    },
    init = function()
      vim.api.nvim_create_autocmd("BufWinEnter", {
        desc = "Set options on DAP windows",
        group = vim.api.nvim_create_augroup("set_dap_win_options", { clear = true }),
        pattern = { "\\[dap-repl\\]", "DAP *" },
        callback = function(args)
          local win = vim.fn.bufwinid(args.buf)
          vim.schedule(function()
            if not vim.api.nvim_win_is_valid(win) then return end
            vim.api.nvim_set_option_value("number", true, { win = win })
          end)
        end,
      })
    end,
  },
}

--------------------------------------------------------------------------------

local lazypath = root .. "/plugins/lazy.nvim"
---@diagnostic disable-next-line: undefined-field
if not (vim.uv or vim.loop).fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "https://github.com/folke/lazy.nvim.git",
    "--branch=stable",
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

Debug adapter version

NONE

Steps to Reproduce

  1. Open vim with nvim --clean +'so repro.lua'
  2. Close the lazy.nvim manager window
  3. Open the repl with <leader>dR
  4. Go to the repl window with <C-w><down>
  5. Enter insert mode and add several new lines by pressing Enter
  6. You will notice that the repl window has a column number (it helps me to navigate with vim motions)
  7. Go into normal mode and press 4gg to goto line 4, 5gg, etc etc. This works fine, but!
  8. Pressing 4G should also work but it doesn't. I believe it doesn't work due to the autoscroll feature that is overriding the NG builtin keymap.

Thanks!

Expected Result

I should be able to navigate by column number using vim's builtin motion NG

Actual Result

It doesn't work

mfussenegger commented 5 months ago

Could you try with https://github.com/mfussenegger/nvim-dap/pull/1132 ?

serranomorante commented 5 months ago

Magnificent! It works now. Thanks!