Pascal for VS Code
Object Pascal language support for Free Pascal / Lazarus and Delphi, built around a
hand-written parser and a language server — so navigation, completion and diagnostics
work on real projects rather than on regular expressions.
Features
Navigation
- Go to Definition (
F12 / Ctrl+Click): on a call site or a declaration, jumps
straight to the implementation. On the implementation itself, jumps straight to its one
call site, or lists every call site (not the declaration) when there's more than one.
- Go to Implementation (
Ctrl+F12) lists the body plus every overriding method.
- Go to Super (
Ctrl+U) jumps from an override to the method it overrides.
- Toggle Declaration / Implementation (
Ctrl+Alt+Down).
- Find All References covers the prototype, the body and every call site.
- Hover shows a type's/routine's/variable's declared signature or type, including
builtins.
- Code lenses above declarations link to the implementation, the overridden method,
the overriding methods, and a type's descendants.
Editing
- Context-aware completion for classes, functions and variables — including members
after
. (own and inherited, from self. and any other expression), uses units and
{$ directives — with no noise from Pascal's own keywords.
- Signature help while typing a call's arguments, and inline parameter-name hints.
- Override methods (
Ctrl+Alt+O / Cmd+Alt+O, or the code lens above a class that
extends something; works anywhere the cursor is inside the class, not just on a member)
lists every ancestor method — including from implemented interfaces — not yet declared
on the class. Each entry has a copy button that copies just that method's override
declaration line to the clipboard.
- Folding for class/record/interface bodies and routine bodies.
- Quick fix to remove an unused unit from a
uses clause.
Diagnostics
- Live syntax and semantic checks while typing.
- Run FPC Syntax Check, backed by a real
fpc compiler run: automatically on save and
once for the whole workspace at startup (pascal.diagnostics.useCompiler), or on demand
for the current file (Ctrl+Alt+F9 / Cmd+Alt+F9) or the whole workspace
(Ctrl+Alt+Shift+F9 / Cmd+Alt+Shift+F9) regardless of that setting.
- Inspections for unused units and locals, missing
inherited in destructors, a function
that never assigns Result, and unimplemented interface methods (aware of ancestor
classes and interface delegation via implements properties).
- Declaration/implementation mismatches: a prototype without a body, a body without a
prototype, and signatures that disagree in parameters or return type.
Other
- Restart Language Server command, for when the workspace changes underneath it.
- German and English localization of every user-facing message.
Requirements
A Free Pascal installation is needed for the compiler-backed syntax check on save.
Everything else — parsing, navigation, completion — works without one. Point the
extension at your compiler with pascal.fpc.executablePath if fpc is not on your PATH.
Extension Settings
| Setting |
Default |
Purpose |
pascal.fpc.executablePath |
fpc |
Path to the Free Pascal compiler |
pascal.fpc.compilerOptions |
["-Sa", "-gl", "-O1"] |
Extra options for the syntax check |
pascal.diagnostics.useCompiler |
true |
Run a real fpc syntax check on save and at startup |
pascal.diagnostics.declarationMismatch |
true |
Warn when a declaration and its implementation disagree |
pascal.diagnostics.showAllFiles |
false |
Show diagnostics for every workspace file, not just open ones |
pascal.codeLens.enabled |
true |
Show navigation code lenses above declarations |
pascal.trace.server |
off |
Log client/server communication |
Known Limitations
- No debugger. Running and debugging Pascal programs is not part of this extension.
- No syntax highlighting. By design — this extension focuses on diagnostics, completion
and navigation, not colorization.
.inc files aren't scanned or parsed, and {$I} include files are not followed.
An include file is a fragment spliced into another unit at compile time, not a complete
compilation unit on its own, so a conditional symbol or text macro defined there is invisible
wherever it's included. A branch guarded by an unknown symbol is kept when it has no
{$ELSE}, so its declarations still show up in navigation.
- Type inference does not model generics substitution or
with-introduced scopes.
Acknowledgements
The feature set was informed by I-Pascal, the Object
Pascal plugin for IntelliJ IDEA. This extension is an independent implementation written
from scratch for the Language Server Protocol, and is neither affiliated with nor endorsed
by that project.
License
MIT
Bundled third-party packages and their licenses are listed in
THIRD-PARTY-NOTICES.md.
| |