A language server for Bjolang
Runs the compiler in-process against the Bjolang checkout beside it, and
answers diagnostics, an outline, go to definition, hover and completion,
plus a request of its own for macro expansion.
Diagnostics come from the compiler's own check of the editor's text,
saved or not: on open, on save, and 400 ms after typing pauses. The
outline, definitions, hovers and completions read only as far as the
reader, with no type checking, so they answer on every request: the
top-level names of the file, its imports and the prelude, local names
from the binding forms the parser knows, the declarations and docs as
written, and the builtins with their types. emacs/bjolang-lsp.el shows a
macro call's expansion, one step or all of it, in a buffer.
test/smoke.py drives the server as an editor would.
🤖 Generated with [ECA](https://eca.dev)
Co-Authored-By: eca-agent <git@eca.dev>
2026-10-15 22:38:22 +02:00
|
|
|
# BjolangLsp
|
|
|
|
|
|
A project's packages, and diagnostics at their column
A file in a project is checked against the packages bjo fetched for it:
the server installs the project's .bjo/roots, .bjo/frameworks and
.bjo/nuget/root before its first check, through the compiler's
ProjectInputs, so imports from packages check and definition, hover and
completion reach them. A server serves one project, the first file's; a
warning on a file's first line says when it cannot serve one as bjo
would: packages not fetched, the roots changed since it started, or
another project.
The server no longer has the old Microsoft.Extensions.DependencyInjection
.Abstractions next to it. The compiler excludes it, the exclusion does
not pass through a project reference, and with it there every ASP.NET
type failed to load, so bjoweb did not check.
A diagnostic marks the form at the line and column the compiler names
now: an atom or a string whole, a bracketed form to its closing bracket,
and one over several lines as far as its head.
The build no longer asks git for Source Link, which fails on this
repository's SHA-256 objects.
🤖 Generated with [ECA](https://eca.dev) (anthropic/claude-opus-5-5)
Co-Authored-By: eca-agent <git@eca.dev>
2026-10-20 19:30:50 +02:00
|
|
|
A language server for Bjolang. It checks a file against its project's
|
Rename, and a hover that leads with the type
textDocument/rename and prepareRename rename a local binding, or a
top-level def or defun the module does not export, with its signature,
doc and the files the module includes; a parameter's (arg ...) in its
function's doc goes with it. A rename that could change what the program
means is refused with the reason: a capture, a keyword parameter, an
exported or foreign name, a name that is not one. The renamed text is
checked first, and one with an error the text before did not have is
refused with it.
A hover's first line, which is what the status bar shows, is the type: a
nameless (: Type) above a definition is found and shown with the name, and
a definition with no signature in the file being edited shows the type the
compiler inferred.
🤖 Generated with [ECA](https://eca.dev)
Co-Authored-By: eca-agent <git@eca.dev>
2026-10-22 16:36:22 +02:00
|
|
|
packages (see "Projects"). Inferred types and renaming have sections of
|
|
|
|
|
their own below; besides those, it does these:
|
A language server for Bjolang
Runs the compiler in-process against the Bjolang checkout beside it, and
answers diagnostics, an outline, go to definition, hover and completion,
plus a request of its own for macro expansion.
Diagnostics come from the compiler's own check of the editor's text,
saved or not: on open, on save, and 400 ms after typing pauses. The
outline, definitions, hovers and completions read only as far as the
reader, with no type checking, so they answer on every request: the
top-level names of the file, its imports and the prelude, local names
from the binding forms the parser knows, the declarations and docs as
written, and the builtins with their types. emacs/bjolang-lsp.el shows a
macro call's expansion, one step or all of it, in a buffer.
test/smoke.py drives the server as an editor would.
🤖 Generated with [ECA](https://eca.dev)
Co-Authored-By: eca-agent <git@eca.dev>
2026-10-15 22:38:22 +02:00
|
|
|
|
|
|
|
|
- Diagnostics: it checks a file with the compiler's frontend, as
|
|
|
|
|
`bjolang --check` does, and sends the errors and warnings to the editor.
|
|
|
|
|
It checks the editor's text, saved or not: when a file is opened or
|
|
|
|
|
saved, and 400 ms after typing pauses. Every open file is read from its
|
A project's packages, and diagnostics at their column
A file in a project is checked against the packages bjo fetched for it:
the server installs the project's .bjo/roots, .bjo/frameworks and
.bjo/nuget/root before its first check, through the compiler's
ProjectInputs, so imports from packages check and definition, hover and
completion reach them. A server serves one project, the first file's; a
warning on a file's first line says when it cannot serve one as bjo
would: packages not fetched, the roots changed since it started, or
another project.
The server no longer has the old Microsoft.Extensions.DependencyInjection
.Abstractions next to it. The compiler excludes it, the exclusion does
not pass through a project reference, and with it there every ASP.NET
type failed to load, so bjoweb did not check.
A diagnostic marks the form at the line and column the compiler names
now: an atom or a string whole, a bracketed form to its closing bracket,
and one over several lines as far as its head.
The build no longer asks git for Source Link, which fails on this
repository's SHA-256 objects.
🤖 Generated with [ECA](https://eca.dev) (anthropic/claude-opus-5-5)
Co-Authored-By: eca-agent <git@eca.dev>
2026-10-20 19:30:50 +02:00
|
|
|
buffer, so an unsaved include or `.bjodoc` counts too. A diagnostic marks
|
|
|
|
|
the form at the line and column the compiler names: an atom or a string
|
|
|
|
|
whole, a bracketed form to its closing bracket, and one over several lines
|
|
|
|
|
as far as its head, `(defun` or `(match`.
|
A language server for Bjolang
Runs the compiler in-process against the Bjolang checkout beside it, and
answers diagnostics, an outline, go to definition, hover and completion,
plus a request of its own for macro expansion.
Diagnostics come from the compiler's own check of the editor's text,
saved or not: on open, on save, and 400 ms after typing pauses. The
outline, definitions, hovers and completions read only as far as the
reader, with no type checking, so they answer on every request: the
top-level names of the file, its imports and the prelude, local names
from the binding forms the parser knows, the declarations and docs as
written, and the builtins with their types. emacs/bjolang-lsp.el shows a
macro call's expansion, one step or all of it, in a buffer.
test/smoke.py drives the server as an editor would.
🤖 Generated with [ECA](https://eca.dev)
Co-Authored-By: eca-agent <git@eca.dev>
2026-10-15 22:38:22 +02:00
|
|
|
- An outline (`textDocument/documentSymbol`): the file's top-level
|
|
|
|
|
definitions, with a type's constructors or fields, a trait's methods and an
|
|
|
|
|
`impl`'s functions under them.
|
|
|
|
|
- Go to definition (`textDocument/definition`): a local name goes to where
|
|
|
|
|
it is bound, the innermost binding of it; a top-level name to the file's
|
|
|
|
|
own definition, else one in a module it imports or includes, searched
|
|
|
|
|
nearest first, and then the prelude.
|
References, and code actions that add a match's clauses and fill holes
textDocument/references and documentHighlight give the uses of the name
at point in its module, found as go to definition finds a binding: a
local, a top-level definition, a type or a constructor, or an imported
name where the module uses it. Uses.fs holds the search, which Rename
now shares.
textDocument/codeAction offers what the compiler worked out while it
checked (Exhaustiveness.observe, Holes.observe, kept by Fixes.fs): at an
incomplete match, the clauses it lacks, lined up after its last clause
with holes as bodies; at a typed hole, a binding in scope that fits, a
constructor of its type with holes for what it takes, or a fun.
Version 0.7.0.
🤖 Generated with [ECA](https://eca.dev)
Co-Authored-By: eca-agent <git@eca.dev>
2026-10-22 20:34:41 +02:00
|
|
|
- References (`textDocument/references`) and highlights
|
|
|
|
|
(`textDocument/documentHighlight`): the uses of the name at point in its
|
|
|
|
|
module, its own file and what that includes. A use is a symbol the name
|
|
|
|
|
means there, found as go to definition finds a binding, so a shadowing
|
|
|
|
|
local of the same name, quoted data and a `#'` template's own names are
|
|
|
|
|
not uses. Any name has them: a local, a top-level definition, a type or a
|
|
|
|
|
constructor, and an imported name or a builtin, where this module uses it.
|
|
|
|
|
Uses in other modules are not looked for. A highlight marks the binding
|
|
|
|
|
or definition as a write and the rest as reads.
|
A language server for Bjolang
Runs the compiler in-process against the Bjolang checkout beside it, and
answers diagnostics, an outline, go to definition, hover and completion,
plus a request of its own for macro expansion.
Diagnostics come from the compiler's own check of the editor's text,
saved or not: on open, on save, and 400 ms after typing pauses. The
outline, definitions, hovers and completions read only as far as the
reader, with no type checking, so they answer on every request: the
top-level names of the file, its imports and the prelude, local names
from the binding forms the parser knows, the declarations and docs as
written, and the builtins with their types. emacs/bjolang-lsp.el shows a
macro call's expansion, one step or all of it, in a buffer.
test/smoke.py drives the server as an editor would.
🤖 Generated with [ECA](https://eca.dev)
Co-Authored-By: eca-agent <git@eca.dev>
2026-10-15 22:38:22 +02:00
|
|
|
- Hover (`textDocument/hover`) for the same names. A top-level name shows
|
|
|
|
|
the `(: name Type)` declaration and the definition's head as written, then
|
|
|
|
|
its doc from the module's `(:doc ...)` forms and `.bjodoc` files, with the
|
|
|
|
|
doc markup (`@code`, `@strong`, `@em`, `@itemlist`) as Markdown. A
|
|
|
|
|
constructor or a field shows its type's doc, with its own `case` or
|
|
|
|
|
`field` line. A builtin, which the compiler defines rather than a module,
|
|
|
|
|
shows its type and its doc from the prelude's docs. A local name shows
|
|
|
|
|
its binding as written, a typed parameter with its type, and what binds
|
2026-10-22 12:58:19 +02:00
|
|
|
it. A hover also shows the types the compiler inferred (see "Inferred
|
|
|
|
|
types").
|
A language server for Bjolang
Runs the compiler in-process against the Bjolang checkout beside it, and
answers diagnostics, an outline, go to definition, hover and completion,
plus a request of its own for macro expansion.
Diagnostics come from the compiler's own check of the editor's text,
saved or not: on open, on save, and 400 ms after typing pauses. The
outline, definitions, hovers and completions read only as far as the
reader, with no type checking, so they answer on every request: the
top-level names of the file, its imports and the prelude, local names
from the binding forms the parser knows, the declarations and docs as
written, and the builtins with their types. emacs/bjolang-lsp.el shows a
macro call's expansion, one step or all of it, in a buffer.
test/smoke.py drives the server as an editor would.
🤖 Generated with [ECA](https://eca.dev)
Co-Authored-By: eca-agent <git@eca.dev>
2026-10-15 22:38:22 +02:00
|
|
|
- Completion (`textDocument/completion`): the local names in scope, then
|
|
|
|
|
the top-level names of the file and of every module it sees, the
|
|
|
|
|
builtins, and the special forms, each name once and the nearest first. An
|
|
|
|
|
item replaces the whole word before the cursor, as the lexer reads a word,
|
|
|
|
|
so `string->` is one. Its doc is the hover's, sent along for a local and
|
|
|
|
|
when the client asks for anything else (`completionItem/resolve`).
|
|
|
|
|
Nothing is offered in a comment or a string.
|
|
|
|
|
|
|
|
|
|
And one request of its own, `bjolang/expandMacro`: the expansion of the
|
|
|
|
|
macro call at a position, one step or all the way down, from the last check
|
|
|
|
|
of the file, which runs first if a change is waiting for it. The compiler
|
|
|
|
|
reports each expansion it makes through `Macro.observe` while it checks, so
|
|
|
|
|
an expansion costs nothing beyond the check. Names hygiene renamed are shown
|
|
|
|
|
as the template wrote them, unless `hygienic` asks for the renamed ones.
|
|
|
|
|
`loop`, `seql`, `->`, `defun` and the parser's other forms are not macros,
|
|
|
|
|
and have no expansion.
|
|
|
|
|
|
|
|
|
|
The outline, definitions, hovers and completions read only as far as the
|
|
|
|
|
reader: no macro is expanded and nothing is type checked, so they answer on
|
|
|
|
|
every request. A form being typed is read as if it were closed; text that
|
|
|
|
|
does not read even so leaves the last outline in place.
|
|
|
|
|
|
2026-10-22 12:58:19 +02:00
|
|
|
## Inferred types
|
|
|
|
|
|
|
|
|
|
A check keeps what the compiler inferred: the compiler hands each program it
|
|
|
|
|
type checked to `Inference.observe`, and `Types.fs` reads the names in it
|
|
|
|
|
with their types. A hover then shows
|
|
|
|
|
|
|
|
|
|
- for a local name, `(: name type)` above its binding: a parameter written
|
|
|
|
|
without a type, a `let` binding, a `fun`'s parameter, a pattern's
|
|
|
|
|
variable, a loop variable, a local `defun`;
|
|
|
|
|
- for a use of a generic function, the type it has there, under "At this
|
|
|
|
|
use": `list-map` at the types of the list it is given.
|
|
|
|
|
|
|
|
|
|
The types are those of the last check. A hover runs a check that is due
|
|
|
|
|
first, so that they are of the text as it stands. A declaration that does
|
|
|
|
|
not check has no types until it does; the others keep theirs.
|
|
|
|
|
|
|
|
|
|
Inlay hints (`textDocument/inlayHint`) show the same types in the text,
|
|
|
|
|
after each local name where it is bound, where no type is written:
|
|
|
|
|
`(let ((n: int (length xs))) ...)`. A top-level function's parameters have
|
|
|
|
|
none, as its signature above it says their types. A long type is cut short,
|
|
|
|
|
and its tooltip is the whole of it.
|
|
|
|
|
|
|
|
|
|
An editor asks for hints as the text changes, before the check of the
|
|
|
|
|
change has run. The hints before the first change since the last check are
|
|
|
|
|
where they were and are sent; the ones after it wait for the check. When it
|
|
|
|
|
has run, the server asks the editor to ask again
|
|
|
|
|
(`workspace/inlayHint/refresh`), if the editor says it can be asked.
|
|
|
|
|
|
A language server for Bjolang
Runs the compiler in-process against the Bjolang checkout beside it, and
answers diagnostics, an outline, go to definition, hover and completion,
plus a request of its own for macro expansion.
Diagnostics come from the compiler's own check of the editor's text,
saved or not: on open, on save, and 400 ms after typing pauses. The
outline, definitions, hovers and completions read only as far as the
reader, with no type checking, so they answer on every request: the
top-level names of the file, its imports and the prelude, local names
from the binding forms the parser knows, the declarations and docs as
written, and the builtins with their types. emacs/bjolang-lsp.el shows a
macro call's expansion, one step or all of it, in a buffer.
test/smoke.py drives the server as an editor would.
🤖 Generated with [ECA](https://eca.dev)
Co-Authored-By: eca-agent <git@eca.dev>
2026-10-15 22:38:22 +02:00
|
|
|
Local names are the ones the parser's own forms bind: parameters of a
|
|
|
|
|
`defun`, `fun` and the other `def…` heads, `let`, `let*`, `letrec`,
|
|
|
|
|
`let/mono`, named `let` and `with-open` bindings, `with-return`, `match`
|
|
|
|
|
patterns, the clauses of `loop`, `seql` and a comprehension, and `def` or
|
|
|
|
|
`defun` inside a body, for the forms after it.
|
|
|
|
|
|
Rename, and a hover that leads with the type
textDocument/rename and prepareRename rename a local binding, or a
top-level def or defun the module does not export, with its signature,
doc and the files the module includes; a parameter's (arg ...) in its
function's doc goes with it. A rename that could change what the program
means is refused with the reason: a capture, a keyword parameter, an
exported or foreign name, a name that is not one. The renamed text is
checked first, and one with an error the text before did not have is
refused with it.
A hover's first line, which is what the status bar shows, is the type: a
nameless (: Type) above a definition is found and shown with the name, and
a definition with no signature in the file being edited shows the type the
compiler inferred.
🤖 Generated with [ECA](https://eca.dev)
Co-Authored-By: eca-agent <git@eca.dev>
2026-10-22 16:36:22 +02:00
|
|
|
## Rename
|
|
|
|
|
|
|
|
|
|
`textDocument/rename`, with `textDocument/prepareRename` so that the editor
|
|
|
|
|
says why a name cannot be renamed before a new one is typed. It renames
|
|
|
|
|
|
|
|
|
|
- a local binding: a parameter, a `let`, a `def` or `defun` in a body, a
|
|
|
|
|
pattern's variable, a loop variable or accumulator. A parameter of a
|
|
|
|
|
top-level function is renamed in its `(:doc ...)` too, in `(arg ...)` and
|
|
|
|
|
`(rest ...)`;
|
|
|
|
|
- a top-level `def` or `defun` the module does not export, with its
|
|
|
|
|
signature, its `(:doc ...)` and its other mentions, in the files the module
|
|
|
|
|
includes as well.
|
|
|
|
|
|
|
|
|
|
The places are the ones go to definition would take to the binding: every
|
|
|
|
|
symbol of that name that means it, in an interpolated string's `${...}`
|
|
|
|
|
too. Quoted data, the names of a `#'` template that are not unquoted, and a
|
|
|
|
|
type's declaration are left.
|
|
|
|
|
|
|
|
|
|
It is refused, with what the editor shows as the reason, where it could
|
|
|
|
|
change what the program means:
|
|
|
|
|
|
|
|
|
|
- the new name would take a use from another binding: a binding of it
|
|
|
|
|
inside the renamed one's scope, or a use of it there;
|
|
|
|
|
- a keyword parameter, as callers write its name as `#:name`;
|
|
|
|
|
- an exported name, a macro, `main`, and a name defined elsewhere;
|
|
|
|
|
- a new name that is not one symbol, starts with an upper case letter, or
|
|
|
|
|
has a `.`;
|
|
|
|
|
- a new name the module already sees, for a top-level definition.
|
|
|
|
|
|
|
|
|
|
Before it answers, the server checks the renamed text. A renamed program
|
|
|
|
|
with an error the program before it did not have is refused, with the
|
|
|
|
|
error: `(defun (twice s) ...)` renamed to `when` makes `(twice v)` the
|
|
|
|
|
special form.
|
|
|
|
|
|
References, and code actions that add a match's clauses and fill holes
textDocument/references and documentHighlight give the uses of the name
at point in its module, found as go to definition finds a binding: a
local, a top-level definition, a type or a constructor, or an imported
name where the module uses it. Uses.fs holds the search, which Rename
now shares.
textDocument/codeAction offers what the compiler worked out while it
checked (Exhaustiveness.observe, Holes.observe, kept by Fixes.fs): at an
incomplete match, the clauses it lacks, lined up after its last clause
with holes as bodies; at a typed hole, a binding in scope that fits, a
constructor of its type with holes for what it takes, or a fun.
Version 0.7.0.
🤖 Generated with [ECA](https://eca.dev)
Co-Authored-By: eca-agent <git@eca.dev>
2026-10-22 20:34:41 +02:00
|
|
|
## Code actions
|
|
|
|
|
|
|
|
|
|
`textDocument/codeAction` offers two kinds of quick fix, both worked out by
|
|
|
|
|
the compiler while it checks and handed over through
|
|
|
|
|
`Exhaustiveness.observe` and `Holes.observe` (`Fixes.fs`):
|
|
|
|
|
|
|
|
|
|
- At a match that does not cover every value: add the clauses it lacks,
|
|
|
|
|
after its last clause and lined up with it, each with a hole for its
|
|
|
|
|
body: `((Square _) _)`. They are found one missing value at a time, so
|
|
|
|
|
that together they cover what the match does not, nested cases spelled
|
|
|
|
|
out, `((Some (Square _)) _)`. A value of an integer or a char, or a vec of
|
|
|
|
|
one length, is widened to all of them; past 20 clauses a `_` takes the
|
|
|
|
|
rest.
|
|
|
|
|
- At a typed hole: fill it with a binding in scope that fits it, as the
|
|
|
|
|
hole's message ranks them (the first twelve); with a constructor of its
|
|
|
|
|
type, with holes for what it takes, `(Circle _)`, or a record with each of
|
|
|
|
|
its fields; or, for a function type, with `(fun (x y) _)`.
|
|
|
|
|
|
|
|
|
|
A hole in what was written is a new hole for the next check, so a fix is a
|
|
|
|
|
step: the clauses' bodies are holes, and each says what it has to be. The
|
|
|
|
|
actions are of the file's last check, which a check that is due replaces
|
|
|
|
|
first, as for a hover, and only of text that is still what it checked.
|
|
|
|
|
|
A language server for Bjolang
Runs the compiler in-process against the Bjolang checkout beside it, and
answers diagnostics, an outline, go to definition, hover and completion,
plus a request of its own for macro expansion.
Diagnostics come from the compiler's own check of the editor's text,
saved or not: on open, on save, and 400 ms after typing pauses. The
outline, definitions, hovers and completions read only as far as the
reader, with no type checking, so they answer on every request: the
top-level names of the file, its imports and the prelude, local names
from the binding forms the parser knows, the declarations and docs as
written, and the builtins with their types. emacs/bjolang-lsp.el shows a
macro call's expansion, one step or all of it, in a buffer.
test/smoke.py drives the server as an editor would.
🤖 Generated with [ECA](https://eca.dev)
Co-Authored-By: eca-agent <git@eca.dev>
2026-10-15 22:38:22 +02:00
|
|
|
## Building
|
|
|
|
|
|
|
|
|
|
It expects the Bjolang checkout beside this one, at `../Bjolang`, and runs
|
|
|
|
|
that compiler in-process through a project reference.
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
(cd ../Bjolang && ./build_compiler.sh && ./build_std.sh)
|
|
|
|
|
dotnet build -c Release
|
|
|
|
|
test/smoke.py
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
The server is `bin/Release/net10.0/BjolangLsp.dll`, started as
|
|
|
|
|
`dotnet bin/Release/net10.0/BjolangLsp.dll`. It talks LSP on stdin and
|
|
|
|
|
stdout, and logs to stderr.
|
|
|
|
|
|
A project's packages, and diagnostics at their column
A file in a project is checked against the packages bjo fetched for it:
the server installs the project's .bjo/roots, .bjo/frameworks and
.bjo/nuget/root before its first check, through the compiler's
ProjectInputs, so imports from packages check and definition, hover and
completion reach them. A server serves one project, the first file's; a
warning on a file's first line says when it cannot serve one as bjo
would: packages not fetched, the roots changed since it started, or
another project.
The server no longer has the old Microsoft.Extensions.DependencyInjection
.Abstractions next to it. The compiler excludes it, the exclusion does
not pass through a project reference, and with it there every ASP.NET
type failed to load, so bjoweb did not check.
A diagnostic marks the form at the line and column the compiler names
now: an atom or a string whole, a bracketed form to its closing bracket,
and one over several lines as far as its head.
The build no longer asks git for Source Link, which fails on this
repository's SHA-256 objects.
🤖 Generated with [ECA](https://eca.dev) (anthropic/claude-opus-5-5)
Co-Authored-By: eca-agent <git@eca.dev>
2026-10-20 19:30:50 +02:00
|
|
|
## Projects
|
|
|
|
|
|
|
|
|
|
A file in a project, a directory with a `manifest.bjodat` at or above it, is
|
|
|
|
|
checked against the project's packages, as `bjo` compiles it: the roots file
|
|
|
|
|
`.bjo/roots` that says where each package is, `.bjo/frameworks` for the .NET
|
|
|
|
|
shared frameworks the packages declared, and `.bjo/nuget/root` for restored
|
|
|
|
|
NuGet packages. `bjo` writes them; `bjo fetch` is enough. Imports from the
|
|
|
|
|
packages then check, and go to definition, hover and completion reach them.
|
|
|
|
|
|
|
|
|
|
A compiler process serves one roots file, so a server serves the project of
|
|
|
|
|
the first file it is asked about, from start to exit. A warning on the first
|
|
|
|
|
line of a file says when it cannot serve that file as the command line
|
|
|
|
|
would:
|
|
|
|
|
|
|
|
|
|
- the project's packages are not fetched yet: run `bjo fetch`, then restart
|
|
|
|
|
the server;
|
|
|
|
|
- the roots file changed after the server started, as `bjo fetch` after a
|
|
|
|
|
change to the manifest does: restart the server;
|
|
|
|
|
- the file is in another project than the one the server serves: open it in
|
|
|
|
|
a server of its own, which lsp-mode and eglot do per project root.
|
|
|
|
|
|
A language server for Bjolang
Runs the compiler in-process against the Bjolang checkout beside it, and
answers diagnostics, an outline, go to definition, hover and completion,
plus a request of its own for macro expansion.
Diagnostics come from the compiler's own check of the editor's text,
saved or not: on open, on save, and 400 ms after typing pauses. The
outline, definitions, hovers and completions read only as far as the
reader, with no type checking, so they answer on every request: the
top-level names of the file, its imports and the prelude, local names
from the binding forms the parser knows, the declarations and docs as
written, and the builtins with their types. emacs/bjolang-lsp.el shows a
macro call's expansion, one step or all of it, in a buffer.
test/smoke.py drives the server as an editor would.
🤖 Generated with [ECA](https://eca.dev)
Co-Authored-By: eca-agent <git@eca.dev>
2026-10-15 22:38:22 +02:00
|
|
|
## How it finds things
|
|
|
|
|
|
|
|
|
|
- The standard library and the runtime: through the checkout path baked in
|
|
|
|
|
at build time. `BJOLANG_HOME` overrides it.
|
|
|
|
|
- Staleness: an imported module is judged against the installed compiler,
|
|
|
|
|
`../Bjolang/bin/compiler/Bjolang.dll`, not against the server's own copy of
|
|
|
|
|
the compiler, and a stale import is built by running that compiler. Built
|
|
|
|
|
by the server, its build record would name the server, and the command line
|
|
|
|
|
would build it again.
|
|
|
|
|
- Unsaved text: the compiler reads a source file through
|
|
|
|
|
`Paths.readSource`, and the server hands it the open buffers in
|
|
|
|
|
`Paths.sourceOverrides` for the length of a check.
|
|
|
|
|
|
|
|
|
|
## Emacs (Doom, lsp-mode)
|
|
|
|
|
|
|
|
|
|
```elisp
|
|
|
|
|
(after! lsp-mode
|
|
|
|
|
(add-to-list 'lsp-language-id-configuration '(bjo-mode . "bjolang"))
|
|
|
|
|
(lsp-register-client
|
|
|
|
|
(make-lsp-client
|
|
|
|
|
:new-connection (lsp-stdio-connection
|
|
|
|
|
'("dotnet" "/home/linis/Programmering/BjolangLsp/bin/Release/net10.0/BjolangLsp.dll"))
|
|
|
|
|
:activation-fn (lsp-activate-on "bjolang")
|
|
|
|
|
:server-id 'bjolang-lsp)))
|
|
|
|
|
|
|
|
|
|
(add-hook 'bjo-mode-hook #'lsp)
|
|
|
|
|
```
|
|
|
|
|
|
2026-10-22 12:58:19 +02:00
|
|
|
lsp-mode shows inlay hints only when asked to:
|
|
|
|
|
|
|
|
|
|
```elisp
|
|
|
|
|
(setq lsp-inlay-hint-enable t)
|
|
|
|
|
```
|
|
|
|
|
|
2026-10-16 09:35:25 +02:00
|
|
|
`emacs/bjolang-dape.el` debugs a program with `dape` and
|
|
|
|
|
[netcoredbg](https://github.com/Samsung/netcoredbg/releases):
|
|
|
|
|
|
|
|
|
|
```elisp
|
|
|
|
|
(load "/home/linis/Programmering/BjolangLsp/emacs/bjolang-dape.el")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
`M-x dape RET bjolang RET` in a file with a `main` builds it with `-d` and
|
|
|
|
|
runs it under the debugger. Breakpoints in the `.bjo` file bind, stepping
|
|
|
|
|
goes by its lines, and the call stack names them. The locals are the
|
|
|
|
|
generated C#'s, compiler temporaries included, and values show as their C#
|
|
|
|
|
types, which expand into their fields.
|
|
|
|
|
|
A language server for Bjolang
Runs the compiler in-process against the Bjolang checkout beside it, and
answers diagnostics, an outline, go to definition, hover and completion,
plus a request of its own for macro expansion.
Diagnostics come from the compiler's own check of the editor's text,
saved or not: on open, on save, and 400 ms after typing pauses. The
outline, definitions, hovers and completions read only as far as the
reader, with no type checking, so they answer on every request: the
top-level names of the file, its imports and the prelude, local names
from the binding forms the parser knows, the declarations and docs as
written, and the builtins with their types. emacs/bjolang-lsp.el shows a
macro call's expansion, one step or all of it, in a buffer.
test/smoke.py drives the server as an editor would.
🤖 Generated with [ECA](https://eca.dev)
Co-Authored-By: eca-agent <git@eca.dev>
2026-10-15 22:38:22 +02:00
|
|
|
With eglot instead:
|
|
|
|
|
|
|
|
|
|
```elisp
|
|
|
|
|
(add-to-list 'eglot-server-programs
|
|
|
|
|
'(bjo-mode . ("dotnet" "/home/linis/Programmering/BjolangLsp/bin/Release/net10.0/BjolangLsp.dll")))
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## What it does not do yet
|
|
|
|
|
|
A project's packages, and diagnostics at their column
A file in a project is checked against the packages bjo fetched for it:
the server installs the project's .bjo/roots, .bjo/frameworks and
.bjo/nuget/root before its first check, through the compiler's
ProjectInputs, so imports from packages check and definition, hover and
completion reach them. A server serves one project, the first file's; a
warning on a file's first line says when it cannot serve one as bjo
would: packages not fetched, the roots changed since it started, or
another project.
The server no longer has the old Microsoft.Extensions.DependencyInjection
.Abstractions next to it. The compiler excludes it, the exclusion does
not pass through a project reference, and with it there every ASP.NET
type failed to load, so bjoweb did not check.
A diagnostic marks the form at the line and column the compiler names
now: an atom or a string whole, a bracketed form to its closing bracket,
and one over several lines as far as its head.
The build no longer asks git for Source Link, which fails on this
repository's SHA-256 objects.
🤖 Generated with [ECA](https://eca.dev) (anthropic/claude-opus-5-5)
Co-Authored-By: eca-agent <git@eca.dev>
2026-10-20 19:30:50 +02:00
|
|
|
- Exact ends. The compiler says where a diagnostic starts, and the form that
|
|
|
|
|
starts there is marked, as far as its head when it spans several lines.
|
|
|
|
|
That is the form the message is about in most cases, not in all.
|
A language server for Bjolang
Runs the compiler in-process against the Bjolang checkout beside it, and
answers diagnostics, an outline, go to definition, hover and completion,
plus a request of its own for macro expansion.
Diagnostics come from the compiler's own check of the editor's text,
saved or not: on open, on save, and 400 ms after typing pauses. The
outline, definitions, hovers and completions read only as far as the
reader, with no type checking, so they answer on every request: the
top-level names of the file, its imports and the prelude, local names
from the binding forms the parser knows, the declarations and docs as
written, and the builtins with their types. emacs/bjolang-lsp.el shows a
macro call's expansion, one step or all of it, in a buffer.
test/smoke.py drives the server as an editor would.
🤖 Generated with [ECA](https://eca.dev)
Co-Authored-By: eca-agent <git@eca.dev>
2026-10-15 22:38:22 +02:00
|
|
|
- A check of a large file waits for the requests before it, and they for it:
|
|
|
|
|
everything that touches the compiler runs on one thread, because the
|
|
|
|
|
compiler's state is global.
|
|
|
|
|
- Names a macro binds, at top level or locally. A loop variable is taken to
|
|
|
|
|
be in scope across its whole loop, which is wider than the loop allows.
|
|
|
|
|
- Which definition. A name defined in two imported modules goes to the
|
|
|
|
|
nearer one, which is not always the one the compiler would pick, and a
|
|
|
|
|
module the file does not export from is searched like one it does.
|
|
|
|
|
- Errors in another file. A diagnostic located in an imported or included
|
|
|
|
|
file is shown on the first line of the file being checked, with its
|
|
|
|
|
location in the message.
|
|
|
|
|
- Hover for a special form (`record-ref`, `loop`, `match`), which has no
|
|
|
|
|
definition to find and no doc.
|
2026-10-22 14:03:56 +02:00
|
|
|
- The type of an expression that is not a name.
|
A language server for Bjolang
Runs the compiler in-process against the Bjolang checkout beside it, and
answers diagnostics, an outline, go to definition, hover and completion,
plus a request of its own for macro expansion.
Diagnostics come from the compiler's own check of the editor's text,
saved or not: on open, on save, and 400 ms after typing pauses. The
outline, definitions, hovers and completions read only as far as the
reader, with no type checking, so they answer on every request: the
top-level names of the file, its imports and the prelude, local names
from the binding forms the parser knows, the declarations and docs as
written, and the builtins with their types. emacs/bjolang-lsp.el shows a
macro call's expansion, one step or all of it, in a buffer.
test/smoke.py drives the server as an editor would.
🤖 Generated with [ECA](https://eca.dev)
Co-Authored-By: eca-agent <git@eca.dev>
2026-10-15 22:38:22 +02:00
|
|
|
- Completion of record fields after `record-ref`, of module paths in an
|
|
|
|
|
`import`, or of keyword arguments. A string that began on an earlier line
|
|
|
|
|
is not seen as one, so a multi-line string gets completions.
|
Rename, and a hover that leads with the type
textDocument/rename and prepareRename rename a local binding, or a
top-level def or defun the module does not export, with its signature,
doc and the files the module includes; a parameter's (arg ...) in its
function's doc goes with it. A rename that could change what the program
means is refused with the reason: a capture, a keyword parameter, an
exported or foreign name, a name that is not one. The renamed text is
checked first, and one with an error the text before did not have is
refused with it.
A hover's first line, which is what the status bar shows, is the type: a
nameless (: Type) above a definition is found and shown with the name, and
a definition with no signature in the file being edited shows the type the
compiler inferred.
🤖 Generated with [ECA](https://eca.dev)
Co-Authored-By: eca-agent <git@eca.dev>
2026-10-22 16:36:22 +02:00
|
|
|
- Find references, and renaming an exported name, a keyword parameter, a
|
|
|
|
|
type, a constructor, a field or a trait method (see "Rename").
|
A project's packages, and diagnostics at their column
A file in a project is checked against the packages bjo fetched for it:
the server installs the project's .bjo/roots, .bjo/frameworks and
.bjo/nuget/root before its first check, through the compiler's
ProjectInputs, so imports from packages check and definition, hover and
completion reach them. A server serves one project, the first file's; a
warning on a file's first line says when it cannot serve one as bjo
would: packages not fetched, the roots changed since it started, or
another project.
The server no longer has the old Microsoft.Extensions.DependencyInjection
.Abstractions next to it. The compiler excludes it, the exclusion does
not pass through a project reference, and with it there every ASP.NET
type failed to load, so bjoweb did not check.
A diagnostic marks the form at the line and column the compiler names
now: an atom or a string whole, a bracketed form to its closing bracket,
and one over several lines as far as its head.
The build no longer asks git for Source Link, which fails on this
repository's SHA-256 objects.
🤖 Generated with [ECA](https://eca.dev) (anthropic/claude-opus-5-5)
Co-Authored-By: eca-agent <git@eca.dev>
2026-10-20 19:30:50 +02:00
|
|
|
- More than one project. A server serves the project of the first file it is
|
|
|
|
|
asked about; see "Projects" above.
|
A language server for Bjolang
Runs the compiler in-process against the Bjolang checkout beside it, and
answers diagnostics, an outline, go to definition, hover and completion,
plus a request of its own for macro expansion.
Diagnostics come from the compiler's own check of the editor's text,
saved or not: on open, on save, and 400 ms after typing pauses. The
outline, definitions, hovers and completions read only as far as the
reader, with no type checking, so they answer on every request: the
top-level names of the file, its imports and the prelude, local names
from the binding forms the parser knows, the declarations and docs as
written, and the builtins with their types. emacs/bjolang-lsp.el shows a
macro call's expansion, one step or all of it, in a buffer.
test/smoke.py drives the server as an editor would.
🤖 Generated with [ECA](https://eca.dev)
Co-Authored-By: eca-agent <git@eca.dev>
2026-10-15 22:38:22 +02:00
|
|
|
- Stale imports are built by the installed compiler, which was tested only
|
|
|
|
|
for the standard library being current, not for a stale import.
|