[PATCH] runtime(kconfig): Add support for kconfig_minlines variable

44 views
Skip to first unread message

Dragan Simic

unread,
Jan 20, 2025, 2:20:41 PMJan 20
to vim...@vim.org
Following the approach used in other syntax definitions, add support for
defining the "syntax sync minlines=..." values for kconfig files in users'
~/.vimrc files, to allow the users to adjust that value in case syntax
highlighting stops working for some of the files they edit.

Signed-off-by: Dragan Simic <dsi...@manjaro.org>
---
runtime/syntax/kconfig.vim | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/runtime/syntax/kconfig.vim b/runtime/syntax/kconfig.vim
index 0aecc0006085..62e47471a554 100644
--- a/runtime/syntax/kconfig.vim
+++ b/runtime/syntax/kconfig.vim
@@ -1,7 +1,7 @@
" Vim syntax file
" Maintainer: Christian Brabandt <c...@256bit.org>
" Previous Maintainer: Nikolai Weibull <n...@bitwi.se>
-" Latest Revision: 2024-07-19
+" Latest Revision: 2025-01-19
" License: Vim (see :h license)
" Repository: https://github.com/chrisbra/vim-kconfig

@@ -587,8 +587,6 @@ syn match kconfigConfOptExprGrpE ')'
\ kconfigConfOptExprOr
\ skipwhite skipnl

-syn sync minlines=50
-
hi def link kconfigTodo Todo
hi def link kconfigComment Comment
hi def link kconfigKeyword Keyword
@@ -715,6 +713,11 @@ syn region kconfigHelpText
\ skip='^$'
\ end='^\z1\@!'

+if !exists("kconfig_minlines")
+ let kconfig_minlines = 50
+endif
+exec "syn sync minlines=" . kconfig_minlines
+
hi def link kconfigTodo Todo
hi def link kconfigComment Comment
hi def link kconfigKeyword Keyword

Christian Brabandt

unread,
Jan 20, 2025, 2:30:46 PMJan 20
to vim...@googlegroups.com
Note: first time postings are subject to moderation, unfortunately,
google didn't notify me until now. So I approved your first mail and
rejected the others.

On Sun, 19 Jan 2025, 'Dragan Simic' via vim_dev wrote:

> Following the approach used in other syntax definitions, add support for
> defining the "syntax sync minlines=..." values for kconfig files in users'
> ~/.vimrc files, to allow the users to adjust that value in case syntax
> highlighting stops working for some of the files they edit.
>
> Signed-off-by: Dragan Simic <dsi...@manjaro.org>
> ---
> runtime/syntax/kconfig.vim | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
[...]
> " Repository: https://github.com/chrisbra/vim-kconfig

Technically, patches should go via the upstream repo first. I have
included your change to the upstream repo and will be pushing an update
to the Vim repo in a few minutes.

Thanks,
Christian
--
Do not write in this space.

Dragan Simic

unread,
Jan 20, 2025, 3:28:32 PMJan 20
to vim...@googlegroups.com, Christian Brabandt
Hello Christian,

On 2025-01-20 20:30, Christian Brabandt wrote:
> Note: first time postings are subject to moderation, unfortunately,
> google didn't notify me until now. So I approved your first mail and
> rejected the others.

Thanks for the clarification. My patch seemed to be lost somewhere,
and I didn't know what would be the proper thing to do in such cases,
so I just sent it again.

> On Sun, 19 Jan 2025, 'Dragan Simic' via vim_dev wrote:
>
>> Following the approach used in other syntax definitions, add support
>> for
>> defining the "syntax sync minlines=..." values for kconfig files in
>> users'
>> ~/.vimrc files, to allow the users to adjust that value in case syntax
>> highlighting stops working for some of the files they edit.
>>
>> Signed-off-by: Dragan Simic <dsi...@manjaro.org>
>> ---
>> runtime/syntax/kconfig.vim | 9 ++++++---
>> 1 file changed, 6 insertions(+), 3 deletions(-)
>>
> [...]
>> " Repository: https://github.com/chrisbra/vim-kconfig
>
> Technically, patches should go via the upstream repo first. I have
> included your change to the upstream repo and will be pushing an update
> to the Vim repo in a few minutes.

Thanks a lot for picking my patch and following it through. I saw that
the upstream repository was mentioned in syntax/kconfig.vim, but I also
can't use GitHub at the moment, so I opted to effectively "abuse" the
vim-dev mailing list a bit.

Dragan Simic

unread,
Jan 20, 2025, 5:09:08 PMJan 20
to vim...@googlegroups.com, Christian Brabandt
If I may notice, I'm not really sure that the final form [1] of the code
will work as expected, because I think that the "syntax sync
minlines=..."
should be executed much later in syntax/kconfig.vim, i.e. the way I did
it originally. [2]

To clarify, I originally tried executing "syntax sync minlines=..."
earlier
in syntax/kconfig.vim while setting "kconfig_minlines" to 300 in my
~/.vimrc,
and it failed to work as expected with a troublesome Kconfig file, which
is
why I moved the execution much later in syntax/kconfig.vim.

[1]
https://github.com/chrisbra/vim-kconfig/commit/57cca8215ec067506dd5b49ae1ee37eca39a83ab
[2]
https://github.com/chrisbra/vim-kconfig/commit/ad5151e624d6543a4451de309736f3e061b584d9

Christian Brabandt

unread,
Jan 20, 2025, 5:16:51 PMJan 20
to vim...@googlegroups.com

On Mon, 20 Jan 2025, Dragan Simic wrote:

> If I may notice, I'm not really sure that the final form [1] of the code
> will work as expected, because I think that the "syntax sync minlines=..."
> should be executed much later in syntax/kconfig.vim, i.e. the way I did
> it originally. [2]
>
> To clarify, I originally tried executing "syntax sync minlines=..." earlier
> in syntax/kconfig.vim while setting "kconfig_minlines" to 300 in my
> ~/.vimrc,
> and it failed to work as expected with a troublesome Kconfig file, which is
> why I moved the execution much later in syntax/kconfig.vim.
>
> [1] https://github.com/chrisbra/vim-kconfig/commit/57cca8215ec067506dd5b49ae1ee37eca39a83ab
> [2] https://github.com/chrisbra/vim-kconfig/commit/ad5151e624d6543a4451de309736f3e061b584d9

Can you verify if this works or not? I put it to the top, because you
placed it at the else part of the heavy_syntax config variable condition
(and the whole if-condition confused me quite a bit) and it would
therefore only be effective when the heavy_syntax var wasn't set.

But I don't use Kconfig files at all. So please run in a Kconfig buffer
:syn sync
and vim should output the current setting.

Thanks,
Christian
--
You climb to reach the summit, but once there, discover that all roads
lead down.
-- Stanislaw Lem, "The Cyberiad"

Dragan Simic

unread,
Jan 20, 2025, 11:33:38 PMJan 20
to vim...@googlegroups.com, Christian Brabandt
Hello Christian,
Oh, I see now. Before these changes, "syntax sync minlines=..." was
actually misplaced a bit, and I indeed misplaced my changes. I'm sorry
for that, perhaps I wasn't aware I was tired a bit.

I checked your version [1] with the original troublesome Kconfig file
and it works as expected. Thanks once again for following this through!
Reply all
Reply to author
Forward
0 new messages