Visual Studio Code 高亮扩展项目教程

Visual Studio Code 高亮扩展项目教程

【免费下载链接】vscode-highlight Advanced text highlighter based on regexes. Useful for todos, annotations etc. 【免费下载链接】vscode-highlight 项目地址: https://gitcode.com/gh_mirrors/vs/vscode-highlight

1. 项目的目录结构及介绍

vscode-highlight/
├── media/
│   └── icon.png
├── src/
│   ├── commands/
│   │   └── force_decorate.ts
│   ├── test/
│   │   └── extension.test.ts
│   ├── types/
│   │   └── index.d.ts
│   ├── utils/
│   │   └── index.ts
│   ├── extension.ts
│   └── package.json
├── .gitignore
├── .vscodeignore
├── CHANGELOG.md
├── LICENSE
├── README.md
└── package.json
  • media/: 包含项目的图标文件。
  • src/: 项目的源代码目录。
    • commands/: 包含命令相关的文件,如强制装饰命令。
    • test/: 包含测试文件。
    • types/: 包含类型定义文件。
    • utils/: 包含工具函数文件。
    • extension.ts: 扩展的主入口文件。
    • package.json: 项目的配置文件,包含依赖和脚本等。
  • .gitignore: Git忽略文件。
  • .vscodeignore: VSCode忽略文件。
  • CHANGELOG.md: 变更日志。
  • LICENSE: 许可证文件。
  • README.md: 项目说明文档。
  • package.json: 项目的配置文件,包含依赖和脚本等。

2. 项目的启动文件介绍

项目的启动文件是 src/extension.ts。这个文件是扩展的主入口点,负责初始化扩展和注册命令。以下是 extension.ts 的主要内容:

import * as vscode from 'vscode';
import { forceDecorate } from './commands/force_decorate';

export function activate(context: vscode.ExtensionContext) {
    context.subscriptions.push(
        vscode.commands.registerCommand('highlight.forceDecorate', forceDecorate)
    );
}

export function deactivate() {}
  • activate: 当扩展被激活时调用,注册命令 highlight.forceDecorate
  • deactivate: 当扩展被停用时调用。

3. 项目的配置文件介绍

项目的配置文件是 package.json。这个文件包含了扩展的所有配置信息,包括依赖、命令、设置等。以下是 package.json 的部分内容:

{
    "name": "vscode-highlight",
    "displayName": "Highlight",
    "description": "Advanced text highlighter based on regexes",
    "version": "1.0.0",
    "publisher": "fabiospampinato",
    "engines": {
        "vscode": "^1.50.0"
    },
    "categories": [
        "Other"
    ],
    "activationEvents": [
        "onCommand:highlight.forceDecorate"
    ],
    "main": "./src/extension.ts",
    "contributes": {
        "commands": [
            {
                "command": "highlight.forceDecorate",
                "title": "Highlight: Force Decorate"
            }
        ],
        "configuration": {
            "type": "object",
            "title": "Highlight Configuration",
            "properties": {
                "highlight.regexes": {
                    "type": "array",
                    "default": [],
                    "description": "List of regexes to highlight"
                },
                "highlight.regexFlags": {
                    "type": "string",
                    "default": "gi",
                    "description": "Flags for the regexes"
                },
                "highlight.minDelay": {
                    "type": "number",
                    "default": 50,
                    "description": "Minimum delay before highlighting"
                },
                "highlight.maxMatches": {
                    "type": "number",
                    "default": 250,
                    "description": "Maximum number of matches to decorate"
                }
            }
        }
    }
}
  • name: 扩展的名称。
  • displayName: 扩展的显示名称。
  • description: 扩展的描述。
  • version: 扩展的版本。
  • publisher: 扩展的发布者。

【免费下载链接】vscode-highlight Advanced text highlighter based on regexes. Useful for todos, annotations etc. 【免费下载链接】vscode-highlight 项目地址: https://gitcode.com/gh_mirrors/vs/vscode-highlight

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值