[vim/vim] fix(swayconfig): floating_modifier (PR #14827)

10 views
Skip to first unread message

James Eapen

unread,
May 22, 2024, 4:40:38 PMMay 22
to vim/vim, Subscribed

Restores correct highlighting of swayconfig's floating_modifier with the normal and inverse options. Both i3 and sway have this keyword, but i3 does not have the normal|inverse. When this match was set as contained in 679f5ab, it prevented the sway options from being recognized.

Added the none option which was not supported but is a valid option in sway config.

Ideally floating_modifier would be a keyword as it is in i3config.vim, but I'm still working that out.

Fixes #14826


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/14827

Commit Summary

  • 971d77b fix normal|inverse not being allowed in sway
  • 42aa58f fix: allow none as standalone floating_modifier option

File Changes

(1 file)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14827@github.com>

James Eapen

unread,
May 22, 2024, 6:00:39 PMMay 22
to vim/vim, Subscribed

setting as draft since some issues remain:
image.png (view on web)

The first two lines should show bad normal as errors but do not.

Using

syn match i3ConfigKeyword /floating_modifier \(none$\|$[a-zA-Z0-9+]\+ \(normal\|inverse\)\)$/ contains=i3ConfigVariable,i3ConfigBindModkey,swayConfigFloatingModifierOpts

with the $ outside the alphanumeric match gets
image.png (view on web)

Here it looks better except that Mod keys aren't allowed anything following them.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14827/c2125844055@github.com>

James Eapen

unread,
May 22, 2024, 7:40:16 PMMay 22
to vim/vim, Push

@jamespeapen pushed 1 commit.

  • dbdf3e1 make floating_modifier option matching more precise


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14827/push/18546523448@github.com>

James Eapen

unread,
May 22, 2024, 7:50:10 PMMay 22
to vim/vim, Subscribed

Made the capture groups a little more explicit:
image.png (view on web)

Let me know if you have any suggestions @JosefLitos. Otherwise I'm happy with this. Since both i3 and sway don't share too many different options for the same keyword like floating_modifier, I'm okay with the current fix.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14827/c2125955506@github.com>

Josef Litoš

unread,
May 23, 2024, 1:24:48 AMMay 23
to vim/vim, Subscribed

This is a workaround to the issue, not actually fixing the root of it. The reall source of the problem is a change in i3config.vim floating_modifier implementation. I went from a match to a keyword, which takes precedence.

To make them work both, I'd suggest leaving the contained keyword in the swayconfig part and replacing i3config part with:

" 4.7 Floating modifier
- syn keyword i3ConfigKeyword floating_modifier contained skipwhite nextgroup=i3ConfigVariable,i3ConfigBindModkey
+ syn match i3ConfigKeyword /floating_modifier [$a-zA-Z0-9+]\+$/ contained contains=i3ConfigVariable,i3ConfigBindModkey


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14827/c2126258693@github.com>

James Eapen

unread,
May 23, 2024, 10:34:03 AMMay 23
to vim/vim, Push

@jamespeapen pushed 1 commit.

  • 53cde3f fix: support floating_modifier none; revert broken highlighting


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14827/push/18557670927@github.com>

James Eapen

unread,
May 23, 2024, 10:36:33 AMMay 23
to vim/vim, Push

@jamespeapen pushed 1 commit.


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14827/push/18557718277@github.com>

James Eapen

unread,
May 23, 2024, 10:36:50 AMMay 23
to vim/vim, Subscribed

Thanks! I've reverted the i3 change that caused the issue @hiqua. For the precise matches, I think its more consistent to be precise since other syntax elements are precisely matched, but you have a point that its not going to be used more than once and vim needn't act as a sway linter. I'll go with the simpler option for now but will keep trying to see if there's another way to get that precision.

For a start I did notice two of the errors are recognized if there are any leading spaces:
image.png (view on web)


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14827/c2127290807@github.com>

Christian Brabandt

unread,
May 23, 2024, 11:49:14 AMMay 23
to vim/vim, Subscribed

Thanks. So is this good to be included? Or are you still working on it? @JosefLitos can you please ACK as well please?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14827/c2127470135@github.com>

James Eapen

unread,
May 23, 2024, 11:52:39 AMMay 23
to vim/vim, Subscribed

Yes its good to go.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14827/c2127481824@github.com>

Christian Brabandt

unread,
May 23, 2024, 2:50:41 PMMay 23
to vim/vim, Subscribed

Closed #14827 via 22ac941.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14827/issue_event/12913937146@github.com>

Josef Litoš

unread,
May 24, 2024, 3:32:51 AMMay 24
to vim/vim, Subscribed

@JosefLitos commented on this pull request.


In runtime/syntax/i3config.vim:

> @@ -67,7 +67,7 @@ syn keyword i3ConfigBindKeyword bindsym bindcode contained skipwhite nextgroup=i
 syn region i3ConfigModeBlock matchgroup=i3ConfigKeyword start=/mode\ze\( --pango_markup\)\? \([^'" {]\+\|'[^']\+'\|".\+"\)\s\+{$/ end=/^}\zs$/ contained contains=i3ConfigShParam,@i3ConfigStrVar,i3ConfigBindKeyword,i3ConfigComment,i3ConfigParen fold keepend extend
 
 " 4.7 Floating modifier
-syn keyword i3ConfigKeyword floating_modifier contained skipwhite nextgroup=i3ConfigVariable,i3ConfigBindModkey
+syn match i3ConfigKeyword /^floating_modifier [$0-9A-Za-z]*$/ contains=i3ConfigVariable,i3ConfigBindModkey

I may have miscommunicated the changes in i3. The reverted changes in i3 introduce back the issue for which they were made - leading spaces.
We didn't need to put back the start-of-line anchor, but we should have kept in the contained keyword. I wrote the exact changes in the original comment, but a revert was probably not the best way to describe them.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14827/review/2076073071@github.com>

Josef Litoš

unread,
May 24, 2024, 3:44:44 AMMay 24
to vim/vim, Subscribed

For a start I did notice two of the errors are recognized if there are any leading spaces...

The reason leading spaces play a role is the inclusion of ^ in the i3config regex. Otherwise it would be also recognized as valid syntax. That is because of the simplified highlighting. Since that could be quite a common mistake to write it that way, a small simple change could be made for detecting the first character ->

i3config:

syn match i3ConfigKeyword /floating_modifier [$A-Z][0-9A-Za-z]*$/ contained contains=i3ConfigVariable,i3ConfigBindModkey

swayconfig:

syn match i3ConfigKeyword /floating_modifier \(none\|[$A-Z][a-zA-Z0-9+]\+ \(normal\|inverse\)\)$/ contained contains=i3ConfigVariable,i3ConfigBindModkey,swayConfigFloatingModifierOpts

(added [$A-Z] before the rest of the key/var match)


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14827/c2128822735@github.com>

James Eapen

unread,
May 24, 2024, 8:27:35 AMMay 24
to vim/vim, Subscribed

Ah I did focus more on the revert and the sway suggestion than the i3 diff. Thanks @JosefLitos, and apologies @chrisbra the new pull request should supersede this one.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14827/c2129414225@github.com>

Reply all
Reply to author
Forward
0 new messages