zokugun / vscode-explicit-folding

Customize your Folding for Visual Studio Code
MIT License
99 stars 14 forks source link

Language identifier ? #6

Closed just-Addict closed 5 years ago

just-Addict commented 5 years ago

Hi,

After being totally unhappy with the default VCode folding for HLSL and hunting for info how to change this, I found your extension. But... From the extension page it appears it needs a language identifier to have the folding only affect a specific language.

I tried both "HLSL" and "hlsl" but it doesn't seem to trigger on files using the .fx name format. Any idea which would be the correct identifier to have that section only apply to hlsl files?

daiyam commented 5 years ago

Hi,

You will need another extension to define the language. In your case, the extension slevesque.shader seems to be your only possibility. The language identifier should be hlsl.

just-Addict commented 5 years ago

as it so happens, that's the exact same one I already have installed.

but sadly, using hlsl as identifier didn't make the folding icons show up where I wanted them... (in fact, it didn't seem to have any effect at all)

JIC, this is the section as I added it to settings.json (by far not complete but this what I tried to start with)

    "folding": {
        "hlsl": [
            {
                "begin": "\\{",
                "end": "\\}"
            },
            {
                "begin": "\\/*",
                "end": "\\*/"
            },
            {
                "begin": "#if",
                "end": "#endif"
            },
            {
                "begin": "#ifdef",
                "end": "#endif"
            },
            {
                "begin": "#ifndef",
                "end": "#endif"
            }
        ]
    }

Oddly enough, having this in my setting file and the extension enabled seems to completely disable the folding to work at all... that is, until I disable the extension. after disabling the clunky default folding starts working again...

PS. This is the last section in the settings file, and yes, I placed a comma after the preceding line when entering this and a closing } after this section

daiyam commented 5 years ago

At first, after testing, I thought that something was wrong with the extension :anguished: But after rereading your settings, I've figured out that * and / were not correctly escaped.

So here the correct settings: :relaxed:

"folding": {
    "hlsl": [
        {
            "begin": "\\{",
            "end": "\\}"
        },
        {
            "begin": "\\/\\*",
            "end": "\\*\\/"
        },
        {
            "begin": "#if",
            "end": "#endif"
        },
        {
            "begin": "#ifdef",
            "end": "#endif"
        },
        {
            "begin": "#ifndef",
            "end": "#endif"
        }
    ]
}
daiyam commented 5 years ago

I've updated the extension to support non-regex begin and regex beginRegex properties.

So your settings can be:

"folding": {
    "hlsl": [
        {
            "begin": "{",
            "end": "}"
        },
        {
            "begin": "/*",
            "end": "*/"
        },
        {
            "begin": "#if",
            "end": "#endif"
        },
        {
            "begin": "#ifdef",
            "end": "#endif"
        },
        {
            "begin": "#ifndef",
            "end": "#endif"
        }
    ]
}
just-Addict commented 5 years ago

PERFECT! Thanks! So that was it, I had seen some escaping done on the initial extension details page but apparently overlooked this. Weird though that it made the default folding also stop working...