Tuesday, January 19, 2021

Re: Syntax highlighting

Dominique wrote:

> Tony Mechelynck wrote:
>
> > On Tue, Jan 19, 2021 at 9:53 AM Softwafe Engineer <timsofteng@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.

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 -- Bram@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 ///

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/202101191729.10JHTIRP1318031%40masaka.moolenaar.net.

No comments: