Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Element-specific key mappings (for dap-repl and dapui_... windows) #158

Closed
wookayin opened this issue Oct 26, 2022 · 2 comments
Closed

Element-specific key mappings (for dap-repl and dapui_... windows) #158

wookayin opened this issue Oct 26, 2022 · 2 comments

Comments

@wookayin
Copy link

wookayin commented Oct 26, 2022

Can I configure (buffer-local) keymaps for each of the DAP UI elements?

For instance, I would like to map <CR> to the open action for the "DAP Stacks" element. The current behavior of <CR> in this stack frame widget is just a warning message: "No expand action for current line". It would be more intuitive (as a default behavior or for customization) to have <CR> mapped to some action, or re-mapped to o.

Also, users may want to have a lot of custom key mappings. When it comes to dap-repl, it is possible by making a FileType autocmd event as follows:

  vim.api.nvim_create_autocmd("FileType", {
    pattern = "dap-repl",
    group = ... ,  -- some augroup
    callback = function()
      -- Example: Map CTRL-L to clear the clear REPL
      vim.keymap.set('i', '<c-l>', function() dap.repl.clear() end, { buffer = true, desc = 'Clear REPL' })
      -- and more...
    end,
  })

However this does NOT work for dapui_xxx elements. Custom keymaps mapped for filetypes dapui_stacks, dapui_watches, etc. will be lost as dapui would try to reassign the buf-local keymaps during an execution of dapui.render.canvas.render_buffer() when the content changes.

rcarriga added a commit that referenced this issue Oct 26, 2022
@rcarriga
Copy link
Owner

You can now add element specific mappings by adding this to your setup

  element_mappings = {
    stacks = {
      open = "<CR>",
      expand = "o",
    }
  },

@wookayin
Copy link
Author

Thank you, that works well for dapui elements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants