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

Add opts to remap, remap_event (core.keybinds) #1255

Closed
1 task done
aorith opened this issue Dec 29, 2023 · 1 comment
Closed
1 task done

Add opts to remap, remap_event (core.keybinds) #1255

aorith opened this issue Dec 29, 2023 · 1 comment
Labels
feature Issues related to feature proposals. Please attach a module.

Comments

@aorith
Copy link
Contributor

aorith commented Dec 29, 2023

Issues

  • I have checked existing issues and there are no existing ones with the same request.

Feature description

Hi,

I just noticed that:

hook = function(k)
  k.map("norg", "n", "<LocalLeader>T", "<cmd>Neorg toc<cr>", { desc = "[neorg] ToC" })
end,

Shows the description but:

hook = function(k)
  k.remap("norg", "n", "<LocalLeader>T", "<cmd>Neorg toc<cr>", { desc = "[neorg] ToC" })
end,

Does not, since the later does not accept opts as argument (ref).
I think it would be a good idea if all the map/remap functions accept opts.

Help

Yes

Implementation help

No response

@aorith aorith added the feature Issues related to feature proposals. Please attach a module. label Dec 29, 2023
@github-project-automation github-project-automation bot moved this to added-updated-reopened in sorting neorg issue tracker Dec 29, 2023
@aorith
Copy link
Contributor Author

aorith commented Dec 30, 2023

BTW, it seems like the keybind hooks are being triggered multiple times. For instance, in the following configuration:

load = {
  ["core.defaults"] = {},

  ["core.keybinds"] = {
    config = {
      default_keybinds = true,
      hook = function(k)
        k.map("norg", "n", "<LocalLeader>T", "<cmd>Neorg toc<cr>", { desc = "Table of Content" })
      end,
    },
  },
}

The map hook is executed six times for the same keybind whenever a norg file is opened.

And in this configuration:

load = {
  --["core.defaults"] = {},

  ["core.keybinds"] = {
    config = {
      default_keybinds = true,
      hook = function(k)
        k.map("norg", "n", "<LocalLeader>T", "<cmd>Neorg toc<cr>", { desc = "Table of Content" })
      end,
    },
  },
}

The map hook is called four times.
Is it normal or there is a weird loop going on here?

@aorith aorith closed this as completed Jan 6, 2024
@github-project-automation github-project-automation bot moved this from added-updated-reopened to done in sorting neorg issue tracker Jan 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Issues related to feature proposals. Please attach a module.
Projects
None yet
Development

No branches or pull requests

1 participant