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

Any way to get value from NeoVim? #184

Open
TamaMcGlinn opened this issue Nov 10, 2022 · 1 comment
Open

Any way to get value from NeoVim? #184

TamaMcGlinn opened this issue Nov 10, 2022 · 1 comment

Comments

@TamaMcGlinn
Copy link

TamaMcGlinn commented Nov 10, 2022

In order to configure a linter, I'm trying to read a global from the currently active NeoVim instance (the one that spawned the linter, in this case). Basically, I am trying to get something like this to work:

nvr +echo\ g:fugitive_conflict_x

(for the example I just picked an arbitrary global everyone likely has defined; it is either 0 or 1)

It works if I throw it, but this is just disgusting; can we get a print option in nvr or something?

nvr +throw\ g:fugitive_conflict_x 2>&1 | grep NvimError | sed 's/pynvim.api.common.NvimError: //'

I would have expected writing to stdout the same way as in vim to work (described here), but it doesn't seem to.

@joshbode
Copy link

joshbode commented Mar 3, 2024

Very late response, but you should be able to use --remote-expr to get this working, e.g.

$ nvr --remote-expr "g:lua_version"
5

Note: you'll get an error if the variable doesn't exist, e.g.

$ nvr --remote-expr "g:fugitive_conflict_x"

No valid expression: g:fugitive_conflict_x
Test it in Neovim: :echo eval('...')
If you want to execute a command, use -c or -cc instead.

$ echo $?
0

although the exit-code will still be zero.

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

2 participants