diff --git a/.vscodeignore b/.vscodeignore index 0966bfc..ef039e7 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -5,4 +5,5 @@ test/** src/** **/*.map .gitignore -tsconfig.json \ No newline at end of file +tsconfig.json +clang-format.xcf \ No newline at end of file diff --git a/README.md b/README.md index e698444..0012302 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,9 @@ ## Release history +### v 0.10.0 +* enabling of individual languages with ```clang-format.language.javascript.enable```, etc. + ### v 0.9.0 * add protobuf support (work with https://marketplace.visualstudio.com/items?itemName=peterj.proto) * add javascript/typescript support diff --git a/package.json b/package.json index c802772..38630f8 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "clang-format", "displayName": "Clang-Format", "description": "Use Clang-Format in Visual Studio Code", - "version": "0.9.0", + "version": "0.10.0", "publisher": "xaver", "engines": { "vscode": "^1.0.0" @@ -11,7 +11,20 @@ "sax": "^1.1.5" }, "categories": [ - "Other" + "Other", + "Languages" + ], + "keywords": [ + "Tools", + "C++", + "C", + "JavaScript", + "Protobuf", + "Java", + "Objective-C", + "Clang", + "LLVM", + "Clang-Format" ], "main": "./out/src/extension", "activationEvents": [ @@ -48,75 +61,110 @@ "default": "LLVM", "description": "clang-format fallback style.(-fallback-style=value, value can be none, LLVM, Google, Chromium, Mozilla, WebKit)" }, + "clang-format.language.cpp.enable": { + "type": "boolean", + "default": true, + "description": "enable formatting for C++" + }, "clang-format.language.cpp.style": { "type": "string", "default": "", - "description": "clang-format fallback style for c++, left empty to use clang-format.style" + "description": "clang-format fallback style for C++, left empty to use clang-format.style" }, "clang-format.language.cpp.fallbackStyle": { "type": "string", "default": "", - "description": "clang-format fallback style for c++, left empty to use clang-format.fallbackStyle" + "description": "clang-format fallback style for C++, left empty to use clang-format.fallbackStyle" + }, + "clang-format.language.c.enable": { + "type": "boolean", + "default": true, + "description": "enable formatting for C" }, "clang-format.language.c.style": { "type": "string", "default": "", - "description": "clang-format fallback style for c, left empty to use clang-format.style" + "description": "clang-format fallback style for C, left empty to use clang-format.style" }, "clang-format.language.c.fallbackStyle": { "type": "string", "default": "", - "description": "clang-format fallback style for c, left empty to use clang-format.fallbackStyle" + "description": "clang-format fallback style for C, left empty to use clang-format.fallbackStyle" + }, + "clang-format.language.objective-c.enable": { + "type": "boolean", + "default": true, + "description": "enable formatting for Objective-C" }, "clang-format.language.objective-c.style": { "type": "string", "default": "", - "description": "clang-format fallback style for objective-c, left empty to use clang-format.style" + "description": "clang-format fallback style for Objective-C, left empty to use clang-format.style" }, "clang-format.language.objective-c.fallbackStyle": { "type": "string", "default": "", - "description": "clang-format fallback style for objective-c, left empty to use clang-format.fallbackStyle" + "description": "clang-format fallback style for Objective-C, left empty to use clang-format.fallbackStyle" + }, + "clang-format.language.java.enable": { + "type": "boolean", + "default": true, + "description": "enable formatting for Java" }, "clang-format.language.java.style": { "type": "string", "default": "", - "description": "clang-format fallback style for java, left empty to use clang-format.style" + "description": "clang-format fallback style for Java, left empty to use clang-format.style" }, "clang-format.language.java.fallbackStyle": { "type": "string", "default": "", - "description": "clang-format fallback style for java, left empty to use clang-format.fallbackStyle" + "description": "clang-format fallback style for Java, left empty to use clang-format.fallbackStyle" + }, + "clang-format.language.javascript.enable": { + "type": "boolean", + "default": true, + "description": "enable formatting for JavaScript" }, "clang-format.language.javascript.style": { "type": "string", "default": "", - "description": "clang-format fallback style for javascript, left empty to use clang-format.style" + "description": "clang-format fallback style for JavaScript, left empty to use clang-format.style" }, "clang-format.language.javascript.fallbackStyle": { "type": "string", "default": "", - "description": "clang-format fallback style for javascript, left empty to use clang-format.fallbackStyle" + "description": "clang-format fallback style for JavaScript, left empty to use clang-format.fallbackStyle" + }, + "clang-format.language.typescript.enable": { + "type": "boolean", + "default": true, + "description": "enable formatting for TypeScript" }, "clang-format.language.typescript.style": { "type": "string", "default": "", - "description": "clang-format fallback style for typescript, left empty to use clang-format.style" + "description": "clang-format fallback style for TypeScript, left empty to use clang-format.style" }, "clang-format.language.typescript.fallbackStyle": { "type": "string", "default": "", - "description": "clang-format fallback style for typescript, left empty to use clang-format.fallbackStyle" + "description": "clang-format fallback style for TypeScript, left empty to use clang-format.fallbackStyle" + }, + "clang-format.language.proto.enable": { + "type": "boolean", + "default": true, + "description": "enable formatting for Protobuf" }, "clang-format.language.proto.style": { "type": "string", "default": "", - "description": "clang-format fallback style for proto, left empty to use clang-format.style" + "description": "clang-format fallback style for Protobuf, left empty to use clang-format.style" }, "clang-format.language.proto.fallbackStyle": { "type": "string", "default": "", - "description": "clang-format fallback style for proto, left empty to use clang-format.fallbackStyle" + "description": "clang-format fallback style for Protobuf, left empty to use clang-format.fallbackStyle" } } } diff --git a/src/clangMode.ts b/src/clangMode.ts index 6179b77..3da26fe 100644 --- a/src/clangMode.ts +++ b/src/clangMode.ts @@ -2,5 +2,11 @@ import vscode = require('vscode'); -const LANGUAGES: string[] = ['cpp', 'c', 'objective-c', 'java', 'javascript', 'typescript', 'proto']; -export const MODES: vscode.DocumentFilter[] = LANGUAGES.map(language => ({ language, scheme: 'file' })); +let languages: string[] = []; +for (var l of ["cpp", "c", "objective-c", "java", "javascript", "typescript", "proto"]) { + if (vscode.workspace.getConfiguration("clang-format").get("language." + l + ".enable")) { + languages.push(l); + } +} + +export const MODES: vscode.DocumentFilter[] = languages.map(language => ({ language, scheme: 'file' }));