codethread / qmk.nvim

Format qmk and zmk keymaps in neovim
MIT License
142 stars 5 forks source link

ZMK config question #21

Closed benfrain closed 1 year ago

benfrain commented 1 year ago

When I run :QMKFormat on the file I get [E01] No keymaps found so looks like my config is not correct?

Using Lazy and following the docs I have this:

  {
    "codethread/qmk.nvim",
    config = function()
      ---@type qmk.UserConfig
      local conf = {
        name = "LAYOUT_pretty",
        layout = {
          "x x x x x x x _ _ _ _ _ _ x x x x x x x",
          "x x x x x x x _ _ _ _ _ _ x x x x x x x",
          "x x x x x x x _ _ _ _ _ _ x x x x x x x",
          "x x x x x x _ _ _ _ _ _ _ _ x x x x x x",
          "x x x x x _ _ _ _ _ _ _ _ _ _ x x x x x",
          "_ _ _ _ _ _ x x _ _ _ _ x x _ _ _ _ _ _",
          "_ _ _ _ _ _ _ x _ _ _ _ x _ _ _ _ _ _ _",
          "_ _ _ _ _ x x x _ _ _ _ x x x _ _ _ _ _",
        }
    }
        require("qmk").setup(conf)
    end,
  },

I have the devicetree parser installed, and here is the file I am trying to format: https://github.com/benfrain/Adv360-Pro-ZMK/blob/V2.0/config/adv360.keymap

Could you advise what I am doing wrong?

codethread commented 1 year ago

hey 😄 there's a missing variant config field, there's an example in the README, but it's probably a bit hidden 😅 . The default behaviour assumes QMK, but you're using ZMK

tl;dr

  {
    "codethread/qmk.nvim",
    config = function()
      ---@type qmk.UserConfig
      local conf = {
        name = "LAYOUT_pretty",
        variant = 'zmk', -- <<
        layout = {
          "x x x x x x x _ _ _ _ _ _ x x x x x x x",
          "x x x x x x x _ _ _ _ _ _ x x x x x x x",
          "x x x x x x x _ _ _ _ _ _ x x x x x x x",
          "x x x x x x _ _ _ _ _ _ _ _ x x x x x x",
          "x x x x x _ _ _ _ _ _ _ _ _ _ x x x x x",
          "_ _ _ _ _ _ x x _ _ _ _ x x _ _ _ _ _ _",
          "_ _ _ _ _ _ _ x _ _ _ _ x _ _ _ _ _ _ _",
          "_ _ _ _ _ x x x _ _ _ _ x x x _ _ _ _ _",
        }
    }
        require("qmk").setup(conf)
    end,
  },
codethread commented 1 year ago

though i will update the code to print more helpful errors for the next person 😅

benfrain commented 1 year ago

@codethread ah, I see. Might be worth adding the default variant = "qmk" line in the main example too, just so the copy and pasters (like me :)) have a better idea of what they need to change?