PS C:\Users\mikoto> cd ~/project/
PS C:\Users\mikoto\project> yo code
_-----_ ╭──────────────────────────╮
|| │ Welcome to the Visual │
|--(o)--| │ Studio Code Extension │
`---------´ │ generator! │
(_´U`_ ) ╰──────────────────────────╯
/___A___\ /
|~|__'.___.'__
´ `|° ´ Y`? What type of extension do you want to create? New Extension (TypeScript)
? What's the name of your extension? snippet? What's the identifier of your extension? snippet
? What's the description of your extension? Language Support for Snippet.? Initialize a git repository? Yes? Which package manager to use? npm create snippet\.vscode\extensions.json create snippet\.vscode\launch.json create snippet\.vscode\settings.json create snippet\.vscode\tasks.json create snippet\src\test\runTest.ts create snippet\src\test\suite\extension.test.ts create snippet\src\test\suite\index.ts create snippet\.vscodeignore create snippet\.gitignore create snippet\README.md create snippet\CHANGELOG.md create snippet\vsc-extension-quickstart.md create snippet\tsconfig.json create snippet\src\extension.ts create snippet\package.json create snippet\tslint.jsonI'm all done. Running npm install for you to install the required dependencies. If this fails, try running the command yourself.
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN snippet@0.0.1 No repository field.
npm WARN snippet@0.0.1 No license field.
added 143 packages from 573 contributors and audited 325 packages in 3.974s
found 0 vulnerabilities
Your extension snippet has been created!
To start editing with Visual Studio Code, use the following commands:
cd snippet
code .
Open vsc-extension-quickstart.md inside the new extension for further instructions
on how to modify, test and publish your extension.
For more information, also visit http://code.visualstudio.com and follow us @code.
PS C:\Users\mikoto\project># プロジェクト管理の都合でディレクトリの名前変更PS C:\Users\mikoto\project> mv .\snippet .\vscode-snippet
LSP に必要なパッケージを追加
vscode-languageclient を追加する。
cd vscode-snippet
npm install --save vscode-languageclient
プロジェクトのメタデータを編集
package.json を編集。
{"name":"snippet","displayName":"snippet","description":"Language Support for Snippet.","version":"0.0.1","publisher":"mikoto2000","engines":{"vscode":"^1.37.0"},"categories":["Other"],"activationEvents":["*"],"main":"./out/extension.js","contributes":{},"scripts":{"vscode:prepublish":"npm run compile","compile":"tsc -p ./","watch":"tsc -watch -p ./","pretest":"npm run compile","test":"node ./out/test/runTest.js"},"devDependencies":{"@types/glob":"^7.1.1","@types/mocha":"^5.2.6","@types/node":"^10.12.21","@types/vscode":"^1.37.0","glob":"^7.1.4","mocha":"^6.1.4","typescript":"^3.3.1","tslint":"^5.12.1","vscode-test":"^1.0.2"},"dependencies":{"vscode-languageclient":"^5.2.1"}}
発行者(publisher) を追加
スニペットサーバーは常時起動させておきたいので、 activationEvents を * に修正
コマンドは必要ないので contributes/commands を削除
LSP サーバー起動コードの実装
import * as vscode from 'vscode';
import { Executable, LanguageClient, LanguageClientOptions, StreamInfo } from 'vscode-languageclient';
export function activate(context: vscode.ExtensionContext) {
const serverOptions: Executable = {
// TODO: requirements に「java にパスを通しておくこと」を追加したうえで java に修正
command: 'C:/Java/openjdk-12.0.1/bin/java',
args: ['--add-modules=ALL-SYSTEM',
'--add-opens',
'java.base/java.util=ALL-UNNAMED',
'--add-opens', 'java.base/java.lang=ALL-UNNAMED',
'-Declipse.application=org.eclipse.jdt.ls.core.id1',
'-Dosgi.bundles.defaultStartLevel=4',
'-Declipse.product=org.eclipse.jdt.ls.core.product',
'-Dlog.level=ALL',
'-noverify',
'-Dfile.encoding=UTF-8',
'-Xmx1G',
// TODO: jar を同梱する
'-jar',
'C:/Users/mikoto/project/lsp4snippet/build/libs/lsp4snippet-1.0.0.jar',
// TODO: config 化
'--snippet', 'C:/Users/mikoto/project/dotvim/.vim/snippets/java.yaml',
'--snippet', 'C:/Users/mikoto/project/dotvim/.vim/snippets/markdown.yaml']
};
const clientOptions: LanguageClientOptions = {
documentSelector: [{ scheme: 'file', language: '*' }]
};
const disposable = new LanguageClient('lsp4snippet', 'lsp4snippet', serverOptions, clientOptions).start();
context.subscriptions.push(disposable);
}
// this method is called when your extension is deactivated
export function deactivate() {}
apiVersion: v2publisher: mikoto2000name: java12version: latesttype: VS Code extensiondisplayName: Language Support for Java 12title: Language Support for Java(TM) by mikoto2000description: Java Linting, Intellisense, formatting, refactoring, Maven/Gradle support
and more...
icon: https://www.eclipse.org/che/images/logo-eclipseche.svgrepository: https://github.com/redhat-developer/vscode-javacategory: LanguagefirstPublicationDate:"2019-08-02"spec:containers:-image: mikoto2000/remote-plugin-runner-java12:latestname: vscode-javamemoryLimit:"1500Mi"extensions:-https://github.com/microsoft/vscode-java-debug/releases/download/0.19.0/vscode-java-debug-0.19.0.vsix-https://download.jboss.org/jbosstools/static/jdt.ls/stable/java-0.46.0-1549.vsix