Development Tools
Single-page view · as markdown
Checking and Formatting Programs
GCSL / Development Tools
You can check a GCSL program without running its effects, then format its source consistently. The checker and formatter deliberately have different scopes: checking needs workspace relationships; formatting only needs source text that parses.
Before you start #
You need gcsl and an existing source file or workspace. Commit or save
your changes before rewriting files so you can review the formatting diff.
Check and format #
-
Check a file, including its enclosing workspace if it has one:
-
Preview whether formatting would change that file:
-
Apply the formatter and repeat the check:
Check the result #
The checker reports its summary on standard error. Warnings alone do not make it fail. The final formatting check succeeds without listing the file when it is already formatted.
A file with lexical or syntax errors is left untouched by the formatter; fix those diagnostics and retry. Formatting does not require a successful type check. It uses one language style rather than editor-specific indent settings.
Checking a tree #
With no paths, both commands use the enclosing workspace and exclude
nested workspaces. An explicit directory makes them discover nested
workspaces too. However, gcsl check DIRECTORY checks workspaces, not
unattached .gcsl files under that directory. Pass each standalone file
explicitly when it also needs checking.
For automation, gcsl check --message-format json main.gcsl writes one
JSON diagnostic per line to standard output and keeps the summary on
standard error. See gcsl(1) for the schema and exit statuses.
Configuring an Editor
GCSL / Development Tools
The GCSL language server supplies diagnostics and navigation from the same checker that runs programs. You can use it in an editor that supports the Language Server Protocol (LSP) over standard input and standard output.
Before you start #
You need the following:
- An editor with configurable LSP support.
- The
gcslexecutable on the editor's command search path. - A GCSL file or workspace to open.
Connect the server #
- Associate files ending in
.gcslwith a GCSL language entry in your editor. - Set the server command to
gcsland its argument list to["lsp"]. Use standard input and standard output for transport. - Open a GCSL file. For a multifile project, open the workspace directory so the editor can supply file changes and watch notifications.
Check the result #
Hover over a declared name to see its type. Introduce a misspelled name and confirm that the editor displays a diagnostic. When an unambiguous spelling suggestion is available, a quick fix offers the replacement.
The server checks source but does not evaluate programs. It supports completion, signature help, inlay hints, formatting, symbol search, and references. Rename checks the proposed edits before returning them and refuses changes that introduce errors or change name resolution. It does not rename files, directories, or standard-library declarations.
Incomplete source #
The index retains useful information around many syntax errors. For an unbalanced block, a query can use a repaired copy to answer navigation or completion while diagnostics still describe the real text. Rename needs the real source to be valid enough to verify and can be refused instead.
Editor syntax highlighting is a separate integration. The grammar and
queries in tree-sitter-gcsl are maintained in their own repository; they
are not required for the gcsl lsp process to check your code.