[clangd-dev] Syntax highlighting of keywords

Ilya Biryukov via clangd-dev clangd-dev at lists.llvm.org
Fri Oct 25 09:36:24 PDT 2019


Keywords highlightings (provided by the editors) are definitely much faster
than AST-based ones (which can take minutes in bad cases).
Editors highlightings are also much more reliable, i.e. they never "blink".

IMO one should definitely prefer the editor-based implementation when
possible. The semantic highlightings are always much more "sluggish".

Given that, I think we should prefer to not interfere with the editor
highlightings if we can.

I think we should prefer the failure mode of "editor highlights override as
a keyword and clangd will re-highlight as a variable eventually" to "editor
does not highlight override until clangd produces highlighting".
But I can see how other people can have different opinions here.

Not highlighting 'int' and 'void' in clangd is probably a no-brainer,
though.

On Fri, Oct 25, 2019 at 5:38 PM Duncan P. N. Exon Smith <
dexonsmith at apple.com> wrote:

> Frankly I doubt `final` is tremendously rare as an identifier; it seems
> similar to `result` as a catch-all variable name.
>
> > On Oct 25, 2019, at 08:36, Nathan Ridge via clangd-dev <
> clangd-dev at lists.llvm.org> wrote:
> >
> > I guess it depends how much one values accuracy :) In Eclipse, for
> example, we decided we did not want to keyword-highlight "override" as
> "final" if they occur as identifiers, even if that's rare, so we added them
> to the semantic coloring engine rather than the lexical one. In the LSP
> model, that would be a server-side highlighting.
> >
> > ________________________________________
> > From: Ilya Biryukov <ibiryukov at google.com>
> > Sent: October 25, 2019 2:31 PM
> > To: Nathan Ridge
> > Cc: Haojian Wu; via clangd-dev
> > Subject: Re: [clangd-dev] Syntax highlighting of keywords
> >
> > They're rare as identifiers, though, so I don't see why editors wouldn't
> just always highlight them as keywords.
> >
> > On Fri, Oct 25, 2019 at 4:30 PM Nathan Ridge <zeratul976 at hotmail.com
> <mailto:zeratul976 at hotmail.com>> wrote:
> > It would be useful if clangd highlighted context-sensitive keywords,
> such as "override" and "final" (and, in C++20, likely "import" and
> "module"). Because of their context-sensitivity, clients can't highlight
> those as easily as hard keywords.
> >
> > ________________________________________
> > From: clangd-dev <clangd-dev-bounces at lists.llvm.org<mailto:
> clangd-dev-bounces at lists.llvm.org>> on behalf of Ilya Biryukov via
> clangd-dev <clangd-dev at lists.llvm.org<mailto:clangd-dev at lists.llvm.org>>
> > Sent: October 25, 2019 9:55 AM
> > To: Haojian Wu
> > Cc: via clangd-dev
> > Subject: Re: [clangd-dev] Syntax highlighting of keywords
> >
> > Highlighting typedefs to primitive types in a special manner seems ok, I
> was referring specifically to highlightings of keywords.
> >
> > So unless anyone objects, I'll send a patch to remove highlightings of
> keywords. Typedefs to simple types will still be highlighted with
> 'primitive' highlighting type.
> >
> > On Fri, Oct 25, 2019 at 10:21 AM Haojian Wu <hokein at google.com<mailto:
> hokein at google.com><mailto:hokein at google.com<mailto:hokein at google.com>>>
> wrote:
> > I agree editors handle keyword highlightings very well, but they don't
> have sufficient knowledge to highlight typealias/typedefs for primitive
> types.
> >
> > // We want to highlight A, B as primitive types.
> > using A = int;
> > typedef int B;
> >
> >
> > On Fri, Oct 25, 2019 at 9:59 AM Ilya Biryukov <ibiryukov at google.com
> <mailto:ibiryukov at google.com><mailto:ibiryukov at google.com<mailto:
> ibiryukov at google.com>>> wrote:
> > Hi clangd-dev,
> >
> > I was wondering whether there's any value in the highlighting for
> "primitive" types being added on keywords like 'void', 'int', etc?
> >
> > - Any editor handles those with default syntax highlight.
> > - It's trivial and does not require actual semantic knowledge.
> >
> > With that in mind, I wonder whether we should drop this completely and
> just let the editors handle the keywords?
> > What do people think?
> >
> > --
> > Regards,
> > Ilya Biryukov
> >
> >
> > --
> > Regards,
> > Ilya Biryukov
> >
> >
> > --
> > Regards,
> > Ilya Biryukov
> > _______________________________________________
> > clangd-dev mailing list
> > clangd-dev at lists.llvm.org
> > https://lists.llvm.org/cgi-bin/mailman/listinfo/clangd-dev
>
>

-- 
Regards,
Ilya Biryukov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/clangd-dev/attachments/20191025/8c033a75/attachment-0001.html>


More information about the clangd-dev mailing list