nvim-orgmode / orgmode

Orgmode clone written in Lua for Neovim 0.9+.
https://nvim-orgmode.github.io/
MIT License
2.97k stars 130 forks source link

Ability to overwrite desc in mappings in settings #781

Closed snoblenet closed 3 weeks ago

snoblenet commented 1 month ago

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

snoblenet commented 1 month ago

Don't mind me. The implied solution is in the docs:

require('orgmode').setup({
  mappings = {
    disable_all = true
  }
})
snoblenet commented 1 month ago

I fixed this issue in this PR -- review appreciated

https://github.com/nvim-orgmode/orgmode/pull/789