Hi all,
I use clangd while working on neovim. The compile-commands generated on other distributions work fine, but I’m getting missing library issues on nix. Has anyone solved this issue?
If you need an editor + language client to try this out, you can use neovim’s minimal init.lua here: https://github.com/neovim/nvim-lspconfig/blob/86b316140a5fdc902e89ff585ce429357ce4d5df/test/minimal_init.lua (with clangd substituted for pyright)
git clone https://github.com/neovim/neovim
&& cd neovim
nix develop contrib/
cmakeConfigurePhase
cp compile-commands.json ..
cd ..
nvim src/nvim/main.c
I get many errors of the form:
'assert.h' file not found with <angled> include; use "quotes" instead (fix available)`
In included file: 'inttypes.h' file not found
which don’t occur on traditional distributions.
3 Likes
teto
January 23, 2021, 3:12pm
2
I’ve seen the same behavior without investigating. I wonder if changing the llvm version fixes it.
I tried llvm_latest and llvm_{8,9,10}. 7 is too old. All of the above still show the issue
Try add
CPATH = lib.makeSearchPathOutput "dev" "include" buildInputs;
as an attribute in your derivation, that might fix your problem.
Unfortunately that didn’t seem to do it, still getting
6 Diagnostics:
7 1. 'assert.h' file not found with <angled> include; use "quotes" instead (fix available)
8 2. In included file: 'auto/config.h' file not found
Maybe I’m using it incorrectly, but I get the same issue with nix develop ./contrib when I make the following modifications to the flake:
diff --git a/contrib/flake.nix b/contrib/flake.nix
index d18534215..a21e0466a 100644
--- a/contrib/flake.nix
+++ b/contrib/flake.nix
@@ -13,14 +13,35 @@
pkgs = nixpkgs.legacyPackages.${prev.system};
in
rec {
+ clang-tools = let
+ in
+ prev.clang-tools.overrideAttrs (
+ o: {
+ pname = o.pname + "-with-fixed-cpath";
+
+ installPhase =
+ builtins.replaceStrings [ "export clang" ] [
+ ''
+ libcpp_includes+=":$libc_includes"
+ libc_includes=""
+ export clang''
+ ]
+ o.installPhase;
+
+ }
+ );
+
neovim = pkgs.neovim-unwrapped.overrideAttrs (oa: {
version = "master";
src = ../.;
buildInputs = oa.buildInputs ++ ([
pkgs.tree-sitter
+ final.clang-tools
]);
+ # CPATH = prev.lib.makeSearchPathOutput "dev" "include" oa.buildInputs;
+
cmakeFlags = oa.cmakeFlags ++ [
"-DUSE_BUNDLED=OFF"
];