Skip to content

Ability to overwrite desc in mappings in settings #781

@snoblenet

Description

@snoblenet

Does this feature exist in Emacs orgmode core?

N/A

Orgmode link

No response

Feature value

At present, I have to spell out every key mapping twice.

In my orgmode-nvim settings, as settings => mapping => preferred shortcut.

And in my which-key settings, as settings => mapping => preferred shortcut and desc.

For example:

-- nvim/lua/plugins/orgmode.lua

return {
  'nvim-orgmode/orgmode',
  config = function()
    require('orgmode').setup({
      mappings = {
        org = {
          org_priority = '<leader>opc',
          org_priority_up = '<leader>opu',
          org_priority_down = '<leader>opd',
        },
      },
    })
  end,
}

-- nvim/lua/plugins/whichkey.lua

return {
  'folke/which-key.nvim',
  config = function()
    wk = require('which-key')
    wk.setup({})

    vim.api.nvim_create_autocmd('FileType', {
      pattern = 'org',
      callback = function()
        local buf = vim.api.nvim_get_current_buf()

        wk.add({
          { '<leader>op', group = 'Priority', buffer = buf },
          { '<leader>opc', desc = 'Change', buffer = buf },
          { '<leader>opu', desc = 'Up', buffer = buf },
          { '<leader>opd', desc = 'Down', buffer = buf },
        })
      end,
    })
 end
}

This creates the risk of the two tables getting out of sync.

It also means I spend a lot of wasted effort inside which-key creating autocommands that attempt to duplicate functionality that already exists within orgmode-nvim.

If orgmode-nvim allowed you to overwrite the desc in its own settings, I'd only have to specify this once, which would eliminate the risk of these two tables getting out of sync. I'd also be able to let orgmode-nvim take care of deciding when the shortcut should be made available, instead of writing my own autocommands.

(I'd still have to define custom groups within which-key, but at least they are only defined once.)

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions