microsoft / vscode-textmate

A library that helps tokenize text using Text Mate grammars.
MIT License
583 stars 115 forks source link

Unable to exclude elements with "textmate" scope selectors in custom themes #192

Open madeso opened 2 years ago

madeso commented 2 years ago

Issue Type: Bug

Hello! I haven't found great documentation for the tokenColors.scope property. The only syntax documentation about scope selectors I've been able to find is the textmate "specification", so it's possible this is just a documentation/user issue and not a bug:

I'd like to highlight function names entity.name.function and exclude function calls. Most languages I tested (c, c++, js, ts) doesn't seem to differ between theese (python does) but seems to add a additional scope called meta.function-call to distinguish.

Sample code (from doom) that I'm testing highlight with:

static void derror(char* msg)
{
    fprintf(stderr, "\nwadread error: %s\n", msg);
    exit(-1);
}

And just like the textmate documentation (13.3 Excluding Elements) says I try to exclude function calls from functions but the whole exclude pattern seems to be picked up as a identifier.

{
    "tokenColors": [
        {
            "name": "Global definitions",
            "scope":
            [
                "entity.name.function - meta.function-call"
                , "entity.name.scope-resolution.function.definition"
                , "entity.global"
            ],
            "settings": {
                "foreground": "#6c71c4"
            }
        }
    ]
}

image

So I guess this is a bug, if not:

VS Code version: Code 1.68.1 (30d9c6cd9483b2cc586687151bcbcd635f373630, 2022-06-14T12:48:58.283Z) OS version: Windows_NT x64 10.0.19044 Restricted Mode: No

System Info |Item|Value| |---|---| |CPUs|11th Gen Intel(R) Core(TM) i9-11950H @ 2.60GHz (16 x 2611)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled| |Load (avg)|undefined| |Memory (System)|31.73GB (10.38GB free)| |Process Argv|C:\\WorkingFolder\\github\\vscode\\solarized-alabaster --crash-reporter-id 83e591d6-3e69-4157-88ff-9e09c50b5771| |Screen Reader|no| |VM|0%|
Extensions (13) Extension|Author (truncated)|Version ---|---|--- vscode-graphviz|joa|0.0.6 vscode-webidl|keq|0.0.1 vscode-docker|ms-|1.22.0 python|ms-|2022.8.1 vscode-pylance|ms-|2022.6.30 jupyter|ms-|2022.5.1001601848 jupyter-keymap|ms-|1.0.0 jupyter-renderers|ms-|1.0.8 cmake-tools|ms-|1.11.26 cpptools|ms-|1.10.7 hexeditor|ms-|1.9.7 cmake|twx|0.0.17 vscode-todo-highlight|way|1.0.5
A/B Experiments ``` vsliv368:30146709 vsreu685:30147344 python383:30185418 vspor879:30202332 vspor708:30202333 vspor363:30204092 vslsvsres303:30308271 pythonvspyl392:30443607 vserr242cf:30382550 pythontb:30283811 vsjup518:30340749 pythonvspyt551cf:30345471 pythonptprofiler:30281270 vshan820:30294714 vstes263cf:30335440 vscoreces:30445986 pythondataviewer:30285071 vscod805cf:30301675 binariesv615:30325510 bridge0708:30335490 bridge0723:30353136 vsaa593cf:30376535 vsc1dst:30438360 pythonvs932:30410667 wslgetstarted:30449410 vscscmwlcmt:30465135 cppdebug:30492333 vsclangdf:30486550 ```
aeschli commented 1 year ago

vscode-textmate (the library we use to tokenize and theme) does not support the minus operator in theming rules.