Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatter should considerer the large of a word in aligning #40

Open
jvlara opened this issue Oct 10, 2024 · 4 comments
Open

Formatter should considerer the large of a word in aligning #40

jvlara opened this issue Oct 10, 2024 · 4 comments

Comments

@jvlara
Copy link

jvlara commented Oct 10, 2024

When I autoformat a file, it aligns the content without considering the length of each word, causing the alignment to appear offset compared to the defsrc

It would be helpful if the parser added padding so that every layer aligns properly with the defsrc

@rszyma
Copy link
Owner

rszyma commented Oct 10, 2024

Just to make sure, can you show an example of what you mean? current vs expected examples

@jvlara
Copy link
Author

jvlara commented Oct 10, 2024

Of course!

This is the result of alignment with the current formatter

(defsrc
  esc         1    2    3    4    5   6   7    8    9    0         -       =       bspc
  tab         q    w    e    r    t   y   u    i    o    p         {       }
  caps        a    s    d    f    g   h   j    k    l    ;         apo
  lshift      z    x    c    v    b   n   m    ,    .    /
  lctrl       lmeta lalt            spc                   ralt
  \
)

(deflayer arrows
  `           f1   f2   f3   f4   f5  f6  f7   f8   f9   f10       @lparen @rparen del
  _           @lword up   @rword bspc _   _   home end  @lbrac @rbrac    _       _
  _           left down rght _    _   _   @lparen @rparen @lcor @rcor     _
  _           lrld @tdef @tbase _    _   _   _    _    @lrow @rrow
  _           _     _               @delw                 _
  _
)

This is what i think it should be

(defsrc
  esc         1    2    3    4    5   6   7    8    9    0         -       =       bspc
  tab         q    w    e    r    t   y   u    i    o    p         {       }
  caps        a    s    d    f    g   h   j    k    l    ;         apo
  lshift      z    x    c    v    b   n   m    ,    .    /
  lctrl       lmeta lalt            spc                   ralt
  \
)

(deflayer arrows
  `           f1   f2   f3   f4   f5  f6  f7   f8   f9   f10       @lparen  @rparen  del
  _           @lword   up    @rword   bspc _   _   home   end      @lbrac   @rbrac   _   _
  _           left     down  rght     _    _   _   @lparen @rparen @lcor    @rcor    _
  _           lrld     @tdef @tbase   _    _   _   _       _       @lrow    @rrow
  _           _        _               @delw                 _
  _
)

@rszyma
Copy link
Owner

rszyma commented Oct 13, 2024

Some thoughs:

As a workaround, you could just manually increase spacing in defsrc, enough to fit all items in all deflayers, and use short 3, 4 character aliases in deflayers to make the whole thing not too wide.

Column width adjustment for deflayers sounds ok, until you realize that there's no concept of columns from the point of view of kanata (and formatter). What if user does something like this? (I've seen configs like this before):

(defsrc
  grv   1    2    3    4    5    6    7    8    9    0    -    =    bspc
  tab     q    w    e    r    t    y    u    i    o    p    [    ]    \
  caps      a    s    d    f    g    h    j    k    l    ;    '    ret
  lsft        z    x    c    v    b    n    m    ,    .    /    rsft
  lctl  lmet lalt           spc            ralt rmet rctl
)

Which item is which column?

At the very least this option can't be enabled by default. At least not on it's own. The only way I see it being implemented, is along some strict grid enforcement, forcing defsrc to look like this:

(defsrc
  esc  1    2    3    4    5    6    7    8    9    0    -    =    bspc grv
  tab  q    w    e    r    t    y    u    i    o    p    [    ]    \    del
  caps a    s    d    f    g    h    j    k    l    ;    '    ret       pgup
  lsft z    x    c    v    b    n    m    ,    .    /    rsft      up   pgdn
  lctl lmet lalt                spc            ralt      rctl left down rght
)

then we could tell items are which columns

@jvlara
Copy link
Author

jvlara commented Oct 17, 2024

Got it, the workaround is working great, I’m using it in my current setup

I don’t really think the idea of columns is necessary here. In your example, where the keys aren't orthogonal, it should still keep that alignment of the defsrc across all the deflayers. Maybe it could detect the key with the longest character count and add that spacing into the defsrc automatically? so the user don't need to add the spacing into each key manually with the workaround 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants