Sublime Forum

ActualVim - perfect Vim input for Sublime Text 3

#1

This time it’s not just a proof of concept.

ActualVim uses a single Neovim process to transparently handle your Sublime Text keyboard input.

Bidirectional selection and text sync means you can still use Sublime Text features and plugins, including OS-features like dragging or pasting text into a window.

Just about everything should work besides multiple selection (because I need to figure out how I want to map that into vim). There’s a freezing bug that should be mostly worked around. I’m waiting for Neovim upstream on that.

  1. Install Neovim.
  2. clone actualvim into your package directory (or install via Package Control)
  3. Set the Neovim path in actualvim plugin settings (if you’re on Windows or you installed it somewhere weird. Paths like /usr/local/bin/nvim will just work.).
  4. Restart Sublime. All of your Sublime Text views now support real vim input. (Or check the Sublime console to see why it broke ;))

You can toggle the plugin in realtime without losing vim state via “ActualVim: Disable/Enable” in the command palette.

Looking forward to your feedback :slightly_smiling:

6 Likes

#2

Glad to see someone working on something with NeoVim. As a lot of folk are following the progress on NeoVim I wonder if more people would find and install this if it was called ‘NeoVim-sublime’ or similar — just a thought!
Look forward to giving it a whirl once its on package control. Thanks :slight_smile:

1 Like

#3

Note that using “sublime” in a package for Sublime Text is against our Package Control naming guidelines (because, honestly, all ST packages are for “Sublime Text”).

1 Like

#4

Just waiting on the pull request to get accepted for package control, then I’ll add it to the install instructions.

I have a few problems with calling it “Neovim” as it’s not just a Vim remote UI (which most Vim integrations into any editor have been). The project predates Neovim (I had a working vanilla Vim bridge too), and native Sublime Text editor features still work great! It’s going to be a lot of work and probably some upstream Neovim changes before the more complex Vim UI surfaces here (and maybe some Sublime Text improvements to Phantom too).

Also, yeah, ninja’d by FichteFoll about the “Sublime” half :slight_smile:

0 Likes

#5

Fair enough. :slight_smile: look forward to giving ActualVim a try. Thanks.

0 Likes

#6

Sorry, but I honestly don’t understand about what this plugin is. What’s the difference between ActualVim and Vim/NeoVim? What about vintageous?

It would be cool if there was some pictures/videos.

0 Likes

#7

It’s in the title.

What’s the difference between ActualVim and Vim/NeoVim?

Vim/Neovim aren’t sublime text plugins. And thus can’t use features/ui/plugins of sublime text.

What about vintageous?

This works exactly like vintageous. Except unlike vintageous, every vim motion/command should work. Because ActualVim is powered by a copy of neovim running in the background.

There’s a really old cursor-flickery video from when this was powered by normal vim: https://www.youtube.com/watch?v=18OL76R5sNY - I haven’t had a chance to record a new one yet.

0 Likes

#8

Mh, can’t get it to work…

Windows Server 2016 x64 German
Sublime Text 3 Build 3126 (32-bit)

I downloaded Neovim (32-bit) from https://ci.appveyor.com/api/projects/neovim/neovim/artifacts/build/Neovim.zip?branch=master&job=Configuration%3A%20MINGW_32

and extracted it into “D:\Tools”
So nvim.exe is now in “D:\Tools\Neovim\bin”

Download actualvim (“Download as zip”), renamed it from “actualvim-master.zip” into “actualvim.zip” and
extracted it into “D:\Tools\Sublime Text\Data\Packages”. Ofc it now resides in “…\Packages\actualvim”

Restarted Sublime Text. By default it doesn’t seem to create a .sublime-settings file so I created it myself:
“D:\Tools\Sublime Text\Data\Packages\User\ActualVim.sublime-settings”

Content:

    "enabled": true,
    "neovim_path": "D:\\Tools\\Neovim"
}

When I now restart Sublime Text I get this in the console:

(a lot of other reloading plugin messages with no errors)

reloading plugin TimeStamper.TimeStamper
plugins loaded
Traceback (most recent call last):
  File "./python3.3/subprocess.py", line 1104, in _execute_child
PermissionError: [WinError 5] Zugriff verweigert

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\Tools\Sublime Text\sublime_plugin.py", line 210, in on_api_ready
    m.plugin_loaded()
  File "D:\Tools\Sublime Text\Data\Packages\actualvim\neo.py", line 45, in plugin_loaded
    vim._setup()
  File "D:\Tools\Sublime Text\Data\Packages\actualvim\neo.py", line 146, in _setup
    self.nv = neovim.attach('child', argv=[NEOVIM_PATH, '--embed'])
  File "D:\Tools\Sublime Text\Data\Packages\actualvim\lib\neovim\__init__.py", line 103, in attach
    child_session(argv) if session_type == 'child' else
  File "D:\Tools\Sublime Text\Data\Packages\actualvim\lib\neovim\msgpack_rpc\__init__.py", line 42, in child_session
    return session('child', argv)
  File "D:\Tools\Sublime Text\Data\Packages\actualvim\lib\neovim\msgpack_rpc\__init__.py", line 18, in session
    loop = EventLoop(transport_type, *args, **kwargs)
  File "D:\Tools\Sublime Text\Data\Packages\actualvim\lib\neovim\msgpack_rpc\event_loop\base.py", line 88, in __init__
    getattr(self, '_connect_{}'.format(transport_type))(*args)
  File "D:\Tools\Sublime Text\Data\Packages\actualvim\lib\neovim\msgpack_rpc\event_loop\asyncio.py", line 101, in _connect_child
    self._loop.run_until_complete(coroutine)
  File "D:\Tools\Sublime Text\Data\Packages\actualvim\lib\asyncio\base_events.py", line 466, in run_until_complete
    return future.result()
  File "D:\Tools\Sublime Text\Data\Packages\actualvim\lib\asyncio\futures.py", line 293, in result
    raise self._exception
  File "D:\Tools\Sublime Text\Data\Packages\actualvim\lib\asyncio\tasks.py", line 239, in _step
    result = coro.send(None)
  File "D:\Tools\Sublime Text\Data\Packages\actualvim\lib\asyncio\base_events.py", line 1189, in subprocess_exec
    bufsize, **kwargs)
  File "D:\Tools\Sublime Text\Data\Packages\actualvim\lib\asyncio\windows_events.py", line 373, in _make_subprocess_transport
    **kwargs)
  File "D:\Tools\Sublime Text\Data\Packages\actualvim\lib\asyncio\base_subprocess.py", line 39, in __init__
    stderr=stderr, bufsize=bufsize, **kwargs)
  File "D:\Tools\Sublime Text\Data\Packages\actualvim\lib\asyncio\windows_events.py", line 757, in _start
    bufsize=bufsize, **kwargs)
  File "D:\Tools\Sublime Text\Data\Packages\actualvim\lib\asyncio\windows_utils.py", line 204, in __init__
    stderr=stderr_wfd, **kwds)
  File "./python3.3/subprocess.py", line 819, in __init__
  File "./python3.3/subprocess.py", line 1110, in _execute_child
PermissionError: [WinError 5] Zugriff verweigert
Traceback (most recent call last):
  File "D:\Tools\Sublime Text\sublime_plugin.py", line 228, in on_api_ready
    attach_view(v)
  File "D:\Tools\Sublime Text\sublime_plugin.py", line 276, in attach_view
    check_view_event_listeners(view)
  File "D:\Tools\Sublime Text\sublime_plugin.py", line 270, in check_view_event_listeners
    listeners.append(cls(view))
TypeError: object() takes no parameters
warning: mnemonic I not found in menu caption Find
warning: mnemonic I not found in menu caption Find
Package Control: Skipping automatic upgrade, last run at 2017-02-27 14:23:05, next run at 2017-02-27 15:23:05 or after

I don’t know why there is a permission error (if this is related to actualvim loading nvim.exe?)

“Vintage” is in “ignored_packages”
as well as “Vintageous” (which I normally use)

Sublime Text runs with normal user rights.

0 Likes

#9

Sorry about that, the path needed to be to nvim.exe not just the neovim folder (I assume permission was denied on trying to execute a folder). I just added a check for this in latest master, so it will guess PATH/nvim.exe and PATH/bin/nvim.exe on windows.

As far as plugin settings, I said this in the main readme but not here - there’s a menu item and command palette option for opening the ActualVim user settings, and it will fill in the defaults if the settings didn’t exist yet.

1 Like

#10

No problem. Updated actualvim and pointed neovim_path directly to nvim.exe => It works, no error
messages any more

0 Likes

#11

Also note Windows ActualVim has an input performance problem I haven’t tracked down yet: https://github.com/lunixbochs/actualvim/issues/32#issuecomment-282717630

0 Likes

#12

Noticed that already.

Typing is rather jumpy / slow

0 Likes

#13

I improved the heuristics, and it should be a little better in latest master.

0 Likes

#14

It’s a lot better with the latest changes. Thanks for adding them!

0 Likes

#15

Hello @lunixbochs,

thanks a lot for the wonderful plugin!

Recently I decided to finally abandon Emacs and returned back to (n)vim, but your plugin makes me enthusiastic to-revive usage of my ST3 licenses and get best of both worlds. :smile:

I bet that (n)vim might have better plugins/completions, etc. for some stuff - eg. vim-go for Go language, while ST3 is strong(er) in some other fields like web technology (HTML, CSS, SASS etc.).

Caveats sections lists some currently problematic area, but I wonder, in general, is it possible/feasible to e.g. use both (n)vim/ST3 completion plugins at the same time without enabling/disabling ActualVim globally and/or locally?

0 Likes

#16

This is already implemented. I expose the Sublime completions to vim as a completefunc, so you can hit ^X^U to get Sublime completions while Vim is enabled. I’m also going to hopefully remove the insert-mode input interception so Sublime can still show automatic completion/snippet popups, at which point I’ll query Vim for completion data too to make this work both ways.

The caveat is just that sublime won’t auto-suggest completions as you type, not that they don’t work.

Multiple selection should work extremely well when it’s done, but will take a bit of work to get going (I basically need to track selection 100% on Sublime side, and dispatch a different key to vim per selection, kinda… or wait for official neovim support for it).

The “undo” thing isn’t a huge issue right now (you should mostly just use vim undo), and the insert hack idea that will fix suggestion popups should fix undo too.

0 Likes

#17

OK, I’ve to test it further…

That will be cool as well. :+1:

What about ST3’s status bar to show me when I issuing normal mode’s stuff, e.g. to enter current date via
:!r date

?

One of the thing which I regularly use in vim and won’t give it up so easily is reformat-paragraph feature:
visual-mode j (for selection) gq
so, why e.g. the above snippet cannot produce result immediately, but I’ve to ‘leave’ (n)vim-mode by e.g. pressing Esc or something, iow. is it just a feature required to make the whole bridge working?

0 Likes

#18

I’ve asked for the ability to anchor a phantom to the bottom of a view in Sublime. I don’t have any good ways to display that information yet (but :command line and search should show up in status bar right now)

so, why e.g. the above snippet cannot produce result immediately, but I’ve to ‘leave’ (n)vim-mode by e.g. pressing Esc or something, iow. is it just a feature required to make the whole bridge working?

This should be fixed in Neovim 0.2, which was recently released.

0 Likes

#19

Hmm…trying with
:r !date
example, I do not see anything?

[quote]This should be fixed in Neovim 0.2, which was recently released.
[/quote]

Great…I’m waiting to be released for my Fedora (f25) distro…

0 Likes

#20

I can’t really guarantee anything before neovim 0.2, but I definitely see the status/search/command line on mine.

0 Likes