diff --git a/vscode-extensions/vscode-concourse/lib/Main.ts b/vscode-extensions/vscode-concourse/lib/Main.ts index 599d90bf1..3153a93a0 100644 --- a/vscode-extensions/vscode-concourse/lib/Main.ts +++ b/vscode-extensions/vscode-concourse/lib/Main.ts @@ -13,6 +13,8 @@ import {TextDocument, OutputChannel} from 'vscode'; var log_output : OutputChannel = null; +const PIPELINE_LANGUAGE_ID = "concourse-pipeline-yaml"; + function log(msg : string) { if (log_output) { log_output.append(msg +"\n"); @@ -41,13 +43,12 @@ export function activate(context: VSCode.ExtensionContext) { // events pass on to Language Server only for documents for which function passed via textDocumentFilter property return true // TODO: Remove cast ones https://github.com/Microsoft/vscode-languageserver-node/issues/9 is resolved - documentSelector: [ - {language: 'yaml', pattern: '**/*pipeline*.yml'} - ], + documentSelector: [ PIPELINE_LANGUAGE_ID ], synchronize: { // TODO: Remove textDocumentFilter property once https://github.com/Microsoft/vscode-languageserver-node/issues/9 is resolved textDocumentFilter: function(textDocument : TextDocument) : boolean { - let result : boolean = /^(.*)pipeline(.*)\.yml$/i.test(textDocument.fileName); + let result : boolean = PIPELINE_LANGUAGE_ID===textDocument.languageId; + // old way: let result : boolean = /^(.*)pipeline(.*)\.yml$/i.test(textDocument.fileName); return result; } } diff --git a/vscode-extensions/vscode-concourse/package.json b/vscode-extensions/vscode-concourse/package.json index d656c7675..557d63f7c 100644 --- a/vscode-extensions/vscode-concourse/package.json +++ b/vscode-extensions/vscode-concourse/package.json @@ -24,8 +24,27 @@ "pipeline.yml" ], "activationEvents": [ - "onLanguage:yaml" + "onLanguage:concourse-pipeline-yaml" ], + "contributes": { + "languages": [ + { + "id": "concourse-pipeline-yaml", + "aliases": [ + "concourse-pipeline" + ], + "filenamePatterns": [ + "*pipeline*.yml" + ], + "configuration": "./yaml-support/language-configuration.json" + } + ], + "grammars": [{ + "language": "concourse-pipeline-yaml", + "scopeName": "source.yaml", + "path": "./yaml-support/yaml.tmLanguage" + }] + }, "main": "./out/lib/Main", "scripts": { "prepublish": "tsc -p .", diff --git a/vscode-extensions/vscode-concourse/scripts/preinstall.sh b/vscode-extensions/vscode-concourse/scripts/preinstall.sh index ae0cb376f..2e796a0fe 100755 --- a/vscode-extensions/vscode-concourse/scripts/preinstall.sh +++ b/vscode-extensions/vscode-concourse/scripts/preinstall.sh @@ -1,5 +1,11 @@ #!/bin/bash set -e +# Download yaml TextMate grammar +curl https://raw.githubusercontent.com/textmate/yaml.tmbundle/master/Syntaxes/YAML.tmLanguage > yaml-support/yaml.tmLanguage + +# Preinstall commons-vscode package (cd ../commons-vscode ; npm install) npm install ../commons-vscode + +# Use maven to build fat jar of the language server ../mvnw -U -f ../pom.xml -pl vscode-concourse -am clean install diff --git a/vscode-extensions/vscode-concourse/yaml-support/.gitignore b/vscode-extensions/vscode-concourse/yaml-support/.gitignore new file mode 100644 index 000000000..ddc0ef4f6 --- /dev/null +++ b/vscode-extensions/vscode-concourse/yaml-support/.gitignore @@ -0,0 +1 @@ +yaml.tmLanguage \ No newline at end of file diff --git a/vscode-extensions/vscode-concourse/yaml-support/OSSREADME.json b/vscode-extensions/vscode-concourse/yaml-support/OSSREADME.json new file mode 100644 index 000000000..bcdae2a4c --- /dev/null +++ b/vscode-extensions/vscode-concourse/yaml-support/OSSREADME.json @@ -0,0 +1,28 @@ +// ATTENTION - THIS DIRECTORY CONTAINS THIRD PARTY OPEN SOURCE MATERIALS: + +[{ + "name": "textmate/yaml.tmbundle", + "version": "0.0.0", + "license": "TextMate Bundle License", + "repositoryURL": "https://github.com/textmate/yaml.tmbundle", + "licenseDetail": [ + "Copyright (c) 2015 FichteFoll ", + "", + "Permission is hereby granted, free of charge, to any person obtaining a copy", + "of this software and associated documentation files (the \"Software\"), to deal", + "in the Software without restriction, including without limitation the rights", + "to use, copy, modify, merge, publish, distribute, sublicense, and/or sell", + "copies of the Software, and to permit persons to whom the Software is", + "furnished to do so, subject to the following conditions:", + "", + "The above copyright notice and this permission notice shall be included in all", + "copies or substantial portions of the Software.", + "", + "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR", + "IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,", + "FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE", + "AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER", + "LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,", + "OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE." + ] +}] diff --git a/vscode-extensions/vscode-concourse/yaml-support/language-configuration.json b/vscode-extensions/vscode-concourse/yaml-support/language-configuration.json new file mode 100644 index 000000000..cab4f6602 --- /dev/null +++ b/vscode-extensions/vscode-concourse/yaml-support/language-configuration.json @@ -0,0 +1,24 @@ +{ + "comments": { + "lineComment": "#" + }, + "brackets": [ + ["{", "}"], + ["[", "]"], + ["(", ")"] + ], + "autoClosingPairs": [ + ["{", "}"], + ["[", "]"], + ["(", ")"], + ["\"", "\""], + ["'", "'"] + ], + "surroundingPairs": [ + ["{", "}"], + ["[", "]"], + ["(", ")"], + ["\"", "\""], + ["'", "'"] + ] +} \ No newline at end of file