1、安装fpc
2、安装vs code
3、在VS code 中搜索“Pascal”,并安装下列插件:
-
安装 Pascal, 既pascal language support for Vs code;
-
安装 Pascal Formatter, 增加代码格式化功能,对其设置如下图:
说明:ptop 是fpc 中自带的代码格式工具。
后面WIN7上没找到POTO.CFg文件,可以 选择 JCF engin 后面输入,C:\lazarus\components\jcf2\JCFSettings.cfg
C:\lazarus\components\jcf2\jcf.exe 也可以的。
-
安装 Pascal-runner,增加编译运行功能(好像是save and run 一个绿色图标管用);
-
安装 Pascal Language Basic 及 Object Pascal Syntax Highlithter, 增 语法高亮功能。
- 后面附调整好的settings.json
-
{ "[html]": { "editor.defaultFormatter": "vscode.html-language-features" }, "cmake.configureOnOpen": true, "security.workspace.trust.untrustedFiles": "open", "[javascript]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, "editor.fontSize": 20, "workbench.editorAssociations": { "*.asar": "default", "*.xls": "default", "*.pdf": "default", "*.doc": "default", "*.exe": "default" }, "files.encoding": "gbk", "workbench.editor.empty.hint": "hidden", "editor.unicodeHighlight.nonBasicASCII": false, "files.autoGuessEncoding": true, "cmake.showOptionsMovedNotification": false, "[cpp]": { "editor.defaultFormatter": "ms-vscode.cpptools" }, "files.associations": { "*.pas": "pascal" }, "editor.defaultFormatter": "esbenp.prettier-vscode", "pascal.format.indent": 4, "extensions.ignoreRecommendations": true, "[jsonc]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, "editor.fontFamily": "JetBrains Mono", "workbench.editor.enablePreview": false, "workbench.settings.applyToAllProfiles": [ "pascal.formatter.engineParameters", "pascal.formatter.enginePath", "fpctoolkit.env.FPCTARGETCPU" ], "explorer.confirmDelete": false, "code-runner.runInTerminal": true, "pascal.formatter.engine": "ptop", "pascal.formatter.enginePath": "C:\\lazarus3.22\\fpc\\3.2.2\\bin\\x86_64-win64\\ptop.exe", "pascal.formatter.engineParameters": "C:\\lazarus3.22\\fpc\\3.2.2\\bin\\x86_64-win64\\ptop.cfg", "editor.minimap.enabled": false, "C_Cpp.vcFormat.space.withinExpressionParentheses": true, "C_Cpp.vcFormat.space.withinSquareBrackets": true, "C_Cpp.vcFormat.space.withinParameterListParentheses": true, "files.refactoring.autoSave": false, "files.autoSaveDelay": 5000, "code-runner.saveFileBeforeRun": true, "editor.formatOnSave": true, "workbench.editor.labelFormat": "short", "workbench.iconTheme": "material-icon-theme", "workbench.colorTheme": "Monokai", "[pascal]": { "editor.defaultFormatter": "alefragnani.pascal-formatter" }, "fpctoolkit.env.FPCDIR": "C:\\FPC\\3.2.2", "fpctoolkit.env.LAZARUSDIR": "C:\\lazarus3.22", "fpctoolkit.env.PP": "C:\\lazarus3.22\\fpc\\3.2.2\\bin\\x86_64-win64", "fpctoolkit.format.cfgpath": "C:\\lazarus3.22\\fpc\\3.2.2\\bin\\x86_64-win64", "fpctoolkit.format.enabled": false, "fpctoolkit.format.tabsize": 4, "saveAndRun": { "externalConsole": true }, "C_Cpp.default.cStandard": "c11", "C_Cpp.default.intelliSenseMode": "windows-gcc-x64", "C_Cpp.default.compilerPath": "D:\\Qt6.2\\Tools\\mingw1120_64\\bin\\gcc.exe", "C_Cpp.default.browse.path": ["D:\\Qt6.2\\Tools\\mingw1120_64\\bin\\g++.exe"], "omnipascal.createBuildScripts": true, "omnipascal.defaultDevelopmentEnvironment": "FreePascal", "omnipascal.freePascalSourcePath": "C:\\FPC\\3.2.2", "omnipascal.lazbuildPath": "C:\\lazarus3.22", "omnipascal.msbuildPath": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\MSBuild\\Current\\Bin", "omnipascal.delphiInstallationPath": "C:\\Program Files (x86)\\Embarcadero\\Studio\\22.0", "[c]": { "editor.defaultFormatter": "ms-vscode.cpptools" }, "clang.completion.triggerChars": [".", ":", ">"], "clang.executable": "C:\\upp-win-17261\\upp\\bin\\clang\\bin\\g++.exe", "editor.guides.bracketPairs": true, "code-runner.clearPreviousOutput": true, "code-runner.executorMap": { "javascript": "node", "java": "cd $dir && javac $fileName && java $fileNameWithoutExt", //"c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt", //对于C文件 "c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && clear && Write-Host \"[Running $fileName]\" -ForegroundColor green && $dir$fileNameWithoutExt && Write-Host \"\n[Accomplished]\" -ForegroundColor green", //对于C++文件 "cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt && clear && Write-Host \"[Running $fileName]\" -ForegroundColor green && $dir$fileNameWithoutExt && Write-Host \"\n[Accomplished]\" -ForegroundColor green", "zig": "zig run", //"cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt", "objective-c": "cd $dir && gcc -framework Cocoa $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt", "php": "php", "python": "python -u", "perl": "perl", "perl6": "perl6", "ruby": "ruby", "go": "go run", "lua": "lua", "groovy": "groovy", "powershell": "powershell -ExecutionPolicy ByPass -File", "bat": "cmd /c", "shellscript": "bash", "fsharp": "fsi", "csharp": "scriptcs", "vbscript": "cscript //Nologo", "typescript": "ts-node", "coffeescript": "coffee", "scala": "scala", "swift": "swift", "julia": "julia", "crystal": "crystal", "ocaml": "ocaml", "r": "Rscript", "applescript": "osascript", "clojure": "lein exec", "haxe": "haxe --cwd $dirWithoutTrailingSlash --run $fileNameWithoutExt", "rust": "cd $dir && rustc $fileName && $dir$fileNameWithoutExt", "racket": "racket", "scheme": "csi -script", "ahk": "autohotkey", "autoit": "autoit3", "dart": "dart", //"pascal": "cd $dir && fpc $fileName && $dir$fileNameWithoutExt", //对于pascal文件 "pascal": "cd $dir && fpc $fileName && clear && Write-Host \"[Running $fileName]\" -ForegroundColor green && $dir$fileNameWithoutExt && Write-Host \"\n[Accomplished]\" -ForegroundColor green", "d": "cd $dir && dmd $fileName && $dir$fileNameWithoutExt", "haskell": "runghc", "nim": "nim compile --verbosity:0 --hints:off --run", "lisp": "sbcl --script", "kit": "kitc --run", "v": "v run", "sass": "sass --style expanded", "scss": "scss --style expanded", "less": "cd $dir && lessc $fileName $fileNameWithoutExt.css", "FortranFreeForm": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt", "fortran-modern": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt", "fortran_fixed-form": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt", "fortran": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt", "sml": "cd $dir && sml $fileName", "mojo": "mojo run", "erlang": "escript", "spwn": "spwn build", "pkl": "cd $dir && pkl eval -f yaml $fileName -o $fileNameWithoutExt.yaml", "gleam": "gleam run -m $fileNameWithoutExt" } }