-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
875 additions
and
861 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,56 @@ | ||
import * as vscode from 'vscode'; | ||
import * as vscode from "vscode"; | ||
|
||
/** | ||
* CodelensProvider | ||
*/ | ||
export class CodelensProvider implements vscode.CodeLensProvider { | ||
private codeLenses: vscode.CodeLens[] = []; | ||
private regex: RegExp; | ||
private _onDidChangeCodeLenses: vscode.EventEmitter<void> = new vscode.EventEmitter<void>(); | ||
public readonly onDidChangeCodeLenses: vscode.Event<void> = this._onDidChangeCodeLenses.event; | ||
|
||
private codeLenses: vscode.CodeLens[] = []; | ||
private regex: RegExp; | ||
private _onDidChangeCodeLenses: vscode.EventEmitter<void> = new vscode.EventEmitter<void>(); | ||
public readonly onDidChangeCodeLenses: vscode.Event<void> = this._onDidChangeCodeLenses.event; | ||
constructor() { | ||
this.regex = /(.+)/g; | ||
|
||
constructor() { | ||
this.regex = /(.+)/g; | ||
vscode.workspace.onDidChangeConfiguration(_ => { | ||
this._onDidChangeCodeLenses.fire(); | ||
}); | ||
} | ||
|
||
vscode.workspace.onDidChangeConfiguration((_) => { | ||
this._onDidChangeCodeLenses.fire(); | ||
}); | ||
} | ||
public provideCodeLenses( | ||
document: vscode.TextDocument, | ||
token: vscode.CancellationToken | ||
): vscode.CodeLens[] | Thenable<vscode.CodeLens[]> { | ||
if (vscode.workspace.getConfiguration("codelens-sample").get("enableCodeLens", true)) { | ||
this.codeLenses = []; | ||
const regex = new RegExp(this.regex); | ||
const text = document.getText(); | ||
let matches; | ||
// biome-ignore lint/suspicious/noAssignInExpressions: <explanation> | ||
while ((matches = regex.exec(text)) !== null) { | ||
const line = document.lineAt(document.positionAt(matches.index).line); | ||
const indexOf = line.text.indexOf(matches[0]); | ||
const position = new vscode.Position(line.lineNumber, indexOf); | ||
const range = document.getWordRangeAtPosition(position, new RegExp(this.regex)); | ||
if (range) { | ||
this.codeLenses.push(new vscode.CodeLens(range)); | ||
} | ||
} | ||
return this.codeLenses; | ||
} | ||
return []; | ||
} | ||
|
||
public provideCodeLenses(document: vscode.TextDocument, token: vscode.CancellationToken): vscode.CodeLens[] | Thenable<vscode.CodeLens[]> { | ||
|
||
if (vscode.workspace.getConfiguration("codelens-sample").get("enableCodeLens", true)) { | ||
this.codeLenses = []; | ||
const regex = new RegExp(this.regex); | ||
const text = document.getText(); | ||
let matches; | ||
// biome-ignore lint/suspicious/noAssignInExpressions: <explanation> | ||
while ((matches = regex.exec(text)) !== null) { | ||
const line = document.lineAt(document.positionAt(matches.index).line); | ||
const indexOf = line.text.indexOf(matches[0]); | ||
const position = new vscode.Position(line.lineNumber, indexOf); | ||
const range = document.getWordRangeAtPosition(position, new RegExp(this.regex)); | ||
if (range) { | ||
this.codeLenses.push(new vscode.CodeLens(range)); | ||
} | ||
} | ||
return this.codeLenses; | ||
} | ||
return []; | ||
} | ||
|
||
public resolveCodeLens(codeLens: vscode.CodeLens, token: vscode.CancellationToken) { | ||
if (vscode.workspace.getConfiguration("codelens-sample").get("enableCodeLens", true)) { | ||
codeLens.command = { | ||
title: "Codelens provided by Sillot", | ||
tooltip: "看什么看", | ||
command: "codelens-sample.codelensAction", | ||
arguments: ["Argument 1", false] | ||
}; | ||
return codeLens; | ||
} | ||
return null; | ||
} | ||
public resolveCodeLens(codeLens: vscode.CodeLens, token: vscode.CancellationToken) { | ||
if (vscode.workspace.getConfiguration("codelens-sample").get("enableCodeLens", true)) { | ||
codeLens.command = { | ||
title: "Codelens provided by Sillot", | ||
tooltip: "看什么看", | ||
command: "codelens-sample.codelensAction", | ||
arguments: ["Argument 1", false], | ||
}; | ||
return codeLens; | ||
} | ||
return null; | ||
} | ||
} |
58 changes: 27 additions & 31 deletions
58
_vscode_plugin/Sillot/src/_dosc.language-configuration.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,29 @@ | ||
{ | ||
"comments": { | ||
"lineComment": "//", | ||
"blockComment": ["/*", "*/"] | ||
}, | ||
"brackets": [ | ||
["{", "}"], | ||
["[", "]"], | ||
["(", ")"] | ||
], | ||
"folding": { | ||
"markers": { | ||
"start": "^\\s*//\\s*#?region\\b", | ||
"end": "^\\s*//\\s*#?endregion\\b" | ||
} | ||
}, | ||
"autoClosingPairs": [ | ||
{ "open": "{", "close": "}" }, | ||
{ "open": "[", "close": "]" }, | ||
{ "open": "(", "close": ")" }, | ||
{ "open": "'", "close": "'", "notIn": ["string", "comment"] }, | ||
{ "open": "\"", "close": "\"", "notIn": ["string"] }, | ||
{ "open": "`", "close": "`", "notIn": ["string", "comment"] }, | ||
{ "open": "/**", "close": " */", "notIn": ["string"] } | ||
], | ||
"surroundingPairs": [ | ||
{"open": "{", "close": "}"}, | ||
{"open": "[", "close": "]"}, | ||
{"open": "(", "close": ")"}, | ||
{"open": "'", "close": "'"}, | ||
{"open": "\"", "close": "\""} | ||
] | ||
"comments": { | ||
"lineComment": "//", | ||
"blockComment": ["/*", "*/"] | ||
}, | ||
"brackets": [["{", "}"], ["[", "]"], ["(", ")"]], | ||
"folding": { | ||
"markers": { | ||
"start": "^\\s*//\\s*#?region\\b", | ||
"end": "^\\s*//\\s*#?endregion\\b" | ||
} | ||
}, | ||
"autoClosingPairs": [ | ||
{ "open": "{", "close": "}" }, | ||
{ "open": "[", "close": "]" }, | ||
{ "open": "(", "close": ")" }, | ||
{ "open": "'", "close": "'", "notIn": ["string", "comment"] }, | ||
{ "open": "\"", "close": "\"", "notIn": ["string"] }, | ||
{ "open": "`", "close": "`", "notIn": ["string", "comment"] }, | ||
{ "open": "/**", "close": " */", "notIn": ["string"] } | ||
], | ||
"surroundingPairs": [ | ||
{ "open": "{", "close": "}" }, | ||
{ "open": "[", "close": "]" }, | ||
{ "open": "(", "close": ")" }, | ||
{ "open": "'", "close": "'" }, | ||
{ "open": "\"", "close": "\"" } | ||
] | ||
} |
58 changes: 27 additions & 31 deletions
58
_vscode_plugin/Sillot/src/_sy.language-configuration.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,29 @@ | ||
{ | ||
"comments": { | ||
"lineComment": "//", | ||
"blockComment": ["/*", "*/"] | ||
}, | ||
"brackets": [ | ||
["{", "}"], | ||
["[", "]"], | ||
["(", ")"] | ||
], | ||
"folding": { | ||
"markers": { | ||
"start": "^\\s*//\\s*#?region\\b", | ||
"end": "^\\s*//\\s*#?endregion\\b" | ||
} | ||
}, | ||
"autoClosingPairs": [ | ||
{ "open": "{", "close": "}" }, | ||
{ "open": "[", "close": "]" }, | ||
{ "open": "(", "close": ")" }, | ||
{ "open": "'", "close": "'", "notIn": ["string", "comment"] }, | ||
{ "open": "\"", "close": "\"", "notIn": ["string"] }, | ||
{ "open": "`", "close": "`", "notIn": ["string", "comment"] }, | ||
{ "open": "/**", "close": " */", "notIn": ["string"] } | ||
], | ||
"surroundingPairs": [ | ||
{"open": "{", "close": "}"}, | ||
{"open": "[", "close": "]"}, | ||
{"open": "(", "close": ")"}, | ||
{"open": "'", "close": "'"}, | ||
{"open": "\"", "close": "\""} | ||
] | ||
"comments": { | ||
"lineComment": "//", | ||
"blockComment": ["/*", "*/"] | ||
}, | ||
"brackets": [["{", "}"], ["[", "]"], ["(", ")"]], | ||
"folding": { | ||
"markers": { | ||
"start": "^\\s*//\\s*#?region\\b", | ||
"end": "^\\s*//\\s*#?endregion\\b" | ||
} | ||
}, | ||
"autoClosingPairs": [ | ||
{ "open": "{", "close": "}" }, | ||
{ "open": "[", "close": "]" }, | ||
{ "open": "(", "close": ")" }, | ||
{ "open": "'", "close": "'", "notIn": ["string", "comment"] }, | ||
{ "open": "\"", "close": "\"", "notIn": ["string"] }, | ||
{ "open": "`", "close": "`", "notIn": ["string", "comment"] }, | ||
{ "open": "/**", "close": " */", "notIn": ["string"] } | ||
], | ||
"surroundingPairs": [ | ||
{ "open": "{", "close": "}" }, | ||
{ "open": "[", "close": "]" }, | ||
{ "open": "(", "close": ")" }, | ||
{ "open": "'", "close": "'" }, | ||
{ "open": "\"", "close": "\"" } | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.