jbyuki / one-small-step-for-vimkind

Debug adapter for Neovim plugins
MIT License
396 stars 10 forks source link

Vim:Error invoking 'nvim_exec_lua' on channel 7 #17

Closed NEX-S closed 2 years ago

NEX-S commented 2 years ago

if i using this to auto enable the osv

vim.api.nvim_create_autocmd({ "FileType" }, {
    pattern = "lua",
    callback = function ()
        require "osv".launch({
            host = '127.0.0.1',
            port = 8088,
            log = false
        })
    end
})

then i will get this error messages

Error detected while processing CursorMoved Autocommands for "*":
E5108: Error executing lua ...vim/site/pack/packer/opt/packer.nvim/lua/packer/load.lua:165: Vim(echomsg):E114: Missing quote: "Error in packer_compiled: ...vim/site/pack/packer/opt/packer.nvim/lu
a/packer/load.lua:155: Vim(append):Error executing lua callback: /usr/share/nvim/runtime/filetype.lua:20: Vim(append):Error executing lua callback: Vim:Error invoking 'nvim_exec_lua' on channel 7
:
stack traceback:
        [C]: in function 'cmd'
        ...vim/site/pack/packer/opt/packer.nvim/lua/packer/load.lua:165: in function <...vim/site/pack/packer/opt/packer.nvim/lua/packer/load.lua:161>
        [string ":lua"]:1: in main chunk
NEX-S commented 2 years ago

I don't know why this would happen. I am wondering if there are any ways I can using <C-d> to call dap.continue() in all languages that I have configured.

For example: in C, I press <C-d>, dap starting to work. in Python, I press <C-d>, dap starting to work. in Lua, I press <C-d>, dap starting to work too (not asking me the host or port, set it default to 127.0.0.1 and 8088)

I wish "osv" can automatic start when I press <C-d> in lua.

i have tried to using autocmd to reach that for me.

vim.api.nvim_create_autocmd({ "FileType" }, {
    pattern = "lua",
    callback = function ()
        vim.keymap.set('n', '<C-d>', require "osv".run_this, { noremap = true, silent = true })
    end
})

but i will got this messages

Couldn't connect to 127.0.0.1:8088: ECONNREFUSED

here's my config

dap.configurations.lua = {
    {
        type = 'nlua',
        request = 'attach',
        name = "Attach to running Neovim instance",
        host = '127.0.0.1',
        port = 8088,
    }
}

dap.adapters.nlua = function (callback, config)
    callback({ type = 'server', host = config.host, port = config.port })
end
jbyuki commented 2 years ago

Hi,

So one-small-step-for-vimkind is not really meant to be used as a debugger for vanilla lua scripts. It was specifically designed to debug neovim plugins. Meaning you still need to manually start another instance + start the server with launch(). You can still have a shortcut to dap.continue() in the debugger instance, which I also do. Maybe that clears some issues.

There is WIP ways to automatically start another neovim instance, and the debugger automatically here but this only works for linux/alacritty currently.

NEX-S commented 2 years ago

Thanks!