GithubHelp home page GithubHelp logo

Comments (2)

MattSturgeon avatar MattSturgeon commented on June 17, 2024 1

Thanks. I didn't know yaml had an alias system, that'll come in handy.

That does exactly what I was asking for, probably better than any of my proposals.

from keymap-drawer.

caksoylar avatar caksoylar commented on June 17, 2024

Hey, thanks for the nice thought out post. For this I prefer to use YAML anchors and aliases. Even though I am not a fan of most of YAML's features, this is one that came in handy frequently. Basically, you can assign an anchor to a node with &ref syntax and refer to it later via *ref, a contrived example:

LGUI: &lgui
  tap: $$mdi:monitor-dashboard$$
  held: Left
LEFT_GUI: *lgui
# above keys have identical values

RGUI:
  <<: *lgui
  held: Right
# overrides `held` field from above two

(As an aside, I find oq helpful to work with yamls, e.g. oq -i yaml -o simpleyaml can expand aliases like above and print the final result.)

You can see I (ab)use this in the keyboard layouts YAML to reduce repetition: https://github.com/caksoylar/keymap-drawer/blob/main/resources/zmk_keyboard_layouts.yaml

This is similar to your approach 1 in principle, except it is using the configuration syntax features rather than a feature from the keymap-drawer side. Let me know what you think, i.e. if that is good enough. I'd prefer to not add complexity if not needed.

from keymap-drawer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.