0

I am trying to inspect a lua variable whose name is bufferline.options.indicator

How does one inspect a lua variable in Neovim ?

2
  • 1
    In Vim, I would traditionally do :echo <var> or :PP <var> with scriptease. Maybe something like :lua print <var> or whatever the syntax is?
    – D. Ben Knoble
    Commented Apr 7, 2023 at 13:59
  • @D.BenKnoble I have tried lua print(vim.opt.scrolloff) which set to 1024 for example, but I only get a table 0xdeadbeefdead I didn´t know about PP !
    – cassepipe
    Commented Apr 9, 2023 at 14:40

2 Answers 2

5
  • The = syntax

:lua =var

In version 0.9, you don't even need to type in lua :

:=var will do.

  • The vim.print() syntax

Before version 0.9, there was :lua vim.pretty_print(var)

Now with 0.9, vim.pretty_print has been renamed to vim.print so it's :

:lua vim.print(var)

  • Lua's print + vim.inspect() syntax

:lua print(vim.inspect(var))

0

The command should be nvim_buf_get_option({buffer}, {name}), look at the :help page for more info.

1
  • 1
    This is the API, I meant in when you are in the editor
    – cassepipe
    Commented Apr 9, 2023 at 14:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.