Skip to content

Latest commit

 

History

History
65 lines (53 loc) · 1.47 KB

USAGE_EXAMPLES.md

File metadata and controls

65 lines (53 loc) · 1.47 KB

Usage Examples

Filter items by current mode

require('legendary').find({ filters = { require('legendary.filters').current_mode() } })

Filter items by normal mode

require('legendary').find({ filters = { require('legendary.filters').mode('n') } })

Filter to only keymaps and by current mode

require('legendary').find({
  filters = {
    require('legendary.filters').mode('n'),
    require('legendary.filters').keymaps(),
  },
})

Customize select prompt title

require('legendary').find({ select_prompt = 'Custom prompt' })
-- OR
require('legendary').find({
  filters = { require('legendary.filters').keymaps() },
  select_prompt = function() -- can also be a function
    return string.format('%s | Finding Keymaps', vim.fn.getcwd())
  end,
})

Filter keymaps by normal mode and that start with <leader>

require('legendary').find({
  filters = {
    require('legendary.filters').mode('n'),
    function(item)
      return require('legendary.toolbox').is_keymap(item) and vim.startswith(item[1], '<leader>')
    end,
  },
})

Filter keymaps by current mode, and only display current mode in first column

require('legendary').find({
  filters = { require('legendary.filters').current_mode() },
  formatter = function(item, mode)
    local values = require('legendary.ui.format').default_format(item)
    if require('legendary.toolbox').is_keymap(item) then
      values[1] = mode
    end
    return values
  end
})