caksoylar / keymap-drawer

Visualize keymaps that use advanced features like hold-taps and combos, with automatic parsing
https://caksoylar.github.io/keymap-drawer
MIT License
663 stars 56 forks source link

Feature request/question: zmk-helpers support #101

Closed hendstephen closed 2 months ago

hendstephen commented 3 months ago

Does this/will this support urob's zmk-helpers module, found below? I used version 1, but switched to a normal declarative config to use this keymap-drawer. There are some conveniences I miss though, and have thought about using v2. Is this something that keymap-drawer could support?

https://github.com/urob/zmk-helpers/tree/v2?tab=readme-ov-file

caksoylar commented 3 months ago

Not right now, at least if you use the recommended installation method through config/west.yml. This is something I have been thinking more about, since ZMK is moving more into using west modules. While most modules aren't relevant to keymap drawing, the zmk-helpers one specifically is.

Currently there are two separate things that need to be done to be able to use modules:

  1. Fetch the listed modules: This can be done via utilizing west (e.g. as part of the automated workflow) or re-implementing some of its logic by parsing west.yml
    • This step can be skipped in CLI use, since we could require local paths for modules
  2. Add the module contents to the "include" path: This is needed to be able to #include files that live in modules, like noted here
    • Initial implementation could involve adding a module path arg to keymap parse, where we'd parse module.yml in it and find the right paths to use

I should probably look into this soon, but these are not the fun parts of the project as you can imagine 😄

caksoylar commented 3 months ago

Oh, I think this workaround could be used right now if you really want to use both zmk-helpers/v2 and keymap-drawer: Place this folder in config/zmk-helpers. Then usage like #include "zmk-helpers/helper.h" should work with keymap-drawer, since the files will actually be in those relative paths.

hendstephen commented 3 months ago

Thanks! I figured I could just pull them in locally as a workaround if needed. Totally understand there is more higher priority work, maybe I'll poke around on a fork if I have some free time.

caksoylar commented 2 months ago

Thanks to @stijnveenman, this is now possible through #105 and #107.

You need to add the include path to your config:

parse_config:
  [...]
  zmk_additional_includes: ["zmk-helpers/include"]

If you are using the Github workflow, you need to also set the west config path so it fetches west modules (including zmk-helpers) first in your workflow yaml:

jobs:
  draw:
    uses: caksoylar/keymap-drawer/.github/workflows/draw-zmk.yml@main
    permissions:
      contents: write  # allow workflow to commit to the repo
    with:
      [...]
      install_branch: main  # need this until the next release to get the latest keymap-drawer
      west_config_path: 'config'