Skip to content

Instantly share code, notes, and snippets.

@mihai-vlc
Created September 17, 2025 08:58
Show Gist options
  • Select an option

  • Save mihai-vlc/ad150466b5e7da32dcb6150d8e6b9ee3 to your computer and use it in GitHub Desktop.

Select an option

Save mihai-vlc/ad150466b5e7da32dcb6150d8e6b9ee3 to your computer and use it in GitHub Desktop.
VSCode simple project specific extention. Place the files in the .vscode/extensions/<extention name> folder.
// A launch configuration that launches the extension inside a new window
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"configurations": [
{
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
]
}
]
}
import globals from "globals";
export default [{
files: ["**/*.js"],
languageOptions: {
globals: {
...globals.commonjs,
...globals.node,
},
ecmaVersion: 2022,
sourceType: "module",
},
rules: {
"no-const-assign": "warn",
"no-this-before-super": "warn",
"no-undef": "warn",
"no-unreachable": "warn",
"no-unused-vars": "warn",
"constructor-super": "warn",
"valid-typeof": "warn",
},
}];
const vscode = require('vscode');
/**
* @param {vscode.ExtensionContext} context
*/
function activate(context) {
const disposable = vscode.commands.registerCommand('example-autocomplete.helloWorld', function () {
vscode.window.showInformationMessage('Hello world');
});
context.subscriptions.push(disposable);
const provider = vscode.languages.registerCompletionItemProvider(
{ scheme: "file", language: "javascript" },
{
provideCompletionItems(document, position) {
let currentLine = document.lineAt(position.line).text;
let firstWord = currentLine.trim().split(' ')[0].toUpperCase();
return [
new vscode.CompletionItem("myCustomSnippet", vscode.CompletionItemKind.Snippet),
new vscode.CompletionItem("myFunction", vscode.CompletionItemKind.Function),
new vscode.CompletionItem(currentLine, vscode.CompletionItemKind.Enum),
];
},
},
"'", "~" // trigger characters
);
context.subscriptions.push(provider);
}
function deactivate() { }
module.exports = {
activate,
deactivate
};
{
"compilerOptions": {
"module": "Node16",
"target": "ES2022",
"checkJs": true, /* Typecheck .js files. */
"lib": [
"ES2022"
]
},
"exclude": [
"node_modules"
]
}
{
"name": "example-autocomplete",
"displayName": "example-autocomplete",
"description": "",
"version": "0.0.1",
"engines": {
"vscode": "^1.104.0"
},
"categories": [
"Other"
],
"activationEvents": [],
"main": "./extension.js",
"contributes": {
"commands": [{
"command": "example-autocomplete.helloWorld",
"title": "Hello World"
}]
},
"scripts": {
"lint": "eslint .",
"pretest": "npm run lint"
},
"devDependencies": {
"@types/vscode": "^1.104.0",
"@types/mocha": "^10.0.10",
"@types/node": "22.x",
"eslint": "^9.34.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment