Neovim: Difference between revisions

From miki
Jump to navigation Jump to search
Line 80: Line 80:
* Color theme ''solarized''.
* Color theme ''solarized''.


=== NeoVim GUI ===
== NeoVim GUI ==
There is no equivalent to <code>gvim</code> for neovim so far. On [https://github.com/neovim/neovim/wiki/Related-projects#plugins Neovim related projects] page, several GUI are listed. Among others:
For now, there are no official GUI for Neovim (like <code>gvim</code>). Potential candidates are (see also [https://github.com/neovim/neovim/wiki/Related-projects#plugins Neovim related projects]):
* nvim-qt
* [https://github.com/equalsraf/neovim-qt neovim-qt]
* [https://github.com/equalsraf/neovim-qt neovim-qt]
* [https://github.com/rhysd/NyaoVim NyaoVim] (an advanced Electron UI based client)
* [https://github.com/rhysd/NyaoVim NyaoVim] (an advanced Electron UI based client)
* [https://github.com/extr0py/oni ONI] (another Electron UI based client)
* [https://github.com/extr0py/oni ONI] (another Electron UI based client)
* Use a customized terminal (like Gnome-Terminal)


Criteria for a good GUI:
Criteria for a good GUI:
* Be '''fast''' (fast refresh, no jitter in scrolling).
* Be fast.
* Drop-in replacement for gvim / vim.
* '''Drop-in compatible''' with gvim / vim.
* True color and italic support.
* '''True color''' and '''italic''' support.
* Blinking and customizable (block/caret) cursor.
* '''Blinking''' cursor (mandatory) and '''block/caret''' mode (optional).
:Blinking cursor is necessary when using <code>incsearch</code> plugin (or we miss some hightlights).


;NyaoVim / ONI
=== NyaoVim / ONI ===
For now I discard these clients. These clients introduce additional features that I don't necessarily want.
For now I discard these clients. These clients introduce additional features that I don't necessarily want.


=== neovim-qt ===
;nvim-qt
Build from source. Bindings seem old, so we rebuild them:
TBC.
<source lang=bash>
mkdir build
cd build
cmake ..
make bindings
cmake --build .
</source>


;Issues
;Custom Gnome Terminal
* Cursor '''not blinking'''! Using QT API <code>app.setCursorFlashTime(1000);</code> does not help.
* Message <tt>Unknown Neovim function "Array vim_get_api_info()"</tt>. Due to missing/additional bindings. If necessary, we can mute this message in {{file|src/function.cpp}}.

=== Custom terminal - Gnome-Terminal ===
The best I could do so far is to create a script <code>gnvim</code> that uses gnome-terminal as window, sets title to ''NeoVim'', and sets icon using [https://github.com/xeyownt/xseticon xseticon].
The best I could do so far is to create a script <code>gnvim</code> that uses gnome-terminal as window, sets title to ''NeoVim'', and sets icon using [https://github.com/xeyownt/xseticon xseticon].


Line 106: Line 118:


* Copy neovim icon to {{file|/usr/local/icons/neovim.png}}. For instance, there is an icon in [https://github.com/equalsraf/neovim-qt.git neovim-qt.git]:
* Copy neovim icon to {{file|/usr/local/icons/neovim.png}}. For instance, there is an icon in [https://github.com/equalsraf/neovim-qt.git neovim-qt.git]:
<source lang=bash>
git clone https://github.com/equalsraf/neovim-qt.git
git clone https://github.com/equalsraf/neovim-qt.git
sudo mkdir -p /usr/local/icons
sudo cp neovim-qt/third-party/neovim.png /usr/local/icons
sudo mkdir -p /usr/local/icons
sudo cp neovim-qt/third-party/neovim.png /usr/local/icons
</source>


* Create file {{file|gnvim}}, and make it executable:
* Create file {{file|gnvim}}, and make it executable:

Revision as of 09:12, 13 January 2017

References

Install

See the guide Installing Neovim.

On Ubuntu, we install from repository:

sudo add-apt-repository ppa:neovim-ppa/unstable
sudo apt-get update
sudo apt-get install neovim

Default ini files are located at ~/.config/nvim/init.vim. To import Vim settings (FAQ :help nvim-from-vim)

mkdir ~/.config
ln -s ~/.vim ~/.config/nvim
ln -s ~/.vimrc ~/.config/nvim/init.vim

Configure nvim as default vim alternative:

sudo update-alternatives --install /usr/bin/vi vi /usr/bin/nvim 60
sudo update-alternatives --config vi
sudo update-alternatives --install /usr/bin/vim vim /usr/bin/nvim 60
sudo update-alternatives --config vim
sudo update-alternatives --install /usr/bin/editor editor /usr/bin/nvim 60
sudo update-alternatives --config editor


Ruby support

Must install neovim rubygem:

sudo apt install ruby-dev
sudo gem install neovim

Python support

sudo pip install neovim

Plugin manager

We install vim-plug:

curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs \
    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

Plugins

Content of ~/.config/nvim/init.vim:

Reload the init script and install plugins:

:so $MYVIMRC
"... or ':so %' if it is current file
:PlugInstall

To update plugins:

:PlugUpdate
To test
  • vim-airline, vs powerline, vs vim-bufferline
  • Color theme solarized.

NeoVim GUI

For now, there are no official GUI for Neovim (like gvim). Potential candidates are (see also Neovim related projects):

  • neovim-qt
  • NyaoVim (an advanced Electron UI based client)
  • ONI (another Electron UI based client)
  • Use a customized terminal (like Gnome-Terminal)

Criteria for a good GUI:

  • Be fast (fast refresh, no jitter in scrolling).
  • Drop-in compatible with gvim / vim.
  • True color and italic support.
  • Blinking cursor (mandatory) and block/caret mode (optional).
Blinking cursor is necessary when using incsearch plugin (or we miss some hightlights).

NyaoVim / ONI

For now I discard these clients. These clients introduce additional features that I don't necessarily want.

neovim-qt

Build from source. Bindings seem old, so we rebuild them:

mkdir build
cd build
cmake ..
make bindings
cmake --build .
Issues
  • Cursor not blinking! Using QT API app.setCursorFlashTime(1000); does not help.
  • Message Unknown Neovim function "Array vim_get_api_info()". Due to missing/additional bindings. If necessary, we can mute this message in src/function.cpp.

Custom terminal - Gnome-Terminal

The best I could do so far is to create a script gnvim that uses gnome-terminal as window, sets title to NeoVim, and sets icon using xseticon.

To install gnvim:

  • Copy neovim icon to /usr/local/icons/neovim.png. For instance, there is an icon in neovim-qt.git:
git clone https://github.com/equalsraf/neovim-qt.git
sudo mkdir -p /usr/local/icons
sudo cp neovim-qt/third-party/neovim.png /usr/local/icons
  • Create file gnvim, and make it executable:
#! /bin/bash
# We add a sleep 1 because of race condition between xseticon and echo
gnome-terminal --geometry 132x50 --hide-menubar -x bash -c "echo -ne '\033]0;NeoVim\007'; ((sleep 1; xseticon -name NeoVim /usr/local/icons/neovim.png)&); exec nvim $*"
  • To add NeoVim GUI as a desktop application, create the file ~/.local/share/applications/neovim.desktop:
#!/usr/bin/env xdg-open

[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Exec=/home/peetersm/bin/ngvim
Name=NeoVim
Comment=The future of Vim
Icon=/usr/local/icons/neovim.png

Then

chmod a+x ~/.local/share/applications/neovim.desktop

Tips

Use :term for Read–eval–print loop (REPL)

This can be easily done using a new buffer (C-w v) and a terminal (:term), and then

  • Use watch:
watch 'make this && less that'
  • Use entr:
echo myfile myotherfile | entr make this

Neovim features

Just a couple of things I should not forget exist.

  • Powerful terminal emulation.
  • Quick :term git status.
  • Use terminal for easy REPL.
  • More workflow examples on reddit and SO.
  • Incremental substitution (set inccommand=split) (see here).

Troubleshooting

True color and italic support

See xterm.

Meta/Alt-key mappings choke (when typed too fast)

See bug #2454.

The solution is too actually install the plugin vim-sensible, contrary to what says :CheckHealth.

This plugins set ttimeoutlen to 100, which is sufficient to have alt-key mappings to act correctly in TUI.

No blinking cursor in nvim-qt

Adding call to QApplication::setCursorFlashTime() in main.cpp does not help. See issue #208.

Cursor (sometimes) stops blinking

Neovim hard-codes cursor shape and mode. This is tracked in tickets #5740, #5556. See also [Cursor stops blinking #3257].

Undefined variable: self

See issue #5763.

Last known good version without this bug for me: neovim_0.1.5ubuntu1+git201612110104+2963+22~ubuntu16.04.1_amd64.deb.

Bug fixed, but must update all plugins (:PlugUpdate) and vim-plug itself (with :PlugUpgrade).

incsearch plugin broken

See issue #125.

To Do

True color
Gui
Color scheme
  • Solarized
  • gruvbox
Linters
  • neomake
  • syntactics