Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
cesaryuan opened this issue Nov 29, 2023 · 5 comments
Open

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

cesaryuan opened this issue Nov 29, 2023 · 5 comments

Comments

@cesaryuan
Copy link

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
Copy link
Member

daiyam commented Nov 29, 2023

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

@cesaryuan
Copy link
Author

".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
Copy link
Member

daiyam commented Nov 29, 2023

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

@cesaryuan
Copy link
Author

cesaryuan commented Nov 30, 2023

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
Copy link

".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 #109 (comment)

@ daiyam any input on that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants