FreePascal Toolkit
is a VSCode extension for developing FreePascal applications.
-
Install Lazarus or FreePascal on your system.
-
The extendsion will auto search the path of fpc. If it's not be found, please set the system PATH environment variable, or set
fpctoolkit.env.PP
in vscode's user setting. -
Install GDB Debugger - Beyond to debug your freepascal program .
-
build freepascal program
- Build
- Rebuild
- Clear
-
explorer build tasks
- Customize build tasks
- Inherted from other task
-
code snippets
- A lot of snippets for code quick edit.
- class
- if-else
- begin-end
- ...
- A lot of snippets for code quick edit.
-
auto completion
-
gotoDeclaration, gotoDefinition
- Use
ctrl+up
,ctrl+down
to jump between declaration and implementation.
- Use
-
class and function references
-
documentHighlight
- High light for source code
- Identify the compilation conditions for the definition.
{$IFDEF} {ELSE} {$ENDIF}
-
code format with jcf cli
- Format source code
- Use
jcfsettings.cfg
as config. Will use lazarus's config if it installed.
-
quick fix
- Quick fix for
(5025) Local variable "xxx" not used
- Quick fix for
-
auto rename symbols
- Rename function,procedure,variable and it's reference.
-
code complete
- Use
ctrl+shift+c
auto implement procedure .
- Use
-
code actions
- remove unused units
An LSP server implementation for Pascal variants that are supported by Free Pascal, including Object Pascal. It uses CodeTools from Lazarus as backend.
You can add freepascal compile tasks by editing task.json
in your .vscode folder.
The task's type is fpc
. It contains the following configuration items.
Field | type | Description |
---|---|---|
file | string | main program file. .lpr or .dpr |
type | string | always be fpc |
cwd | string | current path. Use wrokspace root if null. |
cleanExt | string | file extensions for clean file in unitOutputDir. use * for clear all file. default:(.o,.ppu) |
buildOption | object | build options |
inherited | string | inherit from other task |
Field | type | Description |
---|---|---|
before_build | string[] | Run commands before build |
after_build_success | string[] | Run commands after build success. |
after_build_failure | string [] | Run commands after build failure. |
Field | type | Description |
---|---|---|
targetOS | string | Target OS (-T). eg. linux win64 |
targetCPU | string | Target cpu family (-P). eg. x86_64 i386 |
customOptions | string [] | Any compile options for fpc. |
libPath | string[] | Searchpath for libraries.(-Fl) |
outputFile | string | Target file name.(-o) |
unitOutputDir | string | Unit output directory.(-FU) |
optimizationLevel | number | Optimization levels (-O) |
searchPath | string[] | Searchpath for units and other system dependent things.(-Fu) |
syntaxMode | string | Syntax Mode (-M) |
forceRebuild | boolean | Re-compile all used units, even if the unit sources didn’t change since the last compilation.(-B) |
msgIgnore | number[] | Is a list of messages numbers which should not be shown.(-vmxxx) |
example:
{
"version": "2.0.0",
"tasks": [
{
"label": "debug",
"file": "main.lpr",
"type": "fpc",
"buildOption": {
"unitOutputDir": "./out",
"customOptions": [
"-dDEBUG",
"-gw2"
]
}
}
]
}
Syntaxes from https://github.com/maresmar/ST-Pascal
Clone and modified from https://github.com/git-bee/jcf-cli
Clone and modified from https://github.com/genericptr/pascal-language-server https://github.com/arjanadriaanse/pascal-language-server