Skip to content

Commit

Permalink
🚧 #1 CompletionItemProvider
Browse files Browse the repository at this point in the history
CompletionItemProvider

:wrench:

丰富设置

Create LICENSE

Update package.json
  • Loading branch information
kalifun committed Feb 4, 2024
1 parent 923a347 commit b84f72e
Show file tree
Hide file tree
Showing 9 changed files with 124 additions and 11 deletions.
8 changes: 5 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Change Log

All notable changes to the "demo" extension will be documented in this file.
All notable changes to the "vscode-proto3-tools" extension will be documented in this file.

Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.

## [Unreleased]
## [0.1.0.1018_beta]

- snippets
- syntaxes

- Initial release
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 kalifun

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.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
# vscode proto3 tools

<p align="center">
<img src="./images/logo.png">
</p>

> proto3 language service
I'm sure you're no stranger to api documentation, but when there's no common place to store it, it can lead to a variety of formats and fragmentation. This causes us to collect the api documentation is so painful. So I wonder why we don't define some important parameters in advance when we write `proto` and stuff the valid data through `comment` form. When we define the api to complete the api documentation, that's great!

## feature

- [x] Snippets
- [x] Syntaxes
- [ ] Gen Api Doc

![](images/syntaxes.png)

Expand Down
23 changes: 23 additions & 0 deletions docs/readme_zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# vscode proto3 tools

<p align="center">
<img src="../images/logo.png">
</p>

> proto3 language service
我想接口文档大家肯定不陌生,可是当没有一个公共存储的地方,则会导致我们的接口文档有着各种各样的格式,且是零散的。这导致我们收集接口文档是那么的痛苦。所以我在想我们在编写`proto`的时候为啥不提前将一些重要参数定义好,通过`注释`这种形式将有效数据塞入。当我们在定义接口时就完成了接口文档的编写,那不是妙哉!


## 代办项
- [x] Snippets

- [x] Syntaxes

- [ ] Gen Api Doc

# 鸣谢

[vscode-proto3](https://github.com/zxh0/vscode-proto3)  

[language_grammars](https://macromates.com/manual/en/language_grammars#naming_conventions)
Binary file added images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 37 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
{
"name": "vscode-proto3-tools",
"displayName": "proto3 tools",
"version": "0.0.1",
"description": "Write comments in advance",
"displayName": "Proto3 Tools",
"version": "0.1.1",
"description": "proto3 language service",
"engines": {
"vscode": "^1.70.0"
"vscode": "^1.71.0"
},
"categories": [
"Programming Languages"
"Programming Languages",
"Snippets",
"Linters",
"Formatters"
],
"license": "MIT",
"icon": "images/logo.png",
"repository": {
"type": "git",
"url": "https://github.com/kalifun/vscode-proto3-tools"
},
"author": "kalifun",
"author": {
"name": "kalifun"
},
"publisher": "kalifun",
"contributors": [
{
"name": "kalifun",
Expand Down Expand Up @@ -58,7 +66,28 @@
"language": "proto3",
"path": "./snippets/snippets.json"
}
]
],
"configuration": {
"title": "Proto3 Tools Config",
"properties": {
"proto3.outputpath": {
"type": "string",
"default": "doc",
"description": "Path to the generated document(Based on current path)"
},
"proto3.disable_rules": {
"type": "array",
"enum": [
"core::0140::lower-snake",
"core::0131::request-name-field"
],
"default": [
"core::0123::resource-annotation"
],
"description": "Set the check rule to be cancelled(https://linter.aip.dev/)"
}
}
}
},
"scripts": {
"vscode:prepublish": "yarn run compile",
Expand All @@ -81,4 +110,4 @@
"typescript": "^4.7.4",
"@vscode/test-electron": "^2.1.5"
}
}
}
19 changes: 19 additions & 0 deletions src/api/completion/completion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

import vscode = require('vscode');

class Proto3CompletionItemProvider implements vscode.CompletionItemProvider {
provideCompletionItems(
document: vscode.TextDocument,
position: vscode.Position,
token: vscode.CancellationToken,
context: vscode.CompletionContext
): vscode.ProviderResult<vscode.CompletionItem[] | vscode.CompletionList<vscode.CompletionItem>> {
throw new Error('Method not implemented.');
}
resolveCompletionItem?(item: vscode.CompletionItem, token: vscode.CancellationToken): vscode.ProviderResult<vscode.CompletionItem> {
throw new Error('Method not implemented.');
}
}


export { Proto3CompletionItemProvider };
6 changes: 6 additions & 0 deletions src/conf/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import vscode = require('vscode');

export const Proto3: vscode.DocumentSelector = {
scheme: "file",
language: "proto3"
};
5 changes: 5 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
import * as vscode from 'vscode';
import { Proto3CompletionItemProvider } from './api/completion/completion';
import { Proto3 } from './conf/config';



Expand All @@ -12,6 +14,9 @@ export function activate(context: vscode.ExtensionContext) {
// This line of code will only be executed once when your extension is activated
console.log('Congratulations, your extension "demo" is now active!');

// 注册一个自动补全
context.subscriptions.push(vscode.languages.registerCompletionItemProvider(Proto3, new Proto3CompletionItemProvider(), '.', '\"'));

// The command has been defined in the package.json file
// Now provide the implementation of the command with registerCommand
// The commandId parameter must match the command field in package.json
Expand Down

0 comments on commit b84f72e

Please sign in to comment.