hackwaly / vscode-ocaml

An extension for VS Code which provides support for the OCaml language.
MIT License
170 stars 26 forks source link

customize bucklescript projects #88

Open bobzhang opened 7 years ago

bobzhang commented 7 years ago

If we find it is a bucklescript project (see if it has bsconfig.json in toplevel), We disable ocaml.lintOnSave and use problem matcher as bewl, it is better than merlin for error reporting since it is project aware and more solid(And I solved column-1 based issue in bucklescript compiler). Currently I need type Tasks: Build to start a task, is there a way to automatically start when open such project? thanks!

{
    "version": "0.1.0",
    "command": "bsb",
    "options": {
        "cwd": "${workspaceRoot}"
    },
    "isShellCommand": true,
    "args": [
        "-w"
    ],
    "showOutput": "always",
    "isWatching": true,
    "problemMatcher": {
        "fileLocation": "absolute",
        "owner": "ocaml",
        "watching": {
            "activeOnStart": true,
            "beginsPattern": ">>>> Start compiling",
            "endsPattern": ">>>> Finish compiling"
        },
        "pattern": [
            {
                "regexp": "^File \"(.*)\", line (\\d+)(?:, characters (\\d+)-(\\d+))?:$",
                "file": 1,
                "line": 2,
                "column": 3,
                "endColumn": 4
            },
            {
                "regexp": "^(?:(?:Parse\\s+)?(Warning|[Ee]rror)(?:\\s+\\d+)?:)?\\s+(.*)$",
                "severity": 1,
                "message": 2,
                "loop": true
            }
        ]
    }
}
hackwaly commented 7 years ago

I can't find that vscode provides any api for opening project event. but there is https://code.visualstudio.com/docs/extensionAPI/activation-events#_activationeventsworkspacecontains. So it's possible to achieve it by create another extension that execute "Build Task" command when it activate.

You can disable ocaml.lintOnSave by using workspace settings.

bobzhang commented 7 years ago

@hackwaly Currently, whenever user create a new project, it still need create a tasks.json and copy it into that project such configuration, could we make it by default?

hackwaly commented 7 years ago

Maybe we can submit some project generators for yeoman? So we can easily generate bucklescript project and other kind of projects.