Discussion:
has anybody done syntax highlighting for linux Kconfig files ?
Yakov Lerner
2006-04-10 12:54:51 UTC
Permalink
I found no syntax highlighting for Kconfig files (linux kernel configuration).
I searched in vim7 runtime, and in vim.org/scripts, and in google.

If anybody created Kconfig highlighting already, please post it either
to vim.org/scripts or for inclusion into vimruntime,
or send it to me, I am willing to maintain it. If not, I'll make it.

Yakov
Nikolai Weibull
2006-04-10 21:17:09 UTC
Permalink
Post by Yakov Lerner
I found no syntax highlighting for Kconfig files (linux kernel configuration).
I searched in vim7 runtime, and in vim.org/scripts, and in google.
If anybody created Kconfig highlighting already, please post it either
to vim.org/scripts or for inclusion into vimruntime,
or send it to me, I am willing to maintain it. If not, I'll make it.
As per your request, here's a syntax/kconfig.vim. It's rather
complete, although the documentation for the fileformat was
incomplete. Still, writing parsers using only Vim's :syntax command
is quite fun actually. The files are lit up like a christmas tree at
the moment, perhaps more to show that everything works than anything
else, but it's not that bad as it clearly separates the help messages
from the cruft around them. Comments on making the actual
highlighting a little less "verbose" are welcome.

I've also included a ftplugin/kconfig.vim.

Bram: You can add these with the following matcher in filetype.vim:

au BufNewFile,BufRead Kconfig,Kconfig.debug setf kconfig

Enjoy.

nikolai
Yakov Lerner
2006-04-10 22:58:26 UTC
Permalink
Post by Nikolai Weibull
Post by Yakov Lerner
I found no syntax highlighting for Kconfig files (linux kernel configuration).
I searched in vim7 runtime, and in vim.org/scripts, and in google.
If anybody created Kconfig highlighting already, please post it either
to vim.org/scripts or for inclusion into vimruntime,
or send it to me, I am willing to maintain it. If not, I'll make it.
As per your request, here's a syntax/kconfig.vim.
Nice job Nikolai, thanks.
I went though all 2.6 Kconfig files and noticed some mishighlightings.
I extracted them into the attchment, which see (with :set ft=kconfig').

Another issue that I noticed:
when scrolling backward (PgUp) on large Kconfig file,
I get many many unhighlighted lines, sometimes
half-screen of them, which get highlighted when I do Ctrl-L.
Maybe 'syn sync' values shall be adjusted
(screen height was ~ 50, i it's relevant) ?

Thanks
Yakov
Nikolai Weibull
2006-04-11 20:39:17 UTC
Permalink
Post by Yakov Lerner
Post by Nikolai Weibull
As per your request, here's a syntax/kconfig.vim.
Nice job Nikolai, thanks.
I went though all 2.6 Kconfig files and noticed some mishighlightings.
I extracted them into the attchment, which see (with :set ft=kconfig').
when scrolling backward (PgUp) on large Kconfig file,
I get many many unhighlighted lines, sometimes
half-screen of them, which get highlighted when I do Ctrl-L.
Maybe 'syn sync' values shall be adjusted
(screen height was ~ 50, i it's relevant) ?
Hm, yes, there should probably be some syncing in there. In the
meantime, here's a slightly updated version to fix some of the issues
that you found. Most of them are due to the line-continuation
directive /\\$/ which causes a lot of extra work to deal with
correctly (it can be basically anywhere, which makes it hard to retain
the state we try to keep), and comments, which could be made into a
command and thus most of the problems would go away, but never all of
them.

As a solution I've made a "light" version of the kconfig syntax to use
as a default. The "heavy" one previously defined can be enabled by

:let g:kconfig_syntax_heavy = 1

If you could be so kind as to give the light version of the syntax a
try and see if it works just as well as the heavy I'd be happy.

Peace.

nikolai
Yakov Lerner
2006-04-12 07:46:17 UTC
Permalink
Post by Nikolai Weibull
Post by Yakov Lerner
Post by Nikolai Weibull
As per your request, here's a syntax/kconfig.vim.
Nice job Nikolai, thanks.
I went though all 2.6 Kconfig files and noticed some mishighlightings.
I extracted them into the attchment, which see (with :set ft=kconfig').
when scrolling backward (PgUp) on large Kconfig file,
I get many many unhighlighted lines, sometimes
half-screen of them, which get highlighted when I do Ctrl-L.
here's a slightly updated version to fix some of the issues
Post by Nikolai Weibull
that you found. Most of them are due to the line-continuation
directive /\\$/ which causes a lot of extra work to deal with
correctly (it can be basically anywhere, which makes it hard to retain
the state we try to keep), and comments, which could be made into a
command and thus most of the problems would go away, but never all of
them.
As a solution I've made a "light" version of the kconfig syntax to use
as a default. The "heavy" one previously defined can be enabled by
:let g:kconfig_syntax_heavy = 1
Light version suffers from this big problem: the apostrophe in help text
scrambles highlighting for many following paragpaphs
(like "won't" ). Heavy version doesn't suffer from this problem.

Both in light and in heavy version: keywords (if, source )
are highlighted in help texts. Keywords probably shall not be highlighted
in help texts.

Yakov
Nikolai Weibull
2006-04-12 20:03:28 UTC
Permalink
Post by Nikolai Weibull
Post by Nikolai Weibull
Post by Yakov Lerner
Post by Nikolai Weibull
As per your request, here's a syntax/kconfig.vim.
Nice job Nikolai, thanks.
I went though all 2.6 Kconfig files and noticed some mishighlightings.
I extracted them into the attchment, which see (with :set ft=kconfig').
when scrolling backward (PgUp) on large Kconfig file,
I get many many unhighlighted lines, sometimes
half-screen of them, which get highlighted when I do Ctrl-L.
here's a slightly updated version to fix some of the issues
Post by Nikolai Weibull
that you found. Most of them are due to the line-continuation
directive /\\$/ which causes a lot of extra work to deal with
correctly (it can be basically anywhere, which makes it hard to retain
the state we try to keep), and comments, which could be made into a
command and thus most of the problems would go away, but never all of
them.
As a solution I've made a "light" version of the kconfig syntax to use
as a default. The "heavy" one previously defined can be enabled by
:let g:kconfig_syntax_heavy = 1
Light version suffers from this big problem: the apostrophe in help text
scrambles highlighting for many following paragpaphs
(like "won't" ). Heavy version doesn't suffer from this problem.
Both in light and in heavy version: keywords (if, source )
are highlighted in help texts. Keywords probably shall not be highlighted
in help texts.
OK, this and some syncing issues has been fixed.

Here's a probably final version.

Peace.

nikolai
Yakov Lerner
2006-04-13 11:43:32 UTC
Permalink
Post by Nikolai Weibull
Post by Yakov Lerner
Post by Nikolai Weibull
Post by Yakov Lerner
Post by Nikolai Weibull
As per your request, here's a syntax/kconfig.vim.
Nice job Nikolai, thanks.
I went though all 2.6 Kconfig files and noticed some mishighlightings.
As a solution I've made a "light" version of the kconfig syntax to use
as a default. The "heavy" one previously defined can be enabled by
:let g:kconfig_syntax_heavy = 1
Light version suffers from this big problem: the apostrophe in help text
scrambles highlighting for many following paragpaphs
(like "won't" ). Heavy version doesn't suffer from this problem.
Both in light and in heavy version: keywords (if, source )
are highlighted in help texts. Keywords probably shall not be highlighted
in help texts.
OK, this and some syncing issues has been fixed.
Hi Nikolai,
Thanks for a great job. The apostrophe in helptexts mostly works.
I found two cases though where it does not work (see below),
Also, when helptext with apostrophe is top line of the
screen, all screen is painted same color (probably a syncing issue).
Thanks
Yakov
------------------------ case1 ------------------
config ARCNET_CAP
tristate "Enable CAP mode packet interface"
depends on ARCNET
help
ARCnet "cap mode" packet encapsulation. Used to get the hardware
acknowledge back to userspace. After the initial protocol byte every
packet is stuffed with an extra 4 byte "cookie" which doesn't
actually appear on the network. After transmit the driver will send
back a packet with protocol byte 0 containing the status of the
transmition:
0=no hardware acknowledge
1=excessive nak
2=transmition accepted by the reciever hardware

Received packets are also stuffed with the extra 4 bytes but it will
be random data.

Cap only listens to protocol 1-8.
------------------------- case 2 ----------------------------------
# ARM925T
config CPU_ARM925T
bool "Support ARM925T processor" if ARCH_OMAP1
depends on ARCH_OMAP15XX
default y if ARCH_OMAP15XX
select CPU_32v4
select CPU_ABRT_EV4T
select CPU_CACHE_V4WT
select CPU_CACHE_VIVT
select CPU_COPY_V4WB
select CPU_TLB_V4WBI
help
The ARM925T is a mix between the ARM920T and ARM926T, but with
different instruction and data caches. It is used in TI's OMAP
device family.

Say Y if you want support for the ARM925T processor.
Otherwise, say N.
----------------------------------------------------------------------------------------------
Nikolai Weibull
2006-04-13 15:12:06 UTC
Permalink
Post by Yakov Lerner
Post by Nikolai Weibull
OK, this and some syncing issues has been fixed.
Hi Nikolai,
Thanks for a great job. The apostrophe in helptexts mostly works.
I found two cases though where it does not work (see below),
Also, when helptext with apostrophe is top line of the
screen, all screen is painted same color (probably a syncing issue).
Hm, forgot to add syncing to the light version. I added the following:

syn sync match kconfigSyncHelp grouphere kconfigHelpText
'help\|---help---'

I hope that's how you use the 'syn sync ... grouphere' syntax...

It seems to work anyway.

Peace.

nikolai

Bram Moolenaar
2006-04-11 10:23:45 UTC
Permalink
Post by Nikolai Weibull
As per your request, here's a syntax/kconfig.vim. It's rather
complete, although the documentation for the fileformat was
incomplete. Still, writing parsers using only Vim's :syntax command
is quite fun actually. The files are lit up like a christmas tree at
the moment, perhaps more to show that everything works than anything
else, but it's not that bad as it clearly separates the help messages
from the cruft around them. Comments on making the actual
highlighting a little less "verbose" are welcome.
I've also included a ftplugin/kconfig.vim.
au BufNewFile,BufRead Kconfig,Kconfig.debug setf kconfig
I'll include it, thanks!
--
A day without sunshine is like, well, night.

/// Bram Moolenaar -- ***@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ download, build and distribute -- http://www.A-A-P.org ///
\\\ help me help AIDS victims -- http://www.ICCF.nl ///
Loading...