I’m working on switching over to NixOS on my desktop and one of the last things I haven’t got fully working is my neovim config.
My LSP’s are able to start, and all of them work fine except for clangd. For some reason, it can’t find C/C++ header files for any installed libraries. I have all of the LSPs themselves installed through Mason in Neovim, and I have programs.nix-ld.enable = true
enabled so they can be run correctly.
Here is the shell.nix file I’m using for this project:
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell.override { stdenv = pkgs.gccStdenv; } {
nativeBuildInputs = with pkgs.buildPackages; [
glibc libgcc
clang-tools libclang
SDL2 SDL2_image SDL2_sound
];
CPATH = pkgs.lib.makeSearchPathOutput "dev" "include" pkgs.glibc pkgs.SDL2 pkgs.SDL2_Image pkgs.SDL2_sound;
}
Is there something extra I need to do to get clangd to find the C headers being used by the project? when I actually run gcc it compiles fine, it just can’t seem to find them correctly in Neovim
Edit: Forgot to mention that I’m using this shell with direnv and launching nvim directly from the same shell that I’m compiling from
Not really confident, but is the LSP running from a separate child process? Is that child process inheriting all of the anticipated environment variables from the shell that launched Neovim?
The LSPs load when you open a file in nvim, so I think it would be a child process? Is there any way to check what environment variables a process has, like with gdb or something else?
You inspect the
/proc
file tree orps
utility command: