nvim treesitter 在编辑 golang 文件时突出显示错误

问题描述 投票:0回答:1

过去几周我一直在使用 neovim 编辑 .go 文件,没有任何问题,但是在安装了 ubuntu 的软件更新后(如果重要的话,我正在使用 Ubuntu 22.04.4 LTS),现在只要我打开任何扩展名为 .go 的文件并尝试输入

import "
它用以下错误轰炸我:


Error in decoration provider treesitter/highlighter.line:                                                                                                                                                 
Error executing lua: ...nvim-treesitter/lua/nvim-treesitter/query_predicates.lua:80: attempt to call method 'parent' (a nil value)                                                                                 
stack traceback:                                                                                                                                                                                                   
        ...nvim-treesitter/lua/nvim-treesitter/query_predicates.lua:80: in function 'handler'                                                                                                                      
        /usr/share/nvim/runtime/lua/vim/treesitter/query.lua:758: in function 'fn'                                                                                                                                 
        /usr/share/nvim/runtime/lua/vim/func/_memoize.lua:58: in function 'match_preds'                                                                                                                            
        /usr/share/nvim/runtime/lua/vim/treesitter/query.lua:874: in function 'iter'                                                                                                                               
        /usr/share/nvim/runtime/lua/vim/treesitter/highlighter.lua:313: in function 'fn'                                                                                                                           
        /usr/share/nvim/runtime/lua/vim/treesitter/highlighter.lua:213: in function 'for_each_highlight_state'                                                                                                     
        /usr/share/nvim/runtime/lua/vim/treesitter/highlighter.lua:294: in function 'on_line_impl'                                                                                                                 
        /usr/share/nvim/runtime/lua/vim/treesitter/highlighter.lua:370: in function </usr/share/nvim/runtime/lua/vim/treesitter/highlighter.lua:364>

运行

:TSUpdate go
,没有解决问题。

:checkhealth 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 v20.14.0 (only needed for :TSInstallFromGrammar)
- OK `git` executable found.
- OK `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
  Version: cc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.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 = "6.8.0-40-generic",
  sysname = "Linux",
  version = "#40~22.04.3-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 30 17:30:19 UTC 2"
} ~

Parser/Features         H L F I J
  - bash                ✓ ✓ ✓ . ✓
  - c                   ✓ ✓ ✓ ✓ ✓
  - gitcommit           ✓ . . . ✓
  - gitignore           ✓ . . . ✓
  - go                  ✓ ✓ ✓ ✓ ✓
  - gomod               ✓ . . . ✓
  - javascript          ✓ ✓ ✓ ✓ ✓
  - json                ✓ ✓ ✓ ✓ .
  - jsonc               ✓ ✓ ✓ ✓ ✓
  - lua                 ✓ ✓ ✓ ✓ ✓
  - markdown            ✓ . ✓ ✓ ✓
  - markdown_inline     ✓ . . . ✓
  - php                 ✓ ✓ ✓ ✓ ✓
  - proto               ✓ . ✓ . ✓
  - query               ✓ ✓ ✓ ✓ ✓
  - typescript          ✓ ✓ ✓ ✓ ✓
  - vim                 ✓ ✓ ✓ . ✓
  - vimdoc              ✓ . . . ✓
  - xml                 ✓ ✓ ✓ ✓ ✓
  - yaml                ✓ ✓ ✓ ✓ ✓

  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} ~
neovim treesitter
1个回答
0
投票

我也有同样的问题。运行 :TSUpdate go 或 :TSInstall go 也没有为我解决任何问题

© www.soinside.com 2019 - 2024. All rights reserved.