This patch introduces the following configurations to .clangd:
SemanticTokens: DisabledKinds: [ ... ] DisabledModifiers: [ ... ]
Based on the config, clangd would stop producing a certain type of semantic tokens from the source file.
Differential D148489
[clangd] Implement configs to stop clangd produce a certain semantic tokens daiyousei-qz on Apr 16 2023, 8:18 PM. Authored by
Details This patch introduces the following configurations to .clangd: SemanticTokens: DisabledKinds: [ ... ] DisabledModifiers: [ ... ] Based on the config, clangd would stop producing a certain type of semantic tokens from the source file.
Diff Detail
Event TimelineComment Actions Please hold off from reviewing this. I have been figuring out how arc tools work and the unittest of the current version is broken. Comment Actions Fix an issue where the previous change is lost.
Comment Actions Add some comments to the config headers. Resubmit to retrigger build test since I cannot reproduce the failure. Comment Actions before you dive any deeper into the patch, could you give some reasoning about why this is needed/useful? Comment Actions The discussion is at https://github.com/clangd/clangd/discussions/1598. The original motivation is that in the latest clangd, we start to assign semantic token "operator" to all operators in the source code. Since the semantic tokens take priority over the textmate rules in vscode, now we cannot theme different operators differently anymore. For example, we cannot color "new" in blue while have "+" in white. To address the issue, this patch adds configurable filter to the semantic token to filter out unwanted kinds and modifiers. We should have the following benefits with such filter in place.
Comment Actions Thanks for the patch! I think this is a nice and general solution, which rather than solving just a specific problem (e.g. highlighting of new as an operator vs. a keyword), gives users a broader ability to fine-tune clangd's highlightings to suit their needs. Could I kindly ask you to make a PR that updates https://github.com/llvm/clangd-www/blob/main/config.md to cover the new config keys, as well?
Comment Actions Sorry, I'm a little occupied lately and don't have time to fix the test failure. I'll try to fix that in this week.
Comment Actions Thanks! Let me know if you need me to commit.
Comment Actions Sorry for the inactivity. I have replace the parameter with const ref. By the way, I also removed the existing IncludeInactiveRegionTokens flag and uses this filter instead. Please help review the change. Thanks! Comment Actions I went ahead and merged this. When you get a chance, could you update https://github.com/llvm/clangd-www/pull/85 as well so we can merge that too? Comment Actions Thank you! Since the documentation shouldn't be available until LLVM 17, I'm slowly working on it. Let me update the PR in this weekend :) |