nvim-neotest / neotest-python

MIT License
115 stars 34 forks source link

vim/_editor.lua:0: E5560: Vimscript function must not be called in a lua loop callback #74

Closed tmwatchanan closed 2 months ago

tmwatchanan commented 2 months ago

NeoVim Version

NVIM v0.10.0-dev-2993+gc81b7849a-Homebrew
Build type: Release
LuaJIT 2.1.1713517273
Run "nvim -V1 -v" for more info

Describe the bug Error message:

notify.warn Neotest neotest-python: vim/_editor.lua:0: E5560: Vimscript function must not be called in a lua loop callback

To Reproduce Please provide a minimal init.lua to reproduce which can be run as the following:

nvim --clean -u minimal.lua

You can edit the following example file to include your adapters and other required setup.

vim.opt.runtimepath:remove(vim.fn.expand("~/.config/nvim"))
vim.opt.packpath:remove(vim.fn.expand("~/.local/share/nvim/site"))

local lazypath = "/tmp/lazy/lazy.nvim"

if not vim.loop.fs_stat(lazypath) then
    vim.fn.system({
        "git",
        "clone",
        "--filter=blob:none",
        "https://github.com/folke/lazy.nvim.git",
        "--branch=stable", -- latest stable release
        lazypath,
    })
end

vim.opt.rtp:prepend(lazypath)

require("lazy").setup({
    "nvim-neotest/neotest",
    dependencies = {
        "nvim-lua/plenary.nvim",
        "nvim-treesitter/nvim-treesitter",
        -- Install adapters here
        "nvim-neotest/neotest-python",
    },
    config = function()
        -- Install any required parsers
        require("nvim-treesitter.configs").setup({
            ensure_installed = {},
        })

        require("neotest").setup({
            -- Add adapters to the list
            adapters = {

                require('neotest-python')({
                    dap = { justMyCode = false },
                    python = require('config.python').get_python_path(),
                    args = {
                        '-s',
                        '-vv',
                    },
                }),
            },
        })
    end,
    keys = function()
        return {
            { '<leader>tn', function() require('neotest').run.run() end },
        }
    end,
})

Steps to reproduce the behavior:

  1. Go to any Python unit test function
  2. Press <leader>tn to test the function
  3. See error

An example test files to reproduce: File path: tests/test_foo.py

class TestFoo:
    def test_foo(self):
        assert 1 + 2 == 3

Expected behavior It should run unit test for the function.

tmwatchanan commented 2 months ago

Fixed in https://github.com/neovim/neovim/pull/28492