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

NameError: name 'vim' is not defined when in neovim #101

Closed
theniceboy opened this issue Jan 28, 2020 · 8 comments · Fixed by #102
Closed

NameError: name 'vim' is not defined when in neovim #101

theniceboy opened this issue Jan 28, 2020 · 8 comments · Fixed by #102

Comments

@theniceboy
Copy link

Describe the bug
I am trying to setup Vimspector with Neovim, and I am getting this error when I call vimspector#Launch():

Error detected while processing function vimspector#internal#state#Reset[8]..provider#python3#Call:
line   18:
Error invoking 'python_execute' on channel 8 (python3-script-host):
Traceback (most recent call last):
  File "<string>", line 2, in <module>
NameError: name 'vim' is not defined
Error detected while processing function vimspector#Continue[1]..provider#python3#Call:
line   18:
Error invoking 'python_execute' on channel 8 (python3-script-host):
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name '_vimspector_session' is not defined

My NeoVim has both python2 and 3 support. (pynvim installed)

To Reproduce
I followed this issue and added

Plug 'puremourning/vimspector', {'do': './install_gadget.py --enable-c --enable-python'}

to my init.vim.

When I :call vimspector#ToggleBreakpoint() or :call vimspector#Launch(), I would get the error listed above.

Vimspector config file:

{
  "configurations": {
    "<name>: Launch": {
      "adapter": "vscode-cpptools",
      "configuration": {
        "name": "<name>",
        "type": "cppdbg",
        "request": "launch",
        "program": "${workspaceRoot}/debug/neodm",
        "cwd": "${workspaceRoot}",
        "externalConsole": true,
        "stopAtEntry": true,
        "MIMode": "gdb"
      }
    },
    "<name>: Attach": {
      "adapter": "vscode-cpptools",
      "configuration": {
        "name": "<name>: Attach",
        "type": "cppdbg",
        "request": "attach",
        "program": "${workspaceRoot}/debug/neodm",
        "MIMode": "gdb"
      }
    }
  }
}

(~/.vimspector.log is empty)

Environemnt

  • Output of vim --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-unu
sed-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-s
trong -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/neovi
m/src/build/include
Compiled by builduser

Features: +acl +iconv +tui
  • Output of which vim:
/usr/bin/vim (sym linked to /usr/bin/nvim)
  • Output of :py3 pass:
  • Operating system: and version
    Up-to-date Arch Linux
@puremourning
Copy link
Owner

Error invoking 'python_execute' on channel 8 (python3-script-host):
Traceback (most recent call last):
File "", line 2, in
NameError: name 'vim' is not defined

this suggests that your neovim is broken or not correctly installed.

Please check :checkhealth and paste the output of :py3 import vim and following that :py3 print( vim.version )

@mellery451
Copy link

FWIW, I have exactly the same errors reported here when running through the demo using neovim (latest version 0.4.3). checkhealth is all green for me. Demo works perfectly with vim8 on the same system with same vimrc.

@puremourning
Copy link
Owner

hmm ok let me have a look. But I need a solid reproducible case, as this doesn't repro for me.

@puremourning
Copy link
Owner

OK I think there is yet-another-neovim-vs-vim-incompatibility.

In Vim, the vim module is always (automatically) imported. Apparently in neovim it isn't. I'll ask the neovim people, but I can see where this is going ...

@puremourning
Copy link
Owner

can you try applying this patch locally to see if it fixes it :

in autoload/vimspector/internal/state.vim, before from vimspector import debug_session, add import vim as in:

function! vimspector#internal#state#Reset() abort
  let prefix = ''
  if s:is_neovim
    let prefix='neo'
  endif
    py3 << EOF
import vim
from vimspector import debug_session
_vimspector_session = debug_session.DebugSession( vim.eval( 'prefix' ) )
EOF
endfunction

@mellery451
Copy link

🎆 ...that worked for me.

@puremourning
Copy link
Owner

neovim/neovim#11783

I'll fix this in vimspector. standby.

@mergify mergify bot closed this as completed in #102 Jan 28, 2020
@puremourning

This comment has been minimized.

@puremourning puremourning changed the title Unable to setup Vimspector with NeoVim NameError: name 'vim' is not defined when in neovim Jan 28, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants