-
-
Notifications
You must be signed in to change notification settings - Fork 848
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TSInstall errors with clang set as compiler #1449
Comments
I think this is a problem with clang. When I tried to clone the repo and compile using |
Apple Clang? It's somehow not entering C++ mode. But you have GCC's stdc++ installed? |
Stupid me: using |
@bhavitsharma But it should also work with clang. clang++ will not always handle C files so you've got the inverse problem. |
I guess then it's a problem with my nix configuration rather than treesitter because I can't compile even this with #include <string>
int main() {
return 0;
}
|
But it can happen that clang++ fails with |
I think C++ 17 has supports for designated initializers for struct :) but I get your point. I am not sure if the issue with clang is reproducible in other platforms? Quick internet search reveals to use |
I'm on Neovim 0.5 with compat branch.
WorkaroundCreate a { pkgs ? import <nixpkgs> {} }:
with pkgs;
pkgs.mkShell {
buildInputs = [
gcc
nodejs
neovim
tree-sitter
(python39.withPackages (pp: with pp; [
pynvim
]))
];
} Run require("nvim-treesitter.install").compilers = { "clang++" }
require("nvim-treesitter.configs").setup {
ensure_installed = "all",
} This worked for all language parsers except tree-sitter-rst, tree-sitter-svelte, and tree-sitter-vim. For those, I had to comment out the line: -- require("nvim-treesitter.install").compilers = { "clang++" }
DiscussionMy NixOS configuration was pretty vanilla (just installing packages), so I think the culprit is somewhere in Relevant thread: https://www.reddit.com/r/neovim/comments/oa3xq8/how_to_install_nvimtreesitter_on_nixos/ |
I found a way to reproduce the error. If you have { pkgs ? import <nixpkgs> {} }:
with pkgs;
pkgs.mkShell {
buildInputs = [
gcc
nodejs
neovim
tree-sitter
(python39.withPackages (pp: with pp; [
pynvim
]))
# Including this suddenly breaks TSInstall:
clang glibc musl
];
} Everything works fine without Should this bug be reopened? |
@bhavitsharma only in C++20. There is an open PR to use makefiles to compile c++ with clang++ and the C files with clang. But with only one command you can only use |
Helps avoid errors described in nvim-treesitter/nvim-treesitter#1449
Maybe this issue should still be open? I know there are workarounds, but should treesitter compile C++ files with |
where to write this code in init.lua? |
It worked after I changed my GCC version from gcc-9 to gcc-10.3. This may be helpful for anyone else who is experiencing the same problem. |
I'm another NixOS user, and I'm installing plugins with lazy.nvim instead of through Nix. If you got here because you are in a similar situation, and you are getting oodles of errors when you start neovim, my workaround is to avoid the whole clang issue by setting the grammar compiler to I have this in my plugin config - since I'm using lazy.nvim I put this in the require('nvim-treesitter.install').compilers = { 'gcc' } And to make sure that gcc is available while running neovim I have neovim installed through Home Manager like this (see in context): programs.neovim = {
enable = true;
defaultEditor = true;
withPython3 = true;
extraPackages = with pkgs; [
gcc
# ...
];
}; |
Describe the bug
TSInstall cpp
fails to compile when using clang as a compiler on nixos.To Reproduce
env CC=$(which clang) nvim '+TSInstallSync cpp'
Expected behavior
Should compile
Output of
:checkhealth nvim_treesitter
Output of
nvim --version
NVIM v0.5.0-dev Build type: Release LuaJIT 2.1.0-beta3 Compilation: Compiled by nixbld
Features: +acl +iconv +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "
/nix/store/bqfq1sz0ifjf6gnz6j6iqx5015p4yz1d-neovim-unwrapped-master/share/nvim
Run :checkhealth for more info
Additional context
I am using homemanager for managing my dotfiles and here's my config for
nvim.nix
.The text was updated successfully, but these errors were encountered: