Problem: STM32CubeIDE sucks ass, I want to use NVIM
Solution: Use stm32cubemx with CMake output and ccls for LSP. GDB for debugging later on
Setup
-
Project Generation: Use
stm32cubemx. Select “CMake” as the toolchain/IDE.
-
Neovim
cclsLSP Configuration:
lspconfig.ccls.setup({
on_attach = on_attach,
capabilities = capabilities,
init_options = {
cache = {
directory = ".ccls-cache",
},
},
})- Nix
devShellDependencies:
{
description = "Basic emed flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ ];
};
in
{
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
cmake
ccls
gcc-arm-embedded
];
shellHook = "";
};
}
);
}- Build and LSP Setup: From your code’s root directory:
mkdir -p build
cd build
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..
make -j$(nproc)
cd ..
ln -s build/compile_commands.json .Your LSP is now working!