Setting up IntelliSense for PostgreSQL Development

This post builds upon the content presented in our previous two articles, providing further guidance with additional configurations. Building and Running PostgreSQL from Source Code Debugging PostgreSQL with GDB + Visual Studio Code As a developer working on an open source project, it's essential to have a seamless development experience. One way to achieve this is by setting up IntelliSense in Visual Studio Code (VS Code). IntelliSense is a Microsoft-developed set of code-completion features, primarily known for its use in Visual Studio and Visual Studio Code, that provides real-time suggestions, auto-completion, and context-aware documentation for various programming languages. In this post, we'll explore how to configure IntelliSense to work with PostgreSQL source code and exclude unnecessary files from Git changes. Step 1. Configuring IntelliSense To set up IntelliSense, create a c_cpp_properties.json file in the .vscode directory of your project. This file will contain settings for the compiler and include paths. Here's an example configuration: { "env": { "myIncludePath": ["${workspaceFolder}/src/include", "${workspaceFolder}/src/interfaces/**"], "myDefines": [] }, "configurations": [ { "name": "Linux (GCC ARM64)", "compilerPath": "/usr/bin/gcc", "compilerArgs": ["-D_GNU_SOURCE"], "intelliSenseMode": "linux-gcc-arm64", "includePath": [ "${myIncludePath}", "/usr/include", "/usr/local/include" ], "defines": [ "${myDefines}" ], "cStandard": "${default}", "configurationProvider": "ms-vscode.cmake-tools", "mergeConfigurations": true } ], "version": 4, "enableConfigurationSquiggles": true } This configuration sets up the compiler path, include paths for PostgreSQL and standard libraries, and defines. The predefined argument workspaceFolder points the path of the folder opened in VS Code. VS Code provides some other predefined variables, whose definitions can be found here. intelliSenseMode needs to be set appropriately for your platform. This link has a list of platforms where you can set it. Since PostgreSQL depends on GNU functions, setting -D_GNU_SOURCE is necessary to get appropriate code-completion. Step 2. Excluding Files from Git Changes When working on a project, you may not want to commit certain files, such as those in the .vscode directory or log files. To exclude these files from Git changes without adding them to the .gitignore file (which would require committing), you can use the exclude file in the .git/info directory. To exclude the .vscode directory, run the following command: echo .vscode/* >> .git/info/exclude You can verify the excluded files by running: cat .git/info/exclude By following these steps, you'll have IntelliSense set up for your PostgreSQL project and unnecessary files excluded from Git changes. Happy coding!

Mar 20, 2025 - 06:19
 0
Setting up IntelliSense for PostgreSQL Development

This post builds upon the content presented in our previous two articles, providing further guidance with additional configurations.

  1. Building and Running PostgreSQL from Source Code
  2. Debugging PostgreSQL with GDB + Visual Studio Code

As a developer working on an open source project, it's essential to have a seamless development experience. One way to achieve this is by setting up IntelliSense in Visual Studio Code (VS Code). IntelliSense is a Microsoft-developed set of code-completion features, primarily known for its use in Visual Studio and Visual Studio Code, that provides real-time suggestions, auto-completion, and context-aware documentation for various programming languages.

In this post, we'll explore how to configure IntelliSense to work with PostgreSQL source code and exclude unnecessary files from Git changes.

Step 1. Configuring IntelliSense

To set up IntelliSense, create a c_cpp_properties.json file in the .vscode directory of your project. This file will contain settings for the compiler and include paths. Here's an example configuration:

{
    "env": {
        "myIncludePath": ["${workspaceFolder}/src/include", "${workspaceFolder}/src/interfaces/**"],
        "myDefines": []
    },
    "configurations": [
        {
            "name": "Linux (GCC ARM64)",
            "compilerPath": "/usr/bin/gcc",
            "compilerArgs": ["-D_GNU_SOURCE"],
            "intelliSenseMode": "linux-gcc-arm64",
            "includePath": [ "${myIncludePath}", "/usr/include", "/usr/local/include" ],
            "defines": [ "${myDefines}" ],
            "cStandard": "${default}",
            "configurationProvider": "ms-vscode.cmake-tools",
            "mergeConfigurations": true
          }
    ],
    "version": 4,
    "enableConfigurationSquiggles": true
}

This configuration sets up the compiler path, include paths for PostgreSQL and standard libraries, and defines. The predefined argument workspaceFolder points the path of the folder opened in VS Code. VS Code provides some other predefined variables, whose definitions can be found here.

intelliSenseMode needs to be set appropriately for your platform. This link has a list of platforms where you can set it.

Since PostgreSQL depends on GNU functions, setting -D_GNU_SOURCE is necessary to get appropriate code-completion.

Step 2. Excluding Files from Git Changes

When working on a project, you may not want to commit certain files, such as those in the .vscode directory or log files. To exclude these files from Git changes without adding them to the .gitignore file (which would require committing), you can use the exclude file in the .git/info directory.

To exclude the .vscode directory, run the following command:

echo .vscode/* >> .git/info/exclude

You can verify the excluded files by running:

cat .git/info/exclude

By following these steps, you'll have IntelliSense set up for your PostgreSQL project and unnecessary files excluded from Git changes.

Happy coding!