Neovim
Neovim is my editor of choice for rapid-race development.
Dependencies
Install the following dependencies from cargo
cargo install ripgrep websocat fd-find
Install
WARNING
zig
is strongly strongly recommended for Windows for compiling treesitter, as it is a C-compatible compiler. Otherwise you need to figure out how to make MSVC available through the command line, which is not convenient.
Arch Linux:
nvim
should be bootstrapped during the full install. If not, you can install withbashsudo pacman -Syu neovim
- Setup aliasesbash
echo "alias=vi,vim:which:nvim" >> ~/dotbin/extra/portable/link dotbin-link
Windows:
- Download the latest stable release from https://github.com/neovim/neovim/releases. Save
nvim-win64.zip
to theDownloads
directory - Extract itpowershell
7z x -y ~/Downloads/nvim-win64.zip "-o$HOME/dotbin/extra/portable"
- Configure linkpowershell
Add-Content -Path ~/dotbin/extra/portable/link -Value "alias=vi,vim:shim:nvim-win64/bin/nvim.exe`nshim:nvim-win64/bin/win32yank.exe`nshim:nvim-win64/bin/xxd.exe" sudo dotbin-link
- Exclude
nvim
from Windows Defender.powershellAdd-MpPreference -ExclusionPath ~/dotbin Add-MpPreference -ExclusionProcess nvim
WARNING
Run as admin!
WARNING
Verify installation with
nvim --version
Packer
Package manager for Neovim
- Windows:powershell
rm -rf $env:LOCALAPPDATA\nvim-data mkdir -p "$env:LOCALAPPDATA\nvim-data\site\pack\packer\start" git clone https://github.com/wbthomason/packer.nvim "$env:LOCALAPPDATA\nvim-data\site\pack\packer\start\packer.nvim"
- Arch Linux:bash
yay -Syu nvim-packer-git
Config
INFO
I made my configs from 2 tutorials:
(And of course copying from the examples provided by the plugins)
WARNING
Make sure to setup dotbin
for getting the config
python ~/dotbin/script/configure-nvim.py
INFO
To copy the config in the other direction (i.e. from the local machine to dotbin/dotconfig
)
python ~/dotbin/script/configure-nvim.py update
Install the plugins
Start neovim
nvim
You will see some errors because the plugins are not installed. It's OK. Press Shift+G
to go to the bottom and Enter
to continue. Then, run the following command to install them
:PackerSync
Restart neovim and you should be good.
GitHub Copilot
If you have GitHub Copilot, run the following to set it up
:Copilot setup
Then follow on-screen instructions.
You can use :Copilot status
to check at anytime if it is enabled
Integration Config
There are certain integration options that can be configured in nvim/lua/integrations.lua
. (The nvim
directory is in ~/.config
on Linux and %LOCALAPPDATA%
on Windows). These options enable small differences in machines and won't be overwritten when pulling new config changes.
Yank to host clipboard
dotbin
has a utility wsclip
that starts a websocket server that copies inbound messages into clipboard. This is useful for copying text from headless VM to the host. All you need is setup
export HOST_MACHINE_IP=192.168.xxx.xxx
You can see the autocommand in lua/keys.lua
that uses websocat
to send it over to the host. On windows, it uses powershell's Set-Clipboard
command so you don't need to do extra setup.
Currently, it doesn't support copying directly from Linux to system clipboard. This should change when I get a real Linux machine.
Update
To update the config, run
python ~/dotbin/script/configure-nvim.py
To update the plugins/packages/tools, run
:PackerSync
After that, also update treesitter and Mason tools
:TSUpdate
:MasonUpdate
Key mappings
- See here for the raw key mappings
Language-specific LSP Setups
Works out-of-box with Mason
The following should work mostly out-of-box when installing through Mason:
rust-analyzer
typescript-language-server
eslint-lsp
C/C++ (clangd
)
- Install it through Mason
- Your build system must produce a
compile-commands.json
- Create
.clangd
in the root of the projects with the following, changing the path accordinglyyamlCompileFlags: CompilationDatabase: ./path/to/directory/with/compile-commands.json
- If additional configuration is needed, follow https://clangd.llvm.org/config.html#compileflags
Java (jdtls
)
DANGER
This configuration is experimental and unstable
- DO NOT install it through Mason. Instead, download from https://download.eclipse.org/jdtls/milestones
- Extract JDTLS from the download from step 1. Put it in some permanent location, then set the
ECLIPSE_JDTLS_HOME
variable to that folder.
TIP
I have a folder, say E:\Eclipse
(on windows), that I put jdtls
as well as all my jdks.
- You also need a decently new version of JDK. Install the latest from https://jdk.java.net/ or from package manager. At the time of writing, the latest is JDK 21
- Set
ECLIPSE_JDK_HOME
to the JDK you will be using for JDTLS
TIP
Both ECLIPSE_JDTLS_HOME
and ECLIPSE_JDK_HOME
are referenced in the nvim config, so the config can be cross-plat.
- For every runtime you want to use, set the
JDK<version>_HOME
to the path of the JDK. For exampleJDK8_HOME
forJavaSE-1.8
andJDK21_HOME
forJavaSE-21
. JDTLS will detect the runtime to use from.classpath
, then use this env to find the Java installation.