Recent

Author Topic: Freepascal Toolkit in VS Code on macOS does not work  (Read 372 times)

PhoenixHawk

  • Newbie
  • Posts: 2
Freepascal Toolkit in VS Code on macOS does not work
« on: March 19, 2025, 01:48:07 pm »
Hi there,

I wanted to try out freepascal on macOS using VS Code (or Windsurf).
I therefore installed fpc on my computer using brew (fpc is 3.2.2 for aarch64), and the compiler itself works when I manually call it on the commandline.

I installed the FreePascal Toolkit from the VS Code Marketplace, but when I create a pascal file, the language server does not work. I get this output in the VS Code output window from the FreePascal Language Server and "Server initialization failed" from the fpctoolkit.

Code: [Select]
► RootURI: file:///Users/sebastian/dev/sg/freepascal
► ProjectDir: /Users/sebastian/dev/sg/freepascal/
✓ Client: Visual Studio Code 1.98.2
✓ FPCPath:
✓ FPCSrcDir: /usr/local/share/fpcsrc
✓ TargetOS:
✓ TargetProcessor:
✓ LazarusSrcDir:
✓ LazarusSrcOptions:
✓ Working directory: /Users/sebastian/dev/sg/freepascal
✓ FPCOptions: -FU./out -dDEBUG  -Fu/Users/sebastian/dev/sg/freepascal -Fi/Users/sebastian/dev/sg/freepascal -Fu/Users/sebastian/dev/sg/freepascal/.vscode -Fi/Users/sebastian/dev/sg/freepascal/.vscode
✓ ProjectDir: /Users/sebastian/dev/sg/freepascal/
✓ Symbol Database: [unspecified]
✓ Settings:
  ► maximumCompletions: 50
  ► overloadPolicy: Suffix
  ► insertCompletionsAsSnippets: FALSE
  ► insertCompletionProcedureBrackets: FALSE
  ► includeWorkspaceFoldersAsUnitPaths: TRUE
  ► includeWorkspaceFoldersAsIncludePaths: FALSE
  ► checkSyntax: FALSE
  ► publishDiagnostics: FALSE
  ► workspaceSymbols: FALSE
  ► documentSymbols: TRUE
  ► minimalisticCompletions: FALSE
  ► showSyntaxErrors: TRUE
[Error - 1:42:22 PM] Server initialization failed.
  Message: TFPCUnitToSrcCache.GetConfigCache missing CompilerFilename
  Code: -32603
[Error - 1:42:22 PM] Free Pascal Language Server client: couldn't create connection to server.
  Message: TFPCUnitToSrcCache.GetConfigCache missing CompilerFilename
  Code: -32603

What did I miss? I have no idea where to start looking for problems, as I don't have experience with language servers / VS Code plugins.

cdbc

  • Hero Member
  • *****
  • Posts: 2108
    • http://www.cdbc.dk
Re: Freepascal Toolkit in VS Code on macOS does not work
« Reply #1 on: March 19, 2025, 02:23:27 pm »
Hi
Look in VS-Code at another language and try to find where it defines the 'CompilerFilename'...
Then look at the FPC one and see what it says...
Your error mentions it specifically: "missing CompilerFilename".
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 3.6 up until Jan 2024 from then on it's both above &: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 4.99

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 11048
  • Debugger - SynEdit - and more
    • wiki
Re: Freepascal Toolkit in VS Code on macOS does not work
« Reply #2 on: March 19, 2025, 03:23:32 pm »
I don't know the VS Code add in, or anything...

But:
Quote
Code: Text  [Select][+][-]
  1. couldn't create connection to server.

From what I gathered (read a good while back somewhere), the Language server is basically a wrapper for the Lazarus codetools (at least one VS extensions, IIRC the one by Joost V.d.S., does use that).
If that is the case, then it needs to run as a separate app in the background. And may or may not need its own config too.

As I said, nothing of this is for sure. But maybe, with the help of some search engine, this leads you to some docs that will help.

PhoenixHawk

  • Newbie
  • Posts: 2
Re: Freepascal Toolkit in VS Code on macOS does not work
« Reply #3 on: March 19, 2025, 04:04:16 pm »
Thanks. I didn't find that setting first, but then I figure out that it is the fpctoolkit.env.PP configuration and once set, the language server did start up.

 

TinyPortal © 2005-2018