How do install OmniPascal into vscode

2020-06-28 01:46发布

问题:

From the OmniPascal page on Visual Studio Marketplace:

How to install

  • Install Visual Studio Code and open it.
  • Open View -> Command Palette... and type ext install OmniPascal
  • Restart Visual Studio Code and open File -> Preferences -> User Settings
  • Add the key "objectpascal.delphiInstallationPath" to the right editor and set its value to the Delphi installation path. Don't forget to escape the backslashes! Example:

    "objectpascal.delphiInstallationPath" = "C:\\Program Files (x86)\\Embarcadero\\Studio\\16.0",
    

Except that seems to be wrong; it complains that it shouldn't be an = (equals), but a : (colon):

I assume that's a typo, and it should be a colon:

But what should the path be?

The page gives the example path as:

C:\\Program Files (x86)\\Embarcadero\\Studio\\16.0

But the animated installation pastes in a path leading to the subfolder source:

Which is it? I only ask because neither path seems to enable suggestions:

回答1:

Except that seems to be wrong; it complains that it shouldn't be an = (equals), but a : (colon)

Oh, obviously there's an error in the documentation. This will be fixed with the next release. Thanks. Of course it should be a colon since it is an entry in a JSON file.

But what should the path be?

The entry objectpascal.delphiInstallationPath should point to the path where Delphi is installed. It doesn't matter whether you define the source subdirectory or not. The path is internally used to find Delphi units recursively. As all .pas files are located in the source folder the lookup is slightly faster when the entry looks like this:

"objectpascal.delphiInstallationPath": "C:\\Program Files (x86)\\Embarcadero\\Studio\\16.0\\Source"

Free Pascal users should point to the FPC directory

Sample:

"objectpascal.delphiInstallationPath": "C:\\lazarus\\fpc"

I only ask because neither path seems to enable suggestions

The syntax highlighting in your screenshot seems to come from another Pascal plugin for Visual Studio Code. When the OmniPascal plugin is active in a .pas file then the current file type is "ObjectPascal". You see it in the bottom right corner next to the smiling feedback button:

When the current file type is "Pascal" or anything else then the wrong plugin is active. Click on the file type and change it to "ObjectPascal". Now you should get code completion, quick infos and more.