# Dockerfile Language Server
![Node.js Builds](https://github.com/rcjsuen/dockerfile-language-server-nodejs/workflows/Node.js%20Builds/badge.svg?branch=master) [![Coverage Status](https://coveralls.io/repos/github/rcjsuen/dockerfile-language-server-nodejs/badge.svg?branch=master)](https://coveralls.io/github/rcjsuen/dockerfile-language-server-nodejs?branch=master) [![Build Dependencies](https://david-dm.org/rcjsuen/dockerfile-language-server-nodejs.svg)](https://david-dm.org/rcjsuen/dockerfile-language-server-nodejs) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
This is a language server for Dockerfiles powered by Node.js written in TypeScript.
To [install and run](#installation-instructions) this language server, you will need to have either [Node.js](https://nodejs.org/en/download/) or [Docker](https://www.docker.com/get-docker) installed on your computer.
**Supported features:**
- code actions
- code completion
- definition
- diagnostics
- document highlight
- document links
- document symbols
- folding ranges
- formatting
- hovers
- prepare rename
- rename
- semantic highlighting
- signature help
**Projects that use this language server:**
- [vscode-docker](https://github.com/Microsoft/vscode-docker)
- [atom-ide-docker](https://github.com/josa42/atom-ide-docker)
- [Sourcegraph](https://sourcegraph.com/)
- [Theia](https://theia-ide.org/)
- [lsp-mode](https://emacs-lsp.github.io/lsp-mode/)
This repository only contains the code necessary for launching a Dockerfile language server that conforms to the language server protocol.
The actual code for parsing a Dockerfile and offering editor features such as code completion or hovers is not contained within this repository.
The code for analyzing and processing a Dockerfile is contained in the following three libraries:
- [dockerfile-ast](https://github.com/rcjsuen/dockerfile-ast) - parses a Dockerfile
- [dockerfile-language-service](https://github.com/rcjsuen/dockerfile-language-service) - provides API functions for handling the different requests defined by the language server protocol
- [dockerfile-utils](https://github.com/rcjsuen/dockerfile-utils) - validates and formats a Dockerfile, can be run from the CLI
All of the language server protocol requests that help create a rich editing experience for the user is forwarded to the `dockerfile-language-service` library.
You can test its features [right in the browser](https://rcjsuen.github.io/dockerfile-language-service/).
This online editor is a very good representation of what is possible when this language server is connected to an editor that supports the language server protocol.
## Development Instructions
If you wish to build and compile this language server, you must first install [Node.js](https://nodejs.org/en/download/) if you have not already done so.
After you have installed Node.js and cloned the repository with Git, you may now proceed to build and compile the language server with the following commands:
```
npm install
npm run build
npm test
```
If you are planning to change the code, use `npm run watch` to get the
TypeScript files transpiled on-the-fly as they are modified.
Once the code has finished compiling, you can connect a language server
client to the server via Node IPC, stdio, or sockets.
## Installation Instructions
To install this language server onto your computer, please install the
[dockerfile-language-server-nodejs npm module](https://www.npmjs.com/package/dockerfile-language-server-nodejs).
The `-g` flag will install the npm module globally onto your computer.
```
npm install -g dockerfile-language-server-nodejs
```
After the installation has completed, you can start the language
server with the `docker-langserver` binary. You should specify
the desired method of communicating with the language server via one
of the three arguments shown below.
```
docker-langserver --node-ipc
docker-langserver --stdio
docker-langserver --socket=<port>
```
### Docker Image
The `docker-langserver` binary is also available as a Docker image under the name `rcjsuen/docker-langserver`.
## Language Server Settings
Clients may send a `workspace/didChangeConfiguration` notification to
notify the server of settings changes.
The settings object that will be included with the notification must conform
to the following specification.
```TypeScript
interface Settings {
docker: {
languageserver: {
diagnostics?: {
// string values must be equal to "ignore", "warning", or "error"
deprecatedMaintainer?: string,
directiveCasing?: string,
emptyContinuationLine?: string,
instructionCasing?: string,
instructionCmdMultiple?: string,
instructionEntrypointMultiple?: string,
instructionHealthcheckMultiple?: string,
instructionJSONInSingleQuotes?: string
},
formatter?: {
ignoreMultilineInstructions?: boolean,
}
}
}
}
```
## Communicating with the Server
### Node IPC
With the `child_process` API, you can `fork()` a new Node.js process
running the language server and communicate with it using `send(message)`
and `on('message', ...)`.
```TypeScript
import * as child_process from "child_process";
let lspProcess = child_process.fork("out/src/server.js", [ "--node-ipc" ]);
let messageId = 1;
function send(method: string, params: object) {
let message = {
jsonrpc: "2.0",
id: messageId++,
method: method,
params: params
};
lspProcess.send(message);
}
function initialize() {
send("initialize", {
rootPath: process.cwd(),
processId: process.pid,
capabilities: {
/* ... */
}
});
}
lspProcess.on('message', function (json) {
console.log(json);
});
initialize();
```
### Standard Input/Output
When writing directly to the process's stdin, the additional `Content-Length`
header must be included. Similarly, when reading from the process's stdout, the
header will be included in the response message.
```TypeScript
import * as child_process from "child_process";
let lspProcess = child_process.spawn("node", [ "out/src/server.js", "--stdio" ]);
let messageId = 1;
function send(method: string, params: object) {
let message = {
jsonrpc: "2.0",
id: messageId++,
method: method,
params: params
};
let json = JSON.stringify(message);
let headers = "Content-Length: " + json.length + "\r\n\r\n";
lspProcess.stdin.write(headers, "ASCII");
lspProcess.stdin.write(json, "UTF-8");
}
function initialize() {
send("initialize", {
rootPath: process.cwd(),
processId: process.pid,
capabilities: {
/* ... */
}
});
}
lspProcess.stdout.on("data", (message) => {
// "Content-Length: ...\r\n\r\n\" will be included here
console.log(message.toString());
});
initialize();
```
#### vscode-jsonrpc
The `StreamMessageReader` and `StreamMessageWriter` classes from the
`vscode-jsonrpc` module will handle the `Content-Length` headers for you so you
only have to worry about the actual request and response.
```TypeScript
import * as child_process from "child_process";
import { StreamMessageReader, StreamMessageWriter } from "vscode-jsonrpc";
let lspProcess = child_process.spawn("node", [ "out/src/server.js", "--stdio" ]);
let messageId = 1;
const reader = new StreamMessageReader(lspProcess.stdout);
const writer = new StreamMessageWriter(lspProcess.stdin);
function send(method: string, params: object) {
let message = {
jsonrpc: "2.0",
id: messageId++,
method: method,
params: params
};
writer.write(message);
}
function initialize() {
send("initialize", {
rootPath: process.cwd(),
processId: process.pid,
capabilities: {
/* ... */
}
});
}
reader.listen((data) => {
console.log(data);
})
initialize();
没有合适的资源?快使用搜索试试~ 我知道了~
eclipse-cpp-2023-06-R-linux-gtk-x86-64.tar.gz
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 141 浏览量
2023-08-15
19:47:38
上传
评论
收藏 370.59MB GZ 举报
温馨提示
共2000个文件
jar:574个
html:221个
ts:142个
eclipse-cpp-2023-06-R-linux-gtk-x86_64.tar.gz 适用于Linux x86_64位系统
资源推荐
资源详情
资源评论
收起资源包目录
eclipse-cpp-2023-06-R-linux-gtk-x86-64.tar.gz (2000个子文件)
ant 11KB
antRun 862B
.api_description 236B
.api_description 212B
700E4F39BC05364B.asc 4KB
ant.bat 7KB
antRun.bat 1KB
lcp.bat 1KB
ApplicationWorkbenchWindowAdvisor$PostWindowCreateRunnable.class 16KB
DebugExecutable.class 13KB
ApplicationActionBarAdvisor.class 12KB
DebugAttachedExecutable.class 9KB
ApplicationWorkbenchWindowAdvisor.class 8KB
LinuxPasswordProvider.class 8KB
CompilerOptionParser.class 8KB
NewExecutableDialog.class 7KB
CoreFileDialog.class 7KB
RemoteExecutableDialog.class 7KB
ConfigGenerator.class 5KB
BuildOptionsParser.class 5KB
Messages.class 5KB
Application.class 5KB
DebugNewExecutableHandler.class 5KB
DebugRemoteExecutable.class 4KB
DebugRemoteExecutableHandler.class 3KB
InitializeLaunchConfigurations.class 3KB
DebugCoreFile.class 3KB
DebugCoreFileHandler.class 3KB
DebugAttachedExecutableHandler.class 2KB
ApplicationWorkbenchWindowAdvisor$PostWindowCreateRunnable$1.class 2KB
DebugNewExecutableHandler$1.class 2KB
GCCCompileOptionsParser.class 2KB
RemoteExecutableDialog$6.class 2KB
DockerfileLanguageServer.class 2KB
ApplicationActionBarAdvisor$4.class 2KB
ApplicationActionBarAdvisor$3.class 2KB
ApplicationActionBarAdvisor$2.class 2KB
ApplicationActionBarAdvisor$1.class 2KB
RemoteExecutableDialog$2.class 2KB
NewExecutableDialog$2.class 2KB
CoreFileDialog$2.class 2KB
CoreFileDialog$5.class 1KB
DebugExecutable$1.class 1KB
NewExecutableInfo.class 1KB
RemoteExecutableInfo.class 1KB
SecretSchema.class 1KB
ApplicationWorkbenchAdvisor.class 1KB
LinuxPasswordProvider$LibSecret.class 1KB
CoreFileInfo.class 1KB
RemoteExecutableDialog$3.class 1KB
RemoteExecutableDialog$1.class 1KB
RemoteExecutableDialog$4.class 1KB
RemoteExecutableDialog$5.class 1KB
NewExecutableDialog$4.class 1022B
NewExecutableDialog$3.class 1022B
NewExecutableDialog$1.class 1022B
CoreFileDialog$4.class 992B
CoreFileDialog$3.class 992B
CoreFileDialog$1.class 992B
ApplicationActionBarAdvisor$WorkbenchCommandAction.class 977B
Activator.class 959B
GList.class 958B
ApplicationWorkbenchWindowAdvisor$StartupException.class 919B
CompilerOptionParser$CWDTracker.class 909B
SecretSchemaAttribute.class 874B
LinuxPasswordProviderMessages.class 872B
GError.class 789B
CustomizePerspectiveHandler.class 716B
JobContainer.class 699B
LinuxPasswordProvider$LibGio.class 642B
SecretSchemaAttributeType.class 625B
GList$ByReference.class 620B
DummyPage.class 578B
SecretServiceFlags.class 536B
SecretSchemaFlags.class 527B
GBusType.class 521B
SecretCollectionFlags.class 494B
ICDTStandaloneDebugLaunchConstants.class 313B
envset.cmd 4KB
antenv.cmd 3KB
ant.cmd 3KB
runrc.cmd 2KB
node.cmd 213B
node.cmd 213B
node.cmd 213B
e4-dark_globalstyle.css 9KB
e4-dark_ide_colorextensions.css 9KB
e4-light_ide_colorextensions.css 5KB
e4-dark_win.css 5KB
narrow_book.css 4KB
e4-dark_tabstyle.css 4KB
book.css 4KB
e4-dark_partstyle.css 3KB
e4-dark_preferencestyle.css 3KB
e4-light_tabstyle.css 3KB
e4_default_mac.css 3KB
e4-dark_mac1013.css 3KB
e4_default_gtk.css 3KB
e4_default_win.css 2KB
e4-light_globalstyle.css 2KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
YunFeiDong
- 粉丝: 150
- 资源: 3872
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功