The problem you're running into here is that with the current setup, sourcekit-lsp has no way to know what settings to use for a particular file (so eg. main.swift
here).
sourcekit-lsp has a few ways to retrieve this information - either through SwiftPM, a compilation databases, or a custom BSP server.
The second is what you're looking for in this case.
Unfortunately, there's no simple way to produce compile_commands.json with Make (with CMake you can set CMAKE_EXPORT_COMPILE_COMMANDS
). You could probably get away with using compile_flags.txt today, but I would recommend just manually crafting compile_commads.json
instead:
- Remove
swift.sourcekit-lsp.serverArguments
from.vscode/settings.json
- these are arguments to provide to the language server (sourcekit-lsp) on launch, not compilation arguments. - Remove
.sourcekit-lsp/config.json
-swiftPM
is specifically for configuring SwiftPM projects further, which you don't have here. - Add a
compile_commands.json
next to yourmakefile
:
[
{
"directory": "/[ ... REDACTED ... ]/HelloWorld",
"command": "swiftc source/main.swift -enable-experimental-feature Embedded -target armv7em-none-none-eabi -no-allocations -import-objc-header source/Bridging-Header.h -I /opt/devkitPro/DEVKITARM/include -I /opt/devkitPro/DEVKITARM/arm-none-eabi/include -I /opt/devkitPro/libctru/include",
"file": "source/main.swift"
}
]
- Open the workspace in VS Code