Skip to content

Commit

Permalink
feat(selection_popup): allow keybinds to be processed from another bu…
Browse files Browse the repository at this point in the history
…ffer
vhyrro committed Nov 18, 2023

Verified

This commit was signed with the committer’s verified signature.
1 parent 310f3a4 commit 603b633
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lua/neorg/modules/core/ui/selection_popup.lua
Original file line number Diff line number Diff line change
@@ -12,8 +12,9 @@ local module = modules.create("core.ui.selection_popup")
module.public = {
--- Constructs a new selection
---@param buffer number #The number of the buffer the selection should attach to
---@param keybind_buffer number? #An alternate buffer from which the keybinds for the selection popup are entered.
---@return table #A selection object
begin_selection = function(buffer)
begin_selection = function(buffer, keybind_buffer)
-- Data that is gathered up over the lifetime of the selection popup
local data = {}

@@ -105,7 +106,7 @@ module.public = {
-- Go through all keys that the user has bound a listener to and bind them!
for _, key in ipairs(keys) do
vim.keymap.set(mode or "n", key, lib.wrap(func, self), {
buffer = buffer,
buffer = keybind_buffer or buffer,
silent = true,
nowait = true,
})
@@ -126,7 +127,7 @@ module.public = {
-- Go through all keys that the user has bound a listener to and bind them!
for _, key in pairs(keys) do
vim.keymap.set(mode or "n", key, lib.wrap(func, self), {
buffer = buffer,
buffer = keybind_buffer or buffer,
silent = true,
nowait = true,
})

1 comment on commit 603b633

@aarimond
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
I think this is causing an error in my basic setup, when the "link-not-found" popup is supposed be opened as a split:

E5108: Error executing lua: ...im/lazy/neorg/lua/neorg/modules/core/keybinds/module.lua:323: Vim:Error executing Lua callbac
k: vim/keymap.lua:0: Invalid buffer id: 1002
stack traceback:
        [C]: in function 'nvim_buf_set_keymap'
        vim/keymap.lua: in function 'set'
        ...lazy/neorg/lua/neorg/modules/core/ui/selection_popup.lua:108: in function 'listener'
        ...zy/neorg/lua/neorg/modules/core/esupports/hop/module.lua:209: in function 'follow_link'
        ...zy/neorg/lua/neorg/modules/core/esupports/hop/module.lua:956: in function 'on_event'
        .../.local/share/nvim/lazy/neorg/lua/neorg/core/modules.lua:709: in function 'broadcast_event'
        ...im/lazy/neorg/lua/neorg/modules/core/keybinds/module.lua:447: in function <...im/lazy/neorg/lua/neorg/modules/cor
e/keybinds/module.lua:432>
        ...im/lazy/neorg/lua/neorg/modules/core/keybinds/module.lua:431: in function 'on_event'
        .../.local/share/nvim/lazy/neorg/lua/neorg/core/modules.lua:709: in function 'broadcast_event'
        ...im/lazy/neorg/lua/neorg/modules/core/neorgcmd/module.lua:286: in function <...im/lazy/neorg/lua/neorg/modules/cor
e/neorgcmd/module.lua:193>
        [C]: in function 'nvim_cmd'
        ...im/lazy/neorg/lua/neorg/modules/core/keybinds/module.lua:323: in function <...im/lazy/neorg/lua/neorg/modules/cor
e/keybinds/module.lua:321>
stack traceback:
        [C]: in function 'nvim_cmd'
        ...im/lazy/neorg/lua/neorg/modules/core/keybinds/module.lua:323: in function <...im/lazy/neorg/lua/neorg/modules/cor
e/keybinds/module.lua:321>

When I remove the keybind_buffer, the link fixing works properly.

This is my setup:

return {
    "nvim-neorg/neorg",
    build = ":Neorg sync-parsers",
    dependencies = { "nvim-lua/plenary.nvim" },
    config = function()
      require("neorg").setup {
        load = {
          ["core.defaults"] = {}, -- Loads default behaviour
          ["core.keybinds"] = {},
          ["core.concealer"] = {}, -- Adds pretty icons to your documents
          ["core.dirman"] = { -- Manages Neorg workspaces
            config = {
              workspaces = {
                notes = "~/notes",
              },
            },
          },
        },
      }
    end
}

Please sign in to comment.