extension.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright (C) 2019 Google Inc.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. var path = require('path');
  17. var vscode = require('vscode');
  18. var langClient = require('vscode-languageclient');
  19. var LanguageClient = langClient.LanguageClient;
  20. // this method is called when your extension is activated
  21. // your extension is activated the very first time the command is executed
  22. function activate(context) {
  23. let serverModule = path.join(context.extensionPath, 'langsvr');
  24. let debugOptions = {};
  25. // If the extension is launched in debug mode then the debug server options are used
  26. // Otherwise the run options are used
  27. let serverOptions = {
  28. run: { command: serverModule, transport: langClient.stdio },
  29. debug: { command: serverModule, transport: langClient.stdio, options: debugOptions }
  30. }
  31. // Options to control the language client
  32. let clientOptions = {
  33. documentSelector: ['spirv'],
  34. synchronize: {
  35. // Synchronize the setting section 'spirv' to the server
  36. configurationSection: 'spirv',
  37. // Notify the server about file changes to .spvasm files contained in the workspace
  38. fileEvents: vscode.workspace.createFileSystemWatcher('**/*.spvasm')
  39. }
  40. }
  41. // Create the language client and start the client.
  42. let disposable = new LanguageClient('spirv', serverOptions, clientOptions).start();
  43. // Push the disposable to the context's subscriptions so that the
  44. // client can be deactivated on extension deactivation
  45. context.subscriptions.push(disposable);
  46. // Set the language configuration here instead of a language configuration
  47. // file to work around https://github.com/microsoft/vscode/issues/42649.
  48. vscode.languages.setLanguageConfiguration("spirv", {
  49. comments: { "lineComment": ";" },
  50. wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\#\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
  51. });
  52. }
  53. exports.activate = activate;
  54. // this method is called when your extension is deactivated
  55. function deactivate() {
  56. }
  57. exports.deactivate = deactivate;