Skip to content

About

An alternative syntax for Lispico, powered by the Confetti parser.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Lispico Confetti

An experimental alternative frontend for Lispico, using Confetti for parsing. Confetti’s native directive and subdirective AST is translated into Lispico expressions and evaluated by the original interpreter and standard library.

This frontend uses Confetti’s native { … } blocks exclusively for nested expressions. It does not enable Confetti’s parenthesized-expression extension, and it does not tokenize or parse expression strings independently.

See examples for runnable programs, examples/ported-lispico-examples for all original Lispico examples ported to Confetti syntax, and examples/fail for expected translation failures.

Relationship to Lispico

Lispico Confetti is an alternative frontend, not another implementation of Lispico’s runtime. Its standard library, value types, error behavior, variable and array semantics, allocation limits, and memory management (including manual garbage collection) come from Lispico itself.

Lispico is still in active development. Its features and behavior will continue to evolve. When this project updates its pinned Lispico dependency, new runtime capabilities will become available here too, although some may need additional translation rules.

For the complete feature set and runtime documentation, consult Lispico’s README. This README concentrates on expressing Lispico programs using Confetti syntax.

Build and run

For a local build, initialize the Git submodules first:

git submodule update --init --recursive
./build.sh
./lispico-confetti examples/hello.confetti
./lispico-confetti examples/blocks.confetti
./lispico-confetti examples/arrays.confetti
./lispico-confetti examples/infix.confetti
./lispico-confetti examples/prefix.confetti
./lispico-confetti examples/strings.confetti
./tests/run-examples.sh

Or use Nix with pinned Lispico and Confetti sources:

nix-build -A lispico-confetti
./result/bin/lispico-confetti examples/hello.confetti

To use locally initialized submodules instead of the pins:

nix-build -A lispico-confetti --arg useLocalSubmodules true

Command-line interface

Lispico Confetti has the same command-line interface as original Lispico. See for details: https://github.com/unclechu/lispico#command-line-interface

lispico-confetti --help

Immutable command-line references

The interpreter uses the same immutable-reference behavior as Lispico. An immutable reference means a read-only view, not a permanently frozen underlying allocation. The command-line values are held by the host for the whole evaluation; Lispico Confetti borrows them instead of making redundant runtime-managed copies:

  • --var NAME s:VALUE supplies an immutable string reference. Numeric CLI variables remain ordinary numeric values.
  • --arr and --arr-new supply immutable array references. String-array elements are immutable string references too, including empty elements.
  • Built-in argv and args are immutable array references; each contained argument is also an immutable string reference. They keep their original argument bytes rather than copying them into the evaluator.
  • The --arr-set option still initializes a CLI array before evaluation. Scripts cannot modify these borrowed arrays or strings in place; use (copy) to obtain independent writable storage.
  • --freeze NAME still freezes the symbol binding, independently of the value’s immutable-reference flag. Without --freeze, an immutable-reference variable may be rebound using (override).

In Confetti syntax, these checks can be written as:

assert { is-immutable-ref argv }
assert { is-immutable-ref args }
assert { is-immutable-ref { arr-get argv 0 } }
assert { has-immutable-refs argv }
var "writable-argv" { copy argv }
assert { is-immutable-ref writable-argv == false }

Named function arguments, (immutable-ref), (copy), and zero-copy slices use Lispico’s existing runtime semantics after translation; no special Confetti syntax is required. Both the CLI buffers and their descriptor arrays must remain alive until evaluation has finished and the interpreter has been cleaned. This does not change Confetti’s parse-time argument handling.

Parse-time includes and source-aware diagnostics

include "PATH" inserts expressions from another Confetti source file during parsing and translation, before evaluation. Paths must be literal quoted strings. Relative paths resolve against the directory containing the source with the include directive; for stdin, they resolve against the current working directory. Absolute paths work as written.

For example, with lib/setup.confetti:

var "threshold" 10
fn "ready" args value {value >= threshold}

The main program can simply use:

include "lib/setup.confetti"
assert {ready 12}

Includes work within do { … }, function bodies, and native Confetti argument blocks. An include expands to zero or more sibling expressions: there is no wrapper call or newly introduced scope. This is equivalent to copy-pasting the included file’s directives at that position, except that the included source retains its original file locations. A block that specifically requires a single expression still requires exactly one expression after expansion. Included files must themselves contain complete valid Confetti syntax, rather than incomplete fragments of a parent directive.

Repeated inclusion reparses the file on each occurrence. Circular inclusions are rejected by filesystem identity (device and inode), including symlink and hard-link aliases. Included paths are not normalized. There is no automatic include-once behavior or namespace isolation. The file extension is not restricted, but all included files are parsed as Confetti, not as Lispico S-expressions; a future include-lisp would be a separate feature.

Source mapping is enabled by default. Evaluation failures identify the exact source file, line, and byte column, display that file’s excerpt, and print the chain of Included from sites back to the main source. Confetti syntax errors, translation errors, and include-loading or cycle errors also report a filename, line, byte column, source excerpt, and include trace. For example:

[FAIL] Evaluation failed: lib/logic.confetti:2:4: Undefined variable
2 | id missing
  |    ↑
Included from main.confetti:1:1
lispico-confetti --source-highlight=none program.confetti
lispico-confetti --source-context-before=5 program.confetti
lispico-confetti --no-source-map program.confetti

--no-source-map skips retained source-location storage and evaluation excerpts/traces, but does not disable includes. Parsing failures still report their filename and include trace (without an excerpt). The standard Lispico --source-highlight modes bat, none, and sh remain available; bat falls back to the plain renderer when unavailable, and the sh mode receives the original failing source file through stdin and the usual LISPICO_SOURCE_CONTEXT_* environment variables. Confetti uses the confetti file type for source highlighting.

The original in-memory parse_confetti_source() API remains available without filesystem inclusion; the file-aware parse_confetti_source_with_includes() and parse_confetti_source_with_includes_diagnostic() entry points support includes and optional structured parsing diagnostics. When mapping is enabled, the host registers the main source as source ID 0 and keeps the source registry alive until after evaluation and error reporting. Include expansion and cycle detection do not depend on source mapping.

Translation rules

Confetti supplies the complete structural AST. Lispico Confetti interprets directives and their arguments as Lispico expressions:

Confetti Lispico Meaning
message (message) Call a function without arguments
id message message Use a symbol’s value
id 123 123 Use a literal value
println message (println message) Call a function with an argument
var "x" {gc} (var "x" (gc)) A block supplies a call argument
str {id "a"; id "b"} (str "a" "b") Block subdirectives supply separate arguments
str "a" {id "b"} (str "a" "b") Block subdirectives supply separate arguments
str "a" "b" (str "a" "b") Plain arguments
str {} (str) Empty block supplies no arguments
str (str) Empty block supplies no arguments
str do {id "a"; id "b"} (str (do "a" "b")) Explicit sequence is one argument
id {gc} (gc) Pass the result of a nested call through
1 + 2 (+ 1 2) Infix operator directive
+ 1 2 (+ 1 2) Ordinary prefix operator directive
1 + 2 + 3 (+ 1 2 3) Chain the same arithmetic operator
1 && 0 && 1 (and 1 0 1) Short-circuit logical AND
0 || 1 || 0 (or 0 1 0) Short-circuit logical OR
do { … } (do …) Explicit sequence
i = 0 (set "i" 0) Set an existing variable
foo[n] (arr-get "foo" n) Read an array element
foo[n] = x (arr-set "foo" n x) Write an array element
$foo[n] (str-get "foo" n) Read a string byte
$foo[n] = x (str-set "foo" n x) Write a string byte/range

Quoted arguments represent string literals, while bare names represent symbol references. Numeric arguments use Lispico’s existing numeric parser. For example:

var "name" "World"
println name
println "name"
(var "name" "World")
(println name)
(println "name")

Function definitions (fn)

fn has a declaration-specific translation rule. The first argument is the function name (a string literal, variable, or evaluated expression), and the last complete argument or expression is the function body. If there are arguments between them, their first name becomes a Lispico declaration call; its remaining arguments become string literals. The translator does not special-case args or var-args as declaration names: Lispico validates the resulting declaration.

fn "identity" args x x
fn "identity-block" args x {id x}
fn "add" args "left" right {left + right}
fn "all" var-args {id argc}
fn "named-varargs" var-args first do {
  id first
}
(fn "identity" (args "x") x)
(fn "identity-block" (args "x") x)
(fn "add" (args "left" "right") (+ left right))
(fn "all" (var-args) argc)
(fn "named-varargs" (var-args "first") (do first))

A bare argument name such as x or first is converted to a string literal; a quoted name such as "left" stays a string literal. The body is translated normally. A final bare x is a variable reference, while {id x} makes that expression boundary explicit. {left + right} groups one body expression without creating an extra scope. Only do { … } introduces an explicit Lispico (do) scope; the translator does not add one automatically.

A dynamic function name can also occupy the first native Confetti block. Confetti then represents the following declaration/body as a neighboring directive, which fn consumes as part of the definition:

fn {str "dynamic" "-add"} args a b {a + b}
fn {str "dynamic" "-answer"} do {
  id 42
}

These produce (fn (str "dynamic" "-add") (args "a" "b") (+ a b)) and (fn (str "dynamic" "-answer") (do 42)), respectively. An arbitrary declaration name also works syntactically: fn "example" custom a b {id a} becomes (fn "example" (custom "a" "b") a); Lispico decides whether custom is a valid declaration.

The original ordinary argument-block syntax remains supported, including fn "name" {args "x"; id x} and fn {str "dynamic" "-name"; args "x"; id x}. These forms are useful when explicitly listing Lispico expressions instead of using the shorthand. A grouped prefix operator body, such as {+ a b c d e}, is unambiguous in the shorthand. For adjacent operator directives in the legacy braced form, id { … } still avoids the existing infix-continuation heuristic.

Assignment and indexed access

Assignment is translated into Lispico’s existing (set), (arr-set), or (str-set) functions. It does not create new variables; use (var) first. The assignment target becomes a string name, not a reference to the target’s current value:

var "i" 0
arr-new "numbers" u32 10
str-new "text" 10

i = 1
numbers[1] = 42
numbers[i] = 42
$text[i] = str-char "A"

An index written inside brackets is one bare numeric literal or variable reference. Use empty brackets and a trailing native Confetti block for a computed index; the block must contain exactly one logical expression:

numbers[] {i * 2}
numbers[] {i * 2} = 42
numbers[] {i * 2} = {i + 1}

$text[] {i * 2}
$text[] {i * 2} = str-char "A"
$text[] {i * 2} = {str-char "A" + 1}

The second line becomes (arr-set "numbers" (* i 2) 42); the last line becomes (str-set "text" (* i 2) (+ (str-char "A") 1)). Confetti represents numbers[] {i * 2} = 42 as two adjacent directives: the first carries the index block, and the second begins with = and supplies the value. The translator combines them, similarly to its existing operator continuations. No new expression parser is introduced.

Indexed reads are valid wherever a normal value is accepted:

assert {numbers[i] == 42}
assert {numbers[] {i * 2} == 42}
assert {$text[i] == str-char "A"}

$text[i] returns a u32 byte, not a one-character string, matching (str-get). An indexed assignment inherits the destination function’s type and bounds checks. Quoted names retain their literal meaning: explicit arr-get "foo[1]" 0 can still access an array whose name contains brackets. To compute an assignment’s right-hand side, use { … } grouping, for example i = {1 + 2}. Mixed ungrouped operators have no implicit precedence.

Native argument blocks and infix operators

An ordinary block supplies zero or more arguments to the enclosing function, one for each logical expression inside it. The block is not implicitly grouped into a (do). For example:

var "joined" {str {str "Hello"; str " world"}}
assert {joined == "Hello world"}

var "shorter" {str "Hello" " world"}
assert {shorter == joined}

var "empty" {str}
assert {empty == ""}
(var "joined" (str (str "Hello") (str " world")))
(assert (== joined "Hello world"))
(var "shorter" (str "Hello" " world"))
(assert (== shorter joined))
(var "empty" (str))
(assert (== empty ""))

Literals and variable references inside argument blocks still use id, the identity special form. It passes its operand through without an additional Lispico call, like an identity function.

For example, str {id "Hello"} is supported, but str {"Hello"} does not implicitly convert its quoted-only subdirective into a value. Likewise, id message passes the variable’s contents, while message is a zero-argument function call.

The preferred operator syntax is infix:

var "answer" {1 + {2 * 3}}
assert {answer == 7}
var "difference" {20 - 5 - 3}
assert {difference == 12}
(var "answer" (+ 1 (* 2 3)))
(assert (== answer 7))
(var "difference" (- 20 5 3))
(assert (== difference 12))

There is no operator precedence. Each directive may use only one kind of infix operator. Parent-child relationships in Confetti’s AST express nesting:

# Accepted: explicit grouping
var "number" {1 + {2 * 3}}

# Rejected: mixed operators without grouping
# var "number" {1 + 2 * 3}

Arithmetic +, -, *, and / and logical && and || can be chained left to right. Comparisons <, <=, >, >=, ==, and != accept two operands only. A long chain is split into left-associated Lispico calls when it exceeds Lispico’s native argument capacity.

Logical operators and short-circuiting

&& and || are translated directly to Lispico’s existing (and) and (or) special forms. Unlike ordinary function calls, these forms stop evaluating arguments when the result is already known:

var "enabled" {1 && {0 || 1}}
assert {enabled == 1}

# These undefined calls are never evaluated.
assert {id {0 && {never-called}} == 0}
assert {id {1 || {never-called}} == 1}

# Prefix notation works too.
assert {id {&& 1 1} == 1}
assert {id {|| 0 1} == 1}
(var "enabled" (and 1 (or 0 1)))
(assert (== enabled 1))
(assert (== (and 0 (never-called)) 0))
(assert (== (or 1 (never-called)) 1))
(assert (== (and 1 1) 1))
(assert (== (or 0 1) 1))

As with arithmetic, there is no implicit precedence or mixing of infix operators. 1 && 0 || 1 is invalid: use 1 && {0 || 1} or id {1 && 0} || 1 inside a block, depending on the intended grouping. See the logical example for executable tests, including nested expressions and long chains.

Infix directives work at the top level too, including with Lispico’s last-val function:

1 + 2
last-val

This returns TYPE_U32(3). The regression examples also cover top-level id {1 + 2}, composed id expressions, and long arithmetic chains.

Prefix calls are still supported: they are just ordinary Confetti directives. The prefix example demonstrates both forms:

var "two" {+ 1 2}
var "six" {+ 1 2 3}
(var "two" (+ 1 2))
(var "six" (+ 1 2 3))

id and neighboring operator directives

Confetti allows a new directive immediately after another directive’s closing brace. The translator can therefore combine an id directive or an ordinary function call with a trailing argument block with the following operator directives inside the same native block:

var "numbers" {arr 10 20 30}
assert {id {arr-get "numbers" 1} == 20}
assert {type-of {3 - 2} == u32}
assert {id {2 + 3} == id 5}
sin {pi / 2.0} - 1.0
(var "numbers" (arr 10 20 30))
(assert (== (arr-get "numbers" 1) 20))
(assert (== (type-of (- 3 2)) u32))
(assert (== (+ 2 3) 5))
(- (sin (/ pi 2.0)) 1.0)

Confetti provides neighboring subdirectives, not an opaque expression string:

assert
├── id
│   └── arr-get "numbers" 1
└── == 20

Here id {arr-get "numbers" 1} provides the left operand, and == 20 continues the expression. The outer id is unnecessary when the left side is already a function call with an argument block, and id may optionally introduce the right operand as well. Subsequent operator continuations must use the same operator. This is an interpretation of Confetti’s native AST; no extra lexical scanning is involved.

Arithmetic continuations work after any function call with a trailing block, not just id. For example, sin {pi / 2.0} - 1.0 subtracts from the result of sin, whereas a complete prefix call such as + 1 2 3 remains a separate directive. The right operand may itself be a call with a trailing argument block, as in str-size {id "Hello"} + str-size {id "world"}. This translates to (+ (str-size "Hello") (str-size "world")), with both blocks attached to their respective function calls. A grouped right operand also works, as in str-size {id "Hello"} + {str-size {id "world"}}. A standalone prefix call such as + {id 1; id 2} remains separate. The translator distinguishes these cases using Confetti’s native operator and operand arguments.

Operator continuation uses heuristics, not an explicit statement boundary. When neighboring Confetti directives look like an infix expression, the translator may combine them, even when the original source separates them with a semicolon. For example, a directive with a trailing { … } block can consume a following + a b c d e as an infix continuation: the + is not necessarily treated as a separate prefix function call. The translator uses the native directive structure and operator/operand shapes to resolve such ambiguities; some complete prefix calls, such as + 1 2 3, remain separate.

To force an operator to be called as a regular prefix function, wrap the call in id { … }. The wrapper prevents it from being mistaken for an infix continuation of the preceding directive:

# Ambiguous: the + can continue the preceding blocked directive.
args {foo}; + a b c d e

# Explicitly separate expressions: call + as a prefix function.
args {foo}
id {+ a b c d e}

For example, a function with five named arguments can use the same pattern with the concise fn declaration syntax:

fn "sum-five" args a b c d e {+ a b c d e}

The id wrapper only makes the operator call unambiguous; it does not introduce a new Lispico scope or change the call’s arguments or result.

A named function call with inline arguments can also precede a comparison within one directive:

assert {div 7.5 2.0 == 3.0}
assert {div {id 7.5; id 2.0} == 3.0}

Both translate to (assert (== (div 7.5 2.0) 3.0)). In the second example, the id markers are needed because native Confetti subdirectives do not interpret 7.5 2.0 as two separate literal arguments.

The right-hand operand can likewise be a function call with inline arguments, including calls that take enough arguments to give the operator directive an odd number of arguments:

var "signed" {arr {type i32 0}}
assert {arr-get "signed" 0 == type i32 0}
assert {arr-get "signed" 0 == {type i32 0}}
assert {arr-concat {arr 1 2; arr 3 4} == arr 1 2 3 4}

The first two assertions compare (arr-get "signed" 0) with (type i32 0). The third compares two array-valued calls, preserving all arguments of the right-hand arr call instead of interpreting arr as a variable. Between infix operators, one native argument remains an atom, while multiple arguments form a function call. For example, 1 + type u32 2 + 3 translates to (+ 1 (type u32 2) 3). Operators still cannot be mixed without braces, and id still introduces exactly one explicit operand. No new lexer or source-level grouping is needed: these are Confetti’s existing arguments. The final call may also use a native argument block, as in assert {1 == type u32 {id 1}}; quoted operator spellings remain ordinary arguments rather than splitting the call.

One logical argument can span multiple directives, while a subsequent id starts a new argument:

assert {
  id {str-size "Hello"} == 5
  id "Expected exactly five bytes"
}
(assert (== (str-size "Hello") 5) "Expected exactly five bytes")

Nested calls may also appear as the last operand without id:

assert {32 == {2 + {arr-get "numbers" 2}}}
(assert (== 32 (+ 2 (arr-get "numbers" 2))))

An anonymous { … } cannot appear at the start of a Confetti directive. Consequently, assert {{arr-get "numbers" 1} == 20} is not valid Confetti; use the explicit id form above.

Sequences and expression values

do creates a sequence, evaluating its expressions in order and returning the last result. It also establishes Lispico’s existing sequence control-flow boundary. An ordinary function block expands its expressions as separate arguments; explicit do is required to pass a sequence as one argument.

var "answer" do {
  var "first" 10
  first + 5
}

do {
  println "Computed a result"
  id answer
}
(var "answer" (do (var "first" 10) (+ first 5)))
(do (println "Computed a result") answer)

id answer is important when the final sequence expression should be a symbol reference rather than a zero-argument function call. An explicit id {call} also works when the expression is a nested call.

An empty ordinary block supplies no arguments; an explicit empty sequence supplies one argument if passed to another function:

str {}    # Equivalent to (str)
str       # Equivalent to (str)
str do {} # Equivalent to (str (do); Lispico will fail to evaluate)
do {}     # Equivalent to (do)
do        # Equivalent to (do)

Conditional branches are intentionally different: an if branch still requires exactly one expression, or an explicit do for an empty or multi-expression sequence. This prevents a second expression from becoming an accidental false branch.

Strings, escapes, and NUL bytes

Confetti first processes its own escaping (a backslash escapes the following character). Lispico Confetti then decodes surviving backslash sequences using Lispico’s string literal rules. This applies to ordinary and triple-quoted arguments, including inside native { … } blocks.

For instance, two backslashes in Confetti source preserve one backslash for the second stage:

var "message" "hello\\nworld"
var "binary" "A\\0B"
var "literal" "hello\\\\nworld"
(var "message" "hello\nworld")
(var "binary" "A\0B")
(var "literal" "hello\\nworld")
Confetti source Result
\\n Newline (LF)
\\r Carriage return (CR)
\\t Tab
\\0 NUL byte
\\\\ Literal backslash
\\\\n Literal backslash followed by n
\\\\0 Literal backslash followed by 0

Confetti handles ordinary escaped quotes such as \". The second decoder also recognizes Lispico’s quote escape when it survives Confetti’s first pass. Unknown or incomplete surviving escapes cause translation errors.

For example, Confetti decodes "\n" to just "n", which is not a newline. Conversely, "\\q" fails during Lispico decoding, while "\\\\q" represents a literal backslash followed by q.

Triple-quoted strings contain real line breaks and undergo the same second decoding stage. Indentation inside the quotes is part of their value:

var "message" """First line
Second line"""
assert {id {str-get "message" 10} == 10}

Lispico strings store explicit byte lengths, so an embedded NUL does not truncate the value. A final terminator is stored separately.

Conditionals

The translator supports if, else if, and else. Each branch is evaluated only when selected, preserving Lispico’s ordinary lazy if behavior. Conditions may be single values or infix comparisons:

if 5 > 2 {
  println "bigger"
} else if 5 < 2 {
  println "smaller"
} else {
  println "equal"
}

Equivalent Lispico:

(if (> 5 2)
  (println "bigger")
  (if (< 5 2)
    (println "smaller")
    (println "equal")))

then is optional when the condition fits in the directive’s argument list:

if enabled {
  println "Enabled"
}
if enabled then {
  println "Enabled"
}

However, Confetti permits only one trailing block per directive. If the condition itself needs a block, the branch must be an adjacent then or do directive:

if {5 > 2} then {
  println "bigger"
} else if {5 < 2} then {
  println "smaller"
} else {
  println "equal"
}

This is still entirely native Confetti AST: if {5 > 2} contains the condition block, and the next sibling then { … } supplies its branch. No embedded expression strings are re-parsed. Writing if {condition} {branch} directly is invalid because the second block lacks its own directive.

A regular branch block must contain exactly one expression. Use do for zero or multiple expressions; optionally combine it with then:

if {enabled} then {
  println "Enabled"
} else do {
  println "Disabled"
  println "Try enabling it"
}

if enabled then do {
  println "First"
  println "Second"
}

if enabled do {}

do wraps its contents in Lispico (do …). For example, the first conditional above corresponds to:

(if (enabled)
  (println "Enabled")
  (do
    (println "Disabled")
    (println "Try enabling it")))

To read the value of the variable enabled, use if enabled rather than if {enabled}: the braces make {enabled} a zero-argument function call, equivalent to Lispico (enabled). Inside a condition block, use {id enabled} if a variable reference must be explicitly grouped.

See examples/conditionals.confetti and examples/conditionals-root.confetti for executable examples of both condition forms, sequences, and chains.

While loops

while is a Lispico evaluator special form. Confetti accepts the same inline single-value and homogeneous infix conditions as if, but an explicit sequence body uses do, never then:

var "counter" 0
while counter < 1_000_000 do {
  counter = {counter + 1}
}

This translates into:

(while (< counter 1_000_000)
  (do
    (set "counter" (+ counter 1))))

A condition requiring a Confetti block can be followed by a separate do { … } directive, just like the blocked-condition form of if:

while {counter < 10} do {
  counter = {counter + 1}
}

An explicit do always translates into a Lispico (do …) scope, even for a single expression or an empty block. The translator does not remove or infer scopes based on the number of expressions. Lispico’s loop implementation additionally provides an implicit scope per iteration.

Without do, ordinary Confetti function-call argument rules apply:

while {
  counter < 10
  counter = {counter + 1}
}
while false 123

These translate into (while (< counter 10) (set "counter" (+ counter 1))) and (while false 123) respectively, with no explicit (do) inserted. The condition is evaluated before each iteration, and the body is evaluated only when it is true. Lispico’s (break), (break N), and (return) work within loop bodies according to their normal control-flow semantics.

See examples/while.confetti for all these forms and a loop inside a function.

Development environment

direnv example

Create .envrc:

use nix --arg useLocalSubmodules true

Local Vim configuration example

se cc=81,101 tw=100

" Prevent *.h files from being detected as C++
augroup force_c_headers
  autocmd!
  autocmd BufReadPost,BufNewFile *.h setlocal filetype=c
augroup END

" Use Nginx syntax highlighting for Confetti files
augroup force_confetti_syntax_hl
  autocmd!
  autocmd BufReadPost,BufNewFile *.confetti setlocal filetype=nginx
augroup END

let g:ale_linters_explicit = 1
let g:ale_linters = {'c': ['cc'], 'sh': ['shellcheck']}
let g:ale_c_cc_executable = 'gcc'
let g:ale_c_cc_options = '-std=c23 -Wall -Wextra -Wpedantic -Wno-pragma-once-outside-header'

" GCC checker that uses the source file’s directory as its working directory.
" For correct resolution of included headers with relative paths.
call ale#linter#Define('c', {
\ 'name': 'lispico_confetti_cc',
\ 'output_stream': 'stderr',
\ 'executable': function('ale_linters#c#cc#GetExecutable'),
\ 'command': {b -> ale#c#RunMakeCommand(b, function('ale_linters#c#cc#GetCommand'))},
\ 'cwd': {b -> fnamemodify(bufname(b), ':p:h')},
\ 'callback': 'ale#handlers#gcc#HandleGCCFormatWithIncludes',
\})

" Use this checker only for Lispico Confetti’s own C sources.
augroup lispico_confetti_ale
  autocmd!
  autocmd BufReadPost,BufNewFile */lispico-confetti/src/*.c
    \ let b:ale_linters = ['lispico_confetti_cc']
augroup END

License

SPDX: MIT

All files in this repository (apart from third-party dependencies) are licensed under MIT.

About

An alternative syntax for Lispico, powered by the Confetti parser.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Contributors

Languages