English {#english}
CrabPascal in VS Code and Cursor
Writing Pascal in a modern editor should feel as smooth as TypeScript or Rust. The official CrabPascal extension (crabpascal.crabpascal) brings check, run, and build-exe into VS Code and Cursor with problem matchers, tasks, and keyboard shortcuts.
Install the extension
Search the marketplace for CrabPascal or install from the .vsix in vscode-extension/:
cd vscode-extension
vsce package
code --install-extension crabpascal-2.22.0.vsix
Cursor uses the same extension format — install via Extensions panel or CLI.
On first build (Ctrl+Shift+B), the extension can detect a missing compiler and offer auto-install (Windows). See the dedicated post on auto-install for details.
What works out of the box
-
checkon save or demand — syntax and semantic errors in the Problems panel -
Standard error format —
file:line:column: severity: message -
Build tasks — compile/run the active
.dpror.pas -
File associations —
.pas,.dpr,.pp,.incmapped to Pascal
Error format and problem matcher
CrabPascal emits diagnostics compatible with VS Code's built-in matcher:
Unit1.pas:15:3: error: Type mismatch: expected Integer, got String
Unit1.pas:22:1: warning: Unused variable 'Temp'
Click a problem to jump to the exact line and column. This is the same output crab-pascal check produces on the CLI — one source of truth for CI and editor.
Manual tasks.json (optional)
If you prefer project-level control, add .vscode/tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"label": "CrabPascal: Check",
"type": "shell",
"command": "crab-pascal",
"args": ["check", "${file}"],
"problemMatcher": {
"owner": "crabpascal",
"fileLocation": ["relative", "${workspaceFolder}"],
"pattern": {
"regexp": "^(.+?):(\\d+):(\\d+):\\s+(error|warning|info):\\s+(.+)$",
"file": 1, "line": 2, "column": 3, "severity": 4, "message": 5
}
}
},
{
"label": "CrabPascal: Run",
"type": "shell",
"command": "crab-pascal",
"args": ["run", "${file}"],
"group": "test"
}
]
}
Press Ctrl+Shift+B for the default build task.
Recommended settings
{
"files.associations": {
"*.pas": "pascal",
"*.dpr": "pascal"
},
"editor.tabSize": 2,
"crabpascal.compilerPath": "crab-pascal"
}
Point compilerPath to your release binary or target/release/crab-pascal.exe if you build from source.
Workflow example
- Open
examples/crud/crud.dprin Cursor. - Run CrabPascal: Check — fix any semantic errors.
- Run CrabPascal: Run — server starts on port 9000.
- Test with REST Client or Postman.
Troubleshooting
| Issue | Fix |
|---|---|
crab-pascal not found |
Set crabpascal.compilerPath or enable auto-install |
| Errors not in Problems panel | Verify problem matcher regex matches output |
| Wrong file compiled | Ensure the active editor tab is the target .dpr
|
The extension evolves with sprint releases (currently aligned with v2.22.0). Pair it with crabpascal.toml for search paths and Delphi mode — your editor and CLI stay in sync.
Português {#portugus}
CrabPascal no VS Code e Cursor
Escrever Pascal em um editor moderno deve ser tão fluido quanto TypeScript ou Rust. A extensão oficial CrabPascal (crabpascal.crabpascal) traz check, run e build-exe para VS Code e Cursor com problem matchers, tasks e atalhos.
Instalar a extensão
Busque CrabPascal no marketplace ou instale pelo .vsix em vscode-extension/:
cd vscode-extension
vsce package
code --install-extension crabpascal-2.22.0.vsix
O Cursor usa o mesmo formato — instale pelo painel Extensions ou CLI.
No primeiro build (Ctrl+Shift+B), a extensão pode detectar compilador ausente e oferecer auto-instalação (Windows). Veja o post dedicado sobre auto-instalação.
O que funciona de fábrica
-
checksob demanda ou ao salvar — erros de sintaxe e semântica no painel Problems -
Formato padrão de erro —
arquivo:linha:coluna: severity: mensagem -
Tasks de build — compilar/executar o
.dprou.pasativo -
Associações de arquivo —
.pas,.dpr,.pp,.incmapeados para Pascal
Formato de erro e problem matcher
O CrabPascal emite diagnósticos compatíveis com o matcher nativo do VS Code:
Unit1.pas:15:3: error: Type mismatch: expected Integer, got String
Unit1.pas:22:1: warning: Unused variable 'Temp'
Clique no problema para ir à linha e coluna exatas. É a mesma saída do crab-pascal check na CLI — uma fonte de verdade para CI e editor.
tasks.json manual (opcional)
Se preferir controle por projeto, adicione .vscode/tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"label": "CrabPascal: Check",
"type": "shell",
"command": "crab-pascal",
"args": ["check", "${file}"],
"problemMatcher": {
"owner": "crabpascal",
"fileLocation": ["relative", "${workspaceFolder}"],
"pattern": {
"regexp": "^(.+?):(\\d+):(\\d+):\\s+(error|warning|info):\\s+(.+)$",
"file": 1, "line": 2, "column": 3, "severity": 4, "message": 5
}
}
},
{
"label": "CrabPascal: Run",
"type": "shell",
"command": "crab-pascal",
"args": ["run", "${file}"],
"group": "test"
}
]
}
Pressione Ctrl+Shift+B para a task de build padrão.
Configurações recomendadas
{
"files.associations": {
"*.pas": "pascal",
"*.dpr": "pascal"
},
"editor.tabSize": 2,
"crabpascal.compilerPath": "crab-pascal"
}
Aponte compilerPath para o binário de release ou target/release/crab-pascal.exe se compilar do fonte.
Exemplo de fluxo
- Abra
examples/crud/crud.dprno Cursor. - Execute CrabPascal: Check — corrija erros semânticos.
- Execute CrabPascal: Run — servidor sobe na porta 9000.
- Teste com REST Client ou Postman.
Solução de problemas
| Problema | Correção |
|---|---|
crab-pascal não encontrado |
Configure crabpascal.compilerPath ou habilite auto-instalação |
| Erros não aparecem em Problems | Verifique se o regex do problem matcher bate com a saída |
| Arquivo errado compilado | Confirme que a aba ativa é o .dpr desejado |
A extensão evolui com releases de sprint (alinhada à v2.22.0). Combine com crabpascal.toml para search paths e modo Delphi — editor e CLI ficam sincronizados.
Published on dev.to/@crabpascal · Código em CrabPascal
Top comments (0)