Neovim TreeSitter 没有返回 C 编译器错误

Dot*_*man 2 windows lua neovim

我对 neovim 和 vim 生态系统非常陌生。我仍在尝试开始使用自己的配置文件,但是,从https://github.com/nvim-lua/kickstart.nvim下载 Kickstart 时遇到问题。我将 init.lua 文件复制到我自己的文件中并运行它。它下载了所有正确的内容,但是,treesitter 插件似乎存在问题。当我运行:so我的init.lua文件时,它给出了错误。

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.
Run Code Online (Sandbox Code Playgroud)

这是我第二次尝试与造树者打交道。第一次我下载了 GCC 来尝试解决这个问题。没有任何效果,所以我决定删除整个内容并下载 kickstart 来开始配置过程。我需要一些帮助来解决这个问题,因为我还不熟悉 Vim。

编辑:这是:checkhealth nvim-treesitter给出以下内容的命令。

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.
Run Code Online (Sandbox Code Playgroud)

如您所见,gcc 可用,所以我不确定为什么这不起作用。

Sri*_*h S 7

我遇到了这个问题,并从本文中找到了最简单的解决方案。

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

正如错误所示,您需要安装 cc、gcc、clang 或 zig。

视窗

Zig 对于 Windows 来说是最简单的。

如果你安装了choclaty,那就非常简单了,

choco install zig

如果你没有choclaty,你可以直接从他们的网站安装Zig。

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

乌班图

对于 Ubuntu,我发现的修复方法是安装必需品。

https://itsfoss.com/build-essential-ubuntu/

sudo apt update && sudo apt install build-essential

再次运行 Neovim,错误消失。