raghur / vim-ghost

Vim/Nvim client for GhostText - Edit browser text areas in Vim/Neovim
333 stars 13 forks source link

"Undefined variable: max_length" when trying to connect Neovim with Firefox #6

Closed maxigaz closed 6 years ago

maxigaz commented 6 years ago

I have the following error message when I run :GhostStart in Neovim, focus a text area on github.com and then click on the GhostText addon's icon in Firefox:

error caught while executing async callback:
NvimError(b'Vim(echo):E121: Undefined variable: max_length',)
Traceback (most recent call last):
  File "/home/xxx/.config/nvim/plugged/vim-ghost/rplugin/python3/ghost.py", line 178, in _handle_on_message
    max_length=50)
TypeError: slugify() got an unexpected keyword argument 'max_length'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/xxx/.config/nvim/plugged/vim-ghost/rplugin/python3/ghost.py", line 198, in _handle_on_message
    self.nvim.command("echo '%s'" % ex)
  File "/usr/lib/python3.6/site-packages/neovim/api/nvim.py", line 217, in command
    return self.request('nvim_command', string, **kwargs)
  File "/usr/lib/python3.6/site-packages/neovim/api/nvim.py", line 130, in request
    res = self._session.request(name, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/neovim/msgpack_rpc/session.py", line 97, in request
    raise self.error_wrapper(err)
neovim.api.nvim.NvimError: b'Vim(echo):E121: Undefined variable: max_length'

the call was requested at
  File "/usr/lib/python3.6/site-packages/SimpleWebSocketServer/SimpleWebSocketServer.py", line 566, in _parseMessag
e
    self._handlePacket()
  File "/usr/lib/python3.6/site-packages/SimpleWebSocketServer/SimpleWebSocketServer.py", line 238, in _handlePacke
t
    self.handleMessage()
  File "/home/xxx/.config/nvim/plugged/vim-ghost/rplugin/python3/ghost.py", line 36, in handleMessage
    self.server.context.on_message(req, self)
  File "/home/xxx/.config/nvim/plugged/vim-ghost/rplugin/python3/ghost.py", line 214, in on_message
    self.nvim.async_call(self._handle_on_message, req, websocket)
Press ENTER or type command to continue

After this message, I see a popup message in Firefox that the addon has successfully connected to the editor, yet there's no sync between the browser window and Neovim when I edit inside either one.

By the way, I'm not sure if it's related, but I'd also like to mention that even though I added Plug 'raghur/vim-ghost', {'do': ':GhostInstall'} to my vimrc, I had to install simple-websocket-server with sudo pip install git+https://github.com/dpallot/simple-websocket-server.git and python-slugify with sudo pip install slugify, otherwise I would get an error message on running :GhostInstall that these modules were missing.

Running Manjaro Linux, Neovim v0.2.2, Python 3.6.4, and Firefox 58.0.2.

mcepl commented 6 years ago

I guess it is the same with neovim 0.2.2, Python 3.4.5, and Firefox 59.0b14 on RHEL 7.5

raghur commented 6 years ago

By the way, I'm not sure if it's related, but I'd also like to mention that even though I added Plug 'raghur/vim-ghost', {'do': ':GhostInstall'} to my vimrc, I had to install simple-websocket-server with sudo pip install git+https://github.com/dpallot/simple-websocket-server.git and python-slugify with sudo pip install slugify, otherwise I would get an error message on running :GhostInstall that these modules were missing.

Can you check permissions on the install script (top level of plugin folder)? GhostInstall just installs these dependencies with pip install --user

mcepl commented 6 years ago

Pro mě to je -rwxrwxr-x. (775)

raghur commented 6 years ago

That's wierd... so install does have execute perms. What happens if you run ./install from the ghost folder from the terminal? I'm at a loss to understand why the installlation doesn't work.

mcepl commented 6 years ago

It does what it is supposed to do.

matej@mitmanek: vim-ghost (master)$ ./install 
Collecting git+https://github.com/dpallot/simple-websocket-server.git (from -r requirements_posix.txt (line 1))
  Cloning https://github.com/dpallot/simple-websocket-server.git to /tmp/pip-dmnazwsc-build
Collecting python-slugify (from -r requirements_posix.txt (line 2))
  Downloading python_slugify-1.2.4-py2.py3-none-any.whl
Collecting Unidecode>=0.04.16 (from python-slugify->-r requirements_posix.txt (line 2))
  Downloading Unidecode-1.0.22-py2.py3-none-any.whl (235kB)
    100% |████████████████████████████████| 235kB 1.7MB/s 
Installing collected packages: Unidecode, python-slugify, SimpleWebSocketServer
  Running setup.py install for SimpleWebSocketServer ... done
Successfully installed SimpleWebSocketServer-0.1.0 Unidecode-1.0.22 python-slugify-1.2.4
matej@mitmanek: vim-ghost (master)$
mcepl commented 6 years ago

Actually, it might be the problem with having two python3 interpreters on my system. And while neovim uses python3.4, pip3 is for python3.6. Better to follow David Beazley’s example and run python3 -mpip install.

raghur commented 6 years ago

Sounds good - just pushed 842730b

maxigaz commented 6 years ago

Can you check permissions on the install script (top level of plugin folder)?

install had rwxr-xr-x while install.cmd had rw-r--r--. I changed both to 775, so now :GhostInstall works without any errors.

However, I still get an error message when I click on the icon of the addon in Firefox:

error caught while executing async callback:
NvimError(b'Vim(echo):E121: Undefined variable: edit',)
Traceback (most recent call last):
  File "/home/xxx/.config/nvim/plugged/vim-ghost/rplugin/python3/ghost.py", line 182, in _handle_on_message
    self.nvim.command("ed %s" % temp_file_name)
  File "/usr/lib/python3.6/site-packages/neovim/api/nvim.py", line 242, in command
    return self.request('nvim_command', string, **kwargs)
  File "/usr/lib/python3.6/site-packages/neovim/api/nvim.py", line 140, in request
    res = self._session.request(name, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/neovim/msgpack_rpc/session.py", line 98, in request
    raise self.error_wrapper(err)
neovim.api.nvim.NvimError: b'Vim(edit):E37: No write since last change (add ! to override)'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/xxx/.config/nvim/plugged/vim-ghost/rplugin/python3/ghost.py", line 198, in _handle_on_message
    self.nvim.command("echo '%s'" % ex)
  File "/usr/lib/python3.6/site-packages/neovim/api/nvim.py", line 242, in command
    return self.request('nvim_command', string, **kwargs)
  File "/usr/lib/python3.6/site-packages/neovim/api/nvim.py", line 140, in request
    res = self._session.request(name, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/neovim/msgpack_rpc/session.py", line 98, in request
    raise self.error_wrapper(err)
neovim.api.nvim.NvimError: b'Vim(echo):E121: Undefined variable: edit'

the call was requested at
  File "/home/xxx/.local/lib/python3.6/site-packages/SimpleWebSocketServer/SimpleWebSocketServer.py", line 566,
in _parseMessage
    self._handlePacket()
  File "/home/xxx/.local/lib/python3.6/site-packages/SimpleWebSocketServer/SimpleWebSocketServer.py", line 238,
in _handlePacket
    self.handleMessage()
  File "/home/xxx/.config/nvim/plugged/vim-ghost/rplugin/python3/ghost.py", line 36, in handleMessage
    self.server.context.on_message(req, self)
  File "/home/xxx/.config/nvim/plugged/vim-ghost/rplugin/python3/ghost.py", line 214, in on_message
    self.nvim.async_call(self._handle_on_message, req, websocket)
raghur commented 6 years ago

install had rwxr-xr-x while install.cmd had rw-r--r--. I changed both to 775, so now :GhostInstall works without any errors.

What OS are you on? In either case, you shouldn't need to change perms manually - already verified that executable is set for ./install. install.cmd is only for windows.

What does the following return in nvim:

:set hidden?

mcepl commented 6 years ago

hidden for me.

raghur commented 6 years ago

@maxigaz - I could repro your error only if I set nohidden... @mcepl - I'm assuming that you're not seeing the same stacktrace as @maxigaz ?

mcepl commented 6 years ago

No, I don't. With fixes shown above, everything works for me.

maxigaz commented 6 years ago

@raghur I'm still using Manjaro Linux, but you were right about :set hidden?. The return value was nohidden, and setting it to hidden did the trick.

Thank you for your help and this great plugin!