I am new to NixOS. I found that my Neovim configuration works directly on NixOS, but soon I discovered some issues. I need to use clangd
as the LSP to check my C++ code and support features like code navigation. However, no matter where I place the compile_commands.json
file, clangd
does not seem to recognize it. As a result, it fails to support syntax checking and symbol navigation—for example, it cannot even jump into <iostream>
.
How can I make clangd
work on NixOS just like on a regular Linux distribution? Do I need to use home-manager
? I am not a fan of this approach because I prefer to keep my Neovim configuration unified across different Linux distributions rather than customizing it specifically for NixOS. Can something like nixvim
solve this problem?
LSP output is as follows:
LSP configs active in this buffer (bufnr: 9) ~
- Language client log: ~/.local/state/nvim/lsp.log
- Detected filetype:
cpp
- 2 client(s) attached to this buffer
- Client:
clangd
(id: 1, bufnr: [9, 8, 10, 3])
root directory: ~/Workspace/Test/cpp/01/
filetypes: c, cpp, objc, objcpp, cuda, proto
cmd: ~/.local/share/nvim/mason/bin/clangd
version:clangd version 19.1.2 (https://github.com/llvm/llvm-project 7ba7d8e2f7b6445b60679da826210cdde29eaf8b)
executable: true
autostart: true - Client:
null-ls
(id: 2, bufnr: [9, 8, 10, 3])
root directory: ~/Workspace/Test/cpp/01/
filetypes: c, java, cuda, proto, cpp, cs, lua, luau, nix
cmd: ~/Workspace/Test/cpp/01/
version: ? (cmd is a function)
executable: NA
autostart: false