Getting started with Neovim - PDE p.I | xnacly - blogGetting started with Neovim - PDE p.I<br>Dec 27, 2022<br>1088 Words<br>6 Minute read
Tags:<br>Nvim<br>PDE
Info<br>This is the first part of the personalized development environment series<br>Second part: Part II<br>Third part: Part III
Prerequisites<br>The reader of this guide needs to know the basics of:<br>Vim motions and keys<br>opening and saving files in Vim<br>Learn here, here and here<br>Abstract<br>The pde series is intended to provide a simple guide for a new neovim user to learn about configuring the editor.<br>The series will cover:<br>neovim config with lua<br>config setup and dir structure<br>must have plugins and their configurations i uselanguage servers<br>fuzzy finders
theming with lualine, bufferline<br>This part covers:<br>neovim config with luaoptions<br>first plugins<br>plugin options<br>custom keybindings
config setup<br>config dir structure<br>More info:<br>Neovim documentation is located here<br>My configuration can be found here<br>Installing<br>To install read the neovim wiki.<br>Hint :<br>If you are on a linux system use your package manager to install neovim:<br>BASH<br>1sudo pacman -S neovim<br>2sudo apt install neovim<br>Hint 2:<br>For windows I’d recommend installing scoop in the powershell and using it to install neovim<br>POWERSHELL<br>1# allow executing remote scripts<br>2Set-ExecutionPolicy RemoteSigned -Scope CurrentUser<br>3# install scoop<br>4irm get.scoop.sh | iex<br>5# install neovim using scoop<br>6scoop install neovim<br>Config<br>Neovim can be configured using Vimscript1 or Lua2 -<br>I’d recommend the second option over the first, simply because Lua is a real programming language which also is:<br>minimal and powerful<br>widely used3<br>well documented4<br>fast 5<br>This guide will use Lua,<br>due to the fact that I noticed significant performance improvements using lua instead of vimscript.<br>Config guide<br>Config path<br>Config paths differ on windows compared to those on a unix system.<br>I use Windows sometimes, therefore I included the following windows guide additionally to the unix guide.<br>Configuration paths for Neovim, more info here:<br>Windows:
C:\Users\\AppData\Local\nvim
Unix:
$XDG_CONFIG_HOME/nvim
~//.config/nvim
Config layout<br>TEXT<br>1nvim/<br>2| coc-settings.json<br>3| init.lua<br>4|<br>5\---lua/<br>6 keybindings.lua<br>7 options.lua<br>8 plugin-options.lua<br>9 plugins.lua<br>Create the nvim folder<br>Create the lua folder in the nvim folder<br>create the init.lua file in the nvim folder<br>create the following files in the nvim/lua folder:keybindings.lua: we will create new keybindings here<br>options.lua: general options<br>plugin-options.lua: options for plugins<br>plugins.lua: specify plugins we need
Configuring<br>If any of the following options are not commented well enough, start neovim and run:<br>:help<br>After each step save and reload the config using :source %
Open nvim/init.lua and enter the following configuration:<br>LUA<br>1-- lua automatically adds all .lua<br>2-- files in the nvim/lua directory to the namespace<br>4-- order of import is relevant,<br>5-- plugins have to be installed before configuring them<br>7-- import the options<br>8require("options")<br>9-- import the plugins<br>10require("plugins")<br>11-- import the plugin options<br>12require("plugin-options")<br>13-- import the keybinds<br>14require("keybindings")<br>Open nvim/lua/options.lua and enter the following configuration:<br>LUA<br>1-- bind variables<br>2local g = vim.g<br>3local o = vim.opt<br>5-- set the leader key to space<br>6g.mapleader = " "<br>8-- disable default file tree<br>9g.loaded_netrw = 1<br>10g.loaded_netrwPlugin = 1<br>11g.netrw_banner = 0<br>12g.netrw_winsize = 0<br>13<br>14-- enable line numbers<br>15o.number = true<br>16<br>17-- dont save buffers on closing them<br>18o.hidden = true<br>19<br>20-- enable syntax highlighting<br>21o.syntax = "on"<br>22<br>23-- disable wrapping chars which are out of the current view<br>24o.wrap = false<br>25<br>26-- set encodings<br>27o.encoding = "utf-8"<br>28o.fileencoding = "utf-8"<br>29<br>30-- more space for commands at the bottom<br>31o.cmdheight = 2<br>32<br>33-- enable better splitting<br>34o.splitbelow = true<br>35o.splitright = true<br>36<br>37o.conceallevel = 0<br>38<br>39-- indentation, 4 spaces for a tab<br>40o.tabstop = 4<br>41o.shiftwidth = 4<br>42<br>43-- automatically insert tabs<br>44o.smarttab = true<br>45<br>46-- replace tab with spaces<br>47o.expandtab = true<br>48<br>49-- indent blocks automatically<br>50o.smartindent = true<br>51o.autoindent = true<br>52<br>53-- enable tabline if a tab is there<br>54o.showtabline = 1<br>55<br>56-- dont show mode in the bottom bar<br>57o.showmode = false<br>58<br>59-- set updatetime to 50ms (updates every 50ms)<br>60o.updatetime = 50<br>61o.timeoutlen = 500<br>62<br>63-- enable better colors<br>64o.termguicolors = true<br>65<br>66-- better searching<br>67o.incsearch = true<br>68o.smartcase = true<br>69o.hlsearch = false<br>70<br>71-- disable backups<br>72o.backup = false<br>73o.background = "dark"<br>74<br>75-- display the current line different from the rest of the file<br>76o.cursorline = true<br>77<br>78-- disable swap files<br>79o.swapfile = false<br>Open nvim/lua/plugins.lua and enter the following configuration:<br>LUA<br>1-- i use vimplug to manage my plugins<br>3-- this checks if vimplug is installed, if not install it<br>4vim.cmd([[<br>5if empty(glob('~/.config/nvim/autoload/plug.vim'))<br>6...