Subject: bug#65418: 29.1; Eglot: support clangd inactiveRegions extension

From: Filippo Argiolas <[email-masked]>
Date: Tue, 22 Aug 2023 13:02:47 +0200

On Tue, Aug 22, 2023 at 10:56 AM João Távora <[email-masked]> wrote:
> I'm more worried that this isn't even out yet. Afaik Filippo you compiled a Clangd 17 with a patch, right? I have done that in the past, but it's not very practical every time, so either we wait for this to stabilize or you have to tell me where to grab the patched Clangd and llvm toolchain somewhere.

It's much easier than that! They release unstable git snapshots in
github. You can find them at https://github.com/clangd/clangd/releases
Clangd is released as a static binary you can just copy in your path
(e.g. in ~/.local/bin). From what I can tell you don't need to upgrade
the whole toolchain, the binary runs fine on its own. Latest one for
linux is at https://github.com/clangd/clangd/releases/download/snapshot_20230820/clangd-linux-snapshot_20230820.zip

It would be great if you could test it and see if you can get server
notifications for inactiveRegions.

I think the interface should be already stable, reading the review the
only thing that is probably going to change at some point is dropping
the support to generate semantic tokens for inactive regions as
comments, which they are keeping for backwards compatibility.

>> Also this IMHO would solve quite an important problem with C
>> development, not sure if it's worth waiting while we could solve it
>> now with the extension and move to the standard protocol if and once
>> the LSP spec will support this.
>
> I'm also personally interested in this feature. But how likely is it that this makes it into the LSP standard, in your opinion?

Honestly I don't know :-) Only information I could find is this vscode
issue https://github.com/microsoft/vscode/issues/123352 where they
seemed to agree it's not something that belongs in semantic tokens but
then the discussion stalled.

> FWIW, other languages have similar features. Common Lisp has read-time conditionals for example, which are similar if not identical in function (and obviously not as rotten as C macros).
>
> By the way, if you didn't know this silly trick, if you're in a #ifdef web, a half-decent way to know whether a given point is active is to try and find a definition inside it or type some syntactically correct code. If Eglot jumps to target or highlights variable names, the region is active, else it probably isn't.

Thanks! that's actually a great way to see if the highlighted code is
active! Still greying it out or dimming the colors would be great to
see at a glance if a region is dead, especially for big regions. It's
also one of those few features that Emacs still misses when compared
to vscode.

Filippo