GithubHelp home page GithubHelp logo

Comments (5)

nanotee avatar nanotee commented on July 22, 2024 2

Looking at :help lua-commands, the built-in print() function is wired to the message area instead of standard output:

The Lua print() function redirects its output to the Nvim message area, with
arguments separated by " " (space) instead of "\t" (tab).

This isn't immediately obvious from reading the guide though, and people might want to test that everything is working correctly. I'll add a short paragraph about this, thank you for the suggestion!

from nvim-lua-guide.

Julian avatar Julian commented on July 22, 2024 1

Interesting -- print was the first thing I tried and didn't see the output in :messages, but that likely instead means the thing I tried was indeed not running :D

And yeah thanks for writing this!

from nvim-lua-guide.

clason avatar clason commented on July 22, 2024 1

One small gotcha people might not expect is that a silent! in a command also prevents Lua print output. So

nnoremap silent! <leader>l :lua print('foo')<cr>

in fact prints nothing when entering <leader>l.

from nvim-lua-guide.

nanotee avatar nanotee commented on July 22, 2024

@clason Did you mean nnoremap <silent>? I did a few tests and both of these mappings seem to be equivalent:

nnoremap <silent> <leader>l :echomsg 'foo'<CR> " prints 'foo'
nnoremap <silent> <leader>l :lua print('foo')<CR> " prints 'foo'

from nvim-lua-guide.

clason avatar clason commented on July 22, 2024

No, I meant what I wrote (:h silent). It may in fact not be very surprising, although I have repeatedly added debug print statements to Lua functions I call via silent! and then wondered why I didn't see that output (because I didn't connect the vimscript command with the Lua function)...

from nvim-lua-guide.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.