Switch to Neovim

This commit is contained in:
this.ven 2024-08-23 10:06:00 +02:00
parent 7f1fb1e9b6
commit b3fe416987
2 changed files with 32 additions and 30 deletions

View file

@ -74,10 +74,10 @@ the `wheel` group is an option I use to implement:
```bash
pacman -Sy sudo
gpasswd -a thisven wheel
EDITOR=vim visudo
EDITOR=nvim visudo
```
In the ViM editor, I uncomment (removing the `#` and space character) in the
In the NeoVim editor, I uncomment (removing the `#` and space character) in the
following line in the file that has just been opened by the `visudo` command:
```
@ -257,39 +257,41 @@ alias lz='ll -rS' # sort by size
alias lt='ll -rt' # sort by date
```
As an alias such as `alias vi=vim` doesn't work reliably, I create the following
symlink to call `vim` via `vi`:
{{< callout type="info" >}}
I don't set `alias vi=nvim` to get used to invoking the original command.
{{< /callout >}}
```bash
sudo ln -s /usr/bin/vim /usr/bin/vi
### Neovim as default editor
To configure [Neovim](https://wiki.archlinux.org/title/Neovim) as the default
editor I insert the following variables into the `/etc/environment` file:
```{filename="/etc/environment"}
EDITOR=nvim
VISUAL=nvim
```
### Vim configuration
Applications that hardcode vi or vim as default editor can be forced to invoke
nvim by installing the package [neovim-symlinks](https://aur.archlinux.org/packages/neovim-symlinks) from the AUR:
For efficient working with `vim` in a graphical desktop environment, I like to
deactive [using the mouse](https://wiki.archlinux.org/title/Vim#Using_the_mouse)
in order to use the copy & paste function in terminal windows. I also set syntax
highlighting[^3], indentation and spell checking. I create a `~/.vimrc`
configuration file and insert the following settings:
```bash
yay neovim-symlinks
```
```vim {filename="$HOME/.vimrc"}
" Syntax highlighting, see: https://wiki.archlinux.org/title/Vim#Syntax_highlighting
Neovim has syntax highlighting[^3] enabled by default. Othe useful options are [spell](https://neovim.io/doc/user/spell.html) checking, and indentation. Most of these are similar to [Vim's configuration](https://wiki.archlinux.org/title/Vim#Configuration) and you can set them permanently by creating `~/.config/nvim/init.vim`. My configuration file contains:
```vim{filename="~/.config/nvim/init.vim"}
" Recognize file type while editing and enable syntax highlighting, see: https://neovim.io/doc/user/filetype.html#filetype
:filetype plugin on
:syntax on
" Indentation, see https://wiki.archlinux.org/title/Vim#Indentation
:filetype indent on
" Deactivate using the mouse, see: https://wiki.archlinux.org/title/Vim#Using_the_mouse
set mouse-=a
" Spell checking, see: https://wiki.archlinux.org/title/Vim#Spell_checking
set spell
" Deactivate using the mouse, see: https://neovim.io/doc/user/options.html#'mouse'
set mouse=
" Enable spell checking for US English, see: https://neovim.io/doc/user/spell.html
:setlocal spell spelllang=en_us
```
For spell checking you need to install a language package. For German I install
[vim-spell-de](https://archlinux.org/packages/?name=vim-spell-de) as follows:
```bash
sudo pacman -Sy vim-spell-de
```
{{< callout type="info" >}}
You may need to create the `nvim` directory inside `~/.config/` manually.
{{< /callout >}}
### Tab-completion and command-not-found

View file

@ -196,12 +196,12 @@ At this time I can check the layout of my storage device using `lsblk`.
Now I can install the essential packages into the previously mounted location:
```bash
pacstrap /mnt base linux linux-firmware lvm2 vim
pacstrap /mnt base linux linux-firmware lvm2 neovim
```
{{< callout type="info" >}}
The package [lvm2](https://archlinux.org/packages/?name=lvm2) is necessary for
mounting the LVs and [vim](https://archlinux.org/packages/?name=vim) is my
mounting the LVs and [neovim](https://archlinux.org/packages/?name=neovim) is my
favorite text editor. You may want to use another one found in the
[List of applications](https://wiki.archlinux.org/title/List_of_applications).
{{< /callout >}}
@ -218,7 +218,7 @@ genfstab -U /mnt >> /mnt/etc/fstab
for the filesystems instead of `discard`) for security reasons. See this
[section in the ArchWiki article on Dm-crypt Specialties](https://wiki.archlinux.org/title/Dm-crypt/Specialties#Discard/TRIM_support_for_solid_state_drives_(SSD)).
I use `vim /etc/fstab` to open and edit the file accordingly.
I use `nvim /etc/fstab` to open and edit the file accordingly.
{{< /callout >}}
I [change root](https://wiki.archlinux.org/title/Change_root) into the new