From 2cc1bd9b07506d4c707c28f56216da0b8d6e7899 Mon Sep 17 00:00:00 2001 From: dual Date: Thu, 9 Apr 2020 15:34:24 +0800 Subject: [PATCH] version 1.0.0 --- README.md | 67 ++------------------------------------------------- extension.js | 46 +++++++++++++++-------------------- icon.png | Bin 0 -> 1787 bytes package.json | 24 +++++++----------- 4 files changed, 31 insertions(+), 106 deletions(-) create mode 100644 icon.png diff --git a/README.md b/README.md index f1328f4..8f32f68 100644 --- a/README.md +++ b/README.md @@ -1,65 +1,2 @@ -# zsh README - -This is the README for your extension "zsh". After writing up a brief description, we recommend including the following sections. - -## Features - -Describe specific features of your extension including screenshots of your extension in action. Image paths are relative to this README file. - -For example if there is an image subfolder under your extension project workspace: - -\!\[feature X\]\(images/feature-x.png\) - -> Tip: Many popular extensions utilize animations. This is an excellent way to show off your extension! We recommend short, focused animations that are easy to follow. - -## Requirements - -If you have any requirements or dependencies, add a section describing those and how to install and configure them. - -## Extension Settings - -Include if your extension adds any VS Code settings through the `contributes.configuration` extension point. - -For example: - -This extension contributes the following settings: - -* `myExtension.enable`: enable/disable this extension -* `myExtension.thing`: set to `blah` to do something - -## Known Issues - -Calling out known issues can help limit users opening duplicate issues against your extension. - -## Release Notes - -Users appreciate release notes as you update your extension. - -### 1.0.0 - -Initial release of ... - -### 1.0.1 - -Fixed issue #. - -### 1.1.0 - -Added features X, Y, and Z. - ------------------------------------------------------------------------------------------------------------ - -## Working with Markdown - -**Note:** You can author your README using Visual Studio Code. Here are some useful editor keyboard shortcuts: - -* Split the editor (`Cmd+\` on macOS or `Ctrl+\` on Windows and Linux) -* Toggle preview (`Shift+CMD+V` on macOS or `Shift+Ctrl+V` on Windows and Linux) -* Press `Ctrl+Space` (Windows, Linux) or `Cmd+Space` (macOS) to see a list of Markdown snippets - -### For more information - -* [Visual Studio Code's Markdown Support](http://code.visualstudio.com/docs/languages/markdown) -* [Markdown Syntax Reference](https://help.github.com/articles/markdown-basics/) - -**Enjoy!** +# zsh completion script +detect first line of file, if match `#compdef` or `#autoload`, mark it as `shellscript` \ No newline at end of file diff --git a/extension.js b/extension.js index 6d831fa..026005b 100644 --- a/extension.js +++ b/extension.js @@ -1,35 +1,29 @@ -// The module 'vscode' contains the VS Code extensibility API -// Import the module and reference it with the alias vscode in your code below const vscode = require('vscode'); -// this method is called when your extension is activated -// your extension is activated the very first time the command is executed - -/** - * @param {vscode.ExtensionContext} context - */ -function activate(context) { - - // Use the console to output diagnostic information (console.log) and errors (console.error) - // This line of code will only be executed once when your extension is activated - console.log('Congratulations, your extension "zsh" is now active!'); - - // 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 - let disposable = vscode.commands.registerCommand('zsh.helloWorld', function () { - // The code you place here will be executed every time your command is executed - - // Display a message box to the user - vscode.window.showInformationMessage('Hello World from zsh!'); - }); +function detect() { + if (vscode.window.activeTextEditor.document.languageId != 'plaintext') { + return + } + const line = vscode.window.activeTextEditor.document.lineAt(0).text + if (line && line.match(/^#compdef|^#autoload/)) { + vscode.languages + .setTextDocumentLanguage(vscode.window.activeTextEditor.document, "shellscript") + .catch(err => { + console.error(err) + }) + } +} - context.subscriptions.push(disposable); +function activate() { + vscode.window.onDidChangeVisibleTextEditors(() => { + detect() + }) + detect() } + exports.activate = activate; -// this method is called when your extension is deactivated -function deactivate() {} +function deactivate() { } module.exports = { activate, diff --git a/icon.png b/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..f1f35266add8ed062561878973636322681a5292 GIT binary patch literal 1787 zcmai#dpHvc8^EVA&d!E>=ST=0Ja*_ZtcGNpM%xr3)S1h|oJqEvBpjD5Ld51$aye#F zge`ZKODXKe@sf`h1KdwW|X64~Ji1W|Lvq7XmTh{a-EW}Z89 zQjcLzcy(}Ng#D3IU831{VzJnxyTZyEjkCrg5Qqm49-vSt9*<{XVX?lxZewFJJUncN zw{x6s!`tDPmX_-3>e}1eX|0d^{QRP$qnS)5kw^><4$jKTa&~rJ{PykH@&adm%v;!e zslV=G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