Missing auto-complete on header files includes in VS Code with nRF Connect extension

Hello.

I'm following the nRF Connect SDK Fundamentals course. I've setup VS Code with the nRF Connect extension, and everything with building, flashing, etc. works fine.

However, auto-complete does not seem to work on header files includes.

If I write out the complete path, I can even ctrl+click on the header file to open it, so header files are obviously found.

It is quite annoying to work without auto-complete when one is not familiar with Zephyr and such.

So I'm wondering if something is wrong with my setup?


{
  "platform": {
    "os": "linux",
    "osVersion": "#1 SMP PREEMPT Wed Feb 1 12:03:19 UTC 2023",
    "osKernel": "5.15.91-1-MANJARO",
    "vscode": "1.74.3",
    "electron": "19.1.9",
    "node": "v16.14.2"
  },
  "system": {
    "date": "2023-02-07T21:54:28.764Z",
    "vscodeRoot": "/usr/lib/code",
    "nrfConnectForDesktopInstalled": "unknown",
    "vscodeUptime": "00:58:38",
    "osUptime": "03:18:31",
    "cpu": {
      "model": "Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz",
      "speed": "1109 MHz",
      "count": 2
    },
    "memory": {
      "total": "7.49 GB",
      "free": "1.21 GB"
    }
  },
  "workspace": {
    "name": "fundamentals (Workspace)",
    "workspaceFile": "/home/vebjorn/Code/nordic-academy/fundamentals/fundamentals.code-workspace",
    "folders": [
      "/home/vebjorn/Code/nordic-academy/fundamentals",
      "/home/vebjorn/Code/nordic-academy/fundamentals/lesson1-exercise2-blinky",
      "/home/vebjorn/Code/nordic-academy/fundamentals/lesson2-exercise1-polling",
      "/home/vebjorn/Code/nordic-academy/fundamentals/lesson2-exercise2-interrupt",
      "/home/vebjorn/Code/nordic-academy/fundamentals/lesson3-exercise1-application",
      "/home/vebjorn/Code/nordic-academy/fundamentals/lesson3-exercise2-customize",
      "/home/vebjorn/Code/nordic-academy/fundamentals/lesson4-exercise1-print",
      "/home/vebjorn/Code/nordic-academy/fundamentals/lesson4-exercise2-logger",
      "/home/vebjorn/Code/nordic-academy/fundamentals/lesson4-exercise3-config_logger",
      "/home/vebjorn/Code/nordic-academy/fundamentals/lesson5-exercise1-uart_leds"
    ]
  },
  "extensions": {
    "internal": {
      "nordic-semiconductor.nrf-connect": {
        "version": "2023.1.44",
        "path": "/home/vebjorn/.vscode-oss/extensions/nordic-semiconductor.nrf-connect-2023.1.44-linux-x64",
        "isActive": true
      },
      "nordic-semiconductor.nrf-terminal": {
        "version": "2022.11.29",
        "path": "/home/vebjorn/.vscode-oss/extensions/nordic-semiconductor.nrf-terminal-2022.11.29",
        "isActive": true
      },
      "nordic-semiconductor.nrf-devicetree": {
        "version": "2022.11.153",
        "path": "/home/vebjorn/.vscode-oss/extensions/nordic-semiconductor.nrf-devicetree-2022.11.153",
        "isActive": true
      },
      "nordic-semiconductor.nrf-kconfig": {
        "version": "2022.11.50",
        "path": "/home/vebjorn/.vscode-oss/extensions/nordic-semiconductor.nrf-kconfig-2022.11.50",
        "isActive": true
      }
    },
    "external": {
      "marus25.cortex-debug": "1.6.10",
      "ms-vscode.cpptools": "1.13.9",
      "ms-vscode.js-debug": "1.74.1",
      "ms-vscode.js-debug-companion": "1.0.18",
      "ms-vscode.vscode-js-profile-table": "1.0.3",
      "mcu-debug.debug-tracker-vscode": "0.0.13",
      "mcu-debug.memory-view": "0.0.19",
      "mcu-debug.rtos-views": "0.0.4",
      "mjmcloug.vscode-elixir": "1.1.0",
      "ms-python.isort": "2022.8.0",
      "ms-python.python": "2022.20.2",
      "ms-vscode.cpptools-extension-pack": "1.3.0",
      "ms-vscode.cpptools-themes": "2.0.0",
      "rust-lang.rust-analyzer": "0.3.1394",
      "trond-snekvik.gnu-mapfiles": "1.1.0"
    }
  },
  "tools": {
    "/home/vebjorn/ncs/toolchains/v2.2.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc": "0.15.1",
    "/opt/SEGGER/JLink/JLinkExe": "7.84e",
    "/usr/bin/nrfjprog": "10.19.0",
    "nrfutil": "Not found",
    "/home/vebjorn/ncs/toolchains/v2.2.0/usr/local/bin/cmake": "3.20.5",
    "/home/vebjorn/ncs/toolchains/v2.2.0/usr/local/bin/west": "0.14.0",
    "/home/vebjorn/ncs/toolchains/v2.2.0/usr/local/bin/python3": "3.8.2",
    "/home/vebjorn/ncs/toolchains/v2.2.0/usr/local/bin/ninja": "1.9.0",
    "/home/vebjorn/ncs/toolchains/v2.2.0/usr/bin/gperf": "3.1",
    "/home/vebjorn/ncs/toolchains/v2.2.0/usr/bin/dtc": "1.4.7",
    "/home/vebjorn/ncs/toolchains/v2.2.0/opt/bin/gn": "1871",
    "/home/vebjorn/ncs/toolchains/v2.2.0/usr/local/bin/git": "2.37.3",
    "gdbPath": "/home/vebjorn/ncs/toolchains/v2.2.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gdb"
  },
  "sdks": [
    {
      "version": "2.2.0",
      "path": "/home/vebjorn/ncs/nrf_connect_sdk"
    }
  ],
  "toolchains": [
    {
      "version": "2.2.0",
      "path": "/home/vebjorn/ncs/toolchains/v2.2.0"
    }
  ],
  "connectedDevices": [
    {
      "serialNumber": "XXXXX"
    }
  ],
  "deviceProviders": [
    "nrfjprog"
  ],
  "config": {
    "nordic-semiconductor.nrf-connect": {
      "topdir": "${nrf-connect.sdk:2.2.0}",
      "toolchain": {
        "path": "${nrf-connect.toolchain:2.2.0}"
      },
      "ozonePath": "",
      "applications": [
        "${workspaceFolder:lesson1-exercise2-blinky}",
        "${workspaceFolder:lesson2-exercise1-polling}",
        "${workspaceFolder:lesson2-exercise2-interrupt}",
        "${workspaceFolder:lesson3-exercise1-application}",
        "${workspaceFolder:lesson3-exercise2-customize}",
        "${workspaceFolder:lesson4-exercise1-print}",
        "${workspaceFolder:lesson4-exercise2-logger}",
        "${workspaceFolder:lesson4-exercise3-config_logger}",
        "${workspaceFolder:lesson5-exercise1-uart_leds}"
      ],
      "applicationOptions": {},
      "kconfig": {
        "interface": "kconfig",
        "executeInDefaultShell": false
      },
      "welcome": {
        "showOnStartup": true
      },
      "west": {
        "env": {
          "$base": "terminal"
        }
      },
      "boardRoots": [],
      "enableTelemetry": false,
      "taskBindings": {},
      "debugging": {
        "backend": "nRF Debug",
        "flash": true,
        "bindings": {}
      },
      "activeAppFollowActiveEditor": true
    },
    "nordic-semiconductor.nrf-terminal": {
      "terminalMode": "character",
      "scrollBack": 1000
    },
    "marus25.cortex-debug": {
      "armToolchainPath": null,
      "armToolchainPrefix": "arm-none-eabi",
      "gdbPath": null,
      "objdumpPath": null,
      "JLinkGDBServerPath": null,
      "openocdPath": null,
      "pyocdPath": null,
      "PEGDBServerPath": null,
      "stutilPath": null,
      "stlinkPath": null,
      "stm32cubeprogrammer": null,
      "enableTelemetry": true,
      "registerUseNaturalFormat": true,
      "variableUseNaturalFormat": true,
      "dbgServerLogfile": null,
      "showDevDebugOutput": "none"
    }
  },
  "environment": {
    "westExe": "west",
    "westEnv": {
      "ELECTRON_RUN_AS_NODE": "1",
      "GIT_EXEC_PATH": "/home/vebjorn/ncs/toolchains/v2.2.0/usr/lib/git-core",
      "HOME": "/home/vebjorn",
      "PATH": "/home/vebjorn/ncs/toolchains/v2.2.0/usr/bin:/home/vebjorn/ncs/toolchains/v2.2.0/usr/local/bin:/home/vebjorn/ncs/toolchains/v2.2.0/opt/bin:/home/vebjorn/ncs/toolchains/v2.2.0/opt/nanopb/generator-bin:/home/vebjorn/ncs/toolchains/v2.2.0/opt/zephyr-sdk/arm-zephyr-eabi/bin:/home/vebjorn/ncs/toolchains/v2.2.0/arm-zephyr-eabi/bin:/home/vebjorn/.cargo/bin:/home/vebjorn/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/var/lib/snapd/snap/bin",
      "ZEPHYR_BASE": "/home/vebjorn/ncs/nrf_connect_sdk/zephyr",
      "ZEPHYR_TOOLCHAIN_VARIANT": "zephyr",
      "ZEPHYR_SDK_INSTALL_DIR": "/home/vebjorn/ncs/toolchains/v2.2.0/opt/zephyr-sdk",
      "PYTHONPATH": "/home/vebjorn/ncs/toolchains/v2.2.0/usr/local/lib/python3.8/site-packages",
      "USER": "vebjorn"
    },
    "inherited": {
      "ELECTRON_RUN_AS_NODE": "1",
      "HOME": "/home/vebjorn",
      "PATH": "/home/vebjorn/.cargo/bin:/home/vebjorn/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/var/lib/snapd/snap/bin",
      "USER": "vebjorn"
    },
    "toolchainPath": "/home/vebjorn/ncs/toolchains/v2.2.0",
    "toolchainBinPath": "/home/vebjorn/ncs/toolchains/v2.2.0/opt/zephyr-sdk/arm-zephyr-eabi/bin",
    "toolchainVersion": "2.2.0"
  },
  "terminal": {
    "shell": null,
    "defaultProfile": null
  }
}

Parents
  • Hello, 

    I see the same on my side with regards to autcomplete in include paths. Does the autocomplete work with functions?

    Kind regards,
    Øyvind

  • Yes. Autocomplete works with functions.

    I got it working with include paths also now.

    I ran the command C/C++: Edit Configurations (JSON)  and added this as the content of the c_cpp_properties.json in my workspace:

    For some reason I had to specify the full path, using ${nrf-connect.sdk:2.2.0} did not work.

    I guess you provide some kind of configuration with your extension, I suggest you add the sdk includes folders in the "includePath" so that all your users gets autocomplete on includes files.

Reply
  • Yes. Autocomplete works with functions.

    I got it working with include paths also now.

    I ran the command C/C++: Edit Configurations (JSON)  and added this as the content of the c_cpp_properties.json in my workspace:

    For some reason I had to specify the full path, using ${nrf-connect.sdk:2.2.0} did not work.

    I guess you provide some kind of configuration with your extension, I suggest you add the sdk includes folders in the "includePath" so that all your users gets autocomplete on includes files.

Children
  • Glad to hear that you got it working. I forwarded the issue to our developers. 

    What does the command C/C++: Log Diagnostics output on your side?