当我在 NVIM 中打开 Go 文件时,出现错误消息

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

nvim for go 文件中的问题错误消息:

Error executing vim.schedule lua callback: /usr/share/nvim/runtime/lua/vim/lsp/inlay_hint.lua:408: enable: expected boolean, got number
stack traceback:
        [C]: in function 'error'
        vim/shared.lua: in function 'validate'
        /usr/share/nvim/runtime/lua/vim/lsp/inlay_hint.lua:408: in function 'enable'
        ...e/yossef/.local/share/nvim/lazy/go.nvim/lua/go/inlay.lua:322: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>
Press ENTER or type command to continue

the error image

发行版:

经销商 ID:Arch 描述:Arch Linux 发布方式:滚动 代号:不适用

nvim 版本:

NVIM v0.10.0 构建类型:发布 LuaJIT 2.1.1713773202 运行“nvim -V1 -v”以获取更多信息

那么如何解决问题并修复错误

go config neovim treesitter
1个回答
0
投票

我有同样的问题..我的修复:在 gopls 的 on_attach 函数中:

                    on_attach = function(client, bufnr)
                        if client.supports_method("textDocument/inlayHint") then
                            vim.lsp.inlay_hint.enable(true, {
                                assignVariableTypes = true,
                                compositeLiteralFields = true,
                                compositeLiteralTypes = true,
                                constantValues = true,
                                functionTypeParameters = true,
                                parameterNames = true,
                                rangeVariableTypes = true,
                            })
                        end
                    end,

可能在

vim.lsp.inlay_hint.enable
中参数未正确传递。

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