Editor Support & LSP
Developing workflows in Rhythm is most effective when using the official editor tools. Since Rhythm uses a custom .flow syntax—a specialized subset of JavaScript—standard JavaScript extensions may not provide accurate validation or completions for Rhythm-specific globals like Task and Signal.
Visual Studio Code
The recommended way to write Rhythm workflows is with the Rhythm VS Code Extension. It provides a first-class developer experience by bundling the Rhythm Language Server.
Installation
- Open Visual Studio Code.
- Go to the Extensions view (
Ctrl+Shift+XorCmd+Shift+X). - Search for
Rhythm. - Click Install.
Features
- Syntax Highlighting: Full color support for the
.flowgrammar, including keywords, template strings, and asynchronous operators. - Real-time Validation: Instant feedback on syntax errors or invalid Rhythm constructs (e.g., using unsupported JavaScript features like
classorconst). - IntelliSense:
- Auto-completion: Suggestions for global objects including
Task,Signal,Inputs, andMath. - Signature Help: Parameter hints and documentation for
Task.run()andSignal.when().
- Auto-completion: Suggestions for global objects including
- Formatting: Automatic indentation and code cleanup following the Rhythm style guide.
Language Server Protocol (LSP)
The core of Rhythm’s editor support is the rhythm-lsp, written in Rust. If you use an editor other than VS Code (such as Neovim or Helix), you can run the LSP standalone to get the same validation and completion benefits.
Manual Installation
If you have the Rhythm CLI or core tools installed, the language server is typically available as an executable named rhythm-lsp.
# Verify the LSP is in your path
rhythm-lsp --version
Neovim Configuration (nvim-lspconfig)
You can integrate Rhythm into Neovim by defining a custom LspConfig. Ensure .flow files are detected as the rhythm filetype.
-- 1. Register the 'flow' filetype
vim.filetype.add({
extension = {
flow = 'rhythm',
},
})
-- 2. Configure the LSP server
local configs = require('lspconfig.configs')
local lspconfig = require('lspconfig')
if not configs.rhythm_lsp then
configs.rhythm_lsp = {
default_config = {
cmd = { 'rhythm-lsp' },
filetypes = { 'rhythm' },
root_dir = lspconfig.util.root_pattern('.git', 'rhythm.yaml'),
settings = {},
},
}
end
lspconfig.rhythm_lsp.setup({})
Schema & Validation
The Language Server uses the internal Rhythm parser to ensure your scripts are compatible with the durable execution engine. It specifically validates:
- Await Requirements: Ensures
Task.runandSignal.whenare awaited if their results are needed, or correctly handled if fired-and-forgotten. - Sandbox Restrictions: Flags any attempt to use non-deterministic browser or Node.js APIs (like
Date.now()orfetch) which are not available in the.flowruntime. - Input Mapping: Provides completions for the
Inputsobject based on your project's defined workflow triggers.
Task Definitions
To enable autocompletion for task names in Task.run("task-name", ... ), the LSP looks for a rhythm.yaml file in your project root or the presence of the Rhythm Python SDK in your environment. This allows the editor to know which tasks are actually defined in your application code.