Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>ProGuard LanguageNew to Visual Studio Code? Get it now.
ProGuard Language

ProGuard Language

FeribHellscream

|
636 installs
| (0) | Free
Syntax highlighting for ProGuard configuration files.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Ferib

translate this .vim rule to a VSCode plugin

" Vim syntax file
" Language:	ProGuard configuration
" Maintainer:	David Reiss <dreiss@fb.com>
" Version:	2

" Quit when a syntax file was already loaded
if exists("b:current_syntax")
  finish
endif

syn region proguardComment start=/#/ end=/$/
syn match proguardDirective "-keep[a-z,]*\>"
syn match proguardDirective "-\(optimizations\|dontwarn\|assumenosideeffects\)\>"
syn match proguardDirective "-\(dontshrink\|dontoptimize\|dontobfuscate\)\>"
syn match proguardWildcard "\*"
syn match proguardMembers "<\(fields\|methods\)>"

syn keyword javaType boolean char byte short int long float double
syn keyword javaType void
syn keyword javaStorageClass static transient final
syn keyword javaScopeDecl public protected private abstract
syn keyword javaClassDecl class enum
syn keyword javaClassDecl extends implements interface
syn match javaClassDecl "@interface\>"
syn match javaAnnotation "@\([_$a-zA-Z][_$a-zA-Z0-9]*\.\)*[_$a-zA-Z][_$a-zA-Z0-9]*\>"

hi def link proguardComment Comment
hi def link proguardDirective Statement
hi def link proguardWildcard Special
hi def link proguardMembers Identifier
hi def link javaStorageClass StorageClass
hi def link javaScopeDecl javaStorageClass
hi def link javaClassDecl javaStorageClass
hi def link javaAnnotation PreProc

let b:current_syntax = "proguard"

ChatGPT

To translate the given Vim syntax rules for ProGuard configuration to a Visual Studio Code (VSCode) extension, you'll need to create a language definition in a VSCode extension's package.json file and define the corresponding syntax highlighting rules in a .tmLanguage.json file. Below is a rough translation of the provided Vim syntax rules into a VSCode plugin:

Create a package.json file for your extension:

{
  "name": "proguard-language",
  "displayName": "ProGuard Language",
  "description": "Syntax highlighting for ProGuard configuration files.",
  "version": "1.0.0",
  "engines": {
    "vscode": "^1.60.0"
  },
  "categories": ["Languages"],
  "contributes": {
    "languages": [
      {
        "id": "proguard",
        "aliases": ["ProGuard", "proguard"],
        "extensions": [".pro", ".proguard"],
        "configuration": "./language-configuration.json"
      }
    ],
    "grammars": [
      {
        "language": "proguard",
        "scopeName": "source.proguard",
        "path": "./syntaxes/proguard.tmLanguage.json"
      }
    ]
  }
}

Create a syntaxes/proguard.tmLanguage.json file for your syntax highlighting rules:

{
  "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
  "name": "ProGuard",
  "scopeName": "source.proguard",
  "fileTypes": ["pro", "proguard"],
  "patterns": [
    {
      "begin": "#",
      "end": "$",
      "name": "comment"
    },
    {
      "match": "-keep[a-z,]*\\>",
      "name": "keyword"
    },
    {
      "match": "-(optimizations|dontwarn|assumenosideeffects)\\>",
      "name": "keyword"
    },
    {
      "match": "-(dontshrink|dontoptimize|dontobfuscate)\\>",
      "name": "keyword"
    },
    {
      "match": "\\*",
      "name": "keyword"
    },
    {
      "match": "<(fields|methods)>",
      "name": "keyword"
    },
    {
      "match": "\\b(boolean|char|byte|short|int|long|float|double|void)\\b",
      "name": "type"
    },
    {
      "match": "\\b(static|transient|final)\\b",
      "name": "storage"
    },
    {
      "match": "\\b(public|protected|private|abstract)\\b",
      "name": "modifier"
    },
    {
      "match": "\\b(class|enum|extends|implements|interface)\\b",
      "name": "class"
    },
    {
      "match": "@([_$a-zA-Z][_$a-zA-Z0-9]*\\.)*[_$a-zA-Z][_$a-zA-Z0-9]*\\>",
      "name": "annotation"
    }
  ]
}

Create a language-configuration.json file to specify word patterns:

{
  "comments": {
    "lineComment": "#"
  },
  "brackets": [["{", "}"], ["[", "]"], ["(", ")"]],
  "autoClosingPairs": [
    { "open": "{", "close": "}" },
    { "open": "[", "close": "]" },
    { "open": "(", "close": ")" }
  ],
  "surroundingPairs": [
    { "open": "{", "close": "}" },
    { "open": "[", "close": "]" },
    { "open": "(", "close": ")" },
    { "open": "'", "close": "'" },
    { "open": "\"", "close": "\"" }
  ]
}

In your VSCode extension, you can use these files to provide syntax highlighting for ProGuard configuration files. Ensure that your extension is correctly structured and contains the necessary files and configurations. After creating the extension, you can install it in your VSCode instance, and it should provide syntax highlighting for ProGuard configuration files with the specified rules. Make sure to adapt this code as needed for your specific extension setup and requirements.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft