简体   繁体   中英

Neovim TreeSitter Returning No C Complier Error

I am very new to neovim and the vim ecosystem. I am still trying to get started with my own config file, however, I am running into an issue when downloading Kickstart from https://github.com/nvim-lua/kickstart.nvim . I copied the init.lua file into my own file and ran it. It downloaded all of the correct things, however, there seems to be an issue with the treesitter plugin. When I ran :so on my init.lua file, it gave and error.

Re-sourcing your config is not supported with lazy.nvim
Error detected while processing :source (no file):
No C compiler found! "cc", "gcc", "clang", "cl", "zig" are not executable.

This is my second time trying to deal with treesetter. The first time around I downloaded GCC to try and fix the issue. Nothing worked so I decided to delete the whole thing and download kickstart to begin the config process. I need a bit of help with this issue as I am not familiar with Vim yet.

Edit: This is the :checkhealth nvim-treesitter command that gave the following.

nvim-treesitter: require("nvim-treesitter.health").check()
========================================================================
## Installation
  - WARNING: `tree-sitter` executable not found (parser generator, only needed for :TSInstallFromGrammar, not required for :TSInstall)
  - OK: `node` found v16.14.2 (only needed for :TSInstallFromGrammar)
  - OK: `git` executable found.
  - OK: `gcc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
    Version: gcc (MinGW.org GCC-6.3.0-1) 6.3.0
  - OK: Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.

## OS Info:
{
  machine = "x86_64",
  release = "10.0.22621",
  sysname = "Windows_NT",
  version = "Windows 10 Home"
}

## Parser/Features         H L F I J
  - c                   x x x x x
  - cpp                 x x x x x
  - go                  x x x x x
  - help                x . . . x
  - javascript          x x x x x
  - lua                 x x x x x
  - python              x x x x x
  - rust                x x x x x
  - tsx                 x x x x x
  - typescript          x x x x x
  - vim                 x x x . x

  Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
         +) multiple parsers found, only one will be used
         x) errors found in the query, try to run :TSUpdate {lang}

## The following errors have been detected:
  - ERROR: c(highlights): Failed to load parser: uv_dlopen: C:\Users\sadda\AppData\Local\nvim-data\lazy\nvim-treesitter\parser\c.so is not a valid Win32 application.
    
    c(highlights) is concatenated from the following files:
    | [ERROR]:"C:\Users\sadda\AppData\Local\nvim-data\lazy\nvim-treesitter\queries\c\highlights.scm", failed to load: Failed to load parser: uv_dlopen: C:\Users\sadda\AppData\Local\nvim-data\lazy\nvim-treesitter\parser\c.so is not a valid Win32 application.
  - ERROR: c(locals): Failed to load parser: uv_dlopen: C:\Users\sadda\AppData\Local\nvim-data\lazy\nvim-treesitter\parser\c.so is not a valid Win32 application.

As you can see, gcc is available, so I am not sure why this is not working.

Tree-sitter needs to locate correct libraries such as "libstdc++-6.dll" among others. Such dll files are included in Neovim directory. To ensure that Tree-sitter correctly locates correct version of libraries, modify your system's Path environment variable so that the path to Neovim is above other paths that might have dll files.

To do that, follow the instructions below:

  1. press WindowsKey + R
  2. Type sysdm.cpl,3
  3. Click on Environment Variables
  4. Under User Variables, there should be a Path variable with some values in it.
  5. Double click on the Path variable
  6. You will see a list of Path variables
  7. Click on the item which has path to Neovim executable
  8. Press move up button a few times so the system can prioritize dll files in Neovim directory.
  9. Now do a :TSUpdate all inside Neovim to recompile Tree-sitter parsers.

I had this issue and I found the easiest fix from this article.

https://blog.nikfp.com/how-to-install-and-set-up-neovim-on-windows

Like the error says you need to install cc, gcc, clang or zig. Zig is the easiest for Windows.

If you have choclatey installed it is super easy,

choco install zig

If you don't have it you can install it from their site.

https://ziglang.org/learn/getting-started/

Run Neovim again and the error goes away.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM