Image credit astrovim & github.
When I opened a Dockerfile in neovim, I noticed that the syntax highlighting was not working. Unsure of which plugin manager to select from the numerous available options? I came across AstroVim, which is a set of configuration files to unlock the full capabilities of nvim. However, it required nvim v0.6+, which I did not have on Impish. I don’t want to use the nvim appimage/snap/flatpak options, so I’ll build it from source. Also, I don’t want to install a bunch of junk on my system, so I’ll build the binary in Docker.
Local version info
Version Command | Output |
---|---|
lsb_release —all | No LSB modules are available. |
Distributor ID: Ubuntu | |
Description: Ubuntu 21.10 | |
Release: 21.10 | |
Codename: impish | |
git —version | git version 2.32.0 |
docker —version | Docker version 20.10.12, build e91ed57 |
Spin up a docker container
docker run --name=tmp-nvim-build-env -it ubuntu:21.10
Setup build env
# skipping sudo as this is in a disposable docker container
apt-get update
# Install prerequisites
DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends ninja-build gettext libtool libtool-bin autoconf automake cmake g++ pkg-config unzip curl doxygen make \
git ca-certificates
Clone latest stable nvim branch
git clone --single-branch --branch stable https://github.com/neovim/neovim ~/neovim-git \
&& cd ~/neovim-git
Build the binary
As per the docs, the uninstall script is missing(wonder why?). So, I will keep the installation files contained in a folder.
make CMAKE_BUILD_TYPE=Release CMAKE_EXTRA_FLAGS="-DCMAKE_INSTALL_PREFIX=$HOME/neovim"
make install
Setup locally
Copy files over from docker container
docker cp tmp-nvim-build-env:/root/neovim "$HOME/neovim"
Add binary to path
# temporary
export PATH="$HOME/neovim/bin:$PATH"
# permanent
echo '\n# Neovim addition to PATH\nexport PATH="$HOME/neovim/bin:$PATH"' >> ~/.zshrc && tail -n3 ~/.zshrc
nvim --version
Version Command | Output |
---|---|
nvim —version | NVIM v0.6.1 |
Build type: Release | |
LuaJIT 2.1.0-beta3 | |
Compiled by root@7626c7f7a546 | |
Features: +acl +iconv +tui | |
See “:help feature-compile” | |
system vimrc file: “$VIM/sysinit.vim” | |
fall-back for $VIM: “/root/neovim/share/nvim” | |
Run :checkhealth for more info |
Wonder how to fix the fall-back path above or what it does?
Install pynvim (optional)
Install support for python plugins.
pip install pynvim
Finally, install astrovim
# just copy over git files to `~/.config/nvim/`
git clone --depth 1 https://github.com/kabinspace/AstroVim ~/.config/nvim
# install/update plugins
nvim +PackerSync
In nvim,
:checkhealth
(important != true) {
Uh, unexpected,CTRL+SHFT+C
ory
yank stopped working in nvim. Had xclip, but had to install wl-clipboardsudo apt install wl-clipboard
. Now at leasty
works.
}
Output from :checkhealth
states that most things look fine.
nvim: health#nvim#check
========================================================================
## Configuration
- OK: no issues found
## Performance
- OK: Build type: Release
## Remote Plugins
- OK: Up to date
## terminal
- INFO: key_backspace (kbs) terminfo entry: key_backspace=\177
- INFO: key_dc (kdch1) terminfo entry: key_dc=\E[3~
- INFO: $COLORTERM='truecolor'
provider: health#provider#check
========================================================================
## Clipboard (optional)
- OK: Clipboard tool found: wl-copy
## Python 2 provider (optional)
- WARNING: No Python executable found that can `import neovim`. Using the first available executable for diagnostics.
- ERROR: Python provider error:
- ADVICE:
- provider/pythonx: Could not load Python 2:
python2 not found in search path or not executable.
python2.7 not found in search path or not executable.
python2.6 not found in search path or not executable.
/usr/bin/python is Python 3.9 and cannot provide Python 2.
- INFO: Executable: Not found
## Python 3 provider (optional)
- INFO: `g:python3_host_prog` is not set. Searching for python3 in the environment.
- INFO: Multiple python3 executables found. Set `g:python3_host_prog` to avoid surprises.
- INFO: Executable: /usr/bin/python3
- INFO: Other python executable: /bin/python3
- INFO: Python version: 3.9.7
- INFO: pynvim version: 0.4.3
- OK: Latest pynvim is installed.
## Python virtualenv
- OK: no $VIRTUAL_ENV
Opened a Dockerfile
and syntax highlighting works. Was all of the above worth it? Doubt it. Was it fun? Yeah! Although, should have tried the PPA first.
Further,
- Integration with system missing isin’t great. Check how the PPA package behaves. Make a deb package if it doesn’t pan out.
Clean up (optional)
Delete container
docker container rm tmp-nvim-build-env
Remove nvim files
rm -rf $HOME/neovim
rm -rf ~/.config/nvim
Remove last 3 lines from ~/.zshrc
tail -n3 ~/.zshrc
sed -i "$(( $(wc -l < ~/.zshrc)-3+1 )),$ d" ~/.zshrc
References.
Neovim
- GitHub - neovim/neovim: Vim-fork focused on extensibility and usability
- Building Neovim · neovim/neovim Wiki · GitHub
- Installing Neovim · neovim/neovim Wiki · GitHub