{"id":13611994,"url":"https://github.com/rcjsuen/dockerfile-language-server","last_synced_at":"2025-10-21T04:41:30.062Z","repository":{"id":38896634,"uuid":"94993056","full_name":"rcjsuen/dockerfile-language-server","owner":"rcjsuen","description":"A language server for Dockerfiles powered by Node.js, TypeScript, and VSCode technologies.","archived":false,"fork":false,"pushed_at":"2025-07-21T18:50:28.000Z","size":1684,"stargazers_count":438,"open_issues_count":13,"forks_count":16,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-10-15T16:48:45.610Z","etag":null,"topics":["docker","dockerfile","dockerfiles","language-server","language-server-protocol","lsp","moby"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rcjsuen.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"License.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"rcjsuen"}},"created_at":"2017-06-21T10:36:20.000Z","updated_at":"2025-10-10T20:59:21.000Z","dependencies_parsed_at":"2023-02-03T17:16:34.693Z","dependency_job_id":"bca1c839-0383-443e-9d17-854deaa025e8","html_url":"https://github.com/rcjsuen/dockerfile-language-server","commit_stats":{"total_commits":642,"total_committers":4,"mean_commits":160.5,"dds":0.004672897196261627,"last_synced_commit":"399d50e2562639f455386569ccbd528711cc9a65"},"previous_names":["rcjsuen/dockerfile-language-server","rcjsuen/dockerfile-language-server-nodejs"],"tags_count":48,"template":false,"template_full_name":null,"purl":"pkg:github/rcjsuen/dockerfile-language-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcjsuen%2Fdockerfile-language-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcjsuen%2Fdockerfile-language-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcjsuen%2Fdockerfile-language-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcjsuen%2Fdockerfile-language-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rcjsuen","download_url":"https://codeload.github.com/rcjsuen/dockerfile-language-server/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcjsuen%2Fdockerfile-language-server/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280207158,"owners_count":26290614,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-21T02:00:06.614Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","dockerfile","dockerfiles","language-server","language-server-protocol","lsp","moby"],"created_at":"2024-08-01T20:00:20.669Z","updated_at":"2025-10-21T04:41:30.035Z","avatar_url":"https://github.com/rcjsuen.png","language":"TypeScript","readme":"# Dockerfile Language Server\n\n![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)\n\nThis is a language server for Dockerfiles powered by Node.js written in TypeScript.\nTo [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.\n\n**Supported features:**\n- code actions\n- code completion\n- definition\n- diagnostics\n- document highlight\n- document links\n- document symbols\n- folding ranges\n- formatting\n- hovers\n- prepare rename\n- rename\n- semantic highlighting\n- signature help\n\n**Projects that use this language server:**\n- [vscode-docker](https://github.com/Microsoft/vscode-docker)\n- [sublimelsp](https://github.com/sublimelsp/LSP-dockerfile)\n- [Zed](https://github.com/d1y/dockerfile.zed/)\n- [atom-ide-docker](https://github.com/josa42/atom-ide-docker)\n- [Sourcegraph](https://sourcegraph.com/)\n- [Theia](https://theia-ide.org/)\n- [lsp-mode](https://emacs-lsp.github.io/lsp-mode/)\n\nThis repository only contains the code necessary for launching a Dockerfile language server that conforms to the language server protocol.\nThe actual code for parsing a Dockerfile and offering editor features such as code completion or hovers is not contained within this repository.\n\nThe code for analyzing and processing a Dockerfile is contained in the following three libraries:\n- [dockerfile-ast](https://github.com/rcjsuen/dockerfile-ast) - parses a Dockerfile\n- [dockerfile-language-service](https://github.com/rcjsuen/dockerfile-language-service) - provides API functions for handling the different requests defined by the language server protocol\n- [dockerfile-utils](https://github.com/rcjsuen/dockerfile-utils) - validates and formats a Dockerfile, can be run from the CLI\n\nAll of the language server protocol requests that help create a rich editing experience for the user is forwarded to the `dockerfile-language-service` library.\nYou can test its features [right in the browser](https://rcjsuen.github.io/dockerfile-language-service/).\nThis 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.\n\n## Development Instructions\n\nIf 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.\nAfter 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:\n\n```\nnpm install\nnpm run build\nnpm test\n```\n\nIf you are planning to change the code, use `npm run watch` to get the\nTypeScript files transpiled on-the-fly as they are modified.\n\nOnce the code has finished compiling, you can connect a language server\nclient to the server via Node IPC, stdio, or sockets.\n\n## Installation Instructions\n\nTo install this language server onto your computer, please install the\n[dockerfile-language-server-nodejs npm module](https://www.npmjs.com/package/dockerfile-language-server-nodejs).\nThe `-g` flag will install the npm module globally onto your computer.\n\n```\nnpm install -g dockerfile-language-server-nodejs\n```\n\nAfter the installation has completed, you can start the language\nserver with the `docker-langserver` binary. You should specify\nthe desired method of communicating with the language server via one\nof the three arguments shown below.\n\n```\ndocker-langserver --node-ipc\ndocker-langserver --stdio\ndocker-langserver --socket=\u003cport\u003e\n```\n\n### Docker Image\nThe `docker-langserver` binary is also available as a Docker image under the name `rcjsuen/docker-langserver`.\n\n## Language Server Settings\n\nClients may send a `workspace/didChangeConfiguration` notification to\nnotify the server of settings changes.\n\nThe settings object that will be included with the notification must conform\nto the following specification.\n\n```TypeScript\ninterface Settings {\n  docker: {\n    languageserver: {\n      diagnostics?: {\n        // string values must be equal to \"ignore\", \"warning\", or \"error\"\n        deprecatedMaintainer?: string,\n        directiveCasing?: string,\n        emptyContinuationLine?: string,\n        instructionCasing?: string,\n        instructionCmdMultiple?: string,\n        instructionEntrypointMultiple?: string,\n        instructionHealthcheckMultiple?: string,\n        instructionJSONInSingleQuotes?: string\n      },\n      formatter?: {\n        ignoreMultilineInstructions?: boolean,\n      }\n    }\n  }\n}\n```\n\n## Communicating with the Server\n### Node IPC\n\nWith the `child_process` API, you can `fork()` a new Node.js process\nrunning the language server and communicate with it using `send(message)`\nand `on('message', ...)`.\n\n```TypeScript\nimport * as child_process from \"child_process\";\n\nlet lspProcess = child_process.fork(\"out/src/server.js\", [ \"--node-ipc\" ]);\nlet messageId = 1;\n\nfunction send(method: string, params: object) {\n    let message = {\n        jsonrpc: \"2.0\",\n        id: messageId++,\n        method: method,\n        params: params\n    };\n    lspProcess.send(message);\n}\n\nfunction initialize() {\n    send(\"initialize\", {\n        rootPath: process.cwd(),\n        processId: process.pid,\n        capabilities: {\n            /* ... */\n        }\n    });\n}\n\n\nlspProcess.on('message', function (json) {\n    console.log(json);\n});\ninitialize();\n```\n\n### Standard Input/Output\n\nWhen writing directly to the process's stdin, the additional `Content-Length`\nheader must be included. Similarly, when reading from the process's stdout, the\nheader will be included in the response message.\n\n```TypeScript\nimport * as child_process from \"child_process\";\n\nlet lspProcess = child_process.spawn(\"node\", [ \"out/src/server.js\", \"--stdio\" ]);\nlet messageId = 1;\n\nfunction send(method: string, params: object) {\n    let message = {\n        jsonrpc: \"2.0\",\n        id: messageId++,\n        method: method,\n        params: params\n    };\n    let json = JSON.stringify(message);\n    let headers = \"Content-Length: \" + json.length + \"\\r\\n\\r\\n\";\n    lspProcess.stdin.write(headers, \"ASCII\");\n    lspProcess.stdin.write(json, \"UTF-8\");\n}\n\nfunction initialize() {\n    send(\"initialize\", {\n        rootPath: process.cwd(),\n        processId: process.pid,\n        capabilities: {\n            /* ... */\n        }\n    });\n}\n\nlspProcess.stdout.on(\"data\", (message) =\u003e {\n    // \"Content-Length: ...\\r\\n\\r\\n\\\" will be included here\n    console.log(message.toString());\n});\n\ninitialize();\n```\n\n#### vscode-jsonrpc\n\nThe `StreamMessageReader` and `StreamMessageWriter` classes from the\n`vscode-jsonrpc` module will handle the `Content-Length` headers for you so you\nonly have to worry about the actual request and response.\n\n```TypeScript\nimport * as child_process from \"child_process\";\nimport { StreamMessageReader, StreamMessageWriter } from \"vscode-jsonrpc\";\n\nlet lspProcess = child_process.spawn(\"node\", [ \"out/src/server.js\", \"--stdio\" ]);\nlet messageId = 1;\n\nconst reader = new StreamMessageReader(lspProcess.stdout);\nconst writer = new StreamMessageWriter(lspProcess.stdin);\n\nfunction send(method: string, params: object) {\n    let message = {\n        jsonrpc: \"2.0\",\n        id: messageId++,\n        method: method,\n        params: params\n    };\n    writer.write(message);\n}\n\nfunction initialize() {\n    send(\"initialize\", {\n        rootPath: process.cwd(),\n        processId: process.pid,\n        capabilities: {\n            /* ... */\n        }\n    });\n}\n\nreader.listen((data) =\u003e {\n    console.log(data);\n})\n\ninitialize();\n```\n\n### Sockets\n\nTo communicate with the langauge server via a socket, a port must be opened\nup first to listen for incoming connections. After the port is opened, the\nlanguage server may be started and told to connect to the specified port.\nMessages can then be read from and written to the socket.\n\nJust like when trying to communicate to the server using\n[stdio](#standard-inputoutput), the `Content-Length` headers must be written\nand parsed explicitly.\n\n```TypeScript\nimport * as net from \"net\"\nimport * as child_process from \"child_process\"\n\nlet messageId = 1;\n\nfunction send(socket: net.Socket, method: string, params: object) {\n    let message = {\n        jsonrpc: \"2.0\",\n        id: messageId++,\n        method: method,\n        params: params\n    };\n    let json = JSON.stringify(message) + \"\\n\";\n    let headers = \"Content-Length: \" + json.length + \"\\r\\n\\r\\n\";\n    socket.write(headers, \"ASCII\");\n    socket.write(json, \"UTF-8\");\n}\n\nfunction initialize(socket: net.Socket) {\n    send(socket, \"initialize\", {\n        rootPath: process.cwd(),\n        processId: process.pid,\n        capabilities: {\n            textDocument: {\n                /* ... */\n            },\n            workspace: {\n                /* ... */\n            }\n        }\n    });\n}\n\nconst server = net.createServer((socket: net.Socket) =\u003e {\n    server.close();\n    socket.on(\"data\", (message) =\u003e {\n        // \"Content-Length: ...\\r\\n\\r\\n\\\" will be included here\n        console.log(message.toString());\n    });\n    initialize(socket);\n});\n\nserver.listen(3000, () =\u003e {\n    child_process.spawn(\"node\", [ \"out/src/server.js\", \"--socket=3000\" ]);\n});\n```\n\n#### vscode-jsonrpc\n\nThe `SocketMessageReader` and `SocketMessageWriter` classes from the\n`vscode-jsonrpc` module will handle the `Content-Length` headers for you so you\nonly have to worry about the actual request and response.\n\n```TypeScript\nimport * as net from \"net\"\nimport * as child_process from \"child_process\"\nimport { SocketMessageReader, SocketMessageWriter } from \"vscode-jsonrpc\";\n\nlet messageId = 1;\nlet reader: SocketMessageReader = null;\nlet writer: SocketMessageWriter = null;\n\nfunction send(method: string, params: object) {\n    let message = {\n        jsonrpc: \"2.0\",\n        id: messageId++,\n        method: method,\n        params: params\n    };\n    writer.write(message);\n}\n\nfunction initialize() {\n    send(\"initialize\", {\n        rootPath: process.cwd(),\n        processId: process.pid,\n        capabilities: {\n            textDocument: {\n                /* ... */\n            },\n            workspace: {\n                /* ... */\n            }\n        }\n    });\n}\n\nconst server = net.createServer((socket: net.Socket) =\u003e {\n    server.close();\n    reader = new SocketMessageReader(socket);\n    reader.listen((data) =\u003e {\n        console.log(data);\n    });\n    writer = new SocketMessageWriter(socket);\n    initialize();\n});\n\nserver.listen(3000, () =\u003e {\n    child_process.spawn(\"node\", [ \"out/src/server.js\", \"--socket=3000\" ]);\n});\n```\n","funding_links":["https://github.com/sponsors/rcjsuen"],"categories":["Plugins / Themes / Dependencies","TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frcjsuen%2Fdockerfile-language-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frcjsuen%2Fdockerfile-language-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frcjsuen%2Fdockerfile-language-server/lists"}