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

nvim_call_atomic not available via Lua on nvim 0.4.3 or 0.4.4 #13191

Closed
chipsenkbeil opened this issue Oct 29, 2020 · 3 comments
Closed

nvim_call_atomic not available via Lua on nvim 0.4.3 or 0.4.4 #13191

chipsenkbeil opened this issue Oct 29, 2020 · 3 comments

Comments

@chipsenkbeil
Copy link

chipsenkbeil commented Oct 29, 2020

  • nvim --version:
NVIM v0.4.3
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/bin/cc -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -O2 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/build/neovim/src/build/config -I/build/neovim/src/neovim-0.4.3/src -I/usr/include -I/build/neovim/src/build/src/nvim/auto -I/build/neovim/src/build/include
Compiled by builduser

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info
NVIM v0.4.4
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/bin/cc -D_FORTIFY_SOURCE=2 -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/build/neovim/src/build/config -I/build/neovim/src/neovim-0.4.4/src -I/usr/include -I/build/neovim/src/build/src/nvim/auto -I/build/neovim/src/build/includeCompiled by builduser
Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info
  • vim -u DEFAULTS (version: ) behaves differently?
  • Operating system/version: ArchLinux w/ kernel 5.7.12-arch1-1
  • Terminal name/version: Blink Shell v13.5.7.224
  • $TERM: screen-256color

Steps to reproduce using nvim -u NORC

nvim -u NORC +'lua vim.api.nvim_call_atomic({{"nvim_get_var", {"fish"}}, {"nvim_del_var", {"fish"}}})'

Actual behaviour

Function is missing from API despite being listed in api.txt.

E5105: Error while calling lua chunk: [string "<VimL compiled string>"]:1: attempt to call field 'nvim_call_atomic' (a nil value)

Was also mentioned here.

Expected behaviour

Function is accessible. In the above case, we'd return a two-element array with errors not being nil.

@chipsenkbeil chipsenkbeil added the bug issues reporting wrong behavior label Oct 29, 2020
@chipsenkbeil chipsenkbeil changed the title nvim_call_atomic not available on nvim 0.4.3 nvim_call_atomic not available on nvim 0.4.3 or 0.4.4 Oct 29, 2020
@chipsenkbeil chipsenkbeil changed the title nvim_call_atomic not available on nvim 0.4.3 or 0.4.4 nvim_call_atomic not available via Lua on nvim 0.4.3 or 0.4.4 Oct 29, 2020
@erw7
Copy link
Contributor

erw7 commented Nov 2, 2020

The FUNC_API_REMOTE_ONLY attribute is set to nvim_call_atomic() as shown below. Therefore, it will not be exported to vim.api.

neovim/src/nvim/func_attr.h

Lines 212 to 213 in 90f3a8b

/// API function not exposed in VimL/eval.
# define FUNC_API_REMOTE_ONLY

neovim/src/nvim/api/vim.c

Lines 1887 to 1888 in 90f3a8b

Array nvim_call_atomic(uint64_t channel_id, Array calls, Error *err)
FUNC_API_SINCE(1) FUNC_API_REMOTE_ONLY

The built in lua execution should always be atomic, so there is no need for nvim_call_atomic(). The api.txt does not indicate whether it is "REMOTE ONLY" or not, so you will need to look at the source code. I think the api.txt needs to be improved.

@erw7 erw7 added lua stdlib and removed bug issues reporting wrong behavior labels Nov 2, 2020
@chipsenkbeil
Copy link
Author

I didn't know where to look, so this is good to know. Agree that having some mention of what is remote only, etc. in the doc would also be helpful. :)

@lewis6991
Copy link
Member

nvim_call_atomic is now documented with:

                Attributes: ~
                    |RPC| only

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

No branches or pull requests

4 participants