A Go package for parsing and expanding line-based scripts.
echo hello world
define greet name
echo Hello, $name!
greet Alice
Linebased provides both a parser and tooling for line-based DSLs. The parser extracts commands and their bodies with no quoting or escaping rules. The tooling includes an LSP server for editor integration.
Linebased scripts are deliberately simple. There are no string escapes, no
quoting rules, no operator precedence. A line is a command name followed by
whatever text you want. That's it. The only reserved words are define and
include, which provide templates and file composition.
This simplicity has a cost: you can't nest expressions or compute values inline. But it has a benefit: scripts are trivial to read, write, and debug. The parser does exactly what you expect because there's almost nothing it can do.
Multi-line bodies use tabs for continuation. Tabs are visible, unambiguous, and easy to type. Spaces at line start are a syntax error, which catches a common class of invisible bugs.
Templates exist because repetition is error-prone. Parameter substitution is the only form of abstraction provided. Templates cannot recurse, cannot redefine themselves, and cannot produce new definitions. These restrictions prevent the language from becoming a programming language.
The LSP server provides diagnostics, hover, and jump-to-definition. Editor support matters.
# Define a reusable template
define greet name
echo Hello, $name!
# Use it
greet Alice
greet Bob
# Include shared definitions (extension added automatically)
include helpers
See the package documentation for syntax, semantics, and API reference.
Install the linebased command:
go install blake.io/linebased/cmd/linebased@latest
See exactly what your templates produce:
$ linebased expand script.linebased
echo Hello, Alice!
echo Hello, Bob!
Add -x for shell-style tracing that shows each template call as it expands:
$ linebased expand -x script.linebased
+ script.linebased:7: outer hello
++ script.linebased:1: inner hello
echo inner: hello
The + signs show nesting depth—when outer calls inner which produces
echo, you see the full expansion chain.
For AI coding assistants (Claude, Copilot, etc.), the linebased command provides built-in guidance:
linebased agents
This outputs guidance on working with linebased files, emphasizing the expand command for debugging. Add the output to your CLAUDE.md or system prompt.
Configure Neovim:
local lspconfig = require("lspconfig")
local configs = require("lspconfig.configs")
if not configs.linebased then
configs.linebased = {
default_config = {
cmd = { "linebased", "lsp" },
filetypes = { "linebased" },
},
}
end
lspconfig.linebased.setup({})You'll get diagnostics, hovers, and jump-to-definition for .linebased files.