Published on

Setting up Neovim

Categorised under

Installation

Building from source

cd $HOME
git clone https://github.com/neovim/neovim.git
cd neovim
rm -r build/  # clear the CMake cache
make CMAKE_EXTRA_FLAGS="-DCMAKE_INSTALL_PREFIX=$HOME/neovim"
make install
export PATH="$HOME/neovim/bin:$PATH" # add to path
echo 'export PATH="$HOME/neovim/bin:$PATH"' >> $HOME/.bashrc # add to path

Using an appimage

cd $HOME
wget https://github.com/neovim/neovim/releases/download/nightly/nvim.appimage
chmod +x nvim.appimage
mv nvim.appimage $HOME/neovim/bin/nvim
mkdir -p $HOME/neovim/bin
export PATH="$HOME/neovim/bin:$PATH" # add to path
echo 'export PATH="$HOME/neovim/bin:$PATH"' >> $HOME/.bashrc # add to path

Installing packer

git clone https://github.com/wbthomason/packer.nvim ~/.local/share/nvim/site/pack/packer/start/packer.nvim

Alternatively, to automatically install packer if missing, insert the following lines

local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
if fn.empty(fn.glob(install_path)) > 0 then
    fn.system({'git', 'clone', 'https://github.com/wbthomason/packer.nvim', install_path})
    execute "packadd packer.nvim"
end

LSP setup

# npm install -g svelte-language-server
# npm install -g vscode-html-languageserver-bin
# npm install -g typescript typescript-language-server
# npm install -g vls
:LspInstall *name of lsp*

# Installation of dart lsp
sudo apt-get upgrade
sudo apt-get install dart

Configure the Lsp with the following variables defined. on_attach

require('lspconfig').vuels.setup {
    cmd = {DATA_PATH .. "/lspinstall/vue/node_modules/.bin/vls", "--stdio"},
    filetypes = { "vue" },
    on_attach = require'lsp'.on_attach,
    root_dir = require'lspconfig'.util.root_pattern("package.json",".git"),
}

Flutter / Dart

  • use
    akinsho/flutter-tools.nvim
    , specifying the dart lsp configuration within the flutter-tools setup.

DAP

Keymaps

  • A valuable plugin for easily remembering all keymaps is
    folke/which-key
    , which gives prompts about any of the key maps.
  • Check for conflicts with
    :checkhealth which_key
  • Configure specific keymaps by filetype or plugin by calling
    wk.register
    within the config.

Some of the mappings and plugins I use:

:TableModeToggle # toggle table mode for markdown
Command Action
<C-q>
Close split
<leader>c
Close buffer
<leader>w
Write
<F12>
Toggle nvim tree
<C-h/j/k/l>
Move to different split, creating if at end

Vim Surround

Command Action
cst"
Change surrounding HTML tag to ”