zokugun / vscode-explicit-folding

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

How to only apply rules to files with custom extension? #109

Open cesaryuan opened 7 months ago

cesaryuan commented 7 months ago

Describe the issue

I have a file whose ext is .jscasm. How do I only apply rules to it?

I tried the following settings, but it doesn't work.

    "explicitFolding.rules": {
        ".jscasm": [
            {
                "beginRegex": "Bytecode age: ",
                "endRegex": "Constant pool \\(size = ",
                "foldLastLine": false
            },
            {
                "beginRegex": "; #region",
                "endRegex": "; #endregion",
                "foldLastLine": true
            }
        ]
    }

Settings

    "explicitFolding.rules": {
        ".jscasm": [
            {
                "beginRegex": "Bytecode age: ",
                "endRegex": "Constant pool \\(size = ",
                "foldLastLine": false
            },
            {
                "beginRegex": "; #region",
                "endRegex": "; #endregion",
                "foldLastLine": true
            }
        ]
    }
daiyam commented 7 months ago

".jscasm" won't work. It should be the language identifier.

cesaryuan commented 7 months ago

".jscasm" won't work. It should be the language identifier.

Thanks for your reply! But there is no corresponding language identifier. This is a very niche file extension.

daiyam commented 7 months ago

If it's still a Javascript file, you could use explicitFolding.perFiles

cesaryuan commented 7 months ago

If it's still a Javascript file

It is a plaintext file. So I tried the following settings, but it not work.

    "[plaintext]": {
        "editor.foldingStrategy": "auto",
        "editor.defaultFoldingRangeProvider": "zokugun.explicit-folding",
        "explicitFolding.perFiles": {
            "*.jscasm": [
                {
                    "beginRegex": "Bytecode age: ",
                    "endRegex": "Constant pool \\(size = ",
                    "foldLastLine": false
                },
                {
                    "beginRegex": "; #region",
                    "endRegex": "; #endregion",
                    "foldLastLine": true
                }
            ]
        }
    }

By the way, explicitFolding.rules works but is for all plaintext.

.jscasm file example:

Parameter count 1
Register count 1
Frame size 8
Bytecode age: 0
    0 S> 000000CD0011448A @    0 : 80 00 00 00       CreateClosure [0], [0], #0
         000000CD0011448E @    4 : c4                Star0
219746 S> 000000CD0011448F @    5 : a9                Return
Constant pool (size = 1)
000000CD00114491: [FixedArray] in OldSpace
goyalyashpal commented 2 months ago

".jscasm" won't work. It should be the language identifier.

the extension i am concerned with is language independent, think of it as similar to a templating language. so, sometimes i am writing in python, or md or rst in it... so, how would the explicitFolding.perFiles help in that case?

I tried the following settings, but [the ability to select only the particular file extensions] not work. - @cesaryuan at https://github.com/zokugun/vscode-explicit-folding/issues/109#issuecomment-1832993628

@ daiyam any input on that?