DOT Language Server
The `dot-language-server` package provides a robust Language Server Protocol (LSP) implementation specifically tailored for the DOT language, which is commonly used with Graphviz. Currently at version 3.1.0, the project follows an active release cadence, with major versions introducing significant shifts like the recent transition to ECMAScript Modules (ESM) and a strict Node.js v22+ requirement in version 3.x. Its primary differentiator is its dedicated support for DOT syntax, offering features such as refactorings, diagnostics, and code completion to various LSP-compatible editors like Vim, Neovim, Visual Studio Code, Sublime Text, and Emacs. Unlike general-purpose language tools, `dot-language-server` focuses exclusively on providing a rich development experience for Graphviz users, integrating directly into editor workflows rather than requiring external compilation or visualization steps. It functions as a standalone executable.
Common errors
-
Error: The 'dot-language-server' requires Node.js version 22 or higher.
cause Attempting to run the language server with an unsupported Node.js version.fixUpgrade your Node.js installation to version 22 or newer. Use `nvm install 22` and `nvm use 22` or similar version manager commands. -
ERR_REQUIRE_ESM: require() of ES Module .../node_modules/dot-language-server/dist/server.js from ... not supported.
cause Attempting to `require()` the `dot-language-server` package programmatically in a CommonJS context, which is not supported since v3.0.0 (ESM-only).fixAvoid programmatic `require()` of this package. `dot-language-server` is an executable tool. Use it by spawning its command-line interface, typically configured through your LSP client, rather than importing it as a library. -
LSP client reports 'command not found' or server failed to start on Windows.
cause The LSP client failed to locate the `dot-language-server` executable on Windows due to missing `.cmd` extension or shell execution issues.fixIn your LSP client configuration, explicitly add `.cmd` to the executable name, e.g., change `"command": ["dot-language-server", "--stdio"]` to `"command": ["dot-language-server.cmd", "--stdio"]`.
Warnings
- breaking Version 2.0.0 introduced a significant breaking change by requiring Node.js version 22 or higher. Earlier Node.js versions are no longer supported.
- breaking Version 3.0.0 transitioned the package to be ESM-only (ECMAScript Modules). This means any attempts to `require()` the package programmatically will likely result in errors.
- gotcha On Windows, when configuring LSP clients, the `dot-language-server` executable often needs the `.cmd` extension explicitly added to its command path.
Install
-
npm install dot-language-server -
yarn add dot-language-server -
pnpm add dot-language-server
Imports
- dot-language-server
N/A - primary usage is via CLI executable `dot-language-server`
- start
N/A - see above note
- ServerOptions
N/A - see above note
Quickstart
{
"clients": {
"dot-language-server": {
"command": ["dot-language-server", "--stdio"],
"enabled": true,
"languageId": "dot",
"scopes": ["source.dot"],
"syntaxes": ["Packages/Graphviz/DOT.sublime-syntax"]
}
}
}
// Note for Windows Users: You have to append `.cmd` to the first entry in the `command` array
// (e.g., ["dot-language-server.cmd", "--stdio"]), or ensure shell execution is enabled,
// for the server executable to be correctly located and run.