noib3 / nvim-oxi

:link: Rust bindings to all things Neovim
https://crates.io/crates/nvim-oxi
MIT License
902 stars 45 forks source link

`println!` writes to nvim process #136

Closed patata3000 closed 8 months ago

patata3000 commented 8 months ago

Hey! Sorry to bother, it may not even be a problem coming from nvim-oxi but when I add some println!, neovim catch those and prints them wherever the cursor is.

The println! is coming from a library that I can use either as a library (called by nvim-oxi bindings) or, by CLI.

In the first case (from nvim-oxi), I would like to log to nvim logs or if it's too complicated, I would like to just get rid of them.

In the second case (from CLI), I just want them to be printed to stdout.

Is there or way that doesn't involve too much overhead?

noib3 commented 8 months ago

Use nvim_oxi::print!.

patata3000 commented 8 months ago

Hey thanks for answering quickly!

I want my library to be independent from nvim. So I want to be able to sometimes print in nvim (to the nvim logs) and sometime print to the stdout.

When I use println!, it always prints to stdout but it messes up nvim UI. I don't know how to rewire these println! to for example /dev/null

noib3 commented 8 months ago

Then you'd have to create a separate macro that delegates to either nvim_oxi::print! or to println! based on a feature flag set at compile or on a global variable set at runtime.

However this has nothing to do with this specific project, try asking in the Rust forum instead.

patata3000 commented 8 months ago

Thank you very much. This is what I needed