Syntax highlighting

66 views
Skip to first unread message

Softwafe Engineer

unread,
Jan 19, 2021, 3:53:26 AM1/19/21
to v...@vim.org
Hello. Any plans about improving of syntax highlighting? I've tried treesitter in neovim and it's pretty cool. In other hand vim's regexp solution is not best I suppose.

Thanks

Tony Mechelynck

unread,
Jan 19, 2021, 4:59:50 AM1/19/21
to Softwafe Engineer, vim_use
On Tue, Jan 19, 2021 at 9:53 AM Softwafe Engineer <timso...@gmail.com> wrote:
>
> Hello. Any plans about improving of syntax highlighting? I've tried treesitter in neovim and it's pretty cool. In other hand vim's regexp solution is not best I suppose.
>
> Thanks

IMHO, the Vim way of highlighting syntax gives pretty cool results;
but it's free and open source software, and with the possible
exception of Bram, no one is paid for even part-time work on it. This
has the following consequences:
- All (or almost all) developers are volunteers, nobody brings any
changes in Vim unless he (or she, for that matter) wants it.
- If you don't like something, there are no rules against backward
engineering: all the source is where anyone can find it, and if you
think you can make it work better, go ahead and propose (in the
vim_dev list) a patch to either the C source or the runtime files, or
both.
- But be warned that Bram highly values backward compatibility, and
changes which break existing runtime files, or existing user scripts,
have a vanishingly small chance of being accepted into the "official"
Vim source. However you're welcome to fork your own version of Vim the
way the Neovim developers did, and to distribute it yourself in a way
compatible with the Vim license. Or if Neovim is exactly what you
prefer, well, go ahead and use it.

Oh, and BTW, if you don't like this answer, please read "How To Ask
Questions The Smart Way"
http://catb.org/~esr/faqs/smart-questions.html then reformulate your
question.

Best regards,
Tony.

Dominique Pellé

unread,
Jan 19, 2021, 7:04:07 AM1/19/21
to Vim List
Tony Mechelynck wrote:

> On Tue, Jan 19, 2021 at 9:53 AM Softwafe Engineer <timso...@gmail.com> wrote:
> >
> > Hello. Any plans about improving of syntax highlighting? I've tried treesitter in neovim and it's pretty cool. In other hand vim's regexp solution is not best I suppose.
> >
> > Thanks
>
> IMHO, the Vim way of highlighting syntax gives pretty cool results;

To be fair, supporting tree-sitter seems really nice.
Perhaps it does not need native support but can be implemented
as a plugin, using Vim text properties?

I have not tried tree-sitter yet, but I glanced at at:
https://tree-sitter.github.io/tree-sitter/
https://github.com/nvim-treesitter/nvim-treesitter

It could provide syntax highlighting for several languages,
based on a real parser of each language. In contrast, vim
native syntax highlighting is based on heuristics with regexps.
Vim syntax highlighting works quite well in general despite using
heuristics, but some complex languages are impossible to get
100% right with vim syntax highlighting (e.g. sh, Perl, c++,...).
It's a bit similar to heuristic indexing (ctags, cscope) vs indexing
with clangd, rtags (etc) which have a full parser and are thus 100%
reliable in principle.

Syntax highlighting with tree-sitter may not only be more accurate,
but perhaps faster and we piggy-back on another tool to support
languages.

Regards
Dominique

Yegappan Lakshmanan

unread,
Jan 19, 2021, 10:30:04 AM1/19/21
to vim...@googlegroups.com
Hi,

On Tue, Jan 19, 2021 at 4:04 AM Dominique Pellé <dominiq...@gmail.com> wrote:
Tony Mechelynck wrote:

> On Tue, Jan 19, 2021 at 9:53 AM Softwafe Engineer <timso...@gmail.com> wrote:
> >
> > Hello. Any plans about improving of syntax highlighting? I've tried treesitter in neovim and it's pretty cool. In other hand vim's regexp solution is not best I suppose.
> >
> > Thanks
>
> IMHO, the Vim way of highlighting syntax gives pretty cool results;

To be fair, supporting tree-sitter seems really nice.
Perhaps it does not need native support but can be implemented
as a plugin, using Vim text properties?


I agree. We should look into seamlessly integrating the following tools
into VIm (mostly using plugins):


These will greatly help programmers who use Vim for development.
We should look into adding native features that will help simplify
the implementation of these plugins.

Regards,
Yegappan

Bram Moolenaar

unread,
Jan 19, 2021, 12:29:30 PM1/19/21
to vim...@googlegroups.com, Dominique Pellé
The idea is that this solution for syntax highlighting would be much
faster. That matters especially for languages where the pattern
matching struggles to do the job.

Last time I looked there were also several disadvantages, I don't know
how many of these have been tackled. I believe the parser needs to be
compiled, which means you can't just drop-in support for a language.
Also, I wonder how the parser handles a file that's halfway being
edited. Does the highlighting stop or get messed up at the first
unfinished line?

It appears the work in Neovim took a long time, thus one can guess that
including it in Vim will also be a lot of work.

It's unlikely the old regexp based syntax engine will ever go away, thus
there will be two implementations to maintain. That is only justifiable
if the new one is really much better.

--
hundred-and-one symptoms of being an internet addict:
183. You move your coffeemaker next to your computer.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages