Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to debug non-neovim lua code? #5

Closed
vatosarmat opened this issue Jul 31, 2021 · 5 comments
Closed

How to debug non-neovim lua code? #5

vatosarmat opened this issue Jul 31, 2021 · 5 comments

Comments

@vatosarmat
Copy link

Suppose I have a standalone main.lua with #!/usr/bin/lua which does some smart and tricky suftt and therefore it is complicated and therefore I need a debugger with breakpoints to debug it. How to run main.lua under OSV? Maybe there should be an instruction for that

@jbyuki
Copy link
Owner

jbyuki commented Jul 31, 2021

If you can run your script using the embedded lua debugger ( luajit 2.1 ) just go ahead and invoke run_this() with the script open. If you want to use an external lua interpreter I'm afraid it's currently not possible. Have you looked at lua-debug?

@jbyuki
Copy link
Owner

jbyuki commented Jul 31, 2021

It would perfectly possible for me to implement debugging for non-Neovim code, it's just that I never use it outside Neovim so I didn't build any.

@vatosarmat
Copy link
Author

Ok, thanks. Could you hint what are the diffs between .lua.t files and just .lua? and where @annotations in .lua.t come from?

@jbyuki
Copy link
Owner

jbyuki commented Jul 31, 2021

Sure, I'm coding in the lua.t files which in turn generate the lua files using a literate programming plugin called ntangle.nvim. I've coded the past year with it and sticky with it for the moment.

If you want you can install the plugin and it should be ready to use. The docs also explain about the syntax. I would be happy to review any PR.

@SerhatTeker
Copy link

If you can run your script using the embedded lua debugger ( luajit 2.1 ) just go ahead and invoke run_this() with the script open. If you want to use an external lua interpreter I'm afraid it's currently not possible. Have you looked at lua-debug?

Hi,
I have luajit 2.1 on my OS, however running run_this() in any non-neovim file gives module 'osv' not found error.

Error Log
E5108: Error executing lua Vim:Error invoking 'nvim_exec_lua' on channel 6:
Error executing lua: [string "<nvim>"]:1: module 'osv' not found:
        no field package.preload['osv']
        no file './osv.lua'
        no file '/home/runner/work/neovim/neovim/.deps/usr/share/luajit-2.1.0-beta3/osv.lua'
        no file '/usr/local/share/lua/5.1/osv.lua'
        no file '/usr/local/share/lua/5.1/osv/init.lua'
        no file '/home/runner/work/neovim/neovim/.deps/usr/share/lua/5.1/osv.lua'
        no file '/home/runner/work/neovim/neovim/.deps/usr/share/lua/5.1/osv/init.lua'
        no file './osv.so'
        no file '/usr/local/lib/lua/5.1/osv.so'
        no file '/home/runner/work/neovim/neovim/.deps/usr/lib/lua/5.1/osv.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
        [C]: in function 'require'
        [string "<nvim>"]:1: in main chunk
stack traceback:
        [C]: in function 'rpcrequest'
        ...packer/start/one-small-step-for-vimkind/lua/osv/init.lua:706: in function 'run_this'
        [string ":lua"]:1: in main chunk

It seems this error is similar to #11 , however I'm using default config, not nvim -u ${CONFIG_FILE}.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants