Skip to content

Neovim

I made my configs from 2 tutorials:

(And of course copying from the examples provided by the plugins)

packer.nvim

Install packer.nvim, which is the plugin manager.

bash
yay -Syu nvim-packer-git
yay -Syu nvim-packer-git

Get the configs

My configs are on GitHub

I made a script to curl them to the right places. If you want to use them, backup your existing configs

bash
mv ~/.config/nvim ~/.config/nvim.bak
mv ~/.config/nvim ~/.config/nvim.bak

Then download and run the script

bash
curl -o dl-nvim-config.py https://vmsetup.pistonite.org/dl-nvim-config.py
python dl-nvim-config.py
rm dl-nvim-config.py
curl -o dl-nvim-config.py https://vmsetup.pistonite.org/dl-nvim-config.py
python dl-nvim-config.py
rm dl-nvim-config.py

Install the plugins

Start neovim

bash
nvim
nvim

You will see some errors because the plugins are not installed. It's OK. Run the following command to install them

vim
:PackerSync
:PackerSync

Restart neovim and you should be good.

GitHub Copilot

If you have GitHub Copilot, run the following to set it up

vim
:Copilot setup
:Copilot setup

Then follow on-screen instructions.

You can use :Copilot status to check at anytime if it is enabled

Yank to host clipboard

Since the VM is headless, there's no clipboard provider to support the + register. So I made a simple python program ws-clipboard that starts a websocket server and stores whatever it receives into the clipboard.

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.

Update

To update the plugins/packages/tools, run

:PackerSync
:PackerSync

After that, also update treesitter and Mason tools

:TSUpdate
:MasonUpdate
:TSUpdate
:MasonUpdate

Key mappings

Here are some of my key mappings. I use the default leader key.

Normal operations

KeyActionPlugin
<leader>0Toggle relative line numbersN/A
<leader> Turn off search highlightN/A
<A-j>(Visual mode) move selected lines downN/A
<A-k>(Visual mode) move selected lines upN/A
<C-W>>Increase window width by 20N/A
<C-W><Decrease window width by 20N/A
<C-W>+Increase window height by 10N/A
<C-W>-Decrease window height by 10N/A
<leader>wSwitch left and right (rotate buffer positions)N/A
<leader>dhClone right panel to left panelN/A
<leader>dlClone left panel to right panelN/A
<leader>cComment out line/selectionN/A
<leader>uToggle undotreeundotree
<leader>yYank selection to host clipboardN/A
<leader>vgGrep in opened filestelescope
<leader>gsGit statustelescope

File switching

KeyActionPlugin
<leader>AAdd file to Harpoonharpoon
<leader>sToggle Harpoon menuharpoon
<leader>1Go to 1 in HarpoonN/A
<leader>2Go to 2 in HarpoonN/A
<leader>3Go to 3 in HarpoonN/A
<leader>ffFind file in workspacetelescope
<leader>ggFind git filestelescope
<leader>fgFind string in workspacetelescope
<leader>fdFind diagnostics in workspacetelescope
<leader>fbFind file in opened filestelescope

LSP

KeyActionPlugin
<leader>rRename symbollsp-zero/builtin
<leader>fFormatlsp-zero/builtin
'K'Hover actionbuiltin
grFind referencetelescope
gdFind definitiontelescope
gtFind type of symbol under cursorlsp-zero/builtin
giFind implementationtelescope
<leader>vdView diagnostics of current filetelescope
<leader>vsView symbols of current filetelescope
<leader>vwView symbols of workspacetelescope
<C-n>Trigger completionN/A
<C-e>Abort completionN/A
<A-j>Go down in completion menuN/A
<A-k>Go up in completion menuN/A

Terminal

KeyActionPlugin
<C-W>Go to normal mode if in terminal modeN/A
<leader><C-\>Open new terminalvim-floaterm
<C-\>Toggle floating terminalvim-floaterm
<C-n>Cycle through floating terminalsvim-floaterm

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)

  1. Install it through Mason
  2. Your build system must produce a compile-commands.json
  3. Create .clangd in the root of the projects with the following, changing the path accordingly
    yaml
    CompileFlags:
      CompilationDatabase: ./path/to/directory/with/compile-commands.json
    CompileFlags:
      CompilationDatabase: ./path/to/directory/with/compile-commands.json
  4. If additional configuration is needed, follow https://clangd.llvm.org/config.html#compileflags

Java (jdtls)

  1. DO NOT install it through Mason. Instead, download from https://download.eclipse.org/jdtls/milestones
  2. 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.

  1. 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
  2. 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.

  1. For every runtime you want to use, set the JDK<version>_HOME to the path of the JDK. For example JDK8_HOME for JavaSE-1.8 and JDK21_HOME for JavaSE-21. JDTLS will detect the runtime to use from .classpath, then use this env to find the Java installation.