lewis6991 / pckr.nvim

Spiritual successor of https://github.com/wbthomason/packer.nvim
MIT License
243 stars 13 forks source link

feature: add support for binding custom function to keys #10

Closed Zhou-Yicheng closed 7 months ago

Zhou-Yicheng commented 10 months ago

Add support for rhs and opts of vim.keymap.set

Test with following spec:

local keys = require('pckr.loader.keys')
require('pckr').add {
  {
    'folke/flash.nvim',
    cond = {
      keys({ 'n', 'x', 'o' }, 's', function() require('flash').jump() end, { desc = 'Flash' }),
      keys({ 'n', 'x', 'o' }, 'S', function() require('flash').treesitter() end, { desc = 'Flash Treesitter' }),
      keys({ 'o' }, 'r', function() require('flash').remote() end, { desc = 'Remote Flash' }),
      keys({ 'o', 'x' }, 'R', function() require('flash').treesitter_search() end, { desc = 'Treesitter Search' }),
      keys({ 'c' }, '<c-s>', function() require('flash').toggle() end, { desc = 'Toggle Flash Search' }),
    },
  }
}