Neovim: A Modern Vim Text Editor Clone

    Vim is a powerful text editor with a large audience. Although the program is over 20 years old, its functionality continues to be improved through vimscript scripts. The latest version of the free Vim 7.4 editor was released in August 2013.

    The problem is that over two decades Vim has grown to a terrible size: about 300,000 lines of C89 code. “Very few people can understand this code or have the courage to change it. There is a problem with adding new code and patches to Vim: the only maintainer does not keep pace with the development of the plug-in ecosystem, ”writes Brazilian programmer Thiago de Arruda Padilha, who created the Neovim project - an updated and improved version of Vim for the 21st century .

    The Neovim project plans to aggressively refactor Vim source code. Objectives:

    1. Simplify support and increase the speed of adding patches and new features;
    2. Distribute work among several developers;
    3. Implement a modern GUI as an option;
    4. Improve the extensibility of the editor due to the new plug-in architecture based on coprocesses. Plugins can be written in any language without their explicit support from the editor.

    The developer notes that his goal is not to rewrite Vim from scratch and create an IDE, although Neovim has some features of the IDE. On the contrary, changes should not greatly change the model of Vim or vimscript as a whole. Most vimscript plugins will continue to work normally.

    Speaking of specific changes, it is planned to switch to a modern build automation system based on cmake , remove the Vi emulation mode and some other not very important options that make code support difficult, and also remove platform-specific code. Instead, there will be a dynamically linked libuv library that will perform asynchronous I / O on different platforms.

    It is proposed to build a new plug-in system on top of a job management mechanism similar to this one.. Plugins can be written in any language, the editor will check for the presence of the plug-in at startup, and each plug-in will work asynchronously, waiting for events and sending commands to Neovim. For example, this might look like a plugin session using json-rpc.

    plugin -> neovim: {"id": 1, "method": "listenEvent", "params": {"eventName": "keyPressed"}}
    neovim -> plugin: {"id": 1, "result": true}
    neovim -> plugin: {"method": "event", "params": {"name": "keyPressed", "eventArgs": {"keys": ["C"]}}}
    neovim -> plugin: {"method": "event", "params": {"name": "keyPressed", "eventArgs": {"keys": ["Ctrl", "Space"]}}}
    plugin -> neovim: {"id": 2, "method": "showPopup", "params": {"size": {"width": 10, "height": 2} "position": {"column": 2, "line": 3}, "items": ["Completion1", "Completion2"]}}
    plugin -> neovim: {"id": 2, "result": true}}

    Such a scheme gives Neovim almost unlimited extensibility and at the same time improves the stability of the program, since the plugins are separated from the main source code.

    GUI elements and all related widgets will be removed from the main code. The GUI will connect in much the same way as plugins. The only difference is that plugins are loaded into Neovim, and Neovim itself is launched from the GUI.

    Программа GUI
      |
      ---> Neovim
             |
             ---> Плагин 1
             |
             ---> Плагин 2
             |
             ---> Плагин 3

    Hypothetical GUI session.

    gui -> vim: {"id": 1, "method": "initClient", "params": {"size": {"rows": 20, "columns": 25}}}
    vim -> gui: {"id": 1, "result": {"clientId": 1}}
    vim -> gui: {"method": "redraw", "params": {"clientId": 1, "lines": {"5": "   Welcome to neovim!   "}}}
    gui -> vim: {"id": 2, "method": "keyPress", "params": {"keys": ["H", "e", "l", "l", "o"]}}
    vim -> gui: {"method": "redraw", "params": {"clientId": 1, "lines": {"1": "Hello                   ", "5": "                        "}}}

    Thus, modern GUIs written in high-level programming languages ​​and better integrated into the operating system can be embedded in the editor. Plugins will be able to interact directly with the GUI, like minimap in Sublime. The editor core can be run on the server, and many GUI instances can be run on client machines. The editor can be embedded in other programs, just as it is actually built into the GUI.

    All development of Neovim is planned to be conducted on Github . Donations accepted .

    Also popular now: