Skip to content

Commit 3c913ef

Browse files
authored
Merge pull request #2 from scanapi/initial_version
Initial Version
2 parents 87cba32 + d618da5 commit 3c913ef

File tree

7 files changed

+960
-0
lines changed

7 files changed

+960
-0
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
![](https://github.com/scanapi/design/raw/master/images/github-hero-dark.png)
2+
3+
# Scanapi - IntelliSense
4+
5+
An extension that provides code completion for the [ScanApi](https://github.com/scanapi/scanapi) specification.<bR>
6+
Check Scanapi's [documentation](https://github.com/scanapi/scanapi) for futher information about the specification.
7+
8+
## Installing
9+
10+
Preferably, install it from the VSCode Marketplace, but if for some reason you can't, you can download the latest stable version [here](https://github.com/scanapi/vscode-extension/releases).<br>
11+
Install it using:<br>
12+
`code --install-extension file_name_here.vsix`
13+
14+
## Snippets
15+
16+
| Name | Result |
17+
| -------: | ------------------------------------------------ |
18+
| `cvar` | `Produces a custom var / ENV var interpolation.` |
19+
| `pycode` | `Produces a python code interpolation.` |
20+
21+
### `cvar`
22+
23+
```
24+
${custom_var} or ${ENV_VAR}
25+
```
26+
27+
### `pycode`
28+
29+
```python
30+
${{assert 1 + 1 = 2}}
31+
```

images/scanapi.png

3.92 KB
Loading

package.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"name": "scanapi-intellisense",
3+
"displayName": "Scanapi - IntelliSense",
4+
"description": "Provides code completion for the Scanapi YAML specification.",
5+
"icon": "images/scanapi.png",
6+
"version": "0.0.1",
7+
"publisher": "scanapi",
8+
"author": {
9+
"name": "abreumatheus"
10+
},
11+
"license": "SEE LICENSE IN LICENSE",
12+
"repository": {
13+
"type": "git",
14+
"url": "https://github.com/scanapi/vscode-extension"
15+
},
16+
"bugs": {
17+
"url": "https://github.com/scanapi/vscode-extension/issues"
18+
},
19+
"engines": {
20+
"vscode": "^1.47.0"
21+
},
22+
"categories": [
23+
"Other"
24+
],
25+
"activationEvents": [
26+
"onLanguage:yaml"
27+
],
28+
"main": "./out/extension.js",
29+
"scripts": {
30+
"vscode:prepublish": "npm run compile",
31+
"compile": "tsc -p ./",
32+
"lint": "eslint . --ext .ts,.tsx",
33+
"watch": "tsc -watch -p ./"
34+
},
35+
"devDependencies": {
36+
"@types/node": "^12.12.0",
37+
"@types/vscode": "^1.32.0",
38+
"@typescript-eslint/eslint-plugin": "^3.0.2",
39+
"@typescript-eslint/parser": "^3.0.2",
40+
"eslint": "^7.1.0",
41+
"typescript": "^3.9.4"
42+
}
43+
}

src/extension.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import * as vscode from 'vscode';
2+
3+
export function activate(context: vscode.ExtensionContext) {
4+
const provider = vscode.languages.registerCompletionItemProvider('yaml', {
5+
provideCompletionItems(
6+
document: vscode.TextDocument,
7+
position: vscode.Position,
8+
token: vscode.CancellationToken,
9+
context: vscode.CompletionContext,
10+
) {
11+
const customVarSnippet = new vscode.CompletionItem('cvar');
12+
customVarSnippet.insertText = new vscode.SnippetString('${${1}}');
13+
customVarSnippet.documentation = new vscode.MarkdownString(
14+
'Snippet for custom vars or ENV vars:\n`${custom_var}`\n`${ENV_VAR}`',
15+
);
16+
17+
const pythonCodeSnippet = new vscode.CompletionItem('pycode');
18+
pythonCodeSnippet.insertText = new vscode.SnippetString('${{${1}}}');
19+
customVarSnippet.documentation = new vscode.MarkdownString(
20+
'Snippet for python code, used for the tests section:\n`${{assert 1 + 1 == 2}}`',
21+
);
22+
23+
const mainFileSnippets: Array<vscode.CompletionItem> = [
24+
customVarSnippet,
25+
pythonCodeSnippet,
26+
];
27+
28+
const mainFileCompletion: Array<vscode.CompletionItem> = [
29+
new vscode.CompletionItem('endpoints:\n\t- name:'),
30+
new vscode.CompletionItem('requests:\n\t- name:'),
31+
new vscode.CompletionItem('tests:\n\t- name:'),
32+
new vscode.CompletionItem('headers:\n\t- '),
33+
new vscode.CompletionItem('vars:\n\t'),
34+
new vscode.CompletionItem('name: '),
35+
new vscode.CompletionItem('path: '),
36+
new vscode.CompletionItem('method: '),
37+
new vscode.CompletionItem('assert: '),
38+
new vscode.CompletionItem('params: '),
39+
];
40+
41+
const configFileCompletion: Array<vscode.CompletionItem> = [
42+
new vscode.CompletionItem('report:\n\t'),
43+
new vscode.CompletionItem('hide-request\n\t'),
44+
new vscode.CompletionItem('project_name: '),
45+
new vscode.CompletionItem('spec_path: '),
46+
new vscode.CompletionItem('output_path: '),
47+
new vscode.CompletionItem('template: '),
48+
];
49+
50+
return [
51+
...mainFileCompletion,
52+
...mainFileSnippets,
53+
...configFileCompletion,
54+
];
55+
},
56+
});
57+
58+
context.subscriptions.push(provider);
59+
}

tsconfig.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"compilerOptions": {
3+
"module": "commonjs",
4+
"target": "es2019",
5+
"lib": ["ES2019"],
6+
"outDir": "out",
7+
"sourceMap": true,
8+
"strict": true,
9+
"rootDir": "src"
10+
},
11+
"exclude": [
12+
"node_modules",
13+
".vscode-test"
14+
]
15+
}

0 commit comments

Comments
 (0)