fedepujol / move.nvim

Gain the power to move lines and blocks and auto-indent them!
GNU General Public License v3.0
348 stars 6 forks source link

Merge keymapping and lazy config together #30

Open ReKylee opened 2 weeks ago

ReKylee commented 2 weeks ago

I hope this is helpful, but I wrote the keymaps inside the Lazy config, instead of using vim.keymap.set

{
    "fedepujol/move.nvim",
    keys = {
      -- Normal Mode
      { "<A-j>", "<cmd>MoveLine(1)<CR>", desc = "Move Line Up" },
      { "<A-k>", "<cmd>MoveLine(-1)<CR>", desc = "Move Line Down" },
      -- { "<A-h>", "<cmd>MoveHChar(-1)<CR>", desc = "Move Character Left" },
      -- { "<A-l>", "<cmd>MoveHChar(1)<CR>", desc = "Move Character Right" },
      { "<A-h>", "<cmd>MoveWord(-1)<CR>", mode = { "n" }, desc = "Move Word Left" },
      { "<A-l>", "<cmd>MoveWord(1)<CR>", mode = { "n" }, desc = "Move Word Right" },
      -- Visual Mode
      { "<A-j>", "<cmd>MoveBlock(1)<CR>", mode = { "v" }, desc = "Move Block Up" },
      { "<A-k>", "<cmd>MoveBlock(-1)<CR>", mode = { "v" }, desc = "Move Block Down" },
      { "<A-h>", "<cmd>MoveHBlock(-1)<CR>", mode = { "v" }, desc = "Move Block Left" },
      { "<A-l>", "<cmd>MoveHBlock(1)<CR>", mode = { "v" }, desc = "Move Block Right" },
    },
    opts = {
      -- Config here
    },
  },

This MoveHChar is disabled since it's already disabled in the default config. I do not know if this is mapped by default, but when installing through Lazy the plugin didn't load with the keymaps, so I assume Lazy uses that to know when to load the plugin.

ReKylee commented 2 weeks ago

    "fedepujol/move.nvim",
    keys = {
      -- Normal Mode
      { "<A-j>", "<cmd>MoveLine(1)<CR>", desc = "Move Line Up" },
      { "<A-k>", "<cmd>MoveLine(-1)<CR>", desc = "Move Line Down" },
      -- { "<A-h>", "<cmd>MoveHChar(-1)<CR>", desc = "Move Character Left" },
      -- { "<A-l>", "<cmd>MoveHChar(1)<CR>", desc = "Move Character Right" },
      { "<A-b>", "<cmd>MoveWord(-1)<CR>", desc = "Move Word Left" },
      { "<A-w>", "<cmd>MoveWord(1)<CR>", desc = "Move Word Right" },
      -- Visual Mode
      { "<A-j>", "<cmd>MoveBlock(1)<CR>", mode = { "v" }, desc = "Move Block Up" },
      { "<A-k>", "<cmd>MoveBlock(-1)<CR>", mode = { "v" }, desc = "Move Block Down" },
      { "<A-h>", "<cmd>MoveHBlock(-1)<CR>", mode = { "v" }, desc = "Move Block Left" },
      { "<A-l>", "<cmd>MoveHBlock(1)<CR>", mode = { "v" }, desc = "Move Block Right" },
    },
    opts = {
      -- Config here
    },
  },```

  Alternative since my <A-h> is already mapped to New Horizontal Terminal